@needle-tools/engine 3.41.2-beta → 3.41.2-beta.2

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: `+e.toString())}const s=na()||DE()&&ht();if((
4344
4344
  #__vconsole .vc-mask {
4345
4345
  overflow: hidden;
4346
4346
  }
4347
- `,Ho==null||Ho.prepend(i),s===!0&&$D()<=0&&S8(),console.log("🌵 Debug console has loaded")}},e.src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js",document.body.appendChild(e)}function $ie(){const s=new VConsole.VConsolePlugin("needle-console","🌵 Inspect glTF"),e=()=>document.querySelector("#__vc_plug_"+s._id+" iframe");return s.on("renderTab",function(t){const i=globalThis["needle:codegen_files"];if(!i||i.length===0)return;let n=globalThis["needle:codegen_files"][0];const r=n.indexOf("?");r>-1&&(n=n.substring(0,r));const a=location.protocol+"//"+location.host+location.pathname+"/"+n,c=encodeURIComponent(a);s.fullUrl="https://viewer.needle.tools?inspect&file="+c;var l='<iframe src="" style="width: 100%; height: 99%; border: none;"></iframe>';t(l)}),s.on("show",function(){const t=e();t&&t.src!==s.fullUrl&&(t.src=s.fullUrl)}),s.on("hide",function(){const t=e();t&&(t.src="")}),s.on("addTopBar",function(t){var i=new Array;i.push({name:"Open in new window ↗",onClick:function(n){window.open(s.fullUrl,"_blank"),Yo==null||Yo.hide()}}),i.push({name:"Reload",onClick:function(n){const r=e();r&&(r.src=s.fullUrl)}}),i.push({name:"Fullscreen",onClick:function(n){const r=e();r.requestFullscreen?r.requestFullscreen():r.webkitRequestFullscreen instanceof Function&&r.webkitRequestFullscreen()}}),t(i)}),s}function ene(){const s=document.querySelector("#__vconsole .vc-switch");return s||null}function tne(){const s=document.querySelector("#__vconsole");return s||null}const M8=ie("debugdefines");_A('if(!globalThis[""3.41.2-beta""]) globalThis[""3.41.2-beta""] = "0.0.0";');_A('if(!globalThis[""undefined""]) globalThis[""undefined""] = "unknown";');_A('if(!globalThis[""Tue Jun 25 2024 10:43:45 GMT+0200 (Central European Summer Time)""]) globalThis[""Tue Jun 25 2024 10:43:45 GMT+0200 (Central European Summer Time)""] = "unknown";');_A('globalThis["__NEEDLE_ENGINE_VERSION__"] = "3.41.2-beta";');_A('globalThis["__NEEDLE_ENGINE_GENERATOR__"] = "undefined";');_A('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "Tue Jun 25 2024 10:43:45 GMT+0200 (Central European Summer Time)";');const ka="3.41.2-beta",NE="undefined",D2="Tue Jun 25 2024 10:43:45 GMT+0200 (Central European Summer Time)";M8&&console.log(`Engine version: ${ka} (generator: ${NE})
4347
+ `,Ho==null||Ho.prepend(i),s===!0&&$D()<=0&&S8(),console.log("🌵 Debug console has loaded")}},e.src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js",document.body.appendChild(e)}function $ie(){const s=new VConsole.VConsolePlugin("needle-console","🌵 Inspect glTF"),e=()=>document.querySelector("#__vc_plug_"+s._id+" iframe");return s.on("renderTab",function(t){const i=globalThis["needle:codegen_files"];if(!i||i.length===0)return;let n=globalThis["needle:codegen_files"][0];const r=n.indexOf("?");r>-1&&(n=n.substring(0,r));const a=location.protocol+"//"+location.host+location.pathname+"/"+n,c=encodeURIComponent(a);s.fullUrl="https://viewer.needle.tools?inspect&file="+c;var l='<iframe src="" style="width: 100%; height: 99%; border: none;"></iframe>';t(l)}),s.on("show",function(){const t=e();t&&t.src!==s.fullUrl&&(t.src=s.fullUrl)}),s.on("hide",function(){const t=e();t&&(t.src="")}),s.on("addTopBar",function(t){var i=new Array;i.push({name:"Open in new window ↗",onClick:function(n){window.open(s.fullUrl,"_blank"),Yo==null||Yo.hide()}}),i.push({name:"Reload",onClick:function(n){const r=e();r&&(r.src=s.fullUrl)}}),i.push({name:"Fullscreen",onClick:function(n){const r=e();r.requestFullscreen?r.requestFullscreen():r.webkitRequestFullscreen instanceof Function&&r.webkitRequestFullscreen()}}),t(i)}),s}function ene(){const s=document.querySelector("#__vconsole .vc-switch");return s||null}function tne(){const s=document.querySelector("#__vconsole");return s||null}const M8=ie("debugdefines");_A('if(!globalThis[""3.41.2-beta.2""]) globalThis[""3.41.2-beta.2""] = "0.0.0";');_A('if(!globalThis[""undefined""]) globalThis[""undefined""] = "unknown";');_A('if(!globalThis[""Thu Jun 27 2024 15:15:07 GMT+0200 (Central European Summer Time)""]) globalThis[""Thu Jun 27 2024 15:15:07 GMT+0200 (Central European Summer Time)""] = "unknown";');_A('globalThis["__NEEDLE_ENGINE_VERSION__"] = "3.41.2-beta.2";');_A('globalThis["__NEEDLE_ENGINE_GENERATOR__"] = "undefined";');_A('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "Thu Jun 27 2024 15:15:07 GMT+0200 (Central European Summer Time)";');const ka="3.41.2-beta.2",NE="undefined",D2="Thu Jun 27 2024 15:15:07 GMT+0200 (Central European Summer Time)";M8&&console.log(`Engine version: ${ka} (generator: ${NE})
4348
4348
  Project built at ${D2}`);const Rh="needle_isActiveInHierarchy",_f="builtin_components",F0="needle_editor_guid";function _A(s){try{(0,eval)(s)}catch(e){M8&&console.error(e)}}const ine='<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>',nne=btoa(ine),sne="data:image/svg+xml;base64,"+nne,rne=sne,one=`<?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(one);const ane='<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>',cne=btoa(ane),lne="data:image/svg+xml;charset=utf-8;base64,"+cne,hne=lne,Ba=ie("debuglicense");let zf="basic";Ba&&console.log("License Type: "+zf);function Zu(){switch(zf){case"pro":case"enterprise":return!0}return!1}function k2(){switch(zf){case"indie":return!0}return!1}function Ph(){return Zu()||k2()}const T8=[];function une(s){if(Zu()||k2())return s(!0);T8.push(s)}function dne(s){for(const e of T8)try{e(s)}catch{}}ui.registerCallback(Ti.ContextRegistered,s=>{gne(s.context),Ane(),pne(s.context)});let $u,yR=!1,n0="";async function fne(){if($u)return $u;if(zf==="basic")try{const s="https://engine.needle.tools/licensing/check?location="+encodeURIComponent(window.location.href)+"&version="+ka+"&generator="+encodeURIComponent(NE),e=await fetch(s,{method:"GET"}).catch(t=>{Ba&&console.error("License check failed",t)});(e==null?void 0:e.status)===200?(yR=!1,Ba&&console.log("License check succeeded"),zf="pro",dne(!0)):(e==null?void 0:e.status)===403?(yR=!0,n0=await e.text()):Ba&&console.log("License check failed with status "+(e==null?void 0:e.status))}catch(s){Ba&&console.error("License check failed",s)}else Ba&&console.log('Runtime license check is skipped because license is already applied as "'+zf+'"')}$u=fne();async function pne(s){function e(){const n=document.createElement("div");n.className="needle-forbidden",n.style.cssText=`
4349
4349
  position: fixed;
4350
4350
  top: 0;
@@ -4415,7 +4415,7 @@ CLICK HERE TO GET A LICENSE`,i.style.cursor="pointer",i.style.userSelect="none",
4415
4415
  * SPDX-License-Identifier: MIT
4416
4416
  */const vR="162",lS=0,_ne=1,xne=2,cU=1,lU=100,hU=204,uU=205,dU=3,wne=0,fU="attached",Cne="detached",P8=300,Sne=301,Dv=1e3,Pf=1001,bR=1002,fp=1003,Ene=1004,Ine=1005,kv=1006,Mne=1007,QE=1008,Ea=1009,Tne=1014,Gf=1015,uC=1016,Bne=1020,Hu=1023,eM=1026,pU=1027,ym=1028,s0=1030,Rne=33776,Pne=33779,Dne=35840,kne=35842,One=36196,Lne=37492,Fne=37496,Une=37808,gU=37812,Nne=36492,Ov=2300,rA=2301,tM=2302,mU=2400,AU=2401,yU=2402,Qne=2500,zne=0,D8=1,_R=2,Gne=0,hS="",Er="srgb",Co="srgb-linear",k8="display-p3",L2="display-p3-linear",xR="linear",vU="srgb",bU="rec709",_U="p3",Cg=7680,xU=519,Hne=515,wR=35044,Df=2e3,CR=2001;class zE{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;const i=this._listeners;return i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;const n=this._listeners[e];if(n!==void 0){const r=n.indexOf(t);r!==-1&&n.splice(r,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const i=this._listeners[e.type];if(i!==void 0){e.target=this;const n=i.slice(0);for(let r=0,o=n.length;r<o;r++)n[r].call(this,e);e.target=null}}}const Ar=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let wU=1234567;const N0=Math.PI/180,Lv=180/Math.PI;function xc(){const s=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(Ar[s&255]+Ar[s>>8&255]+Ar[s>>16&255]+Ar[s>>24&255]+"-"+Ar[e&255]+Ar[e>>8&255]+"-"+Ar[e>>16&15|64]+Ar[e>>24&255]+"-"+Ar[t&63|128]+Ar[t>>8&255]+"-"+Ar[t>>16&255]+Ar[t>>24&255]+Ar[i&255]+Ar[i>>8&255]+Ar[i>>16&255]+Ar[i>>24&255]).toLowerCase()}function Ir(s,e,t){return Math.max(e,Math.min(t,s))}function F2(s,e){return(s%e+e)%e}function Vne(s,e,t,i,n){return i+(s-e)*(n-i)/(t-e)}function jne(s,e,t){return s!==e?(t-s)/(e-s):0}function Q0(s,e,t){return(1-t)*s+t*e}function Wne(s,e,t,i){return Q0(s,e,1-Math.exp(-t*i))}function qne(s,e=1){return e-Math.abs(F2(s,e*2)-e)}function Xne(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*(3-2*s))}function Yne(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*s*(s*(s*6-15)+10))}function Jne(s,e){return s+Math.floor(Math.random()*(e-s+1))}function Kne(s,e){return s+Math.random()*(e-s)}function Zne(s){return s*(.5-Math.random())}function $ne(s){s!==void 0&&(wU=s);let e=wU+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function ese(s){return s*N0}function tse(s){return s*Lv}function ise(s){return(s&s-1)===0&&s!==0}function nse(s){return Math.pow(2,Math.ceil(Math.log(s)/Math.LN2))}function sse(s){return Math.pow(2,Math.floor(Math.log(s)/Math.LN2))}function rse(s,e,t,i,n){const r=Math.cos,o=Math.sin,a=r(t/2),c=o(t/2),l=r((e+i)/2),h=o((e+i)/2),u=r((e-i)/2),f=o((e-i)/2),p=r((i-e)/2),g=o((i-e)/2);switch(n){case"XYX":s.set(a*h,c*u,c*f,a*l);break;case"YZY":s.set(c*f,a*h,c*u,a*l);break;case"ZXZ":s.set(c*u,c*f,a*h,a*l);break;case"XZX":s.set(a*h,c*g,c*p,a*l);break;case"YXY":s.set(c*p,a*h,c*g,a*l);break;case"ZYZ":s.set(c*g,c*p,a*h,a*l);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+n)}}function fc(s,e){switch(e.constructor){case Float32Array:return s;case Uint32Array:return s/4294967295;case Uint16Array:return s/65535;case Uint8Array:return s/255;case Int32Array:return Math.max(s/2147483647,-1);case Int16Array:return Math.max(s/32767,-1);case Int8Array:return Math.max(s/127,-1);default:throw new Error("Invalid component type.")}}function Oi(s,e){switch(e.constructor){case Float32Array:return s;case Uint32Array:return Math.round(s*4294967295);case Uint16Array:return Math.round(s*65535);case Uint8Array:return Math.round(s*255);case Int32Array:return Math.round(s*2147483647);case Int16Array:return Math.round(s*32767);case Int8Array:return Math.round(s*127);default:throw new Error("Invalid component type.")}}const ose={DEG2RAD:N0,RAD2DEG:Lv,generateUUID:xc,clamp:Ir,euclideanModulo:F2,mapLinear:Vne,inverseLerp:jne,lerp:Q0,damp:Wne,pingpong:qne,smoothstep:Xne,smootherstep:Yne,randInt:Jne,randFloat:Kne,randFloatSpread:Zne,seededRandom:$ne,degToRad:ese,radToDeg:tse,isPowerOfTwo:ise,ceilPowerOfTwo:nse,floorPowerOfTwo:sse,setQuaternionFromProperEuler:rse,normalize:Oi,denormalize:fc};class Sn{constructor(e=0,t=0){Sn.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,i=this.y,n=e.elements;return this.x=n[0]*t+n[3]*i+n[6],this.y=n[1]*t+n[4]*i+n[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(Ir(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const i=Math.cos(t),n=Math.sin(t),r=this.x-e.x,o=this.y-e.y;return this.x=r*i-o*n+e.x,this.y=r*n+o*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class zh{constructor(e,t,i,n,r,o,a,c,l){zh.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,n,r,o,a,c,l)}set(e,t,i,n,r,o,a,c,l){const h=this.elements;return h[0]=e,h[1]=n,h[2]=a,h[3]=t,h[4]=r,h[5]=c,h[6]=i,h[7]=o,h[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,n=t.elements,r=this.elements,o=i[0],a=i[3],c=i[6],l=i[1],h=i[4],u=i[7],f=i[2],p=i[5],g=i[8],y=n[0],m=n[3],A=n[6],b=n[1],v=n[4],_=n[7],w=n[2],E=n[5],I=n[8];return r[0]=o*y+a*b+c*w,r[3]=o*m+a*v+c*E,r[6]=o*A+a*_+c*I,r[1]=l*y+h*b+u*w,r[4]=l*m+h*v+u*E,r[7]=l*A+h*_+u*I,r[2]=f*y+p*b+g*w,r[5]=f*m+p*v+g*E,r[8]=f*A+p*_+g*I,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[1],n=e[2],r=e[3],o=e[4],a=e[5],c=e[6],l=e[7],h=e[8];return t*o*h-t*a*l-i*r*h+i*a*c+n*r*l-n*o*c}invert(){const e=this.elements,t=e[0],i=e[1],n=e[2],r=e[3],o=e[4],a=e[5],c=e[6],l=e[7],h=e[8],u=h*o-a*l,f=a*c-h*r,p=l*r-o*c,g=t*u+i*f+n*p;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const y=1/g;return e[0]=u*y,e[1]=(n*l-h*i)*y,e[2]=(a*i-n*o)*y,e[3]=f*y,e[4]=(h*t-n*c)*y,e[5]=(n*r-a*t)*y,e[6]=p*y,e[7]=(i*c-l*t)*y,e[8]=(o*t-i*r)*y,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,n,r,o,a){const c=Math.cos(r),l=Math.sin(r);return this.set(i*c,i*l,-i*(c*o+l*a)+o+e,-n*l,n*c,-n*(-l*o+c*a)+a+t,0,0,1),this}scale(e,t){return this.premultiply(iM.makeScale(e,t)),this}rotate(e){return this.premultiply(iM.makeRotation(-e)),this}translate(e,t){return this.premultiply(iM.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,i=e.elements;for(let n=0;n<9;n++)if(t[n]!==i[n])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const iM=new zh;function ase(s){for(let e=s.length-1;e>=0;--e)if(s[e]>=65535)return!0;return!1}function SR(s){return document.createElementNS("http://www.w3.org/1999/xhtml",s)}const CU={};function O8(s){s in CU||(CU[s]=!0,console.warn(s))}const SU=new zh().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),EU=new zh().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),Sx={[Co]:{transfer:xR,primaries:bU,toReference:s=>s,fromReference:s=>s},[Er]:{transfer:vU,primaries:bU,toReference:s=>s.convertSRGBToLinear(),fromReference:s=>s.convertLinearToSRGB()},[L2]:{transfer:xR,primaries:_U,toReference:s=>s.applyMatrix3(EU),fromReference:s=>s.applyMatrix3(SU)},[k8]:{transfer:vU,primaries:_U,toReference:s=>s.convertSRGBToLinear().applyMatrix3(EU),fromReference:s=>s.applyMatrix3(SU).convertLinearToSRGB()}},cse=new Set([Co,L2]),Uo={enabled:!0,_workingColorSpace:Co,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(s){if(!cse.has(s))throw new Error(`Unsupported working color space, "${s}".`);this._workingColorSpace=s},convert:function(s,e,t){if(this.enabled===!1||e===t||!e||!t)return s;const i=Sx[e].toReference,n=Sx[t].fromReference;return n(i(s))},fromWorkingColorSpace:function(s,e){return this.convert(s,this._workingColorSpace,e)},toWorkingColorSpace:function(s,e){return this.convert(s,e,this._workingColorSpace)},getPrimaries:function(s){return Sx[s].primaries},getTransfer:function(s){return s===hS?xR:Sx[s].transfer}};function Lm(s){return s<.04045?s*.0773993808:Math.pow(s*.9478672986+.0521327014,2.4)}function nM(s){return s<.0031308?s*12.92:1.055*Math.pow(s,.41666)-.055}let Sg;class lse{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{Sg===void 0&&(Sg=SR("canvas")),Sg.width=e.width,Sg.height=e.height;const i=Sg.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),t=Sg}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=SR("canvas");t.width=e.width,t.height=e.height;const i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);const n=i.getImageData(0,0,e.width,e.height),r=n.data;for(let o=0;o<r.length;o++)r[o]=Lm(r[o]/255)*255;return i.putImageData(n,0,0),t}else if(e.data){const t=e.data.slice(0);for(let i=0;i<t.length;i++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[i]=Math.floor(Lm(t[i]/255)*255):t[i]=Lm(t[i]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let hse=0;class use{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:hse++}),this.uuid=xc(),this.data=e,this.dataReady=!0,this.version=0}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const i={uuid:this.uuid,url:""},n=this.data;if(n!==null){let r;if(Array.isArray(n)){r=[];for(let o=0,a=n.length;o<a;o++)n[o].isDataTexture?r.push(sM(n[o].image)):r.push(sM(n[o]))}else r=sM(n);i.url=r}return t||(e.images[this.uuid]=i),i}}function sM(s){return typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&s instanceof ImageBitmap?lse.getDataURL(s):s.data?{data:Array.from(s.data),width:s.width,height:s.height,type:s.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let dse=0;class ms extends zE{constructor(e=ms.DEFAULT_IMAGE,t=ms.DEFAULT_MAPPING,i=Pf,n=Pf,r=kv,o=QE,a=Hu,c=Ea,l=ms.DEFAULT_ANISOTROPY,h=hS){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:dse++}),this.uuid=xc(),this.name="",this.source=new use(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=i,this.wrapT=n,this.magFilter=r,this.minFilter=o,this.anisotropy=l,this.format=a,this.internalFormat=null,this.type=c,this.offset=new Sn(0,0),this.repeat=new Sn(1,1),this.center=new Sn(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new zh,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.needsPMREMUpdate=!1}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const i={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==P8)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Dv:e.x=e.x-Math.floor(e.x);break;case Pf:e.x=e.x<0?0:1;break;case bR:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Dv:e.y=e.y-Math.floor(e.y);break;case Pf:e.y=e.y<0?0:1;break;case bR:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}}ms.DEFAULT_IMAGE=null;ms.DEFAULT_MAPPING=P8;ms.DEFAULT_ANISOTROPY=1;class Ta{constructor(e=0,t=0,i=0,n=1){Ta.prototype.isVector4=!0,this.x=e,this.y=t,this.z=i,this.w=n}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,n){return this.x=e,this.y=t,this.z=i,this.w=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,i=this.y,n=this.z,r=this.w,o=e.elements;return this.x=o[0]*t+o[4]*i+o[8]*n+o[12]*r,this.y=o[1]*t+o[5]*i+o[9]*n+o[13]*r,this.z=o[2]*t+o[6]*i+o[10]*n+o[14]*r,this.w=o[3]*t+o[7]*i+o[11]*n+o[15]*r,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,n,r;const c=e.elements,l=c[0],h=c[4],u=c[8],f=c[1],p=c[5],g=c[9],y=c[2],m=c[6],A=c[10];if(Math.abs(h-f)<.01&&Math.abs(u-y)<.01&&Math.abs(g-m)<.01){if(Math.abs(h+f)<.1&&Math.abs(u+y)<.1&&Math.abs(g+m)<.1&&Math.abs(l+p+A-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const v=(l+1)/2,_=(p+1)/2,w=(A+1)/2,E=(h+f)/4,I=(u+y)/4,M=(g+m)/4;return v>_&&v>w?v<.01?(i=0,n=.707106781,r=.707106781):(i=Math.sqrt(v),n=E/i,r=I/i):_>w?_<.01?(i=.707106781,n=0,r=.707106781):(n=Math.sqrt(_),i=E/n,r=M/n):w<.01?(i=.707106781,n=.707106781,r=0):(r=Math.sqrt(w),i=I/r,n=M/r),this.set(i,n,r,t),this}let b=Math.sqrt((m-g)*(m-g)+(u-y)*(u-y)+(f-h)*(f-h));return Math.abs(b)<.001&&(b=1),this.x=(m-g)/b,this.y=(u-y)/b,this.z=(f-h)/b,this.w=Math.acos((l+p+A-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class fse extends ms{constructor(e=null,t=1,i=1,n=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:i,depth:n},this.magFilter=fp,this.minFilter=fp,this.wrapR=Pf,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class bd{constructor(e=0,t=0,i=0,n=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=n}static slerpFlat(e,t,i,n,r,o,a){let c=i[n+0],l=i[n+1],h=i[n+2],u=i[n+3];const f=r[o+0],p=r[o+1],g=r[o+2],y=r[o+3];if(a===0){e[t+0]=c,e[t+1]=l,e[t+2]=h,e[t+3]=u;return}if(a===1){e[t+0]=f,e[t+1]=p,e[t+2]=g,e[t+3]=y;return}if(u!==y||c!==f||l!==p||h!==g){let m=1-a;const A=c*f+l*p+h*g+u*y,b=A>=0?1:-1,v=1-A*A;if(v>Number.EPSILON){const w=Math.sqrt(v),E=Math.atan2(w,A*b);m=Math.sin(m*E)/w,a=Math.sin(a*E)/w}const _=a*b;if(c=c*m+f*_,l=l*m+p*_,h=h*m+g*_,u=u*m+y*_,m===1-a){const w=1/Math.sqrt(c*c+l*l+h*h+u*u);c*=w,l*=w,h*=w,u*=w}}e[t]=c,e[t+1]=l,e[t+2]=h,e[t+3]=u}static multiplyQuaternionsFlat(e,t,i,n,r,o){const a=i[n],c=i[n+1],l=i[n+2],h=i[n+3],u=r[o],f=r[o+1],p=r[o+2],g=r[o+3];return e[t]=a*g+h*u+c*p-l*f,e[t+1]=c*g+h*f+l*u-a*p,e[t+2]=l*g+h*p+a*f-c*u,e[t+3]=h*g-a*u-c*f-l*p,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,n){return this._x=e,this._y=t,this._z=i,this._w=n,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const i=e._x,n=e._y,r=e._z,o=e._order,a=Math.cos,c=Math.sin,l=a(i/2),h=a(n/2),u=a(r/2),f=c(i/2),p=c(n/2),g=c(r/2);switch(o){case"XYZ":this._x=f*h*u+l*p*g,this._y=l*p*u-f*h*g,this._z=l*h*g+f*p*u,this._w=l*h*u-f*p*g;break;case"YXZ":this._x=f*h*u+l*p*g,this._y=l*p*u-f*h*g,this._z=l*h*g-f*p*u,this._w=l*h*u+f*p*g;break;case"ZXY":this._x=f*h*u-l*p*g,this._y=l*p*u+f*h*g,this._z=l*h*g+f*p*u,this._w=l*h*u-f*p*g;break;case"ZYX":this._x=f*h*u-l*p*g,this._y=l*p*u+f*h*g,this._z=l*h*g-f*p*u,this._w=l*h*u+f*p*g;break;case"YZX":this._x=f*h*u+l*p*g,this._y=l*p*u+f*h*g,this._z=l*h*g-f*p*u,this._w=l*h*u-f*p*g;break;case"XZY":this._x=f*h*u-l*p*g,this._y=l*p*u-f*h*g,this._z=l*h*g+f*p*u,this._w=l*h*u+f*p*g;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const i=t/2,n=Math.sin(i);return this._x=e.x*n,this._y=e.y*n,this._z=e.z*n,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,i=t[0],n=t[4],r=t[8],o=t[1],a=t[5],c=t[9],l=t[2],h=t[6],u=t[10],f=i+a+u;if(f>0){const p=.5/Math.sqrt(f+1);this._w=.25/p,this._x=(h-c)*p,this._y=(r-l)*p,this._z=(o-n)*p}else if(i>a&&i>u){const p=2*Math.sqrt(1+i-a-u);this._w=(h-c)/p,this._x=.25*p,this._y=(n+o)/p,this._z=(r+l)/p}else if(a>u){const p=2*Math.sqrt(1+a-i-u);this._w=(r-l)/p,this._x=(n+o)/p,this._y=.25*p,this._z=(c+h)/p}else{const p=2*Math.sqrt(1+u-i-a);this._w=(o-n)/p,this._x=(r+l)/p,this._y=(c+h)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<Number.EPSILON?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Ir(this.dot(e),-1,1)))}rotateTowards(e,t){const i=this.angleTo(e);if(i===0)return this;const n=Math.min(1,t/i);return this.slerp(e,n),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const i=e._x,n=e._y,r=e._z,o=e._w,a=t._x,c=t._y,l=t._z,h=t._w;return this._x=i*h+o*a+n*l-r*c,this._y=n*h+o*c+r*a-i*l,this._z=r*h+o*l+i*c-n*a,this._w=o*h-i*a-n*c-r*l,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const i=this._x,n=this._y,r=this._z,o=this._w;let a=o*e._w+i*e._x+n*e._y+r*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=o,this._x=i,this._y=n,this._z=r,this;const c=1-a*a;if(c<=Number.EPSILON){const p=1-t;return this._w=p*o+t*this._w,this._x=p*i+t*this._x,this._y=p*n+t*this._y,this._z=p*r+t*this._z,this.normalize(),this}const l=Math.sqrt(c),h=Math.atan2(l,a),u=Math.sin((1-t)*h)/l,f=Math.sin(t*h)/l;return this._w=o*u+this._w*f,this._x=i*u+this._x*f,this._y=n*u+this._y*f,this._z=r*u+this._z*f,this._onChangeCallback(),this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),i=Math.random(),n=Math.sqrt(1-i),r=Math.sqrt(i);return this.set(n*Math.sin(e),n*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class ue{constructor(e=0,t=0,i=0){ue.prototype.isVector3=!0,this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(IU.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(IU.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,n=this.z,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6]*n,this.y=r[1]*t+r[4]*i+r[7]*n,this.z=r[2]*t+r[5]*i+r[8]*n,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,n=this.z,r=e.elements,o=1/(r[3]*t+r[7]*i+r[11]*n+r[15]);return this.x=(r[0]*t+r[4]*i+r[8]*n+r[12])*o,this.y=(r[1]*t+r[5]*i+r[9]*n+r[13])*o,this.z=(r[2]*t+r[6]*i+r[10]*n+r[14])*o,this}applyQuaternion(e){const t=this.x,i=this.y,n=this.z,r=e.x,o=e.y,a=e.z,c=e.w,l=2*(o*n-a*i),h=2*(a*t-r*n),u=2*(r*i-o*t);return this.x=t+c*l+o*u-a*h,this.y=i+c*h+a*l-r*u,this.z=n+c*u+r*h-o*l,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,i=this.y,n=this.z,r=e.elements;return this.x=r[0]*t+r[4]*i+r[8]*n,this.y=r[1]*t+r[5]*i+r[9]*n,this.z=r[2]*t+r[6]*i+r[10]*n,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const i=e.x,n=e.y,r=e.z,o=t.x,a=t.y,c=t.z;return this.x=n*c-r*a,this.y=r*o-i*c,this.z=i*a-n*o,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return rM.copy(this).projectOnVector(e),this.sub(rM)}reflect(e){return this.sub(rM.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(Ir(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y,n=this.z-e.z;return t*t+i*i+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){const n=Math.sin(t)*e;return this.x=n*Math.sin(i),this.y=Math.cos(t)*e,this.z=n*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),n=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=n,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,i=Math.sqrt(1-t*t);return this.x=i*Math.cos(e),this.y=t,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const rM=new ue,IU=new bd;class Cc{constructor(e=new ue(1/0,1/0,1/0),t=new ue(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t+=3)this.expandByPoint(ec.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,i=e.count;t<i;t++)this.expandByPoint(ec.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const i=ec.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const i=e.geometry;if(i!==void 0){const r=i.getAttribute("position");if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let o=0,a=r.count;o<a;o++)e.isMesh===!0?e.getVertexPosition(o,ec):ec.fromBufferAttribute(r,o),ec.applyMatrix4(e.matrixWorld),this.expandByPoint(ec);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Ex.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),Ex.copy(i.boundingBox)),Ex.applyMatrix4(e.matrixWorld),this.union(Ex)}const n=e.children;for(let r=0,o=n.length;r<o;r++)this.expandByObject(n[r],t);return this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)}intersectsSphere(e){return this.clampPoint(e.center,ec),ec.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(by),Ix.subVectors(this.max,by),Eg.subVectors(e.a,by),Ig.subVectors(e.b,by),Mg.subVectors(e.c,by),au.subVectors(Ig,Eg),cu.subVectors(Mg,Ig),Yd.subVectors(Eg,Mg);let t=[0,-au.z,au.y,0,-cu.z,cu.y,0,-Yd.z,Yd.y,au.z,0,-au.x,cu.z,0,-cu.x,Yd.z,0,-Yd.x,-au.y,au.x,0,-cu.y,cu.x,0,-Yd.y,Yd.x,0];return!oM(t,Eg,Ig,Mg,Ix)||(t=[1,0,0,0,1,0,0,0,1],!oM(t,Eg,Ig,Mg,Ix))?!1:(Mx.crossVectors(au,cu),t=[Mx.x,Mx.y,Mx.z],oM(t,Eg,Ig,Mg,Ix))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,ec).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(ec).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Wl[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Wl[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Wl[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Wl[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Wl[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Wl[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Wl[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Wl[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Wl),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const Wl=[new ue,new ue,new ue,new ue,new ue,new ue,new ue,new ue],ec=new ue,Ex=new Cc,Eg=new ue,Ig=new ue,Mg=new ue,au=new ue,cu=new ue,Yd=new ue,by=new ue,Ix=new ue,Mx=new ue,Jd=new ue;function oM(s,e,t,i,n){for(let r=0,o=s.length-3;r<=o;r+=3){Jd.fromArray(s,r);const a=n.x*Math.abs(Jd.x)+n.y*Math.abs(Jd.y)+n.z*Math.abs(Jd.z),c=e.dot(Jd),l=t.dot(Jd),h=i.dot(Jd);if(Math.max(-Math.max(c,l,h),Math.min(c,l,h))>a)return!1}return!0}const pse=new Cc,_y=new ue,aM=new ue;class Bc{constructor(e=new ue,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const i=this.center;t!==void 0?i.copy(t):pse.setFromPoints(e).getCenter(i);let n=0;for(let r=0,o=e.length;r<o;r++)n=Math.max(n,i.distanceToSquared(e[r]));return this.radius=Math.sqrt(n),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const i=this.center.distanceToSquared(e);return t.copy(e),i>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;_y.subVectors(e,this.center);const t=_y.lengthSq();if(t>this.radius*this.radius){const i=Math.sqrt(t),n=(i-this.radius)*.5;this.center.addScaledVector(_y,n/i),this.radius+=n}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(aM.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(_y.copy(e.center).add(aM)),this.expandByPoint(_y.copy(e.center).sub(aM))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const ql=new ue,cM=new ue,Tx=new ue,lu=new ue,lM=new ue,Bx=new ue,hM=new ue;class GE{constructor(e=new ue,t=new ue(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,ql)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=ql.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(ql.copy(this.origin).addScaledVector(this.direction,t),ql.distanceToSquared(e))}distanceSqToSegment(e,t,i,n){cM.copy(e).add(t).multiplyScalar(.5),Tx.copy(t).sub(e).normalize(),lu.copy(this.origin).sub(cM);const r=e.distanceTo(t)*.5,o=-this.direction.dot(Tx),a=lu.dot(this.direction),c=-lu.dot(Tx),l=lu.lengthSq(),h=Math.abs(1-o*o);let u,f,p,g;if(h>0)if(u=o*c-a,f=o*a-c,g=r*h,u>=0)if(f>=-g)if(f<=g){const y=1/h;u*=y,f*=y,p=u*(u+o*f+2*a)+f*(o*u+f+2*c)+l}else f=r,u=Math.max(0,-(o*f+a)),p=-u*u+f*(f+2*c)+l;else f=-r,u=Math.max(0,-(o*f+a)),p=-u*u+f*(f+2*c)+l;else f<=-g?(u=Math.max(0,-(-o*r+a)),f=u>0?-r:Math.min(Math.max(-r,-c),r),p=-u*u+f*(f+2*c)+l):f<=g?(u=0,f=Math.min(Math.max(-r,-c),r),p=f*(f+2*c)+l):(u=Math.max(0,-(o*r+a)),f=u>0?r:Math.min(Math.max(-r,-c),r),p=-u*u+f*(f+2*c)+l);else f=o>0?-r:r,u=Math.max(0,-(o*f+a)),p=-u*u+f*(f+2*c)+l;return i&&i.copy(this.origin).addScaledVector(this.direction,u),n&&n.copy(cM).addScaledVector(Tx,f),p}intersectSphere(e,t){ql.subVectors(e.center,this.origin);const i=ql.dot(this.direction),n=ql.dot(ql)-i*i,r=e.radius*e.radius;if(n>r)return null;const o=Math.sqrt(r-n),a=i-o,c=i+o;return c<0?null:a<0?this.at(c,t):this.at(a,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){const i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,n,r,o,a,c;const l=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,f=this.origin;return l>=0?(i=(e.min.x-f.x)*l,n=(e.max.x-f.x)*l):(i=(e.max.x-f.x)*l,n=(e.min.x-f.x)*l),h>=0?(r=(e.min.y-f.y)*h,o=(e.max.y-f.y)*h):(r=(e.max.y-f.y)*h,o=(e.min.y-f.y)*h),i>o||r>n||((r>i||isNaN(i))&&(i=r),(o<n||isNaN(n))&&(n=o),u>=0?(a=(e.min.z-f.z)*u,c=(e.max.z-f.z)*u):(a=(e.max.z-f.z)*u,c=(e.min.z-f.z)*u),i>c||a>n)||((a>i||i!==i)&&(i=a),(c<n||n!==n)&&(n=c),n<0)?null:this.at(i>=0?i:n,t)}intersectsBox(e){return this.intersectBox(e,ql)!==null}intersectTriangle(e,t,i,n,r){lM.subVectors(t,e),Bx.subVectors(i,e),hM.crossVectors(lM,Bx);let o=this.direction.dot(hM),a;if(o>0){if(n)return null;a=1}else if(o<0)a=-1,o=-o;else return null;lu.subVectors(this.origin,e);const c=a*this.direction.dot(Bx.crossVectors(lu,Bx));if(c<0)return null;const l=a*this.direction.dot(lM.cross(lu));if(l<0||c+l>o)return null;const h=-a*lu.dot(hM);return h<0?null:this.at(h/o,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class ai{constructor(e,t,i,n,r,o,a,c,l,h,u,f,p,g,y,m){ai.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,i,n,r,o,a,c,l,h,u,f,p,g,y,m)}set(e,t,i,n,r,o,a,c,l,h,u,f,p,g,y,m){const A=this.elements;return A[0]=e,A[4]=t,A[8]=i,A[12]=n,A[1]=r,A[5]=o,A[9]=a,A[13]=c,A[2]=l,A[6]=h,A[10]=u,A[14]=f,A[3]=p,A[7]=g,A[11]=y,A[15]=m,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new ai().fromArray(this.elements)}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){const t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,i){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,i=e.elements,n=1/Tg.setFromMatrixColumn(e,0).length(),r=1/Tg.setFromMatrixColumn(e,1).length(),o=1/Tg.setFromMatrixColumn(e,2).length();return t[0]=i[0]*n,t[1]=i[1]*n,t[2]=i[2]*n,t[3]=0,t[4]=i[4]*r,t[5]=i[5]*r,t[6]=i[6]*r,t[7]=0,t[8]=i[8]*o,t[9]=i[9]*o,t[10]=i[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,i=e.x,n=e.y,r=e.z,o=Math.cos(i),a=Math.sin(i),c=Math.cos(n),l=Math.sin(n),h=Math.cos(r),u=Math.sin(r);if(e.order==="XYZ"){const f=o*h,p=o*u,g=a*h,y=a*u;t[0]=c*h,t[4]=-c*u,t[8]=l,t[1]=p+g*l,t[5]=f-y*l,t[9]=-a*c,t[2]=y-f*l,t[6]=g+p*l,t[10]=o*c}else if(e.order==="YXZ"){const f=c*h,p=c*u,g=l*h,y=l*u;t[0]=f+y*a,t[4]=g*a-p,t[8]=o*l,t[1]=o*u,t[5]=o*h,t[9]=-a,t[2]=p*a-g,t[6]=y+f*a,t[10]=o*c}else if(e.order==="ZXY"){const f=c*h,p=c*u,g=l*h,y=l*u;t[0]=f-y*a,t[4]=-o*u,t[8]=g+p*a,t[1]=p+g*a,t[5]=o*h,t[9]=y-f*a,t[2]=-o*l,t[6]=a,t[10]=o*c}else if(e.order==="ZYX"){const f=o*h,p=o*u,g=a*h,y=a*u;t[0]=c*h,t[4]=g*l-p,t[8]=f*l+y,t[1]=c*u,t[5]=y*l+f,t[9]=p*l-g,t[2]=-l,t[6]=a*c,t[10]=o*c}else if(e.order==="YZX"){const f=o*c,p=o*l,g=a*c,y=a*l;t[0]=c*h,t[4]=y-f*u,t[8]=g*u+p,t[1]=u,t[5]=o*h,t[9]=-a*h,t[2]=-l*h,t[6]=p*u+g,t[10]=f-y*u}else if(e.order==="XZY"){const f=o*c,p=o*l,g=a*c,y=a*l;t[0]=c*h,t[4]=-u,t[8]=l*h,t[1]=f*u+y,t[5]=o*h,t[9]=p*u-g,t[2]=g*u-p,t[6]=a*h,t[10]=y*u+f}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(gse,e,mse)}lookAt(e,t,i){const n=this.elements;return Oo.subVectors(e,t),Oo.lengthSq()===0&&(Oo.z=1),Oo.normalize(),hu.crossVectors(i,Oo),hu.lengthSq()===0&&(Math.abs(i.z)===1?Oo.x+=1e-4:Oo.z+=1e-4,Oo.normalize(),hu.crossVectors(i,Oo)),hu.normalize(),Rx.crossVectors(Oo,hu),n[0]=hu.x,n[4]=Rx.x,n[8]=Oo.x,n[1]=hu.y,n[5]=Rx.y,n[9]=Oo.y,n[2]=hu.z,n[6]=Rx.z,n[10]=Oo.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,n=t.elements,r=this.elements,o=i[0],a=i[4],c=i[8],l=i[12],h=i[1],u=i[5],f=i[9],p=i[13],g=i[2],y=i[6],m=i[10],A=i[14],b=i[3],v=i[7],_=i[11],w=i[15],E=n[0],I=n[4],M=n[8],R=n[12],S=n[1],T=n[5],F=n[9],U=n[13],k=n[2],H=n[6],D=n[10],L=n[14],N=n[3],W=n[7],X=n[11],se=n[15];return r[0]=o*E+a*S+c*k+l*N,r[4]=o*I+a*T+c*H+l*W,r[8]=o*M+a*F+c*D+l*X,r[12]=o*R+a*U+c*L+l*se,r[1]=h*E+u*S+f*k+p*N,r[5]=h*I+u*T+f*H+p*W,r[9]=h*M+u*F+f*D+p*X,r[13]=h*R+u*U+f*L+p*se,r[2]=g*E+y*S+m*k+A*N,r[6]=g*I+y*T+m*H+A*W,r[10]=g*M+y*F+m*D+A*X,r[14]=g*R+y*U+m*L+A*se,r[3]=b*E+v*S+_*k+w*N,r[7]=b*I+v*T+_*H+w*W,r[11]=b*M+v*F+_*D+w*X,r[15]=b*R+v*U+_*L+w*se,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[4],n=e[8],r=e[12],o=e[1],a=e[5],c=e[9],l=e[13],h=e[2],u=e[6],f=e[10],p=e[14],g=e[3],y=e[7],m=e[11],A=e[15];return g*(+r*c*u-n*l*u-r*a*f+i*l*f+n*a*p-i*c*p)+y*(+t*c*p-t*l*f+r*o*f-n*o*p+n*l*h-r*c*h)+m*(+t*l*u-t*a*p-r*o*u+i*o*p+r*a*h-i*l*h)+A*(-n*a*h-t*c*u+t*a*f+n*o*u-i*o*f+i*c*h)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,i){const n=this.elements;return e.isVector3?(n[12]=e.x,n[13]=e.y,n[14]=e.z):(n[12]=e,n[13]=t,n[14]=i),this}invert(){const e=this.elements,t=e[0],i=e[1],n=e[2],r=e[3],o=e[4],a=e[5],c=e[6],l=e[7],h=e[8],u=e[9],f=e[10],p=e[11],g=e[12],y=e[13],m=e[14],A=e[15],b=u*m*l-y*f*l+y*c*p-a*m*p-u*c*A+a*f*A,v=g*f*l-h*m*l-g*c*p+o*m*p+h*c*A-o*f*A,_=h*y*l-g*u*l+g*a*p-o*y*p-h*a*A+o*u*A,w=g*u*c-h*y*c-g*a*f+o*y*f+h*a*m-o*u*m,E=t*b+i*v+n*_+r*w;if(E===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const I=1/E;return e[0]=b*I,e[1]=(y*f*r-u*m*r-y*n*p+i*m*p+u*n*A-i*f*A)*I,e[2]=(a*m*r-y*c*r+y*n*l-i*m*l-a*n*A+i*c*A)*I,e[3]=(u*c*r-a*f*r-u*n*l+i*f*l+a*n*p-i*c*p)*I,e[4]=v*I,e[5]=(h*m*r-g*f*r+g*n*p-t*m*p-h*n*A+t*f*A)*I,e[6]=(g*c*r-o*m*r-g*n*l+t*m*l+o*n*A-t*c*A)*I,e[7]=(o*f*r-h*c*r+h*n*l-t*f*l-o*n*p+t*c*p)*I,e[8]=_*I,e[9]=(g*u*r-h*y*r-g*i*p+t*y*p+h*i*A-t*u*A)*I,e[10]=(o*y*r-g*a*r+g*i*l-t*y*l-o*i*A+t*a*A)*I,e[11]=(h*a*r-o*u*r-h*i*l+t*u*l+o*i*p-t*a*p)*I,e[12]=w*I,e[13]=(h*y*n-g*u*n+g*i*f-t*y*f-h*i*m+t*u*m)*I,e[14]=(g*a*n-o*y*n-g*i*c+t*y*c+o*i*m-t*a*m)*I,e[15]=(o*u*n-h*a*n+h*i*c-t*u*c-o*i*f+t*a*f)*I,this}scale(e){const t=this.elements,i=e.x,n=e.y,r=e.z;return t[0]*=i,t[4]*=n,t[8]*=r,t[1]*=i,t[5]*=n,t[9]*=r,t[2]*=i,t[6]*=n,t[10]*=r,t[3]*=i,t[7]*=n,t[11]*=r,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],n=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,n))}makeTranslation(e,t,i){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const i=Math.cos(t),n=Math.sin(t),r=1-i,o=e.x,a=e.y,c=e.z,l=r*o,h=r*a;return this.set(l*o+i,l*a-n*c,l*c+n*a,0,l*a+n*c,h*a+i,h*c-n*o,0,l*c-n*a,h*c+n*o,r*c*c+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,n,r,o){return this.set(1,i,r,0,e,1,o,0,t,n,1,0,0,0,0,1),this}compose(e,t,i){const n=this.elements,r=t._x,o=t._y,a=t._z,c=t._w,l=r+r,h=o+o,u=a+a,f=r*l,p=r*h,g=r*u,y=o*h,m=o*u,A=a*u,b=c*l,v=c*h,_=c*u,w=i.x,E=i.y,I=i.z;return n[0]=(1-(y+A))*w,n[1]=(p+_)*w,n[2]=(g-v)*w,n[3]=0,n[4]=(p-_)*E,n[5]=(1-(f+A))*E,n[6]=(m+b)*E,n[7]=0,n[8]=(g+v)*I,n[9]=(m-b)*I,n[10]=(1-(f+y))*I,n[11]=0,n[12]=e.x,n[13]=e.y,n[14]=e.z,n[15]=1,this}decompose(e,t,i){const n=this.elements;let r=Tg.set(n[0],n[1],n[2]).length();const o=Tg.set(n[4],n[5],n[6]).length(),a=Tg.set(n[8],n[9],n[10]).length();this.determinant()<0&&(r=-r),e.x=n[12],e.y=n[13],e.z=n[14],tc.copy(this);const l=1/r,h=1/o,u=1/a;return tc.elements[0]*=l,tc.elements[1]*=l,tc.elements[2]*=l,tc.elements[4]*=h,tc.elements[5]*=h,tc.elements[6]*=h,tc.elements[8]*=u,tc.elements[9]*=u,tc.elements[10]*=u,t.setFromRotationMatrix(tc),i.x=r,i.y=o,i.z=a,this}makePerspective(e,t,i,n,r,o,a=Df){const c=this.elements,l=2*r/(t-e),h=2*r/(i-n),u=(t+e)/(t-e),f=(i+n)/(i-n);let p,g;if(a===Df)p=-(o+r)/(o-r),g=-2*o*r/(o-r);else if(a===CR)p=-o/(o-r),g=-o*r/(o-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return c[0]=l,c[4]=0,c[8]=u,c[12]=0,c[1]=0,c[5]=h,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=p,c[14]=g,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,i,n,r,o,a=Df){const c=this.elements,l=1/(t-e),h=1/(i-n),u=1/(o-r),f=(t+e)*l,p=(i+n)*h;let g,y;if(a===Df)g=(o+r)*u,y=-2*u;else if(a===CR)g=r*u,y=-1*u;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return c[0]=2*l,c[4]=0,c[8]=0,c[12]=-f,c[1]=0,c[5]=2*h,c[9]=0,c[13]=-p,c[2]=0,c[6]=0,c[10]=y,c[14]=-g,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const t=this.elements,i=e.elements;for(let n=0;n<16;n++)if(t[n]!==i[n])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}}const Tg=new ue,tc=new ai,gse=new ue(0,0,0),mse=new ue(1,1,1),hu=new ue,Rx=new ue,Oo=new ue,MU=new ai,TU=new bd;class xA{constructor(e=0,t=0,i=0,n=xA.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=i,this._order=n}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,i,n=this._order){return this._x=e,this._y=t,this._z=i,this._order=n,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,i=!0){const n=e.elements,r=n[0],o=n[4],a=n[8],c=n[1],l=n[5],h=n[9],u=n[2],f=n[6],p=n[10];switch(t){case"XYZ":this._y=Math.asin(Ir(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-h,p),this._z=Math.atan2(-o,r)):(this._x=Math.atan2(f,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Ir(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(a,p),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-u,r),this._z=0);break;case"ZXY":this._x=Math.asin(Ir(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(-u,p),this._z=Math.atan2(-o,l)):(this._y=0,this._z=Math.atan2(c,r));break;case"ZYX":this._y=Math.asin(-Ir(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(f,p),this._z=Math.atan2(c,r)):(this._x=0,this._z=Math.atan2(-o,l));break;case"YZX":this._z=Math.asin(Ir(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-u,r)):(this._x=0,this._y=Math.atan2(a,p));break;case"XZY":this._z=Math.asin(-Ir(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(f,l),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-h,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return MU.makeRotationFromQuaternion(e),this.setFromRotationMatrix(MU,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return TU.setFromEuler(this),this.setFromQuaternion(TU,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}xA.DEFAULT_ORDER="XYZ";class Ase{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let yse=0;const BU=new ue,Bg=new bd,Xl=new ai,Px=new ue,xy=new ue,vse=new ue,bse=new bd,RU=new ue(1,0,0),PU=new ue(0,1,0),DU=new ue(0,0,1),_se={type:"added"},xse={type:"removed"},uM={type:"childadded",child:null},dM={type:"childremoved",child:null};class qn extends zE{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:yse++}),this.uuid=xc(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=qn.DEFAULT_UP.clone();const e=new ue,t=new xA,i=new bd,n=new ue(1,1,1);function r(){i.setFromEuler(t,!1)}function o(){t.setFromQuaternion(i,void 0,!1)}t._onChange(r),i._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:n},modelViewMatrix:{value:new ai},normalMatrix:{value:new zh}}),this.matrix=new ai,this.matrixWorld=new ai,this.matrixAutoUpdate=qn.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=qn.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Ase,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Bg.setFromAxisAngle(e,t),this.quaternion.multiply(Bg),this}rotateOnWorldAxis(e,t){return Bg.setFromAxisAngle(e,t),this.quaternion.premultiply(Bg),this}rotateX(e){return this.rotateOnAxis(RU,e)}rotateY(e){return this.rotateOnAxis(PU,e)}rotateZ(e){return this.rotateOnAxis(DU,e)}translateOnAxis(e,t){return BU.copy(e).applyQuaternion(this.quaternion),this.position.add(BU.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(RU,e)}translateY(e){return this.translateOnAxis(PU,e)}translateZ(e){return this.translateOnAxis(DU,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Xl.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?Px.copy(e):Px.set(e,t,i);const n=this.parent;this.updateWorldMatrix(!0,!1),xy.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Xl.lookAt(xy,Px,this.up):Xl.lookAt(Px,xy,this.up),this.quaternion.setFromRotationMatrix(Xl),n&&(Xl.extractRotation(n.matrixWorld),Bg.setFromRotationMatrix(Xl),this.quaternion.premultiply(Bg.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.parent!==null&&e.parent.remove(e),e.parent=this,this.children.push(e),e.dispatchEvent(_se),uM.child=e,this.dispatchEvent(uM),uM.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(xse),dM.child=e,this.dispatchEvent(dM),dM.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),Xl.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Xl.multiply(e.parent.matrixWorld)),e.applyMatrix4(Xl),this.add(e),e.updateWorldMatrix(!1,!0),this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let i=0,n=this.children.length;i<n;i++){const o=this.children[i].getObjectByProperty(e,t);if(o!==void 0)return o}}getObjectsByProperty(e,t,i=[]){this[e]===t&&i.push(this);const n=this.children;for(let r=0,o=n.length;r<o;r++)n[r].getObjectsByProperty(e,t,i);return i}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(xy,e,vse),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(xy,bse,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let i=0,n=t.length;i<n;i++)t[i].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let i=0,n=t.length;i<n;i++)t[i].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let i=0,n=t.length;i<n;i++){const r=t[i];(r.matrixWorldAutoUpdate===!0||e===!0)&&r.updateMatrixWorld(e)}}updateWorldMatrix(e,t){const i=this.parent;if(e===!0&&i!==null&&i.matrixWorldAutoUpdate===!0&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),t===!0){const n=this.children;for(let r=0,o=n.length;r<o;r++){const a=n[r];a.matrixWorldAutoUpdate===!0&&a.updateWorldMatrix(!1,!0)}}}toJSON(e){const t=e===void 0||typeof e=="string",i={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const n={};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.castShadow===!0&&(n.castShadow=!0),this.receiveShadow===!0&&(n.receiveShadow=!0),this.visible===!1&&(n.visible=!1),this.frustumCulled===!1&&(n.frustumCulled=!1),this.renderOrder!==0&&(n.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(n.userData=this.userData),n.layers=this.layers.mask,n.matrix=this.matrix.toArray(),n.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(n.matrixAutoUpdate=!1),this.isInstancedMesh&&(n.type="InstancedMesh",n.count=this.count,n.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(n.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(n.type="BatchedMesh",n.perObjectFrustumCulled=this.perObjectFrustumCulled,n.sortObjects=this.sortObjects,n.drawRanges=this._drawRanges,n.reservedRanges=this._reservedRanges,n.visibility=this._visibility,n.active=this._active,n.bounds=this._bounds.map(a=>({boxInitialized:a.boxInitialized,boxMin:a.box.min.toArray(),boxMax:a.box.max.toArray(),sphereInitialized:a.sphereInitialized,sphereRadius:a.sphere.radius,sphereCenter:a.sphere.center.toArray()})),n.maxGeometryCount=this._maxGeometryCount,n.maxVertexCount=this._maxVertexCount,n.maxIndexCount=this._maxIndexCount,n.geometryInitialized=this._geometryInitialized,n.geometryCount=this._geometryCount,n.matricesTexture=this._matricesTexture.toJSON(e),this.boundingSphere!==null&&(n.boundingSphere={center:n.boundingSphere.center.toArray(),radius:n.boundingSphere.radius}),this.boundingBox!==null&&(n.boundingBox={min:n.boundingBox.min.toArray(),max:n.boundingBox.max.toArray()}));function r(a,c){return a[c.uuid]===void 0&&(a[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?n.background=this.background.toJSON():this.background.isTexture&&(n.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(n.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){n.geometry=r(e.geometries,this.geometry);const a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){const c=a.shapes;if(Array.isArray(c))for(let l=0,h=c.length;l<h;l++){const u=c[l];r(e.shapes,u)}else r(e.shapes,c)}}if(this.isSkinnedMesh&&(n.bindMode=this.bindMode,n.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(e.skeletons,this.skeleton),n.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const a=[];for(let c=0,l=this.material.length;c<l;c++)a.push(r(e.materials,this.material[c]));n.material=a}else n.material=r(e.materials,this.material);if(this.children.length>0){n.children=[];for(let a=0;a<this.children.length;a++)n.children.push(this.children[a].toJSON(e).object)}if(this.animations.length>0){n.animations=[];for(let a=0;a<this.animations.length;a++){const c=this.animations[a];n.animations.push(r(e.animations,c))}}if(t){const a=o(e.geometries),c=o(e.materials),l=o(e.textures),h=o(e.images),u=o(e.shapes),f=o(e.skeletons),p=o(e.animations),g=o(e.nodes);a.length>0&&(i.geometries=a),c.length>0&&(i.materials=c),l.length>0&&(i.textures=l),h.length>0&&(i.images=h),u.length>0&&(i.shapes=u),f.length>0&&(i.skeletons=f),p.length>0&&(i.animations=p),g.length>0&&(i.nodes=g)}return i.object=n,i;function o(a){const c=[];for(const l in a){const h=a[l];delete h.metadata,c.push(h)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;i<e.children.length;i++){const n=e.children[i];this.add(n.clone())}return this}}qn.DEFAULT_UP=new ue(0,1,0);qn.DEFAULT_MATRIX_AUTO_UPDATE=!0;qn.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const ic=new ue,Yl=new ue,fM=new ue,Jl=new ue,Rg=new ue,Pg=new ue,kU=new ue,pM=new ue,gM=new ue,mM=new ue;class tl{constructor(e=new ue,t=new ue,i=new ue){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,n){n.subVectors(i,t),ic.subVectors(e,t),n.cross(ic);const r=n.lengthSq();return r>0?n.multiplyScalar(1/Math.sqrt(r)):n.set(0,0,0)}static getBarycoord(e,t,i,n,r){ic.subVectors(n,t),Yl.subVectors(i,t),fM.subVectors(e,t);const o=ic.dot(ic),a=ic.dot(Yl),c=ic.dot(fM),l=Yl.dot(Yl),h=Yl.dot(fM),u=o*l-a*a;if(u===0)return r.set(0,0,0),null;const f=1/u,p=(l*c-a*h)*f,g=(o*h-a*c)*f;return r.set(1-p-g,g,p)}static containsPoint(e,t,i,n){return this.getBarycoord(e,t,i,n,Jl)===null?!1:Jl.x>=0&&Jl.y>=0&&Jl.x+Jl.y<=1}static getInterpolation(e,t,i,n,r,o,a,c){return this.getBarycoord(e,t,i,n,Jl)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(r,Jl.x),c.addScaledVector(o,Jl.y),c.addScaledVector(a,Jl.z),c)}static isFrontFacing(e,t,i,n){return ic.subVectors(i,t),Yl.subVectors(e,t),ic.cross(Yl).dot(n)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,n){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[n]),this}setFromAttributeAndIndices(e,t,i,n){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,n),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return ic.subVectors(this.c,this.b),Yl.subVectors(this.a,this.b),ic.cross(Yl).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return tl.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return tl.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,n,r){return tl.getInterpolation(e,this.a,this.b,this.c,t,i,n,r)}containsPoint(e){return tl.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return tl.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const i=this.a,n=this.b,r=this.c;let o,a;Rg.subVectors(n,i),Pg.subVectors(r,i),pM.subVectors(e,i);const c=Rg.dot(pM),l=Pg.dot(pM);if(c<=0&&l<=0)return t.copy(i);gM.subVectors(e,n);const h=Rg.dot(gM),u=Pg.dot(gM);if(h>=0&&u<=h)return t.copy(n);const f=c*u-h*l;if(f<=0&&c>=0&&h<=0)return o=c/(c-h),t.copy(i).addScaledVector(Rg,o);mM.subVectors(e,r);const p=Rg.dot(mM),g=Pg.dot(mM);if(g>=0&&p<=g)return t.copy(r);const y=p*l-c*g;if(y<=0&&l>=0&&g<=0)return a=l/(l-g),t.copy(i).addScaledVector(Pg,a);const m=h*g-p*u;if(m<=0&&u-h>=0&&p-g>=0)return kU.subVectors(r,n),a=(u-h)/(u-h+(p-g)),t.copy(n).addScaledVector(kU,a);const A=1/(m+y+f);return o=y*A,a=f*A,t.copy(i).addScaledVector(Rg,o).addScaledVector(Pg,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const L8={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},uu={h:0,s:0,l:0},Dx={h:0,s:0,l:0};function AM(s,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?s+(e-s)*6*t:t<1/2?e:t<2/3?s+(e-s)*6*(2/3-t):s}class os{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(t===void 0&&i===void 0){const n=e;n&&n.isColor?this.copy(n):typeof n=="number"?this.setHex(n):typeof n=="string"&&this.setStyle(n)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Er){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Uo.toWorkingColorSpace(this,t),this}setRGB(e,t,i,n=Uo.workingColorSpace){return this.r=e,this.g=t,this.b=i,Uo.toWorkingColorSpace(this,n),this}setHSL(e,t,i,n=Uo.workingColorSpace){if(e=F2(e,1),t=Ir(t,0,1),i=Ir(i,0,1),t===0)this.r=this.g=this.b=i;else{const r=i<=.5?i*(1+t):i+t-i*t,o=2*i-r;this.r=AM(o,r,e+1/3),this.g=AM(o,r,e),this.b=AM(o,r,e-1/3)}return Uo.toWorkingColorSpace(this,n),this}setStyle(e,t=Er){function i(r){r!==void 0&&parseFloat(r)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let n;if(n=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const o=n[1],a=n[2];switch(o){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(e)){const r=n[1],o=r.length;if(o===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(o===6)return this.setHex(parseInt(r,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Er){const i=L8[e.toLowerCase()];return i!==void 0?this.setHex(i,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Lm(e.r),this.g=Lm(e.g),this.b=Lm(e.b),this}copyLinearToSRGB(e){return this.r=nM(e.r),this.g=nM(e.g),this.b=nM(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Er){return Uo.fromWorkingColorSpace(yr.copy(this),e),Math.round(Ir(yr.r*255,0,255))*65536+Math.round(Ir(yr.g*255,0,255))*256+Math.round(Ir(yr.b*255,0,255))}getHexString(e=Er){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Uo.workingColorSpace){Uo.fromWorkingColorSpace(yr.copy(this),t);const i=yr.r,n=yr.g,r=yr.b,o=Math.max(i,n,r),a=Math.min(i,n,r);let c,l;const h=(a+o)/2;if(a===o)c=0,l=0;else{const u=o-a;switch(l=h<=.5?u/(o+a):u/(2-o-a),o){case i:c=(n-r)/u+(n<r?6:0);break;case n:c=(r-i)/u+2;break;case r:c=(i-n)/u+4;break}c/=6}return e.h=c,e.s=l,e.l=h,e}getRGB(e,t=Uo.workingColorSpace){return Uo.fromWorkingColorSpace(yr.copy(this),t),e.r=yr.r,e.g=yr.g,e.b=yr.b,e}getStyle(e=Er){Uo.fromWorkingColorSpace(yr.copy(this),e);const t=yr.r,i=yr.g,n=yr.b;return e!==Er?`color(${e} ${t.toFixed(3)} ${i.toFixed(3)} ${n.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(i*255)},${Math.round(n*255)})`}offsetHSL(e,t,i){return this.getHSL(uu),this.setHSL(uu.h+e,uu.s+t,uu.l+i)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,i){return this.r=e.r+(t.r-e.r)*i,this.g=e.g+(t.g-e.g)*i,this.b=e.b+(t.b-e.b)*i,this}lerpHSL(e,t){this.getHSL(uu),e.getHSL(Dx);const i=Q0(uu.h,Dx.h,t),n=Q0(uu.s,Dx.s,t),r=Q0(uu.l,Dx.l,t);return this.setHSL(i,n,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,i=this.g,n=this.b,r=e.elements;return this.r=r[0]*t+r[3]*i+r[6]*n,this.g=r[1]*t+r[4]*i+r[7]*n,this.b=r[2]*t+r[5]*i+r[8]*n,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const yr=new os;os.NAMES=L8;let wse=0;class ed extends zE{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:wse++}),this.uuid=xc(),this.name="",this.type="Material",this.blending=cU,this.side=lS,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=hU,this.blendDst=uU,this.blendEquation=lU,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new os(0,0,0),this.blendAlpha=0,this.depthFunc=dU,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=xU,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Cg,this.stencilZFail=Cg,this.stencilZPass=Cg,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const i=e[t];if(i===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const n=this[t];if(n===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}n&&n.isColor?n.set(i):n&&n.isVector3&&i&&i.isVector3?n.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const i={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==cU&&(i.blending=this.blending),this.side!==lS&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==hU&&(i.blendSrc=this.blendSrc),this.blendDst!==uU&&(i.blendDst=this.blendDst),this.blendEquation!==lU&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==dU&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==xU&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Cg&&(i.stencilFail=this.stencilFail),this.stencilZFail!==Cg&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==Cg&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function n(r){const o=[];for(const a in r){const c=r[a];delete c.metadata,o.push(c)}return o}if(t){const r=n(e.textures),o=n(e.images);r.length>0&&(i.textures=r),o.length>0&&(i.images=o)}return i}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let i=null;if(t!==null){const n=t.length;i=new Array(n);for(let r=0;r!==n;++r)i[r]=t[r].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class vm extends ed{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new os(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new xA,this.combine=wne,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const $n=new ue,kx=new Sn;class Zo{constructor(e,t,i=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=wR,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=Gf,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return O8("THREE.BufferAttribute: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let n=0,r=this.itemSize;n<r;n++)this.array[e+n]=t.array[i+n];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,i=this.count;t<i;t++)kx.fromBufferAttribute(this,t),kx.applyMatrix3(e),this.setXY(t,kx.x,kx.y);else if(this.itemSize===3)for(let t=0,i=this.count;t<i;t++)$n.fromBufferAttribute(this,t),$n.applyMatrix3(e),this.setXYZ(t,$n.x,$n.y,$n.z);return this}applyMatrix4(e){for(let t=0,i=this.count;t<i;t++)$n.fromBufferAttribute(this,t),$n.applyMatrix4(e),this.setXYZ(t,$n.x,$n.y,$n.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)$n.fromBufferAttribute(this,t),$n.applyNormalMatrix(e),this.setXYZ(t,$n.x,$n.y,$n.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)$n.fromBufferAttribute(this,t),$n.transformDirection(e),this.setXYZ(t,$n.x,$n.y,$n.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let i=this.array[e*this.itemSize+t];return this.normalized&&(i=fc(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=Oi(i,this.array)),this.array[e*this.itemSize+t]=i,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=fc(t,this.array)),t}setX(e,t){return this.normalized&&(t=Oi(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=fc(t,this.array)),t}setY(e,t){return this.normalized&&(t=Oi(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=fc(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Oi(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=fc(t,this.array)),t}setW(e,t){return this.normalized&&(t=Oi(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=Oi(t,this.array),i=Oi(i,this.array)),this.array[e+0]=t,this.array[e+1]=i,this}setXYZ(e,t,i,n){return e*=this.itemSize,this.normalized&&(t=Oi(t,this.array),i=Oi(i,this.array),n=Oi(n,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=n,this}setXYZW(e,t,i,n,r){return e*=this.itemSize,this.normalized&&(t=Oi(t,this.array),i=Oi(i,this.array),n=Oi(n,this.array),r=Oi(r,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=n,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==wR&&(e.usage=this.usage),e}}class Cse extends Zo{constructor(e,t,i){super(new Uint16Array(e),t,i)}}class Sse extends Zo{constructor(e,t,i){super(new Uint32Array(e),t,i)}}class U2 extends Zo{constructor(e,t,i){super(new Float32Array(e),t,i)}}let Ese=0;const da=new ai,yM=new qn,Dg=new ue,Lo=new Cc,wy=new Cc,ws=new ue;class Sc extends zE{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Ese++}),this.uuid=xc(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(ase(e)?Sse:Cse)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,i=0){this.groups.push({start:e,count:t,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const i=this.attributes.normal;if(i!==void 0){const r=new zh().getNormalMatrix(e);i.applyNormalMatrix(r),i.needsUpdate=!0}const n=this.attributes.tangent;return n!==void 0&&(n.transformDirection(e),n.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return da.makeRotationFromQuaternion(e),this.applyMatrix4(da),this}rotateX(e){return da.makeRotationX(e),this.applyMatrix4(da),this}rotateY(e){return da.makeRotationY(e),this.applyMatrix4(da),this}rotateZ(e){return da.makeRotationZ(e),this.applyMatrix4(da),this}translate(e,t,i){return da.makeTranslation(e,t,i),this.applyMatrix4(da),this}scale(e,t,i){return da.makeScale(e,t,i),this.applyMatrix4(da),this}lookAt(e){return yM.lookAt(e),yM.updateMatrix(),this.applyMatrix4(yM.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Dg).negate(),this.translate(Dg.x,Dg.y,Dg.z),this}setFromPoints(e){const t=[];for(let i=0,n=e.length;i<n;i++){const r=e[i];t.push(r.x,r.y,r.z||0)}return this.setAttribute("position",new U2(t,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Cc);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new ue(-1/0,-1/0,-1/0),new ue(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,n=t.length;i<n;i++){const r=t[i];Lo.setFromBufferAttribute(r),this.morphTargetsRelative?(ws.addVectors(this.boundingBox.min,Lo.min),this.boundingBox.expandByPoint(ws),ws.addVectors(this.boundingBox.max,Lo.max),this.boundingBox.expandByPoint(ws)):(this.boundingBox.expandByPoint(Lo.min),this.boundingBox.expandByPoint(Lo.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Bc);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new ue,1/0);return}if(e){const i=this.boundingSphere.center;if(Lo.setFromBufferAttribute(e),t)for(let r=0,o=t.length;r<o;r++){const a=t[r];wy.setFromBufferAttribute(a),this.morphTargetsRelative?(ws.addVectors(Lo.min,wy.min),Lo.expandByPoint(ws),ws.addVectors(Lo.max,wy.max),Lo.expandByPoint(ws)):(Lo.expandByPoint(wy.min),Lo.expandByPoint(wy.max))}Lo.getCenter(i);let n=0;for(let r=0,o=e.count;r<o;r++)ws.fromBufferAttribute(e,r),n=Math.max(n,i.distanceToSquared(ws));if(t)for(let r=0,o=t.length;r<o;r++){const a=t[r],c=this.morphTargetsRelative;for(let l=0,h=a.count;l<h;l++)ws.fromBufferAttribute(a,l),c&&(Dg.fromBufferAttribute(e,l),ws.add(Dg)),n=Math.max(n,i.distanceToSquared(ws))}this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const i=t.position,n=t.normal,r=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Zo(new Float32Array(4*i.count),4));const o=this.getAttribute("tangent"),a=[],c=[];for(let M=0;M<i.count;M++)a[M]=new ue,c[M]=new ue;const l=new ue,h=new ue,u=new ue,f=new Sn,p=new Sn,g=new Sn,y=new ue,m=new ue;function A(M,R,S){l.fromBufferAttribute(i,M),h.fromBufferAttribute(i,R),u.fromBufferAttribute(i,S),f.fromBufferAttribute(r,M),p.fromBufferAttribute(r,R),g.fromBufferAttribute(r,S),h.sub(l),u.sub(l),p.sub(f),g.sub(f);const T=1/(p.x*g.y-g.x*p.y);isFinite(T)&&(y.copy(h).multiplyScalar(g.y).addScaledVector(u,-p.y).multiplyScalar(T),m.copy(u).multiplyScalar(p.x).addScaledVector(h,-g.x).multiplyScalar(T),a[M].add(y),a[R].add(y),a[S].add(y),c[M].add(m),c[R].add(m),c[S].add(m))}let b=this.groups;b.length===0&&(b=[{start:0,count:e.count}]);for(let M=0,R=b.length;M<R;++M){const S=b[M],T=S.start,F=S.count;for(let U=T,k=T+F;U<k;U+=3)A(e.getX(U+0),e.getX(U+1),e.getX(U+2))}const v=new ue,_=new ue,w=new ue,E=new ue;function I(M){w.fromBufferAttribute(n,M),E.copy(w);const R=a[M];v.copy(R),v.sub(w.multiplyScalar(w.dot(R))).normalize(),_.crossVectors(E,R);const T=_.dot(c[M])<0?-1:1;o.setXYZW(M,v.x,v.y,v.z,T)}for(let M=0,R=b.length;M<R;++M){const S=b[M],T=S.start,F=S.count;for(let U=T,k=T+F;U<k;U+=3)I(e.getX(U+0)),I(e.getX(U+1)),I(e.getX(U+2))}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let i=this.getAttribute("normal");if(i===void 0)i=new Zo(new Float32Array(t.count*3),3),this.setAttribute("normal",i);else for(let f=0,p=i.count;f<p;f++)i.setXYZ(f,0,0,0);const n=new ue,r=new ue,o=new ue,a=new ue,c=new ue,l=new ue,h=new ue,u=new ue;if(e)for(let f=0,p=e.count;f<p;f+=3){const g=e.getX(f+0),y=e.getX(f+1),m=e.getX(f+2);n.fromBufferAttribute(t,g),r.fromBufferAttribute(t,y),o.fromBufferAttribute(t,m),h.subVectors(o,r),u.subVectors(n,r),h.cross(u),a.fromBufferAttribute(i,g),c.fromBufferAttribute(i,y),l.fromBufferAttribute(i,m),a.add(h),c.add(h),l.add(h),i.setXYZ(g,a.x,a.y,a.z),i.setXYZ(y,c.x,c.y,c.z),i.setXYZ(m,l.x,l.y,l.z)}else for(let f=0,p=t.count;f<p;f+=3)n.fromBufferAttribute(t,f+0),r.fromBufferAttribute(t,f+1),o.fromBufferAttribute(t,f+2),h.subVectors(o,r),u.subVectors(n,r),h.cross(u),i.setXYZ(f+0,h.x,h.y,h.z),i.setXYZ(f+1,h.x,h.y,h.z),i.setXYZ(f+2,h.x,h.y,h.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,i=e.count;t<i;t++)ws.fromBufferAttribute(e,t),ws.normalize(),e.setXYZ(t,ws.x,ws.y,ws.z)}toNonIndexed(){function e(a,c){const l=a.array,h=a.itemSize,u=a.normalized,f=new l.constructor(c.length*h);let p=0,g=0;for(let y=0,m=c.length;y<m;y++){a.isInterleavedBufferAttribute?p=c[y]*a.data.stride+a.offset:p=c[y]*h;for(let A=0;A<h;A++)f[g++]=l[p++]}return new Zo(f,h,u)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new Sc,i=this.index.array,n=this.attributes;for(const a in n){const c=n[a],l=e(c,i);t.setAttribute(a,l)}const r=this.morphAttributes;for(const a in r){const c=[],l=r[a];for(let h=0,u=l.length;h<u;h++){const f=l[h],p=e(f,i);c.push(p)}t.morphAttributes[a]=c}t.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let a=0,c=o.length;a<c;a++){const l=o[a];t.addGroup(l.start,l.count,l.materialIndex)}return t}toJSON(){const e={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const c=this.parameters;for(const l in c)c[l]!==void 0&&(e[l]=c[l]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const i=this.attributes;for(const c in i){const l=i[c];e.data.attributes[c]=l.toJSON(e.data)}const n={};let r=!1;for(const c in this.morphAttributes){const l=this.morphAttributes[c],h=[];for(let u=0,f=l.length;u<f;u++){const p=l[u];h.push(p.toJSON(e.data))}h.length>0&&(n[c]=h,r=!0)}r&&(e.data.morphAttributes=n,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const a=this.boundingSphere;return a!==null&&(e.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const i=e.index;i!==null&&this.setIndex(i.clone(t));const n=e.attributes;for(const l in n){const h=n[l];this.setAttribute(l,h.clone(t))}const r=e.morphAttributes;for(const l in r){const h=[],u=r[l];for(let f=0,p=u.length;f<p;f++)h.push(u[f].clone(t));this.morphAttributes[l]=h}this.morphTargetsRelative=e.morphTargetsRelative;const o=e.groups;for(let l=0,h=o.length;l<h;l++){const u=o[l];this.addGroup(u.start,u.count,u.materialIndex)}const a=e.boundingBox;a!==null&&(this.boundingBox=a.clone());const c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const OU=new ai,Kd=new GE,Ox=new Bc,LU=new ue,kg=new ue,Og=new ue,Lg=new ue,vM=new ue,Lx=new ue,Fx=new Sn,Ux=new Sn,Nx=new Sn,FU=new ue,UU=new ue,NU=new ue,Qx=new ue,zx=new ue;class pp extends qn{constructor(e=new Sc,t=new vm){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const n=t[i[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=n.length;r<o;r++){const a=n[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}getVertexPosition(e,t){const i=this.geometry,n=i.attributes.position,r=i.morphAttributes.position,o=i.morphTargetsRelative;t.fromBufferAttribute(n,e);const a=this.morphTargetInfluences;if(r&&a){Lx.set(0,0,0);for(let c=0,l=r.length;c<l;c++){const h=a[c],u=r[c];h!==0&&(vM.fromBufferAttribute(u,e),o?Lx.addScaledVector(vM,h):Lx.addScaledVector(vM.sub(t),h))}t.add(Lx)}return t}raycast(e,t){const i=this.geometry,n=this.material,r=this.matrixWorld;n!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),Ox.copy(i.boundingSphere),Ox.applyMatrix4(r),Kd.copy(e.ray).recast(e.near),!(Ox.containsPoint(Kd.origin)===!1&&(Kd.intersectSphere(Ox,LU)===null||Kd.origin.distanceToSquared(LU)>(e.far-e.near)**2))&&(OU.copy(r).invert(),Kd.copy(e.ray).applyMatrix4(OU),!(i.boundingBox!==null&&Kd.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,Kd)))}_computeIntersections(e,t,i){let n;const r=this.geometry,o=this.material,a=r.index,c=r.attributes.position,l=r.attributes.uv,h=r.attributes.uv1,u=r.attributes.normal,f=r.groups,p=r.drawRange;if(a!==null)if(Array.isArray(o))for(let g=0,y=f.length;g<y;g++){const m=f[g],A=o[m.materialIndex],b=Math.max(m.start,p.start),v=Math.min(a.count,Math.min(m.start+m.count,p.start+p.count));for(let _=b,w=v;_<w;_+=3){const E=a.getX(_),I=a.getX(_+1),M=a.getX(_+2);n=Gx(this,A,e,i,l,h,u,E,I,M),n&&(n.faceIndex=Math.floor(_/3),n.face.materialIndex=m.materialIndex,t.push(n))}}else{const g=Math.max(0,p.start),y=Math.min(a.count,p.start+p.count);for(let m=g,A=y;m<A;m+=3){const b=a.getX(m),v=a.getX(m+1),_=a.getX(m+2);n=Gx(this,o,e,i,l,h,u,b,v,_),n&&(n.faceIndex=Math.floor(m/3),t.push(n))}}else if(c!==void 0)if(Array.isArray(o))for(let g=0,y=f.length;g<y;g++){const m=f[g],A=o[m.materialIndex],b=Math.max(m.start,p.start),v=Math.min(c.count,Math.min(m.start+m.count,p.start+p.count));for(let _=b,w=v;_<w;_+=3){const E=_,I=_+1,M=_+2;n=Gx(this,A,e,i,l,h,u,E,I,M),n&&(n.faceIndex=Math.floor(_/3),n.face.materialIndex=m.materialIndex,t.push(n))}}else{const g=Math.max(0,p.start),y=Math.min(c.count,p.start+p.count);for(let m=g,A=y;m<A;m+=3){const b=m,v=m+1,_=m+2;n=Gx(this,o,e,i,l,h,u,b,v,_),n&&(n.faceIndex=Math.floor(m/3),t.push(n))}}}}function Ise(s,e,t,i,n,r,o,a){let c;if(e.side===_ne?c=i.intersectTriangle(o,r,n,!0,a):c=i.intersectTriangle(n,r,o,e.side===lS,a),c===null)return null;zx.copy(a),zx.applyMatrix4(s.matrixWorld);const l=t.ray.origin.distanceTo(zx);return l<t.near||l>t.far?null:{distance:l,point:zx.clone(),object:s}}function Gx(s,e,t,i,n,r,o,a,c,l){s.getVertexPosition(a,kg),s.getVertexPosition(c,Og),s.getVertexPosition(l,Lg);const h=Ise(s,e,t,i,kg,Og,Lg,Qx);if(h){n&&(Fx.fromBufferAttribute(n,a),Ux.fromBufferAttribute(n,c),Nx.fromBufferAttribute(n,l),h.uv=tl.getInterpolation(Qx,kg,Og,Lg,Fx,Ux,Nx,new Sn)),r&&(Fx.fromBufferAttribute(r,a),Ux.fromBufferAttribute(r,c),Nx.fromBufferAttribute(r,l),h.uv1=tl.getInterpolation(Qx,kg,Og,Lg,Fx,Ux,Nx,new Sn)),o&&(FU.fromBufferAttribute(o,a),UU.fromBufferAttribute(o,c),NU.fromBufferAttribute(o,l),h.normal=tl.getInterpolation(Qx,kg,Og,Lg,FU,UU,NU,new ue),h.normal.dot(i.direction)>0&&h.normal.multiplyScalar(-1));const u={a,b:c,c:l,normal:new ue,materialIndex:0};tl.getNormal(kg,Og,Lg,u.normal),h.face=u}return h}let F8=class extends qn{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new ai,this.projectionMatrix=new ai,this.projectionMatrixInverse=new ai,this.coordinateSystem=Df}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}};const du=new ue,QU=new Sn,zU=new Sn;class N2 extends F8{constructor(e=50,t=1,i=.1,n=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=n,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=Lv*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(N0*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Lv*2*Math.atan(Math.tan(N0*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,i){du.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(du.x,du.y).multiplyScalar(-e/du.z),du.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(du.x,du.y).multiplyScalar(-e/du.z)}getViewSize(e,t){return this.getViewBounds(e,QU,zU),t.subVectors(zU,QU)}setViewOffset(e,t,i,n,r,o){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=n,this.view.width=r,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(N0*.5*this.fov)/this.zoom,i=2*t,n=this.aspect*i,r=-.5*n;const o=this.view;if(this.view!==null&&this.view.enabled){const c=o.fullWidth,l=o.fullHeight;r+=o.offsetX*n/c,t-=o.offsetY*i/l,n*=o.width/c,i*=o.height/l}const a=this.filmOffset;a!==0&&(r+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+n,t,t-i,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const bM=new ue,Mse=new ue,Tse=new zh;class Fg{constructor(e=new ue(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,n){return this.normal.set(e,t,i),this.constant=n,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){const n=bM.subVectors(i,t).cross(Mse.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(n,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const i=e.delta(bM),n=this.normal.dot(i);if(n===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const r=-(e.start.dot(this.normal)+this.constant)/n;return r<0||r>1?null:t.copy(e.start).addScaledVector(i,r)}intersectsLine(e){const t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const i=t||Tse.getNormalMatrix(e),n=this.coplanarPoint(bM).applyMatrix4(e),r=this.normal.applyMatrix3(i).normalize();return this.constant=-n.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Zd=new Bc,Hx=new ue;class U8{constructor(e=new Fg,t=new Fg,i=new Fg,n=new Fg,r=new Fg,o=new Fg){this.planes=[e,t,i,n,r,o]}set(e,t,i,n,r,o){const a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(i),a[3].copy(n),a[4].copy(r),a[5].copy(o),this}copy(e){const t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=Df){const i=this.planes,n=e.elements,r=n[0],o=n[1],a=n[2],c=n[3],l=n[4],h=n[5],u=n[6],f=n[7],p=n[8],g=n[9],y=n[10],m=n[11],A=n[12],b=n[13],v=n[14],_=n[15];if(i[0].setComponents(c-r,f-l,m-p,_-A).normalize(),i[1].setComponents(c+r,f+l,m+p,_+A).normalize(),i[2].setComponents(c+o,f+h,m+g,_+b).normalize(),i[3].setComponents(c-o,f-h,m-g,_-b).normalize(),i[4].setComponents(c-a,f-u,m-y,_-v).normalize(),t===Df)i[5].setComponents(c+a,f+u,m+y,_+v).normalize();else if(t===CR)i[5].setComponents(a,u,y,v).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Zd.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Zd.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Zd)}intersectsSprite(e){return Zd.center.set(0,0,0),Zd.radius=.7071067811865476,Zd.applyMatrix4(e.matrixWorld),this.intersectsSphere(Zd)}intersectsSphere(e){const t=this.planes,i=e.center,n=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(i)<n)return!1;return!0}intersectsBox(e){const t=this.planes;for(let i=0;i<6;i++){const n=t[i];if(Hx.x=n.normal.x>0?e.max.x:e.min.x,Hx.y=n.normal.y>0?e.max.y:e.min.y,Hx.z=n.normal.z>0?e.max.z:e.min.z,n.distanceToPoint(Hx)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class N8 extends F8{constructor(e=-1,t=1,i=1,n=-1,r=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=n,this.near=r,this.far=o,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,i,n,r,o){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=n,this.view.width=r,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,n=(this.top+this.bottom)/2;let r=i-e,o=i+e,a=n+t,c=n-t;if(this.view!==null&&this.view.enabled){const l=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=l*this.view.offsetX,o=r+l*this.view.width,a-=h*this.view.offsetY,c=a-h*this.view.height}this.projectionMatrix.makeOrthographic(r,o,a,c,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}class Bse extends ms{constructor(e,t,i,n,r,o,a,c,l,h){if(h=h!==void 0?h:eM,h!==eM&&h!==pU)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&h===eM&&(i=Tne),i===void 0&&h===pU&&(i=Bne),super(null,n,r,o,a,c,h,i,l),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=a!==void 0?a:fp,this.minFilter=c!==void 0?c:fp,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}const Rse=new Bse(1,1);Rse.compareFunction=Hne;class _M extends qn{constructor(){super(),this.isGroup=!0,this.type="Group"}}class Pse{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=wR,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=xc()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return O8("THREE.InterleavedBuffer: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let n=0,r=this.stride;n<r;n++)this.array[e+n]=t.array[i+n];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=xc()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(t,this.stride);return i.setUsage(this.usage),i}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=xc()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const zr=new ue;class Q2{constructor(e,t,i,n=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=i,this.normalized=n}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,i=this.data.count;t<i;t++)zr.fromBufferAttribute(this,t),zr.applyMatrix4(e),this.setXYZ(t,zr.x,zr.y,zr.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)zr.fromBufferAttribute(this,t),zr.applyNormalMatrix(e),this.setXYZ(t,zr.x,zr.y,zr.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)zr.fromBufferAttribute(this,t),zr.transformDirection(e),this.setXYZ(t,zr.x,zr.y,zr.z);return this}getComponent(e,t){let i=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(i=fc(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=Oi(i,this.array)),this.data.array[e*this.data.stride+this.offset+t]=i,this}setX(e,t){return this.normalized&&(t=Oi(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=Oi(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=Oi(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=Oi(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=fc(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=fc(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=fc(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=fc(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=Oi(t,this.array),i=Oi(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this}setXYZ(e,t,i,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=Oi(t,this.array),i=Oi(i,this.array),n=Oi(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=n,this}setXYZW(e,t,i,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=Oi(t,this.array),i=Oi(i,this.array),n=Oi(n,this.array),r=Oi(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=n,this.data.array[e+3]=r,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let i=0;i<this.count;i++){const n=i*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[n+r])}return new Zo(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new Q2(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let i=0;i<this.count;i++){const n=i*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[n+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}const GU=new ue,HU=new Ta,VU=new Ta,Dse=new ue,jU=new ai,Vx=new ue,xM=new Bc,WU=new ai,wM=new GE;class kse extends pp{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=fU,this.bindMatrix=new ai,this.bindMatrixInverse=new ai,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new Cc),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,Vx),this.boundingBox.expandByPoint(Vx)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Bc),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,Vx),this.boundingSphere.expandByPoint(Vx)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const i=this.material,n=this.matrixWorld;i!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),xM.copy(this.boundingSphere),xM.applyMatrix4(n),e.ray.intersectsSphere(xM)!==!1&&(WU.copy(n).invert(),wM.copy(e.ray).applyMatrix4(WU),!(this.boundingBox!==null&&wM.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,wM)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new Ta,t=this.geometry.attributes.skinWeight;for(let i=0,n=t.count;i<n;i++){e.fromBufferAttribute(t,i);const r=1/e.manhattanLength();r!==1/0?e.multiplyScalar(r):e.set(1,0,0,0),t.setXYZW(i,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===fU?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===Cne?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const i=this.skeleton,n=this.geometry;HU.fromBufferAttribute(n.attributes.skinIndex,e),VU.fromBufferAttribute(n.attributes.skinWeight,e),GU.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let r=0;r<4;r++){const o=VU.getComponent(r);if(o!==0){const a=HU.getComponent(r);jU.multiplyMatrices(i.bones[a].matrixWorld,i.boneInverses[a]),t.addScaledVector(Dse.copy(GU).applyMatrix4(jU),o)}}return t.applyMatrix4(this.bindMatrixInverse)}}class Q8 extends qn{constructor(){super(),this.isBone=!0,this.type="Bone"}}class z2 extends ms{constructor(e=null,t=1,i=1,n,r,o,a,c,l=fp,h=fp,u,f){super(null,o,a,c,l,h,n,r,u,f),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const qU=new ai,Ose=new ai;class G2{constructor(e=[],t=[]){this.uuid=xc(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let i=0,n=this.bones.length;i<n;i++)this.boneInverses.push(new ai)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const i=new ai;this.bones[e]&&i.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(i)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const i=this.bones[e];i&&i.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const i=this.bones[e];i&&(i.parent&&i.parent.isBone?(i.matrix.copy(i.parent.matrixWorld).invert(),i.matrix.multiply(i.matrixWorld)):i.matrix.copy(i.matrixWorld),i.matrix.decompose(i.position,i.quaternion,i.scale))}}update(){const e=this.bones,t=this.boneInverses,i=this.boneMatrices,n=this.boneTexture;for(let r=0,o=e.length;r<o;r++){const a=e[r]?e[r].matrixWorld:Ose;qU.multiplyMatrices(a,t[r]),qU.toArray(i,r*16)}n!==null&&(n.needsUpdate=!0)}clone(){return new G2(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const i=new z2(t,e,e,Hu,Gf);return i.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=i,this}getBoneByName(e){for(let t=0,i=this.bones.length;t<i;t++){const n=this.bones[t];if(n.name===e)return n}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let i=0,n=e.bones.length;i<n;i++){const r=e.bones[i];let o=t[r];o===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",r),o=new Q8),this.bones.push(o),this.boneInverses.push(new ai().fromArray(e.boneInverses[i]))}return this.init(),this}toJSON(){const e={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,i=this.boneInverses;for(let n=0,r=t.length;n<r;n++){const o=t[n];e.bones.push(o.uuid);const a=i[n];e.boneInverses.push(a.toArray())}return e}}class ER extends Zo{constructor(e,t,i,n=1){super(e,t,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const Ug=new ai,XU=new ai,jx=[],YU=new Cc,Lse=new ai,Cy=new pp,Sy=new Bc;class Fse extends pp{constructor(e,t,i){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new ER(new Float32Array(i*16),16),this.instanceColor=null,this.morphTexture=null,this.count=i,this.boundingBox=null,this.boundingSphere=null;for(let n=0;n<i;n++)this.setMatrixAt(n,Lse)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new Cc),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,Ug),YU.copy(e.boundingBox).applyMatrix4(Ug),this.boundingBox.union(YU)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new Bc),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,Ug),Sy.copy(e.boundingSphere).applyMatrix4(Ug),this.boundingSphere.union(Sy)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){const i=t.morphTargetInfluences,n=this.morphTexture.source.data.data,r=i.length+1,o=e*r+1;for(let a=0;a<i.length;a++)i[a]=n[o+a]}raycast(e,t){const i=this.matrixWorld,n=this.count;if(Cy.geometry=this.geometry,Cy.material=this.material,Cy.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Sy.copy(this.boundingSphere),Sy.applyMatrix4(i),e.ray.intersectsSphere(Sy)!==!1))for(let r=0;r<n;r++){this.getMatrixAt(r,Ug),XU.multiplyMatrices(i,Ug),Cy.matrixWorld=XU,Cy.raycast(e,jx);for(let o=0,a=jx.length;o<a;o++){const c=jx[o];c.instanceId=r,c.object=this,t.push(c)}jx.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new ER(new Float32Array(this.instanceMatrix.count*3),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){const i=t.morphTargetInfluences,n=i.length+1;this.morphTexture===null&&(this.morphTexture=new z2(new Float32Array(n*this.count),n,this.count,ym,Gf));const r=this.morphTexture.source.data.data;let o=0;for(let l=0;l<i.length;l++)o+=i[l];const a=this.geometry.morphTargetsRelative?1:1-o,c=n*e;r[c]=a,r.set(i,c+1)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"})}}class z8 extends ed{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new os(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const JU=new ue,KU=new ue,ZU=new ai,CM=new GE,Wx=new Bc;class H2 extends qn{constructor(e=new Sc,t=new z8){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[0];for(let n=1,r=t.count;n<r;n++)JU.fromBufferAttribute(t,n-1),KU.fromBufferAttribute(t,n),i[n]=i[n-1],i[n]+=JU.distanceTo(KU);e.setAttribute("lineDistance",new U2(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const i=this.geometry,n=this.matrixWorld,r=e.params.Line.threshold,o=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Wx.copy(i.boundingSphere),Wx.applyMatrix4(n),Wx.radius+=r,e.ray.intersectsSphere(Wx)===!1)return;ZU.copy(n).invert(),CM.copy(e.ray).applyMatrix4(ZU);const a=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=a*a,l=new ue,h=new ue,u=new ue,f=new ue,p=this.isLineSegments?2:1,g=i.index,m=i.attributes.position;if(g!==null){const A=Math.max(0,o.start),b=Math.min(g.count,o.start+o.count);for(let v=A,_=b-1;v<_;v+=p){const w=g.getX(v),E=g.getX(v+1);if(l.fromBufferAttribute(m,w),h.fromBufferAttribute(m,E),CM.distanceSqToSegment(l,h,f,u)>c)continue;f.applyMatrix4(this.matrixWorld);const M=e.ray.origin.distanceTo(f);M<e.near||M>e.far||t.push({distance:M,point:u.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}else{const A=Math.max(0,o.start),b=Math.min(m.count,o.start+o.count);for(let v=A,_=b-1;v<_;v+=p){if(l.fromBufferAttribute(m,v),h.fromBufferAttribute(m,v+1),CM.distanceSqToSegment(l,h,f,u)>c)continue;f.applyMatrix4(this.matrixWorld);const E=e.ray.origin.distanceTo(f);E<e.near||E>e.far||t.push({distance:E,point:u.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const n=t[i[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=n.length;r<o;r++){const a=n[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}}const $U=new ue,eN=new ue;class Use extends H2{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[];for(let n=0,r=t.count;n<r;n+=2)$U.fromBufferAttribute(t,n),eN.fromBufferAttribute(t,n+1),i[n]=n===0?0:i[n-1],i[n+1]=i[n]+$U.distanceTo(eN);e.setAttribute("lineDistance",new U2(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class Nse extends H2{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class G8 extends ed{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new os(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const tN=new ai,IR=new GE,qx=new Bc,Xx=new ue;class Qse extends qn{constructor(e=new Sc,t=new G8){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){const i=this.geometry,n=this.matrixWorld,r=e.params.Points.threshold,o=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),qx.copy(i.boundingSphere),qx.applyMatrix4(n),qx.radius+=r,e.ray.intersectsSphere(qx)===!1)return;tN.copy(n).invert(),IR.copy(e.ray).applyMatrix4(tN);const a=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=a*a,l=i.index,u=i.attributes.position;if(l!==null){const f=Math.max(0,o.start),p=Math.min(l.count,o.start+o.count);for(let g=f,y=p;g<y;g++){const m=l.getX(g);Xx.fromBufferAttribute(u,m),iN(Xx,m,c,n,e,t,this)}}else{const f=Math.max(0,o.start),p=Math.min(u.count,o.start+o.count);for(let g=f,y=p;g<y;g++)Xx.fromBufferAttribute(u,g),iN(Xx,g,c,n,e,t,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const n=t[i[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=n.length;r<o;r++){const a=n[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}}function iN(s,e,t,i,n,r,o){const a=IR.distanceSqToPoint(s);if(a<t){const c=new ue;IR.closestPointToPoint(s,c),c.applyMatrix4(i);const l=n.ray.origin.distanceTo(c);if(l<n.near||l>n.far)return;r.push({distance:l,distanceToRay:Math.sqrt(a),point:c,index:e,face:null,object:o})}}class HE extends ms{constructor(e,t,i,n,r,o,a,c,l,h,u,f){super(null,o,a,c,l,h,n,r,u,f),this.isCompressedTexture=!0,this.image={width:t,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class zse extends HE{constructor(e,t,i,n,r,o){super(e,t,i,r,o),this.isCompressedArrayTexture=!0,this.image.depth=n,this.wrapR=Pf}}class Gse extends HE{constructor(e,t,i){super(void 0,e[0].width,e[0].height,t,i,Sne),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class VE extends ed{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new os(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new os(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Gne,this.normalScale=new Sn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new xA,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Gh extends VE{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Sn(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Ir(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new os(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new os(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new os(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}function Yx(s,e,t){return!s||!t&&s.constructor===e?s:typeof e.BYTES_PER_ELEMENT=="number"?new e(s):Array.prototype.slice.call(s)}function Hse(s){return ArrayBuffer.isView(s)&&!(s instanceof DataView)}function Vse(s){function e(n,r){return s[n]-s[r]}const t=s.length,i=new Array(t);for(let n=0;n!==t;++n)i[n]=n;return i.sort(e),i}function nN(s,e,t){const i=s.length,n=new s.constructor(i);for(let r=0,o=0;o!==i;++r){const a=t[r]*e;for(let c=0;c!==e;++c)n[o++]=s[a+c]}return n}function H8(s,e,t,i){let n=1,r=s[0];for(;r!==void 0&&r[i]===void 0;)r=s[n++];if(r===void 0)return;let o=r[i];if(o!==void 0)if(Array.isArray(o))do o=r[i],o!==void 0&&(e.push(r.time),t.push.apply(t,o)),r=s[n++];while(r!==void 0);else if(o.toArray!==void 0)do o=r[i],o!==void 0&&(e.push(r.time),o.toArray(t,t.length)),r=s[n++];while(r!==void 0);else do o=r[i],o!==void 0&&(e.push(r.time),t.push(o)),r=s[n++];while(r!==void 0)}class Sb{constructor(e,t,i,n){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=n!==void 0?n:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let i=this._cachedIndex,n=t[i],r=t[i-1];e:{t:{let o;i:{n:if(!(e<n)){for(let a=i+2;;){if(n===void 0){if(e<r)break n;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===a)break;if(r=n,n=t[++i],e<n)break t}o=t.length;break i}if(!(e>=r)){const a=t[1];e<a&&(i=2,r=a);for(let c=i-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===c)break;if(n=r,r=t[--i-1],e>=r)break t}o=i,i=0;break i}break e}for(;i<o;){const a=i+o>>>1;e<t[a]?o=a:i=a+1}if(n=t[i],r=t[i-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===void 0)return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,r,n)}return this.interpolate_(i,r,e,n)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,i=this.sampleValues,n=this.valueSize,r=e*n;for(let o=0;o!==n;++o)t[o]=i[r+o];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class jse extends Sb{constructor(e,t,i,n){super(e,t,i,n),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:mU,endingEnd:mU}}intervalChanged_(e,t,i){const n=this.parameterPositions;let r=e-2,o=e+1,a=n[r],c=n[o];if(a===void 0)switch(this.getSettings_().endingStart){case AU:r=e,a=2*t-i;break;case yU:r=n.length-2,a=t+n[r]-n[r+1];break;default:r=e,a=i}if(c===void 0)switch(this.getSettings_().endingEnd){case AU:o=e,c=2*i-t;break;case yU:o=1,c=i+n[1]-n[0];break;default:o=e-1,c=t}const l=(i-t)*.5,h=this.valueSize;this._weightPrev=l/(t-a),this._weightNext=l/(c-i),this._offsetPrev=r*h,this._offsetNext=o*h}interpolate_(e,t,i,n){const r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=e*a,l=c-a,h=this._offsetPrev,u=this._offsetNext,f=this._weightPrev,p=this._weightNext,g=(i-t)/(n-t),y=g*g,m=y*g,A=-f*m+2*f*y-f*g,b=(1+f)*m+(-1.5-2*f)*y+(-.5+f)*g+1,v=(-1-p)*m+(1.5+p)*y+.5*g,_=p*m-p*y;for(let w=0;w!==a;++w)r[w]=A*o[h+w]+b*o[l+w]+v*o[c+w]+_*o[u+w];return r}}class Wse extends Sb{constructor(e,t,i,n){super(e,t,i,n)}interpolate_(e,t,i,n){const r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=e*a,l=c-a,h=(i-t)/(n-t),u=1-h;for(let f=0;f!==a;++f)r[f]=o[l+f]*u+o[c+f]*h;return r}}class qse extends Sb{constructor(e,t,i,n){super(e,t,i,n)}interpolate_(e){return this.copySampleValue_(e-1)}}class El{constructor(e,t,i,n){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=Yx(t,this.TimeBufferType),this.values=Yx(i,this.ValueBufferType),this.setInterpolation(n||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let i;if(t.toJSON!==this.toJSON)i=t.toJSON(e);else{i={name:e.name,times:Yx(e.times,Array),values:Yx(e.values,Array)};const n=e.getInterpolation();n!==e.DefaultInterpolation&&(i.interpolation=n)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new qse(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Wse(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new jse(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case Ov:t=this.InterpolantFactoryMethodDiscrete;break;case rA:t=this.InterpolantFactoryMethodLinear;break;case tM:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){const i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(i);return console.warn("THREE.KeyframeTrack:",i),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Ov;case this.InterpolantFactoryMethodLinear:return rA;case this.InterpolantFactoryMethodSmooth:return tM}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let i=0,n=t.length;i!==n;++i)t[i]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let i=0,n=t.length;i!==n;++i)t[i]*=e}return this}trim(e,t){const i=this.times,n=i.length;let r=0,o=n-1;for(;r!==n&&i[r]<e;)++r;for(;o!==-1&&i[o]>t;)--o;if(++o,r!==0||o!==n){r>=o&&(o=Math.max(o,1),r=o-1);const a=this.getValueSize();this.times=i.slice(r,o),this.values=this.values.slice(r*a,o*a)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const i=this.times,n=this.values,r=i.length;r===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==r;a++){const c=i[a];if(typeof c=="number"&&isNaN(c)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,c),e=!1;break}if(o!==null&&o>c){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,c,o),e=!1;break}o=c}if(n!==void 0&&Hse(n))for(let a=0,c=n.length;a!==c;++a){const l=n[a];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,l),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),i=this.getValueSize(),n=this.getInterpolation()===tM,r=e.length-1;let o=1;for(let a=1;a<r;++a){let c=!1;const l=e[a],h=e[a+1];if(l!==h&&(a!==1||l!==e[0]))if(n)c=!0;else{const u=a*i,f=u-i,p=u+i;for(let g=0;g!==i;++g){const y=t[u+g];if(y!==t[f+g]||y!==t[p+g]){c=!0;break}}}if(c){if(a!==o){e[o]=e[a];const u=a*i,f=o*i;for(let p=0;p!==i;++p)t[f+p]=t[u+p]}++o}}if(r>0){e[o]=e[r];for(let a=r*i,c=o*i,l=0;l!==i;++l)t[c+l]=t[a+l];++o}return o!==e.length?(this.times=e.slice(0,o),this.values=t.slice(0,o*i)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),i=this.constructor,n=new i(this.name,e,t);return n.createInterpolant=this.createInterpolant,n}}El.prototype.TimeBufferType=Float32Array;El.prototype.ValueBufferType=Float32Array;El.prototype.DefaultInterpolation=rA;class wA extends El{}wA.prototype.ValueTypeName="bool";wA.prototype.ValueBufferType=Array;wA.prototype.DefaultInterpolation=Ov;wA.prototype.InterpolantFactoryMethodLinear=void 0;wA.prototype.InterpolantFactoryMethodSmooth=void 0;class V8 extends El{}V8.prototype.ValueTypeName="color";class oA extends El{}oA.prototype.ValueTypeName="number";class Xse extends Sb{constructor(e,t,i,n){super(e,t,i,n)}interpolate_(e,t,i,n){const r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=(i-t)/(n-t);let l=e*a;for(let h=l+a;l!==h;l+=4)bd.slerpFlat(r,0,o,l-a,o,l,c);return r}}class gp extends El{InterpolantFactoryMethodLinear(e){return new Xse(this.times,this.values,this.getValueSize(),e)}}gp.prototype.ValueTypeName="quaternion";gp.prototype.DefaultInterpolation=rA;gp.prototype.InterpolantFactoryMethodSmooth=void 0;class CA extends El{}CA.prototype.ValueTypeName="string";CA.prototype.ValueBufferType=Array;CA.prototype.DefaultInterpolation=Ov;CA.prototype.InterpolantFactoryMethodLinear=void 0;CA.prototype.InterpolantFactoryMethodSmooth=void 0;class aA extends El{}aA.prototype.ValueTypeName="vector";class Yse{constructor(e,t=-1,i,n=Qne){this.name=e,this.tracks=i,this.duration=t,this.blendMode=n,this.uuid=xc(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],i=e.tracks,n=1/(e.fps||1);for(let o=0,a=i.length;o!==a;++o)t.push(Kse(i[o]).scale(n));const r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r}static toJSON(e){const t=[],i=e.tracks,n={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let r=0,o=i.length;r!==o;++r)t.push(El.toJSON(i[r]));return n}static CreateFromMorphTargetSequence(e,t,i,n){const r=t.length,o=[];for(let a=0;a<r;a++){let c=[],l=[];c.push((a+r-1)%r,a,(a+1)%r),l.push(0,1,0);const h=Vse(c);c=nN(c,1,h),l=nN(l,1,h),!n&&c[0]===0&&(c.push(r),l.push(l[0])),o.push(new oA(".morphTargetInfluences["+t[a].name+"]",c,l).scale(1/i))}return new this(e,-1,o)}static findByName(e,t){let i=e;if(!Array.isArray(e)){const n=e;i=n.geometry&&n.geometry.animations||n.animations}for(let n=0;n<i.length;n++)if(i[n].name===t)return i[n];return null}static CreateClipsFromMorphTargetSequences(e,t,i){const n={},r=/^([\w-]*?)([\d]+)$/;for(let a=0,c=e.length;a<c;a++){const l=e[a],h=l.name.match(r);if(h&&h.length>1){const u=h[1];let f=n[u];f||(n[u]=f=[]),f.push(l)}}const o=[];for(const a in n)o.push(this.CreateFromMorphTargetSequence(a,n[a],t,i));return o}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const i=function(u,f,p,g,y){if(p.length!==0){const m=[],A=[];H8(p,m,A,g),m.length!==0&&y.push(new u(f,m,A))}},n=[],r=e.name||"default",o=e.fps||30,a=e.blendMode;let c=e.length||-1;const l=e.hierarchy||[];for(let u=0;u<l.length;u++){const f=l[u].keys;if(!(!f||f.length===0))if(f[0].morphTargets){const p={};let g;for(g=0;g<f.length;g++)if(f[g].morphTargets)for(let y=0;y<f[g].morphTargets.length;y++)p[f[g].morphTargets[y]]=-1;for(const y in p){const m=[],A=[];for(let b=0;b!==f[g].morphTargets.length;++b){const v=f[g];m.push(v.time),A.push(v.morphTarget===y?1:0)}n.push(new oA(".morphTargetInfluence["+y+"]",m,A))}c=p.length*o}else{const p=".bones["+t[u].name+"]";i(aA,p+".position",f,"pos",n),i(gp,p+".quaternion",f,"rot",n),i(aA,p+".scale",f,"scl",n)}}return n.length===0?null:new this(r,c,n,a)}resetDuration(){const e=this.tracks;let t=0;for(let i=0,n=e.length;i!==n;++i){const r=this.tracks[i];t=Math.max(t,r.times[r.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function Jse(s){switch(s.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return oA;case"vector":case"vector2":case"vector3":case"vector4":return aA;case"color":return V8;case"quaternion":return gp;case"bool":case"boolean":return wA;case"string":return CA}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+s)}function Kse(s){if(s.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=Jse(s.type);if(s.times===void 0){const t=[],i=[];H8(s.keys,t,i,"value"),s.times=t,s.values=i}return e.parse!==void 0?e.parse(s):new e(s.name,s.times,s.values,s.interpolation)}const Vu={enabled:!1,files:{},add:function(s,e){this.enabled!==!1&&(this.files[s]=e)},get:function(s){if(this.enabled!==!1)return this.files[s]},remove:function(s){delete this.files[s]},clear:function(){this.files={}}};class Zse{constructor(e,t,i){const n=this;let r=!1,o=0,a=0,c;const l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this.itemStart=function(h){a++,r===!1&&n.onStart!==void 0&&n.onStart(h,o,a),r=!0},this.itemEnd=function(h){o++,n.onProgress!==void 0&&n.onProgress(h,o,a),o===a&&(r=!1,n.onLoad!==void 0&&n.onLoad())},this.itemError=function(h){n.onError!==void 0&&n.onError(h)},this.resolveURL=function(h){return c?c(h):h},this.setURLModifier=function(h){return c=h,this},this.addHandler=function(h,u){return l.push(h,u),this},this.removeHandler=function(h){const u=l.indexOf(h);return u!==-1&&l.splice(u,2),this},this.getHandler=function(h){for(let u=0,f=l.length;u<f;u+=2){const p=l[u],g=l[u+1];if(p.global&&(p.lastIndex=0),p.test(h))return g}return null}}}const $se=new Zse;class _d{constructor(e){this.manager=e!==void 0?e:$se,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const i=this;return new Promise(function(n,r){i.load(e,n,t,r)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}}_d.DEFAULT_MATERIAL_NAME="__DEFAULT";const Kl={};class ere extends Error{constructor(e,t){super(e),this.response=t}}class Hf extends _d{constructor(e){super(e)}load(e,t,i,n){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=Vu.get(e);if(r!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(r),this.manager.itemEnd(e)},0),r;if(Kl[e]!==void 0){Kl[e].push({onLoad:t,onProgress:i,onError:n});return}Kl[e]=[],Kl[e].push({onLoad:t,onProgress:i,onError:n});const o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,c=this.responseType;fetch(o).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||l.body===void 0||l.body.getReader===void 0)return l;const h=Kl[e],u=l.body.getReader(),f=l.headers.get("Content-Length")||l.headers.get("X-File-Size"),p=f?parseInt(f):0,g=p!==0;let y=0;const m=new ReadableStream({start(A){b();function b(){u.read().then(({done:v,value:_})=>{if(v)A.close();else{y+=_.byteLength;const w=new ProgressEvent("progress",{lengthComputable:g,loaded:y,total:p});for(let E=0,I=h.length;E<I;E++){const M=h[E];M.onProgress&&M.onProgress(w)}A.enqueue(_),b()}})}}});return new Response(m)}else throw new ere(`fetch for "${l.url}" responded with ${l.status}: ${l.statusText}`,l)}).then(l=>{switch(c){case"arraybuffer":return l.arrayBuffer();case"blob":return l.blob();case"document":return l.text().then(h=>new DOMParser().parseFromString(h,a));case"json":return l.json();default:if(a===void 0)return l.text();{const u=/charset="?([^;"\s]*)"?/i.exec(a),f=u&&u[1]?u[1].toLowerCase():void 0,p=new TextDecoder(f);return l.arrayBuffer().then(g=>p.decode(g))}}}).then(l=>{Vu.add(e,l);const h=Kl[e];delete Kl[e];for(let u=0,f=h.length;u<f;u++){const p=h[u];p.onLoad&&p.onLoad(l)}}).catch(l=>{const h=Kl[e];if(h===void 0)throw this.manager.itemError(e),l;delete Kl[e];for(let u=0,f=h.length;u<f;u++){const p=h[u];p.onError&&p.onError(l)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class tre extends _d{constructor(e){super(e)}load(e,t,i,n){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,o=Vu.get(e);if(o!==void 0)return r.manager.itemStart(e),setTimeout(function(){t&&t(o),r.manager.itemEnd(e)},0),o;const a=SR("img");function c(){h(),Vu.add(e,this),t&&t(this),r.manager.itemEnd(e)}function l(u){h(),n&&n(u),r.manager.itemError(e),r.manager.itemEnd(e)}function h(){a.removeEventListener("load",c,!1),a.removeEventListener("error",l,!1)}return a.addEventListener("load",c,!1),a.addEventListener("error",l,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),r.manager.itemStart(e),a.src=e,a}}class j8 extends _d{constructor(e){super(e)}load(e,t,i,n){const r=new ms,o=new tre(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(e,function(a){r.image=a,r.needsUpdate=!0,t!==void 0&&t(r)},i,n),r}}let V2=class extends qn{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new os(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),t}};const SM=new ai,sN=new ue,rN=new ue;class j2{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Sn(512,512),this.map=null,this.mapPass=null,this.matrix=new ai,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new U8,this._frameExtents=new Sn(1,1),this._viewportCount=1,this._viewports=[new Ta(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,i=this.matrix;sN.setFromMatrixPosition(e.matrixWorld),t.position.copy(sN),rN.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(rN),t.updateMatrixWorld(),SM.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(SM),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(SM)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class ire extends j2{constructor(){super(new N2(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,i=Lv*2*e.angle*this.focus,n=this.mapSize.width/this.mapSize.height,r=e.distance||t.far;(i!==t.fov||n!==t.aspect||r!==t.far)&&(t.fov=i,t.aspect=n,t.far=r,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class nre extends V2{constructor(e,t,i=0,n=Math.PI/3,r=0,o=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(qn.DEFAULT_UP),this.updateMatrix(),this.target=new qn,this.distance=i,this.angle=n,this.penumbra=r,this.decay=o,this.map=null,this.shadow=new ire}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}const oN=new ai,Ey=new ue,EM=new ue;class sre extends j2{constructor(){super(new N2(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Sn(4,2),this._viewportCount=6,this._viewports=[new Ta(2,1,1,1),new Ta(0,1,1,1),new Ta(3,1,1,1),new Ta(1,1,1,1),new Ta(3,0,1,1),new Ta(1,0,1,1)],this._cubeDirections=[new ue(1,0,0),new ue(-1,0,0),new ue(0,0,1),new ue(0,0,-1),new ue(0,1,0),new ue(0,-1,0)],this._cubeUps=[new ue(0,1,0),new ue(0,1,0),new ue(0,1,0),new ue(0,1,0),new ue(0,0,1),new ue(0,0,-1)]}updateMatrices(e,t=0){const i=this.camera,n=this.matrix,r=e.distance||i.far;r!==i.far&&(i.far=r,i.updateProjectionMatrix()),Ey.setFromMatrixPosition(e.matrixWorld),i.position.copy(Ey),EM.copy(i.position),EM.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(EM),i.updateMatrixWorld(),n.makeTranslation(-Ey.x,-Ey.y,-Ey.z),oN.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(oN)}}class rre extends V2{constructor(e,t,i=0,n=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=n,this.shadow=new sre}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class ore extends j2{constructor(){super(new N8(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class are extends V2{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(qn.DEFAULT_UP),this.updateMatrix(),this.target=new qn,this.shadow=new ore}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class z0{static decodeText(e){if(typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let i=0,n=e.length;i<n;i++)t+=String.fromCharCode(e[i]);try{return decodeURIComponent(escape(t))}catch{return t}}static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}class cre extends _d{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,i,n){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,o=Vu.get(e);if(o!==void 0){if(r.manager.itemStart(e),o.then){o.then(l=>{t&&t(l),r.manager.itemEnd(e)}).catch(l=>{n&&n(l)});return}return setTimeout(function(){t&&t(o),r.manager.itemEnd(e)},0),o}const a={};a.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",a.headers=this.requestHeader;const c=fetch(e,a).then(function(l){return l.blob()}).then(function(l){return createImageBitmap(l,Object.assign(r.options,{colorSpaceConversion:"none"}))}).then(function(l){return Vu.add(e,l),t&&t(l),r.manager.itemEnd(e),l}).catch(function(l){n&&n(l),Vu.remove(e),r.manager.itemError(e),r.manager.itemEnd(e)});Vu.add(e,c),r.manager.itemStart(e)}}class lre{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=aN(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=aN();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function aN(){return(typeof performance>"u"?Date:performance).now()}const W2="\\[\\]\\.:\\/",hre=new RegExp("["+W2+"]","g"),q2="[^"+W2+"]",ure="[^"+W2.replace("\\.","")+"]",dre=/((?:WC+[\/:])*)/.source.replace("WC",q2),fre=/(WCOD+)?/.source.replace("WCOD",ure),pre=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",q2),gre=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",q2),mre=new RegExp("^"+dre+fre+pre+gre+"$"),Are=["material","materials","bones","map"];class yre{constructor(e,t,i){const n=i||Li.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,n)}getValue(e,t){this.bind();const i=this._targetGroup.nCachedObjects_,n=this._bindings[i];n!==void 0&&n.getValue(e,t)}setValue(e,t){const i=this._bindings;for(let n=this._targetGroup.nCachedObjects_,r=i.length;n!==r;++n)i[n].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}}class Li{constructor(e,t,i){this.path=t,this.parsedPath=i||Li.parseTrackName(t),this.node=Li.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new Li.Composite(e,t,i):new Li(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(hre,"")}static parseTrackName(e){const t=mre.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},n=i.nodeName&&i.nodeName.lastIndexOf(".");if(n!==void 0&&n!==-1){const r=i.nodeName.substring(n+1);Are.indexOf(r)!==-1&&(i.nodeName=i.nodeName.substring(0,n),i.objectName=r)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){const i=function(r){for(let o=0;o<r.length;o++){const a=r[o];if(a.name===t||a.uuid===t)return a;const c=i(a.children);if(c)return c}return null},n=i(e.children);if(n)return n}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)e[t++]=i[n]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)i[n]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)i[n]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)i[n]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,i=t.objectName,n=t.propertyName;let r=t.propertyIndex;if(e||(e=Li.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(i){let l=t.objectIndex;switch(i){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let h=0;h<e.length;h++)if(e[h].name===l){l=h;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[i]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[i]}if(l!==void 0){if(e[l]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[l]}}const o=e[n];if(o===void 0){const l=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+l+"."+n+" but it wasn't found.",e);return}let a=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?a=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(r!==void 0){if(n==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[r]!==void 0&&(r=e.morphTargetDictionary[r])}c=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=r}else o.fromArray!==void 0&&o.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(c=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=n;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}Li.Composite=yre;Li.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Li.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Li.prototype.GetterByBindingType=[Li.prototype._getValue_direct,Li.prototype._getValue_array,Li.prototype._getValue_arrayElement,Li.prototype._getValue_toArray];Li.prototype.SetterByBindingTypeAndVersioning=[[Li.prototype._setValue_direct,Li.prototype._setValue_direct_setNeedsUpdate,Li.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Li.prototype._setValue_array,Li.prototype._setValue_array_setNeedsUpdate,Li.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Li.prototype._setValue_arrayElement,Li.prototype._setValue_arrayElement_setNeedsUpdate,Li.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Li.prototype._setValue_fromArray,Li.prototype._setValue_fromArray_setNeedsUpdate,Li.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:vR}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported. Existing: "+window.__THREE__+", new: "+vR):window.__THREE__=vR);function cN(s,e){if(e===zne)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),s;if(e===_R||e===D8){let t=s.getIndex();if(t===null){const o=[],a=s.getAttribute("position");if(a!==void 0){for(let c=0;c<a.count;c++)o.push(c);s.setIndex(o),t=s.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),s}const i=t.count-2,n=[];if(e===_R)for(let o=1;o<=i;o++)n.push(t.getX(0)),n.push(t.getX(o)),n.push(t.getX(o+1));else for(let o=0;o<i;o++)o%2===0?(n.push(t.getX(o)),n.push(t.getX(o+1)),n.push(t.getX(o+2))):(n.push(t.getX(o+2)),n.push(t.getX(o+1)),n.push(t.getX(o)));n.length/3!==i&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const r=s.clone();return r.setIndex(n),r.clearGroups(),r}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),s}let vre=class extends _d{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new Cre(t)}),this.register(function(t){return new Dre(t)}),this.register(function(t){return new kre(t)}),this.register(function(t){return new Ore(t)}),this.register(function(t){return new Ere(t)}),this.register(function(t){return new Ire(t)}),this.register(function(t){return new Mre(t)}),this.register(function(t){return new Tre(t)}),this.register(function(t){return new wre(t)}),this.register(function(t){return new Bre(t)}),this.register(function(t){return new Sre(t)}),this.register(function(t){return new Pre(t)}),this.register(function(t){return new Rre(t)}),this.register(function(t){return new _re(t)}),this.register(function(t){return new Lre(t)}),this.register(function(t){return new Fre(t)})}load(e,t,i,n){const r=this;let o;if(this.resourcePath!=="")o=this.resourcePath;else if(this.path!==""){const l=z0.extractUrlBase(e);o=z0.resolveURL(l,this.path)}else o=z0.extractUrlBase(e);this.manager.itemStart(e);const a=function(l){n?n(l):console.error(l),r.manager.itemError(e),r.manager.itemEnd(e)},c=new Hf(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(this.withCredentials),c.load(e,function(l){try{r.parse(l,o,function(h){t(h),r.manager.itemEnd(e)},a)}catch(h){a(h)}},i,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,i,n){let r;const o={},a={},c=new TextDecoder;if(typeof e=="string")r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(c.decode(new Uint8Array(e,0,4))===W8){try{o[li.KHR_BINARY_GLTF]=new Ure(e)}catch(u){n&&n(u);return}r=JSON.parse(o[li.KHR_BINARY_GLTF].content)}else r=JSON.parse(c.decode(e));else r=e;if(r.asset===void 0||r.asset.version[0]<2){n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const l=new Kre(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let h=0;h<this.pluginCallbacks.length;h++){const u=this.pluginCallbacks[h](l);u.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[u.name]=u,o[u.name]=!0}if(r.extensionsUsed)for(let h=0;h<r.extensionsUsed.length;++h){const u=r.extensionsUsed[h],f=r.extensionsRequired||[];switch(u){case li.KHR_MATERIALS_UNLIT:o[u]=new xre;break;case li.KHR_DRACO_MESH_COMPRESSION:o[u]=new Nre(r,this.dracoLoader);break;case li.KHR_TEXTURE_TRANSFORM:o[u]=new Qre;break;case li.KHR_MESH_QUANTIZATION:o[u]=new zre;break;default:f.indexOf(u)>=0&&a[u]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}l.setExtensions(o),l.setPlugins(a),l.parse(i,n)}parseAsync(e,t){const i=this;return new Promise(function(n,r){i.parse(e,t,n,r)})}};function bre(){let s={};return{get:function(e){return s[e]},add:function(e,t){s[e]=t},remove:function(e){delete s[e]},removeAll:function(){s={}}}}const li={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};let _re=class{constructor(e){this.parser=e,this.name=li.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let i=0,n=t.length;i<n;i++){const r=t[i];r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){const t=this.parser,i="light:"+e;let n=t.cache.get(i);if(n)return n;const r=t.json,c=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e];let l;const h=new os(16777215);c.color!==void 0&&h.setRGB(c.color[0],c.color[1],c.color[2],Co);const u=c.range!==void 0?c.range:0;switch(c.type){case"directional":l=new are(h),l.target.position.set(0,0,-1),l.add(l.target);break;case"point":l=new rre(h),l.distance=u;break;case"spot":l=new nre(h),l.distance=u,c.spot=c.spot||{},c.spot.innerConeAngle=c.spot.innerConeAngle!==void 0?c.spot.innerConeAngle:0,c.spot.outerConeAngle=c.spot.outerConeAngle!==void 0?c.spot.outerConeAngle:Math.PI/4,l.angle=c.spot.outerConeAngle,l.penumbra=1-c.spot.innerConeAngle/c.spot.outerConeAngle,l.target.position.set(0,0,-1),l.add(l.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+c.type)}return l.position.set(0,0,0),l.decay=2,Ru(l,c),c.intensity!==void 0&&(l.intensity=c.intensity),l.name=t.createUniqueName(c.name||"light_"+e),n=Promise.resolve(l),t.cache.add(i,n),n}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,i=this.parser,r=i.json.nodes[e],a=(r.extensions&&r.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(c){return i._getNodeRef(t.cache,a,c)})}},xre=class{constructor(){this.name=li.KHR_MATERIALS_UNLIT}getMaterialType(){return vm}extendParams(e,t,i){const n=[];e.color=new os(1,1,1),e.opacity=1;const r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const o=r.baseColorFactor;e.color.setRGB(o[0],o[1],o[2],Co),e.opacity=o[3]}r.baseColorTexture!==void 0&&n.push(i.assignTexture(e,"map",r.baseColorTexture,Er))}return Promise.all(n)}},wre=class{constructor(e){this.parser=e,this.name=li.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=n.extensions[this.name].emissiveStrength;return r!==void 0&&(t.emissiveIntensity=r),Promise.resolve()}},Cre=class{constructor(e){this.parser=e,this.name=li.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:Gh}extendMaterialParams(e,t){const i=this.parser,n=i.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],o=n.extensions[this.name];if(o.clearcoatFactor!==void 0&&(t.clearcoat=o.clearcoatFactor),o.clearcoatTexture!==void 0&&r.push(i.assignTexture(t,"clearcoatMap",o.clearcoatTexture)),o.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=o.clearcoatRoughnessFactor),o.clearcoatRoughnessTexture!==void 0&&r.push(i.assignTexture(t,"clearcoatRoughnessMap",o.clearcoatRoughnessTexture)),o.clearcoatNormalTexture!==void 0&&(r.push(i.assignTexture(t,"clearcoatNormalMap",o.clearcoatNormalTexture)),o.clearcoatNormalTexture.scale!==void 0)){const a=o.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new Sn(a,a)}return Promise.all(r)}},Sre=class{constructor(e){this.parser=e,this.name=li.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:Gh}extendMaterialParams(e,t){const i=this.parser,n=i.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],o=n.extensions[this.name];return o.iridescenceFactor!==void 0&&(t.iridescence=o.iridescenceFactor),o.iridescenceTexture!==void 0&&r.push(i.assignTexture(t,"iridescenceMap",o.iridescenceTexture)),o.iridescenceIor!==void 0&&(t.iridescenceIOR=o.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),o.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=o.iridescenceThicknessMinimum),o.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=o.iridescenceThicknessMaximum),o.iridescenceThicknessTexture!==void 0&&r.push(i.assignTexture(t,"iridescenceThicknessMap",o.iridescenceThicknessTexture)),Promise.all(r)}},Ere=class{constructor(e){this.parser=e,this.name=li.KHR_MATERIALS_SHEEN}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:Gh}extendMaterialParams(e,t){const i=this.parser,n=i.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[];t.sheenColor=new os(0,0,0),t.sheenRoughness=0,t.sheen=1;const o=n.extensions[this.name];if(o.sheenColorFactor!==void 0){const a=o.sheenColorFactor;t.sheenColor.setRGB(a[0],a[1],a[2],Co)}return o.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=o.sheenRoughnessFactor),o.sheenColorTexture!==void 0&&r.push(i.assignTexture(t,"sheenColorMap",o.sheenColorTexture,Er)),o.sheenRoughnessTexture!==void 0&&r.push(i.assignTexture(t,"sheenRoughnessMap",o.sheenRoughnessTexture)),Promise.all(r)}},Ire=class{constructor(e){this.parser=e,this.name=li.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:Gh}extendMaterialParams(e,t){const i=this.parser,n=i.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],o=n.extensions[this.name];return o.transmissionFactor!==void 0&&(t.transmission=o.transmissionFactor),o.transmissionTexture!==void 0&&r.push(i.assignTexture(t,"transmissionMap",o.transmissionTexture)),Promise.all(r)}},Mre=class{constructor(e){this.parser=e,this.name=li.KHR_MATERIALS_VOLUME}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:Gh}extendMaterialParams(e,t){const i=this.parser,n=i.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],o=n.extensions[this.name];t.thickness=o.thicknessFactor!==void 0?o.thicknessFactor:0,o.thicknessTexture!==void 0&&r.push(i.assignTexture(t,"thicknessMap",o.thicknessTexture)),t.attenuationDistance=o.attenuationDistance||1/0;const a=o.attenuationColor||[1,1,1];return t.attenuationColor=new os().setRGB(a[0],a[1],a[2],Co),Promise.all(r)}},Tre=class{constructor(e){this.parser=e,this.name=li.KHR_MATERIALS_IOR}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:Gh}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=n.extensions[this.name];return t.ior=r.ior!==void 0?r.ior:1.5,Promise.resolve()}},Bre=class{constructor(e){this.parser=e,this.name=li.KHR_MATERIALS_SPECULAR}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:Gh}extendMaterialParams(e,t){const i=this.parser,n=i.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],o=n.extensions[this.name];t.specularIntensity=o.specularFactor!==void 0?o.specularFactor:1,o.specularTexture!==void 0&&r.push(i.assignTexture(t,"specularIntensityMap",o.specularTexture));const a=o.specularColorFactor||[1,1,1];return t.specularColor=new os().setRGB(a[0],a[1],a[2],Co),o.specularColorTexture!==void 0&&r.push(i.assignTexture(t,"specularColorMap",o.specularColorTexture,Er)),Promise.all(r)}},Rre=class{constructor(e){this.parser=e,this.name=li.EXT_MATERIALS_BUMP}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:Gh}extendMaterialParams(e,t){const i=this.parser,n=i.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],o=n.extensions[this.name];return t.bumpScale=o.bumpFactor!==void 0?o.bumpFactor:1,o.bumpTexture!==void 0&&r.push(i.assignTexture(t,"bumpMap",o.bumpTexture)),Promise.all(r)}},Pre=class{constructor(e){this.parser=e,this.name=li.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:Gh}extendMaterialParams(e,t){const i=this.parser,n=i.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],o=n.extensions[this.name];return o.anisotropyStrength!==void 0&&(t.anisotropy=o.anisotropyStrength),o.anisotropyRotation!==void 0&&(t.anisotropyRotation=o.anisotropyRotation),o.anisotropyTexture!==void 0&&r.push(i.assignTexture(t,"anisotropyMap",o.anisotropyTexture)),Promise.all(r)}},Dre=class{constructor(e){this.parser=e,this.name=li.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,i=t.json,n=i.textures[e];if(!n.extensions||!n.extensions[this.name])return null;const r=n.extensions[this.name],o=t.options.ktx2Loader;if(!o){if(i.extensionsRequired&&i.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,o)}},kre=class{constructor(e){this.parser=e,this.name=li.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,i=this.parser,n=i.json,r=n.textures[e];if(!r.extensions||!r.extensions[t])return null;const o=r.extensions[t],a=n.images[o.source];let c=i.textureLoader;if(a.uri){const l=i.options.manager.getHandler(a.uri);l!==null&&(c=l)}return this.detectSupport().then(function(l){if(l)return i.loadTextureImage(e,o.source,c);if(n.extensionsRequired&&n.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return i.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}},Ore=class{constructor(e){this.parser=e,this.name=li.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,i=this.parser,n=i.json,r=n.textures[e];if(!r.extensions||!r.extensions[t])return null;const o=r.extensions[t],a=n.images[o.source];let c=i.textureLoader;if(a.uri){const l=i.options.manager.getHandler(a.uri);l!==null&&(c=l)}return this.detectSupport().then(function(l){if(l)return i.loadTextureImage(e,o.source,c);if(n.extensionsRequired&&n.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return i.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}},Lre=class{constructor(e){this.name=li.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,i=t.bufferViews[e];if(i.extensions&&i.extensions[this.name]){const n=i.extensions[this.name],r=this.parser.getDependency("buffer",n.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return r.then(function(a){const c=n.byteOffset||0,l=n.byteLength||0,h=n.count,u=n.byteStride,f=new Uint8Array(a,c,l);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(h,u,f,n.mode,n.filter).then(function(p){return p.buffer}):o.ready.then(function(){const p=new ArrayBuffer(h*u);return o.decodeGltfBuffer(new Uint8Array(p),h,u,f,n.mode,n.filter),p})})}else return null}},Fre=class{constructor(e){this.name=li.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,i=t.nodes[e];if(!i.extensions||!i.extensions[this.name]||i.mesh===void 0)return null;const n=t.meshes[i.mesh];for(const l of n.primitives)if(l.mode!==xa.TRIANGLES&&l.mode!==xa.TRIANGLE_STRIP&&l.mode!==xa.TRIANGLE_FAN&&l.mode!==void 0)return null;const o=i.extensions[this.name].attributes,a=[],c={};for(const l in o)a.push(this.parser.getDependency("accessor",o[l]).then(h=>(c[l]=h,c[l])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(l=>{const h=l.pop(),u=h.isGroup?h.children:[h],f=l[0].count,p=[];for(const g of u){const y=new ai,m=new ue,A=new bd,b=new ue(1,1,1),v=new Fse(g.geometry,g.material,f);for(let _=0;_<f;_++)c.TRANSLATION&&m.fromBufferAttribute(c.TRANSLATION,_),c.ROTATION&&A.fromBufferAttribute(c.ROTATION,_),c.SCALE&&b.fromBufferAttribute(c.SCALE,_),v.setMatrixAt(_,y.compose(m,A,b));for(const _ in c)if(_==="_COLOR_0"){const w=c[_];v.instanceColor=new ER(w.array,w.itemSize,w.normalized)}else _!=="TRANSLATION"&&_!=="ROTATION"&&_!=="SCALE"&&g.geometry.setAttribute(_,c[_]);qn.prototype.copy.call(v,g),this.parser.assignFinalMaterial(v),p.push(v)}return h.isGroup?(h.clear(),h.add(...p),h):p[0]}))}};const W8="glTF",Iy=12,lN={JSON:1313821514,BIN:5130562};let Ure=class{constructor(e){this.name=li.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,Iy),i=new TextDecoder;if(this.header={magic:i.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==W8)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-Iy,r=new DataView(e,Iy);let o=0;for(;o<n;){const a=r.getUint32(o,!0);o+=4;const c=r.getUint32(o,!0);if(o+=4,c===lN.JSON){const l=new Uint8Array(e,Iy+o,a);this.content=i.decode(l)}else if(c===lN.BIN){const l=Iy+o;this.body=e.slice(l,l+a)}o+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}},Nre=class{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=li.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const i=this.json,n=this.dracoLoader,r=e.extensions[this.name].bufferView,o=e.extensions[this.name].attributes,a={},c={},l={};for(const h in o){const u=MR[h]||h.toLowerCase();a[u]=o[h]}for(const h in e.attributes){const u=MR[h]||h.toLowerCase();if(o[h]!==void 0){const f=i.accessors[e.attributes[h]],p=Fm[f.componentType];l[u]=p.name,c[u]=f.normalized===!0}}return t.getDependency("bufferView",r).then(function(h){return new Promise(function(u,f){n.decodeDracoFile(h,function(p){for(const g in p.attributes){const y=p.attributes[g],m=c[g];m!==void 0&&(y.normalized=m)}u(p)},a,l,Co,f)})})}},Qre=class{constructor(){this.name=li.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}},zre=class{constructor(){this.name=li.KHR_MESH_QUANTIZATION}},q8=class extends Sb{constructor(e,t,i,n){super(e,t,i,n)}copySampleValue_(e){const t=this.resultBuffer,i=this.sampleValues,n=this.valueSize,r=e*n*3+n;for(let o=0;o!==n;o++)t[o]=i[r+o];return t}interpolate_(e,t,i,n){const r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=a*2,l=a*3,h=n-t,u=(i-t)/h,f=u*u,p=f*u,g=e*l,y=g-l,m=-2*p+3*f,A=p-f,b=1-m,v=A-f+u;for(let _=0;_!==a;_++){const w=o[y+_+a],E=o[y+_+c]*h,I=o[g+_+a],M=o[g+_]*h;r[_]=b*w+v*E+m*I+A*M}return r}};const Gre=new bd;let Hre=class extends q8{interpolate_(e,t,i,n){const r=super.interpolate_(e,t,i,n);return Gre.fromArray(r).normalize().toArray(r),r}};const xa={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},Fm={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},hN={9728:fp,9729:kv,9984:Ene,9985:Mne,9986:Ine,9987:QE},uN={33071:Pf,33648:bR,10497:Dv},IM={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},MR={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},fu={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Vre={CUBICSPLINE:void 0,LINEAR:rA,STEP:Ov},MM={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function jre(s){return s.DefaultMaterial===void 0&&(s.DefaultMaterial=new VE({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:lS})),s.DefaultMaterial}function $d(s,e,t){for(const i in t.extensions)s[i]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[i]=t.extensions[i])}function Ru(s,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(s.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function Wre(s,e,t){let i=!1,n=!1,r=!1;for(let l=0,h=e.length;l<h;l++){const u=e[l];if(u.POSITION!==void 0&&(i=!0),u.NORMAL!==void 0&&(n=!0),u.COLOR_0!==void 0&&(r=!0),i&&n&&r)break}if(!i&&!n&&!r)return Promise.resolve(s);const o=[],a=[],c=[];for(let l=0,h=e.length;l<h;l++){const u=e[l];if(i){const f=u.POSITION!==void 0?t.getDependency("accessor",u.POSITION):s.attributes.position;o.push(f)}if(n){const f=u.NORMAL!==void 0?t.getDependency("accessor",u.NORMAL):s.attributes.normal;a.push(f)}if(r){const f=u.COLOR_0!==void 0?t.getDependency("accessor",u.COLOR_0):s.attributes.color;c.push(f)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(c)]).then(function(l){const h=l[0],u=l[1],f=l[2];return i&&(s.morphAttributes.position=h),n&&(s.morphAttributes.normal=u),r&&(s.morphAttributes.color=f),s.morphTargetsRelative=!0,s})}function qre(s,e){if(s.updateMorphTargets(),e.weights!==void 0)for(let t=0,i=e.weights.length;t<i;t++)s.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(s.morphTargetInfluences.length===t.length){s.morphTargetDictionary={};for(let i=0,n=t.length;i<n;i++)s.morphTargetDictionary[t[i]]=i}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Xre(s){let e;const t=s.extensions&&s.extensions[li.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+TM(t.attributes):e=s.indices+":"+TM(s.attributes)+":"+s.mode,s.targets!==void 0)for(let i=0,n=s.targets.length;i<n;i++)e+=":"+TM(s.targets[i]);return e}function TM(s){let e="";const t=Object.keys(s).sort();for(let i=0,n=t.length;i<n;i++)e+=t[i]+":"+s[t[i]]+";";return e}function TR(s){switch(s){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function Yre(s){return s.search(/\.jpe?g($|\?)/i)>0||s.search(/^data\:image\/jpeg/)===0?"image/jpeg":s.search(/\.webp($|\?)/i)>0||s.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}const Jre=new ai;let Kre=class{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new bre,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let i=!1,n=!1,r=-1;typeof navigator<"u"&&(i=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,n=navigator.userAgent.indexOf("Firefox")>-1,r=n?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||i||n&&r<98?this.textureLoader=new j8(this.options.manager):this.textureLoader=new cre(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Hf(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const i=this,n=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([i.getDependencies("scene"),i.getDependencies("animation"),i.getDependencies("camera")])}).then(function(o){const a={scene:o[0][n.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:n.asset,parser:i,userData:{}};return $d(r,a,n),Ru(a,n),Promise.all(i._invokeAll(function(c){return c.afterRoot&&c.afterRoot(a)})).then(function(){e(a)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],i=this.json.meshes||[];for(let n=0,r=t.length;n<r;n++){const o=t[n].joints;for(let a=0,c=o.length;a<c;a++)e[o[a]].isBone=!0}for(let n=0,r=e.length;n<r;n++){const o=e[n];o.mesh!==void 0&&(this._addNodeRef(this.meshCache,o.mesh),o.skin!==void 0&&(i[o.mesh].isSkinnedMesh=!0)),o.camera!==void 0&&this._addNodeRef(this.cameraCache,o.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,i){if(e.refs[t]<=1)return i;const n=i.clone(),r=(o,a)=>{const c=this.associations.get(o);c!=null&&this.associations.set(a,c);for(const[l,h]of o.children.entries())r(h,a.children[l])};return r(i,n),n.name+="_instance_"+e.uses[t]++,n}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let i=0;i<t.length;i++){const n=e(t[i]);if(n)return n}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const i=[];for(let n=0;n<t.length;n++){const r=e(t[n]);r&&i.push(r)}return i}getDependency(e,t){const i=e+":"+t;let n=this.cache.get(i);if(!n){switch(e){case"scene":n=this.loadScene(t);break;case"node":n=this._invokeOne(function(r){return r.loadNode&&r.loadNode(t)});break;case"mesh":n=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(t)});break;case"accessor":n=this.loadAccessor(t);break;case"bufferView":n=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(t)});break;case"buffer":n=this.loadBuffer(t);break;case"material":n=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(t)});break;case"texture":n=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(t)});break;case"skin":n=this.loadSkin(t);break;case"animation":n=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(t)});break;case"camera":n=this.loadCamera(t);break;default:if(n=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(e,t)}),!n)throw new Error("Unknown type: "+e);break}this.cache.add(i,n)}return n}getDependencies(e){let t=this.cache.get(e);if(!t){const i=this,n=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(n.map(function(r,o){return i.getDependency(e,o)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],i=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[li.KHR_BINARY_GLTF].body);const n=this.options;return new Promise(function(r,o){i.load(z0.resolveURL(t.uri,n.path),r,void 0,function(){o(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(i){const n=t.byteLength||0,r=t.byteOffset||0;return i.slice(r,r+n)})}loadAccessor(e){const t=this,i=this.json,n=this.json.accessors[e];if(n.bufferView===void 0&&n.sparse===void 0){const o=IM[n.type],a=Fm[n.componentType],c=n.normalized===!0,l=new a(n.count*o);return Promise.resolve(new Zo(l,o,c))}const r=[];return n.bufferView!==void 0?r.push(this.getDependency("bufferView",n.bufferView)):r.push(null),n.sparse!==void 0&&(r.push(this.getDependency("bufferView",n.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",n.sparse.values.bufferView))),Promise.all(r).then(function(o){const a=o[0],c=IM[n.type],l=Fm[n.componentType],h=l.BYTES_PER_ELEMENT,u=h*c,f=n.byteOffset||0,p=n.bufferView!==void 0?i.bufferViews[n.bufferView].byteStride:void 0,g=n.normalized===!0;let y,m;if(p&&p!==u){const A=Math.floor(f/p),b="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+A+":"+n.count;let v=t.cache.get(b);v||(y=new l(a,A*p,n.count*p/h),v=new Pse(y,p/h),t.cache.add(b,v)),m=new Q2(v,c,f%p/h,g)}else a===null?y=new l(n.count*c):y=new l(a,f,n.count*c),m=new Zo(y,c,g);if(n.sparse!==void 0){const A=IM.SCALAR,b=Fm[n.sparse.indices.componentType],v=n.sparse.indices.byteOffset||0,_=n.sparse.values.byteOffset||0,w=new b(o[1],v,n.sparse.count*A),E=new l(o[2],_,n.sparse.count*c);a!==null&&(m=new Zo(m.array.slice(),m.itemSize,m.normalized));for(let I=0,M=w.length;I<M;I++){const R=w[I];if(m.setX(R,E[I*c]),c>=2&&m.setY(R,E[I*c+1]),c>=3&&m.setZ(R,E[I*c+2]),c>=4&&m.setW(R,E[I*c+3]),c>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return m})}loadTexture(e){const t=this.json,i=this.options,r=t.textures[e].source,o=t.images[r];let a=this.textureLoader;if(o.uri){const c=i.manager.getHandler(o.uri);c!==null&&(a=c)}return this.loadTextureImage(e,r,a)}loadTextureImage(e,t,i){const n=this,r=this.json,o=r.textures[e],a=r.images[t],c=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[c])return this.textureCache[c];const l=this.loadImageSource(t,i).then(function(h){h.flipY=!1,h.name=o.name||a.name||"",h.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(h.name=a.uri);const f=(r.samplers||{})[o.sampler]||{};return h.magFilter=hN[f.magFilter]||kv,h.minFilter=hN[f.minFilter]||QE,h.wrapS=uN[f.wrapS]||Dv,h.wrapT=uN[f.wrapT]||Dv,h.anisotropy=4,n.associations.set(h,{textures:e}),h}).catch(function(){return null});return this.textureCache[c]=l,l}loadImageSource(e,t){const i=this,n=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(u=>u.clone());const o=n.images[e],a=self.URL||self.webkitURL;let c=o.uri||"",l=!1;if(o.bufferView!==void 0)c=i.getDependency("bufferView",o.bufferView).then(function(u){l=!0;const f=new Blob([u],{type:o.mimeType});return c=a.createObjectURL(f),c});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const h=Promise.resolve(c).then(function(u){return new Promise(function(f,p){let g=f;t.isImageBitmapLoader===!0&&(g=function(y){const m=new ms(y);m.needsUpdate=!0,f(m)}),t.load(z0.resolveURL(u,r.path),g,void 0,p)})}).then(function(u){return l===!0&&a.revokeObjectURL(c),u.userData.mimeType=o.mimeType||Yre(o.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",c),u});return this.sourceCache[e]=h,h}assignTexture(e,t,i,n){const r=this;return this.getDependency("texture",i.index).then(function(o){if(!o)return null;if(i.texCoord!==void 0&&i.texCoord>0&&(o=o.clone(),o.channel=i.texCoord),r.extensions[li.KHR_TEXTURE_TRANSFORM]){const a=i.extensions!==void 0?i.extensions[li.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const c=r.associations.get(o);o=r.extensions[li.KHR_TEXTURE_TRANSFORM].extendTexture(o,a),r.associations.set(o,c)}}return n!==void 0&&(o.colorSpace=n),e[t]=o,o})}assignFinalMaterial(e){const t=e.geometry;let i=e.material;const n=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){const a="PointsMaterial:"+i.uuid;let c=this.cache.get(a);c||(c=new G8,ed.prototype.copy.call(c,i),c.color.copy(i.color),c.map=i.map,c.sizeAttenuation=!1,this.cache.add(a,c)),i=c}else if(e.isLine){const a="LineBasicMaterial:"+i.uuid;let c=this.cache.get(a);c||(c=new z8,ed.prototype.copy.call(c,i),c.color.copy(i.color),c.map=i.map,this.cache.add(a,c)),i=c}if(n||r||o){let a="ClonedMaterial:"+i.uuid+":";n&&(a+="derivative-tangents:"),r&&(a+="vertex-colors:"),o&&(a+="flat-shading:");let c=this.cache.get(a);c||(c=i.clone(),r&&(c.vertexColors=!0),o&&(c.flatShading=!0),n&&(c.normalScale&&(c.normalScale.y*=-1),c.clearcoatNormalScale&&(c.clearcoatNormalScale.y*=-1)),this.cache.add(a,c),this.associations.set(c,this.associations.get(i))),i=c}e.material=i}getMaterialType(){return VE}loadMaterial(e){const t=this,i=this.json,n=this.extensions,r=i.materials[e];let o;const a={},c=r.extensions||{},l=[];if(c[li.KHR_MATERIALS_UNLIT]){const u=n[li.KHR_MATERIALS_UNLIT];o=u.getMaterialType(),l.push(u.extendParams(a,r,t))}else{const u=r.pbrMetallicRoughness||{};if(a.color=new os(1,1,1),a.opacity=1,Array.isArray(u.baseColorFactor)){const f=u.baseColorFactor;a.color.setRGB(f[0],f[1],f[2],Co),a.opacity=f[3]}u.baseColorTexture!==void 0&&l.push(t.assignTexture(a,"map",u.baseColorTexture,Er)),a.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,a.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(l.push(t.assignTexture(a,"metalnessMap",u.metallicRoughnessTexture)),l.push(t.assignTexture(a,"roughnessMap",u.metallicRoughnessTexture))),o=this._invokeOne(function(f){return f.getMaterialType&&f.getMaterialType(e)}),l.push(Promise.all(this._invokeAll(function(f){return f.extendMaterialParams&&f.extendMaterialParams(e,a)})))}r.doubleSided===!0&&(a.side=xne);const h=r.alphaMode||MM.OPAQUE;if(h===MM.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,h===MM.MASK&&(a.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&o!==vm&&(l.push(t.assignTexture(a,"normalMap",r.normalTexture)),a.normalScale=new Sn(1,1),r.normalTexture.scale!==void 0)){const u=r.normalTexture.scale;a.normalScale.set(u,u)}if(r.occlusionTexture!==void 0&&o!==vm&&(l.push(t.assignTexture(a,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&o!==vm){const u=r.emissiveFactor;a.emissive=new os().setRGB(u[0],u[1],u[2],Co)}return r.emissiveTexture!==void 0&&o!==vm&&l.push(t.assignTexture(a,"emissiveMap",r.emissiveTexture,Er)),Promise.all(l).then(function(){const u=new o(a);return r.name&&(u.name=r.name),Ru(u,r),t.associations.set(u,{materials:e}),r.extensions&&$d(n,u,r),u})}createUniqueName(e){const t=Li.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,i=this.extensions,n=this.primitiveCache;function r(a){return i[li.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(c){return dN(c,a,t)})}const o=[];for(let a=0,c=e.length;a<c;a++){const l=e[a],h=Xre(l),u=n[h];if(u)o.push(u.promise);else{let f;l.extensions&&l.extensions[li.KHR_DRACO_MESH_COMPRESSION]?f=r(l):f=dN(new Sc,l,t),n[h]={primitive:l,promise:f},o.push(f)}}return Promise.all(o)}loadMesh(e){const t=this,i=this.json,n=this.extensions,r=i.meshes[e],o=r.primitives,a=[];for(let c=0,l=o.length;c<l;c++){const h=o[c].material===void 0?jre(this.cache):this.getDependency("material",o[c].material);a.push(h)}return a.push(t.loadGeometries(o)),Promise.all(a).then(function(c){const l=c.slice(0,c.length-1),h=c[c.length-1],u=[];for(let p=0,g=h.length;p<g;p++){const y=h[p],m=o[p];let A;const b=l[p];if(m.mode===xa.TRIANGLES||m.mode===xa.TRIANGLE_STRIP||m.mode===xa.TRIANGLE_FAN||m.mode===void 0)A=r.isSkinnedMesh===!0?new kse(y,b):new pp(y,b),A.isSkinnedMesh===!0&&A.normalizeSkinWeights(),m.mode===xa.TRIANGLE_STRIP?A.geometry=cN(A.geometry,D8):m.mode===xa.TRIANGLE_FAN&&(A.geometry=cN(A.geometry,_R));else if(m.mode===xa.LINES)A=new Use(y,b);else if(m.mode===xa.LINE_STRIP)A=new H2(y,b);else if(m.mode===xa.LINE_LOOP)A=new Nse(y,b);else if(m.mode===xa.POINTS)A=new Qse(y,b);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+m.mode);Object.keys(A.geometry.morphAttributes).length>0&&qre(A,r),A.name=t.createUniqueName(r.name||"mesh_"+e),Ru(A,r),m.extensions&&$d(n,A,m),t.assignFinalMaterial(A),u.push(A)}for(let p=0,g=u.length;p<g;p++)t.associations.set(u[p],{meshes:e,primitives:p});if(u.length===1)return r.extensions&&$d(n,u[0],r),u[0];const f=new _M;r.extensions&&$d(n,f,r),t.associations.set(f,{meshes:e});for(let p=0,g=u.length;p<g;p++)f.add(u[p]);return f})}loadCamera(e){let t;const i=this.json.cameras[e],n=i[i.type];if(!n){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return i.type==="perspective"?t=new N2(ose.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):i.type==="orthographic"&&(t=new N8(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),i.name&&(t.name=this.createUniqueName(i.name)),Ru(t,i),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],i=[];for(let n=0,r=t.joints.length;n<r;n++)i.push(this._loadNodeShallow(t.joints[n]));return t.inverseBindMatrices!==void 0?i.push(this.getDependency("accessor",t.inverseBindMatrices)):i.push(null),Promise.all(i).then(function(n){const r=n.pop(),o=n,a=[],c=[];for(let l=0,h=o.length;l<h;l++){const u=o[l];if(u){a.push(u);const f=new ai;r!==null&&f.fromArray(r.array,l*16),c.push(f)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[l])}return new G2(a,c)})}loadAnimation(e){const t=this.json,i=this,n=t.animations[e],r=n.name?n.name:"animation_"+e,o=[],a=[],c=[],l=[],h=[];let u=0,f=n.channels.length;for(u=0,f=n.channels.length;u<f;u++){const p=n.channels[u],g=n.samplers[p.sampler],y=p.target,m=y.node,A=n.parameters!==void 0?n.parameters[g.input]:g.input,b=n.parameters!==void 0?n.parameters[g.output]:g.output;y.node!==void 0&&(o.push(this.getDependency("node",m)),a.push(this.getDependency("accessor",A)),c.push(this.getDependency("accessor",b)),l.push(g),h.push(y))}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(c),Promise.all(l),Promise.all(h)]).then(function(p){const g=p[0],y=p[1],m=p[2],A=p[3],b=p[4],v=[];for(u=0,f=g.length;u<f;u++){const _=g[u],w=y[u],E=m[u],I=A[u],M=b[u];if(_===void 0)continue;_.updateMatrix&&_.updateMatrix();const R=i._createAnimationTracks(_,w,E,I,M);if(R)for(let S=0;S<R.length;S++)v.push(R[S])}return new Yse(r,void 0,v)})}createNodeMesh(e){const t=this.json,i=this,n=t.nodes[e];return n.mesh===void 0?null:i.getDependency("mesh",n.mesh).then(function(r){const o=i._getNodeRef(i.meshCache,n.mesh,r);return n.weights!==void 0&&o.traverse(function(a){if(a.isMesh)for(let c=0,l=n.weights.length;c<l;c++)a.morphTargetInfluences[c]=n.weights[c]}),o})}loadNode(e){const t=this.json,i=this,n=t.nodes[e],r=i._loadNodeShallow(e),o=[],a=n.children||[];for(let l=0,h=a.length;l<h;l++)o.push(i.getDependency("node",a[l]));const c=n.skin===void 0?Promise.resolve(null):i.getDependency("skin",n.skin);return Promise.all([r,Promise.all(o),c]).then(function(l){const h=l[0],u=l[1],f=l[2];f!==null&&h.traverse(function(p){p.isSkinnedMesh&&p.bind(f,Jre)});for(let p=0,g=u.length;p<g;p++)h.add(u[p]);return h})}_loadNodeShallow(e){const t=this.json,i=this.extensions,n=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const r=t.nodes[e],o=r.name?n.createUniqueName(r.name):"",a=[],c=n._invokeOne(function(l){return l.createNodeMesh&&l.createNodeMesh(e)});return c&&a.push(c),r.camera!==void 0&&a.push(n.getDependency("camera",r.camera).then(function(l){return n._getNodeRef(n.cameraCache,r.camera,l)})),n._invokeAll(function(l){return l.createNodeAttachment&&l.createNodeAttachment(e)}).forEach(function(l){a.push(l)}),this.nodeCache[e]=Promise.all(a).then(function(l){let h;if(r.isBone===!0?h=new Q8:l.length>1?h=new _M:l.length===1?h=l[0]:h=new qn,h!==l[0])for(let u=0,f=l.length;u<f;u++)h.add(l[u]);if(r.name&&(h.userData.name=r.name,h.name=o),Ru(h,r),r.extensions&&$d(i,h,r),r.matrix!==void 0){const u=new ai;u.fromArray(r.matrix),h.applyMatrix4(u)}else r.translation!==void 0&&h.position.fromArray(r.translation),r.rotation!==void 0&&h.quaternion.fromArray(r.rotation),r.scale!==void 0&&h.scale.fromArray(r.scale);return n.associations.has(h)||n.associations.set(h,{}),n.associations.get(h).nodes=e,h}),this.nodeCache[e]}loadScene(e){const t=this.extensions,i=this.json.scenes[e],n=this,r=new _M;i.name&&(r.name=n.createUniqueName(i.name)),Ru(r,i),i.extensions&&$d(t,r,i);const o=i.nodes||[],a=[];for(let c=0,l=o.length;c<l;c++)a.push(n.getDependency("node",o[c]));return Promise.all(a).then(function(c){for(let h=0,u=c.length;h<u;h++)r.add(c[h]);const l=h=>{const u=new Map;for(const[f,p]of n.associations)(f instanceof ed||f instanceof ms)&&u.set(f,p);return h.traverse(f=>{const p=n.associations.get(f);p!=null&&u.set(f,p)}),u};return n.associations=l(r),r})}_createAnimationTracks(e,t,i,n,r){const o=[],a=e.name?e.name:e.uuid,c=[];fu[r.path]===fu.weights?e.traverse(function(f){f.morphTargetInfluences&&c.push(f.name?f.name:f.uuid)}):c.push(a);let l;switch(fu[r.path]){case fu.weights:l=oA;break;case fu.rotation:l=gp;break;case fu.position:case fu.scale:l=aA;break;default:switch(i.itemSize){case 1:l=oA;break;case 2:case 3:default:l=aA;break}break}const h=n.interpolation!==void 0?Vre[n.interpolation]:rA,u=this._getArrayFromAccessor(i);for(let f=0,p=c.length;f<p;f++){const g=new l(c[f]+"."+fu[r.path],t.array,u,h);n.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(g),o.push(g)}return o}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const i=TR(t.constructor),n=new Float32Array(t.length);for(let r=0,o=t.length;r<o;r++)n[r]=t[r]*i;t=n}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(i){const n=this instanceof gp?Hre:q8;return new n(this.times,this.values,this.getValueSize()/3,i)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}};function Zre(s,e,t){const i=e.attributes,n=new Cc;if(i.POSITION!==void 0){const a=t.json.accessors[i.POSITION],c=a.min,l=a.max;if(c!==void 0&&l!==void 0){if(n.set(new ue(c[0],c[1],c[2]),new ue(l[0],l[1],l[2])),a.normalized){const h=TR(Fm[a.componentType]);n.min.multiplyScalar(h),n.max.multiplyScalar(h)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const r=e.targets;if(r!==void 0){const a=new ue,c=new ue;for(let l=0,h=r.length;l<h;l++){const u=r[l];if(u.POSITION!==void 0){const f=t.json.accessors[u.POSITION],p=f.min,g=f.max;if(p!==void 0&&g!==void 0){if(c.setX(Math.max(Math.abs(p[0]),Math.abs(g[0]))),c.setY(Math.max(Math.abs(p[1]),Math.abs(g[1]))),c.setZ(Math.max(Math.abs(p[2]),Math.abs(g[2]))),f.normalized){const y=TR(Fm[f.componentType]);c.multiplyScalar(y)}a.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}n.expandByVector(a)}s.boundingBox=n;const o=new Bc;n.getCenter(o.center),o.radius=n.min.distanceTo(n.max)/2,s.boundingSphere=o}function dN(s,e,t){const i=e.attributes,n=[];function r(o,a){return t.getDependency("accessor",o).then(function(c){s.setAttribute(a,c)})}for(const o in i){const a=MR[o]||o.toLowerCase();a in s.attributes||n.push(r(i[o],a))}if(e.indices!==void 0&&!s.index){const o=t.getDependency("accessor",e.indices).then(function(a){s.setIndex(a)});n.push(o)}return Uo.workingColorSpace!==Co&&"COLOR_0"in i&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${Uo.workingColorSpace}" not supported.`),Ru(s,e),Zre(s,e,t),Promise.all(n).then(function(){return e.targets!==void 0?Wre(s,e.targets,t):s})}var $re=function(){var s="b9H79Tebbbe8Fv9Gbb9Gvuuuuueu9Giuuub9Geueu9Giuuueuikqbeeedddillviebeoweuec:q;iekr;leDo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbeY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVbdE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbiL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtblK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949Wbol79IV9Rbrq:P8Yqdbk;3sezu8Jjjjjbcj;eb9Rgv8Kjjjjbc9:hodnadcefal0mbcuhoaiRbbc:Ge9hmbavaialfgrad9Radz1jjjbhwcj;abad9UhoaicefhldnadTmbaoc;WFbGgocjdaocjd6EhDcbhqinaqae9pmeaDaeaq9RaqaDfae6Egkcsfgocl4cifcd4hxdndndndnaoc9WGgmTmbcbhPcehsawcjdfhzalhHinaraH9Rax6midnaraHaxfgl9RcK6mbczhoinawcj;cbfaogifgoc9WfhOdndndndndnaHaic9WfgAco4fRbbaAci4coG4ciGPlbedibkaO9cb83ibaOcwf9cb83ibxikaOalRblalRbbgAco4gCaCciSgCE86bbaocGfalclfaCfgORbbaAcl4ciGgCaCciSgCE86bbaocVfaOaCfgORbbaAcd4ciGgCaCciSgCE86bbaoc7faOaCfgORbbaAciGgAaAciSgAE86bbaoctfaOaAfgARbbalRbegOco4gCaCciSgCE86bbaoc91faAaCfgARbbaOcl4ciGgCaCciSgCE86bbaoc4faAaCfgARbbaOcd4ciGgCaCciSgCE86bbaoc93faAaCfgARbbaOciGgOaOciSgOE86bbaoc94faAaOfgARbbalRbdgOco4gCaCciSgCE86bbaoc95faAaCfgARbbaOcl4ciGgCaCciSgCE86bbaoc96faAaCfgARbbaOcd4ciGgCaCciSgCE86bbaoc97faAaCfgARbbaOciGgOaOciSgOE86bbaoc98faAaOfgORbbalRbiglco4gAaAciSgAE86bbaoc99faOaAfgORbbalcl4ciGgAaAciSgAE86bbaoc9:faOaAfgORbbalcd4ciGgAaAciSgAE86bbaocufaOaAfgoRbbalciGglalciSglE86bbaoalfhlxdkaOalRbwalRbbgAcl4gCaCcsSgCE86bbaocGfalcwfaCfgORbbaAcsGgAaAcsSgAE86bbaocVfaOaAfgORbbalRbegAcl4gCaCcsSgCE86bbaoc7faOaCfgORbbaAcsGgAaAcsSgAE86bbaoctfaOaAfgORbbalRbdgAcl4gCaCcsSgCE86bbaoc91faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc4faOaAfgORbbalRbigAcl4gCaCcsSgCE86bbaoc93faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc94faOaAfgORbbalRblgAcl4gCaCcsSgCE86bbaoc95faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc96faOaAfgORbbalRbvgAcl4gCaCcsSgCE86bbaoc97faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc98faOaAfgORbbalRbogAcl4gCaCcsSgCE86bbaoc99faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc9:faOaAfgORbbalRbrglcl4gAaAcsSgAE86bbaocufaOaAfgoRbbalcsGglalcsSglE86bbaoalfhlxekaOal8Pbb83bbaOcwfalcwf8Pbb83bbalczfhlkdnaiam9pmbaiczfhoaral9RcL0mekkaiam6mialTmidnakTmbawaPfRbbhOcbhoazhiinaiawcj;cbfaofRbbgAce4cbaAceG9R7aOfgO86bbaiadfhiaocefgoak9hmbkkazcefhzaPcefgPad6hsalhHaPad9hmexvkkcbhlasceGmdxikalaxad2fhCdnakTmbcbhHcehsawcjdfhminaral9Rax6mialTmdalaxfhlawaHfRbbhOcbhoamhiinaiawcj;cbfaofRbbgAce4cbaAceG9R7aOfgO86bbaiadfhiaocefgoak9hmbkamcefhmaHcefgHad6hsaHad9hmbkaChlxikcbhocehsinaral9Rax6mdalTmealaxfhlaocefgoad6hsadao9hmbkaChlxdkcbhlasceGTmekc9:hoxikabaqad2fawcjdfakad2z1jjjb8Aawawcjdfakcufad2fadz1jjjb8Aakaqfhqalmbkc9:hoxekcbc99aral9Radcaadca0ESEhokavcj;ebf8Kjjjjbaok;yzeHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecjez:jjjjb8AavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhodnaeTmbcmcsaDceSEhkcbhxcbhmcbhDcbhicbhlindnaoaq9nmbc9:hoxikdndnawRbbgrc;Ve0mbavc;abfalarcl4cu7fcsGcitfgPydlhsaPydbhzdnarcsGgPak9pmbavaiarcu7fcsGcdtfydbaxaPEhraPThPdndnadcd9hmbabaDcetfgHaz87ebaHcdfas87ebaHclfar87ebxekabaDcdtfgHazBdbaHclfasBdbaHcwfarBdbkaxaPfhxavc;abfalcitfgHarBdbaHasBdlavaicdtfarBdbavc;abfalcefcsGglcitfgHazBdbaHarBdlaiaPfhialcefhlxdkdndnaPcsSmbamaPfaPc987fcefhmxekaocefhrao8SbbgPcFeGhHdndnaPcu9mmbarhoxekaocvfhoaHcFbGhHcrhPdninar8SbbgOcFbGaPtaHVhHaOcu9kmearcefhraPcrfgPc8J9hmbxdkkarcefhokaHce4cbaHceG9R7amfhmkdndnadcd9hmbabaDcetfgraz87ebarcdfas87ebarclfam87ebxekabaDcdtfgrazBdbarclfasBdbarcwfamBdbkavc;abfalcitfgramBdbarasBdlavaicdtfamBdbavc;abfalcefcsGglcitfgrazBdbaramBdlaicefhialcefhlxekdnarcpe0mbaxcefgOavaiaqarcsGfRbbgPcl49RcsGcdtfydbaPcz6gHEhravaiaP9RcsGcdtfydbaOaHfgsaPcsGgOEhPaOThOdndnadcd9hmbabaDcetfgzax87ebazcdfar87ebazclfaP87ebxekabaDcdtfgzaxBdbazclfarBdbazcwfaPBdbkavaicdtfaxBdbavc;abfalcitfgzarBdbazaxBdlavaicefgicsGcdtfarBdbavc;abfalcefcsGcitfgzaPBdbazarBdlavaiaHfcsGgicdtfaPBdbavc;abfalcdfcsGglcitfgraxBdbaraPBdlalcefhlaiaOfhiasaOfhxxekaxcbaoRbbgzEgAarc;:eSgrfhsazcsGhCazcl4hXdndnazcs0mbascefhOxekashOavaiaX9RcsGcdtfydbhskdndnaCmbaOcefhxxekaOhxavaiaz9RcsGcdtfydbhOkdndnarTmbaocefhrxekaocdfhrao8SbegHcFeGhPdnaHcu9kmbaocofhAaPcFbGhPcrhodninar8SbbgHcFbGaotaPVhPaHcu9kmearcefhraocrfgoc8J9hmbkaAhrxekarcefhrkaPce4cbaPceG9R7amfgmhAkdndnaXcsSmbarhPxekarcefhPar8SbbgocFeGhHdnaocu9kmbarcvfhsaHcFbGhHcrhodninaP8SbbgrcFbGaotaHVhHarcu9kmeaPcefhPaocrfgoc8J9hmbkashPxekaPcefhPkaHce4cbaHceG9R7amfgmhskdndnaCcsSmbaPhoxekaPcefhoaP8SbbgrcFeGhHdnarcu9kmbaPcvfhOaHcFbGhHcrhrdninao8SbbgPcFbGartaHVhHaPcu9kmeaocefhoarcrfgrc8J9hmbkaOhoxekaocefhokaHce4cbaHceG9R7amfgmhOkdndnadcd9hmbabaDcetfgraA87ebarcdfas87ebarclfaO87ebxekabaDcdtfgraABdbarclfasBdbarcwfaOBdbkavc;abfalcitfgrasBdbaraABdlavaicdtfaABdbavc;abfalcefcsGcitfgraOBdbarasBdlavaicefgicsGcdtfasBdbavc;abfalcdfcsGcitfgraABdbaraOBdlavaiazcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhialcifhlkawcefhwalcsGhlaicsGhiaDcifgDae6mbkkcbc99aoaqSEhokavc;aef8Kjjjjbaok:llevu8Jjjjjbcz9Rhvc9:hodnaecvfal0mbcuhoaiRbbc;:eGc;qe9hmbav9cb83iwaicefhraialfc98fhwdnaeTmbdnadcdSmbcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcdtfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfglBdbaoalBdbaDcefgDae9hmbxdkkcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcetfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfgl87ebaoalBdbaDcefgDae9hmbkkcbc99arawSEhokaok:Lvoeue99dud99eud99dndnadcl9hmbaeTmeindndnabcdfgd8Sbb:Yab8Sbbgi:Ygl:l:tabcefgv8Sbbgo:Ygr:l:tgwJbb;:9cawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai86bbdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad86bbdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad86bbabclfhbaecufgembxdkkaeTmbindndnabclfgd8Ueb:Yab8Uebgi:Ygl:l:tabcdfgv8Uebgo:Ygr:l:tgwJb;:FSawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai87ebdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad87ebdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad87ebabcwfhbaecufgembkkk;siliui99iue99dnaeTmbcbhiabhlindndnJ;Zl81Zalcof8UebgvciV:Y:vgoal8Ueb:YNgrJb;:FSNJbbbZJbbb:;arJbbbb9GEMgw:lJbbb9p9DTmbaw:OhDxekcjjjj94hDkalclf8Uebhqalcdf8UebhkabavcefciGaiVcetfaD87ebdndnaoak:YNgwJb;:FSNJbbbZJbbb:;awJbbbb9GEMgx:lJbbb9p9DTmbax:Ohkxekcjjjj94hkkabavcdfciGaiVcetfak87ebdndnaoaq:YNgoJb;:FSNJbbbZJbbb:;aoJbbbb9GEMgx:lJbbb9p9DTmbax:Ohqxekcjjjj94hqkabavcufciGaiVcetfaq87ebdndnJbbjZararN:tawawN:taoaoN:tgrJbbbbarJbbbb9GE:rJb;:FSNJbbbZMgr:lJbbb9p9DTmbar:Ohqxekcjjjj94hqkabavciGaiVcetfaq87ebalcwfhlaiclfhiaecufgembkkk9mbdnadcd4ae2geTmbinababydbgdcwtcw91:Yadce91cjjj;8ifcjjj98G::NUdbabclfhbaecufgembkkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaiczfhiaeczfheadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabkkkebcjwklz9Kbb",e="b9H79TebbbeKl9Gbb9Gvuuuuueu9Giuuub9Geueuikqbbebeedddilve9Weeeviebeoweuec:q;Aekr;leDo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbdY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVblE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtboK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbrL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949Wbwl79IV9RbDq;t9tqlbzik9:evu8Jjjjjbcz9Rhbcbheincbhdcbhiinabcwfadfaicjuaead4ceGglE86bbaialfhiadcefgdcw9hmbkaec:q:yjjbfai86bbaecitc:q1jjbfab8Piw83ibaecefgecjd9hmbkk;h8JlHud97euo978Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnadcefal0mbcuhoaiRbbc:Ge9hmbavaialfgrad9Rad;8qbbcj;abad9UhoaicefhldnadTmbaoc;WFbGgocjdaocjd6EhwcbhDinaDae9pmeawaeaD9RaDawfae6Egqcsfgoc9WGgkci2hxakcethmaocl4cifcd4hPabaDad2fhscbhzdnincehHalhOcbhAdninaraO9RaP6miavcj;cbfaAak2fhCaOaPfhlcbhidnakc;ab6mbaral9Rc;Gb6mbcbhoinaCaofhidndndndndnaOaoco4fRbbgXciGPlbedibkaipxbbbbbbbbbbbbbbbbpklbxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklbalczfhlkdndndndndnaXcd4ciGPlbedibkaipxbbbbbbbbbbbbbbbbpklzxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklzalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklzalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklzalczfhlkdndndndndnaXcl4ciGPlbedibkaipxbbbbbbbbbbbbbbbbpklaxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklaalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklaalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklaalczfhlkdndndndndnaXco4Plbedibkaipxbbbbbbbbbbbbbbbbpkl8WxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibaXc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkl8WalclfaYpQbfaXc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibaXc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkl8WalcwfaYpQbfaXc:q:yjjbfRbbfhlxekaialpbbbpkl8Walczfhlkaoc;abfhiaocjefak0meaihoaral9Rc;Fb0mbkkdndnaiak9pmbaici4hoinaral9RcK6mdaCaifhXdndndndndnaOaico4fRbbaocoG4ciGPlbedibkaXpxbbbbbbbbbbbbbbbbpklbxikaXalpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaXalpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaXalpbbbpklbalczfhlkaocdfhoaiczfgiak6mbkkalTmbaAci6hHalhOaAcefgohAaoclSmdxekkcbhlaHceGmdkdnakTmbavcjdfazfhiavazfpbdbhYcbhXinaiavcj;cbfaXfgopblbgLcep9TaLpxeeeeeeeeeeeeeeeegQp9op9Hp9rgLaoakfpblbg8Acep9Ta8AaQp9op9Hp9rg8ApmbzeHdOiAlCvXoQrLgEaoamfpblbg3cep9Ta3aQp9op9Hp9rg3aoaxfpblbg5cep9Ta5aQp9op9Hp9rg5pmbzeHdOiAlCvXoQrLg8EpmbezHdiOAlvCXorQLgQaQpmbedibedibedibediaYp9UgYp9AdbbaiadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaEa8EpmwDKYqk8AExm35Ps8E8FgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaLa8ApmwKDYq8AkEx3m5P8Es8FgLa3a5pmwKDYq8AkEx3m5P8Es8Fg8ApmbezHdiOAlvCXorQLgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaLa8ApmwDKYqk8AExm35Ps8E8FgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfhiaXczfgXak6mbkkazclfgzad6mbkasavcjdfaqad2;8qbbavavcjdfaqcufad2fad;8qbbaqaDfhDc9:hoalmexikkc9:hoxekcbc99aral9Radcaadca0ESEhokavcj;kbf8Kjjjjbaokwbz:bjjjbk;uzeHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecje;8kbavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhodnaeTmbcmcsaDceSEhkcbhxcbhmcbhDcbhicbhlindnaoaq9nmbc9:hoxikdndnawRbbgrc;Ve0mbavc;abfalarcl4cu7fcsGcitfgPydlhsaPydbhzdnarcsGgPak9pmbavaiarcu7fcsGcdtfydbaxaPEhraPThPdndnadcd9hmbabaDcetfgHaz87ebaHcdfas87ebaHclfar87ebxekabaDcdtfgHazBdbaHclfasBdbaHcwfarBdbkaxaPfhxavc;abfalcitfgHarBdbaHasBdlavaicdtfarBdbavc;abfalcefcsGglcitfgHazBdbaHarBdlaiaPfhialcefhlxdkdndnaPcsSmbamaPfaPc987fcefhmxekaocefhrao8SbbgPcFeGhHdndnaPcu9mmbarhoxekaocvfhoaHcFbGhHcrhPdninar8SbbgOcFbGaPtaHVhHaOcu9kmearcefhraPcrfgPc8J9hmbxdkkarcefhokaHce4cbaHceG9R7amfhmkdndnadcd9hmbabaDcetfgraz87ebarcdfas87ebarclfam87ebxekabaDcdtfgrazBdbarclfasBdbarcwfamBdbkavc;abfalcitfgramBdbarasBdlavaicdtfamBdbavc;abfalcefcsGglcitfgrazBdbaramBdlaicefhialcefhlxekdnarcpe0mbaxcefgOavaiaqarcsGfRbbgPcl49RcsGcdtfydbaPcz6gHEhravaiaP9RcsGcdtfydbaOaHfgsaPcsGgOEhPaOThOdndnadcd9hmbabaDcetfgzax87ebazcdfar87ebazclfaP87ebxekabaDcdtfgzaxBdbazclfarBdbazcwfaPBdbkavaicdtfaxBdbavc;abfalcitfgzarBdbazaxBdlavaicefgicsGcdtfarBdbavc;abfalcefcsGcitfgzaPBdbazarBdlavaiaHfcsGgicdtfaPBdbavc;abfalcdfcsGglcitfgraxBdbaraPBdlalcefhlaiaOfhiasaOfhxxekaxcbaoRbbgzEgAarc;:eSgrfhsazcsGhCazcl4hXdndnazcs0mbascefhOxekashOavaiaX9RcsGcdtfydbhskdndnaCmbaOcefhxxekaOhxavaiaz9RcsGcdtfydbhOkdndnarTmbaocefhrxekaocdfhrao8SbegHcFeGhPdnaHcu9kmbaocofhAaPcFbGhPcrhodninar8SbbgHcFbGaotaPVhPaHcu9kmearcefhraocrfgoc8J9hmbkaAhrxekarcefhrkaPce4cbaPceG9R7amfgmhAkdndnaXcsSmbarhPxekarcefhPar8SbbgocFeGhHdnaocu9kmbarcvfhsaHcFbGhHcrhodninaP8SbbgrcFbGaotaHVhHarcu9kmeaPcefhPaocrfgoc8J9hmbkashPxekaPcefhPkaHce4cbaHceG9R7amfgmhskdndnaCcsSmbaPhoxekaPcefhoaP8SbbgrcFeGhHdnarcu9kmbaPcvfhOaHcFbGhHcrhrdninao8SbbgPcFbGartaHVhHaPcu9kmeaocefhoarcrfgrc8J9hmbkaOhoxekaocefhokaHce4cbaHceG9R7amfgmhOkdndnadcd9hmbabaDcetfgraA87ebarcdfas87ebarclfaO87ebxekabaDcdtfgraABdbarclfasBdbarcwfaOBdbkavc;abfalcitfgrasBdbaraABdlavaicdtfaABdbavc;abfalcefcsGcitfgraOBdbarasBdlavaicefgicsGcdtfasBdbavc;abfalcdfcsGcitfgraABdbaraOBdlavaiazcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhialcifhlkawcefhwalcsGhlaicsGhiaDcifgDae6mbkkcbc99aoaqSEhokavc;aef8Kjjjjbaok:llevu8Jjjjjbcz9Rhvc9:hodnaecvfal0mbcuhoaiRbbc;:eGc;qe9hmbav9cb83iwaicefhraialfc98fhwdnaeTmbdnadcdSmbcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcdtfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfglBdbaoalBdbaDcefgDae9hmbxdkkcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcetfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfgl87ebaoalBdbaDcefgDae9hmbkkcbc99arawSEhokaok:EPliuo97eue978Jjjjjbca9Rhidndnadcl9hmbdnaec98GglTmbcbhvabhdinadadpbbbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpkbbadczfhdavclfgval6mbkkalae9pmeaiaeciGgvcdtgdVcbczad9R;8kbaiabalcdtfglad;8qbbdnavTmbaiaipblbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpklbkalaiad;8qbbskdnaec98GgxTmbcbhvabhdinadczfglalpbbbgopxbbbbbbFFbbbbbbFFgkp9oadpbbbgDaopmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eaDaopmbediwDqkzHOAKY8AEgoczp:Sep;6egrp;Geaoczp:Reczp:Sep;6egwp;Gep;Kep;Legopxb;:FSb;:FSb;:FSb;:FSawaopxbbbbbbbbbbbbbbbbp:2egqawpxbbbjbbbjbbbjbbbjgmp9op9rp;Kegwawp;Meaoaop;Mearaqaramp9op9rp;Kegoaop;Mep;Kep;Kep;Jep;Negrp;Mepxbbn0bbn0bbn0bbn0gqp;Keczp:Reawarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9op9qgwaoarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogopmwDKYqk8AExm35Ps8E8Fp9qpkbbadaDakp9oawaopmbezHdiOAlvCXorQLp9qpkbbadcafhdavclfgvax6mbkkaxae9pmbaiaeciGgvcitgdfcbcaad9R;8kbaiabaxcitfglad;8qbbdnavTmbaiaipblzgopxbbbbbbFFbbbbbbFFgkp9oaipblbgDaopmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eaDaopmbediwDqkzHOAKY8AEgoczp:Sep;6egrp;Geaoczp:Reczp:Sep;6egwp;Gep;Kep;Legopxb;:FSb;:FSb;:FSb;:FSawaopxbbbbbbbbbbbbbbbbp:2egqawpxbbbjbbbjbbbjbbbjgmp9op9rp;Kegwawp;Meaoaop;Mearaqaramp9op9rp;Kegoaop;Mep;Kep;Kep;Jep;Negrp;Mepxbbn0bbn0bbn0bbn0gqp;Keczp:Reawarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9op9qgwaoarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogopmwDKYqk8AExm35Ps8E8Fp9qpklzaiaDakp9oawaopmbezHdiOAlvCXorQLp9qpklbkalaiad;8qbbkk;4wllue97euv978Jjjjjbc8W9Rhidnaec98GglTmbcbhvabhoinaiaopbbbgraoczfgwpbbbgDpmlvorxmPsCXQL358E8Fgqczp:Segkclp:RepklbaopxbbjZbbjZbbjZbbjZpx;Zl81Z;Zl81Z;Zl81Z;Zl81Zakpxibbbibbbibbbibbbp9qp;6ep;NegkaraDpmbediwDqkzHOAKY8AEgrczp:Reczp:Sep;6ep;MegDaDp;Meakarczp:Sep;6ep;Megxaxp;Meakaqczp:Reczp:Sep;6ep;Megqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jepxb;:FSb;:FSb;:FSb;:FSgkp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbgmp9oaxakp;Mearp;Keczp:Rep9qgxaqakp;Mearp;Keczp:ReaDakp;Mearp;Keamp9op9qgkpmbezHdiOAlvCXorQLgrp5baipblbpEb:T:j83ibaocwfarp5eaipblbpEe:T:j83ibawaxakpmwDKYqk8AExm35Ps8E8Fgkp5baipblbpEd:T:j83ibaocKfakp5eaipblbpEi:T:j83ibaocafhoavclfgval6mbkkdnalae9pmbaiaeciGgvcitgofcbcaao9R;8kbaiabalcitfgwao;8qbbdnavTmbaiaipblbgraipblzgDpmlvorxmPsCXQL358E8Fgqczp:Segkclp:RepklaaipxbbjZbbjZbbjZbbjZpx;Zl81Z;Zl81Z;Zl81Z;Zl81Zakpxibbbibbbibbbibbbp9qp;6ep;NegkaraDpmbediwDqkzHOAKY8AEgrczp:Reczp:Sep;6ep;MegDaDp;Meakarczp:Sep;6ep;Megxaxp;Meakaqczp:Reczp:Sep;6ep;Megqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jepxb;:FSb;:FSb;:FSb;:FSgkp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbgmp9oaxakp;Mearp;Keczp:Rep9qgxaqakp;Mearp;Keczp:ReaDakp;Mearp;Keamp9op9qgkpmbezHdiOAlvCXorQLgrp5baipblapEb:T:j83ibaiarp5eaipblapEe:T:j83iwaiaxakpmwDKYqk8AExm35Ps8E8Fgkp5baipblapEd:T:j83izaiakp5eaipblapEi:T:j83iKkawaiao;8qbbkk:Pddiue978Jjjjjbc;ab9Rhidnadcd4ae2glc98GgvTmbcbhdabheinaeaepbbbgocwp:Recwp:Sep;6eaocep:SepxbbjZbbjZbbjZbbjZp:UepxbbjFbbjFbbjFbbjFp9op;Mepkbbaeczfheadclfgdav6mbkkdnaval9pmbaialciGgdcdtgeVcbc;abae9R;8kbaiabavcdtfgvae;8qbbdnadTmbaiaipblbgocwp:Recwp:Sep;6eaocep:SepxbbjZbbjZbbjZbbjZp:UepxbbjFbbjFbbjFbbjFp9op;Mepklbkavaiae;8qbbkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikkkebcjwklz9Tbb",t=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),i=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if(typeof WebAssembly!="object")return{supported:!1};var n=WebAssembly.validate(t)?e:s,r,o=WebAssembly.instantiate(a(n),{}).then(function(A){r=A.instance,r.exports.__wasm_call_ctors()});function a(A){for(var b=new Uint8Array(A.length),v=0;v<A.length;++v){var _=A.charCodeAt(v);b[v]=_>96?_-97:_>64?_-39:_+4}for(var w=0,v=0;v<A.length;++v)b[w++]=b[v]<60?i[b[v]]:(b[v]-60)*64+b[++v];return b.buffer.slice(0,w)}function c(A,b,v,_,w,E){var I=r.exports.sbrk,M=v+3&-4,R=I(M*_),S=I(w.length),T=new Uint8Array(r.exports.memory.buffer);T.set(w,S);var F=A(R,v,_,S,w.length);if(F==0&&E&&E(R,M,_),b.set(T.subarray(R,R+v*_)),I(R-I(0)),F!=0)throw new Error("Malformed buffer data: "+F)}var l={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},h={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"},u=[],f=0;function p(A){var b={object:new Worker(A),pending:0,requests:{}};return b.object.onmessage=function(v){var _=v.data;b.pending-=_.count,b.requests[_.id][_.action](_.value),delete b.requests[_.id]},b}function g(A){for(var b="var instance; var ready = WebAssembly.instantiate(new Uint8Array(["+new Uint8Array(a(n))+"]), {}).then(function(result) { instance = result.instance; instance.exports.__wasm_call_ctors(); });self.onmessage = workerProcess;"+c.toString()+m.toString(),v=new Blob([b],{type:"text/javascript"}),_=URL.createObjectURL(v),w=0;w<A;++w)u[w]=p(_);URL.revokeObjectURL(_)}function y(A,b,v,_,w){for(var E=u[0],I=1;I<u.length;++I)u[I].pending<E.pending&&(E=u[I]);return new Promise(function(M,R){var S=new Uint8Array(v),T=f++;E.pending+=A,E.requests[T]={resolve:M,reject:R},E.object.postMessage({id:T,count:A,size:b,source:S,mode:_,filter:w},[S.buffer])})}function m(A){o.then(function(){var b=A.data;try{var v=new Uint8Array(b.count*b.size);c(r.exports[b.mode],v,b.count,b.size,b.source,r.exports[b.filter]),self.postMessage({id:b.id,count:b.count,action:"resolve",value:v},[v.buffer])}catch(_){self.postMessage({id:b.id,count:b.count,action:"reject",value:_})}})}return{ready:o,supported:!0,useWorkers:function(A){g(A)},decodeVertexBuffer:function(A,b,v,_,w){c(r.exports.meshopt_decodeVertexBuffer,A,b,v,_,r.exports[l[w]])},decodeIndexBuffer:function(A,b,v,_){c(r.exports.meshopt_decodeIndexBuffer,A,b,v,_)},decodeIndexSequence:function(A,b,v,_){c(r.exports.meshopt_decodeIndexSequence,A,b,v,_)},decodeGltfBuffer:function(A,b,v,_,w,E){c(r.exports[h[w]],A,b,v,_,r.exports[l[E]])},decodeGltfBufferAsync:function(A,b,v,_,w){return u.length>0?y(A,b,v,h[_],l[w]):o.then(function(){var E=new Uint8Array(A*b);return c(r.exports[h[_]],E,A,b,v,r.exports[l[w]]),E})}}}();const BM=new WeakMap;let eoe=class extends _d{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,i,n){const r=new Hf(this.manager);r.setPath(this.path),r.setResponseType("arraybuffer"),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(e,o=>{this.parse(o,t,n)},i,n)}parse(e,t,i=()=>{}){this.decodeDracoFile(e,t,null,null,Er).catch(i)}decodeDracoFile(e,t,i,n,r=Co,o=()=>{}){const a={attributeIDs:i||this.defaultAttributeIDs,attributeTypes:n||this.defaultAttributeTypes,useUniqueIDs:!!i,vertexColorSpace:r};return this.decodeGeometry(e,a).then(t).catch(o)}decodeGeometry(e,t){const i=JSON.stringify(t);if(BM.has(e)){const c=BM.get(e);if(c.key===i)return c.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let n;const r=this.workerNextTaskID++,o=e.byteLength,a=this._getWorker(r,o).then(c=>(n=c,new Promise((l,h)=>{n._callbacks[r]={resolve:l,reject:h},n.postMessage({type:"decode",id:r,taskConfig:t,buffer:e},[e])}))).then(c=>this._createGeometry(c.geometry));return a.catch(()=>!0).then(()=>{n&&r&&this._releaseTask(n,r)}),BM.set(e,{key:i,promise:a}),a}_createGeometry(e){const t=new Sc;e.index&&t.setIndex(new Zo(e.index.array,1));for(let i=0;i<e.attributes.length;i++){const n=e.attributes[i],r=n.name,o=n.array,a=n.itemSize,c=new Zo(o,a);r==="color"&&(this._assignVertexColorSpace(c,n.vertexColorSpace),c.normalized=!(o instanceof Float32Array)),t.setAttribute(r,c)}return t}_assignVertexColorSpace(e,t){if(t!==Er)return;const i=new os;for(let n=0,r=e.count;n<r;n++)i.fromBufferAttribute(e,n).convertSRGBToLinear(),e.setXYZ(n,i.r,i.g,i.b)}_loadLibrary(e,t){const i=new Hf(this.manager);return i.setPath(this.decoderPath),i.setResponseType(t),i.setWithCredentials(this.withCredentials),new Promise((n,r)=>{i.load(e,n,void 0,r)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(i=>{const n=i[0];e||(this.decoderConfig.wasmBinary=i[1]);const r=toe.toString(),o=["/* draco decoder */",n,"","/* worker */",r.substring(r.indexOf("{")+1,r.lastIndexOf("}"))].join(`
4417
4417
  `);this.workerSourceURL=URL.createObjectURL(new Blob([o]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const n=new Worker(this.workerSourceURL);n._callbacks={},n._taskCosts={},n._taskLoad=0,n.postMessage({type:"init",decoderConfig:this.decoderConfig}),n.onmessage=function(r){const o=r.data;switch(o.type){case"decode":n._callbacks[o.id].resolve(o);break;case"error":n._callbacks[o.id].reject(o);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+o.type+'"')}},this.workerPool.push(n)}else this.workerPool.sort(function(n,r){return n._taskLoad>r._taskLoad?-1:1});const i=this.workerPool[this.workerPool.length-1];return i._taskCosts[e]=t,i._taskLoad+=t,i})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}};function toe(){let s,e;onmessage=function(o){const a=o.data;switch(a.type){case"init":s=a.decoderConfig,e=new Promise(function(h){s.onModuleLoaded=function(u){h({draco:u})},DracoDecoderModule(s)});break;case"decode":const c=a.buffer,l=a.taskConfig;e.then(h=>{const u=h.draco,f=new u.Decoder;try{const p=t(u,f,new Int8Array(c),l),g=p.attributes.map(y=>y.array.buffer);p.index&&g.push(p.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:p},g)}catch(p){console.error(p),self.postMessage({type:"error",id:a.id,error:p.message})}finally{u.destroy(f)}});break}};function t(o,a,c,l){const h=l.attributeIDs,u=l.attributeTypes;let f,p;const g=a.GetEncodedGeometryType(c);if(g===o.TRIANGULAR_MESH)f=new o.Mesh,p=a.DecodeArrayToMesh(c,c.byteLength,f);else if(g===o.POINT_CLOUD)f=new o.PointCloud,p=a.DecodeArrayToPointCloud(c,c.byteLength,f);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!p.ok()||f.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+p.error_msg());const y={index:null,attributes:[]};for(const m in h){const A=self[u[m]];let b,v;if(l.useUniqueIDs)v=h[m],b=a.GetAttributeByUniqueId(f,v);else{if(v=a.GetAttributeId(f,o[h[m]]),v===-1)continue;b=a.GetAttribute(f,v)}const _=n(o,a,f,m,A,b);m==="color"&&(_.vertexColorSpace=l.vertexColorSpace),y.attributes.push(_)}return g===o.TRIANGULAR_MESH&&(y.index=i(o,a,f)),o.destroy(f),y}function i(o,a,c){const h=c.num_faces()*3,u=h*4,f=o._malloc(u);a.GetTrianglesUInt32Array(c,u,f);const p=new Uint32Array(o.HEAPF32.buffer,f,h).slice();return o._free(f),{array:p,itemSize:1}}function n(o,a,c,l,h,u){const f=u.num_components(),g=c.num_points()*f,y=g*h.BYTES_PER_ELEMENT,m=r(o,h),A=o._malloc(y);a.GetAttributeDataArrayForAllPoints(c,u,m,y,A);const b=new h(o.HEAPF32.buffer,A,g).slice();return o._free(A),{name:l,array:b,itemSize:f}}function r(o,a){switch(a){case Float32Array:return o.DT_FLOAT32;case Int8Array:return o.DT_INT8;case Int16Array:return o.DT_INT16;case Int32Array:return o.DT_INT32;case Uint8Array:return o.DT_UINT8;case Uint16Array:return o.DT_UINT16;case Uint32Array:return o.DT_UINT32}}}let ioe=class{constructor(e=4){this.pool=e,this.queue=[],this.workers=[],this.workersResolve=[],this.workerStatus=0}_initWorker(e){if(!this.workers[e]){const t=this.workerCreator();t.addEventListener("message",this._onMessage.bind(this,e)),this.workers[e]=t}}_getIdleWorker(){for(let e=0;e<this.pool;e++)if(!(this.workerStatus&1<<e))return e;return-1}_onMessage(e,t){const i=this.workersResolve[e];if(i&&i(t),this.queue.length){const{resolve:n,msg:r,transfer:o}=this.queue.shift();this.workersResolve[e]=n,this.workers[e].postMessage(r,o)}else this.workerStatus^=1<<e}setWorkerCreator(e){this.workerCreator=e}setWorkerLimit(e){this.pool=e}postMessage(e,t){return new Promise(i=>{const n=this._getIdleWorker();n!==-1?(this._initWorker(n),this.workerStatus|=1<<n,this.workersResolve[n]=i,this.workers[n].postMessage(e,t)):this.queue.push({resolve:i,msg:e,transfer:t})})}dispose(){this.workers.forEach(e=>e.terminate()),this.workersResolve.length=0,this.workers.length=0,this.queue.length=0,this.workerStatus=0}};const noe=0,fN=2,soe=1,pN=2,roe=0,ooe=1,aoe=10,coe=0,X8=9,Y8=15,J8=16,K8=22,Z8=37,$8=43,eV=76,tV=83,iV=97,nV=100,sV=103,rV=109,oV=165,aV=166;let loe=class{constructor(){this.vkFormat=0,this.typeSize=1,this.pixelWidth=0,this.pixelHeight=0,this.pixelDepth=0,this.layerCount=0,this.faceCount=1,this.supercompressionScheme=0,this.levels=[],this.dataFormatDescriptor=[{vendorId:0,descriptorType:0,descriptorBlockSize:0,versionNumber:2,colorModel:0,colorPrimaries:1,transferFunction:2,flags:0,texelBlockDimension:[0,0,0,0],bytesPlane:[0,0,0,0,0,0,0,0],samples:[]}],this.keyValue={},this.globalData=null}},My=class{constructor(e,t,i,n){this._dataView=new DataView(e.buffer,e.byteOffset+t,i),this._littleEndian=n,this._offset=0}_nextUint8(){const e=this._dataView.getUint8(this._offset);return this._offset+=1,e}_nextUint16(){const e=this._dataView.getUint16(this._offset,this._littleEndian);return this._offset+=2,e}_nextUint32(){const e=this._dataView.getUint32(this._offset,this._littleEndian);return this._offset+=4,e}_nextUint64(){const e=this._dataView.getUint32(this._offset,this._littleEndian)+4294967296*this._dataView.getUint32(this._offset+4,this._littleEndian);return this._offset+=8,e}_nextInt32(){const e=this._dataView.getInt32(this._offset,this._littleEndian);return this._offset+=4,e}_skip(e){return this._offset+=e,this}_scan(e,t=0){const i=this._offset;let n=0;for(;this._dataView.getUint8(this._offset)!==t&&n<e;)n++,this._offset++;return n<e&&this._offset++,new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+i,n)}};const Gr=[171,75,84,88,32,50,48,187,13,10,26,10];function gN(s){return typeof TextDecoder<"u"?new TextDecoder().decode(s):Buffer.from(s).toString("utf8")}function hoe(s){const e=new Uint8Array(s.buffer,s.byteOffset,Gr.length);if(e[0]!==Gr[0]||e[1]!==Gr[1]||e[2]!==Gr[2]||e[3]!==Gr[3]||e[4]!==Gr[4]||e[5]!==Gr[5]||e[6]!==Gr[6]||e[7]!==Gr[7]||e[8]!==Gr[8]||e[9]!==Gr[9]||e[10]!==Gr[10]||e[11]!==Gr[11])throw new Error("Missing KTX 2.0 identifier.");const t=new loe,i=17*Uint32Array.BYTES_PER_ELEMENT,n=new My(s,Gr.length,i,!0);t.vkFormat=n._nextUint32(),t.typeSize=n._nextUint32(),t.pixelWidth=n._nextUint32(),t.pixelHeight=n._nextUint32(),t.pixelDepth=n._nextUint32(),t.layerCount=n._nextUint32(),t.faceCount=n._nextUint32();const r=n._nextUint32();t.supercompressionScheme=n._nextUint32();const o=n._nextUint32(),a=n._nextUint32(),c=n._nextUint32(),l=n._nextUint32(),h=n._nextUint64(),u=n._nextUint64(),f=new My(s,Gr.length+i,3*r*8,!0);for(let L=0;L<r;L++)t.levels.push({levelData:new Uint8Array(s.buffer,s.byteOffset+f._nextUint64(),f._nextUint64()),uncompressedByteLength:f._nextUint64()});const p=new My(s,o,a,!0),g={vendorId:p._skip(4)._nextUint16(),descriptorType:p._nextUint16(),versionNumber:p._nextUint16(),descriptorBlockSize:p._nextUint16(),colorModel:p._nextUint8(),colorPrimaries:p._nextUint8(),transferFunction:p._nextUint8(),flags:p._nextUint8(),texelBlockDimension:[p._nextUint8(),p._nextUint8(),p._nextUint8(),p._nextUint8()],bytesPlane:[p._nextUint8(),p._nextUint8(),p._nextUint8(),p._nextUint8(),p._nextUint8(),p._nextUint8(),p._nextUint8(),p._nextUint8()],samples:[]},y=(g.descriptorBlockSize/4-6)/4;for(let L=0;L<y;L++){const N={bitOffset:p._nextUint16(),bitLength:p._nextUint8(),channelType:p._nextUint8(),samplePosition:[p._nextUint8(),p._nextUint8(),p._nextUint8(),p._nextUint8()],sampleLower:-1/0,sampleUpper:1/0};64&N.channelType?(N.sampleLower=p._nextInt32(),N.sampleUpper=p._nextInt32()):(N.sampleLower=p._nextUint32(),N.sampleUpper=p._nextUint32()),g.samples[L]=N}t.dataFormatDescriptor.length=0,t.dataFormatDescriptor.push(g);const m=new My(s,c,l,!0);for(;m._offset<l;){const L=m._nextUint32(),N=m._scan(L),W=gN(N),X=m._scan(L-N.byteLength);t.keyValue[W]=W.match(/^ktx/i)?gN(X):X,m._offset%4&&m._skip(4-m._offset%4)}if(u<=0)return t;const A=new My(s,h,u,!0),b=A._nextUint16(),v=A._nextUint16(),_=A._nextUint32(),w=A._nextUint32(),E=A._nextUint32(),I=A._nextUint32(),M=[];for(let L=0;L<r;L++)M.push({imageFlags:A._nextUint32(),rgbSliceByteOffset:A._nextUint32(),rgbSliceByteLength:A._nextUint32(),alphaSliceByteOffset:A._nextUint32(),alphaSliceByteLength:A._nextUint32()});const R=h+A._offset,S=R+_,T=S+w,F=T+E,U=new Uint8Array(s.buffer,s.byteOffset+R,_),k=new Uint8Array(s.buffer,s.byteOffset+S,w),H=new Uint8Array(s.buffer,s.byteOffset+T,E),D=new Uint8Array(s.buffer,s.byteOffset+F,I);return t.globalData={endpointCount:b,selectorCount:v,imageDescs:M,endpointsData:U,selectorsData:k,tablesData:H,extendedData:D},t}let RM,ih,BR;const PM={env:{emscripten_notify_memory_growth:function(s){BR=new Uint8Array(ih.exports.memory.buffer)}}};let uoe=class{init(){return RM||(RM=typeof fetch<"u"?fetch("data:application/wasm;base64,"+mN).then(e=>e.arrayBuffer()).then(e=>WebAssembly.instantiate(e,PM)).then(this._init):WebAssembly.instantiate(Buffer.from(mN,"base64"),PM).then(this._init),RM)}_init(e){ih=e.instance,PM.env.emscripten_notify_memory_growth(0)}decode(e,t=0){if(!ih)throw new Error("ZSTDDecoder: Await .init() before decoding.");const i=e.byteLength,n=ih.exports.malloc(i);BR.set(e,n),t=t||Number(ih.exports.ZSTD_findDecompressedSize(n,i));const r=ih.exports.malloc(t),o=ih.exports.ZSTD_decompress(r,t,n,i),a=BR.slice(r,r+o);return ih.exports.free(n),ih.exports.free(r),a}};const mN="AGFzbQEAAAABpQEVYAF/AX9gAn9/AGADf39/AX9gBX9/f39/AX9gAX8AYAJ/fwF/YAR/f39/AX9gA39/fwBgBn9/f39/fwF/YAd/f39/f39/AX9gAn9/AX5gAn5+AX5gAABgBX9/f39/AGAGf39/f39/AGAIf39/f39/f38AYAl/f39/f39/f38AYAABf2AIf39/f39/f38Bf2ANf39/f39/f39/f39/fwF/YAF/AX4CJwEDZW52H2Vtc2NyaXB0ZW5fbm90aWZ5X21lbW9yeV9ncm93dGgABANpaAEFAAAFAgEFCwACAQABAgIFBQcAAwABDgsBAQcAEhMHAAUBDAQEAAANBwQCAgYCBAgDAwMDBgEACQkHBgICAAYGAgQUBwYGAwIGAAMCAQgBBwUGCgoEEQAEBAEIAwgDBQgDEA8IAAcABAUBcAECAgUEAQCAAgYJAX8BQaCgwAILB2AHBm1lbW9yeQIABm1hbGxvYwAoBGZyZWUAJgxaU1REX2lzRXJyb3IAaBlaU1REX2ZpbmREZWNvbXByZXNzZWRTaXplAFQPWlNURF9kZWNvbXByZXNzAEoGX3N0YXJ0ACQJBwEAQQELASQKussBaA8AIAAgACgCBCABajYCBAsZACAAKAIAIAAoAgRBH3F0QQAgAWtBH3F2CwgAIABBiH9LC34BBH9BAyEBIAAoAgQiA0EgTQRAIAAoAggiASAAKAIQTwRAIAAQDQ8LIAAoAgwiAiABRgRAQQFBAiADQSBJGw8LIAAgASABIAJrIANBA3YiBCABIARrIAJJIgEbIgJrIgQ2AgggACADIAJBA3RrNgIEIAAgBCgAADYCAAsgAQsUAQF/IAAgARACIQIgACABEAEgAgv3AQECfyACRQRAIABCADcCACAAQQA2AhAgAEIANwIIQbh/DwsgACABNgIMIAAgAUEEajYCECACQQRPBEAgACABIAJqIgFBfGoiAzYCCCAAIAMoAAA2AgAgAUF/ai0AACIBBEAgAEEIIAEQFGs2AgQgAg8LIABBADYCBEF/DwsgACABNgIIIAAgAS0AACIDNgIAIAJBfmoiBEEBTQRAIARBAWtFBEAgACABLQACQRB0IANyIgM2AgALIAAgAS0AAUEIdCADajYCAAsgASACakF/ai0AACIBRQRAIABBADYCBEFsDwsgAEEoIAEQFCACQQN0ams2AgQgAgsWACAAIAEpAAA3AAAgACABKQAINwAICy8BAX8gAUECdEGgHWooAgAgACgCAEEgIAEgACgCBGprQR9xdnEhAiAAIAEQASACCyEAIAFCz9bTvtLHq9lCfiAAfEIfiUKHla+vmLbem55/fgsdAQF/IAAoAgggACgCDEYEfyAAKAIEQSBGBUEACwuCBAEDfyACQYDAAE8EQCAAIAEgAhBnIAAPCyAAIAJqIQMCQCAAIAFzQQNxRQRAAkAgAkEBSARAIAAhAgwBCyAAQQNxRQRAIAAhAgwBCyAAIQIDQCACIAEtAAA6AAAgAUEBaiEBIAJBAWoiAiADTw0BIAJBA3ENAAsLAkAgA0F8cSIEQcAASQ0AIAIgBEFAaiIFSw0AA0AgAiABKAIANgIAIAIgASgCBDYCBCACIAEoAgg2AgggAiABKAIMNgIMIAIgASgCEDYCECACIAEoAhQ2AhQgAiABKAIYNgIYIAIgASgCHDYCHCACIAEoAiA2AiAgAiABKAIkNgIkIAIgASgCKDYCKCACIAEoAiw2AiwgAiABKAIwNgIwIAIgASgCNDYCNCACIAEoAjg2AjggAiABKAI8NgI8IAFBQGshASACQUBrIgIgBU0NAAsLIAIgBE8NAQNAIAIgASgCADYCACABQQRqIQEgAkEEaiICIARJDQALDAELIANBBEkEQCAAIQIMAQsgA0F8aiIEIABJBEAgACECDAELIAAhAgNAIAIgAS0AADoAACACIAEtAAE6AAEgAiABLQACOgACIAIgAS0AAzoAAyABQQRqIQEgAkEEaiICIARNDQALCyACIANJBEADQCACIAEtAAA6AAAgAUEBaiEBIAJBAWoiAiADRw0ACwsgAAsMACAAIAEpAAA3AAALQQECfyAAKAIIIgEgACgCEEkEQEEDDwsgACAAKAIEIgJBB3E2AgQgACABIAJBA3ZrIgE2AgggACABKAAANgIAQQALDAAgACABKAIANgAAC/cCAQJ/AkAgACABRg0AAkAgASACaiAASwRAIAAgAmoiBCABSw0BCyAAIAEgAhALDwsgACABc0EDcSEDAkACQCAAIAFJBEAgAwRAIAAhAwwDCyAAQQNxRQRAIAAhAwwCCyAAIQMDQCACRQ0EIAMgAS0AADoAACABQQFqIQEgAkF/aiECIANBAWoiA0EDcQ0ACwwBCwJAIAMNACAEQQNxBEADQCACRQ0FIAAgAkF/aiICaiIDIAEgAmotAAA6AAAgA0EDcQ0ACwsgAkEDTQ0AA0AgACACQXxqIgJqIAEgAmooAgA2AgAgAkEDSw0ACwsgAkUNAgNAIAAgAkF/aiICaiABIAJqLQAAOgAAIAINAAsMAgsgAkEDTQ0AIAIhBANAIAMgASgCADYCACABQQRqIQEgA0EEaiEDIARBfGoiBEEDSw0ACyACQQNxIQILIAJFDQADQCADIAEtAAA6AAAgA0EBaiEDIAFBAWohASACQX9qIgINAAsLIAAL8wICAn8BfgJAIAJFDQAgACACaiIDQX9qIAE6AAAgACABOgAAIAJBA0kNACADQX5qIAE6AAAgACABOgABIANBfWogAToAACAAIAE6AAIgAkEHSQ0AIANBfGogAToAACAAIAE6AAMgAkEJSQ0AIABBACAAa0EDcSIEaiIDIAFB/wFxQYGChAhsIgE2AgAgAyACIARrQXxxIgRqIgJBfGogATYCACAEQQlJDQAgAyABNgIIIAMgATYCBCACQXhqIAE2AgAgAkF0aiABNgIAIARBGUkNACADIAE2AhggAyABNgIUIAMgATYCECADIAE2AgwgAkFwaiABNgIAIAJBbGogATYCACACQWhqIAE2AgAgAkFkaiABNgIAIAQgA0EEcUEYciIEayICQSBJDQAgAa0iBUIghiAFhCEFIAMgBGohAQNAIAEgBTcDGCABIAU3AxAgASAFNwMIIAEgBTcDACABQSBqIQEgAkFgaiICQR9LDQALCyAACy8BAn8gACgCBCAAKAIAQQJ0aiICLQACIQMgACACLwEAIAEgAi0AAxAIajYCACADCy8BAn8gACgCBCAAKAIAQQJ0aiICLQACIQMgACACLwEAIAEgAi0AAxAFajYCACADCx8AIAAgASACKAIEEAg2AgAgARAEGiAAIAJBCGo2AgQLCAAgAGdBH3MLugUBDX8jAEEQayIKJAACfyAEQQNNBEAgCkEANgIMIApBDGogAyAEEAsaIAAgASACIApBDGpBBBAVIgBBbCAAEAMbIAAgACAESxsMAQsgAEEAIAEoAgBBAXRBAmoQECENQVQgAygAACIGQQ9xIgBBCksNABogAiAAQQVqNgIAIAMgBGoiAkF8aiEMIAJBeWohDiACQXtqIRAgAEEGaiELQQQhBSAGQQR2IQRBICAAdCIAQQFyIQkgASgCACEPQQAhAiADIQYCQANAIAlBAkggAiAPS3JFBEAgAiEHAkAgCARAA0AgBEH//wNxQf//A0YEQCAHQRhqIQcgBiAQSQR/IAZBAmoiBigAACAFdgUgBUEQaiEFIARBEHYLIQQMAQsLA0AgBEEDcSIIQQNGBEAgBUECaiEFIARBAnYhBCAHQQNqIQcMAQsLIAcgCGoiByAPSw0EIAVBAmohBQNAIAIgB0kEQCANIAJBAXRqQQA7AQAgAkEBaiECDAELCyAGIA5LQQAgBiAFQQN1aiIHIAxLG0UEQCAHKAAAIAVBB3EiBXYhBAwCCyAEQQJ2IQQLIAYhBwsCfyALQX9qIAQgAEF/anEiBiAAQQF0QX9qIgggCWsiEUkNABogBCAIcSIEQQAgESAEIABIG2shBiALCyEIIA0gAkEBdGogBkF/aiIEOwEAIAlBASAGayAEIAZBAUgbayEJA0AgCSAASARAIABBAXUhACALQX9qIQsMAQsLAn8gByAOS0EAIAcgBSAIaiIFQQN1aiIGIAxLG0UEQCAFQQdxDAELIAUgDCIGIAdrQQN0awshBSACQQFqIQIgBEUhCCAGKAAAIAVBH3F2IQQMAQsLQWwgCUEBRyAFQSBKcg0BGiABIAJBf2o2AgAgBiAFQQdqQQN1aiADawwBC0FQCyEAIApBEGokACAACwkAQQFBBSAAGwsMACAAIAEoAAA2AAALqgMBCn8jAEHwAGsiCiQAIAJBAWohDiAAQQhqIQtBgIAEIAVBf2p0QRB1IQxBACECQQEhBkEBIAV0IglBf2oiDyEIA0AgAiAORkUEQAJAIAEgAkEBdCINai8BACIHQf//A0YEQCALIAhBA3RqIAI2AgQgCEF/aiEIQQEhBwwBCyAGQQAgDCAHQRB0QRB1ShshBgsgCiANaiAHOwEAIAJBAWohAgwBCwsgACAFNgIEIAAgBjYCACAJQQN2IAlBAXZqQQNqIQxBACEAQQAhBkEAIQIDQCAGIA5GBEADQAJAIAAgCUYNACAKIAsgAEEDdGoiASgCBCIGQQF0aiICIAIvAQAiAkEBajsBACABIAUgAhAUayIIOgADIAEgAiAIQf8BcXQgCWs7AQAgASAEIAZBAnQiAmooAgA6AAIgASACIANqKAIANgIEIABBAWohAAwBCwsFIAEgBkEBdGouAQAhDUEAIQcDQCAHIA1ORQRAIAsgAkEDdGogBjYCBANAIAIgDGogD3EiAiAISw0ACyAHQQFqIQcMAQsLIAZBAWohBgwBCwsgCkHwAGokAAsjAEIAIAEQCSAAhUKHla+vmLbem55/fkLj3MqV/M7y9YV/fAsQACAAQn43AwggACABNgIACyQBAX8gAARAIAEoAgQiAgRAIAEoAgggACACEQEADwsgABAmCwsfACAAIAEgAi8BABAINgIAIAEQBBogACACQQRqNgIEC0oBAX9BoCAoAgAiASAAaiIAQX9MBEBBiCBBMDYCAEF/DwsCQCAAPwBBEHRNDQAgABBmDQBBiCBBMDYCAEF/DwtBoCAgADYCACABC9cBAQh/Qbp/IQoCQCACKAIEIgggAigCACIJaiIOIAEgAGtLDQBBbCEKIAkgBCADKAIAIgtrSw0AIAAgCWoiBCACKAIIIgxrIQ0gACABQWBqIg8gCyAJQQAQKSADIAkgC2o2AgACQAJAIAwgBCAFa00EQCANIQUMAQsgDCAEIAZrSw0CIAcgDSAFayIAaiIBIAhqIAdNBEAgBCABIAgQDxoMAgsgBCABQQAgAGsQDyEBIAIgACAIaiIINgIEIAEgAGshBAsgBCAPIAUgCEEBECkLIA4hCgsgCgubAgEBfyMAQYABayINJAAgDSADNgJ8AkAgAkEDSwRAQX8hCQwBCwJAAkACQAJAIAJBAWsOAwADAgELIAZFBEBBuH8hCQwEC0FsIQkgBS0AACICIANLDQMgACAHIAJBAnQiAmooAgAgAiAIaigCABA7IAEgADYCAEEBIQkMAwsgASAJNgIAQQAhCQwCCyAKRQRAQWwhCQwCC0EAIQkgC0UgDEEZSHINAUEIIAR0QQhqIQBBACECA0AgAiAATw0CIAJBQGshAgwAAAsAC0FsIQkgDSANQfwAaiANQfgAaiAFIAYQFSICEAMNACANKAJ4IgMgBEsNACAAIA0gDSgCfCAHIAggAxAYIAEgADYCACACIQkLIA1BgAFqJAAgCQsLACAAIAEgAhALGgsQACAALwAAIAAtAAJBEHRyCy8AAn9BuH8gAUEISQ0AGkFyIAAoAAQiAEF3Sw0AGkG4fyAAQQhqIgAgACABSxsLCwkAIAAgATsAAAsDAAELigYBBX8gACAAKAIAIgVBfnE2AgBBACAAIAVBAXZqQYQgKAIAIgQgAEYbIQECQAJAIAAoAgQiAkUNACACKAIAIgNBAXENACACQQhqIgUgA0EBdkF4aiIDQQggA0EISxtnQR9zQQJ0QYAfaiIDKAIARgRAIAMgAigCDDYCAAsgAigCCCIDBEAgAyACKAIMNgIECyACKAIMIgMEQCADIAIoAgg2AgALIAIgAigCACAAKAIAQX5xajYCAEGEICEAAkACQCABRQ0AIAEgAjYCBCABKAIAIgNBAXENASADQQF2QXhqIgNBCCADQQhLG2dBH3NBAnRBgB9qIgMoAgAgAUEIakYEQCADIAEoAgw2AgALIAEoAggiAwRAIAMgASgCDDYCBAsgASgCDCIDBEAgAyABKAIINgIAQYQgKAIAIQQLIAIgAigCACABKAIAQX5xajYCACABIARGDQAgASABKAIAQQF2akEEaiEACyAAIAI2AgALIAIoAgBBAXZBeGoiAEEIIABBCEsbZ0Efc0ECdEGAH2oiASgCACEAIAEgBTYCACACIAA2AgwgAkEANgIIIABFDQEgACAFNgIADwsCQCABRQ0AIAEoAgAiAkEBcQ0AIAJBAXZBeGoiAkEIIAJBCEsbZ0Efc0ECdEGAH2oiAigCACABQQhqRgRAIAIgASgCDDYCAAsgASgCCCICBEAgAiABKAIMNgIECyABKAIMIgIEQCACIAEoAgg2AgBBhCAoAgAhBAsgACAAKAIAIAEoAgBBfnFqIgI2AgACQCABIARHBEAgASABKAIAQQF2aiAANgIEIAAoAgAhAgwBC0GEICAANgIACyACQQF2QXhqIgFBCCABQQhLG2dBH3NBAnRBgB9qIgIoAgAhASACIABBCGoiAjYCACAAIAE2AgwgAEEANgIIIAFFDQEgASACNgIADwsgBUEBdkF4aiIBQQggAUEISxtnQR9zQQJ0QYAfaiICKAIAIQEgAiAAQQhqIgI2AgAgACABNgIMIABBADYCCCABRQ0AIAEgAjYCAAsLDgAgAARAIABBeGoQJQsLgAIBA38CQCAAQQ9qQXhxQYQgKAIAKAIAQQF2ayICEB1Bf0YNAAJAQYQgKAIAIgAoAgAiAUEBcQ0AIAFBAXZBeGoiAUEIIAFBCEsbZ0Efc0ECdEGAH2oiASgCACAAQQhqRgRAIAEgACgCDDYCAAsgACgCCCIBBEAgASAAKAIMNgIECyAAKAIMIgFFDQAgASAAKAIINgIAC0EBIQEgACAAKAIAIAJBAXRqIgI2AgAgAkEBcQ0AIAJBAXZBeGoiAkEIIAJBCEsbZ0Efc0ECdEGAH2oiAygCACECIAMgAEEIaiIDNgIAIAAgAjYCDCAAQQA2AgggAkUNACACIAM2AgALIAELtwIBA38CQAJAIABBASAAGyICEDgiAA0AAkACQEGEICgCACIARQ0AIAAoAgAiA0EBcQ0AIAAgA0EBcjYCACADQQF2QXhqIgFBCCABQQhLG2dBH3NBAnRBgB9qIgEoAgAgAEEIakYEQCABIAAoAgw2AgALIAAoAggiAQRAIAEgACgCDDYCBAsgACgCDCIBBEAgASAAKAIINgIACyACECchAkEAIQFBhCAoAgAhACACDQEgACAAKAIAQX5xNgIAQQAPCyACQQ9qQXhxIgMQHSICQX9GDQIgAkEHakF4cSIAIAJHBEAgACACaxAdQX9GDQMLAkBBhCAoAgAiAUUEQEGAICAANgIADAELIAAgATYCBAtBhCAgADYCACAAIANBAXRBAXI2AgAMAQsgAEUNAQsgAEEIaiEBCyABC7kDAQJ/IAAgA2ohBQJAIANBB0wEQANAIAAgBU8NAiAAIAItAAA6AAAgAEEBaiEAIAJBAWohAgwAAAsACyAEQQFGBEACQCAAIAJrIgZBB00EQCAAIAItAAA6AAAgACACLQABOgABIAAgAi0AAjoAAiAAIAItAAM6AAMgAEEEaiACIAZBAnQiBkHAHmooAgBqIgIQFyACIAZB4B5qKAIAayECDAELIAAgAhAMCyACQQhqIQIgAEEIaiEACwJAAkACQAJAIAUgAU0EQCAAIANqIQEgBEEBRyAAIAJrQQ9Kcg0BA0AgACACEAwgAkEIaiECIABBCGoiACABSQ0ACwwFCyAAIAFLBEAgACEBDAQLIARBAUcgACACa0EPSnINASAAIQMgAiEEA0AgAyAEEAwgBEEIaiEEIANBCGoiAyABSQ0ACwwCCwNAIAAgAhAHIAJBEGohAiAAQRBqIgAgAUkNAAsMAwsgACEDIAIhBANAIAMgBBAHIARBEGohBCADQRBqIgMgAUkNAAsLIAIgASAAa2ohAgsDQCABIAVPDQEgASACLQAAOgAAIAFBAWohASACQQFqIQIMAAALAAsLQQECfyAAIAAoArjgASIDNgLE4AEgACgCvOABIQQgACABNgK84AEgACABIAJqNgK44AEgACABIAQgA2tqNgLA4AELpgEBAX8gACAAKALs4QEQFjYCyOABIABCADcD+OABIABCADcDuOABIABBwOABakIANwMAIABBqNAAaiIBQYyAgOAANgIAIABBADYCmOIBIABCADcDiOEBIABCAzcDgOEBIABBrNABakHgEikCADcCACAAQbTQAWpB6BIoAgA2AgAgACABNgIMIAAgAEGYIGo2AgggACAAQaAwajYCBCAAIABBEGo2AgALYQEBf0G4fyEDAkAgAUEDSQ0AIAIgABAhIgFBA3YiADYCCCACIAFBAXE2AgQgAiABQQF2QQNxIgM2AgACQCADQX9qIgFBAksNAAJAIAFBAWsOAgEAAgtBbA8LIAAhAwsgAwsMACAAIAEgAkEAEC4LiAQCA38CfiADEBYhBCAAQQBBKBAQIQAgBCACSwRAIAQPCyABRQRAQX8PCwJAAkAgA0EBRg0AIAEoAAAiBkGo6r5pRg0AQXYhAyAGQXBxQdDUtMIBRw0BQQghAyACQQhJDQEgAEEAQSgQECEAIAEoAAQhASAAQQE2AhQgACABrTcDAEEADwsgASACIAMQLyIDIAJLDQAgACADNgIYQXIhAyABIARqIgVBf2otAAAiAkEIcQ0AIAJBIHEiBkUEQEFwIQMgBS0AACIFQacBSw0BIAVBB3GtQgEgBUEDdkEKaq2GIgdCA4h+IAd8IQggBEEBaiEECyACQQZ2IQMgAkECdiEFAkAgAkEDcUF/aiICQQJLBEBBACECDAELAkACQAJAIAJBAWsOAgECAAsgASAEai0AACECIARBAWohBAwCCyABIARqLwAAIQIgBEECaiEEDAELIAEgBGooAAAhAiAEQQRqIQQLIAVBAXEhBQJ+AkACQAJAIANBf2oiA0ECTQRAIANBAWsOAgIDAQtCfyAGRQ0DGiABIARqMQAADAMLIAEgBGovAACtQoACfAwCCyABIARqKAAArQwBCyABIARqKQAACyEHIAAgBTYCICAAIAI2AhwgACAHNwMAQQAhAyAAQQA2AhQgACAHIAggBhsiBzcDCCAAIAdCgIAIIAdCgIAIVBs+AhALIAMLWwEBf0G4fyEDIAIQFiICIAFNBH8gACACakF/ai0AACIAQQNxQQJ0QaAeaigCACACaiAAQQZ2IgFBAnRBsB5qKAIAaiAAQSBxIgBFaiABRSAAQQV2cWoFQbh/CwsdACAAKAKQ4gEQWiAAQQA2AqDiASAAQgA3A5DiAQu1AwEFfyMAQZACayIKJABBuH8hBgJAIAVFDQAgBCwAACIIQf8BcSEHAkAgCEF/TARAIAdBgn9qQQF2IgggBU8NAkFsIQYgB0GBf2oiBUGAAk8NAiAEQQFqIQdBACEGA0AgBiAFTwRAIAUhBiAIIQcMAwUgACAGaiAHIAZBAXZqIgQtAABBBHY6AAAgACAGQQFyaiAELQAAQQ9xOgAAIAZBAmohBgwBCwAACwALIAcgBU8NASAAIARBAWogByAKEFMiBhADDQELIAYhBEEAIQYgAUEAQTQQECEJQQAhBQNAIAQgBkcEQCAAIAZqIggtAAAiAUELSwRAQWwhBgwDBSAJIAFBAnRqIgEgASgCAEEBajYCACAGQQFqIQZBASAILQAAdEEBdSAFaiEFDAILAAsLQWwhBiAFRQ0AIAUQFEEBaiIBQQxLDQAgAyABNgIAQQFBASABdCAFayIDEBQiAXQgA0cNACAAIARqIAFBAWoiADoAACAJIABBAnRqIgAgACgCAEEBajYCACAJKAIEIgBBAkkgAEEBcXINACACIARBAWo2AgAgB0EBaiEGCyAKQZACaiQAIAYLxhEBDH8jAEHwAGsiBSQAQWwhCwJAIANBCkkNACACLwAAIQogAi8AAiEJIAIvAAQhByAFQQhqIAQQDgJAIAMgByAJIApqakEGaiIMSQ0AIAUtAAohCCAFQdgAaiACQQZqIgIgChAGIgsQAw0BIAVBQGsgAiAKaiICIAkQBiILEAMNASAFQShqIAIgCWoiAiAHEAYiCxADDQEgBUEQaiACIAdqIAMgDGsQBiILEAMNASAAIAFqIg9BfWohECAEQQRqIQZBASELIAAgAUEDakECdiIDaiIMIANqIgIgA2oiDiEDIAIhBCAMIQcDQCALIAMgEElxBEAgACAGIAVB2ABqIAgQAkECdGoiCS8BADsAACAFQdgAaiAJLQACEAEgCS0AAyELIAcgBiAFQUBrIAgQAkECdGoiCS8BADsAACAFQUBrIAktAAIQASAJLQADIQogBCAGIAVBKGogCBACQQJ0aiIJLwEAOwAAIAVBKGogCS0AAhABIAktAAMhCSADIAYgBUEQaiAIEAJBAnRqIg0vAQA7AAAgBUEQaiANLQACEAEgDS0AAyENIAAgC2oiCyAGIAVB2ABqIAgQAkECdGoiAC8BADsAACAFQdgAaiAALQACEAEgAC0AAyEAIAcgCmoiCiAGIAVBQGsgCBACQQJ0aiIHLwEAOwAAIAVBQGsgBy0AAhABIActAAMhByAEIAlqIgkgBiAFQShqIAgQAkECdGoiBC8BADsAACAFQShqIAQtAAIQASAELQADIQQgAyANaiIDIAYgBUEQaiAIEAJBAnRqIg0vAQA7AAAgBUEQaiANLQACEAEgACALaiEAIAcgCmohByAEIAlqIQQgAyANLQADaiEDIAVB2ABqEA0gBUFAaxANciAFQShqEA1yIAVBEGoQDXJFIQsMAQsLIAQgDksgByACS3INAEFsIQsgACAMSw0BIAxBfWohCQNAQQAgACAJSSAFQdgAahAEGwRAIAAgBiAFQdgAaiAIEAJBAnRqIgovAQA7AAAgBUHYAGogCi0AAhABIAAgCi0AA2oiACAGIAVB2ABqIAgQAkECdGoiCi8BADsAACAFQdgAaiAKLQACEAEgACAKLQADaiEADAEFIAxBfmohCgNAIAVB2ABqEAQgACAKS3JFBEAgACAGIAVB2ABqIAgQAkECdGoiCS8BADsAACAFQdgAaiAJLQACEAEgACAJLQADaiEADAELCwNAIAAgCk0EQCAAIAYgBUHYAGogCBACQQJ0aiIJLwEAOwAAIAVB2ABqIAktAAIQASAAIAktAANqIQAMAQsLAkAgACAMTw0AIAAgBiAFQdgAaiAIEAIiAEECdGoiDC0AADoAACAMLQADQQFGBEAgBUHYAGogDC0AAhABDAELIAUoAlxBH0sNACAFQdgAaiAGIABBAnRqLQACEAEgBSgCXEEhSQ0AIAVBIDYCXAsgAkF9aiEMA0BBACAHIAxJIAVBQGsQBBsEQCAHIAYgBUFAayAIEAJBAnRqIgAvAQA7AAAgBUFAayAALQACEAEgByAALQADaiIAIAYgBUFAayAIEAJBAnRqIgcvAQA7AAAgBUFAayAHLQACEAEgACAHLQADaiEHDAEFIAJBfmohDANAIAVBQGsQBCAHIAxLckUEQCAHIAYgBUFAayAIEAJBAnRqIgAvAQA7AAAgBUFAayAALQACEAEgByAALQADaiEHDAELCwNAIAcgDE0EQCAHIAYgBUFAayAIEAJBAnRqIgAvAQA7AAAgBUFAayAALQACEAEgByAALQADaiEHDAELCwJAIAcgAk8NACAHIAYgBUFAayAIEAIiAEECdGoiAi0AADoAACACLQADQQFGBEAgBUFAayACLQACEAEMAQsgBSgCREEfSw0AIAVBQGsgBiAAQQJ0ai0AAhABIAUoAkRBIUkNACAFQSA2AkQLIA5BfWohAgNAQQAgBCACSSAFQShqEAQbBEAgBCAGIAVBKGogCBACQQJ0aiIALwEAOwAAIAVBKGogAC0AAhABIAQgAC0AA2oiACAGIAVBKGogCBACQQJ0aiIELwEAOwAAIAVBKGogBC0AAhABIAAgBC0AA2ohBAwBBSAOQX5qIQIDQCAFQShqEAQgBCACS3JFBEAgBCAGIAVBKGogCBACQQJ0aiIALwEAOwAAIAVBKGogAC0AAhABIAQgAC0AA2ohBAwBCwsDQCAEIAJNBEAgBCAGIAVBKGogCBACQQJ0aiIALwEAOwAAIAVBKGogAC0AAhABIAQgAC0AA2ohBAwBCwsCQCAEIA5PDQAgBCAGIAVBKGogCBACIgBBAnRqIgItAAA6AAAgAi0AA0EBRgRAIAVBKGogAi0AAhABDAELIAUoAixBH0sNACAFQShqIAYgAEECdGotAAIQASAFKAIsQSFJDQAgBUEgNgIsCwNAQQAgAyAQSSAFQRBqEAQbBEAgAyAGIAVBEGogCBACQQJ0aiIALwEAOwAAIAVBEGogAC0AAhABIAMgAC0AA2oiACAGIAVBEGogCBACQQJ0aiICLwEAOwAAIAVBEGogAi0AAhABIAAgAi0AA2ohAwwBBSAPQX5qIQIDQCAFQRBqEAQgAyACS3JFBEAgAyAGIAVBEGogCBACQQJ0aiIALwEAOwAAIAVBEGogAC0AAhABIAMgAC0AA2ohAwwBCwsDQCADIAJNBEAgAyAGIAVBEGogCBACQQJ0aiIALwEAOwAAIAVBEGogAC0AAhABIAMgAC0AA2ohAwwBCwsCQCADIA9PDQAgAyAGIAVBEGogCBACIgBBAnRqIgItAAA6AAAgAi0AA0EBRgRAIAVBEGogAi0AAhABDAELIAUoAhRBH0sNACAFQRBqIAYgAEECdGotAAIQASAFKAIUQSFJDQAgBUEgNgIUCyABQWwgBUHYAGoQCiAFQUBrEApxIAVBKGoQCnEgBUEQahAKcRshCwwJCwAACwALAAALAAsAAAsACwAACwALQWwhCwsgBUHwAGokACALC7UEAQ5/IwBBEGsiBiQAIAZBBGogABAOQVQhBQJAIARB3AtJDQAgBi0ABCEHIANB8ARqQQBB7AAQECEIIAdBDEsNACADQdwJaiIJIAggBkEIaiAGQQxqIAEgAhAxIhAQA0UEQCAGKAIMIgQgB0sNASADQdwFaiEPIANBpAVqIREgAEEEaiESIANBqAVqIQEgBCEFA0AgBSICQX9qIQUgCCACQQJ0aigCAEUNAAsgAkEBaiEOQQEhBQNAIAUgDk9FBEAgCCAFQQJ0IgtqKAIAIQwgASALaiAKNgIAIAVBAWohBSAKIAxqIQoMAQsLIAEgCjYCAEEAIQUgBigCCCELA0AgBSALRkUEQCABIAUgCWotAAAiDEECdGoiDSANKAIAIg1BAWo2AgAgDyANQQF0aiINIAw6AAEgDSAFOgAAIAVBAWohBQwBCwtBACEBIANBADYCqAUgBEF/cyAHaiEJQQEhBQNAIAUgDk9FBEAgCCAFQQJ0IgtqKAIAIQwgAyALaiABNgIAIAwgBSAJanQgAWohASAFQQFqIQUMAQsLIAcgBEEBaiIBIAJrIgRrQQFqIQgDQEEBIQUgBCAIT0UEQANAIAUgDk9FBEAgBUECdCIJIAMgBEE0bGpqIAMgCWooAgAgBHY2AgAgBUEBaiEFDAELCyAEQQFqIQQMAQsLIBIgByAPIAogESADIAIgARBkIAZBAToABSAGIAc6AAYgACAGKAIENgIACyAQIQULIAZBEGokACAFC8ENAQt/IwBB8ABrIgUkAEFsIQkCQCADQQpJDQAgAi8AACEKIAIvAAIhDCACLwAEIQYgBUEIaiAEEA4CQCADIAYgCiAMampBBmoiDUkNACAFLQAKIQcgBUHYAGogAkEGaiICIAoQBiIJEAMNASAFQUBrIAIgCmoiAiAMEAYiCRADDQEgBUEoaiACIAxqIgIgBhAGIgkQAw0BIAVBEGogAiAGaiADIA1rEAYiCRADDQEgACABaiIOQX1qIQ8gBEEEaiEGQQEhCSAAIAFBA2pBAnYiAmoiCiACaiIMIAJqIg0hAyAMIQQgCiECA0AgCSADIA9JcQRAIAYgBUHYAGogBxACQQF0aiIILQAAIQsgBUHYAGogCC0AARABIAAgCzoAACAGIAVBQGsgBxACQQF0aiIILQAAIQsgBUFAayAILQABEAEgAiALOgAAIAYgBUEoaiAHEAJBAXRqIggtAAAhCyAFQShqIAgtAAEQASAEIAs6AAAgBiAFQRBqIAcQAkEBdGoiCC0AACELIAVBEGogCC0AARABIAMgCzoAACAGIAVB2ABqIAcQAkEBdGoiCC0AACELIAVB2ABqIAgtAAEQASAAIAs6AAEgBiAFQUBrIAcQAkEBdGoiCC0AACELIAVBQGsgCC0AARABIAIgCzoAASAGIAVBKGogBxACQQF0aiIILQAAIQsgBUEoaiAILQABEAEgBCALOgABIAYgBUEQaiAHEAJBAXRqIggtAAAhCyAFQRBqIAgtAAEQASADIAs6AAEgA0ECaiEDIARBAmohBCACQQJqIQIgAEECaiEAIAkgBUHYAGoQDUVxIAVBQGsQDUVxIAVBKGoQDUVxIAVBEGoQDUVxIQkMAQsLIAQgDUsgAiAMS3INAEFsIQkgACAKSw0BIApBfWohCQNAIAVB2ABqEAQgACAJT3JFBEAgBiAFQdgAaiAHEAJBAXRqIggtAAAhCyAFQdgAaiAILQABEAEgACALOgAAIAYgBUHYAGogBxACQQF0aiIILQAAIQsgBUHYAGogCC0AARABIAAgCzoAASAAQQJqIQAMAQsLA0AgBUHYAGoQBCAAIApPckUEQCAGIAVB2ABqIAcQAkEBdGoiCS0AACEIIAVB2ABqIAktAAEQASAAIAg6AAAgAEEBaiEADAELCwNAIAAgCkkEQCAGIAVB2ABqIAcQAkEBdGoiCS0AACEIIAVB2ABqIAktAAEQASAAIAg6AAAgAEEBaiEADAELCyAMQX1qIQADQCAFQUBrEAQgAiAAT3JFBEAgBiAFQUBrIAcQAkEBdGoiCi0AACEJIAVBQGsgCi0AARABIAIgCToAACAGIAVBQGsgBxACQQF0aiIKLQAAIQkgBUFAayAKLQABEAEgAiAJOgABIAJBAmohAgwBCwsDQCAFQUBrEAQgAiAMT3JFBEAgBiAFQUBrIAcQAkEBdGoiAC0AACEKIAVBQGsgAC0AARABIAIgCjoAACACQQFqIQIMAQsLA0AgAiAMSQRAIAYgBUFAayAHEAJBAXRqIgAtAAAhCiAFQUBrIAAtAAEQASACIAo6AAAgAkEBaiECDAELCyANQX1qIQADQCAFQShqEAQgBCAAT3JFBEAgBiAFQShqIAcQAkEBdGoiAi0AACEKIAVBKGogAi0AARABIAQgCjoAACAGIAVBKGogBxACQQF0aiICLQAAIQogBUEoaiACLQABEAEgBCAKOgABIARBAmohBAwBCwsDQCAFQShqEAQgBCANT3JFBEAgBiAFQShqIAcQAkEBdGoiAC0AACECIAVBKGogAC0AARABIAQgAjoAACAEQQFqIQQMAQsLA0AgBCANSQRAIAYgBUEoaiAHEAJBAXRqIgAtAAAhAiAFQShqIAAtAAEQASAEIAI6AAAgBEEBaiEEDAELCwNAIAVBEGoQBCADIA9PckUEQCAGIAVBEGogBxACQQF0aiIALQAAIQIgBUEQaiAALQABEAEgAyACOgAAIAYgBUEQaiAHEAJBAXRqIgAtAAAhAiAFQRBqIAAtAAEQASADIAI6AAEgA0ECaiEDDAELCwNAIAVBEGoQBCADIA5PckUEQCAGIAVBEGogBxACQQF0aiIALQAAIQIgBUEQaiAALQABEAEgAyACOgAAIANBAWohAwwBCwsDQCADIA5JBEAgBiAFQRBqIAcQAkEBdGoiAC0AACECIAVBEGogAC0AARABIAMgAjoAACADQQFqIQMMAQsLIAFBbCAFQdgAahAKIAVBQGsQCnEgBUEoahAKcSAFQRBqEApxGyEJDAELQWwhCQsgBUHwAGokACAJC8oCAQR/IwBBIGsiBSQAIAUgBBAOIAUtAAIhByAFQQhqIAIgAxAGIgIQA0UEQCAEQQRqIQIgACABaiIDQX1qIQQDQCAFQQhqEAQgACAET3JFBEAgAiAFQQhqIAcQAkEBdGoiBi0AACEIIAVBCGogBi0AARABIAAgCDoAACACIAVBCGogBxACQQF0aiIGLQAAIQggBUEIaiAGLQABEAEgACAIOgABIABBAmohAAwBCwsDQCAFQQhqEAQgACADT3JFBEAgAiAFQQhqIAcQAkEBdGoiBC0AACEGIAVBCGogBC0AARABIAAgBjoAACAAQQFqIQAMAQsLA0AgACADT0UEQCACIAVBCGogBxACQQF0aiIELQAAIQYgBUEIaiAELQABEAEgACAGOgAAIABBAWohAAwBCwsgAUFsIAVBCGoQChshAgsgBUEgaiQAIAILtgMBCX8jAEEQayIGJAAgBkEANgIMIAZBADYCCEFUIQQCQAJAIANBQGsiDCADIAZBCGogBkEMaiABIAIQMSICEAMNACAGQQRqIAAQDiAGKAIMIgcgBi0ABEEBaksNASAAQQRqIQogBkEAOgAFIAYgBzoABiAAIAYoAgQ2AgAgB0EBaiEJQQEhBANAIAQgCUkEQCADIARBAnRqIgEoAgAhACABIAU2AgAgACAEQX9qdCAFaiEFIARBAWohBAwBCwsgB0EBaiEHQQAhBSAGKAIIIQkDQCAFIAlGDQEgAyAFIAxqLQAAIgRBAnRqIgBBASAEdEEBdSILIAAoAgAiAWoiADYCACAHIARrIQhBACEEAkAgC0EDTQRAA0AgBCALRg0CIAogASAEakEBdGoiACAIOgABIAAgBToAACAEQQFqIQQMAAALAAsDQCABIABPDQEgCiABQQF0aiIEIAg6AAEgBCAFOgAAIAQgCDoAAyAEIAU6AAIgBCAIOgAFIAQgBToABCAEIAg6AAcgBCAFOgAGIAFBBGohAQwAAAsACyAFQQFqIQUMAAALAAsgAiEECyAGQRBqJAAgBAutAQECfwJAQYQgKAIAIABHIAAoAgBBAXYiAyABa0F4aiICQXhxQQhHcgR/IAIFIAMQJ0UNASACQQhqC0EQSQ0AIAAgACgCACICQQFxIAAgAWpBD2pBeHEiASAAa0EBdHI2AgAgASAANgIEIAEgASgCAEEBcSAAIAJBAXZqIAFrIgJBAXRyNgIAQYQgIAEgAkH/////B3FqQQRqQYQgKAIAIABGGyABNgIAIAEQJQsLygIBBX8CQAJAAkAgAEEIIABBCEsbZ0EfcyAAaUEBR2oiAUEESSAAIAF2cg0AIAFBAnRB/B5qKAIAIgJFDQADQCACQXhqIgMoAgBBAXZBeGoiBSAATwRAIAIgBUEIIAVBCEsbZ0Efc0ECdEGAH2oiASgCAEYEQCABIAIoAgQ2AgALDAMLIARBHksNASAEQQFqIQQgAigCBCICDQALC0EAIQMgAUEgTw0BA0AgAUECdEGAH2ooAgAiAkUEQCABQR5LIQIgAUEBaiEBIAJFDQEMAwsLIAIgAkF4aiIDKAIAQQF2QXhqIgFBCCABQQhLG2dBH3NBAnRBgB9qIgEoAgBGBEAgASACKAIENgIACwsgAigCACIBBEAgASACKAIENgIECyACKAIEIgEEQCABIAIoAgA2AgALIAMgAygCAEEBcjYCACADIAAQNwsgAwvhCwINfwV+IwBB8ABrIgckACAHIAAoAvDhASIINgJcIAEgAmohDSAIIAAoAoDiAWohDwJAAkAgBUUEQCABIQQMAQsgACgCxOABIRAgACgCwOABIREgACgCvOABIQ4gAEEBNgKM4QFBACEIA0AgCEEDRwRAIAcgCEECdCICaiAAIAJqQazQAWooAgA2AkQgCEEBaiEIDAELC0FsIQwgB0EYaiADIAQQBhADDQEgB0EsaiAHQRhqIAAoAgAQEyAHQTRqIAdBGGogACgCCBATIAdBPGogB0EYaiAAKAIEEBMgDUFgaiESIAEhBEEAIQwDQCAHKAIwIAcoAixBA3RqKQIAIhRCEIinQf8BcSEIIAcoAkAgBygCPEEDdGopAgAiFUIQiKdB/wFxIQsgBygCOCAHKAI0QQN0aikCACIWQiCIpyEJIBVCIIghFyAUQiCIpyECAkAgFkIQiKdB/wFxIgNBAk8EQAJAIAZFIANBGUlyRQRAIAkgB0EYaiADQSAgBygCHGsiCiAKIANLGyIKEAUgAyAKayIDdGohCSAHQRhqEAQaIANFDQEgB0EYaiADEAUgCWohCQwBCyAHQRhqIAMQBSAJaiEJIAdBGGoQBBoLIAcpAkQhGCAHIAk2AkQgByAYNwNIDAELAkAgA0UEQCACBEAgBygCRCEJDAMLIAcoAkghCQwBCwJAAkAgB0EYakEBEAUgCSACRWpqIgNBA0YEQCAHKAJEQX9qIgMgA0VqIQkMAQsgA0ECdCAHaigCRCIJIAlFaiEJIANBAUYNAQsgByAHKAJINgJMCwsgByAHKAJENgJIIAcgCTYCRAsgF6chAyALBEAgB0EYaiALEAUgA2ohAwsgCCALakEUTwRAIAdBGGoQBBoLIAgEQCAHQRhqIAgQBSACaiECCyAHQRhqEAQaIAcgB0EYaiAUQhiIp0H/AXEQCCAUp0H//wNxajYCLCAHIAdBGGogFUIYiKdB/wFxEAggFadB//8DcWo2AjwgB0EYahAEGiAHIAdBGGogFkIYiKdB/wFxEAggFqdB//8DcWo2AjQgByACNgJgIAcoAlwhCiAHIAk2AmggByADNgJkAkACQAJAIAQgAiADaiILaiASSw0AIAIgCmoiEyAPSw0AIA0gBGsgC0Egak8NAQsgByAHKQNoNwMQIAcgBykDYDcDCCAEIA0gB0EIaiAHQdwAaiAPIA4gESAQEB4hCwwBCyACIARqIQggBCAKEAcgAkERTwRAIARBEGohAgNAIAIgCkEQaiIKEAcgAkEQaiICIAhJDQALCyAIIAlrIQIgByATNgJcIAkgCCAOa0sEQCAJIAggEWtLBEBBbCELDAILIBAgAiAOayICaiIKIANqIBBNBEAgCCAKIAMQDxoMAgsgCCAKQQAgAmsQDyEIIAcgAiADaiIDNgJkIAggAmshCCAOIQILIAlBEE8EQCADIAhqIQMDQCAIIAIQByACQRBqIQIgCEEQaiIIIANJDQALDAELAkAgCUEHTQRAIAggAi0AADoAACAIIAItAAE6AAEgCCACLQACOgACIAggAi0AAzoAAyAIQQRqIAIgCUECdCIDQcAeaigCAGoiAhAXIAIgA0HgHmooAgBrIQIgBygCZCEDDAELIAggAhAMCyADQQlJDQAgAyAIaiEDIAhBCGoiCCACQQhqIgJrQQ9MBEADQCAIIAIQDCACQQhqIQIgCEEIaiIIIANJDQAMAgALAAsDQCAIIAIQByACQRBqIQIgCEEQaiIIIANJDQALCyAHQRhqEAQaIAsgDCALEAMiAhshDCAEIAQgC2ogAhshBCAFQX9qIgUNAAsgDBADDQFBbCEMIAdBGGoQBEECSQ0BQQAhCANAIAhBA0cEQCAAIAhBAnQiAmpBrNABaiACIAdqKAJENgIAIAhBAWohCAwBCwsgBygCXCEIC0G6fyEMIA8gCGsiACANIARrSw0AIAQEfyAEIAggABALIABqBUEACyABayEMCyAHQfAAaiQAIAwLkRcCFn8FfiMAQdABayIHJAAgByAAKALw4QEiCDYCvAEgASACaiESIAggACgCgOIBaiETAkACQCAFRQRAIAEhAwwBCyAAKALE4AEhESAAKALA4AEhFSAAKAK84AEhDyAAQQE2AozhAUEAIQgDQCAIQQNHBEAgByAIQQJ0IgJqIAAgAmpBrNABaigCADYCVCAIQQFqIQgMAQsLIAcgETYCZCAHIA82AmAgByABIA9rNgJoQWwhECAHQShqIAMgBBAGEAMNASAFQQQgBUEESBshFyAHQTxqIAdBKGogACgCABATIAdBxABqIAdBKGogACgCCBATIAdBzABqIAdBKGogACgCBBATQQAhBCAHQeAAaiEMIAdB5ABqIQoDQCAHQShqEARBAksgBCAXTnJFBEAgBygCQCAHKAI8QQN0aikCACIdQhCIp0H/AXEhCyAHKAJQIAcoAkxBA3RqKQIAIh5CEIinQf8BcSEJIAcoAkggBygCREEDdGopAgAiH0IgiKchCCAeQiCIISAgHUIgiKchAgJAIB9CEIinQf8BcSIDQQJPBEACQCAGRSADQRlJckUEQCAIIAdBKGogA0EgIAcoAixrIg0gDSADSxsiDRAFIAMgDWsiA3RqIQggB0EoahAEGiADRQ0BIAdBKGogAxAFIAhqIQgMAQsgB0EoaiADEAUgCGohCCAHQShqEAQaCyAHKQJUISEgByAINgJUIAcgITcDWAwBCwJAIANFBEAgAgRAIAcoAlQhCAwDCyAHKAJYIQgMAQsCQAJAIAdBKGpBARAFIAggAkVqaiIDQQNGBEAgBygCVEF/aiIDIANFaiEIDAELIANBAnQgB2ooAlQiCCAIRWohCCADQQFGDQELIAcgBygCWDYCXAsLIAcgBygCVDYCWCAHIAg2AlQLICCnIQMgCQRAIAdBKGogCRAFIANqIQMLIAkgC2pBFE8EQCAHQShqEAQaCyALBEAgB0EoaiALEAUgAmohAgsgB0EoahAEGiAHIAcoAmggAmoiCSADajYCaCAKIAwgCCAJSxsoAgAhDSAHIAdBKGogHUIYiKdB/wFxEAggHadB//8DcWo2AjwgByAHQShqIB5CGIinQf8BcRAIIB6nQf//A3FqNgJMIAdBKGoQBBogB0EoaiAfQhiIp0H/AXEQCCEOIAdB8ABqIARBBHRqIgsgCSANaiAIazYCDCALIAg2AgggCyADNgIEIAsgAjYCACAHIA4gH6dB//8DcWo2AkQgBEEBaiEEDAELCyAEIBdIDQEgEkFgaiEYIAdB4ABqIRogB0HkAGohGyABIQMDQCAHQShqEARBAksgBCAFTnJFBEAgBygCQCAHKAI8QQN0aikCACIdQhCIp0H/AXEhCyAHKAJQIAcoAkxBA3RqKQIAIh5CEIinQf8BcSEIIAcoAkggBygCREEDdGopAgAiH0IgiKchCSAeQiCIISAgHUIgiKchDAJAIB9CEIinQf8BcSICQQJPBEACQCAGRSACQRlJckUEQCAJIAdBKGogAkEgIAcoAixrIgogCiACSxsiChAFIAIgCmsiAnRqIQkgB0EoahAEGiACRQ0BIAdBKGogAhAFIAlqIQkMAQsgB0EoaiACEAUgCWohCSAHQShqEAQaCyAHKQJUISEgByAJNgJUIAcgITcDWAwBCwJAIAJFBEAgDARAIAcoAlQhCQwDCyAHKAJYIQkMAQsCQAJAIAdBKGpBARAFIAkgDEVqaiICQQNGBEAgBygCVEF/aiICIAJFaiEJDAELIAJBAnQgB2ooAlQiCSAJRWohCSACQQFGDQELIAcgBygCWDYCXAsLIAcgBygCVDYCWCAHIAk2AlQLICCnIRQgCARAIAdBKGogCBAFIBRqIRQLIAggC2pBFE8EQCAHQShqEAQaCyALBEAgB0EoaiALEAUgDGohDAsgB0EoahAEGiAHIAcoAmggDGoiGSAUajYCaCAbIBogCSAZSxsoAgAhHCAHIAdBKGogHUIYiKdB/wFxEAggHadB//8DcWo2AjwgByAHQShqIB5CGIinQf8BcRAIIB6nQf//A3FqNgJMIAdBKGoQBBogByAHQShqIB9CGIinQf8BcRAIIB+nQf//A3FqNgJEIAcgB0HwAGogBEEDcUEEdGoiDSkDCCIdNwPIASAHIA0pAwAiHjcDwAECQAJAAkAgBygCvAEiDiAepyICaiIWIBNLDQAgAyAHKALEASIKIAJqIgtqIBhLDQAgEiADayALQSBqTw0BCyAHIAcpA8gBNwMQIAcgBykDwAE3AwggAyASIAdBCGogB0G8AWogEyAPIBUgERAeIQsMAQsgAiADaiEIIAMgDhAHIAJBEU8EQCADQRBqIQIDQCACIA5BEGoiDhAHIAJBEGoiAiAISQ0ACwsgCCAdpyIOayECIAcgFjYCvAEgDiAIIA9rSwRAIA4gCCAVa0sEQEFsIQsMAgsgESACIA9rIgJqIhYgCmogEU0EQCAIIBYgChAPGgwCCyAIIBZBACACaxAPIQggByACIApqIgo2AsQBIAggAmshCCAPIQILIA5BEE8EQCAIIApqIQoDQCAIIAIQByACQRBqIQIgCEEQaiIIIApJDQALDAELAkAgDkEHTQRAIAggAi0AADoAACAIIAItAAE6AAEgCCACLQACOgACIAggAi0AAzoAAyAIQQRqIAIgDkECdCIKQcAeaigCAGoiAhAXIAIgCkHgHmooAgBrIQIgBygCxAEhCgwBCyAIIAIQDAsgCkEJSQ0AIAggCmohCiAIQQhqIgggAkEIaiICa0EPTARAA0AgCCACEAwgAkEIaiECIAhBCGoiCCAKSQ0ADAIACwALA0AgCCACEAcgAkEQaiECIAhBEGoiCCAKSQ0ACwsgCxADBEAgCyEQDAQFIA0gDDYCACANIBkgHGogCWs2AgwgDSAJNgIIIA0gFDYCBCAEQQFqIQQgAyALaiEDDAILAAsLIAQgBUgNASAEIBdrIQtBACEEA0AgCyAFSARAIAcgB0HwAGogC0EDcUEEdGoiAikDCCIdNwPIASAHIAIpAwAiHjcDwAECQAJAAkAgBygCvAEiDCAepyICaiIKIBNLDQAgAyAHKALEASIJIAJqIhBqIBhLDQAgEiADayAQQSBqTw0BCyAHIAcpA8gBNwMgIAcgBykDwAE3AxggAyASIAdBGGogB0G8AWogEyAPIBUgERAeIRAMAQsgAiADaiEIIAMgDBAHIAJBEU8EQCADQRBqIQIDQCACIAxBEGoiDBAHIAJBEGoiAiAISQ0ACwsgCCAdpyIGayECIAcgCjYCvAEgBiAIIA9rSwRAIAYgCCAVa0sEQEFsIRAMAgsgESACIA9rIgJqIgwgCWogEU0EQCAIIAwgCRAPGgwCCyAIIAxBACACaxAPIQggByACIAlqIgk2AsQBIAggAmshCCAPIQILIAZBEE8EQCAIIAlqIQYDQCAIIAIQByACQRBqIQIgCEEQaiIIIAZJDQALDAELAkAgBkEHTQRAIAggAi0AADoAACAIIAItAAE6AAEgCCACLQACOgACIAggAi0AAzoAAyAIQQRqIAIgBkECdCIGQcAeaigCAGoiAhAXIAIgBkHgHmooAgBrIQIgBygCxAEhCQwBCyAIIAIQDAsgCUEJSQ0AIAggCWohBiAIQQhqIgggAkEIaiICa0EPTARAA0AgCCACEAwgAkEIaiECIAhBCGoiCCAGSQ0ADAIACwALA0AgCCACEAcgAkEQaiECIAhBEGoiCCAGSQ0ACwsgEBADDQMgC0EBaiELIAMgEGohAwwBCwsDQCAEQQNHBEAgACAEQQJ0IgJqQazQAWogAiAHaigCVDYCACAEQQFqIQQMAQsLIAcoArwBIQgLQbp/IRAgEyAIayIAIBIgA2tLDQAgAwR/IAMgCCAAEAsgAGoFQQALIAFrIRALIAdB0AFqJAAgEAslACAAQgA3AgAgAEEAOwEIIABBADoACyAAIAE2AgwgACACOgAKC7QFAQN/IwBBMGsiBCQAIABB/wFqIgVBfWohBgJAIAMvAQIEQCAEQRhqIAEgAhAGIgIQAw0BIARBEGogBEEYaiADEBwgBEEIaiAEQRhqIAMQHCAAIQMDQAJAIARBGGoQBCADIAZPckUEQCADIARBEGogBEEYahASOgAAIAMgBEEIaiAEQRhqEBI6AAEgBEEYahAERQ0BIANBAmohAwsgBUF+aiEFAn8DQEG6fyECIAMiASAFSw0FIAEgBEEQaiAEQRhqEBI6AAAgAUEBaiEDIARBGGoQBEEDRgRAQQIhAiAEQQhqDAILIAMgBUsNBSABIARBCGogBEEYahASOgABIAFBAmohA0EDIQIgBEEYahAEQQNHDQALIARBEGoLIQUgAyAFIARBGGoQEjoAACABIAJqIABrIQIMAwsgAyAEQRBqIARBGGoQEjoAAiADIARBCGogBEEYahASOgADIANBBGohAwwAAAsACyAEQRhqIAEgAhAGIgIQAw0AIARBEGogBEEYaiADEBwgBEEIaiAEQRhqIAMQHCAAIQMDQAJAIARBGGoQBCADIAZPckUEQCADIARBEGogBEEYahAROgAAIAMgBEEIaiAEQRhqEBE6AAEgBEEYahAERQ0BIANBAmohAwsgBUF+aiEFAn8DQEG6fyECIAMiASAFSw0EIAEgBEEQaiAEQRhqEBE6AAAgAUEBaiEDIARBGGoQBEEDRgRAQQIhAiAEQQhqDAILIAMgBUsNBCABIARBCGogBEEYahAROgABIAFBAmohA0EDIQIgBEEYahAEQQNHDQALIARBEGoLIQUgAyAFIARBGGoQEToAACABIAJqIABrIQIMAgsgAyAEQRBqIARBGGoQEToAAiADIARBCGogBEEYahAROgADIANBBGohAwwAAAsACyAEQTBqJAAgAgtpAQF/An8CQAJAIAJBB00NACABKAAAQbfIwuF+Rw0AIAAgASgABDYCmOIBQWIgAEEQaiABIAIQPiIDEAMNAhogAEKBgICAEDcDiOEBIAAgASADaiACIANrECoMAQsgACABIAIQKgtBAAsLrQMBBn8jAEGAAWsiAyQAQWIhCAJAIAJBCUkNACAAQZjQAGogAUEIaiIEIAJBeGogAEGY0AAQMyIFEAMiBg0AIANBHzYCfCADIANB/ABqIANB+ABqIAQgBCAFaiAGGyIEIAEgAmoiAiAEaxAVIgUQAw0AIAMoAnwiBkEfSw0AIAMoAngiB0EJTw0AIABBiCBqIAMgBkGAC0GADCAHEBggA0E0NgJ8IAMgA0H8AGogA0H4AGogBCAFaiIEIAIgBGsQFSIFEAMNACADKAJ8IgZBNEsNACADKAJ4IgdBCk8NACAAQZAwaiADIAZBgA1B4A4gBxAYIANBIzYCfCADIANB/ABqIANB+ABqIAQgBWoiBCACIARrEBUiBRADDQAgAygCfCIGQSNLDQAgAygCeCIHQQpPDQAgACADIAZBwBBB0BEgBxAYIAQgBWoiBEEMaiIFIAJLDQAgAiAFayEFQQAhAgNAIAJBA0cEQCAEKAAAIgZBf2ogBU8NAiAAIAJBAnRqQZzQAWogBjYCACACQQFqIQIgBEEEaiEEDAELCyAEIAFrIQgLIANBgAFqJAAgCAtGAQN/IABBCGohAyAAKAIEIQJBACEAA0AgACACdkUEQCABIAMgAEEDdGotAAJBFktqIQEgAEEBaiEADAELCyABQQggAmt0C4YDAQV/Qbh/IQcCQCADRQ0AIAItAAAiBEUEQCABQQA2AgBBAUG4fyADQQFGGw8LAn8gAkEBaiIFIARBGHRBGHUiBkF/Sg0AGiAGQX9GBEAgA0EDSA0CIAUvAABBgP4BaiEEIAJBA2oMAQsgA0ECSA0BIAItAAEgBEEIdHJBgIB+aiEEIAJBAmoLIQUgASAENgIAIAVBAWoiASACIANqIgNLDQBBbCEHIABBEGogACAFLQAAIgVBBnZBI0EJIAEgAyABa0HAEEHQEUHwEiAAKAKM4QEgACgCnOIBIAQQHyIGEAMiCA0AIABBmCBqIABBCGogBUEEdkEDcUEfQQggASABIAZqIAgbIgEgAyABa0GAC0GADEGAFyAAKAKM4QEgACgCnOIBIAQQHyIGEAMiCA0AIABBoDBqIABBBGogBUECdkEDcUE0QQkgASABIAZqIAgbIgEgAyABa0GADUHgDkGQGSAAKAKM4QEgACgCnOIBIAQQHyIAEAMNACAAIAFqIAJrIQcLIAcLrQMBCn8jAEGABGsiCCQAAn9BUiACQf8BSw0AGkFUIANBDEsNABogAkEBaiELIABBBGohCUGAgAQgA0F/anRBEHUhCkEAIQJBASEEQQEgA3QiB0F/aiIMIQUDQCACIAtGRQRAAkAgASACQQF0Ig1qLwEAIgZB//8DRgRAIAkgBUECdGogAjoAAiAFQX9qIQVBASEGDAELIARBACAKIAZBEHRBEHVKGyEECyAIIA1qIAY7AQAgAkEBaiECDAELCyAAIAQ7AQIgACADOwEAIAdBA3YgB0EBdmpBA2ohBkEAIQRBACECA0AgBCALRkUEQCABIARBAXRqLgEAIQpBACEAA0AgACAKTkUEQCAJIAJBAnRqIAQ6AAIDQCACIAZqIAxxIgIgBUsNAAsgAEEBaiEADAELCyAEQQFqIQQMAQsLQX8gAg0AGkEAIQIDfyACIAdGBH9BAAUgCCAJIAJBAnRqIgAtAAJBAXRqIgEgAS8BACIBQQFqOwEAIAAgAyABEBRrIgU6AAMgACABIAVB/wFxdCAHazsBACACQQFqIQIMAQsLCyEFIAhBgARqJAAgBQvjBgEIf0FsIQcCQCACQQNJDQACQAJAAkACQCABLQAAIgNBA3EiCUEBaw4DAwEAAgsgACgCiOEBDQBBYg8LIAJBBUkNAkEDIQYgASgAACEFAn8CQAJAIANBAnZBA3EiCEF+aiIEQQFNBEAgBEEBaw0BDAILIAVBDnZB/wdxIQQgBUEEdkH/B3EhAyAIRQwCCyAFQRJ2IQRBBCEGIAVBBHZB//8AcSEDQQAMAQsgBUEEdkH//w9xIgNBgIAISw0DIAEtAARBCnQgBUEWdnIhBEEFIQZBAAshBSAEIAZqIgogAksNAgJAIANBgQZJDQAgACgCnOIBRQ0AQQAhAgNAIAJBg4ABSw0BIAJBQGshAgwAAAsACwJ/IAlBA0YEQCABIAZqIQEgAEHw4gFqIQIgACgCDCEGIAUEQCACIAMgASAEIAYQXwwCCyACIAMgASAEIAYQXQwBCyAAQbjQAWohAiABIAZqIQEgAEHw4gFqIQYgAEGo0ABqIQggBQRAIAggBiADIAEgBCACEF4MAQsgCCAGIAMgASAEIAIQXAsQAw0CIAAgAzYCgOIBIABBATYCiOEBIAAgAEHw4gFqNgLw4QEgCUECRgRAIAAgAEGo0ABqNgIMCyAAIANqIgBBiOMBakIANwAAIABBgOMBakIANwAAIABB+OIBakIANwAAIABB8OIBakIANwAAIAoPCwJ/AkACQAJAIANBAnZBA3FBf2oiBEECSw0AIARBAWsOAgACAQtBASEEIANBA3YMAgtBAiEEIAEvAABBBHYMAQtBAyEEIAEQIUEEdgsiAyAEaiIFQSBqIAJLBEAgBSACSw0CIABB8OIBaiABIARqIAMQCyEBIAAgAzYCgOIBIAAgATYC8OEBIAEgA2oiAEIANwAYIABCADcAECAAQgA3AAggAEIANwAAIAUPCyAAIAM2AoDiASAAIAEgBGo2AvDhASAFDwsCfwJAAkACQCADQQJ2QQNxQX9qIgRBAksNACAEQQFrDgIAAgELQQEhByADQQN2DAILQQIhByABLwAAQQR2DAELIAJBBEkgARAhIgJBj4CAAUtyDQFBAyEHIAJBBHYLIQIgAEHw4gFqIAEgB2otAAAgAkEgahAQIQEgACACNgKA4gEgACABNgLw4QEgB0EBaiEHCyAHC0sAIABC+erQ0OfJoeThADcDICAAQgA3AxggAELP1tO+0ser2UI3AxAgAELW64Lu6v2J9eAANwMIIABCADcDACAAQShqQQBBKBAQGgviAgICfwV+IABBKGoiASAAKAJIaiECAn4gACkDACIDQiBaBEAgACkDECIEQgeJIAApAwgiBUIBiXwgACkDGCIGQgyJfCAAKQMgIgdCEol8IAUQGSAEEBkgBhAZIAcQGQwBCyAAKQMYQsXP2bLx5brqJ3wLIAN8IQMDQCABQQhqIgAgAk0EQEIAIAEpAAAQCSADhUIbiUKHla+vmLbem55/fkLj3MqV/M7y9YV/fCEDIAAhAQwBCwsCQCABQQRqIgAgAksEQCABIQAMAQsgASgAAK1Ch5Wvr5i23puef34gA4VCF4lCz9bTvtLHq9lCfkL5893xmfaZqxZ8IQMLA0AgACACSQRAIAAxAABCxc/ZsvHluuonfiADhUILiUKHla+vmLbem55/fiEDIABBAWohAAwBCwsgA0IhiCADhULP1tO+0ser2UJ+IgNCHYggA4VC+fPd8Zn2masWfiIDQiCIIAOFC+8CAgJ/BH4gACAAKQMAIAKtfDcDAAJAAkAgACgCSCIDIAJqIgRBH00EQCABRQ0BIAAgA2pBKGogASACECAgACgCSCACaiEEDAELIAEgAmohAgJ/IAMEQCAAQShqIgQgA2ogAUEgIANrECAgACAAKQMIIAQpAAAQCTcDCCAAIAApAxAgACkAMBAJNwMQIAAgACkDGCAAKQA4EAk3AxggACAAKQMgIABBQGspAAAQCTcDICAAKAJIIQMgAEEANgJIIAEgA2tBIGohAQsgAUEgaiACTQsEQCACQWBqIQMgACkDICEFIAApAxghBiAAKQMQIQcgACkDCCEIA0AgCCABKQAAEAkhCCAHIAEpAAgQCSEHIAYgASkAEBAJIQYgBSABKQAYEAkhBSABQSBqIgEgA00NAAsgACAFNwMgIAAgBjcDGCAAIAc3AxAgACAINwMICyABIAJPDQEgAEEoaiABIAIgAWsiBBAgCyAAIAQ2AkgLCy8BAX8gAEUEQEG2f0EAIAMbDwtBun8hBCADIAFNBH8gACACIAMQEBogAwVBun8LCy8BAX8gAEUEQEG2f0EAIAMbDwtBun8hBCADIAFNBH8gACACIAMQCxogAwVBun8LC6gCAQZ/IwBBEGsiByQAIABB2OABaikDAEKAgIAQViEIQbh/IQUCQCAEQf//B0sNACAAIAMgBBBCIgUQAyIGDQAgACgCnOIBIQkgACAHQQxqIAMgAyAFaiAGGyIKIARBACAFIAYbayIGEEAiAxADBEAgAyEFDAELIAcoAgwhBCABRQRAQbp/IQUgBEEASg0BCyAGIANrIQUgAyAKaiEDAkAgCQRAIABBADYCnOIBDAELAkACQAJAIARBBUgNACAAQdjgAWopAwBCgICACFgNAAwBCyAAQQA2ApziAQwBCyAAKAIIED8hBiAAQQA2ApziASAGQRRPDQELIAAgASACIAMgBSAEIAgQOSEFDAELIAAgASACIAMgBSAEIAgQOiEFCyAHQRBqJAAgBQtnACAAQdDgAWogASACIAAoAuzhARAuIgEQAwRAIAEPC0G4fyECAkAgAQ0AIABB7OABaigCACIBBEBBYCECIAAoApjiASABRw0BC0EAIQIgAEHw4AFqKAIARQ0AIABBkOEBahBDCyACCycBAX8QVyIERQRAQUAPCyAEIAAgASACIAMgBBBLEE8hACAEEFYgAAs/AQF/AkACQAJAIAAoAqDiAUEBaiIBQQJLDQAgAUEBaw4CAAECCyAAEDBBAA8LIABBADYCoOIBCyAAKAKU4gELvAMCB38BfiMAQRBrIgkkAEG4fyEGAkAgBCgCACIIQQVBCSAAKALs4QEiBRtJDQAgAygCACIHQQFBBSAFGyAFEC8iBRADBEAgBSEGDAELIAggBUEDakkNACAAIAcgBRBJIgYQAw0AIAEgAmohCiAAQZDhAWohCyAIIAVrIQIgBSAHaiEHIAEhBQNAIAcgAiAJECwiBhADDQEgAkF9aiICIAZJBEBBuH8hBgwCCyAJKAIAIghBAksEQEFsIQYMAgsgB0EDaiEHAn8CQAJAAkAgCEEBaw4CAgABCyAAIAUgCiAFayAHIAYQSAwCCyAFIAogBWsgByAGEEcMAQsgBSAKIAVrIActAAAgCSgCCBBGCyIIEAMEQCAIIQYMAgsgACgC8OABBEAgCyAFIAgQRQsgAiAGayECIAYgB2ohByAFIAhqIQUgCSgCBEUNAAsgACkD0OABIgxCf1IEQEFsIQYgDCAFIAFrrFINAQsgACgC8OABBEBBaiEGIAJBBEkNASALEEQhDCAHKAAAIAynRw0BIAdBBGohByACQXxqIQILIAMgBzYCACAEIAI2AgAgBSABayEGCyAJQRBqJAAgBgsuACAAECsCf0EAQQAQAw0AGiABRSACRXJFBEBBYiAAIAEgAhA9EAMNARoLQQALCzcAIAEEQCAAIAAoAsTgASABKAIEIAEoAghqRzYCnOIBCyAAECtBABADIAFFckUEQCAAIAEQWwsL0QIBB38jAEEQayIGJAAgBiAENgIIIAYgAzYCDCAFBEAgBSgCBCEKIAUoAgghCQsgASEIAkACQANAIAAoAuzhARAWIQsCQANAIAQgC0kNASADKAAAQXBxQdDUtMIBRgRAIAMgBBAiIgcQAw0EIAQgB2shBCADIAdqIQMMAQsLIAYgAzYCDCAGIAQ2AggCQCAFBEAgACAFEE5BACEHQQAQA0UNAQwFCyAAIAogCRBNIgcQAw0ECyAAIAgQUCAMQQFHQQAgACAIIAIgBkEMaiAGQQhqEEwiByIDa0EAIAMQAxtBCkdyRQRAQbh/IQcMBAsgBxADDQMgAiAHayECIAcgCGohCEEBIQwgBigCDCEDIAYoAgghBAwBCwsgBiADNgIMIAYgBDYCCEG4fyEHIAQNASAIIAFrIQcMAQsgBiADNgIMIAYgBDYCCAsgBkEQaiQAIAcLRgECfyABIAAoArjgASICRwRAIAAgAjYCxOABIAAgATYCuOABIAAoArzgASEDIAAgATYCvOABIAAgASADIAJrajYCwOABCwutAgIEfwF+IwBBQGoiBCQAAkACQCACQQhJDQAgASgAAEFwcUHQ1LTCAUcNACABIAIQIiEBIABCADcDCCAAQQA2AgQgACABNgIADAELIARBGGogASACEC0iAxADBEAgACADEBoMAQsgAwRAIABBuH8QGgwBCyACIAQoAjAiA2shAiABIANqIQMDQAJAIAAgAyACIARBCGoQLCIFEAMEfyAFBSACIAVBA2oiBU8NAUG4fwsQGgwCCyAGQQFqIQYgAiAFayECIAMgBWohAyAEKAIMRQ0ACyAEKAI4BEAgAkEDTQRAIABBuH8QGgwCCyADQQRqIQMLIAQoAighAiAEKQMYIQcgAEEANgIEIAAgAyABazYCACAAIAIgBmytIAcgB0J/URs3AwgLIARBQGskAAslAQF/IwBBEGsiAiQAIAIgACABEFEgAigCACEAIAJBEGokACAAC30BBH8jAEGQBGsiBCQAIARB/wE2AggCQCAEQRBqIARBCGogBEEMaiABIAIQFSIGEAMEQCAGIQUMAQtBVCEFIAQoAgwiB0EGSw0AIAMgBEEQaiAEKAIIIAcQQSIFEAMNACAAIAEgBmogAiAGayADEDwhBQsgBEGQBGokACAFC4cBAgJ/An5BABAWIQMCQANAIAEgA08EQAJAIAAoAABBcHFB0NS0wgFGBEAgACABECIiAhADRQ0BQn4PCyAAIAEQVSIEQn1WDQMgBCAFfCIFIARUIQJCfiEEIAINAyAAIAEQUiICEAMNAwsgASACayEBIAAgAmohAAwBCwtCfiAFIAEbIQQLIAQLPwIBfwF+IwBBMGsiAiQAAn5CfiACQQhqIAAgARAtDQAaQgAgAigCHEEBRg0AGiACKQMICyEDIAJBMGokACADC40BAQJ/IwBBMGsiASQAAkAgAEUNACAAKAKI4gENACABIABB/OEBaigCADYCKCABIAApAvThATcDICAAEDAgACgCqOIBIQIgASABKAIoNgIYIAEgASkDIDcDECACIAFBEGoQGyAAQQA2AqjiASABIAEoAig2AgggASABKQMgNwMAIAAgARAbCyABQTBqJAALKgECfyMAQRBrIgAkACAAQQA2AgggAEIANwMAIAAQWCEBIABBEGokACABC4cBAQN/IwBBEGsiAiQAAkAgACgCAEUgACgCBEVzDQAgAiAAKAIINgIIIAIgACkCADcDAAJ/IAIoAgAiAQRAIAIoAghBqOMJIAERBQAMAQtBqOMJECgLIgFFDQAgASAAKQIANwL04QEgAUH84QFqIAAoAgg2AgAgARBZIAEhAwsgAkEQaiQAIAMLywEBAn8jAEEgayIBJAAgAEGBgIDAADYCtOIBIABBADYCiOIBIABBADYC7OEBIABCADcDkOIBIABBADYCpOMJIABBADYC3OIBIABCADcCzOIBIABBADYCvOIBIABBADYCxOABIABCADcCnOIBIABBpOIBakIANwIAIABBrOIBakEANgIAIAFCADcCECABQgA3AhggASABKQMYNwMIIAEgASkDEDcDACABKAIIQQh2QQFxIQIgAEEANgLg4gEgACACNgKM4gEgAUEgaiQAC3YBA38jAEEwayIBJAAgAARAIAEgAEHE0AFqIgIoAgA2AiggASAAKQK80AE3AyAgACgCACEDIAEgAigCADYCGCABIAApArzQATcDECADIAFBEGoQGyABIAEoAig2AgggASABKQMgNwMAIAAgARAbCyABQTBqJAALzAEBAX8gACABKAK00AE2ApjiASAAIAEoAgQiAjYCwOABIAAgAjYCvOABIAAgAiABKAIIaiICNgK44AEgACACNgLE4AEgASgCuNABBEAgAEKBgICAEDcDiOEBIAAgAUGk0ABqNgIMIAAgAUGUIGo2AgggACABQZwwajYCBCAAIAFBDGo2AgAgAEGs0AFqIAFBqNABaigCADYCACAAQbDQAWogAUGs0AFqKAIANgIAIABBtNABaiABQbDQAWooAgA2AgAPCyAAQgA3A4jhAQs7ACACRQRAQbp/DwsgBEUEQEFsDwsgAiAEEGAEQCAAIAEgAiADIAQgBRBhDwsgACABIAIgAyAEIAUQZQtGAQF/IwBBEGsiBSQAIAVBCGogBBAOAn8gBS0ACQRAIAAgASACIAMgBBAyDAELIAAgASACIAMgBBA0CyEAIAVBEGokACAACzQAIAAgAyAEIAUQNiIFEAMEQCAFDwsgBSAESQR/IAEgAiADIAVqIAQgBWsgABA1BUG4fwsLRgEBfyMAQRBrIgUkACAFQQhqIAQQDgJ/IAUtAAkEQCAAIAEgAiADIAQQYgwBCyAAIAEgAiADIAQQNQshACAFQRBqJAAgAAtZAQF/QQ8hAiABIABJBEAgAUEEdCAAbiECCyAAQQh2IgEgAkEYbCIAQYwIaigCAGwgAEGICGooAgBqIgJBA3YgAmogAEGACGooAgAgAEGECGooAgAgAWxqSQs3ACAAIAMgBCAFQYAQEDMiBRADBEAgBQ8LIAUgBEkEfyABIAIgAyAFaiAEIAVrIAAQMgVBuH8LC78DAQN/IwBBIGsiBSQAIAVBCGogAiADEAYiAhADRQRAIAAgAWoiB0F9aiEGIAUgBBAOIARBBGohAiAFLQACIQMDQEEAIAAgBkkgBUEIahAEGwRAIAAgAiAFQQhqIAMQAkECdGoiBC8BADsAACAFQQhqIAQtAAIQASAAIAQtAANqIgQgAiAFQQhqIAMQAkECdGoiAC8BADsAACAFQQhqIAAtAAIQASAEIAAtAANqIQAMAQUgB0F+aiEEA0AgBUEIahAEIAAgBEtyRQRAIAAgAiAFQQhqIAMQAkECdGoiBi8BADsAACAFQQhqIAYtAAIQASAAIAYtAANqIQAMAQsLA0AgACAES0UEQCAAIAIgBUEIaiADEAJBAnRqIgYvAQA7AAAgBUEIaiAGLQACEAEgACAGLQADaiEADAELCwJAIAAgB08NACAAIAIgBUEIaiADEAIiA0ECdGoiAC0AADoAACAALQADQQFGBEAgBUEIaiAALQACEAEMAQsgBSgCDEEfSw0AIAVBCGogAiADQQJ0ai0AAhABIAUoAgxBIUkNACAFQSA2AgwLIAFBbCAFQQhqEAobIQILCwsgBUEgaiQAIAILkgIBBH8jAEFAaiIJJAAgCSADQTQQCyEDAkAgBEECSA0AIAMgBEECdGooAgAhCSADQTxqIAgQIyADQQE6AD8gAyACOgA+QQAhBCADKAI8IQoDQCAEIAlGDQEgACAEQQJ0aiAKNgEAIARBAWohBAwAAAsAC0EAIQkDQCAGIAlGRQRAIAMgBSAJQQF0aiIKLQABIgtBAnRqIgwoAgAhBCADQTxqIAotAABBCHQgCGpB//8DcRAjIANBAjoAPyADIAcgC2siCiACajoAPiAEQQEgASAKa3RqIQogAygCPCELA0AgACAEQQJ0aiALNgEAIARBAWoiBCAKSQ0ACyAMIAo2AgAgCUEBaiEJDAELCyADQUBrJAALowIBCX8jAEHQAGsiCSQAIAlBEGogBUE0EAsaIAcgBmshDyAHIAFrIRADQAJAIAMgCkcEQEEBIAEgByACIApBAXRqIgYtAAEiDGsiCGsiC3QhDSAGLQAAIQ4gCUEQaiAMQQJ0aiIMKAIAIQYgCyAPTwRAIAAgBkECdGogCyAIIAUgCEE0bGogCCAQaiIIQQEgCEEBShsiCCACIAQgCEECdGooAgAiCEEBdGogAyAIayAHIA4QYyAGIA1qIQgMAgsgCUEMaiAOECMgCUEBOgAPIAkgCDoADiAGIA1qIQggCSgCDCELA0AgBiAITw0CIAAgBkECdGogCzYBACAGQQFqIQYMAAALAAsgCUHQAGokAA8LIAwgCDYCACAKQQFqIQoMAAALAAs0ACAAIAMgBCAFEDYiBRADBEAgBQ8LIAUgBEkEfyABIAIgAyAFaiAEIAVrIAAQNAVBuH8LCyMAIAA/AEEQdGtB//8DakEQdkAAQX9GBEBBAA8LQQAQAEEBCzsBAX8gAgRAA0AgACABIAJBgCAgAkGAIEkbIgMQCyEAIAFBgCBqIQEgAEGAIGohACACIANrIgINAAsLCwYAIAAQAwsLqBUJAEGICAsNAQAAAAEAAAACAAAAAgBBoAgLswYBAAAAAQAAAAIAAAACAAAAJgAAAIIAAAAhBQAASgAAAGcIAAAmAAAAwAEAAIAAAABJBQAASgAAAL4IAAApAAAALAIAAIAAAABJBQAASgAAAL4IAAAvAAAAygIAAIAAAACKBQAASgAAAIQJAAA1AAAAcwMAAIAAAACdBQAASgAAAKAJAAA9AAAAgQMAAIAAAADrBQAASwAAAD4KAABEAAAAngMAAIAAAABNBgAASwAAAKoKAABLAAAAswMAAIAAAADBBgAATQAAAB8NAABNAAAAUwQAAIAAAAAjCAAAUQAAAKYPAABUAAAAmQQAAIAAAABLCQAAVwAAALESAABYAAAA2gQAAIAAAABvCQAAXQAAACMUAABUAAAARQUAAIAAAABUCgAAagAAAIwUAABqAAAArwUAAIAAAAB2CQAAfAAAAE4QAAB8AAAA0gIAAIAAAABjBwAAkQAAAJAHAACSAAAAAAAAAAEAAAABAAAABQAAAA0AAAAdAAAAPQAAAH0AAAD9AAAA/QEAAP0DAAD9BwAA/Q8AAP0fAAD9PwAA/X8AAP3/AAD9/wEA/f8DAP3/BwD9/w8A/f8fAP3/PwD9/38A/f//AP3//wH9//8D/f//B/3//w/9//8f/f//P/3//38AAAAAAQAAAAIAAAADAAAABAAAAAUAAAAGAAAABwAAAAgAAAAJAAAACgAAAAsAAAAMAAAADQAAAA4AAAAPAAAAEAAAABEAAAASAAAAEwAAABQAAAAVAAAAFgAAABcAAAAYAAAAGQAAABoAAAAbAAAAHAAAAB0AAAAeAAAAHwAAAAMAAAAEAAAABQAAAAYAAAAHAAAACAAAAAkAAAAKAAAACwAAAAwAAAANAAAADgAAAA8AAAAQAAAAEQAAABIAAAATAAAAFAAAABUAAAAWAAAAFwAAABgAAAAZAAAAGgAAABsAAAAcAAAAHQAAAB4AAAAfAAAAIAAAACEAAAAiAAAAIwAAACUAAAAnAAAAKQAAACsAAAAvAAAAMwAAADsAAABDAAAAUwAAAGMAAACDAAAAAwEAAAMCAAADBAAAAwgAAAMQAAADIAAAA0AAAAOAAAADAAEAQeAPC1EBAAAAAQAAAAEAAAABAAAAAgAAAAIAAAADAAAAAwAAAAQAAAAEAAAABQAAAAcAAAAIAAAACQAAAAoAAAALAAAADAAAAA0AAAAOAAAADwAAABAAQcQQC4sBAQAAAAIAAAADAAAABAAAAAUAAAAGAAAABwAAAAgAAAAJAAAACgAAAAsAAAAMAAAADQAAAA4AAAAPAAAAEAAAABIAAAAUAAAAFgAAABgAAAAcAAAAIAAAACgAAAAwAAAAQAAAAIAAAAAAAQAAAAIAAAAEAAAACAAAABAAAAAgAAAAQAAAAIAAAAAAAQBBkBIL5gQBAAAAAQAAAAEAAAABAAAAAgAAAAIAAAADAAAAAwAAAAQAAAAGAAAABwAAAAgAAAAJAAAACgAAAAsAAAAMAAAADQAAAA4AAAAPAAAAEAAAAAEAAAAEAAAACAAAAAAAAAABAAEBBgAAAAAAAAQAAAAAEAAABAAAAAAgAAAFAQAAAAAAAAUDAAAAAAAABQQAAAAAAAAFBgAAAAAAAAUHAAAAAAAABQkAAAAAAAAFCgAAAAAAAAUMAAAAAAAABg4AAAAAAAEFEAAAAAAAAQUUAAAAAAABBRYAAAAAAAIFHAAAAAAAAwUgAAAAAAAEBTAAAAAgAAYFQAAAAAAABwWAAAAAAAAIBgABAAAAAAoGAAQAAAAADAYAEAAAIAAABAAAAAAAAAAEAQAAAAAAAAUCAAAAIAAABQQAAAAAAAAFBQAAACAAAAUHAAAAAAAABQgAAAAgAAAFCgAAAAAAAAULAAAAAAAABg0AAAAgAAEFEAAAAAAAAQUSAAAAIAABBRYAAAAAAAIFGAAAACAAAwUgAAAAAAADBSgAAAAAAAYEQAAAABAABgRAAAAAIAAHBYAAAAAAAAkGAAIAAAAACwYACAAAMAAABAAAAAAQAAAEAQAAACAAAAUCAAAAIAAABQMAAAAgAAAFBQAAACAAAAUGAAAAIAAABQgAAAAgAAAFCQAAACAAAAULAAAAIAAABQwAAAAAAAAGDwAAACAAAQUSAAAAIAABBRQAAAAgAAIFGAAAACAAAgUcAAAAIAADBSgAAAAgAAQFMAAAAAAAEAYAAAEAAAAPBgCAAAAAAA4GAEAAAAAADQYAIABBgBcLhwIBAAEBBQAAAAAAAAUAAAAAAAAGBD0AAAAAAAkF/QEAAAAADwX9fwAAAAAVBf3/HwAAAAMFBQAAAAAABwR9AAAAAAAMBf0PAAAAABIF/f8DAAAAFwX9/38AAAAFBR0AAAAAAAgE/QAAAAAADgX9PwAAAAAUBf3/DwAAAAIFAQAAABAABwR9AAAAAAALBf0HAAAAABEF/f8BAAAAFgX9/z8AAAAEBQ0AAAAQAAgE/QAAAAAADQX9HwAAAAATBf3/BwAAAAEFAQAAABAABgQ9AAAAAAAKBf0DAAAAABAF/f8AAAAAHAX9//8PAAAbBf3//wcAABoF/f//AwAAGQX9//8BAAAYBf3//wBBkBkLhgQBAAEBBgAAAAAAAAYDAAAAAAAABAQAAAAgAAAFBQAAAAAAAAUGAAAAAAAABQgAAAAAAAAFCQAAAAAAAAULAAAAAAAABg0AAAAAAAAGEAAAAAAAAAYTAAAAAAAABhYAAAAAAAAGGQAAAAAAAAYcAAAAAAAABh8AAAAAAAAGIgAAAAAAAQYlAAAAAAABBikAAAAAAAIGLwAAAAAAAwY7AAAAAAAEBlMAAAAAAAcGgwAAAAAACQYDAgAAEAAABAQAAAAAAAAEBQAAACAAAAUGAAAAAAAABQcAAAAgAAAFCQAAAAAAAAUKAAAAAAAABgwAAAAAAAAGDwAAAAAAAAYSAAAAAAAABhUAAAAAAAAGGAAAAAAAAAYbAAAAAAAABh4AAAAAAAAGIQAAAAAAAQYjAAAAAAABBicAAAAAAAIGKwAAAAAAAwYzAAAAAAAEBkMAAAAAAAUGYwAAAAAACAYDAQAAIAAABAQAAAAwAAAEBAAAABAAAAQFAAAAIAAABQcAAAAgAAAFCAAAACAAAAUKAAAAIAAABQsAAAAAAAAGDgAAAAAAAAYRAAAAAAAABhQAAAAAAAAGFwAAAAAAAAYaAAAAAAAABh0AAAAAAAAGIAAAAAAAEAYDAAEAAAAPBgOAAAAAAA4GA0AAAAAADQYDIAAAAAAMBgMQAAAAAAsGAwgAAAAACgYDBABBpB0L2QEBAAAAAwAAAAcAAAAPAAAAHwAAAD8AAAB/AAAA/wAAAP8BAAD/AwAA/wcAAP8PAAD/HwAA/z8AAP9/AAD//wAA//8BAP//AwD//wcA//8PAP//HwD//z8A//9/AP///wD///8B////A////wf///8P////H////z////9/AAAAAAEAAAACAAAABAAAAAAAAAACAAAABAAAAAgAAAAAAAAAAQAAAAIAAAABAAAABAAAAAQAAAAEAAAABAAAAAgAAAAIAAAACAAAAAcAAAAIAAAACQAAAAoAAAALAEGgIAsDwBBQ",DM=new WeakMap;let kM=0,OM,Eb=class r0 extends _d{constructor(e){super(e),this.transcoderPath="",this.transcoderBinary=null,this.transcoderPending=null,this.workerPool=new ioe,this.workerSourceURL="",this.workerConfig=null,typeof MSC_TRANSCODER<"u"&&console.warn('THREE.KTX2Loader: Please update to latest "basis_transcoder". "msc_basis_transcoder" is no longer supported in three.js r125+.')}setTranscoderPath(e){return this.transcoderPath=e,this}setWorkerLimit(e){return this.workerPool.setWorkerLimit(e),this}async detectSupportAsync(e){return this.workerConfig={astcSupported:await e.hasFeatureAsync("texture-compression-astc"),etc1Supported:await e.hasFeatureAsync("texture-compression-etc1"),etc2Supported:await e.hasFeatureAsync("texture-compression-etc2"),dxtSupported:await e.hasFeatureAsync("texture-compression-bc"),bptcSupported:await e.hasFeatureAsync("texture-compression-bptc"),pvrtcSupported:await e.hasFeatureAsync("texture-compression-pvrtc")},this}detectSupport(e){return e.isWebGPURenderer===!0?this.workerConfig={astcSupported:e.hasFeature("texture-compression-astc"),etc1Supported:e.hasFeature("texture-compression-etc1"),etc2Supported:e.hasFeature("texture-compression-etc2"),dxtSupported:e.hasFeature("texture-compression-bc"),bptcSupported:e.hasFeature("texture-compression-bptc"),pvrtcSupported:e.hasFeature("texture-compression-pvrtc")}:(this.workerConfig={astcSupported:e.extensions.has("WEBGL_compressed_texture_astc"),etc1Supported:e.extensions.has("WEBGL_compressed_texture_etc1"),etc2Supported:e.extensions.has("WEBGL_compressed_texture_etc"),dxtSupported:e.extensions.has("WEBGL_compressed_texture_s3tc"),bptcSupported:e.extensions.has("EXT_texture_compression_bptc"),pvrtcSupported:e.extensions.has("WEBGL_compressed_texture_pvrtc")||e.extensions.has("WEBKIT_WEBGL_compressed_texture_pvrtc")},e.capabilities.isWebGL2&&(this.workerConfig.etc1Supported=!1)),this}init(){if(!this.transcoderPending){const e=new Hf(this.manager);e.setPath(this.transcoderPath),e.setWithCredentials(this.withCredentials);const t=e.loadAsync("basis_transcoder.js"),i=new Hf(this.manager);i.setPath(this.transcoderPath),i.setResponseType("arraybuffer"),i.setWithCredentials(this.withCredentials);const n=i.loadAsync("basis_transcoder.wasm");this.transcoderPending=Promise.all([t,n]).then(([r,o])=>{const a=r0.BasisWorker.toString(),c=["/* constants */","let _EngineFormat = "+JSON.stringify(r0.EngineFormat),"let _TranscoderFormat = "+JSON.stringify(r0.TranscoderFormat),"let _BasisFormat = "+JSON.stringify(r0.BasisFormat),"/* basis_transcoder.js */",r,"/* worker */",a.substring(a.indexOf("{")+1,a.lastIndexOf("}"))].join(`
4418
- `);this.workerSourceURL=URL.createObjectURL(new Blob([c])),this.transcoderBinary=o,this.workerPool.setWorkerCreator(()=>{const l=new Worker(this.workerSourceURL),h=this.transcoderBinary.slice(0);return l.postMessage({type:"init",config:this.workerConfig,transcoderBinary:h},[h]),l})}),kM>0&&console.warn("THREE.KTX2Loader: Multiple active KTX2 loaders may cause performance issues. Use a single KTX2Loader instance, or call .dispose() on old instances."),kM++}return this.transcoderPending}load(e,t,i,n){if(this.workerConfig===null)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");const r=new Hf(this.manager);r.setResponseType("arraybuffer"),r.setWithCredentials(this.withCredentials),r.load(e,o=>{if(DM.has(o))return DM.get(o).promise.then(t).catch(n);this._createTexture(o).then(a=>t?t(a):null).catch(n)},i,n)}_createTextureFrom(e,t){const{faces:i,width:n,height:r,format:o,type:a,error:c,dfdFlags:l}=e;if(a==="error")return Promise.reject(c);let h;if(t.faceCount===6)h=new Gse(i,o,Ea);else{const u=i[0].mipmaps;h=t.layerCount>1?new zse(u,n,r,t.layerCount,o,Ea):new HE(u,n,r,o,Ea)}return h.minFilter=i[0].mipmaps.length===1?kv:QE,h.magFilter=kv,h.generateMipmaps=!1,h.needsUpdate=!0,h.colorSpace=cV(t),h.premultiplyAlpha=!!(l&soe),h}async _createTexture(e,t={}){const i=hoe(new Uint8Array(e));if(i.vkFormat!==coe)return foe(i);const n=t,r=this.init().then(()=>this.workerPool.postMessage({type:"transcode",buffer:e,taskConfig:n},[e])).then(o=>this._createTextureFrom(o.data,i));return DM.set(e,{promise:r}),r}dispose(){return this.workerPool.dispose(),this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),kM--,this}};Eb.BasisFormat={ETC1S:0,UASTC_4x4:1};Eb.TranscoderFormat={ETC1:0,ETC2:1,BC1:2,BC3:3,BC4:4,BC5:5,BC7_M6_OPAQUE_ONLY:6,BC7_M5:7,PVRTC1_4_RGB:8,PVRTC1_4_RGBA:9,ASTC_4x4:10,ATC_RGB:11,ATC_RGBA_INTERPOLATED_ALPHA:12,RGBA32:13,RGB565:14,BGR565:15,RGBA4444:16};Eb.EngineFormat={RGBAFormat:Hu,RGBA_ASTC_4x4_Format:Une,RGBA_BPTC_Format:Nne,RGBA_ETC2_EAC_Format:Fne,RGBA_PVRTC_4BPPV1_Format:kne,RGBA_S3TC_DXT5_Format:Pne,RGB_ETC1_Format:One,RGB_ETC2_Format:Lne,RGB_PVRTC_4BPPV1_Format:Dne,RGB_S3TC_DXT1_Format:Rne};Eb.BasisWorker=function(){let s,e,t;const i=_EngineFormat,n=_TranscoderFormat,r=_BasisFormat;self.addEventListener("message",function(g){const y=g.data;switch(y.type){case"init":s=y.config,o(y.transcoderBinary);break;case"transcode":e.then(()=>{try{const{faces:m,buffers:A,width:b,height:v,hasAlpha:_,format:w,dfdFlags:E}=a(y.buffer);self.postMessage({type:"transcode",id:y.id,faces:m,width:b,height:v,hasAlpha:_,format:w,dfdFlags:E},A)}catch(m){console.error(m),self.postMessage({type:"error",id:y.id,error:m.message})}});break}});function o(g){e=new Promise(y=>{t={wasmBinary:g,onRuntimeInitialized:y},BASIS(t)}).then(()=>{t.initializeBasis(),t.KTX2File===void 0&&console.warn("THREE.KTX2Loader: Please update Basis Universal transcoder.")})}function a(g){const y=new t.KTX2File(new Uint8Array(g));function m(){y.close(),y.delete()}if(!y.isValid())throw m(),new Error("THREE.KTX2Loader: Invalid or unsupported .ktx2 file");const A=y.isUASTC()?r.UASTC_4x4:r.ETC1S,b=y.getWidth(),v=y.getHeight(),_=y.getLayers()||1,w=y.getLevels(),E=y.getFaces(),I=y.getHasAlpha(),M=y.getDFDFlags(),{transcoderFormat:R,engineFormat:S}=u(A,b,v,I);if(!b||!v||!w)throw m(),new Error("THREE.KTX2Loader: Invalid texture");if(!y.startTranscoding())throw m(),new Error("THREE.KTX2Loader: .startTranscoding failed");const T=[],F=[];for(let U=0;U<E;U++){const k=[];for(let H=0;H<w;H++){const D=[];let L,N;for(let X=0;X<_;X++){const se=y.getImageLevelInfo(H,X,U);U===0&&H===0&&X===0&&(se.origWidth%4!==0||se.origHeight%4!==0)&&console.warn("THREE.KTX2Loader: ETC1S and UASTC textures should use multiple-of-four dimensions."),w>1?(L=se.origWidth,N=se.origHeight):(L=se.width,N=se.height);const ae=new Uint8Array(y.getImageTranscodedSizeInBytes(H,X,0,R));if(!y.transcodeImage(ae,H,X,U,R,0,-1,-1))throw m(),new Error("THREE.KTX2Loader: .transcodeImage failed.");D.push(ae)}const W=p(D);k.push({data:W,width:L,height:N}),F.push(W.buffer)}T.push({mipmaps:k,width:b,height:v,format:S})}return m(),{faces:T,buffers:F,width:b,height:v,hasAlpha:I,format:S,dfdFlags:M}}const c=[{if:"astcSupported",basisFormat:[r.UASTC_4x4],transcoderFormat:[n.ASTC_4x4,n.ASTC_4x4],engineFormat:[i.RGBA_ASTC_4x4_Format,i.RGBA_ASTC_4x4_Format],priorityETC1S:1/0,priorityUASTC:1,needsPowerOfTwo:!1},{if:"bptcSupported",basisFormat:[r.ETC1S,r.UASTC_4x4],transcoderFormat:[n.BC7_M5,n.BC7_M5],engineFormat:[i.RGBA_BPTC_Format,i.RGBA_BPTC_Format],priorityETC1S:3,priorityUASTC:2,needsPowerOfTwo:!1},{if:"dxtSupported",basisFormat:[r.ETC1S,r.UASTC_4x4],transcoderFormat:[n.BC1,n.BC3],engineFormat:[i.RGB_S3TC_DXT1_Format,i.RGBA_S3TC_DXT5_Format],priorityETC1S:4,priorityUASTC:5,needsPowerOfTwo:!1},{if:"etc2Supported",basisFormat:[r.ETC1S,r.UASTC_4x4],transcoderFormat:[n.ETC1,n.ETC2],engineFormat:[i.RGB_ETC2_Format,i.RGBA_ETC2_EAC_Format],priorityETC1S:1,priorityUASTC:3,needsPowerOfTwo:!1},{if:"etc1Supported",basisFormat:[r.ETC1S,r.UASTC_4x4],transcoderFormat:[n.ETC1],engineFormat:[i.RGB_ETC1_Format],priorityETC1S:2,priorityUASTC:4,needsPowerOfTwo:!1},{if:"pvrtcSupported",basisFormat:[r.ETC1S,r.UASTC_4x4],transcoderFormat:[n.PVRTC1_4_RGB,n.PVRTC1_4_RGBA],engineFormat:[i.RGB_PVRTC_4BPPV1_Format,i.RGBA_PVRTC_4BPPV1_Format],priorityETC1S:5,priorityUASTC:6,needsPowerOfTwo:!0}],l=c.sort(function(g,y){return g.priorityETC1S-y.priorityETC1S}),h=c.sort(function(g,y){return g.priorityUASTC-y.priorityUASTC});function u(g,y,m,A){let b,v;const _=g===r.ETC1S?l:h;for(let w=0;w<_.length;w++){const E=_[w];if(s[E.if]&&E.basisFormat.includes(g)&&!(A&&E.transcoderFormat.length<2)&&!(E.needsPowerOfTwo&&!(f(y)&&f(m))))return b=E.transcoderFormat[A?1:0],v=E.engineFormat[A?1:0],{transcoderFormat:b,engineFormat:v}}return console.warn("THREE.KTX2Loader: No suitable compressed texture format found. Decoding to RGBA32."),b=n.RGBA32,v=i.RGBAFormat,{transcoderFormat:b,engineFormat:v}}function f(g){return g<=2?!0:(g&g-1)===0&&g!==0}function p(g){if(g.length===1)return g[0];let y=0;for(let b=0;b<g.length;b++){const v=g[b];y+=v.byteLength}const m=new Uint8Array(y);let A=0;for(let b=0;b<g.length;b++){const v=g[b];m.set(v,A),A+=v.byteLength}return m}};const doe=new Set([Hu,s0,ym]),LM={[rV]:Hu,[iV]:Hu,[Z8]:Hu,[$8]:Hu,[sV]:s0,[tV]:s0,[J8]:s0,[K8]:s0,[nV]:ym,[eV]:ym,[Y8]:ym,[X8]:ym,[aV]:gU,[oV]:gU},FM={[rV]:Gf,[iV]:uC,[Z8]:Ea,[$8]:Ea,[sV]:Gf,[tV]:uC,[J8]:Ea,[K8]:Ea,[nV]:Gf,[eV]:uC,[Y8]:Ea,[X8]:Ea,[aV]:Ea,[oV]:Ea};async function foe(s){const{vkFormat:e}=s;if(LM[e]===void 0)throw new Error("THREE.KTX2Loader: Unsupported vkFormat.");let t;s.supercompressionScheme===fN&&(OM||(OM=new Promise(async r=>{const o=new uoe;await o.init(),r(o)})),t=await OM);const i=[];for(let r=0;r<s.levels.length;r++){const o=Math.max(1,s.pixelWidth>>r),a=Math.max(1,s.pixelHeight>>r),c=s.pixelDepth?Math.max(1,s.pixelDepth>>r):0,l=s.levels[r];let h;if(s.supercompressionScheme===noe)h=l.levelData;else if(s.supercompressionScheme===fN)h=t.decode(l.levelData,l.uncompressedByteLength);else throw new Error("THREE.KTX2Loader: Unsupported supercompressionScheme.");let u;FM[e]===Gf?u=new Float32Array(h.buffer,h.byteOffset,h.byteLength/Float32Array.BYTES_PER_ELEMENT):FM[e]===uC?u=new Uint16Array(h.buffer,h.byteOffset,h.byteLength/Uint16Array.BYTES_PER_ELEMENT):u=h,i.push({data:u,width:o,height:a,depth:c})}let n;if(doe.has(LM[e]))n=s.pixelDepth===0?new z2(i[0].data,s.pixelWidth,s.pixelHeight):new fse(i[0].data,s.pixelWidth,s.pixelHeight,s.pixelDepth);else{if(s.pixelDepth>0)throw new Error("THREE.KTX2Loader: Unsupported pixelDepth.");n=new HE(i,s.pixelWidth,s.pixelHeight)}return n.mipmaps=i,n.type=FM[e],n.format=LM[e],n.colorSpace=cV(s),n.needsUpdate=!0,Promise.resolve(n)}function cV(s){const e=s.dataFormatDescriptor[0];return e.colorPrimaries===ooe?e.transferFunction===pN?Er:Co:e.colorPrimaries===aoe?e.transferFunction===pN?k8:L2:(e.colorPrimaries===roe||console.warn(`THREE.KTX2Loader: Unsupported color primaries, "${e.colorPrimaries}"`),hS)}let uS="https://www.gstatic.com/draco/versioned/decoders/1.4.1/",X2="https://www.gstatic.com/basis-universal/versioned/2021-04-15-ba1c3e4/";fetch(uS+"draco_decoder.js",{method:"head"}).catch(s=>{uS="./include/draco/",X2="./include/ktx2/"});function poe(s){uS=s}function goe(s){X2=s}let o0,RR,a0;function moe(s){o0||(o0=new eoe,o0.setDecoderPath(uS),o0.setDecoderConfig({type:"js"})),a0||(a0=new Eb,a0.setTranscoderPath(X2)),RR||(RR=$re),s?a0.detectSupport(s):console.warn("No renderer provided to detect ktx2 support - loading KTX2 textures will probably fail")}function Aoe(s){s.dracoLoader||s.setDRACOLoader(o0),s.ktx2Loader||s.setKTX2Loader(a0),s.meshoptDecoder||s.setMeshoptDecoder(RR)}Ib("debugprogressive");function Ib(s){const t=new URL(window.location.href).searchParams.get(s);return t==null||t==="0"||t==="false"?!1:t===""?!0:t}function yoe(s,e){if(e===void 0||e.startsWith("./")||e.startsWith("http")||s===void 0)return e;const t=s.lastIndexOf("/");if(t>=0){const i=s.substring(0,t+1);for(;i.endsWith("/")&&e.startsWith("/");)e=e.substring(1);return i+e}return e}let Ty;function voe(){return Ty!==void 0||(Ty=/iPhone|iPad|iPod|Android|IEMobile/i.test(navigator.userAgent),Ib("debugprogressive")&&console.log("[glTF Progressive]: isMobileDevice",Ty)),Ty}const PR=Symbol("needle:raycast-mesh");function jE(s){return(s==null?void 0:s[PR])instanceof Sc?s[PR]:null}function boe(s,e){if((s.type==="Mesh"||s.type==="SkinnedMesh")&&!jE(s)){const i=_oe(e);i.userData={isRaycastMesh:!0},s[PR]=i}}function _oe(s){const e=new Sc;for(const t in s.attributes)e.setAttribute(t,s.getAttribute(t));return e.setIndex(s.getIndex()),e}const Pu=new Array,fh="NEEDLE_progressive",en=Ib("debugprogressive"),DR=Symbol("needle-progressive-texture"),G0=new Map,kR=new Set;if(en){let s=function(){e+=1,console.log("Toggle LOD level",e,G0),G0.forEach((n,r)=>{for(const o of n.keys){const a=r[o];if(a!=null){if(a.isBufferGeometry===!0){const c=mi.getMeshLODInformation(a),l=c?Math.min(e,c.lods.length):0;r["DEBUG:LOD"]=e,mi.assignMeshLOD(r,l),c&&(t=Math.max(t,c.lods.length-1))}else if(r.isMaterial===!0){r["DEBUG:LOD"]=e,mi.assignTextureLOD(r,e);break}}}}),e>=t&&(e=-1)},e=-1,t=2,i=!1;window.addEventListener("keyup",n=>{n.key==="p"&&s(),n.key==="w"&&(i=!i,kR&&kR.forEach(r=>{r.name!="BackgroundCubeMaterial"&&r.glyphMap==null&&"wireframe"in r&&(r.wireframe=i)}))})}function AN(s,e,t){var n;if(!en)return;G0.has(s)||G0.set(s,{keys:[],sourceId:t});const i=G0.get(s);((n=i==null?void 0:i.keys)==null?void 0:n.includes(e))==!1&&i.keys.push(e)}const Ps=class{constructor(s,e){this.loadMesh=t=>{var n,r;if(this._isLoadingMesh)return null;const i=(r=(n=this.parser.json.meshes[t])==null?void 0:n.extensions)==null?void 0:r[fh];return i?(this._isLoadingMesh=!0,this.parser.getDependency("mesh",t).then(o=>{var a;return this._isLoadingMesh=!1,o&&Ps.registerMesh(this.url,i.guid,o,(a=i.lods)==null?void 0:a.length,void 0,i),o})):null},en&&console.log("Progressive extension registered for",e),this.parser=s,this.url=e}get name(){return fh}static getMeshLODInformation(s){const e=this.getAssignedLODInformation(s);return e!=null&&e.key?this.lodInfos.get(e.key):null}static getMaterialMinMaxLODsCount(s,e){const t=this,i="LODS:minmax",n=s[i];if(n!=null)return n;if(e||(e={min_count:1/0,max_count:0,lods:[]}),Array.isArray(s)){for(const o of s)this.getMaterialMinMaxLODsCount(o,e);return s[i]=e,e}if(en==="verbose"&&console.log("getMaterialMinMaxLODsCount",s),s.type==="ShaderMaterial"||s.type==="RawShaderMaterial"){const o=s;for(const a of Object.keys(o.uniforms)){const c=o.uniforms[a].value;(c==null?void 0:c.isTexture)===!0&&r(c,e)}}else if(s.isMaterial)for(const o of Object.keys(s)){const a=s[o];(a==null?void 0:a.isTexture)===!0&&r(a,e)}return s[i]=e,e;function r(o,a){const c=t.getAssignedLODInformation(o);if(c){const l=t.lodInfos.get(c.key);if(l&&l.lods){a.min_count=Math.min(a.min_count,l.lods.length),a.max_count=Math.max(a.max_count,l.lods.length);for(let h=0;h<l.lods.length;h++){const u=l.lods[h];u.width&&(a.lods[h]=a.lods[h]||{min_height:1/0,max_height:0},a.lods[h].min_height=Math.min(a.lods[h].min_height,u.height),a.lods[h].max_height=Math.max(a.lods[h].max_height,u.height))}}}}}static hasLODLevelAvailable(s,e){var n;if(Array.isArray(s)){for(const r of s)if(this.hasLODLevelAvailable(r,e))return!0;return!1}if(s.isMaterial===!0){for(const r of Object.keys(s)){const o=s[r];if(o&&o.isTexture&&this.hasLODLevelAvailable(o,e))return!0}return!1}else if(s.isGroup===!0){for(const r of s.children)if(r.isMesh===!0&&this.hasLODLevelAvailable(r,e))return!0}let t,i;if(s.isMesh?t=s.geometry:(s.isBufferGeometry||s.isTexture)&&(t=s),t&&(n=t==null?void 0:t.userData)!=null&&n.LODS){const r=t.userData.LODS;if(i=this.lodInfos.get(r.key),e===void 0)return i!=null;if(i)return Array.isArray(i.lods)?e<i.lods.length:e===0}return!1}static assignMeshLOD(s,e){var t;if(!s)return Promise.resolve(null);if(s instanceof pp||s.isMesh===!0){const i=s.geometry,n=this.getAssignedLODInformation(i);if(!n)return Promise.resolve(null);for(const r of Pu)(t=r.onBeforeGetLODMesh)==null||t.call(r,s,e);return s["LOD:requested level"]=e,Ps.getOrLoadLOD(i,e).then(r=>{if(s["LOD:requested level"]===e){if(delete s["LOD:requested level"],Array.isArray(r)){const o=n.index||0;r=r[o]}r&&i!=r&&((r==null?void 0:r.isBufferGeometry)?(s.geometry=r,en&&AN(s,"geometry",n.url)):en&&console.error("Invalid LOD geometry",r))}return r}).catch(r=>(console.error("Error loading mesh LOD",s,r),null))}else en&&console.error("Invalid call to assignMeshLOD: Request mesh LOD but the object is not a mesh",s);return Promise.resolve(null)}static assignTextureLOD(s,e=0){if(!s)return Promise.resolve(null);if(s instanceof ed||s.isMaterial===!0){const t=s,i=[],n=new Array;if(en&&kR.add(t),t.uniforms&&t.isRawShaderMaterial||t.isShaderMaterial===!0){const r=t;for(const o of Object.keys(r.uniforms)){const a=r.uniforms[o].value;if((a==null?void 0:a.isTexture)===!0){const c=this.assignTextureLODForSlot(a,e,t,o);i.push(c),n.push(o)}}}else for(const r of Object.keys(t)){const o=t[r];if((o==null?void 0:o.isTexture)===!0){const a=this.assignTextureLODForSlot(o,e,t,r);i.push(a),n.push(r)}}return Promise.all(i).then(r=>{const o=new Array;for(let a=0;a<r.length;a++){const c=r[a],l=n[a];c&&c.isTexture===!0?o.push({material:t,slot:l,texture:c,level:e}):o.push({material:t,slot:l,texture:null,level:e})}return o})}if(s instanceof ms||s.isTexture===!0){const t=s;return this.assignTextureLODForSlot(t,e,null,null)}return Promise.resolve(null)}static assignTextureLODForSlot(s,e,t,i){return(s==null?void 0:s.isTexture)!==!0?Promise.resolve(null):i==="glyphMap"?Promise.resolve(s):Ps.getOrLoadLOD(s,e).then(n=>{if(Array.isArray(n))return null;if((n==null?void 0:n.isTexture)===!0){if(n!=s){if(t&&i){const r=t[i];if(r){const o=this.getAssignedLODInformation(r);if(o&&(o==null?void 0:o.level)<e)return en==="verbose"&&console.warn("Assigned texture level is already higher: ",o.level,e,t,r,n),null}t[i]=n}if(en&&i&&t){const r=this.getAssignedLODInformation(s);r&&AN(t,i,r.url)}}return n}else en=="verbose"&&console.warn("No LOD found for",s,e);return null}).catch(n=>(console.error("Error loading LOD",s,n),null))}afterRoot(s){var e,t;return en&&console.log("AFTER",this.url,s),(e=this.parser.json.textures)==null||e.forEach((i,n)=>{var r;if(i!=null&&i.extensions){const o=i==null?void 0:i.extensions[fh];if(o){if(!o.lods){en&&console.warn("Texture has no LODs",o);return}let a=!1;for(const c of this.parser.associations.keys())c.isTexture===!0&&this.parser.associations.get(c).textures===n&&(a=!0,Ps.registerTexture(this.url,c,(r=o.lods)==null?void 0:r.length,n,o));a||this.parser.getDependency("texture",n).then(c=>{var l;c&&Ps.registerTexture(this.url,c,(l=o.lods)==null?void 0:l.length,n,o)})}}}),(t=this.parser.json.meshes)==null||t.forEach((i,n)=>{if(i!=null&&i.extensions){const r=i==null?void 0:i.extensions[fh];if(r&&r.lods){for(const o of this.parser.associations.keys())if(o.isMesh){const a=this.parser.associations.get(o);a.meshes===n&&Ps.registerMesh(this.url,r.guid,o,r.lods.length,a.primitives,r)}}}}),null}static async getOrLoadLOD(s,e){var o,a,c,l;const t=en=="verbose",i=s.userData.LODS;if(!i)return null;const n=i==null?void 0:i.key;let r;if(s.isTexture===!0){const h=s;h.source&&h.source[DR]&&(r=h.source[DR])}if(r||(r=Ps.lodInfos.get(n)),r){if(e>0){let f=!1;const p=Array.isArray(r.lods);if(p&&e>=r.lods.length?f=!0:p||(f=!0),f)return this.lowresCache.get(n)}const h=Array.isArray(r.lods)?(o=r.lods[e])==null?void 0:o.path:r.lods;if(!h)return en&&!r["missing:uri"]&&(r["missing:uri"]=!0,console.warn("Missing uri for progressive asset for LOD "+e,r)),null;const u=yoe(i.url,h);if(u.endsWith(".glb")||u.endsWith(".gltf")){if(!r.guid)return console.warn("missing pointer for glb/gltf texture",r),null;const f=u+"_"+r.guid,p=this.previouslyLoaded.get(f);if(p!==void 0){t&&console.log(`LOD ${e} was already loading/loaded: ${f}`);let A=await p.catch(v=>(console.error(`Error loading LOD ${e} from ${u}
4418
+ `);this.workerSourceURL=URL.createObjectURL(new Blob([c])),this.transcoderBinary=o,this.workerPool.setWorkerCreator(()=>{const l=new Worker(this.workerSourceURL),h=this.transcoderBinary.slice(0);return l.postMessage({type:"init",config:this.workerConfig,transcoderBinary:h},[h]),l})}),kM>0&&console.warn("THREE.KTX2Loader: Multiple active KTX2 loaders may cause performance issues. Use a single KTX2Loader instance, or call .dispose() on old instances."),kM++}return this.transcoderPending}load(e,t,i,n){if(this.workerConfig===null)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");const r=new Hf(this.manager);r.setResponseType("arraybuffer"),r.setWithCredentials(this.withCredentials),r.load(e,o=>{if(DM.has(o))return DM.get(o).promise.then(t).catch(n);this._createTexture(o).then(a=>t?t(a):null).catch(n)},i,n)}_createTextureFrom(e,t){const{faces:i,width:n,height:r,format:o,type:a,error:c,dfdFlags:l}=e;if(a==="error")return Promise.reject(c);let h;if(t.faceCount===6)h=new Gse(i,o,Ea);else{const u=i[0].mipmaps;h=t.layerCount>1?new zse(u,n,r,t.layerCount,o,Ea):new HE(u,n,r,o,Ea)}return h.minFilter=i[0].mipmaps.length===1?kv:QE,h.magFilter=kv,h.generateMipmaps=!1,h.needsUpdate=!0,h.colorSpace=cV(t),h.premultiplyAlpha=!!(l&soe),h}async _createTexture(e,t={}){const i=hoe(new Uint8Array(e));if(i.vkFormat!==coe)return foe(i);const n=t,r=this.init().then(()=>this.workerPool.postMessage({type:"transcode",buffer:e,taskConfig:n},[e])).then(o=>this._createTextureFrom(o.data,i));return DM.set(e,{promise:r}),r}dispose(){return this.workerPool.dispose(),this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),kM--,this}};Eb.BasisFormat={ETC1S:0,UASTC_4x4:1};Eb.TranscoderFormat={ETC1:0,ETC2:1,BC1:2,BC3:3,BC4:4,BC5:5,BC7_M6_OPAQUE_ONLY:6,BC7_M5:7,PVRTC1_4_RGB:8,PVRTC1_4_RGBA:9,ASTC_4x4:10,ATC_RGB:11,ATC_RGBA_INTERPOLATED_ALPHA:12,RGBA32:13,RGB565:14,BGR565:15,RGBA4444:16};Eb.EngineFormat={RGBAFormat:Hu,RGBA_ASTC_4x4_Format:Une,RGBA_BPTC_Format:Nne,RGBA_ETC2_EAC_Format:Fne,RGBA_PVRTC_4BPPV1_Format:kne,RGBA_S3TC_DXT5_Format:Pne,RGB_ETC1_Format:One,RGB_ETC2_Format:Lne,RGB_PVRTC_4BPPV1_Format:Dne,RGB_S3TC_DXT1_Format:Rne};Eb.BasisWorker=function(){let s,e,t;const i=_EngineFormat,n=_TranscoderFormat,r=_BasisFormat;self.addEventListener("message",function(g){const y=g.data;switch(y.type){case"init":s=y.config,o(y.transcoderBinary);break;case"transcode":e.then(()=>{try{const{faces:m,buffers:A,width:b,height:v,hasAlpha:_,format:w,dfdFlags:E}=a(y.buffer);self.postMessage({type:"transcode",id:y.id,faces:m,width:b,height:v,hasAlpha:_,format:w,dfdFlags:E},A)}catch(m){console.error(m),self.postMessage({type:"error",id:y.id,error:m.message})}});break}});function o(g){e=new Promise(y=>{t={wasmBinary:g,onRuntimeInitialized:y},BASIS(t)}).then(()=>{t.initializeBasis(),t.KTX2File===void 0&&console.warn("THREE.KTX2Loader: Please update Basis Universal transcoder.")})}function a(g){const y=new t.KTX2File(new Uint8Array(g));function m(){y.close(),y.delete()}if(!y.isValid())throw m(),new Error("THREE.KTX2Loader: Invalid or unsupported .ktx2 file");const A=y.isUASTC()?r.UASTC_4x4:r.ETC1S,b=y.getWidth(),v=y.getHeight(),_=y.getLayers()||1,w=y.getLevels(),E=y.getFaces(),I=y.getHasAlpha(),M=y.getDFDFlags(),{transcoderFormat:R,engineFormat:S}=u(A,b,v,I);if(!b||!v||!w)throw m(),new Error("THREE.KTX2Loader: Invalid texture");if(!y.startTranscoding())throw m(),new Error("THREE.KTX2Loader: .startTranscoding failed");const T=[],F=[];for(let U=0;U<E;U++){const k=[];for(let H=0;H<w;H++){const D=[];let L,N;for(let X=0;X<_;X++){const se=y.getImageLevelInfo(H,X,U);U===0&&H===0&&X===0&&(se.origWidth%4!==0||se.origHeight%4!==0)&&console.warn("THREE.KTX2Loader: ETC1S and UASTC textures should use multiple-of-four dimensions."),w>1?(L=se.origWidth,N=se.origHeight):(L=se.width,N=se.height);const ae=new Uint8Array(y.getImageTranscodedSizeInBytes(H,X,0,R));if(!y.transcodeImage(ae,H,X,U,R,0,-1,-1))throw m(),new Error("THREE.KTX2Loader: .transcodeImage failed.");D.push(ae)}const W=p(D);k.push({data:W,width:L,height:N}),F.push(W.buffer)}T.push({mipmaps:k,width:b,height:v,format:S})}return m(),{faces:T,buffers:F,width:b,height:v,hasAlpha:I,format:S,dfdFlags:M}}const c=[{if:"astcSupported",basisFormat:[r.UASTC_4x4],transcoderFormat:[n.ASTC_4x4,n.ASTC_4x4],engineFormat:[i.RGBA_ASTC_4x4_Format,i.RGBA_ASTC_4x4_Format],priorityETC1S:1/0,priorityUASTC:1,needsPowerOfTwo:!1},{if:"bptcSupported",basisFormat:[r.ETC1S,r.UASTC_4x4],transcoderFormat:[n.BC7_M5,n.BC7_M5],engineFormat:[i.RGBA_BPTC_Format,i.RGBA_BPTC_Format],priorityETC1S:3,priorityUASTC:2,needsPowerOfTwo:!1},{if:"dxtSupported",basisFormat:[r.ETC1S,r.UASTC_4x4],transcoderFormat:[n.BC1,n.BC3],engineFormat:[i.RGB_S3TC_DXT1_Format,i.RGBA_S3TC_DXT5_Format],priorityETC1S:4,priorityUASTC:5,needsPowerOfTwo:!1},{if:"etc2Supported",basisFormat:[r.ETC1S,r.UASTC_4x4],transcoderFormat:[n.ETC1,n.ETC2],engineFormat:[i.RGB_ETC2_Format,i.RGBA_ETC2_EAC_Format],priorityETC1S:1,priorityUASTC:3,needsPowerOfTwo:!1},{if:"etc1Supported",basisFormat:[r.ETC1S,r.UASTC_4x4],transcoderFormat:[n.ETC1],engineFormat:[i.RGB_ETC1_Format],priorityETC1S:2,priorityUASTC:4,needsPowerOfTwo:!1},{if:"pvrtcSupported",basisFormat:[r.ETC1S,r.UASTC_4x4],transcoderFormat:[n.PVRTC1_4_RGB,n.PVRTC1_4_RGBA],engineFormat:[i.RGB_PVRTC_4BPPV1_Format,i.RGBA_PVRTC_4BPPV1_Format],priorityETC1S:5,priorityUASTC:6,needsPowerOfTwo:!0}],l=c.sort(function(g,y){return g.priorityETC1S-y.priorityETC1S}),h=c.sort(function(g,y){return g.priorityUASTC-y.priorityUASTC});function u(g,y,m,A){let b,v;const _=g===r.ETC1S?l:h;for(let w=0;w<_.length;w++){const E=_[w];if(s[E.if]&&E.basisFormat.includes(g)&&!(A&&E.transcoderFormat.length<2)&&!(E.needsPowerOfTwo&&!(f(y)&&f(m))))return b=E.transcoderFormat[A?1:0],v=E.engineFormat[A?1:0],{transcoderFormat:b,engineFormat:v}}return console.warn("THREE.KTX2Loader: No suitable compressed texture format found. Decoding to RGBA32."),b=n.RGBA32,v=i.RGBAFormat,{transcoderFormat:b,engineFormat:v}}function f(g){return g<=2?!0:(g&g-1)===0&&g!==0}function p(g){if(g.length===1)return g[0];let y=0;for(let b=0;b<g.length;b++){const v=g[b];y+=v.byteLength}const m=new Uint8Array(y);let A=0;for(let b=0;b<g.length;b++){const v=g[b];m.set(v,A),A+=v.byteLength}return m}};const doe=new Set([Hu,s0,ym]),LM={[rV]:Hu,[iV]:Hu,[Z8]:Hu,[$8]:Hu,[sV]:s0,[tV]:s0,[J8]:s0,[K8]:s0,[nV]:ym,[eV]:ym,[Y8]:ym,[X8]:ym,[aV]:gU,[oV]:gU},FM={[rV]:Gf,[iV]:uC,[Z8]:Ea,[$8]:Ea,[sV]:Gf,[tV]:uC,[J8]:Ea,[K8]:Ea,[nV]:Gf,[eV]:uC,[Y8]:Ea,[X8]:Ea,[aV]:Ea,[oV]:Ea};async function foe(s){const{vkFormat:e}=s;if(LM[e]===void 0)throw new Error("THREE.KTX2Loader: Unsupported vkFormat.");let t;s.supercompressionScheme===fN&&(OM||(OM=new Promise(async r=>{const o=new uoe;await o.init(),r(o)})),t=await OM);const i=[];for(let r=0;r<s.levels.length;r++){const o=Math.max(1,s.pixelWidth>>r),a=Math.max(1,s.pixelHeight>>r),c=s.pixelDepth?Math.max(1,s.pixelDepth>>r):0,l=s.levels[r];let h;if(s.supercompressionScheme===noe)h=l.levelData;else if(s.supercompressionScheme===fN)h=t.decode(l.levelData,l.uncompressedByteLength);else throw new Error("THREE.KTX2Loader: Unsupported supercompressionScheme.");let u;FM[e]===Gf?u=new Float32Array(h.buffer,h.byteOffset,h.byteLength/Float32Array.BYTES_PER_ELEMENT):FM[e]===uC?u=new Uint16Array(h.buffer,h.byteOffset,h.byteLength/Uint16Array.BYTES_PER_ELEMENT):u=h,i.push({data:u,width:o,height:a,depth:c})}let n;if(doe.has(LM[e]))n=s.pixelDepth===0?new z2(i[0].data,s.pixelWidth,s.pixelHeight):new fse(i[0].data,s.pixelWidth,s.pixelHeight,s.pixelDepth);else{if(s.pixelDepth>0)throw new Error("THREE.KTX2Loader: Unsupported pixelDepth.");n=new HE(i,s.pixelWidth,s.pixelHeight)}return n.mipmaps=i,n.type=FM[e],n.format=LM[e],n.colorSpace=cV(s),n.needsUpdate=!0,Promise.resolve(n)}function cV(s){const e=s.dataFormatDescriptor[0];return e.colorPrimaries===ooe?e.transferFunction===pN?Er:Co:e.colorPrimaries===aoe?e.transferFunction===pN?k8:L2:(e.colorPrimaries===roe||console.warn(`THREE.KTX2Loader: Unsupported color primaries, "${e.colorPrimaries}"`),hS)}let uS="https://www.gstatic.com/draco/versioned/decoders/1.4.1/",X2="https://www.gstatic.com/basis-universal/versioned/2021-04-15-ba1c3e4/";fetch(uS+"draco_decoder.js",{method:"head"}).catch(s=>{uS="./include/draco/",X2="./include/ktx2/"});function poe(s){uS=s}function goe(s){X2=s}let o0,RR,a0;function moe(s){o0||(o0=new eoe,o0.setDecoderPath(uS),o0.setDecoderConfig({type:"js"})),a0||(a0=new Eb,a0.setTranscoderPath(X2)),RR||(RR=$re),s?a0.detectSupport(s):console.warn("No renderer provided to detect ktx2 support - loading KTX2 textures will probably fail")}function Aoe(s){s.dracoLoader||s.setDRACOLoader(o0),s.ktx2Loader||s.setKTX2Loader(a0),s.meshoptDecoder||s.setMeshoptDecoder(RR)}Ib("debugprogressive");function Ib(s){const t=new URL(window.location.href).searchParams.get(s);return t==null||t==="0"||t==="false"?!1:t===""?!0:t}function yoe(s,e){if(e===void 0||e.startsWith("./")||e.startsWith("http")||s===void 0)return e;const t=s.lastIndexOf("/");if(t>=0){const i=s.substring(0,t+1);for(;i.endsWith("/")&&e.startsWith("/");)e=e.substring(1);return i+e}return e}let Ty;function voe(){return Ty!==void 0||(Ty=/iPhone|iPad|iPod|Android|IEMobile/i.test(navigator.userAgent),Ib("debugprogressive")&&console.log("[glTF Progressive]: isMobileDevice",Ty)),Ty}const PR=Symbol("needle:raycast-mesh");function jE(s){return(s==null?void 0:s[PR])instanceof Sc?s[PR]:null}function boe(s,e){if((s.type==="Mesh"||s.type==="SkinnedMesh")&&!jE(s)){const i=_oe(e);i.userData={isRaycastMesh:!0},s[PR]=i}}function _oe(s){const e=new Sc;for(const t in s.attributes)e.setAttribute(t,s.getAttribute(t));return e.setIndex(s.getIndex()),e}const Pu=new Array,fh="NEEDLE_progressive",en=Ib("debugprogressive"),DR=Symbol("needle-progressive-texture"),G0=new Map,kR=new Set;if(en){let s=function(){e+=1,console.log("Toggle LOD level",e,G0),G0.forEach((n,r)=>{for(const o of n.keys){const a=r[o];if(a!=null){if(a.isBufferGeometry===!0){const c=mi.getMeshLODInformation(a),l=c?Math.min(e,c.lods.length):0;r["DEBUG:LOD"]=e,mi.assignMeshLOD(r,l),c&&(t=Math.max(t,c.lods.length-1))}else if(r.isMaterial===!0){r["DEBUG:LOD"]=e,mi.assignTextureLOD(r,e);break}}}}),e>=t&&(e=-1)},e=-1,t=2,i=!1;window.addEventListener("keyup",n=>{n.key==="p"&&s(),n.key==="w"&&(i=!i,kR&&kR.forEach(r=>{r.name!="BackgroundCubeMaterial"&&r.glyphMap==null&&"wireframe"in r&&(r.wireframe=i)}))})}function AN(s,e,t){var n;if(!en)return;G0.has(s)||G0.set(s,{keys:[],sourceId:t});const i=G0.get(s);((n=i==null?void 0:i.keys)==null?void 0:n.includes(e))==!1&&i.keys.push(e)}const Ps=class{constructor(s,e){this.loadMesh=t=>{var n,r;if(this._isLoadingMesh)return null;const i=(r=(n=this.parser.json.meshes[t])==null?void 0:n.extensions)==null?void 0:r[fh];return i?(this._isLoadingMesh=!0,this.parser.getDependency("mesh",t).then(o=>{var a;return this._isLoadingMesh=!1,o&&Ps.registerMesh(this.url,i.guid,o,(a=i.lods)==null?void 0:a.length,void 0,i),o})):null},en&&console.log("Progressive extension registered for",e),this.parser=s,this.url=e}get name(){return fh}static getMeshLODInformation(s){const e=this.getAssignedLODInformation(s);return e!=null&&e.key?this.lodInfos.get(e.key):null}static getMaterialMinMaxLODsCount(s,e){const t=this,i="LODS:minmax",n=s[i];if(n!=null)return n;if(e||(e={min_count:1/0,max_count:0,lods:[]}),Array.isArray(s)){for(const o of s)this.getMaterialMinMaxLODsCount(o,e);return s[i]=e,e}if(en==="verbose"&&console.log("getMaterialMinMaxLODsCount",s),s.type==="ShaderMaterial"||s.type==="RawShaderMaterial"){const o=s;for(const a of Object.keys(o.uniforms)){const c=o.uniforms[a].value;(c==null?void 0:c.isTexture)===!0&&r(c,e)}}else if(s.isMaterial)for(const o of Object.keys(s)){const a=s[o];(a==null?void 0:a.isTexture)===!0&&r(a,e)}return s[i]=e,e;function r(o,a){const c=t.getAssignedLODInformation(o);if(c){const l=t.lodInfos.get(c.key);if(l&&l.lods){a.min_count=Math.min(a.min_count,l.lods.length),a.max_count=Math.max(a.max_count,l.lods.length);for(let h=0;h<l.lods.length;h++){const u=l.lods[h];u.width&&(a.lods[h]=a.lods[h]||{min_height:1/0,max_height:0},a.lods[h].min_height=Math.min(a.lods[h].min_height,u.height),a.lods[h].max_height=Math.max(a.lods[h].max_height,u.height))}}}}}static hasLODLevelAvailable(s,e){var n;if(Array.isArray(s)){for(const r of s)if(this.hasLODLevelAvailable(r,e))return!0;return!1}if(s.isMaterial===!0){for(const r of Object.keys(s)){const o=s[r];if(o&&o.isTexture&&this.hasLODLevelAvailable(o,e))return!0}return!1}else if(s.isGroup===!0){for(const r of s.children)if(r.isMesh===!0&&this.hasLODLevelAvailable(r,e))return!0}let t,i;if(s.isMesh?t=s.geometry:(s.isBufferGeometry||s.isTexture)&&(t=s),t&&(n=t==null?void 0:t.userData)!=null&&n.LODS){const r=t.userData.LODS;if(i=this.lodInfos.get(r.key),e===void 0)return i!=null;if(i)return Array.isArray(i.lods)?e<i.lods.length:e===0}return!1}static assignMeshLOD(s,e){var t;if(!s)return Promise.resolve(null);if(s instanceof pp||s.isMesh===!0){const i=s.geometry,n=this.getAssignedLODInformation(i);if(!n)return Promise.resolve(null);for(const r of Pu)(t=r.onBeforeGetLODMesh)==null||t.call(r,s,e);return s["LOD:requested level"]=e,Ps.getOrLoadLOD(i,e).then(r=>{if(s["LOD:requested level"]===e){if(delete s["LOD:requested level"],Array.isArray(r)){const o=n.index||0;r=r[o]}r&&i!=r&&((r==null?void 0:r.isBufferGeometry)?(s.geometry=r,en&&AN(s,"geometry",n.url)):en&&console.error("Invalid LOD geometry",r))}return r}).catch(r=>(console.error("Error loading mesh LOD",s,r),null))}else en&&console.error("Invalid call to assignMeshLOD: Request mesh LOD but the object is not a mesh",s);return Promise.resolve(null)}static assignTextureLOD(s,e=0){if(!s)return Promise.resolve(null);if(s instanceof ed||s.isMaterial===!0){const t=s,i=[],n=new Array;if(en&&kR.add(t),t.uniforms&&t.isRawShaderMaterial||t.isShaderMaterial===!0){const r=t;for(const o of Object.keys(r.uniforms)){const a=r.uniforms[o].value;if((a==null?void 0:a.isTexture)===!0){const c=this.assignTextureLODForSlot(a,e,t,o);i.push(c),n.push(o)}}}else for(const r of Object.keys(t)){const o=t[r];if((o==null?void 0:o.isTexture)===!0){const a=this.assignTextureLODForSlot(o,e,t,r);i.push(a),n.push(r)}}return Promise.all(i).then(r=>{const o=new Array;for(let a=0;a<r.length;a++){const c=r[a],l=n[a];c&&c.isTexture===!0?o.push({material:t,slot:l,texture:c,level:e}):o.push({material:t,slot:l,texture:null,level:e})}return o})}if(s instanceof ms||s.isTexture===!0){const t=s;return this.assignTextureLODForSlot(t,e,null,null)}return Promise.resolve(null)}static assignTextureLODForSlot(s,e,t,i){return(s==null?void 0:s.isTexture)!==!0?Promise.resolve(null):i==="glyphMap"?Promise.resolve(s):Ps.getOrLoadLOD(s,e).then(n=>{if(Array.isArray(n))return null;if((n==null?void 0:n.isTexture)===!0){if(n!=s){if(t&&i){const r=t[i];if(r){const o=this.getAssignedLODInformation(r);if(o&&(o==null?void 0:o.level)<e)return en==="verbose"&&console.warn("Assigned texture level is already higher: ",o.level,e,t,r,n),null}t[i]=n}if(en&&i&&t){const r=this.getAssignedLODInformation(s);r&&AN(t,i,r.url)}}return n}else en=="verbose"&&console.warn("No LOD found for",s,e);return null}).catch(n=>(console.error("Error loading LOD",s,n),null))}afterRoot(s){var e,t;return en&&console.log("AFTER",this.url,s),(e=this.parser.json.textures)==null||e.forEach((i,n)=>{var r;if(i!=null&&i.extensions){const o=i==null?void 0:i.extensions[fh];if(o){if(!o.lods){en&&console.warn("Texture has no LODs",o);return}let a=!1;for(const c of this.parser.associations.keys())if(c.isTexture===!0){const l=this.parser.associations.get(c);(l==null?void 0:l.textures)===n&&(a=!0,Ps.registerTexture(this.url,c,(r=o.lods)==null?void 0:r.length,n,o))}a||this.parser.getDependency("texture",n).then(c=>{var l;c&&Ps.registerTexture(this.url,c,(l=o.lods)==null?void 0:l.length,n,o)})}}}),(t=this.parser.json.meshes)==null||t.forEach((i,n)=>{if(i!=null&&i.extensions){const r=i==null?void 0:i.extensions[fh];if(r&&r.lods){for(const o of this.parser.associations.keys())if(o.isMesh){const a=this.parser.associations.get(o);(a==null?void 0:a.meshes)===n&&Ps.registerMesh(this.url,r.guid,o,r.lods.length,a.primitives,r)}}}}),null}static async getOrLoadLOD(s,e){var o,a,c,l;const t=en=="verbose",i=s.userData.LODS;if(!i)return null;const n=i==null?void 0:i.key;let r;if(s.isTexture===!0){const h=s;h.source&&h.source[DR]&&(r=h.source[DR])}if(r||(r=Ps.lodInfos.get(n)),r){if(e>0){let f=!1;const p=Array.isArray(r.lods);if(p&&e>=r.lods.length?f=!0:p||(f=!0),f)return this.lowresCache.get(n)}const h=Array.isArray(r.lods)?(o=r.lods[e])==null?void 0:o.path:r.lods;if(!h)return en&&!r["missing:uri"]&&(r["missing:uri"]=!0,console.warn("Missing uri for progressive asset for LOD "+e,r)),null;const u=yoe(i.url,h);if(u.endsWith(".glb")||u.endsWith(".gltf")){if(!r.guid)return console.warn("missing pointer for glb/gltf texture",r),null;const f=u+"_"+r.guid,p=this.previouslyLoaded.get(f);if(p!==void 0){t&&console.log(`LOD ${e} was already loading/loaded: ${f}`);let A=await p.catch(v=>(console.error(`Error loading LOD ${e} from ${u}
4419
4419
  `,v),null)),b=!1;if(A==null||(A instanceof ms&&s instanceof ms?(a=A.image)!=null&&a.data||(c=A.source)!=null&&c.data?A=this.copySettings(s,A):(b=!0,this.previouslyLoaded.delete(f)):A instanceof Sc&&s instanceof Sc&&((l=A.attributes.position)!=null&&l.array||(b=!0,this.previouslyLoaded.delete(f)))),!b)return A}const g=r,y=new Promise(async(A,b)=>{const v=new vre;Aoe(v),en&&(await new Promise(M=>setTimeout(M,1e3)),t&&console.warn("Start loading (delayed) "+u,g.guid));let _=u;if(g&&Array.isArray(g.lods)){const M=g.lods[e];M.hash&&(_+="?v="+M.hash)}const w=await v.loadAsync(_).catch(M=>(console.error(`Error loading LOD ${e} from ${u}
4420
4420
  `,M),null));if(!w)return null;const E=w.parser;t&&console.log("Loading finished "+u,g.guid);let I=0;if(w.parser.json.textures){let M=!1;for(const R of w.parser.json.textures){if(R!=null&&R.extensions){const S=R==null?void 0:R.extensions[fh];if(S!=null&&S.guid&&S.guid===g.guid){M=!0;break}}I++}if(M){let R=await E.getDependency("texture",I);return R&&Ps.assignLODInformation(i.url,R,n,e,void 0,void 0),t&&console.log('change "'+s.name+'" → "'+R.name+'"',u,I,R,f),s instanceof ms&&(R=this.copySettings(s,R)),R&&(R.guid=g.guid),A(R)}else en&&console.warn("Could not find texture with guid",g.guid,w.parser.json)}if(I=0,w.parser.json.meshes){let M=!1;for(const R of w.parser.json.meshes){if(R!=null&&R.extensions){const S=R==null?void 0:R.extensions[fh];if(S!=null&&S.guid&&S.guid===g.guid){M=!0;break}}I++}if(M){const R=await E.getDependency("mesh",I),S=g;if(t&&console.log(`Loaded Mesh "${R.name}"`,u,I,R,f),R.isMesh===!0){const T=R.geometry;return Ps.assignLODInformation(i.url,T,n,e,void 0,S.density),A(T)}else{const T=new Array;for(let F=0;F<R.children.length;F++){const U=R.children[F];if(U.isMesh===!0){const k=U.geometry;Ps.assignLODInformation(i.url,k,n,e,F,S.density),T.push(k)}}return A(T)}}else en&&console.warn("Could not find mesh with guid",g.guid,w.parser.json)}return A(null)});return this.previouslyLoaded.set(f,y),await y}else if(s instanceof ms){t&&console.log("Load texture from uri: "+u);const p=await new j8().loadAsync(u);return p?(p.guid=r.guid,p.flipY=!1,p.needsUpdate=!0,p.colorSpace=s.colorSpace,t&&console.log(r,p)):en&&console.warn("failed loading",u),p}}else en&&console.warn(`Can not load LOD ${e}: no LOD info found for "${n}" ${s.name}`,s.type);return null}static assignLODInformation(s,e,t,i,n,r){if(!e)return;e.userData||(e.userData={});const o=new xoe(s,t,i,n,r);e.userData.LODS=o}static getAssignedLODInformation(s){var e;return((e=s==null?void 0:s.userData)==null?void 0:e.LODS)||null}static copySettings(s,e){return e=e.clone(),en&&console.warn(`Copying texture settings
4421
4421
  `,s.uuid,`
@@ -5232,7 +5232,7 @@ a=extmap-allow-mixed`)!==-1){const r=n.sdp.split(`
5232
5232
  isWebRTCSupported:`).concat(this.isWebRTCSupported(),`
5233
5233
  isBrowserSupported:`).concat(this.isBrowserSupported(),`
5234
5234
  isUnifiedPlanSupported:`).concat(this.isUnifiedPlanSupported())},s}()),z3={iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:["turn:eu-0.turn.peerjs.com:3478","turn:us-0.turn.peerjs.com:3478"],username:"peerjs",credential:"peerjsp"}],sdpSemantics:"unified-plan"},sde=function(){function s(){this.CLOUD_HOST="0.peerjs.com",this.CLOUD_PORT=443,this.chunkedBrowsers={Chrome:1,chrome:1},this.chunkedMTU=16300,this.defaultConfig=z3,this.browser=Uy.getBrowser(),this.browserVersion=Uy.getVersion(),this.supports=function(){var e={browser:Uy.isBrowserSupported(),webRTC:Uy.isWebRTCSupported(),audioVideo:!1,data:!1,binaryBlob:!1,reliable:!1};if(!e.webRTC)return e;var t;try{t=new RTCPeerConnection(z3),e.audioVideo=!0;var i=void 0;try{i=t.createDataChannel("_PEERJSTEST",{ordered:!0}),e.data=!0,e.reliable=!!i.ordered;try{i.binaryType="blob",e.binaryBlob=!Uy.isIOS}catch{}}catch{}finally{i&&i.close()}}catch{}finally{t&&t.close()}return e}(),this.pack=B3.pack,this.unpack=B3.unpack,this._dataCount=1}return s.prototype.noop=function(){},s.prototype.validateId=function(e){return!e||/^[A-Za-z0-9]+(?:[ _-][A-Za-z0-9]+)*$/.test(e)},s.prototype.chunk=function(e){for(var t=[],i=e.size,n=Math.ceil(i/wi.chunkedMTU),r=0,o=0;o<i;){var a=Math.min(i,o+wi.chunkedMTU),c=e.slice(o,a),l={__peerData:this._dataCount,n:r,data:c,total:n};t.push(l),o=a,r++}return this._dataCount++,t},s.prototype.blobToArrayBuffer=function(e,t){var i=new FileReader;return i.onload=function(n){n.target&&t(n.target.result)},i.readAsArrayBuffer(e),i},s.prototype.binaryStringToArrayBuffer=function(e){for(var t=new Uint8Array(e.length),i=0;i<e.length;i++)t[i]=e.charCodeAt(i)&255;return t.buffer},s.prototype.randomToken=function(){return Math.random().toString(36).slice(2)},s.prototype.isSecure=function(){return location.protocol==="https:"},s}(),wi=new sde,T9={};Ml(T9,"Peer",()=>pP,s=>pP=s);var Pb={},rde=Object.prototype.hasOwnProperty,oo="~";function Gv(){}Object.create&&(Gv.prototype=Object.create(null),new Gv().__proto__||(oo=!1));function ode(s,e,t){this.fn=s,this.context=e,this.once=t||!1}function B9(s,e,t,i,n){if(typeof t!="function")throw new TypeError("The listener must be a function");var r=new ode(t,i||s,n),o=oo?oo+e:e;return s._events[o]?s._events[o].fn?s._events[o]=[s._events[o],r]:s._events[o].push(r):(s._events[o]=r,s._eventsCount++),s}function wC(s,e){--s._eventsCount===0?s._events=new Gv:delete s._events[e]}function Pr(){this._events=new Gv,this._eventsCount=0}Pr.prototype.eventNames=function(){var e=[],t,i;if(this._eventsCount===0)return e;for(i in t=this._events)rde.call(t,i)&&e.push(oo?i.slice(1):i);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e};Pr.prototype.listeners=function(e){var t=oo?oo+e:e,i=this._events[t];if(!i)return[];if(i.fn)return[i.fn];for(var n=0,r=i.length,o=new Array(r);n<r;n++)o[n]=i[n].fn;return o};Pr.prototype.listenerCount=function(e){var t=oo?oo+e:e,i=this._events[t];return i?i.fn?1:i.length:0};Pr.prototype.emit=function(e,t,i,n,r,o){var a=oo?oo+e:e;if(!this._events[a])return!1;var c=this._events[a],l=arguments.length,h,u;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,i),!0;case 4:return c.fn.call(c.context,t,i,n),!0;case 5:return c.fn.call(c.context,t,i,n,r),!0;case 6:return c.fn.call(c.context,t,i,n,r,o),!0}for(u=1,h=new Array(l-1);u<l;u++)h[u-1]=arguments[u];c.fn.apply(c.context,h)}else{var f=c.length,p;for(u=0;u<f;u++)switch(c[u].once&&this.removeListener(e,c[u].fn,void 0,!0),l){case 1:c[u].fn.call(c[u].context);break;case 2:c[u].fn.call(c[u].context,t);break;case 3:c[u].fn.call(c[u].context,t,i);break;case 4:c[u].fn.call(c[u].context,t,i,n);break;default:if(!h)for(p=1,h=new Array(l-1);p<l;p++)h[p-1]=arguments[p];c[u].fn.apply(c[u].context,h)}}return!0};Pr.prototype.on=function(e,t,i){return B9(this,e,t,i,!1)};Pr.prototype.once=function(e,t,i){return B9(this,e,t,i,!0)};Pr.prototype.removeListener=function(e,t,i,n){var r=oo?oo+e:e;if(!this._events[r])return this;if(!t)return wC(this,r),this;var o=this._events[r];if(o.fn)o.fn===t&&(!n||o.once)&&(!i||o.context===i)&&wC(this,r);else{for(var a=0,c=[],l=o.length;a<l;a++)(o[a].fn!==t||n&&!o[a].once||i&&o[a].context!==i)&&c.push(o[a]);c.length?this._events[r]=c.length===1?c[0]:c:wC(this,r)}return this};Pr.prototype.removeAllListeners=function(e){var t;return e?(t=oo?oo+e:e,this._events[t]&&wC(this,t)):(this._events=new Gv,this._eventsCount=0),this};Pr.prototype.off=Pr.prototype.removeListener;Pr.prototype.addListener=Pr.prototype.on;Pr.prefixed=oo;Pr.EventEmitter=Pr;Pb=Pr;var pt={};Ml(pt,"LogLevel",()=>po,s=>po=s);Ml(pt,"default",()=>G3,s=>G3=s);var sf=function(s,e){var t=typeof Symbol=="function"&&s[Symbol.iterator];if(!t)return s;var i=t.call(s),n,r=[],o;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)r.push(n.value)}catch(a){o={error:a}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(o)throw o.error}}return r},rf=function(s,e,t){if(t||arguments.length===2)for(var i=0,n=e.length,r;i<n;i++)(r||!(i in e))&&(r||(r=Array.prototype.slice.call(e,0,i)),r[i]=e[i]);return s.concat(r||Array.prototype.slice.call(e))},ade="PeerJS: ",po;(function(s){s[s.Disabled=0]="Disabled",s[s.Errors=1]="Errors",s[s.Warnings=2]="Warnings",s[s.All=3]="All"})(po||(po={}));var cde=function(){function s(){this._logLevel=po.Disabled}return Object.defineProperty(s.prototype,"logLevel",{get:function(){return this._logLevel},set:function(e){this._logLevel=e},enumerable:!1,configurable:!0}),s.prototype.log=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._logLevel>=po.All&&this._print.apply(this,rf([po.All],sf(e),!1))},s.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._logLevel>=po.Warnings&&this._print.apply(this,rf([po.Warnings],sf(e),!1))},s.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._logLevel>=po.Errors&&this._print.apply(this,rf([po.Errors],sf(e),!1))},s.prototype.setLogFunction=function(e){this._print=e},s.prototype._print=function(e){for(var t=[],i=1;i<arguments.length;i++)t[i-1]=arguments[i];var n=rf([ade],sf(t),!1);for(var r in n)n[r]instanceof Error&&(n[r]="("+n[r].name+") "+n[r].message);e>=po.All?console.log.apply(console,rf([],sf(n),!1)):e>=po.Warnings?console.warn.apply(console,rf(["WARNING"],sf(n),!1)):e>=po.Errors&&console.error.apply(console,rf(["ERROR"],sf(n),!1))},s}(),G3=new cde,R9={};Ml(R9,"Socket",()=>H3,s=>H3=s);var gc;(function(s){s.Data="data",s.Media="media"})(gc||(gc={}));var Hn;(function(s){s.BrowserIncompatible="browser-incompatible",s.Disconnected="disconnected",s.InvalidID="invalid-id",s.InvalidKey="invalid-key",s.Network="network",s.PeerUnavailable="peer-unavailable",s.SslUnavailable="ssl-unavailable",s.ServerError="server-error",s.SocketError="socket-error",s.SocketClosed="socket-closed",s.UnavailableID="unavailable-id",s.WebRTC="webrtc"})(Hn||(Hn={}));var lh;(function(s){s.Binary="binary",s.BinaryUTF8="binary-utf8",s.JSON="json"})(lh||(lh={}));var Eh;(function(s){s.Message="message",s.Disconnected="disconnected",s.Error="error",s.Close="close"})(Eh||(Eh={}));var $s;(function(s){s.Heartbeat="HEARTBEAT",s.Candidate="CANDIDATE",s.Offer="OFFER",s.Answer="ANSWER",s.Open="OPEN",s.Error="ERROR",s.IdTaken="ID-TAKEN",s.InvalidKey="INVALID-KEY",s.Leave="LEAVE",s.Expire="EXPIRE"})($s||($s={}));var Ck={};Ck=JSON.parse('{"name":"peerjs","version":"1.4.7","keywords":["peerjs","webrtc","p2p","rtc"],"description":"PeerJS client","homepage":"https://peerjs.com","bugs":{"url":"https://github.com/peers/peerjs/issues"},"repository":{"type":"git","url":"https://github.com/peers/peerjs"},"license":"MIT","contributors":["Michelle Bu <michelle@michellebu.com>","afrokick <devbyru@gmail.com>","ericz <really.ez@gmail.com>","Jairo <kidandcat@gmail.com>","Jonas Gloning <34194370+jonasgloning@users.noreply.github.com>","Jairo Caro-Accino Viciana <jairo@galax.be>","Carlos Caballero <carlos.caballero.gonzalez@gmail.com>","hc <hheennrryy@gmail.com>","Muhammad Asif <capripio@gmail.com>","PrashoonB <prashoonbhattacharjee@gmail.com>","Harsh Bardhan Mishra <47351025+HarshCasper@users.noreply.github.com>","akotynski <aleksanderkotbury@gmail.com>","lmb <i@lmb.io>","Jairooo <jairocaro@msn.com>","Moritz Stückler <moritz.stueckler@gmail.com>","Simon <crydotsnakegithub@gmail.com>","Denis Lukov <denismassters@gmail.com>","Philipp Hancke <fippo@andyet.net>","Hans Oksendahl <hansoksendahl@gmail.com>","Jess <jessachandler@gmail.com>","khankuan <khankuan@gmail.com>","DUODVK <kurmanov.work@gmail.com>","XiZhao <kwang1imsa@gmail.com>","Matthias Lohr <matthias@lohr.me>","=frank tree <=frnktrb@googlemail.com>","Andre Eckardt <aeckardt@outlook.com>","Chris Cowan <agentme49@gmail.com>","Alex Chuev <alex@chuev.com>","alxnull <alxnull@e.mail.de>","Yemel Jardi <angel.jardi@gmail.com>","Ben Parnell <benjaminparnell.94@gmail.com>","Benny Lichtner <bennlich@gmail.com>","fresheneesz <bitetrudpublic@gmail.com>","bob.barstead@exaptive.com <bob.barstead@exaptive.com>","chandika <chandika@gmail.com>","emersion <contact@emersion.fr>","Christopher Van <cvan@users.noreply.github.com>","eddieherm <edhermoso@gmail.com>","Eduardo Pinho <enet4mikeenet@gmail.com>","Evandro Zanatta <ezanatta@tray.net.br>","Gardner Bickford <gardner@users.noreply.github.com>","Gian Luca <gianluca.cecchi@cynny.com>","PatrickJS <github@gdi2290.com>","jonnyf <github@jonathanfoss.co.uk>","Hizkia Felix <hizkifw@gmail.com>","Hristo Oskov <hristo.oskov@gmail.com>","Isaac Madwed <i.madwed@gmail.com>","Ilya Konanykhin <ilya.konanykhin@gmail.com>","jasonbarry <jasbarry@me.com>","Jonathan Burke <jonathan.burke.1311@googlemail.com>","Josh Hamit <josh.hamit@gmail.com>","Jordan Austin <jrax86@gmail.com>","Joel Wetzell <jwetzell@yahoo.com>","xizhao <kevin.wang@cloudera.com>","Alberto Torres <kungfoobar@gmail.com>","Jonathan Mayol <mayoljonathan@gmail.com>","Jefferson Felix <me@jsfelix.dev>","Rolf Erik Lekang <me@rolflekang.com>","Kevin Mai-Husan Chia <mhchia@users.noreply.github.com>","Pepijn de Vos <pepijndevos@gmail.com>","JooYoung <qkdlql@naver.com>","Tobias Speicher <rootcommander@gmail.com>","Steve Blaurock <sblaurock@gmail.com>","Kyrylo Shegeda <shegeda@ualberta.ca>","Diwank Singh Tomer <singh@diwank.name>","Sören Balko <Soeren.Balko@gmail.com>","Arpit Solanki <solankiarpit1997@gmail.com>","Yuki Ito <yuki@gnnk.net>","Artur Zayats <zag2art@gmail.com>"],"funding":{"type":"opencollective","url":"https://opencollective.com/peer"},"collective":{"type":"opencollective","url":"https://opencollective.com/peer"},"files":["dist/*"],"sideEffects":["lib/global.ts","lib/supports.ts"],"main":"dist/bundler.cjs","module":"dist/bundler.mjs","browser-minified":"dist/peerjs.min.js","browser-unminified":"dist/peerjs.js","types":"dist/types.d.ts","engines":{"node":">= 10"},"targets":{"types":{"source":"lib/exports.ts"},"main":{"source":"lib/exports.ts","sourceMap":{"inlineSources":true}},"module":{"source":"lib/exports.ts","includeNodeModules":["eventemitter3"],"sourceMap":{"inlineSources":true}},"browser-minified":{"context":"browser","outputFormat":"global","optimize":true,"engines":{"browsers":"cover 99%, not dead"},"source":"lib/global.ts"},"browser-unminified":{"context":"browser","outputFormat":"global","optimize":false,"engines":{"browsers":"cover 99%, not dead"},"source":"lib/global.ts"}},"scripts":{"contributors":"git-authors-cli --print=false && prettier --write package.json && git add package.json package-lock.json && git commit -m \\"chore(contributors): update and sort contributors list\\"","check":"tsc --noEmit","watch":"parcel watch","build":"rm -rf dist && parcel build","prepublishOnly":"npm run build","test":"mocha -r ts-node/register -r jsdom-global/register test/**/*.ts","format":"prettier --write .","semantic-release":"semantic-release"},"devDependencies":{"@parcel/config-default":"^2.5.0","@parcel/packager-ts":"^2.5.0","@parcel/transformer-typescript-tsc":"^2.5.0","@parcel/transformer-typescript-types":"^2.5.0","@semantic-release/changelog":"^6.0.1","@semantic-release/git":"^10.0.1","@types/chai":"^4.3.0","@types/mocha":"^9.1.0","@types/node":"^17.0.18","chai":"^4.3.6","git-authors-cli":"^1.0.40","jsdom":"^19.0.0","jsdom-global":"^3.0.2","mocha":"^9.2.0","mock-socket":"8.0.5","parcel":"^2.5.0","parcel-transformer-tsc-sourcemaps":"^1.0.2","prettier":"^2.6.2","semantic-release":"^19.0.2","standard":"^16.0.4","ts-node":"^10.5.0","typescript":"^4.5.5"},"dependencies":{"@swc/helpers":"^0.3.13","eventemitter3":"^4.0.7","peerjs-js-binarypack":"1.0.1","webrtc-adapter":"^7.7.1"}}');var lde=function(){var s=function(e,t){return s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(i[r]=n[r])},s(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");s(e,t);function i(){this.constructor=e}e.prototype=t===null?Object.create(t):(i.prototype=t.prototype,new i)}}(),hde=function(s,e){var t=typeof Symbol=="function"&&s[Symbol.iterator];if(!t)return s;var i=t.call(s),n,r=[],o;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)r.push(n.value)}catch(a){o={error:a}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(o)throw o.error}}return r},ude=function(s,e,t){if(t||arguments.length===2)for(var i=0,n=e.length,r;i<n;i++)(r||!(i in e))&&(r||(r=Array.prototype.slice.call(e,0,i)),r[i]=e[i]);return s.concat(r||Array.prototype.slice.call(e))},dde=function(s){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&s[e],i=0;if(t)return t.call(s);if(s&&typeof s.length=="number")return{next:function(){return s&&i>=s.length&&(s=void 0),{value:s&&s[i++],done:!s}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},H3=function(s){lde(e,s);function e(t,i,n,r,o,a){a===void 0&&(a=5e3);var c=s.call(this)||this;c.pingInterval=a,c._disconnected=!0,c._messagesQueue=[];var l=t?"wss://":"ws://";return c._baseUrl=l+i+":"+n+r+"peerjs?key="+o,c}return e.prototype.start=function(t,i){var n=this;this._id=t;var r="".concat(this._baseUrl,"&id=").concat(t,"&token=").concat(i);this._socket||!this._disconnected||(this._socket=new WebSocket(r+"&version="+Ck.version),this._disconnected=!1,this._socket.onmessage=function(o){var a;try{a=JSON.parse(o.data),pt.default.log("Server message received:",a)}catch{pt.default.log("Invalid server message",o.data);return}n.emit(Eh.Message,a)},this._socket.onclose=function(o){n._disconnected||(pt.default.log("Socket closed.",o),n._cleanup(),n._disconnected=!0,n.emit(Eh.Disconnected))},this._socket.onopen=function(){n._disconnected||(n._sendQueuedMessages(),pt.default.log("Socket open"),n._scheduleHeartbeat())})},e.prototype._scheduleHeartbeat=function(){var t=this;this._wsPingTimer=setTimeout(function(){t._sendHeartbeat()},this.pingInterval)},e.prototype._sendHeartbeat=function(){if(!this._wsOpen()){pt.default.log("Cannot send heartbeat, because socket closed");return}var t=JSON.stringify({type:$s.Heartbeat});this._socket.send(t),this._scheduleHeartbeat()},e.prototype._wsOpen=function(){return!!this._socket&&this._socket.readyState===1},e.prototype._sendQueuedMessages=function(){var t,i,n=ude([],hde(this._messagesQueue),!1);this._messagesQueue=[];try{for(var r=dde(n),o=r.next();!o.done;o=r.next()){var a=o.value;this.send(a)}}catch(c){t={error:c}}finally{try{o&&!o.done&&(i=r.return)&&i.call(r)}finally{if(t)throw t.error}}},e.prototype.send=function(t){if(!this._disconnected){if(!this._id){this._messagesQueue.push(t);return}if(!t.type){this.emit(Eh.Error,"Invalid message");return}if(this._wsOpen()){var i=JSON.stringify(t);this._socket.send(i)}}},e.prototype.close=function(){this._disconnected||(this._cleanup(),this._disconnected=!0)},e.prototype._cleanup=function(){this._socket&&(this._socket.onopen=this._socket.onmessage=this._socket.onclose=null,this._socket.close(),this._socket=void 0),clearTimeout(this._wsPingTimer)},e}(Pb.EventEmitter),dP={};Ml(dP,"MediaConnection",()=>W3,s=>W3=s);var Sk={};Ml(Sk,"Negotiator",()=>V3,s=>V3=s);var vS=function(){return vS=Object.assign||function(s){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(s[n]=e[n])}return s},vS.apply(this,arguments)},uw=function(s,e,t,i){function n(r){return r instanceof t?r:new t(function(o){o(r)})}return new(t||(t=Promise))(function(r,o){function a(h){try{l(i.next(h))}catch(u){o(u)}}function c(h){try{l(i.throw(h))}catch(u){o(u)}}function l(h){h.done?r(h.value):n(h.value).then(a,c)}l((i=i.apply(s,e||[])).next())})},dw=function(s,e){var t={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},i,n,r,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(l){return function(h){return c([l,h])}}function c(l){if(i)throw new TypeError("Generator is already executing.");for(;t;)try{if(i=1,n&&(r=l[0]&2?n.return:l[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,l[1])).done)return r;switch(n=0,r&&(l=[l[0]&2,r.value]),l[0]){case 0:case 1:r=l;break;case 4:return t.label++,{value:l[1],done:!1};case 5:t.label++,n=l[1],l=[0];continue;case 7:l=t.ops.pop(),t.trys.pop();continue;default:if(r=t.trys,!(r=r.length>0&&r[r.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!r||l[1]>r[0]&&l[1]<r[3])){t.label=l[1];break}if(l[0]===6&&t.label<r[1]){t.label=r[1],r=l;break}if(r&&t.label<r[2]){t.label=r[2],t.ops.push(l);break}r[2]&&t.ops.pop(),t.trys.pop();continue}l=e.call(s,t)}catch(h){l=[6,h],n=0}finally{i=r=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},V3=function(){function s(e){this.connection=e}return s.prototype.startConnection=function(e){var t=this._startPeerConnection();if(this.connection.peerConnection=t,this.connection.type===gc.Media&&e._stream&&this._addTracksToConnection(e._stream,t),e.originator){if(this.connection.type===gc.Data){var i=this.connection,n={ordered:!!e.reliable},r=t.createDataChannel(i.label,n);i.initialize(r)}this._makeOffer()}else this.handleSDP("OFFER",e.sdp)},s.prototype._startPeerConnection=function(){pt.default.log("Creating RTCPeerConnection.");var e=new RTCPeerConnection(this.connection.provider.options.config);return this._setupListeners(e),e},s.prototype._setupListeners=function(e){var t=this,i=this.connection.peer,n=this.connection.connectionId,r=this.connection.type,o=this.connection.provider;pt.default.log("Listening for ICE candidates."),e.onicecandidate=function(a){!a.candidate||!a.candidate.candidate||(pt.default.log("Received ICE candidates for ".concat(i,":"),a.candidate),o.socket.send({type:$s.Candidate,payload:{candidate:a.candidate,type:r,connectionId:n},dst:i}))},e.oniceconnectionstatechange=function(){switch(e.iceConnectionState){case"failed":pt.default.log("iceConnectionState is failed, closing connections to "+i),t.connection.emit("error",new Error("Negotiation of connection to "+i+" failed.")),t.connection.close();break;case"closed":pt.default.log("iceConnectionState is closed, closing connections to "+i),t.connection.emit("error",new Error("Connection to "+i+" closed.")),t.connection.close();break;case"disconnected":pt.default.log("iceConnectionState changed to disconnected on the connection with "+i);break;case"completed":e.onicecandidate=wi.noop;break}t.connection.emit("iceStateChanged",e.iceConnectionState)},pt.default.log("Listening for data channel"),e.ondatachannel=function(a){pt.default.log("Received data channel");var c=a.channel,l=o.getConnection(i,n);l.initialize(c)},pt.default.log("Listening for remote stream"),e.ontrack=function(a){pt.default.log("Received remote stream");var c=a.streams[0],l=o.getConnection(i,n);if(l.type===gc.Media){var h=l;t._addStreamToMediaConnection(c,h)}}},s.prototype.cleanup=function(){pt.default.log("Cleaning up PeerConnection to "+this.connection.peer);var e=this.connection.peerConnection;if(e){this.connection.peerConnection=null,e.onicecandidate=e.oniceconnectionstatechange=e.ondatachannel=e.ontrack=function(){};var t=e.signalingState!=="closed",i=!1;if(this.connection.type===gc.Data){var n=this.connection,r=n.dataChannel;r&&(i=!!r.readyState&&r.readyState!=="closed")}(t||i)&&e.close()}},s.prototype._makeOffer=function(){return uw(this,void 0,Promise,function(){var e,t,i,n,r,o,a;return dw(this,function(c){switch(c.label){case 0:e=this.connection.peerConnection,t=this.connection.provider,c.label=1;case 1:return c.trys.push([1,7,,8]),[4,e.createOffer(this.connection.options.constraints)];case 2:i=c.sent(),pt.default.log("Created offer."),this.connection.options.sdpTransform&&typeof this.connection.options.sdpTransform=="function"&&(i.sdp=this.connection.options.sdpTransform(i.sdp)||i.sdp),c.label=3;case 3:return c.trys.push([3,5,,6]),[4,e.setLocalDescription(i)];case 4:return c.sent(),pt.default.log("Set localDescription:",i,"for:".concat(this.connection.peer)),n={sdp:i,type:this.connection.type,connectionId:this.connection.connectionId,metadata:this.connection.metadata,browser:wi.browser},this.connection.type===gc.Data&&(r=this.connection,n=vS(vS({},n),{label:r.label,reliable:r.reliable,serialization:r.serialization})),t.socket.send({type:$s.Offer,payload:n,dst:this.connection.peer}),[3,6];case 5:return o=c.sent(),o!="OperationError: Failed to set local offer sdp: Called in wrong state: kHaveRemoteOffer"&&(t.emitError(Hn.WebRTC,o),pt.default.log("Failed to setLocalDescription, ",o)),[3,6];case 6:return[3,8];case 7:return a=c.sent(),t.emitError(Hn.WebRTC,a),pt.default.log("Failed to createOffer, ",a),[3,8];case 8:return[2]}})})},s.prototype._makeAnswer=function(){return uw(this,void 0,Promise,function(){var e,t,i,n,r;return dw(this,function(o){switch(o.label){case 0:e=this.connection.peerConnection,t=this.connection.provider,o.label=1;case 1:return o.trys.push([1,7,,8]),[4,e.createAnswer()];case 2:i=o.sent(),pt.default.log("Created answer."),this.connection.options.sdpTransform&&typeof this.connection.options.sdpTransform=="function"&&(i.sdp=this.connection.options.sdpTransform(i.sdp)||i.sdp),o.label=3;case 3:return o.trys.push([3,5,,6]),[4,e.setLocalDescription(i)];case 4:return o.sent(),pt.default.log("Set localDescription:",i,"for:".concat(this.connection.peer)),t.socket.send({type:$s.Answer,payload:{sdp:i,type:this.connection.type,connectionId:this.connection.connectionId,browser:wi.browser},dst:this.connection.peer}),[3,6];case 5:return n=o.sent(),t.emitError(Hn.WebRTC,n),pt.default.log("Failed to setLocalDescription, ",n),[3,6];case 6:return[3,8];case 7:return r=o.sent(),t.emitError(Hn.WebRTC,r),pt.default.log("Failed to create answer, ",r),[3,8];case 8:return[2]}})})},s.prototype.handleSDP=function(e,t){return uw(this,void 0,Promise,function(){var i,n,r,o;return dw(this,function(a){switch(a.label){case 0:t=new RTCSessionDescription(t),i=this.connection.peerConnection,n=this.connection.provider,pt.default.log("Setting remote description",t),r=this,a.label=1;case 1:return a.trys.push([1,5,,6]),[4,i.setRemoteDescription(t)];case 2:return a.sent(),pt.default.log("Set remoteDescription:".concat(e," for:").concat(this.connection.peer)),e!=="OFFER"?[3,4]:[4,r._makeAnswer()];case 3:a.sent(),a.label=4;case 4:return[3,6];case 5:return o=a.sent(),n.emitError(Hn.WebRTC,o),pt.default.log("Failed to setRemoteDescription, ",o),[3,6];case 6:return[2]}})})},s.prototype.handleCandidate=function(e){return uw(this,void 0,Promise,function(){var t,i,n,r,o,a;return dw(this,function(c){switch(c.label){case 0:pt.default.log("handleCandidate:",e),t=e.candidate,i=e.sdpMLineIndex,n=e.sdpMid,r=this.connection.peerConnection,o=this.connection.provider,c.label=1;case 1:return c.trys.push([1,3,,4]),[4,r.addIceCandidate(new RTCIceCandidate({sdpMid:n,sdpMLineIndex:i,candidate:t}))];case 2:return c.sent(),pt.default.log("Added ICE candidate for:".concat(this.connection.peer)),[3,4];case 3:return a=c.sent(),o.emitError(Hn.WebRTC,a),pt.default.log("Failed to handleCandidate, ",a),[3,4];case 4:return[2]}})})},s.prototype._addTracksToConnection=function(e,t){if(pt.default.log("add tracks from stream ".concat(e.id," to peer connection")),!t.addTrack)return pt.default.error("Your browser does't support RTCPeerConnection#addTrack. Ignored.");e.getTracks().forEach(function(i){t.addTrack(i,e)})},s.prototype._addStreamToMediaConnection=function(e,t){pt.default.log("add stream ".concat(e.id," to media connection ").concat(t.connectionId)),t.addStream(e)},s}(),Ek={};Ml(Ek,"BaseConnection",()=>j3,s=>j3=s);var fde=function(){var s=function(e,t){return s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(i[r]=n[r])},s(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");s(e,t);function i(){this.constructor=e}e.prototype=t===null?Object.create(t):(i.prototype=t.prototype,new i)}}(),j3=function(s){fde(e,s);function e(t,i,n){var r=s.call(this)||this;return r.peer=t,r.provider=i,r.options=n,r._open=!1,r.metadata=n.metadata,r}return Object.defineProperty(e.prototype,"open",{get:function(){return this._open},enumerable:!1,configurable:!0}),e}(Pb.EventEmitter),pde=function(){var s=function(e,t){return s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(i[r]=n[r])},s(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");s(e,t);function i(){this.constructor=e}e.prototype=t===null?Object.create(t):(i.prototype=t.prototype,new i)}}(),bS=function(){return bS=Object.assign||function(s){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(s[n]=e[n])}return s},bS.apply(this,arguments)},gde=function(s){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&s[e],i=0;if(t)return t.call(s);if(s&&typeof s.length=="number")return{next:function(){return s&&i>=s.length&&(s=void 0),{value:s&&s[i++],done:!s}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},W3=function(s){pde(e,s);function e(t,i,n){var r=s.call(this,t,i,n)||this;return r._localStream=r.options._stream,r.connectionId=r.options.connectionId||e.ID_PREFIX+wi.randomToken(),r._negotiator=new Sk.Negotiator(r),r._localStream&&r._negotiator.startConnection({_stream:r._localStream,originator:!0}),r}return Object.defineProperty(e.prototype,"type",{get:function(){return gc.Media},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"localStream",{get:function(){return this._localStream},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"remoteStream",{get:function(){return this._remoteStream},enumerable:!1,configurable:!0}),e.prototype.addStream=function(t){pt.default.log("Receiving stream",t),this._remoteStream=t,s.prototype.emit.call(this,"stream",t)},e.prototype.handleMessage=function(t){var i=t.type,n=t.payload;switch(t.type){case $s.Answer:this._negotiator.handleSDP(i,n.sdp),this._open=!0;break;case $s.Candidate:this._negotiator.handleCandidate(n.candidate);break;default:pt.default.warn("Unrecognized message type:".concat(i," from peer:").concat(this.peer));break}},e.prototype.answer=function(t,i){var n,r;if(i===void 0&&(i={}),this._localStream){pt.default.warn("Local stream already exists on this MediaConnection. Are you answering a call twice?");return}this._localStream=t,i&&i.sdpTransform&&(this.options.sdpTransform=i.sdpTransform),this._negotiator.startConnection(bS(bS({},this.options._payload),{_stream:t}));var o=this.provider._getMessages(this.connectionId);try{for(var a=gde(o),c=a.next();!c.done;c=a.next()){var l=c.value;this.handleMessage(l)}}catch(h){n={error:h}}finally{try{c&&!c.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}this._open=!0},e.prototype.close=function(){this._negotiator&&(this._negotiator.cleanup(),this._negotiator=null),this._localStream=null,this._remoteStream=null,this.provider&&(this.provider._removeConnection(this),this.provider=null),this.options&&this.options._stream&&(this.options._stream=null),this.open&&(this._open=!1,s.prototype.emit.call(this,"close"))},e.ID_PREFIX="mc_",e}(Ek.BaseConnection),fP={};Ml(fP,"DataConnection",()=>X3,s=>X3=s);var P9={};Ml(P9,"EncodingQueue",()=>q3,s=>q3=s);var mde=function(){var s=function(e,t){return s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(i[r]=n[r])},s(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");s(e,t);function i(){this.constructor=e}e.prototype=t===null?Object.create(t):(i.prototype=t.prototype,new i)}}(),q3=function(s){mde(e,s);function e(){var t=s.call(this)||this;return t.fileReader=new FileReader,t._queue=[],t._processing=!1,t.fileReader.onload=function(i){t._processing=!1,i.target&&t.emit("done",i.target.result),t.doNextTask()},t.fileReader.onerror=function(i){pt.default.error("EncodingQueue error:",i),t._processing=!1,t.destroy(),t.emit("error",i)},t}return Object.defineProperty(e.prototype,"queue",{get:function(){return this._queue},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"size",{get:function(){return this.queue.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"processing",{get:function(){return this._processing},enumerable:!1,configurable:!0}),e.prototype.enque=function(t){this.queue.push(t),!this.processing&&this.doNextTask()},e.prototype.destroy=function(){this.fileReader.abort(),this._queue=[]},e.prototype.doNextTask=function(){this.size!==0&&(this.processing||(this._processing=!0,this.fileReader.readAsArrayBuffer(this.queue.shift())))},e}(Pb.EventEmitter),Ade=function(){var s=function(e,t){return s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(i[r]=n[r])},s(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");s(e,t);function i(){this.constructor=e}e.prototype=t===null?Object.create(t):(i.prototype=t.prototype,new i)}}(),yde=function(s){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&s[e],i=0;if(t)return t.call(s);if(s&&typeof s.length=="number")return{next:function(){return s&&i>=s.length&&(s=void 0),{value:s&&s[i++],done:!s}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},X3=function(s){Ade(e,s);function e(t,i,n){var r=s.call(this,t,i,n)||this;return r.stringify=JSON.stringify,r.parse=JSON.parse,r._buffer=[],r._bufferSize=0,r._buffering=!1,r._chunkedData={},r._encodingQueue=new P9.EncodingQueue,r.connectionId=r.options.connectionId||e.ID_PREFIX+wi.randomToken(),r.label=r.options.label||r.connectionId,r.serialization=r.options.serialization||lh.Binary,r.reliable=!!r.options.reliable,r._encodingQueue.on("done",function(o){r._bufferedSend(o)}),r._encodingQueue.on("error",function(){pt.default.error("DC#".concat(r.connectionId,": Error occured in encoding from blob to arraybuffer, close DC")),r.close()}),r._negotiator=new Sk.Negotiator(r),r._negotiator.startConnection(r.options._payload||{originator:!0}),r}return Object.defineProperty(e.prototype,"type",{get:function(){return gc.Data},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dataChannel",{get:function(){return this._dc},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"bufferSize",{get:function(){return this._bufferSize},enumerable:!1,configurable:!0}),e.prototype.initialize=function(t){this._dc=t,this._configureDataChannel()},e.prototype._configureDataChannel=function(){var t=this;(!wi.supports.binaryBlob||wi.supports.reliable)&&(this.dataChannel.binaryType="arraybuffer"),this.dataChannel.onopen=function(){pt.default.log("DC#".concat(t.connectionId," dc connection success")),t._open=!0,t.emit("open")},this.dataChannel.onmessage=function(i){pt.default.log("DC#".concat(t.connectionId," dc onmessage:"),i.data),t._handleDataMessage(i)},this.dataChannel.onclose=function(){pt.default.log("DC#".concat(t.connectionId," dc closed for:"),t.peer),t.close()}},e.prototype._handleDataMessage=function(t){var i=this,n=t.data,r=n.constructor,o=this.serialization===lh.Binary||this.serialization===lh.BinaryUTF8,a=n;if(o){if(r===Blob){wi.blobToArrayBuffer(n,function(l){var h=wi.unpack(l);i.emit("data",h)});return}else if(r===ArrayBuffer)a=wi.unpack(n);else if(r===String){var c=wi.binaryStringToArrayBuffer(n);a=wi.unpack(c)}}else this.serialization===lh.JSON&&(a=this.parse(n));if(a.__peerData){this._handleChunk(a);return}s.prototype.emit.call(this,"data",a)},e.prototype._handleChunk=function(t){var i=t.__peerData,n=this._chunkedData[i]||{data:[],count:0,total:t.total};if(n.data[t.n]=t.data,n.count++,this._chunkedData[i]=n,n.total===n.count){delete this._chunkedData[i];var r=new Blob(n.data);this._handleDataMessage({data:r})}},e.prototype.close=function(){this._buffer=[],this._bufferSize=0,this._chunkedData={},this._negotiator&&(this._negotiator.cleanup(),this._negotiator=null),this.provider&&(this.provider._removeConnection(this),this.provider=null),this.dataChannel&&(this.dataChannel.onopen=null,this.dataChannel.onmessage=null,this.dataChannel.onclose=null,this._dc=null),this._encodingQueue&&(this._encodingQueue.destroy(),this._encodingQueue.removeAllListeners(),this._encodingQueue=null),this.open&&(this._open=!1,s.prototype.emit.call(this,"close"))},e.prototype.send=function(t,i){if(!this.open){s.prototype.emit.call(this,"error",new Error("Connection is not open. You should listen for the `open` event before sending messages."));return}if(this.serialization===lh.JSON)this._bufferedSend(this.stringify(t));else if(this.serialization===lh.Binary||this.serialization===lh.BinaryUTF8){var n=wi.pack(t);if(!i&&n.size>wi.chunkedMTU){this._sendChunks(n);return}wi.supports.binaryBlob?this._bufferedSend(n):this._encodingQueue.enque(n)}else this._bufferedSend(t)},e.prototype._bufferedSend=function(t){(this._buffering||!this._trySend(t))&&(this._buffer.push(t),this._bufferSize=this._buffer.length)},e.prototype._trySend=function(t){var i=this;if(!this.open)return!1;if(this.dataChannel.bufferedAmount>e.MAX_BUFFERED_AMOUNT)return this._buffering=!0,setTimeout(function(){i._buffering=!1,i._tryBuffer()},50),!1;try{this.dataChannel.send(t)}catch(n){return pt.default.error("DC#:".concat(this.connectionId," Error when sending:"),n),this._buffering=!0,this.close(),!1}return!0},e.prototype._tryBuffer=function(){if(this.open&&this._buffer.length!==0){var t=this._buffer[0];this._trySend(t)&&(this._buffer.shift(),this._bufferSize=this._buffer.length,this._tryBuffer())}},e.prototype._sendChunks=function(t){var i,n,r=wi.chunk(t);pt.default.log("DC#".concat(this.connectionId," Try to send ").concat(r.length," chunks..."));try{for(var o=yde(r),a=o.next();!a.done;a=o.next()){var c=a.value;this.send(c,!0)}}catch(l){i={error:l}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}},e.prototype.handleMessage=function(t){var i=t.payload;switch(t.type){case $s.Answer:this._negotiator.handleSDP(t.type,i.sdp);break;case $s.Candidate:this._negotiator.handleCandidate(i.candidate);break;default:pt.default.warn("Unrecognized message type:",t.type,"from peer:",this.peer);break}},e.ID_PREFIX="dc_",e.MAX_BUFFERED_AMOUNT=8388608,e}(Ek.BaseConnection),D9={};Ml(D9,"API",()=>K3,s=>K3=s);var Y3=function(s,e,t,i){function n(r){return r instanceof t?r:new t(function(o){o(r)})}return new(t||(t=Promise))(function(r,o){function a(h){try{l(i.next(h))}catch(u){o(u)}}function c(h){try{l(i.throw(h))}catch(u){o(u)}}function l(h){h.done?r(h.value):n(h.value).then(a,c)}l((i=i.apply(s,e||[])).next())})},J3=function(s,e){var t={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},i,n,r,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(l){return function(h){return c([l,h])}}function c(l){if(i)throw new TypeError("Generator is already executing.");for(;t;)try{if(i=1,n&&(r=l[0]&2?n.return:l[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,l[1])).done)return r;switch(n=0,r&&(l=[l[0]&2,r.value]),l[0]){case 0:case 1:r=l;break;case 4:return t.label++,{value:l[1],done:!1};case 5:t.label++,n=l[1],l=[0];continue;case 7:l=t.ops.pop(),t.trys.pop();continue;default:if(r=t.trys,!(r=r.length>0&&r[r.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!r||l[1]>r[0]&&l[1]<r[3])){t.label=l[1];break}if(l[0]===6&&t.label<r[1]){t.label=r[1],r=l;break}if(r&&t.label<r[2]){t.label=r[2],t.ops.push(l);break}r[2]&&t.ops.pop(),t.trys.pop();continue}l=e.call(s,t)}catch(h){l=[6,h],n=0}finally{i=r=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},K3=function(){function s(e){this._options=e}return s.prototype._buildRequest=function(e){var t=this._options.secure?"https":"http",i=this._options,n=i.host,r=i.port,o=i.path,a=i.key,c=new URL("".concat(t,"://").concat(n,":").concat(r).concat(o).concat(a,"/").concat(e));return c.searchParams.set("ts","".concat(Date.now()).concat(Math.random())),c.searchParams.set("version",Ck.version),fetch(c.href,{referrerPolicy:this._options.referrerPolicy})},s.prototype.retrieveId=function(){return Y3(this,void 0,Promise,function(){var e,t,i;return J3(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this._buildRequest("id")];case 1:if(e=n.sent(),e.status!==200)throw new Error("Error. Status:".concat(e.status));return[2,e.text()];case 2:throw t=n.sent(),pt.default.error("Error retrieving ID",t),i="",this._options.path==="/"&&this._options.host!==wi.CLOUD_HOST&&(i=" If you passed in a `path` to your self-hosted PeerServer, you'll also need to pass in that same path when creating a new Peer."),new Error("Could not get an ID from the server."+i);case 3:return[2]}})})},s.prototype.listAllPeers=function(){return Y3(this,void 0,Promise,function(){var e,t,i;return J3(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this._buildRequest("peers")];case 1:if(e=n.sent(),e.status!==200)throw e.status===401?(t="",this._options.host===wi.CLOUD_HOST?t="It looks like you're using the cloud server. You can email team@peerjs.com to enable peer listing for your API key.":t="You need to enable `allow_discovery` on your self-hosted PeerServer to use this feature.",new Error("It doesn't look like you have permission to list peers IDs. "+t)):new Error("Error. Status:".concat(e.status));return[2,e.json()];case 2:throw i=n.sent(),pt.default.error("Error retrieving list peers",i),new Error("Could not get list peers from the server."+i);case 3:return[2]}})})},s}(),vde=function(){var s=function(e,t){return s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(i[r]=n[r])},s(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");s(e,t);function i(){this.constructor=e}e.prototype=t===null?Object.create(t):(i.prototype=t.prototype,new i)}}(),Y0=function(){return Y0=Object.assign||function(s){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(s[n]=e[n])}return s},Y0.apply(this,arguments)},Ny=function(s){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&s[e],i=0;if(t)return t.call(s);if(s&&typeof s.length=="number")return{next:function(){return s&&i>=s.length&&(s=void 0),{value:s&&s[i++],done:!s}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},bde=function(s,e){var t=typeof Symbol=="function"&&s[Symbol.iterator];if(!t)return s;var i=t.call(s),n,r=[],o;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)r.push(n.value)}catch(a){o={error:a}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(o)throw o.error}}return r},pP=function(s){vde(e,s);function e(t,i){var n=s.call(this)||this;n._id=null,n._lastServerId=null,n._destroyed=!1,n._disconnected=!1,n._open=!1,n._connections=new Map,n._lostMessages=new Map;var r;return t&&t.constructor==Object?i=t:t&&(r=t.toString()),i=Y0({debug:0,host:wi.CLOUD_HOST,port:wi.CLOUD_PORT,path:"/",key:e.DEFAULT_KEY,token:wi.randomToken(),config:wi.defaultConfig,referrerPolicy:"strict-origin-when-cross-origin"},i),n._options=i,n._options.host==="/"&&(n._options.host=window.location.hostname),n._options.path&&(n._options.path[0]!=="/"&&(n._options.path="/"+n._options.path),n._options.path[n._options.path.length-1]!=="/"&&(n._options.path+="/")),n._options.secure===void 0&&n._options.host!==wi.CLOUD_HOST?n._options.secure=wi.isSecure():n._options.host==wi.CLOUD_HOST&&(n._options.secure=!0),n._options.logFunction&&pt.default.setLogFunction(n._options.logFunction),pt.default.logLevel=n._options.debug||0,n._api=new D9.API(i),n._socket=n._createServerConnection(),!wi.supports.audioVideo&&!wi.supports.data?(n._delayedAbort(Hn.BrowserIncompatible,"The current browser does not support WebRTC"),n):r&&!wi.validateId(r)?(n._delayedAbort(Hn.InvalidID,'ID "'.concat(r,'" is invalid')),n):(r?n._initialize(r):n._api.retrieveId().then(function(o){return n._initialize(o)}).catch(function(o){return n._abort(Hn.ServerError,o)}),n)}return Object.defineProperty(e.prototype,"id",{get:function(){return this._id},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"options",{get:function(){return this._options},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"open",{get:function(){return this._open},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"socket",{get:function(){return this._socket},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"connections",{get:function(){var t,i,n=Object.create(null);try{for(var r=Ny(this._connections),o=r.next();!o.done;o=r.next()){var a=bde(o.value,2),c=a[0],l=a[1];n[c]=l}}catch(h){t={error:h}}finally{try{o&&!o.done&&(i=r.return)&&i.call(r)}finally{if(t)throw t.error}}return n},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"destroyed",{get:function(){return this._destroyed},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"disconnected",{get:function(){return this._disconnected},enumerable:!1,configurable:!0}),e.prototype._createServerConnection=function(){var t=this,i=new R9.Socket(this._options.secure,this._options.host,this._options.port,this._options.path,this._options.key,this._options.pingInterval);return i.on(Eh.Message,function(n){t._handleMessage(n)}),i.on(Eh.Error,function(n){t._abort(Hn.SocketError,n)}),i.on(Eh.Disconnected,function(){t.disconnected||(t.emitError(Hn.Network,"Lost connection to server."),t.disconnect())}),i.on(Eh.Close,function(){t.disconnected||t._abort(Hn.SocketClosed,"Underlying socket is already closed.")}),i},e.prototype._initialize=function(t){this._id=t,this.socket.start(t,this._options.token)},e.prototype._handleMessage=function(t){var i,n,r=t.type,o=t.payload,a=t.src;switch(r){case $s.Open:this._lastServerId=this.id,this._open=!0,this.emit("open",this.id);break;case $s.Error:this._abort(Hn.ServerError,o.msg);break;case $s.IdTaken:this._abort(Hn.UnavailableID,'ID "'.concat(this.id,'" is taken'));break;case $s.InvalidKey:this._abort(Hn.InvalidKey,'API KEY "'.concat(this._options.key,'" is invalid'));break;case $s.Leave:pt.default.log("Received leave message from ".concat(a)),this._cleanupPeer(a),this._connections.delete(a);break;case $s.Expire:this.emitError(Hn.PeerUnavailable,"Could not connect to peer ".concat(a));break;case $s.Offer:var g=o.connectionId,y=this.getConnection(a,g);if(y&&(y.close(),pt.default.warn("Offer received for existing Connection ID:".concat(g))),o.type===gc.Media){var c=new dP.MediaConnection(a,this,{connectionId:g,_payload:o,metadata:o.metadata});y=c,this._addConnection(a,y),this.emit("call",c)}else if(o.type===gc.Data){var l=new fP.DataConnection(a,this,{connectionId:g,_payload:o,metadata:o.metadata,label:o.label,serialization:o.serialization,reliable:o.reliable});y=l,this._addConnection(a,y),this.emit("connection",l)}else{pt.default.warn("Received malformed connection type:".concat(o.type));return}var h=this._getMessages(g);try{for(var u=Ny(h),f=u.next();!f.done;f=u.next()){var p=f.value;y.handleMessage(p)}}catch(m){i={error:m}}finally{try{f&&!f.done&&(n=u.return)&&n.call(u)}finally{if(i)throw i.error}}break;default:if(!o){pt.default.warn("You received a malformed message from ".concat(a," of type ").concat(r));return}var g=o.connectionId,y=this.getConnection(a,g);y&&y.peerConnection?y.handleMessage(t):g?this._storeMessage(g,t):pt.default.warn("You received an unrecognized message:",t);break}},e.prototype._storeMessage=function(t,i){this._lostMessages.has(t)||this._lostMessages.set(t,[]),this._lostMessages.get(t).push(i)},e.prototype._getMessages=function(t){var i=this._lostMessages.get(t);return i?(this._lostMessages.delete(t),i):[]},e.prototype.connect=function(t,i){if(i===void 0&&(i={}),this.disconnected){pt.default.warn("You cannot connect to a new Peer because you called .disconnect() on this Peer and ended your connection with the server. You can create a new Peer to reconnect, or call reconnect on this peer if you believe its ID to still be available."),this.emitError(Hn.Disconnected,"Cannot connect to new Peer after disconnecting from server.");return}var n=new fP.DataConnection(t,this,i);return this._addConnection(t,n),n},e.prototype.call=function(t,i,n){if(n===void 0&&(n={}),this.disconnected){pt.default.warn("You cannot connect to a new Peer because you called .disconnect() on this Peer and ended your connection with the server. You can create a new Peer to reconnect."),this.emitError(Hn.Disconnected,"Cannot connect to new Peer after disconnecting from server.");return}if(!i){pt.default.error("To call a peer, you must provide a stream from your browser's `getUserMedia`.");return}var r=new dP.MediaConnection(t,this,Y0(Y0({},n),{_stream:i}));return this._addConnection(t,r),r},e.prototype._addConnection=function(t,i){pt.default.log("add connection ".concat(i.type,":").concat(i.connectionId," to peerId:").concat(t)),this._connections.has(t)||this._connections.set(t,[]),this._connections.get(t).push(i)},e.prototype._removeConnection=function(t){var i=this._connections.get(t.peer);if(i){var n=i.indexOf(t);n!==-1&&i.splice(n,1)}this._lostMessages.delete(t.connectionId)},e.prototype.getConnection=function(t,i){var n,r,o=this._connections.get(t);if(!o)return null;try{for(var a=Ny(o),c=a.next();!c.done;c=a.next()){var l=c.value;if(l.connectionId===i)return l}}catch(h){n={error:h}}finally{try{c&&!c.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}return null},e.prototype._delayedAbort=function(t,i){var n=this;setTimeout(function(){n._abort(t,i)},0)},e.prototype._abort=function(t,i){pt.default.error("Aborting!"),this.emitError(t,i),this._lastServerId?this.disconnect():this.destroy()},e.prototype.emitError=function(t,i){pt.default.error("Error:",i);var n;typeof i=="string"?n=new Error(i):n=i,n.type=t,this.emit("error",n)},e.prototype.destroy=function(){this.destroyed||(pt.default.log("Destroy peer with ID:".concat(this.id)),this.disconnect(),this._cleanup(),this._destroyed=!0,this.emit("close"))},e.prototype._cleanup=function(){var t,i;try{for(var n=Ny(this._connections.keys()),r=n.next();!r.done;r=n.next()){var o=r.value;this._cleanupPeer(o),this._connections.delete(o)}}catch(a){t={error:a}}finally{try{r&&!r.done&&(i=n.return)&&i.call(n)}finally{if(t)throw t.error}}this.socket.removeAllListeners()},e.prototype._cleanupPeer=function(t){var i,n,r=this._connections.get(t);if(r)try{for(var o=Ny(r),a=o.next();!a.done;a=o.next()){var c=a.value;c.close()}}catch(l){i={error:l}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}},e.prototype.disconnect=function(){if(!this.disconnected){var t=this.id;pt.default.log("Disconnect peer with ID:".concat(t)),this._disconnected=!0,this._open=!1,this.socket.close(),this._lastServerId=t,this._id=null,this.emit("disconnected",t)}},e.prototype.reconnect=function(){if(this.disconnected&&!this.destroyed)pt.default.log("Attempting reconnection to server with ID ".concat(this._lastServerId)),this._disconnected=!1,this._initialize(this._lastServerId);else{if(this.destroyed)throw new Error("This peer cannot reconnect to the server. It has already been destroyed.");if(!this.disconnected&&!this.open)pt.default.error("In a hurry? We're still trying to make the initial connection!");else throw new Error("Peer ".concat(this.id," cannot reconnect because it is not disconnected from the server!"))}},e.prototype.listAllPeers=function(t){var i=this;t===void 0&&(t=function(n){}),this._api.listAllPeers().then(function(n){return t(n)}).catch(function(n){return i._abort(Hn.ServerError,n)})},e.DEFAULT_KEY="peerjs",e}(Pb.EventEmitter),gP=T9.Peer;const _de=Object.freeze(Object.defineProperty({__proto__:null,get Peer(){return pP},default:gP,util:wi},Symbol.toStringTag,{value:"Module"}));let Ik;function xde(){return Ik}function wde(s){Ik=s}function k9(s,e){return e||(e={}),e={...Ik,...e},s?new gP(s,e):new gP(e)}async function Z3(){const s=await Promise.resolve().then(()=>_de);return console.log(s),s.default===void 0?s:s.default}class O9{constructor(){d(this,"_host");d(this,"_client");d(this,"_clientData");this.onEnable()}get isHost(){return this._host!==void 0}onEnable(){const e="HOST-5980e65c-8438-453e-8b35-f13c736dcd81";this.trySetupHost(e)}async trySetupHost(e){const t=await Z3(),i=new t(e);i.on("error",n=>{console.error(n),this._host=void 0,this.trySetupClient(e)}),i.on("open",n=>{this._host=new Sde(i)})}async trySetupClient(e){const t=await Z3();this._client=new t,this._client.on("error",i=>{console.error("Client error",i)}),this._client.on("open",i=>{console.log("client connected",i),this._clientData=this._client.connect(e,{metadata:{id:i}}),this._clientData.on("open",()=>{console.log("Connected to host")}),this._clientData.on("data",n=>{console.log("<<",n)})})}}class Cde{constructor(e){d(this,"_peer");this._peer=e}}class Sde extends Cde{constructor(t){var i;super(t);d(this,"_connections",[]);console.log("I AM THE HOST"),(i=this._peer)==null||i.on("connection",this.onConnection.bind(this)),this._peer.on("close",()=>{this.broadcast("BYE")}),setInterval(()=>{this.broadcast("HELLO")},2e3)}get isHost(){return!0}onConnection(t){console.log("host connection",t),t.on("open",()=>{this._connections.push(t),this.broadcastConnection(t)})}broadcastConnection(t){const i=this._connections.map(n=>{var r;return(r=n.metadata)==null?void 0:r.id}).filter(n=>n!==void 0);this.broadcast({type:"connection-list",connections:i})}broadcast(t){if(t!=null){console.log(">>",t);for(const i in this._peer.connections){const n=this._peer.connections[i];if(n)if(Array.isArray(n))for(const r of n)r&&r.send(t);else console.warn(n)}}}}const $3="https://urls.needle.tools/default-networking-backend/index";let _u="wss://needle-tiny-starter.glitch.me/socket";const Jr=!!ie("debugnet"),v0=!!(Jr||ie("debugowner")),eQ=ie("debugnetbin");var L9=(s=>(s.ConnectionInfo="connection-start-info",s))(L9||{}),Jt=(s=>(s.Join="join-room",s.Leave="leave-room",s.JoinedRoom="joined-room",s.LeftRoom="left-room",s.UserJoinedRoom="user-joined-room",s.UserLeftRoom="user-left-room",s.RoomStateSent="room-state-sent",s))(Jt||{});class Ede{constructor(){d(this,"room");d(this,"viewId");d(this,"allowEditing");d(this,"inRoom")}}class Ide{constructor(){d(this,"room")}}class Mde{constructor(){d(this,"userId")}}var F9=(s=>(s.RequestHasOwner="request-has-owner",s.ResponseHasOwner="response-has-owner",s.RequestIsOwner="request-is-owner",s.ResponseIsOwner="response-is-owner",s.RequestOwnership="request-ownership",s.GainedOwnership="gained-ownership",s.RemoveOwnership="remove-ownership",s.LostOwnership="lost-ownership",s.GainedOwnershipBroadcast="gained-ownership-broadcast",s.LostOwnershipBroadcast="lost-ownership-broadcast",s))(F9||{});class Mk{constructor(e,t){d(this,"guid");d(this,"connection");d(this,"_hasOwnership",!1);d(this,"_isOwned");d(this,"_gainSubscription");d(this,"_lostSubscription");d(this,"_hasOwnerResponse");d(this,"_isWaitingForOwnershipResponseCallback",null);this.connection=e,this.guid=t,this._gainSubscription=this.onGainedOwnership.bind(this),this._lostSubscription=this.onLostOwnership.bind(this),e.beginListen("lost-ownership",this._lostSubscription),e.beginListen("gained-ownership-broadcast",this._gainSubscription),this._hasOwnerResponse=this.onHasOwnerResponse.bind(this),e.beginListen("response-has-owner",this._hasOwnerResponse)}get hasOwnership(){return this._hasOwnership}get isOwned(){return this._isOwned}get isConnected(){return this.connection.isConnected}updateIsOwned(){this.connection.send("request-has-owner",{guid:this.guid})}onHasOwnerResponse(e){e.guid===this.guid&&(this._isOwned=e.value)}requestOwnershipIfNotOwned(){return this._isWaitingForOwnershipResponseCallback!==null?this:(this._isWaitingForOwnershipResponseCallback=this.waitForHasOwnershipRequestResponse.bind(this),this.connection.beginListen("response-has-owner",this._isWaitingForOwnershipResponseCallback),this.connection.send("request-has-owner",{guid:this.guid}),this)}waitForHasOwnershipRequestResponse(e){e.guid===this.guid&&(this._isWaitingForOwnershipResponseCallback&&(this.connection.stopListen("response-has-owner",this._isWaitingForOwnershipResponseCallback),this._isWaitingForOwnershipResponseCallback=null),this._isOwned=e.value,e.value||(v0&&console.log("request ownership",this.guid),this.requestOwnership()))}requestOwnershipAsync(){return new Promise((e,t)=>{this.requestOwnership();let i=0;const n=()=>{if(i++>10)return t("Timeout");setTimeout(()=>{this.hasOwnership?e(this):n()},100)};n()})}requestOwnership(){return v0&&console.log("Request ownership",this.guid),this.connection.send("request-ownership",{guid:this.guid}),this}freeOwnership(){return this.connection.send("remove-ownership",{guid:this.guid}),this._isWaitingForOwnershipResponseCallback&&(this.connection.stopListen("response-has-owner",this._isWaitingForOwnershipResponseCallback),this._isWaitingForOwnershipResponseCallback=null),this}destroy(){this.connection.stopListen("gained-ownership",this._gainSubscription),this.connection.stopListen("lost-ownership",this._lostSubscription),this.connection.stopListen("response-has-owner",this._hasOwnerResponse),this._isWaitingForOwnershipResponseCallback&&(this.connection.stopListen("response-has-owner",this._isWaitingForOwnershipResponseCallback),this._isWaitingForOwnershipResponseCallback=null)}onGainedOwnership(e){e.guid===this.guid&&(this._isOwned=!0,this.connection.connectionId===e.owner?(v0&&console.log("GAINED OWNERSHIP",this.guid),this._hasOwnership=!0):this._hasOwnership=!1)}onLostOwnership(e){e===this.guid&&(v0&&console.log("LOST OWNERSHIP",this.guid),this._hasOwnership=!1,this._isOwned=!1)}}class U9{constructor(e){d(this,"context");d(this,"_peer",null);d(this,"_usersInRoomCopy",[]);d(this,"_defaultMessagesBuffer",[]);d(this,"_defaultMessagesBufferArray",[]);d(this,"netWebSocketUrlProvider");d(this,"_listeners",{});d(this,"_listenersBinary",{});d(this,"connected",!1);d(this,"channelId");d(this,"_connectionId",null);d(this,"_ws");d(this,"_waitingForSocket",{});d(this,"_isInRoom",!1);d(this,"_currentRoomName",null);d(this,"_currentRoomViewId",null);d(this,"_currentRoomAllowEditing",!0);d(this,"_currentInRoom",[]);d(this,"_state",{});d(this,"_currentDelay",-1);d(this,"_connectingToWebsocketPromise",null);this.context=e}get peer(){return this._peer||(this._peer=new O9),this._peer}tryGetState(e){return e==="invalid"?null:this._state[e]}get connectionId(){return this._connectionId}get isDebugEnabled(){return Jr}get isConnected(){return this.connected}get currentRoomName(){return this._currentRoomName}get allowEditing(){return this._currentRoomAllowEditing}get currentRoomViewId(){return this._currentRoomViewId}getViewOnlyUrl(){if(this.currentRoomViewId===null)return null;const e=new URL(window.location.href);return e.searchParams.set("view",this.currentRoomViewId),e.href}get isInRoom(){return this._isInRoom}get currentLatency(){return this._currentDelay}get currentServerUrl(){var e;return((e=this._ws)==null?void 0:e.url)??null}sendPing(){this.send("ping",{time:this.context.time.time})}userIsInRoom(e){return this._currentInRoom.indexOf(e)!==-1}usersInRoom(e=null){e||(e=this._usersInRoomCopy),e.length=0;for(const t of this._currentInRoom)e.push(t);return e}joinRoom(e,t=!1){return e?e.length>1024?(console.error('Room name too long, can not join: "'+e+'". Max length is 1024 characters.'),!1):(this.connect(),Jr&&console.log("join: "+e),this.send("join-room",{room:e,viewOnly:t},Ia.OnConnection),!0):(console.error('Missing room name, can not join: "'+e+'"'),!1)}leaveRoom(e=null){return e||(e=this.currentRoomName),e?(this.send("leave-room",{room:e}),!0):(console.error('Missing room name, can not join: "'+e+'"'),!1)}send(e,t=null,i=Ia.Queued){if(t===null&&(t={}),i===Ia.Queued){this._defaultMessagesBuffer.push({key:e,value:t});return}return this.sendWithWebsocket(e,t,i)}sendDeleteRemoteState(e){this.send("delete-state",{guid:e,dontSave:!0}),delete this._state[e]}sendDeleteRemoteStateAll(){this.send("delete-all-state"),this._state={}}sendBinary(e){var t;eQ&&console.log("<< send binary",this.context.time.frame,e.length/1024+" KB"),(t=this._ws)==null||t.send(e)}sendBufferedMessagesNow(){var i;if(!this._ws)return;this._defaultMessagesBufferArray.length=0;const e=Object.keys(this._defaultMessagesBuffer).length;for(const n in this._defaultMessagesBuffer){const r=this._defaultMessagesBuffer[n];if(e<=1){this.sendWithWebsocket(r.key,r.value,Ia.Immediate);break}const o=this.toMessage(r.key,r.value);this._defaultMessagesBufferArray.push(o)}if(this._defaultMessagesBuffer.length=0,this._defaultMessagesBufferArray.length>0&&Jr&&console.log("SEND BUFFERED",this._defaultMessagesBufferArray.length),this._defaultMessagesBufferArray.length<=0)return;const t=JSON.stringify(this._defaultMessagesBufferArray);(i=this._ws)==null||i.send(t)}beginListen(e,t){return this._listeners[e]||(this._listeners[e]=[]),this._listeners[e].push(t),t}stopListening(e,t){return this.stopListen(e,t)}stopListen(e,t){if(!t||!this._listeners[e])return;const i=this._listeners[e].indexOf(t);i>=0&&this._listeners[e].splice(i,1)}beginListenBinary(e,t){return this._listenersBinary[e]||(this._listenersBinary[e]=[]),this._listenersBinary[e].push(t),t}stopListenBinary(e,t){if(!this._listenersBinary[e])return;const i=this._listenersBinary[e].indexOf(t);i>=0&&this._listenersBinary[e].splice(i,1)}registerProvider(e){this.netWebSocketUrlProvider=e}async connect(){var t;if(this.connected)return Promise.resolve(!0);Jr&&console.log("connecting");const e=(t=this.netWebSocketUrlProvider)==null?void 0:t.getWebsocketUrl();return e?_u=e:lH()&&(_u="wss://"+window.location.host+"/socket"),this.connectWebsocket()}disconnect(){var e;(e=this._ws)==null||e.close(),this._ws=void 0}connectWebsocket(){return this._connectingToWebsocketPromise?this._connectingToWebsocketPromise:this._connectingToWebsocketPromise=new Promise(async(e,t)=>{var c;let i=!1;const n=l=>{i||(i=!0,e(l))};if(_u===void 0&&(console.log("Fetch default backend url: "+$3),_u=await(await fetch($3)).text()),_u===void 0){n(!1);return}console.log(`⊡ Connecting to networking backend on
5235
- `+_u);const r=await Promise.resolve().then(()=>Y_e),o=((c=r.default)==null?void 0:c.WebsocketBuilder)??r.WebsocketBuilder,a=new o(_u).onOpen(()=>{this._connectingToWebsocketPromise=null,this._ws=a,this.connected=!0,console.log(`⊞ Connected to networking backend
5235
+ `+_u);const r=await Promise.resolve().then(()=>X_e),o=((c=r.default)==null?void 0:c.WebsocketBuilder)??r.WebsocketBuilder,a=new o(_u).onOpen(()=>{this._connectingToWebsocketPromise=null,this._ws=a,this.connected=!0,console.log(`⊞ Connected to networking backend
5236
5236
  `+_u),n(!0),this.onSendQueued(Ia.OnConnection)}).onClose(l=>{this._connectingToWebsocketPromise=null,this.connected=!1,this._isInRoom=!1,n(!1)}).onError((l,h)=>{console.error("⊠ Websocket error",l,h),n(!1)}).onRetry(()=>{console.log("Retry connecting to networking websocket")}).build();a.addEventListener(r.WebsocketEvent.message,(l,h)=>{this.onMessage(l,h)})})}onMessage(e,t){const i=t.data;try{if(typeof i!="string"){i.size&&this.handleIncomingBinaryMessage(i);return}const n=JSON.parse(i);if(Array.isArray(n))for(const r of n)this.handleIncomingStringMessage(r);else this.handleIncomingStringMessage(n);return}catch(n){Jr&&i==="pong"?console.log("<<",i):ht()&&console.error("Failed to parse message",n)}}async handleIncomingBinaryMessage(e){eQ&&console.log("<< bin",this.context.time.frame);const t=await e.arrayBuffer();var i=new Uint8Array(t);const n=new zv(i),r=n.getBufferIdentifier(),o=this._listenersBinary[r],a=H5(n),c=V5(a);if(c&&typeof c=="string"&&(this._state[c]=a),!o)return;const l=a??n;for(const h of o)h(l)}handleIncomingStringMessage(e){var n,r;if(Jr&&console.log("<<",e.key??e),e.key)switch(e.key){case"connection-start-info":if(e.data){const c=e.data;c&&(console.assert(c.id!==void 0&&c.id!==null&&c.id.length>0,"server did not send connection id",c.id),console.log("Your id is: "+c.id,this.context.alias??""),this._connectionId=c.id)}else console.warn("Expected connection id in "+e.key);break;case"joined-room":if(Jr&&console.log(e),e){this._isInRoom=!0;const c=e;this._currentRoomName=c.room,this._currentRoomViewId=c.viewId,this._currentRoomAllowEditing=c.allowEditing??!0,this._currentInRoom.length=0,this._currentInRoom.push(...c.inRoom),Jr&&console.log("joined room with",this._currentInRoom,this.context.alias??"");const l=new URL(window.location.href);l.searchParams.has("room")&&l.searchParams.delete("room"),l.searchParams.set("view",this._currentRoomViewId),console.log("Room view id: "+this._currentRoomViewId+`
5237
5237
  `+l.href)}this.onSendQueued(Ia.OnRoomJoin);break;case"left-room":e.room===this.currentRoomName&&(this._isInRoom=!1,this._currentRoomName=null,this._currentInRoom.length=0);break;case"user-joined-room":if(e.data){const c=e.data;this._currentInRoom.push(c.userId),Jr&&console.log(c.userId+" joined","now in room:",this._currentInRoom)}break;case"user-left-room":if(e.data){const c=e.data,l=this._currentInRoom.indexOf(c.userId);l>=0&&(Jr&&console.log(c.userId+" left","now in room:",this._currentInRoom),this._currentInRoom.splice(l,1)),c.userId===this.connectionId&&console.log("you left the room")}break;case"all-room-state-deleted":Jr&&console.log("RECEIVED all-room-state-deleted"),this._state={};break;case"ping":case"pong":const a=(n=e.data)==null?void 0:n.time;a&&(this._currentDelay=this.context.time.time-a),Jr&&console.log("Current latency: "+this._currentDelay.toFixed(1)+" sec","Clients in room: "+((r=this._currentInRoom)==null?void 0:r.length));break}let t=this._listeners[e.key];if(t){t=[...t];for(const o of t)try{o(e.data)}catch(a){console.error('Error invoking callback for "'+e.key+'"',a)}}const i=e.data;i&&(this._state[i.guid]=i)}toMessage(e,t){return{key:e,data:t}}sendWithWebsocket(e,t,i=Ia.OnRoomJoin){if(!this._ws){const r=this._waitingForSocket[i]||[];r.push(()=>this.sendWithWebsocket(e,t,i)),this._waitingForSocket[i]=r;return}const n=JSON.stringify(this.toMessage(e,t));Jr&&console.log(">>",e),this._ws.send(n)}onSendQueued(e){const t=this._waitingForSocket[e];if(t){for(const i of t)i();t.length=0}}}const J0=ie("debugwebxr");class _T{constructor(e,t){d(this,"controllerStates",[]);d(this,"userId");d(this,"context");d(this,"userStateEvtName");d(this,"onReceivedControllerState",e=>{J0&&console.log(`XRSync: Received change for ${this.userId}: ${e.type} ${e.handedness}; tracked=${e.isTracking}`);let t=!1;for(let i=0;i<this.controllerStates.length;i++)if(this.controllerStates[i].index===e.index){this.controllerStates[i]=e,t=!0;break}t||this.controllerStates.push(e)});this.userId=e,this.context=t,this.userStateEvtName="xr-sync-user-state-"+e,this.context.connection.beginListen(this.userStateEvtName,this.onReceivedControllerState)}dispose(){this.context.connection.stopListen(this.userStateEvtName,this.onReceivedControllerState)}update(e){if(this.context.connection.isConnected!=!1){for(let t=this.controllerStates.length-1;t>=0;t--){const i=this.controllerStates[t];let n=!1;for(let r=0;r<e.controllers.length;r++)e.controllers[r].index===i.index&&(n=!0);n||(J0&&console.log(`XRSync: ${i.type} ${i.handedness} removed`,i.index),this.controllerStates.splice(t,1),this.sendControllerRemoved(i))}for(const t of e.controllers)this.updateControllerStates(t)}}onExitXR(e){for(const t of this.controllerStates)this.sendControllerRemoved(t);this.controllerStates.length=0}sendControllerRemoved(e){e.isTracking=!1,e.guid="",this.context.connection.send(this.userStateEvtName,e),this.context.connection.sendDeleteRemoteState(e.guid)}updateControllerStates(e){const t=this.controllerStates.find(i=>i.index===e.index);if(t){let i=!1;i||(i=t.isTracking!=e.isTracking),i&&(t.isTracking=e.isTracking,this.context.connection.send(this.userStateEvtName,t))}else{const i={guid:this.userId+"-"+e.index,isTracking:e.isTracking,handedness:e.side,index:e.index,type:e.hand?"hand":"controller"};this.controllerStates.push(i),this.context.connection.send(this.userStateEvtName,i),J0&&console.log(`XRSync: ${i.type} ${i.handedness} added`,i.index)}}}class N9{constructor(e){d(this,"context");d(this,"onJoinedRoom",()=>{if(this.context.connection.connectionId){this._states.has(this.context.connection.connectionId)||(J0&&console.log("XRSync: Local user joined room",this.context.connection.connectionId),this._states.set(this.context.connection.connectionId,new _T(this.context.connection.connectionId,this.context)));for(const e of this.context.connection.usersInRoom())this._states.has(e)||this._states.set(e,new _T(e,this.context))}});d(this,"onLeftRoom",()=>{if(this.context.connection.connectionId&&!this._states.has(this.context.connection.connectionId)){const e=this._states.get(this.context.connection.connectionId);e==null||e.dispose(),this._states.delete(this.context.connection.connectionId)}});d(this,"onOtherUserJoinedRoom",e=>{const t=e.userId;this._states.has(t)||(J0&&console.log("XRSync: Remote user joined room",t),this._states.set(t,new _T(t,this.context)))});d(this,"onOtherUserLeftRoom",e=>{const t=e.userId;if(!this._states.has(t)){const i=this._states.get(t);i==null||i.dispose(),this._states.delete(t)}});d(this,"_states",new Map);this.context=e,this.context.connection.beginListen(Jt.JoinedRoom,this.onJoinedRoom),this.context.connection.beginListen(Jt.LeftRoom,this.onLeftRoom),this.context.connection.beginListen(Jt.UserJoinedRoom,this.onOtherUserJoinedRoom),this.context.connection.beginListen(Jt.UserLeftRoom,this.onOtherUserLeftRoom)}hasState(e){return e?this._states.has(e):!1}isTracking(e,t){if(!e)return;const i=this._states.get(e);if(!i)return;const n=i.controllerStates.find(r=>r.handedness===t);return(n==null?void 0:n.isTracking)||!1}getDeviceType(e,t){if(!e)return;const i=this._states.get(e);if(!i)return;const n=i.controllerStates.find(r=>r.handedness===t);return(n==null?void 0:n.type)||"unknown"}destroy(){this.context.connection.stopListen(Jt.JoinedRoom,this.onJoinedRoom),this.context.connection.stopListen(Jt.LeftRoom,this.onLeftRoom),this.context.connection.stopListen(Jt.UserJoinedRoom,this.onOtherUserJoinedRoom),this.context.connection.stopListen(Jt.UserLeftRoom,this.onOtherUserLeftRoom)}onUpdate(e){if(this.context.connection.isConnected&&this.context.connection.connectionId){const t=this._states.get(this.context.connection.connectionId);t==null||t.update(e)}}onExitXR(e){if(this.context.connection.isConnected&&this.context.connection.connectionId){const t=this._states.get(this.context.connection.connectionId);t==null||t.onExitXR(e)}}}class tQ{constructor(){d(this,"_fadeToColorQuad");d(this,"_fadeToColorMaterial");d(this,"_requestedFadeValue",0);d(this,"_transitionPromise",null);d(this,"_transitionResolve",null);this._fadeToColorMaterial=new ni({color:0,transparent:!0,depthTest:!1,fog:!1,side:vi}),this._fadeToColorQuad=new pe(new cs(10,10),this._fadeToColorMaterial)}dispose(){this._fadeToColorQuad.geometry.dispose(),this._fadeToColorMaterial.dispose()}update(e,t){const i=this._fadeToColorQuad,n=this._fadeToColorMaterial;i.parent!==e&&n.opacity>0?e.add(i):n.opacity===0&&i.removeFromParent(),i.layers.set(2),i.material=this._fadeToColorMaterial,i.position.z=-1,i.renderOrder=1/0;const r=this._requestedFadeValue;n.opacity=tt.lerp(n.opacity,r,t/.03),Math.abs(n.opacity-r)<=.01&&this._transitionResolve&&(this._transitionResolve(),this._transitionResolve=null,this._transitionPromise=null,this._requestedFadeValue=0)}remove(){this._fadeToColorQuad.removeFromParent()}fadeTransition(){if(this._transitionPromise)return this._transitionPromise;this._requestedFadeValue=1;const e=new Promise(t=>{this._transitionResolve=t});return this._transitionPromise=e,e}}var mp=(s=>(s[s.Quad=0]="Quad",s[s.Cube=1]="Cube",s[s.Sphere=2]="Sphere",s))(mp||{});class Db{static createPrimitive(e,t){let i;switch(e){case"Quad":case 0:{const r=new cs(1,1,1,1),o=(t==null?void 0:t.material)??new Br({color:16777215});t!=null&&t.texture&&"map"in o&&(o.map=t.texture),i=new pe(r,o)}break;case"Cube":case 1:{const r=new Xi(1,1,1),o=(t==null?void 0:t.material)??new Br({color:16777215});t!=null&&t.texture&&"map"in o&&(o.map=t.texture),i=new pe(r,o)}break;case"Sphere":case 2:{const r=new Mc(.5,16,16),o=(t==null?void 0:t.material)??new Br({color:16777215});t!=null&&t.texture&&"map"in o&&(o.map=t.texture),i=new pe(r,o)}break}return this.applyDefaultObjectOptions(i,t),i}static createSprite(e){const i=new cE({color:16777215});e!=null&&e.texture&&"map"in i&&(i.map=e.texture);const n=new wD(i);return this.applyDefaultObjectOptions(n,e),n}static applyDefaultObjectOptions(e,t){t!=null&&t.name&&(e.name=t.name),t!=null&&t.position&&e.position.set(t.position.x,t.position.y,t.position.z),t!=null&&t.rotation&&e.rotation.set(t.rotation.x,t.rotation.y,t.rotation.z),t!=null&&t.scale&&e.scale.set(t.scale.x,t.scale.y,t.scale.z)}}const JO=class{constructor(e,t,i){d(this,"_session");d(this,"_mode");d(this,"_init");d(this,"_renderer");d(this,"_camera");d(this,"_scene");d(this,"onEnd",()=>{var e;(e=this._session)==null||e.removeEventListener("end",this.onEnd),this._renderer.setAnimationLoop(null),this._renderer.dispose(),this._scene.clear()});d(this,"_lastTime",0);d(this,"onFrame",(e,t)=>{const i=e-this._lastTime;this.update(e,i),this._camera.parent!==this._scene&&this._scene.add(this._camera),this._renderer.render(this._scene,this._camera)});d(this,"_objects",[]);this._mode=e,this._init=t,this._session=i,this._session.addEventListener("end",this.onEnd),this._renderer=new Qh({alpha:!0}),this._renderer.setAnimationLoop(this.onFrame),this._renderer.xr.setSession(i),this._renderer.xr.enabled=!0,this._camera=new Nt,this._scene=new rr,this._scene.fog=new aE(4473924,10,250),this._scene.add(this._camera),this.setupScene()}static get active(){return this._active}static async start(e,t){if(this._active)return console.error("Cannot start a new XR session while one is already active"),null;if(this._requestInFlight)return console.error("Cannot start a new XR session while a request is already in flight"),null;if("xr"in navigator&&navigator.xr){if(!t)return console.error("XRSessionInit must be provided"),null;this._requestInFlight=!0;const i=await navigator.xr.requestSession(e,t);return i.addEventListener("end",()=>{this._active=null}),this._requestInFlight?(this._requestInFlight=!1,this._active=new JO(e,t,i),this._active):(i.end(),null)}return null}static async handoff(){return this._active?this._active.handoff():null}static async stop(){this._requestInFlight=!1,this._active&&(await this._active.end(),await _l(100)),this._active=null}get isAR(){return this._mode==="immersive-ar"}end(){return this._session?this._session.end():Promise.resolve()}async handoff(){if(!this._session)throw new Error("Cannot handoff a session that has already ended");const e={session:this._session,mode:this._mode,init:this._init};return await this.onBeforeHandoff(),this.onEnd(),this._session=null,e}async onBeforeHandoff(){await _l(1e3),this._scene.clear()}setupScene(){this._scene.background=new ve(0),this._scene.add(new RE(5,10,1118481,1118481));const e=new cp(16777215,1);e.position.set(0,20,0),e.castShadow=!1,this._scene.add(e);const t=new cp(16777215,1);t.position.set(0,-1,0),t.castShadow=!1,this._scene.add(t);const i=new ap(16777215,1,100,1);i.position.set(0,2,0),i.castShadow=!1,i.distance=200,this._scene.add(i);const n=50;for(let r=0;r<100;r++){const o=new Br({color:2236962,metalness:1,roughness:.8});this.isAR&&(o.emissive=new ve(Math.random(),Math.random(),Math.random()),o.emissiveIntensity=Math.random());const a=tt.random(0,1)>.5?mp.Sphere:mp.Cube,c=Db.createPrimitive(a,{material:o});c.position.x=tt.random(-n,n),c.position.y=tt.random(-2,n),c.position.z=tt.random(-n,n),c.rotation.x=tt.random(0,Math.PI*2),c.rotation.y=tt.random(0,Math.PI*2),c.rotation.z=tt.random(0,Math.PI*2),c.scale.multiplyScalar(.5+Math.random()*10);const l=c.position.distanceTo(this._camera.position)-c.scale.x;l<1&&c.position.multiplyScalar(1+1/l),this._objects.push(c),this._scene.add(c)}}update(e,t){const i=e*4e-4;for(let n=0;n<this._objects.length;n++){const r=this._objects[n];r.position.y+=Math.sin(i+n*.5)*.005,r.rotateY(.002)}}};let Wu=JO;d(Wu,"_active",null),d(Wu,"_requestInFlight",!1);const Cs=ie("debugwebxr"),Tde=ie("stats");function Bde(s){let e=null;const t=s;return t.getAROverlayContainer?e=t.getAROverlayContainer():e=s,e}Rde();async function Rde(){var s;if(ie("debugasap")){let e=globalThis["needle:XRSession"];if(e instanceof Promise){delete globalThis["needle:XRSession"],ui.addContextCreatedCallback(async t=>{if(!e)return;sA(!0);const i=await e;if(i){const n=St.getDefaultSessionInit("immersive-vr");St.setSession("immersive-vr",i,n,t.context)}else console.error("NeedleXRSession: ASAP session was rejected");e=void 0});return}}if("xr"in navigator){if(/WebXRViewer\//i.test(navigator.userAgent)){console.warn("WebXRViewer does not support addEventListener");return}(s=navigator.xr)==null||s.addEventListener("sessiongranted",async()=>{sA(!0),console.log("Received Session Granted..."),await _l(100);const e=sessionStorage.getItem("needle_xr_session_mode"),t=sessionStorage.getItem("needle_xr_session_init")??null,i=t?JSON.parse(t):null;let n=null;if(Q9()&&(await Wu.start(e||"immersive-vr",i||St.getDefaultSessionInit("immersive-vr")),await kde(),n=await Wu.handoff()),n)St.setSession(n.mode,n.session,n.init,Dt.Current);else if(e&&t){console.log("Session Granted: Restore last session");const r=JSON.parse(t);St.start(e,r).catch(o=>console.warn(o))}else St.start("immersive-vr").catch(r=>console.warn("Session Granted failed:",r))},{once:!0})}}function Pde(s,e){sessionStorage.setItem("needle_xr_session_mode",s),sessionStorage.setItem("needle_xr_session_init",JSON.stringify(e))}function Dde(){sessionStorage.removeItem("needle_xr_session_mode"),sessionStorage.removeItem("needle_xr_session_init")}const Tk=new Set;ui.registerCallback(Ti.ContextCreationStart,async s=>{Tk.add(s.context)});ui.registerCallback(Ti.ContextCreated,async s=>{Tk.delete(s.context)});function Q9(){return Tk.size>0}function kde(){return new Promise(s=>{const e=Date.now(),t=setInterval(()=>{(!Q9()||Date.now()-e>6e4)&&(clearInterval(t),s())},100)})}lp()&&ht()&&window.addEventListener("keydown",s=>{(s.key==="x"||s.key==="Escape")&&St.active&&St.stop()});const dh=class{constructor(e,t,i,n){d(this,"context");d(this,"session");d(this,"mode");d(this,"controllers",[]);d(this,"_rigScale",1);d(this,"_lastRigScaleUpdate",-1);d(this,"_rigs",[]);d(this,"_viewerHitTestSource",null);d(this,"_defaultRig");d(this,"_xr_scripts");d(this,"_xr_update_scripts",[]);d(this,"_inactive_scripts",[]);d(this,"_controllerAdded");d(this,"_controllerRemoved");d(this,"_originalCameraWorldPosition");d(this,"_originalCameraWorldRotation");d(this,"_originalCameraWorldScale");d(this,"_originalCameraParent");d(this,"_mainCamera",null);d(this,"onRendererSessionSet",()=>{var e;this.running&&(this.context.renderer.xr.enabled=!0,this.context.renderer.xr.updateCamera(this.context.mainCamera),(e=this.context.mainCameraComponent)==null||e.applyClearFlags())});d(this,"onInputSourceAdded",e=>{if(e.targetRayMode==="screen")return;let t=0;for(let n=0;n<this.session.inputSources.length;n++)if(this.session.inputSources[n]===e){t=n;break}if(this.controllers.find(n=>n.inputSource===e)){console.warn("Controller already exists for input source",t);return}Cs&&console.log("Adding controller",t);const i=new vk(this,e,t);this._newControllers.push(i)});d(this,"_ended",!1);d(this,"_newControllers",[]);d(this,"onEnd",e=>{var n,r,o;if(this._ended)return;this._ended=!0,Cs&&console.log("XR Session ended"),Dde(),this.onAfterRender(),this.revertCustomForward(),this._didStart=!1,this._previousCameraParent=null,wd(this.onBefore,Zi.LateUpdate);const t=this.context.pre_render_callbacks.indexOf(this.onBeforeRender);t>=0&&this.context.pre_render_callbacks.splice(t,1);const i=this.context.post_render_callbacks.indexOf(this.onAfterRender);i>=0&&this.context.post_render_callbacks.splice(i,1),this.context.xr=null,this.context.renderer.xr.enabled=!1,this.context.pre_update_oneshot_callbacks.push(()=>{var a;(a=this.context.mainCameraComponent)==null||a.applyClearFlags()}),Q5({session:this});for(const a of dh._xrEndListeners)a({xr:this});for(let a=0;a<this.controllers.length;a++)this.disconnectInputSource(this.controllers[a].inputSource);for(const a of this._xr_scripts)(n=a==null?void 0:a.onLeaveXR)==null||n.call(a,{xr:this});(r=this.sync)==null||r.onExitXR(this),this.context.mainCamera&&((o=this._originalCameraParent)==null||o.add(this.context.mainCamera),this._originalCameraWorldPosition&&Os(this.context.mainCamera,this._originalCameraWorldPosition),this._originalCameraWorldRotation&&Na(this.context.mainCamera,this._originalCameraWorldRotation),this._originalCameraWorldScale&&nA(this.context.mainCamera,this._originalCameraWorldScale)),this.context.requestSizeUpdate(),this._defaultRig.gameObject.removeFromParent(),sA(!1)});d(this,"_didStart",!1);d(this,"onBefore",e=>{var n,r,o,a,c,l,h,u;const t=e.xrFrame;if(!t)return;this.context.xr=this,this.context.mainCameraComponent&&this.context.mainCameraComponent!==this._mainCamera&&(this._mainCamera=this.context.mainCameraComponent),((n=this.rig)==null?void 0:n.isActive)==!1&&(Cs&&console.warn("Latest rig is not active - trying to activate a different rig",this.rig),this.updateActiveXRRig()),this.rig&&((r=this._mainCamera)!=null&&r.gameObject)&&((a=(o=this._mainCamera)==null?void 0:o.gameObject)==null?void 0:a.parent)!==this.rig.gameObject&&this.rig.gameObject.add((c=this._mainCamera)==null?void 0:c.gameObject),this.internalUpdateState(),this.applyCustomForward();const i={xr:this};if(this._didStart){if(this.context.new_scripts_xr.length>0){const f=[...this.context.new_scripts_xr];for(let p=0;p<f.length;p++){const g=this.context.new_scripts_xr[p];if(!g||g.destroyed||((l=g.supportsXR)==null?void 0:l.call(g,this.mode))==!1){this.context.new_scripts_xr.splice(p,1);continue}if(!g.activeAndEnabled){this.context.new_scripts_xr.splice(p,1),this.markInactive(g);continue}if(this.addScript(g)){this.invokeCallback_EnterXR(g);for(const y of this.controllers)this.invokeCallback_ControllerAdded(g,y)}}}}else{this._didStart=!0,N5({session:this});for(const p of dh._xrStartListeners)p(i);const f=[...this._xr_scripts];Cs&&console.log("NeedleXRSession start, handle scripts:",f);for(const p of f){if(p.destroyed){this._script_to_remove.push(p);continue}if(!p.activeAndEnabled){this.markInactive(p);continue}this.invokeCallback_EnterXR(p);for(const g of this.controllers)this.invokeCallback_ControllerAdded(p,g)}}this.syncCameraCullingMask();for(const f of this.controllers)f.onUpdate(t);if(this._newControllers.length>0){const f=[...this._newControllers];this._newControllers.length=0;for(const p of f)if(p.connected){this.controllers.push(p);for(const g of this._xr_scripts){if(g.destroyed){this._script_to_remove.push(g);continue}g.activeAndEnabled!==!1&&this.invokeCallback_ControllerAdded(g,p)}}this.controllers.sort((p,g)=>p.index-g.index)}for(const f of this._xr_update_scripts){if(f.destroyed===!0){this._script_to_remove.push(f);continue}if(f.activeAndEnabled===!1){this.markInactive(f);continue}f.onUpdateXR&&f.onUpdateXR(i)}if(this.handleInactiveScripts(),this._script_to_remove.length>0){const f=[...new Set(this._script_to_remove)];this._script_to_remove.length=0;for(const p of f)!p.destroyed&&this.running&&((h=p.onLeaveXR)==null||h.call(p,i)),this.removeScript(p)}(u=this.sync)==null||u.onUpdate(this),this.onRenderDebug()});d(this,"onBeforeRender",()=>{this.context.mainCamera&&this.updateFade(this.context.mainCamera)});d(this,"onAfterRender",()=>{if(this.onUpdateFade_PostRender(),lp()){const e=this.context.renderer;if(e.xr.isPresenting&&this.context.mainCamera){const t=e.xr.enabled,i=e.getRenderTarget();e.xr.enabled=!1,e.setRenderTarget(null),e.render(this.context.scene,this.context.mainCamera),e.xr.enabled=t,e.setRenderTarget(i)}}});d(this,"_script_to_remove",[]);d(this,"_camera");d(this,"_cameraRenderParent",new ye().rotateY(Math.PI));d(this,"_previousCameraParent");d(this,"_customforward",!0);d(this,"originalCameraNearPlane");d(this,"_viewerPose");d(this,"_transformOrientation",new Se);d(this,"_transformPosition",new C);d(this,"_transition");var r,o;Pde(e,n.init),this.session=t,this.mode=e,this.context=i,(Cs||ie("console"))&&sA(!0),this._xr_scripts=[...n.scripts],this._xr_update_scripts=this._xr_scripts.filter(a=>typeof a.onUpdateXR=="function"),this._controllerAdded=n.controller_added,this._controllerRemoved=n.controller_removed,xd(this.onBefore,Zi.LateUpdate),this.context.pre_render_callbacks.push(this.onBeforeRender),this.context.post_render_callbacks.push(this.onAfterRender),((r=n.init.optionalFeatures)!=null&&r.includes("hit-test")||(o=n.init.requiredFeatures)!=null&&o.includes("hit-test"))&&t.requestReferenceSpace("viewer").then(a=>{var c,l;return(l=(c=t.requestHitTestSource)==null?void 0:c.call(t,{space:a}))==null?void 0:l.then(h=>this._viewerHitTestSource=h)}).catch(a=>console.warn(a)),this.context.mainCamera&&(this._originalCameraWorldPosition=Ot(this.context.mainCamera,new C),this._originalCameraWorldRotation=Fi(this.context.mainCamera,new Se),this._originalCameraWorldScale=Ji(this.context.mainCamera,new C),this._originalCameraParent=this.context.mainCamera.parent),this._defaultRig=new Fue,this.context.scene.add(this._defaultRig.gameObject),this.addRig(this._defaultRig);for(let a=0;a<t.inputSources.length;a++){const c=t.inputSources[a];if(!c.handedness){console.warn("Input source in xr session has no handedness - ignoring",a);continue}this.onInputSourceAdded(c)}this.session.addEventListener("end",this.onEnd),this.session.addEventListener("inputsourceschange",a=>{for(const c of a.removed)this.disconnectInputSource(c);for(const c of a.added)this.onInputSourceAdded(c)}),this.context.xr=this,this.context.renderer.xr.setSession(this.session).then(this.onRendererSessionSet)}static getXRSync(e){return this._sync||(this._sync=new N9(e)),this._sync}static get currentSessionRequest(){return this._currentSessionRequestMode}static get active(){return this._activeSession}static get activeMode(){var e;return((e=this._activeSession)==null?void 0:e.mode)??null}static get xrSystem(){return"xr"in navigator?navigator.xr:void 0}static isXRSupported(){return Promise.all([this.isVRSupported(),this.isARSupported()]).then(e=>e.some(t=>t)).catch(()=>!1)}static isVRSupported(){return this.isSessionSupported("immersive-vr")}static isARSupported(){return this.isSessionSupported("immersive-ar")}static isSessionSupported(e){var t;return((t=this.xrSystem)==null?void 0:t.isSessionSupported(e).catch(i=>(Cs&&console.error(i),!1)))??Promise.resolve(!1)}static onSessionRequestStart(e){this._sessionRequestStartListeners.push(e)}static offSessionRequestStart(e){const t=this._sessionRequestStartListeners.indexOf(e);t>=0&&this._sessionRequestStartListeners.splice(t,1)}static onSessionRequestEnd(e){this._sessionRequestEndListeners.push(e)}static offSessionRequestEnd(e){const t=this._sessionRequestEndListeners.indexOf(e);t>=0&&this._sessionRequestEndListeners.splice(t,1)}static onXRSessionStart(e){this._xrStartListeners.push(e)}static offXRSessionStart(e){const t=this._xrStartListeners.indexOf(e);t>=0&&this._xrStartListeners.splice(t,1)}static onXRSessionEnd(e){this._xrEndListeners.push(e)}static offXRSessionEnd(e){const t=this._xrEndListeners.indexOf(e);t>=0&&this._xrEndListeners.splice(t,1)}static onControllerAdded(e){this._controllerAddedListeners.push(e)}static offControllerAdded(e){const t=this._controllerAddedListeners.indexOf(e);t>=0&&this._controllerAddedListeners.splice(t,1)}static onControllerRemoved(e){this._controllerRemovedListeners.push(e)}static offControllerRemoved(e){const t=this._controllerRemovedListeners.indexOf(e);t>=0&&this._controllerRemovedListeners.splice(t,1)}static offerSession(e,t,i){return"xr"in navigator&&navigator.xr&&"offerSession"in navigator.xr?(typeof navigator.xr.offerSession=="function"&&(console.log("WebXR offerSession is available - requesting mode: "+e),t=="default"&&(t=this.getDefaultSessionInit(e)),navigator.xr.offerSession(e,{...t}).then(n=>dh.setSession(e,n,t,i)).catch(n=>{console.log("XRSession offer rejected (perhaps because another call to offerSession was made or a call to requestSession was made)")})),!0):!1}static getDefaultSessionInit(e){switch(e){case"immersive-ar":return{optionalFeatures:["anchors","local-floor","hand-tracking","layers","dom-overlay","hit-test"]};case"immersive-vr":return{optionalFeatures:["local-floor","bounded-floor","hand-tracking","high-fixed-foveation-level","layers"]};default:return console.warn("No default session init for mode",e),{}}}static async start(e,t,i){var o,a,c,l;if(ht()&&ie("debugxrpreroom"))return console.warn("Debug: Starting temporary XR session"),await Wu.start(e,t||dh.getDefaultSessionInit(e)),null;if(this._currentSessionRequest)return console.warn("A XRSession is already being requested"),(Cs||ht())&&Ni("A XRSession is already being requested"),this._currentSessionRequest.then(()=>this._activeSession);if(this._activeSession)return console.error("A XRSession is already running"),this._activeSession;if(i||(i=Dt.Current),i||(i=ui.All[0]),!i)throw new Error("No Needle Engine Context found");switch(t||(t={}),e){case"immersive-ar":{if(await((o=this.xrSystem)==null?void 0:o.isSessionSupported("immersive-ar"))!==!0)return console.error(e+" is not supported by this browser."),null;const u=this.getDefaultSessionInit(e),f=Bde(i.domElement);f&&!DE()&&(u.domOverlay={root:f},u.optionalFeatures.push("dom-overlay")),t={...u,...t}}break;case"immersive-vr":{if(await((a=this.xrSystem)==null?void 0:a.isSessionSupported("immersive-vr"))!==!0)return console.error(e+" is not supported by this browser."),null;t={...this.getDefaultSessionInit(e),...t}}break;default:console.warn("No default session init for mode",e);break}t.optionalFeatures??(t.optionalFeatures=[]),t.requiredFeatures??(t.requiredFeatures=[]),await Wu.stop();const n=e=="immersive-ar"?i.scripts_immersive_ar:i.scripts_immersive_vr;Cs?console.log(`%cRequesting ${e} session`,"font-weight:bold;",t,n):console.log(`%cRequesting ${e} session`,"font-weight:bold;");for(const h of n)h.onBeforeXR&&h.onBeforeXR(e,t);for(const h of this._sessionRequestStartListeners)h({mode:e,init:t});Cs&&pn("Requesting "+e+" session ("+Date.now()+")"),this._currentSessionRequest=(c=navigator.xr)==null?void 0:c.requestSession(e,t),this._currentSessionRequestMode=e;const r=await((l=this._currentSessionRequest)==null?void 0:l.catch(h=>{console.error(h,"Code: "+h.code),h.code===9&&Ni("Make sure your device has the required permissions (e.g. camera access)"),console.log("If the specified XR configuration is not supported (e.g. entering AR doesnt work) - make sure you access the website on a secure connection (HTTPS) and your device has the required permissions (e.g. camera access)"),location.protocol==="http:"&&Ni("XR requires a secure connection (HTTPS)")}));this._currentSessionRequest=void 0,this._currentSessionRequestMode=null;for(const h of this._sessionRequestEndListeners)h({mode:e,init:t,newSession:r||null});return r?this.setSession(e,r,t,i):(console.warn("XR Session request was rejected"),null)}static setSession(e,t,i,n){if(this._activeSession)return console.error("A XRSession is already running"),this._activeSession;const r=e=="immersive-ar"?n.scripts_immersive_ar:n.scripts_immersive_vr;return this._activeSession=new dh(e,t,n,{scripts:r,controller_added:this._controllerAddedListeners,controller_removed:this._controllerRemovedListeners,init:i}),t.addEventListener("end",this.onEnd),Cs?console.log(`%cStarted ${e} session`,"font-weight:bold;",r):console.log(`%cStarted ${e} session`,"font-weight:bold;"),this._activeSession}static stop(){var e;(e=this._activeSession)==null||e.end()}get sync(){return dh._sync}get running(){return!this._ended&&this.session!=null}get interactionMode(){return this.session.interactionMode}get visibilityState(){return this.session.visibilityState}get environmentBlendMode(){return this.session.environmentBlendMode}get frame(){return this.context.xrFrame}get leftController(){return this.controllers.find(e=>e.isLeft)}get rightController(){return this.controllers.find(e=>e.isRight)}getController(e){return typeof e=="number"?this.controllers[e]||null:this.controllers.find(t=>t.side===e)||null}get isPassThrough(){return!!(this.environmentBlendMode!=="opaque"&&this.interactionMode==="world-space"||this.mode==="immersive-ar"&&this.environmentBlendMode!=="opaque"&&this.controllers.some(e=>e.inputSource.targetRayMode==="tracked-pointer")||ht()&&lp()&&this.mode==="immersive-ar")}get isAR(){return this.mode==="immersive-ar"}get isVR(){return this.mode==="immersive-vr"}get isScreenBasedAR(){return this.isAR&&!this.isPassThrough}get posePosition(){return this._transformPosition}get poseOrientation(){return this._transformOrientation}get referenceSpace(){return this.context.renderer.xr.getReferenceSpace()}get viewerPose(){return this._viewerPose}get isTrackingImages(){if(this.frame&&"getImageTrackingResults"in this.frame&&typeof this.frame.getImageTrackingResults=="function")try{const e=this.frame.getImageTrackingResults();for(const t of e)if(t.trackingState==="tracked")return!0}catch{return!1}return!1}get rig(){const e=this._rigs[0]??null;return e!=null&&e.gameObject&&Ap(e.gameObject)||(e==null?void 0:e.isActive)===!1?(this.updateActiveXRRig(),this._rigs[0]??null):e}get rigScale(){return this._rigs[0]?(this._lastRigScaleUpdate!==this.context.time.frame&&(this._lastRigScaleUpdate=this.context.time.frame,this._rigScale=this._rigs[0].gameObject.worldScale.x),this._rigScale):1}addRig(e){this._rigs.indexOf(e)>=0||(e.priority===void 0&&(e.priority=0),this._rigs.push(e),this.updateActiveXRRig())}removeRig(e){const t=this._rigs.indexOf(e);t!==-1&&(this._rigs.splice(t,1),this.updateActiveXRRig())}setRigActive(e){const t=this._rigs.indexOf(e);this._rigs.splice(t,1),this._rigs.unshift(e),this.updateActiveXRRig()}updateActiveXRRig(){const e=this._rigs[0]??null;this._defaultRig.gameObject.parent!==this.context.scene&&this.context.scene.add(this._defaultRig.gameObject),this._defaultRig.gameObject.visible=!0,this._rigs.includes(this._defaultRig)||this._rigs.push(this._defaultRig);let t=this._rigs[0];t&&t.priority===void 0&&(t.priority=0);for(let i=1;i<this._rigs.length;i++){const n=this._rigs[i];if(n.isActive){if(Ap(n.gameObject)){this._rigs.splice(i,1),i--;continue}(!t||t.isActive===!1||n.priority!==void 0&&n.priority>t.priority)&&(t=n)}}if(e!==t){const i=this._rigs.indexOf(t);i>=0&&this._rigs.splice(i,1),this._rigs.unshift(t)}Cs&&(e===t?console.log("Updated Active XR Rig:",t,"prev:",e):console.log("Updated Active XRRig:",t," (the same as before)"))}getHitTest(e){if(e)return this.getControllerHitTest(e);if(!this._viewerHitTestSource)return null;const t=this._viewerHitTestSource,i=this.frame.getHitTestResults(t);if(i.length>0){const n=i[0];return this.convertHitTestResult(n)}return null}getControllerHitTest(e){const t=e.hitTestSource;if(!t)return null;const i=this.frame.getHitTestResultsForTransientInput(t);for(const n of i)if(n.inputSource===e.inputSource)for(const r of n.results)return this.convertHitTestResult(r);return null}convertHitTestResult(e){const t=this.context.renderer.xr.getReferenceSpace(),i=t&&e.getPose(t);if(i){const n=kn(i.transform.position),r=Rf(i.transform.orientation),o=this.context.mainCamera;if((o==null?void 0:o.parent)!==this._cameraRenderParent&&n.applyMatrix4(yS),o!=null&&o.parent){n.applyMatrix4(o.parent.matrixWorld),r.multiply(Ca);const a=Fi(o.parent);a.premultiply(Ca),r.premultiply(a)}return{hit:e,position:n,quaternion:r}}return null}convertSpace(e){const t=kn(e.position);t.applyMatrix4(yS);const i=Rf(e.orientation);return i.premultiply(Ca),{position:t,quaternion:i}}disconnectInputSource(e){const t=(i,n,r)=>{if(i.inputSource===e){Cs&&console.log("Disconnecting controller",i.index),this.controllers.splice(r,1),this.invokeControllerEvent(i,this._controllerRemoved,"removed");const o={xr:this,controller:i,change:"removed"};for(const a of this._xr_scripts)a.onXRControllerRemoved&&a.onXRControllerRemoved(o);i.onDisconnected()}};for(let i=this.controllers.length-1;i>=0;i--){const n=this.controllers[i];t(n,this.controllers,i)}for(let i=this._newControllers.length-1;i>=0;i--){const n=this._newControllers[i];t(n,this._newControllers,i)}}end(){this._ended||this.session.end().catch(e=>console.warn(e))}onRenderDebug(){if(Cs)for(const e of this.controllers)e.onRenderDebug();if((Cs||Tde)&&this.rig){const e=this.rig.gameObject.worldPosition,t=this.rig.gameObject.worldForward;e.add(t.multiplyScalar(1.5));const i=this.rig.gameObject.worldUp;e.add(i.multiplyScalar(2.5));let n="";if(n+=this.context.time.smoothedFps.toFixed(1),Cs)for(const r of this.controllers)n+=`
5238
5238
  ${r.hand?"hand":"ctrl"} ${r.inputSource.handedness}[${r.index}] con:${r.connected} tr:${r.isTracking}`;vt.DrawLabel(e,n)}}addScript(e){return this._xr_scripts.includes(e)?!1:(Cs&&console.log("Register new XRScript",e),this._xr_scripts.push(e),typeof e.onUpdateXR=="function"&&this._xr_update_scripts.push(e),!0)}markInactive(e){if(!(this._inactive_scripts.indexOf(e)>=0)){this.removeScript(e,!1),this._inactive_scripts.push(e);for(const t of this.controllers)this.invokeCallback_ControllerRemoved(e,t);this.invokeCallback_LeaveXR(e)}}handleInactiveScripts(){if(this._inactive_scripts.length>0)for(let e=this._inactive_scripts.length-1;e>=0;e--){const t=this._inactive_scripts[e];if(t.activeAndEnabled){this._inactive_scripts.splice(e,1),this.addScript(t),this.invokeCallback_EnterXR(t);for(const i of this.controllers)this.invokeCallback_ControllerAdded(t,i)}}}removeScript(e,t=!0){Cs&&console.log("Remove XRScript",e);const i=this._xr_scripts.indexOf(e);i>=0&&this._xr_scripts.splice(i,1);const n=this._xr_update_scripts.indexOf(e);if(n>=0&&this._xr_update_scripts.splice(n,1),t){const r=this._inactive_scripts.indexOf(e);r>=0&&this._inactive_scripts.splice(r,1)}}invokeCallback_EnterXR(e){e.onEnterXR&&e.onEnterXR({xr:this})}invokeCallback_ControllerAdded(e,t){e.onXRControllerAdded&&e.onXRControllerAdded({xr:this,controller:t,change:"added"})}invokeCallback_ControllerRemoved(e,t){e.onXRControllerRemoved&&e.onXRControllerRemoved({xr:this,controller:t,change:"removed"})}invokeCallback_LeaveXR(e){e.onLeaveXR&&!e.destroyed&&e.onLeaveXR({xr:this})}syncCameraCullingMask(){var i;const e=this.context.xrCamera,t=(i=this.context.mainCameraComponent)==null?void 0:i.cullingMask;if(e&&t!==void 0){for(const n of e.cameras)n.layers.mask=t;e.layers.mask=t}else if(e){for(const n of e.cameras)n.layers.enableAll();e.layers.enableAll()}}invokeControllerEvent(e,t,i){for(let n=t.length-1;n>=0;n--){const r=t[n];if(r)try{r({xr:this,controller:e,change:i})}catch(o){console.error(o)}}}applyCustomForward(){var e;if(this.context.mainCamera&&this._customforward){this._camera=this.context.mainCamera,this._camera.parent!==this._cameraRenderParent&&(this._previousCameraParent=this._camera.parent,(e=this._previousCameraParent)==null||e.add(this._cameraRenderParent)),this._cameraRenderParent.name="XR Camera Render Parent",this._cameraRenderParent.add(this._camera);let t=.02;if(this.rig){const i=Ji(this.rig.gameObject);t*=i.x}this._camera instanceof Nt&&this._camera.near>t&&(this.originalCameraNearPlane=this._camera.near,this._camera.near=t)}}revertCustomForward(){this._camera&&this._previousCameraParent&&this._previousCameraParent.add(this._camera),this._previousCameraParent=null,this._camera instanceof Nt&&this.originalCameraNearPlane!=null&&(this._camera.near=this.originalCameraNearPlane)}internalUpdateState(){const e=this.context.renderer.xr.getReferenceSpace();if(!e){this._viewerPose=void 0;return}if(this._viewerPose=this.frame.getViewerPose(e),this._viewerPose){const t=this._viewerPose.transform;this._transformPosition.set(t.position.x,t.position.y,t.position.z),this._transformOrientation.set(t.orientation.x,t.orientation.y,t.orientation.z,t.orientation.w)}}get transition(){return this._transition||(this._transition=new tQ),this._transition}fadeTransition(){return this._transition||(this._transition=new tQ),this._transition.fadeTransition()}updateFade(e){this._transition&&e instanceof Nt&&this._transition.update(e,this.context.time.deltaTime)}onUpdateFade_PostRender(){var e;(e=this._transition)==null||e.remove()}};let St=dh;d(St,"_sync",null),d(St,"_currentSessionRequestMode",null),d(St,"_currentSessionRequest"),d(St,"_activeSession"),d(St,"_sessionRequestStartListeners",[]),d(St,"_sessionRequestEndListeners",[]),d(St,"_xrStartListeners",[]),d(St,"_xrEndListeners",[]),d(St,"_controllerAddedListeners",[]),d(St,"_controllerRemovedListeners",[]),d(St,"onEnd",()=>{Cs&&console.log("XR Session ended"),dh._activeSession=null});const xT=ie("debugwebxr");class z9{static tryFindAvatarObjects(e,t,i){if(i.head&&i.leftHand&&i.rightHand)return;const n=e.name.toLocaleLowerCase();!i.head&&n.includes("head")&&(xT&&console.log("FOUND AVATAR HEAD",e.name),i.head=new $t("",t,e)),n.includes("hand")&&(!i.leftHand&&n.includes("left")&&(xT&&console.log("FOUND AVATAR LEFT HAND",e.name),i.leftHand=new $t("",t,e)),!i.rightHand&&n.includes("right")&&(xT&&console.log("FOUND AVATAR RIGHT HAND",e.name),i.rightHand=new $t("",t,e)));for(let r=0;r<e.children.length;r++){if(i.head&&i.leftHand&&i.rightHand)return;const o=e.children[r];this.tryFindAvatarObjects(o,t,i)}}}var _S=(s=>(s.Visible="application-visible",s.Hidden="application-hidden",s.MuteChanged="application-mutechanged",s))(_S||{});let xS=!1;const wm=[];function MA(){if(xS)return;ht()&&console.debug("User interaction registered: audio can now be played"),xS=!0;const s=[...wm];wm.length=0,s.forEach(e=>e())}document.addEventListener("pointerdown",MA);document.addEventListener("click",MA);document.addEventListener("dragstart",MA);document.addEventListener("touchstart",MA);document.addEventListener("keydown",MA);St.onXRSessionStart(()=>{MA()});const KO=class extends EventTarget{constructor(t){super();d(this,"_mute",!1);d(this,"context");d(this,"_isVisible",!0);this.context=t,window.addEventListener("visibilitychange",this.onVisiblityChanged.bind(this),!1)}static get userInteractionRegistered(){return xS}static registerWaitForInteraction(t){if(t!==null){if(xS){t();return}wm.indexOf(t)===-1&&wm.push(t)}}static unregisterWaitForInteraction(t){const i=wm.indexOf(t);i!==-1&&wm.splice(i,1)}get muted(){return this._mute}set muted(t){t!==this._mute&&(this._mute=t,this.dispatchEvent(new Event("application-mutechanged")))}get hasFocus(){return document.hasFocus()}get isVisible(){return this._isVisible}onVisiblityChanged(t){switch(t.target.visibilityState){case"hidden":this._isVisible=!1,this.dispatchEvent(new Event("application-hidden"));break;case"visible":this._isVisible=!0,this.dispatchEvent(new Event("application-visible"));break}}};let gl=KO;d(gl,"registerWaitForAllowAudio",KO.registerWaitForInteraction);function*G9(s,e=null){const t=e?e.time:Dt.Current.time,i=t.time;for(;t.time-i<s;)yield}function*Ode(s){for(let e=0;e<s;e++)yield}function*H9(s){let e=!0;for(s.then(()=>e=!1),s.catch(()=>e=!1);e;)yield}class Hv extends ND{constructor(e){super(e),this.type=Cn}parse(e){const R=Math.pow(2.7182818,2.2);function S(P,Q){let Z=0;for(let z=0;z<65536;++z)(z==0||P[z>>3]&1<<(z&7))&&(Q[Z++]=z);const B=Z-1;for(;Z<65536;)Q[Z++]=0;return B}function T(P){for(let Q=0;Q<16384;Q++)P[Q]={},P[Q].len=0,P[Q].lit=0,P[Q].p=null}const F={l:0,c:0,lc:0};function U(P,Q,Z,B,z){for(;Z<P;)Q=Q<<8|Xe(B,z),Z+=8;Z-=P,F.l=Q>>Z&(1<<P)-1,F.c=Q,F.lc=Z}const k=new Array(59);function H(P){for(let Z=0;Z<=58;++Z)k[Z]=0;for(let Z=0;Z<65537;++Z)k[P[Z]]+=1;let Q=0;for(let Z=58;Z>0;--Z){const B=Q+k[Z]>>1;k[Z]=Q,Q=B}for(let Z=0;Z<65537;++Z){const B=P[Z];B>0&&(P[Z]=B|k[B]++<<6)}}function D(P,Q,Z,B,z,V){const Y=Q;let J=0,fe=0;for(;B<=z;B++){if(Y.value-Q.value>Z)return!1;U(6,J,fe,P,Y);const he=F.l;if(J=F.c,fe=F.lc,V[B]=he,he==63){if(Y.value-Q.value>Z)throw new Error("Something wrong with hufUnpackEncTable");U(8,J,fe,P,Y);let _e=F.l+6;if(J=F.c,fe=F.lc,B+_e>z+1)throw new Error("Something wrong with hufUnpackEncTable");for(;_e--;)V[B++]=0;B--}else if(he>=59){let _e=he-59+2;if(B+_e>z+1)throw new Error("Something wrong with hufUnpackEncTable");for(;_e--;)V[B++]=0;B--}}H(V)}function L(P){return P&63}function N(P){return P>>6}function W(P,Q,Z,B){for(;Q<=Z;Q++){const z=N(P[Q]),V=L(P[Q]);if(z>>V)throw new Error("Invalid table entry");if(V>14){const Y=B[z>>V-14];if(Y.len)throw new Error("Invalid table entry");if(Y.lit++,Y.p){const J=Y.p;Y.p=new Array(Y.lit);for(let fe=0;fe<Y.lit-1;++fe)Y.p[fe]=J[fe]}else Y.p=new Array(1);Y.p[Y.lit-1]=Q}else if(V){let Y=0;for(let J=1<<14-V;J>0;J--){const fe=B[(z<<14-V)+Y];if(fe.len||fe.p)throw new Error("Invalid table entry");fe.len=V,fe.lit=Q,Y++}}}return!0}const X={c:0,lc:0};function se(P,Q,Z,B){P=P<<8|Xe(Z,B),Q+=8,X.c=P,X.lc=Q}const ae={c:0,lc:0};function Ie(P,Q,Z,B,z,V,Y,J,fe){if(P==Q){B<8&&(se(Z,B,z,V),Z=X.c,B=X.lc),B-=8;let he=Z>>B;if(he=new Uint8Array([he])[0],J.value+he>fe)return!1;const _e=Y[J.value-1];for(;he-- >0;)Y[J.value++]=_e}else if(J.value<fe)Y[J.value++]=P;else return!1;ae.c=Z,ae.lc=B}function ne(P){return P&65535}function me(P){const Q=ne(P);return Q>32767?Q-65536:Q}const Ce={a:0,b:0};function Oe(P,Q){const Z=me(P),z=me(Q),V=Z+(z&1)+(z>>1),Y=V,J=V-z;Ce.a=Y,Ce.b=J}function We(P,Q){const Z=ne(P),B=ne(Q),z=Z-(B>>1)&65535,V=B+z-32768&65535;Ce.a=V,Ce.b=z}function He(P,Q,Z,B,z,V,Y){const J=Y<16384,fe=Z>z?z:Z;let he=1,_e,Pe;for(;he<=fe;)he<<=1;for(he>>=1,_e=he,he>>=1;he>=1;){Pe=0;const ke=Pe+V*(z-_e),je=V*he,Je=V*_e,$e=B*he,ct=B*_e;let Et,bi,Vt,Tt;for(;Pe<=ke;Pe+=Je){let ki=Pe;const wt=Pe+B*(Z-_e);for(;ki<=wt;ki+=ct){const zi=ki+$e,Nr=ki+je,an=Nr+$e;J?(Oe(P[ki+Q],P[Nr+Q]),Et=Ce.a,Vt=Ce.b,Oe(P[zi+Q],P[an+Q]),bi=Ce.a,Tt=Ce.b,Oe(Et,bi),P[ki+Q]=Ce.a,P[zi+Q]=Ce.b,Oe(Vt,Tt),P[Nr+Q]=Ce.a,P[an+Q]=Ce.b):(We(P[ki+Q],P[Nr+Q]),Et=Ce.a,Vt=Ce.b,We(P[zi+Q],P[an+Q]),bi=Ce.a,Tt=Ce.b,We(Et,bi),P[ki+Q]=Ce.a,P[zi+Q]=Ce.b,We(Vt,Tt),P[Nr+Q]=Ce.a,P[an+Q]=Ce.b)}if(Z&he){const zi=ki+je;J?Oe(P[ki+Q],P[zi+Q]):We(P[ki+Q],P[zi+Q]),Et=Ce.a,P[zi+Q]=Ce.b,P[ki+Q]=Et}}if(z&he){let ki=Pe;const wt=Pe+B*(Z-_e);for(;ki<=wt;ki+=ct){const zi=ki+$e;J?Oe(P[ki+Q],P[zi+Q]):We(P[ki+Q],P[zi+Q]),Et=Ce.a,P[zi+Q]=Ce.b,P[ki+Q]=Et}}_e=he,he>>=1}return Pe}function mt(P,Q,Z,B,z,V,Y,J,fe){let he=0,_e=0;const Pe=Y,ke=Math.trunc(B.value+(z+7)/8);for(;B.value<ke;)for(se(he,_e,Z,B),he=X.c,_e=X.lc;_e>=14;){const Je=he>>_e-14&16383,$e=Q[Je];if($e.len)_e-=$e.len,Ie($e.lit,V,he,_e,Z,B,J,fe,Pe),he=ae.c,_e=ae.lc;else{if(!$e.p)throw new Error("hufDecode issues");let ct;for(ct=0;ct<$e.lit;ct++){const Et=L(P[$e.p[ct]]);for(;_e<Et&&B.value<ke;)se(he,_e,Z,B),he=X.c,_e=X.lc;if(_e>=Et&&N(P[$e.p[ct]])==(he>>_e-Et&(1<<Et)-1)){_e-=Et,Ie($e.p[ct],V,he,_e,Z,B,J,fe,Pe),he=ae.c,_e=ae.lc;break}}if(ct==$e.lit)throw new Error("hufDecode issues")}}const je=8-z&7;for(he>>=je,_e-=je;_e>0;){const Je=Q[he<<14-_e&16383];if(Je.len)_e-=Je.len,Ie(Je.lit,V,he,_e,Z,B,J,fe,Pe),he=ae.c,_e=ae.lc;else throw new Error("hufDecode issues")}return!0}function st(P,Q,Z,B,z,V){const Y={value:0},J=Z.value,fe=dt(Q,Z),he=dt(Q,Z);Z.value+=4;const _e=dt(Q,Z);if(Z.value+=4,fe<0||fe>=65537||he<0||he>=65537)throw new Error("Something wrong with HUF_ENCSIZE");const Pe=new Array(65537),ke=new Array(16384);T(ke);const je=B-(Z.value-J);if(D(P,Z,je,fe,he,Pe),_e>8*(B-(Z.value-J)))throw new Error("Something wrong with hufUncompress");W(Pe,fe,he,ke),mt(Pe,ke,P,Z,_e,he,V,z,Y)}function q(P,Q,Z){for(let B=0;B<Z;++B)Q[B]=P[Q[B]]}function ze(P){for(let Q=1;Q<P.length;Q++){const Z=P[Q-1]+P[Q]-128;P[Q]=Z}}function xe(P,Q){let Z=0,B=Math.floor((P.length+1)/2),z=0;const V=P.length-1;for(;!(z>V||(Q[z++]=P[Z++],z>V));)Q[z++]=P[B++]}function Ne(P){let Q=P.byteLength;const Z=new Array;let B=0;const z=new DataView(P);for(;Q>0;){const V=z.getInt8(B++);if(V<0){const Y=-V;Q-=Y+1;for(let J=0;J<Y;J++)Z.push(z.getUint8(B++))}else{const Y=V;Q-=2;const J=z.getUint8(B++);for(let fe=0;fe<Y+1;fe++)Z.push(J)}}return Z}function Ee(P,Q,Z,B,z,V){let Y=new DataView(V.buffer);const J=Z[P.idx[0]].width,fe=Z[P.idx[0]].height,he=3,_e=Math.floor(J/8),Pe=Math.ceil(J/8),ke=Math.ceil(fe/8),je=J-(Pe-1)*8,Je=fe-(ke-1)*8,$e={value:0},ct=new Array(he),Et=new Array(he),bi=new Array(he),Vt=new Array(he),Tt=new Array(he);for(let wt=0;wt<he;++wt)Tt[wt]=Q[P.idx[wt]],ct[wt]=wt<1?0:ct[wt-1]+Pe*ke,Et[wt]=new Float32Array(64),bi[wt]=new Uint16Array(64),Vt[wt]=new Uint16Array(Pe*64);for(let wt=0;wt<ke;++wt){let zi=8;wt==ke-1&&(zi=Je);let Nr=8;for(let Ai=0;Ai<Pe;++Ai){Ai==Pe-1&&(Nr=je);for(let Wt=0;Wt<he;++Wt)bi[Wt].fill(0),bi[Wt][0]=z[ct[Wt]++],et($e,B,bi[Wt]),Ze(bi[Wt],Et[Wt]),ot(Et[Wt]);kt(Et);for(let Wt=0;Wt<he;++Wt)G(Et[Wt],Vt[Wt],Ai*64)}let an=0;for(let Ai=0;Ai<he;++Ai){const Wt=Z[P.idx[Ai]].type;for(let Qs=8*wt;Qs<8*wt+zi;++Qs){an=Tt[Ai][Qs];for(let Ul=0;Ul<_e;++Ul){const bn=Ul*64+(Qs&7)*8;Y.setUint16(an+0*2*Wt,Vt[Ai][bn+0],!0),Y.setUint16(an+1*2*Wt,Vt[Ai][bn+1],!0),Y.setUint16(an+2*2*Wt,Vt[Ai][bn+2],!0),Y.setUint16(an+3*2*Wt,Vt[Ai][bn+3],!0),Y.setUint16(an+4*2*Wt,Vt[Ai][bn+4],!0),Y.setUint16(an+5*2*Wt,Vt[Ai][bn+5],!0),Y.setUint16(an+6*2*Wt,Vt[Ai][bn+6],!0),Y.setUint16(an+7*2*Wt,Vt[Ai][bn+7],!0),an+=8*2*Wt}}if(_e!=Pe)for(let Qs=8*wt;Qs<8*wt+zi;++Qs){const Ul=Tt[Ai][Qs]+8*_e*2*Wt,bn=_e*64+(Qs&7)*8;for(let Zh=0;Zh<Nr;++Zh)Y.setUint16(Ul+Zh*2*Wt,Vt[Ai][bn+Zh],!0)}}}const ki=new Uint16Array(J);Y=new DataView(V.buffer);for(let wt=0;wt<he;++wt){Z[P.idx[wt]].decoded=!0;const zi=Z[P.idx[wt]].type;if(Z[wt].type==2)for(let Nr=0;Nr<fe;++Nr){const an=Tt[wt][Nr];for(let Ai=0;Ai<J;++Ai)ki[Ai]=Y.getUint16(an+Ai*2*zi,!0);for(let Ai=0;Ai<J;++Ai)Y.setFloat32(an+Ai*2*zi,ce(ki[Ai]),!0)}}}function et(P,Q,Z){let B,z=1;for(;z<64;)B=Q[P.value],B==65280?z=64:B>>8==255?z+=B&255:(Z[z]=B,z++),P.value++}function Ze(P,Q){Q[0]=ce(P[0]),Q[1]=ce(P[1]),Q[2]=ce(P[5]),Q[3]=ce(P[6]),Q[4]=ce(P[14]),Q[5]=ce(P[15]),Q[6]=ce(P[27]),Q[7]=ce(P[28]),Q[8]=ce(P[2]),Q[9]=ce(P[4]),Q[10]=ce(P[7]),Q[11]=ce(P[13]),Q[12]=ce(P[16]),Q[13]=ce(P[26]),Q[14]=ce(P[29]),Q[15]=ce(P[42]),Q[16]=ce(P[3]),Q[17]=ce(P[8]),Q[18]=ce(P[12]),Q[19]=ce(P[17]),Q[20]=ce(P[25]),Q[21]=ce(P[30]),Q[22]=ce(P[41]),Q[23]=ce(P[43]),Q[24]=ce(P[9]),Q[25]=ce(P[11]),Q[26]=ce(P[18]),Q[27]=ce(P[24]),Q[28]=ce(P[31]),Q[29]=ce(P[40]),Q[30]=ce(P[44]),Q[31]=ce(P[53]),Q[32]=ce(P[10]),Q[33]=ce(P[19]),Q[34]=ce(P[23]),Q[35]=ce(P[32]),Q[36]=ce(P[39]),Q[37]=ce(P[45]),Q[38]=ce(P[52]),Q[39]=ce(P[54]),Q[40]=ce(P[20]),Q[41]=ce(P[22]),Q[42]=ce(P[33]),Q[43]=ce(P[38]),Q[44]=ce(P[46]),Q[45]=ce(P[51]),Q[46]=ce(P[55]),Q[47]=ce(P[60]),Q[48]=ce(P[21]),Q[49]=ce(P[34]),Q[50]=ce(P[37]),Q[51]=ce(P[47]),Q[52]=ce(P[50]),Q[53]=ce(P[56]),Q[54]=ce(P[59]),Q[55]=ce(P[61]),Q[56]=ce(P[35]),Q[57]=ce(P[36]),Q[58]=ce(P[48]),Q[59]=ce(P[49]),Q[60]=ce(P[57]),Q[61]=ce(P[58]),Q[62]=ce(P[62]),Q[63]=ce(P[63])}function ot(P){const Q=.5*Math.cos(.7853975),Z=.5*Math.cos(3.14159/16),B=.5*Math.cos(3.14159/8),z=.5*Math.cos(3*3.14159/16),V=.5*Math.cos(5*3.14159/16),Y=.5*Math.cos(3*3.14159/8),J=.5*Math.cos(7*3.14159/16),fe=new Array(4),he=new Array(4),_e=new Array(4),Pe=new Array(4);for(let ke=0;ke<8;++ke){const je=ke*8;fe[0]=B*P[je+2],fe[1]=Y*P[je+2],fe[2]=B*P[je+6],fe[3]=Y*P[je+6],he[0]=Z*P[je+1]+z*P[je+3]+V*P[je+5]+J*P[je+7],he[1]=z*P[je+1]-J*P[je+3]-Z*P[je+5]-V*P[je+7],he[2]=V*P[je+1]-Z*P[je+3]+J*P[je+5]+z*P[je+7],he[3]=J*P[je+1]-V*P[je+3]+z*P[je+5]-Z*P[je+7],_e[0]=Q*(P[je+0]+P[je+4]),_e[3]=Q*(P[je+0]-P[je+4]),_e[1]=fe[0]+fe[3],_e[2]=fe[1]-fe[2],Pe[0]=_e[0]+_e[1],Pe[1]=_e[3]+_e[2],Pe[2]=_e[3]-_e[2],Pe[3]=_e[0]-_e[1],P[je+0]=Pe[0]+he[0],P[je+1]=Pe[1]+he[1],P[je+2]=Pe[2]+he[2],P[je+3]=Pe[3]+he[3],P[je+4]=Pe[3]-he[3],P[je+5]=Pe[2]-he[2],P[je+6]=Pe[1]-he[1],P[je+7]=Pe[0]-he[0]}for(let ke=0;ke<8;++ke)fe[0]=B*P[16+ke],fe[1]=Y*P[16+ke],fe[2]=B*P[48+ke],fe[3]=Y*P[48+ke],he[0]=Z*P[8+ke]+z*P[24+ke]+V*P[40+ke]+J*P[56+ke],he[1]=z*P[8+ke]-J*P[24+ke]-Z*P[40+ke]-V*P[56+ke],he[2]=V*P[8+ke]-Z*P[24+ke]+J*P[40+ke]+z*P[56+ke],he[3]=J*P[8+ke]-V*P[24+ke]+z*P[40+ke]-Z*P[56+ke],_e[0]=Q*(P[ke]+P[32+ke]),_e[3]=Q*(P[ke]-P[32+ke]),_e[1]=fe[0]+fe[3],_e[2]=fe[1]-fe[2],Pe[0]=_e[0]+_e[1],Pe[1]=_e[3]+_e[2],Pe[2]=_e[3]-_e[2],Pe[3]=_e[0]-_e[1],P[0+ke]=Pe[0]+he[0],P[8+ke]=Pe[1]+he[1],P[16+ke]=Pe[2]+he[2],P[24+ke]=Pe[3]+he[3],P[32+ke]=Pe[3]-he[3],P[40+ke]=Pe[2]-he[2],P[48+ke]=Pe[1]-he[1],P[56+ke]=Pe[0]-he[0]}function kt(P){for(let Q=0;Q<64;++Q){const Z=P[0][Q],B=P[1][Q],z=P[2][Q];P[0][Q]=Z+1.5747*z,P[1][Q]=Z-.1873*B-.4682*z,P[2][Q]=Z+1.8556*B}}function G(P,Q,Z){for(let B=0;B<64;++B)Q[Z+B]=Tf.toHalfFloat(O(P[B]))}function O(P){return P<=1?Math.sign(P)*Math.pow(Math.abs(P),2.2):Math.sign(P)*Math.pow(R,Math.abs(P)-1)}function ge(P){return new DataView(P.array.buffer,P.offset.value,P.size)}function be(P){const Q=P.viewer.buffer.slice(P.offset.value,P.offset.value+P.size),Z=new Uint8Array(Ne(Q)),B=new Uint8Array(Z.length);return ze(Z),xe(Z,B),new DataView(B.buffer)}function Re(P){const Q=P.array.slice(P.offset.value,P.offset.value+P.size),Z=l0(Q),B=new Uint8Array(Z.length);return ze(Z),xe(Z,B),new DataView(B.buffer)}function Me(P){const Q=P.viewer,Z={value:P.offset.value},B=new Uint16Array(P.width*P.scanlineBlockSize*(P.channels*P.type)),z=new Uint8Array(8192);let V=0;const Y=new Array(P.channels);for(let Je=0;Je<P.channels;Je++)Y[Je]={},Y[Je].start=V,Y[Je].end=Y[Je].start,Y[Je].nx=P.width,Y[Je].ny=P.lines,Y[Je].size=P.type,V+=Y[Je].nx*Y[Je].ny*Y[Je].size;const J=$(Q,Z),fe=$(Q,Z);if(fe>=8192)throw new Error("Something is wrong with PIZ_COMPRESSION BITMAP_SIZE");if(J<=fe)for(let Je=0;Je<fe-J+1;Je++)z[Je+J]=ft(Q,Z);const he=new Uint16Array(65536),_e=S(z,he),Pe=dt(Q,Z);st(P.array,Q,Z,Pe,B,V);for(let Je=0;Je<P.channels;++Je){const $e=Y[Je];for(let ct=0;ct<Y[Je].size;++ct)He(B,$e.start+ct,$e.nx,$e.size,$e.ny,$e.nx*$e.size,_e)}q(he,B,V);let ke=0;const je=new Uint8Array(B.buffer.byteLength);for(let Je=0;Je<P.lines;Je++)for(let $e=0;$e<P.channels;$e++){const ct=Y[$e],Et=ct.nx*ct.size,bi=new Uint8Array(B.buffer,ct.end*2,Et*2);je.set(bi,ke),ke+=Et*2,ct.end+=Et}return new DataView(je.buffer)}function bt(P){const Q=P.array.slice(P.offset.value,P.offset.value+P.size),Z=l0(Q),B=P.lines*P.channels*P.width,z=P.type==1?new Uint16Array(B):new Uint32Array(B);let V=0,Y=0;const J=new Array(4);for(let fe=0;fe<P.lines;fe++)for(let he=0;he<P.channels;he++){let _e=0;switch(P.type){case 1:J[0]=V,J[1]=J[0]+P.width,V=J[1]+P.width;for(let Pe=0;Pe<P.width;++Pe){const ke=Z[J[0]++]<<8|Z[J[1]++];_e+=ke,z[Y]=_e,Y++}break;case 2:J[0]=V,J[1]=J[0]+P.width,J[2]=J[1]+P.width,V=J[2]+P.width;for(let Pe=0;Pe<P.width;++Pe){const ke=Z[J[0]++]<<24|Z[J[1]++]<<16|Z[J[2]++]<<8;_e+=ke,z[Y]=_e,Y++}break}}return new DataView(z.buffer)}function ut(P){const Q=P.viewer,Z={value:P.offset.value},B=new Uint8Array(P.width*P.lines*(P.channels*P.type*2)),z={version:rt(Q,Z),unknownUncompressedSize:rt(Q,Z),unknownCompressedSize:rt(Q,Z),acCompressedSize:rt(Q,Z),dcCompressedSize:rt(Q,Z),rleCompressedSize:rt(Q,Z),rleUncompressedSize:rt(Q,Z),rleRawSize:rt(Q,Z),totalAcUncompressedCount:rt(Q,Z),totalDcUncompressedCount:rt(Q,Z),acCompression:rt(Q,Z)};if(z.version<2)throw new Error("EXRLoader.parse: "+Kh.compression+" version "+z.version+" is unsupported");const V=new Array;let Y=$(Q,Z)-2;for(;Y>0;){const $e=Le(Q.buffer,Z),ct=ft(Q,Z),Et=ct>>2&3,bi=(ct>>4)-1,Vt=new Int8Array([bi])[0],Tt=ft(Q,Z);V.push({name:$e,index:Vt,type:Tt,compression:Et}),Y-=$e.length+3}const J=Kh.channels,fe=new Array(P.channels);for(let $e=0;$e<P.channels;++$e){const ct=fe[$e]={},Et=J[$e];ct.name=Et.name,ct.compression=0,ct.decoded=!1,ct.type=Et.pixelType,ct.pLinear=Et.pLinear,ct.width=P.width,ct.height=P.lines}const he={idx:new Array(3)};for(let $e=0;$e<P.channels;++$e){const ct=fe[$e];for(let Et=0;Et<V.length;++Et){const bi=V[Et];ct.name==bi.name&&(ct.compression=bi.compression,bi.index>=0&&(he.idx[bi.index]=$e),ct.offset=$e)}}let _e,Pe,ke;if(z.acCompressedSize>0)switch(z.acCompression){case 0:_e=new Uint16Array(z.totalAcUncompressedCount),st(P.array,Q,Z,z.acCompressedSize,_e,z.totalAcUncompressedCount);break;case 1:const $e=P.array.slice(Z.value,Z.value+z.totalAcUncompressedCount),ct=l0($e);_e=new Uint16Array(ct.buffer),Z.value+=z.totalAcUncompressedCount;break}if(z.dcCompressedSize>0){const $e={array:P.array,offset:Z,size:z.dcCompressedSize};Pe=new Uint16Array(Re($e).buffer),Z.value+=z.dcCompressedSize}if(z.rleRawSize>0){const $e=P.array.slice(Z.value,Z.value+z.rleCompressedSize),ct=l0($e);ke=Ne(ct.buffer),Z.value+=z.rleCompressedSize}let je=0;const Je=new Array(fe.length);for(let $e=0;$e<Je.length;++$e)Je[$e]=new Array;for(let $e=0;$e<P.lines;++$e)for(let ct=0;ct<fe.length;++ct)Je[ct].push(je),je+=fe[ct].width*P.type*2;Ee(he,Je,fe,_e,Pe,B);for(let $e=0;$e<fe.length;++$e){const ct=fe[$e];if(!ct.decoded)switch(ct.compression){case 2:let Et=0,bi=0;for(let Vt=0;Vt<P.lines;++Vt){let Tt=Je[$e][Et];for(let ki=0;ki<ct.width;++ki){for(let wt=0;wt<2*ct.type;++wt)B[Tt++]=ke[bi+wt*ct.width*ct.height];bi++}Et++}break;case 1:default:throw new Error("EXRLoader.parse: unsupported channel compression")}}return new DataView(B.buffer)}function Le(P,Q){const Z=new Uint8Array(P);let B=0;for(;Z[Q.value+B]!=0;)B+=1;const z=new TextDecoder().decode(Z.slice(Q.value,Q.value+B));return Q.value=Q.value+B+1,z}function Ve(P,Q,Z){const B=new TextDecoder().decode(new Uint8Array(P).slice(Q.value,Q.value+Z));return Q.value=Q.value+Z,B}function xt(P,Q){const Z=ei(P,Q),B=dt(P,Q);return[Z,B]}function Fe(P,Q){const Z=dt(P,Q),B=dt(P,Q);return[Z,B]}function ei(P,Q){const Z=P.getInt32(Q.value,!0);return Q.value=Q.value+4,Z}function dt(P,Q){const Z=P.getUint32(Q.value,!0);return Q.value=Q.value+4,Z}function Xe(P,Q){const Z=P[Q.value];return Q.value=Q.value+1,Z}function ft(P,Q){const Z=P.getUint8(Q.value);return Q.value=Q.value+1,Z}const rt=function(P,Q){let Z;return"getBigInt64"in DataView.prototype?Z=Number(P.getBigInt64(Q.value,!0)):Z=P.getUint32(Q.value+4,!0)+Number(P.getUint32(Q.value,!0)<<32),Q.value+=8,Z};function Rt(P,Q){const Z=P.getFloat32(Q.value,!0);return Q.value+=4,Z}function j(P,Q){return Tf.toHalfFloat(Rt(P,Q))}function ce(P){const Q=(P&31744)>>10,Z=P&1023;return(P>>15?-1:1)*(Q?Q===31?Z?NaN:1/0:Math.pow(2,Q-15)*(1+Z/1024):6103515625e-14*(Z/1024))}function $(P,Q){const Z=P.getUint16(Q.value,!0);return Q.value+=2,Z}function De(P,Q){return ce($(P,Q))}function le(P,Q,Z,B){const z=Z.value,V=[];for(;Z.value<z+B-1;){const Y=Le(Q,Z),J=ei(P,Z),fe=ft(P,Z);Z.value+=3;const he=ei(P,Z),_e=ei(P,Z);V.push({name:Y,pixelType:J,pLinear:fe,xSampling:he,ySampling:_e})}return Z.value+=1,V}function Ge(P,Q){const Z=Rt(P,Q),B=Rt(P,Q),z=Rt(P,Q),V=Rt(P,Q),Y=Rt(P,Q),J=Rt(P,Q),fe=Rt(P,Q),he=Rt(P,Q);return{redX:Z,redY:B,greenX:z,greenY:V,blueX:Y,blueY:J,whiteX:fe,whiteY:he}}function Ye(P,Q){const Z=["NO_COMPRESSION","RLE_COMPRESSION","ZIPS_COMPRESSION","ZIP_COMPRESSION","PIZ_COMPRESSION","PXR24_COMPRESSION","B44_COMPRESSION","B44A_COMPRESSION","DWAA_COMPRESSION","DWAB_COMPRESSION"],B=ft(P,Q);return Z[B]}function ti(P,Q){const Z=dt(P,Q),B=dt(P,Q),z=dt(P,Q),V=dt(P,Q);return{xMin:Z,yMin:B,xMax:z,yMax:V}}function Mi(P,Q){const Z=["INCREASING_Y"],B=ft(P,Q);return Z[B]}function rn(P,Q){const Z=Rt(P,Q),B=Rt(P,Q);return[Z,B]}function on(P,Q){const Z=Rt(P,Q),B=Rt(P,Q),z=Rt(P,Q);return[Z,B,z]}function si(P,Q,Z,B,z){if(B==="string"||B==="stringvector"||B==="iccProfile")return Ve(Q,Z,z);if(B==="chlist")return le(P,Q,Z,z);if(B==="chromaticities")return Ge(P,Z);if(B==="compression")return Ye(P,Z);if(B==="box2i")return ti(P,Z);if(B==="lineOrder")return Mi(P,Z);if(B==="float")return Rt(P,Z);if(B==="v2f")return rn(P,Z);if(B==="v3f")return on(P,Z);if(B==="int")return ei(P,Z);if(B==="rational")return xt(P,Z);if(B==="timecode")return Fe(P,Z);if(B==="preview")return Z.value+=z,"skipped";Z.value+=z}function vn(P,Q,Z){const B={};if(P.getUint32(0,!0)!=20000630)throw new Error("THREE.EXRLoader: Provided file doesn't appear to be in OpenEXR format.");B.version=P.getUint8(4);const z=P.getUint8(5);B.spec={singleTile:!!(z&2),longName:!!(z&4),deepFormat:!!(z&8),multiPart:!!(z&16)},Z.value=8;let V=!0;for(;V;){const Y=Le(Q,Z);if(Y==0)V=!1;else{const J=Le(Q,Z),fe=dt(P,Z),he=si(P,Q,Z,J,fe);he===void 0?console.warn(`THREE.EXRLoader: Skipped unknown header attribute type '${J}'.`):B[Y]=he}}if(z&-5)throw console.error("THREE.EXRHeader:",B),new Error("THREE.EXRLoader: Provided file is currently unsupported.");return B}function Bn(P,Q,Z,B,z){const V={size:0,viewer:Q,array:Z,offset:B,width:P.dataWindow.xMax-P.dataWindow.xMin+1,height:P.dataWindow.yMax-P.dataWindow.yMin+1,channels:P.channels.length,bytesPerLine:null,lines:null,inputSize:null,type:P.channels[0].pixelType,uncompress:null,getter:null,format:null,colorSpace:Ii};switch(P.compression){case"NO_COMPRESSION":V.lines=1,V.uncompress=ge;break;case"RLE_COMPRESSION":V.lines=1,V.uncompress=be;break;case"ZIPS_COMPRESSION":V.lines=1,V.uncompress=Re;break;case"ZIP_COMPRESSION":V.lines=16,V.uncompress=Re;break;case"PIZ_COMPRESSION":V.lines=32,V.uncompress=Me;break;case"PXR24_COMPRESSION":V.lines=16,V.uncompress=bt;break;case"DWAA_COMPRESSION":V.lines=32,V.uncompress=ut;break;case"DWAB_COMPRESSION":V.lines=256,V.uncompress=ut;break;default:throw new Error("EXRLoader.parse: "+P.compression+" is unsupported")}if(V.scanlineBlockSize=V.lines,V.type==1)switch(z){case tn:V.getter=De,V.inputSize=2;break;case Cn:V.getter=$,V.inputSize=2;break}else if(V.type==2)switch(z){case tn:V.getter=Rt,V.inputSize=4;break;case Cn:V.getter=j,V.inputSize=4}else throw new Error("EXRLoader.parse: unsupported pixelType "+V.type+" for "+P.compression+".");V.blockCount=(P.dataWindow.yMax+1)/V.scanlineBlockSize;for(let J=0;J<V.blockCount;J++)rt(Q,B);V.outputChannels=V.channels==3?4:V.channels;const Y=V.width*V.height*V.outputChannels;switch(z){case tn:V.byteArray=new Float32Array(Y),V.channels<V.outputChannels&&V.byteArray.fill(1,0,Y);break;case Cn:V.byteArray=new Uint16Array(Y),V.channels<V.outputChannels&&V.byteArray.fill(15360,0,Y);break;default:console.error("THREE.EXRLoader: unsupported type: ",z);break}return V.bytesPerLine=V.width*V.inputSize*V.channels,V.outputChannels==4?(V.format=Si,V.colorSpace=Ii):(V.format=Ac,V.colorSpace=Mr),V}const Ro=new DataView(e),Jh=new Uint8Array(e),Po={value:0},Kh=vn(Ro,e,Po),Zt=Bn(Kh,Ro,Jh,Po,this.type),sy={value:0},E_={R:0,G:1,B:2,A:3,Y:0};for(let P=0;P<Zt.height/Zt.scanlineBlockSize;P++){const Q=dt(Ro,Po);Zt.size=dt(Ro,Po),Zt.lines=Q+Zt.scanlineBlockSize>Zt.height?Zt.height-Q:Zt.scanlineBlockSize;const B=Zt.size<Zt.lines*Zt.bytesPerLine?Zt.uncompress(Zt):ge(Zt);Po.value+=Zt.size;for(let z=0;z<Zt.scanlineBlockSize;z++){const V=z+P*Zt.scanlineBlockSize;if(V>=Zt.height)break;for(let Y=0;Y<Zt.channels;Y++){const J=E_[Kh.channels[Y].name];for(let fe=0;fe<Zt.width;fe++){sy.value=(z*(Zt.channels*Zt.width)+Y*Zt.width+fe)*Zt.inputSize;const he=(Zt.height-1-V)*(Zt.width*Zt.outputChannels)+fe*Zt.outputChannels+J;Zt.byteArray[he]=Zt.getter(B,sy)}}}}return{header:Kh,width:Zt.width,height:Zt.height,data:Zt.byteArray,format:Zt.format,colorSpace:Zt.colorSpace,type:this.type}}setDataType(e){return this.type=e,this}load(e,t,i,n){function r(o,a){o.colorSpace=a.colorSpace,o.minFilter=Bt,o.magFilter=Bt,o.generateMipmaps=!1,o.flipY=!1,t&&t(o,a)}return super.load(e,r,i,n)}}const Lde=Object.freeze(Object.defineProperty({__proto__:null,EXRLoader:Hv},Symbol.toStringTag,{value:"Module"}));class wS extends ND{constructor(e){super(e),this.type=Cn}parse(e){const o=function(M,R){switch(M){case 1:throw new Error("THREE.RGBELoader: Read Error: "+(R||""));case 2:throw new Error("THREE.RGBELoader: Write Error: "+(R||""));case 3:throw new Error("THREE.RGBELoader: Bad File Format: "+(R||""));default:case 4:throw new Error("THREE.RGBELoader: Memory Error: "+(R||""))}},h=`
@@ -6232,8 +6232,8 @@ void main() {
6232
6232
  `+t.fragmentShader),this.effectCompositerQuad?(this.effectCompositerQuad.material.dispose(),this.effectCompositerQuad.material=new Pt(t)):this.effectCompositerQuad=new af(new Pt(t))}generateHemisphereSamples(e){const t=[];for(let i=0;i<e;i++){const n=2.399963*i,r=Math.sqrt(i+.5)/Math.sqrt(e),o=r*Math.cos(n),a=r*Math.sin(n),c=Math.sqrt(1-(o*o+a*a));t.push(new C(o,a,c))}return t}generateDenoiseSamples(e,t){const i=2*Math.PI*t/e,n=1/e,r=n,o=[];let a=n,c=0;for(let l=0;l<e;l++)o.push(new ee(Math.cos(c),Math.sin(c)).multiplyScalar(Math.pow(a,.75))),a+=r,c+=i;return o}setSize(e,t){this.firstFrame(),this.width=e,this.height=t;const i=this.configuration.halfRes?.5:1;this.writeTargetInternal.setSize(e*i,t*i),this.readTargetInternal.setSize(e*i,t*i),this.accumulationRenderTarget.setSize(e*i,t*i),this.configuration.halfRes&&this.depthDownsampleTarget.setSize(e*i,t*i),this.configuration.transparencyAware&&(this.transparencyRenderTargetDWFalse.setSize(e,t),this.transparencyRenderTargetDWTrue.setSize(e,t)),this.outputTargetInternal.setSize(e,t)}setDepthTexture(e){this.depthTexture=e}firstFrame(){this.needsFrame=!0}render(e,t,i){const n=e.xr.enabled;e.xr.enabled=!1,e.capabilities.logarithmicDepthBuffer!==this.configuration.logarithmicDepthBuffer&&(this.configuration.logarithmicDepthBuffer=e.capabilities.logarithmicDepthBuffer,this.configureAOPass(this.configuration.logarithmicDepthBuffer),this.configureDenoisePass(this.configuration.logarithmicDepthBuffer),this.configureEffectCompositer(this.configuration.logarithmicDepthBuffer)),this.detectTransparency(),(t.texture.type!==this.outputTargetInternal.texture.type||t.texture.format!==this.outputTargetInternal.texture.format)&&(this.outputTargetInternal.texture.type=t.texture.type,this.outputTargetInternal.texture.format=t.texture.format,this.outputTargetInternal.texture.needsUpdate=!0),this.camera.updateMatrixWorld(),this.lastViewMatrix.equals(this.camera.matrixWorldInverse)&&this.lastProjectionMatrix.equals(this.camera.projectionMatrix)&&this.configuration.accumulate&&!this.needsFrame?this.frame++:(e.setRenderTarget(this.accumulationRenderTarget),e.clear(!0,!0,!0),this.frame=0,this.needsFrame=!1),this.lastViewMatrix.copy(this.camera.matrixWorldInverse),this.lastProjectionMatrix.copy(this.camera.projectionMatrix);let r,o,a;this.debugMode&&(r=e.getContext(),o=r.getExtension("EXT_disjoint_timer_query_webgl2"),o===null&&(console.error("EXT_disjoint_timer_query_webgl2 not available, disabling debug mode."),this.debugMode=!1)),this.debugMode&&(a=r.createQuery(),r.beginQuery(o.TIME_ELAPSED_EXT,a)),this.configuration.transparencyAware&&this.renderTransparency(e),this._r.set(this.width,this.height);let c=this.configuration.aoRadius;if(this.configuration.halfRes&&this.configuration.screenSpaceRadius&&(c*=.5),this.frame<1024/this.configuration.aoSamples){this.configuration.halfRes&&(e.setRenderTarget(this.depthDownsampleTarget),this.depthDownsampleQuad.material.uniforms.sceneDepth.value=this.depthTexture,this.depthDownsampleQuad.material.uniforms.resolution.value=this._r,this.depthDownsampleQuad.material.uniforms.near.value=this.camera.near,this.depthDownsampleQuad.material.uniforms.far.value=this.camera.far,this.depthDownsampleQuad.material.uniforms.projectionMatrixInv.value=this.camera.projectionMatrixInverse,this.depthDownsampleQuad.material.uniforms.viewMatrixInv.value=this.camera.matrixWorld,this.depthDownsampleQuad.material.uniforms.logDepth.value=this.configuration.logarithmicDepthBuffer,this.depthDownsampleQuad.render(e)),this.effectShaderQuad.material.uniforms.sceneDiffuse.value=t.texture,this.effectShaderQuad.material.uniforms.sceneDepth.value=this.configuration.halfRes?this.depthDownsampleTarget.texture[0]:this.depthTexture,this.effectShaderQuad.material.uniforms.sceneNormal.value=this.configuration.halfRes?this.depthDownsampleTarget.texture[1]:null,this.effectShaderQuad.material.uniforms.projMat.value=this.camera.projectionMatrix,this.effectShaderQuad.material.uniforms.viewMat.value=this.camera.matrixWorldInverse,this.effectShaderQuad.material.uniforms.projViewMat.value=this.camera.projectionMatrix.clone().multiply(this.camera.matrixWorldInverse.clone()),this.effectShaderQuad.material.uniforms.projectionMatrixInv.value=this.camera.projectionMatrixInverse,this.effectShaderQuad.material.uniforms.viewMatrixInv.value=this.camera.matrixWorld,this.effectShaderQuad.material.uniforms.cameraPos.value=this.camera.getWorldPosition(new C),this.effectShaderQuad.material.uniforms.resolution.value=this.configuration.halfRes?this._r.clone().multiplyScalar(.5).floor():this._r,this.effectShaderQuad.material.uniforms.time.value=performance.now()/1e3,this.effectShaderQuad.material.uniforms.samples.value=this.samples,this.effectShaderQuad.material.uniforms.bluenoise.value=this.bluenoise,this.effectShaderQuad.material.uniforms.radius.value=c,this.effectShaderQuad.material.uniforms.distanceFalloff.value=this.configuration.distanceFalloff,this.effectShaderQuad.material.uniforms.near.value=this.camera.near,this.effectShaderQuad.material.uniforms.far.value=this.camera.far,this.effectShaderQuad.material.uniforms.logDepth.value=e.capabilities.logarithmicDepthBuffer,this.effectShaderQuad.material.uniforms.ortho.value=this.camera.isOrthographicCamera,this.effectShaderQuad.material.uniforms.screenSpaceRadius.value=this.configuration.screenSpaceRadius,this.effectShaderQuad.material.uniforms.frame.value=this.frame,e.setRenderTarget(this.writeTargetInternal),this.effectShaderQuad.render(e);for(let h=0;h<this.configuration.denoiseIterations;h++)[this.writeTargetInternal,this.readTargetInternal]=[this.readTargetInternal,this.writeTargetInternal],this.poissonBlurQuad.material.uniforms.tDiffuse.value=this.readTargetInternal.texture,this.poissonBlurQuad.material.uniforms.sceneDepth.value=this.configuration.halfRes?this.depthDownsampleTarget.texture[0]:this.depthTexture,this.poissonBlurQuad.material.uniforms.projMat.value=this.camera.projectionMatrix,this.poissonBlurQuad.material.uniforms.viewMat.value=this.camera.matrixWorldInverse,this.poissonBlurQuad.material.uniforms.projectionMatrixInv.value=this.camera.projectionMatrixInverse,this.poissonBlurQuad.material.uniforms.viewMatrixInv.value=this.camera.matrixWorld,this.poissonBlurQuad.material.uniforms.cameraPos.value=this.camera.getWorldPosition(new C),this.poissonBlurQuad.material.uniforms.resolution.value=this.configuration.halfRes?this._r.clone().multiplyScalar(.5).floor():this._r,this.poissonBlurQuad.material.uniforms.time.value=performance.now()/1e3,this.poissonBlurQuad.material.uniforms.blueNoise.value=this.bluenoise,this.poissonBlurQuad.material.uniforms.radius.value=this.configuration.denoiseRadius*(this.configuration.halfRes?.5:1),this.poissonBlurQuad.material.uniforms.worldRadius.value=c,this.poissonBlurQuad.material.uniforms.distanceFalloff.value=this.configuration.distanceFalloff,this.poissonBlurQuad.material.uniforms.index.value=h,this.poissonBlurQuad.material.uniforms.poissonDisk.value=this.samplesDenoise,this.poissonBlurQuad.material.uniforms.near.value=this.camera.near,this.poissonBlurQuad.material.uniforms.far.value=this.camera.far,this.poissonBlurQuad.material.uniforms.logDepth.value=e.capabilities.logarithmicDepthBuffer,this.poissonBlurQuad.material.uniforms.screenSpaceRadius.value=this.configuration.screenSpaceRadius,e.setRenderTarget(this.writeTargetInternal),this.poissonBlurQuad.render(e);e.setRenderTarget(this.accumulationRenderTarget);const l=e.autoClear;e.autoClear=!1,this.accumulationQuad.material.uniforms.tDiffuse.value=this.writeTargetInternal.texture,this.accumulationQuad.material.uniforms.frame.value=this.frame,this.accumulationQuad.render(e),e.autoClear=l}this.configuration.transparencyAware&&(this.effectCompositerQuad.material.uniforms.transparencyDWFalse.value=this.transparencyRenderTargetDWFalse.texture,this.effectCompositerQuad.material.uniforms.transparencyDWTrue.value=this.transparencyRenderTargetDWTrue.texture,this.effectCompositerQuad.material.uniforms.transparencyDWTrueDepth.value=this.transparencyRenderTargetDWTrue.depthTexture,this.effectCompositerQuad.material.uniforms.transparencyAware.value=!0),this.effectCompositerQuad.material.uniforms.sceneDiffuse.value=t.texture,this.effectCompositerQuad.material.uniforms.sceneDepth.value=this.depthTexture,this.effectCompositerQuad.material.uniforms.near.value=this.camera.near,this.effectCompositerQuad.material.uniforms.far.value=this.camera.far,this.effectCompositerQuad.material.uniforms.projectionMatrixInv.value=this.camera.projectionMatrixInverse,this.effectCompositerQuad.material.uniforms.viewMatrixInv.value=this.camera.matrixWorld,this.effectCompositerQuad.material.uniforms.logDepth.value=e.capabilities.logarithmicDepthBuffer,this.effectCompositerQuad.material.uniforms.ortho.value=this.camera.isOrthographicCamera,this.effectCompositerQuad.material.uniforms.downsampledDepth.value=this.configuration.halfRes?this.depthDownsampleTarget.texture[0]:this.depthTexture,this.effectCompositerQuad.material.uniforms.resolution.value=this._r,this.effectCompositerQuad.material.uniforms.blueNoise.value=this.bluenoise,this.effectCompositerQuad.material.uniforms.intensity.value=this.configuration.intensity,this.effectCompositerQuad.material.uniforms.renderMode.value=this.configuration.renderMode,this.effectCompositerQuad.material.uniforms.screenSpaceRadius.value=this.configuration.screenSpaceRadius,this.effectCompositerQuad.material.uniforms.radius.value=c,this.effectCompositerQuad.material.uniforms.distanceFalloff.value=this.configuration.distanceFalloff,this.effectCompositerQuad.material.uniforms.gammaCorrection.value=this.autosetGamma?this.renderToScreen:this.configuration.gammaCorrection,this.effectCompositerQuad.material.uniforms.tDiffuse.value=this.accumulationRenderTarget.texture,this.effectCompositerQuad.material.uniforms.color.value=this._c.copy(this.configuration.color).convertSRGBToLinear(),this.effectCompositerQuad.material.uniforms.colorMultiply.value=this.configuration.colorMultiply,this.effectCompositerQuad.material.uniforms.cameraPos.value=this.camera.getWorldPosition(new C),this.effectCompositerQuad.material.uniforms.fog.value=!!this.scene.fog,this.scene.fog&&(this.scene.fog.isFog?(this.effectCompositerQuad.material.uniforms.fogExp.value=!1,this.effectCompositerQuad.material.uniforms.fogNear.value=this.scene.fog.near,this.effectCompositerQuad.material.uniforms.fogFar.value=this.scene.fog.far):this.scene.fog.isFogExp2?(this.effectCompositerQuad.material.uniforms.fogExp.value=!0,this.effectCompositerQuad.material.uniforms.fogDensity.value=this.scene.fog.density):console.error(`Unsupported fog type ${this.scene.fog.constructor.name} in SSAOPass.`)),e.setRenderTarget(this.outputTargetInternal),this.effectCompositerQuad.render(e),e.setRenderTarget(this.renderToScreen?null:i),this.copyQuad.material.uniforms.tDiffuse.value=this.outputTargetInternal.texture,this.copyQuad.render(e),this.debugMode&&(r.endQuery(o.TIME_ELAPSED_EXT),Y6(a,r,this)),e.xr.enabled=n}enableDebugMode(){this.debugMode=!0}disableDebugMode(){this.debugMode=!1}setDisplayMode(e){this.configuration.renderMode=["Combined","AO","No AO","Split","Split AO"].indexOf(e)}setQualityMode(e){e==="Performance"?(this.configuration.aoSamples=8,this.configuration.denoiseSamples=4,this.configuration.denoiseRadius=12):e==="Low"?(this.configuration.aoSamples=16,this.configuration.denoiseSamples=4,this.configuration.denoiseRadius=12):e==="Medium"?(this.configuration.aoSamples=16,this.configuration.denoiseSamples=8,this.configuration.denoiseRadius=12):e==="High"?(this.configuration.aoSamples=64,this.configuration.denoiseSamples=8,this.configuration.denoiseRadius=6):e==="Ultra"&&(this.configuration.aoSamples=64,this.configuration.denoiseSamples=16,this.configuration.denoiseRadius=6)}}Uint8Array.from(atob(X6),s=>s.charCodeAt(0));var Xge=Object.defineProperty,Yge=Object.getOwnPropertyDescriptor,Jge=(s,e,t,i)=>{for(var n=i>1?void 0:i?Yge(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Xge(e,t,n),n};class jA extends kr{constructor(){super(...arguments);d(this,"mode")}get typeName(){return"ToneMapping"}get isToneMapping(){return!0}init(){this.mode||(this.mode=new Lt(io)),this.mode.defaultValue=io}apply(){this.mode||this.init(),this.mode.onValueChanged=this._apply.bind(this),this._apply(this.mode.value)}_apply(t){this.context.renderer.toneMapping=this.getThreeToneMapping(t)}getThreeToneMapping(t){switch(t){case 0:return Xm;case 1:return XS;case 2:return YS;case 3:return lb;case 4:return Ym;default:return Ym}}}Jge([x(Lt)],jA.prototype,"mode",2);qa("Tonemapping",jA);const Vy=ie("debugpost"),kT=Symbol("needle:postprocessing-handler"),OT=Symbol("needle:previous-autoclear-state");class SI{constructor(e){d(this,"_composer",null);d(this,"_lastVolumeComponents");d(this,"_effects",[]);d(this,"_isActive",!1);d(this,"context");d(this,"tempColorAdjustments",null);this.context=e}get isActive(){return this._isActive}get composer(){return this._composer}apply(e){this._isActive=!0,this.onApply(this.context,e)}unapply(){var i;if(this._isActive=!1,this._lastVolumeComponents){for(const n of this._lastVolumeComponents)n.unapply();this._lastVolumeComponents.length=0}const e=this.context;e[kT]===this&&delete e[kT],e.composer===this._composer&&((i=e.composer)==null||i.dispose(),e.composer=null),typeof e.renderer[OT]=="boolean"&&(e.renderer.autoClear=e.renderer[OT])}dispose(){this.unapply();for(const e of this._effects)e.dispose();this._effects.length=0,this._composer=null}onApply(e,t){if(!t)return;e[kT]=this,Vy&&console.log("refreshing volume profile",t),this._lastVolumeComponents=[...t],this._effects.length=0;const i=t.some(r=>r instanceof jA),n=t.some(r=>r instanceof xl&&r.active);i&&!n&&(Vy&&console.log("Adding a default ColorAdjustments component to apply tonemapping.",...t),this.tempColorAdjustments===null&&(this.tempColorAdjustments=new xl),this._lastVolumeComponents.push(this.tempColorAdjustments));for(const r of this._lastVolumeComponents)if(r.context=e,r.apply){if(r.active){if(!e.mainCameraComponent){console.error("No camera in scene found or available yet - can not create postprocessing effects");return}const o=r.apply();if(!o)continue;Array.isArray(o)?this._effects.push(...o):this._effects.push(o)}}else r.active&&Ni("Volume component is not a VolumeComponent: "+r.__type);this.applyEffects(e)}applyEffects(e){const t=this._effects;if(t.length<=0)return;const i=e.mainCameraComponent,n=e.renderer,r=e.scene,o=i.cam;n[OT]=n.autoClear;const a=n.capabilities.maxSamples;this._composer||(this._composer=new ck(n,{frameBufferType:Cn,stencilBuffer:!0,multisampling:Math.min(na()?4:8,a)})),e.composer=this._composer;const c=e.composer;c.setMainCamera(o),c.setRenderer(n),c.setMainScene(r);for(const h of c.passes)h.dispose();c.removeAllPasses();const l=new ZE(r,o);l.name="Render To Screen",l.mainScene=r,c.addPass(l);try{this.orderEffects();const h=[];for(const u of t)if(u instanceof ja)h.push(u);else if(u instanceof cr){const f=new v3(o,...h);f.mainScene=r,f.name=h.map(p=>p.constructor.name).join(", "),f.enabled=!0,h.length=0,c.addPass(u)}if(h.length>0){const u=new v3(o,...h);u.name=h.map(f=>f.name).join(" "),u.mainScene=r,u.enabled=!0,c.addPass(u)}}catch(h){console.error("Error while applying postprocessing effects",h),c.removeAllPasses()}Vy&&console.log("PostProcessing Passes",t,"->",c.passes)}orderEffects(){var t;Vy&&console.log("Before ordering effects",[...this._effects]);const e=this._effects;e.sort((i,n)=>{const r=BP.indexOf(i.constructor),o=BP.indexOf(n.constructor);return r<0&&o<0?-1:r<0?1:o<0?-1:r-o}),Vy&&console.log("After ordering effects",[...this._effects]);for(let i=0;i<e.length;i++){const n=e[i];if(((t=n==null?void 0:n.configuration)==null?void 0:t.gammaCorrection)!==void 0){const r=i===e.length-1;n.configuration.gammaCorrection=r}}}}const BP=[M5,dk,C5,S5,J6,b5,A5,hk,w5,I5,E5,_5,m5,x5];var Kge=Object.defineProperty,Zge=Object.getOwnPropertyDescriptor,$ge=(s,e,t,i)=>{for(var n=i>1?void 0:i?Zge(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Kge(e,t,n),n};const jy=ie("debugpost");class i_ extends Te{constructor(){super(...arguments);d(this,"sharedProfile");d(this,"_postprocessing");d(this,"_effects",[]);d(this,"_lastApplyTime");d(this,"_rapidApplyCount",0);d(this,"_isDirty",!1);d(this,"_modificationQueue");d(this,"_recreateId",-1)}get effects(){return this._effects}markDirty(){this._isDirty=!0}awake(){var t;jy&&(console.log(this),console.log("Press P to toggle post processing"),window.addEventListener("keydown",i=>{i.key==="p"&&(this.enabled=!this.enabled,pn("Toggle PostProcessing "+this.name+": Enabled="+this.enabled),this.markDirty())})),(t=this.sharedProfile)==null||t.init()}onDisable(){var t;(t=this._postprocessing)==null||t.unapply()}onBeforeRender(){if(!this.context.isInXR){if(this.context.composer&&!(this.context.composer instanceof ck)){jy&&console.warn("PostProcessing: The current composer is not an EffectComposer - this is not supported");return}this.context.mainCamera&&(!this._postprocessing||!this._postprocessing.isActive||this._isDirty)&&this.apply(),this.context.composer&&(this.context.composer.setRenderer(this.context.renderer),this.context.composer.setMainScene(this.context.scene),this.context.mainCamera&&this.context.composer.setMainCamera(this.context.mainCamera))}}onDestroy(){var t;(t=this._postprocessing)==null||t.dispose()}apply(){var i,n;jy&&console.log("Apply PostProcessing",this,(i=this.context.mainCamera)==null?void 0:i.name),ht()&&(this._lastApplyTime!==void 0&&Date.now()-this._lastApplyTime<100&&(this._rapidApplyCount++,this._rapidApplyCount===5&&console.warn("Detected rapid post processing modifications - this might be a bug",this)),this._lastApplyTime=Date.now()),this._isDirty=!1,this.unapply(),this._effects.length=0,(n=this.sharedProfile)!=null&&n.components&&this._effects.push(...this.sharedProfile.components);const t=this.gameObject.getComponentsInChildren(kr);if(jy&&(t!=null&&t.length)&&console.log("Additional",t),t)for(const r of t)r.active&&this._effects.push(r);this._effects.length>0&&(this._postprocessing||(this._postprocessing=new SI(this.context)),this._postprocessing.apply(this._effects),this._applyPostQueue())}unapply(){var t;jy&&console.log("Unapply PostProcessing",this),(t=this._postprocessing)==null||t.unapply()}_applyPostQueue(){if(this._modificationQueue){for(const t of this._modificationQueue.values())this.onEditorModification(t);this._modificationQueue.clear()}}onEditorModification(t){var i,n;if(t.propertyName.startsWith("postprocessing.")){if(!this._postprocessing)return this._modificationQueue||(this._modificationQueue=new Map),this._modificationQueue.set(t.propertyName,t),!0;if(!((i=this._effects)!=null&&i.length))return;const r=t.propertyName.split(".");if(r.length===3||r.length===4){const o=r[1],a=r[2];for(const c of this._effects)if(((n=c.typeName)==null?void 0:n.toLowerCase())===o.toLowerCase()){if(a==="active"){c.active=t.value,this.scheduleRecreate();return}if(!Cw.has(o)){const l=new Array;Cw.set(o,l);const h=Object.keys(c);for(const u of h)c[u]instanceof Lt&&l.push(u)}if(Cw.has(o)){const l=a.toLowerCase(),h=Cw.get(o);for(const u of h)if(u.toLowerCase()===l){const f=c[u];f instanceof Lt&&(r.length===4&&r[3]==="active"?(f.overrideState=t.value,this.scheduleRecreate()):f&&f.value!==void 0&&(f.value=t.value));return}}console.warn("Unknown modification",a);return}}return!0}return!1}scheduleRecreate(){const t=++this._recreateId;setTimeout(()=>{t===this._recreateId&&(this.onDisable(),this.onEnable())},200)}}$ge([SA(jb)],i_.prototype,"sharedProfile",2);const Cw=new Map;var eme=Object.defineProperty,tme=Object.getOwnPropertyDescriptor,EI=(s,e,t,i)=>{for(var n=i>1?void 0:i?tme(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&eme(e,t,n),n};class xl extends kr{constructor(){super(...arguments);d(this,"postExposure");d(this,"contrast");d(this,"hueShift");d(this,"saturation");d(this,"toneMappingEffect",null)}get typeName(){return"ColorAdjustments"}init(){this.postExposure.valueProcessor=t=>(t=Math.pow(2,t),t),this.postExposure.defaultValue=0,this.contrast.valueProcessor=t=>{let i=1;return t>0?i=200:t<0&&(i=100),t/i},this.contrast.defaultValue=0,this.hueShift.valueProcessor=t=>Math.PI*t/180,this.hueShift.defaultValue=0,this.saturation.valueProcessor=t=>t<0?t/100:t/(100*Math.PI),this.saturation.defaultValue=0}unapply(){var n,r,o;const t=(r=(n=this.toneMappingEffect)==null?void 0:n.mode)==null?void 0:r.value,i=(o=this.toneMappingEffect)==null?void 0:o.getThreeToneMapping(t);this.context.renderer.toneMapping=i??Xm}threeToneMappingToEffectMode(t){switch(t){case Xm:return Bs.LINEAR;case YS:return Bs.ACES_FILMIC;case lb:return Bs.AGX;case Ym:return Bs.NEUTRAL;case XS:return Bs.REINHARD;default:return Bs.LINEAR}}onCreateEffect(){var c,l,h,u,f;const t=[];this.context.renderer.toneMapping!==io&&this.postExposure.overrideState&&(this.context.renderer.toneMapping=io),this.toneMappingEffect=(l=(c=re.findObjectOfType(i_))==null?void 0:c.sharedProfile)==null?void 0:l.components.find(p=>p.typeName==="ToneMapping");const i=(u=(h=this.toneMappingEffect)==null?void 0:h.mode)==null?void 0:u.value,n=(f=this.toneMappingEffect)==null?void 0:f.getThreeToneMapping(i),r=new E5({mode:this.threeToneMappingToEffectMode(n)});this.postExposure.onValueChanged=p=>{var A,b,v;this.postExposure.overrideState&&(this.context.renderer.toneMappingExposure=p);const g=(b=(A=this.toneMappingEffect)==null?void 0:A.mode)==null?void 0:b.value,y=(v=this.toneMappingEffect)==null?void 0:v.getThreeToneMapping(g),m=this.threeToneMappingToEffectMode(y);m!==void 0&&(r.mode=m)};const o=new m5;this.contrast.onValueChanged=p=>o.contrast=p;const a=new _5;return t.push(o),t.push(a),t.push(r),this.hueShift.onValueChanged=p=>a.hue=p,this.saturation.onValueChanged=p=>a.saturation=p,t}}EI([x(Lt)],xl.prototype,"postExposure",2);EI([x(Lt)],xl.prototype,"contrast",2);EI([x(Lt)],xl.prototype,"hueShift",2);EI([x(Lt)],xl.prototype,"saturation",2);qa("ColorAdjustments",xl);const ime=(Math.sqrt(5)-1)/4,zs=(5-Math.sqrt(5))/20,Sw=s=>Math.floor(s)|0,Ew=new Float64Array([0,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,1,0,1,1,1,0,1,-1,1,0,-1,1,1,0,-1,-1,-1,0,1,1,-1,0,1,-1,-1,0,-1,1,-1,0,-1,-1,1,1,0,1,1,1,0,-1,1,-1,0,1,1,-1,0,-1,-1,1,0,1,-1,1,0,-1,-1,-1,0,1,-1,-1,0,-1,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,0]);function nme(s=Math.random){const e=sme(s),t=new Float64Array(e).map(o=>Ew[o%32*4]),i=new Float64Array(e).map(o=>Ew[o%32*4+1]),n=new Float64Array(e).map(o=>Ew[o%32*4+2]),r=new Float64Array(e).map(o=>Ew[o%32*4+3]);return function(a,c,l,h){let u,f,p,g,y;const m=(a+c+l+h)*ime,A=Sw(a+m),b=Sw(c+m),v=Sw(l+m),_=Sw(h+m),w=(A+b+v+_)*zs,E=A-w,I=b-w,M=v-w,R=_-w,S=a-E,T=c-I,F=l-M,U=h-R;let k=0,H=0,D=0,L=0;S>T?k++:H++,S>F?k++:D++,S>U?k++:L++,T>F?H++:D++,T>U?H++:L++,F>U?D++:L++;const N=k>=3?1:0,W=H>=3?1:0,X=D>=3?1:0,se=L>=3?1:0,ae=k>=2?1:0,Ie=H>=2?1:0,ne=D>=2?1:0,me=L>=2?1:0,Ce=k>=1?1:0,Oe=H>=1?1:0,We=D>=1?1:0,He=L>=1?1:0,mt=S-N+zs,st=T-W+zs,q=F-X+zs,ze=U-se+zs,xe=S-ae+2*zs,Ne=T-Ie+2*zs,Ee=F-ne+2*zs,et=U-me+2*zs,Ze=S-Ce+3*zs,ot=T-Oe+3*zs,kt=F-We+3*zs,G=U-He+3*zs,O=S-1+4*zs,ge=T-1+4*zs,be=F-1+4*zs,Re=U-1+4*zs,Me=A&255,bt=b&255,ut=v&255,Le=_&255;let Ve=.6-S*S-T*T-F*F-U*U;if(Ve<0)u=0;else{const Xe=Me+e[bt+e[ut+e[Le]]];Ve*=Ve,u=Ve*Ve*(t[Xe]*S+i[Xe]*T+n[Xe]*F+r[Xe]*U)}let xt=.6-mt*mt-st*st-q*q-ze*ze;if(xt<0)f=0;else{const Xe=Me+N+e[bt+W+e[ut+X+e[Le+se]]];xt*=xt,f=xt*xt*(t[Xe]*mt+i[Xe]*st+n[Xe]*q+r[Xe]*ze)}let Fe=.6-xe*xe-Ne*Ne-Ee*Ee-et*et;if(Fe<0)p=0;else{const Xe=Me+ae+e[bt+Ie+e[ut+ne+e[Le+me]]];Fe*=Fe,p=Fe*Fe*(t[Xe]*xe+i[Xe]*Ne+n[Xe]*Ee+r[Xe]*et)}let ei=.6-Ze*Ze-ot*ot-kt*kt-G*G;if(ei<0)g=0;else{const Xe=Me+Ce+e[bt+Oe+e[ut+We+e[Le+He]]];ei*=ei,g=ei*ei*(t[Xe]*Ze+i[Xe]*ot+n[Xe]*kt+r[Xe]*G)}let dt=.6-O*O-ge*ge-be*be-Re*Re;if(dt<0)y=0;else{const Xe=Me+1+e[bt+1+e[ut+1+e[Le+1]]];dt*=dt,y=dt*dt*(t[Xe]*O+i[Xe]*ge+n[Xe]*be+r[Xe]*Re)}return 27*(u+f+p+g+y)}}function sme(s){const t=new Uint8Array(512);for(let i=0;i<512/2;i++)t[i]=i;for(let i=0;i<512/2-1;i++){const n=i+~~(s()*(256-i)),r=t[i];t[i]=t[n],t[n]=r}for(let i=256;i<512;i++)t[i]=t[i-256];return t}const LT=ie("debugstencil");function rme(s,e){return(s&1<<e.layer)!=0}const ome=Symbol("stencils"),Ef=class{constructor(e,t){d(this,"parser");d(this,"source");this.parser=e,this.source=t}get name(){return"NEEDLE_render_objects"}static applyStencil(e){if(!e)return;const t=e.sourceId;if(LT&&console.log(t,Ef.stencils),!t)return;const i=Ef.stencils[t];if(i)for(let n=i.length-1;n>=0;n--){const r=i[n];if(rme(r.layer,e)){LT&&console.log(r),setTimeout(()=>{ro()&&aI(e.gameObject)&&(Ni("Stencil not supported on instanced objects"),console.warn("Stencil not supported on instanced objects",e))},500);for(let o=0;o<e.sharedMaterials.length;o++){let a=e.sharedMaterials[o];a&&(a=a.clone(),a[ome]=!0,a.stencilWrite=!0,a.stencilWriteMask=255,a.stencilFuncMask=255,a.stencilRef=r.value,a.stencilFunc=r.compareFunc,a.stencilZPass=r.passOp,a.stencilFail=r.failOp,a.stencilZFail=r.zFailOp,e.sharedMaterials[o]=a)}e.gameObject.renderOrder=r.event*1e3+r.index*50;break}}}afterRoot(e){const t=this.parser.json.extensions;if(t){const i=t[cme];if(i){LT&&console.log(i);const n=i.stencil;if(n&&Array.isArray(n))for(const r of n){const o={...r};o.compareFunc=ame(o.compareFunc),o.passOp=FT(o.passOp),o.failOp=FT(o.failOp),o.zFailOp=FT(o.zFailOp),Ef.stencils[this.source]||(Ef.stencils[this.source]=[]),Ef.stencils[this.source].push(o)}}}return null}};let tv=Ef;d(tv,"stencils",{});function FT(s){switch(s){case 0:return Bu;case 1:return N4;case 2:return Q4;case 3:return z4;case 4:return G4;case 6:return H4;case 7:return V4;case 5:return j4}return 0}function ame(s){switch(s){case 1:return qB;case 2:return W4;case 3:return q4;case 4:return X4;case 5:return Y4;case 6:return J4;case 7:return K4;case 8:return qC}return qB}const cme="NEEDLE_render_objects",K6=Symbol("customVisibilityFlag");function wf(s,e){s.layers[K6]=e}const IQ=Symbol("DidPatchLayers");function lme(){const s=Tr.prototype;if(s[IQ])return;s[IQ]=!0;const e=s.test;s.test=function(t){return this[K6]===!1?!1:e.call(this,t)}}lme();var hme=Object.defineProperty,ume=Object.getOwnPropertyDescriptor,Z6=(s,e,t,i)=>{for(var n=i>1?void 0:i?ume(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&hme(e,t,n),n};const Wy=ie("debugreflectionprobe"),MQ=ie("noreflectionprobe"),dme=Symbol("reflectionProbeKey"),fme=Symbol("original material");var Jw;const ah=(Jw=class extends Te{constructor(){var e;super();d(this,"_texture");d(this,"center");d(this,"size");d(this,"_boxHelper");ah._probes.has(this.context)||ah._probes.set(this.context,[]),(e=ah._probes.get(this.context))==null||e.push(this)}static get(e,t,i,n){if(!e||e.isObject3D!==!0||MQ)return null;const r=ah._probes.get(t);if(r){for(const o of r)if(o.__didAwake||o.__internalAwake(),o.enabled){if(n){if(o.gameObject===n)return o}else if(o.isInBox(e,void 0))return Wy&&console.log("Found reflection probe",e.name,o.name),o}}return Wy&&console.debug("Did not find reflection probe",e.name,i,e),null}set texture(e){if(e&&!(e instanceof Ht)){console.error("ReflectionProbe.texture must be a Texture",e);return}this._texture=e,e&&(e.mapping=vo,e.colorSpace=gt,e.needsUpdate=!0)}get texture(){return this._texture}isInBox(e,t){var i;return(i=this._boxHelper)==null?void 0:i.isInBox(e,t)}awake(){this._boxHelper=this.gameObject.addNewComponent(Da),this._boxHelper.updateBox(!0),Wy&&this._boxHelper.showHelper(5592320,!0),this.texture&&(this.texture.mapping=vo,this.texture.colorSpace=gt,this.texture.needsUpdate=!0)}onDestroy(){const e=ah._probes.get(this.context);if(e){const t=e.indexOf(this);t>=0&&e.splice(t,1)}}onSet(e){var i;if(MQ||!this.enabled||((i=e.sharedMaterials)==null?void 0:i.length)<=0||!this.texture)return;let t=ah._rendererMaterialsCache.get(e);t||(t=[],ah._rendererMaterialsCache.set(e,t));for(let n=0;n<e.sharedMaterials.length;n++){const r=e.sharedMaterials[n];if(!r||r.envMap===void 0)continue;let o=t[n];const a=r===(o==null?void 0:o.copy),c=!o||o.material.uuid!==r.uuid||o.copy.version!==r.version;if(!a&&c){if(Wy){let u="";o?o.material!==r?u="reference changed; cached instance?: "+a:o.copy.version!==r.version&&(u="version changed"):u="not cached",console.warn("Cloning material",r.name,r.version,"Reason:",u,`
6233
6233
  `,r.uuid,`
6234
6234
  `,o==null?void 0:o.copy.uuid,`
6235
- `,e.name)}const h=r.clone();h.version=r.version,o?(o.copy=h,o.material=r):(o={material:r,copy:h},t.push(o)),h[dme]=this,h[fme]=r,Wy&&console.log("Set reflection",e.name,e.guid)}o&&o.copy&&(o.copy.onBeforeCompile=r.onBeforeCompile);const l=o==null?void 0:o.copy;l.envMap=this.texture,e.sharedMaterials[n]=l}}onUnset(e){const t=ah._rendererMaterialsCache.get(e);if(t)for(let i=0;i<t.length;i++){const n=t[i];e.sharedMaterials[i]=n.material}}},d(Jw,"_probes",new Map),d(Jw,"_rendererMaterialsCache",new Map),Jw);let WA=ah;Z6([x(C)],WA.prototype,"center",2);Z6([x(C)],WA.prototype,"size",2);const UT=ie("debugexr");class pme{constructor(e){d(this,"parser");this.parser=e,UT&&console.log(e)}get name(){return"EXT_texture_exr"}loadTexture(e){const t=this.name,i=this.parser,r=i.json.textures[e];if(UT&&console.log("EXT_texture_exr.loadTexture",e,r),!r.extensions||!r.extensions[t])return null;const o=r.extensions[t],a=new Hv(i.options.manager);return UT&&console.log("EXT_texture_exr.loadTexture",o),i.loadTextureImage(e,o.source,a)}}typeof window<"u"&&window.addEventListener("unhandledrejection",s=>{});const eh=Ds,Iw="$___Export_Components",gme="NEEDLE_components";var $_e;class mme{constructor(){d(this,$_e)}}$_e=_f;class Ame{constructor(e,t,i){d(this,"node");d(this,"nodeIndex");d(this,"nodeDef");this.node=e,this.nodeIndex=t,this.nodeDef=i}}class yme{constructor(){d(this,"parser");d(this,"nodeToObjectMap",{});d(this,"exportContext");d(this,"objectToNodeMap",{});d(this,"context");d(this,"writer")}get name(){return gme}registerExport(e){e.register(t=>{if("serializeUserData"in t){const i=t.serializeUserData.bind(t);this.writer=t,t.serializeUserData=(n,r)=>{try{this.serializeUserData(n,r),i(n,r)}finally{this.afterSerializeUserData(n,r)}}}return this})}beforeParse(){this.exportContext={},this.objectToNodeMap={}}serializeUserData(e,t){var n;const i=(n=e.userData)==null?void 0:n.components;!i||i.length<=0||(delete e.userData.components,e[Iw]=i)}afterSerializeUserData(e,t){if(e.type==="Scene"&&eh&&console.log("DONE",JSON.stringify(t)),e[Iw]===void 0)return;const i=e[Iw];delete e[Iw],i!==null&&(e.userData.components=i)}writeNode(e,t){const i=this.writer.json.nodes.length;eh&&console.log(e.name,i,e.uuid);const n=new Ame(e,i,t);this.exportContext[i]=n,this.objectToNodeMap[e.uuid]=i}afterParse(e){var t;eh&&console.log("AFTER",e);for(const i in this.exportContext){const n=this.exportContext[i],r=n.node,o=n.nodeDef,a=n.nodeIndex,c=(t=r.userData)==null?void 0:t.components;if(!c||c.length<=0)continue;const l=new mme;o.extensions=o.extensions||{},o.extensions[this.name]=l,this.context.object=r,this.context.nodeId=a,this.context.objectToNode=this.objectToNodeMap;const h=[];for(const u of c){this.context.target=u;const f=wc().writeBuiltinComponentData(u,this.context);f!==null&&h.push(f)}h.length>0&&(l[_f]=h,eh&&console.log("DID WRITE",r,"nodeIndex",a,h))}}beforeRoot(){return eh&&console.log("BEGIN LOAD"),this.nodeToObjectMap={},null}async afterRoot(e){const t=e.parser,i=t==null?void 0:t.extensions;if(!i)return;const n=i[this.name];eh&&console.log("After root",e,this.parser,i);const r=[];if(n===!0){const o=t.json.nodes;if(o){for(let a=0;a<o.length;a++){const c=await t.getDependency("node",a);this.nodeToObjectMap[a]=c}for(let a=0;a<o.length;a++){const c=o[a],l=a,h=c.extensions;if(!h)continue;const u=h[this.name];if(!u)continue;eh&&console.log("NODE",c);const f=this.nodeToObjectMap[l];if(!f){console.error("Could not find object for node index: "+l,c,t);continue}cI(f),r.push(this.createComponents(f,u))}}}await Promise.all(r)}async createComponents(e,t){if(!t)return;const i=t[_f];if(i){const n=new Array;eh&&console.log(e.name,i);for(const r in i){const o=i[r];eh&&console.log("Serialized data",JSON.parse(JSON.stringify(o))),o&&this.parser&&n.push(fk(this.parser,o).catch(a=>console.error(`Error while resolving references (see console for details)
6236
- `,a,e,o))),e.userData=e.userData||{},e.userData[_f]=e.userData[_f]||[],e.userData[_f].push(o)}await Promise.all(n).catch(r=>{console.error("Error while loading components",r)})}}}const TQ="NEEDLE_gameobject_data";class vme{constructor(e){d(this,"parser");this.parser=e}get name(){return TQ}afterRoot(e){var i;const t=[];for(let n=0;n<((i=this.parser.json.nodes)==null?void 0:i.length);n++){const r=this.parser.json.nodes[n];if(r&&r.extensions){const o=r.extensions[TQ];if(o){const a=this.findAndApplyExtensionData(n,o);t.push(a)}}}return Promise.all(t).then(()=>null)}async findAndApplyExtensionData(e,t){const i=await this.parser.getDependency("node",e);i&&this.applyExtensionData(i,t)}applyExtensionData(e,t){t.layers===void 0&&(t.layers=0),e.userData.layer=t.layers,e.layers.disableAll(),e.layers.set(t.layers),e.userData.tag=t.tag??"none",e.userData.hideFlags=t.hideFlags??0,e.userData.static=t.static??!1,e.visible=t.activeSelf??!0,e.guid=t.guid}}const BQ="NEEDLE_lighting_settings",lm=ie("debugenvlight");class bme{constructor(e,t,i){d(this,"parser");d(this,"sourceId");d(this,"context");this.parser=e,this.sourceId=t,this.context=i}get name(){return BQ}afterRoot(e){const t=this.parser.json.extensions;if(t){const i=t[BQ];if(i){lm&&console.log('Loaded "'+this.name+'", src: "'+this.sourceId+'"',i);let n;if(e.scene.children.length===1){const r=e.scene.children[0];n=re.addNewComponent(r,TS,{},!1)}else{const r=new ye;r.name="LightSettings "+this.sourceId,e.scene.add(r),n=re.addNewComponent(r,TS,{},!1)}n.sourceId=this.sourceId,n.ambientIntensity=i.ambientIntensity,n.ambientLight=new ve().fromArray(i.ambientLight),Array.isArray(i.ambientTrilight)&&(n.ambientTrilight=i.ambientTrilight.map(r=>new ve().fromArray(r))),n.ambientMode=i.ambientMode,n.environmentReflectionSource=i.environmentReflectionSource}}return null}}ui.registerCallback(Ti.ContextCreated,s=>{const e=s.context,t=re.findObjectOfType(TS,e);t!=null&&t.sourceId&&(t.enabled=!0)});class TS extends Te{constructor(){super(...arguments);d(this,"ambientMode",Hm.Skybox);d(this,"ambientLight");d(this,"ambientTrilight");d(this,"ambientIntensity",1);d(this,"environmentReflectionSource",SS.Skybox);d(this,"_hasReflection",!1);d(this,"_ambientLightObj");d(this,"_hemisphereLightObj")}awake(){var i;if(this.sourceId){const n=this.environmentReflectionSource===SS.Skybox?qu.Skybox:qu.Reflection,r=this.context.lightmaps.tryGet(this.sourceId,n,0);this._hasReflection=r!=null,r&&this.context.sceneLighting.internalRegisterReflection(this.sourceId,r)}this.enabled=!1,this.context.sceneLighting.internalRegisterSceneLightSettings(this),lm&&window.addEventListener("keydown",n=>{if(!this.destroyed)switch(n.key){case"l":this.enabled=!this.enabled;break}});const t=(i=this.gameObject.userData)==null?void 0:i.components;if(t){const n=t.indexOf(this);t.splice(n,1),t.push(this)}}onDestroy(){this.context.sceneLighting.internalUnregisterSceneLightSettings(this)}calculateIntensityFactor(t){const i=Math.max(t.r,t.g,t.b);return 2.2*tt.lerp(0,1.33,i)}onEnable(){if(lm&&console.warn("💡🟡 >>> Enable lighting",this.sourceId,this.enabled,this),this.ambientMode==Hm.Flat){if(this.ambientLight&&!this._ambientLightObj){const t=this.calculateIntensityFactor(this.ambientLight);this._ambientLightObj=new EE(this.ambientLight,this.ambientIntensity*t),lm&&console.log("Created ambient light",this.sourceId,this._ambientLightObj,this.ambientIntensity,t)}this._ambientLightObj&&this.gameObject.add(this._ambientLightObj)}else if(this.ambientMode===Hm.Trilight){if(this.ambientTrilight){const t=this.ambientTrilight[0],i=this.ambientTrilight[this.ambientTrilight.length-1],n=this.calculateIntensityFactor(i);this._hemisphereLightObj=new QD(i,t,this.ambientIntensity*n),this.gameObject.add(this._hemisphereLightObj),lm&&console.log("Created hemisphere ambient light",this.sourceId,this._hemisphereLightObj,this.ambientIntensity,n)}}else this._ambientLightObj&&this._ambientLightObj.removeFromParent(),this._hemisphereLightObj&&this._hemisphereLightObj.removeFromParent();this.sourceId&&this.context.sceneLighting.internalEnableReflection(this.sourceId)}onDisable(){lm&&console.warn("💡⚫ <<< Disable lighting:",this.sourceId,this),this._ambientLightObj&&this._ambientLightObj.removeFromParent(),this._hemisphereLightObj&&this._hemisphereLightObj.removeFromParent(),this.sourceId&&this.context.sceneLighting.internalDisableReflection(this.sourceId)}}var $6=(s=>(s[s.INT=5124]="INT",s[s.FLOAT=5126]="FLOAT",s[s.FLOAT_VEC2=35664]="FLOAT_VEC2",s[s.FLOAT_VEC3=35665]="FLOAT_VEC3",s[s.FLOAT_VEC4=35666]="FLOAT_VEC4",s[s.INT_VEC2=35667]="INT_VEC2",s[s.INT_VEC3=35668]="INT_VEC3",s[s.INT_VEC4=35669]="INT_VEC4",s[s.BOOL=35670]="BOOL",s[s.BOOL_VEC2=35671]="BOOL_VEC2",s[s.BOOL_VEC3=35672]="BOOL_VEC3",s[s.BOOL_VEC4=35673]="BOOL_VEC4",s[s.FLOAT_MAT2=35674]="FLOAT_MAT2",s[s.FLOAT_MAT3=35675]="FLOAT_MAT3",s[s.FLOAT_MAT4=35676]="FLOAT_MAT4",s[s.SAMPLER_2D=35678]="SAMPLER_2D",s[s.SAMPLER_3D=35680]="SAMPLER_3D",s[s.SAMPLER_CUBE=35681]="SAMPLER_CUBE",s[s.UNKNOWN=0]="UNKNOWN",s))($6||{});const Lu=ie("debugcustomshader"),qg="NEEDLE_techniques_webgl";class _me{constructor(){d(this,"objectToWorldMatrix",new Ae);d(this,"worldToObjectMatrix",new Ae);d(this,"objectToWorld",new Array);d(this,"worldToObject",new Array)}updateFrom(e){this.objectToWorldMatrix.copy(e.matrixWorld),CS(this.objectToWorldMatrix,this.objectToWorld),this.worldToObjectMatrix.copy(e.matrixWorld).invert(),CS(this.worldToObjectMatrix,this.worldToObject)}}const hn=class extends xE{constructor(t,...i){super(...i);d(this,"identifier");d(this,"onBeforeRenderSceneCallback",this.onBeforeRenderScene.bind(this));d(this,"_sphericalHarmonicsName","unity_SpecCube0");d(this,"_objToWorldName","hlslcc_mtx4x4unity_ObjectToWorld");d(this,"_worldToObjectName","hlslcc_mtx4x4unity_WorldToObject");d(this,"_viewProjectionName","hlslcc_mtx4x4unity_MatrixVP");d(this,"_viewMatrixName","hlslcc_mtx4x4unity_MatrixV");d(this,"_rendererData",new _me);this.identifier=t,Lu&&console.log(this),this.type="NEEDLE_CUSTOM_SHADER",this.uniforms[this._objToWorldName]||(this.uniforms[this._objToWorldName]={value:[]}),this.uniforms[this._worldToObjectName]||(this.uniforms[this._worldToObjectName]={value:[]}),this.uniforms[this._viewProjectionName]||(this.uniforms[this._viewProjectionName]={value:[]}),this.uniforms[this._sphericalHarmonicsName],(this.depthTextureUniform||this.opaqueTextureUniform)&&Dt.Current.pre_render_callbacks.push(this.onBeforeRenderSceneCallback)}clone(){const t=super.clone();return ej(t),t}dispose(){super.dispose();const t=Dt.Current.pre_render_callbacks.indexOf(this.onBeforeRenderSceneCallback);t>=0&&Dt.Current.pre_render_callbacks.splice(t,1)}get depthTextureUniform(){if(this.uniforms)return this.uniforms._CameraDepthTexture}get opaqueTextureUniform(){if(this.uniforms)return this.uniforms._CameraOpaqueTexture}onBeforeRenderScene(){this.opaqueTextureUniform&&Dt.Current.setRequireColor(!0),this.depthTextureUniform&&Dt.Current.setRequireDepth(!0)}onBeforeRender(t,i,n,r,o,a){r.attributes.tangent||r.computeTangents(),this.onUpdateUniforms(n,o)}onUpdateUniforms(t,i){const n=Dt.Current;if(t&&(hn.viewProjection&&this.uniforms[this._viewProjectionName]&&(hn.viewProjection.copy(t.projectionMatrix).multiply(t.matrixWorldInverse),CS(hn.viewProjection,hn._viewProjectionValues)),hn.viewMatrix&&this.uniforms[this._viewMatrixName]&&(hn.viewMatrix.copy(t.matrixWorldInverse),CS(hn.viewMatrix,hn._viewMatrixValues)),this.uniforms[hn._worldSpaceCameraPosName]&&hn._worldSpaceCameraPos.setFromMatrixPosition(t.matrixWorld)),this.uniforms._TimeParameters&&(this.uniforms._TimeParameters.value=n.sceneLighting.timeVec4),this.uniforms._Time){const c=this.uniforms._Time.value;c.x=n.sceneLighting.timeVec4.x/20,c.y=n.sceneLighting.timeVec4.x,c.z=n.sceneLighting.timeVec4.x*2,c.w=n.sceneLighting.timeVec4.x*3}if(this.uniforms._SinTime){const c=this.uniforms._SinTime.value;c.x=Math.sin(n.sceneLighting.timeVec4.x/8),c.y=Math.sin(n.sceneLighting.timeVec4.x/4),c.z=Math.sin(n.sceneLighting.timeVec4.x/2),c.w=Math.sin(n.sceneLighting.timeVec4.x)}if(this.uniforms._CosTime){const c=this.uniforms._CosTime.value;c.x=Math.cos(n.sceneLighting.timeVec4.x/8),c.y=Math.cos(n.sceneLighting.timeVec4.x/4),c.z=Math.cos(n.sceneLighting.timeVec4.x/2),c.w=Math.cos(n.sceneLighting.timeVec4.x)}if(this.uniforms.unity_DeltaTime){const c=this.uniforms.unity_DeltaTime.value;c.x=n.time.deltaTime,c.y=1/n.time.deltaTime,c.z=n.time.smoothedDeltaTime,c.w=1/n.time.smoothedDeltaTime}const r=n.mainLight;if(r){const c=Ot(r.gameObject,hn._mainLightPosition);this.uniforms._MainLightPosition={value:c.normalize()},hn._mainLightColor.set(r.color.r,r.color.g,r.color.b,0),this.uniforms._MainLightColor={value:hn._mainLightColor};const l=r.intensity;hn._lightData.z=l,this.uniforms.unity_LightData={value:hn._lightData}}if(t&&(hn.viewProjection&&this.uniforms[this._viewProjectionName]&&(this.uniforms[this._viewProjectionName].value=hn._viewProjectionValues),hn.viewMatrix&&this.uniforms[this._viewMatrixName]&&(this.uniforms[this._viewMatrixName].value=hn._viewMatrixValues),this.uniforms[hn._worldSpaceCameraPosName]&&(this.uniforms[hn._worldSpaceCameraPosName]={value:hn._worldSpaceCameraPos}),n.mainCameraComponent)){if(this.uniforms._ProjectionParams){const c=this.uniforms._ProjectionParams.value;c.x=1,c.y=n.mainCameraComponent.nearClipPlane,c.z=n.mainCameraComponent.farClipPlane,c.w=1/c.z,this.uniforms._ProjectionParams.value=c}if(this.uniforms._ZBufferParams){const c=this.uniforms._ZBufferParams.value,l=n.mainCameraComponent;c.x=1-l.farClipPlane/l.nearClipPlane,c.y=l.farClipPlane/l.nearClipPlane,c.z=c.x/l.farClipPlane,c.w=c.y/l.farClipPlane,this.uniforms._ZBufferParams.value=c}if(this.uniforms._ScreenParams){const c=this.uniforms._ScreenParams.value;c.x=n.domWidth,c.y=n.domHeight,c.z=1+1/c.x,c.w=1+1/c.y,this.uniforms._ScreenParams.value=c}if(this.uniforms._ScaledScreenParams){const c=this.uniforms._ScaledScreenParams.value;c.x=n.domWidth,c.y=n.domHeight,c.z=1+1/c.x,c.w=1+1/c.y,this.uniforms._ScaledScreenParams.value=c}}const o=this.depthTextureUniform;o&&(o.value=n.depthTexture);const a=this.opaqueTextureUniform;if(a&&(a.value=n.opaqueColorTexture),i){const c=this._rendererData;c.updateFrom(i),this.uniforms[this._worldToObjectName].value=c.worldToObject,this.uniforms[this._objToWorldName].value=c.objectToWorld}this.uniformsNeedUpdate=!0}};let Qo=hn;d(Qo,"viewProjection",new Ae),d(Qo,"_viewProjectionValues",[]),d(Qo,"viewMatrix",new Ae),d(Qo,"_viewMatrixValues",[]),d(Qo,"_worldSpaceCameraPosName","_WorldSpaceCameraPos"),d(Qo,"_worldSpaceCameraPos",new C),d(Qo,"_mainLightColor",new Ke),d(Qo,"_mainLightPosition",new C),d(Qo,"_lightData",new Ke);class xme{constructor(e,t){d(this,"parser");d(this,"identifier");this.parser=e,this.identifier=t}get name(){return qg}loadMaterial(e){const t=this.parser.json.materials[e];if(!t)return Lu&&console.log(e,this.parser.json.materials),null;if(!t.extensions||!t.extensions[qg])return Lu&&console.log("material "+e+" does not use NEEDLE_techniques_webgl"),null;const i=t.extensions[qg].technique;if(i<0)return null;const n=this.parser.json.extensions[qg];if(!n)return null;Lu&&console.log(n);const r=n.techniques[i];return r?new Promise(async(o,a)=>{var A,b,v;const c=await Wde(n,r.program),l=c==null?void 0:c.fragmentShader,h=c==null?void 0:c.vertexShader;if(!l||!h)return a();Lu&&console.log("loadMaterial",t,c);const u={},f=r.uniforms;(h.includes("_Time")||l.includes("_Time"))&&(u._Time={value:new Ke(0,0,0,0)}),(h.includes("_SinTime")||l.includes("_SinTime"))&&(u._SinTime={value:new Ke(0,0,0,0)}),(h.includes("_CosTime")||l.includes("_CosTime"))&&(u._CosTime={value:new Ke(0,0,0,0)}),(h.includes("unity_DeltaTime")||l.includes("unity_DeltaTime"))&&(u.unity_DeltaTime={value:new Ke(0,0,0,0)});for(const _ in f){const w=_;switch(w){case"_TimeParameters":const E=new Ke;u[w]={value:E};break;case"hlslcc_mtx4x4unity_MatrixV":case"hlslcc_mtx4x4unity_MatrixVP":u[w]={value:[]};break;case"_MainLightPosition":case"_MainLightColor":case"_WorldSpaceCameraPos":u[w]={value:[0,0,0,1]};break;case"unity_OrthoParams":break;case"unity_SpecCube0":u[w]={value:null};break;default:case"_ScreenParams":case"_ZBufferParams":case"_ProjectionParams":u[w]={value:[0,0,0,0]};break;case"_CameraOpaqueTexture":case"_CameraDepthTexture":u[w]={value:null};break}}let p=!1;if(t.extensions&&t.extensions[qg]){const _=t.extensions[qg];if(_.technique===i){Lu&&console.log(t.name,"Material Properties",_);for(const w in _.values){const E=_.values[w];if(typeof E=="string"){if(E.startsWith("/textures/")){const I=E.substring(10),M=Number.parseInt(I);if(M>=0){const R=await this.parser.getDependency("texture",M);R instanceof Ht&&(R.colorSpace=Ii,R.needsUpdate=!0),u[w]={value:R};continue}}switch(w){case"alphaMode":E==="BLEND"&&(p=!0);continue}}if(Array.isArray(E)&&E.length===4){u[w]={value:new Ke(E[0],E[1],E[2],E[3])};continue}u[w]={value:E}}}}const g=new Qo(this.identifier,{name:t.name??"",uniforms:u,vertexShader:h,fragmentShader:l,lights:!1});switch(g.glslVersion=XC,g.vertexShader=g.vertexShader.replace("#version 300 es",""),g.fragmentShader=g.fragmentShader.replace("#version 300 es",""),(A=u._Cull)==null?void 0:A.value){case 0:g.side=vi;break;case 1:g.side=wn;break;case 2:g.side=ys;break;default:g.side=ys;break}switch((b=u._ZTest)==null?void 0:b.value){case 3:g.depthTest=!0,g.depthFunc=qm;break;case 6:g.depthTest=!0,g.depthFunc=ab;break;case 2:g.depthTest=!0,g.depthFunc=dv;break;case 4:g.depthTest=!0,g.depthFunc=tp;break;case 5:g.depthTest=!0,g.depthFunc=qS;break;case 7:g.depthTest=!0,g.depthFunc=WS;break;case 8:g.depthTest=!1,g.depthFunc=jS;break}g.transparent=p,p&&(g.depthWrite=!1),Vde(u),g.onUpdateUniforms();for(const _ in f){const w=_,E=f[_].type;if(((v=u[w])==null?void 0:v.value)===void 0)switch(E){case $6.SAMPLER_2D:u[w]={value:Gde},console.warn("Missing/unassigned texture, fallback to white: "+w);break;default:w==="unity_OrthoParams"||console.warn("TODO: EXPECTED UNIFORM / fallback NOT SET: "+w,f[_]);break}}Lu&&console.log(g.uuid,u),ej(g),o(g)}):null}}function ej(s){if(s.uniforms){Lu&&console.log("Uniforms:",s.uniforms);for(const t in s.uniforms)switch(e(t,t),t){case"_Color":e("color",t);break}}function e(t,i){Object.getOwnPropertyDescriptor(s,t)||Object.defineProperty(s,t,{get:()=>s.uniforms[i].value,set:n=>{s.uniforms[i].value=n,s.needsUpdate=!0}})}}const wme=ie("debugextensions");let BS;const Cme=Promise.resolve().then(()=>Z_e).then(async s=>(BS=s.GLTFAnimationPointerExtension,BS)).catch(s=>{console.warn("Failed to import GLTFLoaderAnimationPointer. Please use @needle-tools/three for full KHR_animation support",s)}),_p=new Array;function Sme(s){_p.includes(s)||_p.push(s)}function Eme(s){const e=_p.indexOf(s);e>=0&&_p.splice(e,1)}function sO(s){const e=new yme;return s.register(t=>(e.parser=t,e)),e}class Ime{resolvePath(e){return e.includes("/extensions/builtin_components/")?e.replace("/extensions/builtin_components/","/userData/components/"):e.includes("extensions/builtin_components/")?e.replace("extensions/builtin_components/","/userData/components/"):e}}async function rO(s,e,t){const i=t.indexOf("?");i>=0&&(t=t.substring(0,i)),s.register(n=>new vme(n)),s.register(n=>new aue(n)),s.register(n=>new Ude(n,e.lightmaps,t)),s.register(n=>new bme(n,t,e)),s.register(n=>new xme(n,t)),s.register(n=>new tv(n,t)),s.register(n=>new mi(n,t)),s.register(n=>new pme(n)),i5()&&s.register(n=>new V0(n)),await Cme.catch(n=>{}),s.register(n=>{if(BS){const r=new BS(n);return r.setAnimationPointerResolver.bind(r)(new Ime),r}else return(wme||ht())&&console.error("Missing KHR_animation_pointer extension..."),{name:"KHR_animation_pointer_NOT_AVAILABLE"}});for(const n of _p)n.onImport&&n.onImport(s,t,e)}function oO(s,e){for(const t of _p)t.onExport&&t.onExport(s,e)}function aO(s,e,t){for(const i of _p)i.onLoaded&&i.onLoaded(s,e,t)}const cc=ie("debuginstancing"),eL=class{constructor(){d(this,"objs",[])}setup(e,t,i,n,r,o=0){e.applySettings(t);const a=this.tryCreateOrAddInstance(t,i,r);if(a)mi.assignTextureLOD(a.renderer.material,0),n===null&&(n=[]),n.push(a);else if(o<=0&&t.type!=="Mesh"){const c=o+1;for(const l of t.children)n=this.setup(e,l,i,n,r,c)}return o===0&&r.useMatrixWorldAutoUpdate&&n&&n.length>=0&&this.autoUpdateInstanceMatrix(t),n}tryCreateOrAddInstance(e,t,i){if(e.type==="Mesh"){const n=i.foundMeshes;if(i.foundMeshes+=1,!i.rend.enableInstancing)return null;if(i.rend.enableInstancing!==!0){if(n>=i.rend.enableInstancing.length)return cc&&console.error("Something is wrong with instance setup",e,i.rend.enableInstancing,n),null;if(!i.rend.enableInstancing[n])return null}const r=e,o=r.material;for(const u of this.objs){if(!u.canAdd(r.geometry,o))continue;return u.addInstance(r)}const a=16;let c=e.name;c!=null&&c.length||(c=KD());const l=new tj(c,r.geometry,o,a,t);return this.objs.push(l),l.addInstance(r)}return null}autoUpdateInstanceMatrix(e){const t=e.matrixWorld.multiplyMatrices.bind(e.matrixWorld),i=e.matrixWorld.clone(),n=(r,o)=>{const a=t(r,o);return(e[Nv]||i.equals(a)===!1)&&(i.copy(a),e[Nv]=!0),a};e.matrixWorld.multiplyMatrices=n}};let Yf=eL;d(Yf,"instance",new eL);const hv=class{constructor(e,t){d(this,"object");d(this,"renderer");d(this,"__instanceIndex",-1);d(this,"__reservedVertexRange",0);d(this,"__reservedIndexRange",0);d(this,"meshInformation");this.__instanceIndex=-1,this.object=e,this.renderer=t,e[a5]=t,this.meshInformation=hm(e.geometry),hv.all.push(this)}get name(){return this.object.name}get isActive(){return this.__instanceIndex>=0}get vertexCount(){return this.object.geometry.attributes.position.count}get maxVertexCount(){return this.meshInformation.vertexCount}get reservedVertexCount(){return this.__reservedVertexRange}get indexCount(){return this.object.geometry.index?this.object.geometry.index.count:0}get maxIndexCount(){return this.meshInformation.indexCount}get reservedIndexCount(){return this.__reservedIndexRange}updateInstanceMatrix(e=!1,t=!0){this.__instanceIndex<0||(t&&this.object.updateWorldMatrix(!0,e),this.renderer.updateInstance(this.object.matrixWorld,this.__instanceIndex))}setMatrix(e){this.__instanceIndex<0||this.renderer.updateInstance(e,this.__instanceIndex)}setGeometry(e){return this.__instanceIndex<0?!1:this.vertexCount>this.__reservedVertexRange?(console.error(`Cannot update geometry, reserved range is too small: ${this.__reservedVertexRange} < ${this.vertexCount} vertices for ${this.name}`),!1):this.indexCount>this.__reservedIndexRange?(console.error(`Cannot update geometry, reserved range is too small: ${this.__reservedIndexRange} < ${this.indexCount} indices for ${this.name}`),!1):this.renderer.updateGeometry(e,this.__instanceIndex)}add(){this.__instanceIndex>=0||(this.renderer.add(this),re.markAsInstancedRendered(this.object,!0))}remove(e){if(!(this.__instanceIndex<0)&&(this.renderer.remove(this,e),re.markAsInstancedRendered(this.object,!1),e)){const t=hv.all.indexOf(this);t>=0&&hv.all.splice(t,1)}}};let Jf=hv;d(Jf,"all",[]);class tj{constructor(e,t,i,n,r){d(this,"allowResize",!0);d(this,"name","");d(this,"geometry");d(this,"material");d(this,"context");d(this,"inst");d(this,"handles",[]);d(this,"maxInstanceCount");d(this,"_currentInstanceCount",0);d(this,"_currentVertexCount",0);d(this,"_currentIndexCount",0);d(this,"_maxVertexCount");d(this,"_maxIndexCount");d(this,"_needUpdateBounds",!1);d(this,"_debugMaterial",null);d(this,"onBeforeRender",()=>{this.inst.layers.enableAll(),this._needUpdateBounds&&this.inst[p0]===!0&&(cc&&console.log("Update instancing bounds",this.name,this.inst.matrixWorldNeedsUpdate),this.updateBounds())});d(this,"onAfterRender",()=>{this.inst.layers.disableAll()});d(this,"_availableBuckets",new Array);d(this,"_usedBuckets",new Array);this.name=e,this.geometry=t,this.material=i,this.context=r,this.maxInstanceCount=Math.max(2,n),cc&&(this._debugMaterial=RQ());const o=this.tryEstimateVertexCountSize(this.maxInstanceCount,[t],n);this._maxVertexCount=o.vertexCount,this._maxIndexCount=o.indexCount,this.inst=new KC(this.maxInstanceCount,this._maxVertexCount,this._maxIndexCount,this._debugMaterial??this.material),this.inst[p0]=!0,this.inst.visible=!0,this.context.scene.add(this.inst),i instanceof xE&&(i.defines.USE_INSTANCING=!0,i.needsUpdate=!0),r.pre_render_callbacks.push(this.onBeforeRender),r.post_render_callbacks.push(this.onAfterRender),cc&&console.log(`Instanced renderer created with ${this.maxInstanceCount} instances, ${this._maxVertexCount} max vertices and ${this._maxIndexCount} max indices for "${e}"`)}get mesh(){return this.inst}get visible(){return this.inst.visible}set visible(e){this.inst.visible=e}get castShadow(){return this.inst.castShadow}set castShadow(e){this.inst.castShadow=e}set receiveShadow(e){this.inst.receiveShadow=e}updateBounds(e=!0,t=!0){this._needUpdateBounds=!1,e&&this.inst.computeBoundingBox(),t&&this.inst.computeBoundingSphere()}get count(){return this._currentInstanceCount}canAdd(e,t){return this._maxVertexCount>1e7||t!==this.material?!1:!!(!this.mustGrow(e)||this.allowResize)}dispose(){cc&&console.warn("Dispose instanced renderer",this.name),this.context.scene.remove(this.inst),this.inst.dispose(),this.inst=null,this.handles=[]}addInstance(e){const t=new Jf(e,this);e.castShadow===!0&&this.inst.castShadow===!1&&(this.inst.castShadow=!0),e.receiveShadow===!0&&this.inst.receiveShadow===!1&&(this.inst.receiveShadow=!0);try{this.add(t)}catch(i){return console.error(`Failed adding mesh to instancing
6235
+ `,e.name)}const h=r.clone();h.version=r.version,o?(o.copy=h,o.material=r):(o={material:r,copy:h},t.push(o)),h[dme]=this,h[fme]=r,Wy&&console.log("Set reflection",e.name,e.guid)}o&&o.copy&&(o.copy.onBeforeCompile=r.onBeforeCompile);const l=o==null?void 0:o.copy;l.envMap=this.texture,e.sharedMaterials[n]=l}}onUnset(e){const t=ah._rendererMaterialsCache.get(e);if(t)for(let i=0;i<t.length;i++){const n=t[i];e.sharedMaterials[i]=n.material}}},d(Jw,"_probes",new Map),d(Jw,"_rendererMaterialsCache",new Map),Jw);let WA=ah;Z6([x(C)],WA.prototype,"center",2);Z6([x(C)],WA.prototype,"size",2);const UT=ie("debugexr");class pme{constructor(e){d(this,"parser");this.parser=e,UT&&console.log(e)}get name(){return"EXT_texture_exr"}loadTexture(e){const t=this.name,i=this.parser,r=i.json.textures[e];if(UT&&console.log("EXT_texture_exr.loadTexture",e,r),!r.extensions||!r.extensions[t])return null;const o=r.extensions[t],a=new Hv(i.options.manager);return UT&&console.log("EXT_texture_exr.loadTexture",o),i.loadTextureImage(e,o.source,a)}}typeof window<"u"&&window.addEventListener("unhandledrejection",s=>{});const eh=Ds,Iw="$___Export_Components",gme="NEEDLE_components";var Z_e;class mme{constructor(){d(this,Z_e)}}Z_e=_f;class Ame{constructor(e,t,i){d(this,"node");d(this,"nodeIndex");d(this,"nodeDef");this.node=e,this.nodeIndex=t,this.nodeDef=i}}class yme{constructor(){d(this,"parser");d(this,"nodeToObjectMap",{});d(this,"exportContext");d(this,"objectToNodeMap",{});d(this,"context");d(this,"writer")}get name(){return gme}registerExport(e){e.register(t=>{if("serializeUserData"in t){const i=t.serializeUserData.bind(t);this.writer=t,t.serializeUserData=(n,r)=>{try{this.serializeUserData(n,r),i(n,r)}finally{this.afterSerializeUserData(n,r)}}}return this})}beforeParse(){this.exportContext={},this.objectToNodeMap={}}serializeUserData(e,t){var n;const i=(n=e.userData)==null?void 0:n.components;!i||i.length<=0||(delete e.userData.components,e[Iw]=i)}afterSerializeUserData(e,t){if(e.type==="Scene"&&eh&&console.log("DONE",JSON.stringify(t)),e[Iw]===void 0)return;const i=e[Iw];delete e[Iw],i!==null&&(e.userData.components=i)}writeNode(e,t){const i=this.writer.json.nodes.length;eh&&console.log(e.name,i,e.uuid);const n=new Ame(e,i,t);this.exportContext[i]=n,this.objectToNodeMap[e.uuid]=i}afterParse(e){var t;eh&&console.log("AFTER",e);for(const i in this.exportContext){const n=this.exportContext[i],r=n.node,o=n.nodeDef,a=n.nodeIndex,c=(t=r.userData)==null?void 0:t.components;if(!c||c.length<=0)continue;const l=new mme;o.extensions=o.extensions||{},o.extensions[this.name]=l,this.context.object=r,this.context.nodeId=a,this.context.objectToNode=this.objectToNodeMap;const h=[];for(const u of c){this.context.target=u;const f=wc().writeBuiltinComponentData(u,this.context);f!==null&&h.push(f)}h.length>0&&(l[_f]=h,eh&&console.log("DID WRITE",r,"nodeIndex",a,h))}}beforeRoot(){return eh&&console.log("BEGIN LOAD"),this.nodeToObjectMap={},null}async afterRoot(e){const t=e.parser,i=t==null?void 0:t.extensions;if(!i)return;const n=i[this.name];eh&&console.log("After root",e,this.parser,i);const r=[];if(n===!0){const o=t.json.nodes;if(o){for(let a=0;a<o.length;a++){const c=await t.getDependency("node",a);this.nodeToObjectMap[a]=c}for(let a=0;a<o.length;a++){const c=o[a],l=a,h=c.extensions;if(!h)continue;const u=h[this.name];if(!u)continue;eh&&console.log("NODE",c);const f=this.nodeToObjectMap[l];if(!f){console.error("Could not find object for node index: "+l,c,t);continue}cI(f),r.push(this.createComponents(f,u))}}}await Promise.all(r)}async createComponents(e,t){if(!t)return;const i=t[_f];if(i){const n=new Array;eh&&console.log(e.name,i);for(const r in i){const o=i[r];eh&&console.log("Serialized data",JSON.parse(JSON.stringify(o))),o&&this.parser&&n.push(fk(this.parser,o).catch(a=>console.error(`Error while resolving references (see console for details)
6236
+ `,a,e,o))),e.userData=e.userData||{},e.userData[_f]=e.userData[_f]||[],e.userData[_f].push(o)}await Promise.all(n).catch(r=>{console.error("Error while loading components",r)})}}}const TQ="NEEDLE_gameobject_data";class vme{constructor(e){d(this,"parser");this.parser=e}get name(){return TQ}afterRoot(e){var i;const t=[];for(let n=0;n<((i=this.parser.json.nodes)==null?void 0:i.length);n++){const r=this.parser.json.nodes[n];if(r&&r.extensions){const o=r.extensions[TQ];if(o){const a=this.findAndApplyExtensionData(n,o);t.push(a)}}}return Promise.all(t).then(()=>null)}async findAndApplyExtensionData(e,t){const i=await this.parser.getDependency("node",e);i&&this.applyExtensionData(i,t)}applyExtensionData(e,t){t.layers===void 0&&(t.layers=0),e.userData.layer=t.layers,e.layers.disableAll(),e.layers.set(t.layers),e.userData.tag=t.tag??"none",e.userData.hideFlags=t.hideFlags??0,e.userData.static=t.static??!1,e.visible=t.activeSelf??!0,e.guid=t.guid}}const BQ="NEEDLE_lighting_settings",lm=ie("debugenvlight");class bme{constructor(e,t,i){d(this,"parser");d(this,"sourceId");d(this,"context");this.parser=e,this.sourceId=t,this.context=i}get name(){return BQ}afterRoot(e){const t=this.parser.json.extensions;if(t){const i=t[BQ];if(i){lm&&console.log('Loaded "'+this.name+'", src: "'+this.sourceId+'"',i);let n;if(e.scene.children.length===1){const r=e.scene.children[0];n=re.addNewComponent(r,TS,{},!1)}else{const r=new ye;r.name="LightSettings "+this.sourceId,e.scene.add(r),n=re.addNewComponent(r,TS,{},!1)}n.sourceId=this.sourceId,n.ambientIntensity=i.ambientIntensity,n.ambientLight=new ve().fromArray(i.ambientLight),Array.isArray(i.ambientTrilight)&&(n.ambientTrilight=i.ambientTrilight.map(r=>new ve().fromArray(r))),n.ambientMode=i.ambientMode,n.environmentReflectionSource=i.environmentReflectionSource}}return null}}ui.registerCallback(Ti.ContextCreated,s=>{const e=s.context,t=re.findObjectOfType(TS,e);t!=null&&t.sourceId&&(t.enabled=!0)});class TS extends Te{constructor(){super(...arguments);d(this,"ambientMode",Hm.Skybox);d(this,"ambientLight");d(this,"ambientTrilight");d(this,"ambientIntensity",1);d(this,"environmentReflectionSource",SS.Skybox);d(this,"_hasReflection",!1);d(this,"_ambientLightObj");d(this,"_hemisphereLightObj")}awake(){var i;if(this.sourceId){const n=this.environmentReflectionSource===SS.Skybox?qu.Skybox:qu.Reflection,r=this.context.lightmaps.tryGet(this.sourceId,n,0);this._hasReflection=r!=null,r&&this.context.sceneLighting.internalRegisterReflection(this.sourceId,r)}this.enabled=!1,this.context.sceneLighting.internalRegisterSceneLightSettings(this),lm&&window.addEventListener("keydown",n=>{if(!this.destroyed)switch(n.key){case"l":this.enabled=!this.enabled;break}});const t=(i=this.gameObject.userData)==null?void 0:i.components;if(t){const n=t.indexOf(this);t.splice(n,1),t.push(this)}}onDestroy(){this.context.sceneLighting.internalUnregisterSceneLightSettings(this)}calculateIntensityFactor(t){const i=Math.max(t.r,t.g,t.b);return 2.2*tt.lerp(0,1.33,i)}onEnable(){if(lm&&console.warn("💡🟡 >>> Enable lighting",this.sourceId,this.enabled,this),this.ambientMode==Hm.Flat){if(this.ambientLight&&!this._ambientLightObj){const t=this.calculateIntensityFactor(this.ambientLight);this._ambientLightObj=new EE(this.ambientLight,this.ambientIntensity*t),lm&&console.log("Created ambient light",this.sourceId,this._ambientLightObj,this.ambientIntensity,t)}this._ambientLightObj&&this.gameObject.add(this._ambientLightObj)}else if(this.ambientMode===Hm.Trilight){if(this.ambientTrilight){const t=this.ambientTrilight[0],i=this.ambientTrilight[this.ambientTrilight.length-1],n=this.calculateIntensityFactor(i);this._hemisphereLightObj=new QD(i,t,this.ambientIntensity*n),this.gameObject.add(this._hemisphereLightObj),lm&&console.log("Created hemisphere ambient light",this.sourceId,this._hemisphereLightObj,this.ambientIntensity,n)}}else this._ambientLightObj&&this._ambientLightObj.removeFromParent(),this._hemisphereLightObj&&this._hemisphereLightObj.removeFromParent();this.sourceId&&this.context.sceneLighting.internalEnableReflection(this.sourceId)}onDisable(){lm&&console.warn("💡⚫ <<< Disable lighting:",this.sourceId,this),this._ambientLightObj&&this._ambientLightObj.removeFromParent(),this._hemisphereLightObj&&this._hemisphereLightObj.removeFromParent(),this.sourceId&&this.context.sceneLighting.internalDisableReflection(this.sourceId)}}var $6=(s=>(s[s.INT=5124]="INT",s[s.FLOAT=5126]="FLOAT",s[s.FLOAT_VEC2=35664]="FLOAT_VEC2",s[s.FLOAT_VEC3=35665]="FLOAT_VEC3",s[s.FLOAT_VEC4=35666]="FLOAT_VEC4",s[s.INT_VEC2=35667]="INT_VEC2",s[s.INT_VEC3=35668]="INT_VEC3",s[s.INT_VEC4=35669]="INT_VEC4",s[s.BOOL=35670]="BOOL",s[s.BOOL_VEC2=35671]="BOOL_VEC2",s[s.BOOL_VEC3=35672]="BOOL_VEC3",s[s.BOOL_VEC4=35673]="BOOL_VEC4",s[s.FLOAT_MAT2=35674]="FLOAT_MAT2",s[s.FLOAT_MAT3=35675]="FLOAT_MAT3",s[s.FLOAT_MAT4=35676]="FLOAT_MAT4",s[s.SAMPLER_2D=35678]="SAMPLER_2D",s[s.SAMPLER_3D=35680]="SAMPLER_3D",s[s.SAMPLER_CUBE=35681]="SAMPLER_CUBE",s[s.UNKNOWN=0]="UNKNOWN",s))($6||{});const Lu=ie("debugcustomshader"),qg="NEEDLE_techniques_webgl";class _me{constructor(){d(this,"objectToWorldMatrix",new Ae);d(this,"worldToObjectMatrix",new Ae);d(this,"objectToWorld",new Array);d(this,"worldToObject",new Array)}updateFrom(e){this.objectToWorldMatrix.copy(e.matrixWorld),CS(this.objectToWorldMatrix,this.objectToWorld),this.worldToObjectMatrix.copy(e.matrixWorld).invert(),CS(this.worldToObjectMatrix,this.worldToObject)}}const hn=class extends xE{constructor(t,...i){super(...i);d(this,"identifier");d(this,"onBeforeRenderSceneCallback",this.onBeforeRenderScene.bind(this));d(this,"_sphericalHarmonicsName","unity_SpecCube0");d(this,"_objToWorldName","hlslcc_mtx4x4unity_ObjectToWorld");d(this,"_worldToObjectName","hlslcc_mtx4x4unity_WorldToObject");d(this,"_viewProjectionName","hlslcc_mtx4x4unity_MatrixVP");d(this,"_viewMatrixName","hlslcc_mtx4x4unity_MatrixV");d(this,"_rendererData",new _me);this.identifier=t,Lu&&console.log(this),this.type="NEEDLE_CUSTOM_SHADER",this.uniforms[this._objToWorldName]||(this.uniforms[this._objToWorldName]={value:[]}),this.uniforms[this._worldToObjectName]||(this.uniforms[this._worldToObjectName]={value:[]}),this.uniforms[this._viewProjectionName]||(this.uniforms[this._viewProjectionName]={value:[]}),this.uniforms[this._sphericalHarmonicsName],(this.depthTextureUniform||this.opaqueTextureUniform)&&Dt.Current.pre_render_callbacks.push(this.onBeforeRenderSceneCallback)}clone(){const t=super.clone();return ej(t),t}dispose(){super.dispose();const t=Dt.Current.pre_render_callbacks.indexOf(this.onBeforeRenderSceneCallback);t>=0&&Dt.Current.pre_render_callbacks.splice(t,1)}get depthTextureUniform(){if(this.uniforms)return this.uniforms._CameraDepthTexture}get opaqueTextureUniform(){if(this.uniforms)return this.uniforms._CameraOpaqueTexture}onBeforeRenderScene(){this.opaqueTextureUniform&&Dt.Current.setRequireColor(!0),this.depthTextureUniform&&Dt.Current.setRequireDepth(!0)}onBeforeRender(t,i,n,r,o,a){r.attributes.tangent||r.computeTangents(),this.onUpdateUniforms(n,o)}onUpdateUniforms(t,i){const n=Dt.Current;if(t&&(hn.viewProjection&&this.uniforms[this._viewProjectionName]&&(hn.viewProjection.copy(t.projectionMatrix).multiply(t.matrixWorldInverse),CS(hn.viewProjection,hn._viewProjectionValues)),hn.viewMatrix&&this.uniforms[this._viewMatrixName]&&(hn.viewMatrix.copy(t.matrixWorldInverse),CS(hn.viewMatrix,hn._viewMatrixValues)),this.uniforms[hn._worldSpaceCameraPosName]&&hn._worldSpaceCameraPos.setFromMatrixPosition(t.matrixWorld)),this.uniforms._TimeParameters&&(this.uniforms._TimeParameters.value=n.sceneLighting.timeVec4),this.uniforms._Time){const c=this.uniforms._Time.value;c.x=n.sceneLighting.timeVec4.x/20,c.y=n.sceneLighting.timeVec4.x,c.z=n.sceneLighting.timeVec4.x*2,c.w=n.sceneLighting.timeVec4.x*3}if(this.uniforms._SinTime){const c=this.uniforms._SinTime.value;c.x=Math.sin(n.sceneLighting.timeVec4.x/8),c.y=Math.sin(n.sceneLighting.timeVec4.x/4),c.z=Math.sin(n.sceneLighting.timeVec4.x/2),c.w=Math.sin(n.sceneLighting.timeVec4.x)}if(this.uniforms._CosTime){const c=this.uniforms._CosTime.value;c.x=Math.cos(n.sceneLighting.timeVec4.x/8),c.y=Math.cos(n.sceneLighting.timeVec4.x/4),c.z=Math.cos(n.sceneLighting.timeVec4.x/2),c.w=Math.cos(n.sceneLighting.timeVec4.x)}if(this.uniforms.unity_DeltaTime){const c=this.uniforms.unity_DeltaTime.value;c.x=n.time.deltaTime,c.y=1/n.time.deltaTime,c.z=n.time.smoothedDeltaTime,c.w=1/n.time.smoothedDeltaTime}const r=n.mainLight;if(r){const c=Ot(r.gameObject,hn._mainLightPosition);this.uniforms._MainLightPosition={value:c.normalize()},hn._mainLightColor.set(r.color.r,r.color.g,r.color.b,0),this.uniforms._MainLightColor={value:hn._mainLightColor};const l=r.intensity;hn._lightData.z=l,this.uniforms.unity_LightData={value:hn._lightData}}if(t&&(hn.viewProjection&&this.uniforms[this._viewProjectionName]&&(this.uniforms[this._viewProjectionName].value=hn._viewProjectionValues),hn.viewMatrix&&this.uniforms[this._viewMatrixName]&&(this.uniforms[this._viewMatrixName].value=hn._viewMatrixValues),this.uniforms[hn._worldSpaceCameraPosName]&&(this.uniforms[hn._worldSpaceCameraPosName]={value:hn._worldSpaceCameraPos}),n.mainCameraComponent)){if(this.uniforms._ProjectionParams){const c=this.uniforms._ProjectionParams.value;c.x=1,c.y=n.mainCameraComponent.nearClipPlane,c.z=n.mainCameraComponent.farClipPlane,c.w=1/c.z,this.uniforms._ProjectionParams.value=c}if(this.uniforms._ZBufferParams){const c=this.uniforms._ZBufferParams.value,l=n.mainCameraComponent;c.x=1-l.farClipPlane/l.nearClipPlane,c.y=l.farClipPlane/l.nearClipPlane,c.z=c.x/l.farClipPlane,c.w=c.y/l.farClipPlane,this.uniforms._ZBufferParams.value=c}if(this.uniforms._ScreenParams){const c=this.uniforms._ScreenParams.value;c.x=n.domWidth,c.y=n.domHeight,c.z=1+1/c.x,c.w=1+1/c.y,this.uniforms._ScreenParams.value=c}if(this.uniforms._ScaledScreenParams){const c=this.uniforms._ScaledScreenParams.value;c.x=n.domWidth,c.y=n.domHeight,c.z=1+1/c.x,c.w=1+1/c.y,this.uniforms._ScaledScreenParams.value=c}}const o=this.depthTextureUniform;o&&(o.value=n.depthTexture);const a=this.opaqueTextureUniform;if(a&&(a.value=n.opaqueColorTexture),i){const c=this._rendererData;c.updateFrom(i),this.uniforms[this._worldToObjectName].value=c.worldToObject,this.uniforms[this._objToWorldName].value=c.objectToWorld}this.uniformsNeedUpdate=!0}};let Qo=hn;d(Qo,"viewProjection",new Ae),d(Qo,"_viewProjectionValues",[]),d(Qo,"viewMatrix",new Ae),d(Qo,"_viewMatrixValues",[]),d(Qo,"_worldSpaceCameraPosName","_WorldSpaceCameraPos"),d(Qo,"_worldSpaceCameraPos",new C),d(Qo,"_mainLightColor",new Ke),d(Qo,"_mainLightPosition",new C),d(Qo,"_lightData",new Ke);class xme{constructor(e,t){d(this,"parser");d(this,"identifier");this.parser=e,this.identifier=t}get name(){return qg}loadMaterial(e){const t=this.parser.json.materials[e];if(!t)return Lu&&console.log(e,this.parser.json.materials),null;if(!t.extensions||!t.extensions[qg])return Lu&&console.log("material "+e+" does not use NEEDLE_techniques_webgl"),null;const i=t.extensions[qg].technique;if(i<0)return null;const n=this.parser.json.extensions[qg];if(!n)return null;Lu&&console.log(n);const r=n.techniques[i];return r?new Promise(async(o,a)=>{var A,b,v;const c=await Wde(n,r.program),l=c==null?void 0:c.fragmentShader,h=c==null?void 0:c.vertexShader;if(!l||!h)return a();Lu&&console.log("loadMaterial",t,c);const u={},f=r.uniforms;(h.includes("_Time")||l.includes("_Time"))&&(u._Time={value:new Ke(0,0,0,0)}),(h.includes("_SinTime")||l.includes("_SinTime"))&&(u._SinTime={value:new Ke(0,0,0,0)}),(h.includes("_CosTime")||l.includes("_CosTime"))&&(u._CosTime={value:new Ke(0,0,0,0)}),(h.includes("unity_DeltaTime")||l.includes("unity_DeltaTime"))&&(u.unity_DeltaTime={value:new Ke(0,0,0,0)});for(const _ in f){const w=_;switch(w){case"_TimeParameters":const E=new Ke;u[w]={value:E};break;case"hlslcc_mtx4x4unity_MatrixV":case"hlslcc_mtx4x4unity_MatrixVP":u[w]={value:[]};break;case"_MainLightPosition":case"_MainLightColor":case"_WorldSpaceCameraPos":u[w]={value:[0,0,0,1]};break;case"unity_OrthoParams":break;case"unity_SpecCube0":u[w]={value:null};break;default:case"_ScreenParams":case"_ZBufferParams":case"_ProjectionParams":u[w]={value:[0,0,0,0]};break;case"_CameraOpaqueTexture":case"_CameraDepthTexture":u[w]={value:null};break}}let p=!1;if(t.extensions&&t.extensions[qg]){const _=t.extensions[qg];if(_.technique===i){Lu&&console.log(t.name,"Material Properties",_);for(const w in _.values){const E=_.values[w];if(typeof E=="string"){if(E.startsWith("/textures/")){const I=E.substring(10),M=Number.parseInt(I);if(M>=0){const R=await this.parser.getDependency("texture",M);R instanceof Ht&&(R.colorSpace=Ii,R.needsUpdate=!0),u[w]={value:R};continue}}switch(w){case"alphaMode":E==="BLEND"&&(p=!0);continue}}if(Array.isArray(E)&&E.length===4){u[w]={value:new Ke(E[0],E[1],E[2],E[3])};continue}u[w]={value:E}}}}const g=new Qo(this.identifier,{name:t.name??"",uniforms:u,vertexShader:h,fragmentShader:l,lights:!1});switch(g.glslVersion=XC,g.vertexShader=g.vertexShader.replace("#version 300 es",""),g.fragmentShader=g.fragmentShader.replace("#version 300 es",""),(A=u._Cull)==null?void 0:A.value){case 0:g.side=vi;break;case 1:g.side=wn;break;case 2:g.side=ys;break;default:g.side=ys;break}switch((b=u._ZTest)==null?void 0:b.value){case 3:g.depthTest=!0,g.depthFunc=qm;break;case 6:g.depthTest=!0,g.depthFunc=ab;break;case 2:g.depthTest=!0,g.depthFunc=dv;break;case 4:g.depthTest=!0,g.depthFunc=tp;break;case 5:g.depthTest=!0,g.depthFunc=qS;break;case 7:g.depthTest=!0,g.depthFunc=WS;break;case 8:g.depthTest=!1,g.depthFunc=jS;break}g.transparent=p,p&&(g.depthWrite=!1),Vde(u),g.onUpdateUniforms();for(const _ in f){const w=_,E=f[_].type;if(((v=u[w])==null?void 0:v.value)===void 0)switch(E){case $6.SAMPLER_2D:u[w]={value:Gde},console.warn("Missing/unassigned texture, fallback to white: "+w);break;default:w==="unity_OrthoParams"||console.warn("TODO: EXPECTED UNIFORM / fallback NOT SET: "+w,f[_]);break}}Lu&&console.log(g.uuid,u),ej(g),o(g)}):null}}function ej(s){if(s.uniforms){Lu&&console.log("Uniforms:",s.uniforms);for(const t in s.uniforms)switch(e(t,t),t){case"_Color":e("color",t);break}}function e(t,i){Object.getOwnPropertyDescriptor(s,t)||Object.defineProperty(s,t,{get:()=>s.uniforms[i].value,set:n=>{s.uniforms[i].value=n,s.needsUpdate=!0}})}}const wme=ie("debugextensions");let BS;const Cme=Promise.resolve().then(()=>K_e).then(async s=>(BS=s.GLTFAnimationPointerExtension,BS)).catch(s=>{console.warn("Failed to import GLTFLoaderAnimationPointer. Please use @needle-tools/three for full KHR_animation support",s)}),_p=new Array;function Sme(s){_p.includes(s)||_p.push(s)}function Eme(s){const e=_p.indexOf(s);e>=0&&_p.splice(e,1)}function sO(s){const e=new yme;return s.register(t=>(e.parser=t,e)),e}class Ime{resolvePath(e){return e.includes("/extensions/builtin_components/")?e.replace("/extensions/builtin_components/","/userData/components/"):e.includes("extensions/builtin_components/")?e.replace("extensions/builtin_components/","/userData/components/"):e}}async function rO(s,e,t){const i=t.indexOf("?");i>=0&&(t=t.substring(0,i)),s.register(n=>new vme(n)),s.register(n=>new aue(n)),s.register(n=>new Ude(n,e.lightmaps,t)),s.register(n=>new bme(n,t,e)),s.register(n=>new xme(n,t)),s.register(n=>new tv(n,t)),s.register(n=>new mi(n,t)),s.register(n=>new pme(n)),i5()&&s.register(n=>new V0(n)),await Cme.catch(n=>{}),s.register(n=>{if(BS){const r=new BS(n);return r.setAnimationPointerResolver.bind(r)(new Ime),r}else return(wme||ht())&&console.error("Missing KHR_animation_pointer extension..."),{name:"KHR_animation_pointer_NOT_AVAILABLE"}});for(const n of _p)n.onImport&&n.onImport(s,t,e)}function oO(s,e){for(const t of _p)t.onExport&&t.onExport(s,e)}function aO(s,e,t){for(const i of _p)i.onLoaded&&i.onLoaded(s,e,t)}const cc=ie("debuginstancing"),eL=class{constructor(){d(this,"objs",[])}setup(e,t,i,n,r,o=0){e.applySettings(t);const a=this.tryCreateOrAddInstance(t,i,r);if(a)mi.assignTextureLOD(a.renderer.material,0),n===null&&(n=[]),n.push(a);else if(o<=0&&t.type!=="Mesh"){const c=o+1;for(const l of t.children)n=this.setup(e,l,i,n,r,c)}return o===0&&r.useMatrixWorldAutoUpdate&&n&&n.length>=0&&this.autoUpdateInstanceMatrix(t),n}tryCreateOrAddInstance(e,t,i){if(e.type==="Mesh"){const n=i.foundMeshes;if(i.foundMeshes+=1,!i.rend.enableInstancing)return null;if(i.rend.enableInstancing!==!0){if(n>=i.rend.enableInstancing.length)return cc&&console.error("Something is wrong with instance setup",e,i.rend.enableInstancing,n),null;if(!i.rend.enableInstancing[n])return null}const r=e,o=r.material;for(const u of this.objs){if(!u.canAdd(r.geometry,o))continue;return u.addInstance(r)}const a=16;let c=e.name;c!=null&&c.length||(c=KD());const l=new tj(c,r.geometry,o,a,t);return this.objs.push(l),l.addInstance(r)}return null}autoUpdateInstanceMatrix(e){const t=e.matrixWorld.multiplyMatrices.bind(e.matrixWorld),i=e.matrixWorld.clone(),n=(r,o)=>{const a=t(r,o);return(e[Nv]||i.equals(a)===!1)&&(i.copy(a),e[Nv]=!0),a};e.matrixWorld.multiplyMatrices=n}};let Yf=eL;d(Yf,"instance",new eL);const hv=class{constructor(e,t){d(this,"object");d(this,"renderer");d(this,"__instanceIndex",-1);d(this,"__reservedVertexRange",0);d(this,"__reservedIndexRange",0);d(this,"meshInformation");this.__instanceIndex=-1,this.object=e,this.renderer=t,e[a5]=t,this.meshInformation=hm(e.geometry),hv.all.push(this)}get name(){return this.object.name}get isActive(){return this.__instanceIndex>=0}get vertexCount(){return this.object.geometry.attributes.position.count}get maxVertexCount(){return this.meshInformation.vertexCount}get reservedVertexCount(){return this.__reservedVertexRange}get indexCount(){return this.object.geometry.index?this.object.geometry.index.count:0}get maxIndexCount(){return this.meshInformation.indexCount}get reservedIndexCount(){return this.__reservedIndexRange}updateInstanceMatrix(e=!1,t=!0){this.__instanceIndex<0||(t&&this.object.updateWorldMatrix(!0,e),this.renderer.updateInstance(this.object.matrixWorld,this.__instanceIndex))}setMatrix(e){this.__instanceIndex<0||this.renderer.updateInstance(e,this.__instanceIndex)}setGeometry(e){return this.__instanceIndex<0?!1:this.vertexCount>this.__reservedVertexRange?(console.error(`Cannot update geometry, reserved range is too small: ${this.__reservedVertexRange} < ${this.vertexCount} vertices for ${this.name}`),!1):this.indexCount>this.__reservedIndexRange?(console.error(`Cannot update geometry, reserved range is too small: ${this.__reservedIndexRange} < ${this.indexCount} indices for ${this.name}`),!1):this.renderer.updateGeometry(e,this.__instanceIndex)}add(){this.__instanceIndex>=0||(this.renderer.add(this),re.markAsInstancedRendered(this.object,!0))}remove(e){if(!(this.__instanceIndex<0)&&(this.renderer.remove(this,e),re.markAsInstancedRendered(this.object,!1),e)){const t=hv.all.indexOf(this);t>=0&&hv.all.splice(t,1)}}};let Jf=hv;d(Jf,"all",[]);class tj{constructor(e,t,i,n,r){d(this,"allowResize",!0);d(this,"name","");d(this,"geometry");d(this,"material");d(this,"context");d(this,"inst");d(this,"handles",[]);d(this,"maxInstanceCount");d(this,"_currentInstanceCount",0);d(this,"_currentVertexCount",0);d(this,"_currentIndexCount",0);d(this,"_maxVertexCount");d(this,"_maxIndexCount");d(this,"_needUpdateBounds",!1);d(this,"_debugMaterial",null);d(this,"onBeforeRender",()=>{this.inst.layers.enableAll(),this._needUpdateBounds&&this.inst[p0]===!0&&(cc&&console.log("Update instancing bounds",this.name,this.inst.matrixWorldNeedsUpdate),this.updateBounds())});d(this,"onAfterRender",()=>{this.inst.layers.disableAll()});d(this,"_availableBuckets",new Array);d(this,"_usedBuckets",new Array);this.name=e,this.geometry=t,this.material=i,this.context=r,this.maxInstanceCount=Math.max(2,n),cc&&(this._debugMaterial=RQ());const o=this.tryEstimateVertexCountSize(this.maxInstanceCount,[t],n);this._maxVertexCount=o.vertexCount,this._maxIndexCount=o.indexCount,this.inst=new KC(this.maxInstanceCount,this._maxVertexCount,this._maxIndexCount,this._debugMaterial??this.material),this.inst[p0]=!0,this.inst.visible=!0,this.context.scene.add(this.inst),i instanceof xE&&(i.defines.USE_INSTANCING=!0,i.needsUpdate=!0),r.pre_render_callbacks.push(this.onBeforeRender),r.post_render_callbacks.push(this.onAfterRender),cc&&console.log(`Instanced renderer created with ${this.maxInstanceCount} instances, ${this._maxVertexCount} max vertices and ${this._maxIndexCount} max indices for "${e}"`)}get mesh(){return this.inst}get visible(){return this.inst.visible}set visible(e){this.inst.visible=e}get castShadow(){return this.inst.castShadow}set castShadow(e){this.inst.castShadow=e}set receiveShadow(e){this.inst.receiveShadow=e}updateBounds(e=!0,t=!0){this._needUpdateBounds=!1,e&&this.inst.computeBoundingBox(),t&&this.inst.computeBoundingSphere()}get count(){return this._currentInstanceCount}canAdd(e,t){return this._maxVertexCount>1e7||t!==this.material?!1:!!(!this.mustGrow(e)||this.allowResize)}dispose(){cc&&console.warn("Dispose instanced renderer",this.name),this.context.scene.remove(this.inst),this.inst.dispose(),this.inst=null,this.handles=[]}addInstance(e){const t=new Jf(e,this);e.castShadow===!0&&this.inst.castShadow===!1&&(this.inst.castShadow=!0),e.receiveShadow===!0&&this.inst.receiveShadow===!1&&(this.inst.receiveShadow=!0);try{this.add(t)}catch(i){return console.error(`Failed adding mesh to instancing
6237
6237
  `,i),ht()&&R2("Failed instancing mesh. See the browser console for details."),null}return t}add(e){const t=e.object.geometry;if(!this.validateGeometry(t)){cc&&console.error("Cannot add instance, invalid geometry",this.name,t);return}if(this.mustGrow(t))if(this.allowResize)this.grow(t);else{console.error("Cannot add instance, max count reached",this.name,this.count,this.maxInstanceCount);return}e.object.updateWorldMatrix(!0,!0),this.addGeometry(e),this.handles[e.__instanceIndex]=e,this._currentInstanceCount+=1,this.markNeedsUpdate(),this._currentInstanceCount>0&&(this.inst.visible=!0)}remove(e,t){e&&(e.__instanceIndex<0||this.handles[e.__instanceIndex]!=e||this._currentInstanceCount<=0||(this.removeGeometry(e,t),this.handles[e.__instanceIndex]=null,e.__instanceIndex=-1,this._currentInstanceCount>0&&(this._currentInstanceCount-=1),this._currentInstanceCount<=0&&(this.inst.visible=!1),this.markNeedsUpdate()))}updateInstance(e,t){this.inst.setMatrixAt(t,e),this.markNeedsUpdate()}updateGeometry(e,t){return this.validateGeometry(e)?(this.mustGrow()&&this.grow(e),cc&&console.debug("UPDATE MESH",t,e.name,hm(e),e.attributes.position.count,e.index?e.index.count:0),this.inst.setGeometryAt(t,e),this.markNeedsUpdate(),!0):!1}validateGeometry(e){return this.geometry,!0}markNeedsUpdate(){this._needUpdateBounds=!0}mustGrow(e){if(this.count>=this.maxInstanceCount)return!0;if(!e)return!1;const t=hm(e),i=t.vertexCount,n=t.indexCount;return this._currentVertexCount+i>this._maxVertexCount||this._currentIndexCount+n>this._maxIndexCount}grow(e){const t=this.maxInstanceCount*2,i=this.tryEstimateVertexCountSize(t,[e]),n=Math.max(this._maxVertexCount,i.vertexCount),r=Math.max(this._maxIndexCount,i.indexCount,this._maxVertexCount*2);if(cc){const a=hm(e);console.warn(`Growing batched mesh for "${this.name}/${e.name}" ${a.vertexCount} vertices, ${a.indexCount} indices
6238
6238
  Max count ${this.maxInstanceCount} → ${t}
6239
6239
  Max vertex count ${this._maxVertexCount} -> ${n}
@@ -7343,7 +7343,7 @@ void main() {
7343
7343
  vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
7344
7344
 
7345
7345
  #include <fog_vertex>
7346
- }`);new C(0,0,1);var F0e=function(s){ty(t,s);var e=iy(t);function t(i){var n;return It(this,t),n=e.call(this,i),te(oi(n),"positionBuffer",void 0),te(oi(n),"previousBuffer",void 0),te(oi(n),"nextBuffer",void 0),te(oi(n),"uvBuffer",void 0),te(oi(n),"sideBuffer",void 0),te(oi(n),"widthBuffer",void 0),te(oi(n),"colorBuffer",void 0),te(oi(n),"indexBuffer",void 0),te(oi(n),"vector_",new C),te(oi(n),"vector2_",new C),te(oi(n),"vector3_",new C),te(oi(n),"quaternion_",new Se),n.maxParticles=1e4,n.setupBuffers(),n.rebuildMaterial(),n}return Mt(t,[{key:"setupBuffers",value:function(){this.geometry&&this.geometry.dispose(),this.geometry=new _t,this.indexBuffer=new it(new Uint32Array(this.maxParticles*6),1),this.indexBuffer.setUsage(Cr),this.geometry.setIndex(this.indexBuffer),this.positionBuffer=new it(new Float32Array(this.maxParticles*6),3),this.positionBuffer.setUsage(Cr),this.geometry.setAttribute("position",this.positionBuffer),this.previousBuffer=new it(new Float32Array(this.maxParticles*6),3),this.previousBuffer.setUsage(Cr),this.geometry.setAttribute("previous",this.previousBuffer),this.nextBuffer=new it(new Float32Array(this.maxParticles*6),3),this.nextBuffer.setUsage(Cr),this.geometry.setAttribute("next",this.nextBuffer),this.widthBuffer=new it(new Float32Array(this.maxParticles*2),1),this.widthBuffer.setUsage(Cr),this.geometry.setAttribute("width",this.widthBuffer),this.sideBuffer=new it(new Float32Array(this.maxParticles*2),1),this.sideBuffer.setUsage(Cr),this.geometry.setAttribute("side",this.sideBuffer),this.uvBuffer=new it(new Float32Array(this.maxParticles*4),2),this.uvBuffer.setUsage(Cr),this.geometry.setAttribute("uv",this.uvBuffer),this.colorBuffer=new it(new Float32Array(this.maxParticles*8),4),this.colorBuffer.setUsage(Cr),this.geometry.setAttribute("color",this.colorBuffer)}},{key:"expandBuffers",value:function(n){for(;n>=this.maxParticles;)this.maxParticles*=2;this.setupBuffers()}},{key:"rebuildMaterial",value:function(){this.layers.mask=this.settings.layers.mask;var n={lineWidth:{value:1},map:{value:null},useMap:{value:0},alphaMap:{value:null},useAlphaMap:{value:0},resolution:{value:new ee(1,1)},sizeAttenuation:{value:1},visibility:{value:1},alphaTest:{value:0},repeat:{value:new ee(1,1)}},r={};if(r.USE_UV="",r.USE_COLOR_ALPHA="",this.settings.material.map&&(r.USE_MAP="",r.MAP_UV=zP(this.settings.material.map.channel),n.map=new we(this.settings.material.map),n.mapTransform=new we(new Qt().copy(this.settings.material.map.matrix))),this.settings.renderMode===at.Trail)this.material=new Pt({uniforms:n,defines:r,vertexShader:L0e,fragmentShader:O0e,transparent:this.settings.material.transparent,depthWrite:!this.settings.material.transparent,side:this.settings.material.side,blending:this.settings.material.blending||ep});else throw new Error("render mode unavailable")}},{key:"update",value:function(){var n=this,r=0,o=0,a=0;this.systems.forEach(function(c){for(var l=0;l<c.particleNum;l++)a+=c.particles[l].previous.length*2}),a>this.maxParticles&&this.expandBuffers(a),this.systems.forEach(function(c){var l=n.quaternion_,h=n.vector2_,u=n.vector3_;c.emitter.matrixWorld.decompose(h,l,u);for(var f=c.particles,p=c.particleNum,g=n.settings.uTileCount,y=n.settings.vTileCount,m=1/g,A=1/y,b=0;b<p;b++){var v=f[b],_=v.uvTile%y,w=Math.floor(v.uvTile/y),E=v.previous.values(),I=E.next(),M=I.value,R=M;I.done||(I=E.next());var S=void 0;I.value!==void 0?S=I.value:S=R;for(var T=0;T<v.previous.length;T++,r+=2){if(n.positionBuffer.setXYZ(r,R.position.x,R.position.y,R.position.z),n.positionBuffer.setXYZ(r+1,R.position.x,R.position.y,R.position.z),c.worldSpace?(n.positionBuffer.setXYZ(r,R.position.x,R.position.y,R.position.z),n.positionBuffer.setXYZ(r+1,R.position.x,R.position.y,R.position.z)):(v.parentMatrix?n.vector_.copy(R.position).applyMatrix4(v.parentMatrix):n.vector_.copy(R.position).applyMatrix4(c.emitter.matrixWorld),n.positionBuffer.setXYZ(r,n.vector_.x,n.vector_.y,n.vector_.z),n.positionBuffer.setXYZ(r+1,n.vector_.x,n.vector_.y,n.vector_.z)),c.worldSpace?(n.previousBuffer.setXYZ(r,M.position.x,M.position.y,M.position.z),n.previousBuffer.setXYZ(r+1,M.position.x,M.position.y,M.position.z)):(v.parentMatrix?n.vector_.copy(M.position).applyMatrix4(v.parentMatrix):n.vector_.copy(M.position).applyMatrix4(c.emitter.matrixWorld),n.previousBuffer.setXYZ(r,n.vector_.x,n.vector_.y,n.vector_.z),n.previousBuffer.setXYZ(r+1,n.vector_.x,n.vector_.y,n.vector_.z)),c.worldSpace?(n.nextBuffer.setXYZ(r,S.position.x,S.position.y,S.position.z),n.nextBuffer.setXYZ(r+1,S.position.x,S.position.y,S.position.z)):(v.parentMatrix?n.vector_.copy(S.position).applyMatrix4(v.parentMatrix):n.vector_.copy(S.position).applyMatrix4(c.emitter.matrixWorld),n.nextBuffer.setXYZ(r,n.vector_.x,n.vector_.y,n.vector_.z),n.nextBuffer.setXYZ(r+1,n.vector_.x,n.vector_.y,n.vector_.z)),n.sideBuffer.setX(r,-1),n.sideBuffer.setX(r+1,1),c.worldSpace)n.widthBuffer.setX(r,R.size),n.widthBuffer.setX(r+1,R.size);else if(v.parentMatrix)n.widthBuffer.setX(r,R.size),n.widthBuffer.setX(r+1,R.size);else{var F=(Math.abs(u.x)+Math.abs(u.y)+Math.abs(u.z))/3;n.widthBuffer.setX(r,R.size*F),n.widthBuffer.setX(r+1,R.size*F)}n.uvBuffer.setXY(r,(T/v.previous.length+_)*m,(y-w-1)*A),n.uvBuffer.setXY(r+1,(T/v.previous.length+_)*m,(y-w)*A),n.colorBuffer.setXYZW(r,R.color.x,R.color.y,R.color.z,R.color.w),n.colorBuffer.setXYZW(r+1,R.color.x,R.color.y,R.color.z,R.color.w),T+1<v.previous.length&&(n.indexBuffer.setX(o*3,r),n.indexBuffer.setX(o*3+1,r+1),n.indexBuffer.setX(o*3+2,r+2),o++,n.indexBuffer.setX(o*3,r+2),n.indexBuffer.setX(o*3+1,r+1),n.indexBuffer.setX(o*3+2,r+3),o++),M=R,R=S,I.done||(I=E.next(),I.value!==void 0&&(S=I.value))}}}),this.positionBuffer.updateRange.count=r*3,this.positionBuffer.needsUpdate=!0,this.previousBuffer.updateRange.count=r*3,this.previousBuffer.needsUpdate=!0,this.nextBuffer.updateRange.count=r*3,this.nextBuffer.needsUpdate=!0,this.sideBuffer.updateRange.count=r,this.sideBuffer.needsUpdate=!0,this.widthBuffer.updateRange.count=r,this.widthBuffer.needsUpdate=!0,this.uvBuffer.updateRange.count=r*2,this.uvBuffer.needsUpdate=!0,this.colorBuffer.updateRange.count=r*4,this.colorBuffer.needsUpdate=!0,this.indexBuffer.updateRange.count=o*3,this.indexBuffer.needsUpdate=!0,this.geometry.setDrawRange(0,o*3)}},{key:"dispose",value:function(){this.geometry.dispose()}}]),t}(Cj),U0e=function(s){ty(t,s);var e=iy(t);function t(){var i;return It(this,t),i=e.call(this),te(oi(i),"batches",[]),te(oi(i),"systemToBatchIndex",new Map),te(oi(i),"type","BatchedRenderer"),i}return Mt(t,[{key:"addSystem",value:function(n){n._renderer=this;for(var r=n.getRendererSettings(),o=0;o<this.batches.length;o++)if(t.equals(this.batches[o].settings,r)){this.batches[o].addSystem(n),this.systemToBatchIndex.set(n,o);return}var a;switch(r.renderMode){case at.Trail:a=new F0e(r);break;case at.Mesh:case at.BillBoard:case at.VerticalBillBoard:case at.HorizontalBillBoard:case at.StretchedBillBoard:a=new k0e(r);break}a.addSystem(n),this.batches.push(a),this.systemToBatchIndex.set(n,this.batches.length-1),this.add(a)}},{key:"deleteSystem",value:function(n){var r=this.systemToBatchIndex.get(n);r!=null&&(this.batches[r].removeSystem(n),this.systemToBatchIndex.delete(n))}},{key:"updateSystem",value:function(n){this.deleteSystem(n),this.addSystem(n)}},{key:"update",value:function(n){this.systemToBatchIndex.forEach(function(o,a){a.update(n)});for(var r=0;r<this.batches.length;r++)this.batches[r].update()}}],[{key:"equals",value:function(n,r){return n.material.side===r.material.side&&n.material.blending===r.material.blending&&n.material.transparent===r.material.transparent&&n.material.type===r.material.type&&n.material.alphaTest===r.material.alphaTest&&n.material.map===r.material.map&&n.renderMode===r.renderMode&&n.uTileCount===r.uTileCount&&n.vTileCount===r.vTileCount&&n.instancingGeometry===r.instancingGeometry&&n.renderOrder===r.renderOrder&&n.layers.mask===r.layers.mask}}]),t}(ye),N0e=U0e,Iz=function(){function s(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:new C;It(this,s),te(this,"locations",[]),this.scaleX=e,this.scaleY=t,this.position=i}return Mt(s,[{key:"transform",value:function(t,i){t.x=this.locations[i%this.locations.length].x*this.scaleX+this.position.x,t.y=this.locations[i%this.locations.length].y*this.scaleY+this.position.y,t.z=this.position.z}},{key:"clone",value:function(){var t=new s(this.scaleX,this.scaleY,this.position.clone());return t.locations=this.locations.map(function(i){return i.clone()}),t}},{key:"toJSON",value:function(){return{scaleX:this.scaleX,scaleY:this.scaleY,position:this.position,locations:this.locations.map(function(t){return{x:t.x,y:t.y}})}}},{key:"fromImage",value:function(t,i){var n=document.createElement("canvas");n.width=t.width,n.height=t.height;var r=n.getContext("2d");if(r){r.drawImage(t,0,0);var o=r.getImageData(0,0,n.width,n.height,{colorSpace:"srgb"});n.remove(),this.locations.length=0;for(var a=0;a<o.height;a++)for(var c=0;c<o.width;c++)o.data[(a*o.width+c)*4+3]>i&&this.locations.push(new ee(c,o.height-a))}}}],[{key:"fromJSON",value:function(t){var i=new s(t.scaleX,t.scaleY,new C(t.position[0],t.position[1],t.position[2]));return i.locations=t.locations.map(function(n){return new ee(n.x,n.y)}),i}}]),s}();function Q0e(s){switch(s.type){case"TextureSequencer":return Iz.fromJSON(s);default:return new Iz}}var z0e=function(){function s(e){It(this,s),te(this,"type","ApplySequences"),te(this,"sequencers",[]),te(this,"time",0),te(this,"index",0),te(this,"pCount",0),te(this,"delay",void 0),te(this,"tempV",new C),this.delay=e}return Mt(s,[{key:"initialize",value:function(t){t.id=this.pCount,t.dst=new C,t.begin=new C,t.inMotion=!1,this.pCount++}},{key:"reset",value:function(){this.time=0,this.index=0,this.pCount=0}},{key:"update",value:function(t,i){var n=this.sequencers[this.index],r=t.id*this.delay;this.time>=n[0].a+r&&this.time<=n[0].b+r?(t.inMotion||(t.inMotion=!0,t.begin.copy(t.position),n[1].transform(t.dst,t.id)),t.position.lerpVectors(t.begin,t.dst,s.BEZIER.genValue((this.time-n[0].a-r)/(n[0].b-n[0].a)))):this.time>n[0].b+r&&(t.inMotion=!1)}},{key:"frameUpdate",value:function(t){for(;this.index+1<this.sequencers.length&&this.time>=this.sequencers[this.index+1][0].a;)this.index++;this.time+=t}},{key:"appendSequencer",value:function(t,i){this.sequencers.push([t,i])}},{key:"toJSON",value:function(){return{type:this.type,delay:this.delay,sequencers:this.sequencers.map(function(t){var i=jm(t,2),n=i[0],r=i[1];return{range:n.toJSON(),sequencer:r.toJSON()}})}}},{key:"clone",value:function(){var t=new s(this.delay);return t.sequencers=this.sequencers.map(function(i){return[i[0].clone(),i[1].clone()]}),t}}],[{key:"fromJSON",value:function(t){var i=new s(t.delay);return t.sequencers.forEach(function(n){i.sequencers.push([Ki(n.range),Q0e(n.sequencer)])}),i}}]),s}();te(z0e,"BEZIER",new FP(0,0,1,1));var de=function(s){return s[s.Number=0]="Number",s[s.Vec2=1]="Vec2",s[s.Vec3=2]="Vec3",s[s.Vec4=3]="Vec4",s[s.Boolean=4]="Boolean",s[s.AnyType=5]="AnyType",s}({}),Mz=Mt(function s(e,t,i,n){It(this,s),te(this,"input",void 0),te(this,"inputIndex",void 0),te(this,"output",void 0),te(this,"outputIndex",void 0),this.input=e,this.inputIndex=t,this.input.outputs[t].push(this),this.output=i,this.outputIndex=n,this.output.inputs[n]=this}),G0e=function(){function s(){It(this,s),te(this,"visited",new Set),te(this,"graph_",void 0),te(this,"context_",void 0),s.Instance=this}return Mt(s,[{key:"traverse",value:function(t){if(this.context_===void 0)throw new Error("context is undefined");if(this.graph_===void 0)throw new Error("graph is undefined");this.visited.add(t.id);for(var i=[],n=0;n<t.inputs.length;n++)if(t.inputs[n]instanceof Mz){var r=t.inputs[n].input;this.visited.has(r.id)||this.traverse(r),i.push(r.outputValues[t.inputs[n].inputIndex])}else i.push(t.inputs[n].getValue(this.context_));t.func(this.context_,i,t.outputValues),this.graph_.nodesInOrder.push(t)}},{key:"executeCompiledGraph",value:function(){if(this.context_===void 0)throw new Error("context is undefined");if(this.graph_===void 0)throw new Error("graph is undefined");for(var t=this.graph_.nodesInOrder,i=0;i<t.length;i++){for(var n=[],r=t[i],o=0;o<r.inputs.length;o++)if(r.inputs[o]instanceof Mz)n.push(r.inputs[o].input.outputValues[r.inputs[o].inputIndex]);else if(r.inputs[o]!==void 0)n.push(r.inputs[o].getValue(this.context_));else throw new Error("miss input for node ".concat(r.id));r.func(this.context_,n,r.outputValues)}}},{key:"run",value:function(t,i){if(this.graph_=t,this.context_=i,t.compiled)this.executeCompiledGraph();else{t.nodesInOrder.length=0,this.visited.clear();for(var n=0;n<t.outputNodes.length;n++){var r=t.outputNodes[n];this.traverse(r)}t.compiled=!0}}}]),s}();te(G0e,"Instance",void 0);var fi=function(){function s(e){It(this,s),te(this,"name",void 0),te(this,"nodeTypeSignatures",[]),this.name=e}return Mt(s,[{key:"addSignature",value:function(t,i,n){this.nodeTypeSignatures.push({inputTypes:t,outputTypes:i,func:n})}}]),s}(),HI=new fi("add");HI.addSignature([de.Number,de.Number],[de.Number],function(s,e,t,i){i[0]=t[0]+t[1]});HI.addSignature([de.Vec2,de.Vec2],[de.Vec2],function(s,e,t,i){i[0].addVectors(t[0],t[1])});HI.addSignature([de.Vec3,de.Vec3],[de.Vec3],function(s,e,t,i){i[0].addVectors(t[0],t[1])});HI.addSignature([de.Vec4,de.Vec4],[de.Vec4],function(s,e,t,i){i[0].addVectors(t[0],t[1])});var VI=new fi("sub");VI.addSignature([de.Number,de.Number],[de.Number],function(s,e,t,i){i[0]=t[0]-t[1]});VI.addSignature([de.Vec2,de.Vec2],[de.Vec2],function(s,e,t,i){i[0].subVectors(t[0],t[1])});VI.addSignature([de.Vec3,de.Vec3],[de.Vec3],function(s,e,t,i){i[0].subVectors(t[0],t[1])});VI.addSignature([de.Vec4,de.Vec4],[de.Vec4],function(s,e,t,i){i[0].subVectors(t[0],t[1])});var jI=new fi("mul");jI.addSignature([de.Number,de.Number],[de.Number],function(s,e,t,i){i[0]=t[0]*t[1]});jI.addSignature([de.Vec2,de.Number],[de.Vec2],function(s,e,t,i){i[0].copy(t[0]).multiplyScalar(t[1])});jI.addSignature([de.Vec3,de.Number],[de.Vec3],function(s,e,t,i){i[0].copy(t[0]).multiplyScalar(t[1])});jI.addSignature([de.Vec4,de.Number],[de.Vec4],function(s,e,t,i){i[0].copy(t[0]).multiplyScalar(t[1])});var WI=new fi("div");WI.addSignature([de.Number,de.Number],[de.Number],function(s,e,t,i){i[0]=t[0]/t[1]});WI.addSignature([de.Vec2,de.Number],[de.Vec2],function(s,e,t,i){i[0].copy(t[0]).divideScalar(t[1])});WI.addSignature([de.Vec3,de.Number],[de.Vec3],function(s,e,t,i){i[0].copy(t[0]).divideScalar(t[1])});WI.addSignature([de.Vec4,de.Number],[de.Vec4],function(s,e,t,i){i[0].copy(t[0]).divideScalar(t[1])});var H0e=new fi("sin");H0e.addSignature([de.Number],[de.Number],function(s,e,t,i){i[0]=Math.sin(t[0])});var V0e=new fi("cos");V0e.addSignature([de.Number],[de.Number],function(s,e,t,i){i[0]=Math.cos(t[0])});var j0e=new fi("tan");j0e.addSignature([de.Number],[de.Number],function(s,e,t,i){i[0]=Math.tan(t[0])});var W0e=new fi("abs");W0e.addSignature([de.Number],[de.Number],function(s,e,t,i){i[0]=Math.abs(t[0])});var q0e=new fi("min");q0e.addSignature([de.Number,de.Number],[de.Number],function(s,e,t,i){i[0]=Math.min(t[0],t[1])});var X0e=new fi("max");X0e.addSignature([de.Number,de.Number],[de.Number],function(s,e,t,i){i[0]=Math.max(t[0],t[1])});var IO=new fi("dot");IO.addSignature([de.Vec2,de.Vec2],[de.Number],function(s,e,t,i){i[0]=t[0].dot(t[1])});IO.addSignature([de.Vec3,de.Vec3],[de.Number],function(s,e,t,i){i[0]=t[0].dot(t[1])});IO.addSignature([de.Vec4,de.Vec4],[de.Number],function(s,e,t,i){i[0]=t[0].dot(t[1])});var Y0e=new fi("cross");Y0e.addSignature([de.Vec3,de.Vec3],[de.Vec3],function(s,e,t,i){i[0].crossVectors(t[0],t[1])});var MO=new fi("length");MO.addSignature([de.Vec2],[de.Number],function(s,e,t,i){i[0]=t[0].length()});MO.addSignature([de.Vec3],[de.Number],function(s,e,t,i){i[0]=t[0].length()});MO.addSignature([de.Vec4],[de.Number],function(s,e,t,i){i[0]=t[0].length()});var TO=new fi("lengthSq");TO.addSignature([de.Vec2],[de.Number],function(s,e,t,i){i[0]=t[0].lengthSq()});TO.addSignature([de.Vec3],[de.Number],function(s,e,t,i){i[0]=t[0].lengthSq()});TO.addSignature([de.Vec4],[de.Number],function(s,e,t,i){i[0]=t[0].lengthSq()});var BO=new fi("normalize");BO.addSignature([de.Vec2],[de.Vec2],function(s,e,t,i){i[0].copy(t[0]).normalize()});BO.addSignature([de.Vec3],[de.Vec3],function(s,e,t,i){i[0].copy(t[0]).normalize()});BO.addSignature([de.Vec4],[de.Vec4],function(s,e,t,i){i[0].copy(t[0]).normalize()});var Sj=new fi("distance");Sj.addSignature([de.Vec2,de.Vec2],[de.Number],function(s,e,t,i){i[0]=t[0].distanceTo(t[1])});Sj.addSignature([de.Vec3,de.Vec3],[de.Number],function(s,e,t,i){i[0]=t[0].distanceTo(t[1])});var J0e=new fi("and");J0e.addSignature([de.Boolean,de.Boolean],[de.Boolean],function(s,e,t,i){i[0]=t[0]&&t[1]});var K0e=new fi("or");K0e.addSignature([de.Boolean,de.Boolean],[de.Boolean],function(s,e,t,i){i[0]=t[0]||t[1]});var Z0e=new fi("not");Z0e.addSignature([de.Boolean],[de.Boolean],function(s,e,t,i){i[0]=!t[0]});var qI=new fi("equal");qI.addSignature([de.Number,de.Number],[de.Boolean],function(s,e,t,i){i[0]=t[0]===t[1]});qI.addSignature([de.Vec2,de.Vec2],[de.Boolean],function(s,e,t,i){i[0]=t[0].equals(t[1])});qI.addSignature([de.Vec3,de.Vec3],[de.Boolean],function(s,e,t,i){i[0]=t[0].equals(t[1])});qI.addSignature([de.Vec4,de.Vec4],[de.Boolean],function(s,e,t,i){i[0]=t[0].equals(t[1])});var $0e=new fi("lessThan");$0e.addSignature([de.Number,de.Number],[de.Boolean],function(s,e,t,i){i[0]=t[0]<t[1]});var eve=new fi("greaterThan");eve.addSignature([de.Number,de.Number],[de.Boolean],function(s,e,t,i){i[0]=t[0]>t[1]});var tve=new fi("lessThanOrEqual");tve.addSignature([de.Number,de.Number],[de.Boolean],function(s,e,t,i){i[0]=t[0]<=t[1]});var ive=new fi("greaterThanOrEqual");ive.addSignature([de.Number,de.Number],[de.Boolean],function(s,e,t,i){i[0]=t[0]>=t[1]});var nve=new fi("if");nve.addSignature([de.Boolean,de.AnyType,de.AnyType],[de.AnyType],function(s,e,t,i){i[0]=t[0]?t[1]:t[2]});var sve=new fi("number");sve.addSignature([],[de.Number],function(s,e,t,i){i[0]=e.value});var rve=new fi("vec2");rve.addSignature([],[de.Vec2],function(s,e,t,i){i[0]=e.value});var ove=new fi("vec3");ove.addSignature([],[de.Vec3],function(s,e,t,i){i[0]=e.value});var ave=new fi("vec4");ave.addSignature([],[de.Vec4],function(s,e,t,i){i[0]=e.value});var cve=new fi("bool");cve.addSignature([],[de.Boolean],function(s,e,t,i){i[0]=e.value});var lve=new fi("particlePosition");lve.addSignature([],[de.Vec3],function(s,e,t,i){i[0]=s.particle[e.property]});var hve=new fi("particleVelocity");hve.addSignature([],[de.Vec3],function(s,e,t,i){i[0]=s.particle[e.property]});var uve=new fi("particleRotation");uve.addSignature([],[de.Number],function(s,e,t,i){i[0]=s.particle[e.property]});var dve=new fi("particleAge");dve.addSignature([],[de.Number],function(s,e,t,i){i[0]=s.particle[e.property]});var p_=new fi("output");p_.addSignature([de.Number],[de.Number],function(s,e,t,i){i[0]=t[0]});p_.addSignature([de.Vec2],[de.Vec2],function(s,e,t,i){i[0]=t[0]});p_.addSignature([de.Vec3],[de.Vec3],function(s,e,t,i){i[0]=t[0]});p_.addSignature([de.Vec4],[de.Vec4],function(s,e,t,i){i[0]=t[0]});p_.addSignature([de.Boolean],[de.Boolean],function(s,e,t,i){i[0]=t[0]});console.log("%c Particle system powered by three.quarks. https://quarks.art/","font-size: 16px; font-weight: bold;");var fve=Object.defineProperty,pve=Object.getOwnPropertyDescriptor,Tn=(s,e,t,i)=>{for(var n=i>1?void 0:i?pve(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&fve(e,t,n),n};const I0=ie("debugparticles"),gve=ie("noprogressive"),mve=ie("debugprogressive");var GP=(s=>(s[s.Birth=0]="Birth",s[s.Collision=1]="Collision",s[s.Death=2]="Death",s[s.Trigger=3]="Trigger",s[s.Manual=4]="Manual",s))(GP||{});class Ja extends Te{constructor(){super(...arguments);d(this,"renderMode");d(this,"particleMaterial");d(this,"trailMaterial");d(this,"particleMesh");d(this,"maxParticleSize");d(this,"minParticleSize");d(this,"velocityScale");d(this,"cameraVelocityScale");d(this,"lengthScale")}start(){if(this.maxParticleSize!==.5&&this.minParticleSize!==0&&ht()){const t=`ParticleSystem "${this.name}" has non-default min/max particle size. This may not render correctly. Please set min size to 0 and the max size to 0.5 and use the "StartSize" setting instead`;console.warn(t)}}get transparent(){var i;return((i=this.particleMaterial)==null?void 0:i.transparent)??!1}getMaterial(t=!1){let i=t===!0&&this.trailMaterial?this.trailMaterial:this.particleMaterial;return i&&t&&i.side===ys&&(i=i.clone(),i.side=wn,t?this.trailMaterial=i:this.particleMaterial=i),i&&!gve&&i._didRequestTextureLOD===void 0&&(i._didRequestTextureLOD=0,mve&&console.log("Load material LOD",i.name),mi.assignTextureLOD(i,0)),i}getMesh(t){let i=null;if(!i&&(this.particleMesh instanceof pe&&(i=this.particleMesh.geometry),i===null)){i=new cs(1,1);const r=i.attributes.uv;for(let o=0;o<r.count;o++)r.setX(o,1-r.getX(o))}return new pe(i,this.getMaterial())}}Tn([x()],Ja.prototype,"renderMode",2);Tn([x(Ut)],Ja.prototype,"particleMaterial",2);Tn([x(Ut)],Ja.prototype,"trailMaterial",2);Tn([x()],Ja.prototype,"maxParticleSize",2);Tn([x()],Ja.prototype,"minParticleSize",2);Tn([x()],Ja.prototype,"velocityScale",2);Tn([x()],Ja.prototype,"cameraVelocityScale",2);Tn([x()],Ja.prototype,"lengthScale",2);class Nw{constructor(e,t=1){d(this,"_curve");d(this,"_factor");d(this,"type","function");this._curve=e,this._factor=t}genValue(e){return this._curve.evaluate(e,Math.random())*this._factor}toJSON(){throw new Error("Method not implemented.")}clone(){throw new Error("Method not implemented.")}}class RO{constructor(e){d(this,"type","value");d(this,"system");this.system=e}toJSON(){throw new Error("Method not implemented.")}clone(){throw new Error("Method not implemented.")}}class Ave extends RO{genValue(){return this.system.textureSheetAnimation.getStartIndex()}}class yve extends RO{constructor(){super(...arguments);d(this,"_lastPosition",new C);d(this,"_lastDistance",0)}update(){const t=Ot(this.system.gameObject);this._lastDistance=this._lastPosition.distanceTo(t),this._lastPosition.copy(t)}genValue(){if(!this.system.isPlaying||!this.system.emission.enabled||this.system.currentParticles>=this.system.maxParticles)return 0;let t=this.system.emission.rateOverTime.evaluate(this.system.time/this.system.duration,Math.random());if(this.system.deltaTime>0){const r=this.system.emission.rateOverDistance.evaluate(this.system.time/this.system.duration,Math.random());let a=this._lastDistance/this.system.deltaTime*r;Number.isFinite(a)||(a=0),t+=a}const i=this.system.emission.getBurst();i>0&&(t+=i/this.system.deltaTime);const n=this.system.maxParticles-this.system.currentParticles;return tt.clamp(t,0,n/this.system.deltaTime)}}class vve extends RO{genValue(){return this.system.isPlaying,0}}class kd{constructor(e){d(this,"system");d(this,"type");this.type=Object.getPrototypeOf(this).constructor.name||"ParticleSystemBaseBehaviour",e&&(this.system=e)}get context(){return this.system.context}initialize(e){}update(e,t){}frameUpdate(e){}toJSON(){throw new Error("Method not implemented.")}clone(){throw new Error("Method not implemented.")}reset(){}}class bve extends kd{constructor(){super(...arguments);d(this,"type","NeedleTextureSheet")}update(t,i){const n=this.system.textureSheetAnimation;if(n.enabled){const r=t.age/t.life,o=n.evaluate(r);o!==void 0&&(t.uvTile=o)}}}const Tz=Symbol("particleRotation");class _ve extends kd{constructor(){super(...arguments);d(this,"type","NeedleRotation")}initialize(t){t[Tz]=Math.random()}update(t,i){if(t.rotation===void 0)return;const n=t.age/t.life;if(typeof t.rotation=="number"&&(this.system.rotationOverLifetime.enabled?t.rotation+=this.system.rotationOverLifetime.evaluate(n,t[Tz])*i:this.system.renderer.renderMode===ph.Billboard&&(t.rotation=Math.PI),this.system.rotationBySpeed.enabled)){const r=t.velocity.length();t.rotation+=this.system.rotationBySpeed.evaluate(n,r)*i}}}const Bz=Symbol("sizeLerpFactor"),xve=new C;class wve extends kd{constructor(){super(...arguments);d(this,"type","NeedleSize");d(this,"_minSize",0);d(this,"_maxSize",1)}initialize(t){t[Bz]=Math.random(),this._minSize=this.system.renderer.minParticleSize,this._maxSize=this.system.renderer.maxParticleSize}update(t,i){const n=t.age/t.life;let r=1;this.system.sizeOverLifetime.enabled&&(r*=this.system.sizeOverLifetime.evaluate(n,void 0,t[Bz]).x);let o=1;if(this.system.renderer.renderMode!==ph.Mesh&&(o=this.system.worldScale.x/this.system.cameraScale),t.size=t.startSize*r*o,this.system.localspace){const a=Ej(this.system,xve);t.size*=a.x}}}const Im=Symbol("particleLife"),$T=Symbol("trailLifetime"),Rz=Symbol("trailStartLength"),eB=Symbol("trailWidthRandom");class Cve extends kd{constructor(){super(...arguments);d(this,"type","NeedleTrail")}initialize(t){t instanceof eb&&(t[Im]=t.life,this.system.trails.enabled&&this.system.trails.dieWithParticles===!1&&(t[$T]=this.system.trails.lifetime.evaluate(Math.random(),Math.random()),t.life+=t[$T]),t[Rz]=t.length,t[eB]=Math.random())}update(t){var i;if((i=this.system.trails)!=null&&i.enabled&&t instanceof eb){const n=t,r=t.age/t[Im],o=t.previous.values(),a=t.previous.length;for(let c=0;c<a;c++){const h=o.next().value,u=1-c/(a-1);let f=t.size;f<=0&&!this.system.trails.sizeAffectsWidth&&(f=20*this.system.trails.widthOverTrail.evaluate(.5,n[eB])),h.size=this.system.trails.getWidth(f,r,u,n[eB]),h.color.copy(t.color),this.system.trails.getColor(h.color,r,u)}if(t.age>t[Im]){t.velocity.set(0,0,0);const c=(t.age-t[Im])/t[$T];n.length=tt.lerp(t[Rz],0,c)}}}}const Qw=Symbol("startVelocity"),Pz=Symbol("gravityModifier"),tB=Symbol("gravitySpeed"),zw=Symbol("velocity lerp factor"),HP=new C;class Sve extends kd{constructor(){super(...arguments);d(this,"type","NeedleVelocity");d(this,"_gravityDirection",new C)}initialize(t){var r,o;const i=this.system.main.simulationSpeed;t.startSpeed=this.system.main.startSpeed.evaluate(Math.random(),Math.random()),t.velocity.copy(this.system.shape.getDirection(t,t.position)).multiplyScalar(t.startSpeed),(r=this.system.inheritVelocity)!=null&&r.enabled&&this.system.inheritVelocity.applyInitial(t.velocity),t[Qw]?t[Qw].copy(t.velocity):t[Qw]=t.velocity.clone();const n=this.system.main.gravityModifier.evaluate(Math.random(),Math.random());t[Pz]=n*i,t[tB]=n*i*.5,t[zw]=Math.random(),(o=this.system.velocityOverLifetime)==null||o.init(t),this._gravityDirection.set(0,-1,0),this.system.main.simulationSpace===Kv.Local&&this._gravityDirection.applyQuaternion(this.system.worldQuaternionInverted).normalize()}update(t,i){var f;const n=t[Qw],r=t[Pz];if(r!==0){const p=r*t[tB];HP.copy(this._gravityDirection).multiplyScalar(p),t[tB]+=i*.05,n.add(HP)}t.velocity.copy(n);const o=t.age/t.life;(f=this.system.inheritVelocity)!=null&&f.enabled&&this.system.inheritVelocity.applyCurrent(t.velocity,o,t[zw]);const a=this.system.noise;a.enabled&&a.apply(0,t.position,t.velocity,i,t.age,t.life);const c=this.system.sizeBySpeed;c!=null&&c.enabled&&(t.size=c.evaluate(t.velocity,o,t[zw],t.size));const l=this.system.colorBySpeed;l!=null&&l.enabled&&l.evaluate(t.velocity,t[zw],t.color);const h=this.system.velocityOverLifetime;h.enabled&&h.apply(t,0,t.position,t.velocity,i,t.age,t.life);const u=this.system.limitVelocityOverLifetime;u.enabled&&u.apply(t.position,n,t.velocity,t.size,o,i,1),this.system.worldspace&&t.velocity.multiply(this.system.worldScale)}}const Dz=Symbol("colorLerpFactor"),kz=new Ei(1,1,1,1),hf=new Ei(1,1,1,1);class Eve extends kd{constructor(){super(...arguments);d(this,"type","NeedleColor")}initialize(t){}_init(t){const i=this.system.renderer.particleMaterial;hf.copy(this.system.main.startColor.evaluate(Math.random())),i!=null&&i.color&&(kz.copy(i.color),hf.multiply(kz)),hf.convertLinearToSRGB(),t.startColor.set(hf.r,hf.g,hf.b,hf.alpha),t.color.copy(t.startColor),t[Dz]=Math.random()}update(t,i){if(t.age===0&&this._init(t),this.system.colorOverLifetime.enabled){const n=t.age/t.life,r=this.system.colorOverLifetime.color.evaluate(n,t[Dz]);t.color.set(r.r,r.g,r.b,r.alpha).multiply(t.startColor)}else t.color.copy(t.startColor)}}class Ive{constructor(e){d(this,"system");d(this,"emission");d(this,"autoDestroy");d(this,"startLength");d(this,"emissionBursts");d(this,"onlyUsedByOther");d(this,"behaviors",[]);d(this,"rendererEmitterSettings",{startLength:new wr(220),followLocalOrigin:!1});d(this,"flatWhiteTexture");d(this,"clonedTexture",{original:void 0,clone:void 0});this.system=e,this.emission=new yve(this.system)}get anim(){return this.system.textureSheetAnimation}get prewarm(){return!1}get material(){return this.system.renderer.getMaterial(this.system.trails.enabled)}get layers(){return this.system.gameObject.layers}update(){this.emission.update()}get looping(){return this.system.main.loop}get duration(){return this.system.duration}get shape(){return this.system.shape}get startLife(){return new Nw(this.system.main.startLifetime)}get startSpeed(){return new Nw(this.system.main.startSpeed)}get startRotation(){return new Nw(this.system.main.startRotation)}get startSize(){return new Nw(this.system.main.startSize)}get startColor(){return new kS(new Ke(1,1,1,1))}get emissionOverTime(){return this.emission}get emissionOverDistance(){return new vve(this.system)}get instancingGeometry(){return this.system.renderer.getMesh(this.system.renderer.renderMode).geometry}get renderMode(){if(this.system.trails.enabled===!0)return at.Trail;switch(this.system.renderer.renderMode){case ph.Billboard:return at.BillBoard;case ph.Stretch:return at.StretchedBillBoard;case ph.HorizontalBillboard:return at.HorizontalBillBoard;case ph.VerticalBillboard:return at.VerticalBillBoard;case ph.Mesh:return at.Mesh}return at.BillBoard}get speedFactor(){var t;let e=this.system.main.simulationSpeed;return((t=this.system.renderer)==null?void 0:t.renderMode)===ph.Stretch&&(e*=this.system.renderer.velocityScale??1),e}get texture(){const e=this.material;if(e&&e.map){const t=e.map;if(this.clonedTexture.original!==t||!this.clonedTexture.clone){const i=t.clone();i.premultiplyAlpha=!1,i.colorSpace=Ii,this.clonedTexture.original=t,this.clonedTexture.clone=i}return this.clonedTexture.clone}return this.flatWhiteTexture||(this.flatWhiteTexture=Bk(new Ei(1,1,1,1),1)),this.flatWhiteTexture}get startTileIndex(){return new Ave(this.system)}get uTileCount(){var e;return this.anim.enabled?(e=this.anim)==null?void 0:e.numTilesX:void 0}get vTileCount(){var e;return this.anim.enabled?(e=this.anim)==null?void 0:e.numTilesY:void 0}get renderOrder(){return 1}get blending(){var e;return((e=this.system.renderer.particleMaterial)==null?void 0:e.blending)??Ju}get transparent(){return this.system.renderer.transparent}get worldSpace(){return this.system.main.simulationSpace===Kv.World}}class Mve{constructor(){d(this,"burstIndex",0);d(this,"burstWaveIndex",0);d(this,"time",0);d(this,"waitEmiting",0)}}const PC=class extends Te{constructor(){super(...arguments);d(this,"_state");d(this,"colorOverLifetime");d(this,"main");d(this,"emission");d(this,"sizeOverLifetime");d(this,"shape");d(this,"noise");d(this,"trails");d(this,"velocityOverLifetime");d(this,"limitVelocityOverLifetime");d(this,"inheritVelocity");d(this,"colorBySpeed");d(this,"textureSheetAnimation");d(this,"rotationOverLifetime");d(this,"rotationBySpeed");d(this,"sizeBySpeed");d(this,"_cameraScale",1);d(this,"__worldQuaternion",new Se);d(this,"_worldQuaternionInverted",new Se);d(this,"_worldScale",new C);d(this,"_worldPositionFrame",-1);d(this,"_worldPos",new C);d(this,"_renderer");d(this,"_batchSystem");d(this,"_particleSystem");d(this,"_interface");d(this,"_container");d(this,"_time",0);d(this,"_isPlaying",!0);d(this,"_isUsedAsSubsystem",!1);d(this,"_didPreWarm",!1);d(this,"_bursts");d(this,"_subEmitterSystems");d(this,"_lastBatchesCount",-1);d(this,"lastMaterialVersion",-1)}play(e=!1){var t;e&&re.foreachComponent(this.gameObject,i=>{i instanceof PC&&i!==this&&i.play(!1)},!0),this._isPlaying=!0,this._particleSystem&&(this._particleSystem.emissionState.time=0,this._particleSystem.emitEnded=!1),(t=this.emission)==null||t.reset()}pause(e=!0){e&&re.foreachComponent(this.gameObject,t=>{t instanceof PC&&t!==this&&t.pause(!1)},!0),this._isPlaying=!1}stop(e=!0,t=!1){e&&re.foreachComponent(this.gameObject,i=>{i instanceof PC&&i!==this&&i.stop(!1,t)},!0),this._isPlaying=!1,this._time=0,t&&this.reset()}reset(){var e;this._time=0,this._particleSystem&&(this._particleSystem.particleNum=0,this._particleSystem.emissionState.time=0,this._particleSystem.emitEnded=!1,(e=this.emission)==null||e.reset())}emit(e){if(this._particleSystem){this.onUpdate(),e=Math.min(e,this.maxParticles-this.currentParticles),this._state||(this._state=new Mve),this._state.waitEmiting=e,this._state.time=0;const t=this._particleSystem.emitEnded;this._particleSystem.emitEnded=!1,this._particleSystem.emit(this.deltaTime,this._state,this._particleSystem.emitter.matrixWorld),this._particleSystem.emitEnded=t}}get playOnAwake(){return this.main.playOnAwake}set playOnAwake(e){this.main.playOnAwake=e}get renderer(){return this._renderer}get isPlaying(){return this._isPlaying}get currentParticles(){var e;return((e=this._particleSystem)==null?void 0:e.particleNum)??0}get maxParticles(){return this.main.maxParticles}get time(){return this._time}get duration(){return this.main.duration}get deltaTime(){return this.context.time.deltaTime*this.main.simulationSpeed}get scale(){return this.gameObject.scale.x}get cameraScale(){return this._cameraScale}get container(){return this._container}get worldspace(){return this.main.simulationSpace===Kv.World}get localspace(){return this.main.simulationSpace===Kv.Local}get worldQuaternion(){return this.__worldQuaternion}get worldQuaternionInverted(){return this._worldQuaternionInverted}get worldScale(){return this._worldScale}get worldPos(){return this._worldPositionFrame!==this.context.time.frame&&(this._worldPositionFrame=this.context.time.frame,Ot(this.gameObject,this._worldPos)),this._worldPos}get matrixWorld(){return this._container.matrixWorld}get isSubsystem(){return this._isUsedAsSubsystem}addBehaviour(e){return this._particleSystem?(e instanceof kd&&(e.system=this),ht()&&console.log("add behaviour",e),this._particleSystem.addBehavior(e),!0):!1}removeBehaviour(e){if(!this._particleSystem)return!1;const t=this._particleSystem.behaviors,i=t.indexOf(e);return i!==-1&&t.splice(i,1),!0}removeAllBehaviours(){return this._particleSystem?(this._particleSystem.behaviors.length=0,!0):!1}get behaviours(){return this._particleSystem?this._particleSystem.behaviors:null}get particleSystem(){return this._particleSystem??null}set bursts(e){for(let t=0;t<e.length;t++){const i=e[t];if(!(i instanceof Zv)){const n=new Zv;lA(n,i),e[t]=n}}this._bursts=e}set subEmitterSystems(e){for(let t=0;t<e.length;t++){const i=e[t];if(!(i instanceof nb)){const n=new nb;lA(n,i),e[t]=n}}I0&&e.length>0&&console.log("SubEmitters: ",e,this),this._subEmitterSystems=e}onAfterDeserialize(e){if(this._subEmitterSystems&&Array.isArray(this._subEmitterSystems))for(const t of this._subEmitterSystems)t._deserialize(this.context,this.gameObject)}awake(){if(this._worldPositionFrame=-1,this._renderer=this.gameObject.getComponent(Ja),!this.main)throw new Error("Not Supported: ParticleSystem needs a serialized MainModule. Creating new particle systems at runtime is currently not supported.");this._container=new ye,this._container.matrixAutoUpdate=!1,this.context.scene.add(this._container),this._batchSystem=new N0e,this._batchSystem.name=this.gameObject.name,this._container.add(this._batchSystem),this._interface=new Ive(this),this._particleSystem=new M0e(this._interface),this._particleSystem.addBehavior(new wve(this)),this._particleSystem.addBehavior(new Eve(this)),this._particleSystem.addBehavior(new bve(this)),this._particleSystem.addBehavior(new _ve(this)),this._particleSystem.addBehavior(new Sve(this)),this._particleSystem.addBehavior(new Cve(this)),this._batchSystem.addSystem(this._particleSystem);const e=this._particleSystem.emitter;this.context.scene.add(e),this.inheritVelocity.system&&this.inheritVelocity.system!==this&&(this.inheritVelocity=this.inheritVelocity.clone()),this.inheritVelocity.awake(this),I0&&(console.log(this),this.gameObject.add(new ta(1)))}start(){this.addSubParticleSystems(),this.updateLayers(),this.renderer.particleMesh instanceof pe&&this._interface.renderMode==at.Mesh&&mi.assignMeshLOD(this.renderer.particleMesh,0).then(e=>{e&&this.particleSystem&&this._interface.renderMode==at.Mesh&&(this.particleSystem.instancingGeometry=e)})}onDestroy(){var e,t,i,n;(e=this._container)==null||e.removeFromParent(),(t=this._batchSystem)==null||t.removeFromParent(),(i=this._particleSystem)==null||i.emitter.removeFromParent(),(n=this._particleSystem)==null||n.dispose()}onEnable(){this.main&&(this.inheritVelocity&&(this.inheritVelocity.system=this),this._batchSystem&&(this._batchSystem.visible=!0),this.playOnAwake&&this.play(),this._isPlaying=this.playOnAwake)}onDisable(){this._batchSystem&&(this._batchSystem.visible=!1)}onBeforeRender(){var e;this.main&&(this._didPreWarm===!1&&((e=this.main)==null?void 0:e.prewarm)===!0&&(this._didPreWarm=!0,this.preWarm()),this.onUpdate(),this.onSimulate(this.deltaTime))}preWarm(){var l;if(!((l=this.emission)!=null&&l.enabled)||this.emission.rateOverTime.getMax()<=0)return;const t=1/60,i=this.main.duration,n=this.main.startLifetime.getMax(),r=1e3,o=Math.min(Math.max(i,n)/Math.max(.01,this.main.simulationSpeed),r),a=Math.ceil(o/t),c=Date.now();I0&&console.log(`Particles ${this.name} - Prewarm for ${a} frames (${o} sec). Duration: ${i}, Lifetime: ${n}`);for(let h=0;h<a&&!(this.currentParticles>=this.maxParticles);h++){const u=Date.now()-c;if(u>2e3){console.warn(`Particles ${this.name} - Prewarm took too long. Aborting: ${u}`);break}this.onUpdate(),this.onSimulate(t)}}onSimulate(e){if(this._batchSystem){let t=this.context.time.frameCount%60===0;this._lastBatchesCount!==this._batchSystem.batches.length&&(this._lastBatchesCount=this._batchSystem.batches.length,t=!0),t&&this.updateLayers(),this._batchSystem.update(e)}this._time+=e,this._time>this.duration&&(this._time=0)}updateLayers(){if(this._batchSystem)for(let e=0;e<this._batchSystem.batches.length;e++){const t=this._batchSystem.batches[e];t.layers.disableAll();const i=this.layer;t.layers.mask=1<<i}}onUpdate(){var r,o;const e=this.renderer.getMaterial(this.trails.enabled);if(e&&e.version!=this.lastMaterialVersion&&this._particleSystem&&(this.lastMaterialVersion=e.version,this._particleSystem.texture=this._interface.texture),this._bursts&&(this.emission.bursts=this._bursts,delete this._bursts),!this._isPlaying)return;const t=this.context.mainCamera;if(t){const a=Ji(t);this._cameraScale=a.x}const i=!this.worldspace,n=this.gameObject;if(Fi(n,this.__worldQuaternion),this._worldQuaternionInverted.copy(this.__worldQuaternion).invert(),Ji(this.gameObject,this._worldScale),i&&this._container&&((r=this.gameObject)!=null&&r.parent)){const a=Ej(this,HP);this._container.matrix.makeScale(a.x,a.y,a.z),this._container.matrix.makeRotationFromQuaternion(this.__worldQuaternion),this._container.matrix.setPosition(this.worldPos),this._container.matrix.scale(this.gameObject.scale)}this.emission.system=this,this._interface.update(),this.shape.update(this,this.context,this.main.simulationSpace,this.gameObject),this.noise.update(this.context),(o=this.inheritVelocity)==null||o.update(this.context),this.velocityOverLifetime.update(this)}addSubParticleSystems(){var e;if(this._subEmitterSystems&&this._particleSystem)for(const t of this._subEmitterSystems){t.particleSystem&&(t.particleSystem.__internalAwake?t.particleSystem.__internalAwake():ht()&&console.warn("SubParticleSystem serialization issue(?)",t.particleSystem,t));const i=(e=t.particleSystem)==null?void 0:e._particleSystem;if(i){t.particleSystem._isUsedAsSubsystem=!0;const n=new XI(this,this._particleSystem,t.particleSystem,i);n.emitterType=t.type,n.emitterProbability=t.emitProbability,this._particleSystem.addBehavior(n)}else I0&&console.warn("Could not add SubParticleSystem",t,this)}}};let as=PC;Tn([x(s_)],as.prototype,"colorOverLifetime",2);Tn([x(dr)],as.prototype,"main",2);Tn([x(Rl)],as.prototype,"emission",2);Tn([x(Bd)],as.prototype,"sizeOverLifetime",2);Tn([x(In)],as.prototype,"shape",2);Tn([x(Di)],as.prototype,"noise",2);Tn([x(yn)],as.prototype,"trails",2);Tn([x(Mn)],as.prototype,"velocityOverLifetime",2);Tn([x(us)],as.prototype,"limitVelocityOverLifetime",2);Tn([x(Rd)],as.prototype,"inheritVelocity",2);Tn([x(Gp)],as.prototype,"colorBySpeed",2);Tn([x(fr)],as.prototype,"textureSheetAnimation",2);Tn([x(Xa)],as.prototype,"rotationOverLifetime",2);Tn([x(ca)],as.prototype,"rotationBySpeed",2);Tn([x(co)],as.prototype,"sizeBySpeed",2);class nb{constructor(){d(this,"particleSystem");d(this,"emitProbability",1);d(this,"properties");d(this,"type")}_deserialize(e,t){const i=this.particleSystem;if(i instanceof as)return;let n="";i&&typeof i.guid=="string"&&(n=i.guid,this.particleSystem=re.findByGuid(n,t)),I0&&!(this.particleSystem instanceof as)&&console.warn("Could not find particle system for sub emitter",n,t,this)}}function Ej(s,e){if(e.set(1,1,1),s.gameObject.parent&&s.localspace)switch(s.main.scalingMode){case RP.Local:e=Ji(s.gameObject.parent,e),e.x=1/e.x,e.y=1/e.y,e.z=1/e.z;break;default:if(!s.unsupported_scaling_mode){s.unsupported_scaling_mode=!0;const t="ParticleSystem scale mode "+RP[s.main.scalingMode]+" is not supported";ht()&&Ni(t),console.warn(t,s.name,s)}e=Ji(s.gameObject,e);break}return e}new C(1,1,1);new C(0,0,1);class XI{constructor(e,t,i,n){d(this,"type","NeedleParticleSubEmitter");d(this,"emitterType");d(this,"emitterProbability");d(this,"q_",new Se);d(this,"v_",new C);d(this,"v2_",new C);d(this,"_emitterMatrix",new Ae);d(this,"_circularBuffer");this.system=e,this.particleSystem=t,this.subSystem=i,this.subParticleSystem=n,this.subParticleSystem&&this.subParticleSystem&&(this.subParticleSystem.onlyUsedByOther=!0);const r=1e3;this._circularBuffer=new Ua(()=>new Ae,r)}clone(){throw new Error("Method not implemented.")}initialize(e){e.emissionState={burstIndex:0,burstWaveIndex:0,time:0,waitEmiting:0},this._emitterMatrix.copy(this.subSystem.matrixWorld).invert().premultiply(this.system.matrixWorld),this._emitterMatrix.setPosition(0,0,0),this.emitterType===GP.Birth&&this.run(e)}update(e,t){this.run(e)}frameUpdate(e){}toJSON(){}reset(){}run(e){if(this.subSystem.currentParticles>=this.subSystem.main.maxParticles||!this.subParticleSystem||!e.emissionState||this.emitterProbability&&Math.random()>this.emitterProbability)return;const t=this.system.deltaTime;if(this.emitterType===GP.Death){let n=e.life;if(e[Im]!==void 0&&(n=e[Im]),!(e.age+t*1.2>=n))return;const o=this.subSystem.main.maxParticles-this.subSystem.currentParticles;e.emissionState.waitEmiting=o}const i=new Ae;i.set(1,0,0,e.position.x,0,1,0,e.position.y,0,0,1,e.position.z,0,0,0,1),this.particleSystem.worldSpace||i.multiplyMatrices(this._emitterMatrix,i),this.subParticleSystem.emit(t,e.emissionState,i)}}var Tve=Object.defineProperty,Bve=Object.getOwnPropertyDescriptor,Rve=(s,e,t,i)=>{for(var n=i>1?void 0:i?Bve(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Tve(e,t,n),n};class g_ extends kr{constructor(){super(...arguments);d(this,"granularity")}get typeName(){return"PixelationEffect"}onCreateEffect(){const t=new x5;return this.granularity.onValueChanged=i=>{t.granularity=i},t}}Rve([x(Lt)],g_.prototype,"granularity",2);qa("PixelationEffect",g_);class fA extends Te{constructor(){super(...arguments);d(this,"_didAssignPlayerColor",!1);d(this,"tryAssignColor",()=>{const t=re.getComponentInParent(this.gameObject,Oa);if(t&&t.owner)return this._didAssignPlayerColor=!0,this.assignUserColor(t.owner),!0;const i=re.getComponentInParent(this.gameObject,As);return i!=null&&i.connectionId?(this._didAssignPlayerColor=!0,this.assignUserColor(i.connectionId),!0):!1})}onEnable(){this.context.connection.beginListen(Jt.JoinedRoom,this.tryAssignColor),this._didAssignPlayerColor||this.startCoroutine(this.waitForConnection())}onDisable(){this.context.connection.stopListen(Jt.JoinedRoom,this.tryAssignColor)}*waitForConnection(){for(;!this.destroyed&&this.activeAndEnabled&&(yield G9(.2),!this.tryAssignColor()););}assignUserColor(t){const i=fA.hashCode(t),n=fA.colorFromHashCode(i);if(this.gameObject.type==="Mesh"){const r=this.gameObject;this.assignColor(n,t,r)}else if(this.gameObject.children)for(const r of this.gameObject.children){const o=r;o.material&&o.material.color&&this.assignColor(n,t,o)}}assignColor(t,i,n){let r=n.material;r&&(r._playerMaterial!==i&&(r=r.clone(),r._playerMaterial=i,n.material=r),r.color=t)}static hashCode(t){var i=0,n,r;if(t.length===0)return i;for(n=0;n<t.length;n++)r=t.charCodeAt(n),i=(i<<5)-i+r,i|=0;return i}static colorFromHashCode(t){const i=(t&16711680)>>16,n=(t&65280)>>8,r=t&255;return new ve(i/255,n/255,r/255)}}async function PO(s){const{NeedleEngineHTMLElement:e}=await Promise.resolve().then(()=>u_e);e.observedAttributes.includes(s)||e.observedAttributes.push(s)}var Pve=Object.defineProperty,Dve=Object.getOwnPropertyDescriptor,m_=(s,e,t,i)=>{for(var n=i>1?void 0:i?Dve(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Pve(e,t,n),n};const Ma=ie("debugskybox");PO("skybox-image");PO("environment-image");function Oz(s,e,t,i,n){const r=new Cl;r.allowDrop=!1,r.allowNetworking=!1,r.background=t,r.environment=i,re.addComponent(s.scene,r);const o=a=>{typeof a=="string"&&(Ma&&console.log(n,"CHANGED TO",a),r.setSkybox(a))};return mH(s.domElement,n,o),r.addEventListener("destroy",()=>{Ma&&console.log("Destroyed attribute remote skybox",n),AH(s.domElement,n,o)}),r.setSkybox(e)}ui.addContextCreatedCallback(s=>{var r;const e=s.context,t=e.domElement.getAttribute("skybox-image"),i=e.domElement.getAttribute("environment-image"),n=new Array;if(t){Ma&&console.log("Creating remote skybox to load "+t),((r=e.mainCameraComponent)==null?void 0:r.clearFlags)!==vp.Skybox&&console.warn('"skybox-image" attribute has no effect: camera clearflags are not set to "Skybox"');const o=Oz(e,t,!0,!1,"skybox-image");n.push(o)}if(i){Ma&&console.log("Creating remote environment to load "+i);const o=Oz(e,i,!1,!0,"environment-image");n.push(o)}return n.length>0?kE(n):Promise.resolve()});function Ij(){return globalThis.NEEDLE_ENGINE_SKYBOX_TEXTURES||(globalThis.NEEDLE_ENGINE_SKYBOX_TEXTURES=new Array),globalThis.NEEDLE_ENGINE_SKYBOX_TEXTURES}function Lz(s){const t=Ij().find(i=>i.src===s);return t?(Ma&&console.log("Skybox: Found previously loaded texture for "+s),t.texture):null}async function kve(s){const e=await s;rk(e,!0),Wi(e)}function Ove(s,e){const t=Ij();for(;t.length>5;){const i=t.shift();i&&kve(i.texture)}e.then(i=>rk(i,!1)),t.push({src:s,texture:e})}class Cl extends Te{constructor(){super(...arguments);d(this,"url");d(this,"allowDrop",!0);d(this,"background",!0);d(this,"environment",!0);d(this,"allowNetworking",!0);d(this,"_loader");d(this,"_prevUrl");d(this,"_prevLoadedEnvironment");d(this,"_prevEnvironment",null);d(this,"_prevBackground",null);d(this,"validTextureTypes",[".hdr",".exr",".jpg",".jpeg",".png"]);d(this,"onDragOverEvent",t=>{if(this.allowDrop&&t.dataTransfer)for(const i of t.dataTransfer.types)(i==="text/uri-list"||i==="Files")&&t.preventDefault()});d(this,"onDrop",t=>{var i,n,r,o;if(this.allowDrop&&t.dataTransfer){for(const a of t.dataTransfer.types)if(Ma&&console.log(a),a==="text/uri-list"){const c=t.dataTransfer.getData(a);Ma&&console.log(a,c);let l=(n=(i=new RegExp(/polyhaven.com\/asset_img\/.+?\/(?<name>.+)\.png/).exec(c))==null?void 0:i.groups)==null?void 0:n.name;if(l||(l=(o=(r=new RegExp(/polyhaven\.com\/a\/(?<name>.+)/).exec(c))==null?void 0:r.groups)==null?void 0:o.name),Ma&&console.log(l),l){const h="https://dl.polyhaven.org/file/ph-assets/HDRIs/exr/1k/"+l+"_1k.exr";console.log(`[Remote Skybox] Setting skybox from url: ${h}`),t.preventDefault(),this.setSkybox(h);break}else if(this.isValidTextureType(c)){console.log("[Remote Skybox] Setting skybox from url: "+c),t.preventDefault(),this.setSkybox(c);break}else{console.warn(`[RemoteSkybox] Unknown url ${c}. 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 h=new CustomEvent("dropped-unknown-url",{detail:{sender:this,event:t,url:c,apply:u=>{t.preventDefault(),this.setSkybox(u)}}});this.dispatchEvent(h)}}else if(a=="Files"){const c=t.dataTransfer.files.item(0);if(Ma&&console.log(a,c),!c)continue;if(!this.isValidTextureType(c.name)){console.warn(`[RemoteSkybox]: File "${c.name}" is not supported. Supported files are ${this.validTextureTypes.join(", ")}`);return}if(Lz(c.name)===null){const l=new Blob([c]),h=URL.createObjectURL(l);t.preventDefault(),this.setSkybox(h,c.name)}else t.preventDefault(),this.setSkybox(c.name);break}}})}onEnable(){this.setSkybox(this.url),this.registerDropEvents()}onDisable(){var t;this.context.scene.environment===this._prevLoadedEnvironment&&(this.context.scene.environment=this._prevEnvironment,Vi.backgroundShouldBeTransparent(this.context)||(this.context.scene.background=this._prevBackground),this._prevLoadedEnvironment=void 0),this.unregisterDropEvents(),(t=this.context.mainCameraComponent)==null||t.applyClearFlags()}urlChangedSyncField(){this.allowNetworking&&this.url&&this.isRemoteTexture(this.url)&&this.setSkybox(this.url)}async setSkybox(t,i){var o;if(!this.activeAndEnabled||(t=Lve(t),!t))return!1;if(i??(i=t),this.isValidTextureType(i)||console.warn("Potentially invalid skybox url",i,"on",this.name),Ma&&console.log("Set remote skybox url: "+t),this._prevUrl===t&&this._prevLoadedEnvironment)return this.applySkybox(),!0;(o=this._prevLoadedEnvironment)==null||o.dispose(),this._prevLoadedEnvironment=void 0,this._prevUrl=t;const n=await this.loadTexture(t,i);if(!n||!this.enabled)return!1;this.url=t;const r=t.lastIndexOf("/");return n.name=t.substring(r>=0?r+1:0),this._loader instanceof fl&&(n.colorSpace=gt),this._prevLoadedEnvironment=n,this.applySkybox(),!0}async loadTexture(t,i){var l,h,u,f,p;if(!t)return Promise.resolve(null);i??(i=t);const n=Lz(i);if(n){const g=await n;if(((h=(l=g.source)==null?void 0:l.data)==null?void 0:h.length)>0||(p=(f=(u=g.source)==null?void 0:u.data)==null?void 0:f.data)!=null&&p.length)return g}const r=i.endsWith(".exr"),o=i.endsWith(".hdr");r?this._loader instanceof Hv||(this._loader=new Hv):o?this._loader instanceof wS||(this._loader=new wS):this._loader instanceof fl||(this._loader=new fl),Ma&&console.log("Loading skybox: "+t);const a=this._loader.loadAsync(t);return Ove(i,a),await a}applySkybox(){var i;const t=this._prevLoadedEnvironment;t&&(t.mapping=Jm,t.needsUpdate=!0,this.context.scene.background!==t&&(this._prevBackground=this.context.scene.background),this.context.scene.environment!==t&&(this._prevEnvironment=this.context.scene.environment),Ma&&console.log("Set remote skybox",this.url,!Vi.backgroundShouldBeTransparent(this.context)),this.environment&&(this.context.scene.environment=t),this.background&&!Vi.backgroundShouldBeTransparent(this.context)&&(this.context.scene.background=t),((i=this.context.mainCameraComponent)==null?void 0:i.backgroundBlurriness)!==void 0&&(this.context.scene.backgroundBlurriness=this.context.mainCameraComponent.backgroundBlurriness))}isRemoteTexture(t){return t.startsWith("http://")||t.startsWith("https://")}isValidTextureType(t){for(const i of this.validTextureTypes)if(t.endsWith(i))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)}}m_([Qk(Cl.prototype.urlChangedSyncField),x(URL)],Cl.prototype,"url",2);m_([x()],Cl.prototype,"allowDrop",2);m_([x()],Cl.prototype,"background",2);m_([x()],Cl.prototype,"environment",2);m_([x()],Cl.prototype,"allowNetworking",2);function Lve(s){switch(s==null?void 0:s.toLowerCase()){case"studio":s="https://cdn.needle.tools/static/skybox/modelviewer-Neutral.hdr";break;case"blurred-skybox":s="https://cdn.needle.tools/static/skybox/blurred-skybox.exr";break;case"quicklook-ar":s="https://cdn.needle.tools/static/skybox/QuickLook-ARMode.exr";break;case"quicklook":s="https://cdn.needle.tools/static/skybox/QuickLook-ObjectMode.exr";break}return s===void 0?null:s}var Fve=Object.defineProperty,Uve=Object.getOwnPropertyDescriptor,la=(s,e,t,i)=>{for(var n=i>1?void 0:i?Uve(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Fve(e,t,n),n};const Vo=ie("debugsceneswitcher"),DC="scene";PO(DC);const Su=Promise.resolve(!1);class Ur extends Te{constructor(){super(...arguments);d(this,"autoLoadFirstScene",!0);d(this,"scenes",[]);d(this,"loadingScene");d(this,"queryParameterName","scene");d(this,"useSceneName",!0);d(this,"clamp",!0);d(this,"useHistory",!0);d(this,"useKeyboard",!0);d(this,"useSwipe",!0);d(this,"useSceneLighting",!0);d(this,"preloadNext",1);d(this,"preloadPrevious",1);d(this,"preloadConcurrent",2);d(this,"_currentIndex",-1);d(this,"_currentScene");d(this,"_engineElementOverserver");d(this,"_preloadScheduler");d(this,"onPopState",async t=>{if(!this.useHistory)return;const i=this.useHistory;try{this.useHistory=!1;let n=!1;if(this.queryParameterName&&(n=await this.tryLoadFromQueryParam()),!n){const r=t==null?void 0:t.state;if(r&&r.startsWith(this.guid)){const o=r.substr(this.guid.length+2);Vo&&console.log("PopState",o),await this.trySelectSceneFromValue(o)}}}finally{this.useHistory=i}});d(this,"normalizedSwipeThresholdX",.1);d(this,"_didSwipe",!1);d(this,"onInputPointerMove",t=>{if(this.useSwipe&&!this._didSwipe&&t.button===0&&t.pointerType==="touch"&&this.context.input.getPointerPressedCount()===1){const i=this.context.input.getPointerPositionDelta(t.button);if(i){const n=i.x/this.context.domWidth;n>=this.normalizedSwipeThresholdX?(this._didSwipe=!0,this.selectPrev()):n<=-this.normalizedSwipeThresholdX&&(this._didSwipe=!0,this.selectNext())}}});d(this,"onInputPointerUp",t=>{t.button===0&&(this._didSwipe=!1)});d(this,"onInputKeyDown",t=>{if(!this.useKeyboard||!this.scenes)return;const i=t.key.toLowerCase();if(!i)return;const n=parseInt(i)-1;if(n>=0){this.trySelectSceneFromValue(n);return}switch(i){case"arrowright":case"d":this.selectNext();break;case"arrowleft":case"a":this.selectPrev();break}});d(this,"__lastSwitchScene");d(this,"__lastSwitchScenePromise");d(this,"_currentlyLoadingScene");d(this,"_lastLoadingScene");d(this,"_loadingScenePromise");d(this,"_isCurrentlyLoading",!1);d(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=[]),Vo&&console.log("SceneSwitcher",this)}async onEnable(){if(globalThis.addEventListener("popstate",this.onPopState),this.context.input.addEventListener(fn.KeyDown,this.onInputKeyDown),this.context.input.addEventListener(fn.PointerMove,this.onInputPointerMove),this.context.input.addEventListener(fn.PointerUp,this.onInputPointerUp),this._engineElementOverserver||(this._engineElementOverserver=new MutationObserver(t=>{for(const i of t)if(i.type==="attributes"&&i.attributeName===DC){const n=this.context.domElement.getAttribute(DC);n!==null&&this.trySelectSceneFromValue(n)}})),this._engineElementOverserver.observe(this.context.domElement,{attributes:!0}),this._preloadScheduler||(this._preloadScheduler=new Nve(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 t=this.context.domElement.getAttribute(DC);try{(t===null||!await this.trySelectSceneFromValue(t))&&this._currentIndex===-1&&this.select(0)}finally{}}}onDisable(){var t;globalThis.removeEventListener("popstate",this.onPopState),this.context.input.removeEventListener(fn.KeyDown,this.onInputKeyDown),this.context.input.removeEventListener(fn.PointerMove,this.onInputPointerMove),this.context.input.removeEventListener(fn.PointerUp,this.onInputPointerUp),(t=this._preloadScheduler)==null||t.stop()}addScene(t){if(typeof t=="string"){let i=this.context.addressables.findAssetReference(t);return i||(i=new $t(t),this.context.addressables.registerAssetReference(i)),this.scenes.push(i),i}return this.scenes.push(t),t}selectNext(){return this.select(this._currentIndex+1)}selectPrev(){return this.select(this._currentIndex-1)}select(t){var n,r,o;if(Vo&&console.log("select",t),typeof t=="object"&&console.warn('Switching to "'+t+'" might not work. Please either use an index or a AssetReference (not a scene reference)'),typeof t=="string"){const a=(n=this.scenes)==null?void 0:n.find(c=>c.uri===t);if(!a){const c=$t.getOrCreate(this.sourceId??"",t,this.context);return this.switchScene(c)}if(a)t=(r=this.scenes)==null?void 0:r.indexOf(a);else return Su}if(!((o=this.scenes)!=null&&o.length))return Su;if(t<0){if(this.clamp)return Su;t=this.scenes.length-1}else if(t>=this.scenes.length){if(this.clamp)return Su;t=0}const i=this.scenes[t];return this.switchScene(i)}async switchScene(t){if(!(t instanceof $t)){const n=typeof t;return n==="string"?this.select(t):n==="number"?this.select(t):(console.warn("SceneSwitcher: Can't switch to scene",t,"of type",n),!1)}return t.uri===this.sourceId?(console.warn("SceneSwitcher: can't load own scene - prevent recursive loading",this.sourceId),!1):this.__lastSwitchScene===t&&this.__lastSwitchScenePromise?this.__lastSwitchScenePromise:(this.__lastSwitchScene=t,this.__lastSwitchScenePromise=this.__internalSwitchScene(t),await this.__lastSwitchScenePromise)}async __internalSwitchScene(t){var n,r;if(this._currentScene){Vo&&console.log("UNLOAD",t.uri);const o=this.tryGetSceneEventListener(this._currentScene.asset);if(o!=null&&o.sceneClosing){const a=o.sceneClosing();a instanceof Promise&&await a}this._currentScene.unload()}this._currentScene=void 0;const i=this._currentIndex=((n=this.scenes)==null?void 0:n.indexOf(t))??-1;try{this._currentlyLoadingScene=t,this._currentLoadingProgress=new ProgressEvent("progress",{loaded:0,total:1});const o=new CustomEvent("loadscene-start",{detail:{scene:t,switcher:this,index:i}});this.dispatchEvent(o),await this.onStartLoading(),await t.loadAssetAsync((c,l)=>{this._currentLoadingProgress=l,this.dispatchEvent(l)}).catch(console.error),await this.onEndLoading();const a=new CustomEvent("loadscene-finished",{detail:{scene:t,switcher:this,index:i}});if(this.dispatchEvent(a),this._currentLoadingProgress=void 0,this._currentlyLoadingScene=void 0,a.defaultPrevented)return Vo&&console.warn("Adding loaded scene prevented:",t,a),!1;if(!t.asset)return Vo&&console.warn("Failed loading scene:",t),!1;if(this._currentIndex===i){if(Vo&&console.log("ADD",t.uri),this._currentScene=t,re.add(t.asset,this.gameObject),this.useSceneLighting&&this.context.sceneLighting.enable(t),this.useHistory&&i>=0){let h=i.toString();if(this.useSceneName&&(h=Fz(t.uri)),(r=this.queryParameterName)!=null&&r.length)tS(this.queryParameterName,h,this.useHistory);else{const u=history.state,f=this.guid+"::"+i;u!==f&&history.pushState(f,"unused",location.href)}}const c=this.tryGetSceneEventListener(t.asset);if(c!=null&&c.sceneOpened){const h=c.sceneOpened(this);h instanceof Promise&&await h}const l=new CustomEvent("scene-opened",{detail:{scene:t,switcher:this,index:i}});return this.dispatchEvent(l),!0}}catch(o){console.error(o)}return!1}preload(t){if(t>=0&&t<this.scenes.length){const i=this.scenes[t];if(i instanceof $t)return i.preload()}return Su}tryLoadFromQueryParam(){var i;if(!((i=this.queryParameterName)!=null&&i.length))return Su;const t=ie(this.queryParameterName);return typeof t=="boolean"?Su:this.trySelectSceneFromValue(t)}trySelectSceneFromValue(t){if(typeof t=="string"){const i=parseInt(t);if(i>=0&&i<this.scenes.length)return this.select(i);{const n=t.toLowerCase();for(let r=0;r<this.scenes.length;r++){const o=this.scenes[r];if(o&&Fz(o.uri).toLowerCase().includes(n))return this.select(r)}}}else if(typeof t=="number"&&t>=0&&t<this.scenes.length)return this.select(t);return ro()&&console.warn('Can not find scene: "'+t+'"',this),Su}async onStartLoading(){var t,i;if(this._isCurrentlyLoading=!0,this.loadingScene&&(this._lastLoadingScene!==this.loadingScene&&(this._loadingScenePromise=void 0),this._lastLoadingScene=this.loadingScene,this._loadingScenePromise||(this._loadingScenePromise=(t=this.loadingScene)==null?void 0:t.loadAssetAsync()),await this._loadingScenePromise,this._isCurrentlyLoading&&((i=this.loadingScene)!=null&&i.asset))){Vo&&console.log("Add loading scene",this.loadingScene.uri,this.loadingScene.asset);const n=this.loadingScene.asset;re.add(n,this.gameObject);const r=this.tryGetSceneEventListener(n);if(r!=null&&r.sceneOpened){const o=r.sceneOpened(this);o instanceof Promise&&await o}}if(this._isCurrentlyLoading){const n=this.tryGetSceneEventListener(this.gameObject);if(n&&n.sceneOpened){const r=n.sceneOpened(this);r instanceof Promise&&await r}}}async onEndLoading(){var t;if(this._isCurrentlyLoading=!1,(t=this.loadingScene)!=null&&t.asset){Vo&&console.log("Remove loading scene",this.loadingScene.uri);const i=this.loadingScene.asset,n=this.tryGetSceneEventListener(i);if(typeof(n==null?void 0:n.sceneClosing)=="function"){const r=n.sceneClosing();r instanceof Promise&&await r}re.remove(i)}if(!this._isCurrentlyLoading){const i=this.tryGetSceneEventListener(this.gameObject);if(i&&i.sceneClosing){const n=i.sceneClosing();n instanceof Promise&&await n}}}tryGetSceneEventListener(t,i=0){const n=re.foreachComponent(t,r=>r.sceneClosing?r:void 0);if(i===0&&!n&&t.children.length)for(const r of t.children){const o=this.tryGetSceneEventListener(r,i+1);if(o)return o}return n||null}}la([x()],Ur.prototype,"autoLoadFirstScene",2);la([x($t)],Ur.prototype,"scenes",2);la([x($t)],Ur.prototype,"loadingScene",2);la([x()],Ur.prototype,"queryParameterName",2);la([x()],Ur.prototype,"useSceneName",2);la([x()],Ur.prototype,"clamp",2);la([x()],Ur.prototype,"useHistory",2);la([x()],Ur.prototype,"useKeyboard",2);la([x()],Ur.prototype,"useSwipe",2);la([x()],Ur.prototype,"useSceneLighting",2);la([x()],Ur.prototype,"preloadNext",2);la([x()],Ur.prototype,"preloadPrevious",2);la([x()],Ur.prototype,"preloadConcurrent",2);function Fz(s){const e=s.split("/").pop(),t=e==null?void 0:e.split(".").shift();return t!=null&&t.length?t:s}class Nve{constructor(e,t=1,i=1,n=2){d(this,"maxLoadAhead");d(this,"maxLoadBehind");d(this,"maxConcurrent");d(this,"_isRunning",!1);d(this,"_switcher");d(this,"_loadTasks",[]);d(this,"_maxConcurrentLoads",1);this._switcher=e,this.maxLoadAhead=t,this.maxLoadBehind=i,this.maxConcurrent=n}begin(){if(this._isRunning)return;Vo&&console.log("Preload begin"),this._isRunning=!0;let e=-1,t,i;const n=this._switcher.scenes,r=setInterval(()=>{if(this.allLoaded()&&(Vo&&console.log("All scenes loaded"),this.stop()),!this._isRunning){clearInterval(r);return}if(this.canLoadNewScene()===!1)return;e!==this._switcher.currentIndex&&(e=this._switcher.currentIndex,i=0,t=0);const o=i%2===0;o&&(t+=1),i+=1;const a=o?this.maxLoadAhead:this.maxLoadBehind;if(t>a)return;const c=o?e+t:e-t;if(c<0||c<0||c>=n.length)return;const l=n[c];new Qve(c,l,this._loadTasks)},200)}stop(){this._isRunning=!1}canLoadNewScene(){return this._loadTasks.length<this._maxConcurrentLoads}allLoaded(){if(this._switcher.scenes){for(const e of this._switcher.scenes)if((e==null?void 0:e.isLoaded())===!1)return!1}return!0}}class Qve{constructor(e,t,i){d(this,"index");d(this,"asset");d(this,"tasks");this.index=e,this.asset=t,this.tasks=i,i.push(this),this.awaitLoading()}async awaitLoading(){this.asset&&!this.asset.isLoaded()&&(Vo&&console.log("Preload start: "+this.asset.uri,this.index),await this.asset.preload(),Vo&&console.log("Preload finished: "+this.asset.uri,this.index));const e=this.tasks.indexOf(this);e>=0&&this.tasks.splice(e,1)}}function zve(){return new Promise((s,e)=>{const i=()=>{i!=null&&(document.removeEventListener("pointerdown",i),document.removeEventListener("click",i),document.removeEventListener("dragstart",i),document.removeEventListener("touchstart",i),s())};document.addEventListener("pointerdown",i),document.addEventListener("click",i),document.addEventListener("dragstart",i),document.addEventListener("touchstart",i)})}async function Gve(s){await zve(),s()}var Hve=Object.defineProperty,Vve=Object.getOwnPropertyDescriptor,ha=(s,e,t,i)=>{for(var n=i>1?void 0:i?Vve(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Hve(e,t,n),n};const Is=ie("debugvideo");var Mj=(s=>(s[s.None=0]="None",s[s.AdjustHeight=1]="AdjustHeight",s[s.AdjustWidth=2]="AdjustWidth",s))(Mj||{}),Tj=(s=>(s[s.VideoClip=0]="VideoClip",s[s.Url=1]="Url",s))(Tj||{}),Bj=(s=>(s[s.CameraFarPlane=0]="CameraFarPlane",s[s.CameraNearPlane=1]="CameraNearPlane",s[s.RenderTexture=2]="RenderTexture",s[s.MaterialOverride=3]="MaterialOverride",s))(Bj||{});class _s extends Te{constructor(){super();d(this,"playOnAwake",!0);d(this,"aspectMode",0);d(this,"clip",null);d(this,"source",1);d(this,"_url",null);d(this,"renderMode");d(this,"targetMaterialProperty");d(this,"targetMaterialRenderer");d(this,"targetTexture");d(this,"time",0);d(this,"_playbackSpeed",1);d(this,"_isLooping",!1);d(this,"_muted",!1);d(this,"_audioOutputMode",2);d(this,"playInBackground",!0);d(this,"_crossOrigin","anonymous");d(this,"_videoElement",null);d(this,"_videoTexture",null);d(this,"_videoMaterial",null);d(this,"_isPlaying",!1);d(this,"wasPlaying",!1);d(this,"visibilityChanged",t=>{switch(document.visibilityState){case"hidden":this.playInBackground||(this.wasPlaying=this._isPlaying,this.pause());break;case"visible":this.wasPlaying&&!this._isPlaying&&this.play();break}});d(this,"_receivedInput",!1);d(this,"_overlay",null);d(this,"_targetObjects");d(this,"_updateAspectRoutineId",-1);d(this,"_hls");d(this,"onHlsAvailable",()=>{var t;Is&&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),(t=this._videoElement)==null||t.play(),Is&&console.log("HLS: loaded",this.clip))});Gve(()=>{this._receivedInput=!0,this.updateVideoElementSettings()}),this._targetObjects=[],ie("videoscreenspace")&&window.addEventListener("keydown",t=>{t.key==="f"&&(this.screenspace=!this.screenspace)})}get url(){return this._url}set url(t){const n=this._url!==t;this.__didAwake?n&&this.setClipURL(t??""):this._url=t}get playbackSpeed(){var t;return((t=this._videoElement)==null?void 0:t.playbackRate)??this._playbackSpeed}set playbackSpeed(t){this._playbackSpeed=t,this._videoElement&&(this._videoElement.playbackRate=t)}get isLooping(){var t;return((t=this._videoElement)==null?void 0:t.loop)??this._isLooping}set isLooping(t){this._isLooping=t,this._videoElement&&(this._videoElement.loop=t)}get currentTime(){var t;return((t=this._videoElement)==null?void 0:t.currentTime)??this.time}set currentTime(t){this._videoElement?this._videoElement.currentTime=t:this.time=t}get isPlaying(){const t=this._videoElement;if(t){if(t.currentTime>0&&!t.paused&&!t.ended&&t.readyState>t.HAVE_CURRENT_DATA)return!0;if(t.srcObject&&t.srcObject.active)return!0}return!1}get crossOrigin(){var t;return((t=this._videoElement)==null?void 0:t.crossOrigin)??this._crossOrigin}set crossOrigin(t){this._crossOrigin=t,this._videoElement&&(t!==null?this._videoElement.setAttribute("crossorigin",t):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 t;return((t=this._videoElement)==null?void 0:t.muted)??this._muted}set muted(t){this._muted=t,this._videoElement&&(this._videoElement.muted=t)}get currentVideo(){return this.clip}set audioOutputMode(t){t!==this._audioOutputMode&&(t===1&&ht()&&console.warn("VideoAudioOutputMode.AudioSource is not yet implemented"),this._audioOutputMode=t,this.updateVideoElementSettings())}get audioOutputMode(){return this._audioOutputMode}preloadVideo(){Is&&console.log("Video Preload: "+this.name,this.clip),this.create(!1)}preload(){this.preloadVideo()}setVideo(t){this.clip=t,this.source=0,this._videoElement?(this._videoElement.srcObject=t,this._isPlaying&&this.play(),this.updateAspect()):this.create(this.playOnAwake)}setClipURL(t){this._url!==t&&(this._url=t,this.source=1,Is&&console.log("set url",t),this._videoElement?t.endsWith(".m3u8")||t.includes(".m3u")?this.ensureM3UCanBePlayed():(this._videoElement.src=t,this._isPlaying&&(this.stop(),this.play())):this.create(this.playOnAwake))}onEnable(){var t,i;Is&&console.log("VideoPlayer.onEnable",Tj[this.source],this.clip,this.url,this),window.addEventListener("visibilitychange",this.visibilityChanged),this.playOnAwake===!0?this.create(!0):this.preloadVideo(),this.screenspace?(t=this._overlay)==null||t.start():(i=this._overlay)==null||i.stop()}onDisable(){var t;window.removeEventListener("visibilitychange",this.visibilityChanged),(t=this._overlay)==null||t.stop(),this.pause()}onDestroy(){var t;this._videoElement&&((t=this.videoElement)==null||t.remove(),this._videoElement=null),this._videoTexture&&(this._videoTexture.dispose(),this._videoTexture=null)}play(){var t,i;if(this._videoElement||this.create(!1),!this._videoElement){Is&&console.warn("Can not play: no video element found",this);return}if(!(this._isPlaying&&!((t=this._videoElement)!=null&&t.ended)&&!((i=this._videoElement)!=null&&i.paused))){if(this._isPlaying=!0,this._receivedInput||(this._videoElement.muted=!0),this.handleBeginPlaying(!1),this.shouldUseM3U){this.ensureM3UCanBePlayed();return}Is&&console.log("Video Play()",this.clip,this._videoElement,this.time),this._videoElement.currentTime=this.time,this._videoElement.play().catch(n=>{var r;console.log(n),Is&&console.error("Error playing video",n,"CODE="+n.code,(r=this.videoElement)==null?void 0:r.src,this),setTimeout(()=>{this._isPlaying&&!this.destroyed&&this.activeAndEnabled&&this.play()},1e3)}),Is&&console.log("play",this._videoElement,this.time)}}stop(){this._isPlaying=!1,this.time=0,this._videoElement&&(this._videoElement.currentTime=0,this._videoElement.pause(),Is&&console.log("STOP",this))}pause(){var t,i;this.time=((t=this._videoElement)==null?void 0:t.currentTime)??0,this._isPlaying=!1,(i=this._videoElement)==null||i.pause(),Is&&console.log("PAUSE",this,this.currentTime)}create(t){let i;switch(this.source){case 0:i=this.clip;break;case 1:i=this.url,!(i!=null&&i.length)&&typeof this.clip=="string"&&(i=this.clip);break}return i?(this._videoElement||(Is&&console.warn("Create VideoElement",this),this._videoElement=this.createVideoElement(),this.context.domElement.shadowRoot.prepend(this._videoElement),this.updateVideoElementStyles()),typeof i=="string"?(Is&&console.log("Set Video src",i),this._videoElement.src=i):(Is&&console.log("Set Video srcObject",i),this._videoElement.srcObject=i),this._videoTexture||(this._videoTexture=new TG(this._videoElement)),this._videoTexture.flipY=!1,this._videoTexture.colorSpace=gt,t&&this.handleBeginPlaying(t),Is&&console.log("Video: handle playing done...",i,t),!0):(Is&&console.warn("No video source set",this),!1)}updateAspect(){this.aspectMode!==0&&this.startCoroutine(this.updateAspectImpl())}get screenspace(){var t;return((t=this._overlay)==null?void 0:t.enabled)??!1}set screenspace(t){var i;if(t){if(!this._videoTexture)return;this._overlay||(this._overlay=new jve(this.context)),this._overlay.add(this._videoTexture)}else(i=this._overlay)==null||i.remove(this._videoTexture);this._overlay&&(this._overlay.enabled=t)}createVideoElement(){const t=document.createElement("video");return this._crossOrigin&&t.setAttribute("crossorigin",this._crossOrigin),Is&&console.log("created video element",t),t}handleBeginPlaying(t){var r,o;if(!this.activeAndEnabled||!this._videoElement)return;this._targetObjects.length=0;let i=this.gameObject;switch(this.renderMode){case 3:i=(r=this.targetMaterialRenderer)==null?void 0:r.gameObject,i||(i=(o=re.getComponent(this.gameObject,Nn))==null?void 0:o.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,Bj[this.renderMode],this);return}const n=i.material;if(n){this._targetObjects.push(i),n!==this._videoMaterial&&(this._videoMaterial=n.clone(),i.material=this._videoMaterial);const a="map",c=this._videoMaterial;if(!this.targetMaterialProperty)c[a]=this._videoTexture;else switch(this.targetMaterialProperty){default:c[a]=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(),t&&(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 t=!this._receivedInput||this.audioOutputMode===0;!t&&this._muted&&(t=!0),this._videoElement.muted=t,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 t=++this._updateAspectRoutineId,i=void 0,n=this.clip;for(;t===this._updateAspectRoutineId&&this.aspectMode!==0&&this.clip&&n===this.clip&&this._isPlaying;){if(!n||typeof n=="string")return;let r;for(const o of n.getVideoTracks()){const a=o.getSettings();if(a&&a.width&&a.height){r=a.width/a.height;break}else r=this.context.renderer.domElement.clientWidth/this.context.renderer.domElement.clientHeight}if(r===void 0){for(let o=0;o<10;o++)yield;if(!this.isPlaying)break;continue}if(i===r){yield;continue}for(const o of this._targetObjects){let a=1;if(o.parent){const c=Ji(o.parent);a=c.x/c.y}switch(this.aspectMode){case 1:o.scale.y=1/r*o.scale.x*a;break;case 2:o.scale.x=r*o.scale.y*a;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 t=document.head.querySelector("script[data-hls_library]");t?globalThis.Hls?this.onHlsAvailable():t.addEventListener("load",this.onHlsAvailable):(Is&&console.log("HLS: load script"),t=document.createElement("script"),t.dataset.hls_library="hls.js",t.src="https://cdn.jsdelivr.net/npm/hls.js@1",t.addEventListener("load",this.onHlsAvailable),document.head.append(t))}}ha([x()],_s.prototype,"playOnAwake",2);ha([x()],_s.prototype,"aspectMode",2);ha([x(URL)],_s.prototype,"clip",2);ha([x()],_s.prototype,"source",2);ha([x(URL)],_s.prototype,"url",1);ha([x()],_s.prototype,"renderMode",2);ha([x()],_s.prototype,"targetMaterialProperty",2);ha([x(Nn)],_s.prototype,"targetMaterialRenderer",2);ha([x(Ht)],_s.prototype,"targetTexture",2);ha([x()],_s.prototype,"time",2);ha([x()],_s.prototype,"playbackSpeed",1);ha([x()],_s.prototype,"isLooping",1);ha([x()],_s.prototype,"audioOutputMode",1);class jve{constructor(e){d(this,"context");d(this,"_videos",[]);d(this,"_screenspaceModeQuad");d(this,"_isInScreenspaceMode",!1);d(this,"_input");this.context=e,this._input=new Wve(this)}get enabled(){return this._isInScreenspaceMode}set enabled(e){e?this.start():this.stop()}add(e){this._videos.indexOf(e)===-1&&this._videos.push(e)}remove(e){if(!e)return;const t=this._videos.indexOf(e);t>=0&&this._videos.splice(t,1)}start(){var n;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=Db.createPrimitive(mp.Quad,{material:new qve(e)}),!this._screenspaceModeQuad)return;this._screenspaceModeQuad.geometry.scale(2,2,2)}const t=this._screenspaceModeQuad;this.context.scene.add(t),this.updateScreenspaceMaterialUniforms();const i=t.material;i==null||i.reset(),(n=this._input)==null||n.enable(i)}stop(){var e;this._isInScreenspaceMode=!1,this._screenspaceModeQuad&&((e=this._input)==null||e.disable(),this._screenspaceModeQuad.removeFromParent())}updateScreenspaceMaterialUniforms(){var t;const e=(t=this._screenspaceModeQuad)==null?void 0:t.material;e&&(e.screenAspect=this.context.domElement.clientWidth/this.context.domElement.clientHeight)}}class Wve{constructor(e){d(this,"_onResizeScreenFn");d(this,"_onKeyUpFn");d(this,"_onMouseWheelFn");d(this,"context");d(this,"overlay");d(this,"_material");d(this,"_isPinching",!1);d(this,"_lastPinch",0);this.overlay=e,this.context=e.context}enable(e){this._material=e,window.addEventListener("resize",this._onResizeScreenFn=()=>{this.overlay.updateScreenspaceMaterialUniforms()}),window.addEventListener("keyup",this._onKeyUpFn=n=>{n.key==="Escape"&&this.overlay.stop()}),window.addEventListener("wheel",this._onMouseWheelFn=n=>{this.overlay.enabled&&(e.zoom+=n.deltaY*5e-4,n.preventDefault())},{passive:!1});const t=new ee;window.addEventListener("mousemove",n=>{if(this.overlay.enabled&&this.context.input.getPointerPressed(0)){const r=new ee(n.movementX,n.movementY);r.x/=this.context.domElement.clientWidth,r.y/=this.context.domElement.clientHeight,t.set(r.x,r.y),t.multiplyScalar(e.zoom/-this.context.time.deltaTime*.01),e.offset=e.offset.add(t)}}),window.addEventListener("pointermove",n=>{this.overlay.enabled&&this.context.input.getPointerPressed(0)&&this.context.input.getTouchesPressedCount()===1&&(t.set(n.movementX,n.movementY),t.multiplyScalar(e.zoom*-this.context.time.deltaTime*.05),e.offset=e.offset.add(t))});let i=0;window.addEventListener("touchstart",n=>{if(n.touches.length<2){this.context.time.time-i<.3&&this.overlay.stop(),i=this.context.time.time;return}this._isPinching=!0,this._lastPinch=0}),window.addEventListener("touchmove",n=>{if(!this._isPinching||!this._material)return;const r=n.touches[0],o=n.touches[1],a=r.clientX-o.clientX,c=r.clientY-o.clientY,l=Math.sqrt(a*a+c*c);if(this._lastPinch!==0){const h=l-this._lastPinch;this._material.zoom-=h*.004}this._lastPinch=l}),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 qve extends Pt{constructor(t){super();d(this,"_offset",new ee);this.uniforms={map:{value:t},screenAspect:{value:1},offsetScale:{value:new Ke(0,0,1,1)}},this.vertexShader=`
7346
+ }`);new C(0,0,1);var F0e=function(s){ty(t,s);var e=iy(t);function t(i){var n;return It(this,t),n=e.call(this,i),te(oi(n),"positionBuffer",void 0),te(oi(n),"previousBuffer",void 0),te(oi(n),"nextBuffer",void 0),te(oi(n),"uvBuffer",void 0),te(oi(n),"sideBuffer",void 0),te(oi(n),"widthBuffer",void 0),te(oi(n),"colorBuffer",void 0),te(oi(n),"indexBuffer",void 0),te(oi(n),"vector_",new C),te(oi(n),"vector2_",new C),te(oi(n),"vector3_",new C),te(oi(n),"quaternion_",new Se),n.maxParticles=1e4,n.setupBuffers(),n.rebuildMaterial(),n}return Mt(t,[{key:"setupBuffers",value:function(){this.geometry&&this.geometry.dispose(),this.geometry=new _t,this.indexBuffer=new it(new Uint32Array(this.maxParticles*6),1),this.indexBuffer.setUsage(Cr),this.geometry.setIndex(this.indexBuffer),this.positionBuffer=new it(new Float32Array(this.maxParticles*6),3),this.positionBuffer.setUsage(Cr),this.geometry.setAttribute("position",this.positionBuffer),this.previousBuffer=new it(new Float32Array(this.maxParticles*6),3),this.previousBuffer.setUsage(Cr),this.geometry.setAttribute("previous",this.previousBuffer),this.nextBuffer=new it(new Float32Array(this.maxParticles*6),3),this.nextBuffer.setUsage(Cr),this.geometry.setAttribute("next",this.nextBuffer),this.widthBuffer=new it(new Float32Array(this.maxParticles*2),1),this.widthBuffer.setUsage(Cr),this.geometry.setAttribute("width",this.widthBuffer),this.sideBuffer=new it(new Float32Array(this.maxParticles*2),1),this.sideBuffer.setUsage(Cr),this.geometry.setAttribute("side",this.sideBuffer),this.uvBuffer=new it(new Float32Array(this.maxParticles*4),2),this.uvBuffer.setUsage(Cr),this.geometry.setAttribute("uv",this.uvBuffer),this.colorBuffer=new it(new Float32Array(this.maxParticles*8),4),this.colorBuffer.setUsage(Cr),this.geometry.setAttribute("color",this.colorBuffer)}},{key:"expandBuffers",value:function(n){for(;n>=this.maxParticles;)this.maxParticles*=2;this.setupBuffers()}},{key:"rebuildMaterial",value:function(){this.layers.mask=this.settings.layers.mask;var n={lineWidth:{value:1},map:{value:null},useMap:{value:0},alphaMap:{value:null},useAlphaMap:{value:0},resolution:{value:new ee(1,1)},sizeAttenuation:{value:1},visibility:{value:1},alphaTest:{value:0},repeat:{value:new ee(1,1)}},r={};if(r.USE_UV="",r.USE_COLOR_ALPHA="",this.settings.material.map&&(r.USE_MAP="",r.MAP_UV=zP(this.settings.material.map.channel),n.map=new we(this.settings.material.map),n.mapTransform=new we(new Qt().copy(this.settings.material.map.matrix))),this.settings.renderMode===at.Trail)this.material=new Pt({uniforms:n,defines:r,vertexShader:L0e,fragmentShader:O0e,transparent:this.settings.material.transparent,depthWrite:!this.settings.material.transparent,side:this.settings.material.side,blending:this.settings.material.blending||ep});else throw new Error("render mode unavailable")}},{key:"update",value:function(){var n=this,r=0,o=0,a=0;this.systems.forEach(function(c){for(var l=0;l<c.particleNum;l++)a+=c.particles[l].previous.length*2}),a>this.maxParticles&&this.expandBuffers(a),this.systems.forEach(function(c){var l=n.quaternion_,h=n.vector2_,u=n.vector3_;c.emitter.matrixWorld.decompose(h,l,u);for(var f=c.particles,p=c.particleNum,g=n.settings.uTileCount,y=n.settings.vTileCount,m=1/g,A=1/y,b=0;b<p;b++){var v=f[b],_=v.uvTile%y,w=Math.floor(v.uvTile/y),E=v.previous.values(),I=E.next(),M=I.value,R=M;I.done||(I=E.next());var S=void 0;I.value!==void 0?S=I.value:S=R;for(var T=0;T<v.previous.length;T++,r+=2){if(n.positionBuffer.setXYZ(r,R.position.x,R.position.y,R.position.z),n.positionBuffer.setXYZ(r+1,R.position.x,R.position.y,R.position.z),c.worldSpace?(n.positionBuffer.setXYZ(r,R.position.x,R.position.y,R.position.z),n.positionBuffer.setXYZ(r+1,R.position.x,R.position.y,R.position.z)):(v.parentMatrix?n.vector_.copy(R.position).applyMatrix4(v.parentMatrix):n.vector_.copy(R.position).applyMatrix4(c.emitter.matrixWorld),n.positionBuffer.setXYZ(r,n.vector_.x,n.vector_.y,n.vector_.z),n.positionBuffer.setXYZ(r+1,n.vector_.x,n.vector_.y,n.vector_.z)),c.worldSpace?(n.previousBuffer.setXYZ(r,M.position.x,M.position.y,M.position.z),n.previousBuffer.setXYZ(r+1,M.position.x,M.position.y,M.position.z)):(v.parentMatrix?n.vector_.copy(M.position).applyMatrix4(v.parentMatrix):n.vector_.copy(M.position).applyMatrix4(c.emitter.matrixWorld),n.previousBuffer.setXYZ(r,n.vector_.x,n.vector_.y,n.vector_.z),n.previousBuffer.setXYZ(r+1,n.vector_.x,n.vector_.y,n.vector_.z)),c.worldSpace?(n.nextBuffer.setXYZ(r,S.position.x,S.position.y,S.position.z),n.nextBuffer.setXYZ(r+1,S.position.x,S.position.y,S.position.z)):(v.parentMatrix?n.vector_.copy(S.position).applyMatrix4(v.parentMatrix):n.vector_.copy(S.position).applyMatrix4(c.emitter.matrixWorld),n.nextBuffer.setXYZ(r,n.vector_.x,n.vector_.y,n.vector_.z),n.nextBuffer.setXYZ(r+1,n.vector_.x,n.vector_.y,n.vector_.z)),n.sideBuffer.setX(r,-1),n.sideBuffer.setX(r+1,1),c.worldSpace)n.widthBuffer.setX(r,R.size),n.widthBuffer.setX(r+1,R.size);else if(v.parentMatrix)n.widthBuffer.setX(r,R.size),n.widthBuffer.setX(r+1,R.size);else{var F=(Math.abs(u.x)+Math.abs(u.y)+Math.abs(u.z))/3;n.widthBuffer.setX(r,R.size*F),n.widthBuffer.setX(r+1,R.size*F)}n.uvBuffer.setXY(r,(T/v.previous.length+_)*m,(y-w-1)*A),n.uvBuffer.setXY(r+1,(T/v.previous.length+_)*m,(y-w)*A),n.colorBuffer.setXYZW(r,R.color.x,R.color.y,R.color.z,R.color.w),n.colorBuffer.setXYZW(r+1,R.color.x,R.color.y,R.color.z,R.color.w),T+1<v.previous.length&&(n.indexBuffer.setX(o*3,r),n.indexBuffer.setX(o*3+1,r+1),n.indexBuffer.setX(o*3+2,r+2),o++,n.indexBuffer.setX(o*3,r+2),n.indexBuffer.setX(o*3+1,r+1),n.indexBuffer.setX(o*3+2,r+3),o++),M=R,R=S,I.done||(I=E.next(),I.value!==void 0&&(S=I.value))}}}),this.positionBuffer.updateRange.count=r*3,this.positionBuffer.needsUpdate=!0,this.previousBuffer.updateRange.count=r*3,this.previousBuffer.needsUpdate=!0,this.nextBuffer.updateRange.count=r*3,this.nextBuffer.needsUpdate=!0,this.sideBuffer.updateRange.count=r,this.sideBuffer.needsUpdate=!0,this.widthBuffer.updateRange.count=r,this.widthBuffer.needsUpdate=!0,this.uvBuffer.updateRange.count=r*2,this.uvBuffer.needsUpdate=!0,this.colorBuffer.updateRange.count=r*4,this.colorBuffer.needsUpdate=!0,this.indexBuffer.updateRange.count=o*3,this.indexBuffer.needsUpdate=!0,this.geometry.setDrawRange(0,o*3)}},{key:"dispose",value:function(){this.geometry.dispose()}}]),t}(Cj),U0e=function(s){ty(t,s);var e=iy(t);function t(){var i;return It(this,t),i=e.call(this),te(oi(i),"batches",[]),te(oi(i),"systemToBatchIndex",new Map),te(oi(i),"type","BatchedRenderer"),i}return Mt(t,[{key:"addSystem",value:function(n){n._renderer=this;for(var r=n.getRendererSettings(),o=0;o<this.batches.length;o++)if(t.equals(this.batches[o].settings,r)){this.batches[o].addSystem(n),this.systemToBatchIndex.set(n,o);return}var a;switch(r.renderMode){case at.Trail:a=new F0e(r);break;case at.Mesh:case at.BillBoard:case at.VerticalBillBoard:case at.HorizontalBillBoard:case at.StretchedBillBoard:a=new k0e(r);break}a.addSystem(n),this.batches.push(a),this.systemToBatchIndex.set(n,this.batches.length-1),this.add(a)}},{key:"deleteSystem",value:function(n){var r=this.systemToBatchIndex.get(n);r!=null&&(this.batches[r].removeSystem(n),this.systemToBatchIndex.delete(n))}},{key:"updateSystem",value:function(n){this.deleteSystem(n),this.addSystem(n)}},{key:"update",value:function(n){this.systemToBatchIndex.forEach(function(o,a){a.update(n)});for(var r=0;r<this.batches.length;r++)this.batches[r].update()}}],[{key:"equals",value:function(n,r){return n.material.side===r.material.side&&n.material.blending===r.material.blending&&n.material.transparent===r.material.transparent&&n.material.type===r.material.type&&n.material.alphaTest===r.material.alphaTest&&n.material.map===r.material.map&&n.renderMode===r.renderMode&&n.uTileCount===r.uTileCount&&n.vTileCount===r.vTileCount&&n.instancingGeometry===r.instancingGeometry&&n.renderOrder===r.renderOrder&&n.layers.mask===r.layers.mask}}]),t}(ye),N0e=U0e,Iz=function(){function s(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:new C;It(this,s),te(this,"locations",[]),this.scaleX=e,this.scaleY=t,this.position=i}return Mt(s,[{key:"transform",value:function(t,i){t.x=this.locations[i%this.locations.length].x*this.scaleX+this.position.x,t.y=this.locations[i%this.locations.length].y*this.scaleY+this.position.y,t.z=this.position.z}},{key:"clone",value:function(){var t=new s(this.scaleX,this.scaleY,this.position.clone());return t.locations=this.locations.map(function(i){return i.clone()}),t}},{key:"toJSON",value:function(){return{scaleX:this.scaleX,scaleY:this.scaleY,position:this.position,locations:this.locations.map(function(t){return{x:t.x,y:t.y}})}}},{key:"fromImage",value:function(t,i){var n=document.createElement("canvas");n.width=t.width,n.height=t.height;var r=n.getContext("2d");if(r){r.drawImage(t,0,0);var o=r.getImageData(0,0,n.width,n.height,{colorSpace:"srgb"});n.remove(),this.locations.length=0;for(var a=0;a<o.height;a++)for(var c=0;c<o.width;c++)o.data[(a*o.width+c)*4+3]>i&&this.locations.push(new ee(c,o.height-a))}}}],[{key:"fromJSON",value:function(t){var i=new s(t.scaleX,t.scaleY,new C(t.position[0],t.position[1],t.position[2]));return i.locations=t.locations.map(function(n){return new ee(n.x,n.y)}),i}}]),s}();function Q0e(s){switch(s.type){case"TextureSequencer":return Iz.fromJSON(s);default:return new Iz}}var z0e=function(){function s(e){It(this,s),te(this,"type","ApplySequences"),te(this,"sequencers",[]),te(this,"time",0),te(this,"index",0),te(this,"pCount",0),te(this,"delay",void 0),te(this,"tempV",new C),this.delay=e}return Mt(s,[{key:"initialize",value:function(t){t.id=this.pCount,t.dst=new C,t.begin=new C,t.inMotion=!1,this.pCount++}},{key:"reset",value:function(){this.time=0,this.index=0,this.pCount=0}},{key:"update",value:function(t,i){var n=this.sequencers[this.index],r=t.id*this.delay;this.time>=n[0].a+r&&this.time<=n[0].b+r?(t.inMotion||(t.inMotion=!0,t.begin.copy(t.position),n[1].transform(t.dst,t.id)),t.position.lerpVectors(t.begin,t.dst,s.BEZIER.genValue((this.time-n[0].a-r)/(n[0].b-n[0].a)))):this.time>n[0].b+r&&(t.inMotion=!1)}},{key:"frameUpdate",value:function(t){for(;this.index+1<this.sequencers.length&&this.time>=this.sequencers[this.index+1][0].a;)this.index++;this.time+=t}},{key:"appendSequencer",value:function(t,i){this.sequencers.push([t,i])}},{key:"toJSON",value:function(){return{type:this.type,delay:this.delay,sequencers:this.sequencers.map(function(t){var i=jm(t,2),n=i[0],r=i[1];return{range:n.toJSON(),sequencer:r.toJSON()}})}}},{key:"clone",value:function(){var t=new s(this.delay);return t.sequencers=this.sequencers.map(function(i){return[i[0].clone(),i[1].clone()]}),t}}],[{key:"fromJSON",value:function(t){var i=new s(t.delay);return t.sequencers.forEach(function(n){i.sequencers.push([Ki(n.range),Q0e(n.sequencer)])}),i}}]),s}();te(z0e,"BEZIER",new FP(0,0,1,1));var de=function(s){return s[s.Number=0]="Number",s[s.Vec2=1]="Vec2",s[s.Vec3=2]="Vec3",s[s.Vec4=3]="Vec4",s[s.Boolean=4]="Boolean",s[s.AnyType=5]="AnyType",s}({}),Mz=Mt(function s(e,t,i,n){It(this,s),te(this,"input",void 0),te(this,"inputIndex",void 0),te(this,"output",void 0),te(this,"outputIndex",void 0),this.input=e,this.inputIndex=t,this.input.outputs[t].push(this),this.output=i,this.outputIndex=n,this.output.inputs[n]=this}),G0e=function(){function s(){It(this,s),te(this,"visited",new Set),te(this,"graph_",void 0),te(this,"context_",void 0),s.Instance=this}return Mt(s,[{key:"traverse",value:function(t){if(this.context_===void 0)throw new Error("context is undefined");if(this.graph_===void 0)throw new Error("graph is undefined");this.visited.add(t.id);for(var i=[],n=0;n<t.inputs.length;n++)if(t.inputs[n]instanceof Mz){var r=t.inputs[n].input;this.visited.has(r.id)||this.traverse(r),i.push(r.outputValues[t.inputs[n].inputIndex])}else i.push(t.inputs[n].getValue(this.context_));t.func(this.context_,i,t.outputValues),this.graph_.nodesInOrder.push(t)}},{key:"executeCompiledGraph",value:function(){if(this.context_===void 0)throw new Error("context is undefined");if(this.graph_===void 0)throw new Error("graph is undefined");for(var t=this.graph_.nodesInOrder,i=0;i<t.length;i++){for(var n=[],r=t[i],o=0;o<r.inputs.length;o++)if(r.inputs[o]instanceof Mz)n.push(r.inputs[o].input.outputValues[r.inputs[o].inputIndex]);else if(r.inputs[o]!==void 0)n.push(r.inputs[o].getValue(this.context_));else throw new Error("miss input for node ".concat(r.id));r.func(this.context_,n,r.outputValues)}}},{key:"run",value:function(t,i){if(this.graph_=t,this.context_=i,t.compiled)this.executeCompiledGraph();else{t.nodesInOrder.length=0,this.visited.clear();for(var n=0;n<t.outputNodes.length;n++){var r=t.outputNodes[n];this.traverse(r)}t.compiled=!0}}}]),s}();te(G0e,"Instance",void 0);var fi=function(){function s(e){It(this,s),te(this,"name",void 0),te(this,"nodeTypeSignatures",[]),this.name=e}return Mt(s,[{key:"addSignature",value:function(t,i,n){this.nodeTypeSignatures.push({inputTypes:t,outputTypes:i,func:n})}}]),s}(),HI=new fi("add");HI.addSignature([de.Number,de.Number],[de.Number],function(s,e,t,i){i[0]=t[0]+t[1]});HI.addSignature([de.Vec2,de.Vec2],[de.Vec2],function(s,e,t,i){i[0].addVectors(t[0],t[1])});HI.addSignature([de.Vec3,de.Vec3],[de.Vec3],function(s,e,t,i){i[0].addVectors(t[0],t[1])});HI.addSignature([de.Vec4,de.Vec4],[de.Vec4],function(s,e,t,i){i[0].addVectors(t[0],t[1])});var VI=new fi("sub");VI.addSignature([de.Number,de.Number],[de.Number],function(s,e,t,i){i[0]=t[0]-t[1]});VI.addSignature([de.Vec2,de.Vec2],[de.Vec2],function(s,e,t,i){i[0].subVectors(t[0],t[1])});VI.addSignature([de.Vec3,de.Vec3],[de.Vec3],function(s,e,t,i){i[0].subVectors(t[0],t[1])});VI.addSignature([de.Vec4,de.Vec4],[de.Vec4],function(s,e,t,i){i[0].subVectors(t[0],t[1])});var jI=new fi("mul");jI.addSignature([de.Number,de.Number],[de.Number],function(s,e,t,i){i[0]=t[0]*t[1]});jI.addSignature([de.Vec2,de.Number],[de.Vec2],function(s,e,t,i){i[0].copy(t[0]).multiplyScalar(t[1])});jI.addSignature([de.Vec3,de.Number],[de.Vec3],function(s,e,t,i){i[0].copy(t[0]).multiplyScalar(t[1])});jI.addSignature([de.Vec4,de.Number],[de.Vec4],function(s,e,t,i){i[0].copy(t[0]).multiplyScalar(t[1])});var WI=new fi("div");WI.addSignature([de.Number,de.Number],[de.Number],function(s,e,t,i){i[0]=t[0]/t[1]});WI.addSignature([de.Vec2,de.Number],[de.Vec2],function(s,e,t,i){i[0].copy(t[0]).divideScalar(t[1])});WI.addSignature([de.Vec3,de.Number],[de.Vec3],function(s,e,t,i){i[0].copy(t[0]).divideScalar(t[1])});WI.addSignature([de.Vec4,de.Number],[de.Vec4],function(s,e,t,i){i[0].copy(t[0]).divideScalar(t[1])});var H0e=new fi("sin");H0e.addSignature([de.Number],[de.Number],function(s,e,t,i){i[0]=Math.sin(t[0])});var V0e=new fi("cos");V0e.addSignature([de.Number],[de.Number],function(s,e,t,i){i[0]=Math.cos(t[0])});var j0e=new fi("tan");j0e.addSignature([de.Number],[de.Number],function(s,e,t,i){i[0]=Math.tan(t[0])});var W0e=new fi("abs");W0e.addSignature([de.Number],[de.Number],function(s,e,t,i){i[0]=Math.abs(t[0])});var q0e=new fi("min");q0e.addSignature([de.Number,de.Number],[de.Number],function(s,e,t,i){i[0]=Math.min(t[0],t[1])});var X0e=new fi("max");X0e.addSignature([de.Number,de.Number],[de.Number],function(s,e,t,i){i[0]=Math.max(t[0],t[1])});var IO=new fi("dot");IO.addSignature([de.Vec2,de.Vec2],[de.Number],function(s,e,t,i){i[0]=t[0].dot(t[1])});IO.addSignature([de.Vec3,de.Vec3],[de.Number],function(s,e,t,i){i[0]=t[0].dot(t[1])});IO.addSignature([de.Vec4,de.Vec4],[de.Number],function(s,e,t,i){i[0]=t[0].dot(t[1])});var Y0e=new fi("cross");Y0e.addSignature([de.Vec3,de.Vec3],[de.Vec3],function(s,e,t,i){i[0].crossVectors(t[0],t[1])});var MO=new fi("length");MO.addSignature([de.Vec2],[de.Number],function(s,e,t,i){i[0]=t[0].length()});MO.addSignature([de.Vec3],[de.Number],function(s,e,t,i){i[0]=t[0].length()});MO.addSignature([de.Vec4],[de.Number],function(s,e,t,i){i[0]=t[0].length()});var TO=new fi("lengthSq");TO.addSignature([de.Vec2],[de.Number],function(s,e,t,i){i[0]=t[0].lengthSq()});TO.addSignature([de.Vec3],[de.Number],function(s,e,t,i){i[0]=t[0].lengthSq()});TO.addSignature([de.Vec4],[de.Number],function(s,e,t,i){i[0]=t[0].lengthSq()});var BO=new fi("normalize");BO.addSignature([de.Vec2],[de.Vec2],function(s,e,t,i){i[0].copy(t[0]).normalize()});BO.addSignature([de.Vec3],[de.Vec3],function(s,e,t,i){i[0].copy(t[0]).normalize()});BO.addSignature([de.Vec4],[de.Vec4],function(s,e,t,i){i[0].copy(t[0]).normalize()});var Sj=new fi("distance");Sj.addSignature([de.Vec2,de.Vec2],[de.Number],function(s,e,t,i){i[0]=t[0].distanceTo(t[1])});Sj.addSignature([de.Vec3,de.Vec3],[de.Number],function(s,e,t,i){i[0]=t[0].distanceTo(t[1])});var J0e=new fi("and");J0e.addSignature([de.Boolean,de.Boolean],[de.Boolean],function(s,e,t,i){i[0]=t[0]&&t[1]});var K0e=new fi("or");K0e.addSignature([de.Boolean,de.Boolean],[de.Boolean],function(s,e,t,i){i[0]=t[0]||t[1]});var Z0e=new fi("not");Z0e.addSignature([de.Boolean],[de.Boolean],function(s,e,t,i){i[0]=!t[0]});var qI=new fi("equal");qI.addSignature([de.Number,de.Number],[de.Boolean],function(s,e,t,i){i[0]=t[0]===t[1]});qI.addSignature([de.Vec2,de.Vec2],[de.Boolean],function(s,e,t,i){i[0]=t[0].equals(t[1])});qI.addSignature([de.Vec3,de.Vec3],[de.Boolean],function(s,e,t,i){i[0]=t[0].equals(t[1])});qI.addSignature([de.Vec4,de.Vec4],[de.Boolean],function(s,e,t,i){i[0]=t[0].equals(t[1])});var $0e=new fi("lessThan");$0e.addSignature([de.Number,de.Number],[de.Boolean],function(s,e,t,i){i[0]=t[0]<t[1]});var eve=new fi("greaterThan");eve.addSignature([de.Number,de.Number],[de.Boolean],function(s,e,t,i){i[0]=t[0]>t[1]});var tve=new fi("lessThanOrEqual");tve.addSignature([de.Number,de.Number],[de.Boolean],function(s,e,t,i){i[0]=t[0]<=t[1]});var ive=new fi("greaterThanOrEqual");ive.addSignature([de.Number,de.Number],[de.Boolean],function(s,e,t,i){i[0]=t[0]>=t[1]});var nve=new fi("if");nve.addSignature([de.Boolean,de.AnyType,de.AnyType],[de.AnyType],function(s,e,t,i){i[0]=t[0]?t[1]:t[2]});var sve=new fi("number");sve.addSignature([],[de.Number],function(s,e,t,i){i[0]=e.value});var rve=new fi("vec2");rve.addSignature([],[de.Vec2],function(s,e,t,i){i[0]=e.value});var ove=new fi("vec3");ove.addSignature([],[de.Vec3],function(s,e,t,i){i[0]=e.value});var ave=new fi("vec4");ave.addSignature([],[de.Vec4],function(s,e,t,i){i[0]=e.value});var cve=new fi("bool");cve.addSignature([],[de.Boolean],function(s,e,t,i){i[0]=e.value});var lve=new fi("particlePosition");lve.addSignature([],[de.Vec3],function(s,e,t,i){i[0]=s.particle[e.property]});var hve=new fi("particleVelocity");hve.addSignature([],[de.Vec3],function(s,e,t,i){i[0]=s.particle[e.property]});var uve=new fi("particleRotation");uve.addSignature([],[de.Number],function(s,e,t,i){i[0]=s.particle[e.property]});var dve=new fi("particleAge");dve.addSignature([],[de.Number],function(s,e,t,i){i[0]=s.particle[e.property]});var p_=new fi("output");p_.addSignature([de.Number],[de.Number],function(s,e,t,i){i[0]=t[0]});p_.addSignature([de.Vec2],[de.Vec2],function(s,e,t,i){i[0]=t[0]});p_.addSignature([de.Vec3],[de.Vec3],function(s,e,t,i){i[0]=t[0]});p_.addSignature([de.Vec4],[de.Vec4],function(s,e,t,i){i[0]=t[0]});p_.addSignature([de.Boolean],[de.Boolean],function(s,e,t,i){i[0]=t[0]});console.log("%c Particle system powered by three.quarks. https://quarks.art/","font-size: 16px; font-weight: bold;");var fve=Object.defineProperty,pve=Object.getOwnPropertyDescriptor,Tn=(s,e,t,i)=>{for(var n=i>1?void 0:i?pve(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&fve(e,t,n),n};const I0=ie("debugparticles"),gve=ie("noprogressive"),mve=ie("debugprogressive");var GP=(s=>(s[s.Birth=0]="Birth",s[s.Collision=1]="Collision",s[s.Death=2]="Death",s[s.Trigger=3]="Trigger",s[s.Manual=4]="Manual",s))(GP||{});class Ja extends Te{constructor(){super(...arguments);d(this,"renderMode");d(this,"particleMaterial");d(this,"trailMaterial");d(this,"particleMesh");d(this,"maxParticleSize");d(this,"minParticleSize");d(this,"velocityScale");d(this,"cameraVelocityScale");d(this,"lengthScale")}start(){if(this.maxParticleSize!==.5&&this.minParticleSize!==0&&ht()){const t=`ParticleSystem "${this.name}" has non-default min/max particle size. This may not render correctly. Please set min size to 0 and the max size to 0.5 and use the "StartSize" setting instead`;console.warn(t)}}get transparent(){var i;return((i=this.particleMaterial)==null?void 0:i.transparent)??!1}getMaterial(t=!1){let i=t===!0&&this.trailMaterial?this.trailMaterial:this.particleMaterial;return i&&t&&i.side===ys&&(i=i.clone(),i.side=wn,t?this.trailMaterial=i:this.particleMaterial=i),i&&!gve&&i._didRequestTextureLOD===void 0&&(i._didRequestTextureLOD=0,mve&&console.log("Load material LOD",i.name),mi.assignTextureLOD(i,0)),i}getMesh(t){let i=null;if(!i&&(this.particleMesh instanceof pe&&(i=this.particleMesh.geometry),i===null)){i=new cs(1,1);const r=i.attributes.uv;for(let o=0;o<r.count;o++)r.setX(o,1-r.getX(o))}return new pe(i,this.getMaterial())}}Tn([x()],Ja.prototype,"renderMode",2);Tn([x(Ut)],Ja.prototype,"particleMaterial",2);Tn([x(Ut)],Ja.prototype,"trailMaterial",2);Tn([x()],Ja.prototype,"maxParticleSize",2);Tn([x()],Ja.prototype,"minParticleSize",2);Tn([x()],Ja.prototype,"velocityScale",2);Tn([x()],Ja.prototype,"cameraVelocityScale",2);Tn([x()],Ja.prototype,"lengthScale",2);class Nw{constructor(e,t=1){d(this,"_curve");d(this,"_factor");d(this,"type","function");this._curve=e,this._factor=t}genValue(e){return this._curve.evaluate(e,Math.random())*this._factor}toJSON(){throw new Error("Method not implemented.")}clone(){throw new Error("Method not implemented.")}}class RO{constructor(e){d(this,"type","value");d(this,"system");this.system=e}toJSON(){throw new Error("Method not implemented.")}clone(){throw new Error("Method not implemented.")}}class Ave extends RO{genValue(){return this.system.textureSheetAnimation.getStartIndex()}}class yve extends RO{constructor(){super(...arguments);d(this,"_lastPosition",new C);d(this,"_lastDistance",0)}update(){const t=Ot(this.system.gameObject);this._lastDistance=this._lastPosition.distanceTo(t),this._lastPosition.copy(t)}genValue(){if(!this.system.isPlaying||!this.system.emission.enabled||this.system.currentParticles>=this.system.maxParticles)return 0;let t=this.system.emission.rateOverTime.evaluate(this.system.time/this.system.duration,Math.random());if(this.system.deltaTime>0){const r=this.system.emission.rateOverDistance.evaluate(this.system.time/this.system.duration,Math.random());let a=this._lastDistance/this.system.deltaTime*r;Number.isFinite(a)||(a=0),t+=a}const i=this.system.emission.getBurst();i>0&&(t+=i/this.system.deltaTime);const n=this.system.maxParticles-this.system.currentParticles;return tt.clamp(t,0,n/this.system.deltaTime)}}class vve extends RO{genValue(){return this.system.isPlaying,0}}class kd{constructor(e){d(this,"system");d(this,"type");this.type=Object.getPrototypeOf(this).constructor.name||"ParticleSystemBaseBehaviour",e&&(this.system=e)}get context(){return this.system.context}initialize(e){}update(e,t){}frameUpdate(e){}toJSON(){throw new Error("Method not implemented.")}clone(){throw new Error("Method not implemented.")}reset(){}}class bve extends kd{constructor(){super(...arguments);d(this,"type","NeedleTextureSheet")}update(t,i){const n=this.system.textureSheetAnimation;if(n.enabled){const r=t.age/t.life,o=n.evaluate(r);o!==void 0&&(t.uvTile=o)}}}const Tz=Symbol("particleRotation");class _ve extends kd{constructor(){super(...arguments);d(this,"type","NeedleRotation")}initialize(t){t[Tz]=Math.random()}update(t,i){if(t.rotation===void 0)return;const n=t.age/t.life;if(typeof t.rotation=="number"&&(this.system.rotationOverLifetime.enabled?t.rotation+=this.system.rotationOverLifetime.evaluate(n,t[Tz])*i:this.system.renderer.renderMode===ph.Billboard&&(t.rotation=Math.PI),this.system.rotationBySpeed.enabled)){const r=t.velocity.length();t.rotation+=this.system.rotationBySpeed.evaluate(n,r)*i}}}const Bz=Symbol("sizeLerpFactor"),xve=new C;class wve extends kd{constructor(){super(...arguments);d(this,"type","NeedleSize");d(this,"_minSize",0);d(this,"_maxSize",1)}initialize(t){t[Bz]=Math.random(),this._minSize=this.system.renderer.minParticleSize,this._maxSize=this.system.renderer.maxParticleSize}update(t,i){const n=t.age/t.life;let r=1;this.system.sizeOverLifetime.enabled&&(r*=this.system.sizeOverLifetime.evaluate(n,void 0,t[Bz]).x);let o=1;if(this.system.renderer.renderMode!==ph.Mesh&&(o=this.system.worldScale.x/this.system.cameraScale),t.size=t.startSize*r*o,this.system.localspace){const a=Ej(this.system,xve);t.size*=a.x}}}const Im=Symbol("particleLife"),$T=Symbol("trailLifetime"),Rz=Symbol("trailStartLength"),eB=Symbol("trailWidthRandom");class Cve extends kd{constructor(){super(...arguments);d(this,"type","NeedleTrail")}initialize(t){t instanceof eb&&(t[Im]=t.life,this.system.trails.enabled&&this.system.trails.dieWithParticles===!1&&(t[$T]=this.system.trails.lifetime.evaluate(Math.random(),Math.random()),t.life+=t[$T]),t[Rz]=t.length,t[eB]=Math.random())}update(t){var i;if((i=this.system.trails)!=null&&i.enabled&&t instanceof eb){const n=t,r=t.age/t[Im],o=t.previous.values(),a=t.previous.length;for(let c=0;c<a;c++){const h=o.next().value,u=1-c/(a-1);let f=t.size;f<=0&&!this.system.trails.sizeAffectsWidth&&(f=20*this.system.trails.widthOverTrail.evaluate(.5,n[eB])),h.size=this.system.trails.getWidth(f,r,u,n[eB]),h.color.copy(t.color),this.system.trails.getColor(h.color,r,u)}if(t.age>t[Im]){t.velocity.set(0,0,0);const c=(t.age-t[Im])/t[$T];n.length=tt.lerp(t[Rz],0,c)}}}}const Qw=Symbol("startVelocity"),Pz=Symbol("gravityModifier"),tB=Symbol("gravitySpeed"),zw=Symbol("velocity lerp factor"),HP=new C;class Sve extends kd{constructor(){super(...arguments);d(this,"type","NeedleVelocity");d(this,"_gravityDirection",new C)}initialize(t){var r,o;const i=this.system.main.simulationSpeed;t.startSpeed=this.system.main.startSpeed.evaluate(Math.random(),Math.random()),t.velocity.copy(this.system.shape.getDirection(t,t.position)).multiplyScalar(t.startSpeed),(r=this.system.inheritVelocity)!=null&&r.enabled&&this.system.inheritVelocity.applyInitial(t.velocity),t[Qw]?t[Qw].copy(t.velocity):t[Qw]=t.velocity.clone();const n=this.system.main.gravityModifier.evaluate(Math.random(),Math.random());t[Pz]=n*i,t[tB]=n*i*.5,t[zw]=Math.random(),(o=this.system.velocityOverLifetime)==null||o.init(t),this._gravityDirection.set(0,-1,0),this.system.main.simulationSpace===Kv.Local&&this._gravityDirection.applyQuaternion(this.system.worldQuaternionInverted).normalize()}update(t,i){var f;const n=t[Qw],r=t[Pz];if(r!==0){const p=r*t[tB];HP.copy(this._gravityDirection).multiplyScalar(p),t[tB]+=i*.05,n.add(HP)}t.velocity.copy(n);const o=t.age/t.life;(f=this.system.inheritVelocity)!=null&&f.enabled&&this.system.inheritVelocity.applyCurrent(t.velocity,o,t[zw]);const a=this.system.noise;a.enabled&&a.apply(0,t.position,t.velocity,i,t.age,t.life);const c=this.system.sizeBySpeed;c!=null&&c.enabled&&(t.size=c.evaluate(t.velocity,o,t[zw],t.size));const l=this.system.colorBySpeed;l!=null&&l.enabled&&l.evaluate(t.velocity,t[zw],t.color);const h=this.system.velocityOverLifetime;h.enabled&&h.apply(t,0,t.position,t.velocity,i,t.age,t.life);const u=this.system.limitVelocityOverLifetime;u.enabled&&u.apply(t.position,n,t.velocity,t.size,o,i,1),this.system.worldspace&&t.velocity.multiply(this.system.worldScale)}}const Dz=Symbol("colorLerpFactor"),kz=new Ei(1,1,1,1),hf=new Ei(1,1,1,1);class Eve extends kd{constructor(){super(...arguments);d(this,"type","NeedleColor")}initialize(t){}_init(t){const i=this.system.renderer.particleMaterial;hf.copy(this.system.main.startColor.evaluate(Math.random())),i!=null&&i.color&&(kz.copy(i.color),hf.multiply(kz)),hf.convertLinearToSRGB(),t.startColor.set(hf.r,hf.g,hf.b,hf.alpha),t.color.copy(t.startColor),t[Dz]=Math.random()}update(t,i){if(t.age===0&&this._init(t),this.system.colorOverLifetime.enabled){const n=t.age/t.life,r=this.system.colorOverLifetime.color.evaluate(n,t[Dz]);t.color.set(r.r,r.g,r.b,r.alpha).multiply(t.startColor)}else t.color.copy(t.startColor)}}class Ive{constructor(e){d(this,"system");d(this,"emission");d(this,"autoDestroy");d(this,"startLength");d(this,"emissionBursts");d(this,"onlyUsedByOther");d(this,"behaviors",[]);d(this,"rendererEmitterSettings",{startLength:new wr(220),followLocalOrigin:!1});d(this,"flatWhiteTexture");d(this,"clonedTexture",{original:void 0,clone:void 0});this.system=e,this.emission=new yve(this.system)}get anim(){return this.system.textureSheetAnimation}get prewarm(){return!1}get material(){return this.system.renderer.getMaterial(this.system.trails.enabled)}get layers(){return this.system.gameObject.layers}update(){this.emission.update()}get looping(){return this.system.main.loop}get duration(){return this.system.duration}get shape(){return this.system.shape}get startLife(){return new Nw(this.system.main.startLifetime)}get startSpeed(){return new Nw(this.system.main.startSpeed)}get startRotation(){return new Nw(this.system.main.startRotation)}get startSize(){return new Nw(this.system.main.startSize)}get startColor(){return new kS(new Ke(1,1,1,1))}get emissionOverTime(){return this.emission}get emissionOverDistance(){return new vve(this.system)}get instancingGeometry(){return this.system.renderer.getMesh(this.system.renderer.renderMode).geometry}get renderMode(){if(this.system.trails.enabled===!0)return at.Trail;switch(this.system.renderer.renderMode){case ph.Billboard:return at.BillBoard;case ph.Stretch:return at.StretchedBillBoard;case ph.HorizontalBillboard:return at.HorizontalBillBoard;case ph.VerticalBillboard:return at.VerticalBillBoard;case ph.Mesh:return at.Mesh}return at.BillBoard}get speedFactor(){var t;let e=this.system.main.simulationSpeed;return((t=this.system.renderer)==null?void 0:t.renderMode)===ph.Stretch&&(e*=this.system.renderer.velocityScale??1),e}get texture(){const e=this.material;if(e&&e.map){const t=e.map;if(this.clonedTexture.original!==t||!this.clonedTexture.clone){const i=t.clone();i.premultiplyAlpha=!1,i.colorSpace=Ii,this.clonedTexture.original=t,this.clonedTexture.clone=i}return this.clonedTexture.clone}return this.flatWhiteTexture||(this.flatWhiteTexture=Bk(new Ei(1,1,1,1),1)),this.flatWhiteTexture}get startTileIndex(){return new Ave(this.system)}get uTileCount(){var e;return this.anim.enabled?(e=this.anim)==null?void 0:e.numTilesX:void 0}get vTileCount(){var e;return this.anim.enabled?(e=this.anim)==null?void 0:e.numTilesY:void 0}get renderOrder(){return 1}get blending(){var e;return((e=this.system.renderer.particleMaterial)==null?void 0:e.blending)??Ju}get transparent(){return this.system.renderer.transparent}get worldSpace(){return this.system.main.simulationSpace===Kv.World}}class Mve{constructor(){d(this,"burstIndex",0);d(this,"burstWaveIndex",0);d(this,"time",0);d(this,"waitEmiting",0)}}const PC=class extends Te{constructor(){super(...arguments);d(this,"_state");d(this,"colorOverLifetime");d(this,"main");d(this,"emission");d(this,"sizeOverLifetime");d(this,"shape");d(this,"noise");d(this,"trails");d(this,"velocityOverLifetime");d(this,"limitVelocityOverLifetime");d(this,"inheritVelocity");d(this,"colorBySpeed");d(this,"textureSheetAnimation");d(this,"rotationOverLifetime");d(this,"rotationBySpeed");d(this,"sizeBySpeed");d(this,"_cameraScale",1);d(this,"__worldQuaternion",new Se);d(this,"_worldQuaternionInverted",new Se);d(this,"_worldScale",new C);d(this,"_worldPositionFrame",-1);d(this,"_worldPos",new C);d(this,"_renderer");d(this,"_batchSystem");d(this,"_particleSystem");d(this,"_interface");d(this,"_container");d(this,"_time",0);d(this,"_isPlaying",!0);d(this,"_isUsedAsSubsystem",!1);d(this,"_didPreWarm",!1);d(this,"_bursts");d(this,"_subEmitterSystems");d(this,"_lastBatchesCount",-1);d(this,"lastMaterialVersion",-1)}play(e=!1){var t;e&&re.foreachComponent(this.gameObject,i=>{i instanceof PC&&i!==this&&i.play(!1)},!0),this._isPlaying=!0,this._particleSystem&&(this._particleSystem.emissionState.time=0,this._particleSystem.emitEnded=!1),(t=this.emission)==null||t.reset()}pause(e=!0){e&&re.foreachComponent(this.gameObject,t=>{t instanceof PC&&t!==this&&t.pause(!1)},!0),this._isPlaying=!1}stop(e=!0,t=!1){e&&re.foreachComponent(this.gameObject,i=>{i instanceof PC&&i!==this&&i.stop(!1,t)},!0),this._isPlaying=!1,this._time=0,t&&this.reset()}reset(){var e;this._time=0,this._particleSystem&&(this._particleSystem.particleNum=0,this._particleSystem.emissionState.time=0,this._particleSystem.emitEnded=!1,(e=this.emission)==null||e.reset())}emit(e){if(this._particleSystem){this.onUpdate(),e=Math.min(e,this.maxParticles-this.currentParticles),this._state||(this._state=new Mve),this._state.waitEmiting=e,this._state.time=0;const t=this._particleSystem.emitEnded;this._particleSystem.emitEnded=!1,this._particleSystem.emit(this.deltaTime,this._state,this._particleSystem.emitter.matrixWorld),this._particleSystem.emitEnded=t}}get playOnAwake(){return this.main.playOnAwake}set playOnAwake(e){this.main.playOnAwake=e}get renderer(){return this._renderer}get isPlaying(){return this._isPlaying}get currentParticles(){var e;return((e=this._particleSystem)==null?void 0:e.particleNum)??0}get maxParticles(){return this.main.maxParticles}get time(){return this._time}get duration(){return this.main.duration}get deltaTime(){return this.context.time.deltaTime*this.main.simulationSpeed}get scale(){return this.gameObject.scale.x}get cameraScale(){return this._cameraScale}get container(){return this._container}get worldspace(){return this.main.simulationSpace===Kv.World}get localspace(){return this.main.simulationSpace===Kv.Local}get worldQuaternion(){return this.__worldQuaternion}get worldQuaternionInverted(){return this._worldQuaternionInverted}get worldScale(){return this._worldScale}get worldPos(){return this._worldPositionFrame!==this.context.time.frame&&(this._worldPositionFrame=this.context.time.frame,Ot(this.gameObject,this._worldPos)),this._worldPos}get matrixWorld(){return this._container.matrixWorld}get isSubsystem(){return this._isUsedAsSubsystem}addBehaviour(e){return this._particleSystem?(e instanceof kd&&(e.system=this),ht()&&console.log("add behaviour",e),this._particleSystem.addBehavior(e),!0):!1}removeBehaviour(e){if(!this._particleSystem)return!1;const t=this._particleSystem.behaviors,i=t.indexOf(e);return i!==-1&&t.splice(i,1),!0}removeAllBehaviours(){return this._particleSystem?(this._particleSystem.behaviors.length=0,!0):!1}get behaviours(){return this._particleSystem?this._particleSystem.behaviors:null}get particleSystem(){return this._particleSystem??null}set bursts(e){for(let t=0;t<e.length;t++){const i=e[t];if(!(i instanceof Zv)){const n=new Zv;lA(n,i),e[t]=n}}this._bursts=e}set subEmitterSystems(e){for(let t=0;t<e.length;t++){const i=e[t];if(!(i instanceof nb)){const n=new nb;lA(n,i),e[t]=n}}I0&&e.length>0&&console.log("SubEmitters: ",e,this),this._subEmitterSystems=e}onAfterDeserialize(e){if(this._subEmitterSystems&&Array.isArray(this._subEmitterSystems))for(const t of this._subEmitterSystems)t._deserialize(this.context,this.gameObject)}awake(){if(this._worldPositionFrame=-1,this._renderer=this.gameObject.getComponent(Ja),!this.main)throw new Error("Not Supported: ParticleSystem needs a serialized MainModule. Creating new particle systems at runtime is currently not supported.");this._container=new ye,this._container.matrixAutoUpdate=!1,this.context.scene.add(this._container),this._batchSystem=new N0e,this._batchSystem.name=this.gameObject.name,this._container.add(this._batchSystem),this._interface=new Ive(this),this._particleSystem=new M0e(this._interface),this._particleSystem.addBehavior(new wve(this)),this._particleSystem.addBehavior(new Eve(this)),this._particleSystem.addBehavior(new bve(this)),this._particleSystem.addBehavior(new _ve(this)),this._particleSystem.addBehavior(new Sve(this)),this._particleSystem.addBehavior(new Cve(this)),this._batchSystem.addSystem(this._particleSystem);const e=this._particleSystem.emitter;this.context.scene.add(e),this.inheritVelocity.system&&this.inheritVelocity.system!==this&&(this.inheritVelocity=this.inheritVelocity.clone()),this.inheritVelocity.awake(this),I0&&(console.log(this),this.gameObject.add(new ta(1)))}start(){this.addSubParticleSystems(),this.updateLayers(),this.renderer.particleMesh instanceof pe&&this._interface.renderMode==at.Mesh&&mi.assignMeshLOD(this.renderer.particleMesh,0).then(e=>{e&&this.particleSystem&&this._interface.renderMode==at.Mesh&&(this.particleSystem.instancingGeometry=e)})}onDestroy(){var e,t,i,n;(e=this._container)==null||e.removeFromParent(),(t=this._batchSystem)==null||t.removeFromParent(),(i=this._particleSystem)==null||i.emitter.removeFromParent(),(n=this._particleSystem)==null||n.dispose()}onEnable(){this.main&&(this.inheritVelocity&&(this.inheritVelocity.system=this),this._batchSystem&&(this._batchSystem.visible=!0),this.playOnAwake&&this.play(),this._isPlaying=this.playOnAwake)}onDisable(){this._batchSystem&&(this._batchSystem.visible=!1)}onBeforeRender(){var e;this.main&&(this._didPreWarm===!1&&((e=this.main)==null?void 0:e.prewarm)===!0&&(this._didPreWarm=!0,this.preWarm()),this.onUpdate(),this.onSimulate(this.deltaTime))}preWarm(){var l;if(!((l=this.emission)!=null&&l.enabled)||this.emission.rateOverTime.getMax()<=0)return;const t=1/60,i=this.main.duration,n=this.main.startLifetime.getMax(),r=1e3,o=Math.min(Math.max(i,n)/Math.max(.01,this.main.simulationSpeed),r),a=Math.ceil(o/t),c=Date.now();I0&&console.log(`Particles ${this.name} - Prewarm for ${a} frames (${o} sec). Duration: ${i}, Lifetime: ${n}`);for(let h=0;h<a&&!(this.currentParticles>=this.maxParticles);h++){const u=Date.now()-c;if(u>2e3){console.warn(`Particles ${this.name} - Prewarm took too long. Aborting: ${u}`);break}this.onUpdate(),this.onSimulate(t)}}onSimulate(e){if(this._batchSystem){let t=this.context.time.frameCount%60===0;this._lastBatchesCount!==this._batchSystem.batches.length&&(this._lastBatchesCount=this._batchSystem.batches.length,t=!0),t&&this.updateLayers(),this._batchSystem.update(e)}this._time+=e,this._time>this.duration&&(this._time=0)}updateLayers(){if(this._batchSystem)for(let e=0;e<this._batchSystem.batches.length;e++){const t=this._batchSystem.batches[e];t.layers.disableAll();const i=this.layer;t.layers.mask=1<<i}}onUpdate(){var r,o;const e=this.renderer.getMaterial(this.trails.enabled);if(e&&e.version!=this.lastMaterialVersion&&this._particleSystem&&(this.lastMaterialVersion=e.version,this._particleSystem.texture=this._interface.texture),this._bursts&&(this.emission.bursts=this._bursts,delete this._bursts),!this._isPlaying)return;const t=this.context.mainCamera;if(t){const a=Ji(t);this._cameraScale=a.x}const i=!this.worldspace,n=this.gameObject;if(Fi(n,this.__worldQuaternion),this._worldQuaternionInverted.copy(this.__worldQuaternion).invert(),Ji(this.gameObject,this._worldScale),i&&this._container&&((r=this.gameObject)!=null&&r.parent)){const a=Ej(this,HP);this._container.matrix.makeScale(a.x,a.y,a.z),this._container.matrix.makeRotationFromQuaternion(this.__worldQuaternion),this._container.matrix.setPosition(this.worldPos),this._container.matrix.scale(this.gameObject.scale)}this.emission.system=this,this._interface.update(),this.shape.update(this,this.context,this.main.simulationSpace,this.gameObject),this.noise.update(this.context),(o=this.inheritVelocity)==null||o.update(this.context),this.velocityOverLifetime.update(this)}addSubParticleSystems(){var e;if(this._subEmitterSystems&&this._particleSystem)for(const t of this._subEmitterSystems){t.particleSystem&&(t.particleSystem.__internalAwake?t.particleSystem.__internalAwake():ht()&&console.warn("SubParticleSystem serialization issue(?)",t.particleSystem,t));const i=(e=t.particleSystem)==null?void 0:e._particleSystem;if(i){t.particleSystem._isUsedAsSubsystem=!0;const n=new XI(this,this._particleSystem,t.particleSystem,i);n.emitterType=t.type,n.emitterProbability=t.emitProbability,this._particleSystem.addBehavior(n)}else I0&&console.warn("Could not add SubParticleSystem",t,this)}}};let as=PC;Tn([x(s_)],as.prototype,"colorOverLifetime",2);Tn([x(dr)],as.prototype,"main",2);Tn([x(Rl)],as.prototype,"emission",2);Tn([x(Bd)],as.prototype,"sizeOverLifetime",2);Tn([x(In)],as.prototype,"shape",2);Tn([x(Di)],as.prototype,"noise",2);Tn([x(yn)],as.prototype,"trails",2);Tn([x(Mn)],as.prototype,"velocityOverLifetime",2);Tn([x(us)],as.prototype,"limitVelocityOverLifetime",2);Tn([x(Rd)],as.prototype,"inheritVelocity",2);Tn([x(Gp)],as.prototype,"colorBySpeed",2);Tn([x(fr)],as.prototype,"textureSheetAnimation",2);Tn([x(Xa)],as.prototype,"rotationOverLifetime",2);Tn([x(ca)],as.prototype,"rotationBySpeed",2);Tn([x(co)],as.prototype,"sizeBySpeed",2);class nb{constructor(){d(this,"particleSystem");d(this,"emitProbability",1);d(this,"properties");d(this,"type")}_deserialize(e,t){const i=this.particleSystem;if(i instanceof as)return;let n="";i&&typeof i.guid=="string"&&(n=i.guid,this.particleSystem=re.findByGuid(n,t)),I0&&!(this.particleSystem instanceof as)&&console.warn("Could not find particle system for sub emitter",n,t,this)}}function Ej(s,e){if(e.set(1,1,1),s.gameObject.parent&&s.localspace)switch(s.main.scalingMode){case RP.Local:e=Ji(s.gameObject.parent,e),e.x=1/e.x,e.y=1/e.y,e.z=1/e.z;break;default:if(!s.unsupported_scaling_mode){s.unsupported_scaling_mode=!0;const t="ParticleSystem scale mode "+RP[s.main.scalingMode]+" is not supported";ht()&&Ni(t),console.warn(t,s.name,s)}e=Ji(s.gameObject,e);break}return e}new C(1,1,1);new C(0,0,1);class XI{constructor(e,t,i,n){d(this,"type","NeedleParticleSubEmitter");d(this,"emitterType");d(this,"emitterProbability");d(this,"q_",new Se);d(this,"v_",new C);d(this,"v2_",new C);d(this,"_emitterMatrix",new Ae);d(this,"_circularBuffer");this.system=e,this.particleSystem=t,this.subSystem=i,this.subParticleSystem=n,this.subParticleSystem&&this.subParticleSystem&&(this.subParticleSystem.onlyUsedByOther=!0);const r=1e3;this._circularBuffer=new Ua(()=>new Ae,r)}clone(){throw new Error("Method not implemented.")}initialize(e){e.emissionState={burstIndex:0,burstWaveIndex:0,time:0,waitEmiting:0},this._emitterMatrix.copy(this.subSystem.matrixWorld).invert().premultiply(this.system.matrixWorld),this._emitterMatrix.setPosition(0,0,0),this.emitterType===GP.Birth&&this.run(e)}update(e,t){this.run(e)}frameUpdate(e){}toJSON(){}reset(){}run(e){if(this.subSystem.currentParticles>=this.subSystem.main.maxParticles||!this.subParticleSystem||!e.emissionState||this.emitterProbability&&Math.random()>this.emitterProbability)return;const t=this.system.deltaTime;if(this.emitterType===GP.Death){let n=e.life;if(e[Im]!==void 0&&(n=e[Im]),!(e.age+t*1.2>=n))return;const o=this.subSystem.main.maxParticles-this.subSystem.currentParticles;e.emissionState.waitEmiting=o}const i=new Ae;i.set(1,0,0,e.position.x,0,1,0,e.position.y,0,0,1,e.position.z,0,0,0,1),this.particleSystem.worldSpace||i.multiplyMatrices(this._emitterMatrix,i),this.subParticleSystem.emit(t,e.emissionState,i)}}var Tve=Object.defineProperty,Bve=Object.getOwnPropertyDescriptor,Rve=(s,e,t,i)=>{for(var n=i>1?void 0:i?Bve(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Tve(e,t,n),n};class g_ extends kr{constructor(){super(...arguments);d(this,"granularity")}get typeName(){return"PixelationEffect"}onCreateEffect(){const t=new x5;return this.granularity.onValueChanged=i=>{t.granularity=i},t}}Rve([x(Lt)],g_.prototype,"granularity",2);qa("PixelationEffect",g_);class fA extends Te{constructor(){super(...arguments);d(this,"_didAssignPlayerColor",!1);d(this,"tryAssignColor",()=>{const t=re.getComponentInParent(this.gameObject,Oa);if(t&&t.owner)return this._didAssignPlayerColor=!0,this.assignUserColor(t.owner),!0;const i=re.getComponentInParent(this.gameObject,As);return i!=null&&i.connectionId?(this._didAssignPlayerColor=!0,this.assignUserColor(i.connectionId),!0):!1})}onEnable(){this.context.connection.beginListen(Jt.JoinedRoom,this.tryAssignColor),this._didAssignPlayerColor||this.startCoroutine(this.waitForConnection())}onDisable(){this.context.connection.stopListen(Jt.JoinedRoom,this.tryAssignColor)}*waitForConnection(){for(;!this.destroyed&&this.activeAndEnabled&&(yield G9(.2),!this.tryAssignColor()););}assignUserColor(t){const i=fA.hashCode(t),n=fA.colorFromHashCode(i);if(this.gameObject.type==="Mesh"){const r=this.gameObject;this.assignColor(n,t,r)}else if(this.gameObject.children)for(const r of this.gameObject.children){const o=r;o.material&&o.material.color&&this.assignColor(n,t,o)}}assignColor(t,i,n){let r=n.material;r&&(r._playerMaterial!==i&&(r=r.clone(),r._playerMaterial=i,n.material=r),r.color=t)}static hashCode(t){var i=0,n,r;if(t.length===0)return i;for(n=0;n<t.length;n++)r=t.charCodeAt(n),i=(i<<5)-i+r,i|=0;return i}static colorFromHashCode(t){const i=(t&16711680)>>16,n=(t&65280)>>8,r=t&255;return new ve(i/255,n/255,r/255)}}async function PO(s){const{NeedleEngineHTMLElement:e}=await Promise.resolve().then(()=>h_e);e.observedAttributes.includes(s)||e.observedAttributes.push(s)}var Pve=Object.defineProperty,Dve=Object.getOwnPropertyDescriptor,m_=(s,e,t,i)=>{for(var n=i>1?void 0:i?Dve(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Pve(e,t,n),n};const Ma=ie("debugskybox");PO("skybox-image");PO("environment-image");function Oz(s,e,t,i,n){const r=new Cl;r.allowDrop=!1,r.allowNetworking=!1,r.background=t,r.environment=i,re.addComponent(s.scene,r);const o=a=>{typeof a=="string"&&(Ma&&console.log(n,"CHANGED TO",a),r.setSkybox(a))};return mH(s.domElement,n,o),r.addEventListener("destroy",()=>{Ma&&console.log("Destroyed attribute remote skybox",n),AH(s.domElement,n,o)}),r.setSkybox(e)}ui.addContextCreatedCallback(s=>{var r;const e=s.context,t=e.domElement.getAttribute("skybox-image"),i=e.domElement.getAttribute("environment-image"),n=new Array;if(t){Ma&&console.log("Creating remote skybox to load "+t),((r=e.mainCameraComponent)==null?void 0:r.clearFlags)!==vp.Skybox&&console.warn('"skybox-image" attribute has no effect: camera clearflags are not set to "Skybox"');const o=Oz(e,t,!0,!1,"skybox-image");n.push(o)}if(i){Ma&&console.log("Creating remote environment to load "+i);const o=Oz(e,i,!1,!0,"environment-image");n.push(o)}return n.length>0?kE(n):Promise.resolve()});function Ij(){return globalThis.NEEDLE_ENGINE_SKYBOX_TEXTURES||(globalThis.NEEDLE_ENGINE_SKYBOX_TEXTURES=new Array),globalThis.NEEDLE_ENGINE_SKYBOX_TEXTURES}function Lz(s){const t=Ij().find(i=>i.src===s);return t?(Ma&&console.log("Skybox: Found previously loaded texture for "+s),t.texture):null}async function kve(s){const e=await s;rk(e,!0),Wi(e)}function Ove(s,e){const t=Ij();for(;t.length>5;){const i=t.shift();i&&kve(i.texture)}e.then(i=>rk(i,!1)),t.push({src:s,texture:e})}class Cl extends Te{constructor(){super(...arguments);d(this,"url");d(this,"allowDrop",!0);d(this,"background",!0);d(this,"environment",!0);d(this,"allowNetworking",!0);d(this,"_loader");d(this,"_prevUrl");d(this,"_prevLoadedEnvironment");d(this,"_prevEnvironment",null);d(this,"_prevBackground",null);d(this,"validTextureTypes",[".hdr",".exr",".jpg",".jpeg",".png"]);d(this,"onDragOverEvent",t=>{if(this.allowDrop&&t.dataTransfer)for(const i of t.dataTransfer.types)(i==="text/uri-list"||i==="Files")&&t.preventDefault()});d(this,"onDrop",t=>{var i,n,r,o;if(this.allowDrop&&t.dataTransfer){for(const a of t.dataTransfer.types)if(Ma&&console.log(a),a==="text/uri-list"){const c=t.dataTransfer.getData(a);Ma&&console.log(a,c);let l=(n=(i=new RegExp(/polyhaven.com\/asset_img\/.+?\/(?<name>.+)\.png/).exec(c))==null?void 0:i.groups)==null?void 0:n.name;if(l||(l=(o=(r=new RegExp(/polyhaven\.com\/a\/(?<name>.+)/).exec(c))==null?void 0:r.groups)==null?void 0:o.name),Ma&&console.log(l),l){const h="https://dl.polyhaven.org/file/ph-assets/HDRIs/exr/1k/"+l+"_1k.exr";console.log(`[Remote Skybox] Setting skybox from url: ${h}`),t.preventDefault(),this.setSkybox(h);break}else if(this.isValidTextureType(c)){console.log("[Remote Skybox] Setting skybox from url: "+c),t.preventDefault(),this.setSkybox(c);break}else{console.warn(`[RemoteSkybox] Unknown url ${c}. 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 h=new CustomEvent("dropped-unknown-url",{detail:{sender:this,event:t,url:c,apply:u=>{t.preventDefault(),this.setSkybox(u)}}});this.dispatchEvent(h)}}else if(a=="Files"){const c=t.dataTransfer.files.item(0);if(Ma&&console.log(a,c),!c)continue;if(!this.isValidTextureType(c.name)){console.warn(`[RemoteSkybox]: File "${c.name}" is not supported. Supported files are ${this.validTextureTypes.join(", ")}`);return}if(Lz(c.name)===null){const l=new Blob([c]),h=URL.createObjectURL(l);t.preventDefault(),this.setSkybox(h,c.name)}else t.preventDefault(),this.setSkybox(c.name);break}}})}onEnable(){this.setSkybox(this.url),this.registerDropEvents()}onDisable(){var t;this.context.scene.environment===this._prevLoadedEnvironment&&(this.context.scene.environment=this._prevEnvironment,Vi.backgroundShouldBeTransparent(this.context)||(this.context.scene.background=this._prevBackground),this._prevLoadedEnvironment=void 0),this.unregisterDropEvents(),(t=this.context.mainCameraComponent)==null||t.applyClearFlags()}urlChangedSyncField(){this.allowNetworking&&this.url&&this.isRemoteTexture(this.url)&&this.setSkybox(this.url)}async setSkybox(t,i){var o;if(!this.activeAndEnabled||(t=Lve(t),!t))return!1;if(i??(i=t),this.isValidTextureType(i)||console.warn("Potentially invalid skybox url",i,"on",this.name),Ma&&console.log("Set remote skybox url: "+t),this._prevUrl===t&&this._prevLoadedEnvironment)return this.applySkybox(),!0;(o=this._prevLoadedEnvironment)==null||o.dispose(),this._prevLoadedEnvironment=void 0,this._prevUrl=t;const n=await this.loadTexture(t,i);if(!n||!this.enabled)return!1;this.url=t;const r=t.lastIndexOf("/");return n.name=t.substring(r>=0?r+1:0),this._loader instanceof fl&&(n.colorSpace=gt),this._prevLoadedEnvironment=n,this.applySkybox(),!0}async loadTexture(t,i){var l,h,u,f,p;if(!t)return Promise.resolve(null);i??(i=t);const n=Lz(i);if(n){const g=await n;if(((h=(l=g.source)==null?void 0:l.data)==null?void 0:h.length)>0||(p=(f=(u=g.source)==null?void 0:u.data)==null?void 0:f.data)!=null&&p.length)return g}const r=i.endsWith(".exr"),o=i.endsWith(".hdr");r?this._loader instanceof Hv||(this._loader=new Hv):o?this._loader instanceof wS||(this._loader=new wS):this._loader instanceof fl||(this._loader=new fl),Ma&&console.log("Loading skybox: "+t);const a=this._loader.loadAsync(t);return Ove(i,a),await a}applySkybox(){var i;const t=this._prevLoadedEnvironment;t&&(t.mapping=Jm,t.needsUpdate=!0,this.context.scene.background!==t&&(this._prevBackground=this.context.scene.background),this.context.scene.environment!==t&&(this._prevEnvironment=this.context.scene.environment),Ma&&console.log("Set remote skybox",this.url,!Vi.backgroundShouldBeTransparent(this.context)),this.environment&&(this.context.scene.environment=t),this.background&&!Vi.backgroundShouldBeTransparent(this.context)&&(this.context.scene.background=t),((i=this.context.mainCameraComponent)==null?void 0:i.backgroundBlurriness)!==void 0&&(this.context.scene.backgroundBlurriness=this.context.mainCameraComponent.backgroundBlurriness))}isRemoteTexture(t){return t.startsWith("http://")||t.startsWith("https://")}isValidTextureType(t){for(const i of this.validTextureTypes)if(t.endsWith(i))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)}}m_([Qk(Cl.prototype.urlChangedSyncField),x(URL)],Cl.prototype,"url",2);m_([x()],Cl.prototype,"allowDrop",2);m_([x()],Cl.prototype,"background",2);m_([x()],Cl.prototype,"environment",2);m_([x()],Cl.prototype,"allowNetworking",2);function Lve(s){switch(s==null?void 0:s.toLowerCase()){case"studio":s="https://cdn.needle.tools/static/skybox/modelviewer-Neutral.hdr";break;case"blurred-skybox":s="https://cdn.needle.tools/static/skybox/blurred-skybox.exr";break;case"quicklook-ar":s="https://cdn.needle.tools/static/skybox/QuickLook-ARMode.exr";break;case"quicklook":s="https://cdn.needle.tools/static/skybox/QuickLook-ObjectMode.exr";break}return s===void 0?null:s}var Fve=Object.defineProperty,Uve=Object.getOwnPropertyDescriptor,la=(s,e,t,i)=>{for(var n=i>1?void 0:i?Uve(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Fve(e,t,n),n};const Vo=ie("debugsceneswitcher"),DC="scene";PO(DC);const Su=Promise.resolve(!1);class Ur extends Te{constructor(){super(...arguments);d(this,"autoLoadFirstScene",!0);d(this,"scenes",[]);d(this,"loadingScene");d(this,"queryParameterName","scene");d(this,"useSceneName",!0);d(this,"clamp",!0);d(this,"useHistory",!0);d(this,"useKeyboard",!0);d(this,"useSwipe",!0);d(this,"useSceneLighting",!0);d(this,"preloadNext",1);d(this,"preloadPrevious",1);d(this,"preloadConcurrent",2);d(this,"_currentIndex",-1);d(this,"_currentScene");d(this,"_engineElementOverserver");d(this,"_preloadScheduler");d(this,"onPopState",async t=>{if(!this.useHistory)return;const i=this.useHistory;try{this.useHistory=!1;let n=!1;if(this.queryParameterName&&(n=await this.tryLoadFromQueryParam()),!n){const r=t==null?void 0:t.state;if(r&&r.startsWith(this.guid)){const o=r.substr(this.guid.length+2);Vo&&console.log("PopState",o),await this.trySelectSceneFromValue(o)}}}finally{this.useHistory=i}});d(this,"normalizedSwipeThresholdX",.1);d(this,"_didSwipe",!1);d(this,"onInputPointerMove",t=>{if(this.useSwipe&&!this._didSwipe&&t.button===0&&t.pointerType==="touch"&&this.context.input.getPointerPressedCount()===1){const i=this.context.input.getPointerPositionDelta(t.button);if(i){const n=i.x/this.context.domWidth;n>=this.normalizedSwipeThresholdX?(this._didSwipe=!0,this.selectPrev()):n<=-this.normalizedSwipeThresholdX&&(this._didSwipe=!0,this.selectNext())}}});d(this,"onInputPointerUp",t=>{t.button===0&&(this._didSwipe=!1)});d(this,"onInputKeyDown",t=>{if(!this.useKeyboard||!this.scenes)return;const i=t.key.toLowerCase();if(!i)return;const n=parseInt(i)-1;if(n>=0){this.trySelectSceneFromValue(n);return}switch(i){case"arrowright":case"d":this.selectNext();break;case"arrowleft":case"a":this.selectPrev();break}});d(this,"__lastSwitchScene");d(this,"__lastSwitchScenePromise");d(this,"_currentlyLoadingScene");d(this,"_lastLoadingScene");d(this,"_loadingScenePromise");d(this,"_isCurrentlyLoading",!1);d(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=[]),Vo&&console.log("SceneSwitcher",this)}async onEnable(){if(globalThis.addEventListener("popstate",this.onPopState),this.context.input.addEventListener(fn.KeyDown,this.onInputKeyDown),this.context.input.addEventListener(fn.PointerMove,this.onInputPointerMove),this.context.input.addEventListener(fn.PointerUp,this.onInputPointerUp),this._engineElementOverserver||(this._engineElementOverserver=new MutationObserver(t=>{for(const i of t)if(i.type==="attributes"&&i.attributeName===DC){const n=this.context.domElement.getAttribute(DC);n!==null&&this.trySelectSceneFromValue(n)}})),this._engineElementOverserver.observe(this.context.domElement,{attributes:!0}),this._preloadScheduler||(this._preloadScheduler=new Nve(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 t=this.context.domElement.getAttribute(DC);try{(t===null||!await this.trySelectSceneFromValue(t))&&this._currentIndex===-1&&this.select(0)}finally{}}}onDisable(){var t;globalThis.removeEventListener("popstate",this.onPopState),this.context.input.removeEventListener(fn.KeyDown,this.onInputKeyDown),this.context.input.removeEventListener(fn.PointerMove,this.onInputPointerMove),this.context.input.removeEventListener(fn.PointerUp,this.onInputPointerUp),(t=this._preloadScheduler)==null||t.stop()}addScene(t){if(typeof t=="string"){let i=this.context.addressables.findAssetReference(t);return i||(i=new $t(t),this.context.addressables.registerAssetReference(i)),this.scenes.push(i),i}return this.scenes.push(t),t}selectNext(){return this.select(this._currentIndex+1)}selectPrev(){return this.select(this._currentIndex-1)}select(t){var n,r,o;if(Vo&&console.log("select",t),typeof t=="object"&&console.warn('Switching to "'+t+'" might not work. Please either use an index or a AssetReference (not a scene reference)'),typeof t=="string"){const a=(n=this.scenes)==null?void 0:n.find(c=>c.uri===t);if(!a){const c=$t.getOrCreate(this.sourceId??"",t,this.context);return this.switchScene(c)}if(a)t=(r=this.scenes)==null?void 0:r.indexOf(a);else return Su}if(!((o=this.scenes)!=null&&o.length))return Su;if(t<0){if(this.clamp)return Su;t=this.scenes.length-1}else if(t>=this.scenes.length){if(this.clamp)return Su;t=0}const i=this.scenes[t];return this.switchScene(i)}async switchScene(t){if(!(t instanceof $t)){const n=typeof t;return n==="string"?this.select(t):n==="number"?this.select(t):(console.warn("SceneSwitcher: Can't switch to scene",t,"of type",n),!1)}return t.uri===this.sourceId?(console.warn("SceneSwitcher: can't load own scene - prevent recursive loading",this.sourceId),!1):this.__lastSwitchScene===t&&this.__lastSwitchScenePromise?this.__lastSwitchScenePromise:(this.__lastSwitchScene=t,this.__lastSwitchScenePromise=this.__internalSwitchScene(t),await this.__lastSwitchScenePromise)}async __internalSwitchScene(t){var n,r;if(this._currentScene){Vo&&console.log("UNLOAD",t.uri);const o=this.tryGetSceneEventListener(this._currentScene.asset);if(o!=null&&o.sceneClosing){const a=o.sceneClosing();a instanceof Promise&&await a}this._currentScene.unload()}this._currentScene=void 0;const i=this._currentIndex=((n=this.scenes)==null?void 0:n.indexOf(t))??-1;try{this._currentlyLoadingScene=t,this._currentLoadingProgress=new ProgressEvent("progress",{loaded:0,total:1});const o=new CustomEvent("loadscene-start",{detail:{scene:t,switcher:this,index:i}});this.dispatchEvent(o),await this.onStartLoading(),await t.loadAssetAsync((c,l)=>{this._currentLoadingProgress=l,this.dispatchEvent(l)}).catch(console.error),await this.onEndLoading();const a=new CustomEvent("loadscene-finished",{detail:{scene:t,switcher:this,index:i}});if(this.dispatchEvent(a),this._currentLoadingProgress=void 0,this._currentlyLoadingScene=void 0,a.defaultPrevented)return Vo&&console.warn("Adding loaded scene prevented:",t,a),!1;if(!t.asset)return Vo&&console.warn("Failed loading scene:",t),!1;if(this._currentIndex===i){if(Vo&&console.log("ADD",t.uri),this._currentScene=t,re.add(t.asset,this.gameObject),this.useSceneLighting&&this.context.sceneLighting.enable(t),this.useHistory&&i>=0){let h=i.toString();if(this.useSceneName&&(h=Fz(t.uri)),(r=this.queryParameterName)!=null&&r.length)tS(this.queryParameterName,h,this.useHistory);else{const u=history.state,f=this.guid+"::"+i;u!==f&&history.pushState(f,"unused",location.href)}}const c=this.tryGetSceneEventListener(t.asset);if(c!=null&&c.sceneOpened){const h=c.sceneOpened(this);h instanceof Promise&&await h}const l=new CustomEvent("scene-opened",{detail:{scene:t,switcher:this,index:i}});return this.dispatchEvent(l),!0}}catch(o){console.error(o)}return!1}preload(t){if(t>=0&&t<this.scenes.length){const i=this.scenes[t];if(i instanceof $t)return i.preload()}return Su}tryLoadFromQueryParam(){var i;if(!((i=this.queryParameterName)!=null&&i.length))return Su;const t=ie(this.queryParameterName);return typeof t=="boolean"?Su:this.trySelectSceneFromValue(t)}trySelectSceneFromValue(t){if(typeof t=="string"){const i=parseInt(t);if(i>=0&&i<this.scenes.length)return this.select(i);{const n=t.toLowerCase();for(let r=0;r<this.scenes.length;r++){const o=this.scenes[r];if(o&&Fz(o.uri).toLowerCase().includes(n))return this.select(r)}}}else if(typeof t=="number"&&t>=0&&t<this.scenes.length)return this.select(t);return ro()&&console.warn('Can not find scene: "'+t+'"',this),Su}async onStartLoading(){var t,i;if(this._isCurrentlyLoading=!0,this.loadingScene&&(this._lastLoadingScene!==this.loadingScene&&(this._loadingScenePromise=void 0),this._lastLoadingScene=this.loadingScene,this._loadingScenePromise||(this._loadingScenePromise=(t=this.loadingScene)==null?void 0:t.loadAssetAsync()),await this._loadingScenePromise,this._isCurrentlyLoading&&((i=this.loadingScene)!=null&&i.asset))){Vo&&console.log("Add loading scene",this.loadingScene.uri,this.loadingScene.asset);const n=this.loadingScene.asset;re.add(n,this.gameObject);const r=this.tryGetSceneEventListener(n);if(r!=null&&r.sceneOpened){const o=r.sceneOpened(this);o instanceof Promise&&await o}}if(this._isCurrentlyLoading){const n=this.tryGetSceneEventListener(this.gameObject);if(n&&n.sceneOpened){const r=n.sceneOpened(this);r instanceof Promise&&await r}}}async onEndLoading(){var t;if(this._isCurrentlyLoading=!1,(t=this.loadingScene)!=null&&t.asset){Vo&&console.log("Remove loading scene",this.loadingScene.uri);const i=this.loadingScene.asset,n=this.tryGetSceneEventListener(i);if(typeof(n==null?void 0:n.sceneClosing)=="function"){const r=n.sceneClosing();r instanceof Promise&&await r}re.remove(i)}if(!this._isCurrentlyLoading){const i=this.tryGetSceneEventListener(this.gameObject);if(i&&i.sceneClosing){const n=i.sceneClosing();n instanceof Promise&&await n}}}tryGetSceneEventListener(t,i=0){const n=re.foreachComponent(t,r=>r.sceneClosing?r:void 0);if(i===0&&!n&&t.children.length)for(const r of t.children){const o=this.tryGetSceneEventListener(r,i+1);if(o)return o}return n||null}}la([x()],Ur.prototype,"autoLoadFirstScene",2);la([x($t)],Ur.prototype,"scenes",2);la([x($t)],Ur.prototype,"loadingScene",2);la([x()],Ur.prototype,"queryParameterName",2);la([x()],Ur.prototype,"useSceneName",2);la([x()],Ur.prototype,"clamp",2);la([x()],Ur.prototype,"useHistory",2);la([x()],Ur.prototype,"useKeyboard",2);la([x()],Ur.prototype,"useSwipe",2);la([x()],Ur.prototype,"useSceneLighting",2);la([x()],Ur.prototype,"preloadNext",2);la([x()],Ur.prototype,"preloadPrevious",2);la([x()],Ur.prototype,"preloadConcurrent",2);function Fz(s){const e=s.split("/").pop(),t=e==null?void 0:e.split(".").shift();return t!=null&&t.length?t:s}class Nve{constructor(e,t=1,i=1,n=2){d(this,"maxLoadAhead");d(this,"maxLoadBehind");d(this,"maxConcurrent");d(this,"_isRunning",!1);d(this,"_switcher");d(this,"_loadTasks",[]);d(this,"_maxConcurrentLoads",1);this._switcher=e,this.maxLoadAhead=t,this.maxLoadBehind=i,this.maxConcurrent=n}begin(){if(this._isRunning)return;Vo&&console.log("Preload begin"),this._isRunning=!0;let e=-1,t,i;const n=this._switcher.scenes,r=setInterval(()=>{if(this.allLoaded()&&(Vo&&console.log("All scenes loaded"),this.stop()),!this._isRunning){clearInterval(r);return}if(this.canLoadNewScene()===!1)return;e!==this._switcher.currentIndex&&(e=this._switcher.currentIndex,i=0,t=0);const o=i%2===0;o&&(t+=1),i+=1;const a=o?this.maxLoadAhead:this.maxLoadBehind;if(t>a)return;const c=o?e+t:e-t;if(c<0||c<0||c>=n.length)return;const l=n[c];new Qve(c,l,this._loadTasks)},200)}stop(){this._isRunning=!1}canLoadNewScene(){return this._loadTasks.length<this._maxConcurrentLoads}allLoaded(){if(this._switcher.scenes){for(const e of this._switcher.scenes)if((e==null?void 0:e.isLoaded())===!1)return!1}return!0}}class Qve{constructor(e,t,i){d(this,"index");d(this,"asset");d(this,"tasks");this.index=e,this.asset=t,this.tasks=i,i.push(this),this.awaitLoading()}async awaitLoading(){this.asset&&!this.asset.isLoaded()&&(Vo&&console.log("Preload start: "+this.asset.uri,this.index),await this.asset.preload(),Vo&&console.log("Preload finished: "+this.asset.uri,this.index));const e=this.tasks.indexOf(this);e>=0&&this.tasks.splice(e,1)}}function zve(){return new Promise((s,e)=>{const i=()=>{i!=null&&(document.removeEventListener("pointerdown",i),document.removeEventListener("click",i),document.removeEventListener("dragstart",i),document.removeEventListener("touchstart",i),s())};document.addEventListener("pointerdown",i),document.addEventListener("click",i),document.addEventListener("dragstart",i),document.addEventListener("touchstart",i)})}async function Gve(s){await zve(),s()}var Hve=Object.defineProperty,Vve=Object.getOwnPropertyDescriptor,ha=(s,e,t,i)=>{for(var n=i>1?void 0:i?Vve(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Hve(e,t,n),n};const Is=ie("debugvideo");var Mj=(s=>(s[s.None=0]="None",s[s.AdjustHeight=1]="AdjustHeight",s[s.AdjustWidth=2]="AdjustWidth",s))(Mj||{}),Tj=(s=>(s[s.VideoClip=0]="VideoClip",s[s.Url=1]="Url",s))(Tj||{}),Bj=(s=>(s[s.CameraFarPlane=0]="CameraFarPlane",s[s.CameraNearPlane=1]="CameraNearPlane",s[s.RenderTexture=2]="RenderTexture",s[s.MaterialOverride=3]="MaterialOverride",s))(Bj||{});class _s extends Te{constructor(){super();d(this,"playOnAwake",!0);d(this,"aspectMode",0);d(this,"clip",null);d(this,"source",1);d(this,"_url",null);d(this,"renderMode");d(this,"targetMaterialProperty");d(this,"targetMaterialRenderer");d(this,"targetTexture");d(this,"time",0);d(this,"_playbackSpeed",1);d(this,"_isLooping",!1);d(this,"_muted",!1);d(this,"_audioOutputMode",2);d(this,"playInBackground",!0);d(this,"_crossOrigin","anonymous");d(this,"_videoElement",null);d(this,"_videoTexture",null);d(this,"_videoMaterial",null);d(this,"_isPlaying",!1);d(this,"wasPlaying",!1);d(this,"visibilityChanged",t=>{switch(document.visibilityState){case"hidden":this.playInBackground||(this.wasPlaying=this._isPlaying,this.pause());break;case"visible":this.wasPlaying&&!this._isPlaying&&this.play();break}});d(this,"_receivedInput",!1);d(this,"_overlay",null);d(this,"_targetObjects");d(this,"_updateAspectRoutineId",-1);d(this,"_hls");d(this,"onHlsAvailable",()=>{var t;Is&&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),(t=this._videoElement)==null||t.play(),Is&&console.log("HLS: loaded",this.clip))});Gve(()=>{this._receivedInput=!0,this.updateVideoElementSettings()}),this._targetObjects=[],ie("videoscreenspace")&&window.addEventListener("keydown",t=>{t.key==="f"&&(this.screenspace=!this.screenspace)})}get url(){return this._url}set url(t){const n=this._url!==t;this.__didAwake?n&&this.setClipURL(t??""):this._url=t}get playbackSpeed(){var t;return((t=this._videoElement)==null?void 0:t.playbackRate)??this._playbackSpeed}set playbackSpeed(t){this._playbackSpeed=t,this._videoElement&&(this._videoElement.playbackRate=t)}get isLooping(){var t;return((t=this._videoElement)==null?void 0:t.loop)??this._isLooping}set isLooping(t){this._isLooping=t,this._videoElement&&(this._videoElement.loop=t)}get currentTime(){var t;return((t=this._videoElement)==null?void 0:t.currentTime)??this.time}set currentTime(t){this._videoElement?this._videoElement.currentTime=t:this.time=t}get isPlaying(){const t=this._videoElement;if(t){if(t.currentTime>0&&!t.paused&&!t.ended&&t.readyState>t.HAVE_CURRENT_DATA)return!0;if(t.srcObject&&t.srcObject.active)return!0}return!1}get crossOrigin(){var t;return((t=this._videoElement)==null?void 0:t.crossOrigin)??this._crossOrigin}set crossOrigin(t){this._crossOrigin=t,this._videoElement&&(t!==null?this._videoElement.setAttribute("crossorigin",t):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 t;return((t=this._videoElement)==null?void 0:t.muted)??this._muted}set muted(t){this._muted=t,this._videoElement&&(this._videoElement.muted=t)}get currentVideo(){return this.clip}set audioOutputMode(t){t!==this._audioOutputMode&&(t===1&&ht()&&console.warn("VideoAudioOutputMode.AudioSource is not yet implemented"),this._audioOutputMode=t,this.updateVideoElementSettings())}get audioOutputMode(){return this._audioOutputMode}preloadVideo(){Is&&console.log("Video Preload: "+this.name,this.clip),this.create(!1)}preload(){this.preloadVideo()}setVideo(t){this.clip=t,this.source=0,this._videoElement?(this._videoElement.srcObject=t,this._isPlaying&&this.play(),this.updateAspect()):this.create(this.playOnAwake)}setClipURL(t){this._url!==t&&(this._url=t,this.source=1,Is&&console.log("set url",t),this._videoElement?t.endsWith(".m3u8")||t.includes(".m3u")?this.ensureM3UCanBePlayed():(this._videoElement.src=t,this._isPlaying&&(this.stop(),this.play())):this.create(this.playOnAwake))}onEnable(){var t,i;Is&&console.log("VideoPlayer.onEnable",Tj[this.source],this.clip,this.url,this),window.addEventListener("visibilitychange",this.visibilityChanged),this.playOnAwake===!0?this.create(!0):this.preloadVideo(),this.screenspace?(t=this._overlay)==null||t.start():(i=this._overlay)==null||i.stop()}onDisable(){var t;window.removeEventListener("visibilitychange",this.visibilityChanged),(t=this._overlay)==null||t.stop(),this.pause()}onDestroy(){var t;this._videoElement&&((t=this.videoElement)==null||t.remove(),this._videoElement=null),this._videoTexture&&(this._videoTexture.dispose(),this._videoTexture=null)}play(){var t,i;if(this._videoElement||this.create(!1),!this._videoElement){Is&&console.warn("Can not play: no video element found",this);return}if(!(this._isPlaying&&!((t=this._videoElement)!=null&&t.ended)&&!((i=this._videoElement)!=null&&i.paused))){if(this._isPlaying=!0,this._receivedInput||(this._videoElement.muted=!0),this.handleBeginPlaying(!1),this.shouldUseM3U){this.ensureM3UCanBePlayed();return}Is&&console.log("Video Play()",this.clip,this._videoElement,this.time),this._videoElement.currentTime=this.time,this._videoElement.play().catch(n=>{var r;console.log(n),Is&&console.error("Error playing video",n,"CODE="+n.code,(r=this.videoElement)==null?void 0:r.src,this),setTimeout(()=>{this._isPlaying&&!this.destroyed&&this.activeAndEnabled&&this.play()},1e3)}),Is&&console.log("play",this._videoElement,this.time)}}stop(){this._isPlaying=!1,this.time=0,this._videoElement&&(this._videoElement.currentTime=0,this._videoElement.pause(),Is&&console.log("STOP",this))}pause(){var t,i;this.time=((t=this._videoElement)==null?void 0:t.currentTime)??0,this._isPlaying=!1,(i=this._videoElement)==null||i.pause(),Is&&console.log("PAUSE",this,this.currentTime)}create(t){let i;switch(this.source){case 0:i=this.clip;break;case 1:i=this.url,!(i!=null&&i.length)&&typeof this.clip=="string"&&(i=this.clip);break}return i?(this._videoElement||(Is&&console.warn("Create VideoElement",this),this._videoElement=this.createVideoElement(),this.context.domElement.shadowRoot.prepend(this._videoElement),this.updateVideoElementStyles()),typeof i=="string"?(Is&&console.log("Set Video src",i),this._videoElement.src=i):(Is&&console.log("Set Video srcObject",i),this._videoElement.srcObject=i),this._videoTexture||(this._videoTexture=new TG(this._videoElement)),this._videoTexture.flipY=!1,this._videoTexture.colorSpace=gt,t&&this.handleBeginPlaying(t),Is&&console.log("Video: handle playing done...",i,t),!0):(Is&&console.warn("No video source set",this),!1)}updateAspect(){this.aspectMode!==0&&this.startCoroutine(this.updateAspectImpl())}get screenspace(){var t;return((t=this._overlay)==null?void 0:t.enabled)??!1}set screenspace(t){var i;if(t){if(!this._videoTexture)return;this._overlay||(this._overlay=new jve(this.context)),this._overlay.add(this._videoTexture)}else(i=this._overlay)==null||i.remove(this._videoTexture);this._overlay&&(this._overlay.enabled=t)}createVideoElement(){const t=document.createElement("video");return this._crossOrigin&&t.setAttribute("crossorigin",this._crossOrigin),Is&&console.log("created video element",t),t}handleBeginPlaying(t){var r,o;if(!this.activeAndEnabled||!this._videoElement)return;this._targetObjects.length=0;let i=this.gameObject;switch(this.renderMode){case 3:i=(r=this.targetMaterialRenderer)==null?void 0:r.gameObject,i||(i=(o=re.getComponent(this.gameObject,Nn))==null?void 0:o.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,Bj[this.renderMode],this);return}const n=i.material;if(n){this._targetObjects.push(i),n!==this._videoMaterial&&(this._videoMaterial=n.clone(),i.material=this._videoMaterial);const a="map",c=this._videoMaterial;if(!this.targetMaterialProperty)c[a]=this._videoTexture;else switch(this.targetMaterialProperty){default:c[a]=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(),t&&(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 t=!this._receivedInput||this.audioOutputMode===0;!t&&this._muted&&(t=!0),this._videoElement.muted=t,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 t=++this._updateAspectRoutineId,i=void 0,n=this.clip;for(;t===this._updateAspectRoutineId&&this.aspectMode!==0&&this.clip&&n===this.clip&&this._isPlaying;){if(!n||typeof n=="string")return;let r;for(const o of n.getVideoTracks()){const a=o.getSettings();if(a&&a.width&&a.height){r=a.width/a.height;break}else r=this.context.renderer.domElement.clientWidth/this.context.renderer.domElement.clientHeight}if(r===void 0){for(let o=0;o<10;o++)yield;if(!this.isPlaying)break;continue}if(i===r){yield;continue}for(const o of this._targetObjects){let a=1;if(o.parent){const c=Ji(o.parent);a=c.x/c.y}switch(this.aspectMode){case 1:o.scale.y=1/r*o.scale.x*a;break;case 2:o.scale.x=r*o.scale.y*a;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 t=document.head.querySelector("script[data-hls_library]");t?globalThis.Hls?this.onHlsAvailable():t.addEventListener("load",this.onHlsAvailable):(Is&&console.log("HLS: load script"),t=document.createElement("script"),t.dataset.hls_library="hls.js",t.src="https://cdn.jsdelivr.net/npm/hls.js@1",t.addEventListener("load",this.onHlsAvailable),document.head.append(t))}}ha([x()],_s.prototype,"playOnAwake",2);ha([x()],_s.prototype,"aspectMode",2);ha([x(URL)],_s.prototype,"clip",2);ha([x()],_s.prototype,"source",2);ha([x(URL)],_s.prototype,"url",1);ha([x()],_s.prototype,"renderMode",2);ha([x()],_s.prototype,"targetMaterialProperty",2);ha([x(Nn)],_s.prototype,"targetMaterialRenderer",2);ha([x(Ht)],_s.prototype,"targetTexture",2);ha([x()],_s.prototype,"time",2);ha([x()],_s.prototype,"playbackSpeed",1);ha([x()],_s.prototype,"isLooping",1);ha([x()],_s.prototype,"audioOutputMode",1);class jve{constructor(e){d(this,"context");d(this,"_videos",[]);d(this,"_screenspaceModeQuad");d(this,"_isInScreenspaceMode",!1);d(this,"_input");this.context=e,this._input=new Wve(this)}get enabled(){return this._isInScreenspaceMode}set enabled(e){e?this.start():this.stop()}add(e){this._videos.indexOf(e)===-1&&this._videos.push(e)}remove(e){if(!e)return;const t=this._videos.indexOf(e);t>=0&&this._videos.splice(t,1)}start(){var n;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=Db.createPrimitive(mp.Quad,{material:new qve(e)}),!this._screenspaceModeQuad)return;this._screenspaceModeQuad.geometry.scale(2,2,2)}const t=this._screenspaceModeQuad;this.context.scene.add(t),this.updateScreenspaceMaterialUniforms();const i=t.material;i==null||i.reset(),(n=this._input)==null||n.enable(i)}stop(){var e;this._isInScreenspaceMode=!1,this._screenspaceModeQuad&&((e=this._input)==null||e.disable(),this._screenspaceModeQuad.removeFromParent())}updateScreenspaceMaterialUniforms(){var t;const e=(t=this._screenspaceModeQuad)==null?void 0:t.material;e&&(e.screenAspect=this.context.domElement.clientWidth/this.context.domElement.clientHeight)}}class Wve{constructor(e){d(this,"_onResizeScreenFn");d(this,"_onKeyUpFn");d(this,"_onMouseWheelFn");d(this,"context");d(this,"overlay");d(this,"_material");d(this,"_isPinching",!1);d(this,"_lastPinch",0);this.overlay=e,this.context=e.context}enable(e){this._material=e,window.addEventListener("resize",this._onResizeScreenFn=()=>{this.overlay.updateScreenspaceMaterialUniforms()}),window.addEventListener("keyup",this._onKeyUpFn=n=>{n.key==="Escape"&&this.overlay.stop()}),window.addEventListener("wheel",this._onMouseWheelFn=n=>{this.overlay.enabled&&(e.zoom+=n.deltaY*5e-4,n.preventDefault())},{passive:!1});const t=new ee;window.addEventListener("mousemove",n=>{if(this.overlay.enabled&&this.context.input.getPointerPressed(0)){const r=new ee(n.movementX,n.movementY);r.x/=this.context.domElement.clientWidth,r.y/=this.context.domElement.clientHeight,t.set(r.x,r.y),t.multiplyScalar(e.zoom/-this.context.time.deltaTime*.01),e.offset=e.offset.add(t)}}),window.addEventListener("pointermove",n=>{this.overlay.enabled&&this.context.input.getPointerPressed(0)&&this.context.input.getTouchesPressedCount()===1&&(t.set(n.movementX,n.movementY),t.multiplyScalar(e.zoom*-this.context.time.deltaTime*.05),e.offset=e.offset.add(t))});let i=0;window.addEventListener("touchstart",n=>{if(n.touches.length<2){this.context.time.time-i<.3&&this.overlay.stop(),i=this.context.time.time;return}this._isPinching=!0,this._lastPinch=0}),window.addEventListener("touchmove",n=>{if(!this._isPinching||!this._material)return;const r=n.touches[0],o=n.touches[1],a=r.clientX-o.clientX,c=r.clientY-o.clientY,l=Math.sqrt(a*a+c*c);if(this._lastPinch!==0){const h=l-this._lastPinch;this._material.zoom-=h*.004}this._lastPinch=l}),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 qve extends Pt{constructor(t){super();d(this,"_offset",new ee);this.uniforms={map:{value:t},screenAspect:{value:1},offsetScale:{value:new Ke(0,0,1,1)}},this.vertexShader=`
7347
7347
  uniform sampler2D map;
7348
7348
  uniform float screenAspect;
7349
7349
  uniform vec4 offsetScale;
@@ -7431,10 +7431,10 @@ void main() {
7431
7431
  ${o}
7432
7432
 
7433
7433
  This could mean you forgot to add a npmdef to your ExportInfo
7434
- <a href="https://engine.needle.tools/docs/project_structure.html#creating-and-installing-a-npmdef" target="_blank">documentation</a>`,Xo.Warn)}}if(e.children)for(const r of e.children)await YP(s,r,t)}function n_e(s,e){const{instance:t,compData:i,obj:n}=s;e.object=n,e.target=t,AS(t,i,e),nv&&console.debug("add "+i.name,i,t)}const Fj=ie("debugfileformat");async function Uj(s){const e=await fetch(s,{method:"GET",headers:{range:"bytes=0-32"}}).catch(t=>null);if(e!=null&&e.ok){const t=await e.arrayBuffer(),i=Nj(t);return Fj&&console.log("Determined file type from header: "+i),i}return"unknown"}function Nj(s){if(s.byteLength<4)return"unknown";const e=new Uint8Array(s);return Fj&&console.warn(`Trying to determine file type from binary data
7434
+ <a href="https://engine.needle.tools/docs/project_structure.html#creating-and-installing-a-npmdef" target="_blank">documentation</a>`,Xo.Warn)}}if(e.children)for(const r of e.children)await YP(s,r,t)}function n_e(s,e){const{instance:t,compData:i,obj:n}=s;e.object=n,e.target=t,AS(t,i,e),nv&&console.debug("add "+i.name,i,t)}const Fj=ie("debugfileformat");async function Uj(s,e=!0){var i;if(e){let n=s;const r=new URL(n,globalThis.location.origin);let o=null;const a=r.searchParams.get("filetype");switch(a&&(o=a.toUpperCase()),o!=null&&o.length||(o=(i=r.pathname.split(".").pop())==null?void 0:i.toUpperCase()),o){case"GLTF":return"gltf";case"VRM":return"vrm";case"GLB":return"glb";case"FBX":return"fbx";case"USD":return"usd";case"USDA":return"usda";case"USDZ":return"usdz"}}const t=await fetch(s,{method:"GET",headers:{range:"bytes=0-32"}}).catch(n=>null);if(t!=null&&t.ok){const n=await t.arrayBuffer(),r=Nj(n);return Fj&&console.log("Determined file type from header: "+r),r}return"unknown"}function Nj(s){if(s.byteLength<4)return"unknown";const e=new Uint8Array(s);return Fj&&console.warn(`Trying to determine file type from binary data
7435
7435
  `,'"'+new TextDecoder().decode(s)+`"
7436
- `,e),e[0]==103&&e[1]==108&&e[2]==84&&e[3]==70?"glb":e[0]==80&&e[1]==75&&e[2]==3&&e[3]==4?"usdz":e[0]==80&&e[1]==88&&e[2]==82&&e[3]==45&&e[4]==85&&e[5]==83&&e[6]==68&&e[7]==67?"usd":e[0]==35&&e[1]==117&&e[2]==115&&e[3]==100&&e[4]==97?"usda":e[0]==75&&e[1]==97&&e[2]==121&&e[3]==100&&e[4]==97&&e[5]==114&&e[6]==97&&e[7]==32?"fbx":e[0]==35&&e[1]==32&&e[2]==66&&e[3]==108&&e[4]==101&&e[5]==110&&e[6]==100&&e[7]==101&&e[8]==114&&e[9]==32?"obj":"unknown"}class FO{createBuiltinComponents(e,t,i,n,r){return i_e(e,t,i,n,r)}writeBuiltinComponentData(e,t){return e_e(e,t)}parseSync(e,t,i,n){return Vj(e,t,i,n)}loadSync(e,t,i,n,r){return NO(e,t,i,n,r)}}YD(FO);const Qj=ie("printGltf")||ie("printgltf"),zj=ie("downloadgltf");var Gj=(s=>(s[s.BeforeLoad=0]="BeforeLoad",s[s.AfterLoaded=1]="AfterLoaded",s[s.FinishedSetup=10]="FinishedSetup",s))(Gj||{});class $f{constructor(e,t,i,n){d(this,"context");d(this,"loader");d(this,"path");d(this,"gltf");this.context=e,this.path=t,this.loader=i,this.gltf=n}}const rd={};function s_e(s,e){rd[s]=rd[s]||[],rd[s].push(e)}function r_e(s,e){if(rd[s]){const t=rd[s].indexOf(e);t>=0&&rd[s].splice(t,1)}}function Wm(s,e){if(rd[s])for(const t of rd[s])t(e)}async function Hj(s,e,t,i,n){Qj&&console.warn("glTF",e,t),e.includes("?")&&(e=e.split("?")[0]),await wc().createBuiltinComponents(s,e,t,i,n)}async function o_e(s){var t;switch(((t=s.split("?")[0].split(".").pop())==null?void 0:t.toUpperCase())||""){case"GLTF":return"gltf";case"GLB":return"glb";case"FBX":return"fbx"}return await Uj(s)||"unknown"}async function UO(s,e){const t=await o_e(s);switch(t){case"unknown":return console.warn("Unknown file type:",s),new ud;case"fbx":return new kV;case"obj":return new $2;case"usd":case"usda":case"usdz":return console.warn("USD files are not supported."),null;default:console.warn("Unknown file type:",t);case"gltf":case"glb":const i=new ud;return await rO(i,e,s),i}}async function Vj(s,e,t,i){typeof t!="string"&&(console.warn("Parse gltf binary without path, this might lead to errors in resolving extensions. Please provide the source path of the gltf/glb file",t,typeof t),t=""),Qj&&console.log("Parse glTF",t);const n=await UO(t,s);if(!n)return;if(n instanceof $2){typeof e!="string"&&(e=new TextDecoder().decode(e));const o=n.parse(e);return{animations:o.animations,scene:o,scenes:[o]}}if(!(n instanceof ud)){const o=n.parse(e,t);return qj(n,o),{animations:o.animations,scene:o,scenes:[o]}}const r=sO(n);return new Promise((o,a)=>{try{let c=t.split("?")[0].trimEnd();if(c.endsWith(".glb")||c.endsWith(".gltf")){const h=c.split("/");h.pop(),c=h.join("/"),c.endsWith("/")||(c+="/")}n.resourcePath=c,WE(n,s),Wm(0,new $f(s,t,n));const l=s.mainCamera;n.parse(e,"",async h=>{aO(t,h,s),Wm(1,new $f(s,t,n,h)),await Hj(s,t,h,i,r),await jj(h.scene,s,l),Wm(10,new $f(s,t,n,h)),o(h),zj&&Wj(e)},h=>{console.error("failed loading "+t,h),o(void 0)})}catch(c){console.error(c),a(c)}})}async function NO(s,e,t,i,n){a_e(e);const r=await UO(e,s);if(!r)return;if(!(r instanceof ud)){const a=await r.loadAsync(e,n);return qj(r,a),{animations:a.animations,scene:a,scenes:[a]}}const o=sO(r);return new Promise((a,c)=>{try{WE(r,s),Wm(0,new $f(s,e,r));const l=s.mainCamera;r.load(e,async h=>{aO(e,h,s),Wm(1,new $f(s,e,r,h)),await Hj(s,t,h,i,o),await jj(h.scene,s,l),Wm(10,new $f(s,e,r,h)),a(h),zj&&Wj(e)},h=>{n==null||n.call(r,h)},h=>{console.error("failed loading "+e,h),a(void 0)})}catch(l){console.error(l),c(l)}})}async function jj(s,e,t){t||(t=e.mainCamera),t?await e.renderer.compileAsync(s,t,e.scene):Wce(s,e)}function a_e(s){if(new URL(s,window.location.href).href.startsWith("file://")){const t=`Hi - it looks like you are trying to load a local file which will not work. You need to use a webserver to serve your files.
7437
- Please refer to the documentation on <a href="https://fwd.needle.tools/needle-engine/docs/local-server">https://docs.needle.tools</a> or ask for help in our <a href="https://discord.needle.tools">discord community</a>`;pn(t),console.warn(t)}}function Wj(s){if(typeof s=="string"){const e=document.createElement("a");e.href=s,e.download=s.split("/").pop(),e.click()}else{const e=new Blob([s],{type:"application/octet-stream"}),t=window.URL.createObjectURL(e),i=document.createElement("a");i.href=t,i.download="download.glb",i.click()}}function qj(s,e){if(e!=null&&e.isObject3D){const t=e;s instanceof kV?t.traverse(i=>{const n=i;n!=null&&n.isMesh&&x8(n,n.material)}):s instanceof $2&&t.traverse(i=>{})}}YD(FO);const ln=ie("debugwebcomponent"),Vz="needle-engine",Xj="vr",Yj="desktop",c_e=[B8,Xj,Yj],Jy="ar-session-active",Ky="desktop-session-active",l_e=["hash","src","camera-controls","loadstart","progress","loadfinished","dracoDecoderPath","dracoDecoderType","ktx2DecoderPath","tone-mapping"];class QO extends HTMLElement{constructor(){super();d(this,"_context");d(this,"_overlay_ar");d(this,"_loadingProgress01",0);d(this,"_loadingView");d(this,"_previousSrc",null);d(this,"_didFullyLoad",!1);d(this,"_loadId",0);d(this,"_abortController",null);d(this,"_lastSourceFiles",null);d(this,"_createContextPromise",null);d(this,"onXRSessionStarted",()=>{var i;const t=this.context.xrSessionMode;t==="immersive-ar"?this.onEnterAR(this.context.xrSession):t==="immersive-vr"&&this.onEnterVR(this.context.xrSession),(i=this.context.xrSession)==null||i.addEventListener("end",()=>{this.dispatchEvent(new CustomEvent("xr-session-ended",{detail:{session:this.context.xrSession,context:this._context,sessionMode:t}})),t==="immersive-ar"?this.onExitAR(this.context.xrSession):t==="immersive-vr"&&this.onExitVR(this.context.xrSession)})});d(this,"onReady",()=>{var t;return(t=this._loadingView)==null?void 0:t.onLoadingFinished()});d(this,"onError",()=>{var t;return(t=this._loadingView)==null?void 0:t.setMessage("Loading failed!")});d(this,"_previouslyRegisteredMap",new Map);this._overlay_ar=new bne,this.addEventListener("ready",this.onReady),Z9(),this.attachShadow({mode:"open"});const t=document.createElement("template");t.innerHTML=`<style>
7436
+ `,e),e[0]==103&&e[1]==108&&e[2]==84&&e[3]==70?"glb":e[0]==80&&e[1]==75&&e[2]==3&&e[3]==4?"usdz":e[0]==80&&e[1]==88&&e[2]==82&&e[3]==45&&e[4]==85&&e[5]==83&&e[6]==68&&e[7]==67?"usd":e[0]==35&&e[1]==117&&e[2]==115&&e[3]==100&&e[4]==97?"usda":e[0]==75&&e[1]==97&&e[2]==121&&e[3]==100&&e[4]==97&&e[5]==114&&e[6]==97&&e[7]==32?"fbx":e[0]==35&&e[1]==32&&e[2]==66&&e[3]==108&&e[4]==101&&e[5]==110&&e[6]==100&&e[7]==101&&e[8]==114&&e[9]==32?"obj":"unknown"}class FO{createBuiltinComponents(e,t,i,n,r){return i_e(e,t,i,n,r)}writeBuiltinComponentData(e,t){return e_e(e,t)}parseSync(e,t,i,n){return Vj(e,t,i,n)}loadSync(e,t,i,n,r){return NO(e,t,i,n,r)}}YD(FO);const Qj=ie("printGltf")||ie("printgltf"),zj=ie("downloadgltf");var Gj=(s=>(s[s.BeforeLoad=0]="BeforeLoad",s[s.AfterLoaded=1]="AfterLoaded",s[s.FinishedSetup=10]="FinishedSetup",s))(Gj||{});class $f{constructor(e,t,i,n){d(this,"context");d(this,"loader");d(this,"path");d(this,"gltf");this.context=e,this.path=t,this.loader=i,this.gltf=n}}const rd={};function s_e(s,e){rd[s]=rd[s]||[],rd[s].push(e)}function r_e(s,e){if(rd[s]){const t=rd[s].indexOf(e);t>=0&&rd[s].splice(t,1)}}function Wm(s,e){if(rd[s])for(const t of rd[s])t(e)}async function Hj(s,e,t,i,n){Qj&&console.warn("glTF",e,t),e.includes("?")&&(e=e.split("?")[0]),await wc().createBuiltinComponents(s,e,t,i,n)}async function UO(s,e){const t=await Uj(s)||"unknown";switch(t){case"unknown":return console.warn("Unknown file type:",s),new ud;case"fbx":return new kV;case"obj":return new $2;case"usd":case"usda":case"usdz":return console.warn("USD files are not supported."),null;default:console.warn("Unknown file type:",t);case"gltf":case"glb":case"vrm":const i=new ud;return await rO(i,e,s),i}}async function Vj(s,e,t,i){typeof t!="string"&&(console.warn("Parse gltf binary without path, this might lead to errors in resolving extensions. Please provide the source path of the gltf/glb file",t,typeof t),t=""),Qj&&console.log("Parse glTF",t);const n=await UO(t,s);if(!n)return;if(n instanceof $2){typeof e!="string"&&(e=new TextDecoder().decode(e));const o=n.parse(e);return{animations:o.animations,scene:o,scenes:[o]}}if(!(n instanceof ud)){const o=n.parse(e,t);return qj(n,o),{animations:o.animations,scene:o,scenes:[o]}}const r=sO(n);return new Promise((o,a)=>{try{let c=t.split("?")[0].trimEnd();if(c.endsWith(".glb")||c.endsWith(".gltf")){const h=c.split("/");h.pop(),c=h.join("/"),c.endsWith("/")||(c+="/")}n.resourcePath=c,WE(n,s),Wm(0,new $f(s,t,n));const l=s.mainCamera;n.parse(e,"",async h=>{aO(t,h,s),Wm(1,new $f(s,t,n,h)),await Hj(s,t,h,i,r),await jj(h.scene,s,l),Wm(10,new $f(s,t,n,h)),o(h),zj&&Wj(e)},h=>{console.error("failed loading "+t,h),o(void 0)})}catch(c){console.error(c),a(c)}})}async function NO(s,e,t,i,n){o_e(e);const r=await UO(e,s);if(!r)return;if(!(r instanceof ud)){const a=await r.loadAsync(e,n);return qj(r,a),{animations:a.animations,scene:a,scenes:[a]}}const o=sO(r);return new Promise((a,c)=>{try{WE(r,s),Wm(0,new $f(s,e,r));const l=s.mainCamera;r.load(e,async h=>{aO(e,h,s),Wm(1,new $f(s,e,r,h)),await Hj(s,t,h,i,o),await jj(h.scene,s,l),Wm(10,new $f(s,e,r,h)),a(h),zj&&Wj(e)},h=>{n==null||n.call(r,h)},h=>{console.error("failed loading "+e,h),a(void 0)})}catch(l){console.error(l),c(l)}})}async function jj(s,e,t){t||(t=e.mainCamera),t?await e.renderer.compileAsync(s,t,e.scene):Wce(s,e)}function o_e(s){if(new URL(s,window.location.href).href.startsWith("file://")){const t=`Hi - it looks like you are trying to load a local file which will not work. You need to use a webserver to serve your files.
7437
+ Please refer to the documentation on <a href="https://fwd.needle.tools/needle-engine/docs/local-server">https://docs.needle.tools</a> or ask for help in our <a href="https://discord.needle.tools">discord community</a>`;pn(t),console.warn(t)}}function Wj(s){if(typeof s=="string"){const e=document.createElement("a");e.href=s,e.download=s.split("/").pop(),e.click()}else{const e=new Blob([s],{type:"application/octet-stream"}),t=window.URL.createObjectURL(e),i=document.createElement("a");i.href=t,i.download="download.glb",i.click()}}function qj(s,e){if(e!=null&&e.isObject3D){const t=e;s instanceof kV?t.traverse(i=>{const n=i;n!=null&&n.isMesh&&x8(n,n.material)}):s instanceof $2&&t.traverse(i=>{})}}YD(FO);const ln=ie("debugwebcomponent"),Vz="needle-engine",Xj="vr",Yj="desktop",a_e=[B8,Xj,Yj],Jy="ar-session-active",Ky="desktop-session-active",c_e=["hash","src","camera-controls","loadstart","progress","loadfinished","dracoDecoderPath","dracoDecoderType","ktx2DecoderPath","tone-mapping"];class QO extends HTMLElement{constructor(){super();d(this,"_context");d(this,"_overlay_ar");d(this,"_loadingProgress01",0);d(this,"_loadingView");d(this,"_previousSrc",null);d(this,"_didFullyLoad",!1);d(this,"_loadId",0);d(this,"_abortController",null);d(this,"_lastSourceFiles",null);d(this,"_createContextPromise",null);d(this,"onXRSessionStarted",()=>{var i;const t=this.context.xrSessionMode;t==="immersive-ar"?this.onEnterAR(this.context.xrSession):t==="immersive-vr"&&this.onEnterVR(this.context.xrSession),(i=this.context.xrSession)==null||i.addEventListener("end",()=>{this.dispatchEvent(new CustomEvent("xr-session-ended",{detail:{session:this.context.xrSession,context:this._context,sessionMode:t}})),t==="immersive-ar"?this.onExitAR(this.context.xrSession):t==="immersive-vr"&&this.onExitVR(this.context.xrSession)})});d(this,"onReady",()=>{var t;return(t=this._loadingView)==null?void 0:t.onLoadingFinished()});d(this,"onError",()=>{var t;return(t=this._loadingView)==null?void 0:t.setMessage("Loading failed!")});d(this,"_previouslyRegisteredMap",new Map);this._overlay_ar=new bne,this.addEventListener("ready",this.onReady),Z9(),this.attachShadow({mode:"open"});const t=document.createElement("template");t.innerHTML=`<style>
7438
7438
  @import url('https://fonts.googleapis.com/css2?family=Roboto+Flex:opsz,wght@8..144,100..1000&display=swap');
7439
7439
 
7440
7440
  :host {
@@ -7492,11 +7492,11 @@ Please refer to the documentation on <a href="https://fwd.needle.tools/needle-en
7492
7492
  <div class="content">
7493
7493
  <slot class="overlay-content"></slot>
7494
7494
  </div>
7495
- `,this.shadowRoot&&this.shadowRoot.appendChild(t.content.cloneNode(!0)),this._context=new Dt({domElement:this}),this.addEventListener("error",this.onError)}static get observedAttributes(){return l_e}get loadingProgress01(){return this._loadingProgress01}get loadingFinished(){return this.loadingProgress01>.999}get cameraControls(){const t=this.getAttribute("camera-controls");return t==null?null:!(t===null||t==="False"||t==="false"||t==="0")}getContext(){return new Promise((t,i)=>{if(this._context&&this.loadingFinished)t(this._context);else{const n=()=>{this.removeEventListener("loadfinished",n),this._context&&this.loadingFinished&&t(this._context)};this.addEventListener("loadfinished",n)}})}get context(){return this._context}async connectedCallback(){if(ln&&console.log("<needle-engine> connected"),this.addEventListener("xr-session-started",this.onXRSessionStarted),this.onSetupDesktop(),!this.getAttribute("src")){const i=globalThis["needle:codegen_files"];ln&&console.log('src is null, trying to load from globalThis["needle:codegen_files"]',i),i&&(ln&&console.log('globalThis["needle:codegen_files"]',i),this.setAttribute("src",i))}ln&&console.log("src",this.getAttribute("src"));const t=this._loadId;setTimeout(()=>{this.isConnected!==!1&&t===this._loadId&&this.onLoad()},1),ka!=null&&ka.length&&this.setAttribute("version",ka)}disconnectedCallback(){var n;this.removeEventListener("xr-session-started",this.onXRSessionStarted),this._didFullyLoad=!1;const t=this.getAttribute("keep-alive"),i=t==null||(t==null?void 0:t.length)>0&&t!=="true"&&t!=="1";ln&&console.warn('<needle-engine> disconnected, keep-alive: "'+t+'"',typeof t,"Dispose=",i),i?(ln&&console.warn("<needle-engine> dispose"),(n=this._context)==null||n.dispose(),this._context=null,this._lastSourceFiles=null,this._loadId+=1):ln&&console.warn("<needle-engine> is not disposed because keep-alive is set")}attributeChangedCallback(t,i,n){switch(ln&&console.log("attributeChangedCallback",t,i,n),t){case"src":ln&&console.warn(`<needle-engine src>
7495
+ `,this.shadowRoot&&this.shadowRoot.appendChild(t.content.cloneNode(!0)),this._context=new Dt({domElement:this}),this.addEventListener("error",this.onError)}static get observedAttributes(){return c_e}get loadingProgress01(){return this._loadingProgress01}get loadingFinished(){return this.loadingProgress01>.999}get cameraControls(){const t=this.getAttribute("camera-controls");return t==null?null:!(t===null||t==="False"||t==="false"||t==="0")}getContext(){return new Promise((t,i)=>{if(this._context&&this.loadingFinished)t(this._context);else{const n=()=>{this.removeEventListener("loadfinished",n),this._context&&this.loadingFinished&&t(this._context)};this.addEventListener("loadfinished",n)}})}get context(){return this._context}async connectedCallback(){if(ln&&console.log("<needle-engine> connected"),this.addEventListener("xr-session-started",this.onXRSessionStarted),this.onSetupDesktop(),!this.getAttribute("src")){const i=globalThis["needle:codegen_files"];ln&&console.log('src is null, trying to load from globalThis["needle:codegen_files"]',i),i&&(ln&&console.log('globalThis["needle:codegen_files"]',i),this.setAttribute("src",i))}ln&&console.log("src",this.getAttribute("src"));const t=this._loadId;setTimeout(()=>{this.isConnected!==!1&&t===this._loadId&&this.onLoad()},1),ka!=null&&ka.length&&this.setAttribute("version",ka)}disconnectedCallback(){var n;this.removeEventListener("xr-session-started",this.onXRSessionStarted),this._didFullyLoad=!1;const t=this.getAttribute("keep-alive"),i=t==null||(t==null?void 0:t.length)>0&&t!=="true"&&t!=="1";ln&&console.warn('<needle-engine> disconnected, keep-alive: "'+t+'"',typeof t,"Dispose=",i),i?(ln&&console.warn("<needle-engine> dispose"),(n=this._context)==null||n.dispose(),this._context=null,this._lastSourceFiles=null,this._loadId+=1):ln&&console.warn("<needle-engine> is not disposed because keep-alive is set")}attributeChangedCallback(t,i,n){switch(ln&&console.log("attributeChangedCallback",t,i,n),t){case"src":ln&&console.warn(`<needle-engine src>
7496
7496
  changed from "`,i,'" to "',n,'"'),this.onLoad();break;case"hash":this._context&&(this._context.hash=n);break;case"loadstart":case"progress":case"loadfinished":typeof n=="string"&&n.length>0&&(ln&&console.log(t+" attribute changed",n),this.registerEventFromAttribute(t,n));break;case"dracoDecoderPath":ln&&console.log("dracoDecoderPath",n),SN(n);break;case"dracoDecoderType":n==="wasm"||n==="js"?(ln&&console.log("dracoDecoderType",n),EN(n)):console.error("Invalid dracoDecoderType",n,"expected js or wasm");break;case"ktx2DecoderPath":ln&&console.log("ktx2DecoderPath",n),IN(n);break;case"tone-mapping":{this.applyTonemapping();break}}}async onLoad(){var g,y;if(!this.isConnected)return;if(this._context||(ln&&console.warn("Create new context"),this._context=new Dt({domElement:this})),!this._context){console.error("Needle Engine: Context not initialized");return}const t=this.getSourceFiles();if(!this.checkIfSourceHasChanged(t,this._lastSourceFiles))return;this._abortController&&(ln&&console.warn("Abort previous loading process"),this._abortController.abort(),this._abortController=null),this._lastSourceFiles=t;const i=++this._loadId;if((t==null||t.length<=0)&&(ln&&console.warn("Clear scene",t),this._context.clear(),i!==this._loadId))return;const n=this.getAttribute("alias");this.classList.add("loading");const r=Ph();this.ensureLoadStartIsRegistered();let o=this.dispatchEvent(new CustomEvent("loadstart",{detail:{context:this._context,alias:n},cancelable:!0}));if(r){const m=this.getAttribute("hide-loading-overlay");m!=null&&m!=="0"&&(o=!1)}o===!1&&!r&&(ht()||(o=!0),console.warn("Needle Engine: You need a commercial license to override the default loading view. Visit https://needle.tools/pricing"),ht()&&Ni('You need a <a target="_blank" href="https://needle.tools/pricing">commercial license</a> to override the default loading view. This will not work in production.')),!this._loadingView&&o&&(this._loadingView=new U0(this)),o&&(this._didFullyLoad!==!0?(g=this._loadingView)==null||g.onLoadingBegin("begin load"):setTimeout(()=>{this._loadingView&&this._loadingProgress01<.3&&this._loadId===i&&this._loadingView.onLoadingBegin("begin load")},300)),ln&&console.warn(`--------------
7497
7497
  Needle Engine: Begin loading `+i+`
7498
- `,t),this.onBeforeBeginLoading();const a=[],c={context:this._context,name:"",progress:{},index:0,count:t.length,totalProgress01:this._loadingProgress01},l=new CustomEvent("progress",{detail:c}),h=new Array,u=new AbortController;this._abortController=u;const f={files:t,abortSignal:u.signal,onLoadingProgress:m=>{var b;if(u.signal.aborted)return;const A=m.index;!h[A]&&m.name&&(h[A]=h_e(m.name)),m.name=h[A],o&&((b=this._loadingView)==null||b.onLoadingUpdate(m)),c.name=m.name,c.progress=m.progress,this._loadingProgress01=O2(m),c.totalProgress01=this._loadingProgress01,this.dispatchEvent(l)},onLoadingFinished:(m,A,b)=>{u.signal.aborted||b&&a.push({src:A,file:b})}},p=this.getAttribute("hash");if(p!=null&&(this._context.hash=p),this._context.alias=n,this._createContextPromise=this._context.create(f),await this._createContextPromise,this.applyTonemapping(),ln&&console.warn(`--------------
7498
+ `,t),this.onBeforeBeginLoading();const a=[],c={context:this._context,name:"",progress:{},index:0,count:t.length,totalProgress01:this._loadingProgress01},l=new CustomEvent("progress",{detail:c}),h=new Array,u=new AbortController;this._abortController=u;const f={files:t,abortSignal:u.signal,onLoadingProgress:m=>{var b;if(u.signal.aborted)return;const A=m.index;!h[A]&&m.name&&(h[A]=l_e(m.name)),m.name=h[A],o&&((b=this._loadingView)==null||b.onLoadingUpdate(m)),c.name=m.name,c.progress=m.progress,this._loadingProgress01=O2(m),c.totalProgress01=this._loadingProgress01,this.dispatchEvent(l)},onLoadingFinished:(m,A,b)=>{u.signal.aborted||b&&a.push({src:A,file:b})}},p=this.getAttribute("hash");if(p!=null&&(this._context.hash=p),this._context.alias=n,this._createContextPromise=this._context.create(f),await this._createContextPromise,this.applyTonemapping(),ln&&console.warn(`--------------
7499
7499
  Needle Engine: finished loading `+i+`
7500
7500
  `,t,`Aborted? ${u.signal.aborted}`),this._loadId!==i||u.signal.aborted){console.log("Loading finished but aborted...");return}this._loadingProgress01=1,o&&((y=this._loadingView)==null||y.onLoadingUpdate(1,"creating scene")),this._didFullyLoad=!0,this.classList.remove("loading"),this.classList.add("loading-finished"),this.dispatchEvent(new CustomEvent("loadfinished",{detail:{context:this._context,src:n,loadedFiles:a}}))}applyTonemapping(){var i;if(!((i=this._context)!=null&&i.renderer))return;const t=this.getAttribute("tone-mapping");switch(t==null?void 0:t.toLowerCase()){case"none":this._context.renderer.toneMapping=io;break;case"linear":this._context.renderer.toneMapping=Xm;break;case"neutral":this._context.renderer.toneMapping=Ym;break;case"agx":this._context.renderer.toneMapping=lb;break;default:t!=null&&console.warn("Invalid tone-mapping attribute: "+t)}}internalSetLoadingMessage(t){var i;(i=this._loadingView)==null||i.setMessage(t)}getSourceFiles(){const t=this.getAttribute("src");if(!t)return[];let i;Array.isArray(t)?i=t:t.startsWith("[")&&t.endsWith("]")?i=JSON.parse(t):t.includes(",")?i=t.split(","):i=[t];for(let n=i.length-1;n>=0;n--){const r=i[n];(r==="null"||r==="undefined"||(r==null?void 0:r.length)<=0)&&i.splice(n,1)}return i}checkIfSourceHasChanged(t,i){if((t==null?void 0:t.length)!==(i==null?void 0:i.length)||t==null&&i!==null||t!==null&&i==null)return!0;if(t!==null&&i!==null){for(let n=0;n<(t==null?void 0:t.length);n++)if(t[n]!==i[n])return!0}return!1}ensureLoadStartIsRegistered(){const t=this.getAttribute("loadstart");t&&this.registerEventFromAttribute("loadstart",t)}registerEventFromAttribute(t,i){const n=this._previouslyRegisteredMap.get(t);if(n&&(this._previouslyRegisteredMap.delete(t),this.removeEventListener(t,n)),typeof i=="string"&&i.length>0)try{const r=(0,eval)(i);typeof r=="function"&&(this._previouslyRegisteredMap.set(t,r),this.addEventListener(t,o=>r==null?void 0:r.call(globalThis,this._context,o)))}catch(r){console.error("Error registering event "+t+'="'+i+`" failed with the following error:
7501
- `,r)}}getAROverlayContainer(){return this._overlay_ar.createOverlayContainer(this)}getVROverlayContainer(){for(let t=0;t<this.children.length;t++){const i=this.children[t];if(i.classList.contains("vr"))return i}return null}onEnterAR(t){var n;this.onSetupAR();const i=this.getAROverlayContainer();this._overlay_ar.onBegin(this._context,i,t),this.dispatchEvent(new CustomEvent("enter-ar",{detail:{session:t,context:this._context,htmlContainer:(n=this._overlay_ar)==null?void 0:n.ARContainer}}))}onExitAR(t){var i;this._overlay_ar.onEnd(this._context),this.onSetupDesktop(),this.dispatchEvent(new CustomEvent("exit-ar",{detail:{session:t,context:this._context,htmlContainer:(i=this._overlay_ar)==null?void 0:i.ARContainer}}))}onEnterVR(t){this.onSetupVR(),this.dispatchEvent(new CustomEvent("enter-vr",{detail:{session:t,context:this._context}}))}onExitVR(t){this.onSetupDesktop(),this.dispatchEvent(new CustomEvent("exit-vr",{detail:{session:t,context:this._context}}))}onSetupAR(){this.classList.add(Jy),this.classList.remove(Ky);const t=this.getAROverlayContainer();ln&&console.warn("onSetupAR:",t),t&&(t.classList.add(Jy),t.classList.remove(Ky)),this.foreachHtmlElement(i=>this.setupElementsForMode(i,B8))}onSetupVR(){this.classList.remove(Jy),this.classList.remove(Ky),this.foreachHtmlElement(t=>this.setupElementsForMode(t,Xj))}onSetupDesktop(){this.classList.remove(Jy),this.classList.add(Ky);const t=this.getAROverlayContainer();t&&(t.classList.remove(Jy),t.classList.add(Ky)),this.foreachHtmlElement(i=>this.setupElementsForMode(i,Yj))}setupElementsForMode(t,i,n=null){var o,a;if(t===((a=(o=this._context)==null?void 0:o.renderer)==null?void 0:a.domElement)||t.id==="VRButton"||t.id==="ARButton")return;if(t.classList.contains(i))t.style.visibility="visible",t.style.display==="none"&&(t.style.display="block");else for(const c of c_e)t.classList.contains(c)&&(t.style.visibility="hidden",t.style.display="none")}foreachHtmlElement(t){for(let i=0;i<this.children.length;i++){const n=this.children[i];n.style&&t(n)}}onBeforeBeginLoading(){const t=this.getAttribute("dracoDecoderPath");t&&(ln&&console.log("using custom draco decoder path",t),SN(t));const i=this.getAttribute("dracoDecoderType");i&&(ln&&console.log("using custom draco decoder type",i),EN(i));const n=this.getAttribute("ktx2DecoderPath");n&&(ln&&console.log("using custom ktx2 decoder path",n),IN(n))}}typeof window<"u"&&!window.customElements.get(Vz)&&window.customElements.define(Vz,QO);function h_e(s){if(s.startsWith("blob:"))return"blob";const e=s.split("/");let t=e[e.length-1];const i=t.indexOf("?");i>0&&(t=t.substring(0,i));const n=t.indexOf("=");n>0&&(t=t.substring(n));const r=t.split(".").pop();if((r==="glb"||r==="gltf")&&(t=t.substring(0,t.length-4)),t=decodeURIComponent(t),t.length>3){let o="";for(let a=0;a<t.length;a++){let c=t[a];if(c===" "&&o.length<=0)continue;const l=o.length===0,h=c>="0"&&c<="9";l==!1&&c===c.toUpperCase()&&!h?o+=" "+c:(l&&(c=c.toUpperCase()),o+=c)}return ln&&console.log("displayName",t,o),o}return ln&&console.log("displayName",t),t}const u_e=Object.freeze(Object.defineProperty({__proto__:null,NeedleEngineHTMLElement:QO},Symbol.toStringTag,{value:"Module"}));function d_e(){gl.registerWaitForAllowAudio(()=>{const s=TE.getContext();s.addEventListener("statechange",()=>{setTimeout(()=>{const e=s.state;(e==="suspended"||e==="interrupted")&&s.resume().then(()=>{console.log("AudioContext resumed successfully")}).catch(t=>{console.log("Failed to resume AudioContext: "+t)})},500)})})}setTimeout(d_e,1e3);const FC=ie("debughotreload");let sb=!1;const sv=new Map;function f_e(){return sb}function p_e(s){var i;if(sb)return;const t=s.constructor.name;sv.has(t)?(i=sv.get(t))==null||i.push(s):sv.set(t,[s])}function g_e(s){if(sb)return;const t=s.constructor.name,i=sv.get(t);if(!i)return;const n=i.indexOf(s);n!==-1&&i.splice(n,1)}let jz=!1;function m_e(){if(FC||jz)return;jz=!0;const s=console.error;console.error=(...e)=>{if(e.length){const t=e[0];if(typeof t=="string"&&t.includes("[hmr] Failed to reload ")){console.log("[Needle Engine] Hot reloading failed"),window.location.reload();return}}s.apply(console,e)}}function A_e(s){FC&&console.log("[HMR] Apply changes",s,Object.keys(s)),m_e();for(const e of Object.keys(s))try{sb=!0;const t=K.get(e);if(!t){FC&&console.log("[HMR] Type not found: "+e);continue}const i=s[e],n=sv.get(i.name);let r="[Needle Engine] Updating type: "+e;const o=(n==null?void 0:n.length)??-1;o>0?r+=" x"+o:r+=" - no instances",console.log(r);const a=Object.getOwnPropertyNames(t.prototype),c=Object.getOwnPropertyDescriptors(i.prototype);for(const l in c)c[l].writable&&(t.prototype[l]=s[e].prototype[l]);for(const l of a)c[l]||delete t.prototype[l];if(n){const l=new i,h=Object.getOwnPropertyDescriptors(l);for(const u of n){const f=u,p=f.isComponent===!0,g=p?f.activeAndEnabled:!0,y=p?f.context:void 0;try{if(p&&y&&yh(f,y),p&&g&&(f.enabled=!1),u.onBeforeHotReloadFields&&u.onBeforeHotReloadFields()===!1)continue;for(const m in h)if(h[m].writable){if(u[m]===void 0)u[m]=l[m];else if(typeof u[m]=="function"&&!u[m].prototype){const b=u[m],v=b.name,_="bound ";if(v===_)continue;const w=b.name.substring(_.length),E=i.prototype[w];E&&(u[m]=E.bind(u))}}u.onAfterHotReloadFields&&u.onAfterHotReloadFields()}finally{p&&y&&ak(f,y),p&&g&&(f.enabled=!0)}}}}catch(t){if(FC)console.error(t);else return!1}finally{sb=!1,al(Xo.Log,"Script changes applied (HMR)")}return!0}let Ue;const rb=new Array(128).fill(void 0);rb.push(void 0,null,!0,!1);rb.length;let Hw=null;function Wz(){return Hw!==null&&Hw.byteLength!==0||(Hw=new Int32Array(Ue.memory.buffer)),Hw}const y_e=typeof TextDecoder<"u"?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):{decode:()=>{throw Error("TextDecoder not available")}};typeof TextDecoder<"u"&&y_e.decode();function At(s,e){if(!(s instanceof e))throw new Error(`expected instance of ${e.name}`);return s.ptr}let Vw=null;function v_e(){return Vw!==null&&Vw.byteLength!==0||(Vw=new Float32Array(Ue.memory.buffer)),Vw}let rv=128;function qz(s){if(rv==1)throw new Error("out of js stack");return rb[--rv]=s,rv}let jw=null;function b_e(){return jw!==null&&jw.byteLength!==0||(jw=new Uint32Array(Ue.memory.buffer)),jw}let zo=0;function uf(s,e){const t=e(4*s.length,4)>>>0;return v_e().set(s,t/4),zo=s.length,t}function Ww(s,e){const t=e(4*s.length,4)>>>0;return b_e().set(s,t/4),zo=s.length,t}const Ws=Object.freeze({Ball:0,0:"Ball",Cuboid:1,1:"Cuboid",Capsule:2,2:"Capsule",Segment:3,3:"Segment",Polyline:4,4:"Polyline",Triangle:5,5:"Triangle",TriMesh:6,6:"TriMesh",HeightField:7,7:"HeightField",Compound:8,8:"Compound",ConvexPolyhedron:9,9:"ConvexPolyhedron",Cylinder:10,10:"Cylinder",Cone:11,11:"Cone",RoundCuboid:12,12:"RoundCuboid",RoundTriangle:13,13:"RoundTriangle",RoundCylinder:14,14:"RoundCylinder",RoundCone:15,15:"RoundCone",RoundConvexPolyhedron:16,16:"RoundConvexPolyhedron",HalfSpace:17,17:"HalfSpace"});class __e{__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,e}free(){const e=this.__destroy_into_raw();Ue.__wbg_raweventqueue_free(e)}constructor(e){const t=Ue.raweventqueue_new(e);return this.__wbg_ptr=t>>>0,this}drainCollisionEvents(e){try{Ue.raweventqueue_drainCollisionEvents(this.__wbg_ptr,qz(e))}finally{rb[rv++]=void 0}}drainContactForceEvents(e){try{Ue.raweventqueue_drainContactForceEvents(this.__wbg_ptr,qz(e))}finally{rb[rv++]=void 0}}clear(){Ue.raweventqueue_clear(this.__wbg_ptr)}}class Sr{static __wrap(e){e>>>=0;const t=Object.create(Sr.prototype);return t.__wbg_ptr=e,t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,e}free(){const e=this.__destroy_into_raw();Ue.__wbg_rawgenericjoint_free(e)}static generic(e,t,i,n){At(e,lt),At(t,lt),At(i,lt);const r=Ue.rawgenericjoint_generic(e.__wbg_ptr,t.__wbg_ptr,i.__wbg_ptr,n);return r===0?void 0:Sr.__wrap(r)}static spring(e,t,i,n,r){At(n,lt),At(r,lt);const o=Ue.rawgenericjoint_spring(e,t,i,n.__wbg_ptr,r.__wbg_ptr);return Sr.__wrap(o)}static rope(e,t,i){At(t,lt),At(i,lt);const n=Ue.rawgenericjoint_rope(e,t.__wbg_ptr,i.__wbg_ptr);return Sr.__wrap(n)}static spherical(e,t){At(e,lt),At(t,lt);const i=Ue.rawgenericjoint_spherical(e.__wbg_ptr,t.__wbg_ptr);return Sr.__wrap(i)}static prismatic(e,t,i,n,r,o){At(e,lt),At(t,lt),At(i,lt);const a=Ue.rawgenericjoint_prismatic(e.__wbg_ptr,t.__wbg_ptr,i.__wbg_ptr,n,r,o);return a===0?void 0:Sr.__wrap(a)}static fixed(e,t,i,n){At(e,lt),At(t,Zs),At(i,lt),At(n,Zs);const r=Ue.rawgenericjoint_fixed(e.__wbg_ptr,t.__wbg_ptr,i.__wbg_ptr,n.__wbg_ptr);return Sr.__wrap(r)}static revolute(e,t,i){At(e,lt),At(t,lt),At(i,lt);const n=Ue.rawgenericjoint_revolute(e.__wbg_ptr,t.__wbg_ptr,i.__wbg_ptr);return n===0?void 0:Sr.__wrap(n)}}class zO{static __wrap(e){e>>>=0;const t=Object.create(zO.prototype);return t.__wbg_ptr=e,t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,e}free(){const e=this.__destroy_into_raw();Ue.__wbg_rawpointprojection_free(e)}point(){const e=Ue.rawpointprojection_point(this.__wbg_ptr);return lt.__wrap(e)}isInside(){return Ue.rawpointprojection_isInside(this.__wbg_ptr)!==0}}class GO{static __wrap(e){e>>>=0;const t=Object.create(GO.prototype);return t.__wbg_ptr=e,t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,e}free(){const e=this.__destroy_into_raw();Ue.__wbg_rawrayintersection_free(e)}normal(){const e=Ue.rawraycolliderintersection_normal(this.__wbg_ptr);return lt.__wrap(e)}toi(){return Ue.rawraycolliderintersection_toi(this.__wbg_ptr)}featureType(){return Ue.rawpointcolliderprojection_featureType(this.__wbg_ptr)}featureId(){try{const i=Ue.__wbindgen_add_to_stack_pointer(-16);Ue.rawpointcolliderprojection_featureId(i,this.__wbg_ptr);var e=Wz()[i/4+0],t=Wz()[i/4+1];return e===0?void 0:t>>>0}finally{Ue.__wbindgen_add_to_stack_pointer(16)}}}class Zs{static __wrap(e){e>>>=0;const t=Object.create(Zs.prototype);return t.__wbg_ptr=e,t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,e}free(){const e=this.__destroy_into_raw();Ue.__wbg_rawrotation_free(e)}constructor(e,t,i,n){const r=Ue.rawrotation_new(e,t,i,n);return this.__wbg_ptr=r>>>0,this}static identity(){const e=Ue.rawrotation_identity();return Zs.__wrap(e)}get x(){return Ue.rawrotation_x(this.__wbg_ptr)}get y(){return Ue.rawintegrationparameters_dt(this.__wbg_ptr)}get z(){return Ue.rawraycolliderintersection_toi(this.__wbg_ptr)}get w(){return Ue.rawintegrationparameters_erp(this.__wbg_ptr)}}class qt{static __wrap(e){e>>>=0;const t=Object.create(qt.prototype);return t.__wbg_ptr=e,t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,e}free(){const e=this.__destroy_into_raw();Ue.__wbg_rawshape_free(e)}static cuboid(e,t,i){const n=Ue.rawshape_cuboid(e,t,i);return qt.__wrap(n)}static roundCuboid(e,t,i,n){const r=Ue.rawshape_roundCuboid(e,t,i,n);return qt.__wrap(r)}static ball(e){const t=Ue.rawshape_ball(e);return qt.__wrap(t)}static halfspace(e){At(e,lt);const t=Ue.rawshape_halfspace(e.__wbg_ptr);return qt.__wrap(t)}static capsule(e,t){const i=Ue.rawshape_capsule(e,t);return qt.__wrap(i)}static cylinder(e,t){const i=Ue.rawshape_cylinder(e,t);return qt.__wrap(i)}static roundCylinder(e,t,i){const n=Ue.rawshape_roundCylinder(e,t,i);return qt.__wrap(n)}static cone(e,t){const i=Ue.rawshape_cone(e,t);return qt.__wrap(i)}static roundCone(e,t,i){const n=Ue.rawshape_roundCone(e,t,i);return qt.__wrap(n)}static polyline(e,t){const i=uf(e,Ue.__wbindgen_malloc),n=zo,r=Ww(t,Ue.__wbindgen_malloc),o=zo,a=Ue.rawshape_polyline(i,n,r,o);return qt.__wrap(a)}static trimesh(e,t){const i=uf(e,Ue.__wbindgen_malloc),n=zo,r=Ww(t,Ue.__wbindgen_malloc),o=zo,a=Ue.rawshape_trimesh(i,n,r,o);return qt.__wrap(a)}static heightfield(e,t,i,n){const r=uf(i,Ue.__wbindgen_malloc),o=zo;At(n,lt);const a=Ue.rawshape_heightfield(e,t,r,o,n.__wbg_ptr);return qt.__wrap(a)}static segment(e,t){At(e,lt),At(t,lt);const i=Ue.rawshape_segment(e.__wbg_ptr,t.__wbg_ptr);return qt.__wrap(i)}static triangle(e,t,i){At(e,lt),At(t,lt),At(i,lt);const n=Ue.rawshape_triangle(e.__wbg_ptr,t.__wbg_ptr,i.__wbg_ptr);return qt.__wrap(n)}static roundTriangle(e,t,i,n){At(e,lt),At(t,lt),At(i,lt);const r=Ue.rawshape_roundTriangle(e.__wbg_ptr,t.__wbg_ptr,i.__wbg_ptr,n);return qt.__wrap(r)}static convexHull(e){const t=uf(e,Ue.__wbindgen_malloc),i=zo,n=Ue.rawshape_convexHull(t,i);return n===0?void 0:qt.__wrap(n)}static roundConvexHull(e,t){const i=uf(e,Ue.__wbindgen_malloc),n=zo,r=Ue.rawshape_roundConvexHull(i,n,t);return r===0?void 0:qt.__wrap(r)}static convexMesh(e,t){const i=uf(e,Ue.__wbindgen_malloc),n=zo,r=Ww(t,Ue.__wbindgen_malloc),o=zo,a=Ue.rawshape_convexMesh(i,n,r,o);return a===0?void 0:qt.__wrap(a)}static roundConvexMesh(e,t,i){const n=uf(e,Ue.__wbindgen_malloc),r=zo,o=Ww(t,Ue.__wbindgen_malloc),a=zo,c=Ue.rawshape_roundConvexMesh(n,r,o,a,i);return c===0?void 0:qt.__wrap(c)}castShape(e,t,i,n,r,o,a,c,l){At(e,lt),At(t,Zs),At(i,lt),At(n,qt),At(r,lt),At(o,Zs),At(a,lt);const h=Ue.rawshape_castShape(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr,i.__wbg_ptr,n.__wbg_ptr,r.__wbg_ptr,o.__wbg_ptr,a.__wbg_ptr,c,l);return h===0?void 0:VO.__wrap(h)}intersectsShape(e,t,i,n,r){return At(e,lt),At(t,Zs),At(i,qt),At(n,lt),At(r,Zs),Ue.rawshape_intersectsShape(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr,i.__wbg_ptr,n.__wbg_ptr,r.__wbg_ptr)!==0}contactShape(e,t,i,n,r,o){At(e,lt),At(t,Zs),At(i,qt),At(n,lt),At(r,Zs);const a=Ue.rawshape_contactShape(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr,i.__wbg_ptr,n.__wbg_ptr,r.__wbg_ptr,o);return a===0?void 0:HO.__wrap(a)}containsPoint(e,t,i){return At(e,lt),At(t,Zs),At(i,lt),Ue.rawshape_containsPoint(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr,i.__wbg_ptr)!==0}projectPoint(e,t,i,n){At(e,lt),At(t,Zs),At(i,lt);const r=Ue.rawshape_projectPoint(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr,i.__wbg_ptr,n);return zO.__wrap(r)}intersectsRay(e,t,i,n,r){return At(e,lt),At(t,Zs),At(i,lt),At(n,lt),Ue.rawshape_intersectsRay(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr,i.__wbg_ptr,n.__wbg_ptr,r)!==0}castRay(e,t,i,n,r,o){return At(e,lt),At(t,Zs),At(i,lt),At(n,lt),Ue.rawshape_castRay(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr,i.__wbg_ptr,n.__wbg_ptr,r,o)}castRayAndGetNormal(e,t,i,n,r,o){At(e,lt),At(t,Zs),At(i,lt),At(n,lt);const a=Ue.rawshape_castRayAndGetNormal(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr,i.__wbg_ptr,n.__wbg_ptr,r,o);return a===0?void 0:GO.__wrap(a)}}class HO{static __wrap(e){e>>>=0;const t=Object.create(HO.prototype);return t.__wbg_ptr=e,t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,e}free(){const e=this.__destroy_into_raw();Ue.__wbg_rawshapecontact_free(e)}distance(){return Ue.rawkinematiccharactercontroller_maxSlopeClimbAngle(this.__wbg_ptr)}point1(){const e=Ue.rawpointprojection_point(this.__wbg_ptr);return lt.__wrap(e)}point2(){const e=Ue.rawraycolliderintersection_normal(this.__wbg_ptr);return lt.__wrap(e)}normal1(){const e=Ue.rawshapecollidertoi_witness2(this.__wbg_ptr);return lt.__wrap(e)}normal2(){const e=Ue.rawcharactercollision_translationDeltaApplied(this.__wbg_ptr);return lt.__wrap(e)}}class VO{static __wrap(e){e>>>=0;const t=Object.create(VO.prototype);return t.__wbg_ptr=e,t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,e}free(){const e=this.__destroy_into_raw();Ue.__wbg_rawshapetoi_free(e)}toi(){return Ue.rawrotation_x(this.__wbg_ptr)}witness1(){const e=Ue.rawshapetoi_witness1(this.__wbg_ptr);return lt.__wrap(e)}witness2(){const e=Ue.rawcontactforceevent_total_force(this.__wbg_ptr);return lt.__wrap(e)}normal1(){const e=Ue.rawshapetoi_normal1(this.__wbg_ptr);return lt.__wrap(e)}normal2(){const e=Ue.rawshapetoi_normal2(this.__wbg_ptr);return lt.__wrap(e)}}class lt{static __wrap(e){e>>>=0;const t=Object.create(lt.prototype);return t.__wbg_ptr=e,t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,e}free(){const e=this.__destroy_into_raw();Ue.__wbg_rawvector_free(e)}static zero(){const e=Ue.rawvector_zero();return lt.__wrap(e)}constructor(e,t,i){const n=Ue.rawvector_new(e,t,i);return this.__wbg_ptr=n>>>0,this}get x(){return Ue.rawrotation_x(this.__wbg_ptr)}set x(e){Ue.rawvector_set_x(this.__wbg_ptr,e)}get y(){return Ue.rawintegrationparameters_dt(this.__wbg_ptr)}set y(e){Ue.rawintegrationparameters_set_dt(this.__wbg_ptr,e)}get z(){return Ue.rawraycolliderintersection_toi(this.__wbg_ptr)}set z(e){Ue.rawvector_set_z(this.__wbg_ptr,e)}xyz(){const e=Ue.rawvector_xyz(this.__wbg_ptr);return lt.__wrap(e)}yxz(){const e=Ue.rawvector_yxz(this.__wbg_ptr);return lt.__wrap(e)}zxy(){const e=Ue.rawvector_zxy(this.__wbg_ptr);return lt.__wrap(e)}xzy(){const e=Ue.rawvector_xzy(this.__wbg_ptr);return lt.__wrap(e)}yzx(){const e=Ue.rawvector_yzx(this.__wbg_ptr);return lt.__wrap(e)}zyx(){const e=Ue.rawvector_zyx(this.__wbg_ptr);return lt.__wrap(e)}}class x_e{constructor(e,t,i){this.x=e,this.y=t,this.z=i}}class Be{static new(e,t,i){return new x_e(e,t,i)}static intoRaw(e){return new lt(e.x,e.y,e.z)}static zeros(){return Be.new(0,0,0)}static fromRaw(e){if(!e)return null;let t=Be.new(e.x,e.y,e.z);return e.free(),t}static copy(e,t){e.x=t.x,e.y=t.y,e.z=t.z}}class Xz{constructor(e,t,i,n){this.x=e,this.y=t,this.z=i,this.w=n}}class Yi{static identity(){return new Xz(0,0,0,1)}static fromRaw(e){if(!e)return null;let t=new Xz(e.x,e.y,e.z,e.w);return e.free(),t}static intoRaw(e){return new Zs(e.x,e.y,e.z,e.w)}static copy(e,t){e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w}}class w_e{constructor(e){this.elements=e}get m11(){return this.elements[0]}get m12(){return this.elements[1]}get m21(){return this.m12}get m13(){return this.elements[2]}get m31(){return this.m13}get m22(){return this.elements[3]}get m23(){return this.elements[4]}get m32(){return this.m23}get m33(){return this.elements[5]}}class Yz{static fromRaw(e){const t=new w_e(e.elements());return e.free(),t}}var ov,_r,Jz,Kz,ts,JP,Kn,Zz,LS,KP,$z,FS,Mm;(function(s){s[s.Dynamic=0]="Dynamic",s[s.Fixed=1]="Fixed",s[s.KinematicPositionBased=2]="KinematicPositionBased",s[s.KinematicVelocityBased=3]="KinematicVelocityBased"})(ov||(ov={}));class e4{constructor(e,t,i){this.rawSet=e,this.colliderSet=t,this.handle=i}finalizeDeserialization(e){this.colliderSet=e}isValid(){return this.rawSet.contains(this.handle)}lockTranslations(e,t){return this.rawSet.rbLockTranslations(this.handle,e,t)}lockRotations(e,t){return this.rawSet.rbLockRotations(this.handle,e,t)}setEnabledTranslations(e,t,i,n){return this.rawSet.rbSetEnabledTranslations(this.handle,e,t,i,n)}restrictTranslations(e,t,i,n){this.setEnabledTranslations(e,t,i,n)}setEnabledRotations(e,t,i,n){return this.rawSet.rbSetEnabledRotations(this.handle,e,t,i,n)}restrictRotations(e,t,i,n){this.setEnabledRotations(e,t,i,n)}dominanceGroup(){return this.rawSet.rbDominanceGroup(this.handle)}setDominanceGroup(e){this.rawSet.rbSetDominanceGroup(this.handle,e)}additionalSolverIterations(){return this.rawSet.rbAdditionalSolverIterations(this.handle)}setAdditionalSolverIterations(e){this.rawSet.rbSetAdditionalSolverIterations(this.handle,e)}enableCcd(e){this.rawSet.rbEnableCcd(this.handle,e)}translation(){let e=this.rawSet.rbTranslation(this.handle);return Be.fromRaw(e)}rotation(){let e=this.rawSet.rbRotation(this.handle);return Yi.fromRaw(e)}nextTranslation(){let e=this.rawSet.rbNextTranslation(this.handle);return Be.fromRaw(e)}nextRotation(){let e=this.rawSet.rbNextRotation(this.handle);return Yi.fromRaw(e)}setTranslation(e,t){this.rawSet.rbSetTranslation(this.handle,e.x,e.y,e.z,t)}setLinvel(e,t){let i=Be.intoRaw(e);this.rawSet.rbSetLinvel(this.handle,i,t),i.free()}gravityScale(){return this.rawSet.rbGravityScale(this.handle)}setGravityScale(e,t){this.rawSet.rbSetGravityScale(this.handle,e,t)}setRotation(e,t){this.rawSet.rbSetRotation(this.handle,e.x,e.y,e.z,e.w,t)}setAngvel(e,t){let i=Be.intoRaw(e);this.rawSet.rbSetAngvel(this.handle,i,t),i.free()}setNextKinematicTranslation(e){this.rawSet.rbSetNextKinematicTranslation(this.handle,e.x,e.y,e.z)}setNextKinematicRotation(e){this.rawSet.rbSetNextKinematicRotation(this.handle,e.x,e.y,e.z,e.w)}linvel(){return Be.fromRaw(this.rawSet.rbLinvel(this.handle))}angvel(){return Be.fromRaw(this.rawSet.rbAngvel(this.handle))}mass(){return this.rawSet.rbMass(this.handle)}effectiveInvMass(){return Be.fromRaw(this.rawSet.rbEffectiveInvMass(this.handle))}invMass(){return this.rawSet.rbInvMass(this.handle)}localCom(){return Be.fromRaw(this.rawSet.rbLocalCom(this.handle))}worldCom(){return Be.fromRaw(this.rawSet.rbWorldCom(this.handle))}invPrincipalInertiaSqrt(){return Be.fromRaw(this.rawSet.rbInvPrincipalInertiaSqrt(this.handle))}principalInertia(){return Be.fromRaw(this.rawSet.rbPrincipalInertia(this.handle))}principalInertiaLocalFrame(){return Yi.fromRaw(this.rawSet.rbPrincipalInertiaLocalFrame(this.handle))}effectiveWorldInvInertiaSqrt(){return Yz.fromRaw(this.rawSet.rbEffectiveWorldInvInertiaSqrt(this.handle))}effectiveAngularInertia(){return Yz.fromRaw(this.rawSet.rbEffectiveAngularInertia(this.handle))}sleep(){this.rawSet.rbSleep(this.handle)}wakeUp(){this.rawSet.rbWakeUp(this.handle)}isCcdEnabled(){return this.rawSet.rbIsCcdEnabled(this.handle)}numColliders(){return this.rawSet.rbNumColliders(this.handle)}collider(e){return this.colliderSet.get(this.rawSet.rbCollider(this.handle,e))}setEnabled(e){this.rawSet.rbSetEnabled(this.handle,e)}isEnabled(){return this.rawSet.rbIsEnabled(this.handle)}bodyType(){return this.rawSet.rbBodyType(this.handle)}setBodyType(e,t){return this.rawSet.rbSetBodyType(this.handle,e,t)}isSleeping(){return this.rawSet.rbIsSleeping(this.handle)}isMoving(){return this.rawSet.rbIsMoving(this.handle)}isFixed(){return this.rawSet.rbIsFixed(this.handle)}isKinematic(){return this.rawSet.rbIsKinematic(this.handle)}isDynamic(){return this.rawSet.rbIsDynamic(this.handle)}linearDamping(){return this.rawSet.rbLinearDamping(this.handle)}angularDamping(){return this.rawSet.rbAngularDamping(this.handle)}setLinearDamping(e){this.rawSet.rbSetLinearDamping(this.handle,e)}recomputeMassPropertiesFromColliders(){this.rawSet.rbRecomputeMassPropertiesFromColliders(this.handle,this.colliderSet.raw)}setAdditionalMass(e,t){this.rawSet.rbSetAdditionalMass(this.handle,e,t)}setAdditionalMassProperties(e,t,i,n,r){let o=Be.intoRaw(t),a=Be.intoRaw(i),c=Yi.intoRaw(n);this.rawSet.rbSetAdditionalMassProperties(this.handle,e,o,a,c,r),o.free(),a.free(),c.free()}setAngularDamping(e){this.rawSet.rbSetAngularDamping(this.handle,e)}resetForces(e){this.rawSet.rbResetForces(this.handle,e)}resetTorques(e){this.rawSet.rbResetTorques(this.handle,e)}addForce(e,t){const i=Be.intoRaw(e);this.rawSet.rbAddForce(this.handle,i,t),i.free()}applyImpulse(e,t){const i=Be.intoRaw(e);this.rawSet.rbApplyImpulse(this.handle,i,t),i.free()}addTorque(e,t){const i=Be.intoRaw(e);this.rawSet.rbAddTorque(this.handle,i,t),i.free()}applyTorqueImpulse(e,t){const i=Be.intoRaw(e);this.rawSet.rbApplyTorqueImpulse(this.handle,i,t),i.free()}addForceAtPoint(e,t,i){const n=Be.intoRaw(e),r=Be.intoRaw(t);this.rawSet.rbAddForceAtPoint(this.handle,n,r,i),n.free(),r.free()}applyImpulseAtPoint(e,t,i){const n=Be.intoRaw(e),r=Be.intoRaw(t);this.rawSet.rbApplyImpulseAtPoint(this.handle,n,r,i),n.free(),r.free()}}(function(s){s[s.Revolute=0]="Revolute",s[s.Fixed=1]="Fixed",s[s.Prismatic=2]="Prismatic",s[s.Rope=3]="Rope",s[s.Spring=4]="Spring",s[s.Spherical=5]="Spherical",s[s.Generic=6]="Generic"})(_r||(_r={})),function(s){s[s.AccelerationBased=0]="AccelerationBased",s[s.ForceBased=1]="ForceBased"}(Jz||(Jz={})),function(s){s[s.X=1]="X",s[s.Y=2]="Y",s[s.Z=4]="Z",s[s.AngX=8]="AngX",s[s.AngY=16]="AngY",s[s.AngZ=32]="AngZ"}(Kz||(Kz={}));class uh{constructor(){}static fixed(e,t,i,n){let r=new uh;return r.anchor1=e,r.anchor2=i,r.frame1=t,r.frame2=n,r.jointType=_r.Fixed,r}static spring(e,t,i,n,r){let o=new uh;return o.anchor1=n,o.anchor2=r,o.length=e,o.stiffness=t,o.damping=i,o.jointType=_r.Spring,o}static rope(e,t,i){let n=new uh;return n.anchor1=t,n.anchor2=i,n.length=e,n.jointType=_r.Rope,n}static generic(e,t,i,n){let r=new uh;return r.anchor1=e,r.anchor2=t,r.axis=i,r.axesMask=n,r.jointType=_r.Generic,r}static spherical(e,t){let i=new uh;return i.anchor1=e,i.anchor2=t,i.jointType=_r.Spherical,i}static prismatic(e,t,i){let n=new uh;return n.anchor1=e,n.anchor2=t,n.axis=i,n.jointType=_r.Prismatic,n}static revolute(e,t,i){let n=new uh;return n.anchor1=e,n.anchor2=t,n.axis=i,n.jointType=_r.Revolute,n}intoRaw(){let e,t,i=Be.intoRaw(this.anchor1),n=Be.intoRaw(this.anchor2),r=!1,o=0,a=0;switch(this.jointType){case _r.Fixed:let c=Yi.intoRaw(this.frame1),l=Yi.intoRaw(this.frame2);t=Sr.fixed(i,c,n,l),c.free(),l.free();break;case _r.Spring:t=Sr.spring(this.length,this.stiffness,this.damping,i,n);break;case _r.Rope:t=Sr.rope(this.length,i,n);break;case _r.Prismatic:e=Be.intoRaw(this.axis),this.limitsEnabled&&(r=!0,o=this.limits[0],a=this.limits[1]),t=Sr.prismatic(i,n,e,r,o,a),e.free();break;case _r.Generic:e=Be.intoRaw(this.axis);let h=this.axesMask;t=Sr.generic(i,n,e,h);break;case _r.Spherical:t=Sr.spherical(i,n);break;case _r.Revolute:e=Be.intoRaw(this.axis),t=Sr.revolute(i,n,e),e.free()}return i.free(),n.free(),t}}(function(s){s[s.Average=0]="Average",s[s.Min=1]="Min",s[s.Multiply=2]="Multiply",s[s.Max=3]="Max"})(ts||(ts={}));class ob{constructor(e,t,i,n,r){this.distance=e,this.point1=t,this.point2=i,this.normal1=n,this.normal2=r}static fromRaw(e){if(!e)return null;const t=new ob(e.distance(),Be.fromRaw(e.point1()),Be.fromRaw(e.point2()),Be.fromRaw(e.normal1()),Be.fromRaw(e.normal2()));return e.free(),t}}(function(s){s[s.Vertex=0]="Vertex",s[s.Edge=1]="Edge",s[s.Face=2]="Face",s[s.Unknown=3]="Unknown"})(JP||(JP={}));class t1{constructor(e,t){this.point=e,this.isInside=t}static fromRaw(e){if(!e)return null;const t=new t1(Be.fromRaw(e.point()),e.isInside());return e.free(),t}}class C_e{constructor(e,t){this.origin=e,this.dir=t}pointAt(e){return{x:this.origin.x+this.dir.x*e,y:this.origin.y+this.dir.y*e,z:this.origin.z+this.dir.z*e}}}class i1{constructor(e,t,i,n){this.featureType=JP.Unknown,this.featureId=void 0,this.toi=e,this.normal=t,n!==void 0&&(this.featureId=n),i!==void 0&&(this.featureType=i)}static fromRaw(e){if(!e)return null;const t=new i1(e.toi(),Be.fromRaw(e.normal()),e.featureType(),e.featureId());return e.free(),t}}class S_{constructor(e,t,i,n,r){this.toi=e,this.witness1=t,this.witness2=i,this.normal1=n,this.normal2=r}static fromRaw(e,t){if(!t)return null;const i=new S_(t.toi(),Be.fromRaw(t.witness1()),Be.fromRaw(t.witness2()),Be.fromRaw(t.normal1()),Be.fromRaw(t.normal2()));return t.free(),i}}class jO extends S_{constructor(e,t,i,n,r,o){super(t,i,n,r,o),this.collider=e}static fromRaw(e,t){if(!t)return null;const i=new jO(e.get(t.colliderHandle()),t.toi(),Be.fromRaw(t.witness1()),Be.fromRaw(t.witness2()),Be.fromRaw(t.normal1()),Be.fromRaw(t.normal2()));return t.free(),i}}class Ns{static fromRaw(e,t){const i=e.coShapeType(t);let n,r,o,a,c,l,h;switch(i){case Ws.Ball:return new WO(e.coRadius(t));case Ws.Cuboid:return n=e.coHalfExtents(t),new Jj(n.x,n.y,n.z);case Ws.RoundCuboid:return n=e.coHalfExtents(t),r=e.coRoundRadius(t),new Kj(n.x,n.y,n.z,r);case Ws.Capsule:return c=e.coHalfHeight(t),l=e.coRadius(t),new Zj(c,l);case Ws.Segment:return o=e.coVertices(t),new $j(Be.new(o[0],o[1],o[2]),Be.new(o[3],o[4],o[5]));case Ws.Polyline:return o=e.coVertices(t),a=e.coIndices(t),new iW(o,a);case Ws.Triangle:return o=e.coVertices(t),new eW(Be.new(o[0],o[1],o[2]),Be.new(o[3],o[4],o[5]),Be.new(o[6],o[7],o[8]));case Ws.RoundTriangle:return o=e.coVertices(t),r=e.coRoundRadius(t),new tW(Be.new(o[0],o[1],o[2]),Be.new(o[3],o[4],o[5]),Be.new(o[6],o[7],o[8]),r);case Ws.HalfSpace:return h=Be.fromRaw(e.coHalfspaceNormal(t)),new S_e(h);case Ws.TriMesh:return o=e.coVertices(t),a=e.coIndices(t),new nW(o,a);case Ws.HeightField:const u=e.coHeightfieldScale(t),f=e.coHeightfieldHeights(t),p=e.coHeightfieldNRows(t),g=e.coHeightfieldNCols(t);return new sW(p,g,f,u);case Ws.ConvexPolyhedron:return o=e.coVertices(t),a=e.coIndices(t),new ZP(o,a);case Ws.RoundConvexPolyhedron:return o=e.coVertices(t),a=e.coIndices(t),r=e.coRoundRadius(t),new $P(o,a,r);case Ws.Cylinder:return c=e.coHalfHeight(t),l=e.coRadius(t),new rW(c,l);case Ws.RoundCylinder:return c=e.coHalfHeight(t),l=e.coRadius(t),r=e.coRoundRadius(t),new oW(c,l,r);case Ws.Cone:return c=e.coHalfHeight(t),l=e.coRadius(t),new aW(c,l);case Ws.RoundCone:return c=e.coHalfHeight(t),l=e.coRadius(t),r=e.coRoundRadius(t),new cW(c,l,r);default:throw new Error("unknown shape type: "+i)}}castShape(e,t,i,n,r,o,a,c,l){let h=Be.intoRaw(e),u=Yi.intoRaw(t),f=Be.intoRaw(i),p=Be.intoRaw(r),g=Yi.intoRaw(o),y=Be.intoRaw(a),m=this.intoRaw(),A=n.intoRaw(),b=S_.fromRaw(null,m.castShape(h,u,f,A,p,g,y,c,l));return h.free(),u.free(),f.free(),p.free(),g.free(),y.free(),m.free(),A.free(),b}intersectsShape(e,t,i,n,r){let o=Be.intoRaw(e),a=Yi.intoRaw(t),c=Be.intoRaw(n),l=Yi.intoRaw(r),h=this.intoRaw(),u=i.intoRaw(),f=h.intersectsShape(o,a,u,c,l);return o.free(),a.free(),c.free(),l.free(),h.free(),u.free(),f}contactShape(e,t,i,n,r,o){let a=Be.intoRaw(e),c=Yi.intoRaw(t),l=Be.intoRaw(n),h=Yi.intoRaw(r),u=this.intoRaw(),f=i.intoRaw(),p=ob.fromRaw(u.contactShape(a,c,f,l,h,o));return a.free(),c.free(),l.free(),h.free(),u.free(),f.free(),p}containsPoint(e,t,i){let n=Be.intoRaw(e),r=Yi.intoRaw(t),o=Be.intoRaw(i),a=this.intoRaw(),c=a.containsPoint(n,r,o);return n.free(),r.free(),o.free(),a.free(),c}projectPoint(e,t,i,n){let r=Be.intoRaw(e),o=Yi.intoRaw(t),a=Be.intoRaw(i),c=this.intoRaw(),l=t1.fromRaw(c.projectPoint(r,o,a,n));return r.free(),o.free(),a.free(),c.free(),l}intersectsRay(e,t,i,n){let r=Be.intoRaw(t),o=Yi.intoRaw(i),a=Be.intoRaw(e.origin),c=Be.intoRaw(e.dir),l=this.intoRaw(),h=l.intersectsRay(r,o,a,c,n);return r.free(),o.free(),a.free(),c.free(),l.free(),h}castRay(e,t,i,n,r){let o=Be.intoRaw(t),a=Yi.intoRaw(i),c=Be.intoRaw(e.origin),l=Be.intoRaw(e.dir),h=this.intoRaw(),u=h.castRay(o,a,c,l,n,r);return o.free(),a.free(),c.free(),l.free(),h.free(),u}castRayAndGetNormal(e,t,i,n,r){let o=Be.intoRaw(t),a=Yi.intoRaw(i),c=Be.intoRaw(e.origin),l=Be.intoRaw(e.dir),h=this.intoRaw(),u=i1.fromRaw(h.castRayAndGetNormal(o,a,c,l,n,r));return o.free(),a.free(),c.free(),l.free(),h.free(),u}}(function(s){s[s.Ball=0]="Ball",s[s.Cuboid=1]="Cuboid",s[s.Capsule=2]="Capsule",s[s.Segment=3]="Segment",s[s.Polyline=4]="Polyline",s[s.Triangle=5]="Triangle",s[s.TriMesh=6]="TriMesh",s[s.HeightField=7]="HeightField",s[s.ConvexPolyhedron=9]="ConvexPolyhedron",s[s.Cylinder=10]="Cylinder",s[s.Cone=11]="Cone",s[s.RoundCuboid=12]="RoundCuboid",s[s.RoundTriangle=13]="RoundTriangle",s[s.RoundCylinder=14]="RoundCylinder",s[s.RoundCone=15]="RoundCone",s[s.RoundConvexPolyhedron=16]="RoundConvexPolyhedron",s[s.HalfSpace=17]="HalfSpace"})(Kn||(Kn={}));class WO extends Ns{constructor(e){super(),this.type=Kn.Ball,this.radius=e}intoRaw(){return qt.ball(this.radius)}}class S_e extends Ns{constructor(e){super(),this.type=Kn.HalfSpace,this.normal=e}intoRaw(){let e=Be.intoRaw(this.normal),t=qt.halfspace(e);return e.free(),t}}class Jj extends Ns{constructor(e,t,i){super(),this.type=Kn.Cuboid,this.halfExtents=Be.new(e,t,i)}intoRaw(){return qt.cuboid(this.halfExtents.x,this.halfExtents.y,this.halfExtents.z)}}class Kj extends Ns{constructor(e,t,i,n){super(),this.type=Kn.RoundCuboid,this.halfExtents=Be.new(e,t,i),this.borderRadius=n}intoRaw(){return qt.roundCuboid(this.halfExtents.x,this.halfExtents.y,this.halfExtents.z,this.borderRadius)}}class Zj extends Ns{constructor(e,t){super(),this.type=Kn.Capsule,this.halfHeight=e,this.radius=t}intoRaw(){return qt.capsule(this.halfHeight,this.radius)}}class $j extends Ns{constructor(e,t){super(),this.type=Kn.Segment,this.a=e,this.b=t}intoRaw(){let e=Be.intoRaw(this.a),t=Be.intoRaw(this.b),i=qt.segment(e,t);return e.free(),t.free(),i}}class eW extends Ns{constructor(e,t,i){super(),this.type=Kn.Triangle,this.a=e,this.b=t,this.c=i}intoRaw(){let e=Be.intoRaw(this.a),t=Be.intoRaw(this.b),i=Be.intoRaw(this.c),n=qt.triangle(e,t,i);return e.free(),t.free(),i.free(),n}}class tW extends Ns{constructor(e,t,i,n){super(),this.type=Kn.RoundTriangle,this.a=e,this.b=t,this.c=i,this.borderRadius=n}intoRaw(){let e=Be.intoRaw(this.a),t=Be.intoRaw(this.b),i=Be.intoRaw(this.c),n=qt.roundTriangle(e,t,i,this.borderRadius);return e.free(),t.free(),i.free(),n}}class iW extends Ns{constructor(e,t){super(),this.type=Kn.Polyline,this.vertices=e,this.indices=t??new Uint32Array(0)}intoRaw(){return qt.polyline(this.vertices,this.indices)}}class nW extends Ns{constructor(e,t){super(),this.type=Kn.TriMesh,this.vertices=e,this.indices=t}intoRaw(){return qt.trimesh(this.vertices,this.indices)}}class ZP extends Ns{constructor(e,t){super(),this.type=Kn.ConvexPolyhedron,this.vertices=e,this.indices=t}intoRaw(){return this.indices?qt.convexMesh(this.vertices,this.indices):qt.convexHull(this.vertices)}}class $P extends Ns{constructor(e,t,i){super(),this.type=Kn.RoundConvexPolyhedron,this.vertices=e,this.indices=t,this.borderRadius=i}intoRaw(){return this.indices?qt.roundConvexMesh(this.vertices,this.indices,this.borderRadius):qt.roundConvexHull(this.vertices,this.borderRadius)}}class sW extends Ns{constructor(e,t,i,n){super(),this.type=Kn.HeightField,this.nrows=e,this.ncols=t,this.heights=i,this.scale=n}intoRaw(){let e=Be.intoRaw(this.scale),t=qt.heightfield(this.nrows,this.ncols,this.heights,e);return e.free(),t}}class rW extends Ns{constructor(e,t){super(),this.type=Kn.Cylinder,this.halfHeight=e,this.radius=t}intoRaw(){return qt.cylinder(this.halfHeight,this.radius)}}class oW extends Ns{constructor(e,t,i){super(),this.type=Kn.RoundCylinder,this.borderRadius=i,this.halfHeight=e,this.radius=t}intoRaw(){return qt.roundCylinder(this.halfHeight,this.radius,this.borderRadius)}}class aW extends Ns{constructor(e,t){super(),this.type=Kn.Cone,this.halfHeight=e,this.radius=t}intoRaw(){return qt.cone(this.halfHeight,this.radius)}}class cW extends Ns{constructor(e,t,i){super(),this.type=Kn.RoundCone,this.halfHeight=e,this.radius=t,this.borderRadius=i}intoRaw(){return qt.roundCone(this.halfHeight,this.radius,this.borderRadius)}}(function(s){s[s.EXCLUDE_FIXED=1]="EXCLUDE_FIXED",s[s.EXCLUDE_KINEMATIC=2]="EXCLUDE_KINEMATIC",s[s.EXCLUDE_DYNAMIC=4]="EXCLUDE_DYNAMIC",s[s.EXCLUDE_SENSORS=8]="EXCLUDE_SENSORS",s[s.EXCLUDE_SOLIDS=16]="EXCLUDE_SOLIDS",s[s.ONLY_DYNAMIC=3]="ONLY_DYNAMIC",s[s.ONLY_KINEMATIC=5]="ONLY_KINEMATIC",s[s.ONLY_FIXED=6]="ONLY_FIXED"})(Zz||(Zz={}));(function(s){s[s.NONE=0]="NONE",s[s.COLLISION_EVENTS=1]="COLLISION_EVENTS",s[s.CONTACT_FORCE_EVENTS=2]="CONTACT_FORCE_EVENTS"})(LS||(LS={}));class E_e{free(){this.raw&&this.raw.free(),this.raw=void 0}collider1(){return this.raw.collider1()}collider2(){return this.raw.collider2()}totalForce(){return Be.fromRaw(this.raw.total_force())}totalForceMagnitude(){return this.raw.total_force_magnitude()}maxForceDirection(){return Be.fromRaw(this.raw.max_force_direction())}maxForceMagnitude(){return this.raw.max_force_magnitude()}}class I_e{constructor(e,t){this.raw=t||new __e(e)}free(){this.raw&&this.raw.free(),this.raw=void 0}drainCollisionEvents(e){this.raw.drainCollisionEvents(e)}drainContactForceEvents(e){let t=new E_e;this.raw.drainContactForceEvents(i=>{t.raw=i,e(t),t.free()})}clear(){this.raw.clear()}}(function(s){s[s.NONE=0]="NONE",s[s.FILTER_CONTACT_PAIRS=1]="FILTER_CONTACT_PAIRS",s[s.FILTER_INTERSECTION_PAIRS=2]="FILTER_INTERSECTION_PAIRS"})(KP||(KP={})),function(s){s[s.EMPTY=0]="EMPTY",s[s.COMPUTE_IMPULSE=1]="COMPUTE_IMPULSE"}($z||($z={})),function(s){s[s.DYNAMIC_DYNAMIC=1]="DYNAMIC_DYNAMIC",s[s.DYNAMIC_KINEMATIC=12]="DYNAMIC_KINEMATIC",s[s.DYNAMIC_FIXED=2]="DYNAMIC_FIXED",s[s.KINEMATIC_KINEMATIC=52224]="KINEMATIC_KINEMATIC",s[s.KINEMATIC_FIXED=8704]="KINEMATIC_FIXED",s[s.FIXED_FIXED=32]="FIXED_FIXED",s[s.DEFAULT=15]="DEFAULT",s[s.ALL=60943]="ALL"}(FS||(FS={}));class t4{constructor(e,t,i,n){this.colliderSet=e,this.handle=t,this._parent=i,this._shape=n}finalizeDeserialization(e){this.handle!=null&&(this._parent=e.get(this.colliderSet.raw.coParent(this.handle)))}ensureShapeIsCached(){this._shape||(this._shape=Ns.fromRaw(this.colliderSet.raw,this.handle))}get shape(){return this.ensureShapeIsCached(),this._shape}isValid(){return this.colliderSet.raw.contains(this.handle)}translation(){return Be.fromRaw(this.colliderSet.raw.coTranslation(this.handle))}rotation(){return Yi.fromRaw(this.colliderSet.raw.coRotation(this.handle))}isSensor(){return this.colliderSet.raw.coIsSensor(this.handle)}setSensor(e){this.colliderSet.raw.coSetSensor(this.handle,e)}setShape(e){let t=e.intoRaw();this.colliderSet.raw.coSetShape(this.handle,t),t.free(),this._shape=e}setEnabled(e){this.colliderSet.raw.coSetEnabled(this.handle,e)}isEnabled(){return this.colliderSet.raw.coIsEnabled(this.handle)}setRestitution(e){this.colliderSet.raw.coSetRestitution(this.handle,e)}setFriction(e){this.colliderSet.raw.coSetFriction(this.handle,e)}frictionCombineRule(){return this.colliderSet.raw.coFrictionCombineRule(this.handle)}setFrictionCombineRule(e){this.colliderSet.raw.coSetFrictionCombineRule(this.handle,e)}restitutionCombineRule(){return this.colliderSet.raw.coRestitutionCombineRule(this.handle)}setRestitutionCombineRule(e){this.colliderSet.raw.coSetRestitutionCombineRule(this.handle,e)}setCollisionGroups(e){this.colliderSet.raw.coSetCollisionGroups(this.handle,e)}setSolverGroups(e){this.colliderSet.raw.coSetSolverGroups(this.handle,e)}activeHooks(){return this.colliderSet.raw.coActiveHooks(this.handle)}setActiveHooks(e){this.colliderSet.raw.coSetActiveHooks(this.handle,e)}activeEvents(){return this.colliderSet.raw.coActiveEvents(this.handle)}setActiveEvents(e){this.colliderSet.raw.coSetActiveEvents(this.handle,e)}activeCollisionTypes(){return this.colliderSet.raw.coActiveCollisionTypes(this.handle)}setContactForceEventThreshold(e){return this.colliderSet.raw.coSetContactForceEventThreshold(this.handle,e)}contactForceEventThreshold(){return this.colliderSet.raw.coContactForceEventThreshold(this.handle)}setActiveCollisionTypes(e){this.colliderSet.raw.coSetActiveCollisionTypes(this.handle,e)}setDensity(e){this.colliderSet.raw.coSetDensity(this.handle,e)}setMass(e){this.colliderSet.raw.coSetMass(this.handle,e)}setMassProperties(e,t,i,n){let r=Be.intoRaw(t),o=Be.intoRaw(i),a=Yi.intoRaw(n);this.colliderSet.raw.coSetMassProperties(this.handle,e,r,o,a),r.free(),o.free(),a.free()}setTranslation(e){this.colliderSet.raw.coSetTranslation(this.handle,e.x,e.y,e.z)}setTranslationWrtParent(e){this.colliderSet.raw.coSetTranslationWrtParent(this.handle,e.x,e.y,e.z)}setRotation(e){this.colliderSet.raw.coSetRotation(this.handle,e.x,e.y,e.z,e.w)}setRotationWrtParent(e){this.colliderSet.raw.coSetRotationWrtParent(this.handle,e.x,e.y,e.z,e.w)}shapeType(){return this.colliderSet.raw.coShapeType(this.handle)}halfExtents(){return Be.fromRaw(this.colliderSet.raw.coHalfExtents(this.handle))}setHalfExtents(e){const t=Be.intoRaw(e);this.colliderSet.raw.coSetHalfExtents(this.handle,t)}radius(){return this.colliderSet.raw.coRadius(this.handle)}setRadius(e){this.colliderSet.raw.coSetRadius(this.handle,e)}roundRadius(){return this.colliderSet.raw.coRoundRadius(this.handle)}setRoundRadius(e){this.colliderSet.raw.coSetRoundRadius(this.handle,e)}halfHeight(){return this.colliderSet.raw.coHalfHeight(this.handle)}setHalfHeight(e){this.colliderSet.raw.coSetHalfHeight(this.handle,e)}vertices(){return this.colliderSet.raw.coVertices(this.handle)}indices(){return this.colliderSet.raw.coIndices(this.handle)}heightfieldHeights(){return this.colliderSet.raw.coHeightfieldHeights(this.handle)}heightfieldScale(){let e=this.colliderSet.raw.coHeightfieldScale(this.handle);return Be.fromRaw(e)}heightfieldNRows(){return this.colliderSet.raw.coHeightfieldNRows(this.handle)}heightfieldNCols(){return this.colliderSet.raw.coHeightfieldNCols(this.handle)}parent(){return this._parent}friction(){return this.colliderSet.raw.coFriction(this.handle)}restitution(){return this.colliderSet.raw.coRestitution(this.handle)}density(){return this.colliderSet.raw.coDensity(this.handle)}mass(){return this.colliderSet.raw.coMass(this.handle)}volume(){return this.colliderSet.raw.coVolume(this.handle)}collisionGroups(){return this.colliderSet.raw.coCollisionGroups(this.handle)}solverGroups(){return this.colliderSet.raw.coSolverGroups(this.handle)}containsPoint(e){let t=Be.intoRaw(e),i=this.colliderSet.raw.coContainsPoint(this.handle,t);return t.free(),i}projectPoint(e,t){let i=Be.intoRaw(e),n=t1.fromRaw(this.colliderSet.raw.coProjectPoint(this.handle,i,t));return i.free(),n}intersectsRay(e,t){let i=Be.intoRaw(e.origin),n=Be.intoRaw(e.dir),r=this.colliderSet.raw.coIntersectsRay(this.handle,i,n,t);return i.free(),n.free(),r}castShape(e,t,i,n,r,o,a){let c=Be.intoRaw(e),l=Be.intoRaw(i),h=Yi.intoRaw(n),u=Be.intoRaw(r),f=t.intoRaw(),p=S_.fromRaw(this.colliderSet,this.colliderSet.raw.coCastShape(this.handle,c,f,l,h,u,o,a));return c.free(),l.free(),h.free(),u.free(),f.free(),p}castCollider(e,t,i,n,r){let o=Be.intoRaw(e),a=Be.intoRaw(i),c=jO.fromRaw(this.colliderSet,this.colliderSet.raw.coCastCollider(this.handle,o,t.handle,a,n,r));return o.free(),a.free(),c}intersectsShape(e,t,i){let n=Be.intoRaw(t),r=Yi.intoRaw(i),o=e.intoRaw(),a=this.colliderSet.raw.coIntersectsShape(this.handle,o,n,r);return n.free(),r.free(),o.free(),a}contactShape(e,t,i,n){let r=Be.intoRaw(t),o=Yi.intoRaw(i),a=e.intoRaw(),c=ob.fromRaw(this.colliderSet.raw.coContactShape(this.handle,a,r,o,n));return r.free(),o.free(),a.free(),c}contactCollider(e,t){return ob.fromRaw(this.colliderSet.raw.coContactCollider(this.handle,e.handle,t))}castRay(e,t,i){let n=Be.intoRaw(e.origin),r=Be.intoRaw(e.dir),o=this.colliderSet.raw.coCastRay(this.handle,n,r,t,i);return n.free(),r.free(),o}castRayAndGetNormal(e,t,i){let n=Be.intoRaw(e.origin),r=Be.intoRaw(e.dir),o=i1.fromRaw(this.colliderSet.raw.coCastRayAndGetNormal(this.handle,n,r,t,i));return n.free(),r.free(),o}}(function(s){s[s.Density=0]="Density",s[s.Mass=1]="Mass",s[s.MassProps=2]="MassProps"})(Mm||(Mm={}));class dn{constructor(e){this.enabled=!0,this.shape=e,this.massPropsMode=Mm.Density,this.density=1,this.friction=.5,this.restitution=0,this.rotation=Yi.identity(),this.translation=Be.zeros(),this.isSensor=!1,this.collisionGroups=4294967295,this.solverGroups=4294967295,this.frictionCombineRule=ts.Average,this.restitutionCombineRule=ts.Average,this.activeCollisionTypes=FS.DEFAULT,this.activeEvents=LS.NONE,this.activeHooks=KP.NONE,this.mass=0,this.centerOfMass=Be.zeros(),this.contactForceEventThreshold=0,this.principalAngularInertia=Be.zeros(),this.angularInertiaLocalFrame=Yi.identity()}static ball(e){const t=new WO(e);return new dn(t)}static capsule(e,t){const i=new Zj(e,t);return new dn(i)}static segment(e,t){const i=new $j(e,t);return new dn(i)}static triangle(e,t,i){const n=new eW(e,t,i);return new dn(n)}static roundTriangle(e,t,i,n){const r=new tW(e,t,i,n);return new dn(r)}static polyline(e,t){const i=new iW(e,t);return new dn(i)}static trimesh(e,t){const i=new nW(e,t);return new dn(i)}static cuboid(e,t,i){const n=new Jj(e,t,i);return new dn(n)}static roundCuboid(e,t,i,n){const r=new Kj(e,t,i,n);return new dn(r)}static heightfield(e,t,i,n){const r=new sW(e,t,i,n);return new dn(r)}static cylinder(e,t){const i=new rW(e,t);return new dn(i)}static roundCylinder(e,t,i){const n=new oW(e,t,i);return new dn(n)}static cone(e,t){const i=new aW(e,t);return new dn(i)}static roundCone(e,t,i){const n=new cW(e,t,i);return new dn(n)}static convexHull(e){const t=new ZP(e,null);return new dn(t)}static convexMesh(e,t){const i=new ZP(e,t);return new dn(i)}static roundConvexHull(e,t){const i=new $P(e,null,t);return new dn(i)}static roundConvexMesh(e,t,i){const n=new $P(e,t,i);return new dn(n)}setTranslation(e,t,i){if(typeof e!="number"||typeof t!="number"||typeof i!="number")throw TypeError("The translation components must be numbers.");return this.translation={x:e,y:t,z:i},this}setRotation(e){return Yi.copy(this.rotation,e),this}setSensor(e){return this.isSensor=e,this}setEnabled(e){return this.enabled=e,this}setDensity(e){return this.massPropsMode=Mm.Density,this.density=e,this}setMass(e){return this.massPropsMode=Mm.Mass,this.mass=e,this}setMassProperties(e,t,i,n){return this.massPropsMode=Mm.MassProps,this.mass=e,Be.copy(this.centerOfMass,t),Be.copy(this.principalAngularInertia,i),Yi.copy(this.angularInertiaLocalFrame,n),this}setRestitution(e){return this.restitution=e,this}setFriction(e){return this.friction=e,this}setFrictionCombineRule(e){return this.frictionCombineRule=e,this}setRestitutionCombineRule(e){return this.restitutionCombineRule=e,this}setCollisionGroups(e){return this.collisionGroups=e,this}setSolverGroups(e){return this.solverGroups=e,this}setActiveHooks(e){return this.activeHooks=e,this}setActiveEvents(e){return this.activeEvents=e,this}setActiveCollisionTypes(e){return this.activeCollisionTypes=e,this}setContactForceEventThreshold(e){return this.contactForceEventThreshold=e,this}}for(var PCe={byteLength:function(s){var e=i4(s),t=e[0],i=e[1];return 3*(t+i)/4-i},toByteArray:function(s){var e,t,i=i4(s),n=i[0],r=i[1],o=new M_e(function(l,h,u){return 3*(h+u)/4-u}(0,n,r)),a=0,c=r>0?n-4:n;for(t=0;t<c;t+=4)e=va[s.charCodeAt(t)]<<18|va[s.charCodeAt(t+1)]<<12|va[s.charCodeAt(t+2)]<<6|va[s.charCodeAt(t+3)],o[a++]=e>>16&255,o[a++]=e>>8&255,o[a++]=255&e;return r===2&&(e=va[s.charCodeAt(t)]<<2|va[s.charCodeAt(t+1)]>>4,o[a++]=255&e),r===1&&(e=va[s.charCodeAt(t)]<<10|va[s.charCodeAt(t+1)]<<4|va[s.charCodeAt(t+2)]>>2,o[a++]=e>>8&255,o[a++]=255&e),o},fromByteArray:function(s){for(var e,t=s.length,i=t%3,n=[],r=16383,o=0,a=t-i;o<a;o+=r)n.push(B_e(s,o,o+r>a?a:o+r));return i===1?(e=s[t-1],n.push(el[e>>2]+el[e<<4&63]+"==")):i===2&&(e=(s[t-2]<<8)+s[t-1],n.push(el[e>>10]+el[e>>4&63]+el[e<<2&63]+"=")),n.join("")}},el=[],va=[],M_e=typeof Uint8Array<"u"?Uint8Array:Array,rB="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Zg=0,T_e=rB.length;Zg<T_e;++Zg)el[Zg]=rB[Zg],va[rB.charCodeAt(Zg)]=Zg;function i4(s){var e=s.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=s.indexOf("=");return t===-1&&(t=e),[t,t===e?0:4-t%4]}function B_e(s,e,t){for(var i,n,r=[],o=e;o<t;o+=3)i=(s[o]<<16&16711680)+(s[o+1]<<8&65280)+(255&s[o+2]),r.push(el[(n=i)>>18&63]+el[n>>12&63]+el[n>>6&63]+el[63&n]);return r.join("")}va["-".charCodeAt(0)]=62,va["_".charCodeAt(0)]=63;const R_e=Symbol("object"),oB=new Ua(()=>new C,20);class lW{constructor(e,t,i,n,r,o){d(this,"_point");d(this,"_normal");d(this,"_tangentVelocity");d(this,"distance");d(this,"impulse");d(this,"friction");this._point=e,this.distance=t,this._normal=i,this.impulse=n,this.friction=r,this._tangentVelocity=o}get point(){return oB.get().set(this._point.x,this._point.y,this._point.z)}get normal(){return oB.get().set(this._normal.x,this._normal.y,this._normal.z)}get tangentVelocity(){return oB.get().set(this._tangentVelocity.x,this._tangentVelocity.y,this._tangentVelocity.z)}}class hW{constructor(e,t,i){d(this,"contacts");d(this,"me");d(this,"_collider");d(this,"_gameObject");this.me=e,this._collider=t,this._gameObject=t.gameObject,this.contacts=i}get collider(){return this._collider}get gameObject(){return this._gameObject}get rigidBody(){var e;return(e=this.collider)==null?void 0:e.attachedRigidbody}}class uW{constructor(e,t){d(this,"object");d(this,"collider");this.object=e,this.collider=t}}const Ys=ie("debugphysics"),aB=ie("debugcolliderplacement"),cB=ie("debugcollisions"),P_e=ie("showcolliders"),lB=ie("debugraycasts"),fo=Symbol("needle component"),qr=Symbol("physics body"),n4=Symbol("rigidbody");let df;globalThis.false=globalThis.false!==void 0?globalThis.false:!0;Ys&&console.log("Use Rapier",!1,globalThis.false);const uv=class{constructor(){d(this,"debugRenderColliders",!1);d(this,"debugRenderRaycasts",!1);d(this,"context");d(this,"_initializePromise");d(this,"_isInitialized",!1);d(this,"rapierRay",new C_e({x:0,y:0,z:0},{x:0,y:0,z:1}));d(this,"raycastVectorsBuffer",new Ua(()=>new C,10));d(this,"rapierSphere",null);d(this,"rapierColliderArray",[]);d(this,"rapierIdentityRotation",{x:0,y:0,z:0,w:1});d(this,"rapierForwardVector",{x:0,y:0,z:1});d(this,"enabled",!1);d(this,"_tempPosition",new C);d(this,"_tempQuaternion",new Se);d(this,"_tempScale",new C);d(this,"_tempMatrix",new Ae);d(this,"_isUpdatingPhysicsWorld",!1);d(this,"_world");d(this,"_hasCreatedWorld",!1);d(this,"eventQueue");d(this,"collisionHandler");d(this,"objects",[]);d(this,"bodies",[]);d(this,"_meshCache",new Map);d(this,"_gravity",{x:0,y:-9.81,z:0});d(this,"lines");d(this,"_tempCenterPos",new C);d(this,"_tempCenterVec",new C);d(this,"_tempCenterQuaternion",new Se)}removeBody(e){var i,n,r;if(!e)return;this.validate();const t=e[qr];if(e[qr]=null,t&&this.world){const o=this.objects.findIndex(a=>a===e);if(o>=0){const a=this.bodies[o];if(this.bodies.splice(o,1),this.objects.splice(o,1),a instanceof t4){const c=a;(i=this.world)==null||i.removeCollider(c,!0);const l=c.parent();l&&l.numColliders()<=0&&(l[fo]||(n=this.world)==null||n.removeRigidBody(l))}else a instanceof e4&&(a.numColliders()<=0?(r=this.world)==null||r.removeRigidBody(a):ht()&&(a.did_log_removing||setTimeout(()=>{a.numColliders()>0&&(a.did_log_removing=!0,console.warn("RapierPhysics: removing rigidbody with colliders from the physics world is not possible right now, please remove the colliders first"))},1)))}}}updateBody(e,t,i){if(this.validate(),!!this.enabled&&!(e.destroyed||!e.gameObject)&&!(!t&&!i))if(e.isCollider===!0)console.warn("TODO: implement updating collider position");else{const n=e,r=n[qr];r&&this.syncPhysicsBody(n.gameObject,r,t,i)}}updateProperties(e){if(this.validate(),e.isCollider){const t=e,i=t[qr];i&&(this.internalUpdateColliderProperties(t,i),t.sharedMaterial&&this.updatePhysicsMaterial(t))}else{const t=e,i=this.internal_getRigidbody(t);i&&this.internalUpdateRigidbodyProperties(t,i)}}addForce(e,t,i){this.validate();const n=this.internal_getRigidbody(e);n?n.addForce(t,i):console.warn("Rigidbody doesn't exist: can not apply force")}addImpulse(e,t,i){this.validate();const n=this.internal_getRigidbody(e);n?n.applyImpulse(t,i):console.warn("Rigidbody doesn't exist: can not apply impulse")}getLinearVelocity(e){this.validate();const t=this.internal_getRigidbody(e);return t?t.linvel():null}getAngularVelocity(e){this.validate();const t=this.internal_getRigidbody(e);return t?t.angvel():null}resetForces(e,t){this.validate();const i=this.internal_getRigidbody(e);i==null||i.resetForces(t)}resetTorques(e,t){this.validate();const i=this.internal_getRigidbody(e);i==null||i.resetTorques(t)}applyImpulse(e,t,i){this.validate();const n=this.internal_getRigidbody(e);n?n.applyImpulse(t,i):console.warn("Rigidbody doesn't exist: can not apply impulse")}wakeup(e){this.validate();const t=this.internal_getRigidbody(e);t?t.wakeUp():console.warn("Rigidbody doesn't exist: can not wake up")}isSleeping(e){this.validate();const t=this.internal_getRigidbody(e);return t==null?void 0:t.isSleeping()}setAngularVelocity(e,t,i){this.validate();const n=this.internal_getRigidbody(e);n?n.setAngvel(t,i):console.warn("Rigidbody doesn't exist: can not set angular velocity")}setLinearVelocity(e,t,i){this.validate();const n=this.internal_getRigidbody(e);n?n.setLinvel(t,i):console.warn("Rigidbody doesn't exist: can not set linear velocity")}async initialize(e){return this.context=e,this._initializePromise||(this._initializePromise=this.internalInitialization()),this._initializePromise}async internalInitialization(){return Ys&&console.log("Initialize rapier physics engine"),"env"in{url:typeof document>"u"?require("url").pathToFileURL(__filename).href:sL&&sL.src||new URL("dist/needle-engine.light.umd.cjs",document.baseURI).href}&&{}.VITE_NEEDLE_USE_RAPIER==="false"&&Ys&&console.log("Rapier disabled"),!1}validate(){this._isInitialized||Ys&&(this._lastWarnTime=this._lastWarnTime??0,Date.now()-this._lastWarnTime>1e3&&(this._lastWarnTime=Date.now(),console.warn("Physics engine is not initialized")))}raycast(e,t,i){var c;let n=i==null?void 0:i.maxDistance,r=i==null?void 0:i.solid;n===void 0&&(n=1/0),r===void 0&&(r=!0);const o=this.getPhysicsRay(this.rapierRay,e,t);if(!o)return null;(this.debugRenderRaycasts||lB)&&vt.DrawRay(o.origin,o.dir,255,1);const a=(c=this.world)==null?void 0:c.castRay(o,n,r,i==null?void 0:i.queryFilterFlags,i==null?void 0:i.filterGroups,void 0,void 0,l=>{const h=l[fo];return i!=null&&i.filterPredicate?i.filterPredicate(h):!(h!=null&&h.gameObject.layers.isEnabled(2))});if(a){const l=o.pointAt(a.toi),h=this.raycastVectorsBuffer.get();return h.set(l.x,l.y,l.z),{point:h,collider:a.collider[fo]}}return null}raycastAndGetNormal(e,t,i){var c;let n=i==null?void 0:i.maxDistance,r=i==null?void 0:i.solid;n===void 0&&(n=1/0),r===void 0&&(r=!0);const o=this.getPhysicsRay(this.rapierRay,e,t);if(!o)return null;(this.debugRenderRaycasts||lB)&&vt.DrawRay(o.origin,o.dir,255,1);const a=(c=this.world)==null?void 0:c.castRayAndGetNormal(o,n,r,i==null?void 0:i.queryFilterFlags,i==null?void 0:i.filterGroups,void 0,void 0,l=>{const h=l[fo];return i!=null&&i.filterPredicate?i.filterPredicate(h):!(h!=null&&h.gameObject.layers.isEnabled(2))});if(a){const l=o.pointAt(a.toi),h=a.normal,u=this.raycastVectorsBuffer.get(),f=this.raycastVectorsBuffer.get();return u.set(l.x,l.y,l.z),f.set(h.x,h.y,h.z),{point:u,normal:f,collider:a.collider[fo]}}return null}getPhysicsRay(e,t,i){var a,c,l;const n=(a=this.context)==null?void 0:a.mainCamera;if(t===void 0){const h=(c=this.context)==null?void 0:c.input.getPointerPosition(0);if(h)t=h;else return null}if(t.z===void 0){if(!n)return console.error("Can not perform raycast from 2d point - no main camera found"),null;const h=this.raycastVectorsBuffer.get();h.x=t.x,h.y=t.y,h.z=0,(h.x>1||h.y>1||h.y<-1||h.x<-1)&&(Ys&&console.warn("Converting screenspace to raycast space",h),(l=this.context)==null||l.input.convertScreenspaceToRaycastSpace(h)),h.unproject(n),t=h}const r=t;e.origin.x=r.x,e.origin.y=r.y,e.origin.z=r.z;const o=this.raycastVectorsBuffer.get();if(i)o.set(i.x,i.y,i.z);else{if(!n)return console.error("Can not perform raycast - no camera found"),null;o.set(e.origin.x,e.origin.y,e.origin.z);const h=Ot(n);o.sub(h)}return o.normalize(),e.dir.x=o.x,e.dir.y=o.y,e.dir.z=o.z,e}sphereOverlap(e,t){return this.rapierColliderArray.length=0,this.world?(this.rapierSphere||(this.rapierSphere=new WO(t)),this.rapierSphere.radius=t,(this.debugRenderRaycasts||lB)&&vt.DrawWireSphere(e,t,3359999,1),this.world.intersectionsWithShape(e,this.rapierIdentityRotation,this.rapierSphere,i=>{const n=i[fo],r=new uW(n.gameObject,n);return this.rapierColliderArray.push(r),!0},void 0,void 0,void 0,void 0,i=>i.isSensor()?!1:i[fo].gameObject.layers.isEnabled(2)==!1),this.rapierColliderArray):this.rapierColliderArray}get world(){return this._world}get isUpdating(){return this._isUpdatingPhysicsWorld}get gravity(){var e;return((e=this.world)==null?void 0:e.gravity)??this._gravity}set gravity(e){this.world?this.world.gravity=e:this._gravity=e}clearCaches(){var e,t,i,n;this._meshCache.clear(),(e=this.eventQueue)!=null&&e.raw&&((t=this.eventQueue)==null||t.free()),(i=this.world)!=null&&i.bodies&&((n=this.world)==null||n.free())}async addBoxCollider(e,t){if(this._isInitialized||await this.initialize(e.context),!e.activeAndEnabled)return;if(!this.enabled){Ys&&console.warn("Physics are disabled");return}const i=e.gameObject,n=Ji(i,this._tempPosition).multiply(t);n.multiplyScalar(.5),n.x<0&&(n.x=Math.abs(n.x)),n.y<0&&(n.y=Math.abs(n.y)),n.z<0&&(n.z=Math.abs(n.z)),n.x==0&&(n.x=1e-7),n.y==0&&(n.y=1e-7),n.z==0&&(n.z=1e-7);const r=dn.cuboid(n.x,n.y,n.z);this.createCollider(e,r)}async addSphereCollider(e){if(this._isInitialized||await this.initialize(e.context),!e.activeAndEnabled)return;if(!this.enabled){Ys&&console.warn("Physics are disabled");return}const t=dn.ball(.5);this.createCollider(e,t),this.updateProperties(e)}async addCapsuleCollider(e,t,i){if(this._isInitialized||await this.initialize(e.context),!e.activeAndEnabled)return;if(!this.enabled){Ys&&console.warn("Physics are disabled");return}const n=e.gameObject,r=Ji(n,this._tempPosition);r.x=Math.abs(r.x),r.y=Math.abs(r.y);const o=i*r.x;t=Math.max(t,o*2);const a=tt.clamp(t*.5*r.y-i*r.x,0,Number.MAX_SAFE_INTEGER),c=dn.capsule(a,o);this.createCollider(e,c)}async addMeshCollider(e,t,i,n){var l,h,u;if(this._isInitialized||await this.initialize(e.context),!e.activeAndEnabled)return;if(!this.enabled){Ys&&console.warn("Physics are disabled");return}let r=t.geometry;if(!r){Ys&&console.warn("Missing mesh geometry",t.name);return}(h=(l=r.index)==null?void 0:l.array)!=null&&h.length||(console.warn(`Your MeshCollider is missing vertices or indices in the assined mesh "${t.name}". Consider providing an indexed geometry.`),r=Cae(r));let o=r.getAttribute("position").array;const a=(u=r.index)==null?void 0:u.array;if(Math.abs(n.x-1)>1e-4||Math.abs(n.y-1)>1e-4||Math.abs(n.z-1)>1e-4){const f=r.uuid+"_"+n.x+"_"+n.y+"_"+n.z+"_"+i;if(this._meshCache.has(f))Ys&&console.warn("Use cached mesh collider"),o=this._meshCache.get(f);else{(Ys||ht())&&console.warn(`Your MeshCollider "${e.name}" is scaled: consider applying the scale to the collider mesh instead (${n.x}, ${n.y}, ${n.z})`);const p=new Float32Array(o.length);for(let g=0;g<o.length;g+=3)p[g]=o[g]*n.x,p[g+1]=o[g+1]*n.y,p[g+2]=o[g+2]*n.z;o=p,this._meshCache.set(f,p)}}const c=i?dn.convexHull(o):dn.trimesh(o,a);c&&this.createCollider(e,c)}updatePhysicsMaterial(e){if(!e)return;const t=e.sharedMaterial,i=e[qr];if(i&&t){if(t.bounciness!==void 0&&i.setRestitution(t.bounciness),t.bounceCombine!==void 0)switch(t.bounceCombine){case Ms.Average:i.setRestitutionCombineRule(ts.Average);break;case Ms.Maximum:i.setRestitutionCombineRule(ts.Max);break;case Ms.Minimum:i.setRestitutionCombineRule(ts.Min);break;case Ms.Multiply:i.setRestitutionCombineRule(ts.Multiply);break}if(t.dynamicFriction!==void 0&&i.setFriction(t.dynamicFriction),t.frictionCombine!==void 0)switch(t.frictionCombine){case Ms.Average:i.setFrictionCombineRule(ts.Average);break;case Ms.Maximum:i.setFrictionCombineRule(ts.Max);break;case Ms.Minimum:i.setFrictionCombineRule(ts.Min);break;case Ms.Multiply:i.setFrictionCombineRule(ts.Multiply);break}}}getBody(e){return e?e[qr]:null}getComponent(e){return e?e[fo]:null}createCollider(e,t){var o;if(!this.world)throw new Error("Physics world not initialized");const i=this._tempMatrix;let n;e.attachedRigidbody?n=this.getRigidbody(e,this._tempMatrix):(Ys&&console.log("Create collider without rigidbody",e.name),i.makeRotationFromQuaternion(Fi(e.gameObject)),i.setPosition(Ot(e.gameObject))),i.decompose(this._tempPosition,this._tempQuaternion,this._tempScale),this.tryApplyCenter(e,this._tempPosition),t.setTranslation(this._tempPosition.x,this._tempPosition.y,this._tempPosition.z),t.setRotation(this._tempQuaternion),t.setSensor(e.isTrigger);const r=e.sharedMaterial;if(r){if(r.bounciness!==void 0&&t.setRestitution(r.bounciness),r.bounceCombine!==void 0)switch(r.bounceCombine){case Ms.Average:t.setRestitutionCombineRule(ts.Average);break;case Ms.Maximum:t.setRestitutionCombineRule(ts.Max);break;case Ms.Minimum:t.setRestitutionCombineRule(ts.Min);break;case Ms.Multiply:t.setRestitutionCombineRule(ts.Multiply);break}if(r.dynamicFriction!==void 0&&t.setFriction(r.dynamicFriction),r.frictionCombine!==void 0)switch(r.frictionCombine){case Ms.Average:t.setFrictionCombineRule(ts.Average);break;case Ms.Maximum:t.setFrictionCombineRule(ts.Max);break;case Ms.Minimum:t.setFrictionCombineRule(ts.Min);break;case Ms.Multiply:t.setFrictionCombineRule(ts.Multiply);break}}((o=e.attachedRigidbody)==null?void 0:o.autoMass)===!1&&(t.setDensity(1e-6),t.setMass(1e-6));try{const a=this.world.createCollider(t,n);return a[fo]=e,e[qr]=a,a.setActiveEvents(LS.COLLISION_EVENTS),a.setActiveCollisionTypes(FS.ALL),this.objects.push(e),this.bodies.push(a),this.updateColliderCollisionGroups(e),a}catch(a){return console.error('Error creating collider "'+e.name+`"
7502
- Error:`,a),null}}updateColliderCollisionGroups(e){const t=e[qr],i=e.membership;let n=0;if(i==null)n=65535;else for(let a=0;a<i.length;a++){const c=i[a];c>31?console.error(`Rapier only supports 32 layers, layer ${c} is not supported`):n|=1<<Math.floor(c)}const r=e.filter;let o=0;if(r==null)o=65535;else for(let a=0;a<r.length;a++){const c=r[a];c>31?console.error(`Rapier only supports 32 layers, layer ${c} is not supported`):o|=1<<Math.floor(c)}t.setCollisionGroups(n<<16|o)}getRigidbody(e,t){if(!this.world)throw new Error("Physics world not initialized");let i=null;if(e.attachedRigidbody){const n=e.attachedRigidbody;if(i=n[qr],!i){const r=n.isKinematic&&!aB;Ys&&console.log("Create rigidbody",r);const o=r?df.RigidBodyDesc.kinematicPositionBased():df.RigidBodyDesc.dynamic(),a=Ot(e.attachedRigidbody.gameObject);o.setTranslation(a.x,a.y,a.z),o.setRotation(Fi(e.attachedRigidbody.gameObject)),o.centerOfMass=new df.Vector3(n.centerOfMass.x,n.centerOfMass.y,n.centerOfMass.z),i=this.world.createRigidBody(o),this.bodies.push(i),this.objects.push(n)}i[fo]=n,n[qr]=i,this.internalUpdateRigidbodyProperties(n,i),this.getRigidbodyRelativeMatrix(e.gameObject,n.gameObject,t),e[n4]=i}else{const n=df.RigidBodyDesc.kinematicPositionBased(),r=Ot(e.gameObject);n.setTranslation(r.x,r.y,r.z),n.setRotation(Fi(e.gameObject)),i=this.world.createRigidBody(n),t.identity(),i[fo]=null}return i}internal_getRigidbody(e){return e.isCollider===!0?e[n4]:e[qr]}internalUpdateColliderProperties(e,t){const i=t.shape;let n=!1;switch(i.type){case Kn.Ball:{const f=i,p=e,g=e.gameObject,y=Ji(g,this._tempPosition),m=Math.abs(p.radius*y.x);n=f.radius!==m,f.radius=m,n&&t.setShape(f);break}case Kn.Cuboid:const r=i,o=e,a=e.gameObject,c=Ji(a,this._tempPosition),l=o.size.x*.5*c.x,h=o.size.y*.5*c.y,u=o.size.z*.5*c.z;n=r.halfExtents.x!==l||r.halfExtents.y!==h||r.halfExtents.z!==u,r.halfExtents.x=l,r.halfExtents.y=h,r.halfExtents.z=u,n&&t.setShape(r);break}if(n){const r=e.attachedRigidbody;if(r!=null&&r.autoMass){const o=this.getBody(r);o==null||o.recomputeMassPropertiesFromColliders()}}this.updateColliderCollisionGroups(e),e.isTrigger!==t.isSensor()&&t.setSensor(e.isTrigger)}internalUpdateRigidbodyProperties(e,t){if(t.enableCcd(e.collisionDetectionMode!==uI.Discrete),t.setLinearDamping(e.drag),t.setAngularDamping(e.angularDrag),t.setGravityScale(e.useGravity?e.gravityScale:0,!0),e.dominanceGroup<=127&&e.dominanceGroup>=-127?t.setDominanceGroup(Math.floor(e.dominanceGroup)):t.setDominanceGroup(0),e.autoMass){t.setAdditionalMass(0,!1);for(let i=0;i<t.numColliders();i++)t.collider(i).setDensity(1);t.recomputeMassPropertiesFromColliders()}else{t.setAdditionalMass(e.mass,!1);for(let i=0;i<t.numColliders();i++)t.collider(i).setDensity(1e-7);t.recomputeMassPropertiesFromColliders()}t.setEnabledRotations(!e.lockRotationX,!e.lockRotationY,!e.lockRotationZ,!1),t.setEnabledTranslations(!e.lockPositionX,!e.lockPositionY,!e.lockPositionZ,!1),e.isKinematic?t.setBodyType(df.RigidBodyType.KinematicPositionBased,!1):t.setBodyType(df.RigidBodyType.Dynamic,!1)}step(e){if(this.world&&this.enabled){if(this._isUpdatingPhysicsWorld=!0,this.eventQueue||(this.eventQueue=new I_e(!1)),e===void 0||e<=0){this._isUpdatingPhysicsWorld=!1;return}else e!==void 0&&(this.world.timestep=tt.lerp(this.world.timestep,e,.8));try{this.world.step(this.eventQueue)}catch(t){console.warn("Error running physics step",t)}this._isUpdatingPhysicsWorld=!1}}postStep(){this.world&&this.enabled&&(this._isUpdatingPhysicsWorld=!0,this.syncObjects(),this._isUpdatingPhysicsWorld=!1,this.eventQueue&&!this.collisionHandler&&(this.collisionHandler=new D_e(this.world,this.eventQueue)),this.collisionHandler&&(this.collisionHandler.handleCollisionEvents(),this.collisionHandler.update()),this.updateDebugRendering(this.world))}updateDebugRendering(e){var t,i,n,r;if(Ys||aB||P_e||this.debugRenderColliders===!0){if(!this.lines){const a=new sn({color:7855479,fog:!1}),c=new _t;this.lines=new so(c,a),this.lines.layers.disableAll(),this.lines.layers.enable(2)}this.lines.parent!==((t=this.context)==null?void 0:t.scene)&&((i=this.context)==null||i.scene.add(this.lines));const o=e.debugRender();this.lines.geometry.setAttribute("position",new it(o.vertices,3)),this.lines.geometry.setAttribute("color",new it(o.colors,4)),(this.context.time.frame%30===0||((n=this.lines.geometry.boundingSphere)==null?void 0:n.radius)===0)&&this.lines.geometry.computeBoundingSphere()}else this.lines&&((r=this.context)==null||r.scene.remove(this.lines))}syncObjects(){if(!aB)for(let e=0;e<this.bodies.length;e++){const t=this.objects[e],i=this.bodies[e],n=t;if((n==null?void 0:n.isCollider)===!0&&!n.attachedRigidbody){const c=i.parent();c?this.syncPhysicsBody(t.gameObject,c,!0,!0):this.syncPhysicsBody(t.gameObject,i,!0,!0);continue}const r=i.translation(),o=i.rotation();if(Number.isNaN(r.x)||Number.isNaN(o.x)){!n.__COLLIDER_NAN&&ht()&&(console.warn("Collider has NaN values",n.name,n.gameObject,i),n.__COLLIDER_NAN=!0);continue}const a=t.center;if(a&&a.isVector3){this._tempQuaternion.set(o.x,o.y,o.z,o.w);const c=this._tempPosition.copy(a).applyQuaternion(this._tempQuaternion),l=Ji(t.gameObject);c.multiply(l),r.x-=c.x,r.y-=c.y,r.z-=c.z}dp(t.gameObject,r.x,r.y,r.z),E2(t.gameObject,o.x,o.y,o.z,o.w)}}syncPhysicsBody(e,t,i,n){if(t instanceof e4){const r=Ot(e,this._tempPosition),o=Fi(e,this._tempQuaternion);switch(t.bodyType()){case ov.Fixed:case ov.KinematicPositionBased:case ov.KinematicVelocityBased:i&&t.setNextKinematicTranslation(r),n&&t.setNextKinematicRotation(o);break;default:i&&t.setTranslation(r,!1),n&&t.setRotation(o,!1);break}}else if(t instanceof t4){const r=Ot(e,this._tempPosition),o=Fi(e,this._tempQuaternion),a=t[fo];if(this.tryApplyCenter(a,r),i){const c=t.translation();(c.x!==r.x||c.y!==r.y||c.z!==r.z)&&t.setTranslation(r)}if(n){const c=t.rotation();(c.x!==o.x||c.y!==o.y||c.z!==o.z||c.w!==o.w)&&t.setRotation(o)}}}tryApplyCenter(e,t){const i=e.center;i&&e.gameObject&&(i.x!==0||i.y!==0||i.z!==0)&&(this._tempCenterPos.x=-i.x,this._tempCenterPos.y=i.y,this._tempCenterPos.z=i.z,Ji(e.gameObject,this._tempCenterVec),this._tempCenterPos.multiply(this._tempCenterVec),e.attachedRigidbody?this._tempCenterPos.applyQuaternion(e.gameObject.quaternion):(Fi(e.gameObject,this._tempCenterQuaternion),this._tempCenterPos.applyQuaternion(this._tempCenterQuaternion)),t.x+=this._tempCenterPos.x,t.y+=this._tempCenterPos.y,t.z+=this._tempCenterPos.z)}getRigidbodyRelativeMatrix(e,t,i,n){if(n===void 0&&(n=uv._matricesBuffer,n.length=0),e===t){const r=Ji(e,this._tempPosition);i.makeScale(r.x,r.y,r.z);for(let o=n.length-1;o>=0;o--)i.multiply(n[o]);return i}return n.push(e.matrix),e.parent&&this.getRigidbodyRelativeMatrix(e.parent,t,i,n),i}addFixedJoint(e,t){if(!this.world){console.error("Physics world not initialized");return}const i=e[qr],n=t[qr];this.calculateJointRelativeMatrices(e.gameObject,t.gameObject,this._tempMatrix),this._tempMatrix.decompose(this._tempPosition,this._tempQuaternion,this._tempScale);const r=uh.fixed(uv.centerConnectionPos,uv.centerConnectionRot,this._tempPosition,this._tempQuaternion),o=this.world.createImpulseJoint(r,i,n,!0);Ys&&console.log("ADD FIXED JOINT",o)}addHingeJoint(e,t,i,n){if(!this.world){console.error("Physics world not initialized");return}const r=e[qr],o=t[qr];this.calculateJointRelativeMatrices(e.gameObject,t.gameObject,this._tempMatrix),this._tempMatrix.decompose(this._tempPosition,this._tempQuaternion,this._tempScale);const a=df.JointData.revolute(i,this._tempPosition,n),c=this.world.createImpulseJoint(a,r,o,!0);Ys&&console.log("ADD HINGE JOINT",c)}calculateJointRelativeMatrices(e,t,i){e.updateWorldMatrix(!0,!1),t.updateWorldMatrix(!0,!1);const n=e.matrixWorld,r=t.matrixWorld;n.elements[0]=1,n.elements[5]=1,n.elements[10]=1,r.elements[0]=1,r.elements[5]=1,r.elements[10]=1,i.copy(r).premultiply(n.invert()).invert()}};let yf=uv;d(yf,"_didLoadPhysicsEngine",!1),d(yf,"_matricesBuffer",[]),d(yf,"centerConnectionPos",{x:0,y:0,z:0}),d(yf,"centerConnectionRot",{x:0,y:0,z:0,w:1});class D_e{constructor(e,t){d(this,"world");d(this,"eventQueue");d(this,"activeCollisions",[]);d(this,"activeCollisionsStay",[]);d(this,"activeTriggers",[]);this.world=e,this.eventQueue=t}handleCollisionEvents(){this.eventQueue&&this.world&&this.eventQueue.drainCollisionEvents((e,t,i)=>{const n=this.world.getCollider(e),r=this.world.getCollider(t);if(!n||!r)return;const o=n[fo],a=r[fo];cB&&console.log("EVT",o.name,a.name,i,n,r),o&&a&&(i?(this.onCollisionStarted(o,n,a,r),this.onCollisionStarted(a,r,o,n)):(this.onCollisionEnded(o,a),this.onCollisionEnded(a,o)))})}update(){this.onHandleCollisionStay()}onCollisionStarted(e,t,i,n){let r=null;if(e.isTrigger||i.isTrigger)yp(e.gameObject,o=>{o.onTriggerEnter&&!o.destroyed&&o.onTriggerEnter(i),this.activeTriggers.push({collider:e,component:o,otherCollider:i})});else{const o=e.gameObject;this.world.contactPair(t,n,(a,c)=>{yp(o,l=>{var u;if(l.destroyed)return;const h=l.onCollisionEnter||l.onCollisionStay||l.onCollisionExit;if(h||cB){if(!r){const f=[],p=a.normal();for(let g=0;g<a.numSolverContacts();g++){const y=a.solverContactPoint(g),m=a.contactImpulse(g);if(y){const A=a.contactDist(g),b=a.solverContactFriction(g),v=a.solverContactTangentVelocity(g),_=new lW(y,A,p,m,b,v);f.push(_),cB&&vt.DrawDirection(y,p,16711680,3,!0)}}r=new hW(o,i,f)}if(h){const f={collider:e,component:l,collision:r};this.activeCollisions.push(f),l.onCollisionStay&&this.activeCollisionsStay.push(f),(u=l.onCollisionEnter)==null||u.call(l,r)}}})})}}onHandleCollisionStay(){for(const e of this.activeCollisionsStay){const t=e.component;if(!t.destroyed&&t.activeAndEnabled&&t.onCollisionStay){if(e.collision.collider.destroyed)continue;const i=e.collision;t.onCollisionStay(i)}}for(const e of this.activeTriggers){const t=e.component;if(!t.destroyed&&t.activeAndEnabled&&t.onTriggerStay){const i=e.otherCollider;if(i.destroyed)continue;t.onTriggerStay(i)}}}onCollisionEnded(e,t){if(!(e.destroyed||t.destroyed)){for(let i=0;i<this.activeCollisions.length;i++){const n=this.activeCollisions[i],r=n.collider;if(r.destroyed||n.collision.collider.destroyed){this.activeCollisions.splice(i,1),i--;continue}if(r===e&&n.collision.collider===t){const o=n.component;if(this.activeCollisions.splice(i,1),i--,o.activeAndEnabled&&o.onCollisionExit){const a=n.collision;o.onCollisionExit(a)}}}for(let i=0;i<this.activeCollisionsStay.length;i++){const n=this.activeCollisionsStay[i],r=n.collider;if(r.destroyed||n.collision.collider.destroyed){this.activeCollisionsStay.splice(i,1),i--;continue}if(r===e&&n.collision.collider===t){const o=n.component;if(this.activeCollisionsStay.splice(i,1),i--,o.activeAndEnabled&&o.onCollisionExit){const a=n.collision;o.onCollisionExit(a)}}}for(let i=0;i<this.activeTriggers.length;i++){const n=this.activeTriggers[i],r=n.collider;if(r.destroyed||n.otherCollider.destroyed){this.activeTriggers.splice(i,1),i--;continue}if(r===e&&n.otherCollider===t){const o=n.component;if(this.activeTriggers.splice(i,1),i--,o.activeAndEnabled&&o.onTriggerExit){const a=n.otherCollider;o.onTriggerExit(a)}}}}}}class k_e{static async createComparisonScene(e){const{files:t}=e,n=await Promise.all(t.map(m=>new $t(m).loadAssetAsync())),r=new rr;let o=0;for(const m of n)if(m instanceof ye){m.position.y=o,r.add(m);const A=ld([m]);o+=A.getSize(new C).y,o+=.1}const a=new Nt(20);r.add(a);const c=e.environment||"https://dl.polyhaven.org/file/ph-assets/HDRIs/exr/1k/studio_small_09_1k.exr";if(c){let m=null;if(c.endsWith(".hdr")){const A=(await Promise.resolve().then(()=>Fde)).RGBELoader;m=new A}else if(c.endsWith(".exr")){const A=(await Promise.resolve().then(()=>Lde)).EXRLoader;m=new A}if(m){const A=await m.loadAsync(c).catch(b=>(console.error(b),null));A&&(A.mapping=vo,A.needsUpdate=!0,r.background=A,r.environment=A,r.backgroundBlurriness=.75)}else console.warn("Unsupported environment map format",c)}const l=ld(r.children),h=l.getCenter(new C),u=l.getSize(new C),p=Math.max(u.x,u.y,u.z)/(2*Math.tan(Math.PI*a.fov/360));a.position.set(h.x,h.y,p),a.lookAt(h);const g=new E6(a,e.domElement||document.body);g.target=h,g.update();const y=(e.domElement||document.body).getBoundingClientRect();return a.aspect=y.width/y.height,a.updateProjectionMatrix(),{scene:r,camera:a}}}function O_e(s,e,t,i="image/webp",n){return dW({context:s,width:e,height:t,mimeType:i,camera:n})}function dW(s={mimeType:"image/png",transparent:!1}){s||(s={});let{context:e,width:t,height:i,camera:n}=s;const{mimeType:r}=s;if(!e&&(e=ui.Current,!e))return console.error("Can not save screenshot: No needle-engine context found or provided."),null;if(!n&&(n=e.mainCamera,!n))return console.error("No camera found"),null;const o=e.renderer.domElement.width,a=e.renderer.domElement.height;t||(t=o),i||(i=a);const c=window.devicePixelRatio||1;t/=c,i/=c,e.renderer.domElement.style.width=t+"px",e.renderer.domElement.style.height=i+"px";const l=e.renderer.getClearColor(new ve);try{s!=null&&s.transparent&&e.renderer.setClearColor(0,0);const h=e.renderer.domElement;e.renderer.setSize(t,i,!1),n instanceof Nt&&e.updateAspect(n,t,i);const u=s.render_events!==!1,f=new Array;u&&(RA(e.scene,Nn,f),f.forEach(g=>g==null?void 0:g.onBeforeRender())),e.renderNow(),u&&f.forEach(g=>g.onAfterRender());const p=h.toDataURL(r);return s.download_filename&&fW(p,s.download_filename),p}finally{e.renderer.setSize(o,a,!1),e.updateSize(),e.renderer.setClearColor(l)}return null}let Zy=null;function fW(s,e){if(s){if(!s.startsWith("data:image")){console.error("Can not save image: Data url is not an image",s);return}Zy||(Zy=document.createElement("a")),Zy.href=s,Zy.download=e,Zy.click()}}let eD=0;function s4(s){s?eD++:eD--}function L_e(){return eD>0}class pW{constructor(e){d(this,"writer");this.writer=e}writeNode(e){}}class F_e extends pW{beforeWriteNode(e,t){vt.isGizmo(e)&&(t.keep=!1)}}class U_e extends pW{beforeWriteTexture(e,t){e.isRenderTargetTexture&&(t.newTexture=Bk(new Ei(1,1,1,0)))}}const N_e={binary:!0,animations:!0};async function Q_e(s){if(!s.context)throw new Error("No context provided to exportAsGLTF");s.scene||(s.scene=s.context.scene);const e={...N_e,...s},{context:t}=e,i=new LI;i.register(a=>new mj(a)),i.register(a=>new F_e(a)),i.register(a=>new U_e(a)),oO(i,e.context);const n={binary:e.binary,animations:G_e(t,e.scene,[])},r=new z_e;console.log("Exporting GLTF",n),r.onBeforeExport(e),s4(!0);const o=await i.parseAsync(e.scene,n).catch(a=>(console.error(a),null));if(s4(!1),r.onAfterExport(e),!o)throw new Error("Failed to export GLTF");if(e.downloadAs!=null){let a=null;if(o instanceof ArrayBuffer?a=new Blob([o],{type:"application/octet-stream"}):console.error("Can not download GLTF as a blob",o),a){const c=URL.createObjectURL(a),l=document.createElement("a");l.href=c;let h=e.downloadAs;!h.endsWith(".glb")&&!h.endsWith(".gltf")&&(h+=e.binary?".glb":".gltf"),l.download=h,l.click()}}return o}const r4=Symbol("needle:weight");class z_e{constructor(){d(this,"_undo",[])}onBeforeExport(e){e.context.animations.mixers.forEach(t=>{const i=Qv.tryGetActionsFromMixer(t);if(i)for(let n=0;n<i.length;n++){const r=i[n];r[r4]=r.weight,r.weight=0,this._undo.push(()=>{r.weight=r[r4]})}t.update(0)})}onAfterExport(e){this._undo.forEach(t=>t()),this._undo.length=0}}function G_e(s,e,t){s.animations.mixers.forEach(n=>{const r=Qv.tryGetActionsFromMixer(n);if(r)for(let o=0;o<r.length;o++){const c=r[o].getClip();t.push(c)}}),Array.isArray(e)||(e=[e]);for(const n of e)Qv.tryGetAnimationClipsFromObjectHierarchy(n,t);const i=new Set(t);return Array.from(i)}Object.defineProperty(Nt.prototype,"fov",{get:function(){return this._fov},set:function(s){const e=s!==this._fov;this._fov=s,e&&this.view!==void 0&&this.updateProjectionMatrix()}});Object.defineProperty(Nt.prototype,"near",{get:function(){return this._near},set:function(s){const e=s!==this._near;this._near=s,e&&this.view!==void 0&&this.updateProjectionMatrix()}});Object.defineProperty(Nt.prototype,"far",{get:function(){return this._far},set:function(s){const e=s!==this._far;this._far=s,e&&this.view!==void 0&&this.updateProjectionMatrix()}});const US=ie("debugmissingcamera");ui.registerCallback(Ti.MissingCamera,s=>{var o,a,c;US&&console.warn("Creating missing camera");const e=s.context.scene,t=new Nt;t.name="Default Fallback Camera",e.add(t);const i=new Vi;i.sourceId=((a=(o=s.files)==null?void 0:o[0])==null?void 0:a.src)??"unknown",(c=s.context.domElement.getAttribute("skybox-image"))!=null&&c.length||0>0||s.context.lightmaps.tryGetSkybox(i.sourceId)?i.clearFlags=vp.Skybox:i.clearFlags=vp.SolidColor,i.backgroundColor=new Ei(.5,.5,.5,1),i.fieldOfView=35,i.backgroundBlurriness=.2;const n=Wf(t,i,!0);t.position.x=0,t.position.y=1,t.position.z=2;const r=s.context.domElement;return(r==null?void 0:r.cameraControls)!=!1&&gW(s.context,n),n});ui.registerCallback(Ti.ContextCreated,s=>{if(!s.context.mainCamera){US&&console.log("Will not auto-fit because a default camera exists");return}const e=s.context.domElement;if((e==null?void 0:e.cameraControls)==!0){const t=m8(s.context.mainCamera);if((t==null?void 0:t.isCameraController)==!0){US&&console.log("Will not auto-fit because a camera controller exists");return}gW(s.context)}});function gW(s,e){e=e??s.mainCameraComponent;const t=e==null?void 0:e.gameObject;if(US&&console.log("Creating default camera controls",e==null?void 0:e.name),t){const i=Lb(t,xi);i.sourceId=(e==null?void 0:e.sourceId)??"unknown";const n=s.domElement.getAttribute("auto-rotate");i.autoRotate=n!==void 0&&(n===""||n==="true"),i.autoRotateSpeed=.5,i.autoFit=!0}else console.warn("Missing camera object, can not add orbit controls")}const qO={Context:Dt,glTF:{loadFromURL:NO}};globalThis.Needle!==void 0&&console.warn("Needle Engine is already imported");globalThis.Needle=qO;function mW(s){for(const e in s)qO[e]=s[e]}mW(pfe);mW(Kbe);for(const s of Object.getOwnPropertyNames(re))switch(s){case"prototype":case"constructor":case"length":case"name":continue;default:qO[s]=re[s];break}globalThis.THREE?console.warn("Threejs is already imported"):globalThis.THREE=BZ;class H_e{constructor(e){if(this._retries=0,!Number.isInteger(e)||e<0)throw new Error("Backoff must be a positive integer");this.backoff=e}get retries(){return this._retries}get current(){return this.backoff}next(){return this._retries++,this.backoff}reset(){this._retries=0}}class V_e{constructor(e,t){if(this._retries=0,!Number.isInteger(e)||e<0)throw new Error("Base must be a positive integer or zero");if(t!==void 0&&(!Number.isInteger(t)||t<0))throw new Error("ExpMax must be a undefined, a positive integer or zero");this.base=e,this.expMax=t,this.i=0}get retries(){return this._retries}get current(){return this.base*Math.pow(2,this.i)}next(){return this._retries++,this.i=this.expMax===void 0?this.i+1:Math.min(this.i+1,this.expMax),this.current}reset(){this._retries=0,this.i=0}}class j_e{constructor(e,t,i){if(this.i=0,this._retries=0,e<0)throw new Error("Initial must be a positive number or zero");if(t<0)throw new Error("Increment must be a positive number or zero");if(i!==void 0&&i<0)throw new Error("Max must be undefined, a positive number or zero");if(i!==void 0&&i<e)throw new Error("Max must be undefined or greater than or equal to initial");this.initial=e,this.increment=t,this.max=i}get retries(){return this._retries}get current(){return this.max===void 0?this.initial+this.increment*this.i:Math.min(this.initial+this.increment*this.i,this.max)}next(){return this._retries++,this.i++,this.current}reset(){this._retries=0,this.i=0}}class W_e{constructor(){this.elements=[]}add(e){this.elements.push(e)}clear(){this.elements.length=0}forEach(e){this.elements.forEach(e)}length(){return this.elements.length}isEmpty(){return this.elements.length===0}peek(){return this.elements[0]}read(){return this.elements.shift()}}class q_e{constructor(e){if(!Number.isInteger(e)||e<=0)throw new Error("Capacity must be a positive integer");this.elements=new Array(e+1),this.head=0,this.tail=0}add(e){this.elements[this.head]=e,this.head=(this.head+1)%this.elements.length,this.head===this.tail&&(this.tail=(this.tail+1)%this.elements.length)}clear(){this.head=0,this.tail=0}forEach(e){for(let t=this.tail;t!==this.head;t=(t+1)%this.elements.length)e(this.elements[t])}length(){return this.tail===this.head?0:this.tail<this.head?this.head-this.tail:this.elements.length-this.tail+this.head}isEmpty(){return this.head===this.tail}peek(){return this.isEmpty()?void 0:this.elements[this.tail]}read(){const e=this.peek();return e!==void 0&&(this.tail=(this.tail+1)%this.elements.length),e}}var Ui;(function(s){s.open="open",s.close="close",s.error="error",s.message="message",s.retry="retry",s.reconnect="reconnect"})(Ui||(Ui={}));class AW{constructor(e,t,i){var n,r,o,a,c,l,h,u,f,p,g,y,m,A,b;this._closedByUser=!1,this.handleOpenEvent=v=>this.handleEvent(Ui.open,v),this.handleErrorEvent=v=>this.handleEvent(Ui.error,v),this.handleCloseEvent=v=>this.handleEvent(Ui.close,v),this.handleMessageEvent=v=>this.handleEvent(Ui.message,v),this._url=e,this._protocols=t,this._options={buffer:i==null?void 0:i.buffer,retry:{maxRetries:(n=i==null?void 0:i.retry)===null||n===void 0?void 0:n.maxRetries,instantReconnect:(r=i==null?void 0:i.retry)===null||r===void 0?void 0:r.instantReconnect,backoff:(o=i==null?void 0:i.retry)===null||o===void 0?void 0:o.backoff},listeners:{open:[...(c=(a=i==null?void 0:i.listeners)===null||a===void 0?void 0:a.open)!==null&&c!==void 0?c:[]],close:[...(h=(l=i==null?void 0:i.listeners)===null||l===void 0?void 0:l.close)!==null&&h!==void 0?h:[]],error:[...(f=(u=i==null?void 0:i.listeners)===null||u===void 0?void 0:u.error)!==null&&f!==void 0?f:[]],message:[...(g=(p=i==null?void 0:i.listeners)===null||p===void 0?void 0:p.message)!==null&&g!==void 0?g:[]],retry:[...(m=(y=i==null?void 0:i.listeners)===null||y===void 0?void 0:y.retry)!==null&&m!==void 0?m:[]],reconnect:[...(b=(A=i==null?void 0:i.listeners)===null||A===void 0?void 0:A.reconnect)!==null&&b!==void 0?b:[]]}},this._underlyingWebsocket=this.tryConnect()}get url(){return this._url}get protocols(){return this._protocols}get buffer(){return this._options.buffer}get maxRetries(){return this._options.retry.maxRetries}get instantReconnect(){return this._options.retry.instantReconnect}get backoff(){return this._options.retry.backoff}get closedByUser(){return this._closedByUser}get lastConnection(){return this._lastConnection}get underlyingWebsocket(){return this._underlyingWebsocket}get readyState(){return this._underlyingWebsocket.readyState}get bufferedAmount(){return this._underlyingWebsocket.bufferedAmount}get extensions(){return this._underlyingWebsocket.extensions}get binaryType(){return this._underlyingWebsocket.binaryType}set binaryType(e){this._underlyingWebsocket.binaryType=e}send(e){this.closedByUser||(this._underlyingWebsocket.readyState===this._underlyingWebsocket.OPEN?this._underlyingWebsocket.send(e):this.buffer!==void 0&&this.buffer.add(e))}close(e,t){this.cancelScheduledConnectionRetry(),this._closedByUser=!0,this._underlyingWebsocket.close(e,t)}addEventListener(e,t,i){this._options.listeners[e].push({listener:t,options:i})}removeEventListener(e,t,i){const n=r=>r.listener!==t||r.options!==i;this._options.listeners[e]=this._options.listeners[e].filter(n)}tryConnect(){return this._underlyingWebsocket=new WebSocket(this.url,this.protocols),this._underlyingWebsocket.addEventListener(Ui.open,this.handleOpenEvent),this._underlyingWebsocket.addEventListener(Ui.close,this.handleCloseEvent),this._underlyingWebsocket.addEventListener(Ui.error,this.handleErrorEvent),this._underlyingWebsocket.addEventListener(Ui.message,this.handleMessageEvent),this._underlyingWebsocket}clearWebsocket(){this._underlyingWebsocket.removeEventListener(Ui.open,this.handleOpenEvent),this._underlyingWebsocket.removeEventListener(Ui.close,this.handleCloseEvent),this._underlyingWebsocket.removeEventListener(Ui.error,this.handleErrorEvent),this._underlyingWebsocket.removeEventListener(Ui.message,this.handleMessageEvent),this._underlyingWebsocket.close()}dispatchEvent(e,t){const i=this._options.listeners[e],n=[];i.forEach(({listener:r,options:o})=>{r(this,t),(o===void 0||o.once===void 0||!o.once)&&n.push({listener:r,options:o})}),this._options.listeners[e]=n}handleEvent(e,t){switch(e){case Ui.close:this.dispatchEvent(e,t),this.scheduleConnectionRetryIfNeeded();break;case Ui.open:if(this.backoff!==void 0&&this._lastConnection!==void 0){const i={retries:this.backoff.retries,lastConnection:new Date(this._lastConnection)},n=new CustomEvent(Ui.reconnect,{detail:i});this.dispatchEvent(Ui.reconnect,n),this.backoff.reset()}this._lastConnection=new Date,this.dispatchEvent(e,t),this.sendBufferedData();break;case Ui.retry:this.dispatchEvent(e,t),this.clearWebsocket(),this.tryConnect();break;default:this.dispatchEvent(e,t);break}}sendBufferedData(){if(this.buffer!==void 0)for(let e=this.buffer.read();e!==void 0;e=this.buffer.read())this.send(e)}scheduleConnectionRetryIfNeeded(){if(this.closedByUser||this.backoff===void 0)return;const e=i=>{const n=new CustomEvent(Ui.retry,{detail:i});this.handleEvent(Ui.retry,n)},t={backoff:this._options.retry.instantReconnect===!0?0:this.backoff.next(),retries:this._options.retry.instantReconnect===!0?0:this.backoff.retries,lastConnection:this._lastConnection};(this._options.retry.maxRetries===void 0||t.retries<=this._options.retry.maxRetries)&&(this.retryTimeout=globalThis.setTimeout(()=>e(t),t.backoff))}cancelScheduledConnectionRetry(){globalThis.clearTimeout(this.retryTimeout)}}class X_e{constructor(e){this._url=e}get url(){return this._url}withProtocols(e){return this._protocols=e,this}get protocols(){return this._protocols}withMaxRetries(e){var t;return this._options=Object.assign(Object.assign({},this._options),{retry:Object.assign(Object.assign({},(t=this._options)===null||t===void 0?void 0:t.retry),{maxRetries:e})}),this}get maxRetries(){var e,t;return(t=(e=this._options)===null||e===void 0?void 0:e.retry)===null||t===void 0?void 0:t.maxRetries}withInstantReconnect(e){var t;return this._options=Object.assign(Object.assign({},this._options),{retry:Object.assign(Object.assign({},(t=this._options)===null||t===void 0?void 0:t.retry),{instantReconnect:e})}),this}get instantReconnect(){var e,t;return(t=(e=this._options)===null||e===void 0?void 0:e.retry)===null||t===void 0?void 0:t.instantReconnect}withBackoff(e){var t;return this._options=Object.assign(Object.assign({},this._options),{retry:Object.assign(Object.assign({},(t=this._options)===null||t===void 0?void 0:t.retry),{backoff:e})}),this}get backoff(){var e,t;return(t=(e=this._options)===null||e===void 0?void 0:e.retry)===null||t===void 0?void 0:t.backoff}withBuffer(e){return this._options=Object.assign(Object.assign({},this._options),{buffer:e}),this}get buffer(){var e;return(e=this._options)===null||e===void 0?void 0:e.buffer}onOpen(e,t){return this.addListener(Ui.open,e,t),this}onClose(e,t){return this.addListener(Ui.close,e,t),this}onError(e,t){return this.addListener(Ui.error,e,t),this}onMessage(e,t){return this.addListener(Ui.message,e,t),this}onRetry(e,t){return this.addListener(Ui.retry,e,t),this}onReconnect(e,t){return this.addListener(Ui.reconnect,e,t),this}build(){return new AW(this._url,this._protocols,this._options)}addListener(e,t,i){var n,r,o,a,c,l,h,u,f,p,g,y,m,A,b,v,_,w,E,I,M;return this._options=Object.assign(Object.assign({},this._options),{listeners:{open:(o=(r=(n=this._options)===null||n===void 0?void 0:n.listeners)===null||r===void 0?void 0:r.open)!==null&&o!==void 0?o:[],close:(l=(c=(a=this._options)===null||a===void 0?void 0:a.listeners)===null||c===void 0?void 0:c.close)!==null&&l!==void 0?l:[],error:(f=(u=(h=this._options)===null||h===void 0?void 0:h.listeners)===null||u===void 0?void 0:u.error)!==null&&f!==void 0?f:[],message:(y=(g=(p=this._options)===null||p===void 0?void 0:p.listeners)===null||g===void 0?void 0:g.message)!==null&&y!==void 0?y:[],retry:(b=(A=(m=this._options)===null||m===void 0?void 0:m.listeners)===null||A===void 0?void 0:A.retry)!==null&&b!==void 0?b:[],reconnect:(w=(_=(v=this._options)===null||v===void 0?void 0:v.listeners)===null||_===void 0?void 0:_.reconnect)!==null&&w!==void 0?w:[],[e]:[...(M=(I=(E=this._options)===null||E===void 0?void 0:E.listeners)===null||I===void 0?void 0:I[e])!==null&&M!==void 0?M:[],{listener:t,options:i}]}}),this}}const Y_e=Object.freeze(Object.defineProperty({__proto__:null,ArrayQueue:W_e,ConstantBackoff:H_e,ExponentialBackoff:V_e,LinearBackoff:j_e,RingQueue:q_e,Websocket:AW,WebsocketBuilder:X_e,get WebsocketEvent(){return Ui}},Symbol.toStringTag,{value:"Module"})),Aa={node:"node",material:"material",camera:"camera",light:"light"},ff="KHR_animation_pointer",J_e={CUBICSPLINE:void 0,LINEAR:vl,STEP:cd},o4=Yt.findNode;let a4=!1;class K_e{constructor(e){this.parser=e,this.name=ff,this.animationPointerResolver=null}setAnimationPointerResolver(e){return this.animationPointerResolver=e,this}_patchPropertyBindingFindNode(){a4||(a4=!0,Yt.findNode=function(e,t){if(t.startsWith(".materials.")){const i=t.substring(11).substring(t.indexOf(".")),n=i.indexOf("."),r=n<0?i:i.substring(0,n);let o=null;return e.traverse(a=>{o!==null||a.type!=="Mesh"&&a.type!=="SkinnedMesh"||a.material&&(a.material.uuid===r||a.material.name===r)&&(o=a.material,o!==null&&(i.endsWith(".map")?o=o.map:i.endsWith(".emissiveMap")&&(o=o.emissiveMap)))}),o}else if(t.startsWith(".nodes.")||t.startsWith(".lights.")||t.startsWith(".cameras.")){const i=t.split(".");let n;for(let r=1;r<i.length;r++){const o=i[r];if(o.length==36)n=e.getObjectByProperty("uuid",o);else if(n&&n[o]){const c=Number.parseInt(o);let l=o;c>=0&&(l=c),n=n[l]}else{const c=e.getObjectByName(o);c&&(n=c)}}if(!n){const r=o4(e,i[2]);return r||console.warn(ff+": Property binding not found",t,e,e.name,i),r}return n}return o4(e,t)})}loadAnimationTargetFromChannel(e){const t=e.target,i=t.node!==void 0?t.node:t.id;return this.parser.getDependency("node",i)}loadAnimationTargetFromChannelWithAnimationPointer(e){this._havePatchedPropertyBindings||this._patchPropertyBindingFindNode();const t=e.target,i=t.extensions&&t.extensions[ff]&&t.path&&t.path==="pointer";if(!i)return null;let n,r=Aa.node,o;if(i){const c=t.extensions[ff];let l=c.pointer;if(!l){console.warn("Invalid path",c,t);return}if(l.startsWith("/materials/")?r=Aa.material:l.startsWith("/extensions/KHR_lights_punctual/lights/")?r=Aa.light:l.startsWith("/cameras/")&&(r=Aa.camera),o=this._tryResolveTargetId(l,r),o===null||isNaN(o)){console.warn("Failed resolving animation node id: "+o,l);return}switch(r){case Aa.material:const u=("/materials/"+o.toString()+"/").length,f=l.substring(0,u);switch(n=l.substring(u),n){case"pbrMetallicRoughness/baseColorFactor":n="color";break;case"pbrMetallicRoughness/roughnessFactor":n="roughness";break;case"pbrMetallicRoughness/metallicFactor":n="metalness";break;case"emissiveFactor":n="emissive";break;case"alphaCutoff":n="alphaTest";break;case"occlusionTexture/strength":n="aoMapIntensity";break;case"normalTexture/scale":n="normalScale";break;case"pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/scale":n="map/repeat";break;case"pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/offset":n="map/offset";break;case"emissiveTexture/extensions/KHR_texture_transform/scale":n="emissiveMap/repeat";break;case"emissiveTexture/extensions/KHR_texture_transform/offset":n="emissiveMap/offset";break;case"extensions/KHR_materials_emissive_strength/emissiveStrength":n="emissiveIntensity";break;case"extensions/KHR_materials_transmission/transmissionFactor":n="transmission";break;case"extensions/KHR_materials_ior/ior":n="ior";break;case"extensions/KHR_materials_volume/thicknessFactor":n="thickness";break;case"extensions/KHR_materials_volume/attenuationColor":n="attenuationColor";break;case"extensions/KHR_materials_volume/attenuationDistance":n="attenuationDistance";break;case"extensions/KHR_materials_iridescence/iridescenceFactor":n="iridescence";break;case"extensions/KHR_materials_iridescence/iridescenceIor":n="iridescenceIOR";break;case"extensions/KHR_materials_iridescence/iridescenceThicknessMinimum":n="iridescenceThicknessRange[0]";break;case"extensions/KHR_materials_iridescence/iridescenceThicknessMaximum":n="iridescenceThicknessRange[1]";break;case"extensions/KHR_materials_clearcoat/clearcoatFactor":n="clearcoat";break;case"extensions/KHR_materials_clearcoat/clearcoatRoughnessFactor":n="clearcoatRoughness";break;case"extensions/KHR_materials_sheen/sheenColorFactor":n="sheenColor";break;case"extensions/KHR_materials_sheen/sheenRoughnessFactor":n="sheenRoughness";break;case"extensions/KHR_materials_specular/specularFactor":n="specularIntensity";break;case"extensions/KHR_materials_specular/specularColorFactor":n="specularColor";break}l=f+n;break;case Aa.node:const p=("/nodes/"+o.toString()+"/").length,g=l.substring(0,p);switch(n=l.substring(p),n){case"translation":n="position";break;case"rotation":n="quaternion";break;case"scale":n="scale";break;case"weights":n="morphTargetInfluences";break}l=g+n;break;case Aa.light:const y=("/extensions/KHR_lights_punctual/lights/"+o.toString()+"/").length;switch(n=l.substring(y),n){case"color":break;case"intensity":break;case"spot/innerConeAngle":n="penumbra";break;case"spot/outerConeAngle":n="angle";break;case"range":n="distance";break}l="/lights/"+o.toString()+"/"+n;break;case Aa.camera:const m=("/cameras/"+o.toString()+"/").length,A=l.substring(0,m);switch(n=l.substring(m),n){case"perspective/yfov":n="fov";break;case"perspective/znear":case"orthographic/znear":n="near";break;case"perspective/zfar":case"orthographic/zfar":n="far";break;case"perspective/aspect":n="aspect";break;case"orthographic/xmag":n="zoom";break;case"orthographic/ymag":n="zoom";break}l=A+n;break}const h=this.animationPointerResolver;h&&h.resolvePath&&(l=h.resolvePath(l)),t.extensions[ff].pointer=l}if(o===null||isNaN(o)){console.warn("Failed resolving animation node id: "+o,t);return}let a;return r===Aa.node?a=this.parser.getDependency("node",o):r===Aa.material?a=this.parser.getDependency("material",o):r===Aa.light?a=this.parser.getDependency("light",o):r===Aa.camera?a=this.parser.getDependency("camera",o):console.error("Unhandled type",r),a}createAnimationTracksWithAnimationPointer(e,t,i,n,r){if(!(r.extensions&&r.extensions[ff]&&r.path&&r.path==="pointer"))return null;let a=r.extensions[ff].pointer;if(!a)return null;const c=[];a=a.replaceAll("/",".");const l=a.split(".");var u=e.name!==void 0&&e.name!==null?e.name:e.uuid;if(l[2]=u,l[3]==="morphTargetInfluences"&&e.type==="Group"){for(const p of e.children)p instanceof bo&&p.morphTargetInfluences&&(l[3]=p.name,l[4]="morphTargetInfluences",f(this.parser));return c}f(this.parser);function f(p){a=l.join(".");let g;switch(i.itemSize){case 1:g=Fh;break;case 2:case 3:g=bl;break;case 4:a.endsWith(".quaternion")?g=Fa:g=CE;break}const y=n.interpolation!==void 0?J_e[n.interpolation]:vl;let m=p._getArrayFromAccessor(i);a.endsWith(".fov")&&(m=m.map(b=>b/Math.PI*180));const A=new g(a,t.array,m,y);if(y==="CUBICSPLINE"&&p._createCubicSplineTrackInterpolant(A),c.push(A),a&&i.itemSize===4&&a.startsWith(".materials.")&&a.endsWith(".color")){const b=new Float32Array(m.length/4);for(let _=0,w=m.length/4;_<w;_+=1)b[_]=m[_*4+3];const v=new g(a.replace(".color",".opacity"),t.array,b,y);y==="CUBICSPLINE"&&p._createCubicSplineTrackInterpolant(A),c.push(v)}}return c}_tryResolveTargetId(e,t){let i="";return t==="node"?i=e.substring(7):t==="material"?i=e.substring(11):t==="light"?i=e.substring(39):t==="camera"&&(i=e.substring(9)),i=i.substring(0,i.indexOf("/")),Number.parseInt(i)}loadAnimation(e){const t=this,i=this.parser.json,n=this.parser,r=i.animations[e],o=r.name?r.name:"animation_"+e,a=[],c=[],l=[],h=[],u=[];for(let f=0,p=r.channels.length;f<p;f++){const g=r.channels[f],y=r.samplers[g.sampler],m=g.target,A=r.parameters!==void 0?r.parameters[y.input]:y.input,b=r.parameters!==void 0?r.parameters[y.output]:y.output;let v=t.loadAnimationTargetFromChannelWithAnimationPointer(g);v||(v=t.loadAnimationTargetFromChannel(g)),a.push(v),c.push(n.getDependency("accessor",A)),l.push(n.getDependency("accessor",b)),h.push(y),u.push(m)}return Promise.all([Promise.all(a),Promise.all(c),Promise.all(l),Promise.all(h),Promise.all(u)]).then(function(f){const p=f[0],g=f[1],y=f[2],m=f[3],A=f[4],b=[];for(let v=0,_=p.length;v<_;v++){const w=p[v],E=g[v],I=y[v],M=m[v],R=A[v];if(w===void 0)continue;w.updateMatrix&&(w.updateMatrix(),w.matrixAutoUpdate=!0);let S=t.createAnimationTracksWithAnimationPointer(w,E,I,M,R);if(S||(S=n._createAnimationTracks(w,E,I,M,R)),S)for(let T=0;T<S.length;T++)b.push(S[T])}return new no(o,void 0,b)})}}const Z_e=Object.freeze(Object.defineProperty({__proto__:null,GLTFAnimationPointerExtension:K_e},Symbol.toStringTag,{value:"Module"}));exports.$physicsKey=R_e;exports.ActionBuilder=pi;exports.ActionCollection=ik;exports.ActionModel=go;exports.Addressables=L5;exports.AlignmentConstraint=Nb;exports.AmbientMode=Hm;exports.Animation=Rr;exports.AnimationCurve=Bp;exports.AnimationExtension=Vb;exports.AnimationTrackHandler=gI;exports.Animator=or;exports.AnimatorConditionMode=Ou;exports.AnimatorController=ea;exports.AnimatorControllerParameterType=Uk;exports.AnimatorStateInfo=_0;exports.Antialiasing=Wb;exports.Application=gl;exports.ApplicationEvents=_S;exports.AssetDatabase=e5;exports.AssetReference=$t;exports.AudioExtension=Sd;exports.AudioListener=nd;exports.AudioSource=Un;exports.AudioTrackHandler=Xf;exports.Avatar=Pp;exports.AvatarBlink_Simple=kp;exports.AvatarEyeLook_Rotation=LA;exports.AvatarLoader=Vk;exports.AvatarMarker=As;exports.AvatarModel=_I;exports.Avatar_Brain_LookAt=Yv;exports.Avatar_MouthShapes=Xb;exports.Avatar_MustacheShake=Gk;exports.Avatar_POI=Al;exports.Axes=Sm;exports.AxesHelper=FA;exports.BUILD_TIME=D2;exports.BaseUIComponent=za;exports.BasicIKConstraint=Wk;exports.BehaviorExtension=xI;exports.BehaviorModel=rs;exports.Behaviour=Te;exports.Bloom=Op;exports.BoxCollider=NA;exports.BoxGizmo=Fp;exports.BoxHelperComponent=Da;exports.Button=Hh;exports.ButtonsFactory=vc;exports.CallDirection=U6;exports.CallInfo=dA;exports.Camera=Vi;exports.CameraTargetReachedEvent=qv;exports.Canvas=ar;exports.CanvasGroup=pd;exports.CapsuleCollider=Nh;exports.ChangeMaterialOnClick=GA;exports.ChangeTransformOnClick=Np;exports.CharacterController=zp;exports.CharacterControllerInput=jh;exports.ChromaticAberration=e_;exports.CircularBuffer=Ua;exports.ClearFlags=vp;exports.ClipExtrapolation=Xc;exports.Collider=ra;exports.Collision=hW;exports.CollisionDetectionMode=uI;exports.ColorAdjustments=xl;exports.ColorBySpeedModule=Gp;exports.ColorOverLifetimeModule=s_;exports.Component=Te;exports.ComponentEvents=Mb;exports.ComponentLifecycleEvents=Tb;exports.ConnectionEvents=L9;exports.ContactPoint=lW;exports.ContactShadows=Pl;exports.Context=Dt;exports.ContextArgs=ife;exports.ContextEvent=Ti;exports.ContextRegistry=ui;exports.ControlTrackHandler=mI;exports.CustomBranding=Pd;exports.CustomShader=Qo;exports.DefaultReflectionMode=SS;exports.Deletable=dO;exports.DeleteBox=PI;exports.DepthOfField=Pc;exports.DeviceFlag=DI;exports.DocumentExtension=fO;exports.DragControls=Ha;exports.DragMode=lj;exports.DropListener=Dd;exports.Duplicatable=Wp;exports.EmissionModule=Rl;exports.EmphasizeOnClick=HA;exports.EngineLoadingView=U0;exports.EventList=Xn;exports.EventListEvent=hI;exports.EventSystem=yo;exports.EventTrigger=OI;exports.FieldWithDefault=cO;exports.FileReference=Gm;exports.FileReferenceSerializer=U5;exports.FileSpawnModel=uj;exports.File_Event=hj;exports.FixedJoint=yO;exports.FlyControls=vO;exports.Fog=KA;exports.FrameEvent=Zi;exports.GENERATOR=NE;exports.GameObject=re;exports.Gizmos=vt;exports.GltfExport=h_;exports.GltfExportBox=_O;exports.GltfLoadEvent=$f;exports.GltfLoadEventType=Gj;exports.Gradient=Td;exports.Graphic=Up;exports.GraphicRaycaster=dI;exports.Graphics=dc;exports.GridHelper=ZA;exports.GridLayoutGroup=eO;exports.GroundProjectedEnv=qp;exports.GroupActionModel=ju;exports.HideFlags=l6;exports.HideOnStart=iO;exports.HingeJoint=l_;exports.HorizontalLayoutGroup=$k;exports.HostData=nfe;exports.Image=zA;exports.ImageReference=zm;exports.ImageReferenceSerializer=F5;exports.InheritVelocityModule=Rd;exports.Input=G5;exports.InputEventQueue=Kc;exports.InputEvents=fn;exports.InputField=Xp;exports.InstanceHandle=Jf;exports.InstancingHandler=Yf;exports.InstancingUtil=La;exports.InstantiateEvent=e6;exports.InstantiateIdProvider=Ls;exports.InstantiateOptions=Rc;exports.Interactable=uO;exports.JoinedRoomResponse=Ede;exports.KeyEventArgs=Oue;exports.Keyframe=Wa;exports.LODGroup=d_;exports.LODModel=Yp;exports.LeftRoomResponse=Ide;exports.Light=Bo;exports.LightData=Y9;exports.LimitVelocityOverLifetimeModule=us;exports.LoadingElementOptions=yne;exports.LogStats=wO;exports.LogType=Xo;exports.LookAt=Jp;exports.LookAtConstraint=Rp;exports.MainModule=dr;exports.MarkerType=Fk;exports.MaskableGraphic=Jb;exports.Mathf=tt;exports.MeshCollider=Lp;exports.MeshRenderer=n_;exports.MinMaxCurve=yt;exports.MinMaxGradient=Mo;exports.NEEDLE_progressive=mi;exports.NEKeyboardEvent=g0;exports.NEPointerEvent=ch;exports.NeedleEngine=ui;exports.NeedleEngineHTMLElement=QO;exports.NeedleGltfLoader=FO;exports.NeedleMenu=Dl;exports.NeedlePatchesKey=mC;exports.NeedleUSDZExporter=WV;exports.NeedleXRController=vk;exports.NeedleXRSession=St;exports.NeedleXRSync=N9;exports.NeedleXRUtils=z9;exports.NestedGltf=QI;exports.NetworkConnection=U9;exports.NetworkedStreamEvents=hl;exports.NetworkedStreams=qb;exports.Networking=$A;exports.NewInstanceModel=s6;exports.NoiseModule=Di;exports.ObjectRaycaster=ia;exports.ObjectUtils=Db;exports.OffsetConstraint=Kp;exports.OneEuroFilter=lC;exports.OneEuroFilterXYZ=C2;exports.OpenURL=ey;exports.OrbitControls=xi;exports.Outline=QA;exports.OwnershipEvent=F9;exports.OwnershipModel=Mk;exports.Padding=Id;exports.ParticleBurst=Zv;exports.ParticleSubEmitter=XI;exports.ParticleSystem=as;exports.ParticleSystemBaseBehaviour=kd;exports.ParticleSystemRenderer=Ja;exports.ParticleSystemShapeType=RS;exports.PeerHandle=Vm;exports.PeerNetworking=O9;exports.Physics=j9;exports.PhysicsExtension=TI;exports.PhysicsMaterialCombine=Ms;exports.PixelationEffect=g_;exports.PlayAnimationOnClick=bp;exports.PlayAudioOnClick=gd;exports.PlayableDirector=fd;exports.PlayerColor=fA;exports.PlayerState=Oa;exports.PlayerStateEvent=k6;exports.PlayerSync=OA;exports.PlayerView=W9;exports.PlayerViewManager=q9;exports.PointerEventData=PA;exports.PointerType=tI;exports.PostProcessingEffect=kr;exports.PostProcessingHandler=SI;exports.PreliminaryAction=VA;exports.PreliminaryTrigger=Zb;exports.PrimitiveType=mp;exports.Progress=ri;exports.PromiseAllWithErrors=kE;exports.PromiseErrorResult=aR;exports.RGBAColor=Ei;exports.RapierPhysics=yf;exports.RawImage=CI;exports.RaycastOptions=Ic;exports.Rect=Jk;exports.RectTransform=Dr;exports.ReflectionProbe=WA;exports.RegisteredAnimationInfo=yI;exports.RemoteSkybox=Cl;exports.RenderTexture=id;exports.RenderTextureSerializer=C6;exports.Renderer=Nn;exports.RendererData=X9;exports.RendererLightmap=Jv;exports.Rigidbody=Qi;exports.RigidbodyConstraints=zn;exports.RoomEvents=Jt;exports.RotationBySpeedModule=ca;exports.RotationOverLifetimeModule=Xa;exports.SceneLightSettings=TS;exports.SceneSwitcher=Ur;exports.ScreenCapture=Od;exports.ScreenSpaceAmbientOcclusion=Yh;exports.ScreenSpaceAmbientOcclusionN8=Dc;exports.SendQueue=Ia;exports.SerializationContext=pk;exports.SetActiveOnClick=Qp;exports.ShadowCatcher=v_;exports.ShapeModule=In;exports.SignalAsset=Gb;exports.SignalReceiver=kA;exports.SignalReceiverEvent=DA;exports.SignalTrackHandler=Xv;exports.Size=Yk;exports.SizeBySpeedModule=co;exports.SizeOverLifetimeModule=Bd;exports.SkinnedMeshRenderer=lO;exports.SmoothFollow=Ld;exports.SpatialGrabRaycaster=Wv;exports.SpatialHtml=b_;exports.SpatialTrigger=x_;exports.SpatialTriggerReceiver=yl;exports.SpectatorCamera=JI;exports.SphereCollider=UA;exports.SphereIntersection=V9;exports.SphereOverlapResult=uW;exports.Sprite=qh;exports.SpriteData=XA;exports.SpriteRenderer=Ya;exports.SpriteSheet=r_;exports.StateMachineBehaviour=fpe;exports.StreamEndedEvent=L6;exports.StreamReceivedEvent=F6;exports.SubEmitterSystem=nb;exports.SyncedCamera=KI;exports.SyncedRoom=Ol;exports.SyncedTransform=dd;exports.TapGestureTrigger=nO;exports.TeleportTarget=MI;exports.TestRunner=DO;exports.TestSceneUtils=k_e;exports.TestSimulateUserData=kO;exports.Text=Lr;exports.TextBuilder=BI;exports.TextExtension=o_;exports.TextureSheetAnimationModule=fr;exports.TiltShiftEffect=Ll;exports.Time=J9;exports.ToneMapping=jA;exports.TrackHandler=Hb;exports.TrackType=No;exports.TrailModule=yn;exports.TransformData=is;exports.TransformGizmo=eg;exports.TriggerBuilder=ks;exports.TriggerModel=Dh;exports.TypeStore=K;exports.UIRaycastUtils=fI;exports.UIRootComponent=Qb;exports.USDObject=nr;exports.USDWriter=jV;exports.USDZExporter=Yn;exports.USDZText=Xu;exports.USDZUIExtension=RI;exports.Upload_Result=nP;exports.UriSerializer=S6;exports.UsageMarker=a_;exports.UserJoinedOrLeftRoomModel=Mde;exports.VERSION=ka;exports.VariantAction=tk;exports.VelocityOverLifetimeModule=Mn;exports.VerticalLayoutGroup=Zk;exports.VideoPlayer=_s;exports.ViewDevice=td;exports.Vignette=tg;exports.VisibilityAction=$b;exports.Voip=Dp;exports.Volume=i_;exports.VolumeParameter=Lt;exports.VolumeProfile=jb;exports.WaitForFrames=Ode;exports.WaitForPromise=H9;exports.WaitForSeconds=G9;exports.Watch=Bh;exports.WebARCameraBackground=$I;exports.WebARSessionRoot=ao;exports.WebXR=Us;exports.WebXRButtonFactory=sd;exports.WebXRImageTracking=pA;exports.WebXRImageTrackingModel=Fl;exports.WebXRPlaneTracking=Fd;exports.WebXRTrackedImage=Yu;exports.XRControllerFollow=C_;exports.XRControllerModel=wl;exports.XRControllerMovement=Ga;exports.XRFlag=jo;exports.XRRig=e1;exports.XRState=tr;exports.XRStateFlag=nl;exports.__Ignore=LO;exports.__internalNotifyObjectDestroyed=r5;exports.activeInHierarchyFieldName=Rh;exports.addAttributeChangeCallback=mH;exports.addComponent=ml;exports.addCustomExtensionPlugin=Sme;exports.addFile=dj;exports.addFileFromUrl=fj;exports.addGltfLoadEventListener=s_e;exports.addNewComponent=Wf;exports.addPatch=YE;exports.apply=cI;exports.applyHMRChanges=A_e;exports.beginListenDestroy=n6;exports.beginListenFileSpawn=pj;exports.beginListenInstantiate=r6;exports.binaryIdentifierCasts=_k;exports.build_scene_functions=tfe;exports.builtinComponentKeyName=_f;exports.calculateProgress01=O2;exports.clearBalloonMessages=CH;exports.clearOverlayMessages=CH;exports.colorSerializer=Cfe;exports.componentSerializer=MC;exports.copyTexture=v8;exports.createLoader=UO;exports.createMotion=P6;exports.debugNet=Jr;exports.debugOwner=v0;exports.deepClone=vb;exports.delay=_l;exports.delayForFrames=fH;exports.deserializeObject=AS;exports.destroy=Qa;exports.destroyComponentInstance=y6;exports.disposeObjectResources=Wi;exports.disposeStream=Ih;exports.download=O5;exports.download_file=mk;exports.editorGuidKeyName=F0;exports.effectsOrder=BP;exports.enableSpatialConsole=sA;exports.eventListSerializer=Tfe;exports.exportAsGLTF=Q_e;exports.findByGuid=Ob;exports.findObjectOfType=kk;exports.findObjectsOfType=b6;exports.findResourceUsers=ok;exports.fitObjectIntoVolume=b8;exports.foreachComponent=yp;exports.foreachComponentEnumerator=Pk;exports.forward=Lie;exports.generateQRCode=yH;exports.generateSeed=oI;exports.getBoundingBox=ld;exports.getCameraController=m8;exports.getComponent=Mp;exports.getComponentInChildren=Ub;exports.getComponentInParent=Vv;exports.getComponents=Fb;exports.getComponentsInChildren=RA;exports.getComponentsInParent=lI;exports.getFormattedDate=zV;exports.getIconElement=Ao;exports.getIconTexture=AP;exports.getIp=zZ;exports.getIpAndLocation=GZ;exports.getIpCloudflare=QZ;exports.getLoader=wc;exports.getOrAddComponent=Lb;exports.getParam=ie;exports.getParentHierarchyPath=Nie;exports.getPath=LZ;exports.getPeerOptions=xde;exports.getPeerjsInstance=k9;exports.getResourceUserCount=Qce;exports.getTempQuaternion=Rf;exports.getTempVector=kn;exports.getUrlParams=yb;exports.getWorldDirection=I2;exports.getWorldEuler=M2;exports.getWorldPosition=Ot;exports.getWorldQuaternion=Fi;exports.getWorldRotation=wb;exports.getWorldScale=Ji;exports.hasCommercialLicense=Ph;exports.hasIndieLicense=k2;exports.hasPointerEventComponent=SP;exports.hasProLicense=Zu;exports.hash=gk;exports.hideDebugConsole=S8;exports.imageToCanvas=YV;exports.instantiate=BA;exports.invokeAfterImportPluginHooks=aO;exports.invokeXRSessionEnd=Q5;exports.invokeXRSessionStart=N5;exports.isActiveInHierarchy=h6;exports.isActiveSelf=TA;exports.isAndroidDevice=gH;exports.isAnimationAction=y8;exports.isDebugMode=PZ;exports.isDesktop=lp;exports.isDestroyed=Ap;exports.isDevEnvironment=ht;exports.isDisposed=Uce;exports.isExporting=L_e;exports.isHostedOnGlitch=lH;exports.isHotReloading=f_e;exports.isIconElement=K9;exports.isLocalNetwork=ro;exports.isMobileDevice=na;exports.isMozillaXR=Nf;exports.isQuest=DE;exports.isResourceTrackingEnabled=i5;exports.isSafari=Om;exports.isUsingInstancing=aI;exports.isiOS=hp;exports.loadSync=NO;exports.logHierarchy=cS;exports.lookAtInverse=Bie;exports.lookAtObject=xb;exports.makeId=kZ;exports.makeIdFromRandomWords=KD;exports.makeNameSafeForUSD=Ec;exports.markAsInstancedRendered=u6;exports.microphonePermissionsGranted=oR;exports.nameof=RZ;exports.nameofFactory=hH;exports.objectSerializer=w6;exports.offXRSessionEnd=Sue;exports.offXRSessionStart=Cue;exports.onAfterRender=Ffe;exports.onBeforeRender=Lfe;exports.onClear=kfe;exports.onDestroy=Ofe;exports.onInitialized=Dfe;exports.onStart=I6;exports.onUpdate=M6;exports.onXRSessionEnd=Ak;exports.onXRSessionStart=eI;exports.parseSync=Vj;exports.placeOnSurface=_8;exports.postprocessFBXMaterials=x8;exports.prefix=Nfe;exports.pushState=uH;exports.randomNumber=OZ;exports.registerBinaryType=xk;exports.registerComponent=sI;exports.registerComponentExtension=sO;exports.registerCustomEffectType=qa;exports.registerExportExtensions=oO;exports.registerExtensions=rO;exports.registerHotReloadType=p_e;exports.registerLoader=YD;exports.registerPrefabProvider=a6;exports.registerType=uce;exports.relativePathPrefix=pH;exports.removeAttributeChangeCallback=AH;exports.removeComponent=Dk;exports.removeCustomImportExtensionType=Eme;exports.removeGltfLoadEventListener=r_e;exports.removePatch=kce;exports.resolveUrl=vd;exports.sanitizeString=dH;exports.saveImage=fW;exports.screenshot=O_e;exports.screenshot2=dW;exports.sendDestroyed=i6;exports.serializable=x;exports.serializeObject=T5;exports.serializeable=SA;exports.setActive=Z0;exports.setAllowBalloonMessages=xH;exports.setAllowOverlayMessages=WZ;exports.setAutoFitEnabled=gR;exports.setCameraController=fR;exports.setDestroyed=f6;exports.setDevEnvironment=qie;exports.setDisposable=rk;exports.setDontDestroy=bP;exports.setOrAddParamsToUrl=rR;exports.setParam=DZ;exports.setParamWithoutReload=tS;exports.setPeerOptions=wde;exports.setResourceTrackingEnabled=Fce;exports.setState=JD;exports.setWorldEuler=T2;exports.setWorldPosition=Os;exports.setWorldPositionXYZ=dp;exports.setWorldQuaternion=Na;exports.setWorldQuaternionXYZW=E2;exports.setWorldRotation=B2;exports.setWorldRotationXYZ=Cb;exports.setWorldScale=nA;exports.showBalloonError=R2;exports.showBalloonMessage=pn;exports.showBalloonWarning=Ni;exports.showDebugConsole=P2;exports.slerp=Mie;exports.syncDestroy=rI;exports.syncField=Qk;exports.syncInstantiate=Rk;exports.textureToCanvas=Qie;exports.tryCastBinary=H5;exports.tryDetermineFileTypeFromBinary=Nj;exports.tryDetermineFileTypeFromURL=Uj;exports.tryFindObject=eA;exports.tryGetGuid=V5;exports.unregisterHotReloadType=g_e;exports.unwatchWrite=ZD;exports.upload_file=k5;exports.useForAutoFit=A8;exports.validate=ur;exports.watchWrite=PE;
7501
+ `,r)}}getAROverlayContainer(){return this._overlay_ar.createOverlayContainer(this)}getVROverlayContainer(){for(let t=0;t<this.children.length;t++){const i=this.children[t];if(i.classList.contains("vr"))return i}return null}onEnterAR(t){var n;this.onSetupAR();const i=this.getAROverlayContainer();this._overlay_ar.onBegin(this._context,i,t),this.dispatchEvent(new CustomEvent("enter-ar",{detail:{session:t,context:this._context,htmlContainer:(n=this._overlay_ar)==null?void 0:n.ARContainer}}))}onExitAR(t){var i;this._overlay_ar.onEnd(this._context),this.onSetupDesktop(),this.dispatchEvent(new CustomEvent("exit-ar",{detail:{session:t,context:this._context,htmlContainer:(i=this._overlay_ar)==null?void 0:i.ARContainer}}))}onEnterVR(t){this.onSetupVR(),this.dispatchEvent(new CustomEvent("enter-vr",{detail:{session:t,context:this._context}}))}onExitVR(t){this.onSetupDesktop(),this.dispatchEvent(new CustomEvent("exit-vr",{detail:{session:t,context:this._context}}))}onSetupAR(){this.classList.add(Jy),this.classList.remove(Ky);const t=this.getAROverlayContainer();ln&&console.warn("onSetupAR:",t),t&&(t.classList.add(Jy),t.classList.remove(Ky)),this.foreachHtmlElement(i=>this.setupElementsForMode(i,B8))}onSetupVR(){this.classList.remove(Jy),this.classList.remove(Ky),this.foreachHtmlElement(t=>this.setupElementsForMode(t,Xj))}onSetupDesktop(){this.classList.remove(Jy),this.classList.add(Ky);const t=this.getAROverlayContainer();t&&(t.classList.remove(Jy),t.classList.add(Ky)),this.foreachHtmlElement(i=>this.setupElementsForMode(i,Yj))}setupElementsForMode(t,i,n=null){var o,a;if(t===((a=(o=this._context)==null?void 0:o.renderer)==null?void 0:a.domElement)||t.id==="VRButton"||t.id==="ARButton")return;if(t.classList.contains(i))t.style.visibility="visible",t.style.display==="none"&&(t.style.display="block");else for(const c of a_e)t.classList.contains(c)&&(t.style.visibility="hidden",t.style.display="none")}foreachHtmlElement(t){for(let i=0;i<this.children.length;i++){const n=this.children[i];n.style&&t(n)}}onBeforeBeginLoading(){const t=this.getAttribute("dracoDecoderPath");t&&(ln&&console.log("using custom draco decoder path",t),SN(t));const i=this.getAttribute("dracoDecoderType");i&&(ln&&console.log("using custom draco decoder type",i),EN(i));const n=this.getAttribute("ktx2DecoderPath");n&&(ln&&console.log("using custom ktx2 decoder path",n),IN(n))}}typeof window<"u"&&!window.customElements.get(Vz)&&window.customElements.define(Vz,QO);function l_e(s){if(s.startsWith("blob:"))return"blob";const e=s.split("/");let t=e[e.length-1];const i=t.indexOf("?");i>0&&(t=t.substring(0,i));const n=t.indexOf("=");n>0&&(t=t.substring(n));const r=t.split(".").pop();if((r==="glb"||r==="gltf")&&(t=t.substring(0,t.length-4)),t=decodeURIComponent(t),t.length>3){let o="";for(let a=0;a<t.length;a++){let c=t[a];if(c===" "&&o.length<=0)continue;const l=o.length===0,h=c>="0"&&c<="9";l==!1&&c===c.toUpperCase()&&!h?o+=" "+c:(l&&(c=c.toUpperCase()),o+=c)}return ln&&console.log("displayName",t,o),o}return ln&&console.log("displayName",t),t}const h_e=Object.freeze(Object.defineProperty({__proto__:null,NeedleEngineHTMLElement:QO},Symbol.toStringTag,{value:"Module"}));function u_e(){gl.registerWaitForAllowAudio(()=>{const s=TE.getContext();s.addEventListener("statechange",()=>{setTimeout(()=>{const e=s.state;(e==="suspended"||e==="interrupted")&&s.resume().then(()=>{console.log("AudioContext resumed successfully")}).catch(t=>{console.log("Failed to resume AudioContext: "+t)})},500)})})}setTimeout(u_e,1e3);const FC=ie("debughotreload");let sb=!1;const sv=new Map;function d_e(){return sb}function f_e(s){var i;if(sb)return;const t=s.constructor.name;sv.has(t)?(i=sv.get(t))==null||i.push(s):sv.set(t,[s])}function p_e(s){if(sb)return;const t=s.constructor.name,i=sv.get(t);if(!i)return;const n=i.indexOf(s);n!==-1&&i.splice(n,1)}let jz=!1;function g_e(){if(FC||jz)return;jz=!0;const s=console.error;console.error=(...e)=>{if(e.length){const t=e[0];if(typeof t=="string"&&t.includes("[hmr] Failed to reload ")){console.log("[Needle Engine] Hot reloading failed"),window.location.reload();return}}s.apply(console,e)}}function m_e(s){FC&&console.log("[HMR] Apply changes",s,Object.keys(s)),g_e();for(const e of Object.keys(s))try{sb=!0;const t=K.get(e);if(!t){FC&&console.log("[HMR] Type not found: "+e);continue}const i=s[e],n=sv.get(i.name);let r="[Needle Engine] Updating type: "+e;const o=(n==null?void 0:n.length)??-1;o>0?r+=" x"+o:r+=" - no instances",console.log(r);const a=Object.getOwnPropertyNames(t.prototype),c=Object.getOwnPropertyDescriptors(i.prototype);for(const l in c)c[l].writable&&(t.prototype[l]=s[e].prototype[l]);for(const l of a)c[l]||delete t.prototype[l];if(n){const l=new i,h=Object.getOwnPropertyDescriptors(l);for(const u of n){const f=u,p=f.isComponent===!0,g=p?f.activeAndEnabled:!0,y=p?f.context:void 0;try{if(p&&y&&yh(f,y),p&&g&&(f.enabled=!1),u.onBeforeHotReloadFields&&u.onBeforeHotReloadFields()===!1)continue;for(const m in h)if(h[m].writable){if(u[m]===void 0)u[m]=l[m];else if(typeof u[m]=="function"&&!u[m].prototype){const b=u[m],v=b.name,_="bound ";if(v===_)continue;const w=b.name.substring(_.length),E=i.prototype[w];E&&(u[m]=E.bind(u))}}u.onAfterHotReloadFields&&u.onAfterHotReloadFields()}finally{p&&y&&ak(f,y),p&&g&&(f.enabled=!0)}}}}catch(t){if(FC)console.error(t);else return!1}finally{sb=!1,al(Xo.Log,"Script changes applied (HMR)")}return!0}let Ue;const rb=new Array(128).fill(void 0);rb.push(void 0,null,!0,!1);rb.length;let Hw=null;function Wz(){return Hw!==null&&Hw.byteLength!==0||(Hw=new Int32Array(Ue.memory.buffer)),Hw}const A_e=typeof TextDecoder<"u"?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):{decode:()=>{throw Error("TextDecoder not available")}};typeof TextDecoder<"u"&&A_e.decode();function At(s,e){if(!(s instanceof e))throw new Error(`expected instance of ${e.name}`);return s.ptr}let Vw=null;function y_e(){return Vw!==null&&Vw.byteLength!==0||(Vw=new Float32Array(Ue.memory.buffer)),Vw}let rv=128;function qz(s){if(rv==1)throw new Error("out of js stack");return rb[--rv]=s,rv}let jw=null;function v_e(){return jw!==null&&jw.byteLength!==0||(jw=new Uint32Array(Ue.memory.buffer)),jw}let zo=0;function uf(s,e){const t=e(4*s.length,4)>>>0;return y_e().set(s,t/4),zo=s.length,t}function Ww(s,e){const t=e(4*s.length,4)>>>0;return v_e().set(s,t/4),zo=s.length,t}const Ws=Object.freeze({Ball:0,0:"Ball",Cuboid:1,1:"Cuboid",Capsule:2,2:"Capsule",Segment:3,3:"Segment",Polyline:4,4:"Polyline",Triangle:5,5:"Triangle",TriMesh:6,6:"TriMesh",HeightField:7,7:"HeightField",Compound:8,8:"Compound",ConvexPolyhedron:9,9:"ConvexPolyhedron",Cylinder:10,10:"Cylinder",Cone:11,11:"Cone",RoundCuboid:12,12:"RoundCuboid",RoundTriangle:13,13:"RoundTriangle",RoundCylinder:14,14:"RoundCylinder",RoundCone:15,15:"RoundCone",RoundConvexPolyhedron:16,16:"RoundConvexPolyhedron",HalfSpace:17,17:"HalfSpace"});class b_e{__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,e}free(){const e=this.__destroy_into_raw();Ue.__wbg_raweventqueue_free(e)}constructor(e){const t=Ue.raweventqueue_new(e);return this.__wbg_ptr=t>>>0,this}drainCollisionEvents(e){try{Ue.raweventqueue_drainCollisionEvents(this.__wbg_ptr,qz(e))}finally{rb[rv++]=void 0}}drainContactForceEvents(e){try{Ue.raweventqueue_drainContactForceEvents(this.__wbg_ptr,qz(e))}finally{rb[rv++]=void 0}}clear(){Ue.raweventqueue_clear(this.__wbg_ptr)}}class Sr{static __wrap(e){e>>>=0;const t=Object.create(Sr.prototype);return t.__wbg_ptr=e,t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,e}free(){const e=this.__destroy_into_raw();Ue.__wbg_rawgenericjoint_free(e)}static generic(e,t,i,n){At(e,lt),At(t,lt),At(i,lt);const r=Ue.rawgenericjoint_generic(e.__wbg_ptr,t.__wbg_ptr,i.__wbg_ptr,n);return r===0?void 0:Sr.__wrap(r)}static spring(e,t,i,n,r){At(n,lt),At(r,lt);const o=Ue.rawgenericjoint_spring(e,t,i,n.__wbg_ptr,r.__wbg_ptr);return Sr.__wrap(o)}static rope(e,t,i){At(t,lt),At(i,lt);const n=Ue.rawgenericjoint_rope(e,t.__wbg_ptr,i.__wbg_ptr);return Sr.__wrap(n)}static spherical(e,t){At(e,lt),At(t,lt);const i=Ue.rawgenericjoint_spherical(e.__wbg_ptr,t.__wbg_ptr);return Sr.__wrap(i)}static prismatic(e,t,i,n,r,o){At(e,lt),At(t,lt),At(i,lt);const a=Ue.rawgenericjoint_prismatic(e.__wbg_ptr,t.__wbg_ptr,i.__wbg_ptr,n,r,o);return a===0?void 0:Sr.__wrap(a)}static fixed(e,t,i,n){At(e,lt),At(t,Zs),At(i,lt),At(n,Zs);const r=Ue.rawgenericjoint_fixed(e.__wbg_ptr,t.__wbg_ptr,i.__wbg_ptr,n.__wbg_ptr);return Sr.__wrap(r)}static revolute(e,t,i){At(e,lt),At(t,lt),At(i,lt);const n=Ue.rawgenericjoint_revolute(e.__wbg_ptr,t.__wbg_ptr,i.__wbg_ptr);return n===0?void 0:Sr.__wrap(n)}}class zO{static __wrap(e){e>>>=0;const t=Object.create(zO.prototype);return t.__wbg_ptr=e,t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,e}free(){const e=this.__destroy_into_raw();Ue.__wbg_rawpointprojection_free(e)}point(){const e=Ue.rawpointprojection_point(this.__wbg_ptr);return lt.__wrap(e)}isInside(){return Ue.rawpointprojection_isInside(this.__wbg_ptr)!==0}}class GO{static __wrap(e){e>>>=0;const t=Object.create(GO.prototype);return t.__wbg_ptr=e,t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,e}free(){const e=this.__destroy_into_raw();Ue.__wbg_rawrayintersection_free(e)}normal(){const e=Ue.rawraycolliderintersection_normal(this.__wbg_ptr);return lt.__wrap(e)}toi(){return Ue.rawraycolliderintersection_toi(this.__wbg_ptr)}featureType(){return Ue.rawpointcolliderprojection_featureType(this.__wbg_ptr)}featureId(){try{const i=Ue.__wbindgen_add_to_stack_pointer(-16);Ue.rawpointcolliderprojection_featureId(i,this.__wbg_ptr);var e=Wz()[i/4+0],t=Wz()[i/4+1];return e===0?void 0:t>>>0}finally{Ue.__wbindgen_add_to_stack_pointer(16)}}}class Zs{static __wrap(e){e>>>=0;const t=Object.create(Zs.prototype);return t.__wbg_ptr=e,t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,e}free(){const e=this.__destroy_into_raw();Ue.__wbg_rawrotation_free(e)}constructor(e,t,i,n){const r=Ue.rawrotation_new(e,t,i,n);return this.__wbg_ptr=r>>>0,this}static identity(){const e=Ue.rawrotation_identity();return Zs.__wrap(e)}get x(){return Ue.rawrotation_x(this.__wbg_ptr)}get y(){return Ue.rawintegrationparameters_dt(this.__wbg_ptr)}get z(){return Ue.rawraycolliderintersection_toi(this.__wbg_ptr)}get w(){return Ue.rawintegrationparameters_erp(this.__wbg_ptr)}}class qt{static __wrap(e){e>>>=0;const t=Object.create(qt.prototype);return t.__wbg_ptr=e,t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,e}free(){const e=this.__destroy_into_raw();Ue.__wbg_rawshape_free(e)}static cuboid(e,t,i){const n=Ue.rawshape_cuboid(e,t,i);return qt.__wrap(n)}static roundCuboid(e,t,i,n){const r=Ue.rawshape_roundCuboid(e,t,i,n);return qt.__wrap(r)}static ball(e){const t=Ue.rawshape_ball(e);return qt.__wrap(t)}static halfspace(e){At(e,lt);const t=Ue.rawshape_halfspace(e.__wbg_ptr);return qt.__wrap(t)}static capsule(e,t){const i=Ue.rawshape_capsule(e,t);return qt.__wrap(i)}static cylinder(e,t){const i=Ue.rawshape_cylinder(e,t);return qt.__wrap(i)}static roundCylinder(e,t,i){const n=Ue.rawshape_roundCylinder(e,t,i);return qt.__wrap(n)}static cone(e,t){const i=Ue.rawshape_cone(e,t);return qt.__wrap(i)}static roundCone(e,t,i){const n=Ue.rawshape_roundCone(e,t,i);return qt.__wrap(n)}static polyline(e,t){const i=uf(e,Ue.__wbindgen_malloc),n=zo,r=Ww(t,Ue.__wbindgen_malloc),o=zo,a=Ue.rawshape_polyline(i,n,r,o);return qt.__wrap(a)}static trimesh(e,t){const i=uf(e,Ue.__wbindgen_malloc),n=zo,r=Ww(t,Ue.__wbindgen_malloc),o=zo,a=Ue.rawshape_trimesh(i,n,r,o);return qt.__wrap(a)}static heightfield(e,t,i,n){const r=uf(i,Ue.__wbindgen_malloc),o=zo;At(n,lt);const a=Ue.rawshape_heightfield(e,t,r,o,n.__wbg_ptr);return qt.__wrap(a)}static segment(e,t){At(e,lt),At(t,lt);const i=Ue.rawshape_segment(e.__wbg_ptr,t.__wbg_ptr);return qt.__wrap(i)}static triangle(e,t,i){At(e,lt),At(t,lt),At(i,lt);const n=Ue.rawshape_triangle(e.__wbg_ptr,t.__wbg_ptr,i.__wbg_ptr);return qt.__wrap(n)}static roundTriangle(e,t,i,n){At(e,lt),At(t,lt),At(i,lt);const r=Ue.rawshape_roundTriangle(e.__wbg_ptr,t.__wbg_ptr,i.__wbg_ptr,n);return qt.__wrap(r)}static convexHull(e){const t=uf(e,Ue.__wbindgen_malloc),i=zo,n=Ue.rawshape_convexHull(t,i);return n===0?void 0:qt.__wrap(n)}static roundConvexHull(e,t){const i=uf(e,Ue.__wbindgen_malloc),n=zo,r=Ue.rawshape_roundConvexHull(i,n,t);return r===0?void 0:qt.__wrap(r)}static convexMesh(e,t){const i=uf(e,Ue.__wbindgen_malloc),n=zo,r=Ww(t,Ue.__wbindgen_malloc),o=zo,a=Ue.rawshape_convexMesh(i,n,r,o);return a===0?void 0:qt.__wrap(a)}static roundConvexMesh(e,t,i){const n=uf(e,Ue.__wbindgen_malloc),r=zo,o=Ww(t,Ue.__wbindgen_malloc),a=zo,c=Ue.rawshape_roundConvexMesh(n,r,o,a,i);return c===0?void 0:qt.__wrap(c)}castShape(e,t,i,n,r,o,a,c,l){At(e,lt),At(t,Zs),At(i,lt),At(n,qt),At(r,lt),At(o,Zs),At(a,lt);const h=Ue.rawshape_castShape(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr,i.__wbg_ptr,n.__wbg_ptr,r.__wbg_ptr,o.__wbg_ptr,a.__wbg_ptr,c,l);return h===0?void 0:VO.__wrap(h)}intersectsShape(e,t,i,n,r){return At(e,lt),At(t,Zs),At(i,qt),At(n,lt),At(r,Zs),Ue.rawshape_intersectsShape(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr,i.__wbg_ptr,n.__wbg_ptr,r.__wbg_ptr)!==0}contactShape(e,t,i,n,r,o){At(e,lt),At(t,Zs),At(i,qt),At(n,lt),At(r,Zs);const a=Ue.rawshape_contactShape(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr,i.__wbg_ptr,n.__wbg_ptr,r.__wbg_ptr,o);return a===0?void 0:HO.__wrap(a)}containsPoint(e,t,i){return At(e,lt),At(t,Zs),At(i,lt),Ue.rawshape_containsPoint(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr,i.__wbg_ptr)!==0}projectPoint(e,t,i,n){At(e,lt),At(t,Zs),At(i,lt);const r=Ue.rawshape_projectPoint(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr,i.__wbg_ptr,n);return zO.__wrap(r)}intersectsRay(e,t,i,n,r){return At(e,lt),At(t,Zs),At(i,lt),At(n,lt),Ue.rawshape_intersectsRay(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr,i.__wbg_ptr,n.__wbg_ptr,r)!==0}castRay(e,t,i,n,r,o){return At(e,lt),At(t,Zs),At(i,lt),At(n,lt),Ue.rawshape_castRay(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr,i.__wbg_ptr,n.__wbg_ptr,r,o)}castRayAndGetNormal(e,t,i,n,r,o){At(e,lt),At(t,Zs),At(i,lt),At(n,lt);const a=Ue.rawshape_castRayAndGetNormal(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr,i.__wbg_ptr,n.__wbg_ptr,r,o);return a===0?void 0:GO.__wrap(a)}}class HO{static __wrap(e){e>>>=0;const t=Object.create(HO.prototype);return t.__wbg_ptr=e,t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,e}free(){const e=this.__destroy_into_raw();Ue.__wbg_rawshapecontact_free(e)}distance(){return Ue.rawkinematiccharactercontroller_maxSlopeClimbAngle(this.__wbg_ptr)}point1(){const e=Ue.rawpointprojection_point(this.__wbg_ptr);return lt.__wrap(e)}point2(){const e=Ue.rawraycolliderintersection_normal(this.__wbg_ptr);return lt.__wrap(e)}normal1(){const e=Ue.rawshapecollidertoi_witness2(this.__wbg_ptr);return lt.__wrap(e)}normal2(){const e=Ue.rawcharactercollision_translationDeltaApplied(this.__wbg_ptr);return lt.__wrap(e)}}class VO{static __wrap(e){e>>>=0;const t=Object.create(VO.prototype);return t.__wbg_ptr=e,t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,e}free(){const e=this.__destroy_into_raw();Ue.__wbg_rawshapetoi_free(e)}toi(){return Ue.rawrotation_x(this.__wbg_ptr)}witness1(){const e=Ue.rawshapetoi_witness1(this.__wbg_ptr);return lt.__wrap(e)}witness2(){const e=Ue.rawcontactforceevent_total_force(this.__wbg_ptr);return lt.__wrap(e)}normal1(){const e=Ue.rawshapetoi_normal1(this.__wbg_ptr);return lt.__wrap(e)}normal2(){const e=Ue.rawshapetoi_normal2(this.__wbg_ptr);return lt.__wrap(e)}}class lt{static __wrap(e){e>>>=0;const t=Object.create(lt.prototype);return t.__wbg_ptr=e,t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,e}free(){const e=this.__destroy_into_raw();Ue.__wbg_rawvector_free(e)}static zero(){const e=Ue.rawvector_zero();return lt.__wrap(e)}constructor(e,t,i){const n=Ue.rawvector_new(e,t,i);return this.__wbg_ptr=n>>>0,this}get x(){return Ue.rawrotation_x(this.__wbg_ptr)}set x(e){Ue.rawvector_set_x(this.__wbg_ptr,e)}get y(){return Ue.rawintegrationparameters_dt(this.__wbg_ptr)}set y(e){Ue.rawintegrationparameters_set_dt(this.__wbg_ptr,e)}get z(){return Ue.rawraycolliderintersection_toi(this.__wbg_ptr)}set z(e){Ue.rawvector_set_z(this.__wbg_ptr,e)}xyz(){const e=Ue.rawvector_xyz(this.__wbg_ptr);return lt.__wrap(e)}yxz(){const e=Ue.rawvector_yxz(this.__wbg_ptr);return lt.__wrap(e)}zxy(){const e=Ue.rawvector_zxy(this.__wbg_ptr);return lt.__wrap(e)}xzy(){const e=Ue.rawvector_xzy(this.__wbg_ptr);return lt.__wrap(e)}yzx(){const e=Ue.rawvector_yzx(this.__wbg_ptr);return lt.__wrap(e)}zyx(){const e=Ue.rawvector_zyx(this.__wbg_ptr);return lt.__wrap(e)}}class __e{constructor(e,t,i){this.x=e,this.y=t,this.z=i}}class Be{static new(e,t,i){return new __e(e,t,i)}static intoRaw(e){return new lt(e.x,e.y,e.z)}static zeros(){return Be.new(0,0,0)}static fromRaw(e){if(!e)return null;let t=Be.new(e.x,e.y,e.z);return e.free(),t}static copy(e,t){e.x=t.x,e.y=t.y,e.z=t.z}}class Xz{constructor(e,t,i,n){this.x=e,this.y=t,this.z=i,this.w=n}}class Yi{static identity(){return new Xz(0,0,0,1)}static fromRaw(e){if(!e)return null;let t=new Xz(e.x,e.y,e.z,e.w);return e.free(),t}static intoRaw(e){return new Zs(e.x,e.y,e.z,e.w)}static copy(e,t){e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w}}class x_e{constructor(e){this.elements=e}get m11(){return this.elements[0]}get m12(){return this.elements[1]}get m21(){return this.m12}get m13(){return this.elements[2]}get m31(){return this.m13}get m22(){return this.elements[3]}get m23(){return this.elements[4]}get m32(){return this.m23}get m33(){return this.elements[5]}}class Yz{static fromRaw(e){const t=new x_e(e.elements());return e.free(),t}}var ov,_r,Jz,Kz,ts,JP,Kn,Zz,LS,KP,$z,FS,Mm;(function(s){s[s.Dynamic=0]="Dynamic",s[s.Fixed=1]="Fixed",s[s.KinematicPositionBased=2]="KinematicPositionBased",s[s.KinematicVelocityBased=3]="KinematicVelocityBased"})(ov||(ov={}));class e4{constructor(e,t,i){this.rawSet=e,this.colliderSet=t,this.handle=i}finalizeDeserialization(e){this.colliderSet=e}isValid(){return this.rawSet.contains(this.handle)}lockTranslations(e,t){return this.rawSet.rbLockTranslations(this.handle,e,t)}lockRotations(e,t){return this.rawSet.rbLockRotations(this.handle,e,t)}setEnabledTranslations(e,t,i,n){return this.rawSet.rbSetEnabledTranslations(this.handle,e,t,i,n)}restrictTranslations(e,t,i,n){this.setEnabledTranslations(e,t,i,n)}setEnabledRotations(e,t,i,n){return this.rawSet.rbSetEnabledRotations(this.handle,e,t,i,n)}restrictRotations(e,t,i,n){this.setEnabledRotations(e,t,i,n)}dominanceGroup(){return this.rawSet.rbDominanceGroup(this.handle)}setDominanceGroup(e){this.rawSet.rbSetDominanceGroup(this.handle,e)}additionalSolverIterations(){return this.rawSet.rbAdditionalSolverIterations(this.handle)}setAdditionalSolverIterations(e){this.rawSet.rbSetAdditionalSolverIterations(this.handle,e)}enableCcd(e){this.rawSet.rbEnableCcd(this.handle,e)}translation(){let e=this.rawSet.rbTranslation(this.handle);return Be.fromRaw(e)}rotation(){let e=this.rawSet.rbRotation(this.handle);return Yi.fromRaw(e)}nextTranslation(){let e=this.rawSet.rbNextTranslation(this.handle);return Be.fromRaw(e)}nextRotation(){let e=this.rawSet.rbNextRotation(this.handle);return Yi.fromRaw(e)}setTranslation(e,t){this.rawSet.rbSetTranslation(this.handle,e.x,e.y,e.z,t)}setLinvel(e,t){let i=Be.intoRaw(e);this.rawSet.rbSetLinvel(this.handle,i,t),i.free()}gravityScale(){return this.rawSet.rbGravityScale(this.handle)}setGravityScale(e,t){this.rawSet.rbSetGravityScale(this.handle,e,t)}setRotation(e,t){this.rawSet.rbSetRotation(this.handle,e.x,e.y,e.z,e.w,t)}setAngvel(e,t){let i=Be.intoRaw(e);this.rawSet.rbSetAngvel(this.handle,i,t),i.free()}setNextKinematicTranslation(e){this.rawSet.rbSetNextKinematicTranslation(this.handle,e.x,e.y,e.z)}setNextKinematicRotation(e){this.rawSet.rbSetNextKinematicRotation(this.handle,e.x,e.y,e.z,e.w)}linvel(){return Be.fromRaw(this.rawSet.rbLinvel(this.handle))}angvel(){return Be.fromRaw(this.rawSet.rbAngvel(this.handle))}mass(){return this.rawSet.rbMass(this.handle)}effectiveInvMass(){return Be.fromRaw(this.rawSet.rbEffectiveInvMass(this.handle))}invMass(){return this.rawSet.rbInvMass(this.handle)}localCom(){return Be.fromRaw(this.rawSet.rbLocalCom(this.handle))}worldCom(){return Be.fromRaw(this.rawSet.rbWorldCom(this.handle))}invPrincipalInertiaSqrt(){return Be.fromRaw(this.rawSet.rbInvPrincipalInertiaSqrt(this.handle))}principalInertia(){return Be.fromRaw(this.rawSet.rbPrincipalInertia(this.handle))}principalInertiaLocalFrame(){return Yi.fromRaw(this.rawSet.rbPrincipalInertiaLocalFrame(this.handle))}effectiveWorldInvInertiaSqrt(){return Yz.fromRaw(this.rawSet.rbEffectiveWorldInvInertiaSqrt(this.handle))}effectiveAngularInertia(){return Yz.fromRaw(this.rawSet.rbEffectiveAngularInertia(this.handle))}sleep(){this.rawSet.rbSleep(this.handle)}wakeUp(){this.rawSet.rbWakeUp(this.handle)}isCcdEnabled(){return this.rawSet.rbIsCcdEnabled(this.handle)}numColliders(){return this.rawSet.rbNumColliders(this.handle)}collider(e){return this.colliderSet.get(this.rawSet.rbCollider(this.handle,e))}setEnabled(e){this.rawSet.rbSetEnabled(this.handle,e)}isEnabled(){return this.rawSet.rbIsEnabled(this.handle)}bodyType(){return this.rawSet.rbBodyType(this.handle)}setBodyType(e,t){return this.rawSet.rbSetBodyType(this.handle,e,t)}isSleeping(){return this.rawSet.rbIsSleeping(this.handle)}isMoving(){return this.rawSet.rbIsMoving(this.handle)}isFixed(){return this.rawSet.rbIsFixed(this.handle)}isKinematic(){return this.rawSet.rbIsKinematic(this.handle)}isDynamic(){return this.rawSet.rbIsDynamic(this.handle)}linearDamping(){return this.rawSet.rbLinearDamping(this.handle)}angularDamping(){return this.rawSet.rbAngularDamping(this.handle)}setLinearDamping(e){this.rawSet.rbSetLinearDamping(this.handle,e)}recomputeMassPropertiesFromColliders(){this.rawSet.rbRecomputeMassPropertiesFromColliders(this.handle,this.colliderSet.raw)}setAdditionalMass(e,t){this.rawSet.rbSetAdditionalMass(this.handle,e,t)}setAdditionalMassProperties(e,t,i,n,r){let o=Be.intoRaw(t),a=Be.intoRaw(i),c=Yi.intoRaw(n);this.rawSet.rbSetAdditionalMassProperties(this.handle,e,o,a,c,r),o.free(),a.free(),c.free()}setAngularDamping(e){this.rawSet.rbSetAngularDamping(this.handle,e)}resetForces(e){this.rawSet.rbResetForces(this.handle,e)}resetTorques(e){this.rawSet.rbResetTorques(this.handle,e)}addForce(e,t){const i=Be.intoRaw(e);this.rawSet.rbAddForce(this.handle,i,t),i.free()}applyImpulse(e,t){const i=Be.intoRaw(e);this.rawSet.rbApplyImpulse(this.handle,i,t),i.free()}addTorque(e,t){const i=Be.intoRaw(e);this.rawSet.rbAddTorque(this.handle,i,t),i.free()}applyTorqueImpulse(e,t){const i=Be.intoRaw(e);this.rawSet.rbApplyTorqueImpulse(this.handle,i,t),i.free()}addForceAtPoint(e,t,i){const n=Be.intoRaw(e),r=Be.intoRaw(t);this.rawSet.rbAddForceAtPoint(this.handle,n,r,i),n.free(),r.free()}applyImpulseAtPoint(e,t,i){const n=Be.intoRaw(e),r=Be.intoRaw(t);this.rawSet.rbApplyImpulseAtPoint(this.handle,n,r,i),n.free(),r.free()}}(function(s){s[s.Revolute=0]="Revolute",s[s.Fixed=1]="Fixed",s[s.Prismatic=2]="Prismatic",s[s.Rope=3]="Rope",s[s.Spring=4]="Spring",s[s.Spherical=5]="Spherical",s[s.Generic=6]="Generic"})(_r||(_r={})),function(s){s[s.AccelerationBased=0]="AccelerationBased",s[s.ForceBased=1]="ForceBased"}(Jz||(Jz={})),function(s){s[s.X=1]="X",s[s.Y=2]="Y",s[s.Z=4]="Z",s[s.AngX=8]="AngX",s[s.AngY=16]="AngY",s[s.AngZ=32]="AngZ"}(Kz||(Kz={}));class uh{constructor(){}static fixed(e,t,i,n){let r=new uh;return r.anchor1=e,r.anchor2=i,r.frame1=t,r.frame2=n,r.jointType=_r.Fixed,r}static spring(e,t,i,n,r){let o=new uh;return o.anchor1=n,o.anchor2=r,o.length=e,o.stiffness=t,o.damping=i,o.jointType=_r.Spring,o}static rope(e,t,i){let n=new uh;return n.anchor1=t,n.anchor2=i,n.length=e,n.jointType=_r.Rope,n}static generic(e,t,i,n){let r=new uh;return r.anchor1=e,r.anchor2=t,r.axis=i,r.axesMask=n,r.jointType=_r.Generic,r}static spherical(e,t){let i=new uh;return i.anchor1=e,i.anchor2=t,i.jointType=_r.Spherical,i}static prismatic(e,t,i){let n=new uh;return n.anchor1=e,n.anchor2=t,n.axis=i,n.jointType=_r.Prismatic,n}static revolute(e,t,i){let n=new uh;return n.anchor1=e,n.anchor2=t,n.axis=i,n.jointType=_r.Revolute,n}intoRaw(){let e,t,i=Be.intoRaw(this.anchor1),n=Be.intoRaw(this.anchor2),r=!1,o=0,a=0;switch(this.jointType){case _r.Fixed:let c=Yi.intoRaw(this.frame1),l=Yi.intoRaw(this.frame2);t=Sr.fixed(i,c,n,l),c.free(),l.free();break;case _r.Spring:t=Sr.spring(this.length,this.stiffness,this.damping,i,n);break;case _r.Rope:t=Sr.rope(this.length,i,n);break;case _r.Prismatic:e=Be.intoRaw(this.axis),this.limitsEnabled&&(r=!0,o=this.limits[0],a=this.limits[1]),t=Sr.prismatic(i,n,e,r,o,a),e.free();break;case _r.Generic:e=Be.intoRaw(this.axis);let h=this.axesMask;t=Sr.generic(i,n,e,h);break;case _r.Spherical:t=Sr.spherical(i,n);break;case _r.Revolute:e=Be.intoRaw(this.axis),t=Sr.revolute(i,n,e),e.free()}return i.free(),n.free(),t}}(function(s){s[s.Average=0]="Average",s[s.Min=1]="Min",s[s.Multiply=2]="Multiply",s[s.Max=3]="Max"})(ts||(ts={}));class ob{constructor(e,t,i,n,r){this.distance=e,this.point1=t,this.point2=i,this.normal1=n,this.normal2=r}static fromRaw(e){if(!e)return null;const t=new ob(e.distance(),Be.fromRaw(e.point1()),Be.fromRaw(e.point2()),Be.fromRaw(e.normal1()),Be.fromRaw(e.normal2()));return e.free(),t}}(function(s){s[s.Vertex=0]="Vertex",s[s.Edge=1]="Edge",s[s.Face=2]="Face",s[s.Unknown=3]="Unknown"})(JP||(JP={}));class t1{constructor(e,t){this.point=e,this.isInside=t}static fromRaw(e){if(!e)return null;const t=new t1(Be.fromRaw(e.point()),e.isInside());return e.free(),t}}class w_e{constructor(e,t){this.origin=e,this.dir=t}pointAt(e){return{x:this.origin.x+this.dir.x*e,y:this.origin.y+this.dir.y*e,z:this.origin.z+this.dir.z*e}}}class i1{constructor(e,t,i,n){this.featureType=JP.Unknown,this.featureId=void 0,this.toi=e,this.normal=t,n!==void 0&&(this.featureId=n),i!==void 0&&(this.featureType=i)}static fromRaw(e){if(!e)return null;const t=new i1(e.toi(),Be.fromRaw(e.normal()),e.featureType(),e.featureId());return e.free(),t}}class S_{constructor(e,t,i,n,r){this.toi=e,this.witness1=t,this.witness2=i,this.normal1=n,this.normal2=r}static fromRaw(e,t){if(!t)return null;const i=new S_(t.toi(),Be.fromRaw(t.witness1()),Be.fromRaw(t.witness2()),Be.fromRaw(t.normal1()),Be.fromRaw(t.normal2()));return t.free(),i}}class jO extends S_{constructor(e,t,i,n,r,o){super(t,i,n,r,o),this.collider=e}static fromRaw(e,t){if(!t)return null;const i=new jO(e.get(t.colliderHandle()),t.toi(),Be.fromRaw(t.witness1()),Be.fromRaw(t.witness2()),Be.fromRaw(t.normal1()),Be.fromRaw(t.normal2()));return t.free(),i}}class Ns{static fromRaw(e,t){const i=e.coShapeType(t);let n,r,o,a,c,l,h;switch(i){case Ws.Ball:return new WO(e.coRadius(t));case Ws.Cuboid:return n=e.coHalfExtents(t),new Jj(n.x,n.y,n.z);case Ws.RoundCuboid:return n=e.coHalfExtents(t),r=e.coRoundRadius(t),new Kj(n.x,n.y,n.z,r);case Ws.Capsule:return c=e.coHalfHeight(t),l=e.coRadius(t),new Zj(c,l);case Ws.Segment:return o=e.coVertices(t),new $j(Be.new(o[0],o[1],o[2]),Be.new(o[3],o[4],o[5]));case Ws.Polyline:return o=e.coVertices(t),a=e.coIndices(t),new iW(o,a);case Ws.Triangle:return o=e.coVertices(t),new eW(Be.new(o[0],o[1],o[2]),Be.new(o[3],o[4],o[5]),Be.new(o[6],o[7],o[8]));case Ws.RoundTriangle:return o=e.coVertices(t),r=e.coRoundRadius(t),new tW(Be.new(o[0],o[1],o[2]),Be.new(o[3],o[4],o[5]),Be.new(o[6],o[7],o[8]),r);case Ws.HalfSpace:return h=Be.fromRaw(e.coHalfspaceNormal(t)),new C_e(h);case Ws.TriMesh:return o=e.coVertices(t),a=e.coIndices(t),new nW(o,a);case Ws.HeightField:const u=e.coHeightfieldScale(t),f=e.coHeightfieldHeights(t),p=e.coHeightfieldNRows(t),g=e.coHeightfieldNCols(t);return new sW(p,g,f,u);case Ws.ConvexPolyhedron:return o=e.coVertices(t),a=e.coIndices(t),new ZP(o,a);case Ws.RoundConvexPolyhedron:return o=e.coVertices(t),a=e.coIndices(t),r=e.coRoundRadius(t),new $P(o,a,r);case Ws.Cylinder:return c=e.coHalfHeight(t),l=e.coRadius(t),new rW(c,l);case Ws.RoundCylinder:return c=e.coHalfHeight(t),l=e.coRadius(t),r=e.coRoundRadius(t),new oW(c,l,r);case Ws.Cone:return c=e.coHalfHeight(t),l=e.coRadius(t),new aW(c,l);case Ws.RoundCone:return c=e.coHalfHeight(t),l=e.coRadius(t),r=e.coRoundRadius(t),new cW(c,l,r);default:throw new Error("unknown shape type: "+i)}}castShape(e,t,i,n,r,o,a,c,l){let h=Be.intoRaw(e),u=Yi.intoRaw(t),f=Be.intoRaw(i),p=Be.intoRaw(r),g=Yi.intoRaw(o),y=Be.intoRaw(a),m=this.intoRaw(),A=n.intoRaw(),b=S_.fromRaw(null,m.castShape(h,u,f,A,p,g,y,c,l));return h.free(),u.free(),f.free(),p.free(),g.free(),y.free(),m.free(),A.free(),b}intersectsShape(e,t,i,n,r){let o=Be.intoRaw(e),a=Yi.intoRaw(t),c=Be.intoRaw(n),l=Yi.intoRaw(r),h=this.intoRaw(),u=i.intoRaw(),f=h.intersectsShape(o,a,u,c,l);return o.free(),a.free(),c.free(),l.free(),h.free(),u.free(),f}contactShape(e,t,i,n,r,o){let a=Be.intoRaw(e),c=Yi.intoRaw(t),l=Be.intoRaw(n),h=Yi.intoRaw(r),u=this.intoRaw(),f=i.intoRaw(),p=ob.fromRaw(u.contactShape(a,c,f,l,h,o));return a.free(),c.free(),l.free(),h.free(),u.free(),f.free(),p}containsPoint(e,t,i){let n=Be.intoRaw(e),r=Yi.intoRaw(t),o=Be.intoRaw(i),a=this.intoRaw(),c=a.containsPoint(n,r,o);return n.free(),r.free(),o.free(),a.free(),c}projectPoint(e,t,i,n){let r=Be.intoRaw(e),o=Yi.intoRaw(t),a=Be.intoRaw(i),c=this.intoRaw(),l=t1.fromRaw(c.projectPoint(r,o,a,n));return r.free(),o.free(),a.free(),c.free(),l}intersectsRay(e,t,i,n){let r=Be.intoRaw(t),o=Yi.intoRaw(i),a=Be.intoRaw(e.origin),c=Be.intoRaw(e.dir),l=this.intoRaw(),h=l.intersectsRay(r,o,a,c,n);return r.free(),o.free(),a.free(),c.free(),l.free(),h}castRay(e,t,i,n,r){let o=Be.intoRaw(t),a=Yi.intoRaw(i),c=Be.intoRaw(e.origin),l=Be.intoRaw(e.dir),h=this.intoRaw(),u=h.castRay(o,a,c,l,n,r);return o.free(),a.free(),c.free(),l.free(),h.free(),u}castRayAndGetNormal(e,t,i,n,r){let o=Be.intoRaw(t),a=Yi.intoRaw(i),c=Be.intoRaw(e.origin),l=Be.intoRaw(e.dir),h=this.intoRaw(),u=i1.fromRaw(h.castRayAndGetNormal(o,a,c,l,n,r));return o.free(),a.free(),c.free(),l.free(),h.free(),u}}(function(s){s[s.Ball=0]="Ball",s[s.Cuboid=1]="Cuboid",s[s.Capsule=2]="Capsule",s[s.Segment=3]="Segment",s[s.Polyline=4]="Polyline",s[s.Triangle=5]="Triangle",s[s.TriMesh=6]="TriMesh",s[s.HeightField=7]="HeightField",s[s.ConvexPolyhedron=9]="ConvexPolyhedron",s[s.Cylinder=10]="Cylinder",s[s.Cone=11]="Cone",s[s.RoundCuboid=12]="RoundCuboid",s[s.RoundTriangle=13]="RoundTriangle",s[s.RoundCylinder=14]="RoundCylinder",s[s.RoundCone=15]="RoundCone",s[s.RoundConvexPolyhedron=16]="RoundConvexPolyhedron",s[s.HalfSpace=17]="HalfSpace"})(Kn||(Kn={}));class WO extends Ns{constructor(e){super(),this.type=Kn.Ball,this.radius=e}intoRaw(){return qt.ball(this.radius)}}class C_e extends Ns{constructor(e){super(),this.type=Kn.HalfSpace,this.normal=e}intoRaw(){let e=Be.intoRaw(this.normal),t=qt.halfspace(e);return e.free(),t}}class Jj extends Ns{constructor(e,t,i){super(),this.type=Kn.Cuboid,this.halfExtents=Be.new(e,t,i)}intoRaw(){return qt.cuboid(this.halfExtents.x,this.halfExtents.y,this.halfExtents.z)}}class Kj extends Ns{constructor(e,t,i,n){super(),this.type=Kn.RoundCuboid,this.halfExtents=Be.new(e,t,i),this.borderRadius=n}intoRaw(){return qt.roundCuboid(this.halfExtents.x,this.halfExtents.y,this.halfExtents.z,this.borderRadius)}}class Zj extends Ns{constructor(e,t){super(),this.type=Kn.Capsule,this.halfHeight=e,this.radius=t}intoRaw(){return qt.capsule(this.halfHeight,this.radius)}}class $j extends Ns{constructor(e,t){super(),this.type=Kn.Segment,this.a=e,this.b=t}intoRaw(){let e=Be.intoRaw(this.a),t=Be.intoRaw(this.b),i=qt.segment(e,t);return e.free(),t.free(),i}}class eW extends Ns{constructor(e,t,i){super(),this.type=Kn.Triangle,this.a=e,this.b=t,this.c=i}intoRaw(){let e=Be.intoRaw(this.a),t=Be.intoRaw(this.b),i=Be.intoRaw(this.c),n=qt.triangle(e,t,i);return e.free(),t.free(),i.free(),n}}class tW extends Ns{constructor(e,t,i,n){super(),this.type=Kn.RoundTriangle,this.a=e,this.b=t,this.c=i,this.borderRadius=n}intoRaw(){let e=Be.intoRaw(this.a),t=Be.intoRaw(this.b),i=Be.intoRaw(this.c),n=qt.roundTriangle(e,t,i,this.borderRadius);return e.free(),t.free(),i.free(),n}}class iW extends Ns{constructor(e,t){super(),this.type=Kn.Polyline,this.vertices=e,this.indices=t??new Uint32Array(0)}intoRaw(){return qt.polyline(this.vertices,this.indices)}}class nW extends Ns{constructor(e,t){super(),this.type=Kn.TriMesh,this.vertices=e,this.indices=t}intoRaw(){return qt.trimesh(this.vertices,this.indices)}}class ZP extends Ns{constructor(e,t){super(),this.type=Kn.ConvexPolyhedron,this.vertices=e,this.indices=t}intoRaw(){return this.indices?qt.convexMesh(this.vertices,this.indices):qt.convexHull(this.vertices)}}class $P extends Ns{constructor(e,t,i){super(),this.type=Kn.RoundConvexPolyhedron,this.vertices=e,this.indices=t,this.borderRadius=i}intoRaw(){return this.indices?qt.roundConvexMesh(this.vertices,this.indices,this.borderRadius):qt.roundConvexHull(this.vertices,this.borderRadius)}}class sW extends Ns{constructor(e,t,i,n){super(),this.type=Kn.HeightField,this.nrows=e,this.ncols=t,this.heights=i,this.scale=n}intoRaw(){let e=Be.intoRaw(this.scale),t=qt.heightfield(this.nrows,this.ncols,this.heights,e);return e.free(),t}}class rW extends Ns{constructor(e,t){super(),this.type=Kn.Cylinder,this.halfHeight=e,this.radius=t}intoRaw(){return qt.cylinder(this.halfHeight,this.radius)}}class oW extends Ns{constructor(e,t,i){super(),this.type=Kn.RoundCylinder,this.borderRadius=i,this.halfHeight=e,this.radius=t}intoRaw(){return qt.roundCylinder(this.halfHeight,this.radius,this.borderRadius)}}class aW extends Ns{constructor(e,t){super(),this.type=Kn.Cone,this.halfHeight=e,this.radius=t}intoRaw(){return qt.cone(this.halfHeight,this.radius)}}class cW extends Ns{constructor(e,t,i){super(),this.type=Kn.RoundCone,this.halfHeight=e,this.radius=t,this.borderRadius=i}intoRaw(){return qt.roundCone(this.halfHeight,this.radius,this.borderRadius)}}(function(s){s[s.EXCLUDE_FIXED=1]="EXCLUDE_FIXED",s[s.EXCLUDE_KINEMATIC=2]="EXCLUDE_KINEMATIC",s[s.EXCLUDE_DYNAMIC=4]="EXCLUDE_DYNAMIC",s[s.EXCLUDE_SENSORS=8]="EXCLUDE_SENSORS",s[s.EXCLUDE_SOLIDS=16]="EXCLUDE_SOLIDS",s[s.ONLY_DYNAMIC=3]="ONLY_DYNAMIC",s[s.ONLY_KINEMATIC=5]="ONLY_KINEMATIC",s[s.ONLY_FIXED=6]="ONLY_FIXED"})(Zz||(Zz={}));(function(s){s[s.NONE=0]="NONE",s[s.COLLISION_EVENTS=1]="COLLISION_EVENTS",s[s.CONTACT_FORCE_EVENTS=2]="CONTACT_FORCE_EVENTS"})(LS||(LS={}));class S_e{free(){this.raw&&this.raw.free(),this.raw=void 0}collider1(){return this.raw.collider1()}collider2(){return this.raw.collider2()}totalForce(){return Be.fromRaw(this.raw.total_force())}totalForceMagnitude(){return this.raw.total_force_magnitude()}maxForceDirection(){return Be.fromRaw(this.raw.max_force_direction())}maxForceMagnitude(){return this.raw.max_force_magnitude()}}class E_e{constructor(e,t){this.raw=t||new b_e(e)}free(){this.raw&&this.raw.free(),this.raw=void 0}drainCollisionEvents(e){this.raw.drainCollisionEvents(e)}drainContactForceEvents(e){let t=new S_e;this.raw.drainContactForceEvents(i=>{t.raw=i,e(t),t.free()})}clear(){this.raw.clear()}}(function(s){s[s.NONE=0]="NONE",s[s.FILTER_CONTACT_PAIRS=1]="FILTER_CONTACT_PAIRS",s[s.FILTER_INTERSECTION_PAIRS=2]="FILTER_INTERSECTION_PAIRS"})(KP||(KP={})),function(s){s[s.EMPTY=0]="EMPTY",s[s.COMPUTE_IMPULSE=1]="COMPUTE_IMPULSE"}($z||($z={})),function(s){s[s.DYNAMIC_DYNAMIC=1]="DYNAMIC_DYNAMIC",s[s.DYNAMIC_KINEMATIC=12]="DYNAMIC_KINEMATIC",s[s.DYNAMIC_FIXED=2]="DYNAMIC_FIXED",s[s.KINEMATIC_KINEMATIC=52224]="KINEMATIC_KINEMATIC",s[s.KINEMATIC_FIXED=8704]="KINEMATIC_FIXED",s[s.FIXED_FIXED=32]="FIXED_FIXED",s[s.DEFAULT=15]="DEFAULT",s[s.ALL=60943]="ALL"}(FS||(FS={}));class t4{constructor(e,t,i,n){this.colliderSet=e,this.handle=t,this._parent=i,this._shape=n}finalizeDeserialization(e){this.handle!=null&&(this._parent=e.get(this.colliderSet.raw.coParent(this.handle)))}ensureShapeIsCached(){this._shape||(this._shape=Ns.fromRaw(this.colliderSet.raw,this.handle))}get shape(){return this.ensureShapeIsCached(),this._shape}isValid(){return this.colliderSet.raw.contains(this.handle)}translation(){return Be.fromRaw(this.colliderSet.raw.coTranslation(this.handle))}rotation(){return Yi.fromRaw(this.colliderSet.raw.coRotation(this.handle))}isSensor(){return this.colliderSet.raw.coIsSensor(this.handle)}setSensor(e){this.colliderSet.raw.coSetSensor(this.handle,e)}setShape(e){let t=e.intoRaw();this.colliderSet.raw.coSetShape(this.handle,t),t.free(),this._shape=e}setEnabled(e){this.colliderSet.raw.coSetEnabled(this.handle,e)}isEnabled(){return this.colliderSet.raw.coIsEnabled(this.handle)}setRestitution(e){this.colliderSet.raw.coSetRestitution(this.handle,e)}setFriction(e){this.colliderSet.raw.coSetFriction(this.handle,e)}frictionCombineRule(){return this.colliderSet.raw.coFrictionCombineRule(this.handle)}setFrictionCombineRule(e){this.colliderSet.raw.coSetFrictionCombineRule(this.handle,e)}restitutionCombineRule(){return this.colliderSet.raw.coRestitutionCombineRule(this.handle)}setRestitutionCombineRule(e){this.colliderSet.raw.coSetRestitutionCombineRule(this.handle,e)}setCollisionGroups(e){this.colliderSet.raw.coSetCollisionGroups(this.handle,e)}setSolverGroups(e){this.colliderSet.raw.coSetSolverGroups(this.handle,e)}activeHooks(){return this.colliderSet.raw.coActiveHooks(this.handle)}setActiveHooks(e){this.colliderSet.raw.coSetActiveHooks(this.handle,e)}activeEvents(){return this.colliderSet.raw.coActiveEvents(this.handle)}setActiveEvents(e){this.colliderSet.raw.coSetActiveEvents(this.handle,e)}activeCollisionTypes(){return this.colliderSet.raw.coActiveCollisionTypes(this.handle)}setContactForceEventThreshold(e){return this.colliderSet.raw.coSetContactForceEventThreshold(this.handle,e)}contactForceEventThreshold(){return this.colliderSet.raw.coContactForceEventThreshold(this.handle)}setActiveCollisionTypes(e){this.colliderSet.raw.coSetActiveCollisionTypes(this.handle,e)}setDensity(e){this.colliderSet.raw.coSetDensity(this.handle,e)}setMass(e){this.colliderSet.raw.coSetMass(this.handle,e)}setMassProperties(e,t,i,n){let r=Be.intoRaw(t),o=Be.intoRaw(i),a=Yi.intoRaw(n);this.colliderSet.raw.coSetMassProperties(this.handle,e,r,o,a),r.free(),o.free(),a.free()}setTranslation(e){this.colliderSet.raw.coSetTranslation(this.handle,e.x,e.y,e.z)}setTranslationWrtParent(e){this.colliderSet.raw.coSetTranslationWrtParent(this.handle,e.x,e.y,e.z)}setRotation(e){this.colliderSet.raw.coSetRotation(this.handle,e.x,e.y,e.z,e.w)}setRotationWrtParent(e){this.colliderSet.raw.coSetRotationWrtParent(this.handle,e.x,e.y,e.z,e.w)}shapeType(){return this.colliderSet.raw.coShapeType(this.handle)}halfExtents(){return Be.fromRaw(this.colliderSet.raw.coHalfExtents(this.handle))}setHalfExtents(e){const t=Be.intoRaw(e);this.colliderSet.raw.coSetHalfExtents(this.handle,t)}radius(){return this.colliderSet.raw.coRadius(this.handle)}setRadius(e){this.colliderSet.raw.coSetRadius(this.handle,e)}roundRadius(){return this.colliderSet.raw.coRoundRadius(this.handle)}setRoundRadius(e){this.colliderSet.raw.coSetRoundRadius(this.handle,e)}halfHeight(){return this.colliderSet.raw.coHalfHeight(this.handle)}setHalfHeight(e){this.colliderSet.raw.coSetHalfHeight(this.handle,e)}vertices(){return this.colliderSet.raw.coVertices(this.handle)}indices(){return this.colliderSet.raw.coIndices(this.handle)}heightfieldHeights(){return this.colliderSet.raw.coHeightfieldHeights(this.handle)}heightfieldScale(){let e=this.colliderSet.raw.coHeightfieldScale(this.handle);return Be.fromRaw(e)}heightfieldNRows(){return this.colliderSet.raw.coHeightfieldNRows(this.handle)}heightfieldNCols(){return this.colliderSet.raw.coHeightfieldNCols(this.handle)}parent(){return this._parent}friction(){return this.colliderSet.raw.coFriction(this.handle)}restitution(){return this.colliderSet.raw.coRestitution(this.handle)}density(){return this.colliderSet.raw.coDensity(this.handle)}mass(){return this.colliderSet.raw.coMass(this.handle)}volume(){return this.colliderSet.raw.coVolume(this.handle)}collisionGroups(){return this.colliderSet.raw.coCollisionGroups(this.handle)}solverGroups(){return this.colliderSet.raw.coSolverGroups(this.handle)}containsPoint(e){let t=Be.intoRaw(e),i=this.colliderSet.raw.coContainsPoint(this.handle,t);return t.free(),i}projectPoint(e,t){let i=Be.intoRaw(e),n=t1.fromRaw(this.colliderSet.raw.coProjectPoint(this.handle,i,t));return i.free(),n}intersectsRay(e,t){let i=Be.intoRaw(e.origin),n=Be.intoRaw(e.dir),r=this.colliderSet.raw.coIntersectsRay(this.handle,i,n,t);return i.free(),n.free(),r}castShape(e,t,i,n,r,o,a){let c=Be.intoRaw(e),l=Be.intoRaw(i),h=Yi.intoRaw(n),u=Be.intoRaw(r),f=t.intoRaw(),p=S_.fromRaw(this.colliderSet,this.colliderSet.raw.coCastShape(this.handle,c,f,l,h,u,o,a));return c.free(),l.free(),h.free(),u.free(),f.free(),p}castCollider(e,t,i,n,r){let o=Be.intoRaw(e),a=Be.intoRaw(i),c=jO.fromRaw(this.colliderSet,this.colliderSet.raw.coCastCollider(this.handle,o,t.handle,a,n,r));return o.free(),a.free(),c}intersectsShape(e,t,i){let n=Be.intoRaw(t),r=Yi.intoRaw(i),o=e.intoRaw(),a=this.colliderSet.raw.coIntersectsShape(this.handle,o,n,r);return n.free(),r.free(),o.free(),a}contactShape(e,t,i,n){let r=Be.intoRaw(t),o=Yi.intoRaw(i),a=e.intoRaw(),c=ob.fromRaw(this.colliderSet.raw.coContactShape(this.handle,a,r,o,n));return r.free(),o.free(),a.free(),c}contactCollider(e,t){return ob.fromRaw(this.colliderSet.raw.coContactCollider(this.handle,e.handle,t))}castRay(e,t,i){let n=Be.intoRaw(e.origin),r=Be.intoRaw(e.dir),o=this.colliderSet.raw.coCastRay(this.handle,n,r,t,i);return n.free(),r.free(),o}castRayAndGetNormal(e,t,i){let n=Be.intoRaw(e.origin),r=Be.intoRaw(e.dir),o=i1.fromRaw(this.colliderSet.raw.coCastRayAndGetNormal(this.handle,n,r,t,i));return n.free(),r.free(),o}}(function(s){s[s.Density=0]="Density",s[s.Mass=1]="Mass",s[s.MassProps=2]="MassProps"})(Mm||(Mm={}));class dn{constructor(e){this.enabled=!0,this.shape=e,this.massPropsMode=Mm.Density,this.density=1,this.friction=.5,this.restitution=0,this.rotation=Yi.identity(),this.translation=Be.zeros(),this.isSensor=!1,this.collisionGroups=4294967295,this.solverGroups=4294967295,this.frictionCombineRule=ts.Average,this.restitutionCombineRule=ts.Average,this.activeCollisionTypes=FS.DEFAULT,this.activeEvents=LS.NONE,this.activeHooks=KP.NONE,this.mass=0,this.centerOfMass=Be.zeros(),this.contactForceEventThreshold=0,this.principalAngularInertia=Be.zeros(),this.angularInertiaLocalFrame=Yi.identity()}static ball(e){const t=new WO(e);return new dn(t)}static capsule(e,t){const i=new Zj(e,t);return new dn(i)}static segment(e,t){const i=new $j(e,t);return new dn(i)}static triangle(e,t,i){const n=new eW(e,t,i);return new dn(n)}static roundTriangle(e,t,i,n){const r=new tW(e,t,i,n);return new dn(r)}static polyline(e,t){const i=new iW(e,t);return new dn(i)}static trimesh(e,t){const i=new nW(e,t);return new dn(i)}static cuboid(e,t,i){const n=new Jj(e,t,i);return new dn(n)}static roundCuboid(e,t,i,n){const r=new Kj(e,t,i,n);return new dn(r)}static heightfield(e,t,i,n){const r=new sW(e,t,i,n);return new dn(r)}static cylinder(e,t){const i=new rW(e,t);return new dn(i)}static roundCylinder(e,t,i){const n=new oW(e,t,i);return new dn(n)}static cone(e,t){const i=new aW(e,t);return new dn(i)}static roundCone(e,t,i){const n=new cW(e,t,i);return new dn(n)}static convexHull(e){const t=new ZP(e,null);return new dn(t)}static convexMesh(e,t){const i=new ZP(e,t);return new dn(i)}static roundConvexHull(e,t){const i=new $P(e,null,t);return new dn(i)}static roundConvexMesh(e,t,i){const n=new $P(e,t,i);return new dn(n)}setTranslation(e,t,i){if(typeof e!="number"||typeof t!="number"||typeof i!="number")throw TypeError("The translation components must be numbers.");return this.translation={x:e,y:t,z:i},this}setRotation(e){return Yi.copy(this.rotation,e),this}setSensor(e){return this.isSensor=e,this}setEnabled(e){return this.enabled=e,this}setDensity(e){return this.massPropsMode=Mm.Density,this.density=e,this}setMass(e){return this.massPropsMode=Mm.Mass,this.mass=e,this}setMassProperties(e,t,i,n){return this.massPropsMode=Mm.MassProps,this.mass=e,Be.copy(this.centerOfMass,t),Be.copy(this.principalAngularInertia,i),Yi.copy(this.angularInertiaLocalFrame,n),this}setRestitution(e){return this.restitution=e,this}setFriction(e){return this.friction=e,this}setFrictionCombineRule(e){return this.frictionCombineRule=e,this}setRestitutionCombineRule(e){return this.restitutionCombineRule=e,this}setCollisionGroups(e){return this.collisionGroups=e,this}setSolverGroups(e){return this.solverGroups=e,this}setActiveHooks(e){return this.activeHooks=e,this}setActiveEvents(e){return this.activeEvents=e,this}setActiveCollisionTypes(e){return this.activeCollisionTypes=e,this}setContactForceEventThreshold(e){return this.contactForceEventThreshold=e,this}}for(var RCe={byteLength:function(s){var e=i4(s),t=e[0],i=e[1];return 3*(t+i)/4-i},toByteArray:function(s){var e,t,i=i4(s),n=i[0],r=i[1],o=new I_e(function(l,h,u){return 3*(h+u)/4-u}(0,n,r)),a=0,c=r>0?n-4:n;for(t=0;t<c;t+=4)e=va[s.charCodeAt(t)]<<18|va[s.charCodeAt(t+1)]<<12|va[s.charCodeAt(t+2)]<<6|va[s.charCodeAt(t+3)],o[a++]=e>>16&255,o[a++]=e>>8&255,o[a++]=255&e;return r===2&&(e=va[s.charCodeAt(t)]<<2|va[s.charCodeAt(t+1)]>>4,o[a++]=255&e),r===1&&(e=va[s.charCodeAt(t)]<<10|va[s.charCodeAt(t+1)]<<4|va[s.charCodeAt(t+2)]>>2,o[a++]=e>>8&255,o[a++]=255&e),o},fromByteArray:function(s){for(var e,t=s.length,i=t%3,n=[],r=16383,o=0,a=t-i;o<a;o+=r)n.push(T_e(s,o,o+r>a?a:o+r));return i===1?(e=s[t-1],n.push(el[e>>2]+el[e<<4&63]+"==")):i===2&&(e=(s[t-2]<<8)+s[t-1],n.push(el[e>>10]+el[e>>4&63]+el[e<<2&63]+"=")),n.join("")}},el=[],va=[],I_e=typeof Uint8Array<"u"?Uint8Array:Array,rB="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Zg=0,M_e=rB.length;Zg<M_e;++Zg)el[Zg]=rB[Zg],va[rB.charCodeAt(Zg)]=Zg;function i4(s){var e=s.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=s.indexOf("=");return t===-1&&(t=e),[t,t===e?0:4-t%4]}function T_e(s,e,t){for(var i,n,r=[],o=e;o<t;o+=3)i=(s[o]<<16&16711680)+(s[o+1]<<8&65280)+(255&s[o+2]),r.push(el[(n=i)>>18&63]+el[n>>12&63]+el[n>>6&63]+el[63&n]);return r.join("")}va["-".charCodeAt(0)]=62,va["_".charCodeAt(0)]=63;const B_e=Symbol("object"),oB=new Ua(()=>new C,20);class lW{constructor(e,t,i,n,r,o){d(this,"_point");d(this,"_normal");d(this,"_tangentVelocity");d(this,"distance");d(this,"impulse");d(this,"friction");this._point=e,this.distance=t,this._normal=i,this.impulse=n,this.friction=r,this._tangentVelocity=o}get point(){return oB.get().set(this._point.x,this._point.y,this._point.z)}get normal(){return oB.get().set(this._normal.x,this._normal.y,this._normal.z)}get tangentVelocity(){return oB.get().set(this._tangentVelocity.x,this._tangentVelocity.y,this._tangentVelocity.z)}}class hW{constructor(e,t,i){d(this,"contacts");d(this,"me");d(this,"_collider");d(this,"_gameObject");this.me=e,this._collider=t,this._gameObject=t.gameObject,this.contacts=i}get collider(){return this._collider}get gameObject(){return this._gameObject}get rigidBody(){var e;return(e=this.collider)==null?void 0:e.attachedRigidbody}}class uW{constructor(e,t){d(this,"object");d(this,"collider");this.object=e,this.collider=t}}const Ys=ie("debugphysics"),aB=ie("debugcolliderplacement"),cB=ie("debugcollisions"),R_e=ie("showcolliders"),lB=ie("debugraycasts"),fo=Symbol("needle component"),qr=Symbol("physics body"),n4=Symbol("rigidbody");let df;globalThis.false=globalThis.false!==void 0?globalThis.false:!0;Ys&&console.log("Use Rapier",!1,globalThis.false);const uv=class{constructor(){d(this,"debugRenderColliders",!1);d(this,"debugRenderRaycasts",!1);d(this,"context");d(this,"_initializePromise");d(this,"_isInitialized",!1);d(this,"rapierRay",new w_e({x:0,y:0,z:0},{x:0,y:0,z:1}));d(this,"raycastVectorsBuffer",new Ua(()=>new C,10));d(this,"rapierSphere",null);d(this,"rapierColliderArray",[]);d(this,"rapierIdentityRotation",{x:0,y:0,z:0,w:1});d(this,"rapierForwardVector",{x:0,y:0,z:1});d(this,"enabled",!1);d(this,"_tempPosition",new C);d(this,"_tempQuaternion",new Se);d(this,"_tempScale",new C);d(this,"_tempMatrix",new Ae);d(this,"_isUpdatingPhysicsWorld",!1);d(this,"_world");d(this,"_hasCreatedWorld",!1);d(this,"eventQueue");d(this,"collisionHandler");d(this,"objects",[]);d(this,"bodies",[]);d(this,"_meshCache",new Map);d(this,"_gravity",{x:0,y:-9.81,z:0});d(this,"lines");d(this,"_tempCenterPos",new C);d(this,"_tempCenterVec",new C);d(this,"_tempCenterQuaternion",new Se)}removeBody(e){var i,n,r;if(!e)return;this.validate();const t=e[qr];if(e[qr]=null,t&&this.world){const o=this.objects.findIndex(a=>a===e);if(o>=0){const a=this.bodies[o];if(this.bodies.splice(o,1),this.objects.splice(o,1),a instanceof t4){const c=a;(i=this.world)==null||i.removeCollider(c,!0);const l=c.parent();l&&l.numColliders()<=0&&(l[fo]||(n=this.world)==null||n.removeRigidBody(l))}else a instanceof e4&&(a.numColliders()<=0?(r=this.world)==null||r.removeRigidBody(a):ht()&&(a.did_log_removing||setTimeout(()=>{a.numColliders()>0&&(a.did_log_removing=!0,console.warn("RapierPhysics: removing rigidbody with colliders from the physics world is not possible right now, please remove the colliders first"))},1)))}}}updateBody(e,t,i){if(this.validate(),!!this.enabled&&!(e.destroyed||!e.gameObject)&&!(!t&&!i))if(e.isCollider===!0)console.warn("TODO: implement updating collider position");else{const n=e,r=n[qr];r&&this.syncPhysicsBody(n.gameObject,r,t,i)}}updateProperties(e){if(this.validate(),e.isCollider){const t=e,i=t[qr];i&&(this.internalUpdateColliderProperties(t,i),t.sharedMaterial&&this.updatePhysicsMaterial(t))}else{const t=e,i=this.internal_getRigidbody(t);i&&this.internalUpdateRigidbodyProperties(t,i)}}addForce(e,t,i){this.validate();const n=this.internal_getRigidbody(e);n?n.addForce(t,i):console.warn("Rigidbody doesn't exist: can not apply force")}addImpulse(e,t,i){this.validate();const n=this.internal_getRigidbody(e);n?n.applyImpulse(t,i):console.warn("Rigidbody doesn't exist: can not apply impulse")}getLinearVelocity(e){this.validate();const t=this.internal_getRigidbody(e);return t?t.linvel():null}getAngularVelocity(e){this.validate();const t=this.internal_getRigidbody(e);return t?t.angvel():null}resetForces(e,t){this.validate();const i=this.internal_getRigidbody(e);i==null||i.resetForces(t)}resetTorques(e,t){this.validate();const i=this.internal_getRigidbody(e);i==null||i.resetTorques(t)}applyImpulse(e,t,i){this.validate();const n=this.internal_getRigidbody(e);n?n.applyImpulse(t,i):console.warn("Rigidbody doesn't exist: can not apply impulse")}wakeup(e){this.validate();const t=this.internal_getRigidbody(e);t?t.wakeUp():console.warn("Rigidbody doesn't exist: can not wake up")}isSleeping(e){this.validate();const t=this.internal_getRigidbody(e);return t==null?void 0:t.isSleeping()}setAngularVelocity(e,t,i){this.validate();const n=this.internal_getRigidbody(e);n?n.setAngvel(t,i):console.warn("Rigidbody doesn't exist: can not set angular velocity")}setLinearVelocity(e,t,i){this.validate();const n=this.internal_getRigidbody(e);n?n.setLinvel(t,i):console.warn("Rigidbody doesn't exist: can not set linear velocity")}async initialize(e){return this.context=e,this._initializePromise||(this._initializePromise=this.internalInitialization()),this._initializePromise}async internalInitialization(){return Ys&&console.log("Initialize rapier physics engine"),"env"in{url:typeof document>"u"?require("url").pathToFileURL(__filename).href:sL&&sL.src||new URL("dist/needle-engine.light.umd.cjs",document.baseURI).href}&&{}.VITE_NEEDLE_USE_RAPIER==="false"&&Ys&&console.log("Rapier disabled"),!1}validate(){this._isInitialized||Ys&&(this._lastWarnTime=this._lastWarnTime??0,Date.now()-this._lastWarnTime>1e3&&(this._lastWarnTime=Date.now(),console.warn("Physics engine is not initialized")))}raycast(e,t,i){var c;let n=i==null?void 0:i.maxDistance,r=i==null?void 0:i.solid;n===void 0&&(n=1/0),r===void 0&&(r=!0);const o=this.getPhysicsRay(this.rapierRay,e,t);if(!o)return null;(this.debugRenderRaycasts||lB)&&vt.DrawRay(o.origin,o.dir,255,1);const a=(c=this.world)==null?void 0:c.castRay(o,n,r,i==null?void 0:i.queryFilterFlags,i==null?void 0:i.filterGroups,void 0,void 0,l=>{const h=l[fo];return i!=null&&i.filterPredicate?i.filterPredicate(h):!(h!=null&&h.gameObject.layers.isEnabled(2))});if(a){const l=o.pointAt(a.toi),h=this.raycastVectorsBuffer.get();return h.set(l.x,l.y,l.z),{point:h,collider:a.collider[fo]}}return null}raycastAndGetNormal(e,t,i){var c;let n=i==null?void 0:i.maxDistance,r=i==null?void 0:i.solid;n===void 0&&(n=1/0),r===void 0&&(r=!0);const o=this.getPhysicsRay(this.rapierRay,e,t);if(!o)return null;(this.debugRenderRaycasts||lB)&&vt.DrawRay(o.origin,o.dir,255,1);const a=(c=this.world)==null?void 0:c.castRayAndGetNormal(o,n,r,i==null?void 0:i.queryFilterFlags,i==null?void 0:i.filterGroups,void 0,void 0,l=>{const h=l[fo];return i!=null&&i.filterPredicate?i.filterPredicate(h):!(h!=null&&h.gameObject.layers.isEnabled(2))});if(a){const l=o.pointAt(a.toi),h=a.normal,u=this.raycastVectorsBuffer.get(),f=this.raycastVectorsBuffer.get();return u.set(l.x,l.y,l.z),f.set(h.x,h.y,h.z),{point:u,normal:f,collider:a.collider[fo]}}return null}getPhysicsRay(e,t,i){var a,c,l;const n=(a=this.context)==null?void 0:a.mainCamera;if(t===void 0){const h=(c=this.context)==null?void 0:c.input.getPointerPosition(0);if(h)t=h;else return null}if(t.z===void 0){if(!n)return console.error("Can not perform raycast from 2d point - no main camera found"),null;const h=this.raycastVectorsBuffer.get();h.x=t.x,h.y=t.y,h.z=0,(h.x>1||h.y>1||h.y<-1||h.x<-1)&&(Ys&&console.warn("Converting screenspace to raycast space",h),(l=this.context)==null||l.input.convertScreenspaceToRaycastSpace(h)),h.unproject(n),t=h}const r=t;e.origin.x=r.x,e.origin.y=r.y,e.origin.z=r.z;const o=this.raycastVectorsBuffer.get();if(i)o.set(i.x,i.y,i.z);else{if(!n)return console.error("Can not perform raycast - no camera found"),null;o.set(e.origin.x,e.origin.y,e.origin.z);const h=Ot(n);o.sub(h)}return o.normalize(),e.dir.x=o.x,e.dir.y=o.y,e.dir.z=o.z,e}sphereOverlap(e,t){return this.rapierColliderArray.length=0,this.world?(this.rapierSphere||(this.rapierSphere=new WO(t)),this.rapierSphere.radius=t,(this.debugRenderRaycasts||lB)&&vt.DrawWireSphere(e,t,3359999,1),this.world.intersectionsWithShape(e,this.rapierIdentityRotation,this.rapierSphere,i=>{const n=i[fo],r=new uW(n.gameObject,n);return this.rapierColliderArray.push(r),!0},void 0,void 0,void 0,void 0,i=>i.isSensor()?!1:i[fo].gameObject.layers.isEnabled(2)==!1),this.rapierColliderArray):this.rapierColliderArray}get world(){return this._world}get isUpdating(){return this._isUpdatingPhysicsWorld}get gravity(){var e;return((e=this.world)==null?void 0:e.gravity)??this._gravity}set gravity(e){this.world?this.world.gravity=e:this._gravity=e}clearCaches(){var e,t,i,n;this._meshCache.clear(),(e=this.eventQueue)!=null&&e.raw&&((t=this.eventQueue)==null||t.free()),(i=this.world)!=null&&i.bodies&&((n=this.world)==null||n.free())}async addBoxCollider(e,t){if(this._isInitialized||await this.initialize(e.context),!e.activeAndEnabled)return;if(!this.enabled){Ys&&console.warn("Physics are disabled");return}const i=e.gameObject,n=Ji(i,this._tempPosition).multiply(t);n.multiplyScalar(.5),n.x<0&&(n.x=Math.abs(n.x)),n.y<0&&(n.y=Math.abs(n.y)),n.z<0&&(n.z=Math.abs(n.z)),n.x==0&&(n.x=1e-7),n.y==0&&(n.y=1e-7),n.z==0&&(n.z=1e-7);const r=dn.cuboid(n.x,n.y,n.z);this.createCollider(e,r)}async addSphereCollider(e){if(this._isInitialized||await this.initialize(e.context),!e.activeAndEnabled)return;if(!this.enabled){Ys&&console.warn("Physics are disabled");return}const t=dn.ball(.5);this.createCollider(e,t),this.updateProperties(e)}async addCapsuleCollider(e,t,i){if(this._isInitialized||await this.initialize(e.context),!e.activeAndEnabled)return;if(!this.enabled){Ys&&console.warn("Physics are disabled");return}const n=e.gameObject,r=Ji(n,this._tempPosition);r.x=Math.abs(r.x),r.y=Math.abs(r.y);const o=i*r.x;t=Math.max(t,o*2);const a=tt.clamp(t*.5*r.y-i*r.x,0,Number.MAX_SAFE_INTEGER),c=dn.capsule(a,o);this.createCollider(e,c)}async addMeshCollider(e,t,i,n){var l,h,u;if(this._isInitialized||await this.initialize(e.context),!e.activeAndEnabled)return;if(!this.enabled){Ys&&console.warn("Physics are disabled");return}let r=t.geometry;if(!r){Ys&&console.warn("Missing mesh geometry",t.name);return}(h=(l=r.index)==null?void 0:l.array)!=null&&h.length||(console.warn(`Your MeshCollider is missing vertices or indices in the assined mesh "${t.name}". Consider providing an indexed geometry.`),r=Cae(r));let o=r.getAttribute("position").array;const a=(u=r.index)==null?void 0:u.array;if(Math.abs(n.x-1)>1e-4||Math.abs(n.y-1)>1e-4||Math.abs(n.z-1)>1e-4){const f=r.uuid+"_"+n.x+"_"+n.y+"_"+n.z+"_"+i;if(this._meshCache.has(f))Ys&&console.warn("Use cached mesh collider"),o=this._meshCache.get(f);else{(Ys||ht())&&console.warn(`Your MeshCollider "${e.name}" is scaled: consider applying the scale to the collider mesh instead (${n.x}, ${n.y}, ${n.z})`);const p=new Float32Array(o.length);for(let g=0;g<o.length;g+=3)p[g]=o[g]*n.x,p[g+1]=o[g+1]*n.y,p[g+2]=o[g+2]*n.z;o=p,this._meshCache.set(f,p)}}const c=i?dn.convexHull(o):dn.trimesh(o,a);c&&this.createCollider(e,c)}updatePhysicsMaterial(e){if(!e)return;const t=e.sharedMaterial,i=e[qr];if(i&&t){if(t.bounciness!==void 0&&i.setRestitution(t.bounciness),t.bounceCombine!==void 0)switch(t.bounceCombine){case Ms.Average:i.setRestitutionCombineRule(ts.Average);break;case Ms.Maximum:i.setRestitutionCombineRule(ts.Max);break;case Ms.Minimum:i.setRestitutionCombineRule(ts.Min);break;case Ms.Multiply:i.setRestitutionCombineRule(ts.Multiply);break}if(t.dynamicFriction!==void 0&&i.setFriction(t.dynamicFriction),t.frictionCombine!==void 0)switch(t.frictionCombine){case Ms.Average:i.setFrictionCombineRule(ts.Average);break;case Ms.Maximum:i.setFrictionCombineRule(ts.Max);break;case Ms.Minimum:i.setFrictionCombineRule(ts.Min);break;case Ms.Multiply:i.setFrictionCombineRule(ts.Multiply);break}}}getBody(e){return e?e[qr]:null}getComponent(e){return e?e[fo]:null}createCollider(e,t){var o;if(!this.world)throw new Error("Physics world not initialized");const i=this._tempMatrix;let n;e.attachedRigidbody?n=this.getRigidbody(e,this._tempMatrix):(Ys&&console.log("Create collider without rigidbody",e.name),i.makeRotationFromQuaternion(Fi(e.gameObject)),i.setPosition(Ot(e.gameObject))),i.decompose(this._tempPosition,this._tempQuaternion,this._tempScale),this.tryApplyCenter(e,this._tempPosition),t.setTranslation(this._tempPosition.x,this._tempPosition.y,this._tempPosition.z),t.setRotation(this._tempQuaternion),t.setSensor(e.isTrigger);const r=e.sharedMaterial;if(r){if(r.bounciness!==void 0&&t.setRestitution(r.bounciness),r.bounceCombine!==void 0)switch(r.bounceCombine){case Ms.Average:t.setRestitutionCombineRule(ts.Average);break;case Ms.Maximum:t.setRestitutionCombineRule(ts.Max);break;case Ms.Minimum:t.setRestitutionCombineRule(ts.Min);break;case Ms.Multiply:t.setRestitutionCombineRule(ts.Multiply);break}if(r.dynamicFriction!==void 0&&t.setFriction(r.dynamicFriction),r.frictionCombine!==void 0)switch(r.frictionCombine){case Ms.Average:t.setFrictionCombineRule(ts.Average);break;case Ms.Maximum:t.setFrictionCombineRule(ts.Max);break;case Ms.Minimum:t.setFrictionCombineRule(ts.Min);break;case Ms.Multiply:t.setFrictionCombineRule(ts.Multiply);break}}((o=e.attachedRigidbody)==null?void 0:o.autoMass)===!1&&(t.setDensity(1e-6),t.setMass(1e-6));try{const a=this.world.createCollider(t,n);return a[fo]=e,e[qr]=a,a.setActiveEvents(LS.COLLISION_EVENTS),a.setActiveCollisionTypes(FS.ALL),this.objects.push(e),this.bodies.push(a),this.updateColliderCollisionGroups(e),a}catch(a){return console.error('Error creating collider "'+e.name+`"
7502
+ Error:`,a),null}}updateColliderCollisionGroups(e){const t=e[qr],i=e.membership;let n=0;if(i==null)n=65535;else for(let a=0;a<i.length;a++){const c=i[a];c>31?console.error(`Rapier only supports 32 layers, layer ${c} is not supported`):n|=1<<Math.floor(c)}const r=e.filter;let o=0;if(r==null)o=65535;else for(let a=0;a<r.length;a++){const c=r[a];c>31?console.error(`Rapier only supports 32 layers, layer ${c} is not supported`):o|=1<<Math.floor(c)}t.setCollisionGroups(n<<16|o)}getRigidbody(e,t){if(!this.world)throw new Error("Physics world not initialized");let i=null;if(e.attachedRigidbody){const n=e.attachedRigidbody;if(i=n[qr],!i){const r=n.isKinematic&&!aB;Ys&&console.log("Create rigidbody",r);const o=r?df.RigidBodyDesc.kinematicPositionBased():df.RigidBodyDesc.dynamic(),a=Ot(e.attachedRigidbody.gameObject);o.setTranslation(a.x,a.y,a.z),o.setRotation(Fi(e.attachedRigidbody.gameObject)),o.centerOfMass=new df.Vector3(n.centerOfMass.x,n.centerOfMass.y,n.centerOfMass.z),i=this.world.createRigidBody(o),this.bodies.push(i),this.objects.push(n)}i[fo]=n,n[qr]=i,this.internalUpdateRigidbodyProperties(n,i),this.getRigidbodyRelativeMatrix(e.gameObject,n.gameObject,t),e[n4]=i}else{const n=df.RigidBodyDesc.kinematicPositionBased(),r=Ot(e.gameObject);n.setTranslation(r.x,r.y,r.z),n.setRotation(Fi(e.gameObject)),i=this.world.createRigidBody(n),t.identity(),i[fo]=null}return i}internal_getRigidbody(e){return e.isCollider===!0?e[n4]:e[qr]}internalUpdateColliderProperties(e,t){const i=t.shape;let n=!1;switch(i.type){case Kn.Ball:{const f=i,p=e,g=e.gameObject,y=Ji(g,this._tempPosition),m=Math.abs(p.radius*y.x);n=f.radius!==m,f.radius=m,n&&t.setShape(f);break}case Kn.Cuboid:const r=i,o=e,a=e.gameObject,c=Ji(a,this._tempPosition),l=o.size.x*.5*c.x,h=o.size.y*.5*c.y,u=o.size.z*.5*c.z;n=r.halfExtents.x!==l||r.halfExtents.y!==h||r.halfExtents.z!==u,r.halfExtents.x=l,r.halfExtents.y=h,r.halfExtents.z=u,n&&t.setShape(r);break}if(n){const r=e.attachedRigidbody;if(r!=null&&r.autoMass){const o=this.getBody(r);o==null||o.recomputeMassPropertiesFromColliders()}}this.updateColliderCollisionGroups(e),e.isTrigger!==t.isSensor()&&t.setSensor(e.isTrigger)}internalUpdateRigidbodyProperties(e,t){if(t.enableCcd(e.collisionDetectionMode!==uI.Discrete),t.setLinearDamping(e.drag),t.setAngularDamping(e.angularDrag),t.setGravityScale(e.useGravity?e.gravityScale:0,!0),e.dominanceGroup<=127&&e.dominanceGroup>=-127?t.setDominanceGroup(Math.floor(e.dominanceGroup)):t.setDominanceGroup(0),e.autoMass){t.setAdditionalMass(0,!1);for(let i=0;i<t.numColliders();i++)t.collider(i).setDensity(1);t.recomputeMassPropertiesFromColliders()}else{t.setAdditionalMass(e.mass,!1);for(let i=0;i<t.numColliders();i++)t.collider(i).setDensity(1e-7);t.recomputeMassPropertiesFromColliders()}t.setEnabledRotations(!e.lockRotationX,!e.lockRotationY,!e.lockRotationZ,!1),t.setEnabledTranslations(!e.lockPositionX,!e.lockPositionY,!e.lockPositionZ,!1),e.isKinematic?t.setBodyType(df.RigidBodyType.KinematicPositionBased,!1):t.setBodyType(df.RigidBodyType.Dynamic,!1)}step(e){if(this.world&&this.enabled){if(this._isUpdatingPhysicsWorld=!0,this.eventQueue||(this.eventQueue=new E_e(!1)),e===void 0||e<=0){this._isUpdatingPhysicsWorld=!1;return}else e!==void 0&&(this.world.timestep=tt.lerp(this.world.timestep,e,.8));try{this.world.step(this.eventQueue)}catch(t){console.warn("Error running physics step",t)}this._isUpdatingPhysicsWorld=!1}}postStep(){this.world&&this.enabled&&(this._isUpdatingPhysicsWorld=!0,this.syncObjects(),this._isUpdatingPhysicsWorld=!1,this.eventQueue&&!this.collisionHandler&&(this.collisionHandler=new P_e(this.world,this.eventQueue)),this.collisionHandler&&(this.collisionHandler.handleCollisionEvents(),this.collisionHandler.update()),this.updateDebugRendering(this.world))}updateDebugRendering(e){var t,i,n,r;if(Ys||aB||R_e||this.debugRenderColliders===!0){if(!this.lines){const a=new sn({color:7855479,fog:!1}),c=new _t;this.lines=new so(c,a),this.lines.layers.disableAll(),this.lines.layers.enable(2)}this.lines.parent!==((t=this.context)==null?void 0:t.scene)&&((i=this.context)==null||i.scene.add(this.lines));const o=e.debugRender();this.lines.geometry.setAttribute("position",new it(o.vertices,3)),this.lines.geometry.setAttribute("color",new it(o.colors,4)),(this.context.time.frame%30===0||((n=this.lines.geometry.boundingSphere)==null?void 0:n.radius)===0)&&this.lines.geometry.computeBoundingSphere()}else this.lines&&((r=this.context)==null||r.scene.remove(this.lines))}syncObjects(){if(!aB)for(let e=0;e<this.bodies.length;e++){const t=this.objects[e],i=this.bodies[e],n=t;if((n==null?void 0:n.isCollider)===!0&&!n.attachedRigidbody){const c=i.parent();c?this.syncPhysicsBody(t.gameObject,c,!0,!0):this.syncPhysicsBody(t.gameObject,i,!0,!0);continue}const r=i.translation(),o=i.rotation();if(Number.isNaN(r.x)||Number.isNaN(o.x)){!n.__COLLIDER_NAN&&ht()&&(console.warn("Collider has NaN values",n.name,n.gameObject,i),n.__COLLIDER_NAN=!0);continue}const a=t.center;if(a&&a.isVector3){this._tempQuaternion.set(o.x,o.y,o.z,o.w);const c=this._tempPosition.copy(a).applyQuaternion(this._tempQuaternion),l=Ji(t.gameObject);c.multiply(l),r.x-=c.x,r.y-=c.y,r.z-=c.z}dp(t.gameObject,r.x,r.y,r.z),E2(t.gameObject,o.x,o.y,o.z,o.w)}}syncPhysicsBody(e,t,i,n){if(t instanceof e4){const r=Ot(e,this._tempPosition),o=Fi(e,this._tempQuaternion);switch(t.bodyType()){case ov.Fixed:case ov.KinematicPositionBased:case ov.KinematicVelocityBased:i&&t.setNextKinematicTranslation(r),n&&t.setNextKinematicRotation(o);break;default:i&&t.setTranslation(r,!1),n&&t.setRotation(o,!1);break}}else if(t instanceof t4){const r=Ot(e,this._tempPosition),o=Fi(e,this._tempQuaternion),a=t[fo];if(this.tryApplyCenter(a,r),i){const c=t.translation();(c.x!==r.x||c.y!==r.y||c.z!==r.z)&&t.setTranslation(r)}if(n){const c=t.rotation();(c.x!==o.x||c.y!==o.y||c.z!==o.z||c.w!==o.w)&&t.setRotation(o)}}}tryApplyCenter(e,t){const i=e.center;i&&e.gameObject&&(i.x!==0||i.y!==0||i.z!==0)&&(this._tempCenterPos.x=-i.x,this._tempCenterPos.y=i.y,this._tempCenterPos.z=i.z,Ji(e.gameObject,this._tempCenterVec),this._tempCenterPos.multiply(this._tempCenterVec),e.attachedRigidbody?this._tempCenterPos.applyQuaternion(e.gameObject.quaternion):(Fi(e.gameObject,this._tempCenterQuaternion),this._tempCenterPos.applyQuaternion(this._tempCenterQuaternion)),t.x+=this._tempCenterPos.x,t.y+=this._tempCenterPos.y,t.z+=this._tempCenterPos.z)}getRigidbodyRelativeMatrix(e,t,i,n){if(n===void 0&&(n=uv._matricesBuffer,n.length=0),e===t){const r=Ji(e,this._tempPosition);i.makeScale(r.x,r.y,r.z);for(let o=n.length-1;o>=0;o--)i.multiply(n[o]);return i}return n.push(e.matrix),e.parent&&this.getRigidbodyRelativeMatrix(e.parent,t,i,n),i}addFixedJoint(e,t){if(!this.world){console.error("Physics world not initialized");return}const i=e[qr],n=t[qr];this.calculateJointRelativeMatrices(e.gameObject,t.gameObject,this._tempMatrix),this._tempMatrix.decompose(this._tempPosition,this._tempQuaternion,this._tempScale);const r=uh.fixed(uv.centerConnectionPos,uv.centerConnectionRot,this._tempPosition,this._tempQuaternion),o=this.world.createImpulseJoint(r,i,n,!0);Ys&&console.log("ADD FIXED JOINT",o)}addHingeJoint(e,t,i,n){if(!this.world){console.error("Physics world not initialized");return}const r=e[qr],o=t[qr];this.calculateJointRelativeMatrices(e.gameObject,t.gameObject,this._tempMatrix),this._tempMatrix.decompose(this._tempPosition,this._tempQuaternion,this._tempScale);const a=df.JointData.revolute(i,this._tempPosition,n),c=this.world.createImpulseJoint(a,r,o,!0);Ys&&console.log("ADD HINGE JOINT",c)}calculateJointRelativeMatrices(e,t,i){e.updateWorldMatrix(!0,!1),t.updateWorldMatrix(!0,!1);const n=e.matrixWorld,r=t.matrixWorld;n.elements[0]=1,n.elements[5]=1,n.elements[10]=1,r.elements[0]=1,r.elements[5]=1,r.elements[10]=1,i.copy(r).premultiply(n.invert()).invert()}};let yf=uv;d(yf,"_didLoadPhysicsEngine",!1),d(yf,"_matricesBuffer",[]),d(yf,"centerConnectionPos",{x:0,y:0,z:0}),d(yf,"centerConnectionRot",{x:0,y:0,z:0,w:1});class P_e{constructor(e,t){d(this,"world");d(this,"eventQueue");d(this,"activeCollisions",[]);d(this,"activeCollisionsStay",[]);d(this,"activeTriggers",[]);this.world=e,this.eventQueue=t}handleCollisionEvents(){this.eventQueue&&this.world&&this.eventQueue.drainCollisionEvents((e,t,i)=>{const n=this.world.getCollider(e),r=this.world.getCollider(t);if(!n||!r)return;const o=n[fo],a=r[fo];cB&&console.log("EVT",o.name,a.name,i,n,r),o&&a&&(i?(this.onCollisionStarted(o,n,a,r),this.onCollisionStarted(a,r,o,n)):(this.onCollisionEnded(o,a),this.onCollisionEnded(a,o)))})}update(){this.onHandleCollisionStay()}onCollisionStarted(e,t,i,n){let r=null;if(e.isTrigger||i.isTrigger)yp(e.gameObject,o=>{o.onTriggerEnter&&!o.destroyed&&o.onTriggerEnter(i),this.activeTriggers.push({collider:e,component:o,otherCollider:i})});else{const o=e.gameObject;this.world.contactPair(t,n,(a,c)=>{yp(o,l=>{var u;if(l.destroyed)return;const h=l.onCollisionEnter||l.onCollisionStay||l.onCollisionExit;if(h||cB){if(!r){const f=[],p=a.normal();for(let g=0;g<a.numSolverContacts();g++){const y=a.solverContactPoint(g),m=a.contactImpulse(g);if(y){const A=a.contactDist(g),b=a.solverContactFriction(g),v=a.solverContactTangentVelocity(g),_=new lW(y,A,p,m,b,v);f.push(_),cB&&vt.DrawDirection(y,p,16711680,3,!0)}}r=new hW(o,i,f)}if(h){const f={collider:e,component:l,collision:r};this.activeCollisions.push(f),l.onCollisionStay&&this.activeCollisionsStay.push(f),(u=l.onCollisionEnter)==null||u.call(l,r)}}})})}}onHandleCollisionStay(){for(const e of this.activeCollisionsStay){const t=e.component;if(!t.destroyed&&t.activeAndEnabled&&t.onCollisionStay){if(e.collision.collider.destroyed)continue;const i=e.collision;t.onCollisionStay(i)}}for(const e of this.activeTriggers){const t=e.component;if(!t.destroyed&&t.activeAndEnabled&&t.onTriggerStay){const i=e.otherCollider;if(i.destroyed)continue;t.onTriggerStay(i)}}}onCollisionEnded(e,t){if(!(e.destroyed||t.destroyed)){for(let i=0;i<this.activeCollisions.length;i++){const n=this.activeCollisions[i],r=n.collider;if(r.destroyed||n.collision.collider.destroyed){this.activeCollisions.splice(i,1),i--;continue}if(r===e&&n.collision.collider===t){const o=n.component;if(this.activeCollisions.splice(i,1),i--,o.activeAndEnabled&&o.onCollisionExit){const a=n.collision;o.onCollisionExit(a)}}}for(let i=0;i<this.activeCollisionsStay.length;i++){const n=this.activeCollisionsStay[i],r=n.collider;if(r.destroyed||n.collision.collider.destroyed){this.activeCollisionsStay.splice(i,1),i--;continue}if(r===e&&n.collision.collider===t){const o=n.component;if(this.activeCollisionsStay.splice(i,1),i--,o.activeAndEnabled&&o.onCollisionExit){const a=n.collision;o.onCollisionExit(a)}}}for(let i=0;i<this.activeTriggers.length;i++){const n=this.activeTriggers[i],r=n.collider;if(r.destroyed||n.otherCollider.destroyed){this.activeTriggers.splice(i,1),i--;continue}if(r===e&&n.otherCollider===t){const o=n.component;if(this.activeTriggers.splice(i,1),i--,o.activeAndEnabled&&o.onTriggerExit){const a=n.otherCollider;o.onTriggerExit(a)}}}}}}class D_e{static async createComparisonScene(e){const{files:t}=e,n=await Promise.all(t.map(m=>new $t(m).loadAssetAsync())),r=new rr;let o=0;for(const m of n)if(m instanceof ye){m.position.y=o,r.add(m);const A=ld([m]);o+=A.getSize(new C).y,o+=.1}const a=new Nt(20);r.add(a);const c=e.environment||"https://dl.polyhaven.org/file/ph-assets/HDRIs/exr/1k/studio_small_09_1k.exr";if(c){let m=null;if(c.endsWith(".hdr")){const A=(await Promise.resolve().then(()=>Fde)).RGBELoader;m=new A}else if(c.endsWith(".exr")){const A=(await Promise.resolve().then(()=>Lde)).EXRLoader;m=new A}if(m){const A=await m.loadAsync(c).catch(b=>(console.error(b),null));A&&(A.mapping=vo,A.needsUpdate=!0,r.background=A,r.environment=A,r.backgroundBlurriness=.75)}else console.warn("Unsupported environment map format",c)}const l=ld(r.children),h=l.getCenter(new C),u=l.getSize(new C),p=Math.max(u.x,u.y,u.z)/(2*Math.tan(Math.PI*a.fov/360));a.position.set(h.x,h.y,p),a.lookAt(h);const g=new E6(a,e.domElement||document.body);g.target=h,g.update();const y=(e.domElement||document.body).getBoundingClientRect();return a.aspect=y.width/y.height,a.updateProjectionMatrix(),{scene:r,camera:a}}}function k_e(s,e,t,i="image/webp",n){return dW({context:s,width:e,height:t,mimeType:i,camera:n})}function dW(s={mimeType:"image/png",transparent:!1}){s||(s={});let{context:e,width:t,height:i,camera:n}=s;const{mimeType:r}=s;if(!e&&(e=ui.Current,!e))return console.error("Can not save screenshot: No needle-engine context found or provided."),null;if(!n&&(n=e.mainCamera,!n))return console.error("No camera found"),null;const o=e.renderer.domElement.width,a=e.renderer.domElement.height;t||(t=o),i||(i=a);const c=window.devicePixelRatio||1;t/=c,i/=c,e.renderer.domElement.style.width=t+"px",e.renderer.domElement.style.height=i+"px";const l=e.renderer.getClearColor(new ve);try{s!=null&&s.transparent&&e.renderer.setClearColor(0,0);const h=e.renderer.domElement;e.renderer.setSize(t,i,!1),n instanceof Nt&&e.updateAspect(n,t,i);const u=s.render_events!==!1,f=new Array;u&&(RA(e.scene,Nn,f),f.forEach(g=>g==null?void 0:g.onBeforeRender())),e.renderNow(),u&&f.forEach(g=>g.onAfterRender());const p=h.toDataURL(r);return s.download_filename&&fW(p,s.download_filename),p}finally{e.renderer.setSize(o,a,!1),e.updateSize(),e.renderer.setClearColor(l)}return null}let Zy=null;function fW(s,e){if(s){if(!s.startsWith("data:image")){console.error("Can not save image: Data url is not an image",s);return}Zy||(Zy=document.createElement("a")),Zy.href=s,Zy.download=e,Zy.click()}}let eD=0;function s4(s){s?eD++:eD--}function O_e(){return eD>0}class pW{constructor(e){d(this,"writer");this.writer=e}writeNode(e){}}class L_e extends pW{beforeWriteNode(e,t){vt.isGizmo(e)&&(t.keep=!1)}}class F_e extends pW{beforeWriteTexture(e,t){e.isRenderTargetTexture&&(t.newTexture=Bk(new Ei(1,1,1,0)))}}const U_e={binary:!0,animations:!0};async function N_e(s){if(!s.context)throw new Error("No context provided to exportAsGLTF");s.scene||(s.scene=s.context.scene);const e={...U_e,...s},{context:t}=e,i=new LI;i.register(a=>new mj(a)),i.register(a=>new L_e(a)),i.register(a=>new F_e(a)),oO(i,e.context);const n={binary:e.binary,animations:z_e(t,e.scene,[])},r=new Q_e;console.log("Exporting GLTF",n),r.onBeforeExport(e),s4(!0);const o=await i.parseAsync(e.scene,n).catch(a=>(console.error(a),null));if(s4(!1),r.onAfterExport(e),!o)throw new Error("Failed to export GLTF");if(e.downloadAs!=null){let a=null;if(o instanceof ArrayBuffer?a=new Blob([o],{type:"application/octet-stream"}):console.error("Can not download GLTF as a blob",o),a){const c=URL.createObjectURL(a),l=document.createElement("a");l.href=c;let h=e.downloadAs;!h.endsWith(".glb")&&!h.endsWith(".gltf")&&(h+=e.binary?".glb":".gltf"),l.download=h,l.click()}}return o}const r4=Symbol("needle:weight");class Q_e{constructor(){d(this,"_undo",[])}onBeforeExport(e){e.context.animations.mixers.forEach(t=>{const i=Qv.tryGetActionsFromMixer(t);if(i)for(let n=0;n<i.length;n++){const r=i[n];r[r4]=r.weight,r.weight=0,this._undo.push(()=>{r.weight=r[r4]})}t.update(0)})}onAfterExport(e){this._undo.forEach(t=>t()),this._undo.length=0}}function z_e(s,e,t){s.animations.mixers.forEach(n=>{const r=Qv.tryGetActionsFromMixer(n);if(r)for(let o=0;o<r.length;o++){const c=r[o].getClip();t.push(c)}}),Array.isArray(e)||(e=[e]);for(const n of e)Qv.tryGetAnimationClipsFromObjectHierarchy(n,t);const i=new Set(t);return Array.from(i)}Object.defineProperty(Nt.prototype,"fov",{get:function(){return this._fov},set:function(s){const e=s!==this._fov;this._fov=s,e&&this.view!==void 0&&this.updateProjectionMatrix()}});Object.defineProperty(Nt.prototype,"near",{get:function(){return this._near},set:function(s){const e=s!==this._near;this._near=s,e&&this.view!==void 0&&this.updateProjectionMatrix()}});Object.defineProperty(Nt.prototype,"far",{get:function(){return this._far},set:function(s){const e=s!==this._far;this._far=s,e&&this.view!==void 0&&this.updateProjectionMatrix()}});const US=ie("debugmissingcamera");ui.registerCallback(Ti.MissingCamera,s=>{var o,a,c;US&&console.warn("Creating missing camera");const e=s.context.scene,t=new Nt;t.name="Default Fallback Camera",e.add(t);const i=new Vi;i.sourceId=((a=(o=s.files)==null?void 0:o[0])==null?void 0:a.src)??"unknown",(c=s.context.domElement.getAttribute("skybox-image"))!=null&&c.length||0>0||s.context.lightmaps.tryGetSkybox(i.sourceId)?i.clearFlags=vp.Skybox:i.clearFlags=vp.SolidColor,i.backgroundColor=new Ei(.5,.5,.5,1),i.fieldOfView=35,i.backgroundBlurriness=.2;const n=Wf(t,i,!0);t.position.x=0,t.position.y=1,t.position.z=2;const r=s.context.domElement;return(r==null?void 0:r.cameraControls)!=!1&&gW(s.context,n),n});ui.registerCallback(Ti.ContextCreated,s=>{if(!s.context.mainCamera){US&&console.log("Will not auto-fit because a default camera exists");return}const e=s.context.domElement;if((e==null?void 0:e.cameraControls)==!0){const t=m8(s.context.mainCamera);if((t==null?void 0:t.isCameraController)==!0){US&&console.log("Will not auto-fit because a camera controller exists");return}gW(s.context)}});function gW(s,e){e=e??s.mainCameraComponent;const t=e==null?void 0:e.gameObject;if(US&&console.log("Creating default camera controls",e==null?void 0:e.name),t){const i=Lb(t,xi);i.sourceId=(e==null?void 0:e.sourceId)??"unknown";const n=s.domElement.getAttribute("auto-rotate");i.autoRotate=n!==void 0&&(n===""||n==="true"),i.autoRotateSpeed=.5,i.autoFit=!0}else console.warn("Missing camera object, can not add orbit controls")}const qO={Context:Dt,glTF:{loadFromURL:NO}};globalThis.Needle!==void 0&&console.warn("Needle Engine is already imported");globalThis.Needle=qO;function mW(s){for(const e in s)qO[e]=s[e]}mW(pfe);mW(Kbe);for(const s of Object.getOwnPropertyNames(re))switch(s){case"prototype":case"constructor":case"length":case"name":continue;default:qO[s]=re[s];break}globalThis.THREE?console.warn("Threejs is already imported"):globalThis.THREE=BZ;class G_e{constructor(e){if(this._retries=0,!Number.isInteger(e)||e<0)throw new Error("Backoff must be a positive integer");this.backoff=e}get retries(){return this._retries}get current(){return this.backoff}next(){return this._retries++,this.backoff}reset(){this._retries=0}}class H_e{constructor(e,t){if(this._retries=0,!Number.isInteger(e)||e<0)throw new Error("Base must be a positive integer or zero");if(t!==void 0&&(!Number.isInteger(t)||t<0))throw new Error("ExpMax must be a undefined, a positive integer or zero");this.base=e,this.expMax=t,this.i=0}get retries(){return this._retries}get current(){return this.base*Math.pow(2,this.i)}next(){return this._retries++,this.i=this.expMax===void 0?this.i+1:Math.min(this.i+1,this.expMax),this.current}reset(){this._retries=0,this.i=0}}class V_e{constructor(e,t,i){if(this.i=0,this._retries=0,e<0)throw new Error("Initial must be a positive number or zero");if(t<0)throw new Error("Increment must be a positive number or zero");if(i!==void 0&&i<0)throw new Error("Max must be undefined, a positive number or zero");if(i!==void 0&&i<e)throw new Error("Max must be undefined or greater than or equal to initial");this.initial=e,this.increment=t,this.max=i}get retries(){return this._retries}get current(){return this.max===void 0?this.initial+this.increment*this.i:Math.min(this.initial+this.increment*this.i,this.max)}next(){return this._retries++,this.i++,this.current}reset(){this._retries=0,this.i=0}}class j_e{constructor(){this.elements=[]}add(e){this.elements.push(e)}clear(){this.elements.length=0}forEach(e){this.elements.forEach(e)}length(){return this.elements.length}isEmpty(){return this.elements.length===0}peek(){return this.elements[0]}read(){return this.elements.shift()}}class W_e{constructor(e){if(!Number.isInteger(e)||e<=0)throw new Error("Capacity must be a positive integer");this.elements=new Array(e+1),this.head=0,this.tail=0}add(e){this.elements[this.head]=e,this.head=(this.head+1)%this.elements.length,this.head===this.tail&&(this.tail=(this.tail+1)%this.elements.length)}clear(){this.head=0,this.tail=0}forEach(e){for(let t=this.tail;t!==this.head;t=(t+1)%this.elements.length)e(this.elements[t])}length(){return this.tail===this.head?0:this.tail<this.head?this.head-this.tail:this.elements.length-this.tail+this.head}isEmpty(){return this.head===this.tail}peek(){return this.isEmpty()?void 0:this.elements[this.tail]}read(){const e=this.peek();return e!==void 0&&(this.tail=(this.tail+1)%this.elements.length),e}}var Ui;(function(s){s.open="open",s.close="close",s.error="error",s.message="message",s.retry="retry",s.reconnect="reconnect"})(Ui||(Ui={}));class AW{constructor(e,t,i){var n,r,o,a,c,l,h,u,f,p,g,y,m,A,b;this._closedByUser=!1,this.handleOpenEvent=v=>this.handleEvent(Ui.open,v),this.handleErrorEvent=v=>this.handleEvent(Ui.error,v),this.handleCloseEvent=v=>this.handleEvent(Ui.close,v),this.handleMessageEvent=v=>this.handleEvent(Ui.message,v),this._url=e,this._protocols=t,this._options={buffer:i==null?void 0:i.buffer,retry:{maxRetries:(n=i==null?void 0:i.retry)===null||n===void 0?void 0:n.maxRetries,instantReconnect:(r=i==null?void 0:i.retry)===null||r===void 0?void 0:r.instantReconnect,backoff:(o=i==null?void 0:i.retry)===null||o===void 0?void 0:o.backoff},listeners:{open:[...(c=(a=i==null?void 0:i.listeners)===null||a===void 0?void 0:a.open)!==null&&c!==void 0?c:[]],close:[...(h=(l=i==null?void 0:i.listeners)===null||l===void 0?void 0:l.close)!==null&&h!==void 0?h:[]],error:[...(f=(u=i==null?void 0:i.listeners)===null||u===void 0?void 0:u.error)!==null&&f!==void 0?f:[]],message:[...(g=(p=i==null?void 0:i.listeners)===null||p===void 0?void 0:p.message)!==null&&g!==void 0?g:[]],retry:[...(m=(y=i==null?void 0:i.listeners)===null||y===void 0?void 0:y.retry)!==null&&m!==void 0?m:[]],reconnect:[...(b=(A=i==null?void 0:i.listeners)===null||A===void 0?void 0:A.reconnect)!==null&&b!==void 0?b:[]]}},this._underlyingWebsocket=this.tryConnect()}get url(){return this._url}get protocols(){return this._protocols}get buffer(){return this._options.buffer}get maxRetries(){return this._options.retry.maxRetries}get instantReconnect(){return this._options.retry.instantReconnect}get backoff(){return this._options.retry.backoff}get closedByUser(){return this._closedByUser}get lastConnection(){return this._lastConnection}get underlyingWebsocket(){return this._underlyingWebsocket}get readyState(){return this._underlyingWebsocket.readyState}get bufferedAmount(){return this._underlyingWebsocket.bufferedAmount}get extensions(){return this._underlyingWebsocket.extensions}get binaryType(){return this._underlyingWebsocket.binaryType}set binaryType(e){this._underlyingWebsocket.binaryType=e}send(e){this.closedByUser||(this._underlyingWebsocket.readyState===this._underlyingWebsocket.OPEN?this._underlyingWebsocket.send(e):this.buffer!==void 0&&this.buffer.add(e))}close(e,t){this.cancelScheduledConnectionRetry(),this._closedByUser=!0,this._underlyingWebsocket.close(e,t)}addEventListener(e,t,i){this._options.listeners[e].push({listener:t,options:i})}removeEventListener(e,t,i){const n=r=>r.listener!==t||r.options!==i;this._options.listeners[e]=this._options.listeners[e].filter(n)}tryConnect(){return this._underlyingWebsocket=new WebSocket(this.url,this.protocols),this._underlyingWebsocket.addEventListener(Ui.open,this.handleOpenEvent),this._underlyingWebsocket.addEventListener(Ui.close,this.handleCloseEvent),this._underlyingWebsocket.addEventListener(Ui.error,this.handleErrorEvent),this._underlyingWebsocket.addEventListener(Ui.message,this.handleMessageEvent),this._underlyingWebsocket}clearWebsocket(){this._underlyingWebsocket.removeEventListener(Ui.open,this.handleOpenEvent),this._underlyingWebsocket.removeEventListener(Ui.close,this.handleCloseEvent),this._underlyingWebsocket.removeEventListener(Ui.error,this.handleErrorEvent),this._underlyingWebsocket.removeEventListener(Ui.message,this.handleMessageEvent),this._underlyingWebsocket.close()}dispatchEvent(e,t){const i=this._options.listeners[e],n=[];i.forEach(({listener:r,options:o})=>{r(this,t),(o===void 0||o.once===void 0||!o.once)&&n.push({listener:r,options:o})}),this._options.listeners[e]=n}handleEvent(e,t){switch(e){case Ui.close:this.dispatchEvent(e,t),this.scheduleConnectionRetryIfNeeded();break;case Ui.open:if(this.backoff!==void 0&&this._lastConnection!==void 0){const i={retries:this.backoff.retries,lastConnection:new Date(this._lastConnection)},n=new CustomEvent(Ui.reconnect,{detail:i});this.dispatchEvent(Ui.reconnect,n),this.backoff.reset()}this._lastConnection=new Date,this.dispatchEvent(e,t),this.sendBufferedData();break;case Ui.retry:this.dispatchEvent(e,t),this.clearWebsocket(),this.tryConnect();break;default:this.dispatchEvent(e,t);break}}sendBufferedData(){if(this.buffer!==void 0)for(let e=this.buffer.read();e!==void 0;e=this.buffer.read())this.send(e)}scheduleConnectionRetryIfNeeded(){if(this.closedByUser||this.backoff===void 0)return;const e=i=>{const n=new CustomEvent(Ui.retry,{detail:i});this.handleEvent(Ui.retry,n)},t={backoff:this._options.retry.instantReconnect===!0?0:this.backoff.next(),retries:this._options.retry.instantReconnect===!0?0:this.backoff.retries,lastConnection:this._lastConnection};(this._options.retry.maxRetries===void 0||t.retries<=this._options.retry.maxRetries)&&(this.retryTimeout=globalThis.setTimeout(()=>e(t),t.backoff))}cancelScheduledConnectionRetry(){globalThis.clearTimeout(this.retryTimeout)}}class q_e{constructor(e){this._url=e}get url(){return this._url}withProtocols(e){return this._protocols=e,this}get protocols(){return this._protocols}withMaxRetries(e){var t;return this._options=Object.assign(Object.assign({},this._options),{retry:Object.assign(Object.assign({},(t=this._options)===null||t===void 0?void 0:t.retry),{maxRetries:e})}),this}get maxRetries(){var e,t;return(t=(e=this._options)===null||e===void 0?void 0:e.retry)===null||t===void 0?void 0:t.maxRetries}withInstantReconnect(e){var t;return this._options=Object.assign(Object.assign({},this._options),{retry:Object.assign(Object.assign({},(t=this._options)===null||t===void 0?void 0:t.retry),{instantReconnect:e})}),this}get instantReconnect(){var e,t;return(t=(e=this._options)===null||e===void 0?void 0:e.retry)===null||t===void 0?void 0:t.instantReconnect}withBackoff(e){var t;return this._options=Object.assign(Object.assign({},this._options),{retry:Object.assign(Object.assign({},(t=this._options)===null||t===void 0?void 0:t.retry),{backoff:e})}),this}get backoff(){var e,t;return(t=(e=this._options)===null||e===void 0?void 0:e.retry)===null||t===void 0?void 0:t.backoff}withBuffer(e){return this._options=Object.assign(Object.assign({},this._options),{buffer:e}),this}get buffer(){var e;return(e=this._options)===null||e===void 0?void 0:e.buffer}onOpen(e,t){return this.addListener(Ui.open,e,t),this}onClose(e,t){return this.addListener(Ui.close,e,t),this}onError(e,t){return this.addListener(Ui.error,e,t),this}onMessage(e,t){return this.addListener(Ui.message,e,t),this}onRetry(e,t){return this.addListener(Ui.retry,e,t),this}onReconnect(e,t){return this.addListener(Ui.reconnect,e,t),this}build(){return new AW(this._url,this._protocols,this._options)}addListener(e,t,i){var n,r,o,a,c,l,h,u,f,p,g,y,m,A,b,v,_,w,E,I,M;return this._options=Object.assign(Object.assign({},this._options),{listeners:{open:(o=(r=(n=this._options)===null||n===void 0?void 0:n.listeners)===null||r===void 0?void 0:r.open)!==null&&o!==void 0?o:[],close:(l=(c=(a=this._options)===null||a===void 0?void 0:a.listeners)===null||c===void 0?void 0:c.close)!==null&&l!==void 0?l:[],error:(f=(u=(h=this._options)===null||h===void 0?void 0:h.listeners)===null||u===void 0?void 0:u.error)!==null&&f!==void 0?f:[],message:(y=(g=(p=this._options)===null||p===void 0?void 0:p.listeners)===null||g===void 0?void 0:g.message)!==null&&y!==void 0?y:[],retry:(b=(A=(m=this._options)===null||m===void 0?void 0:m.listeners)===null||A===void 0?void 0:A.retry)!==null&&b!==void 0?b:[],reconnect:(w=(_=(v=this._options)===null||v===void 0?void 0:v.listeners)===null||_===void 0?void 0:_.reconnect)!==null&&w!==void 0?w:[],[e]:[...(M=(I=(E=this._options)===null||E===void 0?void 0:E.listeners)===null||I===void 0?void 0:I[e])!==null&&M!==void 0?M:[],{listener:t,options:i}]}}),this}}const X_e=Object.freeze(Object.defineProperty({__proto__:null,ArrayQueue:j_e,ConstantBackoff:G_e,ExponentialBackoff:H_e,LinearBackoff:V_e,RingQueue:W_e,Websocket:AW,WebsocketBuilder:q_e,get WebsocketEvent(){return Ui}},Symbol.toStringTag,{value:"Module"})),Aa={node:"node",material:"material",camera:"camera",light:"light"},ff="KHR_animation_pointer",Y_e={CUBICSPLINE:void 0,LINEAR:vl,STEP:cd},o4=Yt.findNode;let a4=!1;class J_e{constructor(e){this.parser=e,this.name=ff,this.animationPointerResolver=null}setAnimationPointerResolver(e){return this.animationPointerResolver=e,this}_patchPropertyBindingFindNode(){a4||(a4=!0,Yt.findNode=function(e,t){if(t.startsWith(".materials.")){const i=t.substring(11).substring(t.indexOf(".")),n=i.indexOf("."),r=n<0?i:i.substring(0,n);let o=null;return e.traverse(a=>{o!==null||a.type!=="Mesh"&&a.type!=="SkinnedMesh"||a.material&&(a.material.uuid===r||a.material.name===r)&&(o=a.material,o!==null&&(i.endsWith(".map")?o=o.map:i.endsWith(".emissiveMap")&&(o=o.emissiveMap)))}),o}else if(t.startsWith(".nodes.")||t.startsWith(".lights.")||t.startsWith(".cameras.")){const i=t.split(".");let n;for(let r=1;r<i.length;r++){const o=i[r];if(o.length==36)n=e.getObjectByProperty("uuid",o);else if(n&&n[o]){const c=Number.parseInt(o);let l=o;c>=0&&(l=c),n=n[l]}else{const c=e.getObjectByName(o);c&&(n=c)}}if(!n){const r=o4(e,i[2]);return r||console.warn(ff+": Property binding not found",t,e,e.name,i),r}return n}return o4(e,t)})}loadAnimationTargetFromChannel(e){const t=e.target,i=t.node!==void 0?t.node:t.id;return this.parser.getDependency("node",i)}loadAnimationTargetFromChannelWithAnimationPointer(e){this._havePatchedPropertyBindings||this._patchPropertyBindingFindNode();const t=e.target,i=t.extensions&&t.extensions[ff]&&t.path&&t.path==="pointer";if(!i)return null;let n,r=Aa.node,o;if(i){const c=t.extensions[ff];let l=c.pointer;if(!l){console.warn("Invalid path",c,t);return}if(l.startsWith("/materials/")?r=Aa.material:l.startsWith("/extensions/KHR_lights_punctual/lights/")?r=Aa.light:l.startsWith("/cameras/")&&(r=Aa.camera),o=this._tryResolveTargetId(l,r),o===null||isNaN(o)){console.warn("Failed resolving animation node id: "+o,l);return}switch(r){case Aa.material:const u=("/materials/"+o.toString()+"/").length,f=l.substring(0,u);switch(n=l.substring(u),n){case"pbrMetallicRoughness/baseColorFactor":n="color";break;case"pbrMetallicRoughness/roughnessFactor":n="roughness";break;case"pbrMetallicRoughness/metallicFactor":n="metalness";break;case"emissiveFactor":n="emissive";break;case"alphaCutoff":n="alphaTest";break;case"occlusionTexture/strength":n="aoMapIntensity";break;case"normalTexture/scale":n="normalScale";break;case"pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/scale":n="map/repeat";break;case"pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/offset":n="map/offset";break;case"emissiveTexture/extensions/KHR_texture_transform/scale":n="emissiveMap/repeat";break;case"emissiveTexture/extensions/KHR_texture_transform/offset":n="emissiveMap/offset";break;case"extensions/KHR_materials_emissive_strength/emissiveStrength":n="emissiveIntensity";break;case"extensions/KHR_materials_transmission/transmissionFactor":n="transmission";break;case"extensions/KHR_materials_ior/ior":n="ior";break;case"extensions/KHR_materials_volume/thicknessFactor":n="thickness";break;case"extensions/KHR_materials_volume/attenuationColor":n="attenuationColor";break;case"extensions/KHR_materials_volume/attenuationDistance":n="attenuationDistance";break;case"extensions/KHR_materials_iridescence/iridescenceFactor":n="iridescence";break;case"extensions/KHR_materials_iridescence/iridescenceIor":n="iridescenceIOR";break;case"extensions/KHR_materials_iridescence/iridescenceThicknessMinimum":n="iridescenceThicknessRange[0]";break;case"extensions/KHR_materials_iridescence/iridescenceThicknessMaximum":n="iridescenceThicknessRange[1]";break;case"extensions/KHR_materials_clearcoat/clearcoatFactor":n="clearcoat";break;case"extensions/KHR_materials_clearcoat/clearcoatRoughnessFactor":n="clearcoatRoughness";break;case"extensions/KHR_materials_sheen/sheenColorFactor":n="sheenColor";break;case"extensions/KHR_materials_sheen/sheenRoughnessFactor":n="sheenRoughness";break;case"extensions/KHR_materials_specular/specularFactor":n="specularIntensity";break;case"extensions/KHR_materials_specular/specularColorFactor":n="specularColor";break}l=f+n;break;case Aa.node:const p=("/nodes/"+o.toString()+"/").length,g=l.substring(0,p);switch(n=l.substring(p),n){case"translation":n="position";break;case"rotation":n="quaternion";break;case"scale":n="scale";break;case"weights":n="morphTargetInfluences";break}l=g+n;break;case Aa.light:const y=("/extensions/KHR_lights_punctual/lights/"+o.toString()+"/").length;switch(n=l.substring(y),n){case"color":break;case"intensity":break;case"spot/innerConeAngle":n="penumbra";break;case"spot/outerConeAngle":n="angle";break;case"range":n="distance";break}l="/lights/"+o.toString()+"/"+n;break;case Aa.camera:const m=("/cameras/"+o.toString()+"/").length,A=l.substring(0,m);switch(n=l.substring(m),n){case"perspective/yfov":n="fov";break;case"perspective/znear":case"orthographic/znear":n="near";break;case"perspective/zfar":case"orthographic/zfar":n="far";break;case"perspective/aspect":n="aspect";break;case"orthographic/xmag":n="zoom";break;case"orthographic/ymag":n="zoom";break}l=A+n;break}const h=this.animationPointerResolver;h&&h.resolvePath&&(l=h.resolvePath(l)),t.extensions[ff].pointer=l}if(o===null||isNaN(o)){console.warn("Failed resolving animation node id: "+o,t);return}let a;return r===Aa.node?a=this.parser.getDependency("node",o):r===Aa.material?a=this.parser.getDependency("material",o):r===Aa.light?a=this.parser.getDependency("light",o):r===Aa.camera?a=this.parser.getDependency("camera",o):console.error("Unhandled type",r),a}createAnimationTracksWithAnimationPointer(e,t,i,n,r){if(!(r.extensions&&r.extensions[ff]&&r.path&&r.path==="pointer"))return null;let a=r.extensions[ff].pointer;if(!a)return null;const c=[];a=a.replaceAll("/",".");const l=a.split(".");var u=e.name!==void 0&&e.name!==null?e.name:e.uuid;if(l[2]=u,l[3]==="morphTargetInfluences"&&e.type==="Group"){for(const p of e.children)p instanceof bo&&p.morphTargetInfluences&&(l[3]=p.name,l[4]="morphTargetInfluences",f(this.parser));return c}f(this.parser);function f(p){a=l.join(".");let g;switch(i.itemSize){case 1:g=Fh;break;case 2:case 3:g=bl;break;case 4:a.endsWith(".quaternion")?g=Fa:g=CE;break}const y=n.interpolation!==void 0?Y_e[n.interpolation]:vl;let m=p._getArrayFromAccessor(i);a.endsWith(".fov")&&(m=m.map(b=>b/Math.PI*180));const A=new g(a,t.array,m,y);if(y==="CUBICSPLINE"&&p._createCubicSplineTrackInterpolant(A),c.push(A),a&&i.itemSize===4&&a.startsWith(".materials.")&&a.endsWith(".color")){const b=new Float32Array(m.length/4);for(let _=0,w=m.length/4;_<w;_+=1)b[_]=m[_*4+3];const v=new g(a.replace(".color",".opacity"),t.array,b,y);y==="CUBICSPLINE"&&p._createCubicSplineTrackInterpolant(A),c.push(v)}}return c}_tryResolveTargetId(e,t){let i="";return t==="node"?i=e.substring(7):t==="material"?i=e.substring(11):t==="light"?i=e.substring(39):t==="camera"&&(i=e.substring(9)),i=i.substring(0,i.indexOf("/")),Number.parseInt(i)}loadAnimation(e){const t=this,i=this.parser.json,n=this.parser,r=i.animations[e],o=r.name?r.name:"animation_"+e,a=[],c=[],l=[],h=[],u=[];for(let f=0,p=r.channels.length;f<p;f++){const g=r.channels[f],y=r.samplers[g.sampler],m=g.target,A=r.parameters!==void 0?r.parameters[y.input]:y.input,b=r.parameters!==void 0?r.parameters[y.output]:y.output;let v=t.loadAnimationTargetFromChannelWithAnimationPointer(g);v||(v=t.loadAnimationTargetFromChannel(g)),a.push(v),c.push(n.getDependency("accessor",A)),l.push(n.getDependency("accessor",b)),h.push(y),u.push(m)}return Promise.all([Promise.all(a),Promise.all(c),Promise.all(l),Promise.all(h),Promise.all(u)]).then(function(f){const p=f[0],g=f[1],y=f[2],m=f[3],A=f[4],b=[];for(let v=0,_=p.length;v<_;v++){const w=p[v],E=g[v],I=y[v],M=m[v],R=A[v];if(w===void 0)continue;w.updateMatrix&&(w.updateMatrix(),w.matrixAutoUpdate=!0);let S=t.createAnimationTracksWithAnimationPointer(w,E,I,M,R);if(S||(S=n._createAnimationTracks(w,E,I,M,R)),S)for(let T=0;T<S.length;T++)b.push(S[T])}return new no(o,void 0,b)})}}const K_e=Object.freeze(Object.defineProperty({__proto__:null,GLTFAnimationPointerExtension:J_e},Symbol.toStringTag,{value:"Module"}));exports.$physicsKey=B_e;exports.ActionBuilder=pi;exports.ActionCollection=ik;exports.ActionModel=go;exports.Addressables=L5;exports.AlignmentConstraint=Nb;exports.AmbientMode=Hm;exports.Animation=Rr;exports.AnimationCurve=Bp;exports.AnimationExtension=Vb;exports.AnimationTrackHandler=gI;exports.Animator=or;exports.AnimatorConditionMode=Ou;exports.AnimatorController=ea;exports.AnimatorControllerParameterType=Uk;exports.AnimatorStateInfo=_0;exports.Antialiasing=Wb;exports.Application=gl;exports.ApplicationEvents=_S;exports.AssetDatabase=e5;exports.AssetReference=$t;exports.AudioExtension=Sd;exports.AudioListener=nd;exports.AudioSource=Un;exports.AudioTrackHandler=Xf;exports.Avatar=Pp;exports.AvatarBlink_Simple=kp;exports.AvatarEyeLook_Rotation=LA;exports.AvatarLoader=Vk;exports.AvatarMarker=As;exports.AvatarModel=_I;exports.Avatar_Brain_LookAt=Yv;exports.Avatar_MouthShapes=Xb;exports.Avatar_MustacheShake=Gk;exports.Avatar_POI=Al;exports.Axes=Sm;exports.AxesHelper=FA;exports.BUILD_TIME=D2;exports.BaseUIComponent=za;exports.BasicIKConstraint=Wk;exports.BehaviorExtension=xI;exports.BehaviorModel=rs;exports.Behaviour=Te;exports.Bloom=Op;exports.BoxCollider=NA;exports.BoxGizmo=Fp;exports.BoxHelperComponent=Da;exports.Button=Hh;exports.ButtonsFactory=vc;exports.CallDirection=U6;exports.CallInfo=dA;exports.Camera=Vi;exports.CameraTargetReachedEvent=qv;exports.Canvas=ar;exports.CanvasGroup=pd;exports.CapsuleCollider=Nh;exports.ChangeMaterialOnClick=GA;exports.ChangeTransformOnClick=Np;exports.CharacterController=zp;exports.CharacterControllerInput=jh;exports.ChromaticAberration=e_;exports.CircularBuffer=Ua;exports.ClearFlags=vp;exports.ClipExtrapolation=Xc;exports.Collider=ra;exports.Collision=hW;exports.CollisionDetectionMode=uI;exports.ColorAdjustments=xl;exports.ColorBySpeedModule=Gp;exports.ColorOverLifetimeModule=s_;exports.Component=Te;exports.ComponentEvents=Mb;exports.ComponentLifecycleEvents=Tb;exports.ConnectionEvents=L9;exports.ContactPoint=lW;exports.ContactShadows=Pl;exports.Context=Dt;exports.ContextArgs=ife;exports.ContextEvent=Ti;exports.ContextRegistry=ui;exports.ControlTrackHandler=mI;exports.CustomBranding=Pd;exports.CustomShader=Qo;exports.DefaultReflectionMode=SS;exports.Deletable=dO;exports.DeleteBox=PI;exports.DepthOfField=Pc;exports.DeviceFlag=DI;exports.DocumentExtension=fO;exports.DragControls=Ha;exports.DragMode=lj;exports.DropListener=Dd;exports.Duplicatable=Wp;exports.EmissionModule=Rl;exports.EmphasizeOnClick=HA;exports.EngineLoadingView=U0;exports.EventList=Xn;exports.EventListEvent=hI;exports.EventSystem=yo;exports.EventTrigger=OI;exports.FieldWithDefault=cO;exports.FileReference=Gm;exports.FileReferenceSerializer=U5;exports.FileSpawnModel=uj;exports.File_Event=hj;exports.FixedJoint=yO;exports.FlyControls=vO;exports.Fog=KA;exports.FrameEvent=Zi;exports.GENERATOR=NE;exports.GameObject=re;exports.Gizmos=vt;exports.GltfExport=h_;exports.GltfExportBox=_O;exports.GltfLoadEvent=$f;exports.GltfLoadEventType=Gj;exports.Gradient=Td;exports.Graphic=Up;exports.GraphicRaycaster=dI;exports.Graphics=dc;exports.GridHelper=ZA;exports.GridLayoutGroup=eO;exports.GroundProjectedEnv=qp;exports.GroupActionModel=ju;exports.HideFlags=l6;exports.HideOnStart=iO;exports.HingeJoint=l_;exports.HorizontalLayoutGroup=$k;exports.HostData=nfe;exports.Image=zA;exports.ImageReference=zm;exports.ImageReferenceSerializer=F5;exports.InheritVelocityModule=Rd;exports.Input=G5;exports.InputEventQueue=Kc;exports.InputEvents=fn;exports.InputField=Xp;exports.InstanceHandle=Jf;exports.InstancingHandler=Yf;exports.InstancingUtil=La;exports.InstantiateEvent=e6;exports.InstantiateIdProvider=Ls;exports.InstantiateOptions=Rc;exports.Interactable=uO;exports.JoinedRoomResponse=Ede;exports.KeyEventArgs=Oue;exports.Keyframe=Wa;exports.LODGroup=d_;exports.LODModel=Yp;exports.LeftRoomResponse=Ide;exports.Light=Bo;exports.LightData=Y9;exports.LimitVelocityOverLifetimeModule=us;exports.LoadingElementOptions=yne;exports.LogStats=wO;exports.LogType=Xo;exports.LookAt=Jp;exports.LookAtConstraint=Rp;exports.MainModule=dr;exports.MarkerType=Fk;exports.MaskableGraphic=Jb;exports.Mathf=tt;exports.MeshCollider=Lp;exports.MeshRenderer=n_;exports.MinMaxCurve=yt;exports.MinMaxGradient=Mo;exports.NEEDLE_progressive=mi;exports.NEKeyboardEvent=g0;exports.NEPointerEvent=ch;exports.NeedleEngine=ui;exports.NeedleEngineHTMLElement=QO;exports.NeedleGltfLoader=FO;exports.NeedleMenu=Dl;exports.NeedlePatchesKey=mC;exports.NeedleUSDZExporter=WV;exports.NeedleXRController=vk;exports.NeedleXRSession=St;exports.NeedleXRSync=N9;exports.NeedleXRUtils=z9;exports.NestedGltf=QI;exports.NetworkConnection=U9;exports.NetworkedStreamEvents=hl;exports.NetworkedStreams=qb;exports.Networking=$A;exports.NewInstanceModel=s6;exports.NoiseModule=Di;exports.ObjectRaycaster=ia;exports.ObjectUtils=Db;exports.OffsetConstraint=Kp;exports.OneEuroFilter=lC;exports.OneEuroFilterXYZ=C2;exports.OpenURL=ey;exports.OrbitControls=xi;exports.Outline=QA;exports.OwnershipEvent=F9;exports.OwnershipModel=Mk;exports.Padding=Id;exports.ParticleBurst=Zv;exports.ParticleSubEmitter=XI;exports.ParticleSystem=as;exports.ParticleSystemBaseBehaviour=kd;exports.ParticleSystemRenderer=Ja;exports.ParticleSystemShapeType=RS;exports.PeerHandle=Vm;exports.PeerNetworking=O9;exports.Physics=j9;exports.PhysicsExtension=TI;exports.PhysicsMaterialCombine=Ms;exports.PixelationEffect=g_;exports.PlayAnimationOnClick=bp;exports.PlayAudioOnClick=gd;exports.PlayableDirector=fd;exports.PlayerColor=fA;exports.PlayerState=Oa;exports.PlayerStateEvent=k6;exports.PlayerSync=OA;exports.PlayerView=W9;exports.PlayerViewManager=q9;exports.PointerEventData=PA;exports.PointerType=tI;exports.PostProcessingEffect=kr;exports.PostProcessingHandler=SI;exports.PreliminaryAction=VA;exports.PreliminaryTrigger=Zb;exports.PrimitiveType=mp;exports.Progress=ri;exports.PromiseAllWithErrors=kE;exports.PromiseErrorResult=aR;exports.RGBAColor=Ei;exports.RapierPhysics=yf;exports.RawImage=CI;exports.RaycastOptions=Ic;exports.Rect=Jk;exports.RectTransform=Dr;exports.ReflectionProbe=WA;exports.RegisteredAnimationInfo=yI;exports.RemoteSkybox=Cl;exports.RenderTexture=id;exports.RenderTextureSerializer=C6;exports.Renderer=Nn;exports.RendererData=X9;exports.RendererLightmap=Jv;exports.Rigidbody=Qi;exports.RigidbodyConstraints=zn;exports.RoomEvents=Jt;exports.RotationBySpeedModule=ca;exports.RotationOverLifetimeModule=Xa;exports.SceneLightSettings=TS;exports.SceneSwitcher=Ur;exports.ScreenCapture=Od;exports.ScreenSpaceAmbientOcclusion=Yh;exports.ScreenSpaceAmbientOcclusionN8=Dc;exports.SendQueue=Ia;exports.SerializationContext=pk;exports.SetActiveOnClick=Qp;exports.ShadowCatcher=v_;exports.ShapeModule=In;exports.SignalAsset=Gb;exports.SignalReceiver=kA;exports.SignalReceiverEvent=DA;exports.SignalTrackHandler=Xv;exports.Size=Yk;exports.SizeBySpeedModule=co;exports.SizeOverLifetimeModule=Bd;exports.SkinnedMeshRenderer=lO;exports.SmoothFollow=Ld;exports.SpatialGrabRaycaster=Wv;exports.SpatialHtml=b_;exports.SpatialTrigger=x_;exports.SpatialTriggerReceiver=yl;exports.SpectatorCamera=JI;exports.SphereCollider=UA;exports.SphereIntersection=V9;exports.SphereOverlapResult=uW;exports.Sprite=qh;exports.SpriteData=XA;exports.SpriteRenderer=Ya;exports.SpriteSheet=r_;exports.StateMachineBehaviour=fpe;exports.StreamEndedEvent=L6;exports.StreamReceivedEvent=F6;exports.SubEmitterSystem=nb;exports.SyncedCamera=KI;exports.SyncedRoom=Ol;exports.SyncedTransform=dd;exports.TapGestureTrigger=nO;exports.TeleportTarget=MI;exports.TestRunner=DO;exports.TestSceneUtils=D_e;exports.TestSimulateUserData=kO;exports.Text=Lr;exports.TextBuilder=BI;exports.TextExtension=o_;exports.TextureSheetAnimationModule=fr;exports.TiltShiftEffect=Ll;exports.Time=J9;exports.ToneMapping=jA;exports.TrackHandler=Hb;exports.TrackType=No;exports.TrailModule=yn;exports.TransformData=is;exports.TransformGizmo=eg;exports.TriggerBuilder=ks;exports.TriggerModel=Dh;exports.TypeStore=K;exports.UIRaycastUtils=fI;exports.UIRootComponent=Qb;exports.USDObject=nr;exports.USDWriter=jV;exports.USDZExporter=Yn;exports.USDZText=Xu;exports.USDZUIExtension=RI;exports.Upload_Result=nP;exports.UriSerializer=S6;exports.UsageMarker=a_;exports.UserJoinedOrLeftRoomModel=Mde;exports.VERSION=ka;exports.VariantAction=tk;exports.VelocityOverLifetimeModule=Mn;exports.VerticalLayoutGroup=Zk;exports.VideoPlayer=_s;exports.ViewDevice=td;exports.Vignette=tg;exports.VisibilityAction=$b;exports.Voip=Dp;exports.Volume=i_;exports.VolumeParameter=Lt;exports.VolumeProfile=jb;exports.WaitForFrames=Ode;exports.WaitForPromise=H9;exports.WaitForSeconds=G9;exports.Watch=Bh;exports.WebARCameraBackground=$I;exports.WebARSessionRoot=ao;exports.WebXR=Us;exports.WebXRButtonFactory=sd;exports.WebXRImageTracking=pA;exports.WebXRImageTrackingModel=Fl;exports.WebXRPlaneTracking=Fd;exports.WebXRTrackedImage=Yu;exports.XRControllerFollow=C_;exports.XRControllerModel=wl;exports.XRControllerMovement=Ga;exports.XRFlag=jo;exports.XRRig=e1;exports.XRState=tr;exports.XRStateFlag=nl;exports.__Ignore=LO;exports.__internalNotifyObjectDestroyed=r5;exports.activeInHierarchyFieldName=Rh;exports.addAttributeChangeCallback=mH;exports.addComponent=ml;exports.addCustomExtensionPlugin=Sme;exports.addFile=dj;exports.addFileFromUrl=fj;exports.addGltfLoadEventListener=s_e;exports.addNewComponent=Wf;exports.addPatch=YE;exports.apply=cI;exports.applyHMRChanges=m_e;exports.beginListenDestroy=n6;exports.beginListenFileSpawn=pj;exports.beginListenInstantiate=r6;exports.binaryIdentifierCasts=_k;exports.build_scene_functions=tfe;exports.builtinComponentKeyName=_f;exports.calculateProgress01=O2;exports.clearBalloonMessages=CH;exports.clearOverlayMessages=CH;exports.colorSerializer=Cfe;exports.componentSerializer=MC;exports.copyTexture=v8;exports.createLoader=UO;exports.createMotion=P6;exports.debugNet=Jr;exports.debugOwner=v0;exports.deepClone=vb;exports.delay=_l;exports.delayForFrames=fH;exports.deserializeObject=AS;exports.destroy=Qa;exports.destroyComponentInstance=y6;exports.disposeObjectResources=Wi;exports.disposeStream=Ih;exports.download=O5;exports.download_file=mk;exports.editorGuidKeyName=F0;exports.effectsOrder=BP;exports.enableSpatialConsole=sA;exports.eventListSerializer=Tfe;exports.exportAsGLTF=N_e;exports.findByGuid=Ob;exports.findObjectOfType=kk;exports.findObjectsOfType=b6;exports.findResourceUsers=ok;exports.fitObjectIntoVolume=b8;exports.foreachComponent=yp;exports.foreachComponentEnumerator=Pk;exports.forward=Lie;exports.generateQRCode=yH;exports.generateSeed=oI;exports.getBoundingBox=ld;exports.getCameraController=m8;exports.getComponent=Mp;exports.getComponentInChildren=Ub;exports.getComponentInParent=Vv;exports.getComponents=Fb;exports.getComponentsInChildren=RA;exports.getComponentsInParent=lI;exports.getFormattedDate=zV;exports.getIconElement=Ao;exports.getIconTexture=AP;exports.getIp=zZ;exports.getIpAndLocation=GZ;exports.getIpCloudflare=QZ;exports.getLoader=wc;exports.getOrAddComponent=Lb;exports.getParam=ie;exports.getParentHierarchyPath=Nie;exports.getPath=LZ;exports.getPeerOptions=xde;exports.getPeerjsInstance=k9;exports.getResourceUserCount=Qce;exports.getTempQuaternion=Rf;exports.getTempVector=kn;exports.getUrlParams=yb;exports.getWorldDirection=I2;exports.getWorldEuler=M2;exports.getWorldPosition=Ot;exports.getWorldQuaternion=Fi;exports.getWorldRotation=wb;exports.getWorldScale=Ji;exports.hasCommercialLicense=Ph;exports.hasIndieLicense=k2;exports.hasPointerEventComponent=SP;exports.hasProLicense=Zu;exports.hash=gk;exports.hideDebugConsole=S8;exports.imageToCanvas=YV;exports.instantiate=BA;exports.invokeAfterImportPluginHooks=aO;exports.invokeXRSessionEnd=Q5;exports.invokeXRSessionStart=N5;exports.isActiveInHierarchy=h6;exports.isActiveSelf=TA;exports.isAndroidDevice=gH;exports.isAnimationAction=y8;exports.isDebugMode=PZ;exports.isDesktop=lp;exports.isDestroyed=Ap;exports.isDevEnvironment=ht;exports.isDisposed=Uce;exports.isExporting=O_e;exports.isHostedOnGlitch=lH;exports.isHotReloading=d_e;exports.isIconElement=K9;exports.isLocalNetwork=ro;exports.isMobileDevice=na;exports.isMozillaXR=Nf;exports.isQuest=DE;exports.isResourceTrackingEnabled=i5;exports.isSafari=Om;exports.isUsingInstancing=aI;exports.isiOS=hp;exports.loadSync=NO;exports.logHierarchy=cS;exports.lookAtInverse=Bie;exports.lookAtObject=xb;exports.makeId=kZ;exports.makeIdFromRandomWords=KD;exports.makeNameSafeForUSD=Ec;exports.markAsInstancedRendered=u6;exports.microphonePermissionsGranted=oR;exports.nameof=RZ;exports.nameofFactory=hH;exports.objectSerializer=w6;exports.offXRSessionEnd=Sue;exports.offXRSessionStart=Cue;exports.onAfterRender=Ffe;exports.onBeforeRender=Lfe;exports.onClear=kfe;exports.onDestroy=Ofe;exports.onInitialized=Dfe;exports.onStart=I6;exports.onUpdate=M6;exports.onXRSessionEnd=Ak;exports.onXRSessionStart=eI;exports.parseSync=Vj;exports.placeOnSurface=_8;exports.postprocessFBXMaterials=x8;exports.prefix=Nfe;exports.pushState=uH;exports.randomNumber=OZ;exports.registerBinaryType=xk;exports.registerComponent=sI;exports.registerComponentExtension=sO;exports.registerCustomEffectType=qa;exports.registerExportExtensions=oO;exports.registerExtensions=rO;exports.registerHotReloadType=f_e;exports.registerLoader=YD;exports.registerPrefabProvider=a6;exports.registerType=uce;exports.relativePathPrefix=pH;exports.removeAttributeChangeCallback=AH;exports.removeComponent=Dk;exports.removeCustomImportExtensionType=Eme;exports.removeGltfLoadEventListener=r_e;exports.removePatch=kce;exports.resolveUrl=vd;exports.sanitizeString=dH;exports.saveImage=fW;exports.screenshot=k_e;exports.screenshot2=dW;exports.sendDestroyed=i6;exports.serializable=x;exports.serializeObject=T5;exports.serializeable=SA;exports.setActive=Z0;exports.setAllowBalloonMessages=xH;exports.setAllowOverlayMessages=WZ;exports.setAutoFitEnabled=gR;exports.setCameraController=fR;exports.setDestroyed=f6;exports.setDevEnvironment=qie;exports.setDisposable=rk;exports.setDontDestroy=bP;exports.setOrAddParamsToUrl=rR;exports.setParam=DZ;exports.setParamWithoutReload=tS;exports.setPeerOptions=wde;exports.setResourceTrackingEnabled=Fce;exports.setState=JD;exports.setWorldEuler=T2;exports.setWorldPosition=Os;exports.setWorldPositionXYZ=dp;exports.setWorldQuaternion=Na;exports.setWorldQuaternionXYZW=E2;exports.setWorldRotation=B2;exports.setWorldRotationXYZ=Cb;exports.setWorldScale=nA;exports.showBalloonError=R2;exports.showBalloonMessage=pn;exports.showBalloonWarning=Ni;exports.showDebugConsole=P2;exports.slerp=Mie;exports.syncDestroy=rI;exports.syncField=Qk;exports.syncInstantiate=Rk;exports.textureToCanvas=Qie;exports.tryCastBinary=H5;exports.tryDetermineFileTypeFromBinary=Nj;exports.tryDetermineFileTypeFromURL=Uj;exports.tryFindObject=eA;exports.tryGetGuid=V5;exports.unregisterHotReloadType=p_e;exports.unwatchWrite=ZD;exports.upload_file=k5;exports.useForAutoFit=A8;exports.validate=ur;exports.watchWrite=PE;