@needle-tools/engine 3.10.3-beta → 3.10.4-beta

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.
@@ -5018,7 +5018,7 @@ void main() {
5018
5018
  justify-content: center;
5019
5019
  align-items: flex-start;
5020
5020
  gap: 10px;
5021
- `,this.context.appendHTMLElement(t);const g=tm;tm&&console.log("ARSupported?",Wc,"VRSupported?",Vc),(g||this.createARButton&&this.enableAR&&Wc)&&(A=Ti.createARButton(this),this._arButton=A,t.appendChild(A)),(g||this.createVRButton&&this.enableVR&&Vc)&&(e=Ti.createVRButton(this),this._vrButton=e,t.appendChild(e)),setTimeout(()=>{Ti.resetButtonStyles(e),Ti.resetButtonStyles(A)},1e3)}get TransformOrientation(){return this._transformOrientation}get HeadPose(){return this._currentHeadPose}onBeforeRender(A){var t;if(!A)return;const e=this.context.renderer.xr.getSession();if(e){const g=A.getViewerPose(this.context.renderer.xr.getReferenceSpace());if(!g)return;this._currentHeadPose=g;const I=g==null?void 0:g.transform;I&&this._transformOrientation.set(I.orientation.x,I.orientation.y,I.orientation.z,I.orientation.w),Ti._isInXr===!1&&e&&this.onEnterXR(e,A);for(const o of this.controllers)o.onUpdate(e);this._isInAR&&((t=this.webAR)==null||t.onUpdate(e,A))}Ti.events.dispatchEvent({type:"xrUpdate",frame:A,xr:this.context.renderer.xr,rig:this.rig})}onClickedARButton(){this._isInAR||(this._requestedAR=!0,this._requestedVR=!1,this.captureStateBeforeXR())}onClickedVRButton(){if(!this._isInVR){if(this._requestedVR){this.onExitXR(null);return}this._requestedAR=!1,this._requestedVR=!0,this.captureStateBeforeXR(),this.ensureRig();for(let A=0;A<2;A++)gi.Create(this,A,this.gameObject,mE.PhysicalDevice);Ti.events.dispatchEvent({type:"requestVRSession"})}}captureStateBeforeXR(){this.context.mainCamera&&(this._originalCameraPosition.copy(ye(this.context.mainCamera)),this._originalCameraRotation.copy(Oi(this.context.mainCamera)),this._originalCameraParent=this.context.mainCamera.parent),this.Rig&&(this._originalXRRigParent=this.Rig.parent,this._originalXRRigPosition.copy(this.Rig.position),this._originalXRRigRotation.copy(this.Rig.quaternion))}ensureRig(){if(!this.rig){const A=eA.findObjectOfType(DS,this.context);A?(this.rig=A.gameObject,this.rig.rotateY(Math.PI)):(this.rig=new To,this.rig.rotateY(Math.PI),this.rig.name="XRRig",this.context.scene.add(this.rig))}}onEnterXR(A,e){var o,s;console.log("[XR] session begin",A,e),Ti._isInXr=!0,this.ensureRig();const t=this.context.renderer.xr.getReferenceSpace();if(t&&this.rig){const C=e.getViewerPose(t),n=C==null?void 0:C.transform.orientation;if(n){const a=new LA(n.x,n.y,n.z,n.w),r=new ug().setFromQuaternion(a);this.rig.rotateY(r.y)}}const g=this.context.renderer.xr;if(this.context.mainCamera){const C=g.getCamera();tm&&console.log("WebXRCamera",C);const n=(o=this.context.mainCameraComponent)==null?void 0:o.cullingMask;if(C&&n!==void 0){for(const a of C.cameras)a.layers.mask=n;C.layers.mask=n}else if(C){for(const a of C.cameras)a.layers.enableAll();C.layers.enableAll()}this.rig.add(this.context.mainCamera),this._requestedAR&&this.context.scene.add(this.rig)}const I=this._requestedAR?Gi.AR:Gi.VR;switch(Yo.Global.Set(I),I){case Gi.AR:this.context.xrSessionMode=id.ImmersiveAR,this._isInAR=!0,(s=this.webAR)==null||s.onBegin(A);break;case Gi.VR:this.context.xrSessionMode=id.ImmersiveVR,this._isInVR=!0,this.onEnterVR(A);break}A.addEventListener("end",()=>{console.log("[XR] session end"),Ti._isInXr=!1,this.onExitXR(A)}),this.onEnterXR_HandleMirrorWindow(A),Ti.events.dispatchEvent({type:"xrStarted",session:A})}onExitXR(A){var t,g,I,o;const e=this._isInAR;A&&(this._isInAR?(t=this.webAR)==null||t.onEnd(A):(g=this.context.mainCameraComponent)==null||g.applyClearFlagsIfIsActiveCamera()),this._isInAR=!1,this._isInVR=!1,this._requestedAR=!1,this._requestedVR=!1,this.context.xrSessionMode=void 0,this.xrMirrorWindow&&(this.xrMirrorWindow.close(),this.xrMirrorWindow=null),this.destroyControllers(),this.context.mainCamera&&((I=this._originalCameraParent)==null||I.add(this.context.mainCamera),di(this.context.mainCamera,this._originalCameraPosition),qI(this.context.mainCamera,this._originalCameraRotation),this.context.mainCamera.scale.set(1,1,1)),e&&((o=this._originalXRRigParent)==null||o.add(this.rig),this.rig.position.copy(this._originalXRRigPosition),this.rig.quaternion.copy(this._originalXRRigRotation)),Yo.Global.Set(Gi.Browser|Gi.ThirdPerson),Ti.events.dispatchEvent({type:"xrStopped",session:A})}onEnterVR(A){}destroyControllers(){var A;for(let e=this.controllers.length-1;e>=0;e-=1)(A=this.controllers[e])==null||A.destroy();this.controllers.length=0}onEnterXR_HandleMirrorWindow(A){oA("mirror")&&setTimeout(()=>{if(!Ti.IsInWebXR)return;const e=new URL(window.location.href);Ll(e.searchParams,Qy,1),Ll(e.searchParams,"isMirror",1);const t=e.toString();this.xrMirrorWindow=window.open(t,"webxr sync","popup=yes"),this.xrMirrorWindow&&(this.xrMirrorWindow.onload=()=>{this.xrMirrorWindow&&(this.xrMirrorWindow.onbeforeunload=()=>{Ti.IsInWebXR&&A.end()})})},1e3)}},B(XQ,"_isInXr",!1),B(XQ,"events",new Vi),B(XQ,"_optionalFeatures_VR",["local-floor","bounded-floor","hand-tracking","high-fixed-foveation-level","layers"]),B(XQ,"_optionalFeatures_AR",["anchors","local-floor","hand-tracking","layers"]),XQ);let Se=Ti;Sh([y()],Se.prototype,"enableVR",2);Sh([y()],Se.prototype,"enableAR",2);Sh([y(og)],Se.prototype,"defaultAvatar",2);Sh([y()],Se.prototype,"handModelPath",2);Sh([y()],Se.prototype,"createVRButton",2);Sh([y()],Se.prototype,"createARButton",2);const lE=class{constructor(A){B(this,"_webxr");B(this,"reticle",null);B(this,"reticleParent",null);B(this,"hitTestSource",null);B(this,"reticleActive",!0);B(this,"previousBackground",null);B(this,"previousEnvironment",null);B(this,"sessionRoot",null);B(this,"_previousParent",null);B(this,"arDomOverlay",null);B(this,"arOverlayElement",null);B(this,"noHitTestAvailable",!1);B(this,"didPlaceARSessionRoot",!1);this._webxr=A}get webxr(){return this._webxr}get context(){return this.webxr.context}getAROverlayContainer(){this.arDomOverlay=this.webxr.context.domElement;const A=this.arDomOverlay;return A.getAROverlayContainer?this.arOverlayElement=A.getAROverlayContainer():this.arOverlayElement=this.arDomOverlay,this.arOverlayElement}setReticleActive(A){this.reticleActive=A}async onBegin(A){var o,s,C,n;const e=this.webxr.context;this.reticleActive=!0,this.didPlaceARSessionRoot=!1,this.getAROverlayContainer();const t=(o=navigator.userAgent)!=null&&o.includes("OculusBrowser")?mE.PhysicalDevice:mE.Touch,g=t===mE.Touch?4:2;for(let a=0;a<g;a++)gi.Create(this.webxr,a,this.webxr.gameObject,t);if((!this.sessionRoot||this.sessionRoot.destroyed||!this.sessionRoot.activeAndEnabled)&&(this.sessionRoot=eA.findObjectOfType(lC,e)),!this.sessionRoot){const a=this.webxr.gameObject;this.sessionRoot=eA.addNewComponent(a,lC),console.warn("WebAR: No ARSessionRoot found, creating one automatically on the WebXR object")}this.previousBackground=e.scene.background,this.previousEnvironment=e.scene.environment,e.scene.background=null,A.requestReferenceSpace("viewer").then(a=>{var r,Q;(Q=(r=A.requestHitTestSource)==null?void 0:r.call(A,{space:a}))==null||Q.then(E=>{this.hitTestSource=E}).catch(E=>{this.noHitTestAvailable=!0,console.warn("WebXR: Hit test not supported",E)})}),!this.reticle&&this.sessionRoot&&(this.reticle=new yA(new Hd(.07,.09,32).rotateX(-Math.PI/2),new dt),this.reticle.name="AR Placement reticle",this.reticle.matrixAutoUpdate=!1,this.reticle.visible=!1,this.reticleParent=new bA,this.reticleParent.name="AR Reticle Parent",this.reticleParent.matrixAutoUpdate=!1,this.reticleParent.add(this.reticle),this.webxr.scene?(this.context.scene.add(this.reticleParent),this.context.scene.visible=!0):console.warn("Could not found WebXR Rig")),this._previousParent=this.webxr.gameObject,lE.tempWebXRObject||(lE.tempWebXRObject=new bA),this.context.scene.add(lE.tempWebXRObject),eA.addComponent(lE.tempWebXRObject,this.webxr),this.sessionRoot?(this.sessionRoot.webAR=this,(s=this.sessionRoot)==null||s.onBegin(A)):console.warn("No WebARSessionRoot found in scene");const I=this.context.domElement;(C=I==null?void 0:I.onEnterAR)==null||C.call(I,A,this.arOverlayElement),(n=this.context.mainCameraComponent)==null||n.applyClearFlagsIfIsActiveCamera()}onEnd(A){var g,I;this._previousParent&&(eA.addComponent(this._previousParent,this.webxr),this._previousParent=null),this.hitTestSource=null;const e=this.webxr.context;e.scene.background=this.previousBackground,e.scene.environment=this.previousEnvironment,this.sessionRoot&&this.sessionRoot.onEnd(this.webxr.Rig,A);const t=this.context.domElement;(g=t.onExitAR)==null||g.call(t,A),(I=this.context.mainCameraComponent)==null||I.applyClearFlagsIfIsActiveCamera()}onUpdate(A,e){var g,I;if(this.noHitTestAvailable===!0){if(this.reticle&&(this.reticle.visible=!1),!this.didPlaceARSessionRoot){this.didPlaceARSessionRoot=!0;const o=this.webxr.Rig,s=wgA.clone();(g=this.sessionRoot)==null||g.placeAt(o,s)}return}if(!this.hitTestSource)return;const t=e.getHitTestResults(this.hitTestSource);if(t.length){const o=t[0],s=this.webxr.context.renderer.xr.getReferenceSpace();if(s){const C=o.getPose(s);if(this.sessionRoot){const n=this.sessionRoot.onUpdate(this.webxr.Rig,A,C);this.didPlaceARSessionRoot=n}if(this.reticle&&(this.reticle.visible=this.reticleActive,this.reticleActive&&C)){const n=C.transform.matrix;this.reticle.matrix.fromArray(n),this.webxr.Rig&&this.reticle.matrix.premultiply(this.webxr.Rig.matrix)}}}else(I=this.sessionRoot)==null||I.onUpdate(this.webxr.Rig,A,null),this.reticle&&(this.reticle.visible=!1)}};let uB=lE;B(uB,"tempWebXRObject");const wgA=new qA().identity().makeTranslation(0,0,0);class dn{constructor(A,e){B(this,"used",!1);B(this,"inputSource");B(this,"object");B(this,"pointerId");B(this,"isDown");B(this,"isUp");B(this,"isPressed");B(this,"isClicked");B(this,"input");B(this,"event");this.event=e,this.input=A}use(){this.used=!0,this.pointerId!==void 0&&this.input.setPointerUsed(this.pointerId)}stopPropagation(){var A;(A=this.event)==null||A.stopImmediatePropagation()}Use(){this.use()}StopPropagation(){var A;(A=this.event)==null||A.stopImmediatePropagation()}clone(){const A=new dn(this.input,this.event);return Object.assign(A,this),A}}class kh extends mA{awake(){II.createIfNoneExists(this.context)}onEnable(){var A;(A=II.get(this.context))==null||A.register(this)}onDisable(){var A;(A=II.get(this.context))==null||A.unregister(this)}performRaycast(A=null){return null}}class Un extends kh{constructor(){super(...arguments);B(this,"targets",null);B(this,"raycastHits",[])}start(){this.targets=[this.gameObject]}performRaycast(e=null){return this.targets?(e??(e=new Fs),e.targets=this.targets,e.results=this.raycastHits,this.context.physics.raycast(e)):null}}class SF extends Un{}const zc=oA("debugeventsystem");var qM=(i=>(i.BeforeHandleInput="BeforeHandleInput",i.AfterHandleInput="AfterHandleInput",i))(qM||{});const Vs=class extends mA{constructor(){super();B(this,"raycaster",[]);B(this,"_selectStartFn");B(this,"_selectEndFn");B(this,"_selectUpdateFn");B(this,"_handleEventFn");B(this,"lastPointerEvent",null);B(this,"objectsHoveredThisFrame",[]);B(this,"objectsHoveredLastFrame",[]);B(this,"raisedPointerDownEvents",[]);B(this,"raisedPointerDownObjects",[]);B(this,"_didMove",!1);B(this,"_tempComponentsArray",[]);B(this,"_sortedHits",[]);B(this,"_sortingBuffer",[]);B(this,"_noDepthTestingResults",[]);B(this,"handleEventsArray",[]);B(this,"out",{});B(this,"currentActiveMeshUIComponents",[]);Vs.systems.push(this)}static createIfNoneExists(e){this.didSearchEventSystem||(this.didSearchEventSystem=!0,Vs.systems.length<=0&&Vs.systems.push(...eA.findObjectsOfType(Vs,e)));for(const g of Vs.systems)if(g.context===e)return;const t=new bA;eA.addNewComponent(t,Vs),e.scene.add(t)}static get systems(){const e=Je.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){en.update(e,t)}static markUIDirty(e){en.markDirty()}get hasActiveUI(){return this.currentActiveMeshUIComponents.length>0}get isHoveringObjects(){return this.objectsHoveredThisFrame.length>0}onDestroy(){Vs.systems.splice(Vs.systems.indexOf(this),1)}start(){if(this.raycaster.length<=0&&!eA.findObjectOfType(kh,this.context)){const t=eA.addNewComponent(this.context.scene,Un);this.raycaster.push(t),Ci()&&console.warn("Added an ObjectRaycaster to the scene because no raycaster was found",this)}}register(e){var t;e&&this.raycaster&&!this.raycaster.includes(e)&&((t=this.raycaster)==null||t.push(e))}unregister(e){var g,I;const t=(g=this.raycaster)==null?void 0:g.indexOf(e);t!==void 0&&t!==-1&&((I=this.raycaster)==null||I.splice(t,1))}onEnable(){const e=new Map;this._selectStartFn??(this._selectStartFn=(g,I)=>{if(!I.grab)return;en.resetLastSelected();const o=new dn(this.context.input);o.inputSource=g,o.pointerId=0,o.isDown=g.selectionDown,o.isUp=g.selectionUp,o.isPressed=g.selectionPressed,o.isClicked=!1,e.set(g,I.grab),I.grab&&!this.handleEvents(I.grab,o)&&(I.grab=null)}),this._selectEndFn??(this._selectEndFn=(g,I)=>{var C;if(!I.grab)return;const o=new dn(this.context.input);o.inputSource=g,o.pointerId=0,o.isDown=g.selectionDown,o.isUp=g.selectionUp,o.isPressed=g.selectionPressed,o.isClicked=g.selectionClick,this.handleEvents(I.grab,o);const s=e.get(g);if(e.set(g,null),s)for(let n=0;n<this.raisedPointerDownEvents.length;n++){const a=this.raisedPointerDownEvents[n];this.raisedPointerDownObjects[n]===s&&a&&((C=a.onPointerUp)==null||C.call(a,o),this.raisedPointerDownEvents.splice(n,1),this.raisedPointerDownObjects.splice(n,1),n--)}});const t=new Fs;this._selectUpdateFn??(this._selectUpdateFn=g=>{t.ray=g.getRay();const I=this.performRaycast(t);if(!I)return;const o=new dn(this.context.input);o.inputSource=g,this.handleIntersections(I,o)}),gi.addEventListener(An.SelectStart,this._selectStartFn),gi.addEventListener(An.SelectEnd,this._selectEndFn),gi.addEventListener(An.Update,this._selectUpdateFn),this._handleEventFn??(this._handleEventFn=this.onHandleEvents.bind(this)),this.context.pre_update_callbacks.push(this._handleEventFn)}onDisable(){gi.removeEventListener(An.SelectStart,this._selectStartFn),gi.removeEventListener(An.SelectEnd,this._selectEndFn),gi.removeEventListener(An.Update,this._selectUpdateFn),this.context.pre_update_callbacks.splice(this.context.pre_update_callbacks.indexOf(this._handleEventFn),1)}onHandleEvents(){if(this.objectsHoveredThisFrame.length=0,this.resetMeshUIStates(),Se.IsInWebXR||this.context.input.isKeyPressed("AltLeft")||this.context.input.isKeyPressed("AltRight"))return;if(!this._didMove){const s=this.context.input.getPointerPositionRC(0);if(s&&s.x===0&&s.y===0)return;this._didMove=!0}let e=0;for(const s of this.context.input.foreachPointerId()){const C=this.context.input.getPointerDown(s),n=this.context.input.getPointerUp(s);if(C||n){e=s;break}}const t=this.context.input.getPointerEvent(e),g=new dn(this.context.input,t);g.inputSource=this.context.input,g.pointerId=e,g.isClicked=this.context.input.getPointerClicked(e),g.isDown=this.context.input.getPointerDown(e),g.isUp=this.context.input.getPointerUp(e),g.isPressed=this.context.input.getPointerPressed(e),zc&&g.isClicked&&console.log("CLICK",e);const I=this.performRaycast(null);if(!I)return;this.lastPointerEvent=g;const o={sender:this,args:g,hasActiveUI:this.currentActiveMeshUIComponents.length>0};zc&&g.isClicked&&Mi("EventSystem: "+g.pointerId+" - "+this.context.time.frame+" - Up:"+g.isUp+", Down:"+g.isDown),this.dispatchEvent(new CustomEvent("BeforeHandleInput",{detail:o})),this.handleIntersections(I,g),this.dispatchEvent(new CustomEvent("AfterHandleInput",{detail:o}))}onBeforeRender(){if(this.lastPointerEvent)this.lastPointerEvent.used=!1;else return;if(this.lastPointerEvent.isUp){for(const t of this.raisedPointerDownEvents)t.onPointerUp&&t.onPointerUp(this.lastPointerEvent);this.raisedPointerDownEvents.length=0,this.raisedPointerDownObjects.length=0}for(const t of this.objectsHoveredLastFrame)if(this.objectsHoveredThisFrame.indexOf(t)<0){this._tempComponentsArray.length=0;const g=eA.getComponentsInParent(t,mA,this._tempComponentsArray);this.lastPointerEvent.object=t;for(let I=0;I<g.length;I++){const o=g[I];if(!o.gameObject||o.destroyed)continue;const s=o;s.onPointerExit&&s.onPointerExit(this.lastPointerEvent)}}const e=this.objectsHoveredLastFrame;this.objectsHoveredLastFrame=this.objectsHoveredThisFrame,this.objectsHoveredThisFrame=e}performRaycast(e){if(!this.raycaster)return null;this._sortedHits.length=0;for(const t of this.raycaster){if(!t.activeAndEnabled)continue;const g=t.performRaycast(e);g&&g.length>0&&this._sortedHits.push(...g)}return this._sortedHits.sort((t,g)=>t.distance-g.distance),this._sortedHits}handleIntersections(e,t){if(!e||e.length<=0)return!1;e=this.sortCandidates(e);for(const g of e){const{object:I}=g;if(this.handleEvents(I,t))return!0}return!1}sortCandidates(e){this._sortingBuffer.length=0,this._noDepthTestingResults.length=0;for(let t=0;t<e.length;t++){const g=e[t],I=g.object;if(I.material&&I.material.depthTest===!1){this._noDepthTestingResults.push(g);continue}this._sortingBuffer.push(g)}for(const t of this._sortingBuffer)this._noDepthTestingResults.push(t);return this._noDepthTestingResults}handleEvents(e,t){if(!this.testIsVisible(e))return t.isClicked&&zc&&console.log("not allowed",e),!1;const g=e;t.object=e,this.lastPointerEvent=t;const I=e.parent;let o=!1;const s=t.isClicked??!1;let C=null;if(I&&I.isUI){const n=(t.isPressed||t.isClicked)??!1;if(I[AC]){const a=I[AC].gameObject;if(a){if(!jE.isInteractable(a,this.out))return!1;C=this.out.canvasGroup??null,this.handleMeshUIIntersection(e,n),e=a,o=!0}}if(!o&&this.handleMeshUiObjectWithoutShadowDom(I,n))return!0}if(s&&zc&&console.log(this.context.time.frame,e),this.objectsHoveredThisFrame.push(e),C===null||C.interactable){const n=this.objectsHoveredLastFrame.indexOf(e)>=0;this.handleEventsArray.length=0;const a=eA.getComponentsInParent(e,mA,this.handleEventsArray);for(let r=0;r<a.length;r++){if(t.used)return!0;if(a[r].destroyed)continue;const Q=a[r];if(Q.interactable!==!1){if(Q.onPointerEnter&&(n||Q.onPointerEnter(t)),Q.onPointerMove&&Q.onPointerMove(t),t.isDown&&Q.onPointerDown&&!this.raisedPointerDownEvents.includes(Q)&&(Q.onPointerDown(t),this.raisedPointerDownEvents.push(Q),this.raisedPointerDownObjects.push(g)),t.isUp&&Q.onPointerUp){const E=this.raisedPointerDownEvents.indexOf(Q);E!==-1&&this.raisedPointerDownEvents.splice(E,1),Q.onPointerUp(t)}t.isClicked&&Q.onPointerClick&&Q.onPointerClick(t)}}}return!0}handleMeshUiObjectWithoutShadowDom(e,t){return!e||!e.isUI?!0:this.handleMeshUIIntersection(e,t)}handleMeshUIIntersection(e,t){const g=en.updateState(e,t);return g&&this.currentActiveMeshUIComponents.push(g),g!==null}resetMeshUIStates(){if(this.context.input.getPointerPressedCount()>0&&en.resetLastSelected(),!(!this.currentActiveMeshUIComponents||this.currentActiveMeshUIComponents.length<=0)){for(let e=0;e<this.currentActiveMeshUIComponents.length;e++){const t=this.currentActiveMeshUIComponents[e];en.resetState(t)}this.currentActiveMeshUIComponents.length=0}}testIsVisible(e){return e?eA.isActiveSelf(e)?this.testIsVisible(e.parent):!1:!0}};let II=Vs;B(II,"_eventSystemMap",new Map),B(II,"didSearchEventSystem",!1);class en{static markDirty(){this.needsUpdate=!0}static update(A,e){const t=e.time.frameCount;for(const g of this.lastUpdateFrame)if(g.context===e){if(t===g.frame)return;g.frame=t;let I=this.needsUpdate||t<1;g.nextUpdate===e.time.frameCount&&(I=!0),I&&(zc&&console.log("Update threemeshui"),this.needsUpdate=!1,A.update());return}this.lastUpdateFrame=[{context:e,frame:t,nextUpdate:t}],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}}B(en,"lastSelected",null),B(en,"lastUpdateFrame",[]),B(en,"needsUpdate",!1);const lD=Symbol("cameraController");function SgA(i){return i[lD]}function Ob(i,A,e){e?i[lD]=A:i[lD]===A&&(i[lD]=null)}var kgA=Object.defineProperty,mgA=Object.getOwnPropertyDescriptor,GgA=(i,A,e,t)=>{for(var g=t>1?void 0:t?mgA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&kgA(A,e,g),g};const $p=oA("freecam"),im=oA("debugcamerafit"),MgA={LEFT:"",UP:"",RIGHT:"",BOTTOM:""};let gm;class Tn extends mA{constructor(){super(...arguments);B(this,"autoRotate",!1);B(this,"autoRotateSpeed",1);B(this,"enableKeys",!0);B(this,"enableDamping",!0);B(this,"dampingFactor",.1);B(this,"enableZoom",!0);B(this,"minZoom",0);B(this,"maxZoom",1/0);B(this,"enablePan",!0);B(this,"lookAtConstraint",null);B(this,"lookAtConstraint01",1);B(this,"middleClickToFocus",!0);B(this,"doubleClickToFocus",!0);B(this,"useSlerp",!0);B(this,"debugLog",!1);B(this,"targetLerpSpeed",5);B(this,"_lookTargetPosition");B(this,"_controls",null);B(this,"_cameraObject",null);B(this,"_lerpToTargetPosition",!1);B(this,"_lerpCameraToTarget",!1);B(this,"_cameraTargetPosition",null);B(this,"_inputs",0);B(this,"_enableTime",0);B(this,"_startedListeningToKeyEvents",!1);B(this,"_eventSystem");B(this,"_afterHandleInputFn");B(this,"_camera",null);B(this,"_syncedTransform");B(this,"targetElement",null);B(this,"onControlsChangeStarted",()=>{this._syncedTransform&&this._syncedTransform.requestOwnership()});B(this,"_shouldDisable",!1);B(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)}awake(){this._lookTargetPosition=new m,this._startedListeningToKeyEvents=!1}start(){if(this._controls){const e=eA.getComponent(this.gameObject,Ot);if(e&&!this.setFromTargetPosition()){this.debugLog&&console.log("NO TARGET");const g=ye(e.cam).length(),I=new m(0,0,-g).applyMatrix4(e.cam.matrixWorld);this.setTarget(I,!0)}}this.startCoroutine(this.startRaycastDelayed()),this._eventSystem=II.get(this.context)??void 0,this._eventSystem&&(this._afterHandleInputFn=this.afterHandleInput.bind(this),this._eventSystem.addEventListener(qM.AfterHandleInput,this._afterHandleInputFn))}onDestroy(){var e,t;(e=this._controls)==null||e.dispose(),(t=this._eventSystem)==null||t.removeEventListener(qM.AfterHandleInput,this._afterHandleInputFn)}onEnable(){this._enableTime=this.context.time.time;const e=eA.getComponent(this.gameObject,Ot);this._camera=e;const t=e==null?void 0:e.cam;if(t&&Ob(t,this,!0),!this._controls){console.assert(t!=null,"Missing camera",this),t&&(this._cameraObject=t);const g=this.targetElement??this.context.domElement,I=t==null?void 0:t.quaternion.clone();this._controls=new G$(t,g),t==null||t.quaternion.copy(I),gm===void 0&&(gm={...this._controls.keys})}this._controls&&($p&&(this.enablePan=!0,this.enableZoom=!0,this.middleClickToFocus=!0,ir()&&(this.doubleClickToFocus=!0)),this._controls.addEventListener("start",this.onControlsChangeStarted),(t==null?void 0:t.type)==="PerspectiveCamera"?$p||(this._controls.minDistance=this.minZoom,this._controls.maxDistance=this.maxZoom):$p||(this._controls.minZoom=this.minZoom,this._controls.maxZoom=this.maxZoom),this._startedListeningToKeyEvents||(this._startedListeningToKeyEvents=!0,this._controls.listenToKeyEvents(window.document.body))),this._syncedTransform=eA.getComponent(this.gameObject,ja)??void 0}onDisable(){var e;(e=this._camera)!=null&&e.cam&&Ob(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))}*startRaycastDelayed(){if(yield,!this.setFromTargetPosition()){const e=new Fs;e.screenPoint=new X(0,0),e.lineThreshold=.1;const t=this.context.physics.raycast(e);t.length>0&&this.setTarget(t[0].point,!0)}}onBeforeRender(){var t,g,I;if(!this._controls||this._cameraObject!==this.context.mainCamera)return;(this.context.input.getPointerDown(0)||this.context.input.getPointerDown(1)||this.context.input.getPointerDown(2))&&(this._inputs+=1),this._inputs>0&&(this.autoRotate=!1,this._controls.autoRotate=!1,this._lerpCameraToTarget=!1,this._lerpToTargetPosition=!1),this._inputs=0;let 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.context.input.getPointerDown(0)||this.context.input.mouseWheelChanged)&&(this._lerpToTargetPosition=!1,this._lerpCameraToTarget=!1),this._lerpToTargetPosition||this._lerpCameraToTarget){const o=this.context.time.deltaTime*this.targetLerpSpeed;if(this._lerpCameraToTarget&&this._cameraTargetPosition&&this._cameraObject){if(this.useSlerp){const s=(t=this._cameraObject)==null?void 0:t.position;JT(s,this._cameraTargetPosition,o)}else(g=this._cameraObject)==null||g.position.lerp(this._cameraTargetPosition,o);this._cameraObject.position.distanceTo(this._cameraTargetPosition)<1e-4&&(this._lerpCameraToTarget=!1)}this._lerpToTargetPosition&&(this.lerpTarget(this._lookTargetPosition,o),this._lookTargetPosition.distanceTo(this._controls.target)<1e-5&&(this._lerpToTargetPosition=!1))}!$p&&((I=this.lookAtConstraint)!=null&&I.locked)&&this.setFromTargetPosition(0,this.lookAtConstraint01),this._controls&&(this.debugLog&&(this._controls.domElement=this.context.renderer.domElement),this._controls.enabled=!this._shouldDisable&&this._camera===this.context.mainCameraComponent&&!this.context.isInXR,this._controls.enableDamping=this.enableDamping,this._controls.keys=this.enableKeys?gm:MgA,this._controls.autoRotate=this.autoRotate,this._controls.autoRotateSpeed=this.autoRotateSpeed,this._controls.enableZoom=this.enableZoom,this._controls.dampingFactor=this.dampingFactor,this._controls.enablePan=this.enablePan,this.context.isInXR||this._controls.update())}setCameraTarget(e,t=!1){var g;e?(this._lerpCameraToTarget=!0,this._cameraTargetPosition=e.clone(),t&&this._cameraTargetPosition&&((g=this.controllerObject)==null||g.position.copy(this._cameraTargetPosition))):this._lerpCameraToTarget=!1}setFromTargetPosition(e=0,t=1){var I;if(!this._controls)return!1;const g=(I=this.lookAtConstraint)==null?void 0:I.sources;if(g&&g.length>0){const o=g[e];if(o)return o.getWorldPosition(this._lookTargetPosition),this.lerpTarget(this._lookTargetPosition,t),!0}return!1}setTarget(e=null,t=!1){this._controls&&(e!==null&&this._lookTargetPosition.copy(e),t?this._controls.target.copy(this._lookTargetPosition):this._lerpToTargetPosition=!0)}lerpTarget(e,t){this._controls&&this._controls.target.lerp(e,t)}distanceToTarget(e){return this._controls?this._controls.target.distanceTo(e):-1}setTargetFromRaycast(){var t,g;if(!this.controls)return;const e=this.context.physics.raycast();for(const I of e)if(I.distance>0&&eA.isActiveInHierarchy(I.object)){if(this._lookTargetPosition.copy(I.point),this._lerpToTargetPosition=!0,this._cameraTargetPosition=null,this.context.mainCamera){this._lerpCameraToTarget=!0;const o=ye(this.context.mainCamera);this._cameraTargetPosition=o.clone().sub(this.controls.target).add(this._lookTargetPosition),(g=(t=this._cameraObject)==null?void 0:t.parent)==null||g.worldToLocal(this._cameraTargetPosition)}break}}fitCamera(e,t=1.1){const g=this._cameraObject,I=this._controls;if(e!=null&&e.length||(e=this.context.scene.children),e.length<=0||!g||!I)return;const o=new m,s=new m,C=new Hi;C.makeEmpty();for(const d of e)d instanceof OG||d instanceof iU||C.expandByObject(d,!0);if(g.updateMatrixWorld(),g.updateProjectionMatrix(),C.getCenter(s),C.applyMatrix4(g.matrixWorldInverse),C.getSize(o),C.setFromCenterAndSize(s,o),o.length()<=1e-10){im&&console.warn("Camera fit size is zero",C,[...e]);return}const n=g.fov,a=2*Math.atan(Math.tan(n*Math.PI/360/2)*g.aspect)/Math.PI*360,r=o.y/(2*Math.atan(Math.PI*n/360)),Q=o.x/(2*Math.atan(Math.PI*a/360)),E=t*Math.max(r,Q)+o.z/2;im&&console.log("Fit camera to objects",r,Q,"distance",E);const h=ye(g),l=I.target.clone().sub(h).normalize().multiplyScalar(E);if(I.maxDistance=E*10,I.minDistance=E*.01,I.target.copy(s),g.near=E/100,g.far=E*100,g.updateMatrixWorld(),g.updateProjectionMatrix(),di(g,I.target.clone().sub(l)),im){const d=new OG(C);this.context.scene.add(d),LT(d,Fw(g)),this._haveAttachedKeyboardEvents||(this._haveAttachedKeyboardEvents=!0,document.body.addEventListener("keydown",c=>{c.code==="KeyF"&&this.fitCamera(e)}))}I.update()}}GgA([y(iu)],Tn.prototype,"lookAtConstraint",2);var RgA=Object.defineProperty,UgA=Object.getOwnPropertyDescriptor,$o=(i,A,e,t)=>{for(var g=t>1?void 0:t?UgA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&RgA(A,e,g),g},dO=(i=>(i[i.Skybox=1]="Skybox",i[i.SolidColor=2]="SolidColor",i[i.Uninitialized=4]="Uninitialized",i))(dO||{});const jc=oA("debugcam"),Pb=oA("debugscreenpointtoray");var Lf;const Zc=(Lf=class extends mA{constructor(){super(...arguments);B(this,"_nearClipPlane",.1);B(this,"_farClipPlane",1e3);B(this,"orthographic",!1);B(this,"orthographicSize",5);B(this,"ARBackgroundAlpha",0);B(this,"_cullingMask",4294967295);B(this,"_backgroundBlurriness");B(this,"_backgroundIntensity");B(this,"_targetTexture",null);B(this,"_backgroundColor");B(this,"_fov");B(this,"_cam",null);B(this,"_clearFlags",2);B(this,"_skybox")}get isCamera(){return!0}get aspect(){return this._cam instanceof je?this._cam.aspect:this.context.domWidth/this.context.domHeight}get fieldOfView(){return this._cam instanceof je?this._cam.fov:this._fov}set fieldOfView(A){const e=this.fieldOfView!=A;if(this._fov=A,e&&this._cam&&this._cam instanceof je){if(this._fov===void 0){console.error("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 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}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){let g=this.cam;const I=Zc._origin;I.set(A,e,-1),this.context.input.convertScreenspaceToRaycastSpace(I),Pb&&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(g);const o=Zc._direction.set(I.x,I.y,I.z),s=ye(g);return o.sub(s),o.normalize(),t?(t.set(s,o),t):new pC(s.clone(),o.clone())}awake(){Pb&&window.addEventListener("pointerdown",A=>{const e=A.clientX,t=A.clientY;console.log("touch",e.toFixed(2),t.toFixed(2));const g=this.screenPointToRay(e,t),I="#"+Math.floor(Math.random()*16777215).toString(16);ln.DrawRay(g.origin,g.direction,I,10)})}onEnable(){jc&&console.log(this),this.buildCamera(),(this.tag=="MainCamera"||!this.context.mainCameraComponent)&&(this.context.setCurrentCamera(this),NgA(this)),this.applyClearFlagsIfIsActiveCamera()}onDisable(){this.context.removeCamera(this)}onBeforeRender(){if(this._cam&&this._targetTexture){this.context.isManagedExternally&&(this._warnedAboutExternalRenderer||(this._warnedAboutExternalRenderer=!0,console.warn("Rendering with external renderer is not supported yet. This may not work or throw errors. Please remove the the target texture from your camera: "+this.name,this.targetTexture))),this.context.composer;const A=this.context.renderer;A&&this._targetTexture.render(this.context.scene,this._cam,A)}}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 je&&(this._fov=e.fov)):e=this.gameObject.children[0],e&&e.isCamera)e instanceof je&&(this._fov&&(e.fov=this._fov),e.near=this._nearClipPlane,e.far=this._farClipPlane,e.updateProjectionMatrix());else if(!this.orthographic)e=new je(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 KB(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){jc&&console.log("Camera does not exist (apply clear flags)");return}switch(this.fieldOfView=this._fov,jc&&Mi("apply Camera clear flags: "+this._clearFlags),this._clearFlags){case 1:if(Zc.backgroundShouldBeTransparent(this.context)&&(!this.ARBackgroundAlpha||this.ARBackgroundAlpha<.001)){this.context.scene.background=null,this.context.renderer.setClearColor(0,0);return}this.enableSkybox(),this._backgroundBlurriness!==void 0&&(this.context.scene.backgroundBlurriness=this._backgroundBlurriness),this._backgroundIntensity!==void 0&&(this.context.scene.backgroundIntensity=this._backgroundIntensity);break;case 2:if(this._backgroundColor){let A=this._backgroundColor.alpha;Zc.backgroundShouldBeTransparent(this.context)&&(A=this.ARBackgroundAlpha??0),this.context.scene.background=null,this.context.renderer.setClearColor(this._backgroundColor,A)}break;case 4:this.context.scene.background=null,this.context.renderer.setClearColor(0,0);break}}enableSkybox(){this._skybox||(this._skybox=new FgA(this)),this._skybox.enable()}static backgroundShouldBeTransparent(A){var I,o,s,C;const e=(I=A.renderer.xr)==null?void 0:I.getSession();if(!e)return!1;const t=e.environmentBlendMode;jc&&Mi("Environment blend mode: "+t+" on "+navigator.userAgent);const g=t==="additive"||t==="alpha-blend";if(A.xrSessionMode===id.ImmersiveAR&&t==="opaque"){if((o=navigator.userAgent)!=null&&o.includes("OculusBrowser"))return!0;if((s=navigator.userAgent)!=null&&s.includes("Mozilla")&&((C=navigator.userAgent)!=null&&C.includes("Mobile WebXRViewer/v2")))return!0}return g}},B(Lf,"_origin",new m),B(Lf,"_direction",new m),Lf);let Ot=Zc;$o([y()],Ot.prototype,"fieldOfView",1);$o([y()],Ot.prototype,"nearClipPlane",1);$o([y()],Ot.prototype,"farClipPlane",1);$o([y()],Ot.prototype,"clearFlags",1);$o([y()],Ot.prototype,"orthographic",2);$o([y()],Ot.prototype,"orthographicSize",2);$o([y()],Ot.prototype,"ARBackgroundAlpha",2);$o([y()],Ot.prototype,"cullingMask",1);$o([y()],Ot.prototype,"backgroundBlurriness",1);$o([y()],Ot.prototype,"backgroundIntensity",1);$o([y(kt)],Ot.prototype,"backgroundColor",1);$o([y(Ta)],Ot.prototype,"targetTexture",1);class FgA{constructor(A){B(this,"_camera");B(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&&(jc&&console.log("Set skybox",this._camera,this._skybox),this._skybox.colorSpace=Ie,this._skybox.mapping=_o,this.context.scene.background=this._skybox):console.warn("Failed to load/find skybox texture",this._camera.sourceId,this.context.lightmaps)}}function NgA(i){oA("freecam")&&i.context.mainCameraComponent===i&&eA.getOrAddComponent(i.gameObject,Tn)}class ZE extends mA{constructor(){super(...arguments);B(this,"_listener",null)}get listener(){return this._listener==null&&(this._listener=new AU),this._listener}awake(){Ni.registerWaitForAllowAudio(()=>{if(this.destroyed)return;const e=this.listener;if(e==null||e.parent)return;const t=eA.getComponentInParent(this.gameObject,Ot);t?t.cam.add(e):this.gameObject.add(e)})}}var KgA=Object.defineProperty,JgA=Object.getOwnPropertyDescriptor,yS=(i,A,e,t)=>{for(var g=t>1?void 0:t?JgA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&KgA(A,e,g),g};const qgA=oA("debugsignals");class au{constructor(){B(this,"guid")}}yS([y()],au.prototype,"guid",2);class mh{constructor(){B(this,"signal");B(this,"reaction")}}yS([y(au)],mh.prototype,"signal",2);yS([y(FI)],mh.prototype,"reaction",2);var $m;const zC=($m=class extends mA{constructor(){super(...arguments);B(this,"events")}static invoke(A){if(zC.receivers[A]){const e=zC.receivers[A];if(!e)return;for(const t of e)t.invoke(A)}}awake(){qgA&&console.log("SignalReceiver awake",this)}onEnable(){if(this.events)for(const A of this.events)zC.receivers[A.signal.guid]||(zC.receivers[A.signal.guid]=[]),zC.receivers[A.signal.guid].push(this)}onDisable(){if(this.events){for(const A of this.events)if(zC.receivers[A.signal.guid]){const e=zC.receivers[A.signal.guid].indexOf(this);e>=0&&zC.receivers[A.signal.guid].splice(e,1)}}}invoke(A){if(!this.events||!Array.isArray(this.events))return;let 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(g){console.error(g)}}},B($m,"receivers",{}),$m);let Gh=zC;yS([y(mh)],Gh.prototype,"events",2);var PI=(i=>(i.Activation="ActivationTrack",i.Animation="AnimationTrack",i.Audio="AudioTrack",i.Control="ControlTrack",i.Marker="MarkerTrack",i.Signal="SignalTrack",i))(PI||{}),Ps=(i=>(i[i.None=0]="None",i[i.Hold=1]="Hold",i[i.Loop=2]="Loop",i[i.PingPong=3]="PingPong",i[i.Continue=4]="Continue",i))(Ps||{}),kF=(i=>(i.Signal="SignalEmitter",i))(kF||{});const yc=oA("debugtimeline"),Yy=class extends mA{constructor(){super(...arguments);B(this,"playableAsset");B(this,"playOnAwake");B(this,"extrapolationMode",1);B(this,"waitForAudio",!0);B(this,"_visibilityChangeEvt");B(this,"_clonedPlayableAsset",!1);B(this,"_speed",1);B(this,"_guidsMap");B(this,"_isPlaying",!1);B(this,"_internalUpdateRoutine");B(this,"_isPaused",!1);B(this,"_time",0);B(this,"_duration",0);B(this,"_weight",1);B(this,"_animationTracks",[]);B(this,"_audioTracks",[]);B(this,"_signalTracks",[]);B(this,"_controlTracks",[]);B(this,"_customTracks",[]);B(this,"_allTracks",[this._animationTracks,this._audioTracks,this._signalTracks,this._controlTracks,this._customTracks])}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:(yc||aI())&&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,g;yc&&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((g=this.playableAsset)==null?void 0:g.tracks),this)}onEnable(){var e,t;for(const g of this._audioTracks)(e=g.onEnable)==null||e.call(g);for(const g of this._customTracks)(t=g.onEnable)==null||t.call(g);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;this.stop();for(const g of this._audioTracks)(e=g.onDisable)==null||e.call(g);for(const g of this._customTracks)(t=g.onDisable)==null||t.call(g);this._visibilityChangeEvt&&window.removeEventListener("visibilitychange",this._visibilityChangeEvt)}onDestroy(){var e;for(const t of this._allTracks)for(const g of t)(e=g.onDestroy)==null||e.call(g)}rebuildGraph(){this.isValid()&&(this.resolveBindings(),this.updateTimelineDuration(),this.setupAndCreateTrackHandlers())}async play(){if(!this.isValid())return;const e=this._isPaused==!0;if(this._isPaused=!1,e&&this.invokePauseChangedMethodsOnTracks(),!this._isPlaying){if(this._isPlaying=!0,this.waitForAudio){const t=[];for(const g of this._audioTracks){const I=g.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&&!Ni.userInteractionRegistered&&this.waitForAudio;)await Kd(200)}this._internalUpdateRoutine=this.startCoroutine(this.internalUpdate())}}pause(){this.isValid()&&(this._isPlaying=!1,!this._isPaused&&(this._isPaused=!0,this.evaluate(),this.invokePauseChangedMethodsOnTracks()))}stop(){for(const g of this._audioTracks)g.stop();const e=this._isPaused==!0,t=this._isPlaying;this._isPlaying&&(this._time=0,this._isPlaying=!1,this._isPaused=!1,this.evaluate(),e&&this.invokePauseChangedMethodsOnTracks()),this._isPlaying=!1,this._isPaused=!1,e&&!t&&this.invokePauseChangedMethodsOnTracks(),this._internalUpdateRoutine&&this.stopCoroutine(this._internalUpdateRoutine),this._internalUpdateRoutine=null}evaluate(){if(!this.isValid())return;let e=this._time;switch(this.extrapolationMode){case 0:this._speed>0?e=Math.min(e,this._duration):this._speed<0&&(e=Math.max(e,0)),this._time=e;break;case 1:e%=this._duration,this._time=e;break;case 2:if(e>this._duration){this.stop();return}break}this.internalEvaluate(e)}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)}*internalUpdate(){for(;this._isPlaying&&this.activeAndEnabled;)!this._isPaused&&this._isPlaying&&(this._time+=this.context.time.deltaTime*this.speed,this.evaluate()),yield}internalEvaluate(e){for(const t of this.playableAsset.tracks)if(!t.muted)switch(t.type){case PI.Activation:for(let g=0;g<t.outputs.length;g++){const I=t.outputs[g];if(typeof I=="object"){let o=!1;for(const C of t.clips)C.start<=e&&e<=C.end&&(o=!0);const s=I;s.visible!==void 0&&(s.visible=o)}}break}for(const t of this._animationTracks)t.evaluate(e);for(const t of this._audioTracks)t.evaluate(e);for(const t of this._signalTracks)t.evaluate(e);for(const t of this._controlTracks)t.evaluate(e);for(const t of this._customTracks)t.evaluate(e)}resolveBindings(){if(this._clonedPlayableAsset||(this._clonedPlayableAsset=!0,this.playableAsset=_y(this.playableAsset)),!this.playableAsset||!this.playableAsset.tracks)return;const e=this.findRoot(this.gameObject);for(const t of this.playableAsset.tracks){for(let g=t.outputs.length-1;g>=0;g--){let I=t.outputs[g];if(typeof I=="string"){this._guidsMap&&this._guidsMap[I]&&(I=this._guidsMap[I]);const o=eA.findByGuid(I,e);o===null||typeof o!="object"?(t.outputs.splice(g,1),console.warn("Failed to resolve binding",I,t.name,t.type)):(yc&&console.log("Resolved binding",I,"to",o),t.outputs[g]=o)}else if(I===null){if(t.outputs.splice(g,1),Yy.createTrackFunctions[t.type])continue;t.type!==PI.Audio&&t.type!==PI.Control&&t.type!==PI.Marker&&t.type!==PI.Signal&&console.warn("Missing binding",I,t.name,t.type,this.name,this.playableAsset.name)}}if(t.type===PI.Control)for(let g=0;g<t.clips.length;g++){const I=t.clips[g];let o=I.asset.sourceObject;if(typeof o=="string"){this._guidsMap&&this._guidsMap[o]&&(o=this._guidsMap[o]);const s=eA.findByGuid(o,e);s===null||typeof s!="object"?console.warn("Failed to resolve sourceObject binding",o,t.name,I):(yc&&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){for(const t of e.clips)t.end>this._duration&&(this._duration=t.end);for(const t of e.markers)t.time>this._duration&&(this._duration=t.time+.001)}}}setupAndCreateTrackHandlers(){var t,g;if(this._animationTracks.length=0,this._audioTracks.length=0,this._signalTracks.length=0,!this.playableAsset)return;const e=eA.findObjectOfType(ZE,this.context);for(const I of this.playableAsset.tracks){const o=I.type,s=Yy.createTrackFunctions[o];if(s!=null){const C=s(this,I);if(typeof C.evaluate=="function"){C.director=this,C.track=I,this._customTracks.push(C);continue}}if(I.type===PI.Animation){if(I.clips.length<=0){yc&&console.warn("Animation track has no clips",I);continue}for(let C=I.outputs.length-1;C>=0;C--){let n=I.outputs[C];if(n instanceof bA){const r=eA.getOrAddComponent(n,QI);r&&(n=r)}const a=(t=n==null?void 0:n.gameObject)==null?void 0:t.animations;if(a){const r=new wS;r.trackOffset=I.trackOffset,r.director=this,r.track=I;for(let Q=0;Q<I.clips.length;Q++){const E=I.clips[Q],h=E.asset;if(!h){console.error("MISSING anim model?","clip#"+Q,E,I,this.playableAsset,this.name);continue}const l=h.clip;let d=l;if((typeof d=="string"||typeof d=="number")&&(d=a.find(p=>p.name===l)),!d){console.warn("Could not find animationClip for model",E,I.name,this.name,(g=this.playableAsset)==null?void 0:g.name);continue}r.mixer||(r.mixer=new Rw(n.gameObject)),r.clips.push(d),r.mixer.uncacheAction(d),r.createHooks(E.asset,d);const c=r.mixer.clipAction(d);r.actions.push(c),r.models.push(E)}this._animationTracks.push(r)}}}else if(I.type===PI.Audio){if(I.clips.length<=0)continue;const C=new fB;if(C.director=this,C.track=I,this._audioTracks.push(C),!e)continue;C.listener=e.listener;for(let n=0;n<I.clips.length;n++){const a=I.clips[n];C.addModel(a)}}else if(I.type===PI.Marker){const C=new ld;C.director=this,C.track=I;for(const n of I.markers)switch(n.type){case kF.Signal:C.models.push(n),C.didTrigger.push(!1);break}if(C!==null&&C.models.length>0){const n=eA.getComponent(this.gameObject,Gh);n&&(C.receivers.push(n),this._signalTracks.push(C))}}else if(I.type===PI.Signal){const C=new ld;C.director=this,C.track=I;for(const n of I.markers)C.models.push(n),C.didTrigger.push(!1);for(const n of I.outputs)C.receivers.push(n);this._signalTracks.push(C)}else if(I.type===PI.Control){const C=new SS;C.director=this,C.track=I;for(const n of I.clips)C.models.push(n);C.resolveSourceObjects(this.context),this._controlTracks.push(C)}}}setAudioTracksAllowPlaying(e){for(const t of this._audioTracks)t.onAllowAudioChanged(e)}};let wn=Yy;B(wn,"createTrackFunctions",{});const pB=oA("debugtimeline");class ru{constructor(){B(this,"director");B(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,g=!0){if(e<0||e>=t.length)return 0;const I=t[e];if(g||A>=I.start&&A<=I.end){let o=1,s=!1;if(I.easeInDuration>0){const C=Math.min((A-I.start)/I.easeInDuration,1);o*=C}if(I.easeOutDuration>0&&!s){const C=Math.min((I.end-A)/I.easeOutDuration,1);o*=C}return o}return 0}}class bgA{constructor(A){B(this,"clip");B(this,"rootPositionOffset");B(this,"rootQuaternionOffset");B(this,"rootStartPosition");B(this,"rootEndPosition");B(this,"rootStartQuaternion");B(this,"rootEndQuaternion");const e=A.getClip();this.clip=e;const t=A.getRoot(),g=t.name+".position",I=t.name+".quaternion";pB&&console.log(e.name,e.tracks,g);for(const o of e.tracks)if(!(o.times.length<=0)){if(o.name.endsWith(g))this.rootStartPosition=new m().fromArray(o.values,0),this.rootEndPosition=new m().fromArray(o.values,o.values.length-3),this.rootPositionOffset=this.rootEndPosition.clone().sub(this.rootStartPosition),pB&&console.log(this.rootPositionOffset);else if(o.name.endsWith(I)&&(this.rootStartQuaternion=new LA().fromArray(o.values,0),this.rootEndQuaternion=new LA().fromArray(o.values,o.values.length-4),this.rootQuaternionOffset=this.rootEndQuaternion.clone().multiply(this.rootStartQuaternion),pB)){const s=new ug().setFromQuaternion(this.rootQuaternionOffset);console.log("ROT",s)}}}get hasOffsets(){return this.rootPositionOffset!==void 0||this.rootQuaternionOffset!==void 0}}class wS extends ru{constructor(){super(...arguments);B(this,"models",[]);B(this,"trackOffset");B(this,"target");B(this,"mixer");B(this,"clips",[]);B(this,"actions",[]);B(this,"_actionOffsets",[]);B(this,"_didBind",!1);B(this,"_animator",null);B(this,"_animatorWasEnabled",!1);B(this,"_useclipOffsets",!0);B(this,"_totalOffsetPosition",new m);B(this,"_totalOffsetRotation",new LA);B(this,"_totalOffsetPosition2",new m);B(this,"_totalOffsetRotation2",new LA);B(this,"_summedPos",new m);B(this,"_tempPos",new m);B(this,"_summedRot",new LA);B(this,"_tempRot",new LA);B(this,"_clipRotQuat",new LA)}onPauseChanged(){this._animator&&this._animatorWasEnabled!==void 0&&(this._animator.enabled=this.director.isPlaying===!1?this._animatorWasEnabled:!1)}createHooks(e,t){var a,r;if(((a=t.tracks)==null?void 0:a.length)<=0){console.warn("No tracks in AnimationClip",t);return}const g=t.tracks[0].name.split("."),I=g[g.length-2],o=I+".position",s=I+".quaternion";let C=!1,n=!1;for(const Q of t.tracks)Q.name.endsWith(o)?(C=!0,this.createPositionInterpolant(t,e,Q)):Q.name.endsWith(s)&&(n=!0,this.createRotationInterpolant(t,e,Q));if(!C||!n){const Q=(r=this.mixer)==null?void 0:r.getRoot(),E=t.tracks[0],h=E.name.lastIndexOf("."),l=E.name.substring(0,h),d=l.substring(l.lastIndexOf(".")+1),c=Q.getObjectByName(d);if(c)if(C){if(!n){const p=t.tracks[0].name.substring(0,h)+".quaternion";pB&&console.warn("Create quaternion track",d,c);const u=c.quaternion,f=new hC(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=l+".position";pB&&console.warn("Create position track",d,c);const u=c.position,f=new Va(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,pB&&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 bgA(e);this._actionOffsets.push(t)}this.target&&(this._animator=eA.getComponent(this.target,QI)??null,this._animator?(this._animatorWasEnabled=this._animator.enabled,this._animator.enabled=!1):this._animatorWasEnabled=!1);for(const e of this.models){const t=e.asset,g=t.position,I=t.rotation;g&&g.x!==void 0&&(g.isVector3||(t.position=new m(g.x,g.y,g.z)),I.isQuaternion||(t.rotation=new LA(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 m(e.x,e.y,e.z)));const t=this.trackOffset.rotation;t&&(t.isQuaternion||(this.trackOffset.rotation=new LA(t.x,t.y,t.z,t.w)))}}evaluate(e){if(this.track.muted||!this.mixer)return;this.bind(),this._animator&&this.director.isPlaying&&this.director.weight>0&&(this._animator.enabled=!1),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,g=0,I=!1,o=!1;for(let s=0;s<this.clips.length;s++){const C=this.models[s],n=this.actions[s],a=C.asset;n.weight=0;const r=e>=C.start&&e<=C.end,Q=C.preExtrapolationMode,E=C.postExtrapolationMode,h=s<this.clips.length-1?this.models[s+1]:null;let l=r,d=!1;if(!l&&!I&&C.end<e&&E!==Ps.None?(!h||h.start>e)&&(l=!0,I=!0):s==0&&!l&&!o&&C.start>e&&Q!==Ps.None&&(!h||h.start<e)&&(l=!0,d=!0,o=!0),l){let c=1;c*=this.evaluateWeight(e,s,this.models,l),c*=this.director.weight;let p=r;if(d)switch(Q){case Ps.Hold:break;case Ps.Loop:e+=C.start,p=!0;break;default:e+=C.start,p=!0;break}let u=this.getClipTime(e,C),f=0;const D=a.duration;if(d&&Q===Ps.Hold&&(u=0),p){if(a.loop)for(f+=Math.floor(u/(D+1e-6));u>D;)u-=D}else if(!r&&I)switch(E){case Ps.Hold:u=this.getClipTime(C.end,C);break;case Ps.Loop:u%=D;break;case Ps.PingPong:const R=Math.floor(u/D)%2!==0;u%=D,R&&(u=D-u);break}C.reversed===!0?n.time=n.getClip().duration-u:n.time=u,n.timeScale=0;const w=c;if(n.weight=w,n.clampWhenFinished=!0,n.isRunning()||n.play(),this._useclipOffsets){const M=t==0?this._totalOffsetPosition:this._totalOffsetPosition2,R=t==0?this._totalOffsetRotation:this._totalOffsetRotation2;t<1&&(g=1-c),t+=1;const k=this._summedPos.set(0,0,0),G=this._tempPos.set(0,0,0),J=this._summedRot.identity(),P=this._tempRot.identity(),L=a.rotation;L&&(this._clipRotQuat.identity(),this._clipRotQuat.slerp(L,c));const T=this._actionOffsets[s];if(T.hasOffsets)for(let _=0;_<f;_++)T.rootPositionOffset?G.copy(T.rootPositionOffset):G.set(0,0,0),G.applyQuaternion(J),this._clipRotQuat&&G.applyQuaternion(this._clipRotQuat),T.rootQuaternionOffset&&(P.copy(T.rootQuaternionOffset),J.multiply(P)),k.add(G);this._clipRotQuat&&R.multiply(this._clipRotQuat),R.multiply(J),a.position&&k.add(a.position),M.add(k)}}}this._useclipOffsets&&(this._totalOffsetPosition.lerp(this._totalOffsetPosition2,g),this._totalOffsetRotation.slerp(this._totalOffsetRotation2,g)),this.mixer.update(e)}createRotationInterpolant(e,t,g){var C;const I=g.createInterpolant.bind(g),o=new LA;this.ensureTrackOffsets();const s=(C=this.trackOffset)==null?void 0:C.rotation;g.createInterpolant=()=>{const n=I(),a=n.evaluate.bind(n);return n.evaluate=r=>{const Q=a(r);return o.set(Q[0],Q[1],Q[2],Q[3]),o.premultiply(this._totalOffsetRotation),s&&o.premultiply(s),Q[0]=o.x,Q[1]=o.y,Q[2]=o.z,Q[3]=o.w,Q},n}}createPositionInterpolant(e,t,g){var a,r;const I=g.createInterpolant.bind(g),o=new m;this.ensureTrackOffsets();const s=(a=this.trackOffset)==null?void 0:a.rotation,C=(r=this.trackOffset)==null?void 0:r.position;let n;g.createInterpolant=()=>{const Q=I(),E=Q.evaluate.bind(Q);return Q.evaluate=h=>{var d,c;const l=E(h);return o.set(l[0],l[1],l[2]),t.removeStartOffset&&(n===void 0?(n=null,n=(c=(d=this._actionOffsets.find(p=>p.clip===e))==null?void 0:d.rootStartPosition)==null?void 0:c.clone()):n!=null&&n.isVector3&&o.sub(n)),o.applyQuaternion(this._totalOffsetRotation),o.add(this._totalOffsetPosition),s&&o.applyQuaternion(s),C&&(o.x-=C.x,o.y+=C.y,o.z+=C.z),l[0]=o.x,l[1]=o.y,l[2]=o.z,l},Q}}}const xgA=oA("mutetimeline"),dE=class extends ru{constructor(){super(...arguments);B(this,"models",[]);B(this,"listener");B(this,"audio",[]);B(this,"audioContextTimeOffset",[]);B(this,"lastTime",0);B(this,"_audioLoader",null)}getAudioFilePath(e){const t=this.director.sourceId;return tr(t,e)}onAllowAudioChanged(e){for(let t=0;t<this.models.length;t++){const g=this.models[t];this.audio[t].setVolume(e?g.asset.volume:0)}}addModel(e){const t=new Mw(this.listener);this.audio.push(t),this.models.push(e)}onDisable(){for(const e of this.audio)e.isPlaying&&e.stop()}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()}}evaluate(e){if(xgA||this.track.muted||this.director.speed<0)return;const t=this.director.context.application.muted,g=t?.1:0;for(let I=0;I<this.models.length;I++){const o=this.models[I],s=this.audio[I];if((!s||!s.buffer)&&this.isInTimeRange(o,e-1,e+1)&&this.handleAudioLoading(o,s),Ni.userInteractionRegistered!==!1&&!(s===null||!s.buffer))if(s.playbackRate=this.director.context.time.timeScale,s.loop=o.asset.loop,e>=o.start&&e<=o.end&&e<this.director.duration){if(this.director.isPlaying==!1){if(s.isPlaying&&s.stop(),this.lastTime===e)continue}else if(!s.isPlaying)s.offset=o.clipIn+(e-o.start)*o.timeScale,s.play(g);else{const n=o.clipIn+(e-o.start)*o.timeScale,a=s.context.currentTime-s._startedAt+s.offset;Math.abs(n-a)>.3&&(s.offset=n,s.stop(),s.play(g))}let C=o.asset.volume;if(t&&(C=0),o.easeInDuration>0){const n=Math.min((e-o.start)/o.easeInDuration,1);C*=n}if(o.easeOutDuration>0){const n=Math.min((o.end-e)/o.easeOutDuration,1);C*=n}s.setVolume(C*this.director.weight)}else s.isPlaying&&s.stop()}this.lastTime=e}loadAudio(e,t=0,g=0){let I=null;const o=e-g,s=e+t;for(const C of this.models)if(this.isInTimeRange(C,o,s)){const n=this.audio[this.models.indexOf(C)],a=this.handleAudioLoading(C,n);a!==null&&(I===null&&(I=[]),I.push(a))}return I!==null?Promise.all(I):null}isInTimeRange(e,t,g){return t<=e.start&&g>=e.end||t>=e.start&&t<=e.end||g>=e.start&&g<=e.end}static dispose(){dE._audioBuffers.clear()}handleAudioLoading(e,t){this._audioLoader||(this._audioLoader=new jD);const g=this.getAudioFilePath(e.asset.clip);if(dE._audioBuffers.get(g)){const o=dE._audioBuffers.get(g);return o.then(s=>{s&&t.setBuffer(s)}),o}pB&&console.warn("LOAD audio track",g,this.director.sourceId);const I=new Promise((o,s)=>{this._audioLoader.load(g,C=>{t.setBuffer(C),o(C)},void 0,C=>{console.error("Error loading audio",C),o(null)})});return dE._audioBuffers.set(g,I),I}};let fB=dE;B(fB,"_audioBuffers",new Map);class ld extends ru{constructor(){super(...arguments);B(this,"models",[]);B(this,"didTrigger",[]);B(this,"receivers",[])}evaluate(e){var g;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],C=o.time-e;let n=!1;if(o.retroActive)n=C<=1e-6;else{const a=Math.abs(C);a>=1e-5&&a<t&&(n=!0)}if(n){if(!s)if(this.didTrigger[I]=!0,((g=this.receivers)==null?void 0:g.length)<=0)Gh.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 ru{constructor(){super(...arguments);B(this,"models",[]);B(this,"timelines",[]);B(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=eA.getComponent(I.sourceObject,wn);this.timelines.push(o),o&&I.updateDirector&&(o.playOnAwake=!1)}}}evaluate(e){var t;this._previousActiveModel=null;for(let g=0;g<this.models.length;g++){const I=this.models[g],o=I.asset;if(e>=I.start&&e<=I.end){this._previousActiveModel=I;const s=this.getClipTime(e,I);if(o.controlActivation){const C=o.sourceObject;C.visible=!0}if(o.updateDirector){const C=this.timelines[g];C&&(C.isPlaying&&C.pause(),C.time=s,C.evaluate())}}else{const s=(t=this._previousActiveModel)==null?void 0:t.asset;if(o.controlActivation){const C=o.sourceObject;(s==null?void 0:s.sourceObject)!==C&&(C.visible=!1)}}}}}var LgA=Object.defineProperty,vgA=Object.getOwnPropertyDescriptor,uO=(i,A,e,t)=>{for(var g=t>1?void 0:t?vgA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&LgA(A,e,g),g};class Re{constructor(A){B(this,"_active",!0);B(this,"_value");B(this,"_valueRaw");B(this,"_defaultValue");B(this,"valueProcessor");B(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;!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)}testIfValueChanged(A){return this._valueRaw!==A}}uO([y()],Re.prototype,"overrideState",1);uO([y()],Re.prototype,"value",1);var TgA=Object.defineProperty,YgA=Object.getOwnPropertyDescriptor,HgA=(i,A,e,t)=>{for(var g=t>1?void 0:t?YgA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&TgA(A,e,g),g};const _gA=oA("debugpost");class _g extends nr{constructor(e=void 0){super();B(this,"active",!0);B(this,"_result");B(this,"_didCreateVolumeParameters",!1);if(e){this.ensureVolumeParameters();for(const t of Object.keys(e)){const g=e[t],I=this[t];I instanceof Re&&(I.value=g)}}}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(){_gA&&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 g=this[t];g instanceof Re&&g.__init()}}onAfterDeserialize(e,t){if(typeof e=="object"){const g=this.$serializedTypes;if(g){for(const I of Object.keys(g))if(g[I]===Re){const s=e[I];if(s!==void 0){const C=this[I];C.value=s}}}}}onEditorModification(e){const t=e.propertyName;if(this[t]instanceof Re){const g=e.value;return this[t].value=g,!0}}ensureVolumeParameters(){if(this._didCreateVolumeParameters)return;this._didCreateVolumeParameters=!0;const e=this.$serializedTypes;if(e)for(const t of Object.keys(e))e[t]===Re&&(this[t]||(this[t]=new Re))}}HgA([y()],_g.prototype,"active",2);var OgA=Object.defineProperty,PgA=Object.getOwnPropertyDescriptor,WgA=(i,A,e,t)=>{for(var g=t>1?void 0:t?PgA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&OgA(A,e,g),g};const VgA=oA("debugpost"),bM={};function As(i,A){bM[i]=A}function zgA(i){return i.__type in bM?bM[i.__type]:(VgA&&i.__type&&console.warn("Unknown postprocessing type",i.__type,i),_g)}class Bu{constructor(){B(this,"components",[])}init(){var A;(A=this.components)==null||A.forEach(e=>e.init())}}WgA([dh([i=>zgA(i),_g])],Bu.prototype,"components",2);var jgA=Object.defineProperty,ZgA=Object.getOwnPropertyDescriptor,XgA=(i,A,e,t)=>{for(var g=t>1?void 0:t?ZgA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&jgA(A,e,g),g};class Qu extends _g{constructor(){super(...arguments);B(this,"preset")}get typeName(){return"Antialiasing"}onCreateEffect(){const e=new n9({preset:$Q.HIGH,edgeDetectionMode:DU.DEPTH});return this.preset.onValueChanged=t=>{e.applyPreset(t)},e}}XgA([y(Re)],Qu.prototype,"preset",2);As("Antialiasing",Qu);class kS{constructor(){B(this,"files",[])}get extensionName(){return"Audio"}onExportObject(A,e,t){const g=eA.getComponents(A,Ni);if(g.length)for(const I of g){if(!I.clip||!I.playOnAwake)continue;const o=I.clip.split("/").pop();this.files.includes(I.clip)||this.files.push(I.clip),e.addEventListener("serialize",(s,C)=>{s.appendLine(),s.beginBlock(`def SpatialAudio "${e.name}"`),s.appendLine(`uniform asset filePath = @audio/${o}@`),s.appendLine(`uniform token auralMode = "${I.spatialBlend>0?"spatial":"nonSpatial"}"`),s.appendLine(`uniform token playbackMode = "${I.loop?"loopFromStage":"onceFromStart"}"`),s.appendLine(`uniform float gain = ${I.volume}`),s.closeBlock()})}}async onAfterSerialize(A){for(const e of this.files){const t=e.split("/").pop(),o=await(await(await fetch(e)).blob()).arrayBuffer(),s=new Uint8Array(o);A.files["audio/"+t]=s}}}var $gA=Object.defineProperty,AIA=Object.getOwnPropertyDescriptor,pO=(i,A,e,t)=>{for(var g=t>1?void 0:t?AIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&$gA(A,e,g),g};const eIA=oA("debugmouth");class Eu extends mA{constructor(){super(...arguments);B(this,"idle",[]);B(this,"talking",[]);B(this,"marker",null);B(this,"voip",null);B(this,"lastMouthChangeTime",0);B(this,"mouthChangeLength",0)}awake(){setTimeout(()=>{this.voip=eA.findObjectOfType(xn,this.context),this.marker||(this.marker=eA.getComponentInParent(this.gameObject,Ig))},3e3)}update(){var g;if(!this.voip||this.context.time.frameCount%10!==0)return;let e=((g=this.marker)==null?void 0:g.connectionId)??null;if(!e){eIA&&(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(g=>g.visible=!1):this.talking.map(g=>g.visible=!1);for(let g=0;g<e.length;g++){const I=e[g];I&&(I.visible=g===t)}}}}pO([y(bA)],Eu.prototype,"idle",2);pO([y(bA)],Eu.prototype,"talking",2);class mF extends mA{constructor(){super(...arguments);B(this,"voip",null);B(this,"marker",null);B(this,"_startPosition",null)}awake(){this.voip=eA.findObjectOfType(xn,this.context),this.marker=eA.getComponentInParent(this.gameObject,Ig)}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());let g=t/100;this.gameObject.position.y=this._startPosition.y+g*.07}}var tIA=Object.defineProperty,iIA=Object.getOwnPropertyDescriptor,mS=(i,A,e,t)=>{for(var g=t>1?void 0:t?iIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&tIA(A,e,g),g};class TB extends mA{constructor(){super(...arguments);B(this,"eyes",[]);B(this,"lastBlinkTime",0);B(this,"blinkLength",0);B(this,"eyesOpen",!0);B(this,"state",null)}awake(){this.state=eA.getComponentInParent(this.gameObject,dg)}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([y(bA)],TB.prototype,"eyes",2);mS([y()],TB.prototype,"lastBlinkTime",2);mS([y()],TB.prototype,"blinkLength",2);mS([y()],TB.prototype,"eyesOpen",2);var gIA=Object.defineProperty,IIA=Object.getOwnPropertyDescriptor,GF=(i,A,e,t)=>{for(var g=t>1?void 0:t?IIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&gIA(A,e,g),g},AG;const fO=(AG=class extends mA{constructor(){super(...arguments);B(this,"head",null);B(this,"eyes",null);B(this,"target",null);B(this,"brain",null);B(this,"vec",new m);B(this,"currentTargetPoint",new m)}awake(){this.brain||(this.brain=eA.getComponentInParent(this.gameObject,sd)),this.brain||(console.log("No look at brain found, adding it now"),this.brain=eA.addNewComponent(this.gameObject,sd)),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=ye(A);this.currentTargetPoint.lerp(t,this.context.time.deltaTime/.1);const g=ye(this.head),I=this.vec.copy(this.currentTargetPoint).sub(g).normalize();if(I.length()<.1)return;const o=fO.forward;if(o.set(0,0,1),o.applyQuaternion(Oi(this.head)),o.dot(I)>.45)for(let C=0;C<e.length;C++)e[C].lookAt(this.currentTargetPoint)}}}},B(AG,"forward",new m(0,0,1)),AG);let Mh=fO;GF([y(bA)],Mh.prototype,"head",2);GF([y(bA)],Mh.prototype,"eyes",2);GF([y(bA)],Mh.prototype,"target",2);var oIA=Object.defineProperty,sIA=Object.getOwnPropertyDescriptor,MF=(i,A,e,t)=>{for(var g=t>1?void 0:t?sIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&oIA(A,e,g),g};class Rh extends mA{constructor(){super(...arguments);B(this,"length",1);B(this,"depthTest",!0);B(this,"isGizmo",!0);B(this,"_axes",null)}onEnable(){if(this.isGizmo&&!_d)return;this._axes||(this._axes=new ah(this.length)),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)}}MF([y()],Rh.prototype,"length",2);MF([y()],Rh.prototype,"depthTest",2);MF([y()],Rh.prototype,"isGizmo",2);class RF extends mA{constructor(){super(...arguments);B(this,"from");B(this,"to");B(this,"hint");B(this,"desiredDistance",1)}onEnable(){}update(){if(!this.from||!this.to||!this.hint)return;let e=ye(this.to).clone(),t=ye(this.from).clone(),g=e.distanceTo(t),I=e.clone();I.sub(t);let o=t.clone();o.add(e),o.multiplyScalar(.5);let s=ye(this.hint).clone();s.sub(o);let C=new m;C.crossVectors(s,I),C.crossVectors(I,C),C.normalize();let n=g*.5,a=Math.max(this.desiredDistance,n),r=Math.sqrt(a*a-n*n),Q=C.clone();Q.multiplyScalar(r),Q.add(o),di(this.gameObject,Q);let E=o.clone();E.sub(C),this.gameObject.lookAt(E)}}class GS{constructor(){B(this,"behaviours",[]);B(this,"behaviourComponents",[]);B(this,"behaviourComponentsCopy",[])}get extensionName(){return"Behaviour"}addBehavior(A){this.behaviours.push(A)}onBeforeBuildDocument(A){const e=[];return A.root.traverse(t=>{eA.foreachComponent(t,g=>{var o;const I=g;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)}),Promise.all(e)}onExportObject(A,e,t){var g;for(const I of this.behaviourComponents)(g=I.createBehaviours)==null||g.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 g of this.behaviours)g.writeTo(this,A.document,e);e.closeBlock()}}async onAfterSerialize(A){console.log("onAfterSerialize",this.behaviourComponentsCopy);for(const e of this.behaviourComponentsCopy)console.log("behaviour",e),typeof e.afterSerialize=="function"&&(console.log("beh has afterSerialize",e),e.afterSerialize.constructor.name==="AsyncFunction"?await e.afterSerialize(this,A):e.afterSerialize(this,A))}}var CIA=Object.defineProperty,nIA=Object.getOwnPropertyDescriptor,UF=(i,A,e,t)=>{for(var g=t>1?void 0:t?nIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&CIA(A,e,g),g};class YB extends _g{constructor(){super(...arguments);B(this,"threshold");B(this,"intensity");B(this,"scatter");B(this,"selectiveBloom",!0)}get typeName(){return"Bloom"}init(){this.threshold.defaultValue=1,this.intensity.defaultValue=0,this.scatter.defaultValue=.2,this.selectiveBloom?(this.threshold.valueProcessor=e=>e,this.intensity.valueProcessor=e=>e,this.scatter.valueProcessor=e=>1*Math.PI*(1-e)):(this.threshold.valueProcessor=e=>e,this.intensity.valueProcessor=e=>e,this.scatter.valueProcessor=e=>100*(1-e))}onCreateEffect(){let e;if(this.selectiveBloom){const t=e=new JH(this.context.scene,this.context.mainCamera,{blendFunction:qe.ADD,mipmapBlur:!0,luminanceThreshold:this.threshold.value,luminanceSmoothing:this.scatter.value,intensity:this.intensity.value});t.inverted=!0}else e=new kU;return this.intensity.onValueChanged=t=>{e.intensity=t},this.threshold.onValueChanged=t=>{e.luminanceMaterial.threshold=t},this.scatter.onValueChanged=t=>{e.luminancePass.enabled=!0,e.luminanceMaterial.smoothing=t},e}}UF([y(Re)],YB.prototype,"threshold",2);UF([y(Re)],YB.prototype,"intensity",2);UF([y(Re)],YB.prototype,"scatter",2);As("Bloom",YB);var aIA=Object.defineProperty,rIA=Object.getOwnPropertyDescriptor,Js=(i,A,e,t)=>{for(var g=t>1?void 0:t?rIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&aIA(A,e,g),g};class yC extends mA{constructor(){super(...arguments);B(this,"attachedRigidbody",null);B(this,"isTrigger",!1);B(this,"sharedMaterial")}get isCollider(){return!0}awake(){super.awake(),this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Xt))}start(){this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Xt))}onEnable(){this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Xt))}onDisable(){var e;(e=this.context.physics.engine)==null||e.removeBody(this)}}Js([y(Xt)],yC.prototype,"attachedRigidbody",2);Js([y()],yC.prototype,"isTrigger",2);Js([y()],yC.prototype,"sharedMaterial",2);class hu extends yC{constructor(){super(...arguments);B(this,"radius",.5);B(this,"center",new m(0,0,0))}onEnable(){var e;super.onEnable(),(e=this.context.physics.engine)==null||e.addSphereCollider(this,this.center,this.radius)}}Js([y()],hu.prototype,"radius",2);Js([y(m)],hu.prototype,"center",2);class cu extends yC{constructor(){super(...arguments);B(this,"size",new m(1,1,1));B(this,"center",new m(0,0,0))}onEnable(){var e;super.onEnable(),(e=this.context.physics.engine)==null||e.addBoxCollider(this,this.center,this.size)}}Js([y(m)],cu.prototype,"size",2);Js([y(m)],cu.prototype,"center",2);class lu extends yC{constructor(){super(...arguments);B(this,"sharedMesh");B(this,"convex",!1)}onEnable(){var e,t,g,I,o;if(super.onEnable(),(e=this.sharedMesh)!=null&&e.isMesh||this.gameObject instanceof yA&&(this.sharedMesh=this.gameObject),(t=this.sharedMesh)!=null&&t.isMesh)(g=this.context.physics.engine)==null||g.addMeshCollider(this,this.sharedMesh,this.convex,lg(this.gameObject));else{const s=this.sharedMesh;if(s!=null&&s.isGroup){console.warn(`MeshCollider mesh is a group "${(I=this.sharedMesh)==null?void 0:I.name}", adding all children as colliders. This is currently not fully supported (colliders can not be removed from world again)`,this);for(const C in s.children){const n=s.children[C];n.isMesh&&((o=this.context.physics.engine)==null||o.addMeshCollider(this,n,this.convex,lg(this.gameObject)))}}}}}Js([y()],lu.prototype,"convex",2);class Xa extends yC{constructor(){super(...arguments);B(this,"center",new m(0,0,0));B(this,"radius",.5);B(this,"height",2)}onEnable(){var e;super.onEnable(),(e=this.context.physics.engine)==null||e.addCapsuleCollider(this,this.center,this.height,this.radius)}}Js([y(m)],Xa.prototype,"center",2);Js([y()],Xa.prototype,"radius",2);Js([y()],Xa.prototype,"height",2);function FF(i){const A=i[AC];return A||(i.parent?FF(i.parent):null)}function Dy(i,A){if(!i)return;const e=i.material;if((e==null?void 0:e.isMaterial)===!0){const t=i.parent;t&&t.isText,e.side=A.doubleSided??!0?Jt:Tg,e.shadowSide=A.doubleSided?Jt:Tg,i.castShadow=A.castShadows?A.castShadows:!1,i.receiveShadow=A.receiveShadows?A.receiveShadows:!1}for(const t of i.children)Dy(t,A)}function tE(i,A,e){i[A]===void 0&&console.warn("Field",A,"is undefined on",i);const t=Proxy.revocable(i[A],{set(o,s,C,n){const a=o[s],r=Reflect.set(o,s,C,n);return e(C,a),r}}),g=t.revoke,I=i[A];return t.revoke=()=>{i[A]=I,g()},i[A]=t.proxy,t}const Wb=Symbol("Scheduled action");function BIA(i,A,e=so.OnBeforeRender){let t=i[Wb];t||(t=i[Wb]={});const g=A.name;t[e]||(t[e]={});const I=t[e];if(I[g])return;function*s(){A==null||A.call(i),I[g]=null}const C=i.startCoroutine(s(),e);I[g]=C}var QIA=Object.defineProperty,EIA=Object.getOwnPropertyDescriptor,HB=(i,A,e,t)=>{for(var g=t>1?void 0:t?EIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&QIA(A,e,g),g};const Im=oA("debugui"),om=oA("debuguilayout");class NF{constructor(){B(this,"width");B(this,"height")}}class KF{constructor(){B(this,"x");B(this,"y");B(this,"width");B(this,"height")}}const Cs=new m,wc=new qA,Af=new LA,DO=class extends Gs{constructor(){super(...arguments);B(this,"_anchoredPosition");B(this,"sizeDelta",new X(100,100));B(this,"pivot",new X(.5,.5));B(this,"anchorMin",new X(0,0));B(this,"anchorMax",new X(1,1));B(this,"offsetMin",new X(0,0));B(this,"offsetMax",new X(0,0));B(this,"lastMatrix");B(this,"rectBlock");B(this,"_transformNeedsUpdate",!1);B(this,"_initialPosition");B(this,"_parentRectTransform");B(this,"_lastUpdateFrame",-1);B(this,"_lastAnchoring");B(this,"_createdBlocks",[]);B(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 X),this._anchoredPosition}set anchoredPosition(A){this._anchoredPosition=A}get width(){if(this.anchorMin.x!==this.anchorMax.x&&this._parentRectTransform){const A=this._parentRectTransform.width,e=this.anchorMax.x-this.anchorMin.x;let t=A*e;return t+=this.sizeDelta.x,t}return this.sizeDelta.x}get height(){if(this.anchorMin.y!==this.anchorMax.y&&this._parentRectTransform){const A=this._parentRectTransform.height,e=this.anchorMax.y-this.anchorMin.y;let t=A*e;return t+=this.sizeDelta.y,t}return this.sizeDelta.y}awake(){super.awake(),this._anchoredPosition||(this._anchoredPosition=new X),this.lastMatrix=new qA,this.rectBlock=new bA,this.rectBlock.name=this.name,this._initialPosition=this.gameObject.position.clone(),this._initialPosition.z=0,tE(this,"_anchoredPosition",()=>{this.markDirty()}),tE(this,"sizeDelta",()=>{this.markDirty()}),tE(this,"pivot",()=>{this.markDirty()}),tE(this,"anchorMin",()=>{this.markDirty()}),tE(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(om?`${A.name} changed`:void 0)}get isDirty(){return this._transformNeedsUpdate||(this._transformNeedsUpdate=!this.lastMatrix.equals(this.gameObject.matrix)),this._transformNeedsUpdate}markDirty(){this._transformNeedsUpdate||(om&&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 g;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=eA.getComponentInParent(this.gameObject.parent,DO):this._parentRectTransform=void 0,this._transformNeedsUpdate=!1,om&&console.warn("RectTransform → ApplyTransform",this.name+" because "+A),this.isRoot()?this.Root.screenspace||(e.rotation.y=Math.PI):(e.matrix.identity(),e.matrixAutoUpdate=!1,Cs.set(0,0,0),this.applyPivot(Cs),e.matrix.setPosition(Cs.x,Cs.y,0),(this.gameObject.quaternion.x||this.gameObject.quaternion.y||this.gameObject.quaternion.z)&&(Af.copy(this.gameObject.quaternion),Af.x*=-1,Af.z*=-1,wc.makeRotationFromQuaternion(Af),e.matrix.premultiply(wc)),Cs.set(0,0,0),this.applyAnchoring(Cs),(g=this.Canvas)!=null&&g.screenspace?Cs.z+=.1:Cs.z+=.01,wc.identity(),wc.setPosition(Cs.x,Cs.y,Cs.z),e.matrix.premultiply(wc),e.matrix.scale(this.gameObject.scale)),this.lastMatrix.copy(this.gameObject.matrix);const t=!0;for(const I of pU(this.gameObject,Gs,t,1)){if(I===this||!I.activeAndEnabled)continue;const o=I;o.onParentRectTransformChanged&&o.onParentRectTransformChanged(this)}}applyAnchoring(A){this._lastAnchoring||(this._lastAnchoring=new X);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 g=0;const I=1-this.anchorMax.y-this.anchorMin.y;g-=t.height*.5*I,A.y+=g;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},Im&&console.log(this.name,A);const e=new DF(A);return this._createdBlocks.push(e),e}createNewText(A){Im&&console.log(A),A={...this.getBasicOptions(),...A},Im&&console.log(this.name,A);const e=new EO(A);return this._createdTextBlocks.push(e),e}};let yg=DO;HB([y(X)],yg.prototype,"anchoredPosition",1);HB([y(X)],yg.prototype,"sizeDelta",2);HB([y(X)],yg.prototype,"pivot",2);HB([y(X)],yg.prototype,"anchorMin",2);HB([y(X)],yg.prototype,"anchorMax",2);HB([y(X)],yg.prototype,"offsetMin",2);HB([y(X)],yg.prototype,"offsetMax",2);class hIA extends QO{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 g in e[t])A._simpleState__statesProperties[g]||(A._simpleState__statesProperties[g]=[]),A._simpleState__statesProperties[g].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 g in e)this._simpleState__statesProperties[g]||(this._simpleState__statesProperties[g]=[],t.push(g)),this._simpleState__statesProperties[g].push(A);for(const g of this._components)t.indexOf(g.id)>-1&&(this._simpleState__normalStyles[g.id]=g.inline?g.inline:g._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 cIA=Object.defineProperty,lIA=Object.getOwnPropertyDescriptor,yO=(i,A,e,t)=>{for(var g=t>1?void 0:t?lIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&cIA(A,e,g),g};class Uh extends mA{constructor(){super(...arguments);B(this,"effectColor");B(this,"effectDistance")}}yO([y(kt)],Uh.prototype,"effectColor",2);yO([y(X)],Uh.prototype,"effectDistance",2);var dIA=Object.defineProperty,uIA=Object.getOwnPropertyDescriptor,wO=(i,A,e,t)=>{for(var g=t>1?void 0:t?uIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&dIA(A,e,g),g};const ef={backgroundColor:new DA(1,1,1),backgroundOpacity:1,borderColor:new DA(1,1,1),borderOpacity:1};var eG;const dD=(eG=class extends Gs{constructor(){super(...arguments);B(this,"_alphaFactor",1);B(this,"raycastTarget",!0);B(this,"uiObject",null);B(this,"_color",null);B(this,"_rect",null);B(this,"_stateManager",null);B(this,"_currentlyCreatingPanel",!1)}get isGraphic(){return!0}get color(){return this._color||(this._color=new kt(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 kt(1,1,1,1)),this._color.copy(A))}setAlphaFactor(A){this._alphaFactor=A,this.onColorChanged()}get alphaFactor(){return this._alphaFactor}onColorChanged(){this.uiObject&&(ef.backgroundColor=this._color,ef.backgroundOpacity=this._color.alpha*this._alphaFactor,this.applyEffects(ef,this._alphaFactor),this.uiObject.set(ef),this.markDirty())}get m_Color(){return this._color}get rectTransform(){return this._rect||(this._rect=eA.getComponent(this.gameObject,yg)),this._rect}onParentRectTransformChanged(){var A;(A=this.uiObject)==null||A.set({width:this.rectTransform.width,height:this.rectTransform.height}),this.markDirty()}__internalNewInstanceCreated(){super.__internalNewInstanceCreated(),this._rect=null,this.uiObject=null,this._color&&(this._color=this._color.clone())}setState(A){this.makePanel(),this.uiObject&&(this.uiObject.setState(A),this==null||this.markDirty())}setupState(A){this.makePanel(),this.uiObject&&(this._stateManager||(this._stateManager=new hIA(this.uiObject)),this.uiObject.setupState(A.state,A.attributes))}setOptions(A){this.makePanel(),this.uiObject&&this.uiObject.set(A)}awake(){super.awake(),this.makePanel(),tE(this,"_color",()=>BIA(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;let A=.015;const 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()}onBeforeCreate(A){}onCreate(A){this.uiObject=this.rectTransform.createNewBlock(A),this.uiObject.name=this.name}onAfterCreated(){}applyEffects(A,e=1){var g;const t=(g=this.gameObject)==null?void 0:g.getComponent(Uh);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(A.colorSpace===Ie)if(dD.textureCache.has(A))A=dD.textureCache.get(A);else{const e=A.clone();e.colorSpace=sg,dD.textureCache.set(A,e),A=e}this.setOptions({backgroundImage:A,borderRadius:0,backgroundOpacity:this.color.alpha,backgroundSize:"stretch"})}else this.setOptions({backgroundImage:null,borderRadius:0,backgroundOpacity:this.color.alpha});this.markDirty()}onAfterAddedToScene(){super.onAfterAddedToScene(),this.shadowComponent&&(this.shadowComponent.offset=this.shadowComponent.position.z)}},B(eG,"textureCache",new Map),eG);let _B=dD;wO([y(kt)],_B.prototype,"color",1);wO([y()],_B.prototype,"raycastTarget",2);class du extends _B{constructor(){super(...arguments);B(this,"_flippedObject",!1)}onAfterCreated(){this.uiObject&&!this._flippedObject&&(this._flippedObject=!0,this.uiObject.scale.y*=-1)}}var pIA=Object.defineProperty,fIA=Object.getOwnPropertyDescriptor,MS=(i,A,e,t)=>{for(var g=t>1?void 0:t?fIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&pIA(A,e,g),g};let JF=class{constructor(){B(this,"texture",null);B(this,"rect")}};MS([y(He)],JF.prototype,"texture",2);let Fh=class extends du{constructor(){super(...arguments);B(this,"_sprite");B(this,"pixelsPerUnitMultiplier",1)}set image(e){this.sprite||(this.sprite=new JF),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 e,t,g,I,o,s,C,n;switch((t=(e=this.sprite)==null?void 0:e.texture)==null?void 0:t.name){case"InputFieldBackground":case"UISprite":case"Background":case"Knob":return!0}return((o=(I=(g=this.sprite)==null?void 0:g.texture)==null?void 0:I.image)==null?void 0:o.width)===32&&((n=(C=(s=this.sprite)==null?void 0:s.texture)==null?void 0:C.image)==null?void 0:n.height)===32}onBeforeCreate(e){var t,g;super.onBeforeCreate(e),this.isBuiltinSprite()&&(e.borderRadius=5/this.pixelsPerUnitMultiplier,((g=(t=this.sprite)==null?void 0:t.texture)==null?void 0:g.name)==="Knob"&&(e.borderRadius=999))}onAfterCreated(){var e;this.__didAwake&&(super.onAfterCreated(),!this.isBuiltinSprite()&&this.setTexture((e=this.sprite)==null?void 0:e.texture))}};MS([y(JF)],Fh.prototype,"sprite",1);MS([y()],Fh.prototype,"pixelsPerUnitMultiplier",2);class RS extends du{constructor(){super(...arguments);B(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))}}MS([y(He)],RS.prototype,"mainTexture",1);var DIA=Object.defineProperty,yIA=Object.getOwnPropertyDescriptor,ro=(i,A,e,t)=>{for(var g=t>1?void 0:t?yIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&DIA(A,e,g),g};const bQ=oA("debugbutton");class OB{constructor(){B(this,"colorMultiplier");B(this,"disabledColor");B(this,"fadeDuration");B(this,"highlightedColor");B(this,"normalColor");B(this,"pressedColor");B(this,"selectedColor")}}ro([y()],OB.prototype,"colorMultiplier",2);ro([y(kt)],OB.prototype,"disabledColor",2);ro([y()],OB.prototype,"fadeDuration",2);ro([y(kt)],OB.prototype,"highlightedColor",2);ro([y(kt)],OB.prototype,"normalColor",2);ro([y(kt)],OB.prototype,"pressedColor",2);ro([y(kt)],OB.prototype,"selectedColor",2);class Yn extends mA{constructor(){super(...arguments);B(this,"onClick");B(this,"_isHovered",!1);B(this,"colors");B(this,"transition");B(this,"animationTriggers");B(this,"animator");B(this,"_interactable",!0);B(this,"_requestedAnimatorTrigger");B(this,"_isInit",!1);B(this,"_image")}onPointerEnter(e){var t,g;bQ&&console.log("Button Enter",(t=this.animationTriggers)==null?void 0:t.highlightedTrigger,this.animator),this._isHovered=!0,this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.highlightedTrigger):this.transition===1&&this.colors&&((g=this._image)==null||g.setState("hovered")),this.context.input.setCursorPointer())}onPointerExit(){var e,t;bQ&&console.log("Button Exit",(e=this.animationTriggers)==null?void 0:e.highlightedTrigger,this.animator),this._isHovered=!1,this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.normalTrigger):this.transition===1&&this.colors&&((t=this._image)==null||t.setState("normal")),this.context.input.setCursorNormal())}onPointerDown(e){var t,g;bQ&&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&&((g=this._image)==null||g.setState("pressed")))}onPointerUp(e){var t,g;bQ&&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&&((g=this._image)==null||g.setState(this._isHovered?"hovered":"normal")))}onPointerClick(e){var t;this.interactable&&e.pointerId===0&&(bQ&&(console.warn("Button Click",this.onClick),Mi("CLICKED button "+this.name+" at "+this.context.time.frameCount)),(t=this.onClick)==null||t.invoke())}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(),bQ&&console.log(this),this._isInit=!1,this.init()}start(){var e;(e=this._image)==null||e.setInteractable(this.interactable)}onEnable(){super.onEnable()}*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=eA.getComponent(this.gameObject,Fh),this._image&&(this.stateSetup(this._image),this.interactable?this._image.setState("normal"):this._image.setState("disabled")))}stateSetup(e){var E,h,l,d,c;e.setInteractable(this.interactable);const t=this.getFinalColor(e.color,(E=this.colors)==null?void 0:E.normalColor),g={state:"normal",attributes:{backgroundColor:t,backgroundOpacity:t.alpha}};e.setupState(g);const I=this.getFinalColor(e.color,(h=this.colors)==null?void 0:h.highlightedColor),o={state:"hovered",attributes:{backgroundColor:I,backgroundOpacity:I.alpha}};e.setupState(o);const s=this.getFinalColor(e.color,(l=this.colors)==null?void 0:l.pressedColor),C={state:"pressed",attributes:{backgroundColor:s,backgroundOpacity:s.alpha}};e.setupState(C);const n=this.getFinalColor(e.color,(d=this.colors)==null?void 0:d.selectedColor),a={state:"selected",attributes:{backgroundColor:n,backgroundOpacity:n.alpha}};e.setupState(a);const r=this.getFinalColor(e.color,(c=this.colors)==null?void 0:c.disabledColor),Q={state:"disabled",attributes:{backgroundColor:r,backgroundOpacity:r.alpha}};e.setupState(Q)}getFinalColor(e,t){return t?e.clone().multiply(t):e.clone()}}ro([y(FI)],Yn.prototype,"onClick",2);ro([y()],Yn.prototype,"colors",2);ro([y()],Yn.prototype,"transition",2);ro([y()],Yn.prototype,"animationTriggers",2);ro([y(QI)],Yn.prototype,"animator",2);ro([y()],Yn.prototype,"interactable",1);var wIA=Object.defineProperty,SIA=Object.getOwnPropertyDescriptor,qi=(i,A,e,t)=>{for(var g=t>1?void 0:t?SIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&wIA(A,e,g),g};const Vb=oA("debuguilayout");class Er{constructor(){B(this,"left",0);B(this,"right",0);B(this,"top",0);B(this,"bottom",0)}get vertical(){return this.top+this.bottom}get horizontal(){return this.left+this.right}}qi([y()],Er.prototype,"left",2);qi([y()],Er.prototype,"right",2);qi([y()],Er.prototype,"top",2);qi([y()],Er.prototype,"bottom",2);class Bo extends mA{constructor(){super(...arguments);B(this,"_rectTransform",null);B(this,"_needsUpdate",!1);B(this,"childAlignment",0);B(this,"reverseArrangement",!1);B(this,"spacing",0);B(this,"padding");B(this,"minWidth",0);B(this,"minHeight",0);B(this,"flexibleHeight",0);B(this,"flexibleWidth",0);B(this,"preferredHeight",0);B(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&&(Vb&&console.warn("Layout Update",this.context.time.frame,this.name),this._needsUpdate=!1,this.onCalculateLayout(this._rectTransform))}start(){this._needsUpdate=!0}onEnable(){Vb&&console.log(this.name,this),this._rectTransform=this.gameObject.getComponent(yg);const e=this.gameObject.getComponentInParent(wg);e&&e.registerLayoutGroup(this),this._needsUpdate=!0}onDisable(){const e=this.gameObject.getComponentInParent(wg);e&&e.unregisterLayoutGroup(this)}set m_Spacing(e){e!==this.spacing&&(this._needsUpdate=!0,this.spacing=e)}get m_Spacing(){return this.spacing}}qi([y()],Bo.prototype,"childAlignment",2);qi([y()],Bo.prototype,"reverseArrangement",2);qi([y()],Bo.prototype,"spacing",2);qi([y(Er)],Bo.prototype,"padding",2);qi([y()],Bo.prototype,"minWidth",2);qi([y()],Bo.prototype,"minHeight",2);qi([y()],Bo.prototype,"flexibleHeight",2);qi([y()],Bo.prototype,"flexibleWidth",2);qi([y()],Bo.prototype,"preferredHeight",2);qi([y()],Bo.prototype,"preferredWidth",2);class hr extends Bo{constructor(){super(...arguments);B(this,"childControlHeight",!0);B(this,"childControlWidth",!0);B(this,"childForceExpandHeight",!1);B(this,"childForceExpandWidth",!1);B(this,"childScaleHeight",!1);B(this,"childScaleWidth",!1)}onCalculateLayout(e){var R;const t=this.primaryAxis,g=e.width;let I=g;const o=e.height;let s=o;I-=this.padding.horizontal,s-=this.padding.vertical,t==="x"?this.padding.horizontal:this.padding.vertical;const C=t==="x",n=C?"y":"x",a=C?this.childControlWidth:this.childControlHeight,r=C?this.childControlHeight:this.childControlWidth,Q=C?this.childForceExpandWidth:this.childForceExpandHeight,E=C?this.childForceExpandHeight:this.childForceExpandWidth,h=C?s:I,l=C?g:o,d=.5*(C?this.childAlignment%3:Math.floor(this.childAlignment/3));let c=0;C?c+=this.padding.left:c+=this.padding.top;let p=0,u=0;for(let k=0;k<this.gameObject.children.length;k++){const G=this.gameObject.children[k],J=eA.getComponent(G,yg);J!=null&&J.activeAndEnabled&&(u+=1,C?p+=J.width:p+=J.height)}let f=0;const D=this.spacing*(u-1);if(Q||a){let k=0;C?k=I-=D:k=s-=D,u>0&&(f=k/u)}let w=0;w+=this.padding.left,w-=this.padding.right,d!==0&&(c=l-p,c*=d,c-=D*d,C?(c-=this.padding.right*d,c+=this.padding.left*(1-d),c<this.padding.left&&(c=this.padding.left)):(c-=this.padding.bottom*d,c+=this.padding.top*(1-d),c<this.padding.top&&(c=this.padding.top)));let M=1;for(let k=0;k<this.gameObject.children.length;k++){const G=this.gameObject.children[k],J=eA.getComponent(G,yg);if(J!=null&&J.activeAndEnabled){(R=J.pivot)==null||R.set(.5,.5),J.anchorMin.set(0,1),J.anchorMax.set(0,1);const P=g*.5+w*.5;J.anchoredPosition.x!==P&&(J.anchoredPosition.x=P);const L=o*-.5;J.anchoredPosition.y!==L&&(J.anchoredPosition.y=L),E&&r&&J.sizeDelta[n]!==h&&(J.sizeDelta[n]=h),Q&&a&&J.sizeDelta[t]!==f&&(J.sizeDelta[t]=f);const T=C?J.width:J.height;let _=T*.5;if(c+=_,Q){let V=f*M-f*.5;V>c&&(c=V-f*.5+T+this.padding.left,c-=_)}let tA=c;t==="y"&&(tA=-tA),J.anchoredPosition[t]!==tA&&(J.anchoredPosition[t]=tA),c+=_,c+=this.spacing,M+=1}}}}qi([y()],hr.prototype,"childControlHeight",2);qi([y()],hr.prototype,"childControlWidth",2);qi([y()],hr.prototype,"childForceExpandHeight",2);qi([y()],hr.prototype,"childForceExpandWidth",2);qi([y()],hr.prototype,"childScaleHeight",2);qi([y()],hr.prototype,"childScaleWidth",2);class qF extends hr{get primaryAxis(){return"y"}}class bF extends hr{get primaryAxis(){return"x"}}class xF extends Bo{onCalculateLayout(){}}var kIA=Object.defineProperty,mIA=Object.getOwnPropertyDescriptor,wC=(i,A,e,t)=>{for(var g=t>1?void 0:t?mIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&kIA(A,e,g),g},SO=(i=>(i[i.ScreenSpaceOverlay=0]="ScreenSpaceOverlay",i[i.ScreenSpaceCamera=1]="ScreenSpaceCamera",i[i.WorldSpace=2]="WorldSpace",i[i.Undefined=-1]="Undefined",i))(SO||{});const sm=oA("debuguilayout"),kO=class extends nu{constructor(){super(...arguments);B(this,"_renderOnTop");B(this,"_depthWrite",!1);B(this,"_doubleSided",!0);B(this,"_castShadows",!1);B(this,"_receiveShadows",!1);B(this,"_renderMode",-1);B(this,"_rootCanvas");B(this,"_scaleFactor",1);B(this,"worldCamera");B(this,"planeDistance",-1);B(this,"_boundRenderSettingsChanged",this.onRenderSettingsChanged.bind(this));B(this,"previousParent",null);B(this,"_lastMatrixWorld",null);B(this,"_rectTransforms",[]);B(this,"_layoutGroups",new Map);B(this,"onBeforeRenderRoutine",()=>{var A,e,t,g;if(this.context.isInVR){(A=this.shadowComponent)==null||A.updateMatrixWorld(!0),(e=this.shadowComponent)==null||e.updateWorldMatrix(!0,!0),II.ensureUpdateMeshUI(em,this.context);return}this.previousParent=this.gameObject.parent,this.renderOnTop||this.screenspace?this.gameObject.removeFromParent():(this.onUpdateRenderMode(),this.handleLayoutUpdates(),(t=this.shadowComponent)==null||t.updateMatrixWorld(!0),(g=this.shadowComponent)==null||g.updateWorldMatrix(!0,!0),II.ensureUpdateMeshUI(em,this.context))});B(this,"onAfterRenderRoutine",()=>{var A,e;if(!this.context.isInVR){if((this.screenspace||this.renderOnTop)&&this.previousParent&&this.context.mainCamera){if(this.screenspace){const I=this.context.mainCamera;I==null||I.add(this.gameObject)}else this.previousParent.add(this.gameObject);const t=this.context.renderer.autoClear,g=this.context.renderer.autoClearColor;this.context.renderer.autoClear=!1,this.context.renderer.autoClearColor=!1,this.context.renderer.clearDepth(),this.onUpdateRenderMode(!0),this.handleLayoutUpdates(),(A=this.shadowComponent)==null||A.updateMatrixWorld(!0),II.ensureUpdateMeshUI(em,this.context),this.context.renderer.render(this.gameObject,this.context.mainCamera),this.context.renderer.autoClear=t,this.context.renderer.autoClearColor=g,this.previousParent.add(this.gameObject)}(e=this._lastMatrixWorld)==null||e.copy(this.gameObject.matrixWorld)}});B(this,"_updateRenderSettingsRoutine");B(this,"_activeRenderMode",-1);B(this,"_lastWidth",-1);B(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 kO||(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,sm&&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 qA,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)}handleLayoutUpdates(){this._lastMatrixWorld===null&&(this._lastMatrixWorld=new qA);const A=!this._lastMatrixWorld.equals(this.gameObject.matrixWorld);sm&&A&&console.log("Canvas Layout changed",this.context.time.frameCount,this.name);let e=!1;for(const t of this._rectTransforms){A&&t.markDirty();let g=this._layoutGroups.get(t.gameObject);t.isDirty&&!g&&(g=t.gameObject.getComponentInParent(Bo)),(t.isDirty||g!=null&&g.isDirty)&&(sm&&!e&&console.log("CANVAS UPDATE ### "+t.name+" ##################################### "+this.context.time.frame),g==null||g.updateLayout(),t.updateTransform())}}applyRenderSettings(){this.onRenderSettingsChanged()}onRenderSettingsChanged(){this._updateRenderSettingsRoutine||(this._updateRenderSettingsRoutine=this.startCoroutine(this._updateRenderSettingsDelayed(),so.OnBeforeRender))}*_updateRenderSettingsDelayed(){if(yield,this._updateRenderSettingsRoutine=void 0,this.shadowComponent){this.onUpdateRenderMode(),Dy(this.shadowComponent,this);for(const A of eA.getComponentsInChildren(this.gameObject,Gs))Dy(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,.15)),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 g=t+.01;this.gameObject.position.x=0,this.gameObject.position.y=0,this.gameObject.position.z=-g,this.gameObject.quaternion.identity();const I=this.gameObject.getComponent(yg);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,C=2*Math.tan(s/2)*Math.abs(g);this.gameObject.scale.x=C/this.context.domHeight,this.gameObject.scale.y=C/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 wg=kO;wC([y()],wg.prototype,"renderOnTop",1);wC([y()],wg.prototype,"depthWrite",1);wC([y()],wg.prototype,"doubleSided",1);wC([y()],wg.prototype,"castShadows",1);wC([y()],wg.prototype,"receiveShadows",1);wC([y()],wg.prototype,"renderMode",1);wC([y(wg)],wg.prototype,"rootCanvas",1);wC([y()],wg.prototype,"scaleFactor",1);wC([y(Ot)],wg.prototype,"worldCamera",2);wC([y()],wg.prototype,"planeDistance",2);var GIA=Object.defineProperty,MIA=Object.getOwnPropertyDescriptor,LF=(i,A,e,t)=>{for(var g=t>1?void 0:t?MIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&GIA(A,e,g),g};class $a extends mA{constructor(){super(...arguments);B(this,"_alpha",1);B(this,"interactable",!0);B(this,"blocksRaycasts",!0);B(this,"_isDirty",!1);B(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(),so.OnBeforeRender))}*applyChangesDelayed(){this._isDirty=!1,this.applyChangesNow()}applyChangesNow(){for(const e of eA.getComponentsInChildren(this.gameObject,Gs,this._buffer)){const t=e;t.setAlphaFactor&&t.setAlphaFactor(this._alpha)}}}LF([y()],$a.prototype,"alpha",1);LF([y()],$a.prototype,"interactable",2);LF([y()],$a.prototype,"blocksRaycasts",2);var RIA=Object.defineProperty,UIA=Object.getOwnPropertyDescriptor,xt=(i,A,e,t)=>{for(var g=t>1?void 0:t?UIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&RIA(A,e,g),g};class PB extends mA{constructor(){super(...arguments);B(this,"object");B(this,"target");B(this,"duration",1);B(this,"relativeMotion",!1);B(this,"coroutine",null);B(this,"targetPos",new m);B(this,"targetRot",new LA);B(this,"targetScale",new m)}*moveToTarget(){if(!this.target||!this.object)return;const e=ye(this.object).clone(),t=ye(this.target).clone(),g=Oi(this.object).clone(),I=Oi(this.target).clone(),o=lg(this.object).clone(),s=lg(this.target).clone(),C=e.distanceTo(t),n=g.angleTo(I),a=o.distanceTo(s);if(C<.01&&n<.01&&a<.01){di(this.object,t),qI(this.object,I),XG(this.object,s),this.coroutine=null;return}let r=0,Q=0;for(;r<1;)r+=this.context.time.deltaTime/this.duration,r>1&&(r=1),Q=r<.5?4*r*r*r:1-Math.pow(-2*r+2,3)/2,this.targetPos.lerpVectors(e,t,Q),this.targetRot.slerpQuaternions(g,I,Q),this.targetScale.lerpVectors(o,s,Q),di(this.object,this.targetPos),qI(this.object,this.targetRot),XG(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(),g=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 C=0,n=0;for(;C<1;)C+=this.context.time.deltaTime/this.duration,C>1&&(C=1),n=C<.5?4*C*C*C:1-Math.pow(-2*C+2,3)/2,this.object.position.lerpVectors(e,this.targetPos,n),this.object.quaternion.slerpQuaternions(t,this.targetRot,n),this.object.scale.lerpVectors(g,this.targetScale,n),yield;this.coroutine=null}onPointerClick(){this.coroutine&&this.stopCoroutine(this.coroutine),this.relativeMotion?this.coroutine=this.startCoroutine(this.moveRelative()):this.coroutine=this.startCoroutine(this.moveToTarget())}beforeCreateDocument(e){var t;if(this.target&&this.object&&this.gameObject){const g=new pg("Move to "+((t=this.target)==null?void 0:t.name),NI.tapTrigger(this.gameObject),Qt.transformAction(this.object,this.target,this.duration,this.relativeMotion?kM.Relative:kM.Absolute));e.addBehavior(g)}}}xt([y(bA)],PB.prototype,"object",2);xt([y(bA)],PB.prototype,"target",2);xt([y()],PB.prototype,"duration",2);xt([y()],PB.prototype,"relativeMotion",2);var tG;const Zr=(tG=class extends mA{constructor(){super(...arguments);B(this,"materialToSwitch");B(this,"variantMaterial");B(this,"fadeDuration",0);B(this,"_objectsWithThisMaterial",[]);B(this,"selfModel");B(this,"targetModels")}awake(){if(this.variantMaterial&&this.materialToSwitch){const A=eA.findObjectsOfType(_t);for(const e of A)e.sharedMaterial===this.materialToSwitch&&this._objectsWithThisMaterial.push(e)}}onPointerClick(){if(this.variantMaterial)for(const A of this._objectsWithThisMaterial)A.sharedMaterial=this.variantMaterial}async beforeCreateDocument(A,e){this.targetModels=[],Zr._materialTriggersPerId={},this.materialToSwitch&&await jI.assignTextureLOD(this.context,this.sourceId,this.materialToSwitch,0),this.variantMaterial&&await jI.assignTextureLOD(this.context,this.sourceId,this.variantMaterial,0)}createBehaviours(A,e,t){this._objectsWithThisMaterial.find(I=>I.gameObject.uuid===e.uuid)&&this.targetModels.push(e),this.gameObject.uuid===e.uuid&&(this.selfModel=e,this.materialToSwitch&&(Zr._materialTriggersPerId[this.materialToSwitch.uuid]||(Zr._materialTriggersPerId[this.materialToSwitch.uuid]=[]),Zr._materialTriggersPerId[this.materialToSwitch.uuid].push(this)))}afterCreateDocument(A,e){if(!this.materialToSwitch)return;const t=Zr._materialTriggersPerId[this.materialToSwitch.uuid];if(t){const g={};for(const o of t){const s=o.createVariants();s&&s.length>0&&(g[o.selfModel.uuid]=s)}const I=[];for(const o of t){for(const s in g)s!==o.selfModel.uuid&&I.push(g[s]);o.createAndAttachBehaviors(A,g[o.selfModel.uuid],I)}}delete Zr._materialTriggersPerId[this.materialToSwitch.uuid]}createAndAttachBehaviors(A,e,t){const g=[],I=[],o=Math.max(0,this.fadeDuration);for(const s of this.targetModels){const C=Qt.fadeAction(s,o,!1);I.push(C)}for(const s of t)I.push(Qt.fadeAction(s,o,!1));for(const s of e)g.push(Qt.fadeAction(s,o,!1)),I.push(Qt.fadeAction(s,o,!0));A.addBehavior(new pg("Select "+this.selfModel.name,NI.tapTrigger(this.selfModel),Qt.parallel(...I))),A.addBehavior(new pg("Start hidden "+this.selfModel.name,NI.sceneStartTrigger(),Qt.parallel(...g)))}createVariants(){if(!this.variantMaterial)return null;const A=[];for(const e of this.targetModels){const t=e.clone();t.name+=" variant_"+this.variantMaterial.name,t.name=t.name.replace(/\s/g,"_"),t.material=this.variantMaterial,t.geometry=e.geometry,t.matrix=e.matrix,(!e.parent||!e.parent.isEmpty())&&GI.createEmptyParent(e),e.parent&&e.parent.add(t),A.push(t)}return A}},B(tG,"_materialTriggersPerId",{}),tG);let Nh=Zr;xt([y(Ke)],Nh.prototype,"materialToSwitch",2);xt([y(Ke)],Nh.prototype,"variantMaterial",2);xt([y()],Nh.prototype,"fadeDuration",2);class Kh extends mA{constructor(){super(...arguments);B(this,"target");B(this,"toggleOnClick",!1);B(this,"targetState",!0);B(this,"hideSelf",!0);B(this,"selfModel");B(this,"otherModel");B(this,"toggleModel");B(this,"stateBeforeCreatingDocument",!1)}onPointerClick(){!this.toggleOnClick&&this.hideSelf&&(this.gameObject.visible=!1),this.target&&(this.target.visible=this.toggleOnClick?!this.target.visible:this.targetState)}createBehaviours(e,t,g){t.uuid===this.gameObject.uuid&&(this.selfModel=t)}beforeCreateDocument(){this.stateBeforeCreatingDocument=this.gameObject.visible,this.gameObject.visible=!0}afterCreateDocument(e,t){if(this.target){if(this.otherModel=t.document.findById(this.target.uuid),this.selfModel&&this.otherModel){let g=this.hideSelf;this.targetState,this.toggleOnClick&&(g=!0,this.target.visible,(!this.selfModel.parent||this.selfModel.parent.isEmpty())&&N_.createEmptyParent(this.selfModel),this.toggleModel=this.selfModel.clone(),this.toggleModel.name+="_toggle",this.selfModel.parent.add(this.toggleModel));const I=[];if(g&&I.push(Qt.fadeAction(this.selfModel,0,!1)),this.toggleModel&&I.push(Qt.fadeAction(this.toggleModel,0,!0)),I.push(Qt.fadeAction(this.otherModel,0,this.targetState)),e.addBehavior(new pg("Toggle_"+this.selfModel.name+"_hideSelf",NI.tapTrigger(this.selfModel),Qt.sequence(...I))),this.toggleOnClick&&this.toggleModel){const o=[];o.push(Qt.fadeAction(this.toggleModel,0,!1)),o.push(Qt.fadeAction(this.selfModel,0,!0)),o.push(Qt.fadeAction(this.otherModel,0,!this.targetState)),e.addBehavior(new pg("Toggle_"+this.selfModel.name+"_toggleSelf",NI.tapTrigger(this.toggleModel),Qt.sequence(...o))),e.addBehavior(new pg("HideOnStart_"+this.gameObject.name,NI.sceneStartTrigger(),Qt.fadeAction(this.toggleModel,0,!1)))}}this.gameObject.visible=this.stateBeforeCreatingDocument}}}xt([y(bA)],Kh.prototype,"target",2);xt([y()],Kh.prototype,"targetState",2);xt([y()],Kh.prototype,"hideSelf",2);class vF extends mA{start(){this.gameObject.visible=!1}createBehaviours(A,e,t){e.uuid===this.gameObject.uuid&&A.addBehavior(new pg("HideOnStart_"+this.gameObject.name,NI.sceneStartTrigger(),Qt.fadeAction(e,0,!1)))}beforeCreateDocument(){this.gameObject.visible=!0}afterCreateDocument(){this.gameObject.visible=!1}}class Jh extends mA{constructor(){super(...arguments);B(this,"target");B(this,"duration",.5);B(this,"motionType",YU.bounce)}beforeCreateDocument(){}createBehaviours(e,t,g){if(this.target&&t.uuid===this.gameObject.uuid){const I=new pg("emphasize "+this.name,NI.tapTrigger(this.gameObject),Qt.emphasize(this.target,this.duration,this.motionType,void 0,"basic"));e.addBehavior(I)}}afterCreateDocument(e,t){}}xt([y()],Jh.prototype,"target",2);xt([y()],Jh.prototype,"duration",2);xt([y()],Jh.prototype,"motionType",2);class qh extends mA{constructor(){super(...arguments);B(this,"target");B(this,"clip","");B(this,"toggleOnClick",!1)}onPointerClick(){if(!(!this.target&&!this.clip)){if(!this.target){const e=this.gameObject.addNewComponent(Ni);e&&(e.spatialBlend=1,e.volume=1,e.loop=!1,this.target=e)}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,g){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)return;const o=this.target?this.target.gameObject:this.gameObject,s=I.split("/").pop(),C=this.target?this.target.volume:1,n=this.target&&this.target.spatialBlend==0?mM.NonSpatial:mM.Spatial,a=new pg("playAudio "+this.name,NI.tapTrigger(this.gameObject),Qt.playAudioAction(o,"audio/"+s,L_.Play,C,n));e.addBehavior(a)}}async afterSerialize(e,t){if(!this.target&&!this.clip)return;const g=this.clip?this.clip:this.target?this.target.clip:void 0;if(!g)return;const I=g.split("/").pop(),C=await(await(await fetch(this.clip)).blob()).arrayBuffer(),n=new Uint8Array(C);t.files["audio/"+I]=n}}xt([y(Ni)],qh.prototype,"target",2);xt([y(URL)],qh.prototype,"clip",2);xt([y()],qh.prototype,"toggleOnClick",2);var iG;const iE=(iG=class extends mA{constructor(){super(...arguments);B(this,"target");B(this,"animator");B(this,"stateName");B(this,"stateNameAfterPlaying");B(this,"loopAfterPlaying",!1);B(this,"selfModel");B(this,"stateAnimationModel");B(this,"stateAnimation");B(this,"stateAfterPlayingAnimationModel");B(this,"stateAfterPlayingAnimation")}onPointerClick(){var A;this.target&&this.stateName&&((A=this.animator)==null||A.play(this.stateName,0,0,.1))}createBehaviours(A,e,t){e.uuid===this.gameObject.uuid&&(this.selfModel=e)}onAfterHierarchy(){iE.animationActions=[]}afterCreateDocument(A,e){if(!this.stateAnimation||!this.stateAnimationModel)return;e.document.traverse(g=>{var I,o;if(g.uuid===((I=this.target)==null?void 0:I.uuid)&&this.stateAnimation){const s=[];let C=iE.animationActions.find(a=>a.affectedObjects==g&&a.start==this.stateAnimation.start&&a.duration==this.stateAnimation.duration);if(C||(C=Qt.startAnimationAction(g,this.stateAnimation.start,this.stateAnimation.duration),iE.animationActions.push(C)),s.push(C),this.stateAfterPlayingAnimation&&this.stateAfterPlayingAnimationModel){let a=iE.animationActions.find(Q=>Q.affectedObjects==g&&Q.start==this.stateAfterPlayingAnimation.start&&Q.duration==this.stateAfterPlayingAnimation.duration);a||(a=Qt.startAnimationAction(g,this.stateAfterPlayingAnimation.start,this.stateAfterPlayingAnimation.duration),iE.animationActions.push(a));const r=Qt.sequence(a);this.loopAfterPlaying&&r.makeLooping(),s.push(r)}const n=new pg("tap "+this.name+" for "+this.stateName+" on "+((o=this.target)==null?void 0:o.name),NI.tapTrigger(this.selfModel),Qt.sequence(...s));A.addBehavior(n)}})}createAnimation(A,e,t){var g,I,o,s;if(this.target&&this.animator){const C=(I=(g=this.animator)==null?void 0:g.runtimeAnimatorController)==null?void 0:I.findState(this.stateName);this.stateAnimationModel=e,this.stateAnimation=A.registerAnimation(this.target,C==null?void 0:C.motion.clip);const n=(s=(o=this.animator)==null?void 0:o.runtimeAnimatorController)==null?void 0:s.findState(this.stateNameAfterPlaying);this.stateAfterPlayingAnimationModel=e,this.stateAfterPlayingAnimation=A.registerAnimation(this.target,n==null?void 0:n.motion.clip)}}},B(iG,"animationActions",[]),iG);let cr=iE;xt([y(bA)],cr.prototype,"target",2);xt([y(QI)],cr.prototype,"animator",2);xt([y()],cr.prototype,"stateName",2);xt([y()],cr.prototype,"stateNameAfterPlaying",2);xt([y()],cr.prototype,"loopAfterPlaying",2);class bh extends mA{constructor(){super(...arguments);B(this,"target")}getType(){}getDuration(){}}xt([y(bA)],bh.prototype,"target",2);class uu extends mA{constructor(){super(...arguments);B(this,"target")}}xt([y(bh)],uu.prototype,"target",2);class pu extends bh{constructor(){super(...arguments);B(this,"type",1);B(this,"duration",1)}getType(){switch(this.type){case 1:return"hide";case 0:return"show"}}getDuration(){return this.duration}}xt([y()],pu.prototype,"type",2);xt([y()],pu.prototype,"duration",2);class TF extends uu{}var FIA=Object.defineProperty,NIA=Object.getOwnPropertyDescriptor,Hn=(i,A,e,t)=>{for(var g=t>1?void 0:t?NIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&FIA(A,e,g),g};class WB extends mA{constructor(){super(...arguments);B(this,"center",new m(0,0,0));B(this,"radius",.5);B(this,"height",2);B(this,"_rigidbody",null);B(this,"_activeGroundCollisions",new Set)}get rigidbody(){return this._rigidbody?this._rigidbody:(this._rigidbody=this.gameObject.getComponent(Xt),this._rigidbody||(this._rigidbody=this.gameObject.addNewComponent(Xt)),this.rigidbody)}onEnable(){let e=this.rigidbody,t=this.gameObject.getComponent(Xa);t||(t=this.gameObject.addNewComponent(Xa)),t.center.copy(this.center),t.radius=this.radius,t.height=this.height,this.gameObject.rotation.x=0,this.gameObject.rotation.z=0,e.lockRotationX=!0,e.lockRotationY=!0,e.lockRotationZ=!0}move(e){this.gameObject.position.add(e)}onCollisionEnter(e){for(const t of e.contacts)if(t.normal.y>.1){this._activeGroundCollisions.add(e);break}}onCollisionExit(e){this._activeGroundCollisions.delete(e)}get isGrounded(){return this._activeGroundCollisions.size>0}}Hn([y(m)],WB.prototype,"center",2);Hn([y()],WB.prototype,"radius",2);Hn([y()],WB.prototype,"height",2);class _n extends mA{constructor(){super(...arguments);B(this,"controller");B(this,"movementSpeed",2);B(this,"rotationSpeed",2);B(this,"jumpForce",1);B(this,"doubleJumpForce",2);B(this,"animator");B(this,"lookForward",!0);B(this,"_currentSpeed",new m(0,0,0));B(this,"_currentAngularSpeed",new m(0,0,0));B(this,"_temp",new m(0,0,0));B(this,"_jumpCount",0);B(this,"_currentRotation");B(this,"_raycastOptions",new Fs)}awake(){this._currentRotation=new LA}update(){var n,a,r,Q,E,h,l,d,c,p,u;(n=this.controller)!=null&&n.isGrounded&&(this._jumpCount=0,this.doubleJumpForce>0&&((a=this.animator)==null||a.setBool("doubleJump",!1)));const e=this.context.input.isKeyPressed("w"),t=this.context.input.isKeyPressed("s"),g=this.context.input.isKeyPressed("a"),I=this.context.input.isKeyPressed("d"),o=this.context.input.isKeyDown(" "),s=(e?1:0)+(t?-1:0);this._currentSpeed.z+=s*this.movementSpeed*this.context.time.deltaTime,(r=this.animator)==null||r.setBool("running",s!=0),(E=this.animator)==null||E.setBool("jumping",((Q=this.controller)==null?void 0:Q.isGrounded)===!0&&o),this._temp.copy(this._currentSpeed),this._temp.applyQuaternion(this.gameObject.quaternion),this.controller?this.controller.move(this._temp):this.gameObject.position.add(this._temp);const C=(g?1:0)+(I?-1:0);if(this._currentAngularSpeed.y+=te.toRadians(C*this.rotationSpeed)*this.context.time.deltaTime,this.lookForward&&Math.abs(this._currentAngularSpeed.y)<.01){const f=this.context.mainCameraComponent.forward;f.y=0,f.normalize(),this._currentRotation.setFromUnitVectors(new m(0,0,1),f),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&&o&&this.jumpForce>0){let f=(h=this.controller)==null?void 0:h.isGrounded;if(this.doubleJumpForce>0&&!((l=this.controller)!=null&&l.isGrounded)&&this._jumpCount===1&&(f=!0,(d=this.animator)==null||d.setBool("doubleJump",!0)),f){this._jumpCount+=1;const D=this.controller.rigidbody,w=this._jumpCount===2?this.doubleJumpForce:this.jumpForce;D.applyImpulse(new m(0,1,0).multiplyScalar(w))}}if(this.controller){const f=(c=this.controller)==null?void 0:c.rigidbody.getVelocity().y;if(f<-1){this._raycastOptions.ray||(this._raycastOptions.ray=new pC),this._raycastOptions.ray.origin.copy(ye(this.gameObject)),this._raycastOptions.ray.direction.set(0,-1,0);const D=this.layer;this.gameObject.layers.disableAll(),this.gameObject.layers.set(2);const w=this.context.physics.raycast(this._raycastOptions);this.gameObject.layers.set(D),(w.length&&w[0].distance>2||f<-10)&&((p=this.animator)==null||p.setBool("falling",!0))}else(u=this.animator)==null||u.setBool("falling",!1)}}}Hn([y(WB)],_n.prototype,"controller",2);Hn([y()],_n.prototype,"movementSpeed",2);Hn([y()],_n.prototype,"rotationSpeed",2);Hn([y()],_n.prototype,"jumpForce",2);Hn([y()],_n.prototype,"doubleJumpForce",2);Hn([y(QI)],_n.prototype,"animator",2);var KIA=Object.defineProperty,JIA=Object.getOwnPropertyDescriptor,qIA=(i,A,e,t)=>{for(var g=t>1?void 0:t?JIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&KIA(A,e,g),g};class fu extends _g{constructor(){super(...arguments);B(this,"intensity")}get typeName(){return"ChromaticAberration"}init(){this.intensity.defaultValue=0}onCreateEffect(){const e=new UH;return e.offset=new X(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}}qIA([y(Re)],fu.prototype,"intensity",2);As("ChromaticAberration",fu);var bIA=Object.defineProperty,xIA=Object.getOwnPropertyDescriptor,US=(i,A,e,t)=>{for(var g=t>1?void 0:t?xIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&bIA(A,e,g),g};class lr extends _g{constructor(){super(...arguments);B(this,"postExposure");B(this,"contrast");B(this,"hueShift");B(this,"saturation")}get typeName(){return"ColorAdjustments"}init(){this.postExposure.valueProcessor=e=>(e=Math.pow(2,e),e),this.postExposure.defaultValue=0,this.contrast.valueProcessor=e=>{let t=1;return e>0?t=200:e<0&&(t=100),e/t},this.contrast.defaultValue=0,this.hueShift.valueProcessor=e=>Math.PI*e/180,this.hueShift.defaultValue=0,this.saturation.valueProcessor=e=>e<0?e/100:e/(100*Math.PI),this.saturation.defaultValue=0}unapply(){this.context.renderer.toneMappingExposure=1}onCreateEffect(){this.context.renderer.toneMapping===oI&&this.postExposure.overrideState&&(this.context.renderer.toneMapping=Yl);const e=new RH;this.postExposure.onValueChanged=g=>{this.context.renderer.toneMapping===oI&&(this.context.renderer.toneMapping=Yl),this.postExposure.overrideState&&(this.context.renderer.toneMappingExposure=g)},this.contrast.onValueChanged=g=>{e.contrast=g};const t=new NH;return this.hueShift.onValueChanged=g=>t.hue=g,this.saturation.onValueChanged=g=>t.saturation=g,[t,e]}}US([y(Re)],lr.prototype,"postExposure",2);US([y(Re)],lr.prototype,"contrast",2);US([y(Re)],lr.prototype,"hueShift",2);US([y(Re)],lr.prototype,"saturation",2);As("ColorAdjustments",lr);const LIA=(Math.sqrt(5)-1)/4,ag=(5-Math.sqrt(5))/20,tf=i=>Math.floor(i)|0,gf=new Float64Array([0,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,1,0,1,1,1,0,1,-1,1,0,-1,1,1,0,-1,-1,-1,0,1,1,-1,0,1,-1,-1,0,-1,1,-1,0,-1,-1,1,1,0,1,1,1,0,-1,1,-1,0,1,1,-1,0,-1,-1,1,0,1,-1,1,0,-1,-1,-1,0,1,-1,-1,0,-1,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,0]);function vIA(i=Math.random){const A=TIA(i),e=new Float64Array(A).map(o=>gf[o%32*4]),t=new Float64Array(A).map(o=>gf[o%32*4+1]),g=new Float64Array(A).map(o=>gf[o%32*4+2]),I=new Float64Array(A).map(o=>gf[o%32*4+3]);return function(s,C,n,a){let r,Q,E,h,l;const d=(s+C+n+a)*LIA,c=tf(s+d),p=tf(C+d),u=tf(n+d),f=tf(a+d),D=(c+p+u+f)*ag,w=c-D,M=p-D,R=u-D,k=f-D,G=s-w,J=C-M,P=n-R,L=a-k;let T=0,_=0,tA=0,V=0;G>J?T++:_++,G>P?T++:tA++,G>L?T++:V++,J>P?_++:tA++,J>L?_++:V++,P>L?tA++:V++;const $=T>=3?1:0,gA=_>=3?1:0,nA=tA>=3?1:0,j=V>=3?1:0,iA=T>=2?1:0,kA=_>=2?1:0,wA=tA>=2?1:0,GA=V>=2?1:0,MA=T>=1?1:0,WA=_>=1?1:0,_A=tA>=1?1:0,ae=V>=1?1:0,ke=G-$+ag,ie=J-gA+ag,H=P-nA+ag,vA=L-j+ag,uA=G-iA+2*ag,xA=J-kA+2*ag,SA=P-wA+2*ag,Ae=L-GA+2*ag,zA=G-MA+3*ag,ZA=J-WA+3*ag,Ee=P-_A+3*ag,me=L-ae+3*ag,Ze=G-1+4*ag,v=J-1+4*ag,q=P-1+4*ag,EA=L-1+4*ag,UA=c&255,FA=p&255,TA=u&255,O=f&255;let cA=.6-G*G-J*J-P*P-L*L;if(cA<0)r=0;else{const JA=UA+A[FA+A[TA+A[O]]];cA*=cA,r=cA*cA*(e[JA]*G+t[JA]*J+g[JA]*P+I[JA]*L)}let aA=.6-ke*ke-ie*ie-H*H-vA*vA;if(aA<0)Q=0;else{const JA=UA+$+A[FA+gA+A[TA+nA+A[O+j]]];aA*=aA,Q=aA*aA*(e[JA]*ke+t[JA]*ie+g[JA]*H+I[JA]*vA)}let PA=.6-uA*uA-xA*xA-SA*SA-Ae*Ae;if(PA<0)E=0;else{const JA=UA+iA+A[FA+kA+A[TA+wA+A[O+GA]]];PA*=PA,E=PA*PA*(e[JA]*uA+t[JA]*xA+g[JA]*SA+I[JA]*Ae)}let jA=.6-zA*zA-ZA*ZA-Ee*Ee-me*me;if(jA<0)h=0;else{const JA=UA+MA+A[FA+WA+A[TA+_A+A[O+ae]]];jA*=jA,h=jA*jA*(e[JA]*zA+t[JA]*ZA+g[JA]*Ee+I[JA]*me)}let HA=.6-Ze*Ze-v*v-q*q-EA*EA;if(HA<0)l=0;else{const JA=UA+1+A[FA+1+A[TA+1+A[O+1]]];HA*=HA,l=HA*HA*(e[JA]*Ze+t[JA]*v+g[JA]*q+I[JA]*EA)}return 27*(r+Q+E+h+l)}}function TIA(i){const e=new Uint8Array(512);for(let t=0;t<512/2;t++)e[t]=t;for(let t=0;t<512/2-1;t++){const g=t+~~(i()*(256-t)),I=e[t];e[t]=e[g],e[g]=I}for(let t=256;t<512;t++)e[t]=e[t-256];return e}var YIA=Object.defineProperty,HIA=Object.getOwnPropertyDescriptor,AA=(i,A,e,t)=>{for(var g=t>1?void 0:t?HIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&YIA(A,e,g),g};const If=oA("debugparticles");var nn=(i=>(i[i.Billboard=0]="Billboard",i[i.Stretch=1]="Stretch",i[i.HorizontalBillboard=2]="HorizontalBillboard",i[i.VerticalBillboard=3]="VerticalBillboard",i[i.Mesh=4]="Mesh",i))(nn||{});class dr{constructor(){B(this,"alphaKeys");B(this,"colorKeys")}get duration(){return 1}evaluate(A,e){let t,g=0,I=null,o=0;for(let s=0;s<this.alphaKeys.length;s++){const C=this.alphaKeys[s];(C.time<A||!t)&&(t=C,g=s)}for(let s=0;s<this.colorKeys.length;s++){const C=this.colorKeys[s];(C.time<A||!I)&&(I=C,o=s)}if(I)if(o+1<this.colorKeys.length){const C=this.colorKeys[o+1],n=te.remap(A,I.time,C.time,0,1);e.r=te.lerp(I.color.r,C.color.r,n),e.g=te.lerp(I.color.g,C.color.g,n),e.b=te.lerp(I.color.b,C.color.b,n)}else e.r=I.color.r,e.g=I.color.g,e.b=I.color.b;if(t)if(g+1<this.alphaKeys.length){const C=this.alphaKeys[g+1],n=te.remap(A,t.time,C.time,0,1);e.alpha=te.lerp(t.alpha,C.alpha,n)}else e.alpha=t.alpha;return e}}AA([y()],dr.prototype,"alphaKeys",2);AA([y()],dr.prototype,"colorKeys",2);var FS=(i=>(i[i.Local=0]="Local",i[i.World=1]="World",i[i.Custom=2]="Custom",i))(FS||{}),mO=(i=>(i[i.Sphere=0]="Sphere",i[i.SphereShell=1]="SphereShell",i[i.Hemisphere=2]="Hemisphere",i[i.HemisphereShell=3]="HemisphereShell",i[i.Cone=4]="Cone",i[i.Box=5]="Box",i[i.Mesh=6]="Mesh",i[i.ConeShell=7]="ConeShell",i[i.ConeVolume=8]="ConeVolume",i[i.ConeVolumeShell=9]="ConeVolumeShell",i[i.Circle=10]="Circle",i[i.CircleEdge=11]="CircleEdge",i[i.SingleSidedEdge=12]="SingleSidedEdge",i[i.MeshRenderer=13]="MeshRenderer",i[i.SkinnedMeshRenderer=14]="SkinnedMeshRenderer",i[i.BoxShell=15]="BoxShell",i[i.BoxEdge=16]="BoxEdge",i[i.Donut=17]="Donut",i[i.Rectangle=18]="Rectangle",i[i.Sprite=19]="Sprite",i[i.SpriteRenderer=20]="SpriteRenderer",i))(mO||{});class ne{constructor(){B(this,"mode");B(this,"constant");B(this,"constantMin");B(this,"constantMax");B(this,"curve");B(this,"curveMin");B(this,"curveMax");B(this,"curveMultiplier")}evaluate(A,e){const t=e===void 0?Math.random():e;switch(this.mode){case 0:return this.constant;case 1:return A=te.clamp01(A),this.curve.evaluate(A)*this.curveMultiplier;case 2:const g=A*this.curveMin.duration,I=A*this.curveMax.duration;return te.lerp(this.curveMin.evaluate(g),this.curveMax.evaluate(I),t%1)*this.curveMultiplier;case 3:return te.lerp(this.constantMin,this.constantMax,t%1);default:this.curveMax.evaluate(A)*this.curveMultiplier;break}return 0}getMax(){switch(this.mode){case 0:return this.constant;case 1:return this.getMaxFromCurve(this.curve)*this.curveMultiplier;case 2:return Math.max(this.getMaxFromCurve(this.curveMin),this.getMaxFromCurve(this.curveMax))*this.curveMultiplier;case 3:return Math.max(this.constantMin,this.constantMax);default:return 0}}getMaxFromCurve(A){if(!A)return 0;let e=Number.MIN_VALUE;for(let t=0;t<A.keys.length;t++){const g=A.keys[t];g.value>e&&(e=g.value)}return e}}AA([y()],ne.prototype,"mode",2);AA([y()],ne.prototype,"constant",2);AA([y()],ne.prototype,"constantMin",2);AA([y()],ne.prototype,"constantMax",2);AA([y(xB)],ne.prototype,"curve",2);AA([y(xB)],ne.prototype,"curveMin",2);AA([y(xB)],ne.prototype,"curveMax",2);AA([y()],ne.prototype,"curveMultiplier",2);var vf;const hs=(vf=class{constructor(){B(this,"mode");B(this,"color");B(this,"colorMin");B(this,"colorMax");B(this,"gradient");B(this,"gradientMin");B(this,"gradientMax")}evaluate(i,A){const e=A===void 0?Math.random():A;switch(this.mode){case 0:return this.color;case 1:return this.gradient.evaluate(i,hs._temp),hs._temp;case 2:return hs._temp.lerpColors(this.colorMin,this.colorMax,e);case 3:return this.gradientMin.evaluate(i,hs._temp),this.gradientMax.evaluate(i,hs._temp2),hs._temp.lerp(hs._temp2,e)}return hs._temp.set(16711935),hs._temp.alpha=1,hs._temp}},B(vf,"_temp",new kt(0,0,0,1)),B(vf,"_temp2",new kt(0,0,0,1)),vf);let bI=hs;AA([y(kt)],bI.prototype,"color",2);AA([y(kt)],bI.prototype,"colorMin",2);AA([y(kt)],bI.prototype,"colorMax",2);AA([y(dr)],bI.prototype,"gradient",2);AA([y(dr)],bI.prototype,"gradientMin",2);AA([y(dr)],bI.prototype,"gradientMax",2);class Gg{constructor(){B(this,"cullingMode");B(this,"duration");B(this,"emitterVelocityMode");B(this,"flipRotation");B(this,"gravityModifier");B(this,"gravityModifierMultiplier");B(this,"loop");B(this,"maxParticles");B(this,"playOnAwake");B(this,"prewarm");B(this,"ringBufferLoopRange");B(this,"ringBufferMode");B(this,"scalingMode");B(this,"simulationSpace");B(this,"simulationSpeed");B(this,"startColor");B(this,"startDelay");B(this,"startDelayMultiplier");B(this,"startLifetime");B(this,"startLifetimeMultiplier");B(this,"startRotation");B(this,"startRotationMultiplier");B(this,"startRotation3D");B(this,"startRotationX");B(this,"startRotationXMultiplier");B(this,"startRotationY");B(this,"startRotationYMultiplier");B(this,"startRotationZ");B(this,"startRotationZMultiplier");B(this,"startSize");B(this,"startSize3D");B(this,"startSizeMultiplier");B(this,"startSizeX");B(this,"startSizeXMultiplier");B(this,"startSizeY");B(this,"startSizeYMultiplier");B(this,"startSizeZ");B(this,"startSizeZMultiplier");B(this,"startSpeed");B(this,"startSpeedMultiplier");B(this,"stopAction");B(this,"useUnscaledTime")}}AA([y(ne)],Gg.prototype,"gravityModifier",2);AA([y(bI)],Gg.prototype,"startColor",2);AA([y(ne)],Gg.prototype,"startDelay",2);AA([y(ne)],Gg.prototype,"startLifetime",2);AA([y(ne)],Gg.prototype,"startRotation",2);AA([y(ne)],Gg.prototype,"startRotationX",2);AA([y(ne)],Gg.prototype,"startRotationY",2);AA([y(ne)],Gg.prototype,"startRotationZ",2);AA([y(ne)],Gg.prototype,"startSize",2);AA([y(ne)],Gg.prototype,"startSizeX",2);AA([y(ne)],Gg.prototype,"startSizeY",2);AA([y(ne)],Gg.prototype,"startSizeZ",2);AA([y(ne)],Gg.prototype,"startSpeed",2);class dd{constructor(){B(this,"cycleCount");B(this,"maxCount");B(this,"minCount");B(this,"probability");B(this,"repeatInterval");B(this,"time");B(this,"count");B(this,"_performed",0)}reset(){this._performed=0}run(A){if(A<=this.time)return 0;let e=0;if(this.cycleCount===0||this._performed<this.cycleCount){const t=this.time+this.repeatInterval*this._performed;if(A>=t&&(this._performed+=1,Math.random()<this.probability))switch(this.count.mode){case 0:e=this.count.constant;break;case 3:e=te.lerp(this.count.constantMin,this.count.constantMax,Math.random());break;case 1:e=this.count.curve.evaluate(Math.random());break;case 2:const g=Math.random();e=te.lerp(this.count.curveMin.evaluate(g),this.count.curveMax.evaluate(g),Math.random());break}}return e}}class SC{constructor(){B(this,"enabled");B(this,"bursts");B(this,"rateOverTime");B(this,"rateOverTimeMultiplier");B(this,"rateOverDistance");B(this,"rateOverDistanceMultiplier");B(this,"system")}get burstCount(){var A;return((A=this.bursts)==null?void 0:A.length)??0}reset(){var A;(A=this.bursts)==null||A.forEach(e=>e.reset())}getBurst(){let A=0;if(this.burstCount>0)for(let e=0;e<this.burstCount;e++){const t=this.bursts[e];this.system.main.loop&&t.time>=this.system.time&&t.reset(),A+=Math.round(t.run(this.system.time))}return A}}AA([y()],SC.prototype,"enabled",2);AA([y()],SC.prototype,"bursts",2);AA([y(ne)],SC.prototype,"rateOverTime",2);AA([y()],SC.prototype,"rateOverTimeMultiplier",2);AA([y(ne)],SC.prototype,"rateOverDistance",2);AA([y()],SC.prototype,"rateOverDistanceMultiplier",2);class Du{constructor(){B(this,"enabled");B(this,"color")}}AA([y(bI)],Du.prototype,"color",2);class ur{constructor(){B(this,"enabled");B(this,"separateAxes");B(this,"size");B(this,"sizeMultiplier");B(this,"x");B(this,"xMultiplier");B(this,"y");B(this,"yMultiplier");B(this,"z");B(this,"zMultiplier");B(this,"_time",0);B(this,"_temp",new m)}evaluate(A,e,t){if(e||(e=this._temp),!this.enabled)return e.x=e.y=e.z=1,e;if(this.separateAxes)e.x=this.x.evaluate(A,t)*this.xMultiplier,e.y=this.y.evaluate(A,t)*this.yMultiplier,e.z=this.z.evaluate(A,t)*this.zMultiplier;else{const g=this.size.evaluate(A,t)*this.sizeMultiplier;e.x=g}return e}}AA([y(ne)],ur.prototype,"size",2);AA([y(ne)],ur.prototype,"x",2);AA([y(ne)],ur.prototype,"y",2);AA([y(ne)],ur.prototype,"z",2);var Tf;const Xc=(Tf=class{constructor(){B(this,"shapeType",5);B(this,"enabled",!0);B(this,"alignToDirection",!1);B(this,"angle",0);B(this,"arc",360);B(this,"arcSpread");B(this,"arcSpeedMultiplier");B(this,"arcMode");B(this,"boxThickness");B(this,"position");B(this,"rotation");B(this,"_rotation",new ug);B(this,"scale");B(this,"radius");B(this,"radiusThickness");B(this,"sphericalDirectionAmount");B(this,"randomDirectionAmount");B(this,"randomPositionAmount");B(this,"system");B(this,"_space");B(this,"_worldSpaceMatrix",new qA);B(this,"_worldSpaceMatrixInverse",new qA);B(this,"_vector",new m(0,0,0));B(this,"_temp",new m(0,0,0));B(this,"_dir",new m);B(this,"_loopTime",0);B(this,"_loopDirection",1);If&&console.log(this)}get type(){return mO[this.shapeType]}initialize(i){this.getPosition(),i.position.copy(this._vector)}toJSON(){return this}clone(){return new Xc}update(i,A,e,t){this.system=i,this._space=e,e===1&&(this._worldSpaceMatrix.copy(t.matrixWorld),this._worldSpaceMatrix.elements[0]=1,this._worldSpaceMatrix.elements[5]=1,this._worldSpaceMatrix.elements[10]=1,this._worldSpaceMatrixInverse.copy(this._worldSpaceMatrix).invert())}applyRotation(i){const A=this.rotation.x!==0||this.rotation.y!==0||this.rotation.z!==0;return A&&(this._rotation.x=te.toRadians(this.rotation.x),this._rotation.y=te.toRadians(this.rotation.y),this._rotation.z=te.toRadians(this.rotation.z),this._rotation.order="ZYX",i.applyEuler(this._rotation)),A}get vector(){return this._vector}getPosition(){this._vector.set(0,0,0);const i=this._temp.copy(this.position),A=this._space===1;A&&i.applyQuaternion(this.system.worldQuaternion);let e=this.radius;if(A&&(e*=this.system.worldScale.x),this.enabled){switch(this.shapeType){case 5:If&&ln.DrawBox(this.position,this.scale,14540253,1),this._vector.x=Math.random()*this.scale.x-this.scale.x/2,this._vector.y=Math.random()*this.scale.y-this.scale.y/2,this._vector.z=Math.random()*this.scale.z-this.scale.z/2,this._vector.add(i);break;case 4:this.randomConePoint(this.position,this.angle,e,this.radiusThickness,this.arc,this.arcMode,this._vector);break;case 0:this.randomSpherePoint(this.position,e,this.radiusThickness,this.arc,this._vector);break;case 10:this.randomCirclePoint(this.position,e,this.radiusThickness,this.arc,this._vector);break;default:this._vector.set(0,0,0);break}this.randomizePosition(this._vector,this.randomPositionAmount)}this.applyRotation(this._vector),A&&(this._vector.applyQuaternion(this.system.worldQuaternion),this._vector.add(this.system.worldPos)),If&&ln.DrawSphere(this._vector,.03,16711680,.5,!0)}getDirection(i){var A;if(!this.enabled)return this._dir.set(0,0,1),this._dir;switch(this.shapeType){case 5:this._dir.set(0,0,1);break;case 4:this._dir.set(0,0,1);break;case 10:case 0:const e=i.x,t=i.y,g=i.z;this._dir.set(e,t,g),(A=this.system)!=null&&A.worldspace?this._dir.sub(this.system.worldPos):this._dir.sub(this.position);break;default:this._dir.set(0,0,1);break}return this._space===1&&this._dir.applyQuaternion(this.system.worldQuaternion),this.applyRotation(this._dir),this._dir.normalize(),this.spherizeDirection(this._dir,this.sphericalDirectionAmount),this.randomizeDirection(this._dir,this.randomDirectionAmount),If&&(ln.DrawSphere(i,.01,8925952,.5,!0),ln.DrawDirection(i,this._dir,8925952,.5,!0)),this._dir}randomizePosition(i,A){if(A<=0)return;const e=Xc._tempVec;e.set(Math.random()*2-1,Math.random()*2-1,Math.random()*2-1),e.x*=A*this.scale.x,e.y*=A*this.scale.y,e.z*=A*this.scale.z,i.add(e)}randomizeDirection(i,A){if(A===0)return;const e=Xc._randomQuat,t=Xc._tempVec;t.set(Math.random()-.5,Math.random()-.5,Math.random()-.5).normalize(),e.setFromAxisAngle(t,A*Math.random()*Math.PI),i.applyQuaternion(e)}spherizeDirection(i,A){if(A===0)return;const e=Math.random()*Math.PI*2,t=Math.acos(1-Math.random()*2),g=Math.sin(t)*Math.cos(e),I=Math.sin(t)*Math.sin(e),o=Math.cos(t),s=new m(g,I,o);i.lerp(s,A)}randomSpherePoint(i,A,e,t,g){const I=Math.random(),o=Math.random(),s=2*Math.PI*I*(t/360),C=Math.acos(2*o-1),n=te.lerp(1,1-Math.pow(1-Math.random(),Math.PI),e)*A,a=i.x+this.scale.x*(-n*Math.sin(C)*Math.cos(s)),r=i.y+this.scale.y*(n*Math.sin(C)*Math.sin(s)),Q=i.z+this.scale.z*(n*Math.cos(C));g.x=a,g.y=r,g.z=Q}randomCirclePoint(i,A,e,t,g){const I=Math.random(),o=2*Math.PI*I*(t/360),s=te.lerp(1,1-Math.pow(1-Math.random(),Math.PI),e)*A,C=i.x+this.scale.x*s*Math.cos(o),n=i.y+this.scale.y*s*Math.sin(o),a=i.z;g.x=C,g.y=n,g.z=a}randomConePoint(i,A,e,t,g,I,o){let s=0,C=0;switch(I){case 0:s=Math.random(),C=Math.random();break;case 2:this._loopTime>1&&(this._loopDirection=-1),this._loopTime<0&&(this._loopDirection=1);case 1:s=.5,C=Math.random(),this._loopTime+=this.system.deltaTime*this._loopDirection;break}let n=2*Math.PI*s*(g/360);switch(I){case 2:case 1:n+=Math.PI+.5,n+=this._loopTime*Math.PI*2,n%=te.toRadians(g);break}const a=Math.acos(2*C-1),r=te.lerp(1,1-Math.pow(1-Math.random(),Math.PI),t)*e,Q=i.x+-r*Math.sin(a)*Math.cos(n),E=i.y+r*Math.sin(a)*Math.sin(n),h=i.z;o.x=Q*this.scale.x,o.y=E*this.scale.y,o.z=h*this.scale.z}},B(Tf,"_randomQuat",new LA),B(Tf,"_tempVec",new m),Tf);let pi=Xc;AA([y()],pi.prototype,"shapeType",2);AA([y()],pi.prototype,"enabled",2);AA([y()],pi.prototype,"alignToDirection",2);AA([y()],pi.prototype,"angle",2);AA([y()],pi.prototype,"arc",2);AA([y()],pi.prototype,"arcSpread",2);AA([y()],pi.prototype,"arcSpeedMultiplier",2);AA([y()],pi.prototype,"arcMode",2);AA([y(m)],pi.prototype,"boxThickness",2);AA([y(m)],pi.prototype,"position",2);AA([y(m)],pi.prototype,"rotation",2);AA([y(m)],pi.prototype,"scale",2);AA([y()],pi.prototype,"radius",2);AA([y()],pi.prototype,"radiusThickness",2);AA([y()],pi.prototype,"sphericalDirectionAmount",2);AA([y()],pi.prototype,"randomDirectionAmount",2);AA([y()],pi.prototype,"randomPositionAmount",2);class ft{constructor(){B(this,"damping");B(this,"enabled");B(this,"frequency");B(this,"octaveCount");B(this,"octaveMultiplier");B(this,"octaveScale");B(this,"positionAmount");B(this,"quality");B(this,"remap");B(this,"remapEnabled");B(this,"remapMultiplier");B(this,"remapX");B(this,"remapXMultiplier");B(this,"remapY");B(this,"remapYMultiplier");B(this,"remapZ");B(this,"remapZMultiplier");B(this,"scrollSpeedMultiplier");B(this,"separateAxes");B(this,"strengthMultiplier");B(this,"strengthX");B(this,"strengthXMultiplier");B(this,"strengthY");B(this,"strengthYMultiplier");B(this,"strengthZ");B(this,"strengthZMultiplier");B(this,"_noise");B(this,"_time",0);B(this,"_temp",new m)}update(A){this._time+=A.time.deltaTime*this.scrollSpeedMultiplier}apply(A,e,t,g,I,o){if(!this.enabled)return;this._noise||(this._noise=vIA(()=>0));const s=this._temp.set(e.x,e.y,e.z).multiplyScalar(this.frequency),C=this._noise(s.x,s.y,s.z,this._time),n=this._noise(s.x,s.y,s.z,this._time+1e3*this.frequency),a=this._noise(s.x,s.y,s.z,this._time+2e3*this.frequency);this._temp.set(C,n,a).normalize();const r=I/o;let Q=this.positionAmount.evaluate(r);this.separateAxes?(this._temp.x*=Q*this.strengthXMultiplier,this._temp.y*=Q*this.strengthYMultiplier,this._temp.z*=Q*this.strengthZMultiplier):(this.strengthX&&(Q*=this.strengthX.evaluate(r)*1.5),this._temp.multiplyScalar(Q)),t.x+=this._temp.x,t.y+=this._temp.y,t.z+=this._temp.z}}AA([y()],ft.prototype,"damping",2);AA([y()],ft.prototype,"enabled",2);AA([y()],ft.prototype,"frequency",2);AA([y()],ft.prototype,"octaveCount",2);AA([y()],ft.prototype,"octaveMultiplier",2);AA([y()],ft.prototype,"octaveScale",2);AA([y(ne)],ft.prototype,"positionAmount",2);AA([y()],ft.prototype,"quality",2);AA([y(ne)],ft.prototype,"remap",2);AA([y()],ft.prototype,"remapEnabled",2);AA([y()],ft.prototype,"remapMultiplier",2);AA([y(ne)],ft.prototype,"remapX",2);AA([y()],ft.prototype,"remapXMultiplier",2);AA([y(ne)],ft.prototype,"remapY",2);AA([y()],ft.prototype,"remapYMultiplier",2);AA([y(ne)],ft.prototype,"remapZ",2);AA([y()],ft.prototype,"remapZMultiplier",2);AA([y()],ft.prototype,"scrollSpeedMultiplier",2);AA([y()],ft.prototype,"separateAxes",2);AA([y()],ft.prototype,"strengthMultiplier",2);AA([y(ne)],ft.prototype,"strengthX",2);AA([y()],ft.prototype,"strengthXMultiplier",2);AA([y(ne)],ft.prototype,"strengthY",2);AA([y()],ft.prototype,"strengthYMultiplier",2);AA([y(ne)],ft.prototype,"strengthZ",2);AA([y()],ft.prototype,"strengthZMultiplier",2);class Wt{constructor(){B(this,"enabled");B(this,"attachRibbonToTransform",!1);B(this,"colorOverLifetime");B(this,"colorOverTrail");B(this,"dieWithParticles",!0);B(this,"inheritParticleColor",!0);B(this,"lifetime");B(this,"lifetimeMultiplier");B(this,"minVertexDistance",.2);B(this,"mode",0);B(this,"ratio",1);B(this,"ribbonCount",1);B(this,"shadowBias",0);B(this,"sizeAffectsLifetime",!1);B(this,"sizeAffectsWidth",!1);B(this,"splitSubEmitterRibbons",!1);B(this,"textureMode",0);B(this,"widthOverTrail");B(this,"widthOverTrailMultiplier");B(this,"worldSpace",!1)}getWidth(A,e,t,g){let I=this.widthOverTrail.evaluate(t,g);return A*=I,A}getColor(A,e,t){const g=this.colorOverTrail.evaluate(t),I=this.colorOverLifetime.evaluate(e);A.x*=g.r*I.r,A.y*=g.g*I.g,A.z*=g.b*I.b,A.w*=g.alpha*I.alpha}}AA([y()],Wt.prototype,"enabled",2);AA([y()],Wt.prototype,"attachRibbonToTransform",2);AA([y(bI)],Wt.prototype,"colorOverLifetime",2);AA([y(bI)],Wt.prototype,"colorOverTrail",2);AA([y()],Wt.prototype,"dieWithParticles",2);AA([y()],Wt.prototype,"inheritParticleColor",2);AA([y(ne)],Wt.prototype,"lifetime",2);AA([y()],Wt.prototype,"lifetimeMultiplier",2);AA([y()],Wt.prototype,"minVertexDistance",2);AA([y()],Wt.prototype,"mode",2);AA([y()],Wt.prototype,"ratio",2);AA([y()],Wt.prototype,"ribbonCount",2);AA([y()],Wt.prototype,"shadowBias",2);AA([y()],Wt.prototype,"sizeAffectsLifetime",2);AA([y()],Wt.prototype,"sizeAffectsWidth",2);AA([y()],Wt.prototype,"splitSubEmitterRibbons",2);AA([y()],Wt.prototype,"textureMode",2);AA([y(ne)],Wt.prototype,"widthOverTrail",2);AA([y()],Wt.prototype,"widthOverTrailMultiplier",2);AA([y()],Wt.prototype,"worldSpace",2);class $t{constructor(){B(this,"enabled");B(this,"space",0);B(this,"orbitalX");B(this,"orbitalY");B(this,"orbitalZ");B(this,"orbitalXMultiplier");B(this,"orbitalYMultiplier");B(this,"orbitalZMultiplier");B(this,"orbitalOffsetX");B(this,"orbitalOffsetY");B(this,"orbitalOffsetZ");B(this,"speedModifier");B(this,"speedModifierMultiplier");B(this,"x");B(this,"xMultiplier");B(this,"y");B(this,"yMultiplier");B(this,"z");B(this,"zMultiplier");B(this,"_system");B(this,"_temp",new m);B(this,"_temp2",new m);B(this,"_temp3",new m);B(this,"_hasOrbital",!1);B(this,"_index",0);B(this,"_orbitalMatrix",new qA)}update(A){this._system=A}init(A){this._index==0&&(A.debug=!0),this._index+=1,A.orbitx=this.orbitalX.evaluate(Math.random()),A.orbity=this.orbitalY.evaluate(Math.random()),A.orbitz=this.orbitalZ.evaluate(Math.random()),this._hasOrbital=A.orbitx!=0||A.orbity!=0||A.orbitz!=0}apply(A,e,t,g,I,o,s){var E;if(!this.enabled)return;const C=o/s,n=this.speedModifier.evaluate(C)*this.speedModifierMultiplier,a=this.x.evaluate(C),r=this.y.evaluate(C),Q=this.z.evaluate(C);if(this._temp.set(-a,r,Q),this._system&&this._system.main.simulationSpace===1&&this._temp.applyQuaternion(this._system.worldQuaternion),this._hasOrbital&&((E=this._system)==null?void 0:E.worldPos)){const l=this._temp2.set(t.x,t.y,t.z),d=this.orbitalXMultiplier,c=this.orbitalYMultiplier,p=this.orbitalZMultiplier,u=n*Math.PI*2*10,f=Math.cos(u*d),D=Math.sin(u*d),w=Math.cos(u*c),M=Math.sin(u*c),R=Math.cos(u*p),k=Math.sin(u*p),G=l.x*(w*R)+l.y*(w*k)+l.z*-M,J=l.x*(D*M*R-f*k)+l.y*(D*M*k+f*R)+l.z*(D*w),P=l.x*(f*M*R+D*k)+l.y*(f*M*k-D*R)+l.z*(f*w),L=this._temp3.set(l.x-G,l.y-J,l.z-P);L.normalize(),L.multiplyScalar(.2/I*Math.max(this.orbitalXMultiplier,this.orbitalYMultiplier,this.orbitalZMultiplier)),g.x+=L.x,g.y+=L.y,g.z+=L.z}g.x+=this._temp.x,g.y+=this._temp.y,g.z+=this._temp.z,g.x*=n,g.y*=n,g.z*=n}}AA([y()],$t.prototype,"enabled",2);AA([y()],$t.prototype,"space",2);AA([y(ne)],$t.prototype,"orbitalX",2);AA([y(ne)],$t.prototype,"orbitalY",2);AA([y(ne)],$t.prototype,"orbitalZ",2);AA([y()],$t.prototype,"orbitalXMultiplier",2);AA([y()],$t.prototype,"orbitalYMultiplier",2);AA([y()],$t.prototype,"orbitalZMultiplier",2);AA([y()],$t.prototype,"orbitalOffsetX",2);AA([y()],$t.prototype,"orbitalOffsetY",2);AA([y()],$t.prototype,"orbitalOffsetZ",2);AA([y(ne)],$t.prototype,"speedModifier",2);AA([y()],$t.prototype,"speedModifierMultiplier",2);AA([y(ne)],$t.prototype,"x",2);AA([y()],$t.prototype,"xMultiplier",2);AA([y(ne)],$t.prototype,"y",2);AA([y()],$t.prototype,"yMultiplier",2);AA([y(ne)],$t.prototype,"z",2);AA([y()],$t.prototype,"zMultiplier",2);class Mg{constructor(){B(this,"animation");B(this,"enabled");B(this,"cycleCount");B(this,"frameOverTime");B(this,"frameOverTimeMultiplier");B(this,"numTilesX");B(this,"numTilesY");B(this,"startFrame");B(this,"startFrameMultiplier");B(this,"rowMode");B(this,"rowIndex");B(this,"spriteCount");B(this,"timeMode")}sampleOnceAtStart(){if(this.timeMode===0)switch(this.frameOverTime.mode){case 0:case 3:case 2:case 1:return!0}return!1}getStartIndex(){return this.sampleOnceAtStart()?Math.random()*(this.numTilesX*this.numTilesY):0}evaluate(A){if(!this.sampleOnceAtStart())return this.getIndex(A)}getIndex(A){const e=this.numTilesX*this.numTilesY;A=A*this.cycleCount;let t=this.frameOverTime.evaluate(A%1);return t*=this.frameOverTimeMultiplier,t*=e,t=t%e,t=Math.floor(t),t}}AA([y()],Mg.prototype,"animation",2);AA([y()],Mg.prototype,"enabled",2);AA([y()],Mg.prototype,"cycleCount",2);AA([y(ne)],Mg.prototype,"frameOverTime",2);AA([y()],Mg.prototype,"frameOverTimeMultiplier",2);AA([y()],Mg.prototype,"numTilesX",2);AA([y()],Mg.prototype,"numTilesY",2);AA([y(ne)],Mg.prototype,"startFrame",2);AA([y()],Mg.prototype,"startFrameMultiplier",2);AA([y()],Mg.prototype,"rowMode",2);AA([y()],Mg.prototype,"rowIndex",2);AA([y()],Mg.prototype,"spriteCount",2);AA([y()],Mg.prototype,"timeMode",2);class es{constructor(){B(this,"enabled");B(this,"separateAxes");B(this,"x");B(this,"xMultiplier");B(this,"y");B(this,"yMultiplier");B(this,"z");B(this,"zMultiplier")}evaluate(A,e){return this.enabled?this.separateAxes?0:this.z.evaluate(A,e)*-1:0}}AA([y()],es.prototype,"enabled",2);AA([y()],es.prototype,"separateAxes",2);AA([y(ne)],es.prototype,"x",2);AA([y()],es.prototype,"xMultiplier",2);AA([y(ne)],es.prototype,"y",2);AA([y()],es.prototype,"yMultiplier",2);AA([y(ne)],es.prototype,"z",2);AA([y()],es.prototype,"zMultiplier",2);class Qo{constructor(){B(this,"enabled");B(this,"range");B(this,"separateAxes");B(this,"x");B(this,"xMultiplier");B(this,"y");B(this,"yMultiplier");B(this,"z");B(this,"zMultiplier")}evaluate(A,e){if(!this.enabled)return 0;if(!this.separateAxes){const t=te.lerp(this.range.x,this.range.y,e);return this.z.evaluate(t)*-1}return 0}}AA([y()],Qo.prototype,"enabled",2);AA([y()],Qo.prototype,"range",2);AA([y()],Qo.prototype,"separateAxes",2);AA([y(ne)],Qo.prototype,"x",2);AA([y()],Qo.prototype,"xMultiplier",2);AA([y(ne)],Qo.prototype,"y",2);AA([y()],Qo.prototype,"yMultiplier",2);AA([y(ne)],Qo.prototype,"z",2);AA([y()],Qo.prototype,"zMultiplier",2);class bi{constructor(){B(this,"enabled");B(this,"dampen");B(this,"drag");B(this,"dragMultiplier");B(this,"limit");B(this,"limitMultiplier");B(this,"separateAxes");B(this,"limitX");B(this,"limitXMultiplier");B(this,"limitY");B(this,"limitYMultiplier");B(this,"limitZ");B(this,"limitZMultiplier");B(this,"multiplyDragByParticleSize",!1);B(this,"multiplyDragByParticleVelocity",!1);B(this,"space");B(this,"_temp",new m);B(this,"_temp2",new m)}apply(A,e,t,g,I,o,s){if(this.enabled){const C=this.limit.evaluate(I)*this.limitMultiplier;if(e.length()>C){this._temp.copy(e).normalize().multiplyScalar(C);let a=this.dampen*.5;e.x=te.lerp(e.x,this._temp.x,a),e.y=te.lerp(e.y,this._temp.y,a),e.z=te.lerp(e.z,this._temp.z,a),t.x=te.lerp(t.x,this._temp.x,a),t.y=te.lerp(t.y,this._temp.y,a),t.z=te.lerp(t.z,this._temp.z,a)}}}}AA([y()],bi.prototype,"enabled",2);AA([y()],bi.prototype,"dampen",2);AA([y(ne)],bi.prototype,"drag",2);AA([y()],bi.prototype,"dragMultiplier",2);AA([y(ne)],bi.prototype,"limit",2);AA([y()],bi.prototype,"limitMultiplier",2);AA([y()],bi.prototype,"separateAxes",2);AA([y(ne)],bi.prototype,"limitX",2);AA([y()],bi.prototype,"limitXMultiplier",2);AA([y(ne)],bi.prototype,"limitY",2);AA([y()],bi.prototype,"limitYMultiplier",2);AA([y(ne)],bi.prototype,"limitZ",2);AA([y()],bi.prototype,"limitZMultiplier",2);AA([y()],bi.prototype,"multiplyDragByParticleSize",2);AA([y()],bi.prototype,"multiplyDragByParticleVelocity",2);AA([y()],bi.prototype,"space",2);class pr{constructor(){B(this,"enabled");B(this,"curve");B(this,"curveMultiplier");B(this,"mode");B(this,"system");B(this,"_lastWorldPosition");B(this,"_velocity",new m);B(this,"_temp",new m)}update(A){this.enabled&&this.system.worldspace!==!1&&(this._lastWorldPosition?(this._velocity.copy(this.system.worldPos).sub(this._lastWorldPosition).multiplyScalar(1/this.system.deltaTime),this._lastWorldPosition.copy(this.system.worldPos)):(this._velocity.set(0,0,0),this._lastWorldPosition=this.system.worldPos.clone()))}applyInitial(A){if(this.enabled&&this.system.worldspace!==!1&&this.mode===0){const e=this.curve.evaluate(Math.random(),Math.random());this._temp.copy(this._velocity).multiplyScalar(e),A.add(this._temp)}}applyCurrent(A,e,t){if(this.enabled&&this.system.worldspace!==!1&&this.mode===1){const g=this.curve.evaluate(e,t);this._temp.copy(this._velocity).multiplyScalar(g),A.add(this._temp)}}}AA([y()],pr.prototype,"enabled",2);AA([y(ne)],pr.prototype,"curve",2);AA([y()],pr.prototype,"curveMultiplier",2);AA([y()],pr.prototype,"mode",2);class hI{constructor(){B(this,"enabled");B(this,"range");B(this,"separateAxes");B(this,"size");B(this,"sizeMultiplier");B(this,"x");B(this,"xMultiplier");B(this,"y");B(this,"yMultiplier");B(this,"z");B(this,"zMultiplier")}evaluate(A,e,t,g){const I=A.length(),o=te.remap(I,this.range.x,this.range.y,0,1),s=this.size.evaluate(o,t);return g*s}}AA([y()],hI.prototype,"enabled",2);AA([y(X)],hI.prototype,"range",2);AA([y()],hI.prototype,"separateAxes",2);AA([y(ne)],hI.prototype,"size",2);AA([y()],hI.prototype,"sizeMultiplier",2);AA([y(ne)],hI.prototype,"x",2);AA([y()],hI.prototype,"xMultiplier",2);AA([y(ne)],hI.prototype,"y",2);AA([y()],hI.prototype,"yMultiplier",2);AA([y(ne)],hI.prototype,"z",2);AA([y()],hI.prototype,"zMultiplier",2);class VB{constructor(){B(this,"enabled");B(this,"range");B(this,"color")}evaluate(A,e,t){const g=A.length(),I=te.remap(g,this.range.x,this.range.y,0,1),o=this.color.evaluate(I,e);t.x*=o.r,t.y*=o.g,t.z*=o.b,t.w*=o.alpha}}AA([y()],VB.prototype,"enabled",2);AA([y(X)],VB.prototype,"range",2);AA([y(bI)],VB.prototype,"color",2);function _IA(i){const A=i.domElement.querySelector("link[rel='ar']");if(A)return A;const e=document.createElement("div");e.classList.add("menu"),e.classList.add("quicklook-menu"),e.style.display="none",e.style.visibility="hidden";const t=document.createElement("button");t.id="open-in-ar",t.innerText="Open in QuickLook",e.appendChild(t);const g=document.createElement("a");g.id="needle-usdz-link",g.style.display="none",g.rel="ar",g.href="",e.appendChild(g);const I=document.createElement("img");return I.id="button",g.appendChild(I),i.domElement.appendChild(e),g}function OIA(){var i=new Date;const A=i.getMonth()+1,e=i.getDate(),t=i.getHours(),g=i.getMinutes(),I=i.getSeconds(),o=(A<10?"0":"")+A,s=(e<10?"0":"")+e,C=(t<10?"0":"")+t,n=(g<10?"0":"")+g,a=(I<10?"0":"")+I;return i.getFullYear()+o+s+"-"+C+n+a}const of=oA("debugusdz");function PIA(i,A){const e=[],t=eA.getComponentsInChildren(i,QI);let g=!1;of&&console.log(t);for(const I of t){if(!I||!I.runtimeAnimatorController)continue;of&&console.log(I);const o=[];for(const s of I.runtimeAnimatorController.enumerateActions()){of&&console.log(s);const C=s.getClip();if(!g&&C.tracks.length>0){g=!0;const n=C.tracks[0],a=n.name.substring(0,n.name.lastIndexOf(".")),r=new oo(a+".position",[0,.01],[0,0,0,0,0,0]),Q=new oo(a+".quaternion",[0,.01],[0,0,0,1,0,0,0,1]);o.push(new sI("rest",.01,[r,Q]))}o.includes(C)||o.push(C)}e.push({root:I.gameObject,clips:o})}of&&console.log(e);for(const I of e)for(const o of I.clips)A.registerAnimation(I.root,o)}var WIA=Object.defineProperty,VIA=Object.getOwnPropertyDescriptor,On=(i,A,e,t)=>{for(var g=t>1?void 0:t?VIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&WIA(A,e,g),g};const br=oA("debugtext");var Yi=(i=>(i[i.UpperLeft=0]="UpperLeft",i[i.UpperCenter=1]="UpperCenter",i[i.UpperRight=2]="UpperRight",i[i.MiddleLeft=3]="MiddleLeft",i[i.MiddleCenter=4]="MiddleCenter",i[i.MiddleRight=5]="MiddleRight",i[i.LowerLeft=6]="LowerLeft",i[i.LowerCenter=7]="LowerCenter",i[i.LowerRight=8]="LowerRight",i))(Yi||{}),GO=(i=>(i[i.Normal=0]="Normal",i[i.Bold=1]="Bold",i[i.Italic=2]="Italic",i[i.BoldAndItalic=3]="BoldAndItalic",i))(GO||{});class cI extends _B{constructor(){super(...arguments);B(this,"alignment",0);B(this,"verticalOverflow",0);B(this,"horizontalOverflow",0);B(this,"lineSpacing",1);B(this,"supportRichText",!1);B(this,"font");B(this,"fontStyle",0);B(this,"_text","");B(this,"_fontSize",12);B(this,"_textMeshUi",null);B(this,"_didHandleTextRenderOnTop",!1)}setAlphaFactor(e){var t;super.setAlphaFactor(e),(t=this.uiObject)==null||t.set({fontOpacity:this.color.alpha*this.alphaFactor}),this.markDirty()}get text(){return this._text}set text(e){e!==this._text&&(this._text=e,this.feedText(this.text,this.supportRichText),this.markDirty())}set_text(e){this.text=e}get fontSize(){return this._fontSize}set fontSize(e){var t;this._fontSize=e,(t=this.uiObject)==null||t.set({fontSize:e})}onColorChanged(){var e;(e=this.uiObject)==null||e.set({color:this.color,fontOpacity:this.color.alpha})}onParentRectTransformChanged(){super.onParentRectTransformChanged(),this.uiObject&&this.updateOverflow()}onBeforeRender(){var e;this.uiObject&&((e=this.Canvas)!=null&&e.screenspace||this.context.isInVR)&&this.updateOverflow()}updateOverflow(){var t;const e=(t=this.uiObject)==null?void 0:t._overflow;e&&(e._needsUpdate=!0,this.markDirty())}onCreate(e){br&&console.log(this),this.horizontalOverflow==1&&(e.whiteSpace="pre"),this.verticalOverflow==0&&(this.context.renderer.localClippingEnabled=!0,e.overflow="hidden"),this.horizontalOverflow==1&&this.verticalOverflow==0,e.lineHeight=this.lineSpacing,delete e.backgroundOpacity,delete e.backgroundColor,br&&(e.backgroundColor=16750848,e.backgroundOpacity=.5);const t=this.rectTransform;e={...e,...this.getTextOpts()},this.getAlignment(e),br&&(e.backgroundColor=Math.random()*16777215,e.backgroundOpacity=.1),this.uiObject=t.createNewText(e),this.feedText(this.text,this.supportRichText)}onAfterAddedToScene(){super.onAfterAddedToScene(),this.handleTextRenderOnTop()}getTextOpts(){let e=this.fontSize;const t={color:this.color,fontOpacity:this.color.alpha,fontSize:e,fontKerning:"normal"};return this.setFont(t,this.fontStyle),t}onEnable(){super.onEnable(),this._didHandleTextRenderOnTop=!1,this.uiObject&&this.uiObject.addAfterUpdate(()=>{this.setShadowComponentOwner(this.uiObject),this.markDirty()}),setTimeout(()=>this.markDirty(),10)}getAlignment(e){switch(e.flexDirection="column",this.alignment){case 0:case 3:case 6:e.textAlign="left";break;case 1:case 4:case 7:e.textAlign="center";break;case 2:case 5:case 8:e.textAlign="right";break}switch(this.alignment){default:case 0:case 1:case 2:e.alignItems="start";break;case 3:case 4:case 5:e.alignItems="center";break;case 6:case 7:case 8:e.alignItems="end";break}return e}feedText(e,t){var g,I,o;if(br&&console.log("feedText",this.uiObject,e,t),!!this.uiObject)if(this._textMeshUi||(this._textMeshUi=[]),this.uiObject.children.length=0,!t||e.length===0)this.uiObject.textContent=e;else{let s=this.getNextTag(e);if(s){if(s.startIndex>0){for(let a=this.uiObject.children.length-1;a>=0;a--){const r=this.uiObject.children[a];r.isUI&&(this.uiObject.remove(r),r.clear())}const n=new cD({textContent:e.substring(0,s.startIndex),color:"inherit"});this.uiObject.add(n)}}else{this.uiObject.textContent="",this.setOptions({textContent:e});return}const C=[];for(;s;){const n=this.getNextTag(e,s.endIndex),a={fontFamily:(g=this.uiObject)==null?void 0:g.get("fontFamily"),color:"inherit",textContent:""};if(n){a.textContent=this.getText(e,s,n),this.handleTag(s,a,C);const r=new cD(a);(I=this.uiObject)==null||I.add(r)}else{a.textContent=e.substring(s.endIndex),this.handleTag(s,a,C);const r=new cD(a);(o=this.uiObject)==null||o.add(r)}s=n}}}handleTextRenderOnTop(){this._didHandleTextRenderOnTop||(this._didHandleTextRenderOnTop=!0,this.startCoroutine(this.renderOnTopCoroutine()))}*renderOnTopCoroutine(){if(!this.canvas)return;const e=[],t=this.canvas,g={renderOnTop:t.renderOnTop,depthWrite:t.depthWrite,doubleSided:t.doubleSided};for(;;){let I=!1;if(this._textMeshUi)for(let o=0;o<this._textMeshUi.length;o++){if(e[o]===!0)continue;I=!0;const s=this._textMeshUi[o];s.textContent&&(Dy(s,g),e[o]=!0)}if(!I)break;yield}}handleTag(e,t,g){if(!e.isEndTag){if(e.type.includes("color")){const I=new Cm(e,{color:t.color});if(g.push(I),e.type.length>6){const o=parseInt("0x"+e.type.substring(7));t.color=o}else t.color=new DA(1,1,1)}else if(e.type=="b"){this.setFont(t,1);const I=new Cm(e,{fontWeight:700});g.push(I)}else if(e.type=="i"){this.setFont(t,2);const I=new Cm(e,{fontStyle:"italic"});g.push(I)}}}getText(e,t,g){return e.substring(t.endIndex,g.startIndex)}getNextTag(e,t=0){const g=e.indexOf("<",t),I=e.indexOf(">",g);if(g>=0&&I>=0){const o=e.substring(g+1,I);return{type:o,startIndex:g,endIndex:I+1,isEndTag:o.startsWith("/")}}return null}setFont(e,t){if(!this.font)return;let g=this.font,I=this.getFamilyNameWithCorrectSuffix(g,t);br&&console.log("Selected font family:"+I);let o=KM.getFontFamily(I);switch(o||(o=KM.addFontFamily(I)),e.fontFamily=o,t){default:case 0:e.fontWeight=400,e.fontStyle="normal";break;case 1:e.fontWeight=700,e.fontStyle="normal";break;case 2:e.fontWeight=400,e.fontStyle="italic";break;case 3:e.fontStyle="italic",e.fontWeight=400}let s=o.getVariant(e.fontWeight,e.fontStyle);if(!s){let C=I;C!=null&&C.endsWith("-msdf.json")||(C+="-msdf.json");let n=I;n!=null&&n.endsWith(".png")||(n+=".png"),s=o.addVariant(e.fontWeight,e.fontStyle,C,n),s==null||s.addEventListener("ready",()=>{this.markDirty()})}}getFamilyNameWithCorrectSuffix(e,t){var a;const g=e.lastIndexOf("-");if(g<0)return e;const I=(a=e.substring(g+1))==null?void 0:a.toLowerCase();if(zIA.includes(I))return br&&console.warn("Unsupported font style: "+I),e;const o=e.lastIndexOf("/");let s=e;o>=0&&(s=s.substring(o+1));let C=s[0]===s[0].toUpperCase();const n=e.substring(0,g);switch(br&&console.log("Select font: ",e,GO[t],s,C,n),t){case 0:return C?n+"-Regular":n+"-regular";case 1:return C?n+"-Bold":n+"-bold";case 2:return C?n+"-Italic":n+"-italic";case 3:return C?n+"-BoldItalic":n+"-bolditalic";default:return e}}}On([y()],cI.prototype,"alignment",2);On([y()],cI.prototype,"verticalOverflow",2);On([y()],cI.prototype,"horizontalOverflow",2);On([y()],cI.prototype,"lineSpacing",2);On([y()],cI.prototype,"supportRichText",2);On([y(URL)],cI.prototype,"font",2);On([y()],cI.prototype,"fontStyle",2);On([y()],cI.prototype,"text",1);On([y()],cI.prototype,"fontSize",1);class Cm{constructor(A,e){B(this,"tag");B(this,"previousValues");this.tag=A,this.previousValues=e}}const zIA=["medium","mediumitalic","black","blackitalic","thin","thinitalic","extrabold","light","lightitalic","semibold"];class Fa{constructor(A){B(this,"id");B(this,"content","");B(this,"font",[]);B(this,"pointSize",144);B(this,"width");B(this,"height");B(this,"depth");B(this,"wrapMode");B(this,"horizontalAlignment");B(this,"verticalAlignment");B(this,"material");this.id=A}static getId(){return this.global_id++}setDepth(A){return this.depth=A,this}setPointSize(A){return this.pointSize=A,this}setHorizontalAlignment(A){return this.horizontalAlignment=A,this}setVerticalAlignment(A){return this.verticalAlignment=A,this}writeTo(A,e){var g;e.beginBlock(`def Preliminary_Text "${this.id}"`),this.content&&e.appendLine(`string content = "${this.content}"`),(!this.font||this.font.length<=0)&&(this.font||(this.font=[]),(g=this.font)==null||g.push("sans-serif"));const t=this.font.map(I=>`"${I}"`).join(", ");e.appendLine(`string[] font = [ ${t} ]`),e.appendLine(`double pointSize = ${this.pointSize}`),typeof this.width=="number"&&e.appendLine(`double width = ${this.width}`),typeof this.height=="number"&&e.appendLine(`double height = ${this.height}`),typeof this.depth=="number"&&e.appendLine(`double depth = ${this.depth}`),this.wrapMode&&e.appendLine(`token wrapMode = "${this.wrapMode}"`),this.horizontalAlignment&&e.appendLine(`token horizontalAlignment = "${this.horizontalAlignment}"`),this.verticalAlignment&&e.appendLine(`token verticalAlignment = "${this.verticalAlignment}"`),this.material!==void 0&&e.appendLine(`rel material:binding = </Materials/Material_${this.material.id}>`),e.closeBlock()}}B(Fa,"global_id",0);class NS{static singleLine(A,e,t){const g=new Fa("text_"+Fa.getId());return g.content=A,e&&(g.pointSize=e),t&&(g.depth=t),g}static multiLine(A,e,t,g,I,o){const s=new Fa("text_"+Fa.getId());return s.content=A,s.width=e,s.height=t,s.horizontalAlignment=g,s.verticalAlignment=I,o!==void 0&&(s.wrapMode=o),s}}const jIA=new qA().makeRotationY(Math.PI),ZIA=new qA().makeScale(-1,1,-1);class yu{get extensionName(){return"text"}onExportObject(A,e,t){}exportText(A,e,t){const g=eA.getComponent(A,cI);if(!g)return;const I=eA.getComponent(A,yg);let o=100,s=100;I&&(o=I.width,s=I.height),e.matrix=jIA.clone(),I&&e.matrix.premultiply(ZIA);const C=new DA().copySRGBToLinear(g.color);e.material=new ks({color:C,emissive:C}),e.addEventListener("serialize",(n,a)=>{let r=g.text;r=r.replace(/\n/g,"\\n");const Q=NS.multiLine(r,o,s,"center","bottom","flowing");this.setTextAlignment(Q,g.alignment),this.setOverflow(Q,g),e.material&&(Q.material=e.material),Q.pointSize=this.convertToTextSize(g.fontSize),Q.depth=.001,Q.writeTo(void 0,n)})}convertToTextSize(A){return 1/.0502*144*A}setOverflow(A,e){e.horizontalOverflow?A.wrapMode="singleLine":A.wrapMode="flowing"}setTextAlignment(A,e){switch(e){case Yi.LowerLeft:case Yi.MiddleLeft:case Yi.UpperLeft:A.horizontalAlignment="left";break;case Yi.LowerCenter:case Yi.MiddleCenter:case Yi.UpperCenter:A.horizontalAlignment="center";break;case Yi.LowerRight:case Yi.MiddleRight:case Yi.UpperRight:A.horizontalAlignment="right";break}switch(e){case Yi.LowerLeft:case Yi.LowerCenter:case Yi.LowerRight:A.verticalAlignment="bottom";break;case Yi.MiddleLeft:case Yi.MiddleCenter:case Yi.MiddleRight:A.verticalAlignment="middle";break;case Yi.UpperLeft:case Yi.UpperCenter:case Yi.UpperRight:A.verticalAlignment="top";break}}}class KS{get extensionName(){return"tmui"}onExportObject(A,e,t){const g=eA.getComponent(A,wg);if(g&&g.activeAndEnabled&&g.renderMode===SO.WorldSpace){const I=new yu,o=eA.getComponent(A,yg),s=eA.getComponent(A,$a);if(o){o.width,o.height;const C=GI.createEmpty(),n=o.shadowComponent;if(e.add(C),n){const a=n.matrix;C.matrix.copy(a);const r=new Map,Q=new Map;r.set(n,C),Q.set(n,s?s.alpha:1),n.traverse(E=>{if(E===n)return;const h=GI.createEmpty();h.matrix.copy(E.matrix);const l=E.parent,d=l&&typeof l.textContent=="string"&&l.textContent.length;let c=Q.get(l)||1;const p=eA.getComponent(E,$a);if(p&&(c*=p.alpha),E instanceof yA&&d){const f=E[AC].gameObject;I.exportText(f,h,t)}if(E instanceof yA&&!d){const f=E.geometry.clone();f.scale(1,1,-1),this.flipWindingOrder(f),h.geometry=f;const D=new DA,w=E.material.opacity;D.copy(E.material.color),h.material=new dt({color:D,opacity:w*c,map:E.material.map,transparent:!0})}r.set(E,h),Q.set(E,c);const u=r.get(l);if(!u){console.error("Error when exporting UI: shadow component parent not found!",E,E.parent);return}u.add(h)})}}}}flipWindingOrder(A){const e=A.index.array;for(let t=0,g=e.length/3;t<g;t++){let I=e[t*3];e[t*3]=e[t*3+2],e[t*3+2]=I}A.index.needsUpdate=!0}}var XIA=Object.defineProperty,$IA=Object.getOwnPropertyDescriptor,Eo=(i,A,e,t)=>{for(var g=t>1?void 0:t?$IA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&XIA(A,e,g),g};const Zi=oA("debugusdz");class fr{constructor(){B(this,"callToAction");B(this,"checkoutTitle");B(this,"checkoutSubtitle");B(this,"callToActionURL")}}Eo([y()],fr.prototype,"callToAction",2);Eo([y()],fr.prototype,"checkoutTitle",2);Eo([y()],fr.prototype,"checkoutSubtitle",2);Eo([y()],fr.prototype,"callToActionURL",2);class ho extends mA{constructor(){super(...arguments);B(this,"objectToExport");B(this,"autoExportAnimations",!1);B(this,"exportFileName");B(this,"customUsdzFile");B(this,"customBranding");B(this,"anchoringType","plane");B(this,"planeAnchoringAlignment","horizontal");B(this,"interactive",!0);B(this,"extensions",[]);B(this,"allowCreateQuicklookButton",!0);B(this,"link");B(this,"webxr");B(this,"onClickedOpenInARElement",e=>{e.preventDefault(),this.exportAsync()});B(this,"lastCallback");B(this,"_quicklookButton");B(this,"_quicklookButtonContainer",null)}start(){var e,t,g;Zi&&(console.log(this),console.log("Debug USDZ, press 't' to export"),window.addEventListener("keydown",I=>{switch(I.key){case"t":this.exportAsync();break}}),ir()&&setTimeout(()=>{this.exportAsync()},2e3)),this.objectToExport||(this.objectToExport=this.gameObject),!((t=(e=this.objectToExport)==null?void 0:e.children)!=null&&t.length)&&!((g=this.objectToExport)!=null&&g.isMesh)&&(this.objectToExport=this.context.scene),this.interactive&&(this.extensions.push(new GS),this.extensions.push(new kS),this.extensions.push(new yu),this.extensions.push(new KS))}onEnable(){var g;const e=vl(),t=tn();(Zi||e&&t)&&((Zi||this.allowCreateQuicklookButton)&&this.addQuicklookButton(),this.lastCallback=this.quicklookCallback.bind(this),this.link=_IA(this.context),this.link.addEventListener("message",this.lastCallback)),Zi&&Mi("USDZ Exporter enabled: "+this.name),(g=document.getElementById("open-in-ar"))==null||g.addEventListener("click",this.onClickedOpenInARElement)}onDisable(){var g,I;(g=this.link)==null||g.removeEventListener("message",this.lastCallback);const e=vl(),t=tn();(Zi||e&&t)&&this.removeQuicklookButton(),Zi&&Mi("USDZ Exporter disabled: "+this.name),(I=document.getElementById("open-in-ar"))==null||I.removeEventListener("click",this.onClickedOpenInARElement)}async exportAsync(){var l;let e=this.exportFileName??((l=this.objectToExport)==null?void 0:l.name)??this.name;if(wE()||(e+="-MadeWithNeedle"),e+="-"+OIA(),this.customUsdzFile){Zi&&console.log("Exporting custom usdz",this.customUsdzFile);const d=this.buildQuicklookOverlay();Zi&&console.log(d);const c=d.callToAction?encodeURIComponent(d.callToAction):"",p=d.checkoutTitle?encodeURIComponent(d.checkoutTitle):"",u=d.checkoutSubtitle?encodeURIComponent(d.checkoutSubtitle):"";this.link.href=this.customUsdzFile+`#callToAction=${c}&checkoutTitle=${p}&checkoutSubtitle=${u}&callToActionURL=${d.callToActionURL}`,Zi&&console.log(this.link.href),this.lastCallback||(this.lastCallback=this.quicklookCallback.bind(this),this.link.addEventListener("message",this.lastCallback)),this.link.download=e+".usdz",this.link.click();return}if(!this.objectToExport)return;const t=eA.getComponentsInChildren(this.objectToExport,_t),g=new Array;for(const d of t)for(const c of d.sharedMaterials)if(c){const p=d.loadProgressiveTextures(c);p instanceof Promise&&g.push(p)}Zi&&Mi("Load textures: "+g.length),await Promise.all(g),Zi&&Mi("Load textures: done"),this.applyWebARSessionRoot();const I=new Z7,o=[...this.extensions],s=new CS;o.push(s),this.autoExportAnimations&&PIA(this.objectToExport,s);const C={self:this,exporter:I,extensions:o,object:this.objectToExport};this.dispatchEvent(new CustomEvent("before-export",{detail:C})),I.debug=Zi,this.anchoringType!=="plane"&&this.anchoringType!=="none"&&this.anchoringType!=="image"&&this.anchoringType!=="face"&&(this.anchoringType="plane"),this.planeAnchoringAlignment!=="horizontal"&&this.planeAnchoringAlignment!=="vertical"&&this.planeAnchoringAlignment!=="any"&&(this.planeAnchoringAlignment="horizontal");const n=await I.parse(this.objectToExport,{ar:{anchoring:{type:this.anchoringType},planeAnchoring:{alignment:this.planeAnchoringAlignment}},extensions:o,quickLookCompatible:!0}),a=new Blob([n],{type:"application/octet-stream"});this.dispatchEvent(new CustomEvent("after-export",{detail:C}));const r=this.buildQuicklookOverlay();Zi&&console.log(r);const Q=r.callToAction?encodeURIComponent(r.callToAction):"",E=r.checkoutTitle?encodeURIComponent(r.checkoutTitle):"",h=r.checkoutSubtitle?encodeURIComponent(r.checkoutSubtitle):"";this.link.href=URL.createObjectURL(a)+`#callToAction=${Q}&checkoutTitle=${E}&checkoutSubtitle=${h}&callToActionURL=${r.callToActionURL}`,this.lastCallback||(this.lastCallback=this.quicklookCallback.bind(this),this.link.addEventListener("message",this.lastCallback)),this.link.download=e+".usdz",this.link.click()}quicklookCallback(e){if((e==null?void 0:e.data)=="_apple_ar_quicklook_button_tapped"){Zi&&zo("Quicklook closed via call to action button");var t=new CustomEvent("quicklook-button-tapped",{detail:this});if(this.dispatchEvent(t),!t.defaultPrevented){const g=new URLSearchParams(this.link.href);if(g){const I=g.get("callToActionURL");Zi&&Mi("Quicklook url: "+I),I&&(wE()?globalThis.open(I,"_blank"):console.warn("Quicklook closed: custom redirects require a Needle Engine Pro license: https://needle.tools/pricing",I))}}}}buildQuicklookOverlay(){var g,I,o,s,C,n;const e={};return this.customBranding&&Object.assign(e,this.customBranding),wE()||(console.log("Custom Quicklook banner text requires pro license: https://needle.tools/pricing"),e.callToAction="Close",e.checkoutTitle="🌵 Made with Needle",e.checkoutSubtitle="_"),(((g=e.callToAction)==null?void 0:g.length)||((I=e.checkoutTitle)==null?void 0:I.length)||((o=e.checkoutSubtitle)==null?void 0:o.length))&&((s=e.callToAction)!=null&&s.length||(e.callToAction="\0"),(C=e.checkoutTitle)!=null&&C.length||(e.checkoutTitle="\0"),(n=e.checkoutSubtitle)!=null&&n.length||(e.checkoutSubtitle="\0")),this.dispatchEvent(new CustomEvent("quicklook-overlay",{detail:e})),e}async createQuicklookButton(){var e,t;if(!this.webxr)if(await Kd(1),this.webxr=eA.findObjectOfType(Se)??void 0,this.webxr)if(this.webxr.VRButton&&((e=this.webxr.VRButton.parentElement)==null||e.removeChild(this.webxr.VRButton)),this.webxr.ARButton&&this._quicklookButton!==this.webxr.ARButton){this._quicklookButton=this.webxr.ARButton;const g=(t=this.webxr.ARButton.parentElement)==null?void 0:t.querySelector("a");g&&(g.href=""),this.webxr.ARButton.innerText="Open in Quicklook",this.webxr.ARButton.disabled=!1,this.webxr.ARButton.addEventListener("click",I=>{I.preventDefault(),this.exportAsync()}),this.webxr.ARButton.classList.add("quicklook-ar-button"),this._quicklookButtonContainer=this.webxr.ARButton.parentElement,this.dispatchEvent(new CustomEvent("created-button",{detail:this.webxr.ARButton}))}else{this.webxr.createARButton=!1,this.webxr.createVRButton=!1;let g=this.context.domElement.shadowRoot.querySelector(".webxr-buttons");g||(g=document.createElement("div"),g.classList.add("webxr-buttons"));const I=document.createElement("button");I.innerText="Open in Quicklook",I.addEventListener("click",()=>{this.exportAsync()}),I.classList.add("webxr-ar-button"),I.classList.add("webxr-button"),I.classList.add("quicklook-ar-button"),this._quicklookButton=I,g.appendChild(I),this._quicklookButtonContainer=g,this.dispatchEvent(new CustomEvent("created-button",{detail:I}))}else console.warn("Could not find WebXR component: will not create Quicklook button",Je.Current)}async addQuicklookButton(){await this.createQuicklookButton(),this._quicklookButton&&this._quicklookButtonContainer&&this._quicklookButtonContainer.appendChild(this._quicklookButton)}removeQuicklookButton(){var e;(e=this._quicklookButton)==null||e.remove()}applyWebARSessionRoot(){if(Zi&&console.log("applyWebARSessionRoot"),!this.objectToExport)return;let e=eA.getComponentInParent(this.objectToExport,lC);const t=e!=null;if(e||(e=eA.getComponentInChildren(this.objectToExport,lC)),!e){Zi&&console.warn("No WebARSessionRoot found in parent hierarchy",this.objectToExport);return}const g=t?this.objectToExport:e.gameObject,I=1/e.arScale;Zi&&console.log("Scale",I,g),g.matrix.makeScale(I,I,I),e.invertForward&&g.matrix.multiply(new qA().makeRotationY(Math.PI))}}Eo([y(bA)],ho.prototype,"objectToExport",2);Eo([y()],ho.prototype,"autoExportAnimations",2);Eo([y()],ho.prototype,"exportFileName",2);Eo([y(URL)],ho.prototype,"customUsdzFile",2);Eo([y(fr)],ho.prototype,"customBranding",2);Eo([y()],ho.prototype,"anchoringType",2);Eo([y()],ho.prototype,"planeAnchoringAlignment",2);Eo([y()],ho.prototype,"interactive",2);Eo([y()],ho.prototype,"allowCreateQuicklookButton",2);const zb=oA("debugdeletable");class JS extends Lo{}class YF extends mA{constructor(){super(...arguments);B(this,"deleteBoxes",[])}awake(){this.deleteBoxes=eA.findObjectsOfType(JS,this.context)}update(){for(const e of this.deleteBoxes){const t=this.gameObject;if(e.isInBox(t)===!0){const I=eA.getComponentInParent(this.gameObject,fh);I?zb&&console.warn("Can not delete object with usage marker",this.guid,I):(zb&&console.log("DESTROY",this.gameObject),Pw(this.gameObject,this.context.connection))}}}}var AoA=Object.defineProperty,eoA=Object.getOwnPropertyDescriptor,zB=(i,A,e,t)=>{for(var g=t>1?void 0:t?eoA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&AoA(A,e,g),g};class qs extends _g{constructor(){super(...arguments);B(this,"mode");B(this,"focusDistance");B(this,"focalLength");B(this,"aperture");B(this,"gaussianMaxRadius");B(this,"resolutionScale");B(this,"bokehScale")}get typeName(){return"DepthOfField"}init(){this.focalLength.valueProcessor=t=>{const g=t/300,I=2;return te.lerp(I,.01,g)};const e=20;this.aperture.valueProcessor=t=>{const g=1-t/32;return te.lerp(1,e,g)}}onCreateEffect(){if(this.mode===0)return;const e=1/window.devicePixelRatio;if(this.resolutionScale===void 0){let g=1;ir()&&(g=.6),this.resolutionScale=new Re(g*e)}const t=new FH(this.context.mainCamera,{worldFocusRange:.2,focalLength:1,bokehScale:20,resolutionScale:this.resolutionScale.value});return this.focusDistance.onValueChanged=g=>{t.circleOfConfusionMaterial.worldFocusDistance=g},this.focalLength.onValueChanged=g=>t.circleOfConfusionMaterial.worldFocusRange=g,this.aperture.onValueChanged=g=>t.bokehScale=g,this.resolutionScale&&(this.resolutionScale.onValueChanged=g=>t.resolution.scale=g),[t]}unapply(){}}zB([y()],qs.prototype,"mode",2);zB([y(Re)],qs.prototype,"focusDistance",2);zB([y(Re)],qs.prototype,"focalLength",2);zB([y(Re)],qs.prototype,"aperture",2);zB([y(Re)],qs.prototype,"gaussianMaxRadius",2);zB([y(Re)],qs.prototype,"resolutionScale",2);zB([y(Re)],qs.prototype,"bokehScale",2);As("DepthOfField",qs);var toA=Object.defineProperty,ioA=Object.getOwnPropertyDescriptor,goA=(i,A,e,t)=>{for(var g=t>1?void 0:t?ioA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&toA(A,e,g),g};class qS extends mA{constructor(){super(...arguments);B(this,"visibleOn")}onEnable(){this.apply()}apply(){this.test()||eA.setActive(this.gameObject,!1)}test(){return this.visibleOn<0?!0:IoA()?(this.visibleOn&2)!==0:(this.visibleOn&1)!==0}}goA([y()],qS.prototype,"visibleOn",2);let sf;function IoA(){if(sf===!0||sf===!1)return sf;let i=!1;return function(A){(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(A)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(A.substr(0,4)))&&(i=!0)}(navigator.userAgent||navigator.vendor||window.opera),sf=i,i}class HF{get extensionName(){return"DocumentExtension"}onAfterBuildDocument(A){}}var ooA=Object.defineProperty,soA=Object.getOwnPropertyDescriptor,MO=(i,A,e,t)=>{for(var g=t>1?void 0:t?soA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&ooA(A,e,g),g},RO=(i=>(i.SelectStart="selectstart",i.SelectEnd="selectend",i))(RO||{}),Yf;const ya=(Yf=class extends ph{constructor(){super();B(this,"showGizmo",!0);B(this,"useViewAngle",!0);B(this,"transformSelf",!0);B(this,"orbit",null);B(this,"selectStartEventListener",[]);B(this,"selectEndEventListener",[]);B(this,"_dragHelper",null);B(this,"_draggingRigidbodies",[]);B(this,"_waitingForDragStart",null);B(this,"_isDragging",!1);B(this,"_marker",null);B(this,"_dragDelta");B(this,"_didDrag",!1);B(this,"_activePointerId");this.selectStartEventListener=[],this.selectEndEventListener=[],this._dragDelta=new X}static get HasAnySelected(){return this._active>0}addDragEventListener(A,e){switch(A){case"selectstart":this.selectStartEventListener.push(e);break;case"selectend":this.selectEndEventListener.push(e);break}}start(){this.orbit=eA.findObjectOfType(Tn,this.context),this.gameObject.getComponentInParent(Un)||this.gameObject.addNewComponent(Un)}allowEdit(A=null){return this.context.connection.allowEditing}onPointerEnter(A){if(!this.allowEdit(this.gameObject)||Se.IsInWebXR)return;const e=eA.getComponentInParent(A.object,ya);!e||e!==this||(ya.lastHovered=A.object,this.context.domElement.style.cursor="pointer")}onPointerExit(A){this.allowEdit(this.gameObject)&&(Se.IsInWebXR||ya.lastHovered===A.object&&(this.context.domElement.style.cursor="auto"))}onPointerDown(A){this.allowEdit(this.gameObject)&&(Se.IsInWebXR||(ya._active+=1,this._dragDelta.set(0,0),this._didDrag=!1,this._waitingForDragStart=A.clone(),A.stopPropagation(),this.orbit&&(this.orbit.enabled=!1)))}onPointerUp(A){this._waitingForDragStart=null,this.allowEdit(this.gameObject)&&(ya._active>0&&(ya._active-=1),!Se.IsInWebXR&&(this.onDragEnd(A),A.stopPropagation(),this.orbit&&(this.orbit.enabled=!0)))}update(){var A;if(!Se.IsInWebXR){if(this._waitingForDragStart){if(!this._didDrag){const t=this.context.input.getPointerPositionDelta(0);if(t&&this._dragDelta.add(t),this._dragDelta.length()>2)this._didDrag=!0;else return}const e=this._waitingForDragStart;this._waitingForDragStart=null,this.onDragStart(e)}this._dragHelper&&this._dragHelper.hasSelected&&this.onUpdateDrag(),(((A=this._dragHelper)==null?void 0:A.hasSelected)===!1||this._activePointerId!==void 0&&this.context.input.getPointerPressed(this._activePointerId)===!1)&&this.onDragEnd(null)}}onDragStart(A){if(!this._dragHelper)if(this.context.mainCamera)this._dragHelper=new uD(this.context.mainCamera);else return;if(!A||!A.object)return;const e=eA.getComponentInParent(A.object,ya);if(!e||e!==this)return;let t=A.object;this.transformSelf&&(t=this.gameObject);const g={selected:t,attached:t};for(const C of this.selectStartEventListener)C(this,g);if(this._activePointerId=A.pointerId,!g.attached)return;g.attached,t=g.attached,this._isDragging=!0,this._dragHelper.setSelected(t,this.context),this.orbit&&(this.orbit.enabled=!1);const I=eA.getComponentInChildren(t,ja);I&&(I.fastMode=!0,I==null||I.requestOwnership()),this._marker=eA.addNewComponent(t,fh),this._draggingRigidbodies.length=0;const o=eA.getComponentsInChildren(t,Xt);o&&this._draggingRigidbodies.push(...o);const s=bD();eA.invokeOnChildren(this._dragHelper.selected,s("onDragStart"))}onUpdateDrag(){if(this._dragHelper){this._dragHelper.showGizmo=this.showGizmo,this._dragHelper.useViewAngle=this.useViewAngle,this._dragHelper.onUpdate(this.context);for(const A of this._draggingRigidbodies)A.wakeUp(),A.resetVelocities()}}onDragEnd(A){if(!this||!this._isDragging||(this._isDragging=!1,!this._dragHelper))return;for(const g of this._draggingRigidbodies)g.setVelocity(g.smoothedVelocity);this._draggingRigidbodies.length=0;const e=this._dragHelper.selected;if(this._dragHelper.setSelected(null,this.context),this.orbit&&(this.orbit.enabled=!0),A!=null&&A.object){const g=eA.getComponentInChildren(A.object,ja);g&&(g.fastMode=!1)}this._marker&&this._marker.destroy();for(const g of this.selectEndEventListener)g(this);const t=bD();eA.invokeOnChildren(e,t("onDragEnd"))}},B(Yf,"_active",0),B(Yf,"lastHovered"),Yf);let xh=ya;MO([y()],xh.prototype,"showGizmo",2);MO([y()],xh.prototype,"useViewAngle",2);const iK=class{constructor(A){B(this,"showGizmo",!0);B(this,"useViewAngle",!0);B(this,"_selected",null);B(this,"_context",null);B(this,"_camera");B(this,"_cameraPlane",new qo);B(this,"_hasGroundPlane",!1);B(this,"_groundPlane",new qo);B(this,"_groundOffset",new m);B(this,"_groundOffsetFactor",0);B(this,"_groundDistance",0);B(this,"_groundPlanePoint",new m);B(this,"_raycaster",new nh);B(this,"_cameraPlaneOffset",new m);B(this,"_intersection",new m);B(this,"_worldPosition",new m);B(this,"_inverseMatrix",new qA);B(this,"_rbs",[]);B(this,"_groundLine");B(this,"_groundMarker");B(this,"_groundOffsetVector",new m(0,1,0));B(this,"_requireUpdateGroundPlane",!0);B(this,"_didDragOnGroundPlaneLastFrame",!1);this._camera=A;const e=new ci(iK.geometry),t=e.material;t.color=new DA(.4,.4,.4),e.layers.set(2),e.name="line",e.scale.y=1,this._groundLine=e;const g=new Zo(.5,22,22),I=new dt({color:t.color}),o=new yA(g,I);o.visible=!1,o.layers.set(2),this._groundMarker=o}get hasSelected(){return this._selected!==null&&this._selected!==void 0}get selected(){return this._selected}setSelected(A,e){if(this._selected&&e)for(const t of this._rbs)t.wakeUp(),t.setVelocity(0,0,0);if(this._selected&&nI.Remove(e,this._selected),this._selected=A,this._context=e,this._rbs.length=0,A?(e.scene.add(this._groundLine),e.scene.add(this._groundMarker)):(this._groundLine.removeFromParent(),this._groundMarker.removeFromParent()),this._selected){if(!e){console.error("DragHelper: no context");return}nI.Add(e,this._selected,null),this._groundOffsetFactor=0,this._hasGroundPlane=!0,this._groundOffset.set(0,0,0),this._requireUpdateGroundPlane=!0,this.onUpdateScreenSpacePlane()}}onUpdate(A){var s,C,n,a,r;if(!this._context)return;const e="Space",t="KeyD",g=((s=this._context)==null?void 0:s.input.isKeyPressed(e))||((C=this._context)==null?void 0:C.input.isKeyPressed(t)),I=this._context.input.getTouchesPressedCount()>=2||g;if(I){const Q=this._context.input.getPointerPositionDelta(0);Q&&(this._groundOffsetVector.set(0,1,0),(n=this._selected)==null||n.rotateOnWorldAxis(this._groundOffsetVector,Q.x*this._context.time.deltaTime))}const o=this._context.input.getPointerPositionRC(0);if(o&&(this._raycaster.setFromCamera(o,this._camera),this._selected)){this._groundOffsetVector.set(0,1,0);const Q=ye(this._camera).clone().sub(ye(this._selected)).normalize(),E=Math.abs(Q.dot(this._groundOffsetVector)),h=((a=this._context)==null?void 0:a.input.isKeyPressed(e))||((r=this._context)==null?void 0:r.input.isKeyPressed(t));let l=!this.useViewAngle||E>.2;(I||h||this._context.input.getPointerPressedCount()>1)&&(l=!1);const d=this._didDragOnGroundPlaneLastFrame!==l;if(this._didDragOnGroundPlaneLastFrame=l,this._hasGroundPlane||(this._requireUpdateGroundPlane=!0),(this._requireUpdateGroundPlane||!l||d)&&this.onUpdateGroundPlane(),this._requireUpdateGroundPlane=!1,this._hasGroundPlane)if(this._raycaster.ray.intersectPlane(this._groundPlane,this._intersection)){const c=this._intersection.y;if(this._groundPlanePoint.copy(this._intersection).sub(this._groundOffset),this._groundPlanePoint.y=c,l){this._groundOffsetVector.set(0,1,0);const p=this._intersection.sub(this._groundOffset).add(this._groundOffsetVector.multiplyScalar(this._groundOffsetFactor));this.onUpdateWorldPosition(p,this._groundPlanePoint,!1),this.onDidUpdate();return}}else this._groundPlanePoint.set(0,99999,0);d&&this.onUpdateScreenSpacePlane(),this._requireUpdateGroundPlane=!0,this._raycaster.ray.intersectPlane(this._cameraPlane,this._intersection)&&(this.onUpdateWorldPosition(this._intersection.sub(this._cameraPlaneOffset),this._groundPlanePoint,!0),this.onDidUpdate())}}onUpdateWorldPosition(A,e,t){if(this._selected){if(t){const g=ye(this._selected);g.y=A.y,A=g}if(di(this._selected,A),di(this._groundLine,A),this._hasGroundPlane?this._groundLine.scale.y=this._groundDistance:this._groundLine.scale.y=1e3,this._groundLine.visible=this.showGizmo,this._groundMarker.visible=e!==null&&this.showGizmo,e){const g=ye(this._camera).distanceTo(e)*.01;this._groundMarker.scale.set(g,g,g),di(this._groundMarker,e)}}}onUpdateScreenSpacePlane(){if(!this._selected||!this._context)return;const A=this._context.input.getPointerPositionRC(0);A&&(this._raycaster.setFromCamera(A,this._camera),this._cameraPlane.setFromNormalAndCoplanarPoint(this._camera.getWorldDirection(this._cameraPlane.normal),this._worldPosition.setFromMatrixPosition(this._selected.matrixWorld)),this._raycaster.ray.intersectPlane(this._cameraPlane,this._intersection)&&this._selected.parent&&(this._inverseMatrix.copy(this._selected.parent.matrixWorld).invert(),this._cameraPlaneOffset.copy(this._intersection).sub(this._worldPosition.setFromMatrixPosition(this._selected.matrixWorld))))}onUpdateGroundPlane(){if(!this._selected||!this._context)return;const A=ye(this._selected),e=new pC(new m(0,.1,0).add(A),new m(0,-1,0)),t=new Fs;t.ignore=[this._selected];const g=this._context.physics.raycastFromRay(e,t);for(let I=0;I<g.length;I++){const o=g[I];if(!o.face||this.contains(this._selected,o.object))continue;const s=new m(0,1,0);this._groundPlane.setFromNormalAndCoplanarPoint(s,o.point);break}this._hasGroundPlane=!0,this._groundPlane.setFromNormalAndCoplanarPoint(e.direction.multiplyScalar(-1),e.origin),this._raycaster.ray.intersectPlane(this._groundPlane,this._intersection),this._groundDistance=this._intersection.distanceTo(A),this._groundOffset.copy(this._intersection).sub(A)}onDidUpdate(){UI.markDirty(this._selected);for(const A of this._rbs)A.wakeUp(),A.resetForcesAndTorques(),A.setAngularVelocity(0,0,0)}contains(A,e){if(A===e)return!0;if(A.children){for(const t of A.children)if(this.contains(t,e))return!0}return!1}};let uD=iK;B(uD,"geometry",new we().setFromPoints([new m(0,0,0),new m(0,-1,0)]));function _F(i,A,e){console.warn("Adding components on object has been temporarily disabled")}var UO=(i=>(i.File_Spawned="file-spawned",i))(UO||{});class FO{constructor(A,e,t,g,I,o,s,C){B(this,"guid");B(this,"file_name");B(this,"file_hash");B(this,"file_size");B(this,"position");B(this,"seed");B(this,"sender");B(this,"serverUrl");B(this,"parentGuid");B(this,"boundsSize");this.seed=e,this.guid=t,this.file_name=g,this.file_hash=I,this.file_size=o,this.position=s,this.sender=A,this.serverUrl=C}}async function NO(i,A,e){const t=i.name;return t.endsWith(".gltf")||t.endsWith(".glb")?new Promise((g,I)=>{const o=new FileReader;o.readAsArrayBuffer(i),o.onloadend=async s=>{const C=o.result,n=Ww(),a=new CI(n),r=await ms().parseSync(A,C,i.name,a);if(r&&r.scene){const Q=r.scene;if(!Q.guid){const E=new CI(n);Q.guid=E.generateUUID()}e&&CoA(A.connection,i,n,Q,e),_F(),g(r)}}}):(console.warn("Unsupported file type: "+t,i),null)}async function KO(i,A){return new Promise(async(e,t)=>{const g=Ww(),I=new CI(g),o=i.toString(),s=await ms().loadSync(A,o,o,I);s&&s.scene?(s.scene,_F(),e(s)):console.warn("Unsupported file type: "+i.toString())})}Kt.registerCallback(Lg.ContextCreated,i=>{JO(i.context)});function JO(i){i.connection.beginListen("file-spawned",async A=>{if(A.sender!==i.connection.connectionId){console.log("received file event",A),noA(A,i);let e=null;try{e=await GU(A.file_name,A.file_hash,A.file_size,A.serverUrl)}finally{aoA(A)}if(e){const t=new CI(A.seed),g=await ms().parseSync(i,e,A.file_name,t);if(g&&g.scene){const I=g.scene;if(_F(),A.parentGuid){const o=Zd(A.parentGuid,i.scene);o&&"add"in o&&o.add(I)}I.parent||i.scene.add(I),A.position!==null&&I.position.copy(A.position)}}else console.error("download didnt return file")}})}async function CoA(i,A,e,t,g){if(!i.connectionId){console.error("Can not upload file - no connection id");return}if(!t.guid){console.error("Can not upload file - no guid",t,t.guid);return}const I=await HH(A,g);if(!I)return;if(!I.filename){console.error("Can not send upload event - no filename",A.name);return}if(!I.hash){console.error("Can not send upload event - no hash",A.name);return}const o=new FO(i.connectionId,e,t.guid,I.filename,I.hash,A.size,t.position,I.url??g);t.parent&&(o.parentGuid=t.parent.guid),i.send("file-spawned",o)}const xM={};function noA(i,A){const e=new Dt,t=new yA(e,new dt({color:65280})),g=new Uw(t,5592405);if(xM[i.guid]=g,A.scene.add(g),i.parentGuid){const I=Zd(i.parentGuid,A.scene);I&&I.add(g)}i.position&&g.position.copy(i.position)}function aoA(i,A){const e=i.guid,t=xM[e];t&&(delete xM[e],t.removeFromParent())}var roA=Object.defineProperty,BoA=Object.getOwnPropertyDescriptor,OF=(i,A,e,t)=>{for(var g=t>1?void 0:t?BoA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&roA(A,e,g),g};const QoA=oA("debugnet"),LM=class extends mA{constructor(){super(...arguments);B(this,"url",null);B(this,"urlParameterName",null);B(this,"localhost",null)}awake(){QoA&&console.log(this),this.context.connection.registerProvider(this)}getWebsocketUrl(){let A=this.url?LM.GetUrl(this.url,this.localhost):null;if(this.urlParameterName){const I=oA(this.urlParameterName);I&&typeof I=="string"&&(A=I)}if(!A)return null;const t=new RegExp("(((https?)|(?<socket_prefix>wss?))://)?(www.)?(?<url>.+)","gm").exec(A);return t!=null&&t.groups?(t==null?void 0:t.groups.socket_prefix)?A:"wss://"+(t==null?void 0:t.groups.url):null}static GetUrl(A,e){let t=A;const g=LM.IsLocalNetwork()&&e;return g&&(t=e),A!=null&&A.startsWith("/")&&(t=(g?t:window.location.origin)+A),t}static IsLocalNetwork(A=window.location.hostname){return aI(A)}};let jB=LM;OF([y()],jB.prototype,"url",2);OF([y()],jB.prototype,"urlParameterName",2);OF([y()],jB.prototype,"localhost",2);var EoA=Object.defineProperty,hoA=Object.getOwnPropertyDescriptor,qO=(i,A,e,t)=>{for(var g=t>1?void 0:t?hoA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&EoA(A,e,g),g};const xQ=oA("debugdroplistener");class wu extends mA{constructor(){super(...arguments);B(this,"filesBackendUrl");B(this,"localhost");B(this,"onDrag",e=>{e.preventDefault()});B(this,"onDrop",async e=>{if(xQ&&console.log(e),!e.dataTransfer)return;e.preventDefault();const t=e.dataTransfer.items;if(t)for(const g in t){const I=t[g];if(I.kind==="file"){const o=I.getAsFile();if(!o)continue;await this.addFiles(o)}else I.kind==="string"&&I.type=="text/plain"&&I.getAsString(async o=>{xQ&&console.log("dropped url",o);try{const s=new URL(o);if(!s)return;const C=await KO(s,this.context);C&&this.addObject(e,C)}catch{console.log("dropped string is not a valid URL!",o)}})}})}onEnable(){this.filesBackendUrl=jB.GetUrl(this.filesBackendUrl,this.localhost)??this.filesBackendUrl,xQ&&console.log(this,this.filesBackendUrl),this.context.domElement.addEventListener("dragover",this.onDrag),this.context.domElement.addEventListener("drop",this.onDrop)}onDisable(){this.context.domElement.removeEventListener("dragover",this.onDrag),this.context.domElement.removeEventListener("drop",this.onDrop)}async addFiles(...e){if(xQ&&console.log("Add files",e),!!Array.isArray(e)&&e.length)for(const t of e){if(!t)continue;xQ&&console.log("Register file "+t.name+" to",this.filesBackendUrl,t);const g=await NO(t,this.context,this.filesBackendUrl);this.dispatchEvent(new CustomEvent("file-dropped",{detail:t})),g&&this.addObject(void 0,g)}}async addObject(e,t){xQ&&console.log("Dropped",t);const g=t.scene;if(e!==void 0){const I=new Fs;I.setMask(16777215),I.screenPointFromOffset(e.offsetX,e.offsetY);const o=this.context.physics.raycast(I);if(o&&o.length>0)for(const s of o){g.position.copy(s.point);break}}this.gameObject.add(g),this.dispatchEvent(new CustomEvent("object-added",{detail:t}))}}qO([y()],wu.prototype,"filesBackendUrl",2);qO([y()],wu.prototype,"localhost",2);var coA=Object.defineProperty,loA=Object.getOwnPropertyDescriptor,bS=(i,A,e,t)=>{for(var g=t>1?void 0:t?loA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&coA(A,e,g),g};class ZB extends ph{constructor(){super(...arguments);B(this,"parent",null);B(this,"object",null);B(this,"limitCount",10);B(this,"limitInterval",60);B(this,"_currentCount",0);B(this,"_startPosition",null);B(this,"_startQuaternion",null)}awake(){var t,g;if(this.object){if(this.object===this.gameObject){console.error("Can not duplicate self");return}this.object.visible=!1,this._startPosition=((t=this.object.position)==null?void 0:t.clone())??new m(0,0,0),this._startQuaternion=((g=this.object.quaternion)==null?void 0:g.clone())??new LA(0,0,0,1)}const e=eA.getComponentInParent(this.gameObject,xh);e?e.addDragEventListener(RO.SelectStart,(I,o)=>{if(this._currentCount>=this.limitCount){o.attached=null;return}const s=this.handleDuplication(o.selected);s&&(console.assert(s!==o.selected,"Duplicated object is original"),o.attached=s)}):console.warn("Could no find drag controls in parent",this.name),gi.addEventListener(An.SelectStart,(I,o)=>{if(this._currentCount>=this.limitCount){o.grab=null;return}const s=this.handleDuplication(o.selected);s&&(o.grab=s)}),this.cloneLimitIntervalFn()}cloneLimitIntervalFn(){this.destroyed||(this._currentCount>0&&(this._currentCount-=1),setTimeout(()=>{this.cloneLimitIntervalFn()},this.limitInterval/this.limitCount*1e3))}handleDuplication(e){var t;if(this._currentCount>=this.limitCount||!this.object)return null;if(e===this.gameObject||this.handleMultiObject(e)){if(this.object===this.gameObject)return null;this.object.visible=!0,this._startPosition&&this.object.position.copy(this._startPosition),this._startQuaternion&&this.object.quaternion.copy(this._startQuaternion);const g=new cC;this.parent||(this.parent=this.gameObject.parent),this.parent&&(g.parent=this.parent.guid??((t=this.parent.userData)==null?void 0:t.guid),g.keepWorldPosition=!0),g.position=this.worldPosition,g.rotation=this.worldQuaternion,g.context=this.context,this._currentCount+=1;const I=eA.instantiateSynced(this.object,g);return console.assert(I!==this.object,"Duplicated object is original"),this.object.visible=!1,this._startPosition&&this.object.position.clone().copy(this._startPosition),this._startQuaternion&&this.object.quaternion.clone().copy(this._startQuaternion),I}return null}handleMultiObject(e){return this.gameObject.type==="Group"||this.gameObject.type==="Object3D"?this.isInChildren(this.gameObject,e):!1}isInChildren(e,t){if(!e)return!1;if(e===t)return!0;if(e.children){for(let g of e.children)if(this.isInChildren(g,t))return!0}return!1}}bS([y(bA)],ZB.prototype,"parent",2);bS([y(bA)],ZB.prototype,"object",2);bS([y()],ZB.prototype,"limitCount",2);bS([y()],ZB.prototype,"limitInterval",2);var gE=(i=>(i[i.PointerEnter=0]="PointerEnter",i[i.PointerExit=1]="PointerExit",i[i.PointerDown=2]="PointerDown",i[i.PointerUp=3]="PointerUp",i[i.PointerClick=4]="PointerClick",i[i.Drag=5]="Drag",i[i.Drop=6]="Drop",i[i.Scroll=7]="Scroll",i[i.UpdateSelected=8]="UpdateSelected",i[i.Select=9]="Select",i[i.Deselect=10]="Deselect",i[i.Move=11]="Move",i[i.InitializePotentialDrag=12]="InitializePotentialDrag",i[i.BeginDrag=13]="BeginDrag",i[i.EndDrag=14]="EndDrag",i[i.Submit=15]="Submit",i[i.Cancel=16]="Cancel",i))(gE||{}),doA=Object.defineProperty,uoA=Object.getOwnPropertyDescriptor,PF=(i,A,e,t)=>{for(var g=t>1?void 0:t?uoA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&doA(A,e,g),g};class WF{constructor(){B(this,"eventID");B(this,"callback")}}PF([y()],WF.prototype,"eventID",2);PF([y(FI)],WF.prototype,"callback",2);class xS extends mA{constructor(){super(...arguments);B(this,"triggers")}invoke(e){if(this.triggers)for(const t of this.triggers)t.eventID===e&&t.callback.invoke()}onPointerClick(e){this.invoke(gE.PointerClick)}onPointerEnter(e){this.invoke(gE.PointerEnter)}onPointerExit(e){this.invoke(gE.PointerExit)}onPointerDown(e){this.invoke(gE.PointerDown)}onPointerUp(e){this.invoke(gE.PointerUp)}}PF([y(WF)],xS.prototype,"triggers",2);var poA=Object.defineProperty,foA=Object.getOwnPropertyDescriptor,VF=(i,A,e,t)=>{for(var g=t>1?void 0:t?foA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&poA(A,e,g),g};class zF extends mA{constructor(){super(...arguments);B(this,"connectedBody");B(this,"_rigidBody",null)}get rigidBody(){return this._rigidBody}onEnable(){this._rigidBody||(this._rigidBody=this.gameObject.getComponent(Xt)),this.rigidBody&&this.connectedBody&&this.startCoroutine(this.create())}*create(){yield,this.rigidBody&&this.connectedBody&&this.createJoint(this.rigidBody,this.connectedBody)}}VF([y(Xt)],zF.prototype,"connectedBody",2);class jF extends zF{createJoint(A,e){var t;(t=this.context.physics.engine)==null||t.addFixedJoint(A,e)}}class Su extends zF{constructor(){super(...arguments);B(this,"anchor");B(this,"axis")}createJoint(e,t){var g;this.axis&&this.anchor&&((g=this.context.physics.engine)==null||g.addHingeJoint(e,t,this.anchor,this.axis))}}VF([y(m)],Su.prototype,"anchor",2);VF([y(m)],Su.prototype,"axis",2);const DoA={type:"change"};let yoA=class extends Vi{constructor(A,e){super(),this.object=A,this.domElement=e,this.enabled=!0,this.movementSpeed=1,this.rollSpeed=.005,this.dragToLook=!1,this.autoForward=!1;const t=this,g=1e-6,I=new LA,o=new m;this.tmpQuaternion=new LA,this.status=0,this.moveState={up:0,down:0,left:0,right:0,forward:0,back:0,pitchUp:0,pitchDown:0,yawLeft:0,yawRight:0,rollLeft:0,rollRight:0},this.moveVector=new m(0,0,0),this.rotationVector=new m(0,0,0),this.keydown=function(E){if(!(E.altKey||this.enabled===!1)){switch(E.code){case"ShiftLeft":case"ShiftRight":this.movementSpeedMultiplier=.1;break;case"KeyW":this.moveState.forward=1;break;case"KeyS":this.moveState.back=1;break;case"KeyA":this.moveState.left=1;break;case"KeyD":this.moveState.right=1;break;case"KeyR":this.moveState.up=1;break;case"KeyF":this.moveState.down=1;break;case"ArrowUp":this.moveState.pitchUp=1;break;case"ArrowDown":this.moveState.pitchDown=1;break;case"ArrowLeft":this.moveState.yawLeft=1;break;case"ArrowRight":this.moveState.yawRight=1;break;case"KeyQ":this.moveState.rollLeft=1;break;case"KeyE":this.moveState.rollRight=1;break}this.updateMovementVector(),this.updateRotationVector()}},this.keyup=function(E){if(this.enabled!==!1){switch(E.code){case"ShiftLeft":case"ShiftRight":this.movementSpeedMultiplier=1;break;case"KeyW":this.moveState.forward=0;break;case"KeyS":this.moveState.back=0;break;case"KeyA":this.moveState.left=0;break;case"KeyD":this.moveState.right=0;break;case"KeyR":this.moveState.up=0;break;case"KeyF":this.moveState.down=0;break;case"ArrowUp":this.moveState.pitchUp=0;break;case"ArrowDown":this.moveState.pitchDown=0;break;case"ArrowLeft":this.moveState.yawLeft=0;break;case"ArrowRight":this.moveState.yawRight=0;break;case"KeyQ":this.moveState.rollLeft=0;break;case"KeyE":this.moveState.rollRight=0;break}this.updateMovementVector(),this.updateRotationVector()}},this.pointerdown=function(E){if(this.enabled!==!1)if(this.dragToLook)this.status++;else{switch(E.button){case 0:this.moveState.forward=1;break;case 2:this.moveState.back=1;break}this.updateMovementVector()}},this.pointermove=function(E){if(this.enabled!==!1&&(!this.dragToLook||this.status>0)){const h=this.getContainerDimensions(),l=h.size[0]/2,d=h.size[1]/2;this.moveState.yawLeft=-(E.pageX-h.offset[0]-l)/l,this.moveState.pitchDown=(E.pageY-h.offset[1]-d)/d,this.updateRotationVector()}},this.pointerup=function(E){if(this.enabled!==!1){if(this.dragToLook)this.status--,this.moveState.yawLeft=this.moveState.pitchDown=0;else{switch(E.button){case 0:this.moveState.forward=0;break;case 2:this.moveState.back=0;break}this.updateMovementVector()}this.updateRotationVector()}},this.contextMenu=function(E){this.enabled!==!1&&E.preventDefault()},this.update=function(E){if(this.enabled===!1)return;const h=E*t.movementSpeed,l=E*t.rollSpeed;t.object.translateX(t.moveVector.x*h),t.object.translateY(t.moveVector.y*h),t.object.translateZ(t.moveVector.z*h),t.tmpQuaternion.set(t.rotationVector.x*l,t.rotationVector.y*l,t.rotationVector.z*l,1).normalize(),t.object.quaternion.multiply(t.tmpQuaternion),(o.distanceToSquared(t.object.position)>g||8*(1-I.dot(t.object.quaternion))>g)&&(t.dispatchEvent(DoA),I.copy(t.object.quaternion),o.copy(t.object.position))},this.updateMovementVector=function(){const E=this.moveState.forward||this.autoForward&&!this.moveState.back?1:0;this.moveVector.x=-this.moveState.left+this.moveState.right,this.moveVector.y=-this.moveState.down+this.moveState.up,this.moveVector.z=-E+this.moveState.back},this.updateRotationVector=function(){this.rotationVector.x=-this.moveState.pitchDown+this.moveState.pitchUp,this.rotationVector.y=-this.moveState.yawRight+this.moveState.yawLeft,this.rotationVector.z=-this.moveState.rollRight+this.moveState.rollLeft},this.getContainerDimensions=function(){return this.domElement!=document?{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}:{size:[window.innerWidth,window.innerHeight],offset:[0,0]}},this.dispose=function(){this.domElement.removeEventListener("contextmenu",s),this.domElement.removeEventListener("pointerdown",n),this.domElement.removeEventListener("pointermove",C),this.domElement.removeEventListener("pointerup",a),window.removeEventListener("keydown",r),window.removeEventListener("keyup",Q)};const s=this.contextMenu.bind(this),C=this.pointermove.bind(this),n=this.pointerdown.bind(this),a=this.pointerup.bind(this),r=this.keydown.bind(this),Q=this.keyup.bind(this);this.domElement.addEventListener("contextmenu",s),this.domElement.addEventListener("pointerdown",n),this.domElement.addEventListener("pointermove",C),this.domElement.addEventListener("pointerup",a),window.addEventListener("keydown",r),window.addEventListener("keyup",Q),this.updateMovementVector(),this.updateRotationVector()}};class ZF extends mA{constructor(){super(...arguments);B(this,"_controls",null)}onEnable(){var t;const e=(t=eA.getComponent(this.gameObject,Ot))==null?void 0:t.cam;this._controls=new yoA(e,this.context.renderer.domElement),this._controls.rollSpeed=.5,this._controls.movementSpeed=3,this._controls.dragToLook=!0}onDisable(){var e;(e=this._controls)==null||e.dispose(),this._controls=null}update(){this._controls&&this._controls.update(this.context.time.deltaTime)}}var woA=Object.defineProperty,SoA=Object.getOwnPropertyDescriptor,XF=(i,A,e,t)=>{for(var g=t>1?void 0:t?SoA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&woA(A,e,g),g};class Lh extends mA{constructor(){super(...arguments);B(this,"_fog")}get fog(){return this._fog||(this._fog=new FR(0,0,50)),this._fog}get mode(){return 1}set near(e){this.fog.near=e}get near(){return this.fog.near}set far(e){this.fog.far=e}get far(){return this.fog.far}set color(e){this.fog.color.copy(e)}get color(){return this.fog.color}onEnable(){this.scene.fog=this.fog}onDisable(){this.scene.fog===this._fog&&(this.scene.fog=null)}}XF([y()],Lh.prototype,"near",1);XF([y()],Lh.prototype,"far",1);XF([y(DA)],Lh.prototype,"color",1);let Cf,nm,LQ,nf;function am(i,A=1/0,e=null){nm||(nm=new Co(2,2,1,1)),LQ||(LQ=new be({uniforms:{blitTexture:new RA(i)},vertexShader:`
5021
+ `,this.context.appendHTMLElement(t);const g=tm;tm&&console.log("ARSupported?",Wc,"VRSupported?",Vc),(g||this.createARButton&&this.enableAR&&Wc)&&(A=Ti.createARButton(this),this._arButton=A,t.appendChild(A)),(g||this.createVRButton&&this.enableVR&&Vc)&&(e=Ti.createVRButton(this),this._vrButton=e,t.appendChild(e)),setTimeout(()=>{Ti.resetButtonStyles(e),Ti.resetButtonStyles(A)},1e3)}get TransformOrientation(){return this._transformOrientation}get HeadPose(){return this._currentHeadPose}onBeforeRender(A){var t;if(!A)return;const e=this.context.renderer.xr.getSession();if(e){const g=A.getViewerPose(this.context.renderer.xr.getReferenceSpace());if(!g)return;this._currentHeadPose=g;const I=g==null?void 0:g.transform;I&&this._transformOrientation.set(I.orientation.x,I.orientation.y,I.orientation.z,I.orientation.w),Ti._isInXr===!1&&e&&this.onEnterXR(e,A);for(const o of this.controllers)o.onUpdate(e);this._isInAR&&((t=this.webAR)==null||t.onUpdate(e,A))}Ti.events.dispatchEvent({type:"xrUpdate",frame:A,xr:this.context.renderer.xr,rig:this.rig})}onClickedARButton(){this._isInAR||(this._requestedAR=!0,this._requestedVR=!1,this.captureStateBeforeXR())}onClickedVRButton(){if(!this._isInVR){if(this._requestedVR){this.onExitXR(null);return}this._requestedAR=!1,this._requestedVR=!0,this.captureStateBeforeXR(),this.ensureRig();for(let A=0;A<2;A++)gi.Create(this,A,this.gameObject,mE.PhysicalDevice);Ti.events.dispatchEvent({type:"requestVRSession"})}}captureStateBeforeXR(){this.context.mainCamera&&(this._originalCameraPosition.copy(ye(this.context.mainCamera)),this._originalCameraRotation.copy(Oi(this.context.mainCamera)),this._originalCameraParent=this.context.mainCamera.parent),this.Rig&&(this._originalXRRigParent=this.Rig.parent,this._originalXRRigPosition.copy(this.Rig.position),this._originalXRRigRotation.copy(this.Rig.quaternion))}ensureRig(){if(!this.rig){const A=eA.findObjectOfType(DS,this.context);A?(this.rig=A.gameObject,this.rig.rotateY(Math.PI)):(this.rig=new To,this.rig.rotateY(Math.PI),this.rig.name="XRRig",this.context.scene.add(this.rig))}}onEnterXR(A,e){var o,s;console.log("[XR] session begin",A,e),Ti._isInXr=!0,this.ensureRig();const t=this.context.renderer.xr.getReferenceSpace();if(t&&this.rig){const C=e.getViewerPose(t),n=C==null?void 0:C.transform.orientation;if(n){const a=new LA(n.x,n.y,n.z,n.w),r=new ug().setFromQuaternion(a);this.rig.rotateY(r.y)}}const g=this.context.renderer.xr;if(this.context.mainCamera){const C=g.getCamera();tm&&console.log("WebXRCamera",C);const n=(o=this.context.mainCameraComponent)==null?void 0:o.cullingMask;if(C&&n!==void 0){for(const a of C.cameras)a.layers.mask=n;C.layers.mask=n}else if(C){for(const a of C.cameras)a.layers.enableAll();C.layers.enableAll()}this.rig.add(this.context.mainCamera),this._requestedAR&&this.context.scene.add(this.rig)}const I=this._requestedAR?Gi.AR:Gi.VR;switch(Yo.Global.Set(I),I){case Gi.AR:this.context.xrSessionMode=id.ImmersiveAR,this._isInAR=!0,(s=this.webAR)==null||s.onBegin(A);break;case Gi.VR:this.context.xrSessionMode=id.ImmersiveVR,this._isInVR=!0,this.onEnterVR(A);break}A.addEventListener("end",()=>{console.log("[XR] session end"),Ti._isInXr=!1,this.onExitXR(A)}),this.onEnterXR_HandleMirrorWindow(A),Ti.events.dispatchEvent({type:"xrStarted",session:A})}onExitXR(A){var t,g,I,o;const e=this._isInAR;A&&(this._isInAR?(t=this.webAR)==null||t.onEnd(A):(g=this.context.mainCameraComponent)==null||g.applyClearFlagsIfIsActiveCamera()),this._isInAR=!1,this._isInVR=!1,this._requestedAR=!1,this._requestedVR=!1,this.context.xrSessionMode=void 0,this.xrMirrorWindow&&(this.xrMirrorWindow.close(),this.xrMirrorWindow=null),this.destroyControllers(),this.context.mainCamera&&((I=this._originalCameraParent)==null||I.add(this.context.mainCamera),di(this.context.mainCamera,this._originalCameraPosition),qI(this.context.mainCamera,this._originalCameraRotation),this.context.mainCamera.scale.set(1,1,1)),e&&((o=this._originalXRRigParent)==null||o.add(this.rig),this.rig.position.copy(this._originalXRRigPosition),this.rig.quaternion.copy(this._originalXRRigRotation)),Yo.Global.Set(Gi.Browser|Gi.ThirdPerson),Ti.events.dispatchEvent({type:"xrStopped",session:A})}onEnterVR(A){}destroyControllers(){var A;for(let e=this.controllers.length-1;e>=0;e-=1)(A=this.controllers[e])==null||A.destroy();this.controllers.length=0}onEnterXR_HandleMirrorWindow(A){oA("mirror")&&setTimeout(()=>{if(!Ti.IsInWebXR)return;const e=new URL(window.location.href);Ll(e.searchParams,Qy,1),Ll(e.searchParams,"isMirror",1);const t=e.toString();this.xrMirrorWindow=window.open(t,"webxr sync","popup=yes"),this.xrMirrorWindow&&(this.xrMirrorWindow.onload=()=>{this.xrMirrorWindow&&(this.xrMirrorWindow.onbeforeunload=()=>{Ti.IsInWebXR&&A.end()})})},1e3)}},B(XQ,"_isInXr",!1),B(XQ,"events",new Vi),B(XQ,"_optionalFeatures_VR",["local-floor","bounded-floor","hand-tracking","high-fixed-foveation-level","layers"]),B(XQ,"_optionalFeatures_AR",["anchors","local-floor","hand-tracking","layers"]),XQ);let Se=Ti;Sh([y()],Se.prototype,"enableVR",2);Sh([y()],Se.prototype,"enableAR",2);Sh([y(og)],Se.prototype,"defaultAvatar",2);Sh([y()],Se.prototype,"handModelPath",2);Sh([y()],Se.prototype,"createVRButton",2);Sh([y()],Se.prototype,"createARButton",2);const lE=class{constructor(A){B(this,"_webxr");B(this,"reticle",null);B(this,"reticleParent",null);B(this,"hitTestSource",null);B(this,"reticleActive",!0);B(this,"previousBackground",null);B(this,"previousEnvironment",null);B(this,"sessionRoot",null);B(this,"_previousParent",null);B(this,"arDomOverlay",null);B(this,"arOverlayElement",null);B(this,"noHitTestAvailable",!1);B(this,"didPlaceARSessionRoot",!1);this._webxr=A}get webxr(){return this._webxr}get context(){return this.webxr.context}getAROverlayContainer(){this.arDomOverlay=this.webxr.context.domElement;const A=this.arDomOverlay;return A.getAROverlayContainer?this.arOverlayElement=A.getAROverlayContainer():this.arOverlayElement=this.arDomOverlay,this.arOverlayElement}setReticleActive(A){this.reticleActive=A}async onBegin(A){var o,s,C,n;const e=this.webxr.context;this.reticleActive=!0,this.didPlaceARSessionRoot=!1,this.getAROverlayContainer();const t=(o=navigator.userAgent)!=null&&o.includes("OculusBrowser")?mE.PhysicalDevice:mE.Touch,g=t===mE.Touch?4:2;for(let a=0;a<g;a++)gi.Create(this.webxr,a,this.webxr.gameObject,t);if((!this.sessionRoot||this.sessionRoot.destroyed||!this.sessionRoot.activeAndEnabled)&&(this.sessionRoot=eA.findObjectOfType(lC,e)),!this.sessionRoot){const a=this.webxr.gameObject;this.sessionRoot=eA.addNewComponent(a,lC),console.warn("WebAR: No ARSessionRoot found, creating one automatically on the WebXR object")}this.previousBackground=e.scene.background,this.previousEnvironment=e.scene.environment,e.scene.background=null,A.requestReferenceSpace("viewer").then(a=>{var r,Q;(Q=(r=A.requestHitTestSource)==null?void 0:r.call(A,{space:a}))==null||Q.then(E=>{this.hitTestSource=E}).catch(E=>{this.noHitTestAvailable=!0,console.warn("WebXR: Hit test not supported",E)})}),!this.reticle&&this.sessionRoot&&(this.reticle=new yA(new Hd(.07,.09,32).rotateX(-Math.PI/2),new dt),this.reticle.name="AR Placement reticle",this.reticle.matrixAutoUpdate=!1,this.reticle.visible=!1,this.reticleParent=new bA,this.reticleParent.name="AR Reticle Parent",this.reticleParent.matrixAutoUpdate=!1,this.reticleParent.add(this.reticle),this.webxr.scene?(this.context.scene.add(this.reticleParent),this.context.scene.visible=!0):console.warn("Could not found WebXR Rig")),this._previousParent=this.webxr.gameObject,lE.tempWebXRObject||(lE.tempWebXRObject=new bA),this.context.scene.add(lE.tempWebXRObject),eA.addComponent(lE.tempWebXRObject,this.webxr),this.sessionRoot?(this.sessionRoot.webAR=this,(s=this.sessionRoot)==null||s.onBegin(A)):console.warn("No WebARSessionRoot found in scene");const I=this.context.domElement;(C=I==null?void 0:I.onEnterAR)==null||C.call(I,A,this.arOverlayElement),(n=this.context.mainCameraComponent)==null||n.applyClearFlagsIfIsActiveCamera()}onEnd(A){var g,I;this._previousParent&&(eA.addComponent(this._previousParent,this.webxr),this._previousParent=null),this.hitTestSource=null;const e=this.webxr.context;e.scene.background=this.previousBackground,e.scene.environment=this.previousEnvironment,this.sessionRoot&&this.sessionRoot.onEnd(this.webxr.Rig,A);const t=this.context.domElement;(g=t.onExitAR)==null||g.call(t,A),(I=this.context.mainCameraComponent)==null||I.applyClearFlagsIfIsActiveCamera()}onUpdate(A,e){var g,I;if(this.noHitTestAvailable===!0){if(this.reticle&&(this.reticle.visible=!1),!this.didPlaceARSessionRoot){this.didPlaceARSessionRoot=!0;const o=this.webxr.Rig,s=wgA.clone();(g=this.sessionRoot)==null||g.placeAt(o,s)}return}if(!this.hitTestSource)return;const t=e.getHitTestResults(this.hitTestSource);if(t.length){const o=t[0],s=this.webxr.context.renderer.xr.getReferenceSpace();if(s){const C=o.getPose(s);if(this.sessionRoot){const n=this.sessionRoot.onUpdate(this.webxr.Rig,A,C);this.didPlaceARSessionRoot=n}if(this.reticle&&(this.reticle.visible=this.reticleActive,this.reticleActive&&C)){const n=C.transform.matrix;this.reticle.matrix.fromArray(n),this.webxr.Rig&&this.reticle.matrix.premultiply(this.webxr.Rig.matrix)}}}else(I=this.sessionRoot)==null||I.onUpdate(this.webxr.Rig,A,null),this.reticle&&(this.reticle.visible=!1)}};let uB=lE;B(uB,"tempWebXRObject");const wgA=new qA().identity().makeTranslation(0,0,0);class dn{constructor(A,e){B(this,"used",!1);B(this,"inputSource");B(this,"object");B(this,"pointerId");B(this,"isDown");B(this,"isUp");B(this,"isPressed");B(this,"isClicked");B(this,"input");B(this,"event");this.event=e,this.input=A}use(){this.used=!0,this.pointerId!==void 0&&this.input.setPointerUsed(this.pointerId)}stopPropagation(){var A;(A=this.event)==null||A.stopImmediatePropagation()}Use(){this.use()}StopPropagation(){var A;(A=this.event)==null||A.stopImmediatePropagation()}clone(){const A=new dn(this.input,this.event);return Object.assign(A,this),A}}class kh extends mA{awake(){II.createIfNoneExists(this.context)}onEnable(){var A;(A=II.get(this.context))==null||A.register(this)}onDisable(){var A;(A=II.get(this.context))==null||A.unregister(this)}performRaycast(A=null){return null}}class Un extends kh{constructor(){super(...arguments);B(this,"targets",null);B(this,"raycastHits",[])}start(){this.targets=[this.gameObject]}performRaycast(e=null){return this.targets?(e??(e=new Fs),e.targets=this.targets,e.results=this.raycastHits,this.context.physics.raycast(e)):null}}class SF extends Un{}const zc=oA("debugeventsystem");var qM=(i=>(i.BeforeHandleInput="BeforeHandleInput",i.AfterHandleInput="AfterHandleInput",i))(qM||{});const Vs=class extends mA{constructor(){super();B(this,"raycaster",[]);B(this,"_selectStartFn");B(this,"_selectEndFn");B(this,"_selectUpdateFn");B(this,"_handleEventFn");B(this,"lastPointerEvent",null);B(this,"objectsHoveredThisFrame",[]);B(this,"objectsHoveredLastFrame",[]);B(this,"raisedPointerDownEvents",[]);B(this,"raisedPointerDownObjects",[]);B(this,"_didMove",!1);B(this,"_tempComponentsArray",[]);B(this,"_sortedHits",[]);B(this,"_sortingBuffer",[]);B(this,"_noDepthTestingResults",[]);B(this,"handleEventsArray",[]);B(this,"out",{});B(this,"currentActiveMeshUIComponents",[]);Vs.systems.push(this)}static createIfNoneExists(e){this.didSearchEventSystem||(this.didSearchEventSystem=!0,Vs.systems.length<=0&&Vs.systems.push(...eA.findObjectsOfType(Vs,e)));for(const g of Vs.systems)if(g.context===e)return;const t=new bA;eA.addNewComponent(t,Vs),e.scene.add(t)}static get systems(){const e=Je.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){en.update(e,t)}static markUIDirty(e){en.markDirty()}get hasActiveUI(){return this.currentActiveMeshUIComponents.length>0}get isHoveringObjects(){return this.objectsHoveredThisFrame.length>0}onDestroy(){Vs.systems.splice(Vs.systems.indexOf(this),1)}start(){if(this.raycaster.length<=0&&!eA.findObjectOfType(kh,this.context)){const t=eA.addNewComponent(this.context.scene,Un);this.raycaster.push(t),Ci()&&console.warn("Added an ObjectRaycaster to the scene because no raycaster was found",this)}}register(e){var t;e&&this.raycaster&&!this.raycaster.includes(e)&&((t=this.raycaster)==null||t.push(e))}unregister(e){var g,I;const t=(g=this.raycaster)==null?void 0:g.indexOf(e);t!==void 0&&t!==-1&&((I=this.raycaster)==null||I.splice(t,1))}onEnable(){const e=new Map;this._selectStartFn??(this._selectStartFn=(g,I)=>{if(!I.grab)return;en.resetLastSelected();const o=new dn(this.context.input);o.inputSource=g,o.pointerId=0,o.isDown=g.selectionDown,o.isUp=g.selectionUp,o.isPressed=g.selectionPressed,o.isClicked=!1,e.set(g,I.grab),I.grab&&!this.handleEvents(I.grab,o)&&(I.grab=null)}),this._selectEndFn??(this._selectEndFn=(g,I)=>{var C;if(!I.grab)return;const o=new dn(this.context.input);o.inputSource=g,o.pointerId=0,o.isDown=g.selectionDown,o.isUp=g.selectionUp,o.isPressed=g.selectionPressed,o.isClicked=g.selectionClick,this.handleEvents(I.grab,o);const s=e.get(g);if(e.set(g,null),s)for(let n=0;n<this.raisedPointerDownEvents.length;n++){const a=this.raisedPointerDownEvents[n];this.raisedPointerDownObjects[n]===s&&a&&((C=a.onPointerUp)==null||C.call(a,o),this.raisedPointerDownEvents.splice(n,1),this.raisedPointerDownObjects.splice(n,1),n--)}});const t=new Fs;this._selectUpdateFn??(this._selectUpdateFn=g=>{t.ray=g.getRay();const I=this.performRaycast(t);if(!I)return;const o=new dn(this.context.input);o.inputSource=g,this.handleIntersections(I,o)}),gi.addEventListener(An.SelectStart,this._selectStartFn),gi.addEventListener(An.SelectEnd,this._selectEndFn),gi.addEventListener(An.Update,this._selectUpdateFn),this._handleEventFn??(this._handleEventFn=this.onHandleEvents.bind(this)),this.context.pre_update_callbacks.push(this._handleEventFn)}onDisable(){gi.removeEventListener(An.SelectStart,this._selectStartFn),gi.removeEventListener(An.SelectEnd,this._selectEndFn),gi.removeEventListener(An.Update,this._selectUpdateFn),this.context.pre_update_callbacks.splice(this.context.pre_update_callbacks.indexOf(this._handleEventFn),1)}onHandleEvents(){if(this.objectsHoveredThisFrame.length=0,this.resetMeshUIStates(),Se.IsInWebXR||this.context.input.isKeyPressed("AltLeft")||this.context.input.isKeyPressed("AltRight"))return;if(!this._didMove){const s=this.context.input.getPointerPositionRC(0);if(s&&s.x===0&&s.y===0)return;this._didMove=!0}let e=0;for(const s of this.context.input.foreachPointerId()){const C=this.context.input.getPointerDown(s),n=this.context.input.getPointerUp(s);if(C||n){e=s;break}}const t=this.context.input.getPointerEvent(e),g=new dn(this.context.input,t);g.inputSource=this.context.input,g.pointerId=e,g.isClicked=this.context.input.getPointerClicked(e),g.isDown=this.context.input.getPointerDown(e),g.isUp=this.context.input.getPointerUp(e),g.isPressed=this.context.input.getPointerPressed(e),zc&&g.isClicked&&console.log("CLICK",e);const I=this.performRaycast(null);if(!I)return;this.lastPointerEvent=g;const o={sender:this,args:g,hasActiveUI:this.currentActiveMeshUIComponents.length>0};zc&&g.isClicked&&Mi("EventSystem: "+g.pointerId+" - "+this.context.time.frame+" - Up:"+g.isUp+", Down:"+g.isDown),this.dispatchEvent(new CustomEvent("BeforeHandleInput",{detail:o})),this.handleIntersections(I,g),this.dispatchEvent(new CustomEvent("AfterHandleInput",{detail:o}))}onBeforeRender(){if(this.lastPointerEvent)this.lastPointerEvent.used=!1;else return;if(this.lastPointerEvent.isUp){for(const t of this.raisedPointerDownEvents)t.onPointerUp&&t.onPointerUp(this.lastPointerEvent);this.raisedPointerDownEvents.length=0,this.raisedPointerDownObjects.length=0}for(const t of this.objectsHoveredLastFrame)if(this.objectsHoveredThisFrame.indexOf(t)<0){this._tempComponentsArray.length=0;const g=eA.getComponentsInParent(t,mA,this._tempComponentsArray);this.lastPointerEvent.object=t;for(let I=0;I<g.length;I++){const o=g[I];if(!o.gameObject||o.destroyed)continue;const s=o;s.onPointerExit&&s.onPointerExit(this.lastPointerEvent)}}const e=this.objectsHoveredLastFrame;this.objectsHoveredLastFrame=this.objectsHoveredThisFrame,this.objectsHoveredThisFrame=e}performRaycast(e){if(!this.raycaster)return null;this._sortedHits.length=0;for(const t of this.raycaster){if(!t.activeAndEnabled)continue;const g=t.performRaycast(e);g&&g.length>0&&this._sortedHits.push(...g)}return this._sortedHits.sort((t,g)=>t.distance-g.distance),this._sortedHits}handleIntersections(e,t){if(!e||e.length<=0)return!1;e=this.sortCandidates(e);for(const g of e){const{object:I}=g;if(this.handleEvents(I,t))return!0}return!1}sortCandidates(e){this._sortingBuffer.length=0,this._noDepthTestingResults.length=0;for(let t=0;t<e.length;t++){const g=e[t],I=g.object;if(I.material&&I.material.depthTest===!1){this._noDepthTestingResults.push(g);continue}this._sortingBuffer.push(g)}for(const t of this._sortingBuffer)this._noDepthTestingResults.push(t);return this._noDepthTestingResults}handleEvents(e,t){if(!this.testIsVisible(e))return t.isClicked&&zc&&console.log("not allowed",e),!1;const g=e;t.object=e,this.lastPointerEvent=t;const I=e.parent;let o=!1;const s=t.isClicked??!1;let C=null;if(I&&I.isUI){const n=(t.isPressed||t.isClicked)??!1;if(I[AC]){const a=I[AC].gameObject;if(a){if(!jE.isInteractable(a,this.out))return!1;C=this.out.canvasGroup??null,this.handleMeshUIIntersection(e,n),e=a,o=!0}}if(!o&&this.handleMeshUiObjectWithoutShadowDom(I,n))return!0}if(s&&zc&&console.log(this.context.time.frame,e),this.objectsHoveredThisFrame.push(e),C===null||C.interactable){const n=this.objectsHoveredLastFrame.indexOf(e)>=0;this.handleEventsArray.length=0;const a=eA.getComponentsInParent(e,mA,this.handleEventsArray);for(let r=0;r<a.length;r++){if(t.used)return!0;if(a[r].destroyed)continue;const Q=a[r];if(Q.interactable!==!1){if(Q.onPointerEnter&&(n||Q.onPointerEnter(t)),Q.onPointerMove&&Q.onPointerMove(t),t.isDown&&Q.onPointerDown&&!this.raisedPointerDownEvents.includes(Q)&&(Q.onPointerDown(t),this.raisedPointerDownEvents.push(Q),this.raisedPointerDownObjects.push(g)),t.isUp&&Q.onPointerUp){const E=this.raisedPointerDownEvents.indexOf(Q);E!==-1&&this.raisedPointerDownEvents.splice(E,1),Q.onPointerUp(t)}t.isClicked&&Q.onPointerClick&&Q.onPointerClick(t)}}}return!0}handleMeshUiObjectWithoutShadowDom(e,t){return!e||!e.isUI?!0:this.handleMeshUIIntersection(e,t)}handleMeshUIIntersection(e,t){const g=en.updateState(e,t);return g&&this.currentActiveMeshUIComponents.push(g),g!==null}resetMeshUIStates(){if(this.context.input.getPointerPressedCount()>0&&en.resetLastSelected(),!(!this.currentActiveMeshUIComponents||this.currentActiveMeshUIComponents.length<=0)){for(let e=0;e<this.currentActiveMeshUIComponents.length;e++){const t=this.currentActiveMeshUIComponents[e];en.resetState(t)}this.currentActiveMeshUIComponents.length=0}}testIsVisible(e){return e?eA.isActiveSelf(e)?this.testIsVisible(e.parent):!1:!0}};let II=Vs;B(II,"_eventSystemMap",new Map),B(II,"didSearchEventSystem",!1);class en{static markDirty(){this.needsUpdate=!0}static update(A,e){const t=e.time.frameCount;for(const g of this.lastUpdateFrame)if(g.context===e){if(t===g.frame)return;g.frame=t;let I=this.needsUpdate||t<1;g.nextUpdate===e.time.frameCount&&(I=!0),I&&(zc&&console.log("Update threemeshui"),this.needsUpdate=!1,A.update());return}this.lastUpdateFrame=[{context:e,frame:t,nextUpdate:t}],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}}B(en,"lastSelected",null),B(en,"lastUpdateFrame",[]),B(en,"needsUpdate",!1);const lD=Symbol("cameraController");function SgA(i){return i[lD]}function Ob(i,A,e){e?i[lD]=A:i[lD]===A&&(i[lD]=null)}var kgA=Object.defineProperty,mgA=Object.getOwnPropertyDescriptor,GgA=(i,A,e,t)=>{for(var g=t>1?void 0:t?mgA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&kgA(A,e,g),g};const $p=oA("freecam"),im=oA("debugcamerafit"),MgA={LEFT:"",UP:"",RIGHT:"",BOTTOM:""};let gm;class Tn extends mA{constructor(){super(...arguments);B(this,"autoRotate",!1);B(this,"autoRotateSpeed",1);B(this,"enableKeys",!0);B(this,"enableDamping",!0);B(this,"dampingFactor",.1);B(this,"enableZoom",!0);B(this,"minZoom",0);B(this,"maxZoom",1/0);B(this,"enablePan",!0);B(this,"lookAtConstraint",null);B(this,"lookAtConstraint01",1);B(this,"middleClickToFocus",!0);B(this,"doubleClickToFocus",!0);B(this,"useSlerp",!0);B(this,"debugLog",!1);B(this,"targetLerpSpeed",5);B(this,"_lookTargetPosition");B(this,"_controls",null);B(this,"_cameraObject",null);B(this,"_lerpToTargetPosition",!1);B(this,"_lerpCameraToTarget",!1);B(this,"_cameraTargetPosition",null);B(this,"_inputs",0);B(this,"_enableTime",0);B(this,"_startedListeningToKeyEvents",!1);B(this,"_eventSystem");B(this,"_afterHandleInputFn");B(this,"_camera",null);B(this,"_syncedTransform");B(this,"targetElement",null);B(this,"onControlsChangeStarted",()=>{this._syncedTransform&&this._syncedTransform.requestOwnership()});B(this,"_shouldDisable",!1);B(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)}awake(){this._lookTargetPosition=new m,this._startedListeningToKeyEvents=!1}start(){if(this._controls){const e=eA.getComponent(this.gameObject,Ot);if(e&&!this.setFromTargetPosition()){this.debugLog&&console.log("NO TARGET");const g=ye(e.cam).length(),I=new m(0,0,-g).applyMatrix4(e.cam.matrixWorld);this.setTarget(I,!0)}}this.startCoroutine(this.startRaycastDelayed()),this._eventSystem=II.get(this.context)??void 0,this._eventSystem&&(this._afterHandleInputFn=this.afterHandleInput.bind(this),this._eventSystem.addEventListener(qM.AfterHandleInput,this._afterHandleInputFn))}onDestroy(){var e,t;(e=this._controls)==null||e.dispose(),(t=this._eventSystem)==null||t.removeEventListener(qM.AfterHandleInput,this._afterHandleInputFn)}onEnable(){this._enableTime=this.context.time.time;const e=eA.getComponent(this.gameObject,Ot);this._camera=e;const t=e==null?void 0:e.cam;if(t&&Ob(t,this,!0),!this._controls){console.assert(t!=null,"Missing camera",this),t&&(this._cameraObject=t);const g=this.targetElement??this.context.domElement,I=t==null?void 0:t.quaternion.clone();this._controls=new G$(t,g),t==null||t.quaternion.copy(I),gm===void 0&&(gm={...this._controls.keys})}this._controls&&($p&&(this.enablePan=!0,this.enableZoom=!0,this.middleClickToFocus=!0,ir()&&(this.doubleClickToFocus=!0)),this._controls.addEventListener("start",this.onControlsChangeStarted),(t==null?void 0:t.type)==="PerspectiveCamera"?$p||(this._controls.minDistance=this.minZoom,this._controls.maxDistance=this.maxZoom):$p||(this._controls.minZoom=this.minZoom,this._controls.maxZoom=this.maxZoom),this._startedListeningToKeyEvents||(this._startedListeningToKeyEvents=!0,this._controls.listenToKeyEvents(window.document.body))),this._syncedTransform=eA.getComponent(this.gameObject,ja)??void 0}onDisable(){var e;(e=this._camera)!=null&&e.cam&&Ob(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))}*startRaycastDelayed(){if(yield,!this.setFromTargetPosition()){const e=new Fs;e.screenPoint=new X(0,0),e.lineThreshold=.1;const t=this.context.physics.raycast(e);t.length>0&&this.setTarget(t[0].point,!0)}}onBeforeRender(){var t,g,I;if(!this._controls||this._cameraObject!==this.context.mainCamera)return;(this.context.input.getPointerDown(0)||this.context.input.getPointerDown(1)||this.context.input.getPointerDown(2))&&(this._inputs+=1),this._inputs>0&&(this.autoRotate=!1,this._controls.autoRotate=!1,this._lerpCameraToTarget=!1,this._lerpToTargetPosition=!1),this._inputs=0;let 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.context.input.getPointerDown(0)||this.context.input.mouseWheelChanged)&&(this._lerpToTargetPosition=!1,this._lerpCameraToTarget=!1),this._lerpToTargetPosition||this._lerpCameraToTarget){const o=this.context.time.deltaTime*this.targetLerpSpeed;if(this._lerpCameraToTarget&&this._cameraTargetPosition&&this._cameraObject){if(this.useSlerp){const s=(t=this._cameraObject)==null?void 0:t.position;JT(s,this._cameraTargetPosition,o)}else(g=this._cameraObject)==null||g.position.lerp(this._cameraTargetPosition,o);this._cameraObject.position.distanceTo(this._cameraTargetPosition)<1e-4&&(this._lerpCameraToTarget=!1)}this._lerpToTargetPosition&&(this.lerpTarget(this._lookTargetPosition,o),this._lookTargetPosition.distanceTo(this._controls.target)<1e-5&&(this._lerpToTargetPosition=!1))}!$p&&((I=this.lookAtConstraint)!=null&&I.locked)&&this.setFromTargetPosition(0,this.lookAtConstraint01),this._controls&&(this.debugLog&&(this._controls.domElement=this.context.renderer.domElement),this._controls.enabled=!this._shouldDisable&&this._camera===this.context.mainCameraComponent&&!this.context.isInXR,this._controls.enableDamping=this.enableDamping,this._controls.keys=this.enableKeys?gm:MgA,this._controls.autoRotate=this.autoRotate,this._controls.autoRotateSpeed=this.autoRotateSpeed,this._controls.enableZoom=this.enableZoom,this._controls.dampingFactor=this.dampingFactor,this._controls.enablePan=this.enablePan,this.context.isInXR||this._controls.update())}setCameraTarget(e,t=!1){var g;e?(this._lerpCameraToTarget=!0,this._cameraTargetPosition=e.clone(),t&&this._cameraTargetPosition&&((g=this.controllerObject)==null||g.position.copy(this._cameraTargetPosition))):this._lerpCameraToTarget=!1}setFromTargetPosition(e=0,t=1){var I;if(!this._controls)return!1;const g=(I=this.lookAtConstraint)==null?void 0:I.sources;if(g&&g.length>0){const o=g[e];if(o)return o.getWorldPosition(this._lookTargetPosition),this.lerpTarget(this._lookTargetPosition,t),!0}return!1}setTarget(e=null,t=!1){this._controls&&(e!==null&&this._lookTargetPosition.copy(e),t?this._controls.target.copy(this._lookTargetPosition):this._lerpToTargetPosition=!0)}lerpTarget(e,t){this._controls&&this._controls.target.lerp(e,t)}distanceToTarget(e){return this._controls?this._controls.target.distanceTo(e):-1}setTargetFromRaycast(){var t,g;if(!this.controls)return;const e=this.context.physics.raycast();for(const I of e)if(I.distance>0&&eA.isActiveInHierarchy(I.object)){if(this._lookTargetPosition.copy(I.point),this._lerpToTargetPosition=!0,this._cameraTargetPosition=null,this.context.mainCamera){this._lerpCameraToTarget=!0;const o=ye(this.context.mainCamera);this._cameraTargetPosition=o.clone().sub(this.controls.target).add(this._lookTargetPosition),(g=(t=this._cameraObject)==null?void 0:t.parent)==null||g.worldToLocal(this._cameraTargetPosition)}break}}fitCamera(e,t=1.1){const g=this._cameraObject,I=this._controls;if(e!=null&&e.length||(e=this.context.scene.children),e.length<=0||!g||!I)return;const o=new m,s=new m,C=new Hi;C.makeEmpty();for(const d of e)d instanceof OG||d instanceof iU||C.expandByObject(d,!0);if(g.updateMatrixWorld(),g.updateProjectionMatrix(),C.getCenter(s),C.applyMatrix4(g.matrixWorldInverse),C.getSize(o),C.setFromCenterAndSize(s,o),o.length()<=1e-10){im&&console.warn("Camera fit size is zero",C,[...e]);return}const n=g.fov,a=2*Math.atan(Math.tan(n*Math.PI/360/2)*g.aspect)/Math.PI*360,r=o.y/(2*Math.atan(Math.PI*n/360)),Q=o.x/(2*Math.atan(Math.PI*a/360)),E=t*Math.max(r,Q)+o.z/2;im&&console.log("Fit camera to objects",r,Q,"distance",E);const h=ye(g),l=I.target.clone().sub(h).normalize().multiplyScalar(E);if(I.maxDistance=E*10,I.minDistance=E*.01,I.target.copy(s),g.near=E/100,g.far=E*100,g.updateMatrixWorld(),g.updateProjectionMatrix(),di(g,I.target.clone().sub(l)),im){const d=new OG(C);this.context.scene.add(d),LT(d,Fw(g)),this._haveAttachedKeyboardEvents||(this._haveAttachedKeyboardEvents=!0,document.body.addEventListener("keydown",c=>{c.code==="KeyF"&&this.fitCamera(e)}))}I.update()}}GgA([y(iu)],Tn.prototype,"lookAtConstraint",2);var RgA=Object.defineProperty,UgA=Object.getOwnPropertyDescriptor,$o=(i,A,e,t)=>{for(var g=t>1?void 0:t?UgA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&RgA(A,e,g),g},dO=(i=>(i[i.Skybox=1]="Skybox",i[i.SolidColor=2]="SolidColor",i[i.Uninitialized=4]="Uninitialized",i))(dO||{});const jc=oA("debugcam"),Pb=oA("debugscreenpointtoray");var Lf;const Zc=(Lf=class extends mA{constructor(){super(...arguments);B(this,"_nearClipPlane",.1);B(this,"_farClipPlane",1e3);B(this,"orthographic",!1);B(this,"orthographicSize",5);B(this,"ARBackgroundAlpha",0);B(this,"_cullingMask",4294967295);B(this,"_backgroundBlurriness");B(this,"_backgroundIntensity");B(this,"_targetTexture",null);B(this,"_backgroundColor");B(this,"_fov");B(this,"_cam",null);B(this,"_clearFlags",2);B(this,"_skybox")}get isCamera(){return!0}get aspect(){return this._cam instanceof je?this._cam.aspect:this.context.domWidth/this.context.domHeight}get fieldOfView(){return this._cam instanceof je?this._cam.fov:this._fov}set fieldOfView(A){const e=this.fieldOfView!=A;if(this._fov=A,e&&this._cam&&this._cam instanceof je){if(this._fov===void 0){console.error("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 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}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){let g=this.cam;const I=Zc._origin;I.set(A,e,-1),this.context.input.convertScreenspaceToRaycastSpace(I),Pb&&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(g);const o=Zc._direction.set(I.x,I.y,I.z),s=ye(g);return o.sub(s),o.normalize(),t?(t.set(s,o),t):new pC(s.clone(),o.clone())}awake(){Pb&&window.addEventListener("pointerdown",A=>{const e=A.clientX,t=A.clientY;console.log("touch",e.toFixed(2),t.toFixed(2));const g=this.screenPointToRay(e,t),I="#"+Math.floor(Math.random()*16777215).toString(16);ln.DrawRay(g.origin,g.direction,I,10)})}onEnable(){jc&&console.log(this),this.buildCamera(),(this.tag=="MainCamera"||!this.context.mainCameraComponent)&&(this.context.setCurrentCamera(this),NgA(this)),this.applyClearFlagsIfIsActiveCamera()}onDisable(){this.context.removeCamera(this)}onBeforeRender(){if(this._cam&&this._targetTexture){this.context.isManagedExternally&&(this._warnedAboutExternalRenderer||(this._warnedAboutExternalRenderer=!0,console.warn("Rendering with external renderer is not supported yet. This may not work or throw errors. Please remove the the target texture from your camera: "+this.name,this.targetTexture))),this.context.composer;const A=this.context.renderer;A&&this._targetTexture.render(this.context.scene,this._cam,A)}}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 je&&(this._fov=e.fov)):e=this.gameObject.children[0],e&&e.isCamera)e instanceof je&&(this._fov&&(e.fov=this._fov),e.near=this._nearClipPlane,e.far=this._farClipPlane,e.updateProjectionMatrix());else if(!this.orthographic)e=new je(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 KB(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){jc&&console.log("Camera does not exist (apply clear flags)");return}switch(this.fieldOfView=this._fov,jc&&Mi("apply Camera clear flags: "+this._clearFlags),this._clearFlags){case 1:if(Zc.backgroundShouldBeTransparent(this.context)&&(!this.ARBackgroundAlpha||this.ARBackgroundAlpha<.001)){this.context.scene.background=null,this.context.renderer.setClearColor(0,0);return}this.enableSkybox(),this._backgroundBlurriness!==void 0&&(this.context.scene.backgroundBlurriness=this._backgroundBlurriness),this._backgroundIntensity!==void 0&&(this.context.scene.backgroundIntensity=this._backgroundIntensity);break;case 2:if(this._backgroundColor){let A=this._backgroundColor.alpha;Zc.backgroundShouldBeTransparent(this.context)&&(A=this.ARBackgroundAlpha??0),this.context.scene.background=null,this.context.renderer.setClearColor(this._backgroundColor,A)}break;case 4:this.context.scene.background=null,this.context.renderer.setClearColor(0,0);break}}enableSkybox(){this._skybox||(this._skybox=new FgA(this)),this._skybox.enable()}static backgroundShouldBeTransparent(A){var I,o,s,C;const e=(I=A.renderer.xr)==null?void 0:I.getSession();if(!e)return!1;const t=e.environmentBlendMode;jc&&Mi("Environment blend mode: "+t+" on "+navigator.userAgent);const g=t==="additive"||t==="alpha-blend";if(A.xrSessionMode===id.ImmersiveAR&&t==="opaque"){if((o=navigator.userAgent)!=null&&o.includes("OculusBrowser"))return!0;if((s=navigator.userAgent)!=null&&s.includes("Mozilla")&&((C=navigator.userAgent)!=null&&C.includes("Mobile WebXRViewer/v2")))return!0}return g}},B(Lf,"_origin",new m),B(Lf,"_direction",new m),Lf);let Ot=Zc;$o([y()],Ot.prototype,"fieldOfView",1);$o([y()],Ot.prototype,"nearClipPlane",1);$o([y()],Ot.prototype,"farClipPlane",1);$o([y()],Ot.prototype,"clearFlags",1);$o([y()],Ot.prototype,"orthographic",2);$o([y()],Ot.prototype,"orthographicSize",2);$o([y()],Ot.prototype,"ARBackgroundAlpha",2);$o([y()],Ot.prototype,"cullingMask",1);$o([y()],Ot.prototype,"backgroundBlurriness",1);$o([y()],Ot.prototype,"backgroundIntensity",1);$o([y(kt)],Ot.prototype,"backgroundColor",1);$o([y(Ta)],Ot.prototype,"targetTexture",1);class FgA{constructor(A){B(this,"_camera");B(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&&(jc&&console.log("Set skybox",this._camera,this._skybox),this._skybox.colorSpace=Ie,this._skybox.mapping=_o,this.context.scene.background=this._skybox):console.warn("Failed to load/find skybox texture",this._camera.sourceId,this.context.lightmaps)}}function NgA(i){oA("freecam")&&i.context.mainCameraComponent===i&&eA.getOrAddComponent(i.gameObject,Tn)}class ZE extends mA{constructor(){super(...arguments);B(this,"_listener",null)}get listener(){return this._listener==null&&(this._listener=new AU),this._listener}awake(){Ni.registerWaitForAllowAudio(()=>{if(this.destroyed)return;const e=this.listener;if(e==null||e.parent)return;const t=eA.getComponentInParent(this.gameObject,Ot);t?t.cam.add(e):this.gameObject.add(e)})}}var KgA=Object.defineProperty,JgA=Object.getOwnPropertyDescriptor,yS=(i,A,e,t)=>{for(var g=t>1?void 0:t?JgA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&KgA(A,e,g),g};const qgA=oA("debugsignals");class au{constructor(){B(this,"guid")}}yS([y()],au.prototype,"guid",2);class mh{constructor(){B(this,"signal");B(this,"reaction")}}yS([y(au)],mh.prototype,"signal",2);yS([y(FI)],mh.prototype,"reaction",2);var $m;const zC=($m=class extends mA{constructor(){super(...arguments);B(this,"events")}static invoke(A){if(zC.receivers[A]){const e=zC.receivers[A];if(!e)return;for(const t of e)t.invoke(A)}}awake(){qgA&&console.log("SignalReceiver awake",this)}onEnable(){if(this.events)for(const A of this.events)zC.receivers[A.signal.guid]||(zC.receivers[A.signal.guid]=[]),zC.receivers[A.signal.guid].push(this)}onDisable(){if(this.events){for(const A of this.events)if(zC.receivers[A.signal.guid]){const e=zC.receivers[A.signal.guid].indexOf(this);e>=0&&zC.receivers[A.signal.guid].splice(e,1)}}}invoke(A){if(!this.events||!Array.isArray(this.events))return;let 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(g){console.error(g)}}},B($m,"receivers",{}),$m);let Gh=zC;yS([y(mh)],Gh.prototype,"events",2);var PI=(i=>(i.Activation="ActivationTrack",i.Animation="AnimationTrack",i.Audio="AudioTrack",i.Control="ControlTrack",i.Marker="MarkerTrack",i.Signal="SignalTrack",i))(PI||{}),Ps=(i=>(i[i.None=0]="None",i[i.Hold=1]="Hold",i[i.Loop=2]="Loop",i[i.PingPong=3]="PingPong",i[i.Continue=4]="Continue",i))(Ps||{}),kF=(i=>(i.Signal="SignalEmitter",i))(kF||{});const yc=oA("debugtimeline"),Yy=class extends mA{constructor(){super(...arguments);B(this,"playableAsset");B(this,"playOnAwake");B(this,"extrapolationMode",1);B(this,"waitForAudio",!0);B(this,"_visibilityChangeEvt");B(this,"_clonedPlayableAsset",!1);B(this,"_speed",1);B(this,"_guidsMap");B(this,"_isPlaying",!1);B(this,"_internalUpdateRoutine");B(this,"_isPaused",!1);B(this,"_time",0);B(this,"_duration",0);B(this,"_weight",1);B(this,"_animationTracks",[]);B(this,"_audioTracks",[]);B(this,"_signalTracks",[]);B(this,"_controlTracks",[]);B(this,"_customTracks",[]);B(this,"_allTracks",[this._animationTracks,this._audioTracks,this._signalTracks,this._controlTracks,this._customTracks])}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:(yc||aI())&&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,g;yc&&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((g=this.playableAsset)==null?void 0:g.tracks),this)}onEnable(){var e,t;for(const g of this._audioTracks)(e=g.onEnable)==null||e.call(g);for(const g of this._customTracks)(t=g.onEnable)==null||t.call(g);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;this.stop();for(const g of this._audioTracks)(e=g.onDisable)==null||e.call(g);for(const g of this._customTracks)(t=g.onDisable)==null||t.call(g);this._visibilityChangeEvt&&window.removeEventListener("visibilitychange",this._visibilityChangeEvt)}onDestroy(){var e;for(const t of this._allTracks)for(const g of t)(e=g.onDestroy)==null||e.call(g)}rebuildGraph(){this.isValid()&&(this.resolveBindings(),this.updateTimelineDuration(),this.setupAndCreateTrackHandlers())}async play(){if(!this.isValid())return;const e=this._isPaused==!0;if(this._isPaused=!1,e&&this.invokePauseChangedMethodsOnTracks(),!this._isPlaying){if(this._isPlaying=!0,this.waitForAudio){const t=[];for(const g of this._audioTracks){const I=g.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&&!Ni.userInteractionRegistered&&this.waitForAudio;)await Kd(200)}this._internalUpdateRoutine=this.startCoroutine(this.internalUpdate())}}pause(){this.isValid()&&(this._isPlaying=!1,!this._isPaused&&(this._isPaused=!0,this.evaluate(),this.invokePauseChangedMethodsOnTracks()))}stop(){for(const g of this._audioTracks)g.stop();const e=this._isPaused==!0,t=this._isPlaying;this._isPlaying&&(this._time=0,this._isPlaying=!1,this._isPaused=!1,this.evaluate(),e&&this.invokePauseChangedMethodsOnTracks()),this._isPlaying=!1,this._isPaused=!1,e&&!t&&this.invokePauseChangedMethodsOnTracks(),this._internalUpdateRoutine&&this.stopCoroutine(this._internalUpdateRoutine),this._internalUpdateRoutine=null}evaluate(){if(!this.isValid())return;let e=this._time;switch(this.extrapolationMode){case 0:this._speed>0?e=Math.min(e,this._duration):this._speed<0&&(e=Math.max(e,0)),this._time=e;break;case 1:e%=this._duration,this._time=e;break;case 2:if(e>this._duration){this.stop();return}break}this.internalEvaluate(e)}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)}*internalUpdate(){for(;this._isPlaying&&this.activeAndEnabled;)!this._isPaused&&this._isPlaying&&(this._time+=this.context.time.deltaTime*this.speed,this.evaluate()),yield}internalEvaluate(e){for(const t of this.playableAsset.tracks)if(!t.muted)switch(t.type){case PI.Activation:for(let g=0;g<t.outputs.length;g++){const I=t.outputs[g];if(typeof I=="object"){let o=!1;for(const C of t.clips)C.start<=e&&e<=C.end&&(o=!0);const s=I;s.visible!==void 0&&(s.visible=o)}}break}for(const t of this._animationTracks)t.evaluate(e);for(const t of this._audioTracks)t.evaluate(e);for(const t of this._signalTracks)t.evaluate(e);for(const t of this._controlTracks)t.evaluate(e);for(const t of this._customTracks)t.evaluate(e)}resolveBindings(){if(this._clonedPlayableAsset||(this._clonedPlayableAsset=!0,this.playableAsset=_y(this.playableAsset)),!this.playableAsset||!this.playableAsset.tracks)return;const e=this.findRoot(this.gameObject);for(const t of this.playableAsset.tracks){for(let g=t.outputs.length-1;g>=0;g--){let I=t.outputs[g];if(typeof I=="string"){this._guidsMap&&this._guidsMap[I]&&(I=this._guidsMap[I]);const o=eA.findByGuid(I,e);o===null||typeof o!="object"?(t.outputs.splice(g,1),console.warn("Failed to resolve binding",I,t.name,t.type)):(yc&&console.log("Resolved binding",I,"to",o),t.outputs[g]=o)}else if(I===null){if(t.outputs.splice(g,1),Yy.createTrackFunctions[t.type])continue;t.type!==PI.Audio&&t.type!==PI.Control&&t.type!==PI.Marker&&t.type!==PI.Signal&&console.warn("Missing binding",I,t.name,t.type,this.name,this.playableAsset.name)}}if(t.type===PI.Control)for(let g=0;g<t.clips.length;g++){const I=t.clips[g];let o=I.asset.sourceObject;if(typeof o=="string"){this._guidsMap&&this._guidsMap[o]&&(o=this._guidsMap[o]);const s=eA.findByGuid(o,e);s===null||typeof s!="object"?console.warn("Failed to resolve sourceObject binding",o,t.name,I):(yc&&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){for(const t of e.clips)t.end>this._duration&&(this._duration=t.end);for(const t of e.markers)t.time>this._duration&&(this._duration=t.time+.001)}}}setupAndCreateTrackHandlers(){var t,g;if(this._animationTracks.length=0,this._audioTracks.length=0,this._signalTracks.length=0,!this.playableAsset)return;const e=eA.findObjectOfType(ZE,this.context);for(const I of this.playableAsset.tracks){const o=I.type,s=Yy.createTrackFunctions[o];if(s!=null){const C=s(this,I);if(typeof C.evaluate=="function"){C.director=this,C.track=I,this._customTracks.push(C);continue}}if(I.type===PI.Animation){if(I.clips.length<=0){yc&&console.warn("Animation track has no clips",I);continue}for(let C=I.outputs.length-1;C>=0;C--){let n=I.outputs[C];if(n instanceof bA){const r=eA.getOrAddComponent(n,QI);r&&(n=r)}const a=(t=n==null?void 0:n.gameObject)==null?void 0:t.animations;if(a){const r=new wS;r.trackOffset=I.trackOffset,r.director=this,r.track=I;for(let Q=0;Q<I.clips.length;Q++){const E=I.clips[Q],h=E.asset;if(!h){console.error("MISSING anim model?","clip#"+Q,E,I,this.playableAsset,this.name);continue}const l=h.clip;let d=l;if((typeof d=="string"||typeof d=="number")&&(d=a.find(p=>p.name===l)),!d){console.warn("Could not find animationClip for model",E,I.name,this.name,(g=this.playableAsset)==null?void 0:g.name);continue}r.mixer||(r.mixer=new Rw(n.gameObject)),r.clips.push(d),r.mixer.uncacheAction(d),r.createHooks(E.asset,d);const c=r.mixer.clipAction(d);r.actions.push(c),r.models.push(E)}this._animationTracks.push(r)}}}else if(I.type===PI.Audio){if(I.clips.length<=0)continue;const C=new fB;if(C.director=this,C.track=I,this._audioTracks.push(C),!e)continue;C.listener=e.listener;for(let n=0;n<I.clips.length;n++){const a=I.clips[n];C.addModel(a)}}else if(I.type===PI.Marker){const C=new ld;C.director=this,C.track=I;for(const n of I.markers)switch(n.type){case kF.Signal:C.models.push(n),C.didTrigger.push(!1);break}if(C!==null&&C.models.length>0){const n=eA.getComponent(this.gameObject,Gh);n&&(C.receivers.push(n),this._signalTracks.push(C))}}else if(I.type===PI.Signal){const C=new ld;C.director=this,C.track=I;for(const n of I.markers)C.models.push(n),C.didTrigger.push(!1);for(const n of I.outputs)C.receivers.push(n);this._signalTracks.push(C)}else if(I.type===PI.Control){const C=new SS;C.director=this,C.track=I;for(const n of I.clips)C.models.push(n);C.resolveSourceObjects(this.context),this._controlTracks.push(C)}}}setAudioTracksAllowPlaying(e){for(const t of this._audioTracks)t.onAllowAudioChanged(e)}};let wn=Yy;B(wn,"createTrackFunctions",{});const pB=oA("debugtimeline");class ru{constructor(){B(this,"director");B(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,g=!0){if(e<0||e>=t.length)return 0;const I=t[e];if(g||A>=I.start&&A<=I.end){let o=1,s=!1;if(I.easeInDuration>0){const C=Math.min((A-I.start)/I.easeInDuration,1);o*=C}if(I.easeOutDuration>0&&!s){const C=Math.min((I.end-A)/I.easeOutDuration,1);o*=C}return o}return 0}}class bgA{constructor(A){B(this,"clip");B(this,"rootPositionOffset");B(this,"rootQuaternionOffset");B(this,"rootStartPosition");B(this,"rootEndPosition");B(this,"rootStartQuaternion");B(this,"rootEndQuaternion");const e=A.getClip();this.clip=e;const t=A.getRoot(),g=t.name+".position",I=t.name+".quaternion";pB&&console.log(e.name,e.tracks,g);for(const o of e.tracks)if(!(o.times.length<=0)){if(o.name.endsWith(g))this.rootStartPosition=new m().fromArray(o.values,0),this.rootEndPosition=new m().fromArray(o.values,o.values.length-3),this.rootPositionOffset=this.rootEndPosition.clone().sub(this.rootStartPosition),pB&&console.log(this.rootPositionOffset);else if(o.name.endsWith(I)&&(this.rootStartQuaternion=new LA().fromArray(o.values,0),this.rootEndQuaternion=new LA().fromArray(o.values,o.values.length-4),this.rootQuaternionOffset=this.rootEndQuaternion.clone().multiply(this.rootStartQuaternion),pB)){const s=new ug().setFromQuaternion(this.rootQuaternionOffset);console.log("ROT",s)}}}get hasOffsets(){return this.rootPositionOffset!==void 0||this.rootQuaternionOffset!==void 0}}class wS extends ru{constructor(){super(...arguments);B(this,"models",[]);B(this,"trackOffset");B(this,"target");B(this,"mixer");B(this,"clips",[]);B(this,"actions",[]);B(this,"_actionOffsets",[]);B(this,"_didBind",!1);B(this,"_animator",null);B(this,"_animatorWasEnabled",!1);B(this,"_useclipOffsets",!0);B(this,"_totalOffsetPosition",new m);B(this,"_totalOffsetRotation",new LA);B(this,"_totalOffsetPosition2",new m);B(this,"_totalOffsetRotation2",new LA);B(this,"_summedPos",new m);B(this,"_tempPos",new m);B(this,"_summedRot",new LA);B(this,"_tempRot",new LA);B(this,"_clipRotQuat",new LA)}onPauseChanged(){this._animator&&this._animatorWasEnabled!==void 0&&(this._animator.enabled=this.director.isPlaying===!1?this._animatorWasEnabled:!1)}createHooks(e,t){var a,r;if(((a=t.tracks)==null?void 0:a.length)<=0){console.warn("No tracks in AnimationClip",t);return}const g=t.tracks[0].name.split("."),I=g[g.length-2],o=I+".position",s=I+".quaternion";let C=!1,n=!1;for(const Q of t.tracks)Q.name.endsWith(o)?(C=!0,this.createPositionInterpolant(t,e,Q)):Q.name.endsWith(s)&&(n=!0,this.createRotationInterpolant(t,e,Q));if(!C||!n){const Q=(r=this.mixer)==null?void 0:r.getRoot(),E=t.tracks[0],h=E.name.lastIndexOf("."),l=E.name.substring(0,h),d=l.substring(l.lastIndexOf(".")+1),c=Q.getObjectByName(d);if(c)if(C){if(!n){const p=t.tracks[0].name.substring(0,h)+".quaternion";pB&&console.warn("Create quaternion track",d,c);const u=c.quaternion,f=new hC(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=l+".position";pB&&console.warn("Create position track",d,c);const u=c.position,f=new Va(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,pB&&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 bgA(e);this._actionOffsets.push(t)}this.target&&(this._animator=eA.getComponent(this.target,QI)??null,this._animator?(this._animatorWasEnabled=this._animator.enabled,this._animator.enabled=!1):this._animatorWasEnabled=!1);for(const e of this.models){const t=e.asset,g=t.position,I=t.rotation;g&&g.x!==void 0&&(g.isVector3||(t.position=new m(g.x,g.y,g.z)),I.isQuaternion||(t.rotation=new LA(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 m(e.x,e.y,e.z)));const t=this.trackOffset.rotation;t&&(t.isQuaternion||(this.trackOffset.rotation=new LA(t.x,t.y,t.z,t.w)))}}evaluate(e){if(this.track.muted||!this.mixer)return;this.bind(),this._animator&&this.director.isPlaying&&this.director.weight>0&&(this._animator.enabled=!1),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,g=0,I=!1,o=!1;for(let s=0;s<this.clips.length;s++){const C=this.models[s],n=this.actions[s],a=C.asset;n.weight=0;const r=e>=C.start&&e<=C.end,Q=C.preExtrapolationMode,E=C.postExtrapolationMode,h=s<this.clips.length-1?this.models[s+1]:null;let l=r,d=!1;if(!l&&!I&&C.end<e&&E!==Ps.None?(!h||h.start>e)&&(l=!0,I=!0):s==0&&!l&&!o&&C.start>e&&Q!==Ps.None&&(!h||h.start<e)&&(l=!0,d=!0,o=!0),l){let c=1;c*=this.evaluateWeight(e,s,this.models,l),c*=this.director.weight;let p=r;if(d)switch(Q){case Ps.Hold:break;case Ps.Loop:e+=C.start,p=!0;break;default:e+=C.start,p=!0;break}let u=this.getClipTime(e,C),f=0;const D=a.duration;if(d&&Q===Ps.Hold&&(u=0),p){if(a.loop)for(f+=Math.floor(u/(D+1e-6));u>D;)u-=D}else if(!r&&I)switch(E){case Ps.Hold:u=this.getClipTime(C.end,C);break;case Ps.Loop:u%=D;break;case Ps.PingPong:const R=Math.floor(u/D)%2!==0;u%=D,R&&(u=D-u);break}C.reversed===!0?n.time=n.getClip().duration-u:n.time=u,n.timeScale=0;const w=c;if(n.weight=w,n.clampWhenFinished=!0,n.isRunning()||n.play(),this._useclipOffsets){const M=t==0?this._totalOffsetPosition:this._totalOffsetPosition2,R=t==0?this._totalOffsetRotation:this._totalOffsetRotation2;t<1&&(g=1-c),t+=1;const k=this._summedPos.set(0,0,0),G=this._tempPos.set(0,0,0),J=this._summedRot.identity(),P=this._tempRot.identity(),L=a.rotation;L&&(this._clipRotQuat.identity(),this._clipRotQuat.slerp(L,c));const T=this._actionOffsets[s];if(T.hasOffsets)for(let _=0;_<f;_++)T.rootPositionOffset?G.copy(T.rootPositionOffset):G.set(0,0,0),G.applyQuaternion(J),this._clipRotQuat&&G.applyQuaternion(this._clipRotQuat),T.rootQuaternionOffset&&(P.copy(T.rootQuaternionOffset),J.multiply(P)),k.add(G);this._clipRotQuat&&R.multiply(this._clipRotQuat),R.multiply(J),a.position&&k.add(a.position),M.add(k)}}}this._useclipOffsets&&(this._totalOffsetPosition.lerp(this._totalOffsetPosition2,g),this._totalOffsetRotation.slerp(this._totalOffsetRotation2,g)),this.mixer.update(e)}createRotationInterpolant(e,t,g){var C;const I=g.createInterpolant.bind(g),o=new LA;this.ensureTrackOffsets();const s=(C=this.trackOffset)==null?void 0:C.rotation;g.createInterpolant=()=>{const n=I(),a=n.evaluate.bind(n);return n.evaluate=r=>{const Q=a(r);return o.set(Q[0],Q[1],Q[2],Q[3]),o.premultiply(this._totalOffsetRotation),s&&o.premultiply(s),Q[0]=o.x,Q[1]=o.y,Q[2]=o.z,Q[3]=o.w,Q},n}}createPositionInterpolant(e,t,g){var a,r;const I=g.createInterpolant.bind(g),o=new m;this.ensureTrackOffsets();const s=(a=this.trackOffset)==null?void 0:a.rotation,C=(r=this.trackOffset)==null?void 0:r.position;let n;g.createInterpolant=()=>{const Q=I(),E=Q.evaluate.bind(Q);return Q.evaluate=h=>{var d,c;const l=E(h);return o.set(l[0],l[1],l[2]),t.removeStartOffset&&(n===void 0?(n=null,n=(c=(d=this._actionOffsets.find(p=>p.clip===e))==null?void 0:d.rootStartPosition)==null?void 0:c.clone()):n!=null&&n.isVector3&&o.sub(n)),o.applyQuaternion(this._totalOffsetRotation),o.add(this._totalOffsetPosition),s&&o.applyQuaternion(s),C&&(o.x-=C.x,o.y+=C.y,o.z+=C.z),l[0]=o.x,l[1]=o.y,l[2]=o.z,l},Q}}}const xgA=oA("mutetimeline"),dE=class extends ru{constructor(){super(...arguments);B(this,"models",[]);B(this,"listener");B(this,"audio",[]);B(this,"audioContextTimeOffset",[]);B(this,"lastTime",0);B(this,"_audioLoader",null)}getAudioFilePath(e){const t=this.director.sourceId;return tr(t,e)}onAllowAudioChanged(e){for(let t=0;t<this.models.length;t++){const g=this.models[t];this.audio[t].setVolume(e?g.asset.volume:0)}}addModel(e){const t=new Mw(this.listener);this.audio.push(t),this.models.push(e)}onDisable(){for(const e of this.audio)e.isPlaying&&e.stop()}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()}}evaluate(e){if(xgA||this.track.muted||this.director.speed<0)return;const t=this.director.context.application.muted,g=t?.1:0;for(let I=0;I<this.models.length;I++){const o=this.models[I],s=this.audio[I];if((!s||!s.buffer)&&this.isInTimeRange(o,e-1,e+1)&&this.handleAudioLoading(o,s),Ni.userInteractionRegistered!==!1&&!(s===null||!s.buffer))if(s.playbackRate=this.director.context.time.timeScale,s.loop=o.asset.loop,e>=o.start&&e<=o.end&&e<this.director.duration){if(this.director.isPlaying==!1){if(s.isPlaying&&s.stop(),this.lastTime===e)continue}else if(!s.isPlaying)s.offset=o.clipIn+(e-o.start)*o.timeScale,s.play(g);else{const n=o.clipIn+(e-o.start)*o.timeScale,a=s.context.currentTime-s._startedAt+s.offset;Math.abs(n-a)>.3&&(s.offset=n,s.stop(),s.play(g))}let C=o.asset.volume;if(t&&(C=0),o.easeInDuration>0){const n=Math.min((e-o.start)/o.easeInDuration,1);C*=n}if(o.easeOutDuration>0){const n=Math.min((o.end-e)/o.easeOutDuration,1);C*=n}s.setVolume(C*this.director.weight)}else s.isPlaying&&s.stop()}this.lastTime=e}loadAudio(e,t=0,g=0){let I=null;const o=e-g,s=e+t;for(const C of this.models)if(this.isInTimeRange(C,o,s)){const n=this.audio[this.models.indexOf(C)],a=this.handleAudioLoading(C,n);a!==null&&(I===null&&(I=[]),I.push(a))}return I!==null?Promise.all(I):null}isInTimeRange(e,t,g){return t<=e.start&&g>=e.end||t>=e.start&&t<=e.end||g>=e.start&&g<=e.end}static dispose(){dE._audioBuffers.clear()}handleAudioLoading(e,t){this._audioLoader||(this._audioLoader=new jD);const g=this.getAudioFilePath(e.asset.clip);if(dE._audioBuffers.get(g)){const o=dE._audioBuffers.get(g);return o.then(s=>{s&&t.setBuffer(s)}),o}pB&&console.warn("LOAD audio track",g,this.director.sourceId);const I=new Promise((o,s)=>{this._audioLoader.load(g,C=>{t.setBuffer(C),o(C)},void 0,C=>{console.error("Error loading audio",C),o(null)})});return dE._audioBuffers.set(g,I),I}};let fB=dE;B(fB,"_audioBuffers",new Map);class ld extends ru{constructor(){super(...arguments);B(this,"models",[]);B(this,"didTrigger",[]);B(this,"receivers",[])}evaluate(e){var g;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],C=o.time-e;let n=!1;if(o.retroActive)n=C<=1e-6;else{const a=Math.abs(C);a>=1e-5&&a<t&&(n=!0)}if(n){if(!s)if(this.didTrigger[I]=!0,((g=this.receivers)==null?void 0:g.length)<=0)Gh.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 ru{constructor(){super(...arguments);B(this,"models",[]);B(this,"timelines",[]);B(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=eA.getComponent(I.sourceObject,wn);this.timelines.push(o),o&&I.updateDirector&&(o.playOnAwake=!1)}}}evaluate(e){var t;this._previousActiveModel=null;for(let g=0;g<this.models.length;g++){const I=this.models[g],o=I.asset;if(e>=I.start&&e<=I.end){this._previousActiveModel=I;const s=this.getClipTime(e,I);if(o.controlActivation){const C=o.sourceObject;C.visible=!0}if(o.updateDirector){const C=this.timelines[g];C&&(C.isPlaying&&C.pause(),C.time=s,C.evaluate())}}else{const s=(t=this._previousActiveModel)==null?void 0:t.asset;if(o.controlActivation){const C=o.sourceObject;(s==null?void 0:s.sourceObject)!==C&&(C.visible=!1)}}}}}var LgA=Object.defineProperty,vgA=Object.getOwnPropertyDescriptor,uO=(i,A,e,t)=>{for(var g=t>1?void 0:t?vgA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&LgA(A,e,g),g};class Re{constructor(A){B(this,"_active",!0);B(this,"_value");B(this,"_valueRaw");B(this,"_defaultValue");B(this,"valueProcessor");B(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;!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)}testIfValueChanged(A){return this._valueRaw!==A}}uO([y()],Re.prototype,"overrideState",1);uO([y()],Re.prototype,"value",1);var TgA=Object.defineProperty,YgA=Object.getOwnPropertyDescriptor,HgA=(i,A,e,t)=>{for(var g=t>1?void 0:t?YgA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&TgA(A,e,g),g};const _gA=oA("debugpost");class _g extends nr{constructor(e=void 0){super();B(this,"active",!0);B(this,"_result");B(this,"_didCreateVolumeParameters",!1);if(e){this.ensureVolumeParameters();for(const t of Object.keys(e)){const g=e[t],I=this[t];I instanceof Re&&(I.value=g)}}}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(){_gA&&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 g=this[t];g instanceof Re&&g.__init()}}onAfterDeserialize(e,t){if(typeof e=="object"){const g=this.$serializedTypes;if(g){for(const I of Object.keys(g))if(g[I]===Re){const s=e[I];if(s!==void 0){const C=this[I];C.value=s}}}}}onEditorModification(e){const t=e.propertyName;if(this[t]instanceof Re){const g=e.value;return this[t].value=g,!0}}ensureVolumeParameters(){if(this._didCreateVolumeParameters)return;this._didCreateVolumeParameters=!0;const e=this.$serializedTypes;if(e)for(const t of Object.keys(e))e[t]===Re&&(this[t]||(this[t]=new Re))}}HgA([y()],_g.prototype,"active",2);var OgA=Object.defineProperty,PgA=Object.getOwnPropertyDescriptor,WgA=(i,A,e,t)=>{for(var g=t>1?void 0:t?PgA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&OgA(A,e,g),g};const VgA=oA("debugpost"),bM={};function As(i,A){bM[i]=A}function zgA(i){return i.__type in bM?bM[i.__type]:(VgA&&i.__type&&console.warn("Unknown postprocessing type",i.__type,i),_g)}class Bu{constructor(){B(this,"components",[])}init(){var A;(A=this.components)==null||A.forEach(e=>e.init())}}WgA([dh([i=>zgA(i),_g])],Bu.prototype,"components",2);var jgA=Object.defineProperty,ZgA=Object.getOwnPropertyDescriptor,XgA=(i,A,e,t)=>{for(var g=t>1?void 0:t?ZgA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&jgA(A,e,g),g};class Qu extends _g{constructor(){super(...arguments);B(this,"preset")}get typeName(){return"Antialiasing"}onCreateEffect(){const e=new n9({preset:$Q.HIGH,edgeDetectionMode:DU.DEPTH});return this.preset.onValueChanged=t=>{e.applyPreset(t)},e}}XgA([y(Re)],Qu.prototype,"preset",2);As("Antialiasing",Qu);class kS{constructor(){B(this,"files",[])}get extensionName(){return"Audio"}onExportObject(A,e,t){const g=eA.getComponents(A,Ni);if(g.length)for(const I of g){if(!I.clip||!I.playOnAwake)continue;const o=I.clip.split("/").pop();this.files.includes(I.clip)||this.files.push(I.clip),e.addEventListener("serialize",(s,C)=>{s.appendLine(),s.beginBlock(`def SpatialAudio "${e.name}"`),s.appendLine(`uniform asset filePath = @audio/${o}@`),s.appendLine(`uniform token auralMode = "${I.spatialBlend>0?"spatial":"nonSpatial"}"`),s.appendLine(`uniform token playbackMode = "${I.loop?"loopFromStage":"onceFromStart"}"`),s.appendLine(`uniform float gain = ${I.volume}`),s.closeBlock()})}}async onAfterSerialize(A){for(const e of this.files){const t=e.split("/").pop(),o=await(await(await fetch(e)).blob()).arrayBuffer(),s=new Uint8Array(o);A.files["audio/"+t]=s}}}var $gA=Object.defineProperty,AIA=Object.getOwnPropertyDescriptor,pO=(i,A,e,t)=>{for(var g=t>1?void 0:t?AIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&$gA(A,e,g),g};const eIA=oA("debugmouth");class Eu extends mA{constructor(){super(...arguments);B(this,"idle",[]);B(this,"talking",[]);B(this,"marker",null);B(this,"voip",null);B(this,"lastMouthChangeTime",0);B(this,"mouthChangeLength",0)}awake(){setTimeout(()=>{this.voip=eA.findObjectOfType(xn,this.context),this.marker||(this.marker=eA.getComponentInParent(this.gameObject,Ig))},3e3)}update(){var g;if(!this.voip||this.context.time.frameCount%10!==0)return;let e=((g=this.marker)==null?void 0:g.connectionId)??null;if(!e){eIA&&(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(g=>g.visible=!1):this.talking.map(g=>g.visible=!1);for(let g=0;g<e.length;g++){const I=e[g];I&&(I.visible=g===t)}}}}pO([y(bA)],Eu.prototype,"idle",2);pO([y(bA)],Eu.prototype,"talking",2);class mF extends mA{constructor(){super(...arguments);B(this,"voip",null);B(this,"marker",null);B(this,"_startPosition",null)}awake(){this.voip=eA.findObjectOfType(xn,this.context),this.marker=eA.getComponentInParent(this.gameObject,Ig)}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());let g=t/100;this.gameObject.position.y=this._startPosition.y+g*.07}}var tIA=Object.defineProperty,iIA=Object.getOwnPropertyDescriptor,mS=(i,A,e,t)=>{for(var g=t>1?void 0:t?iIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&tIA(A,e,g),g};class TB extends mA{constructor(){super(...arguments);B(this,"eyes",[]);B(this,"lastBlinkTime",0);B(this,"blinkLength",0);B(this,"eyesOpen",!0);B(this,"state",null)}awake(){this.state=eA.getComponentInParent(this.gameObject,dg)}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([y(bA)],TB.prototype,"eyes",2);mS([y()],TB.prototype,"lastBlinkTime",2);mS([y()],TB.prototype,"blinkLength",2);mS([y()],TB.prototype,"eyesOpen",2);var gIA=Object.defineProperty,IIA=Object.getOwnPropertyDescriptor,GF=(i,A,e,t)=>{for(var g=t>1?void 0:t?IIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&gIA(A,e,g),g},AG;const fO=(AG=class extends mA{constructor(){super(...arguments);B(this,"head",null);B(this,"eyes",null);B(this,"target",null);B(this,"brain",null);B(this,"vec",new m);B(this,"currentTargetPoint",new m)}awake(){this.brain||(this.brain=eA.getComponentInParent(this.gameObject,sd)),this.brain||(console.log("No look at brain found, adding it now"),this.brain=eA.addNewComponent(this.gameObject,sd)),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=ye(A);this.currentTargetPoint.lerp(t,this.context.time.deltaTime/.1);const g=ye(this.head),I=this.vec.copy(this.currentTargetPoint).sub(g).normalize();if(I.length()<.1)return;const o=fO.forward;if(o.set(0,0,1),o.applyQuaternion(Oi(this.head)),o.dot(I)>.45)for(let C=0;C<e.length;C++)e[C].lookAt(this.currentTargetPoint)}}}},B(AG,"forward",new m(0,0,1)),AG);let Mh=fO;GF([y(bA)],Mh.prototype,"head",2);GF([y(bA)],Mh.prototype,"eyes",2);GF([y(bA)],Mh.prototype,"target",2);var oIA=Object.defineProperty,sIA=Object.getOwnPropertyDescriptor,MF=(i,A,e,t)=>{for(var g=t>1?void 0:t?sIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&oIA(A,e,g),g};class Rh extends mA{constructor(){super(...arguments);B(this,"length",1);B(this,"depthTest",!0);B(this,"isGizmo",!0);B(this,"_axes",null)}onEnable(){if(this.isGizmo&&!_d)return;this._axes||(this._axes=new ah(this.length)),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)}}MF([y()],Rh.prototype,"length",2);MF([y()],Rh.prototype,"depthTest",2);MF([y()],Rh.prototype,"isGizmo",2);class RF extends mA{constructor(){super(...arguments);B(this,"from");B(this,"to");B(this,"hint");B(this,"desiredDistance",1)}onEnable(){}update(){if(!this.from||!this.to||!this.hint)return;let e=ye(this.to).clone(),t=ye(this.from).clone(),g=e.distanceTo(t),I=e.clone();I.sub(t);let o=t.clone();o.add(e),o.multiplyScalar(.5);let s=ye(this.hint).clone();s.sub(o);let C=new m;C.crossVectors(s,I),C.crossVectors(I,C),C.normalize();let n=g*.5,a=Math.max(this.desiredDistance,n),r=Math.sqrt(a*a-n*n),Q=C.clone();Q.multiplyScalar(r),Q.add(o),di(this.gameObject,Q);let E=o.clone();E.sub(C),this.gameObject.lookAt(E)}}class GS{constructor(){B(this,"behaviours",[]);B(this,"behaviourComponents",[]);B(this,"behaviourComponentsCopy",[])}get extensionName(){return"Behaviour"}addBehavior(A){this.behaviours.push(A)}onBeforeBuildDocument(A){const e=[];return A.root.traverse(t=>{eA.foreachComponent(t,g=>{var o;const I=g;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)}),Promise.all(e)}onExportObject(A,e,t){var g;for(const I of this.behaviourComponents)(g=I.createBehaviours)==null||g.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 g of this.behaviours)g.writeTo(this,A.document,e);e.closeBlock()}}async onAfterSerialize(A){console.log("onAfterSerialize",this.behaviourComponentsCopy);for(const e of this.behaviourComponentsCopy)console.log("behaviour",e),typeof e.afterSerialize=="function"&&(console.log("beh has afterSerialize",e),e.afterSerialize.constructor.name==="AsyncFunction"?await e.afterSerialize(this,A):e.afterSerialize(this,A))}}var CIA=Object.defineProperty,nIA=Object.getOwnPropertyDescriptor,UF=(i,A,e,t)=>{for(var g=t>1?void 0:t?nIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&CIA(A,e,g),g};class YB extends _g{constructor(){super(...arguments);B(this,"threshold");B(this,"intensity");B(this,"scatter");B(this,"selectiveBloom",!0)}get typeName(){return"Bloom"}init(){this.threshold.defaultValue=1,this.intensity.defaultValue=0,this.scatter.defaultValue=.2,this.selectiveBloom?(this.threshold.valueProcessor=e=>e,this.intensity.valueProcessor=e=>e,this.scatter.valueProcessor=e=>1*Math.PI*(1-e)):(this.threshold.valueProcessor=e=>e,this.intensity.valueProcessor=e=>e,this.scatter.valueProcessor=e=>100*(1-e))}onCreateEffect(){let e;if(this.selectiveBloom){const t=e=new JH(this.context.scene,this.context.mainCamera,{blendFunction:qe.ADD,mipmapBlur:!0,luminanceThreshold:this.threshold.value,luminanceSmoothing:this.scatter.value,intensity:this.intensity.value});t.inverted=!0}else e=new kU;return this.intensity.onValueChanged=t=>{e.intensity=t},this.threshold.onValueChanged=t=>{e.luminanceMaterial.threshold=t},this.scatter.onValueChanged=t=>{e.luminancePass.enabled=!0,e.luminanceMaterial.smoothing=t},e}}UF([y(Re)],YB.prototype,"threshold",2);UF([y(Re)],YB.prototype,"intensity",2);UF([y(Re)],YB.prototype,"scatter",2);As("Bloom",YB);var aIA=Object.defineProperty,rIA=Object.getOwnPropertyDescriptor,Js=(i,A,e,t)=>{for(var g=t>1?void 0:t?rIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&aIA(A,e,g),g};class yC extends mA{constructor(){super(...arguments);B(this,"attachedRigidbody",null);B(this,"isTrigger",!1);B(this,"sharedMaterial")}get isCollider(){return!0}awake(){super.awake(),this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Xt))}start(){this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Xt))}onEnable(){this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Xt))}onDisable(){var e;(e=this.context.physics.engine)==null||e.removeBody(this)}}Js([y(Xt)],yC.prototype,"attachedRigidbody",2);Js([y()],yC.prototype,"isTrigger",2);Js([y()],yC.prototype,"sharedMaterial",2);class hu extends yC{constructor(){super(...arguments);B(this,"radius",.5);B(this,"center",new m(0,0,0))}onEnable(){var e;super.onEnable(),(e=this.context.physics.engine)==null||e.addSphereCollider(this,this.center,this.radius)}}Js([y()],hu.prototype,"radius",2);Js([y(m)],hu.prototype,"center",2);class cu extends yC{constructor(){super(...arguments);B(this,"size",new m(1,1,1));B(this,"center",new m(0,0,0))}onEnable(){var e;super.onEnable(),(e=this.context.physics.engine)==null||e.addBoxCollider(this,this.center,this.size)}}Js([y(m)],cu.prototype,"size",2);Js([y(m)],cu.prototype,"center",2);class lu extends yC{constructor(){super(...arguments);B(this,"sharedMesh");B(this,"convex",!1)}onEnable(){var e,t,g,I,o;if(super.onEnable(),(e=this.sharedMesh)!=null&&e.isMesh||this.gameObject instanceof yA&&(this.sharedMesh=this.gameObject),(t=this.sharedMesh)!=null&&t.isMesh)(g=this.context.physics.engine)==null||g.addMeshCollider(this,this.sharedMesh,this.convex,lg(this.gameObject));else{const s=this.sharedMesh;if(s!=null&&s.isGroup){console.warn(`MeshCollider mesh is a group "${(I=this.sharedMesh)==null?void 0:I.name}", adding all children as colliders. This is currently not fully supported (colliders can not be removed from world again)`,this);for(const C in s.children){const n=s.children[C];n.isMesh&&((o=this.context.physics.engine)==null||o.addMeshCollider(this,n,this.convex,lg(this.gameObject)))}}}}}Js([y()],lu.prototype,"convex",2);class Xa extends yC{constructor(){super(...arguments);B(this,"center",new m(0,0,0));B(this,"radius",.5);B(this,"height",2)}onEnable(){var e;super.onEnable(),(e=this.context.physics.engine)==null||e.addCapsuleCollider(this,this.center,this.height,this.radius)}}Js([y(m)],Xa.prototype,"center",2);Js([y()],Xa.prototype,"radius",2);Js([y()],Xa.prototype,"height",2);function FF(i){const A=i[AC];return A||(i.parent?FF(i.parent):null)}function Dy(i,A){if(!i)return;const e=i.material;if((e==null?void 0:e.isMaterial)===!0){const t=i.parent;t&&t.isText,e.side=A.doubleSided??!0?Jt:Tg,e.shadowSide=A.doubleSided?Jt:Tg,i.castShadow=A.castShadows?A.castShadows:!1,i.receiveShadow=A.receiveShadows?A.receiveShadows:!1}for(const t of i.children)Dy(t,A)}function tE(i,A,e){i[A]===void 0&&console.warn("Field",A,"is undefined on",i);const t=Proxy.revocable(i[A],{set(o,s,C,n){const a=o[s],r=Reflect.set(o,s,C,n);return e(C,a),r}}),g=t.revoke,I=i[A];return t.revoke=()=>{i[A]=I,g()},i[A]=t.proxy,t}const Wb=Symbol("Scheduled action");function BIA(i,A,e=so.OnBeforeRender){let t=i[Wb];t||(t=i[Wb]={});const g=A.name;t[e]||(t[e]={});const I=t[e];if(I[g])return;function*s(){A==null||A.call(i),I[g]=null}const C=i.startCoroutine(s(),e);I[g]=C}var QIA=Object.defineProperty,EIA=Object.getOwnPropertyDescriptor,HB=(i,A,e,t)=>{for(var g=t>1?void 0:t?EIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&QIA(A,e,g),g};const Im=oA("debugui"),om=oA("debuguilayout");class NF{constructor(){B(this,"width");B(this,"height")}}class KF{constructor(){B(this,"x");B(this,"y");B(this,"width");B(this,"height")}}const Cs=new m,wc=new qA,Af=new LA,DO=class extends Gs{constructor(){super(...arguments);B(this,"_anchoredPosition");B(this,"sizeDelta",new X(100,100));B(this,"pivot",new X(.5,.5));B(this,"anchorMin",new X(0,0));B(this,"anchorMax",new X(1,1));B(this,"offsetMin",new X(0,0));B(this,"offsetMax",new X(0,0));B(this,"lastMatrix");B(this,"rectBlock");B(this,"_transformNeedsUpdate",!1);B(this,"_initialPosition");B(this,"_parentRectTransform");B(this,"_lastUpdateFrame",-1);B(this,"_lastAnchoring");B(this,"_createdBlocks",[]);B(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 X),this._anchoredPosition}set anchoredPosition(A){this._anchoredPosition=A}get width(){if(this.anchorMin.x!==this.anchorMax.x&&this._parentRectTransform){const A=this._parentRectTransform.width,e=this.anchorMax.x-this.anchorMin.x;let t=A*e;return t+=this.sizeDelta.x,t}return this.sizeDelta.x}get height(){if(this.anchorMin.y!==this.anchorMax.y&&this._parentRectTransform){const A=this._parentRectTransform.height,e=this.anchorMax.y-this.anchorMin.y;let t=A*e;return t+=this.sizeDelta.y,t}return this.sizeDelta.y}awake(){super.awake(),this._anchoredPosition||(this._anchoredPosition=new X),this.lastMatrix=new qA,this.rectBlock=new bA,this.rectBlock.name=this.name,this._initialPosition=this.gameObject.position.clone(),this._initialPosition.z=0,tE(this,"_anchoredPosition",()=>{this.markDirty()}),tE(this,"sizeDelta",()=>{this.markDirty()}),tE(this,"pivot",()=>{this.markDirty()}),tE(this,"anchorMin",()=>{this.markDirty()}),tE(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(om?`${A.name} changed`:void 0)}get isDirty(){return this._transformNeedsUpdate||(this._transformNeedsUpdate=!this.lastMatrix.equals(this.gameObject.matrix)),this._transformNeedsUpdate}markDirty(){this._transformNeedsUpdate||(om&&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 g;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=eA.getComponentInParent(this.gameObject.parent,DO):this._parentRectTransform=void 0,this._transformNeedsUpdate=!1,om&&console.warn("RectTransform → ApplyTransform",this.name+" because "+A),this.isRoot()?this.Root.screenspace||(e.rotation.y=Math.PI):(e.matrix.identity(),e.matrixAutoUpdate=!1,Cs.set(0,0,0),this.applyPivot(Cs),e.matrix.setPosition(Cs.x,Cs.y,0),(this.gameObject.quaternion.x||this.gameObject.quaternion.y||this.gameObject.quaternion.z)&&(Af.copy(this.gameObject.quaternion),Af.x*=-1,Af.z*=-1,wc.makeRotationFromQuaternion(Af),e.matrix.premultiply(wc)),Cs.set(0,0,0),this.applyAnchoring(Cs),(g=this.Canvas)!=null&&g.screenspace?Cs.z+=.1:Cs.z+=.01,wc.identity(),wc.setPosition(Cs.x,Cs.y,Cs.z),e.matrix.premultiply(wc),e.matrix.scale(this.gameObject.scale)),this.lastMatrix.copy(this.gameObject.matrix);const t=!0;for(const I of pU(this.gameObject,Gs,t,1)){if(I===this||!I.activeAndEnabled)continue;const o=I;o.onParentRectTransformChanged&&o.onParentRectTransformChanged(this)}}applyAnchoring(A){this._lastAnchoring||(this._lastAnchoring=new X);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 g=0;const I=1-this.anchorMax.y-this.anchorMin.y;g-=t.height*.5*I,A.y+=g;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},Im&&console.log(this.name,A);const e=new DF(A);return this._createdBlocks.push(e),e}createNewText(A){Im&&console.log(A),A={...this.getBasicOptions(),...A},Im&&console.log(this.name,A);const e=new EO(A);return this._createdTextBlocks.push(e),e}};let yg=DO;HB([y(X)],yg.prototype,"anchoredPosition",1);HB([y(X)],yg.prototype,"sizeDelta",2);HB([y(X)],yg.prototype,"pivot",2);HB([y(X)],yg.prototype,"anchorMin",2);HB([y(X)],yg.prototype,"anchorMax",2);HB([y(X)],yg.prototype,"offsetMin",2);HB([y(X)],yg.prototype,"offsetMax",2);class hIA extends QO{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 g in e[t])A._simpleState__statesProperties[g]||(A._simpleState__statesProperties[g]=[]),A._simpleState__statesProperties[g].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 g in e)this._simpleState__statesProperties[g]||(this._simpleState__statesProperties[g]=[],t.push(g)),this._simpleState__statesProperties[g].push(A);for(const g of this._components)t.indexOf(g.id)>-1&&(this._simpleState__normalStyles[g.id]=g.inline?g.inline:g._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 cIA=Object.defineProperty,lIA=Object.getOwnPropertyDescriptor,yO=(i,A,e,t)=>{for(var g=t>1?void 0:t?lIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&cIA(A,e,g),g};class Uh extends mA{constructor(){super(...arguments);B(this,"effectColor");B(this,"effectDistance")}}yO([y(kt)],Uh.prototype,"effectColor",2);yO([y(X)],Uh.prototype,"effectDistance",2);var dIA=Object.defineProperty,uIA=Object.getOwnPropertyDescriptor,wO=(i,A,e,t)=>{for(var g=t>1?void 0:t?uIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&dIA(A,e,g),g};const ef={backgroundColor:new DA(1,1,1),backgroundOpacity:1,borderColor:new DA(1,1,1),borderOpacity:1};var eG;const dD=(eG=class extends Gs{constructor(){super(...arguments);B(this,"_alphaFactor",1);B(this,"raycastTarget",!0);B(this,"uiObject",null);B(this,"_color",null);B(this,"_rect",null);B(this,"_stateManager",null);B(this,"_currentlyCreatingPanel",!1)}get isGraphic(){return!0}get color(){return this._color||(this._color=new kt(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 kt(1,1,1,1)),this._color.copy(A))}setAlphaFactor(A){this._alphaFactor=A,this.onColorChanged()}get alphaFactor(){return this._alphaFactor}onColorChanged(){this.uiObject&&(ef.backgroundColor=this._color,ef.backgroundOpacity=this._color.alpha*this._alphaFactor,this.applyEffects(ef,this._alphaFactor),this.uiObject.set(ef),this.markDirty())}get m_Color(){return this._color}get rectTransform(){return this._rect||(this._rect=eA.getComponent(this.gameObject,yg)),this._rect}onParentRectTransformChanged(){var A;(A=this.uiObject)==null||A.set({width:this.rectTransform.width,height:this.rectTransform.height}),this.markDirty()}__internalNewInstanceCreated(){super.__internalNewInstanceCreated(),this._rect=null,this.uiObject=null,this._color&&(this._color=this._color.clone())}setState(A){this.makePanel(),this.uiObject&&(this.uiObject.setState(A),this==null||this.markDirty())}setupState(A){this.makePanel(),this.uiObject&&(this._stateManager||(this._stateManager=new hIA(this.uiObject)),this.uiObject.setupState(A.state,A.attributes))}setOptions(A){this.makePanel(),this.uiObject&&this.uiObject.set(A)}awake(){super.awake(),this.makePanel(),tE(this,"_color",()=>BIA(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;let A=.015;const 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()}onBeforeCreate(A){}onCreate(A){this.uiObject=this.rectTransform.createNewBlock(A),this.uiObject.name=this.name}onAfterCreated(){}applyEffects(A,e=1){var g;const t=(g=this.gameObject)==null?void 0:g.getComponent(Uh);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(A.colorSpace===Ie)if(dD.textureCache.has(A))A=dD.textureCache.get(A);else{const e=A.clone();e.colorSpace=sg,dD.textureCache.set(A,e),A=e}this.setOptions({backgroundImage:A,borderRadius:0,backgroundOpacity:this.color.alpha,backgroundSize:"stretch"})}else this.setOptions({backgroundImage:null,borderRadius:0,backgroundOpacity:this.color.alpha});this.markDirty()}onAfterAddedToScene(){super.onAfterAddedToScene(),this.shadowComponent&&(this.shadowComponent.offset=this.shadowComponent.position.z)}},B(eG,"textureCache",new Map),eG);let _B=dD;wO([y(kt)],_B.prototype,"color",1);wO([y()],_B.prototype,"raycastTarget",2);class du extends _B{constructor(){super(...arguments);B(this,"_flippedObject",!1)}onAfterCreated(){this.uiObject&&!this._flippedObject&&(this._flippedObject=!0,this.uiObject.scale.y*=-1)}}var pIA=Object.defineProperty,fIA=Object.getOwnPropertyDescriptor,MS=(i,A,e,t)=>{for(var g=t>1?void 0:t?fIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&pIA(A,e,g),g};let JF=class{constructor(){B(this,"texture",null);B(this,"rect")}};MS([y(He)],JF.prototype,"texture",2);let Fh=class extends du{constructor(){super(...arguments);B(this,"_sprite");B(this,"pixelsPerUnitMultiplier",1)}set image(e){this.sprite||(this.sprite=new JF),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 e,t,g,I,o,s,C,n;switch((t=(e=this.sprite)==null?void 0:e.texture)==null?void 0:t.name){case"InputFieldBackground":case"UISprite":case"Background":case"Knob":return!0}return((o=(I=(g=this.sprite)==null?void 0:g.texture)==null?void 0:I.image)==null?void 0:o.width)===32&&((n=(C=(s=this.sprite)==null?void 0:s.texture)==null?void 0:C.image)==null?void 0:n.height)===32}onBeforeCreate(e){var t,g;super.onBeforeCreate(e),this.isBuiltinSprite()&&(e.borderRadius=5/this.pixelsPerUnitMultiplier,((g=(t=this.sprite)==null?void 0:t.texture)==null?void 0:g.name)==="Knob"&&(e.borderRadius=999))}onAfterCreated(){var e;this.__didAwake&&(super.onAfterCreated(),!this.isBuiltinSprite()&&this.setTexture((e=this.sprite)==null?void 0:e.texture))}};MS([y(JF)],Fh.prototype,"sprite",1);MS([y()],Fh.prototype,"pixelsPerUnitMultiplier",2);class RS extends du{constructor(){super(...arguments);B(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))}}MS([y(He)],RS.prototype,"mainTexture",1);var DIA=Object.defineProperty,yIA=Object.getOwnPropertyDescriptor,ro=(i,A,e,t)=>{for(var g=t>1?void 0:t?yIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&DIA(A,e,g),g};const bQ=oA("debugbutton");class OB{constructor(){B(this,"colorMultiplier");B(this,"disabledColor");B(this,"fadeDuration");B(this,"highlightedColor");B(this,"normalColor");B(this,"pressedColor");B(this,"selectedColor")}}ro([y()],OB.prototype,"colorMultiplier",2);ro([y(kt)],OB.prototype,"disabledColor",2);ro([y()],OB.prototype,"fadeDuration",2);ro([y(kt)],OB.prototype,"highlightedColor",2);ro([y(kt)],OB.prototype,"normalColor",2);ro([y(kt)],OB.prototype,"pressedColor",2);ro([y(kt)],OB.prototype,"selectedColor",2);class Yn extends mA{constructor(){super(...arguments);B(this,"onClick");B(this,"_isHovered",!1);B(this,"colors");B(this,"transition");B(this,"animationTriggers");B(this,"animator");B(this,"_interactable",!0);B(this,"_requestedAnimatorTrigger");B(this,"_isInit",!1);B(this,"_image")}onPointerEnter(e){var t,g;bQ&&console.log("Button Enter",(t=this.animationTriggers)==null?void 0:t.highlightedTrigger,this.animator),this._isHovered=!0,this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.highlightedTrigger):this.transition===1&&this.colors&&((g=this._image)==null||g.setState("hovered")),this.context.input.setCursorPointer())}onPointerExit(){var e,t;bQ&&console.log("Button Exit",(e=this.animationTriggers)==null?void 0:e.highlightedTrigger,this.animator),this._isHovered=!1,this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.normalTrigger):this.transition===1&&this.colors&&((t=this._image)==null||t.setState("normal")),this.context.input.setCursorNormal())}onPointerDown(e){var t,g;bQ&&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&&((g=this._image)==null||g.setState("pressed")))}onPointerUp(e){var t,g;bQ&&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&&((g=this._image)==null||g.setState(this._isHovered?"hovered":"normal")))}onPointerClick(e){var t;this.interactable&&e.pointerId===0&&(bQ&&(console.warn("Button Click",this.onClick),Mi("CLICKED button "+this.name+" at "+this.context.time.frameCount)),(t=this.onClick)==null||t.invoke())}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(),bQ&&console.log(this),this._isInit=!1,this.init()}start(){var e;(e=this._image)==null||e.setInteractable(this.interactable)}onEnable(){super.onEnable()}*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=eA.getComponent(this.gameObject,Fh),this._image&&(this.stateSetup(this._image),this.interactable?this._image.setState("normal"):this._image.setState("disabled")))}stateSetup(e){var E,h,l,d,c;e.setInteractable(this.interactable);const t=this.getFinalColor(e.color,(E=this.colors)==null?void 0:E.normalColor),g={state:"normal",attributes:{backgroundColor:t,backgroundOpacity:t.alpha}};e.setupState(g);const I=this.getFinalColor(e.color,(h=this.colors)==null?void 0:h.highlightedColor),o={state:"hovered",attributes:{backgroundColor:I,backgroundOpacity:I.alpha}};e.setupState(o);const s=this.getFinalColor(e.color,(l=this.colors)==null?void 0:l.pressedColor),C={state:"pressed",attributes:{backgroundColor:s,backgroundOpacity:s.alpha}};e.setupState(C);const n=this.getFinalColor(e.color,(d=this.colors)==null?void 0:d.selectedColor),a={state:"selected",attributes:{backgroundColor:n,backgroundOpacity:n.alpha}};e.setupState(a);const r=this.getFinalColor(e.color,(c=this.colors)==null?void 0:c.disabledColor),Q={state:"disabled",attributes:{backgroundColor:r,backgroundOpacity:r.alpha}};e.setupState(Q)}getFinalColor(e,t){return t?e.clone().multiply(t):e.clone()}}ro([y(FI)],Yn.prototype,"onClick",2);ro([y()],Yn.prototype,"colors",2);ro([y()],Yn.prototype,"transition",2);ro([y()],Yn.prototype,"animationTriggers",2);ro([y(QI)],Yn.prototype,"animator",2);ro([y()],Yn.prototype,"interactable",1);var wIA=Object.defineProperty,SIA=Object.getOwnPropertyDescriptor,qi=(i,A,e,t)=>{for(var g=t>1?void 0:t?SIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&wIA(A,e,g),g};const Vb=oA("debuguilayout");class Er{constructor(){B(this,"left",0);B(this,"right",0);B(this,"top",0);B(this,"bottom",0)}get vertical(){return this.top+this.bottom}get horizontal(){return this.left+this.right}}qi([y()],Er.prototype,"left",2);qi([y()],Er.prototype,"right",2);qi([y()],Er.prototype,"top",2);qi([y()],Er.prototype,"bottom",2);class Bo extends mA{constructor(){super(...arguments);B(this,"_rectTransform",null);B(this,"_needsUpdate",!1);B(this,"childAlignment",0);B(this,"reverseArrangement",!1);B(this,"spacing",0);B(this,"padding");B(this,"minWidth",0);B(this,"minHeight",0);B(this,"flexibleHeight",0);B(this,"flexibleWidth",0);B(this,"preferredHeight",0);B(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&&(Vb&&console.warn("Layout Update",this.context.time.frame,this.name),this._needsUpdate=!1,this.onCalculateLayout(this._rectTransform))}start(){this._needsUpdate=!0}onEnable(){Vb&&console.log(this.name,this),this._rectTransform=this.gameObject.getComponent(yg);const e=this.gameObject.getComponentInParent(wg);e&&e.registerLayoutGroup(this),this._needsUpdate=!0}onDisable(){const e=this.gameObject.getComponentInParent(wg);e&&e.unregisterLayoutGroup(this)}set m_Spacing(e){e!==this.spacing&&(this._needsUpdate=!0,this.spacing=e)}get m_Spacing(){return this.spacing}}qi([y()],Bo.prototype,"childAlignment",2);qi([y()],Bo.prototype,"reverseArrangement",2);qi([y()],Bo.prototype,"spacing",2);qi([y(Er)],Bo.prototype,"padding",2);qi([y()],Bo.prototype,"minWidth",2);qi([y()],Bo.prototype,"minHeight",2);qi([y()],Bo.prototype,"flexibleHeight",2);qi([y()],Bo.prototype,"flexibleWidth",2);qi([y()],Bo.prototype,"preferredHeight",2);qi([y()],Bo.prototype,"preferredWidth",2);class hr extends Bo{constructor(){super(...arguments);B(this,"childControlHeight",!0);B(this,"childControlWidth",!0);B(this,"childForceExpandHeight",!1);B(this,"childForceExpandWidth",!1);B(this,"childScaleHeight",!1);B(this,"childScaleWidth",!1)}onCalculateLayout(e){var R;const t=this.primaryAxis,g=e.width;let I=g;const o=e.height;let s=o;I-=this.padding.horizontal,s-=this.padding.vertical,t==="x"?this.padding.horizontal:this.padding.vertical;const C=t==="x",n=C?"y":"x",a=C?this.childControlWidth:this.childControlHeight,r=C?this.childControlHeight:this.childControlWidth,Q=C?this.childForceExpandWidth:this.childForceExpandHeight,E=C?this.childForceExpandHeight:this.childForceExpandWidth,h=C?s:I,l=C?g:o,d=.5*(C?this.childAlignment%3:Math.floor(this.childAlignment/3));let c=0;C?c+=this.padding.left:c+=this.padding.top;let p=0,u=0;for(let k=0;k<this.gameObject.children.length;k++){const G=this.gameObject.children[k],J=eA.getComponent(G,yg);J!=null&&J.activeAndEnabled&&(u+=1,C?p+=J.width:p+=J.height)}let f=0;const D=this.spacing*(u-1);if(Q||a){let k=0;C?k=I-=D:k=s-=D,u>0&&(f=k/u)}let w=0;w+=this.padding.left,w-=this.padding.right,d!==0&&(c=l-p,c*=d,c-=D*d,C?(c-=this.padding.right*d,c+=this.padding.left*(1-d),c<this.padding.left&&(c=this.padding.left)):(c-=this.padding.bottom*d,c+=this.padding.top*(1-d),c<this.padding.top&&(c=this.padding.top)));let M=1;for(let k=0;k<this.gameObject.children.length;k++){const G=this.gameObject.children[k],J=eA.getComponent(G,yg);if(J!=null&&J.activeAndEnabled){(R=J.pivot)==null||R.set(.5,.5),J.anchorMin.set(0,1),J.anchorMax.set(0,1);const P=g*.5+w*.5;J.anchoredPosition.x!==P&&(J.anchoredPosition.x=P);const L=o*-.5;J.anchoredPosition.y!==L&&(J.anchoredPosition.y=L),E&&r&&J.sizeDelta[n]!==h&&(J.sizeDelta[n]=h),Q&&a&&J.sizeDelta[t]!==f&&(J.sizeDelta[t]=f);const T=C?J.width:J.height;let _=T*.5;if(c+=_,Q){let V=f*M-f*.5;V>c&&(c=V-f*.5+T+this.padding.left,c-=_)}let tA=c;t==="y"&&(tA=-tA),J.anchoredPosition[t]!==tA&&(J.anchoredPosition[t]=tA),c+=_,c+=this.spacing,M+=1}}}}qi([y()],hr.prototype,"childControlHeight",2);qi([y()],hr.prototype,"childControlWidth",2);qi([y()],hr.prototype,"childForceExpandHeight",2);qi([y()],hr.prototype,"childForceExpandWidth",2);qi([y()],hr.prototype,"childScaleHeight",2);qi([y()],hr.prototype,"childScaleWidth",2);class qF extends hr{get primaryAxis(){return"y"}}class bF extends hr{get primaryAxis(){return"x"}}class xF extends Bo{onCalculateLayout(){}}var kIA=Object.defineProperty,mIA=Object.getOwnPropertyDescriptor,wC=(i,A,e,t)=>{for(var g=t>1?void 0:t?mIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&kIA(A,e,g),g},SO=(i=>(i[i.ScreenSpaceOverlay=0]="ScreenSpaceOverlay",i[i.ScreenSpaceCamera=1]="ScreenSpaceCamera",i[i.WorldSpace=2]="WorldSpace",i[i.Undefined=-1]="Undefined",i))(SO||{});const sm=oA("debuguilayout"),kO=class extends nu{constructor(){super(...arguments);B(this,"_renderOnTop");B(this,"_depthWrite",!1);B(this,"_doubleSided",!0);B(this,"_castShadows",!1);B(this,"_receiveShadows",!1);B(this,"_renderMode",-1);B(this,"_rootCanvas");B(this,"_scaleFactor",1);B(this,"worldCamera");B(this,"planeDistance",-1);B(this,"_boundRenderSettingsChanged",this.onRenderSettingsChanged.bind(this));B(this,"previousParent",null);B(this,"_lastMatrixWorld",null);B(this,"_rectTransforms",[]);B(this,"_layoutGroups",new Map);B(this,"onBeforeRenderRoutine",()=>{var A,e,t,g;if(this.context.isInVR){this.onUpdateRenderMode(),this.handleLayoutUpdates(),(A=this.shadowComponent)==null||A.updateMatrixWorld(!0),(e=this.shadowComponent)==null||e.updateWorldMatrix(!0,!0),II.ensureUpdateMeshUI(em,this.context);return}this.previousParent=this.gameObject.parent,this.renderOnTop||this.screenspace?this.gameObject.removeFromParent():(this.onUpdateRenderMode(),this.handleLayoutUpdates(),(t=this.shadowComponent)==null||t.updateMatrixWorld(!0),(g=this.shadowComponent)==null||g.updateWorldMatrix(!0,!0),II.ensureUpdateMeshUI(em,this.context))});B(this,"onAfterRenderRoutine",()=>{var A,e;if(!this.context.isInVR){if((this.screenspace||this.renderOnTop)&&this.previousParent&&this.context.mainCamera){if(this.screenspace){const I=this.context.mainCamera;I==null||I.add(this.gameObject)}else this.previousParent.add(this.gameObject);const t=this.context.renderer.autoClear,g=this.context.renderer.autoClearColor;this.context.renderer.autoClear=!1,this.context.renderer.autoClearColor=!1,this.context.renderer.clearDepth(),this.onUpdateRenderMode(!0),this.handleLayoutUpdates(),(A=this.shadowComponent)==null||A.updateMatrixWorld(!0),II.ensureUpdateMeshUI(em,this.context),this.context.renderer.render(this.gameObject,this.context.mainCamera),this.context.renderer.autoClear=t,this.context.renderer.autoClearColor=g,this.previousParent.add(this.gameObject)}(e=this._lastMatrixWorld)==null||e.copy(this.gameObject.matrixWorld)}});B(this,"_updateRenderSettingsRoutine");B(this,"_activeRenderMode",-1);B(this,"_lastWidth",-1);B(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 kO||(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,sm&&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 qA,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)}handleLayoutUpdates(){this._lastMatrixWorld===null&&(this._lastMatrixWorld=new qA);const A=!this._lastMatrixWorld.equals(this.gameObject.matrixWorld);sm&&A&&console.log("Canvas Layout changed",this.context.time.frameCount,this.name);let e=!1;for(const t of this._rectTransforms){A&&t.markDirty();let g=this._layoutGroups.get(t.gameObject);t.isDirty&&!g&&(g=t.gameObject.getComponentInParent(Bo)),(t.isDirty||g!=null&&g.isDirty)&&(sm&&!e&&console.log("CANVAS UPDATE ### "+t.name+" ##################################### "+this.context.time.frame),g==null||g.updateLayout(),t.updateTransform())}}applyRenderSettings(){this.onRenderSettingsChanged()}onRenderSettingsChanged(){this._updateRenderSettingsRoutine||(this._updateRenderSettingsRoutine=this.startCoroutine(this._updateRenderSettingsDelayed(),so.OnBeforeRender))}*_updateRenderSettingsDelayed(){if(yield,this._updateRenderSettingsRoutine=void 0,this.shadowComponent){this.onUpdateRenderMode(),Dy(this.shadowComponent,this);for(const A of eA.getComponentsInChildren(this.gameObject,Gs))Dy(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,.15)),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 g=t+.01;this.gameObject.position.x=0,this.gameObject.position.y=0,this.gameObject.position.z=-g,this.gameObject.quaternion.identity();const I=this.gameObject.getComponent(yg);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,C=2*Math.tan(s/2)*Math.abs(g);this.gameObject.scale.x=C/this.context.domHeight,this.gameObject.scale.y=C/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 wg=kO;wC([y()],wg.prototype,"renderOnTop",1);wC([y()],wg.prototype,"depthWrite",1);wC([y()],wg.prototype,"doubleSided",1);wC([y()],wg.prototype,"castShadows",1);wC([y()],wg.prototype,"receiveShadows",1);wC([y()],wg.prototype,"renderMode",1);wC([y(wg)],wg.prototype,"rootCanvas",1);wC([y()],wg.prototype,"scaleFactor",1);wC([y(Ot)],wg.prototype,"worldCamera",2);wC([y()],wg.prototype,"planeDistance",2);var GIA=Object.defineProperty,MIA=Object.getOwnPropertyDescriptor,LF=(i,A,e,t)=>{for(var g=t>1?void 0:t?MIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&GIA(A,e,g),g};class $a extends mA{constructor(){super(...arguments);B(this,"_alpha",1);B(this,"interactable",!0);B(this,"blocksRaycasts",!0);B(this,"_isDirty",!1);B(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(),so.OnBeforeRender))}*applyChangesDelayed(){this._isDirty=!1,this.applyChangesNow()}applyChangesNow(){for(const e of eA.getComponentsInChildren(this.gameObject,Gs,this._buffer)){const t=e;t.setAlphaFactor&&t.setAlphaFactor(this._alpha)}}}LF([y()],$a.prototype,"alpha",1);LF([y()],$a.prototype,"interactable",2);LF([y()],$a.prototype,"blocksRaycasts",2);var RIA=Object.defineProperty,UIA=Object.getOwnPropertyDescriptor,xt=(i,A,e,t)=>{for(var g=t>1?void 0:t?UIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&RIA(A,e,g),g};class PB extends mA{constructor(){super(...arguments);B(this,"object");B(this,"target");B(this,"duration",1);B(this,"relativeMotion",!1);B(this,"coroutine",null);B(this,"targetPos",new m);B(this,"targetRot",new LA);B(this,"targetScale",new m)}*moveToTarget(){if(!this.target||!this.object)return;const e=ye(this.object).clone(),t=ye(this.target).clone(),g=Oi(this.object).clone(),I=Oi(this.target).clone(),o=lg(this.object).clone(),s=lg(this.target).clone(),C=e.distanceTo(t),n=g.angleTo(I),a=o.distanceTo(s);if(C<.01&&n<.01&&a<.01){di(this.object,t),qI(this.object,I),XG(this.object,s),this.coroutine=null;return}let r=0,Q=0;for(;r<1;)r+=this.context.time.deltaTime/this.duration,r>1&&(r=1),Q=r<.5?4*r*r*r:1-Math.pow(-2*r+2,3)/2,this.targetPos.lerpVectors(e,t,Q),this.targetRot.slerpQuaternions(g,I,Q),this.targetScale.lerpVectors(o,s,Q),di(this.object,this.targetPos),qI(this.object,this.targetRot),XG(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(),g=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 C=0,n=0;for(;C<1;)C+=this.context.time.deltaTime/this.duration,C>1&&(C=1),n=C<.5?4*C*C*C:1-Math.pow(-2*C+2,3)/2,this.object.position.lerpVectors(e,this.targetPos,n),this.object.quaternion.slerpQuaternions(t,this.targetRot,n),this.object.scale.lerpVectors(g,this.targetScale,n),yield;this.coroutine=null}onPointerClick(){this.coroutine&&this.stopCoroutine(this.coroutine),this.relativeMotion?this.coroutine=this.startCoroutine(this.moveRelative()):this.coroutine=this.startCoroutine(this.moveToTarget())}beforeCreateDocument(e){var t;if(this.target&&this.object&&this.gameObject){const g=new pg("Move to "+((t=this.target)==null?void 0:t.name),NI.tapTrigger(this.gameObject),Qt.transformAction(this.object,this.target,this.duration,this.relativeMotion?kM.Relative:kM.Absolute));e.addBehavior(g)}}}xt([y(bA)],PB.prototype,"object",2);xt([y(bA)],PB.prototype,"target",2);xt([y()],PB.prototype,"duration",2);xt([y()],PB.prototype,"relativeMotion",2);var tG;const Zr=(tG=class extends mA{constructor(){super(...arguments);B(this,"materialToSwitch");B(this,"variantMaterial");B(this,"fadeDuration",0);B(this,"_objectsWithThisMaterial",[]);B(this,"selfModel");B(this,"targetModels")}awake(){if(this.variantMaterial&&this.materialToSwitch){const A=eA.findObjectsOfType(_t);for(const e of A)e.sharedMaterial===this.materialToSwitch&&this._objectsWithThisMaterial.push(e)}}onPointerClick(){if(this.variantMaterial)for(const A of this._objectsWithThisMaterial)A.sharedMaterial=this.variantMaterial}async beforeCreateDocument(A,e){this.targetModels=[],Zr._materialTriggersPerId={},this.materialToSwitch&&await jI.assignTextureLOD(this.context,this.sourceId,this.materialToSwitch,0),this.variantMaterial&&await jI.assignTextureLOD(this.context,this.sourceId,this.variantMaterial,0)}createBehaviours(A,e,t){this._objectsWithThisMaterial.find(I=>I.gameObject.uuid===e.uuid)&&this.targetModels.push(e),this.gameObject.uuid===e.uuid&&(this.selfModel=e,this.materialToSwitch&&(Zr._materialTriggersPerId[this.materialToSwitch.uuid]||(Zr._materialTriggersPerId[this.materialToSwitch.uuid]=[]),Zr._materialTriggersPerId[this.materialToSwitch.uuid].push(this)))}afterCreateDocument(A,e){if(!this.materialToSwitch)return;const t=Zr._materialTriggersPerId[this.materialToSwitch.uuid];if(t){const g={};for(const o of t){const s=o.createVariants();s&&s.length>0&&(g[o.selfModel.uuid]=s)}const I=[];for(const o of t){for(const s in g)s!==o.selfModel.uuid&&I.push(g[s]);o.createAndAttachBehaviors(A,g[o.selfModel.uuid],I)}}delete Zr._materialTriggersPerId[this.materialToSwitch.uuid]}createAndAttachBehaviors(A,e,t){const g=[],I=[],o=Math.max(0,this.fadeDuration);for(const s of this.targetModels){const C=Qt.fadeAction(s,o,!1);I.push(C)}for(const s of t)I.push(Qt.fadeAction(s,o,!1));for(const s of e)g.push(Qt.fadeAction(s,o,!1)),I.push(Qt.fadeAction(s,o,!0));A.addBehavior(new pg("Select "+this.selfModel.name,NI.tapTrigger(this.selfModel),Qt.parallel(...I))),A.addBehavior(new pg("Start hidden "+this.selfModel.name,NI.sceneStartTrigger(),Qt.parallel(...g)))}createVariants(){if(!this.variantMaterial)return null;const A=[];for(const e of this.targetModels){const t=e.clone();t.name+=" variant_"+this.variantMaterial.name,t.name=t.name.replace(/\s/g,"_"),t.material=this.variantMaterial,t.geometry=e.geometry,t.matrix=e.matrix,(!e.parent||!e.parent.isEmpty())&&GI.createEmptyParent(e),e.parent&&e.parent.add(t),A.push(t)}return A}},B(tG,"_materialTriggersPerId",{}),tG);let Nh=Zr;xt([y(Ke)],Nh.prototype,"materialToSwitch",2);xt([y(Ke)],Nh.prototype,"variantMaterial",2);xt([y()],Nh.prototype,"fadeDuration",2);class Kh extends mA{constructor(){super(...arguments);B(this,"target");B(this,"toggleOnClick",!1);B(this,"targetState",!0);B(this,"hideSelf",!0);B(this,"selfModel");B(this,"otherModel");B(this,"toggleModel");B(this,"stateBeforeCreatingDocument",!1)}onPointerClick(){!this.toggleOnClick&&this.hideSelf&&(this.gameObject.visible=!1),this.target&&(this.target.visible=this.toggleOnClick?!this.target.visible:this.targetState)}createBehaviours(e,t,g){t.uuid===this.gameObject.uuid&&(this.selfModel=t)}beforeCreateDocument(){this.stateBeforeCreatingDocument=this.gameObject.visible,this.gameObject.visible=!0}afterCreateDocument(e,t){if(this.target){if(this.otherModel=t.document.findById(this.target.uuid),this.selfModel&&this.otherModel){let g=this.hideSelf;this.targetState,this.toggleOnClick&&(g=!0,this.target.visible,(!this.selfModel.parent||this.selfModel.parent.isEmpty())&&N_.createEmptyParent(this.selfModel),this.toggleModel=this.selfModel.clone(),this.toggleModel.name+="_toggle",this.selfModel.parent.add(this.toggleModel));const I=[];if(g&&I.push(Qt.fadeAction(this.selfModel,0,!1)),this.toggleModel&&I.push(Qt.fadeAction(this.toggleModel,0,!0)),I.push(Qt.fadeAction(this.otherModel,0,this.targetState)),e.addBehavior(new pg("Toggle_"+this.selfModel.name+"_hideSelf",NI.tapTrigger(this.selfModel),Qt.sequence(...I))),this.toggleOnClick&&this.toggleModel){const o=[];o.push(Qt.fadeAction(this.toggleModel,0,!1)),o.push(Qt.fadeAction(this.selfModel,0,!0)),o.push(Qt.fadeAction(this.otherModel,0,!this.targetState)),e.addBehavior(new pg("Toggle_"+this.selfModel.name+"_toggleSelf",NI.tapTrigger(this.toggleModel),Qt.sequence(...o))),e.addBehavior(new pg("HideOnStart_"+this.gameObject.name,NI.sceneStartTrigger(),Qt.fadeAction(this.toggleModel,0,!1)))}}this.gameObject.visible=this.stateBeforeCreatingDocument}}}xt([y(bA)],Kh.prototype,"target",2);xt([y()],Kh.prototype,"targetState",2);xt([y()],Kh.prototype,"hideSelf",2);class vF extends mA{start(){this.gameObject.visible=!1}createBehaviours(A,e,t){e.uuid===this.gameObject.uuid&&A.addBehavior(new pg("HideOnStart_"+this.gameObject.name,NI.sceneStartTrigger(),Qt.fadeAction(e,0,!1)))}beforeCreateDocument(){this.gameObject.visible=!0}afterCreateDocument(){this.gameObject.visible=!1}}class Jh extends mA{constructor(){super(...arguments);B(this,"target");B(this,"duration",.5);B(this,"motionType",YU.bounce)}beforeCreateDocument(){}createBehaviours(e,t,g){if(this.target&&t.uuid===this.gameObject.uuid){const I=new pg("emphasize "+this.name,NI.tapTrigger(this.gameObject),Qt.emphasize(this.target,this.duration,this.motionType,void 0,"basic"));e.addBehavior(I)}}afterCreateDocument(e,t){}}xt([y()],Jh.prototype,"target",2);xt([y()],Jh.prototype,"duration",2);xt([y()],Jh.prototype,"motionType",2);class qh extends mA{constructor(){super(...arguments);B(this,"target");B(this,"clip","");B(this,"toggleOnClick",!1)}onPointerClick(){if(!(!this.target&&!this.clip)){if(!this.target){const e=this.gameObject.addNewComponent(Ni);e&&(e.spatialBlend=1,e.volume=1,e.loop=!1,this.target=e)}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,g){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)return;const o=this.target?this.target.gameObject:this.gameObject,s=I.split("/").pop(),C=this.target?this.target.volume:1,n=this.target&&this.target.spatialBlend==0?mM.NonSpatial:mM.Spatial,a=new pg("playAudio "+this.name,NI.tapTrigger(this.gameObject),Qt.playAudioAction(o,"audio/"+s,L_.Play,C,n));e.addBehavior(a)}}async afterSerialize(e,t){if(!this.target&&!this.clip)return;const g=this.clip?this.clip:this.target?this.target.clip:void 0;if(!g)return;const I=g.split("/").pop(),C=await(await(await fetch(this.clip)).blob()).arrayBuffer(),n=new Uint8Array(C);t.files["audio/"+I]=n}}xt([y(Ni)],qh.prototype,"target",2);xt([y(URL)],qh.prototype,"clip",2);xt([y()],qh.prototype,"toggleOnClick",2);var iG;const iE=(iG=class extends mA{constructor(){super(...arguments);B(this,"target");B(this,"animator");B(this,"stateName");B(this,"stateNameAfterPlaying");B(this,"loopAfterPlaying",!1);B(this,"selfModel");B(this,"stateAnimationModel");B(this,"stateAnimation");B(this,"stateAfterPlayingAnimationModel");B(this,"stateAfterPlayingAnimation")}onPointerClick(){var A;this.target&&this.stateName&&((A=this.animator)==null||A.play(this.stateName,0,0,.1))}createBehaviours(A,e,t){e.uuid===this.gameObject.uuid&&(this.selfModel=e)}onAfterHierarchy(){iE.animationActions=[]}afterCreateDocument(A,e){if(!this.stateAnimation||!this.stateAnimationModel)return;e.document.traverse(g=>{var I,o;if(g.uuid===((I=this.target)==null?void 0:I.uuid)&&this.stateAnimation){const s=[];let C=iE.animationActions.find(a=>a.affectedObjects==g&&a.start==this.stateAnimation.start&&a.duration==this.stateAnimation.duration);if(C||(C=Qt.startAnimationAction(g,this.stateAnimation.start,this.stateAnimation.duration),iE.animationActions.push(C)),s.push(C),this.stateAfterPlayingAnimation&&this.stateAfterPlayingAnimationModel){let a=iE.animationActions.find(Q=>Q.affectedObjects==g&&Q.start==this.stateAfterPlayingAnimation.start&&Q.duration==this.stateAfterPlayingAnimation.duration);a||(a=Qt.startAnimationAction(g,this.stateAfterPlayingAnimation.start,this.stateAfterPlayingAnimation.duration),iE.animationActions.push(a));const r=Qt.sequence(a);this.loopAfterPlaying&&r.makeLooping(),s.push(r)}const n=new pg("tap "+this.name+" for "+this.stateName+" on "+((o=this.target)==null?void 0:o.name),NI.tapTrigger(this.selfModel),Qt.sequence(...s));A.addBehavior(n)}})}createAnimation(A,e,t){var g,I,o,s;if(this.target&&this.animator){const C=(I=(g=this.animator)==null?void 0:g.runtimeAnimatorController)==null?void 0:I.findState(this.stateName);this.stateAnimationModel=e,this.stateAnimation=A.registerAnimation(this.target,C==null?void 0:C.motion.clip);const n=(s=(o=this.animator)==null?void 0:o.runtimeAnimatorController)==null?void 0:s.findState(this.stateNameAfterPlaying);this.stateAfterPlayingAnimationModel=e,this.stateAfterPlayingAnimation=A.registerAnimation(this.target,n==null?void 0:n.motion.clip)}}},B(iG,"animationActions",[]),iG);let cr=iE;xt([y(bA)],cr.prototype,"target",2);xt([y(QI)],cr.prototype,"animator",2);xt([y()],cr.prototype,"stateName",2);xt([y()],cr.prototype,"stateNameAfterPlaying",2);xt([y()],cr.prototype,"loopAfterPlaying",2);class bh extends mA{constructor(){super(...arguments);B(this,"target")}getType(){}getDuration(){}}xt([y(bA)],bh.prototype,"target",2);class uu extends mA{constructor(){super(...arguments);B(this,"target")}}xt([y(bh)],uu.prototype,"target",2);class pu extends bh{constructor(){super(...arguments);B(this,"type",1);B(this,"duration",1)}getType(){switch(this.type){case 1:return"hide";case 0:return"show"}}getDuration(){return this.duration}}xt([y()],pu.prototype,"type",2);xt([y()],pu.prototype,"duration",2);class TF extends uu{}var FIA=Object.defineProperty,NIA=Object.getOwnPropertyDescriptor,Hn=(i,A,e,t)=>{for(var g=t>1?void 0:t?NIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&FIA(A,e,g),g};class WB extends mA{constructor(){super(...arguments);B(this,"center",new m(0,0,0));B(this,"radius",.5);B(this,"height",2);B(this,"_rigidbody",null);B(this,"_activeGroundCollisions",new Set)}get rigidbody(){return this._rigidbody?this._rigidbody:(this._rigidbody=this.gameObject.getComponent(Xt),this._rigidbody||(this._rigidbody=this.gameObject.addNewComponent(Xt)),this.rigidbody)}onEnable(){let e=this.rigidbody,t=this.gameObject.getComponent(Xa);t||(t=this.gameObject.addNewComponent(Xa)),t.center.copy(this.center),t.radius=this.radius,t.height=this.height,this.gameObject.rotation.x=0,this.gameObject.rotation.z=0,e.lockRotationX=!0,e.lockRotationY=!0,e.lockRotationZ=!0}move(e){this.gameObject.position.add(e)}onCollisionEnter(e){for(const t of e.contacts)if(t.normal.y>.1){this._activeGroundCollisions.add(e);break}}onCollisionExit(e){this._activeGroundCollisions.delete(e)}get isGrounded(){return this._activeGroundCollisions.size>0}}Hn([y(m)],WB.prototype,"center",2);Hn([y()],WB.prototype,"radius",2);Hn([y()],WB.prototype,"height",2);class _n extends mA{constructor(){super(...arguments);B(this,"controller");B(this,"movementSpeed",2);B(this,"rotationSpeed",2);B(this,"jumpForce",1);B(this,"doubleJumpForce",2);B(this,"animator");B(this,"lookForward",!0);B(this,"_currentSpeed",new m(0,0,0));B(this,"_currentAngularSpeed",new m(0,0,0));B(this,"_temp",new m(0,0,0));B(this,"_jumpCount",0);B(this,"_currentRotation");B(this,"_raycastOptions",new Fs)}awake(){this._currentRotation=new LA}update(){var n,a,r,Q,E,h,l,d,c,p,u;(n=this.controller)!=null&&n.isGrounded&&(this._jumpCount=0,this.doubleJumpForce>0&&((a=this.animator)==null||a.setBool("doubleJump",!1)));const e=this.context.input.isKeyPressed("w"),t=this.context.input.isKeyPressed("s"),g=this.context.input.isKeyPressed("a"),I=this.context.input.isKeyPressed("d"),o=this.context.input.isKeyDown(" "),s=(e?1:0)+(t?-1:0);this._currentSpeed.z+=s*this.movementSpeed*this.context.time.deltaTime,(r=this.animator)==null||r.setBool("running",s!=0),(E=this.animator)==null||E.setBool("jumping",((Q=this.controller)==null?void 0:Q.isGrounded)===!0&&o),this._temp.copy(this._currentSpeed),this._temp.applyQuaternion(this.gameObject.quaternion),this.controller?this.controller.move(this._temp):this.gameObject.position.add(this._temp);const C=(g?1:0)+(I?-1:0);if(this._currentAngularSpeed.y+=te.toRadians(C*this.rotationSpeed)*this.context.time.deltaTime,this.lookForward&&Math.abs(this._currentAngularSpeed.y)<.01){const f=this.context.mainCameraComponent.forward;f.y=0,f.normalize(),this._currentRotation.setFromUnitVectors(new m(0,0,1),f),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&&o&&this.jumpForce>0){let f=(h=this.controller)==null?void 0:h.isGrounded;if(this.doubleJumpForce>0&&!((l=this.controller)!=null&&l.isGrounded)&&this._jumpCount===1&&(f=!0,(d=this.animator)==null||d.setBool("doubleJump",!0)),f){this._jumpCount+=1;const D=this.controller.rigidbody,w=this._jumpCount===2?this.doubleJumpForce:this.jumpForce;D.applyImpulse(new m(0,1,0).multiplyScalar(w))}}if(this.controller){const f=(c=this.controller)==null?void 0:c.rigidbody.getVelocity().y;if(f<-1){this._raycastOptions.ray||(this._raycastOptions.ray=new pC),this._raycastOptions.ray.origin.copy(ye(this.gameObject)),this._raycastOptions.ray.direction.set(0,-1,0);const D=this.layer;this.gameObject.layers.disableAll(),this.gameObject.layers.set(2);const w=this.context.physics.raycast(this._raycastOptions);this.gameObject.layers.set(D),(w.length&&w[0].distance>2||f<-10)&&((p=this.animator)==null||p.setBool("falling",!0))}else(u=this.animator)==null||u.setBool("falling",!1)}}}Hn([y(WB)],_n.prototype,"controller",2);Hn([y()],_n.prototype,"movementSpeed",2);Hn([y()],_n.prototype,"rotationSpeed",2);Hn([y()],_n.prototype,"jumpForce",2);Hn([y()],_n.prototype,"doubleJumpForce",2);Hn([y(QI)],_n.prototype,"animator",2);var KIA=Object.defineProperty,JIA=Object.getOwnPropertyDescriptor,qIA=(i,A,e,t)=>{for(var g=t>1?void 0:t?JIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&KIA(A,e,g),g};class fu extends _g{constructor(){super(...arguments);B(this,"intensity")}get typeName(){return"ChromaticAberration"}init(){this.intensity.defaultValue=0}onCreateEffect(){const e=new UH;return e.offset=new X(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}}qIA([y(Re)],fu.prototype,"intensity",2);As("ChromaticAberration",fu);var bIA=Object.defineProperty,xIA=Object.getOwnPropertyDescriptor,US=(i,A,e,t)=>{for(var g=t>1?void 0:t?xIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&bIA(A,e,g),g};class lr extends _g{constructor(){super(...arguments);B(this,"postExposure");B(this,"contrast");B(this,"hueShift");B(this,"saturation")}get typeName(){return"ColorAdjustments"}init(){this.postExposure.valueProcessor=e=>(e=Math.pow(2,e),e),this.postExposure.defaultValue=0,this.contrast.valueProcessor=e=>{let t=1;return e>0?t=200:e<0&&(t=100),e/t},this.contrast.defaultValue=0,this.hueShift.valueProcessor=e=>Math.PI*e/180,this.hueShift.defaultValue=0,this.saturation.valueProcessor=e=>e<0?e/100:e/(100*Math.PI),this.saturation.defaultValue=0}unapply(){this.context.renderer.toneMappingExposure=1}onCreateEffect(){this.context.renderer.toneMapping===oI&&this.postExposure.overrideState&&(this.context.renderer.toneMapping=Yl);const e=new RH;this.postExposure.onValueChanged=g=>{this.context.renderer.toneMapping===oI&&(this.context.renderer.toneMapping=Yl),this.postExposure.overrideState&&(this.context.renderer.toneMappingExposure=g)},this.contrast.onValueChanged=g=>{e.contrast=g};const t=new NH;return this.hueShift.onValueChanged=g=>t.hue=g,this.saturation.onValueChanged=g=>t.saturation=g,[t,e]}}US([y(Re)],lr.prototype,"postExposure",2);US([y(Re)],lr.prototype,"contrast",2);US([y(Re)],lr.prototype,"hueShift",2);US([y(Re)],lr.prototype,"saturation",2);As("ColorAdjustments",lr);const LIA=(Math.sqrt(5)-1)/4,ag=(5-Math.sqrt(5))/20,tf=i=>Math.floor(i)|0,gf=new Float64Array([0,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,1,0,1,1,1,0,1,-1,1,0,-1,1,1,0,-1,-1,-1,0,1,1,-1,0,1,-1,-1,0,-1,1,-1,0,-1,-1,1,1,0,1,1,1,0,-1,1,-1,0,1,1,-1,0,-1,-1,1,0,1,-1,1,0,-1,-1,-1,0,1,-1,-1,0,-1,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,0]);function vIA(i=Math.random){const A=TIA(i),e=new Float64Array(A).map(o=>gf[o%32*4]),t=new Float64Array(A).map(o=>gf[o%32*4+1]),g=new Float64Array(A).map(o=>gf[o%32*4+2]),I=new Float64Array(A).map(o=>gf[o%32*4+3]);return function(s,C,n,a){let r,Q,E,h,l;const d=(s+C+n+a)*LIA,c=tf(s+d),p=tf(C+d),u=tf(n+d),f=tf(a+d),D=(c+p+u+f)*ag,w=c-D,M=p-D,R=u-D,k=f-D,G=s-w,J=C-M,P=n-R,L=a-k;let T=0,_=0,tA=0,V=0;G>J?T++:_++,G>P?T++:tA++,G>L?T++:V++,J>P?_++:tA++,J>L?_++:V++,P>L?tA++:V++;const $=T>=3?1:0,gA=_>=3?1:0,nA=tA>=3?1:0,j=V>=3?1:0,iA=T>=2?1:0,kA=_>=2?1:0,wA=tA>=2?1:0,GA=V>=2?1:0,MA=T>=1?1:0,WA=_>=1?1:0,_A=tA>=1?1:0,ae=V>=1?1:0,ke=G-$+ag,ie=J-gA+ag,H=P-nA+ag,vA=L-j+ag,uA=G-iA+2*ag,xA=J-kA+2*ag,SA=P-wA+2*ag,Ae=L-GA+2*ag,zA=G-MA+3*ag,ZA=J-WA+3*ag,Ee=P-_A+3*ag,me=L-ae+3*ag,Ze=G-1+4*ag,v=J-1+4*ag,q=P-1+4*ag,EA=L-1+4*ag,UA=c&255,FA=p&255,TA=u&255,O=f&255;let cA=.6-G*G-J*J-P*P-L*L;if(cA<0)r=0;else{const JA=UA+A[FA+A[TA+A[O]]];cA*=cA,r=cA*cA*(e[JA]*G+t[JA]*J+g[JA]*P+I[JA]*L)}let aA=.6-ke*ke-ie*ie-H*H-vA*vA;if(aA<0)Q=0;else{const JA=UA+$+A[FA+gA+A[TA+nA+A[O+j]]];aA*=aA,Q=aA*aA*(e[JA]*ke+t[JA]*ie+g[JA]*H+I[JA]*vA)}let PA=.6-uA*uA-xA*xA-SA*SA-Ae*Ae;if(PA<0)E=0;else{const JA=UA+iA+A[FA+kA+A[TA+wA+A[O+GA]]];PA*=PA,E=PA*PA*(e[JA]*uA+t[JA]*xA+g[JA]*SA+I[JA]*Ae)}let jA=.6-zA*zA-ZA*ZA-Ee*Ee-me*me;if(jA<0)h=0;else{const JA=UA+MA+A[FA+WA+A[TA+_A+A[O+ae]]];jA*=jA,h=jA*jA*(e[JA]*zA+t[JA]*ZA+g[JA]*Ee+I[JA]*me)}let HA=.6-Ze*Ze-v*v-q*q-EA*EA;if(HA<0)l=0;else{const JA=UA+1+A[FA+1+A[TA+1+A[O+1]]];HA*=HA,l=HA*HA*(e[JA]*Ze+t[JA]*v+g[JA]*q+I[JA]*EA)}return 27*(r+Q+E+h+l)}}function TIA(i){const e=new Uint8Array(512);for(let t=0;t<512/2;t++)e[t]=t;for(let t=0;t<512/2-1;t++){const g=t+~~(i()*(256-t)),I=e[t];e[t]=e[g],e[g]=I}for(let t=256;t<512;t++)e[t]=e[t-256];return e}var YIA=Object.defineProperty,HIA=Object.getOwnPropertyDescriptor,AA=(i,A,e,t)=>{for(var g=t>1?void 0:t?HIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&YIA(A,e,g),g};const If=oA("debugparticles");var nn=(i=>(i[i.Billboard=0]="Billboard",i[i.Stretch=1]="Stretch",i[i.HorizontalBillboard=2]="HorizontalBillboard",i[i.VerticalBillboard=3]="VerticalBillboard",i[i.Mesh=4]="Mesh",i))(nn||{});class dr{constructor(){B(this,"alphaKeys");B(this,"colorKeys")}get duration(){return 1}evaluate(A,e){let t,g=0,I=null,o=0;for(let s=0;s<this.alphaKeys.length;s++){const C=this.alphaKeys[s];(C.time<A||!t)&&(t=C,g=s)}for(let s=0;s<this.colorKeys.length;s++){const C=this.colorKeys[s];(C.time<A||!I)&&(I=C,o=s)}if(I)if(o+1<this.colorKeys.length){const C=this.colorKeys[o+1],n=te.remap(A,I.time,C.time,0,1);e.r=te.lerp(I.color.r,C.color.r,n),e.g=te.lerp(I.color.g,C.color.g,n),e.b=te.lerp(I.color.b,C.color.b,n)}else e.r=I.color.r,e.g=I.color.g,e.b=I.color.b;if(t)if(g+1<this.alphaKeys.length){const C=this.alphaKeys[g+1],n=te.remap(A,t.time,C.time,0,1);e.alpha=te.lerp(t.alpha,C.alpha,n)}else e.alpha=t.alpha;return e}}AA([y()],dr.prototype,"alphaKeys",2);AA([y()],dr.prototype,"colorKeys",2);var FS=(i=>(i[i.Local=0]="Local",i[i.World=1]="World",i[i.Custom=2]="Custom",i))(FS||{}),mO=(i=>(i[i.Sphere=0]="Sphere",i[i.SphereShell=1]="SphereShell",i[i.Hemisphere=2]="Hemisphere",i[i.HemisphereShell=3]="HemisphereShell",i[i.Cone=4]="Cone",i[i.Box=5]="Box",i[i.Mesh=6]="Mesh",i[i.ConeShell=7]="ConeShell",i[i.ConeVolume=8]="ConeVolume",i[i.ConeVolumeShell=9]="ConeVolumeShell",i[i.Circle=10]="Circle",i[i.CircleEdge=11]="CircleEdge",i[i.SingleSidedEdge=12]="SingleSidedEdge",i[i.MeshRenderer=13]="MeshRenderer",i[i.SkinnedMeshRenderer=14]="SkinnedMeshRenderer",i[i.BoxShell=15]="BoxShell",i[i.BoxEdge=16]="BoxEdge",i[i.Donut=17]="Donut",i[i.Rectangle=18]="Rectangle",i[i.Sprite=19]="Sprite",i[i.SpriteRenderer=20]="SpriteRenderer",i))(mO||{});class ne{constructor(){B(this,"mode");B(this,"constant");B(this,"constantMin");B(this,"constantMax");B(this,"curve");B(this,"curveMin");B(this,"curveMax");B(this,"curveMultiplier")}evaluate(A,e){const t=e===void 0?Math.random():e;switch(this.mode){case 0:return this.constant;case 1:return A=te.clamp01(A),this.curve.evaluate(A)*this.curveMultiplier;case 2:const g=A*this.curveMin.duration,I=A*this.curveMax.duration;return te.lerp(this.curveMin.evaluate(g),this.curveMax.evaluate(I),t%1)*this.curveMultiplier;case 3:return te.lerp(this.constantMin,this.constantMax,t%1);default:this.curveMax.evaluate(A)*this.curveMultiplier;break}return 0}getMax(){switch(this.mode){case 0:return this.constant;case 1:return this.getMaxFromCurve(this.curve)*this.curveMultiplier;case 2:return Math.max(this.getMaxFromCurve(this.curveMin),this.getMaxFromCurve(this.curveMax))*this.curveMultiplier;case 3:return Math.max(this.constantMin,this.constantMax);default:return 0}}getMaxFromCurve(A){if(!A)return 0;let e=Number.MIN_VALUE;for(let t=0;t<A.keys.length;t++){const g=A.keys[t];g.value>e&&(e=g.value)}return e}}AA([y()],ne.prototype,"mode",2);AA([y()],ne.prototype,"constant",2);AA([y()],ne.prototype,"constantMin",2);AA([y()],ne.prototype,"constantMax",2);AA([y(xB)],ne.prototype,"curve",2);AA([y(xB)],ne.prototype,"curveMin",2);AA([y(xB)],ne.prototype,"curveMax",2);AA([y()],ne.prototype,"curveMultiplier",2);var vf;const hs=(vf=class{constructor(){B(this,"mode");B(this,"color");B(this,"colorMin");B(this,"colorMax");B(this,"gradient");B(this,"gradientMin");B(this,"gradientMax")}evaluate(i,A){const e=A===void 0?Math.random():A;switch(this.mode){case 0:return this.color;case 1:return this.gradient.evaluate(i,hs._temp),hs._temp;case 2:return hs._temp.lerpColors(this.colorMin,this.colorMax,e);case 3:return this.gradientMin.evaluate(i,hs._temp),this.gradientMax.evaluate(i,hs._temp2),hs._temp.lerp(hs._temp2,e)}return hs._temp.set(16711935),hs._temp.alpha=1,hs._temp}},B(vf,"_temp",new kt(0,0,0,1)),B(vf,"_temp2",new kt(0,0,0,1)),vf);let bI=hs;AA([y(kt)],bI.prototype,"color",2);AA([y(kt)],bI.prototype,"colorMin",2);AA([y(kt)],bI.prototype,"colorMax",2);AA([y(dr)],bI.prototype,"gradient",2);AA([y(dr)],bI.prototype,"gradientMin",2);AA([y(dr)],bI.prototype,"gradientMax",2);class Gg{constructor(){B(this,"cullingMode");B(this,"duration");B(this,"emitterVelocityMode");B(this,"flipRotation");B(this,"gravityModifier");B(this,"gravityModifierMultiplier");B(this,"loop");B(this,"maxParticles");B(this,"playOnAwake");B(this,"prewarm");B(this,"ringBufferLoopRange");B(this,"ringBufferMode");B(this,"scalingMode");B(this,"simulationSpace");B(this,"simulationSpeed");B(this,"startColor");B(this,"startDelay");B(this,"startDelayMultiplier");B(this,"startLifetime");B(this,"startLifetimeMultiplier");B(this,"startRotation");B(this,"startRotationMultiplier");B(this,"startRotation3D");B(this,"startRotationX");B(this,"startRotationXMultiplier");B(this,"startRotationY");B(this,"startRotationYMultiplier");B(this,"startRotationZ");B(this,"startRotationZMultiplier");B(this,"startSize");B(this,"startSize3D");B(this,"startSizeMultiplier");B(this,"startSizeX");B(this,"startSizeXMultiplier");B(this,"startSizeY");B(this,"startSizeYMultiplier");B(this,"startSizeZ");B(this,"startSizeZMultiplier");B(this,"startSpeed");B(this,"startSpeedMultiplier");B(this,"stopAction");B(this,"useUnscaledTime")}}AA([y(ne)],Gg.prototype,"gravityModifier",2);AA([y(bI)],Gg.prototype,"startColor",2);AA([y(ne)],Gg.prototype,"startDelay",2);AA([y(ne)],Gg.prototype,"startLifetime",2);AA([y(ne)],Gg.prototype,"startRotation",2);AA([y(ne)],Gg.prototype,"startRotationX",2);AA([y(ne)],Gg.prototype,"startRotationY",2);AA([y(ne)],Gg.prototype,"startRotationZ",2);AA([y(ne)],Gg.prototype,"startSize",2);AA([y(ne)],Gg.prototype,"startSizeX",2);AA([y(ne)],Gg.prototype,"startSizeY",2);AA([y(ne)],Gg.prototype,"startSizeZ",2);AA([y(ne)],Gg.prototype,"startSpeed",2);class dd{constructor(){B(this,"cycleCount");B(this,"maxCount");B(this,"minCount");B(this,"probability");B(this,"repeatInterval");B(this,"time");B(this,"count");B(this,"_performed",0)}reset(){this._performed=0}run(A){if(A<=this.time)return 0;let e=0;if(this.cycleCount===0||this._performed<this.cycleCount){const t=this.time+this.repeatInterval*this._performed;if(A>=t&&(this._performed+=1,Math.random()<this.probability))switch(this.count.mode){case 0:e=this.count.constant;break;case 3:e=te.lerp(this.count.constantMin,this.count.constantMax,Math.random());break;case 1:e=this.count.curve.evaluate(Math.random());break;case 2:const g=Math.random();e=te.lerp(this.count.curveMin.evaluate(g),this.count.curveMax.evaluate(g),Math.random());break}}return e}}class SC{constructor(){B(this,"enabled");B(this,"bursts");B(this,"rateOverTime");B(this,"rateOverTimeMultiplier");B(this,"rateOverDistance");B(this,"rateOverDistanceMultiplier");B(this,"system")}get burstCount(){var A;return((A=this.bursts)==null?void 0:A.length)??0}reset(){var A;(A=this.bursts)==null||A.forEach(e=>e.reset())}getBurst(){let A=0;if(this.burstCount>0)for(let e=0;e<this.burstCount;e++){const t=this.bursts[e];this.system.main.loop&&t.time>=this.system.time&&t.reset(),A+=Math.round(t.run(this.system.time))}return A}}AA([y()],SC.prototype,"enabled",2);AA([y()],SC.prototype,"bursts",2);AA([y(ne)],SC.prototype,"rateOverTime",2);AA([y()],SC.prototype,"rateOverTimeMultiplier",2);AA([y(ne)],SC.prototype,"rateOverDistance",2);AA([y()],SC.prototype,"rateOverDistanceMultiplier",2);class Du{constructor(){B(this,"enabled");B(this,"color")}}AA([y(bI)],Du.prototype,"color",2);class ur{constructor(){B(this,"enabled");B(this,"separateAxes");B(this,"size");B(this,"sizeMultiplier");B(this,"x");B(this,"xMultiplier");B(this,"y");B(this,"yMultiplier");B(this,"z");B(this,"zMultiplier");B(this,"_time",0);B(this,"_temp",new m)}evaluate(A,e,t){if(e||(e=this._temp),!this.enabled)return e.x=e.y=e.z=1,e;if(this.separateAxes)e.x=this.x.evaluate(A,t)*this.xMultiplier,e.y=this.y.evaluate(A,t)*this.yMultiplier,e.z=this.z.evaluate(A,t)*this.zMultiplier;else{const g=this.size.evaluate(A,t)*this.sizeMultiplier;e.x=g}return e}}AA([y(ne)],ur.prototype,"size",2);AA([y(ne)],ur.prototype,"x",2);AA([y(ne)],ur.prototype,"y",2);AA([y(ne)],ur.prototype,"z",2);var Tf;const Xc=(Tf=class{constructor(){B(this,"shapeType",5);B(this,"enabled",!0);B(this,"alignToDirection",!1);B(this,"angle",0);B(this,"arc",360);B(this,"arcSpread");B(this,"arcSpeedMultiplier");B(this,"arcMode");B(this,"boxThickness");B(this,"position");B(this,"rotation");B(this,"_rotation",new ug);B(this,"scale");B(this,"radius");B(this,"radiusThickness");B(this,"sphericalDirectionAmount");B(this,"randomDirectionAmount");B(this,"randomPositionAmount");B(this,"system");B(this,"_space");B(this,"_worldSpaceMatrix",new qA);B(this,"_worldSpaceMatrixInverse",new qA);B(this,"_vector",new m(0,0,0));B(this,"_temp",new m(0,0,0));B(this,"_dir",new m);B(this,"_loopTime",0);B(this,"_loopDirection",1);If&&console.log(this)}get type(){return mO[this.shapeType]}initialize(i){this.getPosition(),i.position.copy(this._vector)}toJSON(){return this}clone(){return new Xc}update(i,A,e,t){this.system=i,this._space=e,e===1&&(this._worldSpaceMatrix.copy(t.matrixWorld),this._worldSpaceMatrix.elements[0]=1,this._worldSpaceMatrix.elements[5]=1,this._worldSpaceMatrix.elements[10]=1,this._worldSpaceMatrixInverse.copy(this._worldSpaceMatrix).invert())}applyRotation(i){const A=this.rotation.x!==0||this.rotation.y!==0||this.rotation.z!==0;return A&&(this._rotation.x=te.toRadians(this.rotation.x),this._rotation.y=te.toRadians(this.rotation.y),this._rotation.z=te.toRadians(this.rotation.z),this._rotation.order="ZYX",i.applyEuler(this._rotation)),A}get vector(){return this._vector}getPosition(){this._vector.set(0,0,0);const i=this._temp.copy(this.position),A=this._space===1;A&&i.applyQuaternion(this.system.worldQuaternion);let e=this.radius;if(A&&(e*=this.system.worldScale.x),this.enabled){switch(this.shapeType){case 5:If&&ln.DrawBox(this.position,this.scale,14540253,1),this._vector.x=Math.random()*this.scale.x-this.scale.x/2,this._vector.y=Math.random()*this.scale.y-this.scale.y/2,this._vector.z=Math.random()*this.scale.z-this.scale.z/2,this._vector.add(i);break;case 4:this.randomConePoint(this.position,this.angle,e,this.radiusThickness,this.arc,this.arcMode,this._vector);break;case 0:this.randomSpherePoint(this.position,e,this.radiusThickness,this.arc,this._vector);break;case 10:this.randomCirclePoint(this.position,e,this.radiusThickness,this.arc,this._vector);break;default:this._vector.set(0,0,0);break}this.randomizePosition(this._vector,this.randomPositionAmount)}this.applyRotation(this._vector),A&&(this._vector.applyQuaternion(this.system.worldQuaternion),this._vector.add(this.system.worldPos)),If&&ln.DrawSphere(this._vector,.03,16711680,.5,!0)}getDirection(i){var A;if(!this.enabled)return this._dir.set(0,0,1),this._dir;switch(this.shapeType){case 5:this._dir.set(0,0,1);break;case 4:this._dir.set(0,0,1);break;case 10:case 0:const e=i.x,t=i.y,g=i.z;this._dir.set(e,t,g),(A=this.system)!=null&&A.worldspace?this._dir.sub(this.system.worldPos):this._dir.sub(this.position);break;default:this._dir.set(0,0,1);break}return this._space===1&&this._dir.applyQuaternion(this.system.worldQuaternion),this.applyRotation(this._dir),this._dir.normalize(),this.spherizeDirection(this._dir,this.sphericalDirectionAmount),this.randomizeDirection(this._dir,this.randomDirectionAmount),If&&(ln.DrawSphere(i,.01,8925952,.5,!0),ln.DrawDirection(i,this._dir,8925952,.5,!0)),this._dir}randomizePosition(i,A){if(A<=0)return;const e=Xc._tempVec;e.set(Math.random()*2-1,Math.random()*2-1,Math.random()*2-1),e.x*=A*this.scale.x,e.y*=A*this.scale.y,e.z*=A*this.scale.z,i.add(e)}randomizeDirection(i,A){if(A===0)return;const e=Xc._randomQuat,t=Xc._tempVec;t.set(Math.random()-.5,Math.random()-.5,Math.random()-.5).normalize(),e.setFromAxisAngle(t,A*Math.random()*Math.PI),i.applyQuaternion(e)}spherizeDirection(i,A){if(A===0)return;const e=Math.random()*Math.PI*2,t=Math.acos(1-Math.random()*2),g=Math.sin(t)*Math.cos(e),I=Math.sin(t)*Math.sin(e),o=Math.cos(t),s=new m(g,I,o);i.lerp(s,A)}randomSpherePoint(i,A,e,t,g){const I=Math.random(),o=Math.random(),s=2*Math.PI*I*(t/360),C=Math.acos(2*o-1),n=te.lerp(1,1-Math.pow(1-Math.random(),Math.PI),e)*A,a=i.x+this.scale.x*(-n*Math.sin(C)*Math.cos(s)),r=i.y+this.scale.y*(n*Math.sin(C)*Math.sin(s)),Q=i.z+this.scale.z*(n*Math.cos(C));g.x=a,g.y=r,g.z=Q}randomCirclePoint(i,A,e,t,g){const I=Math.random(),o=2*Math.PI*I*(t/360),s=te.lerp(1,1-Math.pow(1-Math.random(),Math.PI),e)*A,C=i.x+this.scale.x*s*Math.cos(o),n=i.y+this.scale.y*s*Math.sin(o),a=i.z;g.x=C,g.y=n,g.z=a}randomConePoint(i,A,e,t,g,I,o){let s=0,C=0;switch(I){case 0:s=Math.random(),C=Math.random();break;case 2:this._loopTime>1&&(this._loopDirection=-1),this._loopTime<0&&(this._loopDirection=1);case 1:s=.5,C=Math.random(),this._loopTime+=this.system.deltaTime*this._loopDirection;break}let n=2*Math.PI*s*(g/360);switch(I){case 2:case 1:n+=Math.PI+.5,n+=this._loopTime*Math.PI*2,n%=te.toRadians(g);break}const a=Math.acos(2*C-1),r=te.lerp(1,1-Math.pow(1-Math.random(),Math.PI),t)*e,Q=i.x+-r*Math.sin(a)*Math.cos(n),E=i.y+r*Math.sin(a)*Math.sin(n),h=i.z;o.x=Q*this.scale.x,o.y=E*this.scale.y,o.z=h*this.scale.z}},B(Tf,"_randomQuat",new LA),B(Tf,"_tempVec",new m),Tf);let pi=Xc;AA([y()],pi.prototype,"shapeType",2);AA([y()],pi.prototype,"enabled",2);AA([y()],pi.prototype,"alignToDirection",2);AA([y()],pi.prototype,"angle",2);AA([y()],pi.prototype,"arc",2);AA([y()],pi.prototype,"arcSpread",2);AA([y()],pi.prototype,"arcSpeedMultiplier",2);AA([y()],pi.prototype,"arcMode",2);AA([y(m)],pi.prototype,"boxThickness",2);AA([y(m)],pi.prototype,"position",2);AA([y(m)],pi.prototype,"rotation",2);AA([y(m)],pi.prototype,"scale",2);AA([y()],pi.prototype,"radius",2);AA([y()],pi.prototype,"radiusThickness",2);AA([y()],pi.prototype,"sphericalDirectionAmount",2);AA([y()],pi.prototype,"randomDirectionAmount",2);AA([y()],pi.prototype,"randomPositionAmount",2);class ft{constructor(){B(this,"damping");B(this,"enabled");B(this,"frequency");B(this,"octaveCount");B(this,"octaveMultiplier");B(this,"octaveScale");B(this,"positionAmount");B(this,"quality");B(this,"remap");B(this,"remapEnabled");B(this,"remapMultiplier");B(this,"remapX");B(this,"remapXMultiplier");B(this,"remapY");B(this,"remapYMultiplier");B(this,"remapZ");B(this,"remapZMultiplier");B(this,"scrollSpeedMultiplier");B(this,"separateAxes");B(this,"strengthMultiplier");B(this,"strengthX");B(this,"strengthXMultiplier");B(this,"strengthY");B(this,"strengthYMultiplier");B(this,"strengthZ");B(this,"strengthZMultiplier");B(this,"_noise");B(this,"_time",0);B(this,"_temp",new m)}update(A){this._time+=A.time.deltaTime*this.scrollSpeedMultiplier}apply(A,e,t,g,I,o){if(!this.enabled)return;this._noise||(this._noise=vIA(()=>0));const s=this._temp.set(e.x,e.y,e.z).multiplyScalar(this.frequency),C=this._noise(s.x,s.y,s.z,this._time),n=this._noise(s.x,s.y,s.z,this._time+1e3*this.frequency),a=this._noise(s.x,s.y,s.z,this._time+2e3*this.frequency);this._temp.set(C,n,a).normalize();const r=I/o;let Q=this.positionAmount.evaluate(r);this.separateAxes?(this._temp.x*=Q*this.strengthXMultiplier,this._temp.y*=Q*this.strengthYMultiplier,this._temp.z*=Q*this.strengthZMultiplier):(this.strengthX&&(Q*=this.strengthX.evaluate(r)*1.5),this._temp.multiplyScalar(Q)),t.x+=this._temp.x,t.y+=this._temp.y,t.z+=this._temp.z}}AA([y()],ft.prototype,"damping",2);AA([y()],ft.prototype,"enabled",2);AA([y()],ft.prototype,"frequency",2);AA([y()],ft.prototype,"octaveCount",2);AA([y()],ft.prototype,"octaveMultiplier",2);AA([y()],ft.prototype,"octaveScale",2);AA([y(ne)],ft.prototype,"positionAmount",2);AA([y()],ft.prototype,"quality",2);AA([y(ne)],ft.prototype,"remap",2);AA([y()],ft.prototype,"remapEnabled",2);AA([y()],ft.prototype,"remapMultiplier",2);AA([y(ne)],ft.prototype,"remapX",2);AA([y()],ft.prototype,"remapXMultiplier",2);AA([y(ne)],ft.prototype,"remapY",2);AA([y()],ft.prototype,"remapYMultiplier",2);AA([y(ne)],ft.prototype,"remapZ",2);AA([y()],ft.prototype,"remapZMultiplier",2);AA([y()],ft.prototype,"scrollSpeedMultiplier",2);AA([y()],ft.prototype,"separateAxes",2);AA([y()],ft.prototype,"strengthMultiplier",2);AA([y(ne)],ft.prototype,"strengthX",2);AA([y()],ft.prototype,"strengthXMultiplier",2);AA([y(ne)],ft.prototype,"strengthY",2);AA([y()],ft.prototype,"strengthYMultiplier",2);AA([y(ne)],ft.prototype,"strengthZ",2);AA([y()],ft.prototype,"strengthZMultiplier",2);class Wt{constructor(){B(this,"enabled");B(this,"attachRibbonToTransform",!1);B(this,"colorOverLifetime");B(this,"colorOverTrail");B(this,"dieWithParticles",!0);B(this,"inheritParticleColor",!0);B(this,"lifetime");B(this,"lifetimeMultiplier");B(this,"minVertexDistance",.2);B(this,"mode",0);B(this,"ratio",1);B(this,"ribbonCount",1);B(this,"shadowBias",0);B(this,"sizeAffectsLifetime",!1);B(this,"sizeAffectsWidth",!1);B(this,"splitSubEmitterRibbons",!1);B(this,"textureMode",0);B(this,"widthOverTrail");B(this,"widthOverTrailMultiplier");B(this,"worldSpace",!1)}getWidth(A,e,t,g){let I=this.widthOverTrail.evaluate(t,g);return A*=I,A}getColor(A,e,t){const g=this.colorOverTrail.evaluate(t),I=this.colorOverLifetime.evaluate(e);A.x*=g.r*I.r,A.y*=g.g*I.g,A.z*=g.b*I.b,A.w*=g.alpha*I.alpha}}AA([y()],Wt.prototype,"enabled",2);AA([y()],Wt.prototype,"attachRibbonToTransform",2);AA([y(bI)],Wt.prototype,"colorOverLifetime",2);AA([y(bI)],Wt.prototype,"colorOverTrail",2);AA([y()],Wt.prototype,"dieWithParticles",2);AA([y()],Wt.prototype,"inheritParticleColor",2);AA([y(ne)],Wt.prototype,"lifetime",2);AA([y()],Wt.prototype,"lifetimeMultiplier",2);AA([y()],Wt.prototype,"minVertexDistance",2);AA([y()],Wt.prototype,"mode",2);AA([y()],Wt.prototype,"ratio",2);AA([y()],Wt.prototype,"ribbonCount",2);AA([y()],Wt.prototype,"shadowBias",2);AA([y()],Wt.prototype,"sizeAffectsLifetime",2);AA([y()],Wt.prototype,"sizeAffectsWidth",2);AA([y()],Wt.prototype,"splitSubEmitterRibbons",2);AA([y()],Wt.prototype,"textureMode",2);AA([y(ne)],Wt.prototype,"widthOverTrail",2);AA([y()],Wt.prototype,"widthOverTrailMultiplier",2);AA([y()],Wt.prototype,"worldSpace",2);class $t{constructor(){B(this,"enabled");B(this,"space",0);B(this,"orbitalX");B(this,"orbitalY");B(this,"orbitalZ");B(this,"orbitalXMultiplier");B(this,"orbitalYMultiplier");B(this,"orbitalZMultiplier");B(this,"orbitalOffsetX");B(this,"orbitalOffsetY");B(this,"orbitalOffsetZ");B(this,"speedModifier");B(this,"speedModifierMultiplier");B(this,"x");B(this,"xMultiplier");B(this,"y");B(this,"yMultiplier");B(this,"z");B(this,"zMultiplier");B(this,"_system");B(this,"_temp",new m);B(this,"_temp2",new m);B(this,"_temp3",new m);B(this,"_hasOrbital",!1);B(this,"_index",0);B(this,"_orbitalMatrix",new qA)}update(A){this._system=A}init(A){this._index==0&&(A.debug=!0),this._index+=1,A.orbitx=this.orbitalX.evaluate(Math.random()),A.orbity=this.orbitalY.evaluate(Math.random()),A.orbitz=this.orbitalZ.evaluate(Math.random()),this._hasOrbital=A.orbitx!=0||A.orbity!=0||A.orbitz!=0}apply(A,e,t,g,I,o,s){var E;if(!this.enabled)return;const C=o/s,n=this.speedModifier.evaluate(C)*this.speedModifierMultiplier,a=this.x.evaluate(C),r=this.y.evaluate(C),Q=this.z.evaluate(C);if(this._temp.set(-a,r,Q),this._system&&this._system.main.simulationSpace===1&&this._temp.applyQuaternion(this._system.worldQuaternion),this._hasOrbital&&((E=this._system)==null?void 0:E.worldPos)){const l=this._temp2.set(t.x,t.y,t.z),d=this.orbitalXMultiplier,c=this.orbitalYMultiplier,p=this.orbitalZMultiplier,u=n*Math.PI*2*10,f=Math.cos(u*d),D=Math.sin(u*d),w=Math.cos(u*c),M=Math.sin(u*c),R=Math.cos(u*p),k=Math.sin(u*p),G=l.x*(w*R)+l.y*(w*k)+l.z*-M,J=l.x*(D*M*R-f*k)+l.y*(D*M*k+f*R)+l.z*(D*w),P=l.x*(f*M*R+D*k)+l.y*(f*M*k-D*R)+l.z*(f*w),L=this._temp3.set(l.x-G,l.y-J,l.z-P);L.normalize(),L.multiplyScalar(.2/I*Math.max(this.orbitalXMultiplier,this.orbitalYMultiplier,this.orbitalZMultiplier)),g.x+=L.x,g.y+=L.y,g.z+=L.z}g.x+=this._temp.x,g.y+=this._temp.y,g.z+=this._temp.z,g.x*=n,g.y*=n,g.z*=n}}AA([y()],$t.prototype,"enabled",2);AA([y()],$t.prototype,"space",2);AA([y(ne)],$t.prototype,"orbitalX",2);AA([y(ne)],$t.prototype,"orbitalY",2);AA([y(ne)],$t.prototype,"orbitalZ",2);AA([y()],$t.prototype,"orbitalXMultiplier",2);AA([y()],$t.prototype,"orbitalYMultiplier",2);AA([y()],$t.prototype,"orbitalZMultiplier",2);AA([y()],$t.prototype,"orbitalOffsetX",2);AA([y()],$t.prototype,"orbitalOffsetY",2);AA([y()],$t.prototype,"orbitalOffsetZ",2);AA([y(ne)],$t.prototype,"speedModifier",2);AA([y()],$t.prototype,"speedModifierMultiplier",2);AA([y(ne)],$t.prototype,"x",2);AA([y()],$t.prototype,"xMultiplier",2);AA([y(ne)],$t.prototype,"y",2);AA([y()],$t.prototype,"yMultiplier",2);AA([y(ne)],$t.prototype,"z",2);AA([y()],$t.prototype,"zMultiplier",2);class Mg{constructor(){B(this,"animation");B(this,"enabled");B(this,"cycleCount");B(this,"frameOverTime");B(this,"frameOverTimeMultiplier");B(this,"numTilesX");B(this,"numTilesY");B(this,"startFrame");B(this,"startFrameMultiplier");B(this,"rowMode");B(this,"rowIndex");B(this,"spriteCount");B(this,"timeMode")}sampleOnceAtStart(){if(this.timeMode===0)switch(this.frameOverTime.mode){case 0:case 3:case 2:case 1:return!0}return!1}getStartIndex(){return this.sampleOnceAtStart()?Math.random()*(this.numTilesX*this.numTilesY):0}evaluate(A){if(!this.sampleOnceAtStart())return this.getIndex(A)}getIndex(A){const e=this.numTilesX*this.numTilesY;A=A*this.cycleCount;let t=this.frameOverTime.evaluate(A%1);return t*=this.frameOverTimeMultiplier,t*=e,t=t%e,t=Math.floor(t),t}}AA([y()],Mg.prototype,"animation",2);AA([y()],Mg.prototype,"enabled",2);AA([y()],Mg.prototype,"cycleCount",2);AA([y(ne)],Mg.prototype,"frameOverTime",2);AA([y()],Mg.prototype,"frameOverTimeMultiplier",2);AA([y()],Mg.prototype,"numTilesX",2);AA([y()],Mg.prototype,"numTilesY",2);AA([y(ne)],Mg.prototype,"startFrame",2);AA([y()],Mg.prototype,"startFrameMultiplier",2);AA([y()],Mg.prototype,"rowMode",2);AA([y()],Mg.prototype,"rowIndex",2);AA([y()],Mg.prototype,"spriteCount",2);AA([y()],Mg.prototype,"timeMode",2);class es{constructor(){B(this,"enabled");B(this,"separateAxes");B(this,"x");B(this,"xMultiplier");B(this,"y");B(this,"yMultiplier");B(this,"z");B(this,"zMultiplier")}evaluate(A,e){return this.enabled?this.separateAxes?0:this.z.evaluate(A,e)*-1:0}}AA([y()],es.prototype,"enabled",2);AA([y()],es.prototype,"separateAxes",2);AA([y(ne)],es.prototype,"x",2);AA([y()],es.prototype,"xMultiplier",2);AA([y(ne)],es.prototype,"y",2);AA([y()],es.prototype,"yMultiplier",2);AA([y(ne)],es.prototype,"z",2);AA([y()],es.prototype,"zMultiplier",2);class Qo{constructor(){B(this,"enabled");B(this,"range");B(this,"separateAxes");B(this,"x");B(this,"xMultiplier");B(this,"y");B(this,"yMultiplier");B(this,"z");B(this,"zMultiplier")}evaluate(A,e){if(!this.enabled)return 0;if(!this.separateAxes){const t=te.lerp(this.range.x,this.range.y,e);return this.z.evaluate(t)*-1}return 0}}AA([y()],Qo.prototype,"enabled",2);AA([y()],Qo.prototype,"range",2);AA([y()],Qo.prototype,"separateAxes",2);AA([y(ne)],Qo.prototype,"x",2);AA([y()],Qo.prototype,"xMultiplier",2);AA([y(ne)],Qo.prototype,"y",2);AA([y()],Qo.prototype,"yMultiplier",2);AA([y(ne)],Qo.prototype,"z",2);AA([y()],Qo.prototype,"zMultiplier",2);class bi{constructor(){B(this,"enabled");B(this,"dampen");B(this,"drag");B(this,"dragMultiplier");B(this,"limit");B(this,"limitMultiplier");B(this,"separateAxes");B(this,"limitX");B(this,"limitXMultiplier");B(this,"limitY");B(this,"limitYMultiplier");B(this,"limitZ");B(this,"limitZMultiplier");B(this,"multiplyDragByParticleSize",!1);B(this,"multiplyDragByParticleVelocity",!1);B(this,"space");B(this,"_temp",new m);B(this,"_temp2",new m)}apply(A,e,t,g,I,o,s){if(this.enabled){const C=this.limit.evaluate(I)*this.limitMultiplier;if(e.length()>C){this._temp.copy(e).normalize().multiplyScalar(C);let a=this.dampen*.5;e.x=te.lerp(e.x,this._temp.x,a),e.y=te.lerp(e.y,this._temp.y,a),e.z=te.lerp(e.z,this._temp.z,a),t.x=te.lerp(t.x,this._temp.x,a),t.y=te.lerp(t.y,this._temp.y,a),t.z=te.lerp(t.z,this._temp.z,a)}}}}AA([y()],bi.prototype,"enabled",2);AA([y()],bi.prototype,"dampen",2);AA([y(ne)],bi.prototype,"drag",2);AA([y()],bi.prototype,"dragMultiplier",2);AA([y(ne)],bi.prototype,"limit",2);AA([y()],bi.prototype,"limitMultiplier",2);AA([y()],bi.prototype,"separateAxes",2);AA([y(ne)],bi.prototype,"limitX",2);AA([y()],bi.prototype,"limitXMultiplier",2);AA([y(ne)],bi.prototype,"limitY",2);AA([y()],bi.prototype,"limitYMultiplier",2);AA([y(ne)],bi.prototype,"limitZ",2);AA([y()],bi.prototype,"limitZMultiplier",2);AA([y()],bi.prototype,"multiplyDragByParticleSize",2);AA([y()],bi.prototype,"multiplyDragByParticleVelocity",2);AA([y()],bi.prototype,"space",2);class pr{constructor(){B(this,"enabled");B(this,"curve");B(this,"curveMultiplier");B(this,"mode");B(this,"system");B(this,"_lastWorldPosition");B(this,"_velocity",new m);B(this,"_temp",new m)}update(A){this.enabled&&this.system.worldspace!==!1&&(this._lastWorldPosition?(this._velocity.copy(this.system.worldPos).sub(this._lastWorldPosition).multiplyScalar(1/this.system.deltaTime),this._lastWorldPosition.copy(this.system.worldPos)):(this._velocity.set(0,0,0),this._lastWorldPosition=this.system.worldPos.clone()))}applyInitial(A){if(this.enabled&&this.system.worldspace!==!1&&this.mode===0){const e=this.curve.evaluate(Math.random(),Math.random());this._temp.copy(this._velocity).multiplyScalar(e),A.add(this._temp)}}applyCurrent(A,e,t){if(this.enabled&&this.system.worldspace!==!1&&this.mode===1){const g=this.curve.evaluate(e,t);this._temp.copy(this._velocity).multiplyScalar(g),A.add(this._temp)}}}AA([y()],pr.prototype,"enabled",2);AA([y(ne)],pr.prototype,"curve",2);AA([y()],pr.prototype,"curveMultiplier",2);AA([y()],pr.prototype,"mode",2);class hI{constructor(){B(this,"enabled");B(this,"range");B(this,"separateAxes");B(this,"size");B(this,"sizeMultiplier");B(this,"x");B(this,"xMultiplier");B(this,"y");B(this,"yMultiplier");B(this,"z");B(this,"zMultiplier")}evaluate(A,e,t,g){const I=A.length(),o=te.remap(I,this.range.x,this.range.y,0,1),s=this.size.evaluate(o,t);return g*s}}AA([y()],hI.prototype,"enabled",2);AA([y(X)],hI.prototype,"range",2);AA([y()],hI.prototype,"separateAxes",2);AA([y(ne)],hI.prototype,"size",2);AA([y()],hI.prototype,"sizeMultiplier",2);AA([y(ne)],hI.prototype,"x",2);AA([y()],hI.prototype,"xMultiplier",2);AA([y(ne)],hI.prototype,"y",2);AA([y()],hI.prototype,"yMultiplier",2);AA([y(ne)],hI.prototype,"z",2);AA([y()],hI.prototype,"zMultiplier",2);class VB{constructor(){B(this,"enabled");B(this,"range");B(this,"color")}evaluate(A,e,t){const g=A.length(),I=te.remap(g,this.range.x,this.range.y,0,1),o=this.color.evaluate(I,e);t.x*=o.r,t.y*=o.g,t.z*=o.b,t.w*=o.alpha}}AA([y()],VB.prototype,"enabled",2);AA([y(X)],VB.prototype,"range",2);AA([y(bI)],VB.prototype,"color",2);function _IA(i){const A=i.domElement.querySelector("link[rel='ar']");if(A)return A;const e=document.createElement("div");e.classList.add("menu"),e.classList.add("quicklook-menu"),e.style.display="none",e.style.visibility="hidden";const t=document.createElement("button");t.id="open-in-ar",t.innerText="Open in QuickLook",e.appendChild(t);const g=document.createElement("a");g.id="needle-usdz-link",g.style.display="none",g.rel="ar",g.href="",e.appendChild(g);const I=document.createElement("img");return I.id="button",g.appendChild(I),i.domElement.appendChild(e),g}function OIA(){var i=new Date;const A=i.getMonth()+1,e=i.getDate(),t=i.getHours(),g=i.getMinutes(),I=i.getSeconds(),o=(A<10?"0":"")+A,s=(e<10?"0":"")+e,C=(t<10?"0":"")+t,n=(g<10?"0":"")+g,a=(I<10?"0":"")+I;return i.getFullYear()+o+s+"-"+C+n+a}const of=oA("debugusdz");function PIA(i,A){const e=[],t=eA.getComponentsInChildren(i,QI);let g=!1;of&&console.log(t);for(const I of t){if(!I||!I.runtimeAnimatorController)continue;of&&console.log(I);const o=[];for(const s of I.runtimeAnimatorController.enumerateActions()){of&&console.log(s);const C=s.getClip();if(!g&&C.tracks.length>0){g=!0;const n=C.tracks[0],a=n.name.substring(0,n.name.lastIndexOf(".")),r=new oo(a+".position",[0,.01],[0,0,0,0,0,0]),Q=new oo(a+".quaternion",[0,.01],[0,0,0,1,0,0,0,1]);o.push(new sI("rest",.01,[r,Q]))}o.includes(C)||o.push(C)}e.push({root:I.gameObject,clips:o})}of&&console.log(e);for(const I of e)for(const o of I.clips)A.registerAnimation(I.root,o)}var WIA=Object.defineProperty,VIA=Object.getOwnPropertyDescriptor,On=(i,A,e,t)=>{for(var g=t>1?void 0:t?VIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&WIA(A,e,g),g};const br=oA("debugtext");var Yi=(i=>(i[i.UpperLeft=0]="UpperLeft",i[i.UpperCenter=1]="UpperCenter",i[i.UpperRight=2]="UpperRight",i[i.MiddleLeft=3]="MiddleLeft",i[i.MiddleCenter=4]="MiddleCenter",i[i.MiddleRight=5]="MiddleRight",i[i.LowerLeft=6]="LowerLeft",i[i.LowerCenter=7]="LowerCenter",i[i.LowerRight=8]="LowerRight",i))(Yi||{}),GO=(i=>(i[i.Normal=0]="Normal",i[i.Bold=1]="Bold",i[i.Italic=2]="Italic",i[i.BoldAndItalic=3]="BoldAndItalic",i))(GO||{});class cI extends _B{constructor(){super(...arguments);B(this,"alignment",0);B(this,"verticalOverflow",0);B(this,"horizontalOverflow",0);B(this,"lineSpacing",1);B(this,"supportRichText",!1);B(this,"font");B(this,"fontStyle",0);B(this,"_text","");B(this,"_fontSize",12);B(this,"_textMeshUi",null);B(this,"_didHandleTextRenderOnTop",!1)}setAlphaFactor(e){var t;super.setAlphaFactor(e),(t=this.uiObject)==null||t.set({fontOpacity:this.color.alpha*this.alphaFactor}),this.markDirty()}get text(){return this._text}set text(e){e!==this._text&&(this._text=e,this.feedText(this.text,this.supportRichText),this.markDirty())}set_text(e){this.text=e}get fontSize(){return this._fontSize}set fontSize(e){var t;this._fontSize=e,(t=this.uiObject)==null||t.set({fontSize:e})}onColorChanged(){var e;(e=this.uiObject)==null||e.set({color:this.color,fontOpacity:this.color.alpha})}onParentRectTransformChanged(){super.onParentRectTransformChanged(),this.uiObject&&this.updateOverflow()}onBeforeRender(){var e;this.uiObject&&((e=this.Canvas)!=null&&e.screenspace||this.context.isInVR)&&this.updateOverflow()}updateOverflow(){var t;const e=(t=this.uiObject)==null?void 0:t._overflow;e&&(e._needsUpdate=!0,this.markDirty())}onCreate(e){br&&console.log(this),this.horizontalOverflow==1&&(e.whiteSpace="pre"),this.verticalOverflow==0&&(this.context.renderer.localClippingEnabled=!0,e.overflow="hidden"),this.horizontalOverflow==1&&this.verticalOverflow==0,e.lineHeight=this.lineSpacing,delete e.backgroundOpacity,delete e.backgroundColor,br&&(e.backgroundColor=16750848,e.backgroundOpacity=.5);const t=this.rectTransform;e={...e,...this.getTextOpts()},this.getAlignment(e),br&&(e.backgroundColor=Math.random()*16777215,e.backgroundOpacity=.1),this.uiObject=t.createNewText(e),this.feedText(this.text,this.supportRichText)}onAfterAddedToScene(){super.onAfterAddedToScene(),this.handleTextRenderOnTop()}getTextOpts(){let e=this.fontSize;const t={color:this.color,fontOpacity:this.color.alpha,fontSize:e,fontKerning:"normal"};return this.setFont(t,this.fontStyle),t}onEnable(){super.onEnable(),this._didHandleTextRenderOnTop=!1,this.uiObject&&this.uiObject.addAfterUpdate(()=>{this.setShadowComponentOwner(this.uiObject),this.markDirty()}),setTimeout(()=>this.markDirty(),10)}getAlignment(e){switch(e.flexDirection="column",this.alignment){case 0:case 3:case 6:e.textAlign="left";break;case 1:case 4:case 7:e.textAlign="center";break;case 2:case 5:case 8:e.textAlign="right";break}switch(this.alignment){default:case 0:case 1:case 2:e.alignItems="start";break;case 3:case 4:case 5:e.alignItems="center";break;case 6:case 7:case 8:e.alignItems="end";break}return e}feedText(e,t){var g,I,o;if(br&&console.log("feedText",this.uiObject,e,t),!!this.uiObject)if(this._textMeshUi||(this._textMeshUi=[]),this.uiObject.children.length=0,!t||e.length===0)this.uiObject.textContent=e;else{let s=this.getNextTag(e);if(s){if(s.startIndex>0){for(let a=this.uiObject.children.length-1;a>=0;a--){const r=this.uiObject.children[a];r.isUI&&(this.uiObject.remove(r),r.clear())}const n=new cD({textContent:e.substring(0,s.startIndex),color:"inherit"});this.uiObject.add(n)}}else{this.uiObject.textContent="",this.setOptions({textContent:e});return}const C=[];for(;s;){const n=this.getNextTag(e,s.endIndex),a={fontFamily:(g=this.uiObject)==null?void 0:g.get("fontFamily"),color:"inherit",textContent:""};if(n){a.textContent=this.getText(e,s,n),this.handleTag(s,a,C);const r=new cD(a);(I=this.uiObject)==null||I.add(r)}else{a.textContent=e.substring(s.endIndex),this.handleTag(s,a,C);const r=new cD(a);(o=this.uiObject)==null||o.add(r)}s=n}}}handleTextRenderOnTop(){this._didHandleTextRenderOnTop||(this._didHandleTextRenderOnTop=!0,this.startCoroutine(this.renderOnTopCoroutine()))}*renderOnTopCoroutine(){if(!this.canvas)return;const e=[],t=this.canvas,g={renderOnTop:t.renderOnTop,depthWrite:t.depthWrite,doubleSided:t.doubleSided};for(;;){let I=!1;if(this._textMeshUi)for(let o=0;o<this._textMeshUi.length;o++){if(e[o]===!0)continue;I=!0;const s=this._textMeshUi[o];s.textContent&&(Dy(s,g),e[o]=!0)}if(!I)break;yield}}handleTag(e,t,g){if(!e.isEndTag){if(e.type.includes("color")){const I=new Cm(e,{color:t.color});if(g.push(I),e.type.length>6){const o=parseInt("0x"+e.type.substring(7));t.color=o}else t.color=new DA(1,1,1)}else if(e.type=="b"){this.setFont(t,1);const I=new Cm(e,{fontWeight:700});g.push(I)}else if(e.type=="i"){this.setFont(t,2);const I=new Cm(e,{fontStyle:"italic"});g.push(I)}}}getText(e,t,g){return e.substring(t.endIndex,g.startIndex)}getNextTag(e,t=0){const g=e.indexOf("<",t),I=e.indexOf(">",g);if(g>=0&&I>=0){const o=e.substring(g+1,I);return{type:o,startIndex:g,endIndex:I+1,isEndTag:o.startsWith("/")}}return null}setFont(e,t){if(!this.font)return;let g=this.font,I=this.getFamilyNameWithCorrectSuffix(g,t);br&&console.log("Selected font family:"+I);let o=KM.getFontFamily(I);switch(o||(o=KM.addFontFamily(I)),e.fontFamily=o,t){default:case 0:e.fontWeight=400,e.fontStyle="normal";break;case 1:e.fontWeight=700,e.fontStyle="normal";break;case 2:e.fontWeight=400,e.fontStyle="italic";break;case 3:e.fontStyle="italic",e.fontWeight=400}let s=o.getVariant(e.fontWeight,e.fontStyle);if(!s){let C=I;C!=null&&C.endsWith("-msdf.json")||(C+="-msdf.json");let n=I;n!=null&&n.endsWith(".png")||(n+=".png"),s=o.addVariant(e.fontWeight,e.fontStyle,C,n),s==null||s.addEventListener("ready",()=>{this.markDirty()})}}getFamilyNameWithCorrectSuffix(e,t){var a;const g=e.lastIndexOf("-");if(g<0)return e;const I=(a=e.substring(g+1))==null?void 0:a.toLowerCase();if(zIA.includes(I))return br&&console.warn("Unsupported font style: "+I),e;const o=e.lastIndexOf("/");let s=e;o>=0&&(s=s.substring(o+1));let C=s[0]===s[0].toUpperCase();const n=e.substring(0,g);switch(br&&console.log("Select font: ",e,GO[t],s,C,n),t){case 0:return C?n+"-Regular":n+"-regular";case 1:return C?n+"-Bold":n+"-bold";case 2:return C?n+"-Italic":n+"-italic";case 3:return C?n+"-BoldItalic":n+"-bolditalic";default:return e}}}On([y()],cI.prototype,"alignment",2);On([y()],cI.prototype,"verticalOverflow",2);On([y()],cI.prototype,"horizontalOverflow",2);On([y()],cI.prototype,"lineSpacing",2);On([y()],cI.prototype,"supportRichText",2);On([y(URL)],cI.prototype,"font",2);On([y()],cI.prototype,"fontStyle",2);On([y()],cI.prototype,"text",1);On([y()],cI.prototype,"fontSize",1);class Cm{constructor(A,e){B(this,"tag");B(this,"previousValues");this.tag=A,this.previousValues=e}}const zIA=["medium","mediumitalic","black","blackitalic","thin","thinitalic","extrabold","light","lightitalic","semibold"];class Fa{constructor(A){B(this,"id");B(this,"content","");B(this,"font",[]);B(this,"pointSize",144);B(this,"width");B(this,"height");B(this,"depth");B(this,"wrapMode");B(this,"horizontalAlignment");B(this,"verticalAlignment");B(this,"material");this.id=A}static getId(){return this.global_id++}setDepth(A){return this.depth=A,this}setPointSize(A){return this.pointSize=A,this}setHorizontalAlignment(A){return this.horizontalAlignment=A,this}setVerticalAlignment(A){return this.verticalAlignment=A,this}writeTo(A,e){var g;e.beginBlock(`def Preliminary_Text "${this.id}"`),this.content&&e.appendLine(`string content = "${this.content}"`),(!this.font||this.font.length<=0)&&(this.font||(this.font=[]),(g=this.font)==null||g.push("sans-serif"));const t=this.font.map(I=>`"${I}"`).join(", ");e.appendLine(`string[] font = [ ${t} ]`),e.appendLine(`double pointSize = ${this.pointSize}`),typeof this.width=="number"&&e.appendLine(`double width = ${this.width}`),typeof this.height=="number"&&e.appendLine(`double height = ${this.height}`),typeof this.depth=="number"&&e.appendLine(`double depth = ${this.depth}`),this.wrapMode&&e.appendLine(`token wrapMode = "${this.wrapMode}"`),this.horizontalAlignment&&e.appendLine(`token horizontalAlignment = "${this.horizontalAlignment}"`),this.verticalAlignment&&e.appendLine(`token verticalAlignment = "${this.verticalAlignment}"`),this.material!==void 0&&e.appendLine(`rel material:binding = </Materials/Material_${this.material.id}>`),e.closeBlock()}}B(Fa,"global_id",0);class NS{static singleLine(A,e,t){const g=new Fa("text_"+Fa.getId());return g.content=A,e&&(g.pointSize=e),t&&(g.depth=t),g}static multiLine(A,e,t,g,I,o){const s=new Fa("text_"+Fa.getId());return s.content=A,s.width=e,s.height=t,s.horizontalAlignment=g,s.verticalAlignment=I,o!==void 0&&(s.wrapMode=o),s}}const jIA=new qA().makeRotationY(Math.PI),ZIA=new qA().makeScale(-1,1,-1);class yu{get extensionName(){return"text"}onExportObject(A,e,t){}exportText(A,e,t){const g=eA.getComponent(A,cI);if(!g)return;const I=eA.getComponent(A,yg);let o=100,s=100;I&&(o=I.width,s=I.height),e.matrix=jIA.clone(),I&&e.matrix.premultiply(ZIA);const C=new DA().copySRGBToLinear(g.color);e.material=new ks({color:C,emissive:C}),e.addEventListener("serialize",(n,a)=>{let r=g.text;r=r.replace(/\n/g,"\\n");const Q=NS.multiLine(r,o,s,"center","bottom","flowing");this.setTextAlignment(Q,g.alignment),this.setOverflow(Q,g),e.material&&(Q.material=e.material),Q.pointSize=this.convertToTextSize(g.fontSize),Q.depth=.001,Q.writeTo(void 0,n)})}convertToTextSize(A){return 1/.0502*144*A}setOverflow(A,e){e.horizontalOverflow?A.wrapMode="singleLine":A.wrapMode="flowing"}setTextAlignment(A,e){switch(e){case Yi.LowerLeft:case Yi.MiddleLeft:case Yi.UpperLeft:A.horizontalAlignment="left";break;case Yi.LowerCenter:case Yi.MiddleCenter:case Yi.UpperCenter:A.horizontalAlignment="center";break;case Yi.LowerRight:case Yi.MiddleRight:case Yi.UpperRight:A.horizontalAlignment="right";break}switch(e){case Yi.LowerLeft:case Yi.LowerCenter:case Yi.LowerRight:A.verticalAlignment="bottom";break;case Yi.MiddleLeft:case Yi.MiddleCenter:case Yi.MiddleRight:A.verticalAlignment="middle";break;case Yi.UpperLeft:case Yi.UpperCenter:case Yi.UpperRight:A.verticalAlignment="top";break}}}class KS{get extensionName(){return"tmui"}onExportObject(A,e,t){const g=eA.getComponent(A,wg);if(g&&g.activeAndEnabled&&g.renderMode===SO.WorldSpace){const I=new yu,o=eA.getComponent(A,yg),s=eA.getComponent(A,$a);if(o){o.width,o.height;const C=GI.createEmpty(),n=o.shadowComponent;if(e.add(C),n){const a=n.matrix;C.matrix.copy(a);const r=new Map,Q=new Map;r.set(n,C),Q.set(n,s?s.alpha:1),n.traverse(E=>{if(E===n)return;const h=GI.createEmpty();h.matrix.copy(E.matrix);const l=E.parent,d=l&&typeof l.textContent=="string"&&l.textContent.length;let c=Q.get(l)||1;const p=eA.getComponent(E,$a);if(p&&(c*=p.alpha),E instanceof yA&&d){const f=E[AC].gameObject;I.exportText(f,h,t)}if(E instanceof yA&&!d){const f=E.geometry.clone();f.scale(1,1,-1),this.flipWindingOrder(f),h.geometry=f;const D=new DA,w=E.material.opacity;D.copy(E.material.color),h.material=new dt({color:D,opacity:w*c,map:E.material.map,transparent:!0})}r.set(E,h),Q.set(E,c);const u=r.get(l);if(!u){console.error("Error when exporting UI: shadow component parent not found!",E,E.parent);return}u.add(h)})}}}}flipWindingOrder(A){const e=A.index.array;for(let t=0,g=e.length/3;t<g;t++){let I=e[t*3];e[t*3]=e[t*3+2],e[t*3+2]=I}A.index.needsUpdate=!0}}var XIA=Object.defineProperty,$IA=Object.getOwnPropertyDescriptor,Eo=(i,A,e,t)=>{for(var g=t>1?void 0:t?$IA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&XIA(A,e,g),g};const Zi=oA("debugusdz");class fr{constructor(){B(this,"callToAction");B(this,"checkoutTitle");B(this,"checkoutSubtitle");B(this,"callToActionURL")}}Eo([y()],fr.prototype,"callToAction",2);Eo([y()],fr.prototype,"checkoutTitle",2);Eo([y()],fr.prototype,"checkoutSubtitle",2);Eo([y()],fr.prototype,"callToActionURL",2);class ho extends mA{constructor(){super(...arguments);B(this,"objectToExport");B(this,"autoExportAnimations",!1);B(this,"exportFileName");B(this,"customUsdzFile");B(this,"customBranding");B(this,"anchoringType","plane");B(this,"planeAnchoringAlignment","horizontal");B(this,"interactive",!0);B(this,"extensions",[]);B(this,"allowCreateQuicklookButton",!0);B(this,"link");B(this,"webxr");B(this,"onClickedOpenInARElement",e=>{e.preventDefault(),this.exportAsync()});B(this,"lastCallback");B(this,"_quicklookButton");B(this,"_quicklookButtonContainer",null)}start(){var e,t,g;Zi&&(console.log(this),console.log("Debug USDZ, press 't' to export"),window.addEventListener("keydown",I=>{switch(I.key){case"t":this.exportAsync();break}}),ir()&&setTimeout(()=>{this.exportAsync()},2e3)),this.objectToExport||(this.objectToExport=this.gameObject),!((t=(e=this.objectToExport)==null?void 0:e.children)!=null&&t.length)&&!((g=this.objectToExport)!=null&&g.isMesh)&&(this.objectToExport=this.context.scene),this.interactive&&(this.extensions.push(new GS),this.extensions.push(new kS),this.extensions.push(new yu),this.extensions.push(new KS))}onEnable(){var g;const e=vl(),t=tn();(Zi||e&&t)&&((Zi||this.allowCreateQuicklookButton)&&this.addQuicklookButton(),this.lastCallback=this.quicklookCallback.bind(this),this.link=_IA(this.context),this.link.addEventListener("message",this.lastCallback)),Zi&&Mi("USDZ Exporter enabled: "+this.name),(g=document.getElementById("open-in-ar"))==null||g.addEventListener("click",this.onClickedOpenInARElement)}onDisable(){var g,I;(g=this.link)==null||g.removeEventListener("message",this.lastCallback);const e=vl(),t=tn();(Zi||e&&t)&&this.removeQuicklookButton(),Zi&&Mi("USDZ Exporter disabled: "+this.name),(I=document.getElementById("open-in-ar"))==null||I.removeEventListener("click",this.onClickedOpenInARElement)}async exportAsync(){var l;let e=this.exportFileName??((l=this.objectToExport)==null?void 0:l.name)??this.name;if(wE()||(e+="-MadeWithNeedle"),e+="-"+OIA(),this.customUsdzFile){Zi&&console.log("Exporting custom usdz",this.customUsdzFile);const d=this.buildQuicklookOverlay();Zi&&console.log(d);const c=d.callToAction?encodeURIComponent(d.callToAction):"",p=d.checkoutTitle?encodeURIComponent(d.checkoutTitle):"",u=d.checkoutSubtitle?encodeURIComponent(d.checkoutSubtitle):"";this.link.href=this.customUsdzFile+`#callToAction=${c}&checkoutTitle=${p}&checkoutSubtitle=${u}&callToActionURL=${d.callToActionURL}`,Zi&&console.log(this.link.href),this.lastCallback||(this.lastCallback=this.quicklookCallback.bind(this),this.link.addEventListener("message",this.lastCallback)),this.link.download=e+".usdz",this.link.click();return}if(!this.objectToExport)return;const t=eA.getComponentsInChildren(this.objectToExport,_t),g=new Array;for(const d of t)for(const c of d.sharedMaterials)if(c){const p=d.loadProgressiveTextures(c);p instanceof Promise&&g.push(p)}Zi&&Mi("Load textures: "+g.length),await Promise.all(g),Zi&&Mi("Load textures: done"),this.applyWebARSessionRoot();const I=new Z7,o=[...this.extensions],s=new CS;o.push(s),this.autoExportAnimations&&PIA(this.objectToExport,s);const C={self:this,exporter:I,extensions:o,object:this.objectToExport};this.dispatchEvent(new CustomEvent("before-export",{detail:C})),I.debug=Zi,this.anchoringType!=="plane"&&this.anchoringType!=="none"&&this.anchoringType!=="image"&&this.anchoringType!=="face"&&(this.anchoringType="plane"),this.planeAnchoringAlignment!=="horizontal"&&this.planeAnchoringAlignment!=="vertical"&&this.planeAnchoringAlignment!=="any"&&(this.planeAnchoringAlignment="horizontal");const n=await I.parse(this.objectToExport,{ar:{anchoring:{type:this.anchoringType},planeAnchoring:{alignment:this.planeAnchoringAlignment}},extensions:o,quickLookCompatible:!0}),a=new Blob([n],{type:"application/octet-stream"});this.dispatchEvent(new CustomEvent("after-export",{detail:C}));const r=this.buildQuicklookOverlay();Zi&&console.log(r);const Q=r.callToAction?encodeURIComponent(r.callToAction):"",E=r.checkoutTitle?encodeURIComponent(r.checkoutTitle):"",h=r.checkoutSubtitle?encodeURIComponent(r.checkoutSubtitle):"";this.link.href=URL.createObjectURL(a)+`#callToAction=${Q}&checkoutTitle=${E}&checkoutSubtitle=${h}&callToActionURL=${r.callToActionURL}`,this.lastCallback||(this.lastCallback=this.quicklookCallback.bind(this),this.link.addEventListener("message",this.lastCallback)),this.link.download=e+".usdz",this.link.click()}quicklookCallback(e){if((e==null?void 0:e.data)=="_apple_ar_quicklook_button_tapped"){Zi&&zo("Quicklook closed via call to action button");var t=new CustomEvent("quicklook-button-tapped",{detail:this});if(this.dispatchEvent(t),!t.defaultPrevented){const g=new URLSearchParams(this.link.href);if(g){const I=g.get("callToActionURL");Zi&&Mi("Quicklook url: "+I),I&&(wE()?globalThis.open(I,"_blank"):console.warn("Quicklook closed: custom redirects require a Needle Engine Pro license: https://needle.tools/pricing",I))}}}}buildQuicklookOverlay(){var g,I,o,s,C,n;const e={};return this.customBranding&&Object.assign(e,this.customBranding),wE()||(console.log("Custom Quicklook banner text requires pro license: https://needle.tools/pricing"),e.callToAction="Close",e.checkoutTitle="🌵 Made with Needle",e.checkoutSubtitle="_"),(((g=e.callToAction)==null?void 0:g.length)||((I=e.checkoutTitle)==null?void 0:I.length)||((o=e.checkoutSubtitle)==null?void 0:o.length))&&((s=e.callToAction)!=null&&s.length||(e.callToAction="\0"),(C=e.checkoutTitle)!=null&&C.length||(e.checkoutTitle="\0"),(n=e.checkoutSubtitle)!=null&&n.length||(e.checkoutSubtitle="\0")),this.dispatchEvent(new CustomEvent("quicklook-overlay",{detail:e})),e}async createQuicklookButton(){var e,t;if(!this.webxr)if(await Kd(1),this.webxr=eA.findObjectOfType(Se)??void 0,this.webxr)if(this.webxr.VRButton&&((e=this.webxr.VRButton.parentElement)==null||e.removeChild(this.webxr.VRButton)),this.webxr.ARButton&&this._quicklookButton!==this.webxr.ARButton){this._quicklookButton=this.webxr.ARButton;const g=(t=this.webxr.ARButton.parentElement)==null?void 0:t.querySelector("a");g&&(g.href=""),this.webxr.ARButton.innerText="Open in Quicklook",this.webxr.ARButton.disabled=!1,this.webxr.ARButton.addEventListener("click",I=>{I.preventDefault(),this.exportAsync()}),this.webxr.ARButton.classList.add("quicklook-ar-button"),this._quicklookButtonContainer=this.webxr.ARButton.parentElement,this.dispatchEvent(new CustomEvent("created-button",{detail:this.webxr.ARButton}))}else{this.webxr.createARButton=!1,this.webxr.createVRButton=!1;let g=this.context.domElement.shadowRoot.querySelector(".webxr-buttons");g||(g=document.createElement("div"),g.classList.add("webxr-buttons"));const I=document.createElement("button");I.innerText="Open in Quicklook",I.addEventListener("click",()=>{this.exportAsync()}),I.classList.add("webxr-ar-button"),I.classList.add("webxr-button"),I.classList.add("quicklook-ar-button"),this._quicklookButton=I,g.appendChild(I),this._quicklookButtonContainer=g,this.dispatchEvent(new CustomEvent("created-button",{detail:I}))}else console.warn("Could not find WebXR component: will not create Quicklook button",Je.Current)}async addQuicklookButton(){await this.createQuicklookButton(),this._quicklookButton&&this._quicklookButtonContainer&&this._quicklookButtonContainer.appendChild(this._quicklookButton)}removeQuicklookButton(){var e;(e=this._quicklookButton)==null||e.remove()}applyWebARSessionRoot(){if(Zi&&console.log("applyWebARSessionRoot"),!this.objectToExport)return;let e=eA.getComponentInParent(this.objectToExport,lC);const t=e!=null;if(e||(e=eA.getComponentInChildren(this.objectToExport,lC)),!e){Zi&&console.warn("No WebARSessionRoot found in parent hierarchy",this.objectToExport);return}const g=t?this.objectToExport:e.gameObject,I=1/e.arScale;Zi&&console.log("Scale",I,g),g.matrix.makeScale(I,I,I),e.invertForward&&g.matrix.multiply(new qA().makeRotationY(Math.PI))}}Eo([y(bA)],ho.prototype,"objectToExport",2);Eo([y()],ho.prototype,"autoExportAnimations",2);Eo([y()],ho.prototype,"exportFileName",2);Eo([y(URL)],ho.prototype,"customUsdzFile",2);Eo([y(fr)],ho.prototype,"customBranding",2);Eo([y()],ho.prototype,"anchoringType",2);Eo([y()],ho.prototype,"planeAnchoringAlignment",2);Eo([y()],ho.prototype,"interactive",2);Eo([y()],ho.prototype,"allowCreateQuicklookButton",2);const zb=oA("debugdeletable");class JS extends Lo{}class YF extends mA{constructor(){super(...arguments);B(this,"deleteBoxes",[])}awake(){this.deleteBoxes=eA.findObjectsOfType(JS,this.context)}update(){for(const e of this.deleteBoxes){const t=this.gameObject;if(e.isInBox(t)===!0){const I=eA.getComponentInParent(this.gameObject,fh);I?zb&&console.warn("Can not delete object with usage marker",this.guid,I):(zb&&console.log("DESTROY",this.gameObject),Pw(this.gameObject,this.context.connection))}}}}var AoA=Object.defineProperty,eoA=Object.getOwnPropertyDescriptor,zB=(i,A,e,t)=>{for(var g=t>1?void 0:t?eoA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&AoA(A,e,g),g};class qs extends _g{constructor(){super(...arguments);B(this,"mode");B(this,"focusDistance");B(this,"focalLength");B(this,"aperture");B(this,"gaussianMaxRadius");B(this,"resolutionScale");B(this,"bokehScale")}get typeName(){return"DepthOfField"}init(){this.focalLength.valueProcessor=t=>{const g=t/300,I=2;return te.lerp(I,.01,g)};const e=20;this.aperture.valueProcessor=t=>{const g=1-t/32;return te.lerp(1,e,g)}}onCreateEffect(){if(this.mode===0)return;const e=1/window.devicePixelRatio;if(this.resolutionScale===void 0){let g=1;ir()&&(g=.6),this.resolutionScale=new Re(g*e)}const t=new FH(this.context.mainCamera,{worldFocusRange:.2,focalLength:1,bokehScale:20,resolutionScale:this.resolutionScale.value});return this.focusDistance.onValueChanged=g=>{t.circleOfConfusionMaterial.worldFocusDistance=g},this.focalLength.onValueChanged=g=>t.circleOfConfusionMaterial.worldFocusRange=g,this.aperture.onValueChanged=g=>t.bokehScale=g,this.resolutionScale&&(this.resolutionScale.onValueChanged=g=>t.resolution.scale=g),[t]}unapply(){}}zB([y()],qs.prototype,"mode",2);zB([y(Re)],qs.prototype,"focusDistance",2);zB([y(Re)],qs.prototype,"focalLength",2);zB([y(Re)],qs.prototype,"aperture",2);zB([y(Re)],qs.prototype,"gaussianMaxRadius",2);zB([y(Re)],qs.prototype,"resolutionScale",2);zB([y(Re)],qs.prototype,"bokehScale",2);As("DepthOfField",qs);var toA=Object.defineProperty,ioA=Object.getOwnPropertyDescriptor,goA=(i,A,e,t)=>{for(var g=t>1?void 0:t?ioA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&toA(A,e,g),g};class qS extends mA{constructor(){super(...arguments);B(this,"visibleOn")}onEnable(){this.apply()}apply(){this.test()||eA.setActive(this.gameObject,!1)}test(){return this.visibleOn<0?!0:IoA()?(this.visibleOn&2)!==0:(this.visibleOn&1)!==0}}goA([y()],qS.prototype,"visibleOn",2);let sf;function IoA(){if(sf===!0||sf===!1)return sf;let i=!1;return function(A){(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(A)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(A.substr(0,4)))&&(i=!0)}(navigator.userAgent||navigator.vendor||window.opera),sf=i,i}class HF{get extensionName(){return"DocumentExtension"}onAfterBuildDocument(A){}}var ooA=Object.defineProperty,soA=Object.getOwnPropertyDescriptor,MO=(i,A,e,t)=>{for(var g=t>1?void 0:t?soA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&ooA(A,e,g),g},RO=(i=>(i.SelectStart="selectstart",i.SelectEnd="selectend",i))(RO||{}),Yf;const ya=(Yf=class extends ph{constructor(){super();B(this,"showGizmo",!0);B(this,"useViewAngle",!0);B(this,"transformSelf",!0);B(this,"orbit",null);B(this,"selectStartEventListener",[]);B(this,"selectEndEventListener",[]);B(this,"_dragHelper",null);B(this,"_draggingRigidbodies",[]);B(this,"_waitingForDragStart",null);B(this,"_isDragging",!1);B(this,"_marker",null);B(this,"_dragDelta");B(this,"_didDrag",!1);B(this,"_activePointerId");this.selectStartEventListener=[],this.selectEndEventListener=[],this._dragDelta=new X}static get HasAnySelected(){return this._active>0}addDragEventListener(A,e){switch(A){case"selectstart":this.selectStartEventListener.push(e);break;case"selectend":this.selectEndEventListener.push(e);break}}start(){this.orbit=eA.findObjectOfType(Tn,this.context),this.gameObject.getComponentInParent(Un)||this.gameObject.addNewComponent(Un)}allowEdit(A=null){return this.context.connection.allowEditing}onPointerEnter(A){if(!this.allowEdit(this.gameObject)||Se.IsInWebXR)return;const e=eA.getComponentInParent(A.object,ya);!e||e!==this||(ya.lastHovered=A.object,this.context.domElement.style.cursor="pointer")}onPointerExit(A){this.allowEdit(this.gameObject)&&(Se.IsInWebXR||ya.lastHovered===A.object&&(this.context.domElement.style.cursor="auto"))}onPointerDown(A){this.allowEdit(this.gameObject)&&(Se.IsInWebXR||(ya._active+=1,this._dragDelta.set(0,0),this._didDrag=!1,this._waitingForDragStart=A.clone(),A.stopPropagation(),this.orbit&&(this.orbit.enabled=!1)))}onPointerUp(A){this._waitingForDragStart=null,this.allowEdit(this.gameObject)&&(ya._active>0&&(ya._active-=1),!Se.IsInWebXR&&(this.onDragEnd(A),A.stopPropagation(),this.orbit&&(this.orbit.enabled=!0)))}update(){var A;if(!Se.IsInWebXR){if(this._waitingForDragStart){if(!this._didDrag){const t=this.context.input.getPointerPositionDelta(0);if(t&&this._dragDelta.add(t),this._dragDelta.length()>2)this._didDrag=!0;else return}const e=this._waitingForDragStart;this._waitingForDragStart=null,this.onDragStart(e)}this._dragHelper&&this._dragHelper.hasSelected&&this.onUpdateDrag(),(((A=this._dragHelper)==null?void 0:A.hasSelected)===!1||this._activePointerId!==void 0&&this.context.input.getPointerPressed(this._activePointerId)===!1)&&this.onDragEnd(null)}}onDragStart(A){if(!this._dragHelper)if(this.context.mainCamera)this._dragHelper=new uD(this.context.mainCamera);else return;if(!A||!A.object)return;const e=eA.getComponentInParent(A.object,ya);if(!e||e!==this)return;let t=A.object;this.transformSelf&&(t=this.gameObject);const g={selected:t,attached:t};for(const C of this.selectStartEventListener)C(this,g);if(this._activePointerId=A.pointerId,!g.attached)return;g.attached,t=g.attached,this._isDragging=!0,this._dragHelper.setSelected(t,this.context),this.orbit&&(this.orbit.enabled=!1);const I=eA.getComponentInChildren(t,ja);I&&(I.fastMode=!0,I==null||I.requestOwnership()),this._marker=eA.addNewComponent(t,fh),this._draggingRigidbodies.length=0;const o=eA.getComponentsInChildren(t,Xt);o&&this._draggingRigidbodies.push(...o);const s=bD();eA.invokeOnChildren(this._dragHelper.selected,s("onDragStart"))}onUpdateDrag(){if(this._dragHelper){this._dragHelper.showGizmo=this.showGizmo,this._dragHelper.useViewAngle=this.useViewAngle,this._dragHelper.onUpdate(this.context);for(const A of this._draggingRigidbodies)A.wakeUp(),A.resetVelocities()}}onDragEnd(A){if(!this||!this._isDragging||(this._isDragging=!1,!this._dragHelper))return;for(const g of this._draggingRigidbodies)g.setVelocity(g.smoothedVelocity);this._draggingRigidbodies.length=0;const e=this._dragHelper.selected;if(this._dragHelper.setSelected(null,this.context),this.orbit&&(this.orbit.enabled=!0),A!=null&&A.object){const g=eA.getComponentInChildren(A.object,ja);g&&(g.fastMode=!1)}this._marker&&this._marker.destroy();for(const g of this.selectEndEventListener)g(this);const t=bD();eA.invokeOnChildren(e,t("onDragEnd"))}},B(Yf,"_active",0),B(Yf,"lastHovered"),Yf);let xh=ya;MO([y()],xh.prototype,"showGizmo",2);MO([y()],xh.prototype,"useViewAngle",2);const iK=class{constructor(A){B(this,"showGizmo",!0);B(this,"useViewAngle",!0);B(this,"_selected",null);B(this,"_context",null);B(this,"_camera");B(this,"_cameraPlane",new qo);B(this,"_hasGroundPlane",!1);B(this,"_groundPlane",new qo);B(this,"_groundOffset",new m);B(this,"_groundOffsetFactor",0);B(this,"_groundDistance",0);B(this,"_groundPlanePoint",new m);B(this,"_raycaster",new nh);B(this,"_cameraPlaneOffset",new m);B(this,"_intersection",new m);B(this,"_worldPosition",new m);B(this,"_inverseMatrix",new qA);B(this,"_rbs",[]);B(this,"_groundLine");B(this,"_groundMarker");B(this,"_groundOffsetVector",new m(0,1,0));B(this,"_requireUpdateGroundPlane",!0);B(this,"_didDragOnGroundPlaneLastFrame",!1);this._camera=A;const e=new ci(iK.geometry),t=e.material;t.color=new DA(.4,.4,.4),e.layers.set(2),e.name="line",e.scale.y=1,this._groundLine=e;const g=new Zo(.5,22,22),I=new dt({color:t.color}),o=new yA(g,I);o.visible=!1,o.layers.set(2),this._groundMarker=o}get hasSelected(){return this._selected!==null&&this._selected!==void 0}get selected(){return this._selected}setSelected(A,e){if(this._selected&&e)for(const t of this._rbs)t.wakeUp(),t.setVelocity(0,0,0);if(this._selected&&nI.Remove(e,this._selected),this._selected=A,this._context=e,this._rbs.length=0,A?(e.scene.add(this._groundLine),e.scene.add(this._groundMarker)):(this._groundLine.removeFromParent(),this._groundMarker.removeFromParent()),this._selected){if(!e){console.error("DragHelper: no context");return}nI.Add(e,this._selected,null),this._groundOffsetFactor=0,this._hasGroundPlane=!0,this._groundOffset.set(0,0,0),this._requireUpdateGroundPlane=!0,this.onUpdateScreenSpacePlane()}}onUpdate(A){var s,C,n,a,r;if(!this._context)return;const e="Space",t="KeyD",g=((s=this._context)==null?void 0:s.input.isKeyPressed(e))||((C=this._context)==null?void 0:C.input.isKeyPressed(t)),I=this._context.input.getTouchesPressedCount()>=2||g;if(I){const Q=this._context.input.getPointerPositionDelta(0);Q&&(this._groundOffsetVector.set(0,1,0),(n=this._selected)==null||n.rotateOnWorldAxis(this._groundOffsetVector,Q.x*this._context.time.deltaTime))}const o=this._context.input.getPointerPositionRC(0);if(o&&(this._raycaster.setFromCamera(o,this._camera),this._selected)){this._groundOffsetVector.set(0,1,0);const Q=ye(this._camera).clone().sub(ye(this._selected)).normalize(),E=Math.abs(Q.dot(this._groundOffsetVector)),h=((a=this._context)==null?void 0:a.input.isKeyPressed(e))||((r=this._context)==null?void 0:r.input.isKeyPressed(t));let l=!this.useViewAngle||E>.2;(I||h||this._context.input.getPointerPressedCount()>1)&&(l=!1);const d=this._didDragOnGroundPlaneLastFrame!==l;if(this._didDragOnGroundPlaneLastFrame=l,this._hasGroundPlane||(this._requireUpdateGroundPlane=!0),(this._requireUpdateGroundPlane||!l||d)&&this.onUpdateGroundPlane(),this._requireUpdateGroundPlane=!1,this._hasGroundPlane)if(this._raycaster.ray.intersectPlane(this._groundPlane,this._intersection)){const c=this._intersection.y;if(this._groundPlanePoint.copy(this._intersection).sub(this._groundOffset),this._groundPlanePoint.y=c,l){this._groundOffsetVector.set(0,1,0);const p=this._intersection.sub(this._groundOffset).add(this._groundOffsetVector.multiplyScalar(this._groundOffsetFactor));this.onUpdateWorldPosition(p,this._groundPlanePoint,!1),this.onDidUpdate();return}}else this._groundPlanePoint.set(0,99999,0);d&&this.onUpdateScreenSpacePlane(),this._requireUpdateGroundPlane=!0,this._raycaster.ray.intersectPlane(this._cameraPlane,this._intersection)&&(this.onUpdateWorldPosition(this._intersection.sub(this._cameraPlaneOffset),this._groundPlanePoint,!0),this.onDidUpdate())}}onUpdateWorldPosition(A,e,t){if(this._selected){if(t){const g=ye(this._selected);g.y=A.y,A=g}if(di(this._selected,A),di(this._groundLine,A),this._hasGroundPlane?this._groundLine.scale.y=this._groundDistance:this._groundLine.scale.y=1e3,this._groundLine.visible=this.showGizmo,this._groundMarker.visible=e!==null&&this.showGizmo,e){const g=ye(this._camera).distanceTo(e)*.01;this._groundMarker.scale.set(g,g,g),di(this._groundMarker,e)}}}onUpdateScreenSpacePlane(){if(!this._selected||!this._context)return;const A=this._context.input.getPointerPositionRC(0);A&&(this._raycaster.setFromCamera(A,this._camera),this._cameraPlane.setFromNormalAndCoplanarPoint(this._camera.getWorldDirection(this._cameraPlane.normal),this._worldPosition.setFromMatrixPosition(this._selected.matrixWorld)),this._raycaster.ray.intersectPlane(this._cameraPlane,this._intersection)&&this._selected.parent&&(this._inverseMatrix.copy(this._selected.parent.matrixWorld).invert(),this._cameraPlaneOffset.copy(this._intersection).sub(this._worldPosition.setFromMatrixPosition(this._selected.matrixWorld))))}onUpdateGroundPlane(){if(!this._selected||!this._context)return;const A=ye(this._selected),e=new pC(new m(0,.1,0).add(A),new m(0,-1,0)),t=new Fs;t.ignore=[this._selected];const g=this._context.physics.raycastFromRay(e,t);for(let I=0;I<g.length;I++){const o=g[I];if(!o.face||this.contains(this._selected,o.object))continue;const s=new m(0,1,0);this._groundPlane.setFromNormalAndCoplanarPoint(s,o.point);break}this._hasGroundPlane=!0,this._groundPlane.setFromNormalAndCoplanarPoint(e.direction.multiplyScalar(-1),e.origin),this._raycaster.ray.intersectPlane(this._groundPlane,this._intersection),this._groundDistance=this._intersection.distanceTo(A),this._groundOffset.copy(this._intersection).sub(A)}onDidUpdate(){UI.markDirty(this._selected);for(const A of this._rbs)A.wakeUp(),A.resetForcesAndTorques(),A.setAngularVelocity(0,0,0)}contains(A,e){if(A===e)return!0;if(A.children){for(const t of A.children)if(this.contains(t,e))return!0}return!1}};let uD=iK;B(uD,"geometry",new we().setFromPoints([new m(0,0,0),new m(0,-1,0)]));function _F(i,A,e){console.warn("Adding components on object has been temporarily disabled")}var UO=(i=>(i.File_Spawned="file-spawned",i))(UO||{});class FO{constructor(A,e,t,g,I,o,s,C){B(this,"guid");B(this,"file_name");B(this,"file_hash");B(this,"file_size");B(this,"position");B(this,"seed");B(this,"sender");B(this,"serverUrl");B(this,"parentGuid");B(this,"boundsSize");this.seed=e,this.guid=t,this.file_name=g,this.file_hash=I,this.file_size=o,this.position=s,this.sender=A,this.serverUrl=C}}async function NO(i,A,e){const t=i.name;return t.endsWith(".gltf")||t.endsWith(".glb")?new Promise((g,I)=>{const o=new FileReader;o.readAsArrayBuffer(i),o.onloadend=async s=>{const C=o.result,n=Ww(),a=new CI(n),r=await ms().parseSync(A,C,i.name,a);if(r&&r.scene){const Q=r.scene;if(!Q.guid){const E=new CI(n);Q.guid=E.generateUUID()}e&&CoA(A.connection,i,n,Q,e),_F(),g(r)}}}):(console.warn("Unsupported file type: "+t,i),null)}async function KO(i,A){return new Promise(async(e,t)=>{const g=Ww(),I=new CI(g),o=i.toString(),s=await ms().loadSync(A,o,o,I);s&&s.scene?(s.scene,_F(),e(s)):console.warn("Unsupported file type: "+i.toString())})}Kt.registerCallback(Lg.ContextCreated,i=>{JO(i.context)});function JO(i){i.connection.beginListen("file-spawned",async A=>{if(A.sender!==i.connection.connectionId){console.log("received file event",A),noA(A,i);let e=null;try{e=await GU(A.file_name,A.file_hash,A.file_size,A.serverUrl)}finally{aoA(A)}if(e){const t=new CI(A.seed),g=await ms().parseSync(i,e,A.file_name,t);if(g&&g.scene){const I=g.scene;if(_F(),A.parentGuid){const o=Zd(A.parentGuid,i.scene);o&&"add"in o&&o.add(I)}I.parent||i.scene.add(I),A.position!==null&&I.position.copy(A.position)}}else console.error("download didnt return file")}})}async function CoA(i,A,e,t,g){if(!i.connectionId){console.error("Can not upload file - no connection id");return}if(!t.guid){console.error("Can not upload file - no guid",t,t.guid);return}const I=await HH(A,g);if(!I)return;if(!I.filename){console.error("Can not send upload event - no filename",A.name);return}if(!I.hash){console.error("Can not send upload event - no hash",A.name);return}const o=new FO(i.connectionId,e,t.guid,I.filename,I.hash,A.size,t.position,I.url??g);t.parent&&(o.parentGuid=t.parent.guid),i.send("file-spawned",o)}const xM={};function noA(i,A){const e=new Dt,t=new yA(e,new dt({color:65280})),g=new Uw(t,5592405);if(xM[i.guid]=g,A.scene.add(g),i.parentGuid){const I=Zd(i.parentGuid,A.scene);I&&I.add(g)}i.position&&g.position.copy(i.position)}function aoA(i,A){const e=i.guid,t=xM[e];t&&(delete xM[e],t.removeFromParent())}var roA=Object.defineProperty,BoA=Object.getOwnPropertyDescriptor,OF=(i,A,e,t)=>{for(var g=t>1?void 0:t?BoA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&roA(A,e,g),g};const QoA=oA("debugnet"),LM=class extends mA{constructor(){super(...arguments);B(this,"url",null);B(this,"urlParameterName",null);B(this,"localhost",null)}awake(){QoA&&console.log(this),this.context.connection.registerProvider(this)}getWebsocketUrl(){let A=this.url?LM.GetUrl(this.url,this.localhost):null;if(this.urlParameterName){const I=oA(this.urlParameterName);I&&typeof I=="string"&&(A=I)}if(!A)return null;const t=new RegExp("(((https?)|(?<socket_prefix>wss?))://)?(www.)?(?<url>.+)","gm").exec(A);return t!=null&&t.groups?(t==null?void 0:t.groups.socket_prefix)?A:"wss://"+(t==null?void 0:t.groups.url):null}static GetUrl(A,e){let t=A;const g=LM.IsLocalNetwork()&&e;return g&&(t=e),A!=null&&A.startsWith("/")&&(t=(g?t:window.location.origin)+A),t}static IsLocalNetwork(A=window.location.hostname){return aI(A)}};let jB=LM;OF([y()],jB.prototype,"url",2);OF([y()],jB.prototype,"urlParameterName",2);OF([y()],jB.prototype,"localhost",2);var EoA=Object.defineProperty,hoA=Object.getOwnPropertyDescriptor,qO=(i,A,e,t)=>{for(var g=t>1?void 0:t?hoA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&EoA(A,e,g),g};const xQ=oA("debugdroplistener");class wu extends mA{constructor(){super(...arguments);B(this,"filesBackendUrl");B(this,"localhost");B(this,"onDrag",e=>{e.preventDefault()});B(this,"onDrop",async e=>{if(xQ&&console.log(e),!e.dataTransfer)return;e.preventDefault();const t=e.dataTransfer.items;if(t)for(const g in t){const I=t[g];if(I.kind==="file"){const o=I.getAsFile();if(!o)continue;await this.addFiles(o)}else I.kind==="string"&&I.type=="text/plain"&&I.getAsString(async o=>{xQ&&console.log("dropped url",o);try{const s=new URL(o);if(!s)return;const C=await KO(s,this.context);C&&this.addObject(e,C)}catch{console.log("dropped string is not a valid URL!",o)}})}})}onEnable(){this.filesBackendUrl=jB.GetUrl(this.filesBackendUrl,this.localhost)??this.filesBackendUrl,xQ&&console.log(this,this.filesBackendUrl),this.context.domElement.addEventListener("dragover",this.onDrag),this.context.domElement.addEventListener("drop",this.onDrop)}onDisable(){this.context.domElement.removeEventListener("dragover",this.onDrag),this.context.domElement.removeEventListener("drop",this.onDrop)}async addFiles(...e){if(xQ&&console.log("Add files",e),!!Array.isArray(e)&&e.length)for(const t of e){if(!t)continue;xQ&&console.log("Register file "+t.name+" to",this.filesBackendUrl,t);const g=await NO(t,this.context,this.filesBackendUrl);this.dispatchEvent(new CustomEvent("file-dropped",{detail:t})),g&&this.addObject(void 0,g)}}async addObject(e,t){xQ&&console.log("Dropped",t);const g=t.scene;if(e!==void 0){const I=new Fs;I.setMask(16777215),I.screenPointFromOffset(e.offsetX,e.offsetY);const o=this.context.physics.raycast(I);if(o&&o.length>0)for(const s of o){g.position.copy(s.point);break}}this.gameObject.add(g),this.dispatchEvent(new CustomEvent("object-added",{detail:t}))}}qO([y()],wu.prototype,"filesBackendUrl",2);qO([y()],wu.prototype,"localhost",2);var coA=Object.defineProperty,loA=Object.getOwnPropertyDescriptor,bS=(i,A,e,t)=>{for(var g=t>1?void 0:t?loA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&coA(A,e,g),g};class ZB extends ph{constructor(){super(...arguments);B(this,"parent",null);B(this,"object",null);B(this,"limitCount",10);B(this,"limitInterval",60);B(this,"_currentCount",0);B(this,"_startPosition",null);B(this,"_startQuaternion",null)}awake(){var t,g;if(this.object){if(this.object===this.gameObject){console.error("Can not duplicate self");return}this.object.visible=!1,this._startPosition=((t=this.object.position)==null?void 0:t.clone())??new m(0,0,0),this._startQuaternion=((g=this.object.quaternion)==null?void 0:g.clone())??new LA(0,0,0,1)}const e=eA.getComponentInParent(this.gameObject,xh);e?e.addDragEventListener(RO.SelectStart,(I,o)=>{if(this._currentCount>=this.limitCount){o.attached=null;return}const s=this.handleDuplication(o.selected);s&&(console.assert(s!==o.selected,"Duplicated object is original"),o.attached=s)}):console.warn("Could no find drag controls in parent",this.name),gi.addEventListener(An.SelectStart,(I,o)=>{if(this._currentCount>=this.limitCount){o.grab=null;return}const s=this.handleDuplication(o.selected);s&&(o.grab=s)}),this.cloneLimitIntervalFn()}cloneLimitIntervalFn(){this.destroyed||(this._currentCount>0&&(this._currentCount-=1),setTimeout(()=>{this.cloneLimitIntervalFn()},this.limitInterval/this.limitCount*1e3))}handleDuplication(e){var t;if(this._currentCount>=this.limitCount||!this.object)return null;if(e===this.gameObject||this.handleMultiObject(e)){if(this.object===this.gameObject)return null;this.object.visible=!0,this._startPosition&&this.object.position.copy(this._startPosition),this._startQuaternion&&this.object.quaternion.copy(this._startQuaternion);const g=new cC;this.parent||(this.parent=this.gameObject.parent),this.parent&&(g.parent=this.parent.guid??((t=this.parent.userData)==null?void 0:t.guid),g.keepWorldPosition=!0),g.position=this.worldPosition,g.rotation=this.worldQuaternion,g.context=this.context,this._currentCount+=1;const I=eA.instantiateSynced(this.object,g);return console.assert(I!==this.object,"Duplicated object is original"),this.object.visible=!1,this._startPosition&&this.object.position.clone().copy(this._startPosition),this._startQuaternion&&this.object.quaternion.clone().copy(this._startQuaternion),I}return null}handleMultiObject(e){return this.gameObject.type==="Group"||this.gameObject.type==="Object3D"?this.isInChildren(this.gameObject,e):!1}isInChildren(e,t){if(!e)return!1;if(e===t)return!0;if(e.children){for(let g of e.children)if(this.isInChildren(g,t))return!0}return!1}}bS([y(bA)],ZB.prototype,"parent",2);bS([y(bA)],ZB.prototype,"object",2);bS([y()],ZB.prototype,"limitCount",2);bS([y()],ZB.prototype,"limitInterval",2);var gE=(i=>(i[i.PointerEnter=0]="PointerEnter",i[i.PointerExit=1]="PointerExit",i[i.PointerDown=2]="PointerDown",i[i.PointerUp=3]="PointerUp",i[i.PointerClick=4]="PointerClick",i[i.Drag=5]="Drag",i[i.Drop=6]="Drop",i[i.Scroll=7]="Scroll",i[i.UpdateSelected=8]="UpdateSelected",i[i.Select=9]="Select",i[i.Deselect=10]="Deselect",i[i.Move=11]="Move",i[i.InitializePotentialDrag=12]="InitializePotentialDrag",i[i.BeginDrag=13]="BeginDrag",i[i.EndDrag=14]="EndDrag",i[i.Submit=15]="Submit",i[i.Cancel=16]="Cancel",i))(gE||{}),doA=Object.defineProperty,uoA=Object.getOwnPropertyDescriptor,PF=(i,A,e,t)=>{for(var g=t>1?void 0:t?uoA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&doA(A,e,g),g};class WF{constructor(){B(this,"eventID");B(this,"callback")}}PF([y()],WF.prototype,"eventID",2);PF([y(FI)],WF.prototype,"callback",2);class xS extends mA{constructor(){super(...arguments);B(this,"triggers")}invoke(e){if(this.triggers)for(const t of this.triggers)t.eventID===e&&t.callback.invoke()}onPointerClick(e){this.invoke(gE.PointerClick)}onPointerEnter(e){this.invoke(gE.PointerEnter)}onPointerExit(e){this.invoke(gE.PointerExit)}onPointerDown(e){this.invoke(gE.PointerDown)}onPointerUp(e){this.invoke(gE.PointerUp)}}PF([y(WF)],xS.prototype,"triggers",2);var poA=Object.defineProperty,foA=Object.getOwnPropertyDescriptor,VF=(i,A,e,t)=>{for(var g=t>1?void 0:t?foA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&poA(A,e,g),g};class zF extends mA{constructor(){super(...arguments);B(this,"connectedBody");B(this,"_rigidBody",null)}get rigidBody(){return this._rigidBody}onEnable(){this._rigidBody||(this._rigidBody=this.gameObject.getComponent(Xt)),this.rigidBody&&this.connectedBody&&this.startCoroutine(this.create())}*create(){yield,this.rigidBody&&this.connectedBody&&this.createJoint(this.rigidBody,this.connectedBody)}}VF([y(Xt)],zF.prototype,"connectedBody",2);class jF extends zF{createJoint(A,e){var t;(t=this.context.physics.engine)==null||t.addFixedJoint(A,e)}}class Su extends zF{constructor(){super(...arguments);B(this,"anchor");B(this,"axis")}createJoint(e,t){var g;this.axis&&this.anchor&&((g=this.context.physics.engine)==null||g.addHingeJoint(e,t,this.anchor,this.axis))}}VF([y(m)],Su.prototype,"anchor",2);VF([y(m)],Su.prototype,"axis",2);const DoA={type:"change"};let yoA=class extends Vi{constructor(A,e){super(),this.object=A,this.domElement=e,this.enabled=!0,this.movementSpeed=1,this.rollSpeed=.005,this.dragToLook=!1,this.autoForward=!1;const t=this,g=1e-6,I=new LA,o=new m;this.tmpQuaternion=new LA,this.status=0,this.moveState={up:0,down:0,left:0,right:0,forward:0,back:0,pitchUp:0,pitchDown:0,yawLeft:0,yawRight:0,rollLeft:0,rollRight:0},this.moveVector=new m(0,0,0),this.rotationVector=new m(0,0,0),this.keydown=function(E){if(!(E.altKey||this.enabled===!1)){switch(E.code){case"ShiftLeft":case"ShiftRight":this.movementSpeedMultiplier=.1;break;case"KeyW":this.moveState.forward=1;break;case"KeyS":this.moveState.back=1;break;case"KeyA":this.moveState.left=1;break;case"KeyD":this.moveState.right=1;break;case"KeyR":this.moveState.up=1;break;case"KeyF":this.moveState.down=1;break;case"ArrowUp":this.moveState.pitchUp=1;break;case"ArrowDown":this.moveState.pitchDown=1;break;case"ArrowLeft":this.moveState.yawLeft=1;break;case"ArrowRight":this.moveState.yawRight=1;break;case"KeyQ":this.moveState.rollLeft=1;break;case"KeyE":this.moveState.rollRight=1;break}this.updateMovementVector(),this.updateRotationVector()}},this.keyup=function(E){if(this.enabled!==!1){switch(E.code){case"ShiftLeft":case"ShiftRight":this.movementSpeedMultiplier=1;break;case"KeyW":this.moveState.forward=0;break;case"KeyS":this.moveState.back=0;break;case"KeyA":this.moveState.left=0;break;case"KeyD":this.moveState.right=0;break;case"KeyR":this.moveState.up=0;break;case"KeyF":this.moveState.down=0;break;case"ArrowUp":this.moveState.pitchUp=0;break;case"ArrowDown":this.moveState.pitchDown=0;break;case"ArrowLeft":this.moveState.yawLeft=0;break;case"ArrowRight":this.moveState.yawRight=0;break;case"KeyQ":this.moveState.rollLeft=0;break;case"KeyE":this.moveState.rollRight=0;break}this.updateMovementVector(),this.updateRotationVector()}},this.pointerdown=function(E){if(this.enabled!==!1)if(this.dragToLook)this.status++;else{switch(E.button){case 0:this.moveState.forward=1;break;case 2:this.moveState.back=1;break}this.updateMovementVector()}},this.pointermove=function(E){if(this.enabled!==!1&&(!this.dragToLook||this.status>0)){const h=this.getContainerDimensions(),l=h.size[0]/2,d=h.size[1]/2;this.moveState.yawLeft=-(E.pageX-h.offset[0]-l)/l,this.moveState.pitchDown=(E.pageY-h.offset[1]-d)/d,this.updateRotationVector()}},this.pointerup=function(E){if(this.enabled!==!1){if(this.dragToLook)this.status--,this.moveState.yawLeft=this.moveState.pitchDown=0;else{switch(E.button){case 0:this.moveState.forward=0;break;case 2:this.moveState.back=0;break}this.updateMovementVector()}this.updateRotationVector()}},this.contextMenu=function(E){this.enabled!==!1&&E.preventDefault()},this.update=function(E){if(this.enabled===!1)return;const h=E*t.movementSpeed,l=E*t.rollSpeed;t.object.translateX(t.moveVector.x*h),t.object.translateY(t.moveVector.y*h),t.object.translateZ(t.moveVector.z*h),t.tmpQuaternion.set(t.rotationVector.x*l,t.rotationVector.y*l,t.rotationVector.z*l,1).normalize(),t.object.quaternion.multiply(t.tmpQuaternion),(o.distanceToSquared(t.object.position)>g||8*(1-I.dot(t.object.quaternion))>g)&&(t.dispatchEvent(DoA),I.copy(t.object.quaternion),o.copy(t.object.position))},this.updateMovementVector=function(){const E=this.moveState.forward||this.autoForward&&!this.moveState.back?1:0;this.moveVector.x=-this.moveState.left+this.moveState.right,this.moveVector.y=-this.moveState.down+this.moveState.up,this.moveVector.z=-E+this.moveState.back},this.updateRotationVector=function(){this.rotationVector.x=-this.moveState.pitchDown+this.moveState.pitchUp,this.rotationVector.y=-this.moveState.yawRight+this.moveState.yawLeft,this.rotationVector.z=-this.moveState.rollRight+this.moveState.rollLeft},this.getContainerDimensions=function(){return this.domElement!=document?{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}:{size:[window.innerWidth,window.innerHeight],offset:[0,0]}},this.dispose=function(){this.domElement.removeEventListener("contextmenu",s),this.domElement.removeEventListener("pointerdown",n),this.domElement.removeEventListener("pointermove",C),this.domElement.removeEventListener("pointerup",a),window.removeEventListener("keydown",r),window.removeEventListener("keyup",Q)};const s=this.contextMenu.bind(this),C=this.pointermove.bind(this),n=this.pointerdown.bind(this),a=this.pointerup.bind(this),r=this.keydown.bind(this),Q=this.keyup.bind(this);this.domElement.addEventListener("contextmenu",s),this.domElement.addEventListener("pointerdown",n),this.domElement.addEventListener("pointermove",C),this.domElement.addEventListener("pointerup",a),window.addEventListener("keydown",r),window.addEventListener("keyup",Q),this.updateMovementVector(),this.updateRotationVector()}};class ZF extends mA{constructor(){super(...arguments);B(this,"_controls",null)}onEnable(){var t;const e=(t=eA.getComponent(this.gameObject,Ot))==null?void 0:t.cam;this._controls=new yoA(e,this.context.renderer.domElement),this._controls.rollSpeed=.5,this._controls.movementSpeed=3,this._controls.dragToLook=!0}onDisable(){var e;(e=this._controls)==null||e.dispose(),this._controls=null}update(){this._controls&&this._controls.update(this.context.time.deltaTime)}}var woA=Object.defineProperty,SoA=Object.getOwnPropertyDescriptor,XF=(i,A,e,t)=>{for(var g=t>1?void 0:t?SoA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&woA(A,e,g),g};class Lh extends mA{constructor(){super(...arguments);B(this,"_fog")}get fog(){return this._fog||(this._fog=new FR(0,0,50)),this._fog}get mode(){return 1}set near(e){this.fog.near=e}get near(){return this.fog.near}set far(e){this.fog.far=e}get far(){return this.fog.far}set color(e){this.fog.color.copy(e)}get color(){return this.fog.color}onEnable(){this.scene.fog=this.fog}onDisable(){this.scene.fog===this._fog&&(this.scene.fog=null)}}XF([y()],Lh.prototype,"near",1);XF([y()],Lh.prototype,"far",1);XF([y(DA)],Lh.prototype,"color",1);let Cf,nm,LQ,nf;function am(i,A=1/0,e=null){nm||(nm=new Co(2,2,1,1)),LQ||(LQ=new be({uniforms:{blitTexture:new RA(i)},vertexShader:`
5022
5022
  varying vec2 vUv;
5023
5023
  void main(){
5024
5024
  vUv = uv;