@needle-tools/engine 3.37.7-beta → 3.37.7-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3 -0
- package/dist/needle-engine.js +9 -8
- package/dist/needle-engine.light.js +9 -8
- package/dist/needle-engine.light.min.js +2 -2
- package/dist/needle-engine.light.umd.cjs +2 -2
- package/dist/needle-engine.min.js +2 -2
- package/dist/needle-engine.umd.cjs +2 -2
- package/lib/engine-components/export/usdz/extensions/Animation.js +3 -2
- package/lib/engine-components/export/usdz/extensions/Animation.js.map +1 -1
- package/package.json +1 -1
- package/src/engine-components/export/usdz/extensions/Animation.ts +3 -2
|
@@ -4340,7 +4340,7 @@ void main() {
|
|
|
4340
4340
|
}`),r(Ns,"blipMaterial"),r(Ns,"mesh");function wH(g){return Ns.copyTexture(g)}function X9(g,A=!1){return Ns.textureToCanvas(g,A)}function $9(g){return typeof HTMLImageElement<"u"&&g instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&g instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&g instanceof OffscreenCanvas||typeof ImageBitmap<"u"&&g instanceof ImageBitmap}let df=!1;W5((...g)=>{var A;he()&&((A=st.Current)!=null&&A.isInXR)&&(Ic(!0),yH("error",...g))});function Ic(g){if(g){if(df)return;df=!0,e6()}else{if(!df)return;df=!1,t6()}}const Uh={log:void 0,warn:void 0,error:void 0};class A6{constructor(){r(this,"familyName","needle-xr");r(this,"root",null);r(this,"context",null);r(this,"defaultFontSize",.06);r(this,"targetObject",new uA);r(this,"userForwardViewPoint",new w);r(this,"oneEuroFilter",new WR(90,.8));r(this,"_lastElementRemoveTime",0);r(this,"onBeforeRender",()=>{var e,t;const A=(e=this.context)==null?void 0:e.mainCamera;if(this.context&&A instanceof He){const i=this.getRoot();Number.isNaN(i.position.x)&&i.position.set(0,0,0),Number.isNaN(i.quaternion.x)&&i.quaternion.set(0,0,0,1),this.context.scene.add(this.targetObject);const I=((t=this.context.xr)==null?void 0:t.rigScale)??1,o=3.5*I,s=A.worldForward;s.y=0,s.normalize().multiplyScalar(o),this.userForwardViewPoint.copy(A.worldPosition).sub(s),this.targetObject.position.distanceTo(this.userForwardViewPoint)>2*I&&(this.targetObject.position.copy(this.userForwardViewPoint),Qu(this.targetObject,A,!0,!0),this.targetObject.rotateY(Math.PI)),this.oneEuroFilter.filter(this.targetObject.position,i.position,this.context.time.time);const C=this.context.time.deltaTime;if(i.quaternion.slerp(this.targetObject.quaternion,C*5),i.scale.setScalar(I),this.targetObject.removeFromParent(),this.context.scene.add(i),this.context.time.time-this._lastElementRemoveTime>.1){this._lastElementRemoveTime=this.context.time.time;const a=Date.now();for(let B=0;B<this._activeTexts.length;B++){const Q=this._activeTexts[B];if(Q instanceof _t.Text&&a-Q._activatedTime>2e4){Q.removeFromParent(),this._textBuffer.push(Q),this._activeTexts.splice(B,1);break}}}}});r(this,"textOptions",{fontSize:this.defaultFontSize,fontFamily:this.familyName,padding:.03,margin:.005,color:0,backgroundColor:16777215,backgroundOpacity:.4,borderRadius:.03,offset:.025});r(this,"_textBuffer",[]);r(this,"_activeTexts",[]);this.ensureFont()}onEnable(){this.context=st.Current||st.All[0],this.context.pre_render_callbacks.push(this.onBeforeRender)}onDisable(){var A,e,t;(e=this.context)==null||e.pre_render_callbacks.splice((A=this.context)==null?void 0:A.pre_render_callbacks.indexOf(this.onBeforeRender),1),(t=this.root)==null||t.removeFromParent()}addLog(A,e){const t=this.getRoot(),i=this.getText();let I=16777215,o=0;switch(A){case"log":I=16777215,o=0;break;case"warn":I=16772761,o=4465152;break;case"error":I=16755370,o=7798784;break}e.length>1e3&&(e=e.substring(0,1e3)+"...");const s=new Date().toISOString().split("T")[1].split(".")[0];i.textContent="["+s+"] "+e,i.visible=!0,i._activatedTime=Date.now(),t.add(i),this._activeTexts.push(i),this.context&&this.context.scene.add(t),i.set({backgroundColor:I,color:o}),_t.update()}ensureFont(){let A=_t.FontLibrary.getFontFamily(this.familyName);if(!A){A=_t.FontLibrary.addFontFamily(this.familyName);const e=A.addVariant("normal","normal","./include/needle/arial-msdf.json","./include/needle/arial.png");e==null||e.addEventListener("ready",()=>{_t.update()})}}getText(){const A=this.getRoot();if(this._textBuffer.length>0){const t=this._textBuffer.pop();return t.visible=!0,setTimeout(()=>this.disableDepthTestRecursive(t),100),t}if(A.children.length>20&&this._activeTexts.length>0)return this._activeTexts.shift();const e=new _t.Text(this.textOptions);return setTimeout(()=>this.disableDepthTestRecursive(e),500),setTimeout(()=>this.disableDepthTestRecursive(e),1500),e}disableDepthTestRecursive(A,e=0){for(let i=0;i<A.children.length;i++){const I=A.children[i];I instanceof uA&&this.disableDepthTestRecursive(I,e+1)}A.renderOrder=10*e,A.layers.set(2);const t=A.material;t&&(t.depthWrite=!1,t.depthTest=!1,t.transparent=!0),e===0&&_t.update()}getRoot(){if(this.root)return this.root;const A=this.defaultFontSize,e={boxSizing:"border-box",fontFamily:this.familyName,width:"2.6",fontSize:A,color:0,lineHeight:1,backgroundColor:16777215,backgroundOpacity:0,whiteSpace:"pre-wrap",flexDirection:"column-reverse"};return this.root=new _t.Block(e),this.root}}let UI=null;function e6(){UI||(UI=new A6),UI.onEnable();for(const g in Uh){Uh[g]=console[g];let A=!1;console[g]=function(){var e;if((e=Uh[g])==null||e.apply(console,arguments),!A)try{A=!0,yH(g,...arguments)}finally{A=!1}}}}function t6(){UI==null||UI.onDisable();for(const g in Uh)console[g]=Uh[g]}const wl=new Map;function yH(g,...A){try{switch(wl.clear(),g){case"log":UI==null||UI.addLog("log",e());break;case"warn":UI==null||UI.addLog("warn",e());break;case"error":UI==null||UI.addLog("error",e());break}}catch(I){console.error("Error in spatial console",I)}finally{wl.clear()}function e(){let I="";for(let o=0;o<A.length;o++){const s=A[o];I+=t(s),o<A.length-1&&(I+=", ")}return I}function t(I,o=0){if(typeof I=="string")return'"'+I+'"';if(typeof I=="number"){if(I%1!==0){const n=I.toFixed(5),C=n.indexOf(".");let a=n.length-1;for(;a>C&&n[a]==="0";)a--;return n.substring(0,a+1)}return I.toString()}else if(Array.isArray(I)){let s="[";for(let n=0;n<I.length;n++){const C=I[n];s+=t(C,o+1),n<I.length-1&&(s+=", ")}return s+="]",s}else{if(I===null)return"null";if(I===void 0)return"undefined";if(typeof I=="function")return I.name+"()"}if(I instanceof iA)return`(${t(I.x)}, ${t(I.y)})`;if(I instanceof w)return`(${t(I.x)}, ${t(I.y)}, ${t(I.z)})`;if(I instanceof Ae)return`(${t(I.x)}, ${t(I.y)}, ${t(I.z)}, ${t(I.w)})`;if(I instanceof MA)return`(${t(I.x)}, ${t(I.y)}, ${t(I.z)}, ${t(I.w)})`;if(I instanceof be||I instanceof fe)return I.name;if(I instanceof Le)return`[${I.elements.join(", ")}]`;if(I instanceof GA)return`[${I.elements.join(", ")}]`;if(I instanceof QI)return I.mask.toString();if(typeof I=="object"){if(wl.has(I))return"*";let s=`{
|
|
4341
4341
|
`;s+=i(o);const n=Object.keys(I);let C="";for(let a=0;a<n.length;a++){const B=n[a],Q=I[B];if(wl.has(Q)){C+="";continue}wl.set(Q,!0),C+=B+":"+t(Q,o+1),a<n.length-1&&(C+=", "),C.length>=60&&(C+=`
|
|
4342
4342
|
`,C+=i(o),s+=C,C="")}return s+=C,s+=`
|
|
4343
|
-
}`,s}return I}function i(I){let o="";for(let s=0;s<I;s++)o+=" ";return o}}const i6=IA("nodevlogs");function Ci(g,A=So.Log){Sn(A,g)}function fi(g){Ci(g,So.Warn)}function AN(g){Ci(g,So.Error)}let eM;function he(){return i6?!1:eM!==void 0?eM:No()}function g6(g){eM=g}const SH=IA("debugdefines");kc('if(!globalThis[""3.37.7-beta""]) globalThis[""3.37.7-beta""] = "0.0.0";');kc('if(!globalThis[""undefined""]) globalThis[""undefined""] = "unknown";');kc('if(!globalThis[""Mon Apr 29 2024
|
|
4343
|
+
}`,s}return I}function i(I){let o="";for(let s=0;s<I;s++)o+=" ";return o}}const i6=IA("nodevlogs");function Ci(g,A=So.Log){Sn(A,g)}function fi(g){Ci(g,So.Warn)}function AN(g){Ci(g,So.Error)}let eM;function he(){return i6?!1:eM!==void 0?eM:No()}function g6(g){eM=g}const SH=IA("debugdefines");kc('if(!globalThis[""3.37.7-beta.1""]) globalThis[""3.37.7-beta.1""] = "0.0.0";');kc('if(!globalThis[""undefined""]) globalThis[""undefined""] = "unknown";');kc('if(!globalThis[""Mon Apr 29 2024 17:15:43 GMT+0200 (Central European Summer Time)""]) globalThis[""Mon Apr 29 2024 17:15:43 GMT+0200 (Central European Summer Time)""] = "unknown";');kc('globalThis["__NEEDLE_ENGINE_VERSION__"] = "3.37.7-beta.1";');kc('globalThis["__NEEDLE_ENGINE_GENERATOR__"] = "undefined";');kc('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "Mon Apr 29 2024 17:15:43 GMT+0200 (Central European Summer Time)";');const Gn="3.37.7-beta.1",AS="undefined",eN="Mon Apr 29 2024 17:15:43 GMT+0200 (Central European Summer Time)";SH&&console.log(`Engine version: ${Gn} (generator: ${AS})
|
|
4344
4344
|
Project built at ${eN}`);const FC="needle_isActiveInHierarchy",gB="builtin_components",Rh="needle_editor_guid";function kc(g){try{(0,eval)(g)}catch(A){SH&&console.error(A)}}const I6='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 160 187.74"><defs><linearGradient id="a" x1="89.64" y1="184.81" x2="90.48" y2="21.85" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#62d399"/><stop offset=".51" stop-color="#acd842"/><stop offset=".9" stop-color="#d7db0a"/></linearGradient><linearGradient id="b" x1="69.68" y1="178.9" x2="68.08" y2="16.77" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#0ba398"/><stop offset=".5" stop-color="#4ca352"/><stop offset="1" stop-color="#76a30a"/></linearGradient><linearGradient id="c" x1="36.6" y1="152.17" x2="34.7" y2="84.19" gradientUnits="userSpaceOnUse"><stop offset=".19" stop-color="#36a382"/><stop offset=".54" stop-color="#49a459"/><stop offset="1" stop-color="#76a30b"/></linearGradient><linearGradient id="d" x1="15.82" y1="153.24" x2="18" y2="90.86" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#267880"/><stop offset=".51" stop-color="#457a5c"/><stop offset="1" stop-color="#717516"/></linearGradient><linearGradient id="e" x1="135.08" y1="135.43" x2="148.93" y2="63.47" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#b0d939"/><stop offset="1" stop-color="#eadb04"/></linearGradient><linearGradient id="f" x1="-4163.25" y1="2285.12" x2="-4160.81" y2="2215.34" gradientTransform="rotate(20 4088.49 13316.712)" gradientUnits="userSpaceOnUse"><stop offset=".17" stop-color="#74af52"/><stop offset=".48" stop-color="#99be32"/><stop offset="1" stop-color="#c0c40a"/></linearGradient><symbol id="g" viewBox="0 0 160 187.74"><path style="fill:url(#a)" d="M79.32 36.98v150.76L95 174.54l6.59-156.31-22.27 18.75z"/><path style="fill:url(#b)" d="M79.32 36.98 57.05 18.23l6.59 156.31 15.68 13.2V36.98z"/><path style="fill:url(#c)" d="m25.19 104.83 8.63 49.04 12.5-14.95-2.46-56.42-18.67 22.33z"/><path style="fill:url(#d)" d="M25.19 104.83 0 90.24l16.97 53.86 16.85 9.77-8.63-49.04z"/><path style="fill:#9c3" d="M43.86 82.5 18.69 67.98 0 90.24l25.18 14.59L43.86 82.5z"/><path style="fill:url(#e)" d="m134.82 78.69-9.97 56.5 15.58-9.04L160 64.1l-25.18 14.59z"/><path style="fill:url(#f)" d="m134.82 78.69-18.68-22.33-2.86 65 11.57 13.83 9.97-56.5z"/><path style="fill:#ffe113" d="m160 64.1-18.69-22.26-25.17 14.52 18.67 22.33L160 64.1z"/><path style="fill:#f3e600" d="M101.59 18.23 79.32 0 57.05 18.23l22.27 18.75 22.27-18.75z"/></symbol></defs><use width="160" height="187.74" xlink:href="#g"/></svg>',o6=btoa(I6),s6="data:image/svg+xml;base64,"+o6,n6=s6,C6=`<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'> <svg clip-rule="evenodd" fill-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="2" version="1.1" viewBox="0 0 1014 282" xml:space="preserve" xmlns="http://www.w3.org/2000/svg"> <g transform="matrix(1.008 0 0 1.008 -2.239 .61874)"> <path d="m665.95 132.73v44.88l-10.56-8.4c-0.8-0.64-1.2-1.44-1.2-2.4v-32.4c0-6.48-4.12-9.72-12.36-9.72-2.16 0-4.18 0.4-6.06 1.2s-3.54 1.8-4.98 3-2.56 2.5-3.36 3.9-1.2 2.7-1.2 3.9v40.92l-10.68-8.4c-0.72-0.64-1.08-1.44-1.08-2.4v-53.76l10.92 8.52c0.32 0.24 0.56 0.44 0.72 0.6s0.36 0.32 0.6 0.48c0.96-1.2 2.14-2.28 3.54-3.24s2.92-1.76 4.56-2.4 3.34-1.14 5.1-1.5 3.44-0.54 5.04-0.54c1.44 0 2.92 0.04 4.44 0.12s2.84 0.28 3.96 0.6c4.56 1.12 7.8 3.12 9.72 6s2.88 6.56 2.88 11.04z" fill-rule="nonzero"/> </g> <g transform="matrix(1.008 0 0 1.008 -2.239 .61874)"> <path d="m732.38 146.05c0 0.88 0.02 1.5 0.06 1.86s-0.02 0.98-0.18 1.86h-7.08c-2.08 0-4.44-0.02-7.08-0.06s-5.36-0.06-8.16-0.06h-22.08c0 2.88 0.56 5.36 1.68 7.44s2.6 3.8 4.44 5.16 3.94 2.36 6.3 3 4.74 0.96 7.14 0.96c3.04 0 5.9-0.76 8.58-2.28s4.94-3.52 6.78-6c0.64 0.56 1.54 1.48 2.7 2.76s2.94 3.2 5.34 5.76c-2.8 3.36-6.22 6.02-10.26 7.98s-8.42 2.94-13.14 2.94-8.92-0.64-12.84-1.92-7.32-3.24-10.2-5.88-5.12-5.98-6.72-10.02-2.4-8.82-2.4-14.34c0-4.96 0.66-9.42 1.98-13.38s3.22-7.32 5.7-10.08 5.44-4.9 8.88-6.42 7.32-2.28 11.64-2.28c5.76 0 10.52 0.88 14.28 2.64s6.72 4.16 8.88 7.2 3.66 6.54 4.5 10.5 1.26 8.18 1.26 12.66zm-29.4-22.8c-2.16 0.16-4.16 0.72-6 1.68s-3.42 2.2-4.74 3.72-2.36 3.28-3.12 5.28-1.14 4.12-1.14 6.36h33.12c0-2-0.22-4.06-0.66-6.18s-1.3-4.02-2.58-5.7-3.1-3.02-5.46-4.02-5.5-1.38-9.42-1.14z" fill-rule="nonzero"/> </g> <g transform="matrix(1.008 0 0 1.008 -2.239 .61874)"> <path d="m795.93 146.05c0 0.88 0.02 1.5 0.06 1.86s-0.02 0.98-0.18 1.86h-7.08c-2.08 0-4.44-0.02-7.08-0.06s-5.36-0.06-8.16-0.06h-22.08c0 2.88 0.56 5.36 1.68 7.44s2.6 3.8 4.44 5.16 3.94 2.36 6.3 3 4.74 0.96 7.14 0.96c3.04 0 5.9-0.76 8.58-2.28s4.94-3.52 6.78-6c0.64 0.56 1.54 1.48 2.7 2.76s2.94 3.2 5.34 5.76c-2.8 3.36-6.22 6.02-10.26 7.98s-8.42 2.94-13.14 2.94-8.92-0.64-12.84-1.92-7.32-3.24-10.2-5.88-5.12-5.98-6.72-10.02-2.4-8.82-2.4-14.34c0-4.96 0.66-9.42 1.98-13.38s3.22-7.32 5.7-10.08 5.44-4.9 8.88-6.42 7.32-2.28 11.64-2.28c5.76 0 10.52 0.88 14.28 2.64s6.72 4.16 8.88 7.2 3.66 6.54 4.5 10.5 1.26 8.18 1.26 12.66zm-29.4-22.8c-2.16 0.16-4.16 0.72-6 1.68s-3.42 2.2-4.74 3.72-2.36 3.28-3.12 5.28-1.14 4.12-1.14 6.36h33.12c0-2-0.22-4.06-0.66-6.18s-1.3-4.02-2.58-5.7-3.1-3.02-5.46-4.02-5.5-1.38-9.42-1.14z" fill-rule="nonzero"/> </g> <g transform="matrix(1.008 0 0 1.008 -2.239 .61874)"> <path d="m858.57 97.21c0.64 0.48 0.96 1.16 0.96 2.04v74.88c-0.08 1.04-0.12 2.12-0.12 3.24-1.84-1.52-3.56-2.92-5.16-4.2-1.36-1.12-2.66-2.18-3.9-3.18s-2.06-1.66-2.46-1.98c-1.76 2.48-4.26 4.44-7.5 5.88s-7.02 2.16-11.34 2.16c-3.84 0-7.4-0.7-10.68-2.1s-6.14-3.44-8.58-6.12-4.34-5.94-5.7-9.78-2.04-8.16-2.04-12.96c0-4.32 0.78-8.34 2.34-12.06s3.6-6.92 6.12-9.6 5.38-4.78 8.58-6.3 6.48-2.28 9.84-2.28c2.56 0 4.82 0.22 6.78 0.66s3.68 1.06 5.16 1.86 2.78 1.74 3.9 2.82 2.16 2.22 3.12 3.42v-35.04l10.68 8.64zm-27.96 67.92c3.6 0 6.52-0.68 8.76-2.04s3.98-3.06 5.22-5.1 2.1-4.22 2.58-6.54 0.72-4.44 0.72-6.36v-1.2c0-1.12-0.22-2.7-0.66-4.74s-1.28-4.06-2.52-6.06-3-3.7-5.28-5.1-5.22-2.02-8.82-1.86c-3.44 0-6.26 0.74-8.46 2.22s-3.96 3.26-5.28 5.34-2.24 4.2-2.76 6.36-0.78 3.92-0.78 5.28c0 1.84 0.24 3.92 0.72 6.24s1.36 4.48 2.64 6.48 3.04 3.68 5.28 5.04 5.12 2.04 8.64 2.04z" fill-rule="nonzero"/> </g> <g transform="matrix(1.008 0 0 1.008 -2.239 .61874)"> <path d="m882.81 97.09c0.64 0.48 0.96 1.12 0.96 1.92l-0.12 41.04v37.08l-10.56-8.4c-0.72-0.64-1.08-1.44-1.08-2.4v-77.88l10.8 8.64z" fill-rule="nonzero"/> </g> <g transform="matrix(1.008 0 0 1.008 -2.239 .61874)"> <path d="m950.36 146.05c0 0.88 0.02 1.5 0.06 1.86s-0.02 0.98-0.18 1.86h-7.08c-2.08 0-4.44-0.02-7.08-0.06s-5.36-0.06-8.16-0.06h-22.08c0 2.88 0.56 5.36 1.68 7.44s2.6 3.8 4.44 5.16 3.94 2.36 6.3 3 4.74 0.96 7.14 0.96c3.04 0 5.9-0.76 8.58-2.28s4.94-3.52 6.78-6c0.64 0.56 1.54 1.48 2.7 2.76s2.94 3.2 5.34 5.76c-2.8 3.36-6.22 6.02-10.26 7.98s-8.42 2.94-13.14 2.94-8.92-0.64-12.84-1.92-7.32-3.24-10.2-5.88-5.12-5.98-6.72-10.02-2.4-8.82-2.4-14.34c0-4.96 0.66-9.42 1.98-13.38s3.22-7.32 5.7-10.08 5.44-4.9 8.88-6.42 7.32-2.28 11.64-2.28c5.76 0 10.52 0.88 14.28 2.64s6.72 4.16 8.88 7.2 3.66 6.54 4.5 10.5 1.26 8.18 1.26 12.66zm-29.4-22.8c-2.16 0.16-4.16 0.72-6 1.68s-3.42 2.2-4.74 3.72-2.36 3.28-3.12 5.28-1.14 4.12-1.14 6.36h33.12c0-2-0.22-4.06-0.66-6.18s-1.3-4.02-2.58-5.7-3.1-3.02-5.46-4.02-5.5-1.38-9.42-1.14z" fill-rule="nonzero"/> </g> <g transform="matrix(1.8559 0 0 .7642 45.348 36.475)"> <g transform="translate(2.7114)"> <path d="m3.935 173.02c-0.331 0-0.497-0.402-0.497-1.207v-51.002c0-0.738 0.138-1.107 0.414-1.107h1.781c0.277 0 0.415 0.335 0.415 1.006v5.935c0 0.336 0.027 0.553 0.083 0.654 0.055 0.101 0.151-0.017 0.289-0.352 0.912-1.744 1.754-3.236 2.527-4.477 0.773-1.24 1.554-2.179 2.341-2.816s1.65-0.956 2.588-0.956c1.685 0 3.011 0.922 3.977 2.766 0.967 1.845 1.602 3.84 1.905 5.986 0.056 0.268 0.139 0.369 0.249 0.302s0.221-0.235 0.331-0.503c0.939-1.811 1.802-3.353 2.589-4.628 0.787-1.274 1.581-2.246 2.382-2.917s1.671-1.006 2.61-1.006c2.016 0 3.569 1.392 4.66 4.175 1.09 2.783 1.636 6.421 1.636 10.915v37.925c0 0.871-0.18 1.307-0.539 1.307h-1.739c-0.138 0-0.249-0.1-0.332-0.301-0.083-0.202-0.124-0.503-0.124-0.906v-36.315c0-3.555-0.338-6.321-1.015-8.3-0.676-1.978-1.76-2.967-3.251-2.967-0.884 0-1.726 0.386-2.527 1.157s-1.519 1.727-2.154 2.867-1.201 2.213-1.699 3.219c-0.248 0.469-0.421 0.905-0.517 1.308-0.097 0.402-0.145 0.972-0.145 1.71v37.221c0 0.871-0.166 1.307-0.497 1.307h-1.74c-0.166 0-0.29-0.1-0.373-0.301-0.083-0.202-0.124-0.503-0.124-0.906v-36.315c0-3.555-0.332-6.321-0.994-8.3-0.663-1.978-1.754-2.967-3.273-2.967-1.242 0-2.375 0.704-3.396 2.112-1.022 1.409-2.223 3.555-3.604 6.439v39.031c0 0.805-0.18 1.207-0.539 1.207h-1.698z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> <g transform="translate(2.7114)"> <path d="m53.642 166.28c-1.077 2.549-2.237 4.477-3.479 5.785-1.243 1.307-2.61 1.961-4.101 1.961-2.154 0-3.853-1.324-5.095-3.973-1.243-2.649-1.864-6.187-1.864-10.613 0-3.488 0.4-6.489 1.201-9.004s1.988-4.51 3.562-5.985c1.574-1.476 3.521-2.414 5.841-2.817l3.686-0.704c0.221-0.067 0.394-0.218 0.518-0.453 0.124-0.234 0.187-0.587 0.187-1.056v-2.917c0-3.89-0.504-6.975-1.512-9.255s-2.354-3.42-4.039-3.42c-1.298 0-2.472 0.72-3.521 2.162s-2.002 3.572-2.858 6.388c-0.083 0.268-0.159 0.453-0.228 0.554-0.069 0.1-0.172 0.083-0.311-0.051l-1.698-1.71c-0.083-0.134-0.138-0.285-0.166-0.453-0.027-0.167 0.014-0.452 0.125-0.855 0.856-3.353 2.009-6.052 3.459-8.098 1.449-2.045 3.224-3.068 5.322-3.068 1.74 0 3.211 0.687 4.412 2.062s2.112 3.37 2.734 5.986c0.621 2.615 0.932 5.7 0.932 9.255v35.712c0 0.536-0.035 0.888-0.104 1.056s-0.2 0.251-0.393 0.251h-1.533c-0.166 0-0.29-0.117-0.373-0.352-0.083-0.234-0.124-0.553-0.124-0.955l-0.083-5.231c-0.055-0.939-0.221-1.006-0.497-0.202zm0.456-19.314c0-1.14-0.194-1.643-0.58-1.509l-3.107 0.603c-1.436 0.202-2.686 0.638-3.749 1.308-1.063 0.671-1.953 1.543-2.671 2.616s-1.257 2.33-1.616 3.772-0.538 3.102-0.538 4.98c0 3.152 0.455 5.616 1.367 7.393 0.911 1.778 2.14 2.666 3.686 2.666 0.939 0 1.85-0.419 2.734-1.257s1.671-1.895 2.361-3.169c0.663-1.408 1.181-2.85 1.553-4.326 0.373-1.475 0.56-2.883 0.56-4.225v-8.852z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> <g transform="translate(2.7114)"> <path d="m79.034 173.02c-0.166 0-0.297-0.117-0.394-0.352-0.096-0.234-0.145-0.553-0.145-0.955v-4.628c0-0.536-0.041-0.838-0.124-0.905s-0.207 0.1-0.373 0.503c-0.276 0.67-0.69 1.593-1.242 2.766-0.553 1.174-1.271 2.23-2.154 3.169-0.884 0.939-1.961 1.408-3.231 1.408-1.74 0-3.314-0.989-4.722-2.967-1.409-1.979-2.534-4.963-3.376-8.953-0.843-3.991-1.264-8.937-1.264-14.838 0-5.701 0.415-10.68 1.243-14.939s1.988-7.595 3.479-10.009c1.492-2.415 3.204-3.622 5.137-3.622 1.436 0 2.616 0.57 3.541 1.71 0.926 1.14 1.719 2.381 2.382 3.722 0.249 0.47 0.414 0.637 0.497 0.503s0.125-0.536 0.125-1.207v-23.841c0-0.805 0.151-1.208 0.455-1.208h1.864c0.276 0 0.414 0.369 0.414 1.107v72.128c0 0.537-0.041 0.905-0.124 1.107-0.083 0.201-0.235 0.301-0.455 0.301h-1.533zm-0.621-42.049c-0.939-2.213-1.885-3.94-2.838-5.181s-2.009-1.861-3.169-1.861c-1.463 0-2.768 0.889-3.914 2.666s-2.044 4.376-2.693 7.796-0.973 7.578-0.973 12.474c0 5.097 0.338 9.272 1.015 12.524 0.676 3.253 1.567 5.651 2.672 7.193 1.104 1.543 2.305 2.314 3.603 2.314 1.188 0 2.258-0.704 3.211-2.113 0.952-1.408 1.705-3.118 2.257-5.13s0.829-3.957 0.829-5.835v-24.847z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> <g transform="translate(2.7114)"> <path d="m89.514 149.38c0 3.42 0.345 6.606 1.035 9.557 0.691 2.951 1.609 5.315 2.755 7.092s2.437 2.666 3.873 2.666c1.519 0 2.837-0.738 3.956-2.213 1.118-1.476 2.064-3.655 2.837-6.539 0.083-0.336 0.166-0.52 0.249-0.554 0.083-0.033 0.179 0.017 0.29 0.151l1.408 1.912c0.221 0.268 0.235 0.67 0.041 1.207-0.69 2.548-1.47 4.661-2.34 6.337-0.87 1.677-1.857 2.935-2.962 3.773-1.104 0.838-2.319 1.257-3.645 1.257-2.043 0-3.838-1.14-5.385-3.42-1.546-2.28-2.761-5.482-3.645-9.607-0.884-4.124-1.325-8.836-1.325-14.134 0-5.901 0.455-10.931 1.367-15.089 0.911-4.158 2.14-7.377 3.686-9.658 1.547-2.28 3.3-3.42 5.261-3.42 1.988 0 3.714 1.073 5.178 3.219 1.463 2.146 2.595 5.231 3.396 9.255s1.201 8.886 1.201 14.587c0 0.469-0.02 0.939-0.062 1.408-0.041 0.469-0.214 0.704-0.517 0.704h-16.362c-0.083 0-0.152 0.151-0.207 0.453-0.056 0.302-0.083 0.654-0.083 1.056zm13.752-6.237c0.304 0 0.497-0.1 0.58-0.302 0.083-0.201 0.124-0.57 0.124-1.106 0-3.219-0.283-6.187-0.849-8.903s-1.367-4.896-2.402-6.539c-1.036-1.643-2.272-2.464-3.708-2.464-1.629 0-2.996 0.955-4.101 2.867-1.104 1.911-1.94 4.342-2.506 7.293s-0.849 6.002-0.849 9.154h13.711z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> <g transform="translate(2.7114)"> <path d="m148.54 119.7c0.165 0 0.283 0.117 0.352 0.352s0.076 0.52 0.02 0.855l-6.254 50.902c-0.028 0.47-0.104 0.788-0.228 0.956s-0.297 0.251-0.518 0.251h-1.615c-0.442 0-0.718-0.402-0.829-1.207l-5.26-40.138c-0.111-0.604-0.201-0.905-0.27-0.905s-0.131 0.301-0.186 0.905l-5.012 40.138c-0.028 0.47-0.097 0.788-0.207 0.956-0.111 0.168-0.277 0.251-0.497 0.251h-1.74c-0.442 0-0.718-0.402-0.829-1.207l-6.503-50.801c-0.055-0.403-0.048-0.721 0.021-0.956s0.2-0.352 0.393-0.352h1.823c0.166 0 0.297 0.067 0.393 0.201 0.097 0.134 0.159 0.403 0.187 0.805l5.302 41.848c0.083 0.671 0.179 0.989 0.29 0.956 0.11-0.034 0.207-0.386 0.29-1.056l5.219-41.949c0.055-0.268 0.124-0.47 0.207-0.604s0.193-0.201 0.331-0.201h1.533c0.138 0 0.262 0.067 0.373 0.201 0.11 0.134 0.179 0.403 0.207 0.805l5.468 41.848c0.083 0.671 0.179 0.989 0.29 0.956 0.11-0.034 0.207-0.386 0.29-1.056l5.053-41.849c0.055-0.335 0.138-0.57 0.249-0.704 0.11-0.134 0.234-0.201 0.373-0.201h1.284z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> <g transform="translate(2.7114)"> <path d="m156.49 171.51c0 0.604-0.042 1.006-0.125 1.208-0.082 0.201-0.262 0.301-0.538 0.301h-1.533c-0.221 0-0.366-0.083-0.435-0.251s-0.103-0.486-0.103-0.956v-50.902c0-0.805 0.152-1.207 0.456-1.207h1.822c0.304 0 0.456 0.402 0.456 1.207v50.6zm0.165-63.979c0 1.207-0.207 1.811-0.621 1.811h-1.905c-0.221 0-0.366-0.135-0.435-0.403s-0.104-0.67-0.104-1.207v-7.847c0-1.006 0.18-1.509 0.539-1.509h1.988c0.359 0 0.538 0.47 0.538 1.409v7.746z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> <g transform="translate(2.7114)"> <path d="m168.3 124.83c-0.221 0-0.331 0.269-0.331 0.805v33.801c0 3.42 0.221 5.667 0.663 6.74 0.441 1.073 1.09 1.609 1.946 1.609h3.024c0.138 0 0.242 0.084 0.311 0.252 0.069 0.167 0.103 0.419 0.103 0.754v2.716c0 0.537-0.138 0.906-0.414 1.107-0.248 0.067-0.614 0.134-1.098 0.201-0.483 0.067-0.959 0.118-1.429 0.151-0.469 0.034-0.828 0.05-1.077 0.05-1.712 0-2.934-0.955-3.665-2.867-0.732-1.911-1.098-5.013-1.098-9.305v-35.108c0-0.604-0.124-0.906-0.373-0.906h-3.521c-0.248 0-0.373-0.268-0.373-0.804v-3.521c0-0.537 0.111-0.805 0.332-0.805h3.686c0.166 0 0.263-0.268 0.29-0.805l0.415-16.095c0-0.805 0.124-1.207 0.372-1.207h1.492c0.303 0 0.455 0.436 0.455 1.307v15.995c0 0.537 0.097 0.805 0.29 0.805h5.468c0.221 0 0.331 0.268 0.331 0.805v3.521c0 0.536-0.124 0.804-0.373 0.804h-5.426z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> <g transform="translate(2.7114)"> <path d="m179.4 173.02c-0.331 0-0.497-0.402-0.497-1.207v-72.329c0-0.738 0.138-1.107 0.414-1.107h1.782c0.276 0 0.414 0.336 0.414 1.006v27.162c0 0.335 0.034 0.536 0.103 0.603s0.159-0.033 0.27-0.302c0.994-1.81 1.898-3.319 2.713-4.526 0.814-1.208 1.629-2.113 2.444-2.717 0.814-0.603 1.691-0.905 2.63-0.905 2.182 0 3.839 1.375 4.971 4.125 1.132 2.749 1.698 6.404 1.698 10.965v37.925c0 0.871-0.166 1.307-0.497 1.307h-1.74c-0.165 0-0.29-0.1-0.373-0.301-0.082-0.202-0.124-0.503-0.124-0.906v-36.315c0-3.555-0.366-6.321-1.097-8.3-0.732-1.978-1.899-2.967-3.501-2.967-0.883 0-1.705 0.318-2.464 0.956-0.76 0.637-1.526 1.576-2.299 2.816-0.773 1.241-1.643 2.834-2.61 4.779v39.031c0 0.805-0.179 1.207-0.538 1.207h-1.699z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> </g> <g transform="matrix(.80638 0 0 .80638 452.53 65.421)" fill-rule="nonzero"> <path d="m79.32 36.98v150.76l15.68-13.2 6.59-156.31-22.27 18.75z" fill="url(#f)"/> <path d="m79.32 36.98-22.27-18.75 6.59 156.31 15.68 13.2v-150.76z" fill="url(#e)"/> <path d="m25.19 104.83 8.63 49.04 12.5-14.95-2.46-56.42-18.67 22.33z" fill="url(#d)"/> <path d="m25.19 104.83-25.19-14.59 16.97 53.86 16.85 9.77-8.63-49.04z" fill="url(#c)"/> <path d="M43.86,82.5L18.69,67.98L0,90.24L25.18,104.83L43.86,82.5Z" fill="#9c3"/> <path d="m134.82 78.69-9.97 56.5 15.58-9.04 19.57-62.05-25.18 14.59z" fill="url(#b)"/> <path d="m134.82 78.69-18.68-22.33-2.86 65 11.57 13.83 9.97-56.5z" fill="url(#a)"/> <path d="m160 64.1-18.69-22.26-25.17 14.52 18.67 22.33 25.19-14.59z" fill="#ffe113"/> <path d="M101.59,18.23L79.32,0L57.05,18.23L79.32,36.98L101.59,18.23Z" fill="#f3e600"/> </g> <defs> <linearGradient id="f" x2="1" gradientTransform="matrix(.84 -162.96 162.96 .84 89.64 184.81)" gradientUnits="userSpaceOnUse"><stop stop-color="#62d399" offset="0"/><stop stop-color="#acd842" offset=".51"/><stop stop-color="#d7db0a" offset=".9"/><stop stop-color="#d7db0a" offset="1"/></linearGradient> <linearGradient id="e" x2="1" gradientTransform="matrix(-1.6,-162.13,162.13,-1.6,69.68,178.9)" gradientUnits="userSpaceOnUse"><stop stop-color="#0ba398" offset="0"/><stop stop-color="#4ca352" offset=".5"/><stop stop-color="#76a30a" offset="1"/></linearGradient> <linearGradient id="d" x2="1" gradientTransform="matrix(-1.9,-67.98,67.98,-1.9,36.6,152.17)" gradientUnits="userSpaceOnUse"><stop stop-color="#36a382" offset="0"/><stop stop-color="#36a382" offset=".19"/><stop stop-color="#49a459" offset=".54"/><stop stop-color="#76a30b" offset="1"/></linearGradient> <linearGradient id="c" x2="1" gradientTransform="matrix(2.18,-62.38,62.38,2.18,15.82,153.24)" gradientUnits="userSpaceOnUse"><stop stop-color="#267880" offset="0"/><stop stop-color="#457a5c" offset=".51"/><stop stop-color="#717516" offset="1"/></linearGradient> <linearGradient id="b" x2="1" gradientTransform="matrix(13.85,-71.96,71.96,13.85,135.08,135.43)" gradientUnits="userSpaceOnUse"><stop stop-color="#b0d939" offset="0"/><stop stop-color="#eadb04" offset="1"/></linearGradient> <linearGradient id="a" x2="1" gradientTransform="matrix(26.159 -64.737 64.737 26.159 107.42 128.14)" gradientUnits="userSpaceOnUse"><stop stop-color="#74af52" offset="0"/><stop stop-color="#74af52" offset=".17"/><stop stop-color="#99be32" offset=".48"/><stop stop-color="#c0c40a" offset="1"/></linearGradient> </defs> </svg>`;btoa(C6);const a6='<svg viewBox="0 0 509 154" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2"><path d="M665.95 132.73v44.88l-10.56-8.4c-.8-.64-1.2-1.44-1.2-2.4v-32.4c0-6.48-4.12-9.72-12.36-9.72-2.16 0-4.18.4-6.06 1.2-1.88.8-3.54 1.8-4.98 3-1.44 1.2-2.56 2.5-3.36 3.9-.8 1.4-1.2 2.7-1.2 3.9v40.92l-10.68-8.4c-.72-.64-1.08-1.44-1.08-2.4v-53.76l10.92 8.52c.32.24.56.44.72.6.16.16.36.32.6.48.96-1.2 2.14-2.28 3.54-3.24 1.4-.96 2.92-1.76 4.56-2.4 1.64-.64 3.34-1.14 5.1-1.5 1.76-.36 3.44-.54 5.04-.54 1.44 0 2.92.04 4.44.12 1.52.08 2.84.28 3.96.6 4.56 1.12 7.8 3.12 9.72 6 1.92 2.88 2.88 6.56 2.88 11.04ZM732.38 146.05c0 .88.02 1.5.06 1.86.04.36-.02.98-.18 1.86h-7.08c-2.08 0-4.44-.02-7.08-.06-2.64-.04-5.36-.06-8.16-.06h-22.08c0 2.88.56 5.36 1.68 7.44 1.12 2.08 2.6 3.8 4.44 5.16 1.84 1.36 3.94 2.36 6.3 3 2.36.64 4.74.96 7.14.96 3.04 0 5.9-.76 8.58-2.28 2.68-1.52 4.94-3.52 6.78-6 .64.56 1.54 1.48 2.7 2.76 1.16 1.28 2.94 3.2 5.34 5.76-2.8 3.36-6.22 6.02-10.26 7.98-4.04 1.96-8.42 2.94-13.14 2.94-4.72 0-8.92-.64-12.84-1.92-3.92-1.28-7.32-3.24-10.2-5.88-2.88-2.64-5.12-5.98-6.72-10.02-1.6-4.04-2.4-8.82-2.4-14.34 0-4.96.66-9.42 1.98-13.38 1.32-3.96 3.22-7.32 5.7-10.08s5.44-4.9 8.88-6.42c3.44-1.52 7.32-2.28 11.64-2.28 5.76 0 10.52.88 14.28 2.64 3.76 1.76 6.72 4.16 8.88 7.2 2.16 3.04 3.66 6.54 4.5 10.5.84 3.96 1.26 8.18 1.26 12.66Zm-29.4-22.8c-2.16.16-4.16.72-6 1.68-1.84.96-3.42 2.2-4.74 3.72-1.32 1.52-2.36 3.28-3.12 5.28-.76 2-1.14 4.12-1.14 6.36h33.12c0-2-.22-4.06-.66-6.18-.44-2.12-1.3-4.02-2.58-5.7-1.28-1.68-3.1-3.02-5.46-4.02-2.36-1-5.5-1.38-9.42-1.14ZM795.93 146.05c0 .88.02 1.5.06 1.86.04.36-.02.98-.18 1.86h-7.08c-2.08 0-4.44-.02-7.08-.06-2.64-.04-5.36-.06-8.16-.06h-22.08c0 2.88.56 5.36 1.68 7.44 1.12 2.08 2.6 3.8 4.44 5.16 1.84 1.36 3.94 2.36 6.3 3 2.36.64 4.74.96 7.14.96 3.04 0 5.9-.76 8.58-2.28 2.68-1.52 4.94-3.52 6.78-6 .64.56 1.54 1.48 2.7 2.76 1.16 1.28 2.94 3.2 5.34 5.76-2.8 3.36-6.22 6.02-10.26 7.98-4.04 1.96-8.42 2.94-13.14 2.94-4.72 0-8.92-.64-12.84-1.92-3.92-1.28-7.32-3.24-10.2-5.88-2.88-2.64-5.12-5.98-6.72-10.02-1.6-4.04-2.4-8.82-2.4-14.34 0-4.96.66-9.42 1.98-13.38 1.32-3.96 3.22-7.32 5.7-10.08s5.44-4.9 8.88-6.42c3.44-1.52 7.32-2.28 11.64-2.28 5.76 0 10.52.88 14.28 2.64 3.76 1.76 6.72 4.16 8.88 7.2 2.16 3.04 3.66 6.54 4.5 10.5.84 3.96 1.26 8.18 1.26 12.66Zm-29.4-22.8c-2.16.16-4.16.72-6 1.68-1.84.96-3.42 2.2-4.74 3.72-1.32 1.52-2.36 3.28-3.12 5.28-.76 2-1.14 4.12-1.14 6.36h33.12c0-2-.22-4.06-.66-6.18-.44-2.12-1.3-4.02-2.58-5.7-1.28-1.68-3.1-3.02-5.46-4.02-2.36-1-5.5-1.38-9.42-1.14ZM858.57 97.21c.64.48.96 1.16.96 2.04v74.88c-.08 1.04-.12 2.12-.12 3.24-1.84-1.52-3.56-2.92-5.16-4.2-1.36-1.12-2.66-2.18-3.9-3.18-1.24-1-2.06-1.66-2.46-1.98-1.76 2.48-4.26 4.44-7.5 5.88-3.24 1.44-7.02 2.16-11.34 2.16-3.84 0-7.4-.7-10.68-2.1-3.28-1.4-6.14-3.44-8.58-6.12-2.44-2.68-4.34-5.94-5.7-9.78-1.36-3.84-2.04-8.16-2.04-12.96 0-4.32.78-8.34 2.34-12.06 1.56-3.72 3.6-6.92 6.12-9.6 2.52-2.68 5.38-4.78 8.58-6.3 3.2-1.52 6.48-2.28 9.84-2.28 2.56 0 4.82.22 6.78.66 1.96.44 3.68 1.06 5.16 1.86s2.78 1.74 3.9 2.82a35.92 35.92 0 0 1 3.12 3.42V88.57l10.68 8.64Zm-27.96 67.92c3.6 0 6.52-.68 8.76-2.04 2.24-1.36 3.98-3.06 5.22-5.1a20.5 20.5 0 0 0 2.58-6.54c.48-2.32.72-4.44.72-6.36v-1.2c0-1.12-.22-2.7-.66-4.74-.44-2.04-1.28-4.06-2.52-6.06s-3-3.7-5.28-5.1c-2.28-1.4-5.22-2.02-8.82-1.86-3.44 0-6.26.74-8.46 2.22-2.2 1.48-3.96 3.26-5.28 5.34-1.32 2.08-2.24 4.2-2.76 6.36-.52 2.16-.78 3.92-.78 5.28 0 1.84.24 3.92.72 6.24.48 2.32 1.36 4.48 2.64 6.48s3.04 3.68 5.28 5.04c2.24 1.36 5.12 2.04 8.64 2.04ZM882.81 97.09c.64.48.96 1.12.96 1.92l-.12 41.04v37.08l-10.56-8.4c-.72-.64-1.08-1.44-1.08-2.4V88.45l10.8 8.64ZM950.36 146.05c0 .88.02 1.5.06 1.86.04.36-.02.98-.18 1.86h-7.08c-2.08 0-4.44-.02-7.08-.06-2.64-.04-5.36-.06-8.16-.06h-22.08c0 2.88.56 5.36 1.68 7.44 1.12 2.08 2.6 3.8 4.44 5.16 1.84 1.36 3.94 2.36 6.3 3 2.36.64 4.74.96 7.14.96 3.04 0 5.9-.76 8.58-2.28 2.68-1.52 4.94-3.52 6.78-6 .64.56 1.54 1.48 2.7 2.76 1.16 1.28 2.94 3.2 5.34 5.76-2.8 3.36-6.22 6.02-10.26 7.98-4.04 1.96-8.42 2.94-13.14 2.94-4.72 0-8.92-.64-12.84-1.92-3.92-1.28-7.32-3.24-10.2-5.88-2.88-2.64-5.12-5.98-6.72-10.02-1.6-4.04-2.4-8.82-2.4-14.34 0-4.96.66-9.42 1.98-13.38 1.32-3.96 3.22-7.32 5.7-10.08s5.44-4.9 8.88-6.42c3.44-1.52 7.32-2.28 11.64-2.28 5.76 0 10.52.88 14.28 2.64 3.76 1.76 6.72 4.16 8.88 7.2 2.16 3.04 3.66 6.54 4.5 10.5.84 3.96 1.26 8.18 1.26 12.66Zm-29.4-22.8c-2.16.16-4.16.72-6 1.68-1.84.96-3.42 2.2-4.74 3.72-1.32 1.52-2.36 3.28-3.12 5.28-.76 2-1.14 4.12-1.14 6.36h33.12c0-2-.22-4.06-.66-6.18-.44-2.12-1.3-4.02-2.58-5.7-1.28-1.68-3.1-3.02-5.46-4.02-2.36-1-5.5-1.38-9.42-1.14Z" style="fill-rule:nonzero" transform="translate(-452.406 -63.709) scale(1.00797)"/><path d="M79.32 36.98v150.76L95 174.54l6.59-156.31-22.27 18.75Z" style="fill:url(#a);fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="M79.32 36.98 57.05 18.23l6.59 156.31 15.68 13.2V36.98Z" style="fill:url(#b);fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="m25.19 104.83 8.63 49.04 12.5-14.95-2.46-56.42-18.67 22.33Z" style="fill:url(#c);fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="M25.19 104.83 0 90.24l16.97 53.86 16.85 9.77-8.63-49.04Z" style="fill:url(#d);fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="M43.86 82.5 18.69 67.98 0 90.24l25.18 14.59L43.86 82.5Z" style="fill:#9c3;fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="m134.82 78.69-9.97 56.5 15.58-9.04L160 64.1l-25.18 14.59Z" style="fill:url(#e);fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="m134.82 78.69-18.68-22.33-2.86 65 11.57 13.83 9.97-56.5Z" style="fill:url(#f);fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="m160 64.1-18.69-22.26-25.17 14.52 18.67 22.33L160 64.1Z" style="fill:#ffe113;fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="M101.59 18.23 79.32 0 57.05 18.23l22.27 18.75 22.27-18.75Z" style="fill:#f3e600;fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><defs><linearGradient id="a" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="matrix(.84 -162.96 162.96 .84 89.64 184.81)"><stop offset="0" style="stop-color:#62d399;stop-opacity:1"/><stop offset=".51" style="stop-color:#acd842;stop-opacity:1"/><stop offset=".9" style="stop-color:#d7db0a;stop-opacity:1"/><stop offset="1" style="stop-color:#d7db0a;stop-opacity:1"/></linearGradient><linearGradient id="b" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="rotate(-90.565 123.412 54.953) scale(162.14)"><stop offset="0" style="stop-color:#0ba398;stop-opacity:1"/><stop offset=".5" style="stop-color:#4ca352;stop-opacity:1"/><stop offset="1" style="stop-color:#76a30a;stop-opacity:1"/></linearGradient><linearGradient id="c" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="scale(-68) rotate(88.4 .881 -1.396)"><stop offset="0" style="stop-color:#36a382;stop-opacity:1"/><stop offset=".19" style="stop-color:#36a382;stop-opacity:1"/><stop offset=".54" style="stop-color:#49a459;stop-opacity:1"/><stop offset="1" style="stop-color:#76a30b;stop-opacity:1"/></linearGradient><linearGradient id="d" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="rotate(-88 87.255 68.431) scale(62.42)"><stop offset="0" style="stop-color:#267880;stop-opacity:1"/><stop offset=".51" style="stop-color:#457a5c;stop-opacity:1"/><stop offset="1" style="stop-color:#717516;stop-opacity:1"/></linearGradient><linearGradient id="e" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="rotate(-79.1 149.53 -14.065) scale(73.28)"><stop offset="0" style="stop-color:#b0d939;stop-opacity:1"/><stop offset="1" style="stop-color:#eadb04;stop-opacity:1"/></linearGradient><linearGradient id="f" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="rotate(-67.997 148.705 -15.558) scale(69.8226)"><stop offset="0" style="stop-color:#74af52;stop-opacity:1"/><stop offset=".17" style="stop-color:#74af52;stop-opacity:1"/><stop offset=".48" style="stop-color:#99be32;stop-opacity:1"/><stop offset="1" style="stop-color:#c0c40a;stop-opacity:1"/></linearGradient></defs></svg>',r6=btoa(a6),B6="data:image/svg+xml;charset=utf-8;base64,"+r6,Q6=B6,is=IA("debuglicense");let fB="basic";is&&console.log("License Type: "+fB);function Hs(){switch(fB){case"pro":case"enterprise":return!0}return!1}function tN(){switch(fB){case"indie":return!0}return!1}function oc(){return Hs()||tN()}const mH=[];function E6(g){if(Hs()||tN())return g(!0);mH.push(g)}function c6(g){for(const A of mH)try{A(g)}catch{}}st.registerCallback(di.ContextRegistered,g=>{d6(g.context),p6(),h6(g.context)});let Za,tM=!1,Ah="";async function l6(){if(Za)return Za;if(fB==="basic")try{const g="https://engine.needle.tools/licensing/check?location="+encodeURIComponent(window.location.href)+"&version="+Gn+"&generator="+encodeURIComponent(AS),A=await fetch(g,{method:"GET"}).catch(e=>{is&&console.error("License check failed",e)});(A==null?void 0:A.status)===200?(tM=!1,is&&console.log("License check succeeded"),fB="pro",c6(!0)):(A==null?void 0:A.status)===403?(tM=!0,Ah=await A.text()):is&&console.log("License check failed with status "+(A==null?void 0:A.status))}catch(g){is&&console.error("License check failed",g)}else is&&console.log('Runtime license check is skipped because license is already applied as "'+fB+'"')}Za=l6();async function h6(g){function A(){const i=document.createElement("div");i.className="needle-forbidden",i.style.cssText=`
|
|
4345
4345
|
position: fixed;
|
|
4346
4346
|
top: 0;
|
|
@@ -5505,7 +5505,7 @@ Could not find method ${a.method} on object ${Q.name}. Please rename ${a.method}
|
|
|
5505
5505
|
in script: `,Q),fi("EventList methods must start with lowercase letter, see console for details");return}else console.warn(`EventList method:
|
|
5506
5506
|
Could not find method ${a.method} on object ${Q.name}`,Q,typeof Q[a.method])};if(typeof Q[a.method]!="function"){let u=!1,f=Q;for(;f;){const k=Object.getOwnPropertyDescriptor(f,a.method);if(k&&(k.writable===!0||k.set)){u=!0;break}f=Object.getPrototypeOf(f)}!u&&(he()||Og)&&h()}}let c=a.argument;c!==void 0?c=B(c):a.arguments!==void 0&&(c=a.arguments.map(B));const d=E?this.createEventMethod(Q,a.method,c):void 0,l=new rc(d,a.enabled);if(l.method||(l[rgA]=(o=e.object)==null?void 0:o.name),!Q||!l.method){const h=e.object?"Current object: "+e.object.name+", "+e.object.guid:null;Q?console.warn('EventList method not found: "'+a.method+'" on',Q):console.warn("EventList is missing target - will be ignored",a.target,h,A)}else s.push(l)}const n=new Bg(s);Og&&console.log(n);const C=e.target;return C!==void 0&&e.path!==void 0&&n.setEventTarget(e.path,C),n}}createEventMethod(A,e,t){return(...i)=>{const I=A[e];typeof I=="function"?t!==void 0?Array.isArray(t)?I==null||I.call(A,...t):I==null||I.call(A,t):I==null||I.call(A,...i):A[e]=t}}}const QgA=new BgA;class HO extends _n{constructor(){super([Xa,Xe])}onSerialize(A,e){}onDeserialize(A,e){if(A instanceof fe&&e.type===Xa){const t=A,i=new Xa(t.image.width,t.image.height,{colorSpace:yt});return i.texture=t,t.isRenderTargetTexture=!0,t.flipY=!0,t.offset.y=1,t.repeat.y=-1,t.needsUpdate=!0,t.mipmaps=[],t instanceof Rn&&(t.isCompressedTexture=!1,t.format=RGBAFormat),i}}}new HO;class YO extends _n{constructor(){super([URL])}onSerialize(A,e){return null}onDeserialize(A,e){if(typeof A=="string"&&A.length>0)return WC(e.gltfId,A)}}new YO;var EgA=Object.defineProperty,cgA=Object.getOwnPropertyDescriptor,lgA=(g,A,e,t)=>{for(var i=t>1?void 0:t?cgA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&EgA(A,e,i),i};class Ru extends RA{awake(){Ao.createIfNoneExists(this.context)}onEnable(){var A;(A=Ao.get(this.context))==null||A.register(this)}onDisable(){var A;(A=Ao.get(this.context))==null||A.unregister(this)}}class Ko extends Ru{constructor(){super(...arguments);r(this,"targets",null);r(this,"raycastHits",[]);r(this,"ignoreSkinnedMeshes",!1)}start(){this.targets=[this.gameObject]}performRaycast(e=null){if(!this.targets)return null;e??(e=new Qs),e.targets=this.targets,e.results=this.raycastHits;const t=e.testObject;this.ignoreSkinnedMeshes&&(e.testObject=I=>I instanceof Mo?"continue in children":t?t(I):!0);const i=this.context.physics.raycast(e);return e.testObject=t,i}}lgA([D()],Ko.prototype,"ignoreSkinnedMeshes",2);class fS extends Ko{constructor(){super(),this.ignoreSkinnedMeshes=!0}}class Nd extends Ru{performRaycast(A){if(!Se.active||!(A!=null&&A.ray))return null;const e=A.ray.origin,t=.01;return this.context.physics.sphereOverlap(e,t)}}class DS{static getObject(A){const e=A[gs];return e&&(e.isComponent===!0?A=e.gameObject:A=e),A}static isInteractable(A,e){if(e&&(e.canvasGroup=void 0,e.graphic=void 0),A==null||!A.visible||(A=this.getObject(A),!A.visible))return!1;const t=this.tryFindCanvasGroup(A);if((t==null?void 0:t.isCanvasGroup)===!0&&(e&&(e.canvasGroup=t),t.blocksRaycasts===!1||t.interactable===!1))return!1;const i=HB(A,I=>{if(I.isGraphic===!0)return I},!1);return e&&(i==null?void 0:i.isGraphic)===!0&&(e.graphic=i),!((i==null?void 0:i.raycastTarget)===!1||(i==null?void 0:i.layer)===2)}static tryFindCanvasGroup(A){if(!A)return null;const e=HB(A,t=>{const i=t;if(i.blocksRaycasts!==void 0&&i.interactable!==void 0)return i},!1);return e!==void 0?e:this.tryFindCanvasGroup(A.parent)}}function _N(g){const A=g[gs];return A||(g.parent?_N(g.parent):null)}function hgA(g){return g.isUI===!0||typeof g[gs]=="object"}function qw(g,A){if(!g)return;const e=g.material;if((e==null?void 0:e.isMaterial)===!0){const t=g.parent;t&&t.isText,e.side=A.doubleSided??!0?ht:Pg,e.shadowSide=A.doubleSided?ht:Pg,g.castShadow=A.castShadows?A.castShadows:!1,g.receiveShadow=A.receiveShadows?A.receiveShadows:!1}for(const t of g.children)qw(t,A)}function EE(g,A,e){g[A]===void 0&&console.warn("Field",A,"is undefined on",g);const t=Proxy.revocable(g[A],{set(o,s,n,C){const a=o[s],B=Reflect.set(o,s,n,C);return e(n,a),B}}),i=t.revoke,I=g[A];return t.revoke=()=>{g[A]=I,i()},g[A]=t.proxy,t}const qq=Symbol("Scheduled action");function dgA(g,A,e=Ai.OnBeforeRender){let t=g[qq];t||(t=g[qq]={});const i=A.name;t[e]||(t[e]={});const I=t[e];if(I[i])return;function*s(){A==null||A.call(g),I[i]=null}const n=g.startCoroutine(s(),e);I[i]=n}const CC=IA("debugeventsystem");var VM=(g=>(g.BeforeHandleInput="BeforeHandleInput",g.AfterHandleInput="AfterHandleInput",g))(VM||{});const En=class extends RA{constructor(){super();r(this,"raycaster",[]);r(this,"_handleInputFn");r(this,"pressedByID",new Map);r(this,"hoveredByID",new Map);r(this,"_sortedHits",[]);r(this,"_testObjectsCache",new Map);r(this,"_currentlyActiveRaycaster",null);r(this,"_currentPointerEventName",null);r(this,"shouldRaycastObject",e=>{var I;let t=null;if(hgA(e)&&(t=(I=e[gs])==null?void 0:I.gameObject),this._testObjectsCache.has(e)||t&&this._testObjectsCache.has(t))return this._testObjectsCache.get(e)===!1?"continue in children":!0;{let o=jM(e,this._currentPointerEventName);if(!o&&t&&(o=jM(t,this._currentPointerEventName)),o){this._testObjectsCache.set(e,!0);for(const s of e.children)this.shouldRaycastObject_AddToYesCache(s);return!0}return this._testObjectsCache.set(e,!1),"continue in children"}});r(this,"_sortingBuffer",[]);r(this,"_noDepthTestingResults",[]);r(this,"out",{});r(this,"_capturedPointer",{});r(this,"pointerEnterSymbol",Symbol("pointerEnter"));r(this,"pointerExitSymbol",Symbol("pointerExit"));r(this,"currentActiveMeshUIComponents",[]);En.systems.push(this)}static createIfNoneExists(e){this.didSearchEventSystem||(this.didSearchEventSystem=!0,En.systems.length<=0&&En.systems.push(...aA.findObjectsOfType(En,e)));for(const i of En.systems)if(i.context===e)return;const t=new uA;aA.addNewComponent(t,En),e.scene.add(t)}static get systems(){const e=ve.Current;return this._eventSystemMap.has(e)||this._eventSystemMap.set(e,[]),this._eventSystemMap.get(e)}static get(e){const t=this._eventSystemMap.get(e);return t&&t.length>0?t[0]:null}static get instance(){return this.systems[0]}static ensureUpdateMeshUI(e,t,i=!1){va.update(e,t,i)}static markUIDirty(e){va.markDirty()}get hasActiveUI(){return this.currentActiveMeshUIComponents.length>0}get isHoveringObjects(){return this.hoveredByID.size>0}onDestroy(){En.systems.splice(En.systems.indexOf(this),1)}start(){if(this.raycaster.length<=0&&!aA.findObjectOfType(Ru,this.context)){const t=aA.addNewComponent(this.context.scene,Ko);this.raycaster.push(t),(he()||CC)&&console.warn("Added an ObjectRaycaster to the scene because no raycaster was found.")}}register(e){var t;e&&this.raycaster&&!this.raycaster.includes(e)&&((t=this.raycaster)==null||t.push(e))}unregister(e){var i,I;const t=(i=this.raycaster)==null?void 0:i.indexOf(e);t!==void 0&&t!==-1&&((I=this.raycaster)==null||I.splice(t,1))}onEnable(){this._handleInputFn??(this._handleInputFn=this.onPointerEvent.bind(this)),this.context.input.addEventListener(ni.PointerDown,this._handleInputFn),this.context.input.addEventListener(ni.PointerUp,this._handleInputFn),this.context.input.addEventListener(ni.PointerMove,this._handleInputFn)}onDisable(){this.context.input.removeEventListener(ni.PointerDown,this._handleInputFn),this.context.input.removeEventListener(ni.PointerUp,this._handleInputFn),this.context.input.removeEventListener(ni.PointerMove,this._handleInputFn)}onBeforeRender(){this.resetMeshUIStates()}onPointerEvent(e){if(e===void 0||e.propagationStopped)return;const t=new vc(this.context.input,e);this._currentPointerEventName=e.type,t.inputSource=this.context.input,t.isClick=e.isClick,t.isDoubleClick=e.isDoubleClick,t.isDown=e.type==ni.PointerDown,t.isUp=e.type==ni.PointerUp,t.isPressed=this.context.input.getPointerPressed(e.pointerId),CC&&(t.isDown?console.log("DOWN",t.pointerId):t.isUp&&console.log("UP",t.pointerId),t.isClick&&console.log("CLICK",t.pointerId));const i=new Qs;e.hasRay?i.ray=e.ray:i.screenPoint=this.context.input.getPointerPositionRC(e.pointerId);const I=this.performRaycast(i);if(I)for(const s of I)s.event=e,e.intersections.push(s);CC&&t.isClick&&Ci("EventSystem: "+t.pointerId+" - "+this.context.time.frame+" - Up:"+t.isUp+", Down:"+t.isDown);const o={sender:this,args:t,hasActiveUI:this.currentActiveMeshUIComponents.length>0};this.dispatchEvent(new CustomEvent("BeforeHandleInput",{detail:o})),this.handleIntersections(I,t),this.dispatchEvent(new CustomEvent("AfterHandleInput",{detail:o}))}shouldRaycastObject_AddToYesCache(e){this._testObjectsCache.set(e,!0);for(const t of e.children)this.shouldRaycastObject_AddToYesCache(t)}performRaycast(e){if(!this.raycaster)return null;this._testObjectsCache.clear(),this._sortedHits.length=0,e||(e=new Qs),e.testObject=this.shouldRaycastObject;for(const t of this.raycaster){if(!t.activeAndEnabled)continue;this._currentlyActiveRaycaster=t;const i=t.performRaycast(e);this._currentlyActiveRaycaster=null,i&&i.length>0&&this._sortedHits.push(...i)}return this._sortedHits.sort((t,i)=>t.distance-i.distance),this._sortedHits}assignHitInformation(e,t){t?(e.intersection=t,e.point=t.point,e.normal=t.normal,e.face=t.face,e.distance=t.distance,e.instanceId=t.instanceId):(e.intersection=void 0,e.point=void 0,e.normal=void 0,e.face=void 0,e.distance=void 0,e.instanceId=void 0)}handleIntersections(e,t){var I;if(e!=null&&e.length){e=this.sortCandidates(e);for(const o of e){if(t.event.immediatePropagationStopped)return!1;if(this.assignHitInformation(t,o),this.handleEventOnObject(o.object,t))return!0}}this.assignHitInformation(t,e==null?void 0:e[0]),this.invokePointerCapture(t);const i=this.hoveredByID.get(t.pointerId);return i&&this.propagatePointerExit(i.obj,i.data,null),this.hoveredByID.delete(t.pointerId),t.isUp&&((I=this.pressedByID.get(t.pointerId))==null||I.handlers.forEach(o=>this.invokeOnPointerUp(t,o)),this.pressedByID.delete(t.pointerId)),!1}sortCandidates(e){this._sortingBuffer.length=0,this._noDepthTestingResults.length=0;for(let t=0;t<e.length;t++){const i=e[t],I=i.object;if(I.material&&I.material.depthTest===!1){this._noDepthTestingResults.push(i);continue}this._sortingBuffer.push(i)}for(const t of this._sortingBuffer)this._noDepthTestingResults.push(t);return this._noDepthTestingResults}handleEventOnObject(e,t){if(!this.testIsVisible(e))return t.isClick&&CC&&console.log("not allowed",e),!1;if(t.pointerId===void 0)return CC&&console.error("Event without pointer can't be handled",t),!1;t.object=e;const i=e.parent,I=t.isClick??!1;let o=null;if(i&&i.isUI){const B=(t.isPressed||t.isClick)??!1;if(i[gs]){const Q=i[gs].gameObject;if(Q){if(!DS.isInteractable(Q,this.out))return!1;o=this.out.canvasGroup??null,this.handleMeshUIIntersection(e,B),e=Q}}}I&&CC&&console.log(this.context.time.frame,e);const s=this.hoveredByID.get(t.pointerId),n=s==null?void 0:s.obj;n!==e&&n&&this.propagatePointerExit(n,s.data,e);const a=this.hoveredByID.get(t.pointerId);if(a?(a.obj=e,a.data=t):this.hoveredByID.set(t.pointerId,{obj:e,data:t}),t.isDown){const B=this.pressedByID.get(t.pointerId);B?(B.obj=e,B.data=t):this.pressedByID.set(t.pointerId,{obj:e,data:t,handlers:new Set})}return(o===null||o.interactable)&&this.handleMainInteraction(e,t,n??null),!0}propagate(e,t){for(;e;)aA.foreachComponent(e,i=>{t(i)},!1),e=e.parent}handleMainInteraction(e,t,i){const I=this.pressedByID.get(t.pointerId),o=i!==e;let s=!0;switch(t.event.pointerType){case"mouse":case"touch":const n=this.context.input.getPointerPositionLastFrame(t.pointerId),C=this.context.input.getPointerPosition(t.pointerId);s=n&&!te.approximately(n,C);break}this.propagate(e,n=>{var a;const C=n;C.interactable!==!1&&(!C.activeAndEnabled||!C.enabled||(C.onPointerEnter&&o&&this.handlePointerEnter(C,t),t.isDown&&C.onPointerDown&&(C.onPointerDown(t),I==null||I.handlers.add(C),this.handlePointerCapture(t,C)),C.onPointerMove&&(s&&C.onPointerMove(t),this.handlePointerCapture(t,C)),t.isUp&&(C.onPointerUp&&(this.invokeOnPointerUp(t,C),I==null||I.handlers.delete(C)),C.onPointerExit&&((a=t.event)==null?void 0:a.pointerType)===aS.Touch&&(this.handlePointerExit(C,t),this.hoveredByID.delete(t.pointerId))),t.isClick&&C.onPointerClick&&C.onPointerClick(t)))}),t.isUp&&(I==null||I.handlers.forEach(n=>{this.invokeOnPointerUp(t,n)}),this.pressedByID.delete(t.pointerId))}propagatePointerExit(e,t,i){this.propagate(e,I=>{if(!I.gameObject||I.destroyed)return;const o=I;if(o.onPointerExit){if(i&&this.isChild(i,I.gameObject))return;this.handlePointerExit(o,t)}})}invokeOnPointerUp(e,t){var i;(i=t.onPointerUp)==null||i.call(t,e),this.releasePointerCapture(e,t)}handlePointerEnter(e,t){e.onPointerEnter&&this.updatePointerState(e,t.pointerId,this.pointerEnterSymbol,!0)&&e.onPointerEnter(t),this.updatePointerState(e,t.pointerId,this.pointerExitSymbol,!1)}handlePointerExit(e,t){e.onPointerExit&&this.updatePointerState(e,t.pointerId,this.pointerExitSymbol,!0)&&e.onPointerExit(t),this.updatePointerState(e,t.pointerId,this.pointerEnterSymbol,!1)}updatePointerState(e,t,i,I){let o=e[i];if(I)return o&&o.includes(t)?!1:(o=o||[],o.push(t),e[i]=o,!0);{if(!o||!o.includes(t))return!1;const s=o.indexOf(t);return s!==-1&&o.splice(s,1),!0}}handlePointerCapture(e,t){if(e.z__pointer_ctured){e.z__pointer_ctured=!1;const i=e.pointerId;if(t.onPointerMove){const I=this._capturedPointer[i]||[];I.push(t),this._capturedPointer[i]=I}else he()&&!t.z__warned_no_pointermove&&(t.z__warned_no_pointermove=!0,console.warn("PointerCapture was requested but the component doesn't implement onPointerMove. It will not receive any pointer events"))}else e.z__pointer_cture_rleased&&(e.z__pointer_cture_rleased=!1,this.releasePointerCapture(e,t))}releasePointerCapture(e,t){const i=e.pointerId;if(this._capturedPointer[i]){const I=this._capturedPointer[i].indexOf(t);I!==-1&&(this._capturedPointer[i].splice(I,1),CC&&console.log("released pointer capture",i,t,this._capturedPointer))}}invokePointerCapture(e){var t;if(e.event.type===ni.PointerMove){const i=e.pointerId,I=this._capturedPointer[i];if(I){CC&&console.log("Captured",i,I);for(let o=0;o<I.length;o++){const s=I[o];if(s.destroyed){I.splice(o,1),o--;continue}(t=s.onPointerMove)==null||t.call(s,e)}}}}isChild(e,t){return!e||!t?!1:e===t?!0:e.parent?this.isChild(e.parent,t):!1}handleMeshUiObjectWithoutShadowDom(e,t){return!e||!e.isUI?!0:this.handleMeshUIIntersection(e,t)}handleMeshUIIntersection(e,t){const i=va.updateState(e,t);return i&&this.currentActiveMeshUIComponents.push(i),i!==null}resetMeshUIStates(){if(this.context.input.getPointerPressedCount()>0&&va.resetLastSelected(),!(!this.currentActiveMeshUIComponents||this.currentActiveMeshUIComponents.length<=0)){for(let e=0;e<this.currentActiveMeshUIComponents.length;e++){const t=this.currentActiveMeshUIComponents[e];va.resetState(t)}this.currentActiveMeshUIComponents.length=0}}testIsVisible(e){return e?aA.isActiveSelf(e)?this.testIsVisible(e.parent):!1:!0}};let Ao=En;r(Ao,"_eventSystemMap",new Map),r(Ao,"didSearchEventSystem",!1);class va{static markDirty(){this.needsUpdate=!0}static update(A,e,t=!1){if(t){A.update();return}const i=e.time.frameCount;for(const I of this.lastUpdateFrame)if(I.context===e){if(i===I.frame)return;I.frame=i;let o=this.needsUpdate||i<1;I.nextUpdate===e.time.frameCount&&(o=!0),o&&(CC&&console.log("Update threemeshui"),this.needsUpdate=!1,A.update());return}this.lastUpdateFrame=[{context:e,frame:i,nextUpdate:i}],A.update()}static updateState(A,e){let t=null;if(A&&(t=this.findBlockInParent(A),t&&t!==this.lastSelected)){if(t.interactable===!1)return null;this.needsUpdate=!0}return t}static resetLastSelected(){const A=this.lastSelected;A&&(this.lastSelected=null,this.resetState(A))}static resetState(A){A&&(this.needsUpdate=!0)}static findBlockInParent(A){return A?A.isBlock?A:this.findBlockInParent(A.parent):null}}r(va,"lastSelected",null),r(va,"lastUpdateFrame",[]),r(va,"needsUpdate",!1);var ugA=Object.defineProperty,pgA=Object.getOwnPropertyDescriptor,bi=(g,A,e,t)=>{for(var i=t>1?void 0:t?pgA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&ugA(A,e,i),i};const fgA=IA("debugorbit"),bf=IA("freecam"),vl=IA("debugcamerafit"),vf=IA("smoothcam"),DgA={LEFT:"",UP:"",RIGHT:"",BOTTOM:""};let rG;class Fd extends CustomEvent{constructor(A,e){super("target-reached",{detail:{controls:A,type:e}})}}class Rt extends RA{constructor(){super(...arguments);r(this,"autoTarget",!0);r(this,"autoFit",!1);r(this,"enableRotate",!0);r(this,"autoRotate",!1);r(this,"autoRotateSpeed",1);r(this,"minAzimuthAngle",1/0);r(this,"maxAzimuthAngle",1/0);r(this,"minPolarAngle",0);r(this,"maxPolarAngle",Math.PI);r(this,"enableKeys",!0);r(this,"enableDamping",!0);r(this,"dampingFactor",.1);r(this,"enableZoom",!0);r(this,"minZoom",0);r(this,"maxZoom",1/0);r(this,"enablePan",!0);r(this,"lookAtConstraint",null);r(this,"lookAtConstraint01",1);r(this,"allowInterrupt",!0);r(this,"middleClickToFocus",!0);r(this,"doubleClickToFocus",!0);r(this,"useSlerp",!0);r(this,"debugLog",!1);r(this,"targetLerpDuration",1);r(this,"_controls",null);r(this,"_cameraObject",null);r(this,"_lookTargetLerpActive",!1);r(this,"_lookTargetStartPosition",new w);r(this,"_lookTargetEndPosition",new w);r(this,"_lookTargetLerp01",0);r(this,"_lookTargetLerpDuration",0);r(this,"_cameraLerpActive",!1);r(this,"_cameraStartPosition",new w);r(this,"_cameraEndPosition",new w);r(this,"_cameraLerp01",0);r(this,"_cameraLerpDuration",0);r(this,"_inputs",0);r(this,"_enableTime",0);r(this,"_startedListeningToKeyEvents",!1);r(this,"_eventSystem");r(this,"_afterHandleInputFn");r(this,"_camera",null);r(this,"_syncedTransform");r(this,"_didStart",!1);r(this,"_didSetTarget",!1);r(this,"targetElement",null);r(this,"onControlsChangeStarted",()=>{this._syncedTransform&&this._syncedTransform.requestOwnership()});r(this,"_shouldDisable",!1);r(this,"_haveAttachedKeyboardEvents",!1)}get isCameraController(){return!0}get controls(){return this._controls}get controllerObject(){return this._cameraObject}onStartInteraction(e){var t;(t=this.controls)==null||t.addEventListener("start",e)}get targetLerpSpeed(){return 5}set targetLerpSpeed(e){this.targetLerpDuration=1/e}awake(){this._didStart=!1,this._didSetTarget=!1,this._startedListeningToKeyEvents=!1}start(){this._didStart=!0,this._eventSystem=Ao.get(this.context)??void 0,this._eventSystem&&(this._afterHandleInputFn=this.afterHandleInput.bind(this),this._eventSystem.addEventListener(VM.AfterHandleInput,this._afterHandleInputFn))}onDestroy(){var e,t;(e=this._controls)==null||e.dispose(),(t=this._eventSystem)==null||t.removeEventListener(VM.AfterHandleInput,this._afterHandleInputFn)}onEnable(){this._enableTime=this.context.time.time;const e=aA.getComponent(this.gameObject,Wt);this._camera=e;let t=e==null?void 0:e.cam;if(!t&&this.gameObject instanceof He&&(t=this.gameObject),t&&OM(t,this,!0),!this._controls&&t instanceof He){this._cameraObject=t;const i=this.targetElement??this.context.renderer.domElement,I=t==null?void 0:t.quaternion.clone();this._controls=new WiA(t,i),t==null||t.quaternion.copy(I),rG===void 0&&(rG={...this._controls.keys})}this._controls&&(bf&&(this.enablePan=!0,this.enableZoom=!0,this.middleClickToFocus=!0,vo()&&(this.doubleClickToFocus=!0)),this._controls.addEventListener("start",this.onControlsChangeStarted),(t==null?void 0:t.type)==="PerspectiveCamera"?bf||(this._controls.minDistance=this.minZoom,this._controls.maxDistance=this.maxZoom):bf||(this._controls.minZoom=this.minZoom,this._controls.maxZoom=this.maxZoom),this._startedListeningToKeyEvents||(this._startedListeningToKeyEvents=!0,this._controls.listenToKeyEvents(window.document.body))),this._syncedTransform=aA.getComponent(this.gameObject,nr)??void 0}onDisable(){var e;(e=this._camera)!=null&&e.cam&&OM(this._camera.cam,this,!1),this._controls&&(this._controls.enabled=!1,this._controls.autoRotate=!1,this._controls.removeEventListener("start",this.onControlsChangeStarted))}afterHandleInput(e){e.detail.args.pointerId===0&&(e.detail.args.isDown?this._controls&&this._eventSystem&&(this._shouldDisable=this._eventSystem.hasActiveUI):(!e.detail.args.isPressed||e.detail.args.isUp)&&(this._shouldDisable=!1))}onBeforeRender(){var t,i;if(!this._controls)return;if(this._cameraObject!==this.context.mainCamera){this._controls.enabled=!1;return}this._controls.enabled=!0,this.__handleSetTargetWhenBecomingActiveTheFirstTime(),(this.context.input.getPointerDown(1)||this.context.input.getPointerDown(2)||this.context.input.mouseWheelChanged||this.context.input.getPointerPressed(0)&&((t=this.context.input.getPointerPositionDelta(0))!=null&&t.length())||0>.1)&&(this._inputs+=1),this._inputs>0&&this.allowInterrupt&&(this.enableRotate&&(this.autoRotate=!1),this._cameraLerpActive=!1,this._lookTargetLerpActive=!1),this._inputs=0;let e=this.middleClickToFocus&&this.context.input.getPointerClicked(1);if(e||(e=this.doubleClickToFocus&&this.context.input.getPointerDoubleClicked(0)&&this.context.time.time-this._enableTime>.3),e&&this.setTargetFromRaycast(),this._lookTargetLerpActive||this._cameraLerpActive){if(this._cameraLerpActive&&this._cameraObject)if(this._cameraLerp01+=this.context.time.deltaTime/this._cameraLerpDuration,this._cameraLerp01>=1)this._cameraObject.position.copy(this._cameraEndPosition),this._cameraLerpActive=!1,this.dispatchEvent(new Fd(this,"camera"));else{const I=te.easeInOutCubic(this._cameraLerp01);this._cameraObject.position.lerpVectors(this._cameraStartPosition,this._cameraEndPosition,I)}if(this._lookTargetLerpActive)if(this._lookTargetLerp01+=this.context.time.deltaTime/this._lookTargetLerpDuration,this._lookTargetLerp01>=1)this._controls.target.copy(this._lookTargetEndPosition),this._lookTargetLerpActive=!1,this.dispatchEvent(new Fd(this,"lookat"));else{const I=te.easeInOutCubic(this._lookTargetLerp01);this._controls.target.lerpVectors(this._lookTargetStartPosition,this._lookTargetEndPosition,I)}}if(this._controls){if(this.debugLog&&(this._controls.domElement=this.context.renderer.domElement),this._controls.enabled=!this._shouldDisable&&this._camera===this.context.mainCameraComponent&&!this.context.isInXR,this._controls.keys=this.enableKeys?rG:DgA,this._controls.autoRotate=this.autoRotate,this._controls.autoRotateSpeed=this.autoRotateSpeed,this._controls.enableZoom=this.enableZoom,this._controls.enableDamping=this.enableDamping,this._controls.dampingFactor=this.dampingFactor,this._controls.enablePan=this.enablePan,this._controls.enableRotate=this.enableRotate,this._controls.minAzimuthAngle=this.minAzimuthAngle,this._controls.maxAzimuthAngle=this.maxAzimuthAngle,this._controls.minPolarAngle=this.minPolarAngle,this._controls.maxPolarAngle=this.maxPolarAngle,typeof vf=="number"||vf===!0){this._controls.enableDamping=!0;const I=typeof vf=="number"?vf:.99;this._controls.dampingFactor=Math.max(.001,1-Math.min(1,I))}this.allowInterrupt||(this._lookTargetLerpActive&&(this._controls.enablePan=!1),this._cameraLerpActive&&(this._controls.enableRotate=!1,this._controls.autoRotate=!1),(this._lookTargetLerpActive||this._cameraLerpActive)&&(this._controls.enableZoom=!1)),this.context.isInXR||(!bf&&((i=this.lookAtConstraint)!=null&&i.locked)&&this.setLookTargetFromConstraint(0,this.lookAtConstraint01),this._controls.update(),fgA&&De.DrawWireSphere(this._controls.target,.1,65280))}}__handleSetTargetWhenBecomingActiveTheFirstTime(){if(!this._didSetTarget&&(this._didSetTarget=!0,this.autoTarget)){const e=aA.getComponent(this.gameObject,Wt);if(e&&!this.setLookTargetFromConstraint()){this.debugLog&&console.log("NO TARGET");const i=_e(e.cam).length(),I=new w(0,0,-i).applyMatrix4(e.cam.matrixWorld);this.setLookTargetPosition(I,!0)}if(!this.autoFit&&!this.setLookTargetFromConstraint()){const t=new Qs;t.screenPoint=new iA(0,0),t.lineThreshold=.1;const i=this.context.physics.raycast(t);i.length>0&&this.setLookTargetPosition(i[0].point,!0),vl&&console.log("OrbitControls hits",...i)}this.autoFit&&this.fitCamera()}}setCameraAndLookTarget(e){if(!e||!(e instanceof uA))return;const t=_e(e),i=VR(e);this.setTargetFromRaycast(new io(t,i)),this.setCameraTargetPosition(t)}setCameraTargetPosition(e,t=!1){var i,I;e&&(e instanceof uA&&(e=_e(e)),this._cameraEndPosition||(this._cameraEndPosition=new w),this._cameraEndPosition.copy(e),t===!0?(this._cameraLerpActive=!1,(i=this.controllerObject)==null||i.position.copy(this._cameraEndPosition)):this._cameraObject&&(this._cameraLerpActive=!0,this._cameraLerp01=0,this._cameraStartPosition.copy((I=this._cameraObject)==null?void 0:I.position),typeof t=="number"?this._cameraLerpDuration=t:this._cameraLerpDuration=this.targetLerpDuration))}get cameraLerpActive(){return this._cameraLerpActive}stopCameraLerp(){this._cameraLerpActive=!1}setLookTargetPosition(e=null,t=!1){this._controls&&e&&(e instanceof uA&&(e=_e(e)),this._lookTargetEndPosition.copy(e),t===!0?this._controls.target.copy(this._lookTargetEndPosition):(this._lookTargetLerpActive=!0,this._lookTargetLerp01=0,this._lookTargetStartPosition.copy(this._controls.target),typeof t=="number"?this._lookTargetLerpDuration=t:this._lookTargetLerpDuration=this.targetLerpDuration))}get lookTargetLerpActive(){return this._lookTargetLerpActive}stopLookTargetLerp(){this._lookTargetLerpActive=!1}setLookTargetFromConstraint(e=0,t=1){var I;if(!this._controls)return!1;const i=(I=this.lookAtConstraint)==null?void 0:I.sources;if(i&&i.length>0){const o=i[e];if(o)return o.getWorldPosition(this._lookTargetEndPosition),this.lerpLookTarget(this._lookTargetEndPosition,t),!0}return!1}lerpTarget(e,t){return this.lerpLookTarget(e,t)}lerpLookTarget(e,t){this._controls&&(t>=1?this._controls.target.copy(e):this._controls.target.lerp(e,t))}setTargetFromRaycast(e){if(!this.controls)return;const t=e?this.context.physics.raycastFromRay(e):this.context.physics.raycast();for(const i of t)if(i.distance>0&&aA.isActiveInHierarchy(i.object)){const I=_N(i.object);if(I){const o=I.canvas;if(o!=null&&o.screenspace)break}this.setLookTargetPosition(i.point);break}}fitCamera(e,t=void 0,i=!0){if(this.context.isInXR)return;t==null&&(t=1.1);const I=this._cameraObject,o=this._controls;if(e!=null&&e.length||(e=this.context.scene.children),e.length<=0){console.warn("No objects to fit camera to...");return}if(!I||!o){console.warn("No camera or controls found to fit camera to objects...");return}const s=new w,n=new w,C=new wt;C.makeEmpty();const a=[];function B(G){let M=!0;if(G.visible&&vO(G)!==!1&&!(G.type==="TransformControlsGizmo"||G.type==="TransformControlsPlane")&&(G instanceof Yk&&(M=!1),G instanceof Wy&&(M=!1),G instanceof JO&&(M=!1),G.material instanceof qy&&(M=!1),G instanceof lA||(M=!1),G!==I&&G.isUI!==!0)){if(M){vl&&console.log(G.name,G.type,G);const m=G.children;G.children=a;const N=G.position,y=G.scale;if(Number.isNaN(N.x)||Number.isNaN(N.y)||Number.isNaN(N.z)){console.warn(`Object "${G.name}" has NaN values in position or scale.... will ignore it`,N,y);return}C.expandByObject(G,!0),G.children=m}for(const m of G.children)B(m)}}let Q=!1;for(const G of e)G&&(Q=!0,G.updateMatrixWorld(),B(G));if(!Q){console.warn("No objects to fit camera to...");return}if(I.updateMatrixWorld(),I.updateProjectionMatrix(),C.getCenter(n),C.applyMatrix4(I.matrixWorldInverse),C.getSize(s),C.setFromCenterAndSize(n,s),Number.isNaN(s.x)||Number.isNaN(s.y)||Number.isNaN(s.z)){console.warn("Camera fit size resultet in NaN",I,C,[...e]);return}if(s.length()<=1e-10){vl&&console.warn("Camera fit size is zero",C,[...e]);return}const E=I.fov,c=2*Math.atan(Math.tan(E*Math.PI/360/2)*I.aspect)/Math.PI*360,d=s.y/(2*Math.atan(Math.PI*E/360)),l=s.x/(2*Math.atan(Math.PI*c/360)),h=t*Math.max(d,l)+s.z/2;vl&&console.log("Fit camera to objects",d,l,"distance",h),o.maxDistance=h*10,o.minDistance=h*.01;const p=.05,u=n.clone();u.y-=s.y*p,this.setLookTargetPosition(u,i),this.autoTarget=!1,I.near=h/1e3,I.far=h*100,I.updateMatrixWorld(),I.updateProjectionMatrix();const f=_e(I),k=n.clone();if(k.sub(f),k.y=0,k.normalize(),k.multiplyScalar(h),k.y+=-p*4*s.y,I.parent){const G=I.parent.worldToLocal(n.clone().sub(k));this.setCameraTargetPosition(G,i)}else console.error(`Can not fit camera ${I.name} because it has no parent`);if(vl){const G=new Yk(C);this.context.scene.add(G),$R(G,Eu(I)),setTimeout(()=>{this.context.scene.remove(G)},1e4),this._haveAttachedKeyboardEvents||(this._haveAttachedKeyboardEvents=!0,document.body.addEventListener("keydown",M=>{M.code==="KeyF"&&this.fitCamera(e,t,i)}))}o.update()}}bi([D()],Rt.prototype,"autoTarget",2);bi([D()],Rt.prototype,"autoFit",2);bi([D()],Rt.prototype,"enableRotate",2);bi([D()],Rt.prototype,"autoRotate",2);bi([D()],Rt.prototype,"autoRotateSpeed",2);bi([D()],Rt.prototype,"minAzimuthAngle",2);bi([D()],Rt.prototype,"maxAzimuthAngle",2);bi([D()],Rt.prototype,"minPolarAngle",2);bi([D()],Rt.prototype,"maxPolarAngle",2);bi([D()],Rt.prototype,"enableKeys",2);bi([D()],Rt.prototype,"enableDamping",2);bi([D()],Rt.prototype,"dampingFactor",2);bi([D()],Rt.prototype,"enableZoom",2);bi([D()],Rt.prototype,"minZoom",2);bi([D()],Rt.prototype,"maxZoom",2);bi([D()],Rt.prototype,"enablePan",2);bi([D(IQ)],Rt.prototype,"lookAtConstraint",2);bi([D()],Rt.prototype,"lookAtConstraint01",2);bi([D()],Rt.prototype,"allowInterrupt",2);bi([D()],Rt.prototype,"middleClickToFocus",2);bi([D()],Rt.prototype,"doubleClickToFocus",2);bi([D()],Rt.prototype,"targetLerpDuration",2);var wgA=Object.defineProperty,ygA=Object.getOwnPropertyDescriptor,go=(g,A,e,t)=>{for(var i=t>1?void 0:t?ygA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&wgA(A,e,i),i},YB=(g=>(g[g.Skybox=1]="Skybox",g[g.SolidColor=2]="SolidColor",g[g.Uninitialized=4]="Uninitialized",g))(YB||{});const cC=IA("debugcam"),xq=IA("debugscreenpointtoray");var nD;const rh=(nD=class extends RA{constructor(){super(...arguments);r(this,"_nearClipPlane",.1);r(this,"_farClipPlane",1e3);r(this,"orthographic",!1);r(this,"orthographicSize",5);r(this,"ARBackgroundAlpha",0);r(this,"_cullingMask",4294967295);r(this,"_backgroundBlurriness",0);r(this,"_backgroundIntensity",1);r(this,"_environmentIntensity");r(this,"_targetTexture",null);r(this,"_backgroundColor");r(this,"_fov");r(this,"_cam",null);r(this,"_clearFlags",2);r(this,"_skybox");r(this,"_frustum");r(this,"_projScreenMatrix",new GA)}get isCamera(){return!0}get aspect(){return this._cam instanceof He?this._cam.aspect:this.context.domWidth/this.context.domHeight}set aspect(A){this._cam instanceof He&&this._cam.aspect!==A&&(this._cam.aspect=A,this._cam.updateProjectionMatrix())}get fieldOfView(){return this._cam instanceof He?this._cam.fov:this._fov}set fieldOfView(A){const e=this.fieldOfView!=A;if(this._fov=A,e&&this._cam&&this._cam instanceof He){if(this._fov===void 0){console.warn("Can not set undefined fov on PerspectiveCamera");return}this._cam.fov=this._fov,this._cam.updateProjectionMatrix()}}get nearClipPlane(){return this._nearClipPlane}set nearClipPlane(A){const e=this._nearClipPlane!=A;this._nearClipPlane=A,this._cam&&e&&(this._cam.near=A,this._cam.updateProjectionMatrix())}get farClipPlane(){return this._farClipPlane}set farClipPlane(A){const e=this._farClipPlane!=A;this._farClipPlane=A,this._cam&&e&&(this._cam.far=A,this._cam.updateProjectionMatrix())}get clearFlags(){return this._clearFlags}set clearFlags(A){A!==this._clearFlags&&(this._clearFlags=A,this.applyClearFlagsIfIsActiveCamera())}set cullingMask(A){this._cullingMask=A,this._cam&&(this._cam.layers.mask=A)}get cullingMask(){return this._cam?this._cam.layers.mask:this._cullingMask}set cullingLayer(A){this.cullingMask=(1<<A|0)>>>0}set backgroundBlurriness(A){A!==this._backgroundBlurriness&&(A===void 0?this._backgroundBlurriness=void 0:this._backgroundBlurriness=Math.min(Math.max(A,0),1),this.applyClearFlagsIfIsActiveCamera())}get backgroundBlurriness(){return this._backgroundBlurriness}set backgroundIntensity(A){A!==this._backgroundIntensity&&(A===void 0?this._backgroundIntensity=void 0:this._backgroundIntensity=Math.min(Math.max(A,0),10),this.applyClearFlagsIfIsActiveCamera())}get backgroundIntensity(){return this._backgroundIntensity}set environmentIntensity(A){this._environmentIntensity=A}get environmentIntensity(){return this._environmentIntensity}get backgroundColor(){return this._backgroundColor??null}set backgroundColor(A){if(A){if(this._backgroundColor)this._backgroundColor.copy(A);else{if(!A.clone)return;this._backgroundColor=A.clone()}A.alpha===void 0&&(this._backgroundColor.alpha=1),this.applyClearFlagsIfIsActiveCamera()}}set targetTexture(A){this._targetTexture=A}get targetTexture(){return this._targetTexture}get cam(){return this.activeAndEnabled&&this.buildCamera(),this._cam}screenPointToRay(A,e,t){const i=this.cam,I=rh._origin;I.set(A,e,-1),this.context.input.convertScreenspaceToRaycastSpace(I),xq&&console.log("screenPointToRay",A.toFixed(2),e.toFixed(2),"now:",I.x.toFixed(2),I.y.toFixed(2),"isInXR:"+this.context.isInXR),I.z=-1,I.unproject(i);const o=rh._direction.set(I.x,I.y,I.z),s=_e(i);return o.sub(s),o.normalize(),t?(t.set(s,o),t):new io(s.clone(),o.clone())}getFrustum(){return this._frustum||(this._frustum=new JB,this.updateFrustum()),this._frustum}updateFrustum(){this._frustum||(this._frustum=new JB),this._frustum.setFromProjectionMatrix(this.getProjectionScreenMatrix(this._projScreenMatrix,!0),this.context.renderer.coordinateSystem)}getProjectionScreenMatrix(A,e){return e&&this._projScreenMatrix.multiplyMatrices(this.cam.projectionMatrix,this.cam.matrixWorldInverse),A===this._projScreenMatrix?A:A.copy(this._projScreenMatrix)}awake(){xq&&window.addEventListener("pointerdown",A=>{const e=A.clientX,t=A.clientY;console.log("touch",e.toFixed(2),t.toFixed(2));const i=this.screenPointToRay(e,t),I="#"+Math.floor(Math.random()*16777215).toString(16);De.DrawRay(i.origin,i.direction,I,10)})}onEnable(){cC&&console.log(`Camera enabled: "${this.name}". ClearFlags=${YB[this._clearFlags]}`,this),this.buildCamera(),(this.tag=="MainCamera"||!this.context.mainCameraComponent)&&(this.context.setCurrentCamera(this),mgA(this)),this.applyClearFlagsIfIsActiveCamera()}onDisable(){this.context.removeCamera(this)}onBeforeRender(){if(this._cam&&(this._frustum&&this.updateFrustum(),this._clearFlags===2&&this.applyClearFlagsIfIsActiveCamera(),this._targetTexture)){this.context.isManagedExternally&&(this._warnedAboutExternalRenderer||(this._warnedAboutExternalRenderer=!0,console.warn("Rendering with external renderer is not supported yet. This may not work or throw errors. Please remove the the target texture from your camera: "+this.name,this.targetTexture))),this.context.composer;const A=this.context.renderer;if(A){const e=this.context.mainCameraComponent;this.applyClearFlags(),this._targetTexture.render(this.context.scene,this._cam,A),e==null||e.applyClearFlags()}}}buildCamera(){if(this._cam)return;const A=this.gameObject.isCamera;let e=null;if(A?(e=this.gameObject,e==null||e.layers.enableAll(),e instanceof He&&(this._fov=e.fov)):e=this.gameObject.children[0],e&&e.isCamera)e instanceof He&&(this._fov&&(e.fov=this._fov),e.near=this._nearClipPlane,e.far=this._farClipPlane,e.updateProjectionMatrix());else if(!this.orthographic)e=new He(this.fieldOfView,window.innerWidth/window.innerHeight,this._nearClipPlane,this._farClipPlane),this.fieldOfView&&(e.fov=this.fieldOfView),this.gameObject.add(e);else{const t=this.orthographicSize*100;e=new OC(window.innerWidth/-t,window.innerWidth/t,window.innerHeight/t,window.innerHeight/-t,this._nearClipPlane,this._farClipPlane),this.gameObject.add(e)}this._cam=e,this._cam.layers.mask=this._cullingMask,this.tag=="MainCamera"&&this.context.setCurrentCamera(this)}applyClearFlagsIfIsActiveCamera(){this.context.mainCameraComponent===this&&this.applyClearFlags()}applyClearFlags(){if(!this._cam){cC&&console.log("Camera does not exist (apply clear flags)");return}if(this.fieldOfView=this._fov,cC){const A=`Camera "${this.name}" clear flags: ${YB[this._clearFlags]}`;console.debug(A)}switch(this._clearFlags){case 1:if(rh.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:cC&&console.warn(`Camera "${this.name}" has no background blurriness`),this._backgroundIntensity!==void 0?this.context.scene.backgroundIntensity=this._backgroundIntensity:cC&&console.warn(`Camera "${this.name}" has no background intensity`);break;case 2:if(this._backgroundColor){let A=this._backgroundColor.alpha;rh.backgroundShouldBeTransparent(this.context)&&(A=this.ARBackgroundAlpha??0),this.context.scene.background=null,this.context.renderer.setClearColor(this._backgroundColor,A)}else cC&&console.warn(`Camera "${this.name}" has no background color`,this);break;case 4:this.context.scene.background=null,this.context.renderer.setClearColor(0,0);break}}enableSkybox(){this._skybox||(this._skybox=new SgA(this)),this._skybox.enable()}static backgroundShouldBeTransparent(A){var I,o,s,n;const e=(I=A.renderer.xr)==null?void 0:I.getSession();if(!e)return!1;if(typeof e._transparent=="boolean")return e._transparent;const t=e.environmentBlendMode;cC&&Ci("Environment blend mode: "+t+" on "+navigator.userAgent);let i=t==="additive"||t==="alpha-blend";return A.isInAR&&t==="opaque"&&((o=navigator.userAgent)!=null&&o.includes("OculusBrowser")||(s=navigator.userAgent)!=null&&s.includes("Mozilla")&&((n=navigator.userAgent)!=null&&n.includes("Mobile WebXRViewer/v2")))&&(i=!0),e._transparent=i,i}},r(nD,"_origin",new w),r(nD,"_direction",new w),nD);let Wt=rh;go([D()],Wt.prototype,"aspect",1);go([D()],Wt.prototype,"fieldOfView",1);go([D()],Wt.prototype,"nearClipPlane",1);go([D()],Wt.prototype,"farClipPlane",1);go([D()],Wt.prototype,"clearFlags",1);go([D()],Wt.prototype,"orthographic",2);go([D()],Wt.prototype,"orthographicSize",2);go([D()],Wt.prototype,"ARBackgroundAlpha",2);go([D()],Wt.prototype,"cullingMask",1);go([D()],Wt.prototype,"backgroundBlurriness",1);go([D()],Wt.prototype,"backgroundIntensity",1);go([D()],Wt.prototype,"environmentIntensity",1);go([D(Mt)],Wt.prototype,"backgroundColor",1);go([D(Xa)],Wt.prototype,"targetTexture",1);class SgA{constructor(A){r(this,"_camera");r(this,"_skybox");this._camera=A}get context(){var A;return(A=this._camera)==null?void 0:A.context}enable(){this._skybox=this.context.lightmaps.tryGetSkybox(this._camera.sourceId),this._skybox?this.context.scene.background!==this._skybox&&(cC&&console.log(`Camera "${this._camera.name}" set skybox`,this._camera,this._skybox),this._skybox.mapping=ss,this.context.scene.background=this._skybox):(this._did_log_failed_to_find_skybox||(this._did_log_failed_to_find_skybox=!0,console.warn(`Camera "${this._camera.name}" failed to load/find skybox texture`,this._camera.sourceId,this.context.lightmaps,"Current background: ",this.context.scene.background)),(cC||he())&&fi(`Camera "${this._camera.name}" has no skybox texture`))}}function mgA(g){IA("freecam")&&g.context.mainCameraComponent===g&&aA.getOrAddComponent(g.gameObject,Rt)}class $a extends RA{constructor(){super(...arguments);r(this,"_listener",null)}get listener(){return this._listener==null&&(this._listener=new CT),this._listener}awake(){Di.registerWaitForAllowAudio(()=>{if(this.destroyed)return;const e=this.listener;if(e==null||e.parent)return;const t=this.context.mainCameraComponent||aA.getComponentInParent(this.gameObject,Wt);t!=null&&t.cam?t.cam.add(e):this.gameObject.add(e)})}}var GgA=Object.defineProperty,kgA=Object.getOwnPropertyDescriptor,wS=(g,A,e,t)=>{for(var i=t>1?void 0:t?kgA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&GgA(A,e,i),i};const MgA=IA("debugsignals");class Nu{constructor(){r(this,"guid")}}wS([D()],Nu.prototype,"guid",2);class qc{constructor(){r(this,"signal");r(this,"reaction")}}wS([D(Nu)],qc.prototype,"signal",2);wS([D(Bg)],qc.prototype,"reaction",2);var XG;const aC=(XG=class extends RA{constructor(){super(...arguments);r(this,"events")}static invoke(A){if(aC.receivers[A]){const e=aC.receivers[A];if(!e)return;for(const t of e)t.invoke(A)}}awake(){MgA&&console.log("SignalReceiver awake",this)}onEnable(){if(this.events)for(const A of this.events)aC.receivers[A.signal.guid]||(aC.receivers[A.signal.guid]=[]),aC.receivers[A.signal.guid].push(this)}onDisable(){if(this.events){for(const A of this.events)if(aC.receivers[A.signal.guid]){const e=aC.receivers[A.signal.guid].indexOf(this);e>=0&&aC.receivers[A.signal.guid].splice(e,1)}}}invoke(A){if(!this.events||!Array.isArray(this.events))return;const e=typeof A=="object"?A.guid:A;for(const t of this.events)if(t.signal.guid===e)try{if(t.reaction){if(!t.reaction.invoke){console.warn("Missing invoke - possibly a serialization error",t,this);continue}}else{console.warn("Missing reaction for signal",t,this);continue}t.reaction.invoke()}catch(i){console.error(i)}}},r(XG,"receivers",{}),XG);let xc=aC;wS([D(qc)],xc.prototype,"events",2);var co=(g=>(g.Activation="ActivationTrack",g.Animation="AnimationTrack",g.Audio="AudioTrack",g.Control="ControlTrack",g.Marker="MarkerTrack",g.Signal="SignalTrack",g))(co||{}),Qn=(g=>(g[g.None=0]="None",g[g.Hold=1]="Hold",g[g.Loop=2]="Loop",g[g.PingPong=3]="PingPong",g[g.Continue=4]="Continue",g))(Qn||{}),TN=(g=>(g.Signal="SignalEmitter",g))(TN||{});const kn=IA("debugtimeline");class Fu{constructor(){r(this,"director");r(this,"track")}get muted(){return this.track.muted}set muted(A){var e;A!==this.track.muted&&(this.track.muted=A,(e=this.onMuteChanged)==null||e.call(this))}*forEachClip(A=!1){var e;if((e=this.track)!=null&&e.clips)if(A)for(let t=this.track.clips.length-1;t>=0;t--)yield this.track.clips[t];else for(const t of this.track.clips)yield t}getClipTime(A,e){return e.clipIn+(A-e.start)*e.timeScale}getClipTimeNormalized(A,e){return(A-e.start)/e.duration}evaluateWeight(A,e,t,i=!0){if(e<0||e>=t.length)return 0;const I=t[e];if(i||A>=I.start&&A<=I.end){let o=1;const s=!1;if(I.easeInDuration>0){const n=Math.min((A-I.start)/I.easeInDuration,1);o*=n}if(I.easeOutDuration>0&&!s){const n=Math.min((I.end-A)/I.easeOutDuration,1);o*=n}return o}return 0}}class UgA{constructor(A){r(this,"clip");r(this,"rootPositionOffset");r(this,"rootQuaternionOffset");r(this,"rootStartPosition");r(this,"rootEndPosition");r(this,"rootStartQuaternion");r(this,"rootEndQuaternion");const e=A.getClip();this.clip=e;const t=A.getRoot(),i=t.name+".position",I=t.name+".quaternion";kn&&console.log(e.name,e.tracks,i);for(const o of e.tracks)if(!(o.times.length<=0)){if(o.name.endsWith(i))this.rootStartPosition=new w().fromArray(o.values,0),this.rootEndPosition=new w().fromArray(o.values,o.values.length-3),this.rootPositionOffset=this.rootEndPosition.clone().sub(this.rootStartPosition),kn&&console.log(this.rootPositionOffset);else if(o.name.endsWith(I)&&(this.rootStartQuaternion=new MA().fromArray(o.values,0),this.rootEndQuaternion=new MA().fromArray(o.values,o.values.length-4),this.rootQuaternionOffset=this.rootEndQuaternion.clone().multiply(this.rootStartQuaternion),kn)){const s=new $t().setFromQuaternion(this.rootQuaternionOffset);console.log("ROT",s)}}}get hasOffsets(){return this.rootPositionOffset!==void 0||this.rootQuaternionOffset!==void 0}}class yS extends Fu{constructor(){super(...arguments);r(this,"models",[]);r(this,"trackOffset");r(this,"target");r(this,"mixer");r(this,"clips",[]);r(this,"actions",[]);r(this,"_actionOffsets",[]);r(this,"_didBind",!1);r(this,"_animator",null);r(this,"_useclipOffsets",!0);r(this,"_totalOffsetPosition",new w);r(this,"_totalOffsetRotation",new MA);r(this,"_totalOffsetPosition2",new w);r(this,"_totalOffsetRotation2",new MA);r(this,"_summedPos",new w);r(this,"_tempPos",new w);r(this,"_summedRot",new MA);r(this,"_tempRot",new MA);r(this,"_clipRotQuat",new MA)}onDisable(){var e;(e=this.mixer)==null||e.stopAllAction()}onStateChanged(){this._animator&&Lq(this._animator.gameObject,this,this.director.isPlaying)}createHooks(e,t){var a,B;if(((a=t.tracks)==null?void 0:a.length)<=0){console.warn("No tracks in AnimationClip",t);return}const i=t.tracks[0].name.split("."),I=i[i.length-2],o=I+".position",s=I+".quaternion";let n=!1,C=!1;for(const Q of t.tracks)Q.name.endsWith(o)?(n=!0,this.createPositionInterpolant(t,e,Q)):Q.name.endsWith(s)&&(C=!0,this.createRotationInterpolant(t,e,Q));if(!n||!C){const Q=(B=this.mixer)==null?void 0:B.getRoot(),E=t.tracks[0],c=E.name.lastIndexOf("."),d=E.name.substring(0,c),l=d.substring(d.lastIndexOf(".")+1),h=Q.getObjectByName(l);if(h)if(n){if(!C){const p=t.tracks[0].name.substring(0,c)+".quaternion";kn&&console.warn("Create quaternion track",l,h);const u=h.quaternion,f=new qn(p,[0,t.duration],[u.x,u.y,u.z,u.w,u.x,u.y,u.z,u.w]);t.tracks.push(f),this.createRotationInterpolant(t,e,f)}}else{const p=d+".position";kn&&console.warn("Create position track",l,h);const u=h.position,f=new qC(p,[0,t.duration],[u.x,u.y,u.z,u.x,u.y,u.z]);t.tracks.push(f),this.createPositionInterpolant(t,e,f)}}}bind(){if(!this._didBind){this._didBind=!0,kn&&console.log(this.models),this.mixer?this.target=this.mixer.getRoot():console.warn("No mixer was assigned to animation track");for(const e of this.actions){const t=new UgA(e);this._actionOffsets.push(t)}this.target&&(this._animator=aA.getComponent(this.target,Zg)??null,this._animator&&Lq(this._animator.gameObject,this,!0));for(const e of this.models){const t=e.asset,i=t.position,I=t.rotation;i&&i.x!==void 0&&(i.isVector3||(t.position=new w(i.x,i.y,i.z)),I.isQuaternion||(t.rotation=new MA(I.x,I.y,I.z,I.w)))}this.ensureTrackOffsets()}}ensureTrackOffsets(){if(this.trackOffset){const e=this.trackOffset.position;e&&(e.isVector3||(this.trackOffset.position=new w(e.x,e.y,e.z)));const t=this.trackOffset.rotation;t&&(t.isQuaternion||(this.trackOffset.rotation=new MA(t.x,t.y,t.z,t.w)))}}evaluate(e){var n,C,a,B,Q,E,c;if(this.track.muted||!this.mixer)return;this.bind(),this._totalOffsetPosition.set(0,0,0),this._totalOffsetRotation.set(0,0,0,1),this._totalOffsetPosition2.set(0,0,0),this._totalOffsetRotation2.set(0,0,0,1);let t=0,i=0,I=!1,o=!1,s=0;for(let d=0;d<this.clips.length;d++){const l=this.models[d],h=this.actions[d],p=l.asset;h.weight=0;const u=e>=l.start&&e<=l.end,f=l.preExtrapolationMode,k=l.postExtrapolationMode,G=d<this.clips.length-1?this.models[d+1]:null;let M=u,m=!1;if(!M&&!I&&l.end<e&&k!==Qn.None?(!G||G.start>e)&&(M=!0,I=!0):d==0&&!M&&!o&&l.start>e&&f!==Qn.None&&(!G||G.start<e)&&(M=!0,m=!0,o=!0),M){let N=1;N*=this.evaluateWeight(e,d,this.models,M),N*=this.director.weight;let y=u;if(m)switch(f){case Qn.Hold:break;case Qn.Loop:e+=l.start,y=!0;break;default:e+=l.start,y=!0;break}let U=this.getClipTime(e,l),H=0;const x=p.duration;if(m&&f===Qn.Hold&&(U=0),y){if(p.loop)for(H+=Math.floor(U/(x+1e-6));U>x;)U-=x}else if(!u&&I)switch(k){case Qn.Hold:U=this.getClipTime(l.end,l);break;case Qn.Loop:U%=x;break;case Qn.PingPong:const b=Math.floor(U/x)%2!==0;U%=x,b&&(U=x-U);break}l.reversed===!0?h.time=h.getClip().duration-U:h.time=U,h.timeScale=0;const K=Math.max(0,N);if(h.weight=K,s+=K,h.clampWhenFinished=!1,h.isRunning()||h.play(),this._useclipOffsets){const O=t==0?this._totalOffsetPosition:this._totalOffsetPosition2,b=t==0?this._totalOffsetRotation:this._totalOffsetRotation2;t<1&&(i=1-N),t+=1;const v=this._summedPos.set(0,0,0),T=this._tempPos.set(0,0,0),V=this._summedRot.identity(),X=this._tempRot.identity(),CA=p.rotation;CA&&(this._clipRotQuat.identity(),this._clipRotQuat.slerp(CA,N));const QA=this._actionOffsets[d];if(QA.hasOffsets)for(let FA=0;FA<H;FA++)QA.rootPositionOffset?T.copy(QA.rootPositionOffset):T.set(0,0,0),T.applyQuaternion(V),this._clipRotQuat&&T.applyQuaternion(this._clipRotQuat),QA.rootQuaternionOffset&&(X.copy(QA.rootQuaternionOffset),V.multiply(X)),v.add(T);this._clipRotQuat&&b.multiply(this._clipRotQuat),b.multiply(V),p.position&&v.add(p.position),O.add(v)}}}if(this._useclipOffsets&&(this._totalOffsetPosition.lerp(this._totalOffsetPosition2,i),this._totalOffsetRotation.slerp(this._totalOffsetRotation2,i)),this.__mixerError===void 0&&(kn||he())&&((C=(n=this._animator)==null?void 0:n.runtimeAnimatorController)!=null&&C.mixer)&&this.mixer!==((B=(a=this._animator)==null?void 0:a.runtimeAnimatorController)==null?void 0:B.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)),(Q=this._animator)!=null&&Q.runtimeAnimatorController){const d=Math.max(0,1-s);(c=(E=this._animator)==null?void 0:E.runtimeAnimatorController)==null||c.update(d)}else this.mixer.update(e)}createRotationInterpolant(e,t,i){var n;const I=i.createInterpolant.bind(i),o=new MA;this.ensureTrackOffsets();const s=(n=this.trackOffset)==null?void 0:n.rotation;i.createInterpolant=()=>{const C=I(),a=C.evaluate.bind(C);return C.evaluate=B=>{var E;const Q=a(B);if(o.set(Q[0],Q[1],Q[2],Q[3]),o.premultiply(this._totalOffsetRotation),s&&o.premultiply(s),this.director.animationCallbackReceivers)for(const c of this.director.animationCallbackReceivers)(E=c==null?void 0:c.onTimelineRotation)==null||E.call(c,this.director,this.target,B,o);return Q[0]=o.x,Q[1]=o.y,Q[2]=o.z,Q[3]=o.w,Q},C}}createPositionInterpolant(e,t,i){var a,B;const I=i.createInterpolant.bind(i),o=new w;this.ensureTrackOffsets();const s=(a=this.trackOffset)==null?void 0:a.rotation,n=(B=this.trackOffset)==null?void 0:B.position;let C;i.createInterpolant=()=>{const Q=I(),E=Q.evaluate.bind(Q);return Q.evaluate=c=>{var l,h,p;const d=E(c);if(o.set(d[0],d[1],d[2]),t.removeStartOffset&&(C===void 0?(C=null,C=(h=(l=this._actionOffsets.find(u=>u.clip===e))==null?void 0:l.rootStartPosition)==null?void 0:h.clone()):C!=null&&C.isVector3&&o.sub(C)),o.applyQuaternion(this._totalOffsetRotation),o.add(this._totalOffsetPosition),s&&o.applyQuaternion(s),n&&(o.x-=n.x,o.y+=n.y,o.z+=n.z),this.director.animationCallbackReceivers)for(const u of this.director.animationCallbackReceivers)(p=u==null?void 0:u.onTimelinePosition)==null||p.call(u,this.director,this.target,c,o);return d[0]=o.x,d[1]=o.y,d[2]=o.z,d},Q}}}const RgA=IA("mutetimeline"),JE=class extends Fu{constructor(){super(...arguments);r(this,"models",[]);r(this,"listener");r(this,"audio",[]);r(this,"audioContextTimeOffset",[]);r(this,"lastTime",0);r(this,"audioSource");r(this,"_audioLoader",null);r(this,"_playableDirectorResumed",!1)}getAudioFilePath(e){const t=this.director.sourceId;return WC(t,e)}onAllowAudioChanged(e){for(let t=0;t<this.models.length;t++){const i=this.models[t];this.audio[t].setVolume(e?i.asset.volume:0)}}addModel(e){const t=new BR(this.listener);this.audio.push(t);const i=e;i._didTriggerPlay=!1,this.models.push(i)}onDisable(){for(const e of this.audio)e.isPlaying&&e.stop();for(const e of this.models)e._didTriggerPlay=!1}onDestroy(){for(const e of this.audio)e.source&&(e==null||e.disconnect());this.audio.length=0}onMuteChanged(){if(this.muted)for(let e=0;e<this.audio.length;e++){const t=this.audio[e];t!=null&&t.isPlaying&&t.stop()}}stop(){for(let e=0;e<this.audio.length;e++){const t=this.audio[e];t!=null&&t.isPlaying&&t.stop()}for(const e of this.models)e._didTriggerPlay=!1}onPauseChanged(){for(let e=0;e<this.audio.length;e++){const t=this.audio[e];t!=null&&t.isPlaying&&t.stop()}this._playableDirectorResumed=this.director.isPlaying}evaluate(e){if(RgA||this.track.muted||this.director.speed<0)return;const t=this.director.context.application.muted,i=this._playableDirectorResumed;this._playableDirectorResumed=!1;const I=t?.1:0;for(let o=0;o<this.models.length;o++){const s=this.models[o],n=this.audio[o],C=s.asset;if((!n||!n.buffer)&&this.isInTimeRange(s,e-1,e+1)&&this.handleAudioLoading(s,n),Di.userInteractionRegistered!==!1&&!(n===null||!n.buffer))if(n.playbackRate=this.director.context.time.timeScale*this.director.speed,n.loop=C.loop,e>=s.start&&e<=s.end&&e<this.director.duration){if(!n.isPlaying||!this.director.isPlaying)(i||!s._didTriggerPlay&&this.lastTime<e)&&(s.duration*s.timeScale>.3?n.offset=s.clipIn+(e-s.start)*s.timeScale:n.offset=0,kn&&console.log("Timeline Audio ("+this.track.name+") play with offset "+n.offset+" - "+s.asset.clip),n.play(I),s._didTriggerPlay=!0);else{const B=s.clipIn+(e-s.start)*s.timeScale,Q=n.context.currentTime-n._startedAt+n.offset;Math.abs(B-Q)>.3&&(n.offset=B,n.stop(),n.play(I))}let a=C.volume;if(this.track.volume!==void 0&&(a*=this.track.volume),t&&(a=0),s.easeInDuration>0){const B=Math.min((e-s.start)/s.easeInDuration,1);a*=B}if(s.easeOutDuration>0){const B=Math.min((s.end-e)/s.easeOutDuration,1);a*=B}n.setVolume(a*this.director.weight)}else s._didTriggerPlay=!1,this.director.isPlaying&&n.isPlaying&&n.stop()}this.lastTime=e}loadAudio(e,t=0,i=0){let I=null;const o=e-i,s=e+t;for(const n of this.models)if(this.isInTimeRange(n,o,s)){const C=this.audio[this.models.indexOf(n)],a=this.handleAudioLoading(n,C);a!==null&&(I===null&&(I=[]),I.push(a))}return I!==null?Promise.all(I):null}isInTimeRange(e,t,i){return t<=e.start&&i>=e.end||t>=e.start&&t<=e.end||i>=e.start&&i<=e.end}static dispose(){JE._audioBuffers.clear()}handleAudioLoading(e,t){this._audioLoader||(this._audioLoader=new aw);const i=this.getAudioFilePath(e.asset.clip);if(JE._audioBuffers.get(i)){const o=JE._audioBuffers.get(i);return o.then(s=>{s&&t.setBuffer(s)}),o}kn&&console.warn("LOAD audio track",i,this.director.sourceId);const I=new Promise((o,s)=>{this._audioLoader.load(i,n=>{t.setBuffer(n),o(n)},void 0,n=>{console.error("Error loading audio",n),o(null)})});return JE._audioBuffers.set(i,I),I}};let mB=JE;r(mB,"_audioBuffers",new Map);class Kd extends Fu{constructor(){super(...arguments);r(this,"models",[]);r(this,"didTrigger",[]);r(this,"receivers",[])}evaluate(e){var i;if(this.track.muted)return;const t=this.director.context.time.deltaTime*1.5;for(let I=0;I<this.models.length;I++){const o=this.models[I],s=this.didTrigger[I],n=o.time-e;let C=!1;if(o.retroActive)C=n<=1e-6;else{const a=Math.abs(n);(a===0||a>=1e-5&&a<t)&&(C=!0)}if(C){if(!s)if(kn&&console.log("Trigger signal",e,o.time,o),this.didTrigger[I]=!0,((i=this.receivers)==null?void 0:i.length)<=0)xc.invoke(o.asset);else for(const a of this.receivers)a&&a.invoke(o.asset)}else o.emitOnce||(this.didTrigger[I]=!1)}}}class SS extends Fu{constructor(){super(...arguments);r(this,"models",[]);r(this,"timelines",[]);r(this,"_previousActiveModel",null)}resolveSourceObjects(e){for(let t=this.models.length-1;t>=0;t--){const I=this.models[t].asset;if(!I.sourceObject||typeof I.sourceObject!="object"){console.log("no source object, removing model",t,I),this.models.splice(t,1);continue}else{const o=aA.getComponent(I.sourceObject,bC);this.timelines.push(o),o&&I.updateDirector&&(o.playOnAwake=!1)}}}evaluate(e){var t;this._previousActiveModel=null;for(let i=0;i<this.models.length;i++){const I=this.models[i],o=I.asset;if(e>=I.start&&e<=I.end){this._previousActiveModel=I;const s=this.getClipTime(e,I);if(o.controlActivation){const n=o.sourceObject;n.visible=!0}if(o.updateDirector){const n=this.timelines[i];n&&(n.isPlaying&&n.pause(),n.time=s,n.evaluate())}}else{const s=(t=this._previousActiveModel)==null?void 0:t.asset;if(o.controlActivation){const n=o.sourceObject;(s==null?void 0:s.sourceObject)!==n&&(n.visible=!1)}}}}}const iE=IA("debugtimeline"),Iy=class extends RA{constructor(){super(...arguments);r(this,"playableAsset");r(this,"playOnAwake");r(this,"extrapolationMode",1);r(this,"waitForAudio",!0);r(this,"_visibilityChangeEvt");r(this,"_clonedPlayableAsset",!1);r(this,"_speed",1);r(this,"_guidsMap");r(this,"_isPlaying",!1);r(this,"_internalUpdateRoutine");r(this,"_isPaused",!1);r(this,"_isStopping",!1);r(this,"_time",0);r(this,"_duration",0);r(this,"_weight",1);r(this,"_animationTracks",[]);r(this,"_audioTracks",[]);r(this,"_signalTracks",[]);r(this,"_controlTracks",[]);r(this,"_customTracks",[]);r(this,"_allTracks",[this._animationTracks,this._audioTracks,this._signalTracks,this._controlTracks,this._customTracks]);r(this,"animationCallbackReceivers",[])}static registerCreateTrack(e,t){this.createTrackFunctions[e]=t}get isPlaying(){return this._isPlaying}get isPaused(){return this._isPaused}get time(){return this._time}set time(e){typeof e=="number"&&!Number.isNaN(e)?this._time=e:(iE||No())&&console.error("INVALID TIMELINE.TIME VALUE",e,this.name)}get duration(){return this._duration}set duration(e){this._duration=e}get weight(){return this._weight}set weight(e){this._weight=e}get speed(){return this._speed}set speed(e){this._speed=e}awake(){var e,t,i;iE&&console.log(this,(e=this.playableAsset)==null?void 0:e.tracks),this.rebuildGraph(),this.isValid()||console.warn("PlayableDirector is not valid",this.playableAsset,(t=this.playableAsset)==null?void 0:t.tracks,Array.isArray((i=this.playableAsset)==null?void 0:i.tracks),this)}onEnable(){var e,t,i;for(const I of this._audioTracks)(e=I.onEnable)==null||e.call(I);for(const I of this._customTracks)(t=I.onEnable)==null||t.call(I);for(const I of this._animationTracks)(i=I.onEnable)==null||i.call(I);this.playOnAwake&&this.play(),this._visibilityChangeEvt||(this._visibilityChangeEvt=()=>{switch(document.visibilityState){case"hidden":this.setAudioTracksAllowPlaying(!1);break;case"visible":this.setAudioTracksAllowPlaying(!0);break}}),window.addEventListener("visibilitychange",this._visibilityChangeEvt)}onDisable(){var e,t,i;this.stop();for(const I of this._audioTracks)(e=I.onDisable)==null||e.call(I);for(const I of this._customTracks)(t=I.onDisable)==null||t.call(I);for(const I of this._animationTracks)(i=I.onDisable)==null||i.call(I);this._visibilityChangeEvt&&window.removeEventListener("visibilitychange",this._visibilityChangeEvt)}onDestroy(){var e;for(const t of this._allTracks)for(const i of t)(e=i.onDestroy)==null||e.call(i)}rebuildGraph(){this.isValid()&&(this.resolveBindings(),this.updateTimelineDuration(),this.setupAndCreateTrackHandlers())}async play(){if(!this.isValid())return;const e=this._isPaused==!0;if(this._isPaused=!1,!this._isPlaying){if(this._isPlaying=!0,e&&this.invokePauseChangedMethodsOnTracks(),this.waitForAudio){const t=[];for(const i of this._audioTracks){const I=i.loadAudio(this._time,1,0);I&&t.push(I)}if(t.length>0&&(await Promise.all(t),!this._isPlaying))return;for(;this._audioTracks.length>0&&this._isPlaying&&!Di.userInteractionRegistered&&this.waitForAudio;)await Os(200)}this.invokeStateChangedMethodsOnTracks(),this._internalUpdateRoutine=this.startCoroutine(this.internalUpdate(),Ai.LateUpdate)}}pause(){this.isValid()&&(this._isPlaying=!1,!this._isPaused&&(this._isPaused=!0,this.internalEvaluate(),this.invokePauseChangedMethodsOnTracks(),this.invokeStateChangedMethodsOnTracks()))}stop(){this._isStopping=!0;for(const i of this._audioTracks)i.stop();const e=this._isPaused==!0,t=this._isPlaying;this._isPlaying&&(this._time=0,this._isPlaying=!1,this._isPaused=!1,this.internalEvaluate(),e&&this.invokePauseChangedMethodsOnTracks()),this._isPlaying=!1,this._isPaused=!1,e&&!t&&this.invokePauseChangedMethodsOnTracks(),t&&this.invokeStateChangedMethodsOnTracks(),this._internalUpdateRoutine&&this.stopCoroutine(this._internalUpdateRoutine),this._internalUpdateRoutine=null,this._isStopping=!1}evaluate(){this.internalEvaluate(!0)}isValid(){return this.playableAsset&&this.playableAsset.tracks&&Array.isArray(this.playableAsset.tracks)}*forEachTrack(){for(const e of this._allTracks)for(const t of e)yield t}get audioTracks(){return this._audioTracks}resolveGuids(e){this._guidsMap=e}invokePauseChangedMethodsOnTracks(){var e;for(const t of this.forEachTrack())(e=t.onPauseChanged)==null||e.call(t)}invokeStateChangedMethodsOnTracks(){var e;for(const t of this.forEachTrack())(e=t.onStateChanged)==null||e.call(t,this._isPlaying)}*internalUpdate(){for(;this._isPlaying&&this.activeAndEnabled;)!this._isPaused&&this._isPlaying&&(this._time+=this.context.time.deltaTime*this.speed,this.internalEvaluate()),yield}internalEvaluate(e=!1){if(!this.isValid())return;let t=this._time;switch(this.extrapolationMode){case 0:this._speed>0?t=Math.min(t,this._duration):this._speed<0&&(t=Math.max(t,0)),this._time=t;break;case 1:t%=this._duration,this._time=t;break;case 2:if(t>this._duration){this.stop();return}break}const i=this._time;for(const I of this.playableAsset.tracks)if(!I.muted)switch(I.type){case co.Activation:if(!e&&!this._isPlaying)continue;for(let o=0;o<I.outputs.length;o++){const s=I.outputs[o];if(typeof s=="object"){let n=!1;if(I.clips)for(const a of I.clips)a.start<=i&&i<=a.end&&(n=!0);const C=s;C.visible!==void 0&&C.visible!==n&&(C.visible=n,iE&&console.warn(this.name,"set ActivationTrack-"+o,C.name,n,i))}}break}if(!this._isStopping)for(const I of this._animationTracks)I.evaluate(i);for(const I of this._audioTracks)I.evaluate(i);for(const I of this._signalTracks)I.evaluate(i);for(const I of this._controlTracks)I.evaluate(i);for(const I of this._customTracks)I.evaluate(i)}resolveBindings(){if(this._clonedPlayableAsset||(this._clonedPlayableAsset=!0,this.playableAsset=Cu(this.playableAsset)),!this.playableAsset||!this.playableAsset.tracks)return;const e=this.findRoot(this.gameObject);for(const t of this.playableAsset.tracks){for(let i=t.outputs.length-1;i>=0;i--){let I=t.outputs[i];if(typeof I=="string"){this._guidsMap&&this._guidsMap[I]&&(I=this._guidsMap[I]);const o=aA.findByGuid(I,e);o===null||typeof o!="object"?(t.outputs.splice(i,1),console.warn("Failed to resolve binding",I,t.name,t.type)):(iE&&console.log("Resolved binding",I,"to",o),t.outputs[i]=o)}else if(I===null){if(t.outputs.splice(i,1),Iy.createTrackFunctions[t.type])continue;t.type!==co.Audio&&t.type!==co.Control&&t.type!==co.Marker&&t.type!==co.Signal&&console.warn("Missing binding",I,t.name,t.type,this.name,this.playableAsset.name)}}if(t.type===co.Control&&t.clips)for(let i=0;i<t.clips.length;i++){const I=t.clips[i];let o=I.asset.sourceObject;if(typeof o=="string"){this._guidsMap&&this._guidsMap[o]&&(o=this._guidsMap[o]);const s=aA.findByGuid(o,e);s===null||typeof s!="object"?console.warn("Failed to resolve sourceObject binding",o,t.name,I):(iE&&console.log("Resolved binding",o,"to",s),I.asset.sourceObject=s)}}}}findRoot(e){return e.parent?this.findRoot(e.parent):e}updateTimelineDuration(){if(this._duration=0,!(!this.playableAsset||!this.playableAsset.tracks)){for(const e of this.playableAsset.tracks)if(e.muted!==!0){if(e.clips)for(const t of e.clips)t.end>this._duration&&(this._duration=t.end);if(e.markers)for(const t of e.markers)t.time>this._duration&&(this._duration=t.time+.001)}}}setupAndCreateTrackHandlers(){var t,i,I;if(this._animationTracks.length=0,this._audioTracks.length=0,this._signalTracks.length=0,!this.playableAsset)return;let e=aA.findObjectOfType($a,this.context);for(const o of this.playableAsset.tracks){const s=o.type,n=Iy.createTrackFunctions[s];if(n!=null){const C=n(this,o);if(typeof C.evaluate=="function"){C.director=this,C.track=o,this._customTracks.push(C);continue}}if(o.type===co.Animation){if(!o.clips||o.clips.length<=0){iE&&console.warn("Animation track has no clips",o);continue}for(let C=o.outputs.length-1;C>=0;C--){let a=o.outputs[C];if(a instanceof uA){const Q=aA.getOrAddComponent(a,Zg);Q&&(a=Q)}const B=(t=a==null?void 0:a.gameObject)==null?void 0:t.animations;if(B){const Q=new yS;Q.trackOffset=o.trackOffset,Q.director=this,Q.track=o;for(let E=0;E<o.clips.length;E++){const c=o.clips[E],d=c.asset;if(!d){console.error(`Timeline ${this.name}: clip #${E} on track "${o.name}" has no animation data`);continue}const l=d.clip;let h=l;if((typeof h=="string"||typeof h=="number")&&(h=B.find(u=>u.name===l)),!h){console.warn("Could not find animationClip for model",c,o.name,this.name,(i=this.playableAsset)==null?void 0:i.name);continue}a instanceof Zg&&a.runtimeAnimatorController&&(a.__internalDidAwakeAndStart||a.initializeRuntimeAnimatorController(),a.runtimeAnimatorController.mixer||a.runtimeAnimatorController.bind(a),Q.mixer=a.runtimeAnimatorController.mixer),Q.mixer||(Q.mixer=new Py(a.gameObject)),Q.clips.push(h),Q.mixer.uncacheAction(h),Q.createHooks(c.asset,h);const p=Q.mixer.clipAction(h);Q.actions.push(p),Q.models.push(c)}this._animationTracks.push(Q)}}}else if(o.type===co.Audio){if(!o.clips||o.clips.length<=0)continue;const C=new mB;C.director=this,C.track=o,C.audioSource=o.outputs.find(a=>a instanceof Di),this._audioTracks.push(C),e||(e=(I=this.context.mainCameraComponent)==null?void 0:I.gameObject.addNewComponent($a)),C.listener=e.listener;for(let a=0;a<o.clips.length;a++){const B=o.clips[a];C.addModel(B)}}else if(o.type===co.Marker){const C=new Kd;if(C.director=this,C.track=o,o.markers)for(const a of o.markers)switch(a.type){case TN.Signal:C.models.push(a),C.didTrigger.push(!1);break}if(C!==null&&C.models.length>0){const a=aA.getComponent(this.gameObject,xc);a&&(C.receivers.push(a),this._signalTracks.push(C))}}else if(o.type===co.Signal){const C=new Kd;if(C.director=this,C.track=o,o.markers)for(const a of o.markers)C.models.push(a),C.didTrigger.push(!1);for(const a of o.outputs)C.receivers.push(a);this._signalTracks.push(C)}else if(o.type===co.Control){const C=new SS;if(C.director=this,C.track=o,o.clips)for(const a of o.clips)C.models.push(a);C.resolveSourceObjects(this.context),this._controlTracks.push(C)}}}setAudioTracksAllowPlaying(e){for(const t of this._audioTracks)t.onAllowAudioChanged(e)}registerAnimationCallback(e){this.animationCallbackReceivers.push(e)}unregisterAnimationCallback(e){const t=this.animationCallbackReceivers.indexOf(e);t!==-1&&this.animationCallbackReceivers.splice(t,1)}};let bC=Iy;r(bC,"createTrackFunctions",{});const LD=Symbol("objectIsAnimatedData");function Lq(g,A,e){if(!g)return;if(g[LD]===void 0){if(!e)return;g[LD]=new Set}const t=g[LD];e?t.add(A):t.has(A)&&t.delete(A)}function NgA(g){if(!g)return!1;const A=g[LD];return A!==void 0&&A.size>0}st.registerCallback(di.ContextCreated,g=>{const A=g.context.domElement.getAttribute("autoplay");if(A!==void 0&&(A===""||A==="true")&&g.files)for(const e of g.files)aA.foreachComponent(e.file.scene,i=>{if(i.enabled!==!1){if(i instanceof HI&&i.playAutomatically||i instanceof Zg||i instanceof bC&&i.playOnAwake===!0)return!0;if(i instanceof HI)return i.playAutomatically=!0,!0;if(i instanceof bC)return i.playOnAwake=!0,!0}},!0)!==!0&&FgA(e.file)});function FgA(g){if(!g||!g.animations)return;for(let e=0;e<g.animations.length;e++){const t=g.animations[e];if(!(!t.tracks||t.tracks.length<=0))for(const i in t.tracks){const I=t.tracks[i],o=I.__objectName??I.name.substring(0,I.name.indexOf("."));let s=g.scene.getObjectByName(o);if(!s&&(s=g.scene.getObjectByProperty("uuid",o),!s))continue;let n=A(s);n||(n=za(g.scene,new HI));const C=n.animations=n.animations||[];t.name_animator=n.name,C.indexOf(t)<0&&C.push(t)}}function A(e){var i;if(!e)return;const t=(i=e.userData)==null?void 0:i.components;if(t&&t.length>0)for(let I=0;I<t.length;I++){const o=t[I];if(o instanceof Zg||o instanceof HI)return e}return A(e.parent)}}class KgA{constructor(){r(this,"_context")}get context(){return this._context??ve.Current}get isStateMachineBehaviour(){return!0}}class Bh{constructor(A,e,t,i){r(this,"name");r(this,"nameHash");r(this,"normalizedTime");r(this,"length");r(this,"speed");r(this,"action");r(this,"hasTransitions");var I;this.name=A.name,this.nameHash=A.hash,this.normalizedTime=e,this.length=t,this.speed=i,this.action=A.motion.action||null,this.hasTransitions=((I=A.transitions)==null?void 0:I.length)>0||!1}}function OO(g,A){return{name:"",isLooping:!1,guid:(A==null?void 0:A.generateUUID())??ag.generateUUID(),index:-1,clip:new _I(g,1,[])}}var Na=(g=>(g[g.If=1]="If",g[g.IfNot=2]="IfNot",g[g.Greater=3]="Greater",g[g.Less=4]="Less",g[g.Equals=6]="Equals",g[g.NotEqual=7]="NotEqual",g))(Na||{}),HN=(g=>(g[g.Float=1]="Float",g[g.Int=3]="Int",g[g.Bool=4]="Bool",g[g.Trigger=9]="Trigger",g))(HN||{});const mI=IA("debuganimatorcontroller"),qf=IA("debugrootmotion");class Ro{constructor(A){r(this,"_speed",1);r(this,"normalizedStartOffset",0);r(this,"animator");r(this,"model");r(this,"_mixer");r(this,"_activeState");r(this,"_activeStates",[]);r(this,"rootMotionHandler");this.model=A,mI&&console.log(this)}static createFromClips(A,e={looping:!1,autoTransition:!0,transitionDuration:0}){const t=[];for(let o=0;o<A.length;o++){const s=A[o],n=[];if(e.autoTransition!==!1){const a=e.transitionDuration??0,B=a/s.duration;let Q=o;(e.autoTransition===void 0||e.autoTransition===!0)&&(Q=(o+1)%A.length),n.push({exitTime:1-B,offset:0,duration:a,hasExitTime:!0,destinationState:Q,conditions:[]})}const C={name:s.name,hash:o,motion:{name:s.name,clip:s,isLooping:(e==null?void 0:e.looping)??!1},transitions:n,behaviours:[]};t.push(C)}const i={name:"AnimatorController",guid:new Gg(Date.now()).generateUUID(),parameters:[],layers:[{name:"Base Layer",stateMachine:{defaultState:0,states:t}}]};return new Ro(i)}play(A,e=-1,t=Number.NEGATIVE_INFINITY,i=0){if(e<0)e=0;else if(e>=this.model.layers.length){console.warn("invalid layer");return}const o=this.model.layers[e].stateMachine;for(const s of o.states)if(s.name===A||s.hash===A){mI&&console.log("transition to ",s),this.transitionTo(s,i,t);return}console.warn("Could not find "+A+" to play")}reset(){this.setStartTransition()}setBool(A,e){var i,I;const t=typeof A=="string"?"name":"hash";return(I=(i=this.model)==null?void 0:i.parameters)==null?void 0:I.filter(o=>o[t]===A).forEach(o=>o.value=e)}getBool(A){var t,i,I;const e=typeof A=="string"?"name":"hash";return((I=(i=(t=this.model)==null?void 0:t.parameters)==null?void 0:i.find(o=>o[e]===A))==null?void 0:I.value)??!1}setFloat(A,e){var I,o;const t=typeof A=="string"?"name":"hash",i=(o=(I=this.model)==null?void 0:I.parameters)==null?void 0:o.filter(s=>s[t]===A);return i.forEach(s=>s.value=e),(i==null?void 0:i.length)>0}getFloat(A){var t,i,I;const e=typeof A=="string"?"name":"hash";return((I=(i=(t=this.model)==null?void 0:t.parameters)==null?void 0:i.find(o=>o[e]===A))==null?void 0:I.value)??0}setInteger(A,e){var i,I;const t=typeof A=="string"?"name":"hash";return(I=(i=this.model)==null?void 0:i.parameters)==null?void 0:I.filter(o=>o[t]===A).forEach(o=>o.value=e)}getInteger(A){var t,i,I;const e=typeof A=="string"?"name":"hash";return((I=(i=(t=this.model)==null?void 0:t.parameters)==null?void 0:i.find(o=>o[e]===A))==null?void 0:I.value)??0}setTrigger(A){var t,i;mI&&console.log("SET TRIGGER",A);const e=typeof A=="string"?"name":"hash";return(i=(t=this.model)==null?void 0:t.parameters)==null?void 0:i.filter(I=>I[e]===A).forEach(I=>I.value=!0)}resetTrigger(A){var t,i;const e=typeof A=="string"?"name":"hash";return(i=(t=this.model)==null?void 0:t.parameters)==null?void 0:i.filter(I=>I[e]===A).forEach(I=>I.value=!1)}getTrigger(A){var t,i,I;const e=typeof A=="string"?"name":"hash";return((I=(i=(t=this.model)==null?void 0:t.parameters)==null?void 0:i.find(o=>o[e]===A))==null?void 0:I.value)??!1}isInTransition(){return this._activeStates.length>1}setSpeed(A){this._speed=A}FindState(A){return this.findState(A)}findState(A){if(!A)return null;if(Array.isArray(this.model.layers)){for(const e of this.model.layers)for(const t of e.stateMachine.states)if(t.name===A||t.hash==A)return t}return null}getCurrentStateInfo(){if(!this._activeState)return null;const A=this._activeState.motion.action;if(!A)return null;const e=this._activeState.motion.clip.duration,t=e<=0?0:Math.abs(A.time/e);return new Bh(this._activeState,t,e,this._speed)}get currentAction(){if(!this._activeState)return null;const A=this._activeState.motion.action;return A||null}get context(){var A;return(A=this.animator)==null?void 0:A.context}get mixer(){return this._mixer}bind(A){A?this.animator!==A&&(this.animator=A,this._mixer=new Py(this.animator.gameObject),this.createActions(this.animator)):console.error("AnimatorController.bind: animator is null")}clone(){if(typeof this.model=="string")return console.warn("AnimatorController has not been resolved, can not create model from string",this.model),null;mI&&console.warn("AnimatorController clone()",this.model);const A=Cu(this.model,(t,i,I)=>I==null?!0:!(I.type==="Object3D"||I.isObject3D===!0||DH(I)||I.tracks!==void 0||I instanceof Ro));return console.assert(A!==this.model),new Ro(A)}update(A){var t,i;if(!this.animator)return;this.evaluateTransitions(),this.updateActiveStates(A);const e=this.animator.context.time.deltaTime;this.animator.applyRootMotion&&((t=this.rootMotionHandler)==null||t.onBeforeUpdate(A)),this._mixer.update(e),this.animator.applyRootMotion&&((i=this.rootMotionHandler)==null||i.onAfterUpdate(A))}get activeState(){return this._activeState}updateActiveStates(A){for(let e=0;e<this._activeStates.length;e++){const t=this._activeStates[e],i=t.motion;if(!i.action)this._activeStates.splice(e,1),e--;else{const I=i.action;I.weight=A,I.getEffectiveWeight()<=0&&!I.isRunning()&&(mI&&console.debug("REMOVE",t.name,I.getEffectiveWeight(),I.isRunning(),I.isScheduled()),this._activeStates.splice(e,1),e--)}}}setStartTransition(){for(const A of this.model.layers){const e=A.stateMachine;e.defaultState===void 0&&(mI&&console.warn("AnimatorController default state is undefined, will assign state 0 as default",A),e.defaultState=0);const t=e.states[e.defaultState];this.transitionTo(t,0,this.normalizedStartOffset)}}evaluateTransitions(){var I;let A=!1;if(!this._activeState){if(this.setStartTransition(),!this._activeState)return;A=!0}const e=this._activeState,t=e.motion.action;for(const o of e.transitions){if(!o.hasExitTime&&o.conditions.length<=0)continue;let s=!0;for(const n of o.conditions)if(!this.evaluateCondition(n)){s=!1;break}if(s)if(t){const n=e.motion.clip.duration,C=n<=0?1:Math.abs(t.time/n);let a=!1;if(o.hasExitTime?t.timeScale>0?a=C>=o.exitTime:t.timeScale<0&&(a=1-C>=o.exitTime):a=!0,a){for(const B of o.conditions){const Q=this.model.parameters.find(E=>E.name===B.parameter);(Q==null?void 0:Q.type)===HN.Trigger&&Q.value&&(Q.value=!1)}t.clampWhenFinished=!0,mI&&console.log("transition to "+o.destinationState,o,C,o.exitTime,o.hasExitTime),this.transitionTo(o.destinationState,o.duration,o.offset);return}}else{this.transitionTo(o.destinationState,o.duration,o.offset);return}}if(t){let o=e.speed??1;e.speedParameter&&(o*=this.getFloat(e.speedParameter)),o!==void 0&&(t.timeScale=o*this._speed)}let i=!1;if(e.motion.isLooping&&t&&(t.time>=t.getClip().duration?(i=!0,t.reset(),t.time=0,t.play()):t.time<=0&&t.timeScale<0&&(i=!0,t.reset(),t.time=t.getClip().duration,t.play())),!i&&e&&!A&&t&&this.animator&&e.behaviours){const o=t==null?void 0:t.getClip().duration,s=t.time/o,n=new Bh(this._activeState,s,o,this._speed);for(const C of e.behaviours)C.instance&&((I=C.instance.onStateUpdate)==null||I.call(C.instance,this.animator,n,0))}}getState(A,e){return typeof A=="number"&&(A==-1&&(A=this.model.layers[e].stateMachine.defaultState,A===void 0&&(mI&&console.warn("AnimatorController default state is undefined: ",this.model,"Layer: "+e),A=0)),A=this.model.layers[e].stateMachine.states[A]),A}transitionTo(A,e,t){var C,a,B,Q,E,c,d,l;if(!this.animator)return;const i=0;if(A=this.getState(A,i),!(A!=null&&A.motion)||!A.motion.clip||!(A.motion.clip instanceof _I))return;const I=this._activeState===A;if(I){const h=A.motion;if(!h.action_loopback&&h.clip){const p=this.rootMotionHandler?this.animator.gameObject.matrix.clone():null;this._mixer.uncacheAction(h.clip,this.animator.gameObject),p&&p.decompose(this.animator.gameObject.position,this.animator.gameObject.quaternion,this.animator.gameObject.scale),h.action_loopback=this.createAction(h.clip)}}if((C=this._activeState)!=null&&C.behaviours&&this._activeState.motion.action){const h=(a=this._activeState)==null?void 0:a.motion.clip.duration,p=this._activeState.motion.action.time/h,u=new Bh(this._activeState,p,h,this._speed);for(const f of this._activeState.behaviours)(Q=(B=f.instance)==null?void 0:B.onStateExit)==null||Q.call(f.instance,this.animator,u,i)}const o=(E=this._activeState)==null?void 0:E.motion.action;o&&o.fadeOut(e),I&&(A.motion.action=A.motion.action_loopback,A.motion.action_loopback=o);const s=this._activeState;this._activeState=A;const n=(c=A.motion)==null?void 0:c.action;if(n){if(t=Math.max(0,Math.min(1,t)),A.cycleOffsetParameter){let p=this.getFloat(A.cycleOffsetParameter);typeof p=="number"?(p<0&&(p+=1),t+=p,t%=1):mI&&console.warn("AnimatorController cycle offset parameter is not a number",A.cycleOffsetParameter)}else typeof A.cycleOffset=="number"&&(t+=A.cycleOffset,t%=1);n.isRunning()&&n.stop(),n.reset(),n.enabled=!0;const h=A.motion.clip.duration;if(n.time=I?0:t*h,n.timeScale<0&&(n.time=h-n.time),n.clampWhenFinished=!0,n.setLoop(gd,0),e>0?n.fadeIn(e):n.weight=1,n.play(),this.rootMotionHandler&&this.rootMotionHandler.onStart(n),this._activeStates.includes(A)||this._activeStates.push(A),this._activeState.behaviours){const p=new Bh(A,t,h,this._speed);for(const u of this._activeState.behaviours)(l=(d=u.instance)==null?void 0:d.onStateEnter)==null||l.call(u.instance,this.animator,p,i)}}else mI&&(A.__warned_no_motion||(A.__warned_no_motion=!0,console.warn("No action",A.motion,this)));mI&&console.log("TRANSITION FROM "+(s==null?void 0:s.name)+" TO "+A.name,e,o,n,n==null?void 0:n.getEffectiveTimeScale(),n==null?void 0:n.getEffectiveWeight(),n==null?void 0:n.isRunning(),n==null?void 0:n.isScheduled(),n==null?void 0:n.paused)}createAction(A){var t,i;if(this._mixer.existingAction(A)&&this._mixer.uncacheAction(A,(t=this.animator)==null?void 0:t.gameObject),(i=this.animator)!=null&&i.applyRootMotion){this.rootMotionHandler||(this.rootMotionHandler=new JgA(this));const I=this.animator.gameObject;return this.rootMotionHandler.createClip(this._mixer,I,A)}else return this._mixer.clipAction(A)}evaluateCondition(A){const e=this.model.parameters.find(t=>t.name===A.parameter);if(!e)return!1;switch(A.mode){case Na.If:return e.value===!0;case Na.IfNot:return e.value===!1;case Na.Greater:return e.value>A.threshold;case Na.Less:return e.value<A.threshold;case Na.Equals:return e.value===A.threshold;case Na.NotEqual:return e.value!==A.threshold}return!1}createActions(A){var e,t,i,I;mI&&console.log("AnimatorController createActions",this.model);for(const o of this.model.layers){const s=o.stateMachine;for(let n=0;n<s.states.length;n++){const C=s.states[n];C.transitions||(C.transitions=[]);for(const a of C.transitions)a.conditions||(a.conditions=[]);if(C.motion||(C.motion=OO(C.name)),this.animator&&C.motion.clips){const a=(e=C.motion.clips)==null?void 0:e.find(B=>{var Q,E;return B.node.name===((E=(Q=this.animator)==null?void 0:Q.gameObject)==null?void 0:E.name)});a?C.motion.clip=a.clip:(mI||he())&&console.warn('Could not find clip for animator "'+((i=(t=this.animator)==null?void 0:t.gameObject)==null?void 0:i.name)+'"',C.motion.clips.map(B=>B.node.name))}if(!C.motion.clip){const a=new _I(void 0,void 0,[]);C.motion.clip=a}if((I=C.motion)!=null&&I.clip){const a=C.motion.clip;if(a instanceof _I){const B=this.createAction(a);C.motion.action=B}else(mI||he())&&console.warn("No valid animationclip assigned",C)}if(C.behaviours&&Array.isArray(C.behaviours))for(const a of C.behaviours){if(!(a!=null&&a.typeName))continue;const B=z.get(a.typeName),Q=new B;Q.isStateMachineBehaviour&&(Q._context=this.context??void 0,nc(Q,a.properties),a.instance=Q),mI&&console.log("Created animator controller behaviour",C.name,a.typeName,a.properties,Q)}}}}*enumerateActions(){if(this.model.layers)for(const A of this.model.layers){const e=A.stateMachine;for(let t=0;t<e.states.length;t++){const i=e.states[t];i!=null&&i.motion&&(i.motion.action&&(yield i.motion.action),i.motion.action_loopback&&(yield i.motion.action_loopback))}}}}class _q{constructor(A,e){r(this,"track");r(this,"createdInterpolant");r(this,"originalEvaluate");r(this,"customEvaluate");this.track=A;const t=A,i=t.createInterpolant.bind(A);t.createInterpolant=()=>(t.createInterpolant=i,this.createdInterpolant=i(),this.originalEvaluate=this.createdInterpolant.evaluate.bind(this.createdInterpolant),this.customEvaluate=I=>{if(!this.originalEvaluate)return;const o=this.originalEvaluate(I);return e(I,o)},this.createdInterpolant.evaluate=this.customEvaluate,this.createdInterpolant)}dispose(){this.createdInterpolant&&this.originalEvaluate&&(this.createdInterpolant.evaluate=this.originalEvaluate),this.track=void 0,this.createdInterpolant=null,this.originalEvaluate=void 0,this.customEvaluate=void 0}}const og=class{constructor(A,e,t,i,I){r(this,"_action");r(this,"root");r(this,"clip");r(this,"positionWrapper",null);r(this,"rotationWrapper",null);r(this,"context");r(this,"positionChange",new w);r(this,"rotationChange",new MA);r(this,"_prevTime",0);if(this.context=A,this.root=e,this.clip=t,og.firstKeyframeRotation[this.cacheId]||(og.firstKeyframeRotation[this.cacheId]=new MA),I){const o=I.values;og.firstKeyframeRotation[this.cacheId].set(o[0],o[1],o[2],o[3])}og.spaceRotation[this.cacheId]||(og.spaceRotation[this.cacheId]=new MA),og.effectiveSpaceRotation[this.cacheId]||(og.effectiveSpaceRotation[this.cacheId]=new MA),og.clipOffsetRotation[this.cacheId]=new MA,I&&og.clipOffsetRotation[this.cacheId].set(I.values[0],I.values[1],I.values[2],I.values[3]).invert(),this.handlePosition(t,i),this.handleRotation(t,I)}set action(A){this._action=A}get action(){return this._action}get cacheId(){return this.root.uuid}onStart(A){if(A.getClip()!==this.clip)return;og.lastObjRotation[this.cacheId]||(og.lastObjRotation[this.cacheId]=this.root.quaternion.clone());const e=og.lastObjRotation[this.cacheId];if(og.spaceRotation[this.cacheId].copy(e),qf){const t=new $t().setFromQuaternion(e);console.log("START",this.clip.name,te.toDegrees(t.y),this.root.position.z)}}getClipRotationOffset(){return og.clipOffsetRotation[this.cacheId]}handlePosition(A,e){if(e){const t=this.root;qf&&t.add(new as),og.lastObjPosition[this.cacheId]||(og.lastObjPosition[this.cacheId]=this.root.position.clone());const i=new w,I=new w;this.positionWrapper=new _q(e,(o,s)=>{const n=this.action.getEffectiveWeight();return qf&&t.position.length()>8&&t.position.set(0,t.position.y,0),o>this._prevTime&&(i.set(s[0],s[1],s[2]),i.sub(I),i.multiplyScalar(n),i.applyQuaternion(this.getClipRotationOffset()),i.applyQuaternion(t.quaternion),this.positionChange.copy(i)),I.fromArray(s),this._prevTime=o,s[0]=0,s[1]=0,s[2]=0,s})}}handleRotation(A,e){if(e){if(qf){const o=e.values,s=new $t().setFromQuaternion(new MA(o[0],o[1],o[2],o[3]));console.log(A.name,e.name,"FIRST ROTATION IN TRACK",te.toDegrees(s.y));const n=e.values.length-4,C=new MA().set(o[n],o[n+1],o[n+2],o[n+3]),a=new $t().setFromQuaternion(C);console.log(A.name,e.name,"LAST ROTATION IN TRACK",te.toDegrees(a.y))}let t=0;const i=new MA,I=new MA;this.rotationWrapper=new _q(e,(o,s)=>(o>t&&(I.set(s[0],s[1],s[2],s[3]),i.invert(),I.multiply(i),this.rotationChange.copy(I)),i.fromArray(s),t=o,s[0]=0,s[1]=0,s[2]=0,s[3]=1,s))}}onBeforeUpdate(A){this.positionChange.set(0,0,0),this.rotationChange.set(0,0,0,1)}onAfterUpdate(A){return!this.action||(A*=this.action.getEffectiveWeight(),A<=0)?!1:(this.positionChange.multiplyScalar(A),this.rotationChange.slerp(og.identityQuaternion,1-A),!0)}};let Cn=og;r(Cn,"lastObjPosition",{}),r(Cn,"lastObjRotation",{}),r(Cn,"firstKeyframeRotation",{}),r(Cn,"spaceRotation",{}),r(Cn,"effectiveSpaceRotation",{}),r(Cn,"clipOffsetRotation",{}),r(Cn,"identityQuaternion",new MA);class JgA{constructor(A){r(this,"controller");r(this,"handler",[]);r(this,"root");r(this,"basePosition",new w);r(this,"baseQuaternion",new MA);r(this,"baseRotation",new $t);r(this,"summedPosition",new w);r(this,"summedRotation",new MA);this.controller=A}createClip(A,e,t){this.root=e,e&&"name"in e&&e.name;const i=this.findRootTrack(t,".position"),I=this.findRootTrack(t,".quaternion"),o=new Cn(this.controller.context,e,t,i,I);this.handler.push(o);const s=A.clipAction(t);return o.action=s,s}onStart(A){for(const e of this.handler)e.onStart(A)}onBeforeUpdate(A){this.basePosition.copy(this.root.position),this.baseQuaternion.copy(this.root.quaternion);for(const e of this.handler)e.onBeforeUpdate(A)}onAfterUpdate(A){if(!(A<=0)){this.root.position.copy(this.basePosition),this.root.quaternion.copy(this.baseQuaternion),this.summedPosition.set(0,0,0),this.summedRotation.set(0,0,0,1);for(const e of this.handler)e.onAfterUpdate(A)&&(this.summedPosition.add(e.positionChange),this.summedRotation.multiply(e.rotationChange));this.root.position.add(this.summedPosition),this.root.quaternion.multiply(this.summedRotation)}}findRootTrack(A,e){const t=A.tracks;if(!t)return null;for(const i of t)if(i.name.endsWith(e))return i;return null}}class bgA extends _n{onSerialize(A,e){}onDeserialize(A,e){if(e.type===Ro&&(A==null?void 0:A.__type)==="AnimatorController")return new Ro(A)}}new bgA(Ro);var vgA=Object.defineProperty,qgA=Object.getOwnPropertyDescriptor,mS=(g,A,e,t)=>{for(var i=t>1?void 0:t?qgA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&vgA(A,e,i),i};const Wo=IA("debuganimator");class Zg extends RA{constructor(){super(...arguments);r(this,"applyRootMotion",!1);r(this,"hasRootMotion",!1);r(this,"keepAnimatorControllerStateOnDisable",!1);r(this,"_parametersAreDirty",!1);r(this,"_isDirty",!1);r(this,"_speed",1);r(this,"_normalizedStartOffset",0);r(this,"_animatorController",null);r(this,"_initializeWithRuntimeAnimatorController")}set runtimeAnimatorController(e){var t;this._animatorController&&this._animatorController.model===e||(e?e instanceof Ro?(e.animator&&e.animator!==this&&(console.warn("AnimatorController can not be bound to multiple animators",(t=e.model)==null?void 0:t.name),e.model||console.error("AnimatorController has no model"),e=new Ro(e.model)),this._animatorController=e,this._animatorController.bind(this)):(Wo&&console.log("Assign animator controller",e,this),this._animatorController=new Ro(e),this.__didAwake&&this._animatorController.bind(this)):this._animatorController=null)}get runtimeAnimatorController(){return this._animatorController}getCurrentStateInfo(){var e;return(e=this.runtimeAnimatorController)==null?void 0:e.getCurrentStateInfo()}get currentAction(){var e;return((e=this.runtimeAnimatorController)==null?void 0:e.currentAction)||null}get parametersAreDirty(){return this._parametersAreDirty}get isDirty(){return this._isDirty}Play(e,t=-1,i=Number.NEGATIVE_INFINITY,I=0){this.play(e,t,i,I)}play(e,t=-1,i=Number.NEGATIVE_INFINITY,I=0){var o;(o=this.runtimeAnimatorController)==null||o.play(e,t,i,I),this._isDirty=!0}Reset(){this.reset()}reset(){var e;(e=this._animatorController)==null||e.reset(),this._isDirty=!0}SetBool(e,t){this.setBool(e,t)}setBool(e,t){var i,I;Wo&&console.log("setBool",e,t),((i=this.runtimeAnimatorController)==null?void 0:i.getBool(e))!==t&&(this._parametersAreDirty=!0),(I=this.runtimeAnimatorController)==null||I.setBool(e,t)}GetBool(e){return this.getBool(e)}getBool(e){var i;const t=((i=this.runtimeAnimatorController)==null?void 0:i.getBool(e))??!1;return Wo&&console.log("getBool",e,t),t}toggleBool(e){this.setBool(e,!this.getBool(e))}SetFloat(e,t){this.setFloat(e,t)}setFloat(e,t){var i,I;((i=this.runtimeAnimatorController)==null?void 0:i.getFloat(e))!==t&&(this._parametersAreDirty=!0),Wo&&console.log("setFloat",e,t),(I=this.runtimeAnimatorController)==null||I.setFloat(e,t)}GetFloat(e){return this.getFloat(e)}getFloat(e){var i;const t=((i=this.runtimeAnimatorController)==null?void 0:i.getFloat(e))??-1;return Wo&&console.log("getFloat",e,t),t}SetInteger(e,t){this.setInteger(e,t)}setInteger(e,t){var i,I;((i=this.runtimeAnimatorController)==null?void 0:i.getInteger(e))!==t&&(this._parametersAreDirty=!0),Wo&&console.log("setInteger",e,t),(I=this.runtimeAnimatorController)==null||I.setInteger(e,t)}GetInteger(e){return this.getInteger(e)}getInteger(e){var i;const t=((i=this.runtimeAnimatorController)==null?void 0:i.getInteger(e))??-1;return Wo&&console.log("getInteger",e,t),t}SetTrigger(e){this.setTrigger(e)}setTrigger(e){var t;this._parametersAreDirty=!0,Wo&&console.log("setTrigger",e),(t=this.runtimeAnimatorController)==null||t.setTrigger(e)}ResetTrigger(e){this.resetTrigger(e)}resetTrigger(e){var t;this._parametersAreDirty=!0,Wo&&console.log("resetTrigger",e),(t=this.runtimeAnimatorController)==null||t.resetTrigger(e)}GetTrigger(e){this.getTrigger(e)}getTrigger(e){var i;const t=(i=this.runtimeAnimatorController)==null?void 0:i.getTrigger(e);return Wo&&console.log("getTrigger",e,t),t}IsInTransition(){return this.isInTransition()}isInTransition(){var e;return((e=this.runtimeAnimatorController)==null?void 0:e.isInTransition())??!1}SetSpeed(e){return this.setSpeed(e)}setSpeed(e){var t;e!==this._speed&&(Wo&&console.log("setSpeed",e),this._speed=e,((t=this._animatorController)==null?void 0:t.animator)==this&&this._animatorController.setSpeed(e))}set minMaxSpeed(e){var t;this._speed=te.lerp(e.x,e.y,Math.random()),((t=this._animatorController)==null?void 0:t.animator)==this&&this._animatorController.setSpeed(this._speed)}set minMaxOffsetNormalized(e){var t;this._normalizedStartOffset=te.lerp(e.x,e.y,Math.random()),((t=this.runtimeAnimatorController)==null?void 0:t.animator)==this&&(this.runtimeAnimatorController.normalizedStartOffset=this._normalizedStartOffset)}awake(){Wo&&console.log("ANIMATOR",this.name,this),this.gameObject&&this.initializeRuntimeAnimatorController()}initializeRuntimeAnimatorController(e=!1){const t=e||this.runtimeAnimatorController!==this._initializeWithRuntimeAnimatorController;if(this.runtimeAnimatorController&&t){const i=this.runtimeAnimatorController.clone();this._initializeWithRuntimeAnimatorController=i,i?(console.assert(this.runtimeAnimatorController!==i),this.runtimeAnimatorController=i,console.assert(this.runtimeAnimatorController===i),this.runtimeAnimatorController.bind(this),this.runtimeAnimatorController.setSpeed(this._speed),this.runtimeAnimatorController.normalizedStartOffset=this._normalizedStartOffset):console.warn("Could not clone animator controller",this.runtimeAnimatorController)}}onDisable(){var e;this.keepAnimatorControllerStateOnDisable||(e=this._animatorController)==null||e.reset()}onBeforeRender(){this._isDirty=!1,this._parametersAreDirty=!1,!NgA(this.gameObject)&&this._animatorController&&this._animatorController.update(1)}}mS([D()],Zg.prototype,"applyRootMotion",2);mS([D()],Zg.prototype,"hasRootMotion",2);mS([D()],Zg.prototype,"keepAnimatorControllerStateOnDisable",2);mS([D()],Zg.prototype,"runtimeAnimatorController",1);const hn=IA("debugusdzanimation"),zM=IA("debugusdzanimationserialization");class GS{constructor(A,e,t){r(this,"_start");r(this,"ext");r(this,"root");r(this,"clip");this.ext=A,this.root=e,this.clip=t}get start(){return this._start===void 0&&(this._start=this.ext.getStartTime01(this.root,this.clip)),this._start}get duration(){var A;return((A=this.clip)==null?void 0:A.duration)??Vi.restPoseClipDuration}}const vK=class{constructor(A,e,t){r(this,"clip");r(this,"pos");r(this,"rot");r(this,"scale");r(this,"root");r(this,"target");r(this,"duration",0);r(this,"useRootMotion",!1);this.root=A,this.target=e,this.clip=t,t?this.duration=t.duration:this.duration=vK.restPoseClipDuration;const i=aA.getComponent(A,Zg);i&&(this.useRootMotion=i.applyRootMotion)}get frameRate(){return 60}addTrack(A){if(!this.clip){console.error("This is a rest clip but you're trying to add tracks to it – this is likely a bug");return}A.name.endsWith("position")&&(this.pos=A),A.name.endsWith("quaternion")&&(this.rot=A),A.name.endsWith("scale")&&(this.scale=A)}getFrames(){var A,e,t,i,I,o;return this.clip?Math.max(((e=(A=this.pos)==null?void 0:A.times)==null?void 0:e.length)??0,((i=(t=this.rot)==null?void 0:t.times)==null?void 0:i.length)??0,((o=(I=this.scale)==null?void 0:I.times)==null?void 0:o.length)??0):2}getDuration(){return this.duration}getSortedTimesArray(A=!0,e=!0,t=!0){var n,C,a;if(!this.clip)return[0,this.duration];const i=(n=this.pos)==null?void 0:n.times,I=(C=this.rot)==null?void 0:C.times,o=(a=this.scale)==null?void 0:a.times,s=[];if(A&&i)for(const B of i)s.push(B);if(e&&I)for(const B of I)s.push(B);if(t&&o)for(const B of o)s.push(B);return s.includes(0)||s.push(0),s.sort((B,Q)=>B-Q),[...new Set(s)]}*getValues(A,e=!0,t=!0,i=!0){var Q,E,c;const I=new w,o=new MA,s=new w(1,1,1),n=this.target,C=e?(Q=this.pos)==null?void 0:Q.createInterpolant():void 0,a=t?(E=this.rot)==null?void 0:E.createInterpolant():void 0,B=i?(c=this.scale)==null?void 0:c.createInterpolant():void 0;C||I.set(n.position.x,n.position.y,n.position.z),a||o.set(n.quaternion.x,n.quaternion.y,n.quaternion.z,n.quaternion.w),B||s.set(n.scale.x,n.scale.y,n.scale.z);for(let d=0;d<A.length;d++){const l=A[d];if(C){const h=C.evaluate(l);I.set(h[0],h[1],h[2])}if(a){const h=a.evaluate(l);o.set(h[0],h[1],h[2],h[3])}if(B){const h=B.evaluate(l);s.set(h[0],h[1],h[2])}if(this.useRootMotion&&n===this.root){const h=new GA;h.compose(I,o,s),h.multiply(n.matrix),h.decompose(I,o,s)}yield{time:l,translation:I,rotation:o,scale:s,index:d}}}};let Vi=vK;r(Vi,"animationDurationPadding",1/60),r(Vi,"restPoseClipDuration",1/60);class Ku{constructor(A){r(this,"dict",new Map);r(this,"rootTargetMap",new Map);r(this,"rootAndClipToRegisteredAnimationMap",new Map);r(this,"rootToRegisteredClip",new Map);r(this,"serializers",[]);r(this,"injectRestPoses",!1);r(this,"injectImplicitBehaviours",!1);this.injectRestPoses=A,this.injectImplicitBehaviours=A}get extensionName(){return"animation"}getStartTimeCode(){return!this.injectRestPoses||this.rootAndClipToRegisteredAnimationMap.size===0?0:(Vi.restPoseClipDuration+Vi.animationDurationPadding)*60}getEndTimeCode(){let A=0;for(const[e,t]of this.rootAndClipToRegisteredAnimationMap){const i=t.start+t.duration;i>A&&(A=i)}return A*60}getClipCount(A){var t;let e=((t=this.rootToRegisteredClip.get(A))==null?void 0:t.length)??0;return this.injectRestPoses&&(e=e?e-1:0),e??0}getStartTime01(A,e){if(!e)return 0;const t=this.rootTargetMap.get(A);if(!t)return 0;const i=this.dict.get(t[0]);if(!i)return console.error("Trying to get start time for root that has no animation data",A,e,...this.dict),0;let I=0;for(let o=0;o<i.length&&i[o].clip!==e;o++)I+=i[o].getDuration()+Vi.animationDurationPadding;return I}registerAnimation(A,e){var C;if(!A)return null;this.rootTargetMap.has(A)||this.rootTargetMap.set(A,[]);const t=A.uuid+((e==null?void 0:e.uuid)??"-rest");if(this.rootAndClipToRegisteredAnimationMap.has(t))return this.rootAndClipToRegisteredAnimationMap.get(t);hn&&console.log("registerAnimation",A,e);const i=this.injectRestPoses?1:0,I=(((C=this.rootToRegisteredClip.get(A))==null?void 0:C.length)??0)+i,o=this.rootTargetMap.get(A),s=new Set(o);if(e&&e.tracks)for(const a of e.tracks){const B=Ve.parseTrackName(a.name),Q=Ve.findNode(A,B.nodeName);if(!Q){console.warn("no object found for track",a.name,"using "+A.name+" instead");continue}this.dict.has(Q)||this.dict.set(Q,[]);const E=this.dict.get(Q);if(!E){console.warn("no transform data found for target ",Q,"at slot "+I+", this is likely a bug");continue}s.delete(Q),this.injectRestPoses&&!E[0]&&(E[0]=new Vi(null,Q,null));let c=E[I];c||(c=new Vi(A,Q,e),E[I]=c),c.addTrack(a),o!=null&&o.includes(Q)||o==null||o.push(Q)}hn&&console.log("Unregistered nodes for this clip",s,"clip",e,"at slot",I,"for root",A,"targets",o);for(const a of s){const B=this.dict.get(a);if(!B)continue;if(this.injectRestPoses&&!B[0]){console.warn("Adding rest pose for ",a,e,"at slot",I,"This is likely a bug, should have been added earlier.");const E=new Vi(null,a,null);B[0]=E}let Q=B[I];Q||(hn&&console.log("Adding padding clip for ",a,e,"at slot",I),Q=new Vi(A,a,e),B[I]=Q)}const n=new GS(this,A,e);if(this.rootAndClipToRegisteredAnimationMap.set(t,n),hn&&console.log({root:A,clip:e,info:n}),e){const a=this.rootToRegisteredClip.get(A);a?a.push(e):this.rootToRegisteredClip.set(A,[e])}return n}onAfterHierarchy(A){hn&&console.log("Animation clips per animation target node",this.dict)}onAfterBuildDocument(A){var e,t;hn&&console.log("Animation data",{dict:this.dict,rootTargetMap:this.rootTargetMap,rootToRegisteredClip:this.rootToRegisteredClip});for(const i of this.rootTargetMap.keys()){const I=this.rootTargetMap.get(i);if(!I)continue;let o;const s=[];for(const n of I){const C=this.dict.get(n);if(!C){console.error("No data found for target on USDZ export – please report a bug!",n);continue}o===void 0&&(o=C==null?void 0:C.length),o!==(C==null?void 0:C.length)&&console.error("Different array lengths for targets – please report a bug!",C);for(let a=0;a<C.length;a++){let B=C[a];if(!B){const Q=a-(this.injectRestPoses?1:0);C[a]=new Vi(null,n,this.rootToRegisteredClip.get(i)[Q]),B=C[a]}if(!s[a])s[a]=B.getDuration();else if(s[a]!==B.getDuration()){console.error("Different durations for targets – please report a bug!",C);continue}}}}for(const i of this.serializers){const I=(e=i.model)==null?void 0:e.parent,o=(I==null?void 0:I.isDynamic)===!0;zM&&console.log(o,(t=i.model)==null?void 0:t.parent),o&&i.registerCallback(I)}}onExportObject(A,e,t){aA.foreachComponent(A,I=>{const o=I;typeof o.createAnimation=="function"&&o.createAnimation(this,e,t)},!1);const i=new xgA(A,this.dict);this.serializers.push(i),i.registerCallback(e)}}class xgA{constructor(A,e){r(this,"object");r(this,"dict");r(this,"model");r(this,"callback");this.object=A,this.dict=e}registerCallback(A){this.model&&this.callback&&this.model.removeEventListener("serialize",this.callback),this.callback||(this.callback=this.onSerialize.bind(this)),zM&&console.log("REPARENT",A),this.model=A,this.model.addEventListener("serialize",this.callback)}skinnedMeshExport(A,e){var I;const t=this.model,i=this.dict;if(t&&t.skinnedMesh){let o=function(m){const N=[];for(const[y,U]of m){let H=`${y} : [`;const x=[];for(const K of U)x.push(`(${Dg(K.x)}, ${Dg(K.y)}, ${Dg(K.z)})`);H=H.concat(x.join(", ")),H=H.concat("],"),N.push(H)}return N},s=function(m){const N=[];for(const[y,U]of m){let H=`${y} : [`;const x=[];for(const K of U)x.push(`(${Dg(K.w)}, ${Dg(K.x)}, ${Dg(K.y)}, ${Dg(K.z)})`);H=H.concat(x.join(", ")),H=H.concat("],"),N.push(H)}return N},n=function(m){let N,y=!0;const U=new Map;for(const[x,K]of m){N===void 0&&(N=K.length),N!==K.length&&(y=!1);let O=0;for(const b of K)O++,b||(U.has(x)||U.set(x,[]),U.get(x).push(O))}hn&&console.log("Bone count: ",m.size,"TransformData entries per bone: ",N,"Undefined bone entries: ",U),console.assert(y,"All bones should have the same number of TransformData entries",m),console.assert(U.size===0,"All TransformData entries should be set",U);const H=[];for(const[x,K]of m){const O=new Array;let b=0;for(let v=0;v<K.length;v++)O.push(b),b+=K[v].getDuration()+Vi.animationDurationPadding;for(let v=0;v<K.length;v++){const T=K[v],V=O[v];H.length<=v&&H.push({pos:[],rot:[],scale:[],timeOffset:V});const X=H[v];X.pos.push(...T.getSortedTimesArray(!0,!1,!1)),X.rot.push(...T.getSortedTimesArray(!1,!0,!1)),X.scale.push(...T.getSortedTimesArray(!1,!1,!0))}}for(const x of H)x.pos.sort((K,O)=>K-O),x.rot.sort((K,O)=>K-O),x.scale.sort((K,O)=>K-O),x.pos=[...new Set(x.pos)],x.rot=[...new Set(x.rot)],x.scale=[...new Set(x.scale)];return H},C=function(m,N,y){const U=new Map,H=new Map,x=new Map,K=N.length;for(const O of y){const b=m.get(O);let v;b?console.assert(b.length===K,"We should have the same number of TransformData entries for each bone",b,N):v=new Vi(null,O,null);for(let T=0;T<K;T++){const V=b?b[T]:v,X=N[T];for(const{time:CA,translation:QA}of V.getValues(X.pos,!0,!1,!1)){const gA=(CA+X.timeOffset)*60;U.has(gA)||U.set(gA,new Array),U.get(gA).push(QA.clone())}for(const{time:CA,rotation:QA}of V.getValues(X.rot,!1,!0,!1)){const gA=(CA+X.timeOffset)*60;H.has(gA)||H.set(gA,new Array),H.get(gA).push(QA.clone())}for(const{time:CA,scale:QA}of V.getValues(X.scale,!1,!1,!0)){const gA=(CA+X.timeOffset)*60;x.has(gA)||x.set(gA,new Array),x.get(gA).push(QA.clone())}}}return{position:U.size==0?void 0:U,quaternion:H.size==0?void 0:H,scale:x.size==0?void 0:x}},a=function(m){const N=[];for(const y of m)N.push(`(${Dg(y.x)}, ${Dg(y.y)}, ${Dg(y.z)})`);return N.join(", ")},B=function(m){const N=[];for(const y of m)N.push(`(${Dg(y.w)}, ${Dg(y.x)}, ${Dg(y.y)}, ${Dg(y.z)})`);return N.join(", ")},Q=function(m){const N=new Map;if(hn){const y=new Array;for(const[U,H]of i)y.push(U.uuid+": "+H.length+" "+H.map(x=>{var K;return(K=x.clip)==null?void 0:K.uuid.substring(0,6)}).join(" "));console.log(`getPerBoneTransformData
|
|
5507
5507
|
`+y.join(`
|
|
5508
|
-
`))}for(const y of m){const U=i.get(y);U&&N.set(y,U)}return N},E=function(m){const N=Q(m),y=n(N);return C(N,y,m)};const c=t.skinnedMesh.skeleton,d=new Array;for(const m in c.bones){const N=c.bones[m],y=c.boneInverses[m];d.push({bone:N,inverse:y})}for(const m of $H(c.bones))d.push({bone:m,inverse:m.matrixWorld.clone().invert()});const l=d[0].bone.parent;l||console.error("No bone parent found for skinned mesh during USDZ export",t.skinnedMesh),d.sort((m,N)=>_E(m.bone,l)>_E(N.bone,l)?1:-1);const h=[],p=[],u=[],f=[];for(const{bone:m}of d)h.push(m.matrix.clone()),p.push(m.position),u.push(m.quaternion),f.push(m.scale);const k=d.map(m=>'"'+_E(m.bone,l)+'"').join(", "),G=d.map(m=>GE(m.inverse.clone().invert())).join(", ");A.beginBlock('def Skeleton "Rig"'),A.appendLine(`uniform matrix4d[] bindTransforms = [${G}]`),A.appendLine(`uniform token[] joints = [${k}]`),A.appendLine('uniform token purpose = "guide"'),A.appendLine(`uniform matrix4d[] restTransforms = [${h.map(m=>GE(m)).join(", ")}]`),A.appendLine(`matrix4d xformOp:transform = ${GE(new GA)}`),A.appendLine('uniform token[] xformOpOrder = ["xformOp:transform"]');const M=E(d.map(m=>m.bone));if(hn){let m=1e7,N=0;for(const y of((I=M.position)==null?void 0:I.keys())??[])m=Math.min(m,y),N=Math.max(N,y);console.log("Time samples",m,N,M)}if(A.beginBlock('def SkelAnimation "_anim"'),A.appendLine(`uniform token[] joints = [${k}]`),A.appendLine(`quatf[] rotations = [${B(u)}]`),M&&M.quaternion){A.beginBlock("quatf[] rotations.timeSamples = {","");const m=s(M.quaternion);for(const N of m)A.appendLine(N);A.closeBlock()}if(A.appendLine(`half3[] scales = [${a(f)}]`),M&&M.scale){A.beginBlock("half3[] scales.timeSamples = {","");const m=o(M.scale);for(const N of m)A.appendLine(N);A.closeBlock()}if(A.appendLine(`float3[] translations = [${a(p)}]`),M&&M.position){A.beginBlock("float3[] translations.timeSamples = {","");const m=o(M.position);for(const N of m)A.appendLine(N);A.closeBlock()}A.closeBlock(),A.closeBlock()}}onSerialize(A,e){var a;if(!this.model)return;const t=this.dict.get(this.object);if(t)for(let B=0;B<t.length;B++)t[B]===void 0&&(t[B]=new Vi(null,this.object,null));this.skinnedMeshExport(A,e);const i=this.object,I=this.dict.get(i);if(!I||i.isSkinnedMesh)return;zM&&console.log("SERIALIZE",this.model.name,this.object.type,I);const o=new GA;A.appendLine("matrix4d xformOp:transform.timeSamples = {"),A.indent++;const s=new Array;let n=0;for(let B=0;B<I.length;B++){if(s.push(n),I[B]===void 0){console.error("Got an undefined transform data, this is likely a bug.",i,I);continue}n+=I[B].getDuration()+Vi.animationDurationPadding}const C=Intl.NumberFormat("en",{maximumFractionDigits:2,minimumFractionDigits:0});for(let B=0;B<I.length;B++){const Q=I[B];if(!Q)continue;const E=s[B];{const c=Q.getSortedTimesArray();if(!c||c.length===0){console.error("got an animated object but no time values?",i,Q);continue}{const d=((a=Q.clip)==null?void 0:a.name)??"rest",l=Q.getDuration();hn&&console.log("Write .timeSamples:",d,E,l,I),A.appendLine("# "+d+": start="+C.format(E*Q.frameRate)+", length="+C.format(l*Q.frameRate)+", frames="+Q.getFrames())}for(const{time:d,translation:l,rotation:h,scale:p}of Q.getValues(c)){o.compose(l,h,p);const f=`${C.format((E+d)*Q.frameRate)}: ${GE(o)},`;A.appendLine(f)}}}A.indent--,A.appendLine("}")}}var LgA=Object.defineProperty,_gA=Object.getOwnPropertyDescriptor,PO=(g,A,e,t)=>{for(var i=t>1?void 0:t?_gA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&LgA(A,e,i),i};const Tq=IA("debugpost");class qe{constructor(A){r(this,"_active",!0);r(this,"_value");r(this,"_valueRaw");r(this,"_defaultValue");r(this,"valueProcessor");r(this,"onValueChanged");this._value=A,this._defaultValue=A,this._valueRaw=A}get overrideState(){return this._active}set overrideState(A){if(this._active===A)return;this._active=A;const e=A?this._valueRaw:this._defaultValue;this.processValue(e,!0)}get value(){return this._valueRaw}set value(A){this.processValue(A,!1)}set defaultValue(A){this._defaultValue=A}__init(){this.processValue(this._valueRaw,!0)}processValue(A,e){if(A==null||!e&&this.testIfValueChanged(A)===!1)return;const t=this._value;if(Tq){let i=!0;if(typeof t=="number"&&typeof A=="number"){const I=t==null?void 0:t.toFixed(4),o=A==null?void 0:A.toFixed(4);I!=o?i=!0:i=!1}i&&console.log("VolumeParameter: value changed from",t,"to",A)}!this._active&&this._defaultValue!==void 0?(this._value=this._defaultValue,A=this._defaultValue,this._valueRaw=A):(this._valueRaw=A,this._active&&this.valueProcessor&&(A=this.valueProcessor(A)),this._value=A),this.onValueChanged?this.onValueChanged(A,t,this):Tq&&console.log("VolumeParameter: onValueChanged not set")}testIfValueChanged(A){return this._valueRaw!==A}}PO([D()],qe.prototype,"overrideState",1);PO([D()],qe.prototype,"value",1);var TgA=Object.defineProperty,HgA=Object.getOwnPropertyDescriptor,YgA=(g,A,e,t)=>{for(var i=t>1?void 0:t?HgA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&TgA(A,e,i),i};const OgA=IA("debugpost");class hI extends RA{constructor(e=void 0){super();r(this,"active",!0);r(this,"_result");r(this,"_didCreateVolumeParameters",!1);if(e){this.ensureVolumeParameters();for(const t of Object.keys(e)){const i=e[t],I=this[t];I instanceof qe&&(I.value=i)}}}onEnable(){this.__internalDidAwakeAndStart&&(this.active=!0)}onDisable(){this.active=!1}init(){}apply(){var e;return this.ensureVolumeParameters(),this._result||(this._result=(e=this.onCreateEffect)==null?void 0:e.call(this)),this._result&&this.initParameters(),this._result}unapply(){}dispose(){OgA&&console.warn("DISPOSE",this),this._result&&(Array.isArray(this._result)?this._result.forEach(e=>e.dispose()):this._result.dispose()),this._result=void 0}initParameters(){const e=Object.keys(this);for(const t of e){const i=this[t];i instanceof qe&&i.__init()}}onAfterDeserialize(e,t){if(typeof e=="object"){const i=this.$serializedTypes;if(i){for(const I of Object.keys(i))if(i[I]===qe){const s=e[I];if(s!==void 0){const n=this[I];n.value=s}}}}}onEditorModification(e){const t=e.propertyName;if(this[t]instanceof qe){const i=e.value;return this[t].value=i,!0}}ensureVolumeParameters(){if(this._didCreateVolumeParameters)return;this._didCreateVolumeParameters=!0;const e=this.$serializedTypes;if(e)for(const t of Object.keys(e))e[t]===qe&&(this[t]||(this[t]=new qe))}}YgA([D()],hI.prototype,"active",2);var PgA=Object.defineProperty,WgA=Object.getOwnPropertyDescriptor,ZgA=(g,A,e,t)=>{for(var i=t>1?void 0:t?WgA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&PgA(A,e,i),i};const jgA=IA("debugpost"),XM={};function us(g,A){XM[g]=A}function VgA(g){return g.__type in XM?XM[g.__type]:(jgA&&g.__type&&console.warn("Unknown postprocessing type",g.__type,g),hI)}class Ju{constructor(){r(this,"components",[])}init(){var A;(A=this.components)==null||A.forEach(e=>e.init())}}ZgA([Uc([g=>VgA(g),hI])],Ju.prototype,"components",2);var zgA=Object.defineProperty,XgA=Object.getOwnPropertyDescriptor,$gA=(g,A,e,t)=>{for(var i=t>1?void 0:t?XgA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&zgA(A,e,i),i};class bu extends hI{constructor(){super(...arguments);r(this,"preset")}get typeName(){return"Antialiasing"}onCreateEffect(){const e=new JY({preset:QE.HIGH,edgeDetectionMode:cN.DEPTH});return this.preset.onValueChanged=t=>{e.applyPreset(t)},e}}$gA([D(qe)],bu.prototype,"preset",2);us("Antialiasing",bu);const AIA=IA("debugusdz");class Cr{constructor(){r(this,"files",new Array)}static getName(A){var I;const e=A.split(".").pop();let i=(I=A.split(".").slice(0,-1).join(".").split("/").pop())==null?void 0:I.replace(".","_");return i||(i="Audio_"+Math.random().toString(36).substring(2,15)),Ps(i)+"."+e}get extensionName(){return"Audio"}onExportObject(A,e,t){const i=aA.getComponents(A,Di);if(i.length)for(const I of i){if(!I.clip||typeof I.clip!="string"||!I.playOnAwake)continue;const o=I.clip.split("/").pop()||"Audio",s=Cr.getName(I.clip),n=Ps(s);this.files.some(C=>C.path===I.clip)||this.files.push({path:I.clip,name:s}),t.quickLookCompatible||e.addEventListener("serialize",(C,a)=>{C.appendLine(),C.beginBlock(`def SpatialAudio "${n}"`,"(",!1),C.appendLine(`displayName = "${o}"`),C.closeBlock(")"),C.beginBlock(),C.appendLine(`uniform asset filePath = @audio/${s}@`),C.appendLine(`uniform token auralMode = "${I.spatialBlend>0?"spatial":"nonSpatial"}"`),C.appendLine(`uniform token playbackMode = "${I.loop?"loopFromStage":"onceFromStart"}"`),C.appendLine(`uniform float gain = ${I.volume}`),C.closeBlock()})}}async onAfterSerialize(A){for(const e of this.files){const t="audio/"+e.name;if(A.files[t]){AIA&&console.warn("Audio file with name "+t+" already exists in the context. Skipping.");continue}const o=await(await(await fetch(e.path)).blob()).arrayBuffer(),s=new Uint8Array(o);A.files[t]=s}}}const cB=IA("debugautosync"),BG=Symbol("syncerId");class eIA{constructor(){r(this,"_syncers",{})}getOrCreateSyncer(A){if(!A.guid)return null;if(this._syncers[A.guid])return this._syncers[A.guid];const e=new tIA(A);return e[BG]=A.guid,this._syncers[e[BG]]=e,e}removeSyncer(A){delete this._syncers[A[BG]]}}const YN=new eIA;class tIA{constructor(A){r(this,"comp");r(this,"hasChanges",!1);r(this,"changedProperties",{});r(this,"data",{});r(this,"_isReceiving",!1);r(this,"_isInit",!1);r(this,"onHandleSending",()=>{if(!this.hasChanges)return;this.hasChanges=!1;const A=this.comp.context.connection;if(!A||!A.isConnected||!A.isInRoom){for(const e in this.changedProperties)delete this.changedProperties[e];return}for(const e in this.data)delete this.data[e];this.data.guid=this.comp.guid;for(const e in this.changedProperties){const t=this.changedProperties[e];delete this.changedProperties[e],this.data[e]=t}A.send(this.networkingKey,this.data,es.Queued)});r(this,"onHandleReceiving",A=>{if(cB&&console.log("RECEIVE",this.comp.name,this.comp.guid,A),!this._isInit||!this.comp)return;const e=A.guid;if(!(e&&e!==this.comp.guid)){cB&&console.log("RECEIVED",this.comp.name,this.comp.guid,A);try{this._isReceiving=!0;for(const t in A){if(t==="guid")continue;const i=A[t];this.comp[t]=i,cB&&console.log("SET",t,i)}}catch(t){console.error(t)}finally{this._isReceiving=!1}}});this.comp=A}get networkingKey(){return this.comp.guid}init(A){if(this._isInit)return;this._isInit=!0,this.comp=A,this.comp.context.post_render_callbacks.push(this.onHandleSending),this.comp.context.connection.beginListen(this.networkingKey,this.onHandleReceiving);const e=this.comp.context.connection.tryGetState(this.comp.guid);e&&this.onHandleReceiving(e)}destroy(){this._isInit&&(this.comp.context.post_render_callbacks.splice(this.comp.context.post_render_callbacks.indexOf(this.onHandleSending),1),this.comp.context.connection.stopListen(this.networkingKey,this.onHandleReceiving),this.comp=null,this._isInit=!1)}notifyChanged(A,e){this._isReceiving||(cB&&console.log("Property changed: "+A,e),this.hasChanges=!0,this.changedProperties[A]=e)}}function iIA(g,A){let e=A!==g;return!e&&g&&A&&(Array.isArray(g)&&Array.isArray(A)||typeof g=="object"&&typeof A=="object")&&(e=!0),e}const Yh=Symbol("AutoSyncHandler");function gIA(g){if(g[Yh])return g[Yh];const A=YN.getOrCreateSyncer(g);return A==null||A.init(g),g[Yh]=A,A}function IIA(g){const A=g[Yh];A&&(YN.removeSyncer(A),A.destroy(),delete g[Yh])}const ON=function(g){return function(A,e){var a;let t="";typeof e=="string"?t=e:t=e.name;let i=null,I;typeof g=="string"?I=A[g]:typeof g=="function"&&(I=g);const o=A,s=o.__internalAwake;if(typeof s!="function"){(cB||he())&&console.error('@syncField can currently only used on Needle Engine Components, custom object of type "'+((a=A==null?void 0:A.constructor)==null?void 0:a.name)+'" is not supported',A);return}cB&&console.log(t);const n=Symbol(t);o.__internalAwake=function(){if(this[n]!==void 0)return;this[n]=this[t],i=YN.getOrCreateSyncer(this);const B=Object.getOwnPropertyDescriptor(this,t);if((B==null?void 0:B.set)===void 0){let Q=!1;Object.defineProperty(this,t,{set:function(E){var d;const c=this[n];if(this[n]=E,Q){he()&&console.warn("Recursive call detected",t);return}Q=!0;try{const l=iIA(E,c);cB&&console.log("SyncField assignment",t,"changed?",l,E),l&&(I==null?void 0:I.call(this,E,c))!==!1&&((d=gIA(this))==null||d.notifyChanged(t,E))}finally{Q=!1}},get:function(){return this[n]},configurable:!0,enumerable:!0})}i==null||i.init(this),s.call(this)};const C=o.__internalDestroy;o.__internalDestroy=function(){IIA(this),C.call(this)}}};var oIA=Object.defineProperty,sIA=Object.getOwnPropertyDescriptor,kS=(g,A,e,t)=>{for(var i=t>1?void 0:t?sIA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&oIA(A,e,i),i};const uo=IA("debugplayersync");class Lc extends RA{constructor(){super(...arguments);r(this,"autoSync",!0);r(this,"asset");r(this,"onPlayerSpawned");r(this,"_localInstance");r(this,"onJoinedRoom",()=>{uo&&console.log("PlayerSync.joinedRoom. autoSync is set to "+this.autoSync),this.autoSync&&this.getInstance()})}awake(){this.watchTabVisible(),this.onPlayerSpawned||(this.onPlayerSpawned=new Bg)}onEnable(){this.context.connection.beginListen(It.RoomStateSent,this.onJoinedRoom),this.context.connection.beginListen(It.JoinedRoom,this.onJoinedRoom),this.context.connection.isInRoom&&this.onJoinedRoom()}onDisable(){this.context.connection.stopListen(It.RoomStateSent,this.onJoinedRoom),this.context.connection.stopListen(It.JoinedRoom,this.onJoinedRoom)}async getInstance(){var t,i,I,o,s,n;if(this._localInstance)return this._localInstance;if(uo&&console.log("PlayerSync.createInstance",(t=this.asset)==null?void 0:t.uri),!((i=this.asset)!=null&&i.asset)&&!((I=this.asset)!=null&&I.uri))return console.error('PlayerSync: can not create an instance because "asset" is not set!'),null;this._localInstance=(o=this.asset)==null?void 0:o.instantiateSynced({parent:this.gameObject},!0);const e=await this._localInstance;if(e){const C=aA.getComponent(e,os);C?(C.owner=this.context.connection.connectionId,(s=this.onPlayerSpawned)==null||s.invoke(e)):(this._localInstance=void 0,console.error("<strong>Failed finding PlayerState on "+((n=this.asset)==null?void 0:n.uri)+"</strong>: please make sure the asset has a PlayerState component!"),aA.destroySynced(e))}else this._localInstance=void 0,console.warn("PlayerSync: failed instantiating asset!");return this._localInstance}destroyInstance(){var e;(e=this._localInstance)==null||e.then(t=>(uo&&console.log("PlayerSync.destroyInstance",t),aA.destroySynced(t))),this._localInstance=void 0}watchTabVisible(){window.addEventListener("visibilitychange",e=>{if(document.visibilityState==="visible")for(let t=os.all.length-1;t>=0;t--){const i=os.all[t];(!i.owner||!this.context.connection.userIsInRoom(i.owner))&&i.doDestroy()}})}}kS([D()],Lc.prototype,"autoSync",2);kS([D(tt)],Lc.prototype,"asset",2);kS([D(Bg)],Lc.prototype,"onPlayerSpawned",2);var WO=(g=>(g.OwnerChanged="ownerChanged",g))(WO||{}),jl;const vg=(jl=class extends RA{constructor(){super(...arguments);r(this,"onOwnerChangeEvent",new Bg);r(this,"onFirstOwnerChangeEvent",new Bg);r(this,"hasOwner",!1);r(this,"owner");r(this,"dontDestroy",!1);r(this,"onUserLeftRoom",A=>{if(A.userId===this.owner){uo&&console.log("PLAYERSYNC LEFT",this.owner),this.doDestroy();return}})}static get all(){return vg._all}static get local(){return vg._local}static getFor(A){if(A instanceof uA)return aA.getComponentInParent(A,vg);if(A instanceof RA)return aA.getComponentInParent(A.gameObject,vg)}static isLocalPlayer(A){const e=vg.getFor(A);return(e==null?void 0:e.isLocalPlayer)??!1}static addEventListener(A,e){return this._callbacks[A]||(this._callbacks[A]=[]),this._callbacks[A].push(e),e}static removeEventListener(A,e){if(!this._callbacks[A])return;const t=this._callbacks[A].indexOf(e);t>=0&&this._callbacks[A].splice(t,1)}static dispatchEvent(A,e){if(this._callbacks[A])for(const t of this._callbacks[A])t(e)}get isLocalPlayer(){return this.owner===this.context.connection.connectionId}onOwnerChange(A,e){var o,s;uo&&console.log("PlayerSync.onOwnerChange",this,"newOwner",A,"oldOwner",e);const t=vg._local.indexOf(this);t>=0&&vg._local.splice(t,1);const i={playerState:this,oldValue:e,newValue:A};if(this.hasOwner||(this.hasOwner=!0,(o=this.onFirstOwnerChangeEvent)==null||o.invoke(i)),(s=this.onOwnerChangeEvent)==null||s.invoke(i),this.owner===this.context.connection.connectionId){vg._local.push(this);const n=new CustomEvent("local-owner-changed",{detail:i});this.dispatchEvent(n)}const I=new CustomEvent("owner-changed",{detail:i});this.dispatchEvent(I),vg.dispatchEvent("ownerChanged",I)}awake(){vg.all.push(this),uo&&console.log("Registered new PlayerState",this.guid,vg.all.length-1,vg.all),this.context.connection.beginListen(It.UserLeftRoom,this.onUserLeftRoom)}async start(){uo&&console.log("PLAYERSTATE.START, owner: "+this.owner,this.context.connection.usersInRoom([])),this.owner?(this.context.connection.isInRoom||await Os(300),this.context.connection.userIsInRoom(this.owner)==!1&&(uo&&console.log(`PlayerSync.start → doDestroy "${this.name}" because user "${this.owner}" is not in room anymore...`,"Currently in room:",...this.context.connection.usersInRoom()),this.doDestroy())):this.owner||(uo&&console.warn("PlayerState.start → owner is undefined!",this.name),setTimeout(()=>{!this.destroyed&&!this.owner?this.dontDestroy?uo&&console.warn("PlayerState.start → owner is still undefined but dontDestroy is set to true",this.name):(uo&&console.warn(`PlayerState.start → owner is still undefined: destroying "${this.name}" instance now`),this.doDestroy()):uo&&console.log("PlayerState.start → owner is assigned",this.owner)},2e3))}doDestroy(){uo&&console.log("PlayerSync.doDestroy → syncDestroy",this.name),ES(this.gameObject,this.context.connection)}onDestroy(){if(this.context.connection.stopListen(It.UserLeftRoom,this.onUserLeftRoom),vg.all.splice(vg.all.indexOf(this),1),this.isLocalPlayer){const A=vg._local.indexOf(this);A>=0&&vg._local.splice(A,1)}}},r(jl,"_all",[]),r(jl,"_local",[]),r(jl,"_callbacks",{}),jl);let os=vg;kS([ON(os.prototype.onOwnerChange)],os.prototype,"owner",2);const nIA=IA("debugavatar"),Rs=class extends RA{constructor(){super(...arguments);r(this,"connectionId");r(this,"avatar")}static getAvatar(e){return e>=0&&e<Rs.instances.length?Rs.instances[e]:null}static onAvatarMarkerCreated(e){return Rs._onNewAvatarMarkerAdded.push(e),e}static onAvatarMarkerDestroyed(e){return Rs._onAvatarMarkerDestroyed.push(e),e}awake(){Rs.instances.push(this),nIA&&console.log(this);for(const e of Rs._onNewAvatarMarkerAdded)e({avatarMarker:this,gameObject:this.gameObject})}onDestroy(){Rs.instances.splice(Rs.instances.indexOf(this),1);for(const e of Rs._onAvatarMarkerDestroyed)e({avatarMarker:this,gameObject:this.gameObject})}isLocalAvatar(){return this.connectionId===this.context.connection.connectionId}};let ng=Rs;r(ng,"instances",[]),r(ng,"_onNewAvatarMarkerAdded",[]),r(ng,"_onAvatarMarkerDestroyed",[]);var CIA=Object.defineProperty,aIA=Object.getOwnPropertyDescriptor,rIA=(g,A,e,t)=>{for(var i=t>1?void 0:t?aIA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&CIA(A,e,i),i};const cE=IA("debugxrflags"),ZO=IA("disablexrflags");ZO&&console.warn("XRFlags are disabled");var fn=(g=>(g[g.Never=0]="Never",g[g.Browser=1]="Browser",g[g.AR=2]="AR",g[g.VR=4]="VR",g[g.FirstPerson=8]="FirstPerson",g[g.ThirdPerson=16]="ThirdPerson",g[g.All=4294967295]="All",g))(fn||{});const qK=class{constructor(){r(this,"Mask",17)}Has(A){return(this.Mask&A)!==0}Set(A){cE&&console.warn("Set XR flag state to",A),this.Mask=A,Do.Apply()}Enable(A){this.Mask|=A,Do.Apply()}Disable(A){this.Mask&=~A,Do.Apply()}Toggle(A){this.Mask^=A,Do.Apply()}EnableAll(){this.Mask=-1,Do.Apply()}DisableAll(){this.Mask=0,Do.Apply()}};let Hg=qK;r(Hg,"Global",new qK);var Vl;const rC=(Vl=class extends RA{constructor(){super(...arguments);r(this,"visibleIn")}static Apply(){for(const A of this.registry)A.UpdateVisible(Hg.Global)}awake(){rC.registry.push(this)}onEnable(){rC.firstApply?this.UpdateVisible(Hg.Global):(rC.firstApply=!0,rC.Apply())}onDestroy(){const A=rC.registry.indexOf(this);A>=0&&rC.registry.splice(A,1)}get isOn(){return this.gameObject.visible}UpdateVisible(A=null){if(ZO)return;let e;const t=A;if(t&&typeof t=="number"&&(console.assert(typeof t=="number","XRFlag.UpdateVisible: state must be a number",t),cE&&console.log(t),rC.buffer.Mask=t,A=rC.buffer),A instanceof Hg?(cE&&console.warn(this.name,"use passed in mask",A.Mask,this.visibleIn),e=A.Has(this.visibleIn)):(cE&&console.log(this.name,"use global mask"),Hg.Global.Has(this.visibleIn)),e!==void 0)if(e)cE&&console.log(this.name,"is visible",this.gameObject.uuid),aA.setActive(this.gameObject,!0);else{if(cE&&console.log(this.name,"is not visible",this.gameObject.uuid),!this.gameObject.visible)return;this.gameObject.visible=!1}}},r(Vl,"registry",[]),r(Vl,"firstApply"),r(Vl,"buffer",new Hg),Vl);let Do=rC;rIA([D()],Do.prototype,"visibleIn",2);var BIA=Object.defineProperty,QIA=Object.getOwnPropertyDescriptor,PN=(g,A,e,t)=>{for(var i=t>1?void 0:t?QIA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&BIA(A,e,i),i};const ql=IA("debugwebxr"),Hq=new MA().setFromAxisAngle(new w(0,1,0),Math.PI);class oQ extends RA{constructor(){super(...arguments);r(this,"head");r(this,"leftHand");r(this,"rightHand");r(this,"_syncTransforms")}async onEnterXR(e){if(!this.activeAndEnabled)return;ql&&console.warn("AVATAR ENTER XR",this.guid,this.sourceId,this,this.activeAndEnabled),this._syncTransforms&&(this._syncTransforms.length=0),await this.prepareAvatar();const t=os.getFor(this);if(t!=null&&t.owner){const i=this.gameObject.addNewComponent(ng);i.avatar=this.gameObject,i.connectionId=t.owner}else this.context.connection.isConnected?console.error("No player state found for avatar",this):t&&!this.context.connection.isConnected&&(t.dontDestroy=!0)}onLeaveXR(e){const t=this.gameObject.getComponent(ng);t&&t.destroy()}onUpdateXR(e){var n,C;if(!this.activeAndEnabled)return;const t=os.isLocalPlayer(this);if(!t)return;const i=e.xr;if(i.rig&&i.rig.gameObject!==this.gameObject.parent&&(this.gameObject.position.set(0,0,0),this.gameObject.rotation.set(0,0,0),this.gameObject.scale.set(1,1,1),i.rig.gameObject.add(this.gameObject)),this._syncTransforms&&t)for(const a of this._syncTransforms)a.fastMode=!0,a.isOwned()||a.requestOwnership();if(this.head&&this.context.mainCamera){const a=this.head.asset;if(a.position.copy(this.context.mainCamera.position),a.quaternion.copy(this.context.mainCamera.quaternion),a.quaternion.x*=-1,this.context.time.frameCount%10===0){const B=aA.getComponentsInChildren(this.head.asset,Do);for(const Q of B)Q.enabled=!1,Q.gameObject.visible=!1}}const I=e.xr.leftController,o=(n=this.leftHand)==null?void 0:n.asset;I&&o&&(o.position.copy(I.gripPosition),o.quaternion.copy(I.gripQuaternion),o.quaternion.multiply(Hq),o.visible=I.isTracking);const s=e.xr.rightController;if(s&&((C=this.rightHand)!=null&&C.asset)){const a=this.rightHand.asset;a.position.copy(s.gripPosition),a.quaternion.copy(s.gripQuaternion),a.quaternion.multiply(Hq),a.visible=s.isTracking}}onBeforeRender(){this.context.time.frame%10===0&&this.updateRemoteAvatarVisibility()}updateRemoteAvatarVisibility(){var e,t,i;if(this.context.connection.isConnected){const I=os.getFor(this);if(I&&I.isLocalPlayer==!1){const o=Se.getXRSync(this.context);if(o&&o.hasState(I.owner)){this.tryFindAvatarObjectsIfMissing();const s=(e=this.leftHand)==null?void 0:e.asset;s&&(s.visible=(o==null?void 0:o.isTracking(I.owner,"left"))??!1);const n=(t=this.rightHand)==null?void 0:t.asset;n&&(n.visible=(o==null?void 0:o.isTracking(I.owner,"right"))??!1)}if((i=this.head)!=null&&i.asset){const s=aA.getComponentsInChildren(this.head.asset,Do);for(const n of s)n.enabled=!1,n.gameObject.visible=!0}}}}tryFindAvatarObjectsIfMissing(){if(!this.head||!this.leftHand||!this.rightHand){const e={head:this.head,leftHand:this.leftHand,rightHand:this.rightHand};z2.tryFindAvatarObjects(this.gameObject,this.sourceId||"",e),e.head&&(this.head=e.head),e.leftHand&&(this.leftHand=e.leftHand),e.rightHand&&(this.rightHand=e.rightHand)}}async prepareAvatar(){if(this.tryFindAvatarObjectsIfMissing(),this.head)this.head instanceof uA&&(this.head=new tt("",this.sourceId,this.head));else{const e=new uA;e.name="Head";const t=Du.createPrimitive(_B.Cube);e.add(t),this.gameObject.add(e),this.head=new tt("",this.sourceId,e),ql&&console.log("Create head",e)}if(this.rightHand)this.rightHand instanceof uA&&(this.rightHand=new tt("",this.sourceId,this.rightHand));else{const e=new uA;e.name="Right Hand",this.gameObject.add(e),this.rightHand=new tt("",this.sourceId,e),ql&&console.log("Create right hand",e)}if(this.leftHand)this.leftHand instanceof uA&&(this.leftHand=new tt("",this.sourceId,this.leftHand));else{const e=new uA;e.name="Left Hand",this.gameObject.add(e),this.leftHand=new tt("",this.sourceId,e),ql&&console.log("Create left hand",e)}await this.loadAvatarObjects(this.head,this.leftHand,this.rightHand),os.isLocalPlayer(this.gameObject)&&(this._syncTransforms=aA.getComponentsInChildren(this.gameObject,nr))}async loadAvatarObjects(e,t,i){const I=e.loadAssetAsync(),o=t.loadAssetAsync(),s=i.loadAssetAsync(),n=new Array;I&&n.push(I),o&&n.push(o),s&&n.push(s);const C=await au(n);ql&&console.log("Avatar loaded results:",C)}}PN([D(tt)],oQ.prototype,"head",2);PN([D(tt)],oQ.prototype,"leftHand",2);PN([D(tt)],oQ.prototype,"rightHand",2);class Jn{static Add(A,e,t=null){if(e){for(const i of this.Pois)if(i.obj===e)return;this.Pois.push({obj:e,avatar:t}),this.LastChangeTime=A.time.time}}static Remove(A,e){var t;if(e){for(const i of this.Pois)if(i.obj===e){this.Pois.splice(this.Pois.indexOf(i),1),this.LastChangeTime=(A==null?void 0:A.time.time)??((t=ve.Current)==null?void 0:t.time.time);return}}}}r(Jn,"Pois",[]),r(Jn,"LastChangeTime",0);class EIA{constructor(){r(this,"guid");r(this,"position",new w)}}class Jd extends RA{constructor(){super(...arguments);r(this,"target",null);r(this,"avatar",null);r(this,"_model",null);r(this,"_targetModel",new EIA);r(this,"_currentTargetObject",null);r(this,"_lastUpdateTime",0);r(this,"_lookDuration",0);r(this,"_lastPoiChangedTime",0)}set controlledTarget(e){this.target=e;const t=z.get("MoveRandom");if(t&&this.target){const i=aA.getComponent(this.target,t);i&&i.destroy()}}awake(){if(this.avatar=aA.getComponentInParent(this.gameObject,ng),this.avatar){const e=aA.getComponentInParent(this.gameObject,ng);this._model=new JN(this.context.connection,this.guid),e!=null&&e.isLocalAvatar&&this._model.requestOwnership()}this.context.connection.beginListen("avatar-look-target-changed",e=>{var t;this.target&&e&&e.guid===((t=this.avatar)==null?void 0:t.guid)&&EI(this.target,e.position)})}update(){var t;if((!this.context.connection.isConnected||(t=this._model)!=null&&t.hasOwnership)&&(Jn.LastChangeTime!==this._lastPoiChangedTime&&(this._lastPoiChangedTime=Jn.LastChangeTime,this._lookDuration=0),this.selectTarget(),this._currentTargetObject&&this.context.time.frameCount%10===0&&this.target)){const i=_e(this._currentTargetObject);EI(this.target,i),this.context.connection.isConnected&&this.avatar&&(this.context.connection.send("avatar-look-target-changed",this._targetModel),this._targetModel.guid=this.avatar.guid,this._targetModel.position.copy(i))}}selectTarget(){if(this.context.time.time-this._lastUpdateTime>this._lookDuration){this._lastUpdateTime=this.context.time.time,this._lookDuration=Math.random()*.5+.2;const t=Jn.Pois;if(t.length>0){const i=t[Math.floor(Math.random()*t.length)];if(i&&i.obj){if(i.avatar&&i.avatar===this.avatar)return;this._currentTargetObject=i.obj}}}}}const NE=IA("debugnetworkingstreams");var Mn=(g=>(g.Connected="peer-user-connected",g.StreamReceived="receive-stream",g.StreamEnded="call-ended",g.Disconnected="peer-user-disconnected",g.UserJoined="user-joined",g))(Mn||{});class jO{constructor(A,e){r(this,"type","call-ended");r(this,"userId");r(this,"direction");this.userId=A,this.direction=e}}class VO{constructor(A,e){r(this,"type","receive-stream");r(this,"stream");r(this,"target");this.stream=A,this.target=e}}class cIA{constructor(A,e){r(this,"guid");r(this,"peerId");r(this,"dontSave",!0);this.guid=A.id,this.peerId=e}}var zO=(g=>(g.Incoming="incoming",g.Outgoing="outgoing",g))(zO||{});class lIA extends kg{constructor(e,t,i){super();r(this,"userId");r(this,"direction");r(this,"call");r(this,"_stream",null);r(this,"_isDisposed",!1);this.userId=e,this.call=t,this.direction=i,this._stream=null,t.on("stream",I=>{if(NE&&console.log("Receive video",I.getAudioTracks(),I.getVideoTracks()),this._stream=I,i==="incoming"){const o=new VO(I,this);this.dispatchEvent(o)}}),t.on("close",()=>{this.dispatchEvent(new jO(e,i))})}get stream(){return this._stream}close(){this._isDisposed||(this._isDisposed=!0,this.call.close(),UC(this._stream))}get isOpen(){var e;return((e=this.call.peerConnection)==null?void 0:e.connectionState)==="connected"}get isOpening(){var e;return((e=this.call.peerConnection)==null?void 0:e.connectionState)==="connecting"}get isClosed(){return!this.isOpen}}const bE=class extends kg{constructor(e,t){super();r(this,"id");r(this,"context");r(this,"_peer");r(this,"_incomingCalls",[]);r(this,"_outgoingCalls",[]);r(this,"_enabled",!1);r(this,"_enabledPeer",!1);r(this,"onConnectRoomFn",this.onConnectRoom.bind(this));r(this,"onPeerConnectFn",this.onPeerConnect.bind(this));r(this,"onPeerReceiveCallFn",this.onPeerReceivingCall.bind(this));this.context=e,this.id=t,this.setupPeer(),navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia}static getOrCreate(e,t){if(bE.instances.has(t))return bE.instances.get(t);const i=new bE(e,t);return bE.instances.set(t,i),i}getMyPeerId(){if(this.context.connection.connectionId)return this.getPeerIdFromUserId(this.context.connection.connectionId)}getPeerIdFromUserId(e){return this.id+"-"+e}getUserIdFromPeerId(e){return e.substring(this.id.length+1)}makeCall(e,t){var o;const i={metadata:{userId:this.context.connection.connectionId}},I=(o=this._peer)==null?void 0:o.call(e,t,i);if(I)return this.registerCall(I,"outgoing")}get peer(){return this._peer}enable(){this._enabled||(this._enabled=!0,this.context.connection.beginListen(It.JoinedRoom,this.onConnectRoomFn),this.subscribePeerEvents())}disable(){this._enabled&&(this._enabled=!1,this.context.connection.stopListen(It.JoinedRoom,this.onConnectRoomFn),this.unsubscribePeerEvents())}onConnectRoom(){this.setupPeer()}setupPeer(){if(this.context.connection.connectionId&&!this._enabledPeer){if(this._enabledPeer=!0,!this._peer){const e=this.getMyPeerId();e?this._peer=Y2(e):console.error("Failed to setup peerjs because we dont have a connection id",this.context.connection.connectionId)}this._enabled&&this.subscribePeerEvents()}}subscribePeerEvents(){this._peer&&(this._peer.on("open",this.onPeerConnectFn),this._peer.on("call",this.onPeerReceiveCallFn))}unsubscribePeerEvents(){this._peer&&(this._peer.off("open",this.onPeerConnectFn),this._peer.off("call",this.onPeerReceiveCallFn))}onPeerConnect(e){NE&&console.log("Peer connected as",e),this.context.connection.send("peer-user-connected",new cIA(this,e))}onPeerReceivingCall(e){e.answer(),this.registerCall(e,"incoming")}registerCall(e,t){const i=e.metadata;(!i||!i.userId)&&console.error("Missing call metadata",e);const I=i.userId;t==="incoming"&&NE?console.log("Receive call from",e.metadata):NE&&console.log("Make call to",e.metadata);const o=t==="incoming"?this._incomingCalls:this._outgoingCalls,s=new lIA(I,e,t);return o.push(s),e.on("error",n=>{console.error("Call error",n)}),e.on("close",()=>{NE&&console.log("Call ended",e.metadata),e.close();const n=o.indexOf(s);n!==-1&&o.splice(n,1)}),s.addEventListener("call-ended",n=>{this.dispatchEvent(n)}),t==="incoming"&&(s.addEventListener("receive-stream",n=>{this.dispatchEvent(n)}),e.on("stream",()=>{let n=0;const C=setInterval(()=>{const a=n===0;!s.isOpen&&a&&(n+=1,clearInterval(C),s.close())},2e3)})),s}};let OE=bE;r(OE,"instances",new Map);class vu extends kg{constructor(e,t){super();r(this,"context");r(this,"peer");r(this,"_sendingStreams",new Map);r(this,"debug",!1);r(this,"onJoinedRoom",e=>{this.debug&&console.log(`${e.userId} joined room and I'm currently sending ${this._sendingStreams.size} streams`),this._sendingStreams.size>0&&this.updateSendingCalls()});r(this,"onReceiveStream",e=>{this.debug&&console.log("RECEIVE STREAM",e),this.dispatchEvent({type:"receive-stream",target:this,stream:e.stream,userId:e.userId})});r(this,"onCallEnded",e=>{this.dispatchEvent(e)});r(this,"onUserConnected",e=>{if(this.peer.id===e.guid){this.debug&&console.log("USER CONNECTED",e.guid,e);const t=this._sendingStreams.keys().next().value;this.peer.makeCall(e.peerId,t)}});r(this,"onUserLeft",e=>{this.stopCallsToUsersThatAreNotInTheRoomAnymore()});this.context=e,this.peer=t,NE&&(this.debug=!0)}static create(e){const t=OE.getOrCreate(e.context,e.context.connection.connectionId);return new vu(e.context,t)}startSendingStream(e){this._sendingStreams.has(e)?console.warn("Received start sending stream with stream that is already being sent"):(this._sendingStreams.set(e,[]),this.updateSendingCalls())}stopSendingStream(e){if(e){const t=this._sendingStreams.get(e);if(t){this.debug&&console.log("Closing calls",t);for(const i of t)i.close()}this._sendingStreams.delete(e),t&&this.debug&&console.log("Currently sending",this._sendingStreams)}}enable(){this.peer.enable(),this.peer.addEventListener("receive-stream",this.onReceiveStream),this.peer.addEventListener("call-ended",this.onCallEnded),this.context.connection.beginListen("peer-user-connected",this.onUserConnected),this.context.connection.beginListen(It.JoinedRoom,this.onJoinedRoom),this.context.connection.beginListen(It.UserJoinedRoom,this.onJoinedRoom),this.context.connection.beginListen(It.UserLeftRoom,this.onUserLeft)}disable(){this.peer.disable(),this.peer.removeEventListener("receive-stream",this.onReceiveStream),this.peer.removeEventListener("call-ended",this.onCallEnded),this.context.connection.stopListen("peer-user-connected",this.onUserConnected),this.context.connection.stopListen(It.JoinedRoom,this.onJoinedRoom),this.context.connection.stopListen(It.UserJoinedRoom,this.onJoinedRoom),this.context.connection.stopListen(It.UserLeftRoom,this.onUserLeft)}updateSendingCalls(){var i;let e=!1;const t=this.context.connection.connectionId;for(const I of this._sendingStreams.keys()){const o=this._sendingStreams.get(I)||[];for(const s of this.context.connection.usersInRoom()){if(s===t)continue;const n=o.find(C=>C.userId===s);if(!n||((i=n.stream)==null?void 0:i.active)===!1){this.debug&&console.log("Starting call to",s,t);const C=this.peer.makeCall(this.peer.getPeerIdFromUserId(s),I);C&&(e=!0,o.push(C))}}this._sendingStreams.set(I,o)}this.stopCallsToUsersThatAreNotInTheRoomAnymore(),e&&this.debug&&console.log("Currently sending",this._sendingStreams)}stopCallsToUsersThatAreNotInTheRoomAnymore(){for(const e of this._sendingStreams.keys()){const t=this._sendingStreams.get(e);if(t)for(let i=t.length-1;i>=0;i--){const I=t[i];this.context.connection.userIsInRoom(I.userId)||(I.close(),t.splice(i,1))}}}}function UC(g){if(g&&g instanceof MediaStream)for(const A of g.getTracks())A.stop()}var hIA=Object.defineProperty,dIA=Object.getOwnPropertyDescriptor,XO=(g,A,e,t)=>{for(var i=t>1?void 0:t?dIA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&hIA(A,e,i),i};const uIA="noVoip",pIA=IA("debugvoip");class sQ extends RA{constructor(){super(...arguments);r(this,"autoConnect",!1);r(this,"runInBackground",!0);r(this,"debug",!1);r(this,"_net");r(this,"_outputStream",null);r(this,"onJoinedRoom",async()=>{await Os(300),this.autoConnect&&!this.isSending&&this.connect()});r(this,"_incomingStreams",new Map);r(this,"onReceiveStream",e=>{const t=e.target.userId,i=e.stream,I=this._incomingStreams.get(t);if(I)I.srcObject=i,I.setAttribute("autoplay","true");else{const o=new Audio;this._incomingStreams.set(t,o),o.setAttribute("autoplay","true"),o.srcObject=i}});r(this,"onStreamEnded",e=>{const t=this._incomingStreams.get(e.userId);UC(t==null?void 0:t.srcObject),this._incomingStreams.delete(e.userId)});r(this,"onEnabledChanged",()=>{for(const e of this._incomingStreams){const t=e[1];t.muted=!this.enabled}});r(this,"onVisibilityChanged",()=>{if(this.runInBackground)return;const t=!(document.visibilityState==="visible");this.setMuted(t);for(const i of this._incomingStreams){const I=i[1];I.muted=t}})}awake(){pIA&&(this.debug=!0),this.debug&&window.addEventListener("keydown",async e=>{e.key==="v"&&(console.log("MUTE?",!this.isMuted),this.setMuted(!this.isMuted))})}onEnable(){this._net||(this._net=vu.create(this)),this._net.addEventListener(Mn.StreamReceived,this.onReceiveStream),this._net.addEventListener(Mn.StreamEnded,this.onStreamEnded),this._net.enable(),this.autoConnect&&(this.context.connection.isConnected?this.connect():this.context.connection.beginListen(It.JoinedRoom,this.onJoinedRoom)),this.onEnabledChanged(),window.addEventListener("visibilitychange",this.onVisibilityChanged)}onDisable(){var e;this._net.stopSendingStream(this._outputStream),this._net.removeEventListener(Mn.StreamReceived,this.onReceiveStream),this._net.removeEventListener(Mn.StreamEnded,this.onStreamEnded),(e=this._net)==null||e.disable(),this.context.connection.stopListen(It.JoinedRoom,this.onJoinedRoom),this.onEnabledChanged(),window.removeEventListener("visibilitychange",this.onVisibilityChanged)}get isSending(){return this._outputStream!=null&&this._outputStream.active}async connect(e){if(this.context.connection.isConnected){if(!await Wk())return console.error("Cannot connect to voice chat - microphone permissions not granted"),!1}else return console.error("Cannot connect to voice chat - not connected to server"),!1;return this._net.stopSendingStream(this._outputStream),UC(this._outputStream),this._outputStream=await this.getAudioStream(e),this._outputStream?(this._net.startSendingStream(this._outputStream),!0):(await Wk()?console.error("VOIP: Could not get audio stream - please make sure to connect an audio device and grant microphone permissions"):AN("Microphone permissions not granted: Please grant microphone permissions to use voice chat"),!1)}disconnect(){this._net.stopSendingStream(this._outputStream),UC(this._outputStream),this._outputStream=null}setMuted(e){var i;const t=(i=this._outputStream)==null?void 0:i.getAudioTracks();if(t)for(const I of t)I.enabled=!e}get isMuted(){var t;if(this._outputStream===null)return!1;const e=(t=this._outputStream)==null?void 0:t.getAudioTracks();if(e){for(const i of e)if(!i.enabled)return!0}return!1}getFrequency(e){return this.unsupported_getfrequency||(this.unsupported_getfrequency=!0,he()&&fi("VOIP: getFrequency is currently not supported"),console.warn("VOIP: getFrequency is currently not supported")),null}async getAudioStream(e){return navigator.mediaDevices.getUserMedia?await navigator.mediaDevices.getUserMedia({audio:e??!0,video:!1}).catch(i=>(console.warn("VOIP failed getting audio stream",i),null)):(console.error("No getDisplayMedia support"),null)}}XO([D()],sQ.prototype,"autoConnect",2);XO([D()],sQ.prototype,"runInBackground",2);var fIA=Object.defineProperty,DIA=Object.getOwnPropertyDescriptor,$O=(g,A,e,t)=>{for(var i=t>1?void 0:t?DIA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&fIA(A,e,i),i};const wIA=IA("debugmouth");class qu extends RA{constructor(){super(...arguments);r(this,"idle",[]);r(this,"talking",[]);r(this,"marker",null);r(this,"voip",null);r(this,"lastMouthChangeTime",0);r(this,"mouthChangeLength",0)}awake(){setTimeout(()=>{this.voip=aA.findObjectOfType(sQ,this.context),this.marker||(this.marker=aA.getComponentInParent(this.gameObject,ng))},3e3)}update(){var i;if(!this.voip||this.context.time.frameCount%10!==0)return;let e=((i=this.marker)==null?void 0:i.connectionId)??null;if(!e){wIA&&(e=null);return}const t=this.voip.getFrequency(e)??0;this.updateLips(t)}updateLips(e){if(this.context.time.time-this.lastMouthChangeTime>this.mouthChangeLength){if(this.mouthChangeLength=.05+Math.random()*.1,this.talking&&this.talking.length>0&&e>30){this.lastMouthChangeTime=this.context.time.time;const t=Math.floor(Math.random()*this.talking.length);this.setMouthShapeActive(this.talking,t)}else if(this.idle.length>0&&this.context.time.time-this.lastMouthChangeTime>.5){this.lastMouthChangeTime=this.context.time.time;const t=Math.floor(Math.random()*this.idle.length);this.setMouthShapeActive(this.idle,t)}}}setMouthShapeActive(e,t){if(e){e!=this.idle?this.idle.map(i=>i.visible=!1):this.talking.map(i=>i.visible=!1);for(let i=0;i<e.length;i++){const I=e[i];I&&(I.visible=i===t)}}}}$O([D(uA)],qu.prototype,"idle",2);$O([D(uA)],qu.prototype,"talking",2);class WN extends RA{constructor(){super(...arguments);r(this,"voip",null);r(this,"marker",null);r(this,"_startPosition",null)}awake(){this.voip=aA.findObjectOfType(sQ,this.context),this.marker=aA.getComponentInParent(this.gameObject,ng)}update(){if(!this.voip||!this.marker||this.context.time.frameCount%10!==0)return;const e=this.marker.connectionId,t=this.voip.getFrequency(e);if(t==null)return;this._startPosition||(this._startPosition=this.gameObject.position.clone());const i=t/100;this.gameObject.position.y=this._startPosition.y+i*.07}}var yIA=Object.defineProperty,SIA=Object.getOwnPropertyDescriptor,MS=(g,A,e,t)=>{for(var i=t>1?void 0:t?SIA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&yIA(A,e,i),i};class nQ extends RA{constructor(){super(...arguments);r(this,"eyes",[]);r(this,"lastBlinkTime",0);r(this,"blinkLength",0);r(this,"eyesOpen",!0);r(this,"state",null)}awake(){this.state=aA.getComponentInParent(this.gameObject,Do)}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 t of this.eyes)t&&(t.visible=this.eyesOpen)}}}MS([D(uA)],nQ.prototype,"eyes",2);MS([D()],nQ.prototype,"lastBlinkTime",2);MS([D()],nQ.prototype,"blinkLength",2);MS([D()],nQ.prototype,"eyesOpen",2);var mIA=Object.defineProperty,GIA=Object.getOwnPropertyDescriptor,ZN=(g,A,e,t)=>{for(var i=t>1?void 0:t?GIA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&mIA(A,e,i),i},$G;const AP=($G=class extends RA{constructor(){super(...arguments);r(this,"head",null);r(this,"eyes",null);r(this,"target",null);r(this,"brain",null);r(this,"vec",new w);r(this,"currentTargetPoint",new w)}awake(){this.brain||(this.brain=aA.getComponentInParent(this.gameObject,Jd)),this.brain||(console.log("No look at brain found, adding it now"),this.brain=aA.addNewComponent(this.gameObject,Jd)),this.brain&&this.target&&(this.brain.controlledTarget=this.target)}update(){const A=this.target;if(A&&this.head){const e=this.eyes;if(e){const t=_e(A);this.currentTargetPoint.lerp(t,this.context.time.deltaTime/.1);const i=_e(this.head),I=this.vec.copy(this.currentTargetPoint).sub(i).normalize();if(I.length()<.1)return;const o=AP.forward;if(o.set(0,0,1),o.applyQuaternion(Jt(this.head)),o.dot(I)>.45)for(let n=0;n<e.length;n++)e[n].lookAt(this.currentTargetPoint)}}}},r($G,"forward",new w(0,0,1)),$G);let _c=AP;ZN([D(uA)],_c.prototype,"head",2);ZN([D(uA)],_c.prototype,"eyes",2);ZN([D(uA)],_c.prototype,"target",2);const xl=IA("debugavatar");class US{constructor(A,e,t,i){r(this,"root");r(this,"head");r(this,"leftHand");r(this,"rigthHand");var I;this.root=A,this.head=e,this.leftHand=t,this.rigthHand=i,(I=this.root)==null||I.traverse(o=>o.layers.set(2))}get isValid(){return this.head!==null&&this.head!==void 0}}class jN{constructor(){r(this,"avatarRegistryUrl",null)}async getOrCreateNewAvatarInstance(A,e){if(!e)return console.error("Can not create avatar: failed to provide id or root object"),null;let t=null;if(typeof e=="string"){if(t=await this.loadAvatar(A,e),!t){const I=new Xs;t=aA.instantiate(tc(e,A.scene),I)}}else t=e;if(!t)return null;const i=this.findAvatar(t);return i.isValid?(xl&&console.log("[Custom Avatar] valid config",e,xl?i:""),i):(console.warn("[Custom Avatar] config isn't valid",e,xl?i:""),null)}async loadAvatar(A,e){if(console.assert(e!=null&&typeof e=="string","Avatar id must not be null"),e.length<=0||!e)return null;if(xl&&console.log("[Custom Avatar] "+e+", loading..."),e.endsWith(".glb")||(e+=".glb"),this.avatarRegistryUrl===null){const i=await fetch("./"+e);let I=null;if(i.ok){const s=await i.blob();s&&(I=await s.arrayBuffer())}if(!I&&(I=await wN(e,e,0,"no url here go away",!0),!I))return null;const o=await Ys().parseSync(A,I,null,0);return(o==null?void 0:o.scene)??null}const t=new Mc;return lu(t,A),new Promise((i,I)=>{const o=this.avatarRegistryUrl+"/"+e;t.load(o,async s=>{await Ys().createBuiltinComponents(A,o,s,null,void 0),i(s.scene)},s=>{xl&&console.log("[Custom Avatar] "+s.loaded/s.total*100+"% loaded of "+s.total/1024+"kB")},s=>{console.error("[Custom Avatar] Error when loading: "+s),i(null)})})}cacheModel(A,e){}findAvatar(A){const e=A;let t=e;t.children.length==1&&(t=A.children[0]);let i=this.findAvatarPart(t,["head"]);const I=this.findAvatarPart(t,["left","hand"]),o=this.findAvatarPart(t,["right","hand"]);if(!i){i=e;const n=new w;new wt().setFromObject(i).getSize(n);const C=Math.max(n.x,n.y,n.z);console.warn("[Custom Avatar] Normalizing head scale, it's too big: "+C+" meters! Should be < 0.3m"),C>.3&&i.scale.multiplyScalar(1/C*.3)}return new US(e,i,I,o)}findAvatarPart(A,e){const t=A.name.toLowerCase();let i=!0;for(const I of e){if(!i)break;t.indexOf(I)===-1&&(i=!1)}if(i)return A;if(A.children)for(const I of A.children){const o=this.findAvatarPart(I,e);if(o)return o}return null}handleCustomAvatarErrors(A){if(!A.ok)throw Error(A.statusText);return A}}var kIA=Object.defineProperty,MIA=Object.getOwnPropertyDescriptor,VN=(g,A,e,t)=>{for(var i=t>1?void 0:t?MIA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&kIA(A,e,i),i};class Tc extends RA{constructor(){super(...arguments);r(this,"length",1);r(this,"depthTest",!0);r(this,"isGizmo",!0);r(this,"_axes",null)}onEnable(){if(this.isGizmo&&!uu)return;this._axes||(this._axes=new as(this.length)),this._axes.layers.disableAll(),this._axes.layers.set(this.layer),this.gameObject.add(this._axes);const e=this._axes.material;e&&e.depthTest!==void 0&&(e.depthTest=this.depthTest)}onDisable(){this._axes&&this.gameObject.remove(this._axes)}}VN([D()],Tc.prototype,"length",2);VN([D()],Tc.prototype,"depthTest",2);VN([D()],Tc.prototype,"isGizmo",2);class zN extends RA{constructor(){super(...arguments);r(this,"from");r(this,"to");r(this,"hint");r(this,"desiredDistance",1)}onEnable(){}update(){if(!this.from||!this.to||!this.hint)return;const e=_e(this.to).clone(),t=_e(this.from).clone(),i=e.distanceTo(t),I=e.clone();I.sub(t);const o=t.clone();o.add(e),o.multiplyScalar(.5);const s=_e(this.hint).clone();s.sub(o);const n=new w;n.crossVectors(s,I),n.crossVectors(I,n),n.normalize();const C=i*.5,a=Math.max(this.desiredDistance,C),B=Math.sqrt(a*a-C*C),Q=n.clone();Q.multiplyScalar(B),Q.add(o),EI(this.gameObject,Q);const E=o.clone();E.sub(n),this.gameObject.lookAt(E)}}const QG=IA("debugusdzbehaviours");class RS{constructor(){r(this,"behaviours",[]);r(this,"behaviourComponents",[]);r(this,"behaviourComponentsCopy",[])}get extensionName(){return"Behaviour"}addBehavior(A){this.behaviours.push(A)}onBeforeBuildDocument(A){const e=[];return A.root.traverse(t=>{aA.foreachComponent(t,i=>{var o;const I=i;if(typeof I.createBehaviours=="function"||typeof I.beforeCreateDocument=="function"||typeof I.afterCreateDocument=="function"||typeof I.afterSerialize=="function"){this.behaviourComponents.push(I);const s=(o=I.beforeCreateDocument)==null?void 0:o.call(I,this,A);s instanceof Promise&&e.push(s)}},!1)}),QG&&console.log("onBeforeBuildDocument: all components",this.behaviourComponents),Promise.all(e)}onExportObject(A,e,t){var i;for(const I of this.behaviourComponents)QG&&console.log("onExportObject: createBehaviours",I),(i=I.createBehaviours)==null||i.call(I,this,e,t)}onAfterBuildDocument(A){for(const e of this.behaviourComponents)typeof e.afterCreateDocument=="function"&&e.afterCreateDocument(this,A);this.behaviourComponentsCopy=this.behaviourComponents.slice(),this.behaviourComponents.length=0}onAfterHierarchy(A,e){var t;if((t=this.behaviours)!=null&&t.length){e.beginBlock('def Scope "Behaviors"');for(const i of this.behaviours)i.writeTo(this,A.document,e);e.closeBlock()}}async onAfterSerialize(A){QG&&console.log("onAfterSerialize behaviours",this.behaviourComponentsCopy);for(const e of this.behaviourComponentsCopy)typeof e.afterSerialize=="function"&&(e.afterSerialize.constructor.name==="AsyncFunction"?await e.afterSerialize(this,A):e.afterSerialize(this,A));this.behaviours.length=0}}var UIA=Object.defineProperty,RIA=Object.getOwnPropertyDescriptor,XN=(g,A,e,t)=>{for(var i=t>1?void 0:t?RIA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&UIA(A,e,i),i},Ak;const eP=(Ak=class extends hI{constructor(){super(...arguments);r(this,"threshold");r(this,"intensity");r(this,"scatter");r(this,"selectiveBloom")}get typeName(){return"Bloom"}init(){this.threshold.defaultValue=1,this.intensity.defaultValue=0,this.scatter.defaultValue=.2,this.selectiveBloom?(this.threshold.valueProcessor=A=>A,this.intensity.valueProcessor=A=>A,this.scatter.valueProcessor=A=>1*Math.PI*(1-A)):(this.threshold.valueProcessor=A=>A,this.intensity.valueProcessor=A=>A,this.scatter.valueProcessor=A=>100*(1-A))}onCreateEffect(){let A;if(this.selectiveBloom==null&&(this.selectiveBloom=eP.useSelectiveBloom),this.selectiveBloom){const e=A=new KY(this.context.scene,this.context.mainCamera,{blendFunction:We.ADD,mipmapBlur:!0,luminanceThreshold:this.threshold.value,luminanceSmoothing:this.scatter.value,intensity:this.intensity.value});e.inverted=!0}else A=new uN({blendFunction:We.ADD,mipmapBlur:!0,luminanceThreshold:this.threshold.value,luminanceSmoothing:this.scatter.value,intensity:this.intensity.value});return this.intensity.onValueChanged=e=>{A.intensity=e},this.threshold.onValueChanged=e=>{A.luminanceMaterial.threshold=e},this.scatter.onValueChanged=e=>{A.luminancePass.enabled=!0,A.luminanceMaterial.smoothing=e},A}},r(Ak,"useSelectiveBloom",!1),Ak);let CQ=eP;XN([D(qe)],CQ.prototype,"threshold",2);XN([D(qe)],CQ.prototype,"intensity",2);XN([D(qe)],CQ.prototype,"scatter",2);us("Bloom",CQ);const lE="NEEDLE_progressive",nI=IA("debugprogressive"),EG=Symbol("needle-progressive-texture"),PE=new Map;if(nI){let g=function(){A+=1,Ci(`Toggle LOD level: ${A}<br/>Registered objects: ${PE.size}`),console.log("Toggle LOD level",A,PE);const t=st.Current;PE.forEach((i,I)=>{for(const o of i.keys){const s=I[o];if(s instanceof ue){const n=Kt.getMeshLODInformation(s),C=n?Math.min(A,n.lods.length):0;I["DEBUG:LOD"]=C,Kt.assignMeshLOD(t,i.sourceId,I,C),n&&(e=Math.max(e,n.lods.length-1))}else if(I instanceof be){Kt.assignTextureLOD(t,i.sourceId,I,A);break}}}),A>=e&&(A=-1)},A=-1,e=2;window.addEventListener("keyup",t=>{t.key==="p"&&g()}),st.registerCallback(di.ContextCreated,t=>{const i=document.createElement("button");i.innerText="Toggle Progressive",i.onclick=g,t.context.menu.appendChild(i)})}function Yq(g,A,e){var i;if(!nI)return;PE.has(g)||PE.set(g,{keys:[],sourceId:e});const t=PE.get(g);((i=t==null?void 0:t.keys)==null?void 0:i.includes(A))==!1&&t.keys.push(A)}const VI=class{constructor(A,e,t){r(this,"parser");r(this,"sourceId");r(this,"context");this.parser=A,this.sourceId=e,this.context=t}get name(){return lE}static getMeshLODInformation(A){const e=this.getAssignedLODInformation(A);return e!=null&&e.key?this.lodInfos.get(e.key):null}static hasLODLevelAvailable(A,e){var I;if(A instanceof be){for(const o of Object.keys(A)){const s=A[o];if(s instanceof fe&&this.hasLODLevelAvailable(s,e))return!0}return!1}else if(A instanceof bI){for(const o of A.children)if(o instanceof lA&&this.hasLODLevelAvailable(o,e))return!0}let t,i;if(A instanceof lA?t=A.geometry:A instanceof fe&&(t=A),t&&(I=t==null?void 0:t.userData)!=null&&I.LODS){const o=t.userData.LODS;if(i=this.lodInfos.get(o.key),e===void 0)return i!=null;if(i)return Array.isArray(i.lods)?e<i.lods.length:e===0}return!1}static assignMeshLOD(A,e,t,i){if(!t)return Promise.resolve(null);if(t instanceof lA){const I=t.geometry,o=this.getAssignedLODInformation(I);if(!o)return Promise.resolve(null);Md(t)||FD(t,t.geometry);const s=this.onProgressiveLoadStart(A,e,t,null);return t["LOD:requested level"]=i,VI.getOrLoadLOD(A,e,I,i).then(n=>{if(t["LOD:requested level"]===i){if(delete t["LOD:requested level"],Array.isArray(n)){const C=o.index||0;n=n[C]}n&&I!=n&&(nI=="verbose"&&console.log("Progressive Mesh "+t.name+" loaded",I,"→",n,`
|
|
5508
|
+
`))}for(const y of m){const U=i.get(y);U&&N.set(y,U)}return N},E=function(m){const N=Q(m),y=n(N);return C(N,y,m)};const c=t.skinnedMesh.skeleton,d=new Array;for(const m in c.bones){const N=c.bones[m],y=c.boneInverses[m];d.push({bone:N,inverse:y})}for(const m of $H(c.bones))d.push({bone:m,inverse:m.matrixWorld.clone().invert()});const l=d[0].bone.parent;l||console.error("No bone parent found for skinned mesh during USDZ export",t.skinnedMesh),d.sort((m,N)=>_E(m.bone,l)>_E(N.bone,l)?1:-1);const h=[],p=[],u=[],f=[];for(const{bone:m}of d)h.push(m.matrix.clone()),p.push(m.position),u.push(m.quaternion),f.push(m.scale);const k=d.map(m=>'"'+_E(m.bone,l)+'"').join(", "),G=d.map(m=>GE(m.inverse.clone().invert())).join(", ");A.beginBlock('def Skeleton "Rig"'),A.appendLine(`uniform matrix4d[] bindTransforms = [${G}]`),A.appendLine(`uniform token[] joints = [${k}]`),A.appendLine('uniform token purpose = "guide"'),A.appendLine(`uniform matrix4d[] restTransforms = [${h.map(m=>GE(m)).join(", ")}]`),A.appendLine(`matrix4d xformOp:transform = ${GE(new GA)}`),A.appendLine('uniform token[] xformOpOrder = ["xformOp:transform"]');const M=E(d.map(m=>m.bone));if(hn){let m=1e7,N=0;for(const y of((I=M.position)==null?void 0:I.keys())??[])m=Math.min(m,y),N=Math.max(N,y);console.log("Time samples",m,N,M)}if(A.beginBlock('def SkelAnimation "_anim"'),A.appendLine(`uniform token[] joints = [${k}]`),A.appendLine(`quatf[] rotations = [${B(u)}]`),M&&M.quaternion){A.beginBlock("quatf[] rotations.timeSamples = {","");const m=s(M.quaternion);for(const N of m)A.appendLine(N);A.closeBlock()}if(A.appendLine(`half3[] scales = [${a(f)}]`),M&&M.scale){A.beginBlock("half3[] scales.timeSamples = {","");const m=o(M.scale);for(const N of m)A.appendLine(N);A.closeBlock()}if(A.appendLine(`float3[] translations = [${a(p)}]`),M&&M.position){A.beginBlock("float3[] translations.timeSamples = {","");const m=o(M.position);for(const N of m)A.appendLine(N);A.closeBlock()}A.closeBlock(),A.closeBlock()}}onSerialize(A,e){var a;if(!this.model)return;const t=this.dict.get(this.object);if(t)for(let B=0;B<t.length;B++)t[B]===void 0&&(t[B]=new Vi(null,this.object,null));this.skinnedMeshExport(A,e);const i=this.object,I=this.dict.get(i);if(!I||i.isSkinnedMesh)return;zM&&console.log("SERIALIZE",this.model.name,this.object.type,I);const o=new GA;A.appendLine("matrix4d xformOp:transform.timeSamples = {"),A.indent++;const s=new Array;let n=0;for(let B=0;B<I.length;B++){if(s.push(n),I[B]===void 0){console.error("Got an undefined transform data, this is likely a bug.",i,I);continue}n+=I[B].getDuration()+Vi.animationDurationPadding}const C=Intl.NumberFormat("en-US",{maximumFractionDigits:3,minimumFractionDigits:0,useGrouping:!1});for(let B=0;B<I.length;B++){const Q=I[B];if(!Q)continue;const E=s[B];{const c=Q.getSortedTimesArray();if(!c||c.length===0){console.error("got an animated object but no time values?",i,Q);continue}{const d=((a=Q.clip)==null?void 0:a.name)??"rest",l=Q.getDuration();hn&&console.log("Write .timeSamples:",d,E,l,I),A.appendLine("# "+d+": start="+C.format(E*Q.frameRate)+", length="+C.format(l*Q.frameRate)+", frames="+Q.getFrames())}for(const{time:d,translation:l,rotation:h,scale:p}of Q.getValues(c)){o.compose(l,h,p);const f=`${C.format((E+d)*Q.frameRate)}: ${GE(o)},`;A.appendLine(f)}}}A.indent--,A.appendLine("}")}}var LgA=Object.defineProperty,_gA=Object.getOwnPropertyDescriptor,PO=(g,A,e,t)=>{for(var i=t>1?void 0:t?_gA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&LgA(A,e,i),i};const Tq=IA("debugpost");class qe{constructor(A){r(this,"_active",!0);r(this,"_value");r(this,"_valueRaw");r(this,"_defaultValue");r(this,"valueProcessor");r(this,"onValueChanged");this._value=A,this._defaultValue=A,this._valueRaw=A}get overrideState(){return this._active}set overrideState(A){if(this._active===A)return;this._active=A;const e=A?this._valueRaw:this._defaultValue;this.processValue(e,!0)}get value(){return this._valueRaw}set value(A){this.processValue(A,!1)}set defaultValue(A){this._defaultValue=A}__init(){this.processValue(this._valueRaw,!0)}processValue(A,e){if(A==null||!e&&this.testIfValueChanged(A)===!1)return;const t=this._value;if(Tq){let i=!0;if(typeof t=="number"&&typeof A=="number"){const I=t==null?void 0:t.toFixed(4),o=A==null?void 0:A.toFixed(4);I!=o?i=!0:i=!1}i&&console.log("VolumeParameter: value changed from",t,"to",A)}!this._active&&this._defaultValue!==void 0?(this._value=this._defaultValue,A=this._defaultValue,this._valueRaw=A):(this._valueRaw=A,this._active&&this.valueProcessor&&(A=this.valueProcessor(A)),this._value=A),this.onValueChanged?this.onValueChanged(A,t,this):Tq&&console.log("VolumeParameter: onValueChanged not set")}testIfValueChanged(A){return this._valueRaw!==A}}PO([D()],qe.prototype,"overrideState",1);PO([D()],qe.prototype,"value",1);var TgA=Object.defineProperty,HgA=Object.getOwnPropertyDescriptor,YgA=(g,A,e,t)=>{for(var i=t>1?void 0:t?HgA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&TgA(A,e,i),i};const OgA=IA("debugpost");class hI extends RA{constructor(e=void 0){super();r(this,"active",!0);r(this,"_result");r(this,"_didCreateVolumeParameters",!1);if(e){this.ensureVolumeParameters();for(const t of Object.keys(e)){const i=e[t],I=this[t];I instanceof qe&&(I.value=i)}}}onEnable(){this.__internalDidAwakeAndStart&&(this.active=!0)}onDisable(){this.active=!1}init(){}apply(){var e;return this.ensureVolumeParameters(),this._result||(this._result=(e=this.onCreateEffect)==null?void 0:e.call(this)),this._result&&this.initParameters(),this._result}unapply(){}dispose(){OgA&&console.warn("DISPOSE",this),this._result&&(Array.isArray(this._result)?this._result.forEach(e=>e.dispose()):this._result.dispose()),this._result=void 0}initParameters(){const e=Object.keys(this);for(const t of e){const i=this[t];i instanceof qe&&i.__init()}}onAfterDeserialize(e,t){if(typeof e=="object"){const i=this.$serializedTypes;if(i){for(const I of Object.keys(i))if(i[I]===qe){const s=e[I];if(s!==void 0){const n=this[I];n.value=s}}}}}onEditorModification(e){const t=e.propertyName;if(this[t]instanceof qe){const i=e.value;return this[t].value=i,!0}}ensureVolumeParameters(){if(this._didCreateVolumeParameters)return;this._didCreateVolumeParameters=!0;const e=this.$serializedTypes;if(e)for(const t of Object.keys(e))e[t]===qe&&(this[t]||(this[t]=new qe))}}YgA([D()],hI.prototype,"active",2);var PgA=Object.defineProperty,WgA=Object.getOwnPropertyDescriptor,ZgA=(g,A,e,t)=>{for(var i=t>1?void 0:t?WgA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&PgA(A,e,i),i};const jgA=IA("debugpost"),XM={};function us(g,A){XM[g]=A}function VgA(g){return g.__type in XM?XM[g.__type]:(jgA&&g.__type&&console.warn("Unknown postprocessing type",g.__type,g),hI)}class Ju{constructor(){r(this,"components",[])}init(){var A;(A=this.components)==null||A.forEach(e=>e.init())}}ZgA([Uc([g=>VgA(g),hI])],Ju.prototype,"components",2);var zgA=Object.defineProperty,XgA=Object.getOwnPropertyDescriptor,$gA=(g,A,e,t)=>{for(var i=t>1?void 0:t?XgA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&zgA(A,e,i),i};class bu extends hI{constructor(){super(...arguments);r(this,"preset")}get typeName(){return"Antialiasing"}onCreateEffect(){const e=new JY({preset:QE.HIGH,edgeDetectionMode:cN.DEPTH});return this.preset.onValueChanged=t=>{e.applyPreset(t)},e}}$gA([D(qe)],bu.prototype,"preset",2);us("Antialiasing",bu);const AIA=IA("debugusdz");class Cr{constructor(){r(this,"files",new Array)}static getName(A){var I;const e=A.split(".").pop();let i=(I=A.split(".").slice(0,-1).join(".").split("/").pop())==null?void 0:I.replace(".","_");return i||(i="Audio_"+Math.random().toString(36).substring(2,15)),Ps(i)+"."+e}get extensionName(){return"Audio"}onExportObject(A,e,t){const i=aA.getComponents(A,Di);if(i.length)for(const I of i){if(!I.clip||typeof I.clip!="string"||!I.playOnAwake)continue;const o=I.clip.split("/").pop()||"Audio",s=Cr.getName(I.clip),n=Ps(s);this.files.some(C=>C.path===I.clip)||this.files.push({path:I.clip,name:s}),t.quickLookCompatible||e.addEventListener("serialize",(C,a)=>{C.appendLine(),C.beginBlock(`def SpatialAudio "${n}"`,"(",!1),C.appendLine(`displayName = "${o}"`),C.closeBlock(")"),C.beginBlock(),C.appendLine(`uniform asset filePath = @audio/${s}@`),C.appendLine(`uniform token auralMode = "${I.spatialBlend>0?"spatial":"nonSpatial"}"`),C.appendLine(`uniform token playbackMode = "${I.loop?"loopFromStage":"onceFromStart"}"`),C.appendLine(`uniform float gain = ${I.volume}`),C.closeBlock()})}}async onAfterSerialize(A){for(const e of this.files){const t="audio/"+e.name;if(A.files[t]){AIA&&console.warn("Audio file with name "+t+" already exists in the context. Skipping.");continue}const o=await(await(await fetch(e.path)).blob()).arrayBuffer(),s=new Uint8Array(o);A.files[t]=s}}}const cB=IA("debugautosync"),BG=Symbol("syncerId");class eIA{constructor(){r(this,"_syncers",{})}getOrCreateSyncer(A){if(!A.guid)return null;if(this._syncers[A.guid])return this._syncers[A.guid];const e=new tIA(A);return e[BG]=A.guid,this._syncers[e[BG]]=e,e}removeSyncer(A){delete this._syncers[A[BG]]}}const YN=new eIA;class tIA{constructor(A){r(this,"comp");r(this,"hasChanges",!1);r(this,"changedProperties",{});r(this,"data",{});r(this,"_isReceiving",!1);r(this,"_isInit",!1);r(this,"onHandleSending",()=>{if(!this.hasChanges)return;this.hasChanges=!1;const A=this.comp.context.connection;if(!A||!A.isConnected||!A.isInRoom){for(const e in this.changedProperties)delete this.changedProperties[e];return}for(const e in this.data)delete this.data[e];this.data.guid=this.comp.guid;for(const e in this.changedProperties){const t=this.changedProperties[e];delete this.changedProperties[e],this.data[e]=t}A.send(this.networkingKey,this.data,es.Queued)});r(this,"onHandleReceiving",A=>{if(cB&&console.log("RECEIVE",this.comp.name,this.comp.guid,A),!this._isInit||!this.comp)return;const e=A.guid;if(!(e&&e!==this.comp.guid)){cB&&console.log("RECEIVED",this.comp.name,this.comp.guid,A);try{this._isReceiving=!0;for(const t in A){if(t==="guid")continue;const i=A[t];this.comp[t]=i,cB&&console.log("SET",t,i)}}catch(t){console.error(t)}finally{this._isReceiving=!1}}});this.comp=A}get networkingKey(){return this.comp.guid}init(A){if(this._isInit)return;this._isInit=!0,this.comp=A,this.comp.context.post_render_callbacks.push(this.onHandleSending),this.comp.context.connection.beginListen(this.networkingKey,this.onHandleReceiving);const e=this.comp.context.connection.tryGetState(this.comp.guid);e&&this.onHandleReceiving(e)}destroy(){this._isInit&&(this.comp.context.post_render_callbacks.splice(this.comp.context.post_render_callbacks.indexOf(this.onHandleSending),1),this.comp.context.connection.stopListen(this.networkingKey,this.onHandleReceiving),this.comp=null,this._isInit=!1)}notifyChanged(A,e){this._isReceiving||(cB&&console.log("Property changed: "+A,e),this.hasChanges=!0,this.changedProperties[A]=e)}}function iIA(g,A){let e=A!==g;return!e&&g&&A&&(Array.isArray(g)&&Array.isArray(A)||typeof g=="object"&&typeof A=="object")&&(e=!0),e}const Yh=Symbol("AutoSyncHandler");function gIA(g){if(g[Yh])return g[Yh];const A=YN.getOrCreateSyncer(g);return A==null||A.init(g),g[Yh]=A,A}function IIA(g){const A=g[Yh];A&&(YN.removeSyncer(A),A.destroy(),delete g[Yh])}const ON=function(g){return function(A,e){var a;let t="";typeof e=="string"?t=e:t=e.name;let i=null,I;typeof g=="string"?I=A[g]:typeof g=="function"&&(I=g);const o=A,s=o.__internalAwake;if(typeof s!="function"){(cB||he())&&console.error('@syncField can currently only used on Needle Engine Components, custom object of type "'+((a=A==null?void 0:A.constructor)==null?void 0:a.name)+'" is not supported',A);return}cB&&console.log(t);const n=Symbol(t);o.__internalAwake=function(){if(this[n]!==void 0)return;this[n]=this[t],i=YN.getOrCreateSyncer(this);const B=Object.getOwnPropertyDescriptor(this,t);if((B==null?void 0:B.set)===void 0){let Q=!1;Object.defineProperty(this,t,{set:function(E){var d;const c=this[n];if(this[n]=E,Q){he()&&console.warn("Recursive call detected",t);return}Q=!0;try{const l=iIA(E,c);cB&&console.log("SyncField assignment",t,"changed?",l,E),l&&(I==null?void 0:I.call(this,E,c))!==!1&&((d=gIA(this))==null||d.notifyChanged(t,E))}finally{Q=!1}},get:function(){return this[n]},configurable:!0,enumerable:!0})}i==null||i.init(this),s.call(this)};const C=o.__internalDestroy;o.__internalDestroy=function(){IIA(this),C.call(this)}}};var oIA=Object.defineProperty,sIA=Object.getOwnPropertyDescriptor,kS=(g,A,e,t)=>{for(var i=t>1?void 0:t?sIA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&oIA(A,e,i),i};const uo=IA("debugplayersync");class Lc extends RA{constructor(){super(...arguments);r(this,"autoSync",!0);r(this,"asset");r(this,"onPlayerSpawned");r(this,"_localInstance");r(this,"onJoinedRoom",()=>{uo&&console.log("PlayerSync.joinedRoom. autoSync is set to "+this.autoSync),this.autoSync&&this.getInstance()})}awake(){this.watchTabVisible(),this.onPlayerSpawned||(this.onPlayerSpawned=new Bg)}onEnable(){this.context.connection.beginListen(It.RoomStateSent,this.onJoinedRoom),this.context.connection.beginListen(It.JoinedRoom,this.onJoinedRoom),this.context.connection.isInRoom&&this.onJoinedRoom()}onDisable(){this.context.connection.stopListen(It.RoomStateSent,this.onJoinedRoom),this.context.connection.stopListen(It.JoinedRoom,this.onJoinedRoom)}async getInstance(){var t,i,I,o,s,n;if(this._localInstance)return this._localInstance;if(uo&&console.log("PlayerSync.createInstance",(t=this.asset)==null?void 0:t.uri),!((i=this.asset)!=null&&i.asset)&&!((I=this.asset)!=null&&I.uri))return console.error('PlayerSync: can not create an instance because "asset" is not set!'),null;this._localInstance=(o=this.asset)==null?void 0:o.instantiateSynced({parent:this.gameObject},!0);const e=await this._localInstance;if(e){const C=aA.getComponent(e,os);C?(C.owner=this.context.connection.connectionId,(s=this.onPlayerSpawned)==null||s.invoke(e)):(this._localInstance=void 0,console.error("<strong>Failed finding PlayerState on "+((n=this.asset)==null?void 0:n.uri)+"</strong>: please make sure the asset has a PlayerState component!"),aA.destroySynced(e))}else this._localInstance=void 0,console.warn("PlayerSync: failed instantiating asset!");return this._localInstance}destroyInstance(){var e;(e=this._localInstance)==null||e.then(t=>(uo&&console.log("PlayerSync.destroyInstance",t),aA.destroySynced(t))),this._localInstance=void 0}watchTabVisible(){window.addEventListener("visibilitychange",e=>{if(document.visibilityState==="visible")for(let t=os.all.length-1;t>=0;t--){const i=os.all[t];(!i.owner||!this.context.connection.userIsInRoom(i.owner))&&i.doDestroy()}})}}kS([D()],Lc.prototype,"autoSync",2);kS([D(tt)],Lc.prototype,"asset",2);kS([D(Bg)],Lc.prototype,"onPlayerSpawned",2);var WO=(g=>(g.OwnerChanged="ownerChanged",g))(WO||{}),jl;const vg=(jl=class extends RA{constructor(){super(...arguments);r(this,"onOwnerChangeEvent",new Bg);r(this,"onFirstOwnerChangeEvent",new Bg);r(this,"hasOwner",!1);r(this,"owner");r(this,"dontDestroy",!1);r(this,"onUserLeftRoom",A=>{if(A.userId===this.owner){uo&&console.log("PLAYERSYNC LEFT",this.owner),this.doDestroy();return}})}static get all(){return vg._all}static get local(){return vg._local}static getFor(A){if(A instanceof uA)return aA.getComponentInParent(A,vg);if(A instanceof RA)return aA.getComponentInParent(A.gameObject,vg)}static isLocalPlayer(A){const e=vg.getFor(A);return(e==null?void 0:e.isLocalPlayer)??!1}static addEventListener(A,e){return this._callbacks[A]||(this._callbacks[A]=[]),this._callbacks[A].push(e),e}static removeEventListener(A,e){if(!this._callbacks[A])return;const t=this._callbacks[A].indexOf(e);t>=0&&this._callbacks[A].splice(t,1)}static dispatchEvent(A,e){if(this._callbacks[A])for(const t of this._callbacks[A])t(e)}get isLocalPlayer(){return this.owner===this.context.connection.connectionId}onOwnerChange(A,e){var o,s;uo&&console.log("PlayerSync.onOwnerChange",this,"newOwner",A,"oldOwner",e);const t=vg._local.indexOf(this);t>=0&&vg._local.splice(t,1);const i={playerState:this,oldValue:e,newValue:A};if(this.hasOwner||(this.hasOwner=!0,(o=this.onFirstOwnerChangeEvent)==null||o.invoke(i)),(s=this.onOwnerChangeEvent)==null||s.invoke(i),this.owner===this.context.connection.connectionId){vg._local.push(this);const n=new CustomEvent("local-owner-changed",{detail:i});this.dispatchEvent(n)}const I=new CustomEvent("owner-changed",{detail:i});this.dispatchEvent(I),vg.dispatchEvent("ownerChanged",I)}awake(){vg.all.push(this),uo&&console.log("Registered new PlayerState",this.guid,vg.all.length-1,vg.all),this.context.connection.beginListen(It.UserLeftRoom,this.onUserLeftRoom)}async start(){uo&&console.log("PLAYERSTATE.START, owner: "+this.owner,this.context.connection.usersInRoom([])),this.owner?(this.context.connection.isInRoom||await Os(300),this.context.connection.userIsInRoom(this.owner)==!1&&(uo&&console.log(`PlayerSync.start → doDestroy "${this.name}" because user "${this.owner}" is not in room anymore...`,"Currently in room:",...this.context.connection.usersInRoom()),this.doDestroy())):this.owner||(uo&&console.warn("PlayerState.start → owner is undefined!",this.name),setTimeout(()=>{!this.destroyed&&!this.owner?this.dontDestroy?uo&&console.warn("PlayerState.start → owner is still undefined but dontDestroy is set to true",this.name):(uo&&console.warn(`PlayerState.start → owner is still undefined: destroying "${this.name}" instance now`),this.doDestroy()):uo&&console.log("PlayerState.start → owner is assigned",this.owner)},2e3))}doDestroy(){uo&&console.log("PlayerSync.doDestroy → syncDestroy",this.name),ES(this.gameObject,this.context.connection)}onDestroy(){if(this.context.connection.stopListen(It.UserLeftRoom,this.onUserLeftRoom),vg.all.splice(vg.all.indexOf(this),1),this.isLocalPlayer){const A=vg._local.indexOf(this);A>=0&&vg._local.splice(A,1)}}},r(jl,"_all",[]),r(jl,"_local",[]),r(jl,"_callbacks",{}),jl);let os=vg;kS([ON(os.prototype.onOwnerChange)],os.prototype,"owner",2);const nIA=IA("debugavatar"),Rs=class extends RA{constructor(){super(...arguments);r(this,"connectionId");r(this,"avatar")}static getAvatar(e){return e>=0&&e<Rs.instances.length?Rs.instances[e]:null}static onAvatarMarkerCreated(e){return Rs._onNewAvatarMarkerAdded.push(e),e}static onAvatarMarkerDestroyed(e){return Rs._onAvatarMarkerDestroyed.push(e),e}awake(){Rs.instances.push(this),nIA&&console.log(this);for(const e of Rs._onNewAvatarMarkerAdded)e({avatarMarker:this,gameObject:this.gameObject})}onDestroy(){Rs.instances.splice(Rs.instances.indexOf(this),1);for(const e of Rs._onAvatarMarkerDestroyed)e({avatarMarker:this,gameObject:this.gameObject})}isLocalAvatar(){return this.connectionId===this.context.connection.connectionId}};let ng=Rs;r(ng,"instances",[]),r(ng,"_onNewAvatarMarkerAdded",[]),r(ng,"_onAvatarMarkerDestroyed",[]);var CIA=Object.defineProperty,aIA=Object.getOwnPropertyDescriptor,rIA=(g,A,e,t)=>{for(var i=t>1?void 0:t?aIA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&CIA(A,e,i),i};const cE=IA("debugxrflags"),ZO=IA("disablexrflags");ZO&&console.warn("XRFlags are disabled");var fn=(g=>(g[g.Never=0]="Never",g[g.Browser=1]="Browser",g[g.AR=2]="AR",g[g.VR=4]="VR",g[g.FirstPerson=8]="FirstPerson",g[g.ThirdPerson=16]="ThirdPerson",g[g.All=4294967295]="All",g))(fn||{});const qK=class{constructor(){r(this,"Mask",17)}Has(A){return(this.Mask&A)!==0}Set(A){cE&&console.warn("Set XR flag state to",A),this.Mask=A,Do.Apply()}Enable(A){this.Mask|=A,Do.Apply()}Disable(A){this.Mask&=~A,Do.Apply()}Toggle(A){this.Mask^=A,Do.Apply()}EnableAll(){this.Mask=-1,Do.Apply()}DisableAll(){this.Mask=0,Do.Apply()}};let Hg=qK;r(Hg,"Global",new qK);var Vl;const rC=(Vl=class extends RA{constructor(){super(...arguments);r(this,"visibleIn")}static Apply(){for(const A of this.registry)A.UpdateVisible(Hg.Global)}awake(){rC.registry.push(this)}onEnable(){rC.firstApply?this.UpdateVisible(Hg.Global):(rC.firstApply=!0,rC.Apply())}onDestroy(){const A=rC.registry.indexOf(this);A>=0&&rC.registry.splice(A,1)}get isOn(){return this.gameObject.visible}UpdateVisible(A=null){if(ZO)return;let e;const t=A;if(t&&typeof t=="number"&&(console.assert(typeof t=="number","XRFlag.UpdateVisible: state must be a number",t),cE&&console.log(t),rC.buffer.Mask=t,A=rC.buffer),A instanceof Hg?(cE&&console.warn(this.name,"use passed in mask",A.Mask,this.visibleIn),e=A.Has(this.visibleIn)):(cE&&console.log(this.name,"use global mask"),Hg.Global.Has(this.visibleIn)),e!==void 0)if(e)cE&&console.log(this.name,"is visible",this.gameObject.uuid),aA.setActive(this.gameObject,!0);else{if(cE&&console.log(this.name,"is not visible",this.gameObject.uuid),!this.gameObject.visible)return;this.gameObject.visible=!1}}},r(Vl,"registry",[]),r(Vl,"firstApply"),r(Vl,"buffer",new Hg),Vl);let Do=rC;rIA([D()],Do.prototype,"visibleIn",2);var BIA=Object.defineProperty,QIA=Object.getOwnPropertyDescriptor,PN=(g,A,e,t)=>{for(var i=t>1?void 0:t?QIA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&BIA(A,e,i),i};const ql=IA("debugwebxr"),Hq=new MA().setFromAxisAngle(new w(0,1,0),Math.PI);class oQ extends RA{constructor(){super(...arguments);r(this,"head");r(this,"leftHand");r(this,"rightHand");r(this,"_syncTransforms")}async onEnterXR(e){if(!this.activeAndEnabled)return;ql&&console.warn("AVATAR ENTER XR",this.guid,this.sourceId,this,this.activeAndEnabled),this._syncTransforms&&(this._syncTransforms.length=0),await this.prepareAvatar();const t=os.getFor(this);if(t!=null&&t.owner){const i=this.gameObject.addNewComponent(ng);i.avatar=this.gameObject,i.connectionId=t.owner}else this.context.connection.isConnected?console.error("No player state found for avatar",this):t&&!this.context.connection.isConnected&&(t.dontDestroy=!0)}onLeaveXR(e){const t=this.gameObject.getComponent(ng);t&&t.destroy()}onUpdateXR(e){var n,C;if(!this.activeAndEnabled)return;const t=os.isLocalPlayer(this);if(!t)return;const i=e.xr;if(i.rig&&i.rig.gameObject!==this.gameObject.parent&&(this.gameObject.position.set(0,0,0),this.gameObject.rotation.set(0,0,0),this.gameObject.scale.set(1,1,1),i.rig.gameObject.add(this.gameObject)),this._syncTransforms&&t)for(const a of this._syncTransforms)a.fastMode=!0,a.isOwned()||a.requestOwnership();if(this.head&&this.context.mainCamera){const a=this.head.asset;if(a.position.copy(this.context.mainCamera.position),a.quaternion.copy(this.context.mainCamera.quaternion),a.quaternion.x*=-1,this.context.time.frameCount%10===0){const B=aA.getComponentsInChildren(this.head.asset,Do);for(const Q of B)Q.enabled=!1,Q.gameObject.visible=!1}}const I=e.xr.leftController,o=(n=this.leftHand)==null?void 0:n.asset;I&&o&&(o.position.copy(I.gripPosition),o.quaternion.copy(I.gripQuaternion),o.quaternion.multiply(Hq),o.visible=I.isTracking);const s=e.xr.rightController;if(s&&((C=this.rightHand)!=null&&C.asset)){const a=this.rightHand.asset;a.position.copy(s.gripPosition),a.quaternion.copy(s.gripQuaternion),a.quaternion.multiply(Hq),a.visible=s.isTracking}}onBeforeRender(){this.context.time.frame%10===0&&this.updateRemoteAvatarVisibility()}updateRemoteAvatarVisibility(){var e,t,i;if(this.context.connection.isConnected){const I=os.getFor(this);if(I&&I.isLocalPlayer==!1){const o=Se.getXRSync(this.context);if(o&&o.hasState(I.owner)){this.tryFindAvatarObjectsIfMissing();const s=(e=this.leftHand)==null?void 0:e.asset;s&&(s.visible=(o==null?void 0:o.isTracking(I.owner,"left"))??!1);const n=(t=this.rightHand)==null?void 0:t.asset;n&&(n.visible=(o==null?void 0:o.isTracking(I.owner,"right"))??!1)}if((i=this.head)!=null&&i.asset){const s=aA.getComponentsInChildren(this.head.asset,Do);for(const n of s)n.enabled=!1,n.gameObject.visible=!0}}}}tryFindAvatarObjectsIfMissing(){if(!this.head||!this.leftHand||!this.rightHand){const e={head:this.head,leftHand:this.leftHand,rightHand:this.rightHand};z2.tryFindAvatarObjects(this.gameObject,this.sourceId||"",e),e.head&&(this.head=e.head),e.leftHand&&(this.leftHand=e.leftHand),e.rightHand&&(this.rightHand=e.rightHand)}}async prepareAvatar(){if(this.tryFindAvatarObjectsIfMissing(),this.head)this.head instanceof uA&&(this.head=new tt("",this.sourceId,this.head));else{const e=new uA;e.name="Head";const t=Du.createPrimitive(_B.Cube);e.add(t),this.gameObject.add(e),this.head=new tt("",this.sourceId,e),ql&&console.log("Create head",e)}if(this.rightHand)this.rightHand instanceof uA&&(this.rightHand=new tt("",this.sourceId,this.rightHand));else{const e=new uA;e.name="Right Hand",this.gameObject.add(e),this.rightHand=new tt("",this.sourceId,e),ql&&console.log("Create right hand",e)}if(this.leftHand)this.leftHand instanceof uA&&(this.leftHand=new tt("",this.sourceId,this.leftHand));else{const e=new uA;e.name="Left Hand",this.gameObject.add(e),this.leftHand=new tt("",this.sourceId,e),ql&&console.log("Create left hand",e)}await this.loadAvatarObjects(this.head,this.leftHand,this.rightHand),os.isLocalPlayer(this.gameObject)&&(this._syncTransforms=aA.getComponentsInChildren(this.gameObject,nr))}async loadAvatarObjects(e,t,i){const I=e.loadAssetAsync(),o=t.loadAssetAsync(),s=i.loadAssetAsync(),n=new Array;I&&n.push(I),o&&n.push(o),s&&n.push(s);const C=await au(n);ql&&console.log("Avatar loaded results:",C)}}PN([D(tt)],oQ.prototype,"head",2);PN([D(tt)],oQ.prototype,"leftHand",2);PN([D(tt)],oQ.prototype,"rightHand",2);class Jn{static Add(A,e,t=null){if(e){for(const i of this.Pois)if(i.obj===e)return;this.Pois.push({obj:e,avatar:t}),this.LastChangeTime=A.time.time}}static Remove(A,e){var t;if(e){for(const i of this.Pois)if(i.obj===e){this.Pois.splice(this.Pois.indexOf(i),1),this.LastChangeTime=(A==null?void 0:A.time.time)??((t=ve.Current)==null?void 0:t.time.time);return}}}}r(Jn,"Pois",[]),r(Jn,"LastChangeTime",0);class EIA{constructor(){r(this,"guid");r(this,"position",new w)}}class Jd extends RA{constructor(){super(...arguments);r(this,"target",null);r(this,"avatar",null);r(this,"_model",null);r(this,"_targetModel",new EIA);r(this,"_currentTargetObject",null);r(this,"_lastUpdateTime",0);r(this,"_lookDuration",0);r(this,"_lastPoiChangedTime",0)}set controlledTarget(e){this.target=e;const t=z.get("MoveRandom");if(t&&this.target){const i=aA.getComponent(this.target,t);i&&i.destroy()}}awake(){if(this.avatar=aA.getComponentInParent(this.gameObject,ng),this.avatar){const e=aA.getComponentInParent(this.gameObject,ng);this._model=new JN(this.context.connection,this.guid),e!=null&&e.isLocalAvatar&&this._model.requestOwnership()}this.context.connection.beginListen("avatar-look-target-changed",e=>{var t;this.target&&e&&e.guid===((t=this.avatar)==null?void 0:t.guid)&&EI(this.target,e.position)})}update(){var t;if((!this.context.connection.isConnected||(t=this._model)!=null&&t.hasOwnership)&&(Jn.LastChangeTime!==this._lastPoiChangedTime&&(this._lastPoiChangedTime=Jn.LastChangeTime,this._lookDuration=0),this.selectTarget(),this._currentTargetObject&&this.context.time.frameCount%10===0&&this.target)){const i=_e(this._currentTargetObject);EI(this.target,i),this.context.connection.isConnected&&this.avatar&&(this.context.connection.send("avatar-look-target-changed",this._targetModel),this._targetModel.guid=this.avatar.guid,this._targetModel.position.copy(i))}}selectTarget(){if(this.context.time.time-this._lastUpdateTime>this._lookDuration){this._lastUpdateTime=this.context.time.time,this._lookDuration=Math.random()*.5+.2;const t=Jn.Pois;if(t.length>0){const i=t[Math.floor(Math.random()*t.length)];if(i&&i.obj){if(i.avatar&&i.avatar===this.avatar)return;this._currentTargetObject=i.obj}}}}}const NE=IA("debugnetworkingstreams");var Mn=(g=>(g.Connected="peer-user-connected",g.StreamReceived="receive-stream",g.StreamEnded="call-ended",g.Disconnected="peer-user-disconnected",g.UserJoined="user-joined",g))(Mn||{});class jO{constructor(A,e){r(this,"type","call-ended");r(this,"userId");r(this,"direction");this.userId=A,this.direction=e}}class VO{constructor(A,e){r(this,"type","receive-stream");r(this,"stream");r(this,"target");this.stream=A,this.target=e}}class cIA{constructor(A,e){r(this,"guid");r(this,"peerId");r(this,"dontSave",!0);this.guid=A.id,this.peerId=e}}var zO=(g=>(g.Incoming="incoming",g.Outgoing="outgoing",g))(zO||{});class lIA extends kg{constructor(e,t,i){super();r(this,"userId");r(this,"direction");r(this,"call");r(this,"_stream",null);r(this,"_isDisposed",!1);this.userId=e,this.call=t,this.direction=i,this._stream=null,t.on("stream",I=>{if(NE&&console.log("Receive video",I.getAudioTracks(),I.getVideoTracks()),this._stream=I,i==="incoming"){const o=new VO(I,this);this.dispatchEvent(o)}}),t.on("close",()=>{this.dispatchEvent(new jO(e,i))})}get stream(){return this._stream}close(){this._isDisposed||(this._isDisposed=!0,this.call.close(),UC(this._stream))}get isOpen(){var e;return((e=this.call.peerConnection)==null?void 0:e.connectionState)==="connected"}get isOpening(){var e;return((e=this.call.peerConnection)==null?void 0:e.connectionState)==="connecting"}get isClosed(){return!this.isOpen}}const bE=class extends kg{constructor(e,t){super();r(this,"id");r(this,"context");r(this,"_peer");r(this,"_incomingCalls",[]);r(this,"_outgoingCalls",[]);r(this,"_enabled",!1);r(this,"_enabledPeer",!1);r(this,"onConnectRoomFn",this.onConnectRoom.bind(this));r(this,"onPeerConnectFn",this.onPeerConnect.bind(this));r(this,"onPeerReceiveCallFn",this.onPeerReceivingCall.bind(this));this.context=e,this.id=t,this.setupPeer(),navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia}static getOrCreate(e,t){if(bE.instances.has(t))return bE.instances.get(t);const i=new bE(e,t);return bE.instances.set(t,i),i}getMyPeerId(){if(this.context.connection.connectionId)return this.getPeerIdFromUserId(this.context.connection.connectionId)}getPeerIdFromUserId(e){return this.id+"-"+e}getUserIdFromPeerId(e){return e.substring(this.id.length+1)}makeCall(e,t){var o;const i={metadata:{userId:this.context.connection.connectionId}},I=(o=this._peer)==null?void 0:o.call(e,t,i);if(I)return this.registerCall(I,"outgoing")}get peer(){return this._peer}enable(){this._enabled||(this._enabled=!0,this.context.connection.beginListen(It.JoinedRoom,this.onConnectRoomFn),this.subscribePeerEvents())}disable(){this._enabled&&(this._enabled=!1,this.context.connection.stopListen(It.JoinedRoom,this.onConnectRoomFn),this.unsubscribePeerEvents())}onConnectRoom(){this.setupPeer()}setupPeer(){if(this.context.connection.connectionId&&!this._enabledPeer){if(this._enabledPeer=!0,!this._peer){const e=this.getMyPeerId();e?this._peer=Y2(e):console.error("Failed to setup peerjs because we dont have a connection id",this.context.connection.connectionId)}this._enabled&&this.subscribePeerEvents()}}subscribePeerEvents(){this._peer&&(this._peer.on("open",this.onPeerConnectFn),this._peer.on("call",this.onPeerReceiveCallFn))}unsubscribePeerEvents(){this._peer&&(this._peer.off("open",this.onPeerConnectFn),this._peer.off("call",this.onPeerReceiveCallFn))}onPeerConnect(e){NE&&console.log("Peer connected as",e),this.context.connection.send("peer-user-connected",new cIA(this,e))}onPeerReceivingCall(e){e.answer(),this.registerCall(e,"incoming")}registerCall(e,t){const i=e.metadata;(!i||!i.userId)&&console.error("Missing call metadata",e);const I=i.userId;t==="incoming"&&NE?console.log("Receive call from",e.metadata):NE&&console.log("Make call to",e.metadata);const o=t==="incoming"?this._incomingCalls:this._outgoingCalls,s=new lIA(I,e,t);return o.push(s),e.on("error",n=>{console.error("Call error",n)}),e.on("close",()=>{NE&&console.log("Call ended",e.metadata),e.close();const n=o.indexOf(s);n!==-1&&o.splice(n,1)}),s.addEventListener("call-ended",n=>{this.dispatchEvent(n)}),t==="incoming"&&(s.addEventListener("receive-stream",n=>{this.dispatchEvent(n)}),e.on("stream",()=>{let n=0;const C=setInterval(()=>{const a=n===0;!s.isOpen&&a&&(n+=1,clearInterval(C),s.close())},2e3)})),s}};let OE=bE;r(OE,"instances",new Map);class vu extends kg{constructor(e,t){super();r(this,"context");r(this,"peer");r(this,"_sendingStreams",new Map);r(this,"debug",!1);r(this,"onJoinedRoom",e=>{this.debug&&console.log(`${e.userId} joined room and I'm currently sending ${this._sendingStreams.size} streams`),this._sendingStreams.size>0&&this.updateSendingCalls()});r(this,"onReceiveStream",e=>{this.debug&&console.log("RECEIVE STREAM",e),this.dispatchEvent({type:"receive-stream",target:this,stream:e.stream,userId:e.userId})});r(this,"onCallEnded",e=>{this.dispatchEvent(e)});r(this,"onUserConnected",e=>{if(this.peer.id===e.guid){this.debug&&console.log("USER CONNECTED",e.guid,e);const t=this._sendingStreams.keys().next().value;this.peer.makeCall(e.peerId,t)}});r(this,"onUserLeft",e=>{this.stopCallsToUsersThatAreNotInTheRoomAnymore()});this.context=e,this.peer=t,NE&&(this.debug=!0)}static create(e){const t=OE.getOrCreate(e.context,e.context.connection.connectionId);return new vu(e.context,t)}startSendingStream(e){this._sendingStreams.has(e)?console.warn("Received start sending stream with stream that is already being sent"):(this._sendingStreams.set(e,[]),this.updateSendingCalls())}stopSendingStream(e){if(e){const t=this._sendingStreams.get(e);if(t){this.debug&&console.log("Closing calls",t);for(const i of t)i.close()}this._sendingStreams.delete(e),t&&this.debug&&console.log("Currently sending",this._sendingStreams)}}enable(){this.peer.enable(),this.peer.addEventListener("receive-stream",this.onReceiveStream),this.peer.addEventListener("call-ended",this.onCallEnded),this.context.connection.beginListen("peer-user-connected",this.onUserConnected),this.context.connection.beginListen(It.JoinedRoom,this.onJoinedRoom),this.context.connection.beginListen(It.UserJoinedRoom,this.onJoinedRoom),this.context.connection.beginListen(It.UserLeftRoom,this.onUserLeft)}disable(){this.peer.disable(),this.peer.removeEventListener("receive-stream",this.onReceiveStream),this.peer.removeEventListener("call-ended",this.onCallEnded),this.context.connection.stopListen("peer-user-connected",this.onUserConnected),this.context.connection.stopListen(It.JoinedRoom,this.onJoinedRoom),this.context.connection.stopListen(It.UserJoinedRoom,this.onJoinedRoom),this.context.connection.stopListen(It.UserLeftRoom,this.onUserLeft)}updateSendingCalls(){var i;let e=!1;const t=this.context.connection.connectionId;for(const I of this._sendingStreams.keys()){const o=this._sendingStreams.get(I)||[];for(const s of this.context.connection.usersInRoom()){if(s===t)continue;const n=o.find(C=>C.userId===s);if(!n||((i=n.stream)==null?void 0:i.active)===!1){this.debug&&console.log("Starting call to",s,t);const C=this.peer.makeCall(this.peer.getPeerIdFromUserId(s),I);C&&(e=!0,o.push(C))}}this._sendingStreams.set(I,o)}this.stopCallsToUsersThatAreNotInTheRoomAnymore(),e&&this.debug&&console.log("Currently sending",this._sendingStreams)}stopCallsToUsersThatAreNotInTheRoomAnymore(){for(const e of this._sendingStreams.keys()){const t=this._sendingStreams.get(e);if(t)for(let i=t.length-1;i>=0;i--){const I=t[i];this.context.connection.userIsInRoom(I.userId)||(I.close(),t.splice(i,1))}}}}function UC(g){if(g&&g instanceof MediaStream)for(const A of g.getTracks())A.stop()}var hIA=Object.defineProperty,dIA=Object.getOwnPropertyDescriptor,XO=(g,A,e,t)=>{for(var i=t>1?void 0:t?dIA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&hIA(A,e,i),i};const uIA="noVoip",pIA=IA("debugvoip");class sQ extends RA{constructor(){super(...arguments);r(this,"autoConnect",!1);r(this,"runInBackground",!0);r(this,"debug",!1);r(this,"_net");r(this,"_outputStream",null);r(this,"onJoinedRoom",async()=>{await Os(300),this.autoConnect&&!this.isSending&&this.connect()});r(this,"_incomingStreams",new Map);r(this,"onReceiveStream",e=>{const t=e.target.userId,i=e.stream,I=this._incomingStreams.get(t);if(I)I.srcObject=i,I.setAttribute("autoplay","true");else{const o=new Audio;this._incomingStreams.set(t,o),o.setAttribute("autoplay","true"),o.srcObject=i}});r(this,"onStreamEnded",e=>{const t=this._incomingStreams.get(e.userId);UC(t==null?void 0:t.srcObject),this._incomingStreams.delete(e.userId)});r(this,"onEnabledChanged",()=>{for(const e of this._incomingStreams){const t=e[1];t.muted=!this.enabled}});r(this,"onVisibilityChanged",()=>{if(this.runInBackground)return;const t=!(document.visibilityState==="visible");this.setMuted(t);for(const i of this._incomingStreams){const I=i[1];I.muted=t}})}awake(){pIA&&(this.debug=!0),this.debug&&window.addEventListener("keydown",async e=>{e.key==="v"&&(console.log("MUTE?",!this.isMuted),this.setMuted(!this.isMuted))})}onEnable(){this._net||(this._net=vu.create(this)),this._net.addEventListener(Mn.StreamReceived,this.onReceiveStream),this._net.addEventListener(Mn.StreamEnded,this.onStreamEnded),this._net.enable(),this.autoConnect&&(this.context.connection.isConnected?this.connect():this.context.connection.beginListen(It.JoinedRoom,this.onJoinedRoom)),this.onEnabledChanged(),window.addEventListener("visibilitychange",this.onVisibilityChanged)}onDisable(){var e;this._net.stopSendingStream(this._outputStream),this._net.removeEventListener(Mn.StreamReceived,this.onReceiveStream),this._net.removeEventListener(Mn.StreamEnded,this.onStreamEnded),(e=this._net)==null||e.disable(),this.context.connection.stopListen(It.JoinedRoom,this.onJoinedRoom),this.onEnabledChanged(),window.removeEventListener("visibilitychange",this.onVisibilityChanged)}get isSending(){return this._outputStream!=null&&this._outputStream.active}async connect(e){if(this.context.connection.isConnected){if(!await Wk())return console.error("Cannot connect to voice chat - microphone permissions not granted"),!1}else return console.error("Cannot connect to voice chat - not connected to server"),!1;return this._net.stopSendingStream(this._outputStream),UC(this._outputStream),this._outputStream=await this.getAudioStream(e),this._outputStream?(this._net.startSendingStream(this._outputStream),!0):(await Wk()?console.error("VOIP: Could not get audio stream - please make sure to connect an audio device and grant microphone permissions"):AN("Microphone permissions not granted: Please grant microphone permissions to use voice chat"),!1)}disconnect(){this._net.stopSendingStream(this._outputStream),UC(this._outputStream),this._outputStream=null}setMuted(e){var i;const t=(i=this._outputStream)==null?void 0:i.getAudioTracks();if(t)for(const I of t)I.enabled=!e}get isMuted(){var t;if(this._outputStream===null)return!1;const e=(t=this._outputStream)==null?void 0:t.getAudioTracks();if(e){for(const i of e)if(!i.enabled)return!0}return!1}getFrequency(e){return this.unsupported_getfrequency||(this.unsupported_getfrequency=!0,he()&&fi("VOIP: getFrequency is currently not supported"),console.warn("VOIP: getFrequency is currently not supported")),null}async getAudioStream(e){return navigator.mediaDevices.getUserMedia?await navigator.mediaDevices.getUserMedia({audio:e??!0,video:!1}).catch(i=>(console.warn("VOIP failed getting audio stream",i),null)):(console.error("No getDisplayMedia support"),null)}}XO([D()],sQ.prototype,"autoConnect",2);XO([D()],sQ.prototype,"runInBackground",2);var fIA=Object.defineProperty,DIA=Object.getOwnPropertyDescriptor,$O=(g,A,e,t)=>{for(var i=t>1?void 0:t?DIA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&fIA(A,e,i),i};const wIA=IA("debugmouth");class qu extends RA{constructor(){super(...arguments);r(this,"idle",[]);r(this,"talking",[]);r(this,"marker",null);r(this,"voip",null);r(this,"lastMouthChangeTime",0);r(this,"mouthChangeLength",0)}awake(){setTimeout(()=>{this.voip=aA.findObjectOfType(sQ,this.context),this.marker||(this.marker=aA.getComponentInParent(this.gameObject,ng))},3e3)}update(){var i;if(!this.voip||this.context.time.frameCount%10!==0)return;let e=((i=this.marker)==null?void 0:i.connectionId)??null;if(!e){wIA&&(e=null);return}const t=this.voip.getFrequency(e)??0;this.updateLips(t)}updateLips(e){if(this.context.time.time-this.lastMouthChangeTime>this.mouthChangeLength){if(this.mouthChangeLength=.05+Math.random()*.1,this.talking&&this.talking.length>0&&e>30){this.lastMouthChangeTime=this.context.time.time;const t=Math.floor(Math.random()*this.talking.length);this.setMouthShapeActive(this.talking,t)}else if(this.idle.length>0&&this.context.time.time-this.lastMouthChangeTime>.5){this.lastMouthChangeTime=this.context.time.time;const t=Math.floor(Math.random()*this.idle.length);this.setMouthShapeActive(this.idle,t)}}}setMouthShapeActive(e,t){if(e){e!=this.idle?this.idle.map(i=>i.visible=!1):this.talking.map(i=>i.visible=!1);for(let i=0;i<e.length;i++){const I=e[i];I&&(I.visible=i===t)}}}}$O([D(uA)],qu.prototype,"idle",2);$O([D(uA)],qu.prototype,"talking",2);class WN extends RA{constructor(){super(...arguments);r(this,"voip",null);r(this,"marker",null);r(this,"_startPosition",null)}awake(){this.voip=aA.findObjectOfType(sQ,this.context),this.marker=aA.getComponentInParent(this.gameObject,ng)}update(){if(!this.voip||!this.marker||this.context.time.frameCount%10!==0)return;const e=this.marker.connectionId,t=this.voip.getFrequency(e);if(t==null)return;this._startPosition||(this._startPosition=this.gameObject.position.clone());const i=t/100;this.gameObject.position.y=this._startPosition.y+i*.07}}var yIA=Object.defineProperty,SIA=Object.getOwnPropertyDescriptor,MS=(g,A,e,t)=>{for(var i=t>1?void 0:t?SIA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&yIA(A,e,i),i};class nQ extends RA{constructor(){super(...arguments);r(this,"eyes",[]);r(this,"lastBlinkTime",0);r(this,"blinkLength",0);r(this,"eyesOpen",!0);r(this,"state",null)}awake(){this.state=aA.getComponentInParent(this.gameObject,Do)}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 t of this.eyes)t&&(t.visible=this.eyesOpen)}}}MS([D(uA)],nQ.prototype,"eyes",2);MS([D()],nQ.prototype,"lastBlinkTime",2);MS([D()],nQ.prototype,"blinkLength",2);MS([D()],nQ.prototype,"eyesOpen",2);var mIA=Object.defineProperty,GIA=Object.getOwnPropertyDescriptor,ZN=(g,A,e,t)=>{for(var i=t>1?void 0:t?GIA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&mIA(A,e,i),i},$G;const AP=($G=class extends RA{constructor(){super(...arguments);r(this,"head",null);r(this,"eyes",null);r(this,"target",null);r(this,"brain",null);r(this,"vec",new w);r(this,"currentTargetPoint",new w)}awake(){this.brain||(this.brain=aA.getComponentInParent(this.gameObject,Jd)),this.brain||(console.log("No look at brain found, adding it now"),this.brain=aA.addNewComponent(this.gameObject,Jd)),this.brain&&this.target&&(this.brain.controlledTarget=this.target)}update(){const A=this.target;if(A&&this.head){const e=this.eyes;if(e){const t=_e(A);this.currentTargetPoint.lerp(t,this.context.time.deltaTime/.1);const i=_e(this.head),I=this.vec.copy(this.currentTargetPoint).sub(i).normalize();if(I.length()<.1)return;const o=AP.forward;if(o.set(0,0,1),o.applyQuaternion(Jt(this.head)),o.dot(I)>.45)for(let n=0;n<e.length;n++)e[n].lookAt(this.currentTargetPoint)}}}},r($G,"forward",new w(0,0,1)),$G);let _c=AP;ZN([D(uA)],_c.prototype,"head",2);ZN([D(uA)],_c.prototype,"eyes",2);ZN([D(uA)],_c.prototype,"target",2);const xl=IA("debugavatar");class US{constructor(A,e,t,i){r(this,"root");r(this,"head");r(this,"leftHand");r(this,"rigthHand");var I;this.root=A,this.head=e,this.leftHand=t,this.rigthHand=i,(I=this.root)==null||I.traverse(o=>o.layers.set(2))}get isValid(){return this.head!==null&&this.head!==void 0}}class jN{constructor(){r(this,"avatarRegistryUrl",null)}async getOrCreateNewAvatarInstance(A,e){if(!e)return console.error("Can not create avatar: failed to provide id or root object"),null;let t=null;if(typeof e=="string"){if(t=await this.loadAvatar(A,e),!t){const I=new Xs;t=aA.instantiate(tc(e,A.scene),I)}}else t=e;if(!t)return null;const i=this.findAvatar(t);return i.isValid?(xl&&console.log("[Custom Avatar] valid config",e,xl?i:""),i):(console.warn("[Custom Avatar] config isn't valid",e,xl?i:""),null)}async loadAvatar(A,e){if(console.assert(e!=null&&typeof e=="string","Avatar id must not be null"),e.length<=0||!e)return null;if(xl&&console.log("[Custom Avatar] "+e+", loading..."),e.endsWith(".glb")||(e+=".glb"),this.avatarRegistryUrl===null){const i=await fetch("./"+e);let I=null;if(i.ok){const s=await i.blob();s&&(I=await s.arrayBuffer())}if(!I&&(I=await wN(e,e,0,"no url here go away",!0),!I))return null;const o=await Ys().parseSync(A,I,null,0);return(o==null?void 0:o.scene)??null}const t=new Mc;return lu(t,A),new Promise((i,I)=>{const o=this.avatarRegistryUrl+"/"+e;t.load(o,async s=>{await Ys().createBuiltinComponents(A,o,s,null,void 0),i(s.scene)},s=>{xl&&console.log("[Custom Avatar] "+s.loaded/s.total*100+"% loaded of "+s.total/1024+"kB")},s=>{console.error("[Custom Avatar] Error when loading: "+s),i(null)})})}cacheModel(A,e){}findAvatar(A){const e=A;let t=e;t.children.length==1&&(t=A.children[0]);let i=this.findAvatarPart(t,["head"]);const I=this.findAvatarPart(t,["left","hand"]),o=this.findAvatarPart(t,["right","hand"]);if(!i){i=e;const n=new w;new wt().setFromObject(i).getSize(n);const C=Math.max(n.x,n.y,n.z);console.warn("[Custom Avatar] Normalizing head scale, it's too big: "+C+" meters! Should be < 0.3m"),C>.3&&i.scale.multiplyScalar(1/C*.3)}return new US(e,i,I,o)}findAvatarPart(A,e){const t=A.name.toLowerCase();let i=!0;for(const I of e){if(!i)break;t.indexOf(I)===-1&&(i=!1)}if(i)return A;if(A.children)for(const I of A.children){const o=this.findAvatarPart(I,e);if(o)return o}return null}handleCustomAvatarErrors(A){if(!A.ok)throw Error(A.statusText);return A}}var kIA=Object.defineProperty,MIA=Object.getOwnPropertyDescriptor,VN=(g,A,e,t)=>{for(var i=t>1?void 0:t?MIA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&kIA(A,e,i),i};class Tc extends RA{constructor(){super(...arguments);r(this,"length",1);r(this,"depthTest",!0);r(this,"isGizmo",!0);r(this,"_axes",null)}onEnable(){if(this.isGizmo&&!uu)return;this._axes||(this._axes=new as(this.length)),this._axes.layers.disableAll(),this._axes.layers.set(this.layer),this.gameObject.add(this._axes);const e=this._axes.material;e&&e.depthTest!==void 0&&(e.depthTest=this.depthTest)}onDisable(){this._axes&&this.gameObject.remove(this._axes)}}VN([D()],Tc.prototype,"length",2);VN([D()],Tc.prototype,"depthTest",2);VN([D()],Tc.prototype,"isGizmo",2);class zN extends RA{constructor(){super(...arguments);r(this,"from");r(this,"to");r(this,"hint");r(this,"desiredDistance",1)}onEnable(){}update(){if(!this.from||!this.to||!this.hint)return;const e=_e(this.to).clone(),t=_e(this.from).clone(),i=e.distanceTo(t),I=e.clone();I.sub(t);const o=t.clone();o.add(e),o.multiplyScalar(.5);const s=_e(this.hint).clone();s.sub(o);const n=new w;n.crossVectors(s,I),n.crossVectors(I,n),n.normalize();const C=i*.5,a=Math.max(this.desiredDistance,C),B=Math.sqrt(a*a-C*C),Q=n.clone();Q.multiplyScalar(B),Q.add(o),EI(this.gameObject,Q);const E=o.clone();E.sub(n),this.gameObject.lookAt(E)}}const QG=IA("debugusdzbehaviours");class RS{constructor(){r(this,"behaviours",[]);r(this,"behaviourComponents",[]);r(this,"behaviourComponentsCopy",[])}get extensionName(){return"Behaviour"}addBehavior(A){this.behaviours.push(A)}onBeforeBuildDocument(A){const e=[];return A.root.traverse(t=>{aA.foreachComponent(t,i=>{var o;const I=i;if(typeof I.createBehaviours=="function"||typeof I.beforeCreateDocument=="function"||typeof I.afterCreateDocument=="function"||typeof I.afterSerialize=="function"){this.behaviourComponents.push(I);const s=(o=I.beforeCreateDocument)==null?void 0:o.call(I,this,A);s instanceof Promise&&e.push(s)}},!1)}),QG&&console.log("onBeforeBuildDocument: all components",this.behaviourComponents),Promise.all(e)}onExportObject(A,e,t){var i;for(const I of this.behaviourComponents)QG&&console.log("onExportObject: createBehaviours",I),(i=I.createBehaviours)==null||i.call(I,this,e,t)}onAfterBuildDocument(A){for(const e of this.behaviourComponents)typeof e.afterCreateDocument=="function"&&e.afterCreateDocument(this,A);this.behaviourComponentsCopy=this.behaviourComponents.slice(),this.behaviourComponents.length=0}onAfterHierarchy(A,e){var t;if((t=this.behaviours)!=null&&t.length){e.beginBlock('def Scope "Behaviors"');for(const i of this.behaviours)i.writeTo(this,A.document,e);e.closeBlock()}}async onAfterSerialize(A){QG&&console.log("onAfterSerialize behaviours",this.behaviourComponentsCopy);for(const e of this.behaviourComponentsCopy)typeof e.afterSerialize=="function"&&(e.afterSerialize.constructor.name==="AsyncFunction"?await e.afterSerialize(this,A):e.afterSerialize(this,A));this.behaviours.length=0}}var UIA=Object.defineProperty,RIA=Object.getOwnPropertyDescriptor,XN=(g,A,e,t)=>{for(var i=t>1?void 0:t?RIA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&UIA(A,e,i),i},Ak;const eP=(Ak=class extends hI{constructor(){super(...arguments);r(this,"threshold");r(this,"intensity");r(this,"scatter");r(this,"selectiveBloom")}get typeName(){return"Bloom"}init(){this.threshold.defaultValue=1,this.intensity.defaultValue=0,this.scatter.defaultValue=.2,this.selectiveBloom?(this.threshold.valueProcessor=A=>A,this.intensity.valueProcessor=A=>A,this.scatter.valueProcessor=A=>1*Math.PI*(1-A)):(this.threshold.valueProcessor=A=>A,this.intensity.valueProcessor=A=>A,this.scatter.valueProcessor=A=>100*(1-A))}onCreateEffect(){let A;if(this.selectiveBloom==null&&(this.selectiveBloom=eP.useSelectiveBloom),this.selectiveBloom){const e=A=new KY(this.context.scene,this.context.mainCamera,{blendFunction:We.ADD,mipmapBlur:!0,luminanceThreshold:this.threshold.value,luminanceSmoothing:this.scatter.value,intensity:this.intensity.value});e.inverted=!0}else A=new uN({blendFunction:We.ADD,mipmapBlur:!0,luminanceThreshold:this.threshold.value,luminanceSmoothing:this.scatter.value,intensity:this.intensity.value});return this.intensity.onValueChanged=e=>{A.intensity=e},this.threshold.onValueChanged=e=>{A.luminanceMaterial.threshold=e},this.scatter.onValueChanged=e=>{A.luminancePass.enabled=!0,A.luminanceMaterial.smoothing=e},A}},r(Ak,"useSelectiveBloom",!1),Ak);let CQ=eP;XN([D(qe)],CQ.prototype,"threshold",2);XN([D(qe)],CQ.prototype,"intensity",2);XN([D(qe)],CQ.prototype,"scatter",2);us("Bloom",CQ);const lE="NEEDLE_progressive",nI=IA("debugprogressive"),EG=Symbol("needle-progressive-texture"),PE=new Map;if(nI){let g=function(){A+=1,Ci(`Toggle LOD level: ${A}<br/>Registered objects: ${PE.size}`),console.log("Toggle LOD level",A,PE);const t=st.Current;PE.forEach((i,I)=>{for(const o of i.keys){const s=I[o];if(s instanceof ue){const n=Kt.getMeshLODInformation(s),C=n?Math.min(A,n.lods.length):0;I["DEBUG:LOD"]=C,Kt.assignMeshLOD(t,i.sourceId,I,C),n&&(e=Math.max(e,n.lods.length-1))}else if(I instanceof be){Kt.assignTextureLOD(t,i.sourceId,I,A);break}}}),A>=e&&(A=-1)},A=-1,e=2;window.addEventListener("keyup",t=>{t.key==="p"&&g()}),st.registerCallback(di.ContextCreated,t=>{const i=document.createElement("button");i.innerText="Toggle Progressive",i.onclick=g,t.context.menu.appendChild(i)})}function Yq(g,A,e){var i;if(!nI)return;PE.has(g)||PE.set(g,{keys:[],sourceId:e});const t=PE.get(g);((i=t==null?void 0:t.keys)==null?void 0:i.includes(A))==!1&&t.keys.push(A)}const VI=class{constructor(A,e,t){r(this,"parser");r(this,"sourceId");r(this,"context");this.parser=A,this.sourceId=e,this.context=t}get name(){return lE}static getMeshLODInformation(A){const e=this.getAssignedLODInformation(A);return e!=null&&e.key?this.lodInfos.get(e.key):null}static hasLODLevelAvailable(A,e){var I;if(A instanceof be){for(const o of Object.keys(A)){const s=A[o];if(s instanceof fe&&this.hasLODLevelAvailable(s,e))return!0}return!1}else if(A instanceof bI){for(const o of A.children)if(o instanceof lA&&this.hasLODLevelAvailable(o,e))return!0}let t,i;if(A instanceof lA?t=A.geometry:A instanceof fe&&(t=A),t&&(I=t==null?void 0:t.userData)!=null&&I.LODS){const o=t.userData.LODS;if(i=this.lodInfos.get(o.key),e===void 0)return i!=null;if(i)return Array.isArray(i.lods)?e<i.lods.length:e===0}return!1}static assignMeshLOD(A,e,t,i){if(!t)return Promise.resolve(null);if(t instanceof lA){const I=t.geometry,o=this.getAssignedLODInformation(I);if(!o)return Promise.resolve(null);Md(t)||FD(t,t.geometry);const s=this.onProgressiveLoadStart(A,e,t,null);return t["LOD:requested level"]=i,VI.getOrLoadLOD(A,e,I,i).then(n=>{if(t["LOD:requested level"]===i){if(delete t["LOD:requested level"],Array.isArray(n)){const C=o.index||0;n=n[C]}n&&I!=n&&(nI=="verbose"&&console.log("Progressive Mesh "+t.name+" loaded",I,"→",n,`
|
|
5509
5509
|
`,t),n instanceof ue&&(t.geometry=n,nI&&Yq(t,"geometry",e)))}return this.onProgressiveLoadEnd(s),n}).catch(n=>(this.onProgressiveLoadEnd(s),console.error("Error loading mesh LOD",t,n),null))}else nI&&console.error("Invalid call to assignMeshLOD: Request mesh LOD but the object is not a mesh",t);return Promise.resolve(null)}static assignTextureLOD(A,e,t,i=0){if(!t)return Promise.resolve(null);if(t instanceof be){const I=t,o=[],s=new Array;if(I instanceof ou)for(const n of Object.keys(I.uniforms)){const C=I.uniforms[n].value;if(C instanceof fe){const a=this.assignTextureLODForSlot(A,e,C,i,I,n);o.push(a),s.push(n)}}else for(const n of Object.keys(I)){const C=I[n];if(C instanceof fe){const a=this.assignTextureLODForSlot(A,e,C,i,I,n);o.push(a),s.push(n)}}return au(o).then(n=>{const C=new Array;for(let a=0;a<n.results.length;a++){const B=n.results[a],Q=s[a];B instanceof fe?C.push({material:I,slot:Q,texture:B,level:i}):C.push({material:I,slot:Q,texture:null,level:i})}return C})}if(t instanceof fe){const I=t;return this.assignTextureLODForSlot(A,e,I,i,null,null)}return Promise.resolve(null)}static assignTextureLODForSlot(A,e,t,i,I,o){if((t==null?void 0:t.isTexture)!==!0)return Promise.resolve(null);const s=this.onProgressiveLoadStart(A,e,I,o);return VI.getOrLoadLOD(A,e,t,i).then(n=>Array.isArray(n)?null:(n==null?void 0:n.isTexture)===!0?(n!=t&&(I&&o&&(I[o]=n),nI&&o&&I&&Yq(I,o,e)),this.onProgressiveLoadEnd(s),n):(nI=="verbose"&&console.warn("No LOD found for",t,i),this.onProgressiveLoadEnd(s),null)).catch(n=>(this.onProgressiveLoadEnd(s),console.error("Error loading LOD",t,n),null))}afterRoot(A){var t,i;nI&&console.log("AFTER",this.sourceId,A),(t=this.parser.json.textures)==null||t.forEach((I,o)=>{if(I!=null&&I.extensions){const s=I==null?void 0:I.extensions[lE];if(s){for(const n of this.parser.associations.keys())if(n instanceof fe&&this.parser.associations.get(n).textures===o){const a=n;nI&&console.log("> Progressive: register texture",o,a.name,a.uuid,a,s),a.source&&(a.source[EG]=s);const B=a.uuid;VI.assignLODInformation(a,B,0,0,void 0),VI.lodInfos.set(B,s),VI.lowresCache.set(B,a)}}}});const e=(I,o,s,n,C)=>{const a=o.geometry;a["needle:raycast-mesh"]=!0,a&&!Md(o)&&(nI&&console.log("Set raycast mesh",o.name,o.uuid,a),FD(o,a),IS(a,!0).forEach(B=>{B instanceof lA&&FD(B,a)})),a.userData||(a.userData={}),VI.assignLODInformation(a,I,s,n,C.density),VI.lodInfos.set(I,C)};return(i=this.parser.json.meshes)==null||i.forEach((I,o)=>{if(I!=null&&I.extensions){const s=I==null?void 0:I.extensions[lE];if(s&&s.lods){for(const n of this.parser.associations.keys())if(n instanceof lA){const C=this.parser.associations.get(n);if(C.meshes===o){const a=n;nI&&console.log("> Progressive: register mesh",o,a.name,s,a.uuid,a);const B=a.uuid,Q=s.lods.length;if(a instanceof lA){e(B,a,Q,C.primitives,s);let E=VI.lowresCache.get(B);E?E.push(a.geometry):E=[a.geometry],VI.lowresCache.set(B,E)}}}}}}),null}static async getOrLoadLOD(A,e,t,i){var C,a,B;const I=nI=="verbose",o=t.userData.LODS;if(!o)return null;const s=o==null?void 0:o.key;let n;if(t instanceof fe&&t.source&&t.source[EG]&&(n=t.source[EG]),n||(n=VI.lodInfos.get(s)),n){if(i>0){let c=!1;const d=Array.isArray(n.lods);if(d&&i>=n.lods.length?c=!0:d||(c=!0),c)return this.lowresCache.get(s)}const Q=Array.isArray(n.lods)?n.lods[i].path:n.lods;if(!Q)return nI&&!n["missing:uri"]&&(n["missing:uri"]=!0,console.warn("Missing uri for progressive asset for LOD "+i,n)),null;let E=WC(e,Q);if(E.endsWith(".glb")||E.endsWith(".gltf")){if(!n.guid)return console.warn("missing pointer for glb/gltf texture",n),null;const c=E+"_"+n.guid,d=this.previouslyLoaded.get(c);if(d!==void 0){I&&console.log(`LOD ${i} was already loading/loaded: ${c}`);let u=await d.catch(k=>(console.error(`Error loading LOD ${i} from ${E}
|
|
5510
5510
|
`,k),null)),f=!1;if(u==null||(u instanceof fe&&t instanceof fe?(C=u.image)!=null&&C.data||(a=u.source)!=null&&a.data?u=this.copySettings(t,u):(f=!0,this.previouslyLoaded.delete(c)):u instanceof ue&&t instanceof ue&&((B=u.attributes.position)!=null&&B.array||(f=!0,this.previouslyLoaded.delete(c)))),!f)return u}const l=n,h=new Promise(async(u,f)=>{const k=new Mc;if(lu(k,A),n&&Array.isArray(n.lods)){const N=n.lods[i];N.hash&&(E+="?v="+N.hash)}nI&&(await Os(Math.random()*1e3),I&&console.warn("Start loading (delayed) "+E,l.guid));const G=await k.loadAsync(E).catch(N=>(console.error(`Error loading LOD ${i} from ${E}
|
|
5511
5511
|
`,N),null));if(!G)return null;const M=G.parser;I&&console.log("Loading finished "+E,l.guid);let m=0;if(G.parser.json.textures){let N=!1;for(const y of G.parser.json.textures){if(y!=null&&y.extensions){const U=y==null?void 0:y.extensions[lE];if(U!=null&&U.guid&&U.guid===l.guid){N=!0;break}}m++}if(N){let y=await M.getDependency("texture",m);return I&&console.log('change "'+t.name+'" → "'+y.name+'"',E,m,y,c),t instanceof fe&&(y=this.copySettings(t,y)),y&&(y.guid=l.guid),u(y)}}if(m=0,G.parser.json.meshes){let N=!1;for(const y of G.parser.json.meshes){if(y!=null&&y.extensions){const U=y==null?void 0:y.extensions[lE];if(U!=null&&U.guid&&U.guid===l.guid){N=!0;break}}m++}if(N){const y=await M.getDependency("mesh",m),U=l;if(I&&console.log(`Loaded Mesh "${y.name}"`,E,m,y,c),y instanceof lA){const H=y.geometry;return VI.assignLODInformation(H,s,i,void 0,U.density),u(H)}else{const H=new Array;for(let x=0;x<y.children.length;x++){const K=y.children[x];if(K instanceof lA){const O=K.geometry;VI.assignLODInformation(O,s,i,x,U.density),H.push(O)}}return u(H)}}}return u(null)});return this.previouslyLoaded.set(c,h),await h}else if(t instanceof fe){I&&console.log("Load texture from uri: "+E);const d=await new Fn().loadAsync(E);return d?(d.guid=n.guid,d.flipY=!1,d.needsUpdate=!0,d.colorSpace=t.colorSpace,I&&console.log(n,d)):nI&&console.warn("failed loading",E),d}}else nI&&console.warn(`Can not load LOD ${i}: no LOD info found for "${s}" ${t.name}`,t.type);return null}static assignLODInformation(A,e,t,i,I){if(!A)return;A.userData||(A.userData={});const o=new NIA(e,t,i,I);A.userData.LODS=o,A.userData.LOD=t}static getAssignedLODInformation(A){var e;return((e=A==null?void 0:A.userData)==null?void 0:e.LODS)||null}static copySettings(A,e){const t=this._copiedTextures.get(A);return t||(e=e.clone(),this._copiedTextures.set(A,e),e.offset=A.offset,e.repeat=A.repeat,e.colorSpace=A.colorSpace,e)}static beginListenStart(A,e){this._progressiveEventListeners.has(A)||this._progressiveEventListeners.set(A,new Oq),this._progressiveEventListeners.get(A).start.push(e)}static stopListenStart(A,e){if(!this._progressiveEventListeners.has(A))return;const t=this._progressiveEventListeners.get(A).start,i=t.indexOf(e);i>=0&&t.splice(i,1)}static beginListenEnd(A,e){this._progressiveEventListeners.has(A)||this._progressiveEventListeners.set(A,new Oq),this._progressiveEventListeners.get(A).end.push(e)}static stopListenEnd(A,e){if(!this._progressiveEventListeners.has(A))return;const t=this._progressiveEventListeners.get(A).end,i=t.indexOf(e);i>=0&&t.splice(i,1)}static onProgressiveLoadStart(A,e,t,i){this._currentProgressiveLoadingInfo.has(A)||this._currentProgressiveLoadingInfo.set(A,[]);const I=new tP(A,e,t,i),o=this._currentProgressiveLoadingInfo.get(A),s=this._progressiveEventListeners.get(A);return s&&s.onStart(I),o.push(I),I}static onProgressiveLoadEnd(A){if(!A)return;const e=A.context;if(!this._currentProgressiveLoadingInfo.has(e))return;const t=this._currentProgressiveLoadingInfo.get(e),i=t.indexOf(A);if(i<0)return;t.splice(i,1);const I=this._progressiveEventListeners.get(e);I&&I.onEnd(A)}};let Kt=VI;r(Kt,"lodInfos",new Map),r(Kt,"previouslyLoaded",new Map),r(Kt,"lowresCache",new Map),r(Kt,"_copiedTextures",new Map),r(Kt,"_progressiveEventListeners",new Map),r(Kt,"_currentProgressiveLoadingInfo",new Map);class NIA{constructor(A,e,t,i){r(this,"key");r(this,"level");r(this,"index");r(this,"density");this.key=A,this.level=e,t!=null&&(this.index=t),i!=null&&(this.density=i)}}class tP{constructor(A,e,t,i){r(this,"context");r(this,"source");r(this,"material");r(this,"slot");r(this,"mesh");this.context=A,this.source=e,t instanceof lA?this.mesh=t:this.material=t,this.slot=i}}class Oq{constructor(){r(this,"start",[]);r(this,"end",[])}onStart(A){for(const e of this.start)e(A)}onEnd(A){for(const e of this.end)e(A)}}var FIA=Object.defineProperty,KIA=Object.getOwnPropertyDescriptor,Io=(g,A,e,t)=>{for(var i=t>1?void 0:t?KIA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&FIA(A,e,i),i};class xo extends RA{constructor(){super(...arguments);r(this,"attachedRigidbody",null);r(this,"isTrigger",!1);r(this,"sharedMaterial");r(this,"membership",[0]);r(this,"filter");r(this,"updateProperties",()=>{var e;(e=this.context.physics.engine)==null||e.updateProperties(this)})}get isCollider(){return!0}awake(){super.awake(),this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(vt))}start(){this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(vt))}onEnable(){this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(vt))}onDisable(){var e;(e=this.context.physics.engine)==null||e.removeBody(this)}get body(){var e;return(e=this.context.physics.engine)==null?void 0:e.getBody(this)}updatePhysicsMaterial(){var e;(e=this.context.physics.engine)==null||e.updatePhysicsMaterial(this)}}Io([D(vt)],xo.prototype,"attachedRigidbody",2);Io([D()],xo.prototype,"isTrigger",2);Io([D()],xo.prototype,"sharedMaterial",2);Io([D()],xo.prototype,"membership",2);Io([D()],xo.prototype,"filter",2);class Hc extends xo{constructor(){super(...arguments);r(this,"radius",.5);r(this,"center",new w(0,0,0))}onEnable(){var e;super.onEnable(),(e=this.context.physics.engine)==null||e.addSphereCollider(this),Zy(this.gameObject.scale,this.updateProperties)}onDisable(){super.onDisable(),pR(this.gameObject.scale,this.updateProperties)}onValidate(){this.updateProperties()}}Io([AI(),D()],Hc.prototype,"radius",2);Io([D(w)],Hc.prototype,"center",2);class Yc extends xo{constructor(){super(...arguments);r(this,"size",new w(1,1,1));r(this,"center",new w(0,0,0))}onEnable(){var e;super.onEnable(),(e=this.context.physics.engine)==null||e.addBoxCollider(this,this.size),Zy(this.gameObject.scale,this.updateProperties)}onDisable(){super.onDisable(),pR(this.gameObject.scale,this.updateProperties)}onValidate(){this.updateProperties()}}Io([AI(),D(w)],Yc.prototype,"size",2);Io([D(w)],Yc.prototype,"center",2);class aQ extends xo{constructor(){super(...arguments);r(this,"sharedMesh");r(this,"convex",!1)}onEnable(){var t,i,I;if(super.onEnable(),!this.context.physics.engine)return;(t=this.sharedMesh)!=null&&t.isMesh||this.gameObject instanceof lA&&(this.sharedMesh=this.gameObject);const e=0;if((i=this.sharedMesh)!=null&&i.isMesh)this.context.physics.engine.addMeshCollider(this,this.sharedMesh,this.convex,Vt(this.gameObject)),Kt.assignMeshLOD(this.context,this.sourceId,this.sharedMesh,e).then(o=>{o&&this.activeAndEnabled&&this.context.physics.engine&&this.sharedMesh&&(this.context.physics.engine.removeBody(this),this.sharedMesh.geometry=o,this.context.physics.engine.addMeshCollider(this,this.sharedMesh,this.convex,Vt(this.gameObject)))});else{const o=this.sharedMesh;if(o!=null&&o.isGroup){console.warn(`MeshCollider mesh is a group "${((I=this.sharedMesh)==null?void 0:I.name)||this.gameObject.name}", adding all children as colliders. This is currently not fully supported (colliders can not be removed from world again)`,this);const s=new Array;for(const n in o.children){const C=o.children[n];C.isMesh&&(this.context.physics.engine.addMeshCollider(this,C,this.convex,Vt(this.gameObject)),s.push(Kt.assignMeshLOD(this.context,this.sourceId,C,e)))}Promise.all(s).then(n=>{var a,B;if(n.some(Q=>Q)==!1)return;(a=this.context.physics.engine)==null||a.removeBody(this);const C=new lA;for(const Q of n)Q&&this.activeAndEnabled&&(C.geometry=Q,(B=this.context.physics.engine)==null||B.addMeshCollider(this,C,this.convex,Vt(this.gameObject)))})}}}}Io([D(lA)],aQ.prototype,"sharedMesh",2);Io([D()],aQ.prototype,"convex",2);class LC extends xo{constructor(){super(...arguments);r(this,"center",new w(0,0,0));r(this,"radius",.5);r(this,"height",2)}onEnable(){var e;super.onEnable(),(e=this.context.physics.engine)==null||e.addCapsuleCollider(this,this.height,this.radius)}}Io([D(w)],LC.prototype,"center",2);Io([D()],LC.prototype,"radius",2);Io([D()],LC.prototype,"height",2);var JIA=Object.defineProperty,bIA=Object.getOwnPropertyDescriptor,$N=(g,A,e,t)=>{for(var i=t>1?void 0:t?bIA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&JIA(A,e,i),i};class rQ extends RA{constructor(){super(...arguments);r(this,"objectBounds",!1);r(this,"color");r(this,"isGizmo",!0);r(this,"_gizmoObject",null);r(this,"_boxHelper",null)}onEnable(){this.isGizmo&&!uu||(this._gizmoObject||(this.objectBounds?this._gizmoObject=new lR(this.gameObject,this.color??16776960):(this.objectBounds=!1,this._gizmoObject=SN(this.color??16776960))),this.objectBounds?(this.scene.add(this._gizmoObject),this._boxHelper=this._gizmoObject,this.startCoroutine(this.syncObjectBounds(),Ai.OnBeforeRender)):this.gameObject.add(this._gizmoObject))}onDisable(){this._gizmoObject&&this.gameObject.remove(this._gizmoObject)}*syncObjectBounds(){var e;for(;this._boxHelper;)(e=this._boxHelper)==null||e.update(),yield}}$N([D()],rQ.prototype,"objectBounds",2);$N([D(mA)],rQ.prototype,"color",2);$N([D()],rQ.prototype,"isGizmo",2);const vIA=IA("gizmos"),qIA=IA("debugboxhelper"),Vo=class extends RA{constructor(){super(...arguments);r(this,"box",null);r(this,"_lastMatrixUpdateFrame",-1);r(this,"_helper",null);r(this,"_color",null)}isInBox(e,t){var I;if(!e)return;if(this.box||(this.box=new wt),e.type==="Mesh")Vo.testBox.setFromObject(e);else if(e.type==="Group"){if(Vo.testBox.makeEmpty(),e.children.length>0)for(let o=0;o<e.children.length;o++)e.children[o].type==="Mesh"&&Vo.testBox.expandByObject(e)}else{const o=_e(e,Vo._position),s=Vt(e,Vo._size);t!==void 0&&s.multiplyScalar(t),Vo.testBox.setFromCenterAndSize(o,s)}this.updateBox();const i=(I=this.box)==null?void 0:I.intersectsBox(Vo.testBox);return i&&qIA&&De.DrawWireBox3(Vo.testBox,16711680,5),i}intersects(e){return e?this.updateBox(!1).intersectsBox(e):!1}updateBox(e=!1){if(this.box||(this.box=new wt),e||this.context.time.frameCount!=this._lastMatrixUpdateFrame){const t=this._lastMatrixUpdateFrame<0;this._lastMatrixUpdateFrame=this.context.time.frameCount;const i=t,I=_e(this.gameObject,Vo._position,i),o=Vt(this.gameObject,Vo._size);this.box.setFromCenterAndSize(I,o)}return this.box}awake(){this._helper=null,this._color=null,this.box=null}showHelper(e=null,t=!1){var i;if(!(!vIA&&!t)){if(this._helper){e&&((i=this._color)==null||i.set(e)),this.gameObject.add(this._helper);return}this._helper=SN(e),this.gameObject.add(this._helper)}}};let Is=Vo;r(Is,"testBox",new wt),r(Is,"_position",new w),r(Is,"_size",new w(.01,.01,.01));class xIA extends pH{constructor(A,e={}){super(A),A._simpleState__activeStates=[],A._simpleState__normalStyles={},A._simpleState__states=e,A._simpleState__statesProperties={};for(const t in e)for(const i in e[t])A._simpleState__statesProperties[i]||(A._simpleState__statesProperties[i]=[]),A._simpleState__statesProperties[i].push(t);for(const t of A._components)A._simpleState__statesProperties[t.id]&&(A._simpleState__normalStyles[t.id]=t.inline?t.inline:t._value);A.__overridedSet=A.set,A.set=this.storeSet.bind(A),A.renderStates=this.renderStates.bind(A),A.setupState=this.setupState.bind(A),A.setState=this.setState.bind(A),A.activatePseudoState=this.activatePseudoState.bind(A),A.deactivatePseudoState=this.deactivatePseudoState.bind(A),A.togglePseudoState=this.togglePseudoState.bind(A)}act(){}attach(){}detach(){}setupState(A,e){this._simpleState__states[A]=e;const t=[];for(const i in e)this._simpleState__statesProperties[i]||(this._simpleState__statesProperties[i]=[],t.push(i)),this._simpleState__statesProperties[i].push(A);for(const i of this._components)t.indexOf(i.id)>-1&&(this._simpleState__normalStyles[i.id]=i.inline?i.inline:i._value)}renderStates(){let A={...this._simpleState__normalStyles};for(const e in this._simpleState__states)this._simpleState__activeStates.indexOf(e)>-1&&(A={...A,...this._simpleState__states[e]});this.set(A,!1)}storeSet(A,e=!0){if(e)for(const t in A)this._simpleState__statesProperties[t]&&(this._simpleState__normalStyles[t]=A[t]);this.__overridedSet(A)}activatePseudoState(A){this._simpleState__activeStates.indexOf(A)===-1&&(this._simpleState__activeStates.push(A),this.renderStates())}deactivatePseudoState(A){const e=this._simpleState__activeStates.indexOf(A);e>-1&&(this._simpleState__activeStates.splice(e,1),this.renderStates())}togglePseudoState(A){const e=this._simpleState__activeStates.indexOf(A);e>-1?this._simpleState__activeStates.splice(e,1):this._simpleState__activeStates.push(A),this.renderStates()}setState(A){Array.isArray(A)?this._simpleState__activeStates=A:this._simpleState__activeStates=[A],this.renderStates()}}var LIA=Object.defineProperty,_IA=Object.getOwnPropertyDescriptor,iP=(g,A,e,t)=>{for(var i=t>1?void 0:t?_IA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&LIA(A,e,i),i};class Oc extends RA{constructor(){super(...arguments);r(this,"effectColor");r(this,"effectDistance")}}iP([D(Mt)],Oc.prototype,"effectColor",2);iP([D(iA)],Oc.prototype,"effectDistance",2);var TIA=Object.defineProperty,HIA=Object.getOwnPropertyDescriptor,xu=(g,A,e,t)=>{for(var i=t>1?void 0:t?HIA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&TIA(A,e,i),i};const cG=IA("debugui"),lG=IA("debuguilayout");class AF{constructor(){r(this,"width");r(this,"height")}}class eF{constructor(){r(this,"x");r(this,"y");r(this,"width");r(this,"height")}}const Gs=new w,Ll=new GA,xf=new MA,gP=class extends Zs{constructor(){super(...arguments);r(this,"_anchoredPosition");r(this,"sizeDelta",new iA(100,100));r(this,"pivot",new iA(.5,.5));r(this,"anchorMin",new iA(0,0));r(this,"anchorMax",new iA(1,1));r(this,"minWidth");r(this,"minHeight");r(this,"lastMatrix");r(this,"rectBlock");r(this,"_transformNeedsUpdate",!1);r(this,"_initialPosition");r(this,"_parentRectTransform");r(this,"_lastUpdateFrame",-1);r(this,"_lastAnchoring");r(this,"_createdBlocks",[]);r(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 iA),this._anchoredPosition}set anchoredPosition(A){this._anchoredPosition=A}get width(){let A=this.sizeDelta.x;if(this.anchorMin.x!==this.anchorMax.x&&this._parentRectTransform){const e=this._parentRectTransform.width,t=this.anchorMax.x-this.anchorMin.x;A=e*t,A+=this.sizeDelta.x}return this.minWidth!==void 0&&A<this.minWidth?this.minWidth:A}get height(){let A=this.sizeDelta.y;if(this.anchorMin.y!==this.anchorMax.y&&this._parentRectTransform){const e=this._parentRectTransform.height,t=this.anchorMax.y-this.anchorMin.y;A=e*t,A+=this.sizeDelta.y}return this.minHeight!==void 0&&A<this.minHeight?this.minHeight:A}awake(){super.awake(),this._anchoredPosition||(this._anchoredPosition=new iA),this.lastMatrix=new GA,this.rectBlock=new uA,this.rectBlock.name=this.name,this._initialPosition=this.gameObject.position.clone(),this._initialPosition.z=0,EE(this,"_anchoredPosition",()=>{this.markDirty()}),EE(this,"sizeDelta",()=>{this.markDirty()}),EE(this,"pivot",()=>{this.markDirty()}),EE(this,"anchorMin",()=>{this.markDirty()}),EE(this,"anchorMax",()=>{this.markDirty()})}onEnable(){var A;super.onEnable(),this.addShadowComponent(this.rectBlock),this._transformNeedsUpdate=!0,(A=this.Canvas)==null||A.registerTransform(this)}onDisable(){var A;super.onDisable(),this.removeShadowComponent(),(A=this.Canvas)==null||A.unregisterTransform(this)}onParentRectTransformChanged(A){this._transformNeedsUpdate||this.onApplyTransform(lG?`${A.name} changed`:void 0)}get isDirty(){return this._transformNeedsUpdate||(this._transformNeedsUpdate=!this.lastMatrix.equals(this.gameObject.matrix)),this._transformNeedsUpdate}markDirty(){this._transformNeedsUpdate||(lG&&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(A){var i;if(this.context.time.frameCount===this._lastUpdateFrame)return;this._lastUpdateFrame=this.context.time.frameCount;const e=this.shadowComponent;if(!e)return;this.gameObject.parent?this._parentRectTransform=aA.getComponentInParent(this.gameObject.parent,gP):this._parentRectTransform=void 0,this._transformNeedsUpdate=!1,lG&&console.warn("RectTransform → ApplyTransform",this.name+" because "+A),this.isRoot()?this.Root.screenspace||(e.rotation.y=Math.PI):(e.matrix.identity(),e.matrixAutoUpdate=!1,Gs.set(0,0,0),this.applyPivot(Gs),e.matrix.setPosition(Gs.x,Gs.y,0),(this.gameObject.quaternion.x||this.gameObject.quaternion.y||this.gameObject.quaternion.z)&&(xf.copy(this.gameObject.quaternion),xf.x*=-1,xf.z*=-1,Ll.makeRotationFromQuaternion(xf),e.matrix.premultiply(Ll)),Gs.set(0,0,0),this.applyAnchoring(Gs),(i=this.Canvas)!=null&&i.screenspace?Gs.z+=.1:Gs.z+=.01,Ll.identity(),Ll.setPosition(Gs.x,Gs.y,Gs.z),e.matrix.premultiply(Ll),e.matrix.scale(this.gameObject.scale)),this.lastMatrix.copy(this.gameObject.matrix);const t=!0;for(const I of qN(this.gameObject,Zs,t,1)){if(I===this||!I.activeAndEnabled)continue;const o=I;o.onParentRectTransformChanged&&o.onParentRectTransformChanged(this)}}applyAnchoring(A){this._lastAnchoring||(this._lastAnchoring=new iA);const e=this._lastAnchoring.sub(this._anchoredPosition);this.gameObject.position.x+=e.x,this.gameObject.position.y+=e.y,this._lastAnchoring.copy(this._anchoredPosition),A.x+=this._initialPosition.x-this.gameObject.position.x,A.y+=this._initialPosition.y-this.gameObject.position.y,A.z+=this._initialPosition.z-this.gameObject.position.z;const t=this._parentRectTransform;if(t){let i=0;const I=1-this.anchorMax.y-this.anchorMin.y;i-=t.height*.5*I,A.y+=i;let o=0;const s=1-this.anchorMax.x-this.anchorMin.x;o-=t.width*.5*s,A.x+=o}}applyPivot(A){if(this.pivot&&!this.isRoot()){const e=this.pivot.x-.5;A.x-=e*this.sizeDelta.x*this.gameObject.scale.x;const t=this.pivot.y-.5;A.y-=t*this.sizeDelta.y*this.gameObject.scale.y}}getBasicOptions(){const A={width:this.sizeDelta.x,height:this.sizeDelta.y,offset:0,backgroundOpacity:0,borderWidth:0,borderRadius:0,borderOpacity:0,letterSpacing:-.03};return this.ensureValidSize(A),A}ensureValidSize(A,e=1e-4){return A.width<=0&&(A.width=e),A.height<=0&&(A.height=1e-4),A}createNewBlock(A){A={...this.getBasicOptions(),...A},cG&&console.log(this.name,A);const e=new OR(A);return this._createdBlocks.push(e),e}createNewText(A){cG&&console.log(A),A={...this.getBasicOptions(),...A},cG&&console.log(this.name,A);const e=new PR(A);return this._createdTextBlocks.push(e),e}};let YI=gP;xu([D(iA)],YI.prototype,"anchoredPosition",1);xu([D(iA)],YI.prototype,"sizeDelta",2);xu([D(iA)],YI.prototype,"pivot",2);xu([D(iA)],YI.prototype,"anchorMin",2);xu([D(iA)],YI.prototype,"anchorMax",2);var YIA=Object.defineProperty,OIA=Object.getOwnPropertyDescriptor,IP=(g,A,e,t)=>{for(var i=t>1?void 0:t?OIA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&YIA(A,e,i),i};const Lf={backgroundColor:new mA(1,1,1),backgroundOpacity:1,borderColor:new mA(1,1,1),borderOpacity:1};var ek;const _D=(ek=class extends Zs{constructor(){super(...arguments);r(this,"_alphaFactor",1);r(this,"sRGBColor",new mA(1,0,1));r(this,"raycastTarget",!0);r(this,"uiObject",null);r(this,"_color",null);r(this,"_rect",null);r(this,"_stateManager",null);r(this,"_currentlyCreatingPanel",!1)}get isGraphic(){return!0}get color(){return this._color||(this._color=new Mt(1,1,1,1)),this._color}set color(A){(!this._color||this._color.r!==A.r||this._color.g!==A.g||this._color.b!==A.b||this._color.alpha!==A.alpha)&&(this._color||(this._color=new Mt(1,1,1,1)),this._color.copy(A),this.onColorChanged())}setAlphaFactor(A){this._alphaFactor=A,this.onColorChanged()}get alphaFactor(){return this._alphaFactor}onColorChanged(){this.uiObject&&(this.sRGBColor.copy(this._color),this.sRGBColor.convertLinearToSRGB(),Lf.backgroundColor=this.sRGBColor,Lf.backgroundOpacity=this._color.alpha*this._alphaFactor,this.applyEffects(Lf,this._alphaFactor),this.uiObject.set(Lf),this.markDirty())}get m_Color(){return this._color}get rectTransform(){if(this._rect||(this._rect=aA.getComponent(this.gameObject,YI)),!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 A;(A=this.uiObject)==null||A.set({width:this.rectTransform.width,height:this.rectTransform.height}),this.markDirty()}__internalNewInstanceCreated(A){return super.__internalNewInstanceCreated(A),this._rect=null,this.uiObject=null,this._color&&(this._color=this._color.clone()),this}setState(A){this.makePanel(),this.uiObject&&(this.uiObject.setState(A),this==null||this.markDirty())}setupState(A){this.makePanel(),this.uiObject&&(this._stateManager||(this._stateManager=new xIA(this.uiObject)),this.uiObject.setupState(A.state,A.attributes))}setOptions(A){this.makePanel(),this.uiObject&&this.uiObject.set(A)}awake(){super.awake(),this.makePanel(),EE(this,"_color",()=>dgA(this,this.onColorChanged))}onEnable(){var A;super.onEnable(),this.uiObject&&((A=this.rectTransform.shadowComponent)==null||A.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 A=.015,e={backgroundColor:this.color,backgroundOpacity:this.color.alpha,offset:A};this.onBeforeCreate(e),this.applyEffects(e),this.onCreate(e),this.controlsChildLayout=!1,this._currentlyCreatingPanel=!1,this.onAfterCreated(),this.onColorChanged()}onBeforeCreate(A){}onCreate(A){this.uiObject=this.rectTransform.createNewBlock(A),this.uiObject.name=this.name}onAfterCreated(){}applyEffects(A,e=1){var i;const t=(i=this.gameObject)==null?void 0:i.getComponent(Oc);t&&(t.effectDistance&&(A.borderWidth=Math.max(Math.abs(t.effectDistance.x),Math.abs(t.effectDistance.y))),t.effectColor&&(A.borderColor=t.effectColor,A.borderOpacity=t.effectColor.alpha*e))}async setTexture(A){if(this.setOptions({backgroundOpacity:0}),A){if(_D.textureCache.has(A))A=_D.textureCache.get(A);else if(!A.isRenderTargetTexture){const e=A.clone();e.colorSpace=yt,_D.textureCache.set(A,e),A=e}this.setOptions({backgroundImage:A,borderRadius:0,backgroundOpacity:this.color.alpha,backgroundSize:"stretch"}),Kt.assignTextureLOD(this.context,this.sourceId,A,0).then(e=>{e instanceof fe&&this.setOptions({backgroundImage:e})})}else this.setOptions({backgroundImage:void 0,borderRadius:0,backgroundOpacity:this.color.alpha});this.markDirty()}onAfterAddedToScene(){super.onAfterAddedToScene(),this.shadowComponent&&(this.shadowComponent.offset=this.shadowComponent.position.z)}},r(ek,"textureCache",new Map),ek);let BQ=_D;IP([D(Mt)],BQ.prototype,"color",1);IP([D()],BQ.prototype,"raycastTarget",2);class Lu extends BQ{constructor(){super(...arguments);r(this,"_flippedObject",!1)}onAfterCreated(){this.uiObject&&!this._flippedObject&&(this._flippedObject=!0,this.uiObject.scale.y*=-1)}}var PIA=Object.defineProperty,WIA=Object.getOwnPropertyDescriptor,NS=(g,A,e,t)=>{for(var i=t>1?void 0:t?WIA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&PIA(A,e,i),i};let tF=class{constructor(){r(this,"texture",null);r(this,"rect")}};NS([D(fe)],tF.prototype,"texture",2);let Pc=class extends Lu{constructor(){super(...arguments);r(this,"_sprite");r(this,"pixelsPerUnitMultiplier",1)}set image(e){this.sprite||(this.sprite=new tF),this.sprite.texture=e,this.onAfterCreated()}get image(){return this.sprite?this.sprite.texture:null}get sprite(){return this._sprite}set sprite(e){this._sprite!==e&&(this._sprite=e,this.onAfterCreated())}isBuiltinSprite(){var t,i,I,o,s,n,C;const e=this.sprite;switch((t=e==null?void 0:e.texture)==null?void 0:t.name){case"InputFieldBackground":case"UISprite":case"Background":case"Knob":return!0}return!((I=(i=e==null?void 0:e.texture)==null?void 0:i.name)!=null&&I.length)&&((s=(o=e==null?void 0:e.texture)==null?void 0:o.image)==null?void 0:s.width)===32&&((C=(n=e==null?void 0:e.texture)==null?void 0:n.image)==null?void 0:C.height)===32}onBeforeCreate(e){var t,i;super.onBeforeCreate(e),this.isBuiltinSprite()&&(e.borderRadius=5/this.pixelsPerUnitMultiplier,((i=(t=this.sprite)==null?void 0:t.texture)==null?void 0:i.name)==="Knob"&&(e.borderRadius=999))}onAfterCreated(){var e;this.__didAwake&&(super.onAfterCreated(),!this.isBuiltinSprite()&&this.setTexture((e=this.sprite)==null?void 0:e.texture))}};NS([D(tF)],Pc.prototype,"sprite",1);NS([D()],Pc.prototype,"pixelsPerUnitMultiplier",2);class FS extends Lu{constructor(){super(...arguments);r(this,"_mainTexture")}get mainTexture(){return this._mainTexture}set mainTexture(e){this._mainTexture!==e&&(this._mainTexture=e,this.onAfterCreated())}onAfterCreated(){this.__didAwake&&(super.onAfterCreated(),this.setTexture(this.mainTexture))}}NS([D(fe)],FS.prototype,"mainTexture",1);var ZIA=Object.defineProperty,jIA=Object.getOwnPropertyDescriptor,Lo=(g,A,e,t)=>{for(var i=t>1?void 0:t?jIA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&ZIA(A,e,i),i};const Or=IA("debugbutton");class hr{constructor(){r(this,"colorMultiplier");r(this,"disabledColor");r(this,"fadeDuration");r(this,"highlightedColor");r(this,"normalColor");r(this,"pressedColor");r(this,"selectedColor")}}Lo([D()],hr.prototype,"colorMultiplier",2);Lo([D(Mt)],hr.prototype,"disabledColor",2);Lo([D()],hr.prototype,"fadeDuration",2);Lo([D(Mt)],hr.prototype,"highlightedColor",2);Lo([D(Mt)],hr.prototype,"normalColor",2);Lo([D(Mt)],hr.prototype,"pressedColor",2);Lo([D(Mt)],hr.prototype,"selectedColor",2);class VIA{constructor(){r(this,"disabledTrigger");r(this,"highlightedTrigger");r(this,"normalTrigger");r(this,"pressedTrigger");r(this,"selectedTrigger")}}class ZC extends RA{constructor(){super(...arguments);r(this,"onClick");r(this,"_isHovered",0);r(this,"colors");r(this,"transition");r(this,"animationTriggers");r(this,"animator");r(this,"_interactable",!0);r(this,"_requestedAnimatorTrigger");r(this,"_isInit",!1);r(this,"_image")}onPointerEnter(e){var i,I;const t=e.event.pointerType==="mouse"&&e.button===0;t&&(this._isHovered+=1),Or&&console.warn("Button Enter",t,this._isHovered,(i=this.animationTriggers)==null?void 0:i.highlightedTrigger,this.animator),this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.highlightedTrigger):this.transition===1&&this.colors&&((I=this._image)==null||I.setState("hovered")),t&&this.context.input.setCursorPointer())}onPointerExit(){var e,t;this._isHovered-=1,this._isHovered<0&&(this._isHovered=0),Or&&console.log("Button Exit",this._isHovered,(e=this.animationTriggers)==null?void 0:e.highlightedTrigger,this.animator),this.interactable&&(this._isHovered>0||(this._isHovered=0,this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.normalTrigger):this.transition===1&&this.colors&&((t=this._image)==null||t.setState("normal")),this.context.input.setCursorNormal()))}onPointerDown(e){var t,i;Or&&console.log("Button Down",(t=this.animationTriggers)==null?void 0:t.highlightedTrigger,this.animator),this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.pressedTrigger):this.transition===1&&this.colors&&((i=this._image)==null||i.setState("pressed")))}onPointerUp(e){var t,i;Or&&console.warn("Button Up",(t=this.animationTriggers)==null?void 0:t.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&&((i=this._image)==null||i.setState(this._isHovered?"hovered":"normal")))}onPointerClick(e){if(this.interactable&&!(e.button!==0&&e.event.pointerType===aS.Mouse)&&(Or&&(console.warn("Button Click",this.onClick),Ci("CLICKED button "+this.name+" at "+this.context.time.frameCount)),this.onClick&&this.onClick.listenerCount>0&&(this.onClick.invoke(),e.use(),Or))){const t=this.gameObject.worldPosition;t.add(this.gameObject.worldUp.multiplyScalar(1+Math.random()*.5)),De.DrawLabel(t,"CLICK:"+Date.now(),.1,1+Math.random()*.5)}}set interactable(e){this._interactable=e,this._image&&(this._image.setInteractable(e),e?this._image.setState("normal"):this._image.setState("disabled"))}get interactable(){return this._interactable}set_interactable(e){this.interactable=e}awake(){super.awake(),Or&&console.log(this),this._isInit=!1,this.init()}start(){var e;(e=this._image)==null||e.setInteractable(this.interactable),this.gameObject.getComponentInParent(Ru)||this.gameObject.addComponent(fS)}onEnable(){super.onEnable()}onDestroy(){this._isHovered&&this.context.input.setCursorNormal()}*setAnimatorTriggerAtEndOfFrame(e){var t;this._requestedAnimatorTrigger=e,yield,yield,this._requestedAnimatorTrigger==e&&((t=this.animator)==null||t.SetTrigger(e))}init(){this._isInit||(this._isInit=!0,this._image=aA.getComponent(this.gameObject,Pc),this._image&&(this.stateSetup(this._image),this.interactable?this._image.setState("normal"):this._image.setState("disabled")))}stateSetup(e){var E,c,d,l,h;e.setInteractable(this.interactable);const t=this.getFinalColor(e.color,(E=this.colors)==null?void 0:E.normalColor),i={state:"normal",attributes:{backgroundColor:t,backgroundOpacity:t.alpha}};e.setupState(i);const I=this.getFinalColor(e.color,(c=this.colors)==null?void 0:c.highlightedColor),o={state:"hovered",attributes:{backgroundColor:I,backgroundOpacity:I.alpha}};e.setupState(o);const s=this.getFinalColor(e.color,(d=this.colors)==null?void 0:d.pressedColor),n={state:"pressed",attributes:{backgroundColor:s,backgroundOpacity:s.alpha}};e.setupState(n);const C=this.getFinalColor(e.color,(l=this.colors)==null?void 0:l.selectedColor),a={state:"selected",attributes:{backgroundColor:C,backgroundOpacity:C.alpha}};e.setupState(a);const B=this.getFinalColor(e.color,(h=this.colors)==null?void 0:h.disabledColor),Q={state:"disabled",attributes:{backgroundColor:B,backgroundOpacity:B.alpha}};e.setupState(Q)}getFinalColor(e,t){return t?e.clone().multiply(t).convertLinearToSRGB():e.clone().convertLinearToSRGB()}}Lo([D(Bg)],ZC.prototype,"onClick",2);Lo([D(hr)],ZC.prototype,"colors",2);Lo([D()],ZC.prototype,"transition",2);Lo([D(VIA)],ZC.prototype,"animationTriggers",2);Lo([D(Zg)],ZC.prototype,"animator",2);Lo([D()],ZC.prototype,"interactable",1);var zIA=Object.defineProperty,XIA=Object.getOwnPropertyDescriptor,eg=(g,A,e,t)=>{for(var i=t>1?void 0:t?XIA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&zIA(A,e,i),i};const Pq=IA("debuguilayout");class dr{constructor(){r(this,"left",0);r(this,"right",0);r(this,"top",0);r(this,"bottom",0)}get vertical(){return this.top+this.bottom}get horizontal(){return this.left+this.right}}eg([D()],dr.prototype,"left",2);eg([D()],dr.prototype,"right",2);eg([D()],dr.prototype,"top",2);eg([D()],dr.prototype,"bottom",2);class _o extends RA{constructor(){super(...arguments);r(this,"_rectTransform",null);r(this,"_needsUpdate",!1);r(this,"childAlignment",0);r(this,"reverseArrangement",!1);r(this,"spacing",0);r(this,"padding");r(this,"minWidth",0);r(this,"minHeight",0);r(this,"flexibleHeight",0);r(this,"flexibleWidth",0);r(this,"preferredHeight",0);r(this,"preferredWidth",0)}get rectTransform(){return this._rectTransform}onParentRectTransformChanged(e){this._needsUpdate=!0}get isDirty(){return this._needsUpdate}get isLayoutGroup(){return!0}updateLayout(){this._rectTransform&&(Pq&&console.warn("Layout Update",this.context.time.frame,this.name),this._needsUpdate=!1,this.onCalculateLayout(this._rectTransform))}start(){this._needsUpdate=!0}onEnable(){Pq&&console.log(this.name,this),this._rectTransform=this.gameObject.getComponent(YI);const e=this.gameObject.getComponentInParent(jg);e&&e.registerLayoutGroup(this),this._needsUpdate=!0}onDisable(){const e=this.gameObject.getComponentInParent(jg);e&&e.unregisterLayoutGroup(this)}set m_Spacing(e){e!==this.spacing&&(this._needsUpdate=!0,this.spacing=e)}get m_Spacing(){return this.spacing}}eg([D()],_o.prototype,"childAlignment",2);eg([D()],_o.prototype,"reverseArrangement",2);eg([D()],_o.prototype,"spacing",2);eg([D(dr)],_o.prototype,"padding",2);eg([D()],_o.prototype,"minWidth",2);eg([D()],_o.prototype,"minHeight",2);eg([D()],_o.prototype,"flexibleHeight",2);eg([D()],_o.prototype,"flexibleWidth",2);eg([D()],_o.prototype,"preferredHeight",2);eg([D()],_o.prototype,"preferredWidth",2);class ur extends _o{constructor(){super(...arguments);r(this,"childControlHeight",!0);r(this,"childControlWidth",!0);r(this,"childForceExpandHeight",!1);r(this,"childForceExpandWidth",!1);r(this,"childScaleHeight",!1);r(this,"childScaleWidth",!1)}onCalculateLayout(e){var m;const t=this.primaryAxis,i=e.width;let I=i;const o=e.height;let s=o;I-=this.padding.horizontal,s-=this.padding.vertical,t==="x"?this.padding.horizontal:this.padding.vertical;const n=t==="x",C=n?"y":"x",a=n?this.childControlWidth:this.childControlHeight,B=n?this.childControlHeight:this.childControlWidth,Q=n?this.childForceExpandWidth:this.childForceExpandHeight,E=n?this.childForceExpandHeight:this.childForceExpandWidth,c=n?s:I,d=n?i:o,l=.5*(n?this.childAlignment%3:Math.floor(this.childAlignment/3));let h=0;n?h+=this.padding.left:h+=this.padding.top;let p=0,u=0;for(let N=0;N<this.gameObject.children.length;N++){const y=this.gameObject.children[N],U=aA.getComponent(y,YI);U!=null&&U.activeAndEnabled&&(u+=1,n?p+=U.width:p+=U.height)}let f=0;const k=this.spacing*(u-1);if(Q||a){let N=0;n?N=I-=k:N=s-=k,u>0&&(f=N/u)}let G=0;G+=this.padding.left,G-=this.padding.right,l!==0&&(h=d-p,h*=l,h-=k*l,n?(h-=this.padding.right*l,h+=this.padding.left*(1-l),h<this.padding.left&&(h=this.padding.left)):(h-=this.padding.bottom*l,h+=this.padding.top*(1-l),h<this.padding.top&&(h=this.padding.top)));let M=1;for(let N=0;N<this.gameObject.children.length;N++){const y=this.gameObject.children[N],U=aA.getComponent(y,YI);if(U!=null&&U.activeAndEnabled){(m=U.pivot)==null||m.set(.5,.5),U.anchorMin.set(0,1),U.anchorMax.set(0,1);const H=i*.5+G*.5;U.anchoredPosition.x!==H&&(U.anchoredPosition.x=H);const x=o*-.5;U.anchoredPosition.y!==x&&(U.anchoredPosition.y=x),E&&B&&U.sizeDelta[C]!==c&&(U.sizeDelta[C]=c),Q&&a&&U.sizeDelta[t]!==f&&(U.sizeDelta[t]=f);const K=n?U.width:U.height,O=K*.5;if(h+=O,Q){const v=f*M-f*.5;v>h&&(h=v-f*.5+K+this.padding.left,h-=O)}let b=h;t==="y"&&(b=-b),U.anchoredPosition[t]!==b&&(U.anchoredPosition[t]=b),h+=O,h+=this.spacing,M+=1}}}}eg([D()],ur.prototype,"childControlHeight",2);eg([D()],ur.prototype,"childControlWidth",2);eg([D()],ur.prototype,"childForceExpandHeight",2);eg([D()],ur.prototype,"childForceExpandWidth",2);eg([D()],ur.prototype,"childScaleHeight",2);eg([D()],ur.prototype,"childScaleWidth",2);class iF extends ur{get primaryAxis(){return"y"}}class gF extends ur{get primaryAxis(){return"x"}}class IF extends _o{onCalculateLayout(){}}var $IA=Object.defineProperty,AoA=Object.getOwnPropertyDescriptor,Yn=(g,A,e,t)=>{for(var i=t>1?void 0:t?AoA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&$IA(A,e,i),i},oP=(g=>(g[g.ScreenSpaceOverlay=0]="ScreenSpaceOverlay",g[g.ScreenSpaceCamera=1]="ScreenSpaceCamera",g[g.WorldSpace=2]="WorldSpace",g[g.Undefined=-1]="Undefined",g))(oP||{});const hG=IA("debuguilayout"),sP=class extends Uu{constructor(){super(...arguments);r(this,"_renderOnTop");r(this,"_depthWrite",!1);r(this,"_doubleSided",!0);r(this,"_castShadows",!1);r(this,"_receiveShadows",!1);r(this,"_renderMode",-1);r(this,"_rootCanvas");r(this,"_scaleFactor",1);r(this,"worldCamera");r(this,"planeDistance",-1);r(this,"_boundRenderSettingsChanged",this.onRenderSettingsChanged.bind(this));r(this,"previousParent",null);r(this,"_lastMatrixWorld",null);r(this,"_rectTransforms",[]);r(this,"_layoutGroups",new Map);r(this,"_receivers",[]);r(this,"onBeforeRenderRoutine",()=>{var A,e,t,i;if(this.previousParent=this.gameObject.parent,((A=this.context.xr)!=null&&A.isVR||(e=this.context.xr)!=null&&e.isPassThrough)&&this.screenspace){this.gameObject.visible=!1,this.gameObject.removeFromParent();return}this.renderOnTop||this.screenspace?this.gameObject.removeFromParent():(this.onUpdateRenderMode(),this.handleLayoutUpdates(),(t=this.shadowComponent)==null||t.updateMatrixWorld(!0),(i=this.shadowComponent)==null||i.updateWorldMatrix(!0,!0),this.invokeBeforeRenderEvents(),Ao.ensureUpdateMeshUI(vb,this.context))});r(this,"onAfterRenderRoutine",()=>{var A,e,t,i,I;if(((A=this.context.xr)!=null&&A.isVR||(e=this.context.xr)!=null&&e.isPassThrough)&&this.screenspace){(t=this.previousParent)==null||t.add(this.gameObject);return}if((this.screenspace||this.renderOnTop)&&this.previousParent&&this.context.mainCamera){if(this.screenspace){const n=this.context.mainCamera;n==null||n.add(this.gameObject)}else this.previousParent.add(this.gameObject);const o=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(),(i=this.shadowComponent)==null||i.updateMatrixWorld(!0),this.invokeBeforeRenderEvents(),Ao.ensureUpdateMeshUI(vb,this.context,!0),this.context.renderer.render(this.gameObject,this.context.mainCamera),this.context.renderer.autoClear=o,this.context.renderer.autoClearColor=s,this.previousParent.add(this.gameObject)}(I=this._lastMatrixWorld)==null||I.copy(this.gameObject.matrixWorld)});r(this,"_updateRenderSettingsRoutine");r(this,"_activeRenderMode",-1);r(this,"_lastWidth",-1);r(this,"_lastHeight",-1)}get isCanvas(){return!0}get screenspace(){return this.renderMode!==2}set renderOnTop(A){A!==this._renderOnTop&&(this._renderOnTop=A,this.onRenderSettingsChanged())}get renderOnTop(){return this._renderOnTop!==void 0?this._renderOnTop:!!(this.screenspace&&this._renderMode===0)}set depthWrite(A){this._depthWrite!==A&&(this._depthWrite=A,this.onRenderSettingsChanged())}get depthWrite(){return this._depthWrite}set doubleSided(A){this._doubleSided!==A&&(this._doubleSided=A,this.onRenderSettingsChanged())}get doubleSided(){return this._doubleSided}set castShadows(A){this._castShadows!==A&&(this._castShadows=A,this.onRenderSettingsChanged())}get castShadows(){return this._castShadows}set receiveShadows(A){this._receiveShadows!==A&&(this._receiveShadows=A,this.onRenderSettingsChanged())}get receiveShadows(){return this._receiveShadows}get renderMode(){return this._renderMode}set renderMode(A){this._renderMode!==A&&(this._renderMode=A,this.onRenderSettingsChanged())}set rootCanvas(A){this._rootCanvas instanceof sP||(this._rootCanvas=A)}get rootCanvas(){return this._rootCanvas}get scaleFactor(){return this._scaleFactor}set scaleFactor(A){this._scaleFactor=A}awake(){var A;this.shadowComponent=this.gameObject,this.previousParent=this.gameObject.parent,hG&&console.log("Canvas.Awake()",((A=this.previousParent)==null?void 0:A.name)+"/"+this.gameObject.name),super.awake()}start(){this.onUpdateRenderMode()}onEnable(){super.onEnable(),this._updateRenderSettingsRoutine=void 0,this._lastMatrixWorld=new GA,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 A=this.context.pre_render_callbacks.indexOf(this.onBeforeRenderRoutine);A!==-1&&this.context.pre_render_callbacks.splice(A,1);const e=this.context.post_render_callbacks.indexOf(this.onAfterRenderRoutine);e!==-1&&this.context.post_render_callbacks.splice(e,1)}registerTransform(A){this._rectTransforms.push(A)}unregisterTransform(A){const e=this._rectTransforms.indexOf(A);e!==-1&&this._rectTransforms.splice(e,1)}registerLayoutGroup(A){const e=A.gameObject;this._layoutGroups.set(e,A)}unregisterLayoutGroup(A){const e=A.gameObject;this._layoutGroups.delete(e)}registerEventReceiver(A){this._receivers.push(A)}unregisterEventReceiver(A){const e=this._receivers.indexOf(A);e!==-1&&this._receivers.splice(e,1)}async onEnterXR(A){this.screenspace?(A.xr.isVR||A.xr.isPassThrough)&&(this.gameObject.visible=!1):(this.gameObject.visible=!1,await pT(1).then(()=>{this.gameObject.visible=!0}))}onLeaveXR(A){this.screenspace&&(A.xr.isVR||A.xr.isPassThrough)&&(this.gameObject.visible=!0)}invokeBeforeRenderEvents(){var A;for(const e of this._receivers)(A=e.onBeforeCanvasRender)==null||A.call(e,this)}handleLayoutUpdates(){this._lastMatrixWorld===null&&(this._lastMatrixWorld=new GA);const A=!this._lastMatrixWorld.equals(this.gameObject.matrixWorld);hG&&A&&console.log("Canvas Layout changed",this.context.time.frameCount,this.name);const e=!1;for(const t of this._rectTransforms){A&&t.markDirty();let i=this._layoutGroups.get(t.gameObject);t.isDirty&&!i&&(i=t.gameObject.getComponentInParent(_o)),(t.isDirty||i!=null&&i.isDirty)&&(hG&&!e&&console.log("CANVAS UPDATE ### "+t.name+" ##################################### "+this.context.time.frame),i==null||i.updateLayout(),t.updateTransform())}}applyRenderSettings(){this.onRenderSettingsChanged()}onRenderSettingsChanged(){this._updateRenderSettingsRoutine||(this._updateRenderSettingsRoutine=this.startCoroutine(this._updateRenderSettingsDelayed(),Ai.OnBeforeRender))}*_updateRenderSettingsDelayed(){if(yield,this._updateRenderSettingsRoutine=void 0,this.shadowComponent){this.onUpdateRenderMode(),qw(this.shadowComponent,this);for(const A of aA.getComponentsInChildren(this.gameObject,Zs))qw(A.shadowComponent,this)}}onUpdateRenderMode(A=!1){if(!A&&this._renderMode===this._activeRenderMode&&this._lastWidth===this.context.domWidth&&this._lastHeight===this.context.domHeight)return;this._activeRenderMode=this._renderMode;let e=this.context.mainCameraComponent,t=10;switch(e&&e.nearClipPlane>0&&e.farClipPlane>0&&(t=te.lerp(e.nearClipPlane,e.farClipPlane,.01)),this._renderMode===1&&(this.worldCamera&&(e=this.worldCamera),this.planeDistance>0&&(t=this.planeDistance)),this._renderMode){case 0:case 1:if(this._lastWidth=this.context.domWidth,this._lastHeight=this.context.domHeight,!e)return;const i=t+.01;this.gameObject.position.x=0,this.gameObject.position.y=0,this.gameObject.position.z=-i,this.gameObject.quaternion.identity();const I=this.gameObject.getComponent(YI);let o=!1;I.sizeDelta.x!==this.context.domWidth&&(o=!0),I.sizeDelta.y!==this.context.domHeight&&(o=!0);const s=e.fieldOfView*Math.PI/180,n=2*Math.tan(s/2)*Math.abs(i);this.gameObject.scale.x=n/this.context.domHeight,this.gameObject.scale.y=n/this.context.domHeight,this.gameObject.scale.z=.01,o&&(I.sizeDelta.x=this.context.domWidth,I.sizeDelta.y=this.context.domHeight,I==null||I.markDirty());break;case 2:this._lastWidth=-1,this._lastHeight=-1;break}}};let jg=sP;Yn([D()],jg.prototype,"renderOnTop",1);Yn([D()],jg.prototype,"depthWrite",1);Yn([D()],jg.prototype,"doubleSided",1);Yn([D()],jg.prototype,"castShadows",1);Yn([D()],jg.prototype,"receiveShadows",1);Yn([D()],jg.prototype,"renderMode",1);Yn([D(jg)],jg.prototype,"rootCanvas",1);Yn([D()],jg.prototype,"scaleFactor",1);Yn([D(Wt)],jg.prototype,"worldCamera",2);Yn([D()],jg.prototype,"planeDistance",2);var eoA=Object.defineProperty,toA=Object.getOwnPropertyDescriptor,oF=(g,A,e,t)=>{for(var i=t>1?void 0:t?toA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&eoA(A,e,i),i};class ar extends RA{constructor(){super(...arguments);r(this,"_alpha",1);r(this,"interactable",!0);r(this,"blocksRaycasts",!0);r(this,"_isDirty",!1);r(this,"_buffer",[])}get alpha(){return this._alpha}set alpha(e){e!==this._alpha&&(this._alpha=e,this.markDirty())}get isCanvasGroup(){return!0}markDirty(){this._isDirty||(this._isDirty=!0,this.startCoroutine(this.applyChangesDelayed(),Ai.OnBeforeRender))}*applyChangesDelayed(){this._isDirty=!1,this.applyChangesNow()}applyChangesNow(){this._buffer.length=0;for(const e of aA.getComponentsInChildren(this.gameObject,Zs,this._buffer)){const t=e;t.setAlphaFactor&&t.setAlphaFactor(this._alpha)}}}oF([D()],ar.prototype,"alpha",1);oF([D()],ar.prototype,"interactable",2);oF([D()],ar.prototype,"blocksRaycasts",2);var ioA=Object.defineProperty,goA=Object.getOwnPropertyDescriptor,yi=(g,A,e,t)=>{for(var i=t>1?void 0:t?goA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&ioA(A,e,i),i};const Wq=IA("debugusdzbehaviours");function _u(g){g&&(g.getComponentInParent(Ru)||(he()&&console.warn("Create Raycaster on "+g.name+" because no raycaster was found in the hierarchy"),g.addNewComponent(Ko)))}class QQ extends RA{constructor(){super(...arguments);r(this,"object");r(this,"target");r(this,"duration",1);r(this,"relativeMotion",!1);r(this,"coroutine",null);r(this,"targetPos",new w);r(this,"targetRot",new MA);r(this,"targetScale",new w)}start(){_u(this.gameObject)}onPointerClick(e){e.use(),this.coroutine&&this.stopCoroutine(this.coroutine),this.relativeMotion?this.coroutine=this.startCoroutine(this.moveRelative()):this.coroutine=this.startCoroutine(this.moveToTarget())}*moveToTarget(){if(!this.target||!this.object)return;const e=_e(this.object).clone(),t=_e(this.target).clone(),i=Jt(this.object).clone(),I=Jt(this.target).clone(),o=Vt(this.object).clone(),s=Vt(this.target).clone(),n=e.distanceTo(t),C=i.angleTo(I),a=o.distanceTo(s);if(n<.01&&C<.01&&a<.01){EI(this.object,t),Bs(this.object,I),wd(this.object,s),this.coroutine=null;return}let B=0,Q=0;for(;B<1;)B+=this.context.time.deltaTime/this.duration,B>1&&(B=1),Q=B<.5?4*B*B*B:1-Math.pow(-2*B+2,3)/2,this.targetPos.lerpVectors(e,t,Q),this.targetRot.slerpQuaternions(i,I,Q),this.targetScale.lerpVectors(o,s,Q),EI(this.object,this.targetPos),Bs(this.object,this.targetRot),wd(this.object,this.targetScale),yield;this.coroutine=null}*moveRelative(){if(!this.target||!this.object)return;const e=this.object.position.clone(),t=this.object.quaternion.clone(),i=this.object.scale.clone(),I=this.target.position.clone(),o=this.target.quaternion.clone(),s=this.target.scale.clone();I.applyQuaternion(this.object.quaternion),this.targetPos.copy(this.object.position).add(I),this.targetRot.copy(this.object.quaternion).multiply(o),this.targetScale.copy(this.object.scale).multiply(s);let n=0,C=0;for(;n<1;)n+=this.context.time.deltaTime/this.duration,n>1&&(n=1),C=n<.5?4*n*n*n:1-Math.pow(-2*n+2,3)/2,this.object.position.lerpVectors(e,this.targetPos,C),this.object.quaternion.slerpQuaternions(t,this.targetRot,C),this.object.scale.lerpVectors(i,this.targetScale,C),yield;this.coroutine=null}beforeCreateDocument(e){var t;if(this.target&&this.object&&this.gameObject){const i=new Cg("Move to "+((t=this.target)==null?void 0:t.name),Yg.tapTrigger(this.gameObject),Bt.transformAction(this.object,this.target,this.duration,this.relativeMotion?"relative":"absolute"));e.addBehavior(i)}}}yi([D(uA)],QQ.prototype,"object",2);yi([D(uA)],QQ.prototype,"target",2);yi([D()],QQ.prototype,"duration",2);yi([D()],QQ.prototype,"relativeMotion",2);var CD;const an=(CD=class extends RA{constructor(){super(...arguments);r(this,"materialToSwitch");r(this,"variantMaterial");r(this,"fadeDuration",0);r(this,"_objectsWithThisMaterial",null);r(this,"selfModel");r(this,"targetModels")}start(){this._objectsWithThisMaterial=this.objectsWithThisMaterial,_u(this.gameObject)}onPointerClick(A){if(A.use(),!!this.variantMaterial)for(let e=0;e<this.objectsWithThisMaterial.length;e++){const t=this.objectsWithThisMaterial[e];t.material=this.variantMaterial}}get objectsWithThisMaterial(){return this._objectsWithThisMaterial!=null?this._objectsWithThisMaterial:(this._objectsWithThisMaterial=[],this.variantMaterial&&this.materialToSwitch&&this.context.scene.traverse(A=>{if(A instanceof lA)if(Array.isArray(A.material)){for(const e of A.material)if(e===this.materialToSwitch){this.objectsWithThisMaterial.push(A);break}}else A.material===this.materialToSwitch&&this.objectsWithThisMaterial.push(A)}),this._objectsWithThisMaterial)}async beforeCreateDocument(A,e){this.targetModels=[],an._materialTriggersPerId={},an.variantSwitchIndex=0,this.materialToSwitch&&await Kt.assignTextureLOD(this.context,this.sourceId,this.materialToSwitch,0),this.variantMaterial&&await Kt.assignTextureLOD(this.context,this.sourceId,this.variantMaterial,0)}createBehaviours(A,e,t){this.objectsWithThisMaterial.find(I=>I.uuid===e.uuid)&&this.targetModels.push(e),this.gameObject.uuid===e.uuid&&(this.selfModel=e,this.materialToSwitch&&(an._materialTriggersPerId[this.materialToSwitch.uuid]||(an._materialTriggersPerId[this.materialToSwitch.uuid]=[]),an._materialTriggersPerId[this.materialToSwitch.uuid].push(this)))}afterCreateDocument(A,e){if(!this.materialToSwitch)return;const t=an._materialTriggersPerId[this.materialToSwitch.uuid];if(t){const i={};for(const I of t){const o=I.createVariants();o&&o.length>0&&(i[I.selfModel.uuid]=o)}for(const I of t){const o=[];for(const s in i)s!==I.selfModel.uuid&&o.push(...i[s]);I.createAndAttachBehaviors(A,i[I.selfModel.uuid],o)}}delete an._materialTriggersPerId[this.materialToSwitch.uuid]}createAndAttachBehaviors(A,e,t){const i=[],I=[],o=Math.max(0,this.fadeDuration);I.push(Bt.fadeAction([...this.targetModels,...t],o,!1)),i.push(Bt.fadeAction(e,o,!1)),I.push(Bt.fadeAction(e,o,!0)),A.addBehavior(new Cg("Select_"+this.selfModel.name,Yg.tapTrigger(this.selfModel),Bt.parallel(...I))),A.addBehavior(new Cg("StartHidden_"+this.selfModel.name,Yg.sceneStartTrigger(),Bt.parallel(...i)))}static getMaterialName(A){return Ps(A.name||"Material")+"_"+A.id}createVariants(){if(!this.variantMaterial)return null;const A=[];for(const e of this.targetModels){const t=e.clone();t.name+="_Variant_"+an.variantSwitchIndex+++"_"+an.getMaterialName(this.variantMaterial),t.displayName=t.displayName+": Variant with material "+this.variantMaterial.name,t.material=this.variantMaterial,t.geometry=e.geometry,t.matrix=e.matrix,(!e.parent||!e.parent.isEmpty())&&xI.createEmptyParent(e),e.parent&&e.parent.add(t),A.push(t)}return A}},r(CD,"_materialTriggersPerId",{}),r(CD,"variantSwitchIndex",0),CD);let Wc=an;yi([D(be)],Wc.prototype,"materialToSwitch",2);yi([D(be)],Wc.prototype,"variantMaterial",2);yi([D()],Wc.prototype,"fadeDuration",2);var aE;const ci=(aE=class extends RA{constructor(){super(...arguments);r(this,"target");r(this,"toggleOnClick",!1);r(this,"targetState",!0);r(this,"hideSelf",!0);r(this,"selfModel");r(this,"selfModelClone");r(this,"targetModel");r(this,"toggleModel");r(this,"stateBeforeCreatingDocument",!1);r(this,"targetStateBeforeCreatingDocument",!1)}start(){_u(this.gameObject)}onPointerClick(A){A.use(),!this.toggleOnClick&&this.hideSelf&&(this.gameObject.visible=!1),this.target&&(this.target.visible=this.toggleOnClick?!this.target.visible:this.targetState)}createBehaviours(A,e,t){e.uuid===this.gameObject.uuid&&(this.selfModel=e,this.selfModelClone=e.clone())}beforeCreateDocument(){this.target&&(this.gameObject[ci.wasVisible]===void 0&&(this.gameObject[ci.wasVisible]=this.gameObject.activeSelf),this.target[ci.wasVisible]===void 0&&(this.target[ci.wasVisible]=this.target.activeSelf),this.stateBeforeCreatingDocument=this.gameObject[ci.wasVisible],this.targetStateBeforeCreatingDocument=this.target[ci.wasVisible],this.gameObject.visible=!0,this.target.visible=!0)}afterCreateDocument(A,e){if(!this.target)return;this.targetModel=e.document.findById(this.target.uuid);const t=this.selfModel;if(this.selfModel&&this.targetModel){let i=this.selfModel,I=this.targetState;if(this.toggleOnClick)if(I=!this.targetStateBeforeCreatingDocument,!this.selfModelClone.geometry)(!this.selfModel.parent||this.selfModel.parent.isEmpty())&&AY.createEmptyParent(this.selfModel),this.toggleModel=this.selfModel.deepClone(),this.toggleModel.name+="_toggle",this.selfModel.parent.add(this.toggleModel);else{if(!this.gameObject[ci.toggleClone]){const C=this.selfModelClone.clone();C.matrix.identity(),C.name+="_toggle"+ci.clonedToggleIndex++,t.add(C),this.gameObject[ci.toggleClone]=C,console.warn("USDZExport: Toggle "+this.gameObject.name+" doesn't have geometry. It will be deep cloned and nested behaviours will likely not work.")}const n=this.gameObject[ci.toggleClone];if(!this.gameObject[ci.reverseToggleClone]){const C=this.selfModelClone.clone();C.matrix.identity(),C.name+="_toggleReverse"+ci.clonedToggleIndex++,t.add(C),this.gameObject[ci.reverseToggleClone]=C}this.toggleModel=this.gameObject[ci.reverseToggleClone],(!this.toggleModel.geometry||!n.geometry)&&console.error("triggers without childs and without geometry won't work!",this,t.geometry),i=n,t.geometry=null,t.material=null}if(this.toggleModel){if(this.toggleOnClick){const n=[];n.push(Bt.fadeAction(i,0,!1)),n.push(Bt.fadeAction(this.toggleModel,0,!0)),n.push(Bt.fadeAction(this.targetModel,0,I)),A.addBehavior(new Cg("Toggle_"+i.name+"_toggleTo"+(I?"On":"Off"),Yg.tapTrigger(i),Bt.parallel(...n)));const C=[];C.push(Bt.fadeAction(this.toggleModel,0,!1)),C.push(Bt.fadeAction(i,0,!0)),C.push(Bt.fadeAction(this.targetModel,0,!I)),A.addBehavior(new Cg("Toggle_"+i.name+"_toggleTo"+(I?"Off":"On"),Yg.tapTrigger(this.toggleModel),Bt.parallel(...C)))}}else{const n=[];this.hideSelf&&n.push(Bt.fadeAction(i,0,!1)),n.push(Bt.fadeAction(this.targetModel,0,I)),A.addBehavior(new Cg("Toggle_"+i.name+"_toggleTo"+(I?"On":"Off"),Yg.tapTrigger(i),Bt.parallel(...n)))}const o=n=>{const C=xI.createEmpty();C.name="InputTarget",C.displayName=void 0,C.type="RealityKitComponent",C.onSerialize=a=>{a.appendLine("bool allowsDirectInput = 1"),a.appendLine("bool allowsIndirectInput = 1"),a.appendLine('uniform token info:id = "RealityKit.InputTarget"')},n.add(C)};o(i),this.toggleModel&&o(this.toggleModel);const s=new Array;this.targetStateBeforeCreatingDocument||s.push(this.targetModel),this.stateBeforeCreatingDocument||s.push(t),this.toggleModel&&s.push(this.toggleModel),A.addBehavior(new Cg("HideOnStart_"+this.gameObject.name,Yg.sceneStartTrigger(),Bt.fadeAction(s,0,!1)))}}afterSerialize(A,e){this.gameObject[ci.wasVisible]!==void 0&&(this.gameObject.visible=this.gameObject[ci.wasVisible],delete this.gameObject[ci.wasVisible]),this.target&&this.target[ci.wasVisible]!==void 0&&(this.target.visible=this.target[ci.wasVisible],delete this.target[ci.wasVisible]),delete this.gameObject[ci.toggleClone],delete this.gameObject[ci.reverseToggleClone]}},r(aE,"clonedToggleIndex",0),r(aE,"wasVisible",Symbol("usdz_SetActiveOnClick_wasVisible")),r(aE,"toggleClone",Symbol("clone for toggling")),r(aE,"reverseToggleClone",Symbol("clone for reverse toggling")),aE);let EQ=ci;yi([D(uA)],EQ.prototype,"target",2);yi([D()],EQ.prototype,"toggleOnClick",2);yi([D()],EQ.prototype,"targetState",2);yi([D()],EQ.prototype,"hideSelf",2);class sF extends RA{start(){this.gameObject.visible=!1}createBehaviours(A,e,t){e.uuid===this.gameObject.uuid&&A.addBehavior(new Cg("HideOnStart_"+this.gameObject.name,Yg.sceneStartTrigger(),Bt.fadeAction(e,0,!1)))}beforeCreateDocument(){this.gameObject.visible=!0}afterCreateDocument(){this.gameObject.visible=!1}}class Zc extends RA{constructor(){super(...arguments);r(this,"target");r(this,"duration",.5);r(this,"motionType","bounce")}beforeCreateDocument(){}createBehaviours(e,t,i){if(this.target&&t.uuid===this.gameObject.uuid){const I=new Cg("emphasize "+this.name,Yg.tapTrigger(this.gameObject),Bt.emphasize(this.target,this.duration,this.motionType,void 0,"basic"));e.addBehavior(I)}}afterCreateDocument(e,t){}}yi([D()],Zc.prototype,"target",2);yi([D()],Zc.prototype,"duration",2);yi([D()],Zc.prototype,"motionType",2);class rr extends RA{constructor(){super(...arguments);r(this,"target");r(this,"clip","");r(this,"toggleOnClick",!1)}start(){_u(this.gameObject)}ensureAudioSource(){if(!this.target){const e=this.gameObject.addNewComponent(Di);e&&(this.target=e,e.spatialBlend=1,e.volume=1,e.loop=!1)}}onPointerClick(e){var t;e.use(),!(!((t=this.target)!=null&&t.clip)&&!this.clip)&&(this.ensureAudioSource(),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(e,t,i){if(!(!this.target&&!this.clip)&&t.uuid===this.gameObject.uuid){const I=this.clip?this.clip:this.target?this.target.clip:void 0;if(!I||typeof I!="string")return;const o=this.target?this.target.gameObject:this.gameObject,s=Cr.getName(I),n=this.target?this.target.volume:1,C=this.target&&this.target.spatialBlend==0?"nonSpatial":"spatial";let a=!1;if(this.gameObject.traverse(B=>{B instanceof lA&&B.visible&&(a=!0)}),a=!0,a){let B=Bt.playAudioAction(o,"audio/"+s,"play",n,C);this.toggleOnClick&&(B.multiplePerformOperation="stop"),this.target&&this.target.loop&&(B=Bt.sequence(B).makeLooping());const Q=new Cg("playAudio "+this.name,Yg.tapTrigger(this.gameObject),B);e.addBehavior(Q)}if(this.target&&this.target.playOnAwake&&this.target.enabled){let B=Bt.playAudioAction(o,"audio/"+s,"play",n,C);this.target.loop&&(B=Bt.sequence(B).makeLooping());const Q=new Cg("playAudioOnStart"+(this.name?"_"+this.name:""),Yg.sceneStartTrigger(),B);e.addBehavior(Q)}}}async afterSerialize(e,t){if(!this.target&&!this.clip)return;const i=this.clip?this.clip:this.target?this.target.clip:void 0;if(!i||typeof i!="string")return;const o="audio/"+Cr.getName(i);if(t.files[o])return;const C=await(await(await fetch(i)).blob()).arrayBuffer(),a=new Uint8Array(C);t.files[o]=a}}yi([D(Di)],rr.prototype,"target",2);yi([D(URL)],rr.prototype,"clip",2);yi([D()],rr.prototype,"toggleOnClick",2);var aD;const ka=(aD=class extends RA{constructor(){super(...arguments);r(this,"animator");r(this,"stateName");r(this,"trigger","tap");r(this,"animation");r(this,"selfModel");r(this,"stateAnimationModel");r(this,"animationSequence",new Array);r(this,"animationLoopAfterSequence",new Array)}get target(){var A,e;return((A=this.animator)==null?void 0:A.gameObject)||((e=this.animation)==null?void 0:e.gameObject)}start(){_u(this.gameObject)}onPointerClick(A){var e;A.use(),this.target&&this.stateName&&((e=this.animator)==null||e.play(this.stateName,0,0,.1))}createBehaviours(A,e,t){e.uuid===this.gameObject.uuid&&(this.selfModel=e)}afterSerialize(){if(ka.rootsWithExclusivePlayback.size>1){const A='Multiple root objects targeted by more than one animation. To work around QuickLook bug FB13410767, animations will be set as "exclusive" and activating them will stop other animations being marked as exclusive.';he()&&fi(A),console.warn(A,...ka.rootsWithExclusivePlayback)}ka.animationActions=[],ka.rootsWithExclusivePlayback=new Set}afterCreateDocument(A,e){if(this.animationSequence===void 0&&this.animationLoopAfterSequence===void 0||!this.stateAnimationModel||!this.target)return;const t=e.document,i=e.extensions.find(s=>s instanceof Ku);if(!i)return;const I=i.getClipCount(this.target)>1;I&&(he()&&console.warn("Setting exclusive playback for "+this.target.name+"@"+this.stateName+" because it has "+i.getClipCount(this.target)+" animations. This works around QuickLook bug FB13410767."),ka.rootsWithExclusivePlayback.add(this.target));const o=(s,n)=>{let C=ka.animationActions.find(a=>a.affectedObjects==s&&a.start==n.start&&a.duration==n.duration);return C||(C=Bt.startAnimationAction(s,n.start,n.duration),ka.animationActions.push(C)),C};t.traverse(s=>{var n,C;if(s.uuid===((n=this.target)==null?void 0:n.uuid)){const a=Bt.sequence();if(this.animationSequence&&this.animationSequence.length>0)for(const Q of this.animationSequence)a.addAction(o(s,Q));if(this.animationLoopAfterSequence&&this.animationLoopAfterSequence.length>0){const Q=a.actions.length==0?a:Bt.sequence();for(const E of this.animationLoopAfterSequence)Q.addAction(o(s,E));Q.makeLooping(),a!==Q&&a.addAction(Q)}const B=new Cg("_tap_"+this.name+"_toPlayClip_"+this.stateName+"_on_"+((C=this.target)==null?void 0:C.name),this.trigger=="tap"?Yg.tapTrigger(this.selfModel):Yg.sceneStartTrigger(),a);I&&B.makeExclusive(!0),A.addBehavior(B)}})}createAnimation(A,e,t){var C,a,B,Q,E,c,d;if(!this.target||!this.animator&&!this.animation)return;if(this.stateAnimationModel=e,this.animation){this.animationSequence=new Array,this.animationLoopAfterSequence=new Array;const l=A.registerAnimation(this.target,this.animation.clip);l&&this.animationLoopAfterSequence.push(l);return}const i=(C=this.animator)==null?void 0:C.runtimeAnimatorController;let I=i==null?void 0:i.findState(this.stateName),o=[],s=[];if(i&&I){const l=new Array;l.push(I);let h=!1;for(;l.length<100;){if(!I||I===null||!I.transitions||I.transitions.length===0){(a=I.motion)!=null&&a.isLooping&&(h=!0);break}const p=I.transitions.find(f=>f.conditions.length===0),u=p?i.getState(p.destinationState,0):null;if(u&&l.includes(u)){I=u,h=!0;break}else if(p){if(I=u,!I)break;l.push(I)}else{h=((B=I.motion)==null?void 0:B.isLooping)??!1;break}}if(h&&I){const p=l.indexOf(I);o=l.slice(0,p),s=l.slice(p),Wq&&console.log("found loop from "+this.stateName,"states until loop",o,"states looping",s)}else o=l,s=[],Wq&&console.log("found no loop from "+this.stateName,"states",o)}if(o.length===1&&(!((Q=o[0].motion)!=null&&Q.clip)||((c=(E=o[0].motion)==null?void 0:E.clip.tracks)==null?void 0:c.length)===0)){this.animationSequence=new Array;const l=A.registerAnimation(this.target,null);l&&this.animationSequence.push(l);return}if(o=o.filter(l=>{var h,p,u;return((h=l.motion)==null?void 0:h.clip)&&((u=(p=l.motion)==null?void 0:p.clip.tracks)==null?void 0:u.length)>0}),s=s.filter(l=>{var h,p,u;return((h=l.motion)==null?void 0:h.clip)&&((u=(p=l.motion)==null?void 0:p.clip.tracks)==null?void 0:u.length)>0}),o.length===0&&s.length===0){console.warn("No clips found for state "+this.stateName+" on "+((d=this.animator)==null?void 0:d.name)+", can't export animation data");return}const n=(l,h)=>{var u;if(!this.target)return;const p=A.registerAnimation(this.target,l.motion.clip??null);p?h.push(p):console.warn("Couldn't register animation for state "+l.name+" on "+((u=this.animator)==null?void 0:u.name))};if(o.length>0){this.animationSequence=new Array;for(const l of o)n(l,this.animationSequence)}if(s.length>0){this.animationLoopAfterSequence=new Array;for(const l of s)n(l,this.animationLoopAfterSequence)}}},r(aD,"animationActions",[]),r(aD,"rootsWithExclusivePlayback",new Set),aD);let OB=ka;yi([D(Zg)],OB.prototype,"animator",2);yi([D()],OB.prototype,"stateName",2);class jc extends RA{constructor(){super(...arguments);r(this,"target")}getType(){}getDuration(){}}yi([D(uA)],jc.prototype,"target",2);class Tu extends RA{constructor(){super(...arguments);r(this,"target")}}yi([D(jc)],Tu.prototype,"target",2);class Hu extends jc{constructor(){super(...arguments);r(this,"type",1);r(this,"duration",1)}getType(){switch(this.type){case 1:return"hide";case 0:return"show"}}getDuration(){return this.duration}}yi([D()],Hu.prototype,"type",2);yi([D()],Hu.prototype,"duration",2);class nF extends Tu{}var IoA=Object.defineProperty,ooA=Object.getOwnPropertyDescriptor,jC=(g,A,e,t)=>{for(var i=t>1?void 0:t?ooA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&IoA(A,e,i),i};const Zq=IA("debugcharactercontroller");class cQ extends RA{constructor(){super(...arguments);r(this,"center",new w(0,0,0));r(this,"radius",.5);r(this,"height",2);r(this,"_rigidbody",null);r(this,"_activeGroundCollisions");r(this,"_contactVelocity",new w)}get rigidbody(){return this._rigidbody?this._rigidbody:(this._rigidbody=this.gameObject.getComponent(vt),this._rigidbody||(this._rigidbody=this.gameObject.addNewComponent(vt)),this.rigidbody)}awake(){this._activeGroundCollisions=new Set}onEnable(){const e=this.rigidbody;let t=this.gameObject.getComponent(LC);t||(t=this.gameObject.addNewComponent(LC)),t.center.copy(this.center),t.radius=this.radius,t.height=this.height;const i=new w(0,0,1),I=new w(1,0,0),o=new w(0,1,0),s=this.gameObject.getWorldDirection(new w);s.y=0;const n=I.dot(s)<0?-1:1,C=i.angleTo(s)*n;this.gameObject.setRotationFromAxisAngle(o,C),e.lockRotationX=!0,e.lockRotationY=!0,e.lockRotationZ=!0}move(e){this.gameObject.position.add(e)}onCollisionEnter(e){(e.contacts.length==0||e.contacts.some(t=>t.normal.y>.2))&&(this._activeGroundCollisions.add(e),Zq&&console.log(`Collision(${this._activeGroundCollisions.size}): ${e.contacts.map(t=>t.normal.y.toFixed(2)).join(", ")} - ${this.isGrounded}`))}onCollisionExit(e){this._activeGroundCollisions.delete(e),Zq&&console.log(`Collision(${this._activeGroundCollisions.size}) - ${this.isGrounded}`)}get isGrounded(){return this._activeGroundCollisions.size>0}get contactVelocity(){var e;this._contactVelocity.set(0,0,0);for(const t of this._activeGroundCollisions){const i=(e=this.context.physics.engine)==null?void 0:e.getLinearVelocity(t.collider);i&&(this._contactVelocity.x+=i.x,this._contactVelocity.y+=i.y,this._contactVelocity.z+=i.z)}return this._contactVelocity}}jC([D(w)],cQ.prototype,"center",2);jC([D()],cQ.prototype,"radius",2);jC([D()],cQ.prototype,"height",2);class VC extends RA{constructor(){super(...arguments);r(this,"controller");r(this,"movementSpeed",2);r(this,"rotationSpeed",2);r(this,"jumpForce",1);r(this,"doubleJumpForce",2);r(this,"animator");r(this,"lookForward",!0);r(this,"lookInput",new iA(0,0));r(this,"moveInput",new iA(0,0));r(this,"jumpInput",!1);r(this,"_currentSpeed",new w(0,0,0));r(this,"_currentAngularSpeed",new w(0,0,0));r(this,"_temp",new w(0,0,0));r(this,"_jumpCount",0);r(this,"_currentRotation");r(this,"_raycastOptions",new Qs)}awake(){this._currentRotation=new MA}update(){const e=this.context.input;e.isKeyPressed("KeyW")?this.moveInput.y+=1:e.isKeyPressed("KeyS")&&(this.moveInput.y-=1),e.isKeyPressed("KeyD")?this.lookInput.x+=1:e.isKeyPressed("KeyA")&&(this.lookInput.x-=1),this.jumpInput||(this.jumpInput=e.isKeyDown("Space"))}move(e){this.moveInput.add(e)}look(e){this.lookInput.add(e)}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(e,t,i){var I,o,s,n,C,a,B,Q,E,c,d;if((I=this.controller)!=null&&I.isGrounded&&(this._jumpCount=0,this.doubleJumpForce>0&&((o=this.animator)==null||o.setBool("doubleJump",!1))),this._currentSpeed.z+=e.y*this.movementSpeed*this.context.time.deltaTime,(s=this.animator)==null||s.setBool("running",e.length()>.01),(C=this.animator)==null||C.setBool("jumping",((n=this.controller)==null?void 0:n.isGrounded)===!0&&i),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+=te.toRadians(-t.x*this.rotationSpeed)*this.context.time.deltaTime,this.lookForward&&Math.abs(this._currentAngularSpeed.y)<.01){const l=this.context.mainCameraComponent.forward;l.y=0,l.normalize(),this._currentRotation.setFromUnitVectors(new w(0,0,1),l),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&&i&&this.jumpForce>0){let l=(a=this.controller)==null?void 0:a.isGrounded;if(this.doubleJumpForce>0&&!((B=this.controller)!=null&&B.isGrounded)&&this._jumpCount===1&&(l=!0,(Q=this.animator)==null||Q.setBool("doubleJump",!0)),l){this._jumpCount+=1;const h=this.controller.rigidbody,p=this._jumpCount===2?this.doubleJumpForce:this.jumpForce;h.applyImpulse(new w(0,1,0).multiplyScalar(p))}}if(this.controller){const l=(E=this.controller)==null?void 0:E.rigidbody.getVelocity().y;if(l<-1){this._raycastOptions.ray||(this._raycastOptions.ray=new io),this._raycastOptions.ray.origin.copy(_e(this.gameObject)),this._raycastOptions.ray.direction.set(0,-1,0);const h=this.layer;this.gameObject.layers.disableAll(),this.gameObject.layers.set(2);const p=this.context.physics.raycast(this._raycastOptions);this.gameObject.layers.set(h),(p.length&&p[0].distance>2||l<-10)&&((c=this.animator)==null||c.setBool("falling",!0))}else(d=this.animator)==null||d.setBool("falling",!1)}}}jC([D(cQ)],VC.prototype,"controller",2);jC([D()],VC.prototype,"movementSpeed",2);jC([D()],VC.prototype,"rotationSpeed",2);jC([D()],VC.prototype,"jumpForce",2);jC([D()],VC.prototype,"doubleJumpForce",2);jC([D(Zg)],VC.prototype,"animator",2);var soA=Object.defineProperty,noA=Object.getOwnPropertyDescriptor,CoA=(g,A,e,t)=>{for(var i=t>1?void 0:t?noA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&soA(A,e,i),i};class Yu extends hI{constructor(){super(...arguments);r(this,"intensity")}get typeName(){return"ChromaticAberration"}init(){this.intensity.defaultValue=0}onCreateEffect(){const e=new UY;return e.offset=new iA(0,0),e.radialModulation=!0,e.modulationOffset=.15,this.intensity.valueProcessor=t=>t*.02,this.intensity.onValueChanged=t=>{e.offset.x=-t,e.offset.y=t},e}}CoA([D(qe)],Yu.prototype,"intensity",2);us("ChromaticAberration",Yu);const Ou=new ue;Ou.setAttribute("position",new ie(new Float32Array([-1,-1,3,-1,-1,3]),2));Ou.setAttribute("uv",new ie(new Float32Array([0,0,2,0,0,2]),2));Ou.boundingSphere=new Ji;Ou.computeBoundingSphere=function(){};const aoA=new OC;class Pr{constructor(A){this._mesh=new lA(Ou,A),this._mesh.frustumCulled=!1}render(A){A.render(this._mesh,aoA)}get material(){return this._mesh.material}set material(A){this._mesh.material=A}dispose(){this._mesh.material.dispose(),this._mesh.geometry.dispose()}}const roA={uniforms:{sceneDiffuse:{value:null},sceneDepth:{value:null},sceneNormal:{value:null},projMat:{value:new GA},viewMat:{value:new GA},projViewMat:{value:new GA},projectionMatrixInv:{value:new GA},viewMatrixInv:{value:new GA},cameraPos:{value:new w},resolution:{value:new iA},time:{value:0},samples:{value:[]},bluenoise:{value:null},distanceFalloff:{value:1},radius:{value:5},near:{value:.1},far:{value:1e3},logDepth:{value:!1},ortho:{value:!1},screenSpaceRadius:{value:!1},frame:{value:0}},depthWrite:!1,depthTest:!1,vertexShader:`
|