@needle-tools/engine 3.16.2 → 3.16.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/needle-engine.js +40 -21
- package/dist/needle-engine.light.js +40 -21
- package/dist/needle-engine.light.min.js +22 -4
- package/dist/needle-engine.light.umd.cjs +22 -4
- package/dist/needle-engine.min.js +22 -4
- package/dist/needle-engine.umd.cjs +22 -4
- package/lib/engine/engine_license.js +27 -6
- package/lib/engine/engine_license.js.map +1 -1
- package/lib/engine/engine_loaders.js +5 -2
- package/lib/engine/engine_loaders.js.map +1 -1
- package/lib/engine-components/CameraUtils.js +7 -3
- package/lib/engine-components/CameraUtils.js.map +1 -1
- package/lib/engine-components/ui/RectTransform.d.ts +0 -1
- package/lib/engine-components/ui/RectTransform.js +2 -5
- package/lib/engine-components/ui/RectTransform.js.map +1 -1
- package/package.json +1 -1
- package/src/engine/engine_license.ts +28 -6
- package/src/engine/engine_loaders.ts +8 -4
- package/src/engine-components/CameraUtils.ts +8 -4
- package/src/engine-components/ui/RectTransform.ts +4 -8
|
@@ -4305,7 +4305,7 @@ irradiance += getLightProbeIrradiance( lightProbe, geometry.normal );
|
|
|
4305
4305
|
font-family: sans-serif;
|
|
4306
4306
|
text-align: center;
|
|
4307
4307
|
user-select: none;
|
|
4308
|
-
`;const o=(_g==null?void 0:_g.length)>1?_g:"Needle Engine<br/>This application is not allowed to run on this domain!";return r.innerHTML=o,s}let t=e();const i=t.style.cssText;setInterval(()=>{var s;RE===!0&&(t.style.cssText!==i&&(t=e()),"isPaused"in n&&(n.isPaused=!0),t.parentNode!==n.domElement.shadowRoot&&((s=n.domElement.shadowRoot)==null||s.appendChild(t)))},500)}async function rY(n){try{if(Of()!==!0)return Kw(n)}catch(e){return Yo&&console.log("License check failed",e),Kw(n)}Yo&&Kw(n)}const cN="needle-license-element",PE=1e4,BE=
|
|
4308
|
+
`;const o=(_g==null?void 0:_g.length)>1?_g:"Needle Engine<br/>This application is not allowed to run on this domain!";return r.innerHTML=o,s}let t=e();const i=t.style.cssText;setInterval(()=>{var s;RE===!0&&(t.style.cssText!==i&&(t=e()),"isPaused"in n&&(n.isPaused=!0),t.parentNode!==n.domElement.shadowRoot&&((s=n.domElement.shadowRoot)==null||s.appendChild(t)))},500)}async function rY(n){try{if(Of()!==!0)return Kw(n)}catch(e){return Yo&&console.log("License check failed",e),Kw(n)}Yo&&Kw(n)}const cN="needle-license-element",PE=1e4,BE=1200;async function Kw(n){await(Xl==null?void 0:Xl.catch(()=>{})),!Of()&&(oY(),n.domElement.addEventListener("ready",()=>{lN(n)}))}function lN(n){const e=aY(),t=cY(),i=()=>{if(!e)return;const c=n.domElement.shadowRoot||n.domElement;e.parentNode!==c&&(c.appendChild(e),t&&c.appendChild(t))};i();const s=setInterval(()=>{i()},1e3),r=`<img class="logo" src="${aN}" style="width: 40px; height: 40px; margin-right: 2px; vertical-align: middle; margin-bottom: 2px;"/>`,o=document.createElement("div");o.innerHTML=r,o.classList.add("logo"),e.appendChild(o);const a=document.createElement("div");if(a.classList.add("text"),e.appendChild(a),e.title="Needle Engine",Of()||(e.title+=" No active license found - Non Commercial Use"),e.addEventListener("click",()=>{globalThis.open("https://needle.tools","_blank")}),tT()){const c=PE+BE;setTimeout(()=>{clearInterval(s),e==null||e.remove(),t==null||t.remove();const l=5;setTimeout(()=>{n.domElement.parentNode&&lN(n)},1e3*60*l)},c)}}let ZB=0;async function oY(n){const e=Date.now();if(e-ZB<2e3)return;ZB=e;const i=`
|
|
4309
4309
|
position: relative;
|
|
4310
4310
|
display: block;
|
|
4311
4311
|
font-size: 18px;
|
|
@@ -4423,9 +4423,27 @@ irradiance += getLightProbeIrradiance( lightProbe, geometry.normal );
|
|
|
4423
4423
|
transform: scale(1.02) !important;
|
|
4424
4424
|
cursor: pointer !important;
|
|
4425
4425
|
}
|
|
4426
|
+
|
|
4427
|
+
@media (prefers-reduced-motion: reduce) {
|
|
4428
|
+
${e} .text {
|
|
4429
|
+
animation: none !important;
|
|
4430
|
+
transition: none !important;
|
|
4431
|
+
/* animation end state */
|
|
4432
|
+
opacity: 1;
|
|
4433
|
+
}
|
|
4434
|
+
|
|
4435
|
+
${e} .logo {
|
|
4436
|
+
animation: none !important;
|
|
4437
|
+
transition: none !important;
|
|
4438
|
+
/* animation end state */
|
|
4439
|
+
opacity: 1;
|
|
4440
|
+
pointer-events: all;
|
|
4441
|
+
transform: scale(1)
|
|
4442
|
+
}
|
|
4443
|
+
}
|
|
4426
4444
|
`,n}async function lY(){try{const n="https://needle-engine-analytics-v2-r26roub2hq-lz.a.run.app";if(n){Yo&&console.log("Analytics backend url",n);const e=window.location.href;let t="api/v2/new/request";n.endsWith("/")||(t="/"+t);const s=`${n}${t}?license=${Au}&url=${encodeURIComponent(e)}&hostname=${encodeURIComponent(window.location.hostname)}&pathname=${encodeURIComponent(window.location.pathname)}&search=${encodeURIComponent(window.location.search)}&hash=${encodeURIComponent(window.location.hash)}&version=${kc}&generator=${E_}`;Yo&&console.log("Sending non-commercial usage message to analytics backend",s),fetch(s,{mode:"no-cors"}).catch(r=>{Yo&&console.log("Failed to send non-commercial usage message to analytics backend",r)})}}catch(n){Yo&&console.log("Failed to send non-commercial usage message to analytics backend",n)}}const tu=re("debugloading"),jp=re("debugloadingrendering"),$B=re("debuglicense");class hY{constructor(){u(this,"className");u(this,"additionalClasses")}}let Xp=0,eD;function iT(n){tu&&console.log(n.progress.loaded.toFixed(0)+"/"+n.progress.total.toFixed(0),n);const e=n.count,t=n.progress.total;t===0||t===void 0?(eD!==n.name&&(Xp=0),eD=n.name,Xp+=(1-Xp)*.001,tu&&nr("Loading "+n.name+" did not report total size")):Xp=n.progress.loaded/t;const i=n.index/e+Xp/e;return tt.clamp01(i)}const Mb=class{constructor(e,t){u(this,"loadingProgress",0);u(this,"_element");u(this,"_progress",0);u(this,"_allowCustomLoadingElement",!0);u(this,"_loadingElement");u(this,"_loadingTextContainer",null);u(this,"_loadingBar",null);u(this,"_messageContainer",null);u(this,"_loadingElementOptions");u(this,"_progressLoop");this._element=e,this._loadingElementOptions=t}async onLoadingBegin(e){const t=this._element.shadowRoot||this._element;if(tu&&console.warn("Begin Loading"),!this._loadingElement){for(let i=0;i<t.children.length;i++){const s=t.children[i];if(s.classList.contains(Mb.LoadingContainerClassName)){if(!this._allowCustomLoadingElement){tu&&console.warn("Remove custom loading container"),t.removeChild(s);continue}this._loadingElement=this.createLoadingElement(s)}}this._loadingElement||(this._loadingElement=this.createLoadingElement())}this._progress=0,this.loadingProgress=0,this._loadingElement.style.display="flex",t.appendChild(this._loadingElement),this.smoothProgressLoop(),this.setMessage(e??"")}onLoadingUpdate(e,t){var s;if(!((s=this._loadingElement)!=null&&s.parentNode))return;let i=0;typeof e=="number"?i=e:("index"in e&&(i=iT(e)),!t&&"name"in e&&this.setMessage("loading "+e.name)),this.loadingProgress=i,t&&this.setMessage(t),this.updateDisplay()}onLoadingFinished(){tu&&console.warn("Finished Loading"),jp||(this.loadingProgress=1,this.onDoneLoading())}setMessage(e){this._messageContainer&&(this._messageContainer.innerText=e)}smoothProgressLoop(){if(this._progressLoop)return;let e=1/12;jp&&(e=1/500,typeof jp=="number"&&(e*=jp)),this._progressLoop=setInterval(()=>{this.loadingProgress>=.95&&!jp&&(e=.9),this._progress=tt.lerp(this._progress,this.loadingProgress,e*this.loadingProgress),this.updateDisplay()},e)}onDoneLoading(){this._loadingElement&&(tu&&console.log("Hiding loading element"),this._loadingElement.style.display="none",this._loadingElement.remove()),this._progressLoop&&clearInterval(this._progressLoop),this._progressLoop=null}updateDisplay(){const e=this._progress,t=(e*100).toFixed(0)+"%";this._loadingBar&&(this._loadingBar.style.width=e*100+"%"),this._loadingTextContainer&&(this._loadingTextContainer.textContent=t)}createLoadingElement(e){var d,f;tu&&!e&&console.log("Creating loading element"),this._loadingElement=e||document.createElement("div");let t=this._element.getAttribute("loading-style");t==="auto"&&(window.matchMedia("(prefers-color-scheme: dark)").matches?t="dark":t="light");const i=pf();if(!e&&(this._loadingElement.style.position="absolute",this._loadingElement.style.width="100%",this._loadingElement.style.height="100%",this._loadingElement.style.left="0",this._loadingElement.style.top="0",t==="light"?this._loadingElement.style.backgroundColor="#ddd":this._loadingElement.style.backgroundColor="#222",this._loadingElement.style.display="flex",this._loadingElement.style.alignItems="center",this._loadingElement.style.justifyContent="center",this._loadingElement.style.zIndex=Number.MAX_SAFE_INTEGER.toString(),this._loadingElement.style.flexDirection="column",this._loadingElement.style.pointerEvents="none",this._loadingElement.style.color="white",t==="light"?this._loadingElement.style.color="rgba(0,0,0,.8)":this._loadingElement.style.color="rgba(255,255,255,.5)",i&&this._element)){const p=this._element.getAttribute("loading-background-color");p&&(this._loadingElement.style.backgroundColor=p);const g=this._element.getAttribute("loading-text-color");g&&(this._loadingElement.style.color=g)}const s=((d=this._loadingElementOptions)==null?void 0:d.className)??Mb.LoadingContainerClassName;if(this._loadingElement.classList.add(s),(f=this._loadingElementOptions)!=null&&f.additionalClasses)for(const p of this._loadingElementOptions.additionalClasses)this._loadingElement.classList.add(p);const r=document.createElement("div"),o=30;r.style.display="flex",r.style.width=o+"%",r.style.height="2px",t==="light"?r.style.backgroundColor="rgba(0,0,0,.2)":r.style.backgroundColor="rgba(255,255,255,.2)";const a=document.createElement("img"),c=64;if(a.style.width=`${c}px`,a.style.height=`${c}px`,a.style.marginBottom="20px",a.addEventListener("click",()=>window.open("https://needle.tools","_blank")),a.style.cursor="pointer",a.style.userSelect="none",a.style.pointerEvents="all",a.style.objectFit="contain",a.src=aN,i&&this._element){const p=this._element.getAttribute("loading-logo-src");p&&(a.src=p)}this._loadingElement.appendChild(a),this._loadingElement.appendChild(r),this._loadingBar=document.createElement("div"),r.appendChild(this._loadingBar);const l=function(p){return tt.lerp(o*.5,100-o*.5,p)+"%"};if(this._loadingBar.style.background=`linear-gradient(90deg, #02022B ${l(0)}, #0BA398 ${l(.4)}, #99CC33 ${l(.5)}, #D7DB0A ${l(1)})`,this._loadingBar.style.backgroundAttachment="fixed",this._loadingBar.style.width="0%",this._loadingBar.style.height="100%",i&&this._element){const p=this._element.getAttribute("primary-color"),g=this._element.getAttribute("secondary-color");p&&g?this._loadingBar.style.background=`linear-gradient(90deg, ${p} ${l(0)}, ${g} ${l(1)})`:p?this._loadingBar.style.background=p:g&&(this._loadingBar.style.background=g)}this._loadingTextContainer=document.createElement("div"),this._loadingTextContainer.style.display="flex",this._loadingTextContainer.style.justifyContent="center",this._loadingTextContainer.style.marginTop="1.2em",this._loadingElement.appendChild(this._loadingTextContainer);const h=document.createElement("div");if(this._messageContainer=h,h.style.display="flex",h.style.fontSize=".8em",h.style.paddingTop=".5em",h.style.fontWeight="200",h.style.fontFamily="Roboto, sans-serif, Arial",h.style.justifyContent="center",this._loadingElement.appendChild(h),i&&this._element){const p=this._element.getAttribute("loading-text-color");p&&(h.style.color=p)}return this.handleRuntimeLicense(this._loadingElement),this._loadingElement}async handleRuntimeLicense(e){let t=Of();if(t||(Xl&&($B&&console.log("Waiting for runtime license check"),await Xl,t=Of()),t))return;$B&&console.log("Loading UI has commercial license?",t);const i=document.createElement("div");i.style.paddingTop=".6em",i.style.fontSize=".8em",i.innerText="NON COMMERCIAL",e.appendChild(i)}};let Yg=Mb;u(Yg,"LoadingContainerClassName","loading");const Jw=new WeakMap;class nT extends fs{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,s){const r=new Ln(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,s)},i,s)}parse(e,t,i){this.decodeDracoFile(e,t,null,null,Ze).catch(i)}decodeDracoFile(e,t,i,s,r=pn){const o={attributeIDs:i||this.defaultAttributeIDs,attributeTypes:s||this.defaultAttributeTypes,useUniqueIDs:!!i,vertexColorSpace:r};return this.decodeGeometry(e,o).then(t)}decodeGeometry(e,t){const i=JSON.stringify(t);if(Jw.has(e)){const c=Jw.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 s;const r=this.workerNextTaskID++,o=e.byteLength,a=this._getWorker(r,o).then(c=>(s=c,new Promise((l,h)=>{s._callbacks[r]={resolve:l,reject:h},s.postMessage({type:"decode",id:r,taskConfig:t,buffer:e},[e])}))).then(c=>this._createGeometry(c.geometry));return a.catch(()=>!0).then(()=>{s&&r&&this._releaseTask(s,r)}),Jw.set(e,{key:i,promise:a}),a}_createGeometry(e){const t=new vt;e.index&&t.setIndex(new rt(e.index.array,1));for(let i=0;i<e.attributes.length;i++){const s=e.attributes[i],r=s.name,o=s.array,a=s.itemSize,c=new rt(o,a);r==="color"&&(this._assignVertexColorSpace(c,s.vertexColorSpace),c.normalized=!(o instanceof Float32Array)),t.setAttribute(r,c)}return t}_assignVertexColorSpace(e,t){if(t!==Ze)return;const i=new _e;for(let s=0,r=e.count;s<r;s++)i.fromBufferAttribute(e,s).convertSRGBToLinear(),e.setXYZ(s,i.r,i.g,i.b)}_loadLibrary(e,t){const i=new Ln(this.manager);return i.setPath(this.decoderPath),i.setResponseType(t),i.setWithCredentials(this.withCredentials),new Promise((s,r)=>{i.load(e,s,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 s=i[0];e||(this.decoderConfig.wasmBinary=i[1]);const r=uY.toString(),o=["/* draco decoder */",s,"","/* worker */",r.substring(r.indexOf("{")+1,r.lastIndexOf("}"))].join(`
|
|
4427
4445
|
`);this.workerSourceURL=URL.createObjectURL(new Blob([o]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const s=new Worker(this.workerSourceURL);s._callbacks={},s._taskCosts={},s._taskLoad=0,s.postMessage({type:"init",decoderConfig:this.decoderConfig}),s.onmessage=function(r){const o=r.data;switch(o.type){case"decode":s._callbacks[o.id].resolve(o);break;case"error":s._callbacks[o.id].reject(o);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+o.type+'"')}},this.workerPool.push(s)}else this.workerPool.sort(function(s,r){return s._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 uY(){let n,e;onmessage=function(o){const a=o.data;switch(a.type){case"init":n=a.decoderConfig,e=new Promise(function(h){n.onModuleLoaded=function(d){h({draco:d})},DracoDecoderModule(n)});break;case"decode":const c=a.buffer,l=a.taskConfig;e.then(h=>{const d=h.draco,f=new d.Decoder;try{const p=t(d,f,new Int8Array(c),l),g=p.attributes.map(A=>A.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{d.destroy(f)}});break}};function t(o,a,c,l){const h=l.attributeIDs,d=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 A={index:null,attributes:[]};for(const v in h){const m=self[d[v]];let b,y;if(l.useUniqueIDs)y=h[v],b=a.GetAttributeByUniqueId(f,y);else{if(y=a.GetAttributeId(f,o[h[v]]),y===-1)continue;b=a.GetAttribute(f,y)}const _=s(o,a,f,v,m,b);v==="color"&&(_.vertexColorSpace=l.vertexColorSpace),A.attributes.push(_)}return g===o.TRIANGULAR_MESH&&(A.index=i(o,a,f)),o.destroy(f),A}function i(o,a,c){const h=c.num_faces()*3,d=h*4,f=o._malloc(d);a.GetTrianglesUInt32Array(c,d,f);const p=new Uint32Array(o.HEAPF32.buffer,f,h).slice();return o._free(f),{array:p,itemSize:1}}function s(o,a,c,l,h,d){const f=d.num_components(),g=c.num_points()*f,A=g*h.BYTES_PER_ELEMENT,v=r(o,h),m=o._malloc(A);a.GetAttributeDataArrayForAllPoints(c,d,v,A,m);const b=new h(o.HEAPF32.buffer,m,g).slice();return o._free(m),{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}}}class dY{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:s,msg:r,transfer:o}=this.queue.shift();this.workersResolve[e]=s,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 s=this._getIdleWorker();s!==-1?(this._initWorker(s),this.workerStatus|=1<<s,this.workersResolve[s]=i,this.workers[s].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 fY=0,pY=2,gY=1,mY=2,AY=0,hN=9,sT=15,uN=16,rT=22,dN=37,oT=43,fN=76,pN=83,gN=97,mN=100,AN=103,vN=109;class vY{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}}class qp{constructor(e,t,i,s){this._dataView=new DataView(e.buffer,e.byteOffset+t,i),this._littleEndian=s,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 s=0;for(;this._dataView.getUint8(this._offset)!==t&&s<e;)s++,this._offset++;return s<e&&this._offset++,new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+i,s)}}const Fs=[171,75,84,88,32,50,48,187,13,10,26,10];function tD(n){return typeof TextDecoder<"u"?new TextDecoder().decode(n):Buffer.from(n).toString("utf8")}function yY(n){const e=new Uint8Array(n.buffer,n.byteOffset,Fs.length);if(e[0]!==Fs[0]||e[1]!==Fs[1]||e[2]!==Fs[2]||e[3]!==Fs[3]||e[4]!==Fs[4]||e[5]!==Fs[5]||e[6]!==Fs[6]||e[7]!==Fs[7]||e[8]!==Fs[8]||e[9]!==Fs[9]||e[10]!==Fs[10]||e[11]!==Fs[11])throw new Error("Missing KTX 2.0 identifier.");const t=new vY,i=17*Uint32Array.BYTES_PER_ELEMENT,s=new qp(n,Fs.length,i,!0);t.vkFormat=s._nextUint32(),t.typeSize=s._nextUint32(),t.pixelWidth=s._nextUint32(),t.pixelHeight=s._nextUint32(),t.pixelDepth=s._nextUint32(),t.layerCount=s._nextUint32(),t.faceCount=s._nextUint32();const r=s._nextUint32();t.supercompressionScheme=s._nextUint32();const o=s._nextUint32(),a=s._nextUint32(),c=s._nextUint32(),l=s._nextUint32(),h=s._nextUint64(),d=s._nextUint64(),f=new qp(n,Fs.length+i,3*r*8,!0);for(let L=0;L<r;L++)t.levels.push({levelData:new Uint8Array(n.buffer,n.byteOffset+f._nextUint64(),f._nextUint64()),uncompressedByteLength:f._nextUint64()});const p=new qp(n,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:[]},A=(g.descriptorBlockSize/4-6)/4;for(let L=0;L<A;L++){const G={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&G.channelType?(G.sampleLower=p._nextInt32(),G.sampleUpper=p._nextInt32()):(G.sampleLower=p._nextUint32(),G.sampleUpper=p._nextUint32()),g.samples[L]=G}t.dataFormatDescriptor.length=0,t.dataFormatDescriptor.push(g);const v=new qp(n,c,l,!0);for(;v._offset<l;){const L=v._nextUint32(),G=v._scan(L),ee=tD(G),$=v._scan(L-G.byteLength);t.keyValue[ee]=ee.match(/^ktx/i)?tD($):$,v._offset%4&&v._skip(4-v._offset%4)}if(d<=0)return t;const m=new qp(n,h,d,!0),b=m._nextUint16(),y=m._nextUint16(),_=m._nextUint32(),C=m._nextUint32(),M=m._nextUint32(),I=m._nextUint32(),R=[];for(let L=0;L<r;L++)R.push({imageFlags:m._nextUint32(),rgbSliceByteOffset:m._nextUint32(),rgbSliceByteLength:m._nextUint32(),alphaSliceByteOffset:m._nextUint32(),alphaSliceByteLength:m._nextUint32()});const E=h+m._offset,T=E+_,O=T+C,K=O+M,H=new Uint8Array(n.buffer,n.byteOffset+E,_),V=new Uint8Array(n.buffer,n.byteOffset+T,C),Y=new Uint8Array(n.buffer,n.byteOffset+O,M),N=new Uint8Array(n.buffer,n.byteOffset+K,I);return t.globalData={endpointCount:b,selectorCount:y,imageDescs:R,endpointsData:H,selectorsData:V,tablesData:Y,extendedData:N},t}let Zw,fc,DE;const $w={env:{emscripten_notify_memory_growth:function(n){DE=new Uint8Array(fc.exports.memory.buffer)}}};class bY{init(){return Zw||(Zw=typeof fetch<"u"?fetch("data:application/wasm;base64,"+iD).then(e=>e.arrayBuffer()).then(e=>WebAssembly.instantiate(e,$w)).then(this._init):WebAssembly.instantiate(Buffer.from(iD,"base64"),$w).then(this._init),Zw)}_init(e){fc=e.instance,$w.env.emscripten_notify_memory_growth(0)}decode(e,t=0){if(!fc)throw new Error("ZSTDDecoder: Await .init() before decoding.");const i=e.byteLength,s=fc.exports.malloc(i);DE.set(e,s),t=t||Number(fc.exports.ZSTD_findDecompressedSize(s,i));const r=fc.exports.malloc(t),o=fc.exports.ZSTD_decompress(r,t,s,i),a=DE.slice(r,r+o);return fc.exports.free(s),fc.exports.free(r),a}}const iD="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",eS=new WeakMap;let tS=0,iS;class Ko extends fs{constructor(e){super(e),this.transcoderPath="",this.transcoderBinary=null,this.transcoderPending=null,this.workerPool=new dY,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}detectSupport(e){return e.isWebGPURenderer===!0?this.workerConfig={astcSupported:e.hasFeature("texture-compression-astc"),etc1Supported:!1,etc2Supported:e.hasFeature("texture-compression-etc2"),dxtSupported:e.hasFeature("texture-compression-bc"),bptcSupported:!1,pvrtcSupported:!1}:(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 Ln(this.manager);e.setPath(this.transcoderPath),e.setWithCredentials(this.withCredentials);const t=e.loadAsync("basis_transcoder.js"),i=new Ln(this.manager);i.setPath(this.transcoderPath),i.setResponseType("arraybuffer"),i.setWithCredentials(this.withCredentials);const s=i.loadAsync("basis_transcoder.wasm");this.transcoderPending=Promise.all([t,s]).then(([r,o])=>{const a=Ko.BasisWorker.toString(),c=["/* constants */","let _EngineFormat = "+JSON.stringify(Ko.EngineFormat),"let _TranscoderFormat = "+JSON.stringify(Ko.TranscoderFormat),"let _BasisFormat = "+JSON.stringify(Ko.BasisFormat),"/* basis_transcoder.js */",r,"/* worker */",a.substring(a.indexOf("{")+1,a.lastIndexOf("}"))].join(`
|
|
4428
|
-
`);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})}),tS>0&&console.warn("THREE.KTX2Loader: Multiple active KTX2 loaders may cause performance issues. Use a single KTX2Loader instance, or call .dispose() on old instances."),tS++}return this.transcoderPending}load(e,t,i,s){if(this.workerConfig===null)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");const r=new Ln(this.manager);r.setResponseType("arraybuffer"),r.setWithCredentials(this.withCredentials),r.load(e,o=>{if(eS.has(o))return eS.get(o).promise.then(t).catch(s);this._createTexture(o).then(a=>t?t(a):null).catch(s)},i,s)}_createTextureFrom(e,t){const{faces:i,width:s,height:r,format:o,type:a,error:c,dfdTransferFn:l,dfdFlags:h}=e;if(a==="error")return Promise.reject(c);let d;if(t.faceCount===6)d=new Gc,d.image=i,d.format=o,d.type=pi;else{const f=i[0].mipmaps;d=t.layerCount>1?new qL(f,s,r,t.layerCount,o,pi):new Gc(f,s,r,o,pi)}return d.minFilter=i[0].mipmaps.length===1?Ft:Mo,d.magFilter=Ft,d.generateMipmaps=!1,d.needsUpdate=!0,d.colorSpace=l===mY?Ze:mr,d.premultiplyAlpha=!!(h&gY),d}async _createTexture(e,t={}){const i=yY(new Uint8Array(e));if(i.vkFormat!==AY){const o=[],a=[];for(let l=0;l<i.levels.length;l++)a.push(xY(i,l).then(function(h){o[l]=h}));await Promise.all(a);const c=o[0];return c.mipmaps=o.map(l=>({data:l.source.data,width:l.source.data.width,height:l.source.data.height,depth:l.source.data.depth})),c}const s=t,r=this.init().then(()=>this.workerPool.postMessage({type:"transcode",buffer:e,taskConfig:s},[e])).then(o=>this._createTextureFrom(o.data,i));return eS.set(e,{promise:r}),r}dispose(){return this.workerPool.dispose(),this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),tS--,this}}Ko.BasisFormat={ETC1S:0,UASTC_4x4:1};Ko.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};Ko.EngineFormat={RGBAFormat:Ei,RGBA_ASTC_4x4_Format:H0,RGBA_BPTC_Format:Lg,RGBA_ETC2_EAC_Format:G0,RGBA_PVRTC_4BPPV1_Format:N0,RGBA_S3TC_DXT5_Format:kg,RGB_ETC1_Format:UM,RGB_ETC2_Format:z0,RGB_PVRTC_4BPPV1_Format:U0,RGB_S3TC_DXT1_Format:Og};Ko.BasisWorker=function(){let n,e,t;const i=_EngineFormat,s=_TranscoderFormat,r=_BasisFormat;self.addEventListener("message",function(g){const A=g.data;switch(A.type){case"init":n=A.config,o(A.transcoderBinary);break;case"transcode":e.then(()=>{try{const{faces:v,buffers:m,width:b,height:y,hasAlpha:_,format:C,dfdTransferFn:M,dfdFlags:I}=a(A.buffer);self.postMessage({type:"transcode",id:A.id,faces:v,width:b,height:y,hasAlpha:_,format:C,dfdTransferFn:M,dfdFlags:I},m)}catch(v){console.error(v),self.postMessage({type:"error",id:A.id,error:v.message})}});break}});function o(g){e=new Promise(A=>{t={wasmBinary:g,onRuntimeInitialized:A},BASIS(t)}).then(()=>{t.initializeBasis(),t.KTX2File===void 0&&console.warn("THREE.KTX2Loader: Please update Basis Universal transcoder.")})}function a(g){const A=new t.KTX2File(new Uint8Array(g));function v(){A.close(),A.delete()}if(!A.isValid())throw v(),new Error("THREE.KTX2Loader: Invalid or unsupported .ktx2 file");const m=A.isUASTC()?r.UASTC_4x4:r.ETC1S,b=A.getWidth(),y=A.getHeight(),_=A.getLayers()||1,C=A.getLevels(),M=A.getFaces(),I=A.getHasAlpha(),R=A.getDFDTransferFunc(),E=A.getDFDFlags(),{transcoderFormat:T,engineFormat:O}=d(m,b,y,I);if(!b||!y||!C)throw v(),new Error("THREE.KTX2Loader: Invalid texture");if(!A.startTranscoding())throw v(),new Error("THREE.KTX2Loader: .startTranscoding failed");const K=[],H=[];for(let V=0;V<M;V++){const Y=[];for(let N=0;N<C;N++){const L=[];let G,ee;for(let j=0;j<_;j++){const ie=A.getImageLevelInfo(N,j,V);V===0&&N===0&&j===0&&(ie.origWidth%4!==0||ie.origHeight%4!==0)&&console.warn("THREE.KTX2Loader: ETC1S and UASTC textures should use multiple-of-four dimensions."),C>1?(G=ie.origWidth,ee=ie.origHeight):(G=ie.width,ee=ie.height);const Ae=new Uint8Array(A.getImageTranscodedSizeInBytes(N,j,0,T));if(!A.transcodeImage(Ae,N,j,V,T,0,-1,-1))throw v(),new Error("THREE.KTX2Loader: .transcodeImage failed.");L.push(Ae)}const $=p(L);Y.push({data:$,width:G,height:ee}),H.push($.buffer)}K.push({mipmaps:Y,width:b,height:y,format:O})}return v(),{faces:K,buffers:H,width:b,height:y,hasAlpha:I,format:O,dfdTransferFn:R,dfdFlags:E}}const c=[{if:"astcSupported",basisFormat:[r.UASTC_4x4],transcoderFormat:[s.ASTC_4x4,s.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:[s.BC7_M5,s.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:[s.BC1,s.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:[s.ETC1,s.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:[s.ETC1],engineFormat:[i.RGB_ETC1_Format],priorityETC1S:2,priorityUASTC:4,needsPowerOfTwo:!1},{if:"pvrtcSupported",basisFormat:[r.ETC1S,r.UASTC_4x4],transcoderFormat:[s.PVRTC1_4_RGB,s.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,A){return g.priorityETC1S-A.priorityETC1S}),h=c.sort(function(g,A){return g.priorityUASTC-A.priorityUASTC});function d(g,A,v,m){let b,y;const _=g===r.ETC1S?l:h;for(let C=0;C<_.length;C++){const M=_[C];if(n[M.if]&&M.basisFormat.includes(g)&&!(m&&M.transcoderFormat.length<2)&&!(M.needsPowerOfTwo&&!(f(A)&&f(v))))return b=M.transcoderFormat[m?1:0],y=M.engineFormat[m?1:0],{transcoderFormat:b,engineFormat:y}}return console.warn("THREE.KTX2Loader: No suitable compressed texture format found. Decoding to RGBA32."),b=s.RGBA32,y=i.RGBAFormat,{transcoderFormat:b,engineFormat:y}}function f(g){return g<=2?!0:(g&g-1)===0&&g!==0}function p(g){if(g.length===1)return g[0];let A=0;for(let b=0;b<g.length;b++){const y=g[b];A+=y.byteLength}const v=new Uint8Array(A);let m=0;for(let b=0;b<g.length;b++){const y=g[b];v.set(y,m),m+=y.byteLength}return v}};const nD={[vN]:Ei,[gN]:Ei,[dN]:Ei,[oT]:Ei,[AN]:su,[pN]:su,[uN]:su,[rT]:su,[mN]:Pc,[fN]:Pc,[sT]:Pc,[hN]:Pc},nS={[vN]:sn,[gN]:wn,[dN]:pi,[oT]:pi,[AN]:sn,[pN]:wn,[uN]:pi,[rT]:pi,[mN]:sn,[fN]:wn,[sT]:pi,[hN]:pi},_Y={[oT]:Ze,[rT]:Ze,[sT]:Ze};async function xY(n,e=0){const{vkFormat:t}=n,i=Math.max(1,n.pixelWidth>>e),s=Math.max(1,n.pixelHeight>>e),r=Math.max(1,n.pixelDepth>>e);if(nD[t]===void 0)throw new Error("THREE.KTX2Loader: Unsupported vkFormat.");const o=n.levels[e];let a,c;if(n.supercompressionScheme===fY)a=o.levelData;else if(n.supercompressionScheme===pY)iS||(iS=new Promise(async h=>{const d=new bY;await d.init(),h(d)})),a=(await iS).decode(o.levelData,o.uncompressedByteLength);else throw new Error("THREE.KTX2Loader: Unsupported supercompressionScheme.");nS[t]===sn?c=new Float32Array(a.buffer,a.byteOffset,a.byteLength/Float32Array.BYTES_PER_ELEMENT):nS[t]===wn?c=new Uint16Array(a.buffer,a.byteOffset,a.byteLength/Uint16Array.BYTES_PER_ELEMENT):c=a;const l=r===0?new Co(c,i,s):new Hb(c,i,s,r);return l.type=nS[t],l.format=nD[t],l.colorSpace=_Y[t]||mr,l.needsUpdate=!0,Promise.resolve(l)}var wY=function(){var n="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 s=WebAssembly.validate(t)?e:n,r,o=WebAssembly.instantiate(a(s),{}).then(function(m){r=m.instance,r.exports.__wasm_call_ctors()});function a(m){for(var b=new Uint8Array(m.length),y=0;y<m.length;++y){var _=m.charCodeAt(y);b[y]=_>96?_-97:_>64?_-39:_+4}for(var C=0,y=0;y<m.length;++y)b[C++]=b[y]<60?i[b[y]]:(b[y]-60)*64+b[++y];return b.buffer.slice(0,C)}function c(m,b,y,_,C,M){var I=r.exports.sbrk,R=y+3&-4,E=I(R*_),T=I(C.length),O=new Uint8Array(r.exports.memory.buffer);O.set(C,T);var K=m(E,y,_,T,C.length);if(K==0&&M&&M(E,R,_),b.set(O.subarray(E,E+y*_)),I(E-I(0)),K!=0)throw new Error("Malformed buffer data: "+K)}var l={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},h={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"},d=[],f=0;function p(m){var b={object:new Worker(m),pending:0,requests:{}};return b.object.onmessage=function(y){var _=y.data;b.pending-=_.count,b.requests[_.id][_.action](_.value),delete b.requests[_.id]},b}function g(m){for(var b="var instance; var ready = WebAssembly.instantiate(new Uint8Array(["+new Uint8Array(a(s))+"]), {}).then(function(result) { instance = result.instance; instance.exports.__wasm_call_ctors(); });self.onmessage = workerProcess;"+c.toString()+v.toString(),y=new Blob([b],{type:"text/javascript"}),_=URL.createObjectURL(y),C=0;C<m;++C)d[C]=p(_);URL.revokeObjectURL(_)}function A(m,b,y,_,C){for(var M=d[0],I=1;I<d.length;++I)d[I].pending<M.pending&&(M=d[I]);return new Promise(function(R,E){var T=new Uint8Array(y),O=f++;M.pending+=m,M.requests[O]={resolve:R,reject:E},M.object.postMessage({id:O,count:m,size:b,source:T,mode:_,filter:C},[T.buffer])})}function v(m){o.then(function(){var b=m.data;try{var y=new Uint8Array(b.count*b.size);c(r.exports[b.mode],y,b.count,b.size,b.source,r.exports[b.filter]),self.postMessage({id:b.id,count:b.count,action:"resolve",value:y},[y.buffer])}catch(_){self.postMessage({id:b.id,count:b.count,action:"reject",value:_})}})}return{ready:o,supported:!0,useWorkers:function(m){g(m)},decodeVertexBuffer:function(m,b,y,_,C){c(r.exports.meshopt_decodeVertexBuffer,m,b,y,_,r.exports[l[C]])},decodeIndexBuffer:function(m,b,y,_){c(r.exports.meshopt_decodeIndexBuffer,m,b,y,_)},decodeIndexSequence:function(m,b,y,_){c(r.exports.meshopt_decodeIndexSequence,m,b,y,_)},decodeGltfBuffer:function(m,b,y,_,C,M){c(r.exports[h[C]],m,b,y,_,r.exports[l[M]])},decodeGltfBufferAsync:function(m,b,y,_,C){return d.length>0?A(m,b,y,h[_],l[C]):o.then(function(){var M=new Uint8Array(m*b);return c(r.exports[h[_]],M,m,b,y,r.exports[l[C]]),M})}}}();const gf=re("debugdecoders"),sD="https://www.gstatic.com/draco/versioned/decoders/1.4.1/",rD="https://www.gstatic.com/basis-universal/versioned/2021-04-15-ba1c3e4/";let Xo,sS,zl;function oD(n){n!==void 0&&typeof n=="string"&&(Xo||(Xo=new nT),gf&&console.log("Setting draco decoder path to",n),Xo.setDecoderPath(n))}function aD(n){n!==void 0&&typeof n=="string"&&(Xo||(Xo=new nT),gf&&console.log("Setting draco decoder type to",n),Xo.setDecoderConfig({type:n}))}function cD(n){n!==void 0&&typeof n=="string"&&(zl||(zl=new Ko),gf&&console.log("Setting ktx2 transcoder path to",n),zl.setTranscoderPath(n))}function EA(n,e){Xo||(Xo=new nT,Xo.setDecoderPath(sD),Xo.setDecoderConfig({type:"js"}),gf&&console.log("Setting draco decoder path to",sD)),zl||(zl=new Ko,zl.setTranscoderPath(rD),gf&&console.log("Setting ktx2 transcoder path to",rD),e.renderer&&zl.detectSupport(e.renderer)),sS||(sS=wY,gf&&console.log("Using the default meshopt decoder")),n.setDRACOLoader(Xo),n.setKTX2Loader(zl),n.setMeshoptDecoder(sS)}function SY(n,e=1e-4){e=Math.max(e,Number.EPSILON);const t={},i=n.getIndex(),s=n.getAttribute("position"),r=i?i.count:s.count;let o=0;const a=Object.keys(n.attributes),c={},l={},h=[],d=["getX","getY","getZ","getW"],f=["setX","setY","setZ","setW"];for(let v=0,m=a.length;v<m;v++){const b=a[v],y=n.attributes[b];c[b]=new rt(new y.array.constructor(y.count*y.itemSize),y.itemSize,y.normalized);const _=n.morphAttributes[b];_&&(l[b]=new rt(new _.array.constructor(_.count*_.itemSize),_.itemSize,_.normalized))}const p=Math.log10(1/e),g=Math.pow(10,p);for(let v=0;v<r;v++){const m=i?i.getX(v):v;let b="";for(let y=0,_=a.length;y<_;y++){const C=a[y],M=n.getAttribute(C),I=M.itemSize;for(let R=0;R<I;R++)b+=`${~~(M[d[R]](m)*g)},`}if(b in t)h.push(t[b]);else{for(let y=0,_=a.length;y<_;y++){const C=a[y],M=n.getAttribute(C),I=n.morphAttributes[C],R=M.itemSize,E=c[C],T=l[C];for(let O=0;O<R;O++){const K=d[O],H=f[O];if(E[H](o,M[K](m)),I)for(let V=0,Y=I.length;V<Y;V++)T[V][H](o,I[V][K](m))}}t[b]=o,h.push(o),o++}}const A=n.clone();for(const v in n.attributes){const m=c[v];if(A.setAttribute(v,new rt(m.array.slice(0,o*m.itemSize),m.itemSize,m.normalized)),v in l)for(let b=0;b<l[v].length;b++){const y=l[v][b];A.morphAttributes[v][b]=new rt(y.array.slice(0,o*y.itemSize),y.itemSize,y.normalized)}}return A.setIndex(h),A}function lD(n,e){if(e===cL)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),n;if(e===V0||e===GM){let t=n.getIndex();if(t===null){const o=[],a=n.getAttribute("position");if(a!==void 0){for(let c=0;c<a.count;c++)o.push(c);n.setIndex(o),t=n.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),n}const i=t.count-2,s=[];if(e===V0)for(let o=1;o<=i;o++)s.push(t.getX(0)),s.push(t.getX(o)),s.push(t.getX(o+1));else for(let o=0;o<i;o++)o%2===0?(s.push(t.getX(o)),s.push(t.getX(o+1)),s.push(t.getX(o+2))):(s.push(t.getX(o+2)),s.push(t.getX(o+1)),s.push(t.getX(o)));s.length/3!==i&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const r=n.clone();return r.setIndex(s),r.clearGroups(),r}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),n}class ep extends fs{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new IY(t)}),this.register(function(t){return new FY(t)}),this.register(function(t){return new UY(t)}),this.register(function(t){return new NY(t)}),this.register(function(t){return new PY(t)}),this.register(function(t){return new BY(t)}),this.register(function(t){return new DY(t)}),this.register(function(t){return new OY(t)}),this.register(function(t){return new TY(t)}),this.register(function(t){return new kY(t)}),this.register(function(t){return new RY(t)}),this.register(function(t){return new LY(t)}),this.register(function(t){return new EY(t)}),this.register(function(t){return new zY(t)}),this.register(function(t){return new GY(t)})}load(e,t,i,s){const r=this;let o;this.resourcePath!==""?o=this.resourcePath:this.path!==""?o=this.path:o=Pf.extractUrlBase(e),this.manager.itemStart(e);const a=function(l){s?s(l):console.error(l),r.manager.itemError(e),r.manager.itemEnd(e)},c=new Ln(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,s){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))===yN){try{o[ei.KHR_BINARY_GLTF]=new HY(e)}catch(d){s&&s(d);return}r=JSON.parse(o[ei.KHR_BINARY_GLTF].content)}else r=JSON.parse(c.decode(e));else r=e;if(r.asset===void 0||r.asset.version[0]<2){s&&s(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const l=new t7(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 d=this.pluginCallbacks[h](l);a[d.name]=d,o[d.name]=!0}if(r.extensionsUsed)for(let h=0;h<r.extensionsUsed.length;++h){const d=r.extensionsUsed[h],f=r.extensionsRequired||[];switch(d){case ei.KHR_MATERIALS_UNLIT:o[d]=new MY;break;case ei.KHR_DRACO_MESH_COMPRESSION:o[d]=new VY(r,this.dracoLoader);break;case ei.KHR_TEXTURE_TRANSFORM:o[d]=new QY;break;case ei.KHR_MESH_QUANTIZATION:o[d]=new WY;break;default:f.indexOf(d)>=0&&a[d]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+d+'".')}}l.setExtensions(o),l.setPlugins(a),l.parse(i,s)}parseAsync(e,t){const i=this;return new Promise(function(s,r){i.parse(e,t,s,r)})}}function CY(){let n={};return{get:function(e){return n[e]},add:function(e,t){n[e]=t},remove:function(e){delete n[e]},removeAll:function(){n={}}}}const ei={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_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"};class EY{constructor(e){this.parser=e,this.name=ei.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let i=0,s=t.length;i<s;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 s=t.cache.get(i);if(s)return s;const r=t.json,c=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e];let l;const h=new _e(16777215);c.color!==void 0&&h.fromArray(c.color);const d=c.range!==void 0?c.range:0;switch(c.type){case"directional":l=new g_(h),l.target.position.set(0,0,-1),l.add(l.target);break;case"point":l=new p_(h),l.distance=d;break;case"spot":l=new f_(h),l.distance=d,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,Ul(l,c),c.intensity!==void 0&&(l.intensity=c.intensity),l.name=t.createUniqueName(c.name||"light_"+e),s=Promise.resolve(l),t.cache.add(i,s),s}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)})}}let MY=class{constructor(){this.name=ei.KHR_MATERIALS_UNLIT}getMaterialType(){return hi}extendParams(e,t,i){const s=[];e.color=new _e(1,1,1),e.opacity=1;const r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const o=r.baseColorFactor;e.color.fromArray(o),e.opacity=o[3]}r.baseColorTexture!==void 0&&s.push(i.assignTexture(e,"map",r.baseColorTexture,Ze))}return Promise.all(s)}},TY=class{constructor(e){this.parser=e,this.name=ei.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=s.extensions[this.name].emissiveStrength;return r!==void 0&&(t.emissiveIntensity=r),Promise.resolve()}},IY=class{constructor(e){this.parser=e,this.name=ei.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:na}extendMaterialParams(e,t){const i=this.parser,s=i.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],o=s.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 te(a,a)}return Promise.all(r)}},RY=class{constructor(e){this.parser=e,this.name=ei.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:na}extendMaterialParams(e,t){const i=this.parser,s=i.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],o=s.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)}},PY=class{constructor(e){this.parser=e,this.name=ei.KHR_MATERIALS_SHEEN}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:na}extendMaterialParams(e,t){const i=this.parser,s=i.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[];t.sheenColor=new _e(0,0,0),t.sheenRoughness=0,t.sheen=1;const o=s.extensions[this.name];return o.sheenColorFactor!==void 0&&t.sheenColor.fromArray(o.sheenColorFactor),o.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=o.sheenRoughnessFactor),o.sheenColorTexture!==void 0&&r.push(i.assignTexture(t,"sheenColorMap",o.sheenColorTexture,Ze)),o.sheenRoughnessTexture!==void 0&&r.push(i.assignTexture(t,"sheenRoughnessMap",o.sheenRoughnessTexture)),Promise.all(r)}},BY=class{constructor(e){this.parser=e,this.name=ei.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:na}extendMaterialParams(e,t){const i=this.parser,s=i.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],o=s.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)}},DY=class{constructor(e){this.parser=e,this.name=ei.KHR_MATERIALS_VOLUME}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:na}extendMaterialParams(e,t){const i=this.parser,s=i.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],o=s.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 _e(a[0],a[1],a[2]),Promise.all(r)}},OY=class{constructor(e){this.parser=e,this.name=ei.KHR_MATERIALS_IOR}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:na}extendMaterialParams(e,t){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=s.extensions[this.name];return t.ior=r.ior!==void 0?r.ior:1.5,Promise.resolve()}},kY=class{constructor(e){this.parser=e,this.name=ei.KHR_MATERIALS_SPECULAR}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:na}extendMaterialParams(e,t){const i=this.parser,s=i.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],o=s.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 _e(a[0],a[1],a[2]),o.specularColorTexture!==void 0&&r.push(i.assignTexture(t,"specularColorMap",o.specularColorTexture,Ze)),Promise.all(r)}},LY=class{constructor(e){this.parser=e,this.name=ei.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:na}extendMaterialParams(e,t){const i=this.parser,s=i.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],o=s.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)}};class FY{constructor(e){this.parser=e,this.name=ei.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,i=t.json,s=i.textures[e];if(!s.extensions||!s.extensions[this.name])return null;const r=s.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)}}class UY{constructor(e){this.parser=e,this.name=ei.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,i=this.parser,s=i.json,r=s.textures[e];if(!r.extensions||!r.extensions[t])return null;const o=r.extensions[t],a=s.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(s.extensionsRequired&&s.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}}class NY{constructor(e){this.parser=e,this.name=ei.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,i=this.parser,s=i.json,r=s.textures[e];if(!r.extensions||!r.extensions[t])return null;const o=r.extensions[t],a=s.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(s.extensionsRequired&&s.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}}class zY{constructor(e){this.name=ei.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 s=i.extensions[this.name],r=this.parser.getDependency("buffer",s.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=s.byteOffset||0,l=s.byteLength||0,h=s.count,d=s.byteStride,f=new Uint8Array(a,c,l);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(h,d,f,s.mode,s.filter).then(function(p){return p.buffer}):o.ready.then(function(){const p=new ArrayBuffer(h*d);return o.decodeGltfBuffer(new Uint8Array(p),h,d,f,s.mode,s.filter),p})})}else return null}}class GY{constructor(e){this.name=ei.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 s=t.meshes[i.mesh];for(const l of s.primitives)if(l.mode!==go.TRIANGLES&&l.mode!==go.TRIANGLE_STRIP&&l.mode!==go.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(),d=h.isGroup?h.children:[h],f=l[0].count,p=[];for(const g of d){const A=new Re,v=new S,m=new Se,b=new S(1,1,1),y=new Kb(g.geometry,g.material,f);for(let _=0;_<f;_++)c.TRANSLATION&&v.fromBufferAttribute(c.TRANSLATION,_),c.ROTATION&&m.fromBufferAttribute(c.ROTATION,_),c.SCALE&&b.fromBufferAttribute(c.SCALE,_),y.setMatrixAt(_,A.compose(v,m,b));for(const _ in c)_!=="TRANSLATION"&&_!=="ROTATION"&&_!=="SCALE"&&g.geometry.setAttribute(_,c[_]);Te.prototype.copy.call(y,g),this.parser.assignFinalMaterial(y),p.push(y)}return h.isGroup?(h.clear(),h.add(...p),h):p[0]}))}}const yN="glTF",Yp=12,hD={JSON:1313821514,BIN:5130562};class HY{constructor(e){this.name=ei.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,Yp),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!==yN)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const s=this.header.length-Yp,r=new DataView(e,Yp);let o=0;for(;o<s;){const a=r.getUint32(o,!0);o+=4;const c=r.getUint32(o,!0);if(o+=4,c===hD.JSON){const l=new Uint8Array(e,Yp+o,a);this.content=i.decode(l)}else if(c===hD.BIN){const l=Yp+o;this.body=e.slice(l,l+a)}o+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class VY{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=ei.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const i=this.json,s=this.dracoLoader,r=e.extensions[this.name].bufferView,o=e.extensions[this.name].attributes,a={},c={},l={};for(const h in o){const d=OE[h]||h.toLowerCase();a[d]=o[h]}for(const h in e.attributes){const d=OE[h]||h.toLowerCase();if(o[h]!==void 0){const f=i.accessors[e.attributes[h]],p=mf[f.componentType];l[d]=p.name,c[d]=f.normalized===!0}}return t.getDependency("bufferView",r).then(function(h){return new Promise(function(d){s.decodeDracoFile(h,function(f){for(const p in f.attributes){const g=f.attributes[p],A=c[p];A!==void 0&&(g.normalized=A)}d(f)},a,l)})})}}class QY{constructor(){this.name=ei.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}}class WY{constructor(){this.name=ei.KHR_MESH_QUANTIZATION}}class bN extends Wf{constructor(e,t,i,s){super(e,t,i,s)}copySampleValue_(e){const t=this.resultBuffer,i=this.sampleValues,s=this.valueSize,r=e*s*3+s;for(let o=0;o!==s;o++)t[o]=i[r+o];return t}interpolate_(e,t,i,s){const r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=a*2,l=a*3,h=s-t,d=(i-t)/h,f=d*d,p=f*d,g=e*l,A=g-l,v=-2*p+3*f,m=p-f,b=1-v,y=m-f+d;for(let _=0;_!==a;_++){const C=o[A+_+a],M=o[A+_+c]*h,I=o[g+_+a],R=o[g+_]*h;r[_]=b*C+y*M+v*I+m*R}return r}}const jY=new Se;class XY extends bN{interpolate_(e,t,i,s){const r=super.interpolate_(e,t,i,s);return jY.fromArray(r).normalize().toArray(r),r}}const go={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},mf={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},uD={9728:Ht,9729:Ft,9984:Mf,9985:aA,9986:du,9987:Mo},dD={33071:Yn,33648:xu,10497:Eo},rS={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},OE={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"},Tl={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},qY={CUBICSPLINE:void 0,LINEAR:Ha,STEP:eh},oS={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function YY(n){return n.DefaultMaterial===void 0&&(n.DefaultMaterial=new $o({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:Rs})),n.DefaultMaterial}function zh(n,e,t){for(const i in t.extensions)n[i]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[i]=t.extensions[i])}function Ul(n,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(n.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function KY(n,e,t){let i=!1,s=!1,r=!1;for(let l=0,h=e.length;l<h;l++){const d=e[l];if(d.POSITION!==void 0&&(i=!0),d.NORMAL!==void 0&&(s=!0),d.COLOR_0!==void 0&&(r=!0),i&&s&&r)break}if(!i&&!s&&!r)return Promise.resolve(n);const o=[],a=[],c=[];for(let l=0,h=e.length;l<h;l++){const d=e[l];if(i){const f=d.POSITION!==void 0?t.getDependency("accessor",d.POSITION):n.attributes.position;o.push(f)}if(s){const f=d.NORMAL!==void 0?t.getDependency("accessor",d.NORMAL):n.attributes.normal;a.push(f)}if(r){const f=d.COLOR_0!==void 0?t.getDependency("accessor",d.COLOR_0):n.attributes.color;c.push(f)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(c)]).then(function(l){const h=l[0],d=l[1],f=l[2];return i&&(n.morphAttributes.position=h),s&&(n.morphAttributes.normal=d),r&&(n.morphAttributes.color=f),n.morphTargetsRelative=!0,n})}function JY(n,e){if(n.updateMorphTargets(),e.weights!==void 0)for(let t=0,i=e.weights.length;t<i;t++)n.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(n.morphTargetInfluences.length===t.length){n.morphTargetDictionary={};for(let i=0,s=t.length;i<s;i++)n.morphTargetDictionary[t[i]]=i}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function ZY(n){let e;const t=n.extensions&&n.extensions[ei.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+aS(t.attributes):e=n.indices+":"+aS(n.attributes)+":"+n.mode,n.targets!==void 0)for(let i=0,s=n.targets.length;i<s;i++)e+=":"+aS(n.targets[i]);return e}function aS(n){let e="";const t=Object.keys(n).sort();for(let i=0,s=t.length;i<s;i++)e+=t[i]+":"+n[t[i]]+";";return e}function kE(n){switch(n){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 $Y(n){return n.search(/\.jpe?g($|\?)/i)>0||n.search(/^data\:image\/jpeg/)===0?"image/jpeg":n.search(/\.webp($|\?)/i)>0||n.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}const e7=new Re;class t7{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new CY,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,s=!1,r=-1;typeof navigator<"u"&&(i=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,s=navigator.userAgent.indexOf("Firefox")>-1,r=s?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||i||s&&r<98?this.textureLoader=new Hc(this.options.manager):this.textureLoader=new A2(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Ln(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,s=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][s.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:s.asset,parser:i,userData:{}};zh(r,a,s),Ul(a,s),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 s=0,r=t.length;s<r;s++){const o=t[s].joints;for(let a=0,c=o.length;a<c;a++)e[o[a]].isBone=!0}for(let s=0,r=e.length;s<r;s++){const o=e[s];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 s=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,s),s.name+="_instance_"+e.uses[t]++,s}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let i=0;i<t.length;i++){const s=e(t[i]);if(s)return s}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const i=[];for(let s=0;s<t.length;s++){const r=e(t[s]);r&&i.push(r)}return i}getDependency(e,t){const i=e+":"+t;let s=this.cache.get(i);if(!s){switch(e){case"scene":s=this.loadScene(t);break;case"node":s=this._invokeOne(function(r){return r.loadNode&&r.loadNode(t)});break;case"mesh":s=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(t)});break;case"accessor":s=this.loadAccessor(t);break;case"bufferView":s=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(t)});break;case"buffer":s=this.loadBuffer(t);break;case"material":s=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(t)});break;case"texture":s=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(t)});break;case"skin":s=this.loadSkin(t);break;case"animation":s=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(t)});break;case"camera":s=this.loadCamera(t);break;default:if(s=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(e,t)}),!s)throw new Error("Unknown type: "+e);break}this.cache.add(i,s)}return s}getDependencies(e){let t=this.cache.get(e);if(!t){const i=this,s=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(s.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[ei.KHR_BINARY_GLTF].body);const s=this.options;return new Promise(function(r,o){i.load(Pf.resolveURL(t.uri,s.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 s=t.byteLength||0,r=t.byteOffset||0;return i.slice(r,r+s)})}loadAccessor(e){const t=this,i=this.json,s=this.json.accessors[e];if(s.bufferView===void 0&&s.sparse===void 0){const o=rS[s.type],a=mf[s.componentType],c=s.normalized===!0,l=new a(s.count*o);return Promise.resolve(new rt(l,o,c))}const r=[];return s.bufferView!==void 0?r.push(this.getDependency("bufferView",s.bufferView)):r.push(null),s.sparse!==void 0&&(r.push(this.getDependency("bufferView",s.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",s.sparse.values.bufferView))),Promise.all(r).then(function(o){const a=o[0],c=rS[s.type],l=mf[s.componentType],h=l.BYTES_PER_ELEMENT,d=h*c,f=s.byteOffset||0,p=s.bufferView!==void 0?i.bufferViews[s.bufferView].byteStride:void 0,g=s.normalized===!0;let A,v;if(p&&p!==d){const m=Math.floor(f/p),b="InterleavedBuffer:"+s.bufferView+":"+s.componentType+":"+m+":"+s.count;let y=t.cache.get(b);y||(A=new l(a,m*p,s.count*p/h),y=new hA(A,p/h),t.cache.add(b,y)),v=new qc(y,c,f%p/h,g)}else a===null?A=new l(s.count*c):A=new l(a,f,s.count*c),v=new rt(A,c,g);if(s.sparse!==void 0){const m=rS.SCALAR,b=mf[s.sparse.indices.componentType],y=s.sparse.indices.byteOffset||0,_=s.sparse.values.byteOffset||0,C=new b(o[1],y,s.sparse.count*m),M=new l(o[2],_,s.sparse.count*c);a!==null&&(v=new rt(v.array.slice(),v.itemSize,v.normalized));for(let I=0,R=C.length;I<R;I++){const E=C[I];if(v.setX(E,M[I*c]),c>=2&&v.setY(E,M[I*c+1]),c>=3&&v.setZ(E,M[I*c+2]),c>=4&&v.setW(E,M[I*c+3]),c>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return v})}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 s=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=uD[f.magFilter]||Ft,h.minFilter=uD[f.minFilter]||Mo,h.wrapS=dD[f.wrapS]||Eo,h.wrapT=dD[f.wrapT]||Eo,h.anisotropy=4,s.associations.set(h,{textures:e}),h}).catch(function(){return null});return this.textureCache[c]=l,l}loadImageSource(e,t){const i=this,s=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(d=>d.clone());const o=s.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(d){l=!0;const f=new Blob([d],{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(d){return new Promise(function(f,p){let g=f;t.isImageBitmapLoader===!0&&(g=function(A){const v=new Ot(A);v.needsUpdate=!0,f(v)}),t.load(Pf.resolveURL(d,r.path),g,void 0,p)})}).then(function(d){return l===!0&&a.revokeObjectURL(c),d.userData.mimeType=o.mimeType||$Y(o.uri),d}).catch(function(d){throw console.error("THREE.GLTFLoader: Couldn't load texture",c),d});return this.sourceCache[e]=h,h}assignTexture(e,t,i,s){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[ei.KHR_TEXTURE_TRANSFORM]){const a=i.extensions!==void 0?i.extensions[ei.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const c=r.associations.get(o);o=r.extensions[ei.KHR_TEXTURE_TRANSFORM].extendTexture(o,a),r.associations.set(o,c)}}return s!==void 0&&(o.colorSpace=s),e[t]=o,o})}assignFinalMaterial(e){const t=e.geometry;let i=e.material;const s=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 Jb,kt.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 gn,kt.prototype.copy.call(c,i),c.color.copy(i.color),c.map=i.map,this.cache.add(a,c)),i=c}if(s||r||o){let a="ClonedMaterial:"+i.uuid+":";s&&(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),s&&(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 $o}loadMaterial(e){const t=this,i=this.json,s=this.extensions,r=i.materials[e];let o;const a={},c=r.extensions||{},l=[];if(c[ei.KHR_MATERIALS_UNLIT]){const d=s[ei.KHR_MATERIALS_UNLIT];o=d.getMaterialType(),l.push(d.extendParams(a,r,t))}else{const d=r.pbrMetallicRoughness||{};if(a.color=new _e(1,1,1),a.opacity=1,Array.isArray(d.baseColorFactor)){const f=d.baseColorFactor;a.color.fromArray(f),a.opacity=f[3]}d.baseColorTexture!==void 0&&l.push(t.assignTexture(a,"map",d.baseColorTexture,Ze)),a.metalness=d.metallicFactor!==void 0?d.metallicFactor:1,a.roughness=d.roughnessFactor!==void 0?d.roughnessFactor:1,d.metallicRoughnessTexture!==void 0&&(l.push(t.assignTexture(a,"metalnessMap",d.metallicRoughnessTexture)),l.push(t.assignTexture(a,"roughnessMap",d.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=Si);const h=r.alphaMode||oS.OPAQUE;if(h===oS.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,h===oS.MASK&&(a.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&o!==hi&&(l.push(t.assignTexture(a,"normalMap",r.normalTexture)),a.normalScale=new te(1,1),r.normalTexture.scale!==void 0)){const d=r.normalTexture.scale;a.normalScale.set(d,d)}return r.occlusionTexture!==void 0&&o!==hi&&(l.push(t.assignTexture(a,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&o!==hi&&(a.emissive=new _e().fromArray(r.emissiveFactor)),r.emissiveTexture!==void 0&&o!==hi&&l.push(t.assignTexture(a,"emissiveMap",r.emissiveTexture,Ze)),Promise.all(l).then(function(){const d=new o(a);return r.name&&(d.name=r.name),Ul(d,r),t.associations.set(d,{materials:e}),r.extensions&&zh(s,d,r),d})}createUniqueName(e){const t=Ut.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,i=this.extensions,s=this.primitiveCache;function r(a){return i[ei.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(c){return fD(c,a,t)})}const o=[];for(let a=0,c=e.length;a<c;a++){const l=e[a],h=ZY(l),d=s[h];if(d)o.push(d.promise);else{let f;l.extensions&&l.extensions[ei.KHR_DRACO_MESH_COMPRESSION]?f=r(l):f=fD(new vt,l,t),s[h]={primitive:l,promise:f},o.push(f)}}return Promise.all(o)}loadMesh(e){const t=this,i=this.json,s=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?YY(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],d=[];for(let p=0,g=h.length;p<g;p++){const A=h[p],v=o[p];let m;const b=l[p];if(v.mode===go.TRIANGLES||v.mode===go.TRIANGLE_STRIP||v.mode===go.TRIANGLE_FAN||v.mode===void 0)m=r.isSkinnedMesh===!0?new Bu(A,b):new ye(A,b),m.isSkinnedMesh===!0&&m.normalizeSkinWeights(),v.mode===go.TRIANGLE_STRIP?m.geometry=lD(m.geometry,GM):v.mode===go.TRIANGLE_FAN&&(m.geometry=lD(m.geometry,V0));else if(v.mode===go.LINES)m=new jr(A,b);else if(v.mode===go.LINE_STRIP)m=new hn(A,b);else if(v.mode===go.LINE_LOOP)m=new e1(A,b);else if(v.mode===go.POINTS)m=new t1(A,b);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+v.mode);Object.keys(m.geometry.morphAttributes).length>0&&JY(m,r),m.name=t.createUniqueName(r.name||"mesh_"+e),Ul(m,r),v.extensions&&zh(s,m,v),t.assignFinalMaterial(m),d.push(m)}for(let p=0,g=d.length;p<g;p++)t.associations.set(d[p],{meshes:e,primitives:p});if(d.length===1)return r.extensions&&zh(s,d[0],r),d[0];const f=new zr;r.extensions&&zh(s,f,r),t.associations.set(f,{meshes:e});for(let p=0,g=d.length;p<g;p++)f.add(d[p]);return f})}loadCamera(e){let t;const i=this.json.cameras[e],s=i[i.type];if(!s){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return i.type==="perspective"?t=new qt(as.radToDeg(s.yfov),s.aspectRatio||1,s.znear||1,s.zfar||2e6):i.type==="orthographic"&&(t=new Ru(-s.xmag,s.xmag,s.ymag,-s.ymag,s.znear,s.zfar)),i.name&&(t.name=this.createUniqueName(i.name)),Ul(t,i),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],i=[];for(let s=0,r=t.joints.length;s<r;s++)i.push(this._loadNodeShallow(t.joints[s]));return t.inverseBindMatrices!==void 0?i.push(this.getDependency("accessor",t.inverseBindMatrices)):i.push(null),Promise.all(i).then(function(s){const r=s.pop(),o=s,a=[],c=[];for(let l=0,h=o.length;l<h;l++){const d=o[l];if(d){a.push(d);const f=new Re;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 Qf(a,c)})}loadAnimation(e){const t=this.json,i=this,s=t.animations[e],r=s.name?s.name:"animation_"+e,o=[],a=[],c=[],l=[],h=[];let d=0,f=s.channels.length;for(d=0,f=s.channels.length;d<f;d++){const p=s.channels[d],g=s.samplers[p.sampler],A=p.target,v=A.node,m=s.parameters!==void 0?s.parameters[g.input]:g.input,b=s.parameters!==void 0?s.parameters[g.output]:g.output;A.node!==void 0&&(o.push(this.getDependency("node",v)),a.push(this.getDependency("accessor",m)),c.push(this.getDependency("accessor",b)),l.push(g),h.push(A))}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],A=p[1],v=p[2],m=p[3],b=p[4],y=[];for(d=0,f=g.length;d<f;d++){const _=g[d],C=A[d],M=v[d],I=m[d],R=b[d];if(_===void 0)continue;_.updateMatrix&&(_.updateMatrix(),_.matrixAutoUpdate=!0);const E=i._createAnimationTracks(_,C,M,I,R);if(E)for(let T=0;T<E.length;T++)y.push(E[T])}return new Ks(r,void 0,y)})}createNodeMesh(e){const t=this.json,i=this,s=t.nodes[e];return s.mesh===void 0?null:i.getDependency("mesh",s.mesh).then(function(r){const o=i._getNodeRef(i.meshCache,s.mesh,r);return s.weights!==void 0&&o.traverse(function(a){if(a.isMesh)for(let c=0,l=s.weights.length;c<l;c++)a.morphTargetInfluences[c]=s.weights[c]}),o})}loadNode(e){const t=this.json,i=this,s=t.nodes[e],r=i._loadNodeShallow(e),o=[],a=s.children||[];for(let l=0,h=a.length;l<h;l++)o.push(i.getDependency("node",a[l]));const c=s.skin===void 0?Promise.resolve(null):i.getDependency("skin",s.skin);return Promise.all([r,Promise.all(o),c]).then(function(l){const h=l[0],d=l[1],f=l[2];f!==null&&h.traverse(function(p){p.isSkinnedMesh&&p.bind(f,e7)});for(let p=0,g=d.length;p<g;p++)h.add(d[p]);return h})}_loadNodeShallow(e){const t=this.json,i=this.extensions,s=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const r=t.nodes[e],o=r.name?s.createUniqueName(r.name):"",a=[],c=s._invokeOne(function(l){return l.createNodeMesh&&l.createNodeMesh(e)});return c&&a.push(c),r.camera!==void 0&&a.push(s.getDependency("camera",r.camera).then(function(l){return s._getNodeRef(s.cameraCache,r.camera,l)})),s._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 uA:l.length>1?h=new zr:l.length===1?h=l[0]:h=new Te,h!==l[0])for(let d=0,f=l.length;d<f;d++)h.add(l[d]);if(r.name&&(h.userData.name=r.name,h.name=o),Ul(h,r),r.extensions&&zh(i,h,r),r.matrix!==void 0){const d=new Re;d.fromArray(r.matrix),h.applyMatrix4(d)}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 s.associations.has(h)||s.associations.set(h,{}),s.associations.get(h).nodes=e,h}),this.nodeCache[e]}loadScene(e){const t=this.extensions,i=this.json.scenes[e],s=this,r=new zr;i.name&&(r.name=s.createUniqueName(i.name)),Ul(r,i),i.extensions&&zh(t,r,i);const o=i.nodes||[],a=[];for(let c=0,l=o.length;c<l;c++)a.push(s.getDependency("node",o[c]));return Promise.all(a).then(function(c){for(let h=0,d=c.length;h<d;h++)r.add(c[h]);const l=h=>{const d=new Map;for(const[f,p]of s.associations)(f instanceof kt||f instanceof Ot)&&d.set(f,p);return h.traverse(f=>{const p=s.associations.get(f);p!=null&&d.set(f,p)}),d};return s.associations=l(r),r})}_createAnimationTracks(e,t,i,s,r){const o=[],a=e.name?e.name:e.uuid,c=[];Tl[r.path]===Tl.weights?e.traverse(function(f){f.morphTargetInfluences&&c.push(f.name?f.name:f.uuid)}):c.push(a);let l;switch(Tl[r.path]){case Tl.weights:l=th;break;case Tl.rotation:l=Va;break;case Tl.position:case Tl.scale:l=Yc;break;default:switch(i.itemSize){case 1:l=th;break;case 2:case 3:default:l=Yc;break}break}const h=s.interpolation!==void 0?qY[s.interpolation]:Ha,d=this._getArrayFromAccessor(i);for(let f=0,p=c.length;f<p;f++){const g=new l(c[f]+"."+Tl[r.path],t.array,d,h);s.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(g),o.push(g)}return o}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const i=kE(t.constructor),s=new Float32Array(t.length);for(let r=0,o=t.length;r<o;r++)s[r]=t[r]*i;t=s}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(i){const s=this instanceof Va?XY:bN;return new s(this.times,this.values,this.getValueSize()/3,i)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function i7(n,e,t){const i=e.attributes,s=new kn;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(s.set(new S(c[0],c[1],c[2]),new S(l[0],l[1],l[2])),a.normalized){const h=kE(mf[a.componentType]);s.min.multiplyScalar(h),s.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 S,c=new S;for(let l=0,h=r.length;l<h;l++){const d=r[l];if(d.POSITION!==void 0){const f=t.json.accessors[d.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 A=kE(mf[f.componentType]);c.multiplyScalar(A)}a.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}s.expandByVector(a)}n.boundingBox=s;const o=new ir;s.getCenter(o.center),o.radius=s.min.distanceTo(s.max)/2,n.boundingSphere=o}function fD(n,e,t){const i=e.attributes,s=[];function r(o,a){return t.getDependency("accessor",o).then(function(c){n.setAttribute(a,c)})}for(const o in i){const a=OE[o]||o.toLowerCase();a in n.attributes||s.push(r(i[o],a))}if(e.indices!==void 0&&!n.index){const o=t.getDependency("accessor",e.indices).then(function(a){n.setIndex(a)});s.push(o)}return Ul(n,e),i7(n,e,t),Promise.all(s).then(function(){return e.targets!==void 0?KY(n,e.targets,t):n})}var _N=(n=>(n[n.INT=5124]="INT",n[n.FLOAT=5126]="FLOAT",n[n.FLOAT_VEC2=35664]="FLOAT_VEC2",n[n.FLOAT_VEC3=35665]="FLOAT_VEC3",n[n.FLOAT_VEC4=35666]="FLOAT_VEC4",n[n.INT_VEC2=35667]="INT_VEC2",n[n.INT_VEC3=35668]="INT_VEC3",n[n.INT_VEC4=35669]="INT_VEC4",n[n.BOOL=35670]="BOOL",n[n.BOOL_VEC2=35671]="BOOL_VEC2",n[n.BOOL_VEC3=35672]="BOOL_VEC3",n[n.BOOL_VEC4=35673]="BOOL_VEC4",n[n.FLOAT_MAT2=35674]="FLOAT_MAT2",n[n.FLOAT_MAT3=35675]="FLOAT_MAT3",n[n.FLOAT_MAT4=35676]="FLOAT_MAT4",n[n.SAMPLER_2D=35678]="SAMPLER_2D",n[n.SAMPLER_3D=35680]="SAMPLER_3D",n[n.SAMPLER_CUBE=35681]="SAMPLER_CUBE",n[n.UNKNOWN=0]="UNKNOWN",n))(_N||{});const wa=re("debugcustomshader"),Id="NEEDLE_techniques_webgl";class n7{constructor(){u(this,"objectToWorldMatrix",new Re);u(this,"worldToObjectMatrix",new Re);u(this,"objectToWorld",new Array);u(this,"worldToObject",new Array)}updateFrom(e){this.objectToWorldMatrix.copy(e.matrixWorld),sb(this.objectToWorldMatrix,this.objectToWorld),this.worldToObjectMatrix.copy(e.matrixWorld).invert(),sb(this.worldToObjectMatrix,this.worldToObject)}}const Fi=class extends h_{constructor(t,...i){super(...i);u(this,"identifier");u(this,"onBeforeRenderSceneCallback",this.onBeforeRenderScene.bind(this));u(this,"_sphericalHarmonicsName","unity_SpecCube0");u(this,"_objToWorldName","hlslcc_mtx4x4unity_ObjectToWorld");u(this,"_worldToObjectName","hlslcc_mtx4x4unity_WorldToObject");u(this,"_viewProjectionName","hlslcc_mtx4x4unity_MatrixVP");u(this,"_viewMatrixName","hlslcc_mtx4x4unity_MatrixV");u(this,"_rendererData",new n7);this.identifier=t,wa&&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.waitForLighting(),(this.depthTextureUniform||this.opaqueTextureUniform)&&Nt.Current.pre_render_callbacks.push(this.onBeforeRenderSceneCallback)}clone(){const t=super.clone();return xN(t),t}dispose(){super.dispose();const t=Nt.Current.pre_render_callbacks.indexOf(this.onBeforeRenderSceneCallback);t>=0&&Nt.Current.pre_render_callbacks.splice(t,1)}async waitForLighting(){const t=Nt.Current;if(!t){console.error("Missing context");return}const i=await t.sceneLighting.internalGetSceneLightingData(this.identifier);if(!i||!i.array){console.warn("Missing lighting data for custom shader, getSceneLightingData did not return anything");return}wa&&console.log(i);const s=i.array,r=i.texture;this.uniforms.unity_SpecCube0={value:r},zU(this.uniforms,s);const o=Math.sqrt(Math.PI*.5);this.uniforms.unity_SpecCube0_HDR={value:new nt(o,o,o,o)},wa&&console.log("Set environment lighting",this.uniforms)}get depthTextureUniform(){if(this.uniforms)return this.uniforms._CameraDepthTexture}get opaqueTextureUniform(){if(this.uniforms)return this.uniforms._CameraOpaqueTexture}onBeforeRenderScene(){this.opaqueTextureUniform&&Nt.Current.setRequireColor(!0),this.depthTextureUniform&&Nt.Current.setRequireDepth(!0)}onBeforeRender(t,i,s,r,o,a){r.attributes.tangent||r.computeTangents(),this.onUpdateUniforms(s,o)}onUpdateUniforms(t,i){const s=Nt.Current;if(t&&(Fi.viewProjection&&this.uniforms[this._viewProjectionName]&&(Fi.viewProjection.copy(t.projectionMatrix).multiply(t.matrixWorldInverse),sb(Fi.viewProjection,Fi._viewProjectionValues)),Fi.viewMatrix&&this.uniforms[this._viewMatrixName]&&(Fi.viewMatrix.copy(t.matrixWorldInverse),sb(Fi.viewMatrix,Fi._viewMatrixValues)),this.uniforms[Fi._worldSpaceCameraPosName]&&Fi._worldSpaceCameraPos.setFromMatrixPosition(t.matrixWorld)),this.uniforms._TimeParameters&&(this.uniforms._TimeParameters.value=s.sceneLighting.timeVec4),this.uniforms._Time){const c=this.uniforms._Time.value;c.x=s.sceneLighting.timeVec4.x/20,c.y=s.sceneLighting.timeVec4.x,c.z=s.sceneLighting.timeVec4.x*2,c.w=s.sceneLighting.timeVec4.x*3}if(this.uniforms._SinTime){const c=this.uniforms._SinTime.value;c.x=Math.sin(s.sceneLighting.timeVec4.x/8),c.y=Math.sin(s.sceneLighting.timeVec4.x/4),c.z=Math.sin(s.sceneLighting.timeVec4.x/2),c.w=Math.sin(s.sceneLighting.timeVec4.x)}if(this.uniforms._CosTime){const c=this.uniforms._CosTime.value;c.x=Math.cos(s.sceneLighting.timeVec4.x/8),c.y=Math.cos(s.sceneLighting.timeVec4.x/4),c.z=Math.cos(s.sceneLighting.timeVec4.x/2),c.w=Math.cos(s.sceneLighting.timeVec4.x)}if(this.uniforms.unity_DeltaTime){const c=this.uniforms.unity_DeltaTime.value;c.x=s.time.deltaTime,c.y=1/s.time.deltaTime,c.z=s.time.smoothedDeltaTime,c.w=1/s.time.smoothedDeltaTime}const r=s.mainLight;if(r){const c=wt(r.gameObject,Fi._mainLightPosition);this.uniforms._MainLightPosition={value:c.normalize()},Fi._mainLightColor.set(r.color.r,r.color.g,r.color.b,0),this.uniforms._MainLightColor={value:Fi._mainLightColor};const l=r.intensity;Fi._lightData.z=l,this.uniforms.unity_LightData={value:Fi._lightData}}if(t&&(Fi.viewProjection&&this.uniforms[this._viewProjectionName]&&(this.uniforms[this._viewProjectionName].value=Fi._viewProjectionValues),Fi.viewMatrix&&this.uniforms[this._viewMatrixName]&&(this.uniforms[this._viewMatrixName].value=Fi._viewMatrixValues),this.uniforms[Fi._worldSpaceCameraPosName]&&(this.uniforms[Fi._worldSpaceCameraPosName]={value:Fi._worldSpaceCameraPos}),s.mainCameraComponent)){if(this.uniforms._ProjectionParams){const c=this.uniforms._ProjectionParams.value;c.x=1,c.y=s.mainCameraComponent.nearClipPlane,c.z=s.mainCameraComponent.farClipPlane,c.w=1/c.z,this.uniforms._ProjectionParams.value=c}if(this.uniforms._ZBufferParams){const c=this.uniforms._ZBufferParams.value,l=s.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=s.domWidth,c.y=s.domHeight,c.z=1+1/c.x,c.w=1+1/c.y,this.uniforms._ScreenParams.value=c}}const o=this.depthTextureUniform;o&&(o.value=s.depthTexture);const a=this.opaqueTextureUniform;if(a&&(a.value=s.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 Ir=Fi;u(Ir,"viewProjection",new Re),u(Ir,"_viewProjectionValues",[]),u(Ir,"viewMatrix",new Re),u(Ir,"_viewMatrixValues",[]),u(Ir,"_worldSpaceCameraPosName","_WorldSpaceCameraPos"),u(Ir,"_worldSpaceCameraPos",new S),u(Ir,"_mainLightColor",new nt),u(Ir,"_mainLightPosition",new S),u(Ir,"_lightData",new nt);class s7{constructor(e,t){u(this,"parser");u(this,"identifier");this.parser=e,this.identifier=t}get name(){return Id}loadMaterial(e){const t=this.parser.json.materials[e];if(!t)return wa&&console.log(e,this.parser.json.materials),null;if(!t.extensions||!t.extensions[Id])return wa&&console.log("material "+e+" does not use NEEDLE_techniques_webgl"),null;const i=t.extensions[Id].technique;if(i<0)return null;const s=this.parser.json.extensions[Id];if(!s)return null;wa&&console.log(s);const r=s.techniques[i];return r?new Promise(async(o,a)=>{var m,b,y;const c=await mq(s,r.program),l=c==null?void 0:c.fragmentShader,h=c==null?void 0:c.vertexShader;if(!l||!h)return a();wa&&console.log("loadMaterial",t,c);const d={},f=r.uniforms;(h.includes("_Time")||l.includes("_Time"))&&(d._Time={value:new nt(0,0,0,0)}),(h.includes("_SinTime")||l.includes("_SinTime"))&&(d._SinTime={value:new nt(0,0,0,0)}),(h.includes("_CosTime")||l.includes("_CosTime"))&&(d._CosTime={value:new nt(0,0,0,0)}),(h.includes("unity_DeltaTime")||l.includes("unity_DeltaTime"))&&(d.unity_DeltaTime={value:new nt(0,0,0,0)});for(const _ in f){const C=_;switch(C){case"_TimeParameters":const M=new nt;d[C]={value:M};break;case"hlslcc_mtx4x4unity_MatrixV":case"hlslcc_mtx4x4unity_MatrixVP":d[C]={value:[]};break;case"_MainLightPosition":case"_MainLightColor":case"_WorldSpaceCameraPos":d[C]={value:[0,0,0,1]};break;case"unity_OrthoParams":break;case"unity_SpecCube0":d[C]={value:null};break;default:case"_ScreenParams":case"_ZBufferParams":case"_ProjectionParams":d[C]={value:[0,0,0,0]};break;case"_CameraOpaqueTexture":case"_CameraDepthTexture":d[C]={value:null};break}}let p=!1;if(t.extensions&&t.extensions[Id]){const _=t.extensions[Id];if(_.technique===i){wa&&console.log(t.name,"Material Properties",_);for(const C in _.values){const M=_.values[C];if(typeof M=="string"){if(M.startsWith("/textures/")){const I=M.substring(10),R=Number.parseInt(I);if(R>=0){const E=await this.parser.getDependency("texture",R);E instanceof Ot&&(E.colorSpace=pn,E.needsUpdate=!0),d[C]={value:E};continue}}switch(C){case"alphaMode":M==="BLEND"&&(p=!0);continue}}if(Array.isArray(M)&&M.length===4){d[C]={value:new nt(M[0],M[1],M[2],M[3])};continue}d[C]={value:M}}}}const g=new Ir(this.identifier,{name:t.name??"",uniforms:d,vertexShader:h,fragmentShader:l,lights:!1});switch(g.glslVersion=Q0,g.vertexShader=g.vertexShader.replace("#version 300 es",""),g.fragmentShader=g.fragmentShader.replace("#version 300 es",""),(m=d._Cull)==null?void 0:m.value){case 0:g.side=Si;break;case 1:g.side=dn;break;case 2:g.side=Rs;break;default:g.side=Rs;break}switch((b=d._ZTest)==null?void 0:b.value){case 3:g.depthTest=!0,g.depthFunc=Cf;break;case 6:g.depthTest=!0,g.depthFunc=rA;break;case 2:g.depthTest=!0,g.depthFunc=gm;break;case 4:g.depthTest=!0,g.depthFunc=Sf;break;case 5:g.depthTest=!0,g.depthFunc=kb;break;case 7:g.depthTest=!0,g.depthFunc=Ob;break;case 8:g.depthTest=!1,g.depthFunc=Db;break}g.transparent=p,p&&(g.depthWrite=!1),zU(d),g.onUpdateUniforms();for(const _ in f){const C=_,M=f[_].type;if(((y=d[C])==null?void 0:y.value)===void 0)switch(M){case _N.SAMPLER_2D:d[C]={value:fq},console.warn("Missing/unassigned texture, fallback to white: "+C);break;default:C==="unity_OrthoParams"||console.warn("TODO: EXPECTED UNIFORM / fallback NOT SET: "+C,f[_]);break}}wa&&console.log(g.uuid,d),xN(g),o(g)}):null}}function xN(n){if(n.uniforms){wa&&console.log("Uniforms:",n.uniforms);for(const t in n.uniforms)switch(e(t,t),t){case"_Color":e("color",t);break}}function e(t,i){Object.getOwnPropertyDescriptor(n,t)||Object.defineProperty(n,t,{get:()=>n.uniforms[i].value,set:s=>{n.uniforms[i].value=s,n.needsUpdate=!0}})}}const uc=Ts,gy="$___Export_Components",r7="NEEDLE_components";var Hce;class o7{constructor(){u(this,Hce)}}Hce=eu;class a7{constructor(e,t,i){u(this,"node");u(this,"nodeIndex");u(this,"nodeDef");this.node=e,this.nodeIndex=t,this.nodeDef=i}}class wN{constructor(){u(this,"parser");u(this,"nodeToObjectMap",{});u(this,"exportContext");u(this,"objectToNodeMap",{});u(this,"context");u(this,"writer")}get name(){return r7}registerExport(e){e.register(t=>{if("serializeUserData"in t){const i=t.serializeUserData.bind(t);this.writer=t,t.serializeUserData=(s,r)=>{try{this.serializeUserData(s,r),i(s,r)}finally{this.afterSerializeUserData(s,r)}}}return this})}beforeParse(){this.exportContext={},this.objectToNodeMap={}}serializeUserData(e,t){var s;const i=(s=e.userData)==null?void 0:s.components;!i||i.length<=0||(delete e.userData.components,e[gy]=i)}afterSerializeUserData(e,t){if(e.type==="Scene"&&uc&&console.log("DONE",JSON.stringify(t)),e[gy]===void 0)return;const i=e[gy];delete e[gy],i!==null&&(e.userData.components=i)}writeNode(e,t){const i=this.writer.json.nodes.length;uc&&console.log(e.name,i,e.uuid);const s=new a7(e,i,t);this.exportContext[i]=s,this.objectToNodeMap[e.uuid]=i}afterParse(e){var t;uc&&console.log("AFTER",e);for(const i in this.exportContext){const s=this.exportContext[i],r=s.node,o=s.nodeDef,a=s.nodeIndex,c=(t=r.userData)==null?void 0:t.components;if(!c||c.length<=0)continue;const l=new o7;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 d of c){this.context.target=d;const f=ea().writeBuiltinComponentData(d,this.context);f!==null&&h.push(f)}h.length>0&&(l[eu]=h,uc&&console.log("DID WRITE",r,"nodeIndex",a,h))}}beforeRoot(){return uc&&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 s=i[this.name];uc&&console.log("After root",e,this.parser,i);const r=[];if(s===!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 d=h[this.name];if(!d)continue;uc&&console.log("NODE",c);const f=this.nodeToObjectMap[l];if(!f){console.error("Could not find object for node index: "+l,c,t);continue}B_(f),r.push(this.createComponents(f,d))}}}await Promise.all(r)}async createComponents(e,t){if(!t)return;const i=t[eu];if(i){const s=new Array;uc&&console.log(e.name,i);for(const r in i){const o=i[r];uc&&console.log("Serialized data",JSON.parse(JSON.stringify(o))),o&&this.parser&&s.push(E1(this.parser,o).catch(a=>console.error(`Error while resolving references (see console for details)
|
|
4446
|
+
`);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})}),tS>0&&console.warn("THREE.KTX2Loader: Multiple active KTX2 loaders may cause performance issues. Use a single KTX2Loader instance, or call .dispose() on old instances."),tS++}return this.transcoderPending}load(e,t,i,s){if(this.workerConfig===null)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");const r=new Ln(this.manager);r.setResponseType("arraybuffer"),r.setWithCredentials(this.withCredentials),r.load(e,o=>{if(eS.has(o))return eS.get(o).promise.then(t).catch(s);this._createTexture(o).then(a=>t?t(a):null).catch(s)},i,s)}_createTextureFrom(e,t){const{faces:i,width:s,height:r,format:o,type:a,error:c,dfdTransferFn:l,dfdFlags:h}=e;if(a==="error")return Promise.reject(c);let d;if(t.faceCount===6)d=new Gc,d.image=i,d.format=o,d.type=pi;else{const f=i[0].mipmaps;d=t.layerCount>1?new qL(f,s,r,t.layerCount,o,pi):new Gc(f,s,r,o,pi)}return d.minFilter=i[0].mipmaps.length===1?Ft:Mo,d.magFilter=Ft,d.generateMipmaps=!1,d.needsUpdate=!0,d.colorSpace=l===mY?Ze:mr,d.premultiplyAlpha=!!(h&gY),d}async _createTexture(e,t={}){const i=yY(new Uint8Array(e));if(i.vkFormat!==AY){const o=[],a=[];for(let l=0;l<i.levels.length;l++)a.push(xY(i,l).then(function(h){o[l]=h}));await Promise.all(a);const c=o[0];return c.mipmaps=o.map(l=>({data:l.source.data,width:l.source.data.width,height:l.source.data.height,depth:l.source.data.depth})),c}const s=t,r=this.init().then(()=>this.workerPool.postMessage({type:"transcode",buffer:e,taskConfig:s},[e])).then(o=>this._createTextureFrom(o.data,i));return eS.set(e,{promise:r}),r}dispose(){return this.workerPool.dispose(),this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),tS--,this}}Ko.BasisFormat={ETC1S:0,UASTC_4x4:1};Ko.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};Ko.EngineFormat={RGBAFormat:Ei,RGBA_ASTC_4x4_Format:H0,RGBA_BPTC_Format:Lg,RGBA_ETC2_EAC_Format:G0,RGBA_PVRTC_4BPPV1_Format:N0,RGBA_S3TC_DXT5_Format:kg,RGB_ETC1_Format:UM,RGB_ETC2_Format:z0,RGB_PVRTC_4BPPV1_Format:U0,RGB_S3TC_DXT1_Format:Og};Ko.BasisWorker=function(){let n,e,t;const i=_EngineFormat,s=_TranscoderFormat,r=_BasisFormat;self.addEventListener("message",function(g){const A=g.data;switch(A.type){case"init":n=A.config,o(A.transcoderBinary);break;case"transcode":e.then(()=>{try{const{faces:v,buffers:m,width:b,height:y,hasAlpha:_,format:C,dfdTransferFn:M,dfdFlags:I}=a(A.buffer);self.postMessage({type:"transcode",id:A.id,faces:v,width:b,height:y,hasAlpha:_,format:C,dfdTransferFn:M,dfdFlags:I},m)}catch(v){console.error(v),self.postMessage({type:"error",id:A.id,error:v.message})}});break}});function o(g){e=new Promise(A=>{t={wasmBinary:g,onRuntimeInitialized:A},BASIS(t)}).then(()=>{t.initializeBasis(),t.KTX2File===void 0&&console.warn("THREE.KTX2Loader: Please update Basis Universal transcoder.")})}function a(g){const A=new t.KTX2File(new Uint8Array(g));function v(){A.close(),A.delete()}if(!A.isValid())throw v(),new Error("THREE.KTX2Loader: Invalid or unsupported .ktx2 file");const m=A.isUASTC()?r.UASTC_4x4:r.ETC1S,b=A.getWidth(),y=A.getHeight(),_=A.getLayers()||1,C=A.getLevels(),M=A.getFaces(),I=A.getHasAlpha(),R=A.getDFDTransferFunc(),E=A.getDFDFlags(),{transcoderFormat:T,engineFormat:O}=d(m,b,y,I);if(!b||!y||!C)throw v(),new Error("THREE.KTX2Loader: Invalid texture");if(!A.startTranscoding())throw v(),new Error("THREE.KTX2Loader: .startTranscoding failed");const K=[],H=[];for(let V=0;V<M;V++){const Y=[];for(let N=0;N<C;N++){const L=[];let G,ee;for(let j=0;j<_;j++){const ie=A.getImageLevelInfo(N,j,V);V===0&&N===0&&j===0&&(ie.origWidth%4!==0||ie.origHeight%4!==0)&&console.warn("THREE.KTX2Loader: ETC1S and UASTC textures should use multiple-of-four dimensions."),C>1?(G=ie.origWidth,ee=ie.origHeight):(G=ie.width,ee=ie.height);const Ae=new Uint8Array(A.getImageTranscodedSizeInBytes(N,j,0,T));if(!A.transcodeImage(Ae,N,j,V,T,0,-1,-1))throw v(),new Error("THREE.KTX2Loader: .transcodeImage failed.");L.push(Ae)}const $=p(L);Y.push({data:$,width:G,height:ee}),H.push($.buffer)}K.push({mipmaps:Y,width:b,height:y,format:O})}return v(),{faces:K,buffers:H,width:b,height:y,hasAlpha:I,format:O,dfdTransferFn:R,dfdFlags:E}}const c=[{if:"astcSupported",basisFormat:[r.UASTC_4x4],transcoderFormat:[s.ASTC_4x4,s.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:[s.BC7_M5,s.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:[s.BC1,s.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:[s.ETC1,s.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:[s.ETC1],engineFormat:[i.RGB_ETC1_Format],priorityETC1S:2,priorityUASTC:4,needsPowerOfTwo:!1},{if:"pvrtcSupported",basisFormat:[r.ETC1S,r.UASTC_4x4],transcoderFormat:[s.PVRTC1_4_RGB,s.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,A){return g.priorityETC1S-A.priorityETC1S}),h=c.sort(function(g,A){return g.priorityUASTC-A.priorityUASTC});function d(g,A,v,m){let b,y;const _=g===r.ETC1S?l:h;for(let C=0;C<_.length;C++){const M=_[C];if(n[M.if]&&M.basisFormat.includes(g)&&!(m&&M.transcoderFormat.length<2)&&!(M.needsPowerOfTwo&&!(f(A)&&f(v))))return b=M.transcoderFormat[m?1:0],y=M.engineFormat[m?1:0],{transcoderFormat:b,engineFormat:y}}return console.warn("THREE.KTX2Loader: No suitable compressed texture format found. Decoding to RGBA32."),b=s.RGBA32,y=i.RGBAFormat,{transcoderFormat:b,engineFormat:y}}function f(g){return g<=2?!0:(g&g-1)===0&&g!==0}function p(g){if(g.length===1)return g[0];let A=0;for(let b=0;b<g.length;b++){const y=g[b];A+=y.byteLength}const v=new Uint8Array(A);let m=0;for(let b=0;b<g.length;b++){const y=g[b];v.set(y,m),m+=y.byteLength}return v}};const nD={[vN]:Ei,[gN]:Ei,[dN]:Ei,[oT]:Ei,[AN]:su,[pN]:su,[uN]:su,[rT]:su,[mN]:Pc,[fN]:Pc,[sT]:Pc,[hN]:Pc},nS={[vN]:sn,[gN]:wn,[dN]:pi,[oT]:pi,[AN]:sn,[pN]:wn,[uN]:pi,[rT]:pi,[mN]:sn,[fN]:wn,[sT]:pi,[hN]:pi},_Y={[oT]:Ze,[rT]:Ze,[sT]:Ze};async function xY(n,e=0){const{vkFormat:t}=n,i=Math.max(1,n.pixelWidth>>e),s=Math.max(1,n.pixelHeight>>e),r=Math.max(1,n.pixelDepth>>e);if(nD[t]===void 0)throw new Error("THREE.KTX2Loader: Unsupported vkFormat.");const o=n.levels[e];let a,c;if(n.supercompressionScheme===fY)a=o.levelData;else if(n.supercompressionScheme===pY)iS||(iS=new Promise(async h=>{const d=new bY;await d.init(),h(d)})),a=(await iS).decode(o.levelData,o.uncompressedByteLength);else throw new Error("THREE.KTX2Loader: Unsupported supercompressionScheme.");nS[t]===sn?c=new Float32Array(a.buffer,a.byteOffset,a.byteLength/Float32Array.BYTES_PER_ELEMENT):nS[t]===wn?c=new Uint16Array(a.buffer,a.byteOffset,a.byteLength/Uint16Array.BYTES_PER_ELEMENT):c=a;const l=r===0?new Co(c,i,s):new Hb(c,i,s,r);return l.type=nS[t],l.format=nD[t],l.colorSpace=_Y[t]||mr,l.needsUpdate=!0,Promise.resolve(l)}var wY=function(){var n="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 s=WebAssembly.validate(t)?e:n,r,o=WebAssembly.instantiate(a(s),{}).then(function(m){r=m.instance,r.exports.__wasm_call_ctors()});function a(m){for(var b=new Uint8Array(m.length),y=0;y<m.length;++y){var _=m.charCodeAt(y);b[y]=_>96?_-97:_>64?_-39:_+4}for(var C=0,y=0;y<m.length;++y)b[C++]=b[y]<60?i[b[y]]:(b[y]-60)*64+b[++y];return b.buffer.slice(0,C)}function c(m,b,y,_,C,M){var I=r.exports.sbrk,R=y+3&-4,E=I(R*_),T=I(C.length),O=new Uint8Array(r.exports.memory.buffer);O.set(C,T);var K=m(E,y,_,T,C.length);if(K==0&&M&&M(E,R,_),b.set(O.subarray(E,E+y*_)),I(E-I(0)),K!=0)throw new Error("Malformed buffer data: "+K)}var l={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},h={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"},d=[],f=0;function p(m){var b={object:new Worker(m),pending:0,requests:{}};return b.object.onmessage=function(y){var _=y.data;b.pending-=_.count,b.requests[_.id][_.action](_.value),delete b.requests[_.id]},b}function g(m){for(var b="var instance; var ready = WebAssembly.instantiate(new Uint8Array(["+new Uint8Array(a(s))+"]), {}).then(function(result) { instance = result.instance; instance.exports.__wasm_call_ctors(); });self.onmessage = workerProcess;"+c.toString()+v.toString(),y=new Blob([b],{type:"text/javascript"}),_=URL.createObjectURL(y),C=0;C<m;++C)d[C]=p(_);URL.revokeObjectURL(_)}function A(m,b,y,_,C){for(var M=d[0],I=1;I<d.length;++I)d[I].pending<M.pending&&(M=d[I]);return new Promise(function(R,E){var T=new Uint8Array(y),O=f++;M.pending+=m,M.requests[O]={resolve:R,reject:E},M.object.postMessage({id:O,count:m,size:b,source:T,mode:_,filter:C},[T.buffer])})}function v(m){o.then(function(){var b=m.data;try{var y=new Uint8Array(b.count*b.size);c(r.exports[b.mode],y,b.count,b.size,b.source,r.exports[b.filter]),self.postMessage({id:b.id,count:b.count,action:"resolve",value:y},[y.buffer])}catch(_){self.postMessage({id:b.id,count:b.count,action:"reject",value:_})}})}return{ready:o,supported:!0,useWorkers:function(m){g(m)},decodeVertexBuffer:function(m,b,y,_,C){c(r.exports.meshopt_decodeVertexBuffer,m,b,y,_,r.exports[l[C]])},decodeIndexBuffer:function(m,b,y,_){c(r.exports.meshopt_decodeIndexBuffer,m,b,y,_)},decodeIndexSequence:function(m,b,y,_){c(r.exports.meshopt_decodeIndexSequence,m,b,y,_)},decodeGltfBuffer:function(m,b,y,_,C,M){c(r.exports[h[C]],m,b,y,_,r.exports[l[M]])},decodeGltfBufferAsync:function(m,b,y,_,C){return d.length>0?A(m,b,y,h[_],l[C]):o.then(function(){var M=new Uint8Array(m*b);return c(r.exports[h[_]],M,m,b,y,r.exports[l[C]]),M})}}}();const gf=re("debugdecoders"),sD="https://www.gstatic.com/draco/versioned/decoders/1.4.1/",rD="https://www.gstatic.com/basis-universal/versioned/2021-04-15-ba1c3e4/";let Xo,sS,zl;function oD(n){n!==void 0&&typeof n=="string"&&(Xo||(Xo=new nT),gf&&console.log("Setting draco decoder path to",n),Xo.setDecoderPath(n))}function aD(n){n!==void 0&&typeof n=="string"&&(Xo||(Xo=new nT),gf&&console.log("Setting draco decoder type to",n),Xo.setDecoderConfig({type:n}))}function cD(n){n!==void 0&&typeof n=="string"&&(zl||(zl=new Ko),gf&&console.log("Setting ktx2 transcoder path to",n),zl.setTranscoderPath(n))}function EA(n,e){Xo||(Xo=new nT,Xo.setDecoderPath(sD),Xo.setDecoderConfig({type:"js"}),gf&&console.log("Setting draco decoder path to",sD)),zl||(zl=new Ko,zl.setTranscoderPath(rD),gf&&console.log("Setting ktx2 transcoder path to",rD)),sS||(sS=wY,gf&&console.log("Using the default meshopt decoder")),e.renderer?zl.detectSupport(e.renderer):console.warn("No renderer provided to detect ktx2 support - loading KTX2 textures will probably fail"),n.setDRACOLoader(Xo),n.setKTX2Loader(zl),n.setMeshoptDecoder(sS)}function SY(n,e=1e-4){e=Math.max(e,Number.EPSILON);const t={},i=n.getIndex(),s=n.getAttribute("position"),r=i?i.count:s.count;let o=0;const a=Object.keys(n.attributes),c={},l={},h=[],d=["getX","getY","getZ","getW"],f=["setX","setY","setZ","setW"];for(let v=0,m=a.length;v<m;v++){const b=a[v],y=n.attributes[b];c[b]=new rt(new y.array.constructor(y.count*y.itemSize),y.itemSize,y.normalized);const _=n.morphAttributes[b];_&&(l[b]=new rt(new _.array.constructor(_.count*_.itemSize),_.itemSize,_.normalized))}const p=Math.log10(1/e),g=Math.pow(10,p);for(let v=0;v<r;v++){const m=i?i.getX(v):v;let b="";for(let y=0,_=a.length;y<_;y++){const C=a[y],M=n.getAttribute(C),I=M.itemSize;for(let R=0;R<I;R++)b+=`${~~(M[d[R]](m)*g)},`}if(b in t)h.push(t[b]);else{for(let y=0,_=a.length;y<_;y++){const C=a[y],M=n.getAttribute(C),I=n.morphAttributes[C],R=M.itemSize,E=c[C],T=l[C];for(let O=0;O<R;O++){const K=d[O],H=f[O];if(E[H](o,M[K](m)),I)for(let V=0,Y=I.length;V<Y;V++)T[V][H](o,I[V][K](m))}}t[b]=o,h.push(o),o++}}const A=n.clone();for(const v in n.attributes){const m=c[v];if(A.setAttribute(v,new rt(m.array.slice(0,o*m.itemSize),m.itemSize,m.normalized)),v in l)for(let b=0;b<l[v].length;b++){const y=l[v][b];A.morphAttributes[v][b]=new rt(y.array.slice(0,o*y.itemSize),y.itemSize,y.normalized)}}return A.setIndex(h),A}function lD(n,e){if(e===cL)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),n;if(e===V0||e===GM){let t=n.getIndex();if(t===null){const o=[],a=n.getAttribute("position");if(a!==void 0){for(let c=0;c<a.count;c++)o.push(c);n.setIndex(o),t=n.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),n}const i=t.count-2,s=[];if(e===V0)for(let o=1;o<=i;o++)s.push(t.getX(0)),s.push(t.getX(o)),s.push(t.getX(o+1));else for(let o=0;o<i;o++)o%2===0?(s.push(t.getX(o)),s.push(t.getX(o+1)),s.push(t.getX(o+2))):(s.push(t.getX(o+2)),s.push(t.getX(o+1)),s.push(t.getX(o)));s.length/3!==i&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const r=n.clone();return r.setIndex(s),r.clearGroups(),r}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),n}class ep extends fs{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new IY(t)}),this.register(function(t){return new FY(t)}),this.register(function(t){return new UY(t)}),this.register(function(t){return new NY(t)}),this.register(function(t){return new PY(t)}),this.register(function(t){return new BY(t)}),this.register(function(t){return new DY(t)}),this.register(function(t){return new OY(t)}),this.register(function(t){return new TY(t)}),this.register(function(t){return new kY(t)}),this.register(function(t){return new RY(t)}),this.register(function(t){return new LY(t)}),this.register(function(t){return new EY(t)}),this.register(function(t){return new zY(t)}),this.register(function(t){return new GY(t)})}load(e,t,i,s){const r=this;let o;this.resourcePath!==""?o=this.resourcePath:this.path!==""?o=this.path:o=Pf.extractUrlBase(e),this.manager.itemStart(e);const a=function(l){s?s(l):console.error(l),r.manager.itemError(e),r.manager.itemEnd(e)},c=new Ln(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,s){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))===yN){try{o[ei.KHR_BINARY_GLTF]=new HY(e)}catch(d){s&&s(d);return}r=JSON.parse(o[ei.KHR_BINARY_GLTF].content)}else r=JSON.parse(c.decode(e));else r=e;if(r.asset===void 0||r.asset.version[0]<2){s&&s(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const l=new t7(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 d=this.pluginCallbacks[h](l);a[d.name]=d,o[d.name]=!0}if(r.extensionsUsed)for(let h=0;h<r.extensionsUsed.length;++h){const d=r.extensionsUsed[h],f=r.extensionsRequired||[];switch(d){case ei.KHR_MATERIALS_UNLIT:o[d]=new MY;break;case ei.KHR_DRACO_MESH_COMPRESSION:o[d]=new VY(r,this.dracoLoader);break;case ei.KHR_TEXTURE_TRANSFORM:o[d]=new QY;break;case ei.KHR_MESH_QUANTIZATION:o[d]=new WY;break;default:f.indexOf(d)>=0&&a[d]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+d+'".')}}l.setExtensions(o),l.setPlugins(a),l.parse(i,s)}parseAsync(e,t){const i=this;return new Promise(function(s,r){i.parse(e,t,s,r)})}}function CY(){let n={};return{get:function(e){return n[e]},add:function(e,t){n[e]=t},remove:function(e){delete n[e]},removeAll:function(){n={}}}}const ei={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_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"};class EY{constructor(e){this.parser=e,this.name=ei.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let i=0,s=t.length;i<s;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 s=t.cache.get(i);if(s)return s;const r=t.json,c=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e];let l;const h=new _e(16777215);c.color!==void 0&&h.fromArray(c.color);const d=c.range!==void 0?c.range:0;switch(c.type){case"directional":l=new g_(h),l.target.position.set(0,0,-1),l.add(l.target);break;case"point":l=new p_(h),l.distance=d;break;case"spot":l=new f_(h),l.distance=d,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,Ul(l,c),c.intensity!==void 0&&(l.intensity=c.intensity),l.name=t.createUniqueName(c.name||"light_"+e),s=Promise.resolve(l),t.cache.add(i,s),s}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)})}}let MY=class{constructor(){this.name=ei.KHR_MATERIALS_UNLIT}getMaterialType(){return hi}extendParams(e,t,i){const s=[];e.color=new _e(1,1,1),e.opacity=1;const r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const o=r.baseColorFactor;e.color.fromArray(o),e.opacity=o[3]}r.baseColorTexture!==void 0&&s.push(i.assignTexture(e,"map",r.baseColorTexture,Ze))}return Promise.all(s)}},TY=class{constructor(e){this.parser=e,this.name=ei.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=s.extensions[this.name].emissiveStrength;return r!==void 0&&(t.emissiveIntensity=r),Promise.resolve()}},IY=class{constructor(e){this.parser=e,this.name=ei.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:na}extendMaterialParams(e,t){const i=this.parser,s=i.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],o=s.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 te(a,a)}return Promise.all(r)}},RY=class{constructor(e){this.parser=e,this.name=ei.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:na}extendMaterialParams(e,t){const i=this.parser,s=i.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],o=s.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)}},PY=class{constructor(e){this.parser=e,this.name=ei.KHR_MATERIALS_SHEEN}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:na}extendMaterialParams(e,t){const i=this.parser,s=i.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[];t.sheenColor=new _e(0,0,0),t.sheenRoughness=0,t.sheen=1;const o=s.extensions[this.name];return o.sheenColorFactor!==void 0&&t.sheenColor.fromArray(o.sheenColorFactor),o.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=o.sheenRoughnessFactor),o.sheenColorTexture!==void 0&&r.push(i.assignTexture(t,"sheenColorMap",o.sheenColorTexture,Ze)),o.sheenRoughnessTexture!==void 0&&r.push(i.assignTexture(t,"sheenRoughnessMap",o.sheenRoughnessTexture)),Promise.all(r)}},BY=class{constructor(e){this.parser=e,this.name=ei.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:na}extendMaterialParams(e,t){const i=this.parser,s=i.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],o=s.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)}},DY=class{constructor(e){this.parser=e,this.name=ei.KHR_MATERIALS_VOLUME}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:na}extendMaterialParams(e,t){const i=this.parser,s=i.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],o=s.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 _e(a[0],a[1],a[2]),Promise.all(r)}},OY=class{constructor(e){this.parser=e,this.name=ei.KHR_MATERIALS_IOR}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:na}extendMaterialParams(e,t){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=s.extensions[this.name];return t.ior=r.ior!==void 0?r.ior:1.5,Promise.resolve()}},kY=class{constructor(e){this.parser=e,this.name=ei.KHR_MATERIALS_SPECULAR}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:na}extendMaterialParams(e,t){const i=this.parser,s=i.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],o=s.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 _e(a[0],a[1],a[2]),o.specularColorTexture!==void 0&&r.push(i.assignTexture(t,"specularColorMap",o.specularColorTexture,Ze)),Promise.all(r)}},LY=class{constructor(e){this.parser=e,this.name=ei.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:na}extendMaterialParams(e,t){const i=this.parser,s=i.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],o=s.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)}};class FY{constructor(e){this.parser=e,this.name=ei.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,i=t.json,s=i.textures[e];if(!s.extensions||!s.extensions[this.name])return null;const r=s.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)}}class UY{constructor(e){this.parser=e,this.name=ei.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,i=this.parser,s=i.json,r=s.textures[e];if(!r.extensions||!r.extensions[t])return null;const o=r.extensions[t],a=s.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(s.extensionsRequired&&s.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}}class NY{constructor(e){this.parser=e,this.name=ei.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,i=this.parser,s=i.json,r=s.textures[e];if(!r.extensions||!r.extensions[t])return null;const o=r.extensions[t],a=s.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(s.extensionsRequired&&s.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}}class zY{constructor(e){this.name=ei.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 s=i.extensions[this.name],r=this.parser.getDependency("buffer",s.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=s.byteOffset||0,l=s.byteLength||0,h=s.count,d=s.byteStride,f=new Uint8Array(a,c,l);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(h,d,f,s.mode,s.filter).then(function(p){return p.buffer}):o.ready.then(function(){const p=new ArrayBuffer(h*d);return o.decodeGltfBuffer(new Uint8Array(p),h,d,f,s.mode,s.filter),p})})}else return null}}class GY{constructor(e){this.name=ei.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 s=t.meshes[i.mesh];for(const l of s.primitives)if(l.mode!==go.TRIANGLES&&l.mode!==go.TRIANGLE_STRIP&&l.mode!==go.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(),d=h.isGroup?h.children:[h],f=l[0].count,p=[];for(const g of d){const A=new Re,v=new S,m=new Se,b=new S(1,1,1),y=new Kb(g.geometry,g.material,f);for(let _=0;_<f;_++)c.TRANSLATION&&v.fromBufferAttribute(c.TRANSLATION,_),c.ROTATION&&m.fromBufferAttribute(c.ROTATION,_),c.SCALE&&b.fromBufferAttribute(c.SCALE,_),y.setMatrixAt(_,A.compose(v,m,b));for(const _ in c)_!=="TRANSLATION"&&_!=="ROTATION"&&_!=="SCALE"&&g.geometry.setAttribute(_,c[_]);Te.prototype.copy.call(y,g),this.parser.assignFinalMaterial(y),p.push(y)}return h.isGroup?(h.clear(),h.add(...p),h):p[0]}))}}const yN="glTF",Yp=12,hD={JSON:1313821514,BIN:5130562};class HY{constructor(e){this.name=ei.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,Yp),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!==yN)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const s=this.header.length-Yp,r=new DataView(e,Yp);let o=0;for(;o<s;){const a=r.getUint32(o,!0);o+=4;const c=r.getUint32(o,!0);if(o+=4,c===hD.JSON){const l=new Uint8Array(e,Yp+o,a);this.content=i.decode(l)}else if(c===hD.BIN){const l=Yp+o;this.body=e.slice(l,l+a)}o+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class VY{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=ei.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const i=this.json,s=this.dracoLoader,r=e.extensions[this.name].bufferView,o=e.extensions[this.name].attributes,a={},c={},l={};for(const h in o){const d=OE[h]||h.toLowerCase();a[d]=o[h]}for(const h in e.attributes){const d=OE[h]||h.toLowerCase();if(o[h]!==void 0){const f=i.accessors[e.attributes[h]],p=mf[f.componentType];l[d]=p.name,c[d]=f.normalized===!0}}return t.getDependency("bufferView",r).then(function(h){return new Promise(function(d){s.decodeDracoFile(h,function(f){for(const p in f.attributes){const g=f.attributes[p],A=c[p];A!==void 0&&(g.normalized=A)}d(f)},a,l)})})}}class QY{constructor(){this.name=ei.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}}class WY{constructor(){this.name=ei.KHR_MESH_QUANTIZATION}}class bN extends Wf{constructor(e,t,i,s){super(e,t,i,s)}copySampleValue_(e){const t=this.resultBuffer,i=this.sampleValues,s=this.valueSize,r=e*s*3+s;for(let o=0;o!==s;o++)t[o]=i[r+o];return t}interpolate_(e,t,i,s){const r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=a*2,l=a*3,h=s-t,d=(i-t)/h,f=d*d,p=f*d,g=e*l,A=g-l,v=-2*p+3*f,m=p-f,b=1-v,y=m-f+d;for(let _=0;_!==a;_++){const C=o[A+_+a],M=o[A+_+c]*h,I=o[g+_+a],R=o[g+_]*h;r[_]=b*C+y*M+v*I+m*R}return r}}const jY=new Se;class XY extends bN{interpolate_(e,t,i,s){const r=super.interpolate_(e,t,i,s);return jY.fromArray(r).normalize().toArray(r),r}}const go={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},mf={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},uD={9728:Ht,9729:Ft,9984:Mf,9985:aA,9986:du,9987:Mo},dD={33071:Yn,33648:xu,10497:Eo},rS={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},OE={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"},Tl={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},qY={CUBICSPLINE:void 0,LINEAR:Ha,STEP:eh},oS={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function YY(n){return n.DefaultMaterial===void 0&&(n.DefaultMaterial=new $o({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:Rs})),n.DefaultMaterial}function zh(n,e,t){for(const i in t.extensions)n[i]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[i]=t.extensions[i])}function Ul(n,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(n.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function KY(n,e,t){let i=!1,s=!1,r=!1;for(let l=0,h=e.length;l<h;l++){const d=e[l];if(d.POSITION!==void 0&&(i=!0),d.NORMAL!==void 0&&(s=!0),d.COLOR_0!==void 0&&(r=!0),i&&s&&r)break}if(!i&&!s&&!r)return Promise.resolve(n);const o=[],a=[],c=[];for(let l=0,h=e.length;l<h;l++){const d=e[l];if(i){const f=d.POSITION!==void 0?t.getDependency("accessor",d.POSITION):n.attributes.position;o.push(f)}if(s){const f=d.NORMAL!==void 0?t.getDependency("accessor",d.NORMAL):n.attributes.normal;a.push(f)}if(r){const f=d.COLOR_0!==void 0?t.getDependency("accessor",d.COLOR_0):n.attributes.color;c.push(f)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(c)]).then(function(l){const h=l[0],d=l[1],f=l[2];return i&&(n.morphAttributes.position=h),s&&(n.morphAttributes.normal=d),r&&(n.morphAttributes.color=f),n.morphTargetsRelative=!0,n})}function JY(n,e){if(n.updateMorphTargets(),e.weights!==void 0)for(let t=0,i=e.weights.length;t<i;t++)n.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(n.morphTargetInfluences.length===t.length){n.morphTargetDictionary={};for(let i=0,s=t.length;i<s;i++)n.morphTargetDictionary[t[i]]=i}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function ZY(n){let e;const t=n.extensions&&n.extensions[ei.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+aS(t.attributes):e=n.indices+":"+aS(n.attributes)+":"+n.mode,n.targets!==void 0)for(let i=0,s=n.targets.length;i<s;i++)e+=":"+aS(n.targets[i]);return e}function aS(n){let e="";const t=Object.keys(n).sort();for(let i=0,s=t.length;i<s;i++)e+=t[i]+":"+n[t[i]]+";";return e}function kE(n){switch(n){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 $Y(n){return n.search(/\.jpe?g($|\?)/i)>0||n.search(/^data\:image\/jpeg/)===0?"image/jpeg":n.search(/\.webp($|\?)/i)>0||n.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}const e7=new Re;class t7{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new CY,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,s=!1,r=-1;typeof navigator<"u"&&(i=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,s=navigator.userAgent.indexOf("Firefox")>-1,r=s?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||i||s&&r<98?this.textureLoader=new Hc(this.options.manager):this.textureLoader=new A2(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Ln(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,s=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][s.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:s.asset,parser:i,userData:{}};zh(r,a,s),Ul(a,s),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 s=0,r=t.length;s<r;s++){const o=t[s].joints;for(let a=0,c=o.length;a<c;a++)e[o[a]].isBone=!0}for(let s=0,r=e.length;s<r;s++){const o=e[s];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 s=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,s),s.name+="_instance_"+e.uses[t]++,s}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let i=0;i<t.length;i++){const s=e(t[i]);if(s)return s}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const i=[];for(let s=0;s<t.length;s++){const r=e(t[s]);r&&i.push(r)}return i}getDependency(e,t){const i=e+":"+t;let s=this.cache.get(i);if(!s){switch(e){case"scene":s=this.loadScene(t);break;case"node":s=this._invokeOne(function(r){return r.loadNode&&r.loadNode(t)});break;case"mesh":s=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(t)});break;case"accessor":s=this.loadAccessor(t);break;case"bufferView":s=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(t)});break;case"buffer":s=this.loadBuffer(t);break;case"material":s=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(t)});break;case"texture":s=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(t)});break;case"skin":s=this.loadSkin(t);break;case"animation":s=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(t)});break;case"camera":s=this.loadCamera(t);break;default:if(s=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(e,t)}),!s)throw new Error("Unknown type: "+e);break}this.cache.add(i,s)}return s}getDependencies(e){let t=this.cache.get(e);if(!t){const i=this,s=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(s.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[ei.KHR_BINARY_GLTF].body);const s=this.options;return new Promise(function(r,o){i.load(Pf.resolveURL(t.uri,s.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 s=t.byteLength||0,r=t.byteOffset||0;return i.slice(r,r+s)})}loadAccessor(e){const t=this,i=this.json,s=this.json.accessors[e];if(s.bufferView===void 0&&s.sparse===void 0){const o=rS[s.type],a=mf[s.componentType],c=s.normalized===!0,l=new a(s.count*o);return Promise.resolve(new rt(l,o,c))}const r=[];return s.bufferView!==void 0?r.push(this.getDependency("bufferView",s.bufferView)):r.push(null),s.sparse!==void 0&&(r.push(this.getDependency("bufferView",s.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",s.sparse.values.bufferView))),Promise.all(r).then(function(o){const a=o[0],c=rS[s.type],l=mf[s.componentType],h=l.BYTES_PER_ELEMENT,d=h*c,f=s.byteOffset||0,p=s.bufferView!==void 0?i.bufferViews[s.bufferView].byteStride:void 0,g=s.normalized===!0;let A,v;if(p&&p!==d){const m=Math.floor(f/p),b="InterleavedBuffer:"+s.bufferView+":"+s.componentType+":"+m+":"+s.count;let y=t.cache.get(b);y||(A=new l(a,m*p,s.count*p/h),y=new hA(A,p/h),t.cache.add(b,y)),v=new qc(y,c,f%p/h,g)}else a===null?A=new l(s.count*c):A=new l(a,f,s.count*c),v=new rt(A,c,g);if(s.sparse!==void 0){const m=rS.SCALAR,b=mf[s.sparse.indices.componentType],y=s.sparse.indices.byteOffset||0,_=s.sparse.values.byteOffset||0,C=new b(o[1],y,s.sparse.count*m),M=new l(o[2],_,s.sparse.count*c);a!==null&&(v=new rt(v.array.slice(),v.itemSize,v.normalized));for(let I=0,R=C.length;I<R;I++){const E=C[I];if(v.setX(E,M[I*c]),c>=2&&v.setY(E,M[I*c+1]),c>=3&&v.setZ(E,M[I*c+2]),c>=4&&v.setW(E,M[I*c+3]),c>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return v})}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 s=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=uD[f.magFilter]||Ft,h.minFilter=uD[f.minFilter]||Mo,h.wrapS=dD[f.wrapS]||Eo,h.wrapT=dD[f.wrapT]||Eo,h.anisotropy=4,s.associations.set(h,{textures:e}),h}).catch(function(){return null});return this.textureCache[c]=l,l}loadImageSource(e,t){const i=this,s=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(d=>d.clone());const o=s.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(d){l=!0;const f=new Blob([d],{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(d){return new Promise(function(f,p){let g=f;t.isImageBitmapLoader===!0&&(g=function(A){const v=new Ot(A);v.needsUpdate=!0,f(v)}),t.load(Pf.resolveURL(d,r.path),g,void 0,p)})}).then(function(d){return l===!0&&a.revokeObjectURL(c),d.userData.mimeType=o.mimeType||$Y(o.uri),d}).catch(function(d){throw console.error("THREE.GLTFLoader: Couldn't load texture",c),d});return this.sourceCache[e]=h,h}assignTexture(e,t,i,s){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[ei.KHR_TEXTURE_TRANSFORM]){const a=i.extensions!==void 0?i.extensions[ei.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const c=r.associations.get(o);o=r.extensions[ei.KHR_TEXTURE_TRANSFORM].extendTexture(o,a),r.associations.set(o,c)}}return s!==void 0&&(o.colorSpace=s),e[t]=o,o})}assignFinalMaterial(e){const t=e.geometry;let i=e.material;const s=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 Jb,kt.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 gn,kt.prototype.copy.call(c,i),c.color.copy(i.color),c.map=i.map,this.cache.add(a,c)),i=c}if(s||r||o){let a="ClonedMaterial:"+i.uuid+":";s&&(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),s&&(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 $o}loadMaterial(e){const t=this,i=this.json,s=this.extensions,r=i.materials[e];let o;const a={},c=r.extensions||{},l=[];if(c[ei.KHR_MATERIALS_UNLIT]){const d=s[ei.KHR_MATERIALS_UNLIT];o=d.getMaterialType(),l.push(d.extendParams(a,r,t))}else{const d=r.pbrMetallicRoughness||{};if(a.color=new _e(1,1,1),a.opacity=1,Array.isArray(d.baseColorFactor)){const f=d.baseColorFactor;a.color.fromArray(f),a.opacity=f[3]}d.baseColorTexture!==void 0&&l.push(t.assignTexture(a,"map",d.baseColorTexture,Ze)),a.metalness=d.metallicFactor!==void 0?d.metallicFactor:1,a.roughness=d.roughnessFactor!==void 0?d.roughnessFactor:1,d.metallicRoughnessTexture!==void 0&&(l.push(t.assignTexture(a,"metalnessMap",d.metallicRoughnessTexture)),l.push(t.assignTexture(a,"roughnessMap",d.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=Si);const h=r.alphaMode||oS.OPAQUE;if(h===oS.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,h===oS.MASK&&(a.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&o!==hi&&(l.push(t.assignTexture(a,"normalMap",r.normalTexture)),a.normalScale=new te(1,1),r.normalTexture.scale!==void 0)){const d=r.normalTexture.scale;a.normalScale.set(d,d)}return r.occlusionTexture!==void 0&&o!==hi&&(l.push(t.assignTexture(a,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&o!==hi&&(a.emissive=new _e().fromArray(r.emissiveFactor)),r.emissiveTexture!==void 0&&o!==hi&&l.push(t.assignTexture(a,"emissiveMap",r.emissiveTexture,Ze)),Promise.all(l).then(function(){const d=new o(a);return r.name&&(d.name=r.name),Ul(d,r),t.associations.set(d,{materials:e}),r.extensions&&zh(s,d,r),d})}createUniqueName(e){const t=Ut.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,i=this.extensions,s=this.primitiveCache;function r(a){return i[ei.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(c){return fD(c,a,t)})}const o=[];for(let a=0,c=e.length;a<c;a++){const l=e[a],h=ZY(l),d=s[h];if(d)o.push(d.promise);else{let f;l.extensions&&l.extensions[ei.KHR_DRACO_MESH_COMPRESSION]?f=r(l):f=fD(new vt,l,t),s[h]={primitive:l,promise:f},o.push(f)}}return Promise.all(o)}loadMesh(e){const t=this,i=this.json,s=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?YY(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],d=[];for(let p=0,g=h.length;p<g;p++){const A=h[p],v=o[p];let m;const b=l[p];if(v.mode===go.TRIANGLES||v.mode===go.TRIANGLE_STRIP||v.mode===go.TRIANGLE_FAN||v.mode===void 0)m=r.isSkinnedMesh===!0?new Bu(A,b):new ye(A,b),m.isSkinnedMesh===!0&&m.normalizeSkinWeights(),v.mode===go.TRIANGLE_STRIP?m.geometry=lD(m.geometry,GM):v.mode===go.TRIANGLE_FAN&&(m.geometry=lD(m.geometry,V0));else if(v.mode===go.LINES)m=new jr(A,b);else if(v.mode===go.LINE_STRIP)m=new hn(A,b);else if(v.mode===go.LINE_LOOP)m=new e1(A,b);else if(v.mode===go.POINTS)m=new t1(A,b);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+v.mode);Object.keys(m.geometry.morphAttributes).length>0&&JY(m,r),m.name=t.createUniqueName(r.name||"mesh_"+e),Ul(m,r),v.extensions&&zh(s,m,v),t.assignFinalMaterial(m),d.push(m)}for(let p=0,g=d.length;p<g;p++)t.associations.set(d[p],{meshes:e,primitives:p});if(d.length===1)return r.extensions&&zh(s,d[0],r),d[0];const f=new zr;r.extensions&&zh(s,f,r),t.associations.set(f,{meshes:e});for(let p=0,g=d.length;p<g;p++)f.add(d[p]);return f})}loadCamera(e){let t;const i=this.json.cameras[e],s=i[i.type];if(!s){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return i.type==="perspective"?t=new qt(as.radToDeg(s.yfov),s.aspectRatio||1,s.znear||1,s.zfar||2e6):i.type==="orthographic"&&(t=new Ru(-s.xmag,s.xmag,s.ymag,-s.ymag,s.znear,s.zfar)),i.name&&(t.name=this.createUniqueName(i.name)),Ul(t,i),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],i=[];for(let s=0,r=t.joints.length;s<r;s++)i.push(this._loadNodeShallow(t.joints[s]));return t.inverseBindMatrices!==void 0?i.push(this.getDependency("accessor",t.inverseBindMatrices)):i.push(null),Promise.all(i).then(function(s){const r=s.pop(),o=s,a=[],c=[];for(let l=0,h=o.length;l<h;l++){const d=o[l];if(d){a.push(d);const f=new Re;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 Qf(a,c)})}loadAnimation(e){const t=this.json,i=this,s=t.animations[e],r=s.name?s.name:"animation_"+e,o=[],a=[],c=[],l=[],h=[];let d=0,f=s.channels.length;for(d=0,f=s.channels.length;d<f;d++){const p=s.channels[d],g=s.samplers[p.sampler],A=p.target,v=A.node,m=s.parameters!==void 0?s.parameters[g.input]:g.input,b=s.parameters!==void 0?s.parameters[g.output]:g.output;A.node!==void 0&&(o.push(this.getDependency("node",v)),a.push(this.getDependency("accessor",m)),c.push(this.getDependency("accessor",b)),l.push(g),h.push(A))}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],A=p[1],v=p[2],m=p[3],b=p[4],y=[];for(d=0,f=g.length;d<f;d++){const _=g[d],C=A[d],M=v[d],I=m[d],R=b[d];if(_===void 0)continue;_.updateMatrix&&(_.updateMatrix(),_.matrixAutoUpdate=!0);const E=i._createAnimationTracks(_,C,M,I,R);if(E)for(let T=0;T<E.length;T++)y.push(E[T])}return new Ks(r,void 0,y)})}createNodeMesh(e){const t=this.json,i=this,s=t.nodes[e];return s.mesh===void 0?null:i.getDependency("mesh",s.mesh).then(function(r){const o=i._getNodeRef(i.meshCache,s.mesh,r);return s.weights!==void 0&&o.traverse(function(a){if(a.isMesh)for(let c=0,l=s.weights.length;c<l;c++)a.morphTargetInfluences[c]=s.weights[c]}),o})}loadNode(e){const t=this.json,i=this,s=t.nodes[e],r=i._loadNodeShallow(e),o=[],a=s.children||[];for(let l=0,h=a.length;l<h;l++)o.push(i.getDependency("node",a[l]));const c=s.skin===void 0?Promise.resolve(null):i.getDependency("skin",s.skin);return Promise.all([r,Promise.all(o),c]).then(function(l){const h=l[0],d=l[1],f=l[2];f!==null&&h.traverse(function(p){p.isSkinnedMesh&&p.bind(f,e7)});for(let p=0,g=d.length;p<g;p++)h.add(d[p]);return h})}_loadNodeShallow(e){const t=this.json,i=this.extensions,s=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const r=t.nodes[e],o=r.name?s.createUniqueName(r.name):"",a=[],c=s._invokeOne(function(l){return l.createNodeMesh&&l.createNodeMesh(e)});return c&&a.push(c),r.camera!==void 0&&a.push(s.getDependency("camera",r.camera).then(function(l){return s._getNodeRef(s.cameraCache,r.camera,l)})),s._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 uA:l.length>1?h=new zr:l.length===1?h=l[0]:h=new Te,h!==l[0])for(let d=0,f=l.length;d<f;d++)h.add(l[d]);if(r.name&&(h.userData.name=r.name,h.name=o),Ul(h,r),r.extensions&&zh(i,h,r),r.matrix!==void 0){const d=new Re;d.fromArray(r.matrix),h.applyMatrix4(d)}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 s.associations.has(h)||s.associations.set(h,{}),s.associations.get(h).nodes=e,h}),this.nodeCache[e]}loadScene(e){const t=this.extensions,i=this.json.scenes[e],s=this,r=new zr;i.name&&(r.name=s.createUniqueName(i.name)),Ul(r,i),i.extensions&&zh(t,r,i);const o=i.nodes||[],a=[];for(let c=0,l=o.length;c<l;c++)a.push(s.getDependency("node",o[c]));return Promise.all(a).then(function(c){for(let h=0,d=c.length;h<d;h++)r.add(c[h]);const l=h=>{const d=new Map;for(const[f,p]of s.associations)(f instanceof kt||f instanceof Ot)&&d.set(f,p);return h.traverse(f=>{const p=s.associations.get(f);p!=null&&d.set(f,p)}),d};return s.associations=l(r),r})}_createAnimationTracks(e,t,i,s,r){const o=[],a=e.name?e.name:e.uuid,c=[];Tl[r.path]===Tl.weights?e.traverse(function(f){f.morphTargetInfluences&&c.push(f.name?f.name:f.uuid)}):c.push(a);let l;switch(Tl[r.path]){case Tl.weights:l=th;break;case Tl.rotation:l=Va;break;case Tl.position:case Tl.scale:l=Yc;break;default:switch(i.itemSize){case 1:l=th;break;case 2:case 3:default:l=Yc;break}break}const h=s.interpolation!==void 0?qY[s.interpolation]:Ha,d=this._getArrayFromAccessor(i);for(let f=0,p=c.length;f<p;f++){const g=new l(c[f]+"."+Tl[r.path],t.array,d,h);s.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(g),o.push(g)}return o}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const i=kE(t.constructor),s=new Float32Array(t.length);for(let r=0,o=t.length;r<o;r++)s[r]=t[r]*i;t=s}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(i){const s=this instanceof Va?XY:bN;return new s(this.times,this.values,this.getValueSize()/3,i)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function i7(n,e,t){const i=e.attributes,s=new kn;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(s.set(new S(c[0],c[1],c[2]),new S(l[0],l[1],l[2])),a.normalized){const h=kE(mf[a.componentType]);s.min.multiplyScalar(h),s.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 S,c=new S;for(let l=0,h=r.length;l<h;l++){const d=r[l];if(d.POSITION!==void 0){const f=t.json.accessors[d.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 A=kE(mf[f.componentType]);c.multiplyScalar(A)}a.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}s.expandByVector(a)}n.boundingBox=s;const o=new ir;s.getCenter(o.center),o.radius=s.min.distanceTo(s.max)/2,n.boundingSphere=o}function fD(n,e,t){const i=e.attributes,s=[];function r(o,a){return t.getDependency("accessor",o).then(function(c){n.setAttribute(a,c)})}for(const o in i){const a=OE[o]||o.toLowerCase();a in n.attributes||s.push(r(i[o],a))}if(e.indices!==void 0&&!n.index){const o=t.getDependency("accessor",e.indices).then(function(a){n.setIndex(a)});s.push(o)}return Ul(n,e),i7(n,e,t),Promise.all(s).then(function(){return e.targets!==void 0?KY(n,e.targets,t):n})}var _N=(n=>(n[n.INT=5124]="INT",n[n.FLOAT=5126]="FLOAT",n[n.FLOAT_VEC2=35664]="FLOAT_VEC2",n[n.FLOAT_VEC3=35665]="FLOAT_VEC3",n[n.FLOAT_VEC4=35666]="FLOAT_VEC4",n[n.INT_VEC2=35667]="INT_VEC2",n[n.INT_VEC3=35668]="INT_VEC3",n[n.INT_VEC4=35669]="INT_VEC4",n[n.BOOL=35670]="BOOL",n[n.BOOL_VEC2=35671]="BOOL_VEC2",n[n.BOOL_VEC3=35672]="BOOL_VEC3",n[n.BOOL_VEC4=35673]="BOOL_VEC4",n[n.FLOAT_MAT2=35674]="FLOAT_MAT2",n[n.FLOAT_MAT3=35675]="FLOAT_MAT3",n[n.FLOAT_MAT4=35676]="FLOAT_MAT4",n[n.SAMPLER_2D=35678]="SAMPLER_2D",n[n.SAMPLER_3D=35680]="SAMPLER_3D",n[n.SAMPLER_CUBE=35681]="SAMPLER_CUBE",n[n.UNKNOWN=0]="UNKNOWN",n))(_N||{});const wa=re("debugcustomshader"),Id="NEEDLE_techniques_webgl";class n7{constructor(){u(this,"objectToWorldMatrix",new Re);u(this,"worldToObjectMatrix",new Re);u(this,"objectToWorld",new Array);u(this,"worldToObject",new Array)}updateFrom(e){this.objectToWorldMatrix.copy(e.matrixWorld),sb(this.objectToWorldMatrix,this.objectToWorld),this.worldToObjectMatrix.copy(e.matrixWorld).invert(),sb(this.worldToObjectMatrix,this.worldToObject)}}const Fi=class extends h_{constructor(t,...i){super(...i);u(this,"identifier");u(this,"onBeforeRenderSceneCallback",this.onBeforeRenderScene.bind(this));u(this,"_sphericalHarmonicsName","unity_SpecCube0");u(this,"_objToWorldName","hlslcc_mtx4x4unity_ObjectToWorld");u(this,"_worldToObjectName","hlslcc_mtx4x4unity_WorldToObject");u(this,"_viewProjectionName","hlslcc_mtx4x4unity_MatrixVP");u(this,"_viewMatrixName","hlslcc_mtx4x4unity_MatrixV");u(this,"_rendererData",new n7);this.identifier=t,wa&&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.waitForLighting(),(this.depthTextureUniform||this.opaqueTextureUniform)&&Nt.Current.pre_render_callbacks.push(this.onBeforeRenderSceneCallback)}clone(){const t=super.clone();return xN(t),t}dispose(){super.dispose();const t=Nt.Current.pre_render_callbacks.indexOf(this.onBeforeRenderSceneCallback);t>=0&&Nt.Current.pre_render_callbacks.splice(t,1)}async waitForLighting(){const t=Nt.Current;if(!t){console.error("Missing context");return}const i=await t.sceneLighting.internalGetSceneLightingData(this.identifier);if(!i||!i.array){console.warn("Missing lighting data for custom shader, getSceneLightingData did not return anything");return}wa&&console.log(i);const s=i.array,r=i.texture;this.uniforms.unity_SpecCube0={value:r},zU(this.uniforms,s);const o=Math.sqrt(Math.PI*.5);this.uniforms.unity_SpecCube0_HDR={value:new nt(o,o,o,o)},wa&&console.log("Set environment lighting",this.uniforms)}get depthTextureUniform(){if(this.uniforms)return this.uniforms._CameraDepthTexture}get opaqueTextureUniform(){if(this.uniforms)return this.uniforms._CameraOpaqueTexture}onBeforeRenderScene(){this.opaqueTextureUniform&&Nt.Current.setRequireColor(!0),this.depthTextureUniform&&Nt.Current.setRequireDepth(!0)}onBeforeRender(t,i,s,r,o,a){r.attributes.tangent||r.computeTangents(),this.onUpdateUniforms(s,o)}onUpdateUniforms(t,i){const s=Nt.Current;if(t&&(Fi.viewProjection&&this.uniforms[this._viewProjectionName]&&(Fi.viewProjection.copy(t.projectionMatrix).multiply(t.matrixWorldInverse),sb(Fi.viewProjection,Fi._viewProjectionValues)),Fi.viewMatrix&&this.uniforms[this._viewMatrixName]&&(Fi.viewMatrix.copy(t.matrixWorldInverse),sb(Fi.viewMatrix,Fi._viewMatrixValues)),this.uniforms[Fi._worldSpaceCameraPosName]&&Fi._worldSpaceCameraPos.setFromMatrixPosition(t.matrixWorld)),this.uniforms._TimeParameters&&(this.uniforms._TimeParameters.value=s.sceneLighting.timeVec4),this.uniforms._Time){const c=this.uniforms._Time.value;c.x=s.sceneLighting.timeVec4.x/20,c.y=s.sceneLighting.timeVec4.x,c.z=s.sceneLighting.timeVec4.x*2,c.w=s.sceneLighting.timeVec4.x*3}if(this.uniforms._SinTime){const c=this.uniforms._SinTime.value;c.x=Math.sin(s.sceneLighting.timeVec4.x/8),c.y=Math.sin(s.sceneLighting.timeVec4.x/4),c.z=Math.sin(s.sceneLighting.timeVec4.x/2),c.w=Math.sin(s.sceneLighting.timeVec4.x)}if(this.uniforms._CosTime){const c=this.uniforms._CosTime.value;c.x=Math.cos(s.sceneLighting.timeVec4.x/8),c.y=Math.cos(s.sceneLighting.timeVec4.x/4),c.z=Math.cos(s.sceneLighting.timeVec4.x/2),c.w=Math.cos(s.sceneLighting.timeVec4.x)}if(this.uniforms.unity_DeltaTime){const c=this.uniforms.unity_DeltaTime.value;c.x=s.time.deltaTime,c.y=1/s.time.deltaTime,c.z=s.time.smoothedDeltaTime,c.w=1/s.time.smoothedDeltaTime}const r=s.mainLight;if(r){const c=wt(r.gameObject,Fi._mainLightPosition);this.uniforms._MainLightPosition={value:c.normalize()},Fi._mainLightColor.set(r.color.r,r.color.g,r.color.b,0),this.uniforms._MainLightColor={value:Fi._mainLightColor};const l=r.intensity;Fi._lightData.z=l,this.uniforms.unity_LightData={value:Fi._lightData}}if(t&&(Fi.viewProjection&&this.uniforms[this._viewProjectionName]&&(this.uniforms[this._viewProjectionName].value=Fi._viewProjectionValues),Fi.viewMatrix&&this.uniforms[this._viewMatrixName]&&(this.uniforms[this._viewMatrixName].value=Fi._viewMatrixValues),this.uniforms[Fi._worldSpaceCameraPosName]&&(this.uniforms[Fi._worldSpaceCameraPosName]={value:Fi._worldSpaceCameraPos}),s.mainCameraComponent)){if(this.uniforms._ProjectionParams){const c=this.uniforms._ProjectionParams.value;c.x=1,c.y=s.mainCameraComponent.nearClipPlane,c.z=s.mainCameraComponent.farClipPlane,c.w=1/c.z,this.uniforms._ProjectionParams.value=c}if(this.uniforms._ZBufferParams){const c=this.uniforms._ZBufferParams.value,l=s.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=s.domWidth,c.y=s.domHeight,c.z=1+1/c.x,c.w=1+1/c.y,this.uniforms._ScreenParams.value=c}}const o=this.depthTextureUniform;o&&(o.value=s.depthTexture);const a=this.opaqueTextureUniform;if(a&&(a.value=s.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 Ir=Fi;u(Ir,"viewProjection",new Re),u(Ir,"_viewProjectionValues",[]),u(Ir,"viewMatrix",new Re),u(Ir,"_viewMatrixValues",[]),u(Ir,"_worldSpaceCameraPosName","_WorldSpaceCameraPos"),u(Ir,"_worldSpaceCameraPos",new S),u(Ir,"_mainLightColor",new nt),u(Ir,"_mainLightPosition",new S),u(Ir,"_lightData",new nt);class s7{constructor(e,t){u(this,"parser");u(this,"identifier");this.parser=e,this.identifier=t}get name(){return Id}loadMaterial(e){const t=this.parser.json.materials[e];if(!t)return wa&&console.log(e,this.parser.json.materials),null;if(!t.extensions||!t.extensions[Id])return wa&&console.log("material "+e+" does not use NEEDLE_techniques_webgl"),null;const i=t.extensions[Id].technique;if(i<0)return null;const s=this.parser.json.extensions[Id];if(!s)return null;wa&&console.log(s);const r=s.techniques[i];return r?new Promise(async(o,a)=>{var m,b,y;const c=await mq(s,r.program),l=c==null?void 0:c.fragmentShader,h=c==null?void 0:c.vertexShader;if(!l||!h)return a();wa&&console.log("loadMaterial",t,c);const d={},f=r.uniforms;(h.includes("_Time")||l.includes("_Time"))&&(d._Time={value:new nt(0,0,0,0)}),(h.includes("_SinTime")||l.includes("_SinTime"))&&(d._SinTime={value:new nt(0,0,0,0)}),(h.includes("_CosTime")||l.includes("_CosTime"))&&(d._CosTime={value:new nt(0,0,0,0)}),(h.includes("unity_DeltaTime")||l.includes("unity_DeltaTime"))&&(d.unity_DeltaTime={value:new nt(0,0,0,0)});for(const _ in f){const C=_;switch(C){case"_TimeParameters":const M=new nt;d[C]={value:M};break;case"hlslcc_mtx4x4unity_MatrixV":case"hlslcc_mtx4x4unity_MatrixVP":d[C]={value:[]};break;case"_MainLightPosition":case"_MainLightColor":case"_WorldSpaceCameraPos":d[C]={value:[0,0,0,1]};break;case"unity_OrthoParams":break;case"unity_SpecCube0":d[C]={value:null};break;default:case"_ScreenParams":case"_ZBufferParams":case"_ProjectionParams":d[C]={value:[0,0,0,0]};break;case"_CameraOpaqueTexture":case"_CameraDepthTexture":d[C]={value:null};break}}let p=!1;if(t.extensions&&t.extensions[Id]){const _=t.extensions[Id];if(_.technique===i){wa&&console.log(t.name,"Material Properties",_);for(const C in _.values){const M=_.values[C];if(typeof M=="string"){if(M.startsWith("/textures/")){const I=M.substring(10),R=Number.parseInt(I);if(R>=0){const E=await this.parser.getDependency("texture",R);E instanceof Ot&&(E.colorSpace=pn,E.needsUpdate=!0),d[C]={value:E};continue}}switch(C){case"alphaMode":M==="BLEND"&&(p=!0);continue}}if(Array.isArray(M)&&M.length===4){d[C]={value:new nt(M[0],M[1],M[2],M[3])};continue}d[C]={value:M}}}}const g=new Ir(this.identifier,{name:t.name??"",uniforms:d,vertexShader:h,fragmentShader:l,lights:!1});switch(g.glslVersion=Q0,g.vertexShader=g.vertexShader.replace("#version 300 es",""),g.fragmentShader=g.fragmentShader.replace("#version 300 es",""),(m=d._Cull)==null?void 0:m.value){case 0:g.side=Si;break;case 1:g.side=dn;break;case 2:g.side=Rs;break;default:g.side=Rs;break}switch((b=d._ZTest)==null?void 0:b.value){case 3:g.depthTest=!0,g.depthFunc=Cf;break;case 6:g.depthTest=!0,g.depthFunc=rA;break;case 2:g.depthTest=!0,g.depthFunc=gm;break;case 4:g.depthTest=!0,g.depthFunc=Sf;break;case 5:g.depthTest=!0,g.depthFunc=kb;break;case 7:g.depthTest=!0,g.depthFunc=Ob;break;case 8:g.depthTest=!1,g.depthFunc=Db;break}g.transparent=p,p&&(g.depthWrite=!1),zU(d),g.onUpdateUniforms();for(const _ in f){const C=_,M=f[_].type;if(((y=d[C])==null?void 0:y.value)===void 0)switch(M){case _N.SAMPLER_2D:d[C]={value:fq},console.warn("Missing/unassigned texture, fallback to white: "+C);break;default:C==="unity_OrthoParams"||console.warn("TODO: EXPECTED UNIFORM / fallback NOT SET: "+C,f[_]);break}}wa&&console.log(g.uuid,d),xN(g),o(g)}):null}}function xN(n){if(n.uniforms){wa&&console.log("Uniforms:",n.uniforms);for(const t in n.uniforms)switch(e(t,t),t){case"_Color":e("color",t);break}}function e(t,i){Object.getOwnPropertyDescriptor(n,t)||Object.defineProperty(n,t,{get:()=>n.uniforms[i].value,set:s=>{n.uniforms[i].value=s,n.needsUpdate=!0}})}}const uc=Ts,gy="$___Export_Components",r7="NEEDLE_components";var Hce;class o7{constructor(){u(this,Hce)}}Hce=eu;class a7{constructor(e,t,i){u(this,"node");u(this,"nodeIndex");u(this,"nodeDef");this.node=e,this.nodeIndex=t,this.nodeDef=i}}class wN{constructor(){u(this,"parser");u(this,"nodeToObjectMap",{});u(this,"exportContext");u(this,"objectToNodeMap",{});u(this,"context");u(this,"writer")}get name(){return r7}registerExport(e){e.register(t=>{if("serializeUserData"in t){const i=t.serializeUserData.bind(t);this.writer=t,t.serializeUserData=(s,r)=>{try{this.serializeUserData(s,r),i(s,r)}finally{this.afterSerializeUserData(s,r)}}}return this})}beforeParse(){this.exportContext={},this.objectToNodeMap={}}serializeUserData(e,t){var s;const i=(s=e.userData)==null?void 0:s.components;!i||i.length<=0||(delete e.userData.components,e[gy]=i)}afterSerializeUserData(e,t){if(e.type==="Scene"&&uc&&console.log("DONE",JSON.stringify(t)),e[gy]===void 0)return;const i=e[gy];delete e[gy],i!==null&&(e.userData.components=i)}writeNode(e,t){const i=this.writer.json.nodes.length;uc&&console.log(e.name,i,e.uuid);const s=new a7(e,i,t);this.exportContext[i]=s,this.objectToNodeMap[e.uuid]=i}afterParse(e){var t;uc&&console.log("AFTER",e);for(const i in this.exportContext){const s=this.exportContext[i],r=s.node,o=s.nodeDef,a=s.nodeIndex,c=(t=r.userData)==null?void 0:t.components;if(!c||c.length<=0)continue;const l=new o7;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 d of c){this.context.target=d;const f=ea().writeBuiltinComponentData(d,this.context);f!==null&&h.push(f)}h.length>0&&(l[eu]=h,uc&&console.log("DID WRITE",r,"nodeIndex",a,h))}}beforeRoot(){return uc&&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 s=i[this.name];uc&&console.log("After root",e,this.parser,i);const r=[];if(s===!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 d=h[this.name];if(!d)continue;uc&&console.log("NODE",c);const f=this.nodeToObjectMap[l];if(!f){console.error("Could not find object for node index: "+l,c,t);continue}B_(f),r.push(this.createComponents(f,d))}}}await Promise.all(r)}async createComponents(e,t){if(!t)return;const i=t[eu];if(i){const s=new Array;uc&&console.log(e.name,i);for(const r in i){const o=i[r];uc&&console.log("Serialized data",JSON.parse(JSON.stringify(o))),o&&this.parser&&s.push(E1(this.parser,o).catch(a=>console.error(`Error while resolving references (see console for details)
|
|
4429
4447
|
`,a,e,o))),e.userData=e.userData||{},e.userData[eu]=e.userData[eu]||[],e.userData[eu].push(o)}await Promise.all(s).catch(r=>{console.error("Error while loading components",r)})}}}const cS=re("debugexr");class c7{constructor(e){u(this,"parser");this.parser=e,cS&&console.log(e)}get name(){return"EXT_texture_exr"}loadTexture(e){const t=this.name,i=this.parser,r=i.json.textures[e];if(cS&&console.log("EXT_texture_exr.loadTexture",e,r),!r.extensions||!r.extensions[t])return null;const o=r.extensions[t],a=new cb(i.options.manager);return cS&&console.log("EXT_texture_exr.loadTexture",o),i.loadTextureImage(e,o.source,a)}}typeof window<"u"&&window.addEventListener("unhandledrejection",n=>{});const pD="NEEDLE_gameobject_data";class l7{constructor(e){u(this,"parser");this.parser=e}get name(){return pD}afterRoot(e){var i;const t=[];for(let s=0;s<((i=this.parser.json.nodes)==null?void 0:i.length);s++){const r=this.parser.json.nodes[s];if(r&&r.extensions){const o=r.extensions[pD];if(o){const a=this.findAndApplyExtensionData(s,o);t.push(a)}}}return Promise.all(t).then(()=>{})}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 gD="NEEDLE_lighting_settings",Yh=re("debugenvlight");class h7{constructor(e,t,i){u(this,"parser");u(this,"sourceId");u(this,"context");this.parser=e,this.sourceId=t,this.context=i}get name(){return gD}afterRoot(e){const t=this.parser.json.extensions;if(t){const i=t[gD];if(i){Yh&&console.log('Loaded "'+this.name+'", src: "'+this.sourceId+'"',i);let s;if(e.scene.children.length===1){const r=e.scene.children[0];s=se.addNewComponent(r,lb,!1)}else{const r=new Te;r.name="LightSettings "+this.sourceId,e.scene.add(r),s=se.addNewComponent(r,lb,!1)}s.sourceId=this.sourceId,s.ambientIntensity=i.ambientIntensity,s.ambientLight=new _e().fromArray(i.ambientLight),Array.isArray(i.ambientTrilight)&&(s.ambientTrilight=i.ambientTrilight.map(r=>new _e().fromArray(r))),s.ambientMode=i.ambientMode,s.environmentReflectionSource=i.environmentReflectionSource}}return null}}Bi.registerCallback(Qs.ContextCreated,n=>{const e=n.context,t=se.findObjectOfType(lb,e);t!=null&&t.sourceId&&(t.enabled=!0)});class lb extends Me{constructor(){super(...arguments);u(this,"ambientMode",ff.Skybox);u(this,"ambientLight");u(this,"ambientTrilight");u(this,"ambientIntensity",1);u(this,"environmentReflectionSource",rb.Skybox);u(this,"_hasReflection",!1);u(this,"_ambientLightObj");u(this,"_hemisphereLightObj");u(this,"_lightProbeObj")}awake(){var i;if(this.sourceId){const s=this.environmentReflectionSource===rb.Skybox?Hl.Skybox:Hl.Reflection,r=this.context.lightmaps.tryGet(this.sourceId,s,0);this._hasReflection=r!=null,r&&this.context.sceneLighting.internalRegisterReflection(this.sourceId,r)}this.enabled=!1,this.context.sceneLighting.internalRegisterSceneLightSettings(this),Yh&&window.addEventListener("keydown",s=>{if(!this.destroyed)switch(s.key){case"l":this.enabled=!this.enabled;break}});const t=(i=this.gameObject.userData)==null?void 0:i.components;if(t){const s=t.indexOf(this);t.splice(s,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(Yh&&console.warn("💡🟡 >>> Enable lighting",this.sourceId,this.enabled,this),this.ambientMode==ff.Flat){if(this.ambientLight&&!this._ambientLightObj){const t=this.calculateIntensityFactor(this.ambientLight);this._ambientLightObj=new A1(this.ambientLight,this.ambientIntensity*t),Yh&&console.log("Created ambient light",this.sourceId,this._ambientLightObj,this.ambientIntensity,t)}this._ambientLightObj&&this.gameObject.add(this._ambientLightObj),this._lightProbeObj&&this._lightProbeObj.removeFromParent()}else if(this.ambientMode===ff.Trilight){if(this.ambientTrilight){const t=this.ambientTrilight[0],i=this.ambientTrilight[this.ambientTrilight.length-1],s=this.calculateIntensityFactor(i);this._hemisphereLightObj=new g1(i,t,this.ambientIntensity*s),this.gameObject.add(this._hemisphereLightObj),Yh&&console.log("Created hemisphere ambient light",this.sourceId,this._hemisphereLightObj,this.ambientIntensity,s)}}else this._ambientLightObj&&this._ambientLightObj.removeFromParent(),this._hemisphereLightObj&&this._hemisphereLightObj.removeFromParent(),this._lightProbeObj?this.enabled&&this.destroyed&&this._lightProbeObj&&this.gameObject.add(this._lightProbeObj):this.sourceId&&this.context.sceneLighting.internalGetSceneLightingData(this.sourceId).then(t=>{t&&(this._lightProbeObj=t.lightProbe,this.enabled&&!this.destroyed&&this._lightProbeObj&&(Yh&&console.log("Add",this.sourceId,t),this.gameObject.add(this._lightProbeObj)))});this.sourceId&&this.context.sceneLighting.internalEnableReflection(this.sourceId)}onDisable(){Yh&&console.warn("💡⚫ <<< Disable lighting:",this.sourceId,this),this._lightProbeObj&&this._lightProbeObj.removeFromParent(),this._ambientLightObj&&this._ambientLightObj.removeFromParent(),this._hemisphereLightObj&&this._hemisphereLightObj.removeFromParent(),this.sourceId&&this.context.sceneLighting.internalDisableReflection(this.sourceId)}}const lS=re("debugstencil");function u7(n,e){return(n&1<<e.layer)!=0}const d7=Symbol("stencils"),iu=class{constructor(e,t){u(this,"parser");u(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(lS&&console.log(t,iu.stencils),!t)return;const i=iu.stencils[t];if(i)for(let s=i.length-1;s>=0;s--){const r=i[s];if(u7(r.layer,e)){lS&&console.log(r),setTimeout(()=>{$s()&&k_(e.gameObject)&&(nr("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[d7]=!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[p7];if(i){lS&&console.log(i);const s=i.stencil;if(s&&Array.isArray(s))for(const r of s){const o={...r};o.compareFunc=f7(o.compareFunc),o.passOp=hS(o.passOp),o.failOp=hS(o.failOp),o.zFailOp=hS(o.zFailOp),iu.stencils[this.source]||(iu.stencils[this.source]=[]),iu.stencils[this.source].push(o)}}}return null}};let Kg=iu;u(Kg,"stencils",{});function hS(n){switch(n){case 0:return Fg;case 1:return hL;case 2:return uL;case 3:return dL;case 4:return fL;case 6:return pL;case 7:return gL;case 5:return mL}return 0}function f7(n){switch(n){case 1:return GC;case 2:return AL;case 3:return vL;case 4:return yL;case 5:return bL;case 6:return _L;case 7:return xL;case 8:return VM}return GC}const p7="NEEDLE_render_objects",p0="NEEDLE_progressive",Bn=re("debugprogressive"),uS=Symbol("needle-progressive-texture"),LE=new Map;let dS=!1;Bn&&window.addEventListener("keyup",n=>{n.key==="p"&&(LE.forEach((e,t)=>{Object.entries(e).forEach(([i,s])=>{dS?t[i]=s.lod0:t[i]=s.original,t.needsUpdate=!0})}),dS=!dS)});const cm=class{constructor(e,t,i){u(this,"parser");u(this,"sourceId");u(this,"context");this.parser=e,this.sourceId=t,this.context=i}get name(){return p0}static assignTextureLOD(e,t,i,s=0){if(!i)return Promise.resolve(null);const r=[];for(const o of Object.keys(i)){const a=i[o];if(a instanceof Ot){const c=this.assignTextureLODForSlot(e,t,i,s,o,a);r.push(c)}}if(i instanceof h_)for(const o of Object.keys(i.uniforms)){const a=i.uniforms[o].value;if(a instanceof Ot){const c=this.assignTextureLODForSlot(e,t,i,s,o,a);r.push(c)}}return Promise.all(r)}static assignTextureLODForSlot(e,t,i,s,r,o){return(o==null?void 0:o.isTexture)!==!0?Promise.resolve(null):(Bn&&console.log(`-----------
|
|
4430
4448
|
`,"FIND",i.name,r,o==null?void 0:o.name,o==null?void 0:o.userData,o,i),cm.getOrLoadTexture(e,t,i,r,o,s).then(a=>{if((a==null?void 0:a.isTexture)===!0){if(Bn&&console.warn("Assign LOD",i.name,r,a.name,a.guid,i,"Prev:",o,"Now:",a,`
|
|
4431
4449
|
--------------`),i[r]=a,a.needsUpdate=!0,i.needsUpdate=!0,Bn){let c=LE.get(i);c||(c={},LE.set(i,c));let l=c[r];l||(l=c[r]={original:o,lod0:a}),l.lod0=a}return a}return null}))}afterRoot(e){var t;return Bn&&console.log("AFTER",this.sourceId,e),(t=this.parser.json.textures)==null||t.forEach((i,s)=>{if(i!=null&&i.extensions){const r=i==null?void 0:i.extensions[p0];r&&this.parser.getDependency("texture",s).then(a=>{Bn&&console.log("> Progressive: register",a.name,a.uuid,r),a.source&&(a.source[uS]=r),cm.cache.set(a.uuid,r)})}}),null}static async getOrLoadTexture(e,t,i,s,r,o){const a=r.uuid;let c;if(r.source&&r.source[uS]&&(c=r.source[uS]),c||(c=cm.cache.get(a)),c){Bn&&console.log(a,c.uri,c.guid);const l=il(t,c.uri);if(l.endsWith(".glb")||l.endsWith(".gltf")){if(!c.guid)return console.warn("missing pointer for glb/gltf texture",c),null;const h=l+"_"+c.guid;if(this.resolved[h]){let f=this.resolved[h];if(f.image&&f.image.data)return Bn&&console.log("Texture has already been loaded: "+h,i.name,s,r.name,f),f=this.copySettings(r,f),f;f&&Bn&&console.log("Texture has been disposed, will load again: "+h,i.name,s,r.name,f)}const d=this.onProgressiveLoadStart(e,t,l,i,s);try{if(this.currentlyLoading[h]!==void 0){Bn&&console.log("Already loading:",i.name+"."+s,h);let A=await this.currentlyLoading[h];return A&&(A=this.copySettings(r,A)),A}const f=c,p=new Promise(async(A,v)=>{var I;const m=new ep;EA(m,e),Bn&&console.warn("Start loading "+l,i.name,s,f.guid),Bn&&await sA(Math.random()*1e3);const b=await m.loadAsync(l),y=b.parser;Bn&&console.log("Loading finished "+l,i.name,s,f.guid);let _=-1,C=!1;if(!((I=b.parser.json)!=null&&I.textures))return Bn&&console.warn("No textures in glTF "+l+" - may be a bug",i.name,s,f.guid),A(null);for(const R of b.parser.json.textures)if(_++,R!=null&&R.extensions){const E=R==null?void 0:R.extensions[p0];if(E!=null&&E.guid&&E.guid===f.guid){C=!0;break}}if(!C)return A(null);let M=await y.getDependency("texture",_);M=this.copySettings(r,M),M&&(M.guid=f.guid),this.resolved[h]=M,Bn&&console.log(i.name,s,'change "'+r.name+'" → "'+M.name+'"',l,_,M,i,h),A(M)});return this.currentlyLoading[h]=p,await p}finally{delete this.currentlyLoading[h],this.onProgressiveLoadEnd(d)}}else{const h=this.onProgressiveLoadStart(e,t,l,i,s);try{Bn&&console.log("Load texture from uri: "+l);const f=await new Hc().loadAsync(l);return f?(f.guid=c.guid,f.flipY=!1,f.needsUpdate=!0,f.colorSpace=r.colorSpace,Bn&&console.log(c,f)):Bn&&console.warn("failed loading",l),f}finally{this.onProgressiveLoadEnd(h)}}}else Bn&&console.warn("unknown texture",r.name,r.uuid,r);return null}static copySettings(e,t){const i=e.clone(),s=t.source,r=t.mipmaps;return i.copy(e),i.source=s,i.mipmaps=r,i}static beginListenStart(e,t){this._progressiveEventListeners.has(e)||this._progressiveEventListeners.set(e,new mD),this._progressiveEventListeners.get(e).start.push(t)}static stopListenStart(e,t){if(!this._progressiveEventListeners.has(e))return;const i=this._progressiveEventListeners.get(e).start,s=i.indexOf(t);s>=0&&i.splice(s,1)}static beginListenEnd(e,t){this._progressiveEventListeners.has(e)||this._progressiveEventListeners.set(e,new mD),this._progressiveEventListeners.get(e).end.push(t)}static stopListenEnd(e,t){if(!this._progressiveEventListeners.has(e))return;const i=this._progressiveEventListeners.get(e).end,s=i.indexOf(t);s>=0&&i.splice(s,1)}static onProgressiveLoadStart(e,t,i,s,r){this._currentProgressiveLoadingInfo.has(e)||this._currentProgressiveLoadingInfo.set(e,[]);const o=new SN(e,t,i,s,r),a=this._currentProgressiveLoadingInfo.get(e),c=this._progressiveEventListeners.get(e);return c&&c.onStart(o),a.push(o),o}static onProgressiveLoadEnd(e){if(!e)return;const t=e.context;if(!this._currentProgressiveLoadingInfo.has(t))return;const i=this._currentProgressiveLoadingInfo.get(t),s=i.indexOf(e);if(s<0)return;i.splice(s,1);const r=this._progressiveEventListeners.get(t);r&&r.onEnd(e)}};let Or=cm;u(Or,"cache",new Map),u(Or,"resolved",{}),u(Or,"currentlyLoading",{}),u(Or,"_progressiveEventListeners",new Map),u(Or,"_currentProgressiveLoadingInfo",new Map);class SN{constructor(e,t,i,s,r){u(this,"context");u(this,"source");u(this,"uri");u(this,"material");u(this,"slot");this.context=e,this.source=t,this.uri=i,this.material=s,this.slot=r}}class mD{constructor(){u(this,"start",[]);u(this,"end",[])}onStart(e){for(const t of this.start)t(e)}onEnd(e){for(const t of this.end)t(e)}}const g7=re("debugextensions");let hb;const m7=Promise.resolve().then(()=>Gce).then(async n=>(hb=n.GLTFAnimationPointerExtension,hb)).catch(n=>{console.warn("Failed to import GLTFLoaderAnimationPointer. Please use @needle-tools/three for full KHR_animation support",n)}),Om=new Array;function A7(n){Om.includes(n)||(n.name||console.warn("Custom extension has no name",n),Om.push(n))}function v7(n){const e=Om.indexOf(n);e>=0&&Om.splice(e,1)}function aT(n){const e=new wN;return n.register(t=>(e.parser=t,e)),e}class y7{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 CN(n,e,t){const i=t.lastIndexOf("?");i>=0&&(t=t.substring(0,i)),n.register(s=>new l7(s)),n.register(s=>new xj(s)),n.register(s=>new Hq(s,e.lightmaps,t)),n.register(s=>new h7(s,t,e)),n.register(s=>new s7(s,t)),n.register(s=>new Kg(s,t)),n.register(s=>new Or(s,t,e)),n.register(s=>new c7(s)),rU()&&n.register(s=>new Qg(s));for(const s of Om)n.register(r=>new s(r));await m7.catch(s=>{}),n.register(s=>{if(hb){const r=new hb(s);return r.setAnimationPointerResolver.bind(r)(new y7),r}else return(g7||bi())&&console.error("Missing KHR_animation_pointer extension..."),{name:"KHR_animation_pointer_NOT_AVAILABLE"}})}const fS=re("debuglightmaps");class km{constructor(e,t){u(this,"lightmapIndex",-1);u(this,"lightmapScaleOffset",new nt(1,1,0,0));u(this,"context");u(this,"gameObject");u(this,"lightmapTexture",null);u(this,"lightmapScaleOffsetUniform",{value:new nt(1,1,0,0)});u(this,"lightmapUniform",{value:null});u(this,"onBeforeCompile",(e,t)=>{fS&&console.log("Lightmaps, before compile",e),e.lightMapUv="uv1",this.lightmapScaleOffsetUniform.value=this.lightmapScaleOffset,this.lightmapUniform.value=this.lightmapTexture,e.uniforms.lightmapScaleOffset=this.lightmapScaleOffsetUniform});this.gameObject=e,this.context=t}get lightmap(){return this.lightmapTexture}set lightmap(e){e!==this.lightmapTexture&&(this.lightmapTexture=e,this.applyLightmap())}init(e,t,i){console.assert(this.gameObject!==void 0&&this.gameObject!==null,"Missing gameobject",this),this.lightmapIndex=e,!(this.lightmapIndex<0)&&(this.lightmapScaleOffset=t,this.lightmapTexture=i,fS&&this.setLightmapDebugMaterial(),this.applyLightmap())}updateLightmapUniforms(e){const t=e.uniforms;t&&t.lightmap&&(this.lightmapScaleOffsetUniform.value=this.lightmapScaleOffset,t.lightmapScaleOffset=this.lightmapScaleOffsetUniform)}applyLightmap(){if(this.gameObject.type==="Object3D"){fS&&console.warn("Can not add lightmap. Is this object missing a renderer?",this.gameObject.name);return}if(this.gameObject.type==="Group"){console.warn("Lightmap on multimaterial object is not supported yet... please open a feature request on https://github.com/needle-tools/needle-engine-support if your project requires it");return}console.assert(this.gameObject.type==="Mesh","Lightmap only works on meshes",this);const e=this.gameObject;if(e.geometry.getAttribute("uv1")||e.geometry.setAttribute("uv1",e.geometry.getAttribute("uv")),Array.isArray(this.gameObject.material)){const t=this.gameObject.material;for(let i=0;i<t.length;i++){const r=t[i].clone();t[i]=r,r.onBeforeCompile=this.onBeforeCompile}}else{const t=this.gameObject.material.clone();this.gameObject.material=t,this.gameObject.material.onBeforeCompile=this.onBeforeCompile}if(this.lightmapIndex>=0&&this.lightmapTexture){const t=this.gameObject.material;t&&(t.lightMap=this.lightmapTexture,t.needsUpdate=!0)}}setLightmapDebugMaterial(){this.gameObject.material=new Lt({vertexShader:`
|
|
@@ -5051,7 +5069,7 @@ void main() {
|
|
|
5051
5069
|
justify-content: center;
|
|
5052
5070
|
align-items: flex-start;
|
|
5053
5071
|
gap: 10px;
|
|
5054
|
-
`,this.context.appendHTMLElement(i);const s=ES;ES&&console.log("ARSupported?",wg,"VRSupported?",Sg),(s||this.createARButton&&this.enableAR&&wg)&&(e=Dn.createARButton(this),this._arButton=e,i.appendChild(e)),(s||this.createVRButton&&this.enableVR&&Sg)&&(t=Dn.createVRButton(this),this._vrButton=t,i.appendChild(t)),setTimeout(()=>{Dn.resetButtonStyles(t),Dn.resetButtonStyles(e)},1e3)}get TransformOrientation(){return this._transformOrientation}get HeadPose(){return this._currentHeadPose}onBeforeRender(e){var i;if(!e)return;const t=this.context.renderer.xr.getSession();if(t){const s=e.getViewerPose(this.context.renderer.xr.getReferenceSpace());if(!s)return;this._currentHeadPose=s;const r=s==null?void 0:s.transform;r&&this._transformOrientation.set(r.orientation.x,r.orientation.y,r.orientation.z,r.orientation.w),Dn._isInXr===!1&&t&&this.onEnterXR(t,e);for(const o of this.controllers)o.onUpdate(t);this._isInAR&&((i=this.webAR)==null||i.onUpdate(t,e))}Dn.events.dispatchEvent({type:"xrUpdate",frame:e,xr:this.context.renderer.xr,rig:this.rig})}onClickedARButton(){this._isInAR||(this._requestedAR=!0,this._requestedVR=!1,this.captureStateBeforeXR())}onClickedVRButton(){if(!this._isInVR){if(this._requestedVR){this.onExitXR(null);return}this._requestedAR=!1,this._requestedVR=!0,this.captureStateBeforeXR(),this.ensureRig();for(let e=0;e<2;e++)en.Create(this,e,this.gameObject,Af.PhysicalDevice);Dn.events.dispatchEvent({type:"requestVRSession"})}}captureStateBeforeXR(){this.context.mainCamera&&(this._originalCameraPosition.copy(wt(this.context.mainCamera)),this._originalCameraRotation.copy(Fn(this.context.mainCamera)),this._originalCameraParent=this.context.mainCamera.parent),this.Rig&&(this._originalXRRigParent=this.Rig.parent,this._originalXRRigPosition.copy(this.Rig.position),this._originalXRRigRotation.copy(this.Rig.quaternion))}ensureRig(){if(!this.rig){const e=se.findObjectOfType(rx,this.context);e?(this.rig=e.gameObject,this.rig.rotateY(Math.PI)):(this.rig=new zr,this.rig.rotateY(Math.PI),this.rig.name="XRRig",this.context.scene.add(this.rig))}}onEnterXR(e,t){var o,a;console.log("[XR] session begin",e,t),Dn._isInXr=!0,this.ensureRig();const i=this.context.renderer.xr.getReferenceSpace();if(i&&this.rig){const c=t.getViewerPose(i),l=c==null?void 0:c.transform.orientation;if(l){const h=new Se(l.x,l.y,l.z,l.w),d=new Sn().setFromQuaternion(h);this.rig.rotateY(d.y)}}const s=this.context.renderer.xr;if(this.context.mainCamera){const c=s.getCamera();ES&&console.log("WebXRCamera",c);const l=(o=this.context.mainCameraComponent)==null?void 0:o.cullingMask;if(c&&l!==void 0){for(const h of c.cameras)h.layers.mask=l;c.layers.mask=l}else if(c){for(const h of c.cameras)h.layers.enableAll();c.layers.enableAll()}this.rig.add(this.context.mainCamera),this._requestedAR&&this.context.scene.add(this.rig)}const r=this._requestedAR?un.AR:un.VR;switch(Xs.Global.Set(r),r){case un.AR:this.context.xrSessionMode=Dm.ImmersiveAR,this._isInAR=!0,(a=this.webAR)==null||a.onBegin(e);break;case un.VR:this.context.xrSessionMode=Dm.ImmersiveVR,this._isInVR=!0,this.onEnterVR(e);break}e.addEventListener("end",()=>{console.log("[XR] session end"),Dn._isInXr=!1,this.onExitXR(e)}),this.onEnterXR_HandleMirrorWindow(e),Dn.events.dispatchEvent({type:"xrStarted",session:e})}onExitXR(e){var i,s,r,o;const t=this._isInAR;e&&(this._isInAR?(i=this.webAR)==null||i.onEnd(e):(s=this.context.mainCameraComponent)==null||s.applyClearFlagsIfIsActiveCamera()),this._isInAR=!1,this._isInVR=!1,this._requestedAR=!1,this._requestedVR=!1,this.context.xrSessionMode=void 0,this.xrMirrorWindow&&(this.xrMirrorWindow.close(),this.xrMirrorWindow=null),this.destroyControllers(),this.context.mainCamera&&((r=this._originalCameraParent)==null||r.add(this.context.mainCamera),fn(this.context.mainCamera,this._originalCameraPosition),_r(this.context.mainCamera,this._originalCameraRotation),this.context.mainCamera.scale.set(1,1,1)),t&&((o=this._originalXRRigParent)==null||o.add(this.rig),this.rig.position.copy(this._originalXRRigPosition),this.rig.quaternion.copy(this._originalXRRigRotation)),Xs.Global.Set(un.Browser|un.ThirdPerson),Dn.events.dispatchEvent({type:"xrStopped",session:e})}onEnterVR(e){}destroyControllers(){var e;for(let t=this.controllers.length-1;t>=0;t-=1)(e=this.controllers[t])==null||e.destroy();this.controllers.length=0}onEnterXR_HandleMirrorWindow(e){re("mirror")&&setTimeout(()=>{if(!Dn.IsInWebXR)return;const t=new URL(window.location.href);fm(t.searchParams,ub,1),fm(t.searchParams,"isMirror",1);const i=t.toString();this.xrMirrorWindow=window.open(i,"webxr sync","popup=yes"),this.xrMirrorWindow&&(this.xrMirrorWindow.onload=()=>{this.xrMirrorWindow&&(this.xrMirrorWindow.onbeforeunload=()=>{Dn.IsInWebXR&&e.end()})})},1e3)}},u(zd,"_isInXr",!1),u(zd,"events",new Gn),u(zd,"_optionalFeatures_VR",["local-floor","bounded-floor","hand-tracking","high-fixed-foveation-level","layers"]),u(zd,"_optionalFeatures_AR",["anchors","local-floor","hand-tracking","layers"]),zd);let Et=Dn;cp([x()],Et.prototype,"enableVR",2);cp([x()],Et.prototype,"enableAR",2);cp([x(Un)],Et.prototype,"defaultAvatar",2);cp([x()],Et.prototype,"handModelPath",2);cp([x()],Et.prototype,"createVRButton",2);cp([x()],Et.prototype,"createARButton",2);const of=class{constructor(e){u(this,"_webxr");u(this,"reticle",null);u(this,"reticleParent",null);u(this,"hitTestSource",null);u(this,"reticleActive",!0);u(this,"previousBackground",null);u(this,"previousEnvironment",null);u(this,"sessionRoot",null);u(this,"_previousParent",null);u(this,"arDomOverlay",null);u(this,"arOverlayElement",null);u(this,"noHitTestAvailable",!1);u(this,"didPlaceARSessionRoot",!1);this._webxr=e}get webxr(){return this._webxr}get context(){return this.webxr.context}getAROverlayContainer(){this.arDomOverlay=this.webxr.context.domElement;const e=this.arDomOverlay;return e.getAROverlayContainer?this.arOverlayElement=e.getAROverlayContainer():this.arOverlayElement=this.arDomOverlay,this.arOverlayElement}setReticleActive(e){this.reticleActive=e}async onBegin(e){var o,a,c,l;const t=this.webxr.context;this.reticleActive=!0,this.didPlaceARSessionRoot=!1,this.getAROverlayContainer();const i=(o=navigator.userAgent)!=null&&o.includes("OculusBrowser")?Af.PhysicalDevice:Af.Touch,s=i===Af.Touch?4:2;for(let h=0;h<s;h++)en.Create(this.webxr,h,this.webxr.gameObject,i);if((!this.sessionRoot||this.sessionRoot.destroyed||!this.sessionRoot.activeAndEnabled)&&(this.sessionRoot=se.findObjectOfType(Wa,t)),!this.sessionRoot){const h=this.webxr.gameObject;this.sessionRoot=se.addNewComponent(h,Wa),console.warn("WebAR: No ARSessionRoot found, creating one automatically on the WebXR object")}this.previousBackground=t.scene.background,this.previousEnvironment=t.scene.environment,t.scene.background=null,e.requestReferenceSpace("viewer").then(h=>{var d,f;(f=(d=e.requestHitTestSource)==null?void 0:d.call(e,{space:h}))==null||f.then(p=>{this.hitTestSource=p}).catch(p=>{this.noHitTestAvailable=!0,console.warn("WebXR: Hit test not supported",p)})}),!this.reticle&&this.sessionRoot&&(this.reticle=new ye(new pA(.07,.09,32).rotateX(-Math.PI/2),new hi),this.reticle.name="AR Placement reticle",this.reticle.matrixAutoUpdate=!1,this.reticle.visible=!1,this.reticleParent=new Te,this.reticleParent.name="AR Reticle Parent",this.reticleParent.matrixAutoUpdate=!1,this.reticleParent.add(this.reticle),this.webxr.scene?(this.context.scene.add(this.reticleParent),this.context.scene.visible=!0):console.warn("Could not found WebXR Rig")),this._previousParent=this.webxr.gameObject,of.tempWebXRObject||(of.tempWebXRObject=new Te),this.context.scene.add(of.tempWebXRObject),se.addComponent(of.tempWebXRObject,this.webxr),this.sessionRoot?(this.sessionRoot.webAR=this,(a=this.sessionRoot)==null||a.onBegin(e)):console.warn("No WebARSessionRoot found in scene");const r=this.context.domElement;(c=r==null?void 0:r.onEnterAR)==null||c.call(r,e,this.arOverlayElement),(l=this.context.mainCameraComponent)==null||l.applyClearFlagsIfIsActiveCamera()}onEnd(e){var s,r;this._previousParent&&(se.addComponent(this._previousParent,this.webxr),this._previousParent=null),this.hitTestSource=null;const t=this.webxr.context;t.scene.background=this.previousBackground,t.scene.environment=this.previousEnvironment,this.sessionRoot&&this.sessionRoot.onEnd(this.webxr.Rig,e);const i=this.context.domElement;(s=i.onExitAR)==null||s.call(i,e),(r=this.context.mainCameraComponent)==null||r.applyClearFlagsIfIsActiveCamera()}onUpdate(e,t){var s,r;if(this.noHitTestAvailable===!0){if(this.reticle&&(this.reticle.visible=!1),!this.didPlaceARSessionRoot){this.didPlaceARSessionRoot=!0;const o=this.webxr.Rig,a=Ete.clone();(s=this.sessionRoot)==null||s.placeAt(o,a)}return}if(!this.hitTestSource)return;const i=t.getHitTestResults(this.hitTestSource);if(i.length){const o=i[0],a=this.webxr.context.renderer.xr.getReferenceSpace();if(a){const c=o.getPose(a);if(this.sessionRoot){const l=this.sessionRoot.onUpdate(this.webxr.Rig,e,c);this.didPlaceARSessionRoot=l}if(this.reticle&&(this.reticle.visible=this.reticleActive,this.reticleActive&&c)){const l=c.transform.matrix;this.reticle.matrix.fromArray(l),this.webxr.Rig&&this.reticle.matrix.premultiply(this.webxr.Rig.matrix)}}}else(r=this.sessionRoot)==null||r.onUpdate(this.webxr.Rig,e,null),this.reticle&&(this.reticle.visible=!1)}};let vu=of;u(vu,"tempWebXRObject");const Ete=new Re().identity().makeTranslation(0,0,0);class Fc{constructor(e,t){u(this,"used",!1);u(this,"positionDelta",new te);u(this,"inputSource");u(this,"object");u(this,"pointerId");u(this,"isDown");u(this,"isUp");u(this,"isPressed");u(this,"isClicked");u(this,"input");u(this,"event");this.event=t,this.input=e}use(){this.used=!0,this.pointerId!==void 0&&this.input.setPointerUsed(this.pointerId)}stopPropagation(){var e;(e=this.event)==null||e.stopImmediatePropagation()}Use(){this.use()}StopPropagation(){var e;(e=this.event)==null||e.stopImmediatePropagation()}clone(){const e=new Fc(this.input,this.event);return Object.assign(e,this),e}}class lp extends Me{awake(){qs.createIfNoneExists(this.context)}onEnable(){var e;(e=qs.get(this.context))==null||e.register(this)}onDisable(){var e;(e=qs.get(this.context))==null||e.unregister(this)}performRaycast(e=null){return null}}class el extends lp{constructor(){super(...arguments);u(this,"targets",null);u(this,"raycastHits",[])}start(){this.targets=[this.gameObject]}performRaycast(t=null){return this.targets?(t??(t=new sa),t.targets=this.targets,t.results=this.raycastHits,this.context.physics.raycast(t)):null}}class qT extends el{}const Cg=re("debugeventsystem");var YE=(n=>(n.BeforeHandleInput="BeforeHandleInput",n.AfterHandleInput="AfterHandleInput",n))(YE||{});const ba=class extends Me{constructor(){super();u(this,"raycaster",[]);u(this,"_selectStartFn");u(this,"_selectEndFn");u(this,"_selectUpdateFn");u(this,"_handleEventFn");u(this,"lastPointerEvent",null);u(this,"objectsHoveredThisFrame",[]);u(this,"objectsHoveredLastFrame",[]);u(this,"raisedPointerDownEvents",[]);u(this,"raisedPointerDownObjects",[]);u(this,"_didMove",!1);u(this,"_tempComponentsArray",[]);u(this,"_sortedHits",[]);u(this,"_sortingBuffer",[]);u(this,"_noDepthTestingResults",[]);u(this,"handleEventsArray",[]);u(this,"out",{});u(this,"currentActiveMeshUIComponents",[]);ba.systems.push(this)}static createIfNoneExists(t){this.didSearchEventSystem||(this.didSearchEventSystem=!0,ba.systems.length<=0&&ba.systems.push(...se.findObjectsOfType(ba,t)));for(const s of ba.systems)if(s.context===t)return;const i=new Te;se.addNewComponent(i,ba),t.scene.add(i)}static get systems(){const t=Nt.Current;return this._eventSystemMap.has(t)||this._eventSystemMap.set(t,[]),this._eventSystemMap.get(t)}static get(t){const i=this._eventSystemMap.get(t);return i&&i.length>0?i[0]:null}static get instance(){return this.systems[0]}static ensureUpdateMeshUI(t,i){xc.update(t,i)}static markUIDirty(t){xc.markDirty()}get hasActiveUI(){return this.currentActiveMeshUIComponents.length>0}get isHoveringObjects(){return this.objectsHoveredThisFrame.length>0}onDestroy(){ba.systems.splice(ba.systems.indexOf(this),1)}start(){if(this.raycaster.length<=0&&!se.findObjectOfType(lp,this.context)){const i=se.addNewComponent(this.context.scene,el);this.raycaster.push(i),bi()&&console.warn("Added an ObjectRaycaster to the scene because no raycaster was found",this)}}register(t){var i;t&&this.raycaster&&!this.raycaster.includes(t)&&((i=this.raycaster)==null||i.push(t))}unregister(t){var s,r;const i=(s=this.raycaster)==null?void 0:s.indexOf(t);i!==void 0&&i!==-1&&((r=this.raycaster)==null||r.splice(i,1))}onEnable(){const t=new Map;this._selectStartFn??(this._selectStartFn=(s,r)=>{if(!r.grab)return;xc.resetLastSelected();const o=new Fc(this.context.input);o.inputSource=s,o.pointerId=0,o.isDown=s.selectionDown,o.isUp=s.selectionUp,o.isPressed=s.selectionPressed,o.isClicked=!1,t.set(s,r.grab),r.grab&&!this.handleEvents(r.grab,o)&&(r.grab=null)}),this._selectEndFn??(this._selectEndFn=(s,r)=>{var c;if(!r.grab)return;const o=new Fc(this.context.input);o.inputSource=s,o.pointerId=0,o.isDown=s.selectionDown,o.isUp=s.selectionUp,o.isPressed=s.selectionPressed,o.isClicked=s.selectionClick,this.handleEvents(r.grab,o);const a=t.get(s);if(t.set(s,null),a)for(let l=0;l<this.raisedPointerDownEvents.length;l++){const h=this.raisedPointerDownEvents[l];this.raisedPointerDownObjects[l]===a&&h&&((c=h.onPointerUp)==null||c.call(h,o),this.raisedPointerDownEvents.splice(l,1),this.raisedPointerDownObjects.splice(l,1),l--)}});const i=new sa;this._selectUpdateFn??(this._selectUpdateFn=s=>{i.ray=s.getRay();const r=this.performRaycast(i);if(!r)return;const o=new Fc(this.context.input);o.inputSource=s,this.handleIntersections(r,o)}),en.addEventListener(_c.SelectStart,this._selectStartFn),en.addEventListener(_c.SelectEnd,this._selectEndFn),en.addEventListener(_c.Update,this._selectUpdateFn),this._handleEventFn??(this._handleEventFn=this.onHandleEvents.bind(this)),this.context.pre_update_callbacks.push(this._handleEventFn)}onDisable(){en.removeEventListener(_c.SelectStart,this._selectStartFn),en.removeEventListener(_c.SelectEnd,this._selectEndFn),en.removeEventListener(_c.Update,this._selectUpdateFn),this.context.pre_update_callbacks.splice(this.context.pre_update_callbacks.indexOf(this._handleEventFn),1)}onHandleEvents(){if(this.objectsHoveredThisFrame.length=0,this.resetMeshUIStates(),Et.IsInWebXR||this.context.input.isKeyPressed("AltLeft")||this.context.input.isKeyPressed("AltRight"))return;if(!this._didMove){const c=this.context.input.getPointerPositionRC(0);if(c&&c.x===0&&c.y===0)return;this._didMove=!0}let t=0;for(const c of this.context.input.foreachPointerId()){const l=this.context.input.getPointerDown(c),h=this.context.input.getPointerUp(c);if(l||h){t=c;break}}const i=this.context.input.getPointerEvent(t),s=new Fc(this.context.input,i);s.inputSource=this.context.input,s.pointerId=t,s.isClicked=this.context.input.getPointerClicked(t),s.isDown=this.context.input.getPointerDown(t),s.isUp=this.context.input.getPointerUp(t),s.isPressed=this.context.input.getPointerPressed(t);const r=this.context.input.getPointerPositionDelta(t);if(r&&s.positionDelta.copy(r),Cg&&s.isClicked&&console.log("CLICK",t),!s.isDown&&!s.isUp&&!s.isClicked&&!s.isPressed&&!s.positionDelta.x&&!s.positionDelta.y){this.objectsHoveredThisFrame.length=0,this.objectsHoveredThisFrame.push(...this.objectsHoveredLastFrame);return}const o=this.performRaycast(null);if(!o)return;this.lastPointerEvent=s;const a={sender:this,args:s,hasActiveUI:this.currentActiveMeshUIComponents.length>0};Cg&&s.isClicked&&_n("EventSystem: "+s.pointerId+" - "+this.context.time.frame+" - Up:"+s.isUp+", Down:"+s.isDown),this.dispatchEvent(new CustomEvent("BeforeHandleInput",{detail:a})),this.handleIntersections(o,s),this.dispatchEvent(new CustomEvent("AfterHandleInput",{detail:a}))}onBeforeRender(){if(this.lastPointerEvent)this.lastPointerEvent.used=!1;else return;if(this.lastPointerEvent.isUp){for(const i of this.raisedPointerDownEvents)i.onPointerUp&&i.onPointerUp(this.lastPointerEvent);this.raisedPointerDownEvents.length=0,this.raisedPointerDownObjects.length=0}for(const i of this.objectsHoveredLastFrame)if(this.objectsHoveredThisFrame.indexOf(i)<0){this._tempComponentsArray.length=0;const s=se.getComponentsInParent(i,Me,this._tempComponentsArray);this.lastPointerEvent.object=i;for(let r=0;r<s.length;r++){const o=s[r];if(!o.gameObject||o.destroyed)continue;const a=o;a.onPointerExit&&a.onPointerExit(this.lastPointerEvent)}}const t=this.objectsHoveredLastFrame;this.objectsHoveredLastFrame=this.objectsHoveredThisFrame,this.objectsHoveredThisFrame=t}performRaycast(t){if(!this.raycaster)return null;this._sortedHits.length=0;for(const i of this.raycaster){if(!i.activeAndEnabled)continue;const s=i.performRaycast(t);s&&s.length>0&&this._sortedHits.push(...s)}return this._sortedHits.sort((i,s)=>i.distance-s.distance),this._sortedHits}handleIntersections(t,i){if(!t||t.length<=0)return!1;t=this.sortCandidates(t);for(const s of t){const{object:r}=s;if(this.handleEvents(r,i))return!0}return!1}sortCandidates(t){this._sortingBuffer.length=0,this._noDepthTestingResults.length=0;for(let i=0;i<t.length;i++){const s=t[i],r=s.object;if(r.material&&r.material.depthTest===!1){this._noDepthTestingResults.push(s);continue}this._sortingBuffer.push(s)}for(const i of this._sortingBuffer)this._noDepthTestingResults.push(i);return this._noDepthTestingResults}handleEvents(t,i){if(!this.testIsVisible(t))return i.isClicked&&Cg&&console.log("not allowed",t),!1;const s=t;i.object=t,this.lastPointerEvent=i;const r=t.parent;let o=!1;const a=i.isClicked??!1;let c=null;if(r&&r.isUI){const l=(i.isPressed||i.isClicked)??!1;if(r[Ma]){const h=r[Ma].gameObject;if(h){if(!Nf.isInteractable(h,this.out))return!1;c=this.out.canvasGroup??null,this.handleMeshUIIntersection(t,l),t=h,o=!0}}if(!o&&this.handleMeshUiObjectWithoutShadowDom(r,l))return!0}if(a&&Cg&&console.log(this.context.time.frame,t),this.objectsHoveredThisFrame.push(t),c===null||c.interactable){const l=this.objectsHoveredLastFrame.indexOf(t)>=0;this.handleEventsArray.length=0;const h=se.getComponentsInParent(t,Me,this.handleEventsArray);for(let d=0;d<h.length;d++){if(i.used)return!0;if(h[d].destroyed)continue;const f=h[d];if(f.interactable!==!1){if(f.onPointerEnter&&(l||f.onPointerEnter(i)),f.onPointerMove&&i.positionDelta.x!==0&&i.positionDelta.y!==0&&f.onPointerMove(i),i.isDown&&f.onPointerDown&&!this.raisedPointerDownEvents.includes(f)&&(f.onPointerDown(i),this.raisedPointerDownEvents.push(f),this.raisedPointerDownObjects.push(s)),i.isUp&&f.onPointerUp){const p=this.raisedPointerDownEvents.indexOf(f);p!==-1&&this.raisedPointerDownEvents.splice(p,1),f.onPointerUp(i)}i.isClicked&&f.onPointerClick&&f.onPointerClick(i)}}}return!0}handleMeshUiObjectWithoutShadowDom(t,i){return!t||!t.isUI?!0:this.handleMeshUIIntersection(t,i)}handleMeshUIIntersection(t,i){const s=xc.updateState(t,i);return s&&this.currentActiveMeshUIComponents.push(s),s!==null}resetMeshUIStates(){if(this.context.input.getPointerPressedCount()>0&&xc.resetLastSelected(),!(!this.currentActiveMeshUIComponents||this.currentActiveMeshUIComponents.length<=0)){for(let t=0;t<this.currentActiveMeshUIComponents.length;t++){const i=this.currentActiveMeshUIComponents[t];xc.resetState(i)}this.currentActiveMeshUIComponents.length=0}}testIsVisible(t){return t?se.isActiveSelf(t)?this.testIsVisible(t.parent):!1:!0}};let qs=ba;u(qs,"_eventSystemMap",new Map),u(qs,"didSearchEventSystem",!1);class xc{static markDirty(){this.needsUpdate=!0}static update(e,t){const i=t.time.frameCount;for(const s of this.lastUpdateFrame)if(s.context===t){if(i===s.frame)return;s.frame=i;let r=this.needsUpdate||i<1;s.nextUpdate===t.time.frameCount&&(r=!0),r&&(Cg&&console.log("Update threemeshui"),this.needsUpdate=!1,e.update());return}this.lastUpdateFrame=[{context:t,frame:i,nextUpdate:i}],e.update()}static updateState(e,t){let i=null;if(e&&(i=this.findBlockInParent(e),i&&i!==this.lastSelected)){if(i.interactable===!1)return null;this.needsUpdate=!0}return i}static resetLastSelected(){const e=this.lastSelected;e&&(this.lastSelected=null,this.resetState(e))}static resetState(e){e&&(this.needsUpdate=!0)}static findBlockInParent(e){return e?e.isBlock?e:this.findBlockInParent(e.parent):null}}u(xc,"lastSelected",null),u(xc,"lastUpdateFrame",[]),u(xc,"needsUpdate",!1);const w0=Symbol("cameraController");function Mte(n){return n[w0]}function $D(n,e,t){t?n[w0]=e:n[w0]===e&&(n[w0]=null)}function ox(n){const e=n[Ma];return e||(n.parent?ox(n.parent):null)}function bb(n,e){if(!n)return;const t=n.material;if((t==null?void 0:t.isMaterial)===!0){const i=n.parent;i&&i.isText,t.side=e.doubleSided??!0?Si:Rs,t.shadowSide=e.doubleSided?Si:Rs,n.castShadow=e.castShadows?e.castShadows:!1,n.receiveShadow=e.receiveShadows?e.receiveShadows:!1}for(const i of n.children)bb(i,e)}function Qd(n,e,t){n[e]===void 0&&console.warn("Field",e,"is undefined on",n);const i=Proxy.revocable(n[e],{set(o,a,c,l){const h=o[a],d=Reflect.set(o,a,c,l);return t(c,h),d}}),s=i.revoke,r=n[e];return i.revoke=()=>{n[e]=r,s()},n[e]=i.proxy,i}const eO=Symbol("Scheduled action");function Tte(n,e,t=xr.OnBeforeRender){let i=n[eO];i||(i=n[eO]={});const s=e.name;i[t]||(i[t]={});const r=i[t];if(r[s])return;function*a(){e==null||e.call(n),r[s]=null}const c=n.startCoroutine(a(),t);r[s]=c}var Ite=Object.defineProperty,Rte=Object.getOwnPropertyDescriptor,Pte=(n,e,t,i)=>{for(var s=i>1?void 0:i?Rte(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Ite(e,t,s),s};const Ey=re("freecam"),MS=re("debugcamerafit"),Bte={LEFT:"",UP:"",RIGHT:"",BOTTOM:""};let TS;class cl extends Me{constructor(){super(...arguments);u(this,"autoRotate",!1);u(this,"autoRotateSpeed",1);u(this,"enableKeys",!0);u(this,"enableDamping",!0);u(this,"dampingFactor",.1);u(this,"enableZoom",!0);u(this,"minZoom",0);u(this,"maxZoom",1/0);u(this,"enablePan",!0);u(this,"lookAtConstraint",null);u(this,"lookAtConstraint01",1);u(this,"middleClickToFocus",!0);u(this,"doubleClickToFocus",!0);u(this,"useSlerp",!0);u(this,"debugLog",!1);u(this,"targetLerpSpeed",5);u(this,"autoTarget",!0);u(this,"_lookTargetPosition");u(this,"_controls",null);u(this,"_cameraObject",null);u(this,"_lerpToTargetPosition",!1);u(this,"_lerpCameraToTarget",!1);u(this,"_cameraTargetPosition",null);u(this,"_inputs",0);u(this,"_enableTime",0);u(this,"_startedListeningToKeyEvents",!1);u(this,"_eventSystem");u(this,"_afterHandleInputFn");u(this,"_camera",null);u(this,"_syncedTransform");u(this,"targetElement",null);u(this,"onControlsChangeStarted",()=>{this._syncedTransform&&this._syncedTransform.requestOwnership()});u(this,"_shouldDisable",!1);u(this,"_haveAttachedKeyboardEvents",!1)}get isCameraController(){return!0}get controls(){return this._controls}get controllerObject(){return this._cameraObject}onStartInteraction(t){var i;(i=this.controls)==null||i.addEventListener("start",t)}awake(){this._lookTargetPosition=new S,this._startedListeningToKeyEvents=!1}start(){if(this.autoTarget){if(this._controls){const t=se.getComponent(this.gameObject,Oi);if(t&&!this.setFromTargetPosition()){this.debugLog&&console.log("NO TARGET");const s=wt(t.cam).length(),r=new S(0,0,-s).applyMatrix4(t.cam.matrixWorld);this.setTarget(r,!0)}}this.startCoroutine(this.startRaycastDelayed())}this._eventSystem=qs.get(this.context)??void 0,this._eventSystem&&(this._afterHandleInputFn=this.afterHandleInput.bind(this),this._eventSystem.addEventListener(YE.AfterHandleInput,this._afterHandleInputFn))}onDestroy(){var t,i;(t=this._controls)==null||t.dispose(),(i=this._eventSystem)==null||i.removeEventListener(YE.AfterHandleInput,this._afterHandleInputFn)}onEnable(){this._enableTime=this.context.time.time;const t=se.getComponent(this.gameObject,Oi);this._camera=t;const i=t==null?void 0:t.cam;if(i&&$D(i,this,!0),!this._controls){if(!i){console.warn("OrbitControls: Requires a Camera component on the same object as this component.");return}i&&(this._cameraObject=i);const s=this.targetElement??this.context.domElement,r=i==null?void 0:i.quaternion.clone();this._controls=new MK(i,s),i==null||i.quaternion.copy(r),TS===void 0&&(TS={...this._controls.keys})}this._controls&&(Ey&&(this.enablePan=!0,this.enableZoom=!0,this.middleClickToFocus=!0,nl()&&(this.doubleClickToFocus=!0)),this._controls.addEventListener("start",this.onControlsChangeStarted),(i==null?void 0:i.type)==="PerspectiveCamera"?Ey||(this._controls.minDistance=this.minZoom,this._controls.maxDistance=this.maxZoom):Ey||(this._controls.minZoom=this.minZoom,this._controls.maxZoom=this.maxZoom),this._startedListeningToKeyEvents||(this._startedListeningToKeyEvents=!0,this._controls.listenToKeyEvents(window.document.body))),this._syncedTransform=se.getComponent(this.gameObject,nh)??void 0}onDisable(){var t;(t=this._camera)!=null&&t.cam&&$D(this._camera.cam,this,!1),this._controls&&(this._controls.enabled=!1,this._controls.autoRotate=!1,this._controls.removeEventListener("start",this.onControlsChangeStarted))}afterHandleInput(t){t.detail.args.pointerId===0&&(t.detail.args.isDown?this._controls&&this._eventSystem&&(this._shouldDisable=this._eventSystem.hasActiveUI):(!t.detail.args.isPressed||t.detail.args.isUp)&&(this._shouldDisable=!1))}*startRaycastDelayed(){if(yield,this.autoTarget&&!this.setFromTargetPosition()){const t=new sa;t.screenPoint=new te(0,0),t.lineThreshold=.1;const i=this.context.physics.raycast(t);i.length>0&&this.setTarget(i[0].point,!0)}}onBeforeRender(){var i,s,r;if(!this._controls||this._cameraObject!==this.context.mainCamera)return;(this.context.input.getPointerDown(0)||this.context.input.getPointerDown(1)||this.context.input.getPointerDown(2))&&(this._inputs+=1),this._inputs>0&&(this.autoRotate=!1,this._controls.autoRotate=!1,this._lerpCameraToTarget=!1,this._lerpToTargetPosition=!1),this._inputs=0;let t=this.middleClickToFocus&&this.context.input.getPointerClicked(1);if(t||(t=this.doubleClickToFocus&&this.context.input.getPointerDoubleClicked(0)&&this.context.time.time-this._enableTime>.3),t?this.setTargetFromRaycast():(this.context.input.getPointerDown(0)||this.context.input.mouseWheelChanged)&&(this._lerpToTargetPosition=!1,this._lerpCameraToTarget=!1),this._lerpToTargetPosition||this._lerpCameraToTarget){const o=this.context.time.deltaTime*this.targetLerpSpeed;if(this._lerpCameraToTarget&&this._cameraTargetPosition&&this._cameraObject){if(this.useSlerp){const a=(i=this._cameraObject)==null?void 0:i.position;O2(a,this._cameraTargetPosition,o)}else(s=this._cameraObject)==null||s.position.lerp(this._cameraTargetPosition,o);this._cameraObject.position.distanceTo(this._cameraTargetPosition)<1e-4&&(this._lerpCameraToTarget=!1)}this._lerpToTargetPosition&&(this.lerpTarget(this._lookTargetPosition,o),this._lookTargetPosition.distanceTo(this._controls.target)<1e-5&&(this._lerpToTargetPosition=!1))}!Ey&&((r=this.lookAtConstraint)!=null&&r.locked)&&this.setFromTargetPosition(0,this.lookAtConstraint01),this._controls&&(this.debugLog&&(this._controls.domElement=this.context.renderer.domElement),this._controls.enabled=!this._shouldDisable&&this._camera===this.context.mainCameraComponent&&!this.context.isInXR,this._controls.enableDamping=this.enableDamping,this._controls.keys=this.enableKeys?TS:Bte,this._controls.autoRotate=this.autoRotate,this._controls.autoRotateSpeed=this.autoRotateSpeed,this._controls.enableZoom=this.enableZoom,this._controls.dampingFactor=this.dampingFactor,this._controls.enablePan=this.enablePan,this.context.isInXR||this._controls.update())}setCameraTarget(t,i=!1){var s;t?(this._lerpCameraToTarget=!0,this._cameraTargetPosition=t.clone(),i&&this._cameraTargetPosition&&((s=this.controllerObject)==null||s.position.copy(this._cameraTargetPosition))):this._lerpCameraToTarget=!1}setFromTargetPosition(t=0,i=1){var r;if(!this._controls)return!1;const s=(r=this.lookAtConstraint)==null?void 0:r.sources;if(s&&s.length>0){const o=s[t];if(o)return o.getWorldPosition(this._lookTargetPosition),this.lerpTarget(this._lookTargetPosition,i),!0}return!1}setTarget(t=null,i=!1){this._controls&&(t!==null&&this._lookTargetPosition.copy(t),i?this._controls.target.copy(this._lookTargetPosition):this._lerpToTargetPosition=!0)}lerpTarget(t,i){this._controls&&this._controls.target.lerp(t,i)}distanceToTarget(t){return this._controls?this._controls.target.distanceTo(t):-1}setTargetFromRaycast(){var i,s;if(!this.controls)return;const t=this.context.physics.raycast();for(const r of t)if(r.distance>0&&se.isActiveInHierarchy(r.object)){const o=ox(r.object);if(o){const a=o.canvas;if(a!=null&&a.screenspace)break}if(this._lookTargetPosition.copy(r.point),this._lerpToTargetPosition=!0,this._cameraTargetPosition=null,this.context.mainCamera){this._lerpCameraToTarget=!0;const a=wt(this.context.mainCamera);this._cameraTargetPosition=a.clone().sub(this.controls.target).add(this._lookTargetPosition),(s=(i=this._cameraObject)==null?void 0:i.parent)==null||s.worldToLocal(this._cameraTargetPosition)}break}}fitCamera(t,i=1.1){const s=this._cameraObject,r=this._controls;if(t!=null&&t.length||(t=this.context.scene.children),t.length<=0||!s||!r)return;const o=new S,a=new S,c=new kn;c.makeEmpty();for(const v of t)v instanceof JC||v instanceof S1||(v.updateMatrixWorld(),c.expandByObject(v,!0));if(s.updateMatrixWorld(),s.updateProjectionMatrix(),c.getCenter(a),c.applyMatrix4(s.matrixWorldInverse),c.getSize(o),c.setFromCenterAndSize(a,o),o.length()<=1e-10){MS&&console.warn("Camera fit size is zero",c,[...t]);return}const l=s.fov,h=2*Math.atan(Math.tan(l*Math.PI/360/2)*s.aspect)/Math.PI*360,d=o.y/(2*Math.atan(Math.PI*l/360)),f=o.x/(2*Math.atan(Math.PI*h/360)),p=i*Math.max(d,f)+o.z/2;MS&&console.log("Fit camera to objects",d,f,"distance",p);const g=wt(s),A=r.target.clone().sub(g).normalize().multiplyScalar(p);if(r.maxDistance=p*10,r.minDistance=p*.01,this.setTarget(a,!0),this.autoTarget=!1,s.near=p/100,s.far=p*100,s.updateMatrixWorld(),s.updateProjectionMatrix(),fn(s,r.target.clone().sub(A)),MS){const v=new JC(c);this.context.scene.add(v),U2(v,b_(s)),this._haveAttachedKeyboardEvents||(this._haveAttachedKeyboardEvents=!0,document.body.addEventListener("keydown",m=>{m.code==="KeyF"&&this.fitCamera(t)}))}r.update()}}Pte([x(IA)],cl.prototype,"lookAtConstraint",2);var Dte=Object.defineProperty,Ote=Object.getOwnPropertyDescriptor,qr=(n,e,t,i)=>{for(var s=i>1?void 0:i?Ote(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Dte(e,t,s),s},yz=(n=>(n[n.Skybox=1]="Skybox",n[n.SolidColor=2]="SolidColor",n[n.Uninitialized=4]="Uninitialized",n))(yz||{});const Eg=re("debugcam"),tO=re("debugscreenpointtoray");var Xy;const Mg=(Xy=class extends Me{constructor(){super(...arguments);u(this,"_nearClipPlane",.1);u(this,"_farClipPlane",1e3);u(this,"orthographic",!1);u(this,"orthographicSize",5);u(this,"ARBackgroundAlpha",0);u(this,"_cullingMask",4294967295);u(this,"_backgroundBlurriness");u(this,"_backgroundIntensity");u(this,"_environmentIntensity");u(this,"_targetTexture",null);u(this,"_backgroundColor");u(this,"_fov");u(this,"_cam",null);u(this,"_clearFlags",2);u(this,"_skybox")}get isCamera(){return!0}get aspect(){return this._cam instanceof qt?this._cam.aspect:this.context.domWidth/this.context.domHeight}get fieldOfView(){return this._cam instanceof qt?this._cam.fov:this._fov}set fieldOfView(e){const t=this.fieldOfView!=e;if(this._fov=e,t&&this._cam&&this._cam instanceof qt){if(this._fov===void 0){console.warn("Can not set undefined fov on PerspectiveCamera");return}this._cam.fov=this._fov,this._cam.updateProjectionMatrix()}}get nearClipPlane(){return this._nearClipPlane}set nearClipPlane(e){const t=this._nearClipPlane!=e;this._nearClipPlane=e,this._cam&&t&&(this._cam.near=e,this._cam.updateProjectionMatrix())}get farClipPlane(){return this._farClipPlane}set farClipPlane(e){const t=this._farClipPlane!=e;this._farClipPlane=e,this._cam&&t&&(this._cam.far=e,this._cam.updateProjectionMatrix())}get clearFlags(){return this._clearFlags}set clearFlags(e){e!==this._clearFlags&&(this._clearFlags=e,this.applyClearFlagsIfIsActiveCamera())}set cullingMask(e){this._cullingMask=e,this._cam&&(this._cam.layers.mask=e)}get cullingMask(){return this._cam?this._cam.layers.mask:this._cullingMask}set backgroundBlurriness(e){e!==this._backgroundBlurriness&&(e===void 0?this._backgroundBlurriness=void 0:this._backgroundBlurriness=Math.min(Math.max(e,0),1),this.applyClearFlagsIfIsActiveCamera())}get backgroundBlurriness(){return this._backgroundBlurriness}set backgroundIntensity(e){e!==this._backgroundIntensity&&(e===void 0?this._backgroundIntensity=void 0:this._backgroundIntensity=Math.min(Math.max(e,0),10),this.applyClearFlagsIfIsActiveCamera())}get backgroundIntensity(){return this._backgroundIntensity}set environmentIntensity(e){this._environmentIntensity=e}get environmentIntensity(){return this._environmentIntensity}get backgroundColor(){return this._backgroundColor??null}set backgroundColor(e){if(e){if(this._backgroundColor)this._backgroundColor.copy(e);else{if(!e.clone)return;this._backgroundColor=e.clone()}e.alpha===void 0&&(this._backgroundColor.alpha=1),this.applyClearFlagsIfIsActiveCamera()}}set targetTexture(e){this._targetTexture=e}get targetTexture(){return this._targetTexture}get cam(){return this.activeAndEnabled&&this.buildCamera(),this._cam}screenPointToRay(e,t,i){const s=this.cam,r=Mg._origin;r.set(e,t,-1),this.context.input.convertScreenspaceToRaycastSpace(r),tO&&console.log("screenPointToRay",e.toFixed(2),t.toFixed(2),"now:",r.x.toFixed(2),r.y.toFixed(2),"isInXR:"+this.context.isInXR),r.z=-1,r.unproject(s);const o=Mg._direction.set(r.x,r.y,r.z),a=wt(s);return o.sub(a),o.normalize(),i?(i.set(a,o),i):new ja(a.clone(),o.clone())}awake(){tO&&window.addEventListener("pointerdown",e=>{const t=e.clientX,i=e.clientY;console.log("touch",t.toFixed(2),i.toFixed(2));const s=this.screenPointToRay(t,i),r="#"+Math.floor(Math.random()*16777215).toString(16);Lc.DrawRay(s.origin,s.direction,r,10)})}onEnable(){Eg&&console.log(this),this.buildCamera(),(this.tag=="MainCamera"||!this.context.mainCameraComponent)&&(this.context.setCurrentCamera(this),Lte(this)),this.applyClearFlagsIfIsActiveCamera()}onDisable(){this.context.removeCamera(this)}onBeforeRender(){if(this._cam&&this._targetTexture){this.context.isManagedExternally&&(this._warnedAboutExternalRenderer||(this._warnedAboutExternalRenderer=!0,console.warn("Rendering with external renderer is not supported yet. This may not work or throw errors. Please remove the the target texture from your camera: "+this.name,this.targetTexture))),this.context.composer;const e=this.context.renderer;if(e){const t=this.context.mainCameraComponent;this.applyClearFlags(),this._targetTexture.render(this.context.scene,this._cam,e),t==null||t.applyClearFlags()}}}buildCamera(){if(this._cam)return;const e=this.gameObject.isCamera;let t=null;if(e?(t=this.gameObject,t==null||t.layers.enableAll(),t instanceof qt&&(this._fov=t.fov)):t=this.gameObject.children[0],t&&t.isCamera)t instanceof qt&&(this._fov&&(t.fov=this._fov),t.near=this._nearClipPlane,t.far=this._farClipPlane,t.updateProjectionMatrix());else if(!this.orthographic)t=new qt(this.fieldOfView,window.innerWidth/window.innerHeight,this._nearClipPlane,this._farClipPlane),this.fieldOfView&&(t.fov=this.fieldOfView),this.gameObject.add(t);else{const i=this.orthographicSize*100;t=new Ru(window.innerWidth/-i,window.innerWidth/i,window.innerHeight/i,window.innerHeight/-i,this._nearClipPlane,this._farClipPlane),this.gameObject.add(t)}this._cam=t,this._cam.layers.mask=this._cullingMask,this.tag=="MainCamera"&&this.context.setCurrentCamera(this)}applyClearFlagsIfIsActiveCamera(){this.context.mainCameraComponent===this&&this.applyClearFlags()}applyClearFlags(){if(!this._cam){Eg&&console.log("Camera does not exist (apply clear flags)");return}switch(this.fieldOfView=this._fov,Eg&&_n("apply Camera clear flags: "+this._clearFlags),this._clearFlags){case 1:if(Mg.backgroundShouldBeTransparent(this.context)&&(!this.ARBackgroundAlpha||this.ARBackgroundAlpha<.001)){this.context.scene.background=null,this.context.renderer.setClearColor(0,0);return}this.enableSkybox(),this._backgroundBlurriness!==void 0&&(this.context.scene.backgroundBlurriness=this._backgroundBlurriness),this._backgroundIntensity!==void 0&&(this.context.scene.backgroundIntensity=this._backgroundIntensity);break;case 2:if(this._backgroundColor){let e=this._backgroundColor.alpha;Mg.backgroundShouldBeTransparent(this.context)&&(e=this.ARBackgroundAlpha??0),this.context.scene.background=null,this.context.renderer.setClearColor(this._backgroundColor,e)}break;case 4:this.context.scene.background=null,this.context.renderer.setClearColor(0,0);break}}enableSkybox(){this._skybox||(this._skybox=new kte(this)),this._skybox.enable()}static backgroundShouldBeTransparent(e){var r,o,a,c;const t=(r=e.renderer.xr)==null?void 0:r.getSession();if(!t)return!1;const i=t.environmentBlendMode;Eg&&_n("Environment blend mode: "+i+" on "+navigator.userAgent);const s=i==="additive"||i==="alpha-blend";if(e.xrSessionMode===Dm.ImmersiveAR&&i==="opaque"){if((o=navigator.userAgent)!=null&&o.includes("OculusBrowser"))return!0;if((a=navigator.userAgent)!=null&&a.includes("Mozilla")&&((c=navigator.userAgent)!=null&&c.includes("Mobile WebXRViewer/v2")))return!0}return s}},u(Xy,"_origin",new S),u(Xy,"_direction",new S),Xy);let Oi=Mg;qr([x()],Oi.prototype,"fieldOfView",1);qr([x()],Oi.prototype,"nearClipPlane",1);qr([x()],Oi.prototype,"farClipPlane",1);qr([x()],Oi.prototype,"clearFlags",1);qr([x()],Oi.prototype,"orthographic",2);qr([x()],Oi.prototype,"orthographicSize",2);qr([x()],Oi.prototype,"ARBackgroundAlpha",2);qr([x()],Oi.prototype,"cullingMask",1);qr([x()],Oi.prototype,"backgroundBlurriness",1);qr([x()],Oi.prototype,"backgroundIntensity",1);qr([x()],Oi.prototype,"environmentIntensity",1);qr([x(_i)],Oi.prototype,"backgroundColor",1);qr([x(ql)],Oi.prototype,"targetTexture",1);class kte{constructor(e){u(this,"_camera");u(this,"_skybox");this._camera=e}get context(){var e;return(e=this._camera)==null?void 0:e.context}enable(){this._skybox=this.context.lightmaps.tryGetSkybox(this._camera.sourceId),this._skybox?this.context.scene.background!==this._skybox&&(Eg&&console.log("Set skybox",this._camera,this._skybox),this._skybox.colorSpace=Ze,this._skybox.mapping=So,this.context.scene.background=this._skybox):console.warn("Failed to load/find skybox texture",this._camera.sourceId,this.context.lightmaps)}}function Lte(n){re("freecam")&&n.context.mainCameraComponent===n&&se.getOrAddComponent(n.gameObject,cl)}class zf extends Me{constructor(){super(...arguments);u(this,"_listener",null)}get listener(){return this._listener==null&&(this._listener=new _1),this._listener}awake(){Cn.registerWaitForAllowAudio(()=>{if(this.destroyed)return;const t=this.listener;if(t==null||t.parent)return;const i=this.context.mainCameraComponent||se.getComponentInParent(this.gameObject,Oi);i!=null&&i.cam?i.cam.add(t):this.gameObject.add(t)})}}var Fte=Object.defineProperty,Ute=Object.getOwnPropertyDescriptor,ax=(n,e,t,i)=>{for(var s=i>1?void 0:i?Ute(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Fte(e,t,s),s};const Nte=re("debugsignals");class LA{constructor(){u(this,"guid")}}ax([x()],LA.prototype,"guid",2);class hp{constructor(){u(this,"signal");u(this,"reaction")}}ax([x(LA)],hp.prototype,"signal",2);ax([x(cs)],hp.prototype,"reaction",2);var oC;const Ac=(oC=class extends Me{constructor(){super(...arguments);u(this,"events")}static invoke(e){if(Ac.receivers[e]){const t=Ac.receivers[e];if(!t)return;for(const i of t)i.invoke(e)}}awake(){Nte&&console.log("SignalReceiver awake",this)}onEnable(){if(this.events)for(const e of this.events)Ac.receivers[e.signal.guid]||(Ac.receivers[e.signal.guid]=[]),Ac.receivers[e.signal.guid].push(this)}onDisable(){if(this.events){for(const e of this.events)if(Ac.receivers[e.signal.guid]){const t=Ac.receivers[e.signal.guid].indexOf(this);t>=0&&Ac.receivers[e.signal.guid].splice(t,1)}}}invoke(e){if(!this.events||!Array.isArray(this.events))return;const t=typeof e=="object"?e.guid:e;for(const i of this.events)if(i.signal.guid===t)try{if(i.reaction){if(!i.reaction.invoke){console.warn("Missing invoke - possibly a serialization error",i,this);continue}}else{console.warn("Missing reaction for signal",i,this);continue}i.reaction.invoke()}catch(s){console.error(s)}}},u(oC,"receivers",{}),oC);let up=Ac;ax([x(hp)],up.prototype,"events",2);var Rr=(n=>(n.Activation="ActivationTrack",n.Animation="AnimationTrack",n.Audio="AudioTrack",n.Control="ControlTrack",n.Marker="MarkerTrack",n.Signal="SignalTrack",n))(Rr||{}),va=(n=>(n[n.None=0]="None",n[n.Hold=1]="Hold",n[n.Loop=2]="Loop",n[n.PingPong=3]="PingPong",n[n.Continue=4]="Continue",n))(va||{}),YT=(n=>(n.Signal="SignalEmitter",n))(YT||{});const Bd=re("debugtimeline"),Rb=class extends Me{constructor(){super(...arguments);u(this,"playableAsset");u(this,"playOnAwake");u(this,"extrapolationMode",1);u(this,"waitForAudio",!0);u(this,"_visibilityChangeEvt");u(this,"_clonedPlayableAsset",!1);u(this,"_speed",1);u(this,"_guidsMap");u(this,"_isPlaying",!1);u(this,"_internalUpdateRoutine");u(this,"_isPaused",!1);u(this,"_isStopping",!1);u(this,"_time",0);u(this,"_duration",0);u(this,"_weight",1);u(this,"_animationTracks",[]);u(this,"_audioTracks",[]);u(this,"_signalTracks",[]);u(this,"_controlTracks",[]);u(this,"_customTracks",[]);u(this,"_allTracks",[this._animationTracks,this._audioTracks,this._signalTracks,this._controlTracks,this._customTracks]);u(this,"animationCallbackReceivers",[])}static registerCreateTrack(t,i){this.createTrackFunctions[t]=i}get isPlaying(){return this._isPlaying}get isPaused(){return this._isPaused}get time(){return this._time}set time(t){typeof t=="number"&&!Number.isNaN(t)?this._time=t:(Bd||$s())&&console.error("INVALID TIMELINE.TIME VALUE",t,this.name)}get duration(){return this._duration}set duration(t){this._duration=t}get weight(){return this._weight}set weight(t){this._weight=t}get speed(){return this._speed}set speed(t){this._speed=t}awake(){var t,i,s;Bd&&console.log(this,(t=this.playableAsset)==null?void 0:t.tracks),this.rebuildGraph(),this.isValid()||console.warn("PlayableDirector is not valid",this.playableAsset,(i=this.playableAsset)==null?void 0:i.tracks,Array.isArray((s=this.playableAsset)==null?void 0:s.tracks),this)}onEnable(){var t,i,s;for(const r of this._audioTracks)(t=r.onEnable)==null||t.call(r);for(const r of this._customTracks)(i=r.onEnable)==null||i.call(r);for(const r of this._animationTracks)(s=r.onEnable)==null||s.call(r);this.playOnAwake&&this.play(),this._visibilityChangeEvt||(this._visibilityChangeEvt=()=>{switch(document.visibilityState){case"hidden":this.setAudioTracksAllowPlaying(!1);break;case"visible":this.setAudioTracksAllowPlaying(!0);break}}),window.addEventListener("visibilitychange",this._visibilityChangeEvt)}onDisable(){var t,i,s;this.stop();for(const r of this._audioTracks)(t=r.onDisable)==null||t.call(r);for(const r of this._customTracks)(i=r.onDisable)==null||i.call(r);for(const r of this._animationTracks)(s=r.onDisable)==null||s.call(r);this._visibilityChangeEvt&&window.removeEventListener("visibilitychange",this._visibilityChangeEvt)}onDestroy(){var t;for(const i of this._allTracks)for(const s of i)(t=s.onDestroy)==null||t.call(s)}rebuildGraph(){this.isValid()&&(this.resolveBindings(),this.updateTimelineDuration(),this.setupAndCreateTrackHandlers())}async play(){if(!this.isValid())return;const t=this._isPaused==!0;if(this._isPaused=!1,t&&this.invokePauseChangedMethodsOnTracks(),!this._isPlaying){if(this._isPlaying=!0,this.waitForAudio){const i=[];for(const s of this._audioTracks){const r=s.loadAudio(this._time,1,0);r&&i.push(r)}if(i.length>0&&(await Promise.all(i),!this._isPlaying))return;for(;this._audioTracks.length>0&&this._isPlaying&&!Cn.userInteractionRegistered&&this.waitForAudio;)await sA(200)}this.invokeStateChangedMethodsOnTracks(),this._internalUpdateRoutine=this.startCoroutine(this.internalUpdate(),xr.OnBeforeRender)}}pause(){this.isValid()&&(this._isPlaying=!1,!this._isPaused&&(this._isPaused=!0,this.evaluate(),this.invokePauseChangedMethodsOnTracks(),this.invokeStateChangedMethodsOnTracks()))}stop(){this._isStopping=!0;for(const s of this._audioTracks)s.stop();const t=this._isPaused==!0,i=this._isPlaying;this._isPlaying&&(this._time=0,this._isPlaying=!1,this._isPaused=!1,this.evaluate(),t&&this.invokePauseChangedMethodsOnTracks()),this._isPlaying=!1,this._isPaused=!1,t&&!i&&this.invokePauseChangedMethodsOnTracks(),i&&this.invokeStateChangedMethodsOnTracks(),this._internalUpdateRoutine&&this.stopCoroutine(this._internalUpdateRoutine),this._internalUpdateRoutine=null,this._isStopping=!1}evaluate(){if(!this.isValid())return;let t=this._time;switch(this.extrapolationMode){case 0:this._speed>0?t=Math.min(t,this._duration):this._speed<0&&(t=Math.max(t,0)),this._time=t;break;case 1:t%=this._duration,this._time=t;break;case 2:if(t>this._duration){this.stop();return}break}this.internalEvaluate(t)}isValid(){return this.playableAsset&&this.playableAsset.tracks&&Array.isArray(this.playableAsset.tracks)}*forEachTrack(){for(const t of this._allTracks)for(const i of t)yield i}get audioTracks(){return this._audioTracks}resolveGuids(t){this._guidsMap=t}invokePauseChangedMethodsOnTracks(){var t;for(const i of this.forEachTrack())(t=i.onPauseChanged)==null||t.call(i)}invokeStateChangedMethodsOnTracks(){var t;for(const i of this.forEachTrack())(t=i.onStateChanged)==null||t.call(i,this._isPlaying)}*internalUpdate(){for(;this._isPlaying&&this.activeAndEnabled;)!this._isPaused&&this._isPlaying&&(this._time+=this.context.time.deltaTime*this.speed,this.evaluate()),yield}internalEvaluate(t){for(const i of this.playableAsset.tracks)if(!i.muted)switch(i.type){case Rr.Activation:if(!this._isPlaying)continue;for(let s=0;s<i.outputs.length;s++){const r=i.outputs[s];if(typeof r=="object"){let o=!1;for(const c of i.clips)c.start<=t&&t<=c.end&&(o=!0);const a=r;a.visible!==void 0&&a.visible!==o&&(a.visible=o,Bd&&console.warn(this.name,"set ActivationTrack-"+s,a.name,o,t))}}break}if(!this._isStopping)for(const i of this._animationTracks)i.evaluate(t);for(const i of this._audioTracks)i.evaluate(t);for(const i of this._signalTracks)i.evaluate(t);for(const i of this._controlTracks)i.evaluate(t);for(const i of this._customTracks)i.evaluate(t)}resolveBindings(){if(this._clonedPlayableAsset||(this._clonedPlayableAsset=!0,this.playableAsset=Bb(this.playableAsset)),!this.playableAsset||!this.playableAsset.tracks)return;const t=this.findRoot(this.gameObject);for(const i of this.playableAsset.tracks){for(let s=i.outputs.length-1;s>=0;s--){let r=i.outputs[s];if(typeof r=="string"){this._guidsMap&&this._guidsMap[r]&&(r=this._guidsMap[r]);const o=se.findByGuid(r,t);o===null||typeof o!="object"?(i.outputs.splice(s,1),console.warn("Failed to resolve binding",r,i.name,i.type)):(Bd&&console.log("Resolved binding",r,"to",o),i.outputs[s]=o)}else if(r===null){if(i.outputs.splice(s,1),Rb.createTrackFunctions[i.type])continue;i.type!==Rr.Audio&&i.type!==Rr.Control&&i.type!==Rr.Marker&&i.type!==Rr.Signal&&console.warn("Missing binding",r,i.name,i.type,this.name,this.playableAsset.name)}}if(i.type===Rr.Control)for(let s=0;s<i.clips.length;s++){const r=i.clips[s];let o=r.asset.sourceObject;if(typeof o=="string"){this._guidsMap&&this._guidsMap[o]&&(o=this._guidsMap[o]);const a=se.findByGuid(o,t);a===null||typeof a!="object"?console.warn("Failed to resolve sourceObject binding",o,i.name,r):(Bd&&console.log("Resolved binding",o,"to",a),r.asset.sourceObject=a)}}}}findRoot(t){return t.parent?this.findRoot(t.parent):t}updateTimelineDuration(){if(this._duration=0,!(!this.playableAsset||!this.playableAsset.tracks)){for(const t of this.playableAsset.tracks)if(t.muted!==!0){for(const i of t.clips)i.end>this._duration&&(this._duration=i.end);for(const i of t.markers)i.time>this._duration&&(this._duration=i.time+.001)}}}setupAndCreateTrackHandlers(){var i,s;if(this._animationTracks.length=0,this._audioTracks.length=0,this._signalTracks.length=0,!this.playableAsset)return;const t=se.findObjectOfType(zf,this.context);for(const r of this.playableAsset.tracks){const o=r.type,a=Rb.createTrackFunctions[o];if(a!=null){const c=a(this,r);if(typeof c.evaluate=="function"){c.director=this,c.track=r,this._customTracks.push(c);continue}}if(r.type===Rr.Animation){if(r.clips.length<=0){Bd&&console.warn("Animation track has no clips",r);continue}for(let c=r.outputs.length-1;c>=0;c--){let l=r.outputs[c];if(l instanceof Te){const d=se.getOrAddComponent(l,Bs);d&&(l=d)}const h=(i=l==null?void 0:l.gameObject)==null?void 0:i.animations;if(h){const d=new cx;d.trackOffset=r.trackOffset,d.director=this,d.track=r;for(let f=0;f<r.clips.length;f++){const p=r.clips[f],g=p.asset;if(!g){console.error("MISSING anim model?","clip#"+f,p,r,this.playableAsset,this.name);continue}const A=g.clip;let v=A;if((typeof v=="string"||typeof v=="number")&&(v=h.find(b=>b.name===A)),!v){console.warn("Could not find animationClip for model",p,r.name,this.name,(s=this.playableAsset)==null?void 0:s.name);continue}l instanceof Bs&&l.runtimeAnimatorController&&(l.__internalDidAwakeAndStart||l.initializeRuntimeAnimatorController(),l.runtimeAnimatorController.mixer||l.runtimeAnimatorController.bind(l),d.mixer=l.runtimeAnimatorController.mixer),d.mixer||(d.mixer=new v_(l.gameObject)),d.clips.push(v),d.mixer.uncacheAction(v),d.createHooks(p.asset,v);const m=d.mixer.clipAction(v);d.actions.push(m),d.models.push(p)}this._animationTracks.push(d)}}}else if(r.type===Rr.Audio){if(r.clips.length<=0)continue;const c=new yu;if(c.director=this,c.track=r,this._audioTracks.push(c),!t)continue;c.listener=t.listener;for(let l=0;l<r.clips.length;l++){const h=r.clips[l];c.addModel(h)}}else if(r.type===Rr.Marker){const c=new jm;c.director=this,c.track=r;for(const l of r.markers)switch(l.type){case YT.Signal:c.models.push(l),c.didTrigger.push(!1);break}if(c!==null&&c.models.length>0){const l=se.getComponent(this.gameObject,up);l&&(c.receivers.push(l),this._signalTracks.push(c))}}else if(r.type===Rr.Signal){const c=new jm;c.director=this,c.track=r;for(const l of r.markers)c.models.push(l),c.didTrigger.push(!1);for(const l of r.outputs)c.receivers.push(l);this._signalTracks.push(c)}else if(r.type===Rr.Control){const c=new lx;c.director=this,c.track=r;for(const l of r.clips)c.models.push(l);c.resolveSourceObjects(this.context),this._controlTracks.push(c)}}}setAudioTracksAllowPlaying(t){for(const i of this._audioTracks)i.onAllowAudioChanged(t)}registerAnimationCallback(t){this.animationCallbackReceivers.push(t)}unregisterAnimationCallback(t){const i=this.animationCallbackReceivers.indexOf(t);i!==-1&&this.animationCallbackReceivers.splice(i,1)}};let Xc=Rb;u(Xc,"createTrackFunctions",{});const Uc=re("debugtimeline");class FA{constructor(){u(this,"director");u(this,"track")}get muted(){return this.track.muted}set muted(e){var t;e!==this.track.muted&&(this.track.muted=e,(t=this.onMuteChanged)==null||t.call(this))}*forEachClip(e=!1){var t;if((t=this.track)!=null&&t.clips)if(e)for(let i=this.track.clips.length-1;i>=0;i--)yield this.track.clips[i];else for(const i of this.track.clips)yield i}getClipTime(e,t){return t.clipIn+(e-t.start)*t.timeScale}getClipTimeNormalized(e,t){return(e-t.start)/t.duration}evaluateWeight(e,t,i,s=!0){if(t<0||t>=i.length)return 0;const r=i[t];if(s||e>=r.start&&e<=r.end){let o=1;const a=!1;if(r.easeInDuration>0){const c=Math.min((e-r.start)/r.easeInDuration,1);o*=c}if(r.easeOutDuration>0&&!a){const c=Math.min((r.end-e)/r.easeOutDuration,1);o*=c}return o}return 0}}class zte{constructor(e){u(this,"clip");u(this,"rootPositionOffset");u(this,"rootQuaternionOffset");u(this,"rootStartPosition");u(this,"rootEndPosition");u(this,"rootStartQuaternion");u(this,"rootEndQuaternion");const t=e.getClip();this.clip=t;const i=e.getRoot(),s=i.name+".position",r=i.name+".quaternion";Uc&&console.log(t.name,t.tracks,s);for(const o of t.tracks)if(!(o.times.length<=0)){if(o.name.endsWith(s))this.rootStartPosition=new S().fromArray(o.values,0),this.rootEndPosition=new S().fromArray(o.values,o.values.length-3),this.rootPositionOffset=this.rootEndPosition.clone().sub(this.rootStartPosition),Uc&&console.log(this.rootPositionOffset);else if(o.name.endsWith(r)&&(this.rootStartQuaternion=new Se().fromArray(o.values,0),this.rootEndQuaternion=new Se().fromArray(o.values,o.values.length-4),this.rootQuaternionOffset=this.rootEndQuaternion.clone().multiply(this.rootStartQuaternion),Uc)){const a=new Sn().setFromQuaternion(this.rootQuaternionOffset);console.log("ROT",a)}}}get hasOffsets(){return this.rootPositionOffset!==void 0||this.rootQuaternionOffset!==void 0}}class cx extends FA{constructor(){super(...arguments);u(this,"models",[]);u(this,"trackOffset");u(this,"target");u(this,"mixer");u(this,"clips",[]);u(this,"actions",[]);u(this,"_actionOffsets",[]);u(this,"_didBind",!1);u(this,"_animator",null);u(this,"_useclipOffsets",!0);u(this,"_totalOffsetPosition",new S);u(this,"_totalOffsetRotation",new Se);u(this,"_totalOffsetPosition2",new S);u(this,"_totalOffsetRotation2",new Se);u(this,"_summedPos",new S);u(this,"_tempPos",new S);u(this,"_summedRot",new Se);u(this,"_tempRot",new Se);u(this,"_clipRotQuat",new Se)}onStateChanged(){this._animator&&PD(this._animator.gameObject,this,this.director.isPlaying)}createHooks(t,i){var h,d;if(((h=i.tracks)==null?void 0:h.length)<=0){console.warn("No tracks in AnimationClip",i);return}const s=i.tracks[0].name.split("."),r=s[s.length-2],o=r+".position",a=r+".quaternion";let c=!1,l=!1;for(const f of i.tracks)f.name.endsWith(o)?(c=!0,this.createPositionInterpolant(i,t,f)):f.name.endsWith(a)&&(l=!0,this.createRotationInterpolant(i,t,f));if(!c||!l){const f=(d=this.mixer)==null?void 0:d.getRoot(),p=i.tracks[0],g=p.name.lastIndexOf("."),A=p.name.substring(0,g),v=A.substring(A.lastIndexOf(".")+1),m=f.getObjectByName(v);if(m)if(c){if(!l){const b=i.tracks[0].name.substring(0,g)+".quaternion";Uc&&console.warn("Create quaternion track",v,m);const y=m.quaternion,_=new Va(b,[0,i.duration],[y.x,y.y,y.z,y.w,y.x,y.y,y.z,y.w]);i.tracks.push(_),this.createRotationInterpolant(i,t,_)}}else{const b=A+".position";Uc&&console.warn("Create position track",v,m);const y=m.position,_=new Yc(b,[0,i.duration],[y.x,y.y,y.z,y.x,y.y,y.z]);i.tracks.push(_),this.createPositionInterpolant(i,t,_)}}}bind(){if(!this._didBind){this._didBind=!0,Uc&&console.log(this.models),this.mixer?this.target=this.mixer.getRoot():console.warn("No mixer was assigned to animation track");for(const t of this.actions){const i=new zte(t);this._actionOffsets.push(i)}this.target&&(this._animator=se.getComponent(this.target,Bs)??null,this._animator&&PD(this._animator.gameObject,this,!0));for(const t of this.models){const i=t.asset,s=i.position,r=i.rotation;s&&s.x!==void 0&&(s.isVector3||(i.position=new S(s.x,s.y,s.z)),r.isQuaternion||(i.rotation=new Se(r.x,r.y,r.z,r.w)))}this.ensureTrackOffsets()}}ensureTrackOffsets(){if(this.trackOffset){const t=this.trackOffset.position;t&&(t.isVector3||(this.trackOffset.position=new S(t.x,t.y,t.z)));const i=this.trackOffset.rotation;i&&(i.isQuaternion||(this.trackOffset.rotation=new Se(i.x,i.y,i.z,i.w)))}}evaluate(t){var c,l,h,d,f,p,g;if(this.track.muted||!this.mixer)return;this.bind(),this._totalOffsetPosition.set(0,0,0),this._totalOffsetRotation.set(0,0,0,1),this._totalOffsetPosition2.set(0,0,0),this._totalOffsetRotation2.set(0,0,0,1);let i=0,s=0,r=!1,o=!1,a=0;for(let A=0;A<this.clips.length;A++){const v=this.models[A],m=this.actions[A],b=v.asset;m.weight=0;const y=t>=v.start&&t<=v.end,_=v.preExtrapolationMode,C=v.postExtrapolationMode,M=A<this.clips.length-1?this.models[A+1]:null;let I=y,R=!1;if(!I&&!r&&v.end<t&&C!==va.None?(!M||M.start>t)&&(I=!0,r=!0):A==0&&!I&&!o&&v.start>t&&_!==va.None&&(!M||M.start<t)&&(I=!0,R=!0,o=!0),I){let E=1;E*=this.evaluateWeight(t,A,this.models,I),E*=this.director.weight;let T=y;if(R)switch(_){case va.Hold:break;case va.Loop:t+=v.start,T=!0;break;default:t+=v.start,T=!0;break}let O=this.getClipTime(t,v),K=0;const H=b.duration;if(R&&_===va.Hold&&(O=0),T){if(b.loop)for(K+=Math.floor(O/(H+1e-6));O>H;)O-=H}else if(!y&&r)switch(C){case va.Hold:O=this.getClipTime(v.end,v);break;case va.Loop:O%=H;break;case va.PingPong:const N=Math.floor(O/H)%2!==0;O%=H,N&&(O=H-O);break}v.reversed===!0?m.time=m.getClip().duration-O:m.time=O,m.timeScale=0;const V=Math.max(0,E);if(m.weight=V,a+=V,m.clampWhenFinished=!1,m.isRunning()||m.play(),this._useclipOffsets){const Y=i==0?this._totalOffsetPosition:this._totalOffsetPosition2,N=i==0?this._totalOffsetRotation:this._totalOffsetRotation2;i<1&&(s=1-E),i+=1;const L=this._summedPos.set(0,0,0),G=this._tempPos.set(0,0,0),ee=this._summedRot.identity(),$=this._tempRot.identity(),j=b.rotation;j&&(this._clipRotQuat.identity(),this._clipRotQuat.slerp(j,E));const ie=this._actionOffsets[A];if(ie.hasOffsets)for(let Ae=0;Ae<K;Ae++)ie.rootPositionOffset?G.copy(ie.rootPositionOffset):G.set(0,0,0),G.applyQuaternion(ee),this._clipRotQuat&&G.applyQuaternion(this._clipRotQuat),ie.rootQuaternionOffset&&($.copy(ie.rootQuaternionOffset),ee.multiply($)),L.add(G);this._clipRotQuat&&N.multiply(this._clipRotQuat),N.multiply(ee),b.position&&L.add(b.position),Y.add(L)}}}if(this._useclipOffsets&&(this._totalOffsetPosition.lerp(this._totalOffsetPosition2,s),this._totalOffsetRotation.slerp(this._totalOffsetRotation2,s)),this.__mixerError===void 0&&(Uc||bi())&&((l=(c=this._animator)==null?void 0:c.runtimeAnimatorController)!=null&&l.mixer)&&this.mixer!==((d=(h=this._animator)==null?void 0:h.runtimeAnimatorController)==null?void 0:d.mixer)&&(this.__mixerError=!0,console.error("AnimationTrack mixer is not shared with the animator controller - this might result in the timeline to not animate properly. Please report a bug to the Needle Engine team!",this)),(f=this._animator)!=null&&f.runtimeAnimatorController){const A=Math.max(0,1-a);(g=(p=this._animator)==null?void 0:p.runtimeAnimatorController)==null||g.update(A)}else this.mixer.update(t)}createRotationInterpolant(t,i,s){var c;const r=s.createInterpolant.bind(s),o=new Se;this.ensureTrackOffsets();const a=(c=this.trackOffset)==null?void 0:c.rotation;s.createInterpolant=()=>{const l=r(),h=l.evaluate.bind(l);return l.evaluate=d=>{var p;const f=h(d);if(o.set(f[0],f[1],f[2],f[3]),o.premultiply(this._totalOffsetRotation),a&&o.premultiply(a),this.director.animationCallbackReceivers)for(const g of this.director.animationCallbackReceivers)(p=g==null?void 0:g.onTimelineRotation)==null||p.call(g,this.director,this.target,d,o);return f[0]=o.x,f[1]=o.y,f[2]=o.z,f[3]=o.w,f},l}}createPositionInterpolant(t,i,s){var h,d;const r=s.createInterpolant.bind(s),o=new S;this.ensureTrackOffsets();const a=(h=this.trackOffset)==null?void 0:h.rotation,c=(d=this.trackOffset)==null?void 0:d.position;let l;s.createInterpolant=()=>{const f=r(),p=f.evaluate.bind(f);return f.evaluate=g=>{var v,m,b;const A=p(g);if(o.set(A[0],A[1],A[2]),i.removeStartOffset&&(l===void 0?(l=null,l=(m=(v=this._actionOffsets.find(y=>y.clip===t))==null?void 0:v.rootStartPosition)==null?void 0:m.clone()):l!=null&&l.isVector3&&o.sub(l)),o.applyQuaternion(this._totalOffsetRotation),o.add(this._totalOffsetPosition),a&&o.applyQuaternion(a),c&&(o.x-=c.x,o.y+=c.y,o.z+=c.z),this.director.animationCallbackReceivers)for(const y of this.director.animationCallbackReceivers)(b=y==null?void 0:y.onTimelinePosition)==null||b.call(y,this.director,this.target,g,o);return A[0]=o.x,A[1]=o.y,A[2]=o.z,A},f}}}const Gte=re("mutetimeline"),af=class extends FA{constructor(){super(...arguments);u(this,"models",[]);u(this,"listener");u(this,"audio",[]);u(this,"audioContextTimeOffset",[]);u(this,"lastTime",0);u(this,"_audioLoader",null)}getAudioFilePath(t){const i=this.director.sourceId;return il(i,t)}onAllowAudioChanged(t){for(let i=0;i<this.models.length;i++){const s=this.models[i];this.audio[i].setVolume(t?s.asset.volume:0)}}addModel(t){const i=new A_(this.listener);this.audio.push(i),this.models.push(t)}onDisable(){for(const t of this.audio)t.isPlaying&&t.stop()}onDestroy(){for(const t of this.audio)t.source&&(t==null||t.disconnect());this.audio.length=0}onMuteChanged(){if(this.muted)for(let t=0;t<this.audio.length;t++){const i=this.audio[t];i!=null&&i.isPlaying&&i.stop()}}stop(){for(let t=0;t<this.audio.length;t++){const i=this.audio[t];i!=null&&i.isPlaying&&i.stop()}}evaluate(t){if(Gte||this.track.muted||this.director.speed<0)return;const i=this.director.context.application.muted,s=i?.1:0;for(let r=0;r<this.models.length;r++){const o=this.models[r],a=this.audio[r];if((!a||!a.buffer)&&this.isInTimeRange(o,t-1,t+1)&&this.handleAudioLoading(o,a),Cn.userInteractionRegistered!==!1&&!(a===null||!a.buffer))if(a.playbackRate=this.director.context.time.timeScale,a.loop=o.asset.loop,t>=o.start&&t<=o.end&&t<this.director.duration){if(this.director.isPlaying==!1){if(a.isPlaying&&a.stop(),this.lastTime===t)continue}else if(!a.isPlaying)a.offset=o.clipIn+(t-o.start)*o.timeScale,a.play(s);else{const l=o.clipIn+(t-o.start)*o.timeScale,h=a.context.currentTime-a._startedAt+a.offset;Math.abs(l-h)>.3&&(a.offset=l,a.stop(),a.play(s))}let c=o.asset.volume;if(i&&(c=0),o.easeInDuration>0){const l=Math.min((t-o.start)/o.easeInDuration,1);c*=l}if(o.easeOutDuration>0){const l=Math.min((o.end-t)/o.easeOutDuration,1);c*=l}a.setVolume(c*this.director.weight)}else a.isPlaying&&a.stop()}this.lastTime=t}loadAudio(t,i=0,s=0){let r=null;const o=t-s,a=t+i;for(const c of this.models)if(this.isInTimeRange(c,o,a)){const l=this.audio[this.models.indexOf(c)],h=this.handleAudioLoading(c,l);h!==null&&(r===null&&(r=[]),r.push(h))}return r!==null?Promise.all(r):null}isInTimeRange(t,i,s){return i<=t.start&&s>=t.end||i>=t.start&&i<=t.end||s>=t.start&&s<=t.end}static dispose(){af._audioBuffers.clear()}handleAudioLoading(t,i){this._audioLoader||(this._audioLoader=new X0);const s=this.getAudioFilePath(t.asset.clip);if(af._audioBuffers.get(s)){const o=af._audioBuffers.get(s);return o.then(a=>{a&&i.setBuffer(a)}),o}Uc&&console.warn("LOAD audio track",s,this.director.sourceId);const r=new Promise((o,a)=>{this._audioLoader.load(s,c=>{i.setBuffer(c),o(c)},void 0,c=>{console.error("Error loading audio",c),o(null)})});return af._audioBuffers.set(s,r),r}};let yu=af;u(yu,"_audioBuffers",new Map);class jm extends FA{constructor(){super(...arguments);u(this,"models",[]);u(this,"didTrigger",[]);u(this,"receivers",[])}evaluate(t){var s;if(this.track.muted)return;const i=this.director.context.time.deltaTime*1.5;for(let r=0;r<this.models.length;r++){const o=this.models[r],a=this.didTrigger[r],c=o.time-t;let l=!1;if(o.retroActive)l=c<=1e-6;else{const h=Math.abs(c);(h===0||h>=1e-5&&h<i)&&(l=!0)}if(l){if(!a)if(Uc&&console.log("Trigger signal",t,o.time,o),this.didTrigger[r]=!0,((s=this.receivers)==null?void 0:s.length)<=0)up.invoke(o.asset);else for(const h of this.receivers)h&&h.invoke(o.asset)}else o.emitOnce||(this.didTrigger[r]=!1)}}}class lx extends FA{constructor(){super(...arguments);u(this,"models",[]);u(this,"timelines",[]);u(this,"_previousActiveModel",null)}resolveSourceObjects(t){for(let i=this.models.length-1;i>=0;i--){const r=this.models[i].asset;if(!r.sourceObject||typeof r.sourceObject!="object"){console.log("no source object, removing model",i,r),this.models.splice(i,1);continue}else{const o=se.getComponent(r.sourceObject,Xc);this.timelines.push(o),o&&r.updateDirector&&(o.playOnAwake=!1)}}}evaluate(t){var i;this._previousActiveModel=null;for(let s=0;s<this.models.length;s++){const r=this.models[s],o=r.asset;if(t>=r.start&&t<=r.end){this._previousActiveModel=r;const a=this.getClipTime(t,r);if(o.controlActivation){const c=o.sourceObject;c.visible=!0}if(o.updateDirector){const c=this.timelines[s];c&&(c.isPlaying&&c.pause(),c.time=a,c.evaluate())}}else{const a=(i=this._previousActiveModel)==null?void 0:i.asset;if(o.controlActivation){const c=o.sourceObject;(a==null?void 0:a.sourceObject)!==c&&(c.visible=!1)}}}}}var Hte=Object.defineProperty,Vte=Object.getOwnPropertyDescriptor,bz=(n,e,t,i)=>{for(var s=i>1?void 0:i?Vte(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Hte(e,t,s),s};class Rt{constructor(e){u(this,"_active",!0);u(this,"_value");u(this,"_valueRaw");u(this,"_defaultValue");u(this,"valueProcessor");u(this,"onValueChanged");this._value=e,this._defaultValue=e,this._valueRaw=e}get overrideState(){return this._active}set overrideState(e){if(this._active===e)return;this._active=e;const t=e?this._valueRaw:this._defaultValue;this.processValue(t,!0)}get value(){return this._valueRaw}set value(e){this.processValue(e,!1)}set defaultValue(e){this._defaultValue=e}__init(){this.processValue(this._valueRaw,!0)}processValue(e,t){if(e==null||!t&&this.testIfValueChanged(e)===!1)return;const i=this._value;!this._active&&this._defaultValue!==void 0?(this._value=this._defaultValue,e=this._defaultValue,this._valueRaw=e):(this._valueRaw=e,this._active&&this.valueProcessor&&(e=this.valueProcessor(e)),this._value=e),this.onValueChanged&&this.onValueChanged(e,i,this)}testIfValueChanged(e){return this._valueRaw!==e}}bz([x()],Rt.prototype,"overrideState",1);bz([x()],Rt.prototype,"value",1);var Qte=Object.defineProperty,Wte=Object.getOwnPropertyDescriptor,jte=(n,e,t,i)=>{for(var s=i>1?void 0:i?Wte(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Qte(e,t,s),s};const Xte=re("debugpost");class Os extends dh{constructor(t=void 0){super();u(this,"active",!0);u(this,"_result");u(this,"_didCreateVolumeParameters",!1);if(t){this.ensureVolumeParameters();for(const i of Object.keys(t)){const s=t[i],r=this[i];r instanceof Rt&&(r.value=s)}}}onEnable(){this.__internalDidAwakeAndStart&&(this.active=!0)}onDisable(){this.active=!1}init(){}apply(){var t;return this.ensureVolumeParameters(),this._result||(this._result=(t=this.onCreateEffect)==null?void 0:t.call(this)),this._result&&this.initParameters(),this._result}unapply(){}dispose(){Xte&&console.warn("DISPOSE",this),this._result&&(Array.isArray(this._result)?this._result.forEach(t=>t.dispose()):this._result.dispose()),this._result=void 0}initParameters(){const t=Object.keys(this);for(const i of t){const s=this[i];s instanceof Rt&&s.__init()}}onAfterDeserialize(t,i){if(typeof t=="object"){const s=this.$serializedTypes;if(s){for(const r of Object.keys(s))if(s[r]===Rt){const a=t[r];if(a!==void 0){const c=this[r];c.value=a}}}}}onEditorModification(t){const i=t.propertyName;if(this[i]instanceof Rt){const s=t.value;return this[i].value=s,!0}}ensureVolumeParameters(){if(this._didCreateVolumeParameters)return;this._didCreateVolumeParameters=!0;const t=this.$serializedTypes;if(t)for(const i of Object.keys(t))t[i]===Rt&&(this[i]||(this[i]=new Rt))}}jte([x()],Os.prototype,"active",2);var qte=Object.defineProperty,Yte=Object.getOwnPropertyDescriptor,Kte=(n,e,t,i)=>{for(var s=i>1?void 0:i?Yte(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&qte(e,t,s),s};const Jte=re("debugpost"),KE={};function Ro(n,e){KE[n]=e}function Zte(n){return n.__type in KE?KE[n.__type]:(Jte&&n.__type&&console.warn("Unknown postprocessing type",n.__type,n),Os)}class UA{constructor(){u(this,"components",[])}init(){var e;(e=this.components)==null||e.forEach(t=>t.init())}}Kte([tp([n=>Zte(n),Os])],UA.prototype,"components",2);var $te=Object.defineProperty,eie=Object.getOwnPropertyDescriptor,tie=(n,e,t,i)=>{for(var s=i>1?void 0:i?eie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&$te(e,t,s),s};class NA extends Os{constructor(){super(...arguments);u(this,"preset")}get typeName(){return"Antialiasing"}onCreateEffect(){const t=new rq({preset:Gd.HIGH,edgeDetectionMode:Q1.DEPTH});return this.preset.onValueChanged=i=>{t.applyPreset(i)},t}}tie([x(Rt)],NA.prototype,"preset",2);Ro("Antialiasing",NA);class hx{constructor(){u(this,"files",[])}get extensionName(){return"Audio"}onExportObject(e,t,i){const s=se.getComponents(e,Cn);if(s.length)for(const r of s){if(!r.clip||!r.playOnAwake)continue;const o=r.clip.split("/").pop();this.files.includes(r.clip)||this.files.push(r.clip),t.addEventListener("serialize",(a,c)=>{a.appendLine(),a.beginBlock(`def SpatialAudio "${t.name}"`),a.appendLine(`uniform asset filePath = @audio/${o}@`),a.appendLine(`uniform token auralMode = "${r.spatialBlend>0?"spatial":"nonSpatial"}"`),a.appendLine(`uniform token playbackMode = "${r.loop?"loopFromStage":"onceFromStart"}"`),a.appendLine(`uniform float gain = ${r.volume}`),a.closeBlock()})}}async onAfterSerialize(e){for(const t of this.files){const i=t.split("/").pop(),o=await(await(await fetch(t)).blob()).arrayBuffer(),a=new Uint8Array(o);e.files["audio/"+i]=a}}}var iie=Object.defineProperty,nie=Object.getOwnPropertyDescriptor,_z=(n,e,t,i)=>{for(var s=i>1?void 0:i?nie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&iie(e,t,s),s};const sie=re("debugmouth");class zA extends Me{constructor(){super(...arguments);u(this,"idle",[]);u(this,"talking",[]);u(this,"marker",null);u(this,"voip",null);u(this,"lastMouthChangeTime",0);u(this,"mouthChangeLength",0)}awake(){setTimeout(()=>{this.voip=se.findObjectOfType(rl,this.context),this.marker||(this.marker=se.getComponentInParent(this.gameObject,Kn))},3e3)}update(){var s;if(!this.voip||this.context.time.frameCount%10!==0)return;let t=((s=this.marker)==null?void 0:s.connectionId)??null;if(!t){sie&&(t=null);return}const i=this.voip.getFrequency(t)??0;this.updateLips(i)}updateLips(t){if(this.context.time.time-this.lastMouthChangeTime>this.mouthChangeLength){if(this.mouthChangeLength=.05+Math.random()*.1,this.talking&&this.talking.length>0&&t>30){this.lastMouthChangeTime=this.context.time.time;const i=Math.floor(Math.random()*this.talking.length);this.setMouthShapeActive(this.talking,i)}else if(this.idle.length>0&&this.context.time.time-this.lastMouthChangeTime>.5){this.lastMouthChangeTime=this.context.time.time;const i=Math.floor(Math.random()*this.idle.length);this.setMouthShapeActive(this.idle,i)}}}setMouthShapeActive(t,i){if(t){t!=this.idle?this.idle.map(s=>s.visible=!1):this.talking.map(s=>s.visible=!1);for(let s=0;s<t.length;s++){const r=t[s];r&&(r.visible=s===i)}}}}_z([x(Te)],zA.prototype,"idle",2);_z([x(Te)],zA.prototype,"talking",2);class KT extends Me{constructor(){super(...arguments);u(this,"voip",null);u(this,"marker",null);u(this,"_startPosition",null)}awake(){this.voip=se.findObjectOfType(rl,this.context),this.marker=se.getComponentInParent(this.gameObject,Kn)}update(){if(!this.voip||!this.marker||this.context.time.frameCount%10!==0)return;const t=this.marker.connectionId,i=this.voip.getFrequency(t);if(i==null)return;this._startPosition||(this._startPosition=this.gameObject.position.clone());const s=i/100;this.gameObject.position.y=this._startPosition.y+s*.07}}var rie=Object.defineProperty,oie=Object.getOwnPropertyDescriptor,ux=(n,e,t,i)=>{for(var s=i>1?void 0:i?oie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&rie(e,t,s),s};class zu extends Me{constructor(){super(...arguments);u(this,"eyes",[]);u(this,"lastBlinkTime",0);u(this,"blinkLength",0);u(this,"eyesOpen",!0);u(this,"state",null)}awake(){this.state=se.getComponentInParent(this.gameObject,Fr)}update(){if(!this.gameObject||!this.gameObject.visible||!this.eyes||!Array.isArray(this.eyes)||this.eyes.length===0)return;if(this.context.time.time-this.lastBlinkTime>this.blinkLength){if(this.lastBlinkTime=this.context.time.time,this.state&&!this.state.isOn||!this.activeAndEnabled)return;if(this.eyesOpen=!this.eyesOpen,this.blinkLength=Math.random(),this.eyesOpen?(this.blinkLength*=3,this.blinkLength+=.5,Math.random()<.1&&(this.blinkLength=.1+Math.random()*.2)):(this.blinkLength*=Math.random()*.2,this.blinkLength+=.1),Math.random()<.1&&(this.blinkLength*=3),this.blinkLength=Math.max(.2,this.blinkLength),this.blinkLength=Math.min(3,this.blinkLength),this.eyes)for(const i of this.eyes)i&&(i.visible=this.eyesOpen)}}}ux([x(Te)],zu.prototype,"eyes",2);ux([x()],zu.prototype,"lastBlinkTime",2);ux([x()],zu.prototype,"blinkLength",2);ux([x()],zu.prototype,"eyesOpen",2);var aie=Object.defineProperty,cie=Object.getOwnPropertyDescriptor,JT=(n,e,t,i)=>{for(var s=i>1?void 0:i?cie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&aie(e,t,s),s},aC;const xz=(aC=class extends Me{constructor(){super(...arguments);u(this,"head",null);u(this,"eyes",null);u(this,"target",null);u(this,"brain",null);u(this,"vec",new S);u(this,"currentTargetPoint",new S)}awake(){this.brain||(this.brain=se.getComponentInParent(this.gameObject,Lm)),this.brain||(console.log("No look at brain found, adding it now"),this.brain=se.addNewComponent(this.gameObject,Lm)),this.brain&&this.target&&(this.brain.controlledTarget=this.target)}update(){const e=this.target;if(e&&this.head){const t=this.eyes;if(t){const i=wt(e);this.currentTargetPoint.lerp(i,this.context.time.deltaTime/.1);const s=wt(this.head),r=this.vec.copy(this.currentTargetPoint).sub(s).normalize();if(r.length()<.1)return;const o=xz.forward;if(o.set(0,0,1),o.applyQuaternion(Fn(this.head)),o.dot(r)>.45)for(let c=0;c<t.length;c++)t[c].lookAt(this.currentTargetPoint)}}}},u(aC,"forward",new S(0,0,1)),aC);let dp=xz;JT([x(Te)],dp.prototype,"head",2);JT([x(Te)],dp.prototype,"eyes",2);JT([x(Te)],dp.prototype,"target",2);var lie=Object.defineProperty,hie=Object.getOwnPropertyDescriptor,ZT=(n,e,t,i)=>{for(var s=i>1?void 0:i?hie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&lie(e,t,s),s};class fp extends Me{constructor(){super(...arguments);u(this,"length",1);u(this,"depthTest",!0);u(this,"isGizmo",!0);u(this,"_axes",null)}onEnable(){if(this.isGizmo&&!gA)return;this._axes||(this._axes=new Xf(this.length)),this.gameObject.add(this._axes);const t=this._axes.material;t&&t.depthTest!==void 0&&(t.depthTest=this.depthTest)}onDisable(){this._axes&&this.gameObject.remove(this._axes)}}ZT([x()],fp.prototype,"length",2);ZT([x()],fp.prototype,"depthTest",2);ZT([x()],fp.prototype,"isGizmo",2);class $T extends Me{constructor(){super(...arguments);u(this,"from");u(this,"to");u(this,"hint");u(this,"desiredDistance",1)}onEnable(){}update(){if(!this.from||!this.to||!this.hint)return;const t=wt(this.to).clone(),i=wt(this.from).clone(),s=t.distanceTo(i),r=t.clone();r.sub(i);const o=i.clone();o.add(t),o.multiplyScalar(.5);const a=wt(this.hint).clone();a.sub(o);const c=new S;c.crossVectors(a,r),c.crossVectors(r,c),c.normalize();const l=s*.5,h=Math.max(this.desiredDistance,l),d=Math.sqrt(h*h-l*l),f=c.clone();f.multiplyScalar(d),f.add(o),fn(this.gameObject,f);const p=o.clone();p.sub(c),this.gameObject.lookAt(p)}}const iO=re("debugusdz");class dx{constructor(){u(this,"behaviours",[]);u(this,"behaviourComponents",[]);u(this,"behaviourComponentsCopy",[])}get extensionName(){return"Behaviour"}addBehavior(e){this.behaviours.push(e)}onBeforeBuildDocument(e){const t=[];return e.root.traverse(i=>{se.foreachComponent(i,s=>{var o;const r=s;if(typeof r.createBehaviours=="function"||typeof r.beforeCreateDocument=="function"||typeof r.afterCreateDocument=="function"||typeof r.afterSerialize=="function"){this.behaviourComponents.push(r);const a=(o=r.beforeCreateDocument)==null?void 0:o.call(r,this,e);a instanceof Promise&&t.push(a)}},!1)}),Promise.all(t)}onExportObject(e,t,i){var s;for(const r of this.behaviourComponents)(s=r.createBehaviours)==null||s.call(r,this,t,i)}onAfterBuildDocument(e){for(const t of this.behaviourComponents)typeof t.afterCreateDocument=="function"&&t.afterCreateDocument(this,e);this.behaviourComponentsCopy=this.behaviourComponents.slice(),this.behaviourComponents.length=0}onAfterHierarchy(e,t){var i;if((i=this.behaviours)!=null&&i.length){t.beginBlock('def Scope "Behaviors"');for(const s of this.behaviours)s.writeTo(this,e.document,t);t.closeBlock()}}async onAfterSerialize(e){iO&&console.log("onAfterSerialize behaviours",this.behaviourComponentsCopy);for(const t of this.behaviourComponentsCopy)typeof t.afterSerialize=="function"&&(iO&&console.log("behaviour has afterSerialize",t),t.afterSerialize.constructor.name==="AsyncFunction"?await t.afterSerialize(this,e):t.afterSerialize(this,e))}}var uie=Object.defineProperty,die=Object.getOwnPropertyDescriptor,eI=(n,e,t,i)=>{for(var s=i>1?void 0:i?die(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&uie(e,t,s),s};class Gu extends Os{constructor(){super(...arguments);u(this,"threshold");u(this,"intensity");u(this,"scatter");u(this,"selectiveBloom",!0)}get typeName(){return"Bloom"}init(){this.threshold.defaultValue=1,this.intensity.defaultValue=0,this.scatter.defaultValue=.2,this.selectiveBloom?(this.threshold.valueProcessor=t=>t,this.intensity.valueProcessor=t=>t,this.scatter.valueProcessor=t=>1*Math.PI*(1-t)):(this.threshold.valueProcessor=t=>t,this.intensity.valueProcessor=t=>t,this.scatter.valueProcessor=t=>100*(1-t))}onCreateEffect(){let t;if(this.selectiveBloom){const i=t=new LU(this.context.scene,this.context.mainCamera,{blendFunction:zt.ADD,mipmapBlur:!0,luminanceThreshold:this.threshold.value,luminanceSmoothing:this.scatter.value,intensity:this.intensity.value});i.inverted=!0}else t=new q1;return this.intensity.onValueChanged=i=>{t.intensity=i},this.threshold.onValueChanged=i=>{t.luminanceMaterial.threshold=i},this.scatter.onValueChanged=i=>{t.luminancePass.enabled=!0,t.luminanceMaterial.smoothing=i},t}}eI([x(Rt)],Gu.prototype,"threshold",2);eI([x(Rt)],Gu.prototype,"intensity",2);eI([x(Rt)],Gu.prototype,"scatter",2);Ro("Bloom",Gu);var fie=Object.defineProperty,pie=Object.getOwnPropertyDescriptor,aa=(n,e,t,i)=>{for(var s=i>1?void 0:i?pie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&fie(e,t,s),s};class Ya extends Me{constructor(){super(...arguments);u(this,"attachedRigidbody",null);u(this,"isTrigger",!1);u(this,"sharedMaterial")}get isCollider(){return!0}awake(){super.awake(),this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Yi))}start(){this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Yi))}onEnable(){this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Yi))}onDisable(){var t;(t=this.context.physics.engine)==null||t.removeBody(this)}}aa([x(Yi)],Ya.prototype,"attachedRigidbody",2);aa([x()],Ya.prototype,"isTrigger",2);aa([x()],Ya.prototype,"sharedMaterial",2);class GA extends Ya{constructor(){super(...arguments);u(this,"radius",.5);u(this,"center",new S(0,0,0))}onEnable(){var t;super.onEnable(),(t=this.context.physics.engine)==null||t.addSphereCollider(this,this.center,this.radius)}}aa([x()],GA.prototype,"radius",2);aa([x(S)],GA.prototype,"center",2);class HA extends Ya{constructor(){super(...arguments);u(this,"size",new S(1,1,1));u(this,"center",new S(0,0,0))}onEnable(){var t;super.onEnable(),(t=this.context.physics.engine)==null||t.addBoxCollider(this,this.center,this.size)}}aa([x(S)],HA.prototype,"size",2);aa([x(S)],HA.prototype,"center",2);class VA extends Ya{constructor(){super(...arguments);u(this,"sharedMesh");u(this,"convex",!1)}onEnable(){var t,i,s,r,o;if(super.onEnable(),(t=this.sharedMesh)!=null&&t.isMesh||this.gameObject instanceof ye&&(this.sharedMesh=this.gameObject),(i=this.sharedMesh)!=null&&i.isMesh)(s=this.context.physics.engine)==null||s.addMeshCollider(this,this.sharedMesh,this.convex,qn(this.gameObject));else{const a=this.sharedMesh;if(a!=null&&a.isGroup){console.warn(`MeshCollider mesh is a group "${(r=this.sharedMesh)==null?void 0:r.name}", adding all children as colliders. This is currently not fully supported (colliders can not be removed from world again)`,this);for(const c in a.children){const l=a.children[c];l.isMesh&&((o=this.context.physics.engine)==null||o.addMeshCollider(this,l,this.convex,qn(this.gameObject)))}}}}}aa([x()],VA.prototype,"convex",2);class rh extends Ya{constructor(){super(...arguments);u(this,"center",new S(0,0,0));u(this,"radius",.5);u(this,"height",2)}onEnable(){var t;super.onEnable(),(t=this.context.physics.engine)==null||t.addCapsuleCollider(this,this.center,this.height,this.radius)}}aa([x(S)],rh.prototype,"center",2);aa([x()],rh.prototype,"radius",2);aa([x()],rh.prototype,"height",2);var gie=Object.defineProperty,mie=Object.getOwnPropertyDescriptor,QA=(n,e,t,i)=>{for(var s=i>1?void 0:i?mie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&gie(e,t,s),s};const IS=re("debugui"),RS=re("debuguilayout");class tI{constructor(){u(this,"width");u(this,"height")}}class iI{constructor(){u(this,"x");u(this,"y");u(this,"width");u(this,"height")}}const Uo=new S,eg=new Re,My=new Se,wz=class extends ta{constructor(){super();u(this,"_anchoredPosition");u(this,"sizeDelta",new te(100,100));u(this,"pivot",new te(.5,.5));u(this,"anchorMin",new te(0,0));u(this,"anchorMax",new te(1,1));u(this,"lastMatrix");u(this,"rectBlock");u(this,"_transformNeedsUpdate",!1);u(this,"_initialPosition");u(this,"_parentRectTransform");u(this,"_lastUpdateFrame",-1);u(this,"_lastAnchoring");u(this,"_createdBlocks",[]);u(this,"_createdTextBlocks",[]);this.lastMatrix=new Re,this.rectBlock=new Te}get parent(){return this._parentRectTransform}get translation(){return this.gameObject.position}get rotation(){return this.gameObject.quaternion}get scale(){return this.gameObject.scale}get anchoredPosition(){return this._anchoredPosition||(this._anchoredPosition=new te),this._anchoredPosition}set anchoredPosition(e){this._anchoredPosition=e}get width(){if(this.anchorMin.x!==this.anchorMax.x&&this._parentRectTransform){const e=this._parentRectTransform.width,t=this.anchorMax.x-this.anchorMin.x;let i=e*t;return i+=this.sizeDelta.x,i}return this.sizeDelta.x}get height(){if(this.anchorMin.y!==this.anchorMax.y&&this._parentRectTransform){const e=this._parentRectTransform.height,t=this.anchorMax.y-this.anchorMin.y;let i=e*t;return i+=this.sizeDelta.y,i}return this.sizeDelta.y}awake(){super.awake(),this._anchoredPosition||(this._anchoredPosition=new te),this.rectBlock.name=this.name,this._initialPosition=this.gameObject.position.clone(),this._initialPosition.z=0,Qd(this,"_anchoredPosition",()=>{this.markDirty()}),Qd(this,"sizeDelta",()=>{this.markDirty()}),Qd(this,"pivot",()=>{this.markDirty()}),Qd(this,"anchorMin",()=>{this.markDirty()}),Qd(this,"anchorMax",()=>{this.markDirty()})}onEnable(){var e;super.onEnable(),this.addShadowComponent(this.rectBlock),this._transformNeedsUpdate=!0,(e=this.Canvas)==null||e.registerTransform(this)}onDisable(){var e;super.onDisable(),this.removeShadowComponent(),(e=this.Canvas)==null||e.unregisterTransform(this)}onParentRectTransformChanged(e){this._transformNeedsUpdate||this.onApplyTransform(RS?`${e.name} changed`:void 0)}get isDirty(){return this._transformNeedsUpdate||(this._transformNeedsUpdate=!this.lastMatrix.equals(this.gameObject.matrix)),this._transformNeedsUpdate}markDirty(){this._transformNeedsUpdate||(RS&&console.warn("RectTransform markDirty()",this.name),this._transformNeedsUpdate=!0,this._lastUpdateFrame=-1)}updateTransform(){(this._transformNeedsUpdate||!this.lastMatrix.equals(this.gameObject.matrix))&&this.canUpdate()&&this.onApplyTransform(this._transformNeedsUpdate?"Marked dirty":"Matrix changed")}canUpdate(){return this._transformNeedsUpdate&&this.activeAndEnabled&&this._lastUpdateFrame!==this.context.time.frame}onApplyTransform(e){var s;if(this.context.time.frameCount===this._lastUpdateFrame)return;this._lastUpdateFrame=this.context.time.frameCount;const t=this.shadowComponent;if(!t)return;this.gameObject.parent?this._parentRectTransform=se.getComponentInParent(this.gameObject.parent,wz):this._parentRectTransform=void 0,this._transformNeedsUpdate=!1,RS&&console.warn("RectTransform → ApplyTransform",this.name+" because "+e),this.isRoot()?this.Root.screenspace||(t.rotation.y=Math.PI):(t.matrix.identity(),t.matrixAutoUpdate=!1,Uo.set(0,0,0),this.applyPivot(Uo),t.matrix.setPosition(Uo.x,Uo.y,0),(this.gameObject.quaternion.x||this.gameObject.quaternion.y||this.gameObject.quaternion.z)&&(My.copy(this.gameObject.quaternion),My.x*=-1,My.z*=-1,eg.makeRotationFromQuaternion(My),t.matrix.premultiply(eg)),Uo.set(0,0,0),this.applyAnchoring(Uo),(s=this.Canvas)!=null&&s.screenspace?Uo.z+=.1:Uo.z+=.01,eg.identity(),eg.setPosition(Uo.x,Uo.y,Uo.z),t.matrix.premultiply(eg),t.matrix.scale(this.gameObject.scale)),this.lastMatrix.copy(this.gameObject.matrix);const i=!0;for(const r of H1(this.gameObject,ta,i,1)){if(r===this||!r.activeAndEnabled)continue;const o=r;o.onParentRectTransformChanged&&o.onParentRectTransformChanged(this)}}applyAnchoring(e){this._lastAnchoring||(this._lastAnchoring=new te);const t=this._lastAnchoring.sub(this._anchoredPosition);this.gameObject.position.x+=t.x,this.gameObject.position.y+=t.y,this._lastAnchoring.copy(this._anchoredPosition),e.x+=this._initialPosition.x-this.gameObject.position.x,e.y+=this._initialPosition.y-this.gameObject.position.y,e.z+=this._initialPosition.z-this.gameObject.position.z;const i=this._parentRectTransform;if(i){let s=0;const r=1-this.anchorMax.y-this.anchorMin.y;s-=i.height*.5*r,e.y+=s;let o=0;const a=1-this.anchorMax.x-this.anchorMin.x;o-=i.width*.5*a,e.x+=o}}applyPivot(e){if(this.pivot&&!this.isRoot()){const t=this.pivot.x-.5;e.x-=t*this.sizeDelta.x*this.gameObject.scale.x;const i=this.pivot.y-.5;e.y-=i*this.sizeDelta.y*this.gameObject.scale.y}}getBasicOptions(){const e={width:this.sizeDelta.x,height:this.sizeDelta.y,offset:0,backgroundOpacity:0,borderWidth:0,borderRadius:0,borderOpacity:0,letterSpacing:-.03};return this.ensureValidSize(e),e}ensureValidSize(e,t=1e-4){return e.width<=0&&(e.width=t),e.height<=0&&(e.height=1e-4),e}createNewBlock(e){e={...this.getBasicOptions(),...e},IS&&console.log(this.name,e);const t=new WT(e);return this._createdBlocks.push(t),t}createNewText(e){IS&&console.log(e),e={...this.getBasicOptions(),...e},IS&&console.log(this.name,e);const t=new gz(e);return this._createdTextBlocks.push(t),t}};let tr=wz;QA([x(te)],tr.prototype,"anchoredPosition",1);QA([x(te)],tr.prototype,"sizeDelta",2);QA([x(te)],tr.prototype,"pivot",2);QA([x(te)],tr.prototype,"anchorMin",2);QA([x(te)],tr.prototype,"anchorMax",2);class Aie extends pz{constructor(e,t={}){super(e),e._simpleState__activeStates=[],e._simpleState__normalStyles={},e._simpleState__states=t,e._simpleState__statesProperties={};for(const i in t)for(const s in t[i])e._simpleState__statesProperties[s]||(e._simpleState__statesProperties[s]=[]),e._simpleState__statesProperties[s].push(i);for(const i of e._components)e._simpleState__statesProperties[i.id]&&(e._simpleState__normalStyles[i.id]=i.inline?i.inline:i._value);e.__overridedSet=e.set,e.set=this.storeSet.bind(e),e.renderStates=this.renderStates.bind(e),e.setupState=this.setupState.bind(e),e.setState=this.setState.bind(e),e.activatePseudoState=this.activatePseudoState.bind(e),e.deactivatePseudoState=this.deactivatePseudoState.bind(e),e.togglePseudoState=this.togglePseudoState.bind(e)}act(){}attach(){}detach(){}setupState(e,t){this._simpleState__states[e]=t;const i=[];for(const s in t)this._simpleState__statesProperties[s]||(this._simpleState__statesProperties[s]=[],i.push(s)),this._simpleState__statesProperties[s].push(e);for(const s of this._components)i.indexOf(s.id)>-1&&(this._simpleState__normalStyles[s.id]=s.inline?s.inline:s._value)}renderStates(){let e={...this._simpleState__normalStyles};for(const t in this._simpleState__states)this._simpleState__activeStates.indexOf(t)>-1&&(e={...e,...this._simpleState__states[t]});this.set(e,!1)}storeSet(e,t=!0){if(t)for(const i in e)this._simpleState__statesProperties[i]&&(this._simpleState__normalStyles[i]=e[i]);this.__overridedSet(e)}activatePseudoState(e){this._simpleState__activeStates.indexOf(e)===-1&&(this._simpleState__activeStates.push(e),this.renderStates())}deactivatePseudoState(e){const t=this._simpleState__activeStates.indexOf(e);t>-1&&(this._simpleState__activeStates.splice(t,1),this.renderStates())}togglePseudoState(e){const t=this._simpleState__activeStates.indexOf(e);t>-1?this._simpleState__activeStates.splice(t,1):this._simpleState__activeStates.push(e),this.renderStates()}setState(e){Array.isArray(e)?this._simpleState__activeStates=e:this._simpleState__activeStates=[e],this.renderStates()}}var vie=Object.defineProperty,yie=Object.getOwnPropertyDescriptor,Sz=(n,e,t,i)=>{for(var s=i>1?void 0:i?yie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&vie(e,t,s),s};class pp extends Me{constructor(){super(...arguments);u(this,"effectColor");u(this,"effectDistance")}}Sz([x(_i)],pp.prototype,"effectColor",2);Sz([x(te)],pp.prototype,"effectDistance",2);var bie=Object.defineProperty,_ie=Object.getOwnPropertyDescriptor,Cz=(n,e,t,i)=>{for(var s=i>1?void 0:i?_ie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&bie(e,t,s),s};const Ty={backgroundColor:new _e(1,1,1),backgroundOpacity:1,borderColor:new _e(1,1,1),borderOpacity:1};var cC;const S0=(cC=class extends ta{constructor(){super(...arguments);u(this,"_alphaFactor",1);u(this,"raycastTarget",!0);u(this,"uiObject",null);u(this,"_color",null);u(this,"_rect",null);u(this,"_stateManager",null);u(this,"_currentlyCreatingPanel",!1)}get isGraphic(){return!0}get color(){return this._color||(this._color=new _i(1,1,1,1)),this._color}set color(e){(!this._color||this._color.r!==e.r||this._color.g!==e.g||this._color.b!==e.b||this._color.alpha!==e.alpha)&&(this._color||(this._color=new _i(1,1,1,1)),this._color.copy(e))}setAlphaFactor(e){this._alphaFactor=e,this.onColorChanged()}get alphaFactor(){return this._alphaFactor}onColorChanged(){this.uiObject&&(Ty.backgroundColor=this._color,Ty.backgroundOpacity=this._color.alpha*this._alphaFactor,this.applyEffects(Ty,this._alphaFactor),this.uiObject.set(Ty),this.markDirty())}get m_Color(){return this._color}get rectTransform(){if(this._rect||(this._rect=se.getComponent(this.gameObject,tr)),!this._rect)throw new Error("Not Supported: Make sure to add a RectTransform component before adding a UI Graphic component.");return this._rect}onParentRectTransformChanged(){var e;(e=this.uiObject)==null||e.set({width:this.rectTransform.width,height:this.rectTransform.height}),this.markDirty()}__internalNewInstanceCreated(){super.__internalNewInstanceCreated(),this._rect=null,this.uiObject=null,this._color&&(this._color=this._color.clone())}setState(e){this.makePanel(),this.uiObject&&(this.uiObject.setState(e),this==null||this.markDirty())}setupState(e){this.makePanel(),this.uiObject&&(this._stateManager||(this._stateManager=new Aie(this.uiObject)),this.uiObject.setupState(e.state,e.attributes))}setOptions(e){this.makePanel(),this.uiObject&&this.uiObject.set(e)}awake(){super.awake(),this.makePanel(),Qd(this,"_color",()=>Tte(this,this.onColorChanged))}onEnable(){var e;super.onEnable(),this.uiObject&&((e=this.rectTransform.shadowComponent)==null||e.add(this.uiObject),this.addShadowComponent(this.uiObject,this.rectTransform))}onDisable(){super.onDisable(),this.uiObject&&this.removeShadowComponent()}makePanel(){if(this.uiObject||this._currentlyCreatingPanel)return;this._currentlyCreatingPanel=!0;const e=.015,t={backgroundColor:this.color,backgroundOpacity:this.color.alpha,offset:e};this.onBeforeCreate(t),this.applyEffects(t),this.onCreate(t),this.controlsChildLayout=!1,this._currentlyCreatingPanel=!1,this.onAfterCreated()}onBeforeCreate(e){}onCreate(e){this.uiObject=this.rectTransform.createNewBlock(e),this.uiObject.name=this.name}onAfterCreated(){}applyEffects(e,t=1){var s;const i=(s=this.gameObject)==null?void 0:s.getComponent(pp);i&&(i.effectDistance&&(e.borderWidth=Math.max(Math.abs(i.effectDistance.x),Math.abs(i.effectDistance.y))),i.effectColor&&(e.borderColor=i.effectColor,e.borderOpacity=i.effectColor.alpha*t))}async setTexture(e){if(this.setOptions({backgroundOpacity:0}),e){if(e.colorSpace===Ze){if(S0.textureCache.has(e))e=S0.textureCache.get(e);else if(!e.isRenderTargetTexture){const t=e.clone();t.colorSpace=pn,S0.textureCache.set(e,t),e=t}}this.setOptions({backgroundImage:e,borderRadius:0,backgroundOpacity:this.color.alpha,backgroundSize:"stretch"})}else this.setOptions({backgroundImage:null,borderRadius:0,backgroundOpacity:this.color.alpha});this.markDirty()}onAfterAddedToScene(){super.onAfterAddedToScene(),this.shadowComponent&&(this.shadowComponent.offset=this.shadowComponent.position.z)}},u(cC,"textureCache",new Map),cC);let Hu=S0;Cz([x(_i)],Hu.prototype,"color",1);Cz([x()],Hu.prototype,"raycastTarget",2);class WA extends Hu{constructor(){super(...arguments);u(this,"_flippedObject",!1)}onAfterCreated(){this.uiObject&&!this._flippedObject&&(this._flippedObject=!0,this.uiObject.scale.y*=-1)}}var xie=Object.defineProperty,wie=Object.getOwnPropertyDescriptor,fx=(n,e,t,i)=>{for(var s=i>1?void 0:i?wie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&xie(e,t,s),s};let nI=class{constructor(){u(this,"texture",null);u(this,"rect")}};fx([x(Ot)],nI.prototype,"texture",2);let gp=class extends WA{constructor(){super(...arguments);u(this,"_sprite");u(this,"pixelsPerUnitMultiplier",1)}set image(t){this.sprite||(this.sprite=new nI),this.sprite.texture=t,this.onAfterCreated()}get image(){return this.sprite?this.sprite.texture:null}get sprite(){return this._sprite}set sprite(t){this._sprite!==t&&(this._sprite=t,this.onAfterCreated())}isBuiltinSprite(){var t,i,s,r,o,a,c,l;switch((i=(t=this.sprite)==null?void 0:t.texture)==null?void 0:i.name){case"InputFieldBackground":case"UISprite":case"Background":case"Knob":return!0}return((o=(r=(s=this.sprite)==null?void 0:s.texture)==null?void 0:r.image)==null?void 0:o.width)===32&&((l=(c=(a=this.sprite)==null?void 0:a.texture)==null?void 0:c.image)==null?void 0:l.height)===32}onBeforeCreate(t){var i,s;super.onBeforeCreate(t),this.isBuiltinSprite()&&(t.borderRadius=5/this.pixelsPerUnitMultiplier,((s=(i=this.sprite)==null?void 0:i.texture)==null?void 0:s.name)==="Knob"&&(t.borderRadius=999))}onAfterCreated(){var t;this.__didAwake&&(super.onAfterCreated(),!this.isBuiltinSprite()&&this.setTexture((t=this.sprite)==null?void 0:t.texture))}};fx([x(nI)],gp.prototype,"sprite",1);fx([x()],gp.prototype,"pixelsPerUnitMultiplier",2);class px extends WA{constructor(){super(...arguments);u(this,"_mainTexture")}get mainTexture(){return this._mainTexture}set mainTexture(t){this._mainTexture!==t&&(this._mainTexture=t,this.onAfterCreated())}onAfterCreated(){this.__didAwake&&(super.onAfterCreated(),this.setTexture(this.mainTexture))}}fx([x(Ot)],px.prototype,"mainTexture",1);var Sie=Object.defineProperty,Cie=Object.getOwnPropertyDescriptor,Yr=(n,e,t,i)=>{for(var s=i>1?void 0:i?Cie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Sie(e,t,s),s};const Dd=re("debugbutton");class Vu{constructor(){u(this,"colorMultiplier");u(this,"disabledColor");u(this,"fadeDuration");u(this,"highlightedColor");u(this,"normalColor");u(this,"pressedColor");u(this,"selectedColor")}}Yr([x()],Vu.prototype,"colorMultiplier",2);Yr([x(_i)],Vu.prototype,"disabledColor",2);Yr([x()],Vu.prototype,"fadeDuration",2);Yr([x(_i)],Vu.prototype,"highlightedColor",2);Yr([x(_i)],Vu.prototype,"normalColor",2);Yr([x(_i)],Vu.prototype,"pressedColor",2);Yr([x(_i)],Vu.prototype,"selectedColor",2);class ll extends Me{constructor(){super(...arguments);u(this,"onClick");u(this,"_isHovered",!1);u(this,"colors");u(this,"transition");u(this,"animationTriggers");u(this,"animator");u(this,"_interactable",!0);u(this,"_requestedAnimatorTrigger");u(this,"_isInit",!1);u(this,"_image")}onPointerEnter(t){var i,s;Dd&&console.log("Button Enter",(i=this.animationTriggers)==null?void 0:i.highlightedTrigger,this.animator),this._isHovered=!0,this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.highlightedTrigger):this.transition===1&&this.colors&&((s=this._image)==null||s.setState("hovered")),this.context.input.setCursorPointer())}onPointerExit(){var t,i;Dd&&console.log("Button Exit",(t=this.animationTriggers)==null?void 0:t.highlightedTrigger,this.animator),this._isHovered=!1,this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.normalTrigger):this.transition===1&&this.colors&&((i=this._image)==null||i.setState("normal")),this.context.input.setCursorNormal())}onPointerDown(t){var i,s;Dd&&console.log("Button Down",(i=this.animationTriggers)==null?void 0:i.highlightedTrigger,this.animator),this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.pressedTrigger):this.transition===1&&this.colors&&((s=this._image)==null||s.setState("pressed")))}onPointerUp(t){var i,s;Dd&&console.warn("Button Up",(i=this.animationTriggers)==null?void 0:i.highlightedTrigger,this.animator,this._isHovered),this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this._isHovered?this.animationTriggers.highlightedTrigger:this.animationTriggers.normalTrigger):this.transition===1&&this.colors&&((s=this._image)==null||s.setState(this._isHovered?"hovered":"normal")))}onPointerClick(t){var i;this.interactable&&t.pointerId===0&&(Dd&&(console.warn("Button Click",this.onClick),_n("CLICKED button "+this.name+" at "+this.context.time.frameCount)),(i=this.onClick)==null||i.invoke())}set interactable(t){this._interactable=t,this._image&&(this._image.setInteractable(t),t?this._image.setState("normal"):this._image.setState("disabled"))}get interactable(){return this._interactable}set_interactable(t){this.interactable=t}awake(){super.awake(),Dd&&console.log(this),this._isInit=!1,this.init()}start(){var t;(t=this._image)==null||t.setInteractable(this.interactable)}onEnable(){super.onEnable()}*setAnimatorTriggerAtEndOfFrame(t){var i;this._requestedAnimatorTrigger=t,yield,yield,this._requestedAnimatorTrigger==t&&((i=this.animator)==null||i.SetTrigger(t))}init(){this._isInit||(this._isInit=!0,this._image=se.getComponent(this.gameObject,gp),this._image&&(this.stateSetup(this._image),this.interactable?this._image.setState("normal"):this._image.setState("disabled")))}stateSetup(t){var p,g,A,v,m;t.setInteractable(this.interactable);const i=this.getFinalColor(t.color,(p=this.colors)==null?void 0:p.normalColor),s={state:"normal",attributes:{backgroundColor:i,backgroundOpacity:i.alpha}};t.setupState(s);const r=this.getFinalColor(t.color,(g=this.colors)==null?void 0:g.highlightedColor),o={state:"hovered",attributes:{backgroundColor:r,backgroundOpacity:r.alpha}};t.setupState(o);const a=this.getFinalColor(t.color,(A=this.colors)==null?void 0:A.pressedColor),c={state:"pressed",attributes:{backgroundColor:a,backgroundOpacity:a.alpha}};t.setupState(c);const l=this.getFinalColor(t.color,(v=this.colors)==null?void 0:v.selectedColor),h={state:"selected",attributes:{backgroundColor:l,backgroundOpacity:l.alpha}};t.setupState(h);const d=this.getFinalColor(t.color,(m=this.colors)==null?void 0:m.disabledColor),f={state:"disabled",attributes:{backgroundColor:d,backgroundOpacity:d.alpha}};t.setupState(f)}getFinalColor(t,i){return i?t.clone().multiply(i):t.clone()}}Yr([x(cs)],ll.prototype,"onClick",2);Yr([x()],ll.prototype,"colors",2);Yr([x()],ll.prototype,"transition",2);Yr([x()],ll.prototype,"animationTriggers",2);Yr([x(Bs)],ll.prototype,"animator",2);Yr([x()],ll.prototype,"interactable",1);var Eie=Object.defineProperty,Mie=Object.getOwnPropertyDescriptor,Tn=(n,e,t,i)=>{for(var s=i>1?void 0:i?Mie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Eie(e,t,s),s};const nO=re("debuguilayout");class Ah{constructor(){u(this,"left",0);u(this,"right",0);u(this,"top",0);u(this,"bottom",0)}get vertical(){return this.top+this.bottom}get horizontal(){return this.left+this.right}}Tn([x()],Ah.prototype,"left",2);Tn([x()],Ah.prototype,"right",2);Tn([x()],Ah.prototype,"top",2);Tn([x()],Ah.prototype,"bottom",2);class Kr extends Me{constructor(){super(...arguments);u(this,"_rectTransform",null);u(this,"_needsUpdate",!1);u(this,"childAlignment",0);u(this,"reverseArrangement",!1);u(this,"spacing",0);u(this,"padding");u(this,"minWidth",0);u(this,"minHeight",0);u(this,"flexibleHeight",0);u(this,"flexibleWidth",0);u(this,"preferredHeight",0);u(this,"preferredWidth",0)}get rectTransform(){return this._rectTransform}onParentRectTransformChanged(t){this._needsUpdate=!0}get isDirty(){return this._needsUpdate}get isLayoutGroup(){return!0}updateLayout(){this._rectTransform&&(nO&&console.warn("Layout Update",this.context.time.frame,this.name),this._needsUpdate=!1,this.onCalculateLayout(this._rectTransform))}start(){this._needsUpdate=!0}onEnable(){nO&&console.log(this.name,this),this._rectTransform=this.gameObject.getComponent(tr);const t=this.gameObject.getComponentInParent(us);t&&t.registerLayoutGroup(this),this._needsUpdate=!0}onDisable(){const t=this.gameObject.getComponentInParent(us);t&&t.unregisterLayoutGroup(this)}set m_Spacing(t){t!==this.spacing&&(this._needsUpdate=!0,this.spacing=t)}get m_Spacing(){return this.spacing}}Tn([x()],Kr.prototype,"childAlignment",2);Tn([x()],Kr.prototype,"reverseArrangement",2);Tn([x()],Kr.prototype,"spacing",2);Tn([x(Ah)],Kr.prototype,"padding",2);Tn([x()],Kr.prototype,"minWidth",2);Tn([x()],Kr.prototype,"minHeight",2);Tn([x()],Kr.prototype,"flexibleHeight",2);Tn([x()],Kr.prototype,"flexibleWidth",2);Tn([x()],Kr.prototype,"preferredHeight",2);Tn([x()],Kr.prototype,"preferredWidth",2);class vh extends Kr{constructor(){super(...arguments);u(this,"childControlHeight",!0);u(this,"childControlWidth",!0);u(this,"childForceExpandHeight",!1);u(this,"childForceExpandWidth",!1);u(this,"childScaleHeight",!1);u(this,"childScaleWidth",!1)}onCalculateLayout(t){var R;const i=this.primaryAxis,s=t.width;let r=s;const o=t.height;let a=o;r-=this.padding.horizontal,a-=this.padding.vertical,i==="x"?this.padding.horizontal:this.padding.vertical;const c=i==="x",l=c?"y":"x",h=c?this.childControlWidth:this.childControlHeight,d=c?this.childControlHeight:this.childControlWidth,f=c?this.childForceExpandWidth:this.childForceExpandHeight,p=c?this.childForceExpandHeight:this.childForceExpandWidth,g=c?a:r,A=c?s:o,v=.5*(c?this.childAlignment%3:Math.floor(this.childAlignment/3));let m=0;c?m+=this.padding.left:m+=this.padding.top;let b=0,y=0;for(let E=0;E<this.gameObject.children.length;E++){const T=this.gameObject.children[E],O=se.getComponent(T,tr);O!=null&&O.activeAndEnabled&&(y+=1,c?b+=O.width:b+=O.height)}let _=0;const C=this.spacing*(y-1);if(f||h){let E=0;c?E=r-=C:E=a-=C,y>0&&(_=E/y)}let M=0;M+=this.padding.left,M-=this.padding.right,v!==0&&(m=A-b,m*=v,m-=C*v,c?(m-=this.padding.right*v,m+=this.padding.left*(1-v),m<this.padding.left&&(m=this.padding.left)):(m-=this.padding.bottom*v,m+=this.padding.top*(1-v),m<this.padding.top&&(m=this.padding.top)));let I=1;for(let E=0;E<this.gameObject.children.length;E++){const T=this.gameObject.children[E],O=se.getComponent(T,tr);if(O!=null&&O.activeAndEnabled){(R=O.pivot)==null||R.set(.5,.5),O.anchorMin.set(0,1),O.anchorMax.set(0,1);const K=s*.5+M*.5;O.anchoredPosition.x!==K&&(O.anchoredPosition.x=K);const H=o*-.5;O.anchoredPosition.y!==H&&(O.anchoredPosition.y=H),p&&d&&O.sizeDelta[l]!==g&&(O.sizeDelta[l]=g),f&&h&&O.sizeDelta[i]!==_&&(O.sizeDelta[i]=_);const V=c?O.width:O.height,Y=V*.5;if(m+=Y,f){const L=_*I-_*.5;L>m&&(m=L-_*.5+V+this.padding.left,m-=Y)}let N=m;i==="y"&&(N=-N),O.anchoredPosition[i]!==N&&(O.anchoredPosition[i]=N),m+=Y,m+=this.spacing,I+=1}}}}Tn([x()],vh.prototype,"childControlHeight",2);Tn([x()],vh.prototype,"childControlWidth",2);Tn([x()],vh.prototype,"childForceExpandHeight",2);Tn([x()],vh.prototype,"childForceExpandWidth",2);Tn([x()],vh.prototype,"childScaleHeight",2);Tn([x()],vh.prototype,"childScaleWidth",2);class sI extends vh{get primaryAxis(){return"y"}}class rI extends vh{get primaryAxis(){return"x"}}class oI extends Kr{onCalculateLayout(){}}var Tie=Object.defineProperty,Iie=Object.getOwnPropertyDescriptor,Ka=(n,e,t,i)=>{for(var s=i>1?void 0:i?Iie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Tie(e,t,s),s},Ez=(n=>(n[n.ScreenSpaceOverlay=0]="ScreenSpaceOverlay",n[n.ScreenSpaceCamera=1]="ScreenSpaceCamera",n[n.WorldSpace=2]="WorldSpace",n[n.Undefined=-1]="Undefined",n))(Ez||{});const PS=re("debuguilayout"),Mz=class extends kA{constructor(){super(...arguments);u(this,"_renderOnTop");u(this,"_depthWrite",!1);u(this,"_doubleSided",!0);u(this,"_castShadows",!1);u(this,"_receiveShadows",!1);u(this,"_renderMode",-1);u(this,"_rootCanvas");u(this,"_scaleFactor",1);u(this,"worldCamera");u(this,"planeDistance",-1);u(this,"_boundRenderSettingsChanged",this.onRenderSettingsChanged.bind(this));u(this,"previousParent",null);u(this,"_lastMatrixWorld",null);u(this,"_rectTransforms",[]);u(this,"_layoutGroups",new Map);u(this,"onBeforeRenderRoutine",()=>{var e,t,i,s;if(this.context.isInVR){this.onUpdateRenderMode(),this.handleLayoutUpdates(),(e=this.shadowComponent)==null||e.updateMatrixWorld(!0),(t=this.shadowComponent)==null||t.updateWorldMatrix(!0,!0),qs.ensureUpdateMeshUI(CS,this.context);return}this.previousParent=this.gameObject.parent,this.renderOnTop||this.screenspace?this.gameObject.removeFromParent():(this.onUpdateRenderMode(),this.handleLayoutUpdates(),(i=this.shadowComponent)==null||i.updateMatrixWorld(!0),(s=this.shadowComponent)==null||s.updateWorldMatrix(!0,!0),qs.ensureUpdateMeshUI(CS,this.context))});u(this,"onAfterRenderRoutine",()=>{var e,t;if(!this.context.isInVR){if((this.screenspace||this.renderOnTop)&&this.previousParent&&this.context.mainCamera){if(this.screenspace){const r=this.context.mainCamera;r==null||r.add(this.gameObject)}else this.previousParent.add(this.gameObject);const i=this.context.renderer.autoClear,s=this.context.renderer.autoClearColor;this.context.renderer.autoClear=!1,this.context.renderer.autoClearColor=!1,this.context.renderer.clearDepth(),this.onUpdateRenderMode(!0),this.handleLayoutUpdates(),(e=this.shadowComponent)==null||e.updateMatrixWorld(!0),qs.ensureUpdateMeshUI(CS,this.context),this.context.renderer.render(this.gameObject,this.context.mainCamera),this.context.renderer.autoClear=i,this.context.renderer.autoClearColor=s,this.previousParent.add(this.gameObject)}(t=this._lastMatrixWorld)==null||t.copy(this.gameObject.matrixWorld)}});u(this,"_updateRenderSettingsRoutine");u(this,"_activeRenderMode",-1);u(this,"_lastWidth",-1);u(this,"_lastHeight",-1)}get isCanvas(){return!0}get screenspace(){return this.renderMode!==2}set renderOnTop(e){e!==this._renderOnTop&&(this._renderOnTop=e,this.onRenderSettingsChanged())}get renderOnTop(){return this._renderOnTop!==void 0?this._renderOnTop:!!(this.screenspace&&this._renderMode===0)}set depthWrite(e){this._depthWrite!==e&&(this._depthWrite=e,this.onRenderSettingsChanged())}get depthWrite(){return this._depthWrite}set doubleSided(e){this._doubleSided!==e&&(this._doubleSided=e,this.onRenderSettingsChanged())}get doubleSided(){return this._doubleSided}set castShadows(e){this._castShadows!==e&&(this._castShadows=e,this.onRenderSettingsChanged())}get castShadows(){return this._castShadows}set receiveShadows(e){this._receiveShadows!==e&&(this._receiveShadows=e,this.onRenderSettingsChanged())}get receiveShadows(){return this._receiveShadows}get renderMode(){return this._renderMode}set renderMode(e){this._renderMode!==e&&(this._renderMode=e,this.onRenderSettingsChanged())}set rootCanvas(e){this._rootCanvas instanceof Mz||(this._rootCanvas=e)}get rootCanvas(){return this._rootCanvas}get scaleFactor(){return this._scaleFactor}set scaleFactor(e){this._scaleFactor=e}awake(){var e;this.shadowComponent=this.gameObject,this.previousParent=this.gameObject.parent,PS&&console.log("Canvas.Awake()",((e=this.previousParent)==null?void 0:e.name)+"/"+this.gameObject.name),super.awake()}start(){this.onUpdateRenderMode()}onEnable(){super.onEnable(),this._updateRenderSettingsRoutine=void 0,this._lastMatrixWorld=new Re,this.onUpdateRenderMode(),document.addEventListener("resize",this._boundRenderSettingsChanged),this.context.pre_render_callbacks.push(this.onBeforeRenderRoutine),this.context.post_render_callbacks.push(this.onAfterRenderRoutine)}onDisable(){super.onDisable(),document.removeEventListener("resize",this._boundRenderSettingsChanged);const e=this.context.pre_render_callbacks.indexOf(this.onBeforeRenderRoutine);e!==-1&&this.context.pre_render_callbacks.splice(e,1);const t=this.context.post_render_callbacks.indexOf(this.onAfterRenderRoutine);t!==-1&&this.context.post_render_callbacks.splice(t,1)}registerTransform(e){this._rectTransforms.push(e)}unregisterTransform(e){const t=this._rectTransforms.indexOf(e);t!==-1&&this._rectTransforms.splice(t,1)}registerLayoutGroup(e){const t=e.gameObject;this._layoutGroups.set(t,e)}unregisterLayoutGroup(e){const t=e.gameObject;this._layoutGroups.delete(t)}handleLayoutUpdates(){this._lastMatrixWorld===null&&(this._lastMatrixWorld=new Re);const e=!this._lastMatrixWorld.equals(this.gameObject.matrixWorld);PS&&e&&console.log("Canvas Layout changed",this.context.time.frameCount,this.name);const t=!1;for(const i of this._rectTransforms){e&&i.markDirty();let s=this._layoutGroups.get(i.gameObject);i.isDirty&&!s&&(s=i.gameObject.getComponentInParent(Kr)),(i.isDirty||s!=null&&s.isDirty)&&(PS&&!t&&console.log("CANVAS UPDATE ### "+i.name+" ##################################### "+this.context.time.frame),s==null||s.updateLayout(),i.updateTransform())}}applyRenderSettings(){this.onRenderSettingsChanged()}onRenderSettingsChanged(){this._updateRenderSettingsRoutine||(this._updateRenderSettingsRoutine=this.startCoroutine(this._updateRenderSettingsDelayed(),xr.OnBeforeRender))}*_updateRenderSettingsDelayed(){if(yield,this._updateRenderSettingsRoutine=void 0,this.shadowComponent){this.onUpdateRenderMode(),bb(this.shadowComponent,this);for(const e of se.getComponentsInChildren(this.gameObject,ta))bb(e.shadowComponent,this)}}onUpdateRenderMode(e=!1){if(!e&&this._renderMode===this._activeRenderMode&&this._lastWidth===this.context.domWidth&&this._lastHeight===this.context.domHeight)return;this._activeRenderMode=this._renderMode;let t=this.context.mainCameraComponent,i=10;switch(t&&t.nearClipPlane>0&&t.farClipPlane>0&&(i=tt.lerp(t.nearClipPlane,t.farClipPlane,.15)),this._renderMode===1&&(this.worldCamera&&(t=this.worldCamera),this.planeDistance>0&&(i=this.planeDistance)),this._renderMode){case 0:case 1:if(this._lastWidth=this.context.domWidth,this._lastHeight=this.context.domHeight,!t)return;const s=i+.01;this.gameObject.position.x=0,this.gameObject.position.y=0,this.gameObject.position.z=-s,this.gameObject.quaternion.identity();const r=this.gameObject.getComponent(tr);let o=!1;r.sizeDelta.x!==this.context.domWidth&&(o=!0),r.sizeDelta.y!==this.context.domHeight&&(o=!0);const a=t.fieldOfView*Math.PI/180,c=2*Math.tan(a/2)*Math.abs(s);this.gameObject.scale.x=c/this.context.domHeight,this.gameObject.scale.y=c/this.context.domHeight,this.gameObject.scale.z=.01,o&&(r.sizeDelta.x=this.context.domWidth,r.sizeDelta.y=this.context.domHeight,r==null||r.markDirty());break;case 2:this._lastWidth=-1,this._lastHeight=-1;break}}};let us=Mz;Ka([x()],us.prototype,"renderOnTop",1);Ka([x()],us.prototype,"depthWrite",1);Ka([x()],us.prototype,"doubleSided",1);Ka([x()],us.prototype,"castShadows",1);Ka([x()],us.prototype,"receiveShadows",1);Ka([x()],us.prototype,"renderMode",1);Ka([x(us)],us.prototype,"rootCanvas",1);Ka([x()],us.prototype,"scaleFactor",1);Ka([x(Oi)],us.prototype,"worldCamera",2);Ka([x()],us.prototype,"planeDistance",2);var Rie=Object.defineProperty,Pie=Object.getOwnPropertyDescriptor,aI=(n,e,t,i)=>{for(var s=i>1?void 0:i?Pie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Rie(e,t,s),s};class oh extends Me{constructor(){super(...arguments);u(this,"_alpha",1);u(this,"interactable",!0);u(this,"blocksRaycasts",!0);u(this,"_isDirty",!1);u(this,"_buffer",[])}get alpha(){return this._alpha}set alpha(t){t!==this._alpha&&(this._alpha=t,this.markDirty())}get isCanvasGroup(){return!0}markDirty(){this._isDirty||(this._isDirty=!0,this.startCoroutine(this.applyChangesDelayed(),xr.OnBeforeRender))}*applyChangesDelayed(){this._isDirty=!1,this.applyChangesNow()}applyChangesNow(){for(const t of se.getComponentsInChildren(this.gameObject,ta,this._buffer)){const i=t;i.setAlphaFactor&&i.setAlphaFactor(this._alpha)}}}aI([x()],oh.prototype,"alpha",1);aI([x()],oh.prototype,"interactable",2);aI([x()],oh.prototype,"blocksRaycasts",2);var Bie=Object.defineProperty,Die=Object.getOwnPropertyDescriptor,ki=(n,e,t,i)=>{for(var s=i>1?void 0:i?Die(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Bie(e,t,s),s};class Qu extends Me{constructor(){super(...arguments);u(this,"object");u(this,"target");u(this,"duration",1);u(this,"relativeMotion",!1);u(this,"coroutine",null);u(this,"targetPos",new S);u(this,"targetRot",new Se);u(this,"targetScale",new S)}*moveToTarget(){if(!this.target||!this.object)return;const t=wt(this.object).clone(),i=wt(this.target).clone(),s=Fn(this.object).clone(),r=Fn(this.target).clone(),o=qn(this.object).clone(),a=qn(this.target).clone(),c=t.distanceTo(i),l=s.angleTo(r),h=o.distanceTo(a);if(c<.01&&l<.01&&h<.01){fn(this.object,i),_r(this.object,r),rE(this.object,a),this.coroutine=null;return}let d=0,f=0;for(;d<1;)d+=this.context.time.deltaTime/this.duration,d>1&&(d=1),f=d<.5?4*d*d*d:1-Math.pow(-2*d+2,3)/2,this.targetPos.lerpVectors(t,i,f),this.targetRot.slerpQuaternions(s,r,f),this.targetScale.lerpVectors(o,a,f),fn(this.object,this.targetPos),_r(this.object,this.targetRot),rE(this.object,this.targetScale),yield;this.coroutine=null}*moveRelative(){if(!this.target||!this.object)return;const t=this.object.position.clone(),i=this.object.quaternion.clone(),s=this.object.scale.clone(),r=this.target.position.clone(),o=this.target.quaternion.clone(),a=this.target.scale.clone();r.applyQuaternion(this.object.quaternion),this.targetPos.copy(this.object.position).add(r),this.targetRot.copy(this.object.quaternion).multiply(o),this.targetScale.copy(this.object.scale).multiply(a);let c=0,l=0;for(;c<1;)c+=this.context.time.deltaTime/this.duration,c>1&&(c=1),l=c<.5?4*c*c*c:1-Math.pow(-2*c+2,3)/2,this.object.position.lerpVectors(t,this.targetPos,l),this.object.quaternion.slerpQuaternions(i,this.targetRot,l),this.object.scale.lerpVectors(s,this.targetScale,l),yield;this.coroutine=null}onPointerClick(){this.coroutine&&this.stopCoroutine(this.coroutine),this.relativeMotion?this.coroutine=this.startCoroutine(this.moveRelative()):this.coroutine=this.startCoroutine(this.moveToTarget())}beforeCreateDocument(t){var i;if(this.target&&this.object&&this.gameObject){const s=new ls("Move to "+((i=this.target)==null?void 0:i.name),yr.tapTrigger(this.gameObject),di.transformAction(this.object,this.target,this.duration,this.relativeMotion?UE.Relative:UE.Absolute));t.addBehavior(s)}}}ki([x(Te)],Qu.prototype,"object",2);ki([x(Te)],Qu.prototype,"target",2);ki([x()],Qu.prototype,"duration",2);ki([x()],Qu.prototype,"relativeMotion",2);var qy;const vc=(qy=class extends Me{constructor(){super(...arguments);u(this,"materialToSwitch");u(this,"variantMaterial");u(this,"fadeDuration",0);u(this,"_objectsWithThisMaterial",[]);u(this,"selfModel");u(this,"targetModels")}awake(){if(this.variantMaterial&&this.materialToSwitch){const e=se.findObjectsOfType(Hi);for(const t of e)for(let i=0;i<t.sharedMaterials.length;i++){const s=t.sharedMaterials[i];if(s===this.materialToSwitch){if(t.gameObject instanceof ye)this._objectsWithThisMaterial.push(t.gameObject);else if(t.gameObject instanceof zr)for(const r of t.gameObject.children)r instanceof ye&&r.material===s&&this._objectsWithThisMaterial.push(r);break}}}}onPointerClick(){if(this.variantMaterial)for(let e=0;e<this._objectsWithThisMaterial.length;e++){const t=this._objectsWithThisMaterial[e];t.material=this.variantMaterial}}async beforeCreateDocument(e,t){this.targetModels=[],vc._materialTriggersPerId={},vc.variantSwitchIndex=0,this.materialToSwitch&&await Or.assignTextureLOD(this.context,this.sourceId,this.materialToSwitch,0),this.variantMaterial&&await Or.assignTextureLOD(this.context,this.sourceId,this.variantMaterial,0)}createBehaviours(e,t,i){this._objectsWithThisMaterial.find(r=>r.uuid===t.uuid)&&this.targetModels.push(t),this.gameObject.uuid===t.uuid&&(this.selfModel=t,this.materialToSwitch&&(vc._materialTriggersPerId[this.materialToSwitch.uuid]||(vc._materialTriggersPerId[this.materialToSwitch.uuid]=[]),vc._materialTriggersPerId[this.materialToSwitch.uuid].push(this)))}afterCreateDocument(e,t){if(!this.materialToSwitch)return;const i=vc._materialTriggersPerId[this.materialToSwitch.uuid];if(i){const s={};for(const o of i){const a=o.createVariants();a&&a.length>0&&(s[o.selfModel.uuid]=a)}const r=[];for(const o of i){for(const a in s)a!==o.selfModel.uuid&&r.push(s[a]);o.createAndAttachBehaviors(e,s[o.selfModel.uuid],r)}}delete vc._materialTriggersPerId[this.materialToSwitch.uuid]}createAndAttachBehaviors(e,t,i){const s=[],r=[],o=Math.max(0,this.fadeDuration);for(const a of this.targetModels){const c=di.fadeAction(a,o,!1);r.push(c)}for(const a of i)r.push(di.fadeAction(a,o,!1));for(const a of t)s.push(di.fadeAction(a,o,!1)),r.push(di.fadeAction(a,o,!0));e.addBehavior(new ls("Select "+this.selfModel.name,yr.tapTrigger(this.selfModel),di.parallel(...r))),e.addBehavior(new ls("Start hidden "+this.selfModel.name,yr.sceneStartTrigger(),di.parallel(...s)))}createVariants(){if(!this.variantMaterial)return null;const e=[];for(const t of this.targetModels){const i=t.clone();i.name+=" variant_"+this.variantMaterial.name+"_"+vc.variantSwitchIndex++,i.name=i.name.replace(/\s/g,"_"),i.material=this.variantMaterial,i.geometry=t.geometry,i.matrix=t.matrix,(!t.parent||!t.parent.isEmpty())&&gr.createEmptyParent(t),t.parent&&t.parent.add(i),e.push(i)}return e}},u(qy,"_materialTriggersPerId",{}),u(qy,"variantSwitchIndex",0),qy);let mp=vc;ki([x(kt)],mp.prototype,"materialToSwitch",2);ki([x(kt)],mp.prototype,"variantMaterial",2);ki([x()],mp.prototype,"fadeDuration",2);class Ap extends Me{constructor(){super(...arguments);u(this,"target");u(this,"toggleOnClick",!1);u(this,"targetState",!0);u(this,"hideSelf",!0);u(this,"selfModel");u(this,"otherModel");u(this,"toggleModel");u(this,"stateBeforeCreatingDocument",!1)}onPointerClick(){!this.toggleOnClick&&this.hideSelf&&(this.gameObject.visible=!1),this.target&&(this.target.visible=this.toggleOnClick?!this.target.visible:this.targetState)}createBehaviours(t,i,s){i.uuid===this.gameObject.uuid&&(this.selfModel=i)}beforeCreateDocument(){this.stateBeforeCreatingDocument=this.gameObject.visible,this.gameObject.visible=!0}afterCreateDocument(t,i){if(this.target){if(this.otherModel=i.document.findById(this.target.uuid),this.selfModel&&this.otherModel){let s=this.hideSelf;this.targetState,this.toggleOnClick&&(s=!0,this.target.visible,(!this.selfModel.parent||this.selfModel.parent.isEmpty())&&ON.createEmptyParent(this.selfModel),this.toggleModel=this.selfModel.clone(),this.toggleModel.name+="_toggle",this.selfModel.parent.add(this.toggleModel));const r=[];if(s&&r.push(di.fadeAction(this.selfModel,0,!1)),this.toggleModel&&r.push(di.fadeAction(this.toggleModel,0,!0)),r.push(di.fadeAction(this.otherModel,0,this.targetState)),t.addBehavior(new ls("Toggle_"+this.selfModel.name+"_hideSelf",yr.tapTrigger(this.selfModel),di.sequence(...r))),this.toggleOnClick&&this.toggleModel){const o=[];o.push(di.fadeAction(this.toggleModel,0,!1)),o.push(di.fadeAction(this.selfModel,0,!0)),o.push(di.fadeAction(this.otherModel,0,!this.targetState)),t.addBehavior(new ls("Toggle_"+this.selfModel.name+"_toggleSelf",yr.tapTrigger(this.toggleModel),di.sequence(...o))),t.addBehavior(new ls("HideOnStart_"+this.gameObject.name,yr.sceneStartTrigger(),di.fadeAction(this.toggleModel,0,!1)))}}this.gameObject.visible=this.stateBeforeCreatingDocument}}}ki([x(Te)],Ap.prototype,"target",2);ki([x()],Ap.prototype,"targetState",2);ki([x()],Ap.prototype,"hideSelf",2);class cI extends Me{start(){this.gameObject.visible=!1}createBehaviours(e,t,i){t.uuid===this.gameObject.uuid&&e.addBehavior(new ls("HideOnStart_"+this.gameObject.name,yr.sceneStartTrigger(),di.fadeAction(t,0,!1)))}beforeCreateDocument(){this.gameObject.visible=!0}afterCreateDocument(){this.gameObject.visible=!1}}class vp extends Me{constructor(){super(...arguments);u(this,"target");u(this,"duration",.5);u(this,"motionType",uT.bounce)}beforeCreateDocument(){}createBehaviours(t,i,s){if(this.target&&i.uuid===this.gameObject.uuid){const r=new ls("emphasize "+this.name,yr.tapTrigger(this.gameObject),di.emphasize(this.target,this.duration,this.motionType,void 0,"basic"));t.addBehavior(r)}}afterCreateDocument(t,i){}}ki([x()],vp.prototype,"target",2);ki([x()],vp.prototype,"duration",2);ki([x()],vp.prototype,"motionType",2);class yp extends Me{constructor(){super(...arguments);u(this,"target");u(this,"clip","");u(this,"toggleOnClick",!1)}onPointerClick(){if(!(!this.target&&!this.clip)){if(!this.target){const t=this.gameObject.addNewComponent(Cn);t&&(t.spatialBlend=1,t.volume=1,t.loop=!1,this.target=t)}this.target&&(this.target.isPlaying&&this.toggleOnClick?this.target.stop():(!this.toggleOnClick&&this.target.isPlaying&&this.target.stop(),this.clip?this.target.play(this.clip):this.target.play()))}}createBehaviours(t,i,s){if(!(!this.target&&!this.clip)&&i.uuid===this.gameObject.uuid){const r=this.clip?this.clip:this.target?this.target.clip:void 0;if(!r)return;const o=this.target?this.target.gameObject:this.gameObject,a=r.split("/").pop(),c=this.target?this.target.volume:1,l=this.target&&this.target.spatialBlend==0?NE.NonSpatial:NE.Spatial,h=new ls("playAudio "+this.name,yr.tapTrigger(this.gameObject),di.playAudioAction(o,"audio/"+a,zN.Play,c,l));t.addBehavior(h)}}async afterSerialize(t,i){if(!this.target&&!this.clip)return;const s=this.clip?this.clip:this.target?this.target.clip:void 0;if(!s)return;const r=s.split("/").pop(),c=await(await(await fetch(this.clip)).blob()).arrayBuffer(),l=new Uint8Array(c);i.files["audio/"+r]=l}}ki([x(Cn)],yp.prototype,"target",2);ki([x(URL)],yp.prototype,"clip",2);ki([x()],yp.prototype,"toggleOnClick",2);var lC;const Wd=(lC=class extends Me{constructor(){super(...arguments);u(this,"target");u(this,"animator");u(this,"stateName");u(this,"stateNameAfterPlaying");u(this,"loopAfterPlaying",!1);u(this,"selfModel");u(this,"stateAnimationModel");u(this,"stateAnimation");u(this,"stateAfterPlayingAnimationModel");u(this,"stateAfterPlayingAnimation")}onPointerClick(){var e;this.target&&this.stateName&&((e=this.animator)==null||e.play(this.stateName,0,0,.1))}createBehaviours(e,t,i){t.uuid===this.gameObject.uuid&&(this.selfModel=t)}onAfterHierarchy(){Wd.animationActions=[]}afterCreateDocument(e,t){if(!this.stateAnimation||!this.stateAnimationModel)return;t.document.traverse(s=>{var r,o;if(s.uuid===((r=this.target)==null?void 0:r.uuid)&&this.stateAnimation){const a=[];let c=Wd.animationActions.find(h=>h.affectedObjects==s&&h.start==this.stateAnimation.start&&h.duration==this.stateAnimation.duration);if(c||(c=di.startAnimationAction(s,this.stateAnimation.start,this.stateAnimation.duration),Wd.animationActions.push(c)),a.push(c),this.stateAfterPlayingAnimation&&this.stateAfterPlayingAnimationModel){let h=Wd.animationActions.find(f=>f.affectedObjects==s&&f.start==this.stateAfterPlayingAnimation.start&&f.duration==this.stateAfterPlayingAnimation.duration);h||(h=di.startAnimationAction(s,this.stateAfterPlayingAnimation.start,this.stateAfterPlayingAnimation.duration),Wd.animationActions.push(h));const d=di.sequence(h);this.loopAfterPlaying&&d.makeLooping(),a.push(d)}const l=new ls("tap "+this.name+" for "+this.stateName+" on "+((o=this.target)==null?void 0:o.name),yr.tapTrigger(this.selfModel),di.sequence(...a));e.addBehavior(l)}})}createAnimation(e,t,i){var s,r,o,a,c;if(this.target&&this.animator){const l=(r=(s=this.animator)==null?void 0:s.runtimeAnimatorController)==null?void 0:r.findState(this.stateName);if(!((o=l==null?void 0:l.motion)!=null&&o.clip)){bi()&&console.warn("No clip found for state "+this.stateName);return}this.stateAnimationModel=t,this.stateAnimation=e.registerAnimation(this.target,l==null?void 0:l.motion.clip);const h=(c=(a=this.animator)==null?void 0:a.runtimeAnimatorController)==null?void 0:c.findState(this.stateNameAfterPlaying);this.stateAfterPlayingAnimationModel=t,this.stateAfterPlayingAnimation=e.registerAnimation(this.target,h==null?void 0:h.motion.clip)}}},u(lC,"animationActions",[]),lC);let yh=Wd;ki([x(Te)],yh.prototype,"target",2);ki([x(Bs)],yh.prototype,"animator",2);ki([x()],yh.prototype,"stateName",2);ki([x()],yh.prototype,"stateNameAfterPlaying",2);ki([x()],yh.prototype,"loopAfterPlaying",2);class bp extends Me{constructor(){super(...arguments);u(this,"target")}getType(){}getDuration(){}}ki([x(Te)],bp.prototype,"target",2);class jA extends Me{constructor(){super(...arguments);u(this,"target")}}ki([x(bp)],jA.prototype,"target",2);class XA extends bp{constructor(){super(...arguments);u(this,"type",1);u(this,"duration",1)}getType(){switch(this.type){case 1:return"hide";case 0:return"show"}}getDuration(){return this.duration}}ki([x()],XA.prototype,"type",2);ki([x()],XA.prototype,"duration",2);class lI extends jA{}var Oie=Object.defineProperty,kie=Object.getOwnPropertyDescriptor,hl=(n,e,t,i)=>{for(var s=i>1?void 0:i?kie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Oie(e,t,s),s};class Wu extends Me{constructor(){super(...arguments);u(this,"center",new S(0,0,0));u(this,"radius",.5);u(this,"height",2);u(this,"_rigidbody",null);u(this,"_activeGroundCollisions")}get rigidbody(){return this._rigidbody?this._rigidbody:(this._rigidbody=this.gameObject.getComponent(Yi),this._rigidbody||(this._rigidbody=this.gameObject.addNewComponent(Yi)),this.rigidbody)}awake(){this._activeGroundCollisions=new Set}onEnable(){const t=this.rigidbody;let i=this.gameObject.getComponent(rh);i||(i=this.gameObject.addNewComponent(rh)),i.center.copy(this.center),i.radius=this.radius,i.height=this.height,this.gameObject.rotation.x=0,this.gameObject.rotation.z=0,t.lockRotationX=!0,t.lockRotationY=!0,t.lockRotationZ=!0}move(t){this.gameObject.position.add(t)}onCollisionEnter(t){for(const i of t.contacts)if(i.normal.y>.1){this._activeGroundCollisions.add(t);break}}onCollisionExit(t){this._activeGroundCollisions.delete(t)}get isGrounded(){return this._activeGroundCollisions.size>0}}hl([x(S)],Wu.prototype,"center",2);hl([x()],Wu.prototype,"radius",2);hl([x()],Wu.prototype,"height",2);class ul extends Me{constructor(){super(...arguments);u(this,"controller");u(this,"movementSpeed",2);u(this,"rotationSpeed",2);u(this,"jumpForce",1);u(this,"doubleJumpForce",2);u(this,"animator");u(this,"lookForward",!0);u(this,"lookInput",new te(0,0));u(this,"moveInput",new te(0,0));u(this,"jumpInput",!1);u(this,"_currentSpeed",new S(0,0,0));u(this,"_currentAngularSpeed",new S(0,0,0));u(this,"_temp",new S(0,0,0));u(this,"_jumpCount",0);u(this,"_currentRotation");u(this,"_raycastOptions",new sa)}awake(){this._currentRotation=new Se}update(){const t=this.context.input;t.isKeyPressed("KeyW")?this.moveInput.y+=1:t.isKeyPressed("KeyS")&&(this.moveInput.y-=1),t.isKeyPressed("KeyD")?this.lookInput.x+=1:t.isKeyPressed("KeyA")&&(this.lookInput.x-=1),this.jumpInput||(this.jumpInput=t.isKeyDown("Space"))}move(t){this.moveInput.add(t)}look(t){this.lookInput.add(t)}jump(){this.jumpInput=!0}onBeforeRender(){this.handleInput(this.moveInput,this.lookInput,this.jumpInput),this.lookInput.set(0,0),this.moveInput.set(0,0),this.jumpInput=!1}handleInput(t,i,s){var r,o,a,c,l,h,d,f,p,g,A;if((r=this.controller)!=null&&r.isGrounded&&(this._jumpCount=0,this.doubleJumpForce>0&&((o=this.animator)==null||o.setBool("doubleJump",!1))),this._currentSpeed.z+=t.y*this.movementSpeed*this.context.time.deltaTime,(a=this.animator)==null||a.setBool("running",t.length()>.01),(l=this.animator)==null||l.setBool("jumping",((c=this.controller)==null?void 0:c.isGrounded)===!0&&s),this._temp.copy(this._currentSpeed),this._temp.applyQuaternion(this.gameObject.quaternion),this.controller?this.controller.move(this._temp):this.gameObject.position.add(this._temp),this._currentAngularSpeed.y+=tt.toRadians(-i.x*this.rotationSpeed)*this.context.time.deltaTime,this.lookForward&&Math.abs(this._currentAngularSpeed.y)<.01){const v=this.context.mainCameraComponent.forward;v.y=0,v.normalize(),this._currentRotation.setFromUnitVectors(new S(0,0,1),v),this.gameObject.quaternion.slerp(this._currentRotation,this.context.time.deltaTime*10)}if(this.gameObject.rotateY(this._currentAngularSpeed.y),this._currentSpeed.multiplyScalar(1-this.context.time.deltaTime*10),this._currentAngularSpeed.y*=1-this.context.time.deltaTime*10,this.controller&&s&&this.jumpForce>0){let v=(h=this.controller)==null?void 0:h.isGrounded;if(this.doubleJumpForce>0&&!((d=this.controller)!=null&&d.isGrounded)&&this._jumpCount===1&&(v=!0,(f=this.animator)==null||f.setBool("doubleJump",!0)),v){this._jumpCount+=1;const m=this.controller.rigidbody,b=this._jumpCount===2?this.doubleJumpForce:this.jumpForce;m.applyImpulse(new S(0,1,0).multiplyScalar(b))}}if(this.controller){const v=(p=this.controller)==null?void 0:p.rigidbody.getVelocity().y;if(v<-1){this._raycastOptions.ray||(this._raycastOptions.ray=new ja),this._raycastOptions.ray.origin.copy(wt(this.gameObject)),this._raycastOptions.ray.direction.set(0,-1,0);const m=this.layer;this.gameObject.layers.disableAll(),this.gameObject.layers.set(2);const b=this.context.physics.raycast(this._raycastOptions);this.gameObject.layers.set(m),(b.length&&b[0].distance>2||v<-10)&&((g=this.animator)==null||g.setBool("falling",!0))}else(A=this.animator)==null||A.setBool("falling",!1)}}}hl([x(Wu)],ul.prototype,"controller",2);hl([x()],ul.prototype,"movementSpeed",2);hl([x()],ul.prototype,"rotationSpeed",2);hl([x()],ul.prototype,"jumpForce",2);hl([x()],ul.prototype,"doubleJumpForce",2);hl([x(Bs)],ul.prototype,"animator",2);var Lie=Object.defineProperty,Fie=Object.getOwnPropertyDescriptor,Uie=(n,e,t,i)=>{for(var s=i>1?void 0:i?Fie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Lie(e,t,s),s};class qA extends Os{constructor(){super(...arguments);u(this,"intensity")}get typeName(){return"ChromaticAberration"}init(){this.intensity.defaultValue=0}onCreateEffect(){const t=new BU;return t.offset=new te(0,0),t.radialModulation=!0,t.modulationOffset=.15,this.intensity.valueProcessor=i=>i*.02,this.intensity.onValueChanged=i=>{t.offset.x=-i,t.offset.y=i},t}}Uie([x(Rt)],qA.prototype,"intensity",2);Ro("ChromaticAberration",qA);var Nie=Object.defineProperty,zie=Object.getOwnPropertyDescriptor,gx=(n,e,t,i)=>{for(var s=i>1?void 0:i?zie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Nie(e,t,s),s};class bh extends Os{constructor(){super(...arguments);u(this,"postExposure");u(this,"contrast");u(this,"hueShift");u(this,"saturation")}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(){this.context.renderer.toneMappingExposure=1}onCreateEffect(){this.context.renderer.toneMapping===Ys&&this.postExposure.overrideState&&(this.context.renderer.toneMapping=mm);const t=new PU;this.postExposure.onValueChanged=s=>{this.context.renderer.toneMapping===Ys&&(this.context.renderer.toneMapping=mm),this.postExposure.overrideState&&(this.context.renderer.toneMappingExposure=s)},this.contrast.onValueChanged=s=>{t.contrast=s};const i=new OU;return this.hueShift.onValueChanged=s=>i.hue=s,this.saturation.onValueChanged=s=>i.saturation=s,[i,t]}}gx([x(Rt)],bh.prototype,"postExposure",2);gx([x(Rt)],bh.prototype,"contrast",2);gx([x(Rt)],bh.prototype,"hueShift",2);gx([x(Rt)],bh.prototype,"saturation",2);Ro("ColorAdjustments",bh);const Gie=(Math.sqrt(5)-1)/4,$n=(5-Math.sqrt(5))/20,Iy=n=>Math.floor(n)|0,Ry=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 Hie(n=Math.random){const e=Vie(n),t=new Float64Array(e).map(o=>Ry[o%32*4]),i=new Float64Array(e).map(o=>Ry[o%32*4+1]),s=new Float64Array(e).map(o=>Ry[o%32*4+2]),r=new Float64Array(e).map(o=>Ry[o%32*4+3]);return function(a,c,l,h){let d,f,p,g,A;const v=(a+c+l+h)*Gie,m=Iy(a+v),b=Iy(c+v),y=Iy(l+v),_=Iy(h+v),C=(m+b+y+_)*$n,M=m-C,I=b-C,R=y-C,E=_-C,T=a-M,O=c-I,K=l-R,H=h-E;let V=0,Y=0,N=0,L=0;T>O?V++:Y++,T>K?V++:N++,T>H?V++:L++,O>K?Y++:N++,O>H?Y++:L++,K>H?N++:L++;const G=V>=3?1:0,ee=Y>=3?1:0,$=N>=3?1:0,j=L>=3?1:0,ie=V>=2?1:0,Ae=Y>=2?1:0,ge=N>=2?1:0,Ce=L>=2?1:0,Ee=V>=1?1:0,Ge=Y>=1?1:0,Qe=N>=1?1:0,ht=L>=1?1:0,Mt=T-G+$n,it=O-ee+$n,W=K-$+$n,Fe=H-j+$n,me=T-ie+2*$n,Le=O-Ae+2*$n,we=K-ge+2*$n,$e=H-Ce+2*$n,Xe=T-Ee+3*$n,Ye=O-Ge+3*$n,gt=K-Qe+3*$n,Tt=H-ht+3*$n,Yt=T-1+4*$n,z=O-1+4*$n,k=K-1+4*$n,he=H-1+4*$n,Pe=m&255,Be=b&255,Ue=y&255,X=_&255;let de=.6-T*T-O*O-K*K-H*H;if(de<0)d=0;else{const ke=Pe+e[Be+e[Ue+e[X]]];de*=de,d=de*de*(t[ke]*T+i[ke]*O+s[ke]*K+r[ke]*H)}let ce=.6-Mt*Mt-it*it-W*W-Fe*Fe;if(ce<0)f=0;else{const ke=Pe+G+e[Be+ee+e[Ue+$+e[X+j]]];ce*=ce,f=ce*ce*(t[ke]*Mt+i[ke]*it+s[ke]*W+r[ke]*Fe)}let je=.6-me*me-Le*Le-we*we-$e*$e;if(je<0)p=0;else{const ke=Pe+ie+e[Be+Ae+e[Ue+ge+e[X+Ce]]];je*=je,p=je*je*(t[ke]*me+i[ke]*Le+s[ke]*we+r[ke]*$e)}let qe=.6-Xe*Xe-Ye*Ye-gt*gt-Tt*Tt;if(qe<0)g=0;else{const ke=Pe+Ee+e[Be+Ge+e[Ue+Qe+e[X+ht]]];qe*=qe,g=qe*qe*(t[ke]*Xe+i[ke]*Ye+s[ke]*gt+r[ke]*Tt)}let Ve=.6-Yt*Yt-z*z-k*k-he*he;if(Ve<0)A=0;else{const ke=Pe+1+e[Be+1+e[Ue+1+e[X+1]]];Ve*=Ve,A=Ve*Ve*(t[ke]*Yt+i[ke]*z+s[ke]*k+r[ke]*he)}return 27*(d+f+p+g+A)}}function Vie(n){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 s=i+~~(n()*(256-i)),r=t[i];t[i]=t[s],t[s]=r}for(let i=256;i<512;i++)t[i]=t[i-256];return t}var Qie=Object.defineProperty,Wie=Object.getOwnPropertyDescriptor,ne=(n,e,t,i)=>{for(var s=i>1?void 0:i?Wie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Qie(e,t,s),s};const Py=re("debugparticles");var Ta=(n=>(n[n.Billboard=0]="Billboard",n[n.Stretch=1]="Stretch",n[n.HorizontalBillboard=2]="HorizontalBillboard",n[n.VerticalBillboard=3]="VerticalBillboard",n[n.Mesh=4]="Mesh",n))(Ta||{});let _h=class{constructor(){u(this,"alphaKeys");u(this,"colorKeys")}get duration(){return 1}evaluate(e,t){let i,s=0,r=null,o=0;for(let a=0;a<this.alphaKeys.length;a++){const c=this.alphaKeys[a];(c.time<e||!i)&&(i=c,s=a)}for(let a=0;a<this.colorKeys.length;a++){const c=this.colorKeys[a];(c.time<e||!r)&&(r=c,o=a)}if(r)if(o+1<this.colorKeys.length){const c=this.colorKeys[o+1],l=tt.remap(e,r.time,c.time,0,1);t.r=tt.lerp(r.color.r,c.color.r,l),t.g=tt.lerp(r.color.g,c.color.g,l),t.b=tt.lerp(r.color.b,c.color.b,l)}else t.r=r.color.r,t.g=r.color.g,t.b=r.color.b;if(i)if(s+1<this.alphaKeys.length){const c=this.alphaKeys[s+1],l=tt.remap(e,i.time,c.time,0,1);t.alpha=tt.lerp(i.alpha,c.alpha,l)}else t.alpha=i.alpha;return t}};ne([x()],_h.prototype,"alphaKeys",2);ne([x()],_h.prototype,"colorKeys",2);var Xm=(n=>(n[n.Local=0]="Local",n[n.World=1]="World",n[n.Custom=2]="Custom",n))(Xm||{}),Tz=(n=>(n[n.Sphere=0]="Sphere",n[n.SphereShell=1]="SphereShell",n[n.Hemisphere=2]="Hemisphere",n[n.HemisphereShell=3]="HemisphereShell",n[n.Cone=4]="Cone",n[n.Box=5]="Box",n[n.Mesh=6]="Mesh",n[n.ConeShell=7]="ConeShell",n[n.ConeVolume=8]="ConeVolume",n[n.ConeVolumeShell=9]="ConeVolumeShell",n[n.Circle=10]="Circle",n[n.CircleEdge=11]="CircleEdge",n[n.SingleSidedEdge=12]="SingleSidedEdge",n[n.MeshRenderer=13]="MeshRenderer",n[n.SkinnedMeshRenderer=14]="SkinnedMeshRenderer",n[n.BoxShell=15]="BoxShell",n[n.BoxEdge=16]="BoxEdge",n[n.Donut=17]="Donut",n[n.Rectangle=18]="Rectangle",n[n.Sprite=19]="Sprite",n[n.SpriteRenderer=20]="SpriteRenderer",n))(Tz||{});class lt{constructor(){u(this,"mode");u(this,"constant");u(this,"constantMin");u(this,"constantMax");u(this,"curve");u(this,"curveMin");u(this,"curveMax");u(this,"curveMultiplier")}evaluate(e,t){const i=t===void 0?Math.random():t;switch(this.mode){case 0:return this.constant;case 1:return e=tt.clamp01(e),this.curve.evaluate(e)*this.curveMultiplier;case 2:const s=e*this.curveMin.duration,r=e*this.curveMax.duration;return tt.lerp(this.curveMin.evaluate(s),this.curveMax.evaluate(r),i%1)*this.curveMultiplier;case 3:return tt.lerp(this.constantMin,this.constantMax,i%1);default:this.curveMax.evaluate(e)*this.curveMultiplier;break}return 0}getMax(){switch(this.mode){case 0:return this.constant;case 1:return this.getMaxFromCurve(this.curve)*this.curveMultiplier;case 2:return Math.max(this.getMaxFromCurve(this.curveMin),this.getMaxFromCurve(this.curveMax))*this.curveMultiplier;case 3:return Math.max(this.constantMin,this.constantMax);default:return 0}}getMaxFromCurve(e){if(!e)return 0;let t=Number.MIN_VALUE;for(let i=0;i<e.keys.length;i++){const s=e.keys[i];s.value>t&&(t=s.value)}return t}}ne([x()],lt.prototype,"mode",2);ne([x()],lt.prototype,"constant",2);ne([x()],lt.prototype,"constantMin",2);ne([x()],lt.prototype,"constantMax",2);ne([x(Fu)],lt.prototype,"curve",2);ne([x(Fu)],lt.prototype,"curveMin",2);ne([x(Fu)],lt.prototype,"curveMax",2);ne([x()],lt.prototype,"curveMultiplier",2);var Yy;const Go=(Yy=class{constructor(){u(this,"mode");u(this,"color");u(this,"colorMin");u(this,"colorMax");u(this,"gradient");u(this,"gradientMin");u(this,"gradientMax")}evaluate(n,e){const t=e===void 0?Math.random():e;switch(this.mode){case 0:return this.color;case 1:return this.gradient.evaluate(n,Go._temp),Go._temp;case 2:return Go._temp.lerpColors(this.colorMin,this.colorMax,t);case 3:return this.gradientMin.evaluate(n,Go._temp),this.gradientMax.evaluate(n,Go._temp2),Go._temp.lerp(Go._temp2,t)}return Go._temp.set(16711935),Go._temp.alpha=1,Go._temp}},u(Yy,"_temp",new _i(0,0,0,1)),u(Yy,"_temp2",new _i(0,0,0,1)),Yy);let wr=Go;ne([x(_i)],wr.prototype,"color",2);ne([x(_i)],wr.prototype,"colorMin",2);ne([x(_i)],wr.prototype,"colorMax",2);ne([x(_h)],wr.prototype,"gradient",2);ne([x(_h)],wr.prototype,"gradientMin",2);ne([x(_h)],wr.prototype,"gradientMax",2);var JE=(n=>(n[n.Hierarchy=0]="Hierarchy",n[n.Local=1]="Local",n[n.Shape=2]="Shape",n))(JE||{});class ms{constructor(){u(this,"cullingMode");u(this,"duration");u(this,"emitterVelocityMode");u(this,"flipRotation");u(this,"gravityModifier");u(this,"gravityModifierMultiplier");u(this,"loop");u(this,"maxParticles");u(this,"playOnAwake");u(this,"prewarm");u(this,"ringBufferLoopRange");u(this,"ringBufferMode");u(this,"scalingMode");u(this,"simulationSpace");u(this,"simulationSpeed");u(this,"startColor");u(this,"startDelay");u(this,"startDelayMultiplier");u(this,"startLifetime");u(this,"startLifetimeMultiplier");u(this,"startRotation");u(this,"startRotationMultiplier");u(this,"startRotation3D");u(this,"startRotationX");u(this,"startRotationXMultiplier");u(this,"startRotationY");u(this,"startRotationYMultiplier");u(this,"startRotationZ");u(this,"startRotationZMultiplier");u(this,"startSize");u(this,"startSize3D");u(this,"startSizeMultiplier");u(this,"startSizeX");u(this,"startSizeXMultiplier");u(this,"startSizeY");u(this,"startSizeYMultiplier");u(this,"startSizeZ");u(this,"startSizeZMultiplier");u(this,"startSpeed");u(this,"startSpeedMultiplier");u(this,"stopAction");u(this,"useUnscaledTime")}}ne([x(lt)],ms.prototype,"gravityModifier",2);ne([x(wr)],ms.prototype,"startColor",2);ne([x(lt)],ms.prototype,"startDelay",2);ne([x(lt)],ms.prototype,"startLifetime",2);ne([x(lt)],ms.prototype,"startRotation",2);ne([x(lt)],ms.prototype,"startRotationX",2);ne([x(lt)],ms.prototype,"startRotationY",2);ne([x(lt)],ms.prototype,"startRotationZ",2);ne([x(lt)],ms.prototype,"startSize",2);ne([x(lt)],ms.prototype,"startSizeX",2);ne([x(lt)],ms.prototype,"startSizeY",2);ne([x(lt)],ms.prototype,"startSizeZ",2);ne([x(lt)],ms.prototype,"startSpeed",2);class qm{constructor(){u(this,"cycleCount");u(this,"maxCount");u(this,"minCount");u(this,"probability");u(this,"repeatInterval");u(this,"time");u(this,"count");u(this,"_performed",0)}reset(){this._performed=0}run(e){if(e<=this.time)return 0;let t=0;if(this.cycleCount===0||this._performed<this.cycleCount){const i=this.time+this.repeatInterval*this._performed;if(e>=i&&(this._performed+=1,Math.random()<this.probability))switch(this.count.mode){case 0:t=this.count.constant;break;case 3:t=tt.lerp(this.count.constantMin,this.count.constantMax,Math.random());break;case 1:t=this.count.curve.evaluate(Math.random());break;case 2:const s=Math.random();t=tt.lerp(this.count.curveMin.evaluate(s),this.count.curveMax.evaluate(s),Math.random());break}}return t}}class Ja{constructor(){u(this,"enabled");u(this,"bursts");u(this,"rateOverTime");u(this,"rateOverTimeMultiplier");u(this,"rateOverDistance");u(this,"rateOverDistanceMultiplier");u(this,"system")}get burstCount(){var e;return((e=this.bursts)==null?void 0:e.length)??0}reset(){var e;(e=this.bursts)==null||e.forEach(t=>t.reset())}getBurst(){let e=0;if(this.burstCount>0)for(let t=0;t<this.burstCount;t++){const i=this.bursts[t];this.system.main.loop&&i.time>=this.system.time&&i.reset(),e+=Math.round(i.run(this.system.time))}return e}}ne([x()],Ja.prototype,"enabled",2);ne([x()],Ja.prototype,"bursts",2);ne([x(lt)],Ja.prototype,"rateOverTime",2);ne([x()],Ja.prototype,"rateOverTimeMultiplier",2);ne([x(lt)],Ja.prototype,"rateOverDistance",2);ne([x()],Ja.prototype,"rateOverDistanceMultiplier",2);class YA{constructor(){u(this,"enabled");u(this,"color")}}ne([x(wr)],YA.prototype,"color",2);class xh{constructor(){u(this,"enabled");u(this,"separateAxes");u(this,"size");u(this,"sizeMultiplier");u(this,"x");u(this,"xMultiplier");u(this,"y");u(this,"yMultiplier");u(this,"z");u(this,"zMultiplier");u(this,"_time",0);u(this,"_temp",new S)}evaluate(e,t,i){if(t||(t=this._temp),!this.enabled)return t.x=t.y=t.z=1,t;if(this.separateAxes)t.x=this.x.evaluate(e,i)*this.xMultiplier,t.y=this.y.evaluate(e,i)*this.yMultiplier,t.z=this.z.evaluate(e,i)*this.zMultiplier;else{const s=this.size.evaluate(e,i)*this.sizeMultiplier;t.x=s}return t}}ne([x(lt)],xh.prototype,"size",2);ne([x(lt)],xh.prototype,"x",2);ne([x(lt)],xh.prototype,"y",2);ne([x(lt)],xh.prototype,"z",2);var Ky;const Tg=(Ky=class{constructor(){u(this,"shapeType",5);u(this,"enabled",!0);u(this,"alignToDirection",!1);u(this,"angle",0);u(this,"arc",360);u(this,"arcSpread");u(this,"arcSpeedMultiplier");u(this,"arcMode");u(this,"boxThickness");u(this,"position");u(this,"rotation");u(this,"_rotation",new Sn);u(this,"scale");u(this,"radius");u(this,"radiusThickness");u(this,"sphericalDirectionAmount");u(this,"randomDirectionAmount");u(this,"randomPositionAmount");u(this,"system");u(this,"_space");u(this,"_worldSpaceMatrix",new Re);u(this,"_worldSpaceMatrixInverse",new Re);u(this,"_vector",new S(0,0,0));u(this,"_temp",new S(0,0,0));u(this,"_dir",new S);u(this,"_loopTime",0);u(this,"_loopDirection",1);Py&&console.log(this)}get type(){return Tz[this.shapeType]}initialize(n){this.getPosition(),n.position.copy(this._vector)}toJSON(){return this}clone(){return new Tg}update(n,e,t,i){this.system=n,this._space=t,t===1&&(this._worldSpaceMatrix.copy(i.matrixWorld),this._worldSpaceMatrix.elements[0]=1,this._worldSpaceMatrix.elements[5]=1,this._worldSpaceMatrix.elements[10]=1,this._worldSpaceMatrixInverse.copy(this._worldSpaceMatrix).invert())}applyRotation(n){const e=this.rotation.x!==0||this.rotation.y!==0||this.rotation.z!==0;return e&&(this._rotation.x=tt.toRadians(this.rotation.x),this._rotation.y=tt.toRadians(this.rotation.y),this._rotation.z=tt.toRadians(this.rotation.z),this._rotation.order="ZYX",n.applyEuler(this._rotation)),e}get vector(){return this._vector}getPosition(){this._vector.set(0,0,0);const n=this._temp.copy(this.position),e=this._space===1;e&&n.applyQuaternion(this.system.worldQuaternion);let t=this.radius;if(e&&(t*=this.system.worldScale.x),this.enabled){switch(this.shapeType){case 5:Py&&Lc.DrawBox(this.position,this.scale,14540253,1),this._vector.x=Math.random()*this.scale.x-this.scale.x/2,this._vector.y=Math.random()*this.scale.y-this.scale.y/2,this._vector.z=Math.random()*this.scale.z-this.scale.z/2,this._vector.add(n);break;case 4:this.randomConePoint(this.position,this.angle,t,this.radiusThickness,this.arc,this.arcMode,this._vector);break;case 0:this.randomSpherePoint(this.position,t,this.radiusThickness,this.arc,this._vector);break;case 10:this.randomCirclePoint(this.position,t,this.radiusThickness,this.arc,this._vector);break;default:this._vector.set(0,0,0);break}this.randomizePosition(this._vector,this.randomPositionAmount)}this.applyRotation(this._vector),e&&(this._vector.applyQuaternion(this.system.worldQuaternion),this._vector.add(this.system.worldPos)),Py&&Lc.DrawSphere(this._vector,.03,16711680,.5,!0)}getDirection(n){var e;if(!this.enabled)return this._dir.set(0,0,1),this._dir;switch(this.shapeType){case 5:this._dir.set(0,0,1);break;case 4:this._dir.set(0,0,1);break;case 10:case 0:const t=n.x,i=n.y,s=n.z;this._dir.set(t,i,s),(e=this.system)!=null&&e.worldspace?this._dir.sub(this.system.worldPos):this._dir.sub(this.position);break;default:this._dir.set(0,0,1);break}return this._space===1&&this._dir.applyQuaternion(this.system.worldQuaternion),this.applyRotation(this._dir),this._dir.normalize(),this.spherizeDirection(this._dir,this.sphericalDirectionAmount),this.randomizeDirection(this._dir,this.randomDirectionAmount),Py&&(Lc.DrawSphere(n,.01,8925952,.5,!0),Lc.DrawDirection(n,this._dir,8925952,.5,!0)),this._dir}randomizePosition(n,e){if(e<=0)return;const t=Tg._tempVec;t.set(Math.random()*2-1,Math.random()*2-1,Math.random()*2-1),t.x*=e*this.scale.x,t.y*=e*this.scale.y,t.z*=e*this.scale.z,n.add(t)}randomizeDirection(n,e){if(e===0)return;const t=Tg._randomQuat,i=Tg._tempVec;i.set(Math.random()-.5,Math.random()-.5,Math.random()-.5).normalize(),t.setFromAxisAngle(i,e*Math.random()*Math.PI),n.applyQuaternion(t)}spherizeDirection(n,e){if(e===0)return;const t=Math.random()*Math.PI*2,i=Math.acos(1-Math.random()*2),s=Math.sin(i)*Math.cos(t),r=Math.sin(i)*Math.sin(t),o=Math.cos(i),a=new S(s,r,o);n.lerp(a,e)}randomSpherePoint(n,e,t,i,s){const r=Math.random(),o=Math.random(),a=2*Math.PI*r*(i/360),c=Math.acos(2*o-1),l=tt.lerp(1,1-Math.pow(1-Math.random(),Math.PI),t)*e,h=n.x+this.scale.x*(-l*Math.sin(c)*Math.cos(a)),d=n.y+this.scale.y*(l*Math.sin(c)*Math.sin(a)),f=n.z+this.scale.z*(l*Math.cos(c));s.x=h,s.y=d,s.z=f}randomCirclePoint(n,e,t,i,s){const r=Math.random(),o=2*Math.PI*r*(i/360),a=tt.lerp(1,1-Math.pow(1-Math.random(),Math.PI),t)*e,c=n.x+this.scale.x*a*Math.cos(o),l=n.y+this.scale.y*a*Math.sin(o),h=n.z;s.x=c,s.y=l,s.z=h}randomConePoint(n,e,t,i,s,r,o){let a=0,c=0;switch(r){case 0:a=Math.random(),c=Math.random();break;case 2:this._loopTime>1&&(this._loopDirection=-1),this._loopTime<0&&(this._loopDirection=1);case 1:a=.5,c=Math.random(),this._loopTime+=this.system.deltaTime*this._loopDirection;break}let l=2*Math.PI*a*(s/360);switch(r){case 2:case 1:l+=Math.PI+.5,l+=this._loopTime*Math.PI*2,l%=tt.toRadians(s);break}const h=Math.acos(2*c-1),d=tt.lerp(1,1-Math.pow(1-Math.random(),Math.PI),i)*t,f=n.x+-d*Math.sin(h)*Math.cos(l),p=n.y+d*Math.sin(h)*Math.sin(l),g=n.z;o.x=f*this.scale.x,o.y=p*this.scale.y,o.z=g*this.scale.z}},u(Ky,"_randomQuat",new Se),u(Ky,"_tempVec",new S),Ky);let mn=Tg;ne([x()],mn.prototype,"shapeType",2);ne([x()],mn.prototype,"enabled",2);ne([x()],mn.prototype,"alignToDirection",2);ne([x()],mn.prototype,"angle",2);ne([x()],mn.prototype,"arc",2);ne([x()],mn.prototype,"arcSpread",2);ne([x()],mn.prototype,"arcSpeedMultiplier",2);ne([x()],mn.prototype,"arcMode",2);ne([x(S)],mn.prototype,"boxThickness",2);ne([x(S)],mn.prototype,"position",2);ne([x(S)],mn.prototype,"rotation",2);ne([x(S)],mn.prototype,"scale",2);ne([x()],mn.prototype,"radius",2);ne([x()],mn.prototype,"radiusThickness",2);ne([x()],mn.prototype,"sphericalDirectionAmount",2);ne([x()],mn.prototype,"randomDirectionAmount",2);ne([x()],mn.prototype,"randomPositionAmount",2);class Ai{constructor(){u(this,"damping");u(this,"enabled");u(this,"frequency");u(this,"octaveCount");u(this,"octaveMultiplier");u(this,"octaveScale");u(this,"positionAmount");u(this,"quality");u(this,"remap");u(this,"remapEnabled");u(this,"remapMultiplier");u(this,"remapX");u(this,"remapXMultiplier");u(this,"remapY");u(this,"remapYMultiplier");u(this,"remapZ");u(this,"remapZMultiplier");u(this,"scrollSpeedMultiplier");u(this,"separateAxes");u(this,"strengthMultiplier");u(this,"strengthX");u(this,"strengthXMultiplier");u(this,"strengthY");u(this,"strengthYMultiplier");u(this,"strengthZ");u(this,"strengthZMultiplier");u(this,"_noise");u(this,"_time",0);u(this,"_temp",new S)}update(e){this._time+=e.time.deltaTime*this.scrollSpeedMultiplier}apply(e,t,i,s,r,o){if(!this.enabled)return;this._noise||(this._noise=Hie(()=>0));const a=this._temp.set(t.x,t.y,t.z).multiplyScalar(this.frequency),c=this._noise(a.x,a.y,a.z,this._time),l=this._noise(a.x,a.y,a.z,this._time+1e3*this.frequency),h=this._noise(a.x,a.y,a.z,this._time+2e3*this.frequency);this._temp.set(c,l,h).normalize();const d=r/o;let f=this.positionAmount.evaluate(d);this.separateAxes?(this._temp.x*=f*this.strengthXMultiplier,this._temp.y*=f*this.strengthYMultiplier,this._temp.z*=f*this.strengthZMultiplier):(this.strengthX&&(f*=this.strengthX.evaluate(d)*1.5),this._temp.multiplyScalar(f)),i.x+=this._temp.x,i.y+=this._temp.y,i.z+=this._temp.z}}ne([x()],Ai.prototype,"damping",2);ne([x()],Ai.prototype,"enabled",2);ne([x()],Ai.prototype,"frequency",2);ne([x()],Ai.prototype,"octaveCount",2);ne([x()],Ai.prototype,"octaveMultiplier",2);ne([x()],Ai.prototype,"octaveScale",2);ne([x(lt)],Ai.prototype,"positionAmount",2);ne([x()],Ai.prototype,"quality",2);ne([x(lt)],Ai.prototype,"remap",2);ne([x()],Ai.prototype,"remapEnabled",2);ne([x()],Ai.prototype,"remapMultiplier",2);ne([x(lt)],Ai.prototype,"remapX",2);ne([x()],Ai.prototype,"remapXMultiplier",2);ne([x(lt)],Ai.prototype,"remapY",2);ne([x()],Ai.prototype,"remapYMultiplier",2);ne([x(lt)],Ai.prototype,"remapZ",2);ne([x()],Ai.prototype,"remapZMultiplier",2);ne([x()],Ai.prototype,"scrollSpeedMultiplier",2);ne([x()],Ai.prototype,"separateAxes",2);ne([x()],Ai.prototype,"strengthMultiplier",2);ne([x(lt)],Ai.prototype,"strengthX",2);ne([x()],Ai.prototype,"strengthXMultiplier",2);ne([x(lt)],Ai.prototype,"strengthY",2);ne([x()],Ai.prototype,"strengthYMultiplier",2);ne([x(lt)],Ai.prototype,"strengthZ",2);ne([x()],Ai.prototype,"strengthZMultiplier",2);class Qi{constructor(){u(this,"enabled");u(this,"attachRibbonToTransform",!1);u(this,"colorOverLifetime");u(this,"colorOverTrail");u(this,"dieWithParticles",!0);u(this,"inheritParticleColor",!0);u(this,"lifetime");u(this,"lifetimeMultiplier");u(this,"minVertexDistance",.2);u(this,"mode",0);u(this,"ratio",1);u(this,"ribbonCount",1);u(this,"shadowBias",0);u(this,"sizeAffectsLifetime",!1);u(this,"sizeAffectsWidth",!1);u(this,"splitSubEmitterRibbons",!1);u(this,"textureMode",0);u(this,"widthOverTrail");u(this,"widthOverTrailMultiplier");u(this,"worldSpace",!1)}getWidth(e,t,i,s){const r=this.widthOverTrail.evaluate(i,s);return e*=r,e}getColor(e,t,i){const s=this.colorOverTrail.evaluate(i),r=this.colorOverLifetime.evaluate(t);e.x*=s.r*r.r,e.y*=s.g*r.g,e.z*=s.b*r.b,e.w*=s.alpha*r.alpha}}ne([x()],Qi.prototype,"enabled",2);ne([x()],Qi.prototype,"attachRibbonToTransform",2);ne([x(wr)],Qi.prototype,"colorOverLifetime",2);ne([x(wr)],Qi.prototype,"colorOverTrail",2);ne([x()],Qi.prototype,"dieWithParticles",2);ne([x()],Qi.prototype,"inheritParticleColor",2);ne([x(lt)],Qi.prototype,"lifetime",2);ne([x()],Qi.prototype,"lifetimeMultiplier",2);ne([x()],Qi.prototype,"minVertexDistance",2);ne([x()],Qi.prototype,"mode",2);ne([x()],Qi.prototype,"ratio",2);ne([x()],Qi.prototype,"ribbonCount",2);ne([x()],Qi.prototype,"shadowBias",2);ne([x()],Qi.prototype,"sizeAffectsLifetime",2);ne([x()],Qi.prototype,"sizeAffectsWidth",2);ne([x()],Qi.prototype,"splitSubEmitterRibbons",2);ne([x()],Qi.prototype,"textureMode",2);ne([x(lt)],Qi.prototype,"widthOverTrail",2);ne([x()],Qi.prototype,"widthOverTrailMultiplier",2);ne([x()],Qi.prototype,"worldSpace",2);class Ki{constructor(){u(this,"enabled");u(this,"space",0);u(this,"orbitalX");u(this,"orbitalY");u(this,"orbitalZ");u(this,"orbitalXMultiplier");u(this,"orbitalYMultiplier");u(this,"orbitalZMultiplier");u(this,"orbitalOffsetX");u(this,"orbitalOffsetY");u(this,"orbitalOffsetZ");u(this,"speedModifier");u(this,"speedModifierMultiplier");u(this,"x");u(this,"xMultiplier");u(this,"y");u(this,"yMultiplier");u(this,"z");u(this,"zMultiplier");u(this,"_system");u(this,"_temp",new S);u(this,"_temp2",new S);u(this,"_temp3",new S);u(this,"_hasOrbital",!1);u(this,"_index",0);u(this,"_orbitalMatrix",new Re)}update(e){this._system=e}init(e){this._index==0&&(e.debug=!0),this._index+=1,e.orbitx=this.orbitalX.evaluate(Math.random()),e.orbity=this.orbitalY.evaluate(Math.random()),e.orbitz=this.orbitalZ.evaluate(Math.random()),this._hasOrbital=e.orbitx!=0||e.orbity!=0||e.orbitz!=0}apply(e,t,i,s,r,o,a){var p;if(!this.enabled)return;const c=o/a,l=this.speedModifier.evaluate(c)*this.speedModifierMultiplier,h=this.x.evaluate(c),d=this.y.evaluate(c),f=this.z.evaluate(c);if(this._temp.set(-h,d,f),this._system&&this._system.main.simulationSpace===1&&this._temp.applyQuaternion(this._system.worldQuaternion),this._hasOrbital&&((p=this._system)==null?void 0:p.worldPos)){const A=this._temp2.set(i.x,i.y,i.z),v=this.orbitalXMultiplier,m=this.orbitalYMultiplier,b=this.orbitalZMultiplier,y=l*Math.PI*2*10,_=Math.cos(y*v),C=Math.sin(y*v),M=Math.cos(y*m),I=Math.sin(y*m),R=Math.cos(y*b),E=Math.sin(y*b),T=A.x*(M*R)+A.y*(M*E)+A.z*-I,O=A.x*(C*I*R-_*E)+A.y*(C*I*E+_*R)+A.z*(C*M),K=A.x*(_*I*R+C*E)+A.y*(_*I*E-C*R)+A.z*(_*M),H=this._temp3.set(A.x-T,A.y-O,A.z-K);H.normalize(),H.multiplyScalar(.2/r*Math.max(this.orbitalXMultiplier,this.orbitalYMultiplier,this.orbitalZMultiplier)),s.x+=H.x,s.y+=H.y,s.z+=H.z}s.x+=this._temp.x,s.y+=this._temp.y,s.z+=this._temp.z,s.x*=l,s.y*=l,s.z*=l}}ne([x()],Ki.prototype,"enabled",2);ne([x()],Ki.prototype,"space",2);ne([x(lt)],Ki.prototype,"orbitalX",2);ne([x(lt)],Ki.prototype,"orbitalY",2);ne([x(lt)],Ki.prototype,"orbitalZ",2);ne([x()],Ki.prototype,"orbitalXMultiplier",2);ne([x()],Ki.prototype,"orbitalYMultiplier",2);ne([x()],Ki.prototype,"orbitalZMultiplier",2);ne([x()],Ki.prototype,"orbitalOffsetX",2);ne([x()],Ki.prototype,"orbitalOffsetY",2);ne([x()],Ki.prototype,"orbitalOffsetZ",2);ne([x(lt)],Ki.prototype,"speedModifier",2);ne([x()],Ki.prototype,"speedModifierMultiplier",2);ne([x(lt)],Ki.prototype,"x",2);ne([x()],Ki.prototype,"xMultiplier",2);ne([x(lt)],Ki.prototype,"y",2);ne([x()],Ki.prototype,"yMultiplier",2);ne([x(lt)],Ki.prototype,"z",2);ne([x()],Ki.prototype,"zMultiplier",2);class As{constructor(){u(this,"animation");u(this,"enabled");u(this,"cycleCount");u(this,"frameOverTime");u(this,"frameOverTimeMultiplier");u(this,"numTilesX");u(this,"numTilesY");u(this,"startFrame");u(this,"startFrameMultiplier");u(this,"rowMode");u(this,"rowIndex");u(this,"spriteCount");u(this,"timeMode")}sampleOnceAtStart(){if(this.timeMode===0)switch(this.frameOverTime.mode){case 0:case 3:case 2:case 1:return!0}return!1}getStartIndex(){return this.sampleOnceAtStart()?Math.random()*(this.numTilesX*this.numTilesY):0}evaluate(e){if(!this.sampleOnceAtStart())return this.getIndex(e)}getIndex(e){const t=this.numTilesX*this.numTilesY;e=e*this.cycleCount;let i=this.frameOverTime.evaluate(e%1);return i*=this.frameOverTimeMultiplier,i*=t,i=i%t,i=Math.floor(i),i}}ne([x()],As.prototype,"animation",2);ne([x()],As.prototype,"enabled",2);ne([x()],As.prototype,"cycleCount",2);ne([x(lt)],As.prototype,"frameOverTime",2);ne([x()],As.prototype,"frameOverTimeMultiplier",2);ne([x()],As.prototype,"numTilesX",2);ne([x()],As.prototype,"numTilesY",2);ne([x(lt)],As.prototype,"startFrame",2);ne([x()],As.prototype,"startFrameMultiplier",2);ne([x()],As.prototype,"rowMode",2);ne([x()],As.prototype,"rowIndex",2);ne([x()],As.prototype,"spriteCount",2);ne([x()],As.prototype,"timeMode",2);class Po{constructor(){u(this,"enabled");u(this,"separateAxes");u(this,"x");u(this,"xMultiplier");u(this,"y");u(this,"yMultiplier");u(this,"z");u(this,"zMultiplier")}evaluate(e,t){return this.enabled?this.separateAxes?0:this.z.evaluate(e,t)*-1:0}}ne([x()],Po.prototype,"enabled",2);ne([x()],Po.prototype,"separateAxes",2);ne([x(lt)],Po.prototype,"x",2);ne([x()],Po.prototype,"xMultiplier",2);ne([x(lt)],Po.prototype,"y",2);ne([x()],Po.prototype,"yMultiplier",2);ne([x(lt)],Po.prototype,"z",2);ne([x()],Po.prototype,"zMultiplier",2);class Jr{constructor(){u(this,"enabled");u(this,"range");u(this,"separateAxes");u(this,"x");u(this,"xMultiplier");u(this,"y");u(this,"yMultiplier");u(this,"z");u(this,"zMultiplier")}evaluate(e,t){if(!this.enabled)return 0;if(!this.separateAxes){const i=tt.lerp(this.range.x,this.range.y,t);return this.z.evaluate(i)*-1}return 0}}ne([x()],Jr.prototype,"enabled",2);ne([x()],Jr.prototype,"range",2);ne([x()],Jr.prototype,"separateAxes",2);ne([x(lt)],Jr.prototype,"x",2);ne([x()],Jr.prototype,"xMultiplier",2);ne([x(lt)],Jr.prototype,"y",2);ne([x()],Jr.prototype,"yMultiplier",2);ne([x(lt)],Jr.prototype,"z",2);ne([x()],Jr.prototype,"zMultiplier",2);class In{constructor(){u(this,"enabled");u(this,"dampen");u(this,"drag");u(this,"dragMultiplier");u(this,"limit");u(this,"limitMultiplier");u(this,"separateAxes");u(this,"limitX");u(this,"limitXMultiplier");u(this,"limitY");u(this,"limitYMultiplier");u(this,"limitZ");u(this,"limitZMultiplier");u(this,"multiplyDragByParticleSize",!1);u(this,"multiplyDragByParticleVelocity",!1);u(this,"space");u(this,"_temp",new S);u(this,"_temp2",new S)}apply(e,t,i,s,r,o,a){if(this.enabled){const c=this.limit.evaluate(r)*this.limitMultiplier;if(t.length()>c){this._temp.copy(t).normalize().multiplyScalar(c);const h=this.dampen*.5;t.x=tt.lerp(t.x,this._temp.x,h),t.y=tt.lerp(t.y,this._temp.y,h),t.z=tt.lerp(t.z,this._temp.z,h),i.x=tt.lerp(i.x,this._temp.x,h),i.y=tt.lerp(i.y,this._temp.y,h),i.z=tt.lerp(i.z,this._temp.z,h)}}}}ne([x()],In.prototype,"enabled",2);ne([x()],In.prototype,"dampen",2);ne([x(lt)],In.prototype,"drag",2);ne([x()],In.prototype,"dragMultiplier",2);ne([x(lt)],In.prototype,"limit",2);ne([x()],In.prototype,"limitMultiplier",2);ne([x()],In.prototype,"separateAxes",2);ne([x(lt)],In.prototype,"limitX",2);ne([x()],In.prototype,"limitXMultiplier",2);ne([x(lt)],In.prototype,"limitY",2);ne([x()],In.prototype,"limitYMultiplier",2);ne([x(lt)],In.prototype,"limitZ",2);ne([x()],In.prototype,"limitZMultiplier",2);ne([x()],In.prototype,"multiplyDragByParticleSize",2);ne([x()],In.prototype,"multiplyDragByParticleVelocity",2);ne([x()],In.prototype,"space",2);class wh{constructor(){u(this,"enabled");u(this,"curve");u(this,"curveMultiplier");u(this,"mode");u(this,"system");u(this,"_lastWorldPosition");u(this,"_velocity",new S);u(this,"_temp",new S)}update(e){this.enabled&&this.system.worldspace!==!1&&(this._lastWorldPosition?(this._velocity.copy(this.system.worldPos).sub(this._lastWorldPosition).multiplyScalar(1/this.system.deltaTime),this._lastWorldPosition.copy(this.system.worldPos)):(this._velocity.set(0,0,0),this._lastWorldPosition=this.system.worldPos.clone()))}applyInitial(e){if(this.enabled&&this.system.worldspace!==!1&&this.mode===0){const t=this.curve.evaluate(Math.random(),Math.random());this._temp.copy(this._velocity).multiplyScalar(t),e.add(this._temp)}}applyCurrent(e,t,i){if(this.enabled&&this.system.worldspace!==!1&&this.mode===1){const s=this.curve.evaluate(t,i);this._temp.copy(this._velocity).multiplyScalar(s),e.add(this._temp)}}}ne([x()],wh.prototype,"enabled",2);ne([x(lt)],wh.prototype,"curve",2);ne([x()],wh.prototype,"curveMultiplier",2);ne([x()],wh.prototype,"mode",2);class rr{constructor(){u(this,"enabled");u(this,"range");u(this,"separateAxes");u(this,"size");u(this,"sizeMultiplier");u(this,"x");u(this,"xMultiplier");u(this,"y");u(this,"yMultiplier");u(this,"z");u(this,"zMultiplier")}evaluate(e,t,i,s){const r=e.length(),o=tt.remap(r,this.range.x,this.range.y,0,1),a=this.size.evaluate(o,i);return s*a}}ne([x()],rr.prototype,"enabled",2);ne([x(te)],rr.prototype,"range",2);ne([x()],rr.prototype,"separateAxes",2);ne([x(lt)],rr.prototype,"size",2);ne([x()],rr.prototype,"sizeMultiplier",2);ne([x(lt)],rr.prototype,"x",2);ne([x()],rr.prototype,"xMultiplier",2);ne([x(lt)],rr.prototype,"y",2);ne([x()],rr.prototype,"yMultiplier",2);ne([x(lt)],rr.prototype,"z",2);ne([x()],rr.prototype,"zMultiplier",2);class ju{constructor(){u(this,"enabled");u(this,"range");u(this,"color")}evaluate(e,t,i){const s=e.length(),r=tt.remap(s,this.range.x,this.range.y,0,1),o=this.color.evaluate(r,t);i.x*=o.r,i.y*=o.g,i.z*=o.b,i.w*=o.alpha}}ne([x()],ju.prototype,"enabled",2);ne([x(te)],ju.prototype,"range",2);ne([x(wr)],ju.prototype,"color",2);function sO(n){const e=n.domElement.shadowRoot.querySelector("link[rel='ar']");if(e)return e;const t=document.createElement("div");t.classList.add("menu"),t.classList.add("quicklook-menu"),t.style.display="none",t.style.visibility="hidden";const i=document.createElement("button");i.id="open-in-ar",i.innerText="Open in QuickLook",t.appendChild(i);const s=document.createElement("a");s.id="needle-usdz-link",s.style.display="none",s.rel="ar",s.href="",t.appendChild(s);const r=document.createElement("img");return r.id="button",s.appendChild(r),n.domElement.shadowRoot.appendChild(t),s}function jie(){var n=new Date;const e=n.getMonth()+1,t=n.getDate(),i=n.getHours(),s=n.getMinutes(),r=n.getSeconds(),o=(e<10?"0":"")+e,a=(t<10?"0":"")+t,c=(i<10?"0":"")+i,l=(s<10?"0":"")+s,h=(r<10?"0":"")+r;return n.getFullYear()+o+a+"-"+c+l+h}const By=re("debugusdz");function Xie(n,e){const t=[],i=se.getComponentsInChildren(n,Bs),s=se.getComponentsInChildren(n,Wr);let r=!1;const o=new Ks("rest",.01,[]),a=new Map,c=(l,h)=>{if(!r&&h.tracks.length>0&&(r=!0,l.push(o)),h.tracks.length>0)for(const d of h.tracks){const f=Ut.parseTrackName(d.name),p=Ut.findNode(n,f.nodeName);if(p){a.has(p)||a.set(p,[]);const g=a.get(p);switch(f.propertyName){case"position":{if(g.includes("position"))continue;const A=p.position,v=new Ar(d.name,[0,.01],[A.x,A.y,A.z,A.x,A.y,A.z]);g.push("position"),o.tracks.push(v);break}case"quaternion":{if(g.includes("quaternion"))continue;const A=p.quaternion,v=new Ar(d.name,[0,.01],[A.x,A.y,A.z,A.w,A.x,A.y,A.z,A.w]);g.push("quaternion"),o.tracks.push(v);break}case"scale":{if(g.includes("scale"))continue;const A=p.scale,v=new Ar(d.name,[0,.01],[A.x,A.y,A.z,A.x,A.y,A.z]);g.push("scale"),o.tracks.push(v);break}}}}};for(const l of i){if(!l||!l.runtimeAnimatorController)continue;By&&console.log(l);const h=[];for(const d of l.runtimeAnimatorController.enumerateActions()){By&&console.log(d);const f=d.getClip();c(h,f),h.includes(f)||h.push(f)}t.push({root:l.gameObject,clips:h})}for(const l of s){By&&console.log(l);const h=[];for(const d of l.animations)c(h,d),h.includes(d)||h.push(d);t.push({root:l.gameObject,clips:h})}By&&(console.log("Rest Pose Clip",o),console.log("USDZ Animation Clips",t));for(const l of t)for(const h of l.clips)e.registerAnimation(l.root,h)}var qie=Object.defineProperty,Yie=Object.getOwnPropertyDescriptor,dl=(n,e,t,i)=>{for(var s=i>1?void 0:i?Yie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&qie(e,t,s),s};const Gh=re("debugtext");var On=(n=>(n[n.UpperLeft=0]="UpperLeft",n[n.UpperCenter=1]="UpperCenter",n[n.UpperRight=2]="UpperRight",n[n.MiddleLeft=3]="MiddleLeft",n[n.MiddleCenter=4]="MiddleCenter",n[n.MiddleRight=5]="MiddleRight",n[n.LowerLeft=6]="LowerLeft",n[n.LowerCenter=7]="LowerCenter",n[n.LowerRight=8]="LowerRight",n))(On||{}),Iz=(n=>(n[n.Normal=0]="Normal",n[n.Bold=1]="Bold",n[n.Italic=2]="Italic",n[n.BoldAndItalic=3]="BoldAndItalic",n))(Iz||{});class or extends Hu{constructor(){super(...arguments);u(this,"alignment",0);u(this,"verticalOverflow",0);u(this,"horizontalOverflow",0);u(this,"lineSpacing",1);u(this,"supportRichText",!1);u(this,"font");u(this,"fontStyle",0);u(this,"_text","");u(this,"_fontSize",12);u(this,"_textMeshUi",null);u(this,"_didHandleTextRenderOnTop",!1)}setAlphaFactor(t){var i;super.setAlphaFactor(t),(i=this.uiObject)==null||i.set({fontOpacity:this.color.alpha*this.alphaFactor}),this.markDirty()}get text(){return this._text}set text(t){t!==this._text&&(this._text=t,this.feedText(this.text,this.supportRichText),this.markDirty())}set_text(t){this.text=t}get fontSize(){return this._fontSize}set fontSize(t){var i;this._fontSize=t,(i=this.uiObject)==null||i.set({fontSize:t})}onColorChanged(){var t;(t=this.uiObject)==null||t.set({color:this.color,fontOpacity:this.color.alpha})}onParentRectTransformChanged(){super.onParentRectTransformChanged(),this.uiObject&&this.updateOverflow()}onBeforeRender(){var t;this.uiObject&&((t=this.Canvas)!=null&&t.screenspace||this.context.isInVR)&&this.updateOverflow()}updateOverflow(){var i;const t=(i=this.uiObject)==null?void 0:i._overflow;t&&(t._needsUpdate=!0,this.markDirty())}onCreate(t){Gh&&console.log(this),this.horizontalOverflow==1&&(t.whiteSpace="pre"),this.verticalOverflow==0&&(this.context.renderer.localClippingEnabled=!0,t.overflow="hidden"),this.horizontalOverflow==1&&this.verticalOverflow==0,t.lineHeight=this.lineSpacing,delete t.backgroundOpacity,delete t.backgroundColor,Gh&&(t.backgroundColor=16750848,t.backgroundOpacity=.5);const i=this.rectTransform;t={...t,...this.getTextOpts()},this.getAlignment(t),Gh&&(t.backgroundColor=Math.random()*16777215,t.backgroundOpacity=.1),this.uiObject=i.createNewText(t),this.feedText(this.text,this.supportRichText)}onAfterAddedToScene(){super.onAfterAddedToScene(),this.handleTextRenderOnTop()}getTextOpts(){const t=this.fontSize,i={color:this.color,fontOpacity:this.color.alpha,fontSize:t,fontKerning:"normal"};return this.setFont(i,this.fontStyle),i}onEnable(){super.onEnable(),this._didHandleTextRenderOnTop=!1,this.uiObject&&this.uiObject.addAfterUpdate(()=>{this.setShadowComponentOwner(this.uiObject),this.markDirty()}),setTimeout(()=>this.markDirty(),10)}getAlignment(t){switch(t.flexDirection="column",this.alignment){case 0:case 3:case 6:t.textAlign="left";break;case 1:case 4:case 7:t.textAlign="center";break;case 2:case 5:case 8:t.textAlign="right";break}switch(this.alignment){default:case 0:case 1:case 2:t.alignItems="start";break;case 3:case 4:case 5:t.alignItems="center";break;case 6:case 7:case 8:t.alignItems="end";break}return t}feedText(t,i){var s,r,o;if(Gh&&console.log("feedText",this.uiObject,t,i),!!this.uiObject)if(this._textMeshUi||(this._textMeshUi=[]),this.uiObject.children.length=0,!i||t.length===0)this.uiObject.textContent=t;else{let a=this.getNextTag(t);if(a){if(a.startIndex>0){for(let h=this.uiObject.children.length-1;h>=0;h--){const d=this.uiObject.children[h];d.isUI&&(this.uiObject.remove(d),d.clear())}const l=new x0({textContent:t.substring(0,a.startIndex),color:"inherit"});this.uiObject.add(l)}}else{this.uiObject.textContent="",this.setOptions({textContent:t});return}const c=[];for(;a;){const l=this.getNextTag(t,a.endIndex),h={fontFamily:(s=this.uiObject)==null?void 0:s.get("fontFamily"),color:"inherit",textContent:""};if(l){h.textContent=this.getText(t,a,l),this.handleTag(a,h,c);const d=new x0(h);(r=this.uiObject)==null||r.add(d)}else{h.textContent=t.substring(a.endIndex),this.handleTag(a,h,c);const d=new x0(h);(o=this.uiObject)==null||o.add(d)}a=l}}}handleTextRenderOnTop(){this._didHandleTextRenderOnTop||(this._didHandleTextRenderOnTop=!0,this.startCoroutine(this.renderOnTopCoroutine()))}*renderOnTopCoroutine(){if(!this.canvas)return;const t=[],i=this.canvas,s={renderOnTop:i.renderOnTop,depthWrite:i.depthWrite,doubleSided:i.doubleSided};for(;;){let r=!1;if(this._textMeshUi)for(let o=0;o<this._textMeshUi.length;o++){if(t[o]===!0)continue;r=!0;const a=this._textMeshUi[o];a.textContent&&(bb(a,s),t[o]=!0)}if(!r)break;yield}}handleTag(t,i,s){if(!t.isEndTag){if(t.type.includes("color")){const r=new BS(t,{color:i.color});if(s.push(r),t.type.length>6){const o=parseInt("0x"+t.type.substring(7));i.color=o}else i.color=new _e(1,1,1)}else if(t.type=="b"){this.setFont(i,1);const r=new BS(t,{fontWeight:700});s.push(r)}else if(t.type=="i"){this.setFont(i,2);const r=new BS(t,{fontStyle:"italic"});s.push(r)}}}getText(t,i,s){return t.substring(i.endIndex,s.startIndex)}getNextTag(t,i=0){const s=t.indexOf("<",i),r=t.indexOf(">",s);if(s>=0&&r>=0){const o=t.substring(s+1,r);return{type:o,startIndex:s,endIndex:r+1,isEndTag:o.startsWith("/")}}return null}setFont(t,i){if(!this.font)return;const s=this.font,r=this.getFamilyNameWithCorrectSuffix(s,i);Gh&&console.log("Selected font family:"+r);let o=XE.getFontFamily(r);switch(o||(o=XE.addFontFamily(r)),t.fontFamily=o,i){default:case 0:t.fontWeight=400,t.fontStyle="normal";break;case 1:t.fontWeight=700,t.fontStyle="normal";break;case 2:t.fontWeight=400,t.fontStyle="italic";break;case 3:t.fontStyle="italic",t.fontWeight=400}let a=o.getVariant(t.fontWeight,t.fontStyle);if(!a){let c=r;c!=null&&c.endsWith("-msdf.json")||(c+="-msdf.json");let l=r;l!=null&&l.endsWith(".png")||(l+=".png"),a=o.addVariant(t.fontWeight,t.fontStyle,c,l),a==null||a.addEventListener("ready",()=>{this.markDirty()})}}getFamilyNameWithCorrectSuffix(t,i){var h;const s=t.lastIndexOf("-");if(s<0)return t;const r=(h=t.substring(s+1))==null?void 0:h.toLowerCase();if(Kie.includes(r))return Gh&&console.warn("Unsupported font style: "+r),t;const o=t.lastIndexOf("/");let a=t;o>=0&&(a=a.substring(o+1));const c=a[0]===a[0].toUpperCase(),l=t.substring(0,s);switch(Gh&&console.log("Select font: ",t,Iz[i],a,c,l),i){case 0:return c?l+"-Regular":l+"-regular";case 1:return c?l+"-Bold":l+"-bold";case 2:return c?l+"-Italic":l+"-italic";case 3:return c?l+"-BoldItalic":l+"-bolditalic";default:return t}}}dl([x()],or.prototype,"alignment",2);dl([x()],or.prototype,"verticalOverflow",2);dl([x()],or.prototype,"horizontalOverflow",2);dl([x()],or.prototype,"lineSpacing",2);dl([x()],or.prototype,"supportRichText",2);dl([x(URL)],or.prototype,"font",2);dl([x()],or.prototype,"fontStyle",2);dl([x()],or.prototype,"text",1);dl([x()],or.prototype,"fontSize",1);class BS{constructor(e,t){u(this,"tag");u(this,"previousValues");this.tag=e,this.previousValues=t}}const Kie=["medium","mediumitalic","black","blackitalic","thin","thinitalic","extrabold","light","lightitalic","semibold"];class Ql{constructor(e){u(this,"id");u(this,"content","");u(this,"font",[]);u(this,"pointSize",144);u(this,"width");u(this,"height");u(this,"depth");u(this,"wrapMode");u(this,"horizontalAlignment");u(this,"verticalAlignment");u(this,"material");this.id=e}static getId(){return this.global_id++}setDepth(e){return this.depth=e,this}setPointSize(e){return this.pointSize=e,this}setHorizontalAlignment(e){return this.horizontalAlignment=e,this}setVerticalAlignment(e){return this.verticalAlignment=e,this}writeTo(e,t){var s;t.beginBlock(`def Preliminary_Text "${this.id}"`),this.content&&t.appendLine(`string content = "${this.content}"`),(!this.font||this.font.length<=0)&&(this.font||(this.font=[]),(s=this.font)==null||s.push("sans-serif"));const i=this.font.map(r=>`"${r}"`).join(", ");t.appendLine(`string[] font = [ ${i} ]`),t.appendLine(`double pointSize = ${this.pointSize}`),typeof this.width=="number"&&t.appendLine(`double width = ${this.width}`),typeof this.height=="number"&&t.appendLine(`double height = ${this.height}`),typeof this.depth=="number"&&t.appendLine(`double depth = ${this.depth}`),this.wrapMode&&t.appendLine(`token wrapMode = "${this.wrapMode}"`),this.horizontalAlignment&&t.appendLine(`token horizontalAlignment = "${this.horizontalAlignment}"`),this.verticalAlignment&&t.appendLine(`token verticalAlignment = "${this.verticalAlignment}"`),this.material!==void 0&&t.appendLine(`rel material:binding = </Materials/Material_${this.material.id}>`),t.closeBlock()}}u(Ql,"global_id",0);class mx{static singleLine(e,t,i){const s=new Ql("text_"+Ql.getId());return s.content=e,t&&(s.pointSize=t),i&&(s.depth=i),s}static multiLine(e,t,i,s,r,o){const a=new Ql("text_"+Ql.getId());return a.content=e,a.width=t,a.height=i,a.horizontalAlignment=s,a.verticalAlignment=r,o!==void 0&&(a.wrapMode=o),a}}const Jie=new Re().makeRotationY(Math.PI),Zie=new Re().makeScale(-1,1,-1);class KA{get extensionName(){return"text"}onExportObject(e,t,i){}exportText(e,t,i){const s=se.getComponent(e,or);if(!s)return;const r=se.getComponent(e,tr);let o=100,a=100;r&&(o=r.width,a=r.height),t.matrix=Jie.clone(),r&&t.matrix.premultiply(Zie);const c=new _e().copySRGBToLinear(s.color);t.material=new $o({color:c,emissive:c}),t.addEventListener("serialize",(l,h)=>{let d=s.text;d=d.replace(/\n/g,"\\n");const f=mx.multiLine(d,o,a,"center","bottom","flowing");this.setTextAlignment(f,s.alignment),this.setOverflow(f,s),t.material&&(f.material=t.material),f.pointSize=this.convertToTextSize(s.fontSize),f.depth=.001,f.writeTo(void 0,l)})}convertToTextSize(e){return 1/.0502*144*e}setOverflow(e,t){t.horizontalOverflow?e.wrapMode="singleLine":e.wrapMode="flowing"}setTextAlignment(e,t){switch(t){case On.LowerLeft:case On.MiddleLeft:case On.UpperLeft:e.horizontalAlignment="left";break;case On.LowerCenter:case On.MiddleCenter:case On.UpperCenter:e.horizontalAlignment="center";break;case On.LowerRight:case On.MiddleRight:case On.UpperRight:e.horizontalAlignment="right";break}switch(t){case On.LowerLeft:case On.LowerCenter:case On.LowerRight:e.verticalAlignment="bottom";break;case On.MiddleLeft:case On.MiddleCenter:case On.MiddleRight:e.verticalAlignment="middle";break;case On.UpperLeft:case On.UpperCenter:case On.UpperRight:e.verticalAlignment="top";break}}}class Ax{get extensionName(){return"tmui"}onExportObject(e,t,i){const s=se.getComponent(e,us);if(s&&s.activeAndEnabled&&s.renderMode===Ez.WorldSpace){const r=new KA,o=se.getComponent(e,tr),a=se.getComponent(e,oh);if(o){o.width,o.height;const c=gr.createEmpty(),l=o.shadowComponent;if(t.add(c),l){const h=l.matrix;c.matrix.copy(h);const d=new Map,f=new Map;d.set(l,c),f.set(l,a?a.alpha:1),l.traverse(p=>{if(p===l)return;const g=gr.createEmpty();g.matrix.copy(p.matrix);const A=p.parent,v=A&&typeof A.textContent=="string"&&A.textContent.length;let m=f.get(A)||1;const b=se.getComponent(p,oh);if(b&&(m*=b.alpha),p instanceof ye&&v){const _=p[Ma].gameObject;r.exportText(_,g,i)}if(p instanceof ye&&!v){const _=p.geometry.clone();_.scale(1,1,-1),this.flipWindingOrder(_),g.geometry=_;const C=new _e,M=p.material.opacity;C.copy(p.material.color),g.material=new hi({color:C,opacity:M*m,map:p.material.map,transparent:!0})}d.set(p,g),f.set(p,m);const y=d.get(A);if(!y){console.error("Error when exporting UI: shadow component parent not found!",p,p.parent);return}y.add(g)})}}}}flipWindingOrder(e){const t=e.index.array;for(let i=0,s=t.length/3;i<s;i++){const r=t[i*3];t[i*3]=t[i*3+2],t[i*3+2]=r}e.index.needsUpdate=!0}}var $ie=Object.defineProperty,ene=Object.getOwnPropertyDescriptor,Zr=(n,e,t,i)=>{for(var s=i>1?void 0:i?ene(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&$ie(e,t,s),s};const Pn=re("debugusdz");class Sh{constructor(){u(this,"callToAction");u(this,"checkoutTitle");u(this,"checkoutSubtitle");u(this,"callToActionURL")}}Zr([x()],Sh.prototype,"callToAction",2);Zr([x()],Sh.prototype,"checkoutTitle",2);Zr([x()],Sh.prototype,"checkoutSubtitle",2);Zr([x()],Sh.prototype,"callToActionURL",2);class $r extends Me{constructor(){super(...arguments);u(this,"objectToExport");u(this,"autoExportAnimations",!1);u(this,"exportFileName");u(this,"customUsdzFile");u(this,"customBranding");u(this,"anchoringType","plane");u(this,"planeAnchoringAlignment","horizontal");u(this,"interactive",!0);u(this,"extensions",[]);u(this,"allowCreateQuicklookButton",!0);u(this,"link");u(this,"webxr");u(this,"onClickedOpenInARElement",t=>{t.preventDefault(),this.exportAsync()});u(this,"lastCallback");u(this,"_quicklookButton");u(this,"_quicklookButtonContainer",null)}start(){var t,i,s;Pn&&(console.log("USDZExporter",this),console.log("Debug USDZ Mode. Press 'T' to export"),window.addEventListener("keydown",r=>{switch(r.key){case"t":this.exportAsync();break}}),nl()&&setTimeout(()=>{this.exportAsync()},2e3)),this.objectToExport||(this.objectToExport=this.gameObject),!((i=(t=this.objectToExport)==null?void 0:t.children)!=null&&i.length)&&!((s=this.objectToExport)!=null&&s.isMesh)&&(this.objectToExport=this.context.scene),this.interactive&&(this.extensions.push(new dx),this.extensions.push(new hx),this.extensions.push(new KA),this.extensions.push(new Ax))}onEnable(){var s;const t=pm(),i=wc();(Pn||t&&i)&&((Pn||this.allowCreateQuicklookButton)&&this.addQuicklookButton(),this.lastCallback=this.quicklookCallback.bind(this),this.link=sO(this.context),this.link.addEventListener("message",this.lastCallback)),Pn&&_n("USDZ Exporter enabled: "+this.name),(s=document.getElementById("open-in-ar"))==null||s.addEventListener("click",this.onClickedOpenInARElement)}onDisable(){var s,r;(s=this.link)==null||s.removeEventListener("message",this.lastCallback);const t=pm(),i=wc();(Pn||t&&i)&&this.removeQuicklookButton(),Pn&&_n("USDZ Exporter disabled: "+this.name),(r=document.getElementById("open-in-ar"))==null||r.removeEventListener("click",this.onClickedOpenInARElement)}async exportAsync(){var v;let t=this.exportFileName??((v=this.objectToExport)==null?void 0:v.name)??this.name;if(pf()||(t!==""&&(t+="-"),t+="MadeWithNeedle"),t+="-"+jie(),this.link||(this.link=sO(this.context)),this.customUsdzFile){Pn&&console.log("Exporting custom usdz",this.customUsdzFile);const m=this.buildQuicklookOverlay();Pn&&console.log("QuickLook Overlay",m);const b=m.callToAction?encodeURIComponent(m.callToAction):"",y=m.checkoutTitle?encodeURIComponent(m.checkoutTitle):"",_=m.checkoutSubtitle?encodeURIComponent(m.checkoutSubtitle):"";this.link.href=this.customUsdzFile+`#callToAction=${b}&checkoutTitle=${y}&checkoutSubtitle=${_}&callToActionURL=${m.callToActionURL}`,Pn&&console.log(this.link.href),this.lastCallback||(this.lastCallback=this.quicklookCallback.bind(this),this.link.addEventListener("message",this.lastCallback)),this.link.download=t+".usdz",this.link.click();return}if(!this.objectToExport){console.warn("No object to export",this);return}const i=se.getComponentsInChildren(this.objectToExport,Hi),s=new Array;for(const m of i)for(const b of m.sharedMaterials)if(b){const y=m.loadProgressiveTextures(b);y instanceof Promise&&s.push(y)}Pn&&_n("Load textures: "+s.length),await Promise.all(s),Pn&&_n("Load textures: done");const r=Xs.Global.Mask;Xs.Global.Set(un.AR),this.applyWebARSessionRoot();const o=new X7,a=[...this.extensions],c=new W_;a.push(c),this.autoExportAnimations&&Xie(this.objectToExport,c);const l={self:this,exporter:o,extensions:a,object:this.objectToExport};this.dispatchEvent(new CustomEvent("before-export",{detail:l})),o.debug=Pn,this.anchoringType!=="plane"&&this.anchoringType!=="none"&&this.anchoringType!=="image"&&this.anchoringType!=="face"&&(this.anchoringType="plane"),this.planeAnchoringAlignment!=="horizontal"&&this.planeAnchoringAlignment!=="vertical"&&this.planeAnchoringAlignment!=="any"&&(this.planeAnchoringAlignment="horizontal");const h=await o.parse(this.objectToExport,{ar:{anchoring:{type:this.anchoringType},planeAnchoring:{alignment:this.planeAnchoringAlignment}},extensions:a,quickLookCompatible:!0}),d=new Blob([h],{type:"application/octet-stream"});this.dispatchEvent(new CustomEvent("after-export",{detail:l}));const f=this.buildQuicklookOverlay();Pn&&console.log("QuickLook Overlay",f);const p=f.callToAction?encodeURIComponent(f.callToAction):"",g=f.checkoutTitle?encodeURIComponent(f.checkoutTitle):"",A=f.checkoutSubtitle?encodeURIComponent(f.checkoutSubtitle):"";this.link.href=URL.createObjectURL(d)+`#callToAction=${p}&checkoutTitle=${g}&checkoutSubtitle=${A}&callToActionURL=${f.callToActionURL}`,this.lastCallback||(this.lastCallback=this.quicklookCallback.bind(this),this.link.addEventListener("message",this.lastCallback)),this.link.download=t+".usdz",this.link.click(),Pn&&console.log("USDZ generation done. Downloading as "+this.link.download),Xs.Global.Set(r)}quicklookCallback(t){if((t==null?void 0:t.data)=="_apple_ar_quicklook_button_tapped"){Pn&&nr("Quicklook closed via call to action button");var i=new CustomEvent("quicklook-button-tapped",{detail:this});if(this.dispatchEvent(i),!i.defaultPrevented){const s=new URLSearchParams(this.link.href);if(s){const r=s.get("callToActionURL");Pn&&_n("Quicklook url: "+r),r&&(pf()?globalThis.open(r,"_blank"):console.warn("Quicklook closed: custom redirects require a Needle Engine Pro license: https://needle.tools/pricing",r))}}}}buildQuicklookOverlay(){var s,r,o,a,c,l;const t={};return this.customBranding&&Object.assign(t,this.customBranding),pf()||(console.log("Custom Quicklook banner text requires pro license: https://needle.tools/pricing"),t.callToAction="Close",t.checkoutTitle="🌵 Made with Needle",t.checkoutSubtitle="_"),(((s=t.callToAction)==null?void 0:s.length)||((r=t.checkoutTitle)==null?void 0:r.length)||((o=t.checkoutSubtitle)==null?void 0:o.length))&&((a=t.callToAction)!=null&&a.length||(t.callToAction="\0"),(c=t.checkoutTitle)!=null&&c.length||(t.checkoutTitle="\0"),(l=t.checkoutSubtitle)!=null&&l.length||(t.checkoutSubtitle="\0")),this.dispatchEvent(new CustomEvent("quicklook-overlay",{detail:t})),t}async createQuicklookButton(){var t,i;if(!this.webxr)if(await sA(1),this.webxr=se.findObjectOfType(Et)??void 0,this.webxr)if(this.webxr.VRButton&&((t=this.webxr.VRButton.parentElement)==null||t.removeChild(this.webxr.VRButton)),this.webxr.ARButton&&this._quicklookButton!==this.webxr.ARButton){this._quicklookButton=this.webxr.ARButton;const s=(i=this.webxr.ARButton.parentElement)==null?void 0:i.querySelector("a");s&&(s.href=""),this.webxr.ARButton.innerText="Open in Quicklook",this.webxr.ARButton.disabled=!1,this.webxr.ARButton.addEventListener("click",r=>{r.preventDefault(),this.exportAsync()}),this.webxr.ARButton.classList.add("quicklook-ar-button"),this._quicklookButtonContainer=this.webxr.ARButton.parentElement,this.dispatchEvent(new CustomEvent("created-button",{detail:this.webxr.ARButton}))}else{this.webxr.createARButton=!1,this.webxr.createVRButton=!1;let s=this.context.domElement.shadowRoot.querySelector(".webxr-buttons");s||(s=document.createElement("div"),s.classList.add("webxr-buttons"));const r=document.createElement("button");r.innerText="Open in Quicklook",r.addEventListener("click",()=>{this.exportAsync()}),r.classList.add("webxr-ar-button"),r.classList.add("webxr-button"),r.classList.add("quicklook-ar-button"),this._quicklookButton=r,s.appendChild(r),this._quicklookButtonContainer=s,this.dispatchEvent(new CustomEvent("created-button",{detail:r}))}else console.warn("Could not find WebXR component: will not create Quicklook button",Nt.Current)}async addQuicklookButton(){await this.createQuicklookButton(),this._quicklookButton&&this._quicklookButtonContainer&&this._quicklookButtonContainer.appendChild(this._quicklookButton)}removeQuicklookButton(){var t;(t=this._quicklookButton)==null||t.remove()}applyWebARSessionRoot(){if(!this.objectToExport)return;let t=se.getComponentInParent(this.objectToExport,Wa);const i=t!=null;if(t||(t=se.getComponentInChildren(this.objectToExport,Wa)),Pn&&console.log("applyWebARSessionRoot",t),!t){Pn&&console.warn("No WebARSessionRoot found in parent hierarchy",this.objectToExport);return}const s=i?this.objectToExport:t.gameObject,r=1/t.arScale;Pn&&console.log("AR Session Root scale",r,s),s.matrix.makeScale(r,r,r),t.invertForward&&s.matrix.multiply(new Re().makeRotationY(Math.PI))}}Zr([x(Te)],$r.prototype,"objectToExport",2);Zr([x()],$r.prototype,"autoExportAnimations",2);Zr([x()],$r.prototype,"exportFileName",2);Zr([x(URL)],$r.prototype,"customUsdzFile",2);Zr([x(Sh)],$r.prototype,"customBranding",2);Zr([x()],$r.prototype,"anchoringType",2);Zr([x()],$r.prototype,"planeAnchoringAlignment",2);Zr([x()],$r.prototype,"interactive",2);Zr([x()],$r.prototype,"allowCreateQuicklookButton",2);const rO=re("debugdeletable");class vx extends xo{}class hI extends Me{constructor(){super(...arguments);u(this,"deleteBoxes",[])}awake(){this.deleteBoxes=se.findObjectsOfType(vx,this.context)}update(){for(const t of this.deleteBoxes){const i=this.gameObject;if(t.isInBox(i)===!0){const r=se.getComponentInParent(this.gameObject,sp);r?rO&&console.warn("Can not delete object with usage marker",this.guid,r):(rO&&console.log("DESTROY",this.gameObject),T_(this.gameObject,this.context.connection))}}}}var tne=Object.defineProperty,ine=Object.getOwnPropertyDescriptor,Xu=(n,e,t,i)=>{for(var s=i>1?void 0:i?ine(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&tne(e,t,s),s};class ca extends Os{constructor(){super(...arguments);u(this,"mode");u(this,"focusDistance");u(this,"focalLength");u(this,"aperture");u(this,"gaussianMaxRadius");u(this,"resolutionScale");u(this,"bokehScale")}get typeName(){return"DepthOfField"}init(){this.focalLength.valueProcessor=i=>{const s=i/300,r=2;return tt.lerp(r,.01,s)};const t=20;this.aperture.valueProcessor=i=>{const s=1-i/32;return tt.lerp(1,t,s)}}onCreateEffect(){if(this.mode===0)return;const t=1/window.devicePixelRatio;if(this.resolutionScale===void 0){let s=1;nl()&&(s=.6),this.resolutionScale=new Rt(s*t)}const i=new DU(this.context.mainCamera,{worldFocusRange:.2,focalLength:1,bokehScale:20,resolutionScale:this.resolutionScale.value});return this.focusDistance.onValueChanged=s=>{i.circleOfConfusionMaterial.worldFocusDistance=s},this.focalLength.onValueChanged=s=>i.circleOfConfusionMaterial.worldFocusRange=s,this.aperture.onValueChanged=s=>i.bokehScale=s,this.resolutionScale&&(this.resolutionScale.onValueChanged=s=>i.resolution.scale=s),[i]}unapply(){}}Xu([x()],ca.prototype,"mode",2);Xu([x(Rt)],ca.prototype,"focusDistance",2);Xu([x(Rt)],ca.prototype,"focalLength",2);Xu([x(Rt)],ca.prototype,"aperture",2);Xu([x(Rt)],ca.prototype,"gaussianMaxRadius",2);Xu([x(Rt)],ca.prototype,"resolutionScale",2);Xu([x(Rt)],ca.prototype,"bokehScale",2);Ro("DepthOfField",ca);var nne=Object.defineProperty,sne=Object.getOwnPropertyDescriptor,rne=(n,e,t,i)=>{for(var s=i>1?void 0:i?sne(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&nne(e,t,s),s};class yx extends Me{constructor(){super(...arguments);u(this,"visibleOn")}onEnable(){this.apply()}apply(){this.test()||se.setActive(this.gameObject,!1)}test(){return this.visibleOn<0?!0:nl()?(this.visibleOn&2)!==0:(this.visibleOn&1)!==0}}rne([x()],yx.prototype,"visibleOn",2);class uI{get extensionName(){return"DocumentExtension"}onAfterBuildDocument(e){}}var one=Object.defineProperty,ane=Object.getOwnPropertyDescriptor,Rz=(n,e,t,i)=>{for(var s=i>1?void 0:i?ane(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&one(e,t,s),s},Pz=(n=>(n.SelectStart="selectstart",n.SelectEnd="selectend",n))(Pz||{}),Jy;const Ll=(Jy=class extends np{constructor(){super();u(this,"showGizmo",!0);u(this,"useViewAngle",!0);u(this,"transformSelf",!0);u(this,"orbit",null);u(this,"selectStartEventListener",[]);u(this,"selectEndEventListener",[]);u(this,"_dragHelper",null);u(this,"_draggingRigidbodies",[]);u(this,"_waitingForDragStart",null);u(this,"_isDragging",!1);u(this,"_marker",null);u(this,"_dragDelta");u(this,"_didDrag",!1);u(this,"_activePointerId");this.selectStartEventListener=[],this.selectEndEventListener=[],this._dragDelta=new te}static get HasAnySelected(){return this._active>0}addDragEventListener(e,t){switch(e){case"selectstart":this.selectStartEventListener.push(t);break;case"selectend":this.selectEndEventListener.push(t);break}}start(){this.orbit=se.findObjectOfType(cl,this.context),this.gameObject.getComponentInParent(el)||this.gameObject.addNewComponent(el)}allowEdit(e=null){return this.context.connection.allowEditing}onPointerEnter(e){if(!this.allowEdit(this.gameObject)||Et.IsInWebXR)return;const t=se.getComponentInParent(e.object,Ll);!t||t!==this||(Ll.lastHovered=e.object,this.context.domElement.style.cursor="pointer")}onPointerExit(e){this.allowEdit(this.gameObject)&&(Et.IsInWebXR||Ll.lastHovered===e.object&&(this.context.domElement.style.cursor="auto"))}onPointerDown(e){this.allowEdit(this.gameObject)&&(Et.IsInWebXR||(Ll._active+=1,this._dragDelta.set(0,0),this._didDrag=!1,this._waitingForDragStart=e.clone(),e.stopPropagation(),this.orbit&&(this.orbit.enabled=!1)))}onPointerUp(e){this._waitingForDragStart=null,this.allowEdit(this.gameObject)&&(Ll._active>0&&(Ll._active-=1),!Et.IsInWebXR&&(this.onDragEnd(e),e.stopPropagation(),this.orbit&&(this.orbit.enabled=!0)))}update(){var e;if(!Et.IsInWebXR){if(this._waitingForDragStart){if(!this._didDrag){const i=this.context.input.getPointerPositionDelta(0);if(i&&this._dragDelta.add(i),this._dragDelta.length()>2)this._didDrag=!0;else return}const t=this._waitingForDragStart;this._waitingForDragStart=null,this.onDragStart(t)}this._dragHelper&&this._dragHelper.hasSelected&&this.onUpdateDrag(),(((e=this._dragHelper)==null?void 0:e.hasSelected)===!1||this._activePointerId!==void 0&&this.context.input.getPointerPressed(this._activePointerId)===!1)&&this.onDragEnd(null)}}onDragStart(e){if(!this._dragHelper)if(this.context.mainCamera)this._dragHelper=new C0(this.context.mainCamera);else return;if(!e||!e.object)return;const t=se.getComponentInParent(e.object,Ll);if(!t||t!==this)return;let i=e.object;this.transformSelf&&(i=this.gameObject);const s={selected:i,attached:i};for(const c of this.selectStartEventListener)c(this,s);if(this._activePointerId=e.pointerId,!s.attached)return;s.attached,i=s.attached,this._isDragging=!0,this._dragHelper.setSelected(i,this.context),this.orbit&&(this.orbit.enabled=!1);const r=se.getComponentInChildren(i,nh);r&&(r.fastMode=!0,r==null||r.requestOwnership()),this._marker=se.addNewComponent(i,sp),this._draggingRigidbodies.length=0;const o=se.getComponentsInChildren(i,Yi);o&&this._draggingRigidbodies.push(...o);const a=k0();se.invokeOnChildren(this._dragHelper.selected,a("onDragStart"))}onUpdateDrag(){if(this._dragHelper){this._dragHelper.showGizmo=this.showGizmo,this._dragHelper.useViewAngle=this.useViewAngle,this._dragHelper.onUpdate(this.context);for(const e of this._draggingRigidbodies)e.wakeUp(),e.resetVelocities()}}onDragEnd(e){if(!this||!this._isDragging||(this._isDragging=!1,!this._dragHelper))return;for(const s of this._draggingRigidbodies)s.setVelocity(s.smoothedVelocity);this._draggingRigidbodies.length=0;const t=this._dragHelper.selected;if(this._dragHelper.setSelected(null,this.context),this.orbit&&(this.orbit.enabled=!0),e!=null&&e.object){const s=se.getComponentInChildren(e.object,nh);s&&(s.fastMode=!1)}this._marker&&this._marker.destroy();for(const s of this.selectEndEventListener)s(this);const i=k0();se.invokeOnChildren(t,i("onDragEnd"))}},u(Jy,"_active",0),u(Jy,"lastHovered"),Jy);let _p=Ll;Rz([x()],_p.prototype,"showGizmo",2);Rz([x()],_p.prototype,"useViewAngle",2);const oR=class{constructor(e){u(this,"showGizmo",!0);u(this,"useViewAngle",!0);u(this,"_selected",null);u(this,"_context",null);u(this,"_camera");u(this,"_cameraPlane",new bo);u(this,"_hasGroundPlane",!1);u(this,"_groundPlane",new bo);u(this,"_groundOffset",new S);u(this,"_groundOffsetFactor",0);u(this,"_groundDistance",0);u(this,"_groundPlanePoint",new S);u(this,"_raycaster",new jf);u(this,"_cameraPlaneOffset",new S);u(this,"_intersection",new S);u(this,"_worldPosition",new S);u(this,"_inverseMatrix",new Re);u(this,"_rbs",[]);u(this,"_groundLine");u(this,"_groundMarker");u(this,"_groundOffsetVector",new S(0,1,0));u(this,"_requireUpdateGroundPlane",!0);u(this,"_didDragOnGroundPlaneLastFrame",!1);this._camera=e;const t=new hn(oR.geometry),i=t.material;i.color=new _e(.4,.4,.4),t.layers.set(2),t.name="line",t.scale.y=1,this._groundLine=t;const s=new To(.5,22,22),r=new hi({color:i.color}),o=new ye(s,r);o.visible=!1,o.layers.set(2),this._groundMarker=o}get hasSelected(){return this._selected!==null&&this._selected!==void 0}get selected(){return this._selected}setSelected(e,t){if(this._selected&&t)for(const i of this._rbs)i.wakeUp(),i.setVelocity(0,0,0);if(this._selected&&Zs.Remove(t,this._selected),this._selected=e,this._context=t,this._rbs.length=0,e?(t.scene.add(this._groundLine),t.scene.add(this._groundMarker)):(this._groundLine.removeFromParent(),this._groundMarker.removeFromParent()),this._selected){if(!t){console.error("DragHelper: no context");return}Zs.Add(t,this._selected,null),this._groundOffsetFactor=0,this._hasGroundPlane=!0,this._groundOffset.set(0,0,0),this._requireUpdateGroundPlane=!0,this.onUpdateScreenSpacePlane()}}onUpdate(e){var a,c,l,h,d;if(!this._context)return;const t="Space",i="KeyD",s=((a=this._context)==null?void 0:a.input.isKeyPressed(t))||((c=this._context)==null?void 0:c.input.isKeyPressed(i)),r=this._context.input.getTouchesPressedCount()>=2||s;if(r){const f=this._context.input.getPointerPositionDelta(0);f&&(this._groundOffsetVector.set(0,1,0),(l=this._selected)==null||l.rotateOnWorldAxis(this._groundOffsetVector,f.x*this._context.time.deltaTime))}const o=this._context.input.getPointerPositionRC(0);if(o&&(this._raycaster.setFromCamera(o,this._camera),this._selected)){this._groundOffsetVector.set(0,1,0);const f=wt(this._camera).clone().sub(wt(this._selected)).normalize(),p=Math.abs(f.dot(this._groundOffsetVector)),g=((h=this._context)==null?void 0:h.input.isKeyPressed(t))||((d=this._context)==null?void 0:d.input.isKeyPressed(i));let A=!this.useViewAngle||p>.2;(r||g||this._context.input.getPointerPressedCount()>1)&&(A=!1);const v=this._didDragOnGroundPlaneLastFrame!==A;if(this._didDragOnGroundPlaneLastFrame=A,this._hasGroundPlane||(this._requireUpdateGroundPlane=!0),(this._requireUpdateGroundPlane||!A||v)&&this.onUpdateGroundPlane(),this._requireUpdateGroundPlane=!1,this._hasGroundPlane)if(this._raycaster.ray.intersectPlane(this._groundPlane,this._intersection)){const m=this._intersection.y;if(this._groundPlanePoint.copy(this._intersection).sub(this._groundOffset),this._groundPlanePoint.y=m,A){this._groundOffsetVector.set(0,1,0);const b=this._intersection.sub(this._groundOffset).add(this._groundOffsetVector.multiplyScalar(this._groundOffsetFactor));this.onUpdateWorldPosition(b,this._groundPlanePoint,!1),this.onDidUpdate();return}}else this._groundPlanePoint.set(0,99999,0);v&&this.onUpdateScreenSpacePlane(),this._requireUpdateGroundPlane=!0,this._raycaster.ray.intersectPlane(this._cameraPlane,this._intersection)&&(this.onUpdateWorldPosition(this._intersection.sub(this._cameraPlaneOffset),this._groundPlanePoint,!0),this.onDidUpdate())}}onUpdateWorldPosition(e,t,i){if(this._selected){if(i){const s=wt(this._selected);s.y=e.y,e=s}if(fn(this._selected,e),fn(this._groundLine,e),this._hasGroundPlane?this._groundLine.scale.y=this._groundDistance:this._groundLine.scale.y=1e3,this._groundLine.visible=this.showGizmo,this._groundMarker.visible=t!==null&&this.showGizmo,t){const s=wt(this._camera).distanceTo(t)*.01;this._groundMarker.scale.set(s,s,s),fn(this._groundMarker,t)}}}onUpdateScreenSpacePlane(){if(!this._selected||!this._context)return;const e=this._context.input.getPointerPositionRC(0);e&&(this._raycaster.setFromCamera(e,this._camera),this._cameraPlane.setFromNormalAndCoplanarPoint(this._camera.getWorldDirection(this._cameraPlane.normal),this._worldPosition.setFromMatrixPosition(this._selected.matrixWorld)),this._raycaster.ray.intersectPlane(this._cameraPlane,this._intersection)&&this._selected.parent&&(this._inverseMatrix.copy(this._selected.parent.matrixWorld).invert(),this._cameraPlaneOffset.copy(this._intersection).sub(this._worldPosition.setFromMatrixPosition(this._selected.matrixWorld))))}onUpdateGroundPlane(){if(!this._selected||!this._context)return;const e=wt(this._selected),t=new ja(new S(0,.1,0).add(e),new S(0,-1,0)),i=new sa;i.ignore=[this._selected];const s=this._context.physics.raycastFromRay(t,i);for(let r=0;r<s.length;r++){const o=s[r];if(!o.face||this.contains(this._selected,o.object))continue;const a=new S(0,1,0);this._groundPlane.setFromNormalAndCoplanarPoint(a,o.point);break}this._hasGroundPlane=!0,this._groundPlane.setFromNormalAndCoplanarPoint(t.direction.multiplyScalar(-1),t.origin),this._raycaster.ray.intersectPlane(this._groundPlane,this._intersection),this._groundDistance=this._intersection.distanceTo(e),this._groundOffset.copy(this._intersection).sub(e)}onDidUpdate(){vr.markDirty(this._selected);for(const e of this._rbs)e.wakeUp(),e.resetForcesAndTorques(),e.setAngularVelocity(0,0,0)}contains(e,t){if(e===t)return!0;if(e.children){for(const i of e.children)if(this.contains(i,t))return!0}return!1}};let C0=oR;u(C0,"geometry",new vt().setFromPoints([new S(0,0,0),new S(0,-1,0)]));function dI(n,e,t){console.warn("Adding components on object has been temporarily disabled")}var Bz=(n=>(n.File_Spawned="file-spawned",n))(Bz||{});class Dz{constructor(e,t,i,s,r,o,a,c){u(this,"guid");u(this,"file_name");u(this,"file_hash");u(this,"file_size");u(this,"position");u(this,"seed");u(this,"sender");u(this,"serverUrl");u(this,"parentGuid");u(this,"boundsSize");this.seed=t,this.guid=i,this.file_name=s,this.file_hash=r,this.file_size=o,this.position=a,this.sender=e,this.serverUrl=c}}async function Oz(n,e,t){const i=n.name;return i.endsWith(".gltf")||i.endsWith(".glb")?new Promise((s,r)=>{const o=new FileReader;o.readAsArrayBuffer(n),o.onloadend=async a=>{const c=o.result,l=I_(),h=new Js(l),d=await ea().parseSync(e,c,n.name,h);if(d&&d.scene){const f=d.scene;if(!f.guid){const p=new Js(l);f.guid=p.generateUUID()}t&&cne(e.connection,n,l,f,t),dI(),s(d)}}}):(console.warn("Unsupported file type: "+i,n),null)}async function kz(n,e){return new Promise(async(t,i)=>{const s=I_(),r=new Js(s),o=n.toString(),a=await ea().loadSync(e,o,o,r);a&&a.scene?(a.scene,dI(),t(a)):console.warn("Unsupported file type: "+n.toString())})}Bi.registerCallback(Qs.ContextCreated,n=>{Lz(n.context)});function Lz(n){n.connection.beginListen("file-spawned",async e=>{if(e.sender!==n.connection.connectionId){console.log("received file event",e),lne(e,n);let t=null;try{t=await K1(e.file_name,e.file_hash,e.file_size,e.serverUrl)}finally{hne(e)}if(t){const i=new Js(e.seed),s=await ea().parseSync(n,t,e.file_name,i);if(s&&s.scene){const r=s.scene;if(dI(),e.parentGuid){const o=wA(e.parentGuid,n.scene);o&&"add"in o&&o.add(r)}r.parent||n.scene.add(r),e.position!==null&&r.position.copy(e.position)}}else console.error("download didnt return file")}})}async function cne(n,e,t,i,s){if(!n.connectionId){console.error("Can not upload file - no connection id");return}if(!i.guid){console.error("Can not upload file - no guid",i,i.guid);return}const r=await QU(e,s);if(!r)return;if(!r.filename){console.error("Can not send upload event - no filename",e.name);return}if(!r.hash){console.error("Can not send upload event - no hash",e.name);return}const o=new Dz(n.connectionId,t,i.guid,r.filename,r.hash,e.size,i.position,r.url??s);i.parent&&(o.parentGuid=i.parent.guid),n.send("file-spawned",o)}const ZE={};function lne(n,e){const t=new vi,i=new ye(t,new hi({color:65280})),s=new y_(i,5592405);if(ZE[n.guid]=s,e.scene.add(s),n.parentGuid){const r=wA(n.parentGuid,e.scene);r&&r.add(s)}n.position&&s.position.copy(n.position)}function hne(n,e){const t=n.guid,i=ZE[t];i&&(delete ZE[t],i.removeFromParent())}var une=Object.defineProperty,dne=Object.getOwnPropertyDescriptor,fI=(n,e,t,i)=>{for(var s=i>1?void 0:i?dne(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&une(e,t,s),s};const fne=re("debugnet"),$E=class extends Me{constructor(){super(...arguments);u(this,"url",null);u(this,"urlParameterName",null);u(this,"localhost",null)}awake(){fne&&console.log(this),this.context.connection.registerProvider(this)}getWebsocketUrl(){let e=this.url?$E.GetUrl(this.url,this.localhost):null;if(this.urlParameterName){const r=re(this.urlParameterName);r&&typeof r=="string"&&(e=r)}if(!e)return null;const i=new RegExp("(((https?)|(?<socket_prefix>wss?))://)?(www.)?(?<url>.+)","gm").exec(e);return i!=null&&i.groups?(i==null?void 0:i.groups.socket_prefix)?e:"wss://"+(i==null?void 0:i.groups.url):null}static GetUrl(e,t){let i=e;const s=$E.IsLocalNetwork()&&t;if(s&&(i=t),e!=null&&e.startsWith("/")){const r=s?i:window.location.origin;r!=null&&r.endsWith("/")&&e.startsWith("/")&&(e=e.substring(1)),i=r+e}return i}static IsLocalNetwork(e=window.location.hostname){return $s(e)}};let qu=$E;fI([x()],qu.prototype,"url",2);fI([x()],qu.prototype,"urlParameterName",2);fI([x()],qu.prototype,"localhost",2);var pne=Object.defineProperty,gne=Object.getOwnPropertyDescriptor,Fz=(n,e,t,i)=>{for(var s=i>1?void 0:i?gne(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&pne(e,t,s),s};const Od=re("debugdroplistener");class JA extends Me{constructor(){super(...arguments);u(this,"filesBackendUrl");u(this,"localhost");u(this,"onDrag",t=>{t.preventDefault()});u(this,"onDrop",async t=>{if(Od&&console.log(t),!(t!=null&&t.dataTransfer))return;t.preventDefault();const i=t.dataTransfer.items;if(i)for(const s in i){const r=i[s];if(r.kind==="file"){const o=r.getAsFile();if(!o)continue;await this.addFiles(o)}else r.kind==="string"&&r.type=="text/plain"&&r.getAsString(async o=>{Od&&console.log("dropped url",o);try{const a=new URL(o);if(!a)return;const c=await kz(a,this.context);c&&this.addObject(t,c)}catch{console.log("dropped string is not a valid URL!",o)}})}})}onEnable(){this.filesBackendUrl=qu.GetUrl(this.filesBackendUrl,this.localhost)??this.filesBackendUrl,Od&&console.log(this,this.filesBackendUrl),this.context.domElement.addEventListener("dragover",this.onDrag),this.context.domElement.addEventListener("drop",this.onDrop)}onDisable(){this.context.domElement.removeEventListener("dragover",this.onDrag),this.context.domElement.removeEventListener("drop",this.onDrop)}async addFiles(...t){if(Od&&console.log("Add files",t),!!Array.isArray(t)&&t.length)for(const i of t){if(!i)continue;Od&&console.log("Register file "+i.name+" to",this.filesBackendUrl,i);const s=await Oz(i,this.context,this.filesBackendUrl);this.dispatchEvent(new CustomEvent("file-dropped",{detail:i})),s&&this.addObject(void 0,s)}}async addObject(t,i){if(Od&&console.log("Dropped",i),!(i!=null&&i.scene)){console.warn("No object specified to add to scene",i);return}const s=i.scene;if(t!==void 0){const r=new sa;r.setMask(16777215),r.screenPointFromOffset(t.offsetX,t.offsetY);const o=this.context.physics.raycast(r);if(o&&o.length>0)for(const a of o){s.position.copy(a.point);break}}this.gameObject.add(s),this.dispatchEvent(new CustomEvent("object-added",{detail:i}))}}Fz([x()],JA.prototype,"filesBackendUrl",2);Fz([x()],JA.prototype,"localhost",2);var mne=Object.defineProperty,Ane=Object.getOwnPropertyDescriptor,bx=(n,e,t,i)=>{for(var s=i>1?void 0:i?Ane(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&mne(e,t,s),s};class Yu extends np{constructor(){super(...arguments);u(this,"parent",null);u(this,"object",null);u(this,"limitCount",10);u(this,"limitInterval",60);u(this,"_currentCount",0);u(this,"_startPosition",null);u(this,"_startQuaternion",null)}awake(){var i,s;if(this.object){if(this.object===this.gameObject){console.error("Can not duplicate self");return}this.object.visible=!1,this._startPosition=((i=this.object.position)==null?void 0:i.clone())??new S(0,0,0),this._startQuaternion=((s=this.object.quaternion)==null?void 0:s.clone())??new Se(0,0,0,1)}const t=se.getComponentInParent(this.gameObject,_p);t?t.addDragEventListener(Pz.SelectStart,(r,o)=>{if(this._currentCount>=this.limitCount){o.attached=null;return}const a=this.handleDuplication(o.selected);a&&(console.assert(a!==o.selected,"Duplicated object is original"),o.attached=a)}):console.warn("Could no find drag controls in parent",this.name),en.addEventListener(_c.SelectStart,(r,o)=>{if(this._currentCount>=this.limitCount){o.grab=null;return}const a=this.handleDuplication(o.selected);a&&(o.grab=a)}),this.cloneLimitIntervalFn()}cloneLimitIntervalFn(){this.destroyed||(this._currentCount>0&&(this._currentCount-=1),setTimeout(()=>{this.cloneLimitIntervalFn()},this.limitInterval/this.limitCount*1e3))}handleDuplication(t){var i;if(this._currentCount>=this.limitCount||!this.object)return null;if(t===this.gameObject||this.handleMultiObject(t)){if(this.object===this.gameObject)return null;this.object.visible=!0,this._startPosition&&this.object.position.copy(this._startPosition),this._startQuaternion&&this.object.quaternion.copy(this._startQuaternion);const s=new Qa;this.parent||(this.parent=this.gameObject.parent),this.parent&&(s.parent=this.parent.guid??((i=this.parent.userData)==null?void 0:i.guid),s.keepWorldPosition=!0),s.position=this.worldPosition,s.rotation=this.worldQuaternion,s.context=this.context,this._currentCount+=1;const r=se.instantiateSynced(this.object,s);return console.assert(r!==this.object,"Duplicated object is original"),this.object.visible=!1,this._startPosition&&this.object.position.clone().copy(this._startPosition),this._startQuaternion&&this.object.quaternion.clone().copy(this._startQuaternion),r}return null}handleMultiObject(t){return this.gameObject.type==="Group"||this.gameObject.type==="Object3D"?this.isInChildren(this.gameObject,t):!1}isInChildren(t,i){if(!t)return!1;if(t===i)return!0;if(t.children){for(const s of t.children)if(this.isInChildren(s,i))return!0}return!1}}bx([x(Te)],Yu.prototype,"parent",2);bx([x(Te)],Yu.prototype,"object",2);bx([x()],Yu.prototype,"limitCount",2);bx([x()],Yu.prototype,"limitInterval",2);var jd=(n=>(n[n.PointerEnter=0]="PointerEnter",n[n.PointerExit=1]="PointerExit",n[n.PointerDown=2]="PointerDown",n[n.PointerUp=3]="PointerUp",n[n.PointerClick=4]="PointerClick",n[n.Drag=5]="Drag",n[n.Drop=6]="Drop",n[n.Scroll=7]="Scroll",n[n.UpdateSelected=8]="UpdateSelected",n[n.Select=9]="Select",n[n.Deselect=10]="Deselect",n[n.Move=11]="Move",n[n.InitializePotentialDrag=12]="InitializePotentialDrag",n[n.BeginDrag=13]="BeginDrag",n[n.EndDrag=14]="EndDrag",n[n.Submit=15]="Submit",n[n.Cancel=16]="Cancel",n))(jd||{}),vne=Object.defineProperty,yne=Object.getOwnPropertyDescriptor,pI=(n,e,t,i)=>{for(var s=i>1?void 0:i?yne(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&vne(e,t,s),s};class gI{constructor(){u(this,"eventID");u(this,"callback")}}pI([x()],gI.prototype,"eventID",2);pI([x(cs)],gI.prototype,"callback",2);class _x extends Me{constructor(){super(...arguments);u(this,"triggers")}invoke(t){if(this.triggers)for(const i of this.triggers)i.eventID===t&&i.callback.invoke()}onPointerClick(t){this.invoke(jd.PointerClick)}onPointerEnter(t){this.invoke(jd.PointerEnter)}onPointerExit(t){this.invoke(jd.PointerExit)}onPointerDown(t){this.invoke(jd.PointerDown)}onPointerUp(t){this.invoke(jd.PointerUp)}}pI([x(gI)],_x.prototype,"triggers",2);var bne=Object.defineProperty,_ne=Object.getOwnPropertyDescriptor,mI=(n,e,t,i)=>{for(var s=i>1?void 0:i?_ne(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&bne(e,t,s),s};class AI extends Me{constructor(){super(...arguments);u(this,"connectedBody");u(this,"_rigidBody",null)}get rigidBody(){return this._rigidBody}onEnable(){this._rigidBody||(this._rigidBody=this.gameObject.getComponent(Yi)),this.rigidBody&&this.connectedBody&&this.startCoroutine(this.create())}*create(){yield,this.rigidBody&&this.connectedBody&&this.createJoint(this.rigidBody,this.connectedBody)}}mI([x(Yi)],AI.prototype,"connectedBody",2);class vI extends AI{createJoint(e,t){var i;(i=this.context.physics.engine)==null||i.addFixedJoint(e,t)}}class ZA extends AI{constructor(){super(...arguments);u(this,"anchor");u(this,"axis")}createJoint(t,i){var s;this.axis&&this.anchor&&((s=this.context.physics.engine)==null||s.addHingeJoint(t,i,this.anchor,this.axis))}}mI([x(S)],ZA.prototype,"anchor",2);mI([x(S)],ZA.prototype,"axis",2);const xne={type:"change"};let wne=class extends Gn{constructor(e,t){super(),this.object=e,this.domElement=t,this.enabled=!0,this.movementSpeed=1,this.rollSpeed=.005,this.dragToLook=!1,this.autoForward=!1;const i=this,s=1e-6,r=new Se,o=new S;this.tmpQuaternion=new Se,this.status=0,this.moveState={up:0,down:0,left:0,right:0,forward:0,back:0,pitchUp:0,pitchDown:0,yawLeft:0,yawRight:0,rollLeft:0,rollRight:0},this.moveVector=new S(0,0,0),this.rotationVector=new S(0,0,0),this.keydown=function(p){if(!(p.altKey||this.enabled===!1)){switch(p.code){case"ShiftLeft":case"ShiftRight":this.movementSpeedMultiplier=.1;break;case"KeyW":this.moveState.forward=1;break;case"KeyS":this.moveState.back=1;break;case"KeyA":this.moveState.left=1;break;case"KeyD":this.moveState.right=1;break;case"KeyR":this.moveState.up=1;break;case"KeyF":this.moveState.down=1;break;case"ArrowUp":this.moveState.pitchUp=1;break;case"ArrowDown":this.moveState.pitchDown=1;break;case"ArrowLeft":this.moveState.yawLeft=1;break;case"ArrowRight":this.moveState.yawRight=1;break;case"KeyQ":this.moveState.rollLeft=1;break;case"KeyE":this.moveState.rollRight=1;break}this.updateMovementVector(),this.updateRotationVector()}},this.keyup=function(p){if(this.enabled!==!1){switch(p.code){case"ShiftLeft":case"ShiftRight":this.movementSpeedMultiplier=1;break;case"KeyW":this.moveState.forward=0;break;case"KeyS":this.moveState.back=0;break;case"KeyA":this.moveState.left=0;break;case"KeyD":this.moveState.right=0;break;case"KeyR":this.moveState.up=0;break;case"KeyF":this.moveState.down=0;break;case"ArrowUp":this.moveState.pitchUp=0;break;case"ArrowDown":this.moveState.pitchDown=0;break;case"ArrowLeft":this.moveState.yawLeft=0;break;case"ArrowRight":this.moveState.yawRight=0;break;case"KeyQ":this.moveState.rollLeft=0;break;case"KeyE":this.moveState.rollRight=0;break}this.updateMovementVector(),this.updateRotationVector()}},this.pointerdown=function(p){if(this.enabled!==!1)if(this.dragToLook)this.status++;else{switch(p.button){case 0:this.moveState.forward=1;break;case 2:this.moveState.back=1;break}this.updateMovementVector()}},this.pointermove=function(p){if(this.enabled!==!1&&(!this.dragToLook||this.status>0)){const g=this.getContainerDimensions(),A=g.size[0]/2,v=g.size[1]/2;this.moveState.yawLeft=-(p.pageX-g.offset[0]-A)/A,this.moveState.pitchDown=(p.pageY-g.offset[1]-v)/v,this.updateRotationVector()}},this.pointerup=function(p){if(this.enabled!==!1){if(this.dragToLook)this.status--,this.moveState.yawLeft=this.moveState.pitchDown=0;else{switch(p.button){case 0:this.moveState.forward=0;break;case 2:this.moveState.back=0;break}this.updateMovementVector()}this.updateRotationVector()}},this.contextMenu=function(p){this.enabled!==!1&&p.preventDefault()},this.update=function(p){if(this.enabled===!1)return;const g=p*i.movementSpeed,A=p*i.rollSpeed;i.object.translateX(i.moveVector.x*g),i.object.translateY(i.moveVector.y*g),i.object.translateZ(i.moveVector.z*g),i.tmpQuaternion.set(i.rotationVector.x*A,i.rotationVector.y*A,i.rotationVector.z*A,1).normalize(),i.object.quaternion.multiply(i.tmpQuaternion),(o.distanceToSquared(i.object.position)>s||8*(1-r.dot(i.object.quaternion))>s)&&(i.dispatchEvent(xne),r.copy(i.object.quaternion),o.copy(i.object.position))},this.updateMovementVector=function(){const p=this.moveState.forward||this.autoForward&&!this.moveState.back?1:0;this.moveVector.x=-this.moveState.left+this.moveState.right,this.moveVector.y=-this.moveState.down+this.moveState.up,this.moveVector.z=-p+this.moveState.back},this.updateRotationVector=function(){this.rotationVector.x=-this.moveState.pitchDown+this.moveState.pitchUp,this.rotationVector.y=-this.moveState.yawRight+this.moveState.yawLeft,this.rotationVector.z=-this.moveState.rollRight+this.moveState.rollLeft},this.getContainerDimensions=function(){return this.domElement!=document?{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}:{size:[window.innerWidth,window.innerHeight],offset:[0,0]}},this.dispose=function(){this.domElement.removeEventListener("contextmenu",a),this.domElement.removeEventListener("pointerdown",l),this.domElement.removeEventListener("pointermove",c),this.domElement.removeEventListener("pointerup",h),window.removeEventListener("keydown",d),window.removeEventListener("keyup",f)};const a=this.contextMenu.bind(this),c=this.pointermove.bind(this),l=this.pointerdown.bind(this),h=this.pointerup.bind(this),d=this.keydown.bind(this),f=this.keyup.bind(this);this.domElement.addEventListener("contextmenu",a),this.domElement.addEventListener("pointerdown",l),this.domElement.addEventListener("pointermove",c),this.domElement.addEventListener("pointerup",h),window.addEventListener("keydown",d),window.addEventListener("keyup",f),this.updateMovementVector(),this.updateRotationVector()}};class yI extends Me{constructor(){super(...arguments);u(this,"_controls",null)}onEnable(){var i;const t=(i=se.getComponent(this.gameObject,Oi))==null?void 0:i.cam;if(!t){console.warn("FlyControls: Requires a Camera component on the same object as this component.");return}this._controls=new wne(t,this.context.renderer.domElement),this._controls.rollSpeed=.5,this._controls.movementSpeed=3,this._controls.dragToLook=!0}onDisable(){var t;(t=this._controls)==null||t.dispose(),this._controls=null}update(){this._controls&&this._controls.update(this.context.time.deltaTime)}}var Sne=Object.defineProperty,Cne=Object.getOwnPropertyDescriptor,bI=(n,e,t,i)=>{for(var s=i>1?void 0:i?Cne(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Sne(e,t,s),s};class xp extends Me{constructor(){super(...arguments);u(this,"_fog")}get fog(){return this._fog||(this._fog=new JM(0,0,50)),this._fog}get mode(){return 1}set near(t){this.fog.near=t}get near(){return this.fog.near}set far(t){this.fog.far=t}get far(){return this.fog.far}set color(t){this.fog.color.copy(t)}get color(){return this.fog.color}onEnable(){this.scene.fog=this.fog}onDisable(){this.scene.fog===this._fog&&(this.scene.fog=null)}}bI([x()],xp.prototype,"near",1);bI([x()],xp.prototype,"far",1);bI([x(_e)],xp.prototype,"color",1);let Dy,DS,kd,Oy;function OS(n,e=1/0,t=null){DS||(DS=new ds(2,2,1,1)),kd||(kd=new Lt({uniforms:{blitTexture:new xe(n)},vertexShader:`
|
|
5072
|
+
`,this.context.appendHTMLElement(i);const s=ES;ES&&console.log("ARSupported?",wg,"VRSupported?",Sg),(s||this.createARButton&&this.enableAR&&wg)&&(e=Dn.createARButton(this),this._arButton=e,i.appendChild(e)),(s||this.createVRButton&&this.enableVR&&Sg)&&(t=Dn.createVRButton(this),this._vrButton=t,i.appendChild(t)),setTimeout(()=>{Dn.resetButtonStyles(t),Dn.resetButtonStyles(e)},1e3)}get TransformOrientation(){return this._transformOrientation}get HeadPose(){return this._currentHeadPose}onBeforeRender(e){var i;if(!e)return;const t=this.context.renderer.xr.getSession();if(t){const s=e.getViewerPose(this.context.renderer.xr.getReferenceSpace());if(!s)return;this._currentHeadPose=s;const r=s==null?void 0:s.transform;r&&this._transformOrientation.set(r.orientation.x,r.orientation.y,r.orientation.z,r.orientation.w),Dn._isInXr===!1&&t&&this.onEnterXR(t,e);for(const o of this.controllers)o.onUpdate(t);this._isInAR&&((i=this.webAR)==null||i.onUpdate(t,e))}Dn.events.dispatchEvent({type:"xrUpdate",frame:e,xr:this.context.renderer.xr,rig:this.rig})}onClickedARButton(){this._isInAR||(this._requestedAR=!0,this._requestedVR=!1,this.captureStateBeforeXR())}onClickedVRButton(){if(!this._isInVR){if(this._requestedVR){this.onExitXR(null);return}this._requestedAR=!1,this._requestedVR=!0,this.captureStateBeforeXR(),this.ensureRig();for(let e=0;e<2;e++)en.Create(this,e,this.gameObject,Af.PhysicalDevice);Dn.events.dispatchEvent({type:"requestVRSession"})}}captureStateBeforeXR(){this.context.mainCamera&&(this._originalCameraPosition.copy(wt(this.context.mainCamera)),this._originalCameraRotation.copy(Fn(this.context.mainCamera)),this._originalCameraParent=this.context.mainCamera.parent),this.Rig&&(this._originalXRRigParent=this.Rig.parent,this._originalXRRigPosition.copy(this.Rig.position),this._originalXRRigRotation.copy(this.Rig.quaternion))}ensureRig(){if(!this.rig){const e=se.findObjectOfType(rx,this.context);e?(this.rig=e.gameObject,this.rig.rotateY(Math.PI)):(this.rig=new zr,this.rig.rotateY(Math.PI),this.rig.name="XRRig",this.context.scene.add(this.rig))}}onEnterXR(e,t){var o,a;console.log("[XR] session begin",e,t),Dn._isInXr=!0,this.ensureRig();const i=this.context.renderer.xr.getReferenceSpace();if(i&&this.rig){const c=t.getViewerPose(i),l=c==null?void 0:c.transform.orientation;if(l){const h=new Se(l.x,l.y,l.z,l.w),d=new Sn().setFromQuaternion(h);this.rig.rotateY(d.y)}}const s=this.context.renderer.xr;if(this.context.mainCamera){const c=s.getCamera();ES&&console.log("WebXRCamera",c);const l=(o=this.context.mainCameraComponent)==null?void 0:o.cullingMask;if(c&&l!==void 0){for(const h of c.cameras)h.layers.mask=l;c.layers.mask=l}else if(c){for(const h of c.cameras)h.layers.enableAll();c.layers.enableAll()}this.rig.add(this.context.mainCamera),this._requestedAR&&this.context.scene.add(this.rig)}const r=this._requestedAR?un.AR:un.VR;switch(Xs.Global.Set(r),r){case un.AR:this.context.xrSessionMode=Dm.ImmersiveAR,this._isInAR=!0,(a=this.webAR)==null||a.onBegin(e);break;case un.VR:this.context.xrSessionMode=Dm.ImmersiveVR,this._isInVR=!0,this.onEnterVR(e);break}e.addEventListener("end",()=>{console.log("[XR] session end"),Dn._isInXr=!1,this.onExitXR(e)}),this.onEnterXR_HandleMirrorWindow(e),Dn.events.dispatchEvent({type:"xrStarted",session:e})}onExitXR(e){var i,s,r,o;const t=this._isInAR;e&&(this._isInAR?(i=this.webAR)==null||i.onEnd(e):(s=this.context.mainCameraComponent)==null||s.applyClearFlagsIfIsActiveCamera()),this._isInAR=!1,this._isInVR=!1,this._requestedAR=!1,this._requestedVR=!1,this.context.xrSessionMode=void 0,this.xrMirrorWindow&&(this.xrMirrorWindow.close(),this.xrMirrorWindow=null),this.destroyControllers(),this.context.mainCamera&&((r=this._originalCameraParent)==null||r.add(this.context.mainCamera),fn(this.context.mainCamera,this._originalCameraPosition),_r(this.context.mainCamera,this._originalCameraRotation),this.context.mainCamera.scale.set(1,1,1)),t&&((o=this._originalXRRigParent)==null||o.add(this.rig),this.rig.position.copy(this._originalXRRigPosition),this.rig.quaternion.copy(this._originalXRRigRotation)),Xs.Global.Set(un.Browser|un.ThirdPerson),Dn.events.dispatchEvent({type:"xrStopped",session:e})}onEnterVR(e){}destroyControllers(){var e;for(let t=this.controllers.length-1;t>=0;t-=1)(e=this.controllers[t])==null||e.destroy();this.controllers.length=0}onEnterXR_HandleMirrorWindow(e){re("mirror")&&setTimeout(()=>{if(!Dn.IsInWebXR)return;const t=new URL(window.location.href);fm(t.searchParams,ub,1),fm(t.searchParams,"isMirror",1);const i=t.toString();this.xrMirrorWindow=window.open(i,"webxr sync","popup=yes"),this.xrMirrorWindow&&(this.xrMirrorWindow.onload=()=>{this.xrMirrorWindow&&(this.xrMirrorWindow.onbeforeunload=()=>{Dn.IsInWebXR&&e.end()})})},1e3)}},u(zd,"_isInXr",!1),u(zd,"events",new Gn),u(zd,"_optionalFeatures_VR",["local-floor","bounded-floor","hand-tracking","high-fixed-foveation-level","layers"]),u(zd,"_optionalFeatures_AR",["anchors","local-floor","hand-tracking","layers"]),zd);let Et=Dn;cp([x()],Et.prototype,"enableVR",2);cp([x()],Et.prototype,"enableAR",2);cp([x(Un)],Et.prototype,"defaultAvatar",2);cp([x()],Et.prototype,"handModelPath",2);cp([x()],Et.prototype,"createVRButton",2);cp([x()],Et.prototype,"createARButton",2);const of=class{constructor(e){u(this,"_webxr");u(this,"reticle",null);u(this,"reticleParent",null);u(this,"hitTestSource",null);u(this,"reticleActive",!0);u(this,"previousBackground",null);u(this,"previousEnvironment",null);u(this,"sessionRoot",null);u(this,"_previousParent",null);u(this,"arDomOverlay",null);u(this,"arOverlayElement",null);u(this,"noHitTestAvailable",!1);u(this,"didPlaceARSessionRoot",!1);this._webxr=e}get webxr(){return this._webxr}get context(){return this.webxr.context}getAROverlayContainer(){this.arDomOverlay=this.webxr.context.domElement;const e=this.arDomOverlay;return e.getAROverlayContainer?this.arOverlayElement=e.getAROverlayContainer():this.arOverlayElement=this.arDomOverlay,this.arOverlayElement}setReticleActive(e){this.reticleActive=e}async onBegin(e){var o,a,c,l;const t=this.webxr.context;this.reticleActive=!0,this.didPlaceARSessionRoot=!1,this.getAROverlayContainer();const i=(o=navigator.userAgent)!=null&&o.includes("OculusBrowser")?Af.PhysicalDevice:Af.Touch,s=i===Af.Touch?4:2;for(let h=0;h<s;h++)en.Create(this.webxr,h,this.webxr.gameObject,i);if((!this.sessionRoot||this.sessionRoot.destroyed||!this.sessionRoot.activeAndEnabled)&&(this.sessionRoot=se.findObjectOfType(Wa,t)),!this.sessionRoot){const h=this.webxr.gameObject;this.sessionRoot=se.addNewComponent(h,Wa),console.warn("WebAR: No ARSessionRoot found, creating one automatically on the WebXR object")}this.previousBackground=t.scene.background,this.previousEnvironment=t.scene.environment,t.scene.background=null,e.requestReferenceSpace("viewer").then(h=>{var d,f;(f=(d=e.requestHitTestSource)==null?void 0:d.call(e,{space:h}))==null||f.then(p=>{this.hitTestSource=p}).catch(p=>{this.noHitTestAvailable=!0,console.warn("WebXR: Hit test not supported",p)})}),!this.reticle&&this.sessionRoot&&(this.reticle=new ye(new pA(.07,.09,32).rotateX(-Math.PI/2),new hi),this.reticle.name="AR Placement reticle",this.reticle.matrixAutoUpdate=!1,this.reticle.visible=!1,this.reticleParent=new Te,this.reticleParent.name="AR Reticle Parent",this.reticleParent.matrixAutoUpdate=!1,this.reticleParent.add(this.reticle),this.webxr.scene?(this.context.scene.add(this.reticleParent),this.context.scene.visible=!0):console.warn("Could not found WebXR Rig")),this._previousParent=this.webxr.gameObject,of.tempWebXRObject||(of.tempWebXRObject=new Te),this.context.scene.add(of.tempWebXRObject),se.addComponent(of.tempWebXRObject,this.webxr),this.sessionRoot?(this.sessionRoot.webAR=this,(a=this.sessionRoot)==null||a.onBegin(e)):console.warn("No WebARSessionRoot found in scene");const r=this.context.domElement;(c=r==null?void 0:r.onEnterAR)==null||c.call(r,e,this.arOverlayElement),(l=this.context.mainCameraComponent)==null||l.applyClearFlagsIfIsActiveCamera()}onEnd(e){var s,r;this._previousParent&&(se.addComponent(this._previousParent,this.webxr),this._previousParent=null),this.hitTestSource=null;const t=this.webxr.context;t.scene.background=this.previousBackground,t.scene.environment=this.previousEnvironment,this.sessionRoot&&this.sessionRoot.onEnd(this.webxr.Rig,e);const i=this.context.domElement;(s=i.onExitAR)==null||s.call(i,e),(r=this.context.mainCameraComponent)==null||r.applyClearFlagsIfIsActiveCamera()}onUpdate(e,t){var s,r;if(this.noHitTestAvailable===!0){if(this.reticle&&(this.reticle.visible=!1),!this.didPlaceARSessionRoot){this.didPlaceARSessionRoot=!0;const o=this.webxr.Rig,a=Ete.clone();(s=this.sessionRoot)==null||s.placeAt(o,a)}return}if(!this.hitTestSource)return;const i=t.getHitTestResults(this.hitTestSource);if(i.length){const o=i[0],a=this.webxr.context.renderer.xr.getReferenceSpace();if(a){const c=o.getPose(a);if(this.sessionRoot){const l=this.sessionRoot.onUpdate(this.webxr.Rig,e,c);this.didPlaceARSessionRoot=l}if(this.reticle&&(this.reticle.visible=this.reticleActive,this.reticleActive&&c)){const l=c.transform.matrix;this.reticle.matrix.fromArray(l),this.webxr.Rig&&this.reticle.matrix.premultiply(this.webxr.Rig.matrix)}}}else(r=this.sessionRoot)==null||r.onUpdate(this.webxr.Rig,e,null),this.reticle&&(this.reticle.visible=!1)}};let vu=of;u(vu,"tempWebXRObject");const Ete=new Re().identity().makeTranslation(0,0,0);class Fc{constructor(e,t){u(this,"used",!1);u(this,"positionDelta",new te);u(this,"inputSource");u(this,"object");u(this,"pointerId");u(this,"isDown");u(this,"isUp");u(this,"isPressed");u(this,"isClicked");u(this,"input");u(this,"event");this.event=t,this.input=e}use(){this.used=!0,this.pointerId!==void 0&&this.input.setPointerUsed(this.pointerId)}stopPropagation(){var e;(e=this.event)==null||e.stopImmediatePropagation()}Use(){this.use()}StopPropagation(){var e;(e=this.event)==null||e.stopImmediatePropagation()}clone(){const e=new Fc(this.input,this.event);return Object.assign(e,this),e}}class lp extends Me{awake(){qs.createIfNoneExists(this.context)}onEnable(){var e;(e=qs.get(this.context))==null||e.register(this)}onDisable(){var e;(e=qs.get(this.context))==null||e.unregister(this)}performRaycast(e=null){return null}}class el extends lp{constructor(){super(...arguments);u(this,"targets",null);u(this,"raycastHits",[])}start(){this.targets=[this.gameObject]}performRaycast(t=null){return this.targets?(t??(t=new sa),t.targets=this.targets,t.results=this.raycastHits,this.context.physics.raycast(t)):null}}class qT extends el{}const Cg=re("debugeventsystem");var YE=(n=>(n.BeforeHandleInput="BeforeHandleInput",n.AfterHandleInput="AfterHandleInput",n))(YE||{});const ba=class extends Me{constructor(){super();u(this,"raycaster",[]);u(this,"_selectStartFn");u(this,"_selectEndFn");u(this,"_selectUpdateFn");u(this,"_handleEventFn");u(this,"lastPointerEvent",null);u(this,"objectsHoveredThisFrame",[]);u(this,"objectsHoveredLastFrame",[]);u(this,"raisedPointerDownEvents",[]);u(this,"raisedPointerDownObjects",[]);u(this,"_didMove",!1);u(this,"_tempComponentsArray",[]);u(this,"_sortedHits",[]);u(this,"_sortingBuffer",[]);u(this,"_noDepthTestingResults",[]);u(this,"handleEventsArray",[]);u(this,"out",{});u(this,"currentActiveMeshUIComponents",[]);ba.systems.push(this)}static createIfNoneExists(t){this.didSearchEventSystem||(this.didSearchEventSystem=!0,ba.systems.length<=0&&ba.systems.push(...se.findObjectsOfType(ba,t)));for(const s of ba.systems)if(s.context===t)return;const i=new Te;se.addNewComponent(i,ba),t.scene.add(i)}static get systems(){const t=Nt.Current;return this._eventSystemMap.has(t)||this._eventSystemMap.set(t,[]),this._eventSystemMap.get(t)}static get(t){const i=this._eventSystemMap.get(t);return i&&i.length>0?i[0]:null}static get instance(){return this.systems[0]}static ensureUpdateMeshUI(t,i){xc.update(t,i)}static markUIDirty(t){xc.markDirty()}get hasActiveUI(){return this.currentActiveMeshUIComponents.length>0}get isHoveringObjects(){return this.objectsHoveredThisFrame.length>0}onDestroy(){ba.systems.splice(ba.systems.indexOf(this),1)}start(){if(this.raycaster.length<=0&&!se.findObjectOfType(lp,this.context)){const i=se.addNewComponent(this.context.scene,el);this.raycaster.push(i),bi()&&console.warn("Added an ObjectRaycaster to the scene because no raycaster was found",this)}}register(t){var i;t&&this.raycaster&&!this.raycaster.includes(t)&&((i=this.raycaster)==null||i.push(t))}unregister(t){var s,r;const i=(s=this.raycaster)==null?void 0:s.indexOf(t);i!==void 0&&i!==-1&&((r=this.raycaster)==null||r.splice(i,1))}onEnable(){const t=new Map;this._selectStartFn??(this._selectStartFn=(s,r)=>{if(!r.grab)return;xc.resetLastSelected();const o=new Fc(this.context.input);o.inputSource=s,o.pointerId=0,o.isDown=s.selectionDown,o.isUp=s.selectionUp,o.isPressed=s.selectionPressed,o.isClicked=!1,t.set(s,r.grab),r.grab&&!this.handleEvents(r.grab,o)&&(r.grab=null)}),this._selectEndFn??(this._selectEndFn=(s,r)=>{var c;if(!r.grab)return;const o=new Fc(this.context.input);o.inputSource=s,o.pointerId=0,o.isDown=s.selectionDown,o.isUp=s.selectionUp,o.isPressed=s.selectionPressed,o.isClicked=s.selectionClick,this.handleEvents(r.grab,o);const a=t.get(s);if(t.set(s,null),a)for(let l=0;l<this.raisedPointerDownEvents.length;l++){const h=this.raisedPointerDownEvents[l];this.raisedPointerDownObjects[l]===a&&h&&((c=h.onPointerUp)==null||c.call(h,o),this.raisedPointerDownEvents.splice(l,1),this.raisedPointerDownObjects.splice(l,1),l--)}});const i=new sa;this._selectUpdateFn??(this._selectUpdateFn=s=>{i.ray=s.getRay();const r=this.performRaycast(i);if(!r)return;const o=new Fc(this.context.input);o.inputSource=s,this.handleIntersections(r,o)}),en.addEventListener(_c.SelectStart,this._selectStartFn),en.addEventListener(_c.SelectEnd,this._selectEndFn),en.addEventListener(_c.Update,this._selectUpdateFn),this._handleEventFn??(this._handleEventFn=this.onHandleEvents.bind(this)),this.context.pre_update_callbacks.push(this._handleEventFn)}onDisable(){en.removeEventListener(_c.SelectStart,this._selectStartFn),en.removeEventListener(_c.SelectEnd,this._selectEndFn),en.removeEventListener(_c.Update,this._selectUpdateFn),this.context.pre_update_callbacks.splice(this.context.pre_update_callbacks.indexOf(this._handleEventFn),1)}onHandleEvents(){if(this.objectsHoveredThisFrame.length=0,this.resetMeshUIStates(),Et.IsInWebXR||this.context.input.isKeyPressed("AltLeft")||this.context.input.isKeyPressed("AltRight"))return;if(!this._didMove){const c=this.context.input.getPointerPositionRC(0);if(c&&c.x===0&&c.y===0)return;this._didMove=!0}let t=0;for(const c of this.context.input.foreachPointerId()){const l=this.context.input.getPointerDown(c),h=this.context.input.getPointerUp(c);if(l||h){t=c;break}}const i=this.context.input.getPointerEvent(t),s=new Fc(this.context.input,i);s.inputSource=this.context.input,s.pointerId=t,s.isClicked=this.context.input.getPointerClicked(t),s.isDown=this.context.input.getPointerDown(t),s.isUp=this.context.input.getPointerUp(t),s.isPressed=this.context.input.getPointerPressed(t);const r=this.context.input.getPointerPositionDelta(t);if(r&&s.positionDelta.copy(r),Cg&&s.isClicked&&console.log("CLICK",t),!s.isDown&&!s.isUp&&!s.isClicked&&!s.isPressed&&!s.positionDelta.x&&!s.positionDelta.y){this.objectsHoveredThisFrame.length=0,this.objectsHoveredThisFrame.push(...this.objectsHoveredLastFrame);return}const o=this.performRaycast(null);if(!o)return;this.lastPointerEvent=s;const a={sender:this,args:s,hasActiveUI:this.currentActiveMeshUIComponents.length>0};Cg&&s.isClicked&&_n("EventSystem: "+s.pointerId+" - "+this.context.time.frame+" - Up:"+s.isUp+", Down:"+s.isDown),this.dispatchEvent(new CustomEvent("BeforeHandleInput",{detail:a})),this.handleIntersections(o,s),this.dispatchEvent(new CustomEvent("AfterHandleInput",{detail:a}))}onBeforeRender(){if(this.lastPointerEvent)this.lastPointerEvent.used=!1;else return;if(this.lastPointerEvent.isUp){for(const i of this.raisedPointerDownEvents)i.onPointerUp&&i.onPointerUp(this.lastPointerEvent);this.raisedPointerDownEvents.length=0,this.raisedPointerDownObjects.length=0}for(const i of this.objectsHoveredLastFrame)if(this.objectsHoveredThisFrame.indexOf(i)<0){this._tempComponentsArray.length=0;const s=se.getComponentsInParent(i,Me,this._tempComponentsArray);this.lastPointerEvent.object=i;for(let r=0;r<s.length;r++){const o=s[r];if(!o.gameObject||o.destroyed)continue;const a=o;a.onPointerExit&&a.onPointerExit(this.lastPointerEvent)}}const t=this.objectsHoveredLastFrame;this.objectsHoveredLastFrame=this.objectsHoveredThisFrame,this.objectsHoveredThisFrame=t}performRaycast(t){if(!this.raycaster)return null;this._sortedHits.length=0;for(const i of this.raycaster){if(!i.activeAndEnabled)continue;const s=i.performRaycast(t);s&&s.length>0&&this._sortedHits.push(...s)}return this._sortedHits.sort((i,s)=>i.distance-s.distance),this._sortedHits}handleIntersections(t,i){if(!t||t.length<=0)return!1;t=this.sortCandidates(t);for(const s of t){const{object:r}=s;if(this.handleEvents(r,i))return!0}return!1}sortCandidates(t){this._sortingBuffer.length=0,this._noDepthTestingResults.length=0;for(let i=0;i<t.length;i++){const s=t[i],r=s.object;if(r.material&&r.material.depthTest===!1){this._noDepthTestingResults.push(s);continue}this._sortingBuffer.push(s)}for(const i of this._sortingBuffer)this._noDepthTestingResults.push(i);return this._noDepthTestingResults}handleEvents(t,i){if(!this.testIsVisible(t))return i.isClicked&&Cg&&console.log("not allowed",t),!1;const s=t;i.object=t,this.lastPointerEvent=i;const r=t.parent;let o=!1;const a=i.isClicked??!1;let c=null;if(r&&r.isUI){const l=(i.isPressed||i.isClicked)??!1;if(r[Ma]){const h=r[Ma].gameObject;if(h){if(!Nf.isInteractable(h,this.out))return!1;c=this.out.canvasGroup??null,this.handleMeshUIIntersection(t,l),t=h,o=!0}}if(!o&&this.handleMeshUiObjectWithoutShadowDom(r,l))return!0}if(a&&Cg&&console.log(this.context.time.frame,t),this.objectsHoveredThisFrame.push(t),c===null||c.interactable){const l=this.objectsHoveredLastFrame.indexOf(t)>=0;this.handleEventsArray.length=0;const h=se.getComponentsInParent(t,Me,this.handleEventsArray);for(let d=0;d<h.length;d++){if(i.used)return!0;if(h[d].destroyed)continue;const f=h[d];if(f.interactable!==!1){if(f.onPointerEnter&&(l||f.onPointerEnter(i)),f.onPointerMove&&i.positionDelta.x!==0&&i.positionDelta.y!==0&&f.onPointerMove(i),i.isDown&&f.onPointerDown&&!this.raisedPointerDownEvents.includes(f)&&(f.onPointerDown(i),this.raisedPointerDownEvents.push(f),this.raisedPointerDownObjects.push(s)),i.isUp&&f.onPointerUp){const p=this.raisedPointerDownEvents.indexOf(f);p!==-1&&this.raisedPointerDownEvents.splice(p,1),f.onPointerUp(i)}i.isClicked&&f.onPointerClick&&f.onPointerClick(i)}}}return!0}handleMeshUiObjectWithoutShadowDom(t,i){return!t||!t.isUI?!0:this.handleMeshUIIntersection(t,i)}handleMeshUIIntersection(t,i){const s=xc.updateState(t,i);return s&&this.currentActiveMeshUIComponents.push(s),s!==null}resetMeshUIStates(){if(this.context.input.getPointerPressedCount()>0&&xc.resetLastSelected(),!(!this.currentActiveMeshUIComponents||this.currentActiveMeshUIComponents.length<=0)){for(let t=0;t<this.currentActiveMeshUIComponents.length;t++){const i=this.currentActiveMeshUIComponents[t];xc.resetState(i)}this.currentActiveMeshUIComponents.length=0}}testIsVisible(t){return t?se.isActiveSelf(t)?this.testIsVisible(t.parent):!1:!0}};let qs=ba;u(qs,"_eventSystemMap",new Map),u(qs,"didSearchEventSystem",!1);class xc{static markDirty(){this.needsUpdate=!0}static update(e,t){const i=t.time.frameCount;for(const s of this.lastUpdateFrame)if(s.context===t){if(i===s.frame)return;s.frame=i;let r=this.needsUpdate||i<1;s.nextUpdate===t.time.frameCount&&(r=!0),r&&(Cg&&console.log("Update threemeshui"),this.needsUpdate=!1,e.update());return}this.lastUpdateFrame=[{context:t,frame:i,nextUpdate:i}],e.update()}static updateState(e,t){let i=null;if(e&&(i=this.findBlockInParent(e),i&&i!==this.lastSelected)){if(i.interactable===!1)return null;this.needsUpdate=!0}return i}static resetLastSelected(){const e=this.lastSelected;e&&(this.lastSelected=null,this.resetState(e))}static resetState(e){e&&(this.needsUpdate=!0)}static findBlockInParent(e){return e?e.isBlock?e:this.findBlockInParent(e.parent):null}}u(xc,"lastSelected",null),u(xc,"lastUpdateFrame",[]),u(xc,"needsUpdate",!1);const w0=Symbol("cameraController");function Mte(n){return n[w0]}function $D(n,e,t){t?n[w0]=e:n[w0]===e&&(n[w0]=null)}function ox(n){const e=n[Ma];return e||(n.parent?ox(n.parent):null)}function bb(n,e){if(!n)return;const t=n.material;if((t==null?void 0:t.isMaterial)===!0){const i=n.parent;i&&i.isText,t.side=e.doubleSided??!0?Si:Rs,t.shadowSide=e.doubleSided?Si:Rs,n.castShadow=e.castShadows?e.castShadows:!1,n.receiveShadow=e.receiveShadows?e.receiveShadows:!1}for(const i of n.children)bb(i,e)}function Qd(n,e,t){n[e]===void 0&&console.warn("Field",e,"is undefined on",n);const i=Proxy.revocable(n[e],{set(o,a,c,l){const h=o[a],d=Reflect.set(o,a,c,l);return t(c,h),d}}),s=i.revoke,r=n[e];return i.revoke=()=>{n[e]=r,s()},n[e]=i.proxy,i}const eO=Symbol("Scheduled action");function Tte(n,e,t=xr.OnBeforeRender){let i=n[eO];i||(i=n[eO]={});const s=e.name;i[t]||(i[t]={});const r=i[t];if(r[s])return;function*a(){e==null||e.call(n),r[s]=null}const c=n.startCoroutine(a(),t);r[s]=c}var Ite=Object.defineProperty,Rte=Object.getOwnPropertyDescriptor,Pte=(n,e,t,i)=>{for(var s=i>1?void 0:i?Rte(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Ite(e,t,s),s};const Ey=re("freecam"),MS=re("debugcamerafit"),Bte={LEFT:"",UP:"",RIGHT:"",BOTTOM:""};let TS;class cl extends Me{constructor(){super(...arguments);u(this,"autoRotate",!1);u(this,"autoRotateSpeed",1);u(this,"enableKeys",!0);u(this,"enableDamping",!0);u(this,"dampingFactor",.1);u(this,"enableZoom",!0);u(this,"minZoom",0);u(this,"maxZoom",1/0);u(this,"enablePan",!0);u(this,"lookAtConstraint",null);u(this,"lookAtConstraint01",1);u(this,"middleClickToFocus",!0);u(this,"doubleClickToFocus",!0);u(this,"useSlerp",!0);u(this,"debugLog",!1);u(this,"targetLerpSpeed",5);u(this,"autoTarget",!0);u(this,"_lookTargetPosition");u(this,"_controls",null);u(this,"_cameraObject",null);u(this,"_lerpToTargetPosition",!1);u(this,"_lerpCameraToTarget",!1);u(this,"_cameraTargetPosition",null);u(this,"_inputs",0);u(this,"_enableTime",0);u(this,"_startedListeningToKeyEvents",!1);u(this,"_eventSystem");u(this,"_afterHandleInputFn");u(this,"_camera",null);u(this,"_syncedTransform");u(this,"targetElement",null);u(this,"onControlsChangeStarted",()=>{this._syncedTransform&&this._syncedTransform.requestOwnership()});u(this,"_shouldDisable",!1);u(this,"_haveAttachedKeyboardEvents",!1)}get isCameraController(){return!0}get controls(){return this._controls}get controllerObject(){return this._cameraObject}onStartInteraction(t){var i;(i=this.controls)==null||i.addEventListener("start",t)}awake(){this._lookTargetPosition=new S,this._startedListeningToKeyEvents=!1}start(){if(this.autoTarget){if(this._controls){const t=se.getComponent(this.gameObject,Oi);if(t&&!this.setFromTargetPosition()){this.debugLog&&console.log("NO TARGET");const s=wt(t.cam).length(),r=new S(0,0,-s).applyMatrix4(t.cam.matrixWorld);this.setTarget(r,!0)}}this.startCoroutine(this.startRaycastDelayed())}this._eventSystem=qs.get(this.context)??void 0,this._eventSystem&&(this._afterHandleInputFn=this.afterHandleInput.bind(this),this._eventSystem.addEventListener(YE.AfterHandleInput,this._afterHandleInputFn))}onDestroy(){var t,i;(t=this._controls)==null||t.dispose(),(i=this._eventSystem)==null||i.removeEventListener(YE.AfterHandleInput,this._afterHandleInputFn)}onEnable(){this._enableTime=this.context.time.time;const t=se.getComponent(this.gameObject,Oi);this._camera=t;const i=t==null?void 0:t.cam;if(i&&$D(i,this,!0),!this._controls){if(!i){console.warn("OrbitControls: Requires a Camera component on the same object as this component.");return}i&&(this._cameraObject=i);const s=this.targetElement??this.context.domElement,r=i==null?void 0:i.quaternion.clone();this._controls=new MK(i,s),i==null||i.quaternion.copy(r),TS===void 0&&(TS={...this._controls.keys})}this._controls&&(Ey&&(this.enablePan=!0,this.enableZoom=!0,this.middleClickToFocus=!0,nl()&&(this.doubleClickToFocus=!0)),this._controls.addEventListener("start",this.onControlsChangeStarted),(i==null?void 0:i.type)==="PerspectiveCamera"?Ey||(this._controls.minDistance=this.minZoom,this._controls.maxDistance=this.maxZoom):Ey||(this._controls.minZoom=this.minZoom,this._controls.maxZoom=this.maxZoom),this._startedListeningToKeyEvents||(this._startedListeningToKeyEvents=!0,this._controls.listenToKeyEvents(window.document.body))),this._syncedTransform=se.getComponent(this.gameObject,nh)??void 0}onDisable(){var t;(t=this._camera)!=null&&t.cam&&$D(this._camera.cam,this,!1),this._controls&&(this._controls.enabled=!1,this._controls.autoRotate=!1,this._controls.removeEventListener("start",this.onControlsChangeStarted))}afterHandleInput(t){t.detail.args.pointerId===0&&(t.detail.args.isDown?this._controls&&this._eventSystem&&(this._shouldDisable=this._eventSystem.hasActiveUI):(!t.detail.args.isPressed||t.detail.args.isUp)&&(this._shouldDisable=!1))}*startRaycastDelayed(){if(yield,this.autoTarget&&!this.setFromTargetPosition()){const t=new sa;t.screenPoint=new te(0,0),t.lineThreshold=.1;const i=this.context.physics.raycast(t);i.length>0&&this.setTarget(i[0].point,!0)}}onBeforeRender(){var i,s,r;if(!this._controls||this._cameraObject!==this.context.mainCamera)return;(this.context.input.getPointerDown(0)||this.context.input.getPointerDown(1)||this.context.input.getPointerDown(2))&&(this._inputs+=1),this._inputs>0&&(this.autoRotate=!1,this._controls.autoRotate=!1,this._lerpCameraToTarget=!1,this._lerpToTargetPosition=!1),this._inputs=0;let t=this.middleClickToFocus&&this.context.input.getPointerClicked(1);if(t||(t=this.doubleClickToFocus&&this.context.input.getPointerDoubleClicked(0)&&this.context.time.time-this._enableTime>.3),t?this.setTargetFromRaycast():(this.context.input.getPointerDown(0)||this.context.input.mouseWheelChanged)&&(this._lerpToTargetPosition=!1,this._lerpCameraToTarget=!1),this._lerpToTargetPosition||this._lerpCameraToTarget){const o=this.context.time.deltaTime*this.targetLerpSpeed;if(this._lerpCameraToTarget&&this._cameraTargetPosition&&this._cameraObject){if(this.useSlerp){const a=(i=this._cameraObject)==null?void 0:i.position;O2(a,this._cameraTargetPosition,o)}else(s=this._cameraObject)==null||s.position.lerp(this._cameraTargetPosition,o);this._cameraObject.position.distanceTo(this._cameraTargetPosition)<1e-4&&(this._lerpCameraToTarget=!1)}this._lerpToTargetPosition&&(this.lerpTarget(this._lookTargetPosition,o),this._lookTargetPosition.distanceTo(this._controls.target)<1e-5&&(this._lerpToTargetPosition=!1))}!Ey&&((r=this.lookAtConstraint)!=null&&r.locked)&&this.setFromTargetPosition(0,this.lookAtConstraint01),this._controls&&(this.debugLog&&(this._controls.domElement=this.context.renderer.domElement),this._controls.enabled=!this._shouldDisable&&this._camera===this.context.mainCameraComponent&&!this.context.isInXR,this._controls.enableDamping=this.enableDamping,this._controls.keys=this.enableKeys?TS:Bte,this._controls.autoRotate=this.autoRotate,this._controls.autoRotateSpeed=this.autoRotateSpeed,this._controls.enableZoom=this.enableZoom,this._controls.dampingFactor=this.dampingFactor,this._controls.enablePan=this.enablePan,this.context.isInXR||this._controls.update())}setCameraTarget(t,i=!1){var s;t?(this._lerpCameraToTarget=!0,this._cameraTargetPosition=t.clone(),i&&this._cameraTargetPosition&&((s=this.controllerObject)==null||s.position.copy(this._cameraTargetPosition))):this._lerpCameraToTarget=!1}setFromTargetPosition(t=0,i=1){var r;if(!this._controls)return!1;const s=(r=this.lookAtConstraint)==null?void 0:r.sources;if(s&&s.length>0){const o=s[t];if(o)return o.getWorldPosition(this._lookTargetPosition),this.lerpTarget(this._lookTargetPosition,i),!0}return!1}setTarget(t=null,i=!1){this._controls&&(t!==null&&this._lookTargetPosition.copy(t),i?this._controls.target.copy(this._lookTargetPosition):this._lerpToTargetPosition=!0)}lerpTarget(t,i){this._controls&&this._controls.target.lerp(t,i)}distanceToTarget(t){return this._controls?this._controls.target.distanceTo(t):-1}setTargetFromRaycast(){var i,s;if(!this.controls)return;const t=this.context.physics.raycast();for(const r of t)if(r.distance>0&&se.isActiveInHierarchy(r.object)){const o=ox(r.object);if(o){const a=o.canvas;if(a!=null&&a.screenspace)break}if(this._lookTargetPosition.copy(r.point),this._lerpToTargetPosition=!0,this._cameraTargetPosition=null,this.context.mainCamera){this._lerpCameraToTarget=!0;const a=wt(this.context.mainCamera);this._cameraTargetPosition=a.clone().sub(this.controls.target).add(this._lookTargetPosition),(s=(i=this._cameraObject)==null?void 0:i.parent)==null||s.worldToLocal(this._cameraTargetPosition)}break}}fitCamera(t,i=1.1){const s=this._cameraObject,r=this._controls;if(t!=null&&t.length||(t=this.context.scene.children),t.length<=0||!s||!r)return;const o=new S,a=new S,c=new kn;c.makeEmpty();for(const v of t)v instanceof JC||v instanceof S1||(v.updateMatrixWorld(),c.expandByObject(v,!0));if(s.updateMatrixWorld(),s.updateProjectionMatrix(),c.getCenter(a),c.applyMatrix4(s.matrixWorldInverse),c.getSize(o),c.setFromCenterAndSize(a,o),o.length()<=1e-10){MS&&console.warn("Camera fit size is zero",c,[...t]);return}const l=s.fov,h=2*Math.atan(Math.tan(l*Math.PI/360/2)*s.aspect)/Math.PI*360,d=o.y/(2*Math.atan(Math.PI*l/360)),f=o.x/(2*Math.atan(Math.PI*h/360)),p=i*Math.max(d,f)+o.z/2;MS&&console.log("Fit camera to objects",d,f,"distance",p);const g=wt(s),A=r.target.clone().sub(g).normalize().multiplyScalar(p);if(r.maxDistance=p*10,r.minDistance=p*.01,this.setTarget(a,!0),this.autoTarget=!1,s.near=p/100,s.far=p*100,s.updateMatrixWorld(),s.updateProjectionMatrix(),fn(s,r.target.clone().sub(A)),MS){const v=new JC(c);this.context.scene.add(v),U2(v,b_(s)),this._haveAttachedKeyboardEvents||(this._haveAttachedKeyboardEvents=!0,document.body.addEventListener("keydown",m=>{m.code==="KeyF"&&this.fitCamera(t)}))}r.update()}}Pte([x(IA)],cl.prototype,"lookAtConstraint",2);var Dte=Object.defineProperty,Ote=Object.getOwnPropertyDescriptor,qr=(n,e,t,i)=>{for(var s=i>1?void 0:i?Ote(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Dte(e,t,s),s},yz=(n=>(n[n.Skybox=1]="Skybox",n[n.SolidColor=2]="SolidColor",n[n.Uninitialized=4]="Uninitialized",n))(yz||{});const Eg=re("debugcam"),tO=re("debugscreenpointtoray");var Xy;const Mg=(Xy=class extends Me{constructor(){super(...arguments);u(this,"_nearClipPlane",.1);u(this,"_farClipPlane",1e3);u(this,"orthographic",!1);u(this,"orthographicSize",5);u(this,"ARBackgroundAlpha",0);u(this,"_cullingMask",4294967295);u(this,"_backgroundBlurriness");u(this,"_backgroundIntensity");u(this,"_environmentIntensity");u(this,"_targetTexture",null);u(this,"_backgroundColor");u(this,"_fov");u(this,"_cam",null);u(this,"_clearFlags",2);u(this,"_skybox")}get isCamera(){return!0}get aspect(){return this._cam instanceof qt?this._cam.aspect:this.context.domWidth/this.context.domHeight}get fieldOfView(){return this._cam instanceof qt?this._cam.fov:this._fov}set fieldOfView(e){const t=this.fieldOfView!=e;if(this._fov=e,t&&this._cam&&this._cam instanceof qt){if(this._fov===void 0){console.warn("Can not set undefined fov on PerspectiveCamera");return}this._cam.fov=this._fov,this._cam.updateProjectionMatrix()}}get nearClipPlane(){return this._nearClipPlane}set nearClipPlane(e){const t=this._nearClipPlane!=e;this._nearClipPlane=e,this._cam&&t&&(this._cam.near=e,this._cam.updateProjectionMatrix())}get farClipPlane(){return this._farClipPlane}set farClipPlane(e){const t=this._farClipPlane!=e;this._farClipPlane=e,this._cam&&t&&(this._cam.far=e,this._cam.updateProjectionMatrix())}get clearFlags(){return this._clearFlags}set clearFlags(e){e!==this._clearFlags&&(this._clearFlags=e,this.applyClearFlagsIfIsActiveCamera())}set cullingMask(e){this._cullingMask=e,this._cam&&(this._cam.layers.mask=e)}get cullingMask(){return this._cam?this._cam.layers.mask:this._cullingMask}set backgroundBlurriness(e){e!==this._backgroundBlurriness&&(e===void 0?this._backgroundBlurriness=void 0:this._backgroundBlurriness=Math.min(Math.max(e,0),1),this.applyClearFlagsIfIsActiveCamera())}get backgroundBlurriness(){return this._backgroundBlurriness}set backgroundIntensity(e){e!==this._backgroundIntensity&&(e===void 0?this._backgroundIntensity=void 0:this._backgroundIntensity=Math.min(Math.max(e,0),10),this.applyClearFlagsIfIsActiveCamera())}get backgroundIntensity(){return this._backgroundIntensity}set environmentIntensity(e){this._environmentIntensity=e}get environmentIntensity(){return this._environmentIntensity}get backgroundColor(){return this._backgroundColor??null}set backgroundColor(e){if(e){if(this._backgroundColor)this._backgroundColor.copy(e);else{if(!e.clone)return;this._backgroundColor=e.clone()}e.alpha===void 0&&(this._backgroundColor.alpha=1),this.applyClearFlagsIfIsActiveCamera()}}set targetTexture(e){this._targetTexture=e}get targetTexture(){return this._targetTexture}get cam(){return this.activeAndEnabled&&this.buildCamera(),this._cam}screenPointToRay(e,t,i){const s=this.cam,r=Mg._origin;r.set(e,t,-1),this.context.input.convertScreenspaceToRaycastSpace(r),tO&&console.log("screenPointToRay",e.toFixed(2),t.toFixed(2),"now:",r.x.toFixed(2),r.y.toFixed(2),"isInXR:"+this.context.isInXR),r.z=-1,r.unproject(s);const o=Mg._direction.set(r.x,r.y,r.z),a=wt(s);return o.sub(a),o.normalize(),i?(i.set(a,o),i):new ja(a.clone(),o.clone())}awake(){tO&&window.addEventListener("pointerdown",e=>{const t=e.clientX,i=e.clientY;console.log("touch",t.toFixed(2),i.toFixed(2));const s=this.screenPointToRay(t,i),r="#"+Math.floor(Math.random()*16777215).toString(16);Lc.DrawRay(s.origin,s.direction,r,10)})}onEnable(){Eg&&console.log(this),this.buildCamera(),(this.tag=="MainCamera"||!this.context.mainCameraComponent)&&(this.context.setCurrentCamera(this),Lte(this)),this.applyClearFlagsIfIsActiveCamera()}onDisable(){this.context.removeCamera(this)}onBeforeRender(){if(this._cam&&this._targetTexture){this.context.isManagedExternally&&(this._warnedAboutExternalRenderer||(this._warnedAboutExternalRenderer=!0,console.warn("Rendering with external renderer is not supported yet. This may not work or throw errors. Please remove the the target texture from your camera: "+this.name,this.targetTexture))),this.context.composer;const e=this.context.renderer;if(e){const t=this.context.mainCameraComponent;this.applyClearFlags(),this._targetTexture.render(this.context.scene,this._cam,e),t==null||t.applyClearFlags()}}}buildCamera(){if(this._cam)return;const e=this.gameObject.isCamera;let t=null;if(e?(t=this.gameObject,t==null||t.layers.enableAll(),t instanceof qt&&(this._fov=t.fov)):t=this.gameObject.children[0],t&&t.isCamera)t instanceof qt&&(this._fov&&(t.fov=this._fov),t.near=this._nearClipPlane,t.far=this._farClipPlane,t.updateProjectionMatrix());else if(!this.orthographic)t=new qt(this.fieldOfView,window.innerWidth/window.innerHeight,this._nearClipPlane,this._farClipPlane),this.fieldOfView&&(t.fov=this.fieldOfView),this.gameObject.add(t);else{const i=this.orthographicSize*100;t=new Ru(window.innerWidth/-i,window.innerWidth/i,window.innerHeight/i,window.innerHeight/-i,this._nearClipPlane,this._farClipPlane),this.gameObject.add(t)}this._cam=t,this._cam.layers.mask=this._cullingMask,this.tag=="MainCamera"&&this.context.setCurrentCamera(this)}applyClearFlagsIfIsActiveCamera(){this.context.mainCameraComponent===this&&this.applyClearFlags()}applyClearFlags(){if(!this._cam){Eg&&console.log("Camera does not exist (apply clear flags)");return}switch(this.fieldOfView=this._fov,Eg&&_n("apply Camera clear flags: "+this._clearFlags),this._clearFlags){case 1:if(Mg.backgroundShouldBeTransparent(this.context)&&(!this.ARBackgroundAlpha||this.ARBackgroundAlpha<.001)){this.context.scene.background=null,this.context.renderer.setClearColor(0,0);return}this.enableSkybox(),this._backgroundBlurriness!==void 0&&(this.context.scene.backgroundBlurriness=this._backgroundBlurriness),this._backgroundIntensity!==void 0&&(this.context.scene.backgroundIntensity=this._backgroundIntensity);break;case 2:if(this._backgroundColor){let e=this._backgroundColor.alpha;Mg.backgroundShouldBeTransparent(this.context)&&(e=this.ARBackgroundAlpha??0),this.context.scene.background=null,this.context.renderer.setClearColor(this._backgroundColor,e)}break;case 4:this.context.scene.background=null,this.context.renderer.setClearColor(0,0);break}}enableSkybox(){this._skybox||(this._skybox=new kte(this)),this._skybox.enable()}static backgroundShouldBeTransparent(e){var r,o,a,c;const t=(r=e.renderer.xr)==null?void 0:r.getSession();if(!t)return!1;const i=t.environmentBlendMode;Eg&&_n("Environment blend mode: "+i+" on "+navigator.userAgent);const s=i==="additive"||i==="alpha-blend";if(e.xrSessionMode===Dm.ImmersiveAR&&i==="opaque"){if((o=navigator.userAgent)!=null&&o.includes("OculusBrowser"))return!0;if((a=navigator.userAgent)!=null&&a.includes("Mozilla")&&((c=navigator.userAgent)!=null&&c.includes("Mobile WebXRViewer/v2")))return!0}return s}},u(Xy,"_origin",new S),u(Xy,"_direction",new S),Xy);let Oi=Mg;qr([x()],Oi.prototype,"fieldOfView",1);qr([x()],Oi.prototype,"nearClipPlane",1);qr([x()],Oi.prototype,"farClipPlane",1);qr([x()],Oi.prototype,"clearFlags",1);qr([x()],Oi.prototype,"orthographic",2);qr([x()],Oi.prototype,"orthographicSize",2);qr([x()],Oi.prototype,"ARBackgroundAlpha",2);qr([x()],Oi.prototype,"cullingMask",1);qr([x()],Oi.prototype,"backgroundBlurriness",1);qr([x()],Oi.prototype,"backgroundIntensity",1);qr([x()],Oi.prototype,"environmentIntensity",1);qr([x(_i)],Oi.prototype,"backgroundColor",1);qr([x(ql)],Oi.prototype,"targetTexture",1);class kte{constructor(e){u(this,"_camera");u(this,"_skybox");this._camera=e}get context(){var e;return(e=this._camera)==null?void 0:e.context}enable(){this._skybox=this.context.lightmaps.tryGetSkybox(this._camera.sourceId),this._skybox?this.context.scene.background!==this._skybox&&(Eg&&console.log("Set skybox",this._camera,this._skybox),this._skybox.colorSpace=Ze,this._skybox.mapping=So,this.context.scene.background=this._skybox):console.warn("Failed to load/find skybox texture",this._camera.sourceId,this.context.lightmaps)}}function Lte(n){re("freecam")&&n.context.mainCameraComponent===n&&se.getOrAddComponent(n.gameObject,cl)}class zf extends Me{constructor(){super(...arguments);u(this,"_listener",null)}get listener(){return this._listener==null&&(this._listener=new _1),this._listener}awake(){Cn.registerWaitForAllowAudio(()=>{if(this.destroyed)return;const t=this.listener;if(t==null||t.parent)return;const i=this.context.mainCameraComponent||se.getComponentInParent(this.gameObject,Oi);i!=null&&i.cam?i.cam.add(t):this.gameObject.add(t)})}}var Fte=Object.defineProperty,Ute=Object.getOwnPropertyDescriptor,ax=(n,e,t,i)=>{for(var s=i>1?void 0:i?Ute(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Fte(e,t,s),s};const Nte=re("debugsignals");class LA{constructor(){u(this,"guid")}}ax([x()],LA.prototype,"guid",2);class hp{constructor(){u(this,"signal");u(this,"reaction")}}ax([x(LA)],hp.prototype,"signal",2);ax([x(cs)],hp.prototype,"reaction",2);var oC;const Ac=(oC=class extends Me{constructor(){super(...arguments);u(this,"events")}static invoke(e){if(Ac.receivers[e]){const t=Ac.receivers[e];if(!t)return;for(const i of t)i.invoke(e)}}awake(){Nte&&console.log("SignalReceiver awake",this)}onEnable(){if(this.events)for(const e of this.events)Ac.receivers[e.signal.guid]||(Ac.receivers[e.signal.guid]=[]),Ac.receivers[e.signal.guid].push(this)}onDisable(){if(this.events){for(const e of this.events)if(Ac.receivers[e.signal.guid]){const t=Ac.receivers[e.signal.guid].indexOf(this);t>=0&&Ac.receivers[e.signal.guid].splice(t,1)}}}invoke(e){if(!this.events||!Array.isArray(this.events))return;const t=typeof e=="object"?e.guid:e;for(const i of this.events)if(i.signal.guid===t)try{if(i.reaction){if(!i.reaction.invoke){console.warn("Missing invoke - possibly a serialization error",i,this);continue}}else{console.warn("Missing reaction for signal",i,this);continue}i.reaction.invoke()}catch(s){console.error(s)}}},u(oC,"receivers",{}),oC);let up=Ac;ax([x(hp)],up.prototype,"events",2);var Rr=(n=>(n.Activation="ActivationTrack",n.Animation="AnimationTrack",n.Audio="AudioTrack",n.Control="ControlTrack",n.Marker="MarkerTrack",n.Signal="SignalTrack",n))(Rr||{}),va=(n=>(n[n.None=0]="None",n[n.Hold=1]="Hold",n[n.Loop=2]="Loop",n[n.PingPong=3]="PingPong",n[n.Continue=4]="Continue",n))(va||{}),YT=(n=>(n.Signal="SignalEmitter",n))(YT||{});const Bd=re("debugtimeline"),Rb=class extends Me{constructor(){super(...arguments);u(this,"playableAsset");u(this,"playOnAwake");u(this,"extrapolationMode",1);u(this,"waitForAudio",!0);u(this,"_visibilityChangeEvt");u(this,"_clonedPlayableAsset",!1);u(this,"_speed",1);u(this,"_guidsMap");u(this,"_isPlaying",!1);u(this,"_internalUpdateRoutine");u(this,"_isPaused",!1);u(this,"_isStopping",!1);u(this,"_time",0);u(this,"_duration",0);u(this,"_weight",1);u(this,"_animationTracks",[]);u(this,"_audioTracks",[]);u(this,"_signalTracks",[]);u(this,"_controlTracks",[]);u(this,"_customTracks",[]);u(this,"_allTracks",[this._animationTracks,this._audioTracks,this._signalTracks,this._controlTracks,this._customTracks]);u(this,"animationCallbackReceivers",[])}static registerCreateTrack(t,i){this.createTrackFunctions[t]=i}get isPlaying(){return this._isPlaying}get isPaused(){return this._isPaused}get time(){return this._time}set time(t){typeof t=="number"&&!Number.isNaN(t)?this._time=t:(Bd||$s())&&console.error("INVALID TIMELINE.TIME VALUE",t,this.name)}get duration(){return this._duration}set duration(t){this._duration=t}get weight(){return this._weight}set weight(t){this._weight=t}get speed(){return this._speed}set speed(t){this._speed=t}awake(){var t,i,s;Bd&&console.log(this,(t=this.playableAsset)==null?void 0:t.tracks),this.rebuildGraph(),this.isValid()||console.warn("PlayableDirector is not valid",this.playableAsset,(i=this.playableAsset)==null?void 0:i.tracks,Array.isArray((s=this.playableAsset)==null?void 0:s.tracks),this)}onEnable(){var t,i,s;for(const r of this._audioTracks)(t=r.onEnable)==null||t.call(r);for(const r of this._customTracks)(i=r.onEnable)==null||i.call(r);for(const r of this._animationTracks)(s=r.onEnable)==null||s.call(r);this.playOnAwake&&this.play(),this._visibilityChangeEvt||(this._visibilityChangeEvt=()=>{switch(document.visibilityState){case"hidden":this.setAudioTracksAllowPlaying(!1);break;case"visible":this.setAudioTracksAllowPlaying(!0);break}}),window.addEventListener("visibilitychange",this._visibilityChangeEvt)}onDisable(){var t,i,s;this.stop();for(const r of this._audioTracks)(t=r.onDisable)==null||t.call(r);for(const r of this._customTracks)(i=r.onDisable)==null||i.call(r);for(const r of this._animationTracks)(s=r.onDisable)==null||s.call(r);this._visibilityChangeEvt&&window.removeEventListener("visibilitychange",this._visibilityChangeEvt)}onDestroy(){var t;for(const i of this._allTracks)for(const s of i)(t=s.onDestroy)==null||t.call(s)}rebuildGraph(){this.isValid()&&(this.resolveBindings(),this.updateTimelineDuration(),this.setupAndCreateTrackHandlers())}async play(){if(!this.isValid())return;const t=this._isPaused==!0;if(this._isPaused=!1,t&&this.invokePauseChangedMethodsOnTracks(),!this._isPlaying){if(this._isPlaying=!0,this.waitForAudio){const i=[];for(const s of this._audioTracks){const r=s.loadAudio(this._time,1,0);r&&i.push(r)}if(i.length>0&&(await Promise.all(i),!this._isPlaying))return;for(;this._audioTracks.length>0&&this._isPlaying&&!Cn.userInteractionRegistered&&this.waitForAudio;)await sA(200)}this.invokeStateChangedMethodsOnTracks(),this._internalUpdateRoutine=this.startCoroutine(this.internalUpdate(),xr.OnBeforeRender)}}pause(){this.isValid()&&(this._isPlaying=!1,!this._isPaused&&(this._isPaused=!0,this.evaluate(),this.invokePauseChangedMethodsOnTracks(),this.invokeStateChangedMethodsOnTracks()))}stop(){this._isStopping=!0;for(const s of this._audioTracks)s.stop();const t=this._isPaused==!0,i=this._isPlaying;this._isPlaying&&(this._time=0,this._isPlaying=!1,this._isPaused=!1,this.evaluate(),t&&this.invokePauseChangedMethodsOnTracks()),this._isPlaying=!1,this._isPaused=!1,t&&!i&&this.invokePauseChangedMethodsOnTracks(),i&&this.invokeStateChangedMethodsOnTracks(),this._internalUpdateRoutine&&this.stopCoroutine(this._internalUpdateRoutine),this._internalUpdateRoutine=null,this._isStopping=!1}evaluate(){if(!this.isValid())return;let t=this._time;switch(this.extrapolationMode){case 0:this._speed>0?t=Math.min(t,this._duration):this._speed<0&&(t=Math.max(t,0)),this._time=t;break;case 1:t%=this._duration,this._time=t;break;case 2:if(t>this._duration){this.stop();return}break}this.internalEvaluate(t)}isValid(){return this.playableAsset&&this.playableAsset.tracks&&Array.isArray(this.playableAsset.tracks)}*forEachTrack(){for(const t of this._allTracks)for(const i of t)yield i}get audioTracks(){return this._audioTracks}resolveGuids(t){this._guidsMap=t}invokePauseChangedMethodsOnTracks(){var t;for(const i of this.forEachTrack())(t=i.onPauseChanged)==null||t.call(i)}invokeStateChangedMethodsOnTracks(){var t;for(const i of this.forEachTrack())(t=i.onStateChanged)==null||t.call(i,this._isPlaying)}*internalUpdate(){for(;this._isPlaying&&this.activeAndEnabled;)!this._isPaused&&this._isPlaying&&(this._time+=this.context.time.deltaTime*this.speed,this.evaluate()),yield}internalEvaluate(t){for(const i of this.playableAsset.tracks)if(!i.muted)switch(i.type){case Rr.Activation:if(!this._isPlaying)continue;for(let s=0;s<i.outputs.length;s++){const r=i.outputs[s];if(typeof r=="object"){let o=!1;for(const c of i.clips)c.start<=t&&t<=c.end&&(o=!0);const a=r;a.visible!==void 0&&a.visible!==o&&(a.visible=o,Bd&&console.warn(this.name,"set ActivationTrack-"+s,a.name,o,t))}}break}if(!this._isStopping)for(const i of this._animationTracks)i.evaluate(t);for(const i of this._audioTracks)i.evaluate(t);for(const i of this._signalTracks)i.evaluate(t);for(const i of this._controlTracks)i.evaluate(t);for(const i of this._customTracks)i.evaluate(t)}resolveBindings(){if(this._clonedPlayableAsset||(this._clonedPlayableAsset=!0,this.playableAsset=Bb(this.playableAsset)),!this.playableAsset||!this.playableAsset.tracks)return;const t=this.findRoot(this.gameObject);for(const i of this.playableAsset.tracks){for(let s=i.outputs.length-1;s>=0;s--){let r=i.outputs[s];if(typeof r=="string"){this._guidsMap&&this._guidsMap[r]&&(r=this._guidsMap[r]);const o=se.findByGuid(r,t);o===null||typeof o!="object"?(i.outputs.splice(s,1),console.warn("Failed to resolve binding",r,i.name,i.type)):(Bd&&console.log("Resolved binding",r,"to",o),i.outputs[s]=o)}else if(r===null){if(i.outputs.splice(s,1),Rb.createTrackFunctions[i.type])continue;i.type!==Rr.Audio&&i.type!==Rr.Control&&i.type!==Rr.Marker&&i.type!==Rr.Signal&&console.warn("Missing binding",r,i.name,i.type,this.name,this.playableAsset.name)}}if(i.type===Rr.Control)for(let s=0;s<i.clips.length;s++){const r=i.clips[s];let o=r.asset.sourceObject;if(typeof o=="string"){this._guidsMap&&this._guidsMap[o]&&(o=this._guidsMap[o]);const a=se.findByGuid(o,t);a===null||typeof a!="object"?console.warn("Failed to resolve sourceObject binding",o,i.name,r):(Bd&&console.log("Resolved binding",o,"to",a),r.asset.sourceObject=a)}}}}findRoot(t){return t.parent?this.findRoot(t.parent):t}updateTimelineDuration(){if(this._duration=0,!(!this.playableAsset||!this.playableAsset.tracks)){for(const t of this.playableAsset.tracks)if(t.muted!==!0){for(const i of t.clips)i.end>this._duration&&(this._duration=i.end);for(const i of t.markers)i.time>this._duration&&(this._duration=i.time+.001)}}}setupAndCreateTrackHandlers(){var i,s;if(this._animationTracks.length=0,this._audioTracks.length=0,this._signalTracks.length=0,!this.playableAsset)return;const t=se.findObjectOfType(zf,this.context);for(const r of this.playableAsset.tracks){const o=r.type,a=Rb.createTrackFunctions[o];if(a!=null){const c=a(this,r);if(typeof c.evaluate=="function"){c.director=this,c.track=r,this._customTracks.push(c);continue}}if(r.type===Rr.Animation){if(r.clips.length<=0){Bd&&console.warn("Animation track has no clips",r);continue}for(let c=r.outputs.length-1;c>=0;c--){let l=r.outputs[c];if(l instanceof Te){const d=se.getOrAddComponent(l,Bs);d&&(l=d)}const h=(i=l==null?void 0:l.gameObject)==null?void 0:i.animations;if(h){const d=new cx;d.trackOffset=r.trackOffset,d.director=this,d.track=r;for(let f=0;f<r.clips.length;f++){const p=r.clips[f],g=p.asset;if(!g){console.error("MISSING anim model?","clip#"+f,p,r,this.playableAsset,this.name);continue}const A=g.clip;let v=A;if((typeof v=="string"||typeof v=="number")&&(v=h.find(b=>b.name===A)),!v){console.warn("Could not find animationClip for model",p,r.name,this.name,(s=this.playableAsset)==null?void 0:s.name);continue}l instanceof Bs&&l.runtimeAnimatorController&&(l.__internalDidAwakeAndStart||l.initializeRuntimeAnimatorController(),l.runtimeAnimatorController.mixer||l.runtimeAnimatorController.bind(l),d.mixer=l.runtimeAnimatorController.mixer),d.mixer||(d.mixer=new v_(l.gameObject)),d.clips.push(v),d.mixer.uncacheAction(v),d.createHooks(p.asset,v);const m=d.mixer.clipAction(v);d.actions.push(m),d.models.push(p)}this._animationTracks.push(d)}}}else if(r.type===Rr.Audio){if(r.clips.length<=0)continue;const c=new yu;if(c.director=this,c.track=r,this._audioTracks.push(c),!t)continue;c.listener=t.listener;for(let l=0;l<r.clips.length;l++){const h=r.clips[l];c.addModel(h)}}else if(r.type===Rr.Marker){const c=new jm;c.director=this,c.track=r;for(const l of r.markers)switch(l.type){case YT.Signal:c.models.push(l),c.didTrigger.push(!1);break}if(c!==null&&c.models.length>0){const l=se.getComponent(this.gameObject,up);l&&(c.receivers.push(l),this._signalTracks.push(c))}}else if(r.type===Rr.Signal){const c=new jm;c.director=this,c.track=r;for(const l of r.markers)c.models.push(l),c.didTrigger.push(!1);for(const l of r.outputs)c.receivers.push(l);this._signalTracks.push(c)}else if(r.type===Rr.Control){const c=new lx;c.director=this,c.track=r;for(const l of r.clips)c.models.push(l);c.resolveSourceObjects(this.context),this._controlTracks.push(c)}}}setAudioTracksAllowPlaying(t){for(const i of this._audioTracks)i.onAllowAudioChanged(t)}registerAnimationCallback(t){this.animationCallbackReceivers.push(t)}unregisterAnimationCallback(t){const i=this.animationCallbackReceivers.indexOf(t);i!==-1&&this.animationCallbackReceivers.splice(i,1)}};let Xc=Rb;u(Xc,"createTrackFunctions",{});const Uc=re("debugtimeline");class FA{constructor(){u(this,"director");u(this,"track")}get muted(){return this.track.muted}set muted(e){var t;e!==this.track.muted&&(this.track.muted=e,(t=this.onMuteChanged)==null||t.call(this))}*forEachClip(e=!1){var t;if((t=this.track)!=null&&t.clips)if(e)for(let i=this.track.clips.length-1;i>=0;i--)yield this.track.clips[i];else for(const i of this.track.clips)yield i}getClipTime(e,t){return t.clipIn+(e-t.start)*t.timeScale}getClipTimeNormalized(e,t){return(e-t.start)/t.duration}evaluateWeight(e,t,i,s=!0){if(t<0||t>=i.length)return 0;const r=i[t];if(s||e>=r.start&&e<=r.end){let o=1;const a=!1;if(r.easeInDuration>0){const c=Math.min((e-r.start)/r.easeInDuration,1);o*=c}if(r.easeOutDuration>0&&!a){const c=Math.min((r.end-e)/r.easeOutDuration,1);o*=c}return o}return 0}}class zte{constructor(e){u(this,"clip");u(this,"rootPositionOffset");u(this,"rootQuaternionOffset");u(this,"rootStartPosition");u(this,"rootEndPosition");u(this,"rootStartQuaternion");u(this,"rootEndQuaternion");const t=e.getClip();this.clip=t;const i=e.getRoot(),s=i.name+".position",r=i.name+".quaternion";Uc&&console.log(t.name,t.tracks,s);for(const o of t.tracks)if(!(o.times.length<=0)){if(o.name.endsWith(s))this.rootStartPosition=new S().fromArray(o.values,0),this.rootEndPosition=new S().fromArray(o.values,o.values.length-3),this.rootPositionOffset=this.rootEndPosition.clone().sub(this.rootStartPosition),Uc&&console.log(this.rootPositionOffset);else if(o.name.endsWith(r)&&(this.rootStartQuaternion=new Se().fromArray(o.values,0),this.rootEndQuaternion=new Se().fromArray(o.values,o.values.length-4),this.rootQuaternionOffset=this.rootEndQuaternion.clone().multiply(this.rootStartQuaternion),Uc)){const a=new Sn().setFromQuaternion(this.rootQuaternionOffset);console.log("ROT",a)}}}get hasOffsets(){return this.rootPositionOffset!==void 0||this.rootQuaternionOffset!==void 0}}class cx extends FA{constructor(){super(...arguments);u(this,"models",[]);u(this,"trackOffset");u(this,"target");u(this,"mixer");u(this,"clips",[]);u(this,"actions",[]);u(this,"_actionOffsets",[]);u(this,"_didBind",!1);u(this,"_animator",null);u(this,"_useclipOffsets",!0);u(this,"_totalOffsetPosition",new S);u(this,"_totalOffsetRotation",new Se);u(this,"_totalOffsetPosition2",new S);u(this,"_totalOffsetRotation2",new Se);u(this,"_summedPos",new S);u(this,"_tempPos",new S);u(this,"_summedRot",new Se);u(this,"_tempRot",new Se);u(this,"_clipRotQuat",new Se)}onStateChanged(){this._animator&&PD(this._animator.gameObject,this,this.director.isPlaying)}createHooks(t,i){var h,d;if(((h=i.tracks)==null?void 0:h.length)<=0){console.warn("No tracks in AnimationClip",i);return}const s=i.tracks[0].name.split("."),r=s[s.length-2],o=r+".position",a=r+".quaternion";let c=!1,l=!1;for(const f of i.tracks)f.name.endsWith(o)?(c=!0,this.createPositionInterpolant(i,t,f)):f.name.endsWith(a)&&(l=!0,this.createRotationInterpolant(i,t,f));if(!c||!l){const f=(d=this.mixer)==null?void 0:d.getRoot(),p=i.tracks[0],g=p.name.lastIndexOf("."),A=p.name.substring(0,g),v=A.substring(A.lastIndexOf(".")+1),m=f.getObjectByName(v);if(m)if(c){if(!l){const b=i.tracks[0].name.substring(0,g)+".quaternion";Uc&&console.warn("Create quaternion track",v,m);const y=m.quaternion,_=new Va(b,[0,i.duration],[y.x,y.y,y.z,y.w,y.x,y.y,y.z,y.w]);i.tracks.push(_),this.createRotationInterpolant(i,t,_)}}else{const b=A+".position";Uc&&console.warn("Create position track",v,m);const y=m.position,_=new Yc(b,[0,i.duration],[y.x,y.y,y.z,y.x,y.y,y.z]);i.tracks.push(_),this.createPositionInterpolant(i,t,_)}}}bind(){if(!this._didBind){this._didBind=!0,Uc&&console.log(this.models),this.mixer?this.target=this.mixer.getRoot():console.warn("No mixer was assigned to animation track");for(const t of this.actions){const i=new zte(t);this._actionOffsets.push(i)}this.target&&(this._animator=se.getComponent(this.target,Bs)??null,this._animator&&PD(this._animator.gameObject,this,!0));for(const t of this.models){const i=t.asset,s=i.position,r=i.rotation;s&&s.x!==void 0&&(s.isVector3||(i.position=new S(s.x,s.y,s.z)),r.isQuaternion||(i.rotation=new Se(r.x,r.y,r.z,r.w)))}this.ensureTrackOffsets()}}ensureTrackOffsets(){if(this.trackOffset){const t=this.trackOffset.position;t&&(t.isVector3||(this.trackOffset.position=new S(t.x,t.y,t.z)));const i=this.trackOffset.rotation;i&&(i.isQuaternion||(this.trackOffset.rotation=new Se(i.x,i.y,i.z,i.w)))}}evaluate(t){var c,l,h,d,f,p,g;if(this.track.muted||!this.mixer)return;this.bind(),this._totalOffsetPosition.set(0,0,0),this._totalOffsetRotation.set(0,0,0,1),this._totalOffsetPosition2.set(0,0,0),this._totalOffsetRotation2.set(0,0,0,1);let i=0,s=0,r=!1,o=!1,a=0;for(let A=0;A<this.clips.length;A++){const v=this.models[A],m=this.actions[A],b=v.asset;m.weight=0;const y=t>=v.start&&t<=v.end,_=v.preExtrapolationMode,C=v.postExtrapolationMode,M=A<this.clips.length-1?this.models[A+1]:null;let I=y,R=!1;if(!I&&!r&&v.end<t&&C!==va.None?(!M||M.start>t)&&(I=!0,r=!0):A==0&&!I&&!o&&v.start>t&&_!==va.None&&(!M||M.start<t)&&(I=!0,R=!0,o=!0),I){let E=1;E*=this.evaluateWeight(t,A,this.models,I),E*=this.director.weight;let T=y;if(R)switch(_){case va.Hold:break;case va.Loop:t+=v.start,T=!0;break;default:t+=v.start,T=!0;break}let O=this.getClipTime(t,v),K=0;const H=b.duration;if(R&&_===va.Hold&&(O=0),T){if(b.loop)for(K+=Math.floor(O/(H+1e-6));O>H;)O-=H}else if(!y&&r)switch(C){case va.Hold:O=this.getClipTime(v.end,v);break;case va.Loop:O%=H;break;case va.PingPong:const N=Math.floor(O/H)%2!==0;O%=H,N&&(O=H-O);break}v.reversed===!0?m.time=m.getClip().duration-O:m.time=O,m.timeScale=0;const V=Math.max(0,E);if(m.weight=V,a+=V,m.clampWhenFinished=!1,m.isRunning()||m.play(),this._useclipOffsets){const Y=i==0?this._totalOffsetPosition:this._totalOffsetPosition2,N=i==0?this._totalOffsetRotation:this._totalOffsetRotation2;i<1&&(s=1-E),i+=1;const L=this._summedPos.set(0,0,0),G=this._tempPos.set(0,0,0),ee=this._summedRot.identity(),$=this._tempRot.identity(),j=b.rotation;j&&(this._clipRotQuat.identity(),this._clipRotQuat.slerp(j,E));const ie=this._actionOffsets[A];if(ie.hasOffsets)for(let Ae=0;Ae<K;Ae++)ie.rootPositionOffset?G.copy(ie.rootPositionOffset):G.set(0,0,0),G.applyQuaternion(ee),this._clipRotQuat&&G.applyQuaternion(this._clipRotQuat),ie.rootQuaternionOffset&&($.copy(ie.rootQuaternionOffset),ee.multiply($)),L.add(G);this._clipRotQuat&&N.multiply(this._clipRotQuat),N.multiply(ee),b.position&&L.add(b.position),Y.add(L)}}}if(this._useclipOffsets&&(this._totalOffsetPosition.lerp(this._totalOffsetPosition2,s),this._totalOffsetRotation.slerp(this._totalOffsetRotation2,s)),this.__mixerError===void 0&&(Uc||bi())&&((l=(c=this._animator)==null?void 0:c.runtimeAnimatorController)!=null&&l.mixer)&&this.mixer!==((d=(h=this._animator)==null?void 0:h.runtimeAnimatorController)==null?void 0:d.mixer)&&(this.__mixerError=!0,console.error("AnimationTrack mixer is not shared with the animator controller - this might result in the timeline to not animate properly. Please report a bug to the Needle Engine team!",this)),(f=this._animator)!=null&&f.runtimeAnimatorController){const A=Math.max(0,1-a);(g=(p=this._animator)==null?void 0:p.runtimeAnimatorController)==null||g.update(A)}else this.mixer.update(t)}createRotationInterpolant(t,i,s){var c;const r=s.createInterpolant.bind(s),o=new Se;this.ensureTrackOffsets();const a=(c=this.trackOffset)==null?void 0:c.rotation;s.createInterpolant=()=>{const l=r(),h=l.evaluate.bind(l);return l.evaluate=d=>{var p;const f=h(d);if(o.set(f[0],f[1],f[2],f[3]),o.premultiply(this._totalOffsetRotation),a&&o.premultiply(a),this.director.animationCallbackReceivers)for(const g of this.director.animationCallbackReceivers)(p=g==null?void 0:g.onTimelineRotation)==null||p.call(g,this.director,this.target,d,o);return f[0]=o.x,f[1]=o.y,f[2]=o.z,f[3]=o.w,f},l}}createPositionInterpolant(t,i,s){var h,d;const r=s.createInterpolant.bind(s),o=new S;this.ensureTrackOffsets();const a=(h=this.trackOffset)==null?void 0:h.rotation,c=(d=this.trackOffset)==null?void 0:d.position;let l;s.createInterpolant=()=>{const f=r(),p=f.evaluate.bind(f);return f.evaluate=g=>{var v,m,b;const A=p(g);if(o.set(A[0],A[1],A[2]),i.removeStartOffset&&(l===void 0?(l=null,l=(m=(v=this._actionOffsets.find(y=>y.clip===t))==null?void 0:v.rootStartPosition)==null?void 0:m.clone()):l!=null&&l.isVector3&&o.sub(l)),o.applyQuaternion(this._totalOffsetRotation),o.add(this._totalOffsetPosition),a&&o.applyQuaternion(a),c&&(o.x-=c.x,o.y+=c.y,o.z+=c.z),this.director.animationCallbackReceivers)for(const y of this.director.animationCallbackReceivers)(b=y==null?void 0:y.onTimelinePosition)==null||b.call(y,this.director,this.target,g,o);return A[0]=o.x,A[1]=o.y,A[2]=o.z,A},f}}}const Gte=re("mutetimeline"),af=class extends FA{constructor(){super(...arguments);u(this,"models",[]);u(this,"listener");u(this,"audio",[]);u(this,"audioContextTimeOffset",[]);u(this,"lastTime",0);u(this,"_audioLoader",null)}getAudioFilePath(t){const i=this.director.sourceId;return il(i,t)}onAllowAudioChanged(t){for(let i=0;i<this.models.length;i++){const s=this.models[i];this.audio[i].setVolume(t?s.asset.volume:0)}}addModel(t){const i=new A_(this.listener);this.audio.push(i),this.models.push(t)}onDisable(){for(const t of this.audio)t.isPlaying&&t.stop()}onDestroy(){for(const t of this.audio)t.source&&(t==null||t.disconnect());this.audio.length=0}onMuteChanged(){if(this.muted)for(let t=0;t<this.audio.length;t++){const i=this.audio[t];i!=null&&i.isPlaying&&i.stop()}}stop(){for(let t=0;t<this.audio.length;t++){const i=this.audio[t];i!=null&&i.isPlaying&&i.stop()}}evaluate(t){if(Gte||this.track.muted||this.director.speed<0)return;const i=this.director.context.application.muted,s=i?.1:0;for(let r=0;r<this.models.length;r++){const o=this.models[r],a=this.audio[r];if((!a||!a.buffer)&&this.isInTimeRange(o,t-1,t+1)&&this.handleAudioLoading(o,a),Cn.userInteractionRegistered!==!1&&!(a===null||!a.buffer))if(a.playbackRate=this.director.context.time.timeScale,a.loop=o.asset.loop,t>=o.start&&t<=o.end&&t<this.director.duration){if(this.director.isPlaying==!1){if(a.isPlaying&&a.stop(),this.lastTime===t)continue}else if(!a.isPlaying)a.offset=o.clipIn+(t-o.start)*o.timeScale,a.play(s);else{const l=o.clipIn+(t-o.start)*o.timeScale,h=a.context.currentTime-a._startedAt+a.offset;Math.abs(l-h)>.3&&(a.offset=l,a.stop(),a.play(s))}let c=o.asset.volume;if(i&&(c=0),o.easeInDuration>0){const l=Math.min((t-o.start)/o.easeInDuration,1);c*=l}if(o.easeOutDuration>0){const l=Math.min((o.end-t)/o.easeOutDuration,1);c*=l}a.setVolume(c*this.director.weight)}else a.isPlaying&&a.stop()}this.lastTime=t}loadAudio(t,i=0,s=0){let r=null;const o=t-s,a=t+i;for(const c of this.models)if(this.isInTimeRange(c,o,a)){const l=this.audio[this.models.indexOf(c)],h=this.handleAudioLoading(c,l);h!==null&&(r===null&&(r=[]),r.push(h))}return r!==null?Promise.all(r):null}isInTimeRange(t,i,s){return i<=t.start&&s>=t.end||i>=t.start&&i<=t.end||s>=t.start&&s<=t.end}static dispose(){af._audioBuffers.clear()}handleAudioLoading(t,i){this._audioLoader||(this._audioLoader=new X0);const s=this.getAudioFilePath(t.asset.clip);if(af._audioBuffers.get(s)){const o=af._audioBuffers.get(s);return o.then(a=>{a&&i.setBuffer(a)}),o}Uc&&console.warn("LOAD audio track",s,this.director.sourceId);const r=new Promise((o,a)=>{this._audioLoader.load(s,c=>{i.setBuffer(c),o(c)},void 0,c=>{console.error("Error loading audio",c),o(null)})});return af._audioBuffers.set(s,r),r}};let yu=af;u(yu,"_audioBuffers",new Map);class jm extends FA{constructor(){super(...arguments);u(this,"models",[]);u(this,"didTrigger",[]);u(this,"receivers",[])}evaluate(t){var s;if(this.track.muted)return;const i=this.director.context.time.deltaTime*1.5;for(let r=0;r<this.models.length;r++){const o=this.models[r],a=this.didTrigger[r],c=o.time-t;let l=!1;if(o.retroActive)l=c<=1e-6;else{const h=Math.abs(c);(h===0||h>=1e-5&&h<i)&&(l=!0)}if(l){if(!a)if(Uc&&console.log("Trigger signal",t,o.time,o),this.didTrigger[r]=!0,((s=this.receivers)==null?void 0:s.length)<=0)up.invoke(o.asset);else for(const h of this.receivers)h&&h.invoke(o.asset)}else o.emitOnce||(this.didTrigger[r]=!1)}}}class lx extends FA{constructor(){super(...arguments);u(this,"models",[]);u(this,"timelines",[]);u(this,"_previousActiveModel",null)}resolveSourceObjects(t){for(let i=this.models.length-1;i>=0;i--){const r=this.models[i].asset;if(!r.sourceObject||typeof r.sourceObject!="object"){console.log("no source object, removing model",i,r),this.models.splice(i,1);continue}else{const o=se.getComponent(r.sourceObject,Xc);this.timelines.push(o),o&&r.updateDirector&&(o.playOnAwake=!1)}}}evaluate(t){var i;this._previousActiveModel=null;for(let s=0;s<this.models.length;s++){const r=this.models[s],o=r.asset;if(t>=r.start&&t<=r.end){this._previousActiveModel=r;const a=this.getClipTime(t,r);if(o.controlActivation){const c=o.sourceObject;c.visible=!0}if(o.updateDirector){const c=this.timelines[s];c&&(c.isPlaying&&c.pause(),c.time=a,c.evaluate())}}else{const a=(i=this._previousActiveModel)==null?void 0:i.asset;if(o.controlActivation){const c=o.sourceObject;(a==null?void 0:a.sourceObject)!==c&&(c.visible=!1)}}}}}var Hte=Object.defineProperty,Vte=Object.getOwnPropertyDescriptor,bz=(n,e,t,i)=>{for(var s=i>1?void 0:i?Vte(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Hte(e,t,s),s};class Rt{constructor(e){u(this,"_active",!0);u(this,"_value");u(this,"_valueRaw");u(this,"_defaultValue");u(this,"valueProcessor");u(this,"onValueChanged");this._value=e,this._defaultValue=e,this._valueRaw=e}get overrideState(){return this._active}set overrideState(e){if(this._active===e)return;this._active=e;const t=e?this._valueRaw:this._defaultValue;this.processValue(t,!0)}get value(){return this._valueRaw}set value(e){this.processValue(e,!1)}set defaultValue(e){this._defaultValue=e}__init(){this.processValue(this._valueRaw,!0)}processValue(e,t){if(e==null||!t&&this.testIfValueChanged(e)===!1)return;const i=this._value;!this._active&&this._defaultValue!==void 0?(this._value=this._defaultValue,e=this._defaultValue,this._valueRaw=e):(this._valueRaw=e,this._active&&this.valueProcessor&&(e=this.valueProcessor(e)),this._value=e),this.onValueChanged&&this.onValueChanged(e,i,this)}testIfValueChanged(e){return this._valueRaw!==e}}bz([x()],Rt.prototype,"overrideState",1);bz([x()],Rt.prototype,"value",1);var Qte=Object.defineProperty,Wte=Object.getOwnPropertyDescriptor,jte=(n,e,t,i)=>{for(var s=i>1?void 0:i?Wte(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Qte(e,t,s),s};const Xte=re("debugpost");class Os extends dh{constructor(t=void 0){super();u(this,"active",!0);u(this,"_result");u(this,"_didCreateVolumeParameters",!1);if(t){this.ensureVolumeParameters();for(const i of Object.keys(t)){const s=t[i],r=this[i];r instanceof Rt&&(r.value=s)}}}onEnable(){this.__internalDidAwakeAndStart&&(this.active=!0)}onDisable(){this.active=!1}init(){}apply(){var t;return this.ensureVolumeParameters(),this._result||(this._result=(t=this.onCreateEffect)==null?void 0:t.call(this)),this._result&&this.initParameters(),this._result}unapply(){}dispose(){Xte&&console.warn("DISPOSE",this),this._result&&(Array.isArray(this._result)?this._result.forEach(t=>t.dispose()):this._result.dispose()),this._result=void 0}initParameters(){const t=Object.keys(this);for(const i of t){const s=this[i];s instanceof Rt&&s.__init()}}onAfterDeserialize(t,i){if(typeof t=="object"){const s=this.$serializedTypes;if(s){for(const r of Object.keys(s))if(s[r]===Rt){const a=t[r];if(a!==void 0){const c=this[r];c.value=a}}}}}onEditorModification(t){const i=t.propertyName;if(this[i]instanceof Rt){const s=t.value;return this[i].value=s,!0}}ensureVolumeParameters(){if(this._didCreateVolumeParameters)return;this._didCreateVolumeParameters=!0;const t=this.$serializedTypes;if(t)for(const i of Object.keys(t))t[i]===Rt&&(this[i]||(this[i]=new Rt))}}jte([x()],Os.prototype,"active",2);var qte=Object.defineProperty,Yte=Object.getOwnPropertyDescriptor,Kte=(n,e,t,i)=>{for(var s=i>1?void 0:i?Yte(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&qte(e,t,s),s};const Jte=re("debugpost"),KE={};function Ro(n,e){KE[n]=e}function Zte(n){return n.__type in KE?KE[n.__type]:(Jte&&n.__type&&console.warn("Unknown postprocessing type",n.__type,n),Os)}class UA{constructor(){u(this,"components",[])}init(){var e;(e=this.components)==null||e.forEach(t=>t.init())}}Kte([tp([n=>Zte(n),Os])],UA.prototype,"components",2);var $te=Object.defineProperty,eie=Object.getOwnPropertyDescriptor,tie=(n,e,t,i)=>{for(var s=i>1?void 0:i?eie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&$te(e,t,s),s};class NA extends Os{constructor(){super(...arguments);u(this,"preset")}get typeName(){return"Antialiasing"}onCreateEffect(){const t=new rq({preset:Gd.HIGH,edgeDetectionMode:Q1.DEPTH});return this.preset.onValueChanged=i=>{t.applyPreset(i)},t}}tie([x(Rt)],NA.prototype,"preset",2);Ro("Antialiasing",NA);class hx{constructor(){u(this,"files",[])}get extensionName(){return"Audio"}onExportObject(e,t,i){const s=se.getComponents(e,Cn);if(s.length)for(const r of s){if(!r.clip||!r.playOnAwake)continue;const o=r.clip.split("/").pop();this.files.includes(r.clip)||this.files.push(r.clip),t.addEventListener("serialize",(a,c)=>{a.appendLine(),a.beginBlock(`def SpatialAudio "${t.name}"`),a.appendLine(`uniform asset filePath = @audio/${o}@`),a.appendLine(`uniform token auralMode = "${r.spatialBlend>0?"spatial":"nonSpatial"}"`),a.appendLine(`uniform token playbackMode = "${r.loop?"loopFromStage":"onceFromStart"}"`),a.appendLine(`uniform float gain = ${r.volume}`),a.closeBlock()})}}async onAfterSerialize(e){for(const t of this.files){const i=t.split("/").pop(),o=await(await(await fetch(t)).blob()).arrayBuffer(),a=new Uint8Array(o);e.files["audio/"+i]=a}}}var iie=Object.defineProperty,nie=Object.getOwnPropertyDescriptor,_z=(n,e,t,i)=>{for(var s=i>1?void 0:i?nie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&iie(e,t,s),s};const sie=re("debugmouth");class zA extends Me{constructor(){super(...arguments);u(this,"idle",[]);u(this,"talking",[]);u(this,"marker",null);u(this,"voip",null);u(this,"lastMouthChangeTime",0);u(this,"mouthChangeLength",0)}awake(){setTimeout(()=>{this.voip=se.findObjectOfType(rl,this.context),this.marker||(this.marker=se.getComponentInParent(this.gameObject,Kn))},3e3)}update(){var s;if(!this.voip||this.context.time.frameCount%10!==0)return;let t=((s=this.marker)==null?void 0:s.connectionId)??null;if(!t){sie&&(t=null);return}const i=this.voip.getFrequency(t)??0;this.updateLips(i)}updateLips(t){if(this.context.time.time-this.lastMouthChangeTime>this.mouthChangeLength){if(this.mouthChangeLength=.05+Math.random()*.1,this.talking&&this.talking.length>0&&t>30){this.lastMouthChangeTime=this.context.time.time;const i=Math.floor(Math.random()*this.talking.length);this.setMouthShapeActive(this.talking,i)}else if(this.idle.length>0&&this.context.time.time-this.lastMouthChangeTime>.5){this.lastMouthChangeTime=this.context.time.time;const i=Math.floor(Math.random()*this.idle.length);this.setMouthShapeActive(this.idle,i)}}}setMouthShapeActive(t,i){if(t){t!=this.idle?this.idle.map(s=>s.visible=!1):this.talking.map(s=>s.visible=!1);for(let s=0;s<t.length;s++){const r=t[s];r&&(r.visible=s===i)}}}}_z([x(Te)],zA.prototype,"idle",2);_z([x(Te)],zA.prototype,"talking",2);class KT extends Me{constructor(){super(...arguments);u(this,"voip",null);u(this,"marker",null);u(this,"_startPosition",null)}awake(){this.voip=se.findObjectOfType(rl,this.context),this.marker=se.getComponentInParent(this.gameObject,Kn)}update(){if(!this.voip||!this.marker||this.context.time.frameCount%10!==0)return;const t=this.marker.connectionId,i=this.voip.getFrequency(t);if(i==null)return;this._startPosition||(this._startPosition=this.gameObject.position.clone());const s=i/100;this.gameObject.position.y=this._startPosition.y+s*.07}}var rie=Object.defineProperty,oie=Object.getOwnPropertyDescriptor,ux=(n,e,t,i)=>{for(var s=i>1?void 0:i?oie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&rie(e,t,s),s};class zu extends Me{constructor(){super(...arguments);u(this,"eyes",[]);u(this,"lastBlinkTime",0);u(this,"blinkLength",0);u(this,"eyesOpen",!0);u(this,"state",null)}awake(){this.state=se.getComponentInParent(this.gameObject,Fr)}update(){if(!this.gameObject||!this.gameObject.visible||!this.eyes||!Array.isArray(this.eyes)||this.eyes.length===0)return;if(this.context.time.time-this.lastBlinkTime>this.blinkLength){if(this.lastBlinkTime=this.context.time.time,this.state&&!this.state.isOn||!this.activeAndEnabled)return;if(this.eyesOpen=!this.eyesOpen,this.blinkLength=Math.random(),this.eyesOpen?(this.blinkLength*=3,this.blinkLength+=.5,Math.random()<.1&&(this.blinkLength=.1+Math.random()*.2)):(this.blinkLength*=Math.random()*.2,this.blinkLength+=.1),Math.random()<.1&&(this.blinkLength*=3),this.blinkLength=Math.max(.2,this.blinkLength),this.blinkLength=Math.min(3,this.blinkLength),this.eyes)for(const i of this.eyes)i&&(i.visible=this.eyesOpen)}}}ux([x(Te)],zu.prototype,"eyes",2);ux([x()],zu.prototype,"lastBlinkTime",2);ux([x()],zu.prototype,"blinkLength",2);ux([x()],zu.prototype,"eyesOpen",2);var aie=Object.defineProperty,cie=Object.getOwnPropertyDescriptor,JT=(n,e,t,i)=>{for(var s=i>1?void 0:i?cie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&aie(e,t,s),s},aC;const xz=(aC=class extends Me{constructor(){super(...arguments);u(this,"head",null);u(this,"eyes",null);u(this,"target",null);u(this,"brain",null);u(this,"vec",new S);u(this,"currentTargetPoint",new S)}awake(){this.brain||(this.brain=se.getComponentInParent(this.gameObject,Lm)),this.brain||(console.log("No look at brain found, adding it now"),this.brain=se.addNewComponent(this.gameObject,Lm)),this.brain&&this.target&&(this.brain.controlledTarget=this.target)}update(){const e=this.target;if(e&&this.head){const t=this.eyes;if(t){const i=wt(e);this.currentTargetPoint.lerp(i,this.context.time.deltaTime/.1);const s=wt(this.head),r=this.vec.copy(this.currentTargetPoint).sub(s).normalize();if(r.length()<.1)return;const o=xz.forward;if(o.set(0,0,1),o.applyQuaternion(Fn(this.head)),o.dot(r)>.45)for(let c=0;c<t.length;c++)t[c].lookAt(this.currentTargetPoint)}}}},u(aC,"forward",new S(0,0,1)),aC);let dp=xz;JT([x(Te)],dp.prototype,"head",2);JT([x(Te)],dp.prototype,"eyes",2);JT([x(Te)],dp.prototype,"target",2);var lie=Object.defineProperty,hie=Object.getOwnPropertyDescriptor,ZT=(n,e,t,i)=>{for(var s=i>1?void 0:i?hie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&lie(e,t,s),s};class fp extends Me{constructor(){super(...arguments);u(this,"length",1);u(this,"depthTest",!0);u(this,"isGizmo",!0);u(this,"_axes",null)}onEnable(){if(this.isGizmo&&!gA)return;this._axes||(this._axes=new Xf(this.length)),this.gameObject.add(this._axes);const t=this._axes.material;t&&t.depthTest!==void 0&&(t.depthTest=this.depthTest)}onDisable(){this._axes&&this.gameObject.remove(this._axes)}}ZT([x()],fp.prototype,"length",2);ZT([x()],fp.prototype,"depthTest",2);ZT([x()],fp.prototype,"isGizmo",2);class $T extends Me{constructor(){super(...arguments);u(this,"from");u(this,"to");u(this,"hint");u(this,"desiredDistance",1)}onEnable(){}update(){if(!this.from||!this.to||!this.hint)return;const t=wt(this.to).clone(),i=wt(this.from).clone(),s=t.distanceTo(i),r=t.clone();r.sub(i);const o=i.clone();o.add(t),o.multiplyScalar(.5);const a=wt(this.hint).clone();a.sub(o);const c=new S;c.crossVectors(a,r),c.crossVectors(r,c),c.normalize();const l=s*.5,h=Math.max(this.desiredDistance,l),d=Math.sqrt(h*h-l*l),f=c.clone();f.multiplyScalar(d),f.add(o),fn(this.gameObject,f);const p=o.clone();p.sub(c),this.gameObject.lookAt(p)}}const iO=re("debugusdz");class dx{constructor(){u(this,"behaviours",[]);u(this,"behaviourComponents",[]);u(this,"behaviourComponentsCopy",[])}get extensionName(){return"Behaviour"}addBehavior(e){this.behaviours.push(e)}onBeforeBuildDocument(e){const t=[];return e.root.traverse(i=>{se.foreachComponent(i,s=>{var o;const r=s;if(typeof r.createBehaviours=="function"||typeof r.beforeCreateDocument=="function"||typeof r.afterCreateDocument=="function"||typeof r.afterSerialize=="function"){this.behaviourComponents.push(r);const a=(o=r.beforeCreateDocument)==null?void 0:o.call(r,this,e);a instanceof Promise&&t.push(a)}},!1)}),Promise.all(t)}onExportObject(e,t,i){var s;for(const r of this.behaviourComponents)(s=r.createBehaviours)==null||s.call(r,this,t,i)}onAfterBuildDocument(e){for(const t of this.behaviourComponents)typeof t.afterCreateDocument=="function"&&t.afterCreateDocument(this,e);this.behaviourComponentsCopy=this.behaviourComponents.slice(),this.behaviourComponents.length=0}onAfterHierarchy(e,t){var i;if((i=this.behaviours)!=null&&i.length){t.beginBlock('def Scope "Behaviors"');for(const s of this.behaviours)s.writeTo(this,e.document,t);t.closeBlock()}}async onAfterSerialize(e){iO&&console.log("onAfterSerialize behaviours",this.behaviourComponentsCopy);for(const t of this.behaviourComponentsCopy)typeof t.afterSerialize=="function"&&(iO&&console.log("behaviour has afterSerialize",t),t.afterSerialize.constructor.name==="AsyncFunction"?await t.afterSerialize(this,e):t.afterSerialize(this,e))}}var uie=Object.defineProperty,die=Object.getOwnPropertyDescriptor,eI=(n,e,t,i)=>{for(var s=i>1?void 0:i?die(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&uie(e,t,s),s};class Gu extends Os{constructor(){super(...arguments);u(this,"threshold");u(this,"intensity");u(this,"scatter");u(this,"selectiveBloom",!0)}get typeName(){return"Bloom"}init(){this.threshold.defaultValue=1,this.intensity.defaultValue=0,this.scatter.defaultValue=.2,this.selectiveBloom?(this.threshold.valueProcessor=t=>t,this.intensity.valueProcessor=t=>t,this.scatter.valueProcessor=t=>1*Math.PI*(1-t)):(this.threshold.valueProcessor=t=>t,this.intensity.valueProcessor=t=>t,this.scatter.valueProcessor=t=>100*(1-t))}onCreateEffect(){let t;if(this.selectiveBloom){const i=t=new LU(this.context.scene,this.context.mainCamera,{blendFunction:zt.ADD,mipmapBlur:!0,luminanceThreshold:this.threshold.value,luminanceSmoothing:this.scatter.value,intensity:this.intensity.value});i.inverted=!0}else t=new q1;return this.intensity.onValueChanged=i=>{t.intensity=i},this.threshold.onValueChanged=i=>{t.luminanceMaterial.threshold=i},this.scatter.onValueChanged=i=>{t.luminancePass.enabled=!0,t.luminanceMaterial.smoothing=i},t}}eI([x(Rt)],Gu.prototype,"threshold",2);eI([x(Rt)],Gu.prototype,"intensity",2);eI([x(Rt)],Gu.prototype,"scatter",2);Ro("Bloom",Gu);var fie=Object.defineProperty,pie=Object.getOwnPropertyDescriptor,aa=(n,e,t,i)=>{for(var s=i>1?void 0:i?pie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&fie(e,t,s),s};class Ya extends Me{constructor(){super(...arguments);u(this,"attachedRigidbody",null);u(this,"isTrigger",!1);u(this,"sharedMaterial")}get isCollider(){return!0}awake(){super.awake(),this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Yi))}start(){this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Yi))}onEnable(){this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Yi))}onDisable(){var t;(t=this.context.physics.engine)==null||t.removeBody(this)}}aa([x(Yi)],Ya.prototype,"attachedRigidbody",2);aa([x()],Ya.prototype,"isTrigger",2);aa([x()],Ya.prototype,"sharedMaterial",2);class GA extends Ya{constructor(){super(...arguments);u(this,"radius",.5);u(this,"center",new S(0,0,0))}onEnable(){var t;super.onEnable(),(t=this.context.physics.engine)==null||t.addSphereCollider(this,this.center,this.radius)}}aa([x()],GA.prototype,"radius",2);aa([x(S)],GA.prototype,"center",2);class HA extends Ya{constructor(){super(...arguments);u(this,"size",new S(1,1,1));u(this,"center",new S(0,0,0))}onEnable(){var t;super.onEnable(),(t=this.context.physics.engine)==null||t.addBoxCollider(this,this.center,this.size)}}aa([x(S)],HA.prototype,"size",2);aa([x(S)],HA.prototype,"center",2);class VA extends Ya{constructor(){super(...arguments);u(this,"sharedMesh");u(this,"convex",!1)}onEnable(){var t,i,s,r,o;if(super.onEnable(),(t=this.sharedMesh)!=null&&t.isMesh||this.gameObject instanceof ye&&(this.sharedMesh=this.gameObject),(i=this.sharedMesh)!=null&&i.isMesh)(s=this.context.physics.engine)==null||s.addMeshCollider(this,this.sharedMesh,this.convex,qn(this.gameObject));else{const a=this.sharedMesh;if(a!=null&&a.isGroup){console.warn(`MeshCollider mesh is a group "${(r=this.sharedMesh)==null?void 0:r.name}", adding all children as colliders. This is currently not fully supported (colliders can not be removed from world again)`,this);for(const c in a.children){const l=a.children[c];l.isMesh&&((o=this.context.physics.engine)==null||o.addMeshCollider(this,l,this.convex,qn(this.gameObject)))}}}}}aa([x()],VA.prototype,"convex",2);class rh extends Ya{constructor(){super(...arguments);u(this,"center",new S(0,0,0));u(this,"radius",.5);u(this,"height",2)}onEnable(){var t;super.onEnable(),(t=this.context.physics.engine)==null||t.addCapsuleCollider(this,this.center,this.height,this.radius)}}aa([x(S)],rh.prototype,"center",2);aa([x()],rh.prototype,"radius",2);aa([x()],rh.prototype,"height",2);var gie=Object.defineProperty,mie=Object.getOwnPropertyDescriptor,QA=(n,e,t,i)=>{for(var s=i>1?void 0:i?mie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&gie(e,t,s),s};const IS=re("debugui"),RS=re("debuguilayout");class tI{constructor(){u(this,"width");u(this,"height")}}class iI{constructor(){u(this,"x");u(this,"y");u(this,"width");u(this,"height")}}const Uo=new S,eg=new Re,My=new Se,wz=class extends ta{constructor(){super(...arguments);u(this,"_anchoredPosition");u(this,"sizeDelta",new te(100,100));u(this,"pivot",new te(.5,.5));u(this,"anchorMin",new te(0,0));u(this,"anchorMax",new te(1,1));u(this,"lastMatrix");u(this,"rectBlock");u(this,"_transformNeedsUpdate",!1);u(this,"_initialPosition");u(this,"_parentRectTransform");u(this,"_lastUpdateFrame",-1);u(this,"_lastAnchoring");u(this,"_createdBlocks",[]);u(this,"_createdTextBlocks",[])}get parent(){return this._parentRectTransform}get translation(){return this.gameObject.position}get rotation(){return this.gameObject.quaternion}get scale(){return this.gameObject.scale}get anchoredPosition(){return this._anchoredPosition||(this._anchoredPosition=new te),this._anchoredPosition}set anchoredPosition(e){this._anchoredPosition=e}get width(){if(this.anchorMin.x!==this.anchorMax.x&&this._parentRectTransform){const e=this._parentRectTransform.width,t=this.anchorMax.x-this.anchorMin.x;let i=e*t;return i+=this.sizeDelta.x,i}return this.sizeDelta.x}get height(){if(this.anchorMin.y!==this.anchorMax.y&&this._parentRectTransform){const e=this._parentRectTransform.height,t=this.anchorMax.y-this.anchorMin.y;let i=e*t;return i+=this.sizeDelta.y,i}return this.sizeDelta.y}awake(){super.awake(),this._anchoredPosition||(this._anchoredPosition=new te),this.lastMatrix=new Re,this.rectBlock=new Te,this.rectBlock.name=this.name,this._initialPosition=this.gameObject.position.clone(),this._initialPosition.z=0,Qd(this,"_anchoredPosition",()=>{this.markDirty()}),Qd(this,"sizeDelta",()=>{this.markDirty()}),Qd(this,"pivot",()=>{this.markDirty()}),Qd(this,"anchorMin",()=>{this.markDirty()}),Qd(this,"anchorMax",()=>{this.markDirty()})}onEnable(){var e;super.onEnable(),this.addShadowComponent(this.rectBlock),this._transformNeedsUpdate=!0,(e=this.Canvas)==null||e.registerTransform(this)}onDisable(){var e;super.onDisable(),this.removeShadowComponent(),(e=this.Canvas)==null||e.unregisterTransform(this)}onParentRectTransformChanged(e){this._transformNeedsUpdate||this.onApplyTransform(RS?`${e.name} changed`:void 0)}get isDirty(){return this._transformNeedsUpdate||(this._transformNeedsUpdate=!this.lastMatrix.equals(this.gameObject.matrix)),this._transformNeedsUpdate}markDirty(){this._transformNeedsUpdate||(RS&&console.warn("RectTransform markDirty()",this.name),this._transformNeedsUpdate=!0,this._lastUpdateFrame=-1)}updateTransform(){(this._transformNeedsUpdate||!this.lastMatrix.equals(this.gameObject.matrix))&&this.canUpdate()&&this.onApplyTransform(this._transformNeedsUpdate?"Marked dirty":"Matrix changed")}canUpdate(){return this._transformNeedsUpdate&&this.activeAndEnabled&&this._lastUpdateFrame!==this.context.time.frame}onApplyTransform(e){var s;if(this.context.time.frameCount===this._lastUpdateFrame)return;this._lastUpdateFrame=this.context.time.frameCount;const t=this.shadowComponent;if(!t)return;this.gameObject.parent?this._parentRectTransform=se.getComponentInParent(this.gameObject.parent,wz):this._parentRectTransform=void 0,this._transformNeedsUpdate=!1,RS&&console.warn("RectTransform → ApplyTransform",this.name+" because "+e),this.isRoot()?this.Root.screenspace||(t.rotation.y=Math.PI):(t.matrix.identity(),t.matrixAutoUpdate=!1,Uo.set(0,0,0),this.applyPivot(Uo),t.matrix.setPosition(Uo.x,Uo.y,0),(this.gameObject.quaternion.x||this.gameObject.quaternion.y||this.gameObject.quaternion.z)&&(My.copy(this.gameObject.quaternion),My.x*=-1,My.z*=-1,eg.makeRotationFromQuaternion(My),t.matrix.premultiply(eg)),Uo.set(0,0,0),this.applyAnchoring(Uo),(s=this.Canvas)!=null&&s.screenspace?Uo.z+=.1:Uo.z+=.01,eg.identity(),eg.setPosition(Uo.x,Uo.y,Uo.z),t.matrix.premultiply(eg),t.matrix.scale(this.gameObject.scale)),this.lastMatrix.copy(this.gameObject.matrix);const i=!0;for(const r of H1(this.gameObject,ta,i,1)){if(r===this||!r.activeAndEnabled)continue;const o=r;o.onParentRectTransformChanged&&o.onParentRectTransformChanged(this)}}applyAnchoring(e){this._lastAnchoring||(this._lastAnchoring=new te);const t=this._lastAnchoring.sub(this._anchoredPosition);this.gameObject.position.x+=t.x,this.gameObject.position.y+=t.y,this._lastAnchoring.copy(this._anchoredPosition),e.x+=this._initialPosition.x-this.gameObject.position.x,e.y+=this._initialPosition.y-this.gameObject.position.y,e.z+=this._initialPosition.z-this.gameObject.position.z;const i=this._parentRectTransform;if(i){let s=0;const r=1-this.anchorMax.y-this.anchorMin.y;s-=i.height*.5*r,e.y+=s;let o=0;const a=1-this.anchorMax.x-this.anchorMin.x;o-=i.width*.5*a,e.x+=o}}applyPivot(e){if(this.pivot&&!this.isRoot()){const t=this.pivot.x-.5;e.x-=t*this.sizeDelta.x*this.gameObject.scale.x;const i=this.pivot.y-.5;e.y-=i*this.sizeDelta.y*this.gameObject.scale.y}}getBasicOptions(){const e={width:this.sizeDelta.x,height:this.sizeDelta.y,offset:0,backgroundOpacity:0,borderWidth:0,borderRadius:0,borderOpacity:0,letterSpacing:-.03};return this.ensureValidSize(e),e}ensureValidSize(e,t=1e-4){return e.width<=0&&(e.width=t),e.height<=0&&(e.height=1e-4),e}createNewBlock(e){e={...this.getBasicOptions(),...e},IS&&console.log(this.name,e);const t=new WT(e);return this._createdBlocks.push(t),t}createNewText(e){IS&&console.log(e),e={...this.getBasicOptions(),...e},IS&&console.log(this.name,e);const t=new gz(e);return this._createdTextBlocks.push(t),t}};let tr=wz;QA([x(te)],tr.prototype,"anchoredPosition",1);QA([x(te)],tr.prototype,"sizeDelta",2);QA([x(te)],tr.prototype,"pivot",2);QA([x(te)],tr.prototype,"anchorMin",2);QA([x(te)],tr.prototype,"anchorMax",2);class Aie extends pz{constructor(e,t={}){super(e),e._simpleState__activeStates=[],e._simpleState__normalStyles={},e._simpleState__states=t,e._simpleState__statesProperties={};for(const i in t)for(const s in t[i])e._simpleState__statesProperties[s]||(e._simpleState__statesProperties[s]=[]),e._simpleState__statesProperties[s].push(i);for(const i of e._components)e._simpleState__statesProperties[i.id]&&(e._simpleState__normalStyles[i.id]=i.inline?i.inline:i._value);e.__overridedSet=e.set,e.set=this.storeSet.bind(e),e.renderStates=this.renderStates.bind(e),e.setupState=this.setupState.bind(e),e.setState=this.setState.bind(e),e.activatePseudoState=this.activatePseudoState.bind(e),e.deactivatePseudoState=this.deactivatePseudoState.bind(e),e.togglePseudoState=this.togglePseudoState.bind(e)}act(){}attach(){}detach(){}setupState(e,t){this._simpleState__states[e]=t;const i=[];for(const s in t)this._simpleState__statesProperties[s]||(this._simpleState__statesProperties[s]=[],i.push(s)),this._simpleState__statesProperties[s].push(e);for(const s of this._components)i.indexOf(s.id)>-1&&(this._simpleState__normalStyles[s.id]=s.inline?s.inline:s._value)}renderStates(){let e={...this._simpleState__normalStyles};for(const t in this._simpleState__states)this._simpleState__activeStates.indexOf(t)>-1&&(e={...e,...this._simpleState__states[t]});this.set(e,!1)}storeSet(e,t=!0){if(t)for(const i in e)this._simpleState__statesProperties[i]&&(this._simpleState__normalStyles[i]=e[i]);this.__overridedSet(e)}activatePseudoState(e){this._simpleState__activeStates.indexOf(e)===-1&&(this._simpleState__activeStates.push(e),this.renderStates())}deactivatePseudoState(e){const t=this._simpleState__activeStates.indexOf(e);t>-1&&(this._simpleState__activeStates.splice(t,1),this.renderStates())}togglePseudoState(e){const t=this._simpleState__activeStates.indexOf(e);t>-1?this._simpleState__activeStates.splice(t,1):this._simpleState__activeStates.push(e),this.renderStates()}setState(e){Array.isArray(e)?this._simpleState__activeStates=e:this._simpleState__activeStates=[e],this.renderStates()}}var vie=Object.defineProperty,yie=Object.getOwnPropertyDescriptor,Sz=(n,e,t,i)=>{for(var s=i>1?void 0:i?yie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&vie(e,t,s),s};class pp extends Me{constructor(){super(...arguments);u(this,"effectColor");u(this,"effectDistance")}}Sz([x(_i)],pp.prototype,"effectColor",2);Sz([x(te)],pp.prototype,"effectDistance",2);var bie=Object.defineProperty,_ie=Object.getOwnPropertyDescriptor,Cz=(n,e,t,i)=>{for(var s=i>1?void 0:i?_ie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&bie(e,t,s),s};const Ty={backgroundColor:new _e(1,1,1),backgroundOpacity:1,borderColor:new _e(1,1,1),borderOpacity:1};var cC;const S0=(cC=class extends ta{constructor(){super(...arguments);u(this,"_alphaFactor",1);u(this,"raycastTarget",!0);u(this,"uiObject",null);u(this,"_color",null);u(this,"_rect",null);u(this,"_stateManager",null);u(this,"_currentlyCreatingPanel",!1)}get isGraphic(){return!0}get color(){return this._color||(this._color=new _i(1,1,1,1)),this._color}set color(e){(!this._color||this._color.r!==e.r||this._color.g!==e.g||this._color.b!==e.b||this._color.alpha!==e.alpha)&&(this._color||(this._color=new _i(1,1,1,1)),this._color.copy(e))}setAlphaFactor(e){this._alphaFactor=e,this.onColorChanged()}get alphaFactor(){return this._alphaFactor}onColorChanged(){this.uiObject&&(Ty.backgroundColor=this._color,Ty.backgroundOpacity=this._color.alpha*this._alphaFactor,this.applyEffects(Ty,this._alphaFactor),this.uiObject.set(Ty),this.markDirty())}get m_Color(){return this._color}get rectTransform(){if(this._rect||(this._rect=se.getComponent(this.gameObject,tr)),!this._rect)throw new Error("Not Supported: Make sure to add a RectTransform component before adding a UI Graphic component.");return this._rect}onParentRectTransformChanged(){var e;(e=this.uiObject)==null||e.set({width:this.rectTransform.width,height:this.rectTransform.height}),this.markDirty()}__internalNewInstanceCreated(){super.__internalNewInstanceCreated(),this._rect=null,this.uiObject=null,this._color&&(this._color=this._color.clone())}setState(e){this.makePanel(),this.uiObject&&(this.uiObject.setState(e),this==null||this.markDirty())}setupState(e){this.makePanel(),this.uiObject&&(this._stateManager||(this._stateManager=new Aie(this.uiObject)),this.uiObject.setupState(e.state,e.attributes))}setOptions(e){this.makePanel(),this.uiObject&&this.uiObject.set(e)}awake(){super.awake(),this.makePanel(),Qd(this,"_color",()=>Tte(this,this.onColorChanged))}onEnable(){var e;super.onEnable(),this.uiObject&&((e=this.rectTransform.shadowComponent)==null||e.add(this.uiObject),this.addShadowComponent(this.uiObject,this.rectTransform))}onDisable(){super.onDisable(),this.uiObject&&this.removeShadowComponent()}makePanel(){if(this.uiObject||this._currentlyCreatingPanel)return;this._currentlyCreatingPanel=!0;const e=.015,t={backgroundColor:this.color,backgroundOpacity:this.color.alpha,offset:e};this.onBeforeCreate(t),this.applyEffects(t),this.onCreate(t),this.controlsChildLayout=!1,this._currentlyCreatingPanel=!1,this.onAfterCreated()}onBeforeCreate(e){}onCreate(e){this.uiObject=this.rectTransform.createNewBlock(e),this.uiObject.name=this.name}onAfterCreated(){}applyEffects(e,t=1){var s;const i=(s=this.gameObject)==null?void 0:s.getComponent(pp);i&&(i.effectDistance&&(e.borderWidth=Math.max(Math.abs(i.effectDistance.x),Math.abs(i.effectDistance.y))),i.effectColor&&(e.borderColor=i.effectColor,e.borderOpacity=i.effectColor.alpha*t))}async setTexture(e){if(this.setOptions({backgroundOpacity:0}),e){if(e.colorSpace===Ze){if(S0.textureCache.has(e))e=S0.textureCache.get(e);else if(!e.isRenderTargetTexture){const t=e.clone();t.colorSpace=pn,S0.textureCache.set(e,t),e=t}}this.setOptions({backgroundImage:e,borderRadius:0,backgroundOpacity:this.color.alpha,backgroundSize:"stretch"})}else this.setOptions({backgroundImage:null,borderRadius:0,backgroundOpacity:this.color.alpha});this.markDirty()}onAfterAddedToScene(){super.onAfterAddedToScene(),this.shadowComponent&&(this.shadowComponent.offset=this.shadowComponent.position.z)}},u(cC,"textureCache",new Map),cC);let Hu=S0;Cz([x(_i)],Hu.prototype,"color",1);Cz([x()],Hu.prototype,"raycastTarget",2);class WA extends Hu{constructor(){super(...arguments);u(this,"_flippedObject",!1)}onAfterCreated(){this.uiObject&&!this._flippedObject&&(this._flippedObject=!0,this.uiObject.scale.y*=-1)}}var xie=Object.defineProperty,wie=Object.getOwnPropertyDescriptor,fx=(n,e,t,i)=>{for(var s=i>1?void 0:i?wie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&xie(e,t,s),s};let nI=class{constructor(){u(this,"texture",null);u(this,"rect")}};fx([x(Ot)],nI.prototype,"texture",2);let gp=class extends WA{constructor(){super(...arguments);u(this,"_sprite");u(this,"pixelsPerUnitMultiplier",1)}set image(t){this.sprite||(this.sprite=new nI),this.sprite.texture=t,this.onAfterCreated()}get image(){return this.sprite?this.sprite.texture:null}get sprite(){return this._sprite}set sprite(t){this._sprite!==t&&(this._sprite=t,this.onAfterCreated())}isBuiltinSprite(){var t,i,s,r,o,a,c,l;switch((i=(t=this.sprite)==null?void 0:t.texture)==null?void 0:i.name){case"InputFieldBackground":case"UISprite":case"Background":case"Knob":return!0}return((o=(r=(s=this.sprite)==null?void 0:s.texture)==null?void 0:r.image)==null?void 0:o.width)===32&&((l=(c=(a=this.sprite)==null?void 0:a.texture)==null?void 0:c.image)==null?void 0:l.height)===32}onBeforeCreate(t){var i,s;super.onBeforeCreate(t),this.isBuiltinSprite()&&(t.borderRadius=5/this.pixelsPerUnitMultiplier,((s=(i=this.sprite)==null?void 0:i.texture)==null?void 0:s.name)==="Knob"&&(t.borderRadius=999))}onAfterCreated(){var t;this.__didAwake&&(super.onAfterCreated(),!this.isBuiltinSprite()&&this.setTexture((t=this.sprite)==null?void 0:t.texture))}};fx([x(nI)],gp.prototype,"sprite",1);fx([x()],gp.prototype,"pixelsPerUnitMultiplier",2);class px extends WA{constructor(){super(...arguments);u(this,"_mainTexture")}get mainTexture(){return this._mainTexture}set mainTexture(t){this._mainTexture!==t&&(this._mainTexture=t,this.onAfterCreated())}onAfterCreated(){this.__didAwake&&(super.onAfterCreated(),this.setTexture(this.mainTexture))}}fx([x(Ot)],px.prototype,"mainTexture",1);var Sie=Object.defineProperty,Cie=Object.getOwnPropertyDescriptor,Yr=(n,e,t,i)=>{for(var s=i>1?void 0:i?Cie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Sie(e,t,s),s};const Dd=re("debugbutton");class Vu{constructor(){u(this,"colorMultiplier");u(this,"disabledColor");u(this,"fadeDuration");u(this,"highlightedColor");u(this,"normalColor");u(this,"pressedColor");u(this,"selectedColor")}}Yr([x()],Vu.prototype,"colorMultiplier",2);Yr([x(_i)],Vu.prototype,"disabledColor",2);Yr([x()],Vu.prototype,"fadeDuration",2);Yr([x(_i)],Vu.prototype,"highlightedColor",2);Yr([x(_i)],Vu.prototype,"normalColor",2);Yr([x(_i)],Vu.prototype,"pressedColor",2);Yr([x(_i)],Vu.prototype,"selectedColor",2);class ll extends Me{constructor(){super(...arguments);u(this,"onClick");u(this,"_isHovered",!1);u(this,"colors");u(this,"transition");u(this,"animationTriggers");u(this,"animator");u(this,"_interactable",!0);u(this,"_requestedAnimatorTrigger");u(this,"_isInit",!1);u(this,"_image")}onPointerEnter(t){var i,s;Dd&&console.log("Button Enter",(i=this.animationTriggers)==null?void 0:i.highlightedTrigger,this.animator),this._isHovered=!0,this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.highlightedTrigger):this.transition===1&&this.colors&&((s=this._image)==null||s.setState("hovered")),this.context.input.setCursorPointer())}onPointerExit(){var t,i;Dd&&console.log("Button Exit",(t=this.animationTriggers)==null?void 0:t.highlightedTrigger,this.animator),this._isHovered=!1,this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.normalTrigger):this.transition===1&&this.colors&&((i=this._image)==null||i.setState("normal")),this.context.input.setCursorNormal())}onPointerDown(t){var i,s;Dd&&console.log("Button Down",(i=this.animationTriggers)==null?void 0:i.highlightedTrigger,this.animator),this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.pressedTrigger):this.transition===1&&this.colors&&((s=this._image)==null||s.setState("pressed")))}onPointerUp(t){var i,s;Dd&&console.warn("Button Up",(i=this.animationTriggers)==null?void 0:i.highlightedTrigger,this.animator,this._isHovered),this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this._isHovered?this.animationTriggers.highlightedTrigger:this.animationTriggers.normalTrigger):this.transition===1&&this.colors&&((s=this._image)==null||s.setState(this._isHovered?"hovered":"normal")))}onPointerClick(t){var i;this.interactable&&t.pointerId===0&&(Dd&&(console.warn("Button Click",this.onClick),_n("CLICKED button "+this.name+" at "+this.context.time.frameCount)),(i=this.onClick)==null||i.invoke())}set interactable(t){this._interactable=t,this._image&&(this._image.setInteractable(t),t?this._image.setState("normal"):this._image.setState("disabled"))}get interactable(){return this._interactable}set_interactable(t){this.interactable=t}awake(){super.awake(),Dd&&console.log(this),this._isInit=!1,this.init()}start(){var t;(t=this._image)==null||t.setInteractable(this.interactable)}onEnable(){super.onEnable()}*setAnimatorTriggerAtEndOfFrame(t){var i;this._requestedAnimatorTrigger=t,yield,yield,this._requestedAnimatorTrigger==t&&((i=this.animator)==null||i.SetTrigger(t))}init(){this._isInit||(this._isInit=!0,this._image=se.getComponent(this.gameObject,gp),this._image&&(this.stateSetup(this._image),this.interactable?this._image.setState("normal"):this._image.setState("disabled")))}stateSetup(t){var p,g,A,v,m;t.setInteractable(this.interactable);const i=this.getFinalColor(t.color,(p=this.colors)==null?void 0:p.normalColor),s={state:"normal",attributes:{backgroundColor:i,backgroundOpacity:i.alpha}};t.setupState(s);const r=this.getFinalColor(t.color,(g=this.colors)==null?void 0:g.highlightedColor),o={state:"hovered",attributes:{backgroundColor:r,backgroundOpacity:r.alpha}};t.setupState(o);const a=this.getFinalColor(t.color,(A=this.colors)==null?void 0:A.pressedColor),c={state:"pressed",attributes:{backgroundColor:a,backgroundOpacity:a.alpha}};t.setupState(c);const l=this.getFinalColor(t.color,(v=this.colors)==null?void 0:v.selectedColor),h={state:"selected",attributes:{backgroundColor:l,backgroundOpacity:l.alpha}};t.setupState(h);const d=this.getFinalColor(t.color,(m=this.colors)==null?void 0:m.disabledColor),f={state:"disabled",attributes:{backgroundColor:d,backgroundOpacity:d.alpha}};t.setupState(f)}getFinalColor(t,i){return i?t.clone().multiply(i):t.clone()}}Yr([x(cs)],ll.prototype,"onClick",2);Yr([x()],ll.prototype,"colors",2);Yr([x()],ll.prototype,"transition",2);Yr([x()],ll.prototype,"animationTriggers",2);Yr([x(Bs)],ll.prototype,"animator",2);Yr([x()],ll.prototype,"interactable",1);var Eie=Object.defineProperty,Mie=Object.getOwnPropertyDescriptor,Tn=(n,e,t,i)=>{for(var s=i>1?void 0:i?Mie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Eie(e,t,s),s};const nO=re("debuguilayout");class Ah{constructor(){u(this,"left",0);u(this,"right",0);u(this,"top",0);u(this,"bottom",0)}get vertical(){return this.top+this.bottom}get horizontal(){return this.left+this.right}}Tn([x()],Ah.prototype,"left",2);Tn([x()],Ah.prototype,"right",2);Tn([x()],Ah.prototype,"top",2);Tn([x()],Ah.prototype,"bottom",2);class Kr extends Me{constructor(){super(...arguments);u(this,"_rectTransform",null);u(this,"_needsUpdate",!1);u(this,"childAlignment",0);u(this,"reverseArrangement",!1);u(this,"spacing",0);u(this,"padding");u(this,"minWidth",0);u(this,"minHeight",0);u(this,"flexibleHeight",0);u(this,"flexibleWidth",0);u(this,"preferredHeight",0);u(this,"preferredWidth",0)}get rectTransform(){return this._rectTransform}onParentRectTransformChanged(t){this._needsUpdate=!0}get isDirty(){return this._needsUpdate}get isLayoutGroup(){return!0}updateLayout(){this._rectTransform&&(nO&&console.warn("Layout Update",this.context.time.frame,this.name),this._needsUpdate=!1,this.onCalculateLayout(this._rectTransform))}start(){this._needsUpdate=!0}onEnable(){nO&&console.log(this.name,this),this._rectTransform=this.gameObject.getComponent(tr);const t=this.gameObject.getComponentInParent(us);t&&t.registerLayoutGroup(this),this._needsUpdate=!0}onDisable(){const t=this.gameObject.getComponentInParent(us);t&&t.unregisterLayoutGroup(this)}set m_Spacing(t){t!==this.spacing&&(this._needsUpdate=!0,this.spacing=t)}get m_Spacing(){return this.spacing}}Tn([x()],Kr.prototype,"childAlignment",2);Tn([x()],Kr.prototype,"reverseArrangement",2);Tn([x()],Kr.prototype,"spacing",2);Tn([x(Ah)],Kr.prototype,"padding",2);Tn([x()],Kr.prototype,"minWidth",2);Tn([x()],Kr.prototype,"minHeight",2);Tn([x()],Kr.prototype,"flexibleHeight",2);Tn([x()],Kr.prototype,"flexibleWidth",2);Tn([x()],Kr.prototype,"preferredHeight",2);Tn([x()],Kr.prototype,"preferredWidth",2);class vh extends Kr{constructor(){super(...arguments);u(this,"childControlHeight",!0);u(this,"childControlWidth",!0);u(this,"childForceExpandHeight",!1);u(this,"childForceExpandWidth",!1);u(this,"childScaleHeight",!1);u(this,"childScaleWidth",!1)}onCalculateLayout(t){var R;const i=this.primaryAxis,s=t.width;let r=s;const o=t.height;let a=o;r-=this.padding.horizontal,a-=this.padding.vertical,i==="x"?this.padding.horizontal:this.padding.vertical;const c=i==="x",l=c?"y":"x",h=c?this.childControlWidth:this.childControlHeight,d=c?this.childControlHeight:this.childControlWidth,f=c?this.childForceExpandWidth:this.childForceExpandHeight,p=c?this.childForceExpandHeight:this.childForceExpandWidth,g=c?a:r,A=c?s:o,v=.5*(c?this.childAlignment%3:Math.floor(this.childAlignment/3));let m=0;c?m+=this.padding.left:m+=this.padding.top;let b=0,y=0;for(let E=0;E<this.gameObject.children.length;E++){const T=this.gameObject.children[E],O=se.getComponent(T,tr);O!=null&&O.activeAndEnabled&&(y+=1,c?b+=O.width:b+=O.height)}let _=0;const C=this.spacing*(y-1);if(f||h){let E=0;c?E=r-=C:E=a-=C,y>0&&(_=E/y)}let M=0;M+=this.padding.left,M-=this.padding.right,v!==0&&(m=A-b,m*=v,m-=C*v,c?(m-=this.padding.right*v,m+=this.padding.left*(1-v),m<this.padding.left&&(m=this.padding.left)):(m-=this.padding.bottom*v,m+=this.padding.top*(1-v),m<this.padding.top&&(m=this.padding.top)));let I=1;for(let E=0;E<this.gameObject.children.length;E++){const T=this.gameObject.children[E],O=se.getComponent(T,tr);if(O!=null&&O.activeAndEnabled){(R=O.pivot)==null||R.set(.5,.5),O.anchorMin.set(0,1),O.anchorMax.set(0,1);const K=s*.5+M*.5;O.anchoredPosition.x!==K&&(O.anchoredPosition.x=K);const H=o*-.5;O.anchoredPosition.y!==H&&(O.anchoredPosition.y=H),p&&d&&O.sizeDelta[l]!==g&&(O.sizeDelta[l]=g),f&&h&&O.sizeDelta[i]!==_&&(O.sizeDelta[i]=_);const V=c?O.width:O.height,Y=V*.5;if(m+=Y,f){const L=_*I-_*.5;L>m&&(m=L-_*.5+V+this.padding.left,m-=Y)}let N=m;i==="y"&&(N=-N),O.anchoredPosition[i]!==N&&(O.anchoredPosition[i]=N),m+=Y,m+=this.spacing,I+=1}}}}Tn([x()],vh.prototype,"childControlHeight",2);Tn([x()],vh.prototype,"childControlWidth",2);Tn([x()],vh.prototype,"childForceExpandHeight",2);Tn([x()],vh.prototype,"childForceExpandWidth",2);Tn([x()],vh.prototype,"childScaleHeight",2);Tn([x()],vh.prototype,"childScaleWidth",2);class sI extends vh{get primaryAxis(){return"y"}}class rI extends vh{get primaryAxis(){return"x"}}class oI extends Kr{onCalculateLayout(){}}var Tie=Object.defineProperty,Iie=Object.getOwnPropertyDescriptor,Ka=(n,e,t,i)=>{for(var s=i>1?void 0:i?Iie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Tie(e,t,s),s},Ez=(n=>(n[n.ScreenSpaceOverlay=0]="ScreenSpaceOverlay",n[n.ScreenSpaceCamera=1]="ScreenSpaceCamera",n[n.WorldSpace=2]="WorldSpace",n[n.Undefined=-1]="Undefined",n))(Ez||{});const PS=re("debuguilayout"),Mz=class extends kA{constructor(){super(...arguments);u(this,"_renderOnTop");u(this,"_depthWrite",!1);u(this,"_doubleSided",!0);u(this,"_castShadows",!1);u(this,"_receiveShadows",!1);u(this,"_renderMode",-1);u(this,"_rootCanvas");u(this,"_scaleFactor",1);u(this,"worldCamera");u(this,"planeDistance",-1);u(this,"_boundRenderSettingsChanged",this.onRenderSettingsChanged.bind(this));u(this,"previousParent",null);u(this,"_lastMatrixWorld",null);u(this,"_rectTransforms",[]);u(this,"_layoutGroups",new Map);u(this,"onBeforeRenderRoutine",()=>{var e,t,i,s;if(this.context.isInVR){this.onUpdateRenderMode(),this.handleLayoutUpdates(),(e=this.shadowComponent)==null||e.updateMatrixWorld(!0),(t=this.shadowComponent)==null||t.updateWorldMatrix(!0,!0),qs.ensureUpdateMeshUI(CS,this.context);return}this.previousParent=this.gameObject.parent,this.renderOnTop||this.screenspace?this.gameObject.removeFromParent():(this.onUpdateRenderMode(),this.handleLayoutUpdates(),(i=this.shadowComponent)==null||i.updateMatrixWorld(!0),(s=this.shadowComponent)==null||s.updateWorldMatrix(!0,!0),qs.ensureUpdateMeshUI(CS,this.context))});u(this,"onAfterRenderRoutine",()=>{var e,t;if(!this.context.isInVR){if((this.screenspace||this.renderOnTop)&&this.previousParent&&this.context.mainCamera){if(this.screenspace){const r=this.context.mainCamera;r==null||r.add(this.gameObject)}else this.previousParent.add(this.gameObject);const i=this.context.renderer.autoClear,s=this.context.renderer.autoClearColor;this.context.renderer.autoClear=!1,this.context.renderer.autoClearColor=!1,this.context.renderer.clearDepth(),this.onUpdateRenderMode(!0),this.handleLayoutUpdates(),(e=this.shadowComponent)==null||e.updateMatrixWorld(!0),qs.ensureUpdateMeshUI(CS,this.context),this.context.renderer.render(this.gameObject,this.context.mainCamera),this.context.renderer.autoClear=i,this.context.renderer.autoClearColor=s,this.previousParent.add(this.gameObject)}(t=this._lastMatrixWorld)==null||t.copy(this.gameObject.matrixWorld)}});u(this,"_updateRenderSettingsRoutine");u(this,"_activeRenderMode",-1);u(this,"_lastWidth",-1);u(this,"_lastHeight",-1)}get isCanvas(){return!0}get screenspace(){return this.renderMode!==2}set renderOnTop(e){e!==this._renderOnTop&&(this._renderOnTop=e,this.onRenderSettingsChanged())}get renderOnTop(){return this._renderOnTop!==void 0?this._renderOnTop:!!(this.screenspace&&this._renderMode===0)}set depthWrite(e){this._depthWrite!==e&&(this._depthWrite=e,this.onRenderSettingsChanged())}get depthWrite(){return this._depthWrite}set doubleSided(e){this._doubleSided!==e&&(this._doubleSided=e,this.onRenderSettingsChanged())}get doubleSided(){return this._doubleSided}set castShadows(e){this._castShadows!==e&&(this._castShadows=e,this.onRenderSettingsChanged())}get castShadows(){return this._castShadows}set receiveShadows(e){this._receiveShadows!==e&&(this._receiveShadows=e,this.onRenderSettingsChanged())}get receiveShadows(){return this._receiveShadows}get renderMode(){return this._renderMode}set renderMode(e){this._renderMode!==e&&(this._renderMode=e,this.onRenderSettingsChanged())}set rootCanvas(e){this._rootCanvas instanceof Mz||(this._rootCanvas=e)}get rootCanvas(){return this._rootCanvas}get scaleFactor(){return this._scaleFactor}set scaleFactor(e){this._scaleFactor=e}awake(){var e;this.shadowComponent=this.gameObject,this.previousParent=this.gameObject.parent,PS&&console.log("Canvas.Awake()",((e=this.previousParent)==null?void 0:e.name)+"/"+this.gameObject.name),super.awake()}start(){this.onUpdateRenderMode()}onEnable(){super.onEnable(),this._updateRenderSettingsRoutine=void 0,this._lastMatrixWorld=new Re,this.onUpdateRenderMode(),document.addEventListener("resize",this._boundRenderSettingsChanged),this.context.pre_render_callbacks.push(this.onBeforeRenderRoutine),this.context.post_render_callbacks.push(this.onAfterRenderRoutine)}onDisable(){super.onDisable(),document.removeEventListener("resize",this._boundRenderSettingsChanged);const e=this.context.pre_render_callbacks.indexOf(this.onBeforeRenderRoutine);e!==-1&&this.context.pre_render_callbacks.splice(e,1);const t=this.context.post_render_callbacks.indexOf(this.onAfterRenderRoutine);t!==-1&&this.context.post_render_callbacks.splice(t,1)}registerTransform(e){this._rectTransforms.push(e)}unregisterTransform(e){const t=this._rectTransforms.indexOf(e);t!==-1&&this._rectTransforms.splice(t,1)}registerLayoutGroup(e){const t=e.gameObject;this._layoutGroups.set(t,e)}unregisterLayoutGroup(e){const t=e.gameObject;this._layoutGroups.delete(t)}handleLayoutUpdates(){this._lastMatrixWorld===null&&(this._lastMatrixWorld=new Re);const e=!this._lastMatrixWorld.equals(this.gameObject.matrixWorld);PS&&e&&console.log("Canvas Layout changed",this.context.time.frameCount,this.name);const t=!1;for(const i of this._rectTransforms){e&&i.markDirty();let s=this._layoutGroups.get(i.gameObject);i.isDirty&&!s&&(s=i.gameObject.getComponentInParent(Kr)),(i.isDirty||s!=null&&s.isDirty)&&(PS&&!t&&console.log("CANVAS UPDATE ### "+i.name+" ##################################### "+this.context.time.frame),s==null||s.updateLayout(),i.updateTransform())}}applyRenderSettings(){this.onRenderSettingsChanged()}onRenderSettingsChanged(){this._updateRenderSettingsRoutine||(this._updateRenderSettingsRoutine=this.startCoroutine(this._updateRenderSettingsDelayed(),xr.OnBeforeRender))}*_updateRenderSettingsDelayed(){if(yield,this._updateRenderSettingsRoutine=void 0,this.shadowComponent){this.onUpdateRenderMode(),bb(this.shadowComponent,this);for(const e of se.getComponentsInChildren(this.gameObject,ta))bb(e.shadowComponent,this)}}onUpdateRenderMode(e=!1){if(!e&&this._renderMode===this._activeRenderMode&&this._lastWidth===this.context.domWidth&&this._lastHeight===this.context.domHeight)return;this._activeRenderMode=this._renderMode;let t=this.context.mainCameraComponent,i=10;switch(t&&t.nearClipPlane>0&&t.farClipPlane>0&&(i=tt.lerp(t.nearClipPlane,t.farClipPlane,.15)),this._renderMode===1&&(this.worldCamera&&(t=this.worldCamera),this.planeDistance>0&&(i=this.planeDistance)),this._renderMode){case 0:case 1:if(this._lastWidth=this.context.domWidth,this._lastHeight=this.context.domHeight,!t)return;const s=i+.01;this.gameObject.position.x=0,this.gameObject.position.y=0,this.gameObject.position.z=-s,this.gameObject.quaternion.identity();const r=this.gameObject.getComponent(tr);let o=!1;r.sizeDelta.x!==this.context.domWidth&&(o=!0),r.sizeDelta.y!==this.context.domHeight&&(o=!0);const a=t.fieldOfView*Math.PI/180,c=2*Math.tan(a/2)*Math.abs(s);this.gameObject.scale.x=c/this.context.domHeight,this.gameObject.scale.y=c/this.context.domHeight,this.gameObject.scale.z=.01,o&&(r.sizeDelta.x=this.context.domWidth,r.sizeDelta.y=this.context.domHeight,r==null||r.markDirty());break;case 2:this._lastWidth=-1,this._lastHeight=-1;break}}};let us=Mz;Ka([x()],us.prototype,"renderOnTop",1);Ka([x()],us.prototype,"depthWrite",1);Ka([x()],us.prototype,"doubleSided",1);Ka([x()],us.prototype,"castShadows",1);Ka([x()],us.prototype,"receiveShadows",1);Ka([x()],us.prototype,"renderMode",1);Ka([x(us)],us.prototype,"rootCanvas",1);Ka([x()],us.prototype,"scaleFactor",1);Ka([x(Oi)],us.prototype,"worldCamera",2);Ka([x()],us.prototype,"planeDistance",2);var Rie=Object.defineProperty,Pie=Object.getOwnPropertyDescriptor,aI=(n,e,t,i)=>{for(var s=i>1?void 0:i?Pie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Rie(e,t,s),s};class oh extends Me{constructor(){super(...arguments);u(this,"_alpha",1);u(this,"interactable",!0);u(this,"blocksRaycasts",!0);u(this,"_isDirty",!1);u(this,"_buffer",[])}get alpha(){return this._alpha}set alpha(t){t!==this._alpha&&(this._alpha=t,this.markDirty())}get isCanvasGroup(){return!0}markDirty(){this._isDirty||(this._isDirty=!0,this.startCoroutine(this.applyChangesDelayed(),xr.OnBeforeRender))}*applyChangesDelayed(){this._isDirty=!1,this.applyChangesNow()}applyChangesNow(){for(const t of se.getComponentsInChildren(this.gameObject,ta,this._buffer)){const i=t;i.setAlphaFactor&&i.setAlphaFactor(this._alpha)}}}aI([x()],oh.prototype,"alpha",1);aI([x()],oh.prototype,"interactable",2);aI([x()],oh.prototype,"blocksRaycasts",2);var Bie=Object.defineProperty,Die=Object.getOwnPropertyDescriptor,ki=(n,e,t,i)=>{for(var s=i>1?void 0:i?Die(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Bie(e,t,s),s};class Qu extends Me{constructor(){super(...arguments);u(this,"object");u(this,"target");u(this,"duration",1);u(this,"relativeMotion",!1);u(this,"coroutine",null);u(this,"targetPos",new S);u(this,"targetRot",new Se);u(this,"targetScale",new S)}*moveToTarget(){if(!this.target||!this.object)return;const t=wt(this.object).clone(),i=wt(this.target).clone(),s=Fn(this.object).clone(),r=Fn(this.target).clone(),o=qn(this.object).clone(),a=qn(this.target).clone(),c=t.distanceTo(i),l=s.angleTo(r),h=o.distanceTo(a);if(c<.01&&l<.01&&h<.01){fn(this.object,i),_r(this.object,r),rE(this.object,a),this.coroutine=null;return}let d=0,f=0;for(;d<1;)d+=this.context.time.deltaTime/this.duration,d>1&&(d=1),f=d<.5?4*d*d*d:1-Math.pow(-2*d+2,3)/2,this.targetPos.lerpVectors(t,i,f),this.targetRot.slerpQuaternions(s,r,f),this.targetScale.lerpVectors(o,a,f),fn(this.object,this.targetPos),_r(this.object,this.targetRot),rE(this.object,this.targetScale),yield;this.coroutine=null}*moveRelative(){if(!this.target||!this.object)return;const t=this.object.position.clone(),i=this.object.quaternion.clone(),s=this.object.scale.clone(),r=this.target.position.clone(),o=this.target.quaternion.clone(),a=this.target.scale.clone();r.applyQuaternion(this.object.quaternion),this.targetPos.copy(this.object.position).add(r),this.targetRot.copy(this.object.quaternion).multiply(o),this.targetScale.copy(this.object.scale).multiply(a);let c=0,l=0;for(;c<1;)c+=this.context.time.deltaTime/this.duration,c>1&&(c=1),l=c<.5?4*c*c*c:1-Math.pow(-2*c+2,3)/2,this.object.position.lerpVectors(t,this.targetPos,l),this.object.quaternion.slerpQuaternions(i,this.targetRot,l),this.object.scale.lerpVectors(s,this.targetScale,l),yield;this.coroutine=null}onPointerClick(){this.coroutine&&this.stopCoroutine(this.coroutine),this.relativeMotion?this.coroutine=this.startCoroutine(this.moveRelative()):this.coroutine=this.startCoroutine(this.moveToTarget())}beforeCreateDocument(t){var i;if(this.target&&this.object&&this.gameObject){const s=new ls("Move to "+((i=this.target)==null?void 0:i.name),yr.tapTrigger(this.gameObject),di.transformAction(this.object,this.target,this.duration,this.relativeMotion?UE.Relative:UE.Absolute));t.addBehavior(s)}}}ki([x(Te)],Qu.prototype,"object",2);ki([x(Te)],Qu.prototype,"target",2);ki([x()],Qu.prototype,"duration",2);ki([x()],Qu.prototype,"relativeMotion",2);var qy;const vc=(qy=class extends Me{constructor(){super(...arguments);u(this,"materialToSwitch");u(this,"variantMaterial");u(this,"fadeDuration",0);u(this,"_objectsWithThisMaterial",[]);u(this,"selfModel");u(this,"targetModels")}awake(){if(this.variantMaterial&&this.materialToSwitch){const e=se.findObjectsOfType(Hi);for(const t of e)for(let i=0;i<t.sharedMaterials.length;i++){const s=t.sharedMaterials[i];if(s===this.materialToSwitch){if(t.gameObject instanceof ye)this._objectsWithThisMaterial.push(t.gameObject);else if(t.gameObject instanceof zr)for(const r of t.gameObject.children)r instanceof ye&&r.material===s&&this._objectsWithThisMaterial.push(r);break}}}}onPointerClick(){if(this.variantMaterial)for(let e=0;e<this._objectsWithThisMaterial.length;e++){const t=this._objectsWithThisMaterial[e];t.material=this.variantMaterial}}async beforeCreateDocument(e,t){this.targetModels=[],vc._materialTriggersPerId={},vc.variantSwitchIndex=0,this.materialToSwitch&&await Or.assignTextureLOD(this.context,this.sourceId,this.materialToSwitch,0),this.variantMaterial&&await Or.assignTextureLOD(this.context,this.sourceId,this.variantMaterial,0)}createBehaviours(e,t,i){this._objectsWithThisMaterial.find(r=>r.uuid===t.uuid)&&this.targetModels.push(t),this.gameObject.uuid===t.uuid&&(this.selfModel=t,this.materialToSwitch&&(vc._materialTriggersPerId[this.materialToSwitch.uuid]||(vc._materialTriggersPerId[this.materialToSwitch.uuid]=[]),vc._materialTriggersPerId[this.materialToSwitch.uuid].push(this)))}afterCreateDocument(e,t){if(!this.materialToSwitch)return;const i=vc._materialTriggersPerId[this.materialToSwitch.uuid];if(i){const s={};for(const o of i){const a=o.createVariants();a&&a.length>0&&(s[o.selfModel.uuid]=a)}const r=[];for(const o of i){for(const a in s)a!==o.selfModel.uuid&&r.push(s[a]);o.createAndAttachBehaviors(e,s[o.selfModel.uuid],r)}}delete vc._materialTriggersPerId[this.materialToSwitch.uuid]}createAndAttachBehaviors(e,t,i){const s=[],r=[],o=Math.max(0,this.fadeDuration);for(const a of this.targetModels){const c=di.fadeAction(a,o,!1);r.push(c)}for(const a of i)r.push(di.fadeAction(a,o,!1));for(const a of t)s.push(di.fadeAction(a,o,!1)),r.push(di.fadeAction(a,o,!0));e.addBehavior(new ls("Select "+this.selfModel.name,yr.tapTrigger(this.selfModel),di.parallel(...r))),e.addBehavior(new ls("Start hidden "+this.selfModel.name,yr.sceneStartTrigger(),di.parallel(...s)))}createVariants(){if(!this.variantMaterial)return null;const e=[];for(const t of this.targetModels){const i=t.clone();i.name+=" variant_"+this.variantMaterial.name+"_"+vc.variantSwitchIndex++,i.name=i.name.replace(/\s/g,"_"),i.material=this.variantMaterial,i.geometry=t.geometry,i.matrix=t.matrix,(!t.parent||!t.parent.isEmpty())&&gr.createEmptyParent(t),t.parent&&t.parent.add(i),e.push(i)}return e}},u(qy,"_materialTriggersPerId",{}),u(qy,"variantSwitchIndex",0),qy);let mp=vc;ki([x(kt)],mp.prototype,"materialToSwitch",2);ki([x(kt)],mp.prototype,"variantMaterial",2);ki([x()],mp.prototype,"fadeDuration",2);class Ap extends Me{constructor(){super(...arguments);u(this,"target");u(this,"toggleOnClick",!1);u(this,"targetState",!0);u(this,"hideSelf",!0);u(this,"selfModel");u(this,"otherModel");u(this,"toggleModel");u(this,"stateBeforeCreatingDocument",!1)}onPointerClick(){!this.toggleOnClick&&this.hideSelf&&(this.gameObject.visible=!1),this.target&&(this.target.visible=this.toggleOnClick?!this.target.visible:this.targetState)}createBehaviours(t,i,s){i.uuid===this.gameObject.uuid&&(this.selfModel=i)}beforeCreateDocument(){this.stateBeforeCreatingDocument=this.gameObject.visible,this.gameObject.visible=!0}afterCreateDocument(t,i){if(this.target){if(this.otherModel=i.document.findById(this.target.uuid),this.selfModel&&this.otherModel){let s=this.hideSelf;this.targetState,this.toggleOnClick&&(s=!0,this.target.visible,(!this.selfModel.parent||this.selfModel.parent.isEmpty())&&ON.createEmptyParent(this.selfModel),this.toggleModel=this.selfModel.clone(),this.toggleModel.name+="_toggle",this.selfModel.parent.add(this.toggleModel));const r=[];if(s&&r.push(di.fadeAction(this.selfModel,0,!1)),this.toggleModel&&r.push(di.fadeAction(this.toggleModel,0,!0)),r.push(di.fadeAction(this.otherModel,0,this.targetState)),t.addBehavior(new ls("Toggle_"+this.selfModel.name+"_hideSelf",yr.tapTrigger(this.selfModel),di.sequence(...r))),this.toggleOnClick&&this.toggleModel){const o=[];o.push(di.fadeAction(this.toggleModel,0,!1)),o.push(di.fadeAction(this.selfModel,0,!0)),o.push(di.fadeAction(this.otherModel,0,!this.targetState)),t.addBehavior(new ls("Toggle_"+this.selfModel.name+"_toggleSelf",yr.tapTrigger(this.toggleModel),di.sequence(...o))),t.addBehavior(new ls("HideOnStart_"+this.gameObject.name,yr.sceneStartTrigger(),di.fadeAction(this.toggleModel,0,!1)))}}this.gameObject.visible=this.stateBeforeCreatingDocument}}}ki([x(Te)],Ap.prototype,"target",2);ki([x()],Ap.prototype,"targetState",2);ki([x()],Ap.prototype,"hideSelf",2);class cI extends Me{start(){this.gameObject.visible=!1}createBehaviours(e,t,i){t.uuid===this.gameObject.uuid&&e.addBehavior(new ls("HideOnStart_"+this.gameObject.name,yr.sceneStartTrigger(),di.fadeAction(t,0,!1)))}beforeCreateDocument(){this.gameObject.visible=!0}afterCreateDocument(){this.gameObject.visible=!1}}class vp extends Me{constructor(){super(...arguments);u(this,"target");u(this,"duration",.5);u(this,"motionType",uT.bounce)}beforeCreateDocument(){}createBehaviours(t,i,s){if(this.target&&i.uuid===this.gameObject.uuid){const r=new ls("emphasize "+this.name,yr.tapTrigger(this.gameObject),di.emphasize(this.target,this.duration,this.motionType,void 0,"basic"));t.addBehavior(r)}}afterCreateDocument(t,i){}}ki([x()],vp.prototype,"target",2);ki([x()],vp.prototype,"duration",2);ki([x()],vp.prototype,"motionType",2);class yp extends Me{constructor(){super(...arguments);u(this,"target");u(this,"clip","");u(this,"toggleOnClick",!1)}onPointerClick(){if(!(!this.target&&!this.clip)){if(!this.target){const t=this.gameObject.addNewComponent(Cn);t&&(t.spatialBlend=1,t.volume=1,t.loop=!1,this.target=t)}this.target&&(this.target.isPlaying&&this.toggleOnClick?this.target.stop():(!this.toggleOnClick&&this.target.isPlaying&&this.target.stop(),this.clip?this.target.play(this.clip):this.target.play()))}}createBehaviours(t,i,s){if(!(!this.target&&!this.clip)&&i.uuid===this.gameObject.uuid){const r=this.clip?this.clip:this.target?this.target.clip:void 0;if(!r)return;const o=this.target?this.target.gameObject:this.gameObject,a=r.split("/").pop(),c=this.target?this.target.volume:1,l=this.target&&this.target.spatialBlend==0?NE.NonSpatial:NE.Spatial,h=new ls("playAudio "+this.name,yr.tapTrigger(this.gameObject),di.playAudioAction(o,"audio/"+a,zN.Play,c,l));t.addBehavior(h)}}async afterSerialize(t,i){if(!this.target&&!this.clip)return;const s=this.clip?this.clip:this.target?this.target.clip:void 0;if(!s)return;const r=s.split("/").pop(),c=await(await(await fetch(this.clip)).blob()).arrayBuffer(),l=new Uint8Array(c);i.files["audio/"+r]=l}}ki([x(Cn)],yp.prototype,"target",2);ki([x(URL)],yp.prototype,"clip",2);ki([x()],yp.prototype,"toggleOnClick",2);var lC;const Wd=(lC=class extends Me{constructor(){super(...arguments);u(this,"target");u(this,"animator");u(this,"stateName");u(this,"stateNameAfterPlaying");u(this,"loopAfterPlaying",!1);u(this,"selfModel");u(this,"stateAnimationModel");u(this,"stateAnimation");u(this,"stateAfterPlayingAnimationModel");u(this,"stateAfterPlayingAnimation")}onPointerClick(){var e;this.target&&this.stateName&&((e=this.animator)==null||e.play(this.stateName,0,0,.1))}createBehaviours(e,t,i){t.uuid===this.gameObject.uuid&&(this.selfModel=t)}onAfterHierarchy(){Wd.animationActions=[]}afterCreateDocument(e,t){if(!this.stateAnimation||!this.stateAnimationModel)return;t.document.traverse(s=>{var r,o;if(s.uuid===((r=this.target)==null?void 0:r.uuid)&&this.stateAnimation){const a=[];let c=Wd.animationActions.find(h=>h.affectedObjects==s&&h.start==this.stateAnimation.start&&h.duration==this.stateAnimation.duration);if(c||(c=di.startAnimationAction(s,this.stateAnimation.start,this.stateAnimation.duration),Wd.animationActions.push(c)),a.push(c),this.stateAfterPlayingAnimation&&this.stateAfterPlayingAnimationModel){let h=Wd.animationActions.find(f=>f.affectedObjects==s&&f.start==this.stateAfterPlayingAnimation.start&&f.duration==this.stateAfterPlayingAnimation.duration);h||(h=di.startAnimationAction(s,this.stateAfterPlayingAnimation.start,this.stateAfterPlayingAnimation.duration),Wd.animationActions.push(h));const d=di.sequence(h);this.loopAfterPlaying&&d.makeLooping(),a.push(d)}const l=new ls("tap "+this.name+" for "+this.stateName+" on "+((o=this.target)==null?void 0:o.name),yr.tapTrigger(this.selfModel),di.sequence(...a));e.addBehavior(l)}})}createAnimation(e,t,i){var s,r,o,a,c;if(this.target&&this.animator){const l=(r=(s=this.animator)==null?void 0:s.runtimeAnimatorController)==null?void 0:r.findState(this.stateName);if(!((o=l==null?void 0:l.motion)!=null&&o.clip)){bi()&&console.warn("No clip found for state "+this.stateName);return}this.stateAnimationModel=t,this.stateAnimation=e.registerAnimation(this.target,l==null?void 0:l.motion.clip);const h=(c=(a=this.animator)==null?void 0:a.runtimeAnimatorController)==null?void 0:c.findState(this.stateNameAfterPlaying);this.stateAfterPlayingAnimationModel=t,this.stateAfterPlayingAnimation=e.registerAnimation(this.target,h==null?void 0:h.motion.clip)}}},u(lC,"animationActions",[]),lC);let yh=Wd;ki([x(Te)],yh.prototype,"target",2);ki([x(Bs)],yh.prototype,"animator",2);ki([x()],yh.prototype,"stateName",2);ki([x()],yh.prototype,"stateNameAfterPlaying",2);ki([x()],yh.prototype,"loopAfterPlaying",2);class bp extends Me{constructor(){super(...arguments);u(this,"target")}getType(){}getDuration(){}}ki([x(Te)],bp.prototype,"target",2);class jA extends Me{constructor(){super(...arguments);u(this,"target")}}ki([x(bp)],jA.prototype,"target",2);class XA extends bp{constructor(){super(...arguments);u(this,"type",1);u(this,"duration",1)}getType(){switch(this.type){case 1:return"hide";case 0:return"show"}}getDuration(){return this.duration}}ki([x()],XA.prototype,"type",2);ki([x()],XA.prototype,"duration",2);class lI extends jA{}var Oie=Object.defineProperty,kie=Object.getOwnPropertyDescriptor,hl=(n,e,t,i)=>{for(var s=i>1?void 0:i?kie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Oie(e,t,s),s};class Wu extends Me{constructor(){super(...arguments);u(this,"center",new S(0,0,0));u(this,"radius",.5);u(this,"height",2);u(this,"_rigidbody",null);u(this,"_activeGroundCollisions")}get rigidbody(){return this._rigidbody?this._rigidbody:(this._rigidbody=this.gameObject.getComponent(Yi),this._rigidbody||(this._rigidbody=this.gameObject.addNewComponent(Yi)),this.rigidbody)}awake(){this._activeGroundCollisions=new Set}onEnable(){const t=this.rigidbody;let i=this.gameObject.getComponent(rh);i||(i=this.gameObject.addNewComponent(rh)),i.center.copy(this.center),i.radius=this.radius,i.height=this.height,this.gameObject.rotation.x=0,this.gameObject.rotation.z=0,t.lockRotationX=!0,t.lockRotationY=!0,t.lockRotationZ=!0}move(t){this.gameObject.position.add(t)}onCollisionEnter(t){for(const i of t.contacts)if(i.normal.y>.1){this._activeGroundCollisions.add(t);break}}onCollisionExit(t){this._activeGroundCollisions.delete(t)}get isGrounded(){return this._activeGroundCollisions.size>0}}hl([x(S)],Wu.prototype,"center",2);hl([x()],Wu.prototype,"radius",2);hl([x()],Wu.prototype,"height",2);class ul extends Me{constructor(){super(...arguments);u(this,"controller");u(this,"movementSpeed",2);u(this,"rotationSpeed",2);u(this,"jumpForce",1);u(this,"doubleJumpForce",2);u(this,"animator");u(this,"lookForward",!0);u(this,"lookInput",new te(0,0));u(this,"moveInput",new te(0,0));u(this,"jumpInput",!1);u(this,"_currentSpeed",new S(0,0,0));u(this,"_currentAngularSpeed",new S(0,0,0));u(this,"_temp",new S(0,0,0));u(this,"_jumpCount",0);u(this,"_currentRotation");u(this,"_raycastOptions",new sa)}awake(){this._currentRotation=new Se}update(){const t=this.context.input;t.isKeyPressed("KeyW")?this.moveInput.y+=1:t.isKeyPressed("KeyS")&&(this.moveInput.y-=1),t.isKeyPressed("KeyD")?this.lookInput.x+=1:t.isKeyPressed("KeyA")&&(this.lookInput.x-=1),this.jumpInput||(this.jumpInput=t.isKeyDown("Space"))}move(t){this.moveInput.add(t)}look(t){this.lookInput.add(t)}jump(){this.jumpInput=!0}onBeforeRender(){this.handleInput(this.moveInput,this.lookInput,this.jumpInput),this.lookInput.set(0,0),this.moveInput.set(0,0),this.jumpInput=!1}handleInput(t,i,s){var r,o,a,c,l,h,d,f,p,g,A;if((r=this.controller)!=null&&r.isGrounded&&(this._jumpCount=0,this.doubleJumpForce>0&&((o=this.animator)==null||o.setBool("doubleJump",!1))),this._currentSpeed.z+=t.y*this.movementSpeed*this.context.time.deltaTime,(a=this.animator)==null||a.setBool("running",t.length()>.01),(l=this.animator)==null||l.setBool("jumping",((c=this.controller)==null?void 0:c.isGrounded)===!0&&s),this._temp.copy(this._currentSpeed),this._temp.applyQuaternion(this.gameObject.quaternion),this.controller?this.controller.move(this._temp):this.gameObject.position.add(this._temp),this._currentAngularSpeed.y+=tt.toRadians(-i.x*this.rotationSpeed)*this.context.time.deltaTime,this.lookForward&&Math.abs(this._currentAngularSpeed.y)<.01){const v=this.context.mainCameraComponent.forward;v.y=0,v.normalize(),this._currentRotation.setFromUnitVectors(new S(0,0,1),v),this.gameObject.quaternion.slerp(this._currentRotation,this.context.time.deltaTime*10)}if(this.gameObject.rotateY(this._currentAngularSpeed.y),this._currentSpeed.multiplyScalar(1-this.context.time.deltaTime*10),this._currentAngularSpeed.y*=1-this.context.time.deltaTime*10,this.controller&&s&&this.jumpForce>0){let v=(h=this.controller)==null?void 0:h.isGrounded;if(this.doubleJumpForce>0&&!((d=this.controller)!=null&&d.isGrounded)&&this._jumpCount===1&&(v=!0,(f=this.animator)==null||f.setBool("doubleJump",!0)),v){this._jumpCount+=1;const m=this.controller.rigidbody,b=this._jumpCount===2?this.doubleJumpForce:this.jumpForce;m.applyImpulse(new S(0,1,0).multiplyScalar(b))}}if(this.controller){const v=(p=this.controller)==null?void 0:p.rigidbody.getVelocity().y;if(v<-1){this._raycastOptions.ray||(this._raycastOptions.ray=new ja),this._raycastOptions.ray.origin.copy(wt(this.gameObject)),this._raycastOptions.ray.direction.set(0,-1,0);const m=this.layer;this.gameObject.layers.disableAll(),this.gameObject.layers.set(2);const b=this.context.physics.raycast(this._raycastOptions);this.gameObject.layers.set(m),(b.length&&b[0].distance>2||v<-10)&&((g=this.animator)==null||g.setBool("falling",!0))}else(A=this.animator)==null||A.setBool("falling",!1)}}}hl([x(Wu)],ul.prototype,"controller",2);hl([x()],ul.prototype,"movementSpeed",2);hl([x()],ul.prototype,"rotationSpeed",2);hl([x()],ul.prototype,"jumpForce",2);hl([x()],ul.prototype,"doubleJumpForce",2);hl([x(Bs)],ul.prototype,"animator",2);var Lie=Object.defineProperty,Fie=Object.getOwnPropertyDescriptor,Uie=(n,e,t,i)=>{for(var s=i>1?void 0:i?Fie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Lie(e,t,s),s};class qA extends Os{constructor(){super(...arguments);u(this,"intensity")}get typeName(){return"ChromaticAberration"}init(){this.intensity.defaultValue=0}onCreateEffect(){const t=new BU;return t.offset=new te(0,0),t.radialModulation=!0,t.modulationOffset=.15,this.intensity.valueProcessor=i=>i*.02,this.intensity.onValueChanged=i=>{t.offset.x=-i,t.offset.y=i},t}}Uie([x(Rt)],qA.prototype,"intensity",2);Ro("ChromaticAberration",qA);var Nie=Object.defineProperty,zie=Object.getOwnPropertyDescriptor,gx=(n,e,t,i)=>{for(var s=i>1?void 0:i?zie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Nie(e,t,s),s};class bh extends Os{constructor(){super(...arguments);u(this,"postExposure");u(this,"contrast");u(this,"hueShift");u(this,"saturation")}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(){this.context.renderer.toneMappingExposure=1}onCreateEffect(){this.context.renderer.toneMapping===Ys&&this.postExposure.overrideState&&(this.context.renderer.toneMapping=mm);const t=new PU;this.postExposure.onValueChanged=s=>{this.context.renderer.toneMapping===Ys&&(this.context.renderer.toneMapping=mm),this.postExposure.overrideState&&(this.context.renderer.toneMappingExposure=s)},this.contrast.onValueChanged=s=>{t.contrast=s};const i=new OU;return this.hueShift.onValueChanged=s=>i.hue=s,this.saturation.onValueChanged=s=>i.saturation=s,[i,t]}}gx([x(Rt)],bh.prototype,"postExposure",2);gx([x(Rt)],bh.prototype,"contrast",2);gx([x(Rt)],bh.prototype,"hueShift",2);gx([x(Rt)],bh.prototype,"saturation",2);Ro("ColorAdjustments",bh);const Gie=(Math.sqrt(5)-1)/4,$n=(5-Math.sqrt(5))/20,Iy=n=>Math.floor(n)|0,Ry=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 Hie(n=Math.random){const e=Vie(n),t=new Float64Array(e).map(o=>Ry[o%32*4]),i=new Float64Array(e).map(o=>Ry[o%32*4+1]),s=new Float64Array(e).map(o=>Ry[o%32*4+2]),r=new Float64Array(e).map(o=>Ry[o%32*4+3]);return function(a,c,l,h){let d,f,p,g,A;const v=(a+c+l+h)*Gie,m=Iy(a+v),b=Iy(c+v),y=Iy(l+v),_=Iy(h+v),C=(m+b+y+_)*$n,M=m-C,I=b-C,R=y-C,E=_-C,T=a-M,O=c-I,K=l-R,H=h-E;let V=0,Y=0,N=0,L=0;T>O?V++:Y++,T>K?V++:N++,T>H?V++:L++,O>K?Y++:N++,O>H?Y++:L++,K>H?N++:L++;const G=V>=3?1:0,ee=Y>=3?1:0,$=N>=3?1:0,j=L>=3?1:0,ie=V>=2?1:0,Ae=Y>=2?1:0,ge=N>=2?1:0,Ce=L>=2?1:0,Ee=V>=1?1:0,Ge=Y>=1?1:0,Qe=N>=1?1:0,ht=L>=1?1:0,Mt=T-G+$n,it=O-ee+$n,W=K-$+$n,Fe=H-j+$n,me=T-ie+2*$n,Le=O-Ae+2*$n,we=K-ge+2*$n,$e=H-Ce+2*$n,Xe=T-Ee+3*$n,Ye=O-Ge+3*$n,gt=K-Qe+3*$n,Tt=H-ht+3*$n,Yt=T-1+4*$n,z=O-1+4*$n,k=K-1+4*$n,he=H-1+4*$n,Pe=m&255,Be=b&255,Ue=y&255,X=_&255;let de=.6-T*T-O*O-K*K-H*H;if(de<0)d=0;else{const ke=Pe+e[Be+e[Ue+e[X]]];de*=de,d=de*de*(t[ke]*T+i[ke]*O+s[ke]*K+r[ke]*H)}let ce=.6-Mt*Mt-it*it-W*W-Fe*Fe;if(ce<0)f=0;else{const ke=Pe+G+e[Be+ee+e[Ue+$+e[X+j]]];ce*=ce,f=ce*ce*(t[ke]*Mt+i[ke]*it+s[ke]*W+r[ke]*Fe)}let je=.6-me*me-Le*Le-we*we-$e*$e;if(je<0)p=0;else{const ke=Pe+ie+e[Be+Ae+e[Ue+ge+e[X+Ce]]];je*=je,p=je*je*(t[ke]*me+i[ke]*Le+s[ke]*we+r[ke]*$e)}let qe=.6-Xe*Xe-Ye*Ye-gt*gt-Tt*Tt;if(qe<0)g=0;else{const ke=Pe+Ee+e[Be+Ge+e[Ue+Qe+e[X+ht]]];qe*=qe,g=qe*qe*(t[ke]*Xe+i[ke]*Ye+s[ke]*gt+r[ke]*Tt)}let Ve=.6-Yt*Yt-z*z-k*k-he*he;if(Ve<0)A=0;else{const ke=Pe+1+e[Be+1+e[Ue+1+e[X+1]]];Ve*=Ve,A=Ve*Ve*(t[ke]*Yt+i[ke]*z+s[ke]*k+r[ke]*he)}return 27*(d+f+p+g+A)}}function Vie(n){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 s=i+~~(n()*(256-i)),r=t[i];t[i]=t[s],t[s]=r}for(let i=256;i<512;i++)t[i]=t[i-256];return t}var Qie=Object.defineProperty,Wie=Object.getOwnPropertyDescriptor,ne=(n,e,t,i)=>{for(var s=i>1?void 0:i?Wie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Qie(e,t,s),s};const Py=re("debugparticles");var Ta=(n=>(n[n.Billboard=0]="Billboard",n[n.Stretch=1]="Stretch",n[n.HorizontalBillboard=2]="HorizontalBillboard",n[n.VerticalBillboard=3]="VerticalBillboard",n[n.Mesh=4]="Mesh",n))(Ta||{});let _h=class{constructor(){u(this,"alphaKeys");u(this,"colorKeys")}get duration(){return 1}evaluate(e,t){let i,s=0,r=null,o=0;for(let a=0;a<this.alphaKeys.length;a++){const c=this.alphaKeys[a];(c.time<e||!i)&&(i=c,s=a)}for(let a=0;a<this.colorKeys.length;a++){const c=this.colorKeys[a];(c.time<e||!r)&&(r=c,o=a)}if(r)if(o+1<this.colorKeys.length){const c=this.colorKeys[o+1],l=tt.remap(e,r.time,c.time,0,1);t.r=tt.lerp(r.color.r,c.color.r,l),t.g=tt.lerp(r.color.g,c.color.g,l),t.b=tt.lerp(r.color.b,c.color.b,l)}else t.r=r.color.r,t.g=r.color.g,t.b=r.color.b;if(i)if(s+1<this.alphaKeys.length){const c=this.alphaKeys[s+1],l=tt.remap(e,i.time,c.time,0,1);t.alpha=tt.lerp(i.alpha,c.alpha,l)}else t.alpha=i.alpha;return t}};ne([x()],_h.prototype,"alphaKeys",2);ne([x()],_h.prototype,"colorKeys",2);var Xm=(n=>(n[n.Local=0]="Local",n[n.World=1]="World",n[n.Custom=2]="Custom",n))(Xm||{}),Tz=(n=>(n[n.Sphere=0]="Sphere",n[n.SphereShell=1]="SphereShell",n[n.Hemisphere=2]="Hemisphere",n[n.HemisphereShell=3]="HemisphereShell",n[n.Cone=4]="Cone",n[n.Box=5]="Box",n[n.Mesh=6]="Mesh",n[n.ConeShell=7]="ConeShell",n[n.ConeVolume=8]="ConeVolume",n[n.ConeVolumeShell=9]="ConeVolumeShell",n[n.Circle=10]="Circle",n[n.CircleEdge=11]="CircleEdge",n[n.SingleSidedEdge=12]="SingleSidedEdge",n[n.MeshRenderer=13]="MeshRenderer",n[n.SkinnedMeshRenderer=14]="SkinnedMeshRenderer",n[n.BoxShell=15]="BoxShell",n[n.BoxEdge=16]="BoxEdge",n[n.Donut=17]="Donut",n[n.Rectangle=18]="Rectangle",n[n.Sprite=19]="Sprite",n[n.SpriteRenderer=20]="SpriteRenderer",n))(Tz||{});class lt{constructor(){u(this,"mode");u(this,"constant");u(this,"constantMin");u(this,"constantMax");u(this,"curve");u(this,"curveMin");u(this,"curveMax");u(this,"curveMultiplier")}evaluate(e,t){const i=t===void 0?Math.random():t;switch(this.mode){case 0:return this.constant;case 1:return e=tt.clamp01(e),this.curve.evaluate(e)*this.curveMultiplier;case 2:const s=e*this.curveMin.duration,r=e*this.curveMax.duration;return tt.lerp(this.curveMin.evaluate(s),this.curveMax.evaluate(r),i%1)*this.curveMultiplier;case 3:return tt.lerp(this.constantMin,this.constantMax,i%1);default:this.curveMax.evaluate(e)*this.curveMultiplier;break}return 0}getMax(){switch(this.mode){case 0:return this.constant;case 1:return this.getMaxFromCurve(this.curve)*this.curveMultiplier;case 2:return Math.max(this.getMaxFromCurve(this.curveMin),this.getMaxFromCurve(this.curveMax))*this.curveMultiplier;case 3:return Math.max(this.constantMin,this.constantMax);default:return 0}}getMaxFromCurve(e){if(!e)return 0;let t=Number.MIN_VALUE;for(let i=0;i<e.keys.length;i++){const s=e.keys[i];s.value>t&&(t=s.value)}return t}}ne([x()],lt.prototype,"mode",2);ne([x()],lt.prototype,"constant",2);ne([x()],lt.prototype,"constantMin",2);ne([x()],lt.prototype,"constantMax",2);ne([x(Fu)],lt.prototype,"curve",2);ne([x(Fu)],lt.prototype,"curveMin",2);ne([x(Fu)],lt.prototype,"curveMax",2);ne([x()],lt.prototype,"curveMultiplier",2);var Yy;const Go=(Yy=class{constructor(){u(this,"mode");u(this,"color");u(this,"colorMin");u(this,"colorMax");u(this,"gradient");u(this,"gradientMin");u(this,"gradientMax")}evaluate(n,e){const t=e===void 0?Math.random():e;switch(this.mode){case 0:return this.color;case 1:return this.gradient.evaluate(n,Go._temp),Go._temp;case 2:return Go._temp.lerpColors(this.colorMin,this.colorMax,t);case 3:return this.gradientMin.evaluate(n,Go._temp),this.gradientMax.evaluate(n,Go._temp2),Go._temp.lerp(Go._temp2,t)}return Go._temp.set(16711935),Go._temp.alpha=1,Go._temp}},u(Yy,"_temp",new _i(0,0,0,1)),u(Yy,"_temp2",new _i(0,0,0,1)),Yy);let wr=Go;ne([x(_i)],wr.prototype,"color",2);ne([x(_i)],wr.prototype,"colorMin",2);ne([x(_i)],wr.prototype,"colorMax",2);ne([x(_h)],wr.prototype,"gradient",2);ne([x(_h)],wr.prototype,"gradientMin",2);ne([x(_h)],wr.prototype,"gradientMax",2);var JE=(n=>(n[n.Hierarchy=0]="Hierarchy",n[n.Local=1]="Local",n[n.Shape=2]="Shape",n))(JE||{});class ms{constructor(){u(this,"cullingMode");u(this,"duration");u(this,"emitterVelocityMode");u(this,"flipRotation");u(this,"gravityModifier");u(this,"gravityModifierMultiplier");u(this,"loop");u(this,"maxParticles");u(this,"playOnAwake");u(this,"prewarm");u(this,"ringBufferLoopRange");u(this,"ringBufferMode");u(this,"scalingMode");u(this,"simulationSpace");u(this,"simulationSpeed");u(this,"startColor");u(this,"startDelay");u(this,"startDelayMultiplier");u(this,"startLifetime");u(this,"startLifetimeMultiplier");u(this,"startRotation");u(this,"startRotationMultiplier");u(this,"startRotation3D");u(this,"startRotationX");u(this,"startRotationXMultiplier");u(this,"startRotationY");u(this,"startRotationYMultiplier");u(this,"startRotationZ");u(this,"startRotationZMultiplier");u(this,"startSize");u(this,"startSize3D");u(this,"startSizeMultiplier");u(this,"startSizeX");u(this,"startSizeXMultiplier");u(this,"startSizeY");u(this,"startSizeYMultiplier");u(this,"startSizeZ");u(this,"startSizeZMultiplier");u(this,"startSpeed");u(this,"startSpeedMultiplier");u(this,"stopAction");u(this,"useUnscaledTime")}}ne([x(lt)],ms.prototype,"gravityModifier",2);ne([x(wr)],ms.prototype,"startColor",2);ne([x(lt)],ms.prototype,"startDelay",2);ne([x(lt)],ms.prototype,"startLifetime",2);ne([x(lt)],ms.prototype,"startRotation",2);ne([x(lt)],ms.prototype,"startRotationX",2);ne([x(lt)],ms.prototype,"startRotationY",2);ne([x(lt)],ms.prototype,"startRotationZ",2);ne([x(lt)],ms.prototype,"startSize",2);ne([x(lt)],ms.prototype,"startSizeX",2);ne([x(lt)],ms.prototype,"startSizeY",2);ne([x(lt)],ms.prototype,"startSizeZ",2);ne([x(lt)],ms.prototype,"startSpeed",2);class qm{constructor(){u(this,"cycleCount");u(this,"maxCount");u(this,"minCount");u(this,"probability");u(this,"repeatInterval");u(this,"time");u(this,"count");u(this,"_performed",0)}reset(){this._performed=0}run(e){if(e<=this.time)return 0;let t=0;if(this.cycleCount===0||this._performed<this.cycleCount){const i=this.time+this.repeatInterval*this._performed;if(e>=i&&(this._performed+=1,Math.random()<this.probability))switch(this.count.mode){case 0:t=this.count.constant;break;case 3:t=tt.lerp(this.count.constantMin,this.count.constantMax,Math.random());break;case 1:t=this.count.curve.evaluate(Math.random());break;case 2:const s=Math.random();t=tt.lerp(this.count.curveMin.evaluate(s),this.count.curveMax.evaluate(s),Math.random());break}}return t}}class Ja{constructor(){u(this,"enabled");u(this,"bursts");u(this,"rateOverTime");u(this,"rateOverTimeMultiplier");u(this,"rateOverDistance");u(this,"rateOverDistanceMultiplier");u(this,"system")}get burstCount(){var e;return((e=this.bursts)==null?void 0:e.length)??0}reset(){var e;(e=this.bursts)==null||e.forEach(t=>t.reset())}getBurst(){let e=0;if(this.burstCount>0)for(let t=0;t<this.burstCount;t++){const i=this.bursts[t];this.system.main.loop&&i.time>=this.system.time&&i.reset(),e+=Math.round(i.run(this.system.time))}return e}}ne([x()],Ja.prototype,"enabled",2);ne([x()],Ja.prototype,"bursts",2);ne([x(lt)],Ja.prototype,"rateOverTime",2);ne([x()],Ja.prototype,"rateOverTimeMultiplier",2);ne([x(lt)],Ja.prototype,"rateOverDistance",2);ne([x()],Ja.prototype,"rateOverDistanceMultiplier",2);class YA{constructor(){u(this,"enabled");u(this,"color")}}ne([x(wr)],YA.prototype,"color",2);class xh{constructor(){u(this,"enabled");u(this,"separateAxes");u(this,"size");u(this,"sizeMultiplier");u(this,"x");u(this,"xMultiplier");u(this,"y");u(this,"yMultiplier");u(this,"z");u(this,"zMultiplier");u(this,"_time",0);u(this,"_temp",new S)}evaluate(e,t,i){if(t||(t=this._temp),!this.enabled)return t.x=t.y=t.z=1,t;if(this.separateAxes)t.x=this.x.evaluate(e,i)*this.xMultiplier,t.y=this.y.evaluate(e,i)*this.yMultiplier,t.z=this.z.evaluate(e,i)*this.zMultiplier;else{const s=this.size.evaluate(e,i)*this.sizeMultiplier;t.x=s}return t}}ne([x(lt)],xh.prototype,"size",2);ne([x(lt)],xh.prototype,"x",2);ne([x(lt)],xh.prototype,"y",2);ne([x(lt)],xh.prototype,"z",2);var Ky;const Tg=(Ky=class{constructor(){u(this,"shapeType",5);u(this,"enabled",!0);u(this,"alignToDirection",!1);u(this,"angle",0);u(this,"arc",360);u(this,"arcSpread");u(this,"arcSpeedMultiplier");u(this,"arcMode");u(this,"boxThickness");u(this,"position");u(this,"rotation");u(this,"_rotation",new Sn);u(this,"scale");u(this,"radius");u(this,"radiusThickness");u(this,"sphericalDirectionAmount");u(this,"randomDirectionAmount");u(this,"randomPositionAmount");u(this,"system");u(this,"_space");u(this,"_worldSpaceMatrix",new Re);u(this,"_worldSpaceMatrixInverse",new Re);u(this,"_vector",new S(0,0,0));u(this,"_temp",new S(0,0,0));u(this,"_dir",new S);u(this,"_loopTime",0);u(this,"_loopDirection",1);Py&&console.log(this)}get type(){return Tz[this.shapeType]}initialize(n){this.getPosition(),n.position.copy(this._vector)}toJSON(){return this}clone(){return new Tg}update(n,e,t,i){this.system=n,this._space=t,t===1&&(this._worldSpaceMatrix.copy(i.matrixWorld),this._worldSpaceMatrix.elements[0]=1,this._worldSpaceMatrix.elements[5]=1,this._worldSpaceMatrix.elements[10]=1,this._worldSpaceMatrixInverse.copy(this._worldSpaceMatrix).invert())}applyRotation(n){const e=this.rotation.x!==0||this.rotation.y!==0||this.rotation.z!==0;return e&&(this._rotation.x=tt.toRadians(this.rotation.x),this._rotation.y=tt.toRadians(this.rotation.y),this._rotation.z=tt.toRadians(this.rotation.z),this._rotation.order="ZYX",n.applyEuler(this._rotation)),e}get vector(){return this._vector}getPosition(){this._vector.set(0,0,0);const n=this._temp.copy(this.position),e=this._space===1;e&&n.applyQuaternion(this.system.worldQuaternion);let t=this.radius;if(e&&(t*=this.system.worldScale.x),this.enabled){switch(this.shapeType){case 5:Py&&Lc.DrawBox(this.position,this.scale,14540253,1),this._vector.x=Math.random()*this.scale.x-this.scale.x/2,this._vector.y=Math.random()*this.scale.y-this.scale.y/2,this._vector.z=Math.random()*this.scale.z-this.scale.z/2,this._vector.add(n);break;case 4:this.randomConePoint(this.position,this.angle,t,this.radiusThickness,this.arc,this.arcMode,this._vector);break;case 0:this.randomSpherePoint(this.position,t,this.radiusThickness,this.arc,this._vector);break;case 10:this.randomCirclePoint(this.position,t,this.radiusThickness,this.arc,this._vector);break;default:this._vector.set(0,0,0);break}this.randomizePosition(this._vector,this.randomPositionAmount)}this.applyRotation(this._vector),e&&(this._vector.applyQuaternion(this.system.worldQuaternion),this._vector.add(this.system.worldPos)),Py&&Lc.DrawSphere(this._vector,.03,16711680,.5,!0)}getDirection(n){var e;if(!this.enabled)return this._dir.set(0,0,1),this._dir;switch(this.shapeType){case 5:this._dir.set(0,0,1);break;case 4:this._dir.set(0,0,1);break;case 10:case 0:const t=n.x,i=n.y,s=n.z;this._dir.set(t,i,s),(e=this.system)!=null&&e.worldspace?this._dir.sub(this.system.worldPos):this._dir.sub(this.position);break;default:this._dir.set(0,0,1);break}return this._space===1&&this._dir.applyQuaternion(this.system.worldQuaternion),this.applyRotation(this._dir),this._dir.normalize(),this.spherizeDirection(this._dir,this.sphericalDirectionAmount),this.randomizeDirection(this._dir,this.randomDirectionAmount),Py&&(Lc.DrawSphere(n,.01,8925952,.5,!0),Lc.DrawDirection(n,this._dir,8925952,.5,!0)),this._dir}randomizePosition(n,e){if(e<=0)return;const t=Tg._tempVec;t.set(Math.random()*2-1,Math.random()*2-1,Math.random()*2-1),t.x*=e*this.scale.x,t.y*=e*this.scale.y,t.z*=e*this.scale.z,n.add(t)}randomizeDirection(n,e){if(e===0)return;const t=Tg._randomQuat,i=Tg._tempVec;i.set(Math.random()-.5,Math.random()-.5,Math.random()-.5).normalize(),t.setFromAxisAngle(i,e*Math.random()*Math.PI),n.applyQuaternion(t)}spherizeDirection(n,e){if(e===0)return;const t=Math.random()*Math.PI*2,i=Math.acos(1-Math.random()*2),s=Math.sin(i)*Math.cos(t),r=Math.sin(i)*Math.sin(t),o=Math.cos(i),a=new S(s,r,o);n.lerp(a,e)}randomSpherePoint(n,e,t,i,s){const r=Math.random(),o=Math.random(),a=2*Math.PI*r*(i/360),c=Math.acos(2*o-1),l=tt.lerp(1,1-Math.pow(1-Math.random(),Math.PI),t)*e,h=n.x+this.scale.x*(-l*Math.sin(c)*Math.cos(a)),d=n.y+this.scale.y*(l*Math.sin(c)*Math.sin(a)),f=n.z+this.scale.z*(l*Math.cos(c));s.x=h,s.y=d,s.z=f}randomCirclePoint(n,e,t,i,s){const r=Math.random(),o=2*Math.PI*r*(i/360),a=tt.lerp(1,1-Math.pow(1-Math.random(),Math.PI),t)*e,c=n.x+this.scale.x*a*Math.cos(o),l=n.y+this.scale.y*a*Math.sin(o),h=n.z;s.x=c,s.y=l,s.z=h}randomConePoint(n,e,t,i,s,r,o){let a=0,c=0;switch(r){case 0:a=Math.random(),c=Math.random();break;case 2:this._loopTime>1&&(this._loopDirection=-1),this._loopTime<0&&(this._loopDirection=1);case 1:a=.5,c=Math.random(),this._loopTime+=this.system.deltaTime*this._loopDirection;break}let l=2*Math.PI*a*(s/360);switch(r){case 2:case 1:l+=Math.PI+.5,l+=this._loopTime*Math.PI*2,l%=tt.toRadians(s);break}const h=Math.acos(2*c-1),d=tt.lerp(1,1-Math.pow(1-Math.random(),Math.PI),i)*t,f=n.x+-d*Math.sin(h)*Math.cos(l),p=n.y+d*Math.sin(h)*Math.sin(l),g=n.z;o.x=f*this.scale.x,o.y=p*this.scale.y,o.z=g*this.scale.z}},u(Ky,"_randomQuat",new Se),u(Ky,"_tempVec",new S),Ky);let mn=Tg;ne([x()],mn.prototype,"shapeType",2);ne([x()],mn.prototype,"enabled",2);ne([x()],mn.prototype,"alignToDirection",2);ne([x()],mn.prototype,"angle",2);ne([x()],mn.prototype,"arc",2);ne([x()],mn.prototype,"arcSpread",2);ne([x()],mn.prototype,"arcSpeedMultiplier",2);ne([x()],mn.prototype,"arcMode",2);ne([x(S)],mn.prototype,"boxThickness",2);ne([x(S)],mn.prototype,"position",2);ne([x(S)],mn.prototype,"rotation",2);ne([x(S)],mn.prototype,"scale",2);ne([x()],mn.prototype,"radius",2);ne([x()],mn.prototype,"radiusThickness",2);ne([x()],mn.prototype,"sphericalDirectionAmount",2);ne([x()],mn.prototype,"randomDirectionAmount",2);ne([x()],mn.prototype,"randomPositionAmount",2);class Ai{constructor(){u(this,"damping");u(this,"enabled");u(this,"frequency");u(this,"octaveCount");u(this,"octaveMultiplier");u(this,"octaveScale");u(this,"positionAmount");u(this,"quality");u(this,"remap");u(this,"remapEnabled");u(this,"remapMultiplier");u(this,"remapX");u(this,"remapXMultiplier");u(this,"remapY");u(this,"remapYMultiplier");u(this,"remapZ");u(this,"remapZMultiplier");u(this,"scrollSpeedMultiplier");u(this,"separateAxes");u(this,"strengthMultiplier");u(this,"strengthX");u(this,"strengthXMultiplier");u(this,"strengthY");u(this,"strengthYMultiplier");u(this,"strengthZ");u(this,"strengthZMultiplier");u(this,"_noise");u(this,"_time",0);u(this,"_temp",new S)}update(e){this._time+=e.time.deltaTime*this.scrollSpeedMultiplier}apply(e,t,i,s,r,o){if(!this.enabled)return;this._noise||(this._noise=Hie(()=>0));const a=this._temp.set(t.x,t.y,t.z).multiplyScalar(this.frequency),c=this._noise(a.x,a.y,a.z,this._time),l=this._noise(a.x,a.y,a.z,this._time+1e3*this.frequency),h=this._noise(a.x,a.y,a.z,this._time+2e3*this.frequency);this._temp.set(c,l,h).normalize();const d=r/o;let f=this.positionAmount.evaluate(d);this.separateAxes?(this._temp.x*=f*this.strengthXMultiplier,this._temp.y*=f*this.strengthYMultiplier,this._temp.z*=f*this.strengthZMultiplier):(this.strengthX&&(f*=this.strengthX.evaluate(d)*1.5),this._temp.multiplyScalar(f)),i.x+=this._temp.x,i.y+=this._temp.y,i.z+=this._temp.z}}ne([x()],Ai.prototype,"damping",2);ne([x()],Ai.prototype,"enabled",2);ne([x()],Ai.prototype,"frequency",2);ne([x()],Ai.prototype,"octaveCount",2);ne([x()],Ai.prototype,"octaveMultiplier",2);ne([x()],Ai.prototype,"octaveScale",2);ne([x(lt)],Ai.prototype,"positionAmount",2);ne([x()],Ai.prototype,"quality",2);ne([x(lt)],Ai.prototype,"remap",2);ne([x()],Ai.prototype,"remapEnabled",2);ne([x()],Ai.prototype,"remapMultiplier",2);ne([x(lt)],Ai.prototype,"remapX",2);ne([x()],Ai.prototype,"remapXMultiplier",2);ne([x(lt)],Ai.prototype,"remapY",2);ne([x()],Ai.prototype,"remapYMultiplier",2);ne([x(lt)],Ai.prototype,"remapZ",2);ne([x()],Ai.prototype,"remapZMultiplier",2);ne([x()],Ai.prototype,"scrollSpeedMultiplier",2);ne([x()],Ai.prototype,"separateAxes",2);ne([x()],Ai.prototype,"strengthMultiplier",2);ne([x(lt)],Ai.prototype,"strengthX",2);ne([x()],Ai.prototype,"strengthXMultiplier",2);ne([x(lt)],Ai.prototype,"strengthY",2);ne([x()],Ai.prototype,"strengthYMultiplier",2);ne([x(lt)],Ai.prototype,"strengthZ",2);ne([x()],Ai.prototype,"strengthZMultiplier",2);class Qi{constructor(){u(this,"enabled");u(this,"attachRibbonToTransform",!1);u(this,"colorOverLifetime");u(this,"colorOverTrail");u(this,"dieWithParticles",!0);u(this,"inheritParticleColor",!0);u(this,"lifetime");u(this,"lifetimeMultiplier");u(this,"minVertexDistance",.2);u(this,"mode",0);u(this,"ratio",1);u(this,"ribbonCount",1);u(this,"shadowBias",0);u(this,"sizeAffectsLifetime",!1);u(this,"sizeAffectsWidth",!1);u(this,"splitSubEmitterRibbons",!1);u(this,"textureMode",0);u(this,"widthOverTrail");u(this,"widthOverTrailMultiplier");u(this,"worldSpace",!1)}getWidth(e,t,i,s){const r=this.widthOverTrail.evaluate(i,s);return e*=r,e}getColor(e,t,i){const s=this.colorOverTrail.evaluate(i),r=this.colorOverLifetime.evaluate(t);e.x*=s.r*r.r,e.y*=s.g*r.g,e.z*=s.b*r.b,e.w*=s.alpha*r.alpha}}ne([x()],Qi.prototype,"enabled",2);ne([x()],Qi.prototype,"attachRibbonToTransform",2);ne([x(wr)],Qi.prototype,"colorOverLifetime",2);ne([x(wr)],Qi.prototype,"colorOverTrail",2);ne([x()],Qi.prototype,"dieWithParticles",2);ne([x()],Qi.prototype,"inheritParticleColor",2);ne([x(lt)],Qi.prototype,"lifetime",2);ne([x()],Qi.prototype,"lifetimeMultiplier",2);ne([x()],Qi.prototype,"minVertexDistance",2);ne([x()],Qi.prototype,"mode",2);ne([x()],Qi.prototype,"ratio",2);ne([x()],Qi.prototype,"ribbonCount",2);ne([x()],Qi.prototype,"shadowBias",2);ne([x()],Qi.prototype,"sizeAffectsLifetime",2);ne([x()],Qi.prototype,"sizeAffectsWidth",2);ne([x()],Qi.prototype,"splitSubEmitterRibbons",2);ne([x()],Qi.prototype,"textureMode",2);ne([x(lt)],Qi.prototype,"widthOverTrail",2);ne([x()],Qi.prototype,"widthOverTrailMultiplier",2);ne([x()],Qi.prototype,"worldSpace",2);class Ki{constructor(){u(this,"enabled");u(this,"space",0);u(this,"orbitalX");u(this,"orbitalY");u(this,"orbitalZ");u(this,"orbitalXMultiplier");u(this,"orbitalYMultiplier");u(this,"orbitalZMultiplier");u(this,"orbitalOffsetX");u(this,"orbitalOffsetY");u(this,"orbitalOffsetZ");u(this,"speedModifier");u(this,"speedModifierMultiplier");u(this,"x");u(this,"xMultiplier");u(this,"y");u(this,"yMultiplier");u(this,"z");u(this,"zMultiplier");u(this,"_system");u(this,"_temp",new S);u(this,"_temp2",new S);u(this,"_temp3",new S);u(this,"_hasOrbital",!1);u(this,"_index",0);u(this,"_orbitalMatrix",new Re)}update(e){this._system=e}init(e){this._index==0&&(e.debug=!0),this._index+=1,e.orbitx=this.orbitalX.evaluate(Math.random()),e.orbity=this.orbitalY.evaluate(Math.random()),e.orbitz=this.orbitalZ.evaluate(Math.random()),this._hasOrbital=e.orbitx!=0||e.orbity!=0||e.orbitz!=0}apply(e,t,i,s,r,o,a){var p;if(!this.enabled)return;const c=o/a,l=this.speedModifier.evaluate(c)*this.speedModifierMultiplier,h=this.x.evaluate(c),d=this.y.evaluate(c),f=this.z.evaluate(c);if(this._temp.set(-h,d,f),this._system&&this._system.main.simulationSpace===1&&this._temp.applyQuaternion(this._system.worldQuaternion),this._hasOrbital&&((p=this._system)==null?void 0:p.worldPos)){const A=this._temp2.set(i.x,i.y,i.z),v=this.orbitalXMultiplier,m=this.orbitalYMultiplier,b=this.orbitalZMultiplier,y=l*Math.PI*2*10,_=Math.cos(y*v),C=Math.sin(y*v),M=Math.cos(y*m),I=Math.sin(y*m),R=Math.cos(y*b),E=Math.sin(y*b),T=A.x*(M*R)+A.y*(M*E)+A.z*-I,O=A.x*(C*I*R-_*E)+A.y*(C*I*E+_*R)+A.z*(C*M),K=A.x*(_*I*R+C*E)+A.y*(_*I*E-C*R)+A.z*(_*M),H=this._temp3.set(A.x-T,A.y-O,A.z-K);H.normalize(),H.multiplyScalar(.2/r*Math.max(this.orbitalXMultiplier,this.orbitalYMultiplier,this.orbitalZMultiplier)),s.x+=H.x,s.y+=H.y,s.z+=H.z}s.x+=this._temp.x,s.y+=this._temp.y,s.z+=this._temp.z,s.x*=l,s.y*=l,s.z*=l}}ne([x()],Ki.prototype,"enabled",2);ne([x()],Ki.prototype,"space",2);ne([x(lt)],Ki.prototype,"orbitalX",2);ne([x(lt)],Ki.prototype,"orbitalY",2);ne([x(lt)],Ki.prototype,"orbitalZ",2);ne([x()],Ki.prototype,"orbitalXMultiplier",2);ne([x()],Ki.prototype,"orbitalYMultiplier",2);ne([x()],Ki.prototype,"orbitalZMultiplier",2);ne([x()],Ki.prototype,"orbitalOffsetX",2);ne([x()],Ki.prototype,"orbitalOffsetY",2);ne([x()],Ki.prototype,"orbitalOffsetZ",2);ne([x(lt)],Ki.prototype,"speedModifier",2);ne([x()],Ki.prototype,"speedModifierMultiplier",2);ne([x(lt)],Ki.prototype,"x",2);ne([x()],Ki.prototype,"xMultiplier",2);ne([x(lt)],Ki.prototype,"y",2);ne([x()],Ki.prototype,"yMultiplier",2);ne([x(lt)],Ki.prototype,"z",2);ne([x()],Ki.prototype,"zMultiplier",2);class As{constructor(){u(this,"animation");u(this,"enabled");u(this,"cycleCount");u(this,"frameOverTime");u(this,"frameOverTimeMultiplier");u(this,"numTilesX");u(this,"numTilesY");u(this,"startFrame");u(this,"startFrameMultiplier");u(this,"rowMode");u(this,"rowIndex");u(this,"spriteCount");u(this,"timeMode")}sampleOnceAtStart(){if(this.timeMode===0)switch(this.frameOverTime.mode){case 0:case 3:case 2:case 1:return!0}return!1}getStartIndex(){return this.sampleOnceAtStart()?Math.random()*(this.numTilesX*this.numTilesY):0}evaluate(e){if(!this.sampleOnceAtStart())return this.getIndex(e)}getIndex(e){const t=this.numTilesX*this.numTilesY;e=e*this.cycleCount;let i=this.frameOverTime.evaluate(e%1);return i*=this.frameOverTimeMultiplier,i*=t,i=i%t,i=Math.floor(i),i}}ne([x()],As.prototype,"animation",2);ne([x()],As.prototype,"enabled",2);ne([x()],As.prototype,"cycleCount",2);ne([x(lt)],As.prototype,"frameOverTime",2);ne([x()],As.prototype,"frameOverTimeMultiplier",2);ne([x()],As.prototype,"numTilesX",2);ne([x()],As.prototype,"numTilesY",2);ne([x(lt)],As.prototype,"startFrame",2);ne([x()],As.prototype,"startFrameMultiplier",2);ne([x()],As.prototype,"rowMode",2);ne([x()],As.prototype,"rowIndex",2);ne([x()],As.prototype,"spriteCount",2);ne([x()],As.prototype,"timeMode",2);class Po{constructor(){u(this,"enabled");u(this,"separateAxes");u(this,"x");u(this,"xMultiplier");u(this,"y");u(this,"yMultiplier");u(this,"z");u(this,"zMultiplier")}evaluate(e,t){return this.enabled?this.separateAxes?0:this.z.evaluate(e,t)*-1:0}}ne([x()],Po.prototype,"enabled",2);ne([x()],Po.prototype,"separateAxes",2);ne([x(lt)],Po.prototype,"x",2);ne([x()],Po.prototype,"xMultiplier",2);ne([x(lt)],Po.prototype,"y",2);ne([x()],Po.prototype,"yMultiplier",2);ne([x(lt)],Po.prototype,"z",2);ne([x()],Po.prototype,"zMultiplier",2);class Jr{constructor(){u(this,"enabled");u(this,"range");u(this,"separateAxes");u(this,"x");u(this,"xMultiplier");u(this,"y");u(this,"yMultiplier");u(this,"z");u(this,"zMultiplier")}evaluate(e,t){if(!this.enabled)return 0;if(!this.separateAxes){const i=tt.lerp(this.range.x,this.range.y,t);return this.z.evaluate(i)*-1}return 0}}ne([x()],Jr.prototype,"enabled",2);ne([x()],Jr.prototype,"range",2);ne([x()],Jr.prototype,"separateAxes",2);ne([x(lt)],Jr.prototype,"x",2);ne([x()],Jr.prototype,"xMultiplier",2);ne([x(lt)],Jr.prototype,"y",2);ne([x()],Jr.prototype,"yMultiplier",2);ne([x(lt)],Jr.prototype,"z",2);ne([x()],Jr.prototype,"zMultiplier",2);class In{constructor(){u(this,"enabled");u(this,"dampen");u(this,"drag");u(this,"dragMultiplier");u(this,"limit");u(this,"limitMultiplier");u(this,"separateAxes");u(this,"limitX");u(this,"limitXMultiplier");u(this,"limitY");u(this,"limitYMultiplier");u(this,"limitZ");u(this,"limitZMultiplier");u(this,"multiplyDragByParticleSize",!1);u(this,"multiplyDragByParticleVelocity",!1);u(this,"space");u(this,"_temp",new S);u(this,"_temp2",new S)}apply(e,t,i,s,r,o,a){if(this.enabled){const c=this.limit.evaluate(r)*this.limitMultiplier;if(t.length()>c){this._temp.copy(t).normalize().multiplyScalar(c);const h=this.dampen*.5;t.x=tt.lerp(t.x,this._temp.x,h),t.y=tt.lerp(t.y,this._temp.y,h),t.z=tt.lerp(t.z,this._temp.z,h),i.x=tt.lerp(i.x,this._temp.x,h),i.y=tt.lerp(i.y,this._temp.y,h),i.z=tt.lerp(i.z,this._temp.z,h)}}}}ne([x()],In.prototype,"enabled",2);ne([x()],In.prototype,"dampen",2);ne([x(lt)],In.prototype,"drag",2);ne([x()],In.prototype,"dragMultiplier",2);ne([x(lt)],In.prototype,"limit",2);ne([x()],In.prototype,"limitMultiplier",2);ne([x()],In.prototype,"separateAxes",2);ne([x(lt)],In.prototype,"limitX",2);ne([x()],In.prototype,"limitXMultiplier",2);ne([x(lt)],In.prototype,"limitY",2);ne([x()],In.prototype,"limitYMultiplier",2);ne([x(lt)],In.prototype,"limitZ",2);ne([x()],In.prototype,"limitZMultiplier",2);ne([x()],In.prototype,"multiplyDragByParticleSize",2);ne([x()],In.prototype,"multiplyDragByParticleVelocity",2);ne([x()],In.prototype,"space",2);class wh{constructor(){u(this,"enabled");u(this,"curve");u(this,"curveMultiplier");u(this,"mode");u(this,"system");u(this,"_lastWorldPosition");u(this,"_velocity",new S);u(this,"_temp",new S)}update(e){this.enabled&&this.system.worldspace!==!1&&(this._lastWorldPosition?(this._velocity.copy(this.system.worldPos).sub(this._lastWorldPosition).multiplyScalar(1/this.system.deltaTime),this._lastWorldPosition.copy(this.system.worldPos)):(this._velocity.set(0,0,0),this._lastWorldPosition=this.system.worldPos.clone()))}applyInitial(e){if(this.enabled&&this.system.worldspace!==!1&&this.mode===0){const t=this.curve.evaluate(Math.random(),Math.random());this._temp.copy(this._velocity).multiplyScalar(t),e.add(this._temp)}}applyCurrent(e,t,i){if(this.enabled&&this.system.worldspace!==!1&&this.mode===1){const s=this.curve.evaluate(t,i);this._temp.copy(this._velocity).multiplyScalar(s),e.add(this._temp)}}}ne([x()],wh.prototype,"enabled",2);ne([x(lt)],wh.prototype,"curve",2);ne([x()],wh.prototype,"curveMultiplier",2);ne([x()],wh.prototype,"mode",2);class rr{constructor(){u(this,"enabled");u(this,"range");u(this,"separateAxes");u(this,"size");u(this,"sizeMultiplier");u(this,"x");u(this,"xMultiplier");u(this,"y");u(this,"yMultiplier");u(this,"z");u(this,"zMultiplier")}evaluate(e,t,i,s){const r=e.length(),o=tt.remap(r,this.range.x,this.range.y,0,1),a=this.size.evaluate(o,i);return s*a}}ne([x()],rr.prototype,"enabled",2);ne([x(te)],rr.prototype,"range",2);ne([x()],rr.prototype,"separateAxes",2);ne([x(lt)],rr.prototype,"size",2);ne([x()],rr.prototype,"sizeMultiplier",2);ne([x(lt)],rr.prototype,"x",2);ne([x()],rr.prototype,"xMultiplier",2);ne([x(lt)],rr.prototype,"y",2);ne([x()],rr.prototype,"yMultiplier",2);ne([x(lt)],rr.prototype,"z",2);ne([x()],rr.prototype,"zMultiplier",2);class ju{constructor(){u(this,"enabled");u(this,"range");u(this,"color")}evaluate(e,t,i){const s=e.length(),r=tt.remap(s,this.range.x,this.range.y,0,1),o=this.color.evaluate(r,t);i.x*=o.r,i.y*=o.g,i.z*=o.b,i.w*=o.alpha}}ne([x()],ju.prototype,"enabled",2);ne([x(te)],ju.prototype,"range",2);ne([x(wr)],ju.prototype,"color",2);function sO(n){const e=n.domElement.shadowRoot.querySelector("link[rel='ar']");if(e)return e;const t=document.createElement("div");t.classList.add("menu"),t.classList.add("quicklook-menu"),t.style.display="none",t.style.visibility="hidden";const i=document.createElement("button");i.id="open-in-ar",i.innerText="Open in QuickLook",t.appendChild(i);const s=document.createElement("a");s.id="needle-usdz-link",s.style.display="none",s.rel="ar",s.href="",t.appendChild(s);const r=document.createElement("img");return r.id="button",s.appendChild(r),n.domElement.shadowRoot.appendChild(t),s}function jie(){var n=new Date;const e=n.getMonth()+1,t=n.getDate(),i=n.getHours(),s=n.getMinutes(),r=n.getSeconds(),o=(e<10?"0":"")+e,a=(t<10?"0":"")+t,c=(i<10?"0":"")+i,l=(s<10?"0":"")+s,h=(r<10?"0":"")+r;return n.getFullYear()+o+a+"-"+c+l+h}const By=re("debugusdz");function Xie(n,e){const t=[],i=se.getComponentsInChildren(n,Bs),s=se.getComponentsInChildren(n,Wr);let r=!1;const o=new Ks("rest",.01,[]),a=new Map,c=(l,h)=>{if(!r&&h.tracks.length>0&&(r=!0,l.push(o)),h.tracks.length>0)for(const d of h.tracks){const f=Ut.parseTrackName(d.name),p=Ut.findNode(n,f.nodeName);if(p){a.has(p)||a.set(p,[]);const g=a.get(p);switch(f.propertyName){case"position":{if(g.includes("position"))continue;const A=p.position,v=new Ar(d.name,[0,.01],[A.x,A.y,A.z,A.x,A.y,A.z]);g.push("position"),o.tracks.push(v);break}case"quaternion":{if(g.includes("quaternion"))continue;const A=p.quaternion,v=new Ar(d.name,[0,.01],[A.x,A.y,A.z,A.w,A.x,A.y,A.z,A.w]);g.push("quaternion"),o.tracks.push(v);break}case"scale":{if(g.includes("scale"))continue;const A=p.scale,v=new Ar(d.name,[0,.01],[A.x,A.y,A.z,A.x,A.y,A.z]);g.push("scale"),o.tracks.push(v);break}}}}};for(const l of i){if(!l||!l.runtimeAnimatorController)continue;By&&console.log(l);const h=[];for(const d of l.runtimeAnimatorController.enumerateActions()){By&&console.log(d);const f=d.getClip();c(h,f),h.includes(f)||h.push(f)}t.push({root:l.gameObject,clips:h})}for(const l of s){By&&console.log(l);const h=[];for(const d of l.animations)c(h,d),h.includes(d)||h.push(d);t.push({root:l.gameObject,clips:h})}By&&(console.log("Rest Pose Clip",o),console.log("USDZ Animation Clips",t));for(const l of t)for(const h of l.clips)e.registerAnimation(l.root,h)}var qie=Object.defineProperty,Yie=Object.getOwnPropertyDescriptor,dl=(n,e,t,i)=>{for(var s=i>1?void 0:i?Yie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&qie(e,t,s),s};const Gh=re("debugtext");var On=(n=>(n[n.UpperLeft=0]="UpperLeft",n[n.UpperCenter=1]="UpperCenter",n[n.UpperRight=2]="UpperRight",n[n.MiddleLeft=3]="MiddleLeft",n[n.MiddleCenter=4]="MiddleCenter",n[n.MiddleRight=5]="MiddleRight",n[n.LowerLeft=6]="LowerLeft",n[n.LowerCenter=7]="LowerCenter",n[n.LowerRight=8]="LowerRight",n))(On||{}),Iz=(n=>(n[n.Normal=0]="Normal",n[n.Bold=1]="Bold",n[n.Italic=2]="Italic",n[n.BoldAndItalic=3]="BoldAndItalic",n))(Iz||{});class or extends Hu{constructor(){super(...arguments);u(this,"alignment",0);u(this,"verticalOverflow",0);u(this,"horizontalOverflow",0);u(this,"lineSpacing",1);u(this,"supportRichText",!1);u(this,"font");u(this,"fontStyle",0);u(this,"_text","");u(this,"_fontSize",12);u(this,"_textMeshUi",null);u(this,"_didHandleTextRenderOnTop",!1)}setAlphaFactor(t){var i;super.setAlphaFactor(t),(i=this.uiObject)==null||i.set({fontOpacity:this.color.alpha*this.alphaFactor}),this.markDirty()}get text(){return this._text}set text(t){t!==this._text&&(this._text=t,this.feedText(this.text,this.supportRichText),this.markDirty())}set_text(t){this.text=t}get fontSize(){return this._fontSize}set fontSize(t){var i;this._fontSize=t,(i=this.uiObject)==null||i.set({fontSize:t})}onColorChanged(){var t;(t=this.uiObject)==null||t.set({color:this.color,fontOpacity:this.color.alpha})}onParentRectTransformChanged(){super.onParentRectTransformChanged(),this.uiObject&&this.updateOverflow()}onBeforeRender(){var t;this.uiObject&&((t=this.Canvas)!=null&&t.screenspace||this.context.isInVR)&&this.updateOverflow()}updateOverflow(){var i;const t=(i=this.uiObject)==null?void 0:i._overflow;t&&(t._needsUpdate=!0,this.markDirty())}onCreate(t){Gh&&console.log(this),this.horizontalOverflow==1&&(t.whiteSpace="pre"),this.verticalOverflow==0&&(this.context.renderer.localClippingEnabled=!0,t.overflow="hidden"),this.horizontalOverflow==1&&this.verticalOverflow==0,t.lineHeight=this.lineSpacing,delete t.backgroundOpacity,delete t.backgroundColor,Gh&&(t.backgroundColor=16750848,t.backgroundOpacity=.5);const i=this.rectTransform;t={...t,...this.getTextOpts()},this.getAlignment(t),Gh&&(t.backgroundColor=Math.random()*16777215,t.backgroundOpacity=.1),this.uiObject=i.createNewText(t),this.feedText(this.text,this.supportRichText)}onAfterAddedToScene(){super.onAfterAddedToScene(),this.handleTextRenderOnTop()}getTextOpts(){const t=this.fontSize,i={color:this.color,fontOpacity:this.color.alpha,fontSize:t,fontKerning:"normal"};return this.setFont(i,this.fontStyle),i}onEnable(){super.onEnable(),this._didHandleTextRenderOnTop=!1,this.uiObject&&this.uiObject.addAfterUpdate(()=>{this.setShadowComponentOwner(this.uiObject),this.markDirty()}),setTimeout(()=>this.markDirty(),10)}getAlignment(t){switch(t.flexDirection="column",this.alignment){case 0:case 3:case 6:t.textAlign="left";break;case 1:case 4:case 7:t.textAlign="center";break;case 2:case 5:case 8:t.textAlign="right";break}switch(this.alignment){default:case 0:case 1:case 2:t.alignItems="start";break;case 3:case 4:case 5:t.alignItems="center";break;case 6:case 7:case 8:t.alignItems="end";break}return t}feedText(t,i){var s,r,o;if(Gh&&console.log("feedText",this.uiObject,t,i),!!this.uiObject)if(this._textMeshUi||(this._textMeshUi=[]),this.uiObject.children.length=0,!i||t.length===0)this.uiObject.textContent=t;else{let a=this.getNextTag(t);if(a){if(a.startIndex>0){for(let h=this.uiObject.children.length-1;h>=0;h--){const d=this.uiObject.children[h];d.isUI&&(this.uiObject.remove(d),d.clear())}const l=new x0({textContent:t.substring(0,a.startIndex),color:"inherit"});this.uiObject.add(l)}}else{this.uiObject.textContent="",this.setOptions({textContent:t});return}const c=[];for(;a;){const l=this.getNextTag(t,a.endIndex),h={fontFamily:(s=this.uiObject)==null?void 0:s.get("fontFamily"),color:"inherit",textContent:""};if(l){h.textContent=this.getText(t,a,l),this.handleTag(a,h,c);const d=new x0(h);(r=this.uiObject)==null||r.add(d)}else{h.textContent=t.substring(a.endIndex),this.handleTag(a,h,c);const d=new x0(h);(o=this.uiObject)==null||o.add(d)}a=l}}}handleTextRenderOnTop(){this._didHandleTextRenderOnTop||(this._didHandleTextRenderOnTop=!0,this.startCoroutine(this.renderOnTopCoroutine()))}*renderOnTopCoroutine(){if(!this.canvas)return;const t=[],i=this.canvas,s={renderOnTop:i.renderOnTop,depthWrite:i.depthWrite,doubleSided:i.doubleSided};for(;;){let r=!1;if(this._textMeshUi)for(let o=0;o<this._textMeshUi.length;o++){if(t[o]===!0)continue;r=!0;const a=this._textMeshUi[o];a.textContent&&(bb(a,s),t[o]=!0)}if(!r)break;yield}}handleTag(t,i,s){if(!t.isEndTag){if(t.type.includes("color")){const r=new BS(t,{color:i.color});if(s.push(r),t.type.length>6){const o=parseInt("0x"+t.type.substring(7));i.color=o}else i.color=new _e(1,1,1)}else if(t.type=="b"){this.setFont(i,1);const r=new BS(t,{fontWeight:700});s.push(r)}else if(t.type=="i"){this.setFont(i,2);const r=new BS(t,{fontStyle:"italic"});s.push(r)}}}getText(t,i,s){return t.substring(i.endIndex,s.startIndex)}getNextTag(t,i=0){const s=t.indexOf("<",i),r=t.indexOf(">",s);if(s>=0&&r>=0){const o=t.substring(s+1,r);return{type:o,startIndex:s,endIndex:r+1,isEndTag:o.startsWith("/")}}return null}setFont(t,i){if(!this.font)return;const s=this.font,r=this.getFamilyNameWithCorrectSuffix(s,i);Gh&&console.log("Selected font family:"+r);let o=XE.getFontFamily(r);switch(o||(o=XE.addFontFamily(r)),t.fontFamily=o,i){default:case 0:t.fontWeight=400,t.fontStyle="normal";break;case 1:t.fontWeight=700,t.fontStyle="normal";break;case 2:t.fontWeight=400,t.fontStyle="italic";break;case 3:t.fontStyle="italic",t.fontWeight=400}let a=o.getVariant(t.fontWeight,t.fontStyle);if(!a){let c=r;c!=null&&c.endsWith("-msdf.json")||(c+="-msdf.json");let l=r;l!=null&&l.endsWith(".png")||(l+=".png"),a=o.addVariant(t.fontWeight,t.fontStyle,c,l),a==null||a.addEventListener("ready",()=>{this.markDirty()})}}getFamilyNameWithCorrectSuffix(t,i){var h;const s=t.lastIndexOf("-");if(s<0)return t;const r=(h=t.substring(s+1))==null?void 0:h.toLowerCase();if(Kie.includes(r))return Gh&&console.warn("Unsupported font style: "+r),t;const o=t.lastIndexOf("/");let a=t;o>=0&&(a=a.substring(o+1));const c=a[0]===a[0].toUpperCase(),l=t.substring(0,s);switch(Gh&&console.log("Select font: ",t,Iz[i],a,c,l),i){case 0:return c?l+"-Regular":l+"-regular";case 1:return c?l+"-Bold":l+"-bold";case 2:return c?l+"-Italic":l+"-italic";case 3:return c?l+"-BoldItalic":l+"-bolditalic";default:return t}}}dl([x()],or.prototype,"alignment",2);dl([x()],or.prototype,"verticalOverflow",2);dl([x()],or.prototype,"horizontalOverflow",2);dl([x()],or.prototype,"lineSpacing",2);dl([x()],or.prototype,"supportRichText",2);dl([x(URL)],or.prototype,"font",2);dl([x()],or.prototype,"fontStyle",2);dl([x()],or.prototype,"text",1);dl([x()],or.prototype,"fontSize",1);class BS{constructor(e,t){u(this,"tag");u(this,"previousValues");this.tag=e,this.previousValues=t}}const Kie=["medium","mediumitalic","black","blackitalic","thin","thinitalic","extrabold","light","lightitalic","semibold"];class Ql{constructor(e){u(this,"id");u(this,"content","");u(this,"font",[]);u(this,"pointSize",144);u(this,"width");u(this,"height");u(this,"depth");u(this,"wrapMode");u(this,"horizontalAlignment");u(this,"verticalAlignment");u(this,"material");this.id=e}static getId(){return this.global_id++}setDepth(e){return this.depth=e,this}setPointSize(e){return this.pointSize=e,this}setHorizontalAlignment(e){return this.horizontalAlignment=e,this}setVerticalAlignment(e){return this.verticalAlignment=e,this}writeTo(e,t){var s;t.beginBlock(`def Preliminary_Text "${this.id}"`),this.content&&t.appendLine(`string content = "${this.content}"`),(!this.font||this.font.length<=0)&&(this.font||(this.font=[]),(s=this.font)==null||s.push("sans-serif"));const i=this.font.map(r=>`"${r}"`).join(", ");t.appendLine(`string[] font = [ ${i} ]`),t.appendLine(`double pointSize = ${this.pointSize}`),typeof this.width=="number"&&t.appendLine(`double width = ${this.width}`),typeof this.height=="number"&&t.appendLine(`double height = ${this.height}`),typeof this.depth=="number"&&t.appendLine(`double depth = ${this.depth}`),this.wrapMode&&t.appendLine(`token wrapMode = "${this.wrapMode}"`),this.horizontalAlignment&&t.appendLine(`token horizontalAlignment = "${this.horizontalAlignment}"`),this.verticalAlignment&&t.appendLine(`token verticalAlignment = "${this.verticalAlignment}"`),this.material!==void 0&&t.appendLine(`rel material:binding = </Materials/Material_${this.material.id}>`),t.closeBlock()}}u(Ql,"global_id",0);class mx{static singleLine(e,t,i){const s=new Ql("text_"+Ql.getId());return s.content=e,t&&(s.pointSize=t),i&&(s.depth=i),s}static multiLine(e,t,i,s,r,o){const a=new Ql("text_"+Ql.getId());return a.content=e,a.width=t,a.height=i,a.horizontalAlignment=s,a.verticalAlignment=r,o!==void 0&&(a.wrapMode=o),a}}const Jie=new Re().makeRotationY(Math.PI),Zie=new Re().makeScale(-1,1,-1);class KA{get extensionName(){return"text"}onExportObject(e,t,i){}exportText(e,t,i){const s=se.getComponent(e,or);if(!s)return;const r=se.getComponent(e,tr);let o=100,a=100;r&&(o=r.width,a=r.height),t.matrix=Jie.clone(),r&&t.matrix.premultiply(Zie);const c=new _e().copySRGBToLinear(s.color);t.material=new $o({color:c,emissive:c}),t.addEventListener("serialize",(l,h)=>{let d=s.text;d=d.replace(/\n/g,"\\n");const f=mx.multiLine(d,o,a,"center","bottom","flowing");this.setTextAlignment(f,s.alignment),this.setOverflow(f,s),t.material&&(f.material=t.material),f.pointSize=this.convertToTextSize(s.fontSize),f.depth=.001,f.writeTo(void 0,l)})}convertToTextSize(e){return 1/.0502*144*e}setOverflow(e,t){t.horizontalOverflow?e.wrapMode="singleLine":e.wrapMode="flowing"}setTextAlignment(e,t){switch(t){case On.LowerLeft:case On.MiddleLeft:case On.UpperLeft:e.horizontalAlignment="left";break;case On.LowerCenter:case On.MiddleCenter:case On.UpperCenter:e.horizontalAlignment="center";break;case On.LowerRight:case On.MiddleRight:case On.UpperRight:e.horizontalAlignment="right";break}switch(t){case On.LowerLeft:case On.LowerCenter:case On.LowerRight:e.verticalAlignment="bottom";break;case On.MiddleLeft:case On.MiddleCenter:case On.MiddleRight:e.verticalAlignment="middle";break;case On.UpperLeft:case On.UpperCenter:case On.UpperRight:e.verticalAlignment="top";break}}}class Ax{get extensionName(){return"tmui"}onExportObject(e,t,i){const s=se.getComponent(e,us);if(s&&s.activeAndEnabled&&s.renderMode===Ez.WorldSpace){const r=new KA,o=se.getComponent(e,tr),a=se.getComponent(e,oh);if(o){o.width,o.height;const c=gr.createEmpty(),l=o.shadowComponent;if(t.add(c),l){const h=l.matrix;c.matrix.copy(h);const d=new Map,f=new Map;d.set(l,c),f.set(l,a?a.alpha:1),l.traverse(p=>{if(p===l)return;const g=gr.createEmpty();g.matrix.copy(p.matrix);const A=p.parent,v=A&&typeof A.textContent=="string"&&A.textContent.length;let m=f.get(A)||1;const b=se.getComponent(p,oh);if(b&&(m*=b.alpha),p instanceof ye&&v){const _=p[Ma].gameObject;r.exportText(_,g,i)}if(p instanceof ye&&!v){const _=p.geometry.clone();_.scale(1,1,-1),this.flipWindingOrder(_),g.geometry=_;const C=new _e,M=p.material.opacity;C.copy(p.material.color),g.material=new hi({color:C,opacity:M*m,map:p.material.map,transparent:!0})}d.set(p,g),f.set(p,m);const y=d.get(A);if(!y){console.error("Error when exporting UI: shadow component parent not found!",p,p.parent);return}y.add(g)})}}}}flipWindingOrder(e){const t=e.index.array;for(let i=0,s=t.length/3;i<s;i++){const r=t[i*3];t[i*3]=t[i*3+2],t[i*3+2]=r}e.index.needsUpdate=!0}}var $ie=Object.defineProperty,ene=Object.getOwnPropertyDescriptor,Zr=(n,e,t,i)=>{for(var s=i>1?void 0:i?ene(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&$ie(e,t,s),s};const Pn=re("debugusdz");class Sh{constructor(){u(this,"callToAction");u(this,"checkoutTitle");u(this,"checkoutSubtitle");u(this,"callToActionURL")}}Zr([x()],Sh.prototype,"callToAction",2);Zr([x()],Sh.prototype,"checkoutTitle",2);Zr([x()],Sh.prototype,"checkoutSubtitle",2);Zr([x()],Sh.prototype,"callToActionURL",2);class $r extends Me{constructor(){super(...arguments);u(this,"objectToExport");u(this,"autoExportAnimations",!1);u(this,"exportFileName");u(this,"customUsdzFile");u(this,"customBranding");u(this,"anchoringType","plane");u(this,"planeAnchoringAlignment","horizontal");u(this,"interactive",!0);u(this,"extensions",[]);u(this,"allowCreateQuicklookButton",!0);u(this,"link");u(this,"webxr");u(this,"onClickedOpenInARElement",t=>{t.preventDefault(),this.exportAsync()});u(this,"lastCallback");u(this,"_quicklookButton");u(this,"_quicklookButtonContainer",null)}start(){var t,i,s;Pn&&(console.log("USDZExporter",this),console.log("Debug USDZ Mode. Press 'T' to export"),window.addEventListener("keydown",r=>{switch(r.key){case"t":this.exportAsync();break}}),nl()&&setTimeout(()=>{this.exportAsync()},2e3)),this.objectToExport||(this.objectToExport=this.gameObject),!((i=(t=this.objectToExport)==null?void 0:t.children)!=null&&i.length)&&!((s=this.objectToExport)!=null&&s.isMesh)&&(this.objectToExport=this.context.scene),this.interactive&&(this.extensions.push(new dx),this.extensions.push(new hx),this.extensions.push(new KA),this.extensions.push(new Ax))}onEnable(){var s;const t=pm(),i=wc();(Pn||t&&i)&&((Pn||this.allowCreateQuicklookButton)&&this.addQuicklookButton(),this.lastCallback=this.quicklookCallback.bind(this),this.link=sO(this.context),this.link.addEventListener("message",this.lastCallback)),Pn&&_n("USDZ Exporter enabled: "+this.name),(s=document.getElementById("open-in-ar"))==null||s.addEventListener("click",this.onClickedOpenInARElement)}onDisable(){var s,r;(s=this.link)==null||s.removeEventListener("message",this.lastCallback);const t=pm(),i=wc();(Pn||t&&i)&&this.removeQuicklookButton(),Pn&&_n("USDZ Exporter disabled: "+this.name),(r=document.getElementById("open-in-ar"))==null||r.removeEventListener("click",this.onClickedOpenInARElement)}async exportAsync(){var v;let t=this.exportFileName??((v=this.objectToExport)==null?void 0:v.name)??this.name;if(pf()||(t!==""&&(t+="-"),t+="MadeWithNeedle"),t+="-"+jie(),this.link||(this.link=sO(this.context)),this.customUsdzFile){Pn&&console.log("Exporting custom usdz",this.customUsdzFile);const m=this.buildQuicklookOverlay();Pn&&console.log("QuickLook Overlay",m);const b=m.callToAction?encodeURIComponent(m.callToAction):"",y=m.checkoutTitle?encodeURIComponent(m.checkoutTitle):"",_=m.checkoutSubtitle?encodeURIComponent(m.checkoutSubtitle):"";this.link.href=this.customUsdzFile+`#callToAction=${b}&checkoutTitle=${y}&checkoutSubtitle=${_}&callToActionURL=${m.callToActionURL}`,Pn&&console.log(this.link.href),this.lastCallback||(this.lastCallback=this.quicklookCallback.bind(this),this.link.addEventListener("message",this.lastCallback)),this.link.download=t+".usdz",this.link.click();return}if(!this.objectToExport){console.warn("No object to export",this);return}const i=se.getComponentsInChildren(this.objectToExport,Hi),s=new Array;for(const m of i)for(const b of m.sharedMaterials)if(b){const y=m.loadProgressiveTextures(b);y instanceof Promise&&s.push(y)}Pn&&_n("Load textures: "+s.length),await Promise.all(s),Pn&&_n("Load textures: done");const r=Xs.Global.Mask;Xs.Global.Set(un.AR),this.applyWebARSessionRoot();const o=new X7,a=[...this.extensions],c=new W_;a.push(c),this.autoExportAnimations&&Xie(this.objectToExport,c);const l={self:this,exporter:o,extensions:a,object:this.objectToExport};this.dispatchEvent(new CustomEvent("before-export",{detail:l})),o.debug=Pn,this.anchoringType!=="plane"&&this.anchoringType!=="none"&&this.anchoringType!=="image"&&this.anchoringType!=="face"&&(this.anchoringType="plane"),this.planeAnchoringAlignment!=="horizontal"&&this.planeAnchoringAlignment!=="vertical"&&this.planeAnchoringAlignment!=="any"&&(this.planeAnchoringAlignment="horizontal");const h=await o.parse(this.objectToExport,{ar:{anchoring:{type:this.anchoringType},planeAnchoring:{alignment:this.planeAnchoringAlignment}},extensions:a,quickLookCompatible:!0}),d=new Blob([h],{type:"application/octet-stream"});this.dispatchEvent(new CustomEvent("after-export",{detail:l}));const f=this.buildQuicklookOverlay();Pn&&console.log("QuickLook Overlay",f);const p=f.callToAction?encodeURIComponent(f.callToAction):"",g=f.checkoutTitle?encodeURIComponent(f.checkoutTitle):"",A=f.checkoutSubtitle?encodeURIComponent(f.checkoutSubtitle):"";this.link.href=URL.createObjectURL(d)+`#callToAction=${p}&checkoutTitle=${g}&checkoutSubtitle=${A}&callToActionURL=${f.callToActionURL}`,this.lastCallback||(this.lastCallback=this.quicklookCallback.bind(this),this.link.addEventListener("message",this.lastCallback)),this.link.download=t+".usdz",this.link.click(),Pn&&console.log("USDZ generation done. Downloading as "+this.link.download),Xs.Global.Set(r)}quicklookCallback(t){if((t==null?void 0:t.data)=="_apple_ar_quicklook_button_tapped"){Pn&&nr("Quicklook closed via call to action button");var i=new CustomEvent("quicklook-button-tapped",{detail:this});if(this.dispatchEvent(i),!i.defaultPrevented){const s=new URLSearchParams(this.link.href);if(s){const r=s.get("callToActionURL");Pn&&_n("Quicklook url: "+r),r&&(pf()?globalThis.open(r,"_blank"):console.warn("Quicklook closed: custom redirects require a Needle Engine Pro license: https://needle.tools/pricing",r))}}}}buildQuicklookOverlay(){var s,r,o,a,c,l;const t={};return this.customBranding&&Object.assign(t,this.customBranding),pf()||(console.log("Custom Quicklook banner text requires pro license: https://needle.tools/pricing"),t.callToAction="Close",t.checkoutTitle="🌵 Made with Needle",t.checkoutSubtitle="_"),(((s=t.callToAction)==null?void 0:s.length)||((r=t.checkoutTitle)==null?void 0:r.length)||((o=t.checkoutSubtitle)==null?void 0:o.length))&&((a=t.callToAction)!=null&&a.length||(t.callToAction="\0"),(c=t.checkoutTitle)!=null&&c.length||(t.checkoutTitle="\0"),(l=t.checkoutSubtitle)!=null&&l.length||(t.checkoutSubtitle="\0")),this.dispatchEvent(new CustomEvent("quicklook-overlay",{detail:t})),t}async createQuicklookButton(){var t,i;if(!this.webxr)if(await sA(1),this.webxr=se.findObjectOfType(Et)??void 0,this.webxr)if(this.webxr.VRButton&&((t=this.webxr.VRButton.parentElement)==null||t.removeChild(this.webxr.VRButton)),this.webxr.ARButton&&this._quicklookButton!==this.webxr.ARButton){this._quicklookButton=this.webxr.ARButton;const s=(i=this.webxr.ARButton.parentElement)==null?void 0:i.querySelector("a");s&&(s.href=""),this.webxr.ARButton.innerText="Open in Quicklook",this.webxr.ARButton.disabled=!1,this.webxr.ARButton.addEventListener("click",r=>{r.preventDefault(),this.exportAsync()}),this.webxr.ARButton.classList.add("quicklook-ar-button"),this._quicklookButtonContainer=this.webxr.ARButton.parentElement,this.dispatchEvent(new CustomEvent("created-button",{detail:this.webxr.ARButton}))}else{this.webxr.createARButton=!1,this.webxr.createVRButton=!1;let s=this.context.domElement.shadowRoot.querySelector(".webxr-buttons");s||(s=document.createElement("div"),s.classList.add("webxr-buttons"));const r=document.createElement("button");r.innerText="Open in Quicklook",r.addEventListener("click",()=>{this.exportAsync()}),r.classList.add("webxr-ar-button"),r.classList.add("webxr-button"),r.classList.add("quicklook-ar-button"),this._quicklookButton=r,s.appendChild(r),this._quicklookButtonContainer=s,this.dispatchEvent(new CustomEvent("created-button",{detail:r}))}else console.warn("Could not find WebXR component: will not create Quicklook button",Nt.Current)}async addQuicklookButton(){await this.createQuicklookButton(),this._quicklookButton&&this._quicklookButtonContainer&&this._quicklookButtonContainer.appendChild(this._quicklookButton)}removeQuicklookButton(){var t;(t=this._quicklookButton)==null||t.remove()}applyWebARSessionRoot(){if(!this.objectToExport)return;let t=se.getComponentInParent(this.objectToExport,Wa);const i=t!=null;if(t||(t=se.getComponentInChildren(this.objectToExport,Wa)),Pn&&console.log("applyWebARSessionRoot",t),!t){Pn&&console.warn("No WebARSessionRoot found in parent hierarchy",this.objectToExport);return}const s=i?this.objectToExport:t.gameObject,r=1/t.arScale;Pn&&console.log("AR Session Root scale",r,s),s.matrix.makeScale(r,r,r),t.invertForward&&s.matrix.multiply(new Re().makeRotationY(Math.PI))}}Zr([x(Te)],$r.prototype,"objectToExport",2);Zr([x()],$r.prototype,"autoExportAnimations",2);Zr([x()],$r.prototype,"exportFileName",2);Zr([x(URL)],$r.prototype,"customUsdzFile",2);Zr([x(Sh)],$r.prototype,"customBranding",2);Zr([x()],$r.prototype,"anchoringType",2);Zr([x()],$r.prototype,"planeAnchoringAlignment",2);Zr([x()],$r.prototype,"interactive",2);Zr([x()],$r.prototype,"allowCreateQuicklookButton",2);const rO=re("debugdeletable");class vx extends xo{}class hI extends Me{constructor(){super(...arguments);u(this,"deleteBoxes",[])}awake(){this.deleteBoxes=se.findObjectsOfType(vx,this.context)}update(){for(const t of this.deleteBoxes){const i=this.gameObject;if(t.isInBox(i)===!0){const r=se.getComponentInParent(this.gameObject,sp);r?rO&&console.warn("Can not delete object with usage marker",this.guid,r):(rO&&console.log("DESTROY",this.gameObject),T_(this.gameObject,this.context.connection))}}}}var tne=Object.defineProperty,ine=Object.getOwnPropertyDescriptor,Xu=(n,e,t,i)=>{for(var s=i>1?void 0:i?ine(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&tne(e,t,s),s};class ca extends Os{constructor(){super(...arguments);u(this,"mode");u(this,"focusDistance");u(this,"focalLength");u(this,"aperture");u(this,"gaussianMaxRadius");u(this,"resolutionScale");u(this,"bokehScale")}get typeName(){return"DepthOfField"}init(){this.focalLength.valueProcessor=i=>{const s=i/300,r=2;return tt.lerp(r,.01,s)};const t=20;this.aperture.valueProcessor=i=>{const s=1-i/32;return tt.lerp(1,t,s)}}onCreateEffect(){if(this.mode===0)return;const t=1/window.devicePixelRatio;if(this.resolutionScale===void 0){let s=1;nl()&&(s=.6),this.resolutionScale=new Rt(s*t)}const i=new DU(this.context.mainCamera,{worldFocusRange:.2,focalLength:1,bokehScale:20,resolutionScale:this.resolutionScale.value});return this.focusDistance.onValueChanged=s=>{i.circleOfConfusionMaterial.worldFocusDistance=s},this.focalLength.onValueChanged=s=>i.circleOfConfusionMaterial.worldFocusRange=s,this.aperture.onValueChanged=s=>i.bokehScale=s,this.resolutionScale&&(this.resolutionScale.onValueChanged=s=>i.resolution.scale=s),[i]}unapply(){}}Xu([x()],ca.prototype,"mode",2);Xu([x(Rt)],ca.prototype,"focusDistance",2);Xu([x(Rt)],ca.prototype,"focalLength",2);Xu([x(Rt)],ca.prototype,"aperture",2);Xu([x(Rt)],ca.prototype,"gaussianMaxRadius",2);Xu([x(Rt)],ca.prototype,"resolutionScale",2);Xu([x(Rt)],ca.prototype,"bokehScale",2);Ro("DepthOfField",ca);var nne=Object.defineProperty,sne=Object.getOwnPropertyDescriptor,rne=(n,e,t,i)=>{for(var s=i>1?void 0:i?sne(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&nne(e,t,s),s};class yx extends Me{constructor(){super(...arguments);u(this,"visibleOn")}onEnable(){this.apply()}apply(){this.test()||se.setActive(this.gameObject,!1)}test(){return this.visibleOn<0?!0:nl()?(this.visibleOn&2)!==0:(this.visibleOn&1)!==0}}rne([x()],yx.prototype,"visibleOn",2);class uI{get extensionName(){return"DocumentExtension"}onAfterBuildDocument(e){}}var one=Object.defineProperty,ane=Object.getOwnPropertyDescriptor,Rz=(n,e,t,i)=>{for(var s=i>1?void 0:i?ane(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&one(e,t,s),s},Pz=(n=>(n.SelectStart="selectstart",n.SelectEnd="selectend",n))(Pz||{}),Jy;const Ll=(Jy=class extends np{constructor(){super();u(this,"showGizmo",!0);u(this,"useViewAngle",!0);u(this,"transformSelf",!0);u(this,"orbit",null);u(this,"selectStartEventListener",[]);u(this,"selectEndEventListener",[]);u(this,"_dragHelper",null);u(this,"_draggingRigidbodies",[]);u(this,"_waitingForDragStart",null);u(this,"_isDragging",!1);u(this,"_marker",null);u(this,"_dragDelta");u(this,"_didDrag",!1);u(this,"_activePointerId");this.selectStartEventListener=[],this.selectEndEventListener=[],this._dragDelta=new te}static get HasAnySelected(){return this._active>0}addDragEventListener(e,t){switch(e){case"selectstart":this.selectStartEventListener.push(t);break;case"selectend":this.selectEndEventListener.push(t);break}}start(){this.orbit=se.findObjectOfType(cl,this.context),this.gameObject.getComponentInParent(el)||this.gameObject.addNewComponent(el)}allowEdit(e=null){return this.context.connection.allowEditing}onPointerEnter(e){if(!this.allowEdit(this.gameObject)||Et.IsInWebXR)return;const t=se.getComponentInParent(e.object,Ll);!t||t!==this||(Ll.lastHovered=e.object,this.context.domElement.style.cursor="pointer")}onPointerExit(e){this.allowEdit(this.gameObject)&&(Et.IsInWebXR||Ll.lastHovered===e.object&&(this.context.domElement.style.cursor="auto"))}onPointerDown(e){this.allowEdit(this.gameObject)&&(Et.IsInWebXR||(Ll._active+=1,this._dragDelta.set(0,0),this._didDrag=!1,this._waitingForDragStart=e.clone(),e.stopPropagation(),this.orbit&&(this.orbit.enabled=!1)))}onPointerUp(e){this._waitingForDragStart=null,this.allowEdit(this.gameObject)&&(Ll._active>0&&(Ll._active-=1),!Et.IsInWebXR&&(this.onDragEnd(e),e.stopPropagation(),this.orbit&&(this.orbit.enabled=!0)))}update(){var e;if(!Et.IsInWebXR){if(this._waitingForDragStart){if(!this._didDrag){const i=this.context.input.getPointerPositionDelta(0);if(i&&this._dragDelta.add(i),this._dragDelta.length()>2)this._didDrag=!0;else return}const t=this._waitingForDragStart;this._waitingForDragStart=null,this.onDragStart(t)}this._dragHelper&&this._dragHelper.hasSelected&&this.onUpdateDrag(),(((e=this._dragHelper)==null?void 0:e.hasSelected)===!1||this._activePointerId!==void 0&&this.context.input.getPointerPressed(this._activePointerId)===!1)&&this.onDragEnd(null)}}onDragStart(e){if(!this._dragHelper)if(this.context.mainCamera)this._dragHelper=new C0(this.context.mainCamera);else return;if(!e||!e.object)return;const t=se.getComponentInParent(e.object,Ll);if(!t||t!==this)return;let i=e.object;this.transformSelf&&(i=this.gameObject);const s={selected:i,attached:i};for(const c of this.selectStartEventListener)c(this,s);if(this._activePointerId=e.pointerId,!s.attached)return;s.attached,i=s.attached,this._isDragging=!0,this._dragHelper.setSelected(i,this.context),this.orbit&&(this.orbit.enabled=!1);const r=se.getComponentInChildren(i,nh);r&&(r.fastMode=!0,r==null||r.requestOwnership()),this._marker=se.addNewComponent(i,sp),this._draggingRigidbodies.length=0;const o=se.getComponentsInChildren(i,Yi);o&&this._draggingRigidbodies.push(...o);const a=k0();se.invokeOnChildren(this._dragHelper.selected,a("onDragStart"))}onUpdateDrag(){if(this._dragHelper){this._dragHelper.showGizmo=this.showGizmo,this._dragHelper.useViewAngle=this.useViewAngle,this._dragHelper.onUpdate(this.context);for(const e of this._draggingRigidbodies)e.wakeUp(),e.resetVelocities()}}onDragEnd(e){if(!this||!this._isDragging||(this._isDragging=!1,!this._dragHelper))return;for(const s of this._draggingRigidbodies)s.setVelocity(s.smoothedVelocity);this._draggingRigidbodies.length=0;const t=this._dragHelper.selected;if(this._dragHelper.setSelected(null,this.context),this.orbit&&(this.orbit.enabled=!0),e!=null&&e.object){const s=se.getComponentInChildren(e.object,nh);s&&(s.fastMode=!1)}this._marker&&this._marker.destroy();for(const s of this.selectEndEventListener)s(this);const i=k0();se.invokeOnChildren(t,i("onDragEnd"))}},u(Jy,"_active",0),u(Jy,"lastHovered"),Jy);let _p=Ll;Rz([x()],_p.prototype,"showGizmo",2);Rz([x()],_p.prototype,"useViewAngle",2);const oR=class{constructor(e){u(this,"showGizmo",!0);u(this,"useViewAngle",!0);u(this,"_selected",null);u(this,"_context",null);u(this,"_camera");u(this,"_cameraPlane",new bo);u(this,"_hasGroundPlane",!1);u(this,"_groundPlane",new bo);u(this,"_groundOffset",new S);u(this,"_groundOffsetFactor",0);u(this,"_groundDistance",0);u(this,"_groundPlanePoint",new S);u(this,"_raycaster",new jf);u(this,"_cameraPlaneOffset",new S);u(this,"_intersection",new S);u(this,"_worldPosition",new S);u(this,"_inverseMatrix",new Re);u(this,"_rbs",[]);u(this,"_groundLine");u(this,"_groundMarker");u(this,"_groundOffsetVector",new S(0,1,0));u(this,"_requireUpdateGroundPlane",!0);u(this,"_didDragOnGroundPlaneLastFrame",!1);this._camera=e;const t=new hn(oR.geometry),i=t.material;i.color=new _e(.4,.4,.4),t.layers.set(2),t.name="line",t.scale.y=1,this._groundLine=t;const s=new To(.5,22,22),r=new hi({color:i.color}),o=new ye(s,r);o.visible=!1,o.layers.set(2),this._groundMarker=o}get hasSelected(){return this._selected!==null&&this._selected!==void 0}get selected(){return this._selected}setSelected(e,t){if(this._selected&&t)for(const i of this._rbs)i.wakeUp(),i.setVelocity(0,0,0);if(this._selected&&Zs.Remove(t,this._selected),this._selected=e,this._context=t,this._rbs.length=0,e?(t.scene.add(this._groundLine),t.scene.add(this._groundMarker)):(this._groundLine.removeFromParent(),this._groundMarker.removeFromParent()),this._selected){if(!t){console.error("DragHelper: no context");return}Zs.Add(t,this._selected,null),this._groundOffsetFactor=0,this._hasGroundPlane=!0,this._groundOffset.set(0,0,0),this._requireUpdateGroundPlane=!0,this.onUpdateScreenSpacePlane()}}onUpdate(e){var a,c,l,h,d;if(!this._context)return;const t="Space",i="KeyD",s=((a=this._context)==null?void 0:a.input.isKeyPressed(t))||((c=this._context)==null?void 0:c.input.isKeyPressed(i)),r=this._context.input.getTouchesPressedCount()>=2||s;if(r){const f=this._context.input.getPointerPositionDelta(0);f&&(this._groundOffsetVector.set(0,1,0),(l=this._selected)==null||l.rotateOnWorldAxis(this._groundOffsetVector,f.x*this._context.time.deltaTime))}const o=this._context.input.getPointerPositionRC(0);if(o&&(this._raycaster.setFromCamera(o,this._camera),this._selected)){this._groundOffsetVector.set(0,1,0);const f=wt(this._camera).clone().sub(wt(this._selected)).normalize(),p=Math.abs(f.dot(this._groundOffsetVector)),g=((h=this._context)==null?void 0:h.input.isKeyPressed(t))||((d=this._context)==null?void 0:d.input.isKeyPressed(i));let A=!this.useViewAngle||p>.2;(r||g||this._context.input.getPointerPressedCount()>1)&&(A=!1);const v=this._didDragOnGroundPlaneLastFrame!==A;if(this._didDragOnGroundPlaneLastFrame=A,this._hasGroundPlane||(this._requireUpdateGroundPlane=!0),(this._requireUpdateGroundPlane||!A||v)&&this.onUpdateGroundPlane(),this._requireUpdateGroundPlane=!1,this._hasGroundPlane)if(this._raycaster.ray.intersectPlane(this._groundPlane,this._intersection)){const m=this._intersection.y;if(this._groundPlanePoint.copy(this._intersection).sub(this._groundOffset),this._groundPlanePoint.y=m,A){this._groundOffsetVector.set(0,1,0);const b=this._intersection.sub(this._groundOffset).add(this._groundOffsetVector.multiplyScalar(this._groundOffsetFactor));this.onUpdateWorldPosition(b,this._groundPlanePoint,!1),this.onDidUpdate();return}}else this._groundPlanePoint.set(0,99999,0);v&&this.onUpdateScreenSpacePlane(),this._requireUpdateGroundPlane=!0,this._raycaster.ray.intersectPlane(this._cameraPlane,this._intersection)&&(this.onUpdateWorldPosition(this._intersection.sub(this._cameraPlaneOffset),this._groundPlanePoint,!0),this.onDidUpdate())}}onUpdateWorldPosition(e,t,i){if(this._selected){if(i){const s=wt(this._selected);s.y=e.y,e=s}if(fn(this._selected,e),fn(this._groundLine,e),this._hasGroundPlane?this._groundLine.scale.y=this._groundDistance:this._groundLine.scale.y=1e3,this._groundLine.visible=this.showGizmo,this._groundMarker.visible=t!==null&&this.showGizmo,t){const s=wt(this._camera).distanceTo(t)*.01;this._groundMarker.scale.set(s,s,s),fn(this._groundMarker,t)}}}onUpdateScreenSpacePlane(){if(!this._selected||!this._context)return;const e=this._context.input.getPointerPositionRC(0);e&&(this._raycaster.setFromCamera(e,this._camera),this._cameraPlane.setFromNormalAndCoplanarPoint(this._camera.getWorldDirection(this._cameraPlane.normal),this._worldPosition.setFromMatrixPosition(this._selected.matrixWorld)),this._raycaster.ray.intersectPlane(this._cameraPlane,this._intersection)&&this._selected.parent&&(this._inverseMatrix.copy(this._selected.parent.matrixWorld).invert(),this._cameraPlaneOffset.copy(this._intersection).sub(this._worldPosition.setFromMatrixPosition(this._selected.matrixWorld))))}onUpdateGroundPlane(){if(!this._selected||!this._context)return;const e=wt(this._selected),t=new ja(new S(0,.1,0).add(e),new S(0,-1,0)),i=new sa;i.ignore=[this._selected];const s=this._context.physics.raycastFromRay(t,i);for(let r=0;r<s.length;r++){const o=s[r];if(!o.face||this.contains(this._selected,o.object))continue;const a=new S(0,1,0);this._groundPlane.setFromNormalAndCoplanarPoint(a,o.point);break}this._hasGroundPlane=!0,this._groundPlane.setFromNormalAndCoplanarPoint(t.direction.multiplyScalar(-1),t.origin),this._raycaster.ray.intersectPlane(this._groundPlane,this._intersection),this._groundDistance=this._intersection.distanceTo(e),this._groundOffset.copy(this._intersection).sub(e)}onDidUpdate(){vr.markDirty(this._selected);for(const e of this._rbs)e.wakeUp(),e.resetForcesAndTorques(),e.setAngularVelocity(0,0,0)}contains(e,t){if(e===t)return!0;if(e.children){for(const i of e.children)if(this.contains(i,t))return!0}return!1}};let C0=oR;u(C0,"geometry",new vt().setFromPoints([new S(0,0,0),new S(0,-1,0)]));function dI(n,e,t){console.warn("Adding components on object has been temporarily disabled")}var Bz=(n=>(n.File_Spawned="file-spawned",n))(Bz||{});class Dz{constructor(e,t,i,s,r,o,a,c){u(this,"guid");u(this,"file_name");u(this,"file_hash");u(this,"file_size");u(this,"position");u(this,"seed");u(this,"sender");u(this,"serverUrl");u(this,"parentGuid");u(this,"boundsSize");this.seed=t,this.guid=i,this.file_name=s,this.file_hash=r,this.file_size=o,this.position=a,this.sender=e,this.serverUrl=c}}async function Oz(n,e,t){const i=n.name;return i.endsWith(".gltf")||i.endsWith(".glb")?new Promise((s,r)=>{const o=new FileReader;o.readAsArrayBuffer(n),o.onloadend=async a=>{const c=o.result,l=I_(),h=new Js(l),d=await ea().parseSync(e,c,n.name,h);if(d&&d.scene){const f=d.scene;if(!f.guid){const p=new Js(l);f.guid=p.generateUUID()}t&&cne(e.connection,n,l,f,t),dI(),s(d)}}}):(console.warn("Unsupported file type: "+i,n),null)}async function kz(n,e){return new Promise(async(t,i)=>{const s=I_(),r=new Js(s),o=n.toString(),a=await ea().loadSync(e,o,o,r);a&&a.scene?(a.scene,dI(),t(a)):console.warn("Unsupported file type: "+n.toString())})}Bi.registerCallback(Qs.ContextCreated,n=>{Lz(n.context)});function Lz(n){n.connection.beginListen("file-spawned",async e=>{if(e.sender!==n.connection.connectionId){console.log("received file event",e),lne(e,n);let t=null;try{t=await K1(e.file_name,e.file_hash,e.file_size,e.serverUrl)}finally{hne(e)}if(t){const i=new Js(e.seed),s=await ea().parseSync(n,t,e.file_name,i);if(s&&s.scene){const r=s.scene;if(dI(),e.parentGuid){const o=wA(e.parentGuid,n.scene);o&&"add"in o&&o.add(r)}r.parent||n.scene.add(r),e.position!==null&&r.position.copy(e.position)}}else console.error("download didnt return file")}})}async function cne(n,e,t,i,s){if(!n.connectionId){console.error("Can not upload file - no connection id");return}if(!i.guid){console.error("Can not upload file - no guid",i,i.guid);return}const r=await QU(e,s);if(!r)return;if(!r.filename){console.error("Can not send upload event - no filename",e.name);return}if(!r.hash){console.error("Can not send upload event - no hash",e.name);return}const o=new Dz(n.connectionId,t,i.guid,r.filename,r.hash,e.size,i.position,r.url??s);i.parent&&(o.parentGuid=i.parent.guid),n.send("file-spawned",o)}const ZE={};function lne(n,e){const t=new vi,i=new ye(t,new hi({color:65280})),s=new y_(i,5592405);if(ZE[n.guid]=s,e.scene.add(s),n.parentGuid){const r=wA(n.parentGuid,e.scene);r&&r.add(s)}n.position&&s.position.copy(n.position)}function hne(n,e){const t=n.guid,i=ZE[t];i&&(delete ZE[t],i.removeFromParent())}var une=Object.defineProperty,dne=Object.getOwnPropertyDescriptor,fI=(n,e,t,i)=>{for(var s=i>1?void 0:i?dne(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&une(e,t,s),s};const fne=re("debugnet"),$E=class extends Me{constructor(){super(...arguments);u(this,"url",null);u(this,"urlParameterName",null);u(this,"localhost",null)}awake(){fne&&console.log(this),this.context.connection.registerProvider(this)}getWebsocketUrl(){let e=this.url?$E.GetUrl(this.url,this.localhost):null;if(this.urlParameterName){const r=re(this.urlParameterName);r&&typeof r=="string"&&(e=r)}if(!e)return null;const i=new RegExp("(((https?)|(?<socket_prefix>wss?))://)?(www.)?(?<url>.+)","gm").exec(e);return i!=null&&i.groups?(i==null?void 0:i.groups.socket_prefix)?e:"wss://"+(i==null?void 0:i.groups.url):null}static GetUrl(e,t){let i=e;const s=$E.IsLocalNetwork()&&t;if(s&&(i=t),e!=null&&e.startsWith("/")){const r=s?i:window.location.origin;r!=null&&r.endsWith("/")&&e.startsWith("/")&&(e=e.substring(1)),i=r+e}return i}static IsLocalNetwork(e=window.location.hostname){return $s(e)}};let qu=$E;fI([x()],qu.prototype,"url",2);fI([x()],qu.prototype,"urlParameterName",2);fI([x()],qu.prototype,"localhost",2);var pne=Object.defineProperty,gne=Object.getOwnPropertyDescriptor,Fz=(n,e,t,i)=>{for(var s=i>1?void 0:i?gne(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&pne(e,t,s),s};const Od=re("debugdroplistener");class JA extends Me{constructor(){super(...arguments);u(this,"filesBackendUrl");u(this,"localhost");u(this,"onDrag",t=>{t.preventDefault()});u(this,"onDrop",async t=>{if(Od&&console.log(t),!(t!=null&&t.dataTransfer))return;t.preventDefault();const i=t.dataTransfer.items;if(i)for(const s in i){const r=i[s];if(r.kind==="file"){const o=r.getAsFile();if(!o)continue;await this.addFiles(o)}else r.kind==="string"&&r.type=="text/plain"&&r.getAsString(async o=>{Od&&console.log("dropped url",o);try{const a=new URL(o);if(!a)return;const c=await kz(a,this.context);c&&this.addObject(t,c)}catch{console.log("dropped string is not a valid URL!",o)}})}})}onEnable(){this.filesBackendUrl=qu.GetUrl(this.filesBackendUrl,this.localhost)??this.filesBackendUrl,Od&&console.log(this,this.filesBackendUrl),this.context.domElement.addEventListener("dragover",this.onDrag),this.context.domElement.addEventListener("drop",this.onDrop)}onDisable(){this.context.domElement.removeEventListener("dragover",this.onDrag),this.context.domElement.removeEventListener("drop",this.onDrop)}async addFiles(...t){if(Od&&console.log("Add files",t),!!Array.isArray(t)&&t.length)for(const i of t){if(!i)continue;Od&&console.log("Register file "+i.name+" to",this.filesBackendUrl,i);const s=await Oz(i,this.context,this.filesBackendUrl);this.dispatchEvent(new CustomEvent("file-dropped",{detail:i})),s&&this.addObject(void 0,s)}}async addObject(t,i){if(Od&&console.log("Dropped",i),!(i!=null&&i.scene)){console.warn("No object specified to add to scene",i);return}const s=i.scene;if(t!==void 0){const r=new sa;r.setMask(16777215),r.screenPointFromOffset(t.offsetX,t.offsetY);const o=this.context.physics.raycast(r);if(o&&o.length>0)for(const a of o){s.position.copy(a.point);break}}this.gameObject.add(s),this.dispatchEvent(new CustomEvent("object-added",{detail:i}))}}Fz([x()],JA.prototype,"filesBackendUrl",2);Fz([x()],JA.prototype,"localhost",2);var mne=Object.defineProperty,Ane=Object.getOwnPropertyDescriptor,bx=(n,e,t,i)=>{for(var s=i>1?void 0:i?Ane(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&mne(e,t,s),s};class Yu extends np{constructor(){super(...arguments);u(this,"parent",null);u(this,"object",null);u(this,"limitCount",10);u(this,"limitInterval",60);u(this,"_currentCount",0);u(this,"_startPosition",null);u(this,"_startQuaternion",null)}awake(){var i,s;if(this.object){if(this.object===this.gameObject){console.error("Can not duplicate self");return}this.object.visible=!1,this._startPosition=((i=this.object.position)==null?void 0:i.clone())??new S(0,0,0),this._startQuaternion=((s=this.object.quaternion)==null?void 0:s.clone())??new Se(0,0,0,1)}const t=se.getComponentInParent(this.gameObject,_p);t?t.addDragEventListener(Pz.SelectStart,(r,o)=>{if(this._currentCount>=this.limitCount){o.attached=null;return}const a=this.handleDuplication(o.selected);a&&(console.assert(a!==o.selected,"Duplicated object is original"),o.attached=a)}):console.warn("Could no find drag controls in parent",this.name),en.addEventListener(_c.SelectStart,(r,o)=>{if(this._currentCount>=this.limitCount){o.grab=null;return}const a=this.handleDuplication(o.selected);a&&(o.grab=a)}),this.cloneLimitIntervalFn()}cloneLimitIntervalFn(){this.destroyed||(this._currentCount>0&&(this._currentCount-=1),setTimeout(()=>{this.cloneLimitIntervalFn()},this.limitInterval/this.limitCount*1e3))}handleDuplication(t){var i;if(this._currentCount>=this.limitCount||!this.object)return null;if(t===this.gameObject||this.handleMultiObject(t)){if(this.object===this.gameObject)return null;this.object.visible=!0,this._startPosition&&this.object.position.copy(this._startPosition),this._startQuaternion&&this.object.quaternion.copy(this._startQuaternion);const s=new Qa;this.parent||(this.parent=this.gameObject.parent),this.parent&&(s.parent=this.parent.guid??((i=this.parent.userData)==null?void 0:i.guid),s.keepWorldPosition=!0),s.position=this.worldPosition,s.rotation=this.worldQuaternion,s.context=this.context,this._currentCount+=1;const r=se.instantiateSynced(this.object,s);return console.assert(r!==this.object,"Duplicated object is original"),this.object.visible=!1,this._startPosition&&this.object.position.clone().copy(this._startPosition),this._startQuaternion&&this.object.quaternion.clone().copy(this._startQuaternion),r}return null}handleMultiObject(t){return this.gameObject.type==="Group"||this.gameObject.type==="Object3D"?this.isInChildren(this.gameObject,t):!1}isInChildren(t,i){if(!t)return!1;if(t===i)return!0;if(t.children){for(const s of t.children)if(this.isInChildren(s,i))return!0}return!1}}bx([x(Te)],Yu.prototype,"parent",2);bx([x(Te)],Yu.prototype,"object",2);bx([x()],Yu.prototype,"limitCount",2);bx([x()],Yu.prototype,"limitInterval",2);var jd=(n=>(n[n.PointerEnter=0]="PointerEnter",n[n.PointerExit=1]="PointerExit",n[n.PointerDown=2]="PointerDown",n[n.PointerUp=3]="PointerUp",n[n.PointerClick=4]="PointerClick",n[n.Drag=5]="Drag",n[n.Drop=6]="Drop",n[n.Scroll=7]="Scroll",n[n.UpdateSelected=8]="UpdateSelected",n[n.Select=9]="Select",n[n.Deselect=10]="Deselect",n[n.Move=11]="Move",n[n.InitializePotentialDrag=12]="InitializePotentialDrag",n[n.BeginDrag=13]="BeginDrag",n[n.EndDrag=14]="EndDrag",n[n.Submit=15]="Submit",n[n.Cancel=16]="Cancel",n))(jd||{}),vne=Object.defineProperty,yne=Object.getOwnPropertyDescriptor,pI=(n,e,t,i)=>{for(var s=i>1?void 0:i?yne(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&vne(e,t,s),s};class gI{constructor(){u(this,"eventID");u(this,"callback")}}pI([x()],gI.prototype,"eventID",2);pI([x(cs)],gI.prototype,"callback",2);class _x extends Me{constructor(){super(...arguments);u(this,"triggers")}invoke(t){if(this.triggers)for(const i of this.triggers)i.eventID===t&&i.callback.invoke()}onPointerClick(t){this.invoke(jd.PointerClick)}onPointerEnter(t){this.invoke(jd.PointerEnter)}onPointerExit(t){this.invoke(jd.PointerExit)}onPointerDown(t){this.invoke(jd.PointerDown)}onPointerUp(t){this.invoke(jd.PointerUp)}}pI([x(gI)],_x.prototype,"triggers",2);var bne=Object.defineProperty,_ne=Object.getOwnPropertyDescriptor,mI=(n,e,t,i)=>{for(var s=i>1?void 0:i?_ne(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&bne(e,t,s),s};class AI extends Me{constructor(){super(...arguments);u(this,"connectedBody");u(this,"_rigidBody",null)}get rigidBody(){return this._rigidBody}onEnable(){this._rigidBody||(this._rigidBody=this.gameObject.getComponent(Yi)),this.rigidBody&&this.connectedBody&&this.startCoroutine(this.create())}*create(){yield,this.rigidBody&&this.connectedBody&&this.createJoint(this.rigidBody,this.connectedBody)}}mI([x(Yi)],AI.prototype,"connectedBody",2);class vI extends AI{createJoint(e,t){var i;(i=this.context.physics.engine)==null||i.addFixedJoint(e,t)}}class ZA extends AI{constructor(){super(...arguments);u(this,"anchor");u(this,"axis")}createJoint(t,i){var s;this.axis&&this.anchor&&((s=this.context.physics.engine)==null||s.addHingeJoint(t,i,this.anchor,this.axis))}}mI([x(S)],ZA.prototype,"anchor",2);mI([x(S)],ZA.prototype,"axis",2);const xne={type:"change"};let wne=class extends Gn{constructor(e,t){super(),this.object=e,this.domElement=t,this.enabled=!0,this.movementSpeed=1,this.rollSpeed=.005,this.dragToLook=!1,this.autoForward=!1;const i=this,s=1e-6,r=new Se,o=new S;this.tmpQuaternion=new Se,this.status=0,this.moveState={up:0,down:0,left:0,right:0,forward:0,back:0,pitchUp:0,pitchDown:0,yawLeft:0,yawRight:0,rollLeft:0,rollRight:0},this.moveVector=new S(0,0,0),this.rotationVector=new S(0,0,0),this.keydown=function(p){if(!(p.altKey||this.enabled===!1)){switch(p.code){case"ShiftLeft":case"ShiftRight":this.movementSpeedMultiplier=.1;break;case"KeyW":this.moveState.forward=1;break;case"KeyS":this.moveState.back=1;break;case"KeyA":this.moveState.left=1;break;case"KeyD":this.moveState.right=1;break;case"KeyR":this.moveState.up=1;break;case"KeyF":this.moveState.down=1;break;case"ArrowUp":this.moveState.pitchUp=1;break;case"ArrowDown":this.moveState.pitchDown=1;break;case"ArrowLeft":this.moveState.yawLeft=1;break;case"ArrowRight":this.moveState.yawRight=1;break;case"KeyQ":this.moveState.rollLeft=1;break;case"KeyE":this.moveState.rollRight=1;break}this.updateMovementVector(),this.updateRotationVector()}},this.keyup=function(p){if(this.enabled!==!1){switch(p.code){case"ShiftLeft":case"ShiftRight":this.movementSpeedMultiplier=1;break;case"KeyW":this.moveState.forward=0;break;case"KeyS":this.moveState.back=0;break;case"KeyA":this.moveState.left=0;break;case"KeyD":this.moveState.right=0;break;case"KeyR":this.moveState.up=0;break;case"KeyF":this.moveState.down=0;break;case"ArrowUp":this.moveState.pitchUp=0;break;case"ArrowDown":this.moveState.pitchDown=0;break;case"ArrowLeft":this.moveState.yawLeft=0;break;case"ArrowRight":this.moveState.yawRight=0;break;case"KeyQ":this.moveState.rollLeft=0;break;case"KeyE":this.moveState.rollRight=0;break}this.updateMovementVector(),this.updateRotationVector()}},this.pointerdown=function(p){if(this.enabled!==!1)if(this.dragToLook)this.status++;else{switch(p.button){case 0:this.moveState.forward=1;break;case 2:this.moveState.back=1;break}this.updateMovementVector()}},this.pointermove=function(p){if(this.enabled!==!1&&(!this.dragToLook||this.status>0)){const g=this.getContainerDimensions(),A=g.size[0]/2,v=g.size[1]/2;this.moveState.yawLeft=-(p.pageX-g.offset[0]-A)/A,this.moveState.pitchDown=(p.pageY-g.offset[1]-v)/v,this.updateRotationVector()}},this.pointerup=function(p){if(this.enabled!==!1){if(this.dragToLook)this.status--,this.moveState.yawLeft=this.moveState.pitchDown=0;else{switch(p.button){case 0:this.moveState.forward=0;break;case 2:this.moveState.back=0;break}this.updateMovementVector()}this.updateRotationVector()}},this.contextMenu=function(p){this.enabled!==!1&&p.preventDefault()},this.update=function(p){if(this.enabled===!1)return;const g=p*i.movementSpeed,A=p*i.rollSpeed;i.object.translateX(i.moveVector.x*g),i.object.translateY(i.moveVector.y*g),i.object.translateZ(i.moveVector.z*g),i.tmpQuaternion.set(i.rotationVector.x*A,i.rotationVector.y*A,i.rotationVector.z*A,1).normalize(),i.object.quaternion.multiply(i.tmpQuaternion),(o.distanceToSquared(i.object.position)>s||8*(1-r.dot(i.object.quaternion))>s)&&(i.dispatchEvent(xne),r.copy(i.object.quaternion),o.copy(i.object.position))},this.updateMovementVector=function(){const p=this.moveState.forward||this.autoForward&&!this.moveState.back?1:0;this.moveVector.x=-this.moveState.left+this.moveState.right,this.moveVector.y=-this.moveState.down+this.moveState.up,this.moveVector.z=-p+this.moveState.back},this.updateRotationVector=function(){this.rotationVector.x=-this.moveState.pitchDown+this.moveState.pitchUp,this.rotationVector.y=-this.moveState.yawRight+this.moveState.yawLeft,this.rotationVector.z=-this.moveState.rollRight+this.moveState.rollLeft},this.getContainerDimensions=function(){return this.domElement!=document?{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}:{size:[window.innerWidth,window.innerHeight],offset:[0,0]}},this.dispose=function(){this.domElement.removeEventListener("contextmenu",a),this.domElement.removeEventListener("pointerdown",l),this.domElement.removeEventListener("pointermove",c),this.domElement.removeEventListener("pointerup",h),window.removeEventListener("keydown",d),window.removeEventListener("keyup",f)};const a=this.contextMenu.bind(this),c=this.pointermove.bind(this),l=this.pointerdown.bind(this),h=this.pointerup.bind(this),d=this.keydown.bind(this),f=this.keyup.bind(this);this.domElement.addEventListener("contextmenu",a),this.domElement.addEventListener("pointerdown",l),this.domElement.addEventListener("pointermove",c),this.domElement.addEventListener("pointerup",h),window.addEventListener("keydown",d),window.addEventListener("keyup",f),this.updateMovementVector(),this.updateRotationVector()}};class yI extends Me{constructor(){super(...arguments);u(this,"_controls",null)}onEnable(){var i;const t=(i=se.getComponent(this.gameObject,Oi))==null?void 0:i.cam;if(!t){console.warn("FlyControls: Requires a Camera component on the same object as this component.");return}this._controls=new wne(t,this.context.renderer.domElement),this._controls.rollSpeed=.5,this._controls.movementSpeed=3,this._controls.dragToLook=!0}onDisable(){var t;(t=this._controls)==null||t.dispose(),this._controls=null}update(){this._controls&&this._controls.update(this.context.time.deltaTime)}}var Sne=Object.defineProperty,Cne=Object.getOwnPropertyDescriptor,bI=(n,e,t,i)=>{for(var s=i>1?void 0:i?Cne(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Sne(e,t,s),s};class xp extends Me{constructor(){super(...arguments);u(this,"_fog")}get fog(){return this._fog||(this._fog=new JM(0,0,50)),this._fog}get mode(){return 1}set near(t){this.fog.near=t}get near(){return this.fog.near}set far(t){this.fog.far=t}get far(){return this.fog.far}set color(t){this.fog.color.copy(t)}get color(){return this.fog.color}onEnable(){this.scene.fog=this.fog}onDisable(){this.scene.fog===this._fog&&(this.scene.fog=null)}}bI([x()],xp.prototype,"near",1);bI([x()],xp.prototype,"far",1);bI([x(_e)],xp.prototype,"color",1);let Dy,DS,kd,Oy;function OS(n,e=1/0,t=null){DS||(DS=new ds(2,2,1,1)),kd||(kd=new Lt({uniforms:{blitTexture:new xe(n)},vertexShader:`
|
|
5055
5073
|
varying vec2 vUv;
|
|
5056
5074
|
void main(){
|
|
5057
5075
|
vUv = uv;
|
|
@@ -6591,4 +6609,4 @@ This could mean you forgot to add a npmdef to your ExportInfo
|
|
|
6591
6609
|
<div class="content">
|
|
6592
6610
|
<slot class="overlay-content"></slot>
|
|
6593
6611
|
</div>
|
|
6594
|
-
`,this.shadowRoot&&this.shadowRoot.appendChild(t.content.cloneNode(!0)),this._context=new Nt({domElement:this}),this.addEventListener("error",this.onError)}static get observedAttributes(){return rce}get loadingProgress01(){return this._loadingProgress01}get loadingFinished(){return this.loadingProgress01>.999}get cameraControls(){const t=this.getAttribute("camera-controls");return!(t===null||t==="False"||t==="false"||t==="0")}getContext(){return new Promise((t,i)=>{if(this._context&&this.loadingFinished)t(this._context);else{const s=()=>{this.removeEventListener("loadfinished",s),this._context&&this.loadingFinished&&t(this._context)};this.addEventListener("loadfinished",s)}})}get context(){return this._context}get Context(){return this._context}async connectedCallback(){if(ts&&console.log("<needle-engine> connected"),this.onSetupDesktop(),!this.getAttribute("src")){const i=globalThis["needle:codegen_files"];i&&(ts&&console.log('globalThis["needle:codegen_files"]',i),this.setAttribute("src",i))}const t=this._loadId;setTimeout(()=>{this.isConnected!==!1&&t===this._loadId&&this.onLoad()},1),kc!=null&&kc.length&&this.setAttribute("version",kc)}disconnectedCallback(){var i;this._didFullyLoad=!1;const t=this.getAttribute("keep-alive");ts&&console.warn("<needle-engine> disconnected, keep-alive:",t),(t===void 0||t!=="true")&&(console.warn("<needle-engine> dispose!"),(i=this._context)==null||i.dispose(),this._context=null,this._lastSourceFiles=null,this._loadId+=1)}attributeChangedCallback(t,i,s){switch(ts&&console.log("attributeChangedCallback",t,i,s),t){case"src":ts&&console.warn("src changed to type:",typeof s,', from "',i,'" to "',s,'"'),this.onLoad();break;case"hash":this._context&&(this._context.hash=s);break;case"loadstart":case"progress":case"loadfinished":typeof s=="string"&&s.length>0&&(ts&&console.log(t+" attribute changed",s),this.registerEventFromAttribute(t,s));break;case"dracoDecoderPath":ts&&console.log("dracoDecoderPath",s),oD(s);break;case"dracoDecoderType":s==="wasm"||s==="js"?(ts&&console.log("dracoDecoderType",s),aD(s)):console.error("Invalid dracoDecoderType",s,"expected js or wasm");break;case"ktx2DecoderPath":ts&&console.log("ktx2DecoderPath",s),cD(s);break}}async onLoad(){var f,p;if(!this.isConnected)return;if(this._context||(ts&&console.warn("Create new context"),this._context=new Nt({domElement:this})),!this._context){console.error("Needle Engine: Context not initialized");return}const t=this.getSourceFiles();if(t==null||t.length<=0)ts&&console.warn("Clear scene",t),this._context.clear();else if(!this.checkIfSourceHasChanged(t,this._lastSourceFiles))return;this._lastSourceFiles=t;const i=++this._loadId,s=this.getAttribute("alias");this.classList.add("loading");const r=Of();this.ensureLoadStartIsRegistered();let o=this.dispatchEvent(new CustomEvent("loadstart",{detail:{context:this._context,alias:s},cancelable:!0}));o===!1&&!r&&(bi()||(o=!0),console.warn("Needle Engine: You need a commercial license to override the default loading view. Visit https://needle.tools/pricing"),bi()&&nr('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 Yg(this)),o&&(this._didFullyLoad!==!0?(f=this._loadingView)==null||f.onLoadingBegin("begin load"):setTimeout(()=>{this._loadingView&&this._loadingProgress01<.3&&this._loadId===i&&this._loadingView.onLoadingBegin("begin load")},300)),ts&&console.warn("--------------",i,"Needle Engine: Begin loading",s??"",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={files:t,onLoadingProgress:g=>{var A;g.name=oce(g.name),o&&((A=this._loadingView)==null||A.onLoadingUpdate(g)),c.name=g.name,c.progress=g.progress,this._loadingProgress01=iT(g),c.totalProgress01=this._loadingProgress01,this.dispatchEvent(l)},onLoadingFinished:(g,A,v)=>{v&&a.push({src:A,file:v})}},d=this.getAttribute("hash");d!=null&&(this._context.hash=d),this._context.alias=s,await this._context.create(h),this._loadId===i&&(ts&&console.warn("--------------",i,"Needle Engine: finished loading",s??"",t),this._loadingProgress01=1,o&&((p=this._loadingView)==null||p.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:s,loadedFiles:a}})))}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 s=i.length-1;s>=0;s--){const r=i[s];(r==="null"||r==="undefined"||(r==null?void 0:r.length)<=0)&&i.splice(s,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 s=0;s<(t==null?void 0:t.length);s++)if(t[s]!==i[s])return!0}return!1}ensureLoadStartIsRegistered(){const t=this.getAttribute("loadstart");t&&this.registerEventFromAttribute("loadstart",t)}registerEventFromAttribute(t,i){const s=this._previouslyRegisteredMap.get(t);if(s&&(this._previouslyRegisteredMap.delete(t),this.removeEventListener(t,s)),typeof i=="string"&&i.length>0){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)))}}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,i){var s;this.onSetupAR(),this._overlay_ar.onBegin(this._context,i,t),this.dispatchEvent(new CustomEvent("enter-ar",{detail:{session:t,context:this._context,htmlContainer:(s=this._overlay_ar)==null?void 0:s.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(ag),this.classList.remove(cg);const t=this.getAROverlayContainer();ts&&console.warn("onSetupAR:",t),t&&(t.classList.add(ag),t.classList.remove(cg)),this.foreachHtmlElement(i=>this.setupElementsForMode(i,oN))}onSetupVR(){this.classList.remove(ag),this.classList.remove(cg),this.foreachHtmlElement(t=>this.setupElementsForMode(t,dG))}onSetupDesktop(){this.classList.remove(ag),this.classList.add(cg);const t=this.getAROverlayContainer();t&&(t.classList.remove(ag),t.classList.add(cg)),this.foreachHtmlElement(i=>this.setupElementsForMode(i,fG))}setupElementsForMode(t,i,s=null){var o;if(t===((o=this._context)==null?void 0:o.renderer.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 a of sce)t.classList.contains(a)&&(t.style.visibility="hidden",t.style.display="none")}foreachHtmlElement(t){for(let i=0;i<this.children.length;i++){const s=this.children[i];s.style&&t(s)}}onBeforeBeginLoading(){const t=this.getAttribute("dracoDecoderPath");t&&(ts&&console.log("using custom draco decoder path",t),oD(t));const i=this.getAttribute("dracoDecoderType");i&&(ts&&console.log("using custom draco decoder type",i),aD(i));const s=this.getAttribute("ktx2DecoderPath");s&&(ts&&console.log("using custom ktx2 decoder path",s),cD(s))}}typeof window<"u"&&!window.customElements.get(ak)&&window.customElements.define(ak,WI);function oce(n){const e=n.split("/");let t=e[e.length-1];const i=t.indexOf("?");return i>0&&(t=t.substring(0,i)),decodeURIComponent(t)}const ace=Object.freeze(Object.defineProperty({__proto__:null,NeedleEngineHTMLElement:WI},Symbol.toStringTag,{value:"Module"})),O0=re("debughotreload");let eA=!1;const nm=new Map;function cce(){return eA}function lce(n){var i;if(eA)return;const t=n.constructor.name;nm.has(t)?(i=nm.get(t))==null||i.push(n):nm.set(t,[n])}function hce(n){if(eA)return;const t=n.constructor.name,i=nm.get(t);if(!i)return;const s=i.indexOf(n);s!==-1&&i.splice(s,1)}let ck=!1;function uce(){if(O0||ck)return;ck=!0;const n=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}}n.apply(console,e)}}function dce(n){O0&&console.log("[HMR] Apply changes",n,Object.keys(n)),uce();for(const e of Object.keys(n))try{eA=!0;const t=q.get(e);if(!t){O0&&console.log("[HMR] Type not found: "+e);continue}const i=n[e],s=nm.get(i.name);let r="[Needle Engine] Updating type: "+e;const o=(s==null?void 0:s.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]=n[e].prototype[l]);for(const l of a)c[l]||delete t.prototype[l];if(s){const l=new i,h=Object.getOwnPropertyDescriptors(l);for(const d of s){const f=d,p=f.isComponent===!0,g=p?f.activeAndEnabled:!0,A=p?f.context:void 0;try{if(p&&Mc(f,A),p&&g&&(f.enabled=!1),d.onBeforeHotReloadFields&&d.onBeforeHotReloadFields()===!1)continue;for(const v in h)if(h[v].writable){if(d[v]===void 0)d[v]=l[v];else if(typeof d[v]=="function"&&!d[v].prototype){const b=d[v],y=b.name,_="bound ";if(y===_)continue;const C=b.name.substring(_.length),M=i.prototype[C];M&&(d[v]=M.bind(d))}}d.onAfterHotReloadFields&&d.onAfterHotReloadFields()}finally{p&&V1(f,A),p&&g&&(f.enabled=!0)}}}}catch(t){if(O0)console.error(t);else return!1}finally{eA=!1,Nc(Jo.Log,"Script changes applied (HMR)")}return!0}const fce=Symbol("object"),lk=new Ga(()=>new S,20);class pG{constructor(e,t,i,s,r){u(this,"_point");u(this,"_normal");u(this,"distance");u(this,"impulse");u(this,"friction");this._point=e,this.distance=t,this._normal=i,this.impulse=s,this.friction=r}get point(){return lk.get().set(this._point.x,this._point.y,this._point.z)}get normal(){return lk.get().set(this._normal.x,this._normal.y,this._normal.z)}}class gG{constructor(e,t,i){u(this,"contacts");u(this,"me");u(this,"_collider");u(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 mG{constructor(e,t){u(this,"object");u(this,"collider");this.object=e,this.collider=t}}let Ne;const tA=new Array(32).fill(void 0);tA.push(void 0,null,!0,!1);let hk;tA.length;function uk(){return hk.byteLength,hk}const pce=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});function mt(n,e){if(!(n instanceof e))throw new Error(`expected instance of ${e.name}`);return n.ptr}pce.decode();let dk,fk,sm=32;function pk(n){if(sm==1)throw new Error("out of js stack");return tA[--sm]=n,sm}function gce(){return dk.byteLength,dk}function mce(){return fk.byteLength,fk}let Pr=0;function Qh(n,e){const t=e(4*n.length);return gce().set(n,t/4),Pr=n.length,t}function Wy(n,e){const t=e(4*n.length);return mce().set(n,t/4),Pr=n.length,t}class Sb{static __wrap(e){const t=Object.create(Sb.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();Ne.__wbg_raweventqueue_free(e)}constructor(e){const t=Ne.raweventqueue_new(e);return Sb.__wrap(t)}drainCollisionEvents(e){try{Ne.raweventqueue_drainCollisionEvents(this.ptr,pk(e))}finally{tA[sm++]=void 0}}drainContactForceEvents(e){try{Ne.raweventqueue_drainContactForceEvents(this.ptr,pk(e))}finally{tA[sm++]=void 0}}clear(){Ne.raweventqueue_clear(this.ptr)}}class Ra{static __wrap(e){const t=Object.create(Ra.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();Ne.__wbg_rawgenericjoint_free(e)}static spherical(e,t){mt(e,dt),mt(t,dt);const i=Ne.rawgenericjoint_spherical(e.ptr,t.ptr);return Ra.__wrap(i)}static prismatic(e,t,i,s,r,o){mt(e,dt),mt(t,dt),mt(i,dt);const a=Ne.rawgenericjoint_prismatic(e.ptr,t.ptr,i.ptr,s,r,o);return a===0?void 0:Ra.__wrap(a)}static fixed(e,t,i,s){mt(e,dt),mt(t,jn),mt(i,dt),mt(s,jn);const r=Ne.rawgenericjoint_fixed(e.ptr,t.ptr,i.ptr,s.ptr);return Ra.__wrap(r)}static revolute(e,t,i){mt(e,dt),mt(t,dt),mt(i,dt);const s=Ne.rawgenericjoint_revolute(e.ptr,t.ptr,i.ptr);return s===0?void 0:Ra.__wrap(s)}}class jI{static __wrap(e){const t=Object.create(jI.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();Ne.__wbg_rawpointprojection_free(e)}point(){const e=Ne.rawpointprojection_point(this.ptr);return dt.__wrap(e)}isInside(){return Ne.rawpointprojection_isInside(this.ptr)!==0}}class XI{static __wrap(e){const t=Object.create(XI.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();Ne.__wbg_rawrayintersection_free(e)}normal(){const e=Ne.rawrayintersection_normal(this.ptr);return dt.__wrap(e)}toi(){return Ne.rawintegrationparameters_dt(this.ptr)}featureType(){return Ne.rawrayintersection_featureType(this.ptr)>>>0}featureId(){try{const i=Ne.__wbindgen_add_to_stack_pointer(-16);Ne.rawrayintersection_featureId(i,this.ptr);var e=uk()[i/4+0],t=uk()[i/4+1];return e===0?void 0:t>>>0}finally{Ne.__wbindgen_add_to_stack_pointer(16)}}}class jn{static __wrap(e){const t=Object.create(jn.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();Ne.__wbg_rawrotation_free(e)}constructor(e,t,i,s){const r=Ne.rawrotation_new(e,t,i,s);return jn.__wrap(r)}static identity(){const e=Ne.rawrotation_identity();return jn.__wrap(e)}get x(){return Ne.rawintegrationparameters_dt(this.ptr)}get y(){return Ne.rawrotation_y(this.ptr)}get z(){return Ne.rawintegrationparameters_erp(this.ptr)}get w(){return Ne.rawrotation_w(this.ptr)}}class Gt{static __wrap(e){const t=Object.create(Gt.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();Ne.__wbg_rawshape_free(e)}static cuboid(e,t,i){const s=Ne.rawshape_cuboid(e,t,i);return Gt.__wrap(s)}static roundCuboid(e,t,i,s){const r=Ne.rawshape_roundCuboid(e,t,i,s);return Gt.__wrap(r)}static ball(e){const t=Ne.rawshape_ball(e);return Gt.__wrap(t)}static capsule(e,t){const i=Ne.rawshape_capsule(e,t);return Gt.__wrap(i)}static cylinder(e,t){const i=Ne.rawshape_cylinder(e,t);return Gt.__wrap(i)}static roundCylinder(e,t,i){const s=Ne.rawshape_roundCylinder(e,t,i);return Gt.__wrap(s)}static cone(e,t){const i=Ne.rawshape_cone(e,t);return Gt.__wrap(i)}static roundCone(e,t,i){const s=Ne.rawshape_roundCone(e,t,i);return Gt.__wrap(s)}static polyline(e,t){const i=Qh(e,Ne.__wbindgen_malloc),s=Pr,r=Wy(t,Ne.__wbindgen_malloc),o=Pr,a=Ne.rawshape_polyline(i,s,r,o);return Gt.__wrap(a)}static trimesh(e,t){const i=Qh(e,Ne.__wbindgen_malloc),s=Pr,r=Wy(t,Ne.__wbindgen_malloc),o=Pr,a=Ne.rawshape_trimesh(i,s,r,o);return Gt.__wrap(a)}static heightfield(e,t,i,s){const r=Qh(i,Ne.__wbindgen_malloc),o=Pr;mt(s,dt);const a=Ne.rawshape_heightfield(e,t,r,o,s.ptr);return Gt.__wrap(a)}static segment(e,t){mt(e,dt),mt(t,dt);const i=Ne.rawshape_segment(e.ptr,t.ptr);return Gt.__wrap(i)}static triangle(e,t,i){mt(e,dt),mt(t,dt),mt(i,dt);const s=Ne.rawshape_triangle(e.ptr,t.ptr,i.ptr);return Gt.__wrap(s)}static roundTriangle(e,t,i,s){mt(e,dt),mt(t,dt),mt(i,dt);const r=Ne.rawshape_roundTriangle(e.ptr,t.ptr,i.ptr,s);return Gt.__wrap(r)}static convexHull(e){const t=Qh(e,Ne.__wbindgen_malloc),i=Pr,s=Ne.rawshape_convexHull(t,i);return s===0?void 0:Gt.__wrap(s)}static roundConvexHull(e,t){const i=Qh(e,Ne.__wbindgen_malloc),s=Pr,r=Ne.rawshape_roundConvexHull(i,s,t);return r===0?void 0:Gt.__wrap(r)}static convexMesh(e,t){const i=Qh(e,Ne.__wbindgen_malloc),s=Pr,r=Wy(t,Ne.__wbindgen_malloc),o=Pr,a=Ne.rawshape_convexMesh(i,s,r,o);return a===0?void 0:Gt.__wrap(a)}static roundConvexMesh(e,t,i){const s=Qh(e,Ne.__wbindgen_malloc),r=Pr,o=Wy(t,Ne.__wbindgen_malloc),a=Pr,c=Ne.rawshape_roundConvexMesh(s,r,o,a,i);return c===0?void 0:Gt.__wrap(c)}castShape(e,t,i,s,r,o,a,c){mt(e,dt),mt(t,jn),mt(i,dt),mt(s,Gt),mt(r,dt),mt(o,jn),mt(a,dt);const l=Ne.rawshape_castShape(this.ptr,e.ptr,t.ptr,i.ptr,s.ptr,r.ptr,o.ptr,a.ptr,c);return l===0?void 0:YI.__wrap(l)}intersectsShape(e,t,i,s,r){return mt(e,dt),mt(t,jn),mt(i,Gt),mt(s,dt),mt(r,jn),Ne.rawshape_intersectsShape(this.ptr,e.ptr,t.ptr,i.ptr,s.ptr,r.ptr)!==0}contactShape(e,t,i,s,r,o){mt(e,dt),mt(t,jn),mt(i,Gt),mt(s,dt),mt(r,jn);const a=Ne.rawshape_contactShape(this.ptr,e.ptr,t.ptr,i.ptr,s.ptr,r.ptr,o);return a===0?void 0:qI.__wrap(a)}containsPoint(e,t,i){return mt(e,dt),mt(t,jn),mt(i,dt),Ne.rawshape_containsPoint(this.ptr,e.ptr,t.ptr,i.ptr)!==0}projectPoint(e,t,i,s){mt(e,dt),mt(t,jn),mt(i,dt);const r=Ne.rawshape_projectPoint(this.ptr,e.ptr,t.ptr,i.ptr,s);return jI.__wrap(r)}intersectsRay(e,t,i,s,r){return mt(e,dt),mt(t,jn),mt(i,dt),mt(s,dt),Ne.rawshape_intersectsRay(this.ptr,e.ptr,t.ptr,i.ptr,s.ptr,r)!==0}castRay(e,t,i,s,r,o){return mt(e,dt),mt(t,jn),mt(i,dt),mt(s,dt),Ne.rawshape_castRay(this.ptr,e.ptr,t.ptr,i.ptr,s.ptr,r,o)}castRayAndGetNormal(e,t,i,s,r,o){mt(e,dt),mt(t,jn),mt(i,dt),mt(s,dt);const a=Ne.rawshape_castRayAndGetNormal(this.ptr,e.ptr,t.ptr,i.ptr,s.ptr,r,o);return a===0?void 0:XI.__wrap(a)}}class qI{static __wrap(e){const t=Object.create(qI.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();Ne.__wbg_rawshapecontact_free(e)}distance(){return Ne.rawshapecontact_distance(this.ptr)}point1(){const e=Ne.rawpointprojection_point(this.ptr);return dt.__wrap(e)}point2(){const e=Ne.rawshapecontact_point2(this.ptr);return dt.__wrap(e)}normal1(){const e=Ne.rawshapecontact_normal1(this.ptr);return dt.__wrap(e)}normal2(){const e=Ne.rawshapecontact_normal2(this.ptr);return dt.__wrap(e)}}class YI{static __wrap(e){const t=Object.create(YI.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();Ne.__wbg_rawshapetoi_free(e)}toi(){return Ne.rawintegrationparameters_dt(this.ptr)}witness1(){const e=Ne.rawrayintersection_normal(this.ptr);return dt.__wrap(e)}witness2(){const e=Ne.rawshapetoi_witness2(this.ptr);return dt.__wrap(e)}normal1(){const e=Ne.rawshapetoi_normal1(this.ptr);return dt.__wrap(e)}normal2(){const e=Ne.rawshapetoi_normal2(this.ptr);return dt.__wrap(e)}}class dt{static __wrap(e){const t=Object.create(dt.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();Ne.__wbg_rawvector_free(e)}static zero(){const e=Ne.rawvector_zero();return dt.__wrap(e)}constructor(e,t,i){const s=Ne.rawvector_new(e,t,i);return dt.__wrap(s)}get x(){return Ne.rawintegrationparameters_dt(this.ptr)}set x(e){Ne.rawintegrationparameters_set_dt(this.ptr,e)}get y(){return Ne.rawrotation_y(this.ptr)}set y(e){Ne.rawvector_set_y(this.ptr,e)}get z(){return Ne.rawintegrationparameters_erp(this.ptr)}set z(e){Ne.rawintegrationparameters_set_erp(this.ptr,e)}xyz(){const e=Ne.rawvector_xyz(this.ptr);return dt.__wrap(e)}yxz(){const e=Ne.rawvector_yxz(this.ptr);return dt.__wrap(e)}zxy(){const e=Ne.rawvector_zxy(this.ptr);return dt.__wrap(e)}xzy(){const e=Ne.rawvector_xzy(this.ptr);return dt.__wrap(e)}yzx(){const e=Ne.rawvector_yzx(this.ptr);return dt.__wrap(e)}zyx(){const e=Ne.rawvector_zyx(this.ptr);return dt.__wrap(e)}}class Ace{constructor(e,t,i){this.x=e,this.y=t,this.z=i}}class Ie{static new(e,t,i){return new Ace(e,t,i)}static intoRaw(e){return new dt(e.x,e.y,e.z)}static zeros(){return Ie.new(0,0,0)}static fromRaw(e){if(!e)return null;let t=Ie.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 gk{constructor(e,t,i,s){this.x=e,this.y=t,this.z=i,this.w=s}}class Pi{static identity(){return new gk(0,0,0,1)}static fromRaw(e){if(!e)return null;let t=new gk(e.x,e.y,e.z,e.w);return e.free(),t}static intoRaw(e){return new jn(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}}var rm,ya,mk,yo,vM,si,Cb,tf,yM,bM,Ak,vk;(function(n){n[n.Dynamic=0]="Dynamic",n[n.Fixed=1]="Fixed",n[n.KinematicPositionBased=2]="KinematicPositionBased",n[n.KinematicVelocityBased=3]="KinematicVelocityBased"})(rm||(rm={}));class vce{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,s){return this.rawSet.rbSetEnabledTranslations(this.handle,e,t,i,s)}restrictTranslations(e,t,i,s){this.setEnabledTranslations(e,t,i,s)}setEnabledRotations(e,t,i,s){return this.rawSet.rbSetEnabledRotations(this.handle,e,t,i,s)}restrictRotations(e,t,i,s){this.setEnabledRotations(e,t,i,s)}dominanceGroup(){return this.rawSet.rbDominanceGroup(this.handle)}setDominanceGroup(e){this.rawSet.rbSetDominanceGroup(this.handle,e)}enableCcd(e){this.rawSet.rbEnableCcd(this.handle,e)}translation(){let e=this.rawSet.rbTranslation(this.handle);return Ie.fromRaw(e)}rotation(){let e=this.rawSet.rbRotation(this.handle);return Pi.fromRaw(e)}nextTranslation(){let e=this.rawSet.rbNextTranslation(this.handle);return Ie.fromRaw(e)}nextRotation(){let e=this.rawSet.rbNextRotation(this.handle);return Pi.fromRaw(e)}setTranslation(e,t){this.rawSet.rbSetTranslation(this.handle,e.x,e.y,e.z,t)}setLinvel(e,t){let i=Ie.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=Ie.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 Ie.fromRaw(this.rawSet.rbLinvel(this.handle))}angvel(){return Ie.fromRaw(this.rawSet.rbAngvel(this.handle))}mass(){return this.rawSet.rbMass(this.handle)}sleep(){this.rawSet.rbSleep(this.handle)}wakeUp(){this.rawSet.rbWakeUp(this.handle)}isCcdEnabled(){this.rawSet.rbIsCcdEnabled(this.handle)}numColliders(){return this.rawSet.rbNumColliders(this.handle)}collider(e){return this.colliderSet.get(this.rawSet.rbCollider(this.handle,e))}bodyType(){return this.rawSet.rbBodyType(this.handle)}setBodyType(e){return this.rawSet.rbSetBodyType(this.handle,e)}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,s,r){let o=Ie.intoRaw(t),a=Ie.intoRaw(i),c=Pi.intoRaw(s);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=Ie.intoRaw(e);this.rawSet.rbAddForce(this.handle,i,t),i.free()}applyImpulse(e,t){const i=Ie.intoRaw(e);this.rawSet.rbApplyImpulse(this.handle,i,t),i.free()}addTorque(e,t){const i=Ie.intoRaw(e);this.rawSet.rbAddTorque(this.handle,i,t),i.free()}applyTorqueImpulse(e,t){const i=Ie.intoRaw(e);this.rawSet.rbApplyTorqueImpulse(this.handle,i,t),i.free()}addForceAtPoint(e,t,i){const s=Ie.intoRaw(e),r=Ie.intoRaw(t);this.rawSet.rbAddForceAtPoint(this.handle,s,r,i),s.free(),r.free()}applyImpulseAtPoint(e,t,i){const s=Ie.intoRaw(e),r=Ie.intoRaw(t);this.rawSet.rbApplyImpulseAtPoint(this.handle,s,r,i),s.free(),r.free()}}(function(n){n[n.Revolute=0]="Revolute",n[n.Fixed=1]="Fixed",n[n.Prismatic=2]="Prismatic",n[n.Spherical=3]="Spherical"})(ya||(ya={})),function(n){n[n.AccelerationBased=0]="AccelerationBased",n[n.ForceBased=1]="ForceBased"}(mk||(mk={}));class nf{constructor(){}static fixed(e,t,i,s){let r=new nf;return r.anchor1=e,r.anchor2=i,r.frame1=t,r.frame2=s,r.jointType=ya.Fixed,r}static spherical(e,t){let i=new nf;return i.anchor1=e,i.anchor2=t,i.jointType=ya.Spherical,i}static prismatic(e,t,i){let s=new nf;return s.anchor1=e,s.anchor2=t,s.axis=i,s.jointType=ya.Prismatic,s}static revolute(e,t,i){let s=new nf;return s.anchor1=e,s.anchor2=t,s.axis=i,s.jointType=ya.Revolute,s}intoRaw(){let e,t,i=Ie.intoRaw(this.anchor1),s=Ie.intoRaw(this.anchor2),r=!1,o=0,a=0;switch(this.jointType){case ya.Fixed:let c=Pi.intoRaw(this.frame1),l=Pi.intoRaw(this.frame2);t=Ra.fixed(i,c,s,l),c.free(),l.free();break;case ya.Prismatic:e=Ie.intoRaw(this.axis),this.limitsEnabled&&(r=!0,o=this.limits[0],a=this.limits[1]),t=Ra.prismatic(i,s,e,r,o,a),e.free();break;case ya.Spherical:t=Ra.spherical(i,s);break;case ya.Revolute:e=Ie.intoRaw(this.axis),t=Ra.revolute(i,s,e),e.free()}return i.free(),s.free(),t}}(function(n){n[n.Average=0]="Average",n[n.Min=1]="Min",n[n.Multiply=2]="Multiply",n[n.Max=3]="Max"})(yo||(yo={}));class iA{constructor(e,t,i,s,r){this.distance=e,this.point1=t,this.point2=i,this.normal1=s,this.normal2=r}static fromRaw(e){if(!e)return null;const t=new iA(e.distance(),Ie.fromRaw(e.point1()),Ie.fromRaw(e.point2()),Ie.fromRaw(e.normal1()),Ie.fromRaw(e.normal2()));return e.free(),t}}(function(n){n[n.Vertex=0]="Vertex",n[n.Edge=1]="Edge",n[n.Face=2]="Face",n[n.Unknown=3]="Unknown"})(vM||(vM={}));class Qx{constructor(e,t){this.point=e,this.isInside=t}static fromRaw(e){if(!e)return null;const t=new Qx(Ie.fromRaw(e.point()),e.isInside());return e.free(),t}}class yce{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 Wx{constructor(e,t,i,s){this.featureType=vM.Unknown,this.featureId=void 0,this.toi=e,this.normal=t,s!==void 0&&(this.featureId=s),i!==void 0&&(this.featureType=i)}static fromRaw(e){if(!e)return null;const t=new Wx(e.toi(),Ie.fromRaw(e.normal()),e.featureType(),e.featureId());return e.free(),t}}class pv{constructor(e,t,i,s,r){this.toi=e,this.witness1=t,this.witness2=i,this.normal1=s,this.normal2=r}static fromRaw(e,t){if(!t)return null;const i=new pv(t.toi(),Ie.fromRaw(t.witness1()),Ie.fromRaw(t.witness2()),Ie.fromRaw(t.normal1()),Ie.fromRaw(t.normal2()));return t.free(),i}}class KI extends pv{constructor(e,t,i,s,r,o){super(t,i,s,r,o),this.collider=e}static fromRaw(e,t){if(!t)return null;const i=new KI(e.get(t.colliderHandle()),t.toi(),Ie.fromRaw(t.witness1()),Ie.fromRaw(t.witness2()),Ie.fromRaw(t.normal1()),Ie.fromRaw(t.normal2()));return t.free(),i}}class ys{static fromRaw(e,t){const i=e.coShapeType(t);let s,r,o,a,c,l;switch(i){case si.Ball:return new JI(e.coRadius(t));case si.Cuboid:return s=e.coHalfExtents(t),new AG(s.x,s.y,s.z);case si.RoundCuboid:return s=e.coHalfExtents(t),r=e.coRoundRadius(t),new vG(s.x,s.y,s.z,r);case si.Capsule:return c=e.coHalfHeight(t),l=e.coRadius(t),new yG(c,l);case si.Segment:return o=e.coVertices(t),new bG(Ie.new(o[0],o[1],o[2]),Ie.new(o[3],o[4],o[5]));case si.Polyline:return o=e.coVertices(t),a=e.coIndices(t),new wG(o,a);case si.Triangle:return o=e.coVertices(t),new _G(Ie.new(o[0],o[1],o[2]),Ie.new(o[3],o[4],o[5]),Ie.new(o[6],o[7],o[8]));case si.RoundTriangle:return o=e.coVertices(t),r=e.coRoundRadius(t),new xG(Ie.new(o[0],o[1],o[2]),Ie.new(o[3],o[4],o[5]),Ie.new(o[6],o[7],o[8]),r);case si.TriMesh:return o=e.coVertices(t),a=e.coIndices(t),new SG(o,a);case si.HeightField:const h=e.coHeightfieldScale(t),d=e.coHeightfieldHeights(t),f=e.coHeightfieldNRows(t),p=e.coHeightfieldNCols(t);return new CG(f,p,d,h);case si.ConvexPolyhedron:return o=e.coVertices(t),a=e.coIndices(t),new _M(o,a);case si.RoundConvexPolyhedron:return o=e.coVertices(t),a=e.coIndices(t),r=e.coRoundRadius(t),new xM(o,a,r);case si.Cylinder:return c=e.coHalfHeight(t),l=e.coRadius(t),new EG(c,l);case si.RoundCylinder:return c=e.coHalfHeight(t),l=e.coRadius(t),r=e.coRoundRadius(t),new MG(c,l,r);case si.Cone:return c=e.coHalfHeight(t),l=e.coRadius(t),new TG(c,l);case si.RoundCone:return c=e.coHalfHeight(t),l=e.coRadius(t),r=e.coRoundRadius(t),new IG(c,l,r);default:throw new Error("unknown shape type: "+i)}}castShape(e,t,i,s,r,o,a,c){let l=Ie.intoRaw(e),h=Pi.intoRaw(t),d=Ie.intoRaw(i),f=Ie.intoRaw(r),p=Pi.intoRaw(o),g=Ie.intoRaw(a),A=this.intoRaw(),v=s.intoRaw(),m=pv.fromRaw(null,A.castShape(l,h,d,v,f,p,g,c));return l.free(),h.free(),d.free(),f.free(),p.free(),g.free(),A.free(),v.free(),m}intersectsShape(e,t,i,s,r){let o=Ie.intoRaw(e),a=Pi.intoRaw(t),c=Ie.intoRaw(s),l=Pi.intoRaw(r),h=this.intoRaw(),d=i.intoRaw(),f=h.intersectsShape(o,a,d,c,l);return o.free(),a.free(),c.free(),l.free(),h.free(),d.free(),f}contactShape(e,t,i,s,r,o){let a=Ie.intoRaw(e),c=Pi.intoRaw(t),l=Ie.intoRaw(s),h=Pi.intoRaw(r),d=this.intoRaw(),f=i.intoRaw(),p=iA.fromRaw(d.contactShape(a,c,f,l,h,o));return a.free(),c.free(),l.free(),h.free(),d.free(),f.free(),p}containsPoint(e,t,i){let s=Ie.intoRaw(e),r=Pi.intoRaw(t),o=Ie.intoRaw(i),a=this.intoRaw(),c=a.containsPoint(s,r,o);return s.free(),r.free(),o.free(),a.free(),c}projectPoint(e,t,i,s){let r=Ie.intoRaw(e),o=Pi.intoRaw(t),a=Ie.intoRaw(i),c=this.intoRaw(),l=Qx.fromRaw(c.projectPoint(r,o,a,s));return r.free(),o.free(),a.free(),c.free(),l}intersectsRay(e,t,i,s){let r=Ie.intoRaw(t),o=Pi.intoRaw(i),a=Ie.intoRaw(e.origin),c=Ie.intoRaw(e.dir),l=this.intoRaw(),h=l.intersectsRay(r,o,a,c,s);return r.free(),o.free(),a.free(),c.free(),l.free(),h}castRay(e,t,i,s,r){let o=Ie.intoRaw(t),a=Pi.intoRaw(i),c=Ie.intoRaw(e.origin),l=Ie.intoRaw(e.dir),h=this.intoRaw(),d=h.castRay(o,a,c,l,s,r);return o.free(),a.free(),c.free(),l.free(),h.free(),d}castRayAndGetNormal(e,t,i,s,r){let o=Ie.intoRaw(t),a=Pi.intoRaw(i),c=Ie.intoRaw(e.origin),l=Ie.intoRaw(e.dir),h=this.intoRaw(),d=Wx.fromRaw(h.castRayAndGetNormal(o,a,c,l,s,r));return o.free(),a.free(),c.free(),l.free(),h.free(),d}}(function(n){n[n.Ball=0]="Ball",n[n.Cuboid=1]="Cuboid",n[n.Capsule=2]="Capsule",n[n.Segment=3]="Segment",n[n.Polyline=4]="Polyline",n[n.Triangle=5]="Triangle",n[n.TriMesh=6]="TriMesh",n[n.HeightField=7]="HeightField",n[n.ConvexPolyhedron=9]="ConvexPolyhedron",n[n.Cylinder=10]="Cylinder",n[n.Cone=11]="Cone",n[n.RoundCuboid=12]="RoundCuboid",n[n.RoundTriangle=13]="RoundTriangle",n[n.RoundCylinder=14]="RoundCylinder",n[n.RoundCone=15]="RoundCone",n[n.RoundConvexPolyhedron=16]="RoundConvexPolyhedron"})(si||(si={}));class JI extends ys{constructor(e){super(),this.type=si.Ball,this.radius=e}intoRaw(){return Gt.ball(this.radius)}}class AG extends ys{constructor(e,t,i){super(),this.type=si.Cuboid,this.halfExtents=Ie.new(e,t,i)}intoRaw(){return Gt.cuboid(this.halfExtents.x,this.halfExtents.y,this.halfExtents.z)}}class vG extends ys{constructor(e,t,i,s){super(),this.type=si.RoundCuboid,this.halfExtents=Ie.new(e,t,i),this.borderRadius=s}intoRaw(){return Gt.roundCuboid(this.halfExtents.x,this.halfExtents.y,this.halfExtents.z,this.borderRadius)}}class yG extends ys{constructor(e,t){super(),this.type=si.Capsule,this.halfHeight=e,this.radius=t}intoRaw(){return Gt.capsule(this.halfHeight,this.radius)}}class bG extends ys{constructor(e,t){super(),this.type=si.Segment,this.a=e,this.b=t}intoRaw(){let e=Ie.intoRaw(this.a),t=Ie.intoRaw(this.b),i=Gt.segment(e,t);return e.free(),t.free(),i}}class _G extends ys{constructor(e,t,i){super(),this.type=si.Triangle,this.a=e,this.b=t,this.c=i}intoRaw(){let e=Ie.intoRaw(this.a),t=Ie.intoRaw(this.b),i=Ie.intoRaw(this.c),s=Gt.triangle(e,t,i);return e.free(),t.free(),i.free(),s}}class xG extends ys{constructor(e,t,i,s){super(),this.type=si.RoundTriangle,this.a=e,this.b=t,this.c=i,this.borderRadius=s}intoRaw(){let e=Ie.intoRaw(this.a),t=Ie.intoRaw(this.b),i=Ie.intoRaw(this.c),s=Gt.roundTriangle(e,t,i,this.borderRadius);return e.free(),t.free(),i.free(),s}}class wG extends ys{constructor(e,t){super(),this.type=si.Polyline,this.vertices=e,this.indices=t??new Uint32Array(0)}intoRaw(){return Gt.polyline(this.vertices,this.indices)}}class SG extends ys{constructor(e,t){super(),this.type=si.TriMesh,this.vertices=e,this.indices=t}intoRaw(){return Gt.trimesh(this.vertices,this.indices)}}class _M extends ys{constructor(e,t){super(),this.type=si.ConvexPolyhedron,this.vertices=e,this.indices=t}intoRaw(){return this.indices?Gt.convexMesh(this.vertices,this.indices):Gt.convexHull(this.vertices)}}class xM extends ys{constructor(e,t,i){super(),this.type=si.RoundConvexPolyhedron,this.vertices=e,this.indices=t,this.borderRadius=i}intoRaw(){return this.indices?Gt.roundConvexMesh(this.vertices,this.indices,this.borderRadius):Gt.roundConvexHull(this.vertices,this.borderRadius)}}class CG extends ys{constructor(e,t,i,s){super(),this.type=si.HeightField,this.nrows=e,this.ncols=t,this.heights=i,this.scale=s}intoRaw(){let e=Ie.intoRaw(this.scale),t=Gt.heightfield(this.nrows,this.ncols,this.heights,e);return e.free(),t}}class EG extends ys{constructor(e,t){super(),this.type=si.Cylinder,this.halfHeight=e,this.radius=t}intoRaw(){return Gt.cylinder(this.halfHeight,this.radius)}}class MG extends ys{constructor(e,t,i){super(),this.type=si.RoundCylinder,this.borderRadius=i,this.halfHeight=e,this.radius=t}intoRaw(){return Gt.roundCylinder(this.halfHeight,this.radius,this.borderRadius)}}class TG extends ys{constructor(e,t){super(),this.type=si.Cone,this.halfHeight=e,this.radius=t}intoRaw(){return Gt.cone(this.halfHeight,this.radius)}}class IG extends ys{constructor(e,t,i){super(),this.type=si.RoundCone,this.halfHeight=e,this.radius=t,this.borderRadius=i}intoRaw(){return Gt.roundCone(this.halfHeight,this.radius,this.borderRadius)}}(function(n){n[n.DYNAMIC_DYNAMIC=1]="DYNAMIC_DYNAMIC",n[n.DYNAMIC_KINEMATIC=12]="DYNAMIC_KINEMATIC",n[n.DYNAMIC_FIXED=2]="DYNAMIC_FIXED",n[n.KINEMATIC_KINEMATIC=52224]="KINEMATIC_KINEMATIC",n[n.KINEMATIC_FIXED=8704]="KINEMATIC_FIXED",n[n.FIXED_FIXED=32]="FIXED_FIXED",n[n.DEFAULT=15]="DEFAULT",n[n.ALL=60943]="ALL"})(Cb||(Cb={}));class bce{constructor(e,t,i,s){this.colliderSet=e,this.handle=t,this._parent=i,this._shape=s}finalizeDeserialization(e){this.handle!=null&&(this._parent=e.get(this.colliderSet.raw.coParent(this.handle)))}ensureShapeIsCached(){this._shape||(this._shape=ys.fromRaw(this.colliderSet.raw,this.handle))}get shape(){return this.ensureShapeIsCached(),this._shape}isValid(){return this.colliderSet.raw.contains(this.handle)}translation(){return Ie.fromRaw(this.colliderSet.raw.coTranslation(this.handle))}rotation(){return Pi.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}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,s){let r=Ie.intoRaw(t),o=Ie.intoRaw(i),a=Pi.intoRaw(s);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 Ie.fromRaw(this.colliderSet.raw.coHalfExtents(this.handle))}radius(){return this.colliderSet.raw.coRadius(this.handle)}roundRadius(){return this.colliderSet.raw.coRoundRadius(this.handle)}halfHeight(){return this.colliderSet.raw.coHalfHeight(this.handle)}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 Ie.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=Ie.intoRaw(e),i=this.colliderSet.raw.coContainsPoint(this.handle,t);return t.free(),i}projectPoint(e,t){let i=Ie.intoRaw(e),s=Qx.fromRaw(this.colliderSet.raw.coProjectPoint(this.handle,i,t));return i.free(),s}intersectsRay(e,t){let i=Ie.intoRaw(e.origin),s=Ie.intoRaw(e.dir),r=this.colliderSet.raw.coIntersectsRay(this.handle,i,s,t);return i.free(),s.free(),r}castShape(e,t,i,s,r,o){let a=Ie.intoRaw(e),c=Ie.intoRaw(i),l=Pi.intoRaw(s),h=Ie.intoRaw(r),d=t.intoRaw(),f=pv.fromRaw(this.colliderSet,this.colliderSet.raw.coCastShape(this.handle,a,d,c,l,h,o));return a.free(),c.free(),l.free(),h.free(),d.free(),f}castCollider(e,t,i,s){let r=Ie.intoRaw(e),o=Ie.intoRaw(i),a=KI.fromRaw(this.colliderSet,this.colliderSet.raw.coCastCollider(this.handle,r,t.handle,o,s));return r.free(),o.free(),a}intersectsShape(e,t,i){let s=Ie.intoRaw(t),r=Pi.intoRaw(i),o=e.intoRaw(),a=this.colliderSet.raw.coIntersectsShape(this.handle,o,s,r);return s.free(),r.free(),o.free(),a}contactShape(e,t,i,s){let r=Ie.intoRaw(t),o=Pi.intoRaw(i),a=e.intoRaw(),c=iA.fromRaw(this.colliderSet.raw.coContactShape(this.handle,a,r,o,s));return r.free(),o.free(),a.free(),c}contactCollider(e,t){return iA.fromRaw(this.colliderSet.raw.coContactCollider(this.handle,e.handle,t))}castRay(e,t,i){let s=Ie.intoRaw(e.origin),r=Ie.intoRaw(e.dir),o=this.colliderSet.raw.coCastRay(this.handle,s,r,t,i);return s.free(),r.free(),o}castRayAndGetNormal(e,t,i){let s=Ie.intoRaw(e.origin),r=Ie.intoRaw(e.dir),o=Wx.fromRaw(this.colliderSet.raw.coCastRayAndGetNormal(this.handle,s,r,t,i));return s.free(),r.free(),o}}(function(n){n[n.Density=0]="Density",n[n.Mass=1]="Mass",n[n.MassProps=2]="MassProps"})(tf||(tf={}));class Ni{constructor(e){this.shape=e,this.massPropsMode=tf.Density,this.density=1,this.friction=.5,this.restitution=0,this.rotation=Pi.identity(),this.translation=Ie.zeros(),this.isSensor=!1,this.collisionGroups=4294967295,this.solverGroups=4294967295,this.frictionCombineRule=yo.Average,this.restitutionCombineRule=yo.Average,this.activeCollisionTypes=Cb.DEFAULT,this.activeEvents=0,this.activeHooks=0,this.mass=0,this.centerOfMass=Ie.zeros(),this.contactForceEventThreshold=0,this.principalAngularInertia=Ie.zeros(),this.angularInertiaLocalFrame=Pi.identity()}static ball(e){const t=new JI(e);return new Ni(t)}static capsule(e,t){const i=new yG(e,t);return new Ni(i)}static segment(e,t){const i=new bG(e,t);return new Ni(i)}static triangle(e,t,i){const s=new _G(e,t,i);return new Ni(s)}static roundTriangle(e,t,i,s){const r=new xG(e,t,i,s);return new Ni(r)}static polyline(e,t){const i=new wG(e,t);return new Ni(i)}static trimesh(e,t){const i=new SG(e,t);return new Ni(i)}static cuboid(e,t,i){const s=new AG(e,t,i);return new Ni(s)}static roundCuboid(e,t,i,s){const r=new vG(e,t,i,s);return new Ni(r)}static heightfield(e,t,i,s){const r=new CG(e,t,i,s);return new Ni(r)}static cylinder(e,t){const i=new EG(e,t);return new Ni(i)}static roundCylinder(e,t,i){const s=new MG(e,t,i);return new Ni(s)}static cone(e,t){const i=new TG(e,t);return new Ni(i)}static roundCone(e,t,i){const s=new IG(e,t,i);return new Ni(s)}static convexHull(e){const t=new _M(e,null);return new Ni(t)}static convexMesh(e,t){const i=new _M(e,t);return new Ni(i)}static roundConvexHull(e,t){const i=new xM(e,null,t);return new Ni(i)}static roundConvexMesh(e,t,i){const s=new xM(e,t,i);return new Ni(s)}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 Pi.copy(this.rotation,e),this}setSensor(e){return this.isSensor=e,this}setDensity(e){return this.massPropsMode=tf.Density,this.density=e,this}setMass(e){return this.massPropsMode=tf.Mass,this.mass=e,this}setMassProperties(e,t,i,s){return this.massPropsMode=tf.MassProps,this.mass=e,Ie.copy(this.centerOfMass,t),Ie.copy(this.principalAngularInertia,i),Pi.copy(this.angularInertiaLocalFrame,s),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}}(function(n){n[n.EXCLUDE_FIXED=1]="EXCLUDE_FIXED",n[n.EXCLUDE_KINEMATIC=2]="EXCLUDE_KINEMATIC",n[n.EXCLUDE_DYNAMIC=4]="EXCLUDE_DYNAMIC",n[n.EXCLUDE_SENSORS=8]="EXCLUDE_SENSORS",n[n.EXCLUDE_SOLIDS=16]="EXCLUDE_SOLIDS",n[n.ONLY_DYNAMIC=3]="ONLY_DYNAMIC",n[n.ONLY_KINEMATIC=5]="ONLY_KINEMATIC",n[n.ONLY_FIXED=6]="ONLY_FIXED"})(yM||(yM={}));(function(n){n[n.COLLISION_EVENTS=1]="COLLISION_EVENTS",n[n.CONTACT_FORCE_EVENTS=2]="CONTACT_FORCE_EVENTS"})(bM||(bM={}));class _ce{free(){this.raw.free(),this.raw=void 0}collider1(){return this.raw.collider1()}collider2(){return this.raw.collider2()}totalForce(){return Ie.fromRaw(this.raw.total_force())}totalForceMagnitude(){return this.raw.total_force_magnitude()}maxForceDirection(){return Ie.fromRaw(this.raw.max_force_direction())}maxForceMagnitude(){return this.raw.max_force_magnitude()}}class xce{constructor(e,t){this.raw=t||new Sb(e)}free(){this.raw.free(),this.raw=void 0}drainCollisionEvents(e){this.raw.drainCollisionEvents(e)}drainContactForceEvents(e){let t=new _ce;this.raw.drainContactForceEvents(i=>{t.raw=i,e(t),t.free()})}clear(){this.raw.clear()}}(function(n){n[n.FILTER_CONTACT_PAIRS=1]="FILTER_CONTACT_PAIRS",n[n.FILTER_INTERSECTION_PAIRS=2]="FILTER_INTERSECTION_PAIRS"})(Ak||(Ak={})),function(n){n[n.EMPTY=0]="EMPTY",n[n.COMPUTE_IMPULSE=1]="COMPUTE_IMPULSE"}(vk||(vk={}));for(var vle={byteLength:function(n){var e=yk(n),t=e[0],i=e[1];return 3*(t+i)/4-i},toByteArray:function(n){var e,t,i=yk(n),s=i[0],r=i[1],o=new wce(function(l,h,d){return 3*(h+d)/4-d}(0,s,r)),a=0,c=r>0?s-4:s;for(t=0;t<c;t+=4)e=uo[n.charCodeAt(t)]<<18|uo[n.charCodeAt(t+1)]<<12|uo[n.charCodeAt(t+2)]<<6|uo[n.charCodeAt(t+3)],o[a++]=e>>16&255,o[a++]=e>>8&255,o[a++]=255&e;return r===2&&(e=uo[n.charCodeAt(t)]<<2|uo[n.charCodeAt(t+1)]>>4,o[a++]=255&e),r===1&&(e=uo[n.charCodeAt(t)]<<10|uo[n.charCodeAt(t+1)]<<4|uo[n.charCodeAt(t+2)]>>2,o[a++]=e>>8&255,o[a++]=255&e),o},fromByteArray:function(n){for(var e,t=n.length,i=t%3,s=[],r=16383,o=0,a=t-i;o<a;o+=r)s.push(Cce(n,o,o+r>a?a:o+r));return i===1?(e=n[t-1],s.push(Ca[e>>2]+Ca[e<<4&63]+"==")):i===2&&(e=(n[t-2]<<8)+n[t-1],s.push(Ca[e>>10]+Ca[e>>4&63]+Ca[e<<2&63]+"=")),s.join("")}},Ca=[],uo=[],wce=typeof Uint8Array<"u"?Uint8Array:Array,iC="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Fd=0,Sce=iC.length;Fd<Sce;++Fd)Ca[Fd]=iC[Fd],uo[iC.charCodeAt(Fd)]=Fd;function yk(n){var e=n.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=n.indexOf("=");return t===-1&&(t=e),[t,t===e?0:4-t%4]}function Cce(n,e,t){for(var i,s,r=[],o=e;o<t;o+=3)i=(n[o]<<16&16711680)+(n[o+1]<<8&65280)+(255&n[o+2]),r.push(Ca[(s=i)>>18&63]+Ca[s>>12&63]+Ca[s>>6&63]+Ca[63&s]);return r.join("")}uo["-".charCodeAt(0)]=62,uo["_".charCodeAt(0)]=63;const Ns=re("debugphysics"),nC=re("debugcolliderplacement"),sC=re("debugcollisions"),Ece=re("showcolliders"),fo=Symbol("needle component"),No=Symbol("physics body"),Mce=Symbol("rigidbody");let Ud;globalThis.false=globalThis.false!==void 0?globalThis.false:!0;Ns&&console.log("Use Rapier",!1,globalThis.false);const dm=class{constructor(){u(this,"debugRenderColliders",!1);u(this,"context");u(this,"_initializePromise");u(this,"_isInitialized",!1);u(this,"rapierRay",new yce({x:0,y:0,z:0},{x:0,y:0,z:1}));u(this,"raycastVectorsBuffer",new Ga(()=>new S,10));u(this,"rapierSphere",null);u(this,"rapierColliderArray",[]);u(this,"rapierIdentityRotation",{x:0,y:0,z:0,w:1});u(this,"rapierForwardVector",{x:0,y:0,z:1});u(this,"enabled",!1);u(this,"_tempPosition",new S);u(this,"_tempQuaternion",new Se);u(this,"_tempScale",new S);u(this,"_tempMatrix",new Re);u(this,"_isUpdatingPhysicsWorld",!1);u(this,"world");u(this,"_hasCreatedWorld",!1);u(this,"eventQueue");u(this,"collisionHandler");u(this,"objects",[]);u(this,"bodies",[]);u(this,"_meshCache",new Map);u(this,"_gravity",{x:0,y:-9.81,z:0});u(this,"lines")}removeBody(e){var i,s;if(!e)return;this.validate();const t=e[No];if(e[No]=null,t&&this.world){const r=this.objects.findIndex(o=>o===e);if(r>=0){const o=this.bodies[r];if(this.bodies.splice(r,1),this.objects.splice(r,1),o instanceof bce){const a=o;(i=this.world)==null||i.removeCollider(a,!0);const c=a.parent();if(c&&c.numColliders()<=0){const l=c[fo];this.removeBody(l)}}else o instanceof vce&&(o.numColliders()<=0?(s=this.world)==null||s.removeRigidBody(o):bi()&&(o.did_log_removing||setTimeout(()=>{o.numColliders()>0&&(o.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 s=e,r=s[No];r&&this.syncPhysicsBody(s.gameObject,r,t,i)}}updateProperties(e){this.validate();const t=this.internal_getRigidbody(e);t&&this.internalUpdateProperties(e,t)}addForce(e,t,i){this.validate();const s=this.internal_getRigidbody(e);s==null||s.addForce(t,i)}addImpulse(e,t,i){this.validate();const s=this.internal_getRigidbody(e);s==null||s.applyImpulse(t,i)}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 s=this.internal_getRigidbody(e);s==null||s.applyImpulse(t,i)}wakeup(e){this.validate();const t=this.internal_getRigidbody(e);t==null||t.wakeUp()}setAngularVelocity(e,t,i){this.validate();const s=this.internal_getRigidbody(e);s==null||s.setAngvel(t,i)}setLinearVelocity(e,t,i){this.validate();const s=this.internal_getRigidbody(e);s==null||s.setLinvel(t,i)}async initialize(e){return this.context=e,this._initializePromise||(this._initializePromise=this.internalInitialization()),this._initializePromise}async internalInitialization(){return Ns&&console.log("Initialize rapier physics engine"),"env"in{url:typeof document>"u"?require("url").pathToFileURL(__filename).href:document.currentScript&&document.currentScript.src||new URL("dist/needle-engine.light.umd.cjs",document.baseURI).href}&&{}.VITE_NEEDLE_USE_RAPIER==="false"&&Ns&&console.log("Rapier disabled"),!1}validate(){this._isInitialized||Ns&&(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,s){var a;i===void 0&&(i=1/0),s===void 0&&(s=!0);const r=this.getPhysicsRay(this.rapierRay,e,t);if(!r)return null;const o=(a=this.world)==null?void 0:a.castRay(r,i,s,void 0,void 0,void 0,void 0,c=>{var l;return!((l=c[fo])!=null&&l.gameObject.layers.isEnabled(2))});if(o){const c=r.pointAt(o.toi),l=this.raycastVectorsBuffer.get();return l.set(c.x,c.y,c.z),{point:l,collider:o.collider[fo]}}return null}raycastAndGetNormal(e,t,i,s){var a;i===void 0&&(i=1/0),s===void 0&&(s=!0);const r=this.getPhysicsRay(this.rapierRay,e,t);if(!r)return null;const o=(a=this.world)==null?void 0:a.castRayAndGetNormal(r,i,s,void 0,void 0,void 0,void 0,c=>{var l;return!((l=c[fo])!=null&&l.gameObject.layers.isEnabled(2))});if(o){const c=r.pointAt(o.toi),l=o.normal,h=this.raycastVectorsBuffer.get(),d=this.raycastVectorsBuffer.get();return h.set(c.x,c.y,c.z),d.set(l.x,l.y,l.z),{point:h,normal:d,collider:o.collider[fo]}}return null}getPhysicsRay(e,t,i){var a,c,l;const s=(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(!s)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)&&(Ns&&console.warn("Converting screenspace to raycast space",h),(l=this.context)==null||l.input.convertScreenspaceToRaycastSpace(h)),h.unproject(s),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(!s)return console.error("Can not perform raycast - no camera found"),null;o.set(e.origin.x,e.origin.y,e.origin.z);const h=wt(s);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 JI(t)),this.rapierSphere.radius=t,this.world.intersectionsWithShape(e,this.rapierIdentityRotation,this.rapierSphere,i=>{const s=i[fo],r=new mG(s.gameObject,s);return this.rapierColliderArray.push(r),!0},yM.EXCLUDE_SENSORS,void 0,void 0,void 0,i=>i[fo].gameObject.layers.isEnabled(2)==!1),this.rapierColliderArray):this.rapierColliderArray}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,s;this._meshCache.clear(),(e=this.eventQueue)!=null&&e.raw&&((t=this.eventQueue)==null||t.free()),(i=this.world)!=null&&i.bodies&&((s=this.world)==null||s.free())}async addBoxCollider(e,t,i){if(this._isInitialized||await this.initialize(e.context),!e.activeAndEnabled)return;if(!this.enabled){Ns&&console.warn("Physics are disabled");return}const s=e.gameObject,r=qn(s,this._tempPosition).multiply(i);r.multiplyScalar(.5),r.x<0&&(r.x=Math.abs(r.x)),r.y<0&&(r.y=Math.abs(r.y)),r.z<0&&(r.z=Math.abs(r.z)),r.x==0&&(r.x=1e-7),r.y==0&&(r.y=1e-7),r.z==0&&(r.z=1e-7);const o=Ni.cuboid(r.x,r.y,r.z);this.createCollider(e,o,t)}async addSphereCollider(e,t,i){if(this._isInitialized||await this.initialize(e.context),!e.activeAndEnabled)return;if(!this.enabled){Ns&&console.warn("Physics are disabled");return}const s=e.gameObject,r=qn(s,this._tempPosition).multiplyScalar(i);r.x=Math.abs(r.x);const o=Ni.ball(r.x);this.createCollider(e,o,t)}async addCapsuleCollider(e,t,i,s){if(this._isInitialized||await this.initialize(e.context),!e.activeAndEnabled)return;if(!this.enabled){Ns&&console.warn("Physics are disabled");return}const r=e.gameObject,o=qn(r,this._tempPosition);o.x=Math.abs(o.x),o.y=Math.abs(o.y);const a=Ni.capsule(i*.5*o.y-s,s*o.x);this.createCollider(e,a,t)}async addMeshCollider(e,t,i,s){var l,h,d;if(this._isInitialized||await this.initialize(e.context),!e.activeAndEnabled)return;if(!this.enabled){Ns&&console.warn("Physics are disabled");return}let r=t.geometry;if(!r){Ns&&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=SY(r));let o=r.getAttribute("position").array;const a=(d=r.index)==null?void 0:d.array;if(Math.abs(s.x-1)>1e-4||Math.abs(s.y-1)>1e-4||Math.abs(s.z-1)>1e-4){const f=r.uuid+"_"+s.x+"_"+s.y+"_"+s.z+"_"+i;if(this._meshCache.has(f))Ns&&console.warn("Use cached mesh collider"),o=this._meshCache.get(f);else{console.warn("Your model is using scaled mesh colliders which is not optimal for performance",t.name,Object.assign({},s));const p=new Float32Array(o.length);for(let g=0;g<o.length;g+=3)p[g]=o[g]*s.x,p[g+1]=o[g+1]*s.y,p[g+2]=o[g+2]*s.z;o=p,this._meshCache.set(f,p)}}const c=i?Ni.convexMesh(o):Ni.trimesh(o,a);c&&this.createCollider(e,c).setMassProperties(1,{x:0,y:0,z:0},{x:0,y:0,z:0},{x:0,y:0,z:0,w:1})}createCollider(e,t,i){if(!this.world)throw new Error("Physics world not initialized");const s=this._tempMatrix,{rigidBody:r,useExplicitMassProperties:o}=this.getRigidbody(e,this._tempMatrix);s.decompose(this._tempPosition,this._tempQuaternion,this._tempScale),qn(e.gameObject,this._tempScale),i&&(i.multiply(this._tempScale),this._tempPosition.x-=i.x,this._tempPosition.y+=i.y,this._tempPosition.z+=i.z),t.setTranslation(this._tempPosition.x,this._tempPosition.y,this._tempPosition.z),t.setRotation(this._tempQuaternion),t.setSensor(e.isTrigger);const a=e.sharedMaterial;if(a){switch(t.setRestitution(a.bounciness),a.bounceCombine){case Aa.Average:t.setRestitutionCombineRule(yo.Average);break;case Aa.Maximum:t.setRestitutionCombineRule(yo.Max);break;case Aa.Minimum:t.setRestitutionCombineRule(yo.Min);break;case Aa.Multiply:t.setRestitutionCombineRule(yo.Multiply);break}switch(t.setFriction(a.dynamicFriction),a.frictionCombine){case Aa.Average:t.setFrictionCombineRule(yo.Average);break;case Aa.Maximum:t.setFrictionCombineRule(yo.Max);break;case Aa.Minimum:t.setFrictionCombineRule(yo.Min);break;case Aa.Multiply:t.setFrictionCombineRule(yo.Multiply);break}}const c=this.world.createCollider(t,r);return c[fo]=e,e[No]=c,c.setActiveEvents(bM.COLLISION_EVENTS),c.setActiveCollisionTypes(Cb.ALL),this.objects.push(e),this.bodies.push(c),c}getRigidbody(e,t){if(!this.world)throw new Error("Physics world not initialized");let i=null,s=!1;if(e.attachedRigidbody){const r=e.attachedRigidbody;if(i=r[No],s=!0,!i){const o=r.isKinematic&&!nC;Ns&&console.log("Create rigidbody",o);const a=o?Ud.RigidBodyDesc.kinematicPositionBased():Ud.RigidBodyDesc.dynamic(),c=wt(e.attachedRigidbody.gameObject);a.setTranslation(c.x,c.y,c.z),a.setRotation(Fn(e.attachedRigidbody.gameObject)),i=this.world.createRigidBody(a),this.bodies.push(i),this.objects.push(r)}i[fo]=r,r[No]=i,this.internalUpdateProperties(r,i),this.getRigidbodyRelativeMatrix(e.gameObject,r.gameObject,t)}else{const r=Ud.RigidBodyDesc.kinematicPositionBased(),o=wt(e.gameObject);r.setTranslation(o.x,o.y,o.z),r.setRotation(Fn(e.gameObject)),i=this.world.createRigidBody(r),t.identity(),i[fo]=null}return e[Mce]=i,{rigidBody:i,useExplicitMassProperties:s}}internal_getRigidbody(e){return e[No]}internalUpdateProperties(e,t){t.enableCcd(e.collisionDetectionMode!==Y_.Discrete),t.setLinearDamping(e.drag),t.setAngularDamping(e.angularDrag),t.setGravityScale(e.useGravity?e.gravityScale:0,!0),t.setEnabledRotations(!e.lockRotationX,!e.lockRotationY,!e.lockRotationZ,!0),t.setEnabledTranslations(!e.lockPositionX,!e.lockPositionY,!e.lockPositionZ,!0),e.isKinematic?t.setBodyType(Ud.RigidBodyType.KinematicPositionBased):t.setBodyType(Ud.RigidBodyType.Dynamic)}step(e){this.world&&this.enabled&&(this._isUpdatingPhysicsWorld=!0,this.eventQueue||(this.eventQueue=new xce(!1)),e&&(this.world.timestep=tt.lerp(this.world.timestep,e,.8)),this.world.step(this.eventQueue),this._isUpdatingPhysicsWorld=!1,this.updateDebugRendering(this.world))}updateDebugRendering(e){var t,i,s;if(Ns||nC||Ece||this.debugRenderColliders===!0){if(!this.lines){const o=new gn({color:2258688,fog:!1}),a=new vt;this.lines=new jr(a,o)}this.lines.parent!==((t=this.context)==null?void 0:t.scene)&&((i=this.context)==null||i.scene.add(this.lines));const r=e.debugRender();this.lines.geometry.setAttribute("position",new rt(r.vertices,3)),this.lines.geometry.setAttribute("color",new rt(r.colors,4))}else this.lines&&((s=this.context)==null||s.scene.remove(this.lines))}postStep(){this.world&&this.enabled&&(this._isUpdatingPhysicsWorld=!0,this.syncObjects(),this._isUpdatingPhysicsWorld=!1,this.eventQueue&&!this.collisionHandler&&(this.collisionHandler=new Tce(this.world,this.eventQueue)),this.collisionHandler&&(this.collisionHandler.handleCollisionEvents(),this.collisionHandler.update()))}syncObjects(){if(!nC)for(let e=0;e<this.bodies.length;e++){const t=this.objects[e],i=this.bodies[e],s=t;if((s==null?void 0:s.isCollider)===!0&&!s.attachedRigidbody){const c=i.parent();c&&this.syncPhysicsBody(t.gameObject,c,!0,!0);continue}const r=i.translation(),o=i.rotation(),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=qn(t.gameObject);c.multiply(l),r.x-=c.x,r.y-=c.y,r.z-=c.z}Bf(t.gameObject,r.x,r.y,r.z),k2(t.gameObject,o.x,o.y,o.z,o.w)}}syncPhysicsBody(e,t,i,s){const r=wt(e,this._tempPosition),o=Fn(e,this._tempQuaternion);switch(t.bodyType()){case rm.Fixed:case rm.KinematicPositionBased:case rm.KinematicVelocityBased:i&&t.setNextKinematicTranslation(r),s&&t.setNextKinematicRotation(o);break;default:i&&t.setTranslation(r,!1),s&&t.setRotation(o,!1);break}t.wakeUp()}getRigidbodyRelativeMatrix(e,t,i,s){if(s===void 0&&(s=dm._matricesBuffer,s.length=0),e===t){const r=qn(e,this._tempPosition);i.makeScale(r.x,r.y,r.z);for(let o=s.length-1;o>=0;o--)i.multiply(s[o]);return i}return s.push(e.matrix),e.parent&&this.getRigidbodyRelativeMatrix(e.parent,t,i,s),i}addFixedJoint(e,t){if(!this.world){console.error("Physics world not initialized");return}const i=e[No],s=t[No];this.calculateJointRelativeMatrices(e.gameObject,t.gameObject,this._tempMatrix),this._tempMatrix.decompose(this._tempPosition,this._tempQuaternion,this._tempScale);const r=nf.fixed(dm.centerConnectionPos,dm.centerConnectionRot,this._tempPosition,this._tempQuaternion),o=this.world.createImpulseJoint(r,i,s,!0);Ns&&console.log("ADD FIXED JOINT",o)}addHingeJoint(e,t,i,s){if(!this.world){console.error("Physics world not initialized");return}const r=e[No],o=t[No];this.calculateJointRelativeMatrices(e.gameObject,t.gameObject,this._tempMatrix),this._tempMatrix.decompose(this._tempPosition,this._tempQuaternion,this._tempScale);const a=Ud.JointData.revolute(i,this._tempPosition,s),c=this.world.createImpulseJoint(a,r,o,!0);Ns&&console.log("ADD HINGE JOINT",c)}calculateJointRelativeMatrices(e,t,i){e.updateWorldMatrix(!0,!1),t.updateWorldMatrix(!0,!1);const s=e.matrixWorld,r=t.matrixWorld;s.elements[0]=1,s.elements[5]=1,s.elements[10]=1,r.elements[0]=1,r.elements[5]=1,r.elements[10]=1,i.copy(r).premultiply(s.invert()).invert()}};let Jh=dm;u(Jh,"_didLoadPhysicsEngine",!1),u(Jh,"_matricesBuffer",[]),u(Jh,"centerConnectionPos",{x:0,y:0,z:0}),u(Jh,"centerConnectionRot",{x:0,y:0,z:0,w:1});class Tce{constructor(e,t){u(this,"world");u(this,"eventQueue");u(this,"activeCollisions",[]);u(this,"activeCollisionsStay",[]);u(this,"activeTriggers",[]);this.world=e,this.eventQueue=t}handleCollisionEvents(){this.eventQueue&&this.world&&this.eventQueue.drainCollisionEvents((e,t,i)=>{const s=this.world.getCollider(e),r=this.world.getCollider(t),o=s[fo],a=r[fo];sC&&console.log("EVT",o.name,a.name,i,s,r),o&&a&&(i?(this.onCollisionStarted(o,s,a,r),this.onCollisionStarted(a,r,o,s)):(this.onCollisionEnded(o,a),this.onCollisionEnded(a,o)))})}update(){this.onHandleCollisionStay()}onCollisionStarted(e,t,i,s){let r=null;if(e.isTrigger||i.isTrigger)Eu(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,s,(a,c)=>{Eu(o,l=>{var d;if(l.destroyed)return;const h=l.onCollisionEnter||l.onCollisionStay||l.onCollisionExit;if(h||sC){if(!r){const f=[],p=a.normal();for(let g=0;g<a.numSolverContacts();g++){const A=a.solverContactPoint(g),v=a.contactImpulse(g);if(A){const m=a.contactDist(g),b=a.solverContactFriction(g),y=new pG(A,m,p,v,b);f.push(y),sC&&Lc.DrawDirection(A,p,16711680,3,!0)}}r=new gG(o,i,f)}if(h){const f={collider:e,component:l,collision:r};this.activeCollisions.push(f),l.onCollisionStay&&this.activeCollisionsStay.push(f),(d=l.onCollisionEnter)==null||d.call(l,r)}}})})}}onHandleCollisionStay(){for(const e of this.activeCollisionsStay){const t=e.component;if(!t.destroyed&&t.activeAndEnabled&&t.onCollisionStay){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;t.onTriggerStay(i)}}}onCollisionEnded(e,t){if(!(e.destroyed||t.destroyed)){for(let i=0;i<this.activeCollisions.length;i++){const s=this.activeCollisions[i],r=s.collider;if(r.destroyed){this.activeCollisions.splice(i,1),i--;continue}if(r===e&&s.collision.collider===t){const o=s.component;if(this.activeCollisions.splice(i,1),i--,o.activeAndEnabled&&o.onCollisionExit){const a=s.collision;o.onCollisionExit(a)}}}for(let i=0;i<this.activeCollisionsStay.length;i++){const s=this.activeCollisionsStay[i],r=s.collider;if(r.destroyed){this.activeCollisionsStay.splice(i,1),i--;continue}if(r===e&&s.collision.collider===t){const o=s.component;if(this.activeCollisionsStay.splice(i,1),i--,o.activeAndEnabled&&o.onCollisionExit){const a=s.collision;o.onCollisionExit(a)}}}for(let i=0;i<this.activeTriggers.length;i++){const s=this.activeTriggers[i],r=s.collider;if(r.destroyed){this.activeTriggers.splice(i,1),i--;continue}if(r===e&&s.otherCollider===t){const o=s.component;if(this.activeTriggers.splice(i,1),i--,o.activeAndEnabled&&o.onTriggerExit){const a=s.otherCollider;o.onTriggerExit(a)}}}}}}Object.defineProperty(qt.prototype,"fov",{get:function(){return this._fov},set:function(n){const e=n!==this._fov;this._fov=n,e&&this.view!==void 0&&this.updateProjectionMatrix()}});Object.defineProperty(qt.prototype,"near",{get:function(){return this._near},set:function(n){const e=n!==this._near;this._near=n,e&&this.view!==void 0&&this.updateProjectionMatrix()}});Object.defineProperty(qt.prototype,"far",{get:function(){return this._far},set:function(n){const e=n!==this._far;this._far=n,e&&this.view!==void 0&&this.updateProjectionMatrix()}});function Ice(n,e,t,i="image/webp",s){if(!n&&(n=Bi.Current,!n))return console.error("Can not save screenshot: No needle-engine context found or provided."),null;if(!s&&(s=n.mainCamera,!s))return console.error("No camera found"),null;const r=n.renderer.domElement.width,o=n.renderer.domElement.height;e||(e=r),t||(t=o);try{const a=n.renderer.domElement;return n.renderer.setSize(e,t,!1),s instanceof qt&&n.updateAspect(s,e,t),n.renderNow(),a.toDataURL(i)}finally{n.renderer.setSize(r,o,!1),n.updateSize()}return null}let lg=null;function Rce(n,e){if(n){if(!n.startsWith("data:image")){console.error("Can not save image: Data url is not an image",n);return}lg||(lg=document.createElement("a")),lg.href=n,lg.download=e,lg.click()}}const Eb=re("debugmissingcamera");Bi.registerCallback(Qs.MissingCamera,n=>{var r,o;Eb&&console.warn("Creating missing camera");const e=n.context.scene,t=new Te;t.name="Default Fallback Camera",e.add(t);const i=new Oi;i.sourceId=((o=(r=n.files)==null?void 0:r[0])==null?void 0:o.src)??"unknown",i.clearFlags=1,i.backgroundColor=new _i(.5,.5,.5,1),i.fieldOfView=35,i.backgroundBlurriness=.125;const s=ku(t,i,!0);return t.position.x=0,t.position.y=1,t.position.z=2,RG(n.context,s),s});Bi.registerCallback(Qs.ContextCreated,n=>{if(!n.context.mainCamera){Eb&&console.log("Will not auto-fit because a default camera exists");return}const e=n.context.domElement;if((e==null?void 0:e.cameraControls)===!0){const t=Mte(n.context.mainCamera);if((t==null?void 0:t.isCameraController)===!0){Eb&&console.log("Will not auto-fit because a camera controller exists");return}RG(n.context)}});function RG(n,e){e=e??n.mainCameraComponent;const t=e==null?void 0:e.gameObject;if(Eb&&console.log("Creating default camera controls",e==null?void 0:e.name),t){const i=R_(t,cl);i.sourceId=(e==null?void 0:e.sourceId)??"unknown";const s=n.domElement.getAttribute("auto-rotate");i.autoRotate=s!==void 0&&(s===""||s==="true"),i.autoRotateSpeed=.5;const r=n,o=()=>{r.pre_render_callbacks.splice(r.pre_render_callbacks.indexOf(o),1),i.fitCamera()};r.pre_render_callbacks.push(o)}else console.warn("Missing camera object, can not add orbit controls")}JG();const ZI={Context:Nt,glTF:{loadFromURL:QI}};globalThis.Needle!==void 0&&console.warn("Needle Engine is already imported");globalThis.Needle=ZI;function PG(n){for(const e in n)ZI[e]=n[e]}PG($q);PG(Wae);for(const n of Object.getOwnPropertyNames(se))switch(n){case"prototype":case"constructor":case"length":case"name":continue;default:ZI[n]=se[n];break}globalThis.THREE?console.warn("Threejs is already imported"):globalThis.THREE=rj;var $I={},BG={};Object.defineProperty(BG,"__esModule",{value:!0});var jx={};Object.defineProperty(jx,"__esModule",{value:!0});jx.ConstantBackoff=void 0;var Pce=function(){function n(e){this.reset=function(){},this.backoff=e}return n.prototype.next=function(){return this.backoff},n}();jx.ConstantBackoff=Pce;var Xx={};Object.defineProperty(Xx,"__esModule",{value:!0});Xx.ExponentialBackoff=void 0;var Bce=function(){function n(e,t){this.initial=e,this.expMax=t,this.expCurrent=1,this.current=this.initial}return n.prototype.next=function(){var e=this.current;return this.expMax>this.expCurrent++&&(this.current=this.current*2),e},n.prototype.reset=function(){this.expCurrent=1,this.current=this.initial},n}();Xx.ExponentialBackoff=Bce;var qx={};Object.defineProperty(qx,"__esModule",{value:!0});qx.LinearBackoff=void 0;var Dce=function(){function n(e,t,i){this.initial=e,this.increment=t,this.maximum=i,this.current=this.initial}return n.prototype.next=function(){var e=this.current,t=this.current+this.increment;return this.maximum===void 0?this.current=t:t<=this.maximum&&(this.current=t),e},n.prototype.reset=function(){this.current=this.initial},n}();qx.LinearBackoff=Dce;var DG={};Object.defineProperty(DG,"__esModule",{value:!0});var Yx={};Object.defineProperty(Yx,"__esModule",{value:!0});Yx.LRUBuffer=void 0;var Oce=function(){function n(e){this.writePtr=0,this.wrapped=!1,this.buffer=Array(e)}return n.prototype.len=function(){return this.wrapped?this.buffer.length:this.writePtr},n.prototype.cap=function(){return this.buffer.length},n.prototype.read=function(e){if(e==null||e.length===0||this.buffer.length===0||this.writePtr===0&&!this.wrapped)return 0;for(var t=this.wrapped?this.writePtr:0,i=t-1<0?this.buffer.length-1:t-1,s=0;s<e.length;s++){var r=(t+s)%this.buffer.length;if(e[s]=this.buffer[r],r===i)return s+1}return e.length},n.prototype.write=function(e){if(e==null||e.length===0||this.buffer.length===0)return 0;for(var t=e.length>this.buffer.length?e.length-this.buffer.length:0,i=0;i<e.length-t;i++)this.buffer[this.writePtr]=e[t+i],this.writePtr=(this.writePtr+1)%this.buffer.length,this.writePtr===0&&(this.wrapped=!0);return e.length},n.prototype.forEach=function(e){if(this.writePtr===0&&!this.wrapped)return 0;for(var t=this.wrapped?this.writePtr:0,i=this.wrapped?t-1<0?this.buffer.length-1:t-1:this.writePtr-1,s=this.len();e(this.buffer[t]),t!==i;)t=(t+1)%this.buffer.length;return s},n.prototype.clear=function(){this.writePtr=0,this.wrapped=!1},n}();Yx.LRUBuffer=Oce;var Kx={};Object.defineProperty(Kx,"__esModule",{value:!0});Kx.TimeBuffer=void 0;var kce=function(){function n(e){this.maxAge=e}return n.prototype.cap=function(){return Number.POSITIVE_INFINITY},n.prototype.len=function(){this.forwardTail();for(var e=this.tail,t=0;e!==void 0;)t++,e=e.n;return t},n.prototype.read=function(e){if(this.forwardTail(),e.length===0)return 0;for(var t=this.tail,i=0;t!==void 0&&(e[i++]=t.e,i!==e.length);)t=t.n;return i},n.prototype.write=function(e){for(var t=0;t<e.length;t++)this.putElement(e[t]);return e.length},n.prototype.forEach=function(e){this.forwardTail();for(var t=this.tail,i=0;t!==void 0;)e(t.e),i++,t=t.n;return i},n.prototype.putElement=function(e){var t={e,t:Date.now(),n:void 0};this.tail===void 0&&(this.tail=t),this.head===void 0?this.head=t:(this.head.n=t,this.head=t)},n.prototype.forwardTail=function(){if(this.tail!==void 0)for(var e=Date.now();e-this.tail.t>this.maxAge&&(this.tail===this.head?(this.tail=void 0,this.head=void 0):this.tail=this.tail.n,this.tail!==void 0););},n.prototype.clear=function(){},n}();Kx.TimeBuffer=kce;var eR={};(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.Websocket=n.WebsocketEvents=void 0;var e;(function(i){i.open="open",i.close="close",i.error="error",i.message="message",i.retry="retry"})(e=n.WebsocketEvents||(n.WebsocketEvents={}));var t=function(){function i(s,r,o,a){var c=this;this.eventListeners={open:[],close:[],error:[],message:[],retry:[]},this.closedByUser=!1,this.retries=0,this.handleOpenEvent=function(l){return c.handleEvent(e.open,l)},this.handleCloseEvent=function(l){return c.handleEvent(e.close,l)},this.handleErrorEvent=function(l){return c.handleEvent(e.error,l)},this.handleMessageEvent=function(l){return c.handleEvent(e.message,l)},this.url=s,this.protocols=r,this.buffer=o,this.backoff=a,this.tryConnect()}return Object.defineProperty(i.prototype,"underlyingWebsocket",{get:function(){return this.websocket},enumerable:!1,configurable:!0}),i.prototype.send=function(s){var r;this.closedByUser||(this.websocket===void 0||this.websocket.readyState!==this.websocket.OPEN?(r=this.buffer)===null||r===void 0||r.write([s]):this.websocket.send(s))},i.prototype.close=function(s,r){var o;this.closedByUser=!0,(o=this.websocket)===null||o===void 0||o.close(s,r)},i.prototype.addEventListener=function(s,r,o){var a={listener:r,options:o},c=this.eventListeners[s];c.push(a)},i.prototype.removeEventListener=function(s,r,o){this.eventListeners[s]=this.eventListeners[s].filter(function(a){return a.listener!==r&&(a.options===void 0||a.options!==o)})},i.prototype.dispatchEvent=function(s,r){var o=this,a=this.eventListeners[s],c=[];a.forEach(function(l){l.listener(o,r),l.options!==void 0&&l.options.once&&c.push(l)}),c.forEach(function(l){return o.removeEventListener(s,l.listener,l.options)})},i.prototype.tryConnect=function(){this.websocket!==void 0&&(this.websocket.removeEventListener(e.open,this.handleOpenEvent),this.websocket.removeEventListener(e.close,this.handleCloseEvent),this.websocket.removeEventListener(e.error,this.handleErrorEvent),this.websocket.removeEventListener(e.message,this.handleMessageEvent),this.websocket.close()),this.websocket=new WebSocket(this.url,this.protocols),this.websocket.addEventListener(e.open,this.handleOpenEvent),this.websocket.addEventListener(e.close,this.handleCloseEvent),this.websocket.addEventListener(e.error,this.handleErrorEvent),this.websocket.addEventListener(e.message,this.handleMessageEvent)},i.prototype.handleEvent=function(s,r){var o,a,c;switch(s){case e.close:this.closedByUser||this.reconnect();break;case e.open:this.retries=0,(o=this.backoff)===null||o===void 0||o.reset(),(a=this.buffer)===null||a===void 0||a.forEach(this.send.bind(this)),(c=this.buffer)===null||c===void 0||c.clear();break}this.dispatchEvent(s,r)},i.prototype.reconnect=function(){var s=this;if(this.backoff!==void 0){var r=this.backoff.next();setTimeout(function(){s.dispatchEvent(e.retry,new CustomEvent(e.retry,{detail:{retries:++s.retries,backoff:r}})),s.tryConnect()},r)}},i}();n.Websocket=t})(eR);var Jx={};Object.defineProperty(Jx,"__esModule",{value:!0});Jx.WebsocketBuilder=void 0;var Nd=eR,Lce=function(){function n(e){this.ws=null,this.onOpenListeners=[],this.onCloseListeners=[],this.onErrorListeners=[],this.onMessageListeners=[],this.onRetryListeners=[],this.url=e}return n.prototype.withProtocols=function(e){return this.protocols=e,this},n.prototype.withBackoff=function(e){return this.backoff=e,this},n.prototype.withBuffer=function(e){return this.buffer=e,this},n.prototype.onOpen=function(e,t){return this.onOpenListeners.push({listener:e,options:t}),this},n.prototype.onClose=function(e,t){return this.onCloseListeners.push({listener:e,options:t}),this},n.prototype.onError=function(e,t){return this.onErrorListeners.push({listener:e,options:t}),this},n.prototype.onMessage=function(e,t){return this.onMessageListeners.push({listener:e,options:t}),this},n.prototype.onRetry=function(e,t){return this.onRetryListeners.push({listener:e,options:t}),this},n.prototype.build=function(){var e=this;return this.ws!==null?this.ws:(this.ws=new Nd.Websocket(this.url,this.protocols,this.buffer,this.backoff),this.onOpenListeners.forEach(function(t){var i;return(i=e.ws)===null||i===void 0?void 0:i.addEventListener(Nd.WebsocketEvents.open,t.listener,t.options)}),this.onCloseListeners.forEach(function(t){var i;return(i=e.ws)===null||i===void 0?void 0:i.addEventListener(Nd.WebsocketEvents.close,t.listener,t.options)}),this.onErrorListeners.forEach(function(t){var i;return(i=e.ws)===null||i===void 0?void 0:i.addEventListener(Nd.WebsocketEvents.error,t.listener,t.options)}),this.onMessageListeners.forEach(function(t){var i;return(i=e.ws)===null||i===void 0?void 0:i.addEventListener(Nd.WebsocketEvents.message,t.listener,t.options)}),this.onRetryListeners.forEach(function(t){var i;return(i=e.ws)===null||i===void 0?void 0:i.addEventListener(Nd.WebsocketEvents.retry,t.listener,t.options)}),this.ws)},n}();Jx.WebsocketBuilder=Lce;(function(n){var e=ay&&ay.__createBinding||(Object.create?function(i,s,r,o){o===void 0&&(o=r),Object.defineProperty(i,o,{enumerable:!0,get:function(){return s[r]}})}:function(i,s,r,o){o===void 0&&(o=r),i[o]=s[r]}),t=ay&&ay.__exportStar||function(i,s){for(var r in i)r!=="default"&&!Object.prototype.hasOwnProperty.call(s,r)&&e(s,i,r)};Object.defineProperty(n,"__esModule",{value:!0}),t(BG,n),t(jx,n),t(Xx,n),t(qx,n),t(DG,n),t(Yx,n),t(Kx,n),t(eR,n),t(Jx,n)})($I);const Fce=mA($I),Uce=LG({__proto__:null,default:Fce},[$I]),co={node:"node",material:"material",camera:"camera",light:"light"},Wh="KHR_animation_pointer",Nce={CUBICSPLINE:void 0,LINEAR:Ha,STEP:eh},bk=Ut.findNode;let _k=!1;class zce{constructor(e){this.parser=e,this.name=Wh,this.animationPointerResolver=null}setAnimationPointerResolver(e){return this.animationPointerResolver=e,this}_patchPropertyBindingFindNode(){_k||(_k=!0,Ut.findNode=function(e,t){if(t.startsWith(".materials.")){const i=t.substring(11).substring(t.indexOf(".")),s=i.indexOf("."),r=s<0?i:i.substring(0,s);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 s;for(let r=1;r<i.length;r++){const o=i[r];if(o.length==36)s=e.getObjectByProperty("uuid",o);else if(s&&s[o]){const c=Number.parseInt(o);let l=o;c>=0&&(l=c),s=s[l]}else{const c=e.getObjectByName(o);c&&(s=c)}}if(!s){const r=bk(e,i[2]);return r||console.warn(Wh+": Property binding not found",t,e,e.name,i),r}return s}return bk(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[Wh]&&t.path&&t.path==="pointer";if(!i)return null;let s,r=co.node,o;if(i){const c=t.extensions[Wh];let l=c.pointer;if(!l){console.warn("Invalid path",c,t);return}if(l.startsWith("/materials/")?r=co.material:l.startsWith("/extensions/KHR_lights_punctual/lights/")?r=co.light:l.startsWith("/cameras/")&&(r=co.camera),o=this._tryResolveTargetId(l,r),o===null||isNaN(o)){console.warn("Failed resolving animation node id: "+o,l);return}switch(r){case co.material:const d=("/materials/"+o.toString()+"/").length,f=l.substring(0,d);switch(s=l.substring(d),s){case"pbrMetallicRoughness/baseColorFactor":s="color";break;case"pbrMetallicRoughness/roughnessFactor":s="roughness";break;case"pbrMetallicRoughness/metallicFactor":s="metalness";break;case"emissiveFactor":s="emissive";break;case"alphaCutoff":s="alphaTest";break;case"occlusionTexture/strength":s="aoMapIntensity";break;case"normalTexture/scale":s="normalScale";break;case"pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/scale":s="map/repeat";break;case"pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/offset":s="map/offset";break;case"emissiveTexture/extensions/KHR_texture_transform/scale":s="emissiveMap/repeat";break;case"emissiveTexture/extensions/KHR_texture_transform/offset":s="emissiveMap/offset";break;case"extensions/KHR_materials_emissive_strength/emissiveStrength":s="emissiveIntensity";break;case"extensions/KHR_materials_transmission/transmissionFactor":s="transmission";break;case"extensions/KHR_materials_ior/ior":s="ior";break;case"extensions/KHR_materials_volume/thicknessFactor":s="thickness";break;case"extensions/KHR_materials_volume/attenuationColor":s="attenuationColor";break;case"extensions/KHR_materials_volume/attenuationDistance":s="attenuationDistance";break;case"extensions/KHR_materials_iridescence/iridescenceFactor":s="iridescence";break;case"extensions/KHR_materials_iridescence/iridescenceIor":s="iridescenceIOR";break;case"extensions/KHR_materials_iridescence/iridescenceThicknessMinimum":s="iridescenceThicknessRange[0]";break;case"extensions/KHR_materials_iridescence/iridescenceThicknessMaximum":s="iridescenceThicknessRange[1]";break;case"extensions/KHR_materials_clearcoat/clearcoatFactor":s="clearcoat";break;case"extensions/KHR_materials_clearcoat/clearcoatRoughnessFactor":s="clearcoatRoughness";break;case"extensions/KHR_materials_sheen/sheenColorFactor":s="sheenColor";break;case"extensions/KHR_materials_sheen/sheenRoughnessFactor":s="sheenRoughness";break;case"extensions/KHR_materials_specular/specularFactor":s="specularIntensity";break;case"extensions/KHR_materials_specular/specularColorFactor":s="specularColor";break}l=f+s;break;case co.node:const p=("/nodes/"+o.toString()+"/").length,g=l.substring(0,p);switch(s=l.substring(p),s){case"translation":s="position";break;case"rotation":s="quaternion";break;case"scale":s="scale";break;case"weights":s="morphTargetInfluences";break}l=g+s;break;case co.light:const A=("/extensions/KHR_lights_punctual/lights/"+o.toString()+"/").length;switch(s=l.substring(A),s){case"color":break;case"intensity":break;case"spot/innerConeAngle":s="penumbra";break;case"spot/outerConeAngle":s="angle";break;case"range":s="distance";break}l="/lights/"+o.toString()+"/"+s;break;case co.camera:const v=("/cameras/"+o.toString()+"/").length,m=l.substring(0,v);switch(s=l.substring(v),s){case"perspective/yfov":s="fov";break;case"perspective/znear":case"orthographic/znear":s="near";break;case"perspective/zfar":case"orthographic/zfar":s="far";break;case"perspective/aspect":s="aspect";break;case"orthographic/xmag":s="zoom";break;case"orthographic/ymag":s="zoom";break}l=m+s;break}const h=this.animationPointerResolver;h&&h.resolvePath&&(l=h.resolvePath(l)),t.extensions[Wh].pointer=l}if(o===null||isNaN(o)){console.warn("Failed resolving animation node id: "+o,t);return}let a;return r===co.node?a=this.parser.getDependency("node",o):r===co.material?a=this.parser.getDependency("material",o):r===co.light?a=this.parser.getDependency("light",o):r===co.camera?a=this.parser.getDependency("camera",o):console.error("Unhandled type",r),a}createAnimationTracksWithAnimationPointer(e,t,i,s,r){if(!(r.extensions&&r.extensions[Wh]&&r.path&&r.path==="pointer"))return null;let a=r.extensions[Wh].pointer;if(!a)return null;const c=[];a=a.replaceAll("/",".");const l=a.split(".");var d=e.name!==void 0&&e.name!==null?e.name:e.uuid;if(l[2]=d,l[3]==="morphTargetInfluences"&&e.type==="Group"){for(const p of e.children)p instanceof Bu&&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=th;break;case 2:case 3:g=Yc;break;case 4:a.endsWith(".quaternion")?g=Va:g=u_;break}const A=s.interpolation!==void 0?Nce[s.interpolation]:Ha;let v=p._getArrayFromAccessor(i);a.endsWith(".fov")&&(v=v.map(b=>b/Math.PI*180));const m=new g(a,t.array,v,A);if(A==="CUBICSPLINE"&&p._createCubicSplineTrackInterpolant(m),c.push(m),a&&i.itemSize===4&&a.startsWith(".materials.")&&a.endsWith(".color")){const b=new Float32Array(v.length/4);for(let _=0,C=v.length/4;_<C;_+=1)b[_]=v[_*4+3];const y=new g(a.replace(".color",".opacity"),t.array,b,A);A==="CUBICSPLINE"&&p._createCubicSplineTrackInterpolant(m),c.push(y)}}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,s=this.parser,r=i.animations[e],o=r.name?r.name:"animation_"+e,a=[],c=[],l=[],h=[],d=[];for(let f=0,p=r.channels.length;f<p;f++){const g=r.channels[f],A=r.samplers[g.sampler],v=g.target,m=r.parameters!==void 0?r.parameters[A.input]:A.input,b=r.parameters!==void 0?r.parameters[A.output]:A.output;let y=t.loadAnimationTargetFromChannelWithAnimationPointer(g);y||(y=t.loadAnimationTargetFromChannel(g)),a.push(y),c.push(s.getDependency("accessor",m)),l.push(s.getDependency("accessor",b)),h.push(A),d.push(v)}return Promise.all([Promise.all(a),Promise.all(c),Promise.all(l),Promise.all(h),Promise.all(d)]).then(function(f){const p=f[0],g=f[1],A=f[2],v=f[3],m=f[4],b=[];for(let y=0,_=p.length;y<_;y++){const C=p[y],M=g[y],I=A[y],R=v[y],E=m[y];if(C===void 0)continue;C.updateMatrix&&(C.updateMatrix(),C.matrixAutoUpdate=!0);let T=t.createAnimationTracksWithAnimationPointer(C,M,I,R,E);if(T||(T=s._createAnimationTracks(C,M,I,R,E)),T)for(let O=0;O<T.length;O++)b.push(T[O])}return new Ks(o,void 0,b)})}}const Gce=Object.freeze(Object.defineProperty({__proto__:null,GLTFAnimationPointerExtension:zce},Symbol.toStringTag,{value:"Module"}));exports.$physicsKey=fce;exports.ActionBuilder=di;exports.ActionCollection=fT;exports.ActionModel=kr;exports.Addressables=XU;exports.AlignmentConstraint=MA;exports.AmbientMode=ff;exports.Animation=Wr;exports.AnimationCurve=Fu;exports.AnimationExtension=W_;exports.AnimationTrackHandler=cx;exports.Animator=Bs;exports.AnimatorConditionMode=Nl;exports.AnimatorController=Mu;exports.AnimatorControllerParameterType=pT;exports.AnimatorStateInfo=y0;exports.Antialiasing=NA;exports.Application=JU;exports.ApplicationEvents=ob;exports.AssetDatabase=nU;exports.AssetReference=Un;exports.AttachedObject=wo;exports.AttachedObjectEvents=yb;exports.AudioExtension=hx;exports.AudioListener=zf;exports.AudioSource=Cn;exports.AudioTrackHandler=yu;exports.AvatarBlink_Simple=zu;exports.AvatarEyeLook_Rotation=dp;exports.AvatarLoader=q_;exports.AvatarMarker=Kn;exports.AvatarModel=X_;exports.Avatar_Brain_LookAt=Lm;exports.Avatar_MouthShapes=zA;exports.Avatar_MustacheShake=KT;exports.Avatar_POI=Zs;exports.Axes=$d;exports.AxesHelper=fp;exports.BaseUIComponent=ta;exports.BasicIKConstraint=$T;exports.BehaviorExtension=dx;exports.BehaviorModel=ls;exports.Behaviour=Me;exports.Bloom=Gu;exports.BoxCollider=HA;exports.BoxGizmo=Nu;exports.BoxHelperComponent=xo;exports.Button=ll;exports.CallInfo=kf;exports.Camera=Oi;exports.Canvas=us;exports.CanvasGroup=oh;exports.CapsuleCollider=rh;exports.ChangeMaterialOnClick=mp;exports.ChangeTransformOnClick=Qu;exports.CharacterController=Wu;exports.CharacterControllerInput=ul;exports.ChromaticAberration=qA;exports.CircularBuffer=Ga;exports.ClearFlags=yz;exports.ClipExtrapolation=va;exports.Collider=Ya;exports.Collision=gG;exports.CollisionDetectionMode=Y_;exports.ColorAdjustments=bh;exports.ColorBySpeedModule=ju;exports.ColorOverLifetimeModule=YA;exports.Component=dh;exports.ComponentEvents=vA;exports.ComponentLifecycleEvents=yA;exports.ConnectionEvents=LF;exports.ContactPoint=pG;exports.Context=Nt;exports.ContextArgs=Kq;exports.ContextEvent=Qs;exports.ContextRegistry=Bi;exports.ControlTrackHandler=lx;exports.ControllerEvents=_c;exports.ControllerType=Af;exports.CustomBranding=Sh;exports.CustomShader=Ir;exports.DefaultReflectionMode=rb;exports.Deletable=hI;exports.DeleteBox=vx;exports.DepthOfField=ca;exports.DeviceFlag=yx;exports.DocumentExtension=uI;exports.DragControls=_p;exports.DropListener=JA;exports.Duplicatable=Yu;exports.EXTENSION_NAME=p0;exports.EmissionModule=Ja;exports.EmphasizeOnClick=vp;exports.EngineLoadingView=Yg;exports.EventList=cs;exports.EventListEvent=H_;exports.EventSystem=qs;exports.EventTrigger=_x;exports.FieldWithDefault=cT;exports.FileSpawnModel=Dz;exports.File_Event=Bz;exports.FixedJoint=vI;exports.FlyControls=yI;exports.Fog=xp;exports.FrameEvent=xr;exports.GENERATOR=E_;exports.GameObject=se;exports.Gizmos=Lc;exports.GltfExport=Ic;exports.GltfExportBox=xI;exports.GltfLoadEvent=_u;exports.GltfLoadEventType=cG;exports.Gradient=_h;exports.Graphic=Hu;exports.GraphicRaycaster=qT;exports.Graphics=Qo;exports.GridHelper=wp;exports.GridLayoutGroup=oI;exports.GroundProjectedEnv=Ku;exports.GroupActionModel=Vl;exports.HideFlags=lU;exports.HideOnStart=cI;exports.HingeJoint=ZA;exports.HorizontalLayoutGroup=rI;exports.HostData=V9;exports.Image=gp;exports.ImageReference=df;exports.ImageReferenceSerializer=qU;exports.InheritVelocityModule=wh;exports.Input=D2;exports.InputEvents=_a;exports.InputField=Ju;exports.InstancingUtil=vr;exports.InstantiateEvent=zF;exports.InstantiateIdProvider=Js;exports.InstantiateOptions=Qa;exports.Interactable=np;exports.JoinedRoomResponse=I9;exports.KeyEventArgs=n0;exports.LODGroup=ev;exports.LODModel=Zu;exports.LeftRoomResponse=R9;exports.Light=Sr;exports.LightData=KU;exports.LimitVelocityOverLifetimeModule=In;exports.LoadingElementOptions=hY;exports.LogStats=SI;exports.LogType=Jo;exports.LookAt=$u;exports.LookAtConstraint=IA;exports.MainModule=ms;exports.MarkerType=YT;exports.MaskableGraphic=WA;exports.Mathf=tt;exports.MeshCollider=VA;exports.MeshRenderer=V_;exports.MinMaxCurve=lt;exports.MinMaxGradient=wr;exports.NEEDLE_progressive=Or;exports.NeedleEngine=Bi;exports.NeedleEngineHTMLElement=WI;exports.NeedleGltfLoader=HI;exports.NeedlePatchesKey=c0;exports.NestedGltf=Cx;exports.NetworkConnection=UF;exports.Networking=qu;exports.NoiseModule=Ai;exports.ObjectRaycaster=el;exports.ObjectUtils=Jz;exports.OffsetConstraint=ed;exports.OpenURL=Sp;exports.OrbitControls=cl;exports.Outline=pp;exports.OwnershipEvent=FF;exports.OwnershipModel=C_;exports.Padding=Ah;exports.ParticleBurst=qm;exports.ParticleSubEmitter=Bx;exports.ParticleSystem=En;exports.ParticleSystemRenderer=fl;exports.PeerNetworking=kF;exports.Physics=H2;exports.PhysicsMaterialCombine=Aa;exports.PixelationEffect=nv;exports.PlayAnimationOnClick=yh;exports.PlayAudioOnClick=yp;exports.PlayableDirector=Xc;exports.PlayerColor=Iu;exports.PlayerState=bu;exports.PlayerStateEvent=oG;exports.PlayerSync=Vx;exports.PlayerView=sN;exports.PlayerViewManager=rN;exports.PointerEventData=Fc;exports.PointerType=B2;exports.PostProcessingEffect=Os;exports.PostProcessingHandler=Dx;exports.PreliminaryAction=bp;exports.PreliminaryTrigger=jA;exports.PrimitiveType=OI;exports.ProgressiveLoadingInfo=SN;exports.PromiseAllWithErrors=Pk;exports.PromiseErrorResult=Rk;exports.RGBAColor=_i;exports.RapierPhysics=Jh;exports.RawImage=px;exports.RaycastOptions=sa;exports.Raycaster=lp;exports.Rect=iI;exports.RectTransform=tr;exports.ReflectionProbe=ip;exports.RegisteredAnimationInfo=Q_;exports.RemoteSkybox=tl;exports.RenderTexture=ql;exports.RenderTextureSerializer=MN;exports.Renderer=Hi;exports.RendererData=YU;exports.RendererLightmap=km;exports.Rigidbody=Yi;exports.RigidbodyConstraints=on;exports.RoomEvents=nn;exports.RotationBySpeedModule=Jr;exports.RotationOverLifetimeModule=Po;exports.SceneLightSettings=lb;exports.SceneSwitcher=Cr;exports.ScreenCapture=sv;exports.ScreenSpaceAmbientOcclusion=pl;exports.ScreenSpaceAmbientOcclusionN8=ha;exports.SendQueue=dr;exports.SetActiveOnClick=Ap;exports.ShadowCatcher=av;exports.ShapeModule=mn;exports.SignalAsset=LA;exports.SignalReceiver=up;exports.SignalReceiverEvent=hp;exports.SignalTrackHandler=jm;exports.Size=tI;exports.SizeBySpeedModule=rr;exports.SizeOverLifetimeModule=xh;exports.SkinnedMeshRenderer=lT;exports.SmoothFollow=Ch;exports.SpatialHtml=kI;exports.SpatialTrigger=lv;exports.SpatialTriggerReceiver=za;exports.SpectatorCamera=Lx;exports.SphereCollider=GA;exports.SphereIntersection=G2;exports.SphereOverlapResult=mG;exports.Sprite=gl;exports.SpriteData=Tp;exports.SpriteRenderer=$a;exports.SpriteSheet=hv;exports.StateMachineBehaviour=gK;exports.SubEmitterSystem=$m;exports.SyncedCamera=Fx;exports.SyncedRoom=Eh;exports.SyncedTransform=nh;exports.TapGestureTrigger=lI;exports.TeleportTarget=sx;exports.TestRunner=LI;exports.TestSimulateUserData=FI;exports.Text=or;exports.TextBuilder=mx;exports.TextExtension=KA;exports.TextureSheetAnimationModule=As;exports.TiltShiftEffect=ec;exports.Time=V2;exports.ToneMapping=dv;exports.TrackHandler=FA;exports.TrackType=Rr;exports.TrailModule=Qi;exports.TransformData=Yl;exports.TransformGizmo=id;exports.TriggerBuilder=yr;exports.TriggerModel=Wc;exports.TypeStore=q;exports.UIRaycastUtils=Nf;exports.UIRootComponent=kA;exports.USDObject=gr;exports.USDZExporter=$r;exports.USDZText=Ql;exports.USDZUIExtension=Ax;exports.Upload_Result=wE;exports.UriSerializer=TN;exports.UsageMarker=sp;exports.UserJoinedOrLeftRoomModel=P9;exports.VERSION=kc;exports.VRUserState=qo;exports.VariantAction=dT;exports.VelocityOverLifetimeModule=Ki;exports.VerticalLayoutGroup=sI;exports.VideoPlayer=vs;exports.ViewDevice=Na;exports.Vignette=nd;exports.VisibilityAction=XA;exports.Voip=rl;exports.Volume=Nx;exports.VolumeParameter=Rt;exports.VolumeProfile=UA;exports.WaitForFrames=Zre;exports.WaitForSeconds=Yz;exports.Watch=xf;exports.WebAR=vu;exports.WebARCameraBackground=zx;exports.WebARSessionRoot=Wa;exports.WebXR=Et;exports.WebXRAvatar=Oa;exports.WebXRController=en;exports.WebXREvent=Ci;exports.WebXRImageTracking=Gx;exports.WebXRImageTrackingModel=ml;exports.WebXRPlaneTracking=fv;exports.WebXRSync=Wm;exports.WebXRTrackedImage=Rc;exports.XRFlag=Fr;exports.XRGrabModel=Hx;exports.XRGrabRendering=NI;exports.XRRig=rx;exports.XRSessionMode=Dm;exports.XRState=Xs;exports.XRStateFlag=un;exports.__Ignore=zI;exports.__internalNotifyObjectDestroyed=cU;exports.activeInHierarchyFieldName=Qc;exports.addAttributeChangeCallback=Tk;exports.addCustomExtension=A7;exports.addFile=Oz;exports.addFileFromUrl=kz;exports.addGltfLoadEventListener=tce;exports.addNewComponent=ku;exports.addPatch=D_;exports.apply=B_;exports.applyHMRChanges=dce;exports.beginListenDestroy=VF;exports.beginListenFileSpawn=Lz;exports.beginListenInstantiate=QF;exports.binaryIdentifierCasts=T1;exports.build_scene_functions=Yq;exports.builtinComponentKeyName=eu;exports.calculateProgress01=iT;exports.colorSerializer=x7;exports.componentSerializer=g0;exports.copyTexture=z2;exports.createGLTFLoader=VI;exports.createMotion=VN;exports.debugNet=Gs;exports.debugOwner=yg;exports.deepClone=Bb;exports.delay=sA;exports.deserializeObject=K0;exports.destroy=Kc;exports.destroyComponentInstance=KF;exports.detectARSupport=Az;exports.detectVRSupport=vz;exports.disposeObjectResources=Ri;exports.download=WU;exports.download_file=K1;exports.editorGuidKeyName=Vg;exports.effectsOrder=uM;exports.eventListSerializer=M7;exports.findByGuid=wA;exports.findObjectOfType=ZF;exports.findObjectsOfType=$F;exports.findResourceUsers=z1;exports.foreachComponent=Eu;exports.foreachComponentEnumerator=H1;exports.forward=Fj;exports.generateSeed=I_;exports.getComponent=Kf;exports.getComponentInChildren=_A;exports.getComponentInParent=Im;exports.getComponents=bA;exports.getComponentsInChildren=xA;exports.getComponentsInParent=P_;exports.getIp=XG;exports.getIpAndLocation=qG;exports.getIpCloudflare=jG;exports.getLoader=ea;exports.getOrAddComponent=R_;exports.getParam=re;exports.getPath=GG;exports.getPeerOptions=C9;exports.getPeerjsInstance=O1;exports.getResourceUserCount=r6;exports.getUrlParams=nA;exports.getWorldDirection=Nj;exports.getWorldEuler=L2;exports.getWorldPosition=wt;exports.getWorldQuaternion=Fn;exports.getWorldRotation=b_;exports.getWorldScale=qn;exports.hasIndieLicense=tT;exports.hasProLicense=pf;exports.hash=Y1;exports.instantiate=SA;exports.isActiveInHierarchy=hU;exports.isActiveSelf=Jf;exports.isAnimationAction=N2;exports.isDebugMode=UG;exports.isDestroyed=G1;exports.isDevEnvironment=bi;exports.isDisposed=n6;exports.isHostedOnGlitch=Bk;exports.isHotReloading=cce;exports.isLocalNetwork=$s;exports.isMobileDevice=nl;exports.isMozillaXR=L0;exports.isQuest=QG;exports.isResourceTrackingEnabled=rU;exports.isSafari=wc;exports.isUsingInstancing=k_;exports.isiOS=pm;exports.loadSync=QI;exports.logHierarchy=Z0;exports.lookAtInverse=Dj;exports.makeId=zG;exports.makeIdFromRandomWords=Ck;exports.markAsInstancedRendered=uU;exports.moveComponentInstance=F1;exports.nameof=FG;exports.nameofFactory=k0;exports.objectSerializer=EN;exports.parseSync=hG;exports.prefix=hJ;exports.pushState=wk;exports.randomNumber=Sk;exports.registerBinaryType=w_;exports.registerComponent=G_;exports.registerComponentExtension=aT;exports.registerCustomEffectType=Ro;exports.registerExtensions=CN;exports.registerHotReloadType=lce;exports.registerLoader=J1;exports.registerPrefabProvider=jF;exports.registerType=bj;exports.relativePathPrefix=Mk;exports.removeAttributeChangeCallback=Ik;exports.removeComponent=L1;exports.removeCustomExtension=v7;exports.removeGltfLoadEventListener=ice;exports.removePatch=e6;exports.resolveUrl=il;exports.sanitizeString=Ek;exports.saveImage=Rce;exports.screenshot=Ice;exports.sendDestroyed=HF;exports.serializable=x;exports.serializeObject=R2;exports.serializeable=tp;exports.setActive=Wg;exports.setAllowOverlayMessages=KG;exports.setDestroyed=fU;exports.setDevEnvironment=pj;exports.setDisposable=N1;exports.setOrAddParamsToUrl=fm;exports.setParam=NG;exports.setParamWithoutReload=xk;exports.setPeerOptions=E9;exports.setResourceTrackingEnabled=i6;exports.setState=SM;exports.setWorldEuler=F2;exports.setWorldPosition=fn;exports.setWorldPositionXYZ=Bf;exports.setWorldQuaternion=_r;exports.setWorldQuaternionXYZW=k2;exports.setWorldRotation=U2;exports.setWorldRotationXYZ=__;exports.setWorldScale=rE;exports.showBalloonMessage=_n;exports.showBalloonWarning=nr;exports.showDebugConsole=C1;exports.slerp=O2;exports.syncDestroy=T_;exports.syncField=BI;exports.syncInstantiate=k1;exports.textureToCanvas=Gj;exports.tryCastBinary=Q2;exports.tryFindObject=_f;exports.tryFindObjectByName=uG;exports.tryFindScript=nce;exports.tryGetGuid=W2;exports.unregisterHotReloadType=hce;exports.upload_file=QU;exports.validate=Xr;
|
|
6612
|
+
`,this.shadowRoot&&this.shadowRoot.appendChild(t.content.cloneNode(!0)),this._context=new Nt({domElement:this}),this.addEventListener("error",this.onError)}static get observedAttributes(){return rce}get loadingProgress01(){return this._loadingProgress01}get loadingFinished(){return this.loadingProgress01>.999}get cameraControls(){const t=this.getAttribute("camera-controls");return!(t===null||t==="False"||t==="false"||t==="0")}getContext(){return new Promise((t,i)=>{if(this._context&&this.loadingFinished)t(this._context);else{const s=()=>{this.removeEventListener("loadfinished",s),this._context&&this.loadingFinished&&t(this._context)};this.addEventListener("loadfinished",s)}})}get context(){return this._context}get Context(){return this._context}async connectedCallback(){if(ts&&console.log("<needle-engine> connected"),this.onSetupDesktop(),!this.getAttribute("src")){const i=globalThis["needle:codegen_files"];i&&(ts&&console.log('globalThis["needle:codegen_files"]',i),this.setAttribute("src",i))}const t=this._loadId;setTimeout(()=>{this.isConnected!==!1&&t===this._loadId&&this.onLoad()},1),kc!=null&&kc.length&&this.setAttribute("version",kc)}disconnectedCallback(){var i;this._didFullyLoad=!1;const t=this.getAttribute("keep-alive");ts&&console.warn("<needle-engine> disconnected, keep-alive:",t),(t===void 0||t!=="true")&&(console.warn("<needle-engine> dispose!"),(i=this._context)==null||i.dispose(),this._context=null,this._lastSourceFiles=null,this._loadId+=1)}attributeChangedCallback(t,i,s){switch(ts&&console.log("attributeChangedCallback",t,i,s),t){case"src":ts&&console.warn("src changed to type:",typeof s,', from "',i,'" to "',s,'"'),this.onLoad();break;case"hash":this._context&&(this._context.hash=s);break;case"loadstart":case"progress":case"loadfinished":typeof s=="string"&&s.length>0&&(ts&&console.log(t+" attribute changed",s),this.registerEventFromAttribute(t,s));break;case"dracoDecoderPath":ts&&console.log("dracoDecoderPath",s),oD(s);break;case"dracoDecoderType":s==="wasm"||s==="js"?(ts&&console.log("dracoDecoderType",s),aD(s)):console.error("Invalid dracoDecoderType",s,"expected js or wasm");break;case"ktx2DecoderPath":ts&&console.log("ktx2DecoderPath",s),cD(s);break}}async onLoad(){var f,p;if(!this.isConnected)return;if(this._context||(ts&&console.warn("Create new context"),this._context=new Nt({domElement:this})),!this._context){console.error("Needle Engine: Context not initialized");return}const t=this.getSourceFiles();if(t==null||t.length<=0)ts&&console.warn("Clear scene",t),this._context.clear();else if(!this.checkIfSourceHasChanged(t,this._lastSourceFiles))return;this._lastSourceFiles=t;const i=++this._loadId,s=this.getAttribute("alias");this.classList.add("loading");const r=Of();this.ensureLoadStartIsRegistered();let o=this.dispatchEvent(new CustomEvent("loadstart",{detail:{context:this._context,alias:s},cancelable:!0}));o===!1&&!r&&(bi()||(o=!0),console.warn("Needle Engine: You need a commercial license to override the default loading view. Visit https://needle.tools/pricing"),bi()&&nr('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 Yg(this)),o&&(this._didFullyLoad!==!0?(f=this._loadingView)==null||f.onLoadingBegin("begin load"):setTimeout(()=>{this._loadingView&&this._loadingProgress01<.3&&this._loadId===i&&this._loadingView.onLoadingBegin("begin load")},300)),ts&&console.warn("--------------",i,"Needle Engine: Begin loading",s??"",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={files:t,onLoadingProgress:g=>{var A;g.name=oce(g.name),o&&((A=this._loadingView)==null||A.onLoadingUpdate(g)),c.name=g.name,c.progress=g.progress,this._loadingProgress01=iT(g),c.totalProgress01=this._loadingProgress01,this.dispatchEvent(l)},onLoadingFinished:(g,A,v)=>{v&&a.push({src:A,file:v})}},d=this.getAttribute("hash");d!=null&&(this._context.hash=d),this._context.alias=s,await this._context.create(h),this._loadId===i&&(ts&&console.warn("--------------",i,"Needle Engine: finished loading",s??"",t),this._loadingProgress01=1,o&&((p=this._loadingView)==null||p.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:s,loadedFiles:a}})))}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 s=i.length-1;s>=0;s--){const r=i[s];(r==="null"||r==="undefined"||(r==null?void 0:r.length)<=0)&&i.splice(s,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 s=0;s<(t==null?void 0:t.length);s++)if(t[s]!==i[s])return!0}return!1}ensureLoadStartIsRegistered(){const t=this.getAttribute("loadstart");t&&this.registerEventFromAttribute("loadstart",t)}registerEventFromAttribute(t,i){const s=this._previouslyRegisteredMap.get(t);if(s&&(this._previouslyRegisteredMap.delete(t),this.removeEventListener(t,s)),typeof i=="string"&&i.length>0){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)))}}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,i){var s;this.onSetupAR(),this._overlay_ar.onBegin(this._context,i,t),this.dispatchEvent(new CustomEvent("enter-ar",{detail:{session:t,context:this._context,htmlContainer:(s=this._overlay_ar)==null?void 0:s.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(ag),this.classList.remove(cg);const t=this.getAROverlayContainer();ts&&console.warn("onSetupAR:",t),t&&(t.classList.add(ag),t.classList.remove(cg)),this.foreachHtmlElement(i=>this.setupElementsForMode(i,oN))}onSetupVR(){this.classList.remove(ag),this.classList.remove(cg),this.foreachHtmlElement(t=>this.setupElementsForMode(t,dG))}onSetupDesktop(){this.classList.remove(ag),this.classList.add(cg);const t=this.getAROverlayContainer();t&&(t.classList.remove(ag),t.classList.add(cg)),this.foreachHtmlElement(i=>this.setupElementsForMode(i,fG))}setupElementsForMode(t,i,s=null){var o;if(t===((o=this._context)==null?void 0:o.renderer.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 a of sce)t.classList.contains(a)&&(t.style.visibility="hidden",t.style.display="none")}foreachHtmlElement(t){for(let i=0;i<this.children.length;i++){const s=this.children[i];s.style&&t(s)}}onBeforeBeginLoading(){const t=this.getAttribute("dracoDecoderPath");t&&(ts&&console.log("using custom draco decoder path",t),oD(t));const i=this.getAttribute("dracoDecoderType");i&&(ts&&console.log("using custom draco decoder type",i),aD(i));const s=this.getAttribute("ktx2DecoderPath");s&&(ts&&console.log("using custom ktx2 decoder path",s),cD(s))}}typeof window<"u"&&!window.customElements.get(ak)&&window.customElements.define(ak,WI);function oce(n){const e=n.split("/");let t=e[e.length-1];const i=t.indexOf("?");return i>0&&(t=t.substring(0,i)),decodeURIComponent(t)}const ace=Object.freeze(Object.defineProperty({__proto__:null,NeedleEngineHTMLElement:WI},Symbol.toStringTag,{value:"Module"})),O0=re("debughotreload");let eA=!1;const nm=new Map;function cce(){return eA}function lce(n){var i;if(eA)return;const t=n.constructor.name;nm.has(t)?(i=nm.get(t))==null||i.push(n):nm.set(t,[n])}function hce(n){if(eA)return;const t=n.constructor.name,i=nm.get(t);if(!i)return;const s=i.indexOf(n);s!==-1&&i.splice(s,1)}let ck=!1;function uce(){if(O0||ck)return;ck=!0;const n=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}}n.apply(console,e)}}function dce(n){O0&&console.log("[HMR] Apply changes",n,Object.keys(n)),uce();for(const e of Object.keys(n))try{eA=!0;const t=q.get(e);if(!t){O0&&console.log("[HMR] Type not found: "+e);continue}const i=n[e],s=nm.get(i.name);let r="[Needle Engine] Updating type: "+e;const o=(s==null?void 0:s.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]=n[e].prototype[l]);for(const l of a)c[l]||delete t.prototype[l];if(s){const l=new i,h=Object.getOwnPropertyDescriptors(l);for(const d of s){const f=d,p=f.isComponent===!0,g=p?f.activeAndEnabled:!0,A=p?f.context:void 0;try{if(p&&Mc(f,A),p&&g&&(f.enabled=!1),d.onBeforeHotReloadFields&&d.onBeforeHotReloadFields()===!1)continue;for(const v in h)if(h[v].writable){if(d[v]===void 0)d[v]=l[v];else if(typeof d[v]=="function"&&!d[v].prototype){const b=d[v],y=b.name,_="bound ";if(y===_)continue;const C=b.name.substring(_.length),M=i.prototype[C];M&&(d[v]=M.bind(d))}}d.onAfterHotReloadFields&&d.onAfterHotReloadFields()}finally{p&&V1(f,A),p&&g&&(f.enabled=!0)}}}}catch(t){if(O0)console.error(t);else return!1}finally{eA=!1,Nc(Jo.Log,"Script changes applied (HMR)")}return!0}const fce=Symbol("object"),lk=new Ga(()=>new S,20);class pG{constructor(e,t,i,s,r){u(this,"_point");u(this,"_normal");u(this,"distance");u(this,"impulse");u(this,"friction");this._point=e,this.distance=t,this._normal=i,this.impulse=s,this.friction=r}get point(){return lk.get().set(this._point.x,this._point.y,this._point.z)}get normal(){return lk.get().set(this._normal.x,this._normal.y,this._normal.z)}}class gG{constructor(e,t,i){u(this,"contacts");u(this,"me");u(this,"_collider");u(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 mG{constructor(e,t){u(this,"object");u(this,"collider");this.object=e,this.collider=t}}let Ne;const tA=new Array(32).fill(void 0);tA.push(void 0,null,!0,!1);let hk;tA.length;function uk(){return hk.byteLength,hk}const pce=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});function mt(n,e){if(!(n instanceof e))throw new Error(`expected instance of ${e.name}`);return n.ptr}pce.decode();let dk,fk,sm=32;function pk(n){if(sm==1)throw new Error("out of js stack");return tA[--sm]=n,sm}function gce(){return dk.byteLength,dk}function mce(){return fk.byteLength,fk}let Pr=0;function Qh(n,e){const t=e(4*n.length);return gce().set(n,t/4),Pr=n.length,t}function Wy(n,e){const t=e(4*n.length);return mce().set(n,t/4),Pr=n.length,t}class Sb{static __wrap(e){const t=Object.create(Sb.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();Ne.__wbg_raweventqueue_free(e)}constructor(e){const t=Ne.raweventqueue_new(e);return Sb.__wrap(t)}drainCollisionEvents(e){try{Ne.raweventqueue_drainCollisionEvents(this.ptr,pk(e))}finally{tA[sm++]=void 0}}drainContactForceEvents(e){try{Ne.raweventqueue_drainContactForceEvents(this.ptr,pk(e))}finally{tA[sm++]=void 0}}clear(){Ne.raweventqueue_clear(this.ptr)}}class Ra{static __wrap(e){const t=Object.create(Ra.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();Ne.__wbg_rawgenericjoint_free(e)}static spherical(e,t){mt(e,dt),mt(t,dt);const i=Ne.rawgenericjoint_spherical(e.ptr,t.ptr);return Ra.__wrap(i)}static prismatic(e,t,i,s,r,o){mt(e,dt),mt(t,dt),mt(i,dt);const a=Ne.rawgenericjoint_prismatic(e.ptr,t.ptr,i.ptr,s,r,o);return a===0?void 0:Ra.__wrap(a)}static fixed(e,t,i,s){mt(e,dt),mt(t,jn),mt(i,dt),mt(s,jn);const r=Ne.rawgenericjoint_fixed(e.ptr,t.ptr,i.ptr,s.ptr);return Ra.__wrap(r)}static revolute(e,t,i){mt(e,dt),mt(t,dt),mt(i,dt);const s=Ne.rawgenericjoint_revolute(e.ptr,t.ptr,i.ptr);return s===0?void 0:Ra.__wrap(s)}}class jI{static __wrap(e){const t=Object.create(jI.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();Ne.__wbg_rawpointprojection_free(e)}point(){const e=Ne.rawpointprojection_point(this.ptr);return dt.__wrap(e)}isInside(){return Ne.rawpointprojection_isInside(this.ptr)!==0}}class XI{static __wrap(e){const t=Object.create(XI.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();Ne.__wbg_rawrayintersection_free(e)}normal(){const e=Ne.rawrayintersection_normal(this.ptr);return dt.__wrap(e)}toi(){return Ne.rawintegrationparameters_dt(this.ptr)}featureType(){return Ne.rawrayintersection_featureType(this.ptr)>>>0}featureId(){try{const i=Ne.__wbindgen_add_to_stack_pointer(-16);Ne.rawrayintersection_featureId(i,this.ptr);var e=uk()[i/4+0],t=uk()[i/4+1];return e===0?void 0:t>>>0}finally{Ne.__wbindgen_add_to_stack_pointer(16)}}}class jn{static __wrap(e){const t=Object.create(jn.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();Ne.__wbg_rawrotation_free(e)}constructor(e,t,i,s){const r=Ne.rawrotation_new(e,t,i,s);return jn.__wrap(r)}static identity(){const e=Ne.rawrotation_identity();return jn.__wrap(e)}get x(){return Ne.rawintegrationparameters_dt(this.ptr)}get y(){return Ne.rawrotation_y(this.ptr)}get z(){return Ne.rawintegrationparameters_erp(this.ptr)}get w(){return Ne.rawrotation_w(this.ptr)}}class Gt{static __wrap(e){const t=Object.create(Gt.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();Ne.__wbg_rawshape_free(e)}static cuboid(e,t,i){const s=Ne.rawshape_cuboid(e,t,i);return Gt.__wrap(s)}static roundCuboid(e,t,i,s){const r=Ne.rawshape_roundCuboid(e,t,i,s);return Gt.__wrap(r)}static ball(e){const t=Ne.rawshape_ball(e);return Gt.__wrap(t)}static capsule(e,t){const i=Ne.rawshape_capsule(e,t);return Gt.__wrap(i)}static cylinder(e,t){const i=Ne.rawshape_cylinder(e,t);return Gt.__wrap(i)}static roundCylinder(e,t,i){const s=Ne.rawshape_roundCylinder(e,t,i);return Gt.__wrap(s)}static cone(e,t){const i=Ne.rawshape_cone(e,t);return Gt.__wrap(i)}static roundCone(e,t,i){const s=Ne.rawshape_roundCone(e,t,i);return Gt.__wrap(s)}static polyline(e,t){const i=Qh(e,Ne.__wbindgen_malloc),s=Pr,r=Wy(t,Ne.__wbindgen_malloc),o=Pr,a=Ne.rawshape_polyline(i,s,r,o);return Gt.__wrap(a)}static trimesh(e,t){const i=Qh(e,Ne.__wbindgen_malloc),s=Pr,r=Wy(t,Ne.__wbindgen_malloc),o=Pr,a=Ne.rawshape_trimesh(i,s,r,o);return Gt.__wrap(a)}static heightfield(e,t,i,s){const r=Qh(i,Ne.__wbindgen_malloc),o=Pr;mt(s,dt);const a=Ne.rawshape_heightfield(e,t,r,o,s.ptr);return Gt.__wrap(a)}static segment(e,t){mt(e,dt),mt(t,dt);const i=Ne.rawshape_segment(e.ptr,t.ptr);return Gt.__wrap(i)}static triangle(e,t,i){mt(e,dt),mt(t,dt),mt(i,dt);const s=Ne.rawshape_triangle(e.ptr,t.ptr,i.ptr);return Gt.__wrap(s)}static roundTriangle(e,t,i,s){mt(e,dt),mt(t,dt),mt(i,dt);const r=Ne.rawshape_roundTriangle(e.ptr,t.ptr,i.ptr,s);return Gt.__wrap(r)}static convexHull(e){const t=Qh(e,Ne.__wbindgen_malloc),i=Pr,s=Ne.rawshape_convexHull(t,i);return s===0?void 0:Gt.__wrap(s)}static roundConvexHull(e,t){const i=Qh(e,Ne.__wbindgen_malloc),s=Pr,r=Ne.rawshape_roundConvexHull(i,s,t);return r===0?void 0:Gt.__wrap(r)}static convexMesh(e,t){const i=Qh(e,Ne.__wbindgen_malloc),s=Pr,r=Wy(t,Ne.__wbindgen_malloc),o=Pr,a=Ne.rawshape_convexMesh(i,s,r,o);return a===0?void 0:Gt.__wrap(a)}static roundConvexMesh(e,t,i){const s=Qh(e,Ne.__wbindgen_malloc),r=Pr,o=Wy(t,Ne.__wbindgen_malloc),a=Pr,c=Ne.rawshape_roundConvexMesh(s,r,o,a,i);return c===0?void 0:Gt.__wrap(c)}castShape(e,t,i,s,r,o,a,c){mt(e,dt),mt(t,jn),mt(i,dt),mt(s,Gt),mt(r,dt),mt(o,jn),mt(a,dt);const l=Ne.rawshape_castShape(this.ptr,e.ptr,t.ptr,i.ptr,s.ptr,r.ptr,o.ptr,a.ptr,c);return l===0?void 0:YI.__wrap(l)}intersectsShape(e,t,i,s,r){return mt(e,dt),mt(t,jn),mt(i,Gt),mt(s,dt),mt(r,jn),Ne.rawshape_intersectsShape(this.ptr,e.ptr,t.ptr,i.ptr,s.ptr,r.ptr)!==0}contactShape(e,t,i,s,r,o){mt(e,dt),mt(t,jn),mt(i,Gt),mt(s,dt),mt(r,jn);const a=Ne.rawshape_contactShape(this.ptr,e.ptr,t.ptr,i.ptr,s.ptr,r.ptr,o);return a===0?void 0:qI.__wrap(a)}containsPoint(e,t,i){return mt(e,dt),mt(t,jn),mt(i,dt),Ne.rawshape_containsPoint(this.ptr,e.ptr,t.ptr,i.ptr)!==0}projectPoint(e,t,i,s){mt(e,dt),mt(t,jn),mt(i,dt);const r=Ne.rawshape_projectPoint(this.ptr,e.ptr,t.ptr,i.ptr,s);return jI.__wrap(r)}intersectsRay(e,t,i,s,r){return mt(e,dt),mt(t,jn),mt(i,dt),mt(s,dt),Ne.rawshape_intersectsRay(this.ptr,e.ptr,t.ptr,i.ptr,s.ptr,r)!==0}castRay(e,t,i,s,r,o){return mt(e,dt),mt(t,jn),mt(i,dt),mt(s,dt),Ne.rawshape_castRay(this.ptr,e.ptr,t.ptr,i.ptr,s.ptr,r,o)}castRayAndGetNormal(e,t,i,s,r,o){mt(e,dt),mt(t,jn),mt(i,dt),mt(s,dt);const a=Ne.rawshape_castRayAndGetNormal(this.ptr,e.ptr,t.ptr,i.ptr,s.ptr,r,o);return a===0?void 0:XI.__wrap(a)}}class qI{static __wrap(e){const t=Object.create(qI.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();Ne.__wbg_rawshapecontact_free(e)}distance(){return Ne.rawshapecontact_distance(this.ptr)}point1(){const e=Ne.rawpointprojection_point(this.ptr);return dt.__wrap(e)}point2(){const e=Ne.rawshapecontact_point2(this.ptr);return dt.__wrap(e)}normal1(){const e=Ne.rawshapecontact_normal1(this.ptr);return dt.__wrap(e)}normal2(){const e=Ne.rawshapecontact_normal2(this.ptr);return dt.__wrap(e)}}class YI{static __wrap(e){const t=Object.create(YI.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();Ne.__wbg_rawshapetoi_free(e)}toi(){return Ne.rawintegrationparameters_dt(this.ptr)}witness1(){const e=Ne.rawrayintersection_normal(this.ptr);return dt.__wrap(e)}witness2(){const e=Ne.rawshapetoi_witness2(this.ptr);return dt.__wrap(e)}normal1(){const e=Ne.rawshapetoi_normal1(this.ptr);return dt.__wrap(e)}normal2(){const e=Ne.rawshapetoi_normal2(this.ptr);return dt.__wrap(e)}}class dt{static __wrap(e){const t=Object.create(dt.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();Ne.__wbg_rawvector_free(e)}static zero(){const e=Ne.rawvector_zero();return dt.__wrap(e)}constructor(e,t,i){const s=Ne.rawvector_new(e,t,i);return dt.__wrap(s)}get x(){return Ne.rawintegrationparameters_dt(this.ptr)}set x(e){Ne.rawintegrationparameters_set_dt(this.ptr,e)}get y(){return Ne.rawrotation_y(this.ptr)}set y(e){Ne.rawvector_set_y(this.ptr,e)}get z(){return Ne.rawintegrationparameters_erp(this.ptr)}set z(e){Ne.rawintegrationparameters_set_erp(this.ptr,e)}xyz(){const e=Ne.rawvector_xyz(this.ptr);return dt.__wrap(e)}yxz(){const e=Ne.rawvector_yxz(this.ptr);return dt.__wrap(e)}zxy(){const e=Ne.rawvector_zxy(this.ptr);return dt.__wrap(e)}xzy(){const e=Ne.rawvector_xzy(this.ptr);return dt.__wrap(e)}yzx(){const e=Ne.rawvector_yzx(this.ptr);return dt.__wrap(e)}zyx(){const e=Ne.rawvector_zyx(this.ptr);return dt.__wrap(e)}}class Ace{constructor(e,t,i){this.x=e,this.y=t,this.z=i}}class Ie{static new(e,t,i){return new Ace(e,t,i)}static intoRaw(e){return new dt(e.x,e.y,e.z)}static zeros(){return Ie.new(0,0,0)}static fromRaw(e){if(!e)return null;let t=Ie.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 gk{constructor(e,t,i,s){this.x=e,this.y=t,this.z=i,this.w=s}}class Pi{static identity(){return new gk(0,0,0,1)}static fromRaw(e){if(!e)return null;let t=new gk(e.x,e.y,e.z,e.w);return e.free(),t}static intoRaw(e){return new jn(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}}var rm,ya,mk,yo,vM,si,Cb,tf,yM,bM,Ak,vk;(function(n){n[n.Dynamic=0]="Dynamic",n[n.Fixed=1]="Fixed",n[n.KinematicPositionBased=2]="KinematicPositionBased",n[n.KinematicVelocityBased=3]="KinematicVelocityBased"})(rm||(rm={}));class vce{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,s){return this.rawSet.rbSetEnabledTranslations(this.handle,e,t,i,s)}restrictTranslations(e,t,i,s){this.setEnabledTranslations(e,t,i,s)}setEnabledRotations(e,t,i,s){return this.rawSet.rbSetEnabledRotations(this.handle,e,t,i,s)}restrictRotations(e,t,i,s){this.setEnabledRotations(e,t,i,s)}dominanceGroup(){return this.rawSet.rbDominanceGroup(this.handle)}setDominanceGroup(e){this.rawSet.rbSetDominanceGroup(this.handle,e)}enableCcd(e){this.rawSet.rbEnableCcd(this.handle,e)}translation(){let e=this.rawSet.rbTranslation(this.handle);return Ie.fromRaw(e)}rotation(){let e=this.rawSet.rbRotation(this.handle);return Pi.fromRaw(e)}nextTranslation(){let e=this.rawSet.rbNextTranslation(this.handle);return Ie.fromRaw(e)}nextRotation(){let e=this.rawSet.rbNextRotation(this.handle);return Pi.fromRaw(e)}setTranslation(e,t){this.rawSet.rbSetTranslation(this.handle,e.x,e.y,e.z,t)}setLinvel(e,t){let i=Ie.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=Ie.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 Ie.fromRaw(this.rawSet.rbLinvel(this.handle))}angvel(){return Ie.fromRaw(this.rawSet.rbAngvel(this.handle))}mass(){return this.rawSet.rbMass(this.handle)}sleep(){this.rawSet.rbSleep(this.handle)}wakeUp(){this.rawSet.rbWakeUp(this.handle)}isCcdEnabled(){this.rawSet.rbIsCcdEnabled(this.handle)}numColliders(){return this.rawSet.rbNumColliders(this.handle)}collider(e){return this.colliderSet.get(this.rawSet.rbCollider(this.handle,e))}bodyType(){return this.rawSet.rbBodyType(this.handle)}setBodyType(e){return this.rawSet.rbSetBodyType(this.handle,e)}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,s,r){let o=Ie.intoRaw(t),a=Ie.intoRaw(i),c=Pi.intoRaw(s);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=Ie.intoRaw(e);this.rawSet.rbAddForce(this.handle,i,t),i.free()}applyImpulse(e,t){const i=Ie.intoRaw(e);this.rawSet.rbApplyImpulse(this.handle,i,t),i.free()}addTorque(e,t){const i=Ie.intoRaw(e);this.rawSet.rbAddTorque(this.handle,i,t),i.free()}applyTorqueImpulse(e,t){const i=Ie.intoRaw(e);this.rawSet.rbApplyTorqueImpulse(this.handle,i,t),i.free()}addForceAtPoint(e,t,i){const s=Ie.intoRaw(e),r=Ie.intoRaw(t);this.rawSet.rbAddForceAtPoint(this.handle,s,r,i),s.free(),r.free()}applyImpulseAtPoint(e,t,i){const s=Ie.intoRaw(e),r=Ie.intoRaw(t);this.rawSet.rbApplyImpulseAtPoint(this.handle,s,r,i),s.free(),r.free()}}(function(n){n[n.Revolute=0]="Revolute",n[n.Fixed=1]="Fixed",n[n.Prismatic=2]="Prismatic",n[n.Spherical=3]="Spherical"})(ya||(ya={})),function(n){n[n.AccelerationBased=0]="AccelerationBased",n[n.ForceBased=1]="ForceBased"}(mk||(mk={}));class nf{constructor(){}static fixed(e,t,i,s){let r=new nf;return r.anchor1=e,r.anchor2=i,r.frame1=t,r.frame2=s,r.jointType=ya.Fixed,r}static spherical(e,t){let i=new nf;return i.anchor1=e,i.anchor2=t,i.jointType=ya.Spherical,i}static prismatic(e,t,i){let s=new nf;return s.anchor1=e,s.anchor2=t,s.axis=i,s.jointType=ya.Prismatic,s}static revolute(e,t,i){let s=new nf;return s.anchor1=e,s.anchor2=t,s.axis=i,s.jointType=ya.Revolute,s}intoRaw(){let e,t,i=Ie.intoRaw(this.anchor1),s=Ie.intoRaw(this.anchor2),r=!1,o=0,a=0;switch(this.jointType){case ya.Fixed:let c=Pi.intoRaw(this.frame1),l=Pi.intoRaw(this.frame2);t=Ra.fixed(i,c,s,l),c.free(),l.free();break;case ya.Prismatic:e=Ie.intoRaw(this.axis),this.limitsEnabled&&(r=!0,o=this.limits[0],a=this.limits[1]),t=Ra.prismatic(i,s,e,r,o,a),e.free();break;case ya.Spherical:t=Ra.spherical(i,s);break;case ya.Revolute:e=Ie.intoRaw(this.axis),t=Ra.revolute(i,s,e),e.free()}return i.free(),s.free(),t}}(function(n){n[n.Average=0]="Average",n[n.Min=1]="Min",n[n.Multiply=2]="Multiply",n[n.Max=3]="Max"})(yo||(yo={}));class iA{constructor(e,t,i,s,r){this.distance=e,this.point1=t,this.point2=i,this.normal1=s,this.normal2=r}static fromRaw(e){if(!e)return null;const t=new iA(e.distance(),Ie.fromRaw(e.point1()),Ie.fromRaw(e.point2()),Ie.fromRaw(e.normal1()),Ie.fromRaw(e.normal2()));return e.free(),t}}(function(n){n[n.Vertex=0]="Vertex",n[n.Edge=1]="Edge",n[n.Face=2]="Face",n[n.Unknown=3]="Unknown"})(vM||(vM={}));class Qx{constructor(e,t){this.point=e,this.isInside=t}static fromRaw(e){if(!e)return null;const t=new Qx(Ie.fromRaw(e.point()),e.isInside());return e.free(),t}}class yce{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 Wx{constructor(e,t,i,s){this.featureType=vM.Unknown,this.featureId=void 0,this.toi=e,this.normal=t,s!==void 0&&(this.featureId=s),i!==void 0&&(this.featureType=i)}static fromRaw(e){if(!e)return null;const t=new Wx(e.toi(),Ie.fromRaw(e.normal()),e.featureType(),e.featureId());return e.free(),t}}class pv{constructor(e,t,i,s,r){this.toi=e,this.witness1=t,this.witness2=i,this.normal1=s,this.normal2=r}static fromRaw(e,t){if(!t)return null;const i=new pv(t.toi(),Ie.fromRaw(t.witness1()),Ie.fromRaw(t.witness2()),Ie.fromRaw(t.normal1()),Ie.fromRaw(t.normal2()));return t.free(),i}}class KI extends pv{constructor(e,t,i,s,r,o){super(t,i,s,r,o),this.collider=e}static fromRaw(e,t){if(!t)return null;const i=new KI(e.get(t.colliderHandle()),t.toi(),Ie.fromRaw(t.witness1()),Ie.fromRaw(t.witness2()),Ie.fromRaw(t.normal1()),Ie.fromRaw(t.normal2()));return t.free(),i}}class ys{static fromRaw(e,t){const i=e.coShapeType(t);let s,r,o,a,c,l;switch(i){case si.Ball:return new JI(e.coRadius(t));case si.Cuboid:return s=e.coHalfExtents(t),new AG(s.x,s.y,s.z);case si.RoundCuboid:return s=e.coHalfExtents(t),r=e.coRoundRadius(t),new vG(s.x,s.y,s.z,r);case si.Capsule:return c=e.coHalfHeight(t),l=e.coRadius(t),new yG(c,l);case si.Segment:return o=e.coVertices(t),new bG(Ie.new(o[0],o[1],o[2]),Ie.new(o[3],o[4],o[5]));case si.Polyline:return o=e.coVertices(t),a=e.coIndices(t),new wG(o,a);case si.Triangle:return o=e.coVertices(t),new _G(Ie.new(o[0],o[1],o[2]),Ie.new(o[3],o[4],o[5]),Ie.new(o[6],o[7],o[8]));case si.RoundTriangle:return o=e.coVertices(t),r=e.coRoundRadius(t),new xG(Ie.new(o[0],o[1],o[2]),Ie.new(o[3],o[4],o[5]),Ie.new(o[6],o[7],o[8]),r);case si.TriMesh:return o=e.coVertices(t),a=e.coIndices(t),new SG(o,a);case si.HeightField:const h=e.coHeightfieldScale(t),d=e.coHeightfieldHeights(t),f=e.coHeightfieldNRows(t),p=e.coHeightfieldNCols(t);return new CG(f,p,d,h);case si.ConvexPolyhedron:return o=e.coVertices(t),a=e.coIndices(t),new _M(o,a);case si.RoundConvexPolyhedron:return o=e.coVertices(t),a=e.coIndices(t),r=e.coRoundRadius(t),new xM(o,a,r);case si.Cylinder:return c=e.coHalfHeight(t),l=e.coRadius(t),new EG(c,l);case si.RoundCylinder:return c=e.coHalfHeight(t),l=e.coRadius(t),r=e.coRoundRadius(t),new MG(c,l,r);case si.Cone:return c=e.coHalfHeight(t),l=e.coRadius(t),new TG(c,l);case si.RoundCone:return c=e.coHalfHeight(t),l=e.coRadius(t),r=e.coRoundRadius(t),new IG(c,l,r);default:throw new Error("unknown shape type: "+i)}}castShape(e,t,i,s,r,o,a,c){let l=Ie.intoRaw(e),h=Pi.intoRaw(t),d=Ie.intoRaw(i),f=Ie.intoRaw(r),p=Pi.intoRaw(o),g=Ie.intoRaw(a),A=this.intoRaw(),v=s.intoRaw(),m=pv.fromRaw(null,A.castShape(l,h,d,v,f,p,g,c));return l.free(),h.free(),d.free(),f.free(),p.free(),g.free(),A.free(),v.free(),m}intersectsShape(e,t,i,s,r){let o=Ie.intoRaw(e),a=Pi.intoRaw(t),c=Ie.intoRaw(s),l=Pi.intoRaw(r),h=this.intoRaw(),d=i.intoRaw(),f=h.intersectsShape(o,a,d,c,l);return o.free(),a.free(),c.free(),l.free(),h.free(),d.free(),f}contactShape(e,t,i,s,r,o){let a=Ie.intoRaw(e),c=Pi.intoRaw(t),l=Ie.intoRaw(s),h=Pi.intoRaw(r),d=this.intoRaw(),f=i.intoRaw(),p=iA.fromRaw(d.contactShape(a,c,f,l,h,o));return a.free(),c.free(),l.free(),h.free(),d.free(),f.free(),p}containsPoint(e,t,i){let s=Ie.intoRaw(e),r=Pi.intoRaw(t),o=Ie.intoRaw(i),a=this.intoRaw(),c=a.containsPoint(s,r,o);return s.free(),r.free(),o.free(),a.free(),c}projectPoint(e,t,i,s){let r=Ie.intoRaw(e),o=Pi.intoRaw(t),a=Ie.intoRaw(i),c=this.intoRaw(),l=Qx.fromRaw(c.projectPoint(r,o,a,s));return r.free(),o.free(),a.free(),c.free(),l}intersectsRay(e,t,i,s){let r=Ie.intoRaw(t),o=Pi.intoRaw(i),a=Ie.intoRaw(e.origin),c=Ie.intoRaw(e.dir),l=this.intoRaw(),h=l.intersectsRay(r,o,a,c,s);return r.free(),o.free(),a.free(),c.free(),l.free(),h}castRay(e,t,i,s,r){let o=Ie.intoRaw(t),a=Pi.intoRaw(i),c=Ie.intoRaw(e.origin),l=Ie.intoRaw(e.dir),h=this.intoRaw(),d=h.castRay(o,a,c,l,s,r);return o.free(),a.free(),c.free(),l.free(),h.free(),d}castRayAndGetNormal(e,t,i,s,r){let o=Ie.intoRaw(t),a=Pi.intoRaw(i),c=Ie.intoRaw(e.origin),l=Ie.intoRaw(e.dir),h=this.intoRaw(),d=Wx.fromRaw(h.castRayAndGetNormal(o,a,c,l,s,r));return o.free(),a.free(),c.free(),l.free(),h.free(),d}}(function(n){n[n.Ball=0]="Ball",n[n.Cuboid=1]="Cuboid",n[n.Capsule=2]="Capsule",n[n.Segment=3]="Segment",n[n.Polyline=4]="Polyline",n[n.Triangle=5]="Triangle",n[n.TriMesh=6]="TriMesh",n[n.HeightField=7]="HeightField",n[n.ConvexPolyhedron=9]="ConvexPolyhedron",n[n.Cylinder=10]="Cylinder",n[n.Cone=11]="Cone",n[n.RoundCuboid=12]="RoundCuboid",n[n.RoundTriangle=13]="RoundTriangle",n[n.RoundCylinder=14]="RoundCylinder",n[n.RoundCone=15]="RoundCone",n[n.RoundConvexPolyhedron=16]="RoundConvexPolyhedron"})(si||(si={}));class JI extends ys{constructor(e){super(),this.type=si.Ball,this.radius=e}intoRaw(){return Gt.ball(this.radius)}}class AG extends ys{constructor(e,t,i){super(),this.type=si.Cuboid,this.halfExtents=Ie.new(e,t,i)}intoRaw(){return Gt.cuboid(this.halfExtents.x,this.halfExtents.y,this.halfExtents.z)}}class vG extends ys{constructor(e,t,i,s){super(),this.type=si.RoundCuboid,this.halfExtents=Ie.new(e,t,i),this.borderRadius=s}intoRaw(){return Gt.roundCuboid(this.halfExtents.x,this.halfExtents.y,this.halfExtents.z,this.borderRadius)}}class yG extends ys{constructor(e,t){super(),this.type=si.Capsule,this.halfHeight=e,this.radius=t}intoRaw(){return Gt.capsule(this.halfHeight,this.radius)}}class bG extends ys{constructor(e,t){super(),this.type=si.Segment,this.a=e,this.b=t}intoRaw(){let e=Ie.intoRaw(this.a),t=Ie.intoRaw(this.b),i=Gt.segment(e,t);return e.free(),t.free(),i}}class _G extends ys{constructor(e,t,i){super(),this.type=si.Triangle,this.a=e,this.b=t,this.c=i}intoRaw(){let e=Ie.intoRaw(this.a),t=Ie.intoRaw(this.b),i=Ie.intoRaw(this.c),s=Gt.triangle(e,t,i);return e.free(),t.free(),i.free(),s}}class xG extends ys{constructor(e,t,i,s){super(),this.type=si.RoundTriangle,this.a=e,this.b=t,this.c=i,this.borderRadius=s}intoRaw(){let e=Ie.intoRaw(this.a),t=Ie.intoRaw(this.b),i=Ie.intoRaw(this.c),s=Gt.roundTriangle(e,t,i,this.borderRadius);return e.free(),t.free(),i.free(),s}}class wG extends ys{constructor(e,t){super(),this.type=si.Polyline,this.vertices=e,this.indices=t??new Uint32Array(0)}intoRaw(){return Gt.polyline(this.vertices,this.indices)}}class SG extends ys{constructor(e,t){super(),this.type=si.TriMesh,this.vertices=e,this.indices=t}intoRaw(){return Gt.trimesh(this.vertices,this.indices)}}class _M extends ys{constructor(e,t){super(),this.type=si.ConvexPolyhedron,this.vertices=e,this.indices=t}intoRaw(){return this.indices?Gt.convexMesh(this.vertices,this.indices):Gt.convexHull(this.vertices)}}class xM extends ys{constructor(e,t,i){super(),this.type=si.RoundConvexPolyhedron,this.vertices=e,this.indices=t,this.borderRadius=i}intoRaw(){return this.indices?Gt.roundConvexMesh(this.vertices,this.indices,this.borderRadius):Gt.roundConvexHull(this.vertices,this.borderRadius)}}class CG extends ys{constructor(e,t,i,s){super(),this.type=si.HeightField,this.nrows=e,this.ncols=t,this.heights=i,this.scale=s}intoRaw(){let e=Ie.intoRaw(this.scale),t=Gt.heightfield(this.nrows,this.ncols,this.heights,e);return e.free(),t}}class EG extends ys{constructor(e,t){super(),this.type=si.Cylinder,this.halfHeight=e,this.radius=t}intoRaw(){return Gt.cylinder(this.halfHeight,this.radius)}}class MG extends ys{constructor(e,t,i){super(),this.type=si.RoundCylinder,this.borderRadius=i,this.halfHeight=e,this.radius=t}intoRaw(){return Gt.roundCylinder(this.halfHeight,this.radius,this.borderRadius)}}class TG extends ys{constructor(e,t){super(),this.type=si.Cone,this.halfHeight=e,this.radius=t}intoRaw(){return Gt.cone(this.halfHeight,this.radius)}}class IG extends ys{constructor(e,t,i){super(),this.type=si.RoundCone,this.halfHeight=e,this.radius=t,this.borderRadius=i}intoRaw(){return Gt.roundCone(this.halfHeight,this.radius,this.borderRadius)}}(function(n){n[n.DYNAMIC_DYNAMIC=1]="DYNAMIC_DYNAMIC",n[n.DYNAMIC_KINEMATIC=12]="DYNAMIC_KINEMATIC",n[n.DYNAMIC_FIXED=2]="DYNAMIC_FIXED",n[n.KINEMATIC_KINEMATIC=52224]="KINEMATIC_KINEMATIC",n[n.KINEMATIC_FIXED=8704]="KINEMATIC_FIXED",n[n.FIXED_FIXED=32]="FIXED_FIXED",n[n.DEFAULT=15]="DEFAULT",n[n.ALL=60943]="ALL"})(Cb||(Cb={}));class bce{constructor(e,t,i,s){this.colliderSet=e,this.handle=t,this._parent=i,this._shape=s}finalizeDeserialization(e){this.handle!=null&&(this._parent=e.get(this.colliderSet.raw.coParent(this.handle)))}ensureShapeIsCached(){this._shape||(this._shape=ys.fromRaw(this.colliderSet.raw,this.handle))}get shape(){return this.ensureShapeIsCached(),this._shape}isValid(){return this.colliderSet.raw.contains(this.handle)}translation(){return Ie.fromRaw(this.colliderSet.raw.coTranslation(this.handle))}rotation(){return Pi.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}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,s){let r=Ie.intoRaw(t),o=Ie.intoRaw(i),a=Pi.intoRaw(s);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 Ie.fromRaw(this.colliderSet.raw.coHalfExtents(this.handle))}radius(){return this.colliderSet.raw.coRadius(this.handle)}roundRadius(){return this.colliderSet.raw.coRoundRadius(this.handle)}halfHeight(){return this.colliderSet.raw.coHalfHeight(this.handle)}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 Ie.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=Ie.intoRaw(e),i=this.colliderSet.raw.coContainsPoint(this.handle,t);return t.free(),i}projectPoint(e,t){let i=Ie.intoRaw(e),s=Qx.fromRaw(this.colliderSet.raw.coProjectPoint(this.handle,i,t));return i.free(),s}intersectsRay(e,t){let i=Ie.intoRaw(e.origin),s=Ie.intoRaw(e.dir),r=this.colliderSet.raw.coIntersectsRay(this.handle,i,s,t);return i.free(),s.free(),r}castShape(e,t,i,s,r,o){let a=Ie.intoRaw(e),c=Ie.intoRaw(i),l=Pi.intoRaw(s),h=Ie.intoRaw(r),d=t.intoRaw(),f=pv.fromRaw(this.colliderSet,this.colliderSet.raw.coCastShape(this.handle,a,d,c,l,h,o));return a.free(),c.free(),l.free(),h.free(),d.free(),f}castCollider(e,t,i,s){let r=Ie.intoRaw(e),o=Ie.intoRaw(i),a=KI.fromRaw(this.colliderSet,this.colliderSet.raw.coCastCollider(this.handle,r,t.handle,o,s));return r.free(),o.free(),a}intersectsShape(e,t,i){let s=Ie.intoRaw(t),r=Pi.intoRaw(i),o=e.intoRaw(),a=this.colliderSet.raw.coIntersectsShape(this.handle,o,s,r);return s.free(),r.free(),o.free(),a}contactShape(e,t,i,s){let r=Ie.intoRaw(t),o=Pi.intoRaw(i),a=e.intoRaw(),c=iA.fromRaw(this.colliderSet.raw.coContactShape(this.handle,a,r,o,s));return r.free(),o.free(),a.free(),c}contactCollider(e,t){return iA.fromRaw(this.colliderSet.raw.coContactCollider(this.handle,e.handle,t))}castRay(e,t,i){let s=Ie.intoRaw(e.origin),r=Ie.intoRaw(e.dir),o=this.colliderSet.raw.coCastRay(this.handle,s,r,t,i);return s.free(),r.free(),o}castRayAndGetNormal(e,t,i){let s=Ie.intoRaw(e.origin),r=Ie.intoRaw(e.dir),o=Wx.fromRaw(this.colliderSet.raw.coCastRayAndGetNormal(this.handle,s,r,t,i));return s.free(),r.free(),o}}(function(n){n[n.Density=0]="Density",n[n.Mass=1]="Mass",n[n.MassProps=2]="MassProps"})(tf||(tf={}));class Ni{constructor(e){this.shape=e,this.massPropsMode=tf.Density,this.density=1,this.friction=.5,this.restitution=0,this.rotation=Pi.identity(),this.translation=Ie.zeros(),this.isSensor=!1,this.collisionGroups=4294967295,this.solverGroups=4294967295,this.frictionCombineRule=yo.Average,this.restitutionCombineRule=yo.Average,this.activeCollisionTypes=Cb.DEFAULT,this.activeEvents=0,this.activeHooks=0,this.mass=0,this.centerOfMass=Ie.zeros(),this.contactForceEventThreshold=0,this.principalAngularInertia=Ie.zeros(),this.angularInertiaLocalFrame=Pi.identity()}static ball(e){const t=new JI(e);return new Ni(t)}static capsule(e,t){const i=new yG(e,t);return new Ni(i)}static segment(e,t){const i=new bG(e,t);return new Ni(i)}static triangle(e,t,i){const s=new _G(e,t,i);return new Ni(s)}static roundTriangle(e,t,i,s){const r=new xG(e,t,i,s);return new Ni(r)}static polyline(e,t){const i=new wG(e,t);return new Ni(i)}static trimesh(e,t){const i=new SG(e,t);return new Ni(i)}static cuboid(e,t,i){const s=new AG(e,t,i);return new Ni(s)}static roundCuboid(e,t,i,s){const r=new vG(e,t,i,s);return new Ni(r)}static heightfield(e,t,i,s){const r=new CG(e,t,i,s);return new Ni(r)}static cylinder(e,t){const i=new EG(e,t);return new Ni(i)}static roundCylinder(e,t,i){const s=new MG(e,t,i);return new Ni(s)}static cone(e,t){const i=new TG(e,t);return new Ni(i)}static roundCone(e,t,i){const s=new IG(e,t,i);return new Ni(s)}static convexHull(e){const t=new _M(e,null);return new Ni(t)}static convexMesh(e,t){const i=new _M(e,t);return new Ni(i)}static roundConvexHull(e,t){const i=new xM(e,null,t);return new Ni(i)}static roundConvexMesh(e,t,i){const s=new xM(e,t,i);return new Ni(s)}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 Pi.copy(this.rotation,e),this}setSensor(e){return this.isSensor=e,this}setDensity(e){return this.massPropsMode=tf.Density,this.density=e,this}setMass(e){return this.massPropsMode=tf.Mass,this.mass=e,this}setMassProperties(e,t,i,s){return this.massPropsMode=tf.MassProps,this.mass=e,Ie.copy(this.centerOfMass,t),Ie.copy(this.principalAngularInertia,i),Pi.copy(this.angularInertiaLocalFrame,s),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}}(function(n){n[n.EXCLUDE_FIXED=1]="EXCLUDE_FIXED",n[n.EXCLUDE_KINEMATIC=2]="EXCLUDE_KINEMATIC",n[n.EXCLUDE_DYNAMIC=4]="EXCLUDE_DYNAMIC",n[n.EXCLUDE_SENSORS=8]="EXCLUDE_SENSORS",n[n.EXCLUDE_SOLIDS=16]="EXCLUDE_SOLIDS",n[n.ONLY_DYNAMIC=3]="ONLY_DYNAMIC",n[n.ONLY_KINEMATIC=5]="ONLY_KINEMATIC",n[n.ONLY_FIXED=6]="ONLY_FIXED"})(yM||(yM={}));(function(n){n[n.COLLISION_EVENTS=1]="COLLISION_EVENTS",n[n.CONTACT_FORCE_EVENTS=2]="CONTACT_FORCE_EVENTS"})(bM||(bM={}));class _ce{free(){this.raw.free(),this.raw=void 0}collider1(){return this.raw.collider1()}collider2(){return this.raw.collider2()}totalForce(){return Ie.fromRaw(this.raw.total_force())}totalForceMagnitude(){return this.raw.total_force_magnitude()}maxForceDirection(){return Ie.fromRaw(this.raw.max_force_direction())}maxForceMagnitude(){return this.raw.max_force_magnitude()}}class xce{constructor(e,t){this.raw=t||new Sb(e)}free(){this.raw.free(),this.raw=void 0}drainCollisionEvents(e){this.raw.drainCollisionEvents(e)}drainContactForceEvents(e){let t=new _ce;this.raw.drainContactForceEvents(i=>{t.raw=i,e(t),t.free()})}clear(){this.raw.clear()}}(function(n){n[n.FILTER_CONTACT_PAIRS=1]="FILTER_CONTACT_PAIRS",n[n.FILTER_INTERSECTION_PAIRS=2]="FILTER_INTERSECTION_PAIRS"})(Ak||(Ak={})),function(n){n[n.EMPTY=0]="EMPTY",n[n.COMPUTE_IMPULSE=1]="COMPUTE_IMPULSE"}(vk||(vk={}));for(var vle={byteLength:function(n){var e=yk(n),t=e[0],i=e[1];return 3*(t+i)/4-i},toByteArray:function(n){var e,t,i=yk(n),s=i[0],r=i[1],o=new wce(function(l,h,d){return 3*(h+d)/4-d}(0,s,r)),a=0,c=r>0?s-4:s;for(t=0;t<c;t+=4)e=uo[n.charCodeAt(t)]<<18|uo[n.charCodeAt(t+1)]<<12|uo[n.charCodeAt(t+2)]<<6|uo[n.charCodeAt(t+3)],o[a++]=e>>16&255,o[a++]=e>>8&255,o[a++]=255&e;return r===2&&(e=uo[n.charCodeAt(t)]<<2|uo[n.charCodeAt(t+1)]>>4,o[a++]=255&e),r===1&&(e=uo[n.charCodeAt(t)]<<10|uo[n.charCodeAt(t+1)]<<4|uo[n.charCodeAt(t+2)]>>2,o[a++]=e>>8&255,o[a++]=255&e),o},fromByteArray:function(n){for(var e,t=n.length,i=t%3,s=[],r=16383,o=0,a=t-i;o<a;o+=r)s.push(Cce(n,o,o+r>a?a:o+r));return i===1?(e=n[t-1],s.push(Ca[e>>2]+Ca[e<<4&63]+"==")):i===2&&(e=(n[t-2]<<8)+n[t-1],s.push(Ca[e>>10]+Ca[e>>4&63]+Ca[e<<2&63]+"=")),s.join("")}},Ca=[],uo=[],wce=typeof Uint8Array<"u"?Uint8Array:Array,iC="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Fd=0,Sce=iC.length;Fd<Sce;++Fd)Ca[Fd]=iC[Fd],uo[iC.charCodeAt(Fd)]=Fd;function yk(n){var e=n.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=n.indexOf("=");return t===-1&&(t=e),[t,t===e?0:4-t%4]}function Cce(n,e,t){for(var i,s,r=[],o=e;o<t;o+=3)i=(n[o]<<16&16711680)+(n[o+1]<<8&65280)+(255&n[o+2]),r.push(Ca[(s=i)>>18&63]+Ca[s>>12&63]+Ca[s>>6&63]+Ca[63&s]);return r.join("")}uo["-".charCodeAt(0)]=62,uo["_".charCodeAt(0)]=63;const Ns=re("debugphysics"),nC=re("debugcolliderplacement"),sC=re("debugcollisions"),Ece=re("showcolliders"),fo=Symbol("needle component"),No=Symbol("physics body"),Mce=Symbol("rigidbody");let Ud;globalThis.false=globalThis.false!==void 0?globalThis.false:!0;Ns&&console.log("Use Rapier",!1,globalThis.false);const dm=class{constructor(){u(this,"debugRenderColliders",!1);u(this,"context");u(this,"_initializePromise");u(this,"_isInitialized",!1);u(this,"rapierRay",new yce({x:0,y:0,z:0},{x:0,y:0,z:1}));u(this,"raycastVectorsBuffer",new Ga(()=>new S,10));u(this,"rapierSphere",null);u(this,"rapierColliderArray",[]);u(this,"rapierIdentityRotation",{x:0,y:0,z:0,w:1});u(this,"rapierForwardVector",{x:0,y:0,z:1});u(this,"enabled",!1);u(this,"_tempPosition",new S);u(this,"_tempQuaternion",new Se);u(this,"_tempScale",new S);u(this,"_tempMatrix",new Re);u(this,"_isUpdatingPhysicsWorld",!1);u(this,"world");u(this,"_hasCreatedWorld",!1);u(this,"eventQueue");u(this,"collisionHandler");u(this,"objects",[]);u(this,"bodies",[]);u(this,"_meshCache",new Map);u(this,"_gravity",{x:0,y:-9.81,z:0});u(this,"lines")}removeBody(e){var i,s;if(!e)return;this.validate();const t=e[No];if(e[No]=null,t&&this.world){const r=this.objects.findIndex(o=>o===e);if(r>=0){const o=this.bodies[r];if(this.bodies.splice(r,1),this.objects.splice(r,1),o instanceof bce){const a=o;(i=this.world)==null||i.removeCollider(a,!0);const c=a.parent();if(c&&c.numColliders()<=0){const l=c[fo];this.removeBody(l)}}else o instanceof vce&&(o.numColliders()<=0?(s=this.world)==null||s.removeRigidBody(o):bi()&&(o.did_log_removing||setTimeout(()=>{o.numColliders()>0&&(o.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 s=e,r=s[No];r&&this.syncPhysicsBody(s.gameObject,r,t,i)}}updateProperties(e){this.validate();const t=this.internal_getRigidbody(e);t&&this.internalUpdateProperties(e,t)}addForce(e,t,i){this.validate();const s=this.internal_getRigidbody(e);s==null||s.addForce(t,i)}addImpulse(e,t,i){this.validate();const s=this.internal_getRigidbody(e);s==null||s.applyImpulse(t,i)}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 s=this.internal_getRigidbody(e);s==null||s.applyImpulse(t,i)}wakeup(e){this.validate();const t=this.internal_getRigidbody(e);t==null||t.wakeUp()}setAngularVelocity(e,t,i){this.validate();const s=this.internal_getRigidbody(e);s==null||s.setAngvel(t,i)}setLinearVelocity(e,t,i){this.validate();const s=this.internal_getRigidbody(e);s==null||s.setLinvel(t,i)}async initialize(e){return this.context=e,this._initializePromise||(this._initializePromise=this.internalInitialization()),this._initializePromise}async internalInitialization(){return Ns&&console.log("Initialize rapier physics engine"),"env"in{url:typeof document>"u"?require("url").pathToFileURL(__filename).href:document.currentScript&&document.currentScript.src||new URL("dist/needle-engine.light.umd.cjs",document.baseURI).href}&&{}.VITE_NEEDLE_USE_RAPIER==="false"&&Ns&&console.log("Rapier disabled"),!1}validate(){this._isInitialized||Ns&&(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,s){var a;i===void 0&&(i=1/0),s===void 0&&(s=!0);const r=this.getPhysicsRay(this.rapierRay,e,t);if(!r)return null;const o=(a=this.world)==null?void 0:a.castRay(r,i,s,void 0,void 0,void 0,void 0,c=>{var l;return!((l=c[fo])!=null&&l.gameObject.layers.isEnabled(2))});if(o){const c=r.pointAt(o.toi),l=this.raycastVectorsBuffer.get();return l.set(c.x,c.y,c.z),{point:l,collider:o.collider[fo]}}return null}raycastAndGetNormal(e,t,i,s){var a;i===void 0&&(i=1/0),s===void 0&&(s=!0);const r=this.getPhysicsRay(this.rapierRay,e,t);if(!r)return null;const o=(a=this.world)==null?void 0:a.castRayAndGetNormal(r,i,s,void 0,void 0,void 0,void 0,c=>{var l;return!((l=c[fo])!=null&&l.gameObject.layers.isEnabled(2))});if(o){const c=r.pointAt(o.toi),l=o.normal,h=this.raycastVectorsBuffer.get(),d=this.raycastVectorsBuffer.get();return h.set(c.x,c.y,c.z),d.set(l.x,l.y,l.z),{point:h,normal:d,collider:o.collider[fo]}}return null}getPhysicsRay(e,t,i){var a,c,l;const s=(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(!s)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)&&(Ns&&console.warn("Converting screenspace to raycast space",h),(l=this.context)==null||l.input.convertScreenspaceToRaycastSpace(h)),h.unproject(s),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(!s)return console.error("Can not perform raycast - no camera found"),null;o.set(e.origin.x,e.origin.y,e.origin.z);const h=wt(s);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 JI(t)),this.rapierSphere.radius=t,this.world.intersectionsWithShape(e,this.rapierIdentityRotation,this.rapierSphere,i=>{const s=i[fo],r=new mG(s.gameObject,s);return this.rapierColliderArray.push(r),!0},yM.EXCLUDE_SENSORS,void 0,void 0,void 0,i=>i[fo].gameObject.layers.isEnabled(2)==!1),this.rapierColliderArray):this.rapierColliderArray}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,s;this._meshCache.clear(),(e=this.eventQueue)!=null&&e.raw&&((t=this.eventQueue)==null||t.free()),(i=this.world)!=null&&i.bodies&&((s=this.world)==null||s.free())}async addBoxCollider(e,t,i){if(this._isInitialized||await this.initialize(e.context),!e.activeAndEnabled)return;if(!this.enabled){Ns&&console.warn("Physics are disabled");return}const s=e.gameObject,r=qn(s,this._tempPosition).multiply(i);r.multiplyScalar(.5),r.x<0&&(r.x=Math.abs(r.x)),r.y<0&&(r.y=Math.abs(r.y)),r.z<0&&(r.z=Math.abs(r.z)),r.x==0&&(r.x=1e-7),r.y==0&&(r.y=1e-7),r.z==0&&(r.z=1e-7);const o=Ni.cuboid(r.x,r.y,r.z);this.createCollider(e,o,t)}async addSphereCollider(e,t,i){if(this._isInitialized||await this.initialize(e.context),!e.activeAndEnabled)return;if(!this.enabled){Ns&&console.warn("Physics are disabled");return}const s=e.gameObject,r=qn(s,this._tempPosition).multiplyScalar(i);r.x=Math.abs(r.x);const o=Ni.ball(r.x);this.createCollider(e,o,t)}async addCapsuleCollider(e,t,i,s){if(this._isInitialized||await this.initialize(e.context),!e.activeAndEnabled)return;if(!this.enabled){Ns&&console.warn("Physics are disabled");return}const r=e.gameObject,o=qn(r,this._tempPosition);o.x=Math.abs(o.x),o.y=Math.abs(o.y);const a=Ni.capsule(i*.5*o.y-s,s*o.x);this.createCollider(e,a,t)}async addMeshCollider(e,t,i,s){var l,h,d;if(this._isInitialized||await this.initialize(e.context),!e.activeAndEnabled)return;if(!this.enabled){Ns&&console.warn("Physics are disabled");return}let r=t.geometry;if(!r){Ns&&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=SY(r));let o=r.getAttribute("position").array;const a=(d=r.index)==null?void 0:d.array;if(Math.abs(s.x-1)>1e-4||Math.abs(s.y-1)>1e-4||Math.abs(s.z-1)>1e-4){const f=r.uuid+"_"+s.x+"_"+s.y+"_"+s.z+"_"+i;if(this._meshCache.has(f))Ns&&console.warn("Use cached mesh collider"),o=this._meshCache.get(f);else{console.warn("Your model is using scaled mesh colliders which is not optimal for performance",t.name,Object.assign({},s));const p=new Float32Array(o.length);for(let g=0;g<o.length;g+=3)p[g]=o[g]*s.x,p[g+1]=o[g+1]*s.y,p[g+2]=o[g+2]*s.z;o=p,this._meshCache.set(f,p)}}const c=i?Ni.convexMesh(o):Ni.trimesh(o,a);c&&this.createCollider(e,c).setMassProperties(1,{x:0,y:0,z:0},{x:0,y:0,z:0},{x:0,y:0,z:0,w:1})}createCollider(e,t,i){if(!this.world)throw new Error("Physics world not initialized");const s=this._tempMatrix,{rigidBody:r,useExplicitMassProperties:o}=this.getRigidbody(e,this._tempMatrix);s.decompose(this._tempPosition,this._tempQuaternion,this._tempScale),qn(e.gameObject,this._tempScale),i&&(i.multiply(this._tempScale),this._tempPosition.x-=i.x,this._tempPosition.y+=i.y,this._tempPosition.z+=i.z),t.setTranslation(this._tempPosition.x,this._tempPosition.y,this._tempPosition.z),t.setRotation(this._tempQuaternion),t.setSensor(e.isTrigger);const a=e.sharedMaterial;if(a){switch(t.setRestitution(a.bounciness),a.bounceCombine){case Aa.Average:t.setRestitutionCombineRule(yo.Average);break;case Aa.Maximum:t.setRestitutionCombineRule(yo.Max);break;case Aa.Minimum:t.setRestitutionCombineRule(yo.Min);break;case Aa.Multiply:t.setRestitutionCombineRule(yo.Multiply);break}switch(t.setFriction(a.dynamicFriction),a.frictionCombine){case Aa.Average:t.setFrictionCombineRule(yo.Average);break;case Aa.Maximum:t.setFrictionCombineRule(yo.Max);break;case Aa.Minimum:t.setFrictionCombineRule(yo.Min);break;case Aa.Multiply:t.setFrictionCombineRule(yo.Multiply);break}}const c=this.world.createCollider(t,r);return c[fo]=e,e[No]=c,c.setActiveEvents(bM.COLLISION_EVENTS),c.setActiveCollisionTypes(Cb.ALL),this.objects.push(e),this.bodies.push(c),c}getRigidbody(e,t){if(!this.world)throw new Error("Physics world not initialized");let i=null,s=!1;if(e.attachedRigidbody){const r=e.attachedRigidbody;if(i=r[No],s=!0,!i){const o=r.isKinematic&&!nC;Ns&&console.log("Create rigidbody",o);const a=o?Ud.RigidBodyDesc.kinematicPositionBased():Ud.RigidBodyDesc.dynamic(),c=wt(e.attachedRigidbody.gameObject);a.setTranslation(c.x,c.y,c.z),a.setRotation(Fn(e.attachedRigidbody.gameObject)),i=this.world.createRigidBody(a),this.bodies.push(i),this.objects.push(r)}i[fo]=r,r[No]=i,this.internalUpdateProperties(r,i),this.getRigidbodyRelativeMatrix(e.gameObject,r.gameObject,t)}else{const r=Ud.RigidBodyDesc.kinematicPositionBased(),o=wt(e.gameObject);r.setTranslation(o.x,o.y,o.z),r.setRotation(Fn(e.gameObject)),i=this.world.createRigidBody(r),t.identity(),i[fo]=null}return e[Mce]=i,{rigidBody:i,useExplicitMassProperties:s}}internal_getRigidbody(e){return e[No]}internalUpdateProperties(e,t){t.enableCcd(e.collisionDetectionMode!==Y_.Discrete),t.setLinearDamping(e.drag),t.setAngularDamping(e.angularDrag),t.setGravityScale(e.useGravity?e.gravityScale:0,!0),t.setEnabledRotations(!e.lockRotationX,!e.lockRotationY,!e.lockRotationZ,!0),t.setEnabledTranslations(!e.lockPositionX,!e.lockPositionY,!e.lockPositionZ,!0),e.isKinematic?t.setBodyType(Ud.RigidBodyType.KinematicPositionBased):t.setBodyType(Ud.RigidBodyType.Dynamic)}step(e){this.world&&this.enabled&&(this._isUpdatingPhysicsWorld=!0,this.eventQueue||(this.eventQueue=new xce(!1)),e&&(this.world.timestep=tt.lerp(this.world.timestep,e,.8)),this.world.step(this.eventQueue),this._isUpdatingPhysicsWorld=!1,this.updateDebugRendering(this.world))}updateDebugRendering(e){var t,i,s;if(Ns||nC||Ece||this.debugRenderColliders===!0){if(!this.lines){const o=new gn({color:2258688,fog:!1}),a=new vt;this.lines=new jr(a,o)}this.lines.parent!==((t=this.context)==null?void 0:t.scene)&&((i=this.context)==null||i.scene.add(this.lines));const r=e.debugRender();this.lines.geometry.setAttribute("position",new rt(r.vertices,3)),this.lines.geometry.setAttribute("color",new rt(r.colors,4))}else this.lines&&((s=this.context)==null||s.scene.remove(this.lines))}postStep(){this.world&&this.enabled&&(this._isUpdatingPhysicsWorld=!0,this.syncObjects(),this._isUpdatingPhysicsWorld=!1,this.eventQueue&&!this.collisionHandler&&(this.collisionHandler=new Tce(this.world,this.eventQueue)),this.collisionHandler&&(this.collisionHandler.handleCollisionEvents(),this.collisionHandler.update()))}syncObjects(){if(!nC)for(let e=0;e<this.bodies.length;e++){const t=this.objects[e],i=this.bodies[e],s=t;if((s==null?void 0:s.isCollider)===!0&&!s.attachedRigidbody){const c=i.parent();c&&this.syncPhysicsBody(t.gameObject,c,!0,!0);continue}const r=i.translation(),o=i.rotation(),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=qn(t.gameObject);c.multiply(l),r.x-=c.x,r.y-=c.y,r.z-=c.z}Bf(t.gameObject,r.x,r.y,r.z),k2(t.gameObject,o.x,o.y,o.z,o.w)}}syncPhysicsBody(e,t,i,s){const r=wt(e,this._tempPosition),o=Fn(e,this._tempQuaternion);switch(t.bodyType()){case rm.Fixed:case rm.KinematicPositionBased:case rm.KinematicVelocityBased:i&&t.setNextKinematicTranslation(r),s&&t.setNextKinematicRotation(o);break;default:i&&t.setTranslation(r,!1),s&&t.setRotation(o,!1);break}t.wakeUp()}getRigidbodyRelativeMatrix(e,t,i,s){if(s===void 0&&(s=dm._matricesBuffer,s.length=0),e===t){const r=qn(e,this._tempPosition);i.makeScale(r.x,r.y,r.z);for(let o=s.length-1;o>=0;o--)i.multiply(s[o]);return i}return s.push(e.matrix),e.parent&&this.getRigidbodyRelativeMatrix(e.parent,t,i,s),i}addFixedJoint(e,t){if(!this.world){console.error("Physics world not initialized");return}const i=e[No],s=t[No];this.calculateJointRelativeMatrices(e.gameObject,t.gameObject,this._tempMatrix),this._tempMatrix.decompose(this._tempPosition,this._tempQuaternion,this._tempScale);const r=nf.fixed(dm.centerConnectionPos,dm.centerConnectionRot,this._tempPosition,this._tempQuaternion),o=this.world.createImpulseJoint(r,i,s,!0);Ns&&console.log("ADD FIXED JOINT",o)}addHingeJoint(e,t,i,s){if(!this.world){console.error("Physics world not initialized");return}const r=e[No],o=t[No];this.calculateJointRelativeMatrices(e.gameObject,t.gameObject,this._tempMatrix),this._tempMatrix.decompose(this._tempPosition,this._tempQuaternion,this._tempScale);const a=Ud.JointData.revolute(i,this._tempPosition,s),c=this.world.createImpulseJoint(a,r,o,!0);Ns&&console.log("ADD HINGE JOINT",c)}calculateJointRelativeMatrices(e,t,i){e.updateWorldMatrix(!0,!1),t.updateWorldMatrix(!0,!1);const s=e.matrixWorld,r=t.matrixWorld;s.elements[0]=1,s.elements[5]=1,s.elements[10]=1,r.elements[0]=1,r.elements[5]=1,r.elements[10]=1,i.copy(r).premultiply(s.invert()).invert()}};let Jh=dm;u(Jh,"_didLoadPhysicsEngine",!1),u(Jh,"_matricesBuffer",[]),u(Jh,"centerConnectionPos",{x:0,y:0,z:0}),u(Jh,"centerConnectionRot",{x:0,y:0,z:0,w:1});class Tce{constructor(e,t){u(this,"world");u(this,"eventQueue");u(this,"activeCollisions",[]);u(this,"activeCollisionsStay",[]);u(this,"activeTriggers",[]);this.world=e,this.eventQueue=t}handleCollisionEvents(){this.eventQueue&&this.world&&this.eventQueue.drainCollisionEvents((e,t,i)=>{const s=this.world.getCollider(e),r=this.world.getCollider(t),o=s[fo],a=r[fo];sC&&console.log("EVT",o.name,a.name,i,s,r),o&&a&&(i?(this.onCollisionStarted(o,s,a,r),this.onCollisionStarted(a,r,o,s)):(this.onCollisionEnded(o,a),this.onCollisionEnded(a,o)))})}update(){this.onHandleCollisionStay()}onCollisionStarted(e,t,i,s){let r=null;if(e.isTrigger||i.isTrigger)Eu(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,s,(a,c)=>{Eu(o,l=>{var d;if(l.destroyed)return;const h=l.onCollisionEnter||l.onCollisionStay||l.onCollisionExit;if(h||sC){if(!r){const f=[],p=a.normal();for(let g=0;g<a.numSolverContacts();g++){const A=a.solverContactPoint(g),v=a.contactImpulse(g);if(A){const m=a.contactDist(g),b=a.solverContactFriction(g),y=new pG(A,m,p,v,b);f.push(y),sC&&Lc.DrawDirection(A,p,16711680,3,!0)}}r=new gG(o,i,f)}if(h){const f={collider:e,component:l,collision:r};this.activeCollisions.push(f),l.onCollisionStay&&this.activeCollisionsStay.push(f),(d=l.onCollisionEnter)==null||d.call(l,r)}}})})}}onHandleCollisionStay(){for(const e of this.activeCollisionsStay){const t=e.component;if(!t.destroyed&&t.activeAndEnabled&&t.onCollisionStay){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;t.onTriggerStay(i)}}}onCollisionEnded(e,t){if(!(e.destroyed||t.destroyed)){for(let i=0;i<this.activeCollisions.length;i++){const s=this.activeCollisions[i],r=s.collider;if(r.destroyed){this.activeCollisions.splice(i,1),i--;continue}if(r===e&&s.collision.collider===t){const o=s.component;if(this.activeCollisions.splice(i,1),i--,o.activeAndEnabled&&o.onCollisionExit){const a=s.collision;o.onCollisionExit(a)}}}for(let i=0;i<this.activeCollisionsStay.length;i++){const s=this.activeCollisionsStay[i],r=s.collider;if(r.destroyed){this.activeCollisionsStay.splice(i,1),i--;continue}if(r===e&&s.collision.collider===t){const o=s.component;if(this.activeCollisionsStay.splice(i,1),i--,o.activeAndEnabled&&o.onCollisionExit){const a=s.collision;o.onCollisionExit(a)}}}for(let i=0;i<this.activeTriggers.length;i++){const s=this.activeTriggers[i],r=s.collider;if(r.destroyed){this.activeTriggers.splice(i,1),i--;continue}if(r===e&&s.otherCollider===t){const o=s.component;if(this.activeTriggers.splice(i,1),i--,o.activeAndEnabled&&o.onTriggerExit){const a=s.otherCollider;o.onTriggerExit(a)}}}}}}Object.defineProperty(qt.prototype,"fov",{get:function(){return this._fov},set:function(n){const e=n!==this._fov;this._fov=n,e&&this.view!==void 0&&this.updateProjectionMatrix()}});Object.defineProperty(qt.prototype,"near",{get:function(){return this._near},set:function(n){const e=n!==this._near;this._near=n,e&&this.view!==void 0&&this.updateProjectionMatrix()}});Object.defineProperty(qt.prototype,"far",{get:function(){return this._far},set:function(n){const e=n!==this._far;this._far=n,e&&this.view!==void 0&&this.updateProjectionMatrix()}});function Ice(n,e,t,i="image/webp",s){if(!n&&(n=Bi.Current,!n))return console.error("Can not save screenshot: No needle-engine context found or provided."),null;if(!s&&(s=n.mainCamera,!s))return console.error("No camera found"),null;const r=n.renderer.domElement.width,o=n.renderer.domElement.height;e||(e=r),t||(t=o);try{const a=n.renderer.domElement;return n.renderer.setSize(e,t,!1),s instanceof qt&&n.updateAspect(s,e,t),n.renderNow(),a.toDataURL(i)}finally{n.renderer.setSize(r,o,!1),n.updateSize()}return null}let lg=null;function Rce(n,e){if(n){if(!n.startsWith("data:image")){console.error("Can not save image: Data url is not an image",n);return}lg||(lg=document.createElement("a")),lg.href=n,lg.download=e,lg.click()}}const Eb=re("debugmissingcamera");Bi.registerCallback(Qs.MissingCamera,n=>{var r,o;Eb&&console.warn("Creating missing camera");const e=n.context.scene,t=new Te;t.name="Default Fallback Camera",e.add(t);const i=new Oi;i.sourceId=((o=(r=n.files)==null?void 0:r[0])==null?void 0:o.src)??"unknown",n.context.lightmaps.tryGetSkybox(i.sourceId)?i.clearFlags=1:i.clearFlags=2,i.backgroundColor=new _i(.5,.5,.5,1),i.fieldOfView=35,i.backgroundBlurriness=.2;const s=ku(t,i,!0);return t.position.x=0,t.position.y=1,t.position.z=2,RG(n.context,s),s});Bi.registerCallback(Qs.ContextCreated,n=>{if(!n.context.mainCamera){Eb&&console.log("Will not auto-fit because a default camera exists");return}const e=n.context.domElement;if((e==null?void 0:e.cameraControls)===!0){const t=Mte(n.context.mainCamera);if((t==null?void 0:t.isCameraController)===!0){Eb&&console.log("Will not auto-fit because a camera controller exists");return}RG(n.context)}});function RG(n,e){e=e??n.mainCameraComponent;const t=e==null?void 0:e.gameObject;if(Eb&&console.log("Creating default camera controls",e==null?void 0:e.name),t){const i=R_(t,cl);i.sourceId=(e==null?void 0:e.sourceId)??"unknown";const s=n.domElement.getAttribute("auto-rotate");i.autoRotate=s!==void 0&&(s===""||s==="true"),i.autoRotateSpeed=.5;const r=n,o=()=>{r.pre_render_callbacks.splice(r.pre_render_callbacks.indexOf(o),1),i.fitCamera()};r.pre_render_callbacks.push(o)}else console.warn("Missing camera object, can not add orbit controls")}JG();const ZI={Context:Nt,glTF:{loadFromURL:QI}};globalThis.Needle!==void 0&&console.warn("Needle Engine is already imported");globalThis.Needle=ZI;function PG(n){for(const e in n)ZI[e]=n[e]}PG($q);PG(Wae);for(const n of Object.getOwnPropertyNames(se))switch(n){case"prototype":case"constructor":case"length":case"name":continue;default:ZI[n]=se[n];break}globalThis.THREE?console.warn("Threejs is already imported"):globalThis.THREE=rj;var $I={},BG={};Object.defineProperty(BG,"__esModule",{value:!0});var jx={};Object.defineProperty(jx,"__esModule",{value:!0});jx.ConstantBackoff=void 0;var Pce=function(){function n(e){this.reset=function(){},this.backoff=e}return n.prototype.next=function(){return this.backoff},n}();jx.ConstantBackoff=Pce;var Xx={};Object.defineProperty(Xx,"__esModule",{value:!0});Xx.ExponentialBackoff=void 0;var Bce=function(){function n(e,t){this.initial=e,this.expMax=t,this.expCurrent=1,this.current=this.initial}return n.prototype.next=function(){var e=this.current;return this.expMax>this.expCurrent++&&(this.current=this.current*2),e},n.prototype.reset=function(){this.expCurrent=1,this.current=this.initial},n}();Xx.ExponentialBackoff=Bce;var qx={};Object.defineProperty(qx,"__esModule",{value:!0});qx.LinearBackoff=void 0;var Dce=function(){function n(e,t,i){this.initial=e,this.increment=t,this.maximum=i,this.current=this.initial}return n.prototype.next=function(){var e=this.current,t=this.current+this.increment;return this.maximum===void 0?this.current=t:t<=this.maximum&&(this.current=t),e},n.prototype.reset=function(){this.current=this.initial},n}();qx.LinearBackoff=Dce;var DG={};Object.defineProperty(DG,"__esModule",{value:!0});var Yx={};Object.defineProperty(Yx,"__esModule",{value:!0});Yx.LRUBuffer=void 0;var Oce=function(){function n(e){this.writePtr=0,this.wrapped=!1,this.buffer=Array(e)}return n.prototype.len=function(){return this.wrapped?this.buffer.length:this.writePtr},n.prototype.cap=function(){return this.buffer.length},n.prototype.read=function(e){if(e==null||e.length===0||this.buffer.length===0||this.writePtr===0&&!this.wrapped)return 0;for(var t=this.wrapped?this.writePtr:0,i=t-1<0?this.buffer.length-1:t-1,s=0;s<e.length;s++){var r=(t+s)%this.buffer.length;if(e[s]=this.buffer[r],r===i)return s+1}return e.length},n.prototype.write=function(e){if(e==null||e.length===0||this.buffer.length===0)return 0;for(var t=e.length>this.buffer.length?e.length-this.buffer.length:0,i=0;i<e.length-t;i++)this.buffer[this.writePtr]=e[t+i],this.writePtr=(this.writePtr+1)%this.buffer.length,this.writePtr===0&&(this.wrapped=!0);return e.length},n.prototype.forEach=function(e){if(this.writePtr===0&&!this.wrapped)return 0;for(var t=this.wrapped?this.writePtr:0,i=this.wrapped?t-1<0?this.buffer.length-1:t-1:this.writePtr-1,s=this.len();e(this.buffer[t]),t!==i;)t=(t+1)%this.buffer.length;return s},n.prototype.clear=function(){this.writePtr=0,this.wrapped=!1},n}();Yx.LRUBuffer=Oce;var Kx={};Object.defineProperty(Kx,"__esModule",{value:!0});Kx.TimeBuffer=void 0;var kce=function(){function n(e){this.maxAge=e}return n.prototype.cap=function(){return Number.POSITIVE_INFINITY},n.prototype.len=function(){this.forwardTail();for(var e=this.tail,t=0;e!==void 0;)t++,e=e.n;return t},n.prototype.read=function(e){if(this.forwardTail(),e.length===0)return 0;for(var t=this.tail,i=0;t!==void 0&&(e[i++]=t.e,i!==e.length);)t=t.n;return i},n.prototype.write=function(e){for(var t=0;t<e.length;t++)this.putElement(e[t]);return e.length},n.prototype.forEach=function(e){this.forwardTail();for(var t=this.tail,i=0;t!==void 0;)e(t.e),i++,t=t.n;return i},n.prototype.putElement=function(e){var t={e,t:Date.now(),n:void 0};this.tail===void 0&&(this.tail=t),this.head===void 0?this.head=t:(this.head.n=t,this.head=t)},n.prototype.forwardTail=function(){if(this.tail!==void 0)for(var e=Date.now();e-this.tail.t>this.maxAge&&(this.tail===this.head?(this.tail=void 0,this.head=void 0):this.tail=this.tail.n,this.tail!==void 0););},n.prototype.clear=function(){},n}();Kx.TimeBuffer=kce;var eR={};(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.Websocket=n.WebsocketEvents=void 0;var e;(function(i){i.open="open",i.close="close",i.error="error",i.message="message",i.retry="retry"})(e=n.WebsocketEvents||(n.WebsocketEvents={}));var t=function(){function i(s,r,o,a){var c=this;this.eventListeners={open:[],close:[],error:[],message:[],retry:[]},this.closedByUser=!1,this.retries=0,this.handleOpenEvent=function(l){return c.handleEvent(e.open,l)},this.handleCloseEvent=function(l){return c.handleEvent(e.close,l)},this.handleErrorEvent=function(l){return c.handleEvent(e.error,l)},this.handleMessageEvent=function(l){return c.handleEvent(e.message,l)},this.url=s,this.protocols=r,this.buffer=o,this.backoff=a,this.tryConnect()}return Object.defineProperty(i.prototype,"underlyingWebsocket",{get:function(){return this.websocket},enumerable:!1,configurable:!0}),i.prototype.send=function(s){var r;this.closedByUser||(this.websocket===void 0||this.websocket.readyState!==this.websocket.OPEN?(r=this.buffer)===null||r===void 0||r.write([s]):this.websocket.send(s))},i.prototype.close=function(s,r){var o;this.closedByUser=!0,(o=this.websocket)===null||o===void 0||o.close(s,r)},i.prototype.addEventListener=function(s,r,o){var a={listener:r,options:o},c=this.eventListeners[s];c.push(a)},i.prototype.removeEventListener=function(s,r,o){this.eventListeners[s]=this.eventListeners[s].filter(function(a){return a.listener!==r&&(a.options===void 0||a.options!==o)})},i.prototype.dispatchEvent=function(s,r){var o=this,a=this.eventListeners[s],c=[];a.forEach(function(l){l.listener(o,r),l.options!==void 0&&l.options.once&&c.push(l)}),c.forEach(function(l){return o.removeEventListener(s,l.listener,l.options)})},i.prototype.tryConnect=function(){this.websocket!==void 0&&(this.websocket.removeEventListener(e.open,this.handleOpenEvent),this.websocket.removeEventListener(e.close,this.handleCloseEvent),this.websocket.removeEventListener(e.error,this.handleErrorEvent),this.websocket.removeEventListener(e.message,this.handleMessageEvent),this.websocket.close()),this.websocket=new WebSocket(this.url,this.protocols),this.websocket.addEventListener(e.open,this.handleOpenEvent),this.websocket.addEventListener(e.close,this.handleCloseEvent),this.websocket.addEventListener(e.error,this.handleErrorEvent),this.websocket.addEventListener(e.message,this.handleMessageEvent)},i.prototype.handleEvent=function(s,r){var o,a,c;switch(s){case e.close:this.closedByUser||this.reconnect();break;case e.open:this.retries=0,(o=this.backoff)===null||o===void 0||o.reset(),(a=this.buffer)===null||a===void 0||a.forEach(this.send.bind(this)),(c=this.buffer)===null||c===void 0||c.clear();break}this.dispatchEvent(s,r)},i.prototype.reconnect=function(){var s=this;if(this.backoff!==void 0){var r=this.backoff.next();setTimeout(function(){s.dispatchEvent(e.retry,new CustomEvent(e.retry,{detail:{retries:++s.retries,backoff:r}})),s.tryConnect()},r)}},i}();n.Websocket=t})(eR);var Jx={};Object.defineProperty(Jx,"__esModule",{value:!0});Jx.WebsocketBuilder=void 0;var Nd=eR,Lce=function(){function n(e){this.ws=null,this.onOpenListeners=[],this.onCloseListeners=[],this.onErrorListeners=[],this.onMessageListeners=[],this.onRetryListeners=[],this.url=e}return n.prototype.withProtocols=function(e){return this.protocols=e,this},n.prototype.withBackoff=function(e){return this.backoff=e,this},n.prototype.withBuffer=function(e){return this.buffer=e,this},n.prototype.onOpen=function(e,t){return this.onOpenListeners.push({listener:e,options:t}),this},n.prototype.onClose=function(e,t){return this.onCloseListeners.push({listener:e,options:t}),this},n.prototype.onError=function(e,t){return this.onErrorListeners.push({listener:e,options:t}),this},n.prototype.onMessage=function(e,t){return this.onMessageListeners.push({listener:e,options:t}),this},n.prototype.onRetry=function(e,t){return this.onRetryListeners.push({listener:e,options:t}),this},n.prototype.build=function(){var e=this;return this.ws!==null?this.ws:(this.ws=new Nd.Websocket(this.url,this.protocols,this.buffer,this.backoff),this.onOpenListeners.forEach(function(t){var i;return(i=e.ws)===null||i===void 0?void 0:i.addEventListener(Nd.WebsocketEvents.open,t.listener,t.options)}),this.onCloseListeners.forEach(function(t){var i;return(i=e.ws)===null||i===void 0?void 0:i.addEventListener(Nd.WebsocketEvents.close,t.listener,t.options)}),this.onErrorListeners.forEach(function(t){var i;return(i=e.ws)===null||i===void 0?void 0:i.addEventListener(Nd.WebsocketEvents.error,t.listener,t.options)}),this.onMessageListeners.forEach(function(t){var i;return(i=e.ws)===null||i===void 0?void 0:i.addEventListener(Nd.WebsocketEvents.message,t.listener,t.options)}),this.onRetryListeners.forEach(function(t){var i;return(i=e.ws)===null||i===void 0?void 0:i.addEventListener(Nd.WebsocketEvents.retry,t.listener,t.options)}),this.ws)},n}();Jx.WebsocketBuilder=Lce;(function(n){var e=ay&&ay.__createBinding||(Object.create?function(i,s,r,o){o===void 0&&(o=r),Object.defineProperty(i,o,{enumerable:!0,get:function(){return s[r]}})}:function(i,s,r,o){o===void 0&&(o=r),i[o]=s[r]}),t=ay&&ay.__exportStar||function(i,s){for(var r in i)r!=="default"&&!Object.prototype.hasOwnProperty.call(s,r)&&e(s,i,r)};Object.defineProperty(n,"__esModule",{value:!0}),t(BG,n),t(jx,n),t(Xx,n),t(qx,n),t(DG,n),t(Yx,n),t(Kx,n),t(eR,n),t(Jx,n)})($I);const Fce=mA($I),Uce=LG({__proto__:null,default:Fce},[$I]),co={node:"node",material:"material",camera:"camera",light:"light"},Wh="KHR_animation_pointer",Nce={CUBICSPLINE:void 0,LINEAR:Ha,STEP:eh},bk=Ut.findNode;let _k=!1;class zce{constructor(e){this.parser=e,this.name=Wh,this.animationPointerResolver=null}setAnimationPointerResolver(e){return this.animationPointerResolver=e,this}_patchPropertyBindingFindNode(){_k||(_k=!0,Ut.findNode=function(e,t){if(t.startsWith(".materials.")){const i=t.substring(11).substring(t.indexOf(".")),s=i.indexOf("."),r=s<0?i:i.substring(0,s);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 s;for(let r=1;r<i.length;r++){const o=i[r];if(o.length==36)s=e.getObjectByProperty("uuid",o);else if(s&&s[o]){const c=Number.parseInt(o);let l=o;c>=0&&(l=c),s=s[l]}else{const c=e.getObjectByName(o);c&&(s=c)}}if(!s){const r=bk(e,i[2]);return r||console.warn(Wh+": Property binding not found",t,e,e.name,i),r}return s}return bk(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[Wh]&&t.path&&t.path==="pointer";if(!i)return null;let s,r=co.node,o;if(i){const c=t.extensions[Wh];let l=c.pointer;if(!l){console.warn("Invalid path",c,t);return}if(l.startsWith("/materials/")?r=co.material:l.startsWith("/extensions/KHR_lights_punctual/lights/")?r=co.light:l.startsWith("/cameras/")&&(r=co.camera),o=this._tryResolveTargetId(l,r),o===null||isNaN(o)){console.warn("Failed resolving animation node id: "+o,l);return}switch(r){case co.material:const d=("/materials/"+o.toString()+"/").length,f=l.substring(0,d);switch(s=l.substring(d),s){case"pbrMetallicRoughness/baseColorFactor":s="color";break;case"pbrMetallicRoughness/roughnessFactor":s="roughness";break;case"pbrMetallicRoughness/metallicFactor":s="metalness";break;case"emissiveFactor":s="emissive";break;case"alphaCutoff":s="alphaTest";break;case"occlusionTexture/strength":s="aoMapIntensity";break;case"normalTexture/scale":s="normalScale";break;case"pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/scale":s="map/repeat";break;case"pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/offset":s="map/offset";break;case"emissiveTexture/extensions/KHR_texture_transform/scale":s="emissiveMap/repeat";break;case"emissiveTexture/extensions/KHR_texture_transform/offset":s="emissiveMap/offset";break;case"extensions/KHR_materials_emissive_strength/emissiveStrength":s="emissiveIntensity";break;case"extensions/KHR_materials_transmission/transmissionFactor":s="transmission";break;case"extensions/KHR_materials_ior/ior":s="ior";break;case"extensions/KHR_materials_volume/thicknessFactor":s="thickness";break;case"extensions/KHR_materials_volume/attenuationColor":s="attenuationColor";break;case"extensions/KHR_materials_volume/attenuationDistance":s="attenuationDistance";break;case"extensions/KHR_materials_iridescence/iridescenceFactor":s="iridescence";break;case"extensions/KHR_materials_iridescence/iridescenceIor":s="iridescenceIOR";break;case"extensions/KHR_materials_iridescence/iridescenceThicknessMinimum":s="iridescenceThicknessRange[0]";break;case"extensions/KHR_materials_iridescence/iridescenceThicknessMaximum":s="iridescenceThicknessRange[1]";break;case"extensions/KHR_materials_clearcoat/clearcoatFactor":s="clearcoat";break;case"extensions/KHR_materials_clearcoat/clearcoatRoughnessFactor":s="clearcoatRoughness";break;case"extensions/KHR_materials_sheen/sheenColorFactor":s="sheenColor";break;case"extensions/KHR_materials_sheen/sheenRoughnessFactor":s="sheenRoughness";break;case"extensions/KHR_materials_specular/specularFactor":s="specularIntensity";break;case"extensions/KHR_materials_specular/specularColorFactor":s="specularColor";break}l=f+s;break;case co.node:const p=("/nodes/"+o.toString()+"/").length,g=l.substring(0,p);switch(s=l.substring(p),s){case"translation":s="position";break;case"rotation":s="quaternion";break;case"scale":s="scale";break;case"weights":s="morphTargetInfluences";break}l=g+s;break;case co.light:const A=("/extensions/KHR_lights_punctual/lights/"+o.toString()+"/").length;switch(s=l.substring(A),s){case"color":break;case"intensity":break;case"spot/innerConeAngle":s="penumbra";break;case"spot/outerConeAngle":s="angle";break;case"range":s="distance";break}l="/lights/"+o.toString()+"/"+s;break;case co.camera:const v=("/cameras/"+o.toString()+"/").length,m=l.substring(0,v);switch(s=l.substring(v),s){case"perspective/yfov":s="fov";break;case"perspective/znear":case"orthographic/znear":s="near";break;case"perspective/zfar":case"orthographic/zfar":s="far";break;case"perspective/aspect":s="aspect";break;case"orthographic/xmag":s="zoom";break;case"orthographic/ymag":s="zoom";break}l=m+s;break}const h=this.animationPointerResolver;h&&h.resolvePath&&(l=h.resolvePath(l)),t.extensions[Wh].pointer=l}if(o===null||isNaN(o)){console.warn("Failed resolving animation node id: "+o,t);return}let a;return r===co.node?a=this.parser.getDependency("node",o):r===co.material?a=this.parser.getDependency("material",o):r===co.light?a=this.parser.getDependency("light",o):r===co.camera?a=this.parser.getDependency("camera",o):console.error("Unhandled type",r),a}createAnimationTracksWithAnimationPointer(e,t,i,s,r){if(!(r.extensions&&r.extensions[Wh]&&r.path&&r.path==="pointer"))return null;let a=r.extensions[Wh].pointer;if(!a)return null;const c=[];a=a.replaceAll("/",".");const l=a.split(".");var d=e.name!==void 0&&e.name!==null?e.name:e.uuid;if(l[2]=d,l[3]==="morphTargetInfluences"&&e.type==="Group"){for(const p of e.children)p instanceof Bu&&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=th;break;case 2:case 3:g=Yc;break;case 4:a.endsWith(".quaternion")?g=Va:g=u_;break}const A=s.interpolation!==void 0?Nce[s.interpolation]:Ha;let v=p._getArrayFromAccessor(i);a.endsWith(".fov")&&(v=v.map(b=>b/Math.PI*180));const m=new g(a,t.array,v,A);if(A==="CUBICSPLINE"&&p._createCubicSplineTrackInterpolant(m),c.push(m),a&&i.itemSize===4&&a.startsWith(".materials.")&&a.endsWith(".color")){const b=new Float32Array(v.length/4);for(let _=0,C=v.length/4;_<C;_+=1)b[_]=v[_*4+3];const y=new g(a.replace(".color",".opacity"),t.array,b,A);A==="CUBICSPLINE"&&p._createCubicSplineTrackInterpolant(m),c.push(y)}}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,s=this.parser,r=i.animations[e],o=r.name?r.name:"animation_"+e,a=[],c=[],l=[],h=[],d=[];for(let f=0,p=r.channels.length;f<p;f++){const g=r.channels[f],A=r.samplers[g.sampler],v=g.target,m=r.parameters!==void 0?r.parameters[A.input]:A.input,b=r.parameters!==void 0?r.parameters[A.output]:A.output;let y=t.loadAnimationTargetFromChannelWithAnimationPointer(g);y||(y=t.loadAnimationTargetFromChannel(g)),a.push(y),c.push(s.getDependency("accessor",m)),l.push(s.getDependency("accessor",b)),h.push(A),d.push(v)}return Promise.all([Promise.all(a),Promise.all(c),Promise.all(l),Promise.all(h),Promise.all(d)]).then(function(f){const p=f[0],g=f[1],A=f[2],v=f[3],m=f[4],b=[];for(let y=0,_=p.length;y<_;y++){const C=p[y],M=g[y],I=A[y],R=v[y],E=m[y];if(C===void 0)continue;C.updateMatrix&&(C.updateMatrix(),C.matrixAutoUpdate=!0);let T=t.createAnimationTracksWithAnimationPointer(C,M,I,R,E);if(T||(T=s._createAnimationTracks(C,M,I,R,E)),T)for(let O=0;O<T.length;O++)b.push(T[O])}return new Ks(o,void 0,b)})}}const Gce=Object.freeze(Object.defineProperty({__proto__:null,GLTFAnimationPointerExtension:zce},Symbol.toStringTag,{value:"Module"}));exports.$physicsKey=fce;exports.ActionBuilder=di;exports.ActionCollection=fT;exports.ActionModel=kr;exports.Addressables=XU;exports.AlignmentConstraint=MA;exports.AmbientMode=ff;exports.Animation=Wr;exports.AnimationCurve=Fu;exports.AnimationExtension=W_;exports.AnimationTrackHandler=cx;exports.Animator=Bs;exports.AnimatorConditionMode=Nl;exports.AnimatorController=Mu;exports.AnimatorControllerParameterType=pT;exports.AnimatorStateInfo=y0;exports.Antialiasing=NA;exports.Application=JU;exports.ApplicationEvents=ob;exports.AssetDatabase=nU;exports.AssetReference=Un;exports.AttachedObject=wo;exports.AttachedObjectEvents=yb;exports.AudioExtension=hx;exports.AudioListener=zf;exports.AudioSource=Cn;exports.AudioTrackHandler=yu;exports.AvatarBlink_Simple=zu;exports.AvatarEyeLook_Rotation=dp;exports.AvatarLoader=q_;exports.AvatarMarker=Kn;exports.AvatarModel=X_;exports.Avatar_Brain_LookAt=Lm;exports.Avatar_MouthShapes=zA;exports.Avatar_MustacheShake=KT;exports.Avatar_POI=Zs;exports.Axes=$d;exports.AxesHelper=fp;exports.BaseUIComponent=ta;exports.BasicIKConstraint=$T;exports.BehaviorExtension=dx;exports.BehaviorModel=ls;exports.Behaviour=Me;exports.Bloom=Gu;exports.BoxCollider=HA;exports.BoxGizmo=Nu;exports.BoxHelperComponent=xo;exports.Button=ll;exports.CallInfo=kf;exports.Camera=Oi;exports.Canvas=us;exports.CanvasGroup=oh;exports.CapsuleCollider=rh;exports.ChangeMaterialOnClick=mp;exports.ChangeTransformOnClick=Qu;exports.CharacterController=Wu;exports.CharacterControllerInput=ul;exports.ChromaticAberration=qA;exports.CircularBuffer=Ga;exports.ClearFlags=yz;exports.ClipExtrapolation=va;exports.Collider=Ya;exports.Collision=gG;exports.CollisionDetectionMode=Y_;exports.ColorAdjustments=bh;exports.ColorBySpeedModule=ju;exports.ColorOverLifetimeModule=YA;exports.Component=dh;exports.ComponentEvents=vA;exports.ComponentLifecycleEvents=yA;exports.ConnectionEvents=LF;exports.ContactPoint=pG;exports.Context=Nt;exports.ContextArgs=Kq;exports.ContextEvent=Qs;exports.ContextRegistry=Bi;exports.ControlTrackHandler=lx;exports.ControllerEvents=_c;exports.ControllerType=Af;exports.CustomBranding=Sh;exports.CustomShader=Ir;exports.DefaultReflectionMode=rb;exports.Deletable=hI;exports.DeleteBox=vx;exports.DepthOfField=ca;exports.DeviceFlag=yx;exports.DocumentExtension=uI;exports.DragControls=_p;exports.DropListener=JA;exports.Duplicatable=Yu;exports.EXTENSION_NAME=p0;exports.EmissionModule=Ja;exports.EmphasizeOnClick=vp;exports.EngineLoadingView=Yg;exports.EventList=cs;exports.EventListEvent=H_;exports.EventSystem=qs;exports.EventTrigger=_x;exports.FieldWithDefault=cT;exports.FileSpawnModel=Dz;exports.File_Event=Bz;exports.FixedJoint=vI;exports.FlyControls=yI;exports.Fog=xp;exports.FrameEvent=xr;exports.GENERATOR=E_;exports.GameObject=se;exports.Gizmos=Lc;exports.GltfExport=Ic;exports.GltfExportBox=xI;exports.GltfLoadEvent=_u;exports.GltfLoadEventType=cG;exports.Gradient=_h;exports.Graphic=Hu;exports.GraphicRaycaster=qT;exports.Graphics=Qo;exports.GridHelper=wp;exports.GridLayoutGroup=oI;exports.GroundProjectedEnv=Ku;exports.GroupActionModel=Vl;exports.HideFlags=lU;exports.HideOnStart=cI;exports.HingeJoint=ZA;exports.HorizontalLayoutGroup=rI;exports.HostData=V9;exports.Image=gp;exports.ImageReference=df;exports.ImageReferenceSerializer=qU;exports.InheritVelocityModule=wh;exports.Input=D2;exports.InputEvents=_a;exports.InputField=Ju;exports.InstancingUtil=vr;exports.InstantiateEvent=zF;exports.InstantiateIdProvider=Js;exports.InstantiateOptions=Qa;exports.Interactable=np;exports.JoinedRoomResponse=I9;exports.KeyEventArgs=n0;exports.LODGroup=ev;exports.LODModel=Zu;exports.LeftRoomResponse=R9;exports.Light=Sr;exports.LightData=KU;exports.LimitVelocityOverLifetimeModule=In;exports.LoadingElementOptions=hY;exports.LogStats=SI;exports.LogType=Jo;exports.LookAt=$u;exports.LookAtConstraint=IA;exports.MainModule=ms;exports.MarkerType=YT;exports.MaskableGraphic=WA;exports.Mathf=tt;exports.MeshCollider=VA;exports.MeshRenderer=V_;exports.MinMaxCurve=lt;exports.MinMaxGradient=wr;exports.NEEDLE_progressive=Or;exports.NeedleEngine=Bi;exports.NeedleEngineHTMLElement=WI;exports.NeedleGltfLoader=HI;exports.NeedlePatchesKey=c0;exports.NestedGltf=Cx;exports.NetworkConnection=UF;exports.Networking=qu;exports.NoiseModule=Ai;exports.ObjectRaycaster=el;exports.ObjectUtils=Jz;exports.OffsetConstraint=ed;exports.OpenURL=Sp;exports.OrbitControls=cl;exports.Outline=pp;exports.OwnershipEvent=FF;exports.OwnershipModel=C_;exports.Padding=Ah;exports.ParticleBurst=qm;exports.ParticleSubEmitter=Bx;exports.ParticleSystem=En;exports.ParticleSystemRenderer=fl;exports.PeerNetworking=kF;exports.Physics=H2;exports.PhysicsMaterialCombine=Aa;exports.PixelationEffect=nv;exports.PlayAnimationOnClick=yh;exports.PlayAudioOnClick=yp;exports.PlayableDirector=Xc;exports.PlayerColor=Iu;exports.PlayerState=bu;exports.PlayerStateEvent=oG;exports.PlayerSync=Vx;exports.PlayerView=sN;exports.PlayerViewManager=rN;exports.PointerEventData=Fc;exports.PointerType=B2;exports.PostProcessingEffect=Os;exports.PostProcessingHandler=Dx;exports.PreliminaryAction=bp;exports.PreliminaryTrigger=jA;exports.PrimitiveType=OI;exports.ProgressiveLoadingInfo=SN;exports.PromiseAllWithErrors=Pk;exports.PromiseErrorResult=Rk;exports.RGBAColor=_i;exports.RapierPhysics=Jh;exports.RawImage=px;exports.RaycastOptions=sa;exports.Raycaster=lp;exports.Rect=iI;exports.RectTransform=tr;exports.ReflectionProbe=ip;exports.RegisteredAnimationInfo=Q_;exports.RemoteSkybox=tl;exports.RenderTexture=ql;exports.RenderTextureSerializer=MN;exports.Renderer=Hi;exports.RendererData=YU;exports.RendererLightmap=km;exports.Rigidbody=Yi;exports.RigidbodyConstraints=on;exports.RoomEvents=nn;exports.RotationBySpeedModule=Jr;exports.RotationOverLifetimeModule=Po;exports.SceneLightSettings=lb;exports.SceneSwitcher=Cr;exports.ScreenCapture=sv;exports.ScreenSpaceAmbientOcclusion=pl;exports.ScreenSpaceAmbientOcclusionN8=ha;exports.SendQueue=dr;exports.SetActiveOnClick=Ap;exports.ShadowCatcher=av;exports.ShapeModule=mn;exports.SignalAsset=LA;exports.SignalReceiver=up;exports.SignalReceiverEvent=hp;exports.SignalTrackHandler=jm;exports.Size=tI;exports.SizeBySpeedModule=rr;exports.SizeOverLifetimeModule=xh;exports.SkinnedMeshRenderer=lT;exports.SmoothFollow=Ch;exports.SpatialHtml=kI;exports.SpatialTrigger=lv;exports.SpatialTriggerReceiver=za;exports.SpectatorCamera=Lx;exports.SphereCollider=GA;exports.SphereIntersection=G2;exports.SphereOverlapResult=mG;exports.Sprite=gl;exports.SpriteData=Tp;exports.SpriteRenderer=$a;exports.SpriteSheet=hv;exports.StateMachineBehaviour=gK;exports.SubEmitterSystem=$m;exports.SyncedCamera=Fx;exports.SyncedRoom=Eh;exports.SyncedTransform=nh;exports.TapGestureTrigger=lI;exports.TeleportTarget=sx;exports.TestRunner=LI;exports.TestSimulateUserData=FI;exports.Text=or;exports.TextBuilder=mx;exports.TextExtension=KA;exports.TextureSheetAnimationModule=As;exports.TiltShiftEffect=ec;exports.Time=V2;exports.ToneMapping=dv;exports.TrackHandler=FA;exports.TrackType=Rr;exports.TrailModule=Qi;exports.TransformData=Yl;exports.TransformGizmo=id;exports.TriggerBuilder=yr;exports.TriggerModel=Wc;exports.TypeStore=q;exports.UIRaycastUtils=Nf;exports.UIRootComponent=kA;exports.USDObject=gr;exports.USDZExporter=$r;exports.USDZText=Ql;exports.USDZUIExtension=Ax;exports.Upload_Result=wE;exports.UriSerializer=TN;exports.UsageMarker=sp;exports.UserJoinedOrLeftRoomModel=P9;exports.VERSION=kc;exports.VRUserState=qo;exports.VariantAction=dT;exports.VelocityOverLifetimeModule=Ki;exports.VerticalLayoutGroup=sI;exports.VideoPlayer=vs;exports.ViewDevice=Na;exports.Vignette=nd;exports.VisibilityAction=XA;exports.Voip=rl;exports.Volume=Nx;exports.VolumeParameter=Rt;exports.VolumeProfile=UA;exports.WaitForFrames=Zre;exports.WaitForSeconds=Yz;exports.Watch=xf;exports.WebAR=vu;exports.WebARCameraBackground=zx;exports.WebARSessionRoot=Wa;exports.WebXR=Et;exports.WebXRAvatar=Oa;exports.WebXRController=en;exports.WebXREvent=Ci;exports.WebXRImageTracking=Gx;exports.WebXRImageTrackingModel=ml;exports.WebXRPlaneTracking=fv;exports.WebXRSync=Wm;exports.WebXRTrackedImage=Rc;exports.XRFlag=Fr;exports.XRGrabModel=Hx;exports.XRGrabRendering=NI;exports.XRRig=rx;exports.XRSessionMode=Dm;exports.XRState=Xs;exports.XRStateFlag=un;exports.__Ignore=zI;exports.__internalNotifyObjectDestroyed=cU;exports.activeInHierarchyFieldName=Qc;exports.addAttributeChangeCallback=Tk;exports.addCustomExtension=A7;exports.addFile=Oz;exports.addFileFromUrl=kz;exports.addGltfLoadEventListener=tce;exports.addNewComponent=ku;exports.addPatch=D_;exports.apply=B_;exports.applyHMRChanges=dce;exports.beginListenDestroy=VF;exports.beginListenFileSpawn=Lz;exports.beginListenInstantiate=QF;exports.binaryIdentifierCasts=T1;exports.build_scene_functions=Yq;exports.builtinComponentKeyName=eu;exports.calculateProgress01=iT;exports.colorSerializer=x7;exports.componentSerializer=g0;exports.copyTexture=z2;exports.createGLTFLoader=VI;exports.createMotion=VN;exports.debugNet=Gs;exports.debugOwner=yg;exports.deepClone=Bb;exports.delay=sA;exports.deserializeObject=K0;exports.destroy=Kc;exports.destroyComponentInstance=KF;exports.detectARSupport=Az;exports.detectVRSupport=vz;exports.disposeObjectResources=Ri;exports.download=WU;exports.download_file=K1;exports.editorGuidKeyName=Vg;exports.effectsOrder=uM;exports.eventListSerializer=M7;exports.findByGuid=wA;exports.findObjectOfType=ZF;exports.findObjectsOfType=$F;exports.findResourceUsers=z1;exports.foreachComponent=Eu;exports.foreachComponentEnumerator=H1;exports.forward=Fj;exports.generateSeed=I_;exports.getComponent=Kf;exports.getComponentInChildren=_A;exports.getComponentInParent=Im;exports.getComponents=bA;exports.getComponentsInChildren=xA;exports.getComponentsInParent=P_;exports.getIp=XG;exports.getIpAndLocation=qG;exports.getIpCloudflare=jG;exports.getLoader=ea;exports.getOrAddComponent=R_;exports.getParam=re;exports.getPath=GG;exports.getPeerOptions=C9;exports.getPeerjsInstance=O1;exports.getResourceUserCount=r6;exports.getUrlParams=nA;exports.getWorldDirection=Nj;exports.getWorldEuler=L2;exports.getWorldPosition=wt;exports.getWorldQuaternion=Fn;exports.getWorldRotation=b_;exports.getWorldScale=qn;exports.hasIndieLicense=tT;exports.hasProLicense=pf;exports.hash=Y1;exports.instantiate=SA;exports.isActiveInHierarchy=hU;exports.isActiveSelf=Jf;exports.isAnimationAction=N2;exports.isDebugMode=UG;exports.isDestroyed=G1;exports.isDevEnvironment=bi;exports.isDisposed=n6;exports.isHostedOnGlitch=Bk;exports.isHotReloading=cce;exports.isLocalNetwork=$s;exports.isMobileDevice=nl;exports.isMozillaXR=L0;exports.isQuest=QG;exports.isResourceTrackingEnabled=rU;exports.isSafari=wc;exports.isUsingInstancing=k_;exports.isiOS=pm;exports.loadSync=QI;exports.logHierarchy=Z0;exports.lookAtInverse=Dj;exports.makeId=zG;exports.makeIdFromRandomWords=Ck;exports.markAsInstancedRendered=uU;exports.moveComponentInstance=F1;exports.nameof=FG;exports.nameofFactory=k0;exports.objectSerializer=EN;exports.parseSync=hG;exports.prefix=hJ;exports.pushState=wk;exports.randomNumber=Sk;exports.registerBinaryType=w_;exports.registerComponent=G_;exports.registerComponentExtension=aT;exports.registerCustomEffectType=Ro;exports.registerExtensions=CN;exports.registerHotReloadType=lce;exports.registerLoader=J1;exports.registerPrefabProvider=jF;exports.registerType=bj;exports.relativePathPrefix=Mk;exports.removeAttributeChangeCallback=Ik;exports.removeComponent=L1;exports.removeCustomExtension=v7;exports.removeGltfLoadEventListener=ice;exports.removePatch=e6;exports.resolveUrl=il;exports.sanitizeString=Ek;exports.saveImage=Rce;exports.screenshot=Ice;exports.sendDestroyed=HF;exports.serializable=x;exports.serializeObject=R2;exports.serializeable=tp;exports.setActive=Wg;exports.setAllowOverlayMessages=KG;exports.setDestroyed=fU;exports.setDevEnvironment=pj;exports.setDisposable=N1;exports.setOrAddParamsToUrl=fm;exports.setParam=NG;exports.setParamWithoutReload=xk;exports.setPeerOptions=E9;exports.setResourceTrackingEnabled=i6;exports.setState=SM;exports.setWorldEuler=F2;exports.setWorldPosition=fn;exports.setWorldPositionXYZ=Bf;exports.setWorldQuaternion=_r;exports.setWorldQuaternionXYZW=k2;exports.setWorldRotation=U2;exports.setWorldRotationXYZ=__;exports.setWorldScale=rE;exports.showBalloonMessage=_n;exports.showBalloonWarning=nr;exports.showDebugConsole=C1;exports.slerp=O2;exports.syncDestroy=T_;exports.syncField=BI;exports.syncInstantiate=k1;exports.textureToCanvas=Gj;exports.tryCastBinary=Q2;exports.tryFindObject=_f;exports.tryFindObjectByName=uG;exports.tryFindScript=nce;exports.tryGetGuid=W2;exports.unregisterHotReloadType=hce;exports.upload_file=QU;exports.validate=Xr;
|