@splinetool/viewer 2.0.60 → 2.0.61
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.
|
@@ -344,13 +344,13 @@ ${t.stack}`:r}function qSt(t){t<1028||(nh[t]=Cb,Cb=t)}function Ho(t,e){return t=
|
|
|
344
344
|
}
|
|
345
345
|
post({ kind: 'ready' });
|
|
346
346
|
}, 250);
|
|
347
|
-
})();`}),Kpt=G(()=>{H7=class{constructor(t,e,i){this.deps=t,this.onConsole=e,this.onEvent=i,this.disposed=!1,this.eventUnsubs=new Map,this.variablePollHandle=null,this.lastVariables=null}dispose(){this.disposed=!0;for(let t of this.eventUnsubs.values())t();this.eventUnsubs.clear(),this.stopVariablePolling()}execute(t,e){let i=this.deps;switch(t){case"setVariable":{let r=i.setVariable(String(e[0]),e[1]);return r.warning&&this.onConsole("warn",r.warning),r.ok}case"setVariables":{let r=e[0]??{},s=!0;for(let[n,a]of Object.entries(r)){let o=i.setVariable(n,a);o.warning&&this.onConsole("warn",o.warning),s=s&&o.ok}return s}case"getVariable":return i.getVariable(String(e[0]));case"getVariables":return i.getVariables();case"getAllObjects":return i.getAllObjects();case"findObjectByName":case"findObjectById":return i.findObject(String(e[0]));case"getGeometry":{let r=i.getGeometry(String(e[0]),e[1]??{});return r.warning&&this.onConsole("warn",r.warning),r.data}case"updateObject":return i.updateObject(String(e[0]),e[1]??{});case"createObject":return i.createObject(String(e[0]),e[1]??{});case"createCustomMaterial":if(i.createCustomMaterial===void 0)throw new Error("createCustomMaterial: not available on this surface \u2014 custom three.js/TSL materials need the inline HTML-content mode (editor Preview/Play and web exports).");return i.createCustomMaterial(e[0]);case"getTexture":if(i.getTexture===void 0)throw new Error("getTexture: not available on this surface \u2014 a three.js texture instance needs the inline HTML-content mode (editor Preview/Play and web exports).");return i.getTexture(String(e[0]),e[1]??{});case"setMaterial":if(i.setMaterial===void 0)throw new Error("setMaterial: not available on this surface \u2014 custom three.js/TSL materials need the inline HTML-content mode (editor Preview/Play and web exports).");return i.setMaterial(String(e[0]),e[1]);case"cloneObject":return i.cloneObject(String(e[0]),e[1]??{});case"removeObject":return i.removeObject(String(e[0]));case"spawnObject":{let r=i.spawnObject(String(e[0]),e[1]??{});return r.warning&&this.onConsole("warn",r.warning),r.object}case"destroyObject":return i.destroyObject(String(e[0]));case"setInstanceTransforms":{let r=e[1]===null||e[1]===void 0?null:e[1],s=i.setInstanceTransforms(String(e[0]),r);return s<0&&this.onConsole("warn",`spline.setInstanceTransforms: "${String(e[0])}" has no cloner \u2014 make the object a cloner first (its copies are what this drives).`),s}case"emitEvent":case"emitEventReverse":{let r=i.emitEvent(String(e[0]),String(e[1]),t==="emitEventReverse");return r.warning&&this.onConsole("warn",r.warning),r.ok}case"requestRender":return i.requestRender(),!0;case"listenEvent":{let r=String(e[0]);return r==="variableChange"?this.startVariablePolling():this.eventUnsubs.has(r)||this.eventUnsubs.set(r,i.addSplineEventListener(r,s=>{this.onEvent(r,s)})),!0}case"unlistenEvent":{let r=String(e[0]);return r==="variableChange"?this.stopVariablePolling():(this.eventUnsubs.get(r)?.(),this.eventUnsubs.delete(r)),!0}default:throw new Error(`Unknown spline bridge method: ${t}`)}}startVariablePolling(){this.variablePollHandle===null&&(this.lastVariables=this.deps.getVariables(),this.variablePollHandle=window.setInterval(()=>{if(this.disposed)return;let t=this.deps.getVariables(),e=function(i,r){let s=[];for(let n of Object.keys(r))i[n]!==r[n]&&s.push({name:n,value:r[n]});return s}(this.lastVariables??{},t);this.lastVariables=t;for(let i of e)this.onEvent("variableChange",i)},100))}stopVariablePolling(){this.variablePollHandle!==null&&(window.clearInterval(this.variablePollHandle),this.variablePollHandle=null),this.lastVariables=null}}});function rMt(t,e,i,r){return[t[0]*e+t[4]*i+t[8]*r+t[12],t[1]*e+t[5]*i+t[9]*r+t[13],t[2]*e+t[6]*i+t[10]*r+t[14]]}var sMt=G(()=>{}),Zpt,nMt=G(()=>{}),aMt=G(()=>{$7(),Kpt(),Zpt=class{constructor(t,e,i){this.iframe=t,this.deps=e,this.onConsole=i,this.disposed=!1,this.handshakeSeen=!1,this.handshakeTimer=null,this.onMessage=r=>{if(this.disposed||r.source!==this.iframe.contentWindow)return;let s=r.data;var n;typeof(n=s)!="object"||n===null||n[Fp]!==!0||typeof n.kind!="string"||this.handleMessage(s)},this.host=new H7(e,i,(r,s)=>{this.sendEvent(r,s)})}attach(){window.addEventListener("message",this.onMessage),this.send({[Fp]:!0,kind:"ready-ack"}),this.handshakeTimer=window.setTimeout(()=>{this.handshakeTimer=null,!this.handshakeSeen&&!this.disposed&&this.onConsole("warn","The HTML content frame has not initialized (no signal from its scripts yet) \u2014 if the page looks frozen, check for errors in its code.")},6e3)}dispose(){this.disposed=!0,window.removeEventListener("message",this.onMessage),this.host.dispose(),this.handshakeTimer!==null&&(window.clearTimeout(this.handshakeTimer),this.handshakeTimer=null)}handleMessage(t){switch(t.kind){case"ready":this.handshakeSeen=!0,this.send({[Fp]:!0,kind:"ready-ack"});break;case"console":this.onConsole(t.level,t.text);break;case"call":{let e;try{e=Promise.resolve(this.host.execute(t.method,t.args))}catch(i){e=Promise.reject(i)}e.then(i=>{this.send({[Fp]:!0,kind:"result",id:t.id,ok:!0,value:i,error:void 0})},i=>{let r=i instanceof Error?i.message:String(i);this.send({[Fp]:!0,kind:"result",id:t.id,ok:!1,value:void 0,error:r}),this.onConsole("error",r)});break}case"input":this.dispatchInput(t.event)}}send(t){this.iframe.contentWindow?.postMessage(t,"*")}sendEvent(t,e){this.send({[Fp]:!0,kind:"event",eventName:t,payload:e})}dispatchInput(t){let e=this.deps.getCanvas();if(!e)return;let i=this.iframe.getBoundingClientRect(),r={bubbles:!0,cancelable:!0,view:window,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,altKey:t.altKey,metaKey:t.metaKey};switch(t.type){case"pointerdown":case"pointermove":case"pointerup":case"pointercancel":e.dispatchEvent(new PointerEvent(t.type,{...r,clientX:(t.x??0)+i.left,clientY:(t.y??0)+i.top,button:t.button,buttons:t.buttons,pointerId:t.pointerId,pointerType:t.pointerType,isPrimary:t.isPrimary,movementX:t.movementX,movementY:t.movementY}));break;case"click":case"dblclick":e.dispatchEvent(new MouseEvent(t.type,{...r,clientX:(t.x??0)+i.left,clientY:(t.y??0)+i.top,button:t.button,buttons:t.buttons}));break;case"wheel":{let s=new WheelEvent("wheel",{...r,clientX:(t.x??0)+i.left,clientY:(t.y??0)+i.top,deltaX:t.deltaX,deltaY:t.deltaY,deltaMode:t.deltaMode});typeof t.wheelDeltaX=="number"&&Object.defineProperty(s,"wheelDeltaX",{value:t.wheelDeltaX}),typeof t.wheelDeltaY=="number"&&Object.defineProperty(s,"wheelDeltaY",{value:t.wheelDeltaY}),e.dispatchEvent(s);break}case"keydown":case"keyup":e.dispatchEvent(new KeyboardEvent(t.type,{...r,key:t.key,code:t.code,repeat:t.repeat}))}}}}),ir=G(()=>{q7(),jTt(),GTt(),WTt(),HTt(),$Tt(),XTt(),YTt(),KTt(),ZTt(),QTt(),eMt(),$7(),iMt(),Kpt(),sMt(),nMt(),aMt()}),oMt=G(()=>{});function Qpt(t){return Array.isArray(t)?t:[t]}function X4(t,e){let i=0;for(;i<t.length&&i<e.length;){if(t[i]<e[i])return-1;if(t[i]>e[i])return 1;i+=1}return i!==e.length?-1:i!==t.length?1:0}var lMt=G(()=>{});function $a(t,e){return Object.setPrototypeOf(t,e),t}function zN(t){let e={...t};return Object.setPrototypeOf(e,Object.getPrototypeOf(t)),e}function Zp(t,e,i){if(t===void 0?e===void 0?(t=0,e=10):t=e-10:e===void 0&&(e=t+10),t>e){let n=t;t=e,e=n}let r=[],s=1/(i+1);for(let n=0;n<i;n++){let a=t+(e-t)*(n+.75+.5*Math.random())*s;r.push(a)}return r}function Yg(t){return t instanceof Uint8Array||t instanceof Uint16Array||t instanceof Uint32Array||t instanceof Int8Array||t instanceof Int16Array||t instanceof Int32Array||t instanceof Float32Array||t instanceof Float64Array}var hMt=G(()=>{});function X7(t){if(t.deepFreeze!==void 0)return void t.deepFreeze(t);let e=Object.getOwnPropertyNames(t);for(let i of e){let r=t[i];r&&typeof r=="object"&&X7(r)}return Object.freeze(t)}function Jpt(t){for(let e of Object.keys(t))t[e]===void 0&&delete t[e];return t}var LN,Y4,V8,Be,Y7,uMt=G(()=>{}),hn=G(()=>{oMt(),lMt(),hMt(),uMt()}),K7=G(()=>{LN=class{},Y4=class extends LN{constructor(t){super(),this.id=t}},V8=class extends LN{constructor(t){super(),this.data=t}}}),dMt=G(()=>{}),w5=G(()=>{Be=class{modifyById(t,e){let i=this;if(i[t]===void 0)throw new Error("not expected");{let r={...i,[t]:e};return Object.setPrototypeOf(r,Be.prototype),r}}add(t,e){return this.runOp({type:1,id:t,data:e})?.data??this}runOp(t){let e=this;if(t.type===1){let i,r=e[t.id];i=r===void 0?{type:2,id:t.id}:{type:1,id:t.id,data:r};let{id:s,data:n}=t,a={...e,[s]:n};return Object.setPrototypeOf(a,Be.prototype),{data:a,actual:t,reverse:i}}if(t.type===2){let{id:i}=t,r=e[i];if(r===void 0)return null;{let s={...e};return Object.setPrototypeOf(s,Be.prototype),delete s[i],{data:s,actual:t,reverse:{type:1,id:i,data:r}}}}return null}}}),Z7=G(()=>{Y7=class extends Error{}});function tmt(t,e){for(let i of t)e(i.id,i.data)!==!0&&tmt(i.children,e)}function emt(t,e){if(e(t.id,t.data)!==!0)for(let i of t.children)emt(i,e)}var In,fM,Dv,ge,t0=G(()=>{hn(),Z7(),hn(),In=class extends Array{constructor(...t){super(...t),cc(this,"partialObjectCaches"),cc(this,"objCaches"),cc(this,"parentCaches"),Object.setPrototypeOf(this,In.prototype)}deepFreeze(){let t=0;for(;t<this.length;)X7(this[t]),t++}fillCaches0(t,e){this.objCaches.set(t.id,t),this.parentCaches.set(t.id,e);for(let i of t.children)this.fillCaches0(i,t.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let t of this)this.fillCaches0(t,null)}}randomId(){this.fillCaches();let t=Array.from(this.objCaches.keys());if(t.length!==0)return t[Math.max(0,Math.floor(Math.random()*t.length)-1)]}nonExistOrDescendantOf(t,e){if(!this.has(t))return!0;for(;t;){let i=this.parent(t);if(i===e)return!0;t=i}return!1}rootAcestor(t){for(;t;){let e=this.parent(t);if(!e)return t;t=e}return t}isDescendantOf(t,e){for(;t;){let i=this.parent(t);if(i===e)return!0;t=i}return!1}data(t){return this.get(t)?.data}has(t){return this.childrenOf(t)!==void 0}partialCache(t){this.partialObjectCaches===void 0&&(this.partialObjectCaches=new Map);let e=this.get(t);e!==void 0&&this.partialObjectCaches.set(t,e)}get(t){if(this.partialObjectCaches!==void 0){let e=this.partialObjectCaches.get(t);if(e!==void 0)return e}return this.fillCaches(),this.objCaches.get(t)}childrenOf(t){return t===null?this:this.get(t)?.children}traverseFrom(t,e){if(t===null)this.traverse(e);else{let i=this.get(t);i&&emt(i,e)}}traverse(t){tmt(this,t)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(t){return this.fillCaches(),this.parentCaches.get(t)}childrenArray(t){return t===null?this:this.get(t).children}modifyById(t,e){if(this.get(t)===void 0)throw new Error("not expected");{let i=this.parent(t),r=this.childrenArray(i),s=r.findIndex(o=>o.id===t);if(s<0)throw new Error("not expected");let n=r[s];r=[...r],r[s]={...n,data:e};let a=new Map;return a.set(t,r[s]),this.modifyArrayBy(i,r,a)}}modifyArrayBy(t,e,i=void 0){let r=t,s=e;for(;r!==null;){let a=s,o=r;if(r=this.parent(r),r===void 0)throw new Error;s=this.childrenArray(r);let l=s.findIndex(u=>u.id===o);if(l<0)throw new Error;s=[...s],s[l]={...s[l],children:a},i&&i.set(o,s[l])}Object.setPrototypeOf(s,In.prototype);let n=s;if(i&&this.objCaches!==void 0&&this.parentCaches!==void 0){n.objCaches=this.objCaches;for(let[a,o]of i)n.objCaches.set(a,o);n.parentCaches=this.parentCaches,this.objCaches=void 0,this.parentCaches=void 0}else n.fillCaches();return n}runOp(t){switch(t.type){case 7:return this.addOp(t);case 8:return this.deleteOp(t);case 9:return this.moveOp(t)}return null}checkDuplicatedIdRec({id:t,children:e}){if(this.get(t)!==void 0)return!0;for(let i of e)if(this.checkDuplicatedIdRec(i))return!0;return!1}addOp(t){let{parent:e,fi:i,id:r,data:s,children:n}=t;if(e!==null&&this.get(e)===void 0||this.checkDuplicatedIdRec(t))return null;{let a=e,o=this.childrenArray(a),l={fi:i,id:r,data:s,children:n};return o=[...o,l],o.sort((u,h)=>u.fi-h.fi),t.localIndex=o.indexOf(l),{data:this.modifyArrayBy(a,o),actual:t,reverse:{type:8,id:r}}}}deleteOp(t){let{id:e}=t;if(this.get(e)===null)return null;{let i=this.parent(e);if(i===void 0)return null;let r=this.childrenArray(i),s=r.findIndex(a=>a.id===e);t.localIndex=s,r=[...r];let n=r.splice(s,1)[0];return{data:this.modifyArrayBy(i,r),actual:t,reverse:{type:7,...n,parent:i}}}}moveOp(t){let{parent:e,fi:i,id:r}=t;if(e!==null&&this.get(e)===void 0)return this.deleteOp({type:8,id:r});if(e!==null){let d=e;for(;d!==null;){if(d===void 0)throw new Error;if(d===r)throw new Y7("cyclic tree");d=this.parent(d)}}let s=this.parent(r);if(s===void 0)return null;let n=s,a=this.childrenArray(s),o=a.findIndex(d=>d.id===r);a=[...a];let l=a.splice(o,1)[0],u=this.modifyArrayBy(s,a);s=e,a=u.childrenArray(s);let h=l.fi;return l={...l,fi:i},a=[...a,l],a.sort((d,c)=>d.fi-c.fi),t.localIndex=a.indexOf(l),u=u.modifyArrayBy(s,a),{data:u,actual:t,reverse:{type:9,parent:n,fi:h,id:r}}}previous(t,e){if(e===null){let r=this.childrenArray(t);return r.length===0?null:r[r.length-1].id}let i=null;for(let r of this.childrenArray(t)){if(r.id===e)return i;i=r.id}return null}traverseSortNext(t){let e=this.parent(t);if(e!==void 0){let i=this.childrenArray(e),r=i.findIndex(s=>s.id===t)+1;if(r<i.length)return i[r].id;if(e)return this.traverseSortNext(e)}}sortNext(t){let e=this.childrenArray(t);return e.length>0?e[0].id:this.traverseSortNext(t)}traverseSortPrevious(t){let e=this.childrenArray(t);return e.length>0?this.traverseSortPrevious(e[e.length-1].id):t}sortPrevious(t){let e=this.parent(t);if(e!==void 0){let i=this.childrenArray(e),r=i.findIndex(s=>s.id===t)-1;return r>=0?this.traverseSortPrevious(i[r].id):e}}getAllSorted(t){let e=[];for(let i of t){let r=this.getWithSortKey(i.id);r!==void 0&&e.push({...i,...r})}e.sort((i,r)=>X4(i.sortKey,r.sortKey));for(let i of e)delete i.sortKey;return e}getAllIdSorted(t){let e=[];for(let i of t){let r=this.getWithSortKey(i);r!==void 0&&e.push(r)}e.sort((i,r)=>X4(i.sortKey,r.sortKey));for(let i of e)delete i.sortKey;return e.map(i=>i.id)}getWithSortKey(t){let e=t,i=[],r=this.get(e),s=r;if(r!==void 0){for(;e;)i.splice(0,0,r.fi),e=this.parent(e),e!==null&&(r=this.get(e));return{...s,sortKey:i}}}insertBeforeHelper(t,e,i){return this.insertAfterHelper(t,this.previous(t,e),i)}insertAfterHelper(t,e,i){let r=this.childrenArray(t);if(e===null){if(r.length===0)return Zp(0,i,i);{let s=r[0].fi;return Zp(s-i,s,i)}}{let s=this.get(e);if(s===void 0||this.parent(e)!==t)throw new Error("illegal args");let n=r.find(a=>a.fi>s.fi);if(n===void 0){let a=r[r.length-1].fi;return Zp(a,a+i,i)}return Zp(s.fi,n.fi,i)}}}}),Q7=G(()=>{var t;hn(),fM=null,(t=Dv||(Dv={})).setPreservePrototype=function(e){fM=e},t.tryPreservePrototype=function(e,i){return Object.getPrototypeOf(e)===fM&&Object.setPrototypeOf(i,fM),i},t.runOp=function(e,i){if(i.type!==0)return null;if(Array.isArray(e)||Yg(e)){let r=i.props,s={},n=Yg(e)?e.slice():[...e],a=!1;if(r)for(let o of Object.keys(r)){let l=parseInt(o);if(isNaN(l))throw new Error("wrong index");s[o]=n[l],n[l]=r[o],a=!0}return a?{data:n,actual:i,reverse:{type:0,props:s}}:null}{let r=i.props,s={},n={...e},a=!1;if(r)for(let o of Object.keys(r)){s[o]=n[o];let l=r[o];l===void 0?delete n[o]:n[o]=l,a=!0}return a?{data:t.tryPreservePrototype(e,n),actual:i,reverse:{type:0,props:s}}:null}}}),e0=G(()=>{hn(),hn(),ge=class extends Array{constructor(...t){super(...t),cc(this,"objCaches"),Object.setPrototypeOf(this,ge.prototype)}deepFreeze(){let t=0;for(;t<this.length;)X7(this[t]),t++}fillCaches0(t){this.objCaches.set(t.id,t)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,Object.getOwnPropertyDescriptor(this,"objCaches").enumerable=!1;for(let t of this)this.fillCaches0(t)}}randomId(){this.fillCaches();let t=Array.from(this.objCaches.keys());if(t.length!==0)return t[Math.max(0,Math.floor(Math.random()*t.length)-1)]}data(t){return this.get(t)?.data}get(t){return this.fillCaches(),this.objCaches.get(t)}modifyById(t,e){if(this.get(t)===void 0)throw new Error("not expected");{let i=this,r=i.findIndex(n=>n.id===t);if(r<0)throw new Error("not expected");let s=i[r];return i=[...i],i[r]={...s,data:e},this.modifyArrayBy(i)}}modifyArrayBy(t){Object.setPrototypeOf(t,ge.prototype);let e=t;return typeof process<"u"||e.fillCaches(),e}runOp(t){switch(t.type){case 4:return this.addOp(t);case 5:return this.deleteOp(t);case 6:return this.moveOp(t)}return null}addOp(t){let{fi:e,id:i,data:r}=t,s=this,n={fi:e,id:i,data:r};return s=[...s,n],s.sort((a,o)=>a.fi-o.fi),t.localIndex=s.indexOf(n),{data:this.modifyArrayBy(s),actual:t,reverse:{type:5,id:i}}}deleteOp(t){let{id:e}=t,i=this,r=i.findIndex(n=>n.id===e);if(r===-1)return null;t.localIndex=r,i=[...i];let s=i.splice(r,1)[0];return{data:this.modifyArrayBy(i),actual:t,reverse:{type:4,...s}}}moveOp(t){let{fi:e,id:i}=t,r=this;r=[...r];let s=r.findIndex(o=>o.id===i);if(s===-1)return null;let n=r[s].fi,a={...r[s],fi:e};return r[s]=a,r.sort((o,l)=>o.fi-l.fi),t.localIndex=r.indexOf(a),{data:this.modifyArrayBy(r),actual:t,reverse:{type:6,fi:n,id:i}}}previous(t){if(t===null)return this.length===0?null:this[this.length-1].id;let e=null;for(let i of this){if(i.id===t)return e;e=i.id}return null}insertBeforeHelper(t,e){return this.insertAfterHelper(this.previous(t),e)}insertAfterHelper(t,e){let i=this;if(t===null){if(i.length===0)return Zp(0,e,e);{let r=i[0].fi;return Zp(r-e,r,e)}}{let r=this.get(t);if(r===void 0)throw new Error("illegal args");let s=i.find(n=>n.fi>r.fi);if(s===void 0){let n=i[i.length-1].fi;return Zp(n,n+e,e)}return Zp(r.fi,s.fi,e)}}}});function cMt(t,e){let i={cur:[],result:[],len:0};return[t=nv(t,e,i)??t,i.result]}function MP(t,e){return t===null?null:(t.cur[t.len]=e,t.len+=1,t)}function AP(t){t&&(t.len-=1)}function imt(t,e,i){let r=!1,s=t.map(n=>{let a=n.id,o=e[a];if(o!==void 0&&typeof o=="string"&&(r=!0,a=o,i!==null))throw new Error("not supported");let l=nv(n.data,e,MP(i,a));AP(i),r=r||l!==void 0,l===void 0&&(l=n.data);let u=imt(n.children,e,i);return u!==void 0?r=!0:u=n.children,{...n,id:a,data:l,children:u}});if(r)return s}function nv(t,e,i){if(t instanceof In){let r=imt(t,e,i);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(t)),r}if(t instanceof ge)return function(r,s,n){let a=!1,o=r.map(l=>{let u=l.id,h=s[u];if(h!==void 0&&typeof h=="string"&&(a=!0,u=h,n!==null))throw new Error("not supported");let d=nv(l.data,s,MP(n,u));return AP(n),a=a||d!==void 0,d===void 0&&(d=l.data),{...l,id:u,data:d}});if(a)return Object.setPrototypeOf(o,Object.getPrototypeOf(r)),o}(t,e,i);if(Array.isArray(t)){let r=!1,s=t.map((n,a)=>{let o=nv(n,e,MP(i,a));return AP(i),r=r||o!==void 0,o===void 0&&(o=n),o});return r?(Object.setPrototypeOf(s,Object.getPrototypeOf(t)),s):void 0}if(t&&typeof t=="object"&&!Yg(t)){let r={},s=!1;for(let[n,a]of Object.entries(t))if(n!=="name"&&n!=="variableId"){let o=e[n];if(typeof o=="string"){if(i!==null)throw new Error("not supported");s=!0,n=o}let l=nv(a,e,MP(i,n));AP(i),s=s||l!==void 0,l===void 0&&(l=a),r[n]=l}else r[n]=a;return s?(Object.setPrototypeOf(r,Object.getPrototypeOf(t)),r):void 0}if(typeof t=="string"){let r=e[t];return r!==void 0&&function(s){if(s===null)return null;s.result.push(s.cur.slice(0,s.len))}(i),r}}var rmt=G(()=>{t0(),e0(),hn()});function av(t){return t&&typeof t=="object"&&t instanceof Xs}function J7(t,e){if(e===void 0)return;let i=!1,r=t.map(s=>{let n=s.id,a=U2(s.data,e[n]);if(i=i||a!==void 0,a===void 0&&(a=s.data),s.children){let o=J7(s.children,e);return o!==void 0?i=!0:o=s.children,{...s,id:n,data:a,children:o}}return{...s,id:n,data:a}});return i?r:void 0}function U2(t,e){if(!av(e))return e;if(t instanceof In){let i=J7(t,e);return i!==void 0&&Object.setPrototypeOf(i,Object.getPrototypeOf(t)),i}if(t instanceof ge)return function(i,r){if(r===void 0)return;let s=!1,n=i.map(a=>{let o=a.id,l=U2(a.data,r[o]);return s=s||l!==void 0,l===void 0&&(l=a.data),{...a,id:o,data:l}});return s?(Object.setPrototypeOf(n,Object.getPrototypeOf(i)),n):void 0}(t,e);if(Array.isArray(t)){let i=!1,r=t.map((s,n)=>{let a=U2(s,e[n]);return i=i||a!==void 0,a===void 0&&(a=s),a});return i?(Object.setPrototypeOf(r,Object.getPrototypeOf(t)),r):void 0}if(t instanceof Xs)return tG(t,e);if(t&&typeof t=="object"){let i={},r=!1;for(let[s,n]of Object.entries(t)){let a=U2(n,e[s]);r=r||a!==void 0,a===void 0&&(a=n),i[s]=a}return r?(Object.setPrototypeOf(i,Object.getPrototypeOf(t)),i):void 0}}function tG(t,e){if(t===void 0)return e;if(e===void 0)return t;if(!av(e))return e;if(!av(t))return lm.apply(t,e);let i=new Set;for(let s of Object.keys(t))i.add(s);for(let s of Object.keys(e))i.add(s);let r=new Xs;for(let s of i){let n=tG(t===void 0?void 0:t[s],e===void 0?void 0:e[s]);r[s]=n}return r}var Xs,lm,K4,ea,R$,eG=G(()=>{var t;t0(),e0(),M5(),hn(),Xs=class{unusedFunOverridesTable(e){}runOp(e){let i=[],r=this,s=0,n={};for(;s<e.path.length;){if(i.push(r),r=r===void 0?void 0:r[e.path[s]],r!==void 0&&!av(r))return null;s+=1}r=r?zN(r):new Xs;for(let[a,o]of Object.entries(e.props)){let l=r[a];n[a]=l,o===void 0?delete r[a]:r[a]=o}for(;s>0;){if(Object.keys(r).length===0){let a=i[s-1];a&&(r=zN(a),delete r[e.path[s-1]])}else{let a=i[s-1];if(a){let o=zN(a);o[e.path[s-1]]=r,r=o}else{let o=new Xs;o[e.path[s-1]]=r,r=o}}s-=1}return{data:Object.setPrototypeOf(r,Xs.prototype),actual:e,reverse:{...e,props:n}}}},(t=lm||(lm={})).apply=function(e,i){return U2(e,i)??e},t.merge=function(e,i){return tG(e,i)},t.filterOp=function(e,i){let r=0,s=i.path,n=e;for(;r<s.length&&n!==void 0;){if(n=Dn.zoomOnce(n,s[r]),n===void 0)return i;if(!av(n))return;r+=1}if(n===void 0)return i;if(av(n)){if(i.type===0){let a={...i.props};for(let o of Object.keys(n))delete a[o];return{...i,props:a}}if(i.type===1||i.type===4||i.type===7){let a=J7([i],n);return a?a[0]:i}return i}}}),pMt=G(()=>{hn(),M5(),w5(),t0(),Z7(),Q7(),e0(),rmt(),eG(),(K4||(K4={})).replaceProps=function(t,e){let i=Dn.zoom(e,t.path);if(typeof i=="object"){let r={};for(let s of Object.keys(t.props))r[s]=i[s];return{...t,props:r}}return{...t,props:{}}},(t=>{function e(s,n){let a=n.path,o=[];for(;;){let l;if(s instanceof Xs&&n.type===0&&(l=s.runOp({...n,path:a.slice(o.length)}),l===null&&(l=void 0)),l===void 0&&o.length===a.length&&(l=s instanceof In||s instanceof ge||s instanceof Be?s.runOp(n):Dv.runOp(s,n)),l!==void 0){if(l!==null){let d=l.data;for(let c=o.length-1;c>=0;c--){let p=a[c],m=o[c];if(m instanceof In){if(typeof p=="number")throw new Error("illegal arg");d=m.modifyById(p,d)}else if(m instanceof ge){if(typeof p=="number")throw new Error("illegal arg");d=m.modifyById(p,d)}else if(m instanceof Be){if(typeof p=="number")throw new Error("illegal arg");d=m.modifyById(p,d)}else if(m instanceof Xs){let f={...m,[p]:d};d=Object.setPrototypeOf(f,Xs.prototype)}else{if(typeof m!="object")return null;if(Array.isArray(m)||Yg(m)){if(typeof p=="string"&&(p=parseInt(p),isNaN(p)))throw new Error("Invalid path");let f=d;d=Yg(m)?m.slice():[...m],d[p]=f}else d=Dv.tryPreservePrototype(m,{...m,[p]:d})}}return{data:d,actual:{...l.actual,path:a},reverse:{...l.reverse,path:a}}}return null}let u,h=a[o.length];if(s instanceof In){if(typeof h=="number")throw new Error("");u=s.get(h)?.data}else if(s instanceof ge){if(typeof h=="number")throw new Error("");u=s.get(h)?.data}else s!==null&&(u=s[h]);if(u===void 0)return null;o.push(s),s=u}}function i(s,n){for(let a=0;a<s.length&&a<n.length;a++)if(s[a]!==n[a])return!0;return!1}function r(s,n){if(s.length!==n.length)return!1;for(let a=0;a<s.length;a++)if(s[a]!==n[a])return!1;return!0}t.drop=function(s,n){return{...s,path:s.path.slice(n)}},t.applySimple=function(s,n){return e(s,n)?.data??s},t.apply=e,t.pathDisjoint=i,t.pathEq=r,t.commutative=function(s,n){return i(s.path,n.path)},t.subsumed=function(s,n){return!(s.type!==0||n.type!==0||!r(s.path,n.path))&&Object.keys(s.props).every(a=>n.props[a]!==void 0)}})(ea||(ea={})),(t=>{function e(i,r){let s=i,n=[],a=[];for(let o of r)try{if(o.type===3||o.type===5&&o.path[o.path.length-1]==="variables"){let l,u,h;if(o.type===3?(l=Dn.zoom(s,[...o.path,o.id]),h=ea.apply(s,{...o,type:2})):(l=Dn.zoom(s,[...o.path,o.id,"value"]),h=ea.apply(s,o)),h!==null){s=h.data;let[d,c]=cMt(s,{[o.id]:l});s=d;for(let p=0;p<c.length;p++){let m=c[p],f=m.pop();if(typeof f=="number"){let g=[f];for(let v=p+1;v<c.length;v++){let b=c[v],_=b[b.length-1];if(typeof _!="number"||!Dn.equal(m,b.slice(0,b.length-1)))break;g.push(_),c.splice(v,1)}let y=Dn.zoom(s,m);u=y.map((v,b)=>g.includes(b)?o.id:v),l=y,f=m.pop()}else{if(f==="alphaOverride"||f==="alpha"){l/=100;let g=l,y=Dn.zoom(s,m.slice(0,m.length-2)),v=y.layers.map(b=>b.id===m[m.length-1]?{...b,data:{...b.data,[f]:g}}:b);Object.setPrototypeOf(v,Object.getPrototypeOf(y.layers)),y.layers=v}u=o.id}n.push({type:0,path:m,props:{[f]:l}}),a.push({type:0,path:m,props:{[f]:u}})}a.push(h.reverse),n.push(h.actual)}}else{let l=ea.apply(s,o);l!==null&&(n.push(l.actual),s=l.data,a.push(l.reverse))}}catch(l){if(l instanceof Y7)return null;throw l}return{data:s,actual:n,reverse:a.reverse()}}t.empty=function(){return[]},t.removePrefix=function(i,r){let s=[];for(let n of i){let[a,...o]=n.path;a===r&&s.push({...n,path:o})}return s},t.addPrefix=function(i,r){return i.map(s=>({...s,path:[r,...s.path]}))},t.concat=function(i,r){return[...i,...r]},t.compress=function(i,r){return[...i.filter(s=>!r.some(n=>ea.subsumed(s,n))),...r]},t.commutative=function(i,r){return i.every(s=>r.every(n=>ea.commutative(s,n)))},t.applyAll=function(i,r){for(let s of r){let n=e(i,s);n!==null&&(i=n.data)}return i},t.apply=e})(R$||(R$={}))});function FN(t,e,i){if(t.length>0){let r=t[t.length-1];if(r.type===0&&e.type===0&&Dn.equal(r.path,i))return void Object.assign(r.props,e.props)}t.push({...e,path:i})}function CP(t,e,i){return i instanceof In?new S5(t,e,i):i instanceof ge?new T5(t,e,i):i instanceof Be?new Proxy(new nmt(t,e,i),omt):i!==null&&typeof i=="object"?Yg(i)?i:new Proxy(new smt(t,e,i),amt):i}function Gw(t){let e=new z8(t);return[CP(e,"",t),e]}function Z4(t,e){let[i,r]=Gw(t);return e(i),r.result()}function Gs(t){return t instanceof S5||t instanceof T5?t._current:t!==null&&typeof t=="object"?t[k8]:t}var k8,D$,i_,I0,smt,nmt,UN,amt,omt,S5,T5,z8,Dn,lmt=G(()=>{w5(),t0(),Q7(),e0(),hn(),M5(),k8=Symbol(),D$=Symbol(),i_=Symbol(),I0=class{reportOp(t,e,i=[]){let r=this;if(e===null)return;r._current=e.data;let s=i;for(;!(r instanceof z8);){let n=r._path,a=r._current;if(n!==""&&s.splice(0,0,n),r=r._parent,r===null)return;r.update(n,a)}r.push(s,t,e.actual,e.reverse)}deleteChildren(t){if(this._children){let e=this._children[t];if(e){let i=e[i_];i&&i(),delete this._children[t]}}}},smt=class extends I0{constructor(t,e,i){super(),this._parent=t,this._path=e,this._current=i}update(t,e){if(Array.isArray(this._current)){if(typeof t=="string"&&(t=parseInt(t),isNaN(t)))throw new Error("Invalid path");this._current=[...this._current],this._current[t]=e}else this._current=Dv.tryPreservePrototype(this._current,{...this._current,[t]:e})}runOp(t){this.reportOp(t,Dv.runOp(this._current,t),t.path)}},nmt=class extends I0{constructor(t,e,i){super(),this._parent=t,this._path=e,this._current=i}update(t,e){this._current={...this._current,[t]:e},Object.setPrototypeOf(this._current,Be.prototype)}runOp(t){this.reportOp(t,this._current.runOp(t))}},UN={get(t,e){if(e===i_)return()=>{t._parent=null};if(e===k8)return t._current;if(e===D$)return t;let{_current:i,_children:r}=t;if(e==="push"&&Array.isArray(i))throw new Error("not supported to expand array");let s=r===void 0?void 0:r[e];if(s!==void 0)return s;let n=i[e],a=CP(t,e,n);return a!==n?(r===void 0&&(r={},t._children=r),r[e]=a,a):n},has:(t,e)=>e in t._current,ownKeys:t=>Reflect.ownKeys(t._current),defineProperty(){throw Error("not supported")},getPrototypeOf:t=>Object.getPrototypeOf(t._current),setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(t,e){let i=t._current,r=Reflect.getOwnPropertyDescriptor(i,e);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:i[e]}}},amt={...UN,set(t,e,i){let r={type:0,props:{[e]:Gs(i)??i}};return t.deleteChildren(e),t.runOp(r),!0},deleteProperty(t,e){let i={type:0,props:{[e]:void 0}};return t.deleteChildren(e),t.runOp(i),!0}},omt={...UN,set(t,e,i){return i===void 0?this.deleteProperty(t,e):(t.deleteChildren(e),t.runOp({type:1,id:e,data:i})),!0},deleteProperty:(t,e)=>(t.runOp({type:2,id:e}),!0)},S5=class extends I0{constructor(t,e,i){super(),this._children={},this._parent=t,this._path=e,this._current=i,this[i_]=()=>{this._parent=null}}unproxy(){return this._current}update(t,e){this._current=this._current.modifyById(t,e)}runOp(t){this.reportOp(t,this._current.runOp(t))}randomId(){return this._current.randomId()}isDescendantOf(t,e){return this._current.isDescendantOf(t,e)}childrenOf(t){return this._current.childrenOf(t)}get(t){return this._current.get(t)}parent(t){return this._current.parent(t)}traverse(t){this._current.traverse((e,i)=>{t(e,this.data(e))})}data(t){let{_current:e,_children:i}=this,r=i===void 0?void 0:i[t];if(r!==void 0)return r;let s=e.get(t)?.data,n=CP(this,t,s);return n!==s?(i===void 0&&(i={},this._children=i),i[t]=n,n):s}add(t,e,i,r,s){this.runOp({type:7,parent:t,fi:e,id:i,data:r,children:s})}move(t,e,i){this.runOp({type:9,parent:t,fi:e,id:i})}insertAfter(t,e,i){let r=this._current.insertAfterHelper(t,e,i.length);for(let s=0;s<i.length;s++){let n=i[s];this.add(t,r[s],n.id,n.data,n.children)}}insertBefore(t,e,i){let r=this._current.insertBeforeHelper(t,e,i.length);for(let s=0;s<i.length;s++){let n=i[s];this.add(t,r[s],n.id,n.data,n.children)}}moveAfter(t,e,i){let r=this._current.insertAfterHelper(t,e,i.length);for(let s=0;s<i.length;s++){let n=i[s];this.move(t,r[s],n)}}moveBefore(t,e,i){let r=this._current.insertBeforeHelper(t,e,i.length);for(let s=0;s<i.length;s++){let n=i[s];this.move(t,r[s],n)}}delete(t){this.deleteChildren(t),this.runOp({type:8,id:t})}sortNext(t){return this._current.sortNext(t)}sortPrevious(t){return this._current.sortPrevious(t)}getAllSorted(t){return this._current.getAllSorted(t)}},T5=class extends I0{constructor(t,e,i){super(),this._children={},this._parent=t,this._path=e,this._current=i,this[i_]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(t){let e=this.length;for(let i=0;i<e;i++){let r=this._current[i].id,s=this._current[i].fi;t(this.data(this._current[i].id),r,s,i)}}find(t){let e=this.length;for(let i=0;i<e;i++){let r=this._current[i].id;if(t(this.data(r),r))return this.get(r)}}update(t,e){this._current=this._current.modifyById(t,e)}randomId(){return this._current.randomId()}get(t){return{...this._current.get(t),data:this.data(t)}}at(t){let{id:e,fi:i}=this._current.at(t);return{id:e,fi:i,data:this.data(e)}}data(t){let{_current:e,_children:i}=this,r=i===void 0?void 0:i[t];if(r!==void 0)return r;let s=e.get(t)?.data,n=CP(this,t,s);return n!==s?(i===void 0&&(i={},this._children=i),i[t]=n,n):s}runOp(t){this.reportOp(t,this._current.runOp(t))}add(t,e,i){this.runOp({type:4,fi:t,id:e,data:i})}move(t,e){this.runOp({type:6,fi:t,id:e})}insertAfter(t,e){let i=this._current.insertAfterHelper(t,e.length);for(let r=0;r<e.length;r++){let s=e[r];this.add(i[r],s.id,s.data)}}insertBefore(t,e){let i=this._current.insertBeforeHelper(t,e.length);for(let r=0;r<e.length;r++){let s=e[r];this.add(i[r],s.id,s.data)}}moveAfter(t,e){let i=this._current.insertAfterHelper(t,e.length);for(let r=0;r<e.length;r++){let s=e[r];this.move(i[r],s)}}moveBefore(t,e){let i=this._current.insertBeforeHelper(t,e.length);for(let r=0;r<e.length;r++){let s=e[r];this.move(i[r],s)}}delete(t){this.deleteChildren(t),this.runOp({type:5,id:t})}},z8=class extends I0{constructor(t){super(),this.ts=[],this.actual=[],this.reverse=[],this._current=t}update(t,e){if(t!=="")throw new Error("");this._current=e}push(t,e,i,r){FN(this.ts,e,t),FN(this.actual,i,t),FN(this.reverse,r,t)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}}}),M5=G(()=>{K7(),lmt(),e0(),t0(),hn(),(t=>{function e(r,s){return(r instanceof In||r instanceof S5)&&typeof s=="string"||(r instanceof ge||r instanceof T5)&&typeof s=="string"?r.data(s):typeof s=="number"&&Array.isArray(r)||typeof s=="string"&&typeof r=="object"&&r!==null?r[s]:void 0}function i(r,s,n=0){for(;n<s.length&&r!==void 0;)r=e(r,s[n]),n+=1;return r}t.equal=function(r,s){if(s.length!==r.length)return!1;{let n=0;for(;n<r.length;){if(r[n]!==s[n])return!1;n+=1}}return!0},t.removeOverridden=function(r,s,n){let a=i(n,r);if(a!==void 0&&typeof a=="object"&&a!==null){let o={...s};return Object.keys(a).forEach(l=>{delete o[l]}),o}return s},t.zoomOnce=e,t.zoom=i,t.findPathes=function(r,s){let n=[];return function a(o,l){if(o instanceof Y4&&o.id===s.id)n.push(l);else if(o instanceof ge)for(let u=0;u<o.length;u++)a(o[u].data,[...l,o[u].id]);else if(o instanceof In)o.traverse((u,h)=>{a(h,[...l,u])});else if(Array.isArray(o)){if(typeof o[0]=="number")return;for(let u=0;u<o.length;u++)a(o[u],[...l,u])}else{if(Yg(o))return;if(typeof o=="object"&&o!==null)for(let u in o)a(o[u],[...l,u])}}(r,[]),n}})(Dn||(Dn={}))}),mMt=G(()=>{});function er(t,e){let i=[];if(!(e.length<=t.length))return null;{let r=0;for(;r<e.length;){if(e[r]==="*")i.push(t[r]);else if(t[r]!==e[r])return null;r+=1}}return i}var fMt=G(()=>{});function gM(t){try{if(!Er.trusted&&!fc){let i=Wi.sharedLength||0;i<Wi.length&&(Wi.length=i)}let e;if(Er.randomAccessStructure&&pe[mt]<64&&pe[mt]>=32&&k$?(e=k$(pe,mt,Ql,Er),pe=null,!(t&&t.lazy)&&e&&(e=e.toJSON()),mt=Ql):e=$s(),Da&&(mt=Da.postBundlePosition,Da=null),fc&&(Wi.restoreStructures=null),mt==Ql)Wi&&Wi.restoreStructures&&N$(),Wi=null,pe=null,mc&&(mc=null);else{if(mt>Ql)throw new Error("Unexpected end of MessagePack data");if(!fc){let i;try{i=JSON.stringify(e,(r,s)=>typeof s=="bigint"?`${s}n`:s).slice(0,100)}catch(r){i="(JSON view not available "+r+")"}throw new Error("Data read, but end of buffer not reached "+i)}}return e}catch(e){throw Wi&&Wi.restoreStructures&&N$(),F8(),(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer")||mt>Ql)&&(e.incomplete=!0),e}}function N$(){for(let t in Wi.restoreStructures)Wi[t]=Wi.restoreStructures[t];Wi.restoreStructures=null}function $s(){let t=pe[mt++];if(t<160){if(t<128){if(t<64)return t;{let e=Wi[63&t]||Er.getStructures&&hmt()[63&t];return e?(e.read||(e.read=L8(e,63&t)),e.read()):t}}if(t<144){if(t-=128,Er.mapsAsObjects){let e={};for(let i=0;i<t;i++){let r=dmt();r==="__proto__"&&(r="__proto_"),e[r]=$s()}return e}{let e=new Map;for(let i=0;i<t;i++)e.set($s(),$s());return e}}{t-=144;let e=new Array(t);for(let i=0;i<t;i++)e[i]=$s();return Er.freezeData?Object.freeze(e):e}}if(t<192){let e=t-160;if(qh>=mt)return Qp.slice(mt-pl,(mt+=e)-pl);if(qh==0&&Ql<140){let i=e<16?iG(e):umt(e);if(i!=null)return i}return tR(e)}{let e;switch(t){case 192:return null;case 193:return Da?(e=$s(),e>0?Da[1].slice(Da.position1,Da.position1+=e):Da[0].slice(Da.position0,Da.position0-=e)):mmt;case 194:return!1;case 195:return!0;case 196:if(e=pe[mt++],e===void 0)throw new Error("Unexpected end of buffer");return jN(e);case 197:return e=zi.getUint16(mt),mt+=2,jN(e);case 198:return e=zi.getUint32(mt),mt+=4,jN(e);case 199:return Qm(pe[mt++]);case 200:return e=zi.getUint16(mt),mt+=2,Qm(e);case 201:return e=zi.getUint32(mt),mt+=4,Qm(e);case 202:if(e=zi.getFloat32(mt),Er.useFloat32>2){let i=H8[(127&pe[mt])<<1|pe[mt+1]>>7];return mt+=4,(i*e+(e>0?.5:-.5)|0)/i}return mt+=4,e;case 203:return e=zi.getFloat64(mt),mt+=8,e;case 204:return pe[mt++];case 205:return e=zi.getUint16(mt),mt+=2,e;case 206:return e=zi.getUint32(mt),mt+=4,e;case 207:return Er.int64AsType==="number"?(e=4294967296*zi.getUint32(mt),e+=zi.getUint32(mt+4)):Er.int64AsType==="string"?e=zi.getBigUint64(mt).toString():Er.int64AsType==="auto"?(e=zi.getBigUint64(mt),e<=BigInt(2)<<BigInt(52)&&(e=Number(e))):e=zi.getBigUint64(mt),mt+=8,e;case 208:return zi.getInt8(mt++);case 209:return e=zi.getInt16(mt),mt+=2,e;case 210:return e=zi.getInt32(mt),mt+=4,e;case 211:return Er.int64AsType==="number"?(e=4294967296*zi.getInt32(mt),e+=zi.getUint32(mt+4)):Er.int64AsType==="string"?e=zi.getBigInt64(mt).toString():Er.int64AsType==="auto"?(e=zi.getBigInt64(mt),e>=BigInt(-2)<<BigInt(52)&&e<=BigInt(2)<<BigInt(52)&&(e=Number(e))):e=zi.getBigInt64(mt),mt+=8,e;case 212:if(e=pe[mt++],e==114)return q8(63&pe[mt++]);{let i=Ma[e];if(i)return i.read?(mt++,i.read($s())):i.noBuffer?(mt++,i()):i(pe.subarray(mt,++mt));throw new Error("Unknown extension "+e)}case 213:return e=pe[mt],e==114?(mt++,q8(63&pe[mt++],pe[mt++])):Qm(2);case 214:return Qm(4);case 215:return Qm(8);case 216:return Qm(16);case 217:return e=pe[mt++],qh>=mt?Qp.slice(mt-pl,(mt+=e)-pl):gmt(e);case 218:return e=zi.getUint16(mt),qh>=(mt+=2)?Qp.slice(mt-pl,(mt+=e)-pl):ymt(e);case 219:return e=zi.getUint32(mt),qh>=(mt+=4)?Qp.slice(mt-pl,(mt+=e)-pl):vmt(e);case 220:return e=zi.getUint16(mt),mt+=2,O$(e);case 221:return e=zi.getUint32(mt),mt+=4,O$(e);case 222:return e=zi.getUint16(mt),mt+=2,I$(e);case 223:return e=zi.getUint32(mt),mt+=4,I$(e);default:if(t>=224)return t-256;if(t===void 0){let i=new Error("Unexpected end of MessagePack data");throw i.incomplete=!0,i}throw new Error("Unknown MessagePack token "+t)}}}function L8(t,e){function i(){if(i.count++>j8){let s;try{s=t.read=new Function("r","return function(){return "+(Er.freezeData?"Object.freeze":"")+"({"+t.map(n=>n==="__proto__"?"__proto_:r()":fmt.test(n)?n+":r()":"["+JSON.stringify(n)+"]:r()").join(",")+"})}")($s)}catch{return j8=1/0,i()}return t.read0=s,t.highByte===0&&(t.read=G8(e,t.read)),s()}let r={};for(let s=0,n=t.length;s<n;s++){let a=t[s];a==="__proto__"&&(a="__proto_"),r[a]=$s()}return Er.freezeData?Object.freeze(r):r}return i.count=0,t.read0=i,t.highByte===0?G8(e,i):i}function hmt(){let t=pmt(()=>(pe=null,Er.getStructures()));return Wi=Er._mergeStructures(t,Wi)}function Ww(t){let e;if(t<16&&(e=iG(t)))return e;if(t>64&&U8)return U8.decode(pe.subarray(mt,mt+=t));let i=mt+t,r=[];for(e="";mt<i;){let s=pe[mt++];if(128&s)if((224&s)==192){let n=(31&s)<<6|63&pe[mt++];n<128?r.push(65533):r.push(n)}else if((240&s)==224){let n=(31&s)<<12|(63&pe[mt++])<<6|63&pe[mt++];n<2048||n>=55296&&n<=57343?r.push(65533):r.push(n)}else if((248&s)==240){let n=(7&s)<<18|(63&pe[mt++])<<12|(63&pe[mt++])<<6|63&pe[mt++];n<65536||n>1114111?r.push(65533):(n>65535&&(n-=65536,r.push(n>>>10&1023|55296),n=56320|1023&n),r.push(n))}else r.push(65533);else r.push(s);r.length>=4096&&(e+=Tn.apply(String,r),r.length=0)}return r.length>0&&(e+=Tn.apply(String,r)),e}function O$(t){let e=new Array(t);for(let i=0;i<t;i++)e[i]=$s();return Er.freezeData?Object.freeze(e):e}function I$(t){if(Er.mapsAsObjects){let e={};for(let i=0;i<t;i++){let r=dmt();r==="__proto__"&&(r="__proto_"),e[r]=$s()}return e}{let e=new Map;for(let i=0;i<t;i++)e.set($s(),$s());return e}}function umt(t){let e=mt,i=new Array(t);for(let r=0;r<t;r++){let s=pe[mt++];if((128&s)>0)return void(mt=e);i[r]=s}return Tn.apply(String,i)}function iG(t){if(t<4){if(t<2){if(t===0)return"";{let e=pe[mt++];return(128&e)>1?void(mt-=1):Tn(e)}}{let e=pe[mt++],i=pe[mt++];if((128&e)>0||(128&i)>0)return void(mt-=2);if(t<3)return Tn(e,i);let r=pe[mt++];return(128&r)>0?void(mt-=3):Tn(e,i,r)}}{let e=pe[mt++],i=pe[mt++],r=pe[mt++],s=pe[mt++];if((128&e)>0||(128&i)>0||(128&r)>0||(128&s)>0)return void(mt-=4);if(t<6){if(t===4)return Tn(e,i,r,s);{let n=pe[mt++];return(128&n)>0?void(mt-=5):Tn(e,i,r,s,n)}}if(t<8){let n=pe[mt++],a=pe[mt++];if((128&n)>0||(128&a)>0)return void(mt-=6);if(t<7)return Tn(e,i,r,s,n,a);let o=pe[mt++];return(128&o)>0?void(mt-=7):Tn(e,i,r,s,n,a,o)}{let n=pe[mt++],a=pe[mt++],o=pe[mt++],l=pe[mt++];if((128&n)>0||(128&a)>0||(128&o)>0||(128&l)>0)return void(mt-=8);if(t<10){if(t===8)return Tn(e,i,r,s,n,a,o,l);{let u=pe[mt++];return(128&u)>0?void(mt-=9):Tn(e,i,r,s,n,a,o,l,u)}}if(t<12){let u=pe[mt++],h=pe[mt++];if((128&u)>0||(128&h)>0)return void(mt-=10);if(t<11)return Tn(e,i,r,s,n,a,o,l,u,h);let d=pe[mt++];return(128&d)>0?void(mt-=11):Tn(e,i,r,s,n,a,o,l,u,h,d)}{let u=pe[mt++],h=pe[mt++],d=pe[mt++],c=pe[mt++];if((128&u)>0||(128&h)>0||(128&d)>0||(128&c)>0)return void(mt-=12);if(t<14){if(t===12)return Tn(e,i,r,s,n,a,o,l,u,h,d,c);{let p=pe[mt++];return(128&p)>0?void(mt-=13):Tn(e,i,r,s,n,a,o,l,u,h,d,c,p)}}{let p=pe[mt++],m=pe[mt++];if((128&p)>0||(128&m)>0)return void(mt-=14);if(t<15)return Tn(e,i,r,s,n,a,o,l,u,h,d,c,p,m);let f=pe[mt++];return(128&f)>0?void(mt-=15):Tn(e,i,r,s,n,a,o,l,u,h,d,c,p,m,f)}}}}}function B$(){let t,e=pe[mt++];if(e<192)t=e-160;else switch(e){case 217:t=pe[mt++];break;case 218:t=zi.getUint16(mt),mt+=2;break;case 219:t=zi.getUint32(mt),mt+=4;break;default:throw new Error("Expected string")}return Ww(t)}function jN(t){return Er.copyBuffers?Uint8Array.prototype.slice.call(pe,mt,mt+=t):pe.subarray(mt,mt+=t)}function Qm(t){let e=pe[mt++];if(Ma[e]){let i;return Ma[e](pe.subarray(mt,i=mt+=t),r=>{mt=r;try{return $s()}finally{mt=i}})}throw new Error("Unknown extension type "+e)}function dmt(){let t=pe[mt++];if(!(t>=160&&t<192))return mt--,cmt($s());if(t-=160,qh>=mt)return Qp.slice(mt-pl,(mt+=t)-pl);if(!(qh==0&&Ql<180))return tR(t);let e,i=4095&(t<<5^(t>1?zi.getUint16(mt):t>0?pe[mt]:0)),r=W8[i],s=mt,n=mt+t-3,a=0;if(r&&r.bytes==t){for(;s<n;){if(e=zi.getUint32(s),e!=r[a++]){s=1879048192;break}s+=4}for(n+=3;s<n;)if(e=pe[s++],e!=r[a++]){s=1879048192;break}if(s===n)return mt=s,r.string;n-=3,s=mt}for(r=[],W8[i]=r,r.bytes=t;s<n;)e=zi.getUint32(s),r.push(e),s+=4;for(n+=3;s<n;)e=pe[s++],r.push(e);let o=t<16?iG(t):umt(t);return r.string=o??tR(t)}function cmt(t){if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean"||typeof t=="bigint")return t.toString();if(t==null)return t+"";if(Er.allowArraysInMapKeys&&Array.isArray(t)&&t.flat().every(e=>["string","number","boolean","bigint"].includes(typeof e)))return t.flat().toString();throw new Error("Invalid property type for record: "+typeof t)}function pmt(t){z$&&z$();let e=Ql,i=mt,r=J4,s=pl,n=qh,a=Qp,o=Q4,l=mc,u=Da,h=new Uint8Array(pe.slice(0,Ql)),d=Wi,c=Wi.slice(0,Wi.length),p=Er,m=fc,f=t();return Ql=e,mt=i,J4=r,pl=s,qh=n,Qp=a,Q4=o,mc=l,Da=u,pe=h,fc=m,(Wi=d).splice(0,Wi.length,...c),Er=p,zi=new DataView(pe.buffer,pe.byteOffset,pe.byteLength),f}function F8(){pe=null,mc=null,Wi=null}function gMt(t){t.unpack?Ma[t.type]=t.unpack:Ma[t.type]=t}var U8,pe,Ql,mt,V$,Q4,J4,Er,Wi,Qp,pl,qh,Da,mc,Ma,zi,GN,mmt,fc,j8,k$,z$,qw,fmt,G8,tR,gmt,ymt,vmt,Tn,W8,q8,WN,L$,F$,U$,H8,yM,j$,G$,W$,$8,qN,CS,yMt=G(()=>{try{U8=new TextDecoder}catch{}mt=0,Q4=V$=[],J4=0,Er={},pl=0,qh=0,Ma=[],GN={useRecords:!1,mapsAsObjects:!0},(mmt=new class{}).name="MessagePack 0xC1",fc=!1,j8=2,qw=class{constructor(t){t&&(t.useRecords===!1&&t.mapsAsObjects===void 0&&(t.mapsAsObjects=!0),t.sequential&&t.trusted!==!1&&(t.trusted=!0,!t.structures&&t.useRecords!=0&&(t.structures=[],t.maxSharedStructures||(t.maxSharedStructures=0))),t.structures?t.structures.sharedLength=t.structures.length:t.getStructures&&((t.structures=[]).uninitialized=!0,t.structures.sharedLength=0),t.int64AsNumber&&(t.int64AsType="number")),Object.assign(this,t)}unpack(t,e){if(pe)return pmt(()=>(F8(),this?this.unpack(t,e):qw.prototype.unpack.call(GN,t,e)));!t.buffer&&t.constructor===ArrayBuffer&&(t=typeof Buffer<"u"?Buffer.from(t):new Uint8Array(t)),typeof e=="object"?(Ql=e.end||t.length,mt=e.start||0):(mt=0,Ql=e>-1?e:t.length),J4=0,qh=0,Qp=null,Q4=V$,Da=null,pe=t;try{zi=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(i){throw pe=null,t instanceof Uint8Array?i:new Error("Source must be a Uint8Array or Buffer but was a "+(t&&typeof t=="object"?t.constructor.name:typeof t))}if(this instanceof qw){if(Er=this,this.structures)return Wi=this.structures,gM(e);(!Wi||Wi.length>0)&&(Wi=[])}else Er=GN,(!Wi||Wi.length>0)&&(Wi=[]);return gM(e)}unpackMultiple(t,e){let i,r=0;try{fc=!0;let s=t.length,n=this?this.unpack(t,s):yM.unpack(t,s);if(!e){for(i=[n];mt<s;)r=mt,i.push(gM());return i}if(e(n,r,mt)===!1)return;for(;mt<s;)if(r=mt,e(gM(),r,mt)===!1)return}catch(s){throw s.lastPosition=r,s.values=i,s}finally{fc=!1,F8()}}_mergeStructures(t,e){t=t||[],Object.isFrozen(t)&&(t=t.map(i=>i.slice(0)));for(let i=0,r=t.length;i<r;i++){let s=t[i];s&&(s.isShared=!0,i>=32&&(s.highByte=i-32>>5))}t.sharedLength=t.length;for(let i in e||[])if(i>=0){let r=t[i],s=e[i];s&&(r&&((t.restoreStructures||(t.restoreStructures=[]))[i]=r),t[i]=s)}return this.structures=t}decode(t,e){return this.unpack(t,e)}},fmt=/^[a-zA-Z_$][a-zA-Z\d_$]*$/,G8=(t,e)=>function(){let i=pe[mt++];if(i===0)return e();let r=t<32?-(t+(i<<5)):t+(i<<5),s=Wi[r]||hmt()[r];if(!s)throw new Error("Record id is not defined for "+r);return s.read||(s.read=L8(s,t)),s.read()},tR=Ww,gmt=Ww,ymt=Ww,vmt=Ww,Tn=String.fromCharCode,W8=new Array(4096),q8=(t,e)=>{let i=$s().map(cmt),r=t;e!==void 0&&(t=t<32?-((e<<5)+t):(e<<5)+t,i.highByte=e);let s=Wi[t];return s&&(s.isShared||fc)&&((Wi.restoreStructures||(Wi.restoreStructures=[]))[t]=s),Wi[t]=i,i.read=L8(i,r),(i.read0||i.read)()},Ma[0]=()=>{},Ma[0].noBuffer=!0,Ma[66]=t=>{let e=t.byteLength%8||8,i=BigInt(128&t[0]?t[0]-256:t[0]);for(let r=1;r<e;r++)i<<=BigInt(8),i+=BigInt(t[r]);if(t.byteLength!==e){let r=new DataView(t.buffer,t.byteOffset,t.byteLength),s=(n,a)=>{let o=a-n;if(o<=40){let d=r.getBigUint64(n);for(let c=n+8;c<a;c+=8)d<<=BigInt(64),d|=r.getBigUint64(c);return d}let l=n+(o>>4<<3),u=s(n,l),h=s(l,a);return u<<BigInt(8*(a-l))|h};i=i<<BigInt(8*(r.byteLength-e))|s(e,r.byteLength)}return i},WN={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError,AggregateError:typeof AggregateError=="function"?AggregateError:null},Ma[101]=()=>{let t=$s();if(!WN[t[0]]){let e=Error(t[1],{cause:t[2]});return e.name=t[0],e}return WN[t[0]](t[1],{cause:t[2]})},Ma[105]=t=>{if(Er.structuredClone===!1)throw new Error("Structured clone extension is disabled");let e=zi.getUint32(mt-4);mc||(mc=new Map);let i,r=pe[mt];i=r>=144&&r<160||r==220||r==221?[]:r>=128&&r<144||r==222||r==223?new Map:(r>=199&&r<=201||r>=212&&r<=216)&&pe[mt+1]===115?new Set:{};let s={target:i};mc.set(e,s);let n=$s();if(!s.used)return s.target=n;if(Object.assign(i,n),i instanceof Map)for(let[a,o]of n.entries())i.set(a,o);if(i instanceof Set)for(let a of Array.from(n))i.add(a);return i},Ma[112]=t=>{if(Er.structuredClone===!1)throw new Error("Structured clone extension is disabled");let e=zi.getUint32(mt-4),i=mc.get(e);return i.used=!0,i.target},Ma[115]=()=>new Set($s()),L$=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(t=>t+"Array"),F$=typeof globalThis=="object"?globalThis:window,Ma[116]=t=>{let e=t[0],i=Uint8Array.prototype.slice.call(t,1).buffer,r=L$[e];if(!r){if(e===16)return i;if(e===17)return new DataView(i);throw new Error("Could not find typed array for code "+e)}return new F$[r](i)},Ma[120]=()=>{let t=$s();return new RegExp(t[0],t[1])},U$=[],Ma[98]=t=>{let e=(t[0]<<24)+(t[1]<<16)+(t[2]<<8)+t[3],i=mt;return mt+=e-t.length,Da=U$,(Da=[B$(),B$()]).position0=0,Da.position1=0,Da.postBundlePosition=mt,mt=i,$s()},Ma[255]=t=>t.length==4?new Date(1e3*(16777216*t[0]+(t[1]<<16)+(t[2]<<8)+t[3])):t.length==8?new Date(((t[0]<<22)+(t[1]<<14)+(t[2]<<6)+(t[3]>>2))/1e6+1e3*(4294967296*(3&t[3])+16777216*t[4]+(t[5]<<16)+(t[6]<<8)+t[7])):t.length==12?new Date(((t[0]<<24)+(t[1]<<16)+(t[2]<<8)+t[3])/1e6+1e3*((128&t[4]?-281474976710656:0)+1099511627776*t[6]+4294967296*t[7]+16777216*t[8]+(t[9]<<16)+(t[10]<<8)+t[11])):new Date("invalid"),H8=new Array(147);for(let t=0;t<256;t++)H8[t]=+("1e"+Math.floor(45.15-.30103*t));(yM=new qw({useRecords:!1})).unpack,yM.unpackMultiple,yM.unpack,j$=new Float32Array(1),new Uint8Array(j$.buffer,0,4)}),vMt=G(()=>{yMt(),K7(),eG(),e0(),w5(),t0(),G$=[{Class:Be.prototype.constructor,type:1,write:t=>({...t}),read:t=>(Object.setPrototypeOf(t,Be.prototype),t)},{Class:ge.prototype.constructor,type:2,write:t=>[...t],read:t=>(Object.setPrototypeOf(t,ge.prototype),t)},{Class:In.prototype.constructor,type:3,write:t=>[...t],read:t=>(Object.setPrototypeOf(t,In.prototype),t)},{Class:Y4.prototype.constructor,type:4,write:t=>t.id,read:t=>new Y4(t)},{Class:V8.prototype.constructor,type:5,write:t=>t.data,read:t=>new V8(t)},{Class:Xs.prototype.constructor,type:6,write:t=>({...t}),read:t=>(Object.setPrototypeOf(t,Xs.prototype),t)}];for(let t of G$)gMt(t);W$=new qw({structuredClone:!0}),($8||($8={})).deserialize=function(t){return W$.unpack(t)}}),bMt=G(()=>{vMt(),qN=t=>()=>{throw new Error(t+" is not available in the runtime build (decode-only CollabSerialize)")},CS={deserialize:$8.deserialize,serialize:qN("CollabSerialize.serialize"),checksum:qN("CollabSerialize.checksum")}}),Fi=G(()=>{M5(),dMt(),Z7(),t0(),w5(),Q7(),e0(),pMt(),mMt(),lmt(),fMt(),K7(),bMt(),rmt(),eG()});function X8(t){return t==="MouseDown"||t==="MouseUp"||t==="KeyDown"||t==="KeyUp"||t==="Collision"||t==="Trigger"}var q$,Y8,j2,vM,HN,H$,$$,X$,K8,Z8,Y$,K$,Z$,Q$,J$,Q8,J8,tX,eX,iX,rX,bmt=G(()=>{var t,e,i;Fi(),dt(),(t=q$||(q$={})).toEventUIType=function(r){return r.type==="Conditional"?r.condition.type==="Distance"?"Distance":"StateChange":r.type},t.fromEventUIType=function(r){return r==="Distance"||r==="StateChange"?"Conditional":r},Y8={LookAt:[],Follow:["Create"],DragDrop:["Transition","Animation","Audio","Particles","Create","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],MouseHover:["Transition","Animation","TimelineAnimation","Particles","Create","Destroy","SwitchCamera","SceneTransition","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Scroll:["Transition","Animation","TimelineAnimation","Create","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Start:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Conditional:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],MouseDown:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],MouseUp:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],MousePress:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],KeyDown:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],KeyUp:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],KeyPress:["Transition","Animation","Audio","Particles","Video","Link","Create","SwitchCamera","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],GameControl:["Transition","Animation","TimelineAnimation","Audio","Particles","Create","Conditional"],Collision:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Create","Destroy","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Trigger:["Transition","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Resize:["Transition","Animation","Audio","Particles","Video","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],VariableChange:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],API:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],WEBHOOK:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],AIAssistantListener:["SetVariable"],AIAssistantTrigger:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"]},(r=>{r.is=function(s){return s.type==="MouseDown"||s.type==="MouseUp"||s.type==="MousePress"||s.type==="KeyDown"||s.type==="KeyUp"||s.type==="KeyPress"},r.defaultData=function(s){return s==="MouseDown"||s==="MouseUp"||s==="MousePress"?{type:s,mode:"Object",disabled:!1,name:"",actions:new ge}:{type:s,disabled:!1,name:"",key:void 0,actions:new ge}}})(j2||(j2={})),(r=>{r.propertyDefaultData=function(s){return{type:"Property",value:[s??null,"position","x"]}},r.valueDefaultData={type:"Literal",value:0}})(vM||(vM={})),(e=HN||(HN={})).comparisonDefaultData=function(r){return{type:"Comparison",operator:"==",lOperand:vM.propertyDefaultData(r),rOperand:{...vM.valueDefaultData}}},e.distanceDefaultData=function(r){return{type:"Distance",toObject:r??null,fromObject:r??null,distance:200}},e.stateDefaultData=function(r,s){return{type:"State",object:r??null,state:s??null}},(H$||(H$={})).isConditionalSubActions=function(r){return r.find(s=>s==="ifActions"||s==="elseActions")!==void 0},(r=>{r.is=function(s){return s.type==="Conditional"},r.defaultData=function(s){return{type:"Conditional",disabled:!1,name:"",inActions:new ge,outActions:new ge,condition:HN.distanceDefaultData(s)}}})($$||($$={})),(X$||(X$={})).defaultData={type:"DragDrop",name:"",cursor:"hand",disabled:!1,dampingFactor:1,objects:[],snapTo:"center",snapSurfaceMode:"bbox",snapSurfaceOffset:0,dropOn:"all",autoOrient:!0,dropDestinations:[],plane:"adaptive",planeMode:"locked",referenceFrame:"global",limits:[-1/0,1/0,-1/0,1/0,-1/0,1/0],drop:!1,resetOnSnapFail:!1,snapSpeed:20,resetSpeed:20,dragDropActions:{drag:new ge,drop:new ge}},(K8||(K8={})).defaultData={type:"Follow",disabled:!1,name:"",maxDelta:0,dampingFactor:1,target:"cursor",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledTranslation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5,actions:new ge},(Z8||(Z8={})).defaultData={type:"LookAt",disabled:!1,name:"",distance:1e3,dampingFactor:1,target:"cursor",tilt:"up",axis:"z",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledRotation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5},(r=>{r.is=function(s){return s.type==="MouseHover"},r.defaultData=function(){return{type:"MouseHover",disabled:!1,name:"",actions:new ge}}})(Y$||(Y$={})),(r=>{r.is=function(s){return s.type==="Scroll"},r.defaultData=function(){return{type:"Scroll",disabled:!1,name:"",steps:100,trigger:"load",startFrom:"enter",enterAnchor:"top",startOffset:0,endAfter:400,actions:new ge}}})(K$||(K$={})),(r=>{r.is=function(s){return s.type==="Start"},r.defaultData=function(){return{type:"Start",disabled:!1,name:"",actions:new ge}}})(Z$||(Z$={})),(r=>{r.is=function(s){return s.type==="Collision"},r.defaultData=function(){return{type:"Collision",disabled:!1,name:"",target:"character",actions:new ge}}})(Q$||(Q$={})),(r=>{r.is=function(s){return s.type==="Trigger"},r.defaultData=function(s,n){return{type:"Trigger",name:"",disabled:!1,target:"all",triggeringObjects:[],actions:new ge,triggerZone:"box",position:n.toArray(),rotation:[0,0,0],size:s.toArray(),radius:s.length()/2,helperVisible:!0}}})(J$||(J$={})),(i=Q8||(Q8={})).defaultSizes={mobile:[480,480],tablet:[768,768],desktop:[1200,1200],custom:[769,1200]},i.is=function(r){return r.type==="Resize"},i.sizeToDevice=function(r){return typeof r=="string"?r:"custom"},i.deviceToSize=function(r){return typeof r=="string"?[...i.defaultSizes[r]]:[...r]},i.defaultData=function(){let r={size:"mobile",operator:"<",actions:new ge},s={size:"tablet",operator:"<",actions:new ge},n={size:[...i.defaultSizes.custom],operator:"<>",actions:new ge},a=new ge;return a.push({id:qt.generateUUID(),fi:0,data:r},{id:qt.generateUUID(),fi:1,data:s},{id:qt.generateUUID(),fi:2,data:n}),{type:"Resize",disabled:!1,name:"",orientation:"horizontal",breakpoints:a}},i.defaultBreakpointData=function(){return{size:[...i.defaultSizes.custom],operator:"<>",actions:new ge}},(r=>{r.propertyPaths={Position:["position"],"Position X":["position","x"],"Position Y":["position","y"],"Position Z":["position","z"],Rotation:["rotation"],"Rotation X":["rotation","x"],"Rotation Y":["rotation","y"],"Rotation Z":["rotation","z"],Scale:["scale"],"Scale X":["scale","x"],"Scale Y":["scale","y"],"Scale Z":["scale","z"],Width:["width"],Height:["height"],Depth:["depth"],"Mouse Position X":["mouse","x"],"Mouse Position Y":["mouse","y"],"Mouse Pressed":["mouse","pressed"],"Screen Width":["mouse","width"],"Screen Height":["mouse","height"],"Hit Position X":["raycast","x"],"Hit Position Y":["raycast","y"],"Hit Position Z":["raycast","z"],"Hit Object Position X":["raycast","objX"],"Hit Object Position Y":["raycast","objY"],"Hit Object Position Z":["raycast","objZ"]},r.is=function(s){return s.type==="VariableChange"},r.defaultData=function(){return{disabled:!1,type:"VariableChange",name:"",actions:new ge,variableId:"",objectId:null,property:"Position X"}}})(J8||(J8={})),(r=>{r.is=function(s){return s.type==="API"},r.defaultData=function(){return{disabled:!1,type:"API",name:"",successActions:new ge,errorActions:new ge,userAPIId:""}}})(tX||(tX={})),(r=>{r.is=function(s){return s.type==="WEBHOOK"},r.defaultData=function(){return{disabled:!1,type:"WEBHOOK",name:"",actions:new ge,userWebhookId:""}}})(eX||(eX={})),(r=>{r.is=function(s){return s.type==="AIAssistantListener"},r.defaultData=function(){return{disabled:!1,type:"AIAssistantListener",name:"",actions:new ge,analysis:"average",analysisRange:[0,71],analysisSingle:0}}})(iX||(iX={})),(r=>{r.is=function(s){return s.type==="AIAssistantTrigger"},r.defaultData=function(){return{disabled:!1,description:"",name:"",type:"AIAssistantTrigger",actions:new ge}}})(rX||(rX={}))});function sX(t){let e=typeof t;return t!==null&&(e==="object"||e==="function")}function nX(t){return typeof t=="string"&&t.length===36&&/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t)}var i0,ov,_mt,Kg,aX,qu,hm,ES,oX,lv,nn,qi,tU,lX,Jp,Nv,hX,uX,dX,cX,pX,mX,fX,gX,$N,yX,vX,XN,bX,_X,xX,YN,wX,KN,SX,TX,ZN,MX,eU,AX,CX,EX,PX,RX,DX,Zg,gc,tm,iU,rU,eR,iR,rR,sR,nR,sU,nU,aR,aU,hv,NX,QN,JN,oU,OX,oR,IX,BX,lU,VX,kX,zX,LX,FX,UX,jX,GX,WX,A5,rG,Ws,cs,S1,xmt,PS,lR,cg,hU,sG,hR,uR,uU,lc,EP,ia,tO,$p,wl=G(()=>{var t,e,i,r,s,n,a,o;i0="personal camera",ov="a218fcc3-276b-49b9-b485-49037fd14f5f",_mt=2500134,Kg=5526619,(t=aX||{}).x="x",t.y="y",t.z="z",aX=t,(l=>{function u(c,p){return Math.pow(p[0]-c[0],2)+Math.pow(p[1]-c[1],2)}function h(c,p){return Math.sqrt(u(c,p))}function d(c,p,m){let f=l.sub(p,c),g=l.sub(m,c),y=l.dot(f,g)/l.dot(f,f),v=l.scalarMultiply(f,y);return l.add(c,v)}l.isEqual=function(c,p){return c[0]===p[0]&&c[1]===p[1]},l.lerp=function(c,p,m){return[c[0]+(p[0]-c[0])*m,c[1]+(p[1]-c[1])*m]},l.add=function(c,p){return[c[0]+p[0],c[1]+p[1]]},l.sub=function(c,p){return[c[0]-p[0],c[1]-p[1]]},l.multiply=function(c,p){return[c[0]*p[0],c[1]*p[1]]},l.divide=function(c,p){return[c[0]/p[0],c[1]/p[1]]},l.distanceSquared=u,l.distance=h,l.dot=function(c,p){return c[0]*p[0]+c[1]*p[1]},l.scalarMultiply=function(c,p){return[c[0]*p,c[1]*p]},l.projectionOnto=d,l.projectionOntoDistance=function(c,p,m){return h(c,d(c,p,m))},l.center=function(c,p){return[.5*(c[0]+p[0]),.5*(c[1]+p[1])]}})(qu||(qu={})),(e=hm||(hm={})).isEqual=function(l,u){return l[0]===u[0]&&l[1]===u[1]&&l[2]===u[2]},e.add=function(l,u){return[l[0]+u[0],l[1]+u[1],l[2]+u[2]]},e.sub=function(l,u){return[l[0]-u[0],l[1]-u[1],l[2]-u[2]]},e.div=function(l,u){return[l[0]/u[0],l[1]/u[1],l[2]/u[2]]},e.mul=function(l,u){return[l[0]*u[0],l[1]*u[1],l[2]*u[2]]},e.dist=function(l,u){return Math.hypot(l[0]-u[0],l[1]-u[1],l[2]-u[2])},e.lerp=function(l,u,h){return[l[0]+(u[0]-l[0])*h,l[1]+(u[1]-l[1])*h,l[2]+(u[2]-l[2])*h]},(i=ES||(ES={})).isEqual=function(l,u){return l[0]===u[0]&&l[1]===u[1]&&l[2]===u[2]&&l[3]===u[3]},i.lerp=function(l,u,h){return[l[0]+(u[0]-l[0])*h,l[1]+(u[1]-l[1])*h,l[2]+(u[2]-l[2])*h,l[3]+(u[3]-l[3])*h]},(l=>{let u=180/Math.PI,h=Math.PI/180;function d(p){return typeof p=="number"?p*u:p}function c(p){return typeof p=="number"?p*h:p}l.radToDeg=function(p){return[d(p[0]),d(p[1]),d(p[2])]},l.degToRad=function(p){return[c(p[0]),c(p[1]),c(p[2])]}})(oX||(oX={})),(r=lv||(lv={})).identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],r.isEqual=function(l,u){for(let h=0;h<16;h++)if(l[h]!==u[h])return!1;return!0},r.simplify=function(l){return l??r.identity},r.applyMatrix4=function(l,u){let h=u.slice(0);for(let d=0,c=u.length;d<c;d+=3){let p=l[3]*u[d]+l[7]*u[d+1]+l[11]*u[d+2]+l[15];h[d]=(l[0]*u[d]+l[4]*u[d+1]+l[8]*u[d+2]+l[12])/p,h[d+1]=(l[1]*u[d]+l[5]*u[d+1]+l[9]*u[d+2]+l[13])/p,h[d+2]=(l[2]*u[d]+l[6]*u[d+1]+l[10]*u[d+2]+l[14])/p}return h},(s=nn||(nn={})).isRGB=function(l){return typeof l=="object"&&typeof l.r=="number"&&typeof l.g=="number"&&typeof l.b=="number"},s.white={r:1,g:1,b:1},s.red={r:1,g:0,b:0},s.black={r:0,g:0,b:0},s.toRgb255a1=function(l){return{r:Math.round(255*l.r),g:Math.round(255*l.g),b:Math.round(255*l.b),a:1}},s.clone=function(l){return{r:l.r,g:l.g,b:l.b}},s.fromHex=function(l){return{r:((l=Math.floor(l))>>16&255)/255,g:(l>>8&255)/255,b:(255&l)/255}},s.toHex=function(l){return 65536*Math.round(255*l.r)+256*Math.round(255*l.g)+Math.round(255*l.b)},s.equals=function(l,u){return l.r===u.r&&l.g===u.g&&l.b===u.b},s.equalsFixed=function(l,u){return l.r.toFixed(2)===u.r.toFixed(2)&&l.g.toFixed(2)===u.g.toFixed(2)&&l.b.toFixed(2)===u.b.toFixed(2)},s.lerp=function(l,u,h){return{r:l.r+(u.r-l.r)*h,g:l.g+(u.g-l.g)*h,b:l.b+(u.b-l.b)*h}},s.is=function(l){return!!sX(l)&&"r"in l&&"g"in l&&"b"in l&&!("a"in l)},(n=qi||(qi={})).white={...nn.white,a:1},n.is=function(l){return!!sX(l)&&"r"in l&&"g"in l&&"b"in l&&"a"in l},n.transparent={...nn.white,a:0},n.from0to1=function(l){return{r:l[0],g:l[1],b:l[2],a:l[3]}},n.fromHexAndA=function(l,u){return{...nn.fromHex(l),a:u}},n.toRgb255a1=function(l){return{r:Math.round(255*l.r),g:Math.round(255*l.g),b:Math.round(255*l.b),a:l.a}},n.equals=function(l,u){return nn.equals(l,u)&&l.a===u.a},n.equalsFixed=function(l,u){return nn.equalsFixed(l,u)&&l.a.toFixed(2)===u.a.toFixed(2)},n.lerp=function(l,u,h){return{r:l.r+(u.r-l.r)*h,g:l.g+(u.g-l.g)*h,b:l.b+(u.b-l.b)*h,a:l.a+(u.a-l.a)*h}},n.toStyle=function({r:l,g:u,b:h,a:d}=n.white){return`rgba(${255*l}, ${255*u}, ${255*h}, ${d})`},(tU||(tU={})).identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1],pivot:[0,0,0],pivotRotation:[0,0,0]},(a=lX||{})[a.LINEAR=0]="LINEAR",a[a.EASE=1]="EASE",a[a.EASE_IN=2]="EASE_IN",a[a.EASE_OUT=3]="EASE_OUT",a[a.EASE_IN_OUT=4]="EASE_IN_OUT",a[a.CUBIC=5]="CUBIC",a[a.SPRING=6]="SPRING",a[a.ARC=7]="ARC",a[a.NONE=8]="NONE",lX=a,(Jp||(Jp={})).defaultData={mass:1,stiffness:80,damping:10,velocity:0},(Nv||(Nv={})).defaultData={control1:[.5,0],control2:[.5,1]},(o=hX||(hX={})).linear=[0,0,1,1],o.ease=[.25,.1,.25,1],o.easeIn=[.42,0,1,1],o.easeOut=[0,0,.58,1],o.easeInOut=[.42,0,.58,1]}),_Mt=G(()=>{var t,e;Fi(),bmt(),(uX||(uX={})).defaultData={type:"SwitchCamera",name:"",targetCamera:"",delay:0,animate:!0,duration:1e3,easing:4,runMode:"Normal"},(dX||(dX={})).defaultData={type:"SceneTransition",name:"",target:"",delay:0,duration:1,transition:"none"},(cX||(cX={})).defaultData={type:"Link",name:"",url:null,context:"tab"},(pX||(pX={})).defaultData={type:"Destroy",name:"",objects:[],delay:0},(mX||(mX={})).defaultData={type:"Particles",name:"",emitterObjectId:"",delay:0,emission:"start",triggerAfter:"any"},(fX||(fX={})).defaultData={type:"Create",name:"",object:"",delay:0,creationSpeed:10,coordinateSystem:"world",dynamic:!0,destroy:"No",destroyAfterQuantity:5,lifetime:2,position:[0,0,0],rotation:[0,0,0],velocity:[1e3,0,0],hideBase:"No"},(gX||(gX={})).defaultData={type:"Reset",name:"",delay:0},($N||($N={})).defaultData={interaction:"play",delay:0,volume:.5,loop:1},(t=yX||(yX={})).pauseDefaultData={interaction:"pause",delay:0},t.stopDefaultData={interaction:"stop",delay:0},(e=vX||(vX={})).defaultData={type:"Audio",name:"",...$N.defaultData},e.hasAudioByActions=i=>i.some(({data:r})=>r.type==="Audio"&&r.interaction==="play"&&r.audio),e.hasAudioByEvents=i=>e.getAudiosByEvents(i).length>0,e.getAudiosByActions=i=>{let r=[];return i.forEach(s=>{let n=s.data;n.type==="Audio"&&n.interaction==="play"&&n.audio&&r.push(s),n.type==="Conditional"&&(r.push(...e.getAudiosByActions(n.ifActions)),r.push(...e.getAudiosByActions(n.elseActions)))}),r},e.getAudiosByEvents=i=>{let r=[];return i.forEach(({data:s})=>{j2.is(s)||s.type==="Collision"||s.type==="Start"||s.type==="Trigger"||s.type==="VariableChange"||s.type==="WEBHOOK"||s.type==="AIAssistantTrigger"?r.push(...e.getAudiosByActions(s.actions)):s.type==="Conditional"?(r.push(...e.getAudiosByActions(s.inActions)),r.push(...e.getAudiosByActions(s.outActions))):s.type==="GameControl"?Object.values(s.gameActions).forEach(n=>{r.push(...e.getAudiosByActions(n))}):s.type==="DragDrop"?(r.push(...e.getAudiosByActions(s.dragDropActions.drag)),r.push(...e.getAudiosByActions(s.dragDropActions.drop))):s.type==="Resize"?s.breakpoints.forEach(({data:n})=>{r.push(...e.getAudiosByActions(n.actions))}):s.type==="API"&&(r.push(...e.getAudiosByActions(s.successActions)),r.push(...e.getAudiosByActions(s.errorActions)))}),r},(XN||(XN={})).defaultData={interaction:"play",delay:0,volume:.5,loop:1/0},(i=>{i.pauseDefaultData={interaction:"pause",delay:0},i.stopDefaultData={interaction:"stop",delay:0}})(bX||(bX={})),(i=>{i.defaultData={type:"Video",name:"",triggerAfter:"autoplay",...XN.defaultData},i.hasVideoByActions=r=>r.some(({data:s})=>s.type==="Video"&&s.interaction==="play"&&s.layerId),i.hasVideoByObject=r=>{if(r.events){for(let{data:s}of r.events)if((j2.is(s)||s.type==="Start")&&i.hasVideoByActions(s.actions))return!0}},i.getVideosByActions=r=>{let s=[];return r.forEach(n=>{let a=n.data;a.type==="Video"&&a.interaction==="play"&&a.layerId&&s.push(n)}),s},i.getVideosByEvents=r=>{let s=[];return r.forEach(({data:n})=>{(j2.is(n)||n.type==="Start")&&s.push(...i.getVideosByActions(n.actions))}),s}})(_X||(_X={})),(xX||(xX={})).defaultData=function(i){return{state:i,repeat:0,delay:0,delayDirection:"start-once",direction:"normal",duration:1e3,easing:4}},(YN||(YN={})).defaultData=function(){return{tweens:new ge,repeat:0,delay:0,delayDirection:"start-once",direction:"normal"}},(wX||(wX={})).defaultData=function(i){return{type:"Transition",name:"",runMode:"Once",object:i??null,...YN.defaultData()}},(KN||(KN={})).defaultData=function(i){return{interaction:"play",timeline:i,repeat:0,delay:0,delayDirection:"start-once",direction:"normal",runMode:"Once"}},(i=>{i.pauseDefaultData={interaction:"pause",delay:0},i.stopDefaultData={interaction:"stop",delay:0}})(SX||(SX={})),(TX||(TX={})).defaultData=function(i){return{type:"TimelineAnimation",name:"",...KN.defaultData(i)}},(ZN||(ZN={})).defaultData=function(i,r,s){return{interaction:"play",object:i,clipId:r,crop:s,crop2:s,repeat:-1,delay:0,delayDirection:"start-once",direction:"normal",runMode:"Normal"}},(i=>{i.pauseDefaultData={interaction:"pause",delay:0},i.stopDefaultData={interaction:"stop",delay:0}})(MX||(MX={})),(i=>{i.defaultData=function(r,s,n){return{type:"Animation",name:"",...ZN.defaultData(r,s,n)}},i.isPause=function(r){return r.interaction==="pause"||r.interaction==="stop"}})(eU||(eU={})),(AX||(AX={})).defaultData={type:"SetVariable",name:"",variableId:"",expression:[]},(CX||(CX={})).defaultData=()=>({type:"Conditional",name:"",ifActions:new ge,elseActions:new ge,condition:[]}),(EX||(EX={})).defaultData={type:"DynamicVariablePlay",name:"",variableId:"",mode:"PlayPause",delay:0,pauseDelay:0},(PX||(PX={})).defaultData={type:"ClearLocalStorage",name:"",target:"all"},(RX||(RX={})).defaultData={name:"",type:"UserAPI"}}),xMt=G(()=>{var t;(t=DX||(DX={})).emptyAudio={data:Uint8Array.from(atob("UklGRjIAAABXQVZFZm10IBIAAAABAAEAQB8AAEAfAAABAAgAAABmYWN0BAAAAAAAAABkYXRhAAAAAA=="),e=>e.charCodeAt(0)),mimeType:"audio/wav",filename:"unknown"},t.maxSize=2e6}),wmt=G(()=>{var t;(t=Zg||(Zg={})).all=["PerspectiveCamera","OrthographicCamera"],t.is=function(e){return t.all.includes(e)},(e=>{e.DefaultUp=[0,1,0],e.DefaultTargetOffset=1e3,e.MinTargetOffset=.001,e.sanitizeTargetOffset=function(n){return n===void 0||!Number.isFinite(n)||n<e.MinTargetOffset?e.DefaultTargetOffset:n},e.DefaultAzimuth=-24,e.DefaultElevation=15;let i=e.DefaultAzimuth*Math.PI/180,r=e.DefaultElevation*Math.PI/180,s=180/Math.PI;e.DefaultPosition=[e.DefaultTargetOffset*Math.sin(i)*Math.cos(r),e.DefaultTargetOffset*Math.sin(r),e.DefaultTargetOffset*Math.cos(i)*Math.cos(r)],e.DefaultRotation=[Math.atan2(-Math.sin(r),Math.cos(i)*Math.cos(r))*s,Math.asin(Math.sin(i)*Math.cos(r))*s,Math.atan2(Math.sin(i)*Math.sin(r),Math.cos(i))*s],e.defaultData={far:1e5,type:"PerspectiveCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:e.DefaultUp,isUpVectorFlipped:!1,targetOffset:e.DefaultTargetOffset},e.getZoom=function(n){return n.type==="PerspectiveCamera"?n.perspective?.zoom??1:n.orthographic?.zoom??1}})(gc||(gc={}))}),Smt=G(()=>{var t;(t=tm||(tm={})).defaultData=function(e,i=.1){return{disabled:!1,type:"linear",hideBase:!1,instanced:!1,count:3,radial:{radius:2*Math.max(typeof e[0]=="number"?e[0]:1,typeof e[1]=="number"?e[1]:1),start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0],pivot:[0,0,0],pivotRotation:[0,0,0]},toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal",pivot:[0,0,0],pivotRotation:[0,0,0]},linear:{scale:[1,1,1],rotation:[0,0,0],position:[(typeof e[0]=="number"?e[0]+e[0]:1)*i,0,0],pivot:[0,0,0],pivotRotation:[0,0,0]},grid:{count:[2,2,2],size:e.map(r=>(typeof r=="number"?r:1)*(1+i)),useCenter:!0},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}}},t.merge=function(e,i){let r={...e};if(rU.forEach(s=>{Object.assign(r,{[s]:i[s]??e[s]})}),r.radial={...e.radial},i.radial){let s=e.radial,n=i.radial;eR.forEach(a=>{Object.assign(r.radial,{[a]:n[a]??s[a]})})}if(r.linear={...e.linear},i.linear){let s=e.linear,n=i.linear;iR.forEach(a=>{Object.assign(r.linear,{[a]:n[a]??s[a]})})}if(r.grid={...e.grid},i.grid){let s=e.grid,n=i.grid;rR.forEach(a=>{Object.assign(r.grid,{[a]:n[a]??s[a]})})}if(r.toObject={...e.toObject},i.toObject){let s=e.toObject,n=i.toObject;sR.forEach(a=>{Object.assign(r.toObject,{[a]:n[a]??s[a]})})}if(r.randomnessObject={...e.randomnessObject},i.randomnessObject){let s=e.randomnessObject,n=i.randomnessObject;nR.forEach(a=>{Object.assign(r.randomnessObject,{[a]:n[a]??s[a]})})}return r},t.isPartial=function(e){return!(!e.randomnessObject&&!e.toObject)},(e=>{e.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let i=["radial","linear","grid","toObject","randomnessObject"];e.toOps=function(r,s){let n=[];r.count!==void 0&&n.push({type:0,path:s,props:{count:r.count}});for(let a of i){let o=r[a];o&&Object.keys(o).length>0&&n.push({type:0,path:[...s,a],props:o})}return n}})(iU||(iU={})),rU=["count"],eR=["radius","start","end","position","scale","rotation"],iR=["position","scale","rotation"],rR=["count","size"],sR=["count","position","scale","rotation"],nR=["strength","scale","rotation","position","movement","seed","freqScale"]}),Tmt=G(()=>{var t;wl(),(t=sU||(sU={})).all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"],t.is=function(e){return t.all.includes(e)},(nU||(nU={})).defaultData=function(e){return function(i){if(i==="PointLight")return{type:i,color:qi.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(i==="SpotLight")return{type:i,color:qi.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};if(i==="DirectionalLight")return{type:i,color:qi.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}(e)}}),Mmt=G(()=>{var t;(t=aR||(aR={})).defaultShapeData={type:"PlaneEmitterShape",size:[100,100,100]},t.defaultCollisionData={colliderEntityId:null,collisionBounce:.75},t.defaultData={renderMaterial:{type:"particleMaterial",color:{r:1,g:.2,b:.545,a:1},color2:{r:.945,g:.714,b:.184,a:1},coloring:"gradient",ease:"linearFadeOut",easeSize:"linearFadeOut",transparent:!0,size:[40,40],texture:"pt_default_particle",spriteRotation:[0,0]},birthRatePerSec:50,gravity:1,noiseStrength:0,noiseScale:0,noiseSeed:1,noiseType:"curl",randomRotation:0,randomScale:.2,randomMass:.5,rootObjectType:"instancedMesh",life:1,direction:[0,0,0],directionMode:"axis",speed:10,shape:t.defaultShapeData,autoPlay:!0,emitTimeDelay:0,emitTimeCycle:"infinity",emitTimeDuration:1,...t.defaultCollisionData}}),Amt=G(()=>{var t;(t=aU||(aU={})).defaultData={gravity:10,damping:.03,localStiffness:.67,globalStiffness:.5,globalRange:.15,stiffnessFalloff:.1,windStrength:0,vspCoefficient:.01,elasticity:.15,hairLength:.75,tipSeparation:.8,kink:0,kinkFrequency:0,clumpStrength:0,clumpSize:32,clumpTipScale:1.5,spreadRadius:.03,guideStrands:8192,headShape:"sphere",baseObjectId:null,hairColorSource:"custom",hairShadeRoot:.6,hairShadeTip:1.15,hairRootColor:{r:.29,g:.102,b:.039,a:1},hairMidColor:{r:.8,g:.267,b:.133,a:1},hairTipColor:{r:.545,g:.18,b:.18,a:1},headColor:{r:.325,g:.137,b:.114,a:1},noiseEnabled:!1,noiseColorA:{r:.545,g:.184,b:.788,a:1},noiseColorB:{r:.914,g:.188,b:.914,a:1},noiseColorC:{r:.2,g:.4,b:1,a:1},noiseColorD:{r:.2,g:1,b:.6,a:1},noiseScale:1.8,noiseMixHair:.75,noiseMixHead:.8,castShadow:!0,receiveShadow:!0,hairWidth:1.75,specularPower:40,specularIntensity:.4,diffuseIntensity:.6,ambientIntensity:.25,opacity:1,tipFade:.4,autoPlay:!0},t.regenProps=["hairLength","spreadRadius","guideStrands","headShape","baseObjectId"]}),nG=G(()=>{(hv||(hv={})).defaultData={enabled:"visibility",fusedBody:!0,rigidBody:"positioned",density:1,pointMass:0,gravityScale:1,friction:.5,damping:0,restitution:.2,colliderType:"convex",enabledRotation:[!0,!0,!0],enabledTranslation:[!0,!0,!0]}}),Cmt=G(()=>{var t,e;(t=NX||{})[t.Front=0]="Front",t[t.Back=1]="Back",t[t.Double=2]="Double",NX=t,(e=QN||(QN={})).defaultData={castShadow:!0,receiveShadow:!0},e.equals=function(i,r){return i.castShadow===r.castShadow&&i.receiveShadow===r.receiveShadow},(i=>{i.defaultData={flatShading:!1,wireframe:!1,side:0},i.equals=function(r,s){return r.flatShading===s.flatShading&&r.side===s.side&&r.wireframe===s.wireframe&&(r.shadowCatcher??!1)===(s.shadowCatcher??!1)}})(JN||(JN={})),(oU||(oU={})).defaultData={...JN.defaultData,...QN.defaultData},(OX||(OX={})).getMaterialData=function(i,r){let s=[];if("material"in i){let n=typeof i.material=="string"?r.materials[i.material]??r.lib.materials[i.material]?.asset:i.material;n&&s.push(n)}else if("materials"in i)for(let n of i.materials){let a=typeof n=="string"?r.materials[n]??r.lib.materials[n]?.asset:n;a&&s.push(a)}return s}}),Emt=G(()=>{var t;(t=oR||(oR={})).defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},t.maxSize=3e7}),YS=G(()=>{var t,e,i,r;Fi(),wl(),Emt(),wl(),(IX||(IX={})).is=function(s){return s==="texture"||s==="video"||s==="color"||s==="depth"||s==="normal"||s==="gradient"||s==="noise"||s==="fresnel"||s==="cavity"||s==="dust"||s==="rainbow"||s==="toon"||s==="outline"||s==="particle"||s==="transmission"||s==="reflection"||s==="matcap"||s==="displace"||s==="pattern"||s==="vertexColor"||s==="light"},(BX||(BX={})).is=function(s){return s==="luminance"||s==="r"||s==="g"||s==="b"||s==="a"},(lU||(lU={})).is=function(s){return typeof s=="object"&&s!==null&&s.image!=null},(VX||(VX={})).is=function(s){return s==="phong"||s==="toon"||s==="lambert"||s==="physical"},(r=kX||{})[r.Linear=0]="Linear",r[r.Radial=1]="Radial",r[r.Polar=2]="Polar",kX=r,zX=(s=>(s[s.RepeatWrapping=1e3]="RepeatWrapping",s[s.ClampToEdgeWrapping=1001]="ClampToEdgeWrapping",s[s.MirroredRepeatWrapping=1002]="MirroredRepeatWrapping",s))(zX||{}),LX=(s=>(s[s.NearestFilter=1003]="NearestFilter",s[s.LinearFilter=1006]="LinearFilter",s[s.LinearMipmapLinearFilter=1008]="LinearMipmapLinearFilter",s))(LX||{}),(i=FX||{})[i.UV=0]="UV",i[i.Planar=1]="Planar",i[i.Spherical=2]="Spherical",i[i.Cylindrical=3]="Cylindrical",i[i.Triplanar=4]="Triplanar",FX=i,(e=UX||{})[e.Simplex=0]="Simplex",e[e.SimplexFractal=1]="SimplexFractal",e[e.Ashima=2]="Ashima",e[e.Fbm=3]="Fbm",e[e.Perlin=4]="Perlin",e[e.Voronoi=5]="Voronoi",UX=e,(t=jX||{})[t.F1=0]="F1",t[t.F2=1]="F2",t[t.F2MinusF1=2]="F2MinusF1",t[t.SmoothBlend=3]="SmoothBlend",t[t.Edge=4]="Edge",t[t.Power=5]="Power",t[t.Lines=6]="Lines",t[t.Cells=7]="Cells",jX=t,GX=(s=>(s[s.Lights=0]="Lights",s[s.Static=1]="Static",s[s.Camera=2]="Camera",s))(GX||{}),WX=(s=>(s[s.Circle=0]="Circle",s[s.Ring=1]="Ring",s[s.Polygon=2]="Polygon",s[s.Cross=3]="Cross",s[s.Diamond=4]="Diamond",s[s.Checkerboard=5]="Checkerboard",s[s.Line=6]="Line",s[s.Wave=7]="Wave",s))(WX||{}),A5=["mode","gradientType","noiseType","tracingMode","mirror","displacementType","projection","cnormal","crop","axis","side","roughnessMapChannel","metalnessMap","metalnessMapChannel","normalMap","aoMap","aoMapChannel","emissiveMap","style"],rG=["wrapping","image","video","name","minFilter","magFilter"],(s=>{s.patch=function(n,a){let{texture:o,...l}=a;if(Object.assign(n,l),o){let u=n.texture;u&&Object.assign(u,o)}},s.defaultColorLayer=function(n){return{...s.defaultData("color"),color:n}},s.defaultData=function(n,a){return n==="light"&&a?function(o){let l={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(o){case"phong":return{...l,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...l,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...l,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...l,category:"physical",roughness:.6,metalness:.2,reflectivity:.2,type:"light",alpha:.6,visible:!0,mode:0,occlusion:!0}}}(a):function(o){let l={alpha:1,mode:0,isMask:!1,visible:!0};switch(o){case"texture":return{...l,type:"texture",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{image:"image_0",wrapping:1e3,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006},crop:!1};case"video":return{...l,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:oR.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006},crop:!1};case"color":return{...l,type:"color",color:nn.fromHex(Kg)};case"vertexColor":return{...l,type:"vertexColor"};case"depth":return{...l,type:"depth",gradientType:1,smooth:!1,isVector:!0,isWorldSpace:!1,origin:[0,0,0],direction:[1,0,0],colors:[[1,1,1,1],[0,0,0,1]],steps:[0,1],near:50,far:200};case"normal":return{...l,type:"normal",cnormal:[1,1,1]};case"gradient":return{...l,type:"gradient",gradientType:0,smooth:!1,colors:[[0,0,0,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,1,1,1,1,1,1,1,1,1],num:2,angle:0,offset:[0,0],morph:[0,0]};case"noise":return{...l,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...nn.fromHex(6710886),a:1},colorB:{...nn.fromHex(6710886),a:1},colorC:{...nn.fromHex(16777215),a:1},colorD:{...nn.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8],voronoiStyle:0,highCut:1,lowCut:0,smoothness:.3,seed:0,quality:1};case"cavity":return{...l,type:"cavity",mode:3,ridge:1,valley:1};case"fresnel":return{...l,type:"fresnel",color:qi.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"dust":return{...l,type:"dust",color:qi.fromHexAndA(10323813,1),coverage:.2,softness:.2,noiseStrength:.2,noiseScale:1};case"rainbow":return{...l,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...l,type:"toon",positioning:2,colors:[[0,0,0,1],[.5,.5,.5,1],[.5,.5,.5,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,.475,.525,1,1,1,1,1,1,1],num:4,source:[0,1e3,0],isWorldSpace:!0,noiseStrength:0,noiseScale:1,shadowColor:qi.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...l,type:"outline",outlineColor:qi.fromHexAndA(0,1),contourColor:qi.fromHexAndA(0,1),outlineWidth:2,contourWidth:5,outlineThreshold:.4,contourThreshold:0,outlineSmoothing:0,contourFrequency:10,contourDirection:[0,1,0],positionalLines:!1,compensation:!0};case"matcap":return{...l,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006}};case"transmission":return{...l,type:"transmission",thickness:10,ior:1.5,roughness:1};case"reflection":return{...l,type:"reflection",blur:0,thickness:.001,steps:60,stepSize:.005,tracingMode:1,mirror:0};case"displace":return{visible:!0,type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,voronoiStyle:0,smoothness:.3,seed:0,highCut:1,lowCut:0,quality:1};case"pattern":return{...l,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...nn.fromHex(0),a:1},colorB:{...nn.fromHex(16777215),a:1},frequency:[10,10],size:.5,variation:0,smoothness:.5,zigzag:0,rotation:0,vertical:[0,1],horizontal:[0,1],sides:6}}}(n)}})(Ws||(Ws={})),(s=>{function n(a,o="layer1",l="layer2",u=nn.fromHex(16777215)){let h=new ge;return h.push({fi:0,data:Ws.defaultData("light",a),id:o}),h.push({fi:1,data:Ws.defaultData("color"),id:l}),{layers:h}}s.isMergable=function(a){return!a.layers.some(o=>o.data.type==="texture"&&o.data.projection!==0||o.data.type==="depth"&&!o.data.isWorldSpace||o.data.type==="noise"||o.data.type==="dust"&&o.data.noiseStrength!==0||o.data.type==="displace")},s.getHash=function(a){let o="";return a.layers.forEach(l=>{Object.entries(l.data).forEach(([u,h])=>{o+=`${u}${h}`,Array.isArray(h)?h.forEach(d=>o+=`${d}`):typeof h=="object"?Object.values(h).forEach(d=>{o+=typeof d=="number"?`${d.toFixed(4)}`:`${d}`}):o+=`${h}`})}),o},s.defaultEmptyData=function(){return{layers:new ge}},s.defaultData=function(a="layer1",o="layer2"){return n("physical",a,o)},s.withName=function(a,o){return{...a,name:o}},s.defaultTwoLayerData=n,s.defaultColorMaterial=function(a,o,l="layer1",u="layer2"){let h=new ge;return h.push({fi:0,data:Ws.defaultData("light",o),id:l}),h.push({fi:1,data:Ws.defaultColorLayer(a),id:u}),{layers:h}},s.defaultUIObjectMaterial=function(a){let o=Ws.defaultData("texture");a&&Object.assign(o.texture,{image:a});let l=new ge;return l.push({fi:0,data:o,id:"layer1"}),l.push({fi:1,data:{...Ws.defaultData("transmission"),alpha:1},id:"layer2"}),l.push({fi:2,data:{...Ws.defaultData("light","lambert"),alpha:0},id:"layer3"}),{layers:l}},s.defaultTwoLayerTextureData=function(a,o="physical",l="layer1",u="layer2"){let h=Ws.defaultData("texture");Object.assign(h.texture,{image:a});let d=new ge;return d.push({fi:0,data:h,id:l}),d.push({fi:1,data:Ws.defaultData("light",o),id:u}),{layers:d}},s.defaultTwoLayerVideoTextureData=function(a,o="physical",l="layer1",u="layer2"){let h=Ws.defaultData("video");Object.assign(h.texture,{video:a});let d=new ge;return d.push({fi:0,data:h,id:l}),d.push({fi:1,data:Ws.defaultData("light",o),id:u}),{layers:d}}})(cs||(cs={}))}),wMt=G(()=>{S1="Roboto_regular",xmt="https://fonts.gstatic.com/s/roboto/v30/KFOmCnqEu92Fr1Me5WZLCzYlKw.ttf"}),Pmt=G(()=>{Fi(),(PS||(PS={})).defaultData=function(){return{points:new ge,roundness:0,shapeHoles:[],isClosed:!1}}}),Rmt=G(()=>{Fi(),(lR||(lR={})).defaultData=function(){return{points:new ge,lastInsertionPlane:null,subdivisions:12,isClosed:!1,subdivisionMode:"parametric"}},cg={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0},(hU||(hU={})).merge=function(t,e){let i={...t};return hR.forEach(r=>{Object.assign(i,{[r]:e[r]??t[r]})}),i},sG={shape:cg,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},hR=["depth","offset","angle","twist","startScale","endScale"]}),aG=G(()=>{var t,e;Pmt(),Rmt(),(t=uR||(uR={})).is2DParametricMesh=function(i){return i==="PolygonGeometry"||i==="RectangleGeometry"||i==="StarGeometry"||i==="TriangleGeometry"||i==="EllipseGeometry"||i==="UIGeometry"},t.isParametricMesh=function(i){return i==="PolygonGeometry"||i==="RectangleGeometry"||i==="StarGeometry"||i==="TriangleGeometry"||i==="EllipseGeometry"||i==="PathGeometry"||i==="VectorGeometry"||i==="ConeGeometry"||i==="CubeGeometry"||i==="CylinderGeometry"||i==="DodecahedronGeometry"||i==="HelixGeometry"||i==="IcosahedronGeometry"||i==="LatheGeometry"||i==="PyramidGeometry"||i==="SphereGeometry"||i==="PlaneGeometry"||i==="BackdropGeometry"||i==="TorusGeometry"||i==="TorusKnotGeometry"||i==="BooleanGeometry"||i==="TextGeometry"||i==="InputGeometry"||i==="DecalGeometry"},t.isSwappableGeometry=function(i){return i==="PolygonGeometry"||i==="RectangleGeometry"||i==="StarGeometry"||i==="TriangleGeometry"||i==="EllipseGeometry"||i==="PathGeometry"||i==="VectorGeometry"||i==="ConeGeometry"||i==="CubeGeometry"||i==="CylinderGeometry"||i==="DodecahedronGeometry"||i==="HelixGeometry"||i==="IcosahedronGeometry"||i==="LatheGeometry"||i==="PyramidGeometry"||i==="SphereGeometry"||i==="PlaneGeometry"||i==="BackdropGeometry"||i==="TorusGeometry"||i==="TorusKnotGeometry"||i==="TextGeometry"||i==="SubdivGeometry"||i==="NonParametricGeometry"},(uU||(uU={})).merge=function(i,r){let s={...i};return Object.assign(s,r),s.type==="PathGeometry"&&"extrusion"in r&&r.extrusion&&(s.extrusion={...i.extrusion},Object.assign(s.extrusion,hU.merge(s.extrusion,r.extrusion))),s},(e=lc||(lc={})).defaultData=function(i){if(i==="RectangleGeometry")return{width:320,height:320,type:i,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="UIGeometry")return{type:i,frame:"",cornerRadius:[0,0,0,0],cornerType:0,width:1,height:1};if(i==="PathGeometry")return{type:i,width:1,height:1,depth:1,path:lR.defaultData(),extrusion:sG};if(i==="VectorGeometry")return{width:1,height:1,type:i,subdivisions:12,shape:PS.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="BooleanGeometry")return{type:i,operation:2,width:0,height:0,depth:0,phongAngle:35};if(i==="ShapeBlendGeometry")return{type:i,width:0,height:0,depth:0,resolutionLevel:6,blendRange:100,useChildrenColors:!1};if(i==="DecalGeometry")return{type:i,width:200,height:200,depth:200,offset:1,projection:"all",projectionTargets:[]};if(i==="TextGeometry")return{type:i,width:100,height:100,depth:0,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.2,letterSpacing:0,text:{textValue:""},textTransform:1,font:"Roboto_regular",editable:!1,extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="InputGeometry")return{...e.defaultData("TextGeometry"),type:i,editable:!0};if(i==="SphereGeometry")return{type:"SphereGeometry",width:100,height:100,depth:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180};throw new Error("not implemented")},EP=["width","height","depth"]}),Dmt=G(()=>{wl(),(t=>{function e(i){return i.mode??"linear"}t.defaultData={enabled:!1,useBackgroundColor:!1,color:nn.white,near:.1,far:2e3,mode:"linear",density:.005,heightFalloff:.01,heightBase:0},t.getMode=e,t.getModeIndex=function(i){let r=e(i);return r==="height"?1:r==="both"?2:0},t.getDensity=function(i){return i.density??t.defaultData.density},t.getHeightFalloff=function(i){return i.heightFalloff??t.defaultData.heightFalloff},t.getHeightBase=function(i){return i.heightBase??t.defaultData.heightBase}})(ia||(ia={}))}),oG=G(()=>{(tO||(tO={})).defaultData={image:null,rotation:0,blur:32,showBackground:!0},($p||($p={})).defaultData={enabled:!1,mode:"hdri",hdri:tO.defaultData,timeOfDay:10,weather:"partlyCloudy",lighting:!0,lightingIntensity:1,lightingQuality:"full",clouds:!0,windSpeed:2,animateWind:!0,exposure:1,seed:2}});function SMt(t){let e=typeof t=="string"?Number.parseInt(t,10):t;return typeof e=="number"&&Number.isFinite(e)?Math.min(5,Math.max(0,Math.round(e))):3}var dR,uv,eO,iO,rO,dv,sO,dU,cU,qX,B0,Nmt,sn,cR,HX,$X,XX,YX,Bu,G2,pR,mR,yc,zg,KX,em,fR,vc,nO,aO,bg,Qg,_g,W2,pU,ZX,Na,oO,QX,JX,hc,Zl,cv,mU,Omt=G(()=>{(()=>{let t={opacity:1,blendFunction:13,enabled:!1};(dR||(dR={})).defaultData={enabled:!1,pixelation:{...t,blendFunction:16,granularity:15},bloom:{...t,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...t,offset:[2,2]},vignette:{...t,darkness:1,offset:0},hueSaturation:{...t,hue:3,saturation:0},brightnessContrast:{...t,brightness:.25,contrast:0},depthOfField:{...t,focusDistance:100,focalLength:20,bokehScale:5},noise:{...t,blendFunction:16}}})()}),lG=G(()=>{var t;Dmt(),oG(),Omt(),wl(),(t=uv||(uv={})).defaultData={type:"normal",softShadowQuality:"low"},t.isSoft=function(e){return e!=null&&(e.type===void 0||e.type==="soft")},(eO||(eO={})).defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75},(iO||(iO={})).defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}},(e=>{e.defaultData={pipeline:"classic",toneMapping:"aces",exposure:1},e.isUntouched=function(i){return i===void 0||i.pipeline==="classic"&&(i.toneMapping==="none"||i.toneMapping==="aces")&&i.exposure===1}})(rO||(rO={})),(dv||(dv={})).defaultData={usePhysics:!1,gravity:-10},(sO||(sO={})).defaultData={playCamera:i0,gameControlObject:null},(dU||(dU={})).defaultData={backgroundColor:qi.fromHexAndA(_mt,1),postprocessing:dR.defaultData,fog:ia.defaultData,sky:$p.defaultData,globalPhysics:dv.defaultData,ambient:eO.defaultData,ao:iO.defaultData,shadow:uv.defaultData,publish:sO.defaultData,grading:rO.defaultData}}),TMt=G(()=>{(cU||(cU={})).defaultData={colliderType:"box",size:[100,100,100],colliderHelperVisible:!0,forceType:"collider",forceRange:"global",forceIntensity:.5,forceDambing:.95}}),C5=G(()=>{var t,e,i;Fi(),wmt(),Tmt(),Mmt(),Amt(),nG(),Cmt(),wl(),YS(),aG(),Smt(),hn(),lG(),TMt(),(t=qX||(qX={})).isComponentRelated=function(r){return r==="Component"||r==="Instance"},t.isEmptyOrComponent=function(r){return r==="Empty"||r==="Instance"},(e=B0||(B0={})).identity={...tU.identity,hiddenMatrix:lv.identity},e.fromObject=function(r){return{position:r.position,rotation:r.rotation,scale:r.scale,pivot:r.pivot,pivotRotation:r.pivotRotation,hiddenMatrix:r.hiddenMatrix}},e.merge=function(r,s){return{position:s?.position||r.position,rotation:s?.rotation||r.rotation,pivot:s?.pivot||r.pivot,pivotRotation:s?.pivotRotation||r.pivotRotation,scale:s?.scale||r.scale,hiddenMatrix:s?.hiddenMatrix||r.hiddenMatrix}},e.diff=function(r,s){return Jpt({position:hm.isEqual(r.position,s.position)?void 0:s.position,rotation:hm.isEqual(r.rotation,s.rotation)?void 0:s.rotation,scale:hm.isEqual(r.scale,s.scale)?null:s.scale,hiddenMatrix:lv.isEqual(r.hiddenMatrix,s.hiddenMatrix)?void 0:s.hiddenMatrix})},Nmt=["slide","offset"],(sn||(sn={})).defaultData={states:new ge,events:new ge,visible:!0,raycastLock:!1,physics:hv.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...B0.identity,cloner:null},(cR||(cR={})).defaultData={type:"Empty",...sn.defaultData},(HX||(HX={})).defaultData={type:"ParticleCollider",...cU.defaultData,...sn.defaultData},($X||($X={})).defaultData={type:"Component",...sn.defaultData},(XX||(XX={})).defaultData={type:"Particle",...sn.defaultData,...aR.defaultData},(YX||(YX={})).defaultData={type:"Hair",...sn.defaultData,...aU.defaultData},(Bu||(Bu={})).defaultData={type:"Mesh",...sn.defaultData,...oU.defaultData},(G2||(G2={})).defaultData={...sn.defaultData,...B0.identity,position:gc.DefaultPosition,rotation:gc.DefaultRotation,...gc.defaultData},(r=>{r.defaultData=function(s){return{...sn.defaultData,...nU.defaultData(s)}},r.defaultDirectionalLightData={...r.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(pR||(pR={})),(r=>{function s(n,a,o=0){for(;o<a.length;){let l=n?n[a[o]]:void 0;if(a.length===o+1)return l;if(!l)return;n=l.descendants,o+=1}}r.resolveWithDes=s,r.resolve=function(n,a,o=0){let l=s(n,a,o);if(l){let u=Object.keys(l);if(u.length===1&&u[0]==="descendants")return}return l}})(mR||(mR={})),(r=>{function s(n,a){return{...sn.defaultData,...a,component:n,overrides:new Xs,physics:void 0,events:void 0,type:"Instance"}}r.rootOverrideProps=["physics","events"],r.compositeNonOptionalOverrideProps=["geometry"],r.compositeEntireOverrideOverrideProps=["material"],r.ofComponent=s,r.fromComponentData=function(n){let a=B0.fromObject(n.data);return s(n.id,a)}})(yc||(yc={})),(r=>{r.defaultData={type:"Page",...sn.defaultData,physics:{...hv.defaultData,fusedBody:!1},...dU.defaultData,camera:G2.defaultData,timelines:new Be},r.isUIPage=function(s){return s.uiScene!==void 0}})(zg||(zg={})),(i=KX||(KX={})).defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],pivot:[0,0,0],pivotRotation:[0,0,0],hiddenMatrix:lv.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:hv.defaultData,states:new ge,events:new ge,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...gc.defaultData},i.KeysByResetCategory={States:["states"],Events:["events"],Material:["material","materials"],Geometry:["geometry"],Position:["position"],Rotation:["rotation"],Scale:["scale"],Transform:["position","scale","rotation","hiddenMatrix"],Name:["name"],Visibility:["visible","raycastLock","flatShading","wireframe","side","shadowCatcher"],Shadows:["castShadow","receiveShadow"],Cloner:["cloner"],Physics:["physics"]},i.defaultMeshObject={name:"Rectangle",...sn.defaultData,...Bu.defaultData,geometry:lc.defaultData("RectangleGeometry"),material:cs.defaultTwoLayerData("physical","layer1","layer2")},i.defaultBooleanObject={name:"Boolean",...sn.defaultData,...Bu.defaultData,geometry:lc.defaultData("BooleanGeometry"),material:cs.defaultTwoLayerData("physical","layer1","layer2")},i.defaultShapeBlendObject={name:"Shape Blend",...sn.defaultData,...Bu.defaultData,geometry:lc.defaultData("ShapeBlendGeometry"),material:cs.defaultTwoLayerData("physical","layer1","layer2")},i.defaultTextObject={name:"Text",...sn.defaultData,...Bu.defaultData,geometry:lc.defaultData("TextGeometry"),material:cs.defaultTwoLayerData("physical","layer1","layer2")},i.defaultInputObject={name:"Input",...sn.defaultData,...Bu.defaultData,geometry:lc.defaultData("InputGeometry"),material:cs.defaultTwoLayerData("physical","layer1","layer2")},(r=>{r.newEmpty=function(s,n){let a={name:n};return s.type==="Mesh"?(a.geometry={},"material"in s&&(a.material={layers:new Xs}),"materials"in s&&(a.materials=s.materials.map(o=>({layers:new Xs})))):Zg.is(s.type)&&(a.perspective={},a.orthographic={}),a},r.toOps=function(s,n){let a,o=[],l={orthographic:0,perspective:0,geometry:0};function u(h,d){for(let[c,p]of Object.entries(d.layers)){let{texture:m,...f}=p;if(m!==void 0&&Object.keys(m).length>0){let g={path:[...h,"layers",c,"texture"],props:m,type:0};o.push(g)}if(Object.keys(f).length>0){let g={path:[...h,"layers",c],props:f,type:0};o.push(g)}}}for(let[h,d]of Object.entries(n)){let c=d;if(h!=="name")if(h==="cloner")o.push(...iU.toOps(c,["cloner"]));else if(h==="pathSnapping")o.push({path:[h],props:{slide:c.slide,offset:c.offset},type:0});else if(h==="material")u(["material"],c);else if(h==="materials")for(let[p,m]of Object.entries(c))u(["materials",p],m);else if(l[h]===0){if(h==="geometry"&&c.extrusion!==void 0){let p={path:[h,"extrusion"],props:c.extrusion,type:0};o.push(p),c={...c},delete c.extrusion}if(Object.keys(c).length>0){let p={path:[h],props:c,type:0};o.push(p)}}else a===void 0&&(a={path:[],props:{},type:0},o.push(a)),a.props[h]=c}return o},r.patch=function(s,n){if(n===void 0)return s;let a={...s};if(Object.assign(a,B0.merge(a,n)),Object.assign(a,{pathSnapping:Object.assign({},a.pathSnapping,{slide:n.pathSnapping?.slide??a.pathSnapping?.slide??0,offset:n.pathSnapping?.offset??a.pathSnapping?.offset??0})}),Zg.is(s.type)){a.orthographic={...a.orthographic},a.perspective={...a.perspective};let o=n;o.orthographic?.zoom!==void 0&&(a.orthographic.zoom=o.orthographic.zoom),o.perspective?.zoom!==void 0&&(a.perspective.zoom=o.perspective.zoom),o.isUpVectorFlipped!==void 0&&(a.isUpVectorFlipped=o.isUpVectorFlipped),o.targetOffset!==void 0&&(a.targetOffset=o.targetOffset)}else if(s.type==="Mesh")"geometry"in n&&Object.assign(a,{geometry:uU.merge(a.geometry,n.geometry)}),(n.material||n.materials)&&(a=function(o,l){if(l===void 0)return o;let u={...o};return"material"in u&&"material"in l&&l.material&&(u.material=Z4(u.material,h=>{if(typeof h!="string")for(let[d,c]of Object.entries(l.material.layers)){let p=h.layers.data(d);p&&Ws.patch(p,c)}}).data),u.materials&&l.materials&&(u.materials=Z4(u.materials,h=>{for(let d=0;d<u.materials.length;d++){let c=l.materials[d];if(typeof c!="string")for(let[p,m]of Object.entries(c.layers)){let f=h[d]?.layers?.data(p);f&&Ws.patch(f,m)}}}).data),u}(a,n)),a.cloner&&"cloner"in n&&Object.assign(a,{cloner:tm.merge(a.cloner,n.cloner)});else if(s.type==="Empty")a.cloner&&"cloner"in n&&Object.assign(a,{cloner:tm.merge(a.cloner,n.cloner)});else if(sU.is(s.type)){let o=n;o.intensity!==void 0&&(a.intensity=o.intensity),o.color!==void 0&&(typeof o.color=="string"?a.color=o.color:a.color=nn.clone(o.color))}return a}})(em||(em={}))}),hG=G(()=>{(fR||(fR={})).defaultData={enablePan:!0,enableZoom:!0,enableRotate:!0,enableDamping:!0,rotationLimitsMode:0,rotationVerticalOffset:{min:Math.PI/4,max:Math.PI/4},rotationHorizontalOffset:{min:Math.PI/4,max:Math.PI/4},rotationSoftLimit:2,rotationSpeed:1,panLimitsMode:0,panVerticalOffset:{min:250,max:250},panHorizontalOffset:{min:250,max:250},panSoftLimit:2,zoomLimitsEnabled:!1,zoomLimits:{min:.1,max:2},autoRotate:!1,autoRotateSpeed:2,autoRotateClockwise:!0,hoverRotatePanMode:0,hoverRotatePanStrength:20,hoverRotateDamping:.125,isTouchZoom:!0,orbitTouches:2,panTouches:3,resetHoverEffectOnPointerLeave:!0}}),E5=G(()=>{hG(),wl(),(vc||(vc={})).defaultData={orbitControls:fR.defaultData,playPage:ov,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((t,e)=>{let i=0,r=0;return e<5?r=-30:e<10&&(r=30),e===0||e===10||e===5?i=30:(e===4||e===11||e===9)&&(i=-30),[120,[i,r],"show"]}),settings:{image:{format:"jpg",ratio:1,colorSpace:"display-p3"},videoStatic:{fps:60,mbps:150,ratio:1,duration:1e3,format:"mp4",imageFormat:"jpg",activeTimeline:null,colorSpace:"display-p3"},web:{logo:!0,compress:!0,preset:1,preload:!0,hint:!1,imageQuality:70,pixelRatioMobile:0,pixelRatioDesktop:0}},stopRaycast:!0,hdTransmission:!1,renderer:"webgpu",asyncShaderCompilation:!0}}),Imt=G(()=>{var t;(nO||(nO={})).defaultData={id:"basic",label:"Basic",style:"None",prompt:""},(aO||(aO={})).defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0},(t=bg||(bg={})).defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...nO.defaultData},isRandomSeed:!0,seed:t.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:aO.defaultData}),t.generateSeed=()=>Math.round(1e5*Math.random())}),uG=G(()=>{C5(),Fi(),E5(),wl(),hn(),Imt(),(t=>{function e(i,r){let s=i.scene.objects.get(r);if(s&&s.data.type==="Component")return s;{let n=i.shared.lib.components[r];if(n)return{...n.asset,id:r}}}t.physicsEnabled=function(i){return i.find(r=>r.data.type==="Page"&&r.data.globalPhysics.usePhysics)!==void 0},t.findTimeline=function(i,r){let s=i.find(n=>n.data.type==="Page"&&n.data.timelines?.[r]!==void 0);return s&&s.data.timelines?.[r]},t.getComponentData=e,t.traverseModuleInstances=function(i,r,s){i.scene.objects.traverseFrom(r,(n,a)=>{if(a.type==="Instance"){let o=e(i,a.component)?.data;o&&s(n,a,o.events)}else s(n,a,a.events)})}})(Qg||(Qg={})),(t=>{function e(r=!0,s=[]){let n=[];r&&n.push({...t.defaultLight}),n.push(...s);let a=new In;return a.push({fi:1,id:ov,data:{...zg.defaultData,name:"Scene 1"},children:n}),a}function i(r){return{...t.defaultData,objects:$a(r,In.prototype)}}t.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222",t.defaultLight={fi:-1,data:pR.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]},t.createDefaultObjectTreeWithPage=e,t.defaultData={objects:e(),publish:vc.defaultData,styles:bg.defaultData()},t.emptyDataWithoutPage=function(){return{objects:new In,publish:vc.defaultData,styles:bg.defaultData()}},t.emptyDataWithPage=function(r=!0){return{objects:e(r),publish:vc.defaultData,styles:bg.defaultData()}},t.emptyData=function(){return{objects:new In,publish:{...vc.defaultData},styles:bg.defaultData()}},t.withObjs=i,t.withObj=function(r,s){return i([{id:r,data:s,children:[],fi:0}])}})(_g||(_g={}))}),Bmt=G(()=>{(W2||(W2={})).defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}}}),dG=G(()=>{var t,e;Fi(),hn(),(t=pU||(pU={})).defaultData=i=>({url:i,name:"New Webhook",parametersSchemas:new ge}),t.defaultParameterValueByType=i=>i==="number"?0:i!=="boolean"&&"",(ZX||(ZX={})).defaultData=(i,r="GET")=>({url:i,method:r,name:"New API",headers:new ge,queries:new ge,autoStart:!0}),(i=>{function r(n){return n.textValue!==void 0}function s(n){return typeof n=="boolean"}i.isTextValue=r,i.isNumber=function(n){return typeof n=="number"},i.isBoolean=s,i.typeOfVariable=function(n){return r(n)?"string":s(n)?"boolean":"number"},i.getDisplayedValue=function(n){return i.isTextValue(n)?Array.isArray(n.textValue)?n.textValue.map(a=>a.toString().padStart(n.padding??2,"0")).join(n.deliminator??":")+(n.suffix!==void 0?" "+n.suffix:""):n.textValue.toString():i.isBoolean(n)?n?"True":"False":i.isNumber(n)?parseFloat(n.toFixed(3)).toString():n.toString()}})(Na||(Na={})),(oO||(oO={})).all=["images","videos","colors","audios","particles","fonts","materials","variables"],(QX||(QX={})).all=[...oO.all,"components"],(JX||(JX={})).defaultData=function(){return{images:new Be,videos:new Be,colors:new Be,audios:new Be,particles:new Be,fonts:new Be,materials:new Be,components:new Be,variables:new Be,userAPIs:new Be,userWebhooks:new Be}},(hc||(hc={})).defaultData=function(){return{images:new Be,videos:new Be,colors:new Be,audios:new Be,particles:new Be,fonts:new Be,materials:new Be,components:new Be,variables:new Be,userAPIs:new Be,userWebhooks:new Be}},(e=Zl||(Zl={})).defaultColors=function(){return $a({"89b10010-844c-11ec-a8a3-0242ac120002":{r:.5,g:.5,b:.5,a:1,name:"Default Color"}},Be.prototype)},e.defaultImages=function(){return $a({},Be.prototype)},e.emptyData=function(){return{catelogs:new Be,materials:new Be,images:new Be,videos:new Be,colors:new Be,audios:new Be,particles:new Be,fonts:new Be,variables:new ge,userAPIs:new Be,userWebhooks:new Be,lib:hc.defaultData()}},e.defaultVariables=function(i){switch(i){case"number":return{value:0,name:"Number"};case"boolean":return{value:!1,name:"Boolean"};case"string":return{value:{textValue:"String value"},name:"String"};case"time":{let r=[0,0,0];return{name:"Time",value:{textValue:r,deliminator:":",padding:2,suffix:"AM"},dynamicVariableType:"time",format:"HH:mm:ss",format12h24h:"12ampm",timeZone:null,hasEnd:!1,endValue:{textValue:r,deliminator:":",padding:2,suffix:"AM"},autoStart:!0,repeat:!1}}case"counter":return{name:"Counter",value:0,dynamicVariableType:"counter",updateInterval:1e3,increment:1,autoStart:!0,hasEnd:!0,endValue:60,repeat:!0,randomStart:!1,range:[0,100],decimals:0};case"random":return{name:"Random",value:0,dynamicVariableType:"random",updateInterval:1e3,increment:1,autoStart:!0,isStatic:!1,hasEnd:!0,endValue:60,repeat:!0,min:0,max:100,decimals:0};default:console.error("Unknown variable type",i)}},e.getFormattedTimerTime=function(i,r){if(r.format==="HH:mm:ss"){let s=Math.floor(i/3600),n=Math.floor((i-3600*s)/60);return{textValue:[s,n,Math.round(i-3600*s-60*n)]}}if(r.format==="mm:ss"){let s=Math.floor(i/60);return{textValue:[s,Math.round(i-60*s)]}}return r.format==="number"?Math.round(i):Math.round(1e3*i)/1e3}}),MMt=G(()=>{}),Vmt=G(()=>{var t;Fi(),uG(),Bmt(),dG(),(t=cv||(cv={})).defaultData={schema:131,scene:_g.defaultData,frames:new Be().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",W2.defaultData),shared:{...Zl.emptyData(),colors:Zl.defaultColors()}},t.createDefaultData=function(){return CS.deserialize(CS.serialize(t.defaultData))},t.emptyDataForImports=function(){return{schema:131,scene:_g.emptyDataWithPage(),frames:new Be().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",W2.defaultData),shared:{...Zl.emptyData(),colors:Zl.defaultColors(),images:Zl.defaultImages()}}},t.emptyData=function(){return{schema:131,scene:_g.emptyDataWithPage(),frames:new Be().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",W2.defaultData),shared:Zl.emptyData()}},t.clipboard2dData=function(){return{schema:131,scene:_g.emptyData(),frames:new Be,shared:Zl.emptyData()}},t.withoutLib=function(e){return{...e,shared:{...e.shared,lib:hc.defaultData()}}},t.getComponentData=function(e,i){return Qg.getComponentData(e,i)},t.hasSensitiveData=function(e){let i=Object.values(e.shared.userAPIs);for(let r of i){let s=r.headers;for(let n of s)if(n.data.key.toLowerCase()==="authorization"&&n.data.value!=="")return!0}return!1}}),AMt=G(()=>{(mU||(mU={})).emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"}});function Lg(t,e=[0,0]){return[t&&!isNaN(t[0])?t[0]:e[0],t&&!isNaN(t[1])?t[1]:e[1]]}function r_(t,e,i){switch(t){case 0:return"cubicBezier( 0, 0, 1, 1 )";case 1:return"cubicBezier( .25, .1, .25, 1 )";case 2:return"cubicBezier( .42, 0, 1, 1 )";case 3:return"cubicBezier( 0, 0, .58, 1 )";case 4:return"cubicBezier( .42, 0, .58, 1 )";case 7:return"cubicBezier( .25, 1, .5, 1 )";case 5:{let{control1:r,control2:s}=e??{...Nv.defaultData};return`cubicBezier( ${r[0]}, ${r[1]}, ${s[0]}, ${s[1]} )`}case 6:{let{mass:r,stiffness:s,damping:n,velocity:a}=i??{...Jp.defaultData},o=new kmt(r,s,n,a),l=o.solve(1);return()=>u=>o.solve(u)/l}case 8:return()=>r=>Math.floor(r)}}var tY,eY,Fg,RS,kmt,gR,yR,zmt=G(()=>{Fi(),wl(),(tY||(tY={})).defaultData=function(t,e){return{id:t,name:e,duration:5,objectTimelines:new Be}},(eY||(eY={})).is=function(t){return t&&typeof t.x=="number"&&typeof t.y=="number"&&typeof t.z=="number"},(t=>{function e(h,d){let c=[0,0],p=[1,1];if(h?.cubicControls)c=Lg(h.cubicControls.control1,c);else switch(h?.type){case 2:case 4:c=[.42,0];break;case 3:case 0:c=[0,0];break;case 1:c=[.25,.1];break;case 7:c=[.25,1]}if(d?.cubicControls)p=Lg(d.cubicControls.control2,p);else switch(d?.type){case 2:case 0:p=[1,1];break;case 3:case 4:p=[.58,1];break;case 1:p=[.25,1];break;case 7:p=[.5,1]}return{control1:c,control2:p}}function i(h){if(!t.BEZIER_PRESETS.includes(h))return;let d={type:h};return{control1:e(d).control1,control2:e(void 0,d).control2}}function r(h,d){return Math.abs(h[0]-d[0])<.001&&Math.abs(h[1]-d[1])<.001}function s(h){let d=t.ROOT_PROPERTY_ORDER.indexOf(h[0]);return d===-1?t.ROOT_PROPERTY_ORDER.length:d}function n(h){return h.layerId??h.path.join(".")}function a(h){let d=h[h.length-1];return RS.includes(d)?d:void 0}function o(h){return h.layerId?h.layerId:(a(h.path)?h.path.slice(0,-1):h.path).join(".")}function l(h){return["material",h.type==="light"?`${h.category} lighting`:h.type]}function u(h,d,c){return{id:h,data:{id:h,time:c?.time??0,path:d,value:{},layerId:c?.layerId,index:c?.index,isPlaceholder:!0,easing:{type:5,cubicControls:{control1:[.42,0],control2:[.58,1]}}}}}t.getControlsWithDefault=e,t.BEZIER_PRESETS=[0,1,2,3,4,7],t.presetHandles=i,t.presetForHandles=function(h){return t.BEZIER_PRESETS.find(d=>{let c=i(d);return c!==void 0&&r(c.control1,h.control1)&&r(c.control2,h.control2)})},t.defaultData=function(h){return{id:h,keyframes:new ge}},t.ROOT_PROPERTY_ORDER=["position","rotation","scale","shape size","material","opacity","camera","light","cloner","path extrusion","path snapping"],t.rowOrder=s,t.propertyKey=n,t.groupKeyframes=function(h,d){let c=new Map;for(let p of h){let m=p.data;if(d?.(m))continue;let f=n(m),g=c.get(f);g||(g={id:f,path:m.path,keyframes:[],layerId:m.layerId,index:m.index},c.set(f,g)),m.isPlaceholder?g.placeholder=p.id:g.keyframes.push(p)}return[...c.values()].sort((p,m)=>{let f=s(p.path)-s(m.path);return f!==0?f:(p.index??0)-(m.index??0)})},t.rowAxis=a,t.drawnRowKey=o,t.drawnRows=function(h){let d=new Map;for(let c of h){let p=a(c.path),m=p?c.path.slice(0,-1):c.path,f=o(c),g=d.get(f);g||(g={id:f,path:m,layerId:c.layerId,index:c.index,tracks:[]},d.set(f,g)),g.tracks.push({axis:p,property:c})}return[...d.values()]},t.sortedKeyframes=function(h){return[...h].sort((d,c)=>d.data.time-c.data.time)},t.materialLayerPath=l,t.createMaterialGroup=function(h,d){return h.map(({data:c,id:p},m)=>u(d(),l(c),{layerId:p,index:m}))},t.placeholderKeyframe=u,t.createName=function(h){return Object.entries(h).reduce((d,[c,p])=>(typeof p!="string"&&d.push({name:p.name}),d),[])},t.Presets=[{name:"Slide in",animationParams:{translateX:{value:[-20,0],easing:r_(3),duration:1e3},opacity:{value:[0,1],easing:r_(3),duration:1e3},endDelay:250,loop:!0}},{name:"Rotate",animationParams:{rotate:{value:[0,"1turn"],easing:r_(5),duration:700},endDelay:250,loop:!0}},{name:"Scale Out",animationParams:{scale:{value:[1,1.5],easing:r_(4),duration:1e3},endDelay:250,loop:!0}},{name:"Jump",animationParams:{translateY:[{value:0,duration:200,easing:"linear"},{value:-20,easing:"linear",duration:200},{value:0,easing:"linear",duration:100}],endDelay:500,loop:!0}},{name:"Jump Rotate",animationParams:{translateY:[{value:0,duration:200,easing:"linear"},{value:-20,easing:"linear",duration:200},{value:0,easing:"linear",duration:100}],rotate:{value:[0,"1turn"],easing:r_(5),duration:500},endDelay:500,loop:!0}},{name:"Bounce",animationParams:{translateY:{value:["20px","-20px"],duration:575,easing:"easeOutQuad"},direction:"alternate",loop:!0}}]})(Fg||(Fg={})),RS=["x","y","z"],kmt=class{constructor(t=1,e=100,i=10,r=0){this.mass=t,this.stiffness=e,this.damping=i,this.initialVelocity=r,this.m_w0=Math.sqrt(e/t),this.m_zeta=i/(2*Math.sqrt(e*t)),this.m_zeta<1?(this.m_wd=this.m_w0*Math.sqrt(1-this.m_zeta*this.m_zeta),this.m_A=1,this.m_B=(this.m_zeta*this.m_w0-r)/this.m_wd):(this.m_wd=0,this.m_A=1,this.m_B=-r+this.m_w0)}solve(t){return 1-(this.m_zeta<1?Math.exp(-t*this.m_zeta*this.m_w0)*(this.m_A*Math.cos(this.m_wd*t)+this.m_B*Math.sin(this.m_wd*t)):(this.m_A+this.m_B*t)*Math.exp(-t*this.m_w0))}getDuration(){let t=.16666666666666666,e=0,i=0;for(;;)if(e+=t,this.solve(e)===1){if(i++,i>=16)break}else i=0;return e*t*1e3}}}),cG=G(()=>{var t;wl(),Fi(),(gR||(gR={})).list=["idle","move","jump","run"],(t=yR||(yR={})).defaultColliderData={type:"capsule",height:200,radius:50,position:[0,0,0],rotation:[0,0,0]},t.defaultDataThirdPerson={moveMode:"walk",forwardDirection:"+z",speedTranslate:1e3,speedRotate:100,runMultiplier:2,rotationMode:"normal",rotBy:"keys",rotByTouch:"drag",delayPos:[.3,.3],delayRot:[.3,.3],keyAssignments:[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","\u25B2"],["rotPosY","\u25C0"],["rotNegX","\u25BC"],["rotNegY","\u25B6"],["jump","Space"],["run","\u21E7"],["none","Ctrl"]],touchControl:!0,joystickPosLoc:5,joystickRotLoc:11,jumpTouchButtonLoc:9,collider:t.defaultColliderData,colliderHelperVisible:!0,collisionEnabled:!0,jumpPower:100,resetYPosition:3e3,alignToGround:!1,autoOrientMove:!0,orientWith:"camera",orientMode:"radial",delayPosCamera:.3,delayRotCamera:.3,camera:"",cameraXAxis:"Limit",cameraYAxis:"Free",cameraRotXLimits:[0,Math.PI/2],cameraRotYLimits:[-Math.PI/2,Math.PI/2],gameActions:{idle:new ge,move:new ge,jump:new ge,run:new ge},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:qi.fromHexAndA(3728051,1)}}});function ig(t,...e){let i={};for(let r of e.flat())t!=null&&r in t&&(i[r]=t[r]);return i}function iY(t){t.layers.forEach(e=>{if(e.type==="depth"&&e.colorA!==void 0){let i=e.colorA,r=e.colorB,s=[[i.r,i.g,i.b,i.a],[r.r,r.g,r.b,r.a]],n=[0,1];for(let o=2;o<10;o++)s.push(s[1]),n.push(1);let a={...ig(Gs(e),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,e.near),far:Math.max(0,e.far),colors:s,steps:n,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(e,a)}else if(e.type==="depth"&&e.gradientType===1&&(e.near<0||e.far<0)){let i={...Gs(e),near:Math.max(e.near,0),far:Math.max(e.far,0)};Object.assign(e,i)}})}function Kd(t,e){Object.values(t.shared.materials).forEach(i=>e(i))}function Zd(t,e){t.scene.objects.traverse((i,r)=>{"materials"in r?r.materials.forEach((s,n)=>{s===void 0&&(r.materials[n]=cs.defaultTwoLayerData("phong"),s=r.materials[n]),typeof s!="string"&&e(s)}):"material"in r?typeof r.material!="string"&&(r.material===void 0&&(r.material=cs.defaultTwoLayerData("phong")),e(r.material)):r.type==="Mesh"&&(r.material===void 0&&(r.material=cs.defaultTwoLayerData("phong")),e(r.material)),"overrides"in r&&Object.values(r.overrides).forEach(s=>{s.material&&typeof s.material!="string"&&Object.getPrototypeOf(s.material)!==Xs.prototype&&e(s.material)})})}function rY(t){t.layers===void 0&&Object.assign(t,cs.defaultTwoLayerData("lambert"))}function lO(t){!t.layers||t.layers.forEach(e=>{if(e.type==="depth"&&e.colors.length===10){let i=[...e.colors];i.push(e.colors[9]);let r=[...e.steps];r.push(e.steps[9]);let s={...Gs(e),colors:i,steps:r};Object.assign(e,s)}})}function sY(t){t.scene.objects.traverse((e,i)=>{"materials"in i?i.materials.forEach(r=>{typeof r!="string"&&lO(r)}):"material"in i&&typeof i.material!="string"&&lO(i.material)}),Object.values(t.shared.materials).forEach(e=>lO(e))}function nY(t){t.layers&&t.layers.forEach(e=>{e.type==="depth"&&e.num!==void 0&&(e.colors=e.colors.slice(0,e.num),e.steps=e.steps.slice(0,e.num),delete e.num)})}function aY(t){t.layers&&t.layers.forEach(e=>{(function(i){return i.type!=="displace"})(e)&&e.isMask===void 0&&(e.isMask=!1),(e.type==="texture"||e.type==="video")&&e.blending===void 0&&(e.blending=0),(e.type==="noise"||e.type==="displace"&&e.displacementType==="noise")&&(e.voronoiStyle===void 0&&(e.voronoiStyle=0),e.highCut===void 0&&(e.highCut=1),e.lowCut===void 0&&(e.lowCut=0),e.smoothness===void 0&&(e.smoothness=.3),e.seed===void 0&&(e.seed=0),e.quality===void 0&&(e.quality=1))})}function oY(t){let e=t.layers.find(i=>i.type==="light")?.data;if(e?.category==="basic"){let i=Ws.defaultData("light","phong"),r=e;Object.assign(r,i),r.visible=!1}}function lY(t){Kd(t,oY),Zd(t,oY)}function hY(t){t.layers.forEach(e=>{e.type==="light"&&e.category!=="toon"&&e.occlusion===void 0&&(e.occlusion=!0)})}function uY(t){t.layers&&t.layers.forEach(e=>{e.type==="light"&&e.bumpMapIntensity===void 0&&(e.bumpMapIntensity=5)})}var CMt=G(()=>{YS(),wl(),hG(),C5(),Fi(),E5(),hn(),dt(),aG(),cG(),Imt(),uG(),nG(),lG()}),Lmt={};function dY(t){t.layers&&t.layers.forEach(e=>{e.type==="light"&&e.alphaOverride===void 0&&(e.alphaOverride=1)})}function cY(t,e){let[i,r,s]=t,n=Math.cos(i),a=Math.sin(i),o=Math.cos(r),l=Math.sin(r),u=Math.cos(s),h=Math.sin(s),d=[o*u,n*h+a*u*l,a*h-n*u*l],c=Math.hypot(e[0],e[1],e[2])||1;return Math.abs((d[0]*e[0]+d[1]*e[1]+d[2]*e[2])/c)}function Fmt(t){(function(i){i.rotation=i.rotation.slice(0,3).map(r=>r*Dp)})(t),t.type==="Page"&&function(i){let r=i.rotation.slice(0,3);(function(s,n){let a=Array.isArray(n)&&n.length>=3&&n.every(u=>typeof u=="number"&&Number.isFinite(u))?n:[0,1,0],o=cY(s,a),l=cY(s.map(u=>u*Wmt),a);return Math.abs(o-l)<1e-6?s.some(u=>Math.abs(u)>Math.PI):l<o})(r,i.up)?i.rotation=r:i.rotation=r.map(s=>s*Dp)}(t.camera),t.states?.forEach(i=>{i.rotation===void 0||i.rotation===null||(i.rotation=i.rotation.slice(0,3).map(r=>r*Dp))});let e=t.geometry;e&&e.type==="SphereGeometry"&&(e.thetaLength=(e.thetaLength??180)*Dp),e&&e.type==="TorusGeometry"&&(e.arc=e.arc*Dp),e&&e.type==="PathGeometry"&&(e.extrusion.angle*=Dp,e.extrusion.twist*=Dp),t.type==="Mesh"&&t.geometry.type==="TextGeometry"&&(t.geometry.text={textValue:t.geometry.text}),Array.isArray(Gs(t.events))&&t.events?.forEach(i=>{(i.type==="MouseDown"||i.type==="MouseUp"||i.type==="MousePress"||i.type==="KeyDown"||i.type==="KeyUp"||i.type==="KeyPress"||i.type==="Collision"||i.type==="Trigger")&&(i.runMode=i.toggle?"Toggle":"Repeat")})}function EMt(t){t.scene.objects.traverse((e,i)=>{})}function PMt(t){let e=t.schema??104;e!==131&&e<130&&(vR(t.asset),t.schema=130)}function q1(t,e){e(t.data);for(let i of t.children)q1(i,e)}function Umt(t){let e=t.schema??104;e!==131&&(e<105&&(q1(t.asset,Fmt),t.schema=105),e<118&&(q1(t.asset,Gmt),t.schema=118),e<121&&(q1(t.asset,gU),t.schema=121),e<130&&(q1(t.asset,RMt),t.schema=130))}function jmt(t,e){Zd(t,e),Kd(t,e),Object.values(t.shared.lib.materials).forEach(i=>e(i.asset))}function vR(t){t.layers===void 0&&Object.assign(t,cs.defaultTwoLayerData("phong"))}function RMt(t){"materials"in t?t.materials.forEach(e=>{e!==void 0&&typeof e!="string"&&vR(e)}):"material"in t&&t.material!==void 0&&typeof t.material!="string"&&vR(t.material)}function Gmt(t){t.timelineAnimations=$a({},Be.prototype)}function DMt(t){let e=[];return t?(t.forEach((i,r)=>{let{path:s,keyframes:n}=i.data,a=s[0]==="material"?i.id:void 0;n?.length?n.forEach(({id:o,data:l})=>{e.push({id:o,data:{...l,path:s,layerId:a,index:r}})}):e.push(Fg.placeholderKeyframe(i.id,s,{layerId:a,index:r}))}),e.sort((i,r)=>i.data.time-r.data.time),new ge(...e.map((i,r)=>({...i,fi:r})))):new ge}function NMt(t){for(let{id:e,data:i}of[...t.unproxy()]){let r=i.path?.[0];if(!r||!qmt.includes(r))continue;let s=fU(i.value);if(!s.length)continue;let n=t.data(e);if(!n)continue;let a=i.value,[o,...l]=s;for(let u of l){let h=qt.generateUUID();t.insertBefore(null,[{id:h,data:{...i,id:h,path:[r,u],value:a[u],easing:OMt(i.easing)}}])}n.path=[r,o],n.value=a[o]}}function fU(t){return t===null||typeof t!="object"?[]:RS.filter(e=>e in t)}function OMt(t){let e=t?.cubicControls;return{...t,cubicControls:{control1:[...e?.control1??[0,0]],control2:[...e?.control2??[1,1]]},...t?.springParameters?{springParameters:{...t.springParameters}}:{}}}function IMt(t,e){return Math.abs(t[0]-e[0])<1e-6&&Math.abs(t[1]-e[1])<1e-6}function BMt(t){let e=function(n){let a=[];for(let o of Fg.groupKeyframes(n)){let l=new Set(o.keyframes.flatMap(h=>fU(h.data.value))),u=l.size?[...l].map(h=>o.keyframes.filter(d=>fU(d.data.value).includes(h))):[o.keyframes];for(let h of u){let d=[...h].sort((c,p)=>c.data.time-p.data.time);for(let c=0;c+1<d.length;c++)a.push({left:d[c],right:d[c+1]})}}return a}([...t.unproxy()]),i=new Map,r=new Set;for(let{left:n,right:a}of e){let o=n.data.easing?.type,l=(o===void 0?void 0:Fg.presetHandles(o))?.control2??(o===5?Lg(a.data.easing?.cubicControls?.control2,[1,1]):void 0);if(!l)continue;let u=i.get(a.id);u?IMt(u,l)||r.add(a.id):i.set(a.id,l)}let s=new Map;for(let{id:n,data:a}of t.unproxy()){let o=a.easing?.type,l=o===void 0?void 0:Fg.presetHandles(o);l&&s.set(n,l.control1)}for(let{left:n,right:a}of e)r.has(a.id)&&s.delete(n.id);for(let[n,a]of s){let o=t.data(n);!o?.easing||(o.easing.cubicControls={control1:a,control2:Lg(o.easing.cubicControls?.control2,[1,1])},o.easing.type=5)}for(let{left:n,right:a}of e){if(!s.has(n.id))continue;let o=t.data(a.id),l=i.get(a.id);!o?.easing||!l||(o.easing.cubicControls={control1:Lg(o.easing.cubicControls?.control1,[0,0]),control2:l})}}function pY(t,e){t.scene.objects.traverse((i,r)=>{let s=r;if(s.type==="Page"&&s.timelines)for(let n of Object.values(s.timelines))for(let a of Object.values(n.objectTimelines??{}))e(a.keyframes)})}function gU(t){t.pivot=[0,0,0],t.pivotRotation=[0,0,0]}function VMt(t){}function kMt(t){let e=t.schema??0;if(e!==131){if(e>131)return void console.error(`This scene was created with a newer version of Spline (file format ${e}, this runtime reads 131). Update @splinetool/runtime to the latest version to load it correctly.`);console.warn("updating from ",e,"to ",131),function(i,r){if(r<1&&(Zd(i,iY),Kd(i,iY),i.schema=1),r<2&&(function(s){Object.assign(s.scene.publish,{orbitControls:{...fR.defaultData,...Gs(s.scene.publish.orbitControls)}})}(i),i.schema=2),r<3&&(function(s){function n(a){if(a.layers){for(let o of Object.values(a.layers))if(o){for(let[l,u]of Object.entries(o))if((A5.includes(l)||typeof u=="boolean")&&delete o[l],l==="texture")for(let[h,d]of Object.entries(u))(rG.includes(h)||typeof d=="boolean")&&delete u[h]}}}s.scene.objects.traverse((a,o)=>{o.states.forEach(l=>{let u=l;u.material?n(u.material):u.materials&&u.materials.forEach(h=>{n(h)})})})}(i),i.schema=3),r<4&&(function(s){s.scene.publish.withBackground=!0}(i),i.schema=4),r<5&&(function(s){s.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}(i),i.schema=5),r<6&&(function(s){s.scene.objects.traverse((n,a)=>{let o=a.cloner;o&&(o.radial.scale=o.radial.scale.map(l=>l+1),o.linear.scale=o.linear.scale.map(l=>l+1))})}(i),i.schema=6),r<7&&(function(s){s.scene.objects.traverse((n,a)=>{let o=a.geometry;o&&(o.type==="DodecahedronGeometry"||o.type==="IcosahedronGeometry")&&(o.detail=Math.round(o.detail))})}(i),i.schema=7),r<8&&(i.schema=8),r<9&&(sY(i),i.schema=9),r<10&&(function(s){s.scene.objects.traverse((n,a)=>{a.type==="Mesh"&&(a.geometry.type==="BooleanGeometry"||a.geometry.type==="SubdivGeometry")&&(a.geometry.phongAngle=35)})}(i),i.schema=10),r<11&&(function(s){s.scene.environment.ambientLight.softShadows=!1,s.scene.environment.ambientLight.softShadowQuality="low",s.scene.objects.traverse((n,a)=>{(a.type==="DirectionalLight"||a.type==="SpotLight")&&(a.shadowResolution=1024,a.shadowRadius=1,a.depth=1e5)}),s.shared.penumbraSize=new Array(5).fill(.5)}(i),i.schema=11),r<12&&(sY(i),i.schema=12),r<13&&(function(s){s.shared.audios=$a({},Be.prototype)}(i),i.schema=13),r<14&&(function(s){let n=s.shared.materials;Object.entries(n).forEach(([a,o])=>{if(!o.layers){let l={name:"Untitled Material",layers:[{fi:0,data:{type:"light",category:"phong",alpha:.6,visible:!0,mode:0,specular:{r:.2,g:.2,b:.2},shininess:5},id:"layer1"},{fi:1,data:{type:"color",alpha:1,visible:!0,mode:0,color:{r:.2823529411764706,g:.2823529411764706,b:.30196078431372547}},id:"layer2"}]};Object.assign(n,{[a]:l})}})}(i),i.schema=14),r<15&&(function(s){Object.entries(Gs(s.shared.images)).filter(n=>n[1].asset===!1).map(n=>n[0]).forEach(n=>{delete s.shared.images[n]}),Object.entries(Gs(s.shared.audios)).filter(n=>n[1].asset===!1).map(n=>n[0]).forEach(n=>{delete s.shared.audios[n]})}(i),i.schema=15),r<16&&(function(s){s.scene.publish.settings.web.preload=!1}(i),i.schema=16),r<17&&(Zd(i,nY),Kd(i,nY),i.schema=17),r<18&&(Zd(i,rY),Kd(i,rY),i.schema=18),r<19&&(function(s){Object.assign(s.scene.publish.settings,{video:{...vc.defaultData.settings.video,...Gs(s.scene.publish.settings.video)}})}(i),i.schema=19),r<20&&(function(s){s.shared.fonts=$a({},Be.prototype)}(i),function(s){let n=[];s.scene.objects.traverse((a,o)=>{let l=o;if(l.type==="TextFrame"){let u=cs.defaultTwoLayerData("phong"),h=typeof l.color=="string"?s.shared.colors[l.color]:l.color;u.layers[1].data.color={r:h.r,g:h.g,b:h.b},u.layers[1].data.alpha=l.alpha;let d=function(m){return m.replace(".typeface","").replace(/optimer/gi,"open sans").replace("space_mono","space mono").replace(/alma_mono/gi,"varela round").replace(/droid_sans_mono/gi,"noto sans mono").replace(/droid_sans|gentilis|gnomon_(simple|foreground)|helvetiker/gi,"roboto").replace(/droid_serif/gi,"roboto slab").replace("_sans"," sans").replace("crimson_text","crimson text").replace("medium_medium","medium").replace("fatface_fatface","fatface").replace("100hairline","thin").replace("200thin","extralight").replace("300light","light").replace("500medium","medium").replace("600semi","semibold").replace("800heavy","extrabold").replace("900black","black").replace(/bodoni_(11|16|24|36|48|72|96)([^_])/gi,"bodoni_$1_$2").replace(/bodoni_(11|16|24|36|48|72|96)/gi,"bodoni moda").replace(/(thin|hairline)(_regular)?/gi,"100").replace(/(extra|ultra)light(_regular)?/gi,"200").replace(/light(_regular)?/gi,"300").replace(/_book|_normal|_roman/gi,"_regular").replace(/medium(_regular)?/gi,"500").replace(/(semi|demi)bold(_regular)?/gi,"600").replace(/(extra|ultra)bold(_regular)?/gi,"800").replace(/bold(_regular)?/gi,"700").replace(/(black|heavy|fatface)(_regular)?/gi,"900").replace(/([1-9]00)_italic/gi,"$1italic").replace(/regularitalic/gi,"italic").replace(/regularitalic/gi,"italic").split(" ").map(f=>f.charAt(0).toUpperCase()+f.slice(1)).join(" ")}(l.font);s.shared.fonts[d]===void 0&&(s.shared.fonts[d]={name:d});let c={name:l.name,...sn.defaultData,...Bu.defaultData,flatShading:!1,wireframe:!1,geometry:{...lc.defaultData("TextGeometry"),width:l.width,height:l.height,font:d,depth:0,horizontalAlign:l.horizontalAlign,verticalAlign:l.verticalAlign,fontSize:1.40625*l.fontSize,lineHeight:l.lineHeight/1.40625,letterSpacing:l.letterSpacing-1,text:l.text,textTransform:l.textTransform,extrudeBevelSize:0,extrudeBevelSegments:1},material:u,states:Gs(l.states),events:Gs(l.events),visible:l.visible,raycastLock:l.raycastLock,position:l.position,rotation:l.rotation,scale:l.scale,hiddenMatrix:l.hiddenMatrix},p=Gs(s.scene.objects).parent(a);s.scene.objects.insertAfter(p??null,a,[{id:a+"new",data:c,children:[]}]),n.push(a)}}),n.forEach(a=>{s.scene.objects.delete(a)})}(i),i.schema=20),r<21&&(function(s){let n={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};s.scene.objects.traverse((a,o)=>{o.events.forEach(l=>{if(n[Number(l.type)])if(Object.assign(l,{type:n[Number(l.type)]}),l.type==="Audio"&&"audioEvent"in l&&(Object.assign(l,{playAudio:l.audioEvent}),delete l.audioEvent),l.type==="GameControl")Object.assign(l,{gameActions:{idle:new ge,move:new ge,jump:new ge}});else{let u=new ge;Object.assign(l,{actions:u}),(l.type==="MouseDown"||l.type==="MouseUp"||l.type==="KeyDown"||l.type==="KeyUp")&&"url"in l&&u.push({fi:0,id:qt.generateUUID(),data:{type:"Link",url:l.url,delay:0}}),"targets"in l&&(l.targets.forEach((h,d,c)=>{let p={easing:h.easing,duration:h.duration};h.easing===6?Object.assign(p,ig(h,"mass","stiffness","damping","velocity")):h.easing===5&&Object.assign(p,{control1:{...h.control1},control2:{...h.control2}});let m={repeat:h.repeat?-1:0,delay:h.delay,delayDirection:h.delayDirection,direction:h.cycle&&h.rewind?"pingpong-rewind":h.cycle?"pingpong":"normal"},f={state:h.state,...m,...p},g={allowSlerp:!0,type:"Transition",object:h.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new ge({fi:0,id:qt.generateUUID(),data:{state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4}},{fi:1,id:qt.generateUUID(),data:f})};u.push({fi:c,id:d,data:g})}),delete l.targets)}})})}(i),function(s){s.scene.objects.traverse((n,a)=>{function o(l,u){let h=new ge,d=[];if(a.events.forEach((c,p,m)=>{if(c.type==="Audio"&&c.trigger===u){let f;d.push(p),c.interaction==="play"?f={...ig(c,"interaction","audio","delay","volume","loop"),triggerAfter:"after"in c?c.after:void 0,toggle:"after"in c?c.toggle:void 0,type:"Audio"}:(c.interaction==="pause"||c.interaction==="stop")&&(f={...ig(c,"interaction","delay","object","playAudio"),type:"Audio"}),f&&h.push({fi:m,id:p,data:f})}}),d.forEach(c=>a.events.delete(c)),h.length){let c=a.events.find(p=>p.type===l)?.data;c?"actions"in c&&c.actions.insertBefore(null,h):a.events.insertBefore(null,[{id:qt.generateUUID(),data:{type:l,actions:h}}])}}o("Start","start"),o("MouseDown","mouseDown"),o("MouseUp","mouseUp"),o("KeyDown","keyDown"),o("KeyUp","keyUp")})}(i),i.schema=21),r<22&&(lY(i),i.schema=22),r<23&&(function(s){s.scene.objects.traverse((n,a)=>{a.type==="Mesh"&&a.geometry.type==="SubdivGeometry"&&(a.geometry.scaleBaked||(a.geometry.scaleBaked=[1,1,1]))})}(i),i.schema=23),r<24&&(function(s){s.scene.objects.traverse((n,a)=>{(a.type==="Empty"||a.type==="Mesh")&&a.cloner&&!a.cloner.randomnessObject&&!a.cloner.toObject&&!a.cloner.randomness&&(a.cloner={...a.cloner,toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}})})}(i),i.schema=24),(r<25||i.shared.videos===void 0)&&(function(s){s.shared.videos=$a({},Be.prototype)}(i),r<25&&(i.schema=25)),r<26&&(function(s){s.scene.objects.traverse((n,a)=>{let o=s.scene.objects.unproxy().parent(n);if(o){let l=Gs(s.scene.objects.data(o));l&&l.type==="Mesh"&&l.geometry.type==="BooleanGeometry"&&a.type==="Mesh"&&(a.visible=Gs(a).booleanExclude!==!0)}})}(i),i.schema=26),r<27&&(function(s){s.scene.objects.traverse((n,a)=>{if(a.type==="Mesh"){let o=a;a.geometry.type==="NonParametricGeometry"?o.material!==void 0&&delete o.material:o.materials!==void 0&&delete o.materials}})}(i),i.schema=27),r<28&&(lY(i),i.schema=28),r<29&&(function(s){function n(o){Object.setPrototypeOf(o,Xs.prototype),o.texture&&Object.setPrototypeOf(o.texture,Xs.prototype)}function a(o){Object.setPrototypeOf(o,Xs.prototype);for(let l in o)n(o[l])}s.scene.objects.traverse((o,l)=>{l.states.forEach(u=>{let h=u;if(h.material){let d=Gs(h.material).layers;a(d),h.material.layers=d}if(h.materials)for(let d=0;d<h.materials.length;d++){let c=h.materials[d],p=Gs(c).layers;a(p),c.layers=p}})})}(i),i.schema=29),r<30&&(function(s){s.scene.objects.traverse((n,a)=>{a.type==="Mesh"&&a.geometry.type==="NonParametricGeometry"&&!("material"in a)&&!("materials"in a)&&(a.material=cs.defaultTwoLayerData("phong"))})}(i),i.schema=30),r<31&&(function(s){s.scene.publish.orbitControls.autoZoom===void 0&&(s.scene.publish.orbitControls.autoZoom=!1),s.scene.objects.traverse((n,a)=>{(a.type==="OrthographicCamera"||a.type==="PerspectiveCamera")&&(a.orthographic.autoZoom===void 0&&(a.orthographic.autoZoom=!1),a.orthographic.autoZoomFrustumSize===void 0&&(a.orthographic.autoZoomFrustumSize=790))})}(i),i.schema=31),r<33&&(function(s){s.scene.objects.traverse((n,a)=>{a.pathSnapping===void 0&&(a.pathSnapping={pathId:null,slide:0,offset:0,orientation:"tangential"}),a.pathSnapping.offset===void 0&&(a.pathSnapping.offset=0)})}(i),i.schema=33),r<34&&(function(s){s.scene.publish.mouseEventTarget===void 0&&(s.scene.publish.mouseEventTarget="canvas"),s.scene.publish.settings.web.hint===void 0&&(s.scene.publish.settings.web.hint=!1)}(i),i.schema=34),r<35&&(function(s){let{video:n}=s.scene.publish.settings;n.format==="gif"&&n.fps>48&&(n.fps=15)}(i),i.schema=35),r<36&&(function(s){s.scene.objects.traverse((n,a)=>{a.events.forEach(o=>{o.type==="GameControl"&&(o.resetYPosition=Math.abs(o.resetYPosition-a.position[1]))})})}(i),i.schema=36),r<37&&(function(s){let n=s.scene.environment.usePhysics;s.scene.objects.traverse((a,o)=>{n&&o.physics===null?o.collision=!1:o.collision="visibility"})}(i),i.schema=37),r<38&&(Zd(i,aY),Kd(i,aY),i.schema=38),r<39&&(function(s){s.scene.objects.traverse((n,a)=>{a.events.forEach(o=>{o.type==="GameControl"&&(o.navmesh=yR.defaultDataThirdPerson.navmesh)})})}(i),i.schema=39),r<40&&(function(s){s.scene.styles||(s.scene.styles=bg.defaultData())}(i),i.schema=40),r<41&&(function(s){s.scene.environment.ambientLight.occlusion===void 0&&(s.scene.environment.ambientLight.occlusion=!1),s.scene.environment.ambientLight.aoFullRes===void 0&&(s.scene.environment.ambientLight.aoFullRes=!1),s.scene.environment.ambientLight.radius===void 0&&(s.scene.environment.ambientLight.radius=256),s.scene.environment.ambientLight.bias===void 0&&(s.scene.environment.ambientLight.bias=.5),s.scene.environment.ambientLight.aoColor===void 0&&(s.scene.environment.ambientLight.aoColor={r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}),Zd(s,hY),Kd(s,hY)}(i),i.schema=41),r<42&&(function(s){s.scene.objects.traverse((n,a)=>{a.events.forEach(o=>{o.type==="GameControl"&&Object.assign(o.gameActions,{run:new ge})})})}(i),i.schema=42),r<43&&(function(s){s.scene.objects.traverse((n,a)=>{a.events.forEach(o=>{o.type==="GameControl"&&(o.keyAssignments=[...o.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}(i),i.schema=43),r<99){Zd(i,uY),Kd(i,uY),i.scene.publish.playCamera===null&&(i.scene.publish.playCamera=i0);let s=Gs(i.scene.objects),n=i.scene.objects;i.scene.publish.playPage=ov,n.insertBefore(null,null,[{id:ov,data:{...zg.defaultData,backgroundColor:i.scene.backgroundColor,fog:i.scene.fog,postprocessing:i.scene.postprocessing,ao:ig(i.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:i.scene.publish.playCamera,gameControlObject:i.scene.publish.gameControlObject},shadow:ig(i.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...dv.defaultData,...ig(i.scene.environment,"usePhysics","gravity")},camera:Gs(i.scene.ownerCamera)??zg.defaultData.camera,name:"Scene"},children:[]}]);for(let l of s)l.id!==_g.TRASH_CAN_ID&&n.move(ov,l.fi,l.id);let a=0,o=0;i.shared.penumbraSize&&i.scene.objects.traverse((l,u)=>{u.type==="DirectionalLight"?(u.penumbraSize=i.shared.penumbraSize[Math.min(a,2)],a+=1):u.type==="SpotLight"&&(u.penumbraSize=i.shared.penumbraSize[3+Math.min(o,1)],o+=1),(u.physics===void 0||u.physics===null)&&u.type!=="Instance"&&(u.physics={},Object.assign(u.physics,hv.defaultData)),u.physics!==void 0&&u.physics!==null&&(u.physics.enabled=u.collision??"visibility",delete u.collision)}),i.schema=99}}(t,e),e<100&&(t.scene.publish.joystickSizeAndXYOffset===void 0&&(t.scene.publish.joystickSizeAndXYOffset=vc.defaultData.joystickSizeAndXYOffset),t.schema=100),e<101&&(Zd(t,dY),Kd(t,dY),t.schema=101),e<102&&(function(i){i.scene.objects.traverse((r,s)=>{let n=s.geometry;n&&n.type==="PathGeometry"&&(n.extrusion.capType="flat",n.extrusion.bevel=50,n.extrusion.bevelSides=6,n.extrusion.shape.type==="Custom"&&(n.extrusion.shape.shapeQuality="low"))})}(t),t.schema=102),e<104&&(t.shared.catelogs=new Be,t.shared.lib=hc.defaultData(),t.schema=104),e<105&&(function(i){i.shared.variables=$a({},Be.prototype)}(t),t.scene.objects.traverse((i,r)=>{Fmt(r)}),t.schema=105);for(let i of Object.values(t.shared.lib.components))Umt(i);e<106&&(function(i){let r=Gs(i.shared.variables);i.shared.variables=$a(Object.entries(r??{}).map(([s,n],a)=>({fi:a,id:s,data:n})),ge.prototype)}(t),t.schema=106),e<107&&(t.shared.lib.variables=hc.defaultData().variables,t.schema=107),e<109&&(function(i){i.shared.particles=$a({},Be.prototype),i.shared.lib&&(i.shared.lib.particles=hc.defaultData().particles)}(t),t.schema=109),e<110&&(function(i){i.scene.objects.traverse((r,s)=>{s.type==="Particle"&&typeof s.renderMaterial.size=="number"&&Object.assign(s.renderMaterial,{size:[s.renderMaterial.size,s.renderMaterial.size]})})}(t),t.schema=110),e<111&&(t.scene.objects.traverse((i,r)=>{(function(s){Array.isArray(Gs(s.events))&&s.events?.forEach(n=>{"disabled"in n||(n.disabled=!1),(n.type==="MouseDown"||n.type==="MouseUp"||n.type==="MousePress")&&(n.mode=n.mode||"Object")})})(r)}),t.schema=111),e<112&&(function(i){i.scene.objects.traverse((r,s)=>{s.type==="Page"&&(s.postprocessing.depthOfField.focusDistance=100,s.postprocessing.depthOfField.focalLength=20,s.postprocessing.depthOfField.bokehScale=5)})}(t),t.schema=112),e<113&&(function(i){i.scene.objects.traverse((r,s)=>{Array.isArray(Gs(s.events))!==!1&&s.events?.forEach(n=>{let a=n.runMode;n.type==="MouseDown"||n.type==="MouseUp"||n.type==="KeyDown"||n.type==="KeyUp"||n.type==="Collision"||n.type==="Trigger"?n.actions?.forEach(o=>{o.type==="Transition"&&(o.runMode=a??"Repeat"),(o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode=a==="Toggle"?"Toggle":"Normal")}):n.type==="MouseHover"||n.type==="MousePress"||n.type==="KeyPress"?n.actions?.forEach(o=>{(o.type==="Transition"||o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Toggle")}):n.type==="GameControl"?(delete n.actions,Object.keys(n.gameActions).forEach(o=>{n.gameActions[o]?.forEach(l=>{l.type==="Transition"&&(l.runMode="Repeat"),l.type==="Animation"&&"runMode"in l&&(l.runMode="Normal")})})):n.type==="DragDrop"?(delete n.actions,n.dragDropActions?.drag?.forEach(o=>{(o.type==="Transition"||o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Toggle")}),n.dragDropActions?.drop?.forEach(o=>{(o.type==="Transition"||o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Toggle")})):n.type==="Resize"?(delete n.actions,n.breakpoints?.forEach(o=>{o.actions?.forEach(l=>{(l.type==="Transition"||l.type==="Animation"&&"runMode"in l||l.type==="SwitchCamera")&&(l.runMode="Toggle")})})):n.type==="Start"?n.actions?.forEach(o=>{o.type==="Transition"&&(o.runMode="Once"),(o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Normal")}):n.type==="VariableChange"||n.type==="Scroll"?n.actions?.forEach(o=>{o.type==="Transition"&&(o.runMode="Repeat"),(o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Normal")}):n.type==="Conditional"&&(delete n.actions,n.inActions?.forEach(o=>{o.type==="Transition"&&(o.runMode="Repeat"),(o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Normal")}),n.outActions?.forEach(o=>{o.type==="Transition"&&(o.runMode="Repeat"),(o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Normal")}))})})}(t),t.schema=113),e<114&&(t.scene.publish.settings.web.imageQuality===void 0&&(t.scene.publish.settings.web.imageQuality=70),t.schema=114),e<115&&(function(i){i.shared.userAPIs=$a({},Be.prototype),i.shared.userWebhooks=$a({},Be.prototype),i.shared.lib&&(i.shared.lib.userAPIs=hc.defaultData().userAPIs,i.shared.lib.userWebhooks=hc.defaultData().userWebhooks)}(t),t.schema=115),e<116&&(function(i){i.scene.publish.settings.videoStatic===void 0&&(i.scene.publish.settings.videoStatic=vc.defaultData.settings.videoStatic)}(t),t.schema=116),e<117&&(t.scene.publish.settings.web.pixelRatioMobile===void 0&&(t.scene.publish.settings.web.pixelRatioMobile=0),t.scene.publish.settings.web.pixelRatioDesktop===void 0&&(t.scene.publish.settings.web.pixelRatioDesktop=0),t.schema=117),e<118&&(t.shared.timelineAnimations=$a({},Be.prototype),t.scene.objects.traverse((i,r)=>{Gmt(r)}),t.schema=118),e<119&&(t.scene.publish.settings.videoStatic.format=cv.defaultData.scene.publish.settings.videoStatic.format,t.scene.publish.settings.videoStatic.imageFormat=cv.defaultData.scene.publish.settings.videoStatic.imageFormat,t.schema=119),e<120&&(t.scene.publish.settings.image.colorSpace="display-p3",t.scene.publish.settings.videoStatic.colorSpace="display-p3",t.schema=120),e<121&&(t.scene.objects.traverse((i,r)=>{gU(r),r.type==="Page"&&r.camera!==void 0&&gU(r.camera)}),t.schema=121),e<122&&(delete t.scene.publish.settings.video,t.scene.publish.orbitControls.rotationSpeed=cv.defaultData.scene.publish.orbitControls.rotationSpeed,t.schema=122),e<123&&(t.scene.objects.traverse((i,r)=>{r.type==="Page"&&r.sky===void 0&&(r.sky=$p.defaultData)}),t.schema=123),e<124&&(e>=123&&t.scene.objects.traverse((i,r)=>{let s=r.sky;r.type==="Page"&&s!==void 0&&(typeof s.exposure=="number"&&(s.exposure=Math.round(s.exposure/5e-4*1e4)/1e4),s.lighting===void 0&&(s.lighting=$p.defaultData.lighting))}),t.schema=124),e<125&&(t.scene.objects.traverse((i,r)=>{let s=r.sky;r.type==="Page"&&s!==void 0&&s.lightingIntensity===void 0&&(s.lightingIntensity=$p.defaultData.lightingIntensity)}),t.schema=125),e<126&&(t.scene.objects.traverse((i,r)=>{let s=r.sky;r.type==="Page"&&s!==void 0&&(s.mode===void 0&&(s.mode="physical"),s.hdri===void 0?s.hdri={...$p.defaultData.hdri}:(s.hdri.blur===void 0&&(s.hdri.blur=$p.defaultData.hdri.blur),Array.isArray(s.hdri.rotation)&&(s.hdri.rotation=s.hdri.rotation[1]??0)))}),t.schema=126),e<127&&(t.scene.objects.traverse((i,r)=>{let s=r.sky;r.type==="Page"&&s?.hdri!==void 0&&s.hdri.showBackground===void 0&&(s.hdri.showBackground=!0)}),t.schema=127),e<128&&(t.scene.objects.traverse((i,r)=>{let s=r.sky;r.type==="Page"&&s!==void 0&&s.lightingQuality===void 0&&(s.lightingQuality="full")}),t.schema=128),e<129&&(t.scene.objects.traverse((i,r)=>{if(r.type==="Page"){r.camera===void 0&&(r.camera=zg.defaultData.camera);let s=r.camera;s.far=1e5,s.perspective?s.perspective.near=70:s.perspective={near:70,fov:45,zoom:1}}}),t.schema=129),e<130&&(jmt(t,vR),t.schema=130),e<131&&(function(i){i.scene.objects.traverse((r,s)=>{let n=s.states;if(!n)return;let a=s.timelineAnimations,o=[];n.forEach((l,u)=>{(l.isAnimation||a?.[u])&&o.push(u)}),o.forEach(l=>n.delete(l))})}(t),function(i){let r=i.shared,s=r.timelineAnimations;if(!s)return;let n=i.scene.objects,a=n.unproxy().find(o=>o.data.type==="Page")?.id;for(let[o,l]of Object.entries(s)){let u=$a({},Be.prototype),h=0,d=Boolean(l.loop);for(let[m,f]of Object.entries(l.mapping??{})){let g=n.data(m)?.timelineAnimations?.[f];!g||(h=Math.max(h,g.to??0),d=d||Boolean(g.loop),u[m]={id:m,keyframes:DMt(g.properties?.unproxy())})}let c=l.page??a,p=c?n.data(c):void 0;p&&p.type==="Page"&&((p.timelines??(p.timelines=$a({},Be.prototype)))[o]={id:o,name:l.name,duration:h||5,...d?{loop:d}:{},objectTimelines:u})}delete r.timelineAnimations,n.traverse((o,l)=>{delete l.timelineAnimations})}(t),pY(t,NMt),pY(t,BMt),t.schema=131)}}$S(Lmt,{updateAllMaterials:()=>jmt,updateDocumentSchema:()=>kMt,updateLibSchema:()=>VMt,updateMaterialSchema:()=>PMt,updateObjectStateRec:()=>q1,updateObjectsSchema:()=>Umt,updateTextValues:()=>EMt});var Dp,Wmt,qmt,mY,bM,hO,fY,_M,xg,s_,V0,xM,uO,PP,dO,cO,gY,RP,pO,Ug,yU,P5=G(()=>{dt(),Vmt(),Fi(),zmt(),CMt(),E5(),YS(),hn(),dG(),C5(),oG(),Dp=180/Math.PI,Wmt=Math.PI/180,qmt=["position","rotation","scale","shape size"]}),zMt=G(()=>{var t,e,i;wl(),Fi(),hn(),(mY||(mY={})).is=function(r){return!0},(t=bM||(bM={})).defaultData={position:[0,0],scale:[1,1],rotation:0,shear:[0,0]},t.merge=function(r,s){return{position:s?.position??r.position,rotation:s?.rotation??r.rotation,scale:s?.scale??r.scale,shear:s?.shear??r.shear}},t.diff=function(r,s){return Jpt({position:qu.isEqual(r.position,s.position)?void 0:s.position,rotation:r.rotation===s.rotation?void 0:s.rotation,scale:qu.isEqual(r.scale,s.scale)?void 0:s.scale,shear:r.shear&&s.shear&&qu.isEqual(r.shear,s.shear)?void 0:s.shear})},(hO||(hO={})).defaultData={horizontalConstraint:0,verticalConstraint:0},(fY||(fY={})).defaultData={direction:"row",wrap:"unwrap",align:"top-left",gap:10,rowGap:10,autoGap:!1,autoRowGap:!1,leftPadding:8,rightPadding:8,topPadding:8,bottomPadding:8},(_M||(_M={})).defaultData={opacity:1,fill:{color:qi.fromHexAndA(Kg,1),enabled:!0},stroke:{color:qi.from0to1([0,0,0,1]),thickness:1,enabled:!1,mode:"inside"},layerBlur:{radius:2,enabled:!1},backgroundBlur:{radius:2,enabled:!1},dropShadow:{offset:[10,10],blurRadius:10,color:qi.from0to1([0,0,0,1]),enabled:!1,spread:0},innerShadow:{offset:[10,10],blurRadius:10,color:qi.from0to1([0,0,0,1]),enabled:!1,spread:0}},(e=xg||(xg={})).newEmpty=function(r,s){return{name:s}},e.patch=function(r,s){if(s===void 0)return r;let n={...r};return Object.assign(n,bM.merge(n,s)),n=function(a,o){if(o===void 0)return a;let l={...a},u=["width","height","cornerRadius"];for(let h of u)h in l&&h in o&&o[h]!==void 0&&Object.assign(l,{[h]:o[h]});return l}(n,s),n=function(a,o){if(o===void 0)return a;let l={...a};return"fill"in l&&"fill"in o&&o.fill!==void 0&&Object.assign(l,{fill:{...l.fill,...o.fill}}),"stroke"in l&&"stroke"in o&&o.stroke!==void 0&&Object.assign(l,{stroke:{...l.stroke,...o.stroke}}),"layerBlur"in l&&"layerBlur"in o&&o.layerBlur!==void 0&&Object.assign(l,{layerBlur:{...l.layerBlur,...o.layerBlur}}),"backgroundBlur"in l&&"backgroundBlur"in o&&o.backgroundBlur!==void 0&&Object.assign(l,{backgroundBlur:{...l.backgroundBlur,...o.backgroundBlur}}),"dropShadow"in l&&"dropShadow"in o&&o.dropShadow!==void 0&&Object.assign(l,{dropShadow:{...l.dropShadow,...o.dropShadow}}),"innerShadow"in l&&"innerShadow"in o&&o.innerShadow!==void 0&&Object.assign(l,{innerShadow:{...l.innerShadow,...o.innerShadow}}),l}(n,s),n},e.toOps=function(r,s){let n,a=[];for(let[o,l]of Object.entries(s))o!=="name"&&(n===void 0&&(n={path:[],props:{},type:0},a.push(n)),n.props[o]=l);return a},(s_||(s_={})).defaultData={...bM.defaultData,...hO.defaultData,states:new ge,events:new ge,visible:!0,raycastLock:!1},(V0||(V0={})).defaultData={...s_.defaultData,..._M.defaultData},(xM||(xM={})).defaultData={cornerRadius:[0,0,0,0]},(uO||(uO={})).defaultData={...V0.defaultData,type:"ellipse2d",width:100,height:100,name:"Ellipse"},(PP||(PP={})).defaultData={...V0.defaultData,...xM.defaultData,type:"rectangle2d",width:100,height:100,name:"Rectangle"},(dO||(dO={})).defaultData={...V0.defaultData,type:"text2d",width:100,height:100,fontSize:12,lineHeight:1.2,letterSpacing:0,text:{textValue:"Hello world"},horizontalAlign:1,verticalAlign:1,textTransform:1,font:"Roboto_regular",name:"Text"},(cO||(cO={})).defaultData={...V0.defaultData,type:"path2d",path:"",name:"Path"},(gY||(gY={})).is=function(r){return r.type==="ellipse2d"||r.type==="rectangle2d"||r.type==="text2d"||r.type==="vector2d"||r.type==="path2d"},(RP||(RP={})).defaultData={...s_.defaultData,name:"Group",type:"group2d"},(pO||(pO={})).defaultData=()=>({...s_.defaultData,...xM.defaultData,..._M.defaultData,name:"Frame",type:"frame2d",clipped:!0,width:200,height:200,fill:{color:qi.fromHexAndA(4737101,1),enabled:!0},stroke:{color:qi.fromHexAndA(0,1),thickness:1,enabled:!1,mode:"inside"},backgroundBlur:{radius:2,enabled:!1},layerBlur:{radius:2,enabled:!1}}),(r=>{r.defaultData=function(s){switch(s){case"rectangle2d":case"vector2d":return{...PP.defaultData};case"ellipse2d":return{...uO.defaultData};case"text2d":return{...dO.defaultData};case"path2d":return{...cO.defaultData};case"frame2d":return{...pO.defaultData()};case"group2d":return{...RP.defaultData}}},r.getPivot=function(s){return"width"in s&&"height"in s?[typeof s.width=="number"?.5*s.width:0,typeof s.height=="number"?.5*s.height:0]:[0,0]},r.isResizeable=function(s){return s.type==="rectangle2d"||s.type==="ellipse2d"||s.type==="text2d"||s.type==="frame2d"},r.isAutoLayoutable=function(s){return s.type==="frame2d"&&s.autoLayout!==void 0},r.hasCorners=function(s){return s.type==="rectangle2d"||s.type==="frame2d"}})(Ug||(Ug={})),(i=yU||(yU={})).defaultData={name:"UI",type:"scene2d",objects:new In},i.emptyData=function(){return{type:"scene2d",objects:new In}}}),LMt=G(()=>{_Mt(),xMt(),wmt(),Smt(),Vmt(),bmt(),AMt(),Emt(),Dmt(),oG(),P5(),Bmt(),aG(),nG(),Tmt(),YS(),Cmt(),Omt(),wl(),E5(),C5(),hG(),Rmt(),dG(),uG(),wMt(),Pmt(),cG(),lG(),Mmt(),Amt(),zMt()});function wg(t,e=!1){let i=t[0].index!==null,r=new Set(Object.keys(t[0].attributes)),s=new Set(Object.keys(t[0].morphAttributes)),n={},a={},o=t[0].morphTargetsRelative,l=new ye,u=0;for(let h=0;h<t.length;++h){let d=t[h],c=0;if(i!==(d.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(let p in d.attributes){if(!r.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+'. All geometries must have compatible attributes; make sure "'+p+'" attribute exists among all geometries, or in none of them.'),null;n[p]===void 0&&(n[p]=[]),n[p].push(d.attributes[p]),c++}if(c!==r.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". Make sure all geometries have the same number of attributes."),null;if(o!==d.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let p in d.morphAttributes){if(!s.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". .morphAttributes must be consistent throughout all geometries."),null;a[p]===void 0&&(a[p]=[]),a[p].push(d.morphAttributes[p])}if(e){let p;if(i)p=d.index.count;else{if(d.attributes.position===void 0)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". The geometry must have either an index or a position attribute"),null;p=d.attributes.position.count}l.addGroup(u,p,h),u+=p}}if(i){let h=0,d=[];for(let c=0;c<t.length;++c){let p=t[c].index;for(let m=0;m<p.count;++m)d.push(p.getX(m)+h);h+=t[c].attributes.position.count}l.setIndex(d)}for(let h in n){let d=yY(n[h]);if(!d)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+h+" attribute."),null;l.setAttribute(h,d)}for(let h in a){let d=a[h][0].length;if(d!==0){l.morphAttributes=l.morphAttributes||{},l.morphAttributes[h]=[];for(let c=0;c<d;++c){let p=[];for(let f=0;f<a[h].length;++f)p.push(a[h][f][c]);let m=yY(p);if(!m)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+h+" morphAttribute."),null;l.morphAttributes[h].push(m)}}}return l}function yY(t){let e,i,r,s=-1,n=0;for(let u=0;u<t.length;++u){let h=t[u];if(e===void 0&&(e=h.array.constructor),e!==h.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(i===void 0&&(i=h.itemSize),i!==h.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(r===void 0&&(r=h.normalized),r!==h.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(s===-1&&(s=h.gpuType),s!==h.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;n+=h.count*i}let a=new e(n),o=new we(a,i,r),l=0;for(let u=0;u<t.length;++u){let h=t[u];if(h.isInterleavedBufferAttribute){let d=l/i;for(let c=0,p=h.count;c<p;c++)for(let m=0;m<i;m++){let f=h.getComponent(c,m);o.setComponent(c+d,m,f)}}else a.set(h.array,l);l+=h.count*i}return s!==void 0&&(o.gpuType=s),o}var KS=G(()=>{dt()});function Hmt(t){let e=t.points.length/7,i=new ge;for(let r=0;r<e;r++){let s=7*r,n=t.points[s+0],a=t.points[s+1],o=t.points[s+2],l=t.points[s+3],u=t.points[s+4],h=t.points[s+5],d=t.points[s+6];i.push({fi:r,id:qt.generateUUID(),data:{roundness:d,position:[n,a],areControlsDirectionsMirrored:!0,controlPrevious:{position:[o,l]},controlNext:{position:[u,h]}}})}return{points:i,isClosed:t.isClosed,roundness:t.roundness,shapeHoles:t.shapeHoles?.map(r=>Hmt(r))??[]}}function $mt(t){let{userData:e,uuid:i,...r}=t;if(e===void 0||e.type==="NonParametricGeometry")return function(a){let o,{userData:l,data:u}=a,h=u?.groups,d=u?.attributes??{},c=u?.morphAttributes??{},p=u?.interleavedBuffers,m=u?.arrayBuffers,f=u?.index;d.position!==void 0&&Array.isArray(d.position.array)&&(o=function(y){let v=1/0,b=1/0,_=1/0,x=-1/0,S=-1/0,w=-1/0;for(let T=0;T<y.length;T+=3){let A=y[T],M=y[T+1],C=y[T+2];v=Math.min(v,A),b=Math.min(b,M),_=Math.min(_,C),x=Math.max(x,A),S=Math.max(S,M),w=Math.max(w,C)}return{width:x-v,height:S-b,depth:w-_}}(d.position.array));let g={...l===void 0?{}:l.parameters,data:{attributes:d,morphAttributes:c,interleavedBuffers:p,arrayBuffers:m},...o===void 0?{}:o,type:"NonParametricGeometry"};return f!==void 0&&Object.assign(g.data,{index:f}),h!==void 0&&Object.assign(g.data,{groups:h.map(y=>({...y,materialIndex:y.materialIndex??0}))}),g}(t);if(e.type==="SubdivGeometry"){let a="SubdivGeometry",o=r.data?.attributes;if(o?.positionWASM===void 0){let u=new ye;if(o?.position===void 0||o?.faceMap===void 0)return null;let h=o.position.array,d=o.faceMap.array,c=r.data.index.array;u.setAttribute("position",new fe(h,3)),u.setIndex(new om(c,1));let p=function(y,v=1e-4){v=Math.max(v,Number.EPSILON);let b={},_=y.getIndex(),x=y.getAttribute("position"),S=_?_.count:x.count,w=0,T=Object.keys(y.attributes),A={},M={},C=[],R=["getX","getY","getZ","getW"],O=["setX","setY","setZ","setW"];for(let V=0,q=T.length;V<q;V++){let j=T[V],Q=y.attributes[j];A[j]=new Q.constructor(new Q.array.constructor(Q.count*Q.itemSize),Q.itemSize,Q.normalized);let it=y.morphAttributes[j];it&&(M[j]||(M[j]=[]),it.forEach((at,St)=>{let yt=new at.array.constructor(at.count*at.itemSize);M[j][St]=new at.constructor(yt,at.itemSize,at.normalized)}))}let N=.5*v,B=Math.log10(1/v),k=Math.pow(10,B),z=N*k;for(let V=0;V<S;V++){let q=_?_.getX(V):V,j="";for(let Q=0,it=T.length;Q<it;Q++){let at=T[Q],St=y.getAttribute(at),yt=St.itemSize;for(let Y=0;Y<yt;Y++)j+=~~(St[R[Y]](q)*k+z)+","}if(j in b)C.push(b[j]);else{for(let Q=0,it=T.length;Q<it;Q++){let at=T[Q],St=y.getAttribute(at),yt=y.morphAttributes[at],Y=St.itemSize,pt=A[at],xt=M[at];for(let Tt=0;Tt<Y;Tt++){let Mt=R[Tt],_t=O[Tt];if(pt[_t](w,St[Mt](q)),yt)for(let kt=0,Ut=yt.length;kt<Ut;kt++)xt[kt][_t](w,yt[kt][Mt](q))}}b[j]=w,C.push(w),w++}}let L=y.clone();for(let V in y.attributes){let q=A[V];if(L.setAttribute(V,new q.constructor(q.array.slice(0,w*q.itemSize),q.itemSize,q.normalized)),V in M)for(let j=0;j<M[V].length;j++){let Q=M[V][j];L.morphAttributes[V][j]=new Q.constructor(Q.array.slice(0,w*Q.itemSize),Q.itemSize,Q.normalized)}}return L.setIndex(C),L}(u),m=[],f=new Array(d[d.length-1]+1).fill(3),g=p.getIndex().array;for(let y=0,v=d.length;y<v;)d[y]===d[y+1]?(f[d[y]]++,m.push(...new Set(g.slice(3*y,3*y+6))),y+=2):(m.push(...g.slice(3*y,3*y+3)),y++);o.indexWASM={array:m},o.positionWASM=p.attributes.position,o.verticesPerFaceWASM={array:f}}if(o?.positionWASM===void 0||o?.positionWASM.length===0||o?.indexWASM===void 0||o?.indexWASM.length===0||o?.verticesPerFaceWASM===void 0||o?.verticesPerFaceWASM.length===0)return null;let l={type:a,...FMt(o.positionWASM.array)};l.subdivisions=e.parameters.subdivisions;for(let u in o)u==="positionWASM"?l[u]=new Float32Array(o[u].array):u==="indexWASM"?l[u]=new Int32Array(o[u].array):u==="verticesPerFaceWASM"&&(l[u]=new Int8Array(o[u].array));return l.scaleBaked=[1,1,1],l}let s=e.type,n=e.parameters;return s==="VectorGeometry"?(n.extrudeDepth&&(n.depth=n.extrudeDepth),{...n,width:100,height:100,shape:Hmt(e.shape),type:s}):s==="LatheGeometry"?{...e.parameters,type:s,points:(e?.parameters.points??[]).map(a=>[a.x,a.y])}:(n.extrudeDepth&&(n.depth=n.extrudeDepth),{...n,type:s})}function FMt(t){return vU.setFromArray(t),vU.getSize(Hw),{width:Hw.x,height:Hw.y,depth:Hw.z}}var vU,Hw,mO,UMt=G(()=>{Fi(),dt(),KS(),new bt,new Me,new Qi,new P,new P,vU=new pr,Hw=new P}),jMt=G(()=>{var t;(t=mO||{}).view="view",t.edit="edit",((mO=t)||(mO={})).canWrite=function(e){return e!=="view"},class extends Error{constructor(e,i){super(`This is a ${e.toUpperCase()} document, but it was opened as a ${i.toUpperCase()} one`),this.actual=e,this.expected=i,this.name="DocumentKindMismatchError"}}}),Xmt,bU,DP,Ymt,Kmt,$v,n_,wM,fO,Xv,vY,gO,bY,yO,Ov,Wc,qc,dd,vO,_Y,xY,bO,_U,bc,Zmt=G(()=>{jMt()}),GMt=G(()=>{}),WMt=G(()=>{Fi(),P5(),Zmt()}),qMt=G(()=>{YS(),[...A5],new Set(rG)}),ke=G(()=>{LMt(),GMt(),MMt(),P5(),WMt(),Zmt(),zmt(),qMt(),cG(),Fi()}),R5=G(()=>{Xmt=[3,4,8,9],bU=5,DP=3,Ymt=32,Kmt=.98}),ZS=G(()=>{dt(),$v=t=>{var e;return(e=class extends t{}).geometryHelper=new Zh(30,30,30),e}}),QS=G(()=>{dt(),n_=new pc,wM=new ta,fO=new bt,Xv=(t,e,i,r,s=!1,n=t)=>{let a=e,o=n.matrixWorld;if(a.boundingSphere===null&&a.computeBoundingSphere(),wM.copy(a.boundingSphere),wM.applyMatrix4(o),i.ray.intersectsSphere(wM)===!1||(fO.copy(o).invert(),n_.copy(i.ray).applyMatrix4(fO),a.boundingBox!==null&&n_.intersectsBox(a.boundingBox)===!1))return;let l,u,h,d,c,p,m=a.index,f=a.attributes.position,g=a.drawRange;if(s===!1){for(c=Math.max(0,g.start),p=Math.min(m.count,g.start+g.count);c<p;c+=3)if(u=m.getX(c),h=m.getX(c+1),d=m.getX(c+2),l=y(t,i,n_,f,u,h,d),l)return l.faceIndex=Math.floor(c/3),void r.push(l)}else{let v=a.attributes.position,b=new P,_=new P,x=new P,S=new P,w=2,T=1/((n.scale.x+n.scale.y+n.scale.z)/3),A=T*T;for(let M=Math.max(0,g.start),C=Math.min(v.count,g.start+g.count)-1;M<C;M+=w){if(b.fromBufferAttribute(v,M),_.fromBufferAttribute(v,M+1),n_.distanceSqToSegment(b,_,S,x)>A)continue;S.applyMatrix4(n.matrixWorld);let R=i.ray.origin.distanceTo(S);R<i.near||R>i.far||r.push({distance:R,point:x.clone().applyMatrix4(n.matrixWorld),object:t})}}function y(v,b,_,x,S,w,T){let A=new P,M=new P,C=new P,R=new P,O=new P;if(A.fromBufferAttribute(x,S),M.fromBufferAttribute(x,w),C.fromBufferAttribute(x,T),_.intersectTriangle(A,M,C,!1,R)===null)return null;O.copy(R),O.applyMatrix4(v.matrixWorld);let N=b.ray.origin.distanceTo(O);return N<b.near||N>b.far?null:{faceIndex:1,distance:N,point:O.clone(),object:v}}}}),D5=G(()=>{dt(),ZS(),QS(),vY=new P(1,1,1),gO=new P,bY=new P,yO=new Me,Ov=class extends $v(qpt){constructor(t,e=15){super(e),this.object=t,this.dummy=new Hv,this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${t.uuid}`,this.matrix=this.dummy.matrixWorld,this.matrixAutoUpdate=!1,this.object.isBone&&(this.visible=!1)}raycast(t,e){Xv(this.object,Ov.geometryHelper,t,e,!1,this.dummy)}update(){}updateMatrix(){}updateMatrixWorld(t){this.object.matrixWorld.decompose(gO,yO,bY),this.matrix.compose(gO,yO,vY),super.updateMatrixWorld(t)}updateWorldMatrix(t,e){}}}),HMt=G(()=>{dt(),Wc=new P,qc=new P,dd=new bt,vO=[new P(-1,1,1),new P(-1,-1,1),new P(1,-1,1),new P(1,1,1),new P(-1,1,-1),new P(-1,-1,-1),new P(1,-1,-1),new P(1,1,-1)],_Y=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],xY=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],bO=(t,e,i)=>{t.updateEntityBoxSize(Wc,qc),dd.copy(e).multiply(t.matrixWorld),qc.x===0&&qc.y===0&&qc.z===0?i.push(new P(Wc.x,Wc.y,Wc.z).applyMatrix4(dd)):vO.forEach(r=>{i.push(r.clone().multiply(qc).add(Wc).applyMatrix4(dd))})},_U=class extends pr{constructor(){super(...arguments),this.matrix=new bt,this.vertices=[],this.faces=[],this.edges=[],this.centerEdges=[]}copy(t){return super.copy(t),this.matrix.copy(t.matrix),this.vertices=t.vertices.map(e=>e.clone()),this.faces=t.faces.map(e=>e.clone()),this.edges=t.edges.map(e=>e.clone()),this.centerEdges=t.centerEdges.map(e=>e.clone()),this}setFromObjectSize(t,e=!1){t.updateWorldMatrix(!1,e),this.makeEmpty(),this.matrix.copy(t.matrixWorld);let i=new bt().copy(t.matrixWorld).invert();return this.expandByObjectSize(t,i,e)}expandByObjectSize(t,e,i=!1){let r=[];if(i===!0){let s=[];t.traverseEntity(n=>{if(n.visible||n.cloner&&n.data.visible){if(!("geometry"in n))return dd.copy(e).multiply(n.matrixWorld),void s.push(new P().applyMatrix4(dd));bO(n,e,r)}}),r.length===0&&r.push(...s)}else bO(t,e,r);return this.setFromPoints(r)}getCenter(t){return(t=super.getCenter(t)).applyMatrix4(this.matrix),t}getPositionToCenter(t){return(t=super.getCenter(t)).applyMatrix4(dd.copy(this.matrix).setPosition(0,0,0)),t}computeVertices(){this.getSize(qc).multiplyScalar(.5),this.getCenter(Wc),dd.copy(this.matrix).setPosition(Wc),this.vertices=vO.map(t=>t.clone().multiply(qc).applyMatrix4(dd))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=_Y.map(([t,e])=>new yl(this.vertices[t],this.vertices[e])),this.centerEdges=this.edges.map(t=>t.getCenter(new P))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=xY.map(([t,e])=>this.vertices[t].clone().add(this.vertices[e]).multiplyScalar(.5))}}}),bR=G(()=>{bc={Cloner:null,changeEntityProptotype:()=>{},createEntity:()=>{}}});function q2(t){return t?.isParticleSystem===!0}function Jg(t){return t?.isHairSystem===!0}function Cc(t){return t?.isShapeBlendEntity===!0}function N5(t){return t?.isPathObject===!0}function jo(t){return t?.isObject2D===!0}function Ya(t){return t?.isUIObject===!0}function H1(t){return t?.isCloner===!0}function Sg(t){return t?.isClone===!0}function NP(t){return t?.isComponentObject===!0}var ns=G(()=>{});function Or(t){pG.add(t)}function Nn(t,e){let i=`${t}:${e}`;SU.has(i)||SU.add(i)}function _R(t,e){mG.set(t,e)}function _O(t){return mG.get(t)}function Yv(t,e){fG.set(t,e)}function xO(t){return fG.get(t)}function xU(t,e){gG.set(t,e)}function Qmt(t){return gG.get(t)}function wU(){return O5}var pG,SU,mG,fG,gG,O5,xR,Ii=G(()=>{pG=new Set,SU=new Set,mG=new Map,fG=new Map,gG=new Map,O5=null,xR=null});function Jmt(t){let e=t.elements;Uh.set(e[0],e[1],e[2]),jh.set(e[4],e[5],e[6]),ku.set(e[8],e[9],e[10])}function tft(){let t=Math.max(Uh.lengthSq(),jh.lengthSq(),ku.lengthSq());Uh.lengthSq()>$w*t?ml.copy(Uh).normalize():ml.set(1,0,0),fl.crossVectors(ku,ml),fl.lengthSq()<=$w*t&&(fl.copy(jh).addScaledVector(ml,-jh.dot(ml)),fl.lengthSq()<=$w*t&&function(e,i){e.set(1,0,0).cross(i),e.lengthSq()<=$w&&e.set(0,1,0).cross(i),e.normalize()}(fl,ml)),fl.normalize(),Tg.crossVectors(ml,fl)}function eft(t){return Jmt(t),tft(),ift.makeBasis(ml,fl,Tg)}var Uh,jh,ku,ml,fl,Tg,ift,$w,Xw,SM,Mg,I5,rft=G(()=>{dt(),Uh=new P,jh=new P,ku=new P,ml=new P,fl=new P,Tg=new P,ift=new bt,$w=1e-12,Xw=.01}),JS=G(()=>{dt(),rft(),SM=new bt,(Mg||(Mg={})).is=function(t){return t&&t.__isSPEObject},I5=t=>class extends t{constructor(){super(...arguments),this.previousModelViewMatrix=new bt,this.copyPreviousMatrix=!0,this.hiddenMatrix=new bt,this.pivotMatrix=new bt,this.matrixWorldRigid=new bt,this.shearScale=new bt,this.shearScaleInv=new bt}get __isSPEObject(){return!0}getPhysicsLocalMatrix(e){return!!this.rigidBody?.isDynamic()&&(e.copy(this.matrixWorld),this.hasNonUniformScale&&e.multiply(this.shearScaleInv),this.parent&&e.premultiply(SM.copy(this.parent.matrixWorld).invert()),e.premultiply(SM.copy(this.hiddenMatrix).invert()),e.multiply(SM.copy(this.pivotMatrix).invert()),!0)}isDescendantOf(e){e instanceof dr&&(e=e.uuid);let i=this;for(;i.parent;){if(i.parent.uuid===e)return!0;i=i.parent}return!1}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorld.multiply(this.pivotMatrix),this.matrixWorldNeedsUpdate=!1,e=!0);for(let i of this.children)i.updateMatrixWorld(e)}updateWorldMatrix(e,i){let r=this.parent;if(e&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorld.multiply(this.pivotMatrix),i)for(let s of this.children)s.updateWorldMatrix(!1,!0)}traverseChildren(e,i=0){for(let r of this.children)Mg.is(r)&&r.traverseObject(e,i+1)}traverseObject(e,i=0){if(e(this,i)!==!0)for(let r of this.children)Mg.is(r)&&r.traverseObject(e,i+1)}updateMatrixWorldRigid(){this.hasNonUniformScale=function(e,i,r){return Jmt(e),tft(),i.makeBasis(ml,fl,Tg),r.set(ml.dot(Uh),ml.dot(jh),ml.dot(ku),0,fl.dot(Uh),fl.dot(jh),fl.dot(ku),0,Tg.dot(Uh),Tg.dot(jh),Tg.dot(ku),0,0,0,0,1),function(){let s=Uh.length(),n=jh.length(),a=ku.length(),o=Math.max(s,n,a);if(o-s>Xw||o-n>Xw||o-a>Xw)return!0;let l=Xw*o*o;return Math.abs(Uh.dot(jh))>l||Math.abs(Uh.dot(ku))>l||Math.abs(jh.dot(ku))>l}()}(this.matrixWorld,this.matrixWorldRigid,this.shearScale),this.matrixWorldRigid.copyPosition(this.matrixWorld),this.shearScaleInv.copy(this.shearScale).invert()}attach(e,i){this.updateWorldMatrix(!0,!1);let r=new bt().copy(this.matrixWorld).invert();return e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),r.multiply(e.parent.matrixWorld)),"hiddenMatrix"in e&&e.hiddenMatrix instanceof bt?e.hiddenMatrix.premultiply(r):e.applyMatrix4(r),e.updateWorldMatrix(!1,!1),this.add(e),i!==void 0&&(this.children.pop(),this.children.splice(i,0,e)),this}copy(e,i=!1){return super.copy(e,i),this.hasNonUniformScale=e.hasNonUniformScale,this}onAfterRender(e,i,r,s,n,a){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}}});function wY(t,e,i){return Xp.subVectors(e,t),DS.subVectors(e,i),Xp.cross(DS).length()<=H2}function sft(t){let e=AU.get(t.points);if(e!==void 0&&e.isClosed===t.isClosed)return e.curve;let i=function(r){let s=r.points,n=[s[0]],a=[new P(...s[0].data.position)];rg.copy(a[0]);for(let y=0;y<s.length-1;y++)Xp.fromArray(s[y].data.position),DS.fromArray(s[y+1].data.position),T1.subVectors(Xp,rg),M1.subVectors(Xp,DS),T1.cross(M1).length()>H2&&(n.push(s[y]),a.push(new P().copy(Xp)),rg.copy(Xp));let o=s[s.length-1];n.push(o),a.push(new P(...o.data.position));let l=r.isClosed,u=n.length-(l?0:1),h=n.length,d=[],c=[];for(let y=0;y<h;y++){let v=n[y].data;d.push(new P(...v.controlPrevious.position)),c.push(new P(...v.controlNext.position))}let p=[];for(let y=0;y<u;y++){let v=y===h-1?0:y+1;p.push(wY(a[y],c[y],a[v])&&wY(a[y],d[v],a[v]))}let m=[];for(let y=0;y<h;y++){let v=n[y].data,b=a[y],_={position:b,prevDir:void 0,nextDir:void 0,controlPrevious:d[y],controlNext:c[y],tan:void 0,baseRoundness:v.roundness,removedLength:0};if(m.push(_),v.roundness===0||!l&&(y===0||y===h-1))continue;let x=l&&y==0?h-1:y-1,S=l&&y==h-1?0:y+1,w=new P().subVectors(a[x],b).normalize(),T=new P().subVectors(a[S],b).normalize();_.prevDir=w,_.nextDir=T;let A=p[l&&y===0?h-1:y-1],M=p[y];if(A&&M){sg.addVectors(w,T).normalize();let C=rg.crossVectors(sg,w).length()/w.dot(sg);_.tan=C,_.removedLength=v.roundness/C}}for(let y=0;y<u;y++){let v=l&&y===h-1?0:y+1,b=m[y],_=m[v];if(b.removedLength!==0||_.removedLength!==0){let x=b.position.distanceTo(_.position);b.removedLength=Math.min(b.removedLength,x/2),_.removedLength=Math.min(_.removedLength,x/2)}}let f=new Array(2*h).fill(null);for(let y=0;y<u;y++){let v=l&&y===h-1?0:y+1,b=m[y],_=m[v],x=null;if(p[y]){let S=b.position.clone(),w=_.position.clone();(b.removedLength!==0||_.removedLength!==0)&&(b.nextDir&&S.add(rg.copy(b.nextDir).setLength(b.removedLength)),_.prevDir&&w.add(rg.copy(_.prevDir).setLength(_.removedLength))),S.distanceTo(w)>H2&&(x=new k2(S,S.clone().lerp(w,.3),w.clone().lerp(S,.3),w))}else b.position.distanceTo(_.position)>H2&&(x=new k2(b.position,b.controlNext,_.controlPrevious,_.position));f[2*y+1]=x}for(let y=0;y<h;y++){let v=m[y];if(v.removedLength===0)continue;let b=v.position,_=v.prevDir.clone().multiplyScalar(v.removedLength).add(b),x=v.nextDir.clone().multiplyScalar(v.removedLength).add(b),S=v.tan*v.removedLength;sg.addVectors(v.prevDir,v.nextDir).normalize(),T1.copy(_).lerp(x,.5);let w=_.distanceTo(x)/2;MU.copy(sg).multiplyScalar(Math.sqrt(Math.pow(S,2)-Math.pow(w,2))).add(T1),OP.copy(sg).multiplyScalar(-S).add(MU);let T=b.distanceTo(OP)/b.distanceTo(T1);M1.copy(v.prevDir).multiplyScalar(T*b.distanceTo(_)).add(b),TU.copy(M1).lerp(OP,2);let A=_.clone().lerp(M1,4/3),M=x.clone().lerp(TU,4/3);f[2*y]=new k2(_,A,M,x)}let g=new nft;for(let y=0;y<f.length;y++){let v=f[y];v&&g.add(v)}return g}(t);return AU.set(t.points,{isClosed:t.isClosed,curve:i}),i}var nft,H2,Xp,DS,rg,sg,T1,OP,M1,TU,MU,AU,A1,CU,IP,aft,oft,lft,Mi,Vu,SY,TY,a_,wO,TM,SO,TO,B5,EU,r0,zu,hft=G(()=>{dt(),nft=class extends _8{constructor(){super()}getPoints(t=12){let e,i=[],r=this.getCurveLengths(),s=r[r.length-1]/r.length;for(let n=0,a=this.curves;n<a.length;n++){let o=a[n],l=n===0?r[n]:r[n]-r[n-1],u=Math.ceil(t*l/s),h=o.getPoints(u);for(let d=0;d<h.length;d++){let c=h[d];e&&e.equals(c)||(i.push(c),e=c)}}return this.autoClose&&i.length>1&&!i[i.length-1].equals(i[0])&&i.push(i[0]),i}},H2=.001,Xp=new P,DS=new P,rg=new P,sg=new P,T1=new P,OP=new P,M1=new P,TU=new P,MU=new P,AU=new WeakMap}),$Mt=G(()=>{dt(),A1=new bt,CU=new Me,IP=new Me,aft=new Qi,oft=new P,lft=new P(0,1,0)}),vo=G(()=>{dt(),ke(),HMt(),Fi(),bR(),ns(),Ii(),JS(),hft(),$Mt(),ir(),(Mi||(Mi={})).is=function(t){return t&&t.__isEntity},Vu=t=>Mi.is(t),SY={type:"completeState",isfromEntity:!0},TY=["x","y","z"],a_=new P,wO=new P(1,1,1),TM=new Me,SO=new Qi,TO=new bt,B5=t=>class extends I5(t){constructor(){super(...arguments),this.raycastLock=!1,this.scaleLock=!1,this.disposed=!1,this.stateSelection=null,this.destroyedInAction=!1,this.instances=[],this.prevState=null,this.currentState=null,this.currentAnimationAction=null,this.reversibleToState=null,this.transitionState={settled:!0,state:null},this.currentTransitionEvent=null,this.previousAction=null,this._singleBBox=new _U,this._recursiveBBox=new _U,this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0,this._needApplyPathSnapping=!0,this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(e){let i=this.children[e];if(Mi.is(i))return i}entityChildrenCount(){let e=this.children.length;for(;e--;)if(Mi.is(this.children[e]))return e+1;return 0}get isConcreteEntity(){return typeof this.identity=="string"}get isVirtualEntity(){return typeof this.identity!="string"}get isInstanceRoot(){return this.isConcreteEntity&&this.data.type==="Instance"}nearestInstanceSelfOrParent(){let e=this;for(;e.data.type!=="Instance";){let i=e.parent;if(!Mi.is(i))return;e=i}return e}forInstancesRec(e){this.instances.forEach(i=>{i.disposed||e(i),i.forInstancesRec(e)})}super_Entity(e,i){typeof e=="string"&&(this.uuid=e),this.identity=e,this.data=i,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(e,i,r=!1){if(this.data.states.length!==0||r){for(let s of this.data.states)em.toOps(this.data,s.data).forEach(n=>{let a=K4.replaceProps(n,this.data);this.dataPatched=this.data,this.updateByPatchedOp(a,this.data,i)});if(e!==null){let s=this.data.states.data(e);s&&(this.dataPatched=em.patch(this.data,s),em.toOps(this.data,s).forEach(n=>{this.updateByPatchedOp(n,this.dataPatched,i)}))}r&&this.updateTransformState(this.dataPatched,i),this.stateSelection=e,this.updatePathSnapping(this.dataPatched.pathSnapping)}}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges(),this._singleBBox.computeFaces()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges(),this._recursiveBBox.computeFaces()),this._recursiveBBox}updateEntityBoxSize(e,i){e.setScalar(0),i.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(e=>{Vu(e)&&e.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(e=>{e.resetBBoxNeedsUpdateSelf()})}find(e){let i;return this.traverseEntity(r=>{r.uuid===e&&(i=r)}),i}traverseSortNextHelper(){let e=this.parent;if(e){let i=e.children,r=i.indexOf(this)+1;if(Mi.is(i[r]))return i[r];if(Mi.is(e))return e.traverseSortNextHelper()}}sortNext(){let e=this.children;return this.children.length>0&&Mi.is(this.children[0])?e[0]:this.traverseSortNextHelper()}goUp(e){let i=this;for(;e>0&&i!==null;)i=i.parent,e-=1;return i}hasAnccestorOrSelf(e){return this===e||this.hasAnccestor(e)}hasAnccestor(e){let i=this.parent;for(;i;){if(e===i)return!0;i=i.parent}return!1}countToAccestor(e){let i=0,r=this;for(;r!==e;){if(r===null)return-1;r=r.parent,i+=1}return i}forEachEntity(e){for(let i of this.children)Vu(i)&&e(i)}traverseEntityAncestors(e){this.traverseAncestors(i=>{Mi.is(i)&&e(i)})}traverseConcreteEntity(e,i=0){if(e(this,i)!==!0)for(let r of this.children)Vu(r)&&r.isConcreteEntity&&r.traverseEntity(e,i+1)}traverseEntity(e,i=0){if(e(this,i)!==!0)for(let r of this.children)Vu(r)&&r.traverseEntity(e,i+1)}traverseVisibleEntity(e){e(this);for(let i of this.children)Vu(i)&&i.visible&&i.traverseVisibleEntity(e)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}updateMatrixWorld(e){super.updateMatrixWorld(e),this.dispatchEvent({type:"updateMatrixWorld"})}copy(e,i=!1){return super.copy(e,i),this.dataPatched=e.dataPatched,this.raycastLock=e.raycastLock,this.scaleLock=e.scaleLock,this.hiddenMatrix.copy(e.hiddenMatrix),this}hasEntityChild(){return this.children.some(e=>Vu(e))}isAncestorOf(e){if(this.uuid===e)return!1;let i=!1;return this.traverseEntity(r=>{r.uuid===e&&(i=!0)}),i}toObjectTransformState(e=[]){return this.updateWorldMatrix(!0,!1),B8({position:this.position.toArray(),rotation:[this.rotation.x*qt.RAD2DEG,this.rotation.y*qt.RAD2DEG,this.rotation.z*qt.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray(),pivot:[0,0,0],pivotRotation:[0,0,0]},e)}getTransformValues(e,i,r){return i[e].map((s,n)=>r?.shared.getVariable(s,[this.uuid,e,TY[n]])??s)}updateTransformState(e,i){let r=!1;if(e.position&&(this.position.fromArray(this.getTransformValues("position",e,i)),r=!0),e.rotation&&(a_.fromArray(this.getTransformValues("rotation",e,i)).multiplyScalar(qt.DEG2RAD),this.rotation.setFromVector3(a_),r=!0),e.scale&&(this.scale.fromArray(this.getTransformValues("scale",e,i)),r=!0),e.hiddenMatrix!==void 0&&(r=!0,this.hiddenMatrix.fromArray(e.hiddenMatrix??lv.identity)),e.pivot!==void 0||e.pivotRotation!==void 0){if(r=!0,e.pivot!==void 0&&e.pivotRotation!==void 0)this.pivotMatrix.compose(a_.fromArray(e.pivot).negate(),TM.setFromEuler(SO.fromArray(e.pivotRotation.map(s=>s*qt.DEG2RAD))).invert(),wO);else if(e.pivot!==void 0)this.pivotMatrix.setPosition(-e.pivot[0],-e.pivot[1],-e.pivot[2]);else if(e.pivotRotation!==void 0){let s=a_.setFromMatrixPosition(this.pivotMatrix);TM.setFromEuler(SO.fromArray(e.pivotRotation.map(n=>n*qt.DEG2RAD))).invert(),this.pivotMatrix.compose(s,TM,wO)}}return r&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(s=>{s.invalidateClonerTransform(this)})),e.position&&e.rotation&&e.scale&&e.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),r}onVariableUpdate(e=!1){e?this.resetBBoxNeedsUpdate():(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(i=>{i.invalidateClonerTransform(this)}),this.requestRender())}dispose(){this.disposed=!0,this.cloner&&(this.cloner.dispose(),this.cloner=void 0)}disposeChildrenRecursively(){for(let e of this.children)Mi.is(e)&&e.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(e=>{Mi.is(e)&&e.disposeRecursively()})}toState(e=[]){return B8({name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(e)},e)}updateByObjUpdateOp(e,i){e!==void 0&&this.updateByOp({type:0,props:e,path:[]},{...this.data,...e},i,!1)}updateByOp(e,i,r,s){let n=this.data;this.data=i;let a=e,o=er(e.path,["states","*"]);if(o!==null){if(e.type===0){let[l]=o;if(this?.stateSelection===l){let u={...e.props};if(delete u.name,Object.values(e.props).some(h=>h===void 0)){let h=this.data;if(h!==void 0){let d=Dn.zoom(h,e.path.slice(2));if(d)for(let c in e.props)e.props[c]===void 0&&c in d&&(u[c]=d[c])}}a={...e,props:u,path:e.path.slice(2)}}}}else if(e.type===0){let l=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(l!==void 0){if(e.props.name!==void 0&&l.name){let{name:h,...d}=l;l=d}if(e.props.material!==void 0&&"material"in l){let{material:h,...d}=l;l=d}let u=Dn.removeOverridden(e.path,e.props,l);a={...e,props:u}}}if(this.updateByPatchedOpBase(a,em.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),r),er(e.path,["overrides"])){let l=[],u=[...e.path];for(l.push(u[1]),u.splice(0,2);u.length>0&&u[0]==="descendants";)l.push(u[1]),u.splice(0,2);if(l[l.length-1]===void 0){if(e.type===0)for(let h of Object.keys(e.props)){l[l.length-1]=h;let d=r.scene.findInstance([this.uuid,...l]);d&&(d.overrideData=e.props[h],d.updateState(lm.apply(d.component.data,d.overrideData),r))}}else{let h=r.scene.findInstance([this.uuid,...l]);if(h){let d=Dn.zoom(h.component.data,u);if((e={...e,path:u}).type===0){let c=e.props;if(d)for(let[p,m]of Object.entries(e.props))m===void 0&&(c===e.props&&(c={...e.props}),c[p]=d[p]);e={...e,props:c}}h.overrideData=mR.resolve(i.overrides,l),h.updateByOp(e,ea.applySimple(h.data,e),r,!1)}}}else if(this.instances.length>0){let l;if(e.path.length===0&&e.type===0){let u;for(let h of yc.rootOverrideProps)h in e.props&&(u===void 0&&(u={}),u[h]=e.props[h]);u&&(l={...e,props:u})}else for(let u of yc.rootOverrideProps)if(er(e.path,[u])){l=e;break}l!==void 0&&this.instances.forEach(u=>{if(u.isInstanceRoot){let h=lm.filterOp(u.overrideData,l);h&&u.updateByOp(h,ea.applySimple(u.data,h),r,!0)}}),this.instances.forEach(u=>{if(!u.isInstanceRoot){let h=lm.filterOp(u.overrideData,e);if(h){let d;d=n===u.data&&e===h?i:ea.applySimple(u.data,h),u.updateByOp(h,d,r,!0)}}})}}updateByPatchedOpBase(e,i,r){if(this.dataPatched=i,e.path.length===0&&e.type===0)e.props.type!==void 0&&!Zg.is(e.props.type)&&bc.changeEntityProptotype(this,i,r);else if(e.path.length===1&&e.path[0]==="geometry"&&e.type===0&&"type"in e.props){bc.changeEntityProptotype(this,i,r);for(let s of this.children)Mi.is(s)&&s.updateVisible(r.scene)}this.updateByPatchedOp(e,i,r)}updateByPatchedOp(e,i,r){if(e.path.length===0&&e.type===0?this.updateState(e.props,r):e.type===0&&("resolutionLevel"in e.props||"useChildrenColors"in e.props)&&this.updateState(i,r),e.path[0]==="morphTargetInfluences"&&e.type===0){let s=i.morphTargetInfluences.get(e.path[1])?.data.name;s&&this.updateMorphInfluences(s,r.shared.getVariable(e.props.value,[this.uuid,"morphTargetInfluences",s]))}if(er(e.path,["pathSnapping"])!==null&&this.updatePathSnapping(i.pathSnapping),er(e.path,["cloner"])!==null){let s=ea.drop(e,1);s.path.length===0&&s.type===0&&s.props.disabled===!0?this.setFromClonerState(null,r):this.cloner?this.cloner.updateState(i.cloner,r):(this.setFromClonerState(i.cloner,r),this.expandCloner(r)),this.updateVisible(r.scene)}}updatePathSnapping(e=this.dataPatched.pathSnapping){this._updatedPathSnapping=e,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(e){if(this._needApplyPathSnapping===!1)return;let i=this._updatedPathSnapping?.pathId??this.dataPatched.pathSnapping.pathId,r=this._updatedPathSnapping?.slide??this.dataPatched.pathSnapping.slide??0,s=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset??0,n=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(i===null)return;let a=e.find(i);if(!a)return;this._needApplyPathSnapping=!1;let o=a.data;if(o.geometry.path.points.length<=1)return;let l=sft(o.geometry.path),u=function(p){let m=p%1;return m<0?m+1:m===0&&p>0?1:m}(r+s),h=null;try{h=l.curves.length?l.getPointAt(u):null}catch{}if(h===null)return;a.updateMatrixWorld();let d=this.parent?TO.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix):TO.copy(this.hiddenMatrix),c=function(p,m,f,g){CU.setFromRotationMatrix(A1.extractRotation(g));let y=p.clone().applyMatrix4(A1.copy(g).invert().multiply(f));if(m===null)IP.setFromRotationMatrix(A1.extractRotation(f));else{let v=m.clone().applyMatrix4(A1.extractRotation(f));IP.setFromRotationMatrix(A1.lookAt(oft.set(0,0,0),v,lft))}return{position:y,rotation:new P().setFromEuler(aft.setFromQuaternion(CU.invert().multiply(IP))).multiplyScalar(qt.RAD2DEG)}}(h,n==="tangential"?l.getTangentAt(u):null,a.matrixWorld,d);this.updateTransformState({position:c.position.toArray(),rotation:c.rotation.toArray()}),this.traverseEntity(p=>{p._cameraType&&p.dispatchEvent(SY)})}updateVisible(e){if(this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0),!e)return;let i=!1;this.traverseEntity(r=>{if(r.data.type==="Splat")return i=!0,!0}),i&&e.reloadSplats()}updateState_Entity(e,i){e.name!==void 0&&(this.name=e.name),e.raycastLock!==void 0&&(this.raycastLock=e.raycastLock),e.visible!==void 0&&(this.updateVisible(i?.scene),this.resetBBoxNeedsUpdate()),i&&"cloner"in e&&e.cloner!==void 0&&(this.setFromClonerState(e.cloner,i),this.updateVisible(i.scene)),this.updateTransformState(e,i)}get attachedSurfaceCloners(){return this.children.filter(e=>H1(e)&&e.parameters.type==="toObject")}setFromClonerState(e,i){if(!this.disposed)if(e===null||e.disabled)this.cloner&&this.cloner.dispose(),this.cloner=void 0;else if(this.cloner===void 0){if(bc.Cloner===null)return void Nn("cloners","a cloner");this.cloner=new bc.Cloner(this,e),i.scene.addPendingExpandCloner(this)}else this.cloner.updateState(e,i)}expandCloner(e){!this.disposed&&this.cloner&&this.cloner.expandClones(e)}invalidateClonerTransform(e){this.cloner&&this.cloner.invalidateTransform(e)}requestRender(){this.dispatchEvent({type:"requestRender"})}}}),s0=G(()=>{dt(),vo(),(EU||(EU={})).is=t=>"objectHelper"in t,r0=(t,e)=>class extends B5(t){constructor(){super(...arguments),this.objectHelper=new e(this),this.gizmos={}}get geometryHelper(){return e.geometryHelper}raycast(i,r){this.objectHelper.raycast(i,r)}showGizmos(){for(let i in this.gizmos){let r=this.gizmos[i];r instanceof SS&&(r.visible=!0)}}updateEntityBoxSize(i,r){this.objectHelper.visible&&this.geometryHelper instanceof Zh?(i.setScalar(0),r.set(this.geometryHelper.parameters.width,this.geometryHelper.parameters.height,this.geometryHelper.parameters.height).multiplyScalar(.5)):super.updateEntityBoxSize(i,r)}hideGizmos(){for(let i in this.gizmos){let r=this.gizmos[i];r instanceof SS&&(r.visible=!1)}}}}),V5=G(()=>{dt(),D5(),s0(),zu=class extends r0(Hv,Ov){constructor(t,e){super(),this.super_Entity(t,e),this.objectHelper.update(),this.data.type==="Empty"&&(this.objectHelper.visible=!1)}updateState(t,e){this.updateState_Entity(t,e),"buffer"in t&&Object.keys(t).length===1&&e.scene.reloadSplats()}}});function hh(t,e,i,r,s,n,a){Yw.set(s,n,a).unproject(r);let o=e[t];if(o!==void 0){let l=i.getAttribute("position");for(let u=0,h=o.length;u<h;u++)l.setXYZ(o[u],Yw.x,Yw.y,Yw.z)}}var Yw,Xo,MY,uft,XMt=G(()=>{dt(),ZS(),QS(),Yw=new P,Xo=new vg,MY=class extends b1{constructor(t){let e=new ye,i=new zh({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],s=[],n={},a=new ae(15711266),o=new ae(15711266),l=new ae(2857471);function u(d,c,p){h(d,p),h(c,p)}function h(d,c){r.push(0,0,0),s.push(c.r,c.g,c.b),n[d]===void 0&&(n[d]=[]),n[d].push(r.length/3-1)}u("n1","n2",a),u("n2","n4",a),u("n4","n3",a),u("n3","n1",a),u("f1","f2",a),u("f2","f4",a),u("f4","f3",a),u("f3","f1",a),u("n1","f1",a),u("n2","f2",a),u("n3","f3",a),u("n4","f4",a),u("p","n1",o),u("p","n2",o),u("p","n3",o),u("p","n4",o),u("u1","u2",l),u("u2","u3",l),u("u3","u1",l),e.setAttribute("position",new fe(r,3)),e.setAttribute("color",new fe(s,3)),super(e,i),this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=n,this.update()}update(){let t=this.geometry,e=this.pointMap;Xo.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let i=.8;hh("n1",e,t,Xo,-1,-1,i),hh("n2",e,t,Xo,1,-1,i),hh("n3",e,t,Xo,-1,1,i),hh("n4",e,t,Xo,1,1,i);let r=i;hh("f1",e,t,Xo,-1,-1,r),hh("f2",e,t,Xo,1,-1,r),hh("f3",e,t,Xo,-1,1,r),hh("f4",e,t,Xo,1,1,r);let s=r;hh("u1",e,t,Xo,.35,1.1,s),hh("u2",e,t,Xo,-.35,1.1,s),hh("u3",e,t,Xo,0,1.55,s),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}},uft=class extends $v(MY){constructor(t){super(t),this.object=t,this.name=`CombinedCameraHelper: ${t.uuid}`}updateMatrixWorld(t){super.updateMatrixWorld(t),this.updateTarget()}updateTarget(){let t=this.object.getTarget();this.updateWorldMatrix(!0,!1),this.worldToLocal(t)}raycast(t,e){Xv(this.object,this.geometry,t,e,!0)}}});function AY(t){return 1-Math.pow(1-t,3)}var Jm,MM,AM,CM,k0,EM,uu,ln,Qh=G(()=>{dt(),XMt(),ke(),s0(),ir(),Jm=new P,MM=new P,AM=new Me,CM=new P,k0=new P,EM=new P,uu=class extends r0(vg,uft){constructor(t="",e={...G2.defaultData,name:""}){super(),this._cameraType="OrthographicCamera",this.targetOffset=gc.DefaultTargetOffset,this.isUpVectorFlipped=!1,this.angleOffsetFromUp=0,this.wasMovedByUser=!1,this.wasMovedBySwitchCameraAction=!1,this._createdAt=typeof performance<"u"?performance.now():0,this._tickProjectionTransition=()=>{let s=this._projectionTransition;if(s===void 0)return;if(this.disposed)return void this._endProjectionTransition();s.raf=requestAnimationFrame(this._tickProjectionTransition);let n=uu.projectionTransitionRequestRender??s.requestRender;this.updateProjectionMatrix(),n?.()},this.super_Entity(t,e),this.previousProjectionMatrix=new bt,this.matrixAutoUpdate=!0,this.width=window.innerWidth,this.height=window.innerHeight;let i=this.width,r=this.height;this.orthoCamera=new Rv(-.5*i,.5*i,.5*r,-.5*r,-5e4,1e4),this.perspCamera=new kh(45,i/r,50,1e4),this.left=this.orthoCamera.left,this.right=this.orthoCamera.right,this.top=this.orthoCamera.top,this.bottom=this.orthoCamera.bottom,this.far=this.orthoCamera.far,this.view=this.orthoCamera.view,this.aspect=this.perspCamera.aspect,this.focus=this.perspCamera.focus,this.filmGauge=this.perspCamera.filmGauge,this.filmOffset=this.perspCamera.filmOffset,this.objectHelper.update()}static withoutProjectionTransition(t){let e=uu.projectionTransitionsEnabled;uu.projectionTransitionsEnabled=!1;try{return t()}finally{uu.projectionTransitionsEnabled=e}}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}set fov(t){this.perspCamera.fov=t}get fov(){return this.perspCamera.fov}setNear(t,e){t==="PerspectiveCamera"?this.perspCamera.near=e:this.orthoCamera.near=e}setZoom(t,e){e>=0&&(t==="PerspectiveCamera"?this.perspCamera.zoom=e:this.orthoCamera.zoom=e)}set cameraType(t){t==="PerspectiveCamera"?this.toPerspective():t==="OrthographicCamera"&&this.toOrthographic()}get near(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.near:this.orthoCamera.near}set near(t){this._cameraType==="PerspectiveCamera"?this.perspCamera.near=t:this.orthoCamera.near=t}get zoom(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(t){t>=0&&(this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom=t:this.orthoCamera.zoom=t)}lookAt(t,e,i){typeof t=="number"&&(t=new P(t,e,i)),super.lookAt(t),this.getWorldPosition(Jm),this.targetOffset=Jm.distanceTo(t)}getTarget(t=new P){return this.getWorldDirection(MM),this.getWorldPosition(Jm),MM.multiplyScalar(this.targetOffset),t.copy(Jm).add(MM),t}getDistanceToTarget(){let t=this.getTarget();return this.getWorldPosition(Jm),Jm.distanceTo(t)}updateUp(){this.getWorldQuaternion(AM),CM.set(0,0,1).applyQuaternion(AM),k0.copy(dr.DEFAULT_UP),this.isUpVectorFlipped&&k0.negate(),k0.applyQuaternion(AM),EM.copy(dr.DEFAULT_UP).projectOnPlane(CM),this.angleOffsetFromUp=EM.angleTo(k0),this.angleOffsetFromUp*=EM.cross(k0).dot(CM)>=0?1:-1}updateTransformState(t,e){let i=super.updateTransformState(t,e);return t.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=t.isUpVectorFlipped),this.updateUp(),i}getViewFrontToObject(t){let e=t.getWorldPosition(new P),i=t.getWorldDirection(new P).multiplyScalar(this.targetOffset);return{position:e.clone().add(i),target:e}}getViewToTarget(t){let e=this.getWorldDirection(new P).multiplyScalar(this.targetOffset);return{position:t.clone().sub(e),target:t}}getViewToObject(t){let e=new P;return t.getWorldPosition(e),this.getViewToTarget(e)}setViewplaneSize(t,e,i=!1){if(this.aspect=t/e,i){let r=t>e?this.aspect:1,s=t>e?1:this.aspect;this.left=-395*r,this.right=395*r,this.top=1/s*395,this.bottom=1/s*-395}else this.left=.5*-t,this.right=.5*t,this.top=.5*e,this.bottom=.5*-e;this.updateProjectionMatrix()}copyViewPlaneSize(t){this.aspect=t.aspect,this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.updateProjectionMatrix()}toOrthographic(){this.orthoCamera.left=this.left,this.orthoCamera.right=this.right,this.orthoCamera.top=this.top,this.orthoCamera.bottom=this.bottom,this.orthoCamera.view=this.view,this.orthoCamera.far=this.far,this.orthoCamera.updateProjectionMatrix(),this.projectionMatrix=this.orthoCamera.projectionMatrix,this.projectionMatrixInverse=this.orthoCamera.projectionMatrixInverse,this._cameraType="OrthographicCamera",this._applyProjectionTransition(),this.objectHelper&&this.objectHelper.update()}toPerspective(){this.perspCamera.aspect=this.aspect,this.perspCamera.fov=this.fov,this.perspCamera.view=this.view,this.perspCamera.far=this.far,this.perspCamera.updateProjectionMatrix(),this.projectionMatrix=this.perspCamera.projectionMatrix,this.projectionMatrixInverse=this.perspCamera.projectionMatrixInverse,this._cameraType="PerspectiveCamera",this._applyProjectionTransition(),this.objectHelper&&this.objectHelper.update()}get isProjectionTransitioning(){return this._projectionTransition!==void 0}get projectionTransitionProgress(){let t=this._projectionTransition;if(t===void 0)return 1;let e=(performance.now()-t.start)/t.duration;return e>=1?1:e<=0?0:AY(e)}get _activeSubCamera(){return this._cameraType==="PerspectiveCamera"?this.perspCamera:this.orthoCamera}_canAnimateProjection(){return uu.projectionTransitionsEnabled&&typeof requestAnimationFrame=="function"&&typeof performance<"u"&&performance.now()-this._createdAt>=uu.projectionTransitionMinAgeMs}_beginProjectionTransition(t){let e=this._projectionTransition;e===void 0&&(e={from:new bt,blend:new bt,blendInverse:new bt,start:0,duration:uu.projectionTransitionDuration,referenceDepth:1,raf:0,requestRender:t},this._projectionTransition=e),e.from.copy(this.projectionMatrix),e.start=performance.now(),e.duration=uu.projectionTransitionDuration,e.referenceDepth=Number.isFinite(this.targetOffset)?Math.max(1,this.targetOffset):1,t&&(e.requestRender=t),e.raf!==0&&cancelAnimationFrame(e.raf),e.raf=requestAnimationFrame(this._tickProjectionTransition)}_applyProjectionTransition(){let t=this._projectionTransition;if(t===void 0)return;let e=(performance.now()-t.start)/t.duration;if(e>=1)return void this._endProjectionTransition();let i=AY(e),r=t.from.elements,s=this._activeSubCamera.projectionMatrix.elements,n=t.blend.elements,a=t.referenceDepth,o=Math.max(1e-6,r[15]-r[11]*a),l=i*o/(i*o+(1-i)*Math.max(1e-6,s[15]-s[11]*a));for(let u=0;u<16;u++)n[u]=r[u]+(s[u]-r[u])*l;t.blendInverse.copy(t.blend).invert(),this.projectionMatrix=t.blend,this.projectionMatrixInverse=t.blendInverse}_endProjectionTransition(){let t=this._projectionTransition;if(t===void 0)return;t.raf!==0&&cancelAnimationFrame(t.raf),this._projectionTransition=void 0;let e=this._activeSubCamera;this.projectionMatrix=e.projectionMatrix,this.projectionMatrixInverse=e.projectionMatrixInverse}_syncProjectionTransition(t){let e=t._projectionTransition;if(e===void 0)return void(this._projectionTransition!==void 0&&this._endProjectionTransition());let i=this._projectionTransition;i===void 0?(i={from:new bt,blend:new bt,blendInverse:new bt,start:0,duration:1,referenceDepth:1,raf:0,requestRender:void 0},this._projectionTransition=i):i.raf!==0&&(cancelAnimationFrame(i.raf),i.raf=0),i.requestRender=void 0,i.from.copy(e.from),i.start=e.start,i.duration=e.duration,i.referenceDepth=e.referenceDepth,this._applyProjectionTransition()}setFocalLength(t){this.perspCamera.setFocalLength(t),this.toPerspective()}getFocalLength(){return this.perspCamera.getFocalLength()}getEffectiveFOV(){return this.perspCamera.getEffectiveFOV()}getFilmWidth(){return this.perspCamera.getFilmWidth()}getFilmHeight(){return this.perspCamera.getFilmHeight()}setViewOffset(t,e,i,r,s,n){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(t,e,i,r,s,n):this.orthoCamera.setViewOffset(t,e,i,r,s,n),this._applyProjectionTransition()}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}copyHistory(){this.previousProjectionMatrix&&this.previousProjectionMatrix.copy(this.projectionMatrix)}updateProjectionMatrix(){this._cameraType==="PerspectiveCamera"?this.toPerspective():this._cameraType==="OrthographicCamera"&&this.toOrthographic()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(t,e){return super.copy(t,e),this.parent=t.parent,this.orthoCamera.copy(t.orthoCamera),this.perspCamera.copy(t.perspCamera),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.far=t.far,this.view=t.view===null?null:Object.assign({},t.view),this._cameraType=t._cameraType,this.aspect=t.aspect,this.fov=t.fov,this.focus=t.focus,this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this.targetOffset=gc.sanitizeTargetOffset(t.targetOffset),this.updateProjectionMatrix(),this._syncProjectionTransition(t),this}toCameraState(t=[]){return B8({type:this.cameraType,far:this.far,orthographic:{near:this.orthoCamera.near,zoom:this.orthoCamera.zoom},perspective:{near:this.perspCamera.near,fov:this.perspCamera.fov,zoom:this.perspCamera.zoom},up:this.up.toArray(),targetOffset:this.targetOffset,isUpVectorFlipped:this.isUpVectorFlipped},t)}updateCameraSubtype(t,e){let i=t==="perspective"?"PerspectiveCamera":"OrthographicCamera";e.zoom!==void 0&&this.setZoom(i,e.zoom),e.near!==void 0&&this.setNear(i,e.near),e.fov!==void 0&&i==="PerspectiveCamera"&&(this.fov=e.fov)}updateState(t,e){this.updateCameraState(t,e)}updateCameraState(t,e){this.updateState_Entity(t,e),t.far!==void 0&&(this.far=t.far),t.orthographic!==void 0&&this.updateCameraSubtype("orthographic",t.orthographic),t.perspective!==void 0&&this.updateCameraSubtype("perspective",t.perspective),t.type!==void 0&&(t.type!==this._cameraType&&this._canAnimateProjection()&&this._beginProjectionTransition(e?.shared.requestRender),this.cameraType=t.type),t.up!==void 0&&this.up.fromArray(t.up.map(i=>typeof i=="number"?i:0)),t.targetOffset!==void 0&&(this.targetOffset=gc.sanitizeTargetOffset(t.targetOffset)),t.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=t.isUpVectorFlipped),this.updateProjectionMatrix()}updateByPatchedOp(t,e,i){super.updateByPatchedOp(t,e,i),t.path.length===1&&t.type===0&&this.updateCameraSubtype(t.path[0],t.props)}toState(t){return{...super.toState(t),...this.toCameraState(t),type:this.cameraType}}},(ln=uu).projectionTransitionsEnabled=!1,ln.projectionTransitionDuration=350,ln.projectionTransitionMinAgeMs=1e3});function dft(t){return t.type==="TorusGeometry"&&t.arc===360}var cft,PM,PU,NS=G(()=>{dt(),cft=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},t.parameters),r=Math.abs(i.width),s=Math.abs(i.height??r),n=Math.abs(i.depth??r),a=Math.abs(Math.min(r,n))/2;return{parameters:Object.assign(i,{width:r,height:s,depth:n,radius:a,segments:Math.round(i.segments),pathSegments:Math.round(i.pathSegments),cornerSegments:Math.round(i.cornerSegments)})}}static build(t){let{width:e,height:i,depth:r,radius:s,revolutions:n,segments:a,pathRadius:o,pathType:l,pathSegments:u,cornerRadius:h,cornerSegments:d}=t.parameters,c=new PU(!1,e,i,r,s,n,a,o,l,u,h,d);return Object.assign(c,{userData:{...t,type:"HelixGeometry"}})}},PM=new om([0,0,0],1),PU=class extends ye{constructor(t=!0,e=1,i=1,r=1,s=1,n=1,a=1,o=1,l=1,u=1,h=1,d=1){if(super(),n===0)return;let c=t&&n===1;c&&(d=0),h>100&&(h=100),h===0&&(d=0);let p,m,f,g,y,v,b,_,x=()=>new P,S=new P,w=x(),T=x(),A=x(),M=x(),C=x(),R=x(),O=x(),N=x(),B=x(),k=x(),z=x(),L=i-2*o+.001,V=L/n,q=Math.ceil(a*n),j=q+1,Q=L/q,it=-L/2,at=u+1,St=2*Math.PI/u,yt=Math.PI/2/d,Y=Math.min((1-h/100)*o,o-.01),pt=o-Y,xt=0,Tt=2*d+2,Mt=at*Tt/2,_t=Mt+at*j,kt=Math.max(0,at*(j+Tt)),[Ut,Lt,zt]=[3,3,2].map(Ve=>Array(kt*Ve).fill(0)),Bt=[],jt=s-o;function Xt(Ve,ie){let oi=Math.PI/2;v=ie*Q,_=2*Math.PI*(v%V)/V+oi,v+=it,b=Math.sin(_)*jt,y=Math.cos(_)*jt,t?Ve.set(y,b,v):Ve.set(y,v,b)}Xt(S,-1e-10),Xt(w,0),M.copy(S),Xt(S,1);let Dt=S.distanceTo(w),le=c?0:pt+Y,Wt=Dt*q+2*le,Qt=Y,ee=Wt-le;for(let Ve=0;Ve<=q;Ve++){Xt(T,Ve),z.subVectors(T,M).normalize(),M.copy(T),B.copy(T).setComponent(+t+1,0).normalize(),k.crossVectors(z,B).normalize();let ie=Ve===0,oi=Ve===q,xi=ie?3*Math.PI/2:yt,Ys=ie?Qt:ee,Hi=ie?at:_t,li=ie?0:kt-at,Ur=z.clone().multiplyScalar(ie?-pt:pt).add(T),Jr=z.clone().multiplyScalar(ie?-1:1).normalize();for(let jr=0;jr<at;jr++){let Ui=jr*St;if(C.addVectors(S.copy(B).multiplyScalar(o*Math.cos(Ui)),w.copy(k).multiplyScalar(o*Math.sin(Ui))),R.copy(C).normalize(),ie||oi){c||(xt=li+jr,[0,1,2].forEach(Ci=>{Ut[3*xt+Ci]=Ur.getComponent(Ci),Lt[3*xt+Ci]=Jr.getComponent(Ci)}),zt[2*xt]=+oi,zt[2*xt+1]=jr/u),w.copy(R).multiplyScalar(Y),A.addVectors(T,w);for(let Ci=0;Ci<d;Ci++){let Ks=Ci*yt+xi;O.addVectors(S.copy(z).multiplyScalar(pt*Math.sin(Ks)),w.copy(R).multiplyScalar(pt*Math.cos(Ks))),N.copy(O).normalize(),w.addVectors(A,O),O.normalize(),xt=Hi+Ci*at+jr,[0,1,2].forEach(br=>{Ut[3*xt+br]=w.getComponent(br),Lt[3*xt+br]=N.getComponent(br)});let ps=+ie+Math.sin(Ks);zt[2*xt]=(Ys+pt*ps)/Wt,zt[2*xt+1]=jr/u}}w.addVectors(T,C),xt=Mt+Ve*at+jr,[0,1,2].forEach(Ci=>{Ut[3*xt+Ci]=w.getComponent(Ci),Lt[3*xt+Ci]=R.getComponent(Ci)}),zt[2*xt]=(le+Ve*Dt)/Wt,zt[2*xt+1]=jr/u}}let $=j+2*d+2,[se,Pe]=[+c,$-1];for(let Ve=se;Ve<=Pe-1;Ve++){let ie=c&&Ve===Pe-1;for(let oi=0;oi<at-1;oi++)p=Ve*at+oi,m=p+1,f=(ie?oi:p)+at,g=(ie?oi+1:m)+at,Ve===0?Bt.push(m,g,f):Ve===$-2?Bt.push(p,m,f):Bt.push(p,m,f,m,g,f)}this.setIndex(Bt),this.setAttribute("position",new fe(Ut,3)),this.setAttribute("normal",new fe(Lt,3)),this.setAttribute("uv",new fe(zt,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let t,e,i,r,s=this.userData.parameters,n=Math.ceil(s.tubularSegments),a=s.radialSegments,o=a+1,l=[];for(let u=1;u<n;u++)for(let h=0;h<a;h++)t=u*o+h,e=t+1,i=t+o,r=e+o,l.push(t,e,i,e,r,i);for(let u=0;u<a;u++)t=n*o+u,e=t+1,i=u+o,r=u+1+o,l.push(t,e,i,e,r,i);return PM.array=new Uint32Array(l),PM.count=l.length,PM}}});function YMt(t){return EY||(EY=async function(){let e=t??"https://cdn.spline.design/@splinetool/runtime@2.0.60/build",i=import("./boolean.js"),[r,s]=await Promise.all([i,fetch(`${e}/boolean.wasm`).then(n=>n.arrayBuffer())]);await r.default({module_or_path:s}),OS=r}())}function wR(){if(OS===void 0)throw new Error("boolean-wasm is not loaded");return OS}function yG(t){let e=IS.get(t);if(e===void 0)throw new Error("Unknown csg mesh set handle "+t);return e}function vG(t){return IS.set(++RU,t),RU}function KMt(t,e,i){if(OS===void 0)return-1;let{positions:r,indices:s,normals:n}=function(a,o){if(o&&a.userData.positions!==void 0){let p=a.userData,m=[];for(let f=0,g=0;f<p.verticesPerFace.length;f++){let y=p.verticesPerFace[f];for(let v=1;v<y-1;v++)m.push(p.indices[g],p.indices[g+v],p.indices[g+v+1]);g+=y}return{positions:p.positions instanceof Float32Array?p.positions:new Float32Array(p.positions),indices:new Uint32Array(m)}}let l;l=dft(a.userData.parameters)?a.getClosedTorusIndicesForBooleanOrSubdiv():a.getIndex();let u,h=a.getAttribute("position");if(l===null){u=new Uint32Array(h.count);for(let p=0;p<u.length;p++)u[p]=p}else u=l.array instanceof Uint32Array?l.array:new Uint32Array(l.array);let d=a.getAttribute("normal"),c=d!==void 0&&d.itemSize===3&&d.count===h.count&&d.array instanceof Float32Array&&d.isInterleavedBufferAttribute!==!0?d.array:void 0;return{positions:h.array,indices:u,normals:c}}(t,e);return vG(new OS.CsgMesh(r,s,n))}function CY(t,e){let i=wR(),r=mft[e];if(r===void 0)throw new Error("Unknown boolean operation "+e);let s=t.map(yG);if(s.length===1)return i.clone_mesh(s[0]);let n,a=[];if(e===2&&s.length>2){let o=s[0];for(let l=1;l<s.length-1;l++)o=i.boolean_mesh(o,s[l],0),a.push(o);n=i.boolean_mesh(s[s.length-1],o,2)}else if(e===2)n=i.boolean_mesh(s[1],s[0],2);else{let o=s[s.length-1];for(let l=0;l<s.length-1&&(o=i.boolean_mesh(o,s[l],r),a.push(o),o.tri_count()!==0);l++);n=o,a.pop()}for(let o of a)o.free();return n}function MO(t,e){yG(t).transform(new Float32Array(e.elements))}function pft(t){let e=IS.get(t);e!==void 0&&(e.free(),IS.delete(t))}var OS,IS,RU,EY,mft,k5=G(()=>{dt(),NS(),IS=new Map,RU=0,mft={0:0,1:1,2:2}});function tf(t){return t!==null&&"booleanOp"in t}var DU,fft,ZMt=G(()=>{dt(),vo(),k5(),DU=class extends B5(Sr){constructor(){super(...arguments),this.booleanMeshSetAddress=-1,this.booleanWasTransformed=!1,this.booleanMatrixInvOld=new bt}updateVisible(t){super.updateVisible(t),this.visible=!tf(this.parent)&&this.visible,tf(this.parent)&&this.parent.invalidateDownstreamBooleanData()}onClonerLayoutUpdated(){tf(this.parent)&&this.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(pft(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(t=!1){return t?this.booleanWasTransformed=!0:this.freeBooleanPointer(),tf(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let t of this.children)t instanceof DU&&(t.freeBooleanPointer(),tf(t)&&t.invalidateUpstreamBooleanData())}updateTransformState(t,e){let i=super.updateTransformState(t,e);return i&&tf(this.parent)&&this.invalidateDownstreamBooleanData(!0),i}onVariableUpdate(t=!1){super.onVariableUpdate(t),tf(this.parent)&&this.invalidateDownstreamBooleanData(!0)}}}),QMt=G(()=>{fft=null});function bG(t,e=0,i=t.count,r,s){let n=1/0,a=1/0,o=1/0,l=-1/0,u=-1/0,h=-1/0;for(let d=e;d<i;d++){let c=t.getX(d),p=t.getY(d),m=t.getZ(d);c<n&&(n=c),p<a&&(a=p),m<o&&(o=m),c>l&&(l=c),p>u&&(u=p),m>h&&(h=m)}Kw.min.set(n,a,o),Kw.max.set(l,u,h),Kw.getCenter(r),Kw.getSize(s).multiplyScalar(.5)}var Kw,PY,RY,Bs,la=G(()=>{dt(),ZMt(),QMt(),Kw=new pr,PY=new ye,RY=new Uo,Bs=class extends DU{constructor(t,e){super(PY,RY),this.super_Entity(t,e)}updateState(t,e){this.updateState_Entity(t,e)}raycast(t,e){let i=fft;i===null?super.raycast(t,e):i(this,t,e)}updateEntityBoxSize(t,e){let i=this.geometry.getAttribute("position");i!==void 0?bG(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,t,e):super.updateEntityBoxSize(t,e)}}});function SR(t){return t?.isClassicNodeMaterial===!0}var Dr,NU,gft,yft,$2,vft,bft,_ft,_G=G(()=>{}),Rc=G(()=>{dt(),Dr=class extends ae{constructor(t,e,i,r){super(t,e,i),this.isColorA=!0,this.a=r}setRGBA(t,e,i,r){super.setRGB(t,e,i),this.a=r}copy(t){return super.copy(t),this.a="a"in t?t.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}equals(t){return super.equals(t)&&this.a===t.a}setStyle(t,e="srgb"){let i;if(t==="transparent")return this.setRGBA(0,0,0,0),this;if(i=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(t)){let r,s=i[1],n=i[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(n))return this.a=s==="rgba"?parseFloat(r[4]):1,super.setStyle(t,e);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(n))return this.a=s==="hsla"?parseFloat(r[4]):1,super.setStyle(t,e)}}return super.setStyle(t,e)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(t){this.r=t}set y(t){this.g=t}set z(t){this.b=t}set w(t){this.a=t}}}),JMt=G(()=>{Rc(),NU=class extends Dr{}}),t3t=G(()=>{gft=class{constructor(t=1e4){this.timeout=t,this.cache=new Map,this.head={data:null,time:0,src:null,next:null,prev:null},this.tail={data:null,time:1/0,src:null,next:null,prev:null},this.hasClean=!1,this.cleanupTimer=null,this.head.next=this.tail,this.tail.prev=this.head}log(...t){}remove(t){let e=this.cache.get(t);e&&(this.dispose(t,e.data),this.cache.delete(t),e.prev.next=e.next,e.next.prev=e.prev,e.next=null,e.prev=null,e.data=null)}scheduleCleanup(){this.hasClean||(this.log("scheduled cleanup"),this.hasClean=!0,this.cleanupTimer=setTimeout(()=>{this.hasClean=!1,this.cleanupTimer=null,this.log("cleaning");let t=Date.now(),e=this.head.next;for(;e.time<t-this.timeout;){this.dispose(e.src,e.data),this.cache.delete(e.src);let i=e;e=e.next,e.prev=this.head,this.head.next=e,i.next=null,i.prev=null,i.data=null}this.head.next!==this.tail?this.scheduleCleanup():this.log("no more cleanup")},this.timeout+1e3))}has(t){return this.cache.get(t)?.data}load(t){let e=Date.now(),i=this.cache.get(t);return i===void 0?(i={data:this.create(t),src:t,time:e,next:null,prev:null},this.cache.set(t,i)):(i.time=e,i.prev.next=i.next,i.next.prev=i.prev),i.prev=this.tail.prev,i.next=this.tail,this.tail.prev.next=i,this.tail.prev=i,this.scheduleCleanup(),i.data}disposeAll(){this.cleanupTimer!==null&&(clearTimeout(this.cleanupTimer),this.cleanupTimer=null),this.hasClean=!1,this.cache.forEach((t,e)=>{this.dispose(e,t.data),t.next=null,t.prev=null,t.data=null}),this.cache.clear(),this.head.next=this.tail,this.tail.prev=this.head}destroy(){this.disposeAll(),this.head=null,this.tail=null}}}),xft=G(()=>{t3t(),yft=class extends gft{create(t){return URL.createObjectURL(new Blob([t]))}dispose(t,e){URL.revokeObjectURL(e)}}}),wft=G(()=>{vft=class{constructor(t,e){this.data=t,this.cache=e,this.refCount=0}deref(){this.refCount,this.refCount-=1,this.refCount===0&&(this.cache.remove(this),this.dispose())}dispose(){this.refCount}},bft=class{constructor(){this.cache=new Map}remove(t){this.cache.delete(t.data)}load(t){let e=this.cache.get(t);return e===void 0&&(e=this.create(t),this.cache.set(t,e)),e.refCount+=1,e}}}),e3t=G(()=>{dt(),_ft=class extends Vpt{constructor(t){super(t),this.type=ai}parse(t){let e=function(p,m){switch(p){case 1:throw new Error("THREE.HDRLoader: Read Error: "+(m||""));case 2:throw new Error("THREE.HDRLoader: Write Error: "+(m||""));case 3:throw new Error("THREE.HDRLoader: Bad File Format: "+(m||""));default:throw new Error("THREE.HDRLoader: Memory Error: "+(m||""))}},i=function(p,m,f){m=m||1024;let g=p.pos,y=-1,v=0,b="",_=String.fromCharCode.apply(null,new Uint16Array(p.subarray(g,g+128)));for(;0>(y=_.indexOf(`
|
|
347
|
+
})();`}),Kpt=G(()=>{H7=class{constructor(t,e,i){this.deps=t,this.onConsole=e,this.onEvent=i,this.disposed=!1,this.eventUnsubs=new Map,this.variablePollHandle=null,this.lastVariables=null}dispose(){this.disposed=!0;for(let t of this.eventUnsubs.values())t();this.eventUnsubs.clear(),this.stopVariablePolling()}execute(t,e){let i=this.deps;switch(t){case"setVariable":{let r=i.setVariable(String(e[0]),e[1]);return r.warning&&this.onConsole("warn",r.warning),r.ok}case"setVariables":{let r=e[0]??{},s=!0;for(let[n,a]of Object.entries(r)){let o=i.setVariable(n,a);o.warning&&this.onConsole("warn",o.warning),s=s&&o.ok}return s}case"getVariable":return i.getVariable(String(e[0]));case"getVariables":return i.getVariables();case"getAllObjects":return i.getAllObjects();case"findObjectByName":case"findObjectById":return i.findObject(String(e[0]));case"getGeometry":{let r=i.getGeometry(String(e[0]),e[1]??{});return r.warning&&this.onConsole("warn",r.warning),r.data}case"updateObject":return i.updateObject(String(e[0]),e[1]??{});case"createObject":return i.createObject(String(e[0]),e[1]??{});case"createCustomMaterial":if(i.createCustomMaterial===void 0)throw new Error("createCustomMaterial: not available on this surface \u2014 custom three.js/TSL materials need the inline HTML-content mode (editor Preview/Play and web exports).");return i.createCustomMaterial(e[0]);case"getTexture":if(i.getTexture===void 0)throw new Error("getTexture: not available on this surface \u2014 a three.js texture instance needs the inline HTML-content mode (editor Preview/Play and web exports).");return i.getTexture(String(e[0]),e[1]??{});case"setMaterial":if(i.setMaterial===void 0)throw new Error("setMaterial: not available on this surface \u2014 custom three.js/TSL materials need the inline HTML-content mode (editor Preview/Play and web exports).");return i.setMaterial(String(e[0]),e[1]);case"cloneObject":return i.cloneObject(String(e[0]),e[1]??{});case"removeObject":return i.removeObject(String(e[0]));case"spawnObject":{let r=i.spawnObject(String(e[0]),e[1]??{});return r.warning&&this.onConsole("warn",r.warning),r.object}case"destroyObject":return i.destroyObject(String(e[0]));case"setInstanceTransforms":{let r=e[1]===null||e[1]===void 0?null:e[1],s=i.setInstanceTransforms(String(e[0]),r);return s<0&&this.onConsole("warn",`spline.setInstanceTransforms: "${String(e[0])}" has no cloner \u2014 make the object a cloner first (its copies are what this drives).`),s}case"emitEvent":case"emitEventReverse":{let r=i.emitEvent(String(e[0]),String(e[1]),t==="emitEventReverse");return r.warning&&this.onConsole("warn",r.warning),r.ok}case"requestRender":return i.requestRender(),!0;case"listenEvent":{let r=String(e[0]);return r==="variableChange"?this.startVariablePolling():this.eventUnsubs.has(r)||this.eventUnsubs.set(r,i.addSplineEventListener(r,s=>{this.onEvent(r,s)})),!0}case"unlistenEvent":{let r=String(e[0]);return r==="variableChange"?this.stopVariablePolling():(this.eventUnsubs.get(r)?.(),this.eventUnsubs.delete(r)),!0}default:throw new Error(`Unknown spline bridge method: ${t}`)}}startVariablePolling(){this.variablePollHandle===null&&(this.lastVariables=this.deps.getVariables(),this.variablePollHandle=window.setInterval(()=>{if(this.disposed)return;let t=this.deps.getVariables(),e=function(i,r){let s=[];for(let n of Object.keys(r))i[n]!==r[n]&&s.push({name:n,value:r[n]});return s}(this.lastVariables??{},t);this.lastVariables=t;for(let i of e)this.onEvent("variableChange",i)},100))}stopVariablePolling(){this.variablePollHandle!==null&&(window.clearInterval(this.variablePollHandle),this.variablePollHandle=null),this.lastVariables=null}}});function rMt(t,e,i,r){return[t[0]*e+t[4]*i+t[8]*r+t[12],t[1]*e+t[5]*i+t[9]*r+t[13],t[2]*e+t[6]*i+t[10]*r+t[14]]}var sMt=G(()=>{}),Zpt,nMt=G(()=>{}),aMt=G(()=>{$7(),Kpt(),Zpt=class{constructor(t,e,i){this.iframe=t,this.deps=e,this.onConsole=i,this.disposed=!1,this.handshakeSeen=!1,this.handshakeTimer=null,this.onMessage=r=>{if(this.disposed||r.source!==this.iframe.contentWindow)return;let s=r.data;var n;typeof(n=s)!="object"||n===null||n[Fp]!==!0||typeof n.kind!="string"||this.handleMessage(s)},this.host=new H7(e,i,(r,s)=>{this.sendEvent(r,s)})}attach(){window.addEventListener("message",this.onMessage),this.send({[Fp]:!0,kind:"ready-ack"}),this.handshakeTimer=window.setTimeout(()=>{this.handshakeTimer=null,!this.handshakeSeen&&!this.disposed&&this.onConsole("warn","The HTML content frame has not initialized (no signal from its scripts yet) \u2014 if the page looks frozen, check for errors in its code.")},6e3)}dispose(){this.disposed=!0,window.removeEventListener("message",this.onMessage),this.host.dispose(),this.handshakeTimer!==null&&(window.clearTimeout(this.handshakeTimer),this.handshakeTimer=null)}handleMessage(t){switch(t.kind){case"ready":this.handshakeSeen=!0,this.send({[Fp]:!0,kind:"ready-ack"});break;case"console":this.onConsole(t.level,t.text);break;case"call":{let e;try{e=Promise.resolve(this.host.execute(t.method,t.args))}catch(i){e=Promise.reject(i)}e.then(i=>{this.send({[Fp]:!0,kind:"result",id:t.id,ok:!0,value:i,error:void 0})},i=>{let r=i instanceof Error?i.message:String(i);this.send({[Fp]:!0,kind:"result",id:t.id,ok:!1,value:void 0,error:r}),this.onConsole("error",r)});break}case"input":this.dispatchInput(t.event)}}send(t){this.iframe.contentWindow?.postMessage(t,"*")}sendEvent(t,e){this.send({[Fp]:!0,kind:"event",eventName:t,payload:e})}dispatchInput(t){let e=this.deps.getCanvas();if(!e)return;let i=this.iframe.getBoundingClientRect(),r={bubbles:!0,cancelable:!0,view:window,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,altKey:t.altKey,metaKey:t.metaKey};switch(t.type){case"pointerdown":case"pointermove":case"pointerup":case"pointercancel":e.dispatchEvent(new PointerEvent(t.type,{...r,clientX:(t.x??0)+i.left,clientY:(t.y??0)+i.top,button:t.button,buttons:t.buttons,pointerId:t.pointerId,pointerType:t.pointerType,isPrimary:t.isPrimary,movementX:t.movementX,movementY:t.movementY}));break;case"click":case"dblclick":e.dispatchEvent(new MouseEvent(t.type,{...r,clientX:(t.x??0)+i.left,clientY:(t.y??0)+i.top,button:t.button,buttons:t.buttons}));break;case"wheel":{let s=new WheelEvent("wheel",{...r,clientX:(t.x??0)+i.left,clientY:(t.y??0)+i.top,deltaX:t.deltaX,deltaY:t.deltaY,deltaMode:t.deltaMode});typeof t.wheelDeltaX=="number"&&Object.defineProperty(s,"wheelDeltaX",{value:t.wheelDeltaX}),typeof t.wheelDeltaY=="number"&&Object.defineProperty(s,"wheelDeltaY",{value:t.wheelDeltaY}),e.dispatchEvent(s);break}case"keydown":case"keyup":e.dispatchEvent(new KeyboardEvent(t.type,{...r,key:t.key,code:t.code,repeat:t.repeat}))}}}}),ir=G(()=>{q7(),jTt(),GTt(),WTt(),HTt(),$Tt(),XTt(),YTt(),KTt(),ZTt(),QTt(),eMt(),$7(),iMt(),Kpt(),sMt(),nMt(),aMt()}),oMt=G(()=>{});function Qpt(t){return Array.isArray(t)?t:[t]}function X4(t,e){let i=0;for(;i<t.length&&i<e.length;){if(t[i]<e[i])return-1;if(t[i]>e[i])return 1;i+=1}return i!==e.length?-1:i!==t.length?1:0}var lMt=G(()=>{});function $a(t,e){return Object.setPrototypeOf(t,e),t}function zN(t){let e={...t};return Object.setPrototypeOf(e,Object.getPrototypeOf(t)),e}function Zp(t,e,i){if(t===void 0?e===void 0?(t=0,e=10):t=e-10:e===void 0&&(e=t+10),t>e){let n=t;t=e,e=n}let r=[],s=1/(i+1);for(let n=0;n<i;n++){let a=t+(e-t)*(n+.75+.5*Math.random())*s;r.push(a)}return r}function Yg(t){return t instanceof Uint8Array||t instanceof Uint16Array||t instanceof Uint32Array||t instanceof Int8Array||t instanceof Int16Array||t instanceof Int32Array||t instanceof Float32Array||t instanceof Float64Array}var hMt=G(()=>{});function X7(t){if(t.deepFreeze!==void 0)return void t.deepFreeze(t);let e=Object.getOwnPropertyNames(t);for(let i of e){let r=t[i];r&&typeof r=="object"&&X7(r)}return Object.freeze(t)}function Jpt(t){for(let e of Object.keys(t))t[e]===void 0&&delete t[e];return t}var LN,Y4,V8,Be,Y7,uMt=G(()=>{}),hn=G(()=>{oMt(),lMt(),hMt(),uMt()}),K7=G(()=>{LN=class{},Y4=class extends LN{constructor(t){super(),this.id=t}},V8=class extends LN{constructor(t){super(),this.data=t}}}),dMt=G(()=>{}),w5=G(()=>{Be=class{modifyById(t,e){let i=this;if(i[t]===void 0)throw new Error("not expected");{let r={...i,[t]:e};return Object.setPrototypeOf(r,Be.prototype),r}}add(t,e){return this.runOp({type:1,id:t,data:e})?.data??this}runOp(t){let e=this;if(t.type===1){let i,r=e[t.id];i=r===void 0?{type:2,id:t.id}:{type:1,id:t.id,data:r};let{id:s,data:n}=t,a={...e,[s]:n};return Object.setPrototypeOf(a,Be.prototype),{data:a,actual:t,reverse:i}}if(t.type===2){let{id:i}=t,r=e[i];if(r===void 0)return null;{let s={...e};return Object.setPrototypeOf(s,Be.prototype),delete s[i],{data:s,actual:t,reverse:{type:1,id:i,data:r}}}}return null}}}),Z7=G(()=>{Y7=class extends Error{}});function tmt(t,e){for(let i of t)e(i.id,i.data)!==!0&&tmt(i.children,e)}function emt(t,e){if(e(t.id,t.data)!==!0)for(let i of t.children)emt(i,e)}var In,fM,Dv,ge,t0=G(()=>{hn(),Z7(),hn(),In=class extends Array{constructor(...t){super(...t),cc(this,"partialObjectCaches"),cc(this,"objCaches"),cc(this,"parentCaches"),Object.setPrototypeOf(this,In.prototype)}deepFreeze(){let t=0;for(;t<this.length;)X7(this[t]),t++}fillCaches0(t,e){this.objCaches.set(t.id,t),this.parentCaches.set(t.id,e);for(let i of t.children)this.fillCaches0(i,t.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let t of this)this.fillCaches0(t,null)}}randomId(){this.fillCaches();let t=Array.from(this.objCaches.keys());if(t.length!==0)return t[Math.max(0,Math.floor(Math.random()*t.length)-1)]}nonExistOrDescendantOf(t,e){if(!this.has(t))return!0;for(;t;){let i=this.parent(t);if(i===e)return!0;t=i}return!1}rootAcestor(t){for(;t;){let e=this.parent(t);if(!e)return t;t=e}return t}isDescendantOf(t,e){for(;t;){let i=this.parent(t);if(i===e)return!0;t=i}return!1}data(t){return this.get(t)?.data}has(t){return this.childrenOf(t)!==void 0}partialCache(t){this.partialObjectCaches===void 0&&(this.partialObjectCaches=new Map);let e=this.get(t);e!==void 0&&this.partialObjectCaches.set(t,e)}get(t){if(this.partialObjectCaches!==void 0){let e=this.partialObjectCaches.get(t);if(e!==void 0)return e}return this.fillCaches(),this.objCaches.get(t)}childrenOf(t){return t===null?this:this.get(t)?.children}traverseFrom(t,e){if(t===null)this.traverse(e);else{let i=this.get(t);i&&emt(i,e)}}traverse(t){tmt(this,t)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(t){return this.fillCaches(),this.parentCaches.get(t)}childrenArray(t){return t===null?this:this.get(t).children}modifyById(t,e){if(this.get(t)===void 0)throw new Error("not expected");{let i=this.parent(t),r=this.childrenArray(i),s=r.findIndex(o=>o.id===t);if(s<0)throw new Error("not expected");let n=r[s];r=[...r],r[s]={...n,data:e};let a=new Map;return a.set(t,r[s]),this.modifyArrayBy(i,r,a)}}modifyArrayBy(t,e,i=void 0){let r=t,s=e;for(;r!==null;){let a=s,o=r;if(r=this.parent(r),r===void 0)throw new Error;s=this.childrenArray(r);let l=s.findIndex(u=>u.id===o);if(l<0)throw new Error;s=[...s],s[l]={...s[l],children:a},i&&i.set(o,s[l])}Object.setPrototypeOf(s,In.prototype);let n=s;if(i&&this.objCaches!==void 0&&this.parentCaches!==void 0){n.objCaches=this.objCaches;for(let[a,o]of i)n.objCaches.set(a,o);n.parentCaches=this.parentCaches,this.objCaches=void 0,this.parentCaches=void 0}else n.fillCaches();return n}runOp(t){switch(t.type){case 7:return this.addOp(t);case 8:return this.deleteOp(t);case 9:return this.moveOp(t)}return null}checkDuplicatedIdRec({id:t,children:e}){if(this.get(t)!==void 0)return!0;for(let i of e)if(this.checkDuplicatedIdRec(i))return!0;return!1}addOp(t){let{parent:e,fi:i,id:r,data:s,children:n}=t;if(e!==null&&this.get(e)===void 0||this.checkDuplicatedIdRec(t))return null;{let a=e,o=this.childrenArray(a),l={fi:i,id:r,data:s,children:n};return o=[...o,l],o.sort((u,h)=>u.fi-h.fi),t.localIndex=o.indexOf(l),{data:this.modifyArrayBy(a,o),actual:t,reverse:{type:8,id:r}}}}deleteOp(t){let{id:e}=t;if(this.get(e)===null)return null;{let i=this.parent(e);if(i===void 0)return null;let r=this.childrenArray(i),s=r.findIndex(a=>a.id===e);t.localIndex=s,r=[...r];let n=r.splice(s,1)[0];return{data:this.modifyArrayBy(i,r),actual:t,reverse:{type:7,...n,parent:i}}}}moveOp(t){let{parent:e,fi:i,id:r}=t;if(e!==null&&this.get(e)===void 0)return this.deleteOp({type:8,id:r});if(e!==null){let d=e;for(;d!==null;){if(d===void 0)throw new Error;if(d===r)throw new Y7("cyclic tree");d=this.parent(d)}}let s=this.parent(r);if(s===void 0)return null;let n=s,a=this.childrenArray(s),o=a.findIndex(d=>d.id===r);a=[...a];let l=a.splice(o,1)[0],u=this.modifyArrayBy(s,a);s=e,a=u.childrenArray(s);let h=l.fi;return l={...l,fi:i},a=[...a,l],a.sort((d,c)=>d.fi-c.fi),t.localIndex=a.indexOf(l),u=u.modifyArrayBy(s,a),{data:u,actual:t,reverse:{type:9,parent:n,fi:h,id:r}}}previous(t,e){if(e===null){let r=this.childrenArray(t);return r.length===0?null:r[r.length-1].id}let i=null;for(let r of this.childrenArray(t)){if(r.id===e)return i;i=r.id}return null}traverseSortNext(t){let e=this.parent(t);if(e!==void 0){let i=this.childrenArray(e),r=i.findIndex(s=>s.id===t)+1;if(r<i.length)return i[r].id;if(e)return this.traverseSortNext(e)}}sortNext(t){let e=this.childrenArray(t);return e.length>0?e[0].id:this.traverseSortNext(t)}traverseSortPrevious(t){let e=this.childrenArray(t);return e.length>0?this.traverseSortPrevious(e[e.length-1].id):t}sortPrevious(t){let e=this.parent(t);if(e!==void 0){let i=this.childrenArray(e),r=i.findIndex(s=>s.id===t)-1;return r>=0?this.traverseSortPrevious(i[r].id):e}}getAllSorted(t){let e=[];for(let i of t){let r=this.getWithSortKey(i.id);r!==void 0&&e.push({...i,...r})}e.sort((i,r)=>X4(i.sortKey,r.sortKey));for(let i of e)delete i.sortKey;return e}getAllIdSorted(t){let e=[];for(let i of t){let r=this.getWithSortKey(i);r!==void 0&&e.push(r)}e.sort((i,r)=>X4(i.sortKey,r.sortKey));for(let i of e)delete i.sortKey;return e.map(i=>i.id)}getWithSortKey(t){let e=t,i=[],r=this.get(e),s=r;if(r!==void 0){for(;e;)i.splice(0,0,r.fi),e=this.parent(e),e!==null&&(r=this.get(e));return{...s,sortKey:i}}}insertBeforeHelper(t,e,i){return this.insertAfterHelper(t,this.previous(t,e),i)}insertAfterHelper(t,e,i){let r=this.childrenArray(t);if(e===null){if(r.length===0)return Zp(0,i,i);{let s=r[0].fi;return Zp(s-i,s,i)}}{let s=this.get(e);if(s===void 0||this.parent(e)!==t)throw new Error("illegal args");let n=r.find(a=>a.fi>s.fi);if(n===void 0){let a=r[r.length-1].fi;return Zp(a,a+i,i)}return Zp(s.fi,n.fi,i)}}}}),Q7=G(()=>{var t;hn(),fM=null,(t=Dv||(Dv={})).setPreservePrototype=function(e){fM=e},t.tryPreservePrototype=function(e,i){return Object.getPrototypeOf(e)===fM&&Object.setPrototypeOf(i,fM),i},t.runOp=function(e,i){if(i.type!==0)return null;if(Array.isArray(e)||Yg(e)){let r=i.props,s={},n=Yg(e)?e.slice():[...e],a=!1;if(r)for(let o of Object.keys(r)){let l=parseInt(o);if(isNaN(l))throw new Error("wrong index");s[o]=n[l],n[l]=r[o],a=!0}return a?{data:n,actual:i,reverse:{type:0,props:s}}:null}{let r=i.props,s={},n={...e},a=!1;if(r)for(let o of Object.keys(r)){s[o]=n[o];let l=r[o];l===void 0?delete n[o]:n[o]=l,a=!0}return a?{data:t.tryPreservePrototype(e,n),actual:i,reverse:{type:0,props:s}}:null}}}),e0=G(()=>{hn(),hn(),ge=class extends Array{constructor(...t){super(...t),cc(this,"objCaches"),Object.setPrototypeOf(this,ge.prototype)}deepFreeze(){let t=0;for(;t<this.length;)X7(this[t]),t++}fillCaches0(t){this.objCaches.set(t.id,t)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,Object.getOwnPropertyDescriptor(this,"objCaches").enumerable=!1;for(let t of this)this.fillCaches0(t)}}randomId(){this.fillCaches();let t=Array.from(this.objCaches.keys());if(t.length!==0)return t[Math.max(0,Math.floor(Math.random()*t.length)-1)]}data(t){return this.get(t)?.data}get(t){return this.fillCaches(),this.objCaches.get(t)}modifyById(t,e){if(this.get(t)===void 0)throw new Error("not expected");{let i=this,r=i.findIndex(n=>n.id===t);if(r<0)throw new Error("not expected");let s=i[r];return i=[...i],i[r]={...s,data:e},this.modifyArrayBy(i)}}modifyArrayBy(t){Object.setPrototypeOf(t,ge.prototype);let e=t;return typeof process<"u"||e.fillCaches(),e}runOp(t){switch(t.type){case 4:return this.addOp(t);case 5:return this.deleteOp(t);case 6:return this.moveOp(t)}return null}addOp(t){let{fi:e,id:i,data:r}=t,s=this,n={fi:e,id:i,data:r};return s=[...s,n],s.sort((a,o)=>a.fi-o.fi),t.localIndex=s.indexOf(n),{data:this.modifyArrayBy(s),actual:t,reverse:{type:5,id:i}}}deleteOp(t){let{id:e}=t,i=this,r=i.findIndex(n=>n.id===e);if(r===-1)return null;t.localIndex=r,i=[...i];let s=i.splice(r,1)[0];return{data:this.modifyArrayBy(i),actual:t,reverse:{type:4,...s}}}moveOp(t){let{fi:e,id:i}=t,r=this;r=[...r];let s=r.findIndex(o=>o.id===i);if(s===-1)return null;let n=r[s].fi,a={...r[s],fi:e};return r[s]=a,r.sort((o,l)=>o.fi-l.fi),t.localIndex=r.indexOf(a),{data:this.modifyArrayBy(r),actual:t,reverse:{type:6,fi:n,id:i}}}previous(t){if(t===null)return this.length===0?null:this[this.length-1].id;let e=null;for(let i of this){if(i.id===t)return e;e=i.id}return null}insertBeforeHelper(t,e){return this.insertAfterHelper(this.previous(t),e)}insertAfterHelper(t,e){let i=this;if(t===null){if(i.length===0)return Zp(0,e,e);{let r=i[0].fi;return Zp(r-e,r,e)}}{let r=this.get(t);if(r===void 0)throw new Error("illegal args");let s=i.find(n=>n.fi>r.fi);if(s===void 0){let n=i[i.length-1].fi;return Zp(n,n+e,e)}return Zp(r.fi,s.fi,e)}}}});function cMt(t,e){let i={cur:[],result:[],len:0};return[t=nv(t,e,i)??t,i.result]}function MP(t,e){return t===null?null:(t.cur[t.len]=e,t.len+=1,t)}function AP(t){t&&(t.len-=1)}function imt(t,e,i){let r=!1,s=t.map(n=>{let a=n.id,o=e[a];if(o!==void 0&&typeof o=="string"&&(r=!0,a=o,i!==null))throw new Error("not supported");let l=nv(n.data,e,MP(i,a));AP(i),r=r||l!==void 0,l===void 0&&(l=n.data);let u=imt(n.children,e,i);return u!==void 0?r=!0:u=n.children,{...n,id:a,data:l,children:u}});if(r)return s}function nv(t,e,i){if(t instanceof In){let r=imt(t,e,i);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(t)),r}if(t instanceof ge)return function(r,s,n){let a=!1,o=r.map(l=>{let u=l.id,h=s[u];if(h!==void 0&&typeof h=="string"&&(a=!0,u=h,n!==null))throw new Error("not supported");let d=nv(l.data,s,MP(n,u));return AP(n),a=a||d!==void 0,d===void 0&&(d=l.data),{...l,id:u,data:d}});if(a)return Object.setPrototypeOf(o,Object.getPrototypeOf(r)),o}(t,e,i);if(Array.isArray(t)){let r=!1,s=t.map((n,a)=>{let o=nv(n,e,MP(i,a));return AP(i),r=r||o!==void 0,o===void 0&&(o=n),o});return r?(Object.setPrototypeOf(s,Object.getPrototypeOf(t)),s):void 0}if(t&&typeof t=="object"&&!Yg(t)){let r={},s=!1;for(let[n,a]of Object.entries(t))if(n!=="name"&&n!=="variableId"){let o=e[n];if(typeof o=="string"){if(i!==null)throw new Error("not supported");s=!0,n=o}let l=nv(a,e,MP(i,n));AP(i),s=s||l!==void 0,l===void 0&&(l=a),r[n]=l}else r[n]=a;return s?(Object.setPrototypeOf(r,Object.getPrototypeOf(t)),r):void 0}if(typeof t=="string"){let r=e[t];return r!==void 0&&function(s){if(s===null)return null;s.result.push(s.cur.slice(0,s.len))}(i),r}}var rmt=G(()=>{t0(),e0(),hn()});function av(t){return t&&typeof t=="object"&&t instanceof Xs}function J7(t,e){if(e===void 0)return;let i=!1,r=t.map(s=>{let n=s.id,a=U2(s.data,e[n]);if(i=i||a!==void 0,a===void 0&&(a=s.data),s.children){let o=J7(s.children,e);return o!==void 0?i=!0:o=s.children,{...s,id:n,data:a,children:o}}return{...s,id:n,data:a}});return i?r:void 0}function U2(t,e){if(!av(e))return e;if(t instanceof In){let i=J7(t,e);return i!==void 0&&Object.setPrototypeOf(i,Object.getPrototypeOf(t)),i}if(t instanceof ge)return function(i,r){if(r===void 0)return;let s=!1,n=i.map(a=>{let o=a.id,l=U2(a.data,r[o]);return s=s||l!==void 0,l===void 0&&(l=a.data),{...a,id:o,data:l}});return s?(Object.setPrototypeOf(n,Object.getPrototypeOf(i)),n):void 0}(t,e);if(Array.isArray(t)){let i=!1,r=t.map((s,n)=>{let a=U2(s,e[n]);return i=i||a!==void 0,a===void 0&&(a=s),a});return i?(Object.setPrototypeOf(r,Object.getPrototypeOf(t)),r):void 0}if(t instanceof Xs)return tG(t,e);if(t&&typeof t=="object"){let i={},r=!1;for(let[s,n]of Object.entries(t)){let a=U2(n,e[s]);r=r||a!==void 0,a===void 0&&(a=n),i[s]=a}return r?(Object.setPrototypeOf(i,Object.getPrototypeOf(t)),i):void 0}}function tG(t,e){if(t===void 0)return e;if(e===void 0)return t;if(!av(e))return e;if(!av(t))return lm.apply(t,e);let i=new Set;for(let s of Object.keys(t))i.add(s);for(let s of Object.keys(e))i.add(s);let r=new Xs;for(let s of i){let n=tG(t===void 0?void 0:t[s],e===void 0?void 0:e[s]);r[s]=n}return r}var Xs,lm,K4,ea,R$,eG=G(()=>{var t;t0(),e0(),M5(),hn(),Xs=class{unusedFunOverridesTable(e){}runOp(e){let i=[],r=this,s=0,n={};for(;s<e.path.length;){if(i.push(r),r=r===void 0?void 0:r[e.path[s]],r!==void 0&&!av(r))return null;s+=1}r=r?zN(r):new Xs;for(let[a,o]of Object.entries(e.props)){let l=r[a];n[a]=l,o===void 0?delete r[a]:r[a]=o}for(;s>0;){if(Object.keys(r).length===0){let a=i[s-1];a&&(r=zN(a),delete r[e.path[s-1]])}else{let a=i[s-1];if(a){let o=zN(a);o[e.path[s-1]]=r,r=o}else{let o=new Xs;o[e.path[s-1]]=r,r=o}}s-=1}return{data:Object.setPrototypeOf(r,Xs.prototype),actual:e,reverse:{...e,props:n}}}},(t=lm||(lm={})).apply=function(e,i){return U2(e,i)??e},t.merge=function(e,i){return tG(e,i)},t.filterOp=function(e,i){let r=0,s=i.path,n=e;for(;r<s.length&&n!==void 0;){if(n=Dn.zoomOnce(n,s[r]),n===void 0)return i;if(!av(n))return;r+=1}if(n===void 0)return i;if(av(n)){if(i.type===0){let a={...i.props};for(let o of Object.keys(n))delete a[o];return{...i,props:a}}if(i.type===1||i.type===4||i.type===7){let a=J7([i],n);return a?a[0]:i}return i}}}),pMt=G(()=>{hn(),M5(),w5(),t0(),Z7(),Q7(),e0(),rmt(),eG(),(K4||(K4={})).replaceProps=function(t,e){let i=Dn.zoom(e,t.path);if(typeof i=="object"){let r={};for(let s of Object.keys(t.props))r[s]=i[s];return{...t,props:r}}return{...t,props:{}}},(t=>{function e(s,n){let a=n.path,o=[];for(;;){let l;if(s instanceof Xs&&n.type===0&&(l=s.runOp({...n,path:a.slice(o.length)}),l===null&&(l=void 0)),l===void 0&&o.length===a.length&&(l=s instanceof In||s instanceof ge||s instanceof Be?s.runOp(n):Dv.runOp(s,n)),l!==void 0){if(l!==null){let d=l.data;for(let c=o.length-1;c>=0;c--){let p=a[c],m=o[c];if(m instanceof In){if(typeof p=="number")throw new Error("illegal arg");d=m.modifyById(p,d)}else if(m instanceof ge){if(typeof p=="number")throw new Error("illegal arg");d=m.modifyById(p,d)}else if(m instanceof Be){if(typeof p=="number")throw new Error("illegal arg");d=m.modifyById(p,d)}else if(m instanceof Xs){let f={...m,[p]:d};d=Object.setPrototypeOf(f,Xs.prototype)}else{if(typeof m!="object")return null;if(Array.isArray(m)||Yg(m)){if(typeof p=="string"&&(p=parseInt(p),isNaN(p)))throw new Error("Invalid path");let f=d;d=Yg(m)?m.slice():[...m],d[p]=f}else d=Dv.tryPreservePrototype(m,{...m,[p]:d})}}return{data:d,actual:{...l.actual,path:a},reverse:{...l.reverse,path:a}}}return null}let u,h=a[o.length];if(s instanceof In){if(typeof h=="number")throw new Error("");u=s.get(h)?.data}else if(s instanceof ge){if(typeof h=="number")throw new Error("");u=s.get(h)?.data}else s!==null&&(u=s[h]);if(u===void 0)return null;o.push(s),s=u}}function i(s,n){for(let a=0;a<s.length&&a<n.length;a++)if(s[a]!==n[a])return!0;return!1}function r(s,n){if(s.length!==n.length)return!1;for(let a=0;a<s.length;a++)if(s[a]!==n[a])return!1;return!0}t.drop=function(s,n){return{...s,path:s.path.slice(n)}},t.applySimple=function(s,n){return e(s,n)?.data??s},t.apply=e,t.pathDisjoint=i,t.pathEq=r,t.commutative=function(s,n){return i(s.path,n.path)},t.subsumed=function(s,n){return!(s.type!==0||n.type!==0||!r(s.path,n.path))&&Object.keys(s.props).every(a=>n.props[a]!==void 0)}})(ea||(ea={})),(t=>{function e(i,r){let s=i,n=[],a=[];for(let o of r)try{if(o.type===3||o.type===5&&o.path[o.path.length-1]==="variables"){let l,u,h;if(o.type===3?(l=Dn.zoom(s,[...o.path,o.id]),h=ea.apply(s,{...o,type:2})):(l=Dn.zoom(s,[...o.path,o.id,"value"]),h=ea.apply(s,o)),h!==null){s=h.data;let[d,c]=cMt(s,{[o.id]:l});s=d;for(let p=0;p<c.length;p++){let m=c[p],f=m.pop();if(typeof f=="number"){let g=[f];for(let v=p+1;v<c.length;v++){let b=c[v],_=b[b.length-1];if(typeof _!="number"||!Dn.equal(m,b.slice(0,b.length-1)))break;g.push(_),c.splice(v,1)}let y=Dn.zoom(s,m);u=y.map((v,b)=>g.includes(b)?o.id:v),l=y,f=m.pop()}else{if(f==="alphaOverride"||f==="alpha"){l/=100;let g=l,y=Dn.zoom(s,m.slice(0,m.length-2)),v=y.layers.map(b=>b.id===m[m.length-1]?{...b,data:{...b.data,[f]:g}}:b);Object.setPrototypeOf(v,Object.getPrototypeOf(y.layers)),y.layers=v}u=o.id}n.push({type:0,path:m,props:{[f]:l}}),a.push({type:0,path:m,props:{[f]:u}})}a.push(h.reverse),n.push(h.actual)}}else{let l=ea.apply(s,o);l!==null&&(n.push(l.actual),s=l.data,a.push(l.reverse))}}catch(l){if(l instanceof Y7)return null;throw l}return{data:s,actual:n,reverse:a.reverse()}}t.empty=function(){return[]},t.removePrefix=function(i,r){let s=[];for(let n of i){let[a,...o]=n.path;a===r&&s.push({...n,path:o})}return s},t.addPrefix=function(i,r){return i.map(s=>({...s,path:[r,...s.path]}))},t.concat=function(i,r){return[...i,...r]},t.compress=function(i,r){return[...i.filter(s=>!r.some(n=>ea.subsumed(s,n))),...r]},t.commutative=function(i,r){return i.every(s=>r.every(n=>ea.commutative(s,n)))},t.applyAll=function(i,r){for(let s of r){let n=e(i,s);n!==null&&(i=n.data)}return i},t.apply=e})(R$||(R$={}))});function FN(t,e,i){if(t.length>0){let r=t[t.length-1];if(r.type===0&&e.type===0&&Dn.equal(r.path,i))return void Object.assign(r.props,e.props)}t.push({...e,path:i})}function CP(t,e,i){return i instanceof In?new S5(t,e,i):i instanceof ge?new T5(t,e,i):i instanceof Be?new Proxy(new nmt(t,e,i),omt):i!==null&&typeof i=="object"?Yg(i)?i:new Proxy(new smt(t,e,i),amt):i}function Gw(t){let e=new z8(t);return[CP(e,"",t),e]}function Z4(t,e){let[i,r]=Gw(t);return e(i),r.result()}function Gs(t){return t instanceof S5||t instanceof T5?t._current:t!==null&&typeof t=="object"?t[k8]:t}var k8,D$,i_,I0,smt,nmt,UN,amt,omt,S5,T5,z8,Dn,lmt=G(()=>{w5(),t0(),Q7(),e0(),hn(),M5(),k8=Symbol(),D$=Symbol(),i_=Symbol(),I0=class{reportOp(t,e,i=[]){let r=this;if(e===null)return;r._current=e.data;let s=i;for(;!(r instanceof z8);){let n=r._path,a=r._current;if(n!==""&&s.splice(0,0,n),r=r._parent,r===null)return;r.update(n,a)}r.push(s,t,e.actual,e.reverse)}deleteChildren(t){if(this._children){let e=this._children[t];if(e){let i=e[i_];i&&i(),delete this._children[t]}}}},smt=class extends I0{constructor(t,e,i){super(),this._parent=t,this._path=e,this._current=i}update(t,e){if(Array.isArray(this._current)){if(typeof t=="string"&&(t=parseInt(t),isNaN(t)))throw new Error("Invalid path");this._current=[...this._current],this._current[t]=e}else this._current=Dv.tryPreservePrototype(this._current,{...this._current,[t]:e})}runOp(t){this.reportOp(t,Dv.runOp(this._current,t),t.path)}},nmt=class extends I0{constructor(t,e,i){super(),this._parent=t,this._path=e,this._current=i}update(t,e){this._current={...this._current,[t]:e},Object.setPrototypeOf(this._current,Be.prototype)}runOp(t){this.reportOp(t,this._current.runOp(t))}},UN={get(t,e){if(e===i_)return()=>{t._parent=null};if(e===k8)return t._current;if(e===D$)return t;let{_current:i,_children:r}=t;if(e==="push"&&Array.isArray(i))throw new Error("not supported to expand array");let s=r===void 0?void 0:r[e];if(s!==void 0)return s;let n=i[e],a=CP(t,e,n);return a!==n?(r===void 0&&(r={},t._children=r),r[e]=a,a):n},has:(t,e)=>e in t._current,ownKeys:t=>Reflect.ownKeys(t._current),defineProperty(){throw Error("not supported")},getPrototypeOf:t=>Object.getPrototypeOf(t._current),setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(t,e){let i=t._current,r=Reflect.getOwnPropertyDescriptor(i,e);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:i[e]}}},amt={...UN,set(t,e,i){let r={type:0,props:{[e]:Gs(i)??i}};return t.deleteChildren(e),t.runOp(r),!0},deleteProperty(t,e){let i={type:0,props:{[e]:void 0}};return t.deleteChildren(e),t.runOp(i),!0}},omt={...UN,set(t,e,i){return i===void 0?this.deleteProperty(t,e):(t.deleteChildren(e),t.runOp({type:1,id:e,data:i})),!0},deleteProperty:(t,e)=>(t.runOp({type:2,id:e}),!0)},S5=class extends I0{constructor(t,e,i){super(),this._children={},this._parent=t,this._path=e,this._current=i,this[i_]=()=>{this._parent=null}}unproxy(){return this._current}update(t,e){this._current=this._current.modifyById(t,e)}runOp(t){this.reportOp(t,this._current.runOp(t))}randomId(){return this._current.randomId()}isDescendantOf(t,e){return this._current.isDescendantOf(t,e)}childrenOf(t){return this._current.childrenOf(t)}get(t){return this._current.get(t)}parent(t){return this._current.parent(t)}traverse(t){this._current.traverse((e,i)=>{t(e,this.data(e))})}data(t){let{_current:e,_children:i}=this,r=i===void 0?void 0:i[t];if(r!==void 0)return r;let s=e.get(t)?.data,n=CP(this,t,s);return n!==s?(i===void 0&&(i={},this._children=i),i[t]=n,n):s}add(t,e,i,r,s){this.runOp({type:7,parent:t,fi:e,id:i,data:r,children:s})}move(t,e,i){this.runOp({type:9,parent:t,fi:e,id:i})}insertAfter(t,e,i){let r=this._current.insertAfterHelper(t,e,i.length);for(let s=0;s<i.length;s++){let n=i[s];this.add(t,r[s],n.id,n.data,n.children)}}insertBefore(t,e,i){let r=this._current.insertBeforeHelper(t,e,i.length);for(let s=0;s<i.length;s++){let n=i[s];this.add(t,r[s],n.id,n.data,n.children)}}moveAfter(t,e,i){let r=this._current.insertAfterHelper(t,e,i.length);for(let s=0;s<i.length;s++){let n=i[s];this.move(t,r[s],n)}}moveBefore(t,e,i){let r=this._current.insertBeforeHelper(t,e,i.length);for(let s=0;s<i.length;s++){let n=i[s];this.move(t,r[s],n)}}delete(t){this.deleteChildren(t),this.runOp({type:8,id:t})}sortNext(t){return this._current.sortNext(t)}sortPrevious(t){return this._current.sortPrevious(t)}getAllSorted(t){return this._current.getAllSorted(t)}},T5=class extends I0{constructor(t,e,i){super(),this._children={},this._parent=t,this._path=e,this._current=i,this[i_]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(t){let e=this.length;for(let i=0;i<e;i++){let r=this._current[i].id,s=this._current[i].fi;t(this.data(this._current[i].id),r,s,i)}}find(t){let e=this.length;for(let i=0;i<e;i++){let r=this._current[i].id;if(t(this.data(r),r))return this.get(r)}}update(t,e){this._current=this._current.modifyById(t,e)}randomId(){return this._current.randomId()}get(t){return{...this._current.get(t),data:this.data(t)}}at(t){let{id:e,fi:i}=this._current.at(t);return{id:e,fi:i,data:this.data(e)}}data(t){let{_current:e,_children:i}=this,r=i===void 0?void 0:i[t];if(r!==void 0)return r;let s=e.get(t)?.data,n=CP(this,t,s);return n!==s?(i===void 0&&(i={},this._children=i),i[t]=n,n):s}runOp(t){this.reportOp(t,this._current.runOp(t))}add(t,e,i){this.runOp({type:4,fi:t,id:e,data:i})}move(t,e){this.runOp({type:6,fi:t,id:e})}insertAfter(t,e){let i=this._current.insertAfterHelper(t,e.length);for(let r=0;r<e.length;r++){let s=e[r];this.add(i[r],s.id,s.data)}}insertBefore(t,e){let i=this._current.insertBeforeHelper(t,e.length);for(let r=0;r<e.length;r++){let s=e[r];this.add(i[r],s.id,s.data)}}moveAfter(t,e){let i=this._current.insertAfterHelper(t,e.length);for(let r=0;r<e.length;r++){let s=e[r];this.move(i[r],s)}}moveBefore(t,e){let i=this._current.insertBeforeHelper(t,e.length);for(let r=0;r<e.length;r++){let s=e[r];this.move(i[r],s)}}delete(t){this.deleteChildren(t),this.runOp({type:5,id:t})}},z8=class extends I0{constructor(t){super(),this.ts=[],this.actual=[],this.reverse=[],this._current=t}update(t,e){if(t!=="")throw new Error("");this._current=e}push(t,e,i,r){FN(this.ts,e,t),FN(this.actual,i,t),FN(this.reverse,r,t)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}}}),M5=G(()=>{K7(),lmt(),e0(),t0(),hn(),(t=>{function e(r,s){return(r instanceof In||r instanceof S5)&&typeof s=="string"||(r instanceof ge||r instanceof T5)&&typeof s=="string"?r.data(s):typeof s=="number"&&Array.isArray(r)||typeof s=="string"&&typeof r=="object"&&r!==null?r[s]:void 0}function i(r,s,n=0){for(;n<s.length&&r!==void 0;)r=e(r,s[n]),n+=1;return r}t.equal=function(r,s){if(s.length!==r.length)return!1;{let n=0;for(;n<r.length;){if(r[n]!==s[n])return!1;n+=1}}return!0},t.removeOverridden=function(r,s,n){let a=i(n,r);if(a!==void 0&&typeof a=="object"&&a!==null){let o={...s};return Object.keys(a).forEach(l=>{delete o[l]}),o}return s},t.zoomOnce=e,t.zoom=i,t.findPathes=function(r,s){let n=[];return function a(o,l){if(o instanceof Y4&&o.id===s.id)n.push(l);else if(o instanceof ge)for(let u=0;u<o.length;u++)a(o[u].data,[...l,o[u].id]);else if(o instanceof In)o.traverse((u,h)=>{a(h,[...l,u])});else if(Array.isArray(o)){if(typeof o[0]=="number")return;for(let u=0;u<o.length;u++)a(o[u],[...l,u])}else{if(Yg(o))return;if(typeof o=="object"&&o!==null)for(let u in o)a(o[u],[...l,u])}}(r,[]),n}})(Dn||(Dn={}))}),mMt=G(()=>{});function er(t,e){let i=[];if(!(e.length<=t.length))return null;{let r=0;for(;r<e.length;){if(e[r]==="*")i.push(t[r]);else if(t[r]!==e[r])return null;r+=1}}return i}var fMt=G(()=>{});function gM(t){try{if(!Er.trusted&&!fc){let i=Wi.sharedLength||0;i<Wi.length&&(Wi.length=i)}let e;if(Er.randomAccessStructure&&pe[mt]<64&&pe[mt]>=32&&k$?(e=k$(pe,mt,Ql,Er),pe=null,!(t&&t.lazy)&&e&&(e=e.toJSON()),mt=Ql):e=$s(),Da&&(mt=Da.postBundlePosition,Da=null),fc&&(Wi.restoreStructures=null),mt==Ql)Wi&&Wi.restoreStructures&&N$(),Wi=null,pe=null,mc&&(mc=null);else{if(mt>Ql)throw new Error("Unexpected end of MessagePack data");if(!fc){let i;try{i=JSON.stringify(e,(r,s)=>typeof s=="bigint"?`${s}n`:s).slice(0,100)}catch(r){i="(JSON view not available "+r+")"}throw new Error("Data read, but end of buffer not reached "+i)}}return e}catch(e){throw Wi&&Wi.restoreStructures&&N$(),F8(),(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer")||mt>Ql)&&(e.incomplete=!0),e}}function N$(){for(let t in Wi.restoreStructures)Wi[t]=Wi.restoreStructures[t];Wi.restoreStructures=null}function $s(){let t=pe[mt++];if(t<160){if(t<128){if(t<64)return t;{let e=Wi[63&t]||Er.getStructures&&hmt()[63&t];return e?(e.read||(e.read=L8(e,63&t)),e.read()):t}}if(t<144){if(t-=128,Er.mapsAsObjects){let e={};for(let i=0;i<t;i++){let r=dmt();r==="__proto__"&&(r="__proto_"),e[r]=$s()}return e}{let e=new Map;for(let i=0;i<t;i++)e.set($s(),$s());return e}}{t-=144;let e=new Array(t);for(let i=0;i<t;i++)e[i]=$s();return Er.freezeData?Object.freeze(e):e}}if(t<192){let e=t-160;if(qh>=mt)return Qp.slice(mt-pl,(mt+=e)-pl);if(qh==0&&Ql<140){let i=e<16?iG(e):umt(e);if(i!=null)return i}return tR(e)}{let e;switch(t){case 192:return null;case 193:return Da?(e=$s(),e>0?Da[1].slice(Da.position1,Da.position1+=e):Da[0].slice(Da.position0,Da.position0-=e)):mmt;case 194:return!1;case 195:return!0;case 196:if(e=pe[mt++],e===void 0)throw new Error("Unexpected end of buffer");return jN(e);case 197:return e=zi.getUint16(mt),mt+=2,jN(e);case 198:return e=zi.getUint32(mt),mt+=4,jN(e);case 199:return Qm(pe[mt++]);case 200:return e=zi.getUint16(mt),mt+=2,Qm(e);case 201:return e=zi.getUint32(mt),mt+=4,Qm(e);case 202:if(e=zi.getFloat32(mt),Er.useFloat32>2){let i=H8[(127&pe[mt])<<1|pe[mt+1]>>7];return mt+=4,(i*e+(e>0?.5:-.5)|0)/i}return mt+=4,e;case 203:return e=zi.getFloat64(mt),mt+=8,e;case 204:return pe[mt++];case 205:return e=zi.getUint16(mt),mt+=2,e;case 206:return e=zi.getUint32(mt),mt+=4,e;case 207:return Er.int64AsType==="number"?(e=4294967296*zi.getUint32(mt),e+=zi.getUint32(mt+4)):Er.int64AsType==="string"?e=zi.getBigUint64(mt).toString():Er.int64AsType==="auto"?(e=zi.getBigUint64(mt),e<=BigInt(2)<<BigInt(52)&&(e=Number(e))):e=zi.getBigUint64(mt),mt+=8,e;case 208:return zi.getInt8(mt++);case 209:return e=zi.getInt16(mt),mt+=2,e;case 210:return e=zi.getInt32(mt),mt+=4,e;case 211:return Er.int64AsType==="number"?(e=4294967296*zi.getInt32(mt),e+=zi.getUint32(mt+4)):Er.int64AsType==="string"?e=zi.getBigInt64(mt).toString():Er.int64AsType==="auto"?(e=zi.getBigInt64(mt),e>=BigInt(-2)<<BigInt(52)&&e<=BigInt(2)<<BigInt(52)&&(e=Number(e))):e=zi.getBigInt64(mt),mt+=8,e;case 212:if(e=pe[mt++],e==114)return q8(63&pe[mt++]);{let i=Ma[e];if(i)return i.read?(mt++,i.read($s())):i.noBuffer?(mt++,i()):i(pe.subarray(mt,++mt));throw new Error("Unknown extension "+e)}case 213:return e=pe[mt],e==114?(mt++,q8(63&pe[mt++],pe[mt++])):Qm(2);case 214:return Qm(4);case 215:return Qm(8);case 216:return Qm(16);case 217:return e=pe[mt++],qh>=mt?Qp.slice(mt-pl,(mt+=e)-pl):gmt(e);case 218:return e=zi.getUint16(mt),qh>=(mt+=2)?Qp.slice(mt-pl,(mt+=e)-pl):ymt(e);case 219:return e=zi.getUint32(mt),qh>=(mt+=4)?Qp.slice(mt-pl,(mt+=e)-pl):vmt(e);case 220:return e=zi.getUint16(mt),mt+=2,O$(e);case 221:return e=zi.getUint32(mt),mt+=4,O$(e);case 222:return e=zi.getUint16(mt),mt+=2,I$(e);case 223:return e=zi.getUint32(mt),mt+=4,I$(e);default:if(t>=224)return t-256;if(t===void 0){let i=new Error("Unexpected end of MessagePack data");throw i.incomplete=!0,i}throw new Error("Unknown MessagePack token "+t)}}}function L8(t,e){function i(){if(i.count++>j8){let s;try{s=t.read=new Function("r","return function(){return "+(Er.freezeData?"Object.freeze":"")+"({"+t.map(n=>n==="__proto__"?"__proto_:r()":fmt.test(n)?n+":r()":"["+JSON.stringify(n)+"]:r()").join(",")+"})}")($s)}catch{return j8=1/0,i()}return t.read0=s,t.highByte===0&&(t.read=G8(e,t.read)),s()}let r={};for(let s=0,n=t.length;s<n;s++){let a=t[s];a==="__proto__"&&(a="__proto_"),r[a]=$s()}return Er.freezeData?Object.freeze(r):r}return i.count=0,t.read0=i,t.highByte===0?G8(e,i):i}function hmt(){let t=pmt(()=>(pe=null,Er.getStructures()));return Wi=Er._mergeStructures(t,Wi)}function Ww(t){let e;if(t<16&&(e=iG(t)))return e;if(t>64&&U8)return U8.decode(pe.subarray(mt,mt+=t));let i=mt+t,r=[];for(e="";mt<i;){let s=pe[mt++];if(128&s)if((224&s)==192){let n=(31&s)<<6|63&pe[mt++];n<128?r.push(65533):r.push(n)}else if((240&s)==224){let n=(31&s)<<12|(63&pe[mt++])<<6|63&pe[mt++];n<2048||n>=55296&&n<=57343?r.push(65533):r.push(n)}else if((248&s)==240){let n=(7&s)<<18|(63&pe[mt++])<<12|(63&pe[mt++])<<6|63&pe[mt++];n<65536||n>1114111?r.push(65533):(n>65535&&(n-=65536,r.push(n>>>10&1023|55296),n=56320|1023&n),r.push(n))}else r.push(65533);else r.push(s);r.length>=4096&&(e+=Tn.apply(String,r),r.length=0)}return r.length>0&&(e+=Tn.apply(String,r)),e}function O$(t){let e=new Array(t);for(let i=0;i<t;i++)e[i]=$s();return Er.freezeData?Object.freeze(e):e}function I$(t){if(Er.mapsAsObjects){let e={};for(let i=0;i<t;i++){let r=dmt();r==="__proto__"&&(r="__proto_"),e[r]=$s()}return e}{let e=new Map;for(let i=0;i<t;i++)e.set($s(),$s());return e}}function umt(t){let e=mt,i=new Array(t);for(let r=0;r<t;r++){let s=pe[mt++];if((128&s)>0)return void(mt=e);i[r]=s}return Tn.apply(String,i)}function iG(t){if(t<4){if(t<2){if(t===0)return"";{let e=pe[mt++];return(128&e)>1?void(mt-=1):Tn(e)}}{let e=pe[mt++],i=pe[mt++];if((128&e)>0||(128&i)>0)return void(mt-=2);if(t<3)return Tn(e,i);let r=pe[mt++];return(128&r)>0?void(mt-=3):Tn(e,i,r)}}{let e=pe[mt++],i=pe[mt++],r=pe[mt++],s=pe[mt++];if((128&e)>0||(128&i)>0||(128&r)>0||(128&s)>0)return void(mt-=4);if(t<6){if(t===4)return Tn(e,i,r,s);{let n=pe[mt++];return(128&n)>0?void(mt-=5):Tn(e,i,r,s,n)}}if(t<8){let n=pe[mt++],a=pe[mt++];if((128&n)>0||(128&a)>0)return void(mt-=6);if(t<7)return Tn(e,i,r,s,n,a);let o=pe[mt++];return(128&o)>0?void(mt-=7):Tn(e,i,r,s,n,a,o)}{let n=pe[mt++],a=pe[mt++],o=pe[mt++],l=pe[mt++];if((128&n)>0||(128&a)>0||(128&o)>0||(128&l)>0)return void(mt-=8);if(t<10){if(t===8)return Tn(e,i,r,s,n,a,o,l);{let u=pe[mt++];return(128&u)>0?void(mt-=9):Tn(e,i,r,s,n,a,o,l,u)}}if(t<12){let u=pe[mt++],h=pe[mt++];if((128&u)>0||(128&h)>0)return void(mt-=10);if(t<11)return Tn(e,i,r,s,n,a,o,l,u,h);let d=pe[mt++];return(128&d)>0?void(mt-=11):Tn(e,i,r,s,n,a,o,l,u,h,d)}{let u=pe[mt++],h=pe[mt++],d=pe[mt++],c=pe[mt++];if((128&u)>0||(128&h)>0||(128&d)>0||(128&c)>0)return void(mt-=12);if(t<14){if(t===12)return Tn(e,i,r,s,n,a,o,l,u,h,d,c);{let p=pe[mt++];return(128&p)>0?void(mt-=13):Tn(e,i,r,s,n,a,o,l,u,h,d,c,p)}}{let p=pe[mt++],m=pe[mt++];if((128&p)>0||(128&m)>0)return void(mt-=14);if(t<15)return Tn(e,i,r,s,n,a,o,l,u,h,d,c,p,m);let f=pe[mt++];return(128&f)>0?void(mt-=15):Tn(e,i,r,s,n,a,o,l,u,h,d,c,p,m,f)}}}}}function B$(){let t,e=pe[mt++];if(e<192)t=e-160;else switch(e){case 217:t=pe[mt++];break;case 218:t=zi.getUint16(mt),mt+=2;break;case 219:t=zi.getUint32(mt),mt+=4;break;default:throw new Error("Expected string")}return Ww(t)}function jN(t){return Er.copyBuffers?Uint8Array.prototype.slice.call(pe,mt,mt+=t):pe.subarray(mt,mt+=t)}function Qm(t){let e=pe[mt++];if(Ma[e]){let i;return Ma[e](pe.subarray(mt,i=mt+=t),r=>{mt=r;try{return $s()}finally{mt=i}})}throw new Error("Unknown extension type "+e)}function dmt(){let t=pe[mt++];if(!(t>=160&&t<192))return mt--,cmt($s());if(t-=160,qh>=mt)return Qp.slice(mt-pl,(mt+=t)-pl);if(!(qh==0&&Ql<180))return tR(t);let e,i=4095&(t<<5^(t>1?zi.getUint16(mt):t>0?pe[mt]:0)),r=W8[i],s=mt,n=mt+t-3,a=0;if(r&&r.bytes==t){for(;s<n;){if(e=zi.getUint32(s),e!=r[a++]){s=1879048192;break}s+=4}for(n+=3;s<n;)if(e=pe[s++],e!=r[a++]){s=1879048192;break}if(s===n)return mt=s,r.string;n-=3,s=mt}for(r=[],W8[i]=r,r.bytes=t;s<n;)e=zi.getUint32(s),r.push(e),s+=4;for(n+=3;s<n;)e=pe[s++],r.push(e);let o=t<16?iG(t):umt(t);return r.string=o??tR(t)}function cmt(t){if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean"||typeof t=="bigint")return t.toString();if(t==null)return t+"";if(Er.allowArraysInMapKeys&&Array.isArray(t)&&t.flat().every(e=>["string","number","boolean","bigint"].includes(typeof e)))return t.flat().toString();throw new Error("Invalid property type for record: "+typeof t)}function pmt(t){z$&&z$();let e=Ql,i=mt,r=J4,s=pl,n=qh,a=Qp,o=Q4,l=mc,u=Da,h=new Uint8Array(pe.slice(0,Ql)),d=Wi,c=Wi.slice(0,Wi.length),p=Er,m=fc,f=t();return Ql=e,mt=i,J4=r,pl=s,qh=n,Qp=a,Q4=o,mc=l,Da=u,pe=h,fc=m,(Wi=d).splice(0,Wi.length,...c),Er=p,zi=new DataView(pe.buffer,pe.byteOffset,pe.byteLength),f}function F8(){pe=null,mc=null,Wi=null}function gMt(t){t.unpack?Ma[t.type]=t.unpack:Ma[t.type]=t}var U8,pe,Ql,mt,V$,Q4,J4,Er,Wi,Qp,pl,qh,Da,mc,Ma,zi,GN,mmt,fc,j8,k$,z$,qw,fmt,G8,tR,gmt,ymt,vmt,Tn,W8,q8,WN,L$,F$,U$,H8,yM,j$,G$,W$,$8,qN,CS,yMt=G(()=>{try{U8=new TextDecoder}catch{}mt=0,Q4=V$=[],J4=0,Er={},pl=0,qh=0,Ma=[],GN={useRecords:!1,mapsAsObjects:!0},(mmt=new class{}).name="MessagePack 0xC1",fc=!1,j8=2,qw=class{constructor(t){t&&(t.useRecords===!1&&t.mapsAsObjects===void 0&&(t.mapsAsObjects=!0),t.sequential&&t.trusted!==!1&&(t.trusted=!0,!t.structures&&t.useRecords!=0&&(t.structures=[],t.maxSharedStructures||(t.maxSharedStructures=0))),t.structures?t.structures.sharedLength=t.structures.length:t.getStructures&&((t.structures=[]).uninitialized=!0,t.structures.sharedLength=0),t.int64AsNumber&&(t.int64AsType="number")),Object.assign(this,t)}unpack(t,e){if(pe)return pmt(()=>(F8(),this?this.unpack(t,e):qw.prototype.unpack.call(GN,t,e)));!t.buffer&&t.constructor===ArrayBuffer&&(t=typeof Buffer<"u"?Buffer.from(t):new Uint8Array(t)),typeof e=="object"?(Ql=e.end||t.length,mt=e.start||0):(mt=0,Ql=e>-1?e:t.length),J4=0,qh=0,Qp=null,Q4=V$,Da=null,pe=t;try{zi=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(i){throw pe=null,t instanceof Uint8Array?i:new Error("Source must be a Uint8Array or Buffer but was a "+(t&&typeof t=="object"?t.constructor.name:typeof t))}if(this instanceof qw){if(Er=this,this.structures)return Wi=this.structures,gM(e);(!Wi||Wi.length>0)&&(Wi=[])}else Er=GN,(!Wi||Wi.length>0)&&(Wi=[]);return gM(e)}unpackMultiple(t,e){let i,r=0;try{fc=!0;let s=t.length,n=this?this.unpack(t,s):yM.unpack(t,s);if(!e){for(i=[n];mt<s;)r=mt,i.push(gM());return i}if(e(n,r,mt)===!1)return;for(;mt<s;)if(r=mt,e(gM(),r,mt)===!1)return}catch(s){throw s.lastPosition=r,s.values=i,s}finally{fc=!1,F8()}}_mergeStructures(t,e){t=t||[],Object.isFrozen(t)&&(t=t.map(i=>i.slice(0)));for(let i=0,r=t.length;i<r;i++){let s=t[i];s&&(s.isShared=!0,i>=32&&(s.highByte=i-32>>5))}t.sharedLength=t.length;for(let i in e||[])if(i>=0){let r=t[i],s=e[i];s&&(r&&((t.restoreStructures||(t.restoreStructures=[]))[i]=r),t[i]=s)}return this.structures=t}decode(t,e){return this.unpack(t,e)}},fmt=/^[a-zA-Z_$][a-zA-Z\d_$]*$/,G8=(t,e)=>function(){let i=pe[mt++];if(i===0)return e();let r=t<32?-(t+(i<<5)):t+(i<<5),s=Wi[r]||hmt()[r];if(!s)throw new Error("Record id is not defined for "+r);return s.read||(s.read=L8(s,t)),s.read()},tR=Ww,gmt=Ww,ymt=Ww,vmt=Ww,Tn=String.fromCharCode,W8=new Array(4096),q8=(t,e)=>{let i=$s().map(cmt),r=t;e!==void 0&&(t=t<32?-((e<<5)+t):(e<<5)+t,i.highByte=e);let s=Wi[t];return s&&(s.isShared||fc)&&((Wi.restoreStructures||(Wi.restoreStructures=[]))[t]=s),Wi[t]=i,i.read=L8(i,r),(i.read0||i.read)()},Ma[0]=()=>{},Ma[0].noBuffer=!0,Ma[66]=t=>{let e=t.byteLength%8||8,i=BigInt(128&t[0]?t[0]-256:t[0]);for(let r=1;r<e;r++)i<<=BigInt(8),i+=BigInt(t[r]);if(t.byteLength!==e){let r=new DataView(t.buffer,t.byteOffset,t.byteLength),s=(n,a)=>{let o=a-n;if(o<=40){let d=r.getBigUint64(n);for(let c=n+8;c<a;c+=8)d<<=BigInt(64),d|=r.getBigUint64(c);return d}let l=n+(o>>4<<3),u=s(n,l),h=s(l,a);return u<<BigInt(8*(a-l))|h};i=i<<BigInt(8*(r.byteLength-e))|s(e,r.byteLength)}return i},WN={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError,AggregateError:typeof AggregateError=="function"?AggregateError:null},Ma[101]=()=>{let t=$s();if(!WN[t[0]]){let e=Error(t[1],{cause:t[2]});return e.name=t[0],e}return WN[t[0]](t[1],{cause:t[2]})},Ma[105]=t=>{if(Er.structuredClone===!1)throw new Error("Structured clone extension is disabled");let e=zi.getUint32(mt-4);mc||(mc=new Map);let i,r=pe[mt];i=r>=144&&r<160||r==220||r==221?[]:r>=128&&r<144||r==222||r==223?new Map:(r>=199&&r<=201||r>=212&&r<=216)&&pe[mt+1]===115?new Set:{};let s={target:i};mc.set(e,s);let n=$s();if(!s.used)return s.target=n;if(Object.assign(i,n),i instanceof Map)for(let[a,o]of n.entries())i.set(a,o);if(i instanceof Set)for(let a of Array.from(n))i.add(a);return i},Ma[112]=t=>{if(Er.structuredClone===!1)throw new Error("Structured clone extension is disabled");let e=zi.getUint32(mt-4),i=mc.get(e);return i.used=!0,i.target},Ma[115]=()=>new Set($s()),L$=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(t=>t+"Array"),F$=typeof globalThis=="object"?globalThis:window,Ma[116]=t=>{let e=t[0],i=Uint8Array.prototype.slice.call(t,1).buffer,r=L$[e];if(!r){if(e===16)return i;if(e===17)return new DataView(i);throw new Error("Could not find typed array for code "+e)}return new F$[r](i)},Ma[120]=()=>{let t=$s();return new RegExp(t[0],t[1])},U$=[],Ma[98]=t=>{let e=(t[0]<<24)+(t[1]<<16)+(t[2]<<8)+t[3],i=mt;return mt+=e-t.length,Da=U$,(Da=[B$(),B$()]).position0=0,Da.position1=0,Da.postBundlePosition=mt,mt=i,$s()},Ma[255]=t=>t.length==4?new Date(1e3*(16777216*t[0]+(t[1]<<16)+(t[2]<<8)+t[3])):t.length==8?new Date(((t[0]<<22)+(t[1]<<14)+(t[2]<<6)+(t[3]>>2))/1e6+1e3*(4294967296*(3&t[3])+16777216*t[4]+(t[5]<<16)+(t[6]<<8)+t[7])):t.length==12?new Date(((t[0]<<24)+(t[1]<<16)+(t[2]<<8)+t[3])/1e6+1e3*((128&t[4]?-281474976710656:0)+1099511627776*t[6]+4294967296*t[7]+16777216*t[8]+(t[9]<<16)+(t[10]<<8)+t[11])):new Date("invalid"),H8=new Array(147);for(let t=0;t<256;t++)H8[t]=+("1e"+Math.floor(45.15-.30103*t));(yM=new qw({useRecords:!1})).unpack,yM.unpackMultiple,yM.unpack,j$=new Float32Array(1),new Uint8Array(j$.buffer,0,4)}),vMt=G(()=>{yMt(),K7(),eG(),e0(),w5(),t0(),G$=[{Class:Be.prototype.constructor,type:1,write:t=>({...t}),read:t=>(Object.setPrototypeOf(t,Be.prototype),t)},{Class:ge.prototype.constructor,type:2,write:t=>[...t],read:t=>(Object.setPrototypeOf(t,ge.prototype),t)},{Class:In.prototype.constructor,type:3,write:t=>[...t],read:t=>(Object.setPrototypeOf(t,In.prototype),t)},{Class:Y4.prototype.constructor,type:4,write:t=>t.id,read:t=>new Y4(t)},{Class:V8.prototype.constructor,type:5,write:t=>t.data,read:t=>new V8(t)},{Class:Xs.prototype.constructor,type:6,write:t=>({...t}),read:t=>(Object.setPrototypeOf(t,Xs.prototype),t)}];for(let t of G$)gMt(t);W$=new qw({structuredClone:!0}),($8||($8={})).deserialize=function(t){return W$.unpack(t)}}),bMt=G(()=>{vMt(),qN=t=>()=>{throw new Error(t+" is not available in the runtime build (decode-only CollabSerialize)")},CS={deserialize:$8.deserialize,serialize:qN("CollabSerialize.serialize"),checksum:qN("CollabSerialize.checksum")}}),Fi=G(()=>{M5(),dMt(),Z7(),t0(),w5(),Q7(),e0(),pMt(),mMt(),lmt(),fMt(),K7(),bMt(),rmt(),eG()});function X8(t){return t==="MouseDown"||t==="MouseUp"||t==="KeyDown"||t==="KeyUp"||t==="Collision"||t==="Trigger"}var q$,Y8,j2,vM,HN,H$,$$,X$,K8,Z8,Y$,K$,Z$,Q$,J$,Q8,J8,tX,eX,iX,rX,bmt=G(()=>{var t,e,i;Fi(),dt(),(t=q$||(q$={})).toEventUIType=function(r){return r.type==="Conditional"?r.condition.type==="Distance"?"Distance":"StateChange":r.type},t.fromEventUIType=function(r){return r==="Distance"||r==="StateChange"?"Conditional":r},Y8={LookAt:[],Follow:["Create"],DragDrop:["Transition","Animation","Audio","Particles","Create","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],MouseHover:["Transition","Animation","TimelineAnimation","Particles","Create","Destroy","SwitchCamera","SceneTransition","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Scroll:["Transition","Animation","TimelineAnimation","Create","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Start:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Conditional:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],MouseDown:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],MouseUp:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],MousePress:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],KeyDown:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],KeyUp:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],KeyPress:["Transition","Animation","Audio","Particles","Video","Link","Create","SwitchCamera","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],GameControl:["Transition","Animation","TimelineAnimation","Audio","Particles","Create","Conditional"],Collision:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Create","Destroy","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Trigger:["Transition","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Resize:["Transition","Animation","Audio","Particles","Video","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],VariableChange:["Transition","Animation","TimelineAnimation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],API:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],WEBHOOK:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],AIAssistantListener:["SetVariable"],AIAssistantTrigger:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"]},(r=>{r.is=function(s){return s.type==="MouseDown"||s.type==="MouseUp"||s.type==="MousePress"||s.type==="KeyDown"||s.type==="KeyUp"||s.type==="KeyPress"},r.defaultData=function(s){return s==="MouseDown"||s==="MouseUp"||s==="MousePress"?{type:s,mode:"Object",disabled:!1,name:"",actions:new ge}:{type:s,disabled:!1,name:"",key:void 0,actions:new ge}}})(j2||(j2={})),(r=>{r.propertyDefaultData=function(s){return{type:"Property",value:[s??null,"position","x"]}},r.valueDefaultData={type:"Literal",value:0}})(vM||(vM={})),(e=HN||(HN={})).comparisonDefaultData=function(r){return{type:"Comparison",operator:"==",lOperand:vM.propertyDefaultData(r),rOperand:{...vM.valueDefaultData}}},e.distanceDefaultData=function(r){return{type:"Distance",toObject:r??null,fromObject:r??null,distance:200}},e.stateDefaultData=function(r,s){return{type:"State",object:r??null,state:s??null}},(H$||(H$={})).isConditionalSubActions=function(r){return r.find(s=>s==="ifActions"||s==="elseActions")!==void 0},(r=>{r.is=function(s){return s.type==="Conditional"},r.defaultData=function(s){return{type:"Conditional",disabled:!1,name:"",inActions:new ge,outActions:new ge,condition:HN.distanceDefaultData(s)}}})($$||($$={})),(X$||(X$={})).defaultData={type:"DragDrop",name:"",cursor:"hand",disabled:!1,dampingFactor:1,objects:[],snapTo:"center",snapSurfaceMode:"bbox",snapSurfaceOffset:0,dropOn:"all",autoOrient:!0,dropDestinations:[],plane:"adaptive",planeMode:"locked",referenceFrame:"global",limits:[-1/0,1/0,-1/0,1/0,-1/0,1/0],drop:!1,resetOnSnapFail:!1,snapSpeed:20,resetSpeed:20,dragDropActions:{drag:new ge,drop:new ge}},(K8||(K8={})).defaultData={type:"Follow",disabled:!1,name:"",maxDelta:0,dampingFactor:1,target:"cursor",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledTranslation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5,actions:new ge},(Z8||(Z8={})).defaultData={type:"LookAt",disabled:!1,name:"",distance:1e3,dampingFactor:1,target:"cursor",tilt:"up",axis:"z",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledRotation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5},(r=>{r.is=function(s){return s.type==="MouseHover"},r.defaultData=function(){return{type:"MouseHover",disabled:!1,name:"",actions:new ge}}})(Y$||(Y$={})),(r=>{r.is=function(s){return s.type==="Scroll"},r.defaultData=function(){return{type:"Scroll",disabled:!1,name:"",steps:100,trigger:"load",startFrom:"enter",enterAnchor:"top",startOffset:0,endAfter:400,actions:new ge}}})(K$||(K$={})),(r=>{r.is=function(s){return s.type==="Start"},r.defaultData=function(){return{type:"Start",disabled:!1,name:"",actions:new ge}}})(Z$||(Z$={})),(r=>{r.is=function(s){return s.type==="Collision"},r.defaultData=function(){return{type:"Collision",disabled:!1,name:"",target:"character",actions:new ge}}})(Q$||(Q$={})),(r=>{r.is=function(s){return s.type==="Trigger"},r.defaultData=function(s,n){return{type:"Trigger",name:"",disabled:!1,target:"all",triggeringObjects:[],actions:new ge,triggerZone:"box",position:n.toArray(),rotation:[0,0,0],size:s.toArray(),radius:s.length()/2,helperVisible:!0}}})(J$||(J$={})),(i=Q8||(Q8={})).defaultSizes={mobile:[480,480],tablet:[768,768],desktop:[1200,1200],custom:[769,1200]},i.is=function(r){return r.type==="Resize"},i.sizeToDevice=function(r){return typeof r=="string"?r:"custom"},i.deviceToSize=function(r){return typeof r=="string"?[...i.defaultSizes[r]]:[...r]},i.defaultData=function(){let r={size:"mobile",operator:"<",actions:new ge},s={size:"tablet",operator:"<",actions:new ge},n={size:[...i.defaultSizes.custom],operator:"<>",actions:new ge},a=new ge;return a.push({id:qt.generateUUID(),fi:0,data:r},{id:qt.generateUUID(),fi:1,data:s},{id:qt.generateUUID(),fi:2,data:n}),{type:"Resize",disabled:!1,name:"",orientation:"horizontal",breakpoints:a}},i.defaultBreakpointData=function(){return{size:[...i.defaultSizes.custom],operator:"<>",actions:new ge}},(r=>{r.propertyPaths={Position:["position"],"Position X":["position","x"],"Position Y":["position","y"],"Position Z":["position","z"],Rotation:["rotation"],"Rotation X":["rotation","x"],"Rotation Y":["rotation","y"],"Rotation Z":["rotation","z"],Scale:["scale"],"Scale X":["scale","x"],"Scale Y":["scale","y"],"Scale Z":["scale","z"],Width:["width"],Height:["height"],Depth:["depth"],"Mouse Position X":["mouse","x"],"Mouse Position Y":["mouse","y"],"Mouse Pressed":["mouse","pressed"],"Screen Width":["mouse","width"],"Screen Height":["mouse","height"],"Hit Position X":["raycast","x"],"Hit Position Y":["raycast","y"],"Hit Position Z":["raycast","z"],"Hit Object Position X":["raycast","objX"],"Hit Object Position Y":["raycast","objY"],"Hit Object Position Z":["raycast","objZ"]},r.is=function(s){return s.type==="VariableChange"},r.defaultData=function(){return{disabled:!1,type:"VariableChange",name:"",actions:new ge,variableId:"",objectId:null,property:"Position X"}}})(J8||(J8={})),(r=>{r.is=function(s){return s.type==="API"},r.defaultData=function(){return{disabled:!1,type:"API",name:"",successActions:new ge,errorActions:new ge,userAPIId:""}}})(tX||(tX={})),(r=>{r.is=function(s){return s.type==="WEBHOOK"},r.defaultData=function(){return{disabled:!1,type:"WEBHOOK",name:"",actions:new ge,userWebhookId:""}}})(eX||(eX={})),(r=>{r.is=function(s){return s.type==="AIAssistantListener"},r.defaultData=function(){return{disabled:!1,type:"AIAssistantListener",name:"",actions:new ge,analysis:"average",analysisRange:[0,71],analysisSingle:0}}})(iX||(iX={})),(r=>{r.is=function(s){return s.type==="AIAssistantTrigger"},r.defaultData=function(){return{disabled:!1,description:"",name:"",type:"AIAssistantTrigger",actions:new ge}}})(rX||(rX={}))});function sX(t){let e=typeof t;return t!==null&&(e==="object"||e==="function")}function nX(t){return typeof t=="string"&&t.length===36&&/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t)}var i0,ov,_mt,Kg,aX,qu,hm,ES,oX,lv,nn,qi,tU,lX,Jp,Nv,hX,uX,dX,cX,pX,mX,fX,gX,$N,yX,vX,XN,bX,_X,xX,YN,wX,KN,SX,TX,ZN,MX,eU,AX,CX,EX,PX,RX,DX,Zg,gc,tm,iU,rU,eR,iR,rR,sR,nR,sU,nU,aR,aU,hv,NX,QN,JN,oU,OX,oR,IX,BX,lU,VX,kX,zX,LX,FX,UX,jX,GX,WX,A5,rG,Ws,cs,S1,xmt,PS,lR,cg,hU,sG,hR,uR,uU,lc,EP,ia,tO,$p,wl=G(()=>{var t,e,i,r,s,n,a,o;i0="personal camera",ov="a218fcc3-276b-49b9-b485-49037fd14f5f",_mt=2500134,Kg=5526619,(t=aX||{}).x="x",t.y="y",t.z="z",aX=t,(l=>{function u(c,p){return Math.pow(p[0]-c[0],2)+Math.pow(p[1]-c[1],2)}function h(c,p){return Math.sqrt(u(c,p))}function d(c,p,m){let f=l.sub(p,c),g=l.sub(m,c),y=l.dot(f,g)/l.dot(f,f),v=l.scalarMultiply(f,y);return l.add(c,v)}l.isEqual=function(c,p){return c[0]===p[0]&&c[1]===p[1]},l.lerp=function(c,p,m){return[c[0]+(p[0]-c[0])*m,c[1]+(p[1]-c[1])*m]},l.add=function(c,p){return[c[0]+p[0],c[1]+p[1]]},l.sub=function(c,p){return[c[0]-p[0],c[1]-p[1]]},l.multiply=function(c,p){return[c[0]*p[0],c[1]*p[1]]},l.divide=function(c,p){return[c[0]/p[0],c[1]/p[1]]},l.distanceSquared=u,l.distance=h,l.dot=function(c,p){return c[0]*p[0]+c[1]*p[1]},l.scalarMultiply=function(c,p){return[c[0]*p,c[1]*p]},l.projectionOnto=d,l.projectionOntoDistance=function(c,p,m){return h(c,d(c,p,m))},l.center=function(c,p){return[.5*(c[0]+p[0]),.5*(c[1]+p[1])]}})(qu||(qu={})),(e=hm||(hm={})).isEqual=function(l,u){return l[0]===u[0]&&l[1]===u[1]&&l[2]===u[2]},e.add=function(l,u){return[l[0]+u[0],l[1]+u[1],l[2]+u[2]]},e.sub=function(l,u){return[l[0]-u[0],l[1]-u[1],l[2]-u[2]]},e.div=function(l,u){return[l[0]/u[0],l[1]/u[1],l[2]/u[2]]},e.mul=function(l,u){return[l[0]*u[0],l[1]*u[1],l[2]*u[2]]},e.dist=function(l,u){return Math.hypot(l[0]-u[0],l[1]-u[1],l[2]-u[2])},e.lerp=function(l,u,h){return[l[0]+(u[0]-l[0])*h,l[1]+(u[1]-l[1])*h,l[2]+(u[2]-l[2])*h]},(i=ES||(ES={})).isEqual=function(l,u){return l[0]===u[0]&&l[1]===u[1]&&l[2]===u[2]&&l[3]===u[3]},i.lerp=function(l,u,h){return[l[0]+(u[0]-l[0])*h,l[1]+(u[1]-l[1])*h,l[2]+(u[2]-l[2])*h,l[3]+(u[3]-l[3])*h]},(l=>{let u=180/Math.PI,h=Math.PI/180;function d(p){return typeof p=="number"?p*u:p}function c(p){return typeof p=="number"?p*h:p}l.radToDeg=function(p){return[d(p[0]),d(p[1]),d(p[2])]},l.degToRad=function(p){return[c(p[0]),c(p[1]),c(p[2])]}})(oX||(oX={})),(r=lv||(lv={})).identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],r.isEqual=function(l,u){for(let h=0;h<16;h++)if(l[h]!==u[h])return!1;return!0},r.simplify=function(l){return l??r.identity},r.applyMatrix4=function(l,u){let h=u.slice(0);for(let d=0,c=u.length;d<c;d+=3){let p=l[3]*u[d]+l[7]*u[d+1]+l[11]*u[d+2]+l[15];h[d]=(l[0]*u[d]+l[4]*u[d+1]+l[8]*u[d+2]+l[12])/p,h[d+1]=(l[1]*u[d]+l[5]*u[d+1]+l[9]*u[d+2]+l[13])/p,h[d+2]=(l[2]*u[d]+l[6]*u[d+1]+l[10]*u[d+2]+l[14])/p}return h},(s=nn||(nn={})).isRGB=function(l){return typeof l=="object"&&typeof l.r=="number"&&typeof l.g=="number"&&typeof l.b=="number"},s.white={r:1,g:1,b:1},s.red={r:1,g:0,b:0},s.black={r:0,g:0,b:0},s.toRgb255a1=function(l){return{r:Math.round(255*l.r),g:Math.round(255*l.g),b:Math.round(255*l.b),a:1}},s.clone=function(l){return{r:l.r,g:l.g,b:l.b}},s.fromHex=function(l){return{r:((l=Math.floor(l))>>16&255)/255,g:(l>>8&255)/255,b:(255&l)/255}},s.toHex=function(l){return 65536*Math.round(255*l.r)+256*Math.round(255*l.g)+Math.round(255*l.b)},s.equals=function(l,u){return l.r===u.r&&l.g===u.g&&l.b===u.b},s.equalsFixed=function(l,u){return l.r.toFixed(2)===u.r.toFixed(2)&&l.g.toFixed(2)===u.g.toFixed(2)&&l.b.toFixed(2)===u.b.toFixed(2)},s.lerp=function(l,u,h){return{r:l.r+(u.r-l.r)*h,g:l.g+(u.g-l.g)*h,b:l.b+(u.b-l.b)*h}},s.is=function(l){return!!sX(l)&&"r"in l&&"g"in l&&"b"in l&&!("a"in l)},(n=qi||(qi={})).white={...nn.white,a:1},n.is=function(l){return!!sX(l)&&"r"in l&&"g"in l&&"b"in l&&"a"in l},n.transparent={...nn.white,a:0},n.from0to1=function(l){return{r:l[0],g:l[1],b:l[2],a:l[3]}},n.fromHexAndA=function(l,u){return{...nn.fromHex(l),a:u}},n.toRgb255a1=function(l){return{r:Math.round(255*l.r),g:Math.round(255*l.g),b:Math.round(255*l.b),a:l.a}},n.equals=function(l,u){return nn.equals(l,u)&&l.a===u.a},n.equalsFixed=function(l,u){return nn.equalsFixed(l,u)&&l.a.toFixed(2)===u.a.toFixed(2)},n.lerp=function(l,u,h){return{r:l.r+(u.r-l.r)*h,g:l.g+(u.g-l.g)*h,b:l.b+(u.b-l.b)*h,a:l.a+(u.a-l.a)*h}},n.toStyle=function({r:l,g:u,b:h,a:d}=n.white){return`rgba(${255*l}, ${255*u}, ${255*h}, ${d})`},(tU||(tU={})).identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1],pivot:[0,0,0],pivotRotation:[0,0,0]},(a=lX||{})[a.LINEAR=0]="LINEAR",a[a.EASE=1]="EASE",a[a.EASE_IN=2]="EASE_IN",a[a.EASE_OUT=3]="EASE_OUT",a[a.EASE_IN_OUT=4]="EASE_IN_OUT",a[a.CUBIC=5]="CUBIC",a[a.SPRING=6]="SPRING",a[a.ARC=7]="ARC",a[a.NONE=8]="NONE",lX=a,(Jp||(Jp={})).defaultData={mass:1,stiffness:80,damping:10,velocity:0},(Nv||(Nv={})).defaultData={control1:[.5,0],control2:[.5,1]},(o=hX||(hX={})).linear=[0,0,1,1],o.ease=[.25,.1,.25,1],o.easeIn=[.42,0,1,1],o.easeOut=[0,0,.58,1],o.easeInOut=[.42,0,.58,1]}),_Mt=G(()=>{var t,e;Fi(),bmt(),(uX||(uX={})).defaultData={type:"SwitchCamera",name:"",targetCamera:"",delay:0,animate:!0,duration:1e3,easing:4,runMode:"Normal"},(dX||(dX={})).defaultData={type:"SceneTransition",name:"",target:"",delay:0,duration:1,transition:"none"},(cX||(cX={})).defaultData={type:"Link",name:"",url:null,context:"tab"},(pX||(pX={})).defaultData={type:"Destroy",name:"",objects:[],delay:0},(mX||(mX={})).defaultData={type:"Particles",name:"",emitterObjectId:"",delay:0,emission:"start",triggerAfter:"any"},(fX||(fX={})).defaultData={type:"Create",name:"",object:"",delay:0,creationSpeed:10,coordinateSystem:"world",dynamic:!0,destroy:"No",destroyAfterQuantity:5,lifetime:2,position:[0,0,0],rotation:[0,0,0],velocity:[1e3,0,0],hideBase:"No"},(gX||(gX={})).defaultData={type:"Reset",name:"",delay:0},($N||($N={})).defaultData={interaction:"play",delay:0,volume:.5,loop:1},(t=yX||(yX={})).pauseDefaultData={interaction:"pause",delay:0},t.stopDefaultData={interaction:"stop",delay:0},(e=vX||(vX={})).defaultData={type:"Audio",name:"",...$N.defaultData},e.hasAudioByActions=i=>i.some(({data:r})=>r.type==="Audio"&&r.interaction==="play"&&r.audio),e.hasAudioByEvents=i=>e.getAudiosByEvents(i).length>0,e.getAudiosByActions=i=>{let r=[];return i.forEach(s=>{let n=s.data;n.type==="Audio"&&n.interaction==="play"&&n.audio&&r.push(s),n.type==="Conditional"&&(r.push(...e.getAudiosByActions(n.ifActions)),r.push(...e.getAudiosByActions(n.elseActions)))}),r},e.getAudiosByEvents=i=>{let r=[];return i.forEach(({data:s})=>{j2.is(s)||s.type==="Collision"||s.type==="Start"||s.type==="Trigger"||s.type==="VariableChange"||s.type==="WEBHOOK"||s.type==="AIAssistantTrigger"?r.push(...e.getAudiosByActions(s.actions)):s.type==="Conditional"?(r.push(...e.getAudiosByActions(s.inActions)),r.push(...e.getAudiosByActions(s.outActions))):s.type==="GameControl"?Object.values(s.gameActions).forEach(n=>{r.push(...e.getAudiosByActions(n))}):s.type==="DragDrop"?(r.push(...e.getAudiosByActions(s.dragDropActions.drag)),r.push(...e.getAudiosByActions(s.dragDropActions.drop))):s.type==="Resize"?s.breakpoints.forEach(({data:n})=>{r.push(...e.getAudiosByActions(n.actions))}):s.type==="API"&&(r.push(...e.getAudiosByActions(s.successActions)),r.push(...e.getAudiosByActions(s.errorActions)))}),r},(XN||(XN={})).defaultData={interaction:"play",delay:0,volume:.5,loop:1/0},(i=>{i.pauseDefaultData={interaction:"pause",delay:0},i.stopDefaultData={interaction:"stop",delay:0}})(bX||(bX={})),(i=>{i.defaultData={type:"Video",name:"",triggerAfter:"autoplay",...XN.defaultData},i.hasVideoByActions=r=>r.some(({data:s})=>s.type==="Video"&&s.interaction==="play"&&s.layerId),i.hasVideoByObject=r=>{if(r.events){for(let{data:s}of r.events)if((j2.is(s)||s.type==="Start")&&i.hasVideoByActions(s.actions))return!0}},i.getVideosByActions=r=>{let s=[];return r.forEach(n=>{let a=n.data;a.type==="Video"&&a.interaction==="play"&&a.layerId&&s.push(n)}),s},i.getVideosByEvents=r=>{let s=[];return r.forEach(({data:n})=>{(j2.is(n)||n.type==="Start")&&s.push(...i.getVideosByActions(n.actions))}),s}})(_X||(_X={})),(xX||(xX={})).defaultData=function(i){return{state:i,repeat:0,delay:0,delayDirection:"start-once",direction:"normal",duration:1e3,easing:4}},(YN||(YN={})).defaultData=function(){return{tweens:new ge,repeat:0,delay:0,delayDirection:"start-once",direction:"normal"}},(wX||(wX={})).defaultData=function(i){return{type:"Transition",name:"",runMode:"Once",object:i??null,...YN.defaultData()}},(KN||(KN={})).defaultData=function(i){return{interaction:"play",timeline:i,repeat:0,delay:0,delayDirection:"start-once",direction:"normal",runMode:"Once"}},(i=>{i.pauseDefaultData={interaction:"pause",delay:0},i.stopDefaultData={interaction:"stop",delay:0}})(SX||(SX={})),(TX||(TX={})).defaultData=function(i){return{type:"TimelineAnimation",name:"",...KN.defaultData(i)}},(ZN||(ZN={})).defaultData=function(i,r,s){return{interaction:"play",object:i,clipId:r,crop:s,crop2:s,repeat:-1,delay:0,delayDirection:"start-once",direction:"normal",runMode:"Normal"}},(i=>{i.pauseDefaultData={interaction:"pause",delay:0},i.stopDefaultData={interaction:"stop",delay:0}})(MX||(MX={})),(i=>{i.defaultData=function(r,s,n){return{type:"Animation",name:"",...ZN.defaultData(r,s,n)}},i.isPause=function(r){return r.interaction==="pause"||r.interaction==="stop"}})(eU||(eU={})),(AX||(AX={})).defaultData={type:"SetVariable",name:"",variableId:"",expression:[]},(CX||(CX={})).defaultData=()=>({type:"Conditional",name:"",ifActions:new ge,elseActions:new ge,condition:[]}),(EX||(EX={})).defaultData={type:"DynamicVariablePlay",name:"",variableId:"",mode:"PlayPause",delay:0,pauseDelay:0},(PX||(PX={})).defaultData={type:"ClearLocalStorage",name:"",target:"all"},(RX||(RX={})).defaultData={name:"",type:"UserAPI"}}),xMt=G(()=>{var t;(t=DX||(DX={})).emptyAudio={data:Uint8Array.from(atob("UklGRjIAAABXQVZFZm10IBIAAAABAAEAQB8AAEAfAAABAAgAAABmYWN0BAAAAAAAAABkYXRhAAAAAA=="),e=>e.charCodeAt(0)),mimeType:"audio/wav",filename:"unknown"},t.maxSize=2e6}),wmt=G(()=>{var t;(t=Zg||(Zg={})).all=["PerspectiveCamera","OrthographicCamera"],t.is=function(e){return t.all.includes(e)},(e=>{e.DefaultUp=[0,1,0],e.DefaultTargetOffset=1e3,e.MinTargetOffset=.001,e.sanitizeTargetOffset=function(n){return n===void 0||!Number.isFinite(n)||n<e.MinTargetOffset?e.DefaultTargetOffset:n},e.DefaultAzimuth=-24,e.DefaultElevation=15;let i=e.DefaultAzimuth*Math.PI/180,r=e.DefaultElevation*Math.PI/180,s=180/Math.PI;e.DefaultPosition=[e.DefaultTargetOffset*Math.sin(i)*Math.cos(r),e.DefaultTargetOffset*Math.sin(r),e.DefaultTargetOffset*Math.cos(i)*Math.cos(r)],e.DefaultRotation=[Math.atan2(-Math.sin(r),Math.cos(i)*Math.cos(r))*s,Math.asin(Math.sin(i)*Math.cos(r))*s,Math.atan2(Math.sin(i)*Math.sin(r),Math.cos(i))*s],e.defaultData={far:1e5,type:"PerspectiveCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:e.DefaultUp,isUpVectorFlipped:!1,targetOffset:e.DefaultTargetOffset},e.getZoom=function(n){return n.type==="PerspectiveCamera"?n.perspective?.zoom??1:n.orthographic?.zoom??1}})(gc||(gc={}))}),Smt=G(()=>{var t;(t=tm||(tm={})).defaultData=function(e,i=.1){return{disabled:!1,type:"linear",hideBase:!1,instanced:!1,count:3,radial:{radius:2*Math.max(typeof e[0]=="number"?e[0]:1,typeof e[1]=="number"?e[1]:1),start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0],pivot:[0,0,0],pivotRotation:[0,0,0]},toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal",pivot:[0,0,0],pivotRotation:[0,0,0]},linear:{scale:[1,1,1],rotation:[0,0,0],position:[(typeof e[0]=="number"?e[0]+e[0]:1)*i,0,0],pivot:[0,0,0],pivotRotation:[0,0,0]},grid:{count:[2,2,2],size:e.map(r=>(typeof r=="number"?r:1)*(1+i)),useCenter:!0},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}}},t.merge=function(e,i){let r={...e};if(rU.forEach(s=>{Object.assign(r,{[s]:i[s]??e[s]})}),r.radial={...e.radial},i.radial){let s=e.radial,n=i.radial;eR.forEach(a=>{Object.assign(r.radial,{[a]:n[a]??s[a]})})}if(r.linear={...e.linear},i.linear){let s=e.linear,n=i.linear;iR.forEach(a=>{Object.assign(r.linear,{[a]:n[a]??s[a]})})}if(r.grid={...e.grid},i.grid){let s=e.grid,n=i.grid;rR.forEach(a=>{Object.assign(r.grid,{[a]:n[a]??s[a]})})}if(r.toObject={...e.toObject},i.toObject){let s=e.toObject,n=i.toObject;sR.forEach(a=>{Object.assign(r.toObject,{[a]:n[a]??s[a]})})}if(r.randomnessObject={...e.randomnessObject},i.randomnessObject){let s=e.randomnessObject,n=i.randomnessObject;nR.forEach(a=>{Object.assign(r.randomnessObject,{[a]:n[a]??s[a]})})}return r},t.isPartial=function(e){return!(!e.randomnessObject&&!e.toObject)},(e=>{e.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let i=["radial","linear","grid","toObject","randomnessObject"];e.toOps=function(r,s){let n=[];r.count!==void 0&&n.push({type:0,path:s,props:{count:r.count}});for(let a of i){let o=r[a];o&&Object.keys(o).length>0&&n.push({type:0,path:[...s,a],props:o})}return n}})(iU||(iU={})),rU=["count"],eR=["radius","start","end","position","scale","rotation"],iR=["position","scale","rotation"],rR=["count","size"],sR=["count","position","scale","rotation"],nR=["strength","scale","rotation","position","movement","seed","freqScale"]}),Tmt=G(()=>{var t;wl(),(t=sU||(sU={})).all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"],t.is=function(e){return t.all.includes(e)},(nU||(nU={})).defaultData=function(e){return function(i){if(i==="PointLight")return{type:i,color:qi.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(i==="SpotLight")return{type:i,color:qi.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};if(i==="DirectionalLight")return{type:i,color:qi.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}(e)}}),Mmt=G(()=>{var t;(t=aR||(aR={})).defaultShapeData={type:"PlaneEmitterShape",size:[100,100,100]},t.defaultCollisionData={colliderEntityId:null,collisionBounce:.75},t.defaultData={renderMaterial:{type:"particleMaterial",color:{r:1,g:.2,b:.545,a:1},color2:{r:.945,g:.714,b:.184,a:1},coloring:"gradient",ease:"linearFadeOut",easeSize:"linearFadeOut",transparent:!0,size:[40,40],texture:"pt_default_particle",spriteRotation:[0,0]},birthRatePerSec:50,gravity:1,noiseStrength:0,noiseScale:0,noiseSeed:1,noiseType:"curl",randomRotation:0,randomScale:.2,randomMass:.5,rootObjectType:"instancedMesh",life:1,direction:[0,0,0],directionMode:"axis",speed:10,shape:t.defaultShapeData,autoPlay:!0,emitTimeDelay:0,emitTimeCycle:"infinity",emitTimeDuration:1,...t.defaultCollisionData}}),Amt=G(()=>{var t;(t=aU||(aU={})).defaultData={gravity:10,damping:.03,localStiffness:.67,globalStiffness:.5,globalRange:.15,stiffnessFalloff:.1,windStrength:0,vspCoefficient:.01,elasticity:.15,hairLength:.75,tipSeparation:.8,kink:0,kinkFrequency:0,clumpStrength:0,clumpSize:32,clumpTipScale:1.5,spreadRadius:.03,guideStrands:8192,headShape:"sphere",baseObjectId:null,hairColorSource:"custom",hairShadeRoot:.6,hairShadeTip:1.15,hairRootColor:{r:.29,g:.102,b:.039,a:1},hairMidColor:{r:.8,g:.267,b:.133,a:1},hairTipColor:{r:.545,g:.18,b:.18,a:1},headColor:{r:.325,g:.137,b:.114,a:1},noiseEnabled:!1,noiseColorA:{r:.545,g:.184,b:.788,a:1},noiseColorB:{r:.914,g:.188,b:.914,a:1},noiseColorC:{r:.2,g:.4,b:1,a:1},noiseColorD:{r:.2,g:1,b:.6,a:1},noiseScale:1.8,noiseMixHair:.75,noiseMixHead:.8,castShadow:!0,receiveShadow:!0,hairWidth:1.75,specularPower:40,specularIntensity:.4,diffuseIntensity:.6,ambientIntensity:.25,opacity:1,tipFade:.4,autoPlay:!0},t.regenProps=["hairLength","spreadRadius","guideStrands","headShape","baseObjectId"]}),nG=G(()=>{(hv||(hv={})).defaultData={enabled:"visibility",fusedBody:!0,rigidBody:"positioned",density:1,pointMass:0,gravityScale:1,friction:.5,damping:0,restitution:.2,colliderType:"convex",enabledRotation:[!0,!0,!0],enabledTranslation:[!0,!0,!0]}}),Cmt=G(()=>{var t,e;(t=NX||{})[t.Front=0]="Front",t[t.Back=1]="Back",t[t.Double=2]="Double",NX=t,(e=QN||(QN={})).defaultData={castShadow:!0,receiveShadow:!0},e.equals=function(i,r){return i.castShadow===r.castShadow&&i.receiveShadow===r.receiveShadow},(i=>{i.defaultData={flatShading:!1,wireframe:!1,side:0},i.equals=function(r,s){return r.flatShading===s.flatShading&&r.side===s.side&&r.wireframe===s.wireframe&&(r.shadowCatcher??!1)===(s.shadowCatcher??!1)}})(JN||(JN={})),(oU||(oU={})).defaultData={...JN.defaultData,...QN.defaultData},(OX||(OX={})).getMaterialData=function(i,r){let s=[];if("material"in i){let n=typeof i.material=="string"?r.materials[i.material]??r.lib.materials[i.material]?.asset:i.material;n&&s.push(n)}else if("materials"in i)for(let n of i.materials){let a=typeof n=="string"?r.materials[n]??r.lib.materials[n]?.asset:n;a&&s.push(a)}return s}}),Emt=G(()=>{var t;(t=oR||(oR={})).defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},t.maxSize=3e7}),YS=G(()=>{var t,e,i,r;Fi(),wl(),Emt(),wl(),(IX||(IX={})).is=function(s){return s==="texture"||s==="video"||s==="color"||s==="depth"||s==="normal"||s==="gradient"||s==="noise"||s==="fresnel"||s==="cavity"||s==="dust"||s==="rainbow"||s==="toon"||s==="outline"||s==="particle"||s==="transmission"||s==="reflection"||s==="matcap"||s==="displace"||s==="pattern"||s==="vertexColor"||s==="light"},(BX||(BX={})).is=function(s){return s==="luminance"||s==="r"||s==="g"||s==="b"||s==="a"},(lU||(lU={})).is=function(s){return typeof s=="object"&&s!==null&&s.image!=null},(VX||(VX={})).is=function(s){return s==="phong"||s==="toon"||s==="lambert"||s==="physical"},(r=kX||{})[r.Linear=0]="Linear",r[r.Radial=1]="Radial",r[r.Polar=2]="Polar",kX=r,zX=(s=>(s[s.RepeatWrapping=1e3]="RepeatWrapping",s[s.ClampToEdgeWrapping=1001]="ClampToEdgeWrapping",s[s.MirroredRepeatWrapping=1002]="MirroredRepeatWrapping",s))(zX||{}),LX=(s=>(s[s.NearestFilter=1003]="NearestFilter",s[s.LinearFilter=1006]="LinearFilter",s[s.LinearMipmapLinearFilter=1008]="LinearMipmapLinearFilter",s))(LX||{}),(i=FX||{})[i.UV=0]="UV",i[i.Planar=1]="Planar",i[i.Spherical=2]="Spherical",i[i.Cylindrical=3]="Cylindrical",i[i.Triplanar=4]="Triplanar",FX=i,(e=UX||{})[e.Simplex=0]="Simplex",e[e.SimplexFractal=1]="SimplexFractal",e[e.Ashima=2]="Ashima",e[e.Fbm=3]="Fbm",e[e.Perlin=4]="Perlin",e[e.Voronoi=5]="Voronoi",UX=e,(t=jX||{})[t.F1=0]="F1",t[t.F2=1]="F2",t[t.F2MinusF1=2]="F2MinusF1",t[t.SmoothBlend=3]="SmoothBlend",t[t.Edge=4]="Edge",t[t.Power=5]="Power",t[t.Lines=6]="Lines",t[t.Cells=7]="Cells",jX=t,GX=(s=>(s[s.Lights=0]="Lights",s[s.Static=1]="Static",s[s.Camera=2]="Camera",s))(GX||{}),WX=(s=>(s[s.Circle=0]="Circle",s[s.Ring=1]="Ring",s[s.Polygon=2]="Polygon",s[s.Cross=3]="Cross",s[s.Diamond=4]="Diamond",s[s.Checkerboard=5]="Checkerboard",s[s.Line=6]="Line",s[s.Wave=7]="Wave",s))(WX||{}),A5=["mode","gradientType","noiseType","tracingMode","mirror","displacementType","projection","cnormal","crop","axis","side","roughnessMapChannel","metalnessMap","metalnessMapChannel","normalMap","aoMap","aoMapChannel","emissiveMap","style"],rG=["wrapping","image","video","name","minFilter","magFilter"],(s=>{s.patch=function(n,a){let{texture:o,...l}=a;if(Object.assign(n,l),o){let u=n.texture;u&&Object.assign(u,o)}},s.defaultColorLayer=function(n){return{...s.defaultData("color"),color:n}},s.defaultData=function(n,a){return n==="light"&&a?function(o){let l={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(o){case"phong":return{...l,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...l,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...l,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...l,category:"physical",roughness:.6,metalness:.2,reflectivity:.2,type:"light",alpha:.6,visible:!0,mode:0,occlusion:!0}}}(a):function(o){let l={alpha:1,mode:0,isMask:!1,visible:!0};switch(o){case"texture":return{...l,type:"texture",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{image:"image_0",wrapping:1e3,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006},crop:!1};case"video":return{...l,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:oR.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006},crop:!1};case"color":return{...l,type:"color",color:nn.fromHex(Kg)};case"vertexColor":return{...l,type:"vertexColor"};case"depth":return{...l,type:"depth",gradientType:1,smooth:!1,isVector:!0,isWorldSpace:!1,origin:[0,0,0],direction:[1,0,0],colors:[[1,1,1,1],[0,0,0,1]],steps:[0,1],near:50,far:200};case"normal":return{...l,type:"normal",cnormal:[1,1,1]};case"gradient":return{...l,type:"gradient",gradientType:0,smooth:!1,colors:[[0,0,0,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,1,1,1,1,1,1,1,1,1],num:2,angle:0,offset:[0,0],morph:[0,0]};case"noise":return{...l,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...nn.fromHex(6710886),a:1},colorB:{...nn.fromHex(6710886),a:1},colorC:{...nn.fromHex(16777215),a:1},colorD:{...nn.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8],voronoiStyle:0,highCut:1,lowCut:0,smoothness:.3,seed:0,quality:1};case"cavity":return{...l,type:"cavity",mode:3,ridge:1,valley:1};case"fresnel":return{...l,type:"fresnel",color:qi.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"dust":return{...l,type:"dust",color:qi.fromHexAndA(10323813,1),coverage:.2,softness:.2,noiseStrength:.2,noiseScale:1};case"rainbow":return{...l,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...l,type:"toon",positioning:2,colors:[[0,0,0,1],[.5,.5,.5,1],[.5,.5,.5,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,.475,.525,1,1,1,1,1,1,1],num:4,source:[0,1e3,0],isWorldSpace:!0,noiseStrength:0,noiseScale:1,shadowColor:qi.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...l,type:"outline",outlineColor:qi.fromHexAndA(0,1),contourColor:qi.fromHexAndA(0,1),outlineWidth:2,contourWidth:5,outlineThreshold:.4,contourThreshold:0,outlineSmoothing:0,contourFrequency:10,contourDirection:[0,1,0],positionalLines:!1,compensation:!0};case"matcap":return{...l,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006}};case"transmission":return{...l,type:"transmission",thickness:10,ior:1.5,roughness:1};case"reflection":return{...l,type:"reflection",blur:0,thickness:.001,steps:60,stepSize:.005,tracingMode:1,mirror:0};case"displace":return{visible:!0,type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,voronoiStyle:0,smoothness:.3,seed:0,highCut:1,lowCut:0,quality:1};case"pattern":return{...l,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...nn.fromHex(0),a:1},colorB:{...nn.fromHex(16777215),a:1},frequency:[10,10],size:.5,variation:0,smoothness:.5,zigzag:0,rotation:0,vertical:[0,1],horizontal:[0,1],sides:6}}}(n)}})(Ws||(Ws={})),(s=>{function n(a,o="layer1",l="layer2",u=nn.fromHex(16777215)){let h=new ge;return h.push({fi:0,data:Ws.defaultData("light",a),id:o}),h.push({fi:1,data:Ws.defaultData("color"),id:l}),{layers:h}}s.isMergable=function(a){return!a.layers.some(o=>o.data.type==="texture"&&o.data.projection!==0||o.data.type==="depth"&&!o.data.isWorldSpace||o.data.type==="noise"||o.data.type==="dust"&&o.data.noiseStrength!==0||o.data.type==="displace")},s.getHash=function(a){let o="";return a.layers.forEach(l=>{Object.entries(l.data).forEach(([u,h])=>{o+=`${u}${h}`,Array.isArray(h)?h.forEach(d=>o+=`${d}`):typeof h=="object"?Object.values(h).forEach(d=>{o+=typeof d=="number"?`${d.toFixed(4)}`:`${d}`}):o+=`${h}`})}),o},s.defaultEmptyData=function(){return{layers:new ge}},s.defaultData=function(a="layer1",o="layer2"){return n("physical",a,o)},s.withName=function(a,o){return{...a,name:o}},s.defaultTwoLayerData=n,s.defaultColorMaterial=function(a,o,l="layer1",u="layer2"){let h=new ge;return h.push({fi:0,data:Ws.defaultData("light",o),id:l}),h.push({fi:1,data:Ws.defaultColorLayer(a),id:u}),{layers:h}},s.defaultUIObjectMaterial=function(a){let o=Ws.defaultData("texture");a&&Object.assign(o.texture,{image:a});let l=new ge;return l.push({fi:0,data:o,id:"layer1"}),l.push({fi:1,data:{...Ws.defaultData("transmission"),alpha:1},id:"layer2"}),l.push({fi:2,data:{...Ws.defaultData("light","lambert"),alpha:0},id:"layer3"}),{layers:l}},s.defaultTwoLayerTextureData=function(a,o="physical",l="layer1",u="layer2"){let h=Ws.defaultData("texture");Object.assign(h.texture,{image:a});let d=new ge;return d.push({fi:0,data:h,id:l}),d.push({fi:1,data:Ws.defaultData("light",o),id:u}),{layers:d}},s.defaultTwoLayerVideoTextureData=function(a,o="physical",l="layer1",u="layer2"){let h=Ws.defaultData("video");Object.assign(h.texture,{video:a});let d=new ge;return d.push({fi:0,data:h,id:l}),d.push({fi:1,data:Ws.defaultData("light",o),id:u}),{layers:d}}})(cs||(cs={}))}),wMt=G(()=>{S1="Roboto_regular",xmt="https://fonts.gstatic.com/s/roboto/v30/KFOmCnqEu92Fr1Me5WZLCzYlKw.ttf"}),Pmt=G(()=>{Fi(),(PS||(PS={})).defaultData=function(){return{points:new ge,roundness:0,shapeHoles:[],isClosed:!1}}}),Rmt=G(()=>{Fi(),(lR||(lR={})).defaultData=function(){return{points:new ge,lastInsertionPlane:null,subdivisions:12,isClosed:!1,subdivisionMode:"parametric"}},cg={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0},(hU||(hU={})).merge=function(t,e){let i={...t};return hR.forEach(r=>{Object.assign(i,{[r]:e[r]??t[r]})}),i},sG={shape:cg,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},hR=["depth","offset","angle","twist","startScale","endScale"]}),aG=G(()=>{var t,e;Pmt(),Rmt(),(t=uR||(uR={})).is2DParametricMesh=function(i){return i==="PolygonGeometry"||i==="RectangleGeometry"||i==="StarGeometry"||i==="TriangleGeometry"||i==="EllipseGeometry"||i==="UIGeometry"},t.isParametricMesh=function(i){return i==="PolygonGeometry"||i==="RectangleGeometry"||i==="StarGeometry"||i==="TriangleGeometry"||i==="EllipseGeometry"||i==="PathGeometry"||i==="VectorGeometry"||i==="ConeGeometry"||i==="CubeGeometry"||i==="CylinderGeometry"||i==="DodecahedronGeometry"||i==="HelixGeometry"||i==="IcosahedronGeometry"||i==="LatheGeometry"||i==="PyramidGeometry"||i==="SphereGeometry"||i==="PlaneGeometry"||i==="BackdropGeometry"||i==="TorusGeometry"||i==="TorusKnotGeometry"||i==="BooleanGeometry"||i==="TextGeometry"||i==="InputGeometry"||i==="DecalGeometry"},t.isSwappableGeometry=function(i){return i==="PolygonGeometry"||i==="RectangleGeometry"||i==="StarGeometry"||i==="TriangleGeometry"||i==="EllipseGeometry"||i==="PathGeometry"||i==="VectorGeometry"||i==="ConeGeometry"||i==="CubeGeometry"||i==="CylinderGeometry"||i==="DodecahedronGeometry"||i==="HelixGeometry"||i==="IcosahedronGeometry"||i==="LatheGeometry"||i==="PyramidGeometry"||i==="SphereGeometry"||i==="PlaneGeometry"||i==="BackdropGeometry"||i==="TorusGeometry"||i==="TorusKnotGeometry"||i==="TextGeometry"||i==="SubdivGeometry"||i==="NonParametricGeometry"},(uU||(uU={})).merge=function(i,r){let s={...i};return Object.assign(s,r),s.type==="PathGeometry"&&"extrusion"in r&&r.extrusion&&(s.extrusion={...i.extrusion},Object.assign(s.extrusion,hU.merge(s.extrusion,r.extrusion))),s},(e=lc||(lc={})).defaultData=function(i){if(i==="RectangleGeometry")return{width:320,height:320,type:i,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="UIGeometry")return{type:i,frame:"",cornerRadius:[0,0,0,0],cornerType:0,width:1,height:1};if(i==="PathGeometry")return{type:i,width:1,height:1,depth:1,path:lR.defaultData(),extrusion:sG};if(i==="VectorGeometry")return{width:1,height:1,type:i,subdivisions:12,shape:PS.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="BooleanGeometry")return{type:i,operation:2,width:0,height:0,depth:0,phongAngle:35};if(i==="ShapeBlendGeometry")return{type:i,width:0,height:0,depth:0,resolutionLevel:6,blendRange:100,useChildrenColors:!1};if(i==="DecalGeometry")return{type:i,width:200,height:200,depth:200,offset:1,projection:"all",projectionTargets:[]};if(i==="TextGeometry")return{type:i,width:100,height:100,depth:0,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.2,letterSpacing:0,text:{textValue:""},textTransform:1,font:"Roboto_regular",editable:!1,extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="InputGeometry")return{...e.defaultData("TextGeometry"),type:i,editable:!0};if(i==="SphereGeometry")return{type:"SphereGeometry",width:100,height:100,depth:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180};throw new Error("not implemented")},EP=["width","height","depth"]}),Dmt=G(()=>{wl(),(t=>{function e(i){return i.mode??"linear"}t.defaultData={enabled:!1,useBackgroundColor:!1,color:nn.white,near:.1,far:2e3,mode:"linear",density:.005,heightFalloff:.01,heightBase:0},t.getMode=e,t.getModeIndex=function(i){let r=e(i);return r==="height"?1:r==="both"?2:0},t.getDensity=function(i){return i.density??t.defaultData.density},t.getHeightFalloff=function(i){return i.heightFalloff??t.defaultData.heightFalloff},t.getHeightBase=function(i){return i.heightBase??t.defaultData.heightBase}})(ia||(ia={}))}),oG=G(()=>{(tO||(tO={})).defaultData={image:null,rotation:0,blur:32,showBackground:!0},($p||($p={})).defaultData={enabled:!1,mode:"hdri",hdri:tO.defaultData,timeOfDay:10,weather:"partlyCloudy",lighting:!0,lightingIntensity:1,lightingQuality:"full",clouds:!0,windSpeed:2,animateWind:!0,exposure:1,seed:2}});function SMt(t){let e=typeof t=="string"?Number.parseInt(t,10):t;return typeof e=="number"&&Number.isFinite(e)?Math.min(5,Math.max(0,Math.round(e))):3}var dR,uv,eO,iO,rO,dv,sO,dU,cU,qX,B0,Nmt,sn,cR,HX,$X,XX,YX,Bu,G2,pR,mR,yc,zg,KX,em,fR,vc,nO,aO,bg,Qg,_g,W2,pU,ZX,Na,oO,QX,JX,hc,Zl,cv,mU,Omt=G(()=>{(()=>{let t={opacity:1,blendFunction:13,enabled:!1};(dR||(dR={})).defaultData={enabled:!1,pixelation:{...t,blendFunction:16,granularity:15},bloom:{...t,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...t,offset:[2,2]},vignette:{...t,darkness:1,offset:0},hueSaturation:{...t,hue:3,saturation:0},brightnessContrast:{...t,brightness:.25,contrast:0},depthOfField:{...t,focusDistance:100,focalLength:20,bokehScale:5},noise:{...t,blendFunction:16}}})()}),lG=G(()=>{var t;Dmt(),oG(),Omt(),wl(),(t=uv||(uv={})).defaultData={type:"normal",softShadowQuality:"low"},t.isSoft=function(e){return e!=null&&(e.type===void 0||e.type==="soft")},(eO||(eO={})).defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75},(iO||(iO={})).defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}},(e=>{e.defaultData={pipeline:"classic",toneMapping:"aces",exposure:1},e.isUntouched=function(i){return i===void 0||i.pipeline==="classic"&&(i.toneMapping==="none"||i.toneMapping==="aces")&&i.exposure===1}})(rO||(rO={})),(dv||(dv={})).defaultData={usePhysics:!1,gravity:-10},(sO||(sO={})).defaultData={playCamera:i0,gameControlObject:null},(dU||(dU={})).defaultData={backgroundColor:qi.fromHexAndA(_mt,1),postprocessing:dR.defaultData,fog:ia.defaultData,sky:$p.defaultData,globalPhysics:dv.defaultData,ambient:eO.defaultData,ao:iO.defaultData,shadow:uv.defaultData,publish:sO.defaultData,grading:rO.defaultData}}),TMt=G(()=>{(cU||(cU={})).defaultData={colliderType:"box",size:[100,100,100],colliderHelperVisible:!0,forceType:"collider",forceRange:"global",forceIntensity:.5,forceDambing:.95}}),C5=G(()=>{var t,e,i;Fi(),wmt(),Tmt(),Mmt(),Amt(),nG(),Cmt(),wl(),YS(),aG(),Smt(),hn(),lG(),TMt(),(t=qX||(qX={})).isComponentRelated=function(r){return r==="Component"||r==="Instance"},t.isEmptyOrComponent=function(r){return r==="Empty"||r==="Instance"},(e=B0||(B0={})).identity={...tU.identity,hiddenMatrix:lv.identity},e.fromObject=function(r){return{position:r.position,rotation:r.rotation,scale:r.scale,pivot:r.pivot,pivotRotation:r.pivotRotation,hiddenMatrix:r.hiddenMatrix}},e.merge=function(r,s){return{position:s?.position||r.position,rotation:s?.rotation||r.rotation,pivot:s?.pivot||r.pivot,pivotRotation:s?.pivotRotation||r.pivotRotation,scale:s?.scale||r.scale,hiddenMatrix:s?.hiddenMatrix||r.hiddenMatrix}},e.diff=function(r,s){return Jpt({position:hm.isEqual(r.position,s.position)?void 0:s.position,rotation:hm.isEqual(r.rotation,s.rotation)?void 0:s.rotation,scale:hm.isEqual(r.scale,s.scale)?null:s.scale,hiddenMatrix:lv.isEqual(r.hiddenMatrix,s.hiddenMatrix)?void 0:s.hiddenMatrix})},Nmt=["slide","offset"],(sn||(sn={})).defaultData={states:new ge,events:new ge,visible:!0,raycastLock:!1,physics:hv.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...B0.identity,cloner:null},(cR||(cR={})).defaultData={type:"Empty",...sn.defaultData},(HX||(HX={})).defaultData={type:"ParticleCollider",...cU.defaultData,...sn.defaultData},($X||($X={})).defaultData={type:"Component",...sn.defaultData},(XX||(XX={})).defaultData={type:"Particle",...sn.defaultData,...aR.defaultData},(YX||(YX={})).defaultData={type:"Hair",...sn.defaultData,...aU.defaultData},(Bu||(Bu={})).defaultData={type:"Mesh",...sn.defaultData,...oU.defaultData},(G2||(G2={})).defaultData={...sn.defaultData,...B0.identity,position:gc.DefaultPosition,rotation:gc.DefaultRotation,...gc.defaultData},(r=>{r.defaultData=function(s){return{...sn.defaultData,...nU.defaultData(s)}},r.defaultDirectionalLightData={...r.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(pR||(pR={})),(r=>{function s(n,a,o=0){for(;o<a.length;){let l=n?n[a[o]]:void 0;if(a.length===o+1)return l;if(!l)return;n=l.descendants,o+=1}}r.resolveWithDes=s,r.resolve=function(n,a,o=0){let l=s(n,a,o);if(l){let u=Object.keys(l);if(u.length===1&&u[0]==="descendants")return}return l}})(mR||(mR={})),(r=>{function s(n,a){return{...sn.defaultData,...a,component:n,overrides:new Xs,physics:void 0,events:void 0,type:"Instance"}}r.rootOverrideProps=["physics","events"],r.compositeNonOptionalOverrideProps=["geometry"],r.compositeEntireOverrideOverrideProps=["material"],r.ofComponent=s,r.fromComponentData=function(n){let a=B0.fromObject(n.data);return s(n.id,a)}})(yc||(yc={})),(r=>{r.defaultData={type:"Page",...sn.defaultData,physics:{...hv.defaultData,fusedBody:!1},...dU.defaultData,camera:G2.defaultData,timelines:new Be},r.isUIPage=function(s){return s.uiScene!==void 0}})(zg||(zg={})),(i=KX||(KX={})).defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],pivot:[0,0,0],pivotRotation:[0,0,0],hiddenMatrix:lv.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:hv.defaultData,states:new ge,events:new ge,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...gc.defaultData},i.KeysByResetCategory={States:["states"],Events:["events"],Material:["material","materials"],Geometry:["geometry"],Position:["position"],Rotation:["rotation"],Scale:["scale"],Transform:["position","scale","rotation","hiddenMatrix"],Name:["name"],Visibility:["visible","raycastLock","flatShading","wireframe","side","shadowCatcher"],Shadows:["castShadow","receiveShadow"],Cloner:["cloner"],Physics:["physics"]},i.defaultMeshObject={name:"Rectangle",...sn.defaultData,...Bu.defaultData,geometry:lc.defaultData("RectangleGeometry"),material:cs.defaultTwoLayerData("physical","layer1","layer2")},i.defaultBooleanObject={name:"Boolean",...sn.defaultData,...Bu.defaultData,geometry:lc.defaultData("BooleanGeometry"),material:cs.defaultTwoLayerData("physical","layer1","layer2")},i.defaultShapeBlendObject={name:"Shape Blend",...sn.defaultData,...Bu.defaultData,geometry:lc.defaultData("ShapeBlendGeometry"),material:cs.defaultTwoLayerData("physical","layer1","layer2")},i.defaultTextObject={name:"Text",...sn.defaultData,...Bu.defaultData,geometry:lc.defaultData("TextGeometry"),material:cs.defaultTwoLayerData("physical","layer1","layer2")},i.defaultInputObject={name:"Input",...sn.defaultData,...Bu.defaultData,geometry:lc.defaultData("InputGeometry"),material:cs.defaultTwoLayerData("physical","layer1","layer2")},(r=>{r.newEmpty=function(s,n){let a={name:n};return s.type==="Mesh"?(a.geometry={},"material"in s&&(a.material={layers:new Xs}),"materials"in s&&(a.materials=s.materials.map(o=>({layers:new Xs})))):Zg.is(s.type)&&(a.perspective={},a.orthographic={}),a},r.toOps=function(s,n){let a,o=[],l={orthographic:0,perspective:0,geometry:0};function u(h,d){for(let[c,p]of Object.entries(d.layers)){let{texture:m,...f}=p;if(m!==void 0&&Object.keys(m).length>0){let g={path:[...h,"layers",c,"texture"],props:m,type:0};o.push(g)}if(Object.keys(f).length>0){let g={path:[...h,"layers",c],props:f,type:0};o.push(g)}}}for(let[h,d]of Object.entries(n)){let c=d;if(h!=="name")if(h==="cloner")o.push(...iU.toOps(c,["cloner"]));else if(h==="pathSnapping")o.push({path:[h],props:{slide:c.slide,offset:c.offset},type:0});else if(h==="material")u(["material"],c);else if(h==="materials")for(let[p,m]of Object.entries(c))u(["materials",p],m);else if(l[h]===0){if(h==="geometry"&&c.extrusion!==void 0){let p={path:[h,"extrusion"],props:c.extrusion,type:0};o.push(p),c={...c},delete c.extrusion}if(Object.keys(c).length>0){let p={path:[h],props:c,type:0};o.push(p)}}else a===void 0&&(a={path:[],props:{},type:0},o.push(a)),a.props[h]=c}return o},r.patch=function(s,n){if(n===void 0)return s;let a={...s};if(Object.assign(a,B0.merge(a,n)),Object.assign(a,{pathSnapping:Object.assign({},a.pathSnapping,{slide:n.pathSnapping?.slide??a.pathSnapping?.slide??0,offset:n.pathSnapping?.offset??a.pathSnapping?.offset??0})}),Zg.is(s.type)){a.orthographic={...a.orthographic},a.perspective={...a.perspective};let o=n;o.orthographic?.zoom!==void 0&&(a.orthographic.zoom=o.orthographic.zoom),o.perspective?.zoom!==void 0&&(a.perspective.zoom=o.perspective.zoom),o.isUpVectorFlipped!==void 0&&(a.isUpVectorFlipped=o.isUpVectorFlipped),o.targetOffset!==void 0&&(a.targetOffset=o.targetOffset)}else if(s.type==="Mesh")"geometry"in n&&Object.assign(a,{geometry:uU.merge(a.geometry,n.geometry)}),(n.material||n.materials)&&(a=function(o,l){if(l===void 0)return o;let u={...o};return"material"in u&&"material"in l&&l.material&&(u.material=Z4(u.material,h=>{if(typeof h!="string")for(let[d,c]of Object.entries(l.material.layers)){let p=h.layers.data(d);p&&Ws.patch(p,c)}}).data),u.materials&&l.materials&&(u.materials=Z4(u.materials,h=>{for(let d=0;d<u.materials.length;d++){let c=l.materials[d];if(typeof c!="string")for(let[p,m]of Object.entries(c.layers)){let f=h[d]?.layers?.data(p);f&&Ws.patch(f,m)}}}).data),u}(a,n)),a.cloner&&"cloner"in n&&Object.assign(a,{cloner:tm.merge(a.cloner,n.cloner)});else if(s.type==="Empty")a.cloner&&"cloner"in n&&Object.assign(a,{cloner:tm.merge(a.cloner,n.cloner)});else if(sU.is(s.type)){let o=n;o.intensity!==void 0&&(a.intensity=o.intensity),o.color!==void 0&&(typeof o.color=="string"?a.color=o.color:a.color=nn.clone(o.color))}return a}})(em||(em={}))}),hG=G(()=>{(fR||(fR={})).defaultData={enablePan:!0,enableZoom:!0,enableRotate:!0,enableDamping:!0,rotationLimitsMode:0,rotationVerticalOffset:{min:Math.PI/4,max:Math.PI/4},rotationHorizontalOffset:{min:Math.PI/4,max:Math.PI/4},rotationSoftLimit:2,rotationSpeed:1,panLimitsMode:0,panVerticalOffset:{min:250,max:250},panHorizontalOffset:{min:250,max:250},panSoftLimit:2,zoomLimitsEnabled:!1,zoomLimits:{min:.1,max:2},autoRotate:!1,autoRotateSpeed:2,autoRotateClockwise:!0,hoverRotatePanMode:0,hoverRotatePanStrength:20,hoverRotateDamping:.125,isTouchZoom:!0,orbitTouches:2,panTouches:3,resetHoverEffectOnPointerLeave:!0}}),E5=G(()=>{hG(),wl(),(vc||(vc={})).defaultData={orbitControls:fR.defaultData,playPage:ov,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((t,e)=>{let i=0,r=0;return e<5?r=-30:e<10&&(r=30),e===0||e===10||e===5?i=30:(e===4||e===11||e===9)&&(i=-30),[120,[i,r],"show"]}),settings:{image:{format:"jpg",ratio:1,colorSpace:"display-p3"},videoStatic:{fps:60,mbps:150,ratio:1,duration:1e3,format:"mp4",imageFormat:"jpg",activeTimeline:null,colorSpace:"display-p3"},web:{logo:!0,compress:!0,preset:1,preload:!0,hint:!1,imageQuality:70,pixelRatioMobile:0,pixelRatioDesktop:0}},stopRaycast:!0,hdTransmission:!1,renderer:"webgpu",asyncShaderCompilation:!0}}),Imt=G(()=>{var t;(nO||(nO={})).defaultData={id:"basic",label:"Basic",style:"None",prompt:""},(aO||(aO={})).defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0},(t=bg||(bg={})).defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...nO.defaultData},isRandomSeed:!0,seed:t.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:aO.defaultData}),t.generateSeed=()=>Math.round(1e5*Math.random())}),uG=G(()=>{C5(),Fi(),E5(),wl(),hn(),Imt(),(t=>{function e(i,r){let s=i.scene.objects.get(r);if(s&&s.data.type==="Component")return s;{let n=i.shared.lib.components[r];if(n)return{...n.asset,id:r}}}t.physicsEnabled=function(i){return i.find(r=>r.data.type==="Page"&&r.data.globalPhysics.usePhysics)!==void 0},t.findTimeline=function(i,r){let s=i.find(n=>n.data.type==="Page"&&n.data.timelines?.[r]!==void 0);return s&&s.data.timelines?.[r]},t.getComponentData=e,t.traverseModuleInstances=function(i,r,s){i.scene.objects.traverseFrom(r,(n,a)=>{if(a.type==="Instance"){let o=e(i,a.component)?.data;o&&s(n,a,o.events)}else s(n,a,a.events)})}})(Qg||(Qg={})),(t=>{function e(r=!0,s=[]){let n=[];r&&n.push({...t.defaultLight}),n.push(...s);let a=new In;return a.push({fi:1,id:ov,data:{...zg.defaultData,name:"Scene 1"},children:n}),a}function i(r){return{...t.defaultData,objects:$a(r,In.prototype)}}t.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222",t.defaultLight={fi:-1,data:pR.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]},t.createDefaultObjectTreeWithPage=e,t.defaultData={objects:e(),publish:vc.defaultData,styles:bg.defaultData()},t.emptyDataWithoutPage=function(){return{objects:new In,publish:vc.defaultData,styles:bg.defaultData()}},t.emptyDataWithPage=function(r=!0){return{objects:e(r),publish:vc.defaultData,styles:bg.defaultData()}},t.emptyData=function(){return{objects:new In,publish:{...vc.defaultData},styles:bg.defaultData()}},t.withObjs=i,t.withObj=function(r,s){return i([{id:r,data:s,children:[],fi:0}])}})(_g||(_g={}))}),Bmt=G(()=>{(W2||(W2={})).defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}}}),dG=G(()=>{var t,e;Fi(),hn(),(t=pU||(pU={})).defaultData=i=>({url:i,name:"New Webhook",parametersSchemas:new ge}),t.defaultParameterValueByType=i=>i==="number"?0:i!=="boolean"&&"",(ZX||(ZX={})).defaultData=(i,r="GET")=>({url:i,method:r,name:"New API",headers:new ge,queries:new ge,autoStart:!0}),(i=>{function r(n){return n.textValue!==void 0}function s(n){return typeof n=="boolean"}i.isTextValue=r,i.isNumber=function(n){return typeof n=="number"},i.isBoolean=s,i.typeOfVariable=function(n){return r(n)?"string":s(n)?"boolean":"number"},i.getDisplayedValue=function(n){return i.isTextValue(n)?Array.isArray(n.textValue)?n.textValue.map(a=>a.toString().padStart(n.padding??2,"0")).join(n.deliminator??":")+(n.suffix!==void 0?" "+n.suffix:""):n.textValue.toString():i.isBoolean(n)?n?"True":"False":i.isNumber(n)?parseFloat(n.toFixed(3)).toString():n.toString()}})(Na||(Na={})),(oO||(oO={})).all=["images","videos","colors","audios","particles","fonts","materials","variables"],(QX||(QX={})).all=[...oO.all,"components"],(JX||(JX={})).defaultData=function(){return{images:new Be,videos:new Be,colors:new Be,audios:new Be,particles:new Be,fonts:new Be,materials:new Be,components:new Be,variables:new Be,userAPIs:new Be,userWebhooks:new Be}},(hc||(hc={})).defaultData=function(){return{images:new Be,videos:new Be,colors:new Be,audios:new Be,particles:new Be,fonts:new Be,materials:new Be,components:new Be,variables:new Be,userAPIs:new Be,userWebhooks:new Be}},(e=Zl||(Zl={})).defaultColors=function(){return $a({"89b10010-844c-11ec-a8a3-0242ac120002":{r:.5,g:.5,b:.5,a:1,name:"Default Color"}},Be.prototype)},e.defaultImages=function(){return $a({},Be.prototype)},e.emptyData=function(){return{catelogs:new Be,materials:new Be,images:new Be,videos:new Be,colors:new Be,audios:new Be,particles:new Be,fonts:new Be,variables:new ge,userAPIs:new Be,userWebhooks:new Be,lib:hc.defaultData()}},e.defaultVariables=function(i){switch(i){case"number":return{value:0,name:"Number"};case"boolean":return{value:!1,name:"Boolean"};case"string":return{value:{textValue:"String value"},name:"String"};case"time":{let r=[0,0,0];return{name:"Time",value:{textValue:r,deliminator:":",padding:2,suffix:"AM"},dynamicVariableType:"time",format:"HH:mm:ss",format12h24h:"12ampm",timeZone:null,hasEnd:!1,endValue:{textValue:r,deliminator:":",padding:2,suffix:"AM"},autoStart:!0,repeat:!1}}case"counter":return{name:"Counter",value:0,dynamicVariableType:"counter",updateInterval:1e3,increment:1,autoStart:!0,hasEnd:!0,endValue:60,repeat:!0,randomStart:!1,range:[0,100],decimals:0};case"random":return{name:"Random",value:0,dynamicVariableType:"random",updateInterval:1e3,increment:1,autoStart:!0,isStatic:!1,hasEnd:!0,endValue:60,repeat:!0,min:0,max:100,decimals:0};default:console.error("Unknown variable type",i)}},e.getFormattedTimerTime=function(i,r){if(r.format==="HH:mm:ss"){let s=Math.floor(i/3600),n=Math.floor((i-3600*s)/60);return{textValue:[s,n,Math.round(i-3600*s-60*n)]}}if(r.format==="mm:ss"){let s=Math.floor(i/60);return{textValue:[s,Math.round(i-60*s)]}}return r.format==="number"?Math.round(i):Math.round(1e3*i)/1e3}}),MMt=G(()=>{}),Vmt=G(()=>{var t;Fi(),uG(),Bmt(),dG(),(t=cv||(cv={})).defaultData={schema:131,scene:_g.defaultData,frames:new Be().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",W2.defaultData),shared:{...Zl.emptyData(),colors:Zl.defaultColors()}},t.createDefaultData=function(){return CS.deserialize(CS.serialize(t.defaultData))},t.emptyDataForImports=function(){return{schema:131,scene:_g.emptyDataWithPage(),frames:new Be().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",W2.defaultData),shared:{...Zl.emptyData(),colors:Zl.defaultColors(),images:Zl.defaultImages()}}},t.emptyData=function(){return{schema:131,scene:_g.emptyDataWithPage(),frames:new Be().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",W2.defaultData),shared:Zl.emptyData()}},t.clipboard2dData=function(){return{schema:131,scene:_g.emptyData(),frames:new Be,shared:Zl.emptyData()}},t.withoutLib=function(e){return{...e,shared:{...e.shared,lib:hc.defaultData()}}},t.getComponentData=function(e,i){return Qg.getComponentData(e,i)},t.hasSensitiveData=function(e){let i=Object.values(e.shared.userAPIs);for(let r of i){let s=r.headers;for(let n of s)if(n.data.key.toLowerCase()==="authorization"&&n.data.value!=="")return!0}return!1}}),AMt=G(()=>{(mU||(mU={})).emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"}});function Lg(t,e=[0,0]){return[t&&!isNaN(t[0])?t[0]:e[0],t&&!isNaN(t[1])?t[1]:e[1]]}function r_(t,e,i){switch(t){case 0:return"cubicBezier( 0, 0, 1, 1 )";case 1:return"cubicBezier( .25, .1, .25, 1 )";case 2:return"cubicBezier( .42, 0, 1, 1 )";case 3:return"cubicBezier( 0, 0, .58, 1 )";case 4:return"cubicBezier( .42, 0, .58, 1 )";case 7:return"cubicBezier( .25, 1, .5, 1 )";case 5:{let{control1:r,control2:s}=e??{...Nv.defaultData};return`cubicBezier( ${r[0]}, ${r[1]}, ${s[0]}, ${s[1]} )`}case 6:{let{mass:r,stiffness:s,damping:n,velocity:a}=i??{...Jp.defaultData},o=new kmt(r,s,n,a),l=o.solve(1);return()=>u=>o.solve(u)/l}case 8:return()=>r=>Math.floor(r)}}var tY,eY,Fg,RS,kmt,gR,yR,zmt=G(()=>{Fi(),wl(),(tY||(tY={})).defaultData=function(t,e){return{id:t,name:e,duration:5,objectTimelines:new Be}},(eY||(eY={})).is=function(t){return t&&typeof t.x=="number"&&typeof t.y=="number"&&typeof t.z=="number"},(t=>{function e(h,d){let c=[0,0],p=[1,1];if(h?.cubicControls)c=Lg(h.cubicControls.control1,c);else switch(h?.type){case 2:case 4:c=[.42,0];break;case 3:case 0:c=[0,0];break;case 1:c=[.25,.1];break;case 7:c=[.25,1]}if(d?.cubicControls)p=Lg(d.cubicControls.control2,p);else switch(d?.type){case 2:case 0:p=[1,1];break;case 3:case 4:p=[.58,1];break;case 1:p=[.25,1];break;case 7:p=[.5,1]}return{control1:c,control2:p}}function i(h){if(!t.BEZIER_PRESETS.includes(h))return;let d={type:h};return{control1:e(d).control1,control2:e(void 0,d).control2}}function r(h,d){return Math.abs(h[0]-d[0])<.001&&Math.abs(h[1]-d[1])<.001}function s(h){let d=t.ROOT_PROPERTY_ORDER.indexOf(h[0]);return d===-1?t.ROOT_PROPERTY_ORDER.length:d}function n(h){return h.layerId??h.path.join(".")}function a(h){let d=h[h.length-1];return RS.includes(d)?d:void 0}function o(h){return h.layerId?h.layerId:(a(h.path)?h.path.slice(0,-1):h.path).join(".")}function l(h){return["material",h.type==="light"?`${h.category} lighting`:h.type]}function u(h,d,c){return{id:h,data:{id:h,time:c?.time??0,path:d,value:{},layerId:c?.layerId,index:c?.index,isPlaceholder:!0,easing:{type:5,cubicControls:{control1:[.42,0],control2:[.58,1]}}}}}t.getControlsWithDefault=e,t.BEZIER_PRESETS=[0,1,2,3,4,7],t.presetHandles=i,t.presetForHandles=function(h){return t.BEZIER_PRESETS.find(d=>{let c=i(d);return c!==void 0&&r(c.control1,h.control1)&&r(c.control2,h.control2)})},t.defaultData=function(h){return{id:h,keyframes:new ge}},t.ROOT_PROPERTY_ORDER=["position","rotation","scale","shape size","material","opacity","camera","light","cloner","path extrusion","path snapping"],t.rowOrder=s,t.propertyKey=n,t.groupKeyframes=function(h,d){let c=new Map;for(let p of h){let m=p.data;if(d?.(m))continue;let f=n(m),g=c.get(f);g||(g={id:f,path:m.path,keyframes:[],layerId:m.layerId,index:m.index},c.set(f,g)),m.isPlaceholder?g.placeholder=p.id:g.keyframes.push(p)}return[...c.values()].sort((p,m)=>{let f=s(p.path)-s(m.path);return f!==0?f:(p.index??0)-(m.index??0)})},t.rowAxis=a,t.drawnRowKey=o,t.drawnRows=function(h){let d=new Map;for(let c of h){let p=a(c.path),m=p?c.path.slice(0,-1):c.path,f=o(c),g=d.get(f);g||(g={id:f,path:m,layerId:c.layerId,index:c.index,tracks:[]},d.set(f,g)),g.tracks.push({axis:p,property:c})}return[...d.values()]},t.sortedKeyframes=function(h){return[...h].sort((d,c)=>d.data.time-c.data.time)},t.materialLayerPath=l,t.createMaterialGroup=function(h,d){return h.map(({data:c,id:p},m)=>u(d(),l(c),{layerId:p,index:m}))},t.placeholderKeyframe=u,t.createName=function(h){return Object.entries(h).reduce((d,[c,p])=>(typeof p!="string"&&d.push({name:p.name}),d),[])},t.Presets=[{name:"Slide in",animationParams:{translateX:{value:[-20,0],easing:r_(3),duration:1e3},opacity:{value:[0,1],easing:r_(3),duration:1e3},endDelay:250,loop:!0}},{name:"Rotate",animationParams:{rotate:{value:[0,"1turn"],easing:r_(5),duration:700},endDelay:250,loop:!0}},{name:"Scale Out",animationParams:{scale:{value:[1,1.5],easing:r_(4),duration:1e3},endDelay:250,loop:!0}},{name:"Jump",animationParams:{translateY:[{value:0,duration:200,easing:"linear"},{value:-20,easing:"linear",duration:200},{value:0,easing:"linear",duration:100}],endDelay:500,loop:!0}},{name:"Jump Rotate",animationParams:{translateY:[{value:0,duration:200,easing:"linear"},{value:-20,easing:"linear",duration:200},{value:0,easing:"linear",duration:100}],rotate:{value:[0,"1turn"],easing:r_(5),duration:500},endDelay:500,loop:!0}},{name:"Bounce",animationParams:{translateY:{value:["20px","-20px"],duration:575,easing:"easeOutQuad"},direction:"alternate",loop:!0}}]})(Fg||(Fg={})),RS=["x","y","z"],kmt=class{constructor(t=1,e=100,i=10,r=0){this.mass=t,this.stiffness=e,this.damping=i,this.initialVelocity=r,this.m_w0=Math.sqrt(e/t),this.m_zeta=i/(2*Math.sqrt(e*t)),this.m_zeta<1?(this.m_wd=this.m_w0*Math.sqrt(1-this.m_zeta*this.m_zeta),this.m_A=1,this.m_B=(this.m_zeta*this.m_w0-r)/this.m_wd):(this.m_wd=0,this.m_A=1,this.m_B=-r+this.m_w0)}solve(t){return 1-(this.m_zeta<1?Math.exp(-t*this.m_zeta*this.m_w0)*(this.m_A*Math.cos(this.m_wd*t)+this.m_B*Math.sin(this.m_wd*t)):(this.m_A+this.m_B*t)*Math.exp(-t*this.m_w0))}getDuration(){let t=.16666666666666666,e=0,i=0;for(;;)if(e+=t,this.solve(e)===1){if(i++,i>=16)break}else i=0;return e*t*1e3}}}),cG=G(()=>{var t;wl(),Fi(),(gR||(gR={})).list=["idle","move","jump","run"],(t=yR||(yR={})).defaultColliderData={type:"capsule",height:200,radius:50,position:[0,0,0],rotation:[0,0,0]},t.defaultDataThirdPerson={moveMode:"walk",forwardDirection:"+z",speedTranslate:1e3,speedRotate:100,runMultiplier:2,rotationMode:"normal",rotBy:"keys",rotByTouch:"drag",delayPos:[.3,.3],delayRot:[.3,.3],keyAssignments:[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","\u25B2"],["rotPosY","\u25C0"],["rotNegX","\u25BC"],["rotNegY","\u25B6"],["jump","Space"],["run","\u21E7"],["none","Ctrl"]],touchControl:!0,joystickPosLoc:5,joystickRotLoc:11,jumpTouchButtonLoc:9,collider:t.defaultColliderData,colliderHelperVisible:!0,collisionEnabled:!0,jumpPower:100,resetYPosition:3e3,alignToGround:!1,autoOrientMove:!0,orientWith:"camera",orientMode:"radial",delayPosCamera:.3,delayRotCamera:.3,camera:"",cameraXAxis:"Limit",cameraYAxis:"Free",cameraRotXLimits:[0,Math.PI/2],cameraRotYLimits:[-Math.PI/2,Math.PI/2],gameActions:{idle:new ge,move:new ge,jump:new ge,run:new ge},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:qi.fromHexAndA(3728051,1)}}});function ig(t,...e){let i={};for(let r of e.flat())t!=null&&r in t&&(i[r]=t[r]);return i}function iY(t){t.layers.forEach(e=>{if(e.type==="depth"&&e.colorA!==void 0){let i=e.colorA,r=e.colorB,s=[[i.r,i.g,i.b,i.a],[r.r,r.g,r.b,r.a]],n=[0,1];for(let o=2;o<10;o++)s.push(s[1]),n.push(1);let a={...ig(Gs(e),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,e.near),far:Math.max(0,e.far),colors:s,steps:n,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(e,a)}else if(e.type==="depth"&&e.gradientType===1&&(e.near<0||e.far<0)){let i={...Gs(e),near:Math.max(e.near,0),far:Math.max(e.far,0)};Object.assign(e,i)}})}function Kd(t,e){Object.values(t.shared.materials).forEach(i=>e(i))}function Zd(t,e){t.scene.objects.traverse((i,r)=>{"materials"in r?r.materials.forEach((s,n)=>{s===void 0&&(r.materials[n]=cs.defaultTwoLayerData("phong"),s=r.materials[n]),typeof s!="string"&&e(s)}):"material"in r?typeof r.material!="string"&&(r.material===void 0&&(r.material=cs.defaultTwoLayerData("phong")),e(r.material)):r.type==="Mesh"&&(r.material===void 0&&(r.material=cs.defaultTwoLayerData("phong")),e(r.material)),"overrides"in r&&Object.values(r.overrides).forEach(s=>{s.material&&typeof s.material!="string"&&Object.getPrototypeOf(s.material)!==Xs.prototype&&e(s.material)})})}function rY(t){t.layers===void 0&&Object.assign(t,cs.defaultTwoLayerData("lambert"))}function lO(t){!t.layers||t.layers.forEach(e=>{if(e.type==="depth"&&e.colors.length===10){let i=[...e.colors];i.push(e.colors[9]);let r=[...e.steps];r.push(e.steps[9]);let s={...Gs(e),colors:i,steps:r};Object.assign(e,s)}})}function sY(t){t.scene.objects.traverse((e,i)=>{"materials"in i?i.materials.forEach(r=>{typeof r!="string"&&lO(r)}):"material"in i&&typeof i.material!="string"&&lO(i.material)}),Object.values(t.shared.materials).forEach(e=>lO(e))}function nY(t){t.layers&&t.layers.forEach(e=>{e.type==="depth"&&e.num!==void 0&&(e.colors=e.colors.slice(0,e.num),e.steps=e.steps.slice(0,e.num),delete e.num)})}function aY(t){t.layers&&t.layers.forEach(e=>{(function(i){return i.type!=="displace"})(e)&&e.isMask===void 0&&(e.isMask=!1),(e.type==="texture"||e.type==="video")&&e.blending===void 0&&(e.blending=0),(e.type==="noise"||e.type==="displace"&&e.displacementType==="noise")&&(e.voronoiStyle===void 0&&(e.voronoiStyle=0),e.highCut===void 0&&(e.highCut=1),e.lowCut===void 0&&(e.lowCut=0),e.smoothness===void 0&&(e.smoothness=.3),e.seed===void 0&&(e.seed=0),e.quality===void 0&&(e.quality=1))})}function oY(t){let e=t.layers.find(i=>i.type==="light")?.data;if(e?.category==="basic"){let i=Ws.defaultData("light","phong"),r=e;Object.assign(r,i),r.visible=!1}}function lY(t){Kd(t,oY),Zd(t,oY)}function hY(t){t.layers.forEach(e=>{e.type==="light"&&e.category!=="toon"&&e.occlusion===void 0&&(e.occlusion=!0)})}function uY(t){t.layers&&t.layers.forEach(e=>{e.type==="light"&&e.bumpMapIntensity===void 0&&(e.bumpMapIntensity=5)})}var CMt=G(()=>{YS(),wl(),hG(),C5(),Fi(),E5(),hn(),dt(),aG(),cG(),Imt(),uG(),nG(),lG()}),Lmt={};function dY(t){t.layers&&t.layers.forEach(e=>{e.type==="light"&&e.alphaOverride===void 0&&(e.alphaOverride=1)})}function cY(t,e){let[i,r,s]=t,n=Math.cos(i),a=Math.sin(i),o=Math.cos(r),l=Math.sin(r),u=Math.cos(s),h=Math.sin(s),d=[o*u,n*h+a*u*l,a*h-n*u*l],c=Math.hypot(e[0],e[1],e[2])||1;return Math.abs((d[0]*e[0]+d[1]*e[1]+d[2]*e[2])/c)}function Fmt(t){(function(i){i.rotation=i.rotation.slice(0,3).map(r=>r*Dp)})(t),t.type==="Page"&&function(i){let r=i.rotation.slice(0,3);(function(s,n){let a=Array.isArray(n)&&n.length>=3&&n.every(u=>typeof u=="number"&&Number.isFinite(u))?n:[0,1,0],o=cY(s,a),l=cY(s.map(u=>u*Wmt),a);return Math.abs(o-l)<1e-6?s.some(u=>Math.abs(u)>Math.PI):l<o})(r,i.up)?i.rotation=r:i.rotation=r.map(s=>s*Dp)}(t.camera),t.states?.forEach(i=>{i.rotation===void 0||i.rotation===null||(i.rotation=i.rotation.slice(0,3).map(r=>r*Dp))});let e=t.geometry;e&&e.type==="SphereGeometry"&&(e.thetaLength=(e.thetaLength??180)*Dp),e&&e.type==="TorusGeometry"&&(e.arc=e.arc*Dp),e&&e.type==="PathGeometry"&&(e.extrusion.angle*=Dp,e.extrusion.twist*=Dp),t.type==="Mesh"&&t.geometry.type==="TextGeometry"&&(t.geometry.text={textValue:t.geometry.text}),Array.isArray(Gs(t.events))&&t.events?.forEach(i=>{(i.type==="MouseDown"||i.type==="MouseUp"||i.type==="MousePress"||i.type==="KeyDown"||i.type==="KeyUp"||i.type==="KeyPress"||i.type==="Collision"||i.type==="Trigger")&&(i.runMode=i.toggle?"Toggle":"Repeat")})}function EMt(t){t.scene.objects.traverse((e,i)=>{})}function PMt(t){let e=t.schema??104;e!==131&&e<130&&(vR(t.asset),t.schema=130)}function q1(t,e){e(t.data);for(let i of t.children)q1(i,e)}function Umt(t){let e=t.schema??104;e!==131&&(e<105&&(q1(t.asset,Fmt),t.schema=105),e<118&&(q1(t.asset,Gmt),t.schema=118),e<121&&(q1(t.asset,gU),t.schema=121),e<130&&(q1(t.asset,RMt),t.schema=130))}function jmt(t,e){Zd(t,e),Kd(t,e),Object.values(t.shared.lib.materials).forEach(i=>e(i.asset))}function vR(t){t.layers===void 0&&Object.assign(t,cs.defaultTwoLayerData("phong"))}function RMt(t){"materials"in t?t.materials.forEach(e=>{e!==void 0&&typeof e!="string"&&vR(e)}):"material"in t&&t.material!==void 0&&typeof t.material!="string"&&vR(t.material)}function Gmt(t){t.timelineAnimations=$a({},Be.prototype)}function DMt(t){let e=[];return t?(t.forEach((i,r)=>{let{path:s,keyframes:n}=i.data,a=s[0]==="material"?i.id:void 0;n?.length?n.forEach(({id:o,data:l})=>{e.push({id:o,data:{...l,path:s,layerId:a,index:r}})}):e.push(Fg.placeholderKeyframe(i.id,s,{layerId:a,index:r}))}),e.sort((i,r)=>i.data.time-r.data.time),new ge(...e.map((i,r)=>({...i,fi:r})))):new ge}function NMt(t){for(let{id:e,data:i}of[...t.unproxy()]){let r=i.path?.[0];if(!r||!qmt.includes(r))continue;let s=fU(i.value);if(!s.length)continue;let n=t.data(e);if(!n)continue;let a=i.value,[o,...l]=s;for(let u of l){let h=qt.generateUUID();t.insertBefore(null,[{id:h,data:{...i,id:h,path:[r,u],value:a[u],easing:OMt(i.easing)}}])}n.path=[r,o],n.value=a[o]}}function fU(t){return t===null||typeof t!="object"?[]:RS.filter(e=>e in t)}function OMt(t){let e=t?.cubicControls;return{...t,cubicControls:{control1:[...e?.control1??[0,0]],control2:[...e?.control2??[1,1]]},...t?.springParameters?{springParameters:{...t.springParameters}}:{}}}function IMt(t,e){return Math.abs(t[0]-e[0])<1e-6&&Math.abs(t[1]-e[1])<1e-6}function BMt(t){let e=function(n){let a=[];for(let o of Fg.groupKeyframes(n)){let l=new Set(o.keyframes.flatMap(h=>fU(h.data.value))),u=l.size?[...l].map(h=>o.keyframes.filter(d=>fU(d.data.value).includes(h))):[o.keyframes];for(let h of u){let d=[...h].sort((c,p)=>c.data.time-p.data.time);for(let c=0;c+1<d.length;c++)a.push({left:d[c],right:d[c+1]})}}return a}([...t.unproxy()]),i=new Map,r=new Set;for(let{left:n,right:a}of e){let o=n.data.easing?.type,l=(o===void 0?void 0:Fg.presetHandles(o))?.control2??(o===5?Lg(a.data.easing?.cubicControls?.control2,[1,1]):void 0);if(!l)continue;let u=i.get(a.id);u?IMt(u,l)||r.add(a.id):i.set(a.id,l)}let s=new Map;for(let{id:n,data:a}of t.unproxy()){let o=a.easing?.type,l=o===void 0?void 0:Fg.presetHandles(o);l&&s.set(n,l.control1)}for(let{left:n,right:a}of e)r.has(a.id)&&s.delete(n.id);for(let[n,a]of s){let o=t.data(n);!o?.easing||(o.easing.cubicControls={control1:a,control2:Lg(o.easing.cubicControls?.control2,[1,1])},o.easing.type=5)}for(let{left:n,right:a}of e){if(!s.has(n.id))continue;let o=t.data(a.id),l=i.get(a.id);!o?.easing||!l||(o.easing.cubicControls={control1:Lg(o.easing.cubicControls?.control1,[0,0]),control2:l})}}function pY(t,e){t.scene.objects.traverse((i,r)=>{let s=r;if(s.type==="Page"&&s.timelines)for(let n of Object.values(s.timelines))for(let a of Object.values(n.objectTimelines??{}))e(a.keyframes)})}function gU(t){t.pivot=[0,0,0],t.pivotRotation=[0,0,0]}function VMt(t){}function kMt(t){let e=t.schema??0;if(e!==131){if(e>131)return void console.error(`This scene was created with a newer version of Spline (file format ${e}, this runtime reads 131). Update @splinetool/runtime to the latest version to load it correctly.`);console.warn("updating from ",e,"to ",131),function(i,r){if(r<1&&(Zd(i,iY),Kd(i,iY),i.schema=1),r<2&&(function(s){Object.assign(s.scene.publish,{orbitControls:{...fR.defaultData,...Gs(s.scene.publish.orbitControls)}})}(i),i.schema=2),r<3&&(function(s){function n(a){if(a.layers){for(let o of Object.values(a.layers))if(o){for(let[l,u]of Object.entries(o))if((A5.includes(l)||typeof u=="boolean")&&delete o[l],l==="texture")for(let[h,d]of Object.entries(u))(rG.includes(h)||typeof d=="boolean")&&delete u[h]}}}s.scene.objects.traverse((a,o)=>{o.states.forEach(l=>{let u=l;u.material?n(u.material):u.materials&&u.materials.forEach(h=>{n(h)})})})}(i),i.schema=3),r<4&&(function(s){s.scene.publish.withBackground=!0}(i),i.schema=4),r<5&&(function(s){s.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}(i),i.schema=5),r<6&&(function(s){s.scene.objects.traverse((n,a)=>{let o=a.cloner;o&&(o.radial.scale=o.radial.scale.map(l=>l+1),o.linear.scale=o.linear.scale.map(l=>l+1))})}(i),i.schema=6),r<7&&(function(s){s.scene.objects.traverse((n,a)=>{let o=a.geometry;o&&(o.type==="DodecahedronGeometry"||o.type==="IcosahedronGeometry")&&(o.detail=Math.round(o.detail))})}(i),i.schema=7),r<8&&(i.schema=8),r<9&&(sY(i),i.schema=9),r<10&&(function(s){s.scene.objects.traverse((n,a)=>{a.type==="Mesh"&&(a.geometry.type==="BooleanGeometry"||a.geometry.type==="SubdivGeometry")&&(a.geometry.phongAngle=35)})}(i),i.schema=10),r<11&&(function(s){s.scene.environment.ambientLight.softShadows=!1,s.scene.environment.ambientLight.softShadowQuality="low",s.scene.objects.traverse((n,a)=>{(a.type==="DirectionalLight"||a.type==="SpotLight")&&(a.shadowResolution=1024,a.shadowRadius=1,a.depth=1e5)}),s.shared.penumbraSize=new Array(5).fill(.5)}(i),i.schema=11),r<12&&(sY(i),i.schema=12),r<13&&(function(s){s.shared.audios=$a({},Be.prototype)}(i),i.schema=13),r<14&&(function(s){let n=s.shared.materials;Object.entries(n).forEach(([a,o])=>{if(!o.layers){let l={name:"Untitled Material",layers:[{fi:0,data:{type:"light",category:"phong",alpha:.6,visible:!0,mode:0,specular:{r:.2,g:.2,b:.2},shininess:5},id:"layer1"},{fi:1,data:{type:"color",alpha:1,visible:!0,mode:0,color:{r:.2823529411764706,g:.2823529411764706,b:.30196078431372547}},id:"layer2"}]};Object.assign(n,{[a]:l})}})}(i),i.schema=14),r<15&&(function(s){Object.entries(Gs(s.shared.images)).filter(n=>n[1].asset===!1).map(n=>n[0]).forEach(n=>{delete s.shared.images[n]}),Object.entries(Gs(s.shared.audios)).filter(n=>n[1].asset===!1).map(n=>n[0]).forEach(n=>{delete s.shared.audios[n]})}(i),i.schema=15),r<16&&(function(s){s.scene.publish.settings.web.preload=!1}(i),i.schema=16),r<17&&(Zd(i,nY),Kd(i,nY),i.schema=17),r<18&&(Zd(i,rY),Kd(i,rY),i.schema=18),r<19&&(function(s){Object.assign(s.scene.publish.settings,{video:{...vc.defaultData.settings.video,...Gs(s.scene.publish.settings.video)}})}(i),i.schema=19),r<20&&(function(s){s.shared.fonts=$a({},Be.prototype)}(i),function(s){let n=[];s.scene.objects.traverse((a,o)=>{let l=o;if(l.type==="TextFrame"){let u=cs.defaultTwoLayerData("phong"),h=typeof l.color=="string"?s.shared.colors[l.color]:l.color;u.layers[1].data.color={r:h.r,g:h.g,b:h.b},u.layers[1].data.alpha=l.alpha;let d=function(m){return m.replace(".typeface","").replace(/optimer/gi,"open sans").replace("space_mono","space mono").replace(/alma_mono/gi,"varela round").replace(/droid_sans_mono/gi,"noto sans mono").replace(/droid_sans|gentilis|gnomon_(simple|foreground)|helvetiker/gi,"roboto").replace(/droid_serif/gi,"roboto slab").replace("_sans"," sans").replace("crimson_text","crimson text").replace("medium_medium","medium").replace("fatface_fatface","fatface").replace("100hairline","thin").replace("200thin","extralight").replace("300light","light").replace("500medium","medium").replace("600semi","semibold").replace("800heavy","extrabold").replace("900black","black").replace(/bodoni_(11|16|24|36|48|72|96)([^_])/gi,"bodoni_$1_$2").replace(/bodoni_(11|16|24|36|48|72|96)/gi,"bodoni moda").replace(/(thin|hairline)(_regular)?/gi,"100").replace(/(extra|ultra)light(_regular)?/gi,"200").replace(/light(_regular)?/gi,"300").replace(/_book|_normal|_roman/gi,"_regular").replace(/medium(_regular)?/gi,"500").replace(/(semi|demi)bold(_regular)?/gi,"600").replace(/(extra|ultra)bold(_regular)?/gi,"800").replace(/bold(_regular)?/gi,"700").replace(/(black|heavy|fatface)(_regular)?/gi,"900").replace(/([1-9]00)_italic/gi,"$1italic").replace(/regularitalic/gi,"italic").replace(/regularitalic/gi,"italic").split(" ").map(f=>f.charAt(0).toUpperCase()+f.slice(1)).join(" ")}(l.font);s.shared.fonts[d]===void 0&&(s.shared.fonts[d]={name:d});let c={name:l.name,...sn.defaultData,...Bu.defaultData,flatShading:!1,wireframe:!1,geometry:{...lc.defaultData("TextGeometry"),width:l.width,height:l.height,font:d,depth:0,horizontalAlign:l.horizontalAlign,verticalAlign:l.verticalAlign,fontSize:1.40625*l.fontSize,lineHeight:l.lineHeight/1.40625,letterSpacing:l.letterSpacing-1,text:l.text,textTransform:l.textTransform,extrudeBevelSize:0,extrudeBevelSegments:1},material:u,states:Gs(l.states),events:Gs(l.events),visible:l.visible,raycastLock:l.raycastLock,position:l.position,rotation:l.rotation,scale:l.scale,hiddenMatrix:l.hiddenMatrix},p=Gs(s.scene.objects).parent(a);s.scene.objects.insertAfter(p??null,a,[{id:a+"new",data:c,children:[]}]),n.push(a)}}),n.forEach(a=>{s.scene.objects.delete(a)})}(i),i.schema=20),r<21&&(function(s){let n={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};s.scene.objects.traverse((a,o)=>{o.events.forEach(l=>{if(n[Number(l.type)])if(Object.assign(l,{type:n[Number(l.type)]}),l.type==="Audio"&&"audioEvent"in l&&(Object.assign(l,{playAudio:l.audioEvent}),delete l.audioEvent),l.type==="GameControl")Object.assign(l,{gameActions:{idle:new ge,move:new ge,jump:new ge}});else{let u=new ge;Object.assign(l,{actions:u}),(l.type==="MouseDown"||l.type==="MouseUp"||l.type==="KeyDown"||l.type==="KeyUp")&&"url"in l&&u.push({fi:0,id:qt.generateUUID(),data:{type:"Link",url:l.url,delay:0}}),"targets"in l&&(l.targets.forEach((h,d,c)=>{let p={easing:h.easing,duration:h.duration};h.easing===6?Object.assign(p,ig(h,"mass","stiffness","damping","velocity")):h.easing===5&&Object.assign(p,{control1:{...h.control1},control2:{...h.control2}});let m={repeat:h.repeat?-1:0,delay:h.delay,delayDirection:h.delayDirection,direction:h.cycle&&h.rewind?"pingpong-rewind":h.cycle?"pingpong":"normal"},f={state:h.state,...m,...p},g={allowSlerp:!0,type:"Transition",object:h.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new ge({fi:0,id:qt.generateUUID(),data:{state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4}},{fi:1,id:qt.generateUUID(),data:f})};u.push({fi:c,id:d,data:g})}),delete l.targets)}})})}(i),function(s){s.scene.objects.traverse((n,a)=>{function o(l,u){let h=new ge,d=[];if(a.events.forEach((c,p,m)=>{if(c.type==="Audio"&&c.trigger===u){let f;d.push(p),c.interaction==="play"?f={...ig(c,"interaction","audio","delay","volume","loop"),triggerAfter:"after"in c?c.after:void 0,toggle:"after"in c?c.toggle:void 0,type:"Audio"}:(c.interaction==="pause"||c.interaction==="stop")&&(f={...ig(c,"interaction","delay","object","playAudio"),type:"Audio"}),f&&h.push({fi:m,id:p,data:f})}}),d.forEach(c=>a.events.delete(c)),h.length){let c=a.events.find(p=>p.type===l)?.data;c?"actions"in c&&c.actions.insertBefore(null,h):a.events.insertBefore(null,[{id:qt.generateUUID(),data:{type:l,actions:h}}])}}o("Start","start"),o("MouseDown","mouseDown"),o("MouseUp","mouseUp"),o("KeyDown","keyDown"),o("KeyUp","keyUp")})}(i),i.schema=21),r<22&&(lY(i),i.schema=22),r<23&&(function(s){s.scene.objects.traverse((n,a)=>{a.type==="Mesh"&&a.geometry.type==="SubdivGeometry"&&(a.geometry.scaleBaked||(a.geometry.scaleBaked=[1,1,1]))})}(i),i.schema=23),r<24&&(function(s){s.scene.objects.traverse((n,a)=>{(a.type==="Empty"||a.type==="Mesh")&&a.cloner&&!a.cloner.randomnessObject&&!a.cloner.toObject&&!a.cloner.randomness&&(a.cloner={...a.cloner,toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}})})}(i),i.schema=24),(r<25||i.shared.videos===void 0)&&(function(s){s.shared.videos=$a({},Be.prototype)}(i),r<25&&(i.schema=25)),r<26&&(function(s){s.scene.objects.traverse((n,a)=>{let o=s.scene.objects.unproxy().parent(n);if(o){let l=Gs(s.scene.objects.data(o));l&&l.type==="Mesh"&&l.geometry.type==="BooleanGeometry"&&a.type==="Mesh"&&(a.visible=Gs(a).booleanExclude!==!0)}})}(i),i.schema=26),r<27&&(function(s){s.scene.objects.traverse((n,a)=>{if(a.type==="Mesh"){let o=a;a.geometry.type==="NonParametricGeometry"?o.material!==void 0&&delete o.material:o.materials!==void 0&&delete o.materials}})}(i),i.schema=27),r<28&&(lY(i),i.schema=28),r<29&&(function(s){function n(o){Object.setPrototypeOf(o,Xs.prototype),o.texture&&Object.setPrototypeOf(o.texture,Xs.prototype)}function a(o){Object.setPrototypeOf(o,Xs.prototype);for(let l in o)n(o[l])}s.scene.objects.traverse((o,l)=>{l.states.forEach(u=>{let h=u;if(h.material){let d=Gs(h.material).layers;a(d),h.material.layers=d}if(h.materials)for(let d=0;d<h.materials.length;d++){let c=h.materials[d],p=Gs(c).layers;a(p),c.layers=p}})})}(i),i.schema=29),r<30&&(function(s){s.scene.objects.traverse((n,a)=>{a.type==="Mesh"&&a.geometry.type==="NonParametricGeometry"&&!("material"in a)&&!("materials"in a)&&(a.material=cs.defaultTwoLayerData("phong"))})}(i),i.schema=30),r<31&&(function(s){s.scene.publish.orbitControls.autoZoom===void 0&&(s.scene.publish.orbitControls.autoZoom=!1),s.scene.objects.traverse((n,a)=>{(a.type==="OrthographicCamera"||a.type==="PerspectiveCamera")&&(a.orthographic.autoZoom===void 0&&(a.orthographic.autoZoom=!1),a.orthographic.autoZoomFrustumSize===void 0&&(a.orthographic.autoZoomFrustumSize=790))})}(i),i.schema=31),r<33&&(function(s){s.scene.objects.traverse((n,a)=>{a.pathSnapping===void 0&&(a.pathSnapping={pathId:null,slide:0,offset:0,orientation:"tangential"}),a.pathSnapping.offset===void 0&&(a.pathSnapping.offset=0)})}(i),i.schema=33),r<34&&(function(s){s.scene.publish.mouseEventTarget===void 0&&(s.scene.publish.mouseEventTarget="canvas"),s.scene.publish.settings.web.hint===void 0&&(s.scene.publish.settings.web.hint=!1)}(i),i.schema=34),r<35&&(function(s){let{video:n}=s.scene.publish.settings;n.format==="gif"&&n.fps>48&&(n.fps=15)}(i),i.schema=35),r<36&&(function(s){s.scene.objects.traverse((n,a)=>{a.events.forEach(o=>{o.type==="GameControl"&&(o.resetYPosition=Math.abs(o.resetYPosition-a.position[1]))})})}(i),i.schema=36),r<37&&(function(s){let n=s.scene.environment.usePhysics;s.scene.objects.traverse((a,o)=>{n&&o.physics===null?o.collision=!1:o.collision="visibility"})}(i),i.schema=37),r<38&&(Zd(i,aY),Kd(i,aY),i.schema=38),r<39&&(function(s){s.scene.objects.traverse((n,a)=>{a.events.forEach(o=>{o.type==="GameControl"&&(o.navmesh=yR.defaultDataThirdPerson.navmesh)})})}(i),i.schema=39),r<40&&(function(s){s.scene.styles||(s.scene.styles=bg.defaultData())}(i),i.schema=40),r<41&&(function(s){s.scene.environment.ambientLight.occlusion===void 0&&(s.scene.environment.ambientLight.occlusion=!1),s.scene.environment.ambientLight.aoFullRes===void 0&&(s.scene.environment.ambientLight.aoFullRes=!1),s.scene.environment.ambientLight.radius===void 0&&(s.scene.environment.ambientLight.radius=256),s.scene.environment.ambientLight.bias===void 0&&(s.scene.environment.ambientLight.bias=.5),s.scene.environment.ambientLight.aoColor===void 0&&(s.scene.environment.ambientLight.aoColor={r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}),Zd(s,hY),Kd(s,hY)}(i),i.schema=41),r<42&&(function(s){s.scene.objects.traverse((n,a)=>{a.events.forEach(o=>{o.type==="GameControl"&&Object.assign(o.gameActions,{run:new ge})})})}(i),i.schema=42),r<43&&(function(s){s.scene.objects.traverse((n,a)=>{a.events.forEach(o=>{o.type==="GameControl"&&(o.keyAssignments=[...o.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}(i),i.schema=43),r<99){Zd(i,uY),Kd(i,uY),i.scene.publish.playCamera===null&&(i.scene.publish.playCamera=i0);let s=Gs(i.scene.objects),n=i.scene.objects;i.scene.publish.playPage=ov,n.insertBefore(null,null,[{id:ov,data:{...zg.defaultData,backgroundColor:i.scene.backgroundColor,fog:i.scene.fog,postprocessing:i.scene.postprocessing,ao:ig(i.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:i.scene.publish.playCamera,gameControlObject:i.scene.publish.gameControlObject},shadow:ig(i.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...dv.defaultData,...ig(i.scene.environment,"usePhysics","gravity")},camera:Gs(i.scene.ownerCamera)??zg.defaultData.camera,name:"Scene"},children:[]}]);for(let l of s)l.id!==_g.TRASH_CAN_ID&&n.move(ov,l.fi,l.id);let a=0,o=0;i.shared.penumbraSize&&i.scene.objects.traverse((l,u)=>{u.type==="DirectionalLight"?(u.penumbraSize=i.shared.penumbraSize[Math.min(a,2)],a+=1):u.type==="SpotLight"&&(u.penumbraSize=i.shared.penumbraSize[3+Math.min(o,1)],o+=1),(u.physics===void 0||u.physics===null)&&u.type!=="Instance"&&(u.physics={},Object.assign(u.physics,hv.defaultData)),u.physics!==void 0&&u.physics!==null&&(u.physics.enabled=u.collision??"visibility",delete u.collision)}),i.schema=99}}(t,e),e<100&&(t.scene.publish.joystickSizeAndXYOffset===void 0&&(t.scene.publish.joystickSizeAndXYOffset=vc.defaultData.joystickSizeAndXYOffset),t.schema=100),e<101&&(Zd(t,dY),Kd(t,dY),t.schema=101),e<102&&(function(i){i.scene.objects.traverse((r,s)=>{let n=s.geometry;n&&n.type==="PathGeometry"&&(n.extrusion.capType="flat",n.extrusion.bevel=50,n.extrusion.bevelSides=6,n.extrusion.shape.type==="Custom"&&(n.extrusion.shape.shapeQuality="low"))})}(t),t.schema=102),e<104&&(t.shared.catelogs=new Be,t.shared.lib=hc.defaultData(),t.schema=104),e<105&&(function(i){i.shared.variables=$a({},Be.prototype)}(t),t.scene.objects.traverse((i,r)=>{Fmt(r)}),t.schema=105);for(let i of Object.values(t.shared.lib.components))Umt(i);e<106&&(function(i){let r=Gs(i.shared.variables);i.shared.variables=$a(Object.entries(r??{}).map(([s,n],a)=>({fi:a,id:s,data:n})),ge.prototype)}(t),t.schema=106),e<107&&(t.shared.lib.variables=hc.defaultData().variables,t.schema=107),e<109&&(function(i){i.shared.particles=$a({},Be.prototype),i.shared.lib&&(i.shared.lib.particles=hc.defaultData().particles)}(t),t.schema=109),e<110&&(function(i){i.scene.objects.traverse((r,s)=>{s.type==="Particle"&&typeof s.renderMaterial.size=="number"&&Object.assign(s.renderMaterial,{size:[s.renderMaterial.size,s.renderMaterial.size]})})}(t),t.schema=110),e<111&&(t.scene.objects.traverse((i,r)=>{(function(s){Array.isArray(Gs(s.events))&&s.events?.forEach(n=>{"disabled"in n||(n.disabled=!1),(n.type==="MouseDown"||n.type==="MouseUp"||n.type==="MousePress")&&(n.mode=n.mode||"Object")})})(r)}),t.schema=111),e<112&&(function(i){i.scene.objects.traverse((r,s)=>{s.type==="Page"&&(s.postprocessing.depthOfField.focusDistance=100,s.postprocessing.depthOfField.focalLength=20,s.postprocessing.depthOfField.bokehScale=5)})}(t),t.schema=112),e<113&&(function(i){i.scene.objects.traverse((r,s)=>{Array.isArray(Gs(s.events))!==!1&&s.events?.forEach(n=>{let a=n.runMode;n.type==="MouseDown"||n.type==="MouseUp"||n.type==="KeyDown"||n.type==="KeyUp"||n.type==="Collision"||n.type==="Trigger"?n.actions?.forEach(o=>{o.type==="Transition"&&(o.runMode=a??"Repeat"),(o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode=a==="Toggle"?"Toggle":"Normal")}):n.type==="MouseHover"||n.type==="MousePress"||n.type==="KeyPress"?n.actions?.forEach(o=>{(o.type==="Transition"||o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Toggle")}):n.type==="GameControl"?(delete n.actions,Object.keys(n.gameActions).forEach(o=>{n.gameActions[o]?.forEach(l=>{l.type==="Transition"&&(l.runMode="Repeat"),l.type==="Animation"&&"runMode"in l&&(l.runMode="Normal")})})):n.type==="DragDrop"?(delete n.actions,n.dragDropActions?.drag?.forEach(o=>{(o.type==="Transition"||o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Toggle")}),n.dragDropActions?.drop?.forEach(o=>{(o.type==="Transition"||o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Toggle")})):n.type==="Resize"?(delete n.actions,n.breakpoints?.forEach(o=>{o.actions?.forEach(l=>{(l.type==="Transition"||l.type==="Animation"&&"runMode"in l||l.type==="SwitchCamera")&&(l.runMode="Toggle")})})):n.type==="Start"?n.actions?.forEach(o=>{o.type==="Transition"&&(o.runMode="Once"),(o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Normal")}):n.type==="VariableChange"||n.type==="Scroll"?n.actions?.forEach(o=>{o.type==="Transition"&&(o.runMode="Repeat"),(o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Normal")}):n.type==="Conditional"&&(delete n.actions,n.inActions?.forEach(o=>{o.type==="Transition"&&(o.runMode="Repeat"),(o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Normal")}),n.outActions?.forEach(o=>{o.type==="Transition"&&(o.runMode="Repeat"),(o.type==="Animation"&&"runMode"in o||o.type==="SwitchCamera")&&(o.runMode="Normal")}))})})}(t),t.schema=113),e<114&&(t.scene.publish.settings.web.imageQuality===void 0&&(t.scene.publish.settings.web.imageQuality=70),t.schema=114),e<115&&(function(i){i.shared.userAPIs=$a({},Be.prototype),i.shared.userWebhooks=$a({},Be.prototype),i.shared.lib&&(i.shared.lib.userAPIs=hc.defaultData().userAPIs,i.shared.lib.userWebhooks=hc.defaultData().userWebhooks)}(t),t.schema=115),e<116&&(function(i){i.scene.publish.settings.videoStatic===void 0&&(i.scene.publish.settings.videoStatic=vc.defaultData.settings.videoStatic)}(t),t.schema=116),e<117&&(t.scene.publish.settings.web.pixelRatioMobile===void 0&&(t.scene.publish.settings.web.pixelRatioMobile=0),t.scene.publish.settings.web.pixelRatioDesktop===void 0&&(t.scene.publish.settings.web.pixelRatioDesktop=0),t.schema=117),e<118&&(t.shared.timelineAnimations=$a({},Be.prototype),t.scene.objects.traverse((i,r)=>{Gmt(r)}),t.schema=118),e<119&&(t.scene.publish.settings.videoStatic.format=cv.defaultData.scene.publish.settings.videoStatic.format,t.scene.publish.settings.videoStatic.imageFormat=cv.defaultData.scene.publish.settings.videoStatic.imageFormat,t.schema=119),e<120&&(t.scene.publish.settings.image.colorSpace="display-p3",t.scene.publish.settings.videoStatic.colorSpace="display-p3",t.schema=120),e<121&&(t.scene.objects.traverse((i,r)=>{gU(r),r.type==="Page"&&r.camera!==void 0&&gU(r.camera)}),t.schema=121),e<122&&(delete t.scene.publish.settings.video,t.scene.publish.orbitControls.rotationSpeed=cv.defaultData.scene.publish.orbitControls.rotationSpeed,t.schema=122),e<123&&(t.scene.objects.traverse((i,r)=>{r.type==="Page"&&r.sky===void 0&&(r.sky=$p.defaultData)}),t.schema=123),e<124&&(e>=123&&t.scene.objects.traverse((i,r)=>{let s=r.sky;r.type==="Page"&&s!==void 0&&(typeof s.exposure=="number"&&(s.exposure=Math.round(s.exposure/5e-4*1e4)/1e4),s.lighting===void 0&&(s.lighting=$p.defaultData.lighting))}),t.schema=124),e<125&&(t.scene.objects.traverse((i,r)=>{let s=r.sky;r.type==="Page"&&s!==void 0&&s.lightingIntensity===void 0&&(s.lightingIntensity=$p.defaultData.lightingIntensity)}),t.schema=125),e<126&&(t.scene.objects.traverse((i,r)=>{let s=r.sky;r.type==="Page"&&s!==void 0&&(s.mode===void 0&&(s.mode="physical"),s.hdri===void 0?s.hdri={...$p.defaultData.hdri}:(s.hdri.blur===void 0&&(s.hdri.blur=$p.defaultData.hdri.blur),Array.isArray(s.hdri.rotation)&&(s.hdri.rotation=s.hdri.rotation[1]??0)))}),t.schema=126),e<127&&(t.scene.objects.traverse((i,r)=>{let s=r.sky;r.type==="Page"&&s?.hdri!==void 0&&s.hdri.showBackground===void 0&&(s.hdri.showBackground=!0)}),t.schema=127),e<128&&(t.scene.objects.traverse((i,r)=>{let s=r.sky;r.type==="Page"&&s!==void 0&&s.lightingQuality===void 0&&(s.lightingQuality="full")}),t.schema=128),e<129&&(t.scene.objects.traverse((i,r)=>{if(r.type==="Page"){r.camera===void 0&&(r.camera=zg.defaultData.camera);let s=r.camera;s.far=1e5,s.perspective?s.perspective.near=70:s.perspective={near:70,fov:45,zoom:1}}}),t.schema=129),e<130&&(jmt(t,vR),t.schema=130),e<131&&(function(i){i.scene.objects.traverse((r,s)=>{let n=s.states;if(!n)return;let a=s.timelineAnimations,o=[];n.forEach((l,u)=>{(l.isAnimation||a?.[u])&&o.push(u)}),o.forEach(l=>n.delete(l))})}(t),function(i){let r=i.shared,s=r.timelineAnimations;if(!s)return;let n=i.scene.objects,a=n.unproxy().find(o=>o.data.type==="Page")?.id;for(let[o,l]of Object.entries(s)){let u=$a({},Be.prototype),h=0,d=Boolean(l.loop);for(let[m,f]of Object.entries(l.mapping??{})){let g=n.data(m)?.timelineAnimations?.[f];!g||(h=Math.max(h,g.to??0),d=d||Boolean(g.loop),u[m]={id:m,keyframes:DMt(g.properties?.unproxy())})}let c=l.page??a,p=c?n.data(c):void 0;p&&p.type==="Page"&&((p.timelines??(p.timelines=$a({},Be.prototype)))[o]={id:o,name:l.name,duration:h||5,...d?{loop:d}:{},objectTimelines:u})}delete r.timelineAnimations,n.traverse((o,l)=>{delete l.timelineAnimations})}(t),pY(t,NMt),pY(t,BMt),t.schema=131)}}$S(Lmt,{updateAllMaterials:()=>jmt,updateDocumentSchema:()=>kMt,updateLibSchema:()=>VMt,updateMaterialSchema:()=>PMt,updateObjectStateRec:()=>q1,updateObjectsSchema:()=>Umt,updateTextValues:()=>EMt});var Dp,Wmt,qmt,mY,bM,hO,fY,_M,xg,s_,V0,xM,uO,PP,dO,cO,gY,RP,pO,Ug,yU,P5=G(()=>{dt(),Vmt(),Fi(),zmt(),CMt(),E5(),YS(),hn(),dG(),C5(),oG(),Dp=180/Math.PI,Wmt=Math.PI/180,qmt=["position","rotation","scale","shape size"]}),zMt=G(()=>{var t,e,i;wl(),Fi(),hn(),(mY||(mY={})).is=function(r){return!0},(t=bM||(bM={})).defaultData={position:[0,0],scale:[1,1],rotation:0,shear:[0,0]},t.merge=function(r,s){return{position:s?.position??r.position,rotation:s?.rotation??r.rotation,scale:s?.scale??r.scale,shear:s?.shear??r.shear}},t.diff=function(r,s){return Jpt({position:qu.isEqual(r.position,s.position)?void 0:s.position,rotation:r.rotation===s.rotation?void 0:s.rotation,scale:qu.isEqual(r.scale,s.scale)?void 0:s.scale,shear:r.shear&&s.shear&&qu.isEqual(r.shear,s.shear)?void 0:s.shear})},(hO||(hO={})).defaultData={horizontalConstraint:0,verticalConstraint:0},(fY||(fY={})).defaultData={direction:"row",wrap:"unwrap",align:"top-left",gap:10,rowGap:10,autoGap:!1,autoRowGap:!1,leftPadding:8,rightPadding:8,topPadding:8,bottomPadding:8},(_M||(_M={})).defaultData={opacity:1,fill:{color:qi.fromHexAndA(Kg,1),enabled:!0},stroke:{color:qi.from0to1([0,0,0,1]),thickness:1,enabled:!1,mode:"inside"},layerBlur:{radius:2,enabled:!1},backgroundBlur:{radius:2,enabled:!1},dropShadow:{offset:[10,10],blurRadius:10,color:qi.from0to1([0,0,0,1]),enabled:!1,spread:0},innerShadow:{offset:[10,10],blurRadius:10,color:qi.from0to1([0,0,0,1]),enabled:!1,spread:0}},(e=xg||(xg={})).newEmpty=function(r,s){return{name:s}},e.patch=function(r,s){if(s===void 0)return r;let n={...r};return Object.assign(n,bM.merge(n,s)),n=function(a,o){if(o===void 0)return a;let l={...a},u=["width","height","cornerRadius"];for(let h of u)h in l&&h in o&&o[h]!==void 0&&Object.assign(l,{[h]:o[h]});return l}(n,s),n=function(a,o){if(o===void 0)return a;let l={...a};return"fill"in l&&"fill"in o&&o.fill!==void 0&&Object.assign(l,{fill:{...l.fill,...o.fill}}),"stroke"in l&&"stroke"in o&&o.stroke!==void 0&&Object.assign(l,{stroke:{...l.stroke,...o.stroke}}),"layerBlur"in l&&"layerBlur"in o&&o.layerBlur!==void 0&&Object.assign(l,{layerBlur:{...l.layerBlur,...o.layerBlur}}),"backgroundBlur"in l&&"backgroundBlur"in o&&o.backgroundBlur!==void 0&&Object.assign(l,{backgroundBlur:{...l.backgroundBlur,...o.backgroundBlur}}),"dropShadow"in l&&"dropShadow"in o&&o.dropShadow!==void 0&&Object.assign(l,{dropShadow:{...l.dropShadow,...o.dropShadow}}),"innerShadow"in l&&"innerShadow"in o&&o.innerShadow!==void 0&&Object.assign(l,{innerShadow:{...l.innerShadow,...o.innerShadow}}),l}(n,s),n},e.toOps=function(r,s){let n,a=[];for(let[o,l]of Object.entries(s))o!=="name"&&(n===void 0&&(n={path:[],props:{},type:0},a.push(n)),n.props[o]=l);return a},(s_||(s_={})).defaultData={...bM.defaultData,...hO.defaultData,states:new ge,events:new ge,visible:!0,raycastLock:!1},(V0||(V0={})).defaultData={...s_.defaultData,..._M.defaultData},(xM||(xM={})).defaultData={cornerRadius:[0,0,0,0]},(uO||(uO={})).defaultData={...V0.defaultData,type:"ellipse2d",width:100,height:100,name:"Ellipse"},(PP||(PP={})).defaultData={...V0.defaultData,...xM.defaultData,type:"rectangle2d",width:100,height:100,name:"Rectangle"},(dO||(dO={})).defaultData={...V0.defaultData,type:"text2d",width:100,height:100,fontSize:12,lineHeight:1.2,letterSpacing:0,text:{textValue:"Hello world"},horizontalAlign:1,verticalAlign:1,textTransform:1,font:"Roboto_regular",name:"Text"},(cO||(cO={})).defaultData={...V0.defaultData,type:"path2d",path:"",name:"Path"},(gY||(gY={})).is=function(r){return r.type==="ellipse2d"||r.type==="rectangle2d"||r.type==="text2d"||r.type==="vector2d"||r.type==="path2d"},(RP||(RP={})).defaultData={...s_.defaultData,name:"Group",type:"group2d"},(pO||(pO={})).defaultData=()=>({...s_.defaultData,...xM.defaultData,..._M.defaultData,name:"Frame",type:"frame2d",clipped:!0,width:200,height:200,fill:{color:qi.fromHexAndA(4737101,1),enabled:!0},stroke:{color:qi.fromHexAndA(0,1),thickness:1,enabled:!1,mode:"inside"},backgroundBlur:{radius:2,enabled:!1},layerBlur:{radius:2,enabled:!1}}),(r=>{r.defaultData=function(s){switch(s){case"rectangle2d":case"vector2d":return{...PP.defaultData};case"ellipse2d":return{...uO.defaultData};case"text2d":return{...dO.defaultData};case"path2d":return{...cO.defaultData};case"frame2d":return{...pO.defaultData()};case"group2d":return{...RP.defaultData}}},r.getPivot=function(s){return"width"in s&&"height"in s?[typeof s.width=="number"?.5*s.width:0,typeof s.height=="number"?.5*s.height:0]:[0,0]},r.isResizeable=function(s){return s.type==="rectangle2d"||s.type==="ellipse2d"||s.type==="text2d"||s.type==="frame2d"},r.isAutoLayoutable=function(s){return s.type==="frame2d"&&s.autoLayout!==void 0},r.hasCorners=function(s){return s.type==="rectangle2d"||s.type==="frame2d"}})(Ug||(Ug={})),(i=yU||(yU={})).defaultData={name:"UI",type:"scene2d",objects:new In},i.emptyData=function(){return{type:"scene2d",objects:new In}}}),LMt=G(()=>{_Mt(),xMt(),wmt(),Smt(),Vmt(),bmt(),AMt(),Emt(),Dmt(),oG(),P5(),Bmt(),aG(),nG(),Tmt(),YS(),Cmt(),Omt(),wl(),E5(),C5(),hG(),Rmt(),dG(),uG(),wMt(),Pmt(),cG(),lG(),Mmt(),Amt(),zMt()});function wg(t,e=!1){let i=t[0].index!==null,r=new Set(Object.keys(t[0].attributes)),s=new Set(Object.keys(t[0].morphAttributes)),n={},a={},o=t[0].morphTargetsRelative,l=new ye,u=0;for(let h=0;h<t.length;++h){let d=t[h],c=0;if(i!==(d.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(let p in d.attributes){if(!r.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+'. All geometries must have compatible attributes; make sure "'+p+'" attribute exists among all geometries, or in none of them.'),null;n[p]===void 0&&(n[p]=[]),n[p].push(d.attributes[p]),c++}if(c!==r.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". Make sure all geometries have the same number of attributes."),null;if(o!==d.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let p in d.morphAttributes){if(!s.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". .morphAttributes must be consistent throughout all geometries."),null;a[p]===void 0&&(a[p]=[]),a[p].push(d.morphAttributes[p])}if(e){let p;if(i)p=d.index.count;else{if(d.attributes.position===void 0)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". The geometry must have either an index or a position attribute"),null;p=d.attributes.position.count}l.addGroup(u,p,h),u+=p}}if(i){let h=0,d=[];for(let c=0;c<t.length;++c){let p=t[c].index;for(let m=0;m<p.count;++m)d.push(p.getX(m)+h);h+=t[c].attributes.position.count}l.setIndex(d)}for(let h in n){let d=yY(n[h]);if(!d)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+h+" attribute."),null;l.setAttribute(h,d)}for(let h in a){let d=a[h][0].length;if(d!==0){l.morphAttributes=l.morphAttributes||{},l.morphAttributes[h]=[];for(let c=0;c<d;++c){let p=[];for(let f=0;f<a[h].length;++f)p.push(a[h][f][c]);let m=yY(p);if(!m)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+h+" morphAttribute."),null;l.morphAttributes[h].push(m)}}}return l}function yY(t){let e,i,r,s=-1,n=0;for(let u=0;u<t.length;++u){let h=t[u];if(e===void 0&&(e=h.array.constructor),e!==h.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(i===void 0&&(i=h.itemSize),i!==h.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(r===void 0&&(r=h.normalized),r!==h.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(s===-1&&(s=h.gpuType),s!==h.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;n+=h.count*i}let a=new e(n),o=new we(a,i,r),l=0;for(let u=0;u<t.length;++u){let h=t[u];if(h.isInterleavedBufferAttribute){let d=l/i;for(let c=0,p=h.count;c<p;c++)for(let m=0;m<i;m++){let f=h.getComponent(c,m);o.setComponent(c+d,m,f)}}else a.set(h.array,l);l+=h.count*i}return s!==void 0&&(o.gpuType=s),o}var KS=G(()=>{dt()});function Hmt(t){let e=t.points.length/7,i=new ge;for(let r=0;r<e;r++){let s=7*r,n=t.points[s+0],a=t.points[s+1],o=t.points[s+2],l=t.points[s+3],u=t.points[s+4],h=t.points[s+5],d=t.points[s+6];i.push({fi:r,id:qt.generateUUID(),data:{roundness:d,position:[n,a],areControlsDirectionsMirrored:!0,controlPrevious:{position:[o,l]},controlNext:{position:[u,h]}}})}return{points:i,isClosed:t.isClosed,roundness:t.roundness,shapeHoles:t.shapeHoles?.map(r=>Hmt(r))??[]}}function $mt(t){let{userData:e,uuid:i,...r}=t;if(e===void 0||e.type==="NonParametricGeometry")return function(a){let o,{userData:l,data:u}=a,h=u?.groups,d=u?.attributes??{},c=u?.morphAttributes??{},p=u?.interleavedBuffers,m=u?.arrayBuffers,f=u?.index;d.position!==void 0&&Array.isArray(d.position.array)&&(o=function(y){let v=1/0,b=1/0,_=1/0,x=-1/0,S=-1/0,w=-1/0;for(let T=0;T<y.length;T+=3){let A=y[T],M=y[T+1],C=y[T+2];v=Math.min(v,A),b=Math.min(b,M),_=Math.min(_,C),x=Math.max(x,A),S=Math.max(S,M),w=Math.max(w,C)}return{width:x-v,height:S-b,depth:w-_}}(d.position.array));let g={...l===void 0?{}:l.parameters,data:{attributes:d,morphAttributes:c,interleavedBuffers:p,arrayBuffers:m},...o===void 0?{}:o,type:"NonParametricGeometry"};return f!==void 0&&Object.assign(g.data,{index:f}),h!==void 0&&Object.assign(g.data,{groups:h.map(y=>({...y,materialIndex:y.materialIndex??0}))}),g}(t);if(e.type==="SubdivGeometry"){let a="SubdivGeometry",o=r.data?.attributes;if(o?.positionWASM===void 0){let u=new ye;if(o?.position===void 0||o?.faceMap===void 0)return null;let h=o.position.array,d=o.faceMap.array,c=r.data.index.array;u.setAttribute("position",new fe(h,3)),u.setIndex(new om(c,1));let p=function(y,v=1e-4){v=Math.max(v,Number.EPSILON);let b={},_=y.getIndex(),x=y.getAttribute("position"),S=_?_.count:x.count,w=0,T=Object.keys(y.attributes),A={},M={},C=[],R=["getX","getY","getZ","getW"],O=["setX","setY","setZ","setW"];for(let V=0,q=T.length;V<q;V++){let j=T[V],Q=y.attributes[j];A[j]=new Q.constructor(new Q.array.constructor(Q.count*Q.itemSize),Q.itemSize,Q.normalized);let it=y.morphAttributes[j];it&&(M[j]||(M[j]=[]),it.forEach((at,St)=>{let yt=new at.array.constructor(at.count*at.itemSize);M[j][St]=new at.constructor(yt,at.itemSize,at.normalized)}))}let N=.5*v,B=Math.log10(1/v),k=Math.pow(10,B),z=N*k;for(let V=0;V<S;V++){let q=_?_.getX(V):V,j="";for(let Q=0,it=T.length;Q<it;Q++){let at=T[Q],St=y.getAttribute(at),yt=St.itemSize;for(let Y=0;Y<yt;Y++)j+=~~(St[R[Y]](q)*k+z)+","}if(j in b)C.push(b[j]);else{for(let Q=0,it=T.length;Q<it;Q++){let at=T[Q],St=y.getAttribute(at),yt=y.morphAttributes[at],Y=St.itemSize,pt=A[at],xt=M[at];for(let Tt=0;Tt<Y;Tt++){let Mt=R[Tt],_t=O[Tt];if(pt[_t](w,St[Mt](q)),yt)for(let kt=0,Ut=yt.length;kt<Ut;kt++)xt[kt][_t](w,yt[kt][Mt](q))}}b[j]=w,C.push(w),w++}}let L=y.clone();for(let V in y.attributes){let q=A[V];if(L.setAttribute(V,new q.constructor(q.array.slice(0,w*q.itemSize),q.itemSize,q.normalized)),V in M)for(let j=0;j<M[V].length;j++){let Q=M[V][j];L.morphAttributes[V][j]=new Q.constructor(Q.array.slice(0,w*Q.itemSize),Q.itemSize,Q.normalized)}}return L.setIndex(C),L}(u),m=[],f=new Array(d[d.length-1]+1).fill(3),g=p.getIndex().array;for(let y=0,v=d.length;y<v;)d[y]===d[y+1]?(f[d[y]]++,m.push(...new Set(g.slice(3*y,3*y+6))),y+=2):(m.push(...g.slice(3*y,3*y+3)),y++);o.indexWASM={array:m},o.positionWASM=p.attributes.position,o.verticesPerFaceWASM={array:f}}if(o?.positionWASM===void 0||o?.positionWASM.length===0||o?.indexWASM===void 0||o?.indexWASM.length===0||o?.verticesPerFaceWASM===void 0||o?.verticesPerFaceWASM.length===0)return null;let l={type:a,...FMt(o.positionWASM.array)};l.subdivisions=e.parameters.subdivisions;for(let u in o)u==="positionWASM"?l[u]=new Float32Array(o[u].array):u==="indexWASM"?l[u]=new Int32Array(o[u].array):u==="verticesPerFaceWASM"&&(l[u]=new Int8Array(o[u].array));return l.scaleBaked=[1,1,1],l}let s=e.type,n=e.parameters;return s==="VectorGeometry"?(n.extrudeDepth&&(n.depth=n.extrudeDepth),{...n,width:100,height:100,shape:Hmt(e.shape),type:s}):s==="LatheGeometry"?{...e.parameters,type:s,points:(e?.parameters.points??[]).map(a=>[a.x,a.y])}:(n.extrudeDepth&&(n.depth=n.extrudeDepth),{...n,type:s})}function FMt(t){return vU.setFromArray(t),vU.getSize(Hw),{width:Hw.x,height:Hw.y,depth:Hw.z}}var vU,Hw,mO,UMt=G(()=>{Fi(),dt(),KS(),new bt,new Me,new Qi,new P,new P,vU=new pr,Hw=new P}),jMt=G(()=>{var t;(t=mO||{}).view="view",t.edit="edit",((mO=t)||(mO={})).canWrite=function(e){return e!=="view"},class extends Error{constructor(e,i){super(`This is a ${e.toUpperCase()} document, but it was opened as a ${i.toUpperCase()} one`),this.actual=e,this.expected=i,this.name="DocumentKindMismatchError"}}}),Xmt,bU,DP,Ymt,Kmt,$v,n_,wM,fO,Xv,vY,gO,bY,yO,Ov,Wc,qc,dd,vO,_Y,xY,bO,_U,bc,Zmt=G(()=>{jMt()}),GMt=G(()=>{}),WMt=G(()=>{Fi(),P5(),Zmt()}),qMt=G(()=>{YS(),[...A5],new Set(rG)}),ke=G(()=>{LMt(),GMt(),MMt(),P5(),WMt(),Zmt(),zmt(),qMt(),cG(),Fi()}),R5=G(()=>{Xmt=[3,4,8,9],bU=5,DP=3,Ymt=32,Kmt=.98}),ZS=G(()=>{dt(),$v=t=>{var e;return(e=class extends t{}).geometryHelper=new Zh(30,30,30),e}}),QS=G(()=>{dt(),n_=new pc,wM=new ta,fO=new bt,Xv=(t,e,i,r,s=!1,n=t)=>{let a=e,o=n.matrixWorld;if(a.boundingSphere===null&&a.computeBoundingSphere(),wM.copy(a.boundingSphere),wM.applyMatrix4(o),i.ray.intersectsSphere(wM)===!1||(fO.copy(o).invert(),n_.copy(i.ray).applyMatrix4(fO),a.boundingBox!==null&&n_.intersectsBox(a.boundingBox)===!1))return;let l,u,h,d,c,p,m=a.index,f=a.attributes.position,g=a.drawRange;if(s===!1){for(c=Math.max(0,g.start),p=Math.min(m.count,g.start+g.count);c<p;c+=3)if(u=m.getX(c),h=m.getX(c+1),d=m.getX(c+2),l=y(t,i,n_,f,u,h,d),l)return l.faceIndex=Math.floor(c/3),void r.push(l)}else{let v=a.attributes.position,b=new P,_=new P,x=new P,S=new P,w=2,T=1/((n.scale.x+n.scale.y+n.scale.z)/3),A=T*T;for(let M=Math.max(0,g.start),C=Math.min(v.count,g.start+g.count)-1;M<C;M+=w){if(b.fromBufferAttribute(v,M),_.fromBufferAttribute(v,M+1),n_.distanceSqToSegment(b,_,S,x)>A)continue;S.applyMatrix4(n.matrixWorld);let R=i.ray.origin.distanceTo(S);R<i.near||R>i.far||r.push({distance:R,point:x.clone().applyMatrix4(n.matrixWorld),object:t})}}function y(v,b,_,x,S,w,T){let A=new P,M=new P,C=new P,R=new P,O=new P;if(A.fromBufferAttribute(x,S),M.fromBufferAttribute(x,w),C.fromBufferAttribute(x,T),_.intersectTriangle(A,M,C,!1,R)===null)return null;O.copy(R),O.applyMatrix4(v.matrixWorld);let N=b.ray.origin.distanceTo(O);return N<b.near||N>b.far?null:{faceIndex:1,distance:N,point:O.clone(),object:v}}}}),D5=G(()=>{dt(),ZS(),QS(),vY=new P(1,1,1),gO=new P,bY=new P,yO=new Me,Ov=class extends $v(qpt){constructor(t,e=15){super(e),this.object=t,this.dummy=new Hv,this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${t.uuid}`,this.matrix=this.dummy.matrixWorld,this.matrixAutoUpdate=!1,this.object.isBone&&(this.visible=!1)}raycast(t,e){Xv(this.object,Ov.geometryHelper,t,e,!1,this.dummy)}update(){}updateMatrix(){}updateMatrixWorld(t){this.object.matrixWorld.decompose(gO,yO,bY),this.matrix.compose(gO,yO,vY),super.updateMatrixWorld(t)}updateWorldMatrix(t,e){}}}),HMt=G(()=>{dt(),Wc=new P,qc=new P,dd=new bt,vO=[new P(-1,1,1),new P(-1,-1,1),new P(1,-1,1),new P(1,1,1),new P(-1,1,-1),new P(-1,-1,-1),new P(1,-1,-1),new P(1,1,-1)],_Y=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],xY=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],bO=(t,e,i)=>{t.updateEntityBoxSize(Wc,qc),dd.copy(e).multiply(t.matrixWorld),qc.x===0&&qc.y===0&&qc.z===0?i.push(new P(Wc.x,Wc.y,Wc.z).applyMatrix4(dd)):vO.forEach(r=>{i.push(r.clone().multiply(qc).add(Wc).applyMatrix4(dd))})},_U=class extends pr{constructor(){super(...arguments),this.matrix=new bt,this.vertices=[],this.faces=[],this.edges=[],this.centerEdges=[]}copy(t){return super.copy(t),this.matrix.copy(t.matrix),this.vertices=t.vertices.map(e=>e.clone()),this.faces=t.faces.map(e=>e.clone()),this.edges=t.edges.map(e=>e.clone()),this.centerEdges=t.centerEdges.map(e=>e.clone()),this}setFromObjectSize(t,e=!1){t.updateWorldMatrix(!1,e),this.makeEmpty(),this.matrix.copy(t.matrixWorld);let i=new bt().copy(t.matrixWorld).invert();return this.expandByObjectSize(t,i,e)}expandByObjectSize(t,e,i=!1){let r=[];if(i===!0){let s=[];t.traverseEntity(n=>{if(n.visible||n.cloner&&n.data.visible){if(!("geometry"in n))return dd.copy(e).multiply(n.matrixWorld),void s.push(new P().applyMatrix4(dd));bO(n,e,r)}}),r.length===0&&r.push(...s)}else bO(t,e,r);return this.setFromPoints(r)}getCenter(t){return(t=super.getCenter(t)).applyMatrix4(this.matrix),t}getPositionToCenter(t){return(t=super.getCenter(t)).applyMatrix4(dd.copy(this.matrix).setPosition(0,0,0)),t}computeVertices(){this.getSize(qc).multiplyScalar(.5),this.getCenter(Wc),dd.copy(this.matrix).setPosition(Wc),this.vertices=vO.map(t=>t.clone().multiply(qc).applyMatrix4(dd))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=_Y.map(([t,e])=>new yl(this.vertices[t],this.vertices[e])),this.centerEdges=this.edges.map(t=>t.getCenter(new P))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=xY.map(([t,e])=>this.vertices[t].clone().add(this.vertices[e]).multiplyScalar(.5))}}}),bR=G(()=>{bc={Cloner:null,changeEntityProptotype:()=>{},createEntity:()=>{}}});function q2(t){return t?.isParticleSystem===!0}function Jg(t){return t?.isHairSystem===!0}function Cc(t){return t?.isShapeBlendEntity===!0}function N5(t){return t?.isPathObject===!0}function jo(t){return t?.isObject2D===!0}function Ya(t){return t?.isUIObject===!0}function H1(t){return t?.isCloner===!0}function Sg(t){return t?.isClone===!0}function NP(t){return t?.isComponentObject===!0}var ns=G(()=>{});function Or(t){pG.add(t)}function Nn(t,e){let i=`${t}:${e}`;SU.has(i)||SU.add(i)}function _R(t,e){mG.set(t,e)}function _O(t){return mG.get(t)}function Yv(t,e){fG.set(t,e)}function xO(t){return fG.get(t)}function xU(t,e){gG.set(t,e)}function Qmt(t){return gG.get(t)}function wU(){return O5}var pG,SU,mG,fG,gG,O5,xR,Ii=G(()=>{pG=new Set,SU=new Set,mG=new Map,fG=new Map,gG=new Map,O5=null,xR=null});function Jmt(t){let e=t.elements;Uh.set(e[0],e[1],e[2]),jh.set(e[4],e[5],e[6]),ku.set(e[8],e[9],e[10])}function tft(){let t=Math.max(Uh.lengthSq(),jh.lengthSq(),ku.lengthSq());Uh.lengthSq()>$w*t?ml.copy(Uh).normalize():ml.set(1,0,0),fl.crossVectors(ku,ml),fl.lengthSq()<=$w*t&&(fl.copy(jh).addScaledVector(ml,-jh.dot(ml)),fl.lengthSq()<=$w*t&&function(e,i){e.set(1,0,0).cross(i),e.lengthSq()<=$w&&e.set(0,1,0).cross(i),e.normalize()}(fl,ml)),fl.normalize(),Tg.crossVectors(ml,fl)}function eft(t){return Jmt(t),tft(),ift.makeBasis(ml,fl,Tg)}var Uh,jh,ku,ml,fl,Tg,ift,$w,Xw,SM,Mg,I5,rft=G(()=>{dt(),Uh=new P,jh=new P,ku=new P,ml=new P,fl=new P,Tg=new P,ift=new bt,$w=1e-12,Xw=.01}),JS=G(()=>{dt(),rft(),SM=new bt,(Mg||(Mg={})).is=function(t){return t&&t.__isSPEObject},I5=t=>class extends t{constructor(){super(...arguments),this.previousModelViewMatrix=new bt,this.copyPreviousMatrix=!0,this.hiddenMatrix=new bt,this.pivotMatrix=new bt,this.matrixWorldRigid=new bt,this.shearScale=new bt,this.shearScaleInv=new bt}get __isSPEObject(){return!0}getPhysicsLocalMatrix(e){return!!this.rigidBody?.isDynamic()&&(e.copy(this.matrixWorld),this.hasNonUniformScale&&e.multiply(this.shearScaleInv),this.parent&&e.premultiply(SM.copy(this.parent.matrixWorld).invert()),e.premultiply(SM.copy(this.hiddenMatrix).invert()),e.multiply(SM.copy(this.pivotMatrix).invert()),!0)}isDescendantOf(e){e instanceof dr&&(e=e.uuid);let i=this;for(;i.parent;){if(i.parent.uuid===e)return!0;i=i.parent}return!1}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorld.multiply(this.pivotMatrix),this.matrixWorldNeedsUpdate=!1,e=!0);for(let i of this.children)i.updateMatrixWorld(e)}updateWorldMatrix(e,i){let r=this.parent;if(e&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorld.multiply(this.pivotMatrix),i)for(let s of this.children)s.updateWorldMatrix(!1,!0)}traverseChildren(e,i=0){for(let r of this.children)Mg.is(r)&&r.traverseObject(e,i+1)}traverseObject(e,i=0){if(e(this,i)!==!0)for(let r of this.children)Mg.is(r)&&r.traverseObject(e,i+1)}updateMatrixWorldRigid(){this.hasNonUniformScale=function(e,i,r){return Jmt(e),tft(),i.makeBasis(ml,fl,Tg),r.set(ml.dot(Uh),ml.dot(jh),ml.dot(ku),0,fl.dot(Uh),fl.dot(jh),fl.dot(ku),0,Tg.dot(Uh),Tg.dot(jh),Tg.dot(ku),0,0,0,0,1),function(){let s=Uh.length(),n=jh.length(),a=ku.length(),o=Math.max(s,n,a);if(o-s>Xw||o-n>Xw||o-a>Xw)return!0;let l=Xw*o*o;return Math.abs(Uh.dot(jh))>l||Math.abs(Uh.dot(ku))>l||Math.abs(jh.dot(ku))>l}()}(this.matrixWorld,this.matrixWorldRigid,this.shearScale),this.matrixWorldRigid.copyPosition(this.matrixWorld),this.shearScaleInv.copy(this.shearScale).invert()}attach(e,i){this.updateWorldMatrix(!0,!1);let r=new bt().copy(this.matrixWorld).invert();return e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),r.multiply(e.parent.matrixWorld)),"hiddenMatrix"in e&&e.hiddenMatrix instanceof bt?e.hiddenMatrix.premultiply(r):e.applyMatrix4(r),e.updateWorldMatrix(!1,!1),this.add(e),i!==void 0&&(this.children.pop(),this.children.splice(i,0,e)),this}copy(e,i=!1){return super.copy(e,i),this.hasNonUniformScale=e.hasNonUniformScale,this}onAfterRender(e,i,r,s,n,a){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}}});function wY(t,e,i){return Xp.subVectors(e,t),DS.subVectors(e,i),Xp.cross(DS).length()<=H2}function sft(t){let e=AU.get(t.points);if(e!==void 0&&e.isClosed===t.isClosed)return e.curve;let i=function(r){let s=r.points,n=[s[0]],a=[new P(...s[0].data.position)];rg.copy(a[0]);for(let y=0;y<s.length-1;y++)Xp.fromArray(s[y].data.position),DS.fromArray(s[y+1].data.position),T1.subVectors(Xp,rg),M1.subVectors(Xp,DS),T1.cross(M1).length()>H2&&(n.push(s[y]),a.push(new P().copy(Xp)),rg.copy(Xp));let o=s[s.length-1];n.push(o),a.push(new P(...o.data.position));let l=r.isClosed,u=n.length-(l?0:1),h=n.length,d=[],c=[];for(let y=0;y<h;y++){let v=n[y].data;d.push(new P(...v.controlPrevious.position)),c.push(new P(...v.controlNext.position))}let p=[];for(let y=0;y<u;y++){let v=y===h-1?0:y+1;p.push(wY(a[y],c[y],a[v])&&wY(a[y],d[v],a[v]))}let m=[];for(let y=0;y<h;y++){let v=n[y].data,b=a[y],_={position:b,prevDir:void 0,nextDir:void 0,controlPrevious:d[y],controlNext:c[y],tan:void 0,baseRoundness:v.roundness,removedLength:0};if(m.push(_),v.roundness===0||!l&&(y===0||y===h-1))continue;let x=l&&y==0?h-1:y-1,S=l&&y==h-1?0:y+1,w=new P().subVectors(a[x],b).normalize(),T=new P().subVectors(a[S],b).normalize();_.prevDir=w,_.nextDir=T;let A=p[l&&y===0?h-1:y-1],M=p[y];if(A&&M){sg.addVectors(w,T).normalize();let C=rg.crossVectors(sg,w).length()/w.dot(sg);_.tan=C,_.removedLength=v.roundness/C}}for(let y=0;y<u;y++){let v=l&&y===h-1?0:y+1,b=m[y],_=m[v];if(b.removedLength!==0||_.removedLength!==0){let x=b.position.distanceTo(_.position);b.removedLength=Math.min(b.removedLength,x/2),_.removedLength=Math.min(_.removedLength,x/2)}}let f=new Array(2*h).fill(null);for(let y=0;y<u;y++){let v=l&&y===h-1?0:y+1,b=m[y],_=m[v],x=null;if(p[y]){let S=b.position.clone(),w=_.position.clone();(b.removedLength!==0||_.removedLength!==0)&&(b.nextDir&&S.add(rg.copy(b.nextDir).setLength(b.removedLength)),_.prevDir&&w.add(rg.copy(_.prevDir).setLength(_.removedLength))),S.distanceTo(w)>H2&&(x=new k2(S,S.clone().lerp(w,.3),w.clone().lerp(S,.3),w))}else b.position.distanceTo(_.position)>H2&&(x=new k2(b.position,b.controlNext,_.controlPrevious,_.position));f[2*y+1]=x}for(let y=0;y<h;y++){let v=m[y];if(v.removedLength===0)continue;let b=v.position,_=v.prevDir.clone().multiplyScalar(v.removedLength).add(b),x=v.nextDir.clone().multiplyScalar(v.removedLength).add(b),S=v.tan*v.removedLength;sg.addVectors(v.prevDir,v.nextDir).normalize(),T1.copy(_).lerp(x,.5);let w=_.distanceTo(x)/2;MU.copy(sg).multiplyScalar(Math.sqrt(Math.pow(S,2)-Math.pow(w,2))).add(T1),OP.copy(sg).multiplyScalar(-S).add(MU);let T=b.distanceTo(OP)/b.distanceTo(T1);M1.copy(v.prevDir).multiplyScalar(T*b.distanceTo(_)).add(b),TU.copy(M1).lerp(OP,2);let A=_.clone().lerp(M1,4/3),M=x.clone().lerp(TU,4/3);f[2*y]=new k2(_,A,M,x)}let g=new nft;for(let y=0;y<f.length;y++){let v=f[y];v&&g.add(v)}return g}(t);return AU.set(t.points,{isClosed:t.isClosed,curve:i}),i}var nft,H2,Xp,DS,rg,sg,T1,OP,M1,TU,MU,AU,A1,CU,IP,aft,oft,lft,Mi,Vu,SY,TY,a_,wO,TM,SO,TO,B5,EU,r0,zu,hft=G(()=>{dt(),nft=class extends _8{constructor(){super()}getPoints(t=12){let e,i=[],r=this.getCurveLengths(),s=r[r.length-1]/r.length;for(let n=0,a=this.curves;n<a.length;n++){let o=a[n],l=n===0?r[n]:r[n]-r[n-1],u=Math.ceil(t*l/s),h=o.getPoints(u);for(let d=0;d<h.length;d++){let c=h[d];e&&e.equals(c)||(i.push(c),e=c)}}return this.autoClose&&i.length>1&&!i[i.length-1].equals(i[0])&&i.push(i[0]),i}},H2=.001,Xp=new P,DS=new P,rg=new P,sg=new P,T1=new P,OP=new P,M1=new P,TU=new P,MU=new P,AU=new WeakMap}),$Mt=G(()=>{dt(),A1=new bt,CU=new Me,IP=new Me,aft=new Qi,oft=new P,lft=new P(0,1,0)}),vo=G(()=>{dt(),ke(),HMt(),Fi(),bR(),ns(),Ii(),JS(),hft(),$Mt(),ir(),(Mi||(Mi={})).is=function(t){return t&&t.__isEntity},Vu=t=>Mi.is(t),SY={type:"completeState",isfromEntity:!0},TY=["x","y","z"],a_=new P,wO=new P(1,1,1),TM=new Me,SO=new Qi,TO=new bt,B5=t=>class extends I5(t){constructor(){super(...arguments),this.raycastLock=!1,this.scaleLock=!1,this.disposed=!1,this.stateSelection=null,this.destroyedInAction=!1,this.instances=[],this.prevState=null,this.currentState=null,this.currentAnimationAction=null,this.reversibleToState=null,this.transitionState={settled:!0,state:null},this.currentTransitionEvent=null,this.previousAction=null,this._singleBBox=new _U,this._recursiveBBox=new _U,this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0,this._needApplyPathSnapping=!0,this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(e){let i=this.children[e];if(Mi.is(i))return i}entityChildrenCount(){let e=this.children.length;for(;e--;)if(Mi.is(this.children[e]))return e+1;return 0}get isConcreteEntity(){return typeof this.identity=="string"}get isVirtualEntity(){return typeof this.identity!="string"}get isInstanceRoot(){return this.isConcreteEntity&&this.data.type==="Instance"}nearestInstanceSelfOrParent(){let e=this;for(;e.data.type!=="Instance";){let i=e.parent;if(!Mi.is(i))return;e=i}return e}forInstancesRec(e){this.instances.forEach(i=>{i.disposed||e(i),i.forInstancesRec(e)})}super_Entity(e,i){typeof e=="string"&&(this.uuid=e),this.identity=e,this.data=i,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(e,i,r=!1){if(this.data.states.length!==0||r){for(let s of this.data.states)em.toOps(this.data,s.data).forEach(n=>{let a=K4.replaceProps(n,this.data);this.dataPatched=this.data,this.updateByPatchedOp(a,this.data,i)});if(e!==null){let s=this.data.states.data(e);s&&(this.dataPatched=em.patch(this.data,s),em.toOps(this.data,s).forEach(n=>{this.updateByPatchedOp(n,this.dataPatched,i)}))}r&&this.updateTransformState(this.dataPatched,i),this.stateSelection=e,this.updatePathSnapping(this.dataPatched.pathSnapping)}}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges(),this._singleBBox.computeFaces()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges(),this._recursiveBBox.computeFaces()),this._recursiveBBox}updateEntityBoxSize(e,i){e.setScalar(0),i.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(e=>{Vu(e)&&e.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(e=>{e.resetBBoxNeedsUpdateSelf()})}find(e){let i;return this.traverseEntity(r=>{r.uuid===e&&(i=r)}),i}traverseSortNextHelper(){let e=this.parent;if(e){let i=e.children,r=i.indexOf(this)+1;if(Mi.is(i[r]))return i[r];if(Mi.is(e))return e.traverseSortNextHelper()}}sortNext(){let e=this.children;return this.children.length>0&&Mi.is(this.children[0])?e[0]:this.traverseSortNextHelper()}goUp(e){let i=this;for(;e>0&&i!==null;)i=i.parent,e-=1;return i}hasAnccestorOrSelf(e){return this===e||this.hasAnccestor(e)}hasAnccestor(e){let i=this.parent;for(;i;){if(e===i)return!0;i=i.parent}return!1}countToAccestor(e){let i=0,r=this;for(;r!==e;){if(r===null)return-1;r=r.parent,i+=1}return i}forEachEntity(e){for(let i of this.children)Vu(i)&&e(i)}traverseEntityAncestors(e){this.traverseAncestors(i=>{Mi.is(i)&&e(i)})}traverseConcreteEntity(e,i=0){if(e(this,i)!==!0)for(let r of this.children)Vu(r)&&r.isConcreteEntity&&r.traverseEntity(e,i+1)}traverseEntity(e,i=0){if(e(this,i)!==!0)for(let r of this.children)Vu(r)&&r.traverseEntity(e,i+1)}traverseVisibleEntity(e){e(this);for(let i of this.children)Vu(i)&&i.visible&&i.traverseVisibleEntity(e)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}updateMatrixWorld(e){super.updateMatrixWorld(e),this.dispatchEvent({type:"updateMatrixWorld"})}copy(e,i=!1){return super.copy(e,i),this.dataPatched=e.dataPatched,this.raycastLock=e.raycastLock,this.scaleLock=e.scaleLock,this.hiddenMatrix.copy(e.hiddenMatrix),this}hasEntityChild(){return this.children.some(e=>Vu(e))}isAncestorOf(e){if(this.uuid===e)return!1;let i=!1;return this.traverseEntity(r=>{r.uuid===e&&(i=!0)}),i}toObjectTransformState(e=[]){return this.updateWorldMatrix(!0,!1),B8({position:this.position.toArray(),rotation:[this.rotation.x*qt.RAD2DEG,this.rotation.y*qt.RAD2DEG,this.rotation.z*qt.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray(),pivot:[0,0,0],pivotRotation:[0,0,0]},e)}getTransformValues(e,i,r){return i[e].map((s,n)=>r?.shared.getVariable(s,[this.uuid,e,TY[n]])??s)}updateTransformState(e,i){let r=!1;if(e.position&&(this.position.fromArray(this.getTransformValues("position",e,i)),r=!0),e.rotation&&(a_.fromArray(this.getTransformValues("rotation",e,i)).multiplyScalar(qt.DEG2RAD),this.rotation.setFromVector3(a_),r=!0),e.scale&&(this.scale.fromArray(this.getTransformValues("scale",e,i)),r=!0),e.hiddenMatrix!==void 0&&(r=!0,this.hiddenMatrix.fromArray(e.hiddenMatrix??lv.identity)),e.pivot!==void 0||e.pivotRotation!==void 0){if(r=!0,e.pivot!==void 0&&e.pivotRotation!==void 0)this.pivotMatrix.compose(a_.fromArray(e.pivot).negate(),TM.setFromEuler(SO.fromArray(e.pivotRotation.map(s=>s*qt.DEG2RAD))).invert(),wO);else if(e.pivot!==void 0)this.pivotMatrix.setPosition(-e.pivot[0],-e.pivot[1],-e.pivot[2]);else if(e.pivotRotation!==void 0){let s=a_.setFromMatrixPosition(this.pivotMatrix);TM.setFromEuler(SO.fromArray(e.pivotRotation.map(n=>n*qt.DEG2RAD))).invert(),this.pivotMatrix.compose(s,TM,wO)}}return r&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(s=>{s.invalidateClonerTransform(this)})),e.position&&e.rotation&&e.scale&&e.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),r}onVariableUpdate(e=!1){e?this.resetBBoxNeedsUpdate():(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(i=>{i.invalidateClonerTransform(this)}),this.requestRender())}dispose(){this.disposed=!0,this.cloner&&(this.cloner.dispose(),this.cloner=void 0)}disposeChildrenRecursively(){for(let e of this.children)Mi.is(e)&&e.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(e=>{Mi.is(e)&&e.disposeRecursively()})}toState(e=[]){return B8({name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(e)},e)}updateByObjUpdateOp(e,i){e!==void 0&&this.updateByOp({type:0,props:e,path:[]},{...this.data,...e},i,!1)}updateByOp(e,i,r,s){let n=this.data;this.data=i;let a=e,o=er(e.path,["states","*"]);if(o!==null){if(e.type===0){let[l]=o;if(this?.stateSelection===l){let u={...e.props};if(delete u.name,Object.values(e.props).some(h=>h===void 0)){let h=this.data;if(h!==void 0){let d=Dn.zoom(h,e.path.slice(2));if(d)for(let c in e.props)e.props[c]===void 0&&c in d&&(u[c]=d[c])}}a={...e,props:u,path:e.path.slice(2)}}}}else if(e.type===0){let l=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(l!==void 0){if(e.props.name!==void 0&&l.name){let{name:h,...d}=l;l=d}if(e.props.material!==void 0&&"material"in l){let{material:h,...d}=l;l=d}let u=Dn.removeOverridden(e.path,e.props,l);a={...e,props:u}}}if(this.updateByPatchedOpBase(a,em.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),r),er(e.path,["overrides"])){let l=[],u=[...e.path];for(l.push(u[1]),u.splice(0,2);u.length>0&&u[0]==="descendants";)l.push(u[1]),u.splice(0,2);if(l[l.length-1]===void 0){if(e.type===0)for(let h of Object.keys(e.props)){l[l.length-1]=h;let d=r.scene.findInstance([this.uuid,...l]);d&&(d.overrideData=e.props[h],d.updateState(lm.apply(d.component.data,d.overrideData),r))}}else{let h=r.scene.findInstance([this.uuid,...l]);if(h){let d=Dn.zoom(h.component.data,u);if((e={...e,path:u}).type===0){let c=e.props;if(d)for(let[p,m]of Object.entries(e.props))m===void 0&&(c===e.props&&(c={...e.props}),c[p]=d[p]);e={...e,props:c}}h.overrideData=mR.resolve(i.overrides,l),h.updateByOp(e,ea.applySimple(h.data,e),r,!1)}}}else if(this.instances.length>0){let l;if(e.path.length===0&&e.type===0){let u;for(let h of yc.rootOverrideProps)h in e.props&&(u===void 0&&(u={}),u[h]=e.props[h]);u&&(l={...e,props:u})}else for(let u of yc.rootOverrideProps)if(er(e.path,[u])){l=e;break}l!==void 0&&this.instances.forEach(u=>{if(u.isInstanceRoot){let h=lm.filterOp(u.overrideData,l);h&&u.updateByOp(h,ea.applySimple(u.data,h),r,!0)}}),this.instances.forEach(u=>{if(!u.isInstanceRoot){let h=lm.filterOp(u.overrideData,e);if(h){let d;d=n===u.data&&e===h?i:ea.applySimple(u.data,h),u.updateByOp(h,d,r,!0)}}})}}updateByPatchedOpBase(e,i,r){if(this.dataPatched=i,e.path.length===0&&e.type===0)e.props.type!==void 0&&!Zg.is(e.props.type)&&bc.changeEntityProptotype(this,i,r);else if(e.path.length===1&&e.path[0]==="geometry"&&e.type===0&&"type"in e.props){bc.changeEntityProptotype(this,i,r);for(let s of this.children)Mi.is(s)&&s.updateVisible(r.scene)}this.updateByPatchedOp(e,i,r)}updateByPatchedOp(e,i,r){if(e.path.length===0&&e.type===0?this.updateState(e.props,r):e.type===0&&("resolutionLevel"in e.props||"useChildrenColors"in e.props)&&this.updateState(i,r),e.path[0]==="morphTargetInfluences"&&e.type===0){let s=i.morphTargetInfluences.get(e.path[1])?.data.name;s&&this.updateMorphInfluences(s,r.shared.getVariable(e.props.value,[this.uuid,"morphTargetInfluences",s]))}if(er(e.path,["pathSnapping"])!==null&&this.updatePathSnapping(i.pathSnapping),er(e.path,["cloner"])!==null){let s=ea.drop(e,1);s.path.length===0&&s.type===0&&s.props.disabled===!0?this.setFromClonerState(null,r):this.cloner?this.cloner.updateState(i.cloner,r):(this.setFromClonerState(i.cloner,r),this.expandCloner(r)),this.updateVisible(r.scene)}}updatePathSnapping(e=this.dataPatched.pathSnapping){this._updatedPathSnapping=e,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(e){if(this._needApplyPathSnapping===!1)return;let i=this._updatedPathSnapping?.pathId??this.dataPatched.pathSnapping.pathId,r=this._updatedPathSnapping?.slide??this.dataPatched.pathSnapping.slide??0,s=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset??0,n=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(i===null)return;let a=e.find(i);if(!a)return;this._needApplyPathSnapping=!1;let o=a.data;if(o.geometry.path.points.length<=1)return;let l=sft(o.geometry.path),u=function(p){let m=p%1;return m<0?m+1:m===0&&p>0?1:m}(r+s),h=null;try{h=l.curves.length?l.getPointAt(u):null}catch{}if(h===null)return;a.updateMatrixWorld();let d=this.parent?TO.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix):TO.copy(this.hiddenMatrix),c=function(p,m,f,g){CU.setFromRotationMatrix(A1.extractRotation(g));let y=p.clone().applyMatrix4(A1.copy(g).invert().multiply(f));if(m===null)IP.setFromRotationMatrix(A1.extractRotation(f));else{let v=m.clone().applyMatrix4(A1.extractRotation(f));IP.setFromRotationMatrix(A1.lookAt(oft.set(0,0,0),v,lft))}return{position:y,rotation:new P().setFromEuler(aft.setFromQuaternion(CU.invert().multiply(IP))).multiplyScalar(qt.RAD2DEG)}}(h,n==="tangential"?l.getTangentAt(u):null,a.matrixWorld,d);this.updateTransformState({position:c.position.toArray(),rotation:c.rotation.toArray()}),this.traverseEntity(p=>{p._cameraType&&p.dispatchEvent(SY)})}updateVisible(e){if(this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0),!e)return;let i=!1;this.traverseEntity(r=>{if(r.data.type==="Splat")return i=!0,!0}),i&&e.reloadSplats()}updateState_Entity(e,i){e.name!==void 0&&(this.name=e.name),e.raycastLock!==void 0&&(this.raycastLock=e.raycastLock),e.visible!==void 0&&(this.updateVisible(i?.scene),this.resetBBoxNeedsUpdate()),i&&"cloner"in e&&e.cloner!==void 0&&(this.setFromClonerState(e.cloner,i),this.updateVisible(i.scene)),this.updateTransformState(e,i)}get attachedSurfaceCloners(){return this.children.filter(e=>H1(e)&&e.parameters.type==="toObject")}setFromClonerState(e,i){if(!this.disposed)if(e===null||e.disabled)this.cloner&&this.cloner.dispose(),this.cloner=void 0;else if(this.cloner===void 0){if(bc.Cloner===null)return void Nn("cloners","a cloner");this.cloner=new bc.Cloner(this,e),i.scene.addPendingExpandCloner(this)}else this.cloner.updateState(e,i)}expandCloner(e){!this.disposed&&this.cloner&&this.cloner.expandClones(e)}invalidateClonerTransform(e){this.cloner&&this.cloner.invalidateTransform(e)}requestRender(){this.dispatchEvent({type:"requestRender"})}}}),s0=G(()=>{dt(),vo(),(EU||(EU={})).is=t=>"objectHelper"in t,r0=(t,e)=>class extends B5(t){constructor(){super(...arguments),this.objectHelper=new e(this),this.gizmos={}}get geometryHelper(){return e.geometryHelper}raycast(i,r){this.objectHelper.raycast(i,r)}showGizmos(){for(let i in this.gizmos){let r=this.gizmos[i];r instanceof SS&&(r.visible=!0)}}updateEntityBoxSize(i,r){this.objectHelper.visible&&this.geometryHelper instanceof Zh?(i.setScalar(0),r.set(this.geometryHelper.parameters.width,this.geometryHelper.parameters.height,this.geometryHelper.parameters.height).multiplyScalar(.5)):super.updateEntityBoxSize(i,r)}hideGizmos(){for(let i in this.gizmos){let r=this.gizmos[i];r instanceof SS&&(r.visible=!1)}}}}),V5=G(()=>{dt(),D5(),s0(),zu=class extends r0(Hv,Ov){constructor(t,e){super(),this.super_Entity(t,e),this.objectHelper.update(),this.data.type==="Empty"&&(this.objectHelper.visible=!1)}updateState(t,e){this.updateState_Entity(t,e),"buffer"in t&&Object.keys(t).length===1&&e.scene.reloadSplats()}}});function hh(t,e,i,r,s,n,a){Yw.set(s,n,a).unproject(r);let o=e[t];if(o!==void 0){let l=i.getAttribute("position");for(let u=0,h=o.length;u<h;u++)l.setXYZ(o[u],Yw.x,Yw.y,Yw.z)}}var Yw,Xo,MY,uft,XMt=G(()=>{dt(),ZS(),QS(),Yw=new P,Xo=new vg,MY=class extends b1{constructor(t){let e=new ye,i=new zh({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],s=[],n={},a=new ae(15711266),o=new ae(15711266),l=new ae(2857471);function u(d,c,p){h(d,p),h(c,p)}function h(d,c){r.push(0,0,0),s.push(c.r,c.g,c.b),n[d]===void 0&&(n[d]=[]),n[d].push(r.length/3-1)}u("n1","n2",a),u("n2","n4",a),u("n4","n3",a),u("n3","n1",a),u("f1","f2",a),u("f2","f4",a),u("f4","f3",a),u("f3","f1",a),u("n1","f1",a),u("n2","f2",a),u("n3","f3",a),u("n4","f4",a),u("p","n1",o),u("p","n2",o),u("p","n3",o),u("p","n4",o),u("u1","u2",l),u("u2","u3",l),u("u3","u1",l),e.setAttribute("position",new fe(r,3)),e.setAttribute("color",new fe(s,3)),super(e,i),this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=n,this.update()}update(){let t=this.geometry,e=this.pointMap;Xo.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let i=.8;hh("n1",e,t,Xo,-1,-1,i),hh("n2",e,t,Xo,1,-1,i),hh("n3",e,t,Xo,-1,1,i),hh("n4",e,t,Xo,1,1,i);let r=i;hh("f1",e,t,Xo,-1,-1,r),hh("f2",e,t,Xo,1,-1,r),hh("f3",e,t,Xo,-1,1,r),hh("f4",e,t,Xo,1,1,r);let s=r;hh("u1",e,t,Xo,.35,1.1,s),hh("u2",e,t,Xo,-.35,1.1,s),hh("u3",e,t,Xo,0,1.55,s),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}},uft=class extends $v(MY){constructor(t){super(t),this.object=t,this.name=`CombinedCameraHelper: ${t.uuid}`}updateMatrixWorld(t){super.updateMatrixWorld(t),this.updateTarget()}updateTarget(){let t=this.object.getTarget();this.updateWorldMatrix(!0,!1),this.worldToLocal(t)}raycast(t,e){Xv(this.object,this.geometry,t,e,!0)}}});function AY(t){return 1-Math.pow(1-t,3)}var Jm,MM,AM,CM,k0,EM,uu,ln,Qh=G(()=>{dt(),XMt(),ke(),s0(),ir(),Jm=new P,MM=new P,AM=new Me,CM=new P,k0=new P,EM=new P,uu=class extends r0(vg,uft){constructor(t="",e={...G2.defaultData,name:""}){super(),this._cameraType="OrthographicCamera",this.targetOffset=gc.DefaultTargetOffset,this.isUpVectorFlipped=!1,this.angleOffsetFromUp=0,this.wasMovedByUser=!1,this.wasMovedBySwitchCameraAction=!1,this._createdAt=typeof performance<"u"?performance.now():0,this._tickProjectionTransition=()=>{let s=this._projectionTransition;if(s===void 0)return;if(this.disposed)return void this._endProjectionTransition();s.raf=requestAnimationFrame(this._tickProjectionTransition);let n=uu.projectionTransitionRequestRender??s.requestRender;this.updateProjectionMatrix(),n?.()},this.super_Entity(t,e),this.previousProjectionMatrix=new bt,this.matrixAutoUpdate=!0,this.width=window.innerWidth,this.height=window.innerHeight;let i=this.width,r=this.height;this.orthoCamera=new Rv(-.5*i,.5*i,.5*r,-.5*r,-5e4,1e4),this.perspCamera=new kh(45,i/r,50,1e4),this.left=this.orthoCamera.left,this.right=this.orthoCamera.right,this.top=this.orthoCamera.top,this.bottom=this.orthoCamera.bottom,this.far=this.orthoCamera.far,this.view=this.orthoCamera.view,this.aspect=this.perspCamera.aspect,this.focus=this.perspCamera.focus,this.filmGauge=this.perspCamera.filmGauge,this.filmOffset=this.perspCamera.filmOffset,this.objectHelper.update()}static withoutProjectionTransition(t){let e=uu.projectionTransitionsEnabled;uu.projectionTransitionsEnabled=!1;try{return t()}finally{uu.projectionTransitionsEnabled=e}}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}set fov(t){this.perspCamera.fov=t}get fov(){return this.perspCamera.fov}setNear(t,e){t==="PerspectiveCamera"?this.perspCamera.near=e:this.orthoCamera.near=e}setZoom(t,e){e>=0&&(t==="PerspectiveCamera"?this.perspCamera.zoom=e:this.orthoCamera.zoom=e)}set cameraType(t){t==="PerspectiveCamera"?this.toPerspective():t==="OrthographicCamera"&&this.toOrthographic()}get near(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.near:this.orthoCamera.near}set near(t){this._cameraType==="PerspectiveCamera"?this.perspCamera.near=t:this.orthoCamera.near=t}get zoom(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(t){t>=0&&(this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom=t:this.orthoCamera.zoom=t)}lookAt(t,e,i){typeof t=="number"&&(t=new P(t,e,i)),super.lookAt(t),this.getWorldPosition(Jm),this.targetOffset=Jm.distanceTo(t)}getTarget(t=new P){return this.getWorldDirection(MM),this.getWorldPosition(Jm),MM.multiplyScalar(this.targetOffset),t.copy(Jm).add(MM),t}getDistanceToTarget(){let t=this.getTarget();return this.getWorldPosition(Jm),Jm.distanceTo(t)}updateUp(){this.getWorldQuaternion(AM),CM.set(0,0,1).applyQuaternion(AM),k0.copy(dr.DEFAULT_UP),this.isUpVectorFlipped&&k0.negate(),k0.applyQuaternion(AM),EM.copy(dr.DEFAULT_UP).projectOnPlane(CM),this.angleOffsetFromUp=EM.angleTo(k0),this.angleOffsetFromUp*=EM.cross(k0).dot(CM)>=0?1:-1}updateTransformState(t,e){let i=super.updateTransformState(t,e);return t.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=t.isUpVectorFlipped),this.updateUp(),i}getViewFrontToObject(t){let e=t.getWorldPosition(new P),i=t.getWorldDirection(new P).multiplyScalar(this.targetOffset);return{position:e.clone().add(i),target:e}}getViewToTarget(t){let e=this.getWorldDirection(new P).multiplyScalar(this.targetOffset);return{position:t.clone().sub(e),target:t}}getViewToObject(t){let e=new P;return t.getWorldPosition(e),this.getViewToTarget(e)}setViewplaneSize(t,e,i=!1){if(this.aspect=t/e,i){let r=t>e?this.aspect:1,s=t>e?1:this.aspect;this.left=-395*r,this.right=395*r,this.top=1/s*395,this.bottom=1/s*-395}else this.left=.5*-t,this.right=.5*t,this.top=.5*e,this.bottom=.5*-e;this.updateProjectionMatrix()}copyViewPlaneSize(t){this.aspect=t.aspect,this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.updateProjectionMatrix()}toOrthographic(){this.orthoCamera.left=this.left,this.orthoCamera.right=this.right,this.orthoCamera.top=this.top,this.orthoCamera.bottom=this.bottom,this.orthoCamera.view=this.view,this.orthoCamera.far=this.far,this.orthoCamera.updateProjectionMatrix(),this.projectionMatrix=this.orthoCamera.projectionMatrix,this.projectionMatrixInverse=this.orthoCamera.projectionMatrixInverse,this._cameraType="OrthographicCamera",this._applyProjectionTransition(),this.objectHelper&&this.objectHelper.update()}toPerspective(){this.perspCamera.aspect=this.aspect,this.perspCamera.fov=this.fov,this.perspCamera.view=this.view,this.perspCamera.far=this.far,this.perspCamera.updateProjectionMatrix(),this.projectionMatrix=this.perspCamera.projectionMatrix,this.projectionMatrixInverse=this.perspCamera.projectionMatrixInverse,this._cameraType="PerspectiveCamera",this._applyProjectionTransition(),this.objectHelper&&this.objectHelper.update()}get isProjectionTransitioning(){return this._projectionTransition!==void 0}get projectionTransitionProgress(){let t=this._projectionTransition;if(t===void 0)return 1;let e=(performance.now()-t.start)/t.duration;return e>=1?1:e<=0?0:AY(e)}get _activeSubCamera(){return this._cameraType==="PerspectiveCamera"?this.perspCamera:this.orthoCamera}_canAnimateProjection(){return uu.projectionTransitionsEnabled&&typeof requestAnimationFrame=="function"&&typeof performance<"u"&&performance.now()-this._createdAt>=uu.projectionTransitionMinAgeMs}_beginProjectionTransition(t){let e=this._projectionTransition;e===void 0&&(e={from:new bt,blend:new bt,blendInverse:new bt,start:0,duration:uu.projectionTransitionDuration,referenceDepth:1,raf:0,requestRender:t},this._projectionTransition=e),e.from.copy(this.projectionMatrix),e.start=performance.now(),e.duration=uu.projectionTransitionDuration,e.referenceDepth=Number.isFinite(this.targetOffset)?Math.max(1,this.targetOffset):1,t&&(e.requestRender=t),e.raf!==0&&cancelAnimationFrame(e.raf),e.raf=requestAnimationFrame(this._tickProjectionTransition)}_applyProjectionTransition(){let t=this._projectionTransition;if(t===void 0)return;let e=(performance.now()-t.start)/t.duration;if(e>=1)return void this._endProjectionTransition();let i=AY(e),r=t.from.elements,s=this._activeSubCamera.projectionMatrix.elements,n=t.blend.elements,a=t.referenceDepth,o=Math.max(1e-6,r[15]-r[11]*a),l=i*o/(i*o+(1-i)*Math.max(1e-6,s[15]-s[11]*a));for(let u=0;u<16;u++)n[u]=r[u]+(s[u]-r[u])*l;t.blendInverse.copy(t.blend).invert(),this.projectionMatrix=t.blend,this.projectionMatrixInverse=t.blendInverse}_endProjectionTransition(){let t=this._projectionTransition;if(t===void 0)return;t.raf!==0&&cancelAnimationFrame(t.raf),this._projectionTransition=void 0;let e=this._activeSubCamera;this.projectionMatrix=e.projectionMatrix,this.projectionMatrixInverse=e.projectionMatrixInverse}_syncProjectionTransition(t){let e=t._projectionTransition;if(e===void 0)return void(this._projectionTransition!==void 0&&this._endProjectionTransition());let i=this._projectionTransition;i===void 0?(i={from:new bt,blend:new bt,blendInverse:new bt,start:0,duration:1,referenceDepth:1,raf:0,requestRender:void 0},this._projectionTransition=i):i.raf!==0&&(cancelAnimationFrame(i.raf),i.raf=0),i.requestRender=void 0,i.from.copy(e.from),i.start=e.start,i.duration=e.duration,i.referenceDepth=e.referenceDepth,this._applyProjectionTransition()}setFocalLength(t){this.perspCamera.setFocalLength(t),this.toPerspective()}getFocalLength(){return this.perspCamera.getFocalLength()}getEffectiveFOV(){return this.perspCamera.getEffectiveFOV()}getFilmWidth(){return this.perspCamera.getFilmWidth()}getFilmHeight(){return this.perspCamera.getFilmHeight()}setViewOffset(t,e,i,r,s,n){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(t,e,i,r,s,n):this.orthoCamera.setViewOffset(t,e,i,r,s,n),this._applyProjectionTransition()}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}copyHistory(){this.previousProjectionMatrix&&this.previousProjectionMatrix.copy(this.projectionMatrix)}updateProjectionMatrix(){this._cameraType==="PerspectiveCamera"?this.toPerspective():this._cameraType==="OrthographicCamera"&&this.toOrthographic()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(t,e){return super.copy(t,e),this.parent=t.parent,this.orthoCamera.copy(t.orthoCamera),this.perspCamera.copy(t.perspCamera),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.far=t.far,this.view=t.view===null?null:Object.assign({},t.view),this._cameraType=t._cameraType,this.aspect=t.aspect,this.fov=t.fov,this.focus=t.focus,this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this.targetOffset=gc.sanitizeTargetOffset(t.targetOffset),this.updateProjectionMatrix(),this._syncProjectionTransition(t),this}toCameraState(t=[]){return B8({type:this.cameraType,far:this.far,orthographic:{near:this.orthoCamera.near,zoom:this.orthoCamera.zoom},perspective:{near:this.perspCamera.near,fov:this.perspCamera.fov,zoom:this.perspCamera.zoom},up:this.up.toArray(),targetOffset:this.targetOffset,isUpVectorFlipped:this.isUpVectorFlipped},t)}updateCameraSubtype(t,e){let i=t==="perspective"?"PerspectiveCamera":"OrthographicCamera";e.zoom!==void 0&&this.setZoom(i,e.zoom),e.near!==void 0&&this.setNear(i,e.near),e.fov!==void 0&&i==="PerspectiveCamera"&&(this.fov=e.fov)}updateState(t,e){this.updateCameraState(t,e)}updateCameraState(t,e){this.updateState_Entity(t,e),t.far!==void 0&&(this.far=t.far),t.orthographic!==void 0&&this.updateCameraSubtype("orthographic",t.orthographic),t.perspective!==void 0&&this.updateCameraSubtype("perspective",t.perspective),t.type!==void 0&&(t.type!==this._cameraType&&this._canAnimateProjection()&&this._beginProjectionTransition(e?.shared.requestRender),this.cameraType=t.type),t.up!==void 0&&this.up.fromArray(t.up.map(i=>typeof i=="number"?i:0)),t.targetOffset!==void 0&&(this.targetOffset=gc.sanitizeTargetOffset(t.targetOffset)),t.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=t.isUpVectorFlipped),this.updateProjectionMatrix()}updateByPatchedOp(t,e,i){super.updateByPatchedOp(t,e,i),t.path.length===1&&t.type===0&&this.updateCameraSubtype(t.path[0],t.props)}toState(t){return{...super.toState(t),...this.toCameraState(t),type:this.cameraType}}},(ln=uu).projectionTransitionsEnabled=!1,ln.projectionTransitionDuration=350,ln.projectionTransitionMinAgeMs=1e3});function dft(t){return t.type==="TorusGeometry"&&t.arc===360}var cft,PM,PU,NS=G(()=>{dt(),cft=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},t.parameters),r=Math.abs(i.width),s=Math.abs(i.height??r),n=Math.abs(i.depth??r),a=Math.abs(Math.min(r,n))/2;return{parameters:Object.assign(i,{width:r,height:s,depth:n,radius:a,segments:Math.round(i.segments),pathSegments:Math.round(i.pathSegments),cornerSegments:Math.round(i.cornerSegments)})}}static build(t){let{width:e,height:i,depth:r,radius:s,revolutions:n,segments:a,pathRadius:o,pathType:l,pathSegments:u,cornerRadius:h,cornerSegments:d}=t.parameters,c=new PU(!1,e,i,r,s,n,a,o,l,u,h,d);return Object.assign(c,{userData:{...t,type:"HelixGeometry"}})}},PM=new om([0,0,0],1),PU=class extends ye{constructor(t=!0,e=1,i=1,r=1,s=1,n=1,a=1,o=1,l=1,u=1,h=1,d=1){if(super(),n===0)return;let c=t&&n===1;c&&(d=0),h>100&&(h=100),h===0&&(d=0);let p,m,f,g,y,v,b,_,x=()=>new P,S=new P,w=x(),T=x(),A=x(),M=x(),C=x(),R=x(),O=x(),N=x(),B=x(),k=x(),z=x(),L=i-2*o+.001,V=L/n,q=Math.ceil(a*n),j=q+1,Q=L/q,it=-L/2,at=u+1,St=2*Math.PI/u,yt=Math.PI/2/d,Y=Math.min((1-h/100)*o,o-.01),pt=o-Y,xt=0,Tt=2*d+2,Mt=at*Tt/2,_t=Mt+at*j,kt=Math.max(0,at*(j+Tt)),[Ut,Lt,zt]=[3,3,2].map(Ve=>Array(kt*Ve).fill(0)),Bt=[],jt=s-o;function Xt(Ve,ie){let oi=Math.PI/2;v=ie*Q,_=2*Math.PI*(v%V)/V+oi,v+=it,b=Math.sin(_)*jt,y=Math.cos(_)*jt,t?Ve.set(y,b,v):Ve.set(y,v,b)}Xt(S,-1e-10),Xt(w,0),M.copy(S),Xt(S,1);let Dt=S.distanceTo(w),le=c?0:pt+Y,Wt=Dt*q+2*le,Qt=Y,ee=Wt-le;for(let Ve=0;Ve<=q;Ve++){Xt(T,Ve),z.subVectors(T,M).normalize(),M.copy(T),B.copy(T).setComponent(+t+1,0).normalize(),k.crossVectors(z,B).normalize();let ie=Ve===0,oi=Ve===q,xi=ie?3*Math.PI/2:yt,Ys=ie?Qt:ee,Hi=ie?at:_t,li=ie?0:kt-at,Ur=z.clone().multiplyScalar(ie?-pt:pt).add(T),Jr=z.clone().multiplyScalar(ie?-1:1).normalize();for(let jr=0;jr<at;jr++){let Ui=jr*St;if(C.addVectors(S.copy(B).multiplyScalar(o*Math.cos(Ui)),w.copy(k).multiplyScalar(o*Math.sin(Ui))),R.copy(C).normalize(),ie||oi){c||(xt=li+jr,[0,1,2].forEach(Ci=>{Ut[3*xt+Ci]=Ur.getComponent(Ci),Lt[3*xt+Ci]=Jr.getComponent(Ci)}),zt[2*xt]=+oi,zt[2*xt+1]=jr/u),w.copy(R).multiplyScalar(Y),A.addVectors(T,w);for(let Ci=0;Ci<d;Ci++){let Ks=Ci*yt+xi;O.addVectors(S.copy(z).multiplyScalar(pt*Math.sin(Ks)),w.copy(R).multiplyScalar(pt*Math.cos(Ks))),N.copy(O).normalize(),w.addVectors(A,O),O.normalize(),xt=Hi+Ci*at+jr,[0,1,2].forEach(br=>{Ut[3*xt+br]=w.getComponent(br),Lt[3*xt+br]=N.getComponent(br)});let ps=+ie+Math.sin(Ks);zt[2*xt]=(Ys+pt*ps)/Wt,zt[2*xt+1]=jr/u}}w.addVectors(T,C),xt=Mt+Ve*at+jr,[0,1,2].forEach(Ci=>{Ut[3*xt+Ci]=w.getComponent(Ci),Lt[3*xt+Ci]=R.getComponent(Ci)}),zt[2*xt]=(le+Ve*Dt)/Wt,zt[2*xt+1]=jr/u}}let $=j+2*d+2,[se,Pe]=[+c,$-1];for(let Ve=se;Ve<=Pe-1;Ve++){let ie=c&&Ve===Pe-1;for(let oi=0;oi<at-1;oi++)p=Ve*at+oi,m=p+1,f=(ie?oi:p)+at,g=(ie?oi+1:m)+at,Ve===0?Bt.push(m,g,f):Ve===$-2?Bt.push(p,m,f):Bt.push(p,m,f,m,g,f)}this.setIndex(Bt),this.setAttribute("position",new fe(Ut,3)),this.setAttribute("normal",new fe(Lt,3)),this.setAttribute("uv",new fe(zt,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let t,e,i,r,s=this.userData.parameters,n=Math.ceil(s.tubularSegments),a=s.radialSegments,o=a+1,l=[];for(let u=1;u<n;u++)for(let h=0;h<a;h++)t=u*o+h,e=t+1,i=t+o,r=e+o,l.push(t,e,i,e,r,i);for(let u=0;u<a;u++)t=n*o+u,e=t+1,i=u+o,r=u+1+o,l.push(t,e,i,e,r,i);return PM.array=new Uint32Array(l),PM.count=l.length,PM}}});function YMt(t){return EY||(EY=async function(){let e=t??"https://cdn.spline.design/@splinetool/runtime@2.0.61/build",i=import("./boolean.js"),[r,s]=await Promise.all([i,fetch(`${e}/boolean.wasm`).then(n=>n.arrayBuffer())]);await r.default({module_or_path:s}),OS=r}())}function wR(){if(OS===void 0)throw new Error("boolean-wasm is not loaded");return OS}function yG(t){let e=IS.get(t);if(e===void 0)throw new Error("Unknown csg mesh set handle "+t);return e}function vG(t){return IS.set(++RU,t),RU}function KMt(t,e,i){if(OS===void 0)return-1;let{positions:r,indices:s,normals:n}=function(a,o){if(o&&a.userData.positions!==void 0){let p=a.userData,m=[];for(let f=0,g=0;f<p.verticesPerFace.length;f++){let y=p.verticesPerFace[f];for(let v=1;v<y-1;v++)m.push(p.indices[g],p.indices[g+v],p.indices[g+v+1]);g+=y}return{positions:p.positions instanceof Float32Array?p.positions:new Float32Array(p.positions),indices:new Uint32Array(m)}}let l;l=dft(a.userData.parameters)?a.getClosedTorusIndicesForBooleanOrSubdiv():a.getIndex();let u,h=a.getAttribute("position");if(l===null){u=new Uint32Array(h.count);for(let p=0;p<u.length;p++)u[p]=p}else u=l.array instanceof Uint32Array?l.array:new Uint32Array(l.array);let d=a.getAttribute("normal"),c=d!==void 0&&d.itemSize===3&&d.count===h.count&&d.array instanceof Float32Array&&d.isInterleavedBufferAttribute!==!0?d.array:void 0;return{positions:h.array,indices:u,normals:c}}(t,e);return vG(new OS.CsgMesh(r,s,n))}function CY(t,e){let i=wR(),r=mft[e];if(r===void 0)throw new Error("Unknown boolean operation "+e);let s=t.map(yG);if(s.length===1)return i.clone_mesh(s[0]);let n,a=[];if(e===2&&s.length>2){let o=s[0];for(let l=1;l<s.length-1;l++)o=i.boolean_mesh(o,s[l],0),a.push(o);n=i.boolean_mesh(s[s.length-1],o,2)}else if(e===2)n=i.boolean_mesh(s[1],s[0],2);else{let o=s[s.length-1];for(let l=0;l<s.length-1&&(o=i.boolean_mesh(o,s[l],r),a.push(o),o.tri_count()!==0);l++);n=o,a.pop()}for(let o of a)o.free();return n}function MO(t,e){yG(t).transform(new Float32Array(e.elements))}function pft(t){let e=IS.get(t);e!==void 0&&(e.free(),IS.delete(t))}var OS,IS,RU,EY,mft,k5=G(()=>{dt(),NS(),IS=new Map,RU=0,mft={0:0,1:1,2:2}});function tf(t){return t!==null&&"booleanOp"in t}var DU,fft,ZMt=G(()=>{dt(),vo(),k5(),DU=class extends B5(Sr){constructor(){super(...arguments),this.booleanMeshSetAddress=-1,this.booleanWasTransformed=!1,this.booleanMatrixInvOld=new bt}updateVisible(t){super.updateVisible(t),this.visible=!tf(this.parent)&&this.visible,tf(this.parent)&&this.parent.invalidateDownstreamBooleanData()}onClonerLayoutUpdated(){tf(this.parent)&&this.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(pft(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(t=!1){return t?this.booleanWasTransformed=!0:this.freeBooleanPointer(),tf(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let t of this.children)t instanceof DU&&(t.freeBooleanPointer(),tf(t)&&t.invalidateUpstreamBooleanData())}updateTransformState(t,e){let i=super.updateTransformState(t,e);return i&&tf(this.parent)&&this.invalidateDownstreamBooleanData(!0),i}onVariableUpdate(t=!1){super.onVariableUpdate(t),tf(this.parent)&&this.invalidateDownstreamBooleanData(!0)}}}),QMt=G(()=>{fft=null});function bG(t,e=0,i=t.count,r,s){let n=1/0,a=1/0,o=1/0,l=-1/0,u=-1/0,h=-1/0;for(let d=e;d<i;d++){let c=t.getX(d),p=t.getY(d),m=t.getZ(d);c<n&&(n=c),p<a&&(a=p),m<o&&(o=m),c>l&&(l=c),p>u&&(u=p),m>h&&(h=m)}Kw.min.set(n,a,o),Kw.max.set(l,u,h),Kw.getCenter(r),Kw.getSize(s).multiplyScalar(.5)}var Kw,PY,RY,Bs,la=G(()=>{dt(),ZMt(),QMt(),Kw=new pr,PY=new ye,RY=new Uo,Bs=class extends DU{constructor(t,e){super(PY,RY),this.super_Entity(t,e)}updateState(t,e){this.updateState_Entity(t,e)}raycast(t,e){let i=fft;i===null?super.raycast(t,e):i(this,t,e)}updateEntityBoxSize(t,e){let i=this.geometry.getAttribute("position");i!==void 0?bG(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,t,e):super.updateEntityBoxSize(t,e)}}});function SR(t){return t?.isClassicNodeMaterial===!0}var Dr,NU,gft,yft,$2,vft,bft,_ft,_G=G(()=>{}),Rc=G(()=>{dt(),Dr=class extends ae{constructor(t,e,i,r){super(t,e,i),this.isColorA=!0,this.a=r}setRGBA(t,e,i,r){super.setRGB(t,e,i),this.a=r}copy(t){return super.copy(t),this.a="a"in t?t.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}equals(t){return super.equals(t)&&this.a===t.a}setStyle(t,e="srgb"){let i;if(t==="transparent")return this.setRGBA(0,0,0,0),this;if(i=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(t)){let r,s=i[1],n=i[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(n))return this.a=s==="rgba"?parseFloat(r[4]):1,super.setStyle(t,e);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(n))return this.a=s==="hsla"?parseFloat(r[4]):1,super.setStyle(t,e)}}return super.setStyle(t,e)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(t){this.r=t}set y(t){this.g=t}set z(t){this.b=t}set w(t){this.a=t}}}),JMt=G(()=>{Rc(),NU=class extends Dr{}}),t3t=G(()=>{gft=class{constructor(t=1e4){this.timeout=t,this.cache=new Map,this.head={data:null,time:0,src:null,next:null,prev:null},this.tail={data:null,time:1/0,src:null,next:null,prev:null},this.hasClean=!1,this.cleanupTimer=null,this.head.next=this.tail,this.tail.prev=this.head}log(...t){}remove(t){let e=this.cache.get(t);e&&(this.dispose(t,e.data),this.cache.delete(t),e.prev.next=e.next,e.next.prev=e.prev,e.next=null,e.prev=null,e.data=null)}scheduleCleanup(){this.hasClean||(this.log("scheduled cleanup"),this.hasClean=!0,this.cleanupTimer=setTimeout(()=>{this.hasClean=!1,this.cleanupTimer=null,this.log("cleaning");let t=Date.now(),e=this.head.next;for(;e.time<t-this.timeout;){this.dispose(e.src,e.data),this.cache.delete(e.src);let i=e;e=e.next,e.prev=this.head,this.head.next=e,i.next=null,i.prev=null,i.data=null}this.head.next!==this.tail?this.scheduleCleanup():this.log("no more cleanup")},this.timeout+1e3))}has(t){return this.cache.get(t)?.data}load(t){let e=Date.now(),i=this.cache.get(t);return i===void 0?(i={data:this.create(t),src:t,time:e,next:null,prev:null},this.cache.set(t,i)):(i.time=e,i.prev.next=i.next,i.next.prev=i.prev),i.prev=this.tail.prev,i.next=this.tail,this.tail.prev.next=i,this.tail.prev=i,this.scheduleCleanup(),i.data}disposeAll(){this.cleanupTimer!==null&&(clearTimeout(this.cleanupTimer),this.cleanupTimer=null),this.hasClean=!1,this.cache.forEach((t,e)=>{this.dispose(e,t.data),t.next=null,t.prev=null,t.data=null}),this.cache.clear(),this.head.next=this.tail,this.tail.prev=this.head}destroy(){this.disposeAll(),this.head=null,this.tail=null}}}),xft=G(()=>{t3t(),yft=class extends gft{create(t){return URL.createObjectURL(new Blob([t]))}dispose(t,e){URL.revokeObjectURL(e)}}}),wft=G(()=>{vft=class{constructor(t,e){this.data=t,this.cache=e,this.refCount=0}deref(){this.refCount,this.refCount-=1,this.refCount===0&&(this.cache.remove(this),this.dispose())}dispose(){this.refCount}},bft=class{constructor(){this.cache=new Map}remove(t){this.cache.delete(t.data)}load(t){let e=this.cache.get(t);return e===void 0&&(e=this.create(t),this.cache.set(t,e)),e.refCount+=1,e}}}),e3t=G(()=>{dt(),_ft=class extends Vpt{constructor(t){super(t),this.type=ai}parse(t){let e=function(p,m){switch(p){case 1:throw new Error("THREE.HDRLoader: Read Error: "+(m||""));case 2:throw new Error("THREE.HDRLoader: Write Error: "+(m||""));case 3:throw new Error("THREE.HDRLoader: Bad File Format: "+(m||""));default:throw new Error("THREE.HDRLoader: Memory Error: "+(m||""))}},i=function(p,m,f){m=m||1024;let g=p.pos,y=-1,v=0,b="",_=String.fromCharCode.apply(null,new Uint16Array(p.subarray(g,g+128)));for(;0>(y=_.indexOf(`
|
|
348
348
|
`))&&v<m&&g<p.byteLength;)b+=_,v+=_.length,g+=128,_=String.fromCharCode.apply(null,new Uint16Array(p.subarray(g,g+128)));return-1<y&&(f!==!1&&(p.pos+=v+y+1),b+_.slice(0,y))},r=function(p,m,f,g){let y=p[m+3],v=Math.pow(2,y-128)/255;f[g+0]=p[m+0]*v,f[g+1]=p[m+1]*v,f[g+2]=p[m+2]*v,f[g+3]=1},s=function(p,m,f,g){let y=p[m+3],v=Math.pow(2,y-128)/255;f[g+0]=Kh.toHalfFloat(Math.min(p[m+0]*v,65504)),f[g+1]=Kh.toHalfFloat(Math.min(p[m+1]*v,65504)),f[g+2]=Kh.toHalfFloat(Math.min(p[m+2]*v,65504)),f[g+3]=Kh.toHalfFloat(1)},n=new Uint8Array(t);n.pos=0;let a,o,l,u=function(p){let m,f,g=/^#\?(\S+)/,y=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,v=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,b=/^\s*FORMAT=(\S+)\s*$/,_=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,x={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};for((p.pos>=p.byteLength||!(m=i(p)))&&e(1,"no header found"),(f=m.match(g))||e(3,"bad initial token"),x.valid|=1,x.programtype=f[1],x.string+=m+`
|
|
349
349
|
`;m=i(p),m!==!1;)if(x.string+=m+`
|
|
350
350
|
`,m.charAt(0)!=="#"){if((f=m.match(y))&&(x.gamma=parseFloat(f[1])),(f=m.match(v))&&(x.exposure=parseFloat(f[1])),(f=m.match(b))&&(x.valid|=2,x.format=f[1]),(f=m.match(_))&&(x.valid|=4,x.height=parseInt(f[1],10),x.width=parseInt(f[2],10)),2&x.valid&&4&x.valid)break}else x.comments+=m+`
|
|
351
|
-
`;return 2&x.valid||e(3,"missing format specifier"),4&x.valid||e(3,"missing image size specifier"),x}(n),h=u.width,d=u.height,c=function(p,m,f){let g=m;if(g<8||g>32767||p[0]!==2||p[1]!==2||128&p[2])return new Uint8Array(p);g!==(p[2]<<8|p[3])&&e(3,"wrong scanline width");let y=new Uint8Array(4*m*f);y.length||e(4,"unable to allocate buffer space");let v=0,b=0,_=4*g,x=new Uint8Array(4),S=new Uint8Array(_),w=f;for(;w>0&&b<p.byteLength;){b+4>p.byteLength&&e(1),x[0]=p[b++],x[1]=p[b++],x[2]=p[b++],x[3]=p[b++],(x[0]!=2||x[1]!=2||(x[2]<<8|x[3])!=g)&&e(3,"bad rgbe scanline format");let T,A=0;for(;A<_&&b<p.byteLength;){T=p[b++];let C=T>128;if(C&&(T-=128),(T===0||A+T>_)&&e(3,"bad scanline data"),C){let R=p[b++];for(let O=0;O<T;O++)S[A++]=R}else S.set(p.subarray(b,b+T),A),A+=T,b+=T}let M=g;for(let C=0;C<M;C++){let R=0;y[v]=S[C+R],R+=g,y[v+1]=S[C+R],R+=g,y[v+2]=S[C+R],R+=g,y[v+3]=S[C+R],v+=4}w--}return y}(n.subarray(n.pos),h,d);switch(this.type){case Qe:l=c.length/4;let p=new Float32Array(4*l);for(let f=0;f<l;f++)r(c,4*f,p,4*f);a=p,o=Qe;break;case ai:l=c.length/4;let m=new Uint16Array(4*l);for(let f=0;f<l;f++)s(c,4*f,m,4*f);a=m,o=ai;break;default:throw new Error("THREE.HDRLoader: Unsupported type: "+this.type)}return{width:h,height:d,data:a,header:u.string,gamma:u.gamma,exposure:u.exposure,type:o,colorSpace:Xu,minFilter:me,magFilter:me,generateMipmaps:!1,flipY:!0}}setDataType(t){return this.type=t,this}}});function DY(t){return t.length>2&&t[0]===35&&t[1]===63}function AO(t){return typeof t=="object"&&t!==null&&t.isSplineHdr===!0}function Sft(t){let e=new yr(t.data,t.width,t.height,an,ai);return e.flipY=!1,e.image.isSplineHdr=!0,e.needsUpdate=!0,e}var NY,xG,pg,Tft=G(()=>{dt(),e3t()}),Mft=G(()=>{dt(),xft(),wft(),Tft(),NY=0,xG=class extends vft{constructor(t,e){super(t,e.imageHolderCache),this.data=t,this.shared=e,this.instanceId=++NY,this.loaded=!1,this.isVideo=!1,this.isBuffer=!1,this.isHdr=!1,this._cache={1e3:{},1001:{},1002:{}},this.isVideo=t.type==="video",this.isBuffer=t.isWebGLRenderTarget===!0,this.loadPromise=this.updateSrc(this.isBuffer?t:t.data)}async updateSrc(t){if(typeof document>"u")return;this.disposeTextures(),this.loaded=!1,this.isHdr=!1;let e=()=>{this.loaded=!0;for(let r of Object.values(this._cache))for(let s of Object.values(r))for(let n of Object.values(s))n&&(n.image=this.img,n.needsUpdate=!0);this.shared.requestRender()};if(this.isBuffer)this.img=t,this.loaded=!0;else if(this.isVideo){if(this.img=document.createElement("video"),this.img.preload="auto",this.img.playsInline=!0,this.img.currentTime=.01,typeof t!="string"){let r,s=new FileReader;s.readAsDataURL(new Blob([t],{type:"video/mp4"})),await new Promise(n=>{s.onloadend=a=>{r=a.target?.result,n(null)}}),this.img.src=r}else this.img.src=t;this.img.onloadeddata=()=>{e()}}else if(t instanceof Uint8Array?DY(t):typeof t=="string"&&/\.hdr($|[?#])/i.test(t)){let r=t instanceof Uint8Array?t:null;if(r===null)try{r=new Uint8Array(await(await fetch(t)).arrayBuffer())}catch{r=null}let s=r!==null&&DY(r)?function(n){try{let a=new _ft().parse(n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength));if(!a||!a.width||!a.height)return null;let{width:o,height:l}=a,u=a.data,h=new Uint16Array(u.length),d=4*o,c=f=>Kh.toHalfFloat(Math.pow(Math.max(Kh.fromHalfFloat(f),0),1/2.2)),p=new Map,m=f=>{let g=p.get(f);return g===void 0&&(g=c(f),p.set(f,g)),g};for(let f=0;f<l;f++){let g=f*d,y=(l-1-f)*d;for(let v=0;v<d;v+=4)h[y+v]=m(u[g+v]),h[y+v+1]=m(u[g+v+1]),h[y+v+2]=m(u[g+v+2]),h[y+v+3]=u[g+v+3]}return{isSplineHdr:!0,data:h,width:o,height:l}}catch{return null}}(r):null;s!==null&&(this.isHdr=!0,this.img=s,e())}else this.img=new Image,this.img.src=typeof(i=t)=="string"?i:($2||($2=new yft),$2.load(i)),this.img.onload=e,await new Promise(r=>{this.img.onload=()=>{e(),r(null)}});var i}getTexture(t,e=1008,i=1006){let r=this._cache[t]?.[e]?.[i];if(r)return r;{let s;return this.isBuffer?s=this.img.texture:this.isVideo?s=new z7(this.img,void 0,t,t):this.isHdr?(s=Sft(this.img),s.wrapS=t,s.wrapT=t,s.magFilter=i,s.minFilter=e):s=new pi(this.img,void 0,t,t,i,e),this.isBuffer||(s.anisotropy=8,s.generateMipmaps=e===1008),this.loaded&&(s.needsUpdate=!0),this._cache[t]===void 0&&(this._cache[t]={}),this._cache[t][e]===void 0&&(this._cache[t][e]={}),this._cache[t][e][i]=s,s}}setNeedsUpdate(t){if(!this.isBuffer)for(let e of Object.values(this._cache))for(let i of Object.values(e))for(let r of Object.values(i))r&&(r.needsUpdate=t)}disposeTextures(){for(let[t,e]of Object.entries(this._cache))for(let[i,r]of Object.entries(e))for(let[s,n]of Object.entries(r))n?.dispose(),this._cache[t]!==void 0&&this._cache[t][i]!==void 0&&(this._cache[t][i][s]=void 0)}dispose(){super.dispose(),this.disposeTextures()}}}),Aft=G(()=>{Mft(),pg=class extends xG{}});function i3t(t){if(typeof t=="string")return t;let e=OU.get(t);return e||(e={url:URL.createObjectURL(new Blob([t]))},OU.set(t,e)),e.url}var OU,r3t=G(()=>{OU=new Map});function s3t(){if(!IU)return OY||(OY=async function(){await Promise.resolve().then(()=>(pq(),hxt)),Cft(window!==void 0?window:global),IU=!0}())}var Cft,Eft,IU,OY,Pft=G(()=>{Eft=new Promise(t=>{Cft=t}),IU=!1});function IY(t,e){t.forEach(i=>{"dragDropActions"in i.data?(e.push(...i.data.dragDropActions.drag),e.push(...i.data.dragDropActions.drop)):"inActions"in i.data?(e.push(...i.data.inActions),e.push(...i.data.outActions)):"gameActions"in i.data?(e.push(...i.data.gameActions.idle),e.push(...i.data.gameActions.move),e.push(...i.data.gameActions.jump),e.push(...i.data.gameActions.run)):"breakpoints"in i.data?i.data.breakpoints.forEach(r=>{e.push(...r.data.actions)}):"actions"in i.data&&(e.push(...i.data.actions),i.data.actions.forEach(r=>{r.data.type==="Conditional"&&r.data.ifActions&&(e.push(...r.data.ifActions),e.push(...r.data.elseActions))}))})}function n3t(t){let e=!1,i=[];return t.scene.objects.traverse((r,s)=>{if(s.type==="Page"&&s.uiScene!==void 0&&s.uiScene.objects.traverse((n,a)=>{if(a.events===void 0||Array.isArray(a.events)===!1)return!0;IY(a.events,i),e=e||i.some(o=>o.data.type==="Audio")}),s.events===void 0||Array.isArray(s.events)===!1)return!0;IY(s.events,i),e=e||i.some(n=>n.data.type==="Audio")}),e}var BY,$1,wG=G(()=>{r3t(),Pft(),Eft.then(t=>BY=t),$1=class{constructor({src:t,volume:e,delay:i,loop:r}){let s;this._volume=1,this.delay=0,this._loop=1,this.loopsRemaining=0,this._status="stopped",this.onEnd=()=>{this.loopsRemaining===1/0?this.replay():this.loopsRemaining>1?(this.replay(),this.loopsRemaining--):(this._status="stopped",this.loopsRemaining=this._loop)},s=typeof t=="string"?{src:t}:{src:i3t(t),format:"wav"},this.sound=new BY.Howl(s),this.sound.on("end",this.onEnd),this.src=t,e!==void 0&&(this.volume=e),i!==void 0&&(this.delay=i),r!==void 0&&(this.loop=r)}get status(){return this._status}get volume(){return this._volume}set volume(t){this._volume=t,this.sound.volume(t)}get loop(){return this._loop}set loop(t){this._loop=t,this.loopsRemaining=t}replay(){this.clearDelay(),this.delayTimerId=window.setTimeout(()=>{this.sound.play(),this.clearDelay()},this.delay)}fade(t,e=1e3){t?(this.sound.volume(this._volume),this.clearFade(),this.fadeTimerId=window.setTimeout(()=>{this.sound.fade(this._volume,0,e),this.clearFade()},t)):this.sound.fade(this._volume,0,e)}on(t,e,i){this.sound.on(t,e,i)}off(t,e,i){this.sound.off(t,e,i)}play(){this._status==="playing"||this.sound.playing()||(this._status==="paused"?(this.sound.seek()===0?this.replay():this.sound.play(),this._status="playing"):this._status==="stopped"&&(this.replay(),this._status="playing"))}pause(){this._status==="playing"&&(this.sound.pause(),this.clearFade(),this.clearDelay(),this._status="paused")}stop(){this.sound.stop(),this.loopsRemaining=this._loop,this.clearFade(),this.clearDelay(),this._status="stopped"}clearFade(){this.fadeTimerId&&(clearTimeout(this.fadeTimerId),delete this.fadeTimerId)}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}dispose(t=!1){this.off(),this.stop(),this.clearFade(),this.clearDelay()}}});function VY(t){let e=!1;return t.scene.objects.traverse((i,r)=>{r.type==="Mesh"&&(r.geometry.type==="TextGeometry"||r.geometry.type==="InputGeometry")&&(e=!0)}),e}var SG,TG=G(()=>{SG=null});function kY(t){return new Z(t.y,-t.x)}var MG,BU,Rft,Dft,RM,zY,TR,Nft,CO,MR=G(()=>{dt(),MG=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=t.parameters?.radiusTop,r=t.parameters?.radiusBottom,s=Object.assign({},e?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},t.parameters);s.thetaLength=qt.clamp(s.thetaLength,0,360),s.hollow=qt.clamp(s.hollow??0,0,1);let n=s.width/2,a=s.radiusTop??n,o=s.radiusBottom??n;if(a===o?(a=n,o=n):a>o?(a=n,o=o*n/a):(a=a*n/o,o=n),s.shapeBlendNode){a=i??n,o=r??n;let l=2*Math.max(a,o);s.width=l,s.depth=l}return{parameters:Object.assign(s,{width:Math.abs(s.width),height:Math.abs(s.height??s.width),depth:Math.abs(s.depth??s.width),radiusTop:a,radiusBottom:o})}}static build(t){let e,{width:i,depth:r,height:s,radialSegments:n,heightSegments:a,openEnded:o,thetaStart:l,thetaLength:u,radiusTop:h,radiusBottom:d,cornerRadius:c,cornerSegments:p,hollow:m}=t.parameters;u===0?(e=new ye,e.setAttribute("position",new fe([],3))):e=c||m?new BU(h,d,s,n,a,o,l,u*Math.PI/180,c,c,p,m):new V2(h,d,s,n,a,o,l,u*Math.PI/180);let f=r/i;return f!==1&&e.scale(1,1,f),Object.assign(e,{userData:{...t,type:"CylinderGeometry"}})}},BU=class extends ye{constructor(t,e,i,r,s,n,a,o,l,u,h,d,c=!1){super(),this.type="RoundedCylinderBufferGeometry",t=t!==void 0?t:1,e=e!==void 0?e:1,i=i||1,r=Math.floor(r)||8,s=Math.floor(s)||1,n=n!==void 0&&n,a=a!==void 0?a:0,o=o!==void 0?o:2*Math.PI,n&&(l=0,u=0);let p=i/2;c&&t==0&&(t=l),c&&e==0&&(e=u);let m=new Z(t,p),f=new Z(e,-p),g=null,y=null,v=null,b=null,_=m.clone().sub(f),x=0,S=0,w=0;d>0&&(x=Math.min(t,e)*(1-d),S=t-x,w=e-x);let T=m.clone();T.x-=x;let A=Math.PI-_.angle(),M=_.angle(),C=Math.tan(M/2),R=Math.tan(A/2),O=C+R,N=d?O:R,B=d?O:C;if(l=Math.min(l,(t-S)/N,_.length()/O),u=Math.min(u,(e-w)/B,_.length()/O),l>0){let Bt=l/C;g=m.clone().sub(new Z(Bt,l)),d&&(v=g.clone(),v.x-=x-O*l),m.sub(_.clone().setLength(Bt))}if(u>0){let Bt=u/R;y=f.clone().sub(new Z(Bt,-u)),f.add(_.clone().setLength(Bt)),d&&(b=y.clone(),b.x-=x-O*u,T.sub(_.clone().setLength(Bt)))}_=m.clone().sub(f);let k=_.length()<.5,z=[],L=[],V=[],q=[],j=[],Q=[],it=(Bt,jt,Xt,Dt,le)=>{for(let Wt=0;Wt<h+1;Wt++){let Qt=Wt/h,ee=Dt<0?Qt:1-Qt;le&&(ee-=1),ee*=Bt;let $=Math.sin(ee),se=Math.cos(ee)*Dt,Pe=se*jt+Xt.y;z.push($*jt+Xt.x),L.push(Pe),V.push($),q.push(se),j.push(.5+Pe/i),Q.push(!1)}},at=(Bt,jt,Xt)=>{let Dt=[Bt,jt];Xt<0&&Dt.reverse();for(let le of Dt)z.push(le),L.push(p*Xt),V.push(0),q.push(Xt),j.push(.5),Q.push(!0)};if(b&&y?(it(A,u,b,-1,!0),it(M,u,y,-1,!1)):y?(at(y.x,0,-1),it(M,u,y,-1,!1)):n||at(e,w,-1),!k){let Bt=kY(_).normalize();for(let jt=0;jt<=s;jt++){let Xt=jt/s,Dt=_.y*Xt+f.y;z.push(_.x*Xt+f.x),L.push(Dt),V.push(Bt.x),q.push(Bt.y),j.push(.5+Dt/i),Q.push(!1)}}if(v&&g?(it(A,l,g,1,!1),it(M,l,v,1,!0)):g?(it(A,l,g,1,!1),at(g.x,0,1)):n||at(t,S,1),d&&!k){let Bt=kY(_).multiplyScalar(-1).normalize();for(let jt=0;jt<=s;jt++){let Xt=jt/s,Dt=_.y*-Xt+T.y;z.push(_.x*-Xt+T.x),L.push(Dt),V.push(Bt.x),q.push(Bt.y),j.push(.5+Dt/i),Q.push(!1)}}let St=z.length,yt=St+(d&&!n?1:0),Y=(Bt,jt)=>Bt*St+(jt===St?0:jt),pt=o<2*Math.PI,xt=(r+1)*St+(pt?2*(1+yt):0),Tt=new Float32Array(3*xt),Mt=new Float32Array(3*xt),_t=new Float32Array(2*xt),kt=xt-1>65535?new Uint32Array(r*Math.max(0,yt-1)*6+(pt?2*(yt+1)*3:0)):new Uint16Array(r*Math.max(0,yt-1)*6+(pt?2*(yt+1)*3:0)),Ut=0,Lt=0;for(let Bt=0;Bt<=r;Bt++){let jt=Bt/r,Xt=jt*o+a,Dt=Math.sin(Xt),le=Math.cos(Xt);for(let Wt=0;Wt<St;Wt++){let Qt=3*Lt,ee=2*Lt,$=z[Wt],se=V[Wt];Tt[Qt]=$*Dt,Tt[Qt+1]=L[Wt],Tt[Qt+2]=$*le,Mt[Qt]=se*Dt,Mt[Qt+1]=q[Wt],Mt[Qt+2]=se*le,Q[Wt]?(_t[ee]=.5,_t[ee+1]=.5):(_t[ee]=jt,_t[ee+1]=j[Wt]),Lt++}}for(let Bt=0;Bt<r;Bt++)for(let jt=0;jt<yt-1;jt++){if(n&&d&&jt==s)continue;let Xt=Y(Bt,jt),Dt=Y(Bt+1,jt),le=Y(Bt+1,jt+1),Wt=Y(Bt,jt+1),Qt=Tt[3*le+0],ee=Tt[3*le+2];kt[Ut++]=Xt,kt[Ut++]=Dt,kt[Ut++]=Wt,(Qt!=0||ee!=0)&&(kt[Ut++]=Dt,kt[Ut++]=le,kt[Ut++]=Wt)}function zt(Bt,jt,Xt){let Dt=Math.sin(Xt),le=Math.cos(Xt),Wt=-le,Qt=Dt,ee=Bt<0?(ie,oi,xi)=>{kt[Ut++]=ie,kt[Ut++]=oi,kt[Ut++]=xi}:(ie,oi,xi)=>{kt[Ut++]=ie,kt[Ut++]=xi,kt[Ut++]=oi},$=(t+e+S+w)/4,se=3*Lt,Pe=2*Lt;Tt[se]=$*Dt,Tt[se+1]=0,Tt[se+2]=$*le,Mt[se]=Wt,Mt[se+1]=0,Mt[se+2]=Qt,_t[Pe]=.5,_t[Pe+1]=.5;let Ve=Lt++;for(let ie=0;ie<yt;ie++){let oi=3*(jt+(ie===St?0:ie));se=3*Lt,Pe=2*Lt,Tt[se]=Tt[oi],Tt[se+1]=Tt[oi+1],Tt[se+2]=Tt[oi+2],Mt[se]=Wt,Mt[se+1]=0,Mt[se+2]=Qt;let xi=oi/3*2|0;_t[Pe]=_t[xi],_t[Pe+1]=_t[xi+1],Lt++}for(let ie=Ve+1;ie<Lt-1;ie++)ee(Ve,ie,ie+1);ee(Ve,Lt-1,Ve+1)}pt&&(zt(-1,0,a),zt(1,r*St,a+o)),this.setIndex(new we(kt.slice(0,Ut),1)),this.setAttribute("position",new we(Tt,3)),this.setAttribute("normal",new we(Mt,3)),this.setAttribute("uv",new we(_t,2))}}}),LY=G(()=>{dt(),MR(),Rft=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:8,cornerRadiusBottom:8,cornerSegments:8},t.parameters);return i.thetaLength=qt.clamp(i.thetaLength,0,360),{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(t){let e,{width:i,depth:r,height:s,radialSegments:n,heightSegments:a,openEnded:o,thetaStart:l,thetaLength:u,cornerRadiusTop:h,cornerRadiusBottom:d,cornerSegments:c}=t.parameters;u===0?(e=new ye,e.setAttribute("position",new fe([],3))):e=h>0||d>0||u<360?new BU(0,i/2,s,n,a,o,l,u*Math.PI/180,h,d,c,0,!0):new q4(i/2,s,n,a,o);let p=r/i;return p!==1&&e.scale(1,1,p),Object.assign(e,{userData:{...t,type:"ConeGeometry"}})}}}),FY=G(()=>{dt(),Dft=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},t.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(t){let e,{width:i,height:r,depth:s,widthSegments:n,heightSegments:a,depthSegments:o,cornerRadius:l,cornerSegments:u}=t.parameters;return e=l===0?new Zh(i,r,s,n,a,o):new zY(i,r,s,n,a,o,l,u),Object.assign(e,{userData:{...t,type:"CubeGeometry"}})}},RM=Math.PI/2,zY=class extends ye{constructor(t=1,e=1,i=1,r=1,s=1,n=1,a=0,o=4){super(),this.type="BoxGeometry",r=Math.floor(r),s=Math.floor(s),n=Math.floor(n),o=Math.floor(o);let l=(a=Math.min(a,t/2,e/2,i/2))>0,u=o+1,h=2*((n+1)*(s+1)+(r+1)*(n+1)+(r+1)*(s+1))+(l?4*u*(n+1+(r+1)+(s+1))+u*(u+1)/2*8:0),d=2*(n*s+r*n+r*s)+(l?4*o*(n+r+s):0),c=l?8*o*o:0,p=new Float32Array(3*h),m=new Float32Array(3*h),f=new Float32Array(2*h),g=h-1>65535?new Uint32Array(6*d+3*c):new Uint16Array(6*d+3*c),y=0,v=0,b=new Float64Array(u),_=new Float64Array(u),x=new Float64Array(u),S=new Float64Array(u);for(let O=0;O<u;O++){let N=O/o*RM;b[O]=Math.sin(N)*a,_[O]=(1-Math.cos(N))*a,x[O]=Math.sin(N),S[O]=Math.cos(N)}let w=u*(u+1)/2,T=new Float64Array(3*w),A=new Float64Array(3*w);{let O=new P(t/2,e/2,i/2);O.subScalar(a);let N=0;for(let B=0;B<=o;B++){let k=RM*(1-B/o),z=Math.cos(k),L=Math.sin(k),V=0;for(let q=0;q<=B;q++){let j=z*Math.cos(V),Q=L,it=z*Math.sin(V);T[3*N]=j,T[3*N+1]=Q,T[3*N+2]=it,A[3*N]=O.x+j*a,A[3*N+1]=O.y+Q*a,A[3*N+2]=O.z+it*a,N++,V+=RM/B}}}function M(O,N,B,k,z,L,V,q,j,Q){let it=(L-2*a)/j,at=(V-2*a)/Q,St=L/2-a,yt=V/2-a,Y=q/2,pt=j+1,xt=Q+1,Tt=0,Mt=new P;for(let _t=0;_t<xt;_t++){let kt=_t*at-yt;for(let Ut=0;Ut<pt;Ut++){let Lt=Ut*it-St,zt=3*(y+Tt),Bt=2*(y+Tt);Mt[O]=Lt*k,Mt[N]=kt*z,Mt[B]=Y,p[zt]=Mt.x,p[zt+1]=Mt.y,p[zt+2]=Mt.z,Mt[O]=0,Mt[N]=0,Mt[B]=q>0?1:-1,m[zt]=Mt.x,m[zt+1]=Mt.y,m[zt+2]=Mt.z,f[Bt]=Ut/j,f[Bt+1]=1-_t/Q,Tt+=1}}for(let _t=0;_t<Q;_t++)for(let kt=0;kt<j;kt++){let Ut=y+kt+pt*_t,Lt=y+kt+pt*(_t+1),zt=y+(kt+1)+pt*(_t+1),Bt=y+(kt+1)+pt*_t;g[v++]=Ut,g[v++]=Lt,g[v++]=Bt,g[v++]=Lt,g[v++]=zt,g[v++]=Bt}y+=Tt}function C(O,N,B,k,z,L,V,q,j,Q){let it=(V-2*a)/Q,at=V/2-a,St=q/2-a,yt=j/2,Y=Q+1,pt=0,xt=new P,Tt=new P;for(let Mt=0;Mt<o+1;Mt++){xt[N]=(St+b[Mt])*z,xt[B]=(yt-_[Mt])*L,Tt[O]=0,Tt[N]=x[Mt]*Math.sign(xt[N]),Tt[B]=S[Mt]*Math.sign(xt[B]);for(let _t=0;_t<Y;_t++){let kt=_t*it-at;xt[O]=kt*k;let Ut=3*(y+pt),Lt=2*(y+pt);p[Ut]=xt.x,p[Ut+1]=xt.y,p[Ut+2]=xt.z,m[Ut]=Tt.x,m[Ut+1]=Tt.y,m[Ut+2]=Tt.z,f[Lt]=_t/Q,f[Lt+1]=0,pt+=1}}for(let Mt=0;Mt<o;Mt++)for(let _t=0;_t<Q;_t++){let kt=y+_t+Y*Mt,Ut=y+_t+Y*(Mt+1),Lt=y+(_t+1)+Y*(Mt+1),zt=y+(_t+1)+Y*Mt;g[v++]=kt,g[v++]=Ut,g[v++]=zt,g[v++]=Ut,g[v++]=Lt,g[v++]=zt}y+=pt}function R(O,N,B){let k=O*N*B>0?(L,V,q)=>{g[v++]=L,g[v++]=V,g[v++]=q}:(L,V,q)=>{g[v++]=L,g[v++]=q,g[v++]=V},z=y;for(let L=0;L<w;L++){let V=3*L,q=3*y,j=2*y;p[q]=O*A[V],p[q+1]=N*A[V+1],p[q+2]=B*A[V+2],m[q]=O*T[V],m[q+1]=N*T[V+1],m[q+2]=B*T[V+2],f[j]=0,f[j+1]=0,y++}for(let L=0;L<o;L++){let V=z+L*(L+1)/2,q=z+(L+1)*(L+2)/2;k(V,q+1,q);for(let j=1;j<=L;j++)k(V+j-1,V+j,q+j),k(V+j,q+j+1,q+j)}}M("z","y","x",-1,-1,i,e,t,n,s),M("z","y","x",1,-1,i,e,-t,n,s),M("x","z","y",1,1,t,i,e,r,n),M("x","z","y",1,-1,t,i,-e,r,n),M("x","y","z",1,-1,t,e,i,r,s),M("x","y","z",-1,-1,t,e,-i,r,s),a>0&&(C("z","y","x",-1,-1,1,i,e,t,n),C("z","y","x",1,-1,-1,i,e,t,n),C("z","y","x",-1,1,-1,i,e,t,n),C("z","y","x",1,1,1,i,e,t,n),C("x","y","z",-1,-1,-1,t,e,i,r),C("x","y","z",1,-1,1,t,e,i,r),C("x","y","z",-1,1,1,t,e,i,r),C("x","y","z",1,1,-1,t,e,i,r),C("y","x","z",-1,-1,1,e,t,i,s),C("y","x","z",1,-1,-1,e,t,i,s),C("y","x","z",1,1,1,e,t,i,s),C("y","x","z",-1,1,-1,e,t,i,s),R(1,1,1),R(-1,1,1),R(1,-1,1),R(-1,-1,1),R(1,1,-1),R(-1,1,-1),R(1,-1,-1),R(-1,-1,-1)),this.setIndex(new we(g,1)),this.setAttribute("position",new we(p,3)),this.setAttribute("normal",new we(m,3)),this.setAttribute("uv",new we(f,2))}}}),Oft=G(()=>{dt(),TR=class extends ye{constructor(t=[],e=[],i="",r=1,s=.2,n=4){super(),this.type="PolyhedronGeometryRound";let a,o,l,u=0;return function(){(s=Math.min(.99999,s))==0&&(n=0);let h={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[i],d=new P,c=d.clone(),p=new Os,m=s*r,f=r-m,g=n+1,y=new P,v=(Y,pt)=>y.subVectors(Y,pt).normalize(),b=(Y,pt)=>Array(Y).fill(void 0).map(pt),_=b(t.length/3,(Y,pt)=>new P().fromArray(t,3*pt).setLength(r)),x=[],S=1e6;for(let Y=0;Y<_.length;Y++){let pt,xt,Tt,Mt=_[Y],_t=[],kt=1e10,Ut=-1;for(;(Ut=e.indexOf(Y,Ut+1))!=-1;){let jt=Ut-Ut%3;pt=e[jt+(Ut+1)%3],xt=e[jt+(Ut+2)%3],Tt=Mt.distanceToSquared(_[pt]),kt=Math.min(kt,Tt),_t.push([pt,xt,Tt])}kt+=1e-6;let Lt=[],zt=0,Bt=_t.length;for(let jt=0;jt<Bt;jt++){[pt,xt,Tt]=_t[zt];let Xt=x[pt]?.includes(Y)==1;Tt<=kt&&Lt.push(pt+ +Xt*S),zt=_t.findIndex(Dt=>Dt[0]==xt)}x.push(Lt)}let w=[];{let Y,pt,xt=0,Tt=0,Mt=h==3;for(let _t=0;_t<=n;_t++){Y=_t*(_t+1)/2,pt=(_t+1)*(_t+2)/2;for(let kt=0;kt<n-_t;kt++)[xt,Tt]=[Y+kt+_t+2,pt+kt+_t+3],w.push(Y,pt,...Mt?[Tt,Y]:[xt,pt],Tt,xt),[Y,pt]=[xt,Tt];w.push(Y,pt,Y+n+2)}}let T=0;for(let Y=0;Y<x.length;Y++)for(let pt=0;pt<h;pt++)x[Y][pt]<S&&T++;let A=_.length*h*w.length*3+T*g*6*3+2*T*3*3;a=new Float64Array(A),o=new Float64Array(A),l=new Float64Array(A/3*2);let M=(Y,pt,xt)=>{let Tt=u/3*2;l[Tt]=Math.atan2(xt,-Y)/2/Math.PI+.5,l[Tt+1]=1-(Math.atan2(-pt,Math.sqrt(Y*Y+xt*xt))/Math.PI+.5)},C=Y=>{a[u]=Y.x,a[u+1]=Y.y,a[u+2]=Y.z,o[u]=y.x,o[u+1]=y.y,o[u+2]=y.z,M(Y.x,Y.y,Y.z),u+=3},R=Y=>{a[u]=Y[0].x,a[u+1]=Y[0].y,a[u+2]=Y[0].z,o[u]=Y[1].x,o[u+1]=Y[1].y,o[u+2]=Y[1].z,M(Y[0].x,Y[0].y,Y[0].z),u+=3},O=(n+2)*(n+3)/2,N=new Float64Array(3*O),B=new Float64Array(3*O),k=new Float64Array(2*O),z=b(2*h*g,()=>new P),L=b(n*Math.max(0,n-1)/2,()=>new P),V=d.clone(),q=d.clone(),j=d.clone(),Q=d.clone(),it=d.clone(),at=[],St=b(_.length,()=>b(h,()=>d.clone()));for(let Y=0;Y<_.length;Y++){d.copy(_[Y]).normalize(),V.copy(d).multiplyScalar(f);let pt=x[Y];for(let Lt=0;Lt<pt.length;Lt++){let zt=pt[Lt],Bt=pt[(Lt+1)%h];p.setFromPointsAndIndices(_,Y,zt%S,Bt%S),p.b.sub(p.a).setLength(1e10).add(p.a),p.c.sub(p.a).setLength(1e10).add(p.a),p.closestPointToPoint(V,St[Y][Lt])}let xt=0,Tt=[],Mt=[],_t=new P;n==0&&[...St[Y]].reduce((Lt,zt)=>Lt.add(zt),_t).multiplyScalar(1/h);for(let Lt=0;Lt<h;Lt++){let zt=[],Bt=(Lt-1+h)%h,jt=St[Y][Bt],Xt=St[Y][Lt];d.copy(jt).sub(V),c.copy(Xt).sub(V);let Dt=V.angleTo(d),le=d.angleTo(c),Wt=Math.cos(Dt)*m;n==0?q.copy(_t):q.copy(V).setLength(f+Wt),Tt.push(Wt);let Qt=[q,jt,Xt];for(let ee=0;ee<2;ee++){let $=Qt[ee],se=Qt[ee+1];Q.subVectors($,V),it.subVectors(se,V),j.crossVectors(Q,it).normalize();for(let Pe=0;Pe<g;Pe++){let Ve=[Dt,le][ee]*Pe/g;d.copy(Q).applyAxisAngle(j,Ve).add(V),z[xt++].copy(d),ee&&(v(d,V),zt.push([Pe==0?$:d.clone(),y.clone()]))}ee&&(v(se,V),zt.push([se,y.clone()]))}Mt.push(zt)}at.push(Mt);let kt=2*g,Ut=2;for(let Lt=0;Lt<h;Lt++){let zt=kt*Lt,Bt=kt*((Lt+1)%h),jt=0,Xt=[z[zt]];for(let Dt=1;Dt<g;Dt++){let le=z[zt+Dt],Wt=z[Bt+Dt];Xt.push(le);for(let Qt=1,ee=Dt-Ut+1;Qt<=ee;Qt++)d.lerpVectors(le,Wt,Qt/(ee+1)),d.sub(V).setLength(Tt[Lt]).add(V),Xt.push(L[jt++].copy(d));Xt.push(Wt)}for(let Dt=0;Dt<g;Dt++)Xt.push(z[Dt+g+zt]);Xt.push(z[Bt+g]);for(let Dt=0,le=Xt.length;Dt<le;Dt++){let Wt=Xt[Dt],Qt=3*Dt,ee=2*Dt;N[Qt]=Wt.x,N[Qt+1]=Wt.y,N[Qt+2]=Wt.z,v(Wt,V),B[Qt]=y.x,B[Qt+1]=y.y,B[Qt+2]=y.z,k[ee]=Math.atan2(Wt.z,-Wt.x)/2/Math.PI+.5,k[ee+1]=1-(Math.atan2(-Wt.y,Math.sqrt(Wt.x*Wt.x+Wt.z*Wt.z))/Math.PI+.5)}for(let Dt=0,le=w.length;Dt<le;Dt++){let Wt=3*w[Dt],Qt=2*w[Dt],ee=u/3*2;a[u]=N[Wt],a[u+1]=N[Wt+1],a[u+2]=N[Wt+2],o[u]=B[Wt],o[u+1]=B[Wt+1],o[u+2]=B[Wt+2],l[ee]=k[Qt],l[ee+1]=k[Qt+1],u+=3}}}let yt=[];for(let Y=0;Y<x.length;Y++)for(let pt=0;pt<h;pt++){let xt=x[Y][pt];if(xt<S){let Tt=x[xt].findIndex(kt=>kt%S==Y),Mt=at[Y][pt],_t=at[xt][Tt];for(let kt=0;kt<g;kt++){let Ut=Mt[kt],Lt=_t[g-kt],zt=Mt[kt+1],Bt=_t[g-(kt+1)];R(Ut),R(Lt),R(zt),R(zt),R(Lt),R(Bt)}yt.push(Mt[0][0],_t[g][0],Mt[g][0],_t[0][0])}}for(;yt.length;){let Y,pt,xt,[Tt,Mt]=yt.splice(0,2);Y=Mt;let _t=[Tt];for(;Tt!=Y;)_t.push(Y),pt=yt.indexOf(Y),xt=pt%2,Y=yt.splice(pt-xt,2)[1-xt];y.subVectors(_t[0],_t[1]).cross(d.subVectors(_t[0],_t[2])).normalize();let kt=y.dot(_t[0])<0;kt&&y.negate();for(let Ut=1;Ut<=_t.length-2;Ut++)C(_t[Ut+ +kt]),C(_t[Ut+1-+kt]),C(_t[0])}}(),function(){let h=new P,d=new P,c=new P,p=new P,m=new Z,f=new Z,g=new Z,y=(_,x,S,w)=>{w<0&&_.x===1&&(l[x]=_.x-1),S.x===0&&S.z===0&&(l[x]=w/2/Math.PI+.5)};for(let _=0,x=0;_<u;_+=9,x+=6){h.set(a[_+0],a[_+1],a[_+2]),d.set(a[_+3],a[_+4],a[_+5]),c.set(a[_+6],a[_+7],a[_+8]),m.set(l[x+0],l[x+1]),f.set(l[x+2],l[x+3]),g.set(l[x+4],l[x+5]),p.copy(h).add(d).add(c).divideScalar(3);let S=b(p);y(m,x+0,h,S),y(f,x+2,d,S),y(g,x+4,c,S)}let v=u/3*2;for(let _=0;_<v;_+=6){let x=l[_+0],S=l[_+2],w=l[_+4],T=Math.max(x,S,w),A=Math.min(x,S,w);T>.9&&A<.1&&(x<.2&&(l[_+0]+=1),S<.2&&(l[_+2]+=1),w<.2&&(l[_+4]+=1))}function b(_){return Math.atan2(_.z,-_.x)}}(),this.setAttribute("position",new we(new Float32Array(a.subarray(0,u)),3)),this.setAttribute("normal",new we(new Float32Array(o.subarray(0,u)),3)),void this.setAttribute("uv",new we(new Float32Array(l.subarray(0,u/3*2)),2))}static fromJSON(t){return new TR(t.vertices,t.indices,t.radius,t.corner,t.cornerSides)}}}),UY=G(()=>{Oft(),dt(),Nft=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,detail:0,corner:0,cornerSides:4},t.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(t){let{width:e,height:i,depth:r,detail:s,corner:n,cornerSides:a}=t.parameters,o=s===0&&n!==0?new CO(.5*e,n,a):new v8(.5*e,s),l=i/e,u=r/e;return(l!==1||u!==1)&&o.scale(1,l,u),Object.assign(o,{userData:{...t,type:"DodecahedronGeometry"}})}},CO=class extends TR{constructor(t=1,e=.2,i=4){let r=(1+Math.sqrt(5))/2,s=1/r,n="DodecahedronGeometry";super([-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-s,-r,0,-s,r,0,s,-r,0,s,r,-s,-r,0,-s,r,0,s,-r,0,s,r,0,-r,0,-s,r,0,-s,-r,0,s,r,0,s],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],n,t,e,i),this.type=n}static fromJSON(t){return new CO(t.radius,t.corner,t.cornerSides)}}});function jY(t,e=new Z){let i=t.length();return e.set(-t.y/i,t.x/i)}function a3t(t){let e=new Z;e.addVectors(t.v0,Cg.subVectors(t.v1,t.v0).multiplyScalar(2/3));let i=new Z;return i.addVectors(t.v2,BS.subVectors(t.v1,t.v2).multiplyScalar(2/3)),new Kl(t.v0,e,i,t.v2)}function Zw(t,e,i=Number.EPSILON){return Math.abs(t-e)<i}function o3t(t,e,i=Number.EPSILON){return t.distanceTo(e)<i}function l3t(t,e,i=Number.EPSILON){return t.distanceTo(e)<i}function Ift(t,e,i){let r=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),s=Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2)),n=Math.sqrt(Math.pow(i.x-t.x,2)+Math.pow(i.y-t.y,2));return Math.acos((s*s+r*r-n*n)/(2*s*r))}function h3t(t,e,i){return WY(t,e)&&WY(e,i)&&VU(t.position,e.position,i.position)}function VU(t,e,i){return Cg.copy(e).sub(t).cross(BS.copy(i).sub(t))===0}function u3t(t,e,i,r,s){let n=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),a=(t.y+e.y)/2,o=(t.x+e.x)/2,l=Math.sqrt(Math.pow(i,2)-Math.pow(n/2,2))*(t.y-e.y)/n,u=Math.sqrt(Math.pow(i,2)-Math.pow(n/2,2))*(e.x-t.x)/n;return r.set(o+l,a+u),s.set(o-l,a-u),[r,s]}function d3t(t,e,i){return t.distanceTo(i)<e.distanceTo(i)?e:t}function c3t(t,e,i,r,s,n){let a,o=e.x-t.x,l=e.y-t.y,u=i.x-t.x,h=i.y-t.y,d=Math.sqrt((o+u)*(o+u)+(l+h)*(l+h));return Ift(e,t,i)>Math.PI&&(d*=-1),a=Zw(h,l)?(l+h)*(r/d-.5)*8/3/(o-u):(o+u)*(r/d-.5)*8/3/(h-l),s.set(e.x-a*l,e.y+a*o),n.set(i.x+a*h,i.y-a*u),[s,n]}function GY(t,e){return t.position.equals(t.controls[1].position)&&e.position.equals(e.controls[0].position)}function WY(t,e){return VU(t.position,t.controls[1].position,e.position)&&VU(t.position,e.controls[0].position,e.position)}function qY(t,e=12,i=!1){let r=[];for(let s=0,n=t.length;s<n;s++){let a=t[s],o=0;if(i&&a.roundedCurveCorner!==void 0){let l=.5*Ag(a.roundedCurveCorner,e);s>0&&(r[s-1]+=l),o+=l}a.curveAfter!==void 0&&(o+=Ag(a.curveAfter,e)),r.push(o)}return t.length>0&&i&&t[0].roundedCurveCorner!==void 0&&(r[t.length-1]+=.5*Ag(t[0].roundedCurveCorner,e)),r}function Ag(t,e=12){return t&&t instanceof Uw?2*e:t&&(t instanceof cl||t instanceof b8)?1:t&&t instanceof wP?e*t.points.length:e}var C1,DM,NM,jg,BP,Cg,BS,Bft,Vft,kft,zft,kU,zU,OM,HY,$Y,XY,YY,KY,ds,Lft=G(()=>{dt(),C1=1e-12,DM=class{constructor(t){this.position=new Z,this.startPosition=new Z,this.uuid=qt.generateUUID(),this.position=t.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(t){this.position.copy(this.startPosition).add(t)}copy(t){return this.position.copy(t.position),this.startPosition.copy(t.startPosition),this}clone(){return new DM(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},NM=class extends DM{constructor(t){super(t.position),this.parent=t}copy(t){return super.copy(t),this}clone(){return new NM(this.parent).copy(this)}},jg=class extends DM{constructor(t,e){super(e),this.controls=[],this.roundness=0,this.areControlsDirectionsMirrored=!0,this.uuid=t,this.controls.push(new NM(this),new NM(this))}static create(t,e){let i=new jg(t,new Z(...e.position));return i.controls[0].position.set(...e.controlPrevious.position),i.controls[1].position.set(...e.controlNext.position),i.roundness=e.roundness,i.areControlsDirectionsMirrored=e.areControlsDirectionsMirrored,i}getOppositeControl(t){let e=this.controls.indexOf(t);return e===0?this.controls[1]:e===1?this.controls[0]:null}applyOffsetToControls(t,e=1){for(let i=0,r=this.controls.length;i<r;i++){let s=this.controls[i];this.position.distanceTo(s.position)<=e?s.position.copy(this.position):s.applyOffset(t)}}controlsMoved(){return!(this.position.equals(this.controls[0].position)&&this.position.equals(this.controls[1].position))}copy(t){return super.copy(t),this.controls[0].copy(t.controls[0]),this.controls[1].copy(t.controls[1]),this.roundness=t.roundness,this.uuid=t.uuid,this}clone(){return new jg(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}computeTangents(){let t=this.curveBefore?.getTangentAt(1),e=this.curveAfter?.getTangentAt(0);return[t,e]}computeNormals(t=new Z,e=new Z){let[i,r]=this.computeTangents();return i&&r&&(jY(i,t),jY(r,e)),[t,e]}computeTangent(t=new Z){let[e,i]=this.computeTangents();return e&&i&&t.copy(e).add(i).normalize(),t}computeNormal(t=new Z){let[e,i]=this.computeNormals();return t.copy(e).add(i).normalize(),t}},BP=t=>t,Cg=new Z,BS=new Z,Bft=new Z,Vft=new Z,kft=new Z,zft=new Z,kU=new P,zU=new P}),_m=G(()=>{dt(),Lft(),OM=new Z,HY=new Z,$Y=new Z,XY=new Z,YY=new Z,KY=new Z,ds=class extends bS{constructor(t=100,e=100){super(),this.points=[],this.shapeHoles=[],this.plane=new Ra(new P(0,0,-1)),this.subdivision=0,this.controlSnapDistance=4,this.pointIDs=0,this.isMesh2D=!1,this.isText=!1,this._roundness=0,this.isClosed=!1,this.useCubicForRoundedCorners=!0,this.uuid=qt.generateUUID(),this.needsUpdate=!1,this.roundedCurves=[],this._width=t,this._height=e}static createFromState(t,e,i){let r=new ds;return r.isClosed=t.isClosed,r.points=t.points.map(s=>jg.create(s.id,s.data)),typeof t.roundness=="number"&&(r.roundness=t.roundness),r.shapeHoles=t.shapeHoles.map(s=>ds.createFromState(s)),e!==void 0&&i!==void 0&&r.applySize(e,i),r.update(),r}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(t){if(this._roundness!==t){this._roundness=t;for(let e=0,i=this.points.length;e<i;e++)this.points[e].roundness=t;this.needsUpdate=!0}}getPointsIndexesByIds(t){return t.map(e=>this.getPointIndexById(e)).filter(e=>e>=0)}getPointIndexById(t){let e=this.points.length,i=this.points.findIndex(r=>r.uuid===t);if(i<0){let r=e;for(let s=0,n=this.shapeHoles.length;s<n;s++){let a=this.shapeHoles[s],o=a.points.length,l=a.getPointIndexById(t);if(!(l<0))return l+r;r+=o}}return i}getLineIndexById(t){return this.getPointIndexById(t)}getBezierPoint(t){if(t<=this.points.length-1)return this.points[t];if(this.shapeHoles.length>0){let e=this.points.length;for(let i=0,r=this.shapeHoles.length;i<r;i++){let s=this.shapeHoles[i],n=t-e;if(n<=s.points.length-1)return s.points[n];e+=s.points.length}}throw new Error("This shape does not have a point for this index: "+t)}getBezierPointIndex(t){let e=this.points.indexOf(t);if(e>=0)return e;if(e=this.points.length,this.shapeHoles.length>0)for(let i=0,r=this.shapeHoles.length;i<r;i++){let s=this.shapeHoles[i],n=s.points.indexOf(t);if(n>=0)return e+n;e+=s.points.length}return-1}getAllPoints(){let t=[].concat(...this.shapeHoles.map(e=>e.points));return[...this.points,...t]}applySize(t,e){t===0&&(t=.001),e===0&&(e=.001),this._width=t,this._height=e}applyScale(t,e){let i=OM.set(t,e);for(let r=0,s=this.points.length;r<s;r++){let n=this.points[r];n.position.multiply(i),n.controls[0].position.multiply(i),n.controls[1].position.multiply(i)}for(let r=0,s=this.shapeHoles.length;r<s;r++)this.shapeHoles[r].applyScale(t,e);this._update()}createPoint(t,e=0,i=qt.generateUUID()){let r;r=t instanceof Z?t:new Z(t,e);let s=new jg(i,r);return s.roundness=this.roundness,s}addPoint(t){this.points.push(t),this.needsUpdate=!0}addPointAt(t,e){this.points.splice(e,0,t),this.needsUpdate=!0}getPointByUuid(t){for(let e=0,i=this.points.length;e<i;e++){let r=this.points[e];if(r.uuid===t)return r}for(let e=0,i=this.shapeHoles.length;e<i;e++){let r=this.shapeHoles[e].getPointByUuid(t);if(r)return r}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(t){let e=this.points.indexOf(t);e>=0&&this.points.splice(e,1),this.needsUpdate=!0}removePointById(t){let e=this.points.find(i=>i.uuid===t);e&&this.removePoint(e)}update(){for(let t=0,e=this.shapeHoles.length;t<e;t++)this.shapeHoles[t].update();this._update()}extractShapePointsToBuffer(t,e=12,i=!1){this.subdivision=e,this.curveDivisions===void 0&&this.computeCurveDivisions(e);let r=i?this.roundedCurveDivisions:this.curveDivisions;return function(s,n,a=12,o=!0){let l,u=zU.set(0,0,0),h=0,d=[];for(let c=0;c<n.length;c++){let p=BP(n[c]),m=Cg,f=Ag(p,a);d.push(f);for(let g=0;g<=f;g++)if(p instanceof Kl||p instanceof oc||p instanceof cl){if(p.getPoint(g/f,m),u.set(m.x,m.y,0),l!==void 0&&l3t(l,u))continue;l===void 0&&(l=kU),l.copy(u),s.setXYZ(h,u.x,u.y,u.z),h++}}o&&h>1&&(s.getX(h-1)!==s.getX(0)||s.getY(h-1)!==s.getY(0)||s.getZ(h-1)!==s.getZ(0))&&(s.setXYZ(h,s.getX(0),s.getY(0),s.getZ(0)),h++)}(t,i?this.roundedCurves:this.curves,e,this.autoClose),r.reduce((s,n)=>s+n,0)+1}computeCurveDivisions(t=12){return this.curveDivisions=qY(this.points,t,!1),this.roundedCurveDivisions=qY(this.points,t,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(t,e,i=12){return 2*function(r,s,n,a=12,o=!0){let l=zU.set(0,0,0),u=0,h=[];for(let d=0;d<s.length;d++){if(n[d]===!1)continue;let c,p=BP(s[d]),m=Cg,f=Ag(p,a);h.push(f);for(let g=0;g<=f;g++)if(p instanceof Kl||p instanceof oc||p instanceof cl){if(p.getPoint(g/f,m),l.set(m.x,m.y,0),c?.equals(l))continue;c===void 0?c=kU:(r.setXYZ(u,c.x,c.y,c.z),u++,r.setXYZ(u,l.x,l.y,l.z),u++),c.copy(l)}}return o&&u>1&&!(r.getX(u-1)===r.getX(0)&&r.getY(u-1)===r.getY(0)&&r.getZ(u-1)===r.getZ(0))&&(r.setXYZ(u,r.getX(0),r.getY(0),r.getZ(0)),u++),h}(t,this.curves,e,i,this.autoClose).reduce((r,s)=>r+s,0)}extractShapePointsToFlatArray(t,e=12){return this.subdivision=e,this.curveDivisions===void 0&&this.computeCurveDivisions(e),function(i,r,s=12,n=!0){let a,o=0;for(let l=0;l<r.length;l++){let u=BP(r[l]),h=Ag(u,s),d=Cg;for(let c=0;c<=h;c++)if(u instanceof Kl||u instanceof oc||u instanceof cl){if(u.getPoint(c/h,d),a!==void 0&&o3t(a,d,C1))continue;a===void 0&&(a=BS),a.copy(d),i.push(d.x,d.y),o++}}return Zw(i[0],i[i.length-2],C1)&&Zw(i[1],i[i.length-1],C1)&&(i.pop(),i.pop()),n&&o>1&&!(Zw(i[o-1],i[1],C1)&&Zw(i[o-2],i[0],C1))&&(i.push(i[0],i[1]),o++),i}(t,this.roundedCurves,e,this.autoClose)}getCurveIndexFromVertexId(t,e=!1){let i=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let r=e?this.roundedCurveDivisions:this.curveDivisions,s=0;e&&this.points[0].roundedCurveCorner!==void 0&&(s=.5*Ag(this.points[0].roundedCurveCorner,this.subdivision));let n=t-s;n<0&&(n+=r.reduce((a,o)=>a+o,0));for(let a=0,o=r.length;a<o;a++){let l=r[a];if(n<i+l)return[a,(n-i+1)/l];i+=l}return[0,1]}getCurveT(t,e,i){let r=this.points[t],s=this.points[t>=this.points.length-1?0:t+1],n=this.curveDivisions,a=n[t];if(GY(r,s)){let l=r.position.distanceTo(s.position);return r.position.distanceTo(OM.set(i.x,i.y))/l}let o=0;for(let l=0;l<t;l++)o+=n[l];return(e-o)/a}dispose(){}_applyCurveForPoint(t,e){GY(e,t)?this.lineTo(t.position.x,t.position.y):this.bezierCurveTo(e.controls[1].position.x,e.controls[1].position.y,t.controls[0].position.x,t.controls[0].position.y,t.position.x,t.position.y);let i=this.curves[this.curves.length-1];t.curveBefore=i,e.curveAfter=i;let r=i.clone();t.roundedCurveBefore=r,e.roundedCurveAfter=r,t.roundedCurveCorner=void 0,this.roundedCurves.push(r)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let e=0,i=this.points.length;e<i;e++){let r=this.points[e];if(e===0)this.moveTo(r.position.x,r.position.y);else{let s=this.points[e-1];this._applyCurveForPoint(r,s)}}let t=this.getLastPoint();if(t?.curveAfter&&(t.curveAfter=void 0),this.isClosed){let e=this.points[0],i=this.points[this.points.length-1];this._applyCurveForPoint(e,i)}if(this.points.length>2){let e=0;for(let i=0,r=this.points.length;i<r;i++){let s=this.points[i],n=this.points[i-1]??this.points[this.points.length-1],a=this.points[i+1]??this.points[0],o=s.roundness,l=n&&a&&h3t(n,s,a);if(!s.controlsMoved()&&o>0&&!l){let u=s.curveBefore,h=s.curveAfter;if(u===void 0||h===void 0)continue;let d,c=s.roundedCurveBefore,p=s.roundedCurveAfter,m=u instanceof cl?u.v1.distanceTo(u.v2):u.getLength(),f=h instanceof cl?h.v1.distanceTo(h.v2):h.getLength(),g=Math.min(o,.499*m),y=Math.min(o,.499*f),v=Math.min(g,y),b=1-v/m,_=v/f,x=u.getPointAt(b,OM),S=h.getPointAt(_,HY);if(this._subSplitCurve(u,c,b,x,void 0),this._subSplitCurve(h,p,_,void 0,S),this.useCubicForRoundedCorners){let w=Ift(x,s.position,S)/2,T=Math.tan(w)*x.distanceTo(s.position),[A,M]=u3t(x,S,T,$Y,XY),C=d3t(A,M,s.position),[R,O]=c3t(C,x,S,T,YY,KY);d=new Kl(x.clone(),R.clone(),O.clone(),S.clone())}else d=new oc(x.clone(),s.position.clone(),S.clone());s.roundedCurveCorner=d,this.roundedCurves.splice(i+e,0,d),e++}}}}_subSplitCurve(t,e,i,r,s){if(!(t instanceof cl)){let n=t,a=e,o=n.getUtoTmapping(i,0),l=function(u,h,d,c,p=.5){let m=Cg.subVectors(h,u).multiplyScalar(p).add(u),f=BS.subVectors(d,h).multiplyScalar(p).add(h),g=Bft.subVectors(c,d).multiplyScalar(p).add(d),y=m,v=Vft.subVectors(f,m).multiplyScalar(p).add(m),b=kft.subVectors(g,f).multiplyScalar(p).add(f),_=g,x=zft.subVectors(b,v).multiplyScalar(p).add(v);return[u.x,u.y,y.x,y.y,v.x,v.y,x.x,x.y,b.x,b.y,_.x,_.y,c.x,c.y]}(n.v0,n.v1,n.v2,n.v3,o);return r!==void 0&&(a.v0.set(l[0],l[1]),a.v1.set(l[2],l[3]),a.v2.set(l[4],l[5]),a.v3.set(l[6],l[7])),s!==void 0&&(a.v0.set(l[6],l[7]),a.v1.set(l[8],l[9]),a.v2.set(l[10],l[11]),a.v3.set(l[12],l[13])),a}return r!==void 0&&e.v2.copy(r),s!==void 0&&e.v1.copy(s),e}clone(){let t=new ds(this._width,this._height);return t.points=this.points.map(e=>e.clone()),t.isClosed=this.isClosed,t.roundness=this.roundness,t.isMesh2D=this.isMesh2D,t.shapeHoles=this.shapeHoles.map(e=>e.clone()),t}toJSON(){return{points:this.points.reduce((t,e)=>t.concat(e.toJSON()),[]),shapeHoles:this.shapeHoles.map(t=>t.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(t){this.points=[],this.pointIDs=0;let e=t.points.length/7;for(let i=0;i<e;i++){let r=7*i,s=t.points[r+0],n=t.points[r+1],a=t.points[r+2],o=t.points[r+3],l=t.points[r+4],u=t.points[r+5],h=t.points[r+6],d=new jg(qt.generateUUID(),new Z(s,n));d.controls[0].position.set(a,o),d.controls[1].position.set(l,u),d.roundness=h,this.points.push(d)}return this.shapeHoles=t.shapeHoles?.length?t.shapeHoles.map(i=>{let r=new ds;return r.fromJSON(i),r}):[],this.isClosed=t.isClosed,this._roundness=t.roundness,this._update(),this}fromShape(t,e=!1){this.isText=e;let i=(r,s)=>{s instanceof Kl&&s.v3.equals(r.position)&&r.controls[0].position.copy(s.v2)};return this.points=(r=>{let s,n,a=[];for(s=0,n=r.length;s<n;s++)r[s]instanceof oc&&(r[s]=a3t(r[s]));for(s=0,n=r.length;s<n;s++){let u,h=r[s],d=s>0?r[s-1]:null;h instanceof Kl?(u=this.createPoint(h.v0),u.controls[1].position.copy(h.v1)):h instanceof cl&&(u=this.createPoint(h.v1)),u!==void 0&&(d!==null&&i(u,d),a.push(u))}let o=r[r.length-1],l=!1;return o instanceof Kl?o.v3.equals(a[0].position)&&(a[0].controls[0].position.copy(o.v2),l=!0):o instanceof cl&&o.v2.equals(a[0].position)&&(l=!0),this.isClosed=l,a})(t.curves),t instanceof bS&&(this.shapeHoles=t.holes.map(r=>{let s=new ds;return s.fromShape(r),s})),this.update(),this}updatePoint(t,e){let i=this.getPointByUuid(t);i&&(e.position!==void 0&&i.position.fromArray(e.position),e.roundness!==void 0&&(i.roundness=e.roundness),e.areControlsDirectionsMirrored!==void 0&&(i.areControlsDirectionsMirrored=e.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(t,e){let i=this.getPointByUuid(t)?.controls[0];i&&(e.position&&i.position.fromArray(e.position),this.needsUpdate=!0)}updateNextControl(t,e){let i=this.getPointByUuid(t)?.controls[1];i&&(e.position&&i.position.fromArray(e.position),this.needsUpdate=!0)}}});function EO({x:t,y:e},i,r,s,n){return{x:t*i+s,y:e*r+n}}function p3t(t,e){let i=e===1.5707963267948966?.551915024494:e===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(e/4),r=Math.cos(t),s=Math.sin(t),n=Math.cos(t+e),a=Math.sin(t+e);return[{x:r-s*i,y:s+r*i},{x:n+a*i,y:a-n*i},{x:n,y:a}]}function ZY(t,e,i,r){let s=t*r-e*i<0?-1:1,n=Math.min(1,Math.max(-1,t*i+e*r));return s*Math.acos(n)}var VP,m3t=G(()=>{VP=2*Math.PI});function Xe(t,e){if(!t)throw e||"Assertion Failed!"}function X2(t){var e=t.windingRule,i=e===void 0?ss.ODD:e,r=t.elementType,s=r===void 0?Ea.POLYGONS:r,n=t.polySize,a=n===void 0?3:n,o=t.vertexSize,l=o===void 0?2:o,u=t.normal,h=u===void 0?[0,0,1]:u,d=t.contours,c=d===void 0?[]:d,p=t.strict,m=p===void 0||p,f=t.debug,g=f!==void 0&&f;if(!c&&m)throw new Error("Contours can't be empty");if(c){var y=new Fft;t.edgeCreateCallback&&(y.edgeCreateCallback=t.edgeCreateCallback),t.vertexIdCallback&&(y.vertexIdCallback=t.vertexIdCallback);for(var v=0;v<c.length;v++)y.addContour(l||2,c[v]);return y.tesselate(i,s,a,l,h,m),{vertices:y.vertices,vertexIndices:y.vertexIndices,vertexCount:y.vertexCount,elements:y.elements,elementCount:y.elementCount,mesh:g?y.mesh:void 0}}}var ss,Ea,je,z0,o_,ef,PO,RO,DO,QY,IM,NO,JY,tK,Fft,tT=G(()=>{var t;(t=ss||(ss={}))[t.ODD=0]="ODD",t[t.NONZERO=1]="NONZERO",t[t.POSITIVE=2]="POSITIVE",t[t.NEGATIVE=3]="NEGATIVE",t[t.ABS_GEQ_TWO=4]="ABS_GEQ_TWO",function(e){e[e.POLYGONS=0]="POLYGONS",e[e.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",e[e.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"}(Ea||(Ea={})),je=function(){function e(){}return e.vertEq=function(i,r){return i.s===r.s&&i.t===r.t},e.vertLeq=function(i,r){return i.s<r.s||i.s===r.s&&i.t<=r.t},e.transLeq=function(i,r){return i.t<r.t||i.t===r.t&&i.s<=r.s},e.edgeGoesLeft=function(i){return e.vertLeq(i.Dst,i.Org)},e.edgeGoesRight=function(i){return e.vertLeq(i.Org,i.Dst)},e.vertL1dist=function(i,r){return Math.abs(i.s-r.s)+Math.abs(i.t-r.t)},e.edgeEval=function(i,r,s){Xe(e.vertLeq(i,r)&&e.vertLeq(r,s));var n=r.s-i.s,a=s.s-r.s;return n+a>0?n<a?r.t-i.t+(i.t-s.t)*(n/(n+a)):r.t-s.t+(s.t-i.t)*(a/(n+a)):0},e.edgeSign=function(i,r,s){Xe(e.vertLeq(i,r)&&e.vertLeq(r,s));var n=r.s-i.s,a=s.s-r.s;return n+a>0?(r.t-s.t)*n+(r.t-i.t)*a:0},e.transEval=function(i,r,s){Xe(e.transLeq(i,r)&&e.transLeq(r,s));var n=r.t-i.t,a=s.t-r.t;return n+a>0?n<a?r.s-i.s+(i.s-s.s)*(n/(n+a)):r.s-s.s+(s.s-i.s)*(a/(n+a)):0},e.transSign=function(i,r,s){Xe(e.transLeq(i,r)&&e.transLeq(r,s));var n=r.t-i.t,a=s.t-r.t;return n+a>0?(r.s-s.s)*n+(r.s-i.s)*a:0},e.vertCCW=function(i,r,s){return i.s*(r.t-s.t)+r.s*(s.t-i.t)+s.s*(i.t-r.t)>=0},e.interpolate=function(i,r,s,n){return(i=i<0?0:i)<=(s=s<0?0:s)?s===0?(r+n)/2:r+i/(i+s)*(n-r):n+s/(i+s)*(r-n)},e.intersect=function(i,r,s,n,a){var o,l,u;e.vertLeq(i,r)||(u=i,i=r,r=u),e.vertLeq(s,n)||(u=s,s=n,n=u),e.vertLeq(i,s)||(u=i,i=s,s=u,u=r,r=n,n=u),e.vertLeq(s,r)?e.vertLeq(r,n)?((o=e.edgeEval(i,s,r))+(l=e.edgeEval(s,r,n))<0&&(o=-o,l=-l),a.s=e.interpolate(o,s.s,l,r.s)):((o=e.edgeSign(i,s,r))+(l=-e.edgeSign(i,n,r))<0&&(o=-o,l=-l),a.s=e.interpolate(o,s.s,l,n.s)):a.s=(s.s+r.s)/2,e.transLeq(i,r)||(u=i,i=r,r=u),e.transLeq(s,n)||(u=s,s=n,n=u),e.transLeq(i,s)||(u=i,i=s,s=u,u=r,r=n,n=u),e.transLeq(s,r)?e.transLeq(r,n)?((o=e.transEval(i,s,r))+(l=e.transEval(s,r,n))<0&&(o=-o,l=-l),a.t=e.interpolate(o,s.t,l,r.t)):((o=e.transSign(i,s,r))+(l=-e.transSign(i,n,r))<0&&(o=-o,l=-l),a.t=e.interpolate(o,s.t,l,n.t)):a.t=(s.t+r.t)/2},e}(),z0=function(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1},o_=function(){function e(i){this.side=i,this.next=null,this.Org=null,this.Sym=null,this.Onext=null,this.Lnext=null,this.Lface=null,this.activeRegion=null,this.winding=0}return Object.defineProperty(e.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(i){this.Sym.Lface=i},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(i){this.Sym.Org=i},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(i){this.Sym.Lnext=i},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(i){this.Onext.Sym=i},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(i){this.Lnext.Sym=i},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(i){this.Sym.Onext=i},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(i){this.Sym.Onext.Sym=i},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(i){this.Sym.Lnext.Sym=i},enumerable:!0,configurable:!0}),e}(),ef=function(){this.next=null,this.prev=null,this.anEdge=null,this.coords=[0,0,0],this.s=0,this.t=0,this.pqHandle=0,this.n=0,this.idx=0},PO=function(){function e(){var i=new ef,r=new z0,s=new o_(0),n=new o_(1);i.next=i.prev=i,i.anEdge=null,r.next=r.prev=r,s.next=s,s.Sym=n,n.next=n,n.Sym=s,this.vHead=i,this.fHead=r,this.eHead=s,this.eHeadSym=n}return e.prototype.makeEdge_=function(i){var r=new o_(0),s=new o_(1);i.Sym.side<i.side&&(i=i.Sym);var n=i.Sym.next;return s.next=n,n.Sym.next=r,r.next=i,i.Sym.next=s,r.Sym=s,r.Onext=r,r.Lnext=s,r.Org=null,r.Lface=null,r.winding=0,r.activeRegion=null,s.Sym=r,s.Onext=s,s.Lnext=r,s.Org=null,s.Lface=null,s.winding=0,s.activeRegion=null,r},e.prototype.splice_=function(i,r){var s=i.Onext,n=r.Onext;s.Sym.Lnext=r,n.Sym.Lnext=i,i.Onext=n,r.Onext=s},e.prototype.makeVertex_=function(i,r,s){var n=i;Xe(n,"Vertex can't be null!");var a=s.prev;n.prev=a,a.next=n,n.next=s,s.prev=n,n.anEdge=r;var o=r;do o.Org=n,o=o.Onext;while(o!==r)},e.prototype.makeFace_=function(i,r,s){var n=i;Xe(n,"Face can't be null");var a=s.prev;n.prev=a,a.next=n,n.next=s,s.prev=n,n.anEdge=r,n.trail=null,n.marked=!1,n.inside=s.inside;var o=r;do o.Lface=n,o=o.Lnext;while(o!==r)},e.prototype.killEdge_=function(i){i.Sym.side<i.side&&(i=i.Sym);var r=i.next,s=i.Sym.next;r.Sym.next=s,s.Sym.next=r},e.prototype.killVertex_=function(i,r){var s=i.anEdge,n=s;do n.Org=r,n=n.Onext;while(n!==s);var a=i.prev,o=i.next;o.prev=a,a.next=o},e.prototype.killFace_=function(i,r){var s=i.anEdge,n=s;do n.Lface=r,n=n.Lnext;while(n!==s);var a=i.prev,o=i.next;o.prev=a,a.next=o},e.prototype.makeEdge=function(){var i=new ef,r=new ef,s=new z0,n=this.makeEdge_(this.eHead);return this.makeVertex_(i,n,this.vHead),this.makeVertex_(r,n.Sym,this.vHead),this.makeFace_(s,n,this.fHead),n},e.prototype.splice=function(i,r){var s=!1,n=!1;if(i!==r){if(r.Org!==i.Org&&(n=!0,this.killVertex_(r.Org,i.Org)),r.Lface!==i.Lface&&(s=!0,this.killFace_(r.Lface,i.Lface)),this.splice_(r,i),!n){var a=new ef;this.makeVertex_(a,r,i.Org),i.Org.anEdge=i}if(!s){var o=new z0;this.makeFace_(o,r,i.Lface),i.Lface.anEdge=i}}},e.prototype.delete=function(i){var r=i.Sym,s=!1;if(i.Lface!==i.Rface&&(s=!0,this.killFace_(i.Lface,i.Rface)),i.Onext===i)this.killVertex_(i.Org,null);else if(i.Rface.anEdge=i.Oprev,i.Org.anEdge=i.Onext,this.splice_(i,i.Oprev),!s){var n=new z0;this.makeFace_(n,i,i.Lface)}r.Onext===r?(this.killVertex_(r.Org,null),this.killFace_(r.Lface,null)):(i.Lface.anEdge=r.Oprev,r.Org.anEdge=r.Onext,this.splice_(r,r.Oprev)),this.killEdge_(i)},e.prototype.addEdgeVertex=function(i){var r=this.makeEdge_(i),s=r.Sym;this.splice_(r,i.Lnext),r.Org=i.Dst;var n=new ef;return this.makeVertex_(n,s,r.Org),r.Lface=s.Lface=i.Lface,r},e.prototype.splitEdge=function(i){var r=this.addEdgeVertex(i).Sym;return this.splice_(i.Sym,i.Sym.Oprev),this.splice_(i.Sym,r),i.Dst=r.Org,r.Dst.anEdge=r.Sym,r.Rface=i.Rface,r.winding=i.winding,r.Sym.winding=i.Sym.winding,r.idx=i.idx,r.Sym.idx=i.Sym.idx,r},e.prototype.connect=function(i,r){var s=!1,n=this.makeEdge_(i),a=n.Sym;if(r.Lface!==i.Lface&&(s=!0,this.killFace_(r.Lface,i.Lface)),this.splice_(n,i.Lnext),this.splice_(a,r),n.Org=i.Dst,a.Org=r.Org,n.Lface=a.Lface=i.Lface,i.Lface.anEdge=a,!s){var o=new z0;this.makeFace_(o,n,i.Lface)}return n},e.prototype.zapFace=function(i){var r,s,n,a,o,l=i.anEdge;s=l.Lnext;do s=(r=s).Lnext,r.Lface=null,r.Rface===null&&(r.Onext===r?this.killVertex_(r.Org,null):(r.Org.anEdge=r.Onext,this.splice_(r,r.Oprev)),(n=r.Sym).Onext===n?this.killVertex_(n.Org,null):(n.Org.anEdge=n.Onext,this.splice_(n,n.Oprev)),this.killEdge_(r));while(r!=l);a=i.prev,(o=i.next).prev=a,a.next=o},e.prototype.countFaceVerts_=function(i){var r=i.anEdge,s=0;do s++,r=r.Lnext;while(r!==i.anEdge);return s},e.prototype.mergeConvexFaces=function(i){var r,s,n,a,o;for(r=this.fHead.next;r!==this.fHead;r=r.next)if(r.inside)for(o=(s=r.anEdge).Org;n=s.Lnext,(a=s.Sym)&&a.Lface&&a.Lface.inside&&this.countFaceVerts_(r)+this.countFaceVerts_(a.Lface)-2<=i&&je.vertCCW(s.Lprev.Org,s.Org,a.Lnext.Lnext.Org)&&je.vertCCW(a.Lprev.Org,a.Org,s.Lnext.Lnext.Org)&&(n=a.Lnext,this.delete(a),s=null,a=null),!s||s.Lnext.Org!==o;)s=n;return!0},e.prototype.check=function(){var i,r,s,n,a,o,l=this.fHead,u=this.vHead,h=this.eHead;for(r=l,r=l;(i=r.next)!==l;r=i){Xe(i.prev===r),a=i.anEdge;do Xe(a.Sym!==a),Xe(a.Sym.Sym===a),Xe(a.Lnext.Onext.Sym===a),Xe(a.Onext.Sym.Lnext===a),Xe(a.Lface===i),a=a.Lnext;while(a!==i.anEdge)}for(Xe(i.prev===r&&i.anEdge===null),n=u,n=u;(s=n.next)!==u;n=s){Xe(s.prev===n),a=s.anEdge;do Xe(a.Sym!==a),Xe(a.Sym.Sym===a),Xe(a.Lnext.Onext.Sym===a),Xe(a.Onext.Sym.Lnext===a),Xe(a.Org===s),a=a.Onext;while(a!==s.anEdge)}for(Xe(s.prev===n&&s.anEdge===null),o=h,o=h;(a=o.next)!==h;o=a)Xe(a.Sym.next===o.Sym),Xe(a.Sym!==a),Xe(a.Sym.Sym===a),Xe(a.Org!==null),Xe(a.Dst!==null),Xe(a.Lnext.Onext.Sym===a),Xe(a.Onext.Sym.Lnext===a);Xe(a.Sym.next===o.Sym&&a.Sym===this.eHeadSym&&a.Sym.Sym===a&&a.Org===null&&a.Dst===null&&a.Lface===null&&a.Rface===null)},e}(),RO=function(){this.handle=null},DO=function(){this.key=null,this.node=0},QY=function(){function e(i,r){this.leq=r,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=i,this.nodes=[],this.handles=[];for(var s=0;s<i+1;s++)this.nodes[s]=new RO,this.handles[s]=new DO;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return e.prototype.floatDown_=function(i){var r,s,n,a=this.nodes,o=this.handles;for(r=a[i].handle;;){if((n=i<<1)<this.size&&this.leq(o[a[n+1].handle].key,o[a[n].handle].key)&&++n,Xe(n<=this.max),s=a[n].handle,n>this.size||this.leq(o[r].key,o[s].key)){a[i].handle=r,o[r].node=i;break}a[i].handle=s,o[s].node=i,i=n}},e.prototype.floatUp_=function(i){var r,s,n,a=this.nodes,o=this.handles;for(r=a[i].handle;;){if(s=a[n=i>>1].handle,n===0||this.leq(o[s].key,o[r].key)){a[i].handle=r,o[r].node=i;break}a[i].handle=s,o[s].node=i,i=n}},e.prototype.init=function(){for(var i=this.size;i>=1;--i)this.floatDown_(i);this.initialized=!0},e.prototype.min=function(){return this.handles[this.nodes[1].handle].key},e.prototype.insert=function(i){var r,s;if(2*(r=++this.size)>this.max){var n,a;for(this.max*=2,a=this.nodes.length,this.nodes.length=this.max+1,n=a;n<this.nodes.length;n++)this.nodes[n]=new RO;for(a=this.handles.length,this.handles.length=this.max+1,n=a;n<this.handles.length;n++)this.handles[n]=new DO}return this.freeList===0?s=r:(s=this.freeList,this.freeList=this.handles[s].node),this.nodes[r].handle=s,this.handles[s].node=r,this.handles[s].key=i,this.initialized&&this.floatUp_(r),s},e.prototype.extractMin=function(){var i=this.nodes,r=this.handles,s=i[1].handle,n=r[s].key;return this.size>0&&(i[1].handle=i[this.size].handle,r[i[1].handle].node=1,r[s].key=null,r[s].node=this.freeList,this.freeList=s,--this.size,this.size>0&&this.floatDown_(1)),n},e.prototype.delete=function(i){var r,s=this.nodes,n=this.handles;Xe(i>=1&&i<=this.max&&n[i].key!==null),s[r=n[i].node].handle=s[this.size].handle,n[s[r].handle].node=r,--this.size,r<=this.size&&(r<=1||this.leq(n[s[r>>1].handle].key,n[s[r].handle].key)?this.floatDown_(r):this.floatUp_(r)),n[i].key=null,n[i].node=this.freeList,this.freeList=i},e}(),IM=function(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1},NO=function(){this.key=null,this.next=null,this.prev=null},JY=function(){function e(i,r){this.frame=i,this.leq=r,this.head=new NO,this.head.next=this.head,this.head.prev=this.head}return e.prototype.min=function(){return this.head.next},e.prototype.max=function(){return this.head.prev},e.prototype.insert=function(i){return this.insertBefore(this.head,i)},e.prototype.search=function(i){var r=this.head;do r=r.next;while(r.key!==null&&!this.leq(this.frame,i,r.key));return r},e.prototype.insertBefore=function(i,r){do i=i.prev;while(i.key!==null&&!this.leq(this.frame,i.key,r));var s=new NO;return s.key=r,s.next=i.next,i.next.prev=s,s.prev=i,i.next=s,s},e.prototype.delete=function(i){i.next.prev=i.prev,i.prev.next=i.next},e}(),tK=function(){function e(){}return e.regionBelow=function(i){return i.nodeUp.prev.key},e.regionAbove=function(i){return i.nodeUp.next.key},e.debugEvent=function(i){},e.addWinding=function(i,r){i.winding+=r.winding,i.Sym.winding+=r.Sym.winding},e.edgeLeq=function(i,r,s){var n=i.event,a=r.eUp,o=s.eUp;return a.Dst===n?o.Dst===n?je.vertLeq(a.Org,o.Org)?je.edgeSign(o.Dst,a.Org,o.Org)<=0:je.edgeSign(a.Dst,o.Org,a.Org)>=0:je.edgeSign(o.Dst,n,o.Org)<=0:o.Dst===n?je.edgeSign(a.Dst,n,a.Org)>=0:je.edgeEval(a.Dst,n,a.Org)>=je.edgeEval(o.Dst,n,o.Org)},e.deleteRegion=function(i,r){r.fixUpperEdge&&Xe(r.eUp.winding===0),r.eUp.activeRegion=null,i.dict.delete(r.nodeUp)},e.fixUpperEdge=function(i,r,s){Xe(r.fixUpperEdge),i.mesh.delete(r.eUp),r.fixUpperEdge=!1,r.eUp=s,s.activeRegion=r},e.topLeftRegion=function(i,r){var s,n=r.eUp.Org;do r=e.regionAbove(r);while(r.eUp.Org===n);if(r.fixUpperEdge){if((s=i.mesh.connect(e.regionBelow(r).eUp.Sym,r.eUp.Lnext))===null)return null;e.fixUpperEdge(i,r,s),r=e.regionAbove(r)}return r},e.topRightRegion=function(i){var r=i.eUp.Dst;do i=e.regionAbove(i);while(i.eUp.Dst===r);return i},e.addRegionBelow=function(i,r,s){var n=new IM;return n.eUp=s,n.nodeUp=i.dict.insertBefore(r.nodeUp,n),n.fixUpperEdge=!1,n.sentinel=!1,n.dirty=!1,s.activeRegion=n,n},e.isWindingInside=function(i,r){switch(i.windingRule){case ss.ODD:return!!(1&r);case ss.NONZERO:return r!==0;case ss.POSITIVE:return r>0;case ss.NEGATIVE:return r<0;case ss.ABS_GEQ_TWO:return r>=2||r<=-2}throw new Error("Invalid winding rulle")},e.computeWinding=function(i,r){r.windingNumber=e.regionAbove(r).windingNumber+r.eUp.winding,r.inside=e.isWindingInside(i,r.windingNumber)},e.finishRegion=function(i,r){var s=r.eUp,n=s.Lface;n.inside=r.inside,n.anEdge=s,e.deleteRegion(i,r)},e.finishLeftRegions=function(i,r,s){for(var n,a=null,o=r,l=r.eUp;o!==s;){if(o.fixUpperEdge=!1,(n=(a=e.regionBelow(o)).eUp).Org!=l.Org){if(!a.fixUpperEdge){e.finishRegion(i,o);break}n=i.mesh.connect(l.Lprev,n.Sym),e.fixUpperEdge(i,a,n)}l.Onext!==n&&(i.mesh.splice(n.Oprev,n),i.mesh.splice(l,n)),e.finishRegion(i,o),l=a.eUp,o=a}return l},e.addRightEdges=function(i,r,s,n,a,o){var l,u,h,d,c=!0;h=s;do Xe(je.vertLeq(h.Org,h.Dst)),e.addRegionBelow(i,r,h.Sym),h=h.Onext;while(h!==n);for(a===null&&(a=e.regionBelow(r).eUp.Rprev),u=r,d=a;(h=(l=e.regionBelow(u)).eUp.Sym).Org===d.Org;)h.Onext!==d&&(i.mesh.splice(h.Oprev,h),i.mesh.splice(d.Oprev,h)),l.windingNumber=u.windingNumber-h.winding,l.inside=e.isWindingInside(i,l.windingNumber),u.dirty=!0,!c&&e.checkForRightSplice(i,u)&&(e.addWinding(h,d),e.deleteRegion(i,u),i.mesh.delete(d)),c=!1,u=l,d=h;u.dirty=!0,Xe(u.windingNumber-h.winding===l.windingNumber),o&&e.walkDirtyRegions(i,u)},e.spliceMergeVertices=function(i,r,s){i.mesh.splice(r,s)},e.vertexWeights=function(i,r,s){var n=je.vertL1dist(r,i),a=je.vertL1dist(s,i),o=.5*a/(n+a),l=.5*n/(n+a);i.coords[0]+=o*r.coords[0]+l*s.coords[0],i.coords[1]+=o*r.coords[1]+l*s.coords[1],i.coords[2]+=o*r.coords[2]+l*s.coords[2]},e.getIntersectData=function(i,r,s,n,a,o){r.coords[0]=r.coords[1]=r.coords[2]=0,r.idx=-1,e.vertexWeights(r,s,n),e.vertexWeights(r,a,o)},e.checkForRightSplice=function(i,r){var s=e.regionBelow(r),n=r.eUp,a=s.eUp;if(je.vertLeq(n.Org,a.Org)){if(je.edgeSign(a.Dst,n.Org,a.Org)>0)return!1;je.vertEq(n.Org,a.Org)?n.Org!==a.Org&&(i.pq.delete(n.Org.pqHandle),e.spliceMergeVertices(i,a.Oprev,n)):(i.mesh.splitEdge(a.Sym),i.mesh.splice(n,a.Oprev),r.dirty=s.dirty=!0)}else{if(je.edgeSign(n.Dst,a.Org,n.Org)<0)return!1;e.regionAbove(r).dirty=r.dirty=!0,i.mesh.splitEdge(n.Sym),i.mesh.splice(a.Oprev,n)}return!0},e.checkForLeftSplice=function(i,r){var s,n=e.regionBelow(r),a=r.eUp,o=n.eUp;if(Xe(!je.vertEq(a.Dst,o.Dst)),je.vertLeq(a.Dst,o.Dst)){if(je.edgeSign(a.Dst,o.Dst,a.Org)<0)return!1;e.regionAbove(r).dirty=r.dirty=!0,s=i.mesh.splitEdge(a),i.mesh.splice(o.Sym,s),s.Lface.inside=r.inside}else{if(je.edgeSign(o.Dst,a.Dst,o.Org)>0)return!1;r.dirty=n.dirty=!0,s=i.mesh.splitEdge(o),i.mesh.splice(a.Lnext,o.Sym),s.Rface.inside=r.inside}return!0},e.checkForIntersect=function(i,r){var s,n,a=e.regionBelow(r),o=r.eUp,l=a.eUp,u=o.Org,h=l.Org,d=o.Dst,c=l.Dst,p=new ef;if(Xe(!je.vertEq(c,d)),Xe(je.edgeSign(d,i.event,u)<=0),Xe(je.edgeSign(c,i.event,h)>=0),Xe(u!==i.event&&h!==i.event),Xe(!r.fixUpperEdge&&!a.fixUpperEdge),u===h||Math.min(u.t,d.t)>Math.max(h.t,c.t))return!1;if(je.vertLeq(u,h)){if(je.edgeSign(c,u,h)>0)return!1}else if(je.edgeSign(d,h,u)<0)return!1;return e.debugEvent(i),je.intersect(d,u,c,h,p),Xe(Math.min(u.t,d.t)<=p.t),Xe(p.t<=Math.max(h.t,c.t)),Xe(Math.min(c.s,d.s)<=p.s),Xe(p.s<=Math.max(h.s,u.s)),je.vertLeq(p,i.event)&&(p.s=i.event.s,p.t=i.event.t),s=je.vertLeq(u,h)?u:h,je.vertLeq(s,p)&&(p.s=s.s,p.t=s.t),je.vertEq(p,u)||je.vertEq(p,h)?(e.checkForRightSplice(i,r),!1):!je.vertEq(d,i.event)&&je.edgeSign(d,i.event,p)>=0||!je.vertEq(c,i.event)&&je.edgeSign(c,i.event,p)<=0?c===i.event?(i.mesh.splitEdge(o.Sym),i.mesh.splice(l.Sym,o),r=e.topLeftRegion(i,r),o=e.regionBelow(r).eUp,e.finishLeftRegions(i,e.regionBelow(r),a),e.addRightEdges(i,r,o.Oprev,o,o,!0),!0):d===i.event?(i.mesh.splitEdge(l.Sym),i.mesh.splice(o.Lnext,l.Oprev),a=r,r=e.topRightRegion(r),n=e.regionBelow(r).eUp.Rprev,a.eUp=l.Oprev,l=e.finishLeftRegions(i,a,null),e.addRightEdges(i,r,l.Onext,o.Rprev,n,!0),!0):(je.edgeSign(d,i.event,p)>=0&&(e.regionAbove(r).dirty=r.dirty=!0,i.mesh.splitEdge(o.Sym),o.Org.s=i.event.s,o.Org.t=i.event.t),je.edgeSign(c,i.event,p)<=0&&(r.dirty=a.dirty=!0,i.mesh.splitEdge(l.Sym),l.Org.s=i.event.s,l.Org.t=i.event.t),!1):(i.mesh.splitEdge(o.Sym),i.mesh.splitEdge(l.Sym),i.mesh.splice(l.Oprev,o),o.Org.s=p.s,o.Org.t=p.t,o.Org.pqHandle=i.pq.insert(o.Org),e.getIntersectData(i,o.Org,u,d,h,c),e.regionAbove(r).dirty=r.dirty=a.dirty=!0,!1)},e.walkDirtyRegions=function(i,r){for(var s,n,a=e.regionBelow(r);;){for(;a.dirty;)r=a,a=e.regionBelow(a);if(!r.dirty&&(a=r,(r=e.regionAbove(r))===null||!r.dirty))return;if(r.dirty=!1,s=r.eUp,n=a.eUp,s.Dst!==n.Dst&&e.checkForLeftSplice(i,r)&&(a.fixUpperEdge?(e.deleteRegion(i,a),i.mesh.delete(n),n=(a=e.regionBelow(r)).eUp):r.fixUpperEdge&&(e.deleteRegion(i,r),i.mesh.delete(s),s=(r=e.regionAbove(a)).eUp)),s.Org!==n.Org){if(s.Dst===n.Dst||r.fixUpperEdge||a.fixUpperEdge||s.Dst!==i.event&&n.Dst!==i.event)e.checkForRightSplice(i,r);else if(e.checkForIntersect(i,r))return}s.Org===n.Org&&s.Dst===n.Dst&&(e.addWinding(n,s),e.deleteRegion(i,r),i.mesh.delete(s),r=e.regionAbove(a))}},e.connectRightVertex=function(i,r,s){var n,a=s.Onext,o=e.regionBelow(r),l=r.eUp,u=o.eUp,h=!1;l.Dst!==u.Dst&&e.checkForIntersect(i,r),je.vertEq(l.Org,i.event)&&(i.mesh.splice(a.Oprev,l),r=e.topLeftRegion(i,r),a=e.regionBelow(r).eUp,e.finishLeftRegions(i,e.regionBelow(r),o),h=!0),je.vertEq(u.Org,i.event)&&(i.mesh.splice(s,u.Oprev),s=e.finishLeftRegions(i,o,null),h=!0),h?e.addRightEdges(i,r,s.Onext,a,a,!0):(n=je.vertLeq(u.Org,l.Org)?u.Oprev:l,n=i.mesh.connect(s.Lprev,n),e.addRightEdges(i,r,n,n.Onext,n.Onext,!1),n.Sym.activeRegion.fixUpperEdge=!0,e.walkDirtyRegions(i,r))},e.connectLeftDegenerate=function(i,r,s){var n,a,o,l,u;return n=r.eUp,je.vertEq(n.Org,s)?(Xe(!1),void e.spliceMergeVertices(i,n,s.anEdge)):je.vertEq(n.Dst,s)?(Xe(!1),r=e.topRightRegion(r),a=l=(o=(u=e.regionBelow(r)).eUp.Sym).Onext,u.fixUpperEdge&&(Xe(a!==o),e.deleteRegion(i,u),i.mesh.delete(o),o=a.Oprev),i.mesh.splice(s.anEdge,o),je.edgeGoesLeft(a)||(a=null),void e.addRightEdges(i,r,o.Onext,l,a,!0)):(i.mesh.splitEdge(n.Sym),r.fixUpperEdge&&(i.mesh.delete(n.Onext),r.fixUpperEdge=!1),i.mesh.splice(s.anEdge,n),void e.sweepEvent(i,s))},e.connectLeftVertex=function(i,r){var s,n,a,o,l,u,h=new IM;if(h.eUp=r.anEdge.Sym,s=i.dict.search(h).key,n=e.regionBelow(s)){if(o=s.eUp,l=n.eUp,je.edgeSign(o.Dst,r,o.Org)===0)return void e.connectLeftDegenerate(i,s,r);a=je.vertLeq(l.Dst,o.Dst)?s:n,s.inside||a.fixUpperEdge?(u=a===s?i.mesh.connect(r.anEdge.Sym,o.Lnext):i.mesh.connect(l.Dnext,r.anEdge).Sym,a.fixUpperEdge?e.fixUpperEdge(i,a,u):e.computeWinding(i,e.addRegionBelow(i,s,u)),e.sweepEvent(i,r)):e.addRightEdges(i,s,r.anEdge,r.anEdge,null,!0)}},e.sweepEvent=function(i,r){i.event=r,e.debugEvent(i);for(var s=r.anEdge;s.activeRegion===null;)if((s=s.Onext)===r.anEdge)return void e.connectLeftVertex(i,r);var n=e.topLeftRegion(i,s.activeRegion);Xe(n!==null);var a=e.regionBelow(n),o=a.eUp,l=e.finishLeftRegions(i,a,null);l.Onext===o?e.connectRightVertex(i,n,l):e.addRightEdges(i,n,l.Onext,o,o,!0)},e.addSentinel=function(i,r,s,n){var a=new IM,o=i.mesh.makeEdge();o.Org.s=s,o.Org.t=n,o.Dst.s=r,o.Dst.t=n,i.event=o.Dst,a.eUp=o,a.windingNumber=0,a.inside=!1,a.fixUpperEdge=!1,a.sentinel=!0,a.dirty=!1,a.nodeUp=i.dict.insert(a)},e.initEdgeDict=function(i){i.dict=new JY(i,e.edgeLeq);var r=i.bmax[0]-i.bmin[0],s=i.bmax[1]-i.bmin[1],n=i.bmin[0]-r,a=i.bmax[0]+r,o=i.bmin[1]-s,l=i.bmax[1]+s;e.addSentinel(i,n,a,o),e.addSentinel(i,n,a,l)},e.doneEdgeDict=function(i){for(var r,s=0;(r=i.dict.min().key)!==null;)r.sentinel||(Xe(r.fixUpperEdge),Xe(++s===1)),Xe(r.windingNumber===0),e.deleteRegion(i,r)},e.removeDegenerateEdges=function(i){var r,s,n,a=i.mesh.eHead;for(r=a.next;r!==a;r=s)s=r.next,n=r.Lnext,je.vertEq(r.Org,r.Dst)&&r.Lnext.Lnext!==r&&(e.spliceMergeVertices(i,n,r),i.mesh.delete(r),n=(r=n).Lnext),n.Lnext===r&&(n!==r&&((n===s||n===s.Sym)&&(s=s.next),i.mesh.delete(n)),(r===s||r===s.Sym)&&(s=s.next),i.mesh.delete(r))},e.initPriorityQ=function(i){var r,s,n,a=0;for(s=(n=i.mesh.vHead).next;s!==n;s=s.next)a++;for(a+=8,r=i.pq=new QY(a,je.vertLeq),s=(n=i.mesh.vHead).next;s!==n;s=s.next)s.pqHandle=r.insert(s);return s===n&&(r.init(),!0)},e.donePriorityQ=function(i){i.pq=null},e.removeDegenerateFaces=function(i,r){var s,n,a;for(s=r.fHead.next;s!==r.fHead;s=n)n=s.next,Xe((a=s.anEdge).Lnext!==a),a.Lnext.Lnext===a&&(e.addWinding(a.Onext,a),i.mesh.delete(a));return!0},e.computeInterior=function(i,r){var s,n;if(r===void 0&&(r=!0),e.removeDegenerateEdges(i),!e.initPriorityQ(i))return!1;for(e.initEdgeDict(i);(s=i.pq.extractMin())!==null;){for(;(n=i.pq.min())!==null&&je.vertEq(n,s);)n=i.pq.extractMin(),e.spliceMergeVertices(i,s.anEdge,n.anEdge);e.sweepEvent(i,s)}return i.event=i.dict.min().key.eUp.Org,e.debugEvent(i),e.doneEdgeDict(i),e.donePriorityQ(i),!!e.removeDegenerateFaces(i,i.mesh)&&(r&&i.mesh.check(),!0)},e}(),Fft=function(){function e(){this.mesh=new PO,this.normal=[0,0,0],this.sUnit=[0,0,0],this.tUnit=[0,0,0],this.bmin=[0,0],this.bmax=[0,0],this.windingRule=ss.ODD,this.dict=null,this.pq=null,this.event=null,this.vertexIndexCounter=0,this.vertices=[],this.vertexIndices=[],this.vertexCount=0,this.elements=[],this.elementCount=0}return e.prototype.dot_=function(i,r){return i[0]*r[0]+i[1]*r[1]+i[2]*r[2]},e.prototype.normalize_=function(i){var r=i[0]*i[0]+i[1]*i[1]+i[2]*i[2];if(!r)throw"Zero-size vector!";r=Math.sqrt(r),i[0]/=r,i[1]/=r,i[2]/=r},e.prototype.longAxis_=function(i){var r=0;return Math.abs(i[1])>Math.abs(i[0])&&(r=1),Math.abs(i[2])>Math.abs(i[r])&&(r=2),r},e.prototype.computeNormal_=function(i){var r,s,n,a,o,l,u=[0,0,0],h=[0,0,0],d=[0,0,0],c=[0,0,0],p=[0,0,0],m=[null,null,null],f=[null,null,null],g=this.mesh.vHead;r=g.next;for(var y=0;y<3;++y)a=r.coords[y],h[y]=a,f[y]=r,u[y]=a,m[y]=r;for(r=g.next;r!==g;r=r.next)for(var v=0;v<3;++v)(a=r.coords[v])<h[v]&&(h[v]=a,f[v]=r),a>u[v]&&(u[v]=a,m[v]=r);var b=0;if(u[1]-h[1]>u[0]-h[0]&&(b=1),u[2]-h[2]>u[b]-h[b]&&(b=2),h[b]>=u[b])return i[0]=0,i[1]=0,void(i[2]=1);for(l=0,s=f[b],n=m[b],d[0]=s.coords[0]-n.coords[0],d[1]=s.coords[1]-n.coords[1],d[2]=s.coords[2]-n.coords[2],r=g.next;r!==g;r=r.next)c[0]=r.coords[0]-n.coords[0],c[1]=r.coords[1]-n.coords[1],c[2]=r.coords[2]-n.coords[2],p[0]=d[1]*c[2]-d[2]*c[1],p[1]=d[2]*c[0]-d[0]*c[2],p[2]=d[0]*c[1]-d[1]*c[0],(o=p[0]*p[0]+p[1]*p[1]+p[2]*p[2])>l&&(l=o,i[0]=p[0],i[1]=p[1],i[2]=p[2]);l<=0&&(i[0]=i[1]=i[2]=0,i[this.longAxis_(d)]=1)},e.prototype.checkOrientation_=function(){for(var i,r,s=this.mesh.fHead,n=this.mesh.vHead,a=0,o=s.next;o!==s;o=o.next)if(!((r=o.anEdge).winding<=0))do a+=(r.Org.s-r.Dst.s)*(r.Org.t+r.Dst.t),r=r.Lnext;while(r!==o.anEdge);if(a<0){for(i=n.next;i!==n;i=i.next)i.t=-i.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},e.prototype.projectPolygon_=function(){var i,r,s=this.mesh.vHead,n=[0,0,0],a=!1;n[0]=this.normal[0],n[1]=this.normal[1],n[2]=this.normal[2],!n[0]&&!n[1]&&!n[2]&&(this.computeNormal_(n),a=!0),i=this.sUnit,r=this.tUnit;var o=this.longAxis_(n);i[o]=0,i[(o+1)%3]=1,i[(o+2)%3]=0,r[o]=0,r[(o+1)%3]=0,r[(o+2)%3]=n[o]>0?1:-1;for(var l=s.next;l!==s;l=l.next)l.s=this.dot_(l.coords,i),l.t=this.dot_(l.coords,r);a&&this.checkOrientation_();for(var u=!0,h=s.next;h!==s;h=h.next)u?(this.bmin[0]=this.bmax[0]=h.s,this.bmin[1]=this.bmax[1]=h.t,u=!1):(h.s<this.bmin[0]&&(this.bmin[0]=h.s),h.s>this.bmax[0]&&(this.bmax[0]=h.s),h.t<this.bmin[1]&&(this.bmin[1]=h.t),h.t>this.bmax[1]&&(this.bmax[1]=h.t))},e.prototype.addWinding_=function(i,r){i.winding+=r.winding,i.Sym.winding+=r.Sym.winding},e.prototype.tessellateMonoRegion_=function(i,r){var s,n;if((s=r.anEdge).Lnext===s||s.Lnext.Lnext===s)throw"Mono region invalid";for(;je.vertLeq(s.Dst,s.Org);s=s.Lprev);for(;je.vertLeq(s.Org,s.Dst);s=s.Lnext);for(n=s.Lprev;s.Lnext!==n;)if(je.vertLeq(s.Dst,n.Org)){for(;n.Lnext!==s&&(je.edgeGoesLeft(n.Lnext)||je.edgeSign(n.Org,n.Dst,n.Lnext.Dst)<=0);)n=i.connect(n.Lnext,n).Sym;n=n.Lprev}else{for(;n.Lnext!==s&&(je.edgeGoesRight(s.Lprev)||je.edgeSign(s.Dst,s.Org,s.Lprev.Org)>=0);)s=i.connect(s,s.Lprev).Sym;s=s.Lnext}if(n.Lnext===s)throw"Mono region invalid";for(;n.Lnext.Lnext!==s;)n=i.connect(n.Lnext,n).Sym;return!0},e.prototype.tessellateInterior_=function(i){for(var r,s=i.fHead.next;s!==i.fHead;s=r)if(r=s.next,s.inside&&!this.tessellateMonoRegion_(i,s))return!1;return!0},e.prototype.discardExterior_=function(i){for(var r,s=i.fHead.next;s!==i.fHead;s=r)r=s.next,s.inside||i.zapFace(s)},e.prototype.setWindingNumber_=function(i,r,s){for(var n,a=i.eHead.next;a!==i.eHead;a=n)n=a.next,a.Rface.inside!==a.Lface.inside?a.winding=a.Lface.inside?r:-r:s?i.delete(a):a.winding=0},e.prototype.getNeighbourFace_=function(i){return i.Rface&&i.Rface.inside?i.Rface.n:-1},e.prototype.outputPolymesh_=function(i,r,s,n){var a,o,l=0,u=0;s>3&&i.mergeConvexFaces(s);for(var h=i.vHead.next;h!==i.vHead;h=h.next)h.n=-1;for(var d=i.fHead.next;d!==i.fHead;d=d.next)if(d.n=-1,d.inside){a=d.anEdge,o=0;do(h=a.Org).n===-1&&(h.n=u,u++),o++,a=a.Lnext;while(a!==d.anEdge);if(o>s)throw"Face vertex greater that support polygon";d.n=l,++l}for(this.elementCount=l,r===Ea.CONNECTED_POLYGONS&&(l*=2),this.elements=[],this.elements.length=l*s,this.vertexCount=u,this.vertices=[],this.vertices.length=u*n,this.vertexIndices=[],this.vertexIndices.length=u,h=i.vHead.next;h!==i.vHead;h=h.next)if(h.n!==-1){var c=h.n*n;this.vertices[c+0]=h.coords[0],this.vertices[c+1]=h.coords[1],n>2&&(this.vertices[c+2]=h.coords[2]),this.vertexIndices[h.n]=h.idx}var p=0;for(d=i.fHead.next;d!==i.fHead;d=d.next)if(d.inside){a=d.anEdge,o=0;do h=a.Org,this.elements[p++]=h.n,o++,a=a.Lnext;while(a!==d.anEdge);for(var m=o;m<s;++m)this.elements[p++]=-1;if(r===Ea.CONNECTED_POLYGONS){a=d.anEdge;do this.elements[p++]=this.getNeighbourFace_(a),a=a.Lnext;while(a!==d.anEdge);for(var f=o;f<s;++f)this.elements[p++]=-1}}},e.prototype.outputContours_=function(i,r){var s,n,a=0,o=0;this.vertexCount=0,this.elementCount=0;for(var l=i.fHead.next;l!==i.fHead;l=l.next)if(l.inside){n=s=l.anEdge;do this.vertexCount++,s=s.Lnext;while(s!==n);this.elementCount++}this.elements=[],this.elements.length=2*this.elementCount,this.vertices=[],this.vertices.length=this.vertexCount*r,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var u=0,h=0,d=0;for(a=0,l=i.fHead.next;l!==i.fHead;l=l.next)if(l.inside){o=0,n=s=l.anEdge;do this.vertices[u++]=s.Org.coords[0],this.vertices[u++]=s.Org.coords[1],r>2&&(this.vertices[u++]=s.Org.coords[2]),this.vertexIndices[h++]=this.vertexIdCallback?this.vertexIdCallback(s):s.Org.idx,o++,s=s.Lnext;while(s!==n);this.elements[d++]=a,this.elements[d++]=o,a+=o}},e.prototype.addContour=function(i,r){this.mesh===null&&(this.mesh=new PO),i<2&&(i=2),i>3&&(i=3);for(var s=null,n=0;n<r.length;n+=i)s===null?(s=this.mesh.makeEdge(),this.mesh.splice(s,s.Sym)):(this.mesh.splitEdge(s),s=s.Lnext),s.Org.coords[0]=r[n+0],s.Org.coords[1]=r[n+1],s.Org.coords[2]=i>2?r[n+2]:0,s.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(s),s.winding=1,s.Sym.winding=-1},e.prototype.tesselate=function(i,r,s,n,a,o){if(i===void 0&&(i=ss.ODD),r===void 0&&(r=Ea.POLYGONS),o===void 0&&(o=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,a&&(this.normal[0]=a[0],this.normal[1]=a[1],this.normal[2]=a[2]),this.windingRule=i,n<2&&(n=2),n>3&&(n=3),!this.mesh)return!1;this.projectPolygon_(),tK.computeInterior(this,o);var l=this.mesh;return r===Ea.BOUNDARY_CONTOURS?this.setWindingNumber_(l,1,!0):this.tessellateInterior_(l),o&&l.check(),r===Ea.BOUNDARY_CONTOURS?this.outputContours_(l,n):this.outputPolymesh_(l,r,s,n),!0},e}(),ss.ODD,ss.NONZERO,ss.POSITIVE,ss.NEGATIVE,ss.ABS_GEQ_TWO,Ea.POLYGONS,Ea.CONNECTED_POLYGONS,Ea.BOUNDARY_CONTOURS});function Uft(t,e){let i=t.length/2;if(i<2)return[];let r=0;for(let l=0;l<i;l++){let u=(l+1)%i;r+=t[2*l]*t[2*u+1]-t[2*u]*t[2*l+1]}let s=r>0!==e?1:-1,n=[];for(let l=0;l<i;l++){let u=(l+1)%i,h=t[2*u]-t[2*l],d=t[2*u+1]-t[2*l+1],c=Math.hypot(h,d);n.push(c>0?[s*d/c,-s*h/c]:[0,0])}let a=Math.cos(40*Math.PI/180),o=(l,u)=>{if(l[0]*u[0]+l[1]*u[1]<=a)return l;let[h,d]=[l[0]+u[0],l[1]+u[1]],c=Math.hypot(h,d);return c>0?[h/c,d/c]:l};return n.map((l,u)=>[o(l,n[(u+i-1)%i]),o(l,n[(u+1)%i])])}function jft(t,e,i){let r=t.length/2,s=new Float32Array(r+1);if(!(e>0)||!(i>0)||r<2)return{u:s,vScale:0};let n=0;for(let a=0;a<r;a++){let o=(a+1)%r;n+=Math.hypot((t[2*o]-t[2*a])/e,(t[2*o+1]-t[2*a+1])/i),s[a+1]=n}return{u:s,vScale:Math.sqrt(e*i)}}function Gft(t,e,i){for(let r=0;r<i.length;r+=3){let s=3*i[r],n=3*i[r+1],a=3*i[r+2],o=t[n]-t[s],l=t[n+1]-t[s+1],u=t[n+2]-t[s+2],h=t[a]-t[s],d=t[a+1]-t[s+1],c=t[a+2]-t[s+2],p=u*h-o*c,m=o*d-l*h;if((l*c-u*d)*(e[s]+e[n]+e[a])+p*(e[s+1]+e[n+1]+e[a+1])+m*(e[s+2]+e[n+2]+e[a+2])<0){let f=i[r+1];i[r+1]=i[r+2],i[r+2]=f}}}var AG,Wft,CG,AR,LU,qft=G(()=>{}),EG=G(()=>{AG={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},Wft={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},CG={vertices:[-160,160,160,-160,160,160,-160,-160],vertexIndices:[1,3,0,2],vertexCount:4,elements:[0,1,2,1,0,3],elementCount:2,mesh:void 0}}),f3t=G(()=>{dt(),tT(),ir(),qft(),EG(),AR=class extends ye{constructor(t,e,i=12,r=ss.ODD,s){super(),this.type="FlatExtrusionGeometry",this._nearSide=new Uint8Array(0),this._vScale=0,this._shape=t,this._depth=e,this._curveSegments=i,this._windingRule=r,this._uvPitch=s;let n,a=[t.extractShapePointsToFlatArray([],i),...t.shapeHoles.map(k=>k.extractShapePointsToFlatArray([],i))];try{n=X2({contours:a,windingRule:r,elementType:Ea.POLYGONS,polySize:3,vertexSize:2,strict:!0})}catch{n=CG}let o=n?.vertexCount??0,l=n?.elementCount??0,u=1/0,h=1/0,d=-1/0,c=-1/0;for(let k of a)for(let z=0;z<k.length;z+=2)k[z]<u&&(u=k[z]),k[z]>d&&(d=k[z]),k[z+1]<h&&(h=k[z+1]),k[z+1]>c&&(c=k[z+1]);let p=this._uvPitch,m=p??(d-u||1),f=p??(c-h||1),g=p===void 0?u:0,y=p===void 0?h:0,v=a.map((k,z)=>Uft(k,z>0)),b=0;for(let k of v)b+=k.length;let _=2*o+4*b,x=3*l*2+6*b,S=new Float32Array(3*_),w=new Float32Array(3*_),T=new Float32Array(2*_),A=new Uint32Array(x),M=new Uint8Array(_),C=0,R=0,O=0,N=!1,B=(k,z,L,V,q,j,Q=(k-g)/m,it=(z-y)/f)=>{let at=3*R;S[at]=k,S[at+1]=z,S[at+2]=L,w[at]=V,w[at+1]=q,w[at+2]=j,M[R]=L===e?N?2:1:0,T[2*R]=Q,T[2*R+1]=it,R++};if(n!==void 0)for(let[k,z]of[[e,1],[0,-1]]){let L=R;for(let V=0;V<o;V++)B(n.vertices[2*V],n.vertices[2*V+1],k,0,0,z);for(let V=0;V<l;V++){let[q,j,Q]=[n.elements[3*V],n.elements[3*V+1],n.elements[3*V+2]];A[O++]=L+q,A[O++]=L+(z>0?j:Q),A[O++]=L+(z>0?Q:j)}}N=!0;for(let k=0;k<a.length;k++){let z=a[k],L=v[k],V=z.length/2,{u:q,vScale:j}=jft(z,m,f);C=j;let Q=j===0?0:e/j;for(let it=0;it<L.length;it++){let at=(it+1)%V,[St,yt]=L[it],[Y,pt]=[q[it],q[it+1]],xt=R;B(z[2*it],z[2*it+1],e,St[0],St[1],0,Y,Q),B(z[2*it],z[2*it+1],0,St[0],St[1],0,Y,0),B(z[2*at],z[2*at+1],e,yt[0],yt[1],0,pt,Q),B(z[2*at],z[2*at+1],0,yt[0],yt[1],0,pt,0),A[O++]=xt,A[O++]=xt+1,A[O++]=xt+2,A[O++]=xt+3,A[O++]=xt+2,A[O++]=xt+1}}Gft(S,w,A),this.setAttribute("position",new we(S,3)),this.setAttribute("normal",new we(w,3)),this.setAttribute("uv",new we(T,2)),this.setIndex(new we(A,1)),this._nearSide=M,this._vScale=C}takeDepthStateFrom(t){let e=t;e._nearSide!==void 0&&(this._depth=e._depth??this._depth,this._nearSide=e._nearSide,this._vScale=e._vScale??this._vScale)}canShiftDepthTo(t){return this._nearSide.length>0&&this._depth>0&&t>0}shiftDepthTo(t){if(!this.canShiftDepthTo(t))return!1;let e=t-this._depth;if(this._depth=t,e===0)return!0;let i=this.getAttribute("position");if(i===void 0)return!1;let r=i.array,s=this.getAttribute("uv"),n=s?.array,a=this._vScale>0?e/this._vScale:0,o=this._nearSide;for(let l=0;l<o.length;l++){let u=o[l];u!==0&&(r[3*l+2]+=e,u===2&&n!==void 0&&(n[2*l+1]+=a))}return i.needsUpdate=!0,s!==void 0&&a!==0&&(s.needsUpdate=!0),this.refreshDepthBounds(t),!0}refreshDepthBounds(t){if(this.boundingBox===null&&this.boundingSphere===null)return;this.boundingBox===null&&this.computeBoundingBox();let e=this.boundingBox;e.min.z=Math.min(0,t),e.max.z=Math.max(0,t),this.boundingSphere!==null&&e.getBoundingSphere(this.boundingSphere)}clone(){let t=new AR(this._shape,this._depth,this._curveSegments,this._windingRule);return t.userData=x5(this.userData),t}}}),Hft=G(()=>{dt(),tT(),ir(),EG(),LU=class extends ye{constructor(t,e=12,i={}){super(),this.type="ShapeGeometry",this.windingRule=ss.ODD,this.elementType=Ea.POLYGONS,this.polySize=3,this.vertexSize=2,this.strict=!0,this._shape=t,this._curveSegments=e,this._triangulationOptions=Object.assign({windingRule:ss.ODD,elementType:Ea.POLYGONS,polySize:3,vertexSize:2,strict:!0},i);let r,s,n,a=this._shape.extractShapePointsToFlatArray([],this._curveSegments),o=this._shape.shapeHoles.map(c=>c.extractShapePointsToFlatArray([],this._curveSegments)),l=!0,u=!0;for(let c=0,p=a.length/2;c<p;c++){let m=2*c,f=a[m+0],g=a[m+1];if(s!==void 0&&f!==s&&(l=!1),n!==void 0&&g!==n&&(u=!1),s=f,n=g,!l&&!u)break}if(!l&&!u)try{r=X2({contours:[a,...o],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})}catch{r=AG}let h=r?.vertexCount??1,d=r?.elementCount??1;if(this._positionAttribute=new we(new Float32Array(3*h),3),this._normalAttribute=new we(new Float32Array(3*h),3),this._uvAttribute=new we(new Float32Array(2*h),2),this._indexAttribute=new we(new Uint32Array(3*d),1),r){let c=1/0,p=-1/0,m=1/0,f=-1/0;for(let v=0,b=h;v<b;v++){let _=2*v,x=r.vertices[_+0],S=r.vertices[_+1];x<c&&(c=x),x>p&&(p=x),S<m&&(m=S),S>f&&(f=S)}let g=p-c,y=f-m;for(let v=0,b=h;v<b;v++){let _=2*v,x=r.vertices[_+0],S=r.vertices[_+1],w=(x-c)/g,T=(S-m)/y;this._positionAttribute.setXYZ(v,x,S,0),this._normalAttribute.setXYZ(v,0,0,1),this._uvAttribute.setXY(v,w,T)}for(let v=0,b=d;v<b;v++){let _=3*v,x=r.elements[_+0],S=r.elements[_+1],w=r.elements[_+2];this._indexAttribute.setX(_+0,x),this._indexAttribute.setX(_+1,S),this._indexAttribute.setX(_+2,w)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,3*(r?.elementCount??1))}clone(){let t=new LU(this._shape,this._curveSegments);return t.userData=x5(this.userData),t}}});function g3t(t){return eK||(eK=async function(){let e=t??"https://unpkg.com/@splinetool/runtime@2.0.60/build",i=Promise.resolve().then(()=>(bq(),vq)),[r,s]=await Promise.all([i,fetch(`${e}/bevel.wasm`).then(n=>n.arrayBuffer())]);await r.default({module_or_path:s}),eT=r}())}function y3t(t){let e=!1;return t.scene.objects.traverse((i,r)=>{let s=r.geometry;if(s!==void 0&&(Kft.has(s.type)&&s.depth!==void 0&&s.depth>0&&(s.extrudeBevelSize??0)>0&&(e=!0),s.type==="PathGeometry")){let n=s.extrusion;n!==void 0&&n.capType==="round"&&(n.bevel??0)>0&&(e=!0)}}),e}function $ft(t,e){let i=[t.extractShapePointsToFlatArray([],e)];for(let o of t.shapeHoles)i.push(o.extractShapePointsToFlatArray([],e));let r=0;for(let o of i)r+=o.length>>1;let s=new Float64Array(2*r),n=new Uint32Array(i.length),a=0;for(let o=0;o<i.length;o++)s.set(i[o],2*a),a+=i[o].length>>1,n[o]=a;return{points:s,ends:n}}function CR(t,e,i,r,s,n){let a=t.positions.length/3,o=s.elements,l=Zft.getNormalMatrix(s).elements;for(let h=0;h<a;h++){let d=3*h,c=3*(i+h),p=t.positions[d],m=t.positions[d+1],f=t.positions[d+2];e.positions[c]=o[0]*p+o[4]*m+o[8]*f+o[12],e.positions[c+1]=o[1]*p+o[5]*m+o[9]*f+o[13],e.positions[c+2]=o[2]*p+o[6]*m+o[10]*f+o[14];let g=t.normals[d],y=t.normals[d+1],v=t.normals[d+2];e.normals[c]=l[0]*g+l[3]*y+l[6]*v,e.normals[c+1]=l[1]*g+l[4]*y+l[7]*v,e.normals[c+2]=l[2]*g+l[5]*y+l[8]*v;let b=2*(i+h);if(n===void 0)e.uvs[b]=t.uvs[2*h],e.uvs[b+1]=t.uvs[2*h+1];else{let[_,x]=n(p,m,t.uvs[2*h],t.uvs[2*h+1]);e.uvs[b]=_,e.uvs[b+1]=x}}let u=s.determinant()<0;for(let h=0;h<t.indices.length;h+=3)e.indices[r+h]=t.indices[h]+i,e.indices[r+h+1]=t.indices[h+(u?2:1)]+i,e.indices[r+h+2]=t.indices[h+(u?1:2)]+i}function Xft(t){let{owner:e,shape:i,curveSegments:r,assembledAt:s,bevel:n,bevelSegments:a}=t,o=function(c,p){let m=[p],f=g=>{m.push(g.points.length,g.isClosed?1:0,g.roundness??0);for(let y of g.points){m.push(y.roundness??0,y.position.x,y.position.y);for(let v of y.controls)m.push(v.position.x,v.position.y)}m.push(g.shapeHoles.length);for(let y of g.shapeHoles)f(y)};return f(c),function(g){let y=2166136261;for(let v=0;v<g.length;v++)y^=g[v],y=Math.imul(y,16777619)>>>0;return y}(new Uint8Array(new Float64Array(m).buffer))}(i,r),l=e??`outline:${o}`,u=`${n}/${a}`,h=ER.get(l);if(h!==void 0&&h.outlineVersion===o&&h.capKey===u&&(t.stillServes?.(h)??1))return FU.placements++,h.cap;let d=function(c,p,m,f,g){let{points:y,ends:v}=$ft(c,p);return eT.assemble_cap(y,v,m,f,0,Math.max(1,Math.floor(g)),Yft,40)}(i,r,s,n,a);FU.assemblies++;try{let c=function(p,m){return function(f,g,y,v,b){let _=1/0;for(let x=2;x<f.length;x+=3)f[x]<_&&(_=f[x]);if(_===1/0&&(_=0),_!==0)for(let x=2;x<f.length;x+=3)f[x]-=_;return{positions:f,normals:g,uvs:y,indices:v,rise:b-_}}(p.positions(),p.normals(),p.uvs(),p.indices(),m)}(d,s);return ER.set(l,{outlineVersion:o,capKey:u,assembledAt:s,cap:c}),c}finally{d.free()}}function X1(t,e){return .5*e>1.001*t}var eT,Yft,eK,Kft,Zft,iK,rK,sK,ER,FU,UU,xm,Kv=G(()=>{dt(),ir(),qft(),Yft=.4,Kft=new Set(["VectorGeometry","TextGeometry","InputGeometry","PolygonGeometry","RectangleGeometry","StarGeometry","TriangleGeometry","EllipseGeometry"]),Zft=new Ts,iK=new bt,rK=new bt,sK=new bt().makeScale(1,1,-1),ER=new Map,FU={assemblies:0,placements:0},UU=class extends ye{constructor(t,e,i=0,r=12,s=3,n,a){if(super(),this.type="ShapeGeometry",this._nearSide=new Uint8Array(0),this._effectiveBevel=0,this._vScale=0,eT===void 0)throw new Error("bevel-wasm is not loaded");this._shape=t,this._uvPitch=a,this._depth=e,this._bevel=i,this._curveSegments=r,this._bevelSegments=s,this._ownerId=n,this.rebuild()}takeDepthStateFrom(t){let e=t;e._nearSide!==void 0&&(this._depth=e._depth??this._depth,this._nearSide=e._nearSide,this._vScale=e._vScale??this._vScale,this._effectiveBevel=e._effectiveBevel??this._effectiveBevel)}canShiftDepthTo(t){return this._nearSide.length>0&&X1(this._effectiveBevel,t)&&X1(this._effectiveBevel,this._depth)}shiftDepthTo(t){if(!this.canShiftDepthTo(t))return!1;let e=t-this._depth;if(this._depth=t,e===0)return!0;let i=this.getAttribute("position");if(i===void 0)return!1;let r=i.array,s=this.getAttribute("uv"),n=s?.array,a=this._vScale>0?e/this._vScale:0,o=this._nearSide;for(let l=0;l<o.length;l++){let u=o[l];u!==0&&(r[3*l+2]+=e,u===2&&n!==void 0&&(n[2*l+1]+=a))}return i.needsUpdate=!0,s!==void 0&&a!==0&&(s.needsUpdate=!0),this.refreshDepthBounds(t),!0}refreshDepthBounds(t){if(this.boundingBox===null&&this.boundingSphere===null)return;this.boundingBox===null&&this.computeBoundingBox();let e=this.boundingBox;e.min.z=Math.min(0,t),e.max.z=Math.max(0,t),this.boundingSphere!==null&&e.getBoundingSphere(this.boundingSphere)}setDepth(t){t!==this._depth&&(this._depth=t,this.rebuild(),this.computeBoundingSphere(),this.computeBoundingBox())}rebuild(){let t=Xft({owner:this._ownerId,shape:this._shape,curveSegments:this._curveSegments,assembledAt:this._depth,bevel:this._bevel,bevelSegments:this._bevelSegments,stillServes:a=>X1(a.cap.rise,this._depth)&&X1(a.cap.rise,a.assembledAt)}),e=function(a,o,l,u,h){let d=u.positions.length/3,c=l-u.rise,p=u.rise,{points:m,ends:f}=$ft(a,o),g=1/0,y=1/0,v=-1/0,b=-1/0;for(let q=0;q<m.length;q+=2)m[q]<g&&(g=m[q]),m[q]>v&&(v=m[q]),m[q+1]<y&&(y=m[q+1]),m[q+1]>b&&(b=m[q+1]);let _=h??v-g,x=h??b-y,S=[],w=0;for(let q of f)S.push({at:w,count:q-w}),w=q;let T=0;for(let q of S)T+=q.count;let A=2*d+4*T,M=new Float32Array(3*A),C=new Float32Array(3*A),R=new Float32Array(2*A),O=new Uint32Array(2*u.indices.length+6*T),N=new Uint8Array(A),B=0,k=h===void 0?void 0:(q,j)=>[q/h,j/h],z={positions:M,normals:C,uvs:R,indices:O};CR(u,z,0,0,iK.makeTranslation(0,0,c),k),CR(u,z,d,u.indices.length,rK.makeTranslation(0,0,p).multiply(sK),k),N.fill(1,0,d);let L=2*d,V=2*u.indices.length;for(let q=0;q<S.length;q++){let{at:j,count:Q}=S[q],it=m.subarray(2*j,2*(j+Q)),at=Uft(it,q>0),St=jft(it,_,x),yt=St.u;B=St.vScale;for(let Y=0;Y<Q;Y++){let pt=(Y+1)%Q,[xt,Tt]=at[Y],Mt=L;for(let[_t,kt,Ut,Lt,zt,Bt]of[[it[2*Y],it[2*Y+1],xt,c,yt[Y],2],[it[2*pt],it[2*pt+1],Tt,c,yt[Y+1],2],[it[2*pt],it[2*pt+1],Tt,p,yt[Y+1],0],[it[2*Y],it[2*Y+1],xt,p,yt[Y],0]]){let jt=3*L;M[jt]=_t,M[jt+1]=kt,M[jt+2]=Lt,C[jt]=Ut[0],C[jt+1]=Ut[1],C[jt+2]=0,R[2*L]=zt,R[2*L+1]=B===0?0:(Lt-p)/B,N[L]=Bt,L++}O[V++]=Mt,O[V++]=Mt+1,O[V++]=Mt+2,O[V++]=Mt,O[V++]=Mt+2,O[V++]=Mt+3}}return Gft(M,C,O),{positions:M,normals:C,uvs:R,indices:O,nearSide:N,vScale:B}}(this._shape,this._curveSegments,this._depth,t,this._uvPitch);this._nearSide=e.nearSide,this._vScale=e.vScale,this._effectiveBevel=t.rise;let i=this.getAttribute("position"),r=this.getAttribute("normal"),s=this.getAttribute("uv"),n=this.getIndex();if(i!==void 0&&r!==void 0&&s!==void 0&&n!==null&&i.array.length===e.positions.length&&r.array.length===e.normals.length&&s.array.length===e.uvs.length&&n.array.length===e.indices.length)return i.array.set(e.positions),r.array.set(e.normals),s.array.set(e.uvs),n.array.set(e.indices),i.needsUpdate=!0,r.needsUpdate=!0,s.needsUpdate=!0,void(n.needsUpdate=!0);this.setAttribute("position",new we(e.positions,3)),this.setAttribute("normal",new we(e.normals,3)),this.setAttribute("uv",new we(e.uvs,2)),this.setIndex(new we(e.indices,1))}clone(){let t=new UU(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegments,this._ownerId);return t.userData=x5(this.userData),t}}}),fm=G(()=>{_m(),f3t(),Hft(),Kv(),tT(),xm=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i,r=Object.assign({},e?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:ss.ODD},t.parameters),s=Math.abs(r.width),n=Math.abs(r.height??r.width),a=Math.abs(r.depth??0),o=t.shape??e?.shape,l=o?.roundness??r.roundness;o!==void 0&&(o instanceof ds?(i=o,(i.width!==s||i.height!==n)&&i.applySize(s,n)):i=new ds(s,n).fromJSON(o),t.parameters?.roundness!==void 0&&t.parameters?.roundness>0&&i.update());let u=i??new ds(s,n);return{parameters:Object.assign(r,{width:s,height:n,depth:a,roundness:l}),shape:u,ownerId:t.ownerId??e?.ownerId}}static build(t){let e,{depth:i,extrudeBevelSize:r,extrudeBevelSegments:s,subdivisions:n,roundness:a,windingRule:o,uvPitch:l}=t.parameters;return t.shape.roundness=a,i<=0?e=new LU(t.shape,n,{windingRule:o}):r<=0?e=new AR(t.shape,i,n,o,l):eT!==void 0?e=new UU(t.shape,i,r,n,s,t.ownerId,l):(console.error("[extrude] engine not loaded \u2014 extruding without a bevel"),e=new AR(t.shape,i,n,o,l)),Object.assign(e,{userData:{...t,type:"VectorGeometry"}})}}});function v3t(t,e,i,r,s,n){if(r>=PG)return s>30||s%4==0?(function(h,d,c,p=0,m=0,f=0){let g=.5522847498,y=d*g,v=c*g;h.addPoint(BM(m-d,f,m-d,f-v,m-d,f+v)),h.addPoint(BM(m,f+c,m-y,f+c,m+y,f+c)),h.addPoint(BM(m+d,f,m+d,f+v,m+d,f-v)),h.addPoint(BM(m,f-c,m+y,f-c,m-y,f-c)),p>0&&Jft(h,d,c,p)}(t,e,i,n),Math.round(s/4)):nK(t,r,s,e,i,n);let a={x:0,y:i},o=(r=Math.max(r,.001))+.5*Math.PI,l={x:Math.cos(o)*e,y:Math.sin(o)*i},u=function({px:h,py:d,cx:c,cy:p,rx:m,ry:f,largeArcFlag:g,sweepFlag:y}){let v=[];if(m===0||f===0)return[];let b=(h-c)/2,_=(d-p)/2;if(b===0&&_===0)return[];m=Math.abs(m),f=Math.abs(f);let x=Math.pow(b,2)/Math.pow(m,2)+Math.pow(_,2)/Math.pow(f,2);x>1&&(m*=Math.sqrt(x),f*=Math.sqrt(x));let S=function(O,N,B,k,z,L,V,q,j,Q){let it=Math.pow(z,2),at=Math.pow(L,2),St=Math.pow(V,2),yt=Math.pow(q,2),Y=it*at-it*yt-at*St;Y<0&&(Y=0),Y/=it*yt+at*St,Y=Math.sqrt(Y)*(j===Q?-1:1);let pt=Y*z/L*q,xt=Y*-L/z*V,Tt=pt+(O+B)/2,Mt=xt+(N+k)/2,_t=(V-pt)/z,kt=(q-xt)/L,Ut=(-V-pt)/z,Lt=(-q-xt)/L,zt=ZY(1,0,_t,kt),Bt=ZY(_t,kt,Ut,Lt);return!Q&&Bt>0&&(Bt-=VP),Q&&Bt<0&&(Bt+=VP),{centerx:Tt,centery:Mt,ang1:zt,ang2:Bt}}(h,d,c,p,m,f,b,_,g,y),{ang1:w,ang2:T}=S,{centerx:A,centery:M}=S,C=Math.abs(T)/(VP/4);Math.abs(1-C)<1e-7&&(C=1);let R=Math.max(Math.ceil(C),1);T/=R;for(let O=0;O<R;O++)v.push(p3t(w,T)),w+=T;return v.map(O=>{let{x:N,y:B}=EO(O[0],m,f,A,M),{x:k,y:z}=EO(O[1],m,f,A,M),{x:L,y:V}=EO(O[2],m,f,A,M);return{x1:N,y1:B,x2:k,y2:z,x:L,y:V}})}({px:a.x,py:a.y,cx:l.x,cy:l.y,rx:e,ry:i,largeArcFlag:r>Math.PI,sweepFlag:!0});return s>30||s%u.length===0?function(h,d,c,p,m,f,g,y){let v=Math.round(m/p.length);h.addPoint(pv(d,c));for(let b=0,_=p.length;b<_;b++){let x=p[b],S=h.points[b],w=pv(x.x,x.y);S.controls[1].position.set(x.x1,x.y1),w.controls[0].position.set(x.x2,x.y2),h.addPoint(w)}return y>0?Qft(h,f,g,y):h.addPoint(pv(0,0)),v}(t,a.x,a.y,u,s,e,i,n):nK(t,r,s,e,i,n)}function nK(t,e,i,r,s,n){let a=-e/i;for(let o=0;o<=i;o++){let l=a*o,u=Math.sin(l)*r,h=Math.cos(l)*s;t.addPoint(pv(u,h))}return e<PG?n>0?Qft(t,r,s,n):t.addPoint(pv(0,0)):(t.removePoint(t.points[t.points.length-1]),n>0&&Jft(t,r,s,n)),1}function pv(t,e){return new jg(qt.generateUUID(),new Z(t,e))}function BM(t,e,i,r,s,n){let a=pv(t,e);return a.controls[0].position.set(i,r),a.controls[1].position.set(s,n),a}function Qft(t,e,i,r){tgt(t,e,i,r).forEach(s=>t.addPoint(s))}function Jft(t,e,i,r){let s=tgt(t,e,i,r),n=new ds;s.forEach(a=>n.addPoint(a)),n.isClosed=!0,t.shapeHoles.push(n)}function tgt(t,e,i,r){let s=r*e/100,n=s*(Math.abs(i)/Math.abs(e)),a=new Z(s/e,n/i),o=t.points.map(l=>{let u=l.clone();return u.uuid=qt.generateUUID(),u}).reverse();return o.forEach(l=>{l.position.multiply(a);let u=l.controls[0].position.clone().multiply(a),h=l.controls[1].position.clone().multiply(a);l.controls[0].position.copy(h),l.controls[1].position.copy(u)}),o}var PG,z5,egt,OO,igt,PR=G(()=>{_m(),Lft(),m3t(),fm(),dt(),PG=2*Math.PI,z5=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},t.parameters);return i.angle=qt.clamp(i.angle,0,360),{shape:t.shape&&t.shape instanceof ds?t.shape:new ds,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(t){let e,{width:i,height:r,spikes:s,angle:n,innerRadius:a,depth:o,extrudeBevelSize:l,extrudeBevelSegments:u}=t.parameters,h=t.shape,d=v3t(h,.5*i,.5*r,n*Math.PI/180,s,a);return h.isClosed=!0,h.update(),n===0?(e=new ye,e.setAttribute("position",new fe([],3))):e=xm.create({shape:h,parameters:{subdivisions:d,depth:o,extrudeBevelSize:l,extrudeBevelSegments:u}}),Object.assign(e,{userData:{...t,type:"EllipseGeometry"}})}}}),aK=G(()=>{dt(),Oft(),egt=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,detail:0,corner:0,cornerSides:4},t.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(t){let{width:e,height:i,depth:r,detail:s,corner:n,cornerSides:a}=t.parameters,o=s===0&&n!==0?new OO(.5*e,n,a):new w8(.5*e,s),l=i/e,u=r/e;return(l!==1||u!==1)&&o.scale(1,l,u),Object.assign(o,{userData:{...t,type:"IcosahedronGeometry"}})}},OO=class extends TR{constructor(t=1,e=.2,i=4){let r=(1+Math.sqrt(5))/2,s="IcosahedronGeometry";super([-1,r,0,1,r,0,-1,-r,0,1,-r,0,0,-1,r,0,1,r,0,-1,-r,0,1,-r,r,0,-1,r,0,1,-r,0,-1,-r,0,1],[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],s,t,e,i),this.type=s}static fromJSON(t){return new OO(t.radius,t.corner,t.cornerSides)}}}),oK=G(()=>{dt(),igt=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){(t.parameters?.points??[]).forEach(r=>{Array.isArray(r)&&(r.x=r[0],r.y=r[1])});let i=Object.assign({},e?.parameters??{width:100,segments:64,verticalSegments:64,points:[{x:0,y:-50,id:0},{x:50,y:-50,id:1},{x:50,y:50,id:2},{x:0,y:50,id:3}]},t.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(t){let{points:e,segments:i,verticalSegments:r}=t.parameters,s=new bS;s.moveTo(e[0].x,e[0].y),s.bezierCurveTo(e[1].x,e[1].y,e[2].x,e[2].y,e[3].x,e[3].y);let n=new S8(s.extractPoints(r).shape,i);return n.rotateZ(Math.PI),Object.assign(n,{userData:{...t,type:"LatheGeometry"}})}}});function L0(t,e){return Math.abs(e-t)/2+Math.min(t,e)}function b3t(t){let{positions:e,faces:i,materialIndices:r,uvs:s}=t,n=e.length/3,a=i.length/3,o=s!==null&&a>0,l=3*a,u=new Uint32Array(l),h=new Uint32Array(l),d=new Uint32Array(l),c=new Uint32Array(l),p=new Uint32Array(l),m=0,f=8;for(;f<2*l;)f*=2;let g=f-1,y=new Int32Array(f).fill(-1),v=(N,B)=>{let k=(Math.imul(N,2654435761)^B)&g;for(;;){let z=y[k];if(z===-1)return y[k]=m,u[m]=N,h[m]=B,m++;if(u[z]===N&&h[z]===B)return z;k=k+1&g}},b=(N,B)=>{let k=N<B?N:B,z=N<B?B:N,L=(Math.imul(k,2654435761)^z)&g;for(;;){let V=y[L];if(u[V]===k&&h[V]===z)return V;L=L+1&g}},_=new Uint32Array(n),x=new Float64Array(3*n),S=(N,B,k)=>{let z=N<B?v(N,B):v(B,N),L=++d[z];L===1?c[z]=k:L===2&&(p[z]=k),_[N]++,_[B]++,x[3*N]+=e[3*B],x[3*N+1]+=e[3*B+1],x[3*N+2]+=e[3*B+2],x[3*B]+=e[3*N],x[3*B+1]+=e[3*N+1],x[3*B+2]+=e[3*N+2]};for(let N=0;N<a;N++){let B=i[3*N],k=i[3*N+1],z=i[3*N+2];S(B,k,z),S(k,z,B),S(z,B,k)}let w=new Float64Array(3*m);for(let N=0;N<m;N++){let B=3*u[N],k=3*h[N];if(d[N]===2){let z=3*c[N],L=3*p[N];w[3*N]=.375*(e[B]+e[k])+.125*(e[z]+e[L]),w[3*N+1]=.375*(e[B+1]+e[k+1])+.125*(e[z+1]+e[L+1]),w[3*N+2]=.375*(e[B+2]+e[k+2])+.125*(e[z+2]+e[L+2])}else w[3*N]=.5*(e[B]+e[k]),w[3*N+1]=.5*(e[B+1]+e[k+1]),w[3*N+2]=.5*(e[B+2]+e[k+2])}let T,A=new Float64Array(3*n);for(let N=0;N<n;N++){let B=_[N];B===3?T=3/16:B>3&&(T=3/(8*B));let k=1-B*Number(T),z=Number(T);B===2&&(k=3/4,z=1/8),A[3*N]=e[3*N]*k+x[3*N]*z,A[3*N+1]=e[3*N+1]*k+x[3*N+1]*z,A[3*N+2]=e[3*N+2]*k+x[3*N+2]*z}let M=new Float64Array(3*(n+m));M.set(A),M.set(w,3*n);let C=new Uint32Array(12*a),R=new Array(4*a),O=o?new Float64Array(24*a):null;for(let N=0;N<a;N++){let B=i[3*N],k=i[3*N+1],z=i[3*N+2],L=b(B,k)+n,V=b(k,z)+n,q=b(z,B)+n,j=12*N;C[j++]=L,C[j++]=V,C[j++]=q,C[j++]=B,C[j++]=L,C[j++]=q,C[j++]=k,C[j++]=V,C[j++]=L,C[j++]=z,C[j++]=q,C[j++]=V;let Q=r[N];if(R[4*N]=Q,R[4*N+1]=Q,R[4*N+2]=Q,R[4*N+3]=Q,O!==null){let it=6*N,at=s[it],St=s[it+1],yt=s[it+2],Y=s[it+3],pt=s[it+4],xt=s[it+5],Tt=L0(at,yt),Mt=L0(St,Y),_t=L0(yt,pt),kt=L0(Y,xt),Ut=L0(at,pt),Lt=L0(St,xt),zt=24*N;O[zt++]=Tt,O[zt++]=Mt,O[zt++]=_t,O[zt++]=kt,O[zt++]=Ut,O[zt++]=Lt,O[zt++]=at,O[zt++]=St,O[zt++]=Tt,O[zt++]=Mt,O[zt++]=Ut,O[zt++]=Lt,O[zt++]=yt,O[zt++]=Y,O[zt++]=_t,O[zt++]=kt,O[zt++]=Tt,O[zt++]=Mt,O[zt++]=pt,O[zt++]=xt,O[zt++]=Ut,O[zt++]=Lt,O[zt++]=_t,O[zt++]=kt}}return{positions:M,faces:C,materialIndices:R,uvs:O}}var VM,rgt,tn,sgt,RG,_3t=G(()=>{dt(),VM=1e4,rgt=class{constructor(t=1){this.subdivisions=t}modify(t){let e=function(r){let s=r.getAttribute("position");if(s===void 0)return console.error("SubdivisionModifier: Position attribute required for subdivision."),{positions:new Float64Array(0),faces:new Uint32Array(0),materialIndices:[],uvs:null};let n=r.getAttribute("uv"),a=r.getIndex(),o=s.count,l=new Map,u=new Uint32Array(o),h=[],d=0;for(let v=0;v<o;v++){let b=s.getX(v),_=s.getY(v),x=s.getZ(v),S=Math.round(b*VM),w=Math.round(_*VM),T=Math.round(x*VM),A=l.get(S);A===void 0&&(A=new Map,l.set(S,A));let M=A.get(w);M===void 0&&(M=new Map,A.set(w,M));let C=M.get(T);C===void 0&&(C=d++,M.set(T,C),h.push(b,_,x)),u[v]=C}let c=[],p=[],m=n===void 0?null:[],f=a!==null?a.count:o,g=(v,b)=>{let _=a!==null?a.getX(v):v,x=a!==null?a.getX(v+1):v+1,S=a!==null?a.getX(v+2):v+2;if(!(_<o&&x<o&&S<o))return;let w=u[_],T=u[x],A=u[S];w===T||T===A||A===w||(c.push(w,T,A),p.push(b),m!==null&&m.push(n.getX(_),n.getY(_),n.getX(x),n.getY(x),n.getX(S),n.getY(S)))},y=r.groups;if(y.length>0)for(let v=0;v<y.length;v++){let b=y[v],_=b.materialIndex===void 0?0:b.materialIndex,x=Math.max(b.start,0),S=Math.min(b.start+b.count,f);for(let w=x;w<S&&w+2<f;w+=3)g(w,_)}else for(let v=0;v+2<f;v+=3)g(v,0);return{positions:Float64Array.from(h),faces:Uint32Array.from(c),materialIndices:p,uvs:m===null?null:Float64Array.from(m)}}(t),i=this.subdivisions;for(;i-- >0;)e=b3t(e);return function(r,s){let{positions:n,faces:a,materialIndices:o,uvs:l}=r,u=n.length/3,h=a.length/3,d=new Float64Array(3*u);for(let y=0;y<h;y++){let v=3*a[3*y],b=3*a[3*y+1],_=3*a[3*y+2],x=n[_]-n[b],S=n[_+1]-n[b+1],w=n[_+2]-n[b+2],T=n[v]-n[b],A=n[v+1]-n[b+1],M=n[v+2]-n[b+2],C=S*M-w*A,R=w*T-x*M,O=x*A-S*T;d[v]+=C,d[v+1]+=R,d[v+2]+=O,d[b]+=C,d[b+1]+=R,d[b+2]+=O,d[_]+=C,d[_+1]+=R,d[_+2]+=O}for(let y=0;y<u;y++){let v=d[3*y],b=d[3*y+1],_=d[3*y+2],x=Math.sqrt(v*v+b*b+_*_)||1;d[3*y]=v/x,d[3*y+1]=b/x,d[3*y+2]=_/x}let c=3*h,p=new Float32Array(3*c),m=new Float32Array(3*c),f=l!==null&&l.length>0?new Float32Array(2*c):null;for(let y=0;y<c;y++){let v=3*a[y];p[3*y]=n[v],p[3*y+1]=n[v+1],p[3*y+2]=n[v+2],m[3*y]=d[v],m[3*y+1]=d[v+1],m[3*y+2]=d[v+2]}f!==null&&f.set(l.subarray(0,2*c));let g=new ye;g.setAttribute("position",new we(p,3)),c>0&&(g.setAttribute("normal",new we(m,3)),g.setAttribute("color",new we(new Float32Array(3*c).fill(1),3))),f!==null&&g.setAttribute("uv",new we(f,2));for(let y=0;y<h;){let v=o[y],b=y;do y++;while(y<h&&o[y]===v);g.addGroup(3*b,3*(y-b),v)}return s.boundingBox!==null&&(g.boundingBox=s.boundingBox.clone()),s.boundingSphere!==null&&(g.boundingSphere=s.boundingSphere.clone()),g}(e,t)}}}),lK=G(()=>{dt(),_3t(),tn=new P,sgt=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i,r=t.geometry??e?.geometry??new ye().copy(new Zh(100,100,100));e===void 0?(r.computeBoundingBox(),r.boundingBox.getSize(tn),i={width:tn.x,height:tn.y,depth:tn.z,subdivisions:0}):i=e.parameters;let s={...i,...t.parameters};return{parameters:{width:Math.abs(s.width),height:Math.abs(s.height),depth:Math.abs(s.depth),subdivisions:Math.abs(s.subdivisions)},geometry:r}}static build(t){let{width:e,height:i,depth:r,subdivisions:s}=t.parameters,n=t.geometry??new ye().copy(new Zh(100,100,100)),a=n.userData.parameters;a===void 0?(n.boundingBox=function(l){let u=new pr,h=l.attributes.position;return h?(u.setFromBufferAttribute(h),u):(u.makeEmpty(),u)}(n),n.boundingBox.getSize(tn)):tn.set(a.width,a.height,a.depth),(e!==tn.x||i!==tn.y||r!==tn.z)&&n.scale(tn.x===0?1:e/tn.x,tn.y===0?1:i/tn.y,tn.z===0?1:r/tn.z);let o=n.originalGeometry;try{s>0?(o===void 0||a?.subdivisions!==s)&&(o===void 0&&(o=n),n=new rgt(s).modify(o)):(o!==void 0&&(n=o),o=void 0,n.getAttribute("normal")===void 0&&n.computeVertexNormals())}catch{o!==void 0&&(n=o),o=void 0,n.getAttribute("normal")===void 0&&n.computeVertexNormals()}return o!==void 0&&Object.assign(n,{originalGeometry:o}),delete t.geometry,Object.assign(n,{userData:{...t,type:"NonParametricGeometry"}})}static loadFromUrl(t,e,i){new F7(i).load(t,r=>{let s=this.normalizeInputs({geometry:r});r.boundingBox.getSize(tn);let n=100/tn.x;Object.assign(s.parameters,{width:100,height:tn.y*n,depth:tn.z*n}),e(this.build(s))})}}}),jU=G(()=>{_m(),fm(),RG=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},t.parameters);return{shape:t.shape&&t.shape instanceof ds?t.shape:new ds,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(t){let{width:e,height:i,spikes:r,cornerRadius:s,depth:n,extrudeBevelSize:a,extrudeBevelSegments:o}=t.parameters,l=t.shape,u=.5*e,h=.5*i,d=2*Math.PI/r;for(let p=0;p<r;p++){let m=d*p,f=0+Math.sin(m)*u,g=0+Math.cos(m)*h;l.addPoint(l.createPoint(f,g))}l.isClosed=!0;for(let p=0,m=l.points.length;p<m;p++)l.points[p].roundness=s;l.roundness=s,l.update();let c=xm.create({shape:l,parameters:{roundness:s,depth:n,extrudeBevelSize:a,extrudeBevelSegments:o}});return Object.assign(c,{userData:{...t,type:"PolygonGeometry"}})}}});function l_(t,e,i){i.x=t.x*e.x,i.y=t.y,i.z=t.x*e.y}function IO(t,e,i,r,s,n){let a=agt.copy(e).sub(t),o=ogt.copy(i).sub(t),l=a.angleTo(o);if(a.normalize(),o.normalize(),r===s){let u=a.add(o).normalize();n.copy(t).addScaledVector(u,r/Math.sin(l/2))}else{let u=a.angleTo(o);n.copy(t),n.addScaledVector(a,s/Math.sin(u)),n.addScaledVector(o,r/Math.sin(u))}}function x3t(t,e,i){let r=t.clone().sub(e),s=i.clone().sub(e);return r.projectOnVector(s),r.add(e)}var ngt,agt,ogt,hK,L5,lgt,hgt,ugt,uK,DG,dgt,cgt,pgt,mgt,dK=G(()=>{dt(),ngt=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},t.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(t){let{width:e,height:i,depth:r,radialSegments:s,heightSegments:n,openEnded:a,cornerRadius:o,cornerSegments:l}=t.parameters,u=new hK(.5*e,i,s,n,a,o,l),h=r/e;return h!==1&&u.scale(1,1,h),Object.assign(u,{userData:{...t,type:"PyramidGeometry"}})}},agt=new P,ogt=new P,hK=class extends ye{constructor(t=.5,e=1,i=4,r=1,s=!1,n=0,a=4){super(),i=Math.floor(Math.max(3,i)),r=Math.floor(r),a=Math.floor(a);let o,l=[],u=[],h=[],d=[],c=0,p=e/2,m=Math.PI/i,f=t*Math.cos(Math.PI/i),g=2*Math.PI/i,y=(i-2)*Math.PI/i,v=Math.PI-y,b=new P(0,-p,0),_=new P(0,p,0),x=new Z(t,-p),S=new Z(f,-p),w=new Z(0,_.y).sub(S),T=new Z(0,_.y).sub(x),A=new Z(w.y,-w.x).normalize(),M=new Z(T.y,-T.x).normalize(),C=t*Math.cos(Math.PI/i)*Math.tan((Math.PI-w.angle())/2)-1e-8;n=Math.min(n,C);{let L=new P(A.x,A.y,0),V=new P(Math.cos(g)*L.x,L.y,Math.sin(g)*L.x);o=L.angleTo(V)}let R=n/Math.tan((Math.PI-w.angle())/2),O=n/Math.tan((Math.PI-o)/2),N=new P;if(!s){u.push(b.x,b.y,b.z),h.push(0,-1,0),d.push(0,0);let L=c++,V=[],q=x.clone(),j=R/Math.cos(Math.PI/i);q.x-=j;for(let Q=0;Q<i;Q++){let it=Q/i*Math.PI*2+m;l_(q,new Z(Math.sin(it),Math.cos(it)),N),u.push(N.x,N.y,N.z),h.push(0,-1,0),d.push(0,0),V.push(c++)}for(let Q=0;Q<V.length;Q++)l.push(V[Q],L,V[(Q+1)%V.length])}let B=[];{let L=new P,V=new P,q=new P,j=new P,Q=new P,it=new P;for(let at=0;at<i;at++){let St=at/i*Math.PI*2+m,yt=(at+.5)/i*Math.PI*2+m,Y=(at+1)/i*Math.PI*2+m,pt=new Z(Math.sin(St),Math.cos(St)),xt=new Z(Math.sin(yt),Math.cos(yt)),Tt=new Z(Math.sin(Y),Math.cos(Y));l_(x,pt,V),l_(x,Tt,q),l_(A,xt,L),IO(_,V,q,O,O,j),u.push(j.x,j.y,j.z),IO(V,_,q,O,R,Q),u.push(Q.x,Q.y,Q.z),IO(q,V,_,R,O,it),u.push(it.x,it.y,it.z),h.push(L.x,L.y,L.z),h.push(L.x,L.y,L.z),h.push(L.x,L.y,L.z),d.push(0,0),d.push(0,0),d.push(0,0);let Mt=c++,_t=c++,kt=c++;if(l.push(Mt,_t,kt),n>0){{let zt=V.clone().add(q).multiplyScalar(.5),Bt=_.clone().sub(zt).normalize(),jt=b.clone().sub(zt).normalize().add(Bt).normalize().multiplyScalar(-1);k(zt,it.clone().sub(Q),jt,w.angle())}let Ut,Lt;{let zt=new P;l_(M,Tt,zt);let Bt=it.clone().add(j).multiplyScalar(.5);Bt=x3t(Bt,q,_);let jt=it.clone().sub(j);[Ut,Lt]=k(Bt,jt,zt,o,j.y)}{let zt=Ut,Bt=zt.clone().setY(0).normalize(),jt=new P(0,-1,0),Xt=Bt.clone().cross(jt);z(zt,Bt,jt,Xt)}B.concat(Lt);{let zt=w.angle(),Bt=Math.PI-zt,jt=_.clone();jt.y-=n/Math.sin(zt-Math.PI/2);let Xt=new P,Dt=[];for(let Wt=0;Wt<a;Wt++){let Qt=[],ee=Math.PI/2-Bt*Wt/a,$=Math.cos(ee),se=Math.sin(ee),Pe=yt;for(let Ve=0;Ve<=Wt;Ve++){let ie=Math.cos(Pe),oi=Math.sin(Pe);L.x=$*oi,L.y=se,L.z=$*ie,Xt.copy(jt).addScaledVector(L,n),u.push(Xt.x,Xt.y,Xt.z),h.push(L.x,L.y,L.z),d.push(0,0),Qt.push(c++),Pe+=2*Math.PI/Wt/i}Dt.push(Qt)}Lt.reverse(),Dt.push(Lt);let le=Dt.length-1;for(let Wt=0;Wt<le;Wt++){let Qt=Dt[Wt],ee=Dt[Wt+1],$=Qt.length-1;l.push(ee[1],Qt[0],ee[0]);for(let se=1;se<=$;se++)l.push(Qt[se],Qt[se-1],ee[se]),l.push(ee[se+1],Qt[se],ee[se])}}}}}function k(L,V,q,j,Q){let it=-j/2,at=(Math.PI-j)/2,St=V.clone().normalize().cross(q);L.addScaledVector(q,-n/Math.sin(at));let yt=new P,Y=new P,pt=c,xt=[];for(let Tt=0;Tt<=a;Tt++){let Mt=it+Tt/a*j;Y.set(0,0,0),Y.addScaledVector(St,Math.sin(Mt)),Y.addScaledVector(q,Math.cos(Mt));for(let _t=0;_t<=1;_t++){let kt=_t/1-.5;if(yt.copy(L),yt.addScaledVector(V,kt),yt.addScaledVector(Y,n),Q!=null){let Ut=Math.max(0,yt.y-Q);yt.addScaledVector(V,-Ut/V.y)}u.push(yt.x,yt.y,yt.z),h.push(Y.x,Y.y,Y.z),d.push(0,0),_t===0&&xt.push(c),c++}}for(let Tt=0;Tt<a;Tt++)for(let Mt=0;Mt<1;Mt++){let _t=pt+Mt+2*Tt,kt=_t+2,Ut=kt+1,Lt=_t+1;l.push(_t,kt,Lt),l.push(kt,Ut,Lt)}return[L.clone().addScaledVector(V,.5),xt]}function z(L,V,q,j){let Q=Math.PI/2,it=T.angle()-Q,at=[],St=new P,yt=new P;for(let pt=0;pt<=a;pt++){let xt=[],Tt=pt/a;for(let Mt=0;Mt<=pt;Mt++){let _t=((pt?Mt/pt:0)-.5)*v,kt=Math.cos(_t),Ut=Math.sin(_t),Lt=(Q+Math.atan(Math.tan(it)*kt))*Tt,zt=Math.cos(Lt),Bt=Math.sin(Lt);St.set(0,0,0),St.addScaledVector(V,Bt*kt),St.addScaledVector(q,zt),St.addScaledVector(j,Bt*Ut),yt.copy(L).addScaledVector(St,n),u.push(yt.x,yt.y,yt.z),h.push(St.x,St.y,St.z),d.push(0,0),xt.push(c++)}at.push(xt)}let Y=at.length-1;for(let pt=0;pt<Y;pt++){let xt=at[pt],Tt=at[pt+1],Mt=xt.length-1;l.push(xt[0],Tt[1],Tt[0]);for(let _t=1;_t<=Mt;_t++)l.push(xt[_t-1],xt[_t],Tt[_t]),l.push(xt[_t],Tt[_t+1],Tt[_t])}}this.setIndex(l),this.setAttribute("position",new fe(u,3)),this.setAttribute("normal",new fe(h,3)),this.setAttribute("uv",new fe(d,2))}}}),RR=G(()=>{_m(),fm(),L5=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},t.parameters),r=Object.assign(e?.ui??{enabledIndieCorners:!1},t.ui);return{shape:t.shape&&t.shape instanceof ds?t.shape:new ds,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)}),ui:r}}static build(t){let e=t.shape,{width:i,height:r,cornerRadius:s,cornerType:n,depth:a,extrudeBevelSize:o,extrudeBevelSegments:l}=t.parameters,u={x:.5*i,y:.5*r},h={x:-u.x,y:-u.y},d={x:u.x,y:u.y};function c(_,x,S){return x>i&&S>r?Math.min(_*i/x,_*r/S):x>i?_*i/x:S>r?_*r/S:_}let p=[];p[0]=s[0]===0?0:c(s[0],s[0]+s[3],s[0]+s[1]),p[1]=s[1]===0?0:c(s[1],s[1]+s[2],s[1]+s[0]),p[2]=s[2]===0?0:c(s[2],s[2]+s[1],s[2]+s[3]),p[3]=s[3]===0?0:c(s[3],s[3]+s[0],s[3]+s[2]);let m=h.x,f=d.x,g=d.y,y=h.y;e.addPoint(e.createPoint(m,g)),e.addPoint(e.createPoint(f,g)),e.addPoint(e.createPoint(f,y)),e.addPoint(e.createPoint(m,y)),e.isClosed=!0;let v=!0;for(let _=0,x=e.points.length;_<x;_++)e.points[_].roundness=p[_],_>0&&p[_]!==p[_-1]&&(v=!1);v&&(e.roundness=p[0]),e.useCubicForRoundedCorners=n!==1,e.update();let b=xm.create({shape:e,parameters:{depth:a,extrudeBevelSize:o,extrudeBevelSegments:l}});return Object.assign(b,{userData:{...t,type:"RectangleGeometry"}})}}}),cK=G(()=>{dt(),lgt=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180},t.parameters);return i.thetaLength=qt.clamp(i.thetaLength,0,180),{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(t){let e,{width:i=100,height:r=i,depth:s=i,widthSegments:n=64,heightSegments:a=64,phiStart:o,phiLength:l,thetaStart:u,thetaLength:h}=t.parameters;return h===0?(e=new ye,e.setAttribute("position",new fe([],3))):e=new Tc(.5*i,n,a,o,l,u,h*qt.DEG2RAD),e.scale(1,r/i,s/i),Object.assign(e,{userData:{...t,type:"SphereGeometry"}})}}}),pK=G(()=>{dt(),hgt=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},t.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:0})}}static build(t){let{width:e=100,height:i=e,widthSegments:r=8,heightSegments:s=8}=t.parameters,n=new Ac(e,i,r,s);return n.scale(1,1,1),Object.assign(n,{userData:{...t,type:"PlaneGeometry"}})}}}),mK=G(()=>{dt(),ugt=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},t.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(t){let{width:e,height:i,depth:r,angle:s,cornerRadius:n,cornerSegments:a}=t.parameters,o=new uK(e,i,r,s,n,a);return Object.assign(o,{userData:{...t,type:"BackdropGeometry"}})}},uK=class extends ye{constructor(t=1,e=1,i=1,r=90,s=10,n=24){super(),this.type="BackdropGeometry";let a=[],o=[],l=[],u=.001;s==0&&(n=1),n=Math.max(1,Math.floor(n)),s=Math.min(s,100),r=Math.min(180-u,r),r*=Math.PI/180;let h=[],d=Math.PI/2,c=(yt=0,Y=0,pt=0)=>new P(yt,Y,pt),p=c(),m=c(),[f,g,y]=[e/2,t/2,i/2],v=-g,b=+g,[_,x,S]=[c(v,-f,+y),c(v,-f,-y),c(v,+f,-y)],w=(yt,Y=!1)=>Math.sin(yt-Math.PI/(+Y+1)),T=(yt,Y=!1)=>Math.cos(yt-Math.PI/(+Y+1));S.y=Math.sin(r)*e-f;let A=Math.cos(r)*e-y,M=_.z-u;r<=d?(S.z=Math.min(A,M),S.z==M&&(S.y-=(A-M)/Math.tan(d-r))):x.z=Math.min(x.z-A-y,_.z-u),p.subVectors(_,x),m.subVectors(S,x);let C=Math.min(p.length(),m.length())*s/100,R=C*Math.tan(r/2),O=C/Math.cos(r/2),N=p.clone().normalize().add(m.normalize()).setLength(O).add(x);p.set(0,w(r,!0),T(r,!0)),h.push([S,p.clone()]);let B=(Math.PI-r)/n;for(let yt=0;yt<=n;yt++){let Y=d+r+yt*B;p.set(0,Math.sin(Y)*R,Math.cos(Y)*R),p.add(N),m.set(0,w(Y),T(Y)),h.push([p.clone(),m.clone()])}h.push([_,c(0,1,0)]);let k=Math.sin(B/2)*R*2,z=h.length-1,L=h[0][0].distanceTo(h[1][0]),V=L+k*n+h[z-1][0].distanceTo(h[z][0]);h[0].push(1);for(let yt=0;yt<=n;yt++)h[yt+1].push(1-(L+yt*k)/V);h[z].push(0);let q,j,Q,[it,at,St]=h[0];for(let yt=1;yt<h.length;yt++)[q,j,Q]=h[yt],a.push(v,it.y,it.z,v,q.y,q.z,b,it.y,it.z,b,it.y,it.z,v,q.y,q.z,b,q.y,q.z),o.push(0,at.y,at.z,0,j.y,j.z,0,at.y,at.z,0,at.y,at.z,0,j.y,j.z,0,j.y,j.z),l.push(0,St,0,Q,1,St,1,St,0,Q,1,Q),[it,at,St]=[q,j,Q];this.setAttribute("position",new fe(a,3)),this.setAttribute("normal",new fe(o,3)),this.setAttribute("uv",new fe(l,2))}}}),GU=G(()=>{_m(),fm(),DG=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},t.parameters);return{shape:t.shape&&t.shape instanceof ds?t.shape:new ds,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(t){let{width:e,height:i,innerRadiusPercent:r,spikes:s,cornerRadius:n,angle:a,depth:o,extrudeBevelSize:l,extrudeBevelSegments:u}=t.parameters,h=t.shape,d=.5*e,c=.5*i,p=a*Math.PI/360/s,m=Math.PI/2*3*-1,f=d*r/100,g=c*r/100;if(s===3&&r===50){p=2*Math.PI/s;for(let v=0;v<s;v++){let b=p*v,_=0+Math.sin(b)*d,x=0+Math.cos(b)*c;h.addPoint(h.createPoint(_,x))}}else for(let v=0;v<s;v++){let b=0+Math.cos(m)*d,_=0+Math.sin(m)*c;h.addPoint(h.createPoint(b,_)),m+=p,b=0+Math.cos(m)*f,_=0+Math.sin(m)*g,h.addPoint(h.createPoint(b,_)),m+=p}h.isClosed=!0;for(let v=0,b=h.points.length;v<b;v++)h.points[v].roundness=n;h.roundness=n,h.update();let y=xm.create({shape:h,parameters:{roundness:n,depth:o,extrudeBevelSize:l,extrudeBevelSegments:u}});return Object.assign(y,{userData:{...t,type:"StarGeometry"}})}}}),fK=G(()=>{dt(),dgt=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,depth:0},t.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(t){let{width:e,height:i}=t.parameters,r=new Ac(e,i);return Object.assign(r,{userData:{...t,type:"TextFrameGeometry"}})}}}),gK=G(()=>{dt(),NS(),cgt=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:360,cornerRadius:30,cornerSegments:8},t.parameters),r=Math.abs(i.width),s=Math.abs(i.height??i.width);i.shapeBlendNode&&(s=r);let n=Math.round(Math.abs(i.depth??.25*i.width));return{parameters:Object.assign(i,{width:r,height:s,depth:n})}}static build(t){let{width:e,height:i,depth:r,radialSegments:s,tubularSegments:n,arc:a,cornerRadius:o,cornerSegments:l}=t.parameters,u=function(h,d,c,p,m,f,g,y,v,b,_){[d,c]=[c,d],g=d/2;let x=qt.clamp(m/360,0,1);if(x===0){let S=new ye;return S.setAttribute("position",new fe([],3)),S}return x===1&&(b=0),new PU(!0,h,d,c,p,x,f,g,0,v,b,_)}(e,i,r,.5*e,a,n,0,0,s,o,l);return u.scale(1,i/e,1),Object.assign(u,{userData:{...t,type:"TorusGeometry"}})}}}),yK=G(()=>{dt(),pgt=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},t.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width),tube:i.tube??.125*i.width})}}static build(t){let{width:e,tube:i,tubularSegments:r,radialSegments:s,p:n,q:a}=t.parameters,o=.5*e;o!==i&&(o-=i);let l=new T8(o,i,r,s,n,a);return Object.assign(l,{userData:{...t,type:"TorusKnotGeometry"}})}}}),vK=G(()=>{_m(),fm(),mgt=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},t.parameters);return{shape:t.shape&&t.shape instanceof ds?t.shape:new ds,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width*(i.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(i.depth??0)})}}static build(t){let{width:e=100,height:i,cornerRadius:r,depth:s,extrudeBevelSize:n,extrudeBevelSegments:a,isRect:o}=t.parameters,l=t.shape,u=.5*e,h=.5*i;o?(l.addPoint(l.createPoint(-u,h)),l.addPoint(l.createPoint(u,-h)),l.addPoint(l.createPoint(-u,-h))):(l.addPoint(l.createPoint(0,h)),l.addPoint(l.createPoint(u,-h)),l.addPoint(l.createPoint(-u,-h))),l.isClosed=!0;for(let c=0,p=l.points.length;c<p;c++)l.points[c].roundness=r;l.roundness=r,l.update();let d=xm.create({shape:l,parameters:{roundness:r,depth:s,extrudeBevelSize:n,extrudeBevelSegments:a}});return Object.assign(d,{userData:{...t,type:"TriangleGeometry"}})}}}),w3t=G(()=>{dt()}),S3t=G(()=>{dt(),new ta,new bt,new pc,new P,new P,new P,new P});function bK(){let t=new ye;return t.setAttribute("position",new we(new Float32Array([]),3)),t.setIndex(new we(new Uint16Array([]),1)),t}var _K,WU,fgt=G(()=>{hn(),ke(),tT(),dt(),KS(),_m(),fm(),Kv(),_K=bK().attributes,WU=class extends ye{constructor(t,e){super(),this.isTextGeometry=!0,this.charWidths=[],this.charCoords=[],this.wrappedText=[],this.isLowResolution=!1,this.vectorShapes=[],this._nearSide=new Uint8Array(0),this._depth=0,this._effectiveBevel=0,this._vScale=0,Object.assign(this.attributes,_K),this.userData={parameters:t,type:"TextGeometry"};let i=e.getFont(t.font);i?.isLoaded?(this.font=i,this.update(t,e)):this.updateFont(t.font,e).then(()=>{this.update(t,e),e?.requestRender()})}async updateFont(t,e){let i=e.getFont(t);i&&(this.font=i,await i.loadingPromise)}update(t,e){let i=this.font;if(this.userData={parameters:t,type:"TextGeometry"},!i?.isLoaded)return void console.warn("Cannot update text because its font is not loaded");let{width:r,height:s,depth:n,extrudeBevelSize:a,extrudeBevelSegments:o,text:l,textTransform:u,fontSize:h}=t,d=Na.getDisplayedValue(l),c=function(x,S,w,T){let A=typeof x.width=="string"?Number(T.getVariable(x.width)):x.width,M=[""],C="";for(let R of w)C+=R,R===" "||R===`
|
|
351
|
+
`;return 2&x.valid||e(3,"missing format specifier"),4&x.valid||e(3,"missing image size specifier"),x}(n),h=u.width,d=u.height,c=function(p,m,f){let g=m;if(g<8||g>32767||p[0]!==2||p[1]!==2||128&p[2])return new Uint8Array(p);g!==(p[2]<<8|p[3])&&e(3,"wrong scanline width");let y=new Uint8Array(4*m*f);y.length||e(4,"unable to allocate buffer space");let v=0,b=0,_=4*g,x=new Uint8Array(4),S=new Uint8Array(_),w=f;for(;w>0&&b<p.byteLength;){b+4>p.byteLength&&e(1),x[0]=p[b++],x[1]=p[b++],x[2]=p[b++],x[3]=p[b++],(x[0]!=2||x[1]!=2||(x[2]<<8|x[3])!=g)&&e(3,"bad rgbe scanline format");let T,A=0;for(;A<_&&b<p.byteLength;){T=p[b++];let C=T>128;if(C&&(T-=128),(T===0||A+T>_)&&e(3,"bad scanline data"),C){let R=p[b++];for(let O=0;O<T;O++)S[A++]=R}else S.set(p.subarray(b,b+T),A),A+=T,b+=T}let M=g;for(let C=0;C<M;C++){let R=0;y[v]=S[C+R],R+=g,y[v+1]=S[C+R],R+=g,y[v+2]=S[C+R],R+=g,y[v+3]=S[C+R],v+=4}w--}return y}(n.subarray(n.pos),h,d);switch(this.type){case Qe:l=c.length/4;let p=new Float32Array(4*l);for(let f=0;f<l;f++)r(c,4*f,p,4*f);a=p,o=Qe;break;case ai:l=c.length/4;let m=new Uint16Array(4*l);for(let f=0;f<l;f++)s(c,4*f,m,4*f);a=m,o=ai;break;default:throw new Error("THREE.HDRLoader: Unsupported type: "+this.type)}return{width:h,height:d,data:a,header:u.string,gamma:u.gamma,exposure:u.exposure,type:o,colorSpace:Xu,minFilter:me,magFilter:me,generateMipmaps:!1,flipY:!0}}setDataType(t){return this.type=t,this}}});function DY(t){return t.length>2&&t[0]===35&&t[1]===63}function AO(t){return typeof t=="object"&&t!==null&&t.isSplineHdr===!0}function Sft(t){let e=new yr(t.data,t.width,t.height,an,ai);return e.flipY=!1,e.image.isSplineHdr=!0,e.needsUpdate=!0,e}var NY,xG,pg,Tft=G(()=>{dt(),e3t()}),Mft=G(()=>{dt(),xft(),wft(),Tft(),NY=0,xG=class extends vft{constructor(t,e){super(t,e.imageHolderCache),this.data=t,this.shared=e,this.instanceId=++NY,this.loaded=!1,this.isVideo=!1,this.isBuffer=!1,this.isHdr=!1,this._cache={1e3:{},1001:{},1002:{}},this.isVideo=t.type==="video",this.isBuffer=t.isWebGLRenderTarget===!0,this.loadPromise=this.updateSrc(this.isBuffer?t:t.data)}async updateSrc(t){if(typeof document>"u")return;this.disposeTextures(),this.loaded=!1,this.isHdr=!1;let e=()=>{this.loaded=!0;for(let r of Object.values(this._cache))for(let s of Object.values(r))for(let n of Object.values(s))n&&(n.image=this.img,n.needsUpdate=!0);this.shared.requestRender()};if(this.isBuffer)this.img=t,this.loaded=!0;else if(this.isVideo){if(this.img=document.createElement("video"),this.img.preload="auto",this.img.playsInline=!0,this.img.currentTime=.01,typeof t!="string"){let r,s=new FileReader;s.readAsDataURL(new Blob([t],{type:"video/mp4"})),await new Promise(n=>{s.onloadend=a=>{r=a.target?.result,n(null)}}),this.img.src=r}else this.img.src=t;this.img.onloadeddata=()=>{e()}}else if(t instanceof Uint8Array?DY(t):typeof t=="string"&&/\.hdr($|[?#])/i.test(t)){let r=t instanceof Uint8Array?t:null;if(r===null)try{r=new Uint8Array(await(await fetch(t)).arrayBuffer())}catch{r=null}let s=r!==null&&DY(r)?function(n){try{let a=new _ft().parse(n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength));if(!a||!a.width||!a.height)return null;let{width:o,height:l}=a,u=a.data,h=new Uint16Array(u.length),d=4*o,c=f=>Kh.toHalfFloat(Math.pow(Math.max(Kh.fromHalfFloat(f),0),1/2.2)),p=new Map,m=f=>{let g=p.get(f);return g===void 0&&(g=c(f),p.set(f,g)),g};for(let f=0;f<l;f++){let g=f*d,y=(l-1-f)*d;for(let v=0;v<d;v+=4)h[y+v]=m(u[g+v]),h[y+v+1]=m(u[g+v+1]),h[y+v+2]=m(u[g+v+2]),h[y+v+3]=u[g+v+3]}return{isSplineHdr:!0,data:h,width:o,height:l}}catch{return null}}(r):null;s!==null&&(this.isHdr=!0,this.img=s,e())}else this.img=new Image,this.img.src=typeof(i=t)=="string"?i:($2||($2=new yft),$2.load(i)),this.img.onload=e,await new Promise(r=>{this.img.onload=()=>{e(),r(null)}});var i}getTexture(t,e=1008,i=1006){let r=this._cache[t]?.[e]?.[i];if(r)return r;{let s;return this.isBuffer?s=this.img.texture:this.isVideo?s=new z7(this.img,void 0,t,t):this.isHdr?(s=Sft(this.img),s.wrapS=t,s.wrapT=t,s.magFilter=i,s.minFilter=e):s=new pi(this.img,void 0,t,t,i,e),this.isBuffer||(s.anisotropy=8,s.generateMipmaps=e===1008),this.loaded&&(s.needsUpdate=!0),this._cache[t]===void 0&&(this._cache[t]={}),this._cache[t][e]===void 0&&(this._cache[t][e]={}),this._cache[t][e][i]=s,s}}setNeedsUpdate(t){if(!this.isBuffer)for(let e of Object.values(this._cache))for(let i of Object.values(e))for(let r of Object.values(i))r&&(r.needsUpdate=t)}disposeTextures(){for(let[t,e]of Object.entries(this._cache))for(let[i,r]of Object.entries(e))for(let[s,n]of Object.entries(r))n?.dispose(),this._cache[t]!==void 0&&this._cache[t][i]!==void 0&&(this._cache[t][i][s]=void 0)}dispose(){super.dispose(),this.disposeTextures()}}}),Aft=G(()=>{Mft(),pg=class extends xG{}});function i3t(t){if(typeof t=="string")return t;let e=OU.get(t);return e||(e={url:URL.createObjectURL(new Blob([t]))},OU.set(t,e)),e.url}var OU,r3t=G(()=>{OU=new Map});function s3t(){if(!IU)return OY||(OY=async function(){await Promise.resolve().then(()=>(pq(),hxt)),Cft(window!==void 0?window:global),IU=!0}())}var Cft,Eft,IU,OY,Pft=G(()=>{Eft=new Promise(t=>{Cft=t}),IU=!1});function IY(t,e){t.forEach(i=>{"dragDropActions"in i.data?(e.push(...i.data.dragDropActions.drag),e.push(...i.data.dragDropActions.drop)):"inActions"in i.data?(e.push(...i.data.inActions),e.push(...i.data.outActions)):"gameActions"in i.data?(e.push(...i.data.gameActions.idle),e.push(...i.data.gameActions.move),e.push(...i.data.gameActions.jump),e.push(...i.data.gameActions.run)):"breakpoints"in i.data?i.data.breakpoints.forEach(r=>{e.push(...r.data.actions)}):"actions"in i.data&&(e.push(...i.data.actions),i.data.actions.forEach(r=>{r.data.type==="Conditional"&&r.data.ifActions&&(e.push(...r.data.ifActions),e.push(...r.data.elseActions))}))})}function n3t(t){let e=!1,i=[];return t.scene.objects.traverse((r,s)=>{if(s.type==="Page"&&s.uiScene!==void 0&&s.uiScene.objects.traverse((n,a)=>{if(a.events===void 0||Array.isArray(a.events)===!1)return!0;IY(a.events,i),e=e||i.some(o=>o.data.type==="Audio")}),s.events===void 0||Array.isArray(s.events)===!1)return!0;IY(s.events,i),e=e||i.some(n=>n.data.type==="Audio")}),e}var BY,$1,wG=G(()=>{r3t(),Pft(),Eft.then(t=>BY=t),$1=class{constructor({src:t,volume:e,delay:i,loop:r}){let s;this._volume=1,this.delay=0,this._loop=1,this.loopsRemaining=0,this._status="stopped",this.onEnd=()=>{this.loopsRemaining===1/0?this.replay():this.loopsRemaining>1?(this.replay(),this.loopsRemaining--):(this._status="stopped",this.loopsRemaining=this._loop)},s=typeof t=="string"?{src:t}:{src:i3t(t),format:"wav"},this.sound=new BY.Howl(s),this.sound.on("end",this.onEnd),this.src=t,e!==void 0&&(this.volume=e),i!==void 0&&(this.delay=i),r!==void 0&&(this.loop=r)}get status(){return this._status}get volume(){return this._volume}set volume(t){this._volume=t,this.sound.volume(t)}get loop(){return this._loop}set loop(t){this._loop=t,this.loopsRemaining=t}replay(){this.clearDelay(),this.delayTimerId=window.setTimeout(()=>{this.sound.play(),this.clearDelay()},this.delay)}fade(t,e=1e3){t?(this.sound.volume(this._volume),this.clearFade(),this.fadeTimerId=window.setTimeout(()=>{this.sound.fade(this._volume,0,e),this.clearFade()},t)):this.sound.fade(this._volume,0,e)}on(t,e,i){this.sound.on(t,e,i)}off(t,e,i){this.sound.off(t,e,i)}play(){this._status==="playing"||this.sound.playing()||(this._status==="paused"?(this.sound.seek()===0?this.replay():this.sound.play(),this._status="playing"):this._status==="stopped"&&(this.replay(),this._status="playing"))}pause(){this._status==="playing"&&(this.sound.pause(),this.clearFade(),this.clearDelay(),this._status="paused")}stop(){this.sound.stop(),this.loopsRemaining=this._loop,this.clearFade(),this.clearDelay(),this._status="stopped"}clearFade(){this.fadeTimerId&&(clearTimeout(this.fadeTimerId),delete this.fadeTimerId)}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}dispose(t=!1){this.off(),this.stop(),this.clearFade(),this.clearDelay()}}});function VY(t){let e=!1;return t.scene.objects.traverse((i,r)=>{r.type==="Mesh"&&(r.geometry.type==="TextGeometry"||r.geometry.type==="InputGeometry")&&(e=!0)}),e}var SG,TG=G(()=>{SG=null});function kY(t){return new Z(t.y,-t.x)}var MG,BU,Rft,Dft,RM,zY,TR,Nft,CO,MR=G(()=>{dt(),MG=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=t.parameters?.radiusTop,r=t.parameters?.radiusBottom,s=Object.assign({},e?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},t.parameters);s.thetaLength=qt.clamp(s.thetaLength,0,360),s.hollow=qt.clamp(s.hollow??0,0,1);let n=s.width/2,a=s.radiusTop??n,o=s.radiusBottom??n;if(a===o?(a=n,o=n):a>o?(a=n,o=o*n/a):(a=a*n/o,o=n),s.shapeBlendNode){a=i??n,o=r??n;let l=2*Math.max(a,o);s.width=l,s.depth=l}return{parameters:Object.assign(s,{width:Math.abs(s.width),height:Math.abs(s.height??s.width),depth:Math.abs(s.depth??s.width),radiusTop:a,radiusBottom:o})}}static build(t){let e,{width:i,depth:r,height:s,radialSegments:n,heightSegments:a,openEnded:o,thetaStart:l,thetaLength:u,radiusTop:h,radiusBottom:d,cornerRadius:c,cornerSegments:p,hollow:m}=t.parameters;u===0?(e=new ye,e.setAttribute("position",new fe([],3))):e=c||m?new BU(h,d,s,n,a,o,l,u*Math.PI/180,c,c,p,m):new V2(h,d,s,n,a,o,l,u*Math.PI/180);let f=r/i;return f!==1&&e.scale(1,1,f),Object.assign(e,{userData:{...t,type:"CylinderGeometry"}})}},BU=class extends ye{constructor(t,e,i,r,s,n,a,o,l,u,h,d,c=!1){super(),this.type="RoundedCylinderBufferGeometry",t=t!==void 0?t:1,e=e!==void 0?e:1,i=i||1,r=Math.floor(r)||8,s=Math.floor(s)||1,n=n!==void 0&&n,a=a!==void 0?a:0,o=o!==void 0?o:2*Math.PI,n&&(l=0,u=0);let p=i/2;c&&t==0&&(t=l),c&&e==0&&(e=u);let m=new Z(t,p),f=new Z(e,-p),g=null,y=null,v=null,b=null,_=m.clone().sub(f),x=0,S=0,w=0;d>0&&(x=Math.min(t,e)*(1-d),S=t-x,w=e-x);let T=m.clone();T.x-=x;let A=Math.PI-_.angle(),M=_.angle(),C=Math.tan(M/2),R=Math.tan(A/2),O=C+R,N=d?O:R,B=d?O:C;if(l=Math.min(l,(t-S)/N,_.length()/O),u=Math.min(u,(e-w)/B,_.length()/O),l>0){let Bt=l/C;g=m.clone().sub(new Z(Bt,l)),d&&(v=g.clone(),v.x-=x-O*l),m.sub(_.clone().setLength(Bt))}if(u>0){let Bt=u/R;y=f.clone().sub(new Z(Bt,-u)),f.add(_.clone().setLength(Bt)),d&&(b=y.clone(),b.x-=x-O*u,T.sub(_.clone().setLength(Bt)))}_=m.clone().sub(f);let k=_.length()<.5,z=[],L=[],V=[],q=[],j=[],Q=[],it=(Bt,jt,Xt,Dt,le)=>{for(let Wt=0;Wt<h+1;Wt++){let Qt=Wt/h,ee=Dt<0?Qt:1-Qt;le&&(ee-=1),ee*=Bt;let $=Math.sin(ee),se=Math.cos(ee)*Dt,Pe=se*jt+Xt.y;z.push($*jt+Xt.x),L.push(Pe),V.push($),q.push(se),j.push(.5+Pe/i),Q.push(!1)}},at=(Bt,jt,Xt)=>{let Dt=[Bt,jt];Xt<0&&Dt.reverse();for(let le of Dt)z.push(le),L.push(p*Xt),V.push(0),q.push(Xt),j.push(.5),Q.push(!0)};if(b&&y?(it(A,u,b,-1,!0),it(M,u,y,-1,!1)):y?(at(y.x,0,-1),it(M,u,y,-1,!1)):n||at(e,w,-1),!k){let Bt=kY(_).normalize();for(let jt=0;jt<=s;jt++){let Xt=jt/s,Dt=_.y*Xt+f.y;z.push(_.x*Xt+f.x),L.push(Dt),V.push(Bt.x),q.push(Bt.y),j.push(.5+Dt/i),Q.push(!1)}}if(v&&g?(it(A,l,g,1,!1),it(M,l,v,1,!0)):g?(it(A,l,g,1,!1),at(g.x,0,1)):n||at(t,S,1),d&&!k){let Bt=kY(_).multiplyScalar(-1).normalize();for(let jt=0;jt<=s;jt++){let Xt=jt/s,Dt=_.y*-Xt+T.y;z.push(_.x*-Xt+T.x),L.push(Dt),V.push(Bt.x),q.push(Bt.y),j.push(.5+Dt/i),Q.push(!1)}}let St=z.length,yt=St+(d&&!n?1:0),Y=(Bt,jt)=>Bt*St+(jt===St?0:jt),pt=o<2*Math.PI,xt=(r+1)*St+(pt?2*(1+yt):0),Tt=new Float32Array(3*xt),Mt=new Float32Array(3*xt),_t=new Float32Array(2*xt),kt=xt-1>65535?new Uint32Array(r*Math.max(0,yt-1)*6+(pt?2*(yt+1)*3:0)):new Uint16Array(r*Math.max(0,yt-1)*6+(pt?2*(yt+1)*3:0)),Ut=0,Lt=0;for(let Bt=0;Bt<=r;Bt++){let jt=Bt/r,Xt=jt*o+a,Dt=Math.sin(Xt),le=Math.cos(Xt);for(let Wt=0;Wt<St;Wt++){let Qt=3*Lt,ee=2*Lt,$=z[Wt],se=V[Wt];Tt[Qt]=$*Dt,Tt[Qt+1]=L[Wt],Tt[Qt+2]=$*le,Mt[Qt]=se*Dt,Mt[Qt+1]=q[Wt],Mt[Qt+2]=se*le,Q[Wt]?(_t[ee]=.5,_t[ee+1]=.5):(_t[ee]=jt,_t[ee+1]=j[Wt]),Lt++}}for(let Bt=0;Bt<r;Bt++)for(let jt=0;jt<yt-1;jt++){if(n&&d&&jt==s)continue;let Xt=Y(Bt,jt),Dt=Y(Bt+1,jt),le=Y(Bt+1,jt+1),Wt=Y(Bt,jt+1),Qt=Tt[3*le+0],ee=Tt[3*le+2];kt[Ut++]=Xt,kt[Ut++]=Dt,kt[Ut++]=Wt,(Qt!=0||ee!=0)&&(kt[Ut++]=Dt,kt[Ut++]=le,kt[Ut++]=Wt)}function zt(Bt,jt,Xt){let Dt=Math.sin(Xt),le=Math.cos(Xt),Wt=-le,Qt=Dt,ee=Bt<0?(ie,oi,xi)=>{kt[Ut++]=ie,kt[Ut++]=oi,kt[Ut++]=xi}:(ie,oi,xi)=>{kt[Ut++]=ie,kt[Ut++]=xi,kt[Ut++]=oi},$=(t+e+S+w)/4,se=3*Lt,Pe=2*Lt;Tt[se]=$*Dt,Tt[se+1]=0,Tt[se+2]=$*le,Mt[se]=Wt,Mt[se+1]=0,Mt[se+2]=Qt,_t[Pe]=.5,_t[Pe+1]=.5;let Ve=Lt++;for(let ie=0;ie<yt;ie++){let oi=3*(jt+(ie===St?0:ie));se=3*Lt,Pe=2*Lt,Tt[se]=Tt[oi],Tt[se+1]=Tt[oi+1],Tt[se+2]=Tt[oi+2],Mt[se]=Wt,Mt[se+1]=0,Mt[se+2]=Qt;let xi=oi/3*2|0;_t[Pe]=_t[xi],_t[Pe+1]=_t[xi+1],Lt++}for(let ie=Ve+1;ie<Lt-1;ie++)ee(Ve,ie,ie+1);ee(Ve,Lt-1,Ve+1)}pt&&(zt(-1,0,a),zt(1,r*St,a+o)),this.setIndex(new we(kt.slice(0,Ut),1)),this.setAttribute("position",new we(Tt,3)),this.setAttribute("normal",new we(Mt,3)),this.setAttribute("uv",new we(_t,2))}}}),LY=G(()=>{dt(),MR(),Rft=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:8,cornerRadiusBottom:8,cornerSegments:8},t.parameters);return i.thetaLength=qt.clamp(i.thetaLength,0,360),{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(t){let e,{width:i,depth:r,height:s,radialSegments:n,heightSegments:a,openEnded:o,thetaStart:l,thetaLength:u,cornerRadiusTop:h,cornerRadiusBottom:d,cornerSegments:c}=t.parameters;u===0?(e=new ye,e.setAttribute("position",new fe([],3))):e=h>0||d>0||u<360?new BU(0,i/2,s,n,a,o,l,u*Math.PI/180,h,d,c,0,!0):new q4(i/2,s,n,a,o);let p=r/i;return p!==1&&e.scale(1,1,p),Object.assign(e,{userData:{...t,type:"ConeGeometry"}})}}}),FY=G(()=>{dt(),Dft=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},t.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(t){let e,{width:i,height:r,depth:s,widthSegments:n,heightSegments:a,depthSegments:o,cornerRadius:l,cornerSegments:u}=t.parameters;return e=l===0?new Zh(i,r,s,n,a,o):new zY(i,r,s,n,a,o,l,u),Object.assign(e,{userData:{...t,type:"CubeGeometry"}})}},RM=Math.PI/2,zY=class extends ye{constructor(t=1,e=1,i=1,r=1,s=1,n=1,a=0,o=4){super(),this.type="BoxGeometry",r=Math.floor(r),s=Math.floor(s),n=Math.floor(n),o=Math.floor(o);let l=(a=Math.min(a,t/2,e/2,i/2))>0,u=o+1,h=2*((n+1)*(s+1)+(r+1)*(n+1)+(r+1)*(s+1))+(l?4*u*(n+1+(r+1)+(s+1))+u*(u+1)/2*8:0),d=2*(n*s+r*n+r*s)+(l?4*o*(n+r+s):0),c=l?8*o*o:0,p=new Float32Array(3*h),m=new Float32Array(3*h),f=new Float32Array(2*h),g=h-1>65535?new Uint32Array(6*d+3*c):new Uint16Array(6*d+3*c),y=0,v=0,b=new Float64Array(u),_=new Float64Array(u),x=new Float64Array(u),S=new Float64Array(u);for(let O=0;O<u;O++){let N=O/o*RM;b[O]=Math.sin(N)*a,_[O]=(1-Math.cos(N))*a,x[O]=Math.sin(N),S[O]=Math.cos(N)}let w=u*(u+1)/2,T=new Float64Array(3*w),A=new Float64Array(3*w);{let O=new P(t/2,e/2,i/2);O.subScalar(a);let N=0;for(let B=0;B<=o;B++){let k=RM*(1-B/o),z=Math.cos(k),L=Math.sin(k),V=0;for(let q=0;q<=B;q++){let j=z*Math.cos(V),Q=L,it=z*Math.sin(V);T[3*N]=j,T[3*N+1]=Q,T[3*N+2]=it,A[3*N]=O.x+j*a,A[3*N+1]=O.y+Q*a,A[3*N+2]=O.z+it*a,N++,V+=RM/B}}}function M(O,N,B,k,z,L,V,q,j,Q){let it=(L-2*a)/j,at=(V-2*a)/Q,St=L/2-a,yt=V/2-a,Y=q/2,pt=j+1,xt=Q+1,Tt=0,Mt=new P;for(let _t=0;_t<xt;_t++){let kt=_t*at-yt;for(let Ut=0;Ut<pt;Ut++){let Lt=Ut*it-St,zt=3*(y+Tt),Bt=2*(y+Tt);Mt[O]=Lt*k,Mt[N]=kt*z,Mt[B]=Y,p[zt]=Mt.x,p[zt+1]=Mt.y,p[zt+2]=Mt.z,Mt[O]=0,Mt[N]=0,Mt[B]=q>0?1:-1,m[zt]=Mt.x,m[zt+1]=Mt.y,m[zt+2]=Mt.z,f[Bt]=Ut/j,f[Bt+1]=1-_t/Q,Tt+=1}}for(let _t=0;_t<Q;_t++)for(let kt=0;kt<j;kt++){let Ut=y+kt+pt*_t,Lt=y+kt+pt*(_t+1),zt=y+(kt+1)+pt*(_t+1),Bt=y+(kt+1)+pt*_t;g[v++]=Ut,g[v++]=Lt,g[v++]=Bt,g[v++]=Lt,g[v++]=zt,g[v++]=Bt}y+=Tt}function C(O,N,B,k,z,L,V,q,j,Q){let it=(V-2*a)/Q,at=V/2-a,St=q/2-a,yt=j/2,Y=Q+1,pt=0,xt=new P,Tt=new P;for(let Mt=0;Mt<o+1;Mt++){xt[N]=(St+b[Mt])*z,xt[B]=(yt-_[Mt])*L,Tt[O]=0,Tt[N]=x[Mt]*Math.sign(xt[N]),Tt[B]=S[Mt]*Math.sign(xt[B]);for(let _t=0;_t<Y;_t++){let kt=_t*it-at;xt[O]=kt*k;let Ut=3*(y+pt),Lt=2*(y+pt);p[Ut]=xt.x,p[Ut+1]=xt.y,p[Ut+2]=xt.z,m[Ut]=Tt.x,m[Ut+1]=Tt.y,m[Ut+2]=Tt.z,f[Lt]=_t/Q,f[Lt+1]=0,pt+=1}}for(let Mt=0;Mt<o;Mt++)for(let _t=0;_t<Q;_t++){let kt=y+_t+Y*Mt,Ut=y+_t+Y*(Mt+1),Lt=y+(_t+1)+Y*(Mt+1),zt=y+(_t+1)+Y*Mt;g[v++]=kt,g[v++]=Ut,g[v++]=zt,g[v++]=Ut,g[v++]=Lt,g[v++]=zt}y+=pt}function R(O,N,B){let k=O*N*B>0?(L,V,q)=>{g[v++]=L,g[v++]=V,g[v++]=q}:(L,V,q)=>{g[v++]=L,g[v++]=q,g[v++]=V},z=y;for(let L=0;L<w;L++){let V=3*L,q=3*y,j=2*y;p[q]=O*A[V],p[q+1]=N*A[V+1],p[q+2]=B*A[V+2],m[q]=O*T[V],m[q+1]=N*T[V+1],m[q+2]=B*T[V+2],f[j]=0,f[j+1]=0,y++}for(let L=0;L<o;L++){let V=z+L*(L+1)/2,q=z+(L+1)*(L+2)/2;k(V,q+1,q);for(let j=1;j<=L;j++)k(V+j-1,V+j,q+j),k(V+j,q+j+1,q+j)}}M("z","y","x",-1,-1,i,e,t,n,s),M("z","y","x",1,-1,i,e,-t,n,s),M("x","z","y",1,1,t,i,e,r,n),M("x","z","y",1,-1,t,i,-e,r,n),M("x","y","z",1,-1,t,e,i,r,s),M("x","y","z",-1,-1,t,e,-i,r,s),a>0&&(C("z","y","x",-1,-1,1,i,e,t,n),C("z","y","x",1,-1,-1,i,e,t,n),C("z","y","x",-1,1,-1,i,e,t,n),C("z","y","x",1,1,1,i,e,t,n),C("x","y","z",-1,-1,-1,t,e,i,r),C("x","y","z",1,-1,1,t,e,i,r),C("x","y","z",-1,1,1,t,e,i,r),C("x","y","z",1,1,-1,t,e,i,r),C("y","x","z",-1,-1,1,e,t,i,s),C("y","x","z",1,-1,-1,e,t,i,s),C("y","x","z",1,1,1,e,t,i,s),C("y","x","z",-1,1,-1,e,t,i,s),R(1,1,1),R(-1,1,1),R(1,-1,1),R(-1,-1,1),R(1,1,-1),R(-1,1,-1),R(1,-1,-1),R(-1,-1,-1)),this.setIndex(new we(g,1)),this.setAttribute("position",new we(p,3)),this.setAttribute("normal",new we(m,3)),this.setAttribute("uv",new we(f,2))}}}),Oft=G(()=>{dt(),TR=class extends ye{constructor(t=[],e=[],i="",r=1,s=.2,n=4){super(),this.type="PolyhedronGeometryRound";let a,o,l,u=0;return function(){(s=Math.min(.99999,s))==0&&(n=0);let h={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[i],d=new P,c=d.clone(),p=new Os,m=s*r,f=r-m,g=n+1,y=new P,v=(Y,pt)=>y.subVectors(Y,pt).normalize(),b=(Y,pt)=>Array(Y).fill(void 0).map(pt),_=b(t.length/3,(Y,pt)=>new P().fromArray(t,3*pt).setLength(r)),x=[],S=1e6;for(let Y=0;Y<_.length;Y++){let pt,xt,Tt,Mt=_[Y],_t=[],kt=1e10,Ut=-1;for(;(Ut=e.indexOf(Y,Ut+1))!=-1;){let jt=Ut-Ut%3;pt=e[jt+(Ut+1)%3],xt=e[jt+(Ut+2)%3],Tt=Mt.distanceToSquared(_[pt]),kt=Math.min(kt,Tt),_t.push([pt,xt,Tt])}kt+=1e-6;let Lt=[],zt=0,Bt=_t.length;for(let jt=0;jt<Bt;jt++){[pt,xt,Tt]=_t[zt];let Xt=x[pt]?.includes(Y)==1;Tt<=kt&&Lt.push(pt+ +Xt*S),zt=_t.findIndex(Dt=>Dt[0]==xt)}x.push(Lt)}let w=[];{let Y,pt,xt=0,Tt=0,Mt=h==3;for(let _t=0;_t<=n;_t++){Y=_t*(_t+1)/2,pt=(_t+1)*(_t+2)/2;for(let kt=0;kt<n-_t;kt++)[xt,Tt]=[Y+kt+_t+2,pt+kt+_t+3],w.push(Y,pt,...Mt?[Tt,Y]:[xt,pt],Tt,xt),[Y,pt]=[xt,Tt];w.push(Y,pt,Y+n+2)}}let T=0;for(let Y=0;Y<x.length;Y++)for(let pt=0;pt<h;pt++)x[Y][pt]<S&&T++;let A=_.length*h*w.length*3+T*g*6*3+2*T*3*3;a=new Float64Array(A),o=new Float64Array(A),l=new Float64Array(A/3*2);let M=(Y,pt,xt)=>{let Tt=u/3*2;l[Tt]=Math.atan2(xt,-Y)/2/Math.PI+.5,l[Tt+1]=1-(Math.atan2(-pt,Math.sqrt(Y*Y+xt*xt))/Math.PI+.5)},C=Y=>{a[u]=Y.x,a[u+1]=Y.y,a[u+2]=Y.z,o[u]=y.x,o[u+1]=y.y,o[u+2]=y.z,M(Y.x,Y.y,Y.z),u+=3},R=Y=>{a[u]=Y[0].x,a[u+1]=Y[0].y,a[u+2]=Y[0].z,o[u]=Y[1].x,o[u+1]=Y[1].y,o[u+2]=Y[1].z,M(Y[0].x,Y[0].y,Y[0].z),u+=3},O=(n+2)*(n+3)/2,N=new Float64Array(3*O),B=new Float64Array(3*O),k=new Float64Array(2*O),z=b(2*h*g,()=>new P),L=b(n*Math.max(0,n-1)/2,()=>new P),V=d.clone(),q=d.clone(),j=d.clone(),Q=d.clone(),it=d.clone(),at=[],St=b(_.length,()=>b(h,()=>d.clone()));for(let Y=0;Y<_.length;Y++){d.copy(_[Y]).normalize(),V.copy(d).multiplyScalar(f);let pt=x[Y];for(let Lt=0;Lt<pt.length;Lt++){let zt=pt[Lt],Bt=pt[(Lt+1)%h];p.setFromPointsAndIndices(_,Y,zt%S,Bt%S),p.b.sub(p.a).setLength(1e10).add(p.a),p.c.sub(p.a).setLength(1e10).add(p.a),p.closestPointToPoint(V,St[Y][Lt])}let xt=0,Tt=[],Mt=[],_t=new P;n==0&&[...St[Y]].reduce((Lt,zt)=>Lt.add(zt),_t).multiplyScalar(1/h);for(let Lt=0;Lt<h;Lt++){let zt=[],Bt=(Lt-1+h)%h,jt=St[Y][Bt],Xt=St[Y][Lt];d.copy(jt).sub(V),c.copy(Xt).sub(V);let Dt=V.angleTo(d),le=d.angleTo(c),Wt=Math.cos(Dt)*m;n==0?q.copy(_t):q.copy(V).setLength(f+Wt),Tt.push(Wt);let Qt=[q,jt,Xt];for(let ee=0;ee<2;ee++){let $=Qt[ee],se=Qt[ee+1];Q.subVectors($,V),it.subVectors(se,V),j.crossVectors(Q,it).normalize();for(let Pe=0;Pe<g;Pe++){let Ve=[Dt,le][ee]*Pe/g;d.copy(Q).applyAxisAngle(j,Ve).add(V),z[xt++].copy(d),ee&&(v(d,V),zt.push([Pe==0?$:d.clone(),y.clone()]))}ee&&(v(se,V),zt.push([se,y.clone()]))}Mt.push(zt)}at.push(Mt);let kt=2*g,Ut=2;for(let Lt=0;Lt<h;Lt++){let zt=kt*Lt,Bt=kt*((Lt+1)%h),jt=0,Xt=[z[zt]];for(let Dt=1;Dt<g;Dt++){let le=z[zt+Dt],Wt=z[Bt+Dt];Xt.push(le);for(let Qt=1,ee=Dt-Ut+1;Qt<=ee;Qt++)d.lerpVectors(le,Wt,Qt/(ee+1)),d.sub(V).setLength(Tt[Lt]).add(V),Xt.push(L[jt++].copy(d));Xt.push(Wt)}for(let Dt=0;Dt<g;Dt++)Xt.push(z[Dt+g+zt]);Xt.push(z[Bt+g]);for(let Dt=0,le=Xt.length;Dt<le;Dt++){let Wt=Xt[Dt],Qt=3*Dt,ee=2*Dt;N[Qt]=Wt.x,N[Qt+1]=Wt.y,N[Qt+2]=Wt.z,v(Wt,V),B[Qt]=y.x,B[Qt+1]=y.y,B[Qt+2]=y.z,k[ee]=Math.atan2(Wt.z,-Wt.x)/2/Math.PI+.5,k[ee+1]=1-(Math.atan2(-Wt.y,Math.sqrt(Wt.x*Wt.x+Wt.z*Wt.z))/Math.PI+.5)}for(let Dt=0,le=w.length;Dt<le;Dt++){let Wt=3*w[Dt],Qt=2*w[Dt],ee=u/3*2;a[u]=N[Wt],a[u+1]=N[Wt+1],a[u+2]=N[Wt+2],o[u]=B[Wt],o[u+1]=B[Wt+1],o[u+2]=B[Wt+2],l[ee]=k[Qt],l[ee+1]=k[Qt+1],u+=3}}}let yt=[];for(let Y=0;Y<x.length;Y++)for(let pt=0;pt<h;pt++){let xt=x[Y][pt];if(xt<S){let Tt=x[xt].findIndex(kt=>kt%S==Y),Mt=at[Y][pt],_t=at[xt][Tt];for(let kt=0;kt<g;kt++){let Ut=Mt[kt],Lt=_t[g-kt],zt=Mt[kt+1],Bt=_t[g-(kt+1)];R(Ut),R(Lt),R(zt),R(zt),R(Lt),R(Bt)}yt.push(Mt[0][0],_t[g][0],Mt[g][0],_t[0][0])}}for(;yt.length;){let Y,pt,xt,[Tt,Mt]=yt.splice(0,2);Y=Mt;let _t=[Tt];for(;Tt!=Y;)_t.push(Y),pt=yt.indexOf(Y),xt=pt%2,Y=yt.splice(pt-xt,2)[1-xt];y.subVectors(_t[0],_t[1]).cross(d.subVectors(_t[0],_t[2])).normalize();let kt=y.dot(_t[0])<0;kt&&y.negate();for(let Ut=1;Ut<=_t.length-2;Ut++)C(_t[Ut+ +kt]),C(_t[Ut+1-+kt]),C(_t[0])}}(),function(){let h=new P,d=new P,c=new P,p=new P,m=new Z,f=new Z,g=new Z,y=(_,x,S,w)=>{w<0&&_.x===1&&(l[x]=_.x-1),S.x===0&&S.z===0&&(l[x]=w/2/Math.PI+.5)};for(let _=0,x=0;_<u;_+=9,x+=6){h.set(a[_+0],a[_+1],a[_+2]),d.set(a[_+3],a[_+4],a[_+5]),c.set(a[_+6],a[_+7],a[_+8]),m.set(l[x+0],l[x+1]),f.set(l[x+2],l[x+3]),g.set(l[x+4],l[x+5]),p.copy(h).add(d).add(c).divideScalar(3);let S=b(p);y(m,x+0,h,S),y(f,x+2,d,S),y(g,x+4,c,S)}let v=u/3*2;for(let _=0;_<v;_+=6){let x=l[_+0],S=l[_+2],w=l[_+4],T=Math.max(x,S,w),A=Math.min(x,S,w);T>.9&&A<.1&&(x<.2&&(l[_+0]+=1),S<.2&&(l[_+2]+=1),w<.2&&(l[_+4]+=1))}function b(_){return Math.atan2(_.z,-_.x)}}(),this.setAttribute("position",new we(new Float32Array(a.subarray(0,u)),3)),this.setAttribute("normal",new we(new Float32Array(o.subarray(0,u)),3)),void this.setAttribute("uv",new we(new Float32Array(l.subarray(0,u/3*2)),2))}static fromJSON(t){return new TR(t.vertices,t.indices,t.radius,t.corner,t.cornerSides)}}}),UY=G(()=>{Oft(),dt(),Nft=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,detail:0,corner:0,cornerSides:4},t.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(t){let{width:e,height:i,depth:r,detail:s,corner:n,cornerSides:a}=t.parameters,o=s===0&&n!==0?new CO(.5*e,n,a):new v8(.5*e,s),l=i/e,u=r/e;return(l!==1||u!==1)&&o.scale(1,l,u),Object.assign(o,{userData:{...t,type:"DodecahedronGeometry"}})}},CO=class extends TR{constructor(t=1,e=.2,i=4){let r=(1+Math.sqrt(5))/2,s=1/r,n="DodecahedronGeometry";super([-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-s,-r,0,-s,r,0,s,-r,0,s,r,-s,-r,0,-s,r,0,s,-r,0,s,r,0,-r,0,-s,r,0,-s,-r,0,s,r,0,s],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],n,t,e,i),this.type=n}static fromJSON(t){return new CO(t.radius,t.corner,t.cornerSides)}}});function jY(t,e=new Z){let i=t.length();return e.set(-t.y/i,t.x/i)}function a3t(t){let e=new Z;e.addVectors(t.v0,Cg.subVectors(t.v1,t.v0).multiplyScalar(2/3));let i=new Z;return i.addVectors(t.v2,BS.subVectors(t.v1,t.v2).multiplyScalar(2/3)),new Kl(t.v0,e,i,t.v2)}function Zw(t,e,i=Number.EPSILON){return Math.abs(t-e)<i}function o3t(t,e,i=Number.EPSILON){return t.distanceTo(e)<i}function l3t(t,e,i=Number.EPSILON){return t.distanceTo(e)<i}function Ift(t,e,i){let r=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),s=Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2)),n=Math.sqrt(Math.pow(i.x-t.x,2)+Math.pow(i.y-t.y,2));return Math.acos((s*s+r*r-n*n)/(2*s*r))}function h3t(t,e,i){return WY(t,e)&&WY(e,i)&&VU(t.position,e.position,i.position)}function VU(t,e,i){return Cg.copy(e).sub(t).cross(BS.copy(i).sub(t))===0}function u3t(t,e,i,r,s){let n=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),a=(t.y+e.y)/2,o=(t.x+e.x)/2,l=Math.sqrt(Math.pow(i,2)-Math.pow(n/2,2))*(t.y-e.y)/n,u=Math.sqrt(Math.pow(i,2)-Math.pow(n/2,2))*(e.x-t.x)/n;return r.set(o+l,a+u),s.set(o-l,a-u),[r,s]}function d3t(t,e,i){return t.distanceTo(i)<e.distanceTo(i)?e:t}function c3t(t,e,i,r,s,n){let a,o=e.x-t.x,l=e.y-t.y,u=i.x-t.x,h=i.y-t.y,d=Math.sqrt((o+u)*(o+u)+(l+h)*(l+h));return Ift(e,t,i)>Math.PI&&(d*=-1),a=Zw(h,l)?(l+h)*(r/d-.5)*8/3/(o-u):(o+u)*(r/d-.5)*8/3/(h-l),s.set(e.x-a*l,e.y+a*o),n.set(i.x+a*h,i.y-a*u),[s,n]}function GY(t,e){return t.position.equals(t.controls[1].position)&&e.position.equals(e.controls[0].position)}function WY(t,e){return VU(t.position,t.controls[1].position,e.position)&&VU(t.position,e.controls[0].position,e.position)}function qY(t,e=12,i=!1){let r=[];for(let s=0,n=t.length;s<n;s++){let a=t[s],o=0;if(i&&a.roundedCurveCorner!==void 0){let l=.5*Ag(a.roundedCurveCorner,e);s>0&&(r[s-1]+=l),o+=l}a.curveAfter!==void 0&&(o+=Ag(a.curveAfter,e)),r.push(o)}return t.length>0&&i&&t[0].roundedCurveCorner!==void 0&&(r[t.length-1]+=.5*Ag(t[0].roundedCurveCorner,e)),r}function Ag(t,e=12){return t&&t instanceof Uw?2*e:t&&(t instanceof cl||t instanceof b8)?1:t&&t instanceof wP?e*t.points.length:e}var C1,DM,NM,jg,BP,Cg,BS,Bft,Vft,kft,zft,kU,zU,OM,HY,$Y,XY,YY,KY,ds,Lft=G(()=>{dt(),C1=1e-12,DM=class{constructor(t){this.position=new Z,this.startPosition=new Z,this.uuid=qt.generateUUID(),this.position=t.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(t){this.position.copy(this.startPosition).add(t)}copy(t){return this.position.copy(t.position),this.startPosition.copy(t.startPosition),this}clone(){return new DM(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},NM=class extends DM{constructor(t){super(t.position),this.parent=t}copy(t){return super.copy(t),this}clone(){return new NM(this.parent).copy(this)}},jg=class extends DM{constructor(t,e){super(e),this.controls=[],this.roundness=0,this.areControlsDirectionsMirrored=!0,this.uuid=t,this.controls.push(new NM(this),new NM(this))}static create(t,e){let i=new jg(t,new Z(...e.position));return i.controls[0].position.set(...e.controlPrevious.position),i.controls[1].position.set(...e.controlNext.position),i.roundness=e.roundness,i.areControlsDirectionsMirrored=e.areControlsDirectionsMirrored,i}getOppositeControl(t){let e=this.controls.indexOf(t);return e===0?this.controls[1]:e===1?this.controls[0]:null}applyOffsetToControls(t,e=1){for(let i=0,r=this.controls.length;i<r;i++){let s=this.controls[i];this.position.distanceTo(s.position)<=e?s.position.copy(this.position):s.applyOffset(t)}}controlsMoved(){return!(this.position.equals(this.controls[0].position)&&this.position.equals(this.controls[1].position))}copy(t){return super.copy(t),this.controls[0].copy(t.controls[0]),this.controls[1].copy(t.controls[1]),this.roundness=t.roundness,this.uuid=t.uuid,this}clone(){return new jg(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}computeTangents(){let t=this.curveBefore?.getTangentAt(1),e=this.curveAfter?.getTangentAt(0);return[t,e]}computeNormals(t=new Z,e=new Z){let[i,r]=this.computeTangents();return i&&r&&(jY(i,t),jY(r,e)),[t,e]}computeTangent(t=new Z){let[e,i]=this.computeTangents();return e&&i&&t.copy(e).add(i).normalize(),t}computeNormal(t=new Z){let[e,i]=this.computeNormals();return t.copy(e).add(i).normalize(),t}},BP=t=>t,Cg=new Z,BS=new Z,Bft=new Z,Vft=new Z,kft=new Z,zft=new Z,kU=new P,zU=new P}),_m=G(()=>{dt(),Lft(),OM=new Z,HY=new Z,$Y=new Z,XY=new Z,YY=new Z,KY=new Z,ds=class extends bS{constructor(t=100,e=100){super(),this.points=[],this.shapeHoles=[],this.plane=new Ra(new P(0,0,-1)),this.subdivision=0,this.controlSnapDistance=4,this.pointIDs=0,this.isMesh2D=!1,this.isText=!1,this._roundness=0,this.isClosed=!1,this.useCubicForRoundedCorners=!0,this.uuid=qt.generateUUID(),this.needsUpdate=!1,this.roundedCurves=[],this._width=t,this._height=e}static createFromState(t,e,i){let r=new ds;return r.isClosed=t.isClosed,r.points=t.points.map(s=>jg.create(s.id,s.data)),typeof t.roundness=="number"&&(r.roundness=t.roundness),r.shapeHoles=t.shapeHoles.map(s=>ds.createFromState(s)),e!==void 0&&i!==void 0&&r.applySize(e,i),r.update(),r}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(t){if(this._roundness!==t){this._roundness=t;for(let e=0,i=this.points.length;e<i;e++)this.points[e].roundness=t;this.needsUpdate=!0}}getPointsIndexesByIds(t){return t.map(e=>this.getPointIndexById(e)).filter(e=>e>=0)}getPointIndexById(t){let e=this.points.length,i=this.points.findIndex(r=>r.uuid===t);if(i<0){let r=e;for(let s=0,n=this.shapeHoles.length;s<n;s++){let a=this.shapeHoles[s],o=a.points.length,l=a.getPointIndexById(t);if(!(l<0))return l+r;r+=o}}return i}getLineIndexById(t){return this.getPointIndexById(t)}getBezierPoint(t){if(t<=this.points.length-1)return this.points[t];if(this.shapeHoles.length>0){let e=this.points.length;for(let i=0,r=this.shapeHoles.length;i<r;i++){let s=this.shapeHoles[i],n=t-e;if(n<=s.points.length-1)return s.points[n];e+=s.points.length}}throw new Error("This shape does not have a point for this index: "+t)}getBezierPointIndex(t){let e=this.points.indexOf(t);if(e>=0)return e;if(e=this.points.length,this.shapeHoles.length>0)for(let i=0,r=this.shapeHoles.length;i<r;i++){let s=this.shapeHoles[i],n=s.points.indexOf(t);if(n>=0)return e+n;e+=s.points.length}return-1}getAllPoints(){let t=[].concat(...this.shapeHoles.map(e=>e.points));return[...this.points,...t]}applySize(t,e){t===0&&(t=.001),e===0&&(e=.001),this._width=t,this._height=e}applyScale(t,e){let i=OM.set(t,e);for(let r=0,s=this.points.length;r<s;r++){let n=this.points[r];n.position.multiply(i),n.controls[0].position.multiply(i),n.controls[1].position.multiply(i)}for(let r=0,s=this.shapeHoles.length;r<s;r++)this.shapeHoles[r].applyScale(t,e);this._update()}createPoint(t,e=0,i=qt.generateUUID()){let r;r=t instanceof Z?t:new Z(t,e);let s=new jg(i,r);return s.roundness=this.roundness,s}addPoint(t){this.points.push(t),this.needsUpdate=!0}addPointAt(t,e){this.points.splice(e,0,t),this.needsUpdate=!0}getPointByUuid(t){for(let e=0,i=this.points.length;e<i;e++){let r=this.points[e];if(r.uuid===t)return r}for(let e=0,i=this.shapeHoles.length;e<i;e++){let r=this.shapeHoles[e].getPointByUuid(t);if(r)return r}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(t){let e=this.points.indexOf(t);e>=0&&this.points.splice(e,1),this.needsUpdate=!0}removePointById(t){let e=this.points.find(i=>i.uuid===t);e&&this.removePoint(e)}update(){for(let t=0,e=this.shapeHoles.length;t<e;t++)this.shapeHoles[t].update();this._update()}extractShapePointsToBuffer(t,e=12,i=!1){this.subdivision=e,this.curveDivisions===void 0&&this.computeCurveDivisions(e);let r=i?this.roundedCurveDivisions:this.curveDivisions;return function(s,n,a=12,o=!0){let l,u=zU.set(0,0,0),h=0,d=[];for(let c=0;c<n.length;c++){let p=BP(n[c]),m=Cg,f=Ag(p,a);d.push(f);for(let g=0;g<=f;g++)if(p instanceof Kl||p instanceof oc||p instanceof cl){if(p.getPoint(g/f,m),u.set(m.x,m.y,0),l!==void 0&&l3t(l,u))continue;l===void 0&&(l=kU),l.copy(u),s.setXYZ(h,u.x,u.y,u.z),h++}}o&&h>1&&(s.getX(h-1)!==s.getX(0)||s.getY(h-1)!==s.getY(0)||s.getZ(h-1)!==s.getZ(0))&&(s.setXYZ(h,s.getX(0),s.getY(0),s.getZ(0)),h++)}(t,i?this.roundedCurves:this.curves,e,this.autoClose),r.reduce((s,n)=>s+n,0)+1}computeCurveDivisions(t=12){return this.curveDivisions=qY(this.points,t,!1),this.roundedCurveDivisions=qY(this.points,t,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(t,e,i=12){return 2*function(r,s,n,a=12,o=!0){let l=zU.set(0,0,0),u=0,h=[];for(let d=0;d<s.length;d++){if(n[d]===!1)continue;let c,p=BP(s[d]),m=Cg,f=Ag(p,a);h.push(f);for(let g=0;g<=f;g++)if(p instanceof Kl||p instanceof oc||p instanceof cl){if(p.getPoint(g/f,m),l.set(m.x,m.y,0),c?.equals(l))continue;c===void 0?c=kU:(r.setXYZ(u,c.x,c.y,c.z),u++,r.setXYZ(u,l.x,l.y,l.z),u++),c.copy(l)}}return o&&u>1&&!(r.getX(u-1)===r.getX(0)&&r.getY(u-1)===r.getY(0)&&r.getZ(u-1)===r.getZ(0))&&(r.setXYZ(u,r.getX(0),r.getY(0),r.getZ(0)),u++),h}(t,this.curves,e,i,this.autoClose).reduce((r,s)=>r+s,0)}extractShapePointsToFlatArray(t,e=12){return this.subdivision=e,this.curveDivisions===void 0&&this.computeCurveDivisions(e),function(i,r,s=12,n=!0){let a,o=0;for(let l=0;l<r.length;l++){let u=BP(r[l]),h=Ag(u,s),d=Cg;for(let c=0;c<=h;c++)if(u instanceof Kl||u instanceof oc||u instanceof cl){if(u.getPoint(c/h,d),a!==void 0&&o3t(a,d,C1))continue;a===void 0&&(a=BS),a.copy(d),i.push(d.x,d.y),o++}}return Zw(i[0],i[i.length-2],C1)&&Zw(i[1],i[i.length-1],C1)&&(i.pop(),i.pop()),n&&o>1&&!(Zw(i[o-1],i[1],C1)&&Zw(i[o-2],i[0],C1))&&(i.push(i[0],i[1]),o++),i}(t,this.roundedCurves,e,this.autoClose)}getCurveIndexFromVertexId(t,e=!1){let i=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let r=e?this.roundedCurveDivisions:this.curveDivisions,s=0;e&&this.points[0].roundedCurveCorner!==void 0&&(s=.5*Ag(this.points[0].roundedCurveCorner,this.subdivision));let n=t-s;n<0&&(n+=r.reduce((a,o)=>a+o,0));for(let a=0,o=r.length;a<o;a++){let l=r[a];if(n<i+l)return[a,(n-i+1)/l];i+=l}return[0,1]}getCurveT(t,e,i){let r=this.points[t],s=this.points[t>=this.points.length-1?0:t+1],n=this.curveDivisions,a=n[t];if(GY(r,s)){let l=r.position.distanceTo(s.position);return r.position.distanceTo(OM.set(i.x,i.y))/l}let o=0;for(let l=0;l<t;l++)o+=n[l];return(e-o)/a}dispose(){}_applyCurveForPoint(t,e){GY(e,t)?this.lineTo(t.position.x,t.position.y):this.bezierCurveTo(e.controls[1].position.x,e.controls[1].position.y,t.controls[0].position.x,t.controls[0].position.y,t.position.x,t.position.y);let i=this.curves[this.curves.length-1];t.curveBefore=i,e.curveAfter=i;let r=i.clone();t.roundedCurveBefore=r,e.roundedCurveAfter=r,t.roundedCurveCorner=void 0,this.roundedCurves.push(r)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let e=0,i=this.points.length;e<i;e++){let r=this.points[e];if(e===0)this.moveTo(r.position.x,r.position.y);else{let s=this.points[e-1];this._applyCurveForPoint(r,s)}}let t=this.getLastPoint();if(t?.curveAfter&&(t.curveAfter=void 0),this.isClosed){let e=this.points[0],i=this.points[this.points.length-1];this._applyCurveForPoint(e,i)}if(this.points.length>2){let e=0;for(let i=0,r=this.points.length;i<r;i++){let s=this.points[i],n=this.points[i-1]??this.points[this.points.length-1],a=this.points[i+1]??this.points[0],o=s.roundness,l=n&&a&&h3t(n,s,a);if(!s.controlsMoved()&&o>0&&!l){let u=s.curveBefore,h=s.curveAfter;if(u===void 0||h===void 0)continue;let d,c=s.roundedCurveBefore,p=s.roundedCurveAfter,m=u instanceof cl?u.v1.distanceTo(u.v2):u.getLength(),f=h instanceof cl?h.v1.distanceTo(h.v2):h.getLength(),g=Math.min(o,.499*m),y=Math.min(o,.499*f),v=Math.min(g,y),b=1-v/m,_=v/f,x=u.getPointAt(b,OM),S=h.getPointAt(_,HY);if(this._subSplitCurve(u,c,b,x,void 0),this._subSplitCurve(h,p,_,void 0,S),this.useCubicForRoundedCorners){let w=Ift(x,s.position,S)/2,T=Math.tan(w)*x.distanceTo(s.position),[A,M]=u3t(x,S,T,$Y,XY),C=d3t(A,M,s.position),[R,O]=c3t(C,x,S,T,YY,KY);d=new Kl(x.clone(),R.clone(),O.clone(),S.clone())}else d=new oc(x.clone(),s.position.clone(),S.clone());s.roundedCurveCorner=d,this.roundedCurves.splice(i+e,0,d),e++}}}}_subSplitCurve(t,e,i,r,s){if(!(t instanceof cl)){let n=t,a=e,o=n.getUtoTmapping(i,0),l=function(u,h,d,c,p=.5){let m=Cg.subVectors(h,u).multiplyScalar(p).add(u),f=BS.subVectors(d,h).multiplyScalar(p).add(h),g=Bft.subVectors(c,d).multiplyScalar(p).add(d),y=m,v=Vft.subVectors(f,m).multiplyScalar(p).add(m),b=kft.subVectors(g,f).multiplyScalar(p).add(f),_=g,x=zft.subVectors(b,v).multiplyScalar(p).add(v);return[u.x,u.y,y.x,y.y,v.x,v.y,x.x,x.y,b.x,b.y,_.x,_.y,c.x,c.y]}(n.v0,n.v1,n.v2,n.v3,o);return r!==void 0&&(a.v0.set(l[0],l[1]),a.v1.set(l[2],l[3]),a.v2.set(l[4],l[5]),a.v3.set(l[6],l[7])),s!==void 0&&(a.v0.set(l[6],l[7]),a.v1.set(l[8],l[9]),a.v2.set(l[10],l[11]),a.v3.set(l[12],l[13])),a}return r!==void 0&&e.v2.copy(r),s!==void 0&&e.v1.copy(s),e}clone(){let t=new ds(this._width,this._height);return t.points=this.points.map(e=>e.clone()),t.isClosed=this.isClosed,t.roundness=this.roundness,t.isMesh2D=this.isMesh2D,t.shapeHoles=this.shapeHoles.map(e=>e.clone()),t}toJSON(){return{points:this.points.reduce((t,e)=>t.concat(e.toJSON()),[]),shapeHoles:this.shapeHoles.map(t=>t.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(t){this.points=[],this.pointIDs=0;let e=t.points.length/7;for(let i=0;i<e;i++){let r=7*i,s=t.points[r+0],n=t.points[r+1],a=t.points[r+2],o=t.points[r+3],l=t.points[r+4],u=t.points[r+5],h=t.points[r+6],d=new jg(qt.generateUUID(),new Z(s,n));d.controls[0].position.set(a,o),d.controls[1].position.set(l,u),d.roundness=h,this.points.push(d)}return this.shapeHoles=t.shapeHoles?.length?t.shapeHoles.map(i=>{let r=new ds;return r.fromJSON(i),r}):[],this.isClosed=t.isClosed,this._roundness=t.roundness,this._update(),this}fromShape(t,e=!1){this.isText=e;let i=(r,s)=>{s instanceof Kl&&s.v3.equals(r.position)&&r.controls[0].position.copy(s.v2)};return this.points=(r=>{let s,n,a=[];for(s=0,n=r.length;s<n;s++)r[s]instanceof oc&&(r[s]=a3t(r[s]));for(s=0,n=r.length;s<n;s++){let u,h=r[s],d=s>0?r[s-1]:null;h instanceof Kl?(u=this.createPoint(h.v0),u.controls[1].position.copy(h.v1)):h instanceof cl&&(u=this.createPoint(h.v1)),u!==void 0&&(d!==null&&i(u,d),a.push(u))}let o=r[r.length-1],l=!1;return o instanceof Kl?o.v3.equals(a[0].position)&&(a[0].controls[0].position.copy(o.v2),l=!0):o instanceof cl&&o.v2.equals(a[0].position)&&(l=!0),this.isClosed=l,a})(t.curves),t instanceof bS&&(this.shapeHoles=t.holes.map(r=>{let s=new ds;return s.fromShape(r),s})),this.update(),this}updatePoint(t,e){let i=this.getPointByUuid(t);i&&(e.position!==void 0&&i.position.fromArray(e.position),e.roundness!==void 0&&(i.roundness=e.roundness),e.areControlsDirectionsMirrored!==void 0&&(i.areControlsDirectionsMirrored=e.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(t,e){let i=this.getPointByUuid(t)?.controls[0];i&&(e.position&&i.position.fromArray(e.position),this.needsUpdate=!0)}updateNextControl(t,e){let i=this.getPointByUuid(t)?.controls[1];i&&(e.position&&i.position.fromArray(e.position),this.needsUpdate=!0)}}});function EO({x:t,y:e},i,r,s,n){return{x:t*i+s,y:e*r+n}}function p3t(t,e){let i=e===1.5707963267948966?.551915024494:e===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(e/4),r=Math.cos(t),s=Math.sin(t),n=Math.cos(t+e),a=Math.sin(t+e);return[{x:r-s*i,y:s+r*i},{x:n+a*i,y:a-n*i},{x:n,y:a}]}function ZY(t,e,i,r){let s=t*r-e*i<0?-1:1,n=Math.min(1,Math.max(-1,t*i+e*r));return s*Math.acos(n)}var VP,m3t=G(()=>{VP=2*Math.PI});function Xe(t,e){if(!t)throw e||"Assertion Failed!"}function X2(t){var e=t.windingRule,i=e===void 0?ss.ODD:e,r=t.elementType,s=r===void 0?Ea.POLYGONS:r,n=t.polySize,a=n===void 0?3:n,o=t.vertexSize,l=o===void 0?2:o,u=t.normal,h=u===void 0?[0,0,1]:u,d=t.contours,c=d===void 0?[]:d,p=t.strict,m=p===void 0||p,f=t.debug,g=f!==void 0&&f;if(!c&&m)throw new Error("Contours can't be empty");if(c){var y=new Fft;t.edgeCreateCallback&&(y.edgeCreateCallback=t.edgeCreateCallback),t.vertexIdCallback&&(y.vertexIdCallback=t.vertexIdCallback);for(var v=0;v<c.length;v++)y.addContour(l||2,c[v]);return y.tesselate(i,s,a,l,h,m),{vertices:y.vertices,vertexIndices:y.vertexIndices,vertexCount:y.vertexCount,elements:y.elements,elementCount:y.elementCount,mesh:g?y.mesh:void 0}}}var ss,Ea,je,z0,o_,ef,PO,RO,DO,QY,IM,NO,JY,tK,Fft,tT=G(()=>{var t;(t=ss||(ss={}))[t.ODD=0]="ODD",t[t.NONZERO=1]="NONZERO",t[t.POSITIVE=2]="POSITIVE",t[t.NEGATIVE=3]="NEGATIVE",t[t.ABS_GEQ_TWO=4]="ABS_GEQ_TWO",function(e){e[e.POLYGONS=0]="POLYGONS",e[e.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",e[e.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"}(Ea||(Ea={})),je=function(){function e(){}return e.vertEq=function(i,r){return i.s===r.s&&i.t===r.t},e.vertLeq=function(i,r){return i.s<r.s||i.s===r.s&&i.t<=r.t},e.transLeq=function(i,r){return i.t<r.t||i.t===r.t&&i.s<=r.s},e.edgeGoesLeft=function(i){return e.vertLeq(i.Dst,i.Org)},e.edgeGoesRight=function(i){return e.vertLeq(i.Org,i.Dst)},e.vertL1dist=function(i,r){return Math.abs(i.s-r.s)+Math.abs(i.t-r.t)},e.edgeEval=function(i,r,s){Xe(e.vertLeq(i,r)&&e.vertLeq(r,s));var n=r.s-i.s,a=s.s-r.s;return n+a>0?n<a?r.t-i.t+(i.t-s.t)*(n/(n+a)):r.t-s.t+(s.t-i.t)*(a/(n+a)):0},e.edgeSign=function(i,r,s){Xe(e.vertLeq(i,r)&&e.vertLeq(r,s));var n=r.s-i.s,a=s.s-r.s;return n+a>0?(r.t-s.t)*n+(r.t-i.t)*a:0},e.transEval=function(i,r,s){Xe(e.transLeq(i,r)&&e.transLeq(r,s));var n=r.t-i.t,a=s.t-r.t;return n+a>0?n<a?r.s-i.s+(i.s-s.s)*(n/(n+a)):r.s-s.s+(s.s-i.s)*(a/(n+a)):0},e.transSign=function(i,r,s){Xe(e.transLeq(i,r)&&e.transLeq(r,s));var n=r.t-i.t,a=s.t-r.t;return n+a>0?(r.s-s.s)*n+(r.s-i.s)*a:0},e.vertCCW=function(i,r,s){return i.s*(r.t-s.t)+r.s*(s.t-i.t)+s.s*(i.t-r.t)>=0},e.interpolate=function(i,r,s,n){return(i=i<0?0:i)<=(s=s<0?0:s)?s===0?(r+n)/2:r+i/(i+s)*(n-r):n+s/(i+s)*(r-n)},e.intersect=function(i,r,s,n,a){var o,l,u;e.vertLeq(i,r)||(u=i,i=r,r=u),e.vertLeq(s,n)||(u=s,s=n,n=u),e.vertLeq(i,s)||(u=i,i=s,s=u,u=r,r=n,n=u),e.vertLeq(s,r)?e.vertLeq(r,n)?((o=e.edgeEval(i,s,r))+(l=e.edgeEval(s,r,n))<0&&(o=-o,l=-l),a.s=e.interpolate(o,s.s,l,r.s)):((o=e.edgeSign(i,s,r))+(l=-e.edgeSign(i,n,r))<0&&(o=-o,l=-l),a.s=e.interpolate(o,s.s,l,n.s)):a.s=(s.s+r.s)/2,e.transLeq(i,r)||(u=i,i=r,r=u),e.transLeq(s,n)||(u=s,s=n,n=u),e.transLeq(i,s)||(u=i,i=s,s=u,u=r,r=n,n=u),e.transLeq(s,r)?e.transLeq(r,n)?((o=e.transEval(i,s,r))+(l=e.transEval(s,r,n))<0&&(o=-o,l=-l),a.t=e.interpolate(o,s.t,l,r.t)):((o=e.transSign(i,s,r))+(l=-e.transSign(i,n,r))<0&&(o=-o,l=-l),a.t=e.interpolate(o,s.t,l,n.t)):a.t=(s.t+r.t)/2},e}(),z0=function(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1},o_=function(){function e(i){this.side=i,this.next=null,this.Org=null,this.Sym=null,this.Onext=null,this.Lnext=null,this.Lface=null,this.activeRegion=null,this.winding=0}return Object.defineProperty(e.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(i){this.Sym.Lface=i},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(i){this.Sym.Org=i},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(i){this.Sym.Lnext=i},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(i){this.Onext.Sym=i},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(i){this.Lnext.Sym=i},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(i){this.Sym.Onext=i},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(i){this.Sym.Onext.Sym=i},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(i){this.Sym.Lnext.Sym=i},enumerable:!0,configurable:!0}),e}(),ef=function(){this.next=null,this.prev=null,this.anEdge=null,this.coords=[0,0,0],this.s=0,this.t=0,this.pqHandle=0,this.n=0,this.idx=0},PO=function(){function e(){var i=new ef,r=new z0,s=new o_(0),n=new o_(1);i.next=i.prev=i,i.anEdge=null,r.next=r.prev=r,s.next=s,s.Sym=n,n.next=n,n.Sym=s,this.vHead=i,this.fHead=r,this.eHead=s,this.eHeadSym=n}return e.prototype.makeEdge_=function(i){var r=new o_(0),s=new o_(1);i.Sym.side<i.side&&(i=i.Sym);var n=i.Sym.next;return s.next=n,n.Sym.next=r,r.next=i,i.Sym.next=s,r.Sym=s,r.Onext=r,r.Lnext=s,r.Org=null,r.Lface=null,r.winding=0,r.activeRegion=null,s.Sym=r,s.Onext=s,s.Lnext=r,s.Org=null,s.Lface=null,s.winding=0,s.activeRegion=null,r},e.prototype.splice_=function(i,r){var s=i.Onext,n=r.Onext;s.Sym.Lnext=r,n.Sym.Lnext=i,i.Onext=n,r.Onext=s},e.prototype.makeVertex_=function(i,r,s){var n=i;Xe(n,"Vertex can't be null!");var a=s.prev;n.prev=a,a.next=n,n.next=s,s.prev=n,n.anEdge=r;var o=r;do o.Org=n,o=o.Onext;while(o!==r)},e.prototype.makeFace_=function(i,r,s){var n=i;Xe(n,"Face can't be null");var a=s.prev;n.prev=a,a.next=n,n.next=s,s.prev=n,n.anEdge=r,n.trail=null,n.marked=!1,n.inside=s.inside;var o=r;do o.Lface=n,o=o.Lnext;while(o!==r)},e.prototype.killEdge_=function(i){i.Sym.side<i.side&&(i=i.Sym);var r=i.next,s=i.Sym.next;r.Sym.next=s,s.Sym.next=r},e.prototype.killVertex_=function(i,r){var s=i.anEdge,n=s;do n.Org=r,n=n.Onext;while(n!==s);var a=i.prev,o=i.next;o.prev=a,a.next=o},e.prototype.killFace_=function(i,r){var s=i.anEdge,n=s;do n.Lface=r,n=n.Lnext;while(n!==s);var a=i.prev,o=i.next;o.prev=a,a.next=o},e.prototype.makeEdge=function(){var i=new ef,r=new ef,s=new z0,n=this.makeEdge_(this.eHead);return this.makeVertex_(i,n,this.vHead),this.makeVertex_(r,n.Sym,this.vHead),this.makeFace_(s,n,this.fHead),n},e.prototype.splice=function(i,r){var s=!1,n=!1;if(i!==r){if(r.Org!==i.Org&&(n=!0,this.killVertex_(r.Org,i.Org)),r.Lface!==i.Lface&&(s=!0,this.killFace_(r.Lface,i.Lface)),this.splice_(r,i),!n){var a=new ef;this.makeVertex_(a,r,i.Org),i.Org.anEdge=i}if(!s){var o=new z0;this.makeFace_(o,r,i.Lface),i.Lface.anEdge=i}}},e.prototype.delete=function(i){var r=i.Sym,s=!1;if(i.Lface!==i.Rface&&(s=!0,this.killFace_(i.Lface,i.Rface)),i.Onext===i)this.killVertex_(i.Org,null);else if(i.Rface.anEdge=i.Oprev,i.Org.anEdge=i.Onext,this.splice_(i,i.Oprev),!s){var n=new z0;this.makeFace_(n,i,i.Lface)}r.Onext===r?(this.killVertex_(r.Org,null),this.killFace_(r.Lface,null)):(i.Lface.anEdge=r.Oprev,r.Org.anEdge=r.Onext,this.splice_(r,r.Oprev)),this.killEdge_(i)},e.prototype.addEdgeVertex=function(i){var r=this.makeEdge_(i),s=r.Sym;this.splice_(r,i.Lnext),r.Org=i.Dst;var n=new ef;return this.makeVertex_(n,s,r.Org),r.Lface=s.Lface=i.Lface,r},e.prototype.splitEdge=function(i){var r=this.addEdgeVertex(i).Sym;return this.splice_(i.Sym,i.Sym.Oprev),this.splice_(i.Sym,r),i.Dst=r.Org,r.Dst.anEdge=r.Sym,r.Rface=i.Rface,r.winding=i.winding,r.Sym.winding=i.Sym.winding,r.idx=i.idx,r.Sym.idx=i.Sym.idx,r},e.prototype.connect=function(i,r){var s=!1,n=this.makeEdge_(i),a=n.Sym;if(r.Lface!==i.Lface&&(s=!0,this.killFace_(r.Lface,i.Lface)),this.splice_(n,i.Lnext),this.splice_(a,r),n.Org=i.Dst,a.Org=r.Org,n.Lface=a.Lface=i.Lface,i.Lface.anEdge=a,!s){var o=new z0;this.makeFace_(o,n,i.Lface)}return n},e.prototype.zapFace=function(i){var r,s,n,a,o,l=i.anEdge;s=l.Lnext;do s=(r=s).Lnext,r.Lface=null,r.Rface===null&&(r.Onext===r?this.killVertex_(r.Org,null):(r.Org.anEdge=r.Onext,this.splice_(r,r.Oprev)),(n=r.Sym).Onext===n?this.killVertex_(n.Org,null):(n.Org.anEdge=n.Onext,this.splice_(n,n.Oprev)),this.killEdge_(r));while(r!=l);a=i.prev,(o=i.next).prev=a,a.next=o},e.prototype.countFaceVerts_=function(i){var r=i.anEdge,s=0;do s++,r=r.Lnext;while(r!==i.anEdge);return s},e.prototype.mergeConvexFaces=function(i){var r,s,n,a,o;for(r=this.fHead.next;r!==this.fHead;r=r.next)if(r.inside)for(o=(s=r.anEdge).Org;n=s.Lnext,(a=s.Sym)&&a.Lface&&a.Lface.inside&&this.countFaceVerts_(r)+this.countFaceVerts_(a.Lface)-2<=i&&je.vertCCW(s.Lprev.Org,s.Org,a.Lnext.Lnext.Org)&&je.vertCCW(a.Lprev.Org,a.Org,s.Lnext.Lnext.Org)&&(n=a.Lnext,this.delete(a),s=null,a=null),!s||s.Lnext.Org!==o;)s=n;return!0},e.prototype.check=function(){var i,r,s,n,a,o,l=this.fHead,u=this.vHead,h=this.eHead;for(r=l,r=l;(i=r.next)!==l;r=i){Xe(i.prev===r),a=i.anEdge;do Xe(a.Sym!==a),Xe(a.Sym.Sym===a),Xe(a.Lnext.Onext.Sym===a),Xe(a.Onext.Sym.Lnext===a),Xe(a.Lface===i),a=a.Lnext;while(a!==i.anEdge)}for(Xe(i.prev===r&&i.anEdge===null),n=u,n=u;(s=n.next)!==u;n=s){Xe(s.prev===n),a=s.anEdge;do Xe(a.Sym!==a),Xe(a.Sym.Sym===a),Xe(a.Lnext.Onext.Sym===a),Xe(a.Onext.Sym.Lnext===a),Xe(a.Org===s),a=a.Onext;while(a!==s.anEdge)}for(Xe(s.prev===n&&s.anEdge===null),o=h,o=h;(a=o.next)!==h;o=a)Xe(a.Sym.next===o.Sym),Xe(a.Sym!==a),Xe(a.Sym.Sym===a),Xe(a.Org!==null),Xe(a.Dst!==null),Xe(a.Lnext.Onext.Sym===a),Xe(a.Onext.Sym.Lnext===a);Xe(a.Sym.next===o.Sym&&a.Sym===this.eHeadSym&&a.Sym.Sym===a&&a.Org===null&&a.Dst===null&&a.Lface===null&&a.Rface===null)},e}(),RO=function(){this.handle=null},DO=function(){this.key=null,this.node=0},QY=function(){function e(i,r){this.leq=r,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=i,this.nodes=[],this.handles=[];for(var s=0;s<i+1;s++)this.nodes[s]=new RO,this.handles[s]=new DO;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return e.prototype.floatDown_=function(i){var r,s,n,a=this.nodes,o=this.handles;for(r=a[i].handle;;){if((n=i<<1)<this.size&&this.leq(o[a[n+1].handle].key,o[a[n].handle].key)&&++n,Xe(n<=this.max),s=a[n].handle,n>this.size||this.leq(o[r].key,o[s].key)){a[i].handle=r,o[r].node=i;break}a[i].handle=s,o[s].node=i,i=n}},e.prototype.floatUp_=function(i){var r,s,n,a=this.nodes,o=this.handles;for(r=a[i].handle;;){if(s=a[n=i>>1].handle,n===0||this.leq(o[s].key,o[r].key)){a[i].handle=r,o[r].node=i;break}a[i].handle=s,o[s].node=i,i=n}},e.prototype.init=function(){for(var i=this.size;i>=1;--i)this.floatDown_(i);this.initialized=!0},e.prototype.min=function(){return this.handles[this.nodes[1].handle].key},e.prototype.insert=function(i){var r,s;if(2*(r=++this.size)>this.max){var n,a;for(this.max*=2,a=this.nodes.length,this.nodes.length=this.max+1,n=a;n<this.nodes.length;n++)this.nodes[n]=new RO;for(a=this.handles.length,this.handles.length=this.max+1,n=a;n<this.handles.length;n++)this.handles[n]=new DO}return this.freeList===0?s=r:(s=this.freeList,this.freeList=this.handles[s].node),this.nodes[r].handle=s,this.handles[s].node=r,this.handles[s].key=i,this.initialized&&this.floatUp_(r),s},e.prototype.extractMin=function(){var i=this.nodes,r=this.handles,s=i[1].handle,n=r[s].key;return this.size>0&&(i[1].handle=i[this.size].handle,r[i[1].handle].node=1,r[s].key=null,r[s].node=this.freeList,this.freeList=s,--this.size,this.size>0&&this.floatDown_(1)),n},e.prototype.delete=function(i){var r,s=this.nodes,n=this.handles;Xe(i>=1&&i<=this.max&&n[i].key!==null),s[r=n[i].node].handle=s[this.size].handle,n[s[r].handle].node=r,--this.size,r<=this.size&&(r<=1||this.leq(n[s[r>>1].handle].key,n[s[r].handle].key)?this.floatDown_(r):this.floatUp_(r)),n[i].key=null,n[i].node=this.freeList,this.freeList=i},e}(),IM=function(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1},NO=function(){this.key=null,this.next=null,this.prev=null},JY=function(){function e(i,r){this.frame=i,this.leq=r,this.head=new NO,this.head.next=this.head,this.head.prev=this.head}return e.prototype.min=function(){return this.head.next},e.prototype.max=function(){return this.head.prev},e.prototype.insert=function(i){return this.insertBefore(this.head,i)},e.prototype.search=function(i){var r=this.head;do r=r.next;while(r.key!==null&&!this.leq(this.frame,i,r.key));return r},e.prototype.insertBefore=function(i,r){do i=i.prev;while(i.key!==null&&!this.leq(this.frame,i.key,r));var s=new NO;return s.key=r,s.next=i.next,i.next.prev=s,s.prev=i,i.next=s,s},e.prototype.delete=function(i){i.next.prev=i.prev,i.prev.next=i.next},e}(),tK=function(){function e(){}return e.regionBelow=function(i){return i.nodeUp.prev.key},e.regionAbove=function(i){return i.nodeUp.next.key},e.debugEvent=function(i){},e.addWinding=function(i,r){i.winding+=r.winding,i.Sym.winding+=r.Sym.winding},e.edgeLeq=function(i,r,s){var n=i.event,a=r.eUp,o=s.eUp;return a.Dst===n?o.Dst===n?je.vertLeq(a.Org,o.Org)?je.edgeSign(o.Dst,a.Org,o.Org)<=0:je.edgeSign(a.Dst,o.Org,a.Org)>=0:je.edgeSign(o.Dst,n,o.Org)<=0:o.Dst===n?je.edgeSign(a.Dst,n,a.Org)>=0:je.edgeEval(a.Dst,n,a.Org)>=je.edgeEval(o.Dst,n,o.Org)},e.deleteRegion=function(i,r){r.fixUpperEdge&&Xe(r.eUp.winding===0),r.eUp.activeRegion=null,i.dict.delete(r.nodeUp)},e.fixUpperEdge=function(i,r,s){Xe(r.fixUpperEdge),i.mesh.delete(r.eUp),r.fixUpperEdge=!1,r.eUp=s,s.activeRegion=r},e.topLeftRegion=function(i,r){var s,n=r.eUp.Org;do r=e.regionAbove(r);while(r.eUp.Org===n);if(r.fixUpperEdge){if((s=i.mesh.connect(e.regionBelow(r).eUp.Sym,r.eUp.Lnext))===null)return null;e.fixUpperEdge(i,r,s),r=e.regionAbove(r)}return r},e.topRightRegion=function(i){var r=i.eUp.Dst;do i=e.regionAbove(i);while(i.eUp.Dst===r);return i},e.addRegionBelow=function(i,r,s){var n=new IM;return n.eUp=s,n.nodeUp=i.dict.insertBefore(r.nodeUp,n),n.fixUpperEdge=!1,n.sentinel=!1,n.dirty=!1,s.activeRegion=n,n},e.isWindingInside=function(i,r){switch(i.windingRule){case ss.ODD:return!!(1&r);case ss.NONZERO:return r!==0;case ss.POSITIVE:return r>0;case ss.NEGATIVE:return r<0;case ss.ABS_GEQ_TWO:return r>=2||r<=-2}throw new Error("Invalid winding rulle")},e.computeWinding=function(i,r){r.windingNumber=e.regionAbove(r).windingNumber+r.eUp.winding,r.inside=e.isWindingInside(i,r.windingNumber)},e.finishRegion=function(i,r){var s=r.eUp,n=s.Lface;n.inside=r.inside,n.anEdge=s,e.deleteRegion(i,r)},e.finishLeftRegions=function(i,r,s){for(var n,a=null,o=r,l=r.eUp;o!==s;){if(o.fixUpperEdge=!1,(n=(a=e.regionBelow(o)).eUp).Org!=l.Org){if(!a.fixUpperEdge){e.finishRegion(i,o);break}n=i.mesh.connect(l.Lprev,n.Sym),e.fixUpperEdge(i,a,n)}l.Onext!==n&&(i.mesh.splice(n.Oprev,n),i.mesh.splice(l,n)),e.finishRegion(i,o),l=a.eUp,o=a}return l},e.addRightEdges=function(i,r,s,n,a,o){var l,u,h,d,c=!0;h=s;do Xe(je.vertLeq(h.Org,h.Dst)),e.addRegionBelow(i,r,h.Sym),h=h.Onext;while(h!==n);for(a===null&&(a=e.regionBelow(r).eUp.Rprev),u=r,d=a;(h=(l=e.regionBelow(u)).eUp.Sym).Org===d.Org;)h.Onext!==d&&(i.mesh.splice(h.Oprev,h),i.mesh.splice(d.Oprev,h)),l.windingNumber=u.windingNumber-h.winding,l.inside=e.isWindingInside(i,l.windingNumber),u.dirty=!0,!c&&e.checkForRightSplice(i,u)&&(e.addWinding(h,d),e.deleteRegion(i,u),i.mesh.delete(d)),c=!1,u=l,d=h;u.dirty=!0,Xe(u.windingNumber-h.winding===l.windingNumber),o&&e.walkDirtyRegions(i,u)},e.spliceMergeVertices=function(i,r,s){i.mesh.splice(r,s)},e.vertexWeights=function(i,r,s){var n=je.vertL1dist(r,i),a=je.vertL1dist(s,i),o=.5*a/(n+a),l=.5*n/(n+a);i.coords[0]+=o*r.coords[0]+l*s.coords[0],i.coords[1]+=o*r.coords[1]+l*s.coords[1],i.coords[2]+=o*r.coords[2]+l*s.coords[2]},e.getIntersectData=function(i,r,s,n,a,o){r.coords[0]=r.coords[1]=r.coords[2]=0,r.idx=-1,e.vertexWeights(r,s,n),e.vertexWeights(r,a,o)},e.checkForRightSplice=function(i,r){var s=e.regionBelow(r),n=r.eUp,a=s.eUp;if(je.vertLeq(n.Org,a.Org)){if(je.edgeSign(a.Dst,n.Org,a.Org)>0)return!1;je.vertEq(n.Org,a.Org)?n.Org!==a.Org&&(i.pq.delete(n.Org.pqHandle),e.spliceMergeVertices(i,a.Oprev,n)):(i.mesh.splitEdge(a.Sym),i.mesh.splice(n,a.Oprev),r.dirty=s.dirty=!0)}else{if(je.edgeSign(n.Dst,a.Org,n.Org)<0)return!1;e.regionAbove(r).dirty=r.dirty=!0,i.mesh.splitEdge(n.Sym),i.mesh.splice(a.Oprev,n)}return!0},e.checkForLeftSplice=function(i,r){var s,n=e.regionBelow(r),a=r.eUp,o=n.eUp;if(Xe(!je.vertEq(a.Dst,o.Dst)),je.vertLeq(a.Dst,o.Dst)){if(je.edgeSign(a.Dst,o.Dst,a.Org)<0)return!1;e.regionAbove(r).dirty=r.dirty=!0,s=i.mesh.splitEdge(a),i.mesh.splice(o.Sym,s),s.Lface.inside=r.inside}else{if(je.edgeSign(o.Dst,a.Dst,o.Org)>0)return!1;r.dirty=n.dirty=!0,s=i.mesh.splitEdge(o),i.mesh.splice(a.Lnext,o.Sym),s.Rface.inside=r.inside}return!0},e.checkForIntersect=function(i,r){var s,n,a=e.regionBelow(r),o=r.eUp,l=a.eUp,u=o.Org,h=l.Org,d=o.Dst,c=l.Dst,p=new ef;if(Xe(!je.vertEq(c,d)),Xe(je.edgeSign(d,i.event,u)<=0),Xe(je.edgeSign(c,i.event,h)>=0),Xe(u!==i.event&&h!==i.event),Xe(!r.fixUpperEdge&&!a.fixUpperEdge),u===h||Math.min(u.t,d.t)>Math.max(h.t,c.t))return!1;if(je.vertLeq(u,h)){if(je.edgeSign(c,u,h)>0)return!1}else if(je.edgeSign(d,h,u)<0)return!1;return e.debugEvent(i),je.intersect(d,u,c,h,p),Xe(Math.min(u.t,d.t)<=p.t),Xe(p.t<=Math.max(h.t,c.t)),Xe(Math.min(c.s,d.s)<=p.s),Xe(p.s<=Math.max(h.s,u.s)),je.vertLeq(p,i.event)&&(p.s=i.event.s,p.t=i.event.t),s=je.vertLeq(u,h)?u:h,je.vertLeq(s,p)&&(p.s=s.s,p.t=s.t),je.vertEq(p,u)||je.vertEq(p,h)?(e.checkForRightSplice(i,r),!1):!je.vertEq(d,i.event)&&je.edgeSign(d,i.event,p)>=0||!je.vertEq(c,i.event)&&je.edgeSign(c,i.event,p)<=0?c===i.event?(i.mesh.splitEdge(o.Sym),i.mesh.splice(l.Sym,o),r=e.topLeftRegion(i,r),o=e.regionBelow(r).eUp,e.finishLeftRegions(i,e.regionBelow(r),a),e.addRightEdges(i,r,o.Oprev,o,o,!0),!0):d===i.event?(i.mesh.splitEdge(l.Sym),i.mesh.splice(o.Lnext,l.Oprev),a=r,r=e.topRightRegion(r),n=e.regionBelow(r).eUp.Rprev,a.eUp=l.Oprev,l=e.finishLeftRegions(i,a,null),e.addRightEdges(i,r,l.Onext,o.Rprev,n,!0),!0):(je.edgeSign(d,i.event,p)>=0&&(e.regionAbove(r).dirty=r.dirty=!0,i.mesh.splitEdge(o.Sym),o.Org.s=i.event.s,o.Org.t=i.event.t),je.edgeSign(c,i.event,p)<=0&&(r.dirty=a.dirty=!0,i.mesh.splitEdge(l.Sym),l.Org.s=i.event.s,l.Org.t=i.event.t),!1):(i.mesh.splitEdge(o.Sym),i.mesh.splitEdge(l.Sym),i.mesh.splice(l.Oprev,o),o.Org.s=p.s,o.Org.t=p.t,o.Org.pqHandle=i.pq.insert(o.Org),e.getIntersectData(i,o.Org,u,d,h,c),e.regionAbove(r).dirty=r.dirty=a.dirty=!0,!1)},e.walkDirtyRegions=function(i,r){for(var s,n,a=e.regionBelow(r);;){for(;a.dirty;)r=a,a=e.regionBelow(a);if(!r.dirty&&(a=r,(r=e.regionAbove(r))===null||!r.dirty))return;if(r.dirty=!1,s=r.eUp,n=a.eUp,s.Dst!==n.Dst&&e.checkForLeftSplice(i,r)&&(a.fixUpperEdge?(e.deleteRegion(i,a),i.mesh.delete(n),n=(a=e.regionBelow(r)).eUp):r.fixUpperEdge&&(e.deleteRegion(i,r),i.mesh.delete(s),s=(r=e.regionAbove(a)).eUp)),s.Org!==n.Org){if(s.Dst===n.Dst||r.fixUpperEdge||a.fixUpperEdge||s.Dst!==i.event&&n.Dst!==i.event)e.checkForRightSplice(i,r);else if(e.checkForIntersect(i,r))return}s.Org===n.Org&&s.Dst===n.Dst&&(e.addWinding(n,s),e.deleteRegion(i,r),i.mesh.delete(s),r=e.regionAbove(a))}},e.connectRightVertex=function(i,r,s){var n,a=s.Onext,o=e.regionBelow(r),l=r.eUp,u=o.eUp,h=!1;l.Dst!==u.Dst&&e.checkForIntersect(i,r),je.vertEq(l.Org,i.event)&&(i.mesh.splice(a.Oprev,l),r=e.topLeftRegion(i,r),a=e.regionBelow(r).eUp,e.finishLeftRegions(i,e.regionBelow(r),o),h=!0),je.vertEq(u.Org,i.event)&&(i.mesh.splice(s,u.Oprev),s=e.finishLeftRegions(i,o,null),h=!0),h?e.addRightEdges(i,r,s.Onext,a,a,!0):(n=je.vertLeq(u.Org,l.Org)?u.Oprev:l,n=i.mesh.connect(s.Lprev,n),e.addRightEdges(i,r,n,n.Onext,n.Onext,!1),n.Sym.activeRegion.fixUpperEdge=!0,e.walkDirtyRegions(i,r))},e.connectLeftDegenerate=function(i,r,s){var n,a,o,l,u;return n=r.eUp,je.vertEq(n.Org,s)?(Xe(!1),void e.spliceMergeVertices(i,n,s.anEdge)):je.vertEq(n.Dst,s)?(Xe(!1),r=e.topRightRegion(r),a=l=(o=(u=e.regionBelow(r)).eUp.Sym).Onext,u.fixUpperEdge&&(Xe(a!==o),e.deleteRegion(i,u),i.mesh.delete(o),o=a.Oprev),i.mesh.splice(s.anEdge,o),je.edgeGoesLeft(a)||(a=null),void e.addRightEdges(i,r,o.Onext,l,a,!0)):(i.mesh.splitEdge(n.Sym),r.fixUpperEdge&&(i.mesh.delete(n.Onext),r.fixUpperEdge=!1),i.mesh.splice(s.anEdge,n),void e.sweepEvent(i,s))},e.connectLeftVertex=function(i,r){var s,n,a,o,l,u,h=new IM;if(h.eUp=r.anEdge.Sym,s=i.dict.search(h).key,n=e.regionBelow(s)){if(o=s.eUp,l=n.eUp,je.edgeSign(o.Dst,r,o.Org)===0)return void e.connectLeftDegenerate(i,s,r);a=je.vertLeq(l.Dst,o.Dst)?s:n,s.inside||a.fixUpperEdge?(u=a===s?i.mesh.connect(r.anEdge.Sym,o.Lnext):i.mesh.connect(l.Dnext,r.anEdge).Sym,a.fixUpperEdge?e.fixUpperEdge(i,a,u):e.computeWinding(i,e.addRegionBelow(i,s,u)),e.sweepEvent(i,r)):e.addRightEdges(i,s,r.anEdge,r.anEdge,null,!0)}},e.sweepEvent=function(i,r){i.event=r,e.debugEvent(i);for(var s=r.anEdge;s.activeRegion===null;)if((s=s.Onext)===r.anEdge)return void e.connectLeftVertex(i,r);var n=e.topLeftRegion(i,s.activeRegion);Xe(n!==null);var a=e.regionBelow(n),o=a.eUp,l=e.finishLeftRegions(i,a,null);l.Onext===o?e.connectRightVertex(i,n,l):e.addRightEdges(i,n,l.Onext,o,o,!0)},e.addSentinel=function(i,r,s,n){var a=new IM,o=i.mesh.makeEdge();o.Org.s=s,o.Org.t=n,o.Dst.s=r,o.Dst.t=n,i.event=o.Dst,a.eUp=o,a.windingNumber=0,a.inside=!1,a.fixUpperEdge=!1,a.sentinel=!0,a.dirty=!1,a.nodeUp=i.dict.insert(a)},e.initEdgeDict=function(i){i.dict=new JY(i,e.edgeLeq);var r=i.bmax[0]-i.bmin[0],s=i.bmax[1]-i.bmin[1],n=i.bmin[0]-r,a=i.bmax[0]+r,o=i.bmin[1]-s,l=i.bmax[1]+s;e.addSentinel(i,n,a,o),e.addSentinel(i,n,a,l)},e.doneEdgeDict=function(i){for(var r,s=0;(r=i.dict.min().key)!==null;)r.sentinel||(Xe(r.fixUpperEdge),Xe(++s===1)),Xe(r.windingNumber===0),e.deleteRegion(i,r)},e.removeDegenerateEdges=function(i){var r,s,n,a=i.mesh.eHead;for(r=a.next;r!==a;r=s)s=r.next,n=r.Lnext,je.vertEq(r.Org,r.Dst)&&r.Lnext.Lnext!==r&&(e.spliceMergeVertices(i,n,r),i.mesh.delete(r),n=(r=n).Lnext),n.Lnext===r&&(n!==r&&((n===s||n===s.Sym)&&(s=s.next),i.mesh.delete(n)),(r===s||r===s.Sym)&&(s=s.next),i.mesh.delete(r))},e.initPriorityQ=function(i){var r,s,n,a=0;for(s=(n=i.mesh.vHead).next;s!==n;s=s.next)a++;for(a+=8,r=i.pq=new QY(a,je.vertLeq),s=(n=i.mesh.vHead).next;s!==n;s=s.next)s.pqHandle=r.insert(s);return s===n&&(r.init(),!0)},e.donePriorityQ=function(i){i.pq=null},e.removeDegenerateFaces=function(i,r){var s,n,a;for(s=r.fHead.next;s!==r.fHead;s=n)n=s.next,Xe((a=s.anEdge).Lnext!==a),a.Lnext.Lnext===a&&(e.addWinding(a.Onext,a),i.mesh.delete(a));return!0},e.computeInterior=function(i,r){var s,n;if(r===void 0&&(r=!0),e.removeDegenerateEdges(i),!e.initPriorityQ(i))return!1;for(e.initEdgeDict(i);(s=i.pq.extractMin())!==null;){for(;(n=i.pq.min())!==null&&je.vertEq(n,s);)n=i.pq.extractMin(),e.spliceMergeVertices(i,s.anEdge,n.anEdge);e.sweepEvent(i,s)}return i.event=i.dict.min().key.eUp.Org,e.debugEvent(i),e.doneEdgeDict(i),e.donePriorityQ(i),!!e.removeDegenerateFaces(i,i.mesh)&&(r&&i.mesh.check(),!0)},e}(),Fft=function(){function e(){this.mesh=new PO,this.normal=[0,0,0],this.sUnit=[0,0,0],this.tUnit=[0,0,0],this.bmin=[0,0],this.bmax=[0,0],this.windingRule=ss.ODD,this.dict=null,this.pq=null,this.event=null,this.vertexIndexCounter=0,this.vertices=[],this.vertexIndices=[],this.vertexCount=0,this.elements=[],this.elementCount=0}return e.prototype.dot_=function(i,r){return i[0]*r[0]+i[1]*r[1]+i[2]*r[2]},e.prototype.normalize_=function(i){var r=i[0]*i[0]+i[1]*i[1]+i[2]*i[2];if(!r)throw"Zero-size vector!";r=Math.sqrt(r),i[0]/=r,i[1]/=r,i[2]/=r},e.prototype.longAxis_=function(i){var r=0;return Math.abs(i[1])>Math.abs(i[0])&&(r=1),Math.abs(i[2])>Math.abs(i[r])&&(r=2),r},e.prototype.computeNormal_=function(i){var r,s,n,a,o,l,u=[0,0,0],h=[0,0,0],d=[0,0,0],c=[0,0,0],p=[0,0,0],m=[null,null,null],f=[null,null,null],g=this.mesh.vHead;r=g.next;for(var y=0;y<3;++y)a=r.coords[y],h[y]=a,f[y]=r,u[y]=a,m[y]=r;for(r=g.next;r!==g;r=r.next)for(var v=0;v<3;++v)(a=r.coords[v])<h[v]&&(h[v]=a,f[v]=r),a>u[v]&&(u[v]=a,m[v]=r);var b=0;if(u[1]-h[1]>u[0]-h[0]&&(b=1),u[2]-h[2]>u[b]-h[b]&&(b=2),h[b]>=u[b])return i[0]=0,i[1]=0,void(i[2]=1);for(l=0,s=f[b],n=m[b],d[0]=s.coords[0]-n.coords[0],d[1]=s.coords[1]-n.coords[1],d[2]=s.coords[2]-n.coords[2],r=g.next;r!==g;r=r.next)c[0]=r.coords[0]-n.coords[0],c[1]=r.coords[1]-n.coords[1],c[2]=r.coords[2]-n.coords[2],p[0]=d[1]*c[2]-d[2]*c[1],p[1]=d[2]*c[0]-d[0]*c[2],p[2]=d[0]*c[1]-d[1]*c[0],(o=p[0]*p[0]+p[1]*p[1]+p[2]*p[2])>l&&(l=o,i[0]=p[0],i[1]=p[1],i[2]=p[2]);l<=0&&(i[0]=i[1]=i[2]=0,i[this.longAxis_(d)]=1)},e.prototype.checkOrientation_=function(){for(var i,r,s=this.mesh.fHead,n=this.mesh.vHead,a=0,o=s.next;o!==s;o=o.next)if(!((r=o.anEdge).winding<=0))do a+=(r.Org.s-r.Dst.s)*(r.Org.t+r.Dst.t),r=r.Lnext;while(r!==o.anEdge);if(a<0){for(i=n.next;i!==n;i=i.next)i.t=-i.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},e.prototype.projectPolygon_=function(){var i,r,s=this.mesh.vHead,n=[0,0,0],a=!1;n[0]=this.normal[0],n[1]=this.normal[1],n[2]=this.normal[2],!n[0]&&!n[1]&&!n[2]&&(this.computeNormal_(n),a=!0),i=this.sUnit,r=this.tUnit;var o=this.longAxis_(n);i[o]=0,i[(o+1)%3]=1,i[(o+2)%3]=0,r[o]=0,r[(o+1)%3]=0,r[(o+2)%3]=n[o]>0?1:-1;for(var l=s.next;l!==s;l=l.next)l.s=this.dot_(l.coords,i),l.t=this.dot_(l.coords,r);a&&this.checkOrientation_();for(var u=!0,h=s.next;h!==s;h=h.next)u?(this.bmin[0]=this.bmax[0]=h.s,this.bmin[1]=this.bmax[1]=h.t,u=!1):(h.s<this.bmin[0]&&(this.bmin[0]=h.s),h.s>this.bmax[0]&&(this.bmax[0]=h.s),h.t<this.bmin[1]&&(this.bmin[1]=h.t),h.t>this.bmax[1]&&(this.bmax[1]=h.t))},e.prototype.addWinding_=function(i,r){i.winding+=r.winding,i.Sym.winding+=r.Sym.winding},e.prototype.tessellateMonoRegion_=function(i,r){var s,n;if((s=r.anEdge).Lnext===s||s.Lnext.Lnext===s)throw"Mono region invalid";for(;je.vertLeq(s.Dst,s.Org);s=s.Lprev);for(;je.vertLeq(s.Org,s.Dst);s=s.Lnext);for(n=s.Lprev;s.Lnext!==n;)if(je.vertLeq(s.Dst,n.Org)){for(;n.Lnext!==s&&(je.edgeGoesLeft(n.Lnext)||je.edgeSign(n.Org,n.Dst,n.Lnext.Dst)<=0);)n=i.connect(n.Lnext,n).Sym;n=n.Lprev}else{for(;n.Lnext!==s&&(je.edgeGoesRight(s.Lprev)||je.edgeSign(s.Dst,s.Org,s.Lprev.Org)>=0);)s=i.connect(s,s.Lprev).Sym;s=s.Lnext}if(n.Lnext===s)throw"Mono region invalid";for(;n.Lnext.Lnext!==s;)n=i.connect(n.Lnext,n).Sym;return!0},e.prototype.tessellateInterior_=function(i){for(var r,s=i.fHead.next;s!==i.fHead;s=r)if(r=s.next,s.inside&&!this.tessellateMonoRegion_(i,s))return!1;return!0},e.prototype.discardExterior_=function(i){for(var r,s=i.fHead.next;s!==i.fHead;s=r)r=s.next,s.inside||i.zapFace(s)},e.prototype.setWindingNumber_=function(i,r,s){for(var n,a=i.eHead.next;a!==i.eHead;a=n)n=a.next,a.Rface.inside!==a.Lface.inside?a.winding=a.Lface.inside?r:-r:s?i.delete(a):a.winding=0},e.prototype.getNeighbourFace_=function(i){return i.Rface&&i.Rface.inside?i.Rface.n:-1},e.prototype.outputPolymesh_=function(i,r,s,n){var a,o,l=0,u=0;s>3&&i.mergeConvexFaces(s);for(var h=i.vHead.next;h!==i.vHead;h=h.next)h.n=-1;for(var d=i.fHead.next;d!==i.fHead;d=d.next)if(d.n=-1,d.inside){a=d.anEdge,o=0;do(h=a.Org).n===-1&&(h.n=u,u++),o++,a=a.Lnext;while(a!==d.anEdge);if(o>s)throw"Face vertex greater that support polygon";d.n=l,++l}for(this.elementCount=l,r===Ea.CONNECTED_POLYGONS&&(l*=2),this.elements=[],this.elements.length=l*s,this.vertexCount=u,this.vertices=[],this.vertices.length=u*n,this.vertexIndices=[],this.vertexIndices.length=u,h=i.vHead.next;h!==i.vHead;h=h.next)if(h.n!==-1){var c=h.n*n;this.vertices[c+0]=h.coords[0],this.vertices[c+1]=h.coords[1],n>2&&(this.vertices[c+2]=h.coords[2]),this.vertexIndices[h.n]=h.idx}var p=0;for(d=i.fHead.next;d!==i.fHead;d=d.next)if(d.inside){a=d.anEdge,o=0;do h=a.Org,this.elements[p++]=h.n,o++,a=a.Lnext;while(a!==d.anEdge);for(var m=o;m<s;++m)this.elements[p++]=-1;if(r===Ea.CONNECTED_POLYGONS){a=d.anEdge;do this.elements[p++]=this.getNeighbourFace_(a),a=a.Lnext;while(a!==d.anEdge);for(var f=o;f<s;++f)this.elements[p++]=-1}}},e.prototype.outputContours_=function(i,r){var s,n,a=0,o=0;this.vertexCount=0,this.elementCount=0;for(var l=i.fHead.next;l!==i.fHead;l=l.next)if(l.inside){n=s=l.anEdge;do this.vertexCount++,s=s.Lnext;while(s!==n);this.elementCount++}this.elements=[],this.elements.length=2*this.elementCount,this.vertices=[],this.vertices.length=this.vertexCount*r,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var u=0,h=0,d=0;for(a=0,l=i.fHead.next;l!==i.fHead;l=l.next)if(l.inside){o=0,n=s=l.anEdge;do this.vertices[u++]=s.Org.coords[0],this.vertices[u++]=s.Org.coords[1],r>2&&(this.vertices[u++]=s.Org.coords[2]),this.vertexIndices[h++]=this.vertexIdCallback?this.vertexIdCallback(s):s.Org.idx,o++,s=s.Lnext;while(s!==n);this.elements[d++]=a,this.elements[d++]=o,a+=o}},e.prototype.addContour=function(i,r){this.mesh===null&&(this.mesh=new PO),i<2&&(i=2),i>3&&(i=3);for(var s=null,n=0;n<r.length;n+=i)s===null?(s=this.mesh.makeEdge(),this.mesh.splice(s,s.Sym)):(this.mesh.splitEdge(s),s=s.Lnext),s.Org.coords[0]=r[n+0],s.Org.coords[1]=r[n+1],s.Org.coords[2]=i>2?r[n+2]:0,s.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(s),s.winding=1,s.Sym.winding=-1},e.prototype.tesselate=function(i,r,s,n,a,o){if(i===void 0&&(i=ss.ODD),r===void 0&&(r=Ea.POLYGONS),o===void 0&&(o=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,a&&(this.normal[0]=a[0],this.normal[1]=a[1],this.normal[2]=a[2]),this.windingRule=i,n<2&&(n=2),n>3&&(n=3),!this.mesh)return!1;this.projectPolygon_(),tK.computeInterior(this,o);var l=this.mesh;return r===Ea.BOUNDARY_CONTOURS?this.setWindingNumber_(l,1,!0):this.tessellateInterior_(l),o&&l.check(),r===Ea.BOUNDARY_CONTOURS?this.outputContours_(l,n):this.outputPolymesh_(l,r,s,n),!0},e}(),ss.ODD,ss.NONZERO,ss.POSITIVE,ss.NEGATIVE,ss.ABS_GEQ_TWO,Ea.POLYGONS,Ea.CONNECTED_POLYGONS,Ea.BOUNDARY_CONTOURS});function Uft(t,e){let i=t.length/2;if(i<2)return[];let r=0;for(let l=0;l<i;l++){let u=(l+1)%i;r+=t[2*l]*t[2*u+1]-t[2*u]*t[2*l+1]}let s=r>0!==e?1:-1,n=[];for(let l=0;l<i;l++){let u=(l+1)%i,h=t[2*u]-t[2*l],d=t[2*u+1]-t[2*l+1],c=Math.hypot(h,d);n.push(c>0?[s*d/c,-s*h/c]:[0,0])}let a=Math.cos(40*Math.PI/180),o=(l,u)=>{if(l[0]*u[0]+l[1]*u[1]<=a)return l;let[h,d]=[l[0]+u[0],l[1]+u[1]],c=Math.hypot(h,d);return c>0?[h/c,d/c]:l};return n.map((l,u)=>[o(l,n[(u+i-1)%i]),o(l,n[(u+1)%i])])}function jft(t,e,i){let r=t.length/2,s=new Float32Array(r+1);if(!(e>0)||!(i>0)||r<2)return{u:s,vScale:0};let n=0;for(let a=0;a<r;a++){let o=(a+1)%r;n+=Math.hypot((t[2*o]-t[2*a])/e,(t[2*o+1]-t[2*a+1])/i),s[a+1]=n}return{u:s,vScale:Math.sqrt(e*i)}}function Gft(t,e,i){for(let r=0;r<i.length;r+=3){let s=3*i[r],n=3*i[r+1],a=3*i[r+2],o=t[n]-t[s],l=t[n+1]-t[s+1],u=t[n+2]-t[s+2],h=t[a]-t[s],d=t[a+1]-t[s+1],c=t[a+2]-t[s+2],p=u*h-o*c,m=o*d-l*h;if((l*c-u*d)*(e[s]+e[n]+e[a])+p*(e[s+1]+e[n+1]+e[a+1])+m*(e[s+2]+e[n+2]+e[a+2])<0){let f=i[r+1];i[r+1]=i[r+2],i[r+2]=f}}}var AG,Wft,CG,AR,LU,qft=G(()=>{}),EG=G(()=>{AG={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},Wft={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},CG={vertices:[-160,160,160,-160,160,160,-160,-160],vertexIndices:[1,3,0,2],vertexCount:4,elements:[0,1,2,1,0,3],elementCount:2,mesh:void 0}}),f3t=G(()=>{dt(),tT(),ir(),qft(),EG(),AR=class extends ye{constructor(t,e,i=12,r=ss.ODD,s){super(),this.type="FlatExtrusionGeometry",this._nearSide=new Uint8Array(0),this._vScale=0,this._shape=t,this._depth=e,this._curveSegments=i,this._windingRule=r,this._uvPitch=s;let n,a=[t.extractShapePointsToFlatArray([],i),...t.shapeHoles.map(k=>k.extractShapePointsToFlatArray([],i))];try{n=X2({contours:a,windingRule:r,elementType:Ea.POLYGONS,polySize:3,vertexSize:2,strict:!0})}catch{n=CG}let o=n?.vertexCount??0,l=n?.elementCount??0,u=1/0,h=1/0,d=-1/0,c=-1/0;for(let k of a)for(let z=0;z<k.length;z+=2)k[z]<u&&(u=k[z]),k[z]>d&&(d=k[z]),k[z+1]<h&&(h=k[z+1]),k[z+1]>c&&(c=k[z+1]);let p=this._uvPitch,m=p??(d-u||1),f=p??(c-h||1),g=p===void 0?u:0,y=p===void 0?h:0,v=a.map((k,z)=>Uft(k,z>0)),b=0;for(let k of v)b+=k.length;let _=2*o+4*b,x=3*l*2+6*b,S=new Float32Array(3*_),w=new Float32Array(3*_),T=new Float32Array(2*_),A=new Uint32Array(x),M=new Uint8Array(_),C=0,R=0,O=0,N=!1,B=(k,z,L,V,q,j,Q=(k-g)/m,it=(z-y)/f)=>{let at=3*R;S[at]=k,S[at+1]=z,S[at+2]=L,w[at]=V,w[at+1]=q,w[at+2]=j,M[R]=L===e?N?2:1:0,T[2*R]=Q,T[2*R+1]=it,R++};if(n!==void 0)for(let[k,z]of[[e,1],[0,-1]]){let L=R;for(let V=0;V<o;V++)B(n.vertices[2*V],n.vertices[2*V+1],k,0,0,z);for(let V=0;V<l;V++){let[q,j,Q]=[n.elements[3*V],n.elements[3*V+1],n.elements[3*V+2]];A[O++]=L+q,A[O++]=L+(z>0?j:Q),A[O++]=L+(z>0?Q:j)}}N=!0;for(let k=0;k<a.length;k++){let z=a[k],L=v[k],V=z.length/2,{u:q,vScale:j}=jft(z,m,f);C=j;let Q=j===0?0:e/j;for(let it=0;it<L.length;it++){let at=(it+1)%V,[St,yt]=L[it],[Y,pt]=[q[it],q[it+1]],xt=R;B(z[2*it],z[2*it+1],e,St[0],St[1],0,Y,Q),B(z[2*it],z[2*it+1],0,St[0],St[1],0,Y,0),B(z[2*at],z[2*at+1],e,yt[0],yt[1],0,pt,Q),B(z[2*at],z[2*at+1],0,yt[0],yt[1],0,pt,0),A[O++]=xt,A[O++]=xt+1,A[O++]=xt+2,A[O++]=xt+3,A[O++]=xt+2,A[O++]=xt+1}}Gft(S,w,A),this.setAttribute("position",new we(S,3)),this.setAttribute("normal",new we(w,3)),this.setAttribute("uv",new we(T,2)),this.setIndex(new we(A,1)),this._nearSide=M,this._vScale=C}takeDepthStateFrom(t){let e=t;e._nearSide!==void 0&&(this._depth=e._depth??this._depth,this._nearSide=e._nearSide,this._vScale=e._vScale??this._vScale)}canShiftDepthTo(t){return this._nearSide.length>0&&this._depth>0&&t>0}shiftDepthTo(t){if(!this.canShiftDepthTo(t))return!1;let e=t-this._depth;if(this._depth=t,e===0)return!0;let i=this.getAttribute("position");if(i===void 0)return!1;let r=i.array,s=this.getAttribute("uv"),n=s?.array,a=this._vScale>0?e/this._vScale:0,o=this._nearSide;for(let l=0;l<o.length;l++){let u=o[l];u!==0&&(r[3*l+2]+=e,u===2&&n!==void 0&&(n[2*l+1]+=a))}return i.needsUpdate=!0,s!==void 0&&a!==0&&(s.needsUpdate=!0),this.refreshDepthBounds(t),!0}refreshDepthBounds(t){if(this.boundingBox===null&&this.boundingSphere===null)return;this.boundingBox===null&&this.computeBoundingBox();let e=this.boundingBox;e.min.z=Math.min(0,t),e.max.z=Math.max(0,t),this.boundingSphere!==null&&e.getBoundingSphere(this.boundingSphere)}clone(){let t=new AR(this._shape,this._depth,this._curveSegments,this._windingRule);return t.userData=x5(this.userData),t}}}),Hft=G(()=>{dt(),tT(),ir(),EG(),LU=class extends ye{constructor(t,e=12,i={}){super(),this.type="ShapeGeometry",this.windingRule=ss.ODD,this.elementType=Ea.POLYGONS,this.polySize=3,this.vertexSize=2,this.strict=!0,this._shape=t,this._curveSegments=e,this._triangulationOptions=Object.assign({windingRule:ss.ODD,elementType:Ea.POLYGONS,polySize:3,vertexSize:2,strict:!0},i);let r,s,n,a=this._shape.extractShapePointsToFlatArray([],this._curveSegments),o=this._shape.shapeHoles.map(c=>c.extractShapePointsToFlatArray([],this._curveSegments)),l=!0,u=!0;for(let c=0,p=a.length/2;c<p;c++){let m=2*c,f=a[m+0],g=a[m+1];if(s!==void 0&&f!==s&&(l=!1),n!==void 0&&g!==n&&(u=!1),s=f,n=g,!l&&!u)break}if(!l&&!u)try{r=X2({contours:[a,...o],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})}catch{r=AG}let h=r?.vertexCount??1,d=r?.elementCount??1;if(this._positionAttribute=new we(new Float32Array(3*h),3),this._normalAttribute=new we(new Float32Array(3*h),3),this._uvAttribute=new we(new Float32Array(2*h),2),this._indexAttribute=new we(new Uint32Array(3*d),1),r){let c=1/0,p=-1/0,m=1/0,f=-1/0;for(let v=0,b=h;v<b;v++){let _=2*v,x=r.vertices[_+0],S=r.vertices[_+1];x<c&&(c=x),x>p&&(p=x),S<m&&(m=S),S>f&&(f=S)}let g=p-c,y=f-m;for(let v=0,b=h;v<b;v++){let _=2*v,x=r.vertices[_+0],S=r.vertices[_+1],w=(x-c)/g,T=(S-m)/y;this._positionAttribute.setXYZ(v,x,S,0),this._normalAttribute.setXYZ(v,0,0,1),this._uvAttribute.setXY(v,w,T)}for(let v=0,b=d;v<b;v++){let _=3*v,x=r.elements[_+0],S=r.elements[_+1],w=r.elements[_+2];this._indexAttribute.setX(_+0,x),this._indexAttribute.setX(_+1,S),this._indexAttribute.setX(_+2,w)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,3*(r?.elementCount??1))}clone(){let t=new LU(this._shape,this._curveSegments);return t.userData=x5(this.userData),t}}});function g3t(t){return eK||(eK=async function(){let e=t??"https://unpkg.com/@splinetool/runtime@2.0.61/build",i=Promise.resolve().then(()=>(bq(),vq)),[r,s]=await Promise.all([i,fetch(`${e}/bevel.wasm`).then(n=>n.arrayBuffer())]);await r.default({module_or_path:s}),eT=r}())}function y3t(t){let e=!1;return t.scene.objects.traverse((i,r)=>{let s=r.geometry;if(s!==void 0&&(Kft.has(s.type)&&s.depth!==void 0&&s.depth>0&&(s.extrudeBevelSize??0)>0&&(e=!0),s.type==="PathGeometry")){let n=s.extrusion;n!==void 0&&n.capType==="round"&&(n.bevel??0)>0&&(e=!0)}}),e}function $ft(t,e){let i=[t.extractShapePointsToFlatArray([],e)];for(let o of t.shapeHoles)i.push(o.extractShapePointsToFlatArray([],e));let r=0;for(let o of i)r+=o.length>>1;let s=new Float64Array(2*r),n=new Uint32Array(i.length),a=0;for(let o=0;o<i.length;o++)s.set(i[o],2*a),a+=i[o].length>>1,n[o]=a;return{points:s,ends:n}}function CR(t,e,i,r,s,n){let a=t.positions.length/3,o=s.elements,l=Zft.getNormalMatrix(s).elements;for(let h=0;h<a;h++){let d=3*h,c=3*(i+h),p=t.positions[d],m=t.positions[d+1],f=t.positions[d+2];e.positions[c]=o[0]*p+o[4]*m+o[8]*f+o[12],e.positions[c+1]=o[1]*p+o[5]*m+o[9]*f+o[13],e.positions[c+2]=o[2]*p+o[6]*m+o[10]*f+o[14];let g=t.normals[d],y=t.normals[d+1],v=t.normals[d+2];e.normals[c]=l[0]*g+l[3]*y+l[6]*v,e.normals[c+1]=l[1]*g+l[4]*y+l[7]*v,e.normals[c+2]=l[2]*g+l[5]*y+l[8]*v;let b=2*(i+h);if(n===void 0)e.uvs[b]=t.uvs[2*h],e.uvs[b+1]=t.uvs[2*h+1];else{let[_,x]=n(p,m,t.uvs[2*h],t.uvs[2*h+1]);e.uvs[b]=_,e.uvs[b+1]=x}}let u=s.determinant()<0;for(let h=0;h<t.indices.length;h+=3)e.indices[r+h]=t.indices[h]+i,e.indices[r+h+1]=t.indices[h+(u?2:1)]+i,e.indices[r+h+2]=t.indices[h+(u?1:2)]+i}function Xft(t){let{owner:e,shape:i,curveSegments:r,assembledAt:s,bevel:n,bevelSegments:a}=t,o=function(c,p){let m=[p],f=g=>{m.push(g.points.length,g.isClosed?1:0,g.roundness??0);for(let y of g.points){m.push(y.roundness??0,y.position.x,y.position.y);for(let v of y.controls)m.push(v.position.x,v.position.y)}m.push(g.shapeHoles.length);for(let y of g.shapeHoles)f(y)};return f(c),function(g){let y=2166136261;for(let v=0;v<g.length;v++)y^=g[v],y=Math.imul(y,16777619)>>>0;return y}(new Uint8Array(new Float64Array(m).buffer))}(i,r),l=e??`outline:${o}`,u=`${n}/${a}`,h=ER.get(l);if(h!==void 0&&h.outlineVersion===o&&h.capKey===u&&(t.stillServes?.(h)??1))return FU.placements++,h.cap;let d=function(c,p,m,f,g){let{points:y,ends:v}=$ft(c,p);return eT.assemble_cap(y,v,m,f,0,Math.max(1,Math.floor(g)),Yft,40)}(i,r,s,n,a);FU.assemblies++;try{let c=function(p,m){return function(f,g,y,v,b){let _=1/0;for(let x=2;x<f.length;x+=3)f[x]<_&&(_=f[x]);if(_===1/0&&(_=0),_!==0)for(let x=2;x<f.length;x+=3)f[x]-=_;return{positions:f,normals:g,uvs:y,indices:v,rise:b-_}}(p.positions(),p.normals(),p.uvs(),p.indices(),m)}(d,s);return ER.set(l,{outlineVersion:o,capKey:u,assembledAt:s,cap:c}),c}finally{d.free()}}function X1(t,e){return .5*e>1.001*t}var eT,Yft,eK,Kft,Zft,iK,rK,sK,ER,FU,UU,xm,Kv=G(()=>{dt(),ir(),qft(),Yft=.4,Kft=new Set(["VectorGeometry","TextGeometry","InputGeometry","PolygonGeometry","RectangleGeometry","StarGeometry","TriangleGeometry","EllipseGeometry"]),Zft=new Ts,iK=new bt,rK=new bt,sK=new bt().makeScale(1,1,-1),ER=new Map,FU={assemblies:0,placements:0},UU=class extends ye{constructor(t,e,i=0,r=12,s=3,n,a){if(super(),this.type="ShapeGeometry",this._nearSide=new Uint8Array(0),this._effectiveBevel=0,this._vScale=0,eT===void 0)throw new Error("bevel-wasm is not loaded");this._shape=t,this._uvPitch=a,this._depth=e,this._bevel=i,this._curveSegments=r,this._bevelSegments=s,this._ownerId=n,this.rebuild()}takeDepthStateFrom(t){let e=t;e._nearSide!==void 0&&(this._depth=e._depth??this._depth,this._nearSide=e._nearSide,this._vScale=e._vScale??this._vScale,this._effectiveBevel=e._effectiveBevel??this._effectiveBevel)}canShiftDepthTo(t){return this._nearSide.length>0&&X1(this._effectiveBevel,t)&&X1(this._effectiveBevel,this._depth)}shiftDepthTo(t){if(!this.canShiftDepthTo(t))return!1;let e=t-this._depth;if(this._depth=t,e===0)return!0;let i=this.getAttribute("position");if(i===void 0)return!1;let r=i.array,s=this.getAttribute("uv"),n=s?.array,a=this._vScale>0?e/this._vScale:0,o=this._nearSide;for(let l=0;l<o.length;l++){let u=o[l];u!==0&&(r[3*l+2]+=e,u===2&&n!==void 0&&(n[2*l+1]+=a))}return i.needsUpdate=!0,s!==void 0&&a!==0&&(s.needsUpdate=!0),this.refreshDepthBounds(t),!0}refreshDepthBounds(t){if(this.boundingBox===null&&this.boundingSphere===null)return;this.boundingBox===null&&this.computeBoundingBox();let e=this.boundingBox;e.min.z=Math.min(0,t),e.max.z=Math.max(0,t),this.boundingSphere!==null&&e.getBoundingSphere(this.boundingSphere)}setDepth(t){t!==this._depth&&(this._depth=t,this.rebuild(),this.computeBoundingSphere(),this.computeBoundingBox())}rebuild(){let t=Xft({owner:this._ownerId,shape:this._shape,curveSegments:this._curveSegments,assembledAt:this._depth,bevel:this._bevel,bevelSegments:this._bevelSegments,stillServes:a=>X1(a.cap.rise,this._depth)&&X1(a.cap.rise,a.assembledAt)}),e=function(a,o,l,u,h){let d=u.positions.length/3,c=l-u.rise,p=u.rise,{points:m,ends:f}=$ft(a,o),g=1/0,y=1/0,v=-1/0,b=-1/0;for(let q=0;q<m.length;q+=2)m[q]<g&&(g=m[q]),m[q]>v&&(v=m[q]),m[q+1]<y&&(y=m[q+1]),m[q+1]>b&&(b=m[q+1]);let _=h??v-g,x=h??b-y,S=[],w=0;for(let q of f)S.push({at:w,count:q-w}),w=q;let T=0;for(let q of S)T+=q.count;let A=2*d+4*T,M=new Float32Array(3*A),C=new Float32Array(3*A),R=new Float32Array(2*A),O=new Uint32Array(2*u.indices.length+6*T),N=new Uint8Array(A),B=0,k=h===void 0?void 0:(q,j)=>[q/h,j/h],z={positions:M,normals:C,uvs:R,indices:O};CR(u,z,0,0,iK.makeTranslation(0,0,c),k),CR(u,z,d,u.indices.length,rK.makeTranslation(0,0,p).multiply(sK),k),N.fill(1,0,d);let L=2*d,V=2*u.indices.length;for(let q=0;q<S.length;q++){let{at:j,count:Q}=S[q],it=m.subarray(2*j,2*(j+Q)),at=Uft(it,q>0),St=jft(it,_,x),yt=St.u;B=St.vScale;for(let Y=0;Y<Q;Y++){let pt=(Y+1)%Q,[xt,Tt]=at[Y],Mt=L;for(let[_t,kt,Ut,Lt,zt,Bt]of[[it[2*Y],it[2*Y+1],xt,c,yt[Y],2],[it[2*pt],it[2*pt+1],Tt,c,yt[Y+1],2],[it[2*pt],it[2*pt+1],Tt,p,yt[Y+1],0],[it[2*Y],it[2*Y+1],xt,p,yt[Y],0]]){let jt=3*L;M[jt]=_t,M[jt+1]=kt,M[jt+2]=Lt,C[jt]=Ut[0],C[jt+1]=Ut[1],C[jt+2]=0,R[2*L]=zt,R[2*L+1]=B===0?0:(Lt-p)/B,N[L]=Bt,L++}O[V++]=Mt,O[V++]=Mt+1,O[V++]=Mt+2,O[V++]=Mt,O[V++]=Mt+2,O[V++]=Mt+3}}return Gft(M,C,O),{positions:M,normals:C,uvs:R,indices:O,nearSide:N,vScale:B}}(this._shape,this._curveSegments,this._depth,t,this._uvPitch);this._nearSide=e.nearSide,this._vScale=e.vScale,this._effectiveBevel=t.rise;let i=this.getAttribute("position"),r=this.getAttribute("normal"),s=this.getAttribute("uv"),n=this.getIndex();if(i!==void 0&&r!==void 0&&s!==void 0&&n!==null&&i.array.length===e.positions.length&&r.array.length===e.normals.length&&s.array.length===e.uvs.length&&n.array.length===e.indices.length)return i.array.set(e.positions),r.array.set(e.normals),s.array.set(e.uvs),n.array.set(e.indices),i.needsUpdate=!0,r.needsUpdate=!0,s.needsUpdate=!0,void(n.needsUpdate=!0);this.setAttribute("position",new we(e.positions,3)),this.setAttribute("normal",new we(e.normals,3)),this.setAttribute("uv",new we(e.uvs,2)),this.setIndex(new we(e.indices,1))}clone(){let t=new UU(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegments,this._ownerId);return t.userData=x5(this.userData),t}}}),fm=G(()=>{_m(),f3t(),Hft(),Kv(),tT(),xm=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i,r=Object.assign({},e?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:ss.ODD},t.parameters),s=Math.abs(r.width),n=Math.abs(r.height??r.width),a=Math.abs(r.depth??0),o=t.shape??e?.shape,l=o?.roundness??r.roundness;o!==void 0&&(o instanceof ds?(i=o,(i.width!==s||i.height!==n)&&i.applySize(s,n)):i=new ds(s,n).fromJSON(o),t.parameters?.roundness!==void 0&&t.parameters?.roundness>0&&i.update());let u=i??new ds(s,n);return{parameters:Object.assign(r,{width:s,height:n,depth:a,roundness:l}),shape:u,ownerId:t.ownerId??e?.ownerId}}static build(t){let e,{depth:i,extrudeBevelSize:r,extrudeBevelSegments:s,subdivisions:n,roundness:a,windingRule:o,uvPitch:l}=t.parameters;return t.shape.roundness=a,i<=0?e=new LU(t.shape,n,{windingRule:o}):r<=0?e=new AR(t.shape,i,n,o,l):eT!==void 0?e=new UU(t.shape,i,r,n,s,t.ownerId,l):(console.error("[extrude] engine not loaded \u2014 extruding without a bevel"),e=new AR(t.shape,i,n,o,l)),Object.assign(e,{userData:{...t,type:"VectorGeometry"}})}}});function v3t(t,e,i,r,s,n){if(r>=PG)return s>30||s%4==0?(function(h,d,c,p=0,m=0,f=0){let g=.5522847498,y=d*g,v=c*g;h.addPoint(BM(m-d,f,m-d,f-v,m-d,f+v)),h.addPoint(BM(m,f+c,m-y,f+c,m+y,f+c)),h.addPoint(BM(m+d,f,m+d,f+v,m+d,f-v)),h.addPoint(BM(m,f-c,m+y,f-c,m-y,f-c)),p>0&&Jft(h,d,c,p)}(t,e,i,n),Math.round(s/4)):nK(t,r,s,e,i,n);let a={x:0,y:i},o=(r=Math.max(r,.001))+.5*Math.PI,l={x:Math.cos(o)*e,y:Math.sin(o)*i},u=function({px:h,py:d,cx:c,cy:p,rx:m,ry:f,largeArcFlag:g,sweepFlag:y}){let v=[];if(m===0||f===0)return[];let b=(h-c)/2,_=(d-p)/2;if(b===0&&_===0)return[];m=Math.abs(m),f=Math.abs(f);let x=Math.pow(b,2)/Math.pow(m,2)+Math.pow(_,2)/Math.pow(f,2);x>1&&(m*=Math.sqrt(x),f*=Math.sqrt(x));let S=function(O,N,B,k,z,L,V,q,j,Q){let it=Math.pow(z,2),at=Math.pow(L,2),St=Math.pow(V,2),yt=Math.pow(q,2),Y=it*at-it*yt-at*St;Y<0&&(Y=0),Y/=it*yt+at*St,Y=Math.sqrt(Y)*(j===Q?-1:1);let pt=Y*z/L*q,xt=Y*-L/z*V,Tt=pt+(O+B)/2,Mt=xt+(N+k)/2,_t=(V-pt)/z,kt=(q-xt)/L,Ut=(-V-pt)/z,Lt=(-q-xt)/L,zt=ZY(1,0,_t,kt),Bt=ZY(_t,kt,Ut,Lt);return!Q&&Bt>0&&(Bt-=VP),Q&&Bt<0&&(Bt+=VP),{centerx:Tt,centery:Mt,ang1:zt,ang2:Bt}}(h,d,c,p,m,f,b,_,g,y),{ang1:w,ang2:T}=S,{centerx:A,centery:M}=S,C=Math.abs(T)/(VP/4);Math.abs(1-C)<1e-7&&(C=1);let R=Math.max(Math.ceil(C),1);T/=R;for(let O=0;O<R;O++)v.push(p3t(w,T)),w+=T;return v.map(O=>{let{x:N,y:B}=EO(O[0],m,f,A,M),{x:k,y:z}=EO(O[1],m,f,A,M),{x:L,y:V}=EO(O[2],m,f,A,M);return{x1:N,y1:B,x2:k,y2:z,x:L,y:V}})}({px:a.x,py:a.y,cx:l.x,cy:l.y,rx:e,ry:i,largeArcFlag:r>Math.PI,sweepFlag:!0});return s>30||s%u.length===0?function(h,d,c,p,m,f,g,y){let v=Math.round(m/p.length);h.addPoint(pv(d,c));for(let b=0,_=p.length;b<_;b++){let x=p[b],S=h.points[b],w=pv(x.x,x.y);S.controls[1].position.set(x.x1,x.y1),w.controls[0].position.set(x.x2,x.y2),h.addPoint(w)}return y>0?Qft(h,f,g,y):h.addPoint(pv(0,0)),v}(t,a.x,a.y,u,s,e,i,n):nK(t,r,s,e,i,n)}function nK(t,e,i,r,s,n){let a=-e/i;for(let o=0;o<=i;o++){let l=a*o,u=Math.sin(l)*r,h=Math.cos(l)*s;t.addPoint(pv(u,h))}return e<PG?n>0?Qft(t,r,s,n):t.addPoint(pv(0,0)):(t.removePoint(t.points[t.points.length-1]),n>0&&Jft(t,r,s,n)),1}function pv(t,e){return new jg(qt.generateUUID(),new Z(t,e))}function BM(t,e,i,r,s,n){let a=pv(t,e);return a.controls[0].position.set(i,r),a.controls[1].position.set(s,n),a}function Qft(t,e,i,r){tgt(t,e,i,r).forEach(s=>t.addPoint(s))}function Jft(t,e,i,r){let s=tgt(t,e,i,r),n=new ds;s.forEach(a=>n.addPoint(a)),n.isClosed=!0,t.shapeHoles.push(n)}function tgt(t,e,i,r){let s=r*e/100,n=s*(Math.abs(i)/Math.abs(e)),a=new Z(s/e,n/i),o=t.points.map(l=>{let u=l.clone();return u.uuid=qt.generateUUID(),u}).reverse();return o.forEach(l=>{l.position.multiply(a);let u=l.controls[0].position.clone().multiply(a),h=l.controls[1].position.clone().multiply(a);l.controls[0].position.copy(h),l.controls[1].position.copy(u)}),o}var PG,z5,egt,OO,igt,PR=G(()=>{_m(),Lft(),m3t(),fm(),dt(),PG=2*Math.PI,z5=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},t.parameters);return i.angle=qt.clamp(i.angle,0,360),{shape:t.shape&&t.shape instanceof ds?t.shape:new ds,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(t){let e,{width:i,height:r,spikes:s,angle:n,innerRadius:a,depth:o,extrudeBevelSize:l,extrudeBevelSegments:u}=t.parameters,h=t.shape,d=v3t(h,.5*i,.5*r,n*Math.PI/180,s,a);return h.isClosed=!0,h.update(),n===0?(e=new ye,e.setAttribute("position",new fe([],3))):e=xm.create({shape:h,parameters:{subdivisions:d,depth:o,extrudeBevelSize:l,extrudeBevelSegments:u}}),Object.assign(e,{userData:{...t,type:"EllipseGeometry"}})}}}),aK=G(()=>{dt(),Oft(),egt=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,detail:0,corner:0,cornerSides:4},t.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(t){let{width:e,height:i,depth:r,detail:s,corner:n,cornerSides:a}=t.parameters,o=s===0&&n!==0?new OO(.5*e,n,a):new w8(.5*e,s),l=i/e,u=r/e;return(l!==1||u!==1)&&o.scale(1,l,u),Object.assign(o,{userData:{...t,type:"IcosahedronGeometry"}})}},OO=class extends TR{constructor(t=1,e=.2,i=4){let r=(1+Math.sqrt(5))/2,s="IcosahedronGeometry";super([-1,r,0,1,r,0,-1,-r,0,1,-r,0,0,-1,r,0,1,r,0,-1,-r,0,1,-r,r,0,-1,r,0,1,-r,0,-1,-r,0,1],[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],s,t,e,i),this.type=s}static fromJSON(t){return new OO(t.radius,t.corner,t.cornerSides)}}}),oK=G(()=>{dt(),igt=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){(t.parameters?.points??[]).forEach(r=>{Array.isArray(r)&&(r.x=r[0],r.y=r[1])});let i=Object.assign({},e?.parameters??{width:100,segments:64,verticalSegments:64,points:[{x:0,y:-50,id:0},{x:50,y:-50,id:1},{x:50,y:50,id:2},{x:0,y:50,id:3}]},t.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(t){let{points:e,segments:i,verticalSegments:r}=t.parameters,s=new bS;s.moveTo(e[0].x,e[0].y),s.bezierCurveTo(e[1].x,e[1].y,e[2].x,e[2].y,e[3].x,e[3].y);let n=new S8(s.extractPoints(r).shape,i);return n.rotateZ(Math.PI),Object.assign(n,{userData:{...t,type:"LatheGeometry"}})}}});function L0(t,e){return Math.abs(e-t)/2+Math.min(t,e)}function b3t(t){let{positions:e,faces:i,materialIndices:r,uvs:s}=t,n=e.length/3,a=i.length/3,o=s!==null&&a>0,l=3*a,u=new Uint32Array(l),h=new Uint32Array(l),d=new Uint32Array(l),c=new Uint32Array(l),p=new Uint32Array(l),m=0,f=8;for(;f<2*l;)f*=2;let g=f-1,y=new Int32Array(f).fill(-1),v=(N,B)=>{let k=(Math.imul(N,2654435761)^B)&g;for(;;){let z=y[k];if(z===-1)return y[k]=m,u[m]=N,h[m]=B,m++;if(u[z]===N&&h[z]===B)return z;k=k+1&g}},b=(N,B)=>{let k=N<B?N:B,z=N<B?B:N,L=(Math.imul(k,2654435761)^z)&g;for(;;){let V=y[L];if(u[V]===k&&h[V]===z)return V;L=L+1&g}},_=new Uint32Array(n),x=new Float64Array(3*n),S=(N,B,k)=>{let z=N<B?v(N,B):v(B,N),L=++d[z];L===1?c[z]=k:L===2&&(p[z]=k),_[N]++,_[B]++,x[3*N]+=e[3*B],x[3*N+1]+=e[3*B+1],x[3*N+2]+=e[3*B+2],x[3*B]+=e[3*N],x[3*B+1]+=e[3*N+1],x[3*B+2]+=e[3*N+2]};for(let N=0;N<a;N++){let B=i[3*N],k=i[3*N+1],z=i[3*N+2];S(B,k,z),S(k,z,B),S(z,B,k)}let w=new Float64Array(3*m);for(let N=0;N<m;N++){let B=3*u[N],k=3*h[N];if(d[N]===2){let z=3*c[N],L=3*p[N];w[3*N]=.375*(e[B]+e[k])+.125*(e[z]+e[L]),w[3*N+1]=.375*(e[B+1]+e[k+1])+.125*(e[z+1]+e[L+1]),w[3*N+2]=.375*(e[B+2]+e[k+2])+.125*(e[z+2]+e[L+2])}else w[3*N]=.5*(e[B]+e[k]),w[3*N+1]=.5*(e[B+1]+e[k+1]),w[3*N+2]=.5*(e[B+2]+e[k+2])}let T,A=new Float64Array(3*n);for(let N=0;N<n;N++){let B=_[N];B===3?T=3/16:B>3&&(T=3/(8*B));let k=1-B*Number(T),z=Number(T);B===2&&(k=3/4,z=1/8),A[3*N]=e[3*N]*k+x[3*N]*z,A[3*N+1]=e[3*N+1]*k+x[3*N+1]*z,A[3*N+2]=e[3*N+2]*k+x[3*N+2]*z}let M=new Float64Array(3*(n+m));M.set(A),M.set(w,3*n);let C=new Uint32Array(12*a),R=new Array(4*a),O=o?new Float64Array(24*a):null;for(let N=0;N<a;N++){let B=i[3*N],k=i[3*N+1],z=i[3*N+2],L=b(B,k)+n,V=b(k,z)+n,q=b(z,B)+n,j=12*N;C[j++]=L,C[j++]=V,C[j++]=q,C[j++]=B,C[j++]=L,C[j++]=q,C[j++]=k,C[j++]=V,C[j++]=L,C[j++]=z,C[j++]=q,C[j++]=V;let Q=r[N];if(R[4*N]=Q,R[4*N+1]=Q,R[4*N+2]=Q,R[4*N+3]=Q,O!==null){let it=6*N,at=s[it],St=s[it+1],yt=s[it+2],Y=s[it+3],pt=s[it+4],xt=s[it+5],Tt=L0(at,yt),Mt=L0(St,Y),_t=L0(yt,pt),kt=L0(Y,xt),Ut=L0(at,pt),Lt=L0(St,xt),zt=24*N;O[zt++]=Tt,O[zt++]=Mt,O[zt++]=_t,O[zt++]=kt,O[zt++]=Ut,O[zt++]=Lt,O[zt++]=at,O[zt++]=St,O[zt++]=Tt,O[zt++]=Mt,O[zt++]=Ut,O[zt++]=Lt,O[zt++]=yt,O[zt++]=Y,O[zt++]=_t,O[zt++]=kt,O[zt++]=Tt,O[zt++]=Mt,O[zt++]=pt,O[zt++]=xt,O[zt++]=Ut,O[zt++]=Lt,O[zt++]=_t,O[zt++]=kt}}return{positions:M,faces:C,materialIndices:R,uvs:O}}var VM,rgt,tn,sgt,RG,_3t=G(()=>{dt(),VM=1e4,rgt=class{constructor(t=1){this.subdivisions=t}modify(t){let e=function(r){let s=r.getAttribute("position");if(s===void 0)return console.error("SubdivisionModifier: Position attribute required for subdivision."),{positions:new Float64Array(0),faces:new Uint32Array(0),materialIndices:[],uvs:null};let n=r.getAttribute("uv"),a=r.getIndex(),o=s.count,l=new Map,u=new Uint32Array(o),h=[],d=0;for(let v=0;v<o;v++){let b=s.getX(v),_=s.getY(v),x=s.getZ(v),S=Math.round(b*VM),w=Math.round(_*VM),T=Math.round(x*VM),A=l.get(S);A===void 0&&(A=new Map,l.set(S,A));let M=A.get(w);M===void 0&&(M=new Map,A.set(w,M));let C=M.get(T);C===void 0&&(C=d++,M.set(T,C),h.push(b,_,x)),u[v]=C}let c=[],p=[],m=n===void 0?null:[],f=a!==null?a.count:o,g=(v,b)=>{let _=a!==null?a.getX(v):v,x=a!==null?a.getX(v+1):v+1,S=a!==null?a.getX(v+2):v+2;if(!(_<o&&x<o&&S<o))return;let w=u[_],T=u[x],A=u[S];w===T||T===A||A===w||(c.push(w,T,A),p.push(b),m!==null&&m.push(n.getX(_),n.getY(_),n.getX(x),n.getY(x),n.getX(S),n.getY(S)))},y=r.groups;if(y.length>0)for(let v=0;v<y.length;v++){let b=y[v],_=b.materialIndex===void 0?0:b.materialIndex,x=Math.max(b.start,0),S=Math.min(b.start+b.count,f);for(let w=x;w<S&&w+2<f;w+=3)g(w,_)}else for(let v=0;v+2<f;v+=3)g(v,0);return{positions:Float64Array.from(h),faces:Uint32Array.from(c),materialIndices:p,uvs:m===null?null:Float64Array.from(m)}}(t),i=this.subdivisions;for(;i-- >0;)e=b3t(e);return function(r,s){let{positions:n,faces:a,materialIndices:o,uvs:l}=r,u=n.length/3,h=a.length/3,d=new Float64Array(3*u);for(let y=0;y<h;y++){let v=3*a[3*y],b=3*a[3*y+1],_=3*a[3*y+2],x=n[_]-n[b],S=n[_+1]-n[b+1],w=n[_+2]-n[b+2],T=n[v]-n[b],A=n[v+1]-n[b+1],M=n[v+2]-n[b+2],C=S*M-w*A,R=w*T-x*M,O=x*A-S*T;d[v]+=C,d[v+1]+=R,d[v+2]+=O,d[b]+=C,d[b+1]+=R,d[b+2]+=O,d[_]+=C,d[_+1]+=R,d[_+2]+=O}for(let y=0;y<u;y++){let v=d[3*y],b=d[3*y+1],_=d[3*y+2],x=Math.sqrt(v*v+b*b+_*_)||1;d[3*y]=v/x,d[3*y+1]=b/x,d[3*y+2]=_/x}let c=3*h,p=new Float32Array(3*c),m=new Float32Array(3*c),f=l!==null&&l.length>0?new Float32Array(2*c):null;for(let y=0;y<c;y++){let v=3*a[y];p[3*y]=n[v],p[3*y+1]=n[v+1],p[3*y+2]=n[v+2],m[3*y]=d[v],m[3*y+1]=d[v+1],m[3*y+2]=d[v+2]}f!==null&&f.set(l.subarray(0,2*c));let g=new ye;g.setAttribute("position",new we(p,3)),c>0&&(g.setAttribute("normal",new we(m,3)),g.setAttribute("color",new we(new Float32Array(3*c).fill(1),3))),f!==null&&g.setAttribute("uv",new we(f,2));for(let y=0;y<h;){let v=o[y],b=y;do y++;while(y<h&&o[y]===v);g.addGroup(3*b,3*(y-b),v)}return s.boundingBox!==null&&(g.boundingBox=s.boundingBox.clone()),s.boundingSphere!==null&&(g.boundingSphere=s.boundingSphere.clone()),g}(e,t)}}}),lK=G(()=>{dt(),_3t(),tn=new P,sgt=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i,r=t.geometry??e?.geometry??new ye().copy(new Zh(100,100,100));e===void 0?(r.computeBoundingBox(),r.boundingBox.getSize(tn),i={width:tn.x,height:tn.y,depth:tn.z,subdivisions:0}):i=e.parameters;let s={...i,...t.parameters};return{parameters:{width:Math.abs(s.width),height:Math.abs(s.height),depth:Math.abs(s.depth),subdivisions:Math.abs(s.subdivisions)},geometry:r}}static build(t){let{width:e,height:i,depth:r,subdivisions:s}=t.parameters,n=t.geometry??new ye().copy(new Zh(100,100,100)),a=n.userData.parameters;a===void 0?(n.boundingBox=function(l){let u=new pr,h=l.attributes.position;return h?(u.setFromBufferAttribute(h),u):(u.makeEmpty(),u)}(n),n.boundingBox.getSize(tn)):tn.set(a.width,a.height,a.depth),(e!==tn.x||i!==tn.y||r!==tn.z)&&n.scale(tn.x===0?1:e/tn.x,tn.y===0?1:i/tn.y,tn.z===0?1:r/tn.z);let o=n.originalGeometry;try{s>0?(o===void 0||a?.subdivisions!==s)&&(o===void 0&&(o=n),n=new rgt(s).modify(o)):(o!==void 0&&(n=o),o=void 0,n.getAttribute("normal")===void 0&&n.computeVertexNormals())}catch{o!==void 0&&(n=o),o=void 0,n.getAttribute("normal")===void 0&&n.computeVertexNormals()}return o!==void 0&&Object.assign(n,{originalGeometry:o}),delete t.geometry,Object.assign(n,{userData:{...t,type:"NonParametricGeometry"}})}static loadFromUrl(t,e,i){new F7(i).load(t,r=>{let s=this.normalizeInputs({geometry:r});r.boundingBox.getSize(tn);let n=100/tn.x;Object.assign(s.parameters,{width:100,height:tn.y*n,depth:tn.z*n}),e(this.build(s))})}}}),jU=G(()=>{_m(),fm(),RG=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},t.parameters);return{shape:t.shape&&t.shape instanceof ds?t.shape:new ds,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(t){let{width:e,height:i,spikes:r,cornerRadius:s,depth:n,extrudeBevelSize:a,extrudeBevelSegments:o}=t.parameters,l=t.shape,u=.5*e,h=.5*i,d=2*Math.PI/r;for(let p=0;p<r;p++){let m=d*p,f=0+Math.sin(m)*u,g=0+Math.cos(m)*h;l.addPoint(l.createPoint(f,g))}l.isClosed=!0;for(let p=0,m=l.points.length;p<m;p++)l.points[p].roundness=s;l.roundness=s,l.update();let c=xm.create({shape:l,parameters:{roundness:s,depth:n,extrudeBevelSize:a,extrudeBevelSegments:o}});return Object.assign(c,{userData:{...t,type:"PolygonGeometry"}})}}});function l_(t,e,i){i.x=t.x*e.x,i.y=t.y,i.z=t.x*e.y}function IO(t,e,i,r,s,n){let a=agt.copy(e).sub(t),o=ogt.copy(i).sub(t),l=a.angleTo(o);if(a.normalize(),o.normalize(),r===s){let u=a.add(o).normalize();n.copy(t).addScaledVector(u,r/Math.sin(l/2))}else{let u=a.angleTo(o);n.copy(t),n.addScaledVector(a,s/Math.sin(u)),n.addScaledVector(o,r/Math.sin(u))}}function x3t(t,e,i){let r=t.clone().sub(e),s=i.clone().sub(e);return r.projectOnVector(s),r.add(e)}var ngt,agt,ogt,hK,L5,lgt,hgt,ugt,uK,DG,dgt,cgt,pgt,mgt,dK=G(()=>{dt(),ngt=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},t.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(t){let{width:e,height:i,depth:r,radialSegments:s,heightSegments:n,openEnded:a,cornerRadius:o,cornerSegments:l}=t.parameters,u=new hK(.5*e,i,s,n,a,o,l),h=r/e;return h!==1&&u.scale(1,1,h),Object.assign(u,{userData:{...t,type:"PyramidGeometry"}})}},agt=new P,ogt=new P,hK=class extends ye{constructor(t=.5,e=1,i=4,r=1,s=!1,n=0,a=4){super(),i=Math.floor(Math.max(3,i)),r=Math.floor(r),a=Math.floor(a);let o,l=[],u=[],h=[],d=[],c=0,p=e/2,m=Math.PI/i,f=t*Math.cos(Math.PI/i),g=2*Math.PI/i,y=(i-2)*Math.PI/i,v=Math.PI-y,b=new P(0,-p,0),_=new P(0,p,0),x=new Z(t,-p),S=new Z(f,-p),w=new Z(0,_.y).sub(S),T=new Z(0,_.y).sub(x),A=new Z(w.y,-w.x).normalize(),M=new Z(T.y,-T.x).normalize(),C=t*Math.cos(Math.PI/i)*Math.tan((Math.PI-w.angle())/2)-1e-8;n=Math.min(n,C);{let L=new P(A.x,A.y,0),V=new P(Math.cos(g)*L.x,L.y,Math.sin(g)*L.x);o=L.angleTo(V)}let R=n/Math.tan((Math.PI-w.angle())/2),O=n/Math.tan((Math.PI-o)/2),N=new P;if(!s){u.push(b.x,b.y,b.z),h.push(0,-1,0),d.push(0,0);let L=c++,V=[],q=x.clone(),j=R/Math.cos(Math.PI/i);q.x-=j;for(let Q=0;Q<i;Q++){let it=Q/i*Math.PI*2+m;l_(q,new Z(Math.sin(it),Math.cos(it)),N),u.push(N.x,N.y,N.z),h.push(0,-1,0),d.push(0,0),V.push(c++)}for(let Q=0;Q<V.length;Q++)l.push(V[Q],L,V[(Q+1)%V.length])}let B=[];{let L=new P,V=new P,q=new P,j=new P,Q=new P,it=new P;for(let at=0;at<i;at++){let St=at/i*Math.PI*2+m,yt=(at+.5)/i*Math.PI*2+m,Y=(at+1)/i*Math.PI*2+m,pt=new Z(Math.sin(St),Math.cos(St)),xt=new Z(Math.sin(yt),Math.cos(yt)),Tt=new Z(Math.sin(Y),Math.cos(Y));l_(x,pt,V),l_(x,Tt,q),l_(A,xt,L),IO(_,V,q,O,O,j),u.push(j.x,j.y,j.z),IO(V,_,q,O,R,Q),u.push(Q.x,Q.y,Q.z),IO(q,V,_,R,O,it),u.push(it.x,it.y,it.z),h.push(L.x,L.y,L.z),h.push(L.x,L.y,L.z),h.push(L.x,L.y,L.z),d.push(0,0),d.push(0,0),d.push(0,0);let Mt=c++,_t=c++,kt=c++;if(l.push(Mt,_t,kt),n>0){{let zt=V.clone().add(q).multiplyScalar(.5),Bt=_.clone().sub(zt).normalize(),jt=b.clone().sub(zt).normalize().add(Bt).normalize().multiplyScalar(-1);k(zt,it.clone().sub(Q),jt,w.angle())}let Ut,Lt;{let zt=new P;l_(M,Tt,zt);let Bt=it.clone().add(j).multiplyScalar(.5);Bt=x3t(Bt,q,_);let jt=it.clone().sub(j);[Ut,Lt]=k(Bt,jt,zt,o,j.y)}{let zt=Ut,Bt=zt.clone().setY(0).normalize(),jt=new P(0,-1,0),Xt=Bt.clone().cross(jt);z(zt,Bt,jt,Xt)}B.concat(Lt);{let zt=w.angle(),Bt=Math.PI-zt,jt=_.clone();jt.y-=n/Math.sin(zt-Math.PI/2);let Xt=new P,Dt=[];for(let Wt=0;Wt<a;Wt++){let Qt=[],ee=Math.PI/2-Bt*Wt/a,$=Math.cos(ee),se=Math.sin(ee),Pe=yt;for(let Ve=0;Ve<=Wt;Ve++){let ie=Math.cos(Pe),oi=Math.sin(Pe);L.x=$*oi,L.y=se,L.z=$*ie,Xt.copy(jt).addScaledVector(L,n),u.push(Xt.x,Xt.y,Xt.z),h.push(L.x,L.y,L.z),d.push(0,0),Qt.push(c++),Pe+=2*Math.PI/Wt/i}Dt.push(Qt)}Lt.reverse(),Dt.push(Lt);let le=Dt.length-1;for(let Wt=0;Wt<le;Wt++){let Qt=Dt[Wt],ee=Dt[Wt+1],$=Qt.length-1;l.push(ee[1],Qt[0],ee[0]);for(let se=1;se<=$;se++)l.push(Qt[se],Qt[se-1],ee[se]),l.push(ee[se+1],Qt[se],ee[se])}}}}}function k(L,V,q,j,Q){let it=-j/2,at=(Math.PI-j)/2,St=V.clone().normalize().cross(q);L.addScaledVector(q,-n/Math.sin(at));let yt=new P,Y=new P,pt=c,xt=[];for(let Tt=0;Tt<=a;Tt++){let Mt=it+Tt/a*j;Y.set(0,0,0),Y.addScaledVector(St,Math.sin(Mt)),Y.addScaledVector(q,Math.cos(Mt));for(let _t=0;_t<=1;_t++){let kt=_t/1-.5;if(yt.copy(L),yt.addScaledVector(V,kt),yt.addScaledVector(Y,n),Q!=null){let Ut=Math.max(0,yt.y-Q);yt.addScaledVector(V,-Ut/V.y)}u.push(yt.x,yt.y,yt.z),h.push(Y.x,Y.y,Y.z),d.push(0,0),_t===0&&xt.push(c),c++}}for(let Tt=0;Tt<a;Tt++)for(let Mt=0;Mt<1;Mt++){let _t=pt+Mt+2*Tt,kt=_t+2,Ut=kt+1,Lt=_t+1;l.push(_t,kt,Lt),l.push(kt,Ut,Lt)}return[L.clone().addScaledVector(V,.5),xt]}function z(L,V,q,j){let Q=Math.PI/2,it=T.angle()-Q,at=[],St=new P,yt=new P;for(let pt=0;pt<=a;pt++){let xt=[],Tt=pt/a;for(let Mt=0;Mt<=pt;Mt++){let _t=((pt?Mt/pt:0)-.5)*v,kt=Math.cos(_t),Ut=Math.sin(_t),Lt=(Q+Math.atan(Math.tan(it)*kt))*Tt,zt=Math.cos(Lt),Bt=Math.sin(Lt);St.set(0,0,0),St.addScaledVector(V,Bt*kt),St.addScaledVector(q,zt),St.addScaledVector(j,Bt*Ut),yt.copy(L).addScaledVector(St,n),u.push(yt.x,yt.y,yt.z),h.push(St.x,St.y,St.z),d.push(0,0),xt.push(c++)}at.push(xt)}let Y=at.length-1;for(let pt=0;pt<Y;pt++){let xt=at[pt],Tt=at[pt+1],Mt=xt.length-1;l.push(xt[0],Tt[1],Tt[0]);for(let _t=1;_t<=Mt;_t++)l.push(xt[_t-1],xt[_t],Tt[_t]),l.push(xt[_t],Tt[_t+1],Tt[_t])}}this.setIndex(l),this.setAttribute("position",new fe(u,3)),this.setAttribute("normal",new fe(h,3)),this.setAttribute("uv",new fe(d,2))}}}),RR=G(()=>{_m(),fm(),L5=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},t.parameters),r=Object.assign(e?.ui??{enabledIndieCorners:!1},t.ui);return{shape:t.shape&&t.shape instanceof ds?t.shape:new ds,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)}),ui:r}}static build(t){let e=t.shape,{width:i,height:r,cornerRadius:s,cornerType:n,depth:a,extrudeBevelSize:o,extrudeBevelSegments:l}=t.parameters,u={x:.5*i,y:.5*r},h={x:-u.x,y:-u.y},d={x:u.x,y:u.y};function c(_,x,S){return x>i&&S>r?Math.min(_*i/x,_*r/S):x>i?_*i/x:S>r?_*r/S:_}let p=[];p[0]=s[0]===0?0:c(s[0],s[0]+s[3],s[0]+s[1]),p[1]=s[1]===0?0:c(s[1],s[1]+s[2],s[1]+s[0]),p[2]=s[2]===0?0:c(s[2],s[2]+s[1],s[2]+s[3]),p[3]=s[3]===0?0:c(s[3],s[3]+s[0],s[3]+s[2]);let m=h.x,f=d.x,g=d.y,y=h.y;e.addPoint(e.createPoint(m,g)),e.addPoint(e.createPoint(f,g)),e.addPoint(e.createPoint(f,y)),e.addPoint(e.createPoint(m,y)),e.isClosed=!0;let v=!0;for(let _=0,x=e.points.length;_<x;_++)e.points[_].roundness=p[_],_>0&&p[_]!==p[_-1]&&(v=!1);v&&(e.roundness=p[0]),e.useCubicForRoundedCorners=n!==1,e.update();let b=xm.create({shape:e,parameters:{depth:a,extrudeBevelSize:o,extrudeBevelSegments:l}});return Object.assign(b,{userData:{...t,type:"RectangleGeometry"}})}}}),cK=G(()=>{dt(),lgt=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180},t.parameters);return i.thetaLength=qt.clamp(i.thetaLength,0,180),{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(t){let e,{width:i=100,height:r=i,depth:s=i,widthSegments:n=64,heightSegments:a=64,phiStart:o,phiLength:l,thetaStart:u,thetaLength:h}=t.parameters;return h===0?(e=new ye,e.setAttribute("position",new fe([],3))):e=new Tc(.5*i,n,a,o,l,u,h*qt.DEG2RAD),e.scale(1,r/i,s/i),Object.assign(e,{userData:{...t,type:"SphereGeometry"}})}}}),pK=G(()=>{dt(),hgt=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},t.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:0})}}static build(t){let{width:e=100,height:i=e,widthSegments:r=8,heightSegments:s=8}=t.parameters,n=new Ac(e,i,r,s);return n.scale(1,1,1),Object.assign(n,{userData:{...t,type:"PlaneGeometry"}})}}}),mK=G(()=>{dt(),ugt=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},t.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(t){let{width:e,height:i,depth:r,angle:s,cornerRadius:n,cornerSegments:a}=t.parameters,o=new uK(e,i,r,s,n,a);return Object.assign(o,{userData:{...t,type:"BackdropGeometry"}})}},uK=class extends ye{constructor(t=1,e=1,i=1,r=90,s=10,n=24){super(),this.type="BackdropGeometry";let a=[],o=[],l=[],u=.001;s==0&&(n=1),n=Math.max(1,Math.floor(n)),s=Math.min(s,100),r=Math.min(180-u,r),r*=Math.PI/180;let h=[],d=Math.PI/2,c=(yt=0,Y=0,pt=0)=>new P(yt,Y,pt),p=c(),m=c(),[f,g,y]=[e/2,t/2,i/2],v=-g,b=+g,[_,x,S]=[c(v,-f,+y),c(v,-f,-y),c(v,+f,-y)],w=(yt,Y=!1)=>Math.sin(yt-Math.PI/(+Y+1)),T=(yt,Y=!1)=>Math.cos(yt-Math.PI/(+Y+1));S.y=Math.sin(r)*e-f;let A=Math.cos(r)*e-y,M=_.z-u;r<=d?(S.z=Math.min(A,M),S.z==M&&(S.y-=(A-M)/Math.tan(d-r))):x.z=Math.min(x.z-A-y,_.z-u),p.subVectors(_,x),m.subVectors(S,x);let C=Math.min(p.length(),m.length())*s/100,R=C*Math.tan(r/2),O=C/Math.cos(r/2),N=p.clone().normalize().add(m.normalize()).setLength(O).add(x);p.set(0,w(r,!0),T(r,!0)),h.push([S,p.clone()]);let B=(Math.PI-r)/n;for(let yt=0;yt<=n;yt++){let Y=d+r+yt*B;p.set(0,Math.sin(Y)*R,Math.cos(Y)*R),p.add(N),m.set(0,w(Y),T(Y)),h.push([p.clone(),m.clone()])}h.push([_,c(0,1,0)]);let k=Math.sin(B/2)*R*2,z=h.length-1,L=h[0][0].distanceTo(h[1][0]),V=L+k*n+h[z-1][0].distanceTo(h[z][0]);h[0].push(1);for(let yt=0;yt<=n;yt++)h[yt+1].push(1-(L+yt*k)/V);h[z].push(0);let q,j,Q,[it,at,St]=h[0];for(let yt=1;yt<h.length;yt++)[q,j,Q]=h[yt],a.push(v,it.y,it.z,v,q.y,q.z,b,it.y,it.z,b,it.y,it.z,v,q.y,q.z,b,q.y,q.z),o.push(0,at.y,at.z,0,j.y,j.z,0,at.y,at.z,0,at.y,at.z,0,j.y,j.z,0,j.y,j.z),l.push(0,St,0,Q,1,St,1,St,0,Q,1,Q),[it,at,St]=[q,j,Q];this.setAttribute("position",new fe(a,3)),this.setAttribute("normal",new fe(o,3)),this.setAttribute("uv",new fe(l,2))}}}),GU=G(()=>{_m(),fm(),DG=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},t.parameters);return{shape:t.shape&&t.shape instanceof ds?t.shape:new ds,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(t){let{width:e,height:i,innerRadiusPercent:r,spikes:s,cornerRadius:n,angle:a,depth:o,extrudeBevelSize:l,extrudeBevelSegments:u}=t.parameters,h=t.shape,d=.5*e,c=.5*i,p=a*Math.PI/360/s,m=Math.PI/2*3*-1,f=d*r/100,g=c*r/100;if(s===3&&r===50){p=2*Math.PI/s;for(let v=0;v<s;v++){let b=p*v,_=0+Math.sin(b)*d,x=0+Math.cos(b)*c;h.addPoint(h.createPoint(_,x))}}else for(let v=0;v<s;v++){let b=0+Math.cos(m)*d,_=0+Math.sin(m)*c;h.addPoint(h.createPoint(b,_)),m+=p,b=0+Math.cos(m)*f,_=0+Math.sin(m)*g,h.addPoint(h.createPoint(b,_)),m+=p}h.isClosed=!0;for(let v=0,b=h.points.length;v<b;v++)h.points[v].roundness=n;h.roundness=n,h.update();let y=xm.create({shape:h,parameters:{roundness:n,depth:o,extrudeBevelSize:l,extrudeBevelSegments:u}});return Object.assign(y,{userData:{...t,type:"StarGeometry"}})}}}),fK=G(()=>{dt(),dgt=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,depth:0},t.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(t){let{width:e,height:i}=t.parameters,r=new Ac(e,i);return Object.assign(r,{userData:{...t,type:"TextFrameGeometry"}})}}}),gK=G(()=>{dt(),NS(),cgt=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:360,cornerRadius:30,cornerSegments:8},t.parameters),r=Math.abs(i.width),s=Math.abs(i.height??i.width);i.shapeBlendNode&&(s=r);let n=Math.round(Math.abs(i.depth??.25*i.width));return{parameters:Object.assign(i,{width:r,height:s,depth:n})}}static build(t){let{width:e,height:i,depth:r,radialSegments:s,tubularSegments:n,arc:a,cornerRadius:o,cornerSegments:l}=t.parameters,u=function(h,d,c,p,m,f,g,y,v,b,_){[d,c]=[c,d],g=d/2;let x=qt.clamp(m/360,0,1);if(x===0){let S=new ye;return S.setAttribute("position",new fe([],3)),S}return x===1&&(b=0),new PU(!0,h,d,c,p,x,f,g,0,v,b,_)}(e,i,r,.5*e,a,n,0,0,s,o,l);return u.scale(1,i/e,1),Object.assign(u,{userData:{...t,type:"TorusGeometry"}})}}}),yK=G(()=>{dt(),pgt=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},t.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width),tube:i.tube??.125*i.width})}}static build(t){let{width:e,tube:i,tubularSegments:r,radialSegments:s,p:n,q:a}=t.parameters,o=.5*e;o!==i&&(o-=i);let l=new T8(o,i,r,s,n,a);return Object.assign(l,{userData:{...t,type:"TorusKnotGeometry"}})}}}),vK=G(()=>{_m(),fm(),mgt=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i=Object.assign({},e?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},t.parameters);return{shape:t.shape&&t.shape instanceof ds?t.shape:new ds,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width*(i.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(i.depth??0)})}}static build(t){let{width:e=100,height:i,cornerRadius:r,depth:s,extrudeBevelSize:n,extrudeBevelSegments:a,isRect:o}=t.parameters,l=t.shape,u=.5*e,h=.5*i;o?(l.addPoint(l.createPoint(-u,h)),l.addPoint(l.createPoint(u,-h)),l.addPoint(l.createPoint(-u,-h))):(l.addPoint(l.createPoint(0,h)),l.addPoint(l.createPoint(u,-h)),l.addPoint(l.createPoint(-u,-h))),l.isClosed=!0;for(let c=0,p=l.points.length;c<p;c++)l.points[c].roundness=r;l.roundness=r,l.update();let d=xm.create({shape:l,parameters:{roundness:r,depth:s,extrudeBevelSize:n,extrudeBevelSegments:a}});return Object.assign(d,{userData:{...t,type:"TriangleGeometry"}})}}}),w3t=G(()=>{dt()}),S3t=G(()=>{dt(),new ta,new bt,new pc,new P,new P,new P,new P});function bK(){let t=new ye;return t.setAttribute("position",new we(new Float32Array([]),3)),t.setIndex(new we(new Uint16Array([]),1)),t}var _K,WU,fgt=G(()=>{hn(),ke(),tT(),dt(),KS(),_m(),fm(),Kv(),_K=bK().attributes,WU=class extends ye{constructor(t,e){super(),this.isTextGeometry=!0,this.charWidths=[],this.charCoords=[],this.wrappedText=[],this.isLowResolution=!1,this.vectorShapes=[],this._nearSide=new Uint8Array(0),this._depth=0,this._effectiveBevel=0,this._vScale=0,Object.assign(this.attributes,_K),this.userData={parameters:t,type:"TextGeometry"};let i=e.getFont(t.font);i?.isLoaded?(this.font=i,this.update(t,e)):this.updateFont(t.font,e).then(()=>{this.update(t,e),e?.requestRender()})}async updateFont(t,e){let i=e.getFont(t);i&&(this.font=i,await i.loadingPromise)}update(t,e){let i=this.font;if(this.userData={parameters:t,type:"TextGeometry"},!i?.isLoaded)return void console.warn("Cannot update text because its font is not loaded");let{width:r,height:s,depth:n,extrudeBevelSize:a,extrudeBevelSegments:o,text:l,textTransform:u,fontSize:h}=t,d=Na.getDisplayedValue(l),c=function(x,S,w,T){let A=typeof x.width=="string"?Number(T.getVariable(x.width)):x.width,M=[""],C="";for(let R of w)C+=R,R===" "||R===`
|
|
352
352
|
`?(M[M.length-1]+=C,C="",R===`
|
|
353
|
-
`&&M.push("")):S.getTextWidth(M[M.length-1]+C,x)>A&&(M[M.length-1].length&&M.push(""),S.getTextWidth(M[M.length-1]+C,x)>A&&(C.length===1?(M[M.length-1]+=C,C=""):(M[M.length-1]+=C.slice(0,-1),C=C[C.length-1],M.push(""))));return M[M.length-1]+=C,M}(t,i,u===2?d.toUpperCase():u===3?d.toLowerCase():d,e),{shapes:p,charWidths:m,charCoords:f}=i.generateShapes(c,t,e),g=.5*(typeof r=="number"?r:Number(e.getVariable(r))),y=.5*(typeof s=="number"?s:Number(e.getVariable(s))),v=p.map(x=>new ds().fromShape(x,!0));this.vectorShapes=v;let b=v.map(x=>xm.create({shape:x,parameters:{depth:n,extrudeBevelSegments:o,extrudeBevelSize:a,uvPitch:h,windingRule:n<=0?ss.NONZERO:ss.ODD,subdivisions:this.isLowResolution&&n>0?1:12}})),_=b.length?wg(b):bK();_.translate(-g,y,0),this.dispose(),this.wrappedText=c,this.charCoords=f,this.charWidths=m,this.deleteAttribute("extrudeNormal"),Object.entries(_.attributes).forEach(([x,S])=>{this.setAttribute(x,S)}),this.setIndex(_.index),this.adoptNearSide(b,n),this.computeBoundingSphere()}adoptNearSide(t,e){this._depth=e;let i=0,r=0,s=0;for(let o of t){let l=o,u=l._nearSide;if(u===void 0||u.length===0)return this._nearSide=new Uint8Array(0),this._effectiveBevel=0,void(this._vScale=0);i+=u.length,r=Math.max(r,l._effectiveBevel??0),s=l._vScale??s}this._effectiveBevel=r,this._vScale=s;let n=new Uint8Array(i),a=0;for(let o of t){let l=o._nearSide;n.set(l,a),a+=l.length}this._nearSide=n}takeDepthStateFrom(t){let e=t;e._nearSide!==void 0&&(this._depth=e._depth??this._depth,this._nearSide=e._nearSide,this._vScale=e._vScale??this._vScale,this._effectiveBevel=e._effectiveBevel??this._effectiveBevel)}canShiftDepthTo(t){return this._nearSide.length===this.getAttribute("position")?.count&&X1(this._effectiveBevel,t)&&X1(this._effectiveBevel,this._depth)}shiftDepthTo(t){if(!this.canShiftDepthTo(t))return!1;let e=t-this._depth;if(this._depth=t,e===0)return!0;let i=this.getAttribute("position"),r=i.array,s=this.getAttribute("uv"),n=s?.array,a=this._vScale>0?e/this._vScale:0,o=this._nearSide;for(let l=0;l<o.length;l++){let u=o[l];u!==0&&(r[3*l+2]+=e,u===2&&n!==void 0&&(n[2*l+1]+=a))}return i.needsUpdate=!0,s!==void 0&&a!==0&&(s.needsUpdate=!0),this.refreshDepthBounds(t),!0}refreshDepthBounds(t){if(this.boundingBox===null&&this.boundingSphere===null)return;this.boundingBox===null&&this.computeBoundingBox();let e=this.boundingBox;e.min.z=Math.min(0,t),e.max.z=Math.max(0,t),this.boundingSphere!==null&&e.getBoundingSphere(this.boundingSphere)}clone(){let t=$a(new ye,WU.prototype);return t.copy(this),console.log("CloneGeometry",this,t),t}copy(t){return Object.entries(t.attributes).forEach(([e,i])=>{this.setAttribute(e,i)}),this.setIndex(t.index),this.userData={parameters:{...t.userData.parameters},type:"TextGeometry"},this}async setText(t,e){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:{textValue:t}},e)}get text(){return this.userData.parameters.text??""}}});function T3t(t){if(!qU)return xK||(xK=async function(){let e=t??"https://cdn.spline.design/@splinetool/runtime@2.0.60/build",i=import("./process.js"),[r,s]=await Promise.all([i,fetch(`${e}/process.wasm`).then(o=>o.arrayBuffer())]),n=r.default,a=await n({wasmBinary:s});ggt(a),qU=!0}())}var ggt,NG,qU,xK,F5=G(()=>{NG=new Promise(t=>{ggt=t}),qU=!1});function BO(t,e){if(Object.keys(t.morphAttributes).length>0||Object.keys(e.morphAttributes).length>0)return!1;let i=Object.keys(t.attributes),r=Object.keys(e.attributes);if(i.length!==r.length)return!1;for(let l of r){let u=t.attributes[l],h=e.attributes[l];if(u===void 0||u.isInterleavedBufferAttribute===!0||h.isInterleavedBufferAttribute===!0||u.itemSize!==h.itemSize||u.normalized!==h.normalized||u.array.constructor!==h.array.constructor||u.array.length!==h.array.length)return!1}let s=t.index,n=e.index;if(s===null!=(n===null))return!1;let a=!1;if(s!==null&&n!==null){if(s.array.length!==n.array.length)return!1;let l=s.array.constructor,u=n.array.constructor;if(l!==u){if(l!==Uint32Array||u!==Uint16Array)return!1;a=!0}}if(t.groups.length!==e.groups.length)return!1;for(let l=0;l<e.groups.length;l++){let u=t.groups[l],h=e.groups[l];if(u.start!==h.start||u.count!==h.count||u.materialIndex!==h.materialIndex)return!1}for(let l of r){let u=t.attributes[l],h=e.attributes[l];u.array.set(h.array),u.needsUpdate=!0}let o=t.takeDepthStateFrom;if(typeof o=="function"&&o.call(t,e),s!==null&&n!==null){if(a){let l=s.array,u=n.array;for(let h=0,d=u.length;h<d;h++){let c=u[h];l[h]=c===65535?4294967295:c}}else s.array.set(n.array);s.needsUpdate=!0}return t.drawRange.start=e.drawRange.start,t.drawRange.count=e.drawRange.count,t.userData=e.userData,t.boundingBox=null,t.boundingSphere=null,!0}function HU(t,e,i,r){let s,n,a,o=t.position.array,l=t.normal.array,u=ygt.makeScale(e,i,r).invert().elements;for(let h=0,d=o.length;h<d;h+=3)o[h]*=e,o[h+1]*=i,o[h+2]*=r,s=l[h],n=l[h+1],a=l[h+2],l[h]=u[0]*s+u[4]*n+u[8]*a,l[h+1]=u[1]*s+u[5]*n+u[9]*a,l[h+2]=u[2]*s+u[6]*n+u[10]*a;t.position.needsUpdate=!0,t.normal.needsUpdate=!0}var ygt,vgt=G(()=>{dt(),ygt=new bt});function $U(t){let e=Number(t);return Number.isInteger(e)&&e>=0&&String(e)===t?e:-1}function kM(t){if(t!=null){if(Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView))return t;if(typeof t=="object")return function(e){let i=Object.keys(e),r=0;for(let n of i){let a=$U(n);a>=r&&(r=a+1)}if(r===0||r>i.length)return;let s=new Array(r);for(let n=0;n<r;n++){let a=e[n];if(typeof a!="number")return;s[n]=a}return s}(t)}}function VO(t){if(t==null)return"missing";if(Array.isArray(t))return`Array(${t.length})`;if(ArrayBuffer.isView(t)){let l=t;return`${t.constructor.name}(${l.length})`}if(typeof t!="object")return typeof t;let e=Object.keys(t),i=e.filter(l=>$U(l)===-1),r=0;for(let l of e){let u=$U(l);u>=r&&(r=u+1)}let s=t,n=-1,a=-1;for(let l=0;l<r;l++)l in s?typeof s[l]!="number"&&a===-1&&(a=l):n===-1&&(n=l);let o=[`${e.length} keys`,"max index "+(r-1)];return n!==-1&&o.push(`first missing index ${n}`),a!==-1&&o.push(`non-number at ${a} (${typeof s[a]})`),i.length&&o.push(`stray keys ${i.slice(0,3).join(",")}`),`Object{${o.join(", ")}}`}function bgt(t){let e=Object.keys(t);return e.length===1&&e[0]==="subdivisions"}function OG(t,e){let i=e?e.count:t.count,r=0,s=1e4,n=new Map,a=new Uint32Array(i),o=[];for(let h=0;h<i;h++){let d=e?e.getX(h):h,c=t.getX(d),p=t.getY(d),m=t.getZ(d),f=Math.round(c*s),g=Math.round(p*s),y=Math.round(m*s),v=n.get(f);v===void 0&&(v=new Map,n.set(f,v));let b=v.get(g);b===void 0&&(b=new Map,v.set(g,b));let _=b.get(y);_===void 0&&(_=r++,b.set(y,_),o.push(c,p,m)),a[h]=_}let l=[],u=[];for(let h=0;h<a.length;h+=3)a[h]===a[h+1]||a[h]===a[h+2]||a[h+1]===a[h+2]||(l.push(a[h],a[h+1],a[h+2]),u.push(e?e.getX(h):h,e?e.getX(h+1):h+1,e?e.getX(h+2):h+2));return{positions:o,triIndices:l,triOriginals:u}}var h_,rf,Ie,kO,zO,LO,us,u_,zM,LM,FM,XU,kP,Zv=G(()=>{dt(),F5(),ke(),U5(),vgt(),NS(),h_=new pr,rf=new P,NG.then(t=>{Ie=t}),kO=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),zO=new Uint32Array([0,1,2,3]),LO=new Uint8Array([4]),us=class extends ye{constructor(t,e){super(),this.data=t,this.flatShading=e,this.subdivPointer=0,this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(t,e){this.freeSubdivPointer();let i=this.data.scaleBaked.map(a=>typeof a=="number"?a:1),r=hm.div(e.map(a=>typeof a=="number"?a:0),i);if(r.every(a=>a===1))return;this.subdividedGeometry&&HU(this.subdividedGeometry.attributes,...r),this.originalGeometry&&HU(this.originalGeometry.attributes,...r),this.data=t;let s=this.userData.parameters;this.userData.parameters={width:s.width*r[0],height:s.height*r[1],depth:s.depth*r[2]},this.originalGeometry.boundingSphere.center.multiply(rf.fromArray(r));let n=rf.set(s.width,s.height,s.depth).length();this.originalGeometry.boundingSphere.radius=n/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}mutateDirectlySubdivisions(t){this.freeSubdivPointer(),this.data=t;let e=t.phongAngle??35;this.flatShading&&(e=-1);let i=null;if(t.subdivisions>0){let s=0;try{s=us.allocate(t),i=us.buildRefined(s,t.subdivisions,e)}catch(n){console.error(n,t)}finally{s&&us.freeSubdivPointer(s)}}this.subdividedGeometry?.dispose(),this.subdividedGeometry=i??void 0,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=this.originalGeometry.boundingSphere);let r=this.userData.parameters;Object.assign(this,this.subdividedGeometry??this.originalGeometry),this.userData.parameters=r}rebuild(){let t,e,i;try{({originalGeometry:t,subdividedGeometry:e,subdivPointer:i}=us.build(this.data,void 0,!this.flatShading,void 0))}catch{t=new Zh(100,100,100),i=0}this.subdivPointer=i,this.originalGeometry=t,this.subdividedGeometry=e??void 0;let r=this.subdividedGeometry??this.originalGeometry;Object.assign(this,r),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(us.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let t=this.originalGeometry;t.boundingSphere===null&&(t.boundingSphere=new ta,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=t.boundingSphere));let e=t.attributes.position,i=t.boundingSphere.center;h_.setFromBufferAttribute(e),h_.getCenter(i),t.boundingSphere.radius=i.distanceTo(h_.max),isNaN(t.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),h_.getSize(rf);let r={width:rf.x,height:rf.y,depth:rf.z};return this.userData.parameters=r,r}static build(t,e,i,r){let s,n,a=t?.phongAngle??35;i===!1&&(a=-1),e&&(Ie.free_bvh(e),Ie.free_subdivision_surface(e));try{s=us.allocate(t,r)}catch(l){console.error(l,t),s=us.allocate({positionWASM:kO,indexWASM:zO,verticesPerFaceWASM:LO},r)}Ie.set_destination_refinement_level(s,0);let o=us.buildLevel(s,!0,a);return n=t.subdivisions>0?us.buildRefined(s,t.subdivisions,a):null,{subdivPointer:s,originalGeometry:o,subdividedGeometry:n}}static buildRefined(t,e,i){try{return Ie.set_destination_refinement_level(t,e),us.buildLevel(t,!1,i)??null}catch{try{return Ie.set_destination_refinement_level(t,e-1),us.buildLevel(t,!1,i)??null}catch{return null}}}static primitiveToQuads(t,e,i){t.widthSegments>16&&(t.widthSegments=16),t.heightSegments>16&&(t.heightSegments=16),t.depthSegments>16&&(t.depthSegments=16),t.radialSegments>16&&(t.radialSegments=16),t.type==="DodecahedronGeometry"&&(t.detail=0);let r,s=t.shape!==void 0||t.path!==void 0?e.geometry:im(t,i,!1,e);r=dft(t)?s.getClosedTorusIndicesForBooleanOrSubdiv():s.getIndex();let n,{positions:a,triIndices:o,triOriginals:l}=OG(s.getAttribute("position"),r);if(t.type==="CylinderGeometry"&&t.cornerRadius===0&&t.hollow===0&&t.openEnded===!1){let c=t.radialSegments*t.heightSegments*3*2;n=[c,c+3*t.radialSegments]}let{indices:u,verticesPerFace:h,uvs:d}=function(c,p,m,f,g){let y=[],v=[],b=g?m.getAttribute("uv"):void 0,_=b&&b.itemSize===2?[]:void 0,x=T=>{if(_){let A=g[T];_.push(b.getX(A),b.getY(A))}};if(m.userData.shape!==void 0&&m.userData.parameters.depth===0&&m.userData.shape.shapeHoles.length===0){let T=m.userData.shape.extractShapePointsToFlatArray([]),A=m.userData.parameters.spikes;if(m.userData.type==="EllipseGeometry"&&A<=24&&A%4==0&&m.userData.parameters.angle>=360){let R=T.length/2/A;T=T.filter((O,N)=>Math.floor(N/2)%R===0)}let M=0;for(let R=0;R<T.length;R+=2)M+=(T[R]-T[(R===0?T.length:R)-2])*(T[R+1]+T[(R===0?T.length:R)-1]);c.length=0;let C=0;if(M<0)for(let R=0;R<T.length;R+=2)c.push(T[R],T[R+1],0),y.push(C++);else for(let R=T.length-2;R>=0;R-=2)c.push(T[R],T[R+1],0),y.push(C++);return v.push(C),{indices:y,verticesPerFace:v}}let S=new Float32Array([m.userData.parameters.depth])[0],w=0;for(;w<p.length;){if(m.useNgonForTopBottomFaceDuringBake){let T=0;if((c[3*p[w]+2]===S||c[3*p[w]+2]===0)&&T++,(c[3*p[w+1]+2]===S||c[3*p[w+1]+2]===0)&&T++,(c[3*p[w+2]+2]===S||c[3*p[w+2]+2]===0)&&T++,T===3)break}if(p[w+1]===p[w+3]&&p[w+2]===p[w+5]||p[w+0]===p[w+3]&&p[w+2]===p[w+4]){u_.set(c[3*p[w]],c[3*p[w]+1],c[3*p[w]+2]),zM.set(c[3*p[w+1]],c[3*p[w+1]+1],c[3*p[w+1]+2]),LM.set(c[3*p[w+4]],c[3*p[w+4]+1],c[3*p[w+4]+2]),FM.set(c[3*p[w+5]],c[3*p[w+5]+1],c[3*p[w+5]+2]),zM.sub(u_).normalize(),LM.sub(u_).normalize(),FM.sub(u_).normalize();let T=zM.cross(LM).dot(FM),A=w;Math.abs(T)>.005||f&&f.some((M,C)=>C%2!=1&&A>=f[C]&&A<f[C+1])?(y.push(p[w],p[w+1],p[w+2]),x(w),x(w+1),x(w+2),v.push(3),w+=3):(y.push(p[w],p[w+1],p[w+4],p[w+5]),x(w),x(w+1),x(w+4),x(w+5),v.push(4),w+=6)}else y.push(p[w],p[w+1],p[w+2]),x(w),x(w+1),x(w+2),v.push(3),w+=3}if(m.useNgonForTopBottomFaceDuringBake){let T=[],A=[],M=0;for(let C=0,R=0;C<c.length;C+=3,R++)c[C+2]===0&&(T.push(R),M++),c[C+2]===S&&A.push(R);if(m.userData.parameters.extrudeBevelSize===0){let C=A[0];A[0]=A[1],A[1]=C}T.reverse(),y.push(...T,...A),v.push(M,M),_=void 0}return{indices:y,verticesPerFace:v,uvs:_}}(a,o,s,n,l);return{positions:a,indices:u,verticesPerFace:h,uvs:d}}static allocate(t,e){let i,r,s,n=[],a=[],o=kM(t.positionWASM),l=kM(t.indexWASM),u=kM(t.verticesPerFaceWASM);if(o&&o.length>0){if(!l?.length||!u?.length)throw new Error(`SubdivGeometry.allocate: unusable cage topology \u2014 positionWASM ${VO(t.positionWASM)}, indexWASM ${VO(t.indexWASM)}, verticesPerFaceWASM ${VO(t.verticesPerFaceWASM)}`);i=o,r=l,s=u;let w=kM(t.uvWASM);Ie.alloc_subdivision_surface_uvs&&w&&w.length===2*r.length&&(a=w)}else i=kO,r=zO,s=LO;let h=i.length,d=r.length,c=s.length,p=i.length+n.length+a.length,m=r.length+s.length,f=p*Float32Array.BYTES_PER_ELEMENT+m*Uint32Array.BYTES_PER_ELEMENT,g=p*Float32Array.BYTES_PER_ELEMENT,y=Ie._malloc(f);if(!y)throw new Error(`SubdivGeometry.allocate: wasm _malloc(${f}) failed`);let v,b=new Float32Array(Ie.HEAPF32.buffer,y,p),_=new Uint32Array(Ie.HEAPU32.buffer,y+g,m);b.set(i,0),b.set(n,i.length),b.set(a,i.length+n.length),_.set(r,0),_.set(s,r.length),t?.scaleBaked?.some(w=>w!==1)&&(v=new bt().makeScale(...t.scaleBaked.map(w=>typeof w=="number"?w:1))),e&&(v?v.premultiply(e):v=e);let x=y+(i.length+n.length)*Float32Array.BYTES_PER_ELEMENT,S=a.length?v?Ie.alloc_subdivision_surface_uvs2(y,h,y+g,d,y+g+r.length*Uint32Array.BYTES_PER_ELEMENT,c,x,a.length,v.elements):Ie.alloc_subdivision_surface_uvs(y,h,y+g,d,y+g+r.length*Uint32Array.BYTES_PER_ELEMENT,c,x,a.length):v?Ie.alloc_subdivision_surface2(y,h,y+g,d,y+g+r.length*Uint32Array.BYTES_PER_ELEMENT,c,v.elements):Ie.alloc_subdivision_surface(y,h,y+g,d,y+g+r.length*Uint32Array.BYTES_PER_ELEMENT,c);return Ie._free(y),S}static buildLevel(t,e,i,r,s,n=!1){let a=s?Ie.get_mesh_data2(t,e?Ie.Level.CONTROL:Ie.Level.REFINED,i,s.elements):Ie.get_mesh_data(t,e?Ie.Level.CONTROL:Ie.Level.REFINED,i),o=Ie.HEAPU32.subarray(a>>2,10+(a>>2)),l=o.subarray(4,8),u=0,h=Ie.HEAPU32[o[u]>>2],d=Ie.HEAPF32.subarray(h>>2,(h>>2)+l[u]);u++;let c=Ie.HEAPU32[o[u]>>2],p=Ie.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let m=Ie.HEAPU32[o[u]>>2],f=Ie.HEAPU32.subarray(m>>2,(m>>2)+l[u]);u++;let g,y=Ie.HEAPU32[o[u]>>2],v=Ie.HEAPU32.subarray(y>>2,(y>>2)+l[u]);if(u++,Ie.alloc_subdivision_surface_uvs){let _=o[9];if(_>0){let x=Ie.HEAPU32[o[8]>>2];g=Ie.HEAPF32.subarray(x>>2,(x>>2)+_)}}if(r===void 0){let _=new ye;if(_.setIndex(new om(v,1)),_.setAttribute("position",new fe(d,3)),_.setAttribute("normal",new fe(p,3)),g&&_.setAttribute("uv",new fe(g,2)),e){_.setAttribute("faceMap",new om(f,1));let x=new Float32Array(p.length/3*4).fill(0);_.setAttribute("color",new we(x,4))}return Ie.free_mesh_data(a),_.userData.type="SubdivGeometry",_}if(r.getAttribute("position").copyArray(d),r.getAttribute("normal").copyArray(p),r.attributes.position.needsUpdate=!0,r.attributes.normal.needsUpdate=!0,n){let _=r.getIndex();_!==null&&_.array.length===v.length&&(_.copyArray(v),_.needsUpdate=!0)}let b=r.getAttribute("uv");g&&b&&b.array.length===g.length&&(b.copyArray(g),b.needsUpdate=!0),Ie.free_mesh_data(a)}static freeSubdivPointer(t){Ie.free_bvh(t),Ie.free_subdivision_surface(t)}static buildControlCageWireframe(t,e,i){let r=Ie.get_wireframe_data_for_base_level(t),s=Ie.HEAPU32.subarray(r>>2,4+(r>>2)),n=s.subarray(2,4),a=0,o=Ie.HEAPU32[s[a]>>2],l=Ie.HEAPF32.subarray(o>>2,(o>>2)+n[a]);a++;let u=Ie.HEAPU32[s[a]>>2],h=Ie.HEAPU32.subarray(u>>2,(u>>2)+n[a]);if(e===void 0){let d=new ye;d.setAttribute("position",new fe(l,3));let c=new Float32Array(l.length);for(let p=0,m=l.length;p<m;)c[p++]=i.r,c[p++]=i.g,c[p++]=i.b;return d.setAttribute("color",new we(c,3)),d.setIndex(new om(h,1)),Ie.free_wireframe_data_for_base_level(r),d}e.getAttribute("position").copyArray(l),e.attributes.position.needsUpdate=!0,Ie.free_wireframe_data_for_base_level(r)}static updateCollabMesh(t,e,i){let r=e===0;r||Ie.set_destination_refinement_level(t,e);let s=i?Ie.get_topological_data2(t,r?Ie.Level.CONTROL:Ie.Level.REFINED,i.elements):Ie.get_topological_data(t,r?Ie.Level.CONTROL:Ie.Level.REFINED),n=Ie.HEAPU32.subarray(s>>2,8+(s>>2)),a=n.subarray(3,6),o=0,l=Ie.HEAPU32[n[o]>>2],u=new Float32Array(Ie.HEAPF32.subarray(l>>2,(l>>2)+a[o]));o++;let h=Ie.HEAPU32[n[o]>>2],d=new Uint32Array(Ie.HEAPU32.subarray(h>>2,(h>>2)+a[o]));o++;let c,p=Ie.HEAPU32[n[o]>>2],m=new Uint8Array(Ie.HEAPU32.subarray(p>>2,(p>>2)+a[o]));if(Ie.alloc_subdivision_surface_uvs){let f=n[7];if(f>0){let g=Ie.HEAPU32[n[6]>>2];c=new Float32Array(Ie.HEAPF32.subarray(g>>2,(g>>2)+f))}}return Ie.free_topological_data(s),{positions:u,indices:d,verticesPerFace:m,uvs:c}}},u_=new P,zM=new P,LM=new P,FM=new P}),_gt=G(()=>{LY(),FY(),MR(),UY(),PR(),NS(),aK(),oK(),lK(),jU(),dK(),RR(),cK(),pK(),mK(),GU(),fK(),gK(),yK(),vK(),fm(),Ii(),LY(),FY(),MR(),UY(),PR(),w3t(),NS(),aK(),oK(),lK(),jU(),dK(),RR(),cK(),pK(),mK(),GU(),fK(),gK(),yK(),vK(),fm(),S3t(),Hft(),fgt(),Zv(),F5(),k5(),Kv(),XU={ConeGeometry:Rft,CubeGeometry:Dft,CylinderGeometry:MG,DodecahedronGeometry:Nft,EllipseGeometry:z5,HelixGeometry:cft,IcosahedronGeometry:egt,LatheGeometry:igt,NonParametricGeometry:sgt,PolygonGeometry:RG,PyramidGeometry:ngt,RectangleGeometry:L5,SphereGeometry:lgt,PlaneGeometry:hgt,BackdropGeometry:ugt,StarGeometry:DG,TextFrameGeometry:dgt,TorusGeometry:cgt,TorusKnotGeometry:pgt,TriangleGeometry:mgt,VectorGeometry:xm},kP=t=>{let e=XU[t.type]??Qmt(t.type);if(e===void 0)throw new Error(`No geometry factory registered for "${t.type}" \u2014 was its feature compiled out of this runtime build?`);return e.create(t)}});function im(t,e,i,r){let s,n,a;t.type==="PathGeometry"?(n={...t,extrusion:{...t.extrusion}},a=[[],["extrusion"]]):(n={...t},a=[[]]);for(let u of a){let h=n;for(let d of u)h=h[d];for(s in h){let d=h[s];nX(d)&&!xgt.includes(s)&&(h[s]=e.getVariable(d,[r.uuid,"geometry",...u,s]),nX(h[s])&&(h[s]=1))}}let o,l={parameters:n,type:n.type};if(n.type==="PathGeometry"){l.path=n.path;let u=r.profileShape;u!==void 0&&(l.shapeData=u),l.ownerId=r.uuid}else if(n.type==="VectorGeometry"){let u=ds.createFromState(n.shape,n.width,n.height);l.shape=u,l.ownerId=r.uuid}else if(n.type==="NonParametricGeometry"){if(n.data.groups&&n.data.groups?.forEach(u=>u.materialIndex=Math.max(u.materialIndex??0,0)),l.geometry=new F7().parse(n),l.geometry.groups.length===0){let u=l.geometry;u.addGroup(0,Math.max(u.getIndex()?.count??0,u.getAttribute("position").count),0)}}else{if(n.type==="SubdivGeometry"){let u=new us(n,i);return u.data=t,u}if(n.type==="TextGeometry"||n.type==="InputGeometry"){let u=Qmt(n.type);if(u)return u.create(n,e);Nn("text",`a ${n.type}`);let h=ds.createFromState(PS.defaultData(),100,100);return kP({...n,shape:h,type:"VectorGeometry"})}if(n.type==="UIGeometry")return L5.create({parameters:{width:n.width,height:n.height,cornerRadius:n.cornerRadius,cornerType:n.cornerType}})}try{o=kP(l)}catch(u){console.error(u),console.error(`Error generating geometry with inputs: ${l}`);let h=ds.createFromState(PS.defaultData(),100,100);l.shape=h,l.type="VectorGeometry",o=kP(l)}return o}var xgt,wK,YU,U5=G(()=>{ke(),dt(),_gt(),Ii(),RR(),_m(),Zv(),xgt=["font"]}),M3t=G(()=>{U5(),wK=class{constructor(){this.objects=new Map,this.unreachable=new Set}getCached(t){return this.objects.get(t)}get size(){return this.objects.size}get(t,e,i){let r=this.objects.get(t);return r===void 0?(r=this.createObject(t,e,i),this.objects.set(t,r)):r.isShared=!0,r}forceDelete(t){let e=this.objects.get(t);e&&(this.disposeObject(e),this.objects.delete(t))}adopt(t,e){this.objects.set(t,e)}mutateIfUnique(t,e){let i=this.objects.get(t);if(i&&i.isShared!==!0)return this.objects.delete(t),this.objects.set(e,i),i}startGc(){this.unreachable=new Set(this.objects.keys())}markAsReachable(t,e){e===this.objects.get(t)&&this.unreachable.delete(t)}endGc(){this.unreachable.forEach(t=>{this.disposeObject(this.objects.get(t)),this.objects.delete(t)}),this.unreachable.clear()}dispose(){this.objects.forEach(t=>{this.disposeObject(t)}),this.objects.clear()}},YU=class extends wK{constructor(t){super(),this.flatShading=t}disposeObject(t){t.dispose()}createObject(t,e,i){let r=im(t,e,this.flatShading,i);return r.computeBoundingSphere(),r}}});function DR(){return iT}function wgt(){if(iT==="webgpu"){if(ZU!==void 0)return ZU;QU||(QU=!0,console.warn('[spe] Material backend is "webgpu" but no TSL material factory is registered \u2014 import spe/src/renderer/webgpu before creating materials. Falling back to WebGL materials.'))}if(MK===void 0)throw new Error('[spe] Classic (WebGL) materials are not available in this build \u2014 it was compiled WebGPU-only. Re-export the scene with renderer "Both" or "WebGL 2", or load the full runtime.');return MK}function Sgt(t,e){return wgt().createRootMaterial(t,e)}function SK(t,e,i){return wgt().createSharedMaterial(t,e,i)}function TK(t){return t.getLayersOfType===void 0&&Object.assign(t,{layers:[],getLayersOfType:()=>[],hasAO:!1,assetsLoaded:()=>!0}),t}function KU(){return Tgt}var iT,ZU,MK,QU,JU,Tgt,Mgt,wm=G(()=>{iT="webgl",QU=!1}),A3t=G(()=>{Mgt={markNeedsUpdateRendererDirty:()=>{}}});function Eg(t,e){let i=0;if(!t.layers||t.layers.length===0)return!1;let r=t.layers?.find(s=>s.data.type==="light");if(r){let s=r.data,n=Number(e.getVariable(s.alphaOverride));if((typeof s.alphaOverride=="string"?n/100:s.alphaOverride)<1)return!0}for(let s of t.layers){if(s.data.type!=="displace"&&s.data.isMask)return!0;if(s.data.type!=="displace"&&"alpha"in s.data&&s.data.type!=="light"&&s.data.type!=="fresnel"&&s.data.type!=="cavity"&&s.data.type!=="dust"&&s.data.type!=="texture"&&s.data.type!=="matcap"&&s.data.type!=="rainbow"&&s.data.type!=="outline"&&s.data.type!=="pattern"){let n=s.data.visible?s.data.alpha:0;if(typeof n=="string"&&(n=Math.max(0,Math.min(1,Number(e.getVariable(n)??100)/100))),n===1&&s.data.type==="depth"||s.data.type==="gradient"){for(let a of s.data.colors)if(a[3]<1){n=a[3];break}}else if(n===1&&s.data.type==="noise"){let a=e.color(s.data.colorA).a,o=e.color(s.data.colorB).a,l=e.color(s.data.colorC).a,u=e.color(s.data.colorD).a,h=Math.min(a,Math.min(o,Math.min(l,u)));h<1&&(n=h)}i+=(1-i)*n}}return i<1}var IG=G(()=>{});function mv(t){return typeof t=="string"||typeof t=="number"&&t!==0}var Iv,Mn,rT,Agt,AK,CK,_l,Qv=G(()=>{Iv=(t,e,i)=>Math.max(0,Math.min(1,Number(e.getVariable(typeof t=="number"?100*t:t,i)??100)/100))??1,Mn=(t,e,i)=>typeof t=="number"?t:e.getVariable(t,i),rT={noise:["noiseType"],texture:["projection","axis","projectionAxis","side"],video:["projection","axis","projectionAxis","side"],displace:["noiseType"],light:["roughnessMap","bumpMap","roughnessMapChannel","metalnessMap","metalnessMapChannel","normalMap","aoMap","aoMapChannel","emissiveMap"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"],reflection:["tracingMode","mirror"]},Agt={depth:["colors"],gradient:["colors","steps"],toon:["colors","steps"]}}),Jv=G(()=>{dt(),JS(),AK=class extends I5(dr){},CK=t=>t.type==="Mesh",_l=class extends AK{constructor(t){super(),this.object=t,this.isClone=!0,this.matrixAutoUpdate=!1,this.hasNonUniformScale=t.hasNonUniformScale}raycast(t,e){}expand(){let t=0,e=this.object.entityChildren(t);for(;e;){let i=this.children[t];i?.object!==e&&(i&&this.remove(i),i=new _l(e),this.add(i),this.children.splice(t,0,this.children.pop()),i.matrixWorldNeedsUpdate=!0,i.matrixAutoUpdate=!1,i.matrix=e.matrix,i.hiddenMatrix=e.hiddenMatrix,i.pivotMatrix=e.pivotMatrix),i.expand(),t+=1,e=this.object.entityChildren(t)}for(;this.children.length>t;)this.remove(this.children[t]);this.pivotMatrix=this.object.pivotMatrix}get visible(){let t=this.object.cloner;return(t===void 0||this.parent!==t||!t.instancingActive&&!t.insideBoolean)&&(this.playModeVisible!==void 0?this.playModeVisible:this.object.visible||this.object.dataPatched.visible&&this.object.dataPatched.cloner?.hideBase===!0)}set visible(t){}get castShadow(){return this.object.castShadow}set castShadow(t){}get receiveShadow(){return this.object.receiveShadow}set receiveShadow(t){}get isMesh(){return CK(this.object)}get isLight(){return this.object.isLight}get layers(){return this.object.layers}set layers(t){}get isCamera(){return!1}get geometry(){if(this.object.geometry)return this.object.geometry}get material(){if(this.object.material)return this.object.material}get morphTargetInfluences(){if(this.object.morphTargetInfluences)return this.object.morphTargetInfluences}set morphTargetInfluences(t){}}});function EK(){return BG}var BG,VG,kG=G(()=>{BG=null,VG=null});function tj(t){return"variable_"+t}var FO,UO,jO,PK,GO,RK,WO,DK,NR,zG=G(()=>{ke(),JMt(),Mft(),Aft(),Rc(),wG(),TG(),M3t(),wm(),wft(),A3t(),IG(),Qv(),vo(),Jv(),Fi(),dt(),kG(),Ii(),FO=new bt,UO=new P,jO=new Me,PK=new P,GO=new Qi,RK=class extends bft{constructor(t){super(),this.shared=t}create(t){return new xG(t,this.shared)}},WO=new Set,(NR=DK=class{constructor(t,e={},i=!0,r=!1){if(this.data=t,this.needsJitter=i,this.enableLocalStorageForPersistentVariables=r,this.geometryCache=new YU(!0),this.geometryCache2=new YU(!1),this.imageHolderCache=new RK(this),this.thisContext={scene:Mgt,shared:this},this.deletedImage=new pg(mU.emptyImage,this),this.deletedVideo=new pg(oR.defaultVideo,this),this.materials={},this.images={},this.uiBuffers={},this.videos={},this.colors={},this.audios={},this.particles={},this.fonts={},this.variables={},this.userAPIs={},this.userWebhooks={},this.mouseProperty=null,this.raycastProperty=null,this.requestRender=()=>{this._requestRender&&this._requestRender()},this.transientGeometryKeys=new WeakSet,e.images)for(let[s,n]of Object.entries(e.images))this.addImage(s,n);if(e.videos)for(let[s,n]of Object.entries(e.videos))this.addVideo(s,n);if(e.audios)for(let[s,n]of Object.entries(e.audios))this.addAudio(s,n);if(e.particles)for(let[s,n]of Object.entries(e.particles))this.addParticle(s,n);this.reset(t)}get deletedMaterial(){return this._deletedMaterial??(this._deletedMaterial=SK(cs.defaultTwoLayerData("phong"),this.thisContext,"")),this._deletedMaterial}setRequestRender(t){this._requestRender=t}getImageLoadPromises(){return Object.values(this.images).map(t=>t.loadPromise)}setEntityOpContext(t){this.entityOpContext=t}reset(t,e=!1,i=!1){this.data=t,this.resetLib(t.lib);for(let{id:r,data:s}of t.variables)this.addVariableHolder(r,s),e&&this.updateVariableHolder(r,s);for(let[r,s]of Object.entries(t.userAPIs??{}))this.addUserAPI(r,s);for(let[r,s]of Object.entries(t.userWebhooks??{}))this.addUserWebhook(r,s);if(!i){for(let[r,s]of Object.entries(t.images))this.addImage(r,s);for(let[r,s]of Object.entries(t.videos))this.addVideo(r,s)}for(let[r,s]of Object.entries(t.colors))this.addColor(r,s);for(let[r,s]of Object.entries(t.lib.materials))this.addMaterial(r,s.asset);for(let[r,s]of Object.entries(t.materials))this.addMaterial(r,s);for(let[r,s]of Object.entries(t.audios))this.addAudio(r,s);for(let[r,s]of Object.entries(t.particles))this.addParticle(r,s);for(let[r,s]of Object.entries(t.fonts))this.addFont(r,s)}addMaterial(t,e){if(e.layers===void 0&&(e={...e,layers:cs.defaultTwoLayerData("phong").layers}),this.materials[t]){let i=this.materials[t];i.reset(e,this.thisContext),i.dispose()}else{let i=SK(e,this.thisContext,t);this.materials[t]=i}}deleteMaterial(t){this.materials[t]&&(this.materials[t].nodeMaterialDispose(),delete this.materials[t])}getMaterial(t){return this.materials[t]}getMaterialOrDeletedPlaceholder(t){return this.materials[t]??this.deletedMaterial}material(t){return typeof t=="string"?this.getMaterialOrDeletedPlaceholder(t):t==null?(console.error("material is undefined or null"),this.deletedMaterial):(t.layers===void 0&&(t={...t,layers:cs.defaultTwoLayerData("phong").layers}),Sgt(t,this.thisContext))}getMaterials(){return this.materials}addImage(t,e){return this.images[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.images[t].updateSrc(e.data),!0):(this.images[t]=new pg(e,this),!1)}deleteImage(t){let e=this.images[t];e&&(e.dispose(),delete this.images[t])}getDefaultImage(){return this.images.image_0}getImage(t){return this.images[t]??this.deletedImage}image(t){return typeof t=="string"?this.getImage(t):this.imageHolderCache.load(t)}addUIBuffer(t,e){return this.uiBuffers[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.uiBuffers[t].updateSrc(e),!0):(this.uiBuffers[t]=new pg(e,this),!1)}uiBuffer(t){return this.uiBuffers[t]}getEntityTexture(t,e={}){let i=t.material;if(!i)return null;for(let r of Array.isArray(i)?i:[i]){let s=r.root??r;for(let n of s?.data?.layers??[]){let a=n?.data;if(a?.type!=="texture"&&a?.type!=="matcap"||e.layer!==void 0&&n.id!==e.layer&&a.type!==e.layer)continue;let o=a.texture?.image;if(o==null)continue;let l=(typeof o=="string"?this.uiBuffer(o):void 0)??this.image(o);if(!l)continue;let u=l.getTexture(a.texture.wrapping??(a.type==="texture"?1e3:1001),a.texture.minFilter??1008,a.texture.magFilter??1006),h=l.img;return{texture:u,width:h?.width??0,height:h?.height??0,layerId:n.id,layerType:a.type}}}return null}addVideo(t,e){return this.videos[t]?(this.videos[t].updateSrc(e.data),!0):(this.videos[t]=new pg(e,this),!1)}deleteVideo(t){let e=this.videos[t];e&&(e.dispose(),delete this.videos[t])}getVideo(t){return this.videos[t]??this.deletedVideo}video(t){return typeof t=="string"?this.getVideo(t):this.imageHolderCache.load(t)}addColor(t,e){return this.colors[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),"a"in e?this.colors[t].setRGBA(e.r,e.g,e.b,e.a):this.colors[t].setRGBA(e.r,e.g,e.b,1),!0):(this.colors[t]=new NU(e.r,e.g,e.b,"a"in e?e.a:1),!1)}updateColor(t,e){if(this.colors[t]){this.onColorOrImageUpdate&&this.onColorOrImageUpdate();let i=this.colors[t];return this.colors[t].r=e.r??i.r,this.colors[t].g=e.g??i.g,this.colors[t].b=e.b??i.b,this.colors[t].a=e.a??i.a,!0}return!1}deleteColor(t){this.colors[t]&&delete this.colors[t]}getColor(t){return this.colors[t]}getColorNames(){return Object.values(this.data.colors).map(t=>t.name)}getColorByName(t){for(let e in this.data.colors)if(this.data.colors[e].name===t)return{color:this.colors[e],id:e}}color(t){let e;if(typeof t!="string")return new Dr(t.r,t.g,t.b,"a"in t?t.a:1);{let i=this.getColor(t);i?e=i:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),e=new Dr(0,0,0,0))}return e}addAudio(t,e){this.audios[t]=e}getAudio(t){let e=this.audios[t];if(e instanceof $1)return e;{let i=new $1({src:e.data});return this.audios[t]=i,i}}addParticle(t,e){this.particles[t]=e}getParticle(t){return this.particles[t]}deleteParticle(t){this.particles[t]&&delete this.particles[t]}deleteAudio(t){let e=this.audios[t];e&&(e instanceof $1&&e.dispose(),delete this.audios[t])}addFont(t,e){let i=SG;i!==null?(this.fonts[t]=new i(e),this.fonts[t].loadingPromise.then(()=>this.requestRender())):Nn("text","a font asset")}getFont(t){return this.fonts[t]}deleteFont(t){this.fonts[t]&&delete this.fonts[t]}dispose(){Object.keys(this.materials).forEach(t=>this.deleteMaterial(t)),this._requestRender=void 0,Object.values(this.audios).forEach(t=>{t instanceof $1&&t.dispose()}),this.audios={},this.particles={},this.geometryCache.dispose(),this.geometryCache2.dispose()}addVariableHolder(t,e){if(this.variables[t]===void 0){let i=e.value;if(this.enableLocalStorageForPersistentVariables&&e.persistent){let r=localStorage.getItem(tj(t));i=r!==null?JSON.parse(r):e.value}return this.variables[t]={value:i,locations:[],persistent:e.persistent},"dynamicVariableType"in e&&(this.variables[t].dynamicVariablePlayState="Playing",this.variables[t].dynamicVariableToggleIsForward=void 0),!0}return this.variables[t].value=e.value,!1}resetDynamicVariablePlayState(){for(let t in this.variables)this.variables[t].dynamicVariablePlayState!==void 0&&(this.variables[t].dynamicVariablePlayState="Playing",this.variables[t].dynamicVariableToggleIsForward=void 0)}updateVariableHolder(t,e){this.updateVariable(t,e.value)}updateVariable(t,e){if(this.variables[t]===void 0)return!1;this.variables[t].value=e,this.enableLocalStorageForPersistentVariables&&this.variables[t].persistent&&localStorage.setItem(tj(t),JSON.stringify(e));let i=e;for(;typeof i=="string";)i=this.variables[i].value;let r=this.entityOpContext.scene,s=!1;for(let n=this.variables[t].locations.length-1;n>=0;n--){let a=this.variables[t].locations[n];if(a[0]==="material"){let o=a[1],l=i,u={scene:r,shared:this},h=a.slice(2);r.traverseMaterial(c=>{let p=c.root??c;p.uuid===o&&p.onVariableUpdate(h,l,u)});let d=this.materials[o];d&&d.onVariableUpdate(h,l,u)}else{let o=r.find(a[0]);if(o===void 0){this.variables[t].locations.splice(n,1);continue}if(s=!0,a[1]!=="geometry"&&a[1]!=="particles"){for(let l=1;l<a.length-1;l++)o=o[a[l]];a[1]==="rotation"?o[a[a.length-1]]=i*qt.DEG2RAD:o[a[a.length-1]]=i}if(o=r.find(a[0]),o.type==="ParticleEmitter"&&o.updateVariableState(i,a),Mi.is(o))if(a[1]==="position"||a[1]==="rotation"||a[1]==="scale")o.onVariableUpdate();else if(a[1]==="geometry"){let l=o;o.component&&(l=o.component);let u=l.dataPatched;l.chooseGeoemtryCache(this).forceDelete(u.geometry),l.createGeometryDelayed(this.entityOpContext),l.onVariableUpdate(!0),l.invalidateDownstreamBooleanData(),l.instances.forEach(h=>{let d=h.dataPatched;h.chooseGeoemtryCache(this).forceDelete(d.geometry),h.createGeometryDelayed(this.entityOpContext),h.onVariableUpdate(!0),h.invalidateDownstreamBooleanData()})}else a[1]==="morphTargetInfluences"&&o.updateMorphInfluences(a[2],i)}}return s&&r.markShadowsDirty(),this.requestRender(),!0}updateEntityGeometryParams(t,e){let i=t;if(i.component&&(i=i.component),typeof i.chooseGeoemtryCache!="function")return!1;let r=i.dataPatched,s=r?.geometry;if(!s||typeof s.type!="string"||s.type==="VectorGeometry"||s.type==="PathGeometry")return!1;let n=u=>u.toLowerCase().replace(/[\s_.-]+/g,""),a=new Map;for(let u of Object.keys(s))a.set(n(u),u);let o={};for(let[u,h]of Object.entries(e??{})){let d=a.get(n(u));if(d===void 0||d==="type"||d==="font"||d==="shape"||d==="path"||d==="data")continue;if(d==="text"){(typeof h=="string"||typeof h=="number")&&(o[d]={textValue:String(h)});continue}let c=s[d];typeof h=="number"&&isFinite(h)&&(typeof c=="number"||typeof c=="string")&&(o[d]=h)}if(Object.keys(o).length===0)return!1;let l={...s,...o};return i.dataPatched={...r,geometry:l},this.transientGeometryKeys.has(s)&&i.chooseGeoemtryCache(this).forceDelete(r.geometry),this.transientGeometryKeys.add(l),i.createGeometryDelayed(this.entityOpContext),i.onVariableUpdate(!0),i.invalidateDownstreamBooleanData(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),!0}resetEntityGeometryParams(t){let e=t;if(e.component&&(e=e.component),typeof e.chooseGeoemtryCache!="function")return!1;let i=e.dataPatched?.geometry;return!(!i||!this.transientGeometryKeys.has(i)||(e.dataPatched=e.data,e.chooseGeoemtryCache(this).forceDelete(i),e.createGeometryDelayed(this.entityOpContext),e.onVariableUpdate(!0),e.invalidateDownstreamBooleanData(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),0))}updateEntityGeometryVertices(t,e){let i=t;if(i.component&&(i=i.component),typeof i.chooseGeoemtryCache!="function")return!1;let r=i.dataPatched,s=r?.geometry;if(!s||s.type!=="NonParametricGeometry")return!1;let n=e?.vertices;if(n===void 0||typeof n.length!="number"||n.length<9||n.length%3!=0||n.length/3>DK.MAX_TRANSIENT_VERTICES)return!1;let a,o,l,u=n instanceof Float32Array?n:Float32Array.from(n),h=u.length/3;if(e.normals!==void 0){if(e.normals.length!==u.length)return!1;a=e.normals instanceof Float32Array?e.normals:Float32Array.from(e.normals)}if(e.uvs!==void 0){if(e.uvs.length!==2*h)return!1;o=e.uvs instanceof Float32Array?e.uvs:Float32Array.from(e.uvs)}if(e.indices!==void 0){let x=h>65535?Uint32Array.from(e.indices):Uint16Array.from(e.indices);if(x.length===0||x.length%3!=0)return!1;for(let S=0;S<x.length;S++)if(x[S]>=h)return!1;l={array:x,itemSize:1,type:x.constructor.name,normalized:!1}}else{let x=s.data,S=x?.index;if(S?.array?.length){let w=(x?.attributes?.position?.array?.length??0)/3;if(h!==w)return function(T,A){let M=`${T}/${A}`;WO.has(M)||(WO.add(M),console.warn(`[spline] updateObject: ignoring a geometry update of ${T} vertices for a mesh that holds ${A}. Without \`indices\` the write is taken as a morph of the mesh's own vertices, which only means anything at the same count \u2014 send \`indices\` alongside \`vertices\` to replace the topology too.`))}(h,w),!1;l=S}}let d=1/0,c=1/0,p=1/0,m=-1/0,f=-1/0,g=-1/0;for(let x=0;x<u.length;x+=3){let S=u[x],w=u[x+1],T=u[x+2];S<d&&(d=S),S>m&&(m=S),w<c&&(c=w),w>f&&(f=w),T<p&&(p=T),T>g&&(g=T)}let y=(x,S)=>({array:x,itemSize:S,type:"Float32Array",normalized:!1}),v={position:y(u,3)};a&&(v.normal=y(a,3)),o&&(v.uv=y(o,2));let b={...s,width:m-d,height:f-c,depth:g-p,data:{attributes:v,...l?{index:l}:{}}},_=this.transientGeometryKeys.has(s);return i.dataPatched={...r,geometry:b},this.transientGeometryKeys.add(b),i.applyTransientGeometryData(this.entityOpContext,_),i.onVariableUpdate(!0),i.invalidateDownstreamBooleanData(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),!0}setEntityInstanceTransforms(t,e){let i=t;i.component&&(i=i.component);let r=i.cloner;if(r===void 0)return-1;let s=r.children,n=Math.PI/180,a=!1;if(e===null)for(let o of s)o.transformOverride!==void 0&&(o.transformOverride=void 0,a=!0);else{if(!Array.isArray(e))return s.length;{let o=Math.min(e.length,s.length);for(let l=0;l<o;l++){let u=e[l],h=s[l];if(u==null){h.transformOverride!==void 0&&(h.transformOverride=void 0,a=!0);continue}let d=h.transformOverride??{position:[h.position.x,h.position.y,h.position.z],rotation:[h.rotation.x,h.rotation.y,h.rotation.z],scale:[h.scale.x,h.scale.y,h.scale.z]};u.position&&(typeof u.position.x=="number"&&(d.position[0]=u.position.x),typeof u.position.y=="number"&&(d.position[1]=u.position.y),typeof u.position.z=="number"&&(d.position[2]=u.position.z)),u.rotation&&(typeof u.rotation.x=="number"&&(d.rotation[0]=u.rotation.x*n),typeof u.rotation.y=="number"&&(d.rotation[1]=u.rotation.y*n),typeof u.rotation.z=="number"&&(d.rotation[2]=u.rotation.z*n)),u.scale&&(typeof u.scale.x=="number"&&(d.scale[0]=u.scale.x),typeof u.scale.y=="number"&&(d.scale[1]=u.scale.y),typeof u.scale.z=="number"&&(d.scale[2]=u.scale.z)),h.transformOverride=d,h.position.fromArray(d.position),h.rotation.fromArray(d.rotation),h.scale.fromArray(d.scale),h.updateMatrix(),h.hasNonUniformScale&&(h.updateMatrixWorld(),h.updateMatrixWorldRigid())}}}return a?r.update(this.entityOpContext):r.syncInstanceMatrices(),r.invalidateTransform(i),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),s.length}spawnRuntimeClone(t,e={}){if(typeof t.entityChildren!="function")return;let i=t.parent;if(i===null)return;let r=new _l(t);r.playModeVisible=e.visible!==!1,r.expand(),typeof e.name=="string"&&(r.name=e.name);let s=Math.PI/180;return r.position.copy(t.position),r.rotation.copy(t.rotation),r.scale.copy(t.scale),r.hiddenMatrix.copy(t.hiddenMatrix),e.position&&(typeof e.position.x=="number"&&(r.position.x=e.position.x),typeof e.position.y=="number"&&(r.position.y=e.position.y),typeof e.position.z=="number"&&(r.position.z=e.position.z)),e.rotation&&(typeof e.rotation.x=="number"&&(r.rotation.x=e.rotation.x*s),typeof e.rotation.y=="number"&&(r.rotation.y=e.rotation.y*s),typeof e.rotation.z=="number"&&(r.rotation.z=e.rotation.z*s)),e.scale&&(typeof e.scale.x=="number"&&(r.scale.x=e.scale.x),typeof e.scale.y=="number"&&(r.scale.y=e.scale.y),typeof e.scale.z=="number"&&(r.scale.z=e.scale.z)),r.updateMatrix(),i.add(r),r.updateWorldMatrix(!0,!0),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),r}destroyRuntimeClone(t){t.removeFromParent(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender()}updateEntityMaterialParams(t,e){let i=t.material;if(!i)return!1;let r=[];for(let u of Array.isArray(i)?i:[i]){let h=u.root??u;h&&Array.isArray(h.layers)&&h.data&&!r.includes(h)&&r.push(h)}if(r.length===0)return!1;let s={scene:this.entityOpContext.scene,shared:this},n=u=>u.toLowerCase().replace(/[\s_.-]+/g,""),a=u=>{if(typeof u=="string"){let h=new Dr(1,1,1,1);try{h.set(u)}catch{return null}return{r:h.r,g:h.g,b:h.b,a:void 0}}if(u&&typeof u=="object"&&"r"in u){let h=u;if([h.r,h.g,h.b].some(c=>typeof c!="number"||!isFinite(c)))return null;let d=Math.max(h.r,h.g,h.b)>1?1/255:1;return{r:h.r*d,g:h.g*d,b:h.b*d,a:typeof h.a=="number"?Math.max(0,Math.min(h.a,1)):void 0}}return null},o=(u,h,d)=>{if(!u.hasValue(h))return!1;let c=u.getValue(h);if(!c||typeof c!="object"||!c.isColor)return!1;let p=d.a??(typeof c.a=="number"?c.a:1);return c instanceof NU?u.setValue(h,new Dr(d.r,d.g,d.b,p)):typeof c.setRGBA=="function"?c.setRGBA(d.r,d.g,d.b,p):c.setRGB(d.r,d.g,d.b),!0},l=!1;for(let u of r){let h=u.data.layers??[],d=c=>u.layers.find(p=>p.uuid===c);if(e.color!==void 0){let c=a(e.color),p=h.find(f=>f.data.type==="color"),m=p&&d(p.id);if(c&&m&&o(m,"color",c)&&(l=!0,c.a!==void 0)){let f=c.a<1||Eg(u.data,this);u.setTransparent?u.setTransparent(f,s.scene):u.transparent=f}}typeof e.alpha=="number"&&isFinite(e.alpha)&&(u.onVariableUpdate?.(["alphaOverride"],Math.max(0,Math.min(e.alpha,100)),s),l=!0);for(let c of e.layers??[]){if(!c||typeof c!="object")continue;let p=typeof c.id=="string"?h.find(y=>y.id===c.id):typeof c.index=="number"?h[c.index]:typeof c.type=="string"?h.find(y=>y.data.type===c.type):void 0,m=p&&d(p.id);if(!p||!m)continue;let f=rT[p.data.type]??[],g=Object.keys(p.data);for(let[y,v]of Object.entries(c)){if(y==="id"||y==="index"||y==="type")continue;let b=g.find(x=>x===y)??g.find(x=>n(x)===n(y))??y;if(f.includes(b))continue;let _=a(v);if(_&&o(m,b,_))l=!0;else if(typeof v=="number"&&isFinite(v))u.onVariableUpdate?.(["layer",p.id,b],v,s),l=!0;else if(Array.isArray(v)&&v.length<=3&&v.every(x=>typeof x=="number"&&isFinite(x))){let x=["x","y","z"];v.forEach((S,w)=>{u.onVariableUpdate?.(["layer",p.id,b,x[w]],S,s)}),l=!0}}}}return l&&this.requestRender(),l}deleteVariable(t){this.variables[t]&&delete this.variables[t]}getVariable(t,e){if(Array.isArray(t)){if(t[0]==="mouse")return this.mouseProperty?.[t[1]]??0;if(t[0]==="raycast")return this.raycastProperty?.[t[1]]??0;let i=this.entityOpContext.scene.find(t[0]);if(t[1]==="width"||t[1]==="height"||t[1]==="depth")return i.geometry.userData.parameters[t[1]];if((t[1]==="position"||t[1]==="rotation")&&t.length>2&&i?.getPhysicsLocalMatrix?.(FO))return FO.decompose(UO,jO,PK),t[1]==="position"?UO[t[2]]:(GO.setFromQuaternion(jO,i.rotation.order),GO[t[2]]*qt.RAD2DEG);for(let r=1;r<t.length;r++)i=i[t[r]];return t[1]==="rotation"&&(i*=qt.RAD2DEG),i}for(let i in this.variables){if(e===void 0)break;let r=this.variables[i],s=r.locations?.findIndex(n=>Dn.equal(n,e));s!==void 0&&s!==-1&&r.locations.splice(s,1)}if(typeof t=="string"){let i=t,r=t;do{if(r=i,this.variables[i]===void 0)break;let s=this.variables[i].value;e&&this.variables[r]!==void 0&&this.variables[r].locations.push(e),i=s}while(typeof i=="string");return i}return t}getVariables(){return this.variables}getVariablesNames(){return this.data.variables.map(t=>t.data.name)}getVariableByName(t){for(let e of this.data.variables)if(e.data.name===t)return{variable:e.data,id:e.id}}getDynamicVariablePlayState(t){return this.variables[t]?.dynamicVariablePlayState}setDynamicVariablePlayState(t,e){this.variables[t]!==void 0&&(this.variables[t].dynamicVariablePlayState=e)}getDynamicVariableToggleIsForward(t){return this.variables[t]?.dynamicVariableToggleIsForward}setDynamicVariableToggleIsForward(t,e){this.variables[t]!==void 0&&(this.variables[t].dynamicVariableToggleIsForward=e)}resetLib(t){for(let[e,i]of Object.entries(t.images))this.addImage(e,i.asset);for(let[e,i]of Object.entries(t.audios))this.addAudio(e,i.asset);for(let[e,i]of Object.entries(t.particles))this.addParticle(e,i.asset);for(let[e,i]of Object.entries(t.colors))this.addColor(e,i.asset);for(let[e,i]of Object.entries(t.fonts))this.addFont(e,i.asset);for(let[e,i]of Object.entries(t.videos))this.addVideo(e,i.asset);for(let[e,i]of Object.entries(t.variables))this.addVariableHolder(e,i.asset)}updateLibByOp(t,e){t.path[0]==="images"?t.path.length===1&&t.type===1?this.addImage(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteImage(t.id):t.path[0]==="videos"?t.path.length===1&&t.type===1?this.addVideo(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteVideo(t.id):t.path[0]==="audios"?t.path.length===1&&t.type===1?this.addAudio(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteAudio(t.id):t.path[0]==="particles"?t.path.length===1&&t.type===1?this.addParticle(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteParticle(t.id):t.path[0]==="colors"?t.path.length===1&&t.type===1?this.addColor(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteColor(t.id):t.path[0]==="materials"?t.path.length===1&&t.type===1?this.addMaterial(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteMaterial(t.id):t.path[0]==="fonts"?t.path.length===1&&t.type===1?this.addFont(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteFont(t.id):t.path[0]==="variables"?t.path.length===1&&t.type===1?this.addVariableHolder(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteVariable(t.id):t.path[0]==="components"&&e.updateByLibOp(t,this)}updateByOp(t,e,i){if(this.data=e,t.path[0]==="images")t.path.length===2&&t.type===0?t.props.data&&this.getImage(t.path[1]).updateSrc(t.props.data):t.path.length===1&&t.type===1?this.addImage(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteImage(t.id);else if(t.path[0]==="videos")t.path.length===2&&t.type===0?t.props.data&&this.getVideo(t.path[1]).updateSrc(t.props.data):t.path.length===1&&t.type===1?this.addVideo(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteVideo(t.id);else if(t.path[0]==="audios")t.path.length===2&&t.type===0?t.props.data&&this.addAudio(t.path[1],e.audios[t.path[1]]):t.path.length===1&&t.type===1?this.addAudio(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteAudio(t.id);else if(t.path[0]==="particles")t.path.length===2&&t.type===0?t.props.data&&this.addParticle(t.path[1],e.particles[t.path[1]]):t.path.length===1&&t.type===1?this.addParticle(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteParticle(t.id);else if(t.path[0]==="colors")t.path.length===2&&t.type===0?this.updateColor(t.path[1],t.props):t.path.length===1&&t.type===1?this.addColor(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteColor(t.id);else if(t.path[0]==="materials")t.path.length===1&&t.type===1?this.addMaterial(t.id,t.data):t.path.length===1&&t.type===2?this.deleteMaterial(t.id):t.path.length>1&&this.getMaterial(t.path[1]).updateByOp(ea.drop(t,2),e.materials[t.path[1]],{shared:this,scene:i});else if(t.path[0]==="fonts")t.path.length===2&&t.type===0?this.updateFont(t.path[1],t,i):t.path.length===1&&t.type===1?this.addFont(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteFont(t.id);else if(t.path[0]==="variables")t.path.length===2&&t.type===0?"value"in t.props?this.updateVariable(t.path[1],t.props.value):"persistent"in t.props&&(this.variables[t.path[1]].persistent=t.props.persistent):t.path.length===1&&t.type===4?this.addVariableHolder(t.id,t.data):t.path.length===1&&t.type===5&&this.deleteVariable(t.id);else if(t.path[0]==="userAPIs"){if(t.path.length===1&&t.type===1)this.addUserAPI(t.id,t.data);else if(t.path.length===1&&t.type===2)this.deleteUserAPI(t.id);else if(typeof t.path[1]=="string"){let r=e.userAPIs[t.path[1]];if(r){let s=t.type===0&&t.props.debounce===void 0,n=this.getUserAPI(t.path[1]);n!==void 0&&n===this.openAIRealtime?n.update(r):n?.update(r,this,s)}}}else if(t.path[0]==="userWebhooks"){if(t.path.length===1&&t.type===1)this.addUserWebhook(t.id,t.data);else if(t.path.length===1&&t.type===2)this.deleteUserWebhook(t.id);else if(typeof t.path[1]=="string"){let r=e.userWebhooks[t.path[1]];r&&this.getUserWebhook(t.path[1])?.update(r)}}else t.path[0]==="lib"&&this.updateLibByOp(ea.drop(t,1),i)}updateFont(t,e,i){if(e.props.url){let r=this.getFont(t),s={...this.data.fonts[t],url:e.props.url};r.update(s),r.loadingPromise.then(()=>this.requestRender()),i.updateFont(t,this)}}addUserAPI(t,e){if(this.userAPIs[t])return this.userAPIs[t].update(e,this),!0;if(this.openAIRealtime?.id===t)return this.openAIRealtime.update(e),!0;if(e.integration?.type==="VoiceAssistant"){let i=VG;return i===null?(Nn("ai-assistant","a voice-assistant integration"),!1):(this.openAIRealtime=i(e,t,this),!1)}{let i=EK();return i===null?(Nn("api-services","a user API integration"),!1):(this.userAPIs[t]=i.createUserAPI(t,e,this),!1)}}getUserAPI(t){return this.openAIRealtime?.id===t?this.openAIRealtime:this.userAPIs[t]}getUserAPIs(){return this.userAPIs}deleteUserAPI(t){let e=this.userAPIs[t];e&&(e.dispose(),delete this.userAPIs[t])}addUserWebhook(t,e){if(this.userWebhooks[t])return this.userWebhooks[t].update(e),!0;{let i=EK();return i===null?(Nn("api-services","a user webhook"),!1):(this.userWebhooks[t]=i.createUserWebhook(t,e),!1)}}getUserWebhook(t){return this.userWebhooks[t]}getUserWebhooks(){return this.userWebhooks}deleteUserWebhook(t){let e=this.userWebhooks[t];e&&(e.dispose(),delete this.userWebhooks[t])}get scene(){return this.entityOpContext.scene}}).MAX_TRANSIENT_VERTICES=6e4,new NR(Zl.emptyData())});function Cgt(t){return SR(t)||t?.isTSLNodeMaterial===!0}var yo,qO,HO,$O,NK,XO,Fr,Egt=G(()=>{_G()}),n0=G(()=>{ke(),la(),wm(),Egt(),Fi(),hn(),yo=class extends Bs{setMaterialOverride(t,e){this.materialOverride=TK(t),this.material!==this.shadowCatcherMaterial&&(this.disposeMaterial(),this.material=this.materialOverride,this.layers.set(0),this.syncShapeBlendNodeLayer(),e.scene.markNeedsUpdateRendererDirty())}updateByPatchedOp(t,e,i){if(super.updateByPatchedOp(t,e,i),er(t.path,["geometry"])&&this.syncShadowCatcher(i),function(r,s){let n=[];if(s.length!==r.length)return null;{let a=0;for(;a<r.length;){if(s[a]==="*")n.push(r[a]);else if(r[a]!==s[a])return null;a+=1}}return n}(t.path,["materials"])!==null&&t.type===0&&Array.isArray(this.material))for(let[r,s]of Object.entries(t.props)){let n=this.material[Number(r)],a=i.shared.material(s);a!==n&&yo.disposeOneMaterial(n),this.material[Number(r)]=a}else if(er(t.path,["material"])){let r=this.material;!Array.isArray(r)&&typeof r?.updateByOp=="function"&&"material"in e&&typeof e.material!="string"&&r.updateByOp(ea.drop(t,1),e.material,i)}else if(er(t.path,["materials","*"])&&Array.isArray(this.material)){let r=t.path[1];if("materials"in e&&r<this.material.length){let s=e.materials[r];typeof s!="string"&&this.material[r].updateByOp(ea.drop(t,2),s,i)}}}get needsAO(){return this.material!==void 0&&(Array.isArray(this.material)?this.material[0]:this.material).hasAO}syncShapeBlendNodeLayer(){this.dataPatched.type==="Mesh"&&this.dataPatched.geometry.shapeBlendNode?this.layers.set(9):512&this.layers.mask&&this.layers.set(0)}updateState(t,e){super.updateState(t,e),t.castShadow!==void 0&&(this.castShadow=t.castShadow),t.receiveShadow!==void 0&&(this.receiveShadow=t.receiveShadow);let i,r=this.dataPatched;this.syncShapeBlendNodeLayer(),this.dataPatched.type==="Mesh"&&this.dataPatched.geometry.type==="ShapeBlendGeometry"&&(i={resolutionLevel:Math.min(8,this.dataPatched.geometry.resolutionLevel),useChildrenColors:this.dataPatched.geometry.useChildrenColors});let s=this.materialOverride!==void 0;!s&&t.geometry?.type!=="NonParametricGeometry"&&"material"in t&&t.material!==void 0&&(this.disposeMaterial(),this.material=e.shared.material(t.material).getFlavor(r.flatShading,r.side,r.wireframe,i),e.scene.markNeedsUpdateRendererDirty()),!s&&(t.geometry?.type==="NonParametricGeometry"||"materials"in t)&&("materials"in t&&t.materials!==void 0?(this.disposeMaterial(),this.material=t.materials.map(a=>e.shared.material(a).getFlavor(r.flatShading,r.side,r.wireframe)),e.scene.markNeedsUpdateRendererDirty()):"material"in t&&t.material!==void 0&&(this.disposeMaterial(),this.material=[e.shared.material(t.material).getFlavor(r.flatShading,r.side,r.wireframe)],e.scene.markNeedsUpdateRendererDirty()));let n=this.data;if(!s&&n.geometry?.type!=="NonParametricGeometry"&&"materials"in n&&n.materials!==void 0&&(this.disposeMaterial(),this.material=e.shared.material(n.materials[0]).getFlavor(r.flatShading,r.side,r.wireframe)),!s&&(t.flatShading!==void 0||t.wireframe!==void 0||t.side!==void 0))if(Array.isArray(this.material))for(let a=0;a<this.material.length;a++)this.material[a]=this.material[a].getFlavor(r.flatShading,r.side,r.wireframe);else this.material=this.material.getFlavor(r.flatShading,r.side,r.wireframe,i);this.syncShadowCatcher(e)}shadowCatcherActive(){let t=this.dataPatched,e=t.geometry?.type;return t.shadowCatcher===!0&&(e==="RectangleGeometry"||e==="PlaneGeometry")}syncShadowCatcher(t){let e=this.dataPatched;if(this.shadowCatcherActive()){if(this.shadowCatcherMaterial===void 0){let i=function(){let r=iT==="webgpu"&&JU!==void 0?JU:void 0;return r===void 0?null:TK(r())}();if(i===null)return;this.shadowCatcherMaterial=i}this.shadowCatcherMaterial.side=e.side,this.material!==this.shadowCatcherMaterial&&(this.disposeMaterial(),this.material=this.shadowCatcherMaterial,t.scene.markNeedsUpdateRendererDirty()),this.castShadow=!1,this.receiveShadow=!0,this.layers.set(0)}else this.shadowCatcherMaterial!==void 0&&this.material===this.shadowCatcherMaterial&&(this.materialOverride!==void 0?(this.material=this.materialOverride,t.scene.markNeedsUpdateRendererDirty()):"material"in e&&e.material!==void 0&&(this.material=t.shared.material(e.material).getFlavor(e.flatShading,e.side,e.wireframe),t.scene.markNeedsUpdateRendererDirty(),this.needsAO&&this.layers.enable(5)),this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow)}static disposeOneMaterial(t){var e;Cgt(t)&&!function(i){return i?.isClassicSharedMaterial===!0}(e=t)&&e?.isTSLSharedMaterial!==!0&&t.nodeMaterialDispose()}disposeMaterial(){this.material&&Qpt(this.material).forEach(t=>{yo.disposeOneMaterial(t)})}dispose(){this.disposeMaterial(),this.shadowCatcherMaterial?.dispose(),super.dispose()}}}),bo=G(()=>{ke(),Fi(),zG(),n0(),dt(),U5(),Kv(),Zv(),vgt(),qO=new P,HO=new Te,$O=new Te,NK=new P,XO=new bt,Fr=class extends yo{constructor(t,e,i){super(t,e),this.data=e,this.isSkinnedMesh=!1,this.localGeometry=void 0,e.bindMode&&e.bindMatrix&&(this.bindMode=e.bindMode,this.bindMatrix=new bt().fromArray(e.bindMatrix),this.bindMatrixInverse=new bt)}chooseGeoemtryCache(t){return t.geometryCache}supportsInPlaceGeometryUpdate(t){return t.isTextGeometry!==!0}markGeometryAsReachable(t){this.geometryCreateDeleyed instanceof ye&&this.chooseGeoemtryCache(t).markAsReachable(this.dataPatched.geometry,this.geometryCreateDeleyed)}get builtSharedGeometry(){if(this.localGeometry===void 0)return this.geometryCreateDeleyed instanceof ye?this.geometryCreateDeleyed:void 0}get geometry(){if(this.localGeometry!==void 0)return this.localGeometry;if(this.geometryCreateDeleyed instanceof NR){let t=this.geometryCreateDeleyed,e=this.chooseGeoemtryCache(t),i=this.dataPatched.geometry;this.geometryCreateDeleyed=e.get(i,t,this),this._geometryCacheKey=i}return this.geometryCreateDeleyed}set geometry(t){this.localGeometry=t}get is2DAndNoDepth(){let t=this.dataPatched.geometry;return uR.is2DParametricMesh(t.type)&&t.depth===0}get is2DType(){return uR.is2DParametricMesh(this.geometry.userData.type)}get isTextType(){return this.geometry.isTextGeometry===!0}get isNonParametric(){return this.geometry.userData.type==="NonParametricGeometry"}updateByPatchedOp(t,e,i){super.updateByPatchedOp(t,e,i),er(t.path,["geometry"])&&this.updateByPatchedOpGeometry(ea.drop(t,1),e.geometry,i)}removeInteractionGeometry(t){this.localGeometry?.dispose(),this.localGeometry=void 0}dispose(){var t;super.dispose(),t=this.uuid,ER.delete(t)}get appliedGeometrySize(){let t=this.localGeometry?.userData;if(t!==void 0&&t.sxPrev!==void 0)return[t.sxPrev,t.syPrev,t.szPrev]}updateGeometryInteractions(t,e){this.invalidateDownstreamBooleanData();let i=this.data.geometry.type;if(i==="NonParametricGeometry"||i==="SubdivGeometry"){let r,s,n,a=t;if(this.localGeometry===void 0){let d={...this.data.geometry,...a};this.localGeometry=im(d,e,this.data.flatShading,this)}a.scaleBaked?[r,s,n]=a.scaleBaked:{width:r,height:s,depth:n}=a;let o=this.localGeometry.userData,l=typeof r=="number"?r:1,u=typeof s=="number"?s:1,h=typeof n=="number"?n:1;o.sxPrev!==void 0&&HU(this.localGeometry.attributes,l/o.sxPrev,u/o.syPrev,h/o.szPrev),o.sxPrev=l,o.syPrev=u,o.szPrev=h}else if(!this.absorbDepthInteraction(t)){let r=im({...this.data.geometry,...t},e,this.data.flatShading,this);this.localGeometry!==void 0&&this.supportsInPlaceGeometryUpdate(this.localGeometry)&&BO(this.localGeometry,r)?r.dispose():(this.localGeometry?.dispose(),this.localGeometry=r)}}absorbDepthInteraction(t){let e=this.localGeometry;if(e?.shiftDepthTo===void 0)return!1;let i=t;if(typeof i.depth!="number")return!1;let r=e.userData?.parameters;if(r===void 0)return!1;for(let s of Object.keys(i))if(s!=="depth"&&i[s]!==r[s])return!1;return!!e.shiftDepthTo(i.depth)&&(r.depth=i.depth,!0)}refreshAttachedClonersInteractions(t){for(let e of this.attachedSurfaceCloners)e.update(t)}refreshAttachedCloners(t){for(let e of this.attachedSurfaceCloners)t.scene.addPendingUpdateCloner(e.object)}refreshAttachedPaths(t){for(let e of this.attachedPaths)t.scene.addPendingCommand(()=>e.updateShape())}createGeometryDelayed(t){this.geometryCreateDeleyed=t.shared,this.refreshAttachedCloners(t),this.refreshAttachedPaths(t)}updateByPatchedOpGeometry(t,e,i){let r=!1;if(t.type===0&&t.path.length===0&&Object.keys(t.props).includes("scaleBaked")&&this.geometryCreateDeleyed instanceof us&&this.chooseGeoemtryCache(i.shared).mutateIfUnique(this.geometryCreateDeleyed.data,e)===this.geometryCreateDeleyed&&(r=!0,this.geometryCreateDeleyed.mutateDirectlyScaleBaked(e,t.props.scaleBaked),this.refreshAttachedCloners(i),this.refreshAttachedPaths(i)),!r&&t.type===0&&t.path.length===0&&bgt(t.props)&&this.geometryCreateDeleyed instanceof us&&this.chooseGeoemtryCache(i.shared).mutateIfUnique(this.geometryCreateDeleyed.data,e)===this.geometryCreateDeleyed&&(r=!0,this.geometryCreateDeleyed.mutateDirectlySubdivisions(e),this.refreshAttachedCloners(i),this.refreshAttachedPaths(i)),!r&&t.type===0&&t.path.length===0&&this.geometryCreateDeleyed instanceof ye&&!(this.geometryCreateDeleyed instanceof us)&&this.supportsInPlaceGeometryUpdate(this.geometryCreateDeleyed)&&this._geometryCacheKey!==void 0){let s=i.shared,n=this.chooseGeoemtryCache(s),a=this.geometryCreateDeleyed;if(n.getCached(this._geometryCacheKey)===a&&a.isShared!==!0){let o=this.dataPatched.geometry,l=im(o,s,this.data.flatShading,this);BO(a,l)?(l.dispose(),a.computeBoundingSphere(),n.mutateIfUnique(this._geometryCacheKey,o)):(l.computeBoundingSphere(),n.forceDelete(this._geometryCacheKey),n.adopt(o,l),this.geometryCreateDeleyed=l),this._geometryCacheKey=o,r=!0,this.refreshAttachedCloners(i),this.refreshAttachedPaths(i)}}r||(i.scene?.markGeometryCacheDirty(),this.createGeometryDelayed(i)),this.syncShapeBlendNodeLayer(),this.resetBBoxNeedsUpdate(),this.invalidateDownstreamBooleanData()}updateGeometryOnStateUpdate(t,e){this.createGeometryDelayed(e)}applyTransientGeometryData(t,e){let i=t.shared,r=this.dataPatched.geometry;if(this.geometryCreateDeleyed instanceof ye&&!(this.geometryCreateDeleyed instanceof us)&&this.supportsInPlaceGeometryUpdate(this.geometryCreateDeleyed)&&this._geometryCacheKey!==void 0){let s=this.chooseGeoemtryCache(i),n=this.geometryCreateDeleyed;if(s.getCached(this._geometryCacheKey)===n&&n.isShared!==!0){let a=im(r,i,this.data.flatShading,this);return BO(n,a)?(a.dispose(),n.computeBoundingSphere(),s.mutateIfUnique(this._geometryCacheKey,r)):(a.computeBoundingSphere(),s.forceDelete(this._geometryCacheKey),s.adopt(r,a),this.geometryCreateDeleyed=a),this._geometryCacheKey=r,this.refreshAttachedCloners(t),void this.refreshAttachedPaths(t)}}e&&this._geometryCacheKey!==void 0&&this.chooseGeoemtryCache(i).forceDelete(this._geometryCacheKey),t.scene?.markGeometryCacheDirty(),this.createGeometryDelayed(t)}updateState(t,e){t.geometry!==void 0&&this.updateGeometryOnStateUpdate(t.geometry,e);let i=t.morphTargetInfluences;if(i){this.updateMorphTargets(),this.geometry.morphTargetsRelative=!0;for(let{data:{name:r,value:s}}of i)this.updateMorphInfluences(r,e.shared.getVariable(s,[this.uuid,"morphTargetInfluences",r]))}super.updateState(t,e)}updateMorphInfluences(t,e){if(this.morphTargetDictionary===void 0)return;let i=this.morphTargetDictionary[t];i!==void 0&&(this.morphTargetInfluences[i]=e)}updateGeometryGroupsIfNeeded(){Array.isArray(this.material)&&this.geometry.groups.length===0&&this.geometry.addGroup(0,Math.max(this.geometry.getIndex()?.count??0,this.geometry.getAttribute("position").count),0)}updateEntityBoxSize(t,e){let i=this.geometry.userData.parameters;this.is2DType||this.isTextType?t.set(0,0,.5*i.depth):this.isNonParametric?(t.setScalar(0),this.geometry.boundingSphere&&t.copy(this.geometry.boundingSphere.center),e.set(i.width,i.height,i.depth??0).multiplyScalar(.5)):i.centerOffset?t.fromArray(i.centerOffset):t.setScalar(0),e.set(i.width,i.height,i.depth??0).multiplyScalar(.5)}updateMatrixWorld(t){super.updateMatrixWorld(t),this.bindMode==="attached"?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode==="detached"&&this.bindMatrixInverse.copy(this.bindMatrix).invert()}bind(t,e){this.skeleton=t,this.isSkinnedMesh=!0,e===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),e=this.matrixWorld),this.bindMatrix.copy(e),this.bindMatrixInverse.copy(e).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(t){let e=new Te,i=this.geometry.attributes.skinWeight;for(let r=0,s=i.count;r<s;r++){e.fromBufferAttribute(i,r);let n=1/e.manhattanLength();n!==1/0?e.multiplyScalar(n):e.set(1,0,0,0),i.setXYZW(r,e.x,e.y,e.z,e.w)}}boneTransform(t,e){let i=this.skeleton;if(i===void 0)return;let r=this.geometry;HO.fromBufferAttribute(r.attributes.skinIndex,t),$O.fromBufferAttribute(r.attributes.skinWeight,t),qO.copy(e).applyMatrix4(this.bindMatrix),e.set(0,0,0);for(let s=0;s<4;s++){let n=$O.getComponent(s);if(n!==0){let a=HO.getComponent(s);XO.multiplyMatrices(i.bones[a].matrixWorld,i.boneInverses[a]),e.addScaledVector(NK.copy(qO).applyMatrix4(XO),n)}}return e.applyMatrix4(this.bindMatrixInverse)}}});function fv(t){if(Array.isArray(t.material)){for(let e of t.material)if(e.getLayersOfType("outline").length===0)return}else if(!SR(t.material)||t.material.getLayersOfType("outline").length===0)return;t instanceof Fr&&t.is2DAndNoDepth?function(e){if(e.geometry.attributes.extrudeNormals||!e.geometry.attributes.position)return;let i=e.geometry.attributes.position.array,r=new Float32Array(i.length),s=new P;for(let n=0;n<i.length;n+=3)s.set(i[n],i[n+1],i[n+2]).normalize(),r[n]=s.x,r[n+1]=s.y,r[n+2]=s.z;e.geometry.setAttribute("extrudeNormal",new fe(r,3))}(t):function(e){if(e.geometry.attributes.extrudeNormal||!e.geometry.attributes.position||!e.geometry.attributes.normal)return;let i=new Map,r=e.geometry.attributes,s=r.position.array,n=r.normal.array,a=new Float32Array(s.length);for(let o=0;o<s.length;o+=3){let l=`${s[o]}_${s[o+1]}_${s[o+2]}`,u=new P(n[o],n[o+1],n[o+2]);i.has(l)?i.get(l)?.normals.push(u):i.set(l,{normals:[u],result:new P})}i.forEach((o,l)=>{for(let u of o.normals)o.result.add(u);o.result.divideScalar(o.normals.length)});for(let o=0;o<s.length;o+=3){let l=`${s[o]}_${s[o+1]}_${s[o+2]}`,u=i.get(l)?.result;u&&(a[o]=u.x,a[o+1]=u.y,a[o+2]=u.z)}e.geometry.setAttribute("extrudeNormal",new fe(a,3))}(t)}function YO(t){return Math.min(2047,Math.max(1,Math.round(2048*t)))/2048}function gv(t){if(!t.geometry.attributes.position)return;let e=t.geometry.attributes,i=e.position.array,r=e.randomColor;if(r!==void 0&&3*r.count===i.length)return;let s=new Float32Array(i.length),n=parseInt(t.uuid.replace(/\D/g,"")),a=[YO(qt.seededRandom(n)),YO(qt.seededRandom(n+1e4)),YO(qt.seededRandom(n+2e4))];for(let o=0;o<i.length;o++)s[o]=a[o%3];t.geometry.setAttribute("randomColor",new we(s,3))}var j5=G(()=>{dt(),_G(),bo()});function OK(t){let e=!1;return t.scene.objects.traverse((i,r)=>{r.geometry?.type==="BooleanGeometry"&&(e=!0)}),e}function C3t(t,e){let i=t.cloner;return i!==void 0&&i.parent===e?i:void 0}function IK(t,e,i,r){let s=16*(e.children.length+1);Qw.length<s&&(Qw=new Float32Array(s));let n=0,a=l=>{l.toArray(Qw,16*n),n++},o=e.parameters.hideBase!==!0;o&&a(r),ej.multiplyMatrices(t.hiddenMatrix,t.matrix);for(let l of e.children)!Sg(l)||l.playModeVisible===!1||(ij.multiplyMatrices(l.hiddenMatrix,l.matrix).multiply(l.pivotMatrix),zP.multiplyMatrices(ej,ij),(!o||!zP.equals(r))&&a(zP));try{return n===0?0:function(l,u){return vG(wR().instanced_union(yG(l),u))}(i,Qw.subarray(0,16*n))}finally{pft(i)}}var cd,BK,ej,ij,zP,Qw,um,OR,G5,Hh,Hu,IR,sT=G(()=>{la(),dt(),k5(),j5(),n0(),ns(),cd=new bt,BK=new bt,ej=new bt,ij=new bt,zP=new bt,Qw=new Float32Array(0),um=class extends yo{constructor(t,e,i){super(t,e),this.data=e,this.meshSetAddresses=[],this.needsTransformForDownstream=!1,this.geometry=new ye,this.onAfterRender=(r,s,n,a,o,l)=>{super.onAfterRender(r,s,n,a,o,l),this.recomputeBoolean()},this.geometry.userData.parameters={width:0,height:0,depth:0}}get booleanOp(){return this.data.geometry.operation}get phongAngle(){return this.data.geometry.phongAngle??45}get isLOD(){return this.recomputeBoolean(),!1}updateByPatchedOp(t,e,i){super.updateByPatchedOp(t,e,i),t.path.length===1&&t.path[0]==="geometry"&&t.type===0&&t.props.operation!==void 0&&(this.freeBooleanPointer(),this.resetBBoxNeedsUpdate())}freeBooleanPointer(){super.freeBooleanPointer(),this.geometry.dispose()}recomputeBoolean(t,e=!0){if(this.booleanMeshSetAddress!==-1&&!t)return;for(let r=0;r<this.children.length;r++){let s=this.children[r];s instanceof um&&s.dataPatched.visible===!0&&s.recomputeBoolean(t===!0,e)}this.meshSetAddresses=[];for(let r=0;r<this.children.length;r++){let s=this.children[r];if(s instanceof Bs&&s.dataPatched.visible===!0&&s.geometry.attributes.position?.count>0&&s.geometry.drawRange.count>0&&s.booleanMeshSetAddress!==0){cd.multiplyMatrices(s.hiddenMatrix,s.matrix).multiply(s.pivotMatrix);try{let n=C3t(s,this);if(s.booleanMeshSetAddress===-1){if((s.geometry.index??s.geometry.getAttribute("position")).count/3<15e5){let a=KMt(s.geometry,t===!0);s.booleanMeshSetAddress=n===void 0||a===-1?a:IK(s,n,a,cd)}if(s.booleanMeshSetAddress===-1)return;n===void 0&&MO(s.booleanMeshSetAddress,cd),s.booleanMatrixInvOld.copy(cd).invert(),s.booleanWasTransformed=!1}else s instanceof um&&s.needsTransformForDownstream===!0?(n===void 0?MO(s.booleanMeshSetAddress,cd):s.booleanMeshSetAddress=IK(s,n,s.booleanMeshSetAddress,cd),s.needsTransformForDownstream=!1):s.booleanWasTransformed===!0&&(MO(s.booleanMeshSetAddress,BK.multiplyMatrices(cd,s.booleanMatrixInvOld)),s.booleanMatrixInvOld.copy(cd).invert(),s.booleanWasTransformed=!1)}catch(n){console.error(n),s.booleanMeshSetAddress=0,s.geometry.userData.booleanOperationDidFail=!0;continue}if(s.booleanMeshSetAddress===0)continue;this.meshSetAddresses.push(s.booleanMeshSetAddress),s.geometry.userData.booleanOperationDidFail=!1}}if(this.meshSetAddresses.length===0){if(this.geometry.getAttribute("position")?.array.length!==0){let r=this.geometry;r.dispose(),this.geometry=new ye,this.geometry.userData=r.userData,this.geometry.boundingSphere=r.boundingSphere,this.geometry.setAttribute("position",new fe([],3))}return void this.geometry.setDrawRange(0,0)}if(t===!0)return function(r,s){let n=wR(),a=CY(r,s),o=n.mesh_topological_data(a),l=o.positions(),u=o.indices();return o.free(),a.free(),{positions:l,indices:u,verticesPerFace:new Uint8Array(u.length/3).fill(3)}}(this.meshSetAddresses,this.booleanOp);let i=this.geometry;i.dispose(),this.geometry=new ye,this.geometry.userData=i.userData,this.geometry.boundingSphere=i.boundingSphere;try{this.booleanMeshSetAddress=function(r,s,n,a){let o=wR(),l=CY(r,s),u=o.mesh_render_data(l,Math.max(a,0));if(n.setAttribute("position",new fe(u.positions(),3)),n.setAttribute("normal",new fe(u.normals(),3)),u.free(),n.boundingSphere===null&&(n.boundingSphere=new ta),l.tri_count()===0)n.boundingSphere.center.set(0,0,0),n.boundingSphere.radius=0,n.userData.parameters={width:0,height:0,depth:0};else{let h=l.bounds();n.boundingSphere.center.set(h[0],h[1],h[2]),n.boundingSphere.radius=(h[3]**2+h[4]**2+h[5]**2)**.5,n.userData.parameters={width:2*h[3],height:2*h[4],depth:2*h[5]}}return vG(l)}(this.meshSetAddresses,this.booleanOp,this.geometry,this.phongAngle)}catch(r){this.booleanMeshSetAddress=0,this.geometry.userData.booleanOperationDidFail=!0,console.error(r)}this.booleanMatrixInvOld.copy(this.matrix).invert(),this.needsTransformForDownstream=!0,fv(this),gv(this)}dispose(){super.dispose(),this.geometry.dispose()}}}),nT=G(()=>{dt(),vo(),s0(),(OR||(OR={})).is=function(t){return Mi.is(t)&&t instanceof qd},G5=(t,e)=>class extends r0(t,e){updateState_Light(i,r){if(this.updateState_Entity(i,r),i.color!==void 0&&(this.color=r.shared.color(i.color)),i.intensity!==void 0&&(this.intensity=i.intensity*Math.PI),i.depth!==void 0){let s=this.shadow;s.camera.far=i.depth,s.needsUpdate=!0}i.shadows!==void 0&&(this.castShadow=i.shadows)}}}),Sm=G(()=>{dt(),sT(),la(),s0(),Hh=t=>t instanceof Bs,Hu=t=>t!==null&&t instanceof um,IR=t=>EU.is(t)});function Sa(t,e){return e.color(t)}function VK(t=new Date,e){let i=e.format,r=t.getSeconds(),s=t;e&&e.timeZone!==null&&(s=function(d,c){try{let p=new Intl.DateTimeFormat("en-US",{timeZone:c,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hourCycle:"h23"}).formatToParts(d),m=f=>Number(p.find(g=>g.type===f)?.value);return new Date(m("year"),m("month")-1,m("day"),m("hour"),m("minute"),m("second"),d.getMilliseconds())}catch{return new Date(NaN)}}(new Date,e.timeZone));let n,a=s.getHours(),o=s.getMinutes();e.format12h24h==="12ampm"&&(n=a>=12?"PM":"AM");let l,u,h=a;switch(e.format12h24h!=="24"&&(h=a%12,h===0&&(h=12)),i){case"HH:mm:ss":l=[h,o,r];break;case"HH:mm":l=[h,o];break;case"HH":l=[h],n=void 0;break;case"mm":l=[o],n=void 0;break;case"ss":l=[r],n=void 0;break;case"year":u=s.getFullYear();break;case"month":u=s.getMonth()+1;break;case"dayOfYear":u=Math.floor((s.getTime()-new Date(s.getFullYear(),0,0).getTime())/864e5);break;case"dayOfMonth":u=s.getDate();break;case"secondOfDay":u=60*a*60+60*o+r;break;default:console.error("Unknown time format",i),u=0}return l!==void 0?{textValue:l,suffix:n}:u}var rj,tb,LG=G(()=>{}),E3t=G(()=>{dt(),ZS(),QS(),rj=class extends $v(Wpt){constructor(t,e=15,i=10066329){super(t,e,i),this.object=t,this.added=!1,this.name=`DirectionalLightHelper: ${t.uuid}`}raycast(t,e){Xv(this.object,rj.geometryHelper,t,e)}}}),W5=G(()=>{dt(),E3t(),nT(),tb=class extends G5(xS,rj){constructor(t,e,i){super(),this.super_Entity(t,e),this.castShadow=!0,this.shadow.mapSize.width=2048,this.shadow.mapSize.height=2048,this.shadow.normalBias=1,this.layers.enable(3);let r=this.shadow.camera;r.top=1250,r.bottom=-1250,r.right=1250,r.left=-1250,r.near=-1e4,r.far=2500;let s=new wS(this.shadow.camera);s.visible=!1,this.gizmos.shadowmap=s}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this.gizmos){let e=this.gizmos[t];e instanceof wS&&e.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.objectHelper&&this.objectHelper.update()}updateState(t,e){this.updateState_Light(t,e);let i=t.depth!==void 0&&t.depth!==this.shadow.camera.far||t.size!==void 0&&t.size/2!==this.shadow.camera.right;t.size!==void 0&&function(r,s){r.shadow.camera.right=s/2,r.shadow.camera.left=-s/2,r.shadow.camera.top=s/2,r.shadow.camera.bottom=-s/2,r.shadow.needsUpdate=!0}(this,t.size),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),t.penumbraSize!==void 0&&e.scene.markPenumbraSizeDirty(),i&&this.update()}}});function FG(t){return t instanceof yo&&t.needsAO&&!Cc(t)&&t.isDecalObject!==!0}function UG(t){let e=t.cloner;if(e&&Array.isArray(e.children))for(let i of e.children)i?.layers&&(i.layers.mask=t.layers.mask)}function jG(t){return t.getLayersOfType("reflection").filter(e=>e.data.visible).length}function P3t(t){let e=1/0,i=-1/0;for(let r of t.getLayersOfType("reflection")){let s=r.data;if(!s.visible||s.mirror===1)continue;let n=typeof s.blur=="number"?s.blur:null;e=Math.min(e,n??0),i=Math.max(i,n??10)}return e===1/0?null:{min:e,max:i}}function R3t(t){for(let e of t.getLayersOfType("reflection")){let i=e.data;if(!i.visible)continue;let{blur:r,thickness:s,steps:n,stepSize:a}=i;return typeof r!="number"||typeof s!="number"||typeof n!="number"||typeof a!="number"?"variable":{blur:r,thickness:s,steps:n,stepSize:a,tracingMode:i.tracingMode===1?1:0}}return null}function kK(t,e){let i={outline:!1,cavity:!1},r=t.layers.mask&q5,s=e.getLayersOfType("transmission"),n=e.getLayersOfType("outline"),a=jG(e),o=e.getLayersOfType("cavity");return(n.length>0||o.length>0)&&(t.layers.set(8),s.length>0&&t.layers.enable(3),a>0&&t.layers.enable(4),i.outline=n.length>0,i.cavity=o.length>0,gv(t),fv(t)),s.length===0&&n.length===0&&o.length===0&&a===0&&t.layers.set(0),r&&t.layers.set(9),!r&&FG(t)&&t.layers.enable(5),UG(t),i}function zK(t,e){if(!e.layers)return!1;let i=t.layers.mask&q5,r=!1,s=e.getLayersOfType("transmission").filter(l=>l.data.visible),n=e.getLayersOfType("outline").filter(l=>l.data.visible),a=jG(e),o=e.getLayersOfType("cavity").filter(l=>l.data.visible);return s.length>0&&(t.layers.set(3),(n.length>0||o.length>0)&&t.layers.enable(8),a>0&&t.layers.enable(4),r=!0),s.length===0&&n.length===0&&o.length===0&&a===0&&t.layers.set(0),i&&t.layers.set(9),!i&&FG(t)&&t.layers.enable(5),UG(t),r}function LK(t,e){var i;if(!e.layers)return!1;let r=t.layers.mask&q5,s=!1,n=jG(e),a=e.getLayersOfType("transmission").filter(u=>u.data.visible),o=e.getLayersOfType("outline").filter(u=>u.data.visible),l=e.getLayersOfType("cavity").filter(u=>u.data.visible);return n>0&&((i=t.userData).__splinePlanarMirror??(i.__splinePlanarMirror=0),t.layers.set(4),a.length>0&&t.layers.enable(3),(o.length>0||l.length>0)&&t.layers.enable(8),s=!0),n===0&&a.length===0&&o.length===0&&l.length===0&&t.layers.set(0),r&&t.layers.set(9),!r&&FG(t)&&t.layers.enable(5),UG(t),s}function sj(t,e,i,r=!1){let s=t.cloner;if(s){let n=null;if(t.raycast===Sr.prototype.raycast||t.raycast===Bs.prototype.raycast){let a=t.geometry;a&&(a.boundingSphere===null&&a.computeBoundingSphere(),n=a.boundingSphere)}for(let a of s.children){if(n!==null&&(nj.copy(n).applyMatrix4(a.matrixWorld),!e.ray.intersectsSphere(nj)))continue;let o=Rgt.copy(a.matrixWorld).invert(),l=Dgt.copy(e.ray).applyMatrix4(o),u=t.matrixWorld;l.applyMatrix4(u);let h=Pgt;h.set(l.origin,l.direction),h.near=e.near,h.far=e.far,h.layers.mask=e.layers.mask;let d=h.intersectObject(t,!1);d.length>0&&i.push({...d[0],object:r?a:t})}}}var q5,Pgt,Rgt,Dgt,nj,UM,Ngt,KO,ZO,QO,eb,Hs,GG=G(()=>{ns(),j5(),la(),n0(),dt(),q5=512,Pgt=new j7,Rgt=new bt,Dgt=new pc,nj=new ta}),D3t=G(()=>{dt(),ZS(),QS(),UM=class extends $v(jpt){constructor(t,e=6710886){super(t,e),this.object=t,this.matrix=t.matrixWorld,this.name=`SpotLightHelper: ${t.uuid}`}raycast(t,e){Xv(this.object,UM.geometryHelper,t,e)}update(){if(this.object!==void 0){let t=UM._vector,e=this.object.distance?this.object.distance:1e3,i=e*Math.tan(this.object.angle);this.cone.scale.set(i,i,e),t.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(t);let r=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let s=0,n=this.cone.material.length;s<n;s++)this.cone.material[s].color.set(r);else this.cone.material.color.set(r)}}},(Ngt=UM)._vector=new P}),H5=G(()=>{dt(),D3t(),nT(),KO=new P,ZO=new P,QO=new Me,eb=class extends G5(Vg,Ngt){constructor(t,e,i){super(),this.super_Entity(t,e),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let r=this.shadow.camera;r.fov=2*qt.RAD2DEG*this.angle,r.aspect=1,r.near=100,r.far=2500;let s=new wS(this.shadow.camera);s.visible=!1,this.gizmos.shadowmap=s,this.update()}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this.gizmos){let e=this.gizmos[t];e instanceof wS&&e.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),ZO.setFromMatrixPosition(this.matrixWorld),QO.setFromRotationMatrix(this.matrixWorld),KO.copy(this.up).applyQuaternion(QO).negate().multiplyScalar(this.distance),this.target.position.copy(ZO).add(KO),this.target.updateMatrixWorld(),this.objectHelper&&this.objectHelper.update()}updateState(t,e){this.updateState_Light(t,e),t.distance!==void 0&&(this.distance=t.distance),t.decay!==void 0&&(this.decay=t.decay),t.angle!==void 0&&(this.angle=t.angle),t.penumbra!==void 0&&(this.penumbra=t.penumbra),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.penumbraSize!==void 0&&e.scene.markPenumbraSizeDirty(),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}}}),Dc=G(()=>{ke(),Qh(),dt(),vo(),Rc(),LG(),R5(),W5(),Fi(),wm(),dt(),n0(),Sm(),GG(),H5(),Ii(),sT(),Hs=class extends B5(Yu){constructor(t,e,i){if(super(),this.data=e,this.bgColor=new Dr(1,1,1,1),this.fog=null,this.backupFog=new l8(16777215,.1,2e3),this.fogUseBGColor=!1,this.fogMode="linear",this.fogDensity=ia.getDensity({}),this.fogHeightFalloff=ia.getHeightFalloff({}),this.fogHeightBase=ia.getHeightBase({}),this.isActive=!1,this.skyState=null,this.skyStateVersion=0,this.gradingState=null,this.skyHdriHolder=null,this.aoColor=new ae,this.penumbraSizeArrayCache=null,this.super_Entity(t,e),this.personalCamera=new ln(i0,{...G2.defaultData,...e.camera,name:"Personal Camera"}),this.personalCamera.objectHelper.visible=!1,this.add(this.personalCamera),this.activeCamera=this.personalCamera,this.ambientLight=new _5(13882323,8553090,.75*Math.PI),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.ambientLight.removeFromParent(),this.add(this.ambientLight),e.uiScene){let r=wU();r===null?Nn("ui-2d","a page's 2D scene"):this.uiScene=new r.Scene2D((Array.isArray(t)?t[0]:t)+"-ui",e.uiScene,{dpr:window.devicePixelRatio,shared:i.shared})}else e.uiFrame&&this.createUICanvas(e.uiFrame,i)}get scene(){return this.parent}get postprocessing(){return this.data.postprocessing}get frameId(){return this.data.uiFrame}get frame(){return this.uiCanvas?.frame}createUICanvas(t,e){let i=wU();i!==null?(this.uiCanvas=new i.UICanvas(this.uuid+"-uiscreen",window.innerWidth,window.innerHeight,e),this.uiCanvas.isScreenSpace=!0,this.uiCanvas.promise.then(()=>{this.uiCanvas?.applyFrame(t),this.uiCanvas?.applySize()})):Nn("ui-2d","a page's UI canvas")}updateVisible(){}setBackgroundColor(t){this.bgColor=t,this.fogUseBGColor===!0&&(this.backupFog.color=t)}entityChildrenCount(){return this.uiScene?this.uiScene.children.length:super.entityChildrenCount()}updateAmbientLight(t,e){t.color!==void 0&&(this.ambientLight.color=Sa(t.color,e)),t.intensity!==void 0&&(this.ambientLight.intensity=t.intensity*Math.PI),t.enabled!==void 0&&(t.enabled?this.add(this.ambientLight):this.remove(this.ambientLight))}onDeactive(){this.isActive=!1}onActive(t){this.isActive=!0,t.fog=this.fog,this.traverseEntity(e=>{e instanceof um&&e.recomputeBoolean()}),this.updateShadow(this.data.shadow)}forceMaterialsUpdate(){this.traverseEntity(t=>{if(t instanceof yo)if(Array.isArray(t.material))for(let e of t.material)e.needsUpdate=!0;else t.material.needsUpdate=!0,t.material.dispose()})}updateShadow(t){if(t.softShadowQuality===void 0&&t.type===void 0||!this.isActive)return;let e=this.data.shadow;uv.isSoft(e)}updateFog(t,e){t.enabled?this.fog=this.backupFog:this.fog=null,this.isActive&&(this.scene.fog=this.fog),this.fogUseBGColor=t.useBackgroundColor,t.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=Sa(t.color,e),this.backupFog.near=t.near,this.backupFog.far=t.far,this.fogMode=ia.getMode(t),this.fogDensity=ia.getDensity(t),this.fogHeightFalloff=ia.getHeightFalloff(t),this.fogHeightBase=ia.getHeightBase(t)}updateSky(t,e){this.skyState=t??null,this.skyStateVersion++;let i=t?.hdri?.image;this.skyHdriHolder=i!=null?e.image(i):null}updateAo(t,e){t.aoColor!==void 0&&(this.aoColor=Sa(t.aoColor,e))}updateByOp(t,e,i,r){let s=this.data.uiFrame;super.updateByOp(t,e,i,r);let n=e;er(t.path,["fog"])?this.updateFog(n.fog,i.shared):er(t.path,["sky"])?this.updateSky(n.sky,i.shared):er(t.path,["grading"])?this.gradingState=n.grading??null:er(t.path,["ao"])?this.updateAo(n.ao,i.shared):er(t.path,["ambient"])?this.updateAmbientLight(n.ambient,i.shared):er(t.path,["shadow"])?this.updateShadow(n.shadow):t.type===0&&t.path.length===0&&(t.props.uiFrame!==void 0||s!==n.uiFrame)&&this.updateUIFrame(t.props.uiFrame,i)}updateUIFrame(t,e){t?(this.uiCanvas||this.createUICanvas(t,e),this.uiCanvas.enabled=!0,this.uiCanvas.applyFrame(t)):this.uiCanvas&&(this.uiCanvas.enabled=!1)}updateState(t,e){this.updateState_Entity(t,e),t.backgroundColor!==void 0&&this.setBackgroundColor(Sa(t.backgroundColor,e.shared)),t.fog!==void 0&&this.updateFog(t.fog,e.shared),t.sky!==void 0&&this.updateSky(t.sky,e.shared),t.grading!==void 0&&(this.gradingState=t.grading),t.ambient!==void 0&&this.updateAmbientLight(t.ambient,e.shared),t.ao!==void 0&&this.updateAo(t.ao,e.shared),t.shadow!==void 0&&this.updateShadow(t.shadow)}createFrame(t,e){}raycast(t,e){super.raycast(t,e)}switchActiveCamera(t){t&&t.isDescendantOf(this)&&(this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=t,t.objectHelper.visible=!1)}get playCamera(){return this.scene?.find(this.data.publish.playCamera)??this.personalCamera}switchToPlayCamera(){this.switchActiveCamera(this.playCamera)}get penumbraSizeArray(){return this.penumbraSizeArrayCache===null&&this.updatePenumbraSizeArray(),this.penumbraSizeArrayCache}updatePenumbraSizeArray(){this.penumbraSizeArrayCache=new Array(bU).fill(.5);let t=0,e=0;this.traverseEntity(i=>{if(!i.visible)return!0;i instanceof tb&&i.visible&&t<DP&&(this.penumbraSizeArrayCache[t]=i.data.penumbraSize??.5,t+=1),i instanceof eb&&i.visible&&t<bU-DP&&(this.penumbraSizeArrayCache[DP+e]=i.data.penumbraSize??.5,e+=1)})}raycastWithClones(t){let e=[],i=r=>{for(let s of r.children){let n=s.cloner;Mi.is(s)&&(s.visible||n?.object.data.visible)&&((Hh(s)||IR(s)&&this.scene.enableHelpers&&s.objectHelper.visible)&&(t.intersectObject(s,!1,e),sj(s,t,e,!0)),i(s))}};return i(this),e}updateEntity2DByOp(t,e,i,r){this.uiCanvas?.updateEntity2DByOp(t,e,i,r)}}});function FK(){return WG}function JO(){if(aj===null)throw new Error('[spe] Classic (WebGL) particles are not available in this build \u2014 it was compiled WebGPU-only. Re-export the scene with renderer "Both" or "WebGL 2", or load the full runtime.');return aj}function tI(t){return t?.isWebGPUSplineRenderer===!0}var WG,aj,Ogt=G(()=>{WG=null,aj=null});function oj(){return HG}var qG,HG,$G=G(()=>{qG=null,HG=null});function UK(t,e,i){return Jw.setRGB(t,e,i,Ds),{r:Jw.r,g:Jw.g,b:Jw.b}}function N3t(t,e,i){let r,s=VS(t.angle,0),[n,a]=lj(t.offset),[o,l]=lj(t.morph),u=t.colors??[],h=t.steps??[],d=Math.min(10,u.length,h.length);if(d===0)return[1,1,1,1];if(t.gradientType===1){let g=3*(e+o)-(e+n)-1,y=3*(i+l)-(i+a)-1;r=Math.hypot(g,y)+s}else if(t.gradientType===2){let g=-1*Math.atan2(e+o-.5+n,i+l-.5+a),y=s/Math.PI/-2+.5*g/Math.PI;r=y-Math.floor(y)}else{let g=.5+o/(e!==0?e:1e-6),y=l/(i!==0?i:1e-6),v=Math.cos(s)*g-Math.sin(s)*y,b=Math.sin(s)*g+Math.cos(s)*y,_=v*v+b*b;r=_>1e-12?(((e-.5+n)/2+v/2)*v+((i-.5+a)/2+b/2)*b)/_:0}let c=u[0][0],p=u[0][1],m=u[0][2],f=u[0][3];for(let g=1;g<d;g++){let y=h[g-1],v=h[g]-y,b=v!==0?Math.min(1,Math.max(0,(r-y)/v)):r>=y?1:0;t.smooth&&(b=b*b*(3-2*b)),c+=(u[g][0]-c)*b,p+=(u[g][1]-p)*b,m+=(u[g][2]-m)*b,f+=(u[g][3]-f)*b}return[c,p,m,f]}function O3t(t,e){let i=t,r=i?.data?.layers;if(r&&typeof r.forEach=="function"){let s=e,n=[];return r.forEach(a=>{let o=a.data;if(o.visible===!1||o.isMask===!0)return;let l=VS(o.alpha,1);if(!(l<=0))if(o.type==="color"){let u,h=o.color;typeof h=="string"?u=typeof s?.color=="function"?s.color(h):void 0:h&&typeof h.r=="number"&&(u=h),u&&n.push({kind:"color",layer:o,rgb:{...UK(u.r,u.g,u.b),a:u.a??1},alpha:l})}else o.type==="gradient"&&n.push({kind:"gradient",layer:o,alpha:l})}),n.length===0?null:(a,o)=>{let l=1,u=1,h=1,d=!0;for(let c of n){let p,m,f,g;if(c.kind==="color")({r:p,g:m,b:f}=c.rgb),g=c.rgb.a;else{let[v,b,_,x]=N3t(c.layer,a,o);({r:p,g:m,b:f}=UK(v,b,_)),g=x}let y=d?1:Math.min(1,Math.max(0,g*c.alpha));l+=(p-l)*y,u+=(m-u)*y,h+=(f-h)*y,d=!1}return{r:l,g:u,b:h}}}if(i?.color&&i.color.isColor===!0){let{r:s,g:n,b:a}=i.color;return()=>({r:s,g:n,b:a})}return null}var Jw,VS,lj,I3t=G(()=>{dt(),Jw=new ae,VS=(t,e)=>typeof t=="number"&&Number.isFinite(t)?t:e,lj=t=>Array.isArray(t)&&typeof t[0]=="number"&&typeof t[1]=="number"?[t[0],t[1]]:[0,0]});function B3t(t,e){if(t==="torus"){let l=e()*Math.PI*2,u=e()*Math.PI*2,h=Math.cos(l),d=Math.sin(l),c=Math.cos(u),p=Math.sin(u);return{x:(1.4+.7*c)*h,y:-(1.4+.7*c)*d,z:.7*p,nx:c*h,ny:-c*d,nz:p,cr:1,cg:1,cb:1}}if(t==="cylinder"){let l=e()*Math.PI*2,u=Math.cos(l),h=Math.sin(l);return{x:.8*u,y:1.6*(e()-.5),z:.8*h,nx:u,ny:0,nz:h,cr:1,cg:1,cb:1}}let i=e()*Math.PI*2,r=2*e()-1,s=Math.acos(r),n=Math.sin(s)*Math.cos(i),a=Math.cos(s),o=Math.sin(s)*Math.sin(i);return{x:n,y:a,z:o,nx:n,ny:a,nz:o,cr:1,cg:1,cb:1}}function V3t(t){let{geometry:e,matrix:i}=t,r=e.getAttribute("position");if(!r||r.count<3)return null;let s=e.getAttribute("normal"),n=e.getAttribute("uv"),a=e.getAttribute("color"),o=e.getIndex(),l=o?o.count/3:r.count/3;if(l<1)return null;let u=(y,v)=>o?o.getX(3*y+v):3*y+v,h=i?i.elements:null,d=i?new Ts().getNormalMatrix(i).elements:null,c=y=>{let v=r.getX(y),b=r.getY(y),_=r.getZ(y);return h?h[0]*v+h[4]*b+h[8]*_+h[12]:v},p=y=>{let v=r.getX(y),b=r.getY(y),_=r.getZ(y);return h?h[1]*v+h[5]*b+h[9]*_+h[13]:b},m=y=>{let v=r.getX(y),b=r.getY(y),_=r.getZ(y);return h?h[2]*v+h[6]*b+h[10]*_+h[14]:_},f=new Float64Array(l),g=0;for(let y=0;y<l;y++){let v=u(y,0),b=u(y,1),_=u(y,2),x=c(v),S=p(v),w=m(v),T=c(b)-x,A=p(b)-S,M=m(b)-w,C=c(_)-x,R=p(_)-S,O=m(_)-w,N=A*O-M*R,B=M*C-T*O,k=T*R-A*C;g+=.5*Math.sqrt(N*N+B*B+k*k),f[y]=g}return g<=0?null:{total:g,sample:(y,v)=>{let b=0,_=l-1;for(;b<_;){let Q=b+_>>1;f[Q]<y?b=Q+1:_=Q}let x=b,S=u(x,0),w=u(x,1),T=u(x,2),A=v(),M=v();A+M>1&&(A=1-A,M=1-M);let C,R,O,N=1-A-M,B=c(S)*N+c(w)*A+c(T)*M,k=p(S)*N+p(w)*A+p(T)*M,z=m(S)*N+m(w)*A+m(T)*M;if(s){if(C=s.getX(S)*N+s.getX(w)*A+s.getX(T)*M,R=s.getY(S)*N+s.getY(w)*A+s.getY(T)*M,O=s.getZ(S)*N+s.getZ(w)*A+s.getZ(T)*M,d){let Q=d[0]*C+d[3]*R+d[6]*O,it=d[1]*C+d[4]*R+d[7]*O,at=d[2]*C+d[5]*R+d[8]*O;C=Q,R=it,O=at}}else{let Q=c(S),it=p(S),at=m(S),St=c(w)-Q,yt=p(w)-it,Y=m(w)-at,pt=c(T)-Q,xt=p(T)-it,Tt=m(T)-at;C=yt*Tt-Y*xt,R=Y*pt-St*Tt,O=St*xt-yt*pt}let L=Math.sqrt(C*C+R*R+O*O)||1,V=1,q=1,j=1;if(a)V=a.getX(S)*N+a.getX(w)*A+a.getX(T)*M,q=a.getY(S)*N+a.getY(w)*A+a.getY(T)*M,j=a.getZ(S)*N+a.getZ(w)*A+a.getZ(T)*M;else if(t.sampleColor){let Q=n?n.getX(S)*N+n.getX(w)*A+n.getX(T)*M:.5,it=n?n.getY(S)*N+n.getY(w)*A+n.getY(T)*M:.5,at=t.sampleColor(Q,it);at&&(V=at.r,q=at.g,j=at.b)}return{x:B,y:k,z,nx:C/L,ny:R/L,nz:O/L,cr:V,cg:q,cb:j}}}}function jK(t){let e=Math.min(Math.max(1,Math.floor(t.guideStrands)),yv),i=function(l){let u=l>>>0;return()=>{u|=0,u=u+1831565813|0;let h=Math.imul(u^u>>>15,1|u);return h=h+Math.imul(h^h>>>7,61|h)^h,((h^h>>>14)>>>0)/4294967296}}(t.seed??1337),r=t.shape==="object"&&t.sampler,s=r?t.samplerRadius??Lh:Lh,n=new Float32Array(4*ec),a=new Float32Array(ec),o=new Float32Array(4*yv).fill(1);for(let l=0;l<e;l++){let u=r?t.sampler(i):B3t(t.shape,i),h=r?u.x:u.x*s,d=r?u.y:u.y*s,c=r?u.z:u.z*s,{nx:p,ny:m,nz:f}=u;o[4*l+0]=u.cr,o[4*l+1]=u.cg,o[4*l+2]=u.cb;let g,y,v,b=l*mg,_=(1.8+.8*i())*t.hairLength*s/(mg-1),x=.5+1.5*i(),S=(.02+.06*i())*s;Math.abs(m)<.99?(g=-f,y=0,v=p):(g=1,y=0,v=0);let w=Math.sqrt(g*g+y*y+v*v)||1;for(let T=0;T<mg;T++){let A=T/(mg-1),M=A*A*.4*s,C=S*Math.sin(A*x*Math.PI*2),R=4*(b+T);n[R+0]=h+p*_*T+C*g/w,n[R+1]=d+m*_*T-M+C*y/w,n[R+2]=c+f*_*T+C*v/w,n[R+3]=T===0?0:1,T<mg-1&&(a[b+T]=_)}}return{initialPositions:n,restLengths:a,unitScale:s,rootColors:o}}var mg,yv,ec,Lh,Up,d_,F0,sf,U0,LP,Igt=G(()=>{dt(),ec=(yv=16384)*(mg=32),Lh=100}),Bgt=G(()=>{dt(),la(),$G(),I3t(),Igt(),Up=1/60,d_=new bt,F0=new Me,sf=new P,U0=new P,LP=class extends Bs{constructor(t,e,i){super(t,e),this.type="HairSystem",this.isHairSystem=!0,this.simRunning=!1,this.previewRequested=!1,this.playModeActive=!1,this.pendingSimSeconds=0,this.simTime=0,this.resetRequested=!0,this.generation=0,this.settledSimSeconds=0,this.lastMotionFingerprint=0,this.lastBoneQuat=new Me,this.lastBonePos=new P,this.hasLastBone=!1,this.baseFoundAtRegen=!1,this.baseSourceGeomsAtRegen=[],this.baseSourceHashesAtRegen=[],this.baseColorHashAtRegen=0,this.baseScaleAtRegen=0,this.classicFallbackWarned=!1,this.regenSnapshot=null,this.context=i,this.data=e,this.geometry.setAttribute("position",new we(new Float32Array(0),3)),this.material=new Uo({colorWrite:!1,depthWrite:!1}),this.frustumCulled=!1,this.scalpMesh=new Sr(new Tc(Lh,48,32),new Uo({color:5448477})),this.scalpMesh.name="HairScalp",this.add(this.scalpMesh);let r=new $4;r.setAttribute("position",new we(new Float32Array(12),3)),r.setIndex([0,2,1,2,3,1]),r.instanceCount=0,this.ribbonMesh=new Sr(r,new Uo({visible:!1})),this.ribbonMesh.name="HairRibbons",this.ribbonMesh.frustumCulled=!1,this.ribbonMesh.visible=!1,this.ribbonMesh.matrixAutoUpdate=!1,this.ribbonMesh.updateMatrixWorld=()=>{this.ribbonMesh.matrixWorld.identity()},this.ribbonMesh.updateWorldMatrix=()=>{this.ribbonMesh.matrixWorld.identity()},this.add(this.ribbonMesh),this.activeGuideStrands=e.guideStrands,this.roots=this.buildRoots(),this.regenSnapshot={guideStrands:e.guideStrands,hairLength:e.hairLength,spreadRadius:e.spreadRadius,headShape:e.headShape,baseObjectId:e.baseObjectId},this.applyScalpState(),this.applyShadowState(),this.syncSimRunning()}update(t){!this.simRunning||(this.pendingSimSeconds=Math.min(this.pendingSimSeconds+t/1e3,4*Up*2),this.trackMotionRest(t/1e3))}trackMotionRest(t){this.boneTransform(F0,sf);let e=this.hasLastBone&&(Math.abs(this.lastBoneQuat.dot(F0))<.9999995||this.lastBonePos.distanceToSquared(sf)>1e-8),i=this.motionFingerprint(),r=!this.hasLastBone||e||this.resetRequested||i!==this.lastMotionFingerprint||this.data.windStrength>.001;this.lastBoneQuat.copy(F0),this.lastBonePos.copy(sf),this.lastMotionFingerprint=i,this.hasLastBone=!0,this.settledSimSeconds=r?0:this.settledSimSeconds+t}motionFingerprint(){let t=this.data;return t.gravity+2*t.damping+3*t.localStiffness+4*t.globalStiffness+5*t.globalRange+6*t.stiffnessFalloff+7*t.windStrength+8*t.vspCoefficient+9*t.kink+10*t.kinkFrequency+11*t.clumpStrength+12*t.clumpSize+13*t.clumpTipScale}get isSimulating(){return(this.simRunning||this.resetRequested)&&this.visible}get isMotionSettled(){return this.settledSimSeconds>6}get isVisiblyAnimating(){return this.isSimulating&&!this.isMotionSettled}startPreview(){this.previewRequested=!0,this.syncSimRunning()}stopPreview(){this.previewRequested=!1,this.syncSimRunning()}setPlayMode(t){this.playModeActive=t,t&&this.resetSimulation(),this.syncSimRunning()}resetSimulation(){this.resetRequested=!0,this.pendingSimSeconds=0,this.simTime=0,this.settledSimSeconds=0}warnClassicFallbackOnce(){this.classicFallbackWarned||(this.classicFallbackWarned=!0,console.warn("[spline] Hair System strands require the WebGPU renderer \u2014 the WebGL fallback shows only the scalp. Reload with ?renderer=webgpu in a WebGPU-capable browser."))}syncSimRunning(){this.simRunning=this.playModeActive||this.previewRequested||this.data.autoPlay}updateState(t,e){super.updateState(t,e),this.updateHairState(t)}updateHairState(t){if((t.guideStrands!==void 0||t.hairLength!==void 0||t.spreadRadius!==void 0||t.headShape!==void 0||t.baseObjectId!==void 0)&&this.regenerate(),(t.headShape!==void 0||t.baseObjectId!==void 0)&&this.applyScalpState(),t.headColor!==void 0){let e=this.scalpMesh.material;e.isMeshBasicMaterial===!0&&e.color.setRGB(t.headColor.r,t.headColor.g,t.headColor.b,Ds)}(t.castShadow!==void 0||t.receiveShadow!==void 0)&&this.applyShadowState(),t.autoPlay!==void 0&&this.syncSimRunning()}applyShadowState(){let t=this.data.castShadow??!0,e=this.data.receiveShadow??!0;this.castShadow=t,this.receiveShadow=e,this.scalpMesh.castShadow=t,this.scalpMesh.receiveShadow=e,this.ribbonMesh.castShadow=t,this.ribbonMesh.receiveShadow=e}regenerate(){this.activeGuideStrands=Math.max(1,Math.min(Math.floor(this.data.guideStrands),16384)),this.roots=this.buildRoots(),this.generation++,this.regenSnapshot={guideStrands:this.data.guideStrands,hairLength:this.data.hairLength,spreadRadius:this.data.spreadRadius,headShape:this.data.headShape,baseObjectId:this.data.baseObjectId},this.resetSimulation()}checkDataDrift(){let t=this.data,e=this.regenSnapshot;if(e===null||e.guideStrands!==t.guideStrands||e.hairLength!==t.hairLength||e.spreadRadius!==t.spreadRadius||e.headShape!==t.headShape||e.baseObjectId!==t.baseObjectId){let i=e===null||e.headShape!==t.headShape||e.baseObjectId!==t.baseObjectId;this.regenerate(),i&&this.applyScalpState()}this.syncSimRunning(),this.applyShadowState(),this.checkBaseDrift()}buildRoots(){let{headShape:t,baseObjectId:e,guideStrands:i,hairLength:r}=this.data;if(this.baseFoundAtRegen=!1,this.baseSourceGeomsAtRegen=[],this.baseSourceHashesAtRegen=[],this.baseColorHashAtRegen=0,this.baseScaleAtRegen=0,t==="object"&&e){let s=this.context.scene.find(e);if(s){this.baseFoundAtRegen=!0,s.updateWorldMatrix(!0,!0);let n=this.collectBaseSources(s),a=n?function(o){let l=[];for(let d of o){let c=V3t(d);c&&l.push(c)}if(l.length===0)return null;let u=new Float64Array(l.length),h=0;for(let d=0;d<l.length;d++)h+=l[d].total,u[d]=h;return h<=0?null:d=>{let c=d()*h,p=0,m=l.length-1;for(;p<m;){let g=p+m>>1;u[g]<c?p=g+1:m=g}let f=p===0?c:c-u[p-1];return l[p].sample(f,d)}}(n.sources):null;if(this.baseSourceGeomsAtRegen=n?.sources.map(o=>o.geometry)??[],this.baseSourceHashesAtRegen=n?.hashes??[],this.baseColorHashAtRegen=n?.colorHash??0,n&&a){let o=this.baseWorldScale(s),l=Math.max(n.radius*o,.001);this.baseScaleAtRegen=o;let u=o;return jK({shape:"object",guideStrands:i,hairLength:r,sampler:h=>{let d=a(h);return{...d,x:d.x*u,y:d.y*u,z:d.z*u}},samplerRadius:l})}}}return jK({shape:t==="object"?"sphere":t,guideStrands:i,hairLength:r})}collectBaseSources(t){let e=[],i=[],r=0,s=0;d_.copy(t.matrixWorld).invert();let n=d_.clone(),a=o=>{if(o.isHairSystem===!0||o!==t&&o.visible===!1)return;let l=o.geometry;if(o.isMesh===!0&&l&&(l.getAttribute("position")?.count??0)>=3){let u=o===t?void 0:new bt().multiplyMatrices(n,o.matrixWorld),h=Array.isArray(o.material)?o.material[0]:o.material;e.push({geometry:l,matrix:u,sampleColor:O3t(h,this.context.shared)??void 0}),i.push(LP.matrixHash(u)),s+=function(c,p){let m=c,f=0,g=1,y=b=>{f+=b*g,g+=1},v=m?.data?.layers;if(v&&typeof v.forEach=="function"){let b=p;v.forEach(_=>{let x=_.data;if(x.visible!==!1){if(x.type==="color"){let S=x.color,w=typeof S=="string"?typeof b?.color=="function"?b.color(S):void 0:S;w&&typeof w.r=="number"&&(y(w.r),y(w.g),y(w.b)),y(VS(x.alpha,1))}else if(x.type==="gradient"){let S=x;for(let w of S.colors??[])y(w[0]),y(w[1]),y(w[2]),y(w[3]);for(let w of S.steps??[])y(w);y(VS(S.angle,0)),y(S.gradientType),y(S.smooth?1:0)}}})}else m?.color&&m.color.isColor===!0&&(y(m.color.r),y(m.color.g),y(m.color.b));return f}(h,this.context.shared),l.boundingSphere===null&&l.computeBoundingSphere();let d=l.boundingSphere;if(d){let c=0,p=1;u?(sf.copy(d.center).applyMatrix4(u),c=sf.length(),p=LP.matrixMaxScale(u)):c=d.center.length(),r=Math.max(r,c+d.radius*p)}}for(let u of o.children)a(u)};return a(t),e.length===0?null:{sources:e,hashes:i,radius:Math.max(r,.001),colorHash:s}}static matrixHash(t){if(!t)return 0;let e=t.elements,i=0;for(let r=0;r<16;r++)i+=e[r]*(r+1);return i}static matrixMaxScale(t){let e=t.elements,i=Math.hypot(e[0],e[1],e[2]),r=Math.hypot(e[4],e[5],e[6]),s=Math.hypot(e[8],e[9],e[10]);return Math.max(i,r,s,1e-6)}baseWorldScale(t){return d_.copy(t.matrixWorld).decompose(sf,F0,U0),Math.max(Math.abs(U0.x),Math.abs(U0.y),Math.abs(U0.z),1e-6)}get widthWorldScale(){return this.data.headShape==="object"&&this.data.baseObjectId&&this.baseScaleAtRegen>0?this.baseScaleAtRegen:1}checkBaseDrift(){if(this.data.headShape!=="object"||!this.data.baseObjectId)return;let t=this.context.scene.find(this.data.baseObjectId);if(!t)return;if(!this.baseFoundAtRegen)return void this.regenerate();t.updateWorldMatrix(!0,!0);let e=this.collectBaseSources(t),i=e?.sources??[],r=e?.hashes??[],s=this.baseSourceGeomsAtRegen,n=this.baseSourceHashesAtRegen,a=i.length!==s.length;if(!a){for(let o=0;o<i.length;o++)if(i[o].geometry!==s[o]||Math.abs(r[o]-n[o])>1e-4*Math.max(Math.abs(n[o]),1)){a=!0;break}}if(!a&&this.data.hairColorSource==="object"&&(e?.colorHash??0)!==this.baseColorHashAtRegen&&(a=!0),!a&&i.length>0){let o=this.baseWorldScale(t);a=Math.abs(o-this.baseScaleAtRegen)>.001*Math.max(this.baseScaleAtRegen,1e-6)}a&&this.regenerate()}applyScalpState(){let t=this.data.headShape,e=t==="object"&&this.data.baseObjectId!==null;this.scalpMesh.visible=!e,!e&&(this.scalpMesh.geometry.dispose(),this.scalpMesh.geometry=t==="torus"?new H4(1.4*Lh,.7*Lh,24,48):t==="cylinder"?new V2(.8*Lh,.8*Lh,1.6*Lh,48,1):new Tc(Lh,48,32))}boneTransform(t,e){let i=this.matrixWorld;if(this.data.headShape==="object"&&this.data.baseObjectId){let r=this.context.scene.find(this.data.baseObjectId)?.matrixWorld;r&&(i=r)}d_.copy(i).decompose(e,t,U0)}raycast(t,e){if(!this.scalpMesh.visible)return;let i=[];this.scalpMesh.raycast(t,i);for(let r of i)r.object=this,e.push(r)}get shadowBoundsRadius(){let t=this.data.headShape==="torus"?2.6:1.5;return this.roots.unitScale*(t+2.6*Math.max(this.data.hairLength,0))}getShadowBoundsCenter(t){return this.boneTransform(F0,t),t}updateEntityBoxSize(t,e){let i=this.shadowBoundsRadius;t.set(0,0,0),e.set(i,i,i)}dispose(){super.dispose(),this.scalpMesh.geometry.dispose(),this.scalpMesh.material.dispose(),this.ribbonMesh.geometry.dispose(),this.ribbonMesh.material.dispose?.(),oj()?.release(this)}}});function FP(){return{shapeInput:()=>`
|
|
353
|
+
`&&M.push("")):S.getTextWidth(M[M.length-1]+C,x)>A&&(M[M.length-1].length&&M.push(""),S.getTextWidth(M[M.length-1]+C,x)>A&&(C.length===1?(M[M.length-1]+=C,C=""):(M[M.length-1]+=C.slice(0,-1),C=C[C.length-1],M.push(""))));return M[M.length-1]+=C,M}(t,i,u===2?d.toUpperCase():u===3?d.toLowerCase():d,e),{shapes:p,charWidths:m,charCoords:f}=i.generateShapes(c,t,e),g=.5*(typeof r=="number"?r:Number(e.getVariable(r))),y=.5*(typeof s=="number"?s:Number(e.getVariable(s))),v=p.map(x=>new ds().fromShape(x,!0));this.vectorShapes=v;let b=v.map(x=>xm.create({shape:x,parameters:{depth:n,extrudeBevelSegments:o,extrudeBevelSize:a,uvPitch:h,windingRule:n<=0?ss.NONZERO:ss.ODD,subdivisions:this.isLowResolution&&n>0?1:12}})),_=b.length?wg(b):bK();_.translate(-g,y,0),this.dispose(),this.wrappedText=c,this.charCoords=f,this.charWidths=m,this.deleteAttribute("extrudeNormal"),Object.entries(_.attributes).forEach(([x,S])=>{this.setAttribute(x,S)}),this.setIndex(_.index),this.adoptNearSide(b,n),this.computeBoundingSphere()}adoptNearSide(t,e){this._depth=e;let i=0,r=0,s=0;for(let o of t){let l=o,u=l._nearSide;if(u===void 0||u.length===0)return this._nearSide=new Uint8Array(0),this._effectiveBevel=0,void(this._vScale=0);i+=u.length,r=Math.max(r,l._effectiveBevel??0),s=l._vScale??s}this._effectiveBevel=r,this._vScale=s;let n=new Uint8Array(i),a=0;for(let o of t){let l=o._nearSide;n.set(l,a),a+=l.length}this._nearSide=n}takeDepthStateFrom(t){let e=t;e._nearSide!==void 0&&(this._depth=e._depth??this._depth,this._nearSide=e._nearSide,this._vScale=e._vScale??this._vScale,this._effectiveBevel=e._effectiveBevel??this._effectiveBevel)}canShiftDepthTo(t){return this._nearSide.length===this.getAttribute("position")?.count&&X1(this._effectiveBevel,t)&&X1(this._effectiveBevel,this._depth)}shiftDepthTo(t){if(!this.canShiftDepthTo(t))return!1;let e=t-this._depth;if(this._depth=t,e===0)return!0;let i=this.getAttribute("position"),r=i.array,s=this.getAttribute("uv"),n=s?.array,a=this._vScale>0?e/this._vScale:0,o=this._nearSide;for(let l=0;l<o.length;l++){let u=o[l];u!==0&&(r[3*l+2]+=e,u===2&&n!==void 0&&(n[2*l+1]+=a))}return i.needsUpdate=!0,s!==void 0&&a!==0&&(s.needsUpdate=!0),this.refreshDepthBounds(t),!0}refreshDepthBounds(t){if(this.boundingBox===null&&this.boundingSphere===null)return;this.boundingBox===null&&this.computeBoundingBox();let e=this.boundingBox;e.min.z=Math.min(0,t),e.max.z=Math.max(0,t),this.boundingSphere!==null&&e.getBoundingSphere(this.boundingSphere)}clone(){let t=$a(new ye,WU.prototype);return t.copy(this),console.log("CloneGeometry",this,t),t}copy(t){return Object.entries(t.attributes).forEach(([e,i])=>{this.setAttribute(e,i)}),this.setIndex(t.index),this.userData={parameters:{...t.userData.parameters},type:"TextGeometry"},this}async setText(t,e){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:{textValue:t}},e)}get text(){return this.userData.parameters.text??""}}});function T3t(t){if(!qU)return xK||(xK=async function(){let e=t??"https://cdn.spline.design/@splinetool/runtime@2.0.61/build",i=import("./process.js"),[r,s]=await Promise.all([i,fetch(`${e}/process.wasm`).then(o=>o.arrayBuffer())]),n=r.default,a=await n({wasmBinary:s});ggt(a),qU=!0}())}var ggt,NG,qU,xK,F5=G(()=>{NG=new Promise(t=>{ggt=t}),qU=!1});function BO(t,e){if(Object.keys(t.morphAttributes).length>0||Object.keys(e.morphAttributes).length>0)return!1;let i=Object.keys(t.attributes),r=Object.keys(e.attributes);if(i.length!==r.length)return!1;for(let l of r){let u=t.attributes[l],h=e.attributes[l];if(u===void 0||u.isInterleavedBufferAttribute===!0||h.isInterleavedBufferAttribute===!0||u.itemSize!==h.itemSize||u.normalized!==h.normalized||u.array.constructor!==h.array.constructor||u.array.length!==h.array.length)return!1}let s=t.index,n=e.index;if(s===null!=(n===null))return!1;let a=!1;if(s!==null&&n!==null){if(s.array.length!==n.array.length)return!1;let l=s.array.constructor,u=n.array.constructor;if(l!==u){if(l!==Uint32Array||u!==Uint16Array)return!1;a=!0}}if(t.groups.length!==e.groups.length)return!1;for(let l=0;l<e.groups.length;l++){let u=t.groups[l],h=e.groups[l];if(u.start!==h.start||u.count!==h.count||u.materialIndex!==h.materialIndex)return!1}for(let l of r){let u=t.attributes[l],h=e.attributes[l];u.array.set(h.array),u.needsUpdate=!0}let o=t.takeDepthStateFrom;if(typeof o=="function"&&o.call(t,e),s!==null&&n!==null){if(a){let l=s.array,u=n.array;for(let h=0,d=u.length;h<d;h++){let c=u[h];l[h]=c===65535?4294967295:c}}else s.array.set(n.array);s.needsUpdate=!0}return t.drawRange.start=e.drawRange.start,t.drawRange.count=e.drawRange.count,t.userData=e.userData,t.boundingBox=null,t.boundingSphere=null,!0}function HU(t,e,i,r){let s,n,a,o=t.position.array,l=t.normal.array,u=ygt.makeScale(e,i,r).invert().elements;for(let h=0,d=o.length;h<d;h+=3)o[h]*=e,o[h+1]*=i,o[h+2]*=r,s=l[h],n=l[h+1],a=l[h+2],l[h]=u[0]*s+u[4]*n+u[8]*a,l[h+1]=u[1]*s+u[5]*n+u[9]*a,l[h+2]=u[2]*s+u[6]*n+u[10]*a;t.position.needsUpdate=!0,t.normal.needsUpdate=!0}var ygt,vgt=G(()=>{dt(),ygt=new bt});function $U(t){let e=Number(t);return Number.isInteger(e)&&e>=0&&String(e)===t?e:-1}function kM(t){if(t!=null){if(Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView))return t;if(typeof t=="object")return function(e){let i=Object.keys(e),r=0;for(let n of i){let a=$U(n);a>=r&&(r=a+1)}if(r===0||r>i.length)return;let s=new Array(r);for(let n=0;n<r;n++){let a=e[n];if(typeof a!="number")return;s[n]=a}return s}(t)}}function VO(t){if(t==null)return"missing";if(Array.isArray(t))return`Array(${t.length})`;if(ArrayBuffer.isView(t)){let l=t;return`${t.constructor.name}(${l.length})`}if(typeof t!="object")return typeof t;let e=Object.keys(t),i=e.filter(l=>$U(l)===-1),r=0;for(let l of e){let u=$U(l);u>=r&&(r=u+1)}let s=t,n=-1,a=-1;for(let l=0;l<r;l++)l in s?typeof s[l]!="number"&&a===-1&&(a=l):n===-1&&(n=l);let o=[`${e.length} keys`,"max index "+(r-1)];return n!==-1&&o.push(`first missing index ${n}`),a!==-1&&o.push(`non-number at ${a} (${typeof s[a]})`),i.length&&o.push(`stray keys ${i.slice(0,3).join(",")}`),`Object{${o.join(", ")}}`}function bgt(t){let e=Object.keys(t);return e.length===1&&e[0]==="subdivisions"}function OG(t,e){let i=e?e.count:t.count,r=0,s=1e4,n=new Map,a=new Uint32Array(i),o=[];for(let h=0;h<i;h++){let d=e?e.getX(h):h,c=t.getX(d),p=t.getY(d),m=t.getZ(d),f=Math.round(c*s),g=Math.round(p*s),y=Math.round(m*s),v=n.get(f);v===void 0&&(v=new Map,n.set(f,v));let b=v.get(g);b===void 0&&(b=new Map,v.set(g,b));let _=b.get(y);_===void 0&&(_=r++,b.set(y,_),o.push(c,p,m)),a[h]=_}let l=[],u=[];for(let h=0;h<a.length;h+=3)a[h]===a[h+1]||a[h]===a[h+2]||a[h+1]===a[h+2]||(l.push(a[h],a[h+1],a[h+2]),u.push(e?e.getX(h):h,e?e.getX(h+1):h+1,e?e.getX(h+2):h+2));return{positions:o,triIndices:l,triOriginals:u}}var h_,rf,Ie,kO,zO,LO,us,u_,zM,LM,FM,XU,kP,Zv=G(()=>{dt(),F5(),ke(),U5(),vgt(),NS(),h_=new pr,rf=new P,NG.then(t=>{Ie=t}),kO=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),zO=new Uint32Array([0,1,2,3]),LO=new Uint8Array([4]),us=class extends ye{constructor(t,e){super(),this.data=t,this.flatShading=e,this.subdivPointer=0,this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(t,e){this.freeSubdivPointer();let i=this.data.scaleBaked.map(a=>typeof a=="number"?a:1),r=hm.div(e.map(a=>typeof a=="number"?a:0),i);if(r.every(a=>a===1))return;this.subdividedGeometry&&HU(this.subdividedGeometry.attributes,...r),this.originalGeometry&&HU(this.originalGeometry.attributes,...r),this.data=t;let s=this.userData.parameters;this.userData.parameters={width:s.width*r[0],height:s.height*r[1],depth:s.depth*r[2]},this.originalGeometry.boundingSphere.center.multiply(rf.fromArray(r));let n=rf.set(s.width,s.height,s.depth).length();this.originalGeometry.boundingSphere.radius=n/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}mutateDirectlySubdivisions(t){this.freeSubdivPointer(),this.data=t;let e=t.phongAngle??35;this.flatShading&&(e=-1);let i=null;if(t.subdivisions>0){let s=0;try{s=us.allocate(t),i=us.buildRefined(s,t.subdivisions,e)}catch(n){console.error(n,t)}finally{s&&us.freeSubdivPointer(s)}}this.subdividedGeometry?.dispose(),this.subdividedGeometry=i??void 0,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=this.originalGeometry.boundingSphere);let r=this.userData.parameters;Object.assign(this,this.subdividedGeometry??this.originalGeometry),this.userData.parameters=r}rebuild(){let t,e,i;try{({originalGeometry:t,subdividedGeometry:e,subdivPointer:i}=us.build(this.data,void 0,!this.flatShading,void 0))}catch{t=new Zh(100,100,100),i=0}this.subdivPointer=i,this.originalGeometry=t,this.subdividedGeometry=e??void 0;let r=this.subdividedGeometry??this.originalGeometry;Object.assign(this,r),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(us.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let t=this.originalGeometry;t.boundingSphere===null&&(t.boundingSphere=new ta,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=t.boundingSphere));let e=t.attributes.position,i=t.boundingSphere.center;h_.setFromBufferAttribute(e),h_.getCenter(i),t.boundingSphere.radius=i.distanceTo(h_.max),isNaN(t.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),h_.getSize(rf);let r={width:rf.x,height:rf.y,depth:rf.z};return this.userData.parameters=r,r}static build(t,e,i,r){let s,n,a=t?.phongAngle??35;i===!1&&(a=-1),e&&(Ie.free_bvh(e),Ie.free_subdivision_surface(e));try{s=us.allocate(t,r)}catch(l){console.error(l,t),s=us.allocate({positionWASM:kO,indexWASM:zO,verticesPerFaceWASM:LO},r)}Ie.set_destination_refinement_level(s,0);let o=us.buildLevel(s,!0,a);return n=t.subdivisions>0?us.buildRefined(s,t.subdivisions,a):null,{subdivPointer:s,originalGeometry:o,subdividedGeometry:n}}static buildRefined(t,e,i){try{return Ie.set_destination_refinement_level(t,e),us.buildLevel(t,!1,i)??null}catch{try{return Ie.set_destination_refinement_level(t,e-1),us.buildLevel(t,!1,i)??null}catch{return null}}}static primitiveToQuads(t,e,i){t.widthSegments>16&&(t.widthSegments=16),t.heightSegments>16&&(t.heightSegments=16),t.depthSegments>16&&(t.depthSegments=16),t.radialSegments>16&&(t.radialSegments=16),t.type==="DodecahedronGeometry"&&(t.detail=0);let r,s=t.shape!==void 0||t.path!==void 0?e.geometry:im(t,i,!1,e);r=dft(t)?s.getClosedTorusIndicesForBooleanOrSubdiv():s.getIndex();let n,{positions:a,triIndices:o,triOriginals:l}=OG(s.getAttribute("position"),r);if(t.type==="CylinderGeometry"&&t.cornerRadius===0&&t.hollow===0&&t.openEnded===!1){let c=t.radialSegments*t.heightSegments*3*2;n=[c,c+3*t.radialSegments]}let{indices:u,verticesPerFace:h,uvs:d}=function(c,p,m,f,g){let y=[],v=[],b=g?m.getAttribute("uv"):void 0,_=b&&b.itemSize===2?[]:void 0,x=T=>{if(_){let A=g[T];_.push(b.getX(A),b.getY(A))}};if(m.userData.shape!==void 0&&m.userData.parameters.depth===0&&m.userData.shape.shapeHoles.length===0){let T=m.userData.shape.extractShapePointsToFlatArray([]),A=m.userData.parameters.spikes;if(m.userData.type==="EllipseGeometry"&&A<=24&&A%4==0&&m.userData.parameters.angle>=360){let R=T.length/2/A;T=T.filter((O,N)=>Math.floor(N/2)%R===0)}let M=0;for(let R=0;R<T.length;R+=2)M+=(T[R]-T[(R===0?T.length:R)-2])*(T[R+1]+T[(R===0?T.length:R)-1]);c.length=0;let C=0;if(M<0)for(let R=0;R<T.length;R+=2)c.push(T[R],T[R+1],0),y.push(C++);else for(let R=T.length-2;R>=0;R-=2)c.push(T[R],T[R+1],0),y.push(C++);return v.push(C),{indices:y,verticesPerFace:v}}let S=new Float32Array([m.userData.parameters.depth])[0],w=0;for(;w<p.length;){if(m.useNgonForTopBottomFaceDuringBake){let T=0;if((c[3*p[w]+2]===S||c[3*p[w]+2]===0)&&T++,(c[3*p[w+1]+2]===S||c[3*p[w+1]+2]===0)&&T++,(c[3*p[w+2]+2]===S||c[3*p[w+2]+2]===0)&&T++,T===3)break}if(p[w+1]===p[w+3]&&p[w+2]===p[w+5]||p[w+0]===p[w+3]&&p[w+2]===p[w+4]){u_.set(c[3*p[w]],c[3*p[w]+1],c[3*p[w]+2]),zM.set(c[3*p[w+1]],c[3*p[w+1]+1],c[3*p[w+1]+2]),LM.set(c[3*p[w+4]],c[3*p[w+4]+1],c[3*p[w+4]+2]),FM.set(c[3*p[w+5]],c[3*p[w+5]+1],c[3*p[w+5]+2]),zM.sub(u_).normalize(),LM.sub(u_).normalize(),FM.sub(u_).normalize();let T=zM.cross(LM).dot(FM),A=w;Math.abs(T)>.005||f&&f.some((M,C)=>C%2!=1&&A>=f[C]&&A<f[C+1])?(y.push(p[w],p[w+1],p[w+2]),x(w),x(w+1),x(w+2),v.push(3),w+=3):(y.push(p[w],p[w+1],p[w+4],p[w+5]),x(w),x(w+1),x(w+4),x(w+5),v.push(4),w+=6)}else y.push(p[w],p[w+1],p[w+2]),x(w),x(w+1),x(w+2),v.push(3),w+=3}if(m.useNgonForTopBottomFaceDuringBake){let T=[],A=[],M=0;for(let C=0,R=0;C<c.length;C+=3,R++)c[C+2]===0&&(T.push(R),M++),c[C+2]===S&&A.push(R);if(m.userData.parameters.extrudeBevelSize===0){let C=A[0];A[0]=A[1],A[1]=C}T.reverse(),y.push(...T,...A),v.push(M,M),_=void 0}return{indices:y,verticesPerFace:v,uvs:_}}(a,o,s,n,l);return{positions:a,indices:u,verticesPerFace:h,uvs:d}}static allocate(t,e){let i,r,s,n=[],a=[],o=kM(t.positionWASM),l=kM(t.indexWASM),u=kM(t.verticesPerFaceWASM);if(o&&o.length>0){if(!l?.length||!u?.length)throw new Error(`SubdivGeometry.allocate: unusable cage topology \u2014 positionWASM ${VO(t.positionWASM)}, indexWASM ${VO(t.indexWASM)}, verticesPerFaceWASM ${VO(t.verticesPerFaceWASM)}`);i=o,r=l,s=u;let w=kM(t.uvWASM);Ie.alloc_subdivision_surface_uvs&&w&&w.length===2*r.length&&(a=w)}else i=kO,r=zO,s=LO;let h=i.length,d=r.length,c=s.length,p=i.length+n.length+a.length,m=r.length+s.length,f=p*Float32Array.BYTES_PER_ELEMENT+m*Uint32Array.BYTES_PER_ELEMENT,g=p*Float32Array.BYTES_PER_ELEMENT,y=Ie._malloc(f);if(!y)throw new Error(`SubdivGeometry.allocate: wasm _malloc(${f}) failed`);let v,b=new Float32Array(Ie.HEAPF32.buffer,y,p),_=new Uint32Array(Ie.HEAPU32.buffer,y+g,m);b.set(i,0),b.set(n,i.length),b.set(a,i.length+n.length),_.set(r,0),_.set(s,r.length),t?.scaleBaked?.some(w=>w!==1)&&(v=new bt().makeScale(...t.scaleBaked.map(w=>typeof w=="number"?w:1))),e&&(v?v.premultiply(e):v=e);let x=y+(i.length+n.length)*Float32Array.BYTES_PER_ELEMENT,S=a.length?v?Ie.alloc_subdivision_surface_uvs2(y,h,y+g,d,y+g+r.length*Uint32Array.BYTES_PER_ELEMENT,c,x,a.length,v.elements):Ie.alloc_subdivision_surface_uvs(y,h,y+g,d,y+g+r.length*Uint32Array.BYTES_PER_ELEMENT,c,x,a.length):v?Ie.alloc_subdivision_surface2(y,h,y+g,d,y+g+r.length*Uint32Array.BYTES_PER_ELEMENT,c,v.elements):Ie.alloc_subdivision_surface(y,h,y+g,d,y+g+r.length*Uint32Array.BYTES_PER_ELEMENT,c);return Ie._free(y),S}static buildLevel(t,e,i,r,s,n=!1){let a=s?Ie.get_mesh_data2(t,e?Ie.Level.CONTROL:Ie.Level.REFINED,i,s.elements):Ie.get_mesh_data(t,e?Ie.Level.CONTROL:Ie.Level.REFINED,i),o=Ie.HEAPU32.subarray(a>>2,10+(a>>2)),l=o.subarray(4,8),u=0,h=Ie.HEAPU32[o[u]>>2],d=Ie.HEAPF32.subarray(h>>2,(h>>2)+l[u]);u++;let c=Ie.HEAPU32[o[u]>>2],p=Ie.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let m=Ie.HEAPU32[o[u]>>2],f=Ie.HEAPU32.subarray(m>>2,(m>>2)+l[u]);u++;let g,y=Ie.HEAPU32[o[u]>>2],v=Ie.HEAPU32.subarray(y>>2,(y>>2)+l[u]);if(u++,Ie.alloc_subdivision_surface_uvs){let _=o[9];if(_>0){let x=Ie.HEAPU32[o[8]>>2];g=Ie.HEAPF32.subarray(x>>2,(x>>2)+_)}}if(r===void 0){let _=new ye;if(_.setIndex(new om(v,1)),_.setAttribute("position",new fe(d,3)),_.setAttribute("normal",new fe(p,3)),g&&_.setAttribute("uv",new fe(g,2)),e){_.setAttribute("faceMap",new om(f,1));let x=new Float32Array(p.length/3*4).fill(0);_.setAttribute("color",new we(x,4))}return Ie.free_mesh_data(a),_.userData.type="SubdivGeometry",_}if(r.getAttribute("position").copyArray(d),r.getAttribute("normal").copyArray(p),r.attributes.position.needsUpdate=!0,r.attributes.normal.needsUpdate=!0,n){let _=r.getIndex();_!==null&&_.array.length===v.length&&(_.copyArray(v),_.needsUpdate=!0)}let b=r.getAttribute("uv");g&&b&&b.array.length===g.length&&(b.copyArray(g),b.needsUpdate=!0),Ie.free_mesh_data(a)}static freeSubdivPointer(t){Ie.free_bvh(t),Ie.free_subdivision_surface(t)}static buildControlCageWireframe(t,e,i){let r=Ie.get_wireframe_data_for_base_level(t),s=Ie.HEAPU32.subarray(r>>2,4+(r>>2)),n=s.subarray(2,4),a=0,o=Ie.HEAPU32[s[a]>>2],l=Ie.HEAPF32.subarray(o>>2,(o>>2)+n[a]);a++;let u=Ie.HEAPU32[s[a]>>2],h=Ie.HEAPU32.subarray(u>>2,(u>>2)+n[a]);if(e===void 0){let d=new ye;d.setAttribute("position",new fe(l,3));let c=new Float32Array(l.length);for(let p=0,m=l.length;p<m;)c[p++]=i.r,c[p++]=i.g,c[p++]=i.b;return d.setAttribute("color",new we(c,3)),d.setIndex(new om(h,1)),Ie.free_wireframe_data_for_base_level(r),d}e.getAttribute("position").copyArray(l),e.attributes.position.needsUpdate=!0,Ie.free_wireframe_data_for_base_level(r)}static updateCollabMesh(t,e,i){let r=e===0;r||Ie.set_destination_refinement_level(t,e);let s=i?Ie.get_topological_data2(t,r?Ie.Level.CONTROL:Ie.Level.REFINED,i.elements):Ie.get_topological_data(t,r?Ie.Level.CONTROL:Ie.Level.REFINED),n=Ie.HEAPU32.subarray(s>>2,8+(s>>2)),a=n.subarray(3,6),o=0,l=Ie.HEAPU32[n[o]>>2],u=new Float32Array(Ie.HEAPF32.subarray(l>>2,(l>>2)+a[o]));o++;let h=Ie.HEAPU32[n[o]>>2],d=new Uint32Array(Ie.HEAPU32.subarray(h>>2,(h>>2)+a[o]));o++;let c,p=Ie.HEAPU32[n[o]>>2],m=new Uint8Array(Ie.HEAPU32.subarray(p>>2,(p>>2)+a[o]));if(Ie.alloc_subdivision_surface_uvs){let f=n[7];if(f>0){let g=Ie.HEAPU32[n[6]>>2];c=new Float32Array(Ie.HEAPF32.subarray(g>>2,(g>>2)+f))}}return Ie.free_topological_data(s),{positions:u,indices:d,verticesPerFace:m,uvs:c}}},u_=new P,zM=new P,LM=new P,FM=new P}),_gt=G(()=>{LY(),FY(),MR(),UY(),PR(),NS(),aK(),oK(),lK(),jU(),dK(),RR(),cK(),pK(),mK(),GU(),fK(),gK(),yK(),vK(),fm(),Ii(),LY(),FY(),MR(),UY(),PR(),w3t(),NS(),aK(),oK(),lK(),jU(),dK(),RR(),cK(),pK(),mK(),GU(),fK(),gK(),yK(),vK(),fm(),S3t(),Hft(),fgt(),Zv(),F5(),k5(),Kv(),XU={ConeGeometry:Rft,CubeGeometry:Dft,CylinderGeometry:MG,DodecahedronGeometry:Nft,EllipseGeometry:z5,HelixGeometry:cft,IcosahedronGeometry:egt,LatheGeometry:igt,NonParametricGeometry:sgt,PolygonGeometry:RG,PyramidGeometry:ngt,RectangleGeometry:L5,SphereGeometry:lgt,PlaneGeometry:hgt,BackdropGeometry:ugt,StarGeometry:DG,TextFrameGeometry:dgt,TorusGeometry:cgt,TorusKnotGeometry:pgt,TriangleGeometry:mgt,VectorGeometry:xm},kP=t=>{let e=XU[t.type]??Qmt(t.type);if(e===void 0)throw new Error(`No geometry factory registered for "${t.type}" \u2014 was its feature compiled out of this runtime build?`);return e.create(t)}});function im(t,e,i,r){let s,n,a;t.type==="PathGeometry"?(n={...t,extrusion:{...t.extrusion}},a=[[],["extrusion"]]):(n={...t},a=[[]]);for(let u of a){let h=n;for(let d of u)h=h[d];for(s in h){let d=h[s];nX(d)&&!xgt.includes(s)&&(h[s]=e.getVariable(d,[r.uuid,"geometry",...u,s]),nX(h[s])&&(h[s]=1))}}let o,l={parameters:n,type:n.type};if(n.type==="PathGeometry"){l.path=n.path;let u=r.profileShape;u!==void 0&&(l.shapeData=u),l.ownerId=r.uuid}else if(n.type==="VectorGeometry"){let u=ds.createFromState(n.shape,n.width,n.height);l.shape=u,l.ownerId=r.uuid}else if(n.type==="NonParametricGeometry"){if(n.data.groups&&n.data.groups?.forEach(u=>u.materialIndex=Math.max(u.materialIndex??0,0)),l.geometry=new F7().parse(n),l.geometry.groups.length===0){let u=l.geometry;u.addGroup(0,Math.max(u.getIndex()?.count??0,u.getAttribute("position").count),0)}}else{if(n.type==="SubdivGeometry"){let u=new us(n,i);return u.data=t,u}if(n.type==="TextGeometry"||n.type==="InputGeometry"){let u=Qmt(n.type);if(u)return u.create(n,e);Nn("text",`a ${n.type}`);let h=ds.createFromState(PS.defaultData(),100,100);return kP({...n,shape:h,type:"VectorGeometry"})}if(n.type==="UIGeometry")return L5.create({parameters:{width:n.width,height:n.height,cornerRadius:n.cornerRadius,cornerType:n.cornerType}})}try{o=kP(l)}catch(u){console.error(u),console.error(`Error generating geometry with inputs: ${l}`);let h=ds.createFromState(PS.defaultData(),100,100);l.shape=h,l.type="VectorGeometry",o=kP(l)}return o}var xgt,wK,YU,U5=G(()=>{ke(),dt(),_gt(),Ii(),RR(),_m(),Zv(),xgt=["font"]}),M3t=G(()=>{U5(),wK=class{constructor(){this.objects=new Map,this.unreachable=new Set}getCached(t){return this.objects.get(t)}get size(){return this.objects.size}get(t,e,i){let r=this.objects.get(t);return r===void 0?(r=this.createObject(t,e,i),this.objects.set(t,r)):r.isShared=!0,r}forceDelete(t){let e=this.objects.get(t);e&&(this.disposeObject(e),this.objects.delete(t))}adopt(t,e){this.objects.set(t,e)}mutateIfUnique(t,e){let i=this.objects.get(t);if(i&&i.isShared!==!0)return this.objects.delete(t),this.objects.set(e,i),i}startGc(){this.unreachable=new Set(this.objects.keys())}markAsReachable(t,e){e===this.objects.get(t)&&this.unreachable.delete(t)}endGc(){this.unreachable.forEach(t=>{this.disposeObject(this.objects.get(t)),this.objects.delete(t)}),this.unreachable.clear()}dispose(){this.objects.forEach(t=>{this.disposeObject(t)}),this.objects.clear()}},YU=class extends wK{constructor(t){super(),this.flatShading=t}disposeObject(t){t.dispose()}createObject(t,e,i){let r=im(t,e,this.flatShading,i);return r.computeBoundingSphere(),r}}});function DR(){return iT}function wgt(){if(iT==="webgpu"){if(ZU!==void 0)return ZU;QU||(QU=!0,console.warn('[spe] Material backend is "webgpu" but no TSL material factory is registered \u2014 import spe/src/renderer/webgpu before creating materials. Falling back to WebGL materials.'))}if(MK===void 0)throw new Error('[spe] Classic (WebGL) materials are not available in this build \u2014 it was compiled WebGPU-only. Re-export the scene with renderer "Both" or "WebGL 2", or load the full runtime.');return MK}function Sgt(t,e){return wgt().createRootMaterial(t,e)}function SK(t,e,i){return wgt().createSharedMaterial(t,e,i)}function TK(t){return t.getLayersOfType===void 0&&Object.assign(t,{layers:[],getLayersOfType:()=>[],hasAO:!1,assetsLoaded:()=>!0}),t}function KU(){return Tgt}var iT,ZU,MK,QU,JU,Tgt,Mgt,wm=G(()=>{iT="webgl",QU=!1}),A3t=G(()=>{Mgt={markNeedsUpdateRendererDirty:()=>{}}});function Eg(t,e){let i=0;if(!t.layers||t.layers.length===0)return!1;let r=t.layers?.find(s=>s.data.type==="light");if(r){let s=r.data,n=Number(e.getVariable(s.alphaOverride));if((typeof s.alphaOverride=="string"?n/100:s.alphaOverride)<1)return!0}for(let s of t.layers){if(s.data.type!=="displace"&&s.data.isMask)return!0;if(s.data.type!=="displace"&&"alpha"in s.data&&s.data.type!=="light"&&s.data.type!=="fresnel"&&s.data.type!=="cavity"&&s.data.type!=="dust"&&s.data.type!=="texture"&&s.data.type!=="matcap"&&s.data.type!=="rainbow"&&s.data.type!=="outline"&&s.data.type!=="pattern"){let n=s.data.visible?s.data.alpha:0;if(typeof n=="string"&&(n=Math.max(0,Math.min(1,Number(e.getVariable(n)??100)/100))),n===1&&s.data.type==="depth"||s.data.type==="gradient"){for(let a of s.data.colors)if(a[3]<1){n=a[3];break}}else if(n===1&&s.data.type==="noise"){let a=e.color(s.data.colorA).a,o=e.color(s.data.colorB).a,l=e.color(s.data.colorC).a,u=e.color(s.data.colorD).a,h=Math.min(a,Math.min(o,Math.min(l,u)));h<1&&(n=h)}i+=(1-i)*n}}return i<1}var IG=G(()=>{});function mv(t){return typeof t=="string"||typeof t=="number"&&t!==0}var Iv,Mn,rT,Agt,AK,CK,_l,Qv=G(()=>{Iv=(t,e,i)=>Math.max(0,Math.min(1,Number(e.getVariable(typeof t=="number"?100*t:t,i)??100)/100))??1,Mn=(t,e,i)=>typeof t=="number"?t:e.getVariable(t,i),rT={noise:["noiseType"],texture:["projection","axis","projectionAxis","side"],video:["projection","axis","projectionAxis","side"],displace:["noiseType"],light:["roughnessMap","bumpMap","roughnessMapChannel","metalnessMap","metalnessMapChannel","normalMap","aoMap","aoMapChannel","emissiveMap"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"],reflection:["tracingMode","mirror"]},Agt={depth:["colors"],gradient:["colors","steps"],toon:["colors","steps"]}}),Jv=G(()=>{dt(),JS(),AK=class extends I5(dr){},CK=t=>t.type==="Mesh",_l=class extends AK{constructor(t){super(),this.object=t,this.isClone=!0,this.matrixAutoUpdate=!1,this.hasNonUniformScale=t.hasNonUniformScale}raycast(t,e){}expand(){let t=0,e=this.object.entityChildren(t);for(;e;){let i=this.children[t];i?.object!==e&&(i&&this.remove(i),i=new _l(e),this.add(i),this.children.splice(t,0,this.children.pop()),i.matrixWorldNeedsUpdate=!0,i.matrixAutoUpdate=!1,i.matrix=e.matrix,i.hiddenMatrix=e.hiddenMatrix,i.pivotMatrix=e.pivotMatrix),i.expand(),t+=1,e=this.object.entityChildren(t)}for(;this.children.length>t;)this.remove(this.children[t]);this.pivotMatrix=this.object.pivotMatrix}get visible(){let t=this.object.cloner;return(t===void 0||this.parent!==t||!t.instancingActive&&!t.insideBoolean)&&(this.playModeVisible!==void 0?this.playModeVisible:this.object.visible||this.object.dataPatched.visible&&this.object.dataPatched.cloner?.hideBase===!0)}set visible(t){}get castShadow(){return this.object.castShadow}set castShadow(t){}get receiveShadow(){return this.object.receiveShadow}set receiveShadow(t){}get isMesh(){return CK(this.object)}get isLight(){return this.object.isLight}get layers(){return this.object.layers}set layers(t){}get isCamera(){return!1}get geometry(){if(this.object.geometry)return this.object.geometry}get material(){if(this.object.material)return this.object.material}get morphTargetInfluences(){if(this.object.morphTargetInfluences)return this.object.morphTargetInfluences}set morphTargetInfluences(t){}}});function EK(){return BG}var BG,VG,kG=G(()=>{BG=null,VG=null});function tj(t){return"variable_"+t}var FO,UO,jO,PK,GO,RK,WO,DK,NR,zG=G(()=>{ke(),JMt(),Mft(),Aft(),Rc(),wG(),TG(),M3t(),wm(),wft(),A3t(),IG(),Qv(),vo(),Jv(),Fi(),dt(),kG(),Ii(),FO=new bt,UO=new P,jO=new Me,PK=new P,GO=new Qi,RK=class extends bft{constructor(t){super(),this.shared=t}create(t){return new xG(t,this.shared)}},WO=new Set,(NR=DK=class{constructor(t,e={},i=!0,r=!1){if(this.data=t,this.needsJitter=i,this.enableLocalStorageForPersistentVariables=r,this.geometryCache=new YU(!0),this.geometryCache2=new YU(!1),this.imageHolderCache=new RK(this),this.thisContext={scene:Mgt,shared:this},this.deletedImage=new pg(mU.emptyImage,this),this.deletedVideo=new pg(oR.defaultVideo,this),this.materials={},this.images={},this.uiBuffers={},this.videos={},this.colors={},this.audios={},this.particles={},this.fonts={},this.variables={},this.userAPIs={},this.userWebhooks={},this.mouseProperty=null,this.raycastProperty=null,this.requestRender=()=>{this._requestRender&&this._requestRender()},this.transientGeometryKeys=new WeakSet,e.images)for(let[s,n]of Object.entries(e.images))this.addImage(s,n);if(e.videos)for(let[s,n]of Object.entries(e.videos))this.addVideo(s,n);if(e.audios)for(let[s,n]of Object.entries(e.audios))this.addAudio(s,n);if(e.particles)for(let[s,n]of Object.entries(e.particles))this.addParticle(s,n);this.reset(t)}get deletedMaterial(){return this._deletedMaterial??(this._deletedMaterial=SK(cs.defaultTwoLayerData("phong"),this.thisContext,"")),this._deletedMaterial}setRequestRender(t){this._requestRender=t}getImageLoadPromises(){return Object.values(this.images).map(t=>t.loadPromise)}setEntityOpContext(t){this.entityOpContext=t}reset(t,e=!1,i=!1){this.data=t,this.resetLib(t.lib);for(let{id:r,data:s}of t.variables)this.addVariableHolder(r,s),e&&this.updateVariableHolder(r,s);for(let[r,s]of Object.entries(t.userAPIs??{}))this.addUserAPI(r,s);for(let[r,s]of Object.entries(t.userWebhooks??{}))this.addUserWebhook(r,s);if(!i){for(let[r,s]of Object.entries(t.images))this.addImage(r,s);for(let[r,s]of Object.entries(t.videos))this.addVideo(r,s)}for(let[r,s]of Object.entries(t.colors))this.addColor(r,s);for(let[r,s]of Object.entries(t.lib.materials))this.addMaterial(r,s.asset);for(let[r,s]of Object.entries(t.materials))this.addMaterial(r,s);for(let[r,s]of Object.entries(t.audios))this.addAudio(r,s);for(let[r,s]of Object.entries(t.particles))this.addParticle(r,s);for(let[r,s]of Object.entries(t.fonts))this.addFont(r,s)}addMaterial(t,e){if(e.layers===void 0&&(e={...e,layers:cs.defaultTwoLayerData("phong").layers}),this.materials[t]){let i=this.materials[t];i.reset(e,this.thisContext),i.dispose()}else{let i=SK(e,this.thisContext,t);this.materials[t]=i}}deleteMaterial(t){this.materials[t]&&(this.materials[t].nodeMaterialDispose(),delete this.materials[t])}getMaterial(t){return this.materials[t]}getMaterialOrDeletedPlaceholder(t){return this.materials[t]??this.deletedMaterial}material(t){return typeof t=="string"?this.getMaterialOrDeletedPlaceholder(t):t==null?(console.error("material is undefined or null"),this.deletedMaterial):(t.layers===void 0&&(t={...t,layers:cs.defaultTwoLayerData("phong").layers}),Sgt(t,this.thisContext))}getMaterials(){return this.materials}addImage(t,e){return this.images[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.images[t].updateSrc(e.data),!0):(this.images[t]=new pg(e,this),!1)}deleteImage(t){let e=this.images[t];e&&(e.dispose(),delete this.images[t])}getDefaultImage(){return this.images.image_0}getImage(t){return this.images[t]??this.deletedImage}image(t){return typeof t=="string"?this.getImage(t):this.imageHolderCache.load(t)}addUIBuffer(t,e){return this.uiBuffers[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.uiBuffers[t].updateSrc(e),!0):(this.uiBuffers[t]=new pg(e,this),!1)}uiBuffer(t){return this.uiBuffers[t]}getEntityTexture(t,e={}){let i=t.material;if(!i)return null;for(let r of Array.isArray(i)?i:[i]){let s=r.root??r;for(let n of s?.data?.layers??[]){let a=n?.data;if(a?.type!=="texture"&&a?.type!=="matcap"||e.layer!==void 0&&n.id!==e.layer&&a.type!==e.layer)continue;let o=a.texture?.image;if(o==null)continue;let l=(typeof o=="string"?this.uiBuffer(o):void 0)??this.image(o);if(!l)continue;let u=l.getTexture(a.texture.wrapping??(a.type==="texture"?1e3:1001),a.texture.minFilter??1008,a.texture.magFilter??1006),h=l.img;return{texture:u,width:h?.width??0,height:h?.height??0,layerId:n.id,layerType:a.type}}}return null}addVideo(t,e){return this.videos[t]?(this.videos[t].updateSrc(e.data),!0):(this.videos[t]=new pg(e,this),!1)}deleteVideo(t){let e=this.videos[t];e&&(e.dispose(),delete this.videos[t])}getVideo(t){return this.videos[t]??this.deletedVideo}video(t){return typeof t=="string"?this.getVideo(t):this.imageHolderCache.load(t)}addColor(t,e){return this.colors[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),"a"in e?this.colors[t].setRGBA(e.r,e.g,e.b,e.a):this.colors[t].setRGBA(e.r,e.g,e.b,1),!0):(this.colors[t]=new NU(e.r,e.g,e.b,"a"in e?e.a:1),!1)}updateColor(t,e){if(this.colors[t]){this.onColorOrImageUpdate&&this.onColorOrImageUpdate();let i=this.colors[t];return this.colors[t].r=e.r??i.r,this.colors[t].g=e.g??i.g,this.colors[t].b=e.b??i.b,this.colors[t].a=e.a??i.a,!0}return!1}deleteColor(t){this.colors[t]&&delete this.colors[t]}getColor(t){return this.colors[t]}getColorNames(){return Object.values(this.data.colors).map(t=>t.name)}getColorByName(t){for(let e in this.data.colors)if(this.data.colors[e].name===t)return{color:this.colors[e],id:e}}color(t){let e;if(typeof t!="string")return new Dr(t.r,t.g,t.b,"a"in t?t.a:1);{let i=this.getColor(t);i?e=i:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),e=new Dr(0,0,0,0))}return e}addAudio(t,e){this.audios[t]=e}getAudio(t){let e=this.audios[t];if(e instanceof $1)return e;{let i=new $1({src:e.data});return this.audios[t]=i,i}}addParticle(t,e){this.particles[t]=e}getParticle(t){return this.particles[t]}deleteParticle(t){this.particles[t]&&delete this.particles[t]}deleteAudio(t){let e=this.audios[t];e&&(e instanceof $1&&e.dispose(),delete this.audios[t])}addFont(t,e){let i=SG;i!==null?(this.fonts[t]=new i(e),this.fonts[t].loadingPromise.then(()=>this.requestRender())):Nn("text","a font asset")}getFont(t){return this.fonts[t]}deleteFont(t){this.fonts[t]&&delete this.fonts[t]}dispose(){Object.keys(this.materials).forEach(t=>this.deleteMaterial(t)),this._requestRender=void 0,Object.values(this.audios).forEach(t=>{t instanceof $1&&t.dispose()}),this.audios={},this.particles={},this.geometryCache.dispose(),this.geometryCache2.dispose()}addVariableHolder(t,e){if(this.variables[t]===void 0){let i=e.value;if(this.enableLocalStorageForPersistentVariables&&e.persistent){let r=localStorage.getItem(tj(t));i=r!==null?JSON.parse(r):e.value}return this.variables[t]={value:i,locations:[],persistent:e.persistent},"dynamicVariableType"in e&&(this.variables[t].dynamicVariablePlayState="Playing",this.variables[t].dynamicVariableToggleIsForward=void 0),!0}return this.variables[t].value=e.value,!1}resetDynamicVariablePlayState(){for(let t in this.variables)this.variables[t].dynamicVariablePlayState!==void 0&&(this.variables[t].dynamicVariablePlayState="Playing",this.variables[t].dynamicVariableToggleIsForward=void 0)}updateVariableHolder(t,e){this.updateVariable(t,e.value)}updateVariable(t,e){if(this.variables[t]===void 0)return!1;this.variables[t].value=e,this.enableLocalStorageForPersistentVariables&&this.variables[t].persistent&&localStorage.setItem(tj(t),JSON.stringify(e));let i=e;for(;typeof i=="string";)i=this.variables[i].value;let r=this.entityOpContext.scene,s=!1;for(let n=this.variables[t].locations.length-1;n>=0;n--){let a=this.variables[t].locations[n];if(a[0]==="material"){let o=a[1],l=i,u={scene:r,shared:this},h=a.slice(2);r.traverseMaterial(c=>{let p=c.root??c;p.uuid===o&&p.onVariableUpdate(h,l,u)});let d=this.materials[o];d&&d.onVariableUpdate(h,l,u)}else{let o=r.find(a[0]);if(o===void 0){this.variables[t].locations.splice(n,1);continue}if(s=!0,a[1]!=="geometry"&&a[1]!=="particles"){for(let l=1;l<a.length-1;l++)o=o[a[l]];a[1]==="rotation"?o[a[a.length-1]]=i*qt.DEG2RAD:o[a[a.length-1]]=i}if(o=r.find(a[0]),o.type==="ParticleEmitter"&&o.updateVariableState(i,a),Mi.is(o))if(a[1]==="position"||a[1]==="rotation"||a[1]==="scale")o.onVariableUpdate();else if(a[1]==="geometry"){let l=o;o.component&&(l=o.component);let u=l.dataPatched;l.chooseGeoemtryCache(this).forceDelete(u.geometry),l.createGeometryDelayed(this.entityOpContext),l.onVariableUpdate(!0),l.invalidateDownstreamBooleanData(),l.instances.forEach(h=>{let d=h.dataPatched;h.chooseGeoemtryCache(this).forceDelete(d.geometry),h.createGeometryDelayed(this.entityOpContext),h.onVariableUpdate(!0),h.invalidateDownstreamBooleanData()})}else a[1]==="morphTargetInfluences"&&o.updateMorphInfluences(a[2],i)}}return s&&r.markShadowsDirty(),this.requestRender(),!0}updateEntityGeometryParams(t,e){let i=t;if(i.component&&(i=i.component),typeof i.chooseGeoemtryCache!="function")return!1;let r=i.dataPatched,s=r?.geometry;if(!s||typeof s.type!="string"||s.type==="VectorGeometry"||s.type==="PathGeometry")return!1;let n=u=>u.toLowerCase().replace(/[\s_.-]+/g,""),a=new Map;for(let u of Object.keys(s))a.set(n(u),u);let o={};for(let[u,h]of Object.entries(e??{})){let d=a.get(n(u));if(d===void 0||d==="type"||d==="font"||d==="shape"||d==="path"||d==="data")continue;if(d==="text"){(typeof h=="string"||typeof h=="number")&&(o[d]={textValue:String(h)});continue}let c=s[d];typeof h=="number"&&isFinite(h)&&(typeof c=="number"||typeof c=="string")&&(o[d]=h)}if(Object.keys(o).length===0)return!1;let l={...s,...o};return i.dataPatched={...r,geometry:l},this.transientGeometryKeys.has(s)&&i.chooseGeoemtryCache(this).forceDelete(r.geometry),this.transientGeometryKeys.add(l),i.createGeometryDelayed(this.entityOpContext),i.onVariableUpdate(!0),i.invalidateDownstreamBooleanData(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),!0}resetEntityGeometryParams(t){let e=t;if(e.component&&(e=e.component),typeof e.chooseGeoemtryCache!="function")return!1;let i=e.dataPatched?.geometry;return!(!i||!this.transientGeometryKeys.has(i)||(e.dataPatched=e.data,e.chooseGeoemtryCache(this).forceDelete(i),e.createGeometryDelayed(this.entityOpContext),e.onVariableUpdate(!0),e.invalidateDownstreamBooleanData(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),0))}updateEntityGeometryVertices(t,e){let i=t;if(i.component&&(i=i.component),typeof i.chooseGeoemtryCache!="function")return!1;let r=i.dataPatched,s=r?.geometry;if(!s||s.type!=="NonParametricGeometry")return!1;let n=e?.vertices;if(n===void 0||typeof n.length!="number"||n.length<9||n.length%3!=0||n.length/3>DK.MAX_TRANSIENT_VERTICES)return!1;let a,o,l,u=n instanceof Float32Array?n:Float32Array.from(n),h=u.length/3;if(e.normals!==void 0){if(e.normals.length!==u.length)return!1;a=e.normals instanceof Float32Array?e.normals:Float32Array.from(e.normals)}if(e.uvs!==void 0){if(e.uvs.length!==2*h)return!1;o=e.uvs instanceof Float32Array?e.uvs:Float32Array.from(e.uvs)}if(e.indices!==void 0){let x=h>65535?Uint32Array.from(e.indices):Uint16Array.from(e.indices);if(x.length===0||x.length%3!=0)return!1;for(let S=0;S<x.length;S++)if(x[S]>=h)return!1;l={array:x,itemSize:1,type:x.constructor.name,normalized:!1}}else{let x=s.data,S=x?.index;if(S?.array?.length){let w=(x?.attributes?.position?.array?.length??0)/3;if(h!==w)return function(T,A){let M=`${T}/${A}`;WO.has(M)||(WO.add(M),console.warn(`[spline] updateObject: ignoring a geometry update of ${T} vertices for a mesh that holds ${A}. Without \`indices\` the write is taken as a morph of the mesh's own vertices, which only means anything at the same count \u2014 send \`indices\` alongside \`vertices\` to replace the topology too.`))}(h,w),!1;l=S}}let d=1/0,c=1/0,p=1/0,m=-1/0,f=-1/0,g=-1/0;for(let x=0;x<u.length;x+=3){let S=u[x],w=u[x+1],T=u[x+2];S<d&&(d=S),S>m&&(m=S),w<c&&(c=w),w>f&&(f=w),T<p&&(p=T),T>g&&(g=T)}let y=(x,S)=>({array:x,itemSize:S,type:"Float32Array",normalized:!1}),v={position:y(u,3)};a&&(v.normal=y(a,3)),o&&(v.uv=y(o,2));let b={...s,width:m-d,height:f-c,depth:g-p,data:{attributes:v,...l?{index:l}:{}}},_=this.transientGeometryKeys.has(s);return i.dataPatched={...r,geometry:b},this.transientGeometryKeys.add(b),i.applyTransientGeometryData(this.entityOpContext,_),i.onVariableUpdate(!0),i.invalidateDownstreamBooleanData(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),!0}setEntityInstanceTransforms(t,e){let i=t;i.component&&(i=i.component);let r=i.cloner;if(r===void 0)return-1;let s=r.children,n=Math.PI/180,a=!1;if(e===null)for(let o of s)o.transformOverride!==void 0&&(o.transformOverride=void 0,a=!0);else{if(!Array.isArray(e))return s.length;{let o=Math.min(e.length,s.length);for(let l=0;l<o;l++){let u=e[l],h=s[l];if(u==null){h.transformOverride!==void 0&&(h.transformOverride=void 0,a=!0);continue}let d=h.transformOverride??{position:[h.position.x,h.position.y,h.position.z],rotation:[h.rotation.x,h.rotation.y,h.rotation.z],scale:[h.scale.x,h.scale.y,h.scale.z]};u.position&&(typeof u.position.x=="number"&&(d.position[0]=u.position.x),typeof u.position.y=="number"&&(d.position[1]=u.position.y),typeof u.position.z=="number"&&(d.position[2]=u.position.z)),u.rotation&&(typeof u.rotation.x=="number"&&(d.rotation[0]=u.rotation.x*n),typeof u.rotation.y=="number"&&(d.rotation[1]=u.rotation.y*n),typeof u.rotation.z=="number"&&(d.rotation[2]=u.rotation.z*n)),u.scale&&(typeof u.scale.x=="number"&&(d.scale[0]=u.scale.x),typeof u.scale.y=="number"&&(d.scale[1]=u.scale.y),typeof u.scale.z=="number"&&(d.scale[2]=u.scale.z)),h.transformOverride=d,h.position.fromArray(d.position),h.rotation.fromArray(d.rotation),h.scale.fromArray(d.scale),h.updateMatrix(),h.hasNonUniformScale&&(h.updateMatrixWorld(),h.updateMatrixWorldRigid())}}}return a?r.update(this.entityOpContext):r.syncInstanceMatrices(),r.invalidateTransform(i),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),s.length}spawnRuntimeClone(t,e={}){if(typeof t.entityChildren!="function")return;let i=t.parent;if(i===null)return;let r=new _l(t);r.playModeVisible=e.visible!==!1,r.expand(),typeof e.name=="string"&&(r.name=e.name);let s=Math.PI/180;return r.position.copy(t.position),r.rotation.copy(t.rotation),r.scale.copy(t.scale),r.hiddenMatrix.copy(t.hiddenMatrix),e.position&&(typeof e.position.x=="number"&&(r.position.x=e.position.x),typeof e.position.y=="number"&&(r.position.y=e.position.y),typeof e.position.z=="number"&&(r.position.z=e.position.z)),e.rotation&&(typeof e.rotation.x=="number"&&(r.rotation.x=e.rotation.x*s),typeof e.rotation.y=="number"&&(r.rotation.y=e.rotation.y*s),typeof e.rotation.z=="number"&&(r.rotation.z=e.rotation.z*s)),e.scale&&(typeof e.scale.x=="number"&&(r.scale.x=e.scale.x),typeof e.scale.y=="number"&&(r.scale.y=e.scale.y),typeof e.scale.z=="number"&&(r.scale.z=e.scale.z)),r.updateMatrix(),i.add(r),r.updateWorldMatrix(!0,!0),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),r}destroyRuntimeClone(t){t.removeFromParent(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender()}updateEntityMaterialParams(t,e){let i=t.material;if(!i)return!1;let r=[];for(let u of Array.isArray(i)?i:[i]){let h=u.root??u;h&&Array.isArray(h.layers)&&h.data&&!r.includes(h)&&r.push(h)}if(r.length===0)return!1;let s={scene:this.entityOpContext.scene,shared:this},n=u=>u.toLowerCase().replace(/[\s_.-]+/g,""),a=u=>{if(typeof u=="string"){let h=new Dr(1,1,1,1);try{h.set(u)}catch{return null}return{r:h.r,g:h.g,b:h.b,a:void 0}}if(u&&typeof u=="object"&&"r"in u){let h=u;if([h.r,h.g,h.b].some(c=>typeof c!="number"||!isFinite(c)))return null;let d=Math.max(h.r,h.g,h.b)>1?1/255:1;return{r:h.r*d,g:h.g*d,b:h.b*d,a:typeof h.a=="number"?Math.max(0,Math.min(h.a,1)):void 0}}return null},o=(u,h,d)=>{if(!u.hasValue(h))return!1;let c=u.getValue(h);if(!c||typeof c!="object"||!c.isColor)return!1;let p=d.a??(typeof c.a=="number"?c.a:1);return c instanceof NU?u.setValue(h,new Dr(d.r,d.g,d.b,p)):typeof c.setRGBA=="function"?c.setRGBA(d.r,d.g,d.b,p):c.setRGB(d.r,d.g,d.b),!0},l=!1;for(let u of r){let h=u.data.layers??[],d=c=>u.layers.find(p=>p.uuid===c);if(e.color!==void 0){let c=a(e.color),p=h.find(f=>f.data.type==="color"),m=p&&d(p.id);if(c&&m&&o(m,"color",c)&&(l=!0,c.a!==void 0)){let f=c.a<1||Eg(u.data,this);u.setTransparent?u.setTransparent(f,s.scene):u.transparent=f}}typeof e.alpha=="number"&&isFinite(e.alpha)&&(u.onVariableUpdate?.(["alphaOverride"],Math.max(0,Math.min(e.alpha,100)),s),l=!0);for(let c of e.layers??[]){if(!c||typeof c!="object")continue;let p=typeof c.id=="string"?h.find(y=>y.id===c.id):typeof c.index=="number"?h[c.index]:typeof c.type=="string"?h.find(y=>y.data.type===c.type):void 0,m=p&&d(p.id);if(!p||!m)continue;let f=rT[p.data.type]??[],g=Object.keys(p.data);for(let[y,v]of Object.entries(c)){if(y==="id"||y==="index"||y==="type")continue;let b=g.find(x=>x===y)??g.find(x=>n(x)===n(y))??y;if(f.includes(b))continue;let _=a(v);if(_&&o(m,b,_))l=!0;else if(typeof v=="number"&&isFinite(v))u.onVariableUpdate?.(["layer",p.id,b],v,s),l=!0;else if(Array.isArray(v)&&v.length<=3&&v.every(x=>typeof x=="number"&&isFinite(x))){let x=["x","y","z"];v.forEach((S,w)=>{u.onVariableUpdate?.(["layer",p.id,b,x[w]],S,s)}),l=!0}}}}return l&&this.requestRender(),l}deleteVariable(t){this.variables[t]&&delete this.variables[t]}getVariable(t,e){if(Array.isArray(t)){if(t[0]==="mouse")return this.mouseProperty?.[t[1]]??0;if(t[0]==="raycast")return this.raycastProperty?.[t[1]]??0;let i=this.entityOpContext.scene.find(t[0]);if(t[1]==="width"||t[1]==="height"||t[1]==="depth")return i.geometry.userData.parameters[t[1]];if((t[1]==="position"||t[1]==="rotation")&&t.length>2&&i?.getPhysicsLocalMatrix?.(FO))return FO.decompose(UO,jO,PK),t[1]==="position"?UO[t[2]]:(GO.setFromQuaternion(jO,i.rotation.order),GO[t[2]]*qt.RAD2DEG);for(let r=1;r<t.length;r++)i=i[t[r]];return t[1]==="rotation"&&(i*=qt.RAD2DEG),i}for(let i in this.variables){if(e===void 0)break;let r=this.variables[i],s=r.locations?.findIndex(n=>Dn.equal(n,e));s!==void 0&&s!==-1&&r.locations.splice(s,1)}if(typeof t=="string"){let i=t,r=t;do{if(r=i,this.variables[i]===void 0)break;let s=this.variables[i].value;e&&this.variables[r]!==void 0&&this.variables[r].locations.push(e),i=s}while(typeof i=="string");return i}return t}getVariables(){return this.variables}getVariablesNames(){return this.data.variables.map(t=>t.data.name)}getVariableByName(t){for(let e of this.data.variables)if(e.data.name===t)return{variable:e.data,id:e.id}}getDynamicVariablePlayState(t){return this.variables[t]?.dynamicVariablePlayState}setDynamicVariablePlayState(t,e){this.variables[t]!==void 0&&(this.variables[t].dynamicVariablePlayState=e)}getDynamicVariableToggleIsForward(t){return this.variables[t]?.dynamicVariableToggleIsForward}setDynamicVariableToggleIsForward(t,e){this.variables[t]!==void 0&&(this.variables[t].dynamicVariableToggleIsForward=e)}resetLib(t){for(let[e,i]of Object.entries(t.images))this.addImage(e,i.asset);for(let[e,i]of Object.entries(t.audios))this.addAudio(e,i.asset);for(let[e,i]of Object.entries(t.particles))this.addParticle(e,i.asset);for(let[e,i]of Object.entries(t.colors))this.addColor(e,i.asset);for(let[e,i]of Object.entries(t.fonts))this.addFont(e,i.asset);for(let[e,i]of Object.entries(t.videos))this.addVideo(e,i.asset);for(let[e,i]of Object.entries(t.variables))this.addVariableHolder(e,i.asset)}updateLibByOp(t,e){t.path[0]==="images"?t.path.length===1&&t.type===1?this.addImage(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteImage(t.id):t.path[0]==="videos"?t.path.length===1&&t.type===1?this.addVideo(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteVideo(t.id):t.path[0]==="audios"?t.path.length===1&&t.type===1?this.addAudio(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteAudio(t.id):t.path[0]==="particles"?t.path.length===1&&t.type===1?this.addParticle(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteParticle(t.id):t.path[0]==="colors"?t.path.length===1&&t.type===1?this.addColor(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteColor(t.id):t.path[0]==="materials"?t.path.length===1&&t.type===1?this.addMaterial(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteMaterial(t.id):t.path[0]==="fonts"?t.path.length===1&&t.type===1?this.addFont(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteFont(t.id):t.path[0]==="variables"?t.path.length===1&&t.type===1?this.addVariableHolder(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteVariable(t.id):t.path[0]==="components"&&e.updateByLibOp(t,this)}updateByOp(t,e,i){if(this.data=e,t.path[0]==="images")t.path.length===2&&t.type===0?t.props.data&&this.getImage(t.path[1]).updateSrc(t.props.data):t.path.length===1&&t.type===1?this.addImage(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteImage(t.id);else if(t.path[0]==="videos")t.path.length===2&&t.type===0?t.props.data&&this.getVideo(t.path[1]).updateSrc(t.props.data):t.path.length===1&&t.type===1?this.addVideo(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteVideo(t.id);else if(t.path[0]==="audios")t.path.length===2&&t.type===0?t.props.data&&this.addAudio(t.path[1],e.audios[t.path[1]]):t.path.length===1&&t.type===1?this.addAudio(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteAudio(t.id);else if(t.path[0]==="particles")t.path.length===2&&t.type===0?t.props.data&&this.addParticle(t.path[1],e.particles[t.path[1]]):t.path.length===1&&t.type===1?this.addParticle(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteParticle(t.id);else if(t.path[0]==="colors")t.path.length===2&&t.type===0?this.updateColor(t.path[1],t.props):t.path.length===1&&t.type===1?this.addColor(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteColor(t.id);else if(t.path[0]==="materials")t.path.length===1&&t.type===1?this.addMaterial(t.id,t.data):t.path.length===1&&t.type===2?this.deleteMaterial(t.id):t.path.length>1&&this.getMaterial(t.path[1]).updateByOp(ea.drop(t,2),e.materials[t.path[1]],{shared:this,scene:i});else if(t.path[0]==="fonts")t.path.length===2&&t.type===0?this.updateFont(t.path[1],t,i):t.path.length===1&&t.type===1?this.addFont(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteFont(t.id);else if(t.path[0]==="variables")t.path.length===2&&t.type===0?"value"in t.props?this.updateVariable(t.path[1],t.props.value):"persistent"in t.props&&(this.variables[t.path[1]].persistent=t.props.persistent):t.path.length===1&&t.type===4?this.addVariableHolder(t.id,t.data):t.path.length===1&&t.type===5&&this.deleteVariable(t.id);else if(t.path[0]==="userAPIs"){if(t.path.length===1&&t.type===1)this.addUserAPI(t.id,t.data);else if(t.path.length===1&&t.type===2)this.deleteUserAPI(t.id);else if(typeof t.path[1]=="string"){let r=e.userAPIs[t.path[1]];if(r){let s=t.type===0&&t.props.debounce===void 0,n=this.getUserAPI(t.path[1]);n!==void 0&&n===this.openAIRealtime?n.update(r):n?.update(r,this,s)}}}else if(t.path[0]==="userWebhooks"){if(t.path.length===1&&t.type===1)this.addUserWebhook(t.id,t.data);else if(t.path.length===1&&t.type===2)this.deleteUserWebhook(t.id);else if(typeof t.path[1]=="string"){let r=e.userWebhooks[t.path[1]];r&&this.getUserWebhook(t.path[1])?.update(r)}}else t.path[0]==="lib"&&this.updateLibByOp(ea.drop(t,1),i)}updateFont(t,e,i){if(e.props.url){let r=this.getFont(t),s={...this.data.fonts[t],url:e.props.url};r.update(s),r.loadingPromise.then(()=>this.requestRender()),i.updateFont(t,this)}}addUserAPI(t,e){if(this.userAPIs[t])return this.userAPIs[t].update(e,this),!0;if(this.openAIRealtime?.id===t)return this.openAIRealtime.update(e),!0;if(e.integration?.type==="VoiceAssistant"){let i=VG;return i===null?(Nn("ai-assistant","a voice-assistant integration"),!1):(this.openAIRealtime=i(e,t,this),!1)}{let i=EK();return i===null?(Nn("api-services","a user API integration"),!1):(this.userAPIs[t]=i.createUserAPI(t,e,this),!1)}}getUserAPI(t){return this.openAIRealtime?.id===t?this.openAIRealtime:this.userAPIs[t]}getUserAPIs(){return this.userAPIs}deleteUserAPI(t){let e=this.userAPIs[t];e&&(e.dispose(),delete this.userAPIs[t])}addUserWebhook(t,e){if(this.userWebhooks[t])return this.userWebhooks[t].update(e),!0;{let i=EK();return i===null?(Nn("api-services","a user webhook"),!1):(this.userWebhooks[t]=i.createUserWebhook(t,e),!1)}}getUserWebhook(t){return this.userWebhooks[t]}getUserWebhooks(){return this.userWebhooks}deleteUserWebhook(t){let e=this.userWebhooks[t];e&&(e.dispose(),delete this.userWebhooks[t])}get scene(){return this.entityOpContext.scene}}).MAX_TRANSIENT_VERTICES=6e4,new NR(Zl.emptyData())});function Cgt(t){return SR(t)||t?.isTSLNodeMaterial===!0}var yo,qO,HO,$O,NK,XO,Fr,Egt=G(()=>{_G()}),n0=G(()=>{ke(),la(),wm(),Egt(),Fi(),hn(),yo=class extends Bs{setMaterialOverride(t,e){this.materialOverride=TK(t),this.material!==this.shadowCatcherMaterial&&(this.disposeMaterial(),this.material=this.materialOverride,this.layers.set(0),this.syncShapeBlendNodeLayer(),e.scene.markNeedsUpdateRendererDirty())}updateByPatchedOp(t,e,i){if(super.updateByPatchedOp(t,e,i),er(t.path,["geometry"])&&this.syncShadowCatcher(i),function(r,s){let n=[];if(s.length!==r.length)return null;{let a=0;for(;a<r.length;){if(s[a]==="*")n.push(r[a]);else if(r[a]!==s[a])return null;a+=1}}return n}(t.path,["materials"])!==null&&t.type===0&&Array.isArray(this.material))for(let[r,s]of Object.entries(t.props)){let n=this.material[Number(r)],a=i.shared.material(s);a!==n&&yo.disposeOneMaterial(n),this.material[Number(r)]=a}else if(er(t.path,["material"])){let r=this.material;!Array.isArray(r)&&typeof r?.updateByOp=="function"&&"material"in e&&typeof e.material!="string"&&r.updateByOp(ea.drop(t,1),e.material,i)}else if(er(t.path,["materials","*"])&&Array.isArray(this.material)){let r=t.path[1];if("materials"in e&&r<this.material.length){let s=e.materials[r];typeof s!="string"&&this.material[r].updateByOp(ea.drop(t,2),s,i)}}}get needsAO(){return this.material!==void 0&&(Array.isArray(this.material)?this.material[0]:this.material).hasAO}syncShapeBlendNodeLayer(){this.dataPatched.type==="Mesh"&&this.dataPatched.geometry.shapeBlendNode?this.layers.set(9):512&this.layers.mask&&this.layers.set(0)}updateState(t,e){super.updateState(t,e),t.castShadow!==void 0&&(this.castShadow=t.castShadow),t.receiveShadow!==void 0&&(this.receiveShadow=t.receiveShadow);let i,r=this.dataPatched;this.syncShapeBlendNodeLayer(),this.dataPatched.type==="Mesh"&&this.dataPatched.geometry.type==="ShapeBlendGeometry"&&(i={resolutionLevel:Math.min(8,this.dataPatched.geometry.resolutionLevel),useChildrenColors:this.dataPatched.geometry.useChildrenColors});let s=this.materialOverride!==void 0;!s&&t.geometry?.type!=="NonParametricGeometry"&&"material"in t&&t.material!==void 0&&(this.disposeMaterial(),this.material=e.shared.material(t.material).getFlavor(r.flatShading,r.side,r.wireframe,i),e.scene.markNeedsUpdateRendererDirty()),!s&&(t.geometry?.type==="NonParametricGeometry"||"materials"in t)&&("materials"in t&&t.materials!==void 0?(this.disposeMaterial(),this.material=t.materials.map(a=>e.shared.material(a).getFlavor(r.flatShading,r.side,r.wireframe)),e.scene.markNeedsUpdateRendererDirty()):"material"in t&&t.material!==void 0&&(this.disposeMaterial(),this.material=[e.shared.material(t.material).getFlavor(r.flatShading,r.side,r.wireframe)],e.scene.markNeedsUpdateRendererDirty()));let n=this.data;if(!s&&n.geometry?.type!=="NonParametricGeometry"&&"materials"in n&&n.materials!==void 0&&(this.disposeMaterial(),this.material=e.shared.material(n.materials[0]).getFlavor(r.flatShading,r.side,r.wireframe)),!s&&(t.flatShading!==void 0||t.wireframe!==void 0||t.side!==void 0))if(Array.isArray(this.material))for(let a=0;a<this.material.length;a++)this.material[a]=this.material[a].getFlavor(r.flatShading,r.side,r.wireframe);else this.material=this.material.getFlavor(r.flatShading,r.side,r.wireframe,i);this.syncShadowCatcher(e)}shadowCatcherActive(){let t=this.dataPatched,e=t.geometry?.type;return t.shadowCatcher===!0&&(e==="RectangleGeometry"||e==="PlaneGeometry")}syncShadowCatcher(t){let e=this.dataPatched;if(this.shadowCatcherActive()){if(this.shadowCatcherMaterial===void 0){let i=function(){let r=iT==="webgpu"&&JU!==void 0?JU:void 0;return r===void 0?null:TK(r())}();if(i===null)return;this.shadowCatcherMaterial=i}this.shadowCatcherMaterial.side=e.side,this.material!==this.shadowCatcherMaterial&&(this.disposeMaterial(),this.material=this.shadowCatcherMaterial,t.scene.markNeedsUpdateRendererDirty()),this.castShadow=!1,this.receiveShadow=!0,this.layers.set(0)}else this.shadowCatcherMaterial!==void 0&&this.material===this.shadowCatcherMaterial&&(this.materialOverride!==void 0?(this.material=this.materialOverride,t.scene.markNeedsUpdateRendererDirty()):"material"in e&&e.material!==void 0&&(this.material=t.shared.material(e.material).getFlavor(e.flatShading,e.side,e.wireframe),t.scene.markNeedsUpdateRendererDirty(),this.needsAO&&this.layers.enable(5)),this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow)}static disposeOneMaterial(t){var e;Cgt(t)&&!function(i){return i?.isClassicSharedMaterial===!0}(e=t)&&e?.isTSLSharedMaterial!==!0&&t.nodeMaterialDispose()}disposeMaterial(){this.material&&Qpt(this.material).forEach(t=>{yo.disposeOneMaterial(t)})}dispose(){this.disposeMaterial(),this.shadowCatcherMaterial?.dispose(),super.dispose()}}}),bo=G(()=>{ke(),Fi(),zG(),n0(),dt(),U5(),Kv(),Zv(),vgt(),qO=new P,HO=new Te,$O=new Te,NK=new P,XO=new bt,Fr=class extends yo{constructor(t,e,i){super(t,e),this.data=e,this.isSkinnedMesh=!1,this.localGeometry=void 0,e.bindMode&&e.bindMatrix&&(this.bindMode=e.bindMode,this.bindMatrix=new bt().fromArray(e.bindMatrix),this.bindMatrixInverse=new bt)}chooseGeoemtryCache(t){return t.geometryCache}supportsInPlaceGeometryUpdate(t){return t.isTextGeometry!==!0}markGeometryAsReachable(t){this.geometryCreateDeleyed instanceof ye&&this.chooseGeoemtryCache(t).markAsReachable(this.dataPatched.geometry,this.geometryCreateDeleyed)}get builtSharedGeometry(){if(this.localGeometry===void 0)return this.geometryCreateDeleyed instanceof ye?this.geometryCreateDeleyed:void 0}get geometry(){if(this.localGeometry!==void 0)return this.localGeometry;if(this.geometryCreateDeleyed instanceof NR){let t=this.geometryCreateDeleyed,e=this.chooseGeoemtryCache(t),i=this.dataPatched.geometry;this.geometryCreateDeleyed=e.get(i,t,this),this._geometryCacheKey=i}return this.geometryCreateDeleyed}set geometry(t){this.localGeometry=t}get is2DAndNoDepth(){let t=this.dataPatched.geometry;return uR.is2DParametricMesh(t.type)&&t.depth===0}get is2DType(){return uR.is2DParametricMesh(this.geometry.userData.type)}get isTextType(){return this.geometry.isTextGeometry===!0}get isNonParametric(){return this.geometry.userData.type==="NonParametricGeometry"}updateByPatchedOp(t,e,i){super.updateByPatchedOp(t,e,i),er(t.path,["geometry"])&&this.updateByPatchedOpGeometry(ea.drop(t,1),e.geometry,i)}removeInteractionGeometry(t){this.localGeometry?.dispose(),this.localGeometry=void 0}dispose(){var t;super.dispose(),t=this.uuid,ER.delete(t)}get appliedGeometrySize(){let t=this.localGeometry?.userData;if(t!==void 0&&t.sxPrev!==void 0)return[t.sxPrev,t.syPrev,t.szPrev]}updateGeometryInteractions(t,e){this.invalidateDownstreamBooleanData();let i=this.data.geometry.type;if(i==="NonParametricGeometry"||i==="SubdivGeometry"){let r,s,n,a=t;if(this.localGeometry===void 0){let d={...this.data.geometry,...a};this.localGeometry=im(d,e,this.data.flatShading,this)}a.scaleBaked?[r,s,n]=a.scaleBaked:{width:r,height:s,depth:n}=a;let o=this.localGeometry.userData,l=typeof r=="number"?r:1,u=typeof s=="number"?s:1,h=typeof n=="number"?n:1;o.sxPrev!==void 0&&HU(this.localGeometry.attributes,l/o.sxPrev,u/o.syPrev,h/o.szPrev),o.sxPrev=l,o.syPrev=u,o.szPrev=h}else if(!this.absorbDepthInteraction(t)){let r=im({...this.data.geometry,...t},e,this.data.flatShading,this);this.localGeometry!==void 0&&this.supportsInPlaceGeometryUpdate(this.localGeometry)&&BO(this.localGeometry,r)?r.dispose():(this.localGeometry?.dispose(),this.localGeometry=r)}}absorbDepthInteraction(t){let e=this.localGeometry;if(e?.shiftDepthTo===void 0)return!1;let i=t;if(typeof i.depth!="number")return!1;let r=e.userData?.parameters;if(r===void 0)return!1;for(let s of Object.keys(i))if(s!=="depth"&&i[s]!==r[s])return!1;return!!e.shiftDepthTo(i.depth)&&(r.depth=i.depth,!0)}refreshAttachedClonersInteractions(t){for(let e of this.attachedSurfaceCloners)e.update(t)}refreshAttachedCloners(t){for(let e of this.attachedSurfaceCloners)t.scene.addPendingUpdateCloner(e.object)}refreshAttachedPaths(t){for(let e of this.attachedPaths)t.scene.addPendingCommand(()=>e.updateShape())}createGeometryDelayed(t){this.geometryCreateDeleyed=t.shared,this.refreshAttachedCloners(t),this.refreshAttachedPaths(t)}updateByPatchedOpGeometry(t,e,i){let r=!1;if(t.type===0&&t.path.length===0&&Object.keys(t.props).includes("scaleBaked")&&this.geometryCreateDeleyed instanceof us&&this.chooseGeoemtryCache(i.shared).mutateIfUnique(this.geometryCreateDeleyed.data,e)===this.geometryCreateDeleyed&&(r=!0,this.geometryCreateDeleyed.mutateDirectlyScaleBaked(e,t.props.scaleBaked),this.refreshAttachedCloners(i),this.refreshAttachedPaths(i)),!r&&t.type===0&&t.path.length===0&&bgt(t.props)&&this.geometryCreateDeleyed instanceof us&&this.chooseGeoemtryCache(i.shared).mutateIfUnique(this.geometryCreateDeleyed.data,e)===this.geometryCreateDeleyed&&(r=!0,this.geometryCreateDeleyed.mutateDirectlySubdivisions(e),this.refreshAttachedCloners(i),this.refreshAttachedPaths(i)),!r&&t.type===0&&t.path.length===0&&this.geometryCreateDeleyed instanceof ye&&!(this.geometryCreateDeleyed instanceof us)&&this.supportsInPlaceGeometryUpdate(this.geometryCreateDeleyed)&&this._geometryCacheKey!==void 0){let s=i.shared,n=this.chooseGeoemtryCache(s),a=this.geometryCreateDeleyed;if(n.getCached(this._geometryCacheKey)===a&&a.isShared!==!0){let o=this.dataPatched.geometry,l=im(o,s,this.data.flatShading,this);BO(a,l)?(l.dispose(),a.computeBoundingSphere(),n.mutateIfUnique(this._geometryCacheKey,o)):(l.computeBoundingSphere(),n.forceDelete(this._geometryCacheKey),n.adopt(o,l),this.geometryCreateDeleyed=l),this._geometryCacheKey=o,r=!0,this.refreshAttachedCloners(i),this.refreshAttachedPaths(i)}}r||(i.scene?.markGeometryCacheDirty(),this.createGeometryDelayed(i)),this.syncShapeBlendNodeLayer(),this.resetBBoxNeedsUpdate(),this.invalidateDownstreamBooleanData()}updateGeometryOnStateUpdate(t,e){this.createGeometryDelayed(e)}applyTransientGeometryData(t,e){let i=t.shared,r=this.dataPatched.geometry;if(this.geometryCreateDeleyed instanceof ye&&!(this.geometryCreateDeleyed instanceof us)&&this.supportsInPlaceGeometryUpdate(this.geometryCreateDeleyed)&&this._geometryCacheKey!==void 0){let s=this.chooseGeoemtryCache(i),n=this.geometryCreateDeleyed;if(s.getCached(this._geometryCacheKey)===n&&n.isShared!==!0){let a=im(r,i,this.data.flatShading,this);return BO(n,a)?(a.dispose(),n.computeBoundingSphere(),s.mutateIfUnique(this._geometryCacheKey,r)):(a.computeBoundingSphere(),s.forceDelete(this._geometryCacheKey),s.adopt(r,a),this.geometryCreateDeleyed=a),this._geometryCacheKey=r,this.refreshAttachedCloners(t),void this.refreshAttachedPaths(t)}}e&&this._geometryCacheKey!==void 0&&this.chooseGeoemtryCache(i).forceDelete(this._geometryCacheKey),t.scene?.markGeometryCacheDirty(),this.createGeometryDelayed(t)}updateState(t,e){t.geometry!==void 0&&this.updateGeometryOnStateUpdate(t.geometry,e);let i=t.morphTargetInfluences;if(i){this.updateMorphTargets(),this.geometry.morphTargetsRelative=!0;for(let{data:{name:r,value:s}}of i)this.updateMorphInfluences(r,e.shared.getVariable(s,[this.uuid,"morphTargetInfluences",r]))}super.updateState(t,e)}updateMorphInfluences(t,e){if(this.morphTargetDictionary===void 0)return;let i=this.morphTargetDictionary[t];i!==void 0&&(this.morphTargetInfluences[i]=e)}updateGeometryGroupsIfNeeded(){Array.isArray(this.material)&&this.geometry.groups.length===0&&this.geometry.addGroup(0,Math.max(this.geometry.getIndex()?.count??0,this.geometry.getAttribute("position").count),0)}updateEntityBoxSize(t,e){let i=this.geometry.userData.parameters;this.is2DType||this.isTextType?t.set(0,0,.5*i.depth):this.isNonParametric?(t.setScalar(0),this.geometry.boundingSphere&&t.copy(this.geometry.boundingSphere.center),e.set(i.width,i.height,i.depth??0).multiplyScalar(.5)):i.centerOffset?t.fromArray(i.centerOffset):t.setScalar(0),e.set(i.width,i.height,i.depth??0).multiplyScalar(.5)}updateMatrixWorld(t){super.updateMatrixWorld(t),this.bindMode==="attached"?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode==="detached"&&this.bindMatrixInverse.copy(this.bindMatrix).invert()}bind(t,e){this.skeleton=t,this.isSkinnedMesh=!0,e===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),e=this.matrixWorld),this.bindMatrix.copy(e),this.bindMatrixInverse.copy(e).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(t){let e=new Te,i=this.geometry.attributes.skinWeight;for(let r=0,s=i.count;r<s;r++){e.fromBufferAttribute(i,r);let n=1/e.manhattanLength();n!==1/0?e.multiplyScalar(n):e.set(1,0,0,0),i.setXYZW(r,e.x,e.y,e.z,e.w)}}boneTransform(t,e){let i=this.skeleton;if(i===void 0)return;let r=this.geometry;HO.fromBufferAttribute(r.attributes.skinIndex,t),$O.fromBufferAttribute(r.attributes.skinWeight,t),qO.copy(e).applyMatrix4(this.bindMatrix),e.set(0,0,0);for(let s=0;s<4;s++){let n=$O.getComponent(s);if(n!==0){let a=HO.getComponent(s);XO.multiplyMatrices(i.bones[a].matrixWorld,i.boneInverses[a]),e.addScaledVector(NK.copy(qO).applyMatrix4(XO),n)}}return e.applyMatrix4(this.bindMatrixInverse)}}});function fv(t){if(Array.isArray(t.material)){for(let e of t.material)if(e.getLayersOfType("outline").length===0)return}else if(!SR(t.material)||t.material.getLayersOfType("outline").length===0)return;t instanceof Fr&&t.is2DAndNoDepth?function(e){if(e.geometry.attributes.extrudeNormals||!e.geometry.attributes.position)return;let i=e.geometry.attributes.position.array,r=new Float32Array(i.length),s=new P;for(let n=0;n<i.length;n+=3)s.set(i[n],i[n+1],i[n+2]).normalize(),r[n]=s.x,r[n+1]=s.y,r[n+2]=s.z;e.geometry.setAttribute("extrudeNormal",new fe(r,3))}(t):function(e){if(e.geometry.attributes.extrudeNormal||!e.geometry.attributes.position||!e.geometry.attributes.normal)return;let i=new Map,r=e.geometry.attributes,s=r.position.array,n=r.normal.array,a=new Float32Array(s.length);for(let o=0;o<s.length;o+=3){let l=`${s[o]}_${s[o+1]}_${s[o+2]}`,u=new P(n[o],n[o+1],n[o+2]);i.has(l)?i.get(l)?.normals.push(u):i.set(l,{normals:[u],result:new P})}i.forEach((o,l)=>{for(let u of o.normals)o.result.add(u);o.result.divideScalar(o.normals.length)});for(let o=0;o<s.length;o+=3){let l=`${s[o]}_${s[o+1]}_${s[o+2]}`,u=i.get(l)?.result;u&&(a[o]=u.x,a[o+1]=u.y,a[o+2]=u.z)}e.geometry.setAttribute("extrudeNormal",new fe(a,3))}(t)}function YO(t){return Math.min(2047,Math.max(1,Math.round(2048*t)))/2048}function gv(t){if(!t.geometry.attributes.position)return;let e=t.geometry.attributes,i=e.position.array,r=e.randomColor;if(r!==void 0&&3*r.count===i.length)return;let s=new Float32Array(i.length),n=parseInt(t.uuid.replace(/\D/g,"")),a=[YO(qt.seededRandom(n)),YO(qt.seededRandom(n+1e4)),YO(qt.seededRandom(n+2e4))];for(let o=0;o<i.length;o++)s[o]=a[o%3];t.geometry.setAttribute("randomColor",new we(s,3))}var j5=G(()=>{dt(),_G(),bo()});function OK(t){let e=!1;return t.scene.objects.traverse((i,r)=>{r.geometry?.type==="BooleanGeometry"&&(e=!0)}),e}function C3t(t,e){let i=t.cloner;return i!==void 0&&i.parent===e?i:void 0}function IK(t,e,i,r){let s=16*(e.children.length+1);Qw.length<s&&(Qw=new Float32Array(s));let n=0,a=l=>{l.toArray(Qw,16*n),n++},o=e.parameters.hideBase!==!0;o&&a(r),ej.multiplyMatrices(t.hiddenMatrix,t.matrix);for(let l of e.children)!Sg(l)||l.playModeVisible===!1||(ij.multiplyMatrices(l.hiddenMatrix,l.matrix).multiply(l.pivotMatrix),zP.multiplyMatrices(ej,ij),(!o||!zP.equals(r))&&a(zP));try{return n===0?0:function(l,u){return vG(wR().instanced_union(yG(l),u))}(i,Qw.subarray(0,16*n))}finally{pft(i)}}var cd,BK,ej,ij,zP,Qw,um,OR,G5,Hh,Hu,IR,sT=G(()=>{la(),dt(),k5(),j5(),n0(),ns(),cd=new bt,BK=new bt,ej=new bt,ij=new bt,zP=new bt,Qw=new Float32Array(0),um=class extends yo{constructor(t,e,i){super(t,e),this.data=e,this.meshSetAddresses=[],this.needsTransformForDownstream=!1,this.geometry=new ye,this.onAfterRender=(r,s,n,a,o,l)=>{super.onAfterRender(r,s,n,a,o,l),this.recomputeBoolean()},this.geometry.userData.parameters={width:0,height:0,depth:0}}get booleanOp(){return this.data.geometry.operation}get phongAngle(){return this.data.geometry.phongAngle??45}get isLOD(){return this.recomputeBoolean(),!1}updateByPatchedOp(t,e,i){super.updateByPatchedOp(t,e,i),t.path.length===1&&t.path[0]==="geometry"&&t.type===0&&t.props.operation!==void 0&&(this.freeBooleanPointer(),this.resetBBoxNeedsUpdate())}freeBooleanPointer(){super.freeBooleanPointer(),this.geometry.dispose()}recomputeBoolean(t,e=!0){if(this.booleanMeshSetAddress!==-1&&!t)return;for(let r=0;r<this.children.length;r++){let s=this.children[r];s instanceof um&&s.dataPatched.visible===!0&&s.recomputeBoolean(t===!0,e)}this.meshSetAddresses=[];for(let r=0;r<this.children.length;r++){let s=this.children[r];if(s instanceof Bs&&s.dataPatched.visible===!0&&s.geometry.attributes.position?.count>0&&s.geometry.drawRange.count>0&&s.booleanMeshSetAddress!==0){cd.multiplyMatrices(s.hiddenMatrix,s.matrix).multiply(s.pivotMatrix);try{let n=C3t(s,this);if(s.booleanMeshSetAddress===-1){if((s.geometry.index??s.geometry.getAttribute("position")).count/3<15e5){let a=KMt(s.geometry,t===!0);s.booleanMeshSetAddress=n===void 0||a===-1?a:IK(s,n,a,cd)}if(s.booleanMeshSetAddress===-1)return;n===void 0&&MO(s.booleanMeshSetAddress,cd),s.booleanMatrixInvOld.copy(cd).invert(),s.booleanWasTransformed=!1}else s instanceof um&&s.needsTransformForDownstream===!0?(n===void 0?MO(s.booleanMeshSetAddress,cd):s.booleanMeshSetAddress=IK(s,n,s.booleanMeshSetAddress,cd),s.needsTransformForDownstream=!1):s.booleanWasTransformed===!0&&(MO(s.booleanMeshSetAddress,BK.multiplyMatrices(cd,s.booleanMatrixInvOld)),s.booleanMatrixInvOld.copy(cd).invert(),s.booleanWasTransformed=!1)}catch(n){console.error(n),s.booleanMeshSetAddress=0,s.geometry.userData.booleanOperationDidFail=!0;continue}if(s.booleanMeshSetAddress===0)continue;this.meshSetAddresses.push(s.booleanMeshSetAddress),s.geometry.userData.booleanOperationDidFail=!1}}if(this.meshSetAddresses.length===0){if(this.geometry.getAttribute("position")?.array.length!==0){let r=this.geometry;r.dispose(),this.geometry=new ye,this.geometry.userData=r.userData,this.geometry.boundingSphere=r.boundingSphere,this.geometry.setAttribute("position",new fe([],3))}return void this.geometry.setDrawRange(0,0)}if(t===!0)return function(r,s){let n=wR(),a=CY(r,s),o=n.mesh_topological_data(a),l=o.positions(),u=o.indices();return o.free(),a.free(),{positions:l,indices:u,verticesPerFace:new Uint8Array(u.length/3).fill(3)}}(this.meshSetAddresses,this.booleanOp);let i=this.geometry;i.dispose(),this.geometry=new ye,this.geometry.userData=i.userData,this.geometry.boundingSphere=i.boundingSphere;try{this.booleanMeshSetAddress=function(r,s,n,a){let o=wR(),l=CY(r,s),u=o.mesh_render_data(l,Math.max(a,0));if(n.setAttribute("position",new fe(u.positions(),3)),n.setAttribute("normal",new fe(u.normals(),3)),u.free(),n.boundingSphere===null&&(n.boundingSphere=new ta),l.tri_count()===0)n.boundingSphere.center.set(0,0,0),n.boundingSphere.radius=0,n.userData.parameters={width:0,height:0,depth:0};else{let h=l.bounds();n.boundingSphere.center.set(h[0],h[1],h[2]),n.boundingSphere.radius=(h[3]**2+h[4]**2+h[5]**2)**.5,n.userData.parameters={width:2*h[3],height:2*h[4],depth:2*h[5]}}return vG(l)}(this.meshSetAddresses,this.booleanOp,this.geometry,this.phongAngle)}catch(r){this.booleanMeshSetAddress=0,this.geometry.userData.booleanOperationDidFail=!0,console.error(r)}this.booleanMatrixInvOld.copy(this.matrix).invert(),this.needsTransformForDownstream=!0,fv(this),gv(this)}dispose(){super.dispose(),this.geometry.dispose()}}}),nT=G(()=>{dt(),vo(),s0(),(OR||(OR={})).is=function(t){return Mi.is(t)&&t instanceof qd},G5=(t,e)=>class extends r0(t,e){updateState_Light(i,r){if(this.updateState_Entity(i,r),i.color!==void 0&&(this.color=r.shared.color(i.color)),i.intensity!==void 0&&(this.intensity=i.intensity*Math.PI),i.depth!==void 0){let s=this.shadow;s.camera.far=i.depth,s.needsUpdate=!0}i.shadows!==void 0&&(this.castShadow=i.shadows)}}}),Sm=G(()=>{dt(),sT(),la(),s0(),Hh=t=>t instanceof Bs,Hu=t=>t!==null&&t instanceof um,IR=t=>EU.is(t)});function Sa(t,e){return e.color(t)}function VK(t=new Date,e){let i=e.format,r=t.getSeconds(),s=t;e&&e.timeZone!==null&&(s=function(d,c){try{let p=new Intl.DateTimeFormat("en-US",{timeZone:c,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hourCycle:"h23"}).formatToParts(d),m=f=>Number(p.find(g=>g.type===f)?.value);return new Date(m("year"),m("month")-1,m("day"),m("hour"),m("minute"),m("second"),d.getMilliseconds())}catch{return new Date(NaN)}}(new Date,e.timeZone));let n,a=s.getHours(),o=s.getMinutes();e.format12h24h==="12ampm"&&(n=a>=12?"PM":"AM");let l,u,h=a;switch(e.format12h24h!=="24"&&(h=a%12,h===0&&(h=12)),i){case"HH:mm:ss":l=[h,o,r];break;case"HH:mm":l=[h,o];break;case"HH":l=[h],n=void 0;break;case"mm":l=[o],n=void 0;break;case"ss":l=[r],n=void 0;break;case"year":u=s.getFullYear();break;case"month":u=s.getMonth()+1;break;case"dayOfYear":u=Math.floor((s.getTime()-new Date(s.getFullYear(),0,0).getTime())/864e5);break;case"dayOfMonth":u=s.getDate();break;case"secondOfDay":u=60*a*60+60*o+r;break;default:console.error("Unknown time format",i),u=0}return l!==void 0?{textValue:l,suffix:n}:u}var rj,tb,LG=G(()=>{}),E3t=G(()=>{dt(),ZS(),QS(),rj=class extends $v(Wpt){constructor(t,e=15,i=10066329){super(t,e,i),this.object=t,this.added=!1,this.name=`DirectionalLightHelper: ${t.uuid}`}raycast(t,e){Xv(this.object,rj.geometryHelper,t,e)}}}),W5=G(()=>{dt(),E3t(),nT(),tb=class extends G5(xS,rj){constructor(t,e,i){super(),this.super_Entity(t,e),this.castShadow=!0,this.shadow.mapSize.width=2048,this.shadow.mapSize.height=2048,this.shadow.normalBias=1,this.layers.enable(3);let r=this.shadow.camera;r.top=1250,r.bottom=-1250,r.right=1250,r.left=-1250,r.near=-1e4,r.far=2500;let s=new wS(this.shadow.camera);s.visible=!1,this.gizmos.shadowmap=s}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this.gizmos){let e=this.gizmos[t];e instanceof wS&&e.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.objectHelper&&this.objectHelper.update()}updateState(t,e){this.updateState_Light(t,e);let i=t.depth!==void 0&&t.depth!==this.shadow.camera.far||t.size!==void 0&&t.size/2!==this.shadow.camera.right;t.size!==void 0&&function(r,s){r.shadow.camera.right=s/2,r.shadow.camera.left=-s/2,r.shadow.camera.top=s/2,r.shadow.camera.bottom=-s/2,r.shadow.needsUpdate=!0}(this,t.size),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),t.penumbraSize!==void 0&&e.scene.markPenumbraSizeDirty(),i&&this.update()}}});function FG(t){return t instanceof yo&&t.needsAO&&!Cc(t)&&t.isDecalObject!==!0}function UG(t){let e=t.cloner;if(e&&Array.isArray(e.children))for(let i of e.children)i?.layers&&(i.layers.mask=t.layers.mask)}function jG(t){return t.getLayersOfType("reflection").filter(e=>e.data.visible).length}function P3t(t){let e=1/0,i=-1/0;for(let r of t.getLayersOfType("reflection")){let s=r.data;if(!s.visible||s.mirror===1)continue;let n=typeof s.blur=="number"?s.blur:null;e=Math.min(e,n??0),i=Math.max(i,n??10)}return e===1/0?null:{min:e,max:i}}function R3t(t){for(let e of t.getLayersOfType("reflection")){let i=e.data;if(!i.visible)continue;let{blur:r,thickness:s,steps:n,stepSize:a}=i;return typeof r!="number"||typeof s!="number"||typeof n!="number"||typeof a!="number"?"variable":{blur:r,thickness:s,steps:n,stepSize:a,tracingMode:i.tracingMode===1?1:0}}return null}function kK(t,e){let i={outline:!1,cavity:!1},r=t.layers.mask&q5,s=e.getLayersOfType("transmission"),n=e.getLayersOfType("outline"),a=jG(e),o=e.getLayersOfType("cavity");return(n.length>0||o.length>0)&&(t.layers.set(8),s.length>0&&t.layers.enable(3),a>0&&t.layers.enable(4),i.outline=n.length>0,i.cavity=o.length>0,gv(t),fv(t)),s.length===0&&n.length===0&&o.length===0&&a===0&&t.layers.set(0),r&&t.layers.set(9),!r&&FG(t)&&t.layers.enable(5),UG(t),i}function zK(t,e){if(!e.layers)return!1;let i=t.layers.mask&q5,r=!1,s=e.getLayersOfType("transmission").filter(l=>l.data.visible),n=e.getLayersOfType("outline").filter(l=>l.data.visible),a=jG(e),o=e.getLayersOfType("cavity").filter(l=>l.data.visible);return s.length>0&&(t.layers.set(3),(n.length>0||o.length>0)&&t.layers.enable(8),a>0&&t.layers.enable(4),r=!0),s.length===0&&n.length===0&&o.length===0&&a===0&&t.layers.set(0),i&&t.layers.set(9),!i&&FG(t)&&t.layers.enable(5),UG(t),r}function LK(t,e){var i;if(!e.layers)return!1;let r=t.layers.mask&q5,s=!1,n=jG(e),a=e.getLayersOfType("transmission").filter(u=>u.data.visible),o=e.getLayersOfType("outline").filter(u=>u.data.visible),l=e.getLayersOfType("cavity").filter(u=>u.data.visible);return n>0&&((i=t.userData).__splinePlanarMirror??(i.__splinePlanarMirror=0),t.layers.set(4),a.length>0&&t.layers.enable(3),(o.length>0||l.length>0)&&t.layers.enable(8),s=!0),n===0&&a.length===0&&o.length===0&&l.length===0&&t.layers.set(0),r&&t.layers.set(9),!r&&FG(t)&&t.layers.enable(5),UG(t),s}function sj(t,e,i,r=!1){let s=t.cloner;if(s){let n=null;if(t.raycast===Sr.prototype.raycast||t.raycast===Bs.prototype.raycast){let a=t.geometry;a&&(a.boundingSphere===null&&a.computeBoundingSphere(),n=a.boundingSphere)}for(let a of s.children){if(n!==null&&(nj.copy(n).applyMatrix4(a.matrixWorld),!e.ray.intersectsSphere(nj)))continue;let o=Rgt.copy(a.matrixWorld).invert(),l=Dgt.copy(e.ray).applyMatrix4(o),u=t.matrixWorld;l.applyMatrix4(u);let h=Pgt;h.set(l.origin,l.direction),h.near=e.near,h.far=e.far,h.layers.mask=e.layers.mask;let d=h.intersectObject(t,!1);d.length>0&&i.push({...d[0],object:r?a:t})}}}var q5,Pgt,Rgt,Dgt,nj,UM,Ngt,KO,ZO,QO,eb,Hs,GG=G(()=>{ns(),j5(),la(),n0(),dt(),q5=512,Pgt=new j7,Rgt=new bt,Dgt=new pc,nj=new ta}),D3t=G(()=>{dt(),ZS(),QS(),UM=class extends $v(jpt){constructor(t,e=6710886){super(t,e),this.object=t,this.matrix=t.matrixWorld,this.name=`SpotLightHelper: ${t.uuid}`}raycast(t,e){Xv(this.object,UM.geometryHelper,t,e)}update(){if(this.object!==void 0){let t=UM._vector,e=this.object.distance?this.object.distance:1e3,i=e*Math.tan(this.object.angle);this.cone.scale.set(i,i,e),t.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(t);let r=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let s=0,n=this.cone.material.length;s<n;s++)this.cone.material[s].color.set(r);else this.cone.material.color.set(r)}}},(Ngt=UM)._vector=new P}),H5=G(()=>{dt(),D3t(),nT(),KO=new P,ZO=new P,QO=new Me,eb=class extends G5(Vg,Ngt){constructor(t,e,i){super(),this.super_Entity(t,e),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let r=this.shadow.camera;r.fov=2*qt.RAD2DEG*this.angle,r.aspect=1,r.near=100,r.far=2500;let s=new wS(this.shadow.camera);s.visible=!1,this.gizmos.shadowmap=s,this.update()}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this.gizmos){let e=this.gizmos[t];e instanceof wS&&e.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),ZO.setFromMatrixPosition(this.matrixWorld),QO.setFromRotationMatrix(this.matrixWorld),KO.copy(this.up).applyQuaternion(QO).negate().multiplyScalar(this.distance),this.target.position.copy(ZO).add(KO),this.target.updateMatrixWorld(),this.objectHelper&&this.objectHelper.update()}updateState(t,e){this.updateState_Light(t,e),t.distance!==void 0&&(this.distance=t.distance),t.decay!==void 0&&(this.decay=t.decay),t.angle!==void 0&&(this.angle=t.angle),t.penumbra!==void 0&&(this.penumbra=t.penumbra),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.penumbraSize!==void 0&&e.scene.markPenumbraSizeDirty(),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}}}),Dc=G(()=>{ke(),Qh(),dt(),vo(),Rc(),LG(),R5(),W5(),Fi(),wm(),dt(),n0(),Sm(),GG(),H5(),Ii(),sT(),Hs=class extends B5(Yu){constructor(t,e,i){if(super(),this.data=e,this.bgColor=new Dr(1,1,1,1),this.fog=null,this.backupFog=new l8(16777215,.1,2e3),this.fogUseBGColor=!1,this.fogMode="linear",this.fogDensity=ia.getDensity({}),this.fogHeightFalloff=ia.getHeightFalloff({}),this.fogHeightBase=ia.getHeightBase({}),this.isActive=!1,this.skyState=null,this.skyStateVersion=0,this.gradingState=null,this.skyHdriHolder=null,this.aoColor=new ae,this.penumbraSizeArrayCache=null,this.super_Entity(t,e),this.personalCamera=new ln(i0,{...G2.defaultData,...e.camera,name:"Personal Camera"}),this.personalCamera.objectHelper.visible=!1,this.add(this.personalCamera),this.activeCamera=this.personalCamera,this.ambientLight=new _5(13882323,8553090,.75*Math.PI),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.ambientLight.removeFromParent(),this.add(this.ambientLight),e.uiScene){let r=wU();r===null?Nn("ui-2d","a page's 2D scene"):this.uiScene=new r.Scene2D((Array.isArray(t)?t[0]:t)+"-ui",e.uiScene,{dpr:window.devicePixelRatio,shared:i.shared})}else e.uiFrame&&this.createUICanvas(e.uiFrame,i)}get scene(){return this.parent}get postprocessing(){return this.data.postprocessing}get frameId(){return this.data.uiFrame}get frame(){return this.uiCanvas?.frame}createUICanvas(t,e){let i=wU();i!==null?(this.uiCanvas=new i.UICanvas(this.uuid+"-uiscreen",window.innerWidth,window.innerHeight,e),this.uiCanvas.isScreenSpace=!0,this.uiCanvas.promise.then(()=>{this.uiCanvas?.applyFrame(t),this.uiCanvas?.applySize()})):Nn("ui-2d","a page's UI canvas")}updateVisible(){}setBackgroundColor(t){this.bgColor=t,this.fogUseBGColor===!0&&(this.backupFog.color=t)}entityChildrenCount(){return this.uiScene?this.uiScene.children.length:super.entityChildrenCount()}updateAmbientLight(t,e){t.color!==void 0&&(this.ambientLight.color=Sa(t.color,e)),t.intensity!==void 0&&(this.ambientLight.intensity=t.intensity*Math.PI),t.enabled!==void 0&&(t.enabled?this.add(this.ambientLight):this.remove(this.ambientLight))}onDeactive(){this.isActive=!1}onActive(t){this.isActive=!0,t.fog=this.fog,this.traverseEntity(e=>{e instanceof um&&e.recomputeBoolean()}),this.updateShadow(this.data.shadow)}forceMaterialsUpdate(){this.traverseEntity(t=>{if(t instanceof yo)if(Array.isArray(t.material))for(let e of t.material)e.needsUpdate=!0;else t.material.needsUpdate=!0,t.material.dispose()})}updateShadow(t){if(t.softShadowQuality===void 0&&t.type===void 0||!this.isActive)return;let e=this.data.shadow;uv.isSoft(e)}updateFog(t,e){t.enabled?this.fog=this.backupFog:this.fog=null,this.isActive&&(this.scene.fog=this.fog),this.fogUseBGColor=t.useBackgroundColor,t.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=Sa(t.color,e),this.backupFog.near=t.near,this.backupFog.far=t.far,this.fogMode=ia.getMode(t),this.fogDensity=ia.getDensity(t),this.fogHeightFalloff=ia.getHeightFalloff(t),this.fogHeightBase=ia.getHeightBase(t)}updateSky(t,e){this.skyState=t??null,this.skyStateVersion++;let i=t?.hdri?.image;this.skyHdriHolder=i!=null?e.image(i):null}updateAo(t,e){t.aoColor!==void 0&&(this.aoColor=Sa(t.aoColor,e))}updateByOp(t,e,i,r){let s=this.data.uiFrame;super.updateByOp(t,e,i,r);let n=e;er(t.path,["fog"])?this.updateFog(n.fog,i.shared):er(t.path,["sky"])?this.updateSky(n.sky,i.shared):er(t.path,["grading"])?this.gradingState=n.grading??null:er(t.path,["ao"])?this.updateAo(n.ao,i.shared):er(t.path,["ambient"])?this.updateAmbientLight(n.ambient,i.shared):er(t.path,["shadow"])?this.updateShadow(n.shadow):t.type===0&&t.path.length===0&&(t.props.uiFrame!==void 0||s!==n.uiFrame)&&this.updateUIFrame(t.props.uiFrame,i)}updateUIFrame(t,e){t?(this.uiCanvas||this.createUICanvas(t,e),this.uiCanvas.enabled=!0,this.uiCanvas.applyFrame(t)):this.uiCanvas&&(this.uiCanvas.enabled=!1)}updateState(t,e){this.updateState_Entity(t,e),t.backgroundColor!==void 0&&this.setBackgroundColor(Sa(t.backgroundColor,e.shared)),t.fog!==void 0&&this.updateFog(t.fog,e.shared),t.sky!==void 0&&this.updateSky(t.sky,e.shared),t.grading!==void 0&&(this.gradingState=t.grading),t.ambient!==void 0&&this.updateAmbientLight(t.ambient,e.shared),t.ao!==void 0&&this.updateAo(t.ao,e.shared),t.shadow!==void 0&&this.updateShadow(t.shadow)}createFrame(t,e){}raycast(t,e){super.raycast(t,e)}switchActiveCamera(t){t&&t.isDescendantOf(this)&&(this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=t,t.objectHelper.visible=!1)}get playCamera(){return this.scene?.find(this.data.publish.playCamera)??this.personalCamera}switchToPlayCamera(){this.switchActiveCamera(this.playCamera)}get penumbraSizeArray(){return this.penumbraSizeArrayCache===null&&this.updatePenumbraSizeArray(),this.penumbraSizeArrayCache}updatePenumbraSizeArray(){this.penumbraSizeArrayCache=new Array(bU).fill(.5);let t=0,e=0;this.traverseEntity(i=>{if(!i.visible)return!0;i instanceof tb&&i.visible&&t<DP&&(this.penumbraSizeArrayCache[t]=i.data.penumbraSize??.5,t+=1),i instanceof eb&&i.visible&&t<bU-DP&&(this.penumbraSizeArrayCache[DP+e]=i.data.penumbraSize??.5,e+=1)})}raycastWithClones(t){let e=[],i=r=>{for(let s of r.children){let n=s.cloner;Mi.is(s)&&(s.visible||n?.object.data.visible)&&((Hh(s)||IR(s)&&this.scene.enableHelpers&&s.objectHelper.visible)&&(t.intersectObject(s,!1,e),sj(s,t,e,!0)),i(s))}};return i(this),e}updateEntity2DByOp(t,e,i,r){this.uiCanvas?.updateEntity2DByOp(t,e,i,r)}}});function FK(){return WG}function JO(){if(aj===null)throw new Error('[spe] Classic (WebGL) particles are not available in this build \u2014 it was compiled WebGPU-only. Re-export the scene with renderer "Both" or "WebGL 2", or load the full runtime.');return aj}function tI(t){return t?.isWebGPUSplineRenderer===!0}var WG,aj,Ogt=G(()=>{WG=null,aj=null});function oj(){return HG}var qG,HG,$G=G(()=>{qG=null,HG=null});function UK(t,e,i){return Jw.setRGB(t,e,i,Ds),{r:Jw.r,g:Jw.g,b:Jw.b}}function N3t(t,e,i){let r,s=VS(t.angle,0),[n,a]=lj(t.offset),[o,l]=lj(t.morph),u=t.colors??[],h=t.steps??[],d=Math.min(10,u.length,h.length);if(d===0)return[1,1,1,1];if(t.gradientType===1){let g=3*(e+o)-(e+n)-1,y=3*(i+l)-(i+a)-1;r=Math.hypot(g,y)+s}else if(t.gradientType===2){let g=-1*Math.atan2(e+o-.5+n,i+l-.5+a),y=s/Math.PI/-2+.5*g/Math.PI;r=y-Math.floor(y)}else{let g=.5+o/(e!==0?e:1e-6),y=l/(i!==0?i:1e-6),v=Math.cos(s)*g-Math.sin(s)*y,b=Math.sin(s)*g+Math.cos(s)*y,_=v*v+b*b;r=_>1e-12?(((e-.5+n)/2+v/2)*v+((i-.5+a)/2+b/2)*b)/_:0}let c=u[0][0],p=u[0][1],m=u[0][2],f=u[0][3];for(let g=1;g<d;g++){let y=h[g-1],v=h[g]-y,b=v!==0?Math.min(1,Math.max(0,(r-y)/v)):r>=y?1:0;t.smooth&&(b=b*b*(3-2*b)),c+=(u[g][0]-c)*b,p+=(u[g][1]-p)*b,m+=(u[g][2]-m)*b,f+=(u[g][3]-f)*b}return[c,p,m,f]}function O3t(t,e){let i=t,r=i?.data?.layers;if(r&&typeof r.forEach=="function"){let s=e,n=[];return r.forEach(a=>{let o=a.data;if(o.visible===!1||o.isMask===!0)return;let l=VS(o.alpha,1);if(!(l<=0))if(o.type==="color"){let u,h=o.color;typeof h=="string"?u=typeof s?.color=="function"?s.color(h):void 0:h&&typeof h.r=="number"&&(u=h),u&&n.push({kind:"color",layer:o,rgb:{...UK(u.r,u.g,u.b),a:u.a??1},alpha:l})}else o.type==="gradient"&&n.push({kind:"gradient",layer:o,alpha:l})}),n.length===0?null:(a,o)=>{let l=1,u=1,h=1,d=!0;for(let c of n){let p,m,f,g;if(c.kind==="color")({r:p,g:m,b:f}=c.rgb),g=c.rgb.a;else{let[v,b,_,x]=N3t(c.layer,a,o);({r:p,g:m,b:f}=UK(v,b,_)),g=x}let y=d?1:Math.min(1,Math.max(0,g*c.alpha));l+=(p-l)*y,u+=(m-u)*y,h+=(f-h)*y,d=!1}return{r:l,g:u,b:h}}}if(i?.color&&i.color.isColor===!0){let{r:s,g:n,b:a}=i.color;return()=>({r:s,g:n,b:a})}return null}var Jw,VS,lj,I3t=G(()=>{dt(),Jw=new ae,VS=(t,e)=>typeof t=="number"&&Number.isFinite(t)?t:e,lj=t=>Array.isArray(t)&&typeof t[0]=="number"&&typeof t[1]=="number"?[t[0],t[1]]:[0,0]});function B3t(t,e){if(t==="torus"){let l=e()*Math.PI*2,u=e()*Math.PI*2,h=Math.cos(l),d=Math.sin(l),c=Math.cos(u),p=Math.sin(u);return{x:(1.4+.7*c)*h,y:-(1.4+.7*c)*d,z:.7*p,nx:c*h,ny:-c*d,nz:p,cr:1,cg:1,cb:1}}if(t==="cylinder"){let l=e()*Math.PI*2,u=Math.cos(l),h=Math.sin(l);return{x:.8*u,y:1.6*(e()-.5),z:.8*h,nx:u,ny:0,nz:h,cr:1,cg:1,cb:1}}let i=e()*Math.PI*2,r=2*e()-1,s=Math.acos(r),n=Math.sin(s)*Math.cos(i),a=Math.cos(s),o=Math.sin(s)*Math.sin(i);return{x:n,y:a,z:o,nx:n,ny:a,nz:o,cr:1,cg:1,cb:1}}function V3t(t){let{geometry:e,matrix:i}=t,r=e.getAttribute("position");if(!r||r.count<3)return null;let s=e.getAttribute("normal"),n=e.getAttribute("uv"),a=e.getAttribute("color"),o=e.getIndex(),l=o?o.count/3:r.count/3;if(l<1)return null;let u=(y,v)=>o?o.getX(3*y+v):3*y+v,h=i?i.elements:null,d=i?new Ts().getNormalMatrix(i).elements:null,c=y=>{let v=r.getX(y),b=r.getY(y),_=r.getZ(y);return h?h[0]*v+h[4]*b+h[8]*_+h[12]:v},p=y=>{let v=r.getX(y),b=r.getY(y),_=r.getZ(y);return h?h[1]*v+h[5]*b+h[9]*_+h[13]:b},m=y=>{let v=r.getX(y),b=r.getY(y),_=r.getZ(y);return h?h[2]*v+h[6]*b+h[10]*_+h[14]:_},f=new Float64Array(l),g=0;for(let y=0;y<l;y++){let v=u(y,0),b=u(y,1),_=u(y,2),x=c(v),S=p(v),w=m(v),T=c(b)-x,A=p(b)-S,M=m(b)-w,C=c(_)-x,R=p(_)-S,O=m(_)-w,N=A*O-M*R,B=M*C-T*O,k=T*R-A*C;g+=.5*Math.sqrt(N*N+B*B+k*k),f[y]=g}return g<=0?null:{total:g,sample:(y,v)=>{let b=0,_=l-1;for(;b<_;){let Q=b+_>>1;f[Q]<y?b=Q+1:_=Q}let x=b,S=u(x,0),w=u(x,1),T=u(x,2),A=v(),M=v();A+M>1&&(A=1-A,M=1-M);let C,R,O,N=1-A-M,B=c(S)*N+c(w)*A+c(T)*M,k=p(S)*N+p(w)*A+p(T)*M,z=m(S)*N+m(w)*A+m(T)*M;if(s){if(C=s.getX(S)*N+s.getX(w)*A+s.getX(T)*M,R=s.getY(S)*N+s.getY(w)*A+s.getY(T)*M,O=s.getZ(S)*N+s.getZ(w)*A+s.getZ(T)*M,d){let Q=d[0]*C+d[3]*R+d[6]*O,it=d[1]*C+d[4]*R+d[7]*O,at=d[2]*C+d[5]*R+d[8]*O;C=Q,R=it,O=at}}else{let Q=c(S),it=p(S),at=m(S),St=c(w)-Q,yt=p(w)-it,Y=m(w)-at,pt=c(T)-Q,xt=p(T)-it,Tt=m(T)-at;C=yt*Tt-Y*xt,R=Y*pt-St*Tt,O=St*xt-yt*pt}let L=Math.sqrt(C*C+R*R+O*O)||1,V=1,q=1,j=1;if(a)V=a.getX(S)*N+a.getX(w)*A+a.getX(T)*M,q=a.getY(S)*N+a.getY(w)*A+a.getY(T)*M,j=a.getZ(S)*N+a.getZ(w)*A+a.getZ(T)*M;else if(t.sampleColor){let Q=n?n.getX(S)*N+n.getX(w)*A+n.getX(T)*M:.5,it=n?n.getY(S)*N+n.getY(w)*A+n.getY(T)*M:.5,at=t.sampleColor(Q,it);at&&(V=at.r,q=at.g,j=at.b)}return{x:B,y:k,z,nx:C/L,ny:R/L,nz:O/L,cr:V,cg:q,cb:j}}}}function jK(t){let e=Math.min(Math.max(1,Math.floor(t.guideStrands)),yv),i=function(l){let u=l>>>0;return()=>{u|=0,u=u+1831565813|0;let h=Math.imul(u^u>>>15,1|u);return h=h+Math.imul(h^h>>>7,61|h)^h,((h^h>>>14)>>>0)/4294967296}}(t.seed??1337),r=t.shape==="object"&&t.sampler,s=r?t.samplerRadius??Lh:Lh,n=new Float32Array(4*ec),a=new Float32Array(ec),o=new Float32Array(4*yv).fill(1);for(let l=0;l<e;l++){let u=r?t.sampler(i):B3t(t.shape,i),h=r?u.x:u.x*s,d=r?u.y:u.y*s,c=r?u.z:u.z*s,{nx:p,ny:m,nz:f}=u;o[4*l+0]=u.cr,o[4*l+1]=u.cg,o[4*l+2]=u.cb;let g,y,v,b=l*mg,_=(1.8+.8*i())*t.hairLength*s/(mg-1),x=.5+1.5*i(),S=(.02+.06*i())*s;Math.abs(m)<.99?(g=-f,y=0,v=p):(g=1,y=0,v=0);let w=Math.sqrt(g*g+y*y+v*v)||1;for(let T=0;T<mg;T++){let A=T/(mg-1),M=A*A*.4*s,C=S*Math.sin(A*x*Math.PI*2),R=4*(b+T);n[R+0]=h+p*_*T+C*g/w,n[R+1]=d+m*_*T-M+C*y/w,n[R+2]=c+f*_*T+C*v/w,n[R+3]=T===0?0:1,T<mg-1&&(a[b+T]=_)}}return{initialPositions:n,restLengths:a,unitScale:s,rootColors:o}}var mg,yv,ec,Lh,Up,d_,F0,sf,U0,LP,Igt=G(()=>{dt(),ec=(yv=16384)*(mg=32),Lh=100}),Bgt=G(()=>{dt(),la(),$G(),I3t(),Igt(),Up=1/60,d_=new bt,F0=new Me,sf=new P,U0=new P,LP=class extends Bs{constructor(t,e,i){super(t,e),this.type="HairSystem",this.isHairSystem=!0,this.simRunning=!1,this.previewRequested=!1,this.playModeActive=!1,this.pendingSimSeconds=0,this.simTime=0,this.resetRequested=!0,this.generation=0,this.settledSimSeconds=0,this.lastMotionFingerprint=0,this.lastBoneQuat=new Me,this.lastBonePos=new P,this.hasLastBone=!1,this.baseFoundAtRegen=!1,this.baseSourceGeomsAtRegen=[],this.baseSourceHashesAtRegen=[],this.baseColorHashAtRegen=0,this.baseScaleAtRegen=0,this.classicFallbackWarned=!1,this.regenSnapshot=null,this.context=i,this.data=e,this.geometry.setAttribute("position",new we(new Float32Array(0),3)),this.material=new Uo({colorWrite:!1,depthWrite:!1}),this.frustumCulled=!1,this.scalpMesh=new Sr(new Tc(Lh,48,32),new Uo({color:5448477})),this.scalpMesh.name="HairScalp",this.add(this.scalpMesh);let r=new $4;r.setAttribute("position",new we(new Float32Array(12),3)),r.setIndex([0,2,1,2,3,1]),r.instanceCount=0,this.ribbonMesh=new Sr(r,new Uo({visible:!1})),this.ribbonMesh.name="HairRibbons",this.ribbonMesh.frustumCulled=!1,this.ribbonMesh.visible=!1,this.ribbonMesh.matrixAutoUpdate=!1,this.ribbonMesh.updateMatrixWorld=()=>{this.ribbonMesh.matrixWorld.identity()},this.ribbonMesh.updateWorldMatrix=()=>{this.ribbonMesh.matrixWorld.identity()},this.add(this.ribbonMesh),this.activeGuideStrands=e.guideStrands,this.roots=this.buildRoots(),this.regenSnapshot={guideStrands:e.guideStrands,hairLength:e.hairLength,spreadRadius:e.spreadRadius,headShape:e.headShape,baseObjectId:e.baseObjectId},this.applyScalpState(),this.applyShadowState(),this.syncSimRunning()}update(t){!this.simRunning||(this.pendingSimSeconds=Math.min(this.pendingSimSeconds+t/1e3,4*Up*2),this.trackMotionRest(t/1e3))}trackMotionRest(t){this.boneTransform(F0,sf);let e=this.hasLastBone&&(Math.abs(this.lastBoneQuat.dot(F0))<.9999995||this.lastBonePos.distanceToSquared(sf)>1e-8),i=this.motionFingerprint(),r=!this.hasLastBone||e||this.resetRequested||i!==this.lastMotionFingerprint||this.data.windStrength>.001;this.lastBoneQuat.copy(F0),this.lastBonePos.copy(sf),this.lastMotionFingerprint=i,this.hasLastBone=!0,this.settledSimSeconds=r?0:this.settledSimSeconds+t}motionFingerprint(){let t=this.data;return t.gravity+2*t.damping+3*t.localStiffness+4*t.globalStiffness+5*t.globalRange+6*t.stiffnessFalloff+7*t.windStrength+8*t.vspCoefficient+9*t.kink+10*t.kinkFrequency+11*t.clumpStrength+12*t.clumpSize+13*t.clumpTipScale}get isSimulating(){return(this.simRunning||this.resetRequested)&&this.visible}get isMotionSettled(){return this.settledSimSeconds>6}get isVisiblyAnimating(){return this.isSimulating&&!this.isMotionSettled}startPreview(){this.previewRequested=!0,this.syncSimRunning()}stopPreview(){this.previewRequested=!1,this.syncSimRunning()}setPlayMode(t){this.playModeActive=t,t&&this.resetSimulation(),this.syncSimRunning()}resetSimulation(){this.resetRequested=!0,this.pendingSimSeconds=0,this.simTime=0,this.settledSimSeconds=0}warnClassicFallbackOnce(){this.classicFallbackWarned||(this.classicFallbackWarned=!0,console.warn("[spline] Hair System strands require the WebGPU renderer \u2014 the WebGL fallback shows only the scalp. Reload with ?renderer=webgpu in a WebGPU-capable browser."))}syncSimRunning(){this.simRunning=this.playModeActive||this.previewRequested||this.data.autoPlay}updateState(t,e){super.updateState(t,e),this.updateHairState(t)}updateHairState(t){if((t.guideStrands!==void 0||t.hairLength!==void 0||t.spreadRadius!==void 0||t.headShape!==void 0||t.baseObjectId!==void 0)&&this.regenerate(),(t.headShape!==void 0||t.baseObjectId!==void 0)&&this.applyScalpState(),t.headColor!==void 0){let e=this.scalpMesh.material;e.isMeshBasicMaterial===!0&&e.color.setRGB(t.headColor.r,t.headColor.g,t.headColor.b,Ds)}(t.castShadow!==void 0||t.receiveShadow!==void 0)&&this.applyShadowState(),t.autoPlay!==void 0&&this.syncSimRunning()}applyShadowState(){let t=this.data.castShadow??!0,e=this.data.receiveShadow??!0;this.castShadow=t,this.receiveShadow=e,this.scalpMesh.castShadow=t,this.scalpMesh.receiveShadow=e,this.ribbonMesh.castShadow=t,this.ribbonMesh.receiveShadow=e}regenerate(){this.activeGuideStrands=Math.max(1,Math.min(Math.floor(this.data.guideStrands),16384)),this.roots=this.buildRoots(),this.generation++,this.regenSnapshot={guideStrands:this.data.guideStrands,hairLength:this.data.hairLength,spreadRadius:this.data.spreadRadius,headShape:this.data.headShape,baseObjectId:this.data.baseObjectId},this.resetSimulation()}checkDataDrift(){let t=this.data,e=this.regenSnapshot;if(e===null||e.guideStrands!==t.guideStrands||e.hairLength!==t.hairLength||e.spreadRadius!==t.spreadRadius||e.headShape!==t.headShape||e.baseObjectId!==t.baseObjectId){let i=e===null||e.headShape!==t.headShape||e.baseObjectId!==t.baseObjectId;this.regenerate(),i&&this.applyScalpState()}this.syncSimRunning(),this.applyShadowState(),this.checkBaseDrift()}buildRoots(){let{headShape:t,baseObjectId:e,guideStrands:i,hairLength:r}=this.data;if(this.baseFoundAtRegen=!1,this.baseSourceGeomsAtRegen=[],this.baseSourceHashesAtRegen=[],this.baseColorHashAtRegen=0,this.baseScaleAtRegen=0,t==="object"&&e){let s=this.context.scene.find(e);if(s){this.baseFoundAtRegen=!0,s.updateWorldMatrix(!0,!0);let n=this.collectBaseSources(s),a=n?function(o){let l=[];for(let d of o){let c=V3t(d);c&&l.push(c)}if(l.length===0)return null;let u=new Float64Array(l.length),h=0;for(let d=0;d<l.length;d++)h+=l[d].total,u[d]=h;return h<=0?null:d=>{let c=d()*h,p=0,m=l.length-1;for(;p<m;){let g=p+m>>1;u[g]<c?p=g+1:m=g}let f=p===0?c:c-u[p-1];return l[p].sample(f,d)}}(n.sources):null;if(this.baseSourceGeomsAtRegen=n?.sources.map(o=>o.geometry)??[],this.baseSourceHashesAtRegen=n?.hashes??[],this.baseColorHashAtRegen=n?.colorHash??0,n&&a){let o=this.baseWorldScale(s),l=Math.max(n.radius*o,.001);this.baseScaleAtRegen=o;let u=o;return jK({shape:"object",guideStrands:i,hairLength:r,sampler:h=>{let d=a(h);return{...d,x:d.x*u,y:d.y*u,z:d.z*u}},samplerRadius:l})}}}return jK({shape:t==="object"?"sphere":t,guideStrands:i,hairLength:r})}collectBaseSources(t){let e=[],i=[],r=0,s=0;d_.copy(t.matrixWorld).invert();let n=d_.clone(),a=o=>{if(o.isHairSystem===!0||o!==t&&o.visible===!1)return;let l=o.geometry;if(o.isMesh===!0&&l&&(l.getAttribute("position")?.count??0)>=3){let u=o===t?void 0:new bt().multiplyMatrices(n,o.matrixWorld),h=Array.isArray(o.material)?o.material[0]:o.material;e.push({geometry:l,matrix:u,sampleColor:O3t(h,this.context.shared)??void 0}),i.push(LP.matrixHash(u)),s+=function(c,p){let m=c,f=0,g=1,y=b=>{f+=b*g,g+=1},v=m?.data?.layers;if(v&&typeof v.forEach=="function"){let b=p;v.forEach(_=>{let x=_.data;if(x.visible!==!1){if(x.type==="color"){let S=x.color,w=typeof S=="string"?typeof b?.color=="function"?b.color(S):void 0:S;w&&typeof w.r=="number"&&(y(w.r),y(w.g),y(w.b)),y(VS(x.alpha,1))}else if(x.type==="gradient"){let S=x;for(let w of S.colors??[])y(w[0]),y(w[1]),y(w[2]),y(w[3]);for(let w of S.steps??[])y(w);y(VS(S.angle,0)),y(S.gradientType),y(S.smooth?1:0)}}})}else m?.color&&m.color.isColor===!0&&(y(m.color.r),y(m.color.g),y(m.color.b));return f}(h,this.context.shared),l.boundingSphere===null&&l.computeBoundingSphere();let d=l.boundingSphere;if(d){let c=0,p=1;u?(sf.copy(d.center).applyMatrix4(u),c=sf.length(),p=LP.matrixMaxScale(u)):c=d.center.length(),r=Math.max(r,c+d.radius*p)}}for(let u of o.children)a(u)};return a(t),e.length===0?null:{sources:e,hashes:i,radius:Math.max(r,.001),colorHash:s}}static matrixHash(t){if(!t)return 0;let e=t.elements,i=0;for(let r=0;r<16;r++)i+=e[r]*(r+1);return i}static matrixMaxScale(t){let e=t.elements,i=Math.hypot(e[0],e[1],e[2]),r=Math.hypot(e[4],e[5],e[6]),s=Math.hypot(e[8],e[9],e[10]);return Math.max(i,r,s,1e-6)}baseWorldScale(t){return d_.copy(t.matrixWorld).decompose(sf,F0,U0),Math.max(Math.abs(U0.x),Math.abs(U0.y),Math.abs(U0.z),1e-6)}get widthWorldScale(){return this.data.headShape==="object"&&this.data.baseObjectId&&this.baseScaleAtRegen>0?this.baseScaleAtRegen:1}checkBaseDrift(){if(this.data.headShape!=="object"||!this.data.baseObjectId)return;let t=this.context.scene.find(this.data.baseObjectId);if(!t)return;if(!this.baseFoundAtRegen)return void this.regenerate();t.updateWorldMatrix(!0,!0);let e=this.collectBaseSources(t),i=e?.sources??[],r=e?.hashes??[],s=this.baseSourceGeomsAtRegen,n=this.baseSourceHashesAtRegen,a=i.length!==s.length;if(!a){for(let o=0;o<i.length;o++)if(i[o].geometry!==s[o]||Math.abs(r[o]-n[o])>1e-4*Math.max(Math.abs(n[o]),1)){a=!0;break}}if(!a&&this.data.hairColorSource==="object"&&(e?.colorHash??0)!==this.baseColorHashAtRegen&&(a=!0),!a&&i.length>0){let o=this.baseWorldScale(t);a=Math.abs(o-this.baseScaleAtRegen)>.001*Math.max(this.baseScaleAtRegen,1e-6)}a&&this.regenerate()}applyScalpState(){let t=this.data.headShape,e=t==="object"&&this.data.baseObjectId!==null;this.scalpMesh.visible=!e,!e&&(this.scalpMesh.geometry.dispose(),this.scalpMesh.geometry=t==="torus"?new H4(1.4*Lh,.7*Lh,24,48):t==="cylinder"?new V2(.8*Lh,.8*Lh,1.6*Lh,48,1):new Tc(Lh,48,32))}boneTransform(t,e){let i=this.matrixWorld;if(this.data.headShape==="object"&&this.data.baseObjectId){let r=this.context.scene.find(this.data.baseObjectId)?.matrixWorld;r&&(i=r)}d_.copy(i).decompose(e,t,U0)}raycast(t,e){if(!this.scalpMesh.visible)return;let i=[];this.scalpMesh.raycast(t,i);for(let r of i)r.object=this,e.push(r)}get shadowBoundsRadius(){let t=this.data.headShape==="torus"?2.6:1.5;return this.roots.unitScale*(t+2.6*Math.max(this.data.hairLength,0))}getShadowBoundsCenter(t){return this.boneTransform(F0,t),t}updateEntityBoxSize(t,e){let i=this.shadowBoundsRadius;t.set(0,0,0),e.set(i,i,i)}dispose(){super.dispose(),this.scalpMesh.geometry.dispose(),this.scalpMesh.material.dispose(),this.ribbonMesh.geometry.dispose(),this.ribbonMesh.material.dispose?.(),oj()?.release(this)}}});function FP(){return{shapeInput:()=>`
|
|
354
354
|
const float posRowCoord = ${.5/uc};
|
|
355
355
|
const float quatRowCoord = ${1.5/uc};
|
|
356
356
|
const float param1RowCoord = ${2.5/uc};
|
|
@@ -5085,11 +5085,11 @@ void main() {
|
|
|
5085
5085
|
void main() {
|
|
5086
5086
|
vec4 texel = texture2D( tDiffuse, vUv );
|
|
5087
5087
|
gl_FragColor = texel;
|
|
5088
|
-
}`}),mPt=new class{constructor(t){this._mesh=new Sr(pPt,t)}dispose(){this._mesh.geometry.dispose()}render(t){t.render(this._mesh,cPt)}get material(){return this._mesh.material}set material(t){this._mesh.material=t}}(Gbt),oF=null,lF=null,fPt=ei.identity(),Wbt=class{constructor(t,e,i,r){var s;this.uuid=t,this.width=e,this.height=i,this.context=r,this.enabled=!0,this.isScreenSpace=!1,this.dpr=window.devicePixelRatio,this.isFrameDirty=!1,this.onRenderRequestedDownstream=()=>{this.isFrameDirty=!0,this.isScreenSpace||Q2.add(this),this.context.shared.requestRender()},this._innerApplySize=()=>{let n=this.width,a=this.height;this.renderer.dpr=but(n,a,this.dpr,this.isScreenSpace),this.renderer.setSize(n,a)},this.onFrameOverrideObjectEvent=n=>{if(n.target?.uuid!==void 0){let a=this.frameRoot?.find(n.target.uuid);a&&a.dispatchEvent({...n,target:a})}},this.scene2d=new FW(qt.generateUUID(),yU.defaultData,{dpr:window.devicePixelRatio,shared:r.shared}),this.canvas=(oF===null&&(oF=document.createElement("canvas")),oF),this.renderer=(s=this.canvas,lF===null&&(lF=new nPt(s)),lF),this.promise=this.init(),this.renderTarget=new dg(1,1,{type:ai,stencilBuffer:!1,depthBuffer:!1}),r.shared.addUIBuffer(this.uuid,this.renderTarget),this.textureHolder=r.shared.uiBuffer(this.uuid)}get canvasTexture(){return this._canvasTexture||(this._canvasTexture=new L7(this.canvas)),this._canvasTexture}async init(){await this.renderer.init(),this.renderer.uiFontReady?.then(()=>{this.frameOverride&&this.onRenderRequestedDownstream()})}render(t){if(this.isFrameDirty){if(this.isFrameDirty=!1,this._innerApplySize(),this.renderer.clear(),this.frameOverride?.draw(this.renderer),this.renderer.render(),this.canvasTexture.needsUpdate=!0,t.blitTextureToTarget)t.blitTextureToTarget(this.canvasTexture,this.renderTarget);else{Gbt.uniforms.tDiffuse.value=this.canvasTexture;let e=t.getRenderTarget();t.setRenderTarget(this.renderTarget),t.clear(),mPt.render(t),t.setRenderTarget(e)}this.textureHolder?.setNeedsUpdate(!0)}}updateEntity2DByOp(t,e,i,r){this.scene2d.updateEntityByOp(t,e,i,r),this.applySize()}updateTreeByOp(t,e){this.scene2d.updateTreeByOp(t,e),this.applySize()}applyOverrides(t){if(this.frameOverride&&this.frameRoot){this.frameOverride.position=[0,0],this.frameOverride.rotation=0;let e=t?.width??this.width,i=t?.height??this.height;this.frameOverride.width=e,this.frameOverride.height=i,this.frameOverride.localMatrix=fPt,this.isScreenSpace&&(this.frameOverride.fill.color=qi.from0to1([0,0,0,0])),this.frameOverride.data={...this.frameOverride.data,width:e,height:i},qbt({objectOverride:this.frameOverride,objectRoot:this.frameRoot,newParentWidth:this.frameOverride.width,newParentHeight:this.frameOverride.height,initialParentWidth:this.frameRoot.width,initialParentHeight:this.frameRoot.height}),this.frameOverride.updateWorldMatrix(!0,!1,!0)}}applySize(t,e=window.devicePixelRatio){let i=Math.max(1,t?.width??this.width),r=Math.max(1,t?.height??this.height);this.dpr=e,this.width=i,this.height=r,this._innerApplySize();let s=function(n,a,o,l){let u=but(n,a,o,l),h=Math.max(o,512/Math.min(n,a)),d=Math.min(h,u);return{width:Math.max(1,Math.ceil(n*d)),height:Math.max(1,Math.ceil(a*d))}}(i,r,e,this.isScreenSpace);this.renderTarget.setSize(s.width,s.height),this._canvasTexture?.dispose(),this._canvasTexture=void 0,this.applyOverrides(t),this.frameOverride?.requestRender()}applyFrame(t){let e=this.context.scene.find2D(t);if(e&&e instanceof Zu)return this.disposeFrameOverride(),this.frameRoot=e,this.frameOverride=e.clone({dpr:this.renderer.dpr,shared:this.context.shared}),this.scene2d.add(this.frameOverride),this.applySize(),this.frame?.addEventListener("render",this.onRenderRequestedDownstream),this.frameOverride.traverse(i=>{i.addEventListener("beginState",this.onFrameOverrideObjectEvent),i.addEventListener("completeState",this.onFrameOverrideObjectEvent)}),this.frame?.requestRender(),e}get frame(){return this.frameOverride}get frameId(){return this.frame?.uuid}find(t){return this.scene2d.find(t)}get texture(){return this.textureHolder?.getTexture(1001)}disposeFrameOverride(){this.frameOverride?.removeEventListener("render",this.onRenderRequestedDownstream),this.frameOverride?.traverse(t=>{t.removeEventListener("beginState",this.onFrameOverrideObjectEvent),t.removeEventListener("completeState",this.onFrameOverrideObjectEvent)}),this.frameOverride&&this.scene2d.remove(this.frameOverride)}};function qbt({objectOverride:t,objectRoot:e,newParentWidth:i,newParentHeight:r,initialParentWidth:s,initialParentHeight:n}){if(t instanceof Zu&&e instanceof Zu||t instanceof pm&&e instanceof pm)for(let a=0,o=t.children.length;a<o;a++){let l=t.children[a],u=e.children[a];l&&u&&l.uuid===u.uuid&&gPt({objectOverride:l,objectRoot:u,newParentWidth:i,newParentHeight:r,initialParentWidth:s,initialParentHeight:n})}}function gPt({objectOverride:t,objectRoot:e,newParentWidth:i,newParentHeight:r,initialParentWidth:s,initialParentHeight:n}){let[a,o]=function(d){if(hF(d))return[d.width,d.height];if(d instanceof c5){let[c,p]=d.getHalfSize();return[2*c,2*p]}if(d instanceof pm){let[c,p]=d.recursiveBBox.getHalfSize();return[2*c,2*p]}return[0,0]}(e),{width:l,height:u,position:h}=jbt({constraints:t.data,newParentWidth:i,newParentHeight:r,initialParentWidth:s,initialParentHeight:n,objectInitialWidth:a,objectInitialHeight:o,objectInitialPosition:e.position});if(t.position=h,t.data={...t.data,position:h},t.states)for(let d in t.states)yPt({stateId:d,objectOverride:t,objectRoot:e,newParentWidth:i,newParentHeight:r,initialParentWidth:s,initialParentHeight:n});if(hF(t)||t instanceof pm)hF(t)&&(t.width=l,t.height=u,t.data={...t.data,width:l,height:u}),qbt({objectOverride:t,objectRoot:e,newParentWidth:l,newParentHeight:u,initialParentWidth:a,initialParentHeight:o});else if(t instanceof c5){let d=e,c=a!==0?l/a:1,p=o!==0?u/o:1;t.path=function(m,f=1,g=1){if(f<=0||g<=0)return m;if(Fbt(m))return console.warn("Cannot scale invalid path",m),aF([]);if(f===1&&g===1)return m;try{return aF((0,dPt.parseSVG)(m).map(y=>{let v={...y};return"x"in v&&(v.x=v.x*f),"y"in v&&(v.y=v.y*g),"x1"in v&&(v.x1=v.x1*f),"x2"in v&&(v.x2=v.x2*f),"y1"in v&&(v.y1=v.y1*g),"y2"in v&&(v.y2=v.y2*g),"rx"in v&&(v.rx=v.rx*f),"ry"in v&&(v.ry=v.ry*g),v}))}catch(y){return console.warn("Error parsing SVG path",y),aF([])}}(d.path,c,p),t.data={...t.data,path:t.path}}}function yPt({stateId:t,objectOverride:e,objectRoot:i,newParentWidth:r,newParentHeight:s,initialParentWidth:n,initialParentHeight:a}){let o=e.states?.[t],l=i.states?.[t];if(o&&l){let{width:u,height:h,position:d}=jbt({constraints:e.data,newParentWidth:r,newParentHeight:s,initialParentWidth:n,initialParentHeight:a,objectInitialWidth:Ug.isResizeable(l)?l.width:0,objectInitialHeight:Ug.isResizeable(l)?l.height:0,objectInitialPosition:l.position});Object.assign(e.states[t],{position:d}),Ug.isResizeable(o)&&Object.assign(e.states[t],{width:u,height:h})}}function hF(t){return t instanceof dT||t instanceof Zu||t instanceof zW||t instanceof LW}U5();var _ut,vPt=class extends Fr{constructor(t,e,i){super(t,e,i),this.isUIObject=!0,this.uiCanvas=new Wbt(t+"-canvas",e.geometry.width,e.geometry.height,i),this.uiCanvas.promise.then(()=>{this.applyFrame(this.dataPatched.geometry.frame,i.shared)})}updateByPatchedOpGeometry(t,e,i){super.updateByPatchedOpGeometry(t,e,i),t.type===0&&(t.props.frame!==void 0&&this.applyFrame(t.props.frame,i.shared),(t.props.width!==void 0||t.props.height!==void 0)&&this.applySize(t.props,i.shared))}applySize(t,e){let i=t?.width??this.dataPatched.geometry.width,r=t?.height??this.dataPatched.geometry.height;this.uiCanvas.applySize({width:i,height:r}),this.applyGeometryParametersFromFrame(e)}applyFrame(t,e){this.uiCanvas.applyFrame(t),this.applyGeometryParametersFromFrame(e),this.applyMaterialParametersFromFrame({shared:e})}applyGeometryParametersFromFrame(t){let e=this.frame;e&&(Object.assign(this.data,{geometry:Object.assign(this.data.geometry,{cornerRadius:e.cornerRadius,cornerType:0})}),Object.assign(this.dataPatched,{geometry:Object.assign(this.dataPatched.geometry,{cornerRadius:e.cornerRadius,cornerType:0})}),this.localGeometry?.dispose(),this.localGeometry=im(this.dataPatched.geometry,t,this.data.flatShading,this))}applyMaterialParametersFromFrame(t){let e=this.frame;if(e){let i=e.data.backgroundBlur;Object.assign(this.data.material.layers[0].data.texture,{image:this.uiCanvas.uuid}),Object.assign(this.data.material.layers[1].data,{roughness:i.radius,alpha:i.enabled?1:0}),Object.assign(this.dataPatched.material.layers[0].data.texture,{image:this.uiCanvas.uuid}),Object.assign(this.dataPatched.material.layers[1].data,{roughness:i.radius,alpha:i.enabled?1:0}),this.material.reset?.(this.dataPatched.material,t,!0)}}updateEntity2DByOp(t,e,i,r){this.uiCanvas.updateEntity2DByOp(t,e,i,r),t===this.frameId&&e.type===0&&(e.props.cornerRadius!==void 0?this.applyGeometryParametersFromFrame(r):er(e.path,["backgroundBlur"])&&this.applyMaterialParametersFromFrame({shared:r}))}get frame(){return this.uiCanvas.frame}get frameId(){return this.frame?.uuid}removeInteractionGeometry(t){super.removeInteractionGeometry(t),this.applySize({},t)}updateGeometryInteractions(t,e){super.updateGeometryInteractions(t,e),this.applySize({width:t.width,height:t.height},e);let i={...this.data.geometry,...t};this.localGeometry?.dispose(),this.localGeometry=im(i,e,this.data.flatShading,this)}};Ii(),Yv("UIGeometry",(t,e,i)=>new vPt(t,e,i)),O5=_ut={Scene2D:FW,UICanvas:Wbt,loadHanaUIRUNTIME:function(){return h5||(h5=async()=>async function(t,e){return await t.default(e?{module_or_path:e}:void 0),Object.getOwnPropertyDescriptor(t.Engine.prototype,"scene")||Object.defineProperty(t.Engine.prototype,"scene",{get:function(){let i=Object.create(t.SceneController.prototype);return i.__wbg_ptr=this.__wbg_ptr,i}}),{createEngine:i=>t.Engine.create(i,JSON.parse('{"schema":13,"scenes":[{"fi":0,"id":"32603ebf4-bd9a-54ba-c1e9-6645c3ee7a53","data":{"name":"Page","backgroundColor":[0,0,0,0],"objects":[]}}],"assets":{"images":{},"videos":{},"colors":{},"audios":{},"numbers":{},"booleans":{},"strings":{},"dynamicVariables":{"counters":{},"randoms":{},"timers":{},"times":{}},"fonts":{},"animations":{},"geometries":{},"emojiArt":{}},"publish":{"logo":true,"presentationSizing":"Contain","allowPageScroll":true,"showBackground":true},"framePublish":{},"components":{}}'),!0)}}(await Promise.resolve().then(()=>(fH(),mH)),nut??function(){let t=typeof process<"u"?"2.0.60":void 0;return`https://cdn.spline.design/@splinetool/runtime${t?`@${t}`:""}/build/hana-ui.wasm`}())),zbt().then(()=>{})},setHanaUIWasmUrl:function(t){nut=t}},xR!==null&&_ut.setHanaUIWasmUrl(xR),Or("ui-2d"),ZG(),fgt(),dt();var Hbt,uF,bPt=class{constructor(){this.type="ShapePath",this.color=new ae,this.subPaths=[],this.currentPath=null}moveTo(t,e){return this.currentPath=new z2,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath?.lineTo(t,e),this}quadraticCurveTo(t,e,i,r){return this.currentPath?.quadraticCurveTo(t,e,i,r),this}bezierCurveTo(t,e,i,r,s,n){return this.currentPath?.bezierCurveTo(t,e,i,r,s,n),this}splineThru(t){return this.currentPath?.splineThru(t),this}toShapes(){let t={loc:0,t:0};function e(u,h,d,c){let p=u.x,m=h.x,f=d.x,g=c.x,y=u.y,v=h.y,b=d.y,_=c.y,x=(g-f)*(y-b)-(_-b)*(p-f),S=(_-b)*(m-p)-(g-f)*(v-y),w=x/S,T=((m-p)*(y-b)-(v-y)*(p-f))/S;if(S===0&&x!==0||w<=0||w>=1||T<0||T>1)return null;if(x===0&&S===0){for(let A=0;A<2;A++){if(i(A===0?d:c,u,h),t.loc===0){let M=A===0?d:c;return{x:M.x,y:M.y,t:t.t}}if(t.loc===2)return{x:+(p+t.t*(m-p)).toPrecision(10),y:+(y+t.t*(v-y)).toPrecision(10),t:t.t}}return null}for(let A=0;A<2;A++)if(i(A===0?d:c,u,h),t.loc===0){let M=A===0?d:c;return{x:M.x,y:M.y,t:t.t}}return{x:+(p+w*(m-p)).toPrecision(10),y:+(y+w*(v-y)).toPrecision(10),t:w}}function i(u,h,d){let c,p=d.x-h.x,m=d.y-h.y,f=u.x-h.x,g=u.y-h.y,y=p*g-f*m;return u.x===h.x&&u.y===h.y?(t.loc=0,void(t.t=0)):u.x===d.x&&u.y===d.y?(t.loc=1,void(t.t=1)):void(y<-Number.EPSILON?t.loc=3:y>Number.EPSILON?t.loc=4:p*f<0||m*g<0?t.loc=5:Math.sqrt(p*p+m*m)<Math.sqrt(f*f+g*g)?t.loc=6:(c=p!==0?f/p:g/m,t.loc=2,t.t=c))}let r=0,s=999999999,n=-999999999,a=[];this.subPaths.forEach(u=>{let h=u.getPoints(),d=-999999999,c=999999999,p=-999999999,m=999999999;for(let f=0;f<h.length;f++){let g=h[f];g.y>d&&(d=g.y),g.y<c&&(c=g.y),g.x>p&&(p=g.x),g.x<m&&(m=g.x)}n<=p&&(n=p+1),s>=m&&(s=m-1),h.length&&a.push({curves:u.curves,points:h,isCW:x8.isClockWise(h),identifier:r++,boundingBox:new W7(new Z(m,c),new Z(p,d))})});let o=a.map(u=>function(h,d,c,p,m){(m==null||m==="")&&(m="nonzero");let f=new Z;h.boundingBox.getCenter(f);let g=function(S,w,T){let A=new Z;w.getCenter(A);let M=[];return T.forEach(C=>{C.boundingBox.containsPoint(A)&&function(R,O){let N=[],B=[];for(let k=1;k<R.length;k++){let z=R[k-1],L=R[k];for(let V=1;V<O.length;V++){let q=e(z,L,O[V-1],O[V]);q!==null&&N.find(j=>j.t<=q.t+Number.EPSILON&&j.t>=q.t-Number.EPSILON)===void 0&&(N.push(q),B.push(new Z(q.x,q.y)))}}return B}(S,C.points).forEach(R=>{M.push({identifier:C.identifier,isCW:C.isCW,point:R})})}),M.sort((C,R)=>C.point.x-R.point.x),M}([new Z(c,f.y),new Z(p,f.y)],h.boundingBox,d);g.sort((S,w)=>S.point.x-w.point.x);let y=[],v=[];g.forEach(S=>{S.identifier===h.identifier?y.push(S):v.push(S)});let b=y[0].point.x,_=[],x=0;for(;x<v.length&&v[x].point.x<b;)_.length>0&&_[_.length-1]===v[x].identifier?_.pop():_.push(v[x].identifier),x++;if(_.push(h.identifier),m==="evenodd"){let S=_.length%2==0,w=_[_.length-2];return{identifier:h.identifier,isHole:S,for:w}}if(m==="nonzero"){let S=!0,w=null,T=null;for(let A=0;A<_.length;A++){let M=_[A];d[M]&&(S?(T=d[M].isCW,S=!1,w=M):T!==d[M].isCW&&(T=d[M].isCW,S=!0))}return{identifier:h.identifier,isHole:S,for:w}}console.warn('fill-rule: "'+m+'" is currently not implemented.')}(u,a,s,n,this.userData?.style.fillRule)),l=[];return a.forEach(u=>{let h=o[u.identifier];if(h&&!h.isHole){let d=new bS;d.curves=u.curves,o.filter(c=>c?.isHole&&c.for===u.identifier).forEach(c=>{if(c){let p=a[c.identifier],m=new z2;m.curves=p.curves,d.holes.push(m)}}),l.push(d)}}),l}},$bt=!1,xut=new Promise(t=>{Hbt=t}),wut=!1;function Sut(){if($bt=!0,!wut)return uF||(uF=async function(){let t=await import("./opentype.js");Hbt(t),wut=!0}(),uF)}var _Pt=new class{async load(t,e,i=()=>{}){let{load:r}=await xut;r(t,(s,n)=>{s||!n?i(s??"Something went wrong"):e(n)})}async parse(t){let{parse:e,Bidi:i}=await xut;try{let r=e(t),s=new i,n=a=>r.charToGlyphIndex(a.char);return s.registerModifier("glyphIndex",null,n),s.applyFeatures(r,r.defaultRenderOptions.features),{font:r,bidi:s}}catch(r){console.error(r)}}};function xPt(t,e){return e.state.glyphIndex===t||e.state.fina===t||e.state.medi===t||e.state.init===t}dt(),TG(),Ii(),Yv("TextGeometry",(t,e,i)=>new X5(t,e,i));var Tut={create:(t,e)=>new WU(t,e)};xU("TextGeometry",Tut),xU("InputGeometry",Tut),SG=class{constructor(t){this._arrayBuffer=new ArrayBuffer(1),this._isLoaded=!1,this._intercepted=!1,this._layoutErrorWarned=!1,this._isUserFont=t.isUserFont??!1,this._loadingPromise=this.load(t)}update(t){this._isLoaded=!1,this._isUserFont=t.isUserFont??!1,this._loadingPromise=this.load(t)}async load(t){try{this._layoutErrorWarned=!1;let e=await async function(i){let r,s,n=!1;if(i.url?(r=await async function(a){let o;try{o=await fetch(a)}catch(l){throw new Error(`could not fetch the font at ${a}: ${l}`)}if(!o.ok)throw new Error(`${o.status} ${o.statusText} fetching the font at ${a}`);return await o.arrayBuffer()}(i.url),s=i.url,n=i.url.startsWith("/")):i.data&&(r=i.data.buffer.slice(i.data.byteOffset,i.data.byteOffset+i.data.byteLength)),r){if(!$bt)return{font:void 0,url:s,intercepted:n,arr:r,bidi:null};{let a=await _Pt.parse(r);if(a)return{font:a.font,url:s,intercepted:n,arr:r,bidi:a.bidi}}}}(t);e&&(this._arrayBuffer=e.arr,this._url=e.url,this.font=e.font,this._intercepted=e.intercepted,this._isLoaded=!0,this._bidi=e.bidi)}catch(e){console.warn(`Could not load the font "${t.url??"(inline data)"}"`,e)}}warnLayoutError(t){this._layoutErrorWarned||(this._layoutErrorWarned=!0,console.warn(`Text layout failed for the font "${this._url??"(inline data)"}"`,t))}get url(){return this._url}get intercepted(){return this._intercepted}get isLoaded(){return this._isLoaded}get loadingPromise(){return this._loadingPromise}reverseLigaturesTable(t,e,i){if(!this._bidi)return[];let r=this._bidi;r.getTextGlyphs(e);let s=r.tokenizer.tokens,n=[],a=0,o=i.length===s.length;for(let l=0;l<i.length;l++){let u=i[l].index,h=String.fromCharCode(i[l].unicode),d=s[a];if(xPt(u,d)||o)n.push({char:h,index:u,replacements:[d.state.glyphIndex],replacementChars:[d.char]}),a++;else{let c=d.char,p="",m=[d.state.glyphIndex],f=[],g=!1;for(;!g;)a++,p=e.charAt(a),c+=p,m.push(t.charToGlyphIndex(p)),f=t.stringToGlyphs(c),f.length===1&&f[0].index===u&&(g=!0),a>e.length&&(g=!0);n.push({char:h,index:u,replacements:m,replacementChars:Array.from(c)}),a++}}return n}generateShapes(t,e,i){if(!this._isLoaded)return;let r=this.font,s=e.fontSize/this.unitsPerEm,n=e.fontSize*e.lineHeight,a=t.map(y=>this.getTextWidth(y,e)),o=typeof e.width=="string"?Number(i.getVariable(e.width)):e.width,l=typeof e.height=="string"?Number(i.getVariable(e.height)):e.height,u=this.getCharWidth(`
|
|
5088
|
+
}`}),mPt=new class{constructor(t){this._mesh=new Sr(pPt,t)}dispose(){this._mesh.geometry.dispose()}render(t){t.render(this._mesh,cPt)}get material(){return this._mesh.material}set material(t){this._mesh.material=t}}(Gbt),oF=null,lF=null,fPt=ei.identity(),Wbt=class{constructor(t,e,i,r){var s;this.uuid=t,this.width=e,this.height=i,this.context=r,this.enabled=!0,this.isScreenSpace=!1,this.dpr=window.devicePixelRatio,this.isFrameDirty=!1,this.onRenderRequestedDownstream=()=>{this.isFrameDirty=!0,this.isScreenSpace||Q2.add(this),this.context.shared.requestRender()},this._innerApplySize=()=>{let n=this.width,a=this.height;this.renderer.dpr=but(n,a,this.dpr,this.isScreenSpace),this.renderer.setSize(n,a)},this.onFrameOverrideObjectEvent=n=>{if(n.target?.uuid!==void 0){let a=this.frameRoot?.find(n.target.uuid);a&&a.dispatchEvent({...n,target:a})}},this.scene2d=new FW(qt.generateUUID(),yU.defaultData,{dpr:window.devicePixelRatio,shared:r.shared}),this.canvas=(oF===null&&(oF=document.createElement("canvas")),oF),this.renderer=(s=this.canvas,lF===null&&(lF=new nPt(s)),lF),this.promise=this.init(),this.renderTarget=new dg(1,1,{type:ai,stencilBuffer:!1,depthBuffer:!1}),r.shared.addUIBuffer(this.uuid,this.renderTarget),this.textureHolder=r.shared.uiBuffer(this.uuid)}get canvasTexture(){return this._canvasTexture||(this._canvasTexture=new L7(this.canvas)),this._canvasTexture}async init(){await this.renderer.init(),this.renderer.uiFontReady?.then(()=>{this.frameOverride&&this.onRenderRequestedDownstream()})}render(t){if(this.isFrameDirty){if(this.isFrameDirty=!1,this._innerApplySize(),this.renderer.clear(),this.frameOverride?.draw(this.renderer),this.renderer.render(),this.canvasTexture.needsUpdate=!0,t.blitTextureToTarget)t.blitTextureToTarget(this.canvasTexture,this.renderTarget);else{Gbt.uniforms.tDiffuse.value=this.canvasTexture;let e=t.getRenderTarget();t.setRenderTarget(this.renderTarget),t.clear(),mPt.render(t),t.setRenderTarget(e)}this.textureHolder?.setNeedsUpdate(!0)}}updateEntity2DByOp(t,e,i,r){this.scene2d.updateEntityByOp(t,e,i,r),this.applySize()}updateTreeByOp(t,e){this.scene2d.updateTreeByOp(t,e),this.applySize()}applyOverrides(t){if(this.frameOverride&&this.frameRoot){this.frameOverride.position=[0,0],this.frameOverride.rotation=0;let e=t?.width??this.width,i=t?.height??this.height;this.frameOverride.width=e,this.frameOverride.height=i,this.frameOverride.localMatrix=fPt,this.isScreenSpace&&(this.frameOverride.fill.color=qi.from0to1([0,0,0,0])),this.frameOverride.data={...this.frameOverride.data,width:e,height:i},qbt({objectOverride:this.frameOverride,objectRoot:this.frameRoot,newParentWidth:this.frameOverride.width,newParentHeight:this.frameOverride.height,initialParentWidth:this.frameRoot.width,initialParentHeight:this.frameRoot.height}),this.frameOverride.updateWorldMatrix(!0,!1,!0)}}applySize(t,e=window.devicePixelRatio){let i=Math.max(1,t?.width??this.width),r=Math.max(1,t?.height??this.height);this.dpr=e,this.width=i,this.height=r,this._innerApplySize();let s=function(n,a,o,l){let u=but(n,a,o,l),h=Math.max(o,512/Math.min(n,a)),d=Math.min(h,u);return{width:Math.max(1,Math.ceil(n*d)),height:Math.max(1,Math.ceil(a*d))}}(i,r,e,this.isScreenSpace);this.renderTarget.setSize(s.width,s.height),this._canvasTexture?.dispose(),this._canvasTexture=void 0,this.applyOverrides(t),this.frameOverride?.requestRender()}applyFrame(t){let e=this.context.scene.find2D(t);if(e&&e instanceof Zu)return this.disposeFrameOverride(),this.frameRoot=e,this.frameOverride=e.clone({dpr:this.renderer.dpr,shared:this.context.shared}),this.scene2d.add(this.frameOverride),this.applySize(),this.frame?.addEventListener("render",this.onRenderRequestedDownstream),this.frameOverride.traverse(i=>{i.addEventListener("beginState",this.onFrameOverrideObjectEvent),i.addEventListener("completeState",this.onFrameOverrideObjectEvent)}),this.frame?.requestRender(),e}get frame(){return this.frameOverride}get frameId(){return this.frame?.uuid}find(t){return this.scene2d.find(t)}get texture(){return this.textureHolder?.getTexture(1001)}disposeFrameOverride(){this.frameOverride?.removeEventListener("render",this.onRenderRequestedDownstream),this.frameOverride?.traverse(t=>{t.removeEventListener("beginState",this.onFrameOverrideObjectEvent),t.removeEventListener("completeState",this.onFrameOverrideObjectEvent)}),this.frameOverride&&this.scene2d.remove(this.frameOverride)}};function qbt({objectOverride:t,objectRoot:e,newParentWidth:i,newParentHeight:r,initialParentWidth:s,initialParentHeight:n}){if(t instanceof Zu&&e instanceof Zu||t instanceof pm&&e instanceof pm)for(let a=0,o=t.children.length;a<o;a++){let l=t.children[a],u=e.children[a];l&&u&&l.uuid===u.uuid&&gPt({objectOverride:l,objectRoot:u,newParentWidth:i,newParentHeight:r,initialParentWidth:s,initialParentHeight:n})}}function gPt({objectOverride:t,objectRoot:e,newParentWidth:i,newParentHeight:r,initialParentWidth:s,initialParentHeight:n}){let[a,o]=function(d){if(hF(d))return[d.width,d.height];if(d instanceof c5){let[c,p]=d.getHalfSize();return[2*c,2*p]}if(d instanceof pm){let[c,p]=d.recursiveBBox.getHalfSize();return[2*c,2*p]}return[0,0]}(e),{width:l,height:u,position:h}=jbt({constraints:t.data,newParentWidth:i,newParentHeight:r,initialParentWidth:s,initialParentHeight:n,objectInitialWidth:a,objectInitialHeight:o,objectInitialPosition:e.position});if(t.position=h,t.data={...t.data,position:h},t.states)for(let d in t.states)yPt({stateId:d,objectOverride:t,objectRoot:e,newParentWidth:i,newParentHeight:r,initialParentWidth:s,initialParentHeight:n});if(hF(t)||t instanceof pm)hF(t)&&(t.width=l,t.height=u,t.data={...t.data,width:l,height:u}),qbt({objectOverride:t,objectRoot:e,newParentWidth:l,newParentHeight:u,initialParentWidth:a,initialParentHeight:o});else if(t instanceof c5){let d=e,c=a!==0?l/a:1,p=o!==0?u/o:1;t.path=function(m,f=1,g=1){if(f<=0||g<=0)return m;if(Fbt(m))return console.warn("Cannot scale invalid path",m),aF([]);if(f===1&&g===1)return m;try{return aF((0,dPt.parseSVG)(m).map(y=>{let v={...y};return"x"in v&&(v.x=v.x*f),"y"in v&&(v.y=v.y*g),"x1"in v&&(v.x1=v.x1*f),"x2"in v&&(v.x2=v.x2*f),"y1"in v&&(v.y1=v.y1*g),"y2"in v&&(v.y2=v.y2*g),"rx"in v&&(v.rx=v.rx*f),"ry"in v&&(v.ry=v.ry*g),v}))}catch(y){return console.warn("Error parsing SVG path",y),aF([])}}(d.path,c,p),t.data={...t.data,path:t.path}}}function yPt({stateId:t,objectOverride:e,objectRoot:i,newParentWidth:r,newParentHeight:s,initialParentWidth:n,initialParentHeight:a}){let o=e.states?.[t],l=i.states?.[t];if(o&&l){let{width:u,height:h,position:d}=jbt({constraints:e.data,newParentWidth:r,newParentHeight:s,initialParentWidth:n,initialParentHeight:a,objectInitialWidth:Ug.isResizeable(l)?l.width:0,objectInitialHeight:Ug.isResizeable(l)?l.height:0,objectInitialPosition:l.position});Object.assign(e.states[t],{position:d}),Ug.isResizeable(o)&&Object.assign(e.states[t],{width:u,height:h})}}function hF(t){return t instanceof dT||t instanceof Zu||t instanceof zW||t instanceof LW}U5();var _ut,vPt=class extends Fr{constructor(t,e,i){super(t,e,i),this.isUIObject=!0,this.uiCanvas=new Wbt(t+"-canvas",e.geometry.width,e.geometry.height,i),this.uiCanvas.promise.then(()=>{this.applyFrame(this.dataPatched.geometry.frame,i.shared)})}updateByPatchedOpGeometry(t,e,i){super.updateByPatchedOpGeometry(t,e,i),t.type===0&&(t.props.frame!==void 0&&this.applyFrame(t.props.frame,i.shared),(t.props.width!==void 0||t.props.height!==void 0)&&this.applySize(t.props,i.shared))}applySize(t,e){let i=t?.width??this.dataPatched.geometry.width,r=t?.height??this.dataPatched.geometry.height;this.uiCanvas.applySize({width:i,height:r}),this.applyGeometryParametersFromFrame(e)}applyFrame(t,e){this.uiCanvas.applyFrame(t),this.applyGeometryParametersFromFrame(e),this.applyMaterialParametersFromFrame({shared:e})}applyGeometryParametersFromFrame(t){let e=this.frame;e&&(Object.assign(this.data,{geometry:Object.assign(this.data.geometry,{cornerRadius:e.cornerRadius,cornerType:0})}),Object.assign(this.dataPatched,{geometry:Object.assign(this.dataPatched.geometry,{cornerRadius:e.cornerRadius,cornerType:0})}),this.localGeometry?.dispose(),this.localGeometry=im(this.dataPatched.geometry,t,this.data.flatShading,this))}applyMaterialParametersFromFrame(t){let e=this.frame;if(e){let i=e.data.backgroundBlur;Object.assign(this.data.material.layers[0].data.texture,{image:this.uiCanvas.uuid}),Object.assign(this.data.material.layers[1].data,{roughness:i.radius,alpha:i.enabled?1:0}),Object.assign(this.dataPatched.material.layers[0].data.texture,{image:this.uiCanvas.uuid}),Object.assign(this.dataPatched.material.layers[1].data,{roughness:i.radius,alpha:i.enabled?1:0}),this.material.reset?.(this.dataPatched.material,t,!0)}}updateEntity2DByOp(t,e,i,r){this.uiCanvas.updateEntity2DByOp(t,e,i,r),t===this.frameId&&e.type===0&&(e.props.cornerRadius!==void 0?this.applyGeometryParametersFromFrame(r):er(e.path,["backgroundBlur"])&&this.applyMaterialParametersFromFrame({shared:r}))}get frame(){return this.uiCanvas.frame}get frameId(){return this.frame?.uuid}removeInteractionGeometry(t){super.removeInteractionGeometry(t),this.applySize({},t)}updateGeometryInteractions(t,e){super.updateGeometryInteractions(t,e),this.applySize({width:t.width,height:t.height},e);let i={...this.data.geometry,...t};this.localGeometry?.dispose(),this.localGeometry=im(i,e,this.data.flatShading,this)}};Ii(),Yv("UIGeometry",(t,e,i)=>new vPt(t,e,i)),O5=_ut={Scene2D:FW,UICanvas:Wbt,loadHanaUIRUNTIME:function(){return h5||(h5=async()=>async function(t,e){return await t.default(e?{module_or_path:e}:void 0),Object.getOwnPropertyDescriptor(t.Engine.prototype,"scene")||Object.defineProperty(t.Engine.prototype,"scene",{get:function(){let i=Object.create(t.SceneController.prototype);return i.__wbg_ptr=this.__wbg_ptr,i}}),{createEngine:i=>t.Engine.create(i,JSON.parse('{"schema":13,"scenes":[{"fi":0,"id":"32603ebf4-bd9a-54ba-c1e9-6645c3ee7a53","data":{"name":"Page","backgroundColor":[0,0,0,0],"objects":[]}}],"assets":{"images":{},"videos":{},"colors":{},"audios":{},"numbers":{},"booleans":{},"strings":{},"dynamicVariables":{"counters":{},"randoms":{},"timers":{},"times":{}},"fonts":{},"animations":{},"geometries":{},"emojiArt":{}},"publish":{"logo":true,"presentationSizing":"Contain","allowPageScroll":true,"showBackground":true},"framePublish":{},"components":{}}'),!0)}}(await Promise.resolve().then(()=>(fH(),mH)),nut??function(){let t=typeof process<"u"?"2.0.61":void 0;return`https://cdn.spline.design/@splinetool/runtime${t?`@${t}`:""}/build/hana-ui.wasm`}())),zbt().then(()=>{})},setHanaUIWasmUrl:function(t){nut=t}},xR!==null&&_ut.setHanaUIWasmUrl(xR),Or("ui-2d"),ZG(),fgt(),dt();var Hbt,uF,bPt=class{constructor(){this.type="ShapePath",this.color=new ae,this.subPaths=[],this.currentPath=null}moveTo(t,e){return this.currentPath=new z2,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath?.lineTo(t,e),this}quadraticCurveTo(t,e,i,r){return this.currentPath?.quadraticCurveTo(t,e,i,r),this}bezierCurveTo(t,e,i,r,s,n){return this.currentPath?.bezierCurveTo(t,e,i,r,s,n),this}splineThru(t){return this.currentPath?.splineThru(t),this}toShapes(){let t={loc:0,t:0};function e(u,h,d,c){let p=u.x,m=h.x,f=d.x,g=c.x,y=u.y,v=h.y,b=d.y,_=c.y,x=(g-f)*(y-b)-(_-b)*(p-f),S=(_-b)*(m-p)-(g-f)*(v-y),w=x/S,T=((m-p)*(y-b)-(v-y)*(p-f))/S;if(S===0&&x!==0||w<=0||w>=1||T<0||T>1)return null;if(x===0&&S===0){for(let A=0;A<2;A++){if(i(A===0?d:c,u,h),t.loc===0){let M=A===0?d:c;return{x:M.x,y:M.y,t:t.t}}if(t.loc===2)return{x:+(p+t.t*(m-p)).toPrecision(10),y:+(y+t.t*(v-y)).toPrecision(10),t:t.t}}return null}for(let A=0;A<2;A++)if(i(A===0?d:c,u,h),t.loc===0){let M=A===0?d:c;return{x:M.x,y:M.y,t:t.t}}return{x:+(p+w*(m-p)).toPrecision(10),y:+(y+w*(v-y)).toPrecision(10),t:w}}function i(u,h,d){let c,p=d.x-h.x,m=d.y-h.y,f=u.x-h.x,g=u.y-h.y,y=p*g-f*m;return u.x===h.x&&u.y===h.y?(t.loc=0,void(t.t=0)):u.x===d.x&&u.y===d.y?(t.loc=1,void(t.t=1)):void(y<-Number.EPSILON?t.loc=3:y>Number.EPSILON?t.loc=4:p*f<0||m*g<0?t.loc=5:Math.sqrt(p*p+m*m)<Math.sqrt(f*f+g*g)?t.loc=6:(c=p!==0?f/p:g/m,t.loc=2,t.t=c))}let r=0,s=999999999,n=-999999999,a=[];this.subPaths.forEach(u=>{let h=u.getPoints(),d=-999999999,c=999999999,p=-999999999,m=999999999;for(let f=0;f<h.length;f++){let g=h[f];g.y>d&&(d=g.y),g.y<c&&(c=g.y),g.x>p&&(p=g.x),g.x<m&&(m=g.x)}n<=p&&(n=p+1),s>=m&&(s=m-1),h.length&&a.push({curves:u.curves,points:h,isCW:x8.isClockWise(h),identifier:r++,boundingBox:new W7(new Z(m,c),new Z(p,d))})});let o=a.map(u=>function(h,d,c,p,m){(m==null||m==="")&&(m="nonzero");let f=new Z;h.boundingBox.getCenter(f);let g=function(S,w,T){let A=new Z;w.getCenter(A);let M=[];return T.forEach(C=>{C.boundingBox.containsPoint(A)&&function(R,O){let N=[],B=[];for(let k=1;k<R.length;k++){let z=R[k-1],L=R[k];for(let V=1;V<O.length;V++){let q=e(z,L,O[V-1],O[V]);q!==null&&N.find(j=>j.t<=q.t+Number.EPSILON&&j.t>=q.t-Number.EPSILON)===void 0&&(N.push(q),B.push(new Z(q.x,q.y)))}}return B}(S,C.points).forEach(R=>{M.push({identifier:C.identifier,isCW:C.isCW,point:R})})}),M.sort((C,R)=>C.point.x-R.point.x),M}([new Z(c,f.y),new Z(p,f.y)],h.boundingBox,d);g.sort((S,w)=>S.point.x-w.point.x);let y=[],v=[];g.forEach(S=>{S.identifier===h.identifier?y.push(S):v.push(S)});let b=y[0].point.x,_=[],x=0;for(;x<v.length&&v[x].point.x<b;)_.length>0&&_[_.length-1]===v[x].identifier?_.pop():_.push(v[x].identifier),x++;if(_.push(h.identifier),m==="evenodd"){let S=_.length%2==0,w=_[_.length-2];return{identifier:h.identifier,isHole:S,for:w}}if(m==="nonzero"){let S=!0,w=null,T=null;for(let A=0;A<_.length;A++){let M=_[A];d[M]&&(S?(T=d[M].isCW,S=!1,w=M):T!==d[M].isCW&&(T=d[M].isCW,S=!0))}return{identifier:h.identifier,isHole:S,for:w}}console.warn('fill-rule: "'+m+'" is currently not implemented.')}(u,a,s,n,this.userData?.style.fillRule)),l=[];return a.forEach(u=>{let h=o[u.identifier];if(h&&!h.isHole){let d=new bS;d.curves=u.curves,o.filter(c=>c?.isHole&&c.for===u.identifier).forEach(c=>{if(c){let p=a[c.identifier],m=new z2;m.curves=p.curves,d.holes.push(m)}}),l.push(d)}}),l}},$bt=!1,xut=new Promise(t=>{Hbt=t}),wut=!1;function Sut(){if($bt=!0,!wut)return uF||(uF=async function(){let t=await import("./opentype.js");Hbt(t),wut=!0}(),uF)}var _Pt=new class{async load(t,e,i=()=>{}){let{load:r}=await xut;r(t,(s,n)=>{s||!n?i(s??"Something went wrong"):e(n)})}async parse(t){let{parse:e,Bidi:i}=await xut;try{let r=e(t),s=new i,n=a=>r.charToGlyphIndex(a.char);return s.registerModifier("glyphIndex",null,n),s.applyFeatures(r,r.defaultRenderOptions.features),{font:r,bidi:s}}catch(r){console.error(r)}}};function xPt(t,e){return e.state.glyphIndex===t||e.state.fina===t||e.state.medi===t||e.state.init===t}dt(),TG(),Ii(),Yv("TextGeometry",(t,e,i)=>new X5(t,e,i));var Tut={create:(t,e)=>new WU(t,e)};xU("TextGeometry",Tut),xU("InputGeometry",Tut),SG=class{constructor(t){this._arrayBuffer=new ArrayBuffer(1),this._isLoaded=!1,this._intercepted=!1,this._layoutErrorWarned=!1,this._isUserFont=t.isUserFont??!1,this._loadingPromise=this.load(t)}update(t){this._isLoaded=!1,this._isUserFont=t.isUserFont??!1,this._loadingPromise=this.load(t)}async load(t){try{this._layoutErrorWarned=!1;let e=await async function(i){let r,s,n=!1;if(i.url?(r=await async function(a){let o;try{o=await fetch(a)}catch(l){throw new Error(`could not fetch the font at ${a}: ${l}`)}if(!o.ok)throw new Error(`${o.status} ${o.statusText} fetching the font at ${a}`);return await o.arrayBuffer()}(i.url),s=i.url,n=i.url.startsWith("/")):i.data&&(r=i.data.buffer.slice(i.data.byteOffset,i.data.byteOffset+i.data.byteLength)),r){if(!$bt)return{font:void 0,url:s,intercepted:n,arr:r,bidi:null};{let a=await _Pt.parse(r);if(a)return{font:a.font,url:s,intercepted:n,arr:r,bidi:a.bidi}}}}(t);e&&(this._arrayBuffer=e.arr,this._url=e.url,this.font=e.font,this._intercepted=e.intercepted,this._isLoaded=!0,this._bidi=e.bidi)}catch(e){console.warn(`Could not load the font "${t.url??"(inline data)"}"`,e)}}warnLayoutError(t){this._layoutErrorWarned||(this._layoutErrorWarned=!0,console.warn(`Text layout failed for the font "${this._url??"(inline data)"}"`,t))}get url(){return this._url}get intercepted(){return this._intercepted}get isLoaded(){return this._isLoaded}get loadingPromise(){return this._loadingPromise}reverseLigaturesTable(t,e,i){if(!this._bidi)return[];let r=this._bidi;r.getTextGlyphs(e);let s=r.tokenizer.tokens,n=[],a=0,o=i.length===s.length;for(let l=0;l<i.length;l++){let u=i[l].index,h=String.fromCharCode(i[l].unicode),d=s[a];if(xPt(u,d)||o)n.push({char:h,index:u,replacements:[d.state.glyphIndex],replacementChars:[d.char]}),a++;else{let c=d.char,p="",m=[d.state.glyphIndex],f=[],g=!1;for(;!g;)a++,p=e.charAt(a),c+=p,m.push(t.charToGlyphIndex(p)),f=t.stringToGlyphs(c),f.length===1&&f[0].index===u&&(g=!0),a>e.length&&(g=!0);n.push({char:h,index:u,replacements:m,replacementChars:Array.from(c)}),a++}}return n}generateShapes(t,e,i){if(!this._isLoaded)return;let r=this.font,s=e.fontSize/this.unitsPerEm,n=e.fontSize*e.lineHeight,a=t.map(y=>this.getTextWidth(y,e)),o=typeof e.width=="string"?Number(i.getVariable(e.width)):e.width,l=typeof e.height=="string"?Number(i.getVariable(e.height)):e.height,u=this.getCharWidth(`
|
|
5089
5089
|
`,e),h=e.horizontalAlign===1?u:0,d=this.getLineInitialOffsetX(a[0],o,e.horizontalAlign,t[0],u),c=this.getLineInitialOffsetY(n,t.length,l,s,e.verticalAlign),p=[],m=t.map(()=>[]),f=t.map(()=>[]);for(let y=0;y<t.length;y++){let v=t[y],b={features:{liga:!0},letterSpacing:e.letterSpacing},_=[];try{_=r.stringToGlyphs(v,b)}catch(A){this.warnLayoutError(A)}d=this.getLineInitialOffsetX(a[y],o,e.horizontalAlign,v,u);let x=[];try{x=this.reverseLigaturesTable(r,v,_)}catch(A){this.warnLayoutError(A)}let S=this.computeSpaceWidthForLine(t,y,e,i),w=0,T=_[0];T&&e.horizontalAlign===2&&T.leftSideBearing!==void 0&&(d-=T.leftSideBearing*s);try{this.font?.forEachGlyph(v,d,c,e.fontSize,b,(A,M,C,R,O)=>{let N=A.index===0?`
|
|
5090
5090
|
`:A.unicode?String.fromCharCode(A.unicode):void 0,B=x[w],k=0;if(N===`
|
|
5091
5091
|
`)k=h;else if(N===" ")k=S;else{let z=this.createPath(A,s,M,C,e);z&&(k=z.offsetX,p.push(z.path))}if(B&&B.replacements.length!==1){let z=B.replacements.map(j=>(r.glyphs.get(j).advanceWidth??0)*s),L=z.reduce((j,Q)=>j+Q,0),V=z.map(j=>j/L),q=M;for(let j=0;j<V.length;j++){let Q=k*V[j];f[y].push([q,C]),m[y].push(Q),q+=Q}}else f[y].push([M,C]),m[y].push(k);w++})}catch(A){this.warnLayoutError(A)}c-=n}let g=[];for(let y=0,v=p.length;y<v;y++)g.push(...p[y].toShapes());return{shapes:g,charWidths:m,lineWidths:a,charCoords:f}}get isUserFont(){return this._isUserFont}get arrayBuffer(){return this._arrayBuffer}get ascender(){return this.font?.ascender??0}get descender(){return this.font?.descender??0}get familyName(){return this.font?.names.fontFamily??""}get subfamilyName(){return this.font?.names.fontSubfamily??""}get unitsPerEm(){return this.font?.unitsPerEm??1}getLineInitialOffsetX(t,e,i,r,s){return(i===3||i===2)&&r.indexOf(`
|
|
5092
|
-
`)>=0&&(t-=s),i===3?.5*e-.5*t:i===2?e-t:0}getLineInitialOffsetY(t,e,i,r,s){let n=e*t,a=t-Math.abs(this.ascender-this.descender)*r,o=-this.ascender*r-a/2;return s===3?-(i-n-o):s===2?-(.5*i-.5*n-o):o}createPath(t,e,i,r,s){let n=t.getPath(i,-r,s.fontSize,{kerning:!1,letterSpacing:s.letterSpacing});if(!n)return void console.error('THREE.Font: character "'+t+'" does not exists in font family '+this.familyName+".");let a=new bPt,o=(t.advanceWidth??1)*e;if(t)for(let l of n.commands){let u=a.currentPath?.currentPoint;if(!u||l.type==="Z"||u.x!==l.x||-u.y!==l.y)switch(l.type){case"M":a.moveTo(l.x,-l.y);break;case"L":a.lineTo(l.x,-l.y);break;case"Q":a.quadraticCurveTo(l.x1,-l.y1,l.x,-l.y);break;case"C":a.bezierCurveTo(l.x1,-l.y1,l.x2,-l.y2,l.x,-l.y)}}return a.subPaths.forEach(l=>{let u=function(h){if(h.length){let d=h[0];if(d instanceof cl)return d.v1;if(d instanceof Kl||d instanceof oc)return d.v0}}(l.curves);u!==void 0&&l.currentPoint.distanceTo(u)>0&&l.lineTo(u.x,u.y)}),{offsetX:o,path:a}}getCharWidth(t,e){try{return this.font?.getAdvanceWidth(t,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}catch(i){return this.warnLayoutError(i),0}}getTextWidth(t,e){try{return this.font?.getAdvanceWidth(t,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}catch(i){return this.warnLayoutError(i),0}}computeSpaceWidthForLine(t,e,i,r){let s=this.getCharWidth(" ",i),n=t[e];if(n){let a=this.countSpaces(n.trimEnd());if(i.horizontalAlign===4&&e<t.length-1&&a)return((typeof i.width=="string"?Number(r.getVariable(i.width)):i.width)-(this.getTextWidth(n,i)-a*s))/a}return s}countSpaces(t){return(t.match(/ /g)||[]).length}},Or("text"),ke();var Xbt=null;function Mut(){return Xbt}function wPt(t){let e=!1;return t.scene.objects.forEach(i=>{i.data.type==="Page"&&!e&&i.data.publish.gameControlObject&&Qg.traverseModuleInstances(t,i.id,(r,s,n)=>{for(let a of n)a.data.type==="GameControl"&&a.data.navmesh.enabled&&(e=!0)})}),e}ir();var RE=(t,e)=>{let i=e.x-t.x,r=e.y-t.y;return Math.sqrt(i*i+r*r)},dF=t=>t*(Math.PI/180),DE=new Map,p5=(t,e,i)=>{let r,s=e.split(/[ ,]+/g);for(let n=0;n<s.length;n+=1)r=s[n],t.addEventListener?t.addEventListener(r,i,!1):t.attachEvent&&t.attachEvent(r,i)},m5=(t,e,i)=>{let r,s=e.split(/[ ,]+/g);for(let n=0;n<s.length;n+=1)r=s[n],t.removeEventListener?t.removeEventListener(r,i):t.detachEvent&&t.detachEvent(r,i)},Ybt=t=>(t.preventDefault(),t.type.match(/^touch/)?t.changedTouches:t),Aut=()=>{if(!(typeof window>"u"))return{x:window.pageXOffset!==void 0?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft,y:window.pageYOffset!==void 0?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop}},cF=(t,e)=>{e.top||e.right||e.bottom||e.left?(t.style.top=e.top,t.style.right=e.right,t.style.bottom=e.bottom,t.style.left=e.left):(t.style.left=e.x+"px",t.style.top=e.y+"px")},pF=(t,e,i)=>{let r=Kbt(t);for(let s in r)if(Object.prototype.hasOwnProperty.call(r,s))if(typeof e=="string")r[s]=e+" "+i;else{let n="";for(let a=0,o=e.length;a<o;a+=1)n+=e[a]+" "+i+", ";r[s]=n.slice(0,-2)}return r},Kbt=t=>{let e={};return e[t]="",["webkit","Moz","o"].forEach(function(i){e[i+t.charAt(0).toUpperCase()+t.slice(1)]=""}),e},mF=(t,e)=>{for(let i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},l7=(t,e)=>{if(t.length)for(let i=0,r=t.length;i<r;i+=1)e(t[i]);else e(t)};typeof window<"u"&&(Zbt="ontouchstart"in window,Qbt=!!window.PointerEvent,Jbt=!!window.MSPointerEvent);var Zbt,Qbt,Jbt,Xy,Cut={start:"mousedown",move:"mousemove",end:"mouseup"},mw={};function hg(){}Qbt?Xy={start:"pointerdown",move:"pointermove",end:"pointerup, pointercancel"}:Jbt?Xy={start:"MSPointerDown",move:"MSPointerMove",end:"MSPointerUp"}:Zbt?(Xy={start:"touchstart",move:"touchmove",end:"touchend, touchcancel"},mw=Cut):Xy=Cut,hg.prototype.on=function(t,e){var i,r=this,s=t.split(/[ ,]+/g);r._handlers_=r._handlers_||{};for(var n=0;n<s.length;n+=1)i=s[n],r._handlers_[i]=r._handlers_[i]||[],r._handlers_[i].push(e);return r},hg.prototype.off=function(t,e){var i=this;return i._handlers_=i._handlers_||{},t===void 0?i._handlers_={}:e===void 0?i._handlers_[t]=null:i._handlers_[t]&&i._handlers_[t].indexOf(e)>=0&&i._handlers_[t].splice(i._handlers_[t].indexOf(e),1),i},hg.prototype.trigger=function(t,e){var i,r=this,s=t.split(/[ ,]+/g);r._handlers_=r._handlers_||{};for(var n=0;n<s.length;n+=1)i=s[n],r._handlers_[i]&&r._handlers_[i].length&&r._handlers_[i].forEach(function(a){a.call(r,{type:i,target:r},e)})},hg.prototype.config=function(t){var e=this;e.options=e.defaults||{},t&&(e.options=((i,r)=>{let s={};for(let n in i)Object.prototype.hasOwnProperty.call(i,n)&&Object.prototype.hasOwnProperty.call(r,n)?s[n]=r[n]:Object.prototype.hasOwnProperty.call(i,n)&&(s[n]=i[n]);return s})(e.options,t))},hg.prototype.bindEvt=function(t,e){var i=this;return i._domHandlers_=i._domHandlers_||{},i._domHandlers_[e]=function(){typeof i["on"+e]=="function"?i["on"+e].apply(i,arguments):console.warn('[WARNING] : Missing "on'+e+'" handler.')},p5(t,Xy[e],i._domHandlers_[e]),mw[e]&&p5(t,mw[e],i._domHandlers_[e]),i},hg.prototype.unbindEvt=function(t,e){var i=this;return i._domHandlers_=i._domHandlers_||{},m5(t,Xy[e],i._domHandlers_[e]),mw[e]&&m5(t,mw[e],i._domHandlers_[e]),delete i._domHandlers_[e],this};var UW=hg;function Sn(t,e){return this.identifier=e.identifier,this.position=e.position,this.frontPosition=e.frontPosition,this.collection=t,this.defaults={size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:1,mode:"dynamic",zone:document.body,lockX:!1,lockY:!1,shape:"circle"},this.config(e),this.options.mode==="dynamic"&&(this.options.restOpacity=0),this.id=Sn.id,Sn.id+=1,this.buildEl().stylize(),this.instance={el:this.ui.el,on:this.on.bind(this),off:this.off.bind(this),show:this.show.bind(this),hide:this.hide.bind(this),add:this.addToDom.bind(this),remove:this.removeFromDom.bind(this),destroy:this.destroy.bind(this),setPosition:this.setPosition.bind(this),resetDirection:this.resetDirection.bind(this),computeDirection:this.computeDirection.bind(this),trigger:this.trigger.bind(this),position:this.position,frontPosition:this.frontPosition,ui:this.ui,identifier:this.identifier,id:this.id,options:this.options},this.instance}Sn.prototype=new UW,Sn.constructor=Sn,Sn.id=0,Sn.prototype.buildEl=function(t){return this.ui={},this.options.dataOnly||(this.ui.el=document.createElement("div"),this.ui.back=document.createElement("div"),this.ui.front=document.createElement("div"),this.ui.el.className="nipple collection_"+this.collection.id,this.ui.back.className="back",this.ui.front.className="front",this.ui.el.setAttribute("id","nipple_"+this.collection.id+"_"+this.id),this.ui.el.appendChild(this.ui.back),this.ui.el.appendChild(this.ui.front)),this},Sn.prototype.stylize=function(){if(this.options.dataOnly)return this;var t=this.options.fadeTime+"ms",e=(()=>{let s=Kbt("borderRadius");for(let n in s)Object.prototype.hasOwnProperty.call(s,n)&&(s[n]="50%");return s})(),i=pF("transition","opacity",t),r={};return r.el={position:"absolute",opacity:this.options.restOpacity,display:"block",zIndex:999},r.back={position:"absolute",display:"block",width:this.options.size+"px",height:this.options.size+"px",marginLeft:-this.options.size/2+"px",marginTop:-this.options.size/2+"px",background:"rgba(255, 255, 255, .4)",border:"solid 2px rgba(0, 0, 0, .1)"},r.front={width:this.options.size/2+"px",height:this.options.size/2+"px",position:"absolute",display:"block",marginLeft:-this.options.size/4+"px",marginTop:-this.options.size/4+"px",background:"rgba(255, 255, 255, .8)",border:"solid 2px rgba(0, 0, 0, .1)"},mF(r.el,i),this.options.shape==="circle"&&mF(r.back,e),mF(r.front,e),this.applyStyles(r),this},Sn.prototype.applyStyles=function(t){for(var e in this.ui)if(Object.prototype.hasOwnProperty.call(this.ui,e))for(var i in t[e])this.ui[e].style[i]=t[e][i];return this},Sn.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)||this.options.zone.appendChild(this.ui.el),this},Sn.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)||this.options.zone.removeChild(this.ui.el),this},Sn.prototype.destroy=function(){clearTimeout(this.removeTimeout),clearTimeout(this.showTimeout),clearTimeout(this.restTimeout),this.trigger("destroyed",this.instance),this.removeFromDom(),this.off(),this.ui=null,this.instance=null,this.collection=null,this.options=null},Sn.prototype.show=function(t){var e=this;return e.options.dataOnly||(clearTimeout(e.removeTimeout),clearTimeout(e.showTimeout),clearTimeout(e.restTimeout),e.addToDom(),e.restCallback(),setTimeout(function(){e.ui.el.style.opacity=1},0),e.showTimeout=setTimeout(function(){e.trigger("shown",e.instance),typeof t=="function"&&t.call(this)},e.options.fadeTime)),e},Sn.prototype.hide=function(t){var e=this;if(e.options.dataOnly)return e;if(e.ui.el.style.opacity=e.options.restOpacity,clearTimeout(e.removeTimeout),clearTimeout(e.showTimeout),clearTimeout(e.restTimeout),e.removeTimeout=setTimeout(function(){var i=e.options.mode==="dynamic"?"none":"block";e.ui.el.style.display=i,typeof t=="function"&&t.call(e),e.trigger("hidden",e.instance)},e.options.fadeTime),e.options.restJoystick){let i=e.options.restJoystick,r={};r.x=i===!0||i.x!==!1?0:e.instance.frontPosition.x,r.y=i===!0||i.y!==!1?0:e.instance.frontPosition.y,e.setPosition(t,r)}return e},Sn.prototype.setPosition=function(t,e){var i=this;i.frontPosition={x:e.x,y:e.y};var r=i.options.fadeTime+"ms",s={};s.front=pF("transition",["top","left"],r);var n={front:{}};n.front={left:i.frontPosition.x+"px",top:i.frontPosition.y+"px"},i.applyStyles(s),i.applyStyles(n),i.restTimeout=setTimeout(function(){typeof t=="function"&&t.call(i),i.restCallback()},i.options.fadeTime)},Sn.prototype.restCallback=function(){var t=this,e={};e.front=pF("transition","none",""),t.applyStyles(e),t.trigger("rested",t.instance)},Sn.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}},Sn.prototype.computeDirection=function(t){var e,i,r,s=t.angle.radian,n=Math.PI/4,a=Math.PI/2;if(s>n&&s<3*n&&!t.lockX?e="up":s>-n&&s<=n&&!t.lockY?e="left":s>3*-n&&s<=-n&&!t.lockX?e="down":t.lockY||(e="right"),t.lockY||(i=s>-a&&s<a?"left":"right"),t.lockX||(r=s>0?"up":"down"),t.force>this.options.threshold){var o,l={};for(o in this.direction)Object.prototype.hasOwnProperty.call(this.direction,o)&&(l[o]=this.direction[o]);var u={};for(o in this.direction={x:i,y:r,angle:e},t.direction=this.direction,l)l[o]===this.direction[o]&&(u[o]=!0);if(u.x&&u.y&&u.angle)return t;(!u.x||!u.y)&&this.trigger("plain",t),u.x||this.trigger("plain:"+i,t),u.y||this.trigger("plain:"+r,t),u.angle||this.trigger("dir dir:"+e,t)}else this.resetDirection();return t};var SPt=Sn;function js(t,e){var i=this;i.nipples=[],i.idles=[],i.actives=[],i.ids=[],i.pressureIntervals={},i.manager=t,i.id=js.id,js.id+=1,i.defaults={zone:document.body,multitouch:!1,maxNumberOfNipples:10,mode:"dynamic",position:{top:0,left:0},catchDistance:200,size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:1,lockX:!1,lockY:!1,shape:"circle",dynamicPage:!1,follow:!1},i.config(e),(i.options.mode==="static"||i.options.mode==="semi")&&(i.options.multitouch=!1),i.options.multitouch||(i.options.maxNumberOfNipples=1);let r=getComputedStyle(i.options.zone.parentElement);return r&&r.display==="flex"&&(i.parentIsFlex=!0),i.updateBox(),i.prepareNipples(),i.bindings(),i.begin(),i.nipples}js.prototype=new UW,js.constructor=js,js.id=0,js.prototype.prepareNipples=function(){var t=this,e=t.nipples;e.on=t.on.bind(t),e.off=t.off.bind(t),e.options=t.options,e.destroy=t.destroy.bind(t),e.ids=t.ids,e.id=t.id,e.processOnMove=t.processOnMove.bind(t),e.processOnEnd=t.processOnEnd.bind(t),e.get=function(i){if(i===void 0)return e[0];for(var r=0,s=e.length;r<s;r+=1)if(e[r].identifier===i)return e[r];return!1}},js.prototype.bindings=function(){var t=this;t.bindEvt(t.options.zone,"start"),t.options.zone.style.touchAction="none",t.options.zone.style.msTouchAction="none"},js.prototype.begin=function(){var t=this,e=t.options;if(e.mode==="static"){var i=t.createNipple(e.position,t.manager.getIdentifier());i.add(),t.idles.push(i)}},js.prototype.createNipple=function(t,e){var i=this,r=i.manager.scroll,s={},n=i.options,a=i.parentIsFlex?r.x:r.x+i.box.left,o=i.parentIsFlex?r.y:r.y+i.box.top;if(t.x&&t.y)s={x:t.x-a,y:t.y-o};else if(t.top||t.right||t.bottom||t.left){var l=document.createElement("DIV");l.style.display="hidden",l.style.top=t.top,l.style.right=t.right,l.style.bottom=t.bottom,l.style.left=t.left,l.style.position="absolute",n.zone.appendChild(l);var u=l.getBoundingClientRect();n.zone.removeChild(l),s=t,t={x:u.left+r.x,y:u.top+r.y}}var h=new SPt(i,{color:n.color,size:n.size,threshold:n.threshold,fadeTime:n.fadeTime,dataOnly:n.dataOnly,restJoystick:n.restJoystick,restOpacity:n.restOpacity,mode:n.mode,identifier:e,position:t,zone:n.zone,frontPosition:{x:0,y:0},shape:n.shape});return n.dataOnly||(cF(h.ui.el,s),cF(h.ui.front,h.frontPosition)),i.nipples.push(h),i.trigger("added "+h.identifier+":added",h),i.manager.trigger("added "+h.identifier+":added",h),i.bindNipple(h),h},js.prototype.updateBox=function(){this.box=this.options.zone.getBoundingClientRect()},js.prototype.bindNipple=function(t){var e,i=this,r=function(s,n){e=s.type+" "+n.id+":"+s.type,i.trigger(e,n)};t.on("destroyed",i.onDestroyed.bind(i)),t.on("shown hidden rested dir plain",r),t.on("dir:up dir:right dir:down dir:left",r),t.on("plain:up plain:right plain:down plain:left",r)},js.prototype.pressureFn=function(t,e,i){var r=this,s=0;clearInterval(r.pressureIntervals[i]),r.pressureIntervals[i]=setInterval(function(){var n=t.force||t.pressure||t.webkitForce||0;n!==s&&(e.trigger("pressure",n),r.trigger("pressure "+e.identifier+":pressure",n),s=n)}.bind(r),100)},js.prototype.onstart=function(t){var e=this,i=e.options,r=t;return t=Ybt(t),e.updateBox(),l7(t,function(s){e.actives.length<i.maxNumberOfNipples?e.processOnStart(s):r.type.match(/^touch/)&&(Object.keys(e.manager.ids).forEach(function(n){if(Object.values(r.touches).findIndex(function(o){return o.identifier===n})<0){var a=[t[0]];a.identifier=n,e.processOnEnd(a)}}),e.actives.length<i.maxNumberOfNipples&&e.processOnStart(s))}),e.manager.bindDocument(),!1},js.prototype.processOnStart=function(t){var e,i=this,r=i.options,s=i.manager.getIdentifier(t),n=t.force||t.pressure||t.webkitForce||0,a={x:t.pageX,y:t.pageY},o=i.getOrCreate(s,a);o.identifier!==s&&i.manager.removeIdentifier(o.identifier),o.identifier=s;var l=function(u){u.trigger("start",u),i.trigger("start "+u.id+":start",u),u.show(),n>0&&i.pressureFn(t,u,u.identifier),i.processOnMove(t)};if((e=i.idles.indexOf(o))>=0&&i.idles.splice(e,1),i.actives.push(o),i.ids.push(o.identifier),r.mode!=="semi")l(o);else{if(!(RE(a,o.position)<=r.catchDistance))return o.destroy(),void i.processOnStart(t);l(o)}return o},js.prototype.getOrCreate=function(t,e){var i,r=this,s=r.options;return/(semi|static)/.test(s.mode)?(i=r.idles[0])?(r.idles.splice(0,1),i):s.mode==="semi"?r.createNipple(e,t):(console.warn("Coudln't find the needed nipple."),!1):i=r.createNipple(e,t)},js.prototype.processOnMove=function(t){var e=this,i=e.options,r=e.manager.getIdentifier(t),s=e.nipples.get(r),n=e.manager.scroll;if((b=>isNaN(b.buttons)?b.pressure!==0:b.buttons!==0)(t)){if(!s)return console.error("Found zombie joystick with ID "+r),void e.manager.removeIdentifier(r);if(i.dynamicPage){var a=s.el.getBoundingClientRect();s.position={x:n.x+a.left,y:n.y+a.top}}s.identifier=r;var o=s.options.size/2,l={x:t.pageX,y:t.pageY};i.lockX&&(l.y=s.position.y),i.lockY&&(l.x=s.position.x);var u,h,d=RE(l,s.position),c=((b,_)=>{let x=_.x-b.x,S=_.y-b.y;return(w=>w*(180/Math.PI))(Math.atan2(S,x))})(l,s.position),p=dF(c),m=d/o,f={distance:d,position:l};if(s.options.shape==="circle"?(u=Math.min(d,o),h=((b,_,x)=>{let S={x:0,y:0};return x=dF(x),S.x=b.x-_*Math.cos(x),S.y=b.y-_*Math.sin(x),S})(s.position,u,c)):(h=((b,_,x)=>({x:Math.min(Math.max(b.x,_.x-x),_.x+x),y:Math.min(Math.max(b.y,_.y-x),_.y+x)}))(l,s.position,o),u=RE(h,s.position)),i.follow){if(d>o){let b=l.x-h.x,_=l.y-h.y;s.position.x+=b,s.position.y+=_,s.el.style.top=s.position.y-(e.box.top+n.y)+"px",s.el.style.left=s.position.x-(e.box.left+n.x)+"px",d=RE(l,s.position)}}else l=h,d=u;var g=l.x-s.position.x,y=l.y-s.position.y;s.frontPosition={x:g,y},i.dataOnly||cF(s.ui.front,s.frontPosition);var v={identifier:s.identifier,position:l,force:m,pressure:t.force||t.pressure||t.webkitForce||0,distance:d,angle:{radian:p,degree:c},vector:{x:g/o,y:-y/o},raw:f,instance:s,lockX:i.lockX,lockY:i.lockY};(v=s.computeDirection(v)).angle={radian:dF(180-c),degree:180-c},s.trigger("move",v),e.trigger("move "+s.id+":move",v)}else this.processOnEnd(t)},js.prototype.processOnEnd=function(t){var e=this,i=e.options,r=e.manager.getIdentifier(t),s=e.nipples.get(r),n=e.manager.removeIdentifier(s.identifier);!s||(i.dataOnly||s.hide(function(){i.mode==="dynamic"&&(s.trigger("removed",s),e.trigger("removed "+s.id+":removed",s),e.manager.trigger("removed "+s.id+":removed",s),s.destroy())}),clearInterval(e.pressureIntervals[s.identifier]),s.resetDirection(),s.trigger("end",s),e.trigger("end "+s.id+":end",s),e.ids.indexOf(s.identifier)>=0&&e.ids.splice(e.ids.indexOf(s.identifier),1),e.actives.indexOf(s)>=0&&e.actives.splice(e.actives.indexOf(s),1),/(semi|static)/.test(i.mode)?e.idles.push(s):e.nipples.indexOf(s)>=0&&e.nipples.splice(e.nipples.indexOf(s),1),e.manager.unbindDocument(),/(semi|static)/.test(i.mode)&&(e.manager.ids[n.id]=n.identifier))},js.prototype.onDestroyed=function(t,e){var i=this;i.nipples.indexOf(e)>=0&&i.nipples.splice(i.nipples.indexOf(e),1),i.actives.indexOf(e)>=0&&i.actives.splice(i.actives.indexOf(e),1),i.idles.indexOf(e)>=0&&i.idles.splice(i.idles.indexOf(e),1),i.ids.indexOf(e.identifier)>=0&&i.ids.splice(i.ids.indexOf(e.identifier),1),i.manager.removeIdentifier(e.identifier),i.manager.unbindDocument()},js.prototype.destroy=function(){var t=this;for(var e in t.unbindEvt(t.options.zone,"start"),t.nipples.forEach(function(i){i.destroy()}),t.pressureIntervals)Object.prototype.hasOwnProperty.call(t.pressureIntervals,e)&&clearInterval(t.pressureIntervals[e]);t.trigger("destroyed",t.nipples),t.manager.unbindDocument(),t.off(),t.pressureIntervals={},t.nipples=[],t.idles=[],t.actives=[],t.ids=[],t.manager=null};var TPt=js;function rn(t){var e=this;e.ids={},e.index=0,e.collections=[],e.scroll=Aut(),e._windowBound=!1,e.config(t),e.prepareCollections();var i=function(){var r;e.collections.forEach(function(s){s.forEach(function(n){r=n.el.getBoundingClientRect(),n.position={x:e.scroll.x+r.left,y:e.scroll.y+r.top}})})};return e._onResize=function(){(r=>{DE.has(r)&&clearTimeout(DE.get(r)),DE.set(r,setTimeout(function(){DE.delete(r),r()},100))})(i)},e._onScroll=function(){e.scroll=Aut()},e.collections}rn.prototype=new UW,rn.constructor=rn,rn.prototype.prepareCollections=function(){var t=this;t.collections.create=t.create.bind(t),t.collections.on=t.on.bind(t),t.collections.off=t.off.bind(t),t.collections.destroy=t.destroy.bind(t),t.collections.get=function(e){var i;return t.collections.every(function(r){return!(i=r.get(e))}),i}},rn.prototype.create=function(t){return this.createCollection(t)},rn.prototype.bindWindowEvents=function(){var t=this;t._windowBound||typeof window>"u"||(t._windowBound=!0,p5(window,"resize",t._onResize),p5(window,"scroll",t._onScroll))},rn.prototype.unbindWindowEvents=function(){var t=this;!t._windowBound||typeof window>"u"||(t._windowBound=!1,m5(window,"resize",t._onResize),m5(window,"scroll",t._onScroll))},rn.prototype.createCollection=function(t){var e=this,i=new TPt(e,t);return e.bindCollection(i),e.collections.push(i),e.bindWindowEvents(),i},rn.prototype.bindCollection=function(t){var e,i=this,r=function(s,n){e=s.type+" "+n.id+":"+s.type,i.trigger(e,n)};t.on("destroyed",i.onDestroyed.bind(i)),t.on("shown hidden rested dir plain",r),t.on("dir:up dir:right dir:down dir:left",r),t.on("plain:up plain:right plain:down plain:left",r)},rn.prototype.bindDocument=function(){var t=this;t.binded||(t.bindEvt(document,"move").bindEvt(document,"end"),t.binded=!0)},rn.prototype.unbindDocument=function(t){var e=this;(!Object.keys(e.ids).length||t===!0)&&(e.unbindEvt(document,"move").unbindEvt(document,"end"),e.binded=!1)},rn.prototype.getIdentifier=function(t){var e;return t?(e=t.identifier===void 0?t.pointerId:t.identifier)===void 0&&(e=this.latest||0):e=this.index,this.ids[e]===void 0&&(this.ids[e]=this.index,this.index+=1),this.latest=e,this.ids[e]},rn.prototype.removeIdentifier=function(t){var e={};for(var i in this.ids)if(this.ids[i]===t){e.id=i,e.identifier=this.ids[i],delete this.ids[i];break}return e},rn.prototype.onmove=function(t){return this.onAny("move",t),!1},rn.prototype.onend=function(t){return this.onAny("end",t),!1},rn.prototype.oncancel=function(t){return this.onAny("end",t),!1},rn.prototype.onAny=function(t,e){var i,r=this,s="processOn"+t.charAt(0).toUpperCase()+t.slice(1);e=Ybt(e);var n=function(a,o,l){l.ids.indexOf(o)>=0&&(l[s](a),a._found_=!0)};return l7(e,function(a){i=r.getIdentifier(a),l7(r.collections,n.bind(null,a,i)),a._found_||r.removeIdentifier(i)}),!1},rn.prototype.destroy=function(){var t=this;t.unbindDocument(!0),t.unbindWindowEvents(),t.ids={},t.index=0,t.collections.forEach(function(e){e.destroy()}),t.collections=[],t.off()},rn.prototype.onDestroyed=function(t,e){var i=this;if(i.collections.indexOf(e)<0)return!1;i.collections.splice(i.collections.indexOf(e),1),i.collections.length===0&&i.unbindWindowEvents()};var MPt=rn,Cv=null;function Eut(){return Cv||(Cv=new MPt),Cv}var APt={create:function(t){return Eut().create(t)},destroy:function(){Cv&&(Cv.destroy(),Cv=null)},get factory(){return Eut()}},CPt=APt;ir(),ke(),dt(),Qh(),vo(),ke();var t_t=null;function fF(){return t_t}var e_t,gF,EPt=new Promise(t=>{e_t=t});function PPt(t){return gF||(gF=async function(){let e=t??"https://cdn.spline.design/@splinetool/runtime@2.0.60/build",i=import("./physics.js"),[r,s]=await Promise.all([i,fetch(`${e}/physics.wasm`).then(n=>n.arrayBuffer())]);await r.init(s),e_t(r)}(),gF)}function i_t(t){let e=t.elements,i=e[0]**2+e[1]**2+e[2]**2,r=e[4]**2+e[5]**2+e[6]**2,s=e[8]**2+e[9]**2+e[10]**2,n=e[0]**2+e[4]**2+e[8]**2,a=e[1]**2+e[5]**2+e[9]**2,o=e[2]**2+e[6]**2+e[10]**2,l=1e-8;return i<l||r<l||s<l||n<l||a<l||o<l}function ac(t,e){let i=new ye;if(e&&i_t(e))return i.setAttribute("position",new fe([],3)),i.setIndex([]),i;if(!t.getAttribute("position"))return i.setAttribute("position",new fe([],3)),i.setIndex([]),i;let{positions:r,triIndices:s}=OG(t.getAttribute("position"),t.getIndex());return i.setAttribute("position",new fe(r,3)),i.setIndex(s),e&&i.applyMatrix4(e),i}ns(),vo(),Ii(),XG(),dt(),dt(),Zv(),KS();var ki,RPt=class{constructor(t,e,i,r,s,n){this.id=t,this.data=e,this.object=i,this.initialDisabled=!1,this.actions=un(e,e.actions,r,s,n,i),this.target=e.target}disconnect(){na(this.actions)}dispatch(t){this.initialDisabled||(this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.object.dispatchEvent({type:"beginEvent",eventName:"Collision"}),this.actions.Transition.forEach(e=>e.play()),this.actions.Animation.forEach(e=>{"runMode"in e.data&&e.data.runMode==="Toggle"?e.toggle():e.play()}),this.actions.TimelineAnimation.forEach(e=>{"runMode"in e.data&&e.data.runMode==="Toggle"?e.toggle():e.play()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch(t??!1)}),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Particles.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()}),this.actions.ClearLocalStorage.forEach(e=>e.dispatch()),this.actions.UserAPI.forEach(e=>e.dispatch()))}},Put=class{constructor(t,e,i,r,s,n){this.id=t,this.data=e,this.object=i,this.page=r,this.currentIntersectedObjects=[],this.actions=un(e,e.actions,r,s,n,i),this.target=e.target,this.triggeringObjects=[];for(let a of e.triggeringObjects){let o=r.scene.find(a);o&&this.triggeringObjects.push(o)}}isValidTriggeringObject(t){return this.target==="all"||this.triggeringObjects.some(e=>e===t||e.isAncestorOf(t.uuid)||t.isAncestorOf(e.uuid))}disconnect(){na(this.actions)}dispatch(){this.object.destroyedInAction||(this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.object.dispatchEvent({type:"beginEvent",eventName:"Trigger"}),this.actions.Transition.forEach(t=>t.play()),this.actions.SwitchCamera.forEach(t=>{t.data.runMode==="Toggle"?t.toggle():t.play()}),this.actions.TimelineAnimation.forEach(t=>{"runMode"in t.data&&t.data.runMode==="Toggle"?t.toggle():t.play()}),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch(!1)}),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Particles.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()}),this.actions.SceneTransition.forEach(t=>{t.dispatch()}),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch()))}};ns(),EPt.then(t=>ki=t);var en=new P,Wl=new Me,Tp=new P,Rut=(new Qi(0,0,0,"YXZ"),new Qi(0,0,0,"XYZ")),Ph=new P,yF=new P,vF=new P(1,1,1),Yy=new Me,NE=new bt,Dut=new bt,DPt={type:"updateMatrix"},Nut=new Me,bF=new ta,_F=.01,h7={type:"beginEvent",eventName:"Collision"},NPt={type:"beginEvent",eventName:"Trigger"},f5=t=>t.states.some(e=>e.data.position!==void 0||e.data.rotation!==void 0||e.data.hiddenMatrix!==void 0||e.data.cloner!==void 0||e.data.pathSnapping!==void 0);function Ky(t){return function(e){return typeof e=="object"&&e!==null&&"booleanOp"in e}(Sg(t)?t.object:t)}var OPt=class{constructor(t){this.eventContext=t,this.isEnabled=!1,this.gameControl=null,this.joysticks=[],this.joystickToGameControls=[],this.sharedGameControlGlobals={entitiesWithTransformAnim:[],entityToCollisionEvents:{},colliderToEntity:new Map,kinematicBodyToEntity:new Map,triggers:[],gamePads:[],createdObjects:[],nCreatedPerAction:{}},this.sensorToTriggerEvent={},this.eventManager=void 0,this.needsCollisionDetection=!1,this.initializationCounter=-1,this.fixedBodiesToWatch=[],this.rigidBodyToMesh=new Map,this.nActiveRigidBodies=0,this.collisionEvents=[],this.isExport=!1,this.skipRender=!0,this._staticBVHAttrIds=new WeakMap,this._staticBVHNextAttrId=1,this.processRigidBody=e=>{if(e.bodyType()!==ki.RigidBodyType.Dynamic)return;e.isSleeping()||this.nActiveRigidBodies++;let[i,r,s]=this.rigidBodyToMesh.get(e.handle);if(en.copy(e.translation()).multiplyScalar(this.pixelsPerMeter),Wl.copy(e.rotation()),i.matrixWorld.compose(en,Wl,r),i.hasNonUniformScale&&i.matrixWorld.multiply(i.shearScale),i.dispatchEvent(DPt),s){let n=i.cloner;if(n&&n.objectForSample===void 0){n.matrixWorld.copy(i.matrixWorld);for(let a of n.children)a.updateMatrixWorld(!0)}for(let a of i.children)a.updateMatrixWorld(!0)}},this.accumulator=0,this.handleCollisionEvents=(e,i,r)=>{if(r===!1)return;let s,n;if(this.sensorToTriggerEvent[e]?(s=this.sensorToTriggerEvent[e],n=this.sharedGameControlGlobals.colliderToEntity.get(i)):this.sensorToTriggerEvent[i]&&(s=this.sensorToTriggerEvent[i],n=this.sharedGameControlGlobals.colliderToEntity.get(e)),s&&n&&s.isValidTriggeringObject(n))s.dispatch();else{for(let a=this.sharedGameControlGlobals.createdObjects.length-1;a>=0;a--){let o=this.sharedGameControlGlobals.createdObjects[a];if(o.userData.hasCollisionDestroy&&(o.rigidBody?.collider(0).handle===e||o.rigidBody?.collider(0).handle===i)){this.sharedGameControlGlobals.createdObjects.splice(a,1),o.removeFromParent();let l=o.rigidBody;requestAnimationFrame(()=>{o.rigidBody===l&&(this.sharedGameControlGlobals.rapierWorld?.removeRigidBody(l),o.rigidBody=void 0)});break}}if(this.gameControl?.object!==void 0&&this.gameControl.object===this.sharedGameControlGlobals.colliderToEntity.get(e)){let a=this.sharedGameControlGlobals.colliderToEntity.get(i),o=this.sharedGameControlGlobals.entityToCollisionEvents[a.uuid];if(o===void 0)return;for(let l of o)l.data.target==="character"&&this.dispatchCollisionEvent(l,a,i)}else if(this.gameControl?.object!==void 0&&this.gameControl.object===this.sharedGameControlGlobals.colliderToEntity.get(i)){let a=this.sharedGameControlGlobals.colliderToEntity.get(e),o=this.sharedGameControlGlobals.entityToCollisionEvents[a.uuid];if(o===void 0)return;for(let l of o)l.data.target==="character"&&this.dispatchCollisionEvent(l,a,e)}else{let a=this.sharedGameControlGlobals.colliderToEntity.get(e),o=this.sharedGameControlGlobals.entityToCollisionEvents[a.uuid];if(o!==void 0)for(let h of o)h.data.target==="scene"&&this.dispatchCollisionEvent(h,a,e);let l=this.sharedGameControlGlobals.colliderToEntity.get(i),u=this.sharedGameControlGlobals.entityToCollisionEvents[l?.uuid];if(u!==void 0)for(let h of u)h.data.target==="scene"&&this.dispatchCollisionEvent(h,l,i)}}},this.isExport=t.isExport,this.sharedAssets=t.sharedAssets,this.renderer=t.renderer,this.requestRender=t.requestRender,this.domElement=this.renderer.domElement,this.pixelsPerMeter=200,this.gravity=this.page.data.globalPhysics.gravity}get page(){return this.eventContext.page}markIsDestroyTarget(){this.page.traverseVisibleEntity(t=>{let e=t.dataPatched;for(let i of e.events){if(i.data.disabled===!0)continue;let r=i.data.actions?.find(s=>s.data.type==="Destroy")?.data;if(r)for(let s of r.objects){let n=this.page.scene.find(s);n&&(n.userData.hasDestroy=!0)}}})}markIsDragObject(){this.page.traverseVisibleEntity(t=>{let e=t.dataPatched;for(let i of e.events)if(i.data.disabled!==!0&&i.data.type==="DragDrop")for(let r of i.data.objects){let s=this.page.scene.find(r);s&&(s.userData.hasDrag=!0)}})}_staticBVHIdOf(t){let e=this._staticBVHAttrIds.get(t);return e===void 0&&(e=this._staticBVHNextAttrId++,this._staticBVHAttrIds.set(t,e)),e}initBVH(){if(fF()===null)return void Nn("collision-bvh","trigger/collision detection");let t=[],e=[];if(this.page.traverseChildren(i=>{let r,s=i instanceof vv,n=q2(i);if(H1(i)||s||n)return;r=Sg(i)?i.object:i;let a=r.dataPatched;if(a.physics?.enabled==="visibility"?!a.visible:!a.physics?.enabled)return!0;let o=i.geometry,l=r.userData.hasDestroy===!0,u=r.userData.hasDrag===!0;if(f5(a)||l||u||r.dataPatched.events.some(h=>h.data.disabled!==!0&&(h.data.type==="GameControl"||h.data.type==="Follow")))return i.updateMatrixWorldRigid(),this.addBoundsTree(i),!0;if(o){let h=o.getAttribute("position");if(h!==void 0&&h.count>0){t.push({geometry:o,matrixWorld:i.matrixWorld}),e.push(o.id,this._staticBVHIdOf(h),h.version,o.index!==null?this._staticBVHIdOf(o.index):-1,o.index!==null?o.index.version:-1);for(let d of i.matrixWorld.elements)e.push(d)}}return!!Ky(i)||void 0}),t.length>0){let i=this._staticBVHCache;if(i!==void 0&&i.signature.length===e.length&&i.signature.every((n,a)=>n===e[a]))return void(this.sharedGameControlGlobals.staticMeshBVH=i.bvh);let r=wg(t.map(n=>ac(n.geometry,n.matrixWorld)),!1),s=new(fF())(r);this._staticBVHCache={signature:e,bvh:s},this.sharedGameControlGlobals.staticMeshBVH=s}}addRigidBody(t,e,i){if(i_t(t.matrixWorld))return;let r=[],s="geometry"in t?t.geometry:void 0,n=e.dataPatched;if(s?.getAttribute("position")!==void 0&&r.push(ac(s,t.shearScale)),n.physics.fusedBody){let a=this.gatherChildrenGeom(t,r);t.traverseObject(a),t.children.forEach(l=>l.updateMatrixWorld(!0));let o=t.cloner;o&&o.objectForSample===void 0&&n.physics.rigidBody==="dynamic"&&(o.traverseObject(a),o.children.forEach(l=>l.updateMatrixWorld(!0)))}if(r.length>0){let a,o=!1,l=!i.fromCreate&&n.physics.rigidBody==="dynamic"||i.fromCreate&&i.dynamic;l?(a=ki.RigidBodyDesc.dynamic(),a.setLinearDamping(n.physics.damping).setAngularDamping(n.physics.damping).setAdditionalMass(1e-9).setGravityScale(n.physics.gravityScale).enabledRotations(...n.physics.enabledRotation).enabledTranslations(...n.physics.enabledTranslation)):(i.hasTransformAnim||i.hasFollow||i.hasDrag)&&!i.fromCreate?(a=ki.RigidBodyDesc.kinematicPositionBased(),o=!0):a=ki.RigidBodyDesc.fixed();let u=wg(r);(t.hasNonUniformScale?t.matrixWorldRigid:t.matrixWorld).decompose(en,Wl,Tp),t.position0=en.clone().divideScalar(this.pixelsPerMeter),t.rotation0=Wl.clone(),en.divideScalar(this.pixelsPerMeter),a.setTranslation(en.x,en.y,en.z).setRotation(Wl),s?u?.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter):u?.scale(Tp.x/this.pixelsPerMeter,Tp.y/this.pixelsPerMeter,Tp.z/this.pixelsPerMeter);let h=this.sharedGameControlGlobals.rapierWorld.createRigidBody(a),d=!(n.geometry===void 0||n.geometry.type==="SubdivGeometry"||n.geometry.type==="NonParametricGeometry"||n.geometry.type==="BooleanGeometry"||n.geometry.type==="VectorGeometry"||n.geometry.type==="StarGeometry"||n.geometry.type==="RectangleGeometry"||n.geometry.type==="EllipseGeometry"||n.geometry.type==="TriangleGeometry"||n.geometry.type==="TorusGeometry"||n.geometry.type==="HelixGeometry");try{this.addCollider(h,n.physics,u,e,d)}catch{try{this.addCollider(h,n.physics,u,e,!1)}catch(c){console.error(c)}}if(h.numColliders()===0)return void this.sharedGameControlGlobals.rapierWorld.removeRigidBody(h);l?this.rigidBodyToMesh.set(h.handle,[t,Tp.clone(),n.physics.fusedBody]):o?(this.sharedGameControlGlobals.kinematicBodyToEntity.set(h.handle,t),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(t)):this.fixedBodiesToWatch.push([t,h,(t.hasNonUniformScale?t.matrixWorldRigid:t.matrixWorld).clone()]),t.rigidBody=h}}addBoundsTree(t){let e=[];if(t.geometry?.getAttribute("position")!==void 0&&t.geometry?.getAttribute("position").count>0&&e.push(ac(t.geometry,t.shearScale)),t.traverseObject(this.gatherChildrenGeom(t,e)),t.children.forEach(i=>i.updateMatrixWorld(!0)),e.length>0){let i=wg(e,!1);t.bvhGeometry=i,i.getAttribute("position").count>0&&(t.bvhGeometry.boundsTree=new(fF())(i),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(t))}}addCollider(t,e,i,r,s=!0){if(i?.getAttribute("position").count===0||i?.getIndex()?.count===0)return;let n;i&&(n=e.colliderType==="trimesh"?ki.ColliderDesc.trimesh(i.getAttribute("position").array,i.getIndex().array):ki.ColliderDesc.convexMesh(i.getAttribute("position").array,s?i.getIndex().array:void 0)),n.setFrictionCombineRule(ki.CoefficientCombineRule.Average).setRestitutionCombineRule(ki.CoefficientCombineRule.Average).setDensity(e.density).setFriction(e.friction).setRestitution(e.restitution);let a=this.sharedGameControlGlobals.rapierWorld.createCollider(n,t);this.sharedGameControlGlobals.colliderToEntity.set(a.handle,r),this.sharedGameControlGlobals.entityToCollisionEvents[r.uuid]?.some(o=>o.target==="scene")&&a.setActiveEvents(ki.ActiveEvents.COLLISION_EVENTS)}gatherChildrenGeom(t,e){let i=Ky(t);return(r,s)=>{if(s===0)return;if(i&&r.parent===t)return!0;let n;if(H1(r)){if(!r.objectForSample)return r.object.dataPatched.physics.fusedBody===!0&&r.object.dataPatched.physics.rigidBody==="dynamic"||void 0;if(r.objectForSample.dataPatched.physics.fusedBody)return;n=r.object}else if(Sg(r))n=r.object;else if(n=r,n.dataPatched.cloner?.hideBase)return!0;let a=n.dataPatched;if(a.physics.enabled==="visibility"?!a.visible:!a.physics.enabled)return!0;s===1?t.hasNonUniformScale?r.matrixWorld.multiplyMatrices(t.shearScale,r.hiddenMatrix):r.matrixWorld.copy(r.hiddenMatrix):r.matrixWorld.multiplyMatrices(r.parent.matrixWorld,r.hiddenMatrix),r.matrixWorld.multiply(r.matrix);let o=r.geometry;return o?.getAttribute("position")!==void 0&&e.push(ac(o,r.matrixWorld)),!!Ky(r)||void 0}}activate(t){if(this.isEnabled)return;this.isEnabled=!0,this.eventManager=t,this.usePhysics=this.page.data.globalPhysics.usePhysics;let e=this.page.playCamera,i=!1;this.page.traverseEntity(a=>{for(let o of a.dataPatched.events)if(o.data.disabled===!1&&o.data.type==="Trigger")return this.needsCollisionDetection=!0,!0});let r=Mut();if(r!==null?i=r.setup({manager:this,camera:e,renderer:this.renderer,sharedAssets:this.sharedAssets,eventContext:this.eventContext,isExport:this.isExport})||i:this.page.data.publish.gameControlObject!==null&&Nn("game-controls","the scene's game controls"),i===!1){let{enableRotate:a,enablePan:o,enableZoom:l,autoRotate:u,hoverRotatePanMode:h}=this.eventManager.publish.orbitControls;(a||o||l||u||h!==0)&&(this.orbitControls=new Obt(e,this.renderer.domElement,{isExport:this.isExport,isPlayMode:!0}),this.orbitControls.addEventListener("change",this.requestRender),this.orbitControls.addEventListener("end",this.requestRender),this.orbitControls.addEventListener("start",this.requestRender),this.orbitControls.fromJSON(this.eventManager.publish.orbitControls,this.eventManager.publish.mouseEventTarget),this.orbitControls.useKeyEvents=!1,this.orbitControls.addEventListenersToCamera(),this.orbitControls.connect(),this.orbitControls.update())}let s=this.renderer.domElement.width/this.renderer.getPixelRatio(),n=this.renderer.domElement.height/this.renderer.getPixelRatio();Mut()?.createJoysticks(this,s,n),this.markIsDestroyTarget(),this.markIsDragObject(),this.rebuildBVH(),this.initializationCounter++,window.setTimeout(()=>{this.collisionEvents.forEach(a=>a.initialDisabled=!1)},80)}initPhysics(){this.sharedGameControlGlobals.rapierWorld?.free(),this.sharedGameControlGlobals.rapierWorld=new ki.World(new ki.Vector3(0,this.gravity,0)),this.events=new ki.EventQueue(!0);let t=[],e=[];if(this.page.traverseChildren(a=>{let o;if(H1(a)){if(!a.objectForSample)return a.object.dataPatched.physics.fusedBody===!0&&a.object.dataPatched.physics.rigidBody==="dynamic"||void 0;if(a.objectForSample.dataPatched.physics.fusedBody)return;o=a.object}else if(Sg(a))o=a.object;else{if(q2(a)||Jg(a)||a instanceof vv)return;if(o=a,o.dataPatched.cloner?.disabled===!1&&o.dataPatched.cloner?.hideBase&&o.dataPatched.physics?.fusedBody!==!0)return!0}let l,u=o.dataPatched;for(let g of u.events)g.data.disabled!==!0&&g.data.type==="GameControl"&&(l=g.data);if(!u.physics||(u.physics.enabled==="visibility"?!u.visible:!u.physics.enabled))return!0;a.updateMatrixWorldRigid();let h=f5(u),d=!1,c=o.userData.hasDestroy,p=o.userData.hasDrag,m=!1;for(let g of u.events)if(g.data.disabled!==!0){if(g.data.type==="Collision"){d=!0;let y=new RPt(g.id,g.data,o,this.page,this.sharedAssets,this.eventManager);y.initialDisabled=!0,this.collisionEvents.push(y),this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid]&&this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid].every(v=>v.id!==g.id)?this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid].push(y):this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid]=[y]}else if(g.data.type==="Follow"){m=!0;let y=g.data.target;a.traverseVisible(v=>{v.userData.isFollowingObj=y})}}u.physics.rigidBody==="dynamic"&&u.physics.fusedBody===!1&&(a.matrixWorldFusedFalse=a.matrixWorld.clone());let f=a.geometry;if(l!==void 0){let g=ki.RigidBodyDesc.kinematicPositionBased();(a.hasNonUniformScale?a.matrixWorldRigid:a.matrixWorld).decompose(en,Wl,Tp),a.position0=en.clone().divideScalar(this.pixelsPerMeter),a.rotation0=Wl.clone(),en.divideScalar(this.pixelsPerMeter),g.setTranslation(en.x,en.y,en.z).setRotation(Wl);let y,v=this.sharedGameControlGlobals.rapierWorld.createRigidBody(g);a.rigidBody=v,y=l.collider.type==="sphere"?ki.ColliderDesc.ball(l.collider.radius/this.pixelsPerMeter):l.collider.type==="capsule"?ki.ColliderDesc.capsule((l.collider.height/2-l.collider.radius)/this.pixelsPerMeter,l.collider.radius/this.pixelsPerMeter):ki.ColliderDesc.cuboid(l.collider.width/this.pixelsPerMeter/2,l.collider.height/this.pixelsPerMeter/2,l.collider.depth/this.pixelsPerMeter/2),y.setFrictionCombineRule(ki.CoefficientCombineRule.Average).setDensity(u.physics.density).setFriction(u.physics.friction).setRestitution(0).setRestitutionCombineRule(ki.CoefficientCombineRule.Min);let b=this.sharedGameControlGlobals.rapierWorld.createCollider(y,v);this.sharedGameControlGlobals.colliderToEntity.set(b.handle,o),en.fromArray(l.collider.position.map(x=>typeof x=="number"?x:0)).multiply(Tp.setFromMatrixScale(o.matrixWorld)).divideScalar(this.pixelsPerMeter),b.setTranslationWrtParent(en);let _=new Me().setFromEuler(new Qi().setFromVector3(new P().fromArray(l.collider.rotation.map(x=>typeof x=="number"?x:0))));b.setRotationWrtParent(_),b.setActiveEvents(ki.ActiveEvents.COLLISION_EVENTS),this.generateSensorColliderDescs(o,!0)}else u.physics.rigidBody==="dynamic"||h||m||c||p||d?(this.addRigidBody(a,o,{hasFollow:m,hasTransformAnim:h,hasDrag:p}),this.generateSensorColliderDescs(o,u.physics.fusedBody)):(f&&t.push(ac(f,a.matrixWorld)),u.physics.fusedBody&&!Ky(a)&&a.traverseObject((g,y)=>{if(y===0)return;let v;if(H1(g)){if(!g.objectForSample)return g.object.dataPatched.physics.fusedBody===!0&&g.object.dataPatched.physics.rigidBody==="dynamic"||void 0;if(g.objectForSample.dataPatched.physics.fusedBody)return;v=g.object}else{if(q2(g)||Jg(g)||g instanceof vv)return;if(Sg(g))v=g.object;else if(v=g,v.dataPatched.cloner?.hideBase)return!0}let b=v.dataPatched;if(b.physics.enabled==="visibility"?!b.visible:!b.physics.enabled)return!0;let _=g.geometry;return _?.getAttribute("position")!==void 0&&t.push(ac(_,g.matrixWorld)),!!Ky(g)||void 0}),this.generateSensorColliderDescs(o,u.physics.fusedBody,e));return!(u.physics?.fusedBody!==!0&&!l&&!Ky(a))||void 0}),t.length===0)return;let i=wg(t),r=i.getIndex().count>0;if(!r&&e.length===0)return;i.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter);let s=ki.RigidBodyDesc.fixed(),n=this.sharedGameControlGlobals.rapierWorld.createRigidBody(s);if(r){let a=ki.ColliderDesc.trimesh(i.getAttribute("position").array,i.getIndex().array).setFrictionCombineRule(ki.CoefficientCombineRule.Multiply).setRestitutionCombineRule(ki.CoefficientCombineRule.Multiply).setFriction(1).setRestitution(1);this.sharedGameControlGlobals.rapierWorld.createCollider(a,n)}for(let[a,o]of e){let l=this.sharedGameControlGlobals.rapierWorld.createCollider(a,n);this.sensorToTriggerEvent[l.handle]=o}}updatePositions(){return this.nActiveRigidBodies=0,this.sharedGameControlGlobals.rapierWorld.forEachRigidBody(this.processRigidBody),this.nActiveRigidBodies>0}rebuildBVH(){this.usePhysics?this.initPhysics():(this.page.traverseEntity(t=>{for(let e of t.dataPatched.events)if(e.data.type==="Trigger"&&e.data.disabled!==!0){let i=new Put(e.id,e.data,t,this.page,this.sharedAssets,this.eventManager),r=new bt().compose(Ph.fromArray(e.data.position.map(s=>typeof s=="number"?s:0)),Yy.setFromEuler(Rut.fromArray(e.data.rotation.map(s=>typeof s=="number"?s:0))),vF);if(e.data.triggerZone==="box"){let s=new pr;s.min.fromArray(e.data.size.map(n=>typeof n=="number"?n:0)).multiplyScalar(-.5),s.max.fromArray(e.data.size.map(n=>typeof n=="number"?n:0)).multiplyScalar(.5),this.sharedGameControlGlobals.triggers.push([s,r,t,i])}else this.sharedGameControlGlobals.triggers.push([e.data.radius,r,t,i])}}),this.needsCollisionDetection&&this.initBVH())}disconnectEvents(){this.collisionEvents.forEach(t=>t.disconnect()),this.sharedGameControlGlobals.triggers.forEach(t=>t[3].disconnect()),this.sharedGameControlGlobals.triggers.length=0}deactivate(){if(this.isEnabled){this.isEnabled=!1,this.page.traverse(t=>{let e=t;e.matrixWorldFusedFalse&&(e.matrixWorldFusedFalse=void 0),e.rigidBody&&(e.rigidBody=void 0),e.position0&&(e.position0=void 0),e.rotation0&&(e.rotation0=void 0)}),this.sharedGameControlGlobals.rapierWorld?.free(),this.sharedGameControlGlobals.rapierWorld=void 0,this.sharedGameControlGlobals.staticMeshBVH=void 0,this.accumulator=0,this.sharedGameControlGlobals.entitiesWithTransformAnim=[],this.sharedGameControlGlobals.kinematicBodyToEntity.clear(),this.fixedBodiesToWatch=[],this.disconnectEvents(),this.gameControl?.reset(),this.gameControl?.dispose(),this.gameControl=null,this.initializationCounter=-1,this.joysticks.forEach(([t,e])=>{t?.destroy(),e.remove()}),this.joystickToGameControls=[],this.joysticks=[],this.orbitControls&&(this.orbitControls.dispose(),this.orbitControls=void 0),this.navigationMeshWrapper?.dispose(),this.navigationMeshWrapper=void 0;for(let t of Object.values(this.sharedGameControlGlobals.entityToCollisionEvents))t.forEach(e=>e.disconnect());this.sharedGameControlGlobals.entityToCollisionEvents={},this.page.updateMatrixWorld(!0)}}update(t){if(!this.isEnabled)return!0;let e=!0;if(this.orbitControls!==void 0&&this.orbitControls.needsUpdate&&(this.orbitControls.update(),e=!this.orbitControls.isCurrentlyDamping),this.initializationCounter>=0&&this.initializationCounter<2?(this.initializationCounter++,e=!1):this.initializationCounter===2&&this.gameControl&&(e=!this.gameControl.update(t)&&e),this.usePhysics===!1&&this.checkTrigger(),this.usePhysics){let i=.016666666666666666;if(t===0)e=this.stepPhysics()&&e;else{let r=t/1e3;r<i&&r>.55*i&&(r=i),this.accumulator+=r;let s=performance.now(),n=0,a=6;for(;this.accumulator>=i&&n<a&&(e=this.stepPhysics()&&e,this.accumulator-=i,n++,!(performance.now()-s>1e3*i)););this.accumulator=this.accumulator%i}}this.skipRender=e}recordPhysicsPose(t){(t.hasNonUniformScale?t.matrixWorldRigid:t.matrixWorld).decompose(en,Wl,Tp);let e=t;e.prevQ===void 0?(e.prevQ=Wl.clone(),e.prevT=en.clone()):(e.prevQ.copy(Wl),e.prevT.copy(en))}promoteMovedFixedBodies(){for(let t=this.fixedBodiesToWatch.length-1;t>=0;t--){let[e,i,r]=this.fixedBodiesToWatch[t];e.rigidBody===i?(e.hasNonUniformScale?e.matrixWorldRigid:e.matrixWorld).equals(r)||(i.setBodyType(ki.RigidBodyType.KinematicPositionBased,!0),this.sharedGameControlGlobals.kinematicBodyToEntity.set(i.handle,e),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(e),this.fixedBodiesToWatch.splice(t,1)):this.fixedBodiesToWatch.splice(t,1)}}clampPushedBodies(){let t=this.gameControl?.object.rigidBody;if(t===void 0)return;let e=this.sharedGameControlGlobals.rapierWorld,i=t.linvel(),r=t.translation(),s=Math.hypot(i.x,i.z);for(let n=0;n<t.numColliders();n++){let a=t.collider(n);e.contactPairsWith(a,o=>{let l=o.parent();if(l===null||!l.isDynamic())return;let u=l.translation(),h=-1/0,d=0,c=0;if(e.contactPair(a,o,y=>{let v=y.normal(),b=v.x*(u.x-r.x)+v.y*(u.y-r.y)+v.z*(u.z-r.z)<0?-1:1;if(Math.abs(v.y)>.7)return;let _=b*v.x,x=b*v.z,S=Math.hypot(_,x);if(S<1e-4)return;let w=(i.x*_+i.z*x)/S;w>h&&(h=w,d=_/S,c=x/S)}),h===-1/0)return;let p=i.x*d+i.z*c;if(p<-_F)return;let m=l.linvel();if(s>_F&&p>_F){let y=m.x*d+m.z*c;if(y<=0)return;let v=Math.min(y,p);return void l.setLinvel({x:d*v,y:m.y,z:c*v},!0)}let f=m.x*d+m.z*c-Math.max(0,p);if(f<=0)return;let g=.5*f;l.setLinvel({x:m.x-d*g,y:m.y,z:m.z-c*g},!0)})}}stepPhysics(){this.promoteMovedFixedBodies();let t=this.sharedGameControlGlobals.kinematicBodyToEntity;for(let[e,i]of t)i.rigidBody!==void 0?(this.recordPhysicsPose(i),i.rigidBody.setNextKinematicTranslation(en.divideScalar(this.pixelsPerMeter)),i.rigidBody.setNextKinematicRotation(Wl)):t.delete(e);for(let e of this.sharedGameControlGlobals.entitiesWithTransformAnim)e.rigidBody?.isKinematic()!==!0&&this.recordPhysicsPose(e);return this.sharedGameControlGlobals.rapierWorld.step(this.events),this.clampPushedBodies(),this.events?.drainCollisionEvents(this.handleCollisionEvents),!this.updatePositions()}dispatchCollisionEvent(t,e,i){let r,s=(this.sharedGameControlGlobals.rapierWorld?.getCollider(i))._parent;if(e.cloner){for(let n of e.cloner.children)if(n.rigidBody===s){r=n;break}}t.dispatch(r),e.dispatchEvent(h7)}updateUseWindowEvents(t){this.orbitControls?.updateUseWindowEvents(t)}generateSensorColliderDescs(t,e,i){let r=Dut.copy(t.matrixWorld).invert();t.traverseEntity((s,n)=>{if(e===!1&&n===1)return!0;for(let a of s.dataPatched.events)if(a.data.type==="Trigger"&&a.data.disabled!==!0){let o,l=new Put(a.id,a.data,s,this.page,this.sharedAssets,this.eventManager);if(o=a.data.triggerZone==="box"?ki.ColliderDesc.cuboid(...a.data.size.map(u=>(typeof u=="number"?u:1)/(2*this.pixelsPerMeter))):ki.ColliderDesc.ball(a.data.radius/this.pixelsPerMeter),o.setDensity(0).setSensor(!0).setActiveEvents(ki.ActiveEvents.COLLISION_EVENTS),Ph.fromArray(a.data.position.map(u=>typeof u=="number"?u:0)),Yy.setFromEuler(Rut.fromArray(a.data.rotation.map(u=>typeof u=="number"?u:0))),NE.compose(Ph,Yy,vF).premultiply(s.matrixWorld),i?(NE.decompose(Ph,Yy,yF),o.setActiveCollisionTypes(ki.ActiveCollisionTypes.KINEMATIC_FIXED|ki.ActiveCollisionTypes.DYNAMIC_FIXED)):(NE.premultiply(r).decompose(Ph,Yy,yF),t.rigidBody.bodyType()===ki.RigidBodyType.Dynamic||(t.rigidBody.bodyType()===ki.RigidBodyType.Fixed?o.setActiveCollisionTypes(ki.ActiveCollisionTypes.KINEMATIC_FIXED|ki.ActiveCollisionTypes.DYNAMIC_FIXED):o.setActiveCollisionTypes(ki.ActiveCollisionTypes.KINEMATIC_KINEMATIC|ki.ActiveCollisionTypes.DYNAMIC_KINEMATIC))),Ph.divideScalar(this.pixelsPerMeter),o.setTranslation(Ph.x,Ph.y,Ph.z),o.setRotation(Yy),i)i.push([o,l]);else{let u=this.sharedGameControlGlobals.rapierWorld.createCollider(o,t.rigidBody);this.sensorToTriggerEvent[u.handle]=l}}})}checkTrigger(){let t;for(let e=0;e<this.sharedGameControlGlobals.triggers.length;e++){let[i,r,s,n]=this.sharedGameControlGlobals.triggers[e];for(let a=0;a<this.sharedGameControlGlobals.entitiesWithTransformAnim.length;a++){let o=this.sharedGameControlGlobals.entitiesWithTransformAnim[a];if(s===o||n.isValidTriggeringObject(Mi.is(o)?o:o.object)===!1)continue;let l=Dut.copy(s.matrixWorld).decompose(Ph,Nut,yF).compose(Ph,Nut,vF).multiply(r),u=NE.copy(o.matrixWorld).invert().multiply(l),h=o.bvhGeometry.boundsTree;i instanceof pr?t=h.intersectsBox(i,u):(bF.radius=i,bF.center.setFromMatrixPosition(u),t=h.intersectsSphere(bF)),t?n.currentIntersectedObjects.indexOf(o)===-1&&(n.currentIntersectedObjects.push(o),n.dispatch(),s.dispatchEvent(NPt)):n.currentIntersectedObjects=n.currentIntersectedObjects.filter(d=>d!==o)}}}};Jv(),dt(),MR(),Fi(),wm();var xF=.02,Out=new P,Iut=new P,IPt=new P,qa=new P,Ld=new P,Zy=new P,wF=new bt,But=new bt,BPt=new bt,nl=new Me,Hf=new Me,Qy=new Qi(0,0,0,"YXZ"),VPt=new P(1,0,0),Eu=new P(0,1,0),kPt=new P(0,0,1),Vut=new P(1,1,1),kut=[],zut=t=>kut[t]??(kut[t]=new P),SF=new P,zPt=new P,LPt=new P,FPt=new P,Lut=new Me,UPt=new P,Fut=new Me,Hn=new yl,ql=new pr,jPt={type:"requestRender"},GPt={type:"updateMatrix"},u7=class extends Jn{constructor(t,e,i,r,s,n,a,o,l){super(),this.object=t,this.domElement=e,this.data=i,this.gloabalPhysics=r,this.controlsManager=s,this.cameraFollow=n,this.camera=a,this.page=o,this.sharedAssets=l,this.enableDamping=!0,this.hiddenMatrix0=new bt,this.target0=new P,this.zoom0=1,this.rotForce=1,this.moveForce=1,this.pixelsPerMeter=200,this.euler0=new Qi(0,0,0,"YXZ"),this.position0Cam=new P,this.quat0Cam=new Me,this.scale0Cam=new P,this.hiddenMatrix0Cam=new bt,this.threshEndTranslate=.01,this.threshEndRotate=1e-8,this.threshEndRotVel=.005,this.collider={type:"capsule",radius:40,segment:new yl(new P(0,-40,0),new P(0,40,0)),matrix:new bt,position:new P,rotation:new Me},this.euler=new Qi(0,0,0,"YXZ"),this.eulerDelta=new P,this.lastPosition=new P,this.lastCameraQuaternion=new Me,this.lastCameraPosition=new P,this.PI_2=Math.PI/2,this.prevMouse=new Z,this.velocityTarget=new P,this.velocity=new P,this.directionXZ=new P,this.rotVelocityStick=new P,this.rotVelocityTarget=new P,this.rotVelocity=new P,this.rotDirection=new P,this.nonColliderRotOffset=new bt,this.nonColliderPosOffset=new bt,this.firstPointerId=-1,this.rot=new P,this.path=[],this.movementState={moveNegZ:0,movePosZ:0,moveNegX:0,movePosX:0,moveNegY:0,movePosY:0,rotPosX:0,rotNegX:0,rotPosY:0,rotNegY:0,jump:0,run:0},this.onObject=!1,this.actionState={},this.keyAssignments=[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","ArrowUp"],["rotPosY","ArrowLeft"],["rotNegX","ArrowDown"],["rotNegY","ArrowRight"],["jump"," "]],this.collisionEnabled=!0,this.offsetMatrix=new bt,this.objectToTarget=new P,this.objectToTarget0=new P,this.objectToCamXZ=new P,this.objectToCamXZ0=new P,this.targetToCamera=new P,this.targetToCamera0=new P,this.cameraPolarAxis0=new P,this.targetPos=new P,this.targetQuat=new Me,this.lerpFactorPos=new P().setScalar(.3),this.lerpFactorPosStart=.3,this.lerpFactorPosEnd=.3,this.lerpFactorRotStart=.3,this.lerpFactorRotEnd=.3,this.lerpFactorPosCamera=.3,this.lerpFactorRotCamera=.3,this.objXZQuat=new Me,this.objXZQuatInv=new Me,this.objXZRotMat=new bt,this.isFirstPerson=!1,this.didHit=!1,this.groundVelocity=new P,this.pushedVelocity=new P,this.groundYRotation=0,this.objectRealQuat=new Me,this.colliderWorldQuat=new Me,this.groundNormal=new P,this.groundTilt=new Me,this.groundTiltInv=new Me,this.lastHitObj=null,this.isFirstFrame=!0,this.rotationAccumWhenOrientWithCamera=0,this.navMeshPathDest=null,this.position=new P,this.quaternion=new Me,this.scale=new P,this.initialAction=!0,this.onPointerDown=m=>{!(m.target===this.domElement||m.target instanceof HTMLElement&&m.target.tagName==="SPLINE-VIEWER"&&m.target.shadowRoot?.contains(this.domElement))||this.firstPointerId!==-1||(this.firstPointerId=m.pointerId,this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp),this.rotBy!=="keys"&&!Fo&&!N8&&this.domElement.requestPointerLock(),this.prevMouse.set(m.clientX,m.clientY))},this.onPointerUp=m=>{this.firstPointerId=-1,this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp),m.pointerType==="mouse"&&this.domElement.ownerDocument.exitPointerLock()},this.onPointerMove=m=>{if(m.pointerId!==this.firstPointerId)return;let f=m.clientX-this.prevMouse.x,g=m.clientY-this.prevMouse.y;this.prevMouse.set(m.clientX,m.clientY),m.pointerType==="mouse"&&this.rotBy!=="keys"&&(N8&&Xpt<15.5&&!Fo?(this.eulerDelta.y=-f*this.mouseOrbitSensitivity,this.eulerDelta.x=-g*this.mouseOrbitSensitivity):(this.eulerDelta.y=-m.movementX*this.mouseOrbitSensitivity,this.eulerDelta.x=-m.movementY*this.mouseOrbitSensitivity)),m.pointerType!=="mouse"&&this.rotByTouch==="drag"&&(this.eulerDelta.y=-f*this.mouseOrbitSensitivity*5,this.eulerDelta.x=-g*this.mouseOrbitSensitivity*5),this.controlsManager.requestRender()},this.onPointerlockChange=m=>{this.domElement.ownerDocument.pointerLockElement===this.domElement?u7.isLocked=!0:u7.isLocked=!1},this.onPointerlockError=()=>{console.error("SPE.GameControls: Unable to use Pointer Lock API")},this.handleVisibilityChange=()=>{if(document?.hidden)for(let m in this.movementState)this.movementState[m]=0},this.onKeyDown=m=>{!(m.target instanceof HTMLInputElement)&&(m.code==="ArrowLeft"||m.code==="ArrowUp"||m.code==="ArrowRight"||m.code==="ArrowDown"||m.code==="Space")&&m.preventDefault();for(let f of this.keyAssignments)if(m.key.toUpperCase()===f[1]||m.key===f[1]){this.movementState[f[0]]=1;break}this.controlsManager.requestRender()},this.onKeyUp=m=>{for(let f of this.keyAssignments)if(m.key.toUpperCase()===f[1]||m.key===f[1]||m.code.slice(3,m.code.length).toUpperCase()===f[1]){this.movementState[f[0]]=0;break}},this.copyVRGamePadValues=(m,f)=>{for(let g=2;g<4;g++){let y=m.axes[g];f===0?g===2?this.movementState.movePosX=y:this.movementState.movePosZ=y:(m.buttons[3].pressed?this.movementState.jump=1:this.movementState.jump=0,g===2?this.movementState.rotPosY=y:this.moveMode==="fly"&&(this.movementState.moveNegY=y))}},this.sharedGameControlGlobals=s.sharedGameControlGlobals,t===a&&(this.isFirstPerson=!0),this.hiddenMatrix0.copy(this.object.hiddenMatrix),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.position,this.quaternion,this.scale),this.euler0.setFromQuaternion(this.quaternion,"YXZ");let u=this.euler0.clone(),h=u.y;if(this.objectRealQuat.copy(this.quaternion),u.y=0,this.quaternion.setFromEuler(u),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),u.set(0,h,0),this.quaternion.setFromEuler(u),this.rot.setFromEuler(u),this.object.matrixAutoUpdate=!1,(this.isFirstPerson||this.cameraFollow===!0)&&(this.target0.copy(this.camera.getTarget()),this.zoom0=this.camera.zoom),this.cameraFollow===!0){this.position0Cam.copy(this.camera.position),this.quat0Cam.copy(this.camera.quaternion),this.scale0Cam.copy(this.camera.scale),this.hiddenMatrix0Cam.copy(this.camera.hiddenMatrix),this.camera.parent?(this.camera.hiddenMatrix.copy(this.camera?.parent.matrixWorld),this.camera.matrix.copy(this.camera.matrixWorld)):this.camera.hiddenMatrix.identity(),this.camera.matrix.copy(this.camera.matrixWorld),this.camera.matrix.decompose(this.camera.position,this.camera.quaternion,this.camera.scale),this.camera.matrixAutoUpdate=!1,this.offsetMatrix.copy(this.object.matrix).invert().multiply(this.camera.matrix);let m,f=new P(0,0,-1).applyQuaternion(this.camera.quaternion),g=new P().subVectors(this.position,this.camera.position);this.objectToCamXZ.copy(g),this.objectToCamXZ.y=0,this.objectToCamXZ0.copy(this.objectToCamXZ),Math.abs(f.y)<1e-6?(g.y=0,f.y=0,m=g.projectOnVector(f)):m=g.y/f.y>0?f.multiplyScalar(g.y/f.y):f.multiplyScalar(g.length()),this.targetToCamera0.copy(m).negate();let y=this.camera.position.clone().add(m);this.objectToTarget0.subVectors(y,this.position);let v=new Qi().setFromQuaternion(this.camera.quaternion,"YXZ");this.cameraPolarOffset=-v.x,v.x=0,v.z=0,v.y-=Math.PI/2,this.cameraPolarAxis0.set(0,0,-1).applyEuler(v)}if(this.object instanceof ln&&(this.object.matrixAutoUpdate=!1),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.rotByTouch=i.rotByTouch??"joystick",this.rotBy=i.rotBy??"keys",this.rotationMode=i.rotationMode??"normal",this.moveMode=i.moveMode??"walk",this.collisionEnabled=i.collisionEnabled,this.speedTranslate=1*(i.speedTranslate??250),this.speedOrbit=.025*(i.speedRotate??100),this.mouseOrbitSensitivity=16e-6*(i.speedRotate??100),this.keyAssignments=i.keyAssignments.map(m=>{let f=[m[0],m[1]];return f[1]==="\u25B2"?f[1]="ArrowUp":f[1]==="\u25C0"?f[1]="ArrowLeft":f[1]==="\u25BC"?f[1]="ArrowDown":f[1]==="\u25B6"?f[1]="ArrowRight":f[1]==="\u21E7"?f[1]="Shift":f[1]==="\u21B5"?f[1]="Enter":f[1]==="Space"?f[1]=" ":f[1]==="\u2318"?f[1]="Meta":f[1]==="Ctrl"?f[1]="Control":f[1]==="Esc"&&(f[1]="Escape"),f}),i.rotBy==="mouse"){let m;m=this.keyAssignments.findIndex(f=>f[0]==="rotNegX"),m!==-1&&(this.keyAssignments[m][1]=""),m=this.keyAssignments.findIndex(f=>f[0]==="rotPosX"),m!==-1&&(this.keyAssignments[m][1]=""),m=this.keyAssignments.findIndex(f=>f[0]==="rotPosY"),m!==-1&&(this.keyAssignments[m][1]=""),m=this.keyAssignments.findIndex(f=>f[0]==="rotNegY"),m!==-1&&(this.keyAssignments[m][1]="")}this.lerpFactorPosStart=1-.02**(1/(60*(i.delayPos[0]??.3))),this.lerpFactorPosEnd=1-.02**(1/(60*(i.delayPos[1]??.3))),this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.lerpFactorRotStart=1-.02**(1/(60*(i.delayRot[0]??.3))),this.lerpFactorRotEnd=1-.02**(1/(60*(i.delayRot[1]??.3))),this.lerpFactorPosCamera=1-.02**(1/(60*(i.delayPosCamera??.3))),this.lerpFactorRotCamera=1-.02**(1/(60*(i.delayRotCamera??.3))),this.gravity=12*(this.gloabalPhysics.gravity??dv.defaultData.gravity),this.usePhysics=this.gloabalPhysics.usePhysics??dv.defaultData.usePhysics,this.jumpPower=20*i.jumpPower,this.resetYPosition=this.position.y+Math.abs(i.resetYPosition)*(this.gravity>0?1:-1),this.alignToGround=i.alignToGround??!1,this.orientMode=i.autoOrientMove?i.orientMode:"none",this.orientWith=i.orientWith??yR.defaultDataThirdPerson.orientWith,this.slopeThresh=65*Math.PI/180,i.collider.type==="capsule"?(this.collider.radius=i.collider.radius,this.collider.segment.start.y=i.collider.height/2-i.collider.radius,this.collider.segment.end.y=-this.collider.segment.start.y,this.offset=i.collider.height*xF/this.pixelsPerMeter,this.stepThresh=.3*i.collider.height/this.pixelsPerMeter,this.colliderHeight=i.collider.height):i.collider.type==="sphere"?(this.collider.radius=i.collider.radius,this.collider.segment.start.y=0,this.collider.segment.end.y=0,this.offset=2*i.collider.radius*xF/this.pixelsPerMeter,this.stepThresh=2*i.collider.radius*.3/this.pixelsPerMeter,this.colliderHeight=2*i.collider.radius):(this.offset=i.collider.height*xF/this.pixelsPerMeter,this.stepThresh=.3*i.collider.height/this.pixelsPerMeter,this.colliderHeight=i.collider.height),this.collider.type=i.collider.type;let d=new P().fromArray(i.collider.position.map(m=>typeof m=="number"?m:0)),c=new Me().setFromEuler(new Qi().fromArray([...i.collider.rotation.map(m=>typeof m=="number"?m:0),"XYZ"]));this.collider.position.copy(d).multiply(this.scale),this.collider.rotation.copy(c),this.collider.matrix.compose(d,c,Vut),i.cameraXAxis!==void 0&&(this.cameraXAxis=i.cameraXAxis,this.cameraYAxis=i.cameraYAxis,this.minPolarAngle=i.cameraRotXLimits[0],this.maxPolarAngle=i.cameraRotXLimits[1],this.minAzimuthAngleRel=i.cameraRotYLimits[0],this.maxAzimuthAngleRel=i.cameraRotYLimits[1]),this.forwardDir=i.forwardDirection??"-z",this.isFirstPerson&&(this.forwardDir="-z"),this.runMultiplier=i.runMultiplier??2;let p=2*i.navmesh.destinationHelperRadius;if(p>0){let m=new ge;m.push({fi:0,data:{...Ws.defaultData("light","phong"),alpha:0},id:"layer1"}),m.push({fi:0,data:{...Ws.defaultData("color"),color:i.navmesh.destinationHelperColor,alpha:i.navmesh.destinationHelperColor.a},id:"layer2"});let f=Sgt({layers:m},{scene:this.page.scene,shared:this.sharedAssets});this.navMeshPathDest=new Sr(MG.create({parameters:{width:p,height:p/10,hollow:.7}}),f),this.navMeshPathDest.material.userData.opacity0=i.navmesh.destinationHelperColor.a}this.activate()}reset(t=!1){if(this.object.hiddenMatrix.copy(this.hiddenMatrix0),t){this.object.updateMatrix(),this.object.updateMatrixWorld(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.position,this.quaternion,this.scale),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity();let e=new Qi().setFromQuaternion(this.quaternion,"YXZ"),i=e.y;this.objectRealQuat.copy(this.quaternion),e.y=0,this.quaternion.setFromEuler(e),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),e.set(0,i,0),this.quaternion.setFromEuler(e),this.rot.setFromEuler(e),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.velocityTarget.set(0,0,0),this.velocity.set(0,0,0)}else this.object instanceof ln?this.object.matrixAutoUpdate=!0:this.object.updateMatrix();this.cameraFollow===!0&&(this.camera.quaternion.copy(this.quat0Cam),this.camera.position.copy(this.position0Cam),this.camera.scale.copy(this.scale0Cam),this.camera.hiddenMatrix.copy(this.hiddenMatrix0Cam),this.camera.matrixAutoUpdate=!0),this.controlsManager.requestRender()}activate(){this.instantiateActions(),this.domElement.ownerDocument.addEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.addEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.addEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.addEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.addEventListener("pointerlockerror",this.onPointerlockError),this.domElement.ownerDocument.addEventListener("visibilitychange",this.handleVisibilityChange)}deactivate(){this.disposeActions(),this.domElement.ownerDocument.removeEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.removeEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.removeEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.removeEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.removeEventListener("pointerlockerror",this.onPointerlockError),this.domElement.ownerDocument.removeEventListener("visibilitychange",this.handleVisibilityChange)}dispose(){this.deactivate(),this.navMeshPathDest?.parent&&this.page.remove(this.navMeshPathDest)}instantiateActions(){let t=this.data,e=this.sharedAssets;t.gameActions!==void 0&&(this.actions={},gR.list.forEach(i=>{this.actions[i]=un({...t,disabled:!1,type:"GameControl"},t.gameActions[i],this.page,e,this.controlsManager.eventManager,this.object)})),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"),this.initialAction&&(this.initialAction=!1)}disposeActions(){this.initialAction=!1,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),na(this.actions.idle),na(this.actions.move),na(this.actions.run),na(this.actions.jump)}dispatchStartEvent(t){this.actions[t]!==void 0&&(this.actionState[t]||(this.actionState[t]=!0,this.actions[t].Transition.forEach(e=>{e.play()}),this.actions[t].Animation.forEach(e=>{e.play(this.initialAction===!1)}),this.actions[t].TimelineAnimation.forEach(e=>{e.play()}),this.actions[t].Create.forEach(e=>{e.dispatchStart()}),this.actions[t].Audio.forEach(e=>{e.dispatchGameControl("start")}),this.actions[t].Particles.forEach(e=>{e.dispatchGameControl("start")})))}dispatchStopEvent(t){this.actions[t]!==void 0&&(!this.actionState[t]||(this.actionState[t]=!1,this.actions[t].Transition.forEach(e=>{e.stop(),e.object.currentState!==null&&e.object.changeSelectedState(null,{scene:this.page.scene,shared:this.sharedAssets})}),this.actions[t].TimelineAnimation.forEach(e=>{e.stop()}),this.actions[t].Create.forEach(e=>{e.dispatchStop()}),this.actions[t].Audio.forEach(e=>{e.dispatchGameControl("stop")}),this.actions[t].Particles.forEach(e=>{e.dispatchGameControl("stop")})))}get colliderWorldPosition(){return qa.copy(this.collider.position).applyQuaternion(this.objectRealQuat).add(this.position)}update(t){if(this.gravity<0?this.position.y<this.resetYPosition:this.position.y>this.resetYPosition)return this.reset(!0),!0;this.sharedGameControlGlobals.gamePads.forEach(this.copyVRGamePadValues);let e=(this.isFirstFrame?16.6:t)/1e3;this.isFirstFrame&&(this.isFirstFrame=!1);let i=60*e,r=!1;if(this.groundYRotation=0,this.groundVelocity.set(0,0,0),this.usePhysics&&this.collisionEnabled&&this.object.rigidBody?.collider(0).shape){let n=Ld.set(0,(this.velocity.y===0?this.pixelsPerMeter*Math.max(Math.abs(this.gravity)/120,1)*(this.gravity>0?1:-1):this.velocity.y)*e,0).divideScalar(this.pixelsPerMeter),a=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter),this.colliderWorldQuat,n,this.object.rigidBody?.collider(0).shape,0,1,!1,8,void 0,void 0,this.object.rigidBody);if(a){this.onObject=!0,this.groundNormal.set(a.normal2.x,a.normal2.y,a.normal2.z).applyQuaternion(this.colliderWorldQuat).negate(),this.alignToGround&&this.groundTiltAdjustment(this.groundNormal),Math.acos(this.groundNormal.y)<this.slopeThresh&&(r=!0),a.collider.parent()?.bodyType()===0&&Math.acos(this.groundNormal.y)*(180/Math.PI)>45&&(this.onObject=!1);let o=a.collider.parent(),l=o!==null&&o.isKinematic()?o:null,u=l===null?void 0:this.sharedGameControlGlobals.kinematicBodyToEntity.get(l.handle);if(l!==null&&u?.userData.isFollowingObj!==this.object.uuid){let h=this.object.getWorldPosition(qa).add(this.collider.position).divideScalar(this.pixelsPerMeter),d=l.velocityAtPoint(h);this.groundVelocity.set(d.x,d.y,d.z).multiplyScalar(this.pixelsPerMeter),this.groundYRotation=l.angvel().y*e}}else this.onObject=!1}if(this.moveMode==="walk"&&this.collisionEnabled&&(this.movementState.jump===1&&this.onObject&&(this.velocityTarget.y=this.jumpPower,this.movementState.jump=0,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("jump"),this.onObject=!1),this.onObject?this.velocityTarget.y/=2:this.velocityTarget.y+=this.gravity*i),this.moveMode==="fly"&&(this.velocityTarget.y=(this.movementState.movePosY-this.movementState.moveNegY)*this.speedTranslate),this.directionXZ.z=this.movementState.movePosZ-this.movementState.moveNegZ,this.directionXZ.x=this.movementState.movePosX-this.movementState.moveNegX,this.forwardDir==="+z"&&this.directionXZ.multiplyScalar(-1),this.directionXZ.manhattanLength()>0&&(this.path=[]),this.navMeshPathDest){let n=this.navMeshPathDest.material;if(this.moveMode==="walk"&&this.path.length>1){this.navMeshPathDest.position.copy(this.path[this.path.length-1]),this.navMeshPathDest.parent||this.page.add(this.navMeshPathDest);let a=qa.subVectors(this.path[1],this.position),o=Ld.subVectors(this.path[1],this.path[0]);a.dot(o)<0?this.path.shift():(this.directionXZ.x=o.x,this.directionXZ.z=o.z),n.opacity=n.userData.opacity0}else n.opacity-=.05*n.userData.opacity0,this.navMeshPathDest.material.opacity<=0&&this.navMeshPathDest.parent&&this.page.remove(this.navMeshPathDest)}this.directionXZ.normalize(),this.movementState.run?this.moveForce=this.runMultiplier:this.moveForce=1,this.velocityTarget.z=this.directionXZ.z*this.speedTranslate*this.moveForce,this.velocityTarget.x=this.directionXZ.x*this.speedTranslate*this.moveForce,(this.moveMode==="walk"?this.velocityTarget.x+this.velocityTarget.z===0:this.velocityTarget.manhattanLength()===0)?this.lerpFactorPos.setScalar(this.lerpFactorPosEnd):this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.moveMode==="walk"&&(this.lerpFactorPos.y=1),this.didHit===!1&&this.pushedVelocity.manhattanLength()===0||this.usePhysics===!1?(this.velocity.x+=(this.velocityTarget.x-this.velocity.x)*(1-(1-this.lerpFactorPos.x)**i),this.velocity.y+=(this.velocityTarget.y-this.velocity.y)*(1-(1-this.lerpFactorPos.y)**i),this.velocity.z+=(this.velocityTarget.z-this.velocity.z)*(1-(1-this.lerpFactorPos.z)**i)):this.velocity.copy(this.velocityTarget),(this.moveMode==="walk"?this.velocity.x**2+this.velocity.z**2<this.speedTranslate:this.velocity.lengthSq()<this.speedTranslate)?(this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.onObject&&(this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"))):(this.dispatchStopEvent("idle"),(this.onObject||this.moveMode==="fly")&&(this.dispatchStopEvent("jump"),this.movementState.run?(this.dispatchStopEvent("move"),this.dispatchStartEvent("run")):(this.dispatchStopEvent("run"),this.dispatchStartEvent("move"))));let s=IPt.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1){let n=Ld.copy(s);n.y=0,s.set(0,s.y,n.length()*(this.forwardDir==="+z"?1:-1))}if(this.directionXZ.manhattanLength()>0&&this.orientMode!=="none"&&this.isFirstPerson===!1)if(this.orientWith==="camera"&&this.path.length<=1){let n=qa;this.camera.getWorldDirection(n);let a=Zy.copy(Eu).multiplyScalar(n.dot(Eu));n.sub(a);let o=Ld.copy(this.directionXZ);o.x*=-1,this.rot.y=n.angleTo(o)*(n.cross(o).y>0?-1:1)+this.rotationAccumWhenOrientWithCamera}else this.rot.y=(this.path.length>1?0:this.euler.y)+Math.atan2(-this.directionXZ.z,this.directionXZ.x)+Math.PI/2*(this.forwardDir==="+z"?1:-1);if(Qy.setFromVector3(this.rot),this.moveMode==="walk"&&(Qy.x=0),s.applyEuler(Qy),r&&(Hf.setFromUnitVectors(Eu,this.groundNormal),s.applyQuaternion(Hf)),this.usePhysics===!0&&this.object.rigidBody){this.pushedVelocity.set(0,0,0);let n=0;for(let a of this.sharedGameControlGlobals.entitiesWithTransformAnim){if(a.rigidBody===void 0||a.prevQ===void 0)continue;(a.hasNonUniformScale?a.matrixWorldRigid:a.matrixWorld).decompose(SF,Lut,zPt);let o=this.object.getWorldPosition(LPt).add(this.collider.position).sub(SF);Fut.copy(a.prevQ).invert().premultiply(Lut);let l=Zy.subVectors(SF,a.prevT).add(FPt.copy(o).applyQuaternion(Fut).sub(o)).divideScalar(e).divideScalar(this.pixelsPerMeter),u=a.rigidBody.collider(0).castCollider(l,this.object.rigidBody.collider(0),qa.copy(s).divideScalar(this.pixelsPerMeter),0,e,!1);l.multiplyScalar(this.pixelsPerMeter);let h=Mi.is(a)?a:a.object;if(u!==null&&this.lastHitObj!==h){let d;a instanceof _l&&(d=a);let c=this.sharedGameControlGlobals.entityToCollisionEvents[h.uuid];if(c)for(let p of c)p.data.target==="character"&&(p.dispatch(d),h.dispatchEvent(h7));this.lastHitObj=h}u!==null&&(Math.abs(l.x)>Math.abs(this.pushedVelocity.x)&&(this.pushedVelocity.x=l.x),Math.abs(l.y)>Math.abs(this.pushedVelocity.y)&&(this.pushedVelocity.y=l.y),Math.abs(l.z)>Math.abs(this.pushedVelocity.z)&&(this.pushedVelocity.z=l.z),zut(n++).copy(u.normal1).applyQuaternion(a.quaternion))}if(n>0){for(let a=0;a<n;a++){let o=zut(a),l=o.dot(s);l<0&&s.addScaledVector(o,-l)}s.add(this.pushedVelocity)}else s.add(this.groundVelocity)}if(this.rotDirection.y=Number(this.movementState.rotPosY)-Number(this.movementState.rotNegY),this.rotDirection.x=Number(this.movementState.rotPosX)-Number(this.movementState.rotNegX),this.rotDirection.normalize(),this.rotationMode==="normal"&&(this.movementState.rotPosX||this.movementState.rotNegX)||this.rotationMode==="steer"&&(this.movementState.rotPosX||this.movementState.rotNegX)&&(this.movementState.movePosZ||this.movementState.moveNegZ||this.moveMode==="walk")?this.rotVelocityStick.x=-this.rotDirection.x*this.speedOrbit*this.rotForce:this.rotVelocityStick.x=0,this.rotationMode==="normal"&&(this.movementState.rotPosY||this.movementState.rotNegY)||this.rotationMode==="steer"&&(this.movementState.rotPosY||this.movementState.rotNegY)&&(this.movementState.movePosZ||this.movementState.moveNegZ)?this.rotVelocityStick.y=-this.rotDirection.y*this.speedOrbit*this.rotForce:this.rotVelocityStick.y=0,this.rotVelocityTarget.subVectors(this.eulerDelta.divideScalar(e),this.rotVelocityStick),this.rotVelocityTarget.manhattanLength()===0?this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotEnd)**i):this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotStart)**i),this.euler.x+=this.rotVelocity.x*e,this.euler.y+=this.rotVelocity.y*e+this.groundYRotation,this.rotVelocityTarget.y===0&&this.directionXZ.manhattanLength()===0?this.rotationAccumWhenOrientWithCamera=0:(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.rotationAccumWhenOrientWithCamera+=this.rotVelocity.y*e),this.isFirstPerson===!1&&this.orientMode!=="none"&&this.directionXZ.manhattanLength()>0){if(this.orientMode==="radial"){this.objectToCamXZ.copy(this.objectToCamXZ0).applyAxisAngle(Eu,this.euler.y-this.euler0.y);let n=Ld.copy(this.objectToCamXZ).normalize(),a=Zy.copy(s).multiplyScalar(e);a.y=0;let o=a.sub(qa.copy(n).multiplyScalar(a.dot(n))).cross(n).y;this.euler.y-=Math.atan2(o,this.objectToCamXZ.length())}}else this.rot.y+=this.rotVelocity.y*e+this.groundYRotation,this.rotVelocityTarget.y!==0&&(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.euler.y=this.rot.y);if(this.cameraFollow===!0&&(this.moveMode==="walk"?this.cameraXAxis==="Limit"?this.euler.x=qt.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):this.euler.x=qt.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset,this.PI_2+this.cameraPolarOffset):this.cameraXAxis==="Limit"&&(this.euler.x=qt.clamp(this.euler.x,-this.PI_2,this.PI_2))),this.moveMode==="fly"?this.rot.x=this.euler.x:this.isFirstPerson&&(Qy.copy(this.euler),Qy.y=0,this.nonColliderRotOffset.makeRotationFromEuler(Qy)),nl.setFromAxisAngle(VPt,this.rot.x),Hf.setFromAxisAngle(Eu,this.rot.y),Hf.multiply(nl),nl.setFromAxisAngle(kPt,this.rot.z),Hf.multiply(nl),this.quaternion.copy(Hf),this.objectRealQuat.multiplyQuaternions(this.quaternion,this.objXZQuat),this.colliderWorldQuat.copy(this.objectRealQuat).multiply(this.collider.rotation),this.collisionEnabled)if(this.usePhysics&&this.object.rigidBody?.collider(0).shape){let n=Ld.copy(s).multiplyScalar(e/this.pixelsPerMeter),a=null;this.didHit=!1;let o=new P;for(let h=0;h<5;h++){let d=n.length(),c=Zy.copy(n).normalize();if(a=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(o),this.colliderWorldQuat,c,this.object.rigidBody.collider(0).shape,0,d,!1,12,void 0,void 0,this.object.rigidBody),a===null){h===0&&this.directionXZ.manhattanLength()!==0&&(this.lastHitObj=null),o.add(n);break}{this.didHit=!0;let p=this.sharedGameControlGlobals.colliderToEntity.get(a.collider.handle);if(p!==this.lastHitObj&&h===0){this.lastHitObj=p;let y=this.sharedGameControlGlobals.entityToCollisionEvents[p?.uuid];if(y){for(let v of y)if(v.data.target==="character"){let b,_=(this.sharedGameControlGlobals.rapierWorld?.getCollider(a.collider.handle))._parent;if(p.cloner){for(let x of p.cloner.children)if(x.rigidBody===_){b=x;break}}v.dispatch(b),p.dispatchEvent(h7)}}}let m=Out.set(a.normal2.x,a.normal2.y,a.normal2.z).applyQuaternion(this.colliderWorldQuat),f=Iut.copy(c).multiplyScalar(a.time_of_impact).dot(m),g=a.time_of_impact;if(g===0&&(this.position.y+=this.offset*this.pixelsPerMeter),f>this.offset&&(g=a.time_of_impact*(f-this.offset)/f,o.addScaledVector(c,g)),n.copy(c).multiplyScalar(d-g),Math.acos(-m.y)>this.slopeThresh){let y=this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(o),v=Zy.copy(a.witness2).applyQuaternion(this.colliderWorldQuat);v.y=0;let b=y.add(v);b.y+=this.stepThresh;let _=this.sharedGameControlGlobals.rapierWorld.castShape(b,this.colliderWorldQuat,n,this.object.rigidBody?.collider(0).shape,0,1,!1,12,void 0,void 0,this.object.rigidBody);_!==null&&_.time_of_impact===0&&(m.y=0,m.normalize())}n.addScaledVector(m,-n.dot(m))}}this.position.addScaledVector(o,this.pixelsPerMeter),qa.copy(this.position).divideScalar(this.pixelsPerMeter),nl.copy(this.quaternion).premultiply(this.groundTilt).multiply(this.objXZQuat);let l=this.object.rigidBody,u=l!==void 0&&UPt.copy(qa).sub(l.translation()).lengthSq()>1;l!==void 0&&(u?(l.setTranslation(qa,!0),l.setRotation(nl,!0)):(l.setNextKinematicTranslation(qa),l.setNextKinematicRotation(nl)))}else{let n=this.onObject?1:5,a=s.multiplyScalar(e/n);for(let o=0;o<n;o++)this.position.add(a),this.collisionAdjustment(e/n)}else this.position.addScaledVector(s,e);if(this.moveMode==="walk"&&this.onObject&&(this.velocityTarget.y=0,this.velocity.y=0),this.quaternion.premultiply(this.groundTilt).multiply(this.objXZQuat),this.object.matrix.compose(this.position,this.quaternion,this.scale),this.object.matrixWorldNeedsUpdate=!0,this.object.matrix.multiply(this.nonColliderPosOffset).multiply(this.nonColliderRotOffset),this.quaternion.premultiply(this.groundTiltInv).multiply(this.objXZQuatInv),this.cameraFollow===!0){this.updateFollowArms();let n=this.objectToTarget.add(this.position),a=this.targetToCamera.add(n);wF.lookAt(a,n,Eu).setPosition(a),wF.decompose(this.targetPos,this.targetQuat,qa),this.camera.quaternion.slerp(this.targetQuat,1-(1-this.lerpFactorRotCamera)**i),this.camera.position.lerp(this.targetPos,1-(1-this.lerpFactorPosCamera)**i),this.camera.updateMatrix(),this.camera.updateMatrixWorld(),this.cameraYAxis==="Limit"&&this.orientMode==="cartesian"&&(this.euler.y=qt.clamp(this.euler.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel)),this.euler.x=qt.clamp(this.euler.x,-this.PI_2+(this.cameraPolarOffset<0?this.cameraPolarOffset:0),this.PI_2+(this.cameraPolarOffset>0?this.cameraPolarOffset:0))}return this.eulerDelta.set(0,0,0),this.object.dispatchEvent(GPt),!(this.path.length<2&&this.lastPosition.distanceToSquared(this.position)<this.threshEndTranslate&&Math.abs(this.rotVelocity.x)<this.threshEndRotVel&&Math.abs(this.rotVelocity.y)<this.threshEndRotVel&&(this.camera===void 0||this.isFirstPerson||this.lastCameraPosition.distanceToSquared(this.camera.position)<this.threshEndTranslate&&8*(1-this.lastCameraQuaternion.dot(this.camera.quaternion))<this.threshEndRotate)&&(this.moveMode==="fly"||this.onObject===!0||this.collisionEnabled===!1)&&(this.navMeshPathDest===null||this.navMeshPathDest.material.opacity<-.04*this.navMeshPathDest?.material?.userData.opacity0)||(this.camera&&(this.lastCameraPosition.copy(this.camera.position),this.lastCameraQuaternion.copy(this.camera.quaternion)),this.lastPosition.copy(this.position),this.object.dispatchEvent(jPt),0))}updateFollowArms(){this.objectToTarget.copy(this.objectToTarget0),this.targetToCamera.copy(this.targetToCamera0);let t,e=nl.setFromAxisAngle(Eu,this.cameraYAxis==="Limit"&&this.orientMode!=="radial"?qt.clamp(this.euler.y-this.euler0.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel):this.euler.y-this.euler0.y);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&this.objectToTarget.applyQuaternion(e),t=this.cameraXAxis==="Limit"?qt.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):qt.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset+1e-6,this.PI_2+this.cameraPolarOffset-1e-6);let i=qa.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&i.applyQuaternion(e);let r=Hf.setFromAxisAngle(i,t);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(e),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(r)}groundTiltAdjustment(t){180*Eu.angleTo(t)/Math.PI<15||180*Eu.angleTo(t)/Math.PI>85?nl.identity():nl.setFromUnitVectors(Eu,t),this.groundTilt.slerp(nl,.06),this.groundTiltInv.copy(this.groundTilt).invert()}collisionAdjustment(t){let e=Iut.set(0,0,0);this.object.matrix.compose(this.position,this.quaternion,this.scale);let i=wF.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(qa,nl,Ld).compose(qa,nl,Vut);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(s=>{if(s===this.object||s.isDescendantOf(this.object)||!s.bvhGeometry||!s.bvhGeometry.boundsTree)return;ql.makeEmpty(),s.updateMatrixWorldRigid();let n=s.matrixWorldRigid,a=But.copy(n).invert(),o=BPt.copy(But).multiply(i);Hn.copy(this.collider.segment),Hn.start.applyMatrix4(o),Hn.end.applyMatrix4(o);let l=Out.copy(this.position).applyMatrix4(a);ql.expandByPoint(Hn.start),ql.expandByPoint(Hn.end),ql.min.addScalar(-this.collider.radius),ql.max.addScalar(this.collider.radius),s.bvhGeometry.boundsTree.shapecast({boundsTraverseOrder:u=>u.distanceToPoint(Hn.end),intersectsBounds:u=>u.intersectsBox(ql),intersectsTriangle:u=>{let h=qa,d=Ld,c=u.closestPointToSegment(Hn,h,d);if(c<this.collider.radius){let p=this.collider.radius-c,m=d.sub(h).normalize(),f=Zy.copy(l);f.addScaledVector(m,p);let g=f.applyMatrix4(n).sub(this.position);e.add(g),Hn.start.addScaledVector(m,p),Hn.end.addScaledVector(m,p)}}})}),ql.makeEmpty(),Hn.copy(this.collider.segment),Hn.start.applyMatrix4(i),Hn.end.applyMatrix4(i),ql.expandByPoint(Hn.start),ql.expandByPoint(Hn.end),ql.min.addScalar(-this.collider.radius),ql.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({boundsTraverseOrder:s=>s.distanceToPoint(Hn.end),intersectsBounds:s=>s.intersectsBox(ql),intersectsTriangle:s=>{let n=qa,a=Ld,o=s.closestPointToSegment(Hn,n,a);if(o<this.collider.radius){let l=this.collider.radius-o,u=a.sub(n).normalize();this.alignToGround&&this.groundTiltAdjustment(u),e.addScaledVector(u,l),Hn.start.addScaledVector(u,l),Hn.end.addScaledVector(u,l)}}}),this.onObject=Math.abs(e.y)>Math.abs(t*this.velocity.y*.25),this.onObject&&this.dispatchStopEvent("jump");let r=Math.max(0,e.length()-1e-5);e.normalize().multiplyScalar(r),this.position.add(e)}pause(){this.firstPointerId=-1,this.movementState={moveNegZ:0,movePosZ:0,moveNegX:0,movePosX:0,moveNegY:0,movePosY:0,rotPosX:0,rotNegX:0,rotPosY:0,rotNegY:0,jump:0,run:0},this.deactivate()}resume(){this.activate()}},r_t=u7;r_t.isLocked=!1,dt(),KS(),Y5(),Jv(),Zv();var s_t,n_t,TF,WPt=new Promise(t=>{s_t=t});function qPt(t){return TF||(TF=async function(){let e=t??"https://cdn.spline.design/@splinetool/runtime@2.0.60/build";typeof window<"u"&&(n_t=new URL(e.endsWith("/")?e:`${e}/`,window.location.href).href);let i=import("./navmesh.js"),[r,s]=await Promise.all([i,fetch(`${e}/navmesh.wasm`).then(o=>o.arrayBuffer())]),n=r.default,a=await n({wasmBinary:s});s_t(a)}(),TF)}ir();var a_t,Ni,_a,HPt=t=>`
|
|
5092
|
+
`)>=0&&(t-=s),i===3?.5*e-.5*t:i===2?e-t:0}getLineInitialOffsetY(t,e,i,r,s){let n=e*t,a=t-Math.abs(this.ascender-this.descender)*r,o=-this.ascender*r-a/2;return s===3?-(i-n-o):s===2?-(.5*i-.5*n-o):o}createPath(t,e,i,r,s){let n=t.getPath(i,-r,s.fontSize,{kerning:!1,letterSpacing:s.letterSpacing});if(!n)return void console.error('THREE.Font: character "'+t+'" does not exists in font family '+this.familyName+".");let a=new bPt,o=(t.advanceWidth??1)*e;if(t)for(let l of n.commands){let u=a.currentPath?.currentPoint;if(!u||l.type==="Z"||u.x!==l.x||-u.y!==l.y)switch(l.type){case"M":a.moveTo(l.x,-l.y);break;case"L":a.lineTo(l.x,-l.y);break;case"Q":a.quadraticCurveTo(l.x1,-l.y1,l.x,-l.y);break;case"C":a.bezierCurveTo(l.x1,-l.y1,l.x2,-l.y2,l.x,-l.y)}}return a.subPaths.forEach(l=>{let u=function(h){if(h.length){let d=h[0];if(d instanceof cl)return d.v1;if(d instanceof Kl||d instanceof oc)return d.v0}}(l.curves);u!==void 0&&l.currentPoint.distanceTo(u)>0&&l.lineTo(u.x,u.y)}),{offsetX:o,path:a}}getCharWidth(t,e){try{return this.font?.getAdvanceWidth(t,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}catch(i){return this.warnLayoutError(i),0}}getTextWidth(t,e){try{return this.font?.getAdvanceWidth(t,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}catch(i){return this.warnLayoutError(i),0}}computeSpaceWidthForLine(t,e,i,r){let s=this.getCharWidth(" ",i),n=t[e];if(n){let a=this.countSpaces(n.trimEnd());if(i.horizontalAlign===4&&e<t.length-1&&a)return((typeof i.width=="string"?Number(r.getVariable(i.width)):i.width)-(this.getTextWidth(n,i)-a*s))/a}return s}countSpaces(t){return(t.match(/ /g)||[]).length}},Or("text"),ke();var Xbt=null;function Mut(){return Xbt}function wPt(t){let e=!1;return t.scene.objects.forEach(i=>{i.data.type==="Page"&&!e&&i.data.publish.gameControlObject&&Qg.traverseModuleInstances(t,i.id,(r,s,n)=>{for(let a of n)a.data.type==="GameControl"&&a.data.navmesh.enabled&&(e=!0)})}),e}ir();var RE=(t,e)=>{let i=e.x-t.x,r=e.y-t.y;return Math.sqrt(i*i+r*r)},dF=t=>t*(Math.PI/180),DE=new Map,p5=(t,e,i)=>{let r,s=e.split(/[ ,]+/g);for(let n=0;n<s.length;n+=1)r=s[n],t.addEventListener?t.addEventListener(r,i,!1):t.attachEvent&&t.attachEvent(r,i)},m5=(t,e,i)=>{let r,s=e.split(/[ ,]+/g);for(let n=0;n<s.length;n+=1)r=s[n],t.removeEventListener?t.removeEventListener(r,i):t.detachEvent&&t.detachEvent(r,i)},Ybt=t=>(t.preventDefault(),t.type.match(/^touch/)?t.changedTouches:t),Aut=()=>{if(!(typeof window>"u"))return{x:window.pageXOffset!==void 0?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft,y:window.pageYOffset!==void 0?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop}},cF=(t,e)=>{e.top||e.right||e.bottom||e.left?(t.style.top=e.top,t.style.right=e.right,t.style.bottom=e.bottom,t.style.left=e.left):(t.style.left=e.x+"px",t.style.top=e.y+"px")},pF=(t,e,i)=>{let r=Kbt(t);for(let s in r)if(Object.prototype.hasOwnProperty.call(r,s))if(typeof e=="string")r[s]=e+" "+i;else{let n="";for(let a=0,o=e.length;a<o;a+=1)n+=e[a]+" "+i+", ";r[s]=n.slice(0,-2)}return r},Kbt=t=>{let e={};return e[t]="",["webkit","Moz","o"].forEach(function(i){e[i+t.charAt(0).toUpperCase()+t.slice(1)]=""}),e},mF=(t,e)=>{for(let i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},l7=(t,e)=>{if(t.length)for(let i=0,r=t.length;i<r;i+=1)e(t[i]);else e(t)};typeof window<"u"&&(Zbt="ontouchstart"in window,Qbt=!!window.PointerEvent,Jbt=!!window.MSPointerEvent);var Zbt,Qbt,Jbt,Xy,Cut={start:"mousedown",move:"mousemove",end:"mouseup"},mw={};function hg(){}Qbt?Xy={start:"pointerdown",move:"pointermove",end:"pointerup, pointercancel"}:Jbt?Xy={start:"MSPointerDown",move:"MSPointerMove",end:"MSPointerUp"}:Zbt?(Xy={start:"touchstart",move:"touchmove",end:"touchend, touchcancel"},mw=Cut):Xy=Cut,hg.prototype.on=function(t,e){var i,r=this,s=t.split(/[ ,]+/g);r._handlers_=r._handlers_||{};for(var n=0;n<s.length;n+=1)i=s[n],r._handlers_[i]=r._handlers_[i]||[],r._handlers_[i].push(e);return r},hg.prototype.off=function(t,e){var i=this;return i._handlers_=i._handlers_||{},t===void 0?i._handlers_={}:e===void 0?i._handlers_[t]=null:i._handlers_[t]&&i._handlers_[t].indexOf(e)>=0&&i._handlers_[t].splice(i._handlers_[t].indexOf(e),1),i},hg.prototype.trigger=function(t,e){var i,r=this,s=t.split(/[ ,]+/g);r._handlers_=r._handlers_||{};for(var n=0;n<s.length;n+=1)i=s[n],r._handlers_[i]&&r._handlers_[i].length&&r._handlers_[i].forEach(function(a){a.call(r,{type:i,target:r},e)})},hg.prototype.config=function(t){var e=this;e.options=e.defaults||{},t&&(e.options=((i,r)=>{let s={};for(let n in i)Object.prototype.hasOwnProperty.call(i,n)&&Object.prototype.hasOwnProperty.call(r,n)?s[n]=r[n]:Object.prototype.hasOwnProperty.call(i,n)&&(s[n]=i[n]);return s})(e.options,t))},hg.prototype.bindEvt=function(t,e){var i=this;return i._domHandlers_=i._domHandlers_||{},i._domHandlers_[e]=function(){typeof i["on"+e]=="function"?i["on"+e].apply(i,arguments):console.warn('[WARNING] : Missing "on'+e+'" handler.')},p5(t,Xy[e],i._domHandlers_[e]),mw[e]&&p5(t,mw[e],i._domHandlers_[e]),i},hg.prototype.unbindEvt=function(t,e){var i=this;return i._domHandlers_=i._domHandlers_||{},m5(t,Xy[e],i._domHandlers_[e]),mw[e]&&m5(t,mw[e],i._domHandlers_[e]),delete i._domHandlers_[e],this};var UW=hg;function Sn(t,e){return this.identifier=e.identifier,this.position=e.position,this.frontPosition=e.frontPosition,this.collection=t,this.defaults={size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:1,mode:"dynamic",zone:document.body,lockX:!1,lockY:!1,shape:"circle"},this.config(e),this.options.mode==="dynamic"&&(this.options.restOpacity=0),this.id=Sn.id,Sn.id+=1,this.buildEl().stylize(),this.instance={el:this.ui.el,on:this.on.bind(this),off:this.off.bind(this),show:this.show.bind(this),hide:this.hide.bind(this),add:this.addToDom.bind(this),remove:this.removeFromDom.bind(this),destroy:this.destroy.bind(this),setPosition:this.setPosition.bind(this),resetDirection:this.resetDirection.bind(this),computeDirection:this.computeDirection.bind(this),trigger:this.trigger.bind(this),position:this.position,frontPosition:this.frontPosition,ui:this.ui,identifier:this.identifier,id:this.id,options:this.options},this.instance}Sn.prototype=new UW,Sn.constructor=Sn,Sn.id=0,Sn.prototype.buildEl=function(t){return this.ui={},this.options.dataOnly||(this.ui.el=document.createElement("div"),this.ui.back=document.createElement("div"),this.ui.front=document.createElement("div"),this.ui.el.className="nipple collection_"+this.collection.id,this.ui.back.className="back",this.ui.front.className="front",this.ui.el.setAttribute("id","nipple_"+this.collection.id+"_"+this.id),this.ui.el.appendChild(this.ui.back),this.ui.el.appendChild(this.ui.front)),this},Sn.prototype.stylize=function(){if(this.options.dataOnly)return this;var t=this.options.fadeTime+"ms",e=(()=>{let s=Kbt("borderRadius");for(let n in s)Object.prototype.hasOwnProperty.call(s,n)&&(s[n]="50%");return s})(),i=pF("transition","opacity",t),r={};return r.el={position:"absolute",opacity:this.options.restOpacity,display:"block",zIndex:999},r.back={position:"absolute",display:"block",width:this.options.size+"px",height:this.options.size+"px",marginLeft:-this.options.size/2+"px",marginTop:-this.options.size/2+"px",background:"rgba(255, 255, 255, .4)",border:"solid 2px rgba(0, 0, 0, .1)"},r.front={width:this.options.size/2+"px",height:this.options.size/2+"px",position:"absolute",display:"block",marginLeft:-this.options.size/4+"px",marginTop:-this.options.size/4+"px",background:"rgba(255, 255, 255, .8)",border:"solid 2px rgba(0, 0, 0, .1)"},mF(r.el,i),this.options.shape==="circle"&&mF(r.back,e),mF(r.front,e),this.applyStyles(r),this},Sn.prototype.applyStyles=function(t){for(var e in this.ui)if(Object.prototype.hasOwnProperty.call(this.ui,e))for(var i in t[e])this.ui[e].style[i]=t[e][i];return this},Sn.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)||this.options.zone.appendChild(this.ui.el),this},Sn.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)||this.options.zone.removeChild(this.ui.el),this},Sn.prototype.destroy=function(){clearTimeout(this.removeTimeout),clearTimeout(this.showTimeout),clearTimeout(this.restTimeout),this.trigger("destroyed",this.instance),this.removeFromDom(),this.off(),this.ui=null,this.instance=null,this.collection=null,this.options=null},Sn.prototype.show=function(t){var e=this;return e.options.dataOnly||(clearTimeout(e.removeTimeout),clearTimeout(e.showTimeout),clearTimeout(e.restTimeout),e.addToDom(),e.restCallback(),setTimeout(function(){e.ui.el.style.opacity=1},0),e.showTimeout=setTimeout(function(){e.trigger("shown",e.instance),typeof t=="function"&&t.call(this)},e.options.fadeTime)),e},Sn.prototype.hide=function(t){var e=this;if(e.options.dataOnly)return e;if(e.ui.el.style.opacity=e.options.restOpacity,clearTimeout(e.removeTimeout),clearTimeout(e.showTimeout),clearTimeout(e.restTimeout),e.removeTimeout=setTimeout(function(){var i=e.options.mode==="dynamic"?"none":"block";e.ui.el.style.display=i,typeof t=="function"&&t.call(e),e.trigger("hidden",e.instance)},e.options.fadeTime),e.options.restJoystick){let i=e.options.restJoystick,r={};r.x=i===!0||i.x!==!1?0:e.instance.frontPosition.x,r.y=i===!0||i.y!==!1?0:e.instance.frontPosition.y,e.setPosition(t,r)}return e},Sn.prototype.setPosition=function(t,e){var i=this;i.frontPosition={x:e.x,y:e.y};var r=i.options.fadeTime+"ms",s={};s.front=pF("transition",["top","left"],r);var n={front:{}};n.front={left:i.frontPosition.x+"px",top:i.frontPosition.y+"px"},i.applyStyles(s),i.applyStyles(n),i.restTimeout=setTimeout(function(){typeof t=="function"&&t.call(i),i.restCallback()},i.options.fadeTime)},Sn.prototype.restCallback=function(){var t=this,e={};e.front=pF("transition","none",""),t.applyStyles(e),t.trigger("rested",t.instance)},Sn.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}},Sn.prototype.computeDirection=function(t){var e,i,r,s=t.angle.radian,n=Math.PI/4,a=Math.PI/2;if(s>n&&s<3*n&&!t.lockX?e="up":s>-n&&s<=n&&!t.lockY?e="left":s>3*-n&&s<=-n&&!t.lockX?e="down":t.lockY||(e="right"),t.lockY||(i=s>-a&&s<a?"left":"right"),t.lockX||(r=s>0?"up":"down"),t.force>this.options.threshold){var o,l={};for(o in this.direction)Object.prototype.hasOwnProperty.call(this.direction,o)&&(l[o]=this.direction[o]);var u={};for(o in this.direction={x:i,y:r,angle:e},t.direction=this.direction,l)l[o]===this.direction[o]&&(u[o]=!0);if(u.x&&u.y&&u.angle)return t;(!u.x||!u.y)&&this.trigger("plain",t),u.x||this.trigger("plain:"+i,t),u.y||this.trigger("plain:"+r,t),u.angle||this.trigger("dir dir:"+e,t)}else this.resetDirection();return t};var SPt=Sn;function js(t,e){var i=this;i.nipples=[],i.idles=[],i.actives=[],i.ids=[],i.pressureIntervals={},i.manager=t,i.id=js.id,js.id+=1,i.defaults={zone:document.body,multitouch:!1,maxNumberOfNipples:10,mode:"dynamic",position:{top:0,left:0},catchDistance:200,size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:1,lockX:!1,lockY:!1,shape:"circle",dynamicPage:!1,follow:!1},i.config(e),(i.options.mode==="static"||i.options.mode==="semi")&&(i.options.multitouch=!1),i.options.multitouch||(i.options.maxNumberOfNipples=1);let r=getComputedStyle(i.options.zone.parentElement);return r&&r.display==="flex"&&(i.parentIsFlex=!0),i.updateBox(),i.prepareNipples(),i.bindings(),i.begin(),i.nipples}js.prototype=new UW,js.constructor=js,js.id=0,js.prototype.prepareNipples=function(){var t=this,e=t.nipples;e.on=t.on.bind(t),e.off=t.off.bind(t),e.options=t.options,e.destroy=t.destroy.bind(t),e.ids=t.ids,e.id=t.id,e.processOnMove=t.processOnMove.bind(t),e.processOnEnd=t.processOnEnd.bind(t),e.get=function(i){if(i===void 0)return e[0];for(var r=0,s=e.length;r<s;r+=1)if(e[r].identifier===i)return e[r];return!1}},js.prototype.bindings=function(){var t=this;t.bindEvt(t.options.zone,"start"),t.options.zone.style.touchAction="none",t.options.zone.style.msTouchAction="none"},js.prototype.begin=function(){var t=this,e=t.options;if(e.mode==="static"){var i=t.createNipple(e.position,t.manager.getIdentifier());i.add(),t.idles.push(i)}},js.prototype.createNipple=function(t,e){var i=this,r=i.manager.scroll,s={},n=i.options,a=i.parentIsFlex?r.x:r.x+i.box.left,o=i.parentIsFlex?r.y:r.y+i.box.top;if(t.x&&t.y)s={x:t.x-a,y:t.y-o};else if(t.top||t.right||t.bottom||t.left){var l=document.createElement("DIV");l.style.display="hidden",l.style.top=t.top,l.style.right=t.right,l.style.bottom=t.bottom,l.style.left=t.left,l.style.position="absolute",n.zone.appendChild(l);var u=l.getBoundingClientRect();n.zone.removeChild(l),s=t,t={x:u.left+r.x,y:u.top+r.y}}var h=new SPt(i,{color:n.color,size:n.size,threshold:n.threshold,fadeTime:n.fadeTime,dataOnly:n.dataOnly,restJoystick:n.restJoystick,restOpacity:n.restOpacity,mode:n.mode,identifier:e,position:t,zone:n.zone,frontPosition:{x:0,y:0},shape:n.shape});return n.dataOnly||(cF(h.ui.el,s),cF(h.ui.front,h.frontPosition)),i.nipples.push(h),i.trigger("added "+h.identifier+":added",h),i.manager.trigger("added "+h.identifier+":added",h),i.bindNipple(h),h},js.prototype.updateBox=function(){this.box=this.options.zone.getBoundingClientRect()},js.prototype.bindNipple=function(t){var e,i=this,r=function(s,n){e=s.type+" "+n.id+":"+s.type,i.trigger(e,n)};t.on("destroyed",i.onDestroyed.bind(i)),t.on("shown hidden rested dir plain",r),t.on("dir:up dir:right dir:down dir:left",r),t.on("plain:up plain:right plain:down plain:left",r)},js.prototype.pressureFn=function(t,e,i){var r=this,s=0;clearInterval(r.pressureIntervals[i]),r.pressureIntervals[i]=setInterval(function(){var n=t.force||t.pressure||t.webkitForce||0;n!==s&&(e.trigger("pressure",n),r.trigger("pressure "+e.identifier+":pressure",n),s=n)}.bind(r),100)},js.prototype.onstart=function(t){var e=this,i=e.options,r=t;return t=Ybt(t),e.updateBox(),l7(t,function(s){e.actives.length<i.maxNumberOfNipples?e.processOnStart(s):r.type.match(/^touch/)&&(Object.keys(e.manager.ids).forEach(function(n){if(Object.values(r.touches).findIndex(function(o){return o.identifier===n})<0){var a=[t[0]];a.identifier=n,e.processOnEnd(a)}}),e.actives.length<i.maxNumberOfNipples&&e.processOnStart(s))}),e.manager.bindDocument(),!1},js.prototype.processOnStart=function(t){var e,i=this,r=i.options,s=i.manager.getIdentifier(t),n=t.force||t.pressure||t.webkitForce||0,a={x:t.pageX,y:t.pageY},o=i.getOrCreate(s,a);o.identifier!==s&&i.manager.removeIdentifier(o.identifier),o.identifier=s;var l=function(u){u.trigger("start",u),i.trigger("start "+u.id+":start",u),u.show(),n>0&&i.pressureFn(t,u,u.identifier),i.processOnMove(t)};if((e=i.idles.indexOf(o))>=0&&i.idles.splice(e,1),i.actives.push(o),i.ids.push(o.identifier),r.mode!=="semi")l(o);else{if(!(RE(a,o.position)<=r.catchDistance))return o.destroy(),void i.processOnStart(t);l(o)}return o},js.prototype.getOrCreate=function(t,e){var i,r=this,s=r.options;return/(semi|static)/.test(s.mode)?(i=r.idles[0])?(r.idles.splice(0,1),i):s.mode==="semi"?r.createNipple(e,t):(console.warn("Coudln't find the needed nipple."),!1):i=r.createNipple(e,t)},js.prototype.processOnMove=function(t){var e=this,i=e.options,r=e.manager.getIdentifier(t),s=e.nipples.get(r),n=e.manager.scroll;if((b=>isNaN(b.buttons)?b.pressure!==0:b.buttons!==0)(t)){if(!s)return console.error("Found zombie joystick with ID "+r),void e.manager.removeIdentifier(r);if(i.dynamicPage){var a=s.el.getBoundingClientRect();s.position={x:n.x+a.left,y:n.y+a.top}}s.identifier=r;var o=s.options.size/2,l={x:t.pageX,y:t.pageY};i.lockX&&(l.y=s.position.y),i.lockY&&(l.x=s.position.x);var u,h,d=RE(l,s.position),c=((b,_)=>{let x=_.x-b.x,S=_.y-b.y;return(w=>w*(180/Math.PI))(Math.atan2(S,x))})(l,s.position),p=dF(c),m=d/o,f={distance:d,position:l};if(s.options.shape==="circle"?(u=Math.min(d,o),h=((b,_,x)=>{let S={x:0,y:0};return x=dF(x),S.x=b.x-_*Math.cos(x),S.y=b.y-_*Math.sin(x),S})(s.position,u,c)):(h=((b,_,x)=>({x:Math.min(Math.max(b.x,_.x-x),_.x+x),y:Math.min(Math.max(b.y,_.y-x),_.y+x)}))(l,s.position,o),u=RE(h,s.position)),i.follow){if(d>o){let b=l.x-h.x,_=l.y-h.y;s.position.x+=b,s.position.y+=_,s.el.style.top=s.position.y-(e.box.top+n.y)+"px",s.el.style.left=s.position.x-(e.box.left+n.x)+"px",d=RE(l,s.position)}}else l=h,d=u;var g=l.x-s.position.x,y=l.y-s.position.y;s.frontPosition={x:g,y},i.dataOnly||cF(s.ui.front,s.frontPosition);var v={identifier:s.identifier,position:l,force:m,pressure:t.force||t.pressure||t.webkitForce||0,distance:d,angle:{radian:p,degree:c},vector:{x:g/o,y:-y/o},raw:f,instance:s,lockX:i.lockX,lockY:i.lockY};(v=s.computeDirection(v)).angle={radian:dF(180-c),degree:180-c},s.trigger("move",v),e.trigger("move "+s.id+":move",v)}else this.processOnEnd(t)},js.prototype.processOnEnd=function(t){var e=this,i=e.options,r=e.manager.getIdentifier(t),s=e.nipples.get(r),n=e.manager.removeIdentifier(s.identifier);!s||(i.dataOnly||s.hide(function(){i.mode==="dynamic"&&(s.trigger("removed",s),e.trigger("removed "+s.id+":removed",s),e.manager.trigger("removed "+s.id+":removed",s),s.destroy())}),clearInterval(e.pressureIntervals[s.identifier]),s.resetDirection(),s.trigger("end",s),e.trigger("end "+s.id+":end",s),e.ids.indexOf(s.identifier)>=0&&e.ids.splice(e.ids.indexOf(s.identifier),1),e.actives.indexOf(s)>=0&&e.actives.splice(e.actives.indexOf(s),1),/(semi|static)/.test(i.mode)?e.idles.push(s):e.nipples.indexOf(s)>=0&&e.nipples.splice(e.nipples.indexOf(s),1),e.manager.unbindDocument(),/(semi|static)/.test(i.mode)&&(e.manager.ids[n.id]=n.identifier))},js.prototype.onDestroyed=function(t,e){var i=this;i.nipples.indexOf(e)>=0&&i.nipples.splice(i.nipples.indexOf(e),1),i.actives.indexOf(e)>=0&&i.actives.splice(i.actives.indexOf(e),1),i.idles.indexOf(e)>=0&&i.idles.splice(i.idles.indexOf(e),1),i.ids.indexOf(e.identifier)>=0&&i.ids.splice(i.ids.indexOf(e.identifier),1),i.manager.removeIdentifier(e.identifier),i.manager.unbindDocument()},js.prototype.destroy=function(){var t=this;for(var e in t.unbindEvt(t.options.zone,"start"),t.nipples.forEach(function(i){i.destroy()}),t.pressureIntervals)Object.prototype.hasOwnProperty.call(t.pressureIntervals,e)&&clearInterval(t.pressureIntervals[e]);t.trigger("destroyed",t.nipples),t.manager.unbindDocument(),t.off(),t.pressureIntervals={},t.nipples=[],t.idles=[],t.actives=[],t.ids=[],t.manager=null};var TPt=js;function rn(t){var e=this;e.ids={},e.index=0,e.collections=[],e.scroll=Aut(),e._windowBound=!1,e.config(t),e.prepareCollections();var i=function(){var r;e.collections.forEach(function(s){s.forEach(function(n){r=n.el.getBoundingClientRect(),n.position={x:e.scroll.x+r.left,y:e.scroll.y+r.top}})})};return e._onResize=function(){(r=>{DE.has(r)&&clearTimeout(DE.get(r)),DE.set(r,setTimeout(function(){DE.delete(r),r()},100))})(i)},e._onScroll=function(){e.scroll=Aut()},e.collections}rn.prototype=new UW,rn.constructor=rn,rn.prototype.prepareCollections=function(){var t=this;t.collections.create=t.create.bind(t),t.collections.on=t.on.bind(t),t.collections.off=t.off.bind(t),t.collections.destroy=t.destroy.bind(t),t.collections.get=function(e){var i;return t.collections.every(function(r){return!(i=r.get(e))}),i}},rn.prototype.create=function(t){return this.createCollection(t)},rn.prototype.bindWindowEvents=function(){var t=this;t._windowBound||typeof window>"u"||(t._windowBound=!0,p5(window,"resize",t._onResize),p5(window,"scroll",t._onScroll))},rn.prototype.unbindWindowEvents=function(){var t=this;!t._windowBound||typeof window>"u"||(t._windowBound=!1,m5(window,"resize",t._onResize),m5(window,"scroll",t._onScroll))},rn.prototype.createCollection=function(t){var e=this,i=new TPt(e,t);return e.bindCollection(i),e.collections.push(i),e.bindWindowEvents(),i},rn.prototype.bindCollection=function(t){var e,i=this,r=function(s,n){e=s.type+" "+n.id+":"+s.type,i.trigger(e,n)};t.on("destroyed",i.onDestroyed.bind(i)),t.on("shown hidden rested dir plain",r),t.on("dir:up dir:right dir:down dir:left",r),t.on("plain:up plain:right plain:down plain:left",r)},rn.prototype.bindDocument=function(){var t=this;t.binded||(t.bindEvt(document,"move").bindEvt(document,"end"),t.binded=!0)},rn.prototype.unbindDocument=function(t){var e=this;(!Object.keys(e.ids).length||t===!0)&&(e.unbindEvt(document,"move").unbindEvt(document,"end"),e.binded=!1)},rn.prototype.getIdentifier=function(t){var e;return t?(e=t.identifier===void 0?t.pointerId:t.identifier)===void 0&&(e=this.latest||0):e=this.index,this.ids[e]===void 0&&(this.ids[e]=this.index,this.index+=1),this.latest=e,this.ids[e]},rn.prototype.removeIdentifier=function(t){var e={};for(var i in this.ids)if(this.ids[i]===t){e.id=i,e.identifier=this.ids[i],delete this.ids[i];break}return e},rn.prototype.onmove=function(t){return this.onAny("move",t),!1},rn.prototype.onend=function(t){return this.onAny("end",t),!1},rn.prototype.oncancel=function(t){return this.onAny("end",t),!1},rn.prototype.onAny=function(t,e){var i,r=this,s="processOn"+t.charAt(0).toUpperCase()+t.slice(1);e=Ybt(e);var n=function(a,o,l){l.ids.indexOf(o)>=0&&(l[s](a),a._found_=!0)};return l7(e,function(a){i=r.getIdentifier(a),l7(r.collections,n.bind(null,a,i)),a._found_||r.removeIdentifier(i)}),!1},rn.prototype.destroy=function(){var t=this;t.unbindDocument(!0),t.unbindWindowEvents(),t.ids={},t.index=0,t.collections.forEach(function(e){e.destroy()}),t.collections=[],t.off()},rn.prototype.onDestroyed=function(t,e){var i=this;if(i.collections.indexOf(e)<0)return!1;i.collections.splice(i.collections.indexOf(e),1),i.collections.length===0&&i.unbindWindowEvents()};var MPt=rn,Cv=null;function Eut(){return Cv||(Cv=new MPt),Cv}var APt={create:function(t){return Eut().create(t)},destroy:function(){Cv&&(Cv.destroy(),Cv=null)},get factory(){return Eut()}},CPt=APt;ir(),ke(),dt(),Qh(),vo(),ke();var t_t=null;function fF(){return t_t}var e_t,gF,EPt=new Promise(t=>{e_t=t});function PPt(t){return gF||(gF=async function(){let e=t??"https://cdn.spline.design/@splinetool/runtime@2.0.61/build",i=import("./physics.js"),[r,s]=await Promise.all([i,fetch(`${e}/physics.wasm`).then(n=>n.arrayBuffer())]);await r.init(s),e_t(r)}(),gF)}function i_t(t){let e=t.elements,i=e[0]**2+e[1]**2+e[2]**2,r=e[4]**2+e[5]**2+e[6]**2,s=e[8]**2+e[9]**2+e[10]**2,n=e[0]**2+e[4]**2+e[8]**2,a=e[1]**2+e[5]**2+e[9]**2,o=e[2]**2+e[6]**2+e[10]**2,l=1e-8;return i<l||r<l||s<l||n<l||a<l||o<l}function ac(t,e){let i=new ye;if(e&&i_t(e))return i.setAttribute("position",new fe([],3)),i.setIndex([]),i;if(!t.getAttribute("position"))return i.setAttribute("position",new fe([],3)),i.setIndex([]),i;let{positions:r,triIndices:s}=OG(t.getAttribute("position"),t.getIndex());return i.setAttribute("position",new fe(r,3)),i.setIndex(s),e&&i.applyMatrix4(e),i}ns(),vo(),Ii(),XG(),dt(),dt(),Zv(),KS();var ki,RPt=class{constructor(t,e,i,r,s,n){this.id=t,this.data=e,this.object=i,this.initialDisabled=!1,this.actions=un(e,e.actions,r,s,n,i),this.target=e.target}disconnect(){na(this.actions)}dispatch(t){this.initialDisabled||(this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.object.dispatchEvent({type:"beginEvent",eventName:"Collision"}),this.actions.Transition.forEach(e=>e.play()),this.actions.Animation.forEach(e=>{"runMode"in e.data&&e.data.runMode==="Toggle"?e.toggle():e.play()}),this.actions.TimelineAnimation.forEach(e=>{"runMode"in e.data&&e.data.runMode==="Toggle"?e.toggle():e.play()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch(t??!1)}),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Particles.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()}),this.actions.ClearLocalStorage.forEach(e=>e.dispatch()),this.actions.UserAPI.forEach(e=>e.dispatch()))}},Put=class{constructor(t,e,i,r,s,n){this.id=t,this.data=e,this.object=i,this.page=r,this.currentIntersectedObjects=[],this.actions=un(e,e.actions,r,s,n,i),this.target=e.target,this.triggeringObjects=[];for(let a of e.triggeringObjects){let o=r.scene.find(a);o&&this.triggeringObjects.push(o)}}isValidTriggeringObject(t){return this.target==="all"||this.triggeringObjects.some(e=>e===t||e.isAncestorOf(t.uuid)||t.isAncestorOf(e.uuid))}disconnect(){na(this.actions)}dispatch(){this.object.destroyedInAction||(this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.object.dispatchEvent({type:"beginEvent",eventName:"Trigger"}),this.actions.Transition.forEach(t=>t.play()),this.actions.SwitchCamera.forEach(t=>{t.data.runMode==="Toggle"?t.toggle():t.play()}),this.actions.TimelineAnimation.forEach(t=>{"runMode"in t.data&&t.data.runMode==="Toggle"?t.toggle():t.play()}),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch(!1)}),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Particles.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()}),this.actions.SceneTransition.forEach(t=>{t.dispatch()}),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch()))}};ns(),EPt.then(t=>ki=t);var en=new P,Wl=new Me,Tp=new P,Rut=(new Qi(0,0,0,"YXZ"),new Qi(0,0,0,"XYZ")),Ph=new P,yF=new P,vF=new P(1,1,1),Yy=new Me,NE=new bt,Dut=new bt,DPt={type:"updateMatrix"},Nut=new Me,bF=new ta,_F=.01,h7={type:"beginEvent",eventName:"Collision"},NPt={type:"beginEvent",eventName:"Trigger"},f5=t=>t.states.some(e=>e.data.position!==void 0||e.data.rotation!==void 0||e.data.hiddenMatrix!==void 0||e.data.cloner!==void 0||e.data.pathSnapping!==void 0);function Ky(t){return function(e){return typeof e=="object"&&e!==null&&"booleanOp"in e}(Sg(t)?t.object:t)}var OPt=class{constructor(t){this.eventContext=t,this.isEnabled=!1,this.gameControl=null,this.joysticks=[],this.joystickToGameControls=[],this.sharedGameControlGlobals={entitiesWithTransformAnim:[],entityToCollisionEvents:{},colliderToEntity:new Map,kinematicBodyToEntity:new Map,triggers:[],gamePads:[],createdObjects:[],nCreatedPerAction:{}},this.sensorToTriggerEvent={},this.eventManager=void 0,this.needsCollisionDetection=!1,this.initializationCounter=-1,this.fixedBodiesToWatch=[],this.rigidBodyToMesh=new Map,this.nActiveRigidBodies=0,this.collisionEvents=[],this.isExport=!1,this.skipRender=!0,this._staticBVHAttrIds=new WeakMap,this._staticBVHNextAttrId=1,this.processRigidBody=e=>{if(e.bodyType()!==ki.RigidBodyType.Dynamic)return;e.isSleeping()||this.nActiveRigidBodies++;let[i,r,s]=this.rigidBodyToMesh.get(e.handle);if(en.copy(e.translation()).multiplyScalar(this.pixelsPerMeter),Wl.copy(e.rotation()),i.matrixWorld.compose(en,Wl,r),i.hasNonUniformScale&&i.matrixWorld.multiply(i.shearScale),i.dispatchEvent(DPt),s){let n=i.cloner;if(n&&n.objectForSample===void 0){n.matrixWorld.copy(i.matrixWorld);for(let a of n.children)a.updateMatrixWorld(!0)}for(let a of i.children)a.updateMatrixWorld(!0)}},this.accumulator=0,this.handleCollisionEvents=(e,i,r)=>{if(r===!1)return;let s,n;if(this.sensorToTriggerEvent[e]?(s=this.sensorToTriggerEvent[e],n=this.sharedGameControlGlobals.colliderToEntity.get(i)):this.sensorToTriggerEvent[i]&&(s=this.sensorToTriggerEvent[i],n=this.sharedGameControlGlobals.colliderToEntity.get(e)),s&&n&&s.isValidTriggeringObject(n))s.dispatch();else{for(let a=this.sharedGameControlGlobals.createdObjects.length-1;a>=0;a--){let o=this.sharedGameControlGlobals.createdObjects[a];if(o.userData.hasCollisionDestroy&&(o.rigidBody?.collider(0).handle===e||o.rigidBody?.collider(0).handle===i)){this.sharedGameControlGlobals.createdObjects.splice(a,1),o.removeFromParent();let l=o.rigidBody;requestAnimationFrame(()=>{o.rigidBody===l&&(this.sharedGameControlGlobals.rapierWorld?.removeRigidBody(l),o.rigidBody=void 0)});break}}if(this.gameControl?.object!==void 0&&this.gameControl.object===this.sharedGameControlGlobals.colliderToEntity.get(e)){let a=this.sharedGameControlGlobals.colliderToEntity.get(i),o=this.sharedGameControlGlobals.entityToCollisionEvents[a.uuid];if(o===void 0)return;for(let l of o)l.data.target==="character"&&this.dispatchCollisionEvent(l,a,i)}else if(this.gameControl?.object!==void 0&&this.gameControl.object===this.sharedGameControlGlobals.colliderToEntity.get(i)){let a=this.sharedGameControlGlobals.colliderToEntity.get(e),o=this.sharedGameControlGlobals.entityToCollisionEvents[a.uuid];if(o===void 0)return;for(let l of o)l.data.target==="character"&&this.dispatchCollisionEvent(l,a,e)}else{let a=this.sharedGameControlGlobals.colliderToEntity.get(e),o=this.sharedGameControlGlobals.entityToCollisionEvents[a.uuid];if(o!==void 0)for(let h of o)h.data.target==="scene"&&this.dispatchCollisionEvent(h,a,e);let l=this.sharedGameControlGlobals.colliderToEntity.get(i),u=this.sharedGameControlGlobals.entityToCollisionEvents[l?.uuid];if(u!==void 0)for(let h of u)h.data.target==="scene"&&this.dispatchCollisionEvent(h,l,i)}}},this.isExport=t.isExport,this.sharedAssets=t.sharedAssets,this.renderer=t.renderer,this.requestRender=t.requestRender,this.domElement=this.renderer.domElement,this.pixelsPerMeter=200,this.gravity=this.page.data.globalPhysics.gravity}get page(){return this.eventContext.page}markIsDestroyTarget(){this.page.traverseVisibleEntity(t=>{let e=t.dataPatched;for(let i of e.events){if(i.data.disabled===!0)continue;let r=i.data.actions?.find(s=>s.data.type==="Destroy")?.data;if(r)for(let s of r.objects){let n=this.page.scene.find(s);n&&(n.userData.hasDestroy=!0)}}})}markIsDragObject(){this.page.traverseVisibleEntity(t=>{let e=t.dataPatched;for(let i of e.events)if(i.data.disabled!==!0&&i.data.type==="DragDrop")for(let r of i.data.objects){let s=this.page.scene.find(r);s&&(s.userData.hasDrag=!0)}})}_staticBVHIdOf(t){let e=this._staticBVHAttrIds.get(t);return e===void 0&&(e=this._staticBVHNextAttrId++,this._staticBVHAttrIds.set(t,e)),e}initBVH(){if(fF()===null)return void Nn("collision-bvh","trigger/collision detection");let t=[],e=[];if(this.page.traverseChildren(i=>{let r,s=i instanceof vv,n=q2(i);if(H1(i)||s||n)return;r=Sg(i)?i.object:i;let a=r.dataPatched;if(a.physics?.enabled==="visibility"?!a.visible:!a.physics?.enabled)return!0;let o=i.geometry,l=r.userData.hasDestroy===!0,u=r.userData.hasDrag===!0;if(f5(a)||l||u||r.dataPatched.events.some(h=>h.data.disabled!==!0&&(h.data.type==="GameControl"||h.data.type==="Follow")))return i.updateMatrixWorldRigid(),this.addBoundsTree(i),!0;if(o){let h=o.getAttribute("position");if(h!==void 0&&h.count>0){t.push({geometry:o,matrixWorld:i.matrixWorld}),e.push(o.id,this._staticBVHIdOf(h),h.version,o.index!==null?this._staticBVHIdOf(o.index):-1,o.index!==null?o.index.version:-1);for(let d of i.matrixWorld.elements)e.push(d)}}return!!Ky(i)||void 0}),t.length>0){let i=this._staticBVHCache;if(i!==void 0&&i.signature.length===e.length&&i.signature.every((n,a)=>n===e[a]))return void(this.sharedGameControlGlobals.staticMeshBVH=i.bvh);let r=wg(t.map(n=>ac(n.geometry,n.matrixWorld)),!1),s=new(fF())(r);this._staticBVHCache={signature:e,bvh:s},this.sharedGameControlGlobals.staticMeshBVH=s}}addRigidBody(t,e,i){if(i_t(t.matrixWorld))return;let r=[],s="geometry"in t?t.geometry:void 0,n=e.dataPatched;if(s?.getAttribute("position")!==void 0&&r.push(ac(s,t.shearScale)),n.physics.fusedBody){let a=this.gatherChildrenGeom(t,r);t.traverseObject(a),t.children.forEach(l=>l.updateMatrixWorld(!0));let o=t.cloner;o&&o.objectForSample===void 0&&n.physics.rigidBody==="dynamic"&&(o.traverseObject(a),o.children.forEach(l=>l.updateMatrixWorld(!0)))}if(r.length>0){let a,o=!1,l=!i.fromCreate&&n.physics.rigidBody==="dynamic"||i.fromCreate&&i.dynamic;l?(a=ki.RigidBodyDesc.dynamic(),a.setLinearDamping(n.physics.damping).setAngularDamping(n.physics.damping).setAdditionalMass(1e-9).setGravityScale(n.physics.gravityScale).enabledRotations(...n.physics.enabledRotation).enabledTranslations(...n.physics.enabledTranslation)):(i.hasTransformAnim||i.hasFollow||i.hasDrag)&&!i.fromCreate?(a=ki.RigidBodyDesc.kinematicPositionBased(),o=!0):a=ki.RigidBodyDesc.fixed();let u=wg(r);(t.hasNonUniformScale?t.matrixWorldRigid:t.matrixWorld).decompose(en,Wl,Tp),t.position0=en.clone().divideScalar(this.pixelsPerMeter),t.rotation0=Wl.clone(),en.divideScalar(this.pixelsPerMeter),a.setTranslation(en.x,en.y,en.z).setRotation(Wl),s?u?.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter):u?.scale(Tp.x/this.pixelsPerMeter,Tp.y/this.pixelsPerMeter,Tp.z/this.pixelsPerMeter);let h=this.sharedGameControlGlobals.rapierWorld.createRigidBody(a),d=!(n.geometry===void 0||n.geometry.type==="SubdivGeometry"||n.geometry.type==="NonParametricGeometry"||n.geometry.type==="BooleanGeometry"||n.geometry.type==="VectorGeometry"||n.geometry.type==="StarGeometry"||n.geometry.type==="RectangleGeometry"||n.geometry.type==="EllipseGeometry"||n.geometry.type==="TriangleGeometry"||n.geometry.type==="TorusGeometry"||n.geometry.type==="HelixGeometry");try{this.addCollider(h,n.physics,u,e,d)}catch{try{this.addCollider(h,n.physics,u,e,!1)}catch(c){console.error(c)}}if(h.numColliders()===0)return void this.sharedGameControlGlobals.rapierWorld.removeRigidBody(h);l?this.rigidBodyToMesh.set(h.handle,[t,Tp.clone(),n.physics.fusedBody]):o?(this.sharedGameControlGlobals.kinematicBodyToEntity.set(h.handle,t),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(t)):this.fixedBodiesToWatch.push([t,h,(t.hasNonUniformScale?t.matrixWorldRigid:t.matrixWorld).clone()]),t.rigidBody=h}}addBoundsTree(t){let e=[];if(t.geometry?.getAttribute("position")!==void 0&&t.geometry?.getAttribute("position").count>0&&e.push(ac(t.geometry,t.shearScale)),t.traverseObject(this.gatherChildrenGeom(t,e)),t.children.forEach(i=>i.updateMatrixWorld(!0)),e.length>0){let i=wg(e,!1);t.bvhGeometry=i,i.getAttribute("position").count>0&&(t.bvhGeometry.boundsTree=new(fF())(i),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(t))}}addCollider(t,e,i,r,s=!0){if(i?.getAttribute("position").count===0||i?.getIndex()?.count===0)return;let n;i&&(n=e.colliderType==="trimesh"?ki.ColliderDesc.trimesh(i.getAttribute("position").array,i.getIndex().array):ki.ColliderDesc.convexMesh(i.getAttribute("position").array,s?i.getIndex().array:void 0)),n.setFrictionCombineRule(ki.CoefficientCombineRule.Average).setRestitutionCombineRule(ki.CoefficientCombineRule.Average).setDensity(e.density).setFriction(e.friction).setRestitution(e.restitution);let a=this.sharedGameControlGlobals.rapierWorld.createCollider(n,t);this.sharedGameControlGlobals.colliderToEntity.set(a.handle,r),this.sharedGameControlGlobals.entityToCollisionEvents[r.uuid]?.some(o=>o.target==="scene")&&a.setActiveEvents(ki.ActiveEvents.COLLISION_EVENTS)}gatherChildrenGeom(t,e){let i=Ky(t);return(r,s)=>{if(s===0)return;if(i&&r.parent===t)return!0;let n;if(H1(r)){if(!r.objectForSample)return r.object.dataPatched.physics.fusedBody===!0&&r.object.dataPatched.physics.rigidBody==="dynamic"||void 0;if(r.objectForSample.dataPatched.physics.fusedBody)return;n=r.object}else if(Sg(r))n=r.object;else if(n=r,n.dataPatched.cloner?.hideBase)return!0;let a=n.dataPatched;if(a.physics.enabled==="visibility"?!a.visible:!a.physics.enabled)return!0;s===1?t.hasNonUniformScale?r.matrixWorld.multiplyMatrices(t.shearScale,r.hiddenMatrix):r.matrixWorld.copy(r.hiddenMatrix):r.matrixWorld.multiplyMatrices(r.parent.matrixWorld,r.hiddenMatrix),r.matrixWorld.multiply(r.matrix);let o=r.geometry;return o?.getAttribute("position")!==void 0&&e.push(ac(o,r.matrixWorld)),!!Ky(r)||void 0}}activate(t){if(this.isEnabled)return;this.isEnabled=!0,this.eventManager=t,this.usePhysics=this.page.data.globalPhysics.usePhysics;let e=this.page.playCamera,i=!1;this.page.traverseEntity(a=>{for(let o of a.dataPatched.events)if(o.data.disabled===!1&&o.data.type==="Trigger")return this.needsCollisionDetection=!0,!0});let r=Mut();if(r!==null?i=r.setup({manager:this,camera:e,renderer:this.renderer,sharedAssets:this.sharedAssets,eventContext:this.eventContext,isExport:this.isExport})||i:this.page.data.publish.gameControlObject!==null&&Nn("game-controls","the scene's game controls"),i===!1){let{enableRotate:a,enablePan:o,enableZoom:l,autoRotate:u,hoverRotatePanMode:h}=this.eventManager.publish.orbitControls;(a||o||l||u||h!==0)&&(this.orbitControls=new Obt(e,this.renderer.domElement,{isExport:this.isExport,isPlayMode:!0}),this.orbitControls.addEventListener("change",this.requestRender),this.orbitControls.addEventListener("end",this.requestRender),this.orbitControls.addEventListener("start",this.requestRender),this.orbitControls.fromJSON(this.eventManager.publish.orbitControls,this.eventManager.publish.mouseEventTarget),this.orbitControls.useKeyEvents=!1,this.orbitControls.addEventListenersToCamera(),this.orbitControls.connect(),this.orbitControls.update())}let s=this.renderer.domElement.width/this.renderer.getPixelRatio(),n=this.renderer.domElement.height/this.renderer.getPixelRatio();Mut()?.createJoysticks(this,s,n),this.markIsDestroyTarget(),this.markIsDragObject(),this.rebuildBVH(),this.initializationCounter++,window.setTimeout(()=>{this.collisionEvents.forEach(a=>a.initialDisabled=!1)},80)}initPhysics(){this.sharedGameControlGlobals.rapierWorld?.free(),this.sharedGameControlGlobals.rapierWorld=new ki.World(new ki.Vector3(0,this.gravity,0)),this.events=new ki.EventQueue(!0);let t=[],e=[];if(this.page.traverseChildren(a=>{let o;if(H1(a)){if(!a.objectForSample)return a.object.dataPatched.physics.fusedBody===!0&&a.object.dataPatched.physics.rigidBody==="dynamic"||void 0;if(a.objectForSample.dataPatched.physics.fusedBody)return;o=a.object}else if(Sg(a))o=a.object;else{if(q2(a)||Jg(a)||a instanceof vv)return;if(o=a,o.dataPatched.cloner?.disabled===!1&&o.dataPatched.cloner?.hideBase&&o.dataPatched.physics?.fusedBody!==!0)return!0}let l,u=o.dataPatched;for(let g of u.events)g.data.disabled!==!0&&g.data.type==="GameControl"&&(l=g.data);if(!u.physics||(u.physics.enabled==="visibility"?!u.visible:!u.physics.enabled))return!0;a.updateMatrixWorldRigid();let h=f5(u),d=!1,c=o.userData.hasDestroy,p=o.userData.hasDrag,m=!1;for(let g of u.events)if(g.data.disabled!==!0){if(g.data.type==="Collision"){d=!0;let y=new RPt(g.id,g.data,o,this.page,this.sharedAssets,this.eventManager);y.initialDisabled=!0,this.collisionEvents.push(y),this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid]&&this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid].every(v=>v.id!==g.id)?this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid].push(y):this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid]=[y]}else if(g.data.type==="Follow"){m=!0;let y=g.data.target;a.traverseVisible(v=>{v.userData.isFollowingObj=y})}}u.physics.rigidBody==="dynamic"&&u.physics.fusedBody===!1&&(a.matrixWorldFusedFalse=a.matrixWorld.clone());let f=a.geometry;if(l!==void 0){let g=ki.RigidBodyDesc.kinematicPositionBased();(a.hasNonUniformScale?a.matrixWorldRigid:a.matrixWorld).decompose(en,Wl,Tp),a.position0=en.clone().divideScalar(this.pixelsPerMeter),a.rotation0=Wl.clone(),en.divideScalar(this.pixelsPerMeter),g.setTranslation(en.x,en.y,en.z).setRotation(Wl);let y,v=this.sharedGameControlGlobals.rapierWorld.createRigidBody(g);a.rigidBody=v,y=l.collider.type==="sphere"?ki.ColliderDesc.ball(l.collider.radius/this.pixelsPerMeter):l.collider.type==="capsule"?ki.ColliderDesc.capsule((l.collider.height/2-l.collider.radius)/this.pixelsPerMeter,l.collider.radius/this.pixelsPerMeter):ki.ColliderDesc.cuboid(l.collider.width/this.pixelsPerMeter/2,l.collider.height/this.pixelsPerMeter/2,l.collider.depth/this.pixelsPerMeter/2),y.setFrictionCombineRule(ki.CoefficientCombineRule.Average).setDensity(u.physics.density).setFriction(u.physics.friction).setRestitution(0).setRestitutionCombineRule(ki.CoefficientCombineRule.Min);let b=this.sharedGameControlGlobals.rapierWorld.createCollider(y,v);this.sharedGameControlGlobals.colliderToEntity.set(b.handle,o),en.fromArray(l.collider.position.map(x=>typeof x=="number"?x:0)).multiply(Tp.setFromMatrixScale(o.matrixWorld)).divideScalar(this.pixelsPerMeter),b.setTranslationWrtParent(en);let _=new Me().setFromEuler(new Qi().setFromVector3(new P().fromArray(l.collider.rotation.map(x=>typeof x=="number"?x:0))));b.setRotationWrtParent(_),b.setActiveEvents(ki.ActiveEvents.COLLISION_EVENTS),this.generateSensorColliderDescs(o,!0)}else u.physics.rigidBody==="dynamic"||h||m||c||p||d?(this.addRigidBody(a,o,{hasFollow:m,hasTransformAnim:h,hasDrag:p}),this.generateSensorColliderDescs(o,u.physics.fusedBody)):(f&&t.push(ac(f,a.matrixWorld)),u.physics.fusedBody&&!Ky(a)&&a.traverseObject((g,y)=>{if(y===0)return;let v;if(H1(g)){if(!g.objectForSample)return g.object.dataPatched.physics.fusedBody===!0&&g.object.dataPatched.physics.rigidBody==="dynamic"||void 0;if(g.objectForSample.dataPatched.physics.fusedBody)return;v=g.object}else{if(q2(g)||Jg(g)||g instanceof vv)return;if(Sg(g))v=g.object;else if(v=g,v.dataPatched.cloner?.hideBase)return!0}let b=v.dataPatched;if(b.physics.enabled==="visibility"?!b.visible:!b.physics.enabled)return!0;let _=g.geometry;return _?.getAttribute("position")!==void 0&&t.push(ac(_,g.matrixWorld)),!!Ky(g)||void 0}),this.generateSensorColliderDescs(o,u.physics.fusedBody,e));return!(u.physics?.fusedBody!==!0&&!l&&!Ky(a))||void 0}),t.length===0)return;let i=wg(t),r=i.getIndex().count>0;if(!r&&e.length===0)return;i.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter);let s=ki.RigidBodyDesc.fixed(),n=this.sharedGameControlGlobals.rapierWorld.createRigidBody(s);if(r){let a=ki.ColliderDesc.trimesh(i.getAttribute("position").array,i.getIndex().array).setFrictionCombineRule(ki.CoefficientCombineRule.Multiply).setRestitutionCombineRule(ki.CoefficientCombineRule.Multiply).setFriction(1).setRestitution(1);this.sharedGameControlGlobals.rapierWorld.createCollider(a,n)}for(let[a,o]of e){let l=this.sharedGameControlGlobals.rapierWorld.createCollider(a,n);this.sensorToTriggerEvent[l.handle]=o}}updatePositions(){return this.nActiveRigidBodies=0,this.sharedGameControlGlobals.rapierWorld.forEachRigidBody(this.processRigidBody),this.nActiveRigidBodies>0}rebuildBVH(){this.usePhysics?this.initPhysics():(this.page.traverseEntity(t=>{for(let e of t.dataPatched.events)if(e.data.type==="Trigger"&&e.data.disabled!==!0){let i=new Put(e.id,e.data,t,this.page,this.sharedAssets,this.eventManager),r=new bt().compose(Ph.fromArray(e.data.position.map(s=>typeof s=="number"?s:0)),Yy.setFromEuler(Rut.fromArray(e.data.rotation.map(s=>typeof s=="number"?s:0))),vF);if(e.data.triggerZone==="box"){let s=new pr;s.min.fromArray(e.data.size.map(n=>typeof n=="number"?n:0)).multiplyScalar(-.5),s.max.fromArray(e.data.size.map(n=>typeof n=="number"?n:0)).multiplyScalar(.5),this.sharedGameControlGlobals.triggers.push([s,r,t,i])}else this.sharedGameControlGlobals.triggers.push([e.data.radius,r,t,i])}}),this.needsCollisionDetection&&this.initBVH())}disconnectEvents(){this.collisionEvents.forEach(t=>t.disconnect()),this.sharedGameControlGlobals.triggers.forEach(t=>t[3].disconnect()),this.sharedGameControlGlobals.triggers.length=0}deactivate(){if(this.isEnabled){this.isEnabled=!1,this.page.traverse(t=>{let e=t;e.matrixWorldFusedFalse&&(e.matrixWorldFusedFalse=void 0),e.rigidBody&&(e.rigidBody=void 0),e.position0&&(e.position0=void 0),e.rotation0&&(e.rotation0=void 0)}),this.sharedGameControlGlobals.rapierWorld?.free(),this.sharedGameControlGlobals.rapierWorld=void 0,this.sharedGameControlGlobals.staticMeshBVH=void 0,this.accumulator=0,this.sharedGameControlGlobals.entitiesWithTransformAnim=[],this.sharedGameControlGlobals.kinematicBodyToEntity.clear(),this.fixedBodiesToWatch=[],this.disconnectEvents(),this.gameControl?.reset(),this.gameControl?.dispose(),this.gameControl=null,this.initializationCounter=-1,this.joysticks.forEach(([t,e])=>{t?.destroy(),e.remove()}),this.joystickToGameControls=[],this.joysticks=[],this.orbitControls&&(this.orbitControls.dispose(),this.orbitControls=void 0),this.navigationMeshWrapper?.dispose(),this.navigationMeshWrapper=void 0;for(let t of Object.values(this.sharedGameControlGlobals.entityToCollisionEvents))t.forEach(e=>e.disconnect());this.sharedGameControlGlobals.entityToCollisionEvents={},this.page.updateMatrixWorld(!0)}}update(t){if(!this.isEnabled)return!0;let e=!0;if(this.orbitControls!==void 0&&this.orbitControls.needsUpdate&&(this.orbitControls.update(),e=!this.orbitControls.isCurrentlyDamping),this.initializationCounter>=0&&this.initializationCounter<2?(this.initializationCounter++,e=!1):this.initializationCounter===2&&this.gameControl&&(e=!this.gameControl.update(t)&&e),this.usePhysics===!1&&this.checkTrigger(),this.usePhysics){let i=.016666666666666666;if(t===0)e=this.stepPhysics()&&e;else{let r=t/1e3;r<i&&r>.55*i&&(r=i),this.accumulator+=r;let s=performance.now(),n=0,a=6;for(;this.accumulator>=i&&n<a&&(e=this.stepPhysics()&&e,this.accumulator-=i,n++,!(performance.now()-s>1e3*i)););this.accumulator=this.accumulator%i}}this.skipRender=e}recordPhysicsPose(t){(t.hasNonUniformScale?t.matrixWorldRigid:t.matrixWorld).decompose(en,Wl,Tp);let e=t;e.prevQ===void 0?(e.prevQ=Wl.clone(),e.prevT=en.clone()):(e.prevQ.copy(Wl),e.prevT.copy(en))}promoteMovedFixedBodies(){for(let t=this.fixedBodiesToWatch.length-1;t>=0;t--){let[e,i,r]=this.fixedBodiesToWatch[t];e.rigidBody===i?(e.hasNonUniformScale?e.matrixWorldRigid:e.matrixWorld).equals(r)||(i.setBodyType(ki.RigidBodyType.KinematicPositionBased,!0),this.sharedGameControlGlobals.kinematicBodyToEntity.set(i.handle,e),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(e),this.fixedBodiesToWatch.splice(t,1)):this.fixedBodiesToWatch.splice(t,1)}}clampPushedBodies(){let t=this.gameControl?.object.rigidBody;if(t===void 0)return;let e=this.sharedGameControlGlobals.rapierWorld,i=t.linvel(),r=t.translation(),s=Math.hypot(i.x,i.z);for(let n=0;n<t.numColliders();n++){let a=t.collider(n);e.contactPairsWith(a,o=>{let l=o.parent();if(l===null||!l.isDynamic())return;let u=l.translation(),h=-1/0,d=0,c=0;if(e.contactPair(a,o,y=>{let v=y.normal(),b=v.x*(u.x-r.x)+v.y*(u.y-r.y)+v.z*(u.z-r.z)<0?-1:1;if(Math.abs(v.y)>.7)return;let _=b*v.x,x=b*v.z,S=Math.hypot(_,x);if(S<1e-4)return;let w=(i.x*_+i.z*x)/S;w>h&&(h=w,d=_/S,c=x/S)}),h===-1/0)return;let p=i.x*d+i.z*c;if(p<-_F)return;let m=l.linvel();if(s>_F&&p>_F){let y=m.x*d+m.z*c;if(y<=0)return;let v=Math.min(y,p);return void l.setLinvel({x:d*v,y:m.y,z:c*v},!0)}let f=m.x*d+m.z*c-Math.max(0,p);if(f<=0)return;let g=.5*f;l.setLinvel({x:m.x-d*g,y:m.y,z:m.z-c*g},!0)})}}stepPhysics(){this.promoteMovedFixedBodies();let t=this.sharedGameControlGlobals.kinematicBodyToEntity;for(let[e,i]of t)i.rigidBody!==void 0?(this.recordPhysicsPose(i),i.rigidBody.setNextKinematicTranslation(en.divideScalar(this.pixelsPerMeter)),i.rigidBody.setNextKinematicRotation(Wl)):t.delete(e);for(let e of this.sharedGameControlGlobals.entitiesWithTransformAnim)e.rigidBody?.isKinematic()!==!0&&this.recordPhysicsPose(e);return this.sharedGameControlGlobals.rapierWorld.step(this.events),this.clampPushedBodies(),this.events?.drainCollisionEvents(this.handleCollisionEvents),!this.updatePositions()}dispatchCollisionEvent(t,e,i){let r,s=(this.sharedGameControlGlobals.rapierWorld?.getCollider(i))._parent;if(e.cloner){for(let n of e.cloner.children)if(n.rigidBody===s){r=n;break}}t.dispatch(r),e.dispatchEvent(h7)}updateUseWindowEvents(t){this.orbitControls?.updateUseWindowEvents(t)}generateSensorColliderDescs(t,e,i){let r=Dut.copy(t.matrixWorld).invert();t.traverseEntity((s,n)=>{if(e===!1&&n===1)return!0;for(let a of s.dataPatched.events)if(a.data.type==="Trigger"&&a.data.disabled!==!0){let o,l=new Put(a.id,a.data,s,this.page,this.sharedAssets,this.eventManager);if(o=a.data.triggerZone==="box"?ki.ColliderDesc.cuboid(...a.data.size.map(u=>(typeof u=="number"?u:1)/(2*this.pixelsPerMeter))):ki.ColliderDesc.ball(a.data.radius/this.pixelsPerMeter),o.setDensity(0).setSensor(!0).setActiveEvents(ki.ActiveEvents.COLLISION_EVENTS),Ph.fromArray(a.data.position.map(u=>typeof u=="number"?u:0)),Yy.setFromEuler(Rut.fromArray(a.data.rotation.map(u=>typeof u=="number"?u:0))),NE.compose(Ph,Yy,vF).premultiply(s.matrixWorld),i?(NE.decompose(Ph,Yy,yF),o.setActiveCollisionTypes(ki.ActiveCollisionTypes.KINEMATIC_FIXED|ki.ActiveCollisionTypes.DYNAMIC_FIXED)):(NE.premultiply(r).decompose(Ph,Yy,yF),t.rigidBody.bodyType()===ki.RigidBodyType.Dynamic||(t.rigidBody.bodyType()===ki.RigidBodyType.Fixed?o.setActiveCollisionTypes(ki.ActiveCollisionTypes.KINEMATIC_FIXED|ki.ActiveCollisionTypes.DYNAMIC_FIXED):o.setActiveCollisionTypes(ki.ActiveCollisionTypes.KINEMATIC_KINEMATIC|ki.ActiveCollisionTypes.DYNAMIC_KINEMATIC))),Ph.divideScalar(this.pixelsPerMeter),o.setTranslation(Ph.x,Ph.y,Ph.z),o.setRotation(Yy),i)i.push([o,l]);else{let u=this.sharedGameControlGlobals.rapierWorld.createCollider(o,t.rigidBody);this.sensorToTriggerEvent[u.handle]=l}}})}checkTrigger(){let t;for(let e=0;e<this.sharedGameControlGlobals.triggers.length;e++){let[i,r,s,n]=this.sharedGameControlGlobals.triggers[e];for(let a=0;a<this.sharedGameControlGlobals.entitiesWithTransformAnim.length;a++){let o=this.sharedGameControlGlobals.entitiesWithTransformAnim[a];if(s===o||n.isValidTriggeringObject(Mi.is(o)?o:o.object)===!1)continue;let l=Dut.copy(s.matrixWorld).decompose(Ph,Nut,yF).compose(Ph,Nut,vF).multiply(r),u=NE.copy(o.matrixWorld).invert().multiply(l),h=o.bvhGeometry.boundsTree;i instanceof pr?t=h.intersectsBox(i,u):(bF.radius=i,bF.center.setFromMatrixPosition(u),t=h.intersectsSphere(bF)),t?n.currentIntersectedObjects.indexOf(o)===-1&&(n.currentIntersectedObjects.push(o),n.dispatch(),s.dispatchEvent(NPt)):n.currentIntersectedObjects=n.currentIntersectedObjects.filter(d=>d!==o)}}}};Jv(),dt(),MR(),Fi(),wm();var xF=.02,Out=new P,Iut=new P,IPt=new P,qa=new P,Ld=new P,Zy=new P,wF=new bt,But=new bt,BPt=new bt,nl=new Me,Hf=new Me,Qy=new Qi(0,0,0,"YXZ"),VPt=new P(1,0,0),Eu=new P(0,1,0),kPt=new P(0,0,1),Vut=new P(1,1,1),kut=[],zut=t=>kut[t]??(kut[t]=new P),SF=new P,zPt=new P,LPt=new P,FPt=new P,Lut=new Me,UPt=new P,Fut=new Me,Hn=new yl,ql=new pr,jPt={type:"requestRender"},GPt={type:"updateMatrix"},u7=class extends Jn{constructor(t,e,i,r,s,n,a,o,l){super(),this.object=t,this.domElement=e,this.data=i,this.gloabalPhysics=r,this.controlsManager=s,this.cameraFollow=n,this.camera=a,this.page=o,this.sharedAssets=l,this.enableDamping=!0,this.hiddenMatrix0=new bt,this.target0=new P,this.zoom0=1,this.rotForce=1,this.moveForce=1,this.pixelsPerMeter=200,this.euler0=new Qi(0,0,0,"YXZ"),this.position0Cam=new P,this.quat0Cam=new Me,this.scale0Cam=new P,this.hiddenMatrix0Cam=new bt,this.threshEndTranslate=.01,this.threshEndRotate=1e-8,this.threshEndRotVel=.005,this.collider={type:"capsule",radius:40,segment:new yl(new P(0,-40,0),new P(0,40,0)),matrix:new bt,position:new P,rotation:new Me},this.euler=new Qi(0,0,0,"YXZ"),this.eulerDelta=new P,this.lastPosition=new P,this.lastCameraQuaternion=new Me,this.lastCameraPosition=new P,this.PI_2=Math.PI/2,this.prevMouse=new Z,this.velocityTarget=new P,this.velocity=new P,this.directionXZ=new P,this.rotVelocityStick=new P,this.rotVelocityTarget=new P,this.rotVelocity=new P,this.rotDirection=new P,this.nonColliderRotOffset=new bt,this.nonColliderPosOffset=new bt,this.firstPointerId=-1,this.rot=new P,this.path=[],this.movementState={moveNegZ:0,movePosZ:0,moveNegX:0,movePosX:0,moveNegY:0,movePosY:0,rotPosX:0,rotNegX:0,rotPosY:0,rotNegY:0,jump:0,run:0},this.onObject=!1,this.actionState={},this.keyAssignments=[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","ArrowUp"],["rotPosY","ArrowLeft"],["rotNegX","ArrowDown"],["rotNegY","ArrowRight"],["jump"," "]],this.collisionEnabled=!0,this.offsetMatrix=new bt,this.objectToTarget=new P,this.objectToTarget0=new P,this.objectToCamXZ=new P,this.objectToCamXZ0=new P,this.targetToCamera=new P,this.targetToCamera0=new P,this.cameraPolarAxis0=new P,this.targetPos=new P,this.targetQuat=new Me,this.lerpFactorPos=new P().setScalar(.3),this.lerpFactorPosStart=.3,this.lerpFactorPosEnd=.3,this.lerpFactorRotStart=.3,this.lerpFactorRotEnd=.3,this.lerpFactorPosCamera=.3,this.lerpFactorRotCamera=.3,this.objXZQuat=new Me,this.objXZQuatInv=new Me,this.objXZRotMat=new bt,this.isFirstPerson=!1,this.didHit=!1,this.groundVelocity=new P,this.pushedVelocity=new P,this.groundYRotation=0,this.objectRealQuat=new Me,this.colliderWorldQuat=new Me,this.groundNormal=new P,this.groundTilt=new Me,this.groundTiltInv=new Me,this.lastHitObj=null,this.isFirstFrame=!0,this.rotationAccumWhenOrientWithCamera=0,this.navMeshPathDest=null,this.position=new P,this.quaternion=new Me,this.scale=new P,this.initialAction=!0,this.onPointerDown=m=>{!(m.target===this.domElement||m.target instanceof HTMLElement&&m.target.tagName==="SPLINE-VIEWER"&&m.target.shadowRoot?.contains(this.domElement))||this.firstPointerId!==-1||(this.firstPointerId=m.pointerId,this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp),this.rotBy!=="keys"&&!Fo&&!N8&&this.domElement.requestPointerLock(),this.prevMouse.set(m.clientX,m.clientY))},this.onPointerUp=m=>{this.firstPointerId=-1,this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp),m.pointerType==="mouse"&&this.domElement.ownerDocument.exitPointerLock()},this.onPointerMove=m=>{if(m.pointerId!==this.firstPointerId)return;let f=m.clientX-this.prevMouse.x,g=m.clientY-this.prevMouse.y;this.prevMouse.set(m.clientX,m.clientY),m.pointerType==="mouse"&&this.rotBy!=="keys"&&(N8&&Xpt<15.5&&!Fo?(this.eulerDelta.y=-f*this.mouseOrbitSensitivity,this.eulerDelta.x=-g*this.mouseOrbitSensitivity):(this.eulerDelta.y=-m.movementX*this.mouseOrbitSensitivity,this.eulerDelta.x=-m.movementY*this.mouseOrbitSensitivity)),m.pointerType!=="mouse"&&this.rotByTouch==="drag"&&(this.eulerDelta.y=-f*this.mouseOrbitSensitivity*5,this.eulerDelta.x=-g*this.mouseOrbitSensitivity*5),this.controlsManager.requestRender()},this.onPointerlockChange=m=>{this.domElement.ownerDocument.pointerLockElement===this.domElement?u7.isLocked=!0:u7.isLocked=!1},this.onPointerlockError=()=>{console.error("SPE.GameControls: Unable to use Pointer Lock API")},this.handleVisibilityChange=()=>{if(document?.hidden)for(let m in this.movementState)this.movementState[m]=0},this.onKeyDown=m=>{!(m.target instanceof HTMLInputElement)&&(m.code==="ArrowLeft"||m.code==="ArrowUp"||m.code==="ArrowRight"||m.code==="ArrowDown"||m.code==="Space")&&m.preventDefault();for(let f of this.keyAssignments)if(m.key.toUpperCase()===f[1]||m.key===f[1]){this.movementState[f[0]]=1;break}this.controlsManager.requestRender()},this.onKeyUp=m=>{for(let f of this.keyAssignments)if(m.key.toUpperCase()===f[1]||m.key===f[1]||m.code.slice(3,m.code.length).toUpperCase()===f[1]){this.movementState[f[0]]=0;break}},this.copyVRGamePadValues=(m,f)=>{for(let g=2;g<4;g++){let y=m.axes[g];f===0?g===2?this.movementState.movePosX=y:this.movementState.movePosZ=y:(m.buttons[3].pressed?this.movementState.jump=1:this.movementState.jump=0,g===2?this.movementState.rotPosY=y:this.moveMode==="fly"&&(this.movementState.moveNegY=y))}},this.sharedGameControlGlobals=s.sharedGameControlGlobals,t===a&&(this.isFirstPerson=!0),this.hiddenMatrix0.copy(this.object.hiddenMatrix),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.position,this.quaternion,this.scale),this.euler0.setFromQuaternion(this.quaternion,"YXZ");let u=this.euler0.clone(),h=u.y;if(this.objectRealQuat.copy(this.quaternion),u.y=0,this.quaternion.setFromEuler(u),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),u.set(0,h,0),this.quaternion.setFromEuler(u),this.rot.setFromEuler(u),this.object.matrixAutoUpdate=!1,(this.isFirstPerson||this.cameraFollow===!0)&&(this.target0.copy(this.camera.getTarget()),this.zoom0=this.camera.zoom),this.cameraFollow===!0){this.position0Cam.copy(this.camera.position),this.quat0Cam.copy(this.camera.quaternion),this.scale0Cam.copy(this.camera.scale),this.hiddenMatrix0Cam.copy(this.camera.hiddenMatrix),this.camera.parent?(this.camera.hiddenMatrix.copy(this.camera?.parent.matrixWorld),this.camera.matrix.copy(this.camera.matrixWorld)):this.camera.hiddenMatrix.identity(),this.camera.matrix.copy(this.camera.matrixWorld),this.camera.matrix.decompose(this.camera.position,this.camera.quaternion,this.camera.scale),this.camera.matrixAutoUpdate=!1,this.offsetMatrix.copy(this.object.matrix).invert().multiply(this.camera.matrix);let m,f=new P(0,0,-1).applyQuaternion(this.camera.quaternion),g=new P().subVectors(this.position,this.camera.position);this.objectToCamXZ.copy(g),this.objectToCamXZ.y=0,this.objectToCamXZ0.copy(this.objectToCamXZ),Math.abs(f.y)<1e-6?(g.y=0,f.y=0,m=g.projectOnVector(f)):m=g.y/f.y>0?f.multiplyScalar(g.y/f.y):f.multiplyScalar(g.length()),this.targetToCamera0.copy(m).negate();let y=this.camera.position.clone().add(m);this.objectToTarget0.subVectors(y,this.position);let v=new Qi().setFromQuaternion(this.camera.quaternion,"YXZ");this.cameraPolarOffset=-v.x,v.x=0,v.z=0,v.y-=Math.PI/2,this.cameraPolarAxis0.set(0,0,-1).applyEuler(v)}if(this.object instanceof ln&&(this.object.matrixAutoUpdate=!1),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.rotByTouch=i.rotByTouch??"joystick",this.rotBy=i.rotBy??"keys",this.rotationMode=i.rotationMode??"normal",this.moveMode=i.moveMode??"walk",this.collisionEnabled=i.collisionEnabled,this.speedTranslate=1*(i.speedTranslate??250),this.speedOrbit=.025*(i.speedRotate??100),this.mouseOrbitSensitivity=16e-6*(i.speedRotate??100),this.keyAssignments=i.keyAssignments.map(m=>{let f=[m[0],m[1]];return f[1]==="\u25B2"?f[1]="ArrowUp":f[1]==="\u25C0"?f[1]="ArrowLeft":f[1]==="\u25BC"?f[1]="ArrowDown":f[1]==="\u25B6"?f[1]="ArrowRight":f[1]==="\u21E7"?f[1]="Shift":f[1]==="\u21B5"?f[1]="Enter":f[1]==="Space"?f[1]=" ":f[1]==="\u2318"?f[1]="Meta":f[1]==="Ctrl"?f[1]="Control":f[1]==="Esc"&&(f[1]="Escape"),f}),i.rotBy==="mouse"){let m;m=this.keyAssignments.findIndex(f=>f[0]==="rotNegX"),m!==-1&&(this.keyAssignments[m][1]=""),m=this.keyAssignments.findIndex(f=>f[0]==="rotPosX"),m!==-1&&(this.keyAssignments[m][1]=""),m=this.keyAssignments.findIndex(f=>f[0]==="rotPosY"),m!==-1&&(this.keyAssignments[m][1]=""),m=this.keyAssignments.findIndex(f=>f[0]==="rotNegY"),m!==-1&&(this.keyAssignments[m][1]="")}this.lerpFactorPosStart=1-.02**(1/(60*(i.delayPos[0]??.3))),this.lerpFactorPosEnd=1-.02**(1/(60*(i.delayPos[1]??.3))),this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.lerpFactorRotStart=1-.02**(1/(60*(i.delayRot[0]??.3))),this.lerpFactorRotEnd=1-.02**(1/(60*(i.delayRot[1]??.3))),this.lerpFactorPosCamera=1-.02**(1/(60*(i.delayPosCamera??.3))),this.lerpFactorRotCamera=1-.02**(1/(60*(i.delayRotCamera??.3))),this.gravity=12*(this.gloabalPhysics.gravity??dv.defaultData.gravity),this.usePhysics=this.gloabalPhysics.usePhysics??dv.defaultData.usePhysics,this.jumpPower=20*i.jumpPower,this.resetYPosition=this.position.y+Math.abs(i.resetYPosition)*(this.gravity>0?1:-1),this.alignToGround=i.alignToGround??!1,this.orientMode=i.autoOrientMove?i.orientMode:"none",this.orientWith=i.orientWith??yR.defaultDataThirdPerson.orientWith,this.slopeThresh=65*Math.PI/180,i.collider.type==="capsule"?(this.collider.radius=i.collider.radius,this.collider.segment.start.y=i.collider.height/2-i.collider.radius,this.collider.segment.end.y=-this.collider.segment.start.y,this.offset=i.collider.height*xF/this.pixelsPerMeter,this.stepThresh=.3*i.collider.height/this.pixelsPerMeter,this.colliderHeight=i.collider.height):i.collider.type==="sphere"?(this.collider.radius=i.collider.radius,this.collider.segment.start.y=0,this.collider.segment.end.y=0,this.offset=2*i.collider.radius*xF/this.pixelsPerMeter,this.stepThresh=2*i.collider.radius*.3/this.pixelsPerMeter,this.colliderHeight=2*i.collider.radius):(this.offset=i.collider.height*xF/this.pixelsPerMeter,this.stepThresh=.3*i.collider.height/this.pixelsPerMeter,this.colliderHeight=i.collider.height),this.collider.type=i.collider.type;let d=new P().fromArray(i.collider.position.map(m=>typeof m=="number"?m:0)),c=new Me().setFromEuler(new Qi().fromArray([...i.collider.rotation.map(m=>typeof m=="number"?m:0),"XYZ"]));this.collider.position.copy(d).multiply(this.scale),this.collider.rotation.copy(c),this.collider.matrix.compose(d,c,Vut),i.cameraXAxis!==void 0&&(this.cameraXAxis=i.cameraXAxis,this.cameraYAxis=i.cameraYAxis,this.minPolarAngle=i.cameraRotXLimits[0],this.maxPolarAngle=i.cameraRotXLimits[1],this.minAzimuthAngleRel=i.cameraRotYLimits[0],this.maxAzimuthAngleRel=i.cameraRotYLimits[1]),this.forwardDir=i.forwardDirection??"-z",this.isFirstPerson&&(this.forwardDir="-z"),this.runMultiplier=i.runMultiplier??2;let p=2*i.navmesh.destinationHelperRadius;if(p>0){let m=new ge;m.push({fi:0,data:{...Ws.defaultData("light","phong"),alpha:0},id:"layer1"}),m.push({fi:0,data:{...Ws.defaultData("color"),color:i.navmesh.destinationHelperColor,alpha:i.navmesh.destinationHelperColor.a},id:"layer2"});let f=Sgt({layers:m},{scene:this.page.scene,shared:this.sharedAssets});this.navMeshPathDest=new Sr(MG.create({parameters:{width:p,height:p/10,hollow:.7}}),f),this.navMeshPathDest.material.userData.opacity0=i.navmesh.destinationHelperColor.a}this.activate()}reset(t=!1){if(this.object.hiddenMatrix.copy(this.hiddenMatrix0),t){this.object.updateMatrix(),this.object.updateMatrixWorld(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.position,this.quaternion,this.scale),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity();let e=new Qi().setFromQuaternion(this.quaternion,"YXZ"),i=e.y;this.objectRealQuat.copy(this.quaternion),e.y=0,this.quaternion.setFromEuler(e),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),e.set(0,i,0),this.quaternion.setFromEuler(e),this.rot.setFromEuler(e),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.velocityTarget.set(0,0,0),this.velocity.set(0,0,0)}else this.object instanceof ln?this.object.matrixAutoUpdate=!0:this.object.updateMatrix();this.cameraFollow===!0&&(this.camera.quaternion.copy(this.quat0Cam),this.camera.position.copy(this.position0Cam),this.camera.scale.copy(this.scale0Cam),this.camera.hiddenMatrix.copy(this.hiddenMatrix0Cam),this.camera.matrixAutoUpdate=!0),this.controlsManager.requestRender()}activate(){this.instantiateActions(),this.domElement.ownerDocument.addEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.addEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.addEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.addEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.addEventListener("pointerlockerror",this.onPointerlockError),this.domElement.ownerDocument.addEventListener("visibilitychange",this.handleVisibilityChange)}deactivate(){this.disposeActions(),this.domElement.ownerDocument.removeEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.removeEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.removeEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.removeEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.removeEventListener("pointerlockerror",this.onPointerlockError),this.domElement.ownerDocument.removeEventListener("visibilitychange",this.handleVisibilityChange)}dispose(){this.deactivate(),this.navMeshPathDest?.parent&&this.page.remove(this.navMeshPathDest)}instantiateActions(){let t=this.data,e=this.sharedAssets;t.gameActions!==void 0&&(this.actions={},gR.list.forEach(i=>{this.actions[i]=un({...t,disabled:!1,type:"GameControl"},t.gameActions[i],this.page,e,this.controlsManager.eventManager,this.object)})),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"),this.initialAction&&(this.initialAction=!1)}disposeActions(){this.initialAction=!1,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),na(this.actions.idle),na(this.actions.move),na(this.actions.run),na(this.actions.jump)}dispatchStartEvent(t){this.actions[t]!==void 0&&(this.actionState[t]||(this.actionState[t]=!0,this.actions[t].Transition.forEach(e=>{e.play()}),this.actions[t].Animation.forEach(e=>{e.play(this.initialAction===!1)}),this.actions[t].TimelineAnimation.forEach(e=>{e.play()}),this.actions[t].Create.forEach(e=>{e.dispatchStart()}),this.actions[t].Audio.forEach(e=>{e.dispatchGameControl("start")}),this.actions[t].Particles.forEach(e=>{e.dispatchGameControl("start")})))}dispatchStopEvent(t){this.actions[t]!==void 0&&(!this.actionState[t]||(this.actionState[t]=!1,this.actions[t].Transition.forEach(e=>{e.stop(),e.object.currentState!==null&&e.object.changeSelectedState(null,{scene:this.page.scene,shared:this.sharedAssets})}),this.actions[t].TimelineAnimation.forEach(e=>{e.stop()}),this.actions[t].Create.forEach(e=>{e.dispatchStop()}),this.actions[t].Audio.forEach(e=>{e.dispatchGameControl("stop")}),this.actions[t].Particles.forEach(e=>{e.dispatchGameControl("stop")})))}get colliderWorldPosition(){return qa.copy(this.collider.position).applyQuaternion(this.objectRealQuat).add(this.position)}update(t){if(this.gravity<0?this.position.y<this.resetYPosition:this.position.y>this.resetYPosition)return this.reset(!0),!0;this.sharedGameControlGlobals.gamePads.forEach(this.copyVRGamePadValues);let e=(this.isFirstFrame?16.6:t)/1e3;this.isFirstFrame&&(this.isFirstFrame=!1);let i=60*e,r=!1;if(this.groundYRotation=0,this.groundVelocity.set(0,0,0),this.usePhysics&&this.collisionEnabled&&this.object.rigidBody?.collider(0).shape){let n=Ld.set(0,(this.velocity.y===0?this.pixelsPerMeter*Math.max(Math.abs(this.gravity)/120,1)*(this.gravity>0?1:-1):this.velocity.y)*e,0).divideScalar(this.pixelsPerMeter),a=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter),this.colliderWorldQuat,n,this.object.rigidBody?.collider(0).shape,0,1,!1,8,void 0,void 0,this.object.rigidBody);if(a){this.onObject=!0,this.groundNormal.set(a.normal2.x,a.normal2.y,a.normal2.z).applyQuaternion(this.colliderWorldQuat).negate(),this.alignToGround&&this.groundTiltAdjustment(this.groundNormal),Math.acos(this.groundNormal.y)<this.slopeThresh&&(r=!0),a.collider.parent()?.bodyType()===0&&Math.acos(this.groundNormal.y)*(180/Math.PI)>45&&(this.onObject=!1);let o=a.collider.parent(),l=o!==null&&o.isKinematic()?o:null,u=l===null?void 0:this.sharedGameControlGlobals.kinematicBodyToEntity.get(l.handle);if(l!==null&&u?.userData.isFollowingObj!==this.object.uuid){let h=this.object.getWorldPosition(qa).add(this.collider.position).divideScalar(this.pixelsPerMeter),d=l.velocityAtPoint(h);this.groundVelocity.set(d.x,d.y,d.z).multiplyScalar(this.pixelsPerMeter),this.groundYRotation=l.angvel().y*e}}else this.onObject=!1}if(this.moveMode==="walk"&&this.collisionEnabled&&(this.movementState.jump===1&&this.onObject&&(this.velocityTarget.y=this.jumpPower,this.movementState.jump=0,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("jump"),this.onObject=!1),this.onObject?this.velocityTarget.y/=2:this.velocityTarget.y+=this.gravity*i),this.moveMode==="fly"&&(this.velocityTarget.y=(this.movementState.movePosY-this.movementState.moveNegY)*this.speedTranslate),this.directionXZ.z=this.movementState.movePosZ-this.movementState.moveNegZ,this.directionXZ.x=this.movementState.movePosX-this.movementState.moveNegX,this.forwardDir==="+z"&&this.directionXZ.multiplyScalar(-1),this.directionXZ.manhattanLength()>0&&(this.path=[]),this.navMeshPathDest){let n=this.navMeshPathDest.material;if(this.moveMode==="walk"&&this.path.length>1){this.navMeshPathDest.position.copy(this.path[this.path.length-1]),this.navMeshPathDest.parent||this.page.add(this.navMeshPathDest);let a=qa.subVectors(this.path[1],this.position),o=Ld.subVectors(this.path[1],this.path[0]);a.dot(o)<0?this.path.shift():(this.directionXZ.x=o.x,this.directionXZ.z=o.z),n.opacity=n.userData.opacity0}else n.opacity-=.05*n.userData.opacity0,this.navMeshPathDest.material.opacity<=0&&this.navMeshPathDest.parent&&this.page.remove(this.navMeshPathDest)}this.directionXZ.normalize(),this.movementState.run?this.moveForce=this.runMultiplier:this.moveForce=1,this.velocityTarget.z=this.directionXZ.z*this.speedTranslate*this.moveForce,this.velocityTarget.x=this.directionXZ.x*this.speedTranslate*this.moveForce,(this.moveMode==="walk"?this.velocityTarget.x+this.velocityTarget.z===0:this.velocityTarget.manhattanLength()===0)?this.lerpFactorPos.setScalar(this.lerpFactorPosEnd):this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.moveMode==="walk"&&(this.lerpFactorPos.y=1),this.didHit===!1&&this.pushedVelocity.manhattanLength()===0||this.usePhysics===!1?(this.velocity.x+=(this.velocityTarget.x-this.velocity.x)*(1-(1-this.lerpFactorPos.x)**i),this.velocity.y+=(this.velocityTarget.y-this.velocity.y)*(1-(1-this.lerpFactorPos.y)**i),this.velocity.z+=(this.velocityTarget.z-this.velocity.z)*(1-(1-this.lerpFactorPos.z)**i)):this.velocity.copy(this.velocityTarget),(this.moveMode==="walk"?this.velocity.x**2+this.velocity.z**2<this.speedTranslate:this.velocity.lengthSq()<this.speedTranslate)?(this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.onObject&&(this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"))):(this.dispatchStopEvent("idle"),(this.onObject||this.moveMode==="fly")&&(this.dispatchStopEvent("jump"),this.movementState.run?(this.dispatchStopEvent("move"),this.dispatchStartEvent("run")):(this.dispatchStopEvent("run"),this.dispatchStartEvent("move"))));let s=IPt.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1){let n=Ld.copy(s);n.y=0,s.set(0,s.y,n.length()*(this.forwardDir==="+z"?1:-1))}if(this.directionXZ.manhattanLength()>0&&this.orientMode!=="none"&&this.isFirstPerson===!1)if(this.orientWith==="camera"&&this.path.length<=1){let n=qa;this.camera.getWorldDirection(n);let a=Zy.copy(Eu).multiplyScalar(n.dot(Eu));n.sub(a);let o=Ld.copy(this.directionXZ);o.x*=-1,this.rot.y=n.angleTo(o)*(n.cross(o).y>0?-1:1)+this.rotationAccumWhenOrientWithCamera}else this.rot.y=(this.path.length>1?0:this.euler.y)+Math.atan2(-this.directionXZ.z,this.directionXZ.x)+Math.PI/2*(this.forwardDir==="+z"?1:-1);if(Qy.setFromVector3(this.rot),this.moveMode==="walk"&&(Qy.x=0),s.applyEuler(Qy),r&&(Hf.setFromUnitVectors(Eu,this.groundNormal),s.applyQuaternion(Hf)),this.usePhysics===!0&&this.object.rigidBody){this.pushedVelocity.set(0,0,0);let n=0;for(let a of this.sharedGameControlGlobals.entitiesWithTransformAnim){if(a.rigidBody===void 0||a.prevQ===void 0)continue;(a.hasNonUniformScale?a.matrixWorldRigid:a.matrixWorld).decompose(SF,Lut,zPt);let o=this.object.getWorldPosition(LPt).add(this.collider.position).sub(SF);Fut.copy(a.prevQ).invert().premultiply(Lut);let l=Zy.subVectors(SF,a.prevT).add(FPt.copy(o).applyQuaternion(Fut).sub(o)).divideScalar(e).divideScalar(this.pixelsPerMeter),u=a.rigidBody.collider(0).castCollider(l,this.object.rigidBody.collider(0),qa.copy(s).divideScalar(this.pixelsPerMeter),0,e,!1);l.multiplyScalar(this.pixelsPerMeter);let h=Mi.is(a)?a:a.object;if(u!==null&&this.lastHitObj!==h){let d;a instanceof _l&&(d=a);let c=this.sharedGameControlGlobals.entityToCollisionEvents[h.uuid];if(c)for(let p of c)p.data.target==="character"&&(p.dispatch(d),h.dispatchEvent(h7));this.lastHitObj=h}u!==null&&(Math.abs(l.x)>Math.abs(this.pushedVelocity.x)&&(this.pushedVelocity.x=l.x),Math.abs(l.y)>Math.abs(this.pushedVelocity.y)&&(this.pushedVelocity.y=l.y),Math.abs(l.z)>Math.abs(this.pushedVelocity.z)&&(this.pushedVelocity.z=l.z),zut(n++).copy(u.normal1).applyQuaternion(a.quaternion))}if(n>0){for(let a=0;a<n;a++){let o=zut(a),l=o.dot(s);l<0&&s.addScaledVector(o,-l)}s.add(this.pushedVelocity)}else s.add(this.groundVelocity)}if(this.rotDirection.y=Number(this.movementState.rotPosY)-Number(this.movementState.rotNegY),this.rotDirection.x=Number(this.movementState.rotPosX)-Number(this.movementState.rotNegX),this.rotDirection.normalize(),this.rotationMode==="normal"&&(this.movementState.rotPosX||this.movementState.rotNegX)||this.rotationMode==="steer"&&(this.movementState.rotPosX||this.movementState.rotNegX)&&(this.movementState.movePosZ||this.movementState.moveNegZ||this.moveMode==="walk")?this.rotVelocityStick.x=-this.rotDirection.x*this.speedOrbit*this.rotForce:this.rotVelocityStick.x=0,this.rotationMode==="normal"&&(this.movementState.rotPosY||this.movementState.rotNegY)||this.rotationMode==="steer"&&(this.movementState.rotPosY||this.movementState.rotNegY)&&(this.movementState.movePosZ||this.movementState.moveNegZ)?this.rotVelocityStick.y=-this.rotDirection.y*this.speedOrbit*this.rotForce:this.rotVelocityStick.y=0,this.rotVelocityTarget.subVectors(this.eulerDelta.divideScalar(e),this.rotVelocityStick),this.rotVelocityTarget.manhattanLength()===0?this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotEnd)**i):this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotStart)**i),this.euler.x+=this.rotVelocity.x*e,this.euler.y+=this.rotVelocity.y*e+this.groundYRotation,this.rotVelocityTarget.y===0&&this.directionXZ.manhattanLength()===0?this.rotationAccumWhenOrientWithCamera=0:(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.rotationAccumWhenOrientWithCamera+=this.rotVelocity.y*e),this.isFirstPerson===!1&&this.orientMode!=="none"&&this.directionXZ.manhattanLength()>0){if(this.orientMode==="radial"){this.objectToCamXZ.copy(this.objectToCamXZ0).applyAxisAngle(Eu,this.euler.y-this.euler0.y);let n=Ld.copy(this.objectToCamXZ).normalize(),a=Zy.copy(s).multiplyScalar(e);a.y=0;let o=a.sub(qa.copy(n).multiplyScalar(a.dot(n))).cross(n).y;this.euler.y-=Math.atan2(o,this.objectToCamXZ.length())}}else this.rot.y+=this.rotVelocity.y*e+this.groundYRotation,this.rotVelocityTarget.y!==0&&(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.euler.y=this.rot.y);if(this.cameraFollow===!0&&(this.moveMode==="walk"?this.cameraXAxis==="Limit"?this.euler.x=qt.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):this.euler.x=qt.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset,this.PI_2+this.cameraPolarOffset):this.cameraXAxis==="Limit"&&(this.euler.x=qt.clamp(this.euler.x,-this.PI_2,this.PI_2))),this.moveMode==="fly"?this.rot.x=this.euler.x:this.isFirstPerson&&(Qy.copy(this.euler),Qy.y=0,this.nonColliderRotOffset.makeRotationFromEuler(Qy)),nl.setFromAxisAngle(VPt,this.rot.x),Hf.setFromAxisAngle(Eu,this.rot.y),Hf.multiply(nl),nl.setFromAxisAngle(kPt,this.rot.z),Hf.multiply(nl),this.quaternion.copy(Hf),this.objectRealQuat.multiplyQuaternions(this.quaternion,this.objXZQuat),this.colliderWorldQuat.copy(this.objectRealQuat).multiply(this.collider.rotation),this.collisionEnabled)if(this.usePhysics&&this.object.rigidBody?.collider(0).shape){let n=Ld.copy(s).multiplyScalar(e/this.pixelsPerMeter),a=null;this.didHit=!1;let o=new P;for(let h=0;h<5;h++){let d=n.length(),c=Zy.copy(n).normalize();if(a=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(o),this.colliderWorldQuat,c,this.object.rigidBody.collider(0).shape,0,d,!1,12,void 0,void 0,this.object.rigidBody),a===null){h===0&&this.directionXZ.manhattanLength()!==0&&(this.lastHitObj=null),o.add(n);break}{this.didHit=!0;let p=this.sharedGameControlGlobals.colliderToEntity.get(a.collider.handle);if(p!==this.lastHitObj&&h===0){this.lastHitObj=p;let y=this.sharedGameControlGlobals.entityToCollisionEvents[p?.uuid];if(y){for(let v of y)if(v.data.target==="character"){let b,_=(this.sharedGameControlGlobals.rapierWorld?.getCollider(a.collider.handle))._parent;if(p.cloner){for(let x of p.cloner.children)if(x.rigidBody===_){b=x;break}}v.dispatch(b),p.dispatchEvent(h7)}}}let m=Out.set(a.normal2.x,a.normal2.y,a.normal2.z).applyQuaternion(this.colliderWorldQuat),f=Iut.copy(c).multiplyScalar(a.time_of_impact).dot(m),g=a.time_of_impact;if(g===0&&(this.position.y+=this.offset*this.pixelsPerMeter),f>this.offset&&(g=a.time_of_impact*(f-this.offset)/f,o.addScaledVector(c,g)),n.copy(c).multiplyScalar(d-g),Math.acos(-m.y)>this.slopeThresh){let y=this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(o),v=Zy.copy(a.witness2).applyQuaternion(this.colliderWorldQuat);v.y=0;let b=y.add(v);b.y+=this.stepThresh;let _=this.sharedGameControlGlobals.rapierWorld.castShape(b,this.colliderWorldQuat,n,this.object.rigidBody?.collider(0).shape,0,1,!1,12,void 0,void 0,this.object.rigidBody);_!==null&&_.time_of_impact===0&&(m.y=0,m.normalize())}n.addScaledVector(m,-n.dot(m))}}this.position.addScaledVector(o,this.pixelsPerMeter),qa.copy(this.position).divideScalar(this.pixelsPerMeter),nl.copy(this.quaternion).premultiply(this.groundTilt).multiply(this.objXZQuat);let l=this.object.rigidBody,u=l!==void 0&&UPt.copy(qa).sub(l.translation()).lengthSq()>1;l!==void 0&&(u?(l.setTranslation(qa,!0),l.setRotation(nl,!0)):(l.setNextKinematicTranslation(qa),l.setNextKinematicRotation(nl)))}else{let n=this.onObject?1:5,a=s.multiplyScalar(e/n);for(let o=0;o<n;o++)this.position.add(a),this.collisionAdjustment(e/n)}else this.position.addScaledVector(s,e);if(this.moveMode==="walk"&&this.onObject&&(this.velocityTarget.y=0,this.velocity.y=0),this.quaternion.premultiply(this.groundTilt).multiply(this.objXZQuat),this.object.matrix.compose(this.position,this.quaternion,this.scale),this.object.matrixWorldNeedsUpdate=!0,this.object.matrix.multiply(this.nonColliderPosOffset).multiply(this.nonColliderRotOffset),this.quaternion.premultiply(this.groundTiltInv).multiply(this.objXZQuatInv),this.cameraFollow===!0){this.updateFollowArms();let n=this.objectToTarget.add(this.position),a=this.targetToCamera.add(n);wF.lookAt(a,n,Eu).setPosition(a),wF.decompose(this.targetPos,this.targetQuat,qa),this.camera.quaternion.slerp(this.targetQuat,1-(1-this.lerpFactorRotCamera)**i),this.camera.position.lerp(this.targetPos,1-(1-this.lerpFactorPosCamera)**i),this.camera.updateMatrix(),this.camera.updateMatrixWorld(),this.cameraYAxis==="Limit"&&this.orientMode==="cartesian"&&(this.euler.y=qt.clamp(this.euler.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel)),this.euler.x=qt.clamp(this.euler.x,-this.PI_2+(this.cameraPolarOffset<0?this.cameraPolarOffset:0),this.PI_2+(this.cameraPolarOffset>0?this.cameraPolarOffset:0))}return this.eulerDelta.set(0,0,0),this.object.dispatchEvent(GPt),!(this.path.length<2&&this.lastPosition.distanceToSquared(this.position)<this.threshEndTranslate&&Math.abs(this.rotVelocity.x)<this.threshEndRotVel&&Math.abs(this.rotVelocity.y)<this.threshEndRotVel&&(this.camera===void 0||this.isFirstPerson||this.lastCameraPosition.distanceToSquared(this.camera.position)<this.threshEndTranslate&&8*(1-this.lastCameraQuaternion.dot(this.camera.quaternion))<this.threshEndRotate)&&(this.moveMode==="fly"||this.onObject===!0||this.collisionEnabled===!1)&&(this.navMeshPathDest===null||this.navMeshPathDest.material.opacity<-.04*this.navMeshPathDest?.material?.userData.opacity0)||(this.camera&&(this.lastCameraPosition.copy(this.camera.position),this.lastCameraQuaternion.copy(this.camera.quaternion)),this.lastPosition.copy(this.position),this.object.dispatchEvent(jPt),0))}updateFollowArms(){this.objectToTarget.copy(this.objectToTarget0),this.targetToCamera.copy(this.targetToCamera0);let t,e=nl.setFromAxisAngle(Eu,this.cameraYAxis==="Limit"&&this.orientMode!=="radial"?qt.clamp(this.euler.y-this.euler0.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel):this.euler.y-this.euler0.y);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&this.objectToTarget.applyQuaternion(e),t=this.cameraXAxis==="Limit"?qt.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):qt.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset+1e-6,this.PI_2+this.cameraPolarOffset-1e-6);let i=qa.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&i.applyQuaternion(e);let r=Hf.setFromAxisAngle(i,t);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(e),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(r)}groundTiltAdjustment(t){180*Eu.angleTo(t)/Math.PI<15||180*Eu.angleTo(t)/Math.PI>85?nl.identity():nl.setFromUnitVectors(Eu,t),this.groundTilt.slerp(nl,.06),this.groundTiltInv.copy(this.groundTilt).invert()}collisionAdjustment(t){let e=Iut.set(0,0,0);this.object.matrix.compose(this.position,this.quaternion,this.scale);let i=wF.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(qa,nl,Ld).compose(qa,nl,Vut);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(s=>{if(s===this.object||s.isDescendantOf(this.object)||!s.bvhGeometry||!s.bvhGeometry.boundsTree)return;ql.makeEmpty(),s.updateMatrixWorldRigid();let n=s.matrixWorldRigid,a=But.copy(n).invert(),o=BPt.copy(But).multiply(i);Hn.copy(this.collider.segment),Hn.start.applyMatrix4(o),Hn.end.applyMatrix4(o);let l=Out.copy(this.position).applyMatrix4(a);ql.expandByPoint(Hn.start),ql.expandByPoint(Hn.end),ql.min.addScalar(-this.collider.radius),ql.max.addScalar(this.collider.radius),s.bvhGeometry.boundsTree.shapecast({boundsTraverseOrder:u=>u.distanceToPoint(Hn.end),intersectsBounds:u=>u.intersectsBox(ql),intersectsTriangle:u=>{let h=qa,d=Ld,c=u.closestPointToSegment(Hn,h,d);if(c<this.collider.radius){let p=this.collider.radius-c,m=d.sub(h).normalize(),f=Zy.copy(l);f.addScaledVector(m,p);let g=f.applyMatrix4(n).sub(this.position);e.add(g),Hn.start.addScaledVector(m,p),Hn.end.addScaledVector(m,p)}}})}),ql.makeEmpty(),Hn.copy(this.collider.segment),Hn.start.applyMatrix4(i),Hn.end.applyMatrix4(i),ql.expandByPoint(Hn.start),ql.expandByPoint(Hn.end),ql.min.addScalar(-this.collider.radius),ql.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({boundsTraverseOrder:s=>s.distanceToPoint(Hn.end),intersectsBounds:s=>s.intersectsBox(ql),intersectsTriangle:s=>{let n=qa,a=Ld,o=s.closestPointToSegment(Hn,n,a);if(o<this.collider.radius){let l=this.collider.radius-o,u=a.sub(n).normalize();this.alignToGround&&this.groundTiltAdjustment(u),e.addScaledVector(u,l),Hn.start.addScaledVector(u,l),Hn.end.addScaledVector(u,l)}}}),this.onObject=Math.abs(e.y)>Math.abs(t*this.velocity.y*.25),this.onObject&&this.dispatchStopEvent("jump");let r=Math.max(0,e.length()-1e-5);e.normalize().multiplyScalar(r),this.position.add(e)}pause(){this.firstPointerId=-1,this.movementState={moveNegZ:0,movePosZ:0,moveNegX:0,movePosX:0,moveNegY:0,movePosY:0,rotPosX:0,rotNegX:0,rotPosY:0,rotNegY:0,jump:0,run:0},this.deactivate()}resume(){this.activate()}},r_t=u7;r_t.isLocked=!1,dt(),KS(),Y5(),Jv(),Zv();var s_t,n_t,TF,WPt=new Promise(t=>{s_t=t});function qPt(t){return TF||(TF=async function(){let e=t??"https://cdn.spline.design/@splinetool/runtime@2.0.61/build";typeof window<"u"&&(n_t=new URL(e.endsWith("/")?e:`${e}/`,window.location.href).href);let i=import("./navmesh.js"),[r,s]=await Promise.all([i,fetch(`${e}/navmesh.wasm`).then(o=>o.arrayBuffer())]),n=r.default,a=await n({wasmBinary:s});s_t(a)}(),TF)}ir();var a_t,Ni,_a,HPt=t=>`
|
|
5093
5093
|
(async function() {
|
|
5094
5094
|
const [wasmImport, wasmBinary] = await Promise.all([
|
|
5095
5095
|
import('${t}' + 'navmesh.js'),
|
|
@@ -5099,7 +5099,7 @@ void main() {
|
|
|
5099
5099
|
self.module = await wasmModule({ wasmBinary });
|
|
5100
5100
|
postMessage('ready');
|
|
5101
5101
|
})();
|
|
5102
|
-
`,$Pt={cs:6,ch:2,walkableSlopeAngle:90,walkableHeight:20,walkableClimb:5,walkableRadius:0,maxEdgeLen:12,maxSimplificationError:1.3,minRegionArea:8,mergeRegionArea:20,maxVertsPerPoly:6,detailSampleDist:6,detailSampleMaxError:1};WPt.then(t=>{a_t=t,Ni=new t.Vec3,_a=new t.Vec3});var XPt=new P,YPt=class{constructor(t=!1,e=!1){this.usePhysics=t,this.isExport=e,this.onPointerDown=i=>{if(Ge.length!==1)return;let{raycaster:r,page:s}=this.eventContext;this.eventContext.updateRaycaster(i);let n=s.raycastWithClones(r);if(n.length!==0){if(this.gameControl){let a=XPt.copy(this.gameControl.colliderWorldPosition);a.y-=this.gameControl.colliderHeight/2,this.gameControl.path=this.computePath(a,n[0].point)}this.eventContext.requestRender()}},this.traverseWithPhysics=(i,r)=>s=>{let n;if(s instanceof dm){if(!s.objectForSample)return s.object.dataPatched.physics.fusedBody===!0&&s.object.dataPatched.physics.rigidBody==="dynamic"||void 0;if(s.objectForSample.dataPatched.physics.fusedBody)return;n=s.object}else if(s instanceof _l)n=s.object;else if(n=s,n.dataPatched.cloner?.disabled===!1&&n.dataPatched.cloner?.hideBase&&n.dataPatched.physics?.fusedBody!==!0)return!0;if(r&&!n.userData.navmesh)return;let a=n.dataPatched;if(!a.visible&&a.physics?.enabled!==!0)return!0;s.updateMatrixWorldRigid();let o=f5(a),l=n.userData.hasDestroy,u=n.userData.hasDrag,h=!1,d=!1;for(let c of a.events)c.data.disabled!==!0&&(c.data.type==="GameControl"?h=!0:c.data.type==="Follow"&&(d=!0));if(h||o||d||l||u)return!0;if(this.usePhysics&&a.physics?.rigidBody==="dynamic"){if(this.usePhysics&&a.physics?.fusedBody)return!0}else if("geometry"in s&&s.geometry&&i.push(ac(s.geometry,s.matrixWorld)),this.usePhysics&&a.physics?.fusedBody)return s.traverseObject((c,p)=>{if(p===0)return;let m;if(c instanceof dm){if(!c.objectForSample)return c.object.dataPatched.physics.fusedBody===!0&&c.object.dataPatched.physics.rigidBody==="dynamic"||void 0;if(c.objectForSample.dataPatched.physics.fusedBody)return;m=c.object}else if(c instanceof _l)m=c.object;else if(m=c,c.dataPatched.cloner?.hideBase)return!0;let f=m.dataPatched;if(!f.visible&&f.physics?.enabled!==!0)return!0;"geometry"in c&&c.geometry&&i.push(ac(c.geometry,c.matrixWorld))}),!0},this.traverseNoPhysics=(i,r)=>s=>{let n;if(s instanceof dm)return;n=s instanceof _l?s.object:s;let a=n.dataPatched;if(a.physics.enabled==="visibility"?!a.visible:!a.physics.enabled)return!0;if(r&&!n.userData.navmesh)return;let o=s.geometry,l=n.userData.hasDestroy===!0,u=n.userData.hasDrag===!0;if(f5(a)||l||u||n.dataPatched.events.some(h=>h.data.disabled!==!0&&h.data.type==="GameControl"))return!0;o&&i.push(ac(o,s.matrixWorld))},this.navmeshWasm=a_t,this.navMesh=new this.navmeshWasm.NavMesh,this._workerURL=URL.createObjectURL(new Blob([(e?HPt(n_t??"https://cdn.spline.design/@splinetool/runtime@2.0.
|
|
5102
|
+
`,$Pt={cs:6,ch:2,walkableSlopeAngle:90,walkableHeight:20,walkableClimb:5,walkableRadius:0,maxEdgeLen:12,maxSimplificationError:1.3,minRegionArea:8,mergeRegionArea:20,maxVertsPerPoly:6,detailSampleDist:6,detailSampleMaxError:1};WPt.then(t=>{a_t=t,Ni=new t.Vec3,_a=new t.Vec3});var XPt=new P,YPt=class{constructor(t=!1,e=!1){this.usePhysics=t,this.isExport=e,this.onPointerDown=i=>{if(Ge.length!==1)return;let{raycaster:r,page:s}=this.eventContext;this.eventContext.updateRaycaster(i);let n=s.raycastWithClones(r);if(n.length!==0){if(this.gameControl){let a=XPt.copy(this.gameControl.colliderWorldPosition);a.y-=this.gameControl.colliderHeight/2,this.gameControl.path=this.computePath(a,n[0].point)}this.eventContext.requestRender()}},this.traverseWithPhysics=(i,r)=>s=>{let n;if(s instanceof dm){if(!s.objectForSample)return s.object.dataPatched.physics.fusedBody===!0&&s.object.dataPatched.physics.rigidBody==="dynamic"||void 0;if(s.objectForSample.dataPatched.physics.fusedBody)return;n=s.object}else if(s instanceof _l)n=s.object;else if(n=s,n.dataPatched.cloner?.disabled===!1&&n.dataPatched.cloner?.hideBase&&n.dataPatched.physics?.fusedBody!==!0)return!0;if(r&&!n.userData.navmesh)return;let a=n.dataPatched;if(!a.visible&&a.physics?.enabled!==!0)return!0;s.updateMatrixWorldRigid();let o=f5(a),l=n.userData.hasDestroy,u=n.userData.hasDrag,h=!1,d=!1;for(let c of a.events)c.data.disabled!==!0&&(c.data.type==="GameControl"?h=!0:c.data.type==="Follow"&&(d=!0));if(h||o||d||l||u)return!0;if(this.usePhysics&&a.physics?.rigidBody==="dynamic"){if(this.usePhysics&&a.physics?.fusedBody)return!0}else if("geometry"in s&&s.geometry&&i.push(ac(s.geometry,s.matrixWorld)),this.usePhysics&&a.physics?.fusedBody)return s.traverseObject((c,p)=>{if(p===0)return;let m;if(c instanceof dm){if(!c.objectForSample)return c.object.dataPatched.physics.fusedBody===!0&&c.object.dataPatched.physics.rigidBody==="dynamic"||void 0;if(c.objectForSample.dataPatched.physics.fusedBody)return;m=c.object}else if(c instanceof _l)m=c.object;else if(m=c,c.dataPatched.cloner?.hideBase)return!0;let f=m.dataPatched;if(!f.visible&&f.physics?.enabled!==!0)return!0;"geometry"in c&&c.geometry&&i.push(ac(c.geometry,c.matrixWorld))}),!0},this.traverseNoPhysics=(i,r)=>s=>{let n;if(s instanceof dm)return;n=s instanceof _l?s.object:s;let a=n.dataPatched;if(a.physics.enabled==="visibility"?!a.visible:!a.physics.enabled)return!0;if(r&&!n.userData.navmesh)return;let o=s.geometry,l=n.userData.hasDestroy===!0,u=n.userData.hasDrag===!0;if(f5(a)||l||u||n.dataPatched.events.some(h=>h.data.disabled!==!0&&h.data.type==="GameControl"))return!0;o&&i.push(ac(o,s.matrixWorld))},this.navmeshWasm=a_t,this.navMesh=new this.navmeshWasm.NavMesh,this._workerURL=URL.createObjectURL(new Blob([(e?HPt(n_t??"https://cdn.spline.design/@splinetool/runtime@2.0.61/build/"):`
|
|
5103
5103
|
(async function() {
|
|
5104
5104
|
const [wasmImport, wasmBinary] = await Promise.all([
|
|
5105
5105
|
import(self.location.origin + '/_libraries/navmesh.js'),
|
|
@@ -5174,7 +5174,7 @@ onmessage = function(messageEvent) {
|
|
|
5174
5174
|
[${P4}] { pointer-events: none; }
|
|
5175
5175
|
[${P4}] > * { pointer-events: auto; }
|
|
5176
5176
|
[${P4}] [data-spline-passthrough] { pointer-events: none; }
|
|
5177
|
-
`,O_t=class{constructor(t,e,i,r,s,n){this.container=t,this.host=e,this.observer=i,this.spline=r,this.previousSplineGlobal=s,this.removeLateLifecycleShim=n}static mount(t,e,i,r){if(typeof document>"u")return null;let s=e.parentElement;if(!s)return null;getComputedStyle(s).position==="static"&&(s.style.position="relative");let n=document.createElement("div");n.setAttribute(P4,"");let a=n.style;a.position="absolute",a.overflow="hidden";let o=()=>{a.left=`${e.offsetLeft}px`,a.top=`${e.offsetTop}px`,a.width=`${e.offsetWidth}px`,a.height=`${e.offsetHeight}px`};o();let l=new ResizeObserver(o);l.observe(e),l.observe(s);let u=document.createElement("style");u.textContent=S5t,n.appendChild(u);let h=new DOMParser().parseFromString(i,"text/html"),d=Array.from(h.querySelectorAll("script"));for(let v of d)v.remove();for(let v of Array.from(h.head.children))(v.tagName==="STYLE"||v.tagName==="LINK"&&v.rel==="stylesheet")&&n.appendChild(v);for(;h.body.firstChild;)n.appendChild(h.body.firstChild);s.insertBefore(n,e.nextSibling);let c=new Map,p=new H7(D_t(t,e,r),(v,b)=>{v==="warn"?console.warn(`[spline html] ${b}`):v==="error"&&console.error(`[spline html] ${b}`)},(v,b)=>{let _=c.get(v);if(_)for(let x of _)try{x(b)}catch(S){console.error(S)}}),m=(v,b)=>{try{return Promise.resolve(p.execute(v,b))}catch(_){return Promise.reject(_)}},f={ready:Promise.resolve(),setVariable:(v,b)=>m("setVariable",[v,b]),setVariables:v=>m("setVariables",[v]),getVariable:v=>m("getVariable",[v]),getVariables:()=>m("getVariables",[]),getAllObjects:()=>m("getAllObjects",[]),findObjectByName:v=>m("findObjectByName",[v]),findObjectById:v=>m("findObjectById",[v]),getGeometry:(v,b)=>m("getGeometry",[v,b??{}]),updateObject:(v,b)=>m("updateObject",[v,b]),createObject:(v,b)=>m("createObject",[v,b??{}]),createCustomMaterial:v=>m("createCustomMaterial",[v]),getTexture:(v,b)=>m("getTexture",[v,b??{}]),setMaterial:(v,b)=>m("setMaterial",[v,b]),cloneObject:(v,b)=>m("cloneObject",[v,b??{}]),removeObject:v=>m("removeObject",[v]),spawnObject:(v,b)=>m("spawnObject",[v,b??{}]),destroyObject:v=>m("destroyObject",[v]),setInstanceTransforms:(v,b)=>m("setInstanceTransforms",[v,b??null]),emitEvent:(v,b)=>m("emitEvent",[v,b]),emitEventReverse:(v,b)=>m("emitEventReverse",[v,b]),requestRender:()=>m("requestRender",[]),addEventListener:(v,b)=>{if(typeof b!="function")return;let _=c.get(v);_||(_=new Set,c.set(v,_),m("listenEvent",[v])),_.add(b)},removeEventListener:(v,b)=>{let _=c.get(v);!_||(_.delete(b),_.size===0&&(c.delete(v),m("unlistenEvent",[v])))}},g=window.spline;window.spline=f;let y=function(){if(typeof document>"u"||document.readyState==="loading")return()=>{};let v=[],b=(x,S)=>{let w=new Set,T=x.addEventListener.bind(x),A=x.removeEventListener.bind(x);Object.defineProperty(x,"addEventListener",{configurable:!0,writable:!0,value:(M,C,R)=>{if(T(M,C,R),!S.includes(M)||C==null)return;let O={type:M,listener:C};w.add(O),queueMicrotask(()=>{!w.delete(O)||((N,B,k)=>{let z=new Event(k);try{typeof B=="function"?B.call(N,z):B.handleEvent?.(z)}catch(L){console.error(L)}})(x,O.listener,O.type)})}}),Object.defineProperty(x,"removeEventListener",{configurable:!0,writable:!0,value:(M,C,R)=>{A(M,C,R);for(let O of w)O.type===M&&O.listener===C&&w.delete(O)}}),v.push(()=>{delete x.addEventListener,delete x.removeEventListener,w.clear()})};b(document,["DOMContentLoaded"]),b(window,["load"]);let _=Object.getOwnPropertyDescriptor(window,"onload");return Object.defineProperty(window,"onload",{configurable:!0,get:()=>null,set:x=>{typeof x=="function"&&queueMicrotask(()=>{try{x.call(window,new Event("load"))}catch(S){console.error(S)}})}}),v.push(()=>{_?Object.defineProperty(window,"onload",_):delete window.onload}),()=>{for(let x of v)x()}}();for(let v of d){let b=document.createElement("script");for(let _ of Array.from(v.attributes))b.setAttribute(_.name,_.value);v.src?b.async=!1:b.textContent=v.textContent,n.appendChild(b)}return new O_t(n,p,l,f,g,y)}dispose(){this.removeLateLifecycleShim(),this.host.dispose(),this.observer.disconnect(),this.container.remove(),window.spline===this.spline&&(window.spline=this.previousSplineGlobal)}};function I_t(t){return typeof t=="object"&&t!==null&&t.isMaterial===!0}function Wdt(t){if(typeof t.material=="function")throw new Error("createObject: a (three) => material factory must be resolved to a material instance before object creation \u2014 this entry point does not support it.");if(!I_t(t.material))return{options:t};let e=t.material;if(e.isNodeMaterial===!0){let i=KU()?.NodeMaterial;if(i!==void 0&&e instanceof i)return{options:{...t,material:void 0},material:e};throw new Error("createObject: this TSL NodeMaterial comes from your own three/webgpu module instance, which cannot compile in the runtime's bundled three. Build it with app.createCustomMaterial((three) => \u2026) instead, or use a built-in material (MeshStandardMaterial, MeshBasicMaterial, \u2026).")}if(e.isShaderMaterial===!0)throw new Error("createObject: a GLSL ShaderMaterial cannot compile on the WebGPU backend \u2014 port the shader to TSL with app.createCustomMaterial((three) => \u2026), or use a built-in material (MeshStandardMaterial, \u2026).");return{options:{...t,material:void 0},material:e}}ke(),Fi(),dt(),_gt(),Rc(),Fi(),ke(),UMt(),wm();var T5t=new Set(["name","parent","position","rotation","scale","visible","castShadow","receiveShadow","color","material"]),qdt="'Cube', 'Sphere', 'Plane', 'Rectangle', 'Ellipse', 'Triangle', 'Polygon', 'Star', 'Cone', 'Cylinder', 'Pyramid', 'Torus', 'TorusKnot', 'Dodecahedron', 'Icosahedron', 'Helix', 'Backdrop', 'Lathe', 'Text', 'CustomMesh', 'Group', 'PointLight', 'SpotLight', 'DirectionalLight'",M5t={cube:"CubeGeometry",box:"CubeGeometry",sphere:"SphereGeometry",plane:"PlaneGeometry",rectangle:"RectangleGeometry",ellipse:"EllipseGeometry",circle:"EllipseGeometry",triangle:"TriangleGeometry",polygon:"PolygonGeometry",star:"StarGeometry",cone:"ConeGeometry",cylinder:"CylinderGeometry",pyramid:"PyramidGeometry",torus:"TorusGeometry",torusknot:"TorusKnotGeometry",dodecahedron:"DodecahedronGeometry",icosahedron:"IcosahedronGeometry",helix:"HelixGeometry",backdrop:"BackdropGeometry",lathe:"LatheGeometry",text:"TextGeometry",custommesh:"NonParametricGeometry",nonparametric:"NonParametricGeometry"},A5t={group:"Empty",empty:"Empty",pointlight:"PointLight",spotlight:"SpotLight",directionallight:"DirectionalLight"},C5t={shapeblend:"Shape Blends are built from member meshes in the editor and cannot be created empty.",path:"Path shapes need authored path data \u2014 clone an existing one with cloneObject() instead.",vector:"Vector shapes need authored shape data \u2014 clone an existing one with cloneObject() instead.",shape:"Vector shapes need authored shape data \u2014 clone an existing one with cloneObject() instead.",boolean:"Boolean operations are not creatable at runtime \u2014 clone an existing Boolean object with cloneObject() instead.",decal:"Decals need a surface to project onto \u2014 clone an existing Decal with cloneObject() instead.",ui:"UI objects need a 2D frame \u2014 clone an existing one with cloneObject() instead.",input:"Text inputs are not creatable at runtime \u2014 clone an existing one with cloneObject() instead.",particle:"Particle emitters are not creatable at runtime \u2014 clone an existing one with cloneObject() instead.",particlecollider:"Particle forces are not creatable at runtime \u2014 clone an existing one with cloneObject() instead.",hair:"Hair systems are not creatable at runtime \u2014 clone an existing one with cloneObject() instead.",camera:"Cameras are not creatable at runtime.",perspectivecamera:"Cameras are not creatable at runtime.",orthographiccamera:"Cameras are not creatable at runtime.",hemispherelight:"Hemisphere lights are not creatable at runtime.",splat:"Splats are not creatable at runtime.",page:"Pages are not creatable at runtime.",component:"Components are authored in the editor.",instance:"Instances are authored in the editor \u2014 clone an existing one with cloneObject() instead.",bone:"Bones are not creatable at runtime.",mesh:"pass the shape name directly, e.g. createObject('Cube')."},E5t={CubeGeometry:"Cube",SphereGeometry:"Sphere",PlaneGeometry:"Plane",RectangleGeometry:"Rectangle",EllipseGeometry:"Ellipse",TriangleGeometry:"Triangle",PolygonGeometry:"Pentagon",StarGeometry:"Star",ConeGeometry:"Cone",CylinderGeometry:"Cylinder",PyramidGeometry:"Pyramid",TorusGeometry:"Torus",TorusKnotGeometry:"Torus Knot",DodecahedronGeometry:"Dodecahedron",IcosahedronGeometry:"Icosahedron",HelixGeometry:"Helix",BackdropGeometry:"Backdrop",LatheGeometry:"Lathe",TextGeometry:"Text",NonParametricGeometry:"Custom Mesh"},P5t={Empty:"Group",PointLight:"Point Light",SpotLight:"Spot Light",DirectionalLight:"Directional Light"};function HS(t,e){return t===void 0?[e[0],e[1],e[2]]:Array.isArray(t)?[t[0]??e[0],t[1]??e[1],t[2]??e[2]]:[t.x??e[0],t.y??e[1],t.z??e[2]]}function B_t(t){return typeof t=="number"?[t,t,t]:HS(t,[1,1,1])}function P7(t){let e=new Dr(0,0,0,1);return e.setStyle(t),{r:e.r,g:e.g,b:e.b}}function Hdt(t,e){let i=t.material??(t.color!==void 0?{color:t.color}:void 0);if(i===void 0)return cs.defaultColorMaterial($dt(Kg),"physical","layer1","layer2");if(typeof i=="string"){for(let[a,o]of Object.entries(e.shared.materials))if(a===i||o.name===i)return a;if(function(a){let o=a.trim().toLowerCase();return/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(o)||/^(rgb|hsl)a?\(/.test(o)||ae.NAMES[o]!==void 0}(i))return cs.defaultColorMaterial(P7(i),"physical","layer1","layer2");throw new Error(`createObject: material '${i}' matches no shared material in this document (available: ${function(a){let o=Object.entries(a.shared.materials).map(([,l])=>`'${l.name}'`).filter(l=>l!=="'undefined'");return o.length?o.join(", "):"(none)"}(e)}) and is not a valid CSS color.`)}if(typeof i=="function")throw new Error("createObject: a (three) => material factory must be resolved to a material instance before object creation \u2014 this entry point does not support it.");if(I_t(i))throw new Error("createObject: a three.js material instance cannot be stored in the document \u2014 this entry point does not support it.");let r=i.color!==void 0?P7(i.color):$dt(Kg),s=cs.defaultColorMaterial(r,"physical","layer1","layer2"),n=s.layers.find(a=>a.data.type==="light");if(n){let a={};i.roughness!==void 0&&(a.roughness=i.roughness),i.metalness!==void 0&&(a.metalness=i.metalness),i.reflectivity!==void 0&&(a.reflectivity=i.reflectivity),Object.assign(n.data,a)}if(i.alpha!==void 0){let a=s.layers.find(o=>o.data.type==="color");a&&Object.assign(a.data,{alpha:i.alpha})}return s}function $dt(t){return{r:(t>>16&255)/255,g:(t>>8&255)/255,b:(255&t)/255}}function R5t(t){let e=lc.defaultData("TextGeometry"),{text:i,...r}=t,s=r.fontSize;return s!==void 0&&r.width===void 0&&(r.width=350*s/16),s!==void 0&&r.height===void 0&&(r.height=50*s/16),Object.assign(e,r),i!==void 0&&Object.assign(e,{text:{textValue:String(i)}}),e}function oP(t){return Array.isArray(t)?t:!ArrayBuffer.isView(t)||t instanceof DataView?null:Array.from(t)}function D5t(t,e){return $mt({userData:{type:t,...XU[t].normalizeInputs({parameters:e})}})}function N5t(t,e,i){let{objectType:r,geometryType:s}=t,n=function(l){let u={};for(let[h,d]of Object.entries(l))!T5t.has(h)&&d!==void 0&&(u[h]=d);return u}(e),a={states:new ge,events:new ge};if(r==="Mesh"&&s){if(s==="NonParametricGeometry"){let{geometry:l,doubleSide:u}=function(h){let d=oP(h.vertices);if(!d||d.length<9||d.length%3!=0)throw new Error("createObject('CustomMesh'): `vertices` must be a flat number[] of x,y,z triples (length a multiple of 3, at least one triangle).");let c=d.length/3;if(c>6e4)throw new Error(`createObject('CustomMesh'): too many vertices (${c}); keep it under 60000.`);let p=oP(h.indices);if(p&&p.length){let b=p.find(_=>!Number.isInteger(_)||_<0||_>=c);if(b!==void 0)throw new Error(`createObject('CustomMesh'): index ${b} is out of range (mesh has ${c} vertices).`)}else p=null;let m=new ye;m.setAttribute("position",new fe(d,3));let f=oP(h.normals),g=f!==null&&f.length===d.length;g&&m.setAttribute("normal",new fe(f,3));let y=oP(h.uvs);y&&y.length===2*c&&m.setAttribute("uv",new fe(y,2));let v=!1;if(!g){let b=p??Array.from({length:c},(S,w)=>w),{closed:_,inverted:x}=function(S,w){let T=S.length/3,A=new Map,M=new Array(T);for(let N=0;N<T;N++){let B=`${Math.round(1e4*S[3*N])},${Math.round(1e4*S[3*N+1])},${Math.round(1e4*S[3*N+2])}`,k=A.get(B);k===void 0?(A.set(B,N),M[N]=N):M[N]=k}let C=new Map;for(let N=0;N+2<w.length;N+=3){let B=M[w[N]],k=M[w[N+1]],z=M[w[N+2]];for(let[L,V]of[[B,k],[k,z],[z,B]]){if(L===V)continue;let q=L<V?L+"_"+V:V+"_"+L;C.set(q,(C.get(q)??0)+1)}}let R=C.size>0;for(let N of C.values())if(N!==2){R=!1;break}if(!R)return{closed:!1,inverted:!1};let O=0;for(let N=0;N+2<w.length;N+=3){let B=3*w[N],k=3*w[N+1],z=3*w[N+2],L=S[B],V=S[B+1],q=S[B+2],j=S[k],Q=S[k+1],it=S[k+2],at=S[z],St=S[z+1],yt=S[z+2];O+=L*(Q*yt-it*St)+V*(it*at-j*yt)+q*(j*St-Q*at)}return{closed:!0,inverted:O<0}}(d,b);if(_&&x){for(let S=0;S+2<b.length;S+=3){let w=b[S+1];b[S+1]=b[S+2],b[S+2]=w}p=b}else _||(v=!0)}return p&&m.setIndex(p),g||m.computeVertexNormals(),{geometry:$mt({userData:{type:"NonParametricGeometry",parameters:{subdivisions:0}},data:m.toJSON().data}),doubleSide:v}}(n);Object.assign(a,Bu.defaultData,{geometry:l,materials:[Hdt(e,i)]}),u&&(a.side=2)}else Object.assign(a,Bu.defaultData,{geometry:s==="TextGeometry"?R5t(n):D5t(s,n),material:Hdt(e,i)});e.castShadow!==void 0&&(a.castShadow=e.castShadow),e.receiveShadow!==void 0&&(a.receiveShadow=e.receiveShadow)}else r==="Empty"?Object.assign(a,cR.defaultData):(Object.assign(a,pR.defaultData(r),n),e.color!==void 0&&(a.color=P7(e.color)));a.visible=e.visible??!0,a.position=HS(e.position,[0,0,0]),a.rotation=HS(e.rotation,[0,0,0]),a.scale=B_t(e.scale);let o=(s&&E5t[s])??P5t[r]??r;return a.name=e.name??V_t(o,i.scene.objects),a}function V_t(t,e){let i=new Set;if(e.traverse((s,n)=>{i.add(n.name??"")}),!i.has(t))return t;let r=2;for(;i.has(`${t} ${r}`);)r++;return`${t} ${r}`}function k_t(t,e){let i=qt.generateUUID();if(t.data.type==="Component")return{data:{...yc.fromComponentData(t),name:t.data.name+" Instance"},id:i,fi:t.fi,children:[]};e[t.id]=i;let r=t.data;return r.type==="Empty"&&r.animations?.length&&(r={...r,animations:r.animations.map(([s,n,a])=>{let o=qt.generateUUID(),l=a.indexOf(s);return[o,n,l!==-1?a.slice(0,l)+o+a.slice(l+s.length):a]})}),{...t,id:i,data:r,children:t.children.map(s=>k_t(s,e))}}function O5t(t){let e={};return function(i,r){return nv(i,r,null)??i}(k_t(t,e),e)}function I5t(t){let e=Array.isArray(t)?t[0]:t,i=e.layers?.map(B5t)??[],r=e.layers?.find(s=>s.type==="light");return{layers:i,alpha:r?.node.alphaOverride?.value??1}}function B5t(t){return t.type==="texture"||t.type==="video"||t.type==="matcap"?{...t.data,updateTexture:e=>t.color.texture.image.updateSrc(e)}:{...t.data}}wm(),ns(),wG(),Rc();var Ew=new Dr(0,0,0,1),V5t={color:["color"],cavity:[],dust:["color"],fresnel:["color"],normal:[],gradient:["colors"],depth:["colors"],texture:[],video:[],noise:["colorA","colorB","colorC","colorD"],toon:["colors","shadowColor"],outline:["outlineColor","contourColor"],transmission:["attenuationColor"],reflection:[],matcap:[],pattern:["colorA","colorB"],vertexColor:[],light:[],displace:[],rainbow:[],particle:[]};ke(),ke();var k5t=new Z;function Xdt(t){let e=new Dr(0,0,0,1);try{e.setStyle(t)}catch(i){console.error(i)}return e}var z_t=class{constructor(t,{renderOnDemand:e,renderMode:i="auto",wasmPath:r,renderer:s,htmlContentMode:n="sandbox"}={}){if(this._rendererBackend="webgl",this._rendererAuto=!1,this._rendererConfigured=!1,this._viewportMode=1,this._viewportWidth=window.innerWidth,this._viewportHeight=window.innerHeight,this._proxyObjectCache=new Map,this._htmlContentMode="sandbox",this._variablesCache=new Map,this._isPaused=!1,this._renderRequested=!1,this._skipRender=!1,this.time=performance.now(),this.dt=0,this.currentTAAFrame=0,this.disposed=!1,this._requestRenderAutoMode=()=>{this._skipRender=!1},this.requestRender=()=>{this._renderRequested=!0},this.render=a=>{if(this.time=a,this._lastTime&&(this.dt=this.time-this._lastTime),this._lastTime=this.time,this._perfs?.start(),this._renderer)if(this._isPaused||!(this.renderMode==="manual"&&!this._renderRequested||this.renderMode==="auto"&&this._skipRender)){if(this._renderRequested=!1,this._skipRender=!0,this._controls&&(this._skipRender=this._controls.update(this.dt)??!1),this._eventManager&&(this._eventManager.handlers?.Start?.hasVideoAction||this._eventManager.handlers?.Basic?.hasVideoAction||this._eventManager.handlers?.Conditional?.hasVideoAction)&&(this._skipRender=!1),this._animationControls?.update(this.dt),this._skipRender?(this.currentTAAFrame++,this.currentTAAFrame<Ymt?this._skipRender=!1:this.currentTAAFrame=0):this.currentTAAFrame=0,this._scene?.traverseVisibleEntity(o=>{o.type==="ParticleSystem"&&(o.update(this.dt),this._skipRender=!1),Jg(o)&&(this._renderer?.isWebGPUSplineRenderer!==!0&&o.warnClassicFallbackOnce(),o.isSimulating&&(o.update(this.dt),this._skipRender=!1))}),this._scene&&this._scene.activeCamera!==this._camera&&(this._camera=this._scene.activeCamera),this._eventManager?.isEnabled&&(this._eventManager.handlers?.Follow?.onAnimationFrameDamping(),this._eventManager.handlers?.LookAt?.onAnimationFrameDamping(),this._eventManager.handlers?.DragDrop?.onAnimationFrameDamping()),this._scene&&this._camera){if(this._scene.pathConstraints.applyConstraints(this._scene),this._renderer.sceneTransitionTimeRemaining>0){this._renderer.sceneTransitionTimeRemaining-=this.dt;let o=Math.min(1,1-this._renderer.sceneTransitionTimeRemaining/this._renderer.sceneTransitionDuration);this._renderer.pipeline.sceneTransitionPass.uniforms.mixRatio.value=o,this._skipRender=!1}else this._renderer.pipeline.sceneTransitionFromTexture=null;this._renderer.renderSplineScene(this._scene,this._camera),this._renderer.lastFrameIncomplete===!0&&(this._skipRender=!1),this._renderer.skyAnimationActive===!0&&(this._skipRender=!1)}this.canvas.dispatchEvent(this._renderedEvent),this._perfs?.end()}else this._perfs?.end();else this._perfs?.end()},this._resize=a=>{if(this._renderer){if(this._viewportMode===1&&this._frameView&&(this._frameView.frameSize=k5t.set(this._viewportWidth,this._viewportHeight)),a){let o=this._viewportWidth,l=this._viewportHeight;this._renderer.setSize(o-1,l-1,!1),this._renderer.setSize(o,l,!1)}else this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1);this._camera=this._scene?.activeCamera,this._scene?.updateViewPlaneSize(this._frameView?.frameSize?.x??this._viewportWidth,this._frameView?.frameSize?.y??this._viewportHeight,this._frameView?.enableResponsive??!1),this._camera&&(this._frameView?.setCamera(this._camera),this._frameView?.updateCamera(),this._camera.cameraType==="PerspectiveCamera"&&(this._camera.aspect=this._viewportWidth/this._viewportHeight),this._camera.updateProjectionMatrix()),this.eventManager&&(this.eventManager.eventContext.domRect=this.canvas.getBoundingClientRect()),this._requestRenderAutoMode()}},this._debouncedResize=AS(this._resize,10),this._onScroll=a=>{this.eventManager&&(this.eventManager.eventContext.domRect=this.canvas.getBoundingClientRect())},this.canvas=t,this._htmlContentMode=n,this.renderMode=e?"auto":i,r!==void 0&&(this._wasmPath=function(a){let o=a.length;for(;o>0&&"/".includes(a[o-1]);)o--;return a.slice(0,o)}(r)),this._rendererBackend=s??"webgl",s===void 0){let a=null;try{a=new URLSearchParams(window.location.search).get("renderer")}catch{}a==="webgpu"||a==="webgl"||a==="webgl2"?this._rendererBackend=a==="webgl2"?"webgl":a:(this._rendererAuto=!0,this._rendererBackend=typeof navigator<"u"&&"gpu"in navigator?"webgpu":"webgl")}this._renderedEvent=new CustomEvent("rendered",{bubbles:!0}),Object.defineProperty(this._renderedEvent,"target",{writable:!1,value:this}),window.location.search.includes("perfs")&&Promise.resolve().then(()=>(CAt(),$yt)).then(({Perfs:a})=>{this._perfs=new a({x:10,y:10})}),function(a){a.addEventListener("pointerdown",C$,!0),a.addEventListener("pointerdown",mM,!0),a.addEventListener("pointermove",mM,!0),a.addEventListener("pointerup",O0,!0),a.addEventListener("pointercancel",O0,!0),a.addEventListener("pointerleave",O0,!0),window.addEventListener("keydown",E$,!0),window.addEventListener("keyup",P$,!0)}(t)}async _createRenderer(){if(this._rendererBackend==="webgpu"&&this._rendererAuto)try{await navigator.gpu?.requestAdapter()||(this._rendererBackend="webgl")}catch{this._rendererBackend="webgl"}if(this._rendererBackend==="webgpu")try{let{createWebGPUSplineRenderer:t,isWebGPUSupported:e}=await Promise.resolve().then(()=>(KL(),T4));e();let i=!0,r=!1,s=this._data?.scene.publish?.asyncShaderCompilation!==!1;try{let a=new URLSearchParams(window.location.search),o=a.get("bundles");o==="rerecord"?i="rerecord":(o==="off"||o==="0"||o==="false"||o==="no")&&(i=!1),r=a.get("forcegl")==="1";let l=a.get("asynccomp");l==="off"||l==="0"||l==="false"||l==="no"?s=!1:(l==="on"||l==="1"||l==="true"||l==="always")&&(s=!0)}catch{}let n=await t({canvas:this.canvas,antialias:!1,alpha:!0,powerPreference:"high-performance",sceneBundles:!r&&i,forceWebGL:r,asyncCompilation:!r&&s});return n.onBackgroundWorkReady=()=>{this._skipRender=!1,this._renderRequested=!0},n.skyAnimationAllowed=!0,n}catch(t){console.error("[spline] Failed to initialize the WebGPU renderer, falling back to WebGL:",t),this._rendererBackend="webgl"}throw this._failWebGPURequired(),new Error("[spline] This runtime build is WebGPU-only and the browser provides no WebGPU adapter.")}_failWebGPURequired(){console.error('[spline] This scene was exported for WebGPU only and this browser does not provide a WebGPU adapter. Re-export with renderer "Both" or "WebGL 2" to support this browser.');try{let t=window.devicePixelRatio||1,e=this.canvas.clientWidth||300,i=this.canvas.clientHeight||150;this.canvas.width=e*t,this.canvas.height=i*t;let r=this.canvas.getContext("2d");r&&(r.scale(t,t),r.fillStyle="rgba(127, 127, 127, 0.85)",r.font="13px system-ui, -apple-system, Segoe UI, Roboto, sans-serif",r.textAlign="center",r.textBaseline="middle",r.fillText("This scene requires a WebGPU-capable browser.",e/2,i/2))}catch{}this.canvas.dispatchEvent(new CustomEvent("splineerror",{bubbles:!0,detail:{reason:"webgpu-required"}}))}async load(t,e,i){(function(s){let n="The Spline Runtime only accepts .splinecode files that are generated from Spline export panel.";s.endsWith(".spline")?console.warn(n+" The .spline files are only meant to be used by the Editor."):s.endsWith(".splinecode")||console.warn(n)})(t),this.disposed=!1;let r=await(await fetch(t,i)).arrayBuffer();await this.start(r,{variables:e})}async start(t,{interactive:e=!0,variables:i}={}){if(this.disposed)return;Is.init();let r=await async function(c){let[p,m]=Gw(CS.deserialize(new Uint8Array(c)));if((p.schema??0)!==131){let{updateDocumentSchema:f}=await Promise.resolve().then(()=>(P5(),Lmt));f(p)}return m.result().data}(t);this._data=r;let s=function(c){let p=[];return c.scene.objects.traverse((m,f)=>{f.type==="Mesh"&&f.geometry.type==="NonParametricGeometry"&&f.geometry.data.draco!==void 0&&p.push(f)}),p}(r);r.version&&(0,x5t.default)(r.version,"2.0.60")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/runtime to the latest version."),this._wasmPath!==void 0&&(this.setUIWasmUrl(`${this._wasmPath}/hana-ui.wasm`),function(c){bj=c}(this._wasmPath));let n=async function(){}();await Promise.all([n,s.length&&Udt(this._wasmPath),OK(r)&&YMt(this._wasmPath),y3t(r)&&g3t(this._wasmPath),F3t(r)&&T3t(this._wasmPath),Qg.physicsEnabled(r.scene.objects)&&PPt(this._wasmPath),VY(r)&&Sut(),tZ(r)&&lAt(),n3t(r)&&s3t(),fut(r)&&n.then(()=>wU()?.loadHanaUIRUNTIME()),wPt(r)&&qPt(this._wasmPath)].filter(Boolean)),s.length&&await jdt(s),this._eventManager?.deactivate(),this._controls?.deactivate(),this._scene?.dispose();let a=r.scene.publish.renderer;if(this._rendererAuto&&a==="webgl")this._rendererBackend="webgl";else if(this._rendererAuto&&a==="webgpu"){if(this._rendererBackend!=="webgpu"||!await navigator.gpu?.requestAdapter().catch(()=>null))return void this._failWebGPURequired();this._rendererAuto=!1}let o=function(c){let p=new Set;return c.scene.objects.traverse((m,f)=>{if(f.type!=="Page")return;let g=f.postprocessing;if(g&&typeof g=="object"&&g.enabled===!0)for(let[y,v]of Object.entries(g))y!=="enabled"&&v&&typeof v=="object"&&v.enabled===!0&&p.add(y)}),[...p]}(r);if(this._rendererBackend==="webgpu")try{await Promise.all([Promise.resolve().then(()=>(KL(),T4)),_5t(o)]),this._renderer||(this._renderer=await this._createRenderer())}catch(c){console.error("[spline] Failed to load the WebGPU material backend, using WebGL:",c),this._rendererBackend="webgl"}if(this._rendererBackend!=="webgpu")return void this._failWebGPURequired();(function(c){iT=c})(this._rendererBackend==="webgpu"?"webgpu":"webgl");let l=new f5t(r);if(l.resetPersonalCameraFromDocumentData(),this._scene=l.scene,this._sharedAssetsManager=l.sharedAssets,this._camera=this._scene.activeCamera,window.location.search.includes("merge-geometries")){let{mergeStaticGeometries:c}=await Promise.resolve().then(()=>(oEt(),ybt)),p=performance.now();c(r,l.scene);let m=performance.now();console.log("Merged geometries in ",m-p," ms")}OK(r)&&this._scene.traverse(c=>{Hu(c)&&c.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this._requestRenderAutoMode(),this._scene?.traverse(c=>{H1(c)&&c.pendingMediaLoad&&c.update({scene:this._scene,shared:this._sharedAssetsManager})})}),this._scene?.traverse(c=>{c.type==="ParticleSystem"&&(c.wakeUp(),c.data.autoPlay?c.start():c.stop()),Jg(c)&&c.setPlayMode(!0)});let u=Object.keys(r.shared.fonts).flatMap(c=>{let p=this._sharedAssetsManager.getFont(c);return p?[p.loadingPromise]:[]});if(Promise.all(u).then(()=>{this.disposed||(l.scene.markNeedsUpdateRendererDirty(),this._requestRenderAutoMode())}),VY(r)&&function(c){if(Qg.physicsEnabled(c.scene.objects))return!0;let p=!1;return c.scene.objects.traverse((m,f)=>{if(f.events){if(Array.isArray(f.events)){for(let g of f.events)if(g.data.disabled!==!0&&g.data.type==="GameControl"&&g.data.collisionEnabled){p=!0;break}}else for(let g of Object.values(f.events))if(g.disabled!==!0&&g.type==="GameControl"&&g.collisionEnabled){p=!0;break}}}),p}(r)&&await Promise.all(u),fut(r)){let c=[];this._scene.traverseEntity(p=>{(Ya(p)||p instanceof Hs)&&p.uiCanvas&&c.push(p.uiCanvas)}),await Promise.all(c.map(p=>p.promise))}if(this._scene.rewriteEventsBeforeGoToPlayMode(),$W(this._scene.activePage,this._sharedAssetsManager),this._renderer||(this._renderer=await this._createRenderer()),!this._rendererConfigured){this._rendererConfigured=!0,this._renderer.hdTransmission=r.scene.publish.hdTransmission===!0;let c=()=>/Mobi|Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),p=this._getPixelRatio(c()?r.scene.publish.settings.web.pixelRatioMobile:r.scene.publish.settings.web.pixelRatioDesktop);if(this._renderer.setPixelRatio(p),this._renderer.pipeline.enableUIOverlay(),this._renderer.pipeline.addEventListener("smaaloaded",this._requestRenderAutoMode),r.shared.images.SplineWatermark){let m=this._sharedAssetsManager.getImage("SplineWatermark");await m.loadPromise;let f=m.getTexture(1001);this._renderer.pipeline.setWatermark(f)}}tZ(r)&&this._scene.initializeSplatViewer(),r.scene.blueNoiseTextureData!==void 0&&this._renderer.pipeline.updateBlueNoiseTexture(r.scene.blueNoiseTextureData);let h=Object.values(r.frames)[0];if(this._frameView?this._frameView.setCamera(this._camera):(h.preset==="fullscreen"?(this._viewportMode=1,this.canvas.style.display="block",this.canvas.parentElement&&(this._viewportWidth=this.canvas.parentElement.clientWidth||300,this.canvas.style.width="100%"),this.canvas.parentElement&&(this._viewportHeight=this.canvas.parentElement.clientHeight||150,this.canvas.style.height="100%")):(this._viewportMode=2,this._viewportWidth=h.size[0],this._viewportHeight=h.size[1],this.canvas.style.width=`${this._viewportWidth}px`,this.canvas.style.height=`${this._viewportHeight}px`),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._frameView=new jEt(this._renderer,this._camera,new Z(this._viewportWidth,this._viewportHeight)),this._frameView.enableResponsive=(h.allowResponsive??!1)&&h.preset==="fullscreen"),e){let c=new xEt(this._renderer,this.data.scene.publish,this._scene,()=>this._scene.activeCamera,this._sharedAssetsManager,this._requestRenderAutoMode,!0,h);this._scene.updateMatrixWorld(!0),this._controls=new OPt(c),this._animationControls=new v5t(this._scene,this._requestRenderAutoMode),this._eventManager=new VEt(r.scene.publish,this._controls,this._animationControls,c,r.shared.variables),this._eventManager.activate(),this._controls.activate(this._eventManager)}this._resize(),this._scene.activePage.data.postprocessing.depthOfField.enabled&&Promise.all(this._sharedAssetsManager.getImageLoadPromises()).then(()=>{this.disposed||this._resize(!0)}),i!==void 0&&this.setVariables(i),this.dt===0&&(this.render(performance.now()),setTimeout(()=>{this._renderer?.setAnimationLoop(this.render)},0)),this._resizeObserverTimeout=setTimeout(()=>{!this._resizeObserver&&this.canvas.parentElement&&(this._resizeObserver=new ResizeObserver(()=>{this._viewportWidth=this.canvas.clientWidth,this._viewportHeight=this.canvas.clientHeight,this._debouncedResize()}),this._resizeObserver.observe(this.canvas.parentElement))},300),document.addEventListener("scroll",this._onScroll),e&&(this._htmlContentOverlay?.dispose(),this._htmlContentOverlay=void 0);let d=r.scene.publish.htmlContent?.html;if(e&&d&&this._htmlContentMode!=="none"){let c={shared:this._sharedAssetsManager,findEntity:p=>this._scene?.getObjectByProperty("uuid",p)??this._scene?.getObjectByName(p)};this._htmlContentOverlay=(this._htmlContentMode==="inline"?O_t.mount(this,this.canvas,d,c):N_t.mount(this,this.canvas,d,c))??void 0}}setVariables(t){if(this._data!==void 0){let e=Object.entries(t);for(let[i,r]of e)this.setVariable(i,r)}}setVariable(t,e){let i=this._getVariableByName(t);if(i&&!("dynamicVariableType"in i.data)){let r=e;typeof i.data.value=="number"?r=typeof e=="number"?e:typeof e=="boolean"?e===!0?1:0:parseFloat(e):typeof i.data.value=="boolean"?r=typeof e=="number"?!!e:typeof e=="boolean"?e:e.toLocaleLowerCase()!=="false"&&!!e:typeof i.data.value!="string"&&i.data.value.textValue!==void 0&&(r=e.toString());let s=typeof r=="string"?{textValue:r}:r;this._sharedAssetsManager?.updateVariable(i.id,s),this.requestRender(),this._requestRenderAutoMode()}else i===void 0?console.warn(`No variable named ${t} was found in your Spline file. Make sure to create it from Spline editor.`):"dynamicVariableType"in i.data&&console.warn(`Dynamic variables like ${t} cannot be updated from code.`)}getVariables(){let t={};return this._data&&this._data.shared.variables.forEach(e=>{t[e.data.name]===void 0&&(t[e.data.name]=this._getVariableValue(this._sharedAssetsManager.getVariable(e.id)))}),t}getVariable(t){let e=this._getVariableByName(t);if(e){let i=this._sharedAssetsManager.getVariable(e.id);return this._getVariableValue(i)}}_getVariableValue(t){return typeof t!="string"&&Na.isTextValue(t)?Na.getDisplayedValue(t):t}_getVariableByName(t){if(this._data){if(this._variablesCache.has(t))return this._variablesCache.get(t);let e=this._data.shared.variables.find(i=>i.data.name===t);return e&&this._variablesCache.set(t,e),e}}_getPixelRatio(t){switch(t){case 0:return window.devicePixelRatio;case 1:return 1;case 2:return 2}}findObjectById(t){let e=this._scene?.getObjectByProperty("uuid",t);return this._createProxyObject(e)}findObjectByName(t){let e=this._scene?.getObjectByName(t);return this._createProxyObject(e)}getAllObjects(){let t=[];return this._scene?.traverseEntity(e=>{if(!(e.uuid===i0||this._scene.isInvisibleObjects(e)||e instanceof Hs)){let i=this._createProxyObject(e);i&&t.push(i)}}),t}getSplineEvents(){return(this._eventManager?.handlers?.Spline).splineEvents}emitEvent(t,e){(this.findObjectById(e)||this.findObjectByName(e))?.emitEvent(t)}emitEventReverse(t,e){(this.findObjectById(e)||this.findObjectByName(e))?.emitEventReverse(t)}addEventListener(t,e){this.canvas.addEventListener(t,e)}removeEventListener(t,e){this.canvas.removeEventListener(t,e)}setZoom(t){this._controls?.orbitControls instanceof Obt&&this._controls?.orbitControls.setZoom(t)}get eventManager(){return this._eventManager}get controls(){return this._controls}setSize(t,e){this._viewportWidth=t,this._viewportHeight=e,this._viewportMode=2,this._resize()}setBackgroundColor(t){let e=Xdt(t);this._scene?.activePage.setBackgroundColor(e),this._requestRenderAutoMode()}dispose(){this.disposed=!0,this._htmlContentOverlay?.dispose(),this._htmlContentOverlay=void 0,this._eventManager?.dispose(),this._scene?.dispose(),this._scene=void 0,this._camera=void 0,$2&&$2.disposeAll(),this._sharedAssetsManager?.setRequestRender(()=>{}),this._sharedAssetsManager?.dispose(),this._sharedAssetsManager=void 0,this._proxyObjectCache.forEach(t=>{ZL.unsubscribe(t)}),this._proxyObjectCache.clear(),this._variablesCache.clear(),this._renderer?.pipeline.removeEventListener("smaaloaded",this._requestRenderAutoMode),this._renderer?.setAnimationLoop(null),this._renderer?.dispose(),this._renderer=void 0,this._debouncedResize.cancel(),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=void 0),this._resizeObserverTimeout!==void 0&&(clearTimeout(this._resizeObserverTimeout),this._resizeObserverTimeout=void 0),this.canvas.style.width="",this.canvas.style.height="",this.canvas.removeAttribute("width"),this.canvas.removeAttribute("height"),this._frameView=void 0,this._controls?.deactivate(),this._controls=void 0,this._animationControls=void 0,this._eventManager?.eventContext.dispose(),this._eventManager=void 0,this._splatViewer=void 0,this._data=void 0,this._perfs=void 0,this.dt=0,this._lastTime=void 0,function(t){t.removeEventListener("pointerdown",C$,!0),t.removeEventListener("pointerdown",mM,!0),t.removeEventListener("pointermove",mM,!0),t.removeEventListener("pointerup",O0,!0),t.removeEventListener("pointercancel",O0,!0),t.removeEventListener("pointerleave",O0,!0),window.removeEventListener("keydown",E$,!0),window.removeEventListener("keyup",P$,!0)}(this.canvas),document.removeEventListener("scroll",this._onScroll),Is.dispose()}get isStopped(){return this._isPaused}stop(){this._isPaused||(this._renderer?.setAnimationLoop(null),this._isPaused=!0,this._eventManager?.pause(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!1))}play(){!this._isPaused||(this._isPaused=!1,this._eventManager?.resume(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!0),this._renderer?.setAnimationLoop(this.render))}setGlobalEvents(t){this._eventManager?.updateUseWindowEvents(t)}get data(){return this._data}_createProxyObject(t){if(!this._scene)return;let e,i=this._scene;if(t==null)return;if(this._proxyObjectCache.has(t.uuid))return this._proxyObjectCache.get(t.uuid);t.traverseAncestors(h=>{h instanceof Hs&&(e=h.name)});let r=this._sharedAssetsManager,s={shared:r,scene:this._scene},n=h=>{if(h===null||h==="Base State")return null;if(h&&t.data.states){let d=t.data.states.find(c=>c.data.name===h);return d?d.id:void 0}},a="material"in t?t.material:void 0,o=t.materialOverride,l={name:t.name,uuid:t.uuid,visible:t.visible,intensity:t.intensity,position:t.position,rotation:t.rotation,scale:t.scale,type:t.data.type,page:e,material:o??(a?I5t(a):void 0),parentUuid:t.parent instanceof Hs||t instanceof Pg?void 0:t.parent?.uuid,emitEvent(h){t.dispatchEvent({type:"userEvent",eventName:h})},emitEventReverse(h){t.dispatchEvent({type:"userEvent",eventName:h,reverse:!0})},hide(){t.visible&&(t.visible=!1,s.shared.requestRender())},show(){t.visible||(t.visible=!0,s.shared.requestRender())},get state(){let h=t.stateSelection;if(h!==null)return t.data.states.find(({id:d})=>d===h)?.data.name},set state(h){let d;if(h!==void 0){let c=typeof h=="string"?t.data.states.find(({id:p})=>p===h):t.data.states[h];if(c)d=c.id;else{let p=typeof h=="string"?n(h):void 0;p&&(d=p)}}t.changeSelectedState(d??null,s),t.currentState=d??null,t.dispatchEvent({type:"completeState",state:d??null}),s.shared.requestRender()},transition(h){let d=R_t;if(d===null)return Nn("transitions","obj.transition()"),{transition(_){return this},play(){return this},pause(){return this},reset(){return this},seek(_){return this}};let c,p,m=this,f=[],g=!1,y=()=>{p=new f_t({delay:0,delayDirection:"start-once",direction:"normal",repeat:0,runMode:"Repeat"},f.map(_=>_.runner))},v={update(_){p?.update(_),p?.isPlaying!==!0&&Is.remove(v)}},b={transition({from:_,to:x,duration:S,delay:w,...T}){let A=n(_);A===void 0&&(A=c);let M=n(x);return c=M,f.push(new d(t,A,M,{state:M,repeat:0,delay:w??0,delayDirection:"start-once",direction:"normal",duration:S??1e3,...T,...T.easing===6?Jp.defaultData:T.easing===5?Nv.defaultData:{}},r,!1,i.activePage,{onBegin:()=>{(_&&A||_==="Base State"&&!A)&&(m.state=A??void 0)},onComplete:()=>{m.state=M??void 0}})),y(),this},play(){return p?(g=!0,p.play(Is.time),p.isPlaying&&Is.add(v),this):this},pause(){return p?.stop(),Is.remove(v),this},reset(){return this.pause(),g=!1,y(),p?.seek(0),this},seek(_){let x=f.reduce((S,w)=>S+w.runner.duration,0);return x>0&&p?.seek(_/1e3/x),this}};return b.transition(h),(h.autoPlay??!0)&&queueMicrotask(()=>{g||b.play()}),b},set color(h){let d=Xdt(h);if(OR.is(t))return void(t.color=d);if(!(t.type==="Mesh"&&"material"in t&&t instanceof yo))return;let c={r:d.r,g:d.g,b:d.b,a:d.a},p=t.materialOverride;if(p!==void 0){let g=p.color;return void(g?.isColor===!0&&typeof g.setStyle=="function"&&(g.setStyle(h),s.shared.requestRender()))}let m=Array.isArray(t.material)?t.material[0]:t.material,f=m.data.layers.find(g=>g.data.type==="color")?.id;if(f)m.updateByOp({type:0,path:["layers",f],props:{color:{...c}}},m.data,s);else{let g=m.data,y=g.layers.find(w=>w.data.type==="light");if(!y)return;let v=g.layers.indexOf(y)===0?y:null,b=g.layers.at(v?g.layers.indexOf(v)+1:0),_={type:4,fi:v?v.fi+(b?(b.fi-v.fi)/2:1):b?b.fi/2:1,id:qt.generateUUID(),data:{...Ws.defaultData("color"),color:c},localIndex:0},x=g.layers.insertAfterHelper(v?.id??null,1),S=g.layers.runOp({..._,fi:x[0]}).data;Object.assign(m.data,{layers:S}),m.updateByOp({..._,path:["layers"]},m.data,s)}}},u=ZL(l,(h,d)=>{let c=t[h],p=function(m){return m.split(".")}(h);p[0]==="material"&&a&&o===void 0&&function(m,f,g){let y=Array.isArray(g)?g[0]:g;if(m[0]==="layers"){let v=parseInt(m[1]),b=y.layers[v],_=m[2];b&&_&&function(x,S,w){let T=x[0];try{if(function(A,M){return!!V5t[M]?.includes(A)}(T,w.type,x.slice(1)))if(T==="colors"){if(x.length<2)throw new Error("You cannot mutate the colors array, only its items");let A=parseInt(x[1]),M=w.getValue(T)?.[A];if(!M)throw new Error("Color index out of range");Ew.setStyle(S),M.set(Ew.r,Ew.g,Ew.b,Ew.a)}else w.getValue(T)?.setStyle(S);else if(T==="texture"||T==="video"){let A=w.color;(function(M,C,R,O){let N=M[0];if(N==="repeat"||N==="offset"||N==="rotation"){let B=O.getNode("mat"),k=B&&typeof B.updateMatrix=="function"?B:O.getValue("mat");if(!k)return;if(N==="rotation")k.rotation=parseFloat(C);else{let z=M[1];if(z===void 0)C instanceof Array&&C.length===2&&Object.assign(k,{[N]:C});else{let L=k[N],V=parseInt(z)===0?[parseFloat(C),L[1]]:[L[0],parseFloat(C)];Object.assign(k,{[N]:V})}}k.updateMatrix()}else N==="wrapping"||N==="minFilter"||N==="magFilter"?N==="wrapping"?R.texture.wrap=C:R.texture[N]=C:N==="image"&&M[1]==="data"&&R.texture.image.updateSrc(C)})(x.slice(1),S,A,w)}else{let A=x[1],M=w.getValue(T);M?.isVector3&&A!==void 0||M?.isVector2&&A!==void 0?M.setComponent(parseInt(A),S):w.setValue(T,S)}}catch(A){console.error("Error setting material value",A)}}(m.slice(2),f,b)}else m[0]==="alpha"&&y.layers.forEach(v=>{v.type==="light"&&v.node.alphaOverride!==void 0&&(v.node.alphaOverride.value=f,f<1&&(y.transparent=!0))})}(p.slice(1),d,a),typeof c!="object"&&Object.getOwnPropertyDescriptor(t,h)?.writable&&(t[h]=d),this._requestRenderAutoMode(),t.updateMatrix()});return this._proxyObjectCache.set(t.uuid,u),u}setUIWasmUrl(t){(function(e){xR=e,O5?.setHanaUIWasmUrl(e)})(t)}pauseGameControls(){this._eventManager?.controlsManager.gameControl?.pause()}resumeGameControls(){this._eventManager?.controlsManager.gameControl?.resume()}async swapGeometry(t,e){let i;if(typeof e=="string"){if(!e.endsWith(".splinegeometry"))throw new Error("Only .splinegeometry format is supported");{let l=await(await fetch(e)).arrayBuffer();i=new Uint8Array(l)}}else i=e;let r=CS.deserialize(i),s="data"in r&&r.data.draco!==void 0;s&&await Udt(this._wasmPath);let n=this._scene?.getObjectByProperty("uuid",t)??this._scene?.getObjectByName(t);if(!n)return void console.warn(`Object ${t} not found`);if(n.data.type!=="Mesh"||!(n instanceof yo))return void console.warn(`Object ${t} is not a mesh`);let a=n,o={...a.data,geometry:r};s&&await jdt([o]),a.updateByOp({type:0,path:[],props:{geometry:o.geometry}},o,{shared:this._sharedAssetsManager,scene:this._scene},!1);for(let l of a.data.states){let u={...l.data};a.states||(a.states={}),a.states[l.id]=em.patch(o,u)}return i}_applyDocumentTransaction(t){this._data=t.data,this._scene&&(this._scene.data=this._data.scene),this._sharedAssetsManager&&(this._sharedAssetsManager.data=this._data.shared);for(let e of t.actual){let i=e.path;Array.isArray(i)&&i.length===2&&i[0]==="scene"&&i[1]==="objects"&&this._scene?.updateTreeByOp({...e,path:[]},this._sharedAssetsManager)}}_findEntity(t){return this._scene?.getObjectByProperty("uuid",t)??this._scene?.getObjectByName(t)}_resolveParentId(t){if(t===void 0)return this._scene.activePage.uuid;let e=typeof t=="string"?t:t.uuid,i=this._findEntity(e);if(!i)throw new Error(`parent '${e}' \u2014 no object with that name or uuid in the scene.`);return i.uuid}async createCustomMaterial(t){if(this.disposed)throw new Error("createCustomMaterial: this Application was disposed.");if(typeof t!="function")throw new Error("createCustomMaterial: expected a factory function \u2014 createCustomMaterial((three) => new three.MeshStandardNodeMaterial()).");let e=KU();if(e===void 0&&(this._rendererBackend==="webgpu"&&(await Promise.resolve().then(()=>(KL(),T4)),e=KU()),e===void 0))throw new Error("createCustomMaterial: requires the webgpu backend (the runtime default where WebGPU is available). This Application is on the classic WebGL pipeline \u2014 pass { renderer: 'webgpu' } or drop any ?renderer=webgl2 override.");let i=t(e);if(typeof i!="object"||i===null||i.isMaterial!==!0)throw new Error("createCustomMaterial: the factory must return a three.js material built from the namespace it receives \u2014 e.g. (three) => new three.MeshStandardNodeMaterial().");return i}async setMaterial(t,e){if(this.disposed)throw new Error("setMaterial: this Application was disposed.");let i=this._scene;if(!i)throw new Error("setMaterial: no scene loaded \u2014 call load() or start() first.");let r=typeof t=="string"?t:t.uuid,s=this._findEntity(r);if(!s)throw new Error(`setMaterial: '${r}' \u2014 no object with that name or uuid in the scene.`);if(!(s instanceof yo))throw new Error(`setMaterial: '${r}' is not a mesh \u2014 lights, groups, and cameras have no material.`);let n=typeof e=="function"?await this.createCustomMaterial(e):e;if(DR()!=="webgpu")throw new Error("setMaterial: custom three.js materials require the webgpu backend (the runtime default where WebGPU is available). This scene is running the classic WebGL pipeline \u2014 pass { renderer: 'webgpu' } or drop any ?renderer=webgl2 override.");let a=Wdt({material:n});if(a.material===void 0)throw new Error("setMaterial: expected a three.js material instance or a (three) => material factory.");return s.setMaterialOverride(a.material,{scene:i,shared:this._sharedAssetsManager}),this._proxyObjectCache.delete(s.uuid),this._requestRenderAutoMode(),a.material}async createObject(t,e={}){if(this.disposed)throw new Error("createObject: this Application was disposed.");let i=this._scene,r=this._data;if(!i||!r)throw new Error("createObject: no scene loaded \u2014 call load() or start() first.");let s=function(g){if(typeof g!="string"||g.length===0)throw new Error(`createObject: expected a type name string \u2014 one of ${qdt}.`);let y=g.replace(/Geometry$/i,"").replace(/[\s_-]/g,"").toLowerCase(),v=A5t[y];if(v)return{objectType:v};let b=M5t[y];if(b)return{objectType:"Mesh",geometryType:b};let _=C5t[y];throw _?new Error(`createObject: '${g}' is not supported \u2014 ${_}`):new Error(`createObject: '${g}' is not a creatable Spline type \u2014 use one of ${qdt}, e.g. createObject('Cube', { width: 200 }).`)}(t);typeof e.material=="function"&&(e={...e,material:await this.createCustomMaterial(e.material)});let n,a,{options:o,material:l}=Wdt(e);if(l!==void 0){if(s.objectType!=="Mesh")throw new Error("createObject: a three.js material instance only applies to mesh types \u2014 lights and groups have no material.");if(DR()!=="webgpu")throw new Error("createObject: three.js material instances require the webgpu backend (the runtime default where WebGPU is available). This scene is running the classic WebGL pipeline \u2014 pass { renderer: 'webgpu' } to the Application, or drop any ?renderer=webgl2 override.")}if(s.geometryType==="TextGeometry"){if(!pG.has("text"))throw new Error("createObject: this runtime build was compiled without the 'text' feature \u2014 re-export the scene with a Text object present, or load the full runtime build.");if(await Sut(),a=e.font??S1,r.shared.fonts[a]===void 0){if(a!==S1){let g=Object.keys(r.shared.fonts).join(", ");throw new Error(`createObject: font '${a}' is not in this document \u2014 available fonts: ${g||"(none)"}.`)}n={name:S1,url:xmt}}}let u=this._resolveParentId(e.parent),h=N5t(s,o,r),d=qt.generateUUID(),[c,p]=Gw(r);n&&(c.shared.fonts[S1]=n),c.scene.objects.insertAfter(u,null,[{id:d,data:h,children:[]}]);let m=p.result();if(n&&this._sharedAssetsManager.addFont(S1,n),a!==void 0){let g=this._sharedAssetsManager.getFont(a);g&&await g.loadingPromise}this._applyDocumentTransaction(m);let f=i.find(d);return l!==void 0&&f.setMaterialOverride(l,{scene:i,shared:this._sharedAssetsManager}),this._requestRenderAutoMode(),this._createProxyObject(f)}cloneObject(t,e={}){if(this.disposed)throw new Error("cloneObject: this Application was disposed.");let i=this._scene,r=this._data;if(!i||!r)throw new Error("cloneObject: no scene loaded \u2014 call load() or start() first.");let s=typeof t=="string"?t:t?.uuid,n=s?this._findEntity(s):void 0;if(!n)throw new Error(`cloneObject: '${s}' \u2014 no object with that name or uuid in the scene.`);if(n instanceof Hs)throw new Error("cloneObject: pages cannot be cloned.");let a=r.scene.objects.get(n.uuid);if(!a)throw new Error(`cloneObject: '${s}' is not part of the document tree (expanded clones and instanced children cannot be cloned \u2014 clone their source object instead).`);let o=function(p,m,f){let g={...p.data};return m.position!==void 0&&(g.position=HS(m.position,[0,0,0])),m.rotation!==void 0&&(g.rotation=HS(m.rotation,[0,0,0])),m.scale!==void 0&&(g.scale=B_t(m.scale)),m.visible!==void 0&&(g.visible=m.visible),g.name=m.name??V_t(`${p.data.name??"Object"} Copy`,f),{...p,data:g}}(O5t(a),e,r.scene.objects),l=e.parent!==void 0?this._resolveParentId(e.parent):r.scene.objects.parent(n.uuid)??null,u=e.parent!==void 0?null:n.uuid,[h,d]=Gw(r);h.scene.objects.insertAfter(l,u,[o]),this._applyDocumentTransaction(d.result());let c=i.find(o.id);return this._requestRenderAutoMode(),this._createProxyObject(c)}removeObject(t){let e=this._scene,i=this._data;if(this.disposed||!e||!i)return!1;let r=typeof t=="string"?t:t?.uuid,s=r?this._findEntity(r):void 0;if(!s)return!1;if(s instanceof Hs)throw new Error("removeObject: pages cannot be removed.");if(s.data.type==="PerspectiveCamera"||s.data.type==="OrthographicCamera")throw new Error("removeObject: cameras cannot be removed.");if(i.scene.objects.get(s.uuid)===void 0)throw new Error(`removeObject: '${r}' is not part of the document tree (expanded clones and instanced children cannot be removed individually).`);let n=[];s.traverseEntity(l=>{n.push(l.uuid)});let[a,o]=Gw(i);a.scene.objects.delete(s.uuid),this._applyDocumentTransaction(o.result());for(let l of n){let u=this._proxyObjectCache.get(l);u&&(ZL.unsubscribe(u),this._proxyObjectCache.delete(l))}return this._requestRenderAutoMode(),!0}};var dD=window,cD=dD.ShadowRoot&&(dD.ShadyCSS===void 0||dD.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,XW=Symbol(),L_t=new WeakMap,cT=class{constructor(e,i,r){if(this._$cssResult$=!0,r!==XW)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=i}get styleSheet(){let e=this.o,i=this.t;if(cD&&e===void 0){let r=i!==void 0&&i.length===1;r&&(e=L_t.get(i)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),r&&L_t.set(i,e))}return e}toString(){return this.cssText}},F_t=t=>new cT(typeof t=="string"?t:t+"",void 0,XW),YW=(t,...e)=>{let i=t.length===1?t[0]:e.reduce((r,s,n)=>r+(a=>{if(a._$cssResult$===!0)return a.cssText;if(typeof a=="number")return a;throw Error("Value passed to 'css' function must be a 'css' function result: "+a+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+t[n+1],t[0]);return new cT(i,t,XW)},KW=(t,e)=>{cD?t.adoptedStyleSheets=e.map(i=>i instanceof CSSStyleSheet?i:i.styleSheet):e.forEach(i=>{let r=document.createElement("style"),s=dD.litNonce;s!==void 0&&r.setAttribute("nonce",s),r.textContent=i.cssText,t.appendChild(r)})},pD=cD?t=>t:t=>t instanceof CSSStyleSheet?(e=>{let i="";for(let r of e.cssRules)i+=r.cssText;return F_t(i)})(t):t;var ZW,mD=window,U_t=mD.trustedTypes,z5t=U_t?U_t.emptyScript:"",j_t=mD.reactiveElementPolyfillSupport,JW={toAttribute(t,e){switch(e){case Boolean:t=t?z5t:null;break;case Object:case Array:t=t==null?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){case Boolean:i=t!==null;break;case Number:i=t===null?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch{i=null}}return i}},G_t=(t,e)=>e!==t&&(e==e||t==t),QW={attribute:!0,type:String,converter:JW,reflect:!1,hasChanged:G_t},tq="finalized",Nc=class extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this._$Eu()}static addInitializer(e){var i;this.finalize(),((i=this.h)!==null&&i!==void 0?i:this.h=[]).push(e)}static get observedAttributes(){this.finalize();let e=[];return this.elementProperties.forEach((i,r)=>{let s=this._$Ep(r,i);s!==void 0&&(this._$Ev.set(s,r),e.push(s))}),e}static createProperty(e,i=QW){if(i.state&&(i.attribute=!1),this.finalize(),this.elementProperties.set(e,i),!i.noAccessor&&!this.prototype.hasOwnProperty(e)){let r=typeof e=="symbol"?Symbol():"__"+e,s=this.getPropertyDescriptor(e,r,i);s!==void 0&&Object.defineProperty(this.prototype,e,s)}}static getPropertyDescriptor(e,i,r){return{get(){return this[i]},set(s){let n=this[e];this[i]=s,this.requestUpdate(e,n,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)||QW}static finalize(){if(this.hasOwnProperty(tq))return!1;this[tq]=!0;let e=Object.getPrototypeOf(this);if(e.finalize(),e.h!==void 0&&(this.h=[...e.h]),this.elementProperties=new Map(e.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){let i=this.properties,r=[...Object.getOwnPropertyNames(i),...Object.getOwnPropertySymbols(i)];for(let s of r)this.createProperty(s,i[s])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(e){let i=[];if(Array.isArray(e)){let r=new Set(e.flat(1/0).reverse());for(let s of r)i.unshift(pD(s))}else e!==void 0&&i.push(pD(e));return i}static _$Ep(e,i){let r=i.attribute;return r===!1?void 0:typeof r=="string"?r:typeof e=="string"?e.toLowerCase():void 0}_$Eu(){var e;this._$E_=new Promise(i=>this.enableUpdating=i),this._$AL=new Map,this._$Eg(),this.requestUpdate(),(e=this.constructor.h)===null||e===void 0||e.forEach(i=>i(this))}addController(e){var i,r;((i=this._$ES)!==null&&i!==void 0?i:this._$ES=[]).push(e),this.renderRoot!==void 0&&this.isConnected&&((r=e.hostConnected)===null||r===void 0||r.call(e))}removeController(e){var i;(i=this._$ES)===null||i===void 0||i.splice(this._$ES.indexOf(e)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach((e,i)=>{this.hasOwnProperty(i)&&(this._$Ei.set(i,this[i]),delete this[i])})}createRenderRoot(){var e;let i=(e=this.shadowRoot)!==null&&e!==void 0?e:this.attachShadow(this.constructor.shadowRootOptions);return KW(i,this.constructor.elementStyles),i}connectedCallback(){var e;this.renderRoot===void 0&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(e=this._$ES)===null||e===void 0||e.forEach(i=>{var r;return(r=i.hostConnected)===null||r===void 0?void 0:r.call(i)})}enableUpdating(e){}disconnectedCallback(){var e;(e=this._$ES)===null||e===void 0||e.forEach(i=>{var r;return(r=i.hostDisconnected)===null||r===void 0?void 0:r.call(i)})}attributeChangedCallback(e,i,r){this._$AK(e,r)}_$EO(e,i,r=QW){var s;let n=this.constructor._$Ep(e,r);if(n!==void 0&&r.reflect===!0){let a=(((s=r.converter)===null||s===void 0?void 0:s.toAttribute)!==void 0?r.converter:JW).toAttribute(i,r.type);this._$El=e,a==null?this.removeAttribute(n):this.setAttribute(n,a),this._$El=null}}_$AK(e,i){var r;let s=this.constructor,n=s._$Ev.get(e);if(n!==void 0&&this._$El!==n){let a=s.getPropertyOptions(n),o=typeof a.converter=="function"?{fromAttribute:a.converter}:((r=a.converter)===null||r===void 0?void 0:r.fromAttribute)!==void 0?a.converter:JW;this._$El=n,this[n]=o.fromAttribute(i,a.type),this._$El=null}}requestUpdate(e,i,r){let s=!0;e!==void 0&&(((r=r||this.constructor.getPropertyOptions(e)).hasChanged||G_t)(this[e],i)?(this._$AL.has(e)||this._$AL.set(e,i),r.reflect===!0&&this._$El!==e&&(this._$EC===void 0&&(this._$EC=new Map),this._$EC.set(e,r))):s=!1),!this.isUpdatePending&&s&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(i){Promise.reject(i)}let e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var e;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach((s,n)=>this[n]=s),this._$Ei=void 0);let i=!1,r=this._$AL;try{i=this.shouldUpdate(r),i?(this.willUpdate(r),(e=this._$ES)===null||e===void 0||e.forEach(s=>{var n;return(n=s.hostUpdate)===null||n===void 0?void 0:n.call(s)}),this.update(r)):this._$Ek()}catch(s){throw i=!1,this._$Ek(),s}i&&this._$AE(r)}willUpdate(e){}_$AE(e){var i;(i=this._$ES)===null||i===void 0||i.forEach(r=>{var s;return(s=r.hostUpdated)===null||s===void 0?void 0:s.call(r)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(e){return!0}update(e){this._$EC!==void 0&&(this._$EC.forEach((i,r)=>this._$EO(r,this[r],i)),this._$EC=void 0),this._$Ek()}updated(e){}firstUpdated(e){}};Nc[tq]=!0,Nc.elementProperties=new Map,Nc.elementStyles=[],Nc.shadowRootOptions={mode:"open"},j_t?.({ReactiveElement:Nc}),((ZW=mD.reactiveElementVersions)!==null&&ZW!==void 0?ZW:mD.reactiveElementVersions=[]).push("1.6.3");var eq,fD=window,nb=fD.trustedTypes,W_t=nb?nb.createPolicy("lit-html",{createHTML:t=>t}):void 0,rq="$lit$",Tm=`lit$${(Math.random()+"").slice(9)}$`,Z_t="?"+Tm,L5t=`<${Z_t}>`,h0=document,mT=()=>h0.createComment(""),fT=t=>t===null||typeof t!="object"&&typeof t!="function",Q_t=Array.isArray,F5t=t=>Q_t(t)||typeof t?.[Symbol.iterator]=="function",iq=`[
|
|
5177
|
+
`,O_t=class{constructor(t,e,i,r,s,n){this.container=t,this.host=e,this.observer=i,this.spline=r,this.previousSplineGlobal=s,this.removeLateLifecycleShim=n}static mount(t,e,i,r){if(typeof document>"u")return null;let s=e.parentElement;if(!s)return null;getComputedStyle(s).position==="static"&&(s.style.position="relative");let n=document.createElement("div");n.setAttribute(P4,"");let a=n.style;a.position="absolute",a.overflow="hidden";let o=()=>{a.left=`${e.offsetLeft}px`,a.top=`${e.offsetTop}px`,a.width=`${e.offsetWidth}px`,a.height=`${e.offsetHeight}px`};o();let l=new ResizeObserver(o);l.observe(e),l.observe(s);let u=document.createElement("style");u.textContent=S5t,n.appendChild(u);let h=new DOMParser().parseFromString(i,"text/html"),d=Array.from(h.querySelectorAll("script"));for(let v of d)v.remove();for(let v of Array.from(h.head.children))(v.tagName==="STYLE"||v.tagName==="LINK"&&v.rel==="stylesheet")&&n.appendChild(v);for(;h.body.firstChild;)n.appendChild(h.body.firstChild);s.insertBefore(n,e.nextSibling);let c=new Map,p=new H7(D_t(t,e,r),(v,b)=>{v==="warn"?console.warn(`[spline html] ${b}`):v==="error"&&console.error(`[spline html] ${b}`)},(v,b)=>{let _=c.get(v);if(_)for(let x of _)try{x(b)}catch(S){console.error(S)}}),m=(v,b)=>{try{return Promise.resolve(p.execute(v,b))}catch(_){return Promise.reject(_)}},f={ready:Promise.resolve(),setVariable:(v,b)=>m("setVariable",[v,b]),setVariables:v=>m("setVariables",[v]),getVariable:v=>m("getVariable",[v]),getVariables:()=>m("getVariables",[]),getAllObjects:()=>m("getAllObjects",[]),findObjectByName:v=>m("findObjectByName",[v]),findObjectById:v=>m("findObjectById",[v]),getGeometry:(v,b)=>m("getGeometry",[v,b??{}]),updateObject:(v,b)=>m("updateObject",[v,b]),createObject:(v,b)=>m("createObject",[v,b??{}]),createCustomMaterial:v=>m("createCustomMaterial",[v]),getTexture:(v,b)=>m("getTexture",[v,b??{}]),setMaterial:(v,b)=>m("setMaterial",[v,b]),cloneObject:(v,b)=>m("cloneObject",[v,b??{}]),removeObject:v=>m("removeObject",[v]),spawnObject:(v,b)=>m("spawnObject",[v,b??{}]),destroyObject:v=>m("destroyObject",[v]),setInstanceTransforms:(v,b)=>m("setInstanceTransforms",[v,b??null]),emitEvent:(v,b)=>m("emitEvent",[v,b]),emitEventReverse:(v,b)=>m("emitEventReverse",[v,b]),requestRender:()=>m("requestRender",[]),addEventListener:(v,b)=>{if(typeof b!="function")return;let _=c.get(v);_||(_=new Set,c.set(v,_),m("listenEvent",[v])),_.add(b)},removeEventListener:(v,b)=>{let _=c.get(v);!_||(_.delete(b),_.size===0&&(c.delete(v),m("unlistenEvent",[v])))}},g=window.spline;window.spline=f;let y=function(){if(typeof document>"u"||document.readyState==="loading")return()=>{};let v=[],b=(x,S)=>{let w=new Set,T=x.addEventListener.bind(x),A=x.removeEventListener.bind(x);Object.defineProperty(x,"addEventListener",{configurable:!0,writable:!0,value:(M,C,R)=>{if(T(M,C,R),!S.includes(M)||C==null)return;let O={type:M,listener:C};w.add(O),queueMicrotask(()=>{!w.delete(O)||((N,B,k)=>{let z=new Event(k);try{typeof B=="function"?B.call(N,z):B.handleEvent?.(z)}catch(L){console.error(L)}})(x,O.listener,O.type)})}}),Object.defineProperty(x,"removeEventListener",{configurable:!0,writable:!0,value:(M,C,R)=>{A(M,C,R);for(let O of w)O.type===M&&O.listener===C&&w.delete(O)}}),v.push(()=>{delete x.addEventListener,delete x.removeEventListener,w.clear()})};b(document,["DOMContentLoaded"]),b(window,["load"]);let _=Object.getOwnPropertyDescriptor(window,"onload");return Object.defineProperty(window,"onload",{configurable:!0,get:()=>null,set:x=>{typeof x=="function"&&queueMicrotask(()=>{try{x.call(window,new Event("load"))}catch(S){console.error(S)}})}}),v.push(()=>{_?Object.defineProperty(window,"onload",_):delete window.onload}),()=>{for(let x of v)x()}}();for(let v of d){let b=document.createElement("script");for(let _ of Array.from(v.attributes))b.setAttribute(_.name,_.value);v.src?b.async=!1:b.textContent=v.textContent,n.appendChild(b)}return new O_t(n,p,l,f,g,y)}dispose(){this.removeLateLifecycleShim(),this.host.dispose(),this.observer.disconnect(),this.container.remove(),window.spline===this.spline&&(window.spline=this.previousSplineGlobal)}};function I_t(t){return typeof t=="object"&&t!==null&&t.isMaterial===!0}function Wdt(t){if(typeof t.material=="function")throw new Error("createObject: a (three) => material factory must be resolved to a material instance before object creation \u2014 this entry point does not support it.");if(!I_t(t.material))return{options:t};let e=t.material;if(e.isNodeMaterial===!0){let i=KU()?.NodeMaterial;if(i!==void 0&&e instanceof i)return{options:{...t,material:void 0},material:e};throw new Error("createObject: this TSL NodeMaterial comes from your own three/webgpu module instance, which cannot compile in the runtime's bundled three. Build it with app.createCustomMaterial((three) => \u2026) instead, or use a built-in material (MeshStandardMaterial, MeshBasicMaterial, \u2026).")}if(e.isShaderMaterial===!0)throw new Error("createObject: a GLSL ShaderMaterial cannot compile on the WebGPU backend \u2014 port the shader to TSL with app.createCustomMaterial((three) => \u2026), or use a built-in material (MeshStandardMaterial, \u2026).");return{options:{...t,material:void 0},material:e}}ke(),Fi(),dt(),_gt(),Rc(),Fi(),ke(),UMt(),wm();var T5t=new Set(["name","parent","position","rotation","scale","visible","castShadow","receiveShadow","color","material"]),qdt="'Cube', 'Sphere', 'Plane', 'Rectangle', 'Ellipse', 'Triangle', 'Polygon', 'Star', 'Cone', 'Cylinder', 'Pyramid', 'Torus', 'TorusKnot', 'Dodecahedron', 'Icosahedron', 'Helix', 'Backdrop', 'Lathe', 'Text', 'CustomMesh', 'Group', 'PointLight', 'SpotLight', 'DirectionalLight'",M5t={cube:"CubeGeometry",box:"CubeGeometry",sphere:"SphereGeometry",plane:"PlaneGeometry",rectangle:"RectangleGeometry",ellipse:"EllipseGeometry",circle:"EllipseGeometry",triangle:"TriangleGeometry",polygon:"PolygonGeometry",star:"StarGeometry",cone:"ConeGeometry",cylinder:"CylinderGeometry",pyramid:"PyramidGeometry",torus:"TorusGeometry",torusknot:"TorusKnotGeometry",dodecahedron:"DodecahedronGeometry",icosahedron:"IcosahedronGeometry",helix:"HelixGeometry",backdrop:"BackdropGeometry",lathe:"LatheGeometry",text:"TextGeometry",custommesh:"NonParametricGeometry",nonparametric:"NonParametricGeometry"},A5t={group:"Empty",empty:"Empty",pointlight:"PointLight",spotlight:"SpotLight",directionallight:"DirectionalLight"},C5t={shapeblend:"Shape Blends are built from member meshes in the editor and cannot be created empty.",path:"Path shapes need authored path data \u2014 clone an existing one with cloneObject() instead.",vector:"Vector shapes need authored shape data \u2014 clone an existing one with cloneObject() instead.",shape:"Vector shapes need authored shape data \u2014 clone an existing one with cloneObject() instead.",boolean:"Boolean operations are not creatable at runtime \u2014 clone an existing Boolean object with cloneObject() instead.",decal:"Decals need a surface to project onto \u2014 clone an existing Decal with cloneObject() instead.",ui:"UI objects need a 2D frame \u2014 clone an existing one with cloneObject() instead.",input:"Text inputs are not creatable at runtime \u2014 clone an existing one with cloneObject() instead.",particle:"Particle emitters are not creatable at runtime \u2014 clone an existing one with cloneObject() instead.",particlecollider:"Particle forces are not creatable at runtime \u2014 clone an existing one with cloneObject() instead.",hair:"Hair systems are not creatable at runtime \u2014 clone an existing one with cloneObject() instead.",camera:"Cameras are not creatable at runtime.",perspectivecamera:"Cameras are not creatable at runtime.",orthographiccamera:"Cameras are not creatable at runtime.",hemispherelight:"Hemisphere lights are not creatable at runtime.",splat:"Splats are not creatable at runtime.",page:"Pages are not creatable at runtime.",component:"Components are authored in the editor.",instance:"Instances are authored in the editor \u2014 clone an existing one with cloneObject() instead.",bone:"Bones are not creatable at runtime.",mesh:"pass the shape name directly, e.g. createObject('Cube')."},E5t={CubeGeometry:"Cube",SphereGeometry:"Sphere",PlaneGeometry:"Plane",RectangleGeometry:"Rectangle",EllipseGeometry:"Ellipse",TriangleGeometry:"Triangle",PolygonGeometry:"Pentagon",StarGeometry:"Star",ConeGeometry:"Cone",CylinderGeometry:"Cylinder",PyramidGeometry:"Pyramid",TorusGeometry:"Torus",TorusKnotGeometry:"Torus Knot",DodecahedronGeometry:"Dodecahedron",IcosahedronGeometry:"Icosahedron",HelixGeometry:"Helix",BackdropGeometry:"Backdrop",LatheGeometry:"Lathe",TextGeometry:"Text",NonParametricGeometry:"Custom Mesh"},P5t={Empty:"Group",PointLight:"Point Light",SpotLight:"Spot Light",DirectionalLight:"Directional Light"};function HS(t,e){return t===void 0?[e[0],e[1],e[2]]:Array.isArray(t)?[t[0]??e[0],t[1]??e[1],t[2]??e[2]]:[t.x??e[0],t.y??e[1],t.z??e[2]]}function B_t(t){return typeof t=="number"?[t,t,t]:HS(t,[1,1,1])}function P7(t){let e=new Dr(0,0,0,1);return e.setStyle(t),{r:e.r,g:e.g,b:e.b}}function Hdt(t,e){let i=t.material??(t.color!==void 0?{color:t.color}:void 0);if(i===void 0)return cs.defaultColorMaterial($dt(Kg),"physical","layer1","layer2");if(typeof i=="string"){for(let[a,o]of Object.entries(e.shared.materials))if(a===i||o.name===i)return a;if(function(a){let o=a.trim().toLowerCase();return/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(o)||/^(rgb|hsl)a?\(/.test(o)||ae.NAMES[o]!==void 0}(i))return cs.defaultColorMaterial(P7(i),"physical","layer1","layer2");throw new Error(`createObject: material '${i}' matches no shared material in this document (available: ${function(a){let o=Object.entries(a.shared.materials).map(([,l])=>`'${l.name}'`).filter(l=>l!=="'undefined'");return o.length?o.join(", "):"(none)"}(e)}) and is not a valid CSS color.`)}if(typeof i=="function")throw new Error("createObject: a (three) => material factory must be resolved to a material instance before object creation \u2014 this entry point does not support it.");if(I_t(i))throw new Error("createObject: a three.js material instance cannot be stored in the document \u2014 this entry point does not support it.");let r=i.color!==void 0?P7(i.color):$dt(Kg),s=cs.defaultColorMaterial(r,"physical","layer1","layer2"),n=s.layers.find(a=>a.data.type==="light");if(n){let a={};i.roughness!==void 0&&(a.roughness=i.roughness),i.metalness!==void 0&&(a.metalness=i.metalness),i.reflectivity!==void 0&&(a.reflectivity=i.reflectivity),Object.assign(n.data,a)}if(i.alpha!==void 0){let a=s.layers.find(o=>o.data.type==="color");a&&Object.assign(a.data,{alpha:i.alpha})}return s}function $dt(t){return{r:(t>>16&255)/255,g:(t>>8&255)/255,b:(255&t)/255}}function R5t(t){let e=lc.defaultData("TextGeometry"),{text:i,...r}=t,s=r.fontSize;return s!==void 0&&r.width===void 0&&(r.width=350*s/16),s!==void 0&&r.height===void 0&&(r.height=50*s/16),Object.assign(e,r),i!==void 0&&Object.assign(e,{text:{textValue:String(i)}}),e}function oP(t){return Array.isArray(t)?t:!ArrayBuffer.isView(t)||t instanceof DataView?null:Array.from(t)}function D5t(t,e){return $mt({userData:{type:t,...XU[t].normalizeInputs({parameters:e})}})}function N5t(t,e,i){let{objectType:r,geometryType:s}=t,n=function(l){let u={};for(let[h,d]of Object.entries(l))!T5t.has(h)&&d!==void 0&&(u[h]=d);return u}(e),a={states:new ge,events:new ge};if(r==="Mesh"&&s){if(s==="NonParametricGeometry"){let{geometry:l,doubleSide:u}=function(h){let d=oP(h.vertices);if(!d||d.length<9||d.length%3!=0)throw new Error("createObject('CustomMesh'): `vertices` must be a flat number[] of x,y,z triples (length a multiple of 3, at least one triangle).");let c=d.length/3;if(c>6e4)throw new Error(`createObject('CustomMesh'): too many vertices (${c}); keep it under 60000.`);let p=oP(h.indices);if(p&&p.length){let b=p.find(_=>!Number.isInteger(_)||_<0||_>=c);if(b!==void 0)throw new Error(`createObject('CustomMesh'): index ${b} is out of range (mesh has ${c} vertices).`)}else p=null;let m=new ye;m.setAttribute("position",new fe(d,3));let f=oP(h.normals),g=f!==null&&f.length===d.length;g&&m.setAttribute("normal",new fe(f,3));let y=oP(h.uvs);y&&y.length===2*c&&m.setAttribute("uv",new fe(y,2));let v=!1;if(!g){let b=p??Array.from({length:c},(S,w)=>w),{closed:_,inverted:x}=function(S,w){let T=S.length/3,A=new Map,M=new Array(T);for(let N=0;N<T;N++){let B=`${Math.round(1e4*S[3*N])},${Math.round(1e4*S[3*N+1])},${Math.round(1e4*S[3*N+2])}`,k=A.get(B);k===void 0?(A.set(B,N),M[N]=N):M[N]=k}let C=new Map;for(let N=0;N+2<w.length;N+=3){let B=M[w[N]],k=M[w[N+1]],z=M[w[N+2]];for(let[L,V]of[[B,k],[k,z],[z,B]]){if(L===V)continue;let q=L<V?L+"_"+V:V+"_"+L;C.set(q,(C.get(q)??0)+1)}}let R=C.size>0;for(let N of C.values())if(N!==2){R=!1;break}if(!R)return{closed:!1,inverted:!1};let O=0;for(let N=0;N+2<w.length;N+=3){let B=3*w[N],k=3*w[N+1],z=3*w[N+2],L=S[B],V=S[B+1],q=S[B+2],j=S[k],Q=S[k+1],it=S[k+2],at=S[z],St=S[z+1],yt=S[z+2];O+=L*(Q*yt-it*St)+V*(it*at-j*yt)+q*(j*St-Q*at)}return{closed:!0,inverted:O<0}}(d,b);if(_&&x){for(let S=0;S+2<b.length;S+=3){let w=b[S+1];b[S+1]=b[S+2],b[S+2]=w}p=b}else _||(v=!0)}return p&&m.setIndex(p),g||m.computeVertexNormals(),{geometry:$mt({userData:{type:"NonParametricGeometry",parameters:{subdivisions:0}},data:m.toJSON().data}),doubleSide:v}}(n);Object.assign(a,Bu.defaultData,{geometry:l,materials:[Hdt(e,i)]}),u&&(a.side=2)}else Object.assign(a,Bu.defaultData,{geometry:s==="TextGeometry"?R5t(n):D5t(s,n),material:Hdt(e,i)});e.castShadow!==void 0&&(a.castShadow=e.castShadow),e.receiveShadow!==void 0&&(a.receiveShadow=e.receiveShadow)}else r==="Empty"?Object.assign(a,cR.defaultData):(Object.assign(a,pR.defaultData(r),n),e.color!==void 0&&(a.color=P7(e.color)));a.visible=e.visible??!0,a.position=HS(e.position,[0,0,0]),a.rotation=HS(e.rotation,[0,0,0]),a.scale=B_t(e.scale);let o=(s&&E5t[s])??P5t[r]??r;return a.name=e.name??V_t(o,i.scene.objects),a}function V_t(t,e){let i=new Set;if(e.traverse((s,n)=>{i.add(n.name??"")}),!i.has(t))return t;let r=2;for(;i.has(`${t} ${r}`);)r++;return`${t} ${r}`}function k_t(t,e){let i=qt.generateUUID();if(t.data.type==="Component")return{data:{...yc.fromComponentData(t),name:t.data.name+" Instance"},id:i,fi:t.fi,children:[]};e[t.id]=i;let r=t.data;return r.type==="Empty"&&r.animations?.length&&(r={...r,animations:r.animations.map(([s,n,a])=>{let o=qt.generateUUID(),l=a.indexOf(s);return[o,n,l!==-1?a.slice(0,l)+o+a.slice(l+s.length):a]})}),{...t,id:i,data:r,children:t.children.map(s=>k_t(s,e))}}function O5t(t){let e={};return function(i,r){return nv(i,r,null)??i}(k_t(t,e),e)}function I5t(t){let e=Array.isArray(t)?t[0]:t,i=e.layers?.map(B5t)??[],r=e.layers?.find(s=>s.type==="light");return{layers:i,alpha:r?.node.alphaOverride?.value??1}}function B5t(t){return t.type==="texture"||t.type==="video"||t.type==="matcap"?{...t.data,updateTexture:e=>t.color.texture.image.updateSrc(e)}:{...t.data}}wm(),ns(),wG(),Rc();var Ew=new Dr(0,0,0,1),V5t={color:["color"],cavity:[],dust:["color"],fresnel:["color"],normal:[],gradient:["colors"],depth:["colors"],texture:[],video:[],noise:["colorA","colorB","colorC","colorD"],toon:["colors","shadowColor"],outline:["outlineColor","contourColor"],transmission:["attenuationColor"],reflection:[],matcap:[],pattern:["colorA","colorB"],vertexColor:[],light:[],displace:[],rainbow:[],particle:[]};ke(),ke();var k5t=new Z;function Xdt(t){let e=new Dr(0,0,0,1);try{e.setStyle(t)}catch(i){console.error(i)}return e}var z_t=class{constructor(t,{renderOnDemand:e,renderMode:i="auto",wasmPath:r,renderer:s,htmlContentMode:n="sandbox"}={}){if(this._rendererBackend="webgl",this._rendererAuto=!1,this._rendererConfigured=!1,this._viewportMode=1,this._viewportWidth=window.innerWidth,this._viewportHeight=window.innerHeight,this._proxyObjectCache=new Map,this._htmlContentMode="sandbox",this._variablesCache=new Map,this._isPaused=!1,this._renderRequested=!1,this._skipRender=!1,this.time=performance.now(),this.dt=0,this.currentTAAFrame=0,this.disposed=!1,this._requestRenderAutoMode=()=>{this._skipRender=!1},this.requestRender=()=>{this._renderRequested=!0},this.render=a=>{if(this.time=a,this._lastTime&&(this.dt=this.time-this._lastTime),this._lastTime=this.time,this._perfs?.start(),this._renderer)if(this._isPaused||!(this.renderMode==="manual"&&!this._renderRequested||this.renderMode==="auto"&&this._skipRender)){if(this._renderRequested=!1,this._skipRender=!0,this._controls&&(this._skipRender=this._controls.update(this.dt)??!1),this._eventManager&&(this._eventManager.handlers?.Start?.hasVideoAction||this._eventManager.handlers?.Basic?.hasVideoAction||this._eventManager.handlers?.Conditional?.hasVideoAction)&&(this._skipRender=!1),this._animationControls?.update(this.dt),this._skipRender?(this.currentTAAFrame++,this.currentTAAFrame<Ymt?this._skipRender=!1:this.currentTAAFrame=0):this.currentTAAFrame=0,this._scene?.traverseVisibleEntity(o=>{o.type==="ParticleSystem"&&(o.update(this.dt),this._skipRender=!1),Jg(o)&&(this._renderer?.isWebGPUSplineRenderer!==!0&&o.warnClassicFallbackOnce(),o.isSimulating&&(o.update(this.dt),this._skipRender=!1))}),this._scene&&this._scene.activeCamera!==this._camera&&(this._camera=this._scene.activeCamera),this._eventManager?.isEnabled&&(this._eventManager.handlers?.Follow?.onAnimationFrameDamping(),this._eventManager.handlers?.LookAt?.onAnimationFrameDamping(),this._eventManager.handlers?.DragDrop?.onAnimationFrameDamping()),this._scene&&this._camera){if(this._scene.pathConstraints.applyConstraints(this._scene),this._renderer.sceneTransitionTimeRemaining>0){this._renderer.sceneTransitionTimeRemaining-=this.dt;let o=Math.min(1,1-this._renderer.sceneTransitionTimeRemaining/this._renderer.sceneTransitionDuration);this._renderer.pipeline.sceneTransitionPass.uniforms.mixRatio.value=o,this._skipRender=!1}else this._renderer.pipeline.sceneTransitionFromTexture=null;this._renderer.renderSplineScene(this._scene,this._camera),this._renderer.lastFrameIncomplete===!0&&(this._skipRender=!1),this._renderer.skyAnimationActive===!0&&(this._skipRender=!1)}this.canvas.dispatchEvent(this._renderedEvent),this._perfs?.end()}else this._perfs?.end();else this._perfs?.end()},this._resize=a=>{if(this._renderer){if(this._viewportMode===1&&this._frameView&&(this._frameView.frameSize=k5t.set(this._viewportWidth,this._viewportHeight)),a){let o=this._viewportWidth,l=this._viewportHeight;this._renderer.setSize(o-1,l-1,!1),this._renderer.setSize(o,l,!1)}else this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1);this._camera=this._scene?.activeCamera,this._scene?.updateViewPlaneSize(this._frameView?.frameSize?.x??this._viewportWidth,this._frameView?.frameSize?.y??this._viewportHeight,this._frameView?.enableResponsive??!1),this._camera&&(this._frameView?.setCamera(this._camera),this._frameView?.updateCamera(),this._camera.cameraType==="PerspectiveCamera"&&(this._camera.aspect=this._viewportWidth/this._viewportHeight),this._camera.updateProjectionMatrix()),this.eventManager&&(this.eventManager.eventContext.domRect=this.canvas.getBoundingClientRect()),this._requestRenderAutoMode()}},this._debouncedResize=AS(this._resize,10),this._onScroll=a=>{this.eventManager&&(this.eventManager.eventContext.domRect=this.canvas.getBoundingClientRect())},this.canvas=t,this._htmlContentMode=n,this.renderMode=e?"auto":i,r!==void 0&&(this._wasmPath=function(a){let o=a.length;for(;o>0&&"/".includes(a[o-1]);)o--;return a.slice(0,o)}(r)),this._rendererBackend=s??"webgl",s===void 0){let a=null;try{a=new URLSearchParams(window.location.search).get("renderer")}catch{}a==="webgpu"||a==="webgl"||a==="webgl2"?this._rendererBackend=a==="webgl2"?"webgl":a:(this._rendererAuto=!0,this._rendererBackend=typeof navigator<"u"&&"gpu"in navigator?"webgpu":"webgl")}this._renderedEvent=new CustomEvent("rendered",{bubbles:!0}),Object.defineProperty(this._renderedEvent,"target",{writable:!1,value:this}),window.location.search.includes("perfs")&&Promise.resolve().then(()=>(CAt(),$yt)).then(({Perfs:a})=>{this._perfs=new a({x:10,y:10})}),function(a){a.addEventListener("pointerdown",C$,!0),a.addEventListener("pointerdown",mM,!0),a.addEventListener("pointermove",mM,!0),a.addEventListener("pointerup",O0,!0),a.addEventListener("pointercancel",O0,!0),a.addEventListener("pointerleave",O0,!0),window.addEventListener("keydown",E$,!0),window.addEventListener("keyup",P$,!0)}(t)}async _createRenderer(){if(this._rendererBackend==="webgpu"&&this._rendererAuto)try{await navigator.gpu?.requestAdapter()||(this._rendererBackend="webgl")}catch{this._rendererBackend="webgl"}if(this._rendererBackend==="webgpu")try{let{createWebGPUSplineRenderer:t,isWebGPUSupported:e}=await Promise.resolve().then(()=>(KL(),T4));e();let i=!0,r=!1,s=this._data?.scene.publish?.asyncShaderCompilation!==!1;try{let a=new URLSearchParams(window.location.search),o=a.get("bundles");o==="rerecord"?i="rerecord":(o==="off"||o==="0"||o==="false"||o==="no")&&(i=!1),r=a.get("forcegl")==="1";let l=a.get("asynccomp");l==="off"||l==="0"||l==="false"||l==="no"?s=!1:(l==="on"||l==="1"||l==="true"||l==="always")&&(s=!0)}catch{}let n=await t({canvas:this.canvas,antialias:!1,alpha:!0,powerPreference:"high-performance",sceneBundles:!r&&i,forceWebGL:r,asyncCompilation:!r&&s});return n.onBackgroundWorkReady=()=>{this._skipRender=!1,this._renderRequested=!0},n.skyAnimationAllowed=!0,n}catch(t){console.error("[spline] Failed to initialize the WebGPU renderer, falling back to WebGL:",t),this._rendererBackend="webgl"}throw this._failWebGPURequired(),new Error("[spline] This runtime build is WebGPU-only and the browser provides no WebGPU adapter.")}_failWebGPURequired(){console.error('[spline] This scene was exported for WebGPU only and this browser does not provide a WebGPU adapter. Re-export with renderer "Both" or "WebGL 2" to support this browser.');try{let t=window.devicePixelRatio||1,e=this.canvas.clientWidth||300,i=this.canvas.clientHeight||150;this.canvas.width=e*t,this.canvas.height=i*t;let r=this.canvas.getContext("2d");r&&(r.scale(t,t),r.fillStyle="rgba(127, 127, 127, 0.85)",r.font="13px system-ui, -apple-system, Segoe UI, Roboto, sans-serif",r.textAlign="center",r.textBaseline="middle",r.fillText("This scene requires a WebGPU-capable browser.",e/2,i/2))}catch{}this.canvas.dispatchEvent(new CustomEvent("splineerror",{bubbles:!0,detail:{reason:"webgpu-required"}}))}async load(t,e,i){(function(s){let n="The Spline Runtime only accepts .splinecode files that are generated from Spline export panel.";s.endsWith(".spline")?console.warn(n+" The .spline files are only meant to be used by the Editor."):s.endsWith(".splinecode")||console.warn(n)})(t),this.disposed=!1;let r=await(await fetch(t,i)).arrayBuffer();await this.start(r,{variables:e})}async start(t,{interactive:e=!0,variables:i}={}){if(this.disposed)return;Is.init();let r=await async function(c){let[p,m]=Gw(CS.deserialize(new Uint8Array(c)));if((p.schema??0)!==131){let{updateDocumentSchema:f}=await Promise.resolve().then(()=>(P5(),Lmt));f(p)}return m.result().data}(t);this._data=r;let s=function(c){let p=[];return c.scene.objects.traverse((m,f)=>{f.type==="Mesh"&&f.geometry.type==="NonParametricGeometry"&&f.geometry.data.draco!==void 0&&p.push(f)}),p}(r);r.version&&(0,x5t.default)(r.version,"2.0.61")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/runtime to the latest version."),this._wasmPath!==void 0&&(this.setUIWasmUrl(`${this._wasmPath}/hana-ui.wasm`),function(c){bj=c}(this._wasmPath));let n=async function(){}();await Promise.all([n,s.length&&Udt(this._wasmPath),OK(r)&&YMt(this._wasmPath),y3t(r)&&g3t(this._wasmPath),F3t(r)&&T3t(this._wasmPath),Qg.physicsEnabled(r.scene.objects)&&PPt(this._wasmPath),VY(r)&&Sut(),tZ(r)&&lAt(),n3t(r)&&s3t(),fut(r)&&n.then(()=>wU()?.loadHanaUIRUNTIME()),wPt(r)&&qPt(this._wasmPath)].filter(Boolean)),s.length&&await jdt(s),this._eventManager?.deactivate(),this._controls?.deactivate(),this._scene?.dispose();let a=r.scene.publish.renderer;if(this._rendererAuto&&a==="webgl")this._rendererBackend="webgl";else if(this._rendererAuto&&a==="webgpu"){if(this._rendererBackend!=="webgpu"||!await navigator.gpu?.requestAdapter().catch(()=>null))return void this._failWebGPURequired();this._rendererAuto=!1}let o=function(c){let p=new Set;return c.scene.objects.traverse((m,f)=>{if(f.type!=="Page")return;let g=f.postprocessing;if(g&&typeof g=="object"&&g.enabled===!0)for(let[y,v]of Object.entries(g))y!=="enabled"&&v&&typeof v=="object"&&v.enabled===!0&&p.add(y)}),[...p]}(r);if(this._rendererBackend==="webgpu")try{await Promise.all([Promise.resolve().then(()=>(KL(),T4)),_5t(o)]),this._renderer||(this._renderer=await this._createRenderer())}catch(c){console.error("[spline] Failed to load the WebGPU material backend, using WebGL:",c),this._rendererBackend="webgl"}if(this._rendererBackend!=="webgpu")return void this._failWebGPURequired();(function(c){iT=c})(this._rendererBackend==="webgpu"?"webgpu":"webgl");let l=new f5t(r);if(l.resetPersonalCameraFromDocumentData(),this._scene=l.scene,this._sharedAssetsManager=l.sharedAssets,this._camera=this._scene.activeCamera,window.location.search.includes("merge-geometries")){let{mergeStaticGeometries:c}=await Promise.resolve().then(()=>(oEt(),ybt)),p=performance.now();c(r,l.scene);let m=performance.now();console.log("Merged geometries in ",m-p," ms")}OK(r)&&this._scene.traverse(c=>{Hu(c)&&c.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this._requestRenderAutoMode(),this._scene?.traverse(c=>{H1(c)&&c.pendingMediaLoad&&c.update({scene:this._scene,shared:this._sharedAssetsManager})})}),this._scene?.traverse(c=>{c.type==="ParticleSystem"&&(c.wakeUp(),c.data.autoPlay?c.start():c.stop()),Jg(c)&&c.setPlayMode(!0)});let u=Object.keys(r.shared.fonts).flatMap(c=>{let p=this._sharedAssetsManager.getFont(c);return p?[p.loadingPromise]:[]});if(Promise.all(u).then(()=>{this.disposed||(l.scene.markNeedsUpdateRendererDirty(),this._requestRenderAutoMode())}),VY(r)&&function(c){if(Qg.physicsEnabled(c.scene.objects))return!0;let p=!1;return c.scene.objects.traverse((m,f)=>{if(f.events){if(Array.isArray(f.events)){for(let g of f.events)if(g.data.disabled!==!0&&g.data.type==="GameControl"&&g.data.collisionEnabled){p=!0;break}}else for(let g of Object.values(f.events))if(g.disabled!==!0&&g.type==="GameControl"&&g.collisionEnabled){p=!0;break}}}),p}(r)&&await Promise.all(u),fut(r)){let c=[];this._scene.traverseEntity(p=>{(Ya(p)||p instanceof Hs)&&p.uiCanvas&&c.push(p.uiCanvas)}),await Promise.all(c.map(p=>p.promise))}if(this._scene.rewriteEventsBeforeGoToPlayMode(),$W(this._scene.activePage,this._sharedAssetsManager),this._renderer||(this._renderer=await this._createRenderer()),!this._rendererConfigured){this._rendererConfigured=!0,this._renderer.hdTransmission=r.scene.publish.hdTransmission===!0;let c=()=>/Mobi|Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),p=this._getPixelRatio(c()?r.scene.publish.settings.web.pixelRatioMobile:r.scene.publish.settings.web.pixelRatioDesktop);if(this._renderer.setPixelRatio(p),this._renderer.pipeline.enableUIOverlay(),this._renderer.pipeline.addEventListener("smaaloaded",this._requestRenderAutoMode),r.shared.images.SplineWatermark){let m=this._sharedAssetsManager.getImage("SplineWatermark");await m.loadPromise;let f=m.getTexture(1001);this._renderer.pipeline.setWatermark(f)}}tZ(r)&&this._scene.initializeSplatViewer(),r.scene.blueNoiseTextureData!==void 0&&this._renderer.pipeline.updateBlueNoiseTexture(r.scene.blueNoiseTextureData);let h=Object.values(r.frames)[0];if(this._frameView?this._frameView.setCamera(this._camera):(h.preset==="fullscreen"?(this._viewportMode=1,this.canvas.style.display="block",this.canvas.parentElement&&(this._viewportWidth=this.canvas.parentElement.clientWidth||300,this.canvas.style.width="100%"),this.canvas.parentElement&&(this._viewportHeight=this.canvas.parentElement.clientHeight||150,this.canvas.style.height="100%")):(this._viewportMode=2,this._viewportWidth=h.size[0],this._viewportHeight=h.size[1],this.canvas.style.width=`${this._viewportWidth}px`,this.canvas.style.height=`${this._viewportHeight}px`),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._frameView=new jEt(this._renderer,this._camera,new Z(this._viewportWidth,this._viewportHeight)),this._frameView.enableResponsive=(h.allowResponsive??!1)&&h.preset==="fullscreen"),e){let c=new xEt(this._renderer,this.data.scene.publish,this._scene,()=>this._scene.activeCamera,this._sharedAssetsManager,this._requestRenderAutoMode,!0,h);this._scene.updateMatrixWorld(!0),this._controls=new OPt(c),this._animationControls=new v5t(this._scene,this._requestRenderAutoMode),this._eventManager=new VEt(r.scene.publish,this._controls,this._animationControls,c,r.shared.variables),this._eventManager.activate(),this._controls.activate(this._eventManager)}this._resize(),this._scene.activePage.data.postprocessing.depthOfField.enabled&&Promise.all(this._sharedAssetsManager.getImageLoadPromises()).then(()=>{this.disposed||this._resize(!0)}),i!==void 0&&this.setVariables(i),this.dt===0&&(this.render(performance.now()),setTimeout(()=>{this._renderer?.setAnimationLoop(this.render)},0)),this._resizeObserverTimeout=setTimeout(()=>{!this._resizeObserver&&this.canvas.parentElement&&(this._resizeObserver=new ResizeObserver(()=>{this._viewportWidth=this.canvas.clientWidth,this._viewportHeight=this.canvas.clientHeight,this._debouncedResize()}),this._resizeObserver.observe(this.canvas.parentElement))},300),document.addEventListener("scroll",this._onScroll),e&&(this._htmlContentOverlay?.dispose(),this._htmlContentOverlay=void 0);let d=r.scene.publish.htmlContent?.html;if(e&&d&&this._htmlContentMode!=="none"){let c={shared:this._sharedAssetsManager,findEntity:p=>this._scene?.getObjectByProperty("uuid",p)??this._scene?.getObjectByName(p)};this._htmlContentOverlay=(this._htmlContentMode==="inline"?O_t.mount(this,this.canvas,d,c):N_t.mount(this,this.canvas,d,c))??void 0}}setVariables(t){if(this._data!==void 0){let e=Object.entries(t);for(let[i,r]of e)this.setVariable(i,r)}}setVariable(t,e){let i=this._getVariableByName(t);if(i&&!("dynamicVariableType"in i.data)){let r=e;typeof i.data.value=="number"?r=typeof e=="number"?e:typeof e=="boolean"?e===!0?1:0:parseFloat(e):typeof i.data.value=="boolean"?r=typeof e=="number"?!!e:typeof e=="boolean"?e:e.toLocaleLowerCase()!=="false"&&!!e:typeof i.data.value!="string"&&i.data.value.textValue!==void 0&&(r=e.toString());let s=typeof r=="string"?{textValue:r}:r;this._sharedAssetsManager?.updateVariable(i.id,s),this.requestRender(),this._requestRenderAutoMode()}else i===void 0?console.warn(`No variable named ${t} was found in your Spline file. Make sure to create it from Spline editor.`):"dynamicVariableType"in i.data&&console.warn(`Dynamic variables like ${t} cannot be updated from code.`)}getVariables(){let t={};return this._data&&this._data.shared.variables.forEach(e=>{t[e.data.name]===void 0&&(t[e.data.name]=this._getVariableValue(this._sharedAssetsManager.getVariable(e.id)))}),t}getVariable(t){let e=this._getVariableByName(t);if(e){let i=this._sharedAssetsManager.getVariable(e.id);return this._getVariableValue(i)}}_getVariableValue(t){return typeof t!="string"&&Na.isTextValue(t)?Na.getDisplayedValue(t):t}_getVariableByName(t){if(this._data){if(this._variablesCache.has(t))return this._variablesCache.get(t);let e=this._data.shared.variables.find(i=>i.data.name===t);return e&&this._variablesCache.set(t,e),e}}_getPixelRatio(t){switch(t){case 0:return window.devicePixelRatio;case 1:return 1;case 2:return 2}}findObjectById(t){let e=this._scene?.getObjectByProperty("uuid",t);return this._createProxyObject(e)}findObjectByName(t){let e=this._scene?.getObjectByName(t);return this._createProxyObject(e)}getAllObjects(){let t=[];return this._scene?.traverseEntity(e=>{if(!(e.uuid===i0||this._scene.isInvisibleObjects(e)||e instanceof Hs)){let i=this._createProxyObject(e);i&&t.push(i)}}),t}getSplineEvents(){return(this._eventManager?.handlers?.Spline).splineEvents}emitEvent(t,e){(this.findObjectById(e)||this.findObjectByName(e))?.emitEvent(t)}emitEventReverse(t,e){(this.findObjectById(e)||this.findObjectByName(e))?.emitEventReverse(t)}addEventListener(t,e){this.canvas.addEventListener(t,e)}removeEventListener(t,e){this.canvas.removeEventListener(t,e)}setZoom(t){this._controls?.orbitControls instanceof Obt&&this._controls?.orbitControls.setZoom(t)}get eventManager(){return this._eventManager}get controls(){return this._controls}setSize(t,e){this._viewportWidth=t,this._viewportHeight=e,this._viewportMode=2,this._resize()}setBackgroundColor(t){let e=Xdt(t);this._scene?.activePage.setBackgroundColor(e),this._requestRenderAutoMode()}dispose(){this.disposed=!0,this._htmlContentOverlay?.dispose(),this._htmlContentOverlay=void 0,this._eventManager?.dispose(),this._scene?.dispose(),this._scene=void 0,this._camera=void 0,$2&&$2.disposeAll(),this._sharedAssetsManager?.setRequestRender(()=>{}),this._sharedAssetsManager?.dispose(),this._sharedAssetsManager=void 0,this._proxyObjectCache.forEach(t=>{ZL.unsubscribe(t)}),this._proxyObjectCache.clear(),this._variablesCache.clear(),this._renderer?.pipeline.removeEventListener("smaaloaded",this._requestRenderAutoMode),this._renderer?.setAnimationLoop(null),this._renderer?.dispose(),this._renderer=void 0,this._debouncedResize.cancel(),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=void 0),this._resizeObserverTimeout!==void 0&&(clearTimeout(this._resizeObserverTimeout),this._resizeObserverTimeout=void 0),this.canvas.style.width="",this.canvas.style.height="",this.canvas.removeAttribute("width"),this.canvas.removeAttribute("height"),this._frameView=void 0,this._controls?.deactivate(),this._controls=void 0,this._animationControls=void 0,this._eventManager?.eventContext.dispose(),this._eventManager=void 0,this._splatViewer=void 0,this._data=void 0,this._perfs=void 0,this.dt=0,this._lastTime=void 0,function(t){t.removeEventListener("pointerdown",C$,!0),t.removeEventListener("pointerdown",mM,!0),t.removeEventListener("pointermove",mM,!0),t.removeEventListener("pointerup",O0,!0),t.removeEventListener("pointercancel",O0,!0),t.removeEventListener("pointerleave",O0,!0),window.removeEventListener("keydown",E$,!0),window.removeEventListener("keyup",P$,!0)}(this.canvas),document.removeEventListener("scroll",this._onScroll),Is.dispose()}get isStopped(){return this._isPaused}stop(){this._isPaused||(this._renderer?.setAnimationLoop(null),this._isPaused=!0,this._eventManager?.pause(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!1))}play(){!this._isPaused||(this._isPaused=!1,this._eventManager?.resume(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!0),this._renderer?.setAnimationLoop(this.render))}setGlobalEvents(t){this._eventManager?.updateUseWindowEvents(t)}get data(){return this._data}_createProxyObject(t){if(!this._scene)return;let e,i=this._scene;if(t==null)return;if(this._proxyObjectCache.has(t.uuid))return this._proxyObjectCache.get(t.uuid);t.traverseAncestors(h=>{h instanceof Hs&&(e=h.name)});let r=this._sharedAssetsManager,s={shared:r,scene:this._scene},n=h=>{if(h===null||h==="Base State")return null;if(h&&t.data.states){let d=t.data.states.find(c=>c.data.name===h);return d?d.id:void 0}},a="material"in t?t.material:void 0,o=t.materialOverride,l={name:t.name,uuid:t.uuid,visible:t.visible,intensity:t.intensity,position:t.position,rotation:t.rotation,scale:t.scale,type:t.data.type,page:e,material:o??(a?I5t(a):void 0),parentUuid:t.parent instanceof Hs||t instanceof Pg?void 0:t.parent?.uuid,emitEvent(h){t.dispatchEvent({type:"userEvent",eventName:h})},emitEventReverse(h){t.dispatchEvent({type:"userEvent",eventName:h,reverse:!0})},hide(){t.visible&&(t.visible=!1,s.shared.requestRender())},show(){t.visible||(t.visible=!0,s.shared.requestRender())},get state(){let h=t.stateSelection;if(h!==null)return t.data.states.find(({id:d})=>d===h)?.data.name},set state(h){let d;if(h!==void 0){let c=typeof h=="string"?t.data.states.find(({id:p})=>p===h):t.data.states[h];if(c)d=c.id;else{let p=typeof h=="string"?n(h):void 0;p&&(d=p)}}t.changeSelectedState(d??null,s),t.currentState=d??null,t.dispatchEvent({type:"completeState",state:d??null}),s.shared.requestRender()},transition(h){let d=R_t;if(d===null)return Nn("transitions","obj.transition()"),{transition(_){return this},play(){return this},pause(){return this},reset(){return this},seek(_){return this}};let c,p,m=this,f=[],g=!1,y=()=>{p=new f_t({delay:0,delayDirection:"start-once",direction:"normal",repeat:0,runMode:"Repeat"},f.map(_=>_.runner))},v={update(_){p?.update(_),p?.isPlaying!==!0&&Is.remove(v)}},b={transition({from:_,to:x,duration:S,delay:w,...T}){let A=n(_);A===void 0&&(A=c);let M=n(x);return c=M,f.push(new d(t,A,M,{state:M,repeat:0,delay:w??0,delayDirection:"start-once",direction:"normal",duration:S??1e3,...T,...T.easing===6?Jp.defaultData:T.easing===5?Nv.defaultData:{}},r,!1,i.activePage,{onBegin:()=>{(_&&A||_==="Base State"&&!A)&&(m.state=A??void 0)},onComplete:()=>{m.state=M??void 0}})),y(),this},play(){return p?(g=!0,p.play(Is.time),p.isPlaying&&Is.add(v),this):this},pause(){return p?.stop(),Is.remove(v),this},reset(){return this.pause(),g=!1,y(),p?.seek(0),this},seek(_){let x=f.reduce((S,w)=>S+w.runner.duration,0);return x>0&&p?.seek(_/1e3/x),this}};return b.transition(h),(h.autoPlay??!0)&&queueMicrotask(()=>{g||b.play()}),b},set color(h){let d=Xdt(h);if(OR.is(t))return void(t.color=d);if(!(t.type==="Mesh"&&"material"in t&&t instanceof yo))return;let c={r:d.r,g:d.g,b:d.b,a:d.a},p=t.materialOverride;if(p!==void 0){let g=p.color;return void(g?.isColor===!0&&typeof g.setStyle=="function"&&(g.setStyle(h),s.shared.requestRender()))}let m=Array.isArray(t.material)?t.material[0]:t.material,f=m.data.layers.find(g=>g.data.type==="color")?.id;if(f)m.updateByOp({type:0,path:["layers",f],props:{color:{...c}}},m.data,s);else{let g=m.data,y=g.layers.find(w=>w.data.type==="light");if(!y)return;let v=g.layers.indexOf(y)===0?y:null,b=g.layers.at(v?g.layers.indexOf(v)+1:0),_={type:4,fi:v?v.fi+(b?(b.fi-v.fi)/2:1):b?b.fi/2:1,id:qt.generateUUID(),data:{...Ws.defaultData("color"),color:c},localIndex:0},x=g.layers.insertAfterHelper(v?.id??null,1),S=g.layers.runOp({..._,fi:x[0]}).data;Object.assign(m.data,{layers:S}),m.updateByOp({..._,path:["layers"]},m.data,s)}}},u=ZL(l,(h,d)=>{let c=t[h],p=function(m){return m.split(".")}(h);p[0]==="material"&&a&&o===void 0&&function(m,f,g){let y=Array.isArray(g)?g[0]:g;if(m[0]==="layers"){let v=parseInt(m[1]),b=y.layers[v],_=m[2];b&&_&&function(x,S,w){let T=x[0];try{if(function(A,M){return!!V5t[M]?.includes(A)}(T,w.type,x.slice(1)))if(T==="colors"){if(x.length<2)throw new Error("You cannot mutate the colors array, only its items");let A=parseInt(x[1]),M=w.getValue(T)?.[A];if(!M)throw new Error("Color index out of range");Ew.setStyle(S),M.set(Ew.r,Ew.g,Ew.b,Ew.a)}else w.getValue(T)?.setStyle(S);else if(T==="texture"||T==="video"){let A=w.color;(function(M,C,R,O){let N=M[0];if(N==="repeat"||N==="offset"||N==="rotation"){let B=O.getNode("mat"),k=B&&typeof B.updateMatrix=="function"?B:O.getValue("mat");if(!k)return;if(N==="rotation")k.rotation=parseFloat(C);else{let z=M[1];if(z===void 0)C instanceof Array&&C.length===2&&Object.assign(k,{[N]:C});else{let L=k[N],V=parseInt(z)===0?[parseFloat(C),L[1]]:[L[0],parseFloat(C)];Object.assign(k,{[N]:V})}}k.updateMatrix()}else N==="wrapping"||N==="minFilter"||N==="magFilter"?N==="wrapping"?R.texture.wrap=C:R.texture[N]=C:N==="image"&&M[1]==="data"&&R.texture.image.updateSrc(C)})(x.slice(1),S,A,w)}else{let A=x[1],M=w.getValue(T);M?.isVector3&&A!==void 0||M?.isVector2&&A!==void 0?M.setComponent(parseInt(A),S):w.setValue(T,S)}}catch(A){console.error("Error setting material value",A)}}(m.slice(2),f,b)}else m[0]==="alpha"&&y.layers.forEach(v=>{v.type==="light"&&v.node.alphaOverride!==void 0&&(v.node.alphaOverride.value=f,f<1&&(y.transparent=!0))})}(p.slice(1),d,a),typeof c!="object"&&Object.getOwnPropertyDescriptor(t,h)?.writable&&(t[h]=d),this._requestRenderAutoMode(),t.updateMatrix()});return this._proxyObjectCache.set(t.uuid,u),u}setUIWasmUrl(t){(function(e){xR=e,O5?.setHanaUIWasmUrl(e)})(t)}pauseGameControls(){this._eventManager?.controlsManager.gameControl?.pause()}resumeGameControls(){this._eventManager?.controlsManager.gameControl?.resume()}async swapGeometry(t,e){let i;if(typeof e=="string"){if(!e.endsWith(".splinegeometry"))throw new Error("Only .splinegeometry format is supported");{let l=await(await fetch(e)).arrayBuffer();i=new Uint8Array(l)}}else i=e;let r=CS.deserialize(i),s="data"in r&&r.data.draco!==void 0;s&&await Udt(this._wasmPath);let n=this._scene?.getObjectByProperty("uuid",t)??this._scene?.getObjectByName(t);if(!n)return void console.warn(`Object ${t} not found`);if(n.data.type!=="Mesh"||!(n instanceof yo))return void console.warn(`Object ${t} is not a mesh`);let a=n,o={...a.data,geometry:r};s&&await jdt([o]),a.updateByOp({type:0,path:[],props:{geometry:o.geometry}},o,{shared:this._sharedAssetsManager,scene:this._scene},!1);for(let l of a.data.states){let u={...l.data};a.states||(a.states={}),a.states[l.id]=em.patch(o,u)}return i}_applyDocumentTransaction(t){this._data=t.data,this._scene&&(this._scene.data=this._data.scene),this._sharedAssetsManager&&(this._sharedAssetsManager.data=this._data.shared);for(let e of t.actual){let i=e.path;Array.isArray(i)&&i.length===2&&i[0]==="scene"&&i[1]==="objects"&&this._scene?.updateTreeByOp({...e,path:[]},this._sharedAssetsManager)}}_findEntity(t){return this._scene?.getObjectByProperty("uuid",t)??this._scene?.getObjectByName(t)}_resolveParentId(t){if(t===void 0)return this._scene.activePage.uuid;let e=typeof t=="string"?t:t.uuid,i=this._findEntity(e);if(!i)throw new Error(`parent '${e}' \u2014 no object with that name or uuid in the scene.`);return i.uuid}async createCustomMaterial(t){if(this.disposed)throw new Error("createCustomMaterial: this Application was disposed.");if(typeof t!="function")throw new Error("createCustomMaterial: expected a factory function \u2014 createCustomMaterial((three) => new three.MeshStandardNodeMaterial()).");let e=KU();if(e===void 0&&(this._rendererBackend==="webgpu"&&(await Promise.resolve().then(()=>(KL(),T4)),e=KU()),e===void 0))throw new Error("createCustomMaterial: requires the webgpu backend (the runtime default where WebGPU is available). This Application is on the classic WebGL pipeline \u2014 pass { renderer: 'webgpu' } or drop any ?renderer=webgl2 override.");let i=t(e);if(typeof i!="object"||i===null||i.isMaterial!==!0)throw new Error("createCustomMaterial: the factory must return a three.js material built from the namespace it receives \u2014 e.g. (three) => new three.MeshStandardNodeMaterial().");return i}async setMaterial(t,e){if(this.disposed)throw new Error("setMaterial: this Application was disposed.");let i=this._scene;if(!i)throw new Error("setMaterial: no scene loaded \u2014 call load() or start() first.");let r=typeof t=="string"?t:t.uuid,s=this._findEntity(r);if(!s)throw new Error(`setMaterial: '${r}' \u2014 no object with that name or uuid in the scene.`);if(!(s instanceof yo))throw new Error(`setMaterial: '${r}' is not a mesh \u2014 lights, groups, and cameras have no material.`);let n=typeof e=="function"?await this.createCustomMaterial(e):e;if(DR()!=="webgpu")throw new Error("setMaterial: custom three.js materials require the webgpu backend (the runtime default where WebGPU is available). This scene is running the classic WebGL pipeline \u2014 pass { renderer: 'webgpu' } or drop any ?renderer=webgl2 override.");let a=Wdt({material:n});if(a.material===void 0)throw new Error("setMaterial: expected a three.js material instance or a (three) => material factory.");return s.setMaterialOverride(a.material,{scene:i,shared:this._sharedAssetsManager}),this._proxyObjectCache.delete(s.uuid),this._requestRenderAutoMode(),a.material}async createObject(t,e={}){if(this.disposed)throw new Error("createObject: this Application was disposed.");let i=this._scene,r=this._data;if(!i||!r)throw new Error("createObject: no scene loaded \u2014 call load() or start() first.");let s=function(g){if(typeof g!="string"||g.length===0)throw new Error(`createObject: expected a type name string \u2014 one of ${qdt}.`);let y=g.replace(/Geometry$/i,"").replace(/[\s_-]/g,"").toLowerCase(),v=A5t[y];if(v)return{objectType:v};let b=M5t[y];if(b)return{objectType:"Mesh",geometryType:b};let _=C5t[y];throw _?new Error(`createObject: '${g}' is not supported \u2014 ${_}`):new Error(`createObject: '${g}' is not a creatable Spline type \u2014 use one of ${qdt}, e.g. createObject('Cube', { width: 200 }).`)}(t);typeof e.material=="function"&&(e={...e,material:await this.createCustomMaterial(e.material)});let n,a,{options:o,material:l}=Wdt(e);if(l!==void 0){if(s.objectType!=="Mesh")throw new Error("createObject: a three.js material instance only applies to mesh types \u2014 lights and groups have no material.");if(DR()!=="webgpu")throw new Error("createObject: three.js material instances require the webgpu backend (the runtime default where WebGPU is available). This scene is running the classic WebGL pipeline \u2014 pass { renderer: 'webgpu' } to the Application, or drop any ?renderer=webgl2 override.")}if(s.geometryType==="TextGeometry"){if(!pG.has("text"))throw new Error("createObject: this runtime build was compiled without the 'text' feature \u2014 re-export the scene with a Text object present, or load the full runtime build.");if(await Sut(),a=e.font??S1,r.shared.fonts[a]===void 0){if(a!==S1){let g=Object.keys(r.shared.fonts).join(", ");throw new Error(`createObject: font '${a}' is not in this document \u2014 available fonts: ${g||"(none)"}.`)}n={name:S1,url:xmt}}}let u=this._resolveParentId(e.parent),h=N5t(s,o,r),d=qt.generateUUID(),[c,p]=Gw(r);n&&(c.shared.fonts[S1]=n),c.scene.objects.insertAfter(u,null,[{id:d,data:h,children:[]}]);let m=p.result();if(n&&this._sharedAssetsManager.addFont(S1,n),a!==void 0){let g=this._sharedAssetsManager.getFont(a);g&&await g.loadingPromise}this._applyDocumentTransaction(m);let f=i.find(d);return l!==void 0&&f.setMaterialOverride(l,{scene:i,shared:this._sharedAssetsManager}),this._requestRenderAutoMode(),this._createProxyObject(f)}cloneObject(t,e={}){if(this.disposed)throw new Error("cloneObject: this Application was disposed.");let i=this._scene,r=this._data;if(!i||!r)throw new Error("cloneObject: no scene loaded \u2014 call load() or start() first.");let s=typeof t=="string"?t:t?.uuid,n=s?this._findEntity(s):void 0;if(!n)throw new Error(`cloneObject: '${s}' \u2014 no object with that name or uuid in the scene.`);if(n instanceof Hs)throw new Error("cloneObject: pages cannot be cloned.");let a=r.scene.objects.get(n.uuid);if(!a)throw new Error(`cloneObject: '${s}' is not part of the document tree (expanded clones and instanced children cannot be cloned \u2014 clone their source object instead).`);let o=function(p,m,f){let g={...p.data};return m.position!==void 0&&(g.position=HS(m.position,[0,0,0])),m.rotation!==void 0&&(g.rotation=HS(m.rotation,[0,0,0])),m.scale!==void 0&&(g.scale=B_t(m.scale)),m.visible!==void 0&&(g.visible=m.visible),g.name=m.name??V_t(`${p.data.name??"Object"} Copy`,f),{...p,data:g}}(O5t(a),e,r.scene.objects),l=e.parent!==void 0?this._resolveParentId(e.parent):r.scene.objects.parent(n.uuid)??null,u=e.parent!==void 0?null:n.uuid,[h,d]=Gw(r);h.scene.objects.insertAfter(l,u,[o]),this._applyDocumentTransaction(d.result());let c=i.find(o.id);return this._requestRenderAutoMode(),this._createProxyObject(c)}removeObject(t){let e=this._scene,i=this._data;if(this.disposed||!e||!i)return!1;let r=typeof t=="string"?t:t?.uuid,s=r?this._findEntity(r):void 0;if(!s)return!1;if(s instanceof Hs)throw new Error("removeObject: pages cannot be removed.");if(s.data.type==="PerspectiveCamera"||s.data.type==="OrthographicCamera")throw new Error("removeObject: cameras cannot be removed.");if(i.scene.objects.get(s.uuid)===void 0)throw new Error(`removeObject: '${r}' is not part of the document tree (expanded clones and instanced children cannot be removed individually).`);let n=[];s.traverseEntity(l=>{n.push(l.uuid)});let[a,o]=Gw(i);a.scene.objects.delete(s.uuid),this._applyDocumentTransaction(o.result());for(let l of n){let u=this._proxyObjectCache.get(l);u&&(ZL.unsubscribe(u),this._proxyObjectCache.delete(l))}return this._requestRenderAutoMode(),!0}};var dD=window,cD=dD.ShadowRoot&&(dD.ShadyCSS===void 0||dD.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,XW=Symbol(),L_t=new WeakMap,cT=class{constructor(e,i,r){if(this._$cssResult$=!0,r!==XW)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=i}get styleSheet(){let e=this.o,i=this.t;if(cD&&e===void 0){let r=i!==void 0&&i.length===1;r&&(e=L_t.get(i)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),r&&L_t.set(i,e))}return e}toString(){return this.cssText}},F_t=t=>new cT(typeof t=="string"?t:t+"",void 0,XW),YW=(t,...e)=>{let i=t.length===1?t[0]:e.reduce((r,s,n)=>r+(a=>{if(a._$cssResult$===!0)return a.cssText;if(typeof a=="number")return a;throw Error("Value passed to 'css' function must be a 'css' function result: "+a+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+t[n+1],t[0]);return new cT(i,t,XW)},KW=(t,e)=>{cD?t.adoptedStyleSheets=e.map(i=>i instanceof CSSStyleSheet?i:i.styleSheet):e.forEach(i=>{let r=document.createElement("style"),s=dD.litNonce;s!==void 0&&r.setAttribute("nonce",s),r.textContent=i.cssText,t.appendChild(r)})},pD=cD?t=>t:t=>t instanceof CSSStyleSheet?(e=>{let i="";for(let r of e.cssRules)i+=r.cssText;return F_t(i)})(t):t;var ZW,mD=window,U_t=mD.trustedTypes,z5t=U_t?U_t.emptyScript:"",j_t=mD.reactiveElementPolyfillSupport,JW={toAttribute(t,e){switch(e){case Boolean:t=t?z5t:null;break;case Object:case Array:t=t==null?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){case Boolean:i=t!==null;break;case Number:i=t===null?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch{i=null}}return i}},G_t=(t,e)=>e!==t&&(e==e||t==t),QW={attribute:!0,type:String,converter:JW,reflect:!1,hasChanged:G_t},tq="finalized",Nc=class extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this._$Eu()}static addInitializer(e){var i;this.finalize(),((i=this.h)!==null&&i!==void 0?i:this.h=[]).push(e)}static get observedAttributes(){this.finalize();let e=[];return this.elementProperties.forEach((i,r)=>{let s=this._$Ep(r,i);s!==void 0&&(this._$Ev.set(s,r),e.push(s))}),e}static createProperty(e,i=QW){if(i.state&&(i.attribute=!1),this.finalize(),this.elementProperties.set(e,i),!i.noAccessor&&!this.prototype.hasOwnProperty(e)){let r=typeof e=="symbol"?Symbol():"__"+e,s=this.getPropertyDescriptor(e,r,i);s!==void 0&&Object.defineProperty(this.prototype,e,s)}}static getPropertyDescriptor(e,i,r){return{get(){return this[i]},set(s){let n=this[e];this[i]=s,this.requestUpdate(e,n,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)||QW}static finalize(){if(this.hasOwnProperty(tq))return!1;this[tq]=!0;let e=Object.getPrototypeOf(this);if(e.finalize(),e.h!==void 0&&(this.h=[...e.h]),this.elementProperties=new Map(e.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){let i=this.properties,r=[...Object.getOwnPropertyNames(i),...Object.getOwnPropertySymbols(i)];for(let s of r)this.createProperty(s,i[s])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(e){let i=[];if(Array.isArray(e)){let r=new Set(e.flat(1/0).reverse());for(let s of r)i.unshift(pD(s))}else e!==void 0&&i.push(pD(e));return i}static _$Ep(e,i){let r=i.attribute;return r===!1?void 0:typeof r=="string"?r:typeof e=="string"?e.toLowerCase():void 0}_$Eu(){var e;this._$E_=new Promise(i=>this.enableUpdating=i),this._$AL=new Map,this._$Eg(),this.requestUpdate(),(e=this.constructor.h)===null||e===void 0||e.forEach(i=>i(this))}addController(e){var i,r;((i=this._$ES)!==null&&i!==void 0?i:this._$ES=[]).push(e),this.renderRoot!==void 0&&this.isConnected&&((r=e.hostConnected)===null||r===void 0||r.call(e))}removeController(e){var i;(i=this._$ES)===null||i===void 0||i.splice(this._$ES.indexOf(e)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach((e,i)=>{this.hasOwnProperty(i)&&(this._$Ei.set(i,this[i]),delete this[i])})}createRenderRoot(){var e;let i=(e=this.shadowRoot)!==null&&e!==void 0?e:this.attachShadow(this.constructor.shadowRootOptions);return KW(i,this.constructor.elementStyles),i}connectedCallback(){var e;this.renderRoot===void 0&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(e=this._$ES)===null||e===void 0||e.forEach(i=>{var r;return(r=i.hostConnected)===null||r===void 0?void 0:r.call(i)})}enableUpdating(e){}disconnectedCallback(){var e;(e=this._$ES)===null||e===void 0||e.forEach(i=>{var r;return(r=i.hostDisconnected)===null||r===void 0?void 0:r.call(i)})}attributeChangedCallback(e,i,r){this._$AK(e,r)}_$EO(e,i,r=QW){var s;let n=this.constructor._$Ep(e,r);if(n!==void 0&&r.reflect===!0){let a=(((s=r.converter)===null||s===void 0?void 0:s.toAttribute)!==void 0?r.converter:JW).toAttribute(i,r.type);this._$El=e,a==null?this.removeAttribute(n):this.setAttribute(n,a),this._$El=null}}_$AK(e,i){var r;let s=this.constructor,n=s._$Ev.get(e);if(n!==void 0&&this._$El!==n){let a=s.getPropertyOptions(n),o=typeof a.converter=="function"?{fromAttribute:a.converter}:((r=a.converter)===null||r===void 0?void 0:r.fromAttribute)!==void 0?a.converter:JW;this._$El=n,this[n]=o.fromAttribute(i,a.type),this._$El=null}}requestUpdate(e,i,r){let s=!0;e!==void 0&&(((r=r||this.constructor.getPropertyOptions(e)).hasChanged||G_t)(this[e],i)?(this._$AL.has(e)||this._$AL.set(e,i),r.reflect===!0&&this._$El!==e&&(this._$EC===void 0&&(this._$EC=new Map),this._$EC.set(e,r))):s=!1),!this.isUpdatePending&&s&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(i){Promise.reject(i)}let e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var e;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach((s,n)=>this[n]=s),this._$Ei=void 0);let i=!1,r=this._$AL;try{i=this.shouldUpdate(r),i?(this.willUpdate(r),(e=this._$ES)===null||e===void 0||e.forEach(s=>{var n;return(n=s.hostUpdate)===null||n===void 0?void 0:n.call(s)}),this.update(r)):this._$Ek()}catch(s){throw i=!1,this._$Ek(),s}i&&this._$AE(r)}willUpdate(e){}_$AE(e){var i;(i=this._$ES)===null||i===void 0||i.forEach(r=>{var s;return(s=r.hostUpdated)===null||s===void 0?void 0:s.call(r)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(e){return!0}update(e){this._$EC!==void 0&&(this._$EC.forEach((i,r)=>this._$EO(r,this[r],i)),this._$EC=void 0),this._$Ek()}updated(e){}firstUpdated(e){}};Nc[tq]=!0,Nc.elementProperties=new Map,Nc.elementStyles=[],Nc.shadowRootOptions={mode:"open"},j_t?.({ReactiveElement:Nc}),((ZW=mD.reactiveElementVersions)!==null&&ZW!==void 0?ZW:mD.reactiveElementVersions=[]).push("1.6.3");var eq,fD=window,nb=fD.trustedTypes,W_t=nb?nb.createPolicy("lit-html",{createHTML:t=>t}):void 0,rq="$lit$",Tm=`lit$${(Math.random()+"").slice(9)}$`,Z_t="?"+Tm,L5t=`<${Z_t}>`,h0=document,mT=()=>h0.createComment(""),fT=t=>t===null||typeof t!="object"&&typeof t!="function",Q_t=Array.isArray,F5t=t=>Q_t(t)||typeof t?.[Symbol.iterator]=="function",iq=`[
|
|
5178
5178
|
\f\r]`,pT=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,q_t=/-->/g,H_t=/>/g,o0=RegExp(`>|${iq}(?:([^\\s"'>=/]+)(${iq}*=${iq}*(?:[^
|
|
5179
5179
|
\f\r"'\`<>=]|("|')|))|$)`,"g"),$_t=/'/g,X_t=/"/g,J_t=/^(?:script|style|textarea|title)$/i,txt=t=>(e,...i)=>({_$litType$:t,strings:e,values:i}),ext=txt(1),Kjt=txt(2),u0=Symbol.for("lit-noChange"),ha=Symbol.for("lit-nothing"),Y_t=new WeakMap,l0=h0.createTreeWalker(h0,129,null,!1);function ixt(t,e){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return W_t!==void 0?W_t.createHTML(e):e}var U5t=(t,e)=>{let i=t.length-1,r=[],s,n=e===2?"<svg>":"",a=pT;for(let o=0;o<i;o++){let l=t[o],u,h,d=-1,c=0;for(;c<l.length&&(a.lastIndex=c,h=a.exec(l),h!==null);)c=a.lastIndex,a===pT?h[1]==="!--"?a=q_t:h[1]!==void 0?a=H_t:h[2]!==void 0?(J_t.test(h[2])&&(s=RegExp("</"+h[2],"g")),a=o0):h[3]!==void 0&&(a=o0):a===o0?h[0]===">"?(a=s??pT,d=-1):h[1]===void 0?d=-2:(d=a.lastIndex-h[2].length,u=h[1],a=h[3]===void 0?o0:h[3]==='"'?X_t:$_t):a===X_t||a===$_t?a=o0:a===q_t||a===H_t?a=pT:(a=o0,s=void 0);let p=a===o0&&t[o+1].startsWith("/>")?" ":"";n+=a===pT?l+L5t:d>=0?(r.push(u),l.slice(0,d)+rq+l.slice(d)+Tm+p):l+Tm+(d===-2?(r.push(void 0),o):p)}return[ixt(t,n+(t[i]||"<?>")+(e===2?"</svg>":"")),r]},d0=class{constructor({strings:e,_$litType$:i},r){let s;this.parts=[];let n=0,a=0,o=e.length-1,l=this.parts,[u,h]=U5t(e,i);if(this.el=d0.createElement(u,r),l0.currentNode=this.el.content,i===2){let d=this.el.content,c=d.firstChild;c.remove(),d.append(...c.childNodes)}for(;(s=l0.nextNode())!==null&&l.length<o;){if(s.nodeType===1){if(s.hasAttributes()){let d=[];for(let c of s.getAttributeNames())if(c.endsWith(rq)||c.startsWith(Tm)){let p=h[a++];if(d.push(c),p!==void 0){let m=s.getAttribute(p.toLowerCase()+rq).split(Tm),f=/([.?@])?(.*)/.exec(p);l.push({type:1,index:n,name:f[2],strings:m,ctor:f[1]==="."?nq:f[1]==="?"?aq:f[1]==="@"?oq:ob})}else l.push({type:6,index:n})}for(let c of d)s.removeAttribute(c)}if(J_t.test(s.tagName)){let d=s.textContent.split(Tm),c=d.length-1;if(c>0){s.textContent=nb?nb.emptyScript:"";for(let p=0;p<c;p++)s.append(d[p],mT()),l0.nextNode(),l.push({type:2,index:++n});s.append(d[c],mT())}}}else if(s.nodeType===8)if(s.data===Z_t)l.push({type:2,index:n});else{let d=-1;for(;(d=s.data.indexOf(Tm,d+1))!==-1;)l.push({type:7,index:n}),d+=Tm.length-1}n++}}static createElement(e,i){let r=h0.createElement("template");return r.innerHTML=e,r}};function ab(t,e,i=t,r){var s,n,a,o;if(e===u0)return e;let l=r!==void 0?(s=i._$Co)===null||s===void 0?void 0:s[r]:i._$Cl,u=fT(e)?void 0:e._$litDirective$;return l?.constructor!==u&&((n=l?._$AO)===null||n===void 0||n.call(l,!1),u===void 0?l=void 0:(l=new u(t),l._$AT(t,i,r)),r!==void 0?((a=(o=i)._$Co)!==null&&a!==void 0?a:o._$Co=[])[r]=l:i._$Cl=l),l!==void 0&&(e=ab(t,l._$AS(t,e.values),l,r)),e}var sq=class{constructor(e,i){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=i}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){var i;let{el:{content:r},parts:s}=this._$AD,n=((i=e?.creationScope)!==null&&i!==void 0?i:h0).importNode(r,!0);l0.currentNode=n;let a=l0.nextNode(),o=0,l=0,u=s[0];for(;u!==void 0;){if(o===u.index){let h;u.type===2?h=new c0(a,a.nextSibling,this,e):u.type===1?h=new u.ctor(a,u.name,u.strings,this,e):u.type===6&&(h=new lq(a,this,e)),this._$AV.push(h),u=s[++l]}o!==u?.index&&(a=l0.nextNode(),o++)}return l0.currentNode=h0,n}v(e){let i=0;for(let r of this._$AV)r!==void 0&&(r.strings!==void 0?(r._$AI(e,r,i),i+=r.strings.length-2):r._$AI(e[i])),i++}},c0=class{constructor(e,i,r,s){var n;this.type=2,this._$AH=ha,this._$AN=void 0,this._$AA=e,this._$AB=i,this._$AM=r,this.options=s,this._$Cp=(n=s?.isConnected)===null||n===void 0||n}get _$AU(){var e,i;return(i=(e=this._$AM)===null||e===void 0?void 0:e._$AU)!==null&&i!==void 0?i:this._$Cp}get parentNode(){let e=this._$AA.parentNode,i=this._$AM;return i!==void 0&&e?.nodeType===11&&(e=i.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,i=this){e=ab(this,e,i),fT(e)?e===ha||e==null||e===""?(this._$AH!==ha&&this._$AR(),this._$AH=ha):e!==this._$AH&&e!==u0&&this._(e):e._$litType$!==void 0?this.g(e):e.nodeType!==void 0?this.$(e):F5t(e)?this.T(e):this._(e)}k(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}$(e){this._$AH!==e&&(this._$AR(),this._$AH=this.k(e))}_(e){this._$AH!==ha&&fT(this._$AH)?this._$AA.nextSibling.data=e:this.$(h0.createTextNode(e)),this._$AH=e}g(e){var i;let{values:r,_$litType$:s}=e,n=typeof s=="number"?this._$AC(e):(s.el===void 0&&(s.el=d0.createElement(ixt(s.h,s.h[0]),this.options)),s);if(((i=this._$AH)===null||i===void 0?void 0:i._$AD)===n)this._$AH.v(r);else{let a=new sq(n,this),o=a.u(this.options);a.v(r),this.$(o),this._$AH=a}}_$AC(e){let i=Y_t.get(e.strings);return i===void 0&&Y_t.set(e.strings,i=new d0(e)),i}T(e){Q_t(this._$AH)||(this._$AH=[],this._$AR());let i=this._$AH,r,s=0;for(let n of e)s===i.length?i.push(r=new c0(this.k(mT()),this.k(mT()),this,this.options)):r=i[s],r._$AI(n),s++;s<i.length&&(this._$AR(r&&r._$AB.nextSibling,s),i.length=s)}_$AR(e=this._$AA.nextSibling,i){var r;for((r=this._$AP)===null||r===void 0||r.call(this,!1,!0,i);e&&e!==this._$AB;){let s=e.nextSibling;e.remove(),e=s}}setConnected(e){var i;this._$AM===void 0&&(this._$Cp=e,(i=this._$AP)===null||i===void 0||i.call(this,e))}},ob=class{constructor(e,i,r,s,n){this.type=1,this._$AH=ha,this._$AN=void 0,this.element=e,this.name=i,this._$AM=s,this.options=n,r.length>2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=ha}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(e,i=this,r,s){let n=this.strings,a=!1;if(n===void 0)e=ab(this,e,i,0),a=!fT(e)||e!==this._$AH&&e!==u0,a&&(this._$AH=e);else{let o=e,l,u;for(e=n[0],l=0;l<n.length-1;l++)u=ab(this,o[r+l],i,l),u===u0&&(u=this._$AH[l]),a||(a=!fT(u)||u!==this._$AH[l]),u===ha?e=ha:e!==ha&&(e+=(u??"")+n[l+1]),this._$AH[l]=u}a&&!s&&this.j(e)}j(e){e===ha?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}},nq=class extends ob{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===ha?void 0:e}},j5t=nb?nb.emptyScript:"",aq=class extends ob{constructor(){super(...arguments),this.type=4}j(e){e&&e!==ha?this.element.setAttribute(this.name,j5t):this.element.removeAttribute(this.name)}},oq=class extends ob{constructor(e,i,r,s,n){super(e,i,r,s,n),this.type=5}_$AI(e,i=this){var r;if((e=(r=ab(this,e,i,0))!==null&&r!==void 0?r:ha)===u0)return;let s=this._$AH,n=e===ha&&s!==ha||e.capture!==s.capture||e.once!==s.once||e.passive!==s.passive,a=e!==ha&&(s===ha||n);n&&this.element.removeEventListener(this.name,this,s),a&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var i,r;typeof this._$AH=="function"?this._$AH.call((r=(i=this.options)===null||i===void 0?void 0:i.host)!==null&&r!==void 0?r:this.element,e):this._$AH.handleEvent(e)}},lq=class{constructor(e,i,r){this.element=e,this.type=6,this._$AN=void 0,this._$AM=i,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(e){ab(this,e)}};var K_t=fD.litHtmlPolyfillSupport;K_t?.(d0,c0),((eq=fD.litHtmlVersions)!==null&&eq!==void 0?eq:fD.litHtmlVersions=[]).push("2.8.0");var gT=(t,e,i)=>{var r,s;let n=(r=i?.renderBefore)!==null&&r!==void 0?r:e,a=n._$litPart$;if(a===void 0){let o=(s=i?.renderBefore)!==null&&s!==void 0?s:null;n._$litPart$=a=new c0(e.insertBefore(mT(),o),o,void 0,i??{})}return a._$AI(t),a};var hq,uq;var Mm=class extends Nc{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var e,i;let r=super.createRenderRoot();return(e=(i=this.renderOptions).renderBefore)!==null&&e!==void 0||(i.renderBefore=r.firstChild),r}update(e){let i=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=gT(i,this.renderRoot,this.renderOptions)}connectedCallback(){var e;super.connectedCallback(),(e=this._$Do)===null||e===void 0||e.setConnected(!0)}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this._$Do)===null||e===void 0||e.setConnected(!1)}render(){return u0}};Mm.finalized=!0,Mm._$litElement$=!0,(hq=globalThis.litElementHydrateSupport)===null||hq===void 0||hq.call(globalThis,{LitElement:Mm});var rxt=globalThis.litElementPolyfillSupport;rxt?.({LitElement:Mm});((uq=globalThis.litElementVersions)!==null&&uq!==void 0?uq:globalThis.litElementVersions=[]).push("3.3.3");var sxt=t=>e=>typeof e=="function"?((i,r)=>(customElements.define(i,r),r))(t,e):((i,r)=>{let{kind:s,elements:n}=r;return{kind:s,elements:n,finisher(a){customElements.define(i,a)}}})(t,e);var G5t=(t,e)=>e.kind==="method"&&e.descriptor&&!("value"in e.descriptor)?{...e,finisher(i){i.createProperty(e.key,t)}}:{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:e.key,initializer(){typeof e.initializer=="function"&&(this[e.key]=e.initializer.call(this))},finisher(i){i.createProperty(e.key,t)}},W5t=(t,e,i)=>{e.constructor.createProperty(i,t)};function Tl(t){return(e,i)=>i!==void 0?W5t(t,e,i):G5t(t,e)}var dq,S9t=((dq=window.HTMLSlotElement)===null||dq===void 0?void 0:dq.prototype.assignedElements)!=null?(t,e)=>t.assignedElements(e):(t,e)=>t.assignedNodes(e).filter(i=>i.nodeType===Node.ELEMENT_NODE);var gD=window.IntersectionObserver!=null;var nxt=(t=32,e=2)=>{let i=t/2;return ext` <style>
|
|
5180
5180
|
:host {
|