@splinetool/viewer 2.0.204 → 2.0.206
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.
|
@@ -378,13 +378,13 @@ ${t.stack}`;let e=toString.call(t),i=/\[object ([^\]]+)\]/.exec(e)?.[1];if(i===v
|
|
|
378
378
|
}
|
|
379
379
|
post({ kind: 'ready' });
|
|
380
380
|
}, 250);
|
|
381
|
-
})();`});function VM(t){return t==null||t===""?void 0:String(t)}var zG,cft=U(()=>{zG=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"getAnimations":{let r=i.getAnimations(VM(e[0]));return r.warning&&this.onConsole("warn",`spline.${t}: ${r.warning}`),r.clips}case"playAnimation":{let r=typeof e[1]=="object"&&e[1]!==null,s=i.playAnimation(String(e[0]),r?void 0:VM(e[1]),(r?e[1]:e[2])??{});return s.warning&&this.onConsole("warn",`spline.${t}: ${s.warning}`),s.clip}case"pauseAnimation":case"stopAnimation":{let r=VM(e[0]),s=VM(e[1]),n=t==="pauseAnimation"?i.pauseAnimation(r,s):i.stopAnimation(r,s);return n.warning&&this.onConsole("warn",`spline.${t}: ${n.warning}`),n.ok}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 c3t(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 p3t=U(()=>{}),pft,m3t=U(()=>{}),f3t=U(()=>{VG(),cft(),pft=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[Gp]!==!0||typeof n.kind!="string"||this.handleMessage(s)},this.host=new zG(e,i,(r,s)=>{this.sendEvent(r,s)})}attach(){window.addEventListener("message",this.onMessage),this.send({[Gp]:!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({[Gp]:!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({[Gp]:!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({[Gp]:!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({[Gp]:!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}))}}}}),er=U(()=>{kG(),ZAt(),QAt(),JAt(),e3t(),i3t(),r3t(),s3t(),n3t(),a3t(),o3t(),u3t(),VG(),d3t(),cft(),p3t(),m3t(),f3t()}),g3t=U(()=>{});function mft(t){return Array.isArray(t)?t:[t]}function M4(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 y3t=U(()=>{});function qa(t,e){return Object.setPrototypeOf(t,e),t}function xI(t){let e={...t};return Object.setPrototypeOf(e,Object.getPrototypeOf(t)),e}function tm(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 e0(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 v3t=U(()=>{});function LG(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"&&LG(r)}return Object.freeze(t)}function fft(t){for(let e of Object.keys(t))t[e]===void 0&&delete t[e];return t}var wI,A4,wU,Ne,FG,b3t=U(()=>{}),dn=U(()=>{g3t(),y3t(),v3t(),b3t()}),UG=U(()=>{wI=class{},A4=class extends wI{constructor(t){super(),this.id=t}},wU=class extends wI{constructor(t){super(),this.data=t}}}),_3t=U(()=>{}),nD=U(()=>{Ne=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,Ne.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,Ne.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,Ne.prototype),delete s[i],{data:s,actual:t,reverse:{type:1,id:i,data:r}}}}return null}}}),jG=U(()=>{FG=class extends Error{}});function gft(t,e){for(let i of t)e(i.id,i.data)!==!0&&gft(i.children,e)}function yft(t,e){if(e(t.id,t.data)!==!0)for(let i of t.children)yft(i,e)}var Nn,zM,Lv,ue,a0=U(()=>{dn(),jG(),dn(),Nn=class extends Array{constructor(...t){super(...t),pc(this,"partialObjectCaches"),pc(this,"objCaches"),pc(this,"parentCaches"),Object.setPrototypeOf(this,Nn.prototype)}deepFreeze(){let t=0;for(;t<this.length;)LG(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&&yft(i,e)}}traverse(t){gft(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(h=>h.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,Nn.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((h,u)=>h.fi-u.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 FG("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],h=this.modifyArrayBy(s,a);s=e,a=h.childrenArray(s);let u=l.fi;return l={...l,fi:i},a=[...a,l],a.sort((d,c)=>d.fi-c.fi),t.localIndex=a.indexOf(l),h=h.modifyArrayBy(s,a),{data:h,actual:t,reverse:{type:9,parent:n,fi:u,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)=>M4(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)=>M4(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 tm(0,i,i);{let s=r[0].fi;return tm(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 tm(a,a+i,i)}return tm(s.fi,n.fi,i)}}}}),GG=U(()=>{var t;dn(),zM=null,(t=Lv||(Lv={})).setPreservePrototype=function(e){zM=e},t.tryPreservePrototype=function(e,i){return Object.getPrototypeOf(e)===zM&&Object.setPrototypeOf(i,zM),i},t.runOp=function(e,i){if(i.type!==0)return null;if(Array.isArray(e)||e0(e)){let r=i.props,s={},n=e0(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}}}),o0=U(()=>{dn(),dn(),ue=class extends Array{constructor(...t){super(...t),pc(this,"objCaches"),Object.setPrototypeOf(this,ue.prototype)}deepFreeze(){let t=0;for(;t<this.length;)LG(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,ue.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 tm(0,e,e);{let r=i[0].fi;return tm(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 tm(n,n+e,e)}return tm(r.fi,s.fi,e)}}}});function x3t(t,e){let i={cur:[],result:[],len:0};return[t=cv(t,e,i)??t,i.result]}function tR(t,e){return t===null?null:(t.cur[t.len]=e,t.len+=1,t)}function eR(t){t&&(t.len-=1)}function vft(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=cv(n.data,e,tR(i,a));eR(i),r=r||l!==void 0,l===void 0&&(l=n.data);let h=vft(n.children,e,i);return h!==void 0?r=!0:h=n.children,{...n,id:a,data:l,children:h}});if(r)return s}function cv(t,e,i){if(t instanceof Nn){let r=vft(t,e,i);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(t)),r}if(t instanceof ue)return function(r,s,n){let a=!1,o=r.map(l=>{let h=l.id,u=s[h];if(u!==void 0&&typeof u=="string"&&(a=!0,h=u,n!==null))throw new Error("not supported");let d=cv(l.data,s,tR(n,h));return eR(n),a=a||d!==void 0,d===void 0&&(d=l.data),{...l,id:h,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=cv(n,e,tR(i,a));return eR(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"&&!e0(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=cv(a,e,tR(i,n));eR(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 bft=U(()=>{a0(),o0(),dn()});function pv(t){return t&&typeof t=="object"&&t instanceof Cs}function WG(t,e){if(e===void 0)return;let i=!1,r=t.map(s=>{let n=s.id,a=aS(s.data,e[n]);if(i=i||a!==void 0,a===void 0&&(a=s.data),s.children){let o=WG(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 aS(t,e){if(!pv(e))return e;if(t instanceof Nn){let i=WG(t,e);return i!==void 0&&Object.setPrototypeOf(i,Object.getPrototypeOf(t)),i}if(t instanceof ue)return function(i,r){if(r===void 0)return;let s=!1,n=i.map(a=>{let o=a.id,l=aS(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=aS(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 Cs)return qG(t,e);if(t&&typeof t=="object"){let i={},r=!1;for(let[s,n]of Object.entries(t)){let a=aS(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 qG(t,e){if(t===void 0)return e;if(e===void 0)return t;if(!pv(e))return e;if(!pv(t))return mm.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 Cs;for(let s of i){let n=qG(t===void 0?void 0:t[s],e===void 0?void 0:e[s]);r[s]=n}return r}var Cs,mm,C4,Qn,CX,aD=U(()=>{var t;a0(),o0(),oD(),dn(),Cs=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&&!pv(r))return null;s+=1}r=r?xI(r):new Cs;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=xI(a),delete r[e.path[s-1]])}else{let a=i[s-1];if(a){let o=xI(a);o[e.path[s-1]]=r,r=o}else{let o=new Cs;o[e.path[s-1]]=r,r=o}}s-=1}return{data:Object.setPrototypeOf(r,Cs.prototype),actual:e,reverse:{...e,props:n}}}},(t=mm||(mm={})).apply=function(e,i){return aS(e,i)??e},t.merge=function(e,i){return qG(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(!pv(n))return;r+=1}if(n===void 0)return i;if(pv(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=WG([i],n);return a?a[0]:i}return i}}}),w3t=U(()=>{dn(),oD(),nD(),a0(),jG(),GG(),o0(),bft(),aD(),(C4||(C4={})).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 Cs&&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 Nn||s instanceof ue||s instanceof Ne?s.runOp(n):Lv.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 Nn){if(typeof p=="number")throw new Error("illegal arg");d=m.modifyById(p,d)}else if(m instanceof ue){if(typeof p=="number")throw new Error("illegal arg");d=m.modifyById(p,d)}else if(m instanceof Ne){if(typeof p=="number")throw new Error("illegal arg");d=m.modifyById(p,d)}else if(m instanceof Cs){let f={...m,[p]:d};d=Object.setPrototypeOf(f,Cs.prototype)}else{if(typeof m!="object")return null;if(Array.isArray(m)||e0(m)){if(typeof p=="string"&&(p=parseInt(p),isNaN(p)))throw new Error("Invalid path");let f=d;d=e0(m)?m.slice():[...m],d[p]=f}else d=Lv.tryPreservePrototype(m,{...m,[p]:d})}}return{data:d,actual:{...l.actual,path:a},reverse:{...l.reverse,path:a}}}return null}let h,u=a[o.length];if(s instanceof Nn){if(typeof u=="number")throw new Error("");h=s.get(u)?.data}else if(s instanceof ue){if(typeof u=="number")throw new Error("");h=s.get(u)?.data}else s!==null&&(h=s[u]);if(h===void 0)return null;o.push(s),s=h}}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)}})(Qn||(Qn={})),(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,h;if(o.type===3?(l=Dn.zoom(s,[...o.path,o.id]),h=Qn.apply(s,{...o,type:2})):(l=Dn.zoom(s,[...o.path,o.id,"value"]),h=Qn.apply(s,o)),h!==null){s=h.data;let[u,d]=x3t(s,{[o.id]:l});s=u;for(let c=0;c<d.length;c++){let p,m,f=d[c],g=f.pop();if(typeof g=="number"){let y=[g];for(let b=c+1;b<d.length;b++){let _=d[b],x=_[_.length-1];if(typeof x!="number"||!Dn.equal(f,_.slice(0,_.length-1)))break;y.push(x),d.splice(b,1)}let v=Dn.zoom(s,f);m=v.map((b,_)=>y.includes(_)?o.id:b),p=v,g=f.pop()}else p=l,(g==="alphaOverride"||g==="alpha")&&(p=l/100,Dn.zoom(s,f)[g]=p),m=o.id;n.push({type:0,path:f,props:{[g]:p}}),a.push({type:0,path:f,props:{[g]:m}})}a.push(h.reverse),n.push(h.actual)}}else{let l=Qn.apply(s,o);l!==null&&(n.push(l.actual),s=l.data,a.push(l.reverse))}}catch(l){if(l instanceof FG)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=>Qn.subsumed(s,n))),...r]},t.commutative=function(i,r){return i.every(s=>r.every(n=>Qn.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})(CX||(CX={}))});function EX(t,e){return t instanceof Cs?Object.setPrototypeOf(e,Cs.prototype):Lv.tryPreservePrototype(t,e)}function SI(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 iR(t,e,i){return i instanceof Nn?new fT(t,e,i):i instanceof ue?new gT(t,e,i):i instanceof Ne?new Proxy(new xft(t,e,i),Sft):i!==null&&typeof i=="object"?e0(i)?i:new Proxy(new _ft(t,e,i),wft):i}function s2(t){let e=new SU(t);return[iR(e,"",t),e]}function E4(t,e){let[i,r]=s2(t);return e(i),r.result()}function Os(t){return t instanceof fT||t instanceof gT?t._current:t!==null&&typeof t=="object"?t[P4]:t}function Q1(t){if(t instanceof fT||t instanceof gT)return t._current;if(t!==null&&typeof t=="object"){let e=t[P4];return e!==void 0?e:t}return t}var P4,PX,m_,j0,_ft,xft,TI,wft,Sft,fT,gT,SU,Dn,Tft=U(()=>{nD(),a0(),GG(),o0(),dn(),oD(),aD(),P4=Symbol(),PX=Symbol(),m_=Symbol(),j0=class{reportOp(t,e,i=[]){let r=this;if(e===null)return;r._current=e.data;let s=i;for(;!(r instanceof SU);){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[m_];i&&i(),delete this._children[t]}}}},_ft=class extends j0{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=EX(this._current,{...this._current,[t]:e})}runOp(t){let e=Lv.runOp(this._current,t);e!==null&&(e.data=EX(this._current,e.data)),this.reportOp(t,e,t.path)}},xft=class extends j0{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,Ne.prototype)}runOp(t){this.reportOp(t,this._current.runOp(t))}},TI={get(t,e){if(e===m_)return()=>{t._parent=null};if(e===P4)return t._current;if(e===PX)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=iR(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]}}},wft={...TI,set(t,e,i){let r={type:0,props:{[e]:Os(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}},Sft={...TI,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)},fT=class extends j0{constructor(t,e,i){super(),this._children={},this._parent=t,this._path=e,this._current=i,this[m_]=()=>{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=iR(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)}},gT=class extends j0{constructor(t,e,i){super(),this._children={},this._parent=t,this._path=e,this._current=i,this[m_]=()=>{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=iR(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})}},SU=class extends j0{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){SI(this.ts,e,t),SI(this.actual,i,t),SI(this.reverse,r,t)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}}}),oD=U(()=>{UG(),Tft(),o0(),a0(),dn(),(t=>{function e(r,s){return(r instanceof Nn||r instanceof fT)&&typeof s=="string"||(r instanceof ue||r instanceof gT)&&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 A4&&o.id===s.id)n.push(l);else if(o instanceof ue)for(let h=0;h<o.length;h++)a(o[h].data,[...l,o[h].id]);else if(o instanceof Nn)o.traverse((h,u)=>{a(u,[...l,h])});else if(Array.isArray(o)){if(typeof o[0]=="number")return;for(let h=0;h<o.length;h++)a(o[h],[...l,h])}else{if(e0(o))return;if(typeof o=="object"&&o!==null)for(let h in o)a(o[h],[...l,h])}}(r,[]),n}})(Dn||(Dn={}))}),S3t=U(()=>{});function tr(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 T3t=U(()=>{});function LM(t){try{if(!Er.trusted&&!gc){let i=Gi.sharedLength||0;i<Gi.length&&(Gi.length=i)}let e;if(Er.randomAccessStructure&&ce[pt]<64&&ce[pt]>=32&&BX?(e=BX(ce,pt,Jl,Er),ce=null,!(t&&t.lazy)&&e&&(e=e.toJSON()),pt=Jl):e=Ys(),Ea&&(pt=Ea.postBundlePosition,Ea=null),gc&&(Gi.restoreStructures=null),pt==Jl)Gi&&Gi.restoreStructures&&RX(),Gi=null,ce=null,fc&&(fc=null);else{if(pt>Jl)throw new Error("Unexpected end of MessagePack data");if(!gc){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 Gi&&Gi.restoreStructures&&RX(),MU(),(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer")||pt>Jl)&&(e.incomplete=!0),e}}function RX(){for(let t in Gi.restoreStructures)Gi[t]=Gi.restoreStructures[t];Gi.restoreStructures=null}function Ys(){let t=ce[pt++];if(t<160){if(t<128){if(t<64)return t;{let e=Gi[63&t]||Er.getStructures&&Mft()[63&t];return e?(e.read||(e.read=TU(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=Cft();r==="__proto__"&&(r="__proto_"),e[r]=Ys()}return e}{let e=new Map;for(let i=0;i<t;i++)e.set(Ys(),Ys());return e}}{t-=144;let e=new Array(t);for(let i=0;i<t;i++)e[i]=Ys();return Er.freezeData?Object.freeze(e):e}}if(t<192){let e=t-160;if(Gh>=pt)return em.slice(pt-ml,(pt+=e)-ml);if(Gh==0&&Jl<140){let i=e<16?HG(e):Aft(e);if(i!=null)return i}return O4(e)}{let e;switch(t){case 192:return null;case 193:return Ea?(e=Ys(),e>0?Ea[1].slice(Ea.position1,Ea.position1+=e):Ea[0].slice(Ea.position0,Ea.position0-=e)):Rft;case 194:return!1;case 195:return!0;case 196:if(e=ce[pt++],e===void 0)throw new Error("Unexpected end of buffer");return MI(e);case 197:return e=ki.getUint16(pt),pt+=2,MI(e);case 198:return e=ki.getUint32(pt),pt+=4,MI(e);case 199:return nf(ce[pt++]);case 200:return e=ki.getUint16(pt),pt+=2,nf(e);case 201:return e=ki.getUint32(pt),pt+=4,nf(e);case 202:if(e=ki.getFloat32(pt),Er.useFloat32>2){let i=DU[(127&ce[pt])<<1|ce[pt+1]>>7];return pt+=4,(i*e+(e>0?.5:-.5)|0)/i}return pt+=4,e;case 203:return e=ki.getFloat64(pt),pt+=8,e;case 204:return ce[pt++];case 205:return e=ki.getUint16(pt),pt+=2,e;case 206:return e=ki.getUint32(pt),pt+=4,e;case 207:return Er.int64AsType==="number"?(e=4294967296*ki.getUint32(pt),e+=ki.getUint32(pt+4)):Er.int64AsType==="string"?e=ki.getBigUint64(pt).toString():Er.int64AsType==="auto"?(e=ki.getBigUint64(pt),e<=BigInt(2)<<BigInt(52)&&(e=Number(e))):e=ki.getBigUint64(pt),pt+=8,e;case 208:return ki.getInt8(pt++);case 209:return e=ki.getInt16(pt),pt+=2,e;case 210:return e=ki.getInt32(pt),pt+=4,e;case 211:return Er.int64AsType==="number"?(e=4294967296*ki.getInt32(pt),e+=ki.getUint32(pt+4)):Er.int64AsType==="string"?e=ki.getBigInt64(pt).toString():Er.int64AsType==="auto"?(e=ki.getBigInt64(pt),e>=BigInt(-2)<<BigInt(52)&&e<=BigInt(2)<<BigInt(52)&&(e=Number(e))):e=ki.getBigInt64(pt),pt+=8,e;case 212:if(e=ce[pt++],e==114)return RU(63&ce[pt++]);{let i=wa[e];if(i)return i.read?(pt++,i.read(Ys())):i.noBuffer?(pt++,i()):i(ce.subarray(pt,++pt));throw new Error("Unknown extension "+e)}case 213:return e=ce[pt],e==114?(pt++,RU(63&ce[pt++],ce[pt++])):nf(2);case 214:return nf(4);case 215:return nf(8);case 216:return nf(16);case 217:return e=ce[pt++],Gh>=pt?em.slice(pt-ml,(pt+=e)-ml):Oft(e);case 218:return e=ki.getUint16(pt),Gh>=(pt+=2)?em.slice(pt-ml,(pt+=e)-ml):Ift(e);case 219:return e=ki.getUint32(pt),Gh>=(pt+=4)?em.slice(pt-ml,(pt+=e)-ml):Nft(e);case 220:return e=ki.getUint16(pt),pt+=2,DX(e);case 221:return e=ki.getUint32(pt),pt+=4,DX(e);case 222:return e=ki.getUint16(pt),pt+=2,OX(e);case 223:return e=ki.getUint32(pt),pt+=4,OX(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 TU(t,e){function i(){if(i.count++>CU){let s;try{s=t.read=new Function("r","return function(){return "+(Er.freezeData?"Object.freeze":"")+"({"+t.map(n=>n==="__proto__"?"__proto_:r()":Dft.test(n)?n+":r()":"["+JSON.stringify(n)+"]:r()").join(",")+"})}")(Ys)}catch{return CU=1/0,i()}return t.read0=s,t.highByte===0&&(t.read=EU(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]=Ys()}return Er.freezeData?Object.freeze(r):r}return i.count=0,t.read0=i,t.highByte===0?EU(e,i):i}function Mft(){let t=Pft(()=>(ce=null,Er.getStructures()));return Gi=Er._mergeStructures(t,Gi)}function n2(t){let e;if(t<16&&(e=HG(t)))return e;if(t>64&&AU)return AU.decode(ce.subarray(pt,pt+=t));let i=pt+t,r=[];for(e="";pt<i;){let s=ce[pt++];if(128&s)if((224&s)==192){let n=(31&s)<<6|63&ce[pt++];n<128?r.push(65533):r.push(n)}else if((240&s)==224){let n=(31&s)<<12|(63&ce[pt++])<<6|63&ce[pt++];n<2048||n>=55296&&n<=57343?r.push(65533):r.push(n)}else if((248&s)==240){let n=(7&s)<<18|(63&ce[pt++])<<12|(63&ce[pt++])<<6|63&ce[pt++];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+=Mn.apply(String,r),r.length=0)}return r.length>0&&(e+=Mn.apply(String,r)),e}function DX(t){let e=new Array(t);for(let i=0;i<t;i++)e[i]=Ys();return Er.freezeData?Object.freeze(e):e}function OX(t){if(Er.mapsAsObjects){let e={};for(let i=0;i<t;i++){let r=Cft();r==="__proto__"&&(r="__proto_"),e[r]=Ys()}return e}{let e=new Map;for(let i=0;i<t;i++)e.set(Ys(),Ys());return e}}function Aft(t){let e=pt,i=new Array(t);for(let r=0;r<t;r++){let s=ce[pt++];if((128&s)>0)return void(pt=e);i[r]=s}return Mn.apply(String,i)}function HG(t){if(t<4){if(t<2){if(t===0)return"";{let e=ce[pt++];return(128&e)>1?void(pt-=1):Mn(e)}}{let e=ce[pt++],i=ce[pt++];if((128&e)>0||(128&i)>0)return void(pt-=2);if(t<3)return Mn(e,i);let r=ce[pt++];return(128&r)>0?void(pt-=3):Mn(e,i,r)}}{let e=ce[pt++],i=ce[pt++],r=ce[pt++],s=ce[pt++];if((128&e)>0||(128&i)>0||(128&r)>0||(128&s)>0)return void(pt-=4);if(t<6){if(t===4)return Mn(e,i,r,s);{let n=ce[pt++];return(128&n)>0?void(pt-=5):Mn(e,i,r,s,n)}}if(t<8){let n=ce[pt++],a=ce[pt++];if((128&n)>0||(128&a)>0)return void(pt-=6);if(t<7)return Mn(e,i,r,s,n,a);let o=ce[pt++];return(128&o)>0?void(pt-=7):Mn(e,i,r,s,n,a,o)}{let n=ce[pt++],a=ce[pt++],o=ce[pt++],l=ce[pt++];if((128&n)>0||(128&a)>0||(128&o)>0||(128&l)>0)return void(pt-=8);if(t<10){if(t===8)return Mn(e,i,r,s,n,a,o,l);{let h=ce[pt++];return(128&h)>0?void(pt-=9):Mn(e,i,r,s,n,a,o,l,h)}}if(t<12){let h=ce[pt++],u=ce[pt++];if((128&h)>0||(128&u)>0)return void(pt-=10);if(t<11)return Mn(e,i,r,s,n,a,o,l,h,u);let d=ce[pt++];return(128&d)>0?void(pt-=11):Mn(e,i,r,s,n,a,o,l,h,u,d)}{let h=ce[pt++],u=ce[pt++],d=ce[pt++],c=ce[pt++];if((128&h)>0||(128&u)>0||(128&d)>0||(128&c)>0)return void(pt-=12);if(t<14){if(t===12)return Mn(e,i,r,s,n,a,o,l,h,u,d,c);{let p=ce[pt++];return(128&p)>0?void(pt-=13):Mn(e,i,r,s,n,a,o,l,h,u,d,c,p)}}{let p=ce[pt++],m=ce[pt++];if((128&p)>0||(128&m)>0)return void(pt-=14);if(t<15)return Mn(e,i,r,s,n,a,o,l,h,u,d,c,p,m);let f=ce[pt++];return(128&f)>0?void(pt-=15):Mn(e,i,r,s,n,a,o,l,h,u,d,c,p,m,f)}}}}}function IX(){let t,e=ce[pt++];if(e<192)t=e-160;else switch(e){case 217:t=ce[pt++];break;case 218:t=ki.getUint16(pt),pt+=2;break;case 219:t=ki.getUint32(pt),pt+=4;break;default:throw new Error("Expected string")}return n2(t)}function MI(t){return Er.copyBuffers?Uint8Array.prototype.slice.call(ce,pt,pt+=t):ce.subarray(pt,pt+=t)}function nf(t){let e=ce[pt++];if(wa[e]){let i;return wa[e](ce.subarray(pt,i=pt+=t),r=>{pt=r;try{return Ys()}finally{pt=i}})}throw new Error("Unknown extension type "+e)}function Cft(){let t=ce[pt++];if(!(t>=160&&t<192))return pt--,Eft(Ys());if(t-=160,Gh>=pt)return em.slice(pt-ml,(pt+=t)-ml);if(!(Gh==0&&Jl<180))return O4(t);let e,i=4095&(t<<5^(t>1?ki.getUint16(pt):t>0?ce[pt]:0)),r=PU[i],s=pt,n=pt+t-3,a=0;if(r&&r.bytes==t){for(;s<n;){if(e=ki.getUint32(s),e!=r[a++]){s=1879048192;break}s+=4}for(n+=3;s<n;)if(e=ce[s++],e!=r[a++]){s=1879048192;break}if(s===n)return pt=s,r.string;n-=3,s=pt}for(r=[],PU[i]=r,r.bytes=t;s<n;)e=ki.getUint32(s),r.push(e),s+=4;for(n+=3;s<n;)e=ce[s++],r.push(e);let o=t<16?HG(t):Aft(t);return r.string=o??O4(t)}function Eft(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 Pft(t){kX&&kX();let e=Jl,i=pt,r=D4,s=ml,n=Gh,a=em,o=R4,l=fc,h=Ea,u=new Uint8Array(ce.slice(0,Jl)),d=Gi,c=Gi.slice(0,Gi.length),p=Er,m=gc,f=t();return Jl=e,pt=i,D4=r,ml=s,Gh=n,em=a,R4=o,fc=l,Ea=h,ce=u,gc=m,(Gi=d).splice(0,Gi.length,...c),Er=p,ki=new DataView(ce.buffer,ce.byteOffset,ce.byteLength),f}function MU(){ce=null,fc=null,Gi=null}function M3t(t){t.unpack?wa[t.type]=t.unpack:wa[t.type]=t}var AU,ce,Jl,pt,NX,R4,D4,Er,Gi,em,ml,Gh,Ea,fc,wa,ki,AI,Rft,gc,CU,BX,kX,a2,Dft,EU,O4,Oft,Ift,Nft,Mn,PU,RU,CI,VX,zX,LX,DU,FM,FX,UX,jX,OU,EI,$S,A3t=U(()=>{try{AU=new TextDecoder}catch{}pt=0,R4=NX=[],D4=0,Er={},ml=0,Gh=0,wa=[],AI={useRecords:!1,mapsAsObjects:!0},(Rft=new class{}).name="MessagePack 0xC1",gc=!1,CU=2,a2=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(ce)return Pft(()=>(MU(),this?this.unpack(t,e):a2.prototype.unpack.call(AI,t,e)));!t.buffer&&t.constructor===ArrayBuffer&&(t=typeof Buffer<"u"?Buffer.from(t):new Uint8Array(t)),typeof e=="object"?(Jl=e.end||t.length,pt=e.start||0):(pt=0,Jl=e>-1?e:t.length),D4=0,Gh=0,em=null,R4=NX,Ea=null,ce=t;try{ki=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(i){throw ce=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 a2){if(Er=this,this.structures)return Gi=this.structures,LM(e);(!Gi||Gi.length>0)&&(Gi=[])}else Er=AI,(!Gi||Gi.length>0)&&(Gi=[]);return LM(e)}unpackMultiple(t,e){let i,r=0;try{gc=!0;let s=t.length,n=this?this.unpack(t,s):FM.unpack(t,s);if(!e){for(i=[n];pt<s;)r=pt,i.push(LM());return i}if(e(n,r,pt)===!1)return;for(;pt<s;)if(r=pt,e(LM(),r,pt)===!1)return}catch(s){throw s.lastPosition=r,s.values=i,s}finally{gc=!1,MU()}}_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)}},Dft=/^[a-zA-Z_$][a-zA-Z\d_$]*$/,EU=(t,e)=>function(){let i=ce[pt++];if(i===0)return e();let r=t<32?-(t+(i<<5)):t+(i<<5),s=Gi[r]||Mft()[r];if(!s)throw new Error("Record id is not defined for "+r);return s.read||(s.read=TU(s,t)),s.read()},O4=n2,Oft=n2,Ift=n2,Nft=n2,Mn=String.fromCharCode,PU=new Array(4096),RU=(t,e)=>{let i=Ys().map(Eft),r=t;e!==void 0&&(t=t<32?-((e<<5)+t):(e<<5)+t,i.highByte=e);let s=Gi[t];return s&&(s.isShared||gc)&&((Gi.restoreStructures||(Gi.restoreStructures=[]))[t]=s),Gi[t]=i,i.read=TU(i,r),(i.read0||i.read)()},wa[0]=()=>{},wa[0].noBuffer=!0,wa[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),h=s(n,l),u=s(l,a);return h<<BigInt(8*(a-l))|u};i=i<<BigInt(8*(r.byteLength-e))|s(e,r.byteLength)}return i},CI={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError,AggregateError:typeof AggregateError=="function"?AggregateError:null},wa[101]=()=>{let t=Ys();if(!CI[t[0]]){let e=Error(t[1],{cause:t[2]});return e.name=t[0],e}return CI[t[0]](t[1],{cause:t[2]})},wa[105]=t=>{if(Er.structuredClone===!1)throw new Error("Structured clone extension is disabled");let e=ki.getUint32(pt-4);fc||(fc=new Map);let i,r=ce[pt];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)&&ce[pt+1]===115?new Set:{};let s={target:i};fc.set(e,s);let n=Ys();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},wa[112]=t=>{if(Er.structuredClone===!1)throw new Error("Structured clone extension is disabled");let e=ki.getUint32(pt-4),i=fc.get(e);return i.used=!0,i.target},wa[115]=()=>new Set(Ys()),VX=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(t=>t+"Array"),zX=typeof globalThis=="object"?globalThis:window,wa[116]=t=>{let e=t[0],i=Uint8Array.prototype.slice.call(t,1).buffer,r=VX[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 zX[r](i)},wa[120]=()=>{let t=Ys();return new RegExp(t[0],t[1])},LX=[],wa[98]=t=>{let e=(t[0]<<24)+(t[1]<<16)+(t[2]<<8)+t[3],i=pt;return pt+=e-t.length,Ea=LX,(Ea=[IX(),IX()]).position0=0,Ea.position1=0,Ea.postBundlePosition=pt,pt=i,Ys()},wa[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"),DU=new Array(147);for(let t=0;t<256;t++)DU[t]=+("1e"+Math.floor(45.15-.30103*t));(FM=new a2({useRecords:!1})).unpack,FM.unpackMultiple,FM.unpack,FX=new Float32Array(1),new Uint8Array(FX.buffer,0,4)}),C3t=U(()=>{A3t(),UG(),aD(),o0(),nD(),a0(),UX=[{Class:Ne.prototype.constructor,type:1,write:t=>({...t}),read:t=>(Object.setPrototypeOf(t,Ne.prototype),t)},{Class:ue.prototype.constructor,type:2,write:t=>[...t],read:t=>(Object.setPrototypeOf(t,ue.prototype),t)},{Class:Nn.prototype.constructor,type:3,write:t=>[...t],read:t=>(Object.setPrototypeOf(t,Nn.prototype),t)},{Class:A4.prototype.constructor,type:4,write:t=>t.id,read:t=>new A4(t)},{Class:wU.prototype.constructor,type:5,write:t=>t.data,read:t=>new wU(t)},{Class:Cs.prototype.constructor,type:6,write:t=>({...t}),read:t=>(Object.setPrototypeOf(t,Cs.prototype),t)}];for(let t of UX)M3t(t);jX=new a2({structuredClone:!0}),(OU||(OU={})).deserialize=function(t){return jX.unpack(t)}}),E3t=U(()=>{C3t(),EI=t=>()=>{throw new Error(t+" is not available in the runtime build (decode-only CollabSerialize)")},$S={deserialize:OU.deserialize,serialize:EI("CollabSerialize.serialize"),checksum:EI("CollabSerialize.checksum")}}),Li=U(()=>{oD(),_3t(),jG(),a0(),nD(),GG(),o0(),w3t(),S3t(),Tft(),T3t(),UG(),E3t(),bft(),aD()});function IU(t){return t==="MouseDown"||t==="MouseUp"||t==="KeyDown"||t==="KeyUp"||t==="Collision"||t==="Trigger"}var GX,NU,oS,UM,PI,WX,qX,HX,BU,kU,$X,XX,YX,KX,ZX,VU,zU,QX,JX,tY,eY,Bft=U(()=>{var t,e,i;Li(),ot(),(t=GX||(GX={})).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},NU={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 ue}:{type:s,disabled:!1,name:"",key:void 0,actions:new ue}}})(oS||(oS={})),(r=>{r.propertyDefaultData=function(s){return{type:"Property",value:[s??null,"position","x"]}},r.valueDefaultData={type:"Literal",value:0}})(UM||(UM={})),(e=PI||(PI={})).comparisonDefaultData=function(r){return{type:"Comparison",operator:"==",lOperand:UM.propertyDefaultData(r),rOperand:{...UM.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}},(WX||(WX={})).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 ue,outActions:new ue,condition:PI.distanceDefaultData(s)}}})(qX||(qX={})),(HX||(HX={})).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 ue,drop:new ue}},(BU||(BU={})).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 ue},(kU||(kU={})).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 ue}}})($X||($X={})),(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 ue}}})(XX||(XX={})),(r=>{r.is=function(s){return s.type==="Start"},r.defaultData=function(){return{type:"Start",disabled:!1,name:"",actions:new ue}}})(YX||(YX={})),(r=>{r.is=function(s){return s.type==="Collision"},r.defaultData=function(){return{type:"Collision",disabled:!1,name:"",target:"character",actions:new ue}}})(KX||(KX={})),(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 ue,triggerZone:"box",position:n.toArray(),rotation:[0,0,0],size:s.toArray(),radius:s.length()/2,helperVisible:!0}}})(ZX||(ZX={})),(i=VU||(VU={})).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 ue},s={size:"tablet",operator:"<",actions:new ue},n={size:[...i.defaultSizes.custom],operator:"<>",actions:new ue},a=new ue;return a.push({id:zt.generateUUID(),fi:0,data:r},{id:zt.generateUUID(),fi:1,data:s},{id:zt.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 ue}},(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 ue,variableId:"",objectId:null,property:"Position X"}}})(zU||(zU={})),(r=>{r.is=function(s){return s.type==="API"},r.defaultData=function(){return{disabled:!1,type:"API",name:"",successActions:new ue,errorActions:new ue,userAPIId:""}}})(QX||(QX={})),(r=>{r.is=function(s){return s.type==="WEBHOOK"},r.defaultData=function(){return{disabled:!1,type:"WEBHOOK",name:"",actions:new ue,userWebhookId:""}}})(JX||(JX={})),(r=>{r.is=function(s){return s.type==="AIAssistantListener"},r.defaultData=function(){return{disabled:!1,type:"AIAssistantListener",name:"",actions:new ue,analysis:"average",analysisRange:[0,71],analysisSingle:0}}})(tY||(tY={})),(r=>{r.is=function(s){return s.type==="AIAssistantTrigger"},r.defaultData=function(){return{disabled:!1,description:"",name:"",type:"AIAssistantTrigger",actions:new ue}}})(eY||(eY={}))});function iY(t){let e=typeof t;return t!==null&&(e==="object"||e==="function")}function LU(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 l0,mv,kft,i0,rY,Gu,fm,XS,sY,RI,_l,$s,qi,FU,nY,im,Fv,aY,oY,lY,hY,uY,dY,cY,pY,DI,mY,fY,OI,gY,yY,vY,II,bY,NI,_Y,xY,BI,wY,UU,SY,TY,MY,AY,CY,EY,r0,yc,rm,jU,GU,I4,N4,B4,k4,V4,WU,qU,z4,HU,fv,PY,kI,VI,$U,RY,L4,F4,zI,DY,XU,LI,OY,IY,NY,BY,Uv,kY,VY,zY,LY,lD,$G,Is,Qr,E1,Vft,jv,U4,wg,YU,XG,j4,G4,W4,hc,rR,Jn,FI,Kp,qo=U(()=>{var t,e,i,r,s,n,a,o;l0="personal camera",mv="a218fcc3-276b-49b9-b485-49037fd14f5f",kft=2500134,i0=5526619,(t=rY||{}).x="x",t.y="y",t.z="z",rY=t,(l=>{function h(c,p){return Math.pow(p[0]-c[0],2)+Math.pow(p[1]-c[1],2)}function u(c,p){return Math.sqrt(h(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=h,l.distance=u,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 u(c,d(c,p,m))},l.center=function(c,p){return[.5*(c[0]+p[0]),.5*(c[1]+p[1])]}})(Gu||(Gu={})),(e=fm||(fm={})).isEqual=function(l,h){return l[0]===h[0]&&l[1]===h[1]&&l[2]===h[2]},e.add=function(l,h){return[l[0]+h[0],l[1]+h[1],l[2]+h[2]]},e.sub=function(l,h){return[l[0]-h[0],l[1]-h[1],l[2]-h[2]]},e.div=function(l,h){return[l[0]/h[0],l[1]/h[1],l[2]/h[2]]},e.mul=function(l,h){return[l[0]*h[0],l[1]*h[1],l[2]*h[2]]},e.dist=function(l,h){return Math.hypot(l[0]-h[0],l[1]-h[1],l[2]-h[2])},e.lerp=function(l,h,u){return[l[0]+(h[0]-l[0])*u,l[1]+(h[1]-l[1])*u,l[2]+(h[2]-l[2])*u]},(i=XS||(XS={})).isEqual=function(l,h){return l[0]===h[0]&&l[1]===h[1]&&l[2]===h[2]&&l[3]===h[3]},i.lerp=function(l,h,u){return[l[0]+(h[0]-l[0])*u,l[1]+(h[1]-l[1])*u,l[2]+(h[2]-l[2])*u,l[3]+(h[3]-l[3])*u]},(l=>{let h=180/Math.PI,u=Math.PI/180;function d(p){return typeof p=="number"?p*h:p}function c(p){return typeof p=="number"?p*u: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])]}})(sY||(sY={})),(r=RI||(RI={})).identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],r.isEqual=function(l,h){for(let u=0;u<16;u++)if(l[u]!==h[u])return!1;return!0},r.simplify=function(l){return l??r.identity},r.applyMatrix4=function(l,h){let u=h.slice(0);for(let d=0,c=h.length;d<c;d+=3){let p=l[3]*h[d]+l[7]*h[d+1]+l[11]*h[d+2]+l[15];u[d]=(l[0]*h[d]+l[4]*h[d+1]+l[8]*h[d+2]+l[12])/p,u[d+1]=(l[1]*h[d]+l[5]*h[d+1]+l[9]*h[d+2]+l[13])/p,u[d+2]=(l[2]*h[d]+l[6]*h[d+1]+l[10]*h[d+2]+l[14])/p}return u},(l=>{l.zero=[0,0,0,0,0,0],l.INDEX_MAP=[4,8,1,9,2,6],l.toMatrix=function(h){let u=[...RI.identity];for(let d=0;d<6;d++)u[l.INDEX_MAP[d]]=h[d];return u},l.fromMatrix=function(h){return[h[l.INDEX_MAP[0]],h[l.INDEX_MAP[1]],h[l.INDEX_MAP[2]],h[l.INDEX_MAP[3]],h[l.INDEX_MAP[4]],h[l.INDEX_MAP[5]]]}})(_l||(_l={})),(s=$s||($s={})).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,h){return l.r===h.r&&l.g===h.g&&l.b===h.b},s.equalsFixed=function(l,h){return l.r.toFixed(2)===h.r.toFixed(2)&&l.g.toFixed(2)===h.g.toFixed(2)&&l.b.toFixed(2)===h.b.toFixed(2)},s.lerp=function(l,h,u){return{r:l.r+(h.r-l.r)*u,g:l.g+(h.g-l.g)*u,b:l.b+(h.b-l.b)*u}},s.is=function(l){return!!iY(l)&&"r"in l&&"g"in l&&"b"in l&&!("a"in l)},(n=qi||(qi={})).white={...$s.white,a:1},n.is=function(l){return!!iY(l)&&"r"in l&&"g"in l&&"b"in l&&"a"in l},n.transparent={...$s.white,a:0},n.from0to1=function(l){return{r:l[0],g:l[1],b:l[2],a:l[3]}},n.fromHexAndA=function(l,h){return{...$s.fromHex(l),a:h}},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,h){return $s.equals(l,h)&&l.a===h.a},n.equalsFixed=function(l,h){return $s.equalsFixed(l,h)&&l.a.toFixed(2)===h.a.toFixed(2)},n.lerp=function(l,h,u){return{r:l.r+(h.r-l.r)*u,g:l.g+(h.g-l.g)*u,b:l.b+(h.b-l.b)*u,a:l.a+(h.a-l.a)*u}},n.toStyle=function({r:l,g:h,b:u,a:d}=n.white){return`rgba(${255*l}, ${255*h}, ${255*u}, ${d})`},(FU||(FU={})).identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1],pivot:[0,0,0],pivotRotation:[0,0,0]},(a=nY||{})[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",nY=a,(im||(im={})).defaultData={mass:1,stiffness:80,damping:10,velocity:0},(Fv||(Fv={})).defaultData={control1:[.5,0],control2:[.5,1]},(o=aY||(aY={})).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]}),P3t=U(()=>{var t,e;Li(),Bft(),(oY||(oY={})).defaultData={type:"SwitchCamera",name:"",targetCamera:"",delay:0,animate:!0,duration:1e3,easing:4,runMode:"Normal"},(lY||(lY={})).defaultData={type:"SceneTransition",name:"",target:"",delay:0,duration:1,transition:"none"},(hY||(hY={})).defaultData={type:"Link",name:"",url:null,context:"tab"},(uY||(uY={})).defaultData={type:"Destroy",name:"",objects:[],delay:0},(dY||(dY={})).defaultData={type:"Particles",name:"",emitterObjectId:"",delay:0,emission:"start",triggerAfter:"any"},(cY||(cY={})).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"},(pY||(pY={})).defaultData={type:"Reset",name:"",delay:0},(DI||(DI={})).defaultData={interaction:"play",delay:0,volume:.5,loop:1},(t=mY||(mY={})).pauseDefaultData={interaction:"pause",delay:0},t.stopDefaultData={interaction:"stop",delay:0},(e=fY||(fY={})).defaultData={type:"Audio",name:"",...DI.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})=>{oS.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},(OI||(OI={})).defaultData={interaction:"play",delay:0,volume:.5,loop:1/0},(i=>{i.pauseDefaultData={interaction:"pause",delay:0},i.stopDefaultData={interaction:"stop",delay:0}})(gY||(gY={})),(i=>{i.defaultData={type:"Video",name:"",triggerAfter:"autoplay",...OI.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((oS.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})=>{(oS.is(n)||n.type==="Start")&&s.push(...i.getVideosByActions(n.actions))}),s}})(yY||(yY={})),(vY||(vY={})).defaultData=function(i){return{state:i,repeat:0,delay:0,delayDirection:"start-once",direction:"normal",duration:1e3,easing:4}},(II||(II={})).defaultData=function(){return{tweens:new ue,repeat:0,delay:0,delayDirection:"start-once",direction:"normal"}},(bY||(bY={})).defaultData=function(i){return{type:"Transition",name:"",runMode:"Once",object:i??null,...II.defaultData()}},(NI||(NI={})).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}})(_Y||(_Y={})),(xY||(xY={})).defaultData=function(i){return{type:"TimelineAnimation",name:"",...NI.defaultData(i)}},(BI||(BI={})).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}})(wY||(wY={})),(i=>{i.defaultData=function(r,s,n){return{type:"Animation",name:"",...BI.defaultData(r,s,n)}},i.isPause=function(r){return r.interaction==="pause"||r.interaction==="stop"}})(UU||(UU={})),(SY||(SY={})).defaultData={type:"SetVariable",name:"",variableId:"",expression:[]},(TY||(TY={})).defaultData=()=>({type:"Conditional",name:"",ifActions:new ue,elseActions:new ue,condition:[]}),(MY||(MY={})).defaultData={type:"DynamicVariablePlay",name:"",variableId:"",mode:"PlayPause",delay:0,pauseDelay:0},(AY||(AY={})).defaultData={type:"ClearLocalStorage",name:"",target:"all"},(CY||(CY={})).defaultData={name:"",type:"UserAPI"}}),R3t=U(()=>{var t;(t=EY||(EY={})).emptyAudio={data:Uint8Array.from(atob("UklGRjIAAABXQVZFZm10IBIAAAABAAEAQB8AAEAfAAABAAgAAABmYWN0BAAAAAAAAABkYXRhAAAAAA=="),e=>e.charCodeAt(0)),mimeType:"audio/wav",filename:"unknown"},t.maxSize=2e6}),zft=U(()=>{var t;(t=r0||(r0={})).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}})(yc||(yc={}))}),Lft=U(()=>{var t;(t=rm||(rm={})).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(GU.forEach(s=>{Object.assign(r,{[s]:i[s]??e[s]})}),r.radial={...e.radial},i.radial){let s=e.radial,n=i.radial;I4.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;N4.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;B4.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;k4.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;V4.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}})(jU||(jU={})),GU=["count"],I4=["radius","start","end","position","scale","rotation"],N4=["position","scale","rotation"],B4=["count","size"],k4=["count","position","scale","rotation"],V4=["strength","scale","rotation","position","movement","seed","freqScale"]}),Fft=U(()=>{var t;qo(),(t=WU||(WU={})).all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"],t.is=function(e){return t.all.includes(e)},(qU||(qU={})).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)}}),Uft=U(()=>{var t;(t=z4||(z4={})).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}}),jft=U(()=>{var t;(t=HU||(HU={})).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"]}),YG=U(()=>{(fv||(fv={})).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]}}),Gft=U(()=>{var t,e;(t=PY||{})[t.Front=0]="Front",t[t.Back=1]="Back",t[t.Double=2]="Double",PY=t,(e=kI||(kI={})).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)}})(VI||(VI={})),($U||($U={})).defaultData={...VI.defaultData,...kI.defaultData},(RY||(RY={})).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}}),Wft=U(()=>{var t;(t=L4||(L4={})).bytesFromFlattened=function(e){if(typeof e!="object"||e===null||Array.isArray(e)||ArrayBuffer.isView(e)||typeof e[0]!="number")return null;let i=Object.getPrototypeOf(e);if(i!==Object.prototype&&i!==null)return null;let r=Object.keys(e),s=new Uint8Array(r.length),n=e;for(let a=0;a<r.length;a++){let o=n[a];if(r[a]!==String(a)||typeof o!="number"||!Number.isInteger(o)||o<0||o>255)return null;s[a]=o}return s},t.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"}}),qft=U(()=>{var t;(t=F4||(F4={})).defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},t.maxSize=3e7}),yT=U(()=>{var t,e,i,r;Li(),qo(),Wft(),qft(),qo(),(zI||(zI={})).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"},(DY||(DY={})).is=function(s){return s==="luminance"||s==="r"||s==="g"||s==="b"||s==="a"},(XU||(XU={})).is=function(s){return typeof s=="object"&&s!==null&&s.image!=null},(LI||(LI={})).is=function(s){return s==="phong"||s==="toon"||s==="lambert"||s==="physical"},(e=OY||{})[e.Linear=0]="Linear",e[e.Radial=1]="Radial",e[e.Polar=2]="Polar",OY=e,IY=(s=>(s[s.RepeatWrapping=1e3]="RepeatWrapping",s[s.ClampToEdgeWrapping=1001]="ClampToEdgeWrapping",s[s.MirroredRepeatWrapping=1002]="MirroredRepeatWrapping",s))(IY||{}),NY=(s=>(s[s.NearestFilter=1003]="NearestFilter",s[s.LinearFilter=1006]="LinearFilter",s[s.LinearMipmapLinearFilter=1008]="LinearMipmapLinearFilter",s))(NY||{}),(t=BY||{})[t.UV=0]="UV",t[t.Planar=1]="Planar",t[t.Spherical=2]="Spherical",t[t.Cylindrical=3]="Cylindrical",t[t.Triplanar=4]="Triplanar",BY=t,(s=>{s.MAX=3,s.of=function(n){return typeof n=="number"&&Number.isInteger(n)&&n>=0&&n<=3?n:0},s.attributeName=function(n){return n===0?"uv":`uv${n}`}})(Uv||(Uv={})),(r=kY||{})[r.Simplex=0]="Simplex",r[r.SimplexFractal=1]="SimplexFractal",r[r.Ashima=2]="Ashima",r[r.Fbm=3]="Fbm",r[r.Perlin=4]="Perlin",r[r.Voronoi=5]="Voronoi",kY=r,(i=VY||{})[i.F1=0]="F1",i[i.F2=1]="F2",i[i.F2MinusF1=2]="F2MinusF1",i[i.SmoothBlend=3]="SmoothBlend",i[i.Edge=4]="Edge",i[i.Power=5]="Power",i[i.Lines=6]="Lines",i[i.Cells=7]="Cells",VY=i,zY=(s=>(s[s.Lights=0]="Lights",s[s.Static=1]="Static",s[s.Camera=2]="Camera",s))(zY||{}),LY=(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))(LY||{}),lD=["mode","gradientType","noiseType","tracingMode","mirror","displacementType","projection","cnormal","crop","axis","side","roughnessMapChannel","metalnessMap","metalnessMapChannel","normalMap","aoMap","aoMapChannel","emissiveMap","style"],$G=["wrapping","image","video","name","minFilter","magFilter"],(s=>{function n(a,o){return a==="light"&&o?function(l){let h={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(l){case"phong":return{...h,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...h,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...h,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...h,category:"physical",roughness:.6,metalness:.2,reflectivity:.2,type:"light",alpha:.6,visible:!0,mode:0,occlusion:!0}}}(o):function(l){let h={alpha:1,mode:0,isMask:!1,visible:!0};switch(l){case"texture":return{...h,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{...h,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:F4.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006},crop:!1};case"color":return{...h,type:"color",color:$s.fromHex(i0)};case"vertexColor":return{...h,type:"vertexColor"};case"depth":return{...h,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{...h,type:"normal",cnormal:[1,1,1]};case"gradient":return{...h,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{...h,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...$s.fromHex(6710886),a:1},colorB:{...$s.fromHex(6710886),a:1},colorC:{...$s.fromHex(16777215),a:1},colorD:{...$s.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{...h,type:"cavity",mode:3,ridge:1,valley:1};case"fresnel":return{...h,type:"fresnel",color:qi.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"dust":return{...h,type:"dust",color:qi.fromHexAndA(10323813,1),coverage:.2,softness:.2,noiseStrength:.2,noiseScale:1};case"rainbow":return{...h,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...h,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{...h,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{...h,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006}};case"transmission":return{...h,type:"transmission",thickness:10,ior:1.5,roughness:1};case"reflection":return{...h,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{...h,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...$s.fromHex(0),a:1},colorB:{...$s.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}}}(a)}s.patch=function(a,o){let{texture:l,...h}=o;if(Object.assign(a,h),l){let u=a.texture;u&&Object.assign(u,l)}},s.defaultColorLayer=function(a){return{...s.defaultData("color"),color:a}},s.defaultData=n,s.defaultDataFor=function(a,o){return a!=="light"?n(a):n("light",typeof o=="string"&&LI.is(o)?o:"physical")}})(Is||(Is={})),(s=>{function n(l,h){if(typeof l!="string"||!/^#[0-9a-f]{6}([0-9a-f]{2})?$/i.test(l))return l;let{r:u,g:d,b:c}=$s.fromHex(parseInt(l.slice(1,7),16)),p=l.length===9?parseInt(l.slice(7),16)/255:void 0;if(Array.isArray(h))return h.length>3?[u,d,c,p??h[3]]:[u,d,c];let m=h;return typeof m?.r!="number"?l:typeof m.a=="number"?{r:u,g:d,b:c,a:p??m.a}:{r:u,g:d,b:c}}function a(l){let h=l?.data;return typeof h=="object"&&h!==null}function o(l,h="layer1",u="layer2",d=$s.fromHex(16777215)){let c=new ue;return c.push({fi:0,data:Is.defaultData("light",l),id:h}),c.push({fi:1,data:Is.defaultData("color"),id:u}),{layers:c}}s.restoreImageBytes=function(l){let h=[],u=new Map,d=(p,m)=>{let f=Q1(p);if(typeof f!="object"||f===null||ArrayBuffer.isView(f))return p;if(u.has(f))return u.get(f)??p;u.set(f,void 0);let g=c(f,m)??p;return u.set(f,g),g},c=(p,m)=>{let f=p;if(!Array.isArray(p)){if(typeof f[0]=="number")return;if(typeof f.name=="string"){let y=L4.bytesFromFlattened(Q1(f.data));if(y!==null)return h.push({path:`${m}/data`,bytes:y.byteLength}),Object.setPrototypeOf({...f,data:y},Object.getPrototypeOf(p))}}let g=null;for(let y of Object.keys(p)){let v=f[y],b=d(v,`${m}/${y}`);b!==v&&(g===null&&(g=Array.isArray(p)?[...p]:{...f},Object.setPrototypeOf(g,Object.getPrototypeOf(p))),g[y]=b)}return g??void 0};return{material:d(l,""),restored:h}},s.restoreLayersSeq=function(l){let h=Q1(l.layers);if(!Array.isArray(h)||h instanceof ue||!h.every(c=>typeof c=="object"&&c!==null&&typeof c.id=="string"&&typeof c.data=="object"))return{material:l,restored:!1};let u=Object.setPrototypeOf([...h],ue.prototype),d=Q1(l);return{material:Object.setPrototypeOf({...d,layers:u},Object.getPrototypeOf(d)),restored:!0}},s.isMergable=function(l){return!l.layers.some(h=>h.data.type==="texture"&&h.data.projection!==0||h.data.type==="depth"&&!h.data.isWorldSpace||h.data.type==="noise"||h.data.type==="dust"&&h.data.noiseStrength!==0||h.data.type==="displace")},s.getHash=function(l){let h="";return l.layers.forEach(u=>{Object.entries(u.data).forEach(([d,c])=>{h+=`${d}${c}`,Array.isArray(c)?c.forEach(p=>h+=`${p}`):typeof c=="object"?Object.values(c).forEach(p=>{h+=typeof p=="number"?`${p.toFixed(4)}`:`${p}`}):h+=`${c}`})}),h},s.defaultEmptyData=function(){return{layers:new ue}},s.defaultData=function(l="layer1",h="layer2"){return o("physical",l,h)},s.withName=function(l,h){return{...l,name:h}},s.isLayerEntry=a,s.withRepairedLayers=function(l){if(l.layers===void 0)return{...l,layers:o("phong").layers};let h=Array.from(l.layers);if(h.every(a))return l;let u=new ue;return h.forEach((d,c)=>{if(a(d))return void u.push(d);let{id:p,fi:m,...f}=d??{};if(typeof f.type!="string"||!zI.is(f.type))return;let g=Is.defaultDataFor(f.type,f.category),y={...g,...f};for(let[v,b]of Object.entries(f)){let _=g[v];y[v]=Array.isArray(b)&&Array.isArray(_)&&Array.isArray(_[0])?b.map(x=>n(x,_[0])):n(b,_)}u.push({id:typeof p=="string"&&p?p:`layer${c+1}`,fi:typeof m=="number"?m:c,data:y})}),{...l,layers:u}},s.defaultTwoLayerData=o,s.defaultColorMaterial=function(l,h,u="layer1",d="layer2"){let c=new ue;return c.push({fi:0,data:Is.defaultData("light",h),id:u}),c.push({fi:1,data:Is.defaultColorLayer(l),id:d}),{layers:c}},s.defaultUIObjectMaterial=function(l){let h=Is.defaultData("texture");l&&Object.assign(h.texture,{image:l});let u=new ue;return u.push({fi:0,data:h,id:"layer1"}),u.push({fi:1,data:{...Is.defaultData("transmission"),alpha:1},id:"layer2"}),u.push({fi:2,data:{...Is.defaultData("light","lambert"),alpha:0},id:"layer3"}),{layers:u}},s.defaultTwoLayerTextureData=function(l,h="physical",u="layer1",d="layer2"){let c=Is.defaultData("texture");Object.assign(c.texture,{image:l});let p=new ue;return p.push({fi:0,data:c,id:u}),p.push({fi:1,data:Is.defaultData("light",h),id:d}),{layers:p}},s.defaultTwoLayerVideoTextureData=function(l,h="physical",u="layer1",d="layer2"){let c=Is.defaultData("video");Object.assign(c.texture,{video:l});let p=new ue;return p.push({fi:0,data:c,id:u}),p.push({fi:1,data:Is.defaultData("light",h),id:d}),{layers:p}}})(Qr||(Qr={}))}),D3t=U(()=>{E1="Roboto_regular",Vft="https://fonts.gstatic.com/s/roboto/v30/KFOmCnqEu92Fr1Me5WZLCzYlKw.ttf"}),O3t=U(()=>{D3t()}),Hft=U(()=>{var t;Li(),(t=jv||(jv={})).defaultData=function(){return{points:new ue,roundness:0,shapeHoles:[],isClosed:!1}},t.scaled=function e(i,r,s){let n=a=>[a[0]*r,a[1]*s];return{...i,points:new ue(...i.points.map(({id:a,fi:o,data:l})=>({id:a,fi:o,data:{...l,position:n(l.position),controlPrevious:{position:n(l.controlPrevious.position)},controlNext:{position:n(l.controlNext.position)}}}))),shapeHoles:i.shapeHoles.map(a=>e(a,r,s))}}}),$ft=U(()=>{Li(),(U4||(U4={})).defaultData=function(){return{points:new ue,lastInsertionPlane:null,subdivisions:12,isClosed:!1,subdivisionMode:"parametric"}},wg={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0},(YU||(YU={})).merge=function(t,e){let i={...t};return j4.forEach(r=>{Object.assign(i,{[r]:e[r]??t[r]})}),i},XG={shape:wg,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},j4=["depth","offset","angle","twist","startScale","endScale"]}),KG=U(()=>{var t,e;Hft(),$ft(),(t=G4||(G4={})).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"},(W4||(W4={})).merge=function(i,r){let s={...i};if(Object.assign(s,r),s.type==="PathGeometry"&&"extrusion"in r&&r.extrusion&&(s.extrusion={...i.extrusion},Object.assign(s.extrusion,YU.merge(s.extrusion,r.extrusion))),i.type==="VectorGeometry"&&s.type==="VectorGeometry"){let n=(l,h)=>typeof l=="number"&&typeof h=="number"&&h!==0?l/h:1,a=n(s.width,i.width),o=n(s.height,i.height);(a!==1||o!==1)&&(s.shape=jv.scaled(i.shape,a,o))}return s},(e=hc||(hc={})).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:U4.defaultData(),extrusion:XG};if(i==="VectorGeometry")return{width:1,height:1,type:i,subdivisions:12,shape:jv.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")},rR=["width","height","depth"]}),Xft=U(()=>{qo(),(t=>{function e(i){return i.mode??"linear"}t.defaultData={enabled:!1,useBackgroundColor:!1,color:$s.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}})(Jn||(Jn={}))}),ZG=U(()=>{(FI||(FI={})).defaultData={image:null,rotation:0,blur:32,showBackground:!0},(Kp||(Kp={})).defaultData={enabled:!1,mode:"hdri",hdri:FI.defaultData,timeOfDay:10,weather:"partlyCloudy",lighting:!0,lightingIntensity:1,lightingQuality:"full",clouds:!0,windSpeed:2,animateWind:!0,exposure:1,seed:2}});function I3t(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 q4,gv,UI,jI,GI,yv,WI,KU,ZU,FY,G0,Yft,an,H4,UY,jY,GY,WY,Iu,lS,$4,X4,vc,Hg,qY,sm,Y4,bc,qI,HI,Pg,s0,Rg,hS,QU,HY,Pa,$I,$Y,XY,uc,Zl,vv,Kft=U(()=>{(()=>{let t={opacity:1,blendFunction:13,enabled:!1};(q4||(q4={})).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}}})()}),QG=U(()=>{var t;Xft(),ZG(),Kft(),qo(),(t=gv||(gv={})).defaultData={type:"normal",softShadowQuality:"low"},t.isSoft=function(e){return e!=null&&(e.type===void 0||e.type==="soft")},(UI||(UI={})).defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75},(jI||(jI={})).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}})(GI||(GI={})),(yv||(yv={})).defaultData={usePhysics:!1,gravity:-10},(WI||(WI={})).defaultData={playCamera:l0,gameControlObject:null},(KU||(KU={})).defaultData={backgroundColor:qi.fromHexAndA(kft,1),postprocessing:q4.defaultData,fog:Jn.defaultData,sky:Kp.defaultData,globalPhysics:yv.defaultData,ambient:UI.defaultData,ao:jI.defaultData,shadow:gv.defaultData,publish:WI.defaultData,grading:GI.defaultData}}),N3t=U(()=>{(ZU||(ZU={})).defaultData={colliderType:"box",size:[100,100,100],colliderHelperVisible:!0,forceType:"collider",forceRange:"global",forceIntensity:.5,forceDambing:.95}}),hD=U(()=>{var t,e,i;Li(),zft(),Fft(),Uft(),jft(),YG(),Gft(),qo(),yT(),KG(),Lft(),dn(),QG(),N3t(),(t=FY||(FY={})).isComponentRelated=function(r){return r==="Component"||r==="Instance"},t.isEmptyOrComponent=function(r){return r==="Empty"||r==="Instance"},(e=G0||(G0={})).identity={...FU.identity,shear:_l.zero},e.fromObject=function(r){return{position:r.position,rotation:r.rotation,scale:r.scale,pivot:r.pivot,pivotRotation:r.pivotRotation,shear:r.shear}},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,shear:s?.shear||r.shear}},e.diff=function(r,s){return fft({position:fm.isEqual(r.position,s.position)?void 0:s.position,rotation:fm.isEqual(r.rotation,s.rotation)?void 0:s.rotation,scale:fm.isEqual(r.scale,s.scale)?null:s.scale,shear:s.shear?.every((n,a)=>n===r.shear?.[a])?void 0:s.shear})},Yft=["slide","offset"],(an||(an={})).defaultData={states:new ue,events:new ue,visible:!0,raycastLock:!1,physics:fv.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...G0.identity,cloner:null},(H4||(H4={})).defaultData={type:"Empty",...an.defaultData},(UY||(UY={})).defaultData={type:"ParticleCollider",...ZU.defaultData,...an.defaultData},(jY||(jY={})).defaultData={type:"Component",...an.defaultData},(GY||(GY={})).defaultData={type:"Particle",...an.defaultData,...z4.defaultData},(WY||(WY={})).defaultData={type:"Hair",...an.defaultData,...HU.defaultData},(Iu||(Iu={})).defaultData={type:"Mesh",...an.defaultData,...$U.defaultData},(lS||(lS={})).defaultData={...an.defaultData,...G0.identity,position:yc.DefaultPosition,rotation:yc.DefaultRotation,...yc.defaultData},(r=>{r.defaultData=function(s){return{...an.defaultData,...qU.defaultData(s)}},r.defaultDirectionalLightData={...r.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})($4||($4={})),(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 h=Object.keys(l);if(h.length===1&&h[0]==="descendants")return}return l}})(X4||(X4={})),(r=>{function s(n,a){return{...an.defaultData,...a,component:n,overrides:new Cs,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=G0.fromObject(n.data);return s(n.id,a)}})(vc||(vc={})),(r=>{r.defaultData={type:"Page",...an.defaultData,physics:{...fv.defaultData,fusedBody:!1},...KU.defaultData,camera:lS.defaultData,timelines:new Ne},r.isUIPage=function(s){return s.uiScene!==void 0}})(Hg||(Hg={})),(i=qY||(qY={})).defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],pivot:[0,0,0],pivotRotation:[0,0,0],shear:_l.zero,name:"Play Camera",visible:!0,raycastLock:!1,physics:fv.defaultData,states:new ue,events:new ue,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...yc.defaultData},i.KeysByResetCategory={States:["states"],Events:["events"],Material:["material","materials"],Geometry:["geometry"],Position:["position"],Rotation:["rotation"],Scale:["scale"],Transform:["position","scale","rotation","shear"],Name:["name"],Visibility:["visible","raycastLock","flatShading","wireframe","side","shadowCatcher"],Shadows:["castShadow","receiveShadow"],Cloner:["cloner"],Physics:["physics"]},i.defaultMeshObject={name:"Rectangle",...an.defaultData,...Iu.defaultData,geometry:hc.defaultData("RectangleGeometry"),material:Qr.defaultTwoLayerData("physical","layer1","layer2")},i.defaultBooleanObject={name:"Boolean",...an.defaultData,...Iu.defaultData,geometry:hc.defaultData("BooleanGeometry"),material:Qr.defaultTwoLayerData("physical","layer1","layer2")},i.defaultShapeBlendObject={name:"Shape Blend",...an.defaultData,...Iu.defaultData,geometry:hc.defaultData("ShapeBlendGeometry"),material:Qr.defaultTwoLayerData("physical","layer1","layer2")},i.defaultTextObject={name:"Text",...an.defaultData,...Iu.defaultData,geometry:hc.defaultData("TextGeometry"),material:Qr.defaultTwoLayerData("physical","layer1","layer2")},i.defaultInputObject={name:"Input",...an.defaultData,...Iu.defaultData,geometry:hc.defaultData("InputGeometry"),material:Qr.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 Cs}),"materials"in s&&(a.materials=s.materials.map(o=>({layers:new Cs})))):r0.is(s.type)&&(a.perspective={},a.orthographic={}),a},r.toOps=function(s,n){let a,o=[],l={orthographic:0,perspective:0,geometry:0};function h(u,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:[...u,"layers",c,"texture"],props:m,type:0};o.push(g)}if(Object.keys(f).length>0){let g={path:[...u,"layers",c],props:f,type:0};o.push(g)}}}for(let[u,d]of Object.entries(n)){let c=d;if(u!=="name")if(u==="cloner")o.push(...jU.toOps(c,["cloner"]));else if(u==="pathSnapping")o.push({path:[u],props:{slide:c.slide,offset:c.offset},type:0});else if(u==="material")h(["material"],c);else if(u==="materials")for(let[p,m]of Object.entries(c))h(["materials",p],m);else if(l[u]===0){if(u==="geometry"&&c.extrusion!==void 0){let p={path:[u,"extrusion"],props:c.extrusion,type:0};o.push(p),c={...c},delete c.extrusion}if(Object.keys(c).length>0){let p={path:[u],props:c,type:0};o.push(p)}}else a===void 0&&(a={path:[],props:{},type:0},o.push(a)),a.props[u]=c}return o},r.patch=function(s,n){if(n===void 0)return s;let a={...s};if(Object.assign(a,G0.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})}),r0.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:W4.merge(a.geometry,n.geometry)}),(n.material||n.materials)&&(a=function(o,l){if(l===void 0)return o;let h={...o};return"material"in h&&"material"in l&&l.material&&(h.material=E4(h.material,u=>{if(typeof u!="string")for(let[d,c]of Object.entries(l.material.layers)){let p=u.layers.data(d);p&&Is.patch(p,c)}}).data),h.materials&&l.materials&&(h.materials=E4(h.materials,u=>{for(let d=0;d<h.materials.length;d++){let c=l.materials[d];if(typeof c!="string")for(let[p,m]of Object.entries(c.layers)){let f=u[d]?.layers?.data(p);f&&Is.patch(f,m)}}}).data),h}(a,n)),a.cloner&&"cloner"in n&&Object.assign(a,{cloner:rm.merge(a.cloner,n.cloner)});else if(s.type==="Empty")a.cloner&&"cloner"in n&&Object.assign(a,{cloner:rm.merge(a.cloner,n.cloner)});else if(WU.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=$s.clone(o.color))}return a}})(sm||(sm={}))}),JG=U(()=>{(Y4||(Y4={})).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}}),uD=U(()=>{JG(),qo(),(bc||(bc={})).defaultData={orbitControls:Y4.defaultData,playPage:mv,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}}),Zft=U(()=>{var t;(qI||(qI={})).defaultData={id:"basic",label:"Basic",style:"None",prompt:""},(HI||(HI={})).defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0},(t=Pg||(Pg={})).defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...qI.defaultData},isRandomSeed:!0,seed:t.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:HI.defaultData}),t.generateSeed=()=>Math.round(1e5*Math.random())}),tW=U(()=>{hD(),Li(),uD(),qo(),dn(),Zft(),(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)})}})(s0||(s0={})),(t=>{function e(r=!0,s=[]){let n=[];r&&n.push({...t.defaultLight}),n.push(...s);let a=new Nn;return a.push({fi:1,id:mv,data:{...Hg.defaultData,name:"Scene 1"},children:n}),a}function i(r){return{...t.defaultData,objects:qa(r,Nn.prototype)}}t.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222",t.defaultLight={fi:-1,data:$4.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]},t.createDefaultObjectTreeWithPage=e,t.defaultData={objects:e(),publish:bc.defaultData,styles:Pg.defaultData()},t.emptyDataWithoutPage=function(){return{objects:new Nn,publish:bc.defaultData,styles:Pg.defaultData()}},t.emptyDataWithPage=function(r=!0){return{objects:e(r),publish:bc.defaultData,styles:Pg.defaultData()}},t.emptyData=function(){return{objects:new Nn,publish:{...bc.defaultData},styles:Pg.defaultData()}},t.withObjs=i,t.withObj=function(r,s){return i([{id:r,data:s,children:[],fi:0}])}})(Rg||(Rg={}))}),Qft=U(()=>{(hS||(hS={})).defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}}}),eW=U(()=>{var t,e;Li(),dn(),(t=QU||(QU={})).defaultData=i=>({url:i,name:"New Webhook",parametersSchemas:new ue}),t.defaultParameterValueByType=i=>i==="number"?0:i!=="boolean"&&"",(HY||(HY={})).defaultData=(i,r="GET")=>({url:i,method:r,name:"New API",headers:new ue,queries:new ue,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()}})(Pa||(Pa={})),($I||($I={})).all=["images","videos","colors","audios","particles","fonts","materials","variables"],($Y||($Y={})).all=[...$I.all,"components"],(XY||(XY={})).defaultData=function(){return{images:new Ne,videos:new Ne,colors:new Ne,audios:new Ne,particles:new Ne,fonts:new Ne,materials:new Ne,components:new Ne,variables:new Ne,userAPIs:new Ne,userWebhooks:new Ne}},(uc||(uc={})).defaultData=function(){return{images:new Ne,videos:new Ne,colors:new Ne,audios:new Ne,particles:new Ne,fonts:new Ne,materials:new Ne,components:new Ne,variables:new Ne,userAPIs:new Ne,userWebhooks:new Ne}},(e=Zl||(Zl={})).defaultColors=function(){return qa({"89b10010-844c-11ec-a8a3-0242ac120002":{r:.5,g:.5,b:.5,a:1,name:"Default Color"}},Ne.prototype)},e.defaultImages=function(){return qa({},Ne.prototype)},e.emptyData=function(){return{catelogs:new Ne,materials:new Ne,images:new Ne,videos:new Ne,colors:new Ne,audios:new Ne,particles:new Ne,fonts:new Ne,variables:new ue,userAPIs:new Ne,userWebhooks:new Ne,lib:uc.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}}),B3t=U(()=>{}),Jft=U(()=>{var t;Li(),tW(),Qft(),eW(),(t=vv||(vv={})).defaultData={schema:136,scene:Rg.defaultData,frames:new Ne().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",hS.defaultData),shared:{...Zl.emptyData(),colors:Zl.defaultColors()}},t.createDefaultData=function(){return $S.deserialize($S.serialize(t.defaultData))},t.emptyDataForImports=function(){return{schema:136,scene:Rg.emptyDataWithPage(),frames:new Ne().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",hS.defaultData),shared:{...Zl.emptyData(),colors:Zl.defaultColors(),images:Zl.defaultImages()}}},t.emptyData=function(){return{schema:136,scene:Rg.emptyDataWithPage(),frames:new Ne().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",hS.defaultData),shared:Zl.emptyData()}},t.clipboard2dData=function(){return{schema:136,scene:Rg.emptyData(),frames:new Ne,shared:Zl.emptyData()}},t.withoutLib=function(e){return{...e,shared:{...e.shared,lib:uc.defaultData()}}},t.getComponentData=function(e,i){return s0.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}});function Cc(t,e=[0,0]){return[t&&!isNaN(t[0])?t[0]:e[0],t&&!isNaN(t[1])?t[1]:e[1]]}function f_(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??{...Fv.defaultData};return`cubicBezier( ${r[0]}, ${r[1]}, ${s[0]}, ${s[1]} )`}case 6:{let{mass:r,stiffness:s,damping:n,velocity:a}=i??{...im.defaultData},o=new tgt(r,s,n,a),l=o.solve(1);return()=>h=>o.solve(h)/l}case 8:return()=>r=>Math.floor(r)}}function k3t(t){let e=function(r){return r.layers?.find(({data:s})=>s.type==="light")}(t);if(!e)return;let i=e.data.alphaOverride;return typeof i=="number"?i:1}function V3t(t,e,i){return i>0?t*e/i:t}var YY,KY,gm,YS,tgt,K4,Z4,iW=U(()=>{Li(),qo(),(YY||(YY={})).defaultData=function(t,e){return{id:t,name:e,duration:5,objectTimelines:new Ne}},(KY||(KY={})).is=function(t){return t&&typeof t.x=="number"&&typeof t.y=="number"&&typeof t.z=="number"},(t=>{function e(u,d){let c=[0,0],p=[1,1];if(u?.cubicControls)c=Cc(u.cubicControls.control1,c);else switch(u?.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=Cc(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(u){if(!t.BEZIER_PRESETS.includes(u))return;let d={type:u};return{control1:e(d).control1,control2:e(void 0,d).control2}}function r(u,d){return Math.abs(u[0]-d[0])<.001&&Math.abs(u[1]-d[1])<.001}function s(u){let d=t.ROOT_PROPERTY_ORDER.indexOf(u[0]);return d===-1?t.ROOT_PROPERTY_ORDER.length:d}function n(u){return u.layerId??u.path.join(".")}function a(u){let d=u[u.length-1];return YS.includes(d)?d:void 0}function o(u){return u.layerId?u.layerId:(a(u.path)?u.path.slice(0,-1):u.path).join(".")}function l(u){return["material",u.type==="light"?`${u.category} lighting`:u.type]}function h(u,d,c){return{id:u,data:{id:u,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(u){return t.BEZIER_PRESETS.find(d=>{let c=i(d);return c!==void 0&&r(c.control1,u.control1)&&r(c.control2,u.control2)})},t.defaultData=function(u){return{id:u,keyframes:new ue}},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(u,d){let c=new Map;for(let p of u){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(u){let d=new Map;for(let c of u){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(u){return[...u].sort((d,c)=>d.data.time-c.data.time)},t.materialLayerPath=l,t.createMaterialGroup=function(u,d){return u.map(({data:c,id:p},m)=>h(d(),l(c),{layerId:p,index:m}))},t.placeholderKeyframe=h,t.createName=function(u){return Object.entries(u).reduce((d,[c,p])=>(typeof p!="string"&&d.push({name:p.name}),d),[])},t.Presets=[{name:"Slide in",animationParams:{translateX:{value:[-20,0],easing:f_(3),duration:1e3},opacity:{value:[0,1],easing:f_(3),duration:1e3},endDelay:250,loop:!0}},{name:"Rotate",animationParams:{rotate:{value:[0,"1turn"],easing:f_(5),duration:700},endDelay:250,loop:!0}},{name:"Scale Out",animationParams:{scale:{value:[1,1.5],easing:f_(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:f_(5),duration:500},endDelay:500,loop:!0}},{name:"Bounce",animationParams:{translateY:{value:["20px","-20px"],duration:575,easing:"easeOutQuad"},direction:"alternate",loop:!0}}]})(gm||(gm={})),YS=["x","y","z"],tgt=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}}}),rW=U(()=>{var t;qo(),Li(),(K4||(K4={})).list=["idle","move","jump","run"],(t=Z4||(Z4={})).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 ue,move:new ue,jump:new ue,run:new ue},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 dg(t,...e){let i={};for(let r of e.flat())t!=null&&r in t&&(i[r]=t[r]);return i}function ZY(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={...dg(Os(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={...Os(e),near:Math.max(e.near,0),far:Math.max(e.far,0)};Object.assign(e,i)}})}function Zd(t,e){Object.values(t.shared.materials).forEach(i=>e(i))}function Qd(t,e){t.scene.objects.traverse((i,r)=>{"materials"in r?r.materials.forEach((s,n)=>{s===void 0&&(r.materials[n]=Qr.defaultTwoLayerData("phong"),s=r.materials[n]),typeof s!="string"&&e(s)}):"material"in r?typeof r.material!="string"&&(r.material===void 0&&(r.material=Qr.defaultTwoLayerData("phong")),e(r.material)):r.type==="Mesh"&&(r.material===void 0&&(r.material=Qr.defaultTwoLayerData("phong")),e(r.material)),"overrides"in r&&Object.values(r.overrides).forEach(s=>{s.material&&typeof s.material!="string"&&Object.getPrototypeOf(s.material)!==Cs.prototype&&e(s.material)})})}function QY(t){t.layers===void 0&&Object.assign(t,Qr.defaultTwoLayerData("lambert"))}function XI(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={...Os(e),colors:i,steps:r};Object.assign(e,s)}})}function JY(t){t.scene.objects.traverse((e,i)=>{"materials"in i?i.materials.forEach(r=>{typeof r!="string"&&XI(r)}):"material"in i&&typeof i.material!="string"&&XI(i.material)}),Object.values(t.shared.materials).forEach(e=>XI(e))}function tK(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 eK(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 iK(t){let e=t.layers.find(i=>i.type==="light")?.data;if(e?.category==="basic"){let i=Is.defaultData("light","phong"),r=e;Object.assign(r,i),r.visible=!1}}function rK(t){Zd(t,iK),Qd(t,iK)}function sK(t){t.layers.forEach(e=>{e.type==="light"&&e.category!=="toon"&&e.occlusion===void 0&&(e.occlusion=!0)})}function nK(t){t.layers&&t.layers.forEach(e=>{e.type==="light"&&e.bumpMapIntensity===void 0&&(e.bumpMapIntensity=5)})}var z3t=U(()=>{yT(),qo(),JG(),hD(),Li(),uD(),dn(),ot(),KG(),rW(),Zft(),tW(),YG(),QG()});function egt(t){let e=t.elements;Fh.set(e[0],e[1],e[2]),Uh.set(e[4],e[5],e[6]),Bu.set(e[8],e[9],e[10])}function igt(){let t=Math.max(Fh.lengthSq(),Uh.lengthSq(),Bu.lengthSq());Fh.lengthSq()>o2*t?fl.copy(Fh).normalize():fl.set(1,0,0),gl.crossVectors(Bu,fl),gl.lengthSq()<=o2*t&&(gl.copy(Uh).addScaledVector(fl,-Uh.dot(fl)),gl.lengthSq()<=o2*t&&function(e,i){e.set(1,0,0).cross(i),e.lengthSq()<=o2&&e.set(0,1,0).cross(i),e.normalize()}(gl,fl)),gl.normalize(),Dg.crossVectors(fl,gl)}function rgt(t,e,i){return egt(t),igt(),e.makeBasis(fl,gl,Dg),i.set(fl.dot(Fh),fl.dot(Uh),fl.dot(Bu),0,gl.dot(Fh),gl.dot(Uh),gl.dot(Bu),0,Dg.dot(Fh),Dg.dot(Uh),Dg.dot(Bu),0,0,0,0,1),function(){let r=Fh.length(),s=Uh.length(),n=Bu.length(),a=Math.max(r,s,n);if(a-r>l2||a-s>l2||a-n>l2)return!0;let o=l2*a*a;return Math.abs(Fh.dot(Uh))>o||Math.abs(Fh.dot(Bu))>o||Math.abs(Uh.dot(Bu))>o}()}function sgt(t){return egt(t),igt(),ngt.makeBasis(fl,gl,Dg)}var Fh,Uh,Bu,fl,gl,Dg,ngt,o2,l2,dD=U(()=>{ot(),Fh=new E,Uh=new E,Bu=new E,fl=new E,gl=new E,Dg=new E,ngt=new bt,o2=1e-12,l2=.01});function W0(t,e){return e===0?0:t/e}function sW(t){rgt(t,tj,JU),J1.setFromRotationMatrix(tj);let e=function(r,s,n){let a=2*Math.PI,o=d=>d-a*Math.round(d/a),l=o(r+Math.PI),h=o(Math.PI-s),u=o(n+Math.PI);return Math.abs(l)+Math.abs(u)<Math.abs(r)+Math.abs(n)-1e-9?[l,h,u]:[r,s,n]}(J1.x,J1.y,J1.z),i=JU.elements;return{position:[t.elements[12],t.elements[13],t.elements[14]],rotation:[e[0]*zt.RAD2DEG,e[1]*zt.RAD2DEG,e[2]*zt.RAD2DEG],scale:[i[0],i[5],i[10]],shear:[W0(i[4],i[5]),W0(i[8],i[10]),W0(i[1],i[0]),W0(i[9],i[10]),W0(i[2],i[0]),W0(i[6],i[5])]}}function _c(t,{translation:e,quaternion:i,scale:r,shearMatrix:s}={}){let n=sW(t);if(e!==void 0&&e.fromArray(n.position),i!==void 0){let a=n.rotation;i.setFromEuler(J1.set(a[0]*zt.DEG2RAD,a[1]*zt.DEG2RAD,a[2]*zt.DEG2RAD))}r!==void 0&&r.fromArray(n.scale),s!==void 0&&s.fromArray(_l.toMatrix(n.shear))}var JU,tj,J1,vT=U(()=>{ot(),dD(),zgt(),JU=new bt,tj=new bt,J1=new zi});function agt(t){return t.length>=4&&function(e){return typeof e=="object"&&e!==null&&e.v===1&&e.data instanceof Float32Array&&Array.isArray(e.tracks)}(t[3])}function ogt(t,e,i){let r={name:e,duration:i.duration,tracks:[],uuid:t};return i.blendMode!==void 0&&(r.blendMode=i.blendMode),JSON.stringify(r)}function L3t(t,e,i){for(let r=0;r<i.length;r++)if(!Object.is(t[e+r],i[r]))return!1;return!0}function F3t(t){if(!Array.isArray(t)||t.length>3)return t;let e,[i,r,s]=t;if(typeof i!="string"||typeof s!="string")return t;try{e=JSON.parse(s)}catch{return t}return e&&Array.isArray(e.tracks)&&!e.tracks.some(n=>!n?.type||!n.times||!n.values)?function(n,a,o){let l=[],h=0,u=g=>{let y=[h,g.length];return l.push(g),h+=g.length,y},d=new Map,c=o.tracks.map(g=>{let y=(_=>{let x=Float32Array.from(_),S=x.length+":"+x[0]+":"+x[x.length-1],w=d.get(S)??[];for(let C of w)if(L3t(C.run,0,x))return C.span;let T=u(x);return w.push({span:T,run:x}),d.set(S,w),T})(g.times),v=!lgt.has(g.type),b={name:g.name,type:g.type,times:y,values:v?u(Float32Array.from(g.values)):[0,0]};return v||(b.list=Array.from(g.values)),g.interpolation!==void 0&&(b.interpolation=g.interpolation),b}),p=new Float32Array(h),m=0;for(let g of l)p.set(g,m),m+=g.length;let f={v:1,duration:o.duration,data:p,tracks:c};return o.blendMode!==void 0&&(f.blendMode=o.blendMode),o.userData!==void 0&&o.userData!=="{}"&&(f.userData=o.userData),[n,a,ogt(n,a,f),f]}(i,typeof e.name=="string"?e.name:r,e):t}function U3t(t,e,i){return t.map(r=>{let s=e();return i[r[0]]=s,function(n,a){let[o,l,h]=n;if(agt(n))return[a,l,ogt(a,l,n[3]),n[3]];let u=h.indexOf(o);return[a,l,u!==-1?h.slice(0,u)+a+h.slice(u+o.length):h,...n.slice(3)]}(r,s)})}var lgt,hgt=U(()=>{lgt=new Set(["bool","string"])});function jM(t,[e,i]){return Math.min(Math.max(t,e),i)}function ugt(t,e,i,r,s){t=jM(t,fgt),e=jM(e,ggt),i=jM(i,ygt),r=jM(r,vgt);let n=Math.sqrt(e/t),a=i/(2*Math.sqrt(e*t)),o=a<1?n*Math.sqrt(1-a*a):0,l=a<1?(a*n-r)/o:-r+n;return h=>{let u=s!==void 0?s*h:h;return u=a<1?Math.exp(-u*a*n)*(1*Math.cos(o*u)+l*Math.sin(o*u)):(1+l*u)*Math.exp(-u*n),h===0||h===1?h:1-u}}function dgt(t,e){return ei(ei(1-ei(3*e))+ei(3*t))}function cgt(t,e){return ei(ei(3*e)-ei(6*t))}function pgt(t){return ei(3*t)}function GM(t,e,i){return ei(ei(ei(ei(ei(dgt(e,i)*t)+cgt(e,i))*t)+pgt(e))*t)}function aK(t,e,i){let r=ei(ei(ei(3*dgt(e,i))*t)*t),s=ei(ei(2*cgt(e,i))*t);return ei(ei(r+s)+pgt(e))}function q0(t,e,i,r){if(t=ei(t),e=ei(e),i=ei(i),r=ei(r),t<0||t>1||i<0||i>1||t===e&&i===r)return Sgt;let s=new Float32Array(sR);for(let n=0;n<sR;n++)s[n]=GM(ei(n*h2),t,i);return n=>(n=ei(n))===0||n===1?n:GM((a=>{let o=0,l=1,h=sR-1;for(;l!==h&&s[l]<=a;)o=ei(o+h2),l+=1;l-=1;let u=ei(ei(a-s[l])/ei(s[l+1]-s[l])),d=ei(o+ei(u*h2)),c=aK(d,t,i);return c>=_gt?function(p,m,f,g){for(let y=0;y<bgt;y++){let v=aK(m,f,g);if(v===0)return m;let b=ei(GM(m,f,g)-p);m=ei(m-ei(b/v))}return m}(a,d,t,i):c===0?d:function(p,m,f,g,y){let v,b=0,_=0;do b=ei(m+ei(ei(f-m)/2)),v=ei(GM(b,g,y)-p),v>0?f=b:m=b,_+=1;while(Math.abs(v)>xgt&&_<wgt);return b}(a,o,ei(o+h2),t,i)})(n),e,r)}function mgt(t,e,i){switch(t.easing){case 0:default:return i;case 1:return q0(.25,.1,.25,1)(i);case 2:return q0(.42,0,1,1)(i);case 3:return q0(0,0,.58,1)(i);case 4:return q0(.42,0,.58,1)(i);case 7:return q0(.25,1,.5,1)(i);case 8:return Math.floor(i);case 5:{let{control1:r,control2:s}=t;return r&&s?q0(r[0],r[1],s[0],s[1])(i):i}case 6:{let{mass:r,stiffness:s,damping:n,velocity:a}=t;return r===void 0||s===void 0||n===void 0||a===void 0?i:ei(ugt(r,s,n,a,e)(i))}}}var ei,fgt,ggt,ygt,vgt,bgt,_gt,xgt,wgt,sR,h2,Sgt,oK,j3t=U(()=>{ei=Math.fround,fgt=[.01,100],ggt=[.01,1e4],ygt=[.01,1e3],vgt=[.01,1e3],bgt=4,_gt=ei(.001),xgt=ei(1e-7),wgt=10,h2=ei(1/((sR=11)-1)),Sgt=t=>t,oK=ei(1.70158),ei(oK+1)});function Tgt(t,e){if(t.length===0)throw new Error("sampleKeyframes requires at least one keyframe");if(e<=t[0].time)return{index0:0,index1:0,t:1};let{found:i,index:r}=function(h,u){let d=h.length,c=0,p=d;for(;c<p;){let m=c+Math.floor(d/2),f=h[m].time;if(f<u)c=m+1;else{if(!(f>u))return{found:!0,index:m};p=m}d=p-c}return{found:!1,index:c}}(t,e);if(i)return{index0:r,index1:r,t:1};if(r>=t.length){let h=t.length-1;return{index0:h,index1:h,t:1}}let s=r-1,n=r,a=t[s].time,o=t[n].time;if(o===a)return{index0:s,index1:n,t:.5};let l=nR(o-a);return{index0:s,index1:n,t:mgt({...t[s].ease,control2:t[n].ease.control2},l,nR(nR(e-a)/l))}}function Mgt(t){return[...t].sort((e,i)=>e.time-i.time)}var nR,G3t=U(()=>{j3t(),nR=Math.fround});function W3t(t){if(t?.length!==2)return;let e=`${t[0]}.${t[1]}`;return nW.includes(e)?e:void 0}function Agt(t){return t.slice(0,t.indexOf("."))}function Cgt(t){return ym.indexOf(t.slice(-1))}function q3t(t){return{easing:t?.type,control1:Cc(t?.cubicControls?.control1,[0,0]),control2:Cc(t?.cubicControls?.control2,[1,1]),...t?.springParameters}}function H3t(t){let e=t?.cubicControls;return{...t,cubicControls:{control1:[...e?.control1??[0,0]],control2:[...e?.control2??[1,1]]},...t?.springParameters?{springParameters:{...t.springParameters}}:{}}}function lK(t,e,i){let r=Agt(t);if(r==="position"){let s=Cgt(t);return ym.flatMap((n,a)=>Math.abs(e.elements[4*a+s])>1e-9?[`position.${n}`]:[])}return(i?[r]:["rotation","scale"]).flatMap(s=>ym.map(n=>`${s}.${n}`))}function $3t(t,e){let[i,r,s]=t,n=[[i,r,s],[i+180,180-r,s+180]],a=[i,r,s],o=1/0;for(let l of n){let h=l.map((d,c)=>d+360*Math.round((e[c]-d)/360)),u=h.reduce((d,c,p)=>d+Math.abs(c-e[p]),0);u<o-1e-9&&(a=h,o=u)}return a}function X3t(t,e,i){if(t==="rotation"){let r=((e-i)%360+540)%360-180;return Math.abs(r)<1e-6}return Math.abs(e-i)<1e-9*Math.max(1,Math.abs(e),Math.abs(i))}function Y3t(t,e,i,r){let s=new Map;for(let{id:p,data:m}of t.unproxy()){if(m.isPlaceholder)continue;let f=W3t(m.path);if(!f){if(u2.includes(m.path?.[0]))return;continue}if(typeof m.value!="number"||!Number.isFinite(m.value))return;let g=s.get(f)??{keys:[],sampled:[]};g.keys.push({id:p,time:m.time,value:m.value,keyframe:m}),s.set(f,g)}if(s.size===0)return;for(let p of s.values())p.keys.sort((m,f)=>m.time-f.time),p.sampled=Mgt(p.keys.map(m=>({time:m.time,ease:q3t(m.keyframe.easing),value:m.value})));let n=(p,m)=>{let f=s.get(p);return f?function(g,y){let{index0:v,index1:b,t:_}=Tgt(g.sampled,y),x=g.sampled[v].value;return x+(g.sampled[b].value-x)*_}(f,m):i[Agt(p)][Cgt(p)]},a=new we,o=new zi,l=new bt,h=new E,u=new E,d=p=>{let m=(f=>{let g={};for(let y of u2)g[y]=ym.map((v,b)=>n(nW[3*u2.indexOf(y)+b],f));return g})(p);return o.set(m.rotation[0]*zt.DEG2RAD,m.rotation[1]*zt.DEG2RAD,m.rotation[2]*zt.DEG2RAD),l.compose(h.fromArray(m.position),a.setFromEuler(o),u.fromArray(m.scale)).premultiply(e),{pose:m,out:sW(l)}},c=function(p){let m=p.elements,f=[0,4,8].map(v=>new E(m[v],m[v+1],m[v+2])),g=f[0].lengthSq(),y=1e-9*Math.max(1,g);return Math.abs(f[1].lengthSq()-g)<y&&Math.abs(f[2].lengthSq()-g)<y&&Math.abs(f[0].dot(f[1]))<y&&Math.abs(f[0].dot(f[2]))<y&&Math.abs(f[1].dot(f[2]))<y}(e);for(let p of u2){let m,f=ym.map(b=>`${p}.${b}`),g=b=>{let _=new Set;for(let x of lK(b,e,c))for(let S of s.get(x)?.keys??[])_.add(S.time);return[..._].sort((x,S)=>x-S)},y=[...new Set(f.flatMap(b=>g(b)))].sort((b,_)=>b-_),v=new Map;for(let b of y){let{pose:_,out:x}=d(b),S=[...x[p]];p==="rotation"&&(S=$3t(S,m?m.out.map((w,T)=>w+_.rotation[T]-m.in[T]):_.rotation),m={in:_.rotation,out:S}),v.set(b,S)}f.forEach((b,_)=>{let x=s.get(b)?.keys??[],S=g(b),w=new Set(S);if(x.length!==0||!S.every(T=>X3t(p,v.get(T)[_],r[p][_]))){for(let T of x)w.has(T.time)||t.delete(T.id);for(let T of S){let C=v.get(T)[_],M=x.find(O=>O.time===T);if(M){let O=t.data(M.id);O&&(O.value=C);continue}let A=lK(b,e,c).sort((O,D)=>Number(D===b)-Number(O===b)).map(O=>s.get(O)?.keys.find(D=>D.time===T)).find(O=>O!==void 0),P=zt.generateUUID();t.insertBefore(null,[{id:P,data:{id:P,time:T,path:[p,ym[_]],value:C,easing:H3t(A.keyframe.easing),index:gm.rowOrder([p])}}])}}})}}var u2,ym,nW,K3t=U(()=>{ot(),iW(),G3t(),vT(),ym=["x","y","z"],nW=(u2=["position","rotation","scale"]).flatMap(t=>ym.map(e=>`${t}.${e}`))}),Egt={};function hK(t){t.layers&&t.layers.forEach(e=>{e.type==="light"&&e.alphaOverride===void 0&&(e.alphaOverride=1)})}function Pgt(t){let e=t.geometry;e!==void 0&&Bgt.has(e.type)&&e.extrusionVersion===void 0&&(e.extrusionVersion=1)}function Rgt(t){if(t.type!=="Empty")return;let e=Os(t.animations);if(!Array.isArray(e))return;let i=e.map(F3t);i.some((r,s)=>r!==e[s])&&(t.animations=i)}function uK(t,e){let[i,r,s]=t,n=Math.cos(i),a=Math.sin(i),o=Math.cos(r),l=Math.sin(r),h=Math.cos(s),u=Math.sin(s),d=[o*h,n*u+a*h*l,a*u-n*h*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 Dgt(t){(function(i){i.rotation=i.rotation.slice(0,3).map(r=>r*Np)})(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(h=>typeof h=="number"&&Number.isFinite(h))?n:[0,1,0],o=uK(s,a),l=uK(s.map(h=>h*kgt),a);return Math.abs(o-l)<1e-6?s.some(h=>Math.abs(h)>Math.PI):l<o})(r,i.up)?i.rotation=r:i.rotation=r.map(s=>s*Np)}(t.camera),t.states?.forEach(i=>{i.rotation===void 0||i.rotation===null||(i.rotation=i.rotation.slice(0,3).map(r=>r*Np))});let e=t.geometry;e&&e.type==="SphereGeometry"&&(e.thetaLength=(e.thetaLength??180)*Np),e&&e.type==="TorusGeometry"&&(e.arc=e.arc*Np),e&&e.type==="PathGeometry"&&(e.extrusion.angle*=Np,e.extrusion.twist*=Np),t.type==="Mesh"&&t.geometry.type==="TextGeometry"&&(t.geometry.text={textValue:t.geometry.text}),Array.isArray(Os(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 Z3t(t){t.scene.objects.traverse((e,i)=>{})}function Q3t(t){let e=t.schema??104;e!==136&&(e<130&&(aW(t.asset),t.schema=130),e<135&&(oW(t.asset),t.schema=135),e<136&&(lW(t.asset),t.schema=136))}function Vh(t,e){e(t.data);for(let i of t.children)Vh(i,e)}function Ogt(t){let e=t.schema??104;e!==136&&(e<105&&(Vh(t.asset,Dgt),t.schema=105),e<118&&(Vh(t.asset,Igt),t.schema=118),e<121&&(Vh(t.asset,ij),t.schema=121),e<130&&(Vh(t.asset,i=>YI(i,aW)),t.schema=130),e<132&&(Vh(t.asset,Pgt),t.schema=132),e<133&&(Vh(t.asset,i=>Ngt(i,()=>{})),t.schema=133),e<134&&(Vh(t.asset,Rgt),t.schema=134),e<135&&(Vh(t.asset,i=>YI(i,oW)),t.schema=135),e<136&&(Vh(t.asset,i=>YI(i,lW)),t.schema=136))}function aR(t,e){Qd(t,e),Zd(t,e),Object.values(t.shared.lib.materials).forEach(i=>e(i.asset))}function aW(t){t.layers===void 0&&Object.assign(t,Qr.defaultTwoLayerData("phong"))}function oW(t){let e=Q1(t),i=Qr.withRepairedLayers(e);i!==e&&(t.layers=i.layers)}function lW(t){let e=Q1(t),{material:i,restored:r}=Qr.restoreLayersSeq(e);r&&(t.layers=i.layers)}function YI(t,e){"materials"in t?t.materials.forEach(i=>{i!==void 0&&typeof i!="string"&&e(i)}):"material"in t&&t.material!==void 0&&typeof t.material!="string"&&e(t.material)}function Igt(t){t.timelineAnimations=qa({},Ne.prototype)}function J3t(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(gm.placeholderKeyframe(i.id,s,{layerId:a,index:r}))}),e.sort((i,r)=>i.data.time-r.data.time),new ue(...e.map((i,r)=>({...i,fi:r})))):new ue}function tCt(t){for(let{id:e,data:i}of[...t.unproxy()]){let r=i.path?.[0];if(!r||!Vgt.includes(r))continue;let s=ej(i.value);if(!s.length)continue;let n=t.data(e);if(!n)continue;let a=i.value,[o,...l]=s;for(let h of l){let u=zt.generateUUID();t.insertBefore(null,[{id:u,data:{...i,id:u,path:[r,h],value:a[h],easing:eCt(i.easing)}}])}n.path=[r,o],n.value=a[o]}}function ej(t){return t===null||typeof t!="object"?[]:YS.filter(e=>e in t)}function eCt(t){let e=t?.cubicControls;return{...t,cubicControls:{control1:[...e?.control1??[0,0]],control2:[...e?.control2??[1,1]]},...t?.springParameters?{springParameters:{...t.springParameters}}:{}}}function iCt(t,e){return Math.abs(t[0]-e[0])<1e-6&&Math.abs(t[1]-e[1])<1e-6}function rCt(t){let e=function(n){let a=[];for(let o of gm.groupKeyframes(n)){let l=new Set(o.keyframes.flatMap(u=>ej(u.data.value))),h=l.size?[...l].map(u=>o.keyframes.filter(d=>ej(d.data.value).includes(u))):[o.keyframes];for(let u of h){let d=[...u].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:gm.presetHandles(o))?.control2??(o===5?Cc(a.data.easing?.cubicControls?.control2,[1,1]):void 0);if(!l)continue;let h=i.get(a.id);h?iCt(h,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:gm.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:Cc(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:Cc(o.easing.cubicControls?.control1,[0,0]),control2:l})}}function dK(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 ij(t){t.pivot=[0,0,0],t.pivotRotation=[0,0,0]}function Ngt(t,e,i=[]){let r=["position","rotation","scale","shear"];function s(c,p,m){return c?.map(f=>typeof f=="string"?e(f)??m:f)??[...p]}function n(c,p){if(c&&!function(m){return m.every((f,g)=>Math.abs(f-(g%5==0?1:0))<1e-6)}(c))return sW(new bt().fromArray(c).multiply(new bt().compose(new E().fromArray(p.position),new we().setFromEuler(new zi(p.rotation[0]*zt.DEG2RAD,p.rotation[1]*zt.DEG2RAD,p.rotation[2]*zt.DEG2RAD)),new E().fromArray(p.scale))))}function a(c,p){return c.length===p.length&&c.every((m,f)=>m===p[f])}t.shear=_l.zero;let o=t,l=o.hiddenMatrix;l!==void 0&&delete o.hiddenMatrix;let h={position:s(o.position,[0,0,0],0),rotation:s(o.rotation,[0,0,0],0),scale:s(o.scale,[1,1,1],1)},u=n(l,h);if(u&&Object.assign(o,u),u){let c=new bt().fromArray(l);for(let p of i)Y3t(p,c,h,u)}let d=u??{...h,shear:[..._l.zero]};o.states?.forEach(c=>{let p=c.hiddenMatrix;if(p!==void 0&&delete c.hiddenMatrix,p===void 0&&c.position==null&&c.rotation==null&&c.scale==null)return;let m={position:s(c.position,h.position,0),rotation:s(c.rotation,h.rotation,0),scale:s(c.scale,h.scale,1)},f=n(p??l,m);if(!u&&!f)return;let g=f??{...m,shear:[..._l.zero]};for(let y of r)(c[y]!=null||!a(g[y],d[y]))&&(c[y]=g[y])})}function sCt(t){}function nCt(t){let e=t.schema??0;if(e!==136){if(e>136)return void console.error(`This scene was created with a newer version of Spline (file format ${e}, this runtime reads 136). Update @splinetool/runtime to the latest version to load it correctly.`);console.warn("updating from ",e,"to ",136),function(i,r){if(r<1&&(Qd(i,ZY),Zd(i,ZY),i.schema=1),r<2&&(function(s){Object.assign(s.scene.publish,{orbitControls:{...Y4.defaultData,...Os(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,h]of Object.entries(o))if((lD.includes(l)||typeof h=="boolean")&&delete o[l],l==="texture")for(let[u,d]of Object.entries(h))($G.includes(u)||typeof d=="boolean")&&delete h[u]}}}s.scene.objects.traverse((a,o)=>{o.states.forEach(l=>{let h=l;h.material?n(h.material):h.materials&&h.materials.forEach(u=>{n(u)})})})}(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&&(JY(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&&(JY(i),i.schema=12),r<13&&(function(s){s.shared.audios=qa({},Ne.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(Os(s.shared.images)).filter(n=>n[1].asset===!1).map(n=>n[0]).forEach(n=>{delete s.shared.images[n]}),Object.entries(Os(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&&(Qd(i,tK),Zd(i,tK),i.schema=17),r<18&&(Qd(i,QY),Zd(i,QY),i.schema=18),r<19&&(function(s){Object.assign(s.scene.publish.settings,{video:{...bc.defaultData.settings.video,...Os(s.scene.publish.settings.video)}})}(i),i.schema=19),r<20&&(function(s){s.shared.fonts=qa({},Ne.prototype)}(i),function(s){let n=[];s.scene.objects.traverse((a,o)=>{let l=o;if(l.type==="TextFrame"){let h=Qr.defaultTwoLayerData("phong"),u=typeof l.color=="string"?s.shared.colors[l.color]:l.color;h.layers[1].data.color={r:u.r,g:u.g,b:u.b},h.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,...an.defaultData,...Iu.defaultData,flatShading:!1,wireframe:!1,geometry:{...hc.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:h,states:Os(l.states),events:Os(l.events),visible:l.visible,raycastLock:l.raycastLock,position:l.position,rotation:l.rotation,scale:l.scale,hiddenMatrix:l.hiddenMatrix},p=Os(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 ue,move:new ue,jump:new ue}});else{let h=new ue;Object.assign(l,{actions:h}),(l.type==="MouseDown"||l.type==="MouseUp"||l.type==="KeyDown"||l.type==="KeyUp")&&"url"in l&&h.push({fi:0,id:zt.generateUUID(),data:{type:"Link",url:l.url,delay:0}}),"targets"in l&&(l.targets.forEach((u,d,c)=>{let p={easing:u.easing,duration:u.duration};u.easing===6?Object.assign(p,dg(u,"mass","stiffness","damping","velocity")):u.easing===5&&Object.assign(p,{control1:{...u.control1},control2:{...u.control2}});let m={repeat:u.repeat?-1:0,delay:u.delay,delayDirection:u.delayDirection,direction:u.cycle&&u.rewind?"pingpong-rewind":u.cycle?"pingpong":"normal"},f={state:u.state,...m,...p},g={allowSlerp:!0,type:"Transition",object:u.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new ue({fi:0,id:zt.generateUUID(),data:{state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4}},{fi:1,id:zt.generateUUID(),data:f})};h.push({fi:c,id:d,data:g})}),delete l.targets)}})})}(i),function(s){s.scene.objects.traverse((n,a)=>{function o(l,h){let u=new ue,d=[];if(a.events.forEach((c,p,m)=>{if(c.type==="Audio"&&c.trigger===h){let f;d.push(p),c.interaction==="play"?f={...dg(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={...dg(c,"interaction","delay","object","playAudio"),type:"Audio"}),f&&u.push({fi:m,id:p,data:f})}}),d.forEach(c=>a.events.delete(c)),u.length){let c=a.events.find(p=>p.type===l)?.data;c?"actions"in c&&c.actions.insertBefore(null,u):a.events.insertBefore(null,[{id:zt.generateUUID(),data:{type:l,actions:u}}])}}o("Start","start"),o("MouseDown","mouseDown"),o("MouseUp","mouseUp"),o("KeyDown","keyDown"),o("KeyUp","keyUp")})}(i),i.schema=21),r<22&&(rK(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=qa({},Ne.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=Os(s.scene.objects.data(o));l&&l.type==="Mesh"&&l.geometry.type==="BooleanGeometry"&&a.type==="Mesh"&&(a.visible=Os(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&&(rK(i),i.schema=28),r<29&&(function(s){function n(o){Object.setPrototypeOf(o,Cs.prototype),o.texture&&Object.setPrototypeOf(o.texture,Cs.prototype)}function a(o){Object.setPrototypeOf(o,Cs.prototype);for(let l in o)n(o[l])}s.scene.objects.traverse((o,l)=>{l.states.forEach(h=>{let u=h;if(u.material){let d=Os(u.material).layers;a(d),u.material.layers=d}if(u.materials)for(let d=0;d<u.materials.length;d++){let c=u.materials[d],p=Os(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=Qr.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&&(Qd(i,eK),Zd(i,eK),i.schema=38),r<39&&(function(s){s.scene.objects.traverse((n,a)=>{a.events.forEach(o=>{o.type==="GameControl"&&(o.navmesh=Z4.defaultDataThirdPerson.navmesh)})})}(i),i.schema=39),r<40&&(function(s){s.scene.styles||(s.scene.styles=Pg.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}),Qd(s,sK),Zd(s,sK)}(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 ue})})})}(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){Qd(i,nK),Zd(i,nK),i.scene.publish.playCamera===null&&(i.scene.publish.playCamera=l0);let s=Os(i.scene.objects),n=i.scene.objects;i.scene.publish.playPage=mv,n.insertBefore(null,null,[{id:mv,data:{...Hg.defaultData,backgroundColor:i.scene.backgroundColor,fog:i.scene.fog,postprocessing:i.scene.postprocessing,ao:dg(i.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:i.scene.publish.playCamera,gameControlObject:i.scene.publish.gameControlObject},shadow:dg(i.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...yv.defaultData,...dg(i.scene.environment,"usePhysics","gravity")},camera:Os(i.scene.ownerCamera)??Hg.defaultData.camera,name:"Scene"},children:[]}]);for(let l of s)l.id!==Rg.TRASH_CAN_ID&&n.move(mv,l.fi,l.id);let a=0,o=0;i.shared.penumbraSize&&i.scene.objects.traverse((l,h)=>{h.type==="DirectionalLight"?(h.penumbraSize=i.shared.penumbraSize[Math.min(a,2)],a+=1):h.type==="SpotLight"&&(h.penumbraSize=i.shared.penumbraSize[3+Math.min(o,1)],o+=1),(h.physics===void 0||h.physics===null)&&h.type!=="Instance"&&(h.physics={},Object.assign(h.physics,fv.defaultData)),h.physics!==void 0&&h.physics!==null&&(h.physics.enabled=h.collision??"visibility",delete h.collision)}),i.schema=99}}(t,e),e<100&&(t.scene.publish.joystickSizeAndXYOffset===void 0&&(t.scene.publish.joystickSizeAndXYOffset=bc.defaultData.joystickSizeAndXYOffset),t.schema=100),e<101&&(Qd(t,hK),Zd(t,hK),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 Ne,t.shared.lib=uc.defaultData(),t.schema=104),e<105&&(function(i){i.shared.variables=qa({},Ne.prototype)}(t),t.scene.objects.traverse((i,r)=>{Dgt(r)}),t.schema=105);for(let i of Object.values(t.shared.lib.components))Ogt(i);if(e<106&&(function(i){let r=Os(i.shared.variables);i.shared.variables=qa(Object.entries(r??{}).map(([s,n],a)=>({fi:a,id:s,data:n})),ue.prototype)}(t),t.schema=106),e<107&&(t.shared.lib.variables=uc.defaultData().variables,t.schema=107),e<109&&(function(i){i.shared.particles=qa({},Ne.prototype),i.shared.lib&&(i.shared.lib.particles=uc.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(Os(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(Os(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=qa({},Ne.prototype),i.shared.userWebhooks=qa({},Ne.prototype),i.shared.lib&&(i.shared.lib.userAPIs=uc.defaultData().userAPIs,i.shared.lib.userWebhooks=uc.defaultData().userWebhooks)}(t),t.schema=115),e<116&&(function(i){i.scene.publish.settings.videoStatic===void 0&&(i.scene.publish.settings.videoStatic=bc.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=qa({},Ne.prototype),t.scene.objects.traverse((i,r)=>{Igt(r)}),t.schema=118),e<119&&(t.scene.publish.settings.videoStatic.format=vv.defaultData.scene.publish.settings.videoStatic.format,t.scene.publish.settings.videoStatic.imageFormat=vv.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)=>{ij(r),r.type==="Page"&&r.camera!==void 0&&ij(r.camera)}),t.schema=121),e<122&&(delete t.scene.publish.settings.video,t.scene.publish.orbitControls.rotationSpeed=vv.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=Kp.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=Kp.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=Kp.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={...Kp.defaultData.hdri}:(s.hdri.blur===void 0&&(s.hdri.blur=Kp.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=Hg.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&&(aR(t,aW),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,h)=>{(l.isAnimation||a?.[h])&&o.push(h)}),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 h=qa({},Ne.prototype),u=0,d=Boolean(l.loop);for(let[m,f]of Object.entries(l.mapping??{})){let g=n.data(m)?.timelineAnimations?.[f];!g||(u=Math.max(u,g.to??0),d=d||Boolean(g.loop),h[m]={id:m,keyframes:J3t(g.properties?.unproxy())})}let c=l.page??a,p=c?n.data(c):void 0;p&&p.type==="Page"&&((p.timelines??(p.timelines=qa({},Ne.prototype)))[o]={id:o,name:l.name,duration:u||5,...d?{loop:d}:{},objectTimelines:h})}delete r.timelineAnimations,n.traverse((o,l)=>{delete l.timelineAnimations})}(t),dK(t,tCt),dK(t,rCt),t.schema=131),e<132&&(t.scene.objects.traverse((i,r)=>Pgt(r)),t.schema=132),e<133){let i=function(s){return n=>s.get(n)?.data?.value}(t.shared.variables),r=new Map;t.scene.objects.traverse((s,n)=>{let a=n;if(a.type==="Page"&&a.timelines)for(let o of Object.values(a.timelines))for(let[l,h]of Object.entries(o.objectTimelines??{})){let u=r.get(l)??[];u.push(h.keyframes),r.set(l,u)}}),t.scene.objects.traverse((s,n)=>Ngt(n,i,r.get(s))),t.schema=133}e<134&&(t.scene.objects.traverse((i,r)=>Rgt(r)),t.schema=134),e<135&&(aR(t,oW),t.schema=135),e<136&&(aR(t,lW),t.schema=136)}}pT(Egt,{updateAllMaterials:()=>aR,updateDocumentSchema:()=>nCt,updateLibSchema:()=>sCt,updateMaterialSchema:()=>Q3t,updateObjectStateRec:()=>Vh,updateObjectsSchema:()=>Ogt,updateTextValues:()=>Z3t});var Bgt,Np,kgt,Vgt,cK,WM,KI,pK,qM,Og,g_,H0,HM,ZI,oR,QI,JI,mK,lR,tN,$g,rj,cD=U(()=>{ot(),Jft(),Li(),iW(),z3t(),uD(),yT(),qo(),dn(),eW(),hD(),ZG(),vT(),hgt(),K3t(),Bgt=new Set(["RectangleGeometry","EllipseGeometry","StarGeometry","PolygonGeometry","TriangleGeometry","VectorGeometry","TextGeometry","InputGeometry","PathGeometry"]),Np=180/Math.PI,kgt=Math.PI/180,Vgt=["position","rotation","scale","shape size"]}),aCt=U(()=>{var t,e,i;qo(),Li(),dn(),(cK||(cK={})).is=function(r){return!0},(t=WM||(WM={})).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 fft({position:Gu.isEqual(r.position,s.position)?void 0:s.position,rotation:r.rotation===s.rotation?void 0:s.rotation,scale:Gu.isEqual(r.scale,s.scale)?void 0:s.scale,shear:r.shear&&s.shear&&Gu.isEqual(r.shear,s.shear)?void 0:s.shear})},(KI||(KI={})).defaultData={horizontalConstraint:0,verticalConstraint:0},(pK||(pK={})).defaultData={direction:"row",wrap:"unwrap",align:"top-left",gap:10,rowGap:10,autoGap:!1,autoRowGap:!1,leftPadding:8,rightPadding:8,topPadding:8,bottomPadding:8},(qM||(qM={})).defaultData={opacity:1,fill:{color:qi.fromHexAndA(i0,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=Og||(Og={})).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,WM.merge(n,s)),n=function(a,o){if(o===void 0)return a;let l={...a},h=["width","height","cornerRadius"];for(let u of h)u in l&&u in o&&o[u]!==void 0&&Object.assign(l,{[u]:o[u]});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},(g_||(g_={})).defaultData={...WM.defaultData,...KI.defaultData,states:new ue,events:new ue,visible:!0,raycastLock:!1},(H0||(H0={})).defaultData={...g_.defaultData,...qM.defaultData},(HM||(HM={})).defaultData={cornerRadius:[0,0,0,0]},(ZI||(ZI={})).defaultData={...H0.defaultData,type:"ellipse2d",width:100,height:100,name:"Ellipse"},(oR||(oR={})).defaultData={...H0.defaultData,...HM.defaultData,type:"rectangle2d",width:100,height:100,name:"Rectangle"},(QI||(QI={})).defaultData={...H0.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"},(JI||(JI={})).defaultData={...H0.defaultData,type:"path2d",path:"",name:"Path"},(mK||(mK={})).is=function(r){return r.type==="ellipse2d"||r.type==="rectangle2d"||r.type==="text2d"||r.type==="vector2d"||r.type==="path2d"},(lR||(lR={})).defaultData={...g_.defaultData,name:"Group",type:"group2d"},(tN||(tN={})).defaultData=()=>({...g_.defaultData,...HM.defaultData,...qM.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{...oR.defaultData};case"ellipse2d":return{...ZI.defaultData};case"text2d":return{...QI.defaultData};case"path2d":return{...JI.defaultData};case"frame2d":return{...tN.defaultData()};case"group2d":return{...lR.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"}})($g||($g={})),(i=rj||(rj={})).defaultData={name:"UI",type:"scene2d",objects:new Nn},i.emptyData=function(){return{type:"scene2d",objects:new Nn}}}),zgt=U(()=>{P3t(),R3t(),zft(),Lft(),Jft(),Bft(),Wft(),qft(),Xft(),ZG(),cD(),Qft(),KG(),YG(),Fft(),yT(),Gft(),Kft(),qo(),uD(),hD(),hgt(),JG(),$ft(),eW(),tW(),O3t(),Hft(),rW(),QG(),Uft(),jft(),aCt()});function Ig(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 fe,h=0;for(let u=0;u<t.length;++u){let d=t[u],c=0;if(i!==(d.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". 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 "+u+'. 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 "+u+". 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 "+u+". .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 "+u+". .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 "+u+". The geometry must have either an index or a position attribute"),null;p=d.attributes.position.count}l.addGroup(h,p,u),h+=p}}if(i){let u=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)+u);u+=t[c].attributes.position.count}l.setIndex(d)}for(let u in n){let d=fK(n[u]);if(!d)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+u+" attribute."),null;l.setAttribute(u,d)}for(let u in a){let d=a[u][0].length;if(d!==0){l.morphAttributes=l.morphAttributes||{},l.morphAttributes[u]=[];for(let c=0;c<d;++c){let p=[];for(let f=0;f<a[u].length;++f)p.push(a[u][f][c]);let m=fK(p);if(!m)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+u+" morphAttribute."),null;l.morphAttributes[u].push(m)}}}return l}function fK(t){let e,i,r,s=-1,n=0;for(let h=0;h<t.length;++h){let u=t[h];if(e===void 0&&(e=u.array.constructor),e!==u.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=u.itemSize),i!==u.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(r===void 0&&(r=u.normalized),r!==u.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(s===-1&&(s=u.gpuType),s!==u.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;n+=u.count*i}let a=new e(n),o=new ve(a,i,r),l=0;for(let h=0;h<t.length;++h){let u=t[h];if(u.isInterleavedBufferAttribute){let d=l/i;for(let c=0,p=u.count;c<p;c++)for(let m=0;m<i;m++){let f=u.getComponent(c,m);o.setComponent(c+d,m,f)}}else a.set(u.array,l);l+=u.count*i}return s!==void 0&&(o.gpuType=s),o}var bT=U(()=>{ot()});function Lgt(t){let e=t.points.length/7,i=new ue;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],h=t.points[s+4],u=t.points[s+5],d=t.points[s+6];i.push({fi:r,id:zt.generateUUID(),data:{roundness:d,position:[n,a],areControlsDirectionsMirrored:!0,controlPrevious:{position:[o,l]},controlNext:{position:[h,u]}}})}return{points:i,isClosed:t.isClosed,roundness:t.roundness,shapeHoles:t.shapeHoles?.map(r=>Lgt(r))??[]}}function Fgt(t){let{userData:e,uuid:i,...r}=t;if(e===void 0||e.type==="NonParametricGeometry")return function(a){let o,{userData:l,data:h}=a,u=h?.groups,d=h?.attributes??{},c=h?.morphAttributes??{},p=h?.interleavedBuffers,m=h?.arrayBuffers,f=h?.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 C=y[T],M=y[T+1],A=y[T+2];v=Math.min(v,C),b=Math.min(b,M),_=Math.min(_,A),x=Math.max(x,C),S=Math.max(S,M),w=Math.max(w,A)}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}),u!==void 0&&Object.assign(g.data,{groups:u.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 h=new fe;if(o?.position===void 0||o?.faceMap===void 0)return null;let u=o.position.array,d=o.faceMap.array,c=r.data.index.array;h.setAttribute("position",new me(u,3)),h.setIndex(new pm(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),C={},M={},A=[],P=["getX","getY","getZ","getW"],O=["setX","setY","setZ","setW"];for(let V=0,q=T.length;V<q;V++){let W=T[V],H=y.attributes[W];C[W]=new H.constructor(new H.array.constructor(H.count*H.itemSize),H.itemSize,H.normalized);let rt=y.morphAttributes[W];rt&&(M[W]||(M[W]=[]),rt.forEach((it,ft)=>{let dt=new it.array.constructor(it.count*it.itemSize);M[W][ft]=new it.constructor(dt,it.itemSize,it.normalized)}))}let D=.5*v,N=Math.log10(1/v),z=Math.pow(10,N),k=D*z;for(let V=0;V<S;V++){let q=_?_.getX(V):V,W="";for(let H=0,rt=T.length;H<rt;H++){let it=T[H],ft=y.getAttribute(it),dt=ft.itemSize;for(let K=0;K<dt;K++)W+=~~(ft[P[K]](q)*z+k)+","}if(W in b)A.push(b[W]);else{for(let H=0,rt=T.length;H<rt;H++){let it=T[H],ft=y.getAttribute(it),dt=y.morphAttributes[it],K=ft.itemSize,lt=C[it],_t=M[it];for(let xt=0;xt<K;xt++){let wt=P[xt],gt=O[xt];if(lt[gt](w,ft[wt](q)),dt)for(let Dt=0,Lt=dt.length;Dt<Lt;Dt++)_t[Dt][gt](w,dt[Dt][wt](q))}}b[W]=w,A.push(w),w++}}let B=y.clone();for(let V in y.attributes){let q=C[V];if(B.setAttribute(V,new q.constructor(q.array.slice(0,w*q.itemSize),q.itemSize,q.normalized)),V in M)for(let W=0;W<M[V].length;W++){let H=M[V][W];B.morphAttributes[V][W]=new H.constructor(H.array.slice(0,w*H.itemSize),H.itemSize,H.normalized)}}return B.setIndex(A),B}(h),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,...oCt(o.positionWASM.array)};l.subdivisions=e.parameters.subdivisions;for(let h in o)h==="positionWASM"?l[h]=new Float32Array(o[h].array):h==="indexWASM"?l[h]=new Int32Array(o[h].array):h==="verticesPerFaceWASM"&&(l[h]=new Int8Array(o[h].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:Lgt(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 oCt(t){return sj.setFromArray(t),sj.getSize(d2),{width:d2.x,height:d2.y,depth:d2.z}}var sj,d2,eN,lCt=U(()=>{Li(),ot(),bT(),new bt,new we,new zi,new E,new E,sj=new dr,d2=new E}),hCt=U(()=>{var t;(t=eN||{}).view="view",t.edit="edit",((eN=t)||(eN={})).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"}}}),Ugt,nj,hR,jgt,Ggt,sb,y_,$M,iN,nb,gK,rN,yK,sN,Gv,Xc,Yc,ud,nN,vK,bK,aN,aj,xc,Wgt=U(()=>{hCt()}),uCt=U(()=>{}),dCt=U(()=>{Li(),cD(),Wgt()}),cCt=U(()=>{yT(),[...lD],new Set($G)}),De=U(()=>{zgt(),uCt(),B3t(),cD(),dCt(),Wgt(),iW(),cCt(),rW(),Li()}),pD=U(()=>{Ugt=[3,4,8,9],nj=5,hR=3,jgt=32,Ggt=.98}),_T=U(()=>{ot(),sb=t=>{var e;return(e=class extends t{}).geometryHelper=new Yh(30,30,30),e}}),xT=U(()=>{ot(),y_=new mc,$M=new Zn,iN=new bt,nb=(t,e,i,r,s=!1,n=t)=>{let a=e,o=n.matrixWorld;if(a.boundingSphere===null&&a.computeBoundingSphere(),$M.copy(a.boundingSphere),$M.applyMatrix4(o),i.ray.intersectsSphere($M)===!1||(iN.copy(o).invert(),y_.copy(i.ray).applyMatrix4(iN),a.boundingBox!==null&&y_.intersectsBox(a.boundingBox)===!1))return;let l,h,u,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(h=m.getX(c),u=m.getX(c+1),d=m.getX(c+2),l=y(t,i,y_,f,h,u,d),l)return l.faceIndex=Math.floor(c/3),void r.push(l)}else{let v=a.attributes.position,b=new E,_=new E,x=new E,S=new E,w=2,T=1/((n.scale.x+n.scale.y+n.scale.z)/3),C=T*T;for(let M=Math.max(0,g.start),A=Math.min(v.count,g.start+g.count)-1;M<A;M+=w){if(b.fromBufferAttribute(v,M),_.fromBufferAttribute(v,M+1),y_.distanceSqToSegment(b,_,S,x)>C)continue;S.applyMatrix4(n.matrixWorld);let P=i.ray.origin.distanceTo(S);P<i.near||P>i.far||r.push({distance:P,point:x.clone().applyMatrix4(n.matrixWorld),object:t})}}function y(v,b,_,x,S,w,T){let C=new E,M=new E,A=new E,P=new E,O=new E;if(C.fromBufferAttribute(x,S),M.fromBufferAttribute(x,w),A.fromBufferAttribute(x,T),_.intersectTriangle(C,M,A,!1,P)===null)return null;O.copy(P),O.applyMatrix4(v.matrixWorld);let D=b.ray.origin.distanceTo(O);return D<b.near||D>b.far?null:{faceIndex:1,distance:D,point:O.clone(),object:v}}}}),mD=U(()=>{ot(),_T(),xT(),gK=new E(1,1,1),rN=new E,yK=new E,sN=new we,Gv=class extends sb(oft){constructor(t,e=15){super(e),this.object=t,this.dummy=new rb,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){nb(this.object,Gv.geometryHelper,t,e,!1,this.dummy)}update(){}updateMatrix(){}updateMatrixWorld(t){this.object.matrixWorld.decompose(rN,sN,yK),this.matrix.compose(rN,sN,gK),super.updateMatrixWorld(t)}updateWorldMatrix(t,e){}}}),pCt=U(()=>{ot(),Xc=new E,Yc=new E,ud=new bt,nN=[new E(-1,1,1),new E(-1,-1,1),new E(1,-1,1),new E(1,1,1),new E(-1,1,-1),new E(-1,-1,-1),new E(1,-1,-1),new E(1,1,-1)],vK=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],bK=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],aN=(t,e,i)=>{t.updateEntityBoxSize(Xc,Yc),ud.copy(e).multiply(t.matrixWorld),Yc.x===0&&Yc.y===0&&Yc.z===0?i.push(new E(Xc.x,Xc.y,Xc.z).applyMatrix4(ud)):nN.forEach(r=>{i.push(r.clone().multiply(Yc).add(Xc).applyMatrix4(ud))})},aj=class extends dr{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 ud.copy(e).multiply(n.matrixWorld),void s.push(new E().applyMatrix4(ud));aN(n,e,r)}}),r.length===0&&r.push(...s)}else aN(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(ud.copy(this.matrix).setPosition(0,0,0)),t}computeVertices(){this.getSize(Yc).multiplyScalar(.5),this.getCenter(Xc),ud.copy(this.matrix).setPosition(Xc),this.vertices=nN.map(t=>t.clone().multiply(Yc).applyMatrix4(ud))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=vK.map(([t,e])=>new vl(this.vertices[t],this.vertices[e])),this.centerEdges=this.edges.map(t=>t.getCenter(new E))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=bK.map(([t,e])=>this.vertices[t].clone().add(this.vertices[e]).multiplyScalar(.5))}}}),Q4=U(()=>{xc={Cloner:null,changeEntityProptotype:()=>{},createEntity:()=>{}}});function uS(t){return t?.isParticleSystem===!0}function n0(t){return t?.isHairSystem===!0}function Dc(t){return t?.isShapeBlendEntity===!0}function fD(t){return t?.isPathObject===!0}function Go(t){return t?.isObject2D===!0}function $a(t){return t?.isUIObject===!0}function nm(t){return t?.isCloner===!0}function am(t){return t?.isClone===!0}function uR(t){return t?.isComponentObject===!0}var Jr=U(()=>{});function Nr(t){hW.add(t)}function On(t,e){let i=`${t}:${e}`;hj.has(i)||hj.add(i)}function J4(t,e){uW.set(t,e)}function oN(t){return uW.get(t)}function ab(t,e){dW.set(t,e)}function lN(t){return dW.get(t)}function oj(t,e){cW.set(t,e)}function qgt(t){return cW.get(t)}function lj(){return gD}var hW,hj,uW,dW,cW,gD,t5,Oi=U(()=>{hW=new Set,hj=new Set,uW=new Map,dW=new Map,cW=new Map,gD=null,t5=null});function Hgt(t,e,i,r,s=new bt){return s.compose(t,e,$gt).multiply(i).scale(r)}var $gt,hN,Ng,yD,ob=U(()=>{ot(),dD(),$gt=new E(1,1,1),hN=new bt,(Ng||(Ng={})).is=function(t){return t&&t.__isSPEObject},yD=t=>class extends t{constructor(){super(...arguments),this.previousModelViewMatrix=new bt,this.copyPreviousMatrix=!0,this.pivotMatrix=new bt,this.matrixWorldRigid=new bt,this.shearScale=new bt,this.shearScaleInv=new bt,this.shearMatrix=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(hN.copy(this.parent.matrixWorld).invert()),e.multiply(hN.copy(this.pivotMatrix).invert()),!0)}isDescendantOf(e){e instanceof ur&&(e=e.uuid);let i=this;for(;i.parent;){if(i.parent.uuid===e)return!0;i=i.parent}return!1}updateMatrix(){!this.shearMatrix||(Hgt(this.position,this.quaternion,this.shearMatrix,this.scale,this.matrix),this.matrixWorldNeedsUpdate=!0)}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.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.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.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)Ng.is(r)&&r.traverseObject(e,i+1)}traverseObject(e,i=0){if(e(this,i)!==!0)for(let r of this.children)Ng.is(r)&&r.traverseObject(e,i+1)}updateMatrixWorldRigid(){this.hasNonUniformScale=rgt(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)),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}onAfterRender(e,i,r,s,n,a){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}}});function _K(t,e,i){return Zp.subVectors(e,t),KS.subVectors(e,i),Zp.cross(KS).length()<=dS}function Xgt(t){let e=cj.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 E(...s[0].data.position)];cg.copy(a[0]);for(let y=0;y<s.length-1;y++)Zp.fromArray(s[y].data.position),KS.fromArray(s[y+1].data.position),P1.subVectors(Zp,cg),R1.subVectors(Zp,KS),P1.cross(R1).length()>dS&&(n.push(s[y]),a.push(new E().copy(Zp)),cg.copy(Zp));let o=s[s.length-1];n.push(o),a.push(new E(...o.data.position));let l=r.isClosed,h=n.length-(l?0:1),u=n.length,d=[],c=[];for(let y=0;y<u;y++){let v=n[y].data;d.push(new E(...v.controlPrevious.position)),c.push(new E(...v.controlNext.position))}let p=[];for(let y=0;y<h;y++){let v=y===u-1?0:y+1;p.push(_K(a[y],c[y],a[v])&&_K(a[y],d[v],a[v]))}let m=[];for(let y=0;y<u;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===u-1))continue;let x=l&&y==0?u-1:y-1,S=l&&y==u-1?0:y+1,w=new E().subVectors(a[x],b).normalize(),T=new E().subVectors(a[S],b).normalize();_.prevDir=w,_.nextDir=T;let C=p[l&&y===0?u-1:y-1],M=p[y];if(C&&M){pg.addVectors(w,T).normalize();let A=cg.crossVectors(pg,w).length()/w.dot(pg);_.tan=A,_.removedLength=v.roundness/A}}for(let y=0;y<h;y++){let v=l&&y===u-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*u).fill(null);for(let y=0;y<h;y++){let v=l&&y===u-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(cg.copy(b.nextDir).setLength(b.removedLength)),_.prevDir&&w.add(cg.copy(_.prevDir).setLength(_.removedLength))),S.distanceTo(w)>dS&&(x=new iS(S,S.clone().lerp(w,.3),w.clone().lerp(S,.3),w))}else b.position.distanceTo(_.position)>dS&&(x=new iS(b.position,b.controlNext,_.controlPrevious,_.position));f[2*y+1]=x}for(let y=0;y<u;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;pg.addVectors(v.prevDir,v.nextDir).normalize(),P1.copy(_).lerp(x,.5);let w=_.distanceTo(x)/2;dj.copy(pg).multiplyScalar(Math.sqrt(Math.pow(S,2)-Math.pow(w,2))).add(P1),dR.copy(pg).multiplyScalar(-S).add(dj);let T=b.distanceTo(dR)/b.distanceTo(P1);R1.copy(v.prevDir).multiplyScalar(T*b.distanceTo(_)).add(b),uj.copy(R1).lerp(dR,2);let C=_.clone().lerp(R1,4/3),M=x.clone().lerp(uj,4/3);f[2*y]=new iS(_,C,M,x)}let g=new Ygt;for(let y=0;y<f.length;y++){let v=f[y];v&&g.add(v)}return g}(t);return cj.set(t.points,{isClosed:t.isClosed,curve:i}),i}var Ygt,dS,Zp,KS,cg,pg,P1,dR,R1,uj,dj,cj,D1,pj,cR,Kgt,Zgt,Qgt,vi,Nu,xK,wK,v_,uN,XM,dN,cN,vD,mj,h0,ku,Jgt=U(()=>{ot(),Ygt=class extends aU{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],h=Math.ceil(t*l/s),u=o.getPoints(h);for(let d=0;d<u.length;d++){let c=u[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}},dS=.001,Zp=new E,KS=new E,cg=new E,pg=new E,P1=new E,dR=new E,R1=new E,uj=new E,dj=new E,cj=new WeakMap}),mCt=U(()=>{ot(),D1=new bt,pj=new we,cR=new we,Kgt=new zi,Zgt=new E,Qgt=new E(0,1,0)}),yo=U(()=>{ot(),De(),pCt(),Li(),Q4(),Jr(),Oi(),ob(),Jgt(),mCt(),er(),(vi||(vi={})).is=function(t){return t&&t.__isEntity},Nu=t=>vi.is(t),xK={type:"completeState",isfromEntity:!0},wK=["x","y","z"],v_=new E,uN=new E(1,1,1),XM=new we,dN=new zi,cN=new bt,vD=t=>class extends yD(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 aj,this._recursiveBBox=new aj,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(vi.is(i))return i}entityChildrenCount(){let e=this.children.length;for(;e--;)if(vi.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(!vi.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)sm.toOps(this.data,s.data).forEach(n=>{let a=C4.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=sm.patch(this.data,s),sm.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=>{Nu(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(vi.is(i[r]))return i[r];if(vi.is(e))return e.traverseSortNextHelper()}}sortNext(){let e=this.children;return this.children.length>0&&vi.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)Nu(i)&&e(i)}traverseEntityAncestors(e){this.traverseAncestors(i=>{vi.is(i)&&e(i)})}traverseConcreteEntity(e,i=0){if(e(this,i)!==!0)for(let r of this.children)Nu(r)&&r.isConcreteEntity&&r.traverseEntity(e,i+1)}traverseEntity(e,i=0){if(e(this,i)!==!0)for(let r of this.children)Nu(r)&&r.traverseEntity(e,i+1)}traverseVisibleEntity(e){e(this);for(let i of this.children)Nu(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}hasEntityChild(){return this.children.some(e=>Nu(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),xU({position:this.position.toArray(),rotation:[this.rotation.x*zt.RAD2DEG,this.rotation.y*zt.RAD2DEG,this.rotation.z*zt.RAD2DEG],scale:this.scale.toArray(),shear:_l.fromMatrix(this.shearMatrix.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,wK[n]])??s)}updateTransformState(e,i){let r=!1;if(e.position&&(this.position.fromArray(this.getTransformValues("position",e,i)),r=!0),e.rotation&&(v_.fromArray(this.getTransformValues("rotation",e,i)).multiplyScalar(zt.DEG2RAD),this.rotation.setFromVector3(v_),r=!0),e.scale&&(this.scale.fromArray(this.getTransformValues("scale",e,i)),r=!0),e.shear&&(this.shearMatrix.fromArray(_l.toMatrix(e.shear)),r=!0),e.pivot!==void 0||e.pivotRotation!==void 0){if(r=!0,e.pivot!==void 0&&e.pivotRotation!==void 0)this.pivotMatrix.compose(v_.fromArray(e.pivot).negate(),XM.setFromEuler(dN.fromArray(e.pivotRotation.map(s=>s*zt.DEG2RAD))).invert(),uN);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=v_.setFromMatrixPosition(this.pivotMatrix);XM.setFromEuler(dN.fromArray(e.pivotRotation.map(n=>n*zt.DEG2RAD))).invert(),this.pivotMatrix.compose(s,XM,uN)}}return r&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(s=>{s.invalidateClonerTransform(this)})),e.position&&e.rotation&&e.scale&&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)vi.is(e)&&e.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(e=>{vi.is(e)&&e.disposeRecursively()})}toState(e=[]){return xU({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=tr(e.path,["states","*"]);if(o!==null){if(e.type===0){let[l]=o;if(this?.stateSelection===l){let h={...e.props};if(delete h.name,Object.values(e.props).some(u=>u===void 0)){let u=this.data;if(u!==void 0){let d=Dn.zoom(u,e.path.slice(2));if(d)for(let c in e.props)e.props[c]===void 0&&c in d&&(h[c]=d[c])}}a={...e,props:h,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:u,...d}=l;l=d}if(e.props.material!==void 0&&"material"in l){let{material:u,...d}=l;l=d}let h=Dn.removeOverridden(e.path,e.props,l);a={...e,props:h}}}if(this.updateByPatchedOpBase(a,sm.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),r),tr(e.path,["overrides"])){let l=[],h=[...e.path];for(l.push(h[1]),h.splice(0,2);h.length>0&&h[0]==="descendants";)l.push(h[1]),h.splice(0,2);if(l[l.length-1]===void 0){if(e.type===0)for(let u of Object.keys(e.props)){l[l.length-1]=u;let d=r.scene.findInstance([this.uuid,...l]);d&&(d.overrideData=e.props[u],d.updateState(mm.apply(d.component.data,d.overrideData),r))}}else{let u=r.scene.findInstance([this.uuid,...l]);if(u){let d=Dn.zoom(u.component.data,h);if((e={...e,path:h}).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}}u.overrideData=X4.resolve(i.overrides,l),u.updateByOp(e,Qn.applySimple(u.data,e),r,!1)}}}else if(this.instances.length>0){let l;if(e.path.length===0&&e.type===0){let h;for(let u of vc.rootOverrideProps)u in e.props&&(h===void 0&&(h={}),h[u]=e.props[u]);h&&(l={...e,props:h})}else for(let h of vc.rootOverrideProps)if(tr(e.path,[h])){l=e;break}l!==void 0&&this.instances.forEach(h=>{if(h.isInstanceRoot){let u=mm.filterOp(h.overrideData,l);u&&h.updateByOp(u,Qn.applySimple(h.data,u),r,!0)}}),this.instances.forEach(h=>{if(!h.isInstanceRoot){let u=mm.filterOp(h.overrideData,e);if(u){let d;d=n===h.data&&e===u?i:Qn.applySimple(h.data,u),h.updateByOp(u,d,r,!0)}}})}}updateByPatchedOpBase(e,i,r){if(this.dataPatched=i,e.path.length===0&&e.type===0)e.props.type!==void 0&&!r0.is(e.props.type)&&xc.changeEntityProptotype(this,this.data,r);else if(e.path.length===1&&e.path[0]==="geometry"&&e.type===0&&"type"in e.props){xc.changeEntityProptotype(this,this.data,r);for(let s of this.children)vi.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(tr(e.path,["pathSnapping"])!==null&&(this.updatePathSnapping(i.pathSnapping),this.isVirtualEntity&&r.scene?.syncInstancePathConstraint(this)),tr(e.path,["cloner"])!==null){let s=Qn.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(this.isVirtualEntity&&e.pathConstraints.getConstraint(this.uuid)||i);if(!a)return;this._needApplyPathSnapping=!1;let o=a.data;if(o.geometry.path.points.length<=1)return;let l=Xgt(o.geometry.path),h=function(p){let m=p%1;return m<0?m+1:m===0&&p>0?1:m}(r+s),u=null;try{u=l.curves.length?l.getPointAt(h):null}catch{}if(u===null)return;a.updateMatrixWorld();let d=this.parent?cN.copy(this.parent.matrixWorld):cN.identity(),c=function(p,m,f,g){pj.setFromRotationMatrix(D1.extractRotation(g));let y=p.clone().applyMatrix4(D1.copy(g).invert().multiply(f));if(m===null)cR.setFromRotationMatrix(D1.extractRotation(f));else{let v=m.clone().applyMatrix4(D1.extractRotation(f));cR.setFromRotationMatrix(D1.lookAt(Zgt.set(0,0,0),v,Qgt))}return{position:y,rotation:new E().setFromEuler(Kgt.setFromQuaternion(pj.invert().multiply(cR))).multiplyScalar(zt.RAD2DEG)}}(u,n==="tangential"?l.getTangentAt(h):null,a.matrixWorld,d);this.updateTransformState({position:c.position.toArray(),rotation:c.rotation.toArray()}),this.traverseEntity(p=>{p._cameraType&&p.dispatchEvent(xK)})}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=>nm(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(xc.Cloner===null)return void On("cloners","a cloner");this.cloner=new xc.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"})}}}),u0=U(()=>{ot(),yo(),(mj||(mj={})).is=t=>"objectHelper"in t,h0=(t,e)=>class extends vD(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 GS&&(r.visible=!0)}}updateEntityBoxSize(i,r){this.objectHelper.visible&&this.geometryHelper instanceof Yh?(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 GS&&(r.visible=!1)}}}}),bD=U(()=>{ot(),mD(),u0(),ku=class extends h0(rb,Gv){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 uh(t,e,i,r,s,n,a){c2.set(s,n,a).unproject(r);let o=e[t];if(o!==void 0){let l=i.getAttribute("position");for(let h=0,u=o.length;h<u;h++)l.setXYZ(o[h],c2.x,c2.y,c2.z)}}var c2,Yo,SK,t0t,fCt=U(()=>{ot(),_T(),xT(),c2=new E,Yo=new Eg,SK=class extends T1{constructor(t){let e=new fe,i=new zh({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],s=[],n={},a=new se(15711266),o=new se(15711266),l=new se(2857471);function h(d,c,p){u(d,p),u(c,p)}function u(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)}h("n1","n2",a),h("n2","n4",a),h("n4","n3",a),h("n3","n1",a),h("f1","f2",a),h("f2","f4",a),h("f4","f3",a),h("f3","f1",a),h("n1","f1",a),h("n2","f2",a),h("n3","f3",a),h("n4","f4",a),h("p","n1",o),h("p","n2",o),h("p","n3",o),h("p","n4",o),h("u1","u2",l),h("u2","u3",l),h("u3","u1",l),e.setAttribute("position",new me(r,3)),e.setAttribute("color",new me(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;Yo.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let i=.8;uh("n1",e,t,Yo,-1,-1,i),uh("n2",e,t,Yo,1,-1,i),uh("n3",e,t,Yo,-1,1,i),uh("n4",e,t,Yo,1,1,i);let r=i;uh("f1",e,t,Yo,-1,-1,r),uh("f2",e,t,Yo,1,-1,r),uh("f3",e,t,Yo,-1,1,r),uh("f4",e,t,Yo,1,1,r);let s=r;uh("u1",e,t,Yo,.35,1.1,s),uh("u2",e,t,Yo,-.35,1.1,s),uh("u3",e,t,Yo,0,1.55,s),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}},t0t=class extends sb(SK){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){nb(this.object,this.geometry,t,e,!0)}}});function TK(t){return 1-Math.pow(1-t,3)}var af,YM,KM,ZM,$0,QM,lu,zs,Kh=U(()=>{ot(),fCt(),De(),u0(),er(),af=new E,YM=new E,KM=new we,ZM=new E,$0=new E,QM=new E,lu=class extends h0(Eg,t0t){constructor(t="",e={...lS.defaultData,name:""}){super(),this._cameraType="OrthographicCamera",this.targetOffset=yc.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=lu.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 zv(-.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=lu.projectionTransitionsEnabled;lu.projectionTransitionsEnabled=!1;try{return t()}finally{lu.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 E(t,e,i)),super.lookAt(t),this.getWorldPosition(af),this.targetOffset=af.distanceTo(t)}getTarget(t=new E){return this.getWorldDirection(YM),this.getWorldPosition(af),YM.multiplyScalar(this.targetOffset),t.copy(af).add(YM),t}getDistanceToTarget(){let t=this.getTarget();return this.getWorldPosition(af),af.distanceTo(t)}updateUp(){this.getWorldQuaternion(KM),ZM.set(0,0,1).applyQuaternion(KM),$0.copy(ur.DEFAULT_UP),this.isUpVectorFlipped&&$0.negate(),$0.applyQuaternion(KM),QM.copy(ur.DEFAULT_UP).projectOnPlane(ZM),this.angleOffsetFromUp=QM.angleTo($0),this.angleOffsetFromUp*=QM.cross($0).dot(ZM)>=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 E),i=t.getWorldDirection(new E).multiplyScalar(this.targetOffset);return{position:e.clone().add(i),target:e}}getViewToTarget(t){let e=this.getWorldDirection(new E).multiplyScalar(this.targetOffset);return{position:t.clone().sub(e),target:t}}getViewToObject(t){let e=new E;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:TK(e)}get _activeSubCamera(){return this._cameraType==="PerspectiveCamera"?this.perspCamera:this.orthoCamera}_canAnimateProjection(){return lu.projectionTransitionsEnabled&&typeof requestAnimationFrame=="function"&&typeof performance<"u"&&performance.now()-this._createdAt>=lu.projectionTransitionMinAgeMs}_beginProjectionTransition(t){let e=this._projectionTransition;e===void 0&&(e={from:new bt,blend:new bt,blendInverse:new bt,start:0,duration:lu.projectionTransitionDuration,referenceDepth:1,raf:0,requestRender:t},this._projectionTransition=e),e.from.copy(this.projectionMatrix),e.start=performance.now(),e.duration=lu.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=TK(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 h=0;h<16;h++)n[h]=r[h]+(s[h]-r[h])*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=yc.sanitizeTargetOffset(t.targetOffset),this.updateProjectionMatrix(),this._syncProjectionTransition(t),this}toCameraState(t=[]){return xU({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=yc.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}}},(zs=lu).projectionTransitionsEnabled=!1,zs.projectionTransitionDuration=350,zs.projectionTransitionMinAgeMs=1e3});function e0t(t){return t.type==="TorusGeometry"&&t.arc===360}var i0t,JM,fj,ZS=U(()=>{ot(),i0t=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:h,cornerRadius:u,cornerSegments:d}=t.parameters,c=new fj(!1,e,i,r,s,n,a,o,l,h,u,d);return Object.assign(c,{userData:{...t,type:"HelixGeometry"}})}},JM=new pm([0,0,0],1),fj=class extends fe{constructor(t=!0,e=1,i=1,r=1,s=1,n=1,a=1,o=1,l=1,h=1,u=1,d=1){if(super(),n===0)return;let c=t&&n===1;c&&(d=0),u>100&&(u=100),u===0&&(d=0);let p,m,f,g,y,v,b,_,x=()=>new E,S=new E,w=x(),T=x(),C=x(),M=x(),A=x(),P=x(),O=x(),D=x(),N=x(),z=x(),k=x(),B=i-2*o+.001,V=B/n,q=Math.ceil(a*n),W=q+1,H=B/q,rt=-B/2,it=h+1,ft=2*Math.PI/h,dt=Math.PI/2/d,K=Math.min((1-u/100)*o,o-.01),lt=o-K,_t=0,xt=2*d+2,wt=it*xt/2,gt=wt+it*W,Dt=Math.max(0,it*(W+xt)),[Lt,It,kt]=[3,3,2].map(Be=>Array(Dt*Be).fill(0)),Nt=[],Gt=s-o;function qt(Be,te){let ni=Math.PI/2;v=te*H,_=2*Math.PI*(v%V)/V+ni,v+=rt,b=Math.sin(_)*Gt,y=Math.cos(_)*Gt,t?Be.set(y,b,v):Be.set(y,v,b)}qt(S,-1e-10),qt(w,0),M.copy(S),qt(S,1);let Ct=S.distanceTo(w),ne=c?0:lt+K,Ut=Ct*q+2*ne,Yt=K,Zt=Ut-ne;for(let Be=0;Be<=q;Be++){qt(T,Be),k.subVectors(T,M).normalize(),M.copy(T),N.copy(T).setComponent(+t+1,0).normalize(),z.crossVectors(k,N).normalize();let te=Be===0,ni=Be===q,bi=te?3*Math.PI/2:dt,Zs=te?Yt:Zt,Hi=te?it:gt,ai=te?0:Dt-it,Fr=k.clone().multiplyScalar(te?-lt:lt).add(T),ts=k.clone().multiplyScalar(te?-1:1).normalize();for(let Ur=0;Ur<it;Ur++){let Fi=Ur*ft;if(A.addVectors(S.copy(N).multiplyScalar(o*Math.cos(Fi)),w.copy(z).multiplyScalar(o*Math.sin(Fi))),P.copy(A).normalize(),te||ni){c||(_t=ai+Ur,[0,1,2].forEach(Ti=>{Lt[3*_t+Ti]=Fr.getComponent(Ti),It[3*_t+Ti]=ts.getComponent(Ti)}),kt[2*_t]=+ni,kt[2*_t+1]=Ur/h),w.copy(P).multiplyScalar(K),C.addVectors(T,w);for(let Ti=0;Ti<d;Ti++){let Qs=Ti*dt+bi;O.addVectors(S.copy(k).multiplyScalar(lt*Math.sin(Qs)),w.copy(P).multiplyScalar(lt*Math.cos(Qs))),D.copy(O).normalize(),w.addVectors(C,O),O.normalize(),_t=Hi+Ti*it+Ur,[0,1,2].forEach(vr=>{Lt[3*_t+vr]=w.getComponent(vr),It[3*_t+vr]=D.getComponent(vr)});let ms=+te+Math.sin(Qs);kt[2*_t]=(Zs+lt*ms)/Ut,kt[2*_t+1]=Ur/h}}w.addVectors(T,A),_t=wt+Be*it+Ur,[0,1,2].forEach(Ti=>{Lt[3*_t+Ti]=w.getComponent(Ti),It[3*_t+Ti]=P.getComponent(Ti)}),kt[2*_t]=(ne+Be*Ct)/Ut,kt[2*_t+1]=Ur/h}}let $=W+2*d+2,[ie,Ce]=[+c,$-1];for(let Be=ie;Be<=Ce-1;Be++){let te=c&&Be===Ce-1;for(let ni=0;ni<it-1;ni++)p=Be*it+ni,m=p+1,f=(te?ni:p)+it,g=(te?ni+1:m)+it,Be===0?Nt.push(m,g,f):Be===$-2?Nt.push(p,m,f):Nt.push(p,m,f,m,g,f)}this.setIndex(Nt),this.setAttribute("position",new me(Lt,3)),this.setAttribute("normal",new me(It,3)),this.setAttribute("uv",new me(kt,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 h=1;h<n;h++)for(let u=0;u<a;u++)t=h*o+u,e=t+1,i=t+o,r=e+o,l.push(t,e,i,e,r,i);for(let h=0;h<a;h++)t=n*o+h,e=t+1,i=h+o,r=h+1+o,l.push(t,e,i,e,r,i);return JM.array=new Uint32Array(l),JM.count=l.length,JM}}});function gCt(t){return AK||(AK=async function(){let e=t??"https://cdn.spline.design/@splinetool/runtime@2.0.204/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}),QS=r}())}function e5(){if(QS===void 0)throw new Error("boolean-wasm is not loaded");return QS}function pW(t){let e=JS.get(t);if(e===void 0)throw new Error("Unknown csg mesh set handle "+t);return e}function mW(t){return JS.set(++gj,t),gj}function yCt(t,e,i){if(QS===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=e0t(a.userData.parameters)?a.getClosedTorusIndicesForBooleanOrSubdiv():a.getIndex();let h,u=a.getAttribute("position");if(l===null){h=new Uint32Array(u.count);for(let p=0;p<h.length;p++)h[p]=p}else h=l.array instanceof Uint32Array?l.array:new Uint32Array(l.array);let d=a.getAttribute("normal"),c=d!==void 0&&d.itemSize===3&&d.count===u.count&&d.array instanceof Float32Array&&d.isInterleavedBufferAttribute!==!0?d.array:void 0;return{positions:u.array,indices:h,normals:c}}(t,e);return mW(new QS.CsgMesh(r,s,n))}function MK(t,e){let i=e5(),r=s0t[e];if(r===void 0)throw new Error("Unknown boolean operation "+e);let s=t.map(pW);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 pN(t,e){pW(t).transform(new Float32Array(e.elements))}function r0t(t){let e=JS.get(t);e!==void 0&&(e.free(),JS.delete(t))}var QS,JS,gj,AK,s0t,_D=U(()=>{ot(),ZS(),JS=new Map,gj=0,s0t={0:0,1:1,2:2}});function of(t){return t!==null&&"booleanOp"in t}var yj,n0t,vCt=U(()=>{ot(),yo(),_D(),yj=class extends vD(gr){constructor(){super(...arguments),this.booleanMeshSetAddress=-1,this.booleanWasTransformed=!1,this.booleanMatrixInvOld=new bt}updateVisible(t){super.updateVisible(t),this.visible=!of(this.parent)&&this.visible,of(this.parent)&&this.parent.invalidateDownstreamBooleanData()}onClonerLayoutUpdated(){of(this.parent)&&this.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(r0t(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}dispose(){super.dispose(),this.freeBooleanPointer()}invalidateDownstreamBooleanData(t=!1){return t?this.booleanWasTransformed=!0:this.freeBooleanPointer(),of(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let t of this.children)t instanceof yj&&(t.freeBooleanPointer(),of(t)&&t.invalidateUpstreamBooleanData())}updateTransformState(t,e){let i=super.updateTransformState(t,e);return i&&of(this.parent)&&this.invalidateDownstreamBooleanData(!0),i}onVariableUpdate(t=!1){super.onVariableUpdate(t),of(this.parent)&&this.invalidateDownstreamBooleanData(!0)}}}),bCt=U(()=>{n0t=null});function fW(t,e=0,i=t.count,r,s){let n=1/0,a=1/0,o=1/0,l=-1/0,h=-1/0,u=-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>h&&(h=p),m>u&&(u=m)}p2.min.set(n,a,o),p2.max.set(l,h,u),p2.getCenter(r),p2.getSize(s).multiplyScalar(.5)}var p2,CK,EK,Ks,na=U(()=>{ot(),vCt(),bCt(),p2=new dr,CK=new fe,EK=new jo,Ks=class extends yj{constructor(t,e){super(CK,EK),this.super_Entity(t,e)}updateState(t,e){this.updateState_Entity(t,e)}raycast(t,e){if(this.raycastDeformed(t,e))return;let i=n0t;i===null?super.raycast(t,e):i(this,t,e)}raycastDeformed(t,e){return!1}updateEntityBoxSize(t,e){let i=this.geometry.getAttribute("position");i!==void 0?fW(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,t,e):super.updateEntityBoxSize(t,e)}}});function a0t(t){return t?.isClassicNodeMaterial===!0}var Dr,vj,o0t,l0t,cS,h0t,u0t,d0t,c0t=U(()=>{}),Nc=U(()=>{ot(),Dr=class extends se{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}}}),_Ct=U(()=>{Nc(),vj=class extends Dr{}}),xCt=U(()=>{o0t=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}}}),p0t=U(()=>{xCt(),l0t=class extends o0t{create(t){return URL.createObjectURL(new Blob([t]))}dispose(t,e){URL.revokeObjectURL(e)}}}),m0t=U(()=>{h0t=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}},u0t=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}}}),wCt=U(()=>{ot(),d0t=class extends Qmt{constructor(t){super(t),this.type=si}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(`
|
|
381
|
+
})();`});function VM(t){return t==null||t===""?void 0:String(t)}var zG,cft=U(()=>{zG=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"getAnimations":{let r=i.getAnimations(VM(e[0]));return r.warning&&this.onConsole("warn",`spline.${t}: ${r.warning}`),r.clips}case"playAnimation":{let r=typeof e[1]=="object"&&e[1]!==null,s=i.playAnimation(String(e[0]),r?void 0:VM(e[1]),(r?e[1]:e[2])??{});return s.warning&&this.onConsole("warn",`spline.${t}: ${s.warning}`),s.clip}case"pauseAnimation":case"stopAnimation":{let r=VM(e[0]),s=VM(e[1]),n=t==="pauseAnimation"?i.pauseAnimation(r,s):i.stopAnimation(r,s);return n.warning&&this.onConsole("warn",`spline.${t}: ${n.warning}`),n.ok}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 c3t(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 p3t=U(()=>{}),pft,m3t=U(()=>{}),f3t=U(()=>{VG(),cft(),pft=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[Gp]!==!0||typeof n.kind!="string"||this.handleMessage(s)},this.host=new zG(e,i,(r,s)=>{this.sendEvent(r,s)})}attach(){window.addEventListener("message",this.onMessage),this.send({[Gp]:!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({[Gp]:!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({[Gp]:!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({[Gp]:!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({[Gp]:!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}))}}}}),er=U(()=>{kG(),ZAt(),QAt(),JAt(),e3t(),i3t(),r3t(),s3t(),n3t(),a3t(),o3t(),u3t(),VG(),d3t(),cft(),p3t(),m3t(),f3t()}),g3t=U(()=>{});function mft(t){return Array.isArray(t)?t:[t]}function M4(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 y3t=U(()=>{});function qa(t,e){return Object.setPrototypeOf(t,e),t}function xI(t){let e={...t};return Object.setPrototypeOf(e,Object.getPrototypeOf(t)),e}function tm(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 e0(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 v3t=U(()=>{});function LG(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"&&LG(r)}return Object.freeze(t)}function fft(t){for(let e of Object.keys(t))t[e]===void 0&&delete t[e];return t}var wI,A4,wU,Ne,FG,b3t=U(()=>{}),dn=U(()=>{g3t(),y3t(),v3t(),b3t()}),UG=U(()=>{wI=class{},A4=class extends wI{constructor(t){super(),this.id=t}},wU=class extends wI{constructor(t){super(),this.data=t}}}),_3t=U(()=>{}),nD=U(()=>{Ne=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,Ne.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,Ne.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,Ne.prototype),delete s[i],{data:s,actual:t,reverse:{type:1,id:i,data:r}}}}return null}}}),jG=U(()=>{FG=class extends Error{}});function gft(t,e){for(let i of t)e(i.id,i.data)!==!0&&gft(i.children,e)}function yft(t,e){if(e(t.id,t.data)!==!0)for(let i of t.children)yft(i,e)}var Nn,zM,Lv,ue,a0=U(()=>{dn(),jG(),dn(),Nn=class extends Array{constructor(...t){super(...t),pc(this,"partialObjectCaches"),pc(this,"objCaches"),pc(this,"parentCaches"),Object.setPrototypeOf(this,Nn.prototype)}deepFreeze(){let t=0;for(;t<this.length;)LG(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&&yft(i,e)}}traverse(t){gft(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(h=>h.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,Nn.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((h,u)=>h.fi-u.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 FG("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],h=this.modifyArrayBy(s,a);s=e,a=h.childrenArray(s);let u=l.fi;return l={...l,fi:i},a=[...a,l],a.sort((d,c)=>d.fi-c.fi),t.localIndex=a.indexOf(l),h=h.modifyArrayBy(s,a),{data:h,actual:t,reverse:{type:9,parent:n,fi:u,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)=>M4(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)=>M4(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 tm(0,i,i);{let s=r[0].fi;return tm(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 tm(a,a+i,i)}return tm(s.fi,n.fi,i)}}}}),GG=U(()=>{var t;dn(),zM=null,(t=Lv||(Lv={})).setPreservePrototype=function(e){zM=e},t.tryPreservePrototype=function(e,i){return Object.getPrototypeOf(e)===zM&&Object.setPrototypeOf(i,zM),i},t.runOp=function(e,i){if(i.type!==0)return null;if(Array.isArray(e)||e0(e)){let r=i.props,s={},n=e0(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}}}),o0=U(()=>{dn(),dn(),ue=class extends Array{constructor(...t){super(...t),pc(this,"objCaches"),Object.setPrototypeOf(this,ue.prototype)}deepFreeze(){let t=0;for(;t<this.length;)LG(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,ue.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 tm(0,e,e);{let r=i[0].fi;return tm(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 tm(n,n+e,e)}return tm(r.fi,s.fi,e)}}}});function x3t(t,e){let i={cur:[],result:[],len:0};return[t=cv(t,e,i)??t,i.result]}function tR(t,e){return t===null?null:(t.cur[t.len]=e,t.len+=1,t)}function eR(t){t&&(t.len-=1)}function vft(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=cv(n.data,e,tR(i,a));eR(i),r=r||l!==void 0,l===void 0&&(l=n.data);let h=vft(n.children,e,i);return h!==void 0?r=!0:h=n.children,{...n,id:a,data:l,children:h}});if(r)return s}function cv(t,e,i){if(t instanceof Nn){let r=vft(t,e,i);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(t)),r}if(t instanceof ue)return function(r,s,n){let a=!1,o=r.map(l=>{let h=l.id,u=s[h];if(u!==void 0&&typeof u=="string"&&(a=!0,h=u,n!==null))throw new Error("not supported");let d=cv(l.data,s,tR(n,h));return eR(n),a=a||d!==void 0,d===void 0&&(d=l.data),{...l,id:h,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=cv(n,e,tR(i,a));return eR(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"&&!e0(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=cv(a,e,tR(i,n));eR(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 bft=U(()=>{a0(),o0(),dn()});function pv(t){return t&&typeof t=="object"&&t instanceof Cs}function WG(t,e){if(e===void 0)return;let i=!1,r=t.map(s=>{let n=s.id,a=aS(s.data,e[n]);if(i=i||a!==void 0,a===void 0&&(a=s.data),s.children){let o=WG(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 aS(t,e){if(!pv(e))return e;if(t instanceof Nn){let i=WG(t,e);return i!==void 0&&Object.setPrototypeOf(i,Object.getPrototypeOf(t)),i}if(t instanceof ue)return function(i,r){if(r===void 0)return;let s=!1,n=i.map(a=>{let o=a.id,l=aS(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=aS(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 Cs)return qG(t,e);if(t&&typeof t=="object"){let i={},r=!1;for(let[s,n]of Object.entries(t)){let a=aS(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 qG(t,e){if(t===void 0)return e;if(e===void 0)return t;if(!pv(e))return e;if(!pv(t))return mm.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 Cs;for(let s of i){let n=qG(t===void 0?void 0:t[s],e===void 0?void 0:e[s]);r[s]=n}return r}var Cs,mm,C4,Qn,CX,aD=U(()=>{var t;a0(),o0(),oD(),dn(),Cs=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&&!pv(r))return null;s+=1}r=r?xI(r):new Cs;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=xI(a),delete r[e.path[s-1]])}else{let a=i[s-1];if(a){let o=xI(a);o[e.path[s-1]]=r,r=o}else{let o=new Cs;o[e.path[s-1]]=r,r=o}}s-=1}return{data:Object.setPrototypeOf(r,Cs.prototype),actual:e,reverse:{...e,props:n}}}},(t=mm||(mm={})).apply=function(e,i){return aS(e,i)??e},t.merge=function(e,i){return qG(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(!pv(n))return;r+=1}if(n===void 0)return i;if(pv(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=WG([i],n);return a?a[0]:i}return i}}}),w3t=U(()=>{dn(),oD(),nD(),a0(),jG(),GG(),o0(),bft(),aD(),(C4||(C4={})).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 Cs&&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 Nn||s instanceof ue||s instanceof Ne?s.runOp(n):Lv.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 Nn){if(typeof p=="number")throw new Error("illegal arg");d=m.modifyById(p,d)}else if(m instanceof ue){if(typeof p=="number")throw new Error("illegal arg");d=m.modifyById(p,d)}else if(m instanceof Ne){if(typeof p=="number")throw new Error("illegal arg");d=m.modifyById(p,d)}else if(m instanceof Cs){let f={...m,[p]:d};d=Object.setPrototypeOf(f,Cs.prototype)}else{if(typeof m!="object")return null;if(Array.isArray(m)||e0(m)){if(typeof p=="string"&&(p=parseInt(p),isNaN(p)))throw new Error("Invalid path");let f=d;d=e0(m)?m.slice():[...m],d[p]=f}else d=Lv.tryPreservePrototype(m,{...m,[p]:d})}}return{data:d,actual:{...l.actual,path:a},reverse:{...l.reverse,path:a}}}return null}let h,u=a[o.length];if(s instanceof Nn){if(typeof u=="number")throw new Error("");h=s.get(u)?.data}else if(s instanceof ue){if(typeof u=="number")throw new Error("");h=s.get(u)?.data}else s!==null&&(h=s[u]);if(h===void 0)return null;o.push(s),s=h}}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)}})(Qn||(Qn={})),(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,h;if(o.type===3?(l=Dn.zoom(s,[...o.path,o.id]),h=Qn.apply(s,{...o,type:2})):(l=Dn.zoom(s,[...o.path,o.id,"value"]),h=Qn.apply(s,o)),h!==null){s=h.data;let[u,d]=x3t(s,{[o.id]:l});s=u;for(let c=0;c<d.length;c++){let p,m,f=d[c],g=f.pop();if(typeof g=="number"){let y=[g];for(let b=c+1;b<d.length;b++){let _=d[b],x=_[_.length-1];if(typeof x!="number"||!Dn.equal(f,_.slice(0,_.length-1)))break;y.push(x),d.splice(b,1)}let v=Dn.zoom(s,f);m=v.map((b,_)=>y.includes(_)?o.id:b),p=v,g=f.pop()}else p=l,(g==="alphaOverride"||g==="alpha")&&(p=l/100,Dn.zoom(s,f)[g]=p),m=o.id;n.push({type:0,path:f,props:{[g]:p}}),a.push({type:0,path:f,props:{[g]:m}})}a.push(h.reverse),n.push(h.actual)}}else{let l=Qn.apply(s,o);l!==null&&(n.push(l.actual),s=l.data,a.push(l.reverse))}}catch(l){if(l instanceof FG)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=>Qn.subsumed(s,n))),...r]},t.commutative=function(i,r){return i.every(s=>r.every(n=>Qn.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})(CX||(CX={}))});function EX(t,e){return t instanceof Cs?Object.setPrototypeOf(e,Cs.prototype):Lv.tryPreservePrototype(t,e)}function SI(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 iR(t,e,i){return i instanceof Nn?new fT(t,e,i):i instanceof ue?new gT(t,e,i):i instanceof Ne?new Proxy(new xft(t,e,i),Sft):i!==null&&typeof i=="object"?e0(i)?i:new Proxy(new _ft(t,e,i),wft):i}function s2(t){let e=new SU(t);return[iR(e,"",t),e]}function E4(t,e){let[i,r]=s2(t);return e(i),r.result()}function Os(t){return t instanceof fT||t instanceof gT?t._current:t!==null&&typeof t=="object"?t[P4]:t}function Q1(t){if(t instanceof fT||t instanceof gT)return t._current;if(t!==null&&typeof t=="object"){let e=t[P4];return e!==void 0?e:t}return t}var P4,PX,m_,j0,_ft,xft,TI,wft,Sft,fT,gT,SU,Dn,Tft=U(()=>{nD(),a0(),GG(),o0(),dn(),oD(),aD(),P4=Symbol(),PX=Symbol(),m_=Symbol(),j0=class{reportOp(t,e,i=[]){let r=this;if(e===null)return;r._current=e.data;let s=i;for(;!(r instanceof SU);){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[m_];i&&i(),delete this._children[t]}}}},_ft=class extends j0{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=EX(this._current,{...this._current,[t]:e})}runOp(t){let e=Lv.runOp(this._current,t);e!==null&&(e.data=EX(this._current,e.data)),this.reportOp(t,e,t.path)}},xft=class extends j0{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,Ne.prototype)}runOp(t){this.reportOp(t,this._current.runOp(t))}},TI={get(t,e){if(e===m_)return()=>{t._parent=null};if(e===P4)return t._current;if(e===PX)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=iR(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]}}},wft={...TI,set(t,e,i){let r={type:0,props:{[e]:Os(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}},Sft={...TI,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)},fT=class extends j0{constructor(t,e,i){super(),this._children={},this._parent=t,this._path=e,this._current=i,this[m_]=()=>{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=iR(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)}},gT=class extends j0{constructor(t,e,i){super(),this._children={},this._parent=t,this._path=e,this._current=i,this[m_]=()=>{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=iR(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})}},SU=class extends j0{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){SI(this.ts,e,t),SI(this.actual,i,t),SI(this.reverse,r,t)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}}}),oD=U(()=>{UG(),Tft(),o0(),a0(),dn(),(t=>{function e(r,s){return(r instanceof Nn||r instanceof fT)&&typeof s=="string"||(r instanceof ue||r instanceof gT)&&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 A4&&o.id===s.id)n.push(l);else if(o instanceof ue)for(let h=0;h<o.length;h++)a(o[h].data,[...l,o[h].id]);else if(o instanceof Nn)o.traverse((h,u)=>{a(u,[...l,h])});else if(Array.isArray(o)){if(typeof o[0]=="number")return;for(let h=0;h<o.length;h++)a(o[h],[...l,h])}else{if(e0(o))return;if(typeof o=="object"&&o!==null)for(let h in o)a(o[h],[...l,h])}}(r,[]),n}})(Dn||(Dn={}))}),S3t=U(()=>{});function tr(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 T3t=U(()=>{});function LM(t){try{if(!Er.trusted&&!gc){let i=Gi.sharedLength||0;i<Gi.length&&(Gi.length=i)}let e;if(Er.randomAccessStructure&&ce[pt]<64&&ce[pt]>=32&&BX?(e=BX(ce,pt,Jl,Er),ce=null,!(t&&t.lazy)&&e&&(e=e.toJSON()),pt=Jl):e=Ys(),Ea&&(pt=Ea.postBundlePosition,Ea=null),gc&&(Gi.restoreStructures=null),pt==Jl)Gi&&Gi.restoreStructures&&RX(),Gi=null,ce=null,fc&&(fc=null);else{if(pt>Jl)throw new Error("Unexpected end of MessagePack data");if(!gc){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 Gi&&Gi.restoreStructures&&RX(),MU(),(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer")||pt>Jl)&&(e.incomplete=!0),e}}function RX(){for(let t in Gi.restoreStructures)Gi[t]=Gi.restoreStructures[t];Gi.restoreStructures=null}function Ys(){let t=ce[pt++];if(t<160){if(t<128){if(t<64)return t;{let e=Gi[63&t]||Er.getStructures&&Mft()[63&t];return e?(e.read||(e.read=TU(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=Cft();r==="__proto__"&&(r="__proto_"),e[r]=Ys()}return e}{let e=new Map;for(let i=0;i<t;i++)e.set(Ys(),Ys());return e}}{t-=144;let e=new Array(t);for(let i=0;i<t;i++)e[i]=Ys();return Er.freezeData?Object.freeze(e):e}}if(t<192){let e=t-160;if(Gh>=pt)return em.slice(pt-ml,(pt+=e)-ml);if(Gh==0&&Jl<140){let i=e<16?HG(e):Aft(e);if(i!=null)return i}return O4(e)}{let e;switch(t){case 192:return null;case 193:return Ea?(e=Ys(),e>0?Ea[1].slice(Ea.position1,Ea.position1+=e):Ea[0].slice(Ea.position0,Ea.position0-=e)):Rft;case 194:return!1;case 195:return!0;case 196:if(e=ce[pt++],e===void 0)throw new Error("Unexpected end of buffer");return MI(e);case 197:return e=ki.getUint16(pt),pt+=2,MI(e);case 198:return e=ki.getUint32(pt),pt+=4,MI(e);case 199:return nf(ce[pt++]);case 200:return e=ki.getUint16(pt),pt+=2,nf(e);case 201:return e=ki.getUint32(pt),pt+=4,nf(e);case 202:if(e=ki.getFloat32(pt),Er.useFloat32>2){let i=DU[(127&ce[pt])<<1|ce[pt+1]>>7];return pt+=4,(i*e+(e>0?.5:-.5)|0)/i}return pt+=4,e;case 203:return e=ki.getFloat64(pt),pt+=8,e;case 204:return ce[pt++];case 205:return e=ki.getUint16(pt),pt+=2,e;case 206:return e=ki.getUint32(pt),pt+=4,e;case 207:return Er.int64AsType==="number"?(e=4294967296*ki.getUint32(pt),e+=ki.getUint32(pt+4)):Er.int64AsType==="string"?e=ki.getBigUint64(pt).toString():Er.int64AsType==="auto"?(e=ki.getBigUint64(pt),e<=BigInt(2)<<BigInt(52)&&(e=Number(e))):e=ki.getBigUint64(pt),pt+=8,e;case 208:return ki.getInt8(pt++);case 209:return e=ki.getInt16(pt),pt+=2,e;case 210:return e=ki.getInt32(pt),pt+=4,e;case 211:return Er.int64AsType==="number"?(e=4294967296*ki.getInt32(pt),e+=ki.getUint32(pt+4)):Er.int64AsType==="string"?e=ki.getBigInt64(pt).toString():Er.int64AsType==="auto"?(e=ki.getBigInt64(pt),e>=BigInt(-2)<<BigInt(52)&&e<=BigInt(2)<<BigInt(52)&&(e=Number(e))):e=ki.getBigInt64(pt),pt+=8,e;case 212:if(e=ce[pt++],e==114)return RU(63&ce[pt++]);{let i=wa[e];if(i)return i.read?(pt++,i.read(Ys())):i.noBuffer?(pt++,i()):i(ce.subarray(pt,++pt));throw new Error("Unknown extension "+e)}case 213:return e=ce[pt],e==114?(pt++,RU(63&ce[pt++],ce[pt++])):nf(2);case 214:return nf(4);case 215:return nf(8);case 216:return nf(16);case 217:return e=ce[pt++],Gh>=pt?em.slice(pt-ml,(pt+=e)-ml):Oft(e);case 218:return e=ki.getUint16(pt),Gh>=(pt+=2)?em.slice(pt-ml,(pt+=e)-ml):Ift(e);case 219:return e=ki.getUint32(pt),Gh>=(pt+=4)?em.slice(pt-ml,(pt+=e)-ml):Nft(e);case 220:return e=ki.getUint16(pt),pt+=2,DX(e);case 221:return e=ki.getUint32(pt),pt+=4,DX(e);case 222:return e=ki.getUint16(pt),pt+=2,OX(e);case 223:return e=ki.getUint32(pt),pt+=4,OX(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 TU(t,e){function i(){if(i.count++>CU){let s;try{s=t.read=new Function("r","return function(){return "+(Er.freezeData?"Object.freeze":"")+"({"+t.map(n=>n==="__proto__"?"__proto_:r()":Dft.test(n)?n+":r()":"["+JSON.stringify(n)+"]:r()").join(",")+"})}")(Ys)}catch{return CU=1/0,i()}return t.read0=s,t.highByte===0&&(t.read=EU(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]=Ys()}return Er.freezeData?Object.freeze(r):r}return i.count=0,t.read0=i,t.highByte===0?EU(e,i):i}function Mft(){let t=Pft(()=>(ce=null,Er.getStructures()));return Gi=Er._mergeStructures(t,Gi)}function n2(t){let e;if(t<16&&(e=HG(t)))return e;if(t>64&&AU)return AU.decode(ce.subarray(pt,pt+=t));let i=pt+t,r=[];for(e="";pt<i;){let s=ce[pt++];if(128&s)if((224&s)==192){let n=(31&s)<<6|63&ce[pt++];n<128?r.push(65533):r.push(n)}else if((240&s)==224){let n=(31&s)<<12|(63&ce[pt++])<<6|63&ce[pt++];n<2048||n>=55296&&n<=57343?r.push(65533):r.push(n)}else if((248&s)==240){let n=(7&s)<<18|(63&ce[pt++])<<12|(63&ce[pt++])<<6|63&ce[pt++];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+=Mn.apply(String,r),r.length=0)}return r.length>0&&(e+=Mn.apply(String,r)),e}function DX(t){let e=new Array(t);for(let i=0;i<t;i++)e[i]=Ys();return Er.freezeData?Object.freeze(e):e}function OX(t){if(Er.mapsAsObjects){let e={};for(let i=0;i<t;i++){let r=Cft();r==="__proto__"&&(r="__proto_"),e[r]=Ys()}return e}{let e=new Map;for(let i=0;i<t;i++)e.set(Ys(),Ys());return e}}function Aft(t){let e=pt,i=new Array(t);for(let r=0;r<t;r++){let s=ce[pt++];if((128&s)>0)return void(pt=e);i[r]=s}return Mn.apply(String,i)}function HG(t){if(t<4){if(t<2){if(t===0)return"";{let e=ce[pt++];return(128&e)>1?void(pt-=1):Mn(e)}}{let e=ce[pt++],i=ce[pt++];if((128&e)>0||(128&i)>0)return void(pt-=2);if(t<3)return Mn(e,i);let r=ce[pt++];return(128&r)>0?void(pt-=3):Mn(e,i,r)}}{let e=ce[pt++],i=ce[pt++],r=ce[pt++],s=ce[pt++];if((128&e)>0||(128&i)>0||(128&r)>0||(128&s)>0)return void(pt-=4);if(t<6){if(t===4)return Mn(e,i,r,s);{let n=ce[pt++];return(128&n)>0?void(pt-=5):Mn(e,i,r,s,n)}}if(t<8){let n=ce[pt++],a=ce[pt++];if((128&n)>0||(128&a)>0)return void(pt-=6);if(t<7)return Mn(e,i,r,s,n,a);let o=ce[pt++];return(128&o)>0?void(pt-=7):Mn(e,i,r,s,n,a,o)}{let n=ce[pt++],a=ce[pt++],o=ce[pt++],l=ce[pt++];if((128&n)>0||(128&a)>0||(128&o)>0||(128&l)>0)return void(pt-=8);if(t<10){if(t===8)return Mn(e,i,r,s,n,a,o,l);{let h=ce[pt++];return(128&h)>0?void(pt-=9):Mn(e,i,r,s,n,a,o,l,h)}}if(t<12){let h=ce[pt++],u=ce[pt++];if((128&h)>0||(128&u)>0)return void(pt-=10);if(t<11)return Mn(e,i,r,s,n,a,o,l,h,u);let d=ce[pt++];return(128&d)>0?void(pt-=11):Mn(e,i,r,s,n,a,o,l,h,u,d)}{let h=ce[pt++],u=ce[pt++],d=ce[pt++],c=ce[pt++];if((128&h)>0||(128&u)>0||(128&d)>0||(128&c)>0)return void(pt-=12);if(t<14){if(t===12)return Mn(e,i,r,s,n,a,o,l,h,u,d,c);{let p=ce[pt++];return(128&p)>0?void(pt-=13):Mn(e,i,r,s,n,a,o,l,h,u,d,c,p)}}{let p=ce[pt++],m=ce[pt++];if((128&p)>0||(128&m)>0)return void(pt-=14);if(t<15)return Mn(e,i,r,s,n,a,o,l,h,u,d,c,p,m);let f=ce[pt++];return(128&f)>0?void(pt-=15):Mn(e,i,r,s,n,a,o,l,h,u,d,c,p,m,f)}}}}}function IX(){let t,e=ce[pt++];if(e<192)t=e-160;else switch(e){case 217:t=ce[pt++];break;case 218:t=ki.getUint16(pt),pt+=2;break;case 219:t=ki.getUint32(pt),pt+=4;break;default:throw new Error("Expected string")}return n2(t)}function MI(t){return Er.copyBuffers?Uint8Array.prototype.slice.call(ce,pt,pt+=t):ce.subarray(pt,pt+=t)}function nf(t){let e=ce[pt++];if(wa[e]){let i;return wa[e](ce.subarray(pt,i=pt+=t),r=>{pt=r;try{return Ys()}finally{pt=i}})}throw new Error("Unknown extension type "+e)}function Cft(){let t=ce[pt++];if(!(t>=160&&t<192))return pt--,Eft(Ys());if(t-=160,Gh>=pt)return em.slice(pt-ml,(pt+=t)-ml);if(!(Gh==0&&Jl<180))return O4(t);let e,i=4095&(t<<5^(t>1?ki.getUint16(pt):t>0?ce[pt]:0)),r=PU[i],s=pt,n=pt+t-3,a=0;if(r&&r.bytes==t){for(;s<n;){if(e=ki.getUint32(s),e!=r[a++]){s=1879048192;break}s+=4}for(n+=3;s<n;)if(e=ce[s++],e!=r[a++]){s=1879048192;break}if(s===n)return pt=s,r.string;n-=3,s=pt}for(r=[],PU[i]=r,r.bytes=t;s<n;)e=ki.getUint32(s),r.push(e),s+=4;for(n+=3;s<n;)e=ce[s++],r.push(e);let o=t<16?HG(t):Aft(t);return r.string=o??O4(t)}function Eft(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 Pft(t){kX&&kX();let e=Jl,i=pt,r=D4,s=ml,n=Gh,a=em,o=R4,l=fc,h=Ea,u=new Uint8Array(ce.slice(0,Jl)),d=Gi,c=Gi.slice(0,Gi.length),p=Er,m=gc,f=t();return Jl=e,pt=i,D4=r,ml=s,Gh=n,em=a,R4=o,fc=l,Ea=h,ce=u,gc=m,(Gi=d).splice(0,Gi.length,...c),Er=p,ki=new DataView(ce.buffer,ce.byteOffset,ce.byteLength),f}function MU(){ce=null,fc=null,Gi=null}function M3t(t){t.unpack?wa[t.type]=t.unpack:wa[t.type]=t}var AU,ce,Jl,pt,NX,R4,D4,Er,Gi,em,ml,Gh,Ea,fc,wa,ki,AI,Rft,gc,CU,BX,kX,a2,Dft,EU,O4,Oft,Ift,Nft,Mn,PU,RU,CI,VX,zX,LX,DU,FM,FX,UX,jX,OU,EI,$S,A3t=U(()=>{try{AU=new TextDecoder}catch{}pt=0,R4=NX=[],D4=0,Er={},ml=0,Gh=0,wa=[],AI={useRecords:!1,mapsAsObjects:!0},(Rft=new class{}).name="MessagePack 0xC1",gc=!1,CU=2,a2=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(ce)return Pft(()=>(MU(),this?this.unpack(t,e):a2.prototype.unpack.call(AI,t,e)));!t.buffer&&t.constructor===ArrayBuffer&&(t=typeof Buffer<"u"?Buffer.from(t):new Uint8Array(t)),typeof e=="object"?(Jl=e.end||t.length,pt=e.start||0):(pt=0,Jl=e>-1?e:t.length),D4=0,Gh=0,em=null,R4=NX,Ea=null,ce=t;try{ki=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(i){throw ce=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 a2){if(Er=this,this.structures)return Gi=this.structures,LM(e);(!Gi||Gi.length>0)&&(Gi=[])}else Er=AI,(!Gi||Gi.length>0)&&(Gi=[]);return LM(e)}unpackMultiple(t,e){let i,r=0;try{gc=!0;let s=t.length,n=this?this.unpack(t,s):FM.unpack(t,s);if(!e){for(i=[n];pt<s;)r=pt,i.push(LM());return i}if(e(n,r,pt)===!1)return;for(;pt<s;)if(r=pt,e(LM(),r,pt)===!1)return}catch(s){throw s.lastPosition=r,s.values=i,s}finally{gc=!1,MU()}}_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)}},Dft=/^[a-zA-Z_$][a-zA-Z\d_$]*$/,EU=(t,e)=>function(){let i=ce[pt++];if(i===0)return e();let r=t<32?-(t+(i<<5)):t+(i<<5),s=Gi[r]||Mft()[r];if(!s)throw new Error("Record id is not defined for "+r);return s.read||(s.read=TU(s,t)),s.read()},O4=n2,Oft=n2,Ift=n2,Nft=n2,Mn=String.fromCharCode,PU=new Array(4096),RU=(t,e)=>{let i=Ys().map(Eft),r=t;e!==void 0&&(t=t<32?-((e<<5)+t):(e<<5)+t,i.highByte=e);let s=Gi[t];return s&&(s.isShared||gc)&&((Gi.restoreStructures||(Gi.restoreStructures=[]))[t]=s),Gi[t]=i,i.read=TU(i,r),(i.read0||i.read)()},wa[0]=()=>{},wa[0].noBuffer=!0,wa[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),h=s(n,l),u=s(l,a);return h<<BigInt(8*(a-l))|u};i=i<<BigInt(8*(r.byteLength-e))|s(e,r.byteLength)}return i},CI={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError,AggregateError:typeof AggregateError=="function"?AggregateError:null},wa[101]=()=>{let t=Ys();if(!CI[t[0]]){let e=Error(t[1],{cause:t[2]});return e.name=t[0],e}return CI[t[0]](t[1],{cause:t[2]})},wa[105]=t=>{if(Er.structuredClone===!1)throw new Error("Structured clone extension is disabled");let e=ki.getUint32(pt-4);fc||(fc=new Map);let i,r=ce[pt];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)&&ce[pt+1]===115?new Set:{};let s={target:i};fc.set(e,s);let n=Ys();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},wa[112]=t=>{if(Er.structuredClone===!1)throw new Error("Structured clone extension is disabled");let e=ki.getUint32(pt-4),i=fc.get(e);return i.used=!0,i.target},wa[115]=()=>new Set(Ys()),VX=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(t=>t+"Array"),zX=typeof globalThis=="object"?globalThis:window,wa[116]=t=>{let e=t[0],i=Uint8Array.prototype.slice.call(t,1).buffer,r=VX[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 zX[r](i)},wa[120]=()=>{let t=Ys();return new RegExp(t[0],t[1])},LX=[],wa[98]=t=>{let e=(t[0]<<24)+(t[1]<<16)+(t[2]<<8)+t[3],i=pt;return pt+=e-t.length,Ea=LX,(Ea=[IX(),IX()]).position0=0,Ea.position1=0,Ea.postBundlePosition=pt,pt=i,Ys()},wa[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"),DU=new Array(147);for(let t=0;t<256;t++)DU[t]=+("1e"+Math.floor(45.15-.30103*t));(FM=new a2({useRecords:!1})).unpack,FM.unpackMultiple,FM.unpack,FX=new Float32Array(1),new Uint8Array(FX.buffer,0,4)}),C3t=U(()=>{A3t(),UG(),aD(),o0(),nD(),a0(),UX=[{Class:Ne.prototype.constructor,type:1,write:t=>({...t}),read:t=>(Object.setPrototypeOf(t,Ne.prototype),t)},{Class:ue.prototype.constructor,type:2,write:t=>[...t],read:t=>(Object.setPrototypeOf(t,ue.prototype),t)},{Class:Nn.prototype.constructor,type:3,write:t=>[...t],read:t=>(Object.setPrototypeOf(t,Nn.prototype),t)},{Class:A4.prototype.constructor,type:4,write:t=>t.id,read:t=>new A4(t)},{Class:wU.prototype.constructor,type:5,write:t=>t.data,read:t=>new wU(t)},{Class:Cs.prototype.constructor,type:6,write:t=>({...t}),read:t=>(Object.setPrototypeOf(t,Cs.prototype),t)}];for(let t of UX)M3t(t);jX=new a2({structuredClone:!0}),(OU||(OU={})).deserialize=function(t){return jX.unpack(t)}}),E3t=U(()=>{C3t(),EI=t=>()=>{throw new Error(t+" is not available in the runtime build (decode-only CollabSerialize)")},$S={deserialize:OU.deserialize,serialize:EI("CollabSerialize.serialize"),checksum:EI("CollabSerialize.checksum")}}),Li=U(()=>{oD(),_3t(),jG(),a0(),nD(),GG(),o0(),w3t(),S3t(),Tft(),T3t(),UG(),E3t(),bft(),aD()});function IU(t){return t==="MouseDown"||t==="MouseUp"||t==="KeyDown"||t==="KeyUp"||t==="Collision"||t==="Trigger"}var GX,NU,oS,UM,PI,WX,qX,HX,BU,kU,$X,XX,YX,KX,ZX,VU,zU,QX,JX,tY,eY,Bft=U(()=>{var t,e,i;Li(),ot(),(t=GX||(GX={})).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},NU={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 ue}:{type:s,disabled:!1,name:"",key:void 0,actions:new ue}}})(oS||(oS={})),(r=>{r.propertyDefaultData=function(s){return{type:"Property",value:[s??null,"position","x"]}},r.valueDefaultData={type:"Literal",value:0}})(UM||(UM={})),(e=PI||(PI={})).comparisonDefaultData=function(r){return{type:"Comparison",operator:"==",lOperand:UM.propertyDefaultData(r),rOperand:{...UM.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}},(WX||(WX={})).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 ue,outActions:new ue,condition:PI.distanceDefaultData(s)}}})(qX||(qX={})),(HX||(HX={})).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 ue,drop:new ue}},(BU||(BU={})).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 ue},(kU||(kU={})).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 ue}}})($X||($X={})),(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 ue}}})(XX||(XX={})),(r=>{r.is=function(s){return s.type==="Start"},r.defaultData=function(){return{type:"Start",disabled:!1,name:"",actions:new ue}}})(YX||(YX={})),(r=>{r.is=function(s){return s.type==="Collision"},r.defaultData=function(){return{type:"Collision",disabled:!1,name:"",target:"character",actions:new ue}}})(KX||(KX={})),(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 ue,triggerZone:"box",position:n.toArray(),rotation:[0,0,0],size:s.toArray(),radius:s.length()/2,helperVisible:!0}}})(ZX||(ZX={})),(i=VU||(VU={})).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 ue},s={size:"tablet",operator:"<",actions:new ue},n={size:[...i.defaultSizes.custom],operator:"<>",actions:new ue},a=new ue;return a.push({id:zt.generateUUID(),fi:0,data:r},{id:zt.generateUUID(),fi:1,data:s},{id:zt.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 ue}},(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 ue,variableId:"",objectId:null,property:"Position X"}}})(zU||(zU={})),(r=>{r.is=function(s){return s.type==="API"},r.defaultData=function(){return{disabled:!1,type:"API",name:"",successActions:new ue,errorActions:new ue,userAPIId:""}}})(QX||(QX={})),(r=>{r.is=function(s){return s.type==="WEBHOOK"},r.defaultData=function(){return{disabled:!1,type:"WEBHOOK",name:"",actions:new ue,userWebhookId:""}}})(JX||(JX={})),(r=>{r.is=function(s){return s.type==="AIAssistantListener"},r.defaultData=function(){return{disabled:!1,type:"AIAssistantListener",name:"",actions:new ue,analysis:"average",analysisRange:[0,71],analysisSingle:0}}})(tY||(tY={})),(r=>{r.is=function(s){return s.type==="AIAssistantTrigger"},r.defaultData=function(){return{disabled:!1,description:"",name:"",type:"AIAssistantTrigger",actions:new ue}}})(eY||(eY={}))});function iY(t){let e=typeof t;return t!==null&&(e==="object"||e==="function")}function LU(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 l0,mv,kft,i0,rY,Gu,fm,XS,sY,RI,_l,$s,qi,FU,nY,im,Fv,aY,oY,lY,hY,uY,dY,cY,pY,DI,mY,fY,OI,gY,yY,vY,II,bY,NI,_Y,xY,BI,wY,UU,SY,TY,MY,AY,CY,EY,r0,yc,rm,jU,GU,I4,N4,B4,k4,V4,WU,qU,z4,HU,fv,PY,kI,VI,$U,RY,L4,F4,zI,DY,XU,LI,OY,IY,NY,BY,Uv,kY,VY,zY,LY,lD,$G,Is,Qr,E1,Vft,jv,U4,wg,YU,XG,j4,G4,W4,hc,rR,Jn,FI,Kp,qo=U(()=>{var t,e,i,r,s,n,a,o;l0="personal camera",mv="a218fcc3-276b-49b9-b485-49037fd14f5f",kft=2500134,i0=5526619,(t=rY||{}).x="x",t.y="y",t.z="z",rY=t,(l=>{function h(c,p){return Math.pow(p[0]-c[0],2)+Math.pow(p[1]-c[1],2)}function u(c,p){return Math.sqrt(h(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=h,l.distance=u,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 u(c,d(c,p,m))},l.center=function(c,p){return[.5*(c[0]+p[0]),.5*(c[1]+p[1])]}})(Gu||(Gu={})),(e=fm||(fm={})).isEqual=function(l,h){return l[0]===h[0]&&l[1]===h[1]&&l[2]===h[2]},e.add=function(l,h){return[l[0]+h[0],l[1]+h[1],l[2]+h[2]]},e.sub=function(l,h){return[l[0]-h[0],l[1]-h[1],l[2]-h[2]]},e.div=function(l,h){return[l[0]/h[0],l[1]/h[1],l[2]/h[2]]},e.mul=function(l,h){return[l[0]*h[0],l[1]*h[1],l[2]*h[2]]},e.dist=function(l,h){return Math.hypot(l[0]-h[0],l[1]-h[1],l[2]-h[2])},e.lerp=function(l,h,u){return[l[0]+(h[0]-l[0])*u,l[1]+(h[1]-l[1])*u,l[2]+(h[2]-l[2])*u]},(i=XS||(XS={})).isEqual=function(l,h){return l[0]===h[0]&&l[1]===h[1]&&l[2]===h[2]&&l[3]===h[3]},i.lerp=function(l,h,u){return[l[0]+(h[0]-l[0])*u,l[1]+(h[1]-l[1])*u,l[2]+(h[2]-l[2])*u,l[3]+(h[3]-l[3])*u]},(l=>{let h=180/Math.PI,u=Math.PI/180;function d(p){return typeof p=="number"?p*h:p}function c(p){return typeof p=="number"?p*u: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])]}})(sY||(sY={})),(r=RI||(RI={})).identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],r.isEqual=function(l,h){for(let u=0;u<16;u++)if(l[u]!==h[u])return!1;return!0},r.simplify=function(l){return l??r.identity},r.applyMatrix4=function(l,h){let u=h.slice(0);for(let d=0,c=h.length;d<c;d+=3){let p=l[3]*h[d]+l[7]*h[d+1]+l[11]*h[d+2]+l[15];u[d]=(l[0]*h[d]+l[4]*h[d+1]+l[8]*h[d+2]+l[12])/p,u[d+1]=(l[1]*h[d]+l[5]*h[d+1]+l[9]*h[d+2]+l[13])/p,u[d+2]=(l[2]*h[d]+l[6]*h[d+1]+l[10]*h[d+2]+l[14])/p}return u},(l=>{l.zero=[0,0,0,0,0,0],l.INDEX_MAP=[4,8,1,9,2,6],l.toMatrix=function(h){let u=[...RI.identity];for(let d=0;d<6;d++)u[l.INDEX_MAP[d]]=h[d];return u},l.fromMatrix=function(h){return[h[l.INDEX_MAP[0]],h[l.INDEX_MAP[1]],h[l.INDEX_MAP[2]],h[l.INDEX_MAP[3]],h[l.INDEX_MAP[4]],h[l.INDEX_MAP[5]]]}})(_l||(_l={})),(s=$s||($s={})).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,h){return l.r===h.r&&l.g===h.g&&l.b===h.b},s.equalsFixed=function(l,h){return l.r.toFixed(2)===h.r.toFixed(2)&&l.g.toFixed(2)===h.g.toFixed(2)&&l.b.toFixed(2)===h.b.toFixed(2)},s.lerp=function(l,h,u){return{r:l.r+(h.r-l.r)*u,g:l.g+(h.g-l.g)*u,b:l.b+(h.b-l.b)*u}},s.is=function(l){return!!iY(l)&&"r"in l&&"g"in l&&"b"in l&&!("a"in l)},(n=qi||(qi={})).white={...$s.white,a:1},n.is=function(l){return!!iY(l)&&"r"in l&&"g"in l&&"b"in l&&"a"in l},n.transparent={...$s.white,a:0},n.from0to1=function(l){return{r:l[0],g:l[1],b:l[2],a:l[3]}},n.fromHexAndA=function(l,h){return{...$s.fromHex(l),a:h}},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,h){return $s.equals(l,h)&&l.a===h.a},n.equalsFixed=function(l,h){return $s.equalsFixed(l,h)&&l.a.toFixed(2)===h.a.toFixed(2)},n.lerp=function(l,h,u){return{r:l.r+(h.r-l.r)*u,g:l.g+(h.g-l.g)*u,b:l.b+(h.b-l.b)*u,a:l.a+(h.a-l.a)*u}},n.toStyle=function({r:l,g:h,b:u,a:d}=n.white){return`rgba(${255*l}, ${255*h}, ${255*u}, ${d})`},(FU||(FU={})).identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1],pivot:[0,0,0],pivotRotation:[0,0,0]},(a=nY||{})[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",nY=a,(im||(im={})).defaultData={mass:1,stiffness:80,damping:10,velocity:0},(Fv||(Fv={})).defaultData={control1:[.5,0],control2:[.5,1]},(o=aY||(aY={})).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]}),P3t=U(()=>{var t,e;Li(),Bft(),(oY||(oY={})).defaultData={type:"SwitchCamera",name:"",targetCamera:"",delay:0,animate:!0,duration:1e3,easing:4,runMode:"Normal"},(lY||(lY={})).defaultData={type:"SceneTransition",name:"",target:"",delay:0,duration:1,transition:"none"},(hY||(hY={})).defaultData={type:"Link",name:"",url:null,context:"tab"},(uY||(uY={})).defaultData={type:"Destroy",name:"",objects:[],delay:0},(dY||(dY={})).defaultData={type:"Particles",name:"",emitterObjectId:"",delay:0,emission:"start",triggerAfter:"any"},(cY||(cY={})).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"},(pY||(pY={})).defaultData={type:"Reset",name:"",delay:0},(DI||(DI={})).defaultData={interaction:"play",delay:0,volume:.5,loop:1},(t=mY||(mY={})).pauseDefaultData={interaction:"pause",delay:0},t.stopDefaultData={interaction:"stop",delay:0},(e=fY||(fY={})).defaultData={type:"Audio",name:"",...DI.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})=>{oS.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},(OI||(OI={})).defaultData={interaction:"play",delay:0,volume:.5,loop:1/0},(i=>{i.pauseDefaultData={interaction:"pause",delay:0},i.stopDefaultData={interaction:"stop",delay:0}})(gY||(gY={})),(i=>{i.defaultData={type:"Video",name:"",triggerAfter:"autoplay",...OI.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((oS.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})=>{(oS.is(n)||n.type==="Start")&&s.push(...i.getVideosByActions(n.actions))}),s}})(yY||(yY={})),(vY||(vY={})).defaultData=function(i){return{state:i,repeat:0,delay:0,delayDirection:"start-once",direction:"normal",duration:1e3,easing:4}},(II||(II={})).defaultData=function(){return{tweens:new ue,repeat:0,delay:0,delayDirection:"start-once",direction:"normal"}},(bY||(bY={})).defaultData=function(i){return{type:"Transition",name:"",runMode:"Once",object:i??null,...II.defaultData()}},(NI||(NI={})).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}})(_Y||(_Y={})),(xY||(xY={})).defaultData=function(i){return{type:"TimelineAnimation",name:"",...NI.defaultData(i)}},(BI||(BI={})).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}})(wY||(wY={})),(i=>{i.defaultData=function(r,s,n){return{type:"Animation",name:"",...BI.defaultData(r,s,n)}},i.isPause=function(r){return r.interaction==="pause"||r.interaction==="stop"}})(UU||(UU={})),(SY||(SY={})).defaultData={type:"SetVariable",name:"",variableId:"",expression:[]},(TY||(TY={})).defaultData=()=>({type:"Conditional",name:"",ifActions:new ue,elseActions:new ue,condition:[]}),(MY||(MY={})).defaultData={type:"DynamicVariablePlay",name:"",variableId:"",mode:"PlayPause",delay:0,pauseDelay:0},(AY||(AY={})).defaultData={type:"ClearLocalStorage",name:"",target:"all"},(CY||(CY={})).defaultData={name:"",type:"UserAPI"}}),R3t=U(()=>{var t;(t=EY||(EY={})).emptyAudio={data:Uint8Array.from(atob("UklGRjIAAABXQVZFZm10IBIAAAABAAEAQB8AAEAfAAABAAgAAABmYWN0BAAAAAAAAABkYXRhAAAAAA=="),e=>e.charCodeAt(0)),mimeType:"audio/wav",filename:"unknown"},t.maxSize=2e6}),zft=U(()=>{var t;(t=r0||(r0={})).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}})(yc||(yc={}))}),Lft=U(()=>{var t;(t=rm||(rm={})).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(GU.forEach(s=>{Object.assign(r,{[s]:i[s]??e[s]})}),r.radial={...e.radial},i.radial){let s=e.radial,n=i.radial;I4.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;N4.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;B4.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;k4.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;V4.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}})(jU||(jU={})),GU=["count"],I4=["radius","start","end","position","scale","rotation"],N4=["position","scale","rotation"],B4=["count","size"],k4=["count","position","scale","rotation"],V4=["strength","scale","rotation","position","movement","seed","freqScale"]}),Fft=U(()=>{var t;qo(),(t=WU||(WU={})).all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"],t.is=function(e){return t.all.includes(e)},(qU||(qU={})).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)}}),Uft=U(()=>{var t;(t=z4||(z4={})).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}}),jft=U(()=>{var t;(t=HU||(HU={})).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"]}),YG=U(()=>{(fv||(fv={})).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]}}),Gft=U(()=>{var t,e;(t=PY||{})[t.Front=0]="Front",t[t.Back=1]="Back",t[t.Double=2]="Double",PY=t,(e=kI||(kI={})).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)}})(VI||(VI={})),($U||($U={})).defaultData={...VI.defaultData,...kI.defaultData},(RY||(RY={})).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}}),Wft=U(()=>{var t;(t=L4||(L4={})).bytesFromFlattened=function(e){if(typeof e!="object"||e===null||Array.isArray(e)||ArrayBuffer.isView(e)||typeof e[0]!="number")return null;let i=Object.getPrototypeOf(e);if(i!==Object.prototype&&i!==null)return null;let r=Object.keys(e),s=new Uint8Array(r.length),n=e;for(let a=0;a<r.length;a++){let o=n[a];if(r[a]!==String(a)||typeof o!="number"||!Number.isInteger(o)||o<0||o>255)return null;s[a]=o}return s},t.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"}}),qft=U(()=>{var t;(t=F4||(F4={})).defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},t.maxSize=3e7}),yT=U(()=>{var t,e,i,r;Li(),qo(),Wft(),qft(),qo(),(zI||(zI={})).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"},(DY||(DY={})).is=function(s){return s==="luminance"||s==="r"||s==="g"||s==="b"||s==="a"},(XU||(XU={})).is=function(s){return typeof s=="object"&&s!==null&&s.image!=null},(LI||(LI={})).is=function(s){return s==="phong"||s==="toon"||s==="lambert"||s==="physical"},(e=OY||{})[e.Linear=0]="Linear",e[e.Radial=1]="Radial",e[e.Polar=2]="Polar",OY=e,IY=(s=>(s[s.RepeatWrapping=1e3]="RepeatWrapping",s[s.ClampToEdgeWrapping=1001]="ClampToEdgeWrapping",s[s.MirroredRepeatWrapping=1002]="MirroredRepeatWrapping",s))(IY||{}),NY=(s=>(s[s.NearestFilter=1003]="NearestFilter",s[s.LinearFilter=1006]="LinearFilter",s[s.LinearMipmapLinearFilter=1008]="LinearMipmapLinearFilter",s))(NY||{}),(t=BY||{})[t.UV=0]="UV",t[t.Planar=1]="Planar",t[t.Spherical=2]="Spherical",t[t.Cylindrical=3]="Cylindrical",t[t.Triplanar=4]="Triplanar",BY=t,(s=>{s.MAX=3,s.of=function(n){return typeof n=="number"&&Number.isInteger(n)&&n>=0&&n<=3?n:0},s.attributeName=function(n){return n===0?"uv":`uv${n}`}})(Uv||(Uv={})),(r=kY||{})[r.Simplex=0]="Simplex",r[r.SimplexFractal=1]="SimplexFractal",r[r.Ashima=2]="Ashima",r[r.Fbm=3]="Fbm",r[r.Perlin=4]="Perlin",r[r.Voronoi=5]="Voronoi",kY=r,(i=VY||{})[i.F1=0]="F1",i[i.F2=1]="F2",i[i.F2MinusF1=2]="F2MinusF1",i[i.SmoothBlend=3]="SmoothBlend",i[i.Edge=4]="Edge",i[i.Power=5]="Power",i[i.Lines=6]="Lines",i[i.Cells=7]="Cells",VY=i,zY=(s=>(s[s.Lights=0]="Lights",s[s.Static=1]="Static",s[s.Camera=2]="Camera",s))(zY||{}),LY=(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))(LY||{}),lD=["mode","gradientType","noiseType","tracingMode","mirror","displacementType","projection","cnormal","crop","axis","side","roughnessMapChannel","metalnessMap","metalnessMapChannel","normalMap","aoMap","aoMapChannel","emissiveMap","style"],$G=["wrapping","image","video","name","minFilter","magFilter"],(s=>{function n(a,o){return a==="light"&&o?function(l){let h={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(l){case"phong":return{...h,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...h,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...h,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...h,category:"physical",roughness:.6,metalness:.2,reflectivity:.2,type:"light",alpha:.6,visible:!0,mode:0,occlusion:!0}}}(o):function(l){let h={alpha:1,mode:0,isMask:!1,visible:!0};switch(l){case"texture":return{...h,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{...h,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:F4.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006},crop:!1};case"color":return{...h,type:"color",color:$s.fromHex(i0)};case"vertexColor":return{...h,type:"vertexColor"};case"depth":return{...h,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{...h,type:"normal",cnormal:[1,1,1]};case"gradient":return{...h,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{...h,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...$s.fromHex(6710886),a:1},colorB:{...$s.fromHex(6710886),a:1},colorC:{...$s.fromHex(16777215),a:1},colorD:{...$s.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{...h,type:"cavity",mode:3,ridge:1,valley:1};case"fresnel":return{...h,type:"fresnel",color:qi.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"dust":return{...h,type:"dust",color:qi.fromHexAndA(10323813,1),coverage:.2,softness:.2,noiseStrength:.2,noiseScale:1};case"rainbow":return{...h,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...h,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{...h,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{...h,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006}};case"transmission":return{...h,type:"transmission",thickness:10,ior:1.5,roughness:1};case"reflection":return{...h,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{...h,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...$s.fromHex(0),a:1},colorB:{...$s.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}}}(a)}s.patch=function(a,o){let{texture:l,...h}=o;if(Object.assign(a,h),l){let u=a.texture;u&&Object.assign(u,l)}},s.defaultColorLayer=function(a){return{...s.defaultData("color"),color:a}},s.defaultData=n,s.defaultDataFor=function(a,o){return a!=="light"?n(a):n("light",typeof o=="string"&&LI.is(o)?o:"physical")}})(Is||(Is={})),(s=>{function n(l,h){if(typeof l!="string"||!/^#[0-9a-f]{6}([0-9a-f]{2})?$/i.test(l))return l;let{r:u,g:d,b:c}=$s.fromHex(parseInt(l.slice(1,7),16)),p=l.length===9?parseInt(l.slice(7),16)/255:void 0;if(Array.isArray(h))return h.length>3?[u,d,c,p??h[3]]:[u,d,c];let m=h;return typeof m?.r!="number"?l:typeof m.a=="number"?{r:u,g:d,b:c,a:p??m.a}:{r:u,g:d,b:c}}function a(l){let h=l?.data;return typeof h=="object"&&h!==null}function o(l,h="layer1",u="layer2",d=$s.fromHex(16777215)){let c=new ue;return c.push({fi:0,data:Is.defaultData("light",l),id:h}),c.push({fi:1,data:Is.defaultData("color"),id:u}),{layers:c}}s.restoreImageBytes=function(l){let h=[],u=new Map,d=(p,m)=>{let f=Q1(p);if(typeof f!="object"||f===null||ArrayBuffer.isView(f))return p;if(u.has(f))return u.get(f)??p;u.set(f,void 0);let g=c(f,m)??p;return u.set(f,g),g},c=(p,m)=>{let f=p;if(!Array.isArray(p)){if(typeof f[0]=="number")return;if(typeof f.name=="string"){let y=L4.bytesFromFlattened(Q1(f.data));if(y!==null)return h.push({path:`${m}/data`,bytes:y.byteLength}),Object.setPrototypeOf({...f,data:y},Object.getPrototypeOf(p))}}let g=null;for(let y of Object.keys(p)){let v=f[y],b=d(v,`${m}/${y}`);b!==v&&(g===null&&(g=Array.isArray(p)?[...p]:{...f},Object.setPrototypeOf(g,Object.getPrototypeOf(p))),g[y]=b)}return g??void 0};return{material:d(l,""),restored:h}},s.restoreLayersSeq=function(l){let h=Q1(l.layers);if(!Array.isArray(h)||h instanceof ue||!h.every(c=>typeof c=="object"&&c!==null&&typeof c.id=="string"&&typeof c.data=="object"))return{material:l,restored:!1};let u=Object.setPrototypeOf([...h],ue.prototype),d=Q1(l);return{material:Object.setPrototypeOf({...d,layers:u},Object.getPrototypeOf(d)),restored:!0}},s.isMergable=function(l){return!l.layers.some(h=>h.data.type==="texture"&&h.data.projection!==0||h.data.type==="depth"&&!h.data.isWorldSpace||h.data.type==="noise"||h.data.type==="dust"&&h.data.noiseStrength!==0||h.data.type==="displace")},s.getHash=function(l){let h="";return l.layers.forEach(u=>{Object.entries(u.data).forEach(([d,c])=>{h+=`${d}${c}`,Array.isArray(c)?c.forEach(p=>h+=`${p}`):typeof c=="object"?Object.values(c).forEach(p=>{h+=typeof p=="number"?`${p.toFixed(4)}`:`${p}`}):h+=`${c}`})}),h},s.defaultEmptyData=function(){return{layers:new ue}},s.defaultData=function(l="layer1",h="layer2"){return o("physical",l,h)},s.withName=function(l,h){return{...l,name:h}},s.isLayerEntry=a,s.withRepairedLayers=function(l){if(l.layers===void 0)return{...l,layers:o("phong").layers};let h=Array.from(l.layers);if(h.every(a))return l;let u=new ue;return h.forEach((d,c)=>{if(a(d))return void u.push(d);let{id:p,fi:m,...f}=d??{};if(typeof f.type!="string"||!zI.is(f.type))return;let g=Is.defaultDataFor(f.type,f.category),y={...g,...f};for(let[v,b]of Object.entries(f)){let _=g[v];y[v]=Array.isArray(b)&&Array.isArray(_)&&Array.isArray(_[0])?b.map(x=>n(x,_[0])):n(b,_)}u.push({id:typeof p=="string"&&p?p:`layer${c+1}`,fi:typeof m=="number"?m:c,data:y})}),{...l,layers:u}},s.defaultTwoLayerData=o,s.defaultColorMaterial=function(l,h,u="layer1",d="layer2"){let c=new ue;return c.push({fi:0,data:Is.defaultData("light",h),id:u}),c.push({fi:1,data:Is.defaultColorLayer(l),id:d}),{layers:c}},s.defaultUIObjectMaterial=function(l){let h=Is.defaultData("texture");l&&Object.assign(h.texture,{image:l});let u=new ue;return u.push({fi:0,data:h,id:"layer1"}),u.push({fi:1,data:{...Is.defaultData("transmission"),alpha:1},id:"layer2"}),u.push({fi:2,data:{...Is.defaultData("light","lambert"),alpha:0},id:"layer3"}),{layers:u}},s.defaultTwoLayerTextureData=function(l,h="physical",u="layer1",d="layer2"){let c=Is.defaultData("texture");Object.assign(c.texture,{image:l});let p=new ue;return p.push({fi:0,data:c,id:u}),p.push({fi:1,data:Is.defaultData("light",h),id:d}),{layers:p}},s.defaultTwoLayerVideoTextureData=function(l,h="physical",u="layer1",d="layer2"){let c=Is.defaultData("video");Object.assign(c.texture,{video:l});let p=new ue;return p.push({fi:0,data:c,id:u}),p.push({fi:1,data:Is.defaultData("light",h),id:d}),{layers:p}}})(Qr||(Qr={}))}),D3t=U(()=>{E1="Roboto_regular",Vft="https://fonts.gstatic.com/s/roboto/v30/KFOmCnqEu92Fr1Me5WZLCzYlKw.ttf"}),O3t=U(()=>{D3t()}),Hft=U(()=>{var t;Li(),(t=jv||(jv={})).defaultData=function(){return{points:new ue,roundness:0,shapeHoles:[],isClosed:!1}},t.scaled=function e(i,r,s){let n=a=>[a[0]*r,a[1]*s];return{...i,points:new ue(...i.points.map(({id:a,fi:o,data:l})=>({id:a,fi:o,data:{...l,position:n(l.position),controlPrevious:{position:n(l.controlPrevious.position)},controlNext:{position:n(l.controlNext.position)}}}))),shapeHoles:i.shapeHoles.map(a=>e(a,r,s))}}}),$ft=U(()=>{Li(),(U4||(U4={})).defaultData=function(){return{points:new ue,lastInsertionPlane:null,subdivisions:12,isClosed:!1,subdivisionMode:"parametric"}},wg={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0},(YU||(YU={})).merge=function(t,e){let i={...t};return j4.forEach(r=>{Object.assign(i,{[r]:e[r]??t[r]})}),i},XG={shape:wg,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},j4=["depth","offset","angle","twist","startScale","endScale"]}),KG=U(()=>{var t,e;Hft(),$ft(),(t=G4||(G4={})).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"},(W4||(W4={})).merge=function(i,r){let s={...i};if(Object.assign(s,r),s.type==="PathGeometry"&&"extrusion"in r&&r.extrusion&&(s.extrusion={...i.extrusion},Object.assign(s.extrusion,YU.merge(s.extrusion,r.extrusion))),i.type==="VectorGeometry"&&s.type==="VectorGeometry"){let n=(l,h)=>typeof l=="number"&&typeof h=="number"&&h!==0?l/h:1,a=n(s.width,i.width),o=n(s.height,i.height);(a!==1||o!==1)&&(s.shape=jv.scaled(i.shape,a,o))}return s},(e=hc||(hc={})).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:U4.defaultData(),extrusion:XG};if(i==="VectorGeometry")return{width:1,height:1,type:i,subdivisions:12,shape:jv.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")},rR=["width","height","depth"]}),Xft=U(()=>{qo(),(t=>{function e(i){return i.mode??"linear"}t.defaultData={enabled:!1,useBackgroundColor:!1,color:$s.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}})(Jn||(Jn={}))}),ZG=U(()=>{(FI||(FI={})).defaultData={image:null,rotation:0,blur:32,showBackground:!0},(Kp||(Kp={})).defaultData={enabled:!1,mode:"hdri",hdri:FI.defaultData,timeOfDay:10,weather:"partlyCloudy",lighting:!0,lightingIntensity:1,lightingQuality:"full",clouds:!0,windSpeed:2,animateWind:!0,exposure:1,seed:2}});function I3t(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 q4,gv,UI,jI,GI,yv,WI,KU,ZU,FY,G0,Yft,an,H4,UY,jY,GY,WY,Iu,lS,$4,X4,vc,Hg,qY,sm,Y4,bc,qI,HI,Pg,s0,Rg,hS,QU,HY,Pa,$I,$Y,XY,uc,Zl,vv,Kft=U(()=>{(()=>{let t={opacity:1,blendFunction:13,enabled:!1};(q4||(q4={})).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}}})()}),QG=U(()=>{var t;Xft(),ZG(),Kft(),qo(),(t=gv||(gv={})).defaultData={type:"normal",softShadowQuality:"low"},t.isSoft=function(e){return e!=null&&(e.type===void 0||e.type==="soft")},(UI||(UI={})).defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75},(jI||(jI={})).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}})(GI||(GI={})),(yv||(yv={})).defaultData={usePhysics:!1,gravity:-10},(WI||(WI={})).defaultData={playCamera:l0,gameControlObject:null},(KU||(KU={})).defaultData={backgroundColor:qi.fromHexAndA(kft,1),postprocessing:q4.defaultData,fog:Jn.defaultData,sky:Kp.defaultData,globalPhysics:yv.defaultData,ambient:UI.defaultData,ao:jI.defaultData,shadow:gv.defaultData,publish:WI.defaultData,grading:GI.defaultData}}),N3t=U(()=>{(ZU||(ZU={})).defaultData={colliderType:"box",size:[100,100,100],colliderHelperVisible:!0,forceType:"collider",forceRange:"global",forceIntensity:.5,forceDambing:.95}}),hD=U(()=>{var t,e,i;Li(),zft(),Fft(),Uft(),jft(),YG(),Gft(),qo(),yT(),KG(),Lft(),dn(),QG(),N3t(),(t=FY||(FY={})).isComponentRelated=function(r){return r==="Component"||r==="Instance"},t.isEmptyOrComponent=function(r){return r==="Empty"||r==="Instance"},(e=G0||(G0={})).identity={...FU.identity,shear:_l.zero},e.fromObject=function(r){return{position:r.position,rotation:r.rotation,scale:r.scale,pivot:r.pivot,pivotRotation:r.pivotRotation,shear:r.shear}},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,shear:s?.shear||r.shear}},e.diff=function(r,s){return fft({position:fm.isEqual(r.position,s.position)?void 0:s.position,rotation:fm.isEqual(r.rotation,s.rotation)?void 0:s.rotation,scale:fm.isEqual(r.scale,s.scale)?null:s.scale,shear:s.shear?.every((n,a)=>n===r.shear?.[a])?void 0:s.shear})},Yft=["slide","offset"],(an||(an={})).defaultData={states:new ue,events:new ue,visible:!0,raycastLock:!1,physics:fv.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...G0.identity,cloner:null},(H4||(H4={})).defaultData={type:"Empty",...an.defaultData},(UY||(UY={})).defaultData={type:"ParticleCollider",...ZU.defaultData,...an.defaultData},(jY||(jY={})).defaultData={type:"Component",...an.defaultData},(GY||(GY={})).defaultData={type:"Particle",...an.defaultData,...z4.defaultData},(WY||(WY={})).defaultData={type:"Hair",...an.defaultData,...HU.defaultData},(Iu||(Iu={})).defaultData={type:"Mesh",...an.defaultData,...$U.defaultData},(lS||(lS={})).defaultData={...an.defaultData,...G0.identity,position:yc.DefaultPosition,rotation:yc.DefaultRotation,...yc.defaultData},(r=>{r.defaultData=function(s){return{...an.defaultData,...qU.defaultData(s)}},r.defaultDirectionalLightData={...r.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})($4||($4={})),(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 h=Object.keys(l);if(h.length===1&&h[0]==="descendants")return}return l}})(X4||(X4={})),(r=>{function s(n,a){return{...an.defaultData,...a,component:n,overrides:new Cs,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=G0.fromObject(n.data);return s(n.id,a)}})(vc||(vc={})),(r=>{r.defaultData={type:"Page",...an.defaultData,physics:{...fv.defaultData,fusedBody:!1},...KU.defaultData,camera:lS.defaultData,timelines:new Ne},r.isUIPage=function(s){return s.uiScene!==void 0}})(Hg||(Hg={})),(i=qY||(qY={})).defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],pivot:[0,0,0],pivotRotation:[0,0,0],shear:_l.zero,name:"Play Camera",visible:!0,raycastLock:!1,physics:fv.defaultData,states:new ue,events:new ue,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...yc.defaultData},i.KeysByResetCategory={States:["states"],Events:["events"],Material:["material","materials"],Geometry:["geometry"],Position:["position"],Rotation:["rotation"],Scale:["scale"],Transform:["position","scale","rotation","shear"],Name:["name"],Visibility:["visible","raycastLock","flatShading","wireframe","side","shadowCatcher"],Shadows:["castShadow","receiveShadow"],Cloner:["cloner"],Physics:["physics"]},i.defaultMeshObject={name:"Rectangle",...an.defaultData,...Iu.defaultData,geometry:hc.defaultData("RectangleGeometry"),material:Qr.defaultTwoLayerData("physical","layer1","layer2")},i.defaultBooleanObject={name:"Boolean",...an.defaultData,...Iu.defaultData,geometry:hc.defaultData("BooleanGeometry"),material:Qr.defaultTwoLayerData("physical","layer1","layer2")},i.defaultShapeBlendObject={name:"Shape Blend",...an.defaultData,...Iu.defaultData,geometry:hc.defaultData("ShapeBlendGeometry"),material:Qr.defaultTwoLayerData("physical","layer1","layer2")},i.defaultTextObject={name:"Text",...an.defaultData,...Iu.defaultData,geometry:hc.defaultData("TextGeometry"),material:Qr.defaultTwoLayerData("physical","layer1","layer2")},i.defaultInputObject={name:"Input",...an.defaultData,...Iu.defaultData,geometry:hc.defaultData("InputGeometry"),material:Qr.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 Cs}),"materials"in s&&(a.materials=s.materials.map(o=>({layers:new Cs})))):r0.is(s.type)&&(a.perspective={},a.orthographic={}),a},r.toOps=function(s,n){let a,o=[],l={orthographic:0,perspective:0,geometry:0};function h(u,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:[...u,"layers",c,"texture"],props:m,type:0};o.push(g)}if(Object.keys(f).length>0){let g={path:[...u,"layers",c],props:f,type:0};o.push(g)}}}for(let[u,d]of Object.entries(n)){let c=d;if(u!=="name")if(u==="cloner")o.push(...jU.toOps(c,["cloner"]));else if(u==="pathSnapping")o.push({path:[u],props:{slide:c.slide,offset:c.offset},type:0});else if(u==="material")h(["material"],c);else if(u==="materials")for(let[p,m]of Object.entries(c))h(["materials",p],m);else if(l[u]===0){if(u==="geometry"&&c.extrusion!==void 0){let p={path:[u,"extrusion"],props:c.extrusion,type:0};o.push(p),c={...c},delete c.extrusion}if(Object.keys(c).length>0){let p={path:[u],props:c,type:0};o.push(p)}}else a===void 0&&(a={path:[],props:{},type:0},o.push(a)),a.props[u]=c}return o},r.patch=function(s,n){if(n===void 0)return s;let a={...s};if(Object.assign(a,G0.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})}),r0.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:W4.merge(a.geometry,n.geometry)}),(n.material||n.materials)&&(a=function(o,l){if(l===void 0)return o;let h={...o};return"material"in h&&"material"in l&&l.material&&(h.material=E4(h.material,u=>{if(typeof u!="string")for(let[d,c]of Object.entries(l.material.layers)){let p=u.layers.data(d);p&&Is.patch(p,c)}}).data),h.materials&&l.materials&&(h.materials=E4(h.materials,u=>{for(let d=0;d<h.materials.length;d++){let c=l.materials[d];if(typeof c!="string")for(let[p,m]of Object.entries(c.layers)){let f=u[d]?.layers?.data(p);f&&Is.patch(f,m)}}}).data),h}(a,n)),a.cloner&&"cloner"in n&&Object.assign(a,{cloner:rm.merge(a.cloner,n.cloner)});else if(s.type==="Empty")a.cloner&&"cloner"in n&&Object.assign(a,{cloner:rm.merge(a.cloner,n.cloner)});else if(WU.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=$s.clone(o.color))}return a}})(sm||(sm={}))}),JG=U(()=>{(Y4||(Y4={})).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}}),uD=U(()=>{JG(),qo(),(bc||(bc={})).defaultData={orbitControls:Y4.defaultData,playPage:mv,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}}),Zft=U(()=>{var t;(qI||(qI={})).defaultData={id:"basic",label:"Basic",style:"None",prompt:""},(HI||(HI={})).defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0},(t=Pg||(Pg={})).defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...qI.defaultData},isRandomSeed:!0,seed:t.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:HI.defaultData}),t.generateSeed=()=>Math.round(1e5*Math.random())}),tW=U(()=>{hD(),Li(),uD(),qo(),dn(),Zft(),(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)})}})(s0||(s0={})),(t=>{function e(r=!0,s=[]){let n=[];r&&n.push({...t.defaultLight}),n.push(...s);let a=new Nn;return a.push({fi:1,id:mv,data:{...Hg.defaultData,name:"Scene 1"},children:n}),a}function i(r){return{...t.defaultData,objects:qa(r,Nn.prototype)}}t.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222",t.defaultLight={fi:-1,data:$4.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]},t.createDefaultObjectTreeWithPage=e,t.defaultData={objects:e(),publish:bc.defaultData,styles:Pg.defaultData()},t.emptyDataWithoutPage=function(){return{objects:new Nn,publish:bc.defaultData,styles:Pg.defaultData()}},t.emptyDataWithPage=function(r=!0){return{objects:e(r),publish:bc.defaultData,styles:Pg.defaultData()}},t.emptyData=function(){return{objects:new Nn,publish:{...bc.defaultData},styles:Pg.defaultData()}},t.withObjs=i,t.withObj=function(r,s){return i([{id:r,data:s,children:[],fi:0}])}})(Rg||(Rg={}))}),Qft=U(()=>{(hS||(hS={})).defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}}}),eW=U(()=>{var t,e;Li(),dn(),(t=QU||(QU={})).defaultData=i=>({url:i,name:"New Webhook",parametersSchemas:new ue}),t.defaultParameterValueByType=i=>i==="number"?0:i!=="boolean"&&"",(HY||(HY={})).defaultData=(i,r="GET")=>({url:i,method:r,name:"New API",headers:new ue,queries:new ue,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()}})(Pa||(Pa={})),($I||($I={})).all=["images","videos","colors","audios","particles","fonts","materials","variables"],($Y||($Y={})).all=[...$I.all,"components"],(XY||(XY={})).defaultData=function(){return{images:new Ne,videos:new Ne,colors:new Ne,audios:new Ne,particles:new Ne,fonts:new Ne,materials:new Ne,components:new Ne,variables:new Ne,userAPIs:new Ne,userWebhooks:new Ne}},(uc||(uc={})).defaultData=function(){return{images:new Ne,videos:new Ne,colors:new Ne,audios:new Ne,particles:new Ne,fonts:new Ne,materials:new Ne,components:new Ne,variables:new Ne,userAPIs:new Ne,userWebhooks:new Ne}},(e=Zl||(Zl={})).defaultColors=function(){return qa({"89b10010-844c-11ec-a8a3-0242ac120002":{r:.5,g:.5,b:.5,a:1,name:"Default Color"}},Ne.prototype)},e.defaultImages=function(){return qa({},Ne.prototype)},e.emptyData=function(){return{catelogs:new Ne,materials:new Ne,images:new Ne,videos:new Ne,colors:new Ne,audios:new Ne,particles:new Ne,fonts:new Ne,variables:new ue,userAPIs:new Ne,userWebhooks:new Ne,lib:uc.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}}),B3t=U(()=>{}),Jft=U(()=>{var t;Li(),tW(),Qft(),eW(),(t=vv||(vv={})).defaultData={schema:136,scene:Rg.defaultData,frames:new Ne().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",hS.defaultData),shared:{...Zl.emptyData(),colors:Zl.defaultColors()}},t.createDefaultData=function(){return $S.deserialize($S.serialize(t.defaultData))},t.emptyDataForImports=function(){return{schema:136,scene:Rg.emptyDataWithPage(),frames:new Ne().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",hS.defaultData),shared:{...Zl.emptyData(),colors:Zl.defaultColors(),images:Zl.defaultImages()}}},t.emptyData=function(){return{schema:136,scene:Rg.emptyDataWithPage(),frames:new Ne().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",hS.defaultData),shared:Zl.emptyData()}},t.clipboard2dData=function(){return{schema:136,scene:Rg.emptyData(),frames:new Ne,shared:Zl.emptyData()}},t.withoutLib=function(e){return{...e,shared:{...e.shared,lib:uc.defaultData()}}},t.getComponentData=function(e,i){return s0.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}});function Cc(t,e=[0,0]){return[t&&!isNaN(t[0])?t[0]:e[0],t&&!isNaN(t[1])?t[1]:e[1]]}function f_(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??{...Fv.defaultData};return`cubicBezier( ${r[0]}, ${r[1]}, ${s[0]}, ${s[1]} )`}case 6:{let{mass:r,stiffness:s,damping:n,velocity:a}=i??{...im.defaultData},o=new tgt(r,s,n,a),l=o.solve(1);return()=>h=>o.solve(h)/l}case 8:return()=>r=>Math.floor(r)}}function k3t(t){let e=function(r){return r.layers?.find(({data:s})=>s.type==="light")}(t);if(!e)return;let i=e.data.alphaOverride;return typeof i=="number"?i:1}function V3t(t,e,i){return i>0?t*e/i:t}var YY,KY,gm,YS,tgt,K4,Z4,iW=U(()=>{Li(),qo(),(YY||(YY={})).defaultData=function(t,e){return{id:t,name:e,duration:5,objectTimelines:new Ne}},(KY||(KY={})).is=function(t){return t&&typeof t.x=="number"&&typeof t.y=="number"&&typeof t.z=="number"},(t=>{function e(u,d){let c=[0,0],p=[1,1];if(u?.cubicControls)c=Cc(u.cubicControls.control1,c);else switch(u?.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=Cc(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(u){if(!t.BEZIER_PRESETS.includes(u))return;let d={type:u};return{control1:e(d).control1,control2:e(void 0,d).control2}}function r(u,d){return Math.abs(u[0]-d[0])<.001&&Math.abs(u[1]-d[1])<.001}function s(u){let d=t.ROOT_PROPERTY_ORDER.indexOf(u[0]);return d===-1?t.ROOT_PROPERTY_ORDER.length:d}function n(u){return u.layerId??u.path.join(".")}function a(u){let d=u[u.length-1];return YS.includes(d)?d:void 0}function o(u){return u.layerId?u.layerId:(a(u.path)?u.path.slice(0,-1):u.path).join(".")}function l(u){return["material",u.type==="light"?`${u.category} lighting`:u.type]}function h(u,d,c){return{id:u,data:{id:u,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(u){return t.BEZIER_PRESETS.find(d=>{let c=i(d);return c!==void 0&&r(c.control1,u.control1)&&r(c.control2,u.control2)})},t.defaultData=function(u){return{id:u,keyframes:new ue}},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(u,d){let c=new Map;for(let p of u){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(u){let d=new Map;for(let c of u){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(u){return[...u].sort((d,c)=>d.data.time-c.data.time)},t.materialLayerPath=l,t.createMaterialGroup=function(u,d){return u.map(({data:c,id:p},m)=>h(d(),l(c),{layerId:p,index:m}))},t.placeholderKeyframe=h,t.createName=function(u){return Object.entries(u).reduce((d,[c,p])=>(typeof p!="string"&&d.push({name:p.name}),d),[])},t.Presets=[{name:"Slide in",animationParams:{translateX:{value:[-20,0],easing:f_(3),duration:1e3},opacity:{value:[0,1],easing:f_(3),duration:1e3},endDelay:250,loop:!0}},{name:"Rotate",animationParams:{rotate:{value:[0,"1turn"],easing:f_(5),duration:700},endDelay:250,loop:!0}},{name:"Scale Out",animationParams:{scale:{value:[1,1.5],easing:f_(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:f_(5),duration:500},endDelay:500,loop:!0}},{name:"Bounce",animationParams:{translateY:{value:["20px","-20px"],duration:575,easing:"easeOutQuad"},direction:"alternate",loop:!0}}]})(gm||(gm={})),YS=["x","y","z"],tgt=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}}}),rW=U(()=>{var t;qo(),Li(),(K4||(K4={})).list=["idle","move","jump","run"],(t=Z4||(Z4={})).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 ue,move:new ue,jump:new ue,run:new ue},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 dg(t,...e){let i={};for(let r of e.flat())t!=null&&r in t&&(i[r]=t[r]);return i}function ZY(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={...dg(Os(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={...Os(e),near:Math.max(e.near,0),far:Math.max(e.far,0)};Object.assign(e,i)}})}function Zd(t,e){Object.values(t.shared.materials).forEach(i=>e(i))}function Qd(t,e){t.scene.objects.traverse((i,r)=>{"materials"in r?r.materials.forEach((s,n)=>{s===void 0&&(r.materials[n]=Qr.defaultTwoLayerData("phong"),s=r.materials[n]),typeof s!="string"&&e(s)}):"material"in r?typeof r.material!="string"&&(r.material===void 0&&(r.material=Qr.defaultTwoLayerData("phong")),e(r.material)):r.type==="Mesh"&&(r.material===void 0&&(r.material=Qr.defaultTwoLayerData("phong")),e(r.material)),"overrides"in r&&Object.values(r.overrides).forEach(s=>{s.material&&typeof s.material!="string"&&Object.getPrototypeOf(s.material)!==Cs.prototype&&e(s.material)})})}function QY(t){t.layers===void 0&&Object.assign(t,Qr.defaultTwoLayerData("lambert"))}function XI(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={...Os(e),colors:i,steps:r};Object.assign(e,s)}})}function JY(t){t.scene.objects.traverse((e,i)=>{"materials"in i?i.materials.forEach(r=>{typeof r!="string"&&XI(r)}):"material"in i&&typeof i.material!="string"&&XI(i.material)}),Object.values(t.shared.materials).forEach(e=>XI(e))}function tK(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 eK(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 iK(t){let e=t.layers.find(i=>i.type==="light")?.data;if(e?.category==="basic"){let i=Is.defaultData("light","phong"),r=e;Object.assign(r,i),r.visible=!1}}function rK(t){Zd(t,iK),Qd(t,iK)}function sK(t){t.layers.forEach(e=>{e.type==="light"&&e.category!=="toon"&&e.occlusion===void 0&&(e.occlusion=!0)})}function nK(t){t.layers&&t.layers.forEach(e=>{e.type==="light"&&e.bumpMapIntensity===void 0&&(e.bumpMapIntensity=5)})}var z3t=U(()=>{yT(),qo(),JG(),hD(),Li(),uD(),dn(),ot(),KG(),rW(),Zft(),tW(),YG(),QG()});function egt(t){let e=t.elements;Fh.set(e[0],e[1],e[2]),Uh.set(e[4],e[5],e[6]),Bu.set(e[8],e[9],e[10])}function igt(){let t=Math.max(Fh.lengthSq(),Uh.lengthSq(),Bu.lengthSq());Fh.lengthSq()>o2*t?fl.copy(Fh).normalize():fl.set(1,0,0),gl.crossVectors(Bu,fl),gl.lengthSq()<=o2*t&&(gl.copy(Uh).addScaledVector(fl,-Uh.dot(fl)),gl.lengthSq()<=o2*t&&function(e,i){e.set(1,0,0).cross(i),e.lengthSq()<=o2&&e.set(0,1,0).cross(i),e.normalize()}(gl,fl)),gl.normalize(),Dg.crossVectors(fl,gl)}function rgt(t,e,i){return egt(t),igt(),e.makeBasis(fl,gl,Dg),i.set(fl.dot(Fh),fl.dot(Uh),fl.dot(Bu),0,gl.dot(Fh),gl.dot(Uh),gl.dot(Bu),0,Dg.dot(Fh),Dg.dot(Uh),Dg.dot(Bu),0,0,0,0,1),function(){let r=Fh.length(),s=Uh.length(),n=Bu.length(),a=Math.max(r,s,n);if(a-r>l2||a-s>l2||a-n>l2)return!0;let o=l2*a*a;return Math.abs(Fh.dot(Uh))>o||Math.abs(Fh.dot(Bu))>o||Math.abs(Uh.dot(Bu))>o}()}function sgt(t){return egt(t),igt(),ngt.makeBasis(fl,gl,Dg)}var Fh,Uh,Bu,fl,gl,Dg,ngt,o2,l2,dD=U(()=>{ot(),Fh=new E,Uh=new E,Bu=new E,fl=new E,gl=new E,Dg=new E,ngt=new bt,o2=1e-12,l2=.01});function W0(t,e){return e===0?0:t/e}function sW(t){rgt(t,tj,JU),J1.setFromRotationMatrix(tj);let e=function(r,s,n){let a=2*Math.PI,o=d=>d-a*Math.round(d/a),l=o(r+Math.PI),h=o(Math.PI-s),u=o(n+Math.PI);return Math.abs(l)+Math.abs(u)<Math.abs(r)+Math.abs(n)-1e-9?[l,h,u]:[r,s,n]}(J1.x,J1.y,J1.z),i=JU.elements;return{position:[t.elements[12],t.elements[13],t.elements[14]],rotation:[e[0]*zt.RAD2DEG,e[1]*zt.RAD2DEG,e[2]*zt.RAD2DEG],scale:[i[0],i[5],i[10]],shear:[W0(i[4],i[5]),W0(i[8],i[10]),W0(i[1],i[0]),W0(i[9],i[10]),W0(i[2],i[0]),W0(i[6],i[5])]}}function _c(t,{translation:e,quaternion:i,scale:r,shearMatrix:s}={}){let n=sW(t);if(e!==void 0&&e.fromArray(n.position),i!==void 0){let a=n.rotation;i.setFromEuler(J1.set(a[0]*zt.DEG2RAD,a[1]*zt.DEG2RAD,a[2]*zt.DEG2RAD))}r!==void 0&&r.fromArray(n.scale),s!==void 0&&s.fromArray(_l.toMatrix(n.shear))}var JU,tj,J1,vT=U(()=>{ot(),dD(),zgt(),JU=new bt,tj=new bt,J1=new zi});function agt(t){return t.length>=4&&function(e){return typeof e=="object"&&e!==null&&e.v===1&&e.data instanceof Float32Array&&Array.isArray(e.tracks)}(t[3])}function ogt(t,e,i){let r={name:e,duration:i.duration,tracks:[],uuid:t};return i.blendMode!==void 0&&(r.blendMode=i.blendMode),JSON.stringify(r)}function L3t(t,e,i){for(let r=0;r<i.length;r++)if(!Object.is(t[e+r],i[r]))return!1;return!0}function F3t(t){if(!Array.isArray(t)||t.length>3)return t;let e,[i,r,s]=t;if(typeof i!="string"||typeof s!="string")return t;try{e=JSON.parse(s)}catch{return t}return e&&Array.isArray(e.tracks)&&!e.tracks.some(n=>!n?.type||!n.times||!n.values)?function(n,a,o){let l=[],h=0,u=g=>{let y=[h,g.length];return l.push(g),h+=g.length,y},d=new Map,c=o.tracks.map(g=>{let y=(_=>{let x=Float32Array.from(_),S=x.length+":"+x[0]+":"+x[x.length-1],w=d.get(S)??[];for(let C of w)if(L3t(C.run,0,x))return C.span;let T=u(x);return w.push({span:T,run:x}),d.set(S,w),T})(g.times),v=!lgt.has(g.type),b={name:g.name,type:g.type,times:y,values:v?u(Float32Array.from(g.values)):[0,0]};return v||(b.list=Array.from(g.values)),g.interpolation!==void 0&&(b.interpolation=g.interpolation),b}),p=new Float32Array(h),m=0;for(let g of l)p.set(g,m),m+=g.length;let f={v:1,duration:o.duration,data:p,tracks:c};return o.blendMode!==void 0&&(f.blendMode=o.blendMode),o.userData!==void 0&&o.userData!=="{}"&&(f.userData=o.userData),[n,a,ogt(n,a,f),f]}(i,typeof e.name=="string"?e.name:r,e):t}function U3t(t,e,i){return t.map(r=>{let s=e();return i[r[0]]=s,function(n,a){let[o,l,h]=n;if(agt(n))return[a,l,ogt(a,l,n[3]),n[3]];let u=h.indexOf(o);return[a,l,u!==-1?h.slice(0,u)+a+h.slice(u+o.length):h,...n.slice(3)]}(r,s)})}var lgt,hgt=U(()=>{lgt=new Set(["bool","string"])});function jM(t,[e,i]){return Math.min(Math.max(t,e),i)}function ugt(t,e,i,r,s){t=jM(t,fgt),e=jM(e,ggt),i=jM(i,ygt),r=jM(r,vgt);let n=Math.sqrt(e/t),a=i/(2*Math.sqrt(e*t)),o=a<1?n*Math.sqrt(1-a*a):0,l=a<1?(a*n-r)/o:-r+n;return h=>{let u=s!==void 0?s*h:h;return u=a<1?Math.exp(-u*a*n)*(1*Math.cos(o*u)+l*Math.sin(o*u)):(1+l*u)*Math.exp(-u*n),h===0||h===1?h:1-u}}function dgt(t,e){return ei(ei(1-ei(3*e))+ei(3*t))}function cgt(t,e){return ei(ei(3*e)-ei(6*t))}function pgt(t){return ei(3*t)}function GM(t,e,i){return ei(ei(ei(ei(ei(dgt(e,i)*t)+cgt(e,i))*t)+pgt(e))*t)}function aK(t,e,i){let r=ei(ei(ei(3*dgt(e,i))*t)*t),s=ei(ei(2*cgt(e,i))*t);return ei(ei(r+s)+pgt(e))}function q0(t,e,i,r){if(t=ei(t),e=ei(e),i=ei(i),r=ei(r),t<0||t>1||i<0||i>1||t===e&&i===r)return Sgt;let s=new Float32Array(sR);for(let n=0;n<sR;n++)s[n]=GM(ei(n*h2),t,i);return n=>(n=ei(n))===0||n===1?n:GM((a=>{let o=0,l=1,h=sR-1;for(;l!==h&&s[l]<=a;)o=ei(o+h2),l+=1;l-=1;let u=ei(ei(a-s[l])/ei(s[l+1]-s[l])),d=ei(o+ei(u*h2)),c=aK(d,t,i);return c>=_gt?function(p,m,f,g){for(let y=0;y<bgt;y++){let v=aK(m,f,g);if(v===0)return m;let b=ei(GM(m,f,g)-p);m=ei(m-ei(b/v))}return m}(a,d,t,i):c===0?d:function(p,m,f,g,y){let v,b=0,_=0;do b=ei(m+ei(ei(f-m)/2)),v=ei(GM(b,g,y)-p),v>0?f=b:m=b,_+=1;while(Math.abs(v)>xgt&&_<wgt);return b}(a,o,ei(o+h2),t,i)})(n),e,r)}function mgt(t,e,i){switch(t.easing){case 0:default:return i;case 1:return q0(.25,.1,.25,1)(i);case 2:return q0(.42,0,1,1)(i);case 3:return q0(0,0,.58,1)(i);case 4:return q0(.42,0,.58,1)(i);case 7:return q0(.25,1,.5,1)(i);case 8:return Math.floor(i);case 5:{let{control1:r,control2:s}=t;return r&&s?q0(r[0],r[1],s[0],s[1])(i):i}case 6:{let{mass:r,stiffness:s,damping:n,velocity:a}=t;return r===void 0||s===void 0||n===void 0||a===void 0?i:ei(ugt(r,s,n,a,e)(i))}}}var ei,fgt,ggt,ygt,vgt,bgt,_gt,xgt,wgt,sR,h2,Sgt,oK,j3t=U(()=>{ei=Math.fround,fgt=[.01,100],ggt=[.01,1e4],ygt=[.01,1e3],vgt=[.01,1e3],bgt=4,_gt=ei(.001),xgt=ei(1e-7),wgt=10,h2=ei(1/((sR=11)-1)),Sgt=t=>t,oK=ei(1.70158),ei(oK+1)});function Tgt(t,e){if(t.length===0)throw new Error("sampleKeyframes requires at least one keyframe");if(e<=t[0].time)return{index0:0,index1:0,t:1};let{found:i,index:r}=function(h,u){let d=h.length,c=0,p=d;for(;c<p;){let m=c+Math.floor(d/2),f=h[m].time;if(f<u)c=m+1;else{if(!(f>u))return{found:!0,index:m};p=m}d=p-c}return{found:!1,index:c}}(t,e);if(i)return{index0:r,index1:r,t:1};if(r>=t.length){let h=t.length-1;return{index0:h,index1:h,t:1}}let s=r-1,n=r,a=t[s].time,o=t[n].time;if(o===a)return{index0:s,index1:n,t:.5};let l=nR(o-a);return{index0:s,index1:n,t:mgt({...t[s].ease,control2:t[n].ease.control2},l,nR(nR(e-a)/l))}}function Mgt(t){return[...t].sort((e,i)=>e.time-i.time)}var nR,G3t=U(()=>{j3t(),nR=Math.fround});function W3t(t){if(t?.length!==2)return;let e=`${t[0]}.${t[1]}`;return nW.includes(e)?e:void 0}function Agt(t){return t.slice(0,t.indexOf("."))}function Cgt(t){return ym.indexOf(t.slice(-1))}function q3t(t){return{easing:t?.type,control1:Cc(t?.cubicControls?.control1,[0,0]),control2:Cc(t?.cubicControls?.control2,[1,1]),...t?.springParameters}}function H3t(t){let e=t?.cubicControls;return{...t,cubicControls:{control1:[...e?.control1??[0,0]],control2:[...e?.control2??[1,1]]},...t?.springParameters?{springParameters:{...t.springParameters}}:{}}}function lK(t,e,i){let r=Agt(t);if(r==="position"){let s=Cgt(t);return ym.flatMap((n,a)=>Math.abs(e.elements[4*a+s])>1e-9?[`position.${n}`]:[])}return(i?[r]:["rotation","scale"]).flatMap(s=>ym.map(n=>`${s}.${n}`))}function $3t(t,e){let[i,r,s]=t,n=[[i,r,s],[i+180,180-r,s+180]],a=[i,r,s],o=1/0;for(let l of n){let h=l.map((d,c)=>d+360*Math.round((e[c]-d)/360)),u=h.reduce((d,c,p)=>d+Math.abs(c-e[p]),0);u<o-1e-9&&(a=h,o=u)}return a}function X3t(t,e,i){if(t==="rotation"){let r=((e-i)%360+540)%360-180;return Math.abs(r)<1e-6}return Math.abs(e-i)<1e-9*Math.max(1,Math.abs(e),Math.abs(i))}function Y3t(t,e,i,r){let s=new Map;for(let{id:p,data:m}of t.unproxy()){if(m.isPlaceholder)continue;let f=W3t(m.path);if(!f){if(u2.includes(m.path?.[0]))return;continue}if(typeof m.value!="number"||!Number.isFinite(m.value))return;let g=s.get(f)??{keys:[],sampled:[]};g.keys.push({id:p,time:m.time,value:m.value,keyframe:m}),s.set(f,g)}if(s.size===0)return;for(let p of s.values())p.keys.sort((m,f)=>m.time-f.time),p.sampled=Mgt(p.keys.map(m=>({time:m.time,ease:q3t(m.keyframe.easing),value:m.value})));let n=(p,m)=>{let f=s.get(p);return f?function(g,y){let{index0:v,index1:b,t:_}=Tgt(g.sampled,y),x=g.sampled[v].value;return x+(g.sampled[b].value-x)*_}(f,m):i[Agt(p)][Cgt(p)]},a=new we,o=new zi,l=new bt,h=new E,u=new E,d=p=>{let m=(f=>{let g={};for(let y of u2)g[y]=ym.map((v,b)=>n(nW[3*u2.indexOf(y)+b],f));return g})(p);return o.set(m.rotation[0]*zt.DEG2RAD,m.rotation[1]*zt.DEG2RAD,m.rotation[2]*zt.DEG2RAD),l.compose(h.fromArray(m.position),a.setFromEuler(o),u.fromArray(m.scale)).premultiply(e),{pose:m,out:sW(l)}},c=function(p){let m=p.elements,f=[0,4,8].map(v=>new E(m[v],m[v+1],m[v+2])),g=f[0].lengthSq(),y=1e-9*Math.max(1,g);return Math.abs(f[1].lengthSq()-g)<y&&Math.abs(f[2].lengthSq()-g)<y&&Math.abs(f[0].dot(f[1]))<y&&Math.abs(f[0].dot(f[2]))<y&&Math.abs(f[1].dot(f[2]))<y}(e);for(let p of u2){let m,f=ym.map(b=>`${p}.${b}`),g=b=>{let _=new Set;for(let x of lK(b,e,c))for(let S of s.get(x)?.keys??[])_.add(S.time);return[..._].sort((x,S)=>x-S)},y=[...new Set(f.flatMap(b=>g(b)))].sort((b,_)=>b-_),v=new Map;for(let b of y){let{pose:_,out:x}=d(b),S=[...x[p]];p==="rotation"&&(S=$3t(S,m?m.out.map((w,T)=>w+_.rotation[T]-m.in[T]):_.rotation),m={in:_.rotation,out:S}),v.set(b,S)}f.forEach((b,_)=>{let x=s.get(b)?.keys??[],S=g(b),w=new Set(S);if(x.length!==0||!S.every(T=>X3t(p,v.get(T)[_],r[p][_]))){for(let T of x)w.has(T.time)||t.delete(T.id);for(let T of S){let C=v.get(T)[_],M=x.find(O=>O.time===T);if(M){let O=t.data(M.id);O&&(O.value=C);continue}let A=lK(b,e,c).sort((O,D)=>Number(D===b)-Number(O===b)).map(O=>s.get(O)?.keys.find(D=>D.time===T)).find(O=>O!==void 0),P=zt.generateUUID();t.insertBefore(null,[{id:P,data:{id:P,time:T,path:[p,ym[_]],value:C,easing:H3t(A.keyframe.easing),index:gm.rowOrder([p])}}])}}})}}var u2,ym,nW,K3t=U(()=>{ot(),iW(),G3t(),vT(),ym=["x","y","z"],nW=(u2=["position","rotation","scale"]).flatMap(t=>ym.map(e=>`${t}.${e}`))}),Egt={};function hK(t){t.layers&&t.layers.forEach(e=>{e.type==="light"&&e.alphaOverride===void 0&&(e.alphaOverride=1)})}function Pgt(t){let e=t.geometry;e!==void 0&&Bgt.has(e.type)&&e.extrusionVersion===void 0&&(e.extrusionVersion=1)}function Rgt(t){if(t.type!=="Empty")return;let e=Os(t.animations);if(!Array.isArray(e))return;let i=e.map(F3t);i.some((r,s)=>r!==e[s])&&(t.animations=i)}function uK(t,e){let[i,r,s]=t,n=Math.cos(i),a=Math.sin(i),o=Math.cos(r),l=Math.sin(r),h=Math.cos(s),u=Math.sin(s),d=[o*h,n*u+a*h*l,a*u-n*h*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 Dgt(t){(function(i){i.rotation=i.rotation.slice(0,3).map(r=>r*Np)})(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(h=>typeof h=="number"&&Number.isFinite(h))?n:[0,1,0],o=uK(s,a),l=uK(s.map(h=>h*kgt),a);return Math.abs(o-l)<1e-6?s.some(h=>Math.abs(h)>Math.PI):l<o})(r,i.up)?i.rotation=r:i.rotation=r.map(s=>s*Np)}(t.camera),t.states?.forEach(i=>{i.rotation===void 0||i.rotation===null||(i.rotation=i.rotation.slice(0,3).map(r=>r*Np))});let e=t.geometry;e&&e.type==="SphereGeometry"&&(e.thetaLength=(e.thetaLength??180)*Np),e&&e.type==="TorusGeometry"&&(e.arc=e.arc*Np),e&&e.type==="PathGeometry"&&(e.extrusion.angle*=Np,e.extrusion.twist*=Np),t.type==="Mesh"&&t.geometry.type==="TextGeometry"&&(t.geometry.text={textValue:t.geometry.text}),Array.isArray(Os(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 Z3t(t){t.scene.objects.traverse((e,i)=>{})}function Q3t(t){let e=t.schema??104;e!==136&&(e<130&&(aW(t.asset),t.schema=130),e<135&&(oW(t.asset),t.schema=135),e<136&&(lW(t.asset),t.schema=136))}function Vh(t,e){e(t.data);for(let i of t.children)Vh(i,e)}function Ogt(t){let e=t.schema??104;e!==136&&(e<105&&(Vh(t.asset,Dgt),t.schema=105),e<118&&(Vh(t.asset,Igt),t.schema=118),e<121&&(Vh(t.asset,ij),t.schema=121),e<130&&(Vh(t.asset,i=>YI(i,aW)),t.schema=130),e<132&&(Vh(t.asset,Pgt),t.schema=132),e<133&&(Vh(t.asset,i=>Ngt(i,()=>{})),t.schema=133),e<134&&(Vh(t.asset,Rgt),t.schema=134),e<135&&(Vh(t.asset,i=>YI(i,oW)),t.schema=135),e<136&&(Vh(t.asset,i=>YI(i,lW)),t.schema=136))}function aR(t,e){Qd(t,e),Zd(t,e),Object.values(t.shared.lib.materials).forEach(i=>e(i.asset))}function aW(t){t.layers===void 0&&Object.assign(t,Qr.defaultTwoLayerData("phong"))}function oW(t){let e=Q1(t),i=Qr.withRepairedLayers(e);i!==e&&(t.layers=i.layers)}function lW(t){let e=Q1(t),{material:i,restored:r}=Qr.restoreLayersSeq(e);r&&(t.layers=i.layers)}function YI(t,e){"materials"in t?t.materials.forEach(i=>{i!==void 0&&typeof i!="string"&&e(i)}):"material"in t&&t.material!==void 0&&typeof t.material!="string"&&e(t.material)}function Igt(t){t.timelineAnimations=qa({},Ne.prototype)}function J3t(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(gm.placeholderKeyframe(i.id,s,{layerId:a,index:r}))}),e.sort((i,r)=>i.data.time-r.data.time),new ue(...e.map((i,r)=>({...i,fi:r})))):new ue}function tCt(t){for(let{id:e,data:i}of[...t.unproxy()]){let r=i.path?.[0];if(!r||!Vgt.includes(r))continue;let s=ej(i.value);if(!s.length)continue;let n=t.data(e);if(!n)continue;let a=i.value,[o,...l]=s;for(let h of l){let u=zt.generateUUID();t.insertBefore(null,[{id:u,data:{...i,id:u,path:[r,h],value:a[h],easing:eCt(i.easing)}}])}n.path=[r,o],n.value=a[o]}}function ej(t){return t===null||typeof t!="object"?[]:YS.filter(e=>e in t)}function eCt(t){let e=t?.cubicControls;return{...t,cubicControls:{control1:[...e?.control1??[0,0]],control2:[...e?.control2??[1,1]]},...t?.springParameters?{springParameters:{...t.springParameters}}:{}}}function iCt(t,e){return Math.abs(t[0]-e[0])<1e-6&&Math.abs(t[1]-e[1])<1e-6}function rCt(t){let e=function(n){let a=[];for(let o of gm.groupKeyframes(n)){let l=new Set(o.keyframes.flatMap(u=>ej(u.data.value))),h=l.size?[...l].map(u=>o.keyframes.filter(d=>ej(d.data.value).includes(u))):[o.keyframes];for(let u of h){let d=[...u].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:gm.presetHandles(o))?.control2??(o===5?Cc(a.data.easing?.cubicControls?.control2,[1,1]):void 0);if(!l)continue;let h=i.get(a.id);h?iCt(h,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:gm.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:Cc(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:Cc(o.easing.cubicControls?.control1,[0,0]),control2:l})}}function dK(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 ij(t){t.pivot=[0,0,0],t.pivotRotation=[0,0,0]}function Ngt(t,e,i=[]){let r=["position","rotation","scale","shear"];function s(c,p,m){return c?.map(f=>typeof f=="string"?e(f)??m:f)??[...p]}function n(c,p){if(c&&!function(m){return m.every((f,g)=>Math.abs(f-(g%5==0?1:0))<1e-6)}(c))return sW(new bt().fromArray(c).multiply(new bt().compose(new E().fromArray(p.position),new we().setFromEuler(new zi(p.rotation[0]*zt.DEG2RAD,p.rotation[1]*zt.DEG2RAD,p.rotation[2]*zt.DEG2RAD)),new E().fromArray(p.scale))))}function a(c,p){return c.length===p.length&&c.every((m,f)=>m===p[f])}t.shear=_l.zero;let o=t,l=o.hiddenMatrix;l!==void 0&&delete o.hiddenMatrix;let h={position:s(o.position,[0,0,0],0),rotation:s(o.rotation,[0,0,0],0),scale:s(o.scale,[1,1,1],1)},u=n(l,h);if(u&&Object.assign(o,u),u){let c=new bt().fromArray(l);for(let p of i)Y3t(p,c,h,u)}let d=u??{...h,shear:[..._l.zero]};o.states?.forEach(c=>{let p=c.hiddenMatrix;if(p!==void 0&&delete c.hiddenMatrix,p===void 0&&c.position==null&&c.rotation==null&&c.scale==null)return;let m={position:s(c.position,h.position,0),rotation:s(c.rotation,h.rotation,0),scale:s(c.scale,h.scale,1)},f=n(p??l,m);if(!u&&!f)return;let g=f??{...m,shear:[..._l.zero]};for(let y of r)(c[y]!=null||!a(g[y],d[y]))&&(c[y]=g[y])})}function sCt(t){}function nCt(t){let e=t.schema??0;if(e!==136){if(e>136)return void console.error(`This scene was created with a newer version of Spline (file format ${e}, this runtime reads 136). Update @splinetool/runtime to the latest version to load it correctly.`);console.warn("updating from ",e,"to ",136),function(i,r){if(r<1&&(Qd(i,ZY),Zd(i,ZY),i.schema=1),r<2&&(function(s){Object.assign(s.scene.publish,{orbitControls:{...Y4.defaultData,...Os(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,h]of Object.entries(o))if((lD.includes(l)||typeof h=="boolean")&&delete o[l],l==="texture")for(let[u,d]of Object.entries(h))($G.includes(u)||typeof d=="boolean")&&delete h[u]}}}s.scene.objects.traverse((a,o)=>{o.states.forEach(l=>{let h=l;h.material?n(h.material):h.materials&&h.materials.forEach(u=>{n(u)})})})}(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&&(JY(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&&(JY(i),i.schema=12),r<13&&(function(s){s.shared.audios=qa({},Ne.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(Os(s.shared.images)).filter(n=>n[1].asset===!1).map(n=>n[0]).forEach(n=>{delete s.shared.images[n]}),Object.entries(Os(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&&(Qd(i,tK),Zd(i,tK),i.schema=17),r<18&&(Qd(i,QY),Zd(i,QY),i.schema=18),r<19&&(function(s){Object.assign(s.scene.publish.settings,{video:{...bc.defaultData.settings.video,...Os(s.scene.publish.settings.video)}})}(i),i.schema=19),r<20&&(function(s){s.shared.fonts=qa({},Ne.prototype)}(i),function(s){let n=[];s.scene.objects.traverse((a,o)=>{let l=o;if(l.type==="TextFrame"){let h=Qr.defaultTwoLayerData("phong"),u=typeof l.color=="string"?s.shared.colors[l.color]:l.color;h.layers[1].data.color={r:u.r,g:u.g,b:u.b},h.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,...an.defaultData,...Iu.defaultData,flatShading:!1,wireframe:!1,geometry:{...hc.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:h,states:Os(l.states),events:Os(l.events),visible:l.visible,raycastLock:l.raycastLock,position:l.position,rotation:l.rotation,scale:l.scale,hiddenMatrix:l.hiddenMatrix},p=Os(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 ue,move:new ue,jump:new ue}});else{let h=new ue;Object.assign(l,{actions:h}),(l.type==="MouseDown"||l.type==="MouseUp"||l.type==="KeyDown"||l.type==="KeyUp")&&"url"in l&&h.push({fi:0,id:zt.generateUUID(),data:{type:"Link",url:l.url,delay:0}}),"targets"in l&&(l.targets.forEach((u,d,c)=>{let p={easing:u.easing,duration:u.duration};u.easing===6?Object.assign(p,dg(u,"mass","stiffness","damping","velocity")):u.easing===5&&Object.assign(p,{control1:{...u.control1},control2:{...u.control2}});let m={repeat:u.repeat?-1:0,delay:u.delay,delayDirection:u.delayDirection,direction:u.cycle&&u.rewind?"pingpong-rewind":u.cycle?"pingpong":"normal"},f={state:u.state,...m,...p},g={allowSlerp:!0,type:"Transition",object:u.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new ue({fi:0,id:zt.generateUUID(),data:{state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4}},{fi:1,id:zt.generateUUID(),data:f})};h.push({fi:c,id:d,data:g})}),delete l.targets)}})})}(i),function(s){s.scene.objects.traverse((n,a)=>{function o(l,h){let u=new ue,d=[];if(a.events.forEach((c,p,m)=>{if(c.type==="Audio"&&c.trigger===h){let f;d.push(p),c.interaction==="play"?f={...dg(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={...dg(c,"interaction","delay","object","playAudio"),type:"Audio"}),f&&u.push({fi:m,id:p,data:f})}}),d.forEach(c=>a.events.delete(c)),u.length){let c=a.events.find(p=>p.type===l)?.data;c?"actions"in c&&c.actions.insertBefore(null,u):a.events.insertBefore(null,[{id:zt.generateUUID(),data:{type:l,actions:u}}])}}o("Start","start"),o("MouseDown","mouseDown"),o("MouseUp","mouseUp"),o("KeyDown","keyDown"),o("KeyUp","keyUp")})}(i),i.schema=21),r<22&&(rK(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=qa({},Ne.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=Os(s.scene.objects.data(o));l&&l.type==="Mesh"&&l.geometry.type==="BooleanGeometry"&&a.type==="Mesh"&&(a.visible=Os(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&&(rK(i),i.schema=28),r<29&&(function(s){function n(o){Object.setPrototypeOf(o,Cs.prototype),o.texture&&Object.setPrototypeOf(o.texture,Cs.prototype)}function a(o){Object.setPrototypeOf(o,Cs.prototype);for(let l in o)n(o[l])}s.scene.objects.traverse((o,l)=>{l.states.forEach(h=>{let u=h;if(u.material){let d=Os(u.material).layers;a(d),u.material.layers=d}if(u.materials)for(let d=0;d<u.materials.length;d++){let c=u.materials[d],p=Os(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=Qr.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&&(Qd(i,eK),Zd(i,eK),i.schema=38),r<39&&(function(s){s.scene.objects.traverse((n,a)=>{a.events.forEach(o=>{o.type==="GameControl"&&(o.navmesh=Z4.defaultDataThirdPerson.navmesh)})})}(i),i.schema=39),r<40&&(function(s){s.scene.styles||(s.scene.styles=Pg.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}),Qd(s,sK),Zd(s,sK)}(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 ue})})})}(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){Qd(i,nK),Zd(i,nK),i.scene.publish.playCamera===null&&(i.scene.publish.playCamera=l0);let s=Os(i.scene.objects),n=i.scene.objects;i.scene.publish.playPage=mv,n.insertBefore(null,null,[{id:mv,data:{...Hg.defaultData,backgroundColor:i.scene.backgroundColor,fog:i.scene.fog,postprocessing:i.scene.postprocessing,ao:dg(i.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:i.scene.publish.playCamera,gameControlObject:i.scene.publish.gameControlObject},shadow:dg(i.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...yv.defaultData,...dg(i.scene.environment,"usePhysics","gravity")},camera:Os(i.scene.ownerCamera)??Hg.defaultData.camera,name:"Scene"},children:[]}]);for(let l of s)l.id!==Rg.TRASH_CAN_ID&&n.move(mv,l.fi,l.id);let a=0,o=0;i.shared.penumbraSize&&i.scene.objects.traverse((l,h)=>{h.type==="DirectionalLight"?(h.penumbraSize=i.shared.penumbraSize[Math.min(a,2)],a+=1):h.type==="SpotLight"&&(h.penumbraSize=i.shared.penumbraSize[3+Math.min(o,1)],o+=1),(h.physics===void 0||h.physics===null)&&h.type!=="Instance"&&(h.physics={},Object.assign(h.physics,fv.defaultData)),h.physics!==void 0&&h.physics!==null&&(h.physics.enabled=h.collision??"visibility",delete h.collision)}),i.schema=99}}(t,e),e<100&&(t.scene.publish.joystickSizeAndXYOffset===void 0&&(t.scene.publish.joystickSizeAndXYOffset=bc.defaultData.joystickSizeAndXYOffset),t.schema=100),e<101&&(Qd(t,hK),Zd(t,hK),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 Ne,t.shared.lib=uc.defaultData(),t.schema=104),e<105&&(function(i){i.shared.variables=qa({},Ne.prototype)}(t),t.scene.objects.traverse((i,r)=>{Dgt(r)}),t.schema=105);for(let i of Object.values(t.shared.lib.components))Ogt(i);if(e<106&&(function(i){let r=Os(i.shared.variables);i.shared.variables=qa(Object.entries(r??{}).map(([s,n],a)=>({fi:a,id:s,data:n})),ue.prototype)}(t),t.schema=106),e<107&&(t.shared.lib.variables=uc.defaultData().variables,t.schema=107),e<109&&(function(i){i.shared.particles=qa({},Ne.prototype),i.shared.lib&&(i.shared.lib.particles=uc.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(Os(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(Os(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=qa({},Ne.prototype),i.shared.userWebhooks=qa({},Ne.prototype),i.shared.lib&&(i.shared.lib.userAPIs=uc.defaultData().userAPIs,i.shared.lib.userWebhooks=uc.defaultData().userWebhooks)}(t),t.schema=115),e<116&&(function(i){i.scene.publish.settings.videoStatic===void 0&&(i.scene.publish.settings.videoStatic=bc.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=qa({},Ne.prototype),t.scene.objects.traverse((i,r)=>{Igt(r)}),t.schema=118),e<119&&(t.scene.publish.settings.videoStatic.format=vv.defaultData.scene.publish.settings.videoStatic.format,t.scene.publish.settings.videoStatic.imageFormat=vv.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)=>{ij(r),r.type==="Page"&&r.camera!==void 0&&ij(r.camera)}),t.schema=121),e<122&&(delete t.scene.publish.settings.video,t.scene.publish.orbitControls.rotationSpeed=vv.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=Kp.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=Kp.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=Kp.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={...Kp.defaultData.hdri}:(s.hdri.blur===void 0&&(s.hdri.blur=Kp.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=Hg.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&&(aR(t,aW),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,h)=>{(l.isAnimation||a?.[h])&&o.push(h)}),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 h=qa({},Ne.prototype),u=0,d=Boolean(l.loop);for(let[m,f]of Object.entries(l.mapping??{})){let g=n.data(m)?.timelineAnimations?.[f];!g||(u=Math.max(u,g.to??0),d=d||Boolean(g.loop),h[m]={id:m,keyframes:J3t(g.properties?.unproxy())})}let c=l.page??a,p=c?n.data(c):void 0;p&&p.type==="Page"&&((p.timelines??(p.timelines=qa({},Ne.prototype)))[o]={id:o,name:l.name,duration:u||5,...d?{loop:d}:{},objectTimelines:h})}delete r.timelineAnimations,n.traverse((o,l)=>{delete l.timelineAnimations})}(t),dK(t,tCt),dK(t,rCt),t.schema=131),e<132&&(t.scene.objects.traverse((i,r)=>Pgt(r)),t.schema=132),e<133){let i=function(s){return n=>s.get(n)?.data?.value}(t.shared.variables),r=new Map;t.scene.objects.traverse((s,n)=>{let a=n;if(a.type==="Page"&&a.timelines)for(let o of Object.values(a.timelines))for(let[l,h]of Object.entries(o.objectTimelines??{})){let u=r.get(l)??[];u.push(h.keyframes),r.set(l,u)}}),t.scene.objects.traverse((s,n)=>Ngt(n,i,r.get(s))),t.schema=133}e<134&&(t.scene.objects.traverse((i,r)=>Rgt(r)),t.schema=134),e<135&&(aR(t,oW),t.schema=135),e<136&&(aR(t,lW),t.schema=136)}}pT(Egt,{updateAllMaterials:()=>aR,updateDocumentSchema:()=>nCt,updateLibSchema:()=>sCt,updateMaterialSchema:()=>Q3t,updateObjectStateRec:()=>Vh,updateObjectsSchema:()=>Ogt,updateTextValues:()=>Z3t});var Bgt,Np,kgt,Vgt,cK,WM,KI,pK,qM,Og,g_,H0,HM,ZI,oR,QI,JI,mK,lR,tN,$g,rj,cD=U(()=>{ot(),Jft(),Li(),iW(),z3t(),uD(),yT(),qo(),dn(),eW(),hD(),ZG(),vT(),hgt(),K3t(),Bgt=new Set(["RectangleGeometry","EllipseGeometry","StarGeometry","PolygonGeometry","TriangleGeometry","VectorGeometry","TextGeometry","InputGeometry","PathGeometry"]),Np=180/Math.PI,kgt=Math.PI/180,Vgt=["position","rotation","scale","shape size"]}),aCt=U(()=>{var t,e,i;qo(),Li(),dn(),(cK||(cK={})).is=function(r){return!0},(t=WM||(WM={})).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 fft({position:Gu.isEqual(r.position,s.position)?void 0:s.position,rotation:r.rotation===s.rotation?void 0:s.rotation,scale:Gu.isEqual(r.scale,s.scale)?void 0:s.scale,shear:r.shear&&s.shear&&Gu.isEqual(r.shear,s.shear)?void 0:s.shear})},(KI||(KI={})).defaultData={horizontalConstraint:0,verticalConstraint:0},(pK||(pK={})).defaultData={direction:"row",wrap:"unwrap",align:"top-left",gap:10,rowGap:10,autoGap:!1,autoRowGap:!1,leftPadding:8,rightPadding:8,topPadding:8,bottomPadding:8},(qM||(qM={})).defaultData={opacity:1,fill:{color:qi.fromHexAndA(i0,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=Og||(Og={})).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,WM.merge(n,s)),n=function(a,o){if(o===void 0)return a;let l={...a},h=["width","height","cornerRadius"];for(let u of h)u in l&&u in o&&o[u]!==void 0&&Object.assign(l,{[u]:o[u]});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},(g_||(g_={})).defaultData={...WM.defaultData,...KI.defaultData,states:new ue,events:new ue,visible:!0,raycastLock:!1},(H0||(H0={})).defaultData={...g_.defaultData,...qM.defaultData},(HM||(HM={})).defaultData={cornerRadius:[0,0,0,0]},(ZI||(ZI={})).defaultData={...H0.defaultData,type:"ellipse2d",width:100,height:100,name:"Ellipse"},(oR||(oR={})).defaultData={...H0.defaultData,...HM.defaultData,type:"rectangle2d",width:100,height:100,name:"Rectangle"},(QI||(QI={})).defaultData={...H0.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"},(JI||(JI={})).defaultData={...H0.defaultData,type:"path2d",path:"",name:"Path"},(mK||(mK={})).is=function(r){return r.type==="ellipse2d"||r.type==="rectangle2d"||r.type==="text2d"||r.type==="vector2d"||r.type==="path2d"},(lR||(lR={})).defaultData={...g_.defaultData,name:"Group",type:"group2d"},(tN||(tN={})).defaultData=()=>({...g_.defaultData,...HM.defaultData,...qM.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{...oR.defaultData};case"ellipse2d":return{...ZI.defaultData};case"text2d":return{...QI.defaultData};case"path2d":return{...JI.defaultData};case"frame2d":return{...tN.defaultData()};case"group2d":return{...lR.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"}})($g||($g={})),(i=rj||(rj={})).defaultData={name:"UI",type:"scene2d",objects:new Nn},i.emptyData=function(){return{type:"scene2d",objects:new Nn}}}),zgt=U(()=>{P3t(),R3t(),zft(),Lft(),Jft(),Bft(),Wft(),qft(),Xft(),ZG(),cD(),Qft(),KG(),YG(),Fft(),yT(),Gft(),Kft(),qo(),uD(),hD(),hgt(),JG(),$ft(),eW(),tW(),O3t(),Hft(),rW(),QG(),Uft(),jft(),aCt()});function Ig(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 fe,h=0;for(let u=0;u<t.length;++u){let d=t[u],c=0;if(i!==(d.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". 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 "+u+'. 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 "+u+". 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 "+u+". .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 "+u+". .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 "+u+". The geometry must have either an index or a position attribute"),null;p=d.attributes.position.count}l.addGroup(h,p,u),h+=p}}if(i){let u=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)+u);u+=t[c].attributes.position.count}l.setIndex(d)}for(let u in n){let d=fK(n[u]);if(!d)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+u+" attribute."),null;l.setAttribute(u,d)}for(let u in a){let d=a[u][0].length;if(d!==0){l.morphAttributes=l.morphAttributes||{},l.morphAttributes[u]=[];for(let c=0;c<d;++c){let p=[];for(let f=0;f<a[u].length;++f)p.push(a[u][f][c]);let m=fK(p);if(!m)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+u+" morphAttribute."),null;l.morphAttributes[u].push(m)}}}return l}function fK(t){let e,i,r,s=-1,n=0;for(let h=0;h<t.length;++h){let u=t[h];if(e===void 0&&(e=u.array.constructor),e!==u.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=u.itemSize),i!==u.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(r===void 0&&(r=u.normalized),r!==u.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(s===-1&&(s=u.gpuType),s!==u.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;n+=u.count*i}let a=new e(n),o=new ve(a,i,r),l=0;for(let h=0;h<t.length;++h){let u=t[h];if(u.isInterleavedBufferAttribute){let d=l/i;for(let c=0,p=u.count;c<p;c++)for(let m=0;m<i;m++){let f=u.getComponent(c,m);o.setComponent(c+d,m,f)}}else a.set(u.array,l);l+=u.count*i}return s!==void 0&&(o.gpuType=s),o}var bT=U(()=>{ot()});function Lgt(t){let e=t.points.length/7,i=new ue;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],h=t.points[s+4],u=t.points[s+5],d=t.points[s+6];i.push({fi:r,id:zt.generateUUID(),data:{roundness:d,position:[n,a],areControlsDirectionsMirrored:!0,controlPrevious:{position:[o,l]},controlNext:{position:[h,u]}}})}return{points:i,isClosed:t.isClosed,roundness:t.roundness,shapeHoles:t.shapeHoles?.map(r=>Lgt(r))??[]}}function Fgt(t){let{userData:e,uuid:i,...r}=t;if(e===void 0||e.type==="NonParametricGeometry")return function(a){let o,{userData:l,data:h}=a,u=h?.groups,d=h?.attributes??{},c=h?.morphAttributes??{},p=h?.interleavedBuffers,m=h?.arrayBuffers,f=h?.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 C=y[T],M=y[T+1],A=y[T+2];v=Math.min(v,C),b=Math.min(b,M),_=Math.min(_,A),x=Math.max(x,C),S=Math.max(S,M),w=Math.max(w,A)}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}),u!==void 0&&Object.assign(g.data,{groups:u.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 h=new fe;if(o?.position===void 0||o?.faceMap===void 0)return null;let u=o.position.array,d=o.faceMap.array,c=r.data.index.array;h.setAttribute("position",new me(u,3)),h.setIndex(new pm(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),C={},M={},A=[],P=["getX","getY","getZ","getW"],O=["setX","setY","setZ","setW"];for(let V=0,q=T.length;V<q;V++){let W=T[V],H=y.attributes[W];C[W]=new H.constructor(new H.array.constructor(H.count*H.itemSize),H.itemSize,H.normalized);let rt=y.morphAttributes[W];rt&&(M[W]||(M[W]=[]),rt.forEach((it,ft)=>{let dt=new it.array.constructor(it.count*it.itemSize);M[W][ft]=new it.constructor(dt,it.itemSize,it.normalized)}))}let D=.5*v,N=Math.log10(1/v),z=Math.pow(10,N),k=D*z;for(let V=0;V<S;V++){let q=_?_.getX(V):V,W="";for(let H=0,rt=T.length;H<rt;H++){let it=T[H],ft=y.getAttribute(it),dt=ft.itemSize;for(let K=0;K<dt;K++)W+=~~(ft[P[K]](q)*z+k)+","}if(W in b)A.push(b[W]);else{for(let H=0,rt=T.length;H<rt;H++){let it=T[H],ft=y.getAttribute(it),dt=y.morphAttributes[it],K=ft.itemSize,lt=C[it],_t=M[it];for(let xt=0;xt<K;xt++){let wt=P[xt],gt=O[xt];if(lt[gt](w,ft[wt](q)),dt)for(let Dt=0,Lt=dt.length;Dt<Lt;Dt++)_t[Dt][gt](w,dt[Dt][wt](q))}}b[W]=w,A.push(w),w++}}let B=y.clone();for(let V in y.attributes){let q=C[V];if(B.setAttribute(V,new q.constructor(q.array.slice(0,w*q.itemSize),q.itemSize,q.normalized)),V in M)for(let W=0;W<M[V].length;W++){let H=M[V][W];B.morphAttributes[V][W]=new H.constructor(H.array.slice(0,w*H.itemSize),H.itemSize,H.normalized)}}return B.setIndex(A),B}(h),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,...oCt(o.positionWASM.array)};l.subdivisions=e.parameters.subdivisions;for(let h in o)h==="positionWASM"?l[h]=new Float32Array(o[h].array):h==="indexWASM"?l[h]=new Int32Array(o[h].array):h==="verticesPerFaceWASM"&&(l[h]=new Int8Array(o[h].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:Lgt(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 oCt(t){return sj.setFromArray(t),sj.getSize(d2),{width:d2.x,height:d2.y,depth:d2.z}}var sj,d2,eN,lCt=U(()=>{Li(),ot(),bT(),new bt,new we,new zi,new E,new E,sj=new dr,d2=new E}),hCt=U(()=>{var t;(t=eN||{}).view="view",t.edit="edit",((eN=t)||(eN={})).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"}}}),Ugt,nj,hR,jgt,Ggt,sb,y_,$M,iN,nb,gK,rN,yK,sN,Gv,Xc,Yc,ud,nN,vK,bK,aN,aj,xc,Wgt=U(()=>{hCt()}),uCt=U(()=>{}),dCt=U(()=>{Li(),cD(),Wgt()}),cCt=U(()=>{yT(),[...lD],new Set($G)}),De=U(()=>{zgt(),uCt(),B3t(),cD(),dCt(),Wgt(),iW(),cCt(),rW(),Li()}),pD=U(()=>{Ugt=[3,4,8,9],nj=5,hR=3,jgt=32,Ggt=.98}),_T=U(()=>{ot(),sb=t=>{var e;return(e=class extends t{}).geometryHelper=new Yh(30,30,30),e}}),xT=U(()=>{ot(),y_=new mc,$M=new Zn,iN=new bt,nb=(t,e,i,r,s=!1,n=t)=>{let a=e,o=n.matrixWorld;if(a.boundingSphere===null&&a.computeBoundingSphere(),$M.copy(a.boundingSphere),$M.applyMatrix4(o),i.ray.intersectsSphere($M)===!1||(iN.copy(o).invert(),y_.copy(i.ray).applyMatrix4(iN),a.boundingBox!==null&&y_.intersectsBox(a.boundingBox)===!1))return;let l,h,u,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(h=m.getX(c),u=m.getX(c+1),d=m.getX(c+2),l=y(t,i,y_,f,h,u,d),l)return l.faceIndex=Math.floor(c/3),void r.push(l)}else{let v=a.attributes.position,b=new E,_=new E,x=new E,S=new E,w=2,T=1/((n.scale.x+n.scale.y+n.scale.z)/3),C=T*T;for(let M=Math.max(0,g.start),A=Math.min(v.count,g.start+g.count)-1;M<A;M+=w){if(b.fromBufferAttribute(v,M),_.fromBufferAttribute(v,M+1),y_.distanceSqToSegment(b,_,S,x)>C)continue;S.applyMatrix4(n.matrixWorld);let P=i.ray.origin.distanceTo(S);P<i.near||P>i.far||r.push({distance:P,point:x.clone().applyMatrix4(n.matrixWorld),object:t})}}function y(v,b,_,x,S,w,T){let C=new E,M=new E,A=new E,P=new E,O=new E;if(C.fromBufferAttribute(x,S),M.fromBufferAttribute(x,w),A.fromBufferAttribute(x,T),_.intersectTriangle(C,M,A,!1,P)===null)return null;O.copy(P),O.applyMatrix4(v.matrixWorld);let D=b.ray.origin.distanceTo(O);return D<b.near||D>b.far?null:{faceIndex:1,distance:D,point:O.clone(),object:v}}}}),mD=U(()=>{ot(),_T(),xT(),gK=new E(1,1,1),rN=new E,yK=new E,sN=new we,Gv=class extends sb(oft){constructor(t,e=15){super(e),this.object=t,this.dummy=new rb,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){nb(this.object,Gv.geometryHelper,t,e,!1,this.dummy)}update(){}updateMatrix(){}updateMatrixWorld(t){this.object.matrixWorld.decompose(rN,sN,yK),this.matrix.compose(rN,sN,gK),super.updateMatrixWorld(t)}updateWorldMatrix(t,e){}}}),pCt=U(()=>{ot(),Xc=new E,Yc=new E,ud=new bt,nN=[new E(-1,1,1),new E(-1,-1,1),new E(1,-1,1),new E(1,1,1),new E(-1,1,-1),new E(-1,-1,-1),new E(1,-1,-1),new E(1,1,-1)],vK=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],bK=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],aN=(t,e,i)=>{t.updateEntityBoxSize(Xc,Yc),ud.copy(e).multiply(t.matrixWorld),Yc.x===0&&Yc.y===0&&Yc.z===0?i.push(new E(Xc.x,Xc.y,Xc.z).applyMatrix4(ud)):nN.forEach(r=>{i.push(r.clone().multiply(Yc).add(Xc).applyMatrix4(ud))})},aj=class extends dr{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 ud.copy(e).multiply(n.matrixWorld),void s.push(new E().applyMatrix4(ud));aN(n,e,r)}}),r.length===0&&r.push(...s)}else aN(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(ud.copy(this.matrix).setPosition(0,0,0)),t}computeVertices(){this.getSize(Yc).multiplyScalar(.5),this.getCenter(Xc),ud.copy(this.matrix).setPosition(Xc),this.vertices=nN.map(t=>t.clone().multiply(Yc).applyMatrix4(ud))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=vK.map(([t,e])=>new vl(this.vertices[t],this.vertices[e])),this.centerEdges=this.edges.map(t=>t.getCenter(new E))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=bK.map(([t,e])=>this.vertices[t].clone().add(this.vertices[e]).multiplyScalar(.5))}}}),Q4=U(()=>{xc={Cloner:null,changeEntityProptotype:()=>{},createEntity:()=>{}}});function uS(t){return t?.isParticleSystem===!0}function n0(t){return t?.isHairSystem===!0}function Dc(t){return t?.isShapeBlendEntity===!0}function fD(t){return t?.isPathObject===!0}function Go(t){return t?.isObject2D===!0}function $a(t){return t?.isUIObject===!0}function nm(t){return t?.isCloner===!0}function am(t){return t?.isClone===!0}function uR(t){return t?.isComponentObject===!0}var Jr=U(()=>{});function Nr(t){hW.add(t)}function On(t,e){let i=`${t}:${e}`;hj.has(i)||hj.add(i)}function J4(t,e){uW.set(t,e)}function oN(t){return uW.get(t)}function ab(t,e){dW.set(t,e)}function lN(t){return dW.get(t)}function oj(t,e){cW.set(t,e)}function qgt(t){return cW.get(t)}function lj(){return gD}var hW,hj,uW,dW,cW,gD,t5,Oi=U(()=>{hW=new Set,hj=new Set,uW=new Map,dW=new Map,cW=new Map,gD=null,t5=null});function Hgt(t,e,i,r,s=new bt){return s.compose(t,e,$gt).multiply(i).scale(r)}var $gt,hN,Ng,yD,ob=U(()=>{ot(),dD(),$gt=new E(1,1,1),hN=new bt,(Ng||(Ng={})).is=function(t){return t&&t.__isSPEObject},yD=t=>class extends t{constructor(){super(...arguments),this.previousModelViewMatrix=new bt,this.copyPreviousMatrix=!0,this.pivotMatrix=new bt,this.matrixWorldRigid=new bt,this.shearScale=new bt,this.shearScaleInv=new bt,this.shearMatrix=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(hN.copy(this.parent.matrixWorld).invert()),e.multiply(hN.copy(this.pivotMatrix).invert()),!0)}isDescendantOf(e){e instanceof ur&&(e=e.uuid);let i=this;for(;i.parent;){if(i.parent.uuid===e)return!0;i=i.parent}return!1}updateMatrix(){!this.shearMatrix||(Hgt(this.position,this.quaternion,this.shearMatrix,this.scale,this.matrix),this.matrixWorldNeedsUpdate=!0)}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.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.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.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)Ng.is(r)&&r.traverseObject(e,i+1)}traverseObject(e,i=0){if(e(this,i)!==!0)for(let r of this.children)Ng.is(r)&&r.traverseObject(e,i+1)}updateMatrixWorldRigid(){this.hasNonUniformScale=rgt(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)),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}onAfterRender(e,i,r,s,n,a){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}}});function _K(t,e,i){return Zp.subVectors(e,t),KS.subVectors(e,i),Zp.cross(KS).length()<=dS}function Xgt(t){let e=cj.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 E(...s[0].data.position)];cg.copy(a[0]);for(let y=0;y<s.length-1;y++)Zp.fromArray(s[y].data.position),KS.fromArray(s[y+1].data.position),P1.subVectors(Zp,cg),R1.subVectors(Zp,KS),P1.cross(R1).length()>dS&&(n.push(s[y]),a.push(new E().copy(Zp)),cg.copy(Zp));let o=s[s.length-1];n.push(o),a.push(new E(...o.data.position));let l=r.isClosed,h=n.length-(l?0:1),u=n.length,d=[],c=[];for(let y=0;y<u;y++){let v=n[y].data;d.push(new E(...v.controlPrevious.position)),c.push(new E(...v.controlNext.position))}let p=[];for(let y=0;y<h;y++){let v=y===u-1?0:y+1;p.push(_K(a[y],c[y],a[v])&&_K(a[y],d[v],a[v]))}let m=[];for(let y=0;y<u;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===u-1))continue;let x=l&&y==0?u-1:y-1,S=l&&y==u-1?0:y+1,w=new E().subVectors(a[x],b).normalize(),T=new E().subVectors(a[S],b).normalize();_.prevDir=w,_.nextDir=T;let C=p[l&&y===0?u-1:y-1],M=p[y];if(C&&M){pg.addVectors(w,T).normalize();let A=cg.crossVectors(pg,w).length()/w.dot(pg);_.tan=A,_.removedLength=v.roundness/A}}for(let y=0;y<h;y++){let v=l&&y===u-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*u).fill(null);for(let y=0;y<h;y++){let v=l&&y===u-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(cg.copy(b.nextDir).setLength(b.removedLength)),_.prevDir&&w.add(cg.copy(_.prevDir).setLength(_.removedLength))),S.distanceTo(w)>dS&&(x=new iS(S,S.clone().lerp(w,.3),w.clone().lerp(S,.3),w))}else b.position.distanceTo(_.position)>dS&&(x=new iS(b.position,b.controlNext,_.controlPrevious,_.position));f[2*y+1]=x}for(let y=0;y<u;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;pg.addVectors(v.prevDir,v.nextDir).normalize(),P1.copy(_).lerp(x,.5);let w=_.distanceTo(x)/2;dj.copy(pg).multiplyScalar(Math.sqrt(Math.pow(S,2)-Math.pow(w,2))).add(P1),dR.copy(pg).multiplyScalar(-S).add(dj);let T=b.distanceTo(dR)/b.distanceTo(P1);R1.copy(v.prevDir).multiplyScalar(T*b.distanceTo(_)).add(b),uj.copy(R1).lerp(dR,2);let C=_.clone().lerp(R1,4/3),M=x.clone().lerp(uj,4/3);f[2*y]=new iS(_,C,M,x)}let g=new Ygt;for(let y=0;y<f.length;y++){let v=f[y];v&&g.add(v)}return g}(t);return cj.set(t.points,{isClosed:t.isClosed,curve:i}),i}var Ygt,dS,Zp,KS,cg,pg,P1,dR,R1,uj,dj,cj,D1,pj,cR,Kgt,Zgt,Qgt,vi,Nu,xK,wK,v_,uN,XM,dN,cN,vD,mj,h0,ku,Jgt=U(()=>{ot(),Ygt=class extends aU{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],h=Math.ceil(t*l/s),u=o.getPoints(h);for(let d=0;d<u.length;d++){let c=u[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}},dS=.001,Zp=new E,KS=new E,cg=new E,pg=new E,P1=new E,dR=new E,R1=new E,uj=new E,dj=new E,cj=new WeakMap}),mCt=U(()=>{ot(),D1=new bt,pj=new we,cR=new we,Kgt=new zi,Zgt=new E,Qgt=new E(0,1,0)}),yo=U(()=>{ot(),De(),pCt(),Li(),Q4(),Jr(),Oi(),ob(),Jgt(),mCt(),er(),(vi||(vi={})).is=function(t){return t&&t.__isEntity},Nu=t=>vi.is(t),xK={type:"completeState",isfromEntity:!0},wK=["x","y","z"],v_=new E,uN=new E(1,1,1),XM=new we,dN=new zi,cN=new bt,vD=t=>class extends yD(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 aj,this._recursiveBBox=new aj,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(vi.is(i))return i}entityChildrenCount(){let e=this.children.length;for(;e--;)if(vi.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(!vi.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)sm.toOps(this.data,s.data).forEach(n=>{let a=C4.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=sm.patch(this.data,s),sm.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=>{Nu(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(vi.is(i[r]))return i[r];if(vi.is(e))return e.traverseSortNextHelper()}}sortNext(){let e=this.children;return this.children.length>0&&vi.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)Nu(i)&&e(i)}traverseEntityAncestors(e){this.traverseAncestors(i=>{vi.is(i)&&e(i)})}traverseConcreteEntity(e,i=0){if(e(this,i)!==!0)for(let r of this.children)Nu(r)&&r.isConcreteEntity&&r.traverseEntity(e,i+1)}traverseEntity(e,i=0){if(e(this,i)!==!0)for(let r of this.children)Nu(r)&&r.traverseEntity(e,i+1)}traverseVisibleEntity(e){e(this);for(let i of this.children)Nu(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}hasEntityChild(){return this.children.some(e=>Nu(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),xU({position:this.position.toArray(),rotation:[this.rotation.x*zt.RAD2DEG,this.rotation.y*zt.RAD2DEG,this.rotation.z*zt.RAD2DEG],scale:this.scale.toArray(),shear:_l.fromMatrix(this.shearMatrix.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,wK[n]])??s)}updateTransformState(e,i){let r=!1;if(e.position&&(this.position.fromArray(this.getTransformValues("position",e,i)),r=!0),e.rotation&&(v_.fromArray(this.getTransformValues("rotation",e,i)).multiplyScalar(zt.DEG2RAD),this.rotation.setFromVector3(v_),r=!0),e.scale&&(this.scale.fromArray(this.getTransformValues("scale",e,i)),r=!0),e.shear&&(this.shearMatrix.fromArray(_l.toMatrix(e.shear)),r=!0),e.pivot!==void 0||e.pivotRotation!==void 0){if(r=!0,e.pivot!==void 0&&e.pivotRotation!==void 0)this.pivotMatrix.compose(v_.fromArray(e.pivot).negate(),XM.setFromEuler(dN.fromArray(e.pivotRotation.map(s=>s*zt.DEG2RAD))).invert(),uN);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=v_.setFromMatrixPosition(this.pivotMatrix);XM.setFromEuler(dN.fromArray(e.pivotRotation.map(n=>n*zt.DEG2RAD))).invert(),this.pivotMatrix.compose(s,XM,uN)}}return r&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(s=>{s.invalidateClonerTransform(this)})),e.position&&e.rotation&&e.scale&&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)vi.is(e)&&e.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(e=>{vi.is(e)&&e.disposeRecursively()})}toState(e=[]){return xU({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=tr(e.path,["states","*"]);if(o!==null){if(e.type===0){let[l]=o;if(this?.stateSelection===l){let h={...e.props};if(delete h.name,Object.values(e.props).some(u=>u===void 0)){let u=this.data;if(u!==void 0){let d=Dn.zoom(u,e.path.slice(2));if(d)for(let c in e.props)e.props[c]===void 0&&c in d&&(h[c]=d[c])}}a={...e,props:h,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:u,...d}=l;l=d}if(e.props.material!==void 0&&"material"in l){let{material:u,...d}=l;l=d}let h=Dn.removeOverridden(e.path,e.props,l);a={...e,props:h}}}if(this.updateByPatchedOpBase(a,sm.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),r),tr(e.path,["overrides"])){let l=[],h=[...e.path];for(l.push(h[1]),h.splice(0,2);h.length>0&&h[0]==="descendants";)l.push(h[1]),h.splice(0,2);if(l[l.length-1]===void 0){if(e.type===0)for(let u of Object.keys(e.props)){l[l.length-1]=u;let d=r.scene.findInstance([this.uuid,...l]);d&&(d.overrideData=e.props[u],d.updateState(mm.apply(d.component.data,d.overrideData),r))}}else{let u=r.scene.findInstance([this.uuid,...l]);if(u){let d=Dn.zoom(u.component.data,h);if((e={...e,path:h}).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}}u.overrideData=X4.resolve(i.overrides,l),u.updateByOp(e,Qn.applySimple(u.data,e),r,!1)}}}else if(this.instances.length>0){let l;if(e.path.length===0&&e.type===0){let h;for(let u of vc.rootOverrideProps)u in e.props&&(h===void 0&&(h={}),h[u]=e.props[u]);h&&(l={...e,props:h})}else for(let h of vc.rootOverrideProps)if(tr(e.path,[h])){l=e;break}l!==void 0&&this.instances.forEach(h=>{if(h.isInstanceRoot){let u=mm.filterOp(h.overrideData,l);u&&h.updateByOp(u,Qn.applySimple(h.data,u),r,!0)}}),this.instances.forEach(h=>{if(!h.isInstanceRoot){let u=mm.filterOp(h.overrideData,e);if(u){let d;d=n===h.data&&e===u?i:Qn.applySimple(h.data,u),h.updateByOp(u,d,r,!0)}}})}}updateByPatchedOpBase(e,i,r){if(this.dataPatched=i,e.path.length===0&&e.type===0)e.props.type!==void 0&&!r0.is(e.props.type)&&xc.changeEntityProptotype(this,this.data,r);else if(e.path.length===1&&e.path[0]==="geometry"&&e.type===0&&"type"in e.props){xc.changeEntityProptotype(this,this.data,r);for(let s of this.children)vi.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(tr(e.path,["pathSnapping"])!==null&&(this.updatePathSnapping(i.pathSnapping),this.isVirtualEntity&&r.scene?.syncInstancePathConstraint(this)),tr(e.path,["cloner"])!==null){let s=Qn.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(this.isVirtualEntity&&e.pathConstraints.getConstraint(this.uuid)||i);if(!a)return;this._needApplyPathSnapping=!1;let o=a.data;if(o.geometry.path.points.length<=1)return;let l=Xgt(o.geometry.path),h=function(p){let m=p%1;return m<0?m+1:m===0&&p>0?1:m}(r+s),u=null;try{u=l.curves.length?l.getPointAt(h):null}catch{}if(u===null)return;a.updateMatrixWorld();let d=this.parent?cN.copy(this.parent.matrixWorld):cN.identity(),c=function(p,m,f,g){pj.setFromRotationMatrix(D1.extractRotation(g));let y=p.clone().applyMatrix4(D1.copy(g).invert().multiply(f));if(m===null)cR.setFromRotationMatrix(D1.extractRotation(f));else{let v=m.clone().applyMatrix4(D1.extractRotation(f));cR.setFromRotationMatrix(D1.lookAt(Zgt.set(0,0,0),v,Qgt))}return{position:y,rotation:new E().setFromEuler(Kgt.setFromQuaternion(pj.invert().multiply(cR))).multiplyScalar(zt.RAD2DEG)}}(u,n==="tangential"?l.getTangentAt(h):null,a.matrixWorld,d);this.updateTransformState({position:c.position.toArray(),rotation:c.rotation.toArray()}),this.traverseEntity(p=>{p._cameraType&&p.dispatchEvent(xK)})}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=>nm(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(xc.Cloner===null)return void On("cloners","a cloner");this.cloner=new xc.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"})}}}),u0=U(()=>{ot(),yo(),(mj||(mj={})).is=t=>"objectHelper"in t,h0=(t,e)=>class extends vD(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 GS&&(r.visible=!0)}}updateEntityBoxSize(i,r){this.objectHelper.visible&&this.geometryHelper instanceof Yh?(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 GS&&(r.visible=!1)}}}}),bD=U(()=>{ot(),mD(),u0(),ku=class extends h0(rb,Gv){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 uh(t,e,i,r,s,n,a){c2.set(s,n,a).unproject(r);let o=e[t];if(o!==void 0){let l=i.getAttribute("position");for(let h=0,u=o.length;h<u;h++)l.setXYZ(o[h],c2.x,c2.y,c2.z)}}var c2,Yo,SK,t0t,fCt=U(()=>{ot(),_T(),xT(),c2=new E,Yo=new Eg,SK=class extends T1{constructor(t){let e=new fe,i=new zh({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],s=[],n={},a=new se(15711266),o=new se(15711266),l=new se(2857471);function h(d,c,p){u(d,p),u(c,p)}function u(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)}h("n1","n2",a),h("n2","n4",a),h("n4","n3",a),h("n3","n1",a),h("f1","f2",a),h("f2","f4",a),h("f4","f3",a),h("f3","f1",a),h("n1","f1",a),h("n2","f2",a),h("n3","f3",a),h("n4","f4",a),h("p","n1",o),h("p","n2",o),h("p","n3",o),h("p","n4",o),h("u1","u2",l),h("u2","u3",l),h("u3","u1",l),e.setAttribute("position",new me(r,3)),e.setAttribute("color",new me(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;Yo.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let i=.8;uh("n1",e,t,Yo,-1,-1,i),uh("n2",e,t,Yo,1,-1,i),uh("n3",e,t,Yo,-1,1,i),uh("n4",e,t,Yo,1,1,i);let r=i;uh("f1",e,t,Yo,-1,-1,r),uh("f2",e,t,Yo,1,-1,r),uh("f3",e,t,Yo,-1,1,r),uh("f4",e,t,Yo,1,1,r);let s=r;uh("u1",e,t,Yo,.35,1.1,s),uh("u2",e,t,Yo,-.35,1.1,s),uh("u3",e,t,Yo,0,1.55,s),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}},t0t=class extends sb(SK){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){nb(this.object,this.geometry,t,e,!0)}}});function TK(t){return 1-Math.pow(1-t,3)}var af,YM,KM,ZM,$0,QM,lu,zs,Kh=U(()=>{ot(),fCt(),De(),u0(),er(),af=new E,YM=new E,KM=new we,ZM=new E,$0=new E,QM=new E,lu=class extends h0(Eg,t0t){constructor(t="",e={...lS.defaultData,name:""}){super(),this._cameraType="OrthographicCamera",this.targetOffset=yc.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=lu.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 zv(-.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=lu.projectionTransitionsEnabled;lu.projectionTransitionsEnabled=!1;try{return t()}finally{lu.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 E(t,e,i)),super.lookAt(t),this.getWorldPosition(af),this.targetOffset=af.distanceTo(t)}getTarget(t=new E){return this.getWorldDirection(YM),this.getWorldPosition(af),YM.multiplyScalar(this.targetOffset),t.copy(af).add(YM),t}getDistanceToTarget(){let t=this.getTarget();return this.getWorldPosition(af),af.distanceTo(t)}updateUp(){this.getWorldQuaternion(KM),ZM.set(0,0,1).applyQuaternion(KM),$0.copy(ur.DEFAULT_UP),this.isUpVectorFlipped&&$0.negate(),$0.applyQuaternion(KM),QM.copy(ur.DEFAULT_UP).projectOnPlane(ZM),this.angleOffsetFromUp=QM.angleTo($0),this.angleOffsetFromUp*=QM.cross($0).dot(ZM)>=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 E),i=t.getWorldDirection(new E).multiplyScalar(this.targetOffset);return{position:e.clone().add(i),target:e}}getViewToTarget(t){let e=this.getWorldDirection(new E).multiplyScalar(this.targetOffset);return{position:t.clone().sub(e),target:t}}getViewToObject(t){let e=new E;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:TK(e)}get _activeSubCamera(){return this._cameraType==="PerspectiveCamera"?this.perspCamera:this.orthoCamera}_canAnimateProjection(){return lu.projectionTransitionsEnabled&&typeof requestAnimationFrame=="function"&&typeof performance<"u"&&performance.now()-this._createdAt>=lu.projectionTransitionMinAgeMs}_beginProjectionTransition(t){let e=this._projectionTransition;e===void 0&&(e={from:new bt,blend:new bt,blendInverse:new bt,start:0,duration:lu.projectionTransitionDuration,referenceDepth:1,raf:0,requestRender:t},this._projectionTransition=e),e.from.copy(this.projectionMatrix),e.start=performance.now(),e.duration=lu.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=TK(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 h=0;h<16;h++)n[h]=r[h]+(s[h]-r[h])*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=yc.sanitizeTargetOffset(t.targetOffset),this.updateProjectionMatrix(),this._syncProjectionTransition(t),this}toCameraState(t=[]){return xU({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=yc.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}}},(zs=lu).projectionTransitionsEnabled=!1,zs.projectionTransitionDuration=350,zs.projectionTransitionMinAgeMs=1e3});function e0t(t){return t.type==="TorusGeometry"&&t.arc===360}var i0t,JM,fj,ZS=U(()=>{ot(),i0t=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:h,cornerRadius:u,cornerSegments:d}=t.parameters,c=new fj(!1,e,i,r,s,n,a,o,l,h,u,d);return Object.assign(c,{userData:{...t,type:"HelixGeometry"}})}},JM=new pm([0,0,0],1),fj=class extends fe{constructor(t=!0,e=1,i=1,r=1,s=1,n=1,a=1,o=1,l=1,h=1,u=1,d=1){if(super(),n===0)return;let c=t&&n===1;c&&(d=0),u>100&&(u=100),u===0&&(d=0);let p,m,f,g,y,v,b,_,x=()=>new E,S=new E,w=x(),T=x(),C=x(),M=x(),A=x(),P=x(),O=x(),D=x(),N=x(),z=x(),k=x(),B=i-2*o+.001,V=B/n,q=Math.ceil(a*n),W=q+1,H=B/q,rt=-B/2,it=h+1,ft=2*Math.PI/h,dt=Math.PI/2/d,K=Math.min((1-u/100)*o,o-.01),lt=o-K,_t=0,xt=2*d+2,wt=it*xt/2,gt=wt+it*W,Dt=Math.max(0,it*(W+xt)),[Lt,It,kt]=[3,3,2].map(Be=>Array(Dt*Be).fill(0)),Nt=[],Gt=s-o;function qt(Be,te){let ni=Math.PI/2;v=te*H,_=2*Math.PI*(v%V)/V+ni,v+=rt,b=Math.sin(_)*Gt,y=Math.cos(_)*Gt,t?Be.set(y,b,v):Be.set(y,v,b)}qt(S,-1e-10),qt(w,0),M.copy(S),qt(S,1);let Ct=S.distanceTo(w),ne=c?0:lt+K,Ut=Ct*q+2*ne,Yt=K,Zt=Ut-ne;for(let Be=0;Be<=q;Be++){qt(T,Be),k.subVectors(T,M).normalize(),M.copy(T),N.copy(T).setComponent(+t+1,0).normalize(),z.crossVectors(k,N).normalize();let te=Be===0,ni=Be===q,bi=te?3*Math.PI/2:dt,Zs=te?Yt:Zt,Hi=te?it:gt,ai=te?0:Dt-it,Fr=k.clone().multiplyScalar(te?-lt:lt).add(T),ts=k.clone().multiplyScalar(te?-1:1).normalize();for(let Ur=0;Ur<it;Ur++){let Fi=Ur*ft;if(A.addVectors(S.copy(N).multiplyScalar(o*Math.cos(Fi)),w.copy(z).multiplyScalar(o*Math.sin(Fi))),P.copy(A).normalize(),te||ni){c||(_t=ai+Ur,[0,1,2].forEach(Ti=>{Lt[3*_t+Ti]=Fr.getComponent(Ti),It[3*_t+Ti]=ts.getComponent(Ti)}),kt[2*_t]=+ni,kt[2*_t+1]=Ur/h),w.copy(P).multiplyScalar(K),C.addVectors(T,w);for(let Ti=0;Ti<d;Ti++){let Qs=Ti*dt+bi;O.addVectors(S.copy(k).multiplyScalar(lt*Math.sin(Qs)),w.copy(P).multiplyScalar(lt*Math.cos(Qs))),D.copy(O).normalize(),w.addVectors(C,O),O.normalize(),_t=Hi+Ti*it+Ur,[0,1,2].forEach(vr=>{Lt[3*_t+vr]=w.getComponent(vr),It[3*_t+vr]=D.getComponent(vr)});let ms=+te+Math.sin(Qs);kt[2*_t]=(Zs+lt*ms)/Ut,kt[2*_t+1]=Ur/h}}w.addVectors(T,A),_t=wt+Be*it+Ur,[0,1,2].forEach(Ti=>{Lt[3*_t+Ti]=w.getComponent(Ti),It[3*_t+Ti]=P.getComponent(Ti)}),kt[2*_t]=(ne+Be*Ct)/Ut,kt[2*_t+1]=Ur/h}}let $=W+2*d+2,[ie,Ce]=[+c,$-1];for(let Be=ie;Be<=Ce-1;Be++){let te=c&&Be===Ce-1;for(let ni=0;ni<it-1;ni++)p=Be*it+ni,m=p+1,f=(te?ni:p)+it,g=(te?ni+1:m)+it,Be===0?Nt.push(m,g,f):Be===$-2?Nt.push(p,m,f):Nt.push(p,m,f,m,g,f)}this.setIndex(Nt),this.setAttribute("position",new me(Lt,3)),this.setAttribute("normal",new me(It,3)),this.setAttribute("uv",new me(kt,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 h=1;h<n;h++)for(let u=0;u<a;u++)t=h*o+u,e=t+1,i=t+o,r=e+o,l.push(t,e,i,e,r,i);for(let h=0;h<a;h++)t=n*o+h,e=t+1,i=h+o,r=h+1+o,l.push(t,e,i,e,r,i);return JM.array=new Uint32Array(l),JM.count=l.length,JM}}});function gCt(t){return AK||(AK=async function(){let e=t??"https://cdn.spline.design/@splinetool/runtime@2.0.206/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}),QS=r}())}function e5(){if(QS===void 0)throw new Error("boolean-wasm is not loaded");return QS}function pW(t){let e=JS.get(t);if(e===void 0)throw new Error("Unknown csg mesh set handle "+t);return e}function mW(t){return JS.set(++gj,t),gj}function yCt(t,e,i){if(QS===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=e0t(a.userData.parameters)?a.getClosedTorusIndicesForBooleanOrSubdiv():a.getIndex();let h,u=a.getAttribute("position");if(l===null){h=new Uint32Array(u.count);for(let p=0;p<h.length;p++)h[p]=p}else h=l.array instanceof Uint32Array?l.array:new Uint32Array(l.array);let d=a.getAttribute("normal"),c=d!==void 0&&d.itemSize===3&&d.count===u.count&&d.array instanceof Float32Array&&d.isInterleavedBufferAttribute!==!0?d.array:void 0;return{positions:u.array,indices:h,normals:c}}(t,e);return mW(new QS.CsgMesh(r,s,n))}function MK(t,e){let i=e5(),r=s0t[e];if(r===void 0)throw new Error("Unknown boolean operation "+e);let s=t.map(pW);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 pN(t,e){pW(t).transform(new Float32Array(e.elements))}function r0t(t){let e=JS.get(t);e!==void 0&&(e.free(),JS.delete(t))}var QS,JS,gj,AK,s0t,_D=U(()=>{ot(),ZS(),JS=new Map,gj=0,s0t={0:0,1:1,2:2}});function of(t){return t!==null&&"booleanOp"in t}var yj,n0t,vCt=U(()=>{ot(),yo(),_D(),yj=class extends vD(gr){constructor(){super(...arguments),this.booleanMeshSetAddress=-1,this.booleanWasTransformed=!1,this.booleanMatrixInvOld=new bt}updateVisible(t){super.updateVisible(t),this.visible=!of(this.parent)&&this.visible,of(this.parent)&&this.parent.invalidateDownstreamBooleanData()}onClonerLayoutUpdated(){of(this.parent)&&this.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(r0t(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}dispose(){super.dispose(),this.freeBooleanPointer()}invalidateDownstreamBooleanData(t=!1){return t?this.booleanWasTransformed=!0:this.freeBooleanPointer(),of(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let t of this.children)t instanceof yj&&(t.freeBooleanPointer(),of(t)&&t.invalidateUpstreamBooleanData())}updateTransformState(t,e){let i=super.updateTransformState(t,e);return i&&of(this.parent)&&this.invalidateDownstreamBooleanData(!0),i}onVariableUpdate(t=!1){super.onVariableUpdate(t),of(this.parent)&&this.invalidateDownstreamBooleanData(!0)}}}),bCt=U(()=>{n0t=null});function fW(t,e=0,i=t.count,r,s){let n=1/0,a=1/0,o=1/0,l=-1/0,h=-1/0,u=-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>h&&(h=p),m>u&&(u=m)}p2.min.set(n,a,o),p2.max.set(l,h,u),p2.getCenter(r),p2.getSize(s).multiplyScalar(.5)}var p2,CK,EK,Ks,na=U(()=>{ot(),vCt(),bCt(),p2=new dr,CK=new fe,EK=new jo,Ks=class extends yj{constructor(t,e){super(CK,EK),this.super_Entity(t,e)}updateState(t,e){this.updateState_Entity(t,e)}raycast(t,e){if(this.raycastDeformed(t,e))return;let i=n0t;i===null?super.raycast(t,e):i(this,t,e)}raycastDeformed(t,e){return!1}updateEntityBoxSize(t,e){let i=this.geometry.getAttribute("position");i!==void 0?fW(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,t,e):super.updateEntityBoxSize(t,e)}}});function a0t(t){return t?.isClassicNodeMaterial===!0}var Dr,vj,o0t,l0t,cS,h0t,u0t,d0t,c0t=U(()=>{}),Nc=U(()=>{ot(),Dr=class extends se{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}}}),_Ct=U(()=>{Nc(),vj=class extends Dr{}}),xCt=U(()=>{o0t=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}}}),p0t=U(()=>{xCt(),l0t=class extends o0t{create(t){return URL.createObjectURL(new Blob([t]))}dispose(t,e){URL.revokeObjectURL(e)}}}),m0t=U(()=>{h0t=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}},u0t=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}}}),wCt=U(()=>{ot(),d0t=class extends Qmt{constructor(t){super(t),this.type=si}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(`
|
|
382
382
|
`))&&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]=Xh.toHalfFloat(Math.min(p[m+0]*v,65504)),f[g+1]=Xh.toHalfFloat(Math.min(p[m+1]*v,65504)),f[g+2]=Xh.toHalfFloat(Math.min(p[m+2]*v,65504)),f[g+3]=Xh.toHalfFloat(1)},n=new Uint8Array(t);n.pos=0;let a,o,l,h=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+`
|
|
383
383
|
`;m=i(p),m!==!1;)if(x.string+=m+`
|
|
384
384
|
`,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+`
|
|
385
|
-
`;return 2&x.valid||e(3,"missing format specifier"),4&x.valid||e(3,"missing image size specifier"),x}(n),u=h.width,d=h.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,C=0;for(;C<_&&b<p.byteLength;){T=p[b++];let A=T>128;if(A&&(T-=128),(T===0||C+T>_)&&e(3,"bad scanline data"),A){let P=p[b++];for(let O=0;O<T;O++)S[C++]=P}else S.set(p.subarray(b,b+T),C),C+=T,b+=T}let M=g;for(let A=0;A<M;A++){let P=0;y[v]=S[A+P],P+=g,y[v+1]=S[A+P],P+=g,y[v+2]=S[A+P],P+=g,y[v+3]=S[A+P],v+=4}w--}return y}(n.subarray(n.pos),u,d);switch(this.type){case Ye: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=Ye;break;case si: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=si;break;default:throw new Error("THREE.HDRLoader: Unsupported type: "+this.type)}return{width:u,height:d,data:a,header:h.string,gamma:h.gamma,exposure:h.exposure,type:o,colorSpace:Hu,minFilter:pe,magFilter:pe,generateMipmaps:!1,flipY:!0}}setDataType(t){return this.type=t,this}}});function PK(t){return t.length>2&&t[0]===35&&t[1]===63}function mN(t){return typeof t=="object"&&t!==null&&t.isSplineHdr===!0}function f0t(t){let e=new yr(t.data,t.width,t.height,hn,si);return e.flipY=!1,e.image.isSplineHdr=!0,e.needsUpdate=!0,e}var RK,gW,Sg,g0t=U(()=>{ot(),wCt()}),y0t=U(()=>{ot(),p0t(),m0t(),g0t(),RK=0,gW=class extends h0t{constructor(t,e){super(t,e.imageHolderCache),this.data=t,this.shared=e,this.instanceId=++RK,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?PK(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&&PK(r)?function(n){try{let a=new d0t().parse(n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength));if(!a||!a.width||!a.height)return null;let{width:o,height:l}=a,h=a.data,u=new Uint16Array(h.length),d=4*o,c=f=>Xh.toHalfFloat(Math.pow(Math.max(Xh.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)u[y+v]=m(h[g+v]),u[y+v+1]=m(h[g+v+1]),u[y+v+2]=m(h[g+v+2]),u[y+v+3]=h[g+v+3]}return{isSplineHdr:!0,data:u,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:(cS||(cS=new l0t),cS.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 RG(this.img,void 0,t,t):this.isHdr?(s=f0t(this.img),s.wrapS=t,s.wrapT=t,s.magFilter=i,s.minFilter=e):s=new di(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()}}}),v0t=U(()=>{y0t(),Sg=class extends gW{}});function SCt(t){if(typeof t=="string")return t;let e=bj.get(t);return e||(e={url:URL.createObjectURL(new Blob([t]))},bj.set(t,e)),e.url}var bj,TCt=U(()=>{bj=new Map});function MCt(){if(!_j)return DK||(DK=async function(){await Promise.resolve().then(()=>(cH(),g2t)),b0t(window!==void 0?window:global),_j=!0}())}var b0t,_0t,_j,DK,x0t=U(()=>{_0t=new Promise(t=>{b0t=t}),_j=!1});function OK(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 ACt(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;OK(a.events,i),e=e||i.some(o=>o.data.type==="Audio")}),s.events===void 0||Array.isArray(s.events)===!1)return!0;OK(s.events,i),e=e||i.some(n=>n.data.type==="Audio")}),e}var IK,tv,yW=U(()=>{TCt(),x0t(),_0t.then(t=>IK=t),tv=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:SCt(t),format:"wav"},this.sound=new IK.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 NK(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 vW,bW=U(()=>{vW=null});function BK(t){return new Y(t.y,-t.x)}var _W,xj,w0t,S0t,tA,kK,i5,T0t,fN,r5=U(()=>{ot(),_W=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=zt.clamp(s.thetaLength,0,360),s.hollow=zt.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:h,radiusTop:u,radiusBottom:d,cornerRadius:c,cornerSegments:p,hollow:m}=t.parameters;h===0?(e=new fe,e.setAttribute("position",new me([],3))):e=c||m?new xj(u,d,s,n,a,o,l,h*Math.PI/180,c,c,p,m):new eS(u,d,s,n,a,o,l,h*Math.PI/180);let f=r/i;return f!==1&&e.scale(1,1,f),Object.assign(e,{userData:{...t,type:"CylinderGeometry"}})}},xj=class extends fe{constructor(t,e,i,r,s,n,a,o,l,h,u,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,h=0);let p=i/2;c&&t==0&&(t=l),c&&e==0&&(e=h);let m=new Y(t,p),f=new Y(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 C=Math.PI-_.angle(),M=_.angle(),A=Math.tan(M/2),P=Math.tan(C/2),O=A+P,D=d?O:P,N=d?O:A;if(l=Math.min(l,(t-S)/D,_.length()/O),h=Math.min(h,(e-w)/N,_.length()/O),l>0){let Nt=l/A;g=m.clone().sub(new Y(Nt,l)),d&&(v=g.clone(),v.x-=x-O*l),m.sub(_.clone().setLength(Nt))}if(h>0){let Nt=h/P;y=f.clone().sub(new Y(Nt,-h)),f.add(_.clone().setLength(Nt)),d&&(b=y.clone(),b.x-=x-O*h,T.sub(_.clone().setLength(Nt)))}_=m.clone().sub(f);let z=_.length()<.5,k=[],B=[],V=[],q=[],W=[],H=[],rt=(Nt,Gt,qt,Ct,ne)=>{for(let Ut=0;Ut<u+1;Ut++){let Yt=Ut/u,Zt=Ct<0?Yt:1-Yt;ne&&(Zt-=1),Zt*=Nt;let $=Math.sin(Zt),ie=Math.cos(Zt)*Ct,Ce=ie*Gt+qt.y;k.push($*Gt+qt.x),B.push(Ce),V.push($),q.push(ie),W.push(.5+Ce/i),H.push(!1)}},it=(Nt,Gt,qt)=>{let Ct=[Nt,Gt];qt<0&&Ct.reverse();for(let ne of Ct)k.push(ne),B.push(p*qt),V.push(0),q.push(qt),W.push(.5),H.push(!0)};if(b&&y?(rt(C,h,b,-1,!0),rt(M,h,y,-1,!1)):y?(it(y.x,0,-1),rt(M,h,y,-1,!1)):n||it(e,w,-1),!z){let Nt=BK(_).normalize();for(let Gt=0;Gt<=s;Gt++){let qt=Gt/s,Ct=_.y*qt+f.y;k.push(_.x*qt+f.x),B.push(Ct),V.push(Nt.x),q.push(Nt.y),W.push(.5+Ct/i),H.push(!1)}}if(v&&g?(rt(C,l,g,1,!1),rt(M,l,v,1,!0)):g?(rt(C,l,g,1,!1),it(g.x,0,1)):n||it(t,S,1),d&&!z){let Nt=BK(_).multiplyScalar(-1).normalize();for(let Gt=0;Gt<=s;Gt++){let qt=Gt/s,Ct=_.y*-qt+T.y;k.push(_.x*-qt+T.x),B.push(Ct),V.push(Nt.x),q.push(Nt.y),W.push(.5+Ct/i),H.push(!1)}}let ft=k.length,dt=ft+(d&&!n?1:0),K=(Nt,Gt)=>Nt*ft+(Gt===ft?0:Gt),lt=o<2*Math.PI,_t=(r+1)*ft+(lt?2*(1+dt):0),xt=new Float32Array(3*_t),wt=new Float32Array(3*_t),gt=new Float32Array(2*_t),Dt=_t-1>65535?new Uint32Array(r*Math.max(0,dt-1)*6+(lt?2*(dt+1)*3:0)):new Uint16Array(r*Math.max(0,dt-1)*6+(lt?2*(dt+1)*3:0)),Lt=0,It=0;for(let Nt=0;Nt<=r;Nt++){let Gt=Nt/r,qt=Gt*o+a,Ct=Math.sin(qt),ne=Math.cos(qt);for(let Ut=0;Ut<ft;Ut++){let Yt=3*It,Zt=2*It,$=k[Ut],ie=V[Ut];xt[Yt]=$*Ct,xt[Yt+1]=B[Ut],xt[Yt+2]=$*ne,wt[Yt]=ie*Ct,wt[Yt+1]=q[Ut],wt[Yt+2]=ie*ne,H[Ut]?(gt[Zt]=.5,gt[Zt+1]=.5):(gt[Zt]=Gt,gt[Zt+1]=W[Ut]),It++}}for(let Nt=0;Nt<r;Nt++)for(let Gt=0;Gt<dt-1;Gt++){if(n&&d&&Gt==s)continue;let qt=K(Nt,Gt),Ct=K(Nt+1,Gt),ne=K(Nt+1,Gt+1),Ut=K(Nt,Gt+1),Yt=xt[3*ne+0],Zt=xt[3*ne+2];Dt[Lt++]=qt,Dt[Lt++]=Ct,Dt[Lt++]=Ut,(Yt!=0||Zt!=0)&&(Dt[Lt++]=Ct,Dt[Lt++]=ne,Dt[Lt++]=Ut)}function kt(Nt,Gt,qt){let Ct=Math.sin(qt),ne=Math.cos(qt),Ut=-ne,Yt=Ct,Zt=Nt<0?(te,ni,bi)=>{Dt[Lt++]=te,Dt[Lt++]=ni,Dt[Lt++]=bi}:(te,ni,bi)=>{Dt[Lt++]=te,Dt[Lt++]=bi,Dt[Lt++]=ni},$=(t+e+S+w)/4,ie=3*It,Ce=2*It;xt[ie]=$*Ct,xt[ie+1]=0,xt[ie+2]=$*ne,wt[ie]=Ut,wt[ie+1]=0,wt[ie+2]=Yt,gt[Ce]=.5,gt[Ce+1]=.5;let Be=It++;for(let te=0;te<dt;te++){let ni=3*(Gt+(te===ft?0:te));ie=3*It,Ce=2*It,xt[ie]=xt[ni],xt[ie+1]=xt[ni+1],xt[ie+2]=xt[ni+2],wt[ie]=Ut,wt[ie+1]=0,wt[ie+2]=Yt;let bi=ni/3*2|0;gt[Ce]=gt[bi],gt[Ce+1]=gt[bi+1],It++}for(let te=Be+1;te<It-1;te++)Zt(Be,te,te+1);Zt(Be,It-1,Be+1)}lt&&(kt(-1,0,a),kt(1,r*ft,a+o)),this.setIndex(new ve(Dt.slice(0,Lt),1)),this.setAttribute("position",new ve(xt,3)),this.setAttribute("normal",new ve(wt,3)),this.setAttribute("uv",new ve(gt,2))}}}),VK=U(()=>{ot(),r5(),w0t=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=zt.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:h,cornerRadiusTop:u,cornerRadiusBottom:d,cornerSegments:c}=t.parameters;h===0?(e=new fe,e.setAttribute("position",new me([],3))):e=u>0||d>0||h<360?new xj(0,i/2,s,n,a,o,l,h*Math.PI/180,u,d,c,0,!0):new w4(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"}})}}}),zK=U(()=>{ot(),S0t=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:h}=t.parameters;return e=l===0?new Yh(i,r,s,n,a,o):new kK(i,r,s,n,a,o,l,h),Object.assign(e,{userData:{...t,type:"CubeGeometry"}})}},tA=Math.PI/2,kK=class extends fe{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,h=o+1,u=2*((n+1)*(s+1)+(r+1)*(n+1)+(r+1)*(s+1))+(l?4*h*(n+1+(r+1)+(s+1))+h*(h+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*u),m=new Float32Array(3*u),f=new Float32Array(2*u),g=u-1>65535?new Uint32Array(6*d+3*c):new Uint16Array(6*d+3*c),y=0,v=0,b=new Float64Array(h),_=new Float64Array(h),x=new Float64Array(h),S=new Float64Array(h);for(let O=0;O<h;O++){let D=O/o*tA;b[O]=Math.sin(D)*a,_[O]=(1-Math.cos(D))*a,x[O]=Math.sin(D),S[O]=Math.cos(D)}let w=h*(h+1)/2,T=new Float64Array(3*w),C=new Float64Array(3*w);{let O=new E(t/2,e/2,i/2);O.subScalar(a);let D=0;for(let N=0;N<=o;N++){let z=tA*(1-N/o),k=Math.cos(z),B=Math.sin(z),V=0;for(let q=0;q<=N;q++){let W=k*Math.cos(V),H=B,rt=k*Math.sin(V);T[3*D]=W,T[3*D+1]=H,T[3*D+2]=rt,C[3*D]=O.x+W*a,C[3*D+1]=O.y+H*a,C[3*D+2]=O.z+rt*a,D++,V+=tA/N}}}function M(O,D,N,z,k,B,V,q,W,H){let rt=(B-2*a)/W,it=(V-2*a)/H,ft=B/2-a,dt=V/2-a,K=q/2,lt=W+1,_t=H+1,xt=0,wt=new E;for(let gt=0;gt<_t;gt++){let Dt=gt*it-dt;for(let Lt=0;Lt<lt;Lt++){let It=Lt*rt-ft,kt=3*(y+xt),Nt=2*(y+xt);wt[O]=It*z,wt[D]=Dt*k,wt[N]=K,p[kt]=wt.x,p[kt+1]=wt.y,p[kt+2]=wt.z,wt[O]=0,wt[D]=0,wt[N]=q>0?1:-1,m[kt]=wt.x,m[kt+1]=wt.y,m[kt+2]=wt.z,f[Nt]=Lt/W,f[Nt+1]=1-gt/H,xt+=1}}for(let gt=0;gt<H;gt++)for(let Dt=0;Dt<W;Dt++){let Lt=y+Dt+lt*gt,It=y+Dt+lt*(gt+1),kt=y+(Dt+1)+lt*(gt+1),Nt=y+(Dt+1)+lt*gt;g[v++]=Lt,g[v++]=It,g[v++]=Nt,g[v++]=It,g[v++]=kt,g[v++]=Nt}y+=xt}function A(O,D,N,z,k,B,V,q,W,H){let rt=(V-2*a)/H,it=V/2-a,ft=q/2-a,dt=W/2,K=H+1,lt=0,_t=new E,xt=new E;for(let wt=0;wt<o+1;wt++){_t[D]=(ft+b[wt])*k,_t[N]=(dt-_[wt])*B,xt[O]=0,xt[D]=x[wt]*Math.sign(_t[D]),xt[N]=S[wt]*Math.sign(_t[N]);for(let gt=0;gt<K;gt++){let Dt=gt*rt-it;_t[O]=Dt*z;let Lt=3*(y+lt),It=2*(y+lt);p[Lt]=_t.x,p[Lt+1]=_t.y,p[Lt+2]=_t.z,m[Lt]=xt.x,m[Lt+1]=xt.y,m[Lt+2]=xt.z,f[It]=gt/H,f[It+1]=0,lt+=1}}for(let wt=0;wt<o;wt++)for(let gt=0;gt<H;gt++){let Dt=y+gt+K*wt,Lt=y+gt+K*(wt+1),It=y+(gt+1)+K*(wt+1),kt=y+(gt+1)+K*wt;g[v++]=Dt,g[v++]=Lt,g[v++]=kt,g[v++]=Lt,g[v++]=It,g[v++]=kt}y+=lt}function P(O,D,N){let z=O*D*N>0?(B,V,q)=>{g[v++]=B,g[v++]=V,g[v++]=q}:(B,V,q)=>{g[v++]=B,g[v++]=q,g[v++]=V},k=y;for(let B=0;B<w;B++){let V=3*B,q=3*y,W=2*y;p[q]=O*C[V],p[q+1]=D*C[V+1],p[q+2]=N*C[V+2],m[q]=O*T[V],m[q+1]=D*T[V+1],m[q+2]=N*T[V+2],f[W]=0,f[W+1]=0,y++}for(let B=0;B<o;B++){let V=k+B*(B+1)/2,q=k+(B+1)*(B+2)/2;z(V,q+1,q);for(let W=1;W<=B;W++)z(V+W-1,V+W,q+W),z(V+W,q+W+1,q+W)}}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&&(A("z","y","x",-1,-1,1,i,e,t,n),A("z","y","x",1,-1,-1,i,e,t,n),A("z","y","x",-1,1,-1,i,e,t,n),A("z","y","x",1,1,1,i,e,t,n),A("x","y","z",-1,-1,-1,t,e,i,r),A("x","y","z",1,-1,1,t,e,i,r),A("x","y","z",-1,1,1,t,e,i,r),A("x","y","z",1,1,-1,t,e,i,r),A("y","x","z",-1,-1,1,e,t,i,s),A("y","x","z",1,-1,-1,e,t,i,s),A("y","x","z",1,1,1,e,t,i,s),A("y","x","z",-1,1,-1,e,t,i,s),P(1,1,1),P(-1,1,1),P(1,-1,1),P(-1,-1,1),P(1,1,-1),P(-1,1,-1),P(1,-1,-1),P(-1,-1,-1)),this.setIndex(new ve(g,1)),this.setAttribute("position",new ve(p,3)),this.setAttribute("normal",new ve(m,3)),this.setAttribute("uv",new ve(f,2))}}}),M0t=U(()=>{ot(),i5=class extends fe{constructor(t=[],e=[],i="",r=1,s=.2,n=4){super(),this.type="PolyhedronGeometryRound";let a,o,l,h=0;return function(){(s=Math.min(.99999,s))==0&&(n=0);let u={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[i],d=new E,c=d.clone(),p=new ks,m=s*r,f=r-m,g=n+1,y=new E,v=(K,lt)=>y.subVectors(K,lt).normalize(),b=(K,lt)=>Array(K).fill(void 0).map(lt),_=b(t.length/3,(K,lt)=>new E().fromArray(t,3*lt).setLength(r)),x=[],S=1e6;for(let K=0;K<_.length;K++){let lt,_t,xt,wt=_[K],gt=[],Dt=1e10,Lt=-1;for(;(Lt=e.indexOf(K,Lt+1))!=-1;){let Gt=Lt-Lt%3;lt=e[Gt+(Lt+1)%3],_t=e[Gt+(Lt+2)%3],xt=wt.distanceToSquared(_[lt]),Dt=Math.min(Dt,xt),gt.push([lt,_t,xt])}Dt+=1e-6;let It=[],kt=0,Nt=gt.length;for(let Gt=0;Gt<Nt;Gt++){[lt,_t,xt]=gt[kt];let qt=x[lt]?.includes(K)==1;xt<=Dt&&It.push(lt+ +qt*S),kt=gt.findIndex(Ct=>Ct[0]==_t)}x.push(It)}let w=[];{let K,lt,_t=0,xt=0,wt=u==3;for(let gt=0;gt<=n;gt++){K=gt*(gt+1)/2,lt=(gt+1)*(gt+2)/2;for(let Dt=0;Dt<n-gt;Dt++)[_t,xt]=[K+Dt+gt+2,lt+Dt+gt+3],w.push(K,lt,...wt?[xt,K]:[_t,lt],xt,_t),[K,lt]=[_t,xt];w.push(K,lt,K+n+2)}}let T=0;for(let K=0;K<x.length;K++)for(let lt=0;lt<u;lt++)x[K][lt]<S&&T++;let C=_.length*u*w.length*3+T*g*6*3+2*T*3*3;a=new Float64Array(C),o=new Float64Array(C),l=new Float64Array(C/3*2);let M=(K,lt,_t)=>{let xt=h/3*2;l[xt]=Math.atan2(_t,-K)/2/Math.PI+.5,l[xt+1]=1-(Math.atan2(-lt,Math.sqrt(K*K+_t*_t))/Math.PI+.5)},A=K=>{a[h]=K.x,a[h+1]=K.y,a[h+2]=K.z,o[h]=y.x,o[h+1]=y.y,o[h+2]=y.z,M(K.x,K.y,K.z),h+=3},P=K=>{a[h]=K[0].x,a[h+1]=K[0].y,a[h+2]=K[0].z,o[h]=K[1].x,o[h+1]=K[1].y,o[h+2]=K[1].z,M(K[0].x,K[0].y,K[0].z),h+=3},O=(n+2)*(n+3)/2,D=new Float64Array(3*O),N=new Float64Array(3*O),z=new Float64Array(2*O),k=b(2*u*g,()=>new E),B=b(n*Math.max(0,n-1)/2,()=>new E),V=d.clone(),q=d.clone(),W=d.clone(),H=d.clone(),rt=d.clone(),it=[],ft=b(_.length,()=>b(u,()=>d.clone()));for(let K=0;K<_.length;K++){d.copy(_[K]).normalize(),V.copy(d).multiplyScalar(f);let lt=x[K];for(let It=0;It<lt.length;It++){let kt=lt[It],Nt=lt[(It+1)%u];p.setFromPointsAndIndices(_,K,kt%S,Nt%S),p.b.sub(p.a).setLength(1e10).add(p.a),p.c.sub(p.a).setLength(1e10).add(p.a),p.closestPointToPoint(V,ft[K][It])}let _t=0,xt=[],wt=[],gt=new E;n==0&&[...ft[K]].reduce((It,kt)=>It.add(kt),gt).multiplyScalar(1/u);for(let It=0;It<u;It++){let kt=[],Nt=(It-1+u)%u,Gt=ft[K][Nt],qt=ft[K][It];d.copy(Gt).sub(V),c.copy(qt).sub(V);let Ct=V.angleTo(d),ne=d.angleTo(c),Ut=Math.cos(Ct)*m;n==0?q.copy(gt):q.copy(V).setLength(f+Ut),xt.push(Ut);let Yt=[q,Gt,qt];for(let Zt=0;Zt<2;Zt++){let $=Yt[Zt],ie=Yt[Zt+1];H.subVectors($,V),rt.subVectors(ie,V),W.crossVectors(H,rt).normalize();for(let Ce=0;Ce<g;Ce++){let Be=[Ct,ne][Zt]*Ce/g;d.copy(H).applyAxisAngle(W,Be).add(V),k[_t++].copy(d),Zt&&(v(d,V),kt.push([Ce==0?$:d.clone(),y.clone()]))}Zt&&(v(ie,V),kt.push([ie,y.clone()]))}wt.push(kt)}it.push(wt);let Dt=2*g,Lt=2;for(let It=0;It<u;It++){let kt=Dt*It,Nt=Dt*((It+1)%u),Gt=0,qt=[k[kt]];for(let Ct=1;Ct<g;Ct++){let ne=k[kt+Ct],Ut=k[Nt+Ct];qt.push(ne);for(let Yt=1,Zt=Ct-Lt+1;Yt<=Zt;Yt++)d.lerpVectors(ne,Ut,Yt/(Zt+1)),d.sub(V).setLength(xt[It]).add(V),qt.push(B[Gt++].copy(d));qt.push(Ut)}for(let Ct=0;Ct<g;Ct++)qt.push(k[Ct+g+kt]);qt.push(k[Nt+g]);for(let Ct=0,ne=qt.length;Ct<ne;Ct++){let Ut=qt[Ct],Yt=3*Ct,Zt=2*Ct;D[Yt]=Ut.x,D[Yt+1]=Ut.y,D[Yt+2]=Ut.z,v(Ut,V),N[Yt]=y.x,N[Yt+1]=y.y,N[Yt+2]=y.z,z[Zt]=Math.atan2(Ut.z,-Ut.x)/2/Math.PI+.5,z[Zt+1]=1-(Math.atan2(-Ut.y,Math.sqrt(Ut.x*Ut.x+Ut.z*Ut.z))/Math.PI+.5)}for(let Ct=0,ne=w.length;Ct<ne;Ct++){let Ut=3*w[Ct],Yt=2*w[Ct],Zt=h/3*2;a[h]=D[Ut],a[h+1]=D[Ut+1],a[h+2]=D[Ut+2],o[h]=N[Ut],o[h+1]=N[Ut+1],o[h+2]=N[Ut+2],l[Zt]=z[Yt],l[Zt+1]=z[Yt+1],h+=3}}}let dt=[];for(let K=0;K<x.length;K++)for(let lt=0;lt<u;lt++){let _t=x[K][lt];if(_t<S){let xt=x[_t].findIndex(Dt=>Dt%S==K),wt=it[K][lt],gt=it[_t][xt];for(let Dt=0;Dt<g;Dt++){let Lt=wt[Dt],It=gt[g-Dt],kt=wt[Dt+1],Nt=gt[g-(Dt+1)];P(Lt),P(It),P(kt),P(kt),P(It),P(Nt)}dt.push(wt[0][0],gt[g][0],wt[g][0],gt[0][0])}}for(;dt.length;){let K,lt,_t,[xt,wt]=dt.splice(0,2);K=wt;let gt=[xt];for(;xt!=K;)gt.push(K),lt=dt.indexOf(K),_t=lt%2,K=dt.splice(lt-_t,2)[1-_t];y.subVectors(gt[0],gt[1]).cross(d.subVectors(gt[0],gt[2])).normalize();let Dt=y.dot(gt[0])<0;Dt&&y.negate();for(let Lt=1;Lt<=gt.length-2;Lt++)A(gt[Lt+ +Dt]),A(gt[Lt+1-+Dt]),A(gt[0])}}(),function(){let u=new E,d=new E,c=new E,p=new E,m=new Y,f=new Y,g=new Y,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;_<h;_+=9,x+=6){u.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(u).add(d).add(c).divideScalar(3);let S=b(p);y(m,x+0,u,S),y(f,x+2,d,S),y(g,x+4,c,S)}let v=h/3*2;for(let _=0;_<v;_+=6){let x=l[_+0],S=l[_+2],w=l[_+4],T=Math.max(x,S,w),C=Math.min(x,S,w);T>.9&&C<.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 ve(new Float32Array(a.subarray(0,h)),3)),this.setAttribute("normal",new ve(new Float32Array(o.subarray(0,h)),3)),void this.setAttribute("uv",new ve(new Float32Array(l.subarray(0,h/3*2)),2))}static fromJSON(t){return new i5(t.vertices,t.indices,t.radius,t.corner,t.cornerSides)}}}),LK=U(()=>{M0t(),ot(),T0t=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 fN(.5*e,n,a):new sU(.5*e,s),l=i/e,h=r/e;return(l!==1||h!==1)&&o.scale(1,l,h),Object.assign(o,{userData:{...t,type:"DodecahedronGeometry"}})}},fN=class extends i5{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 fN(t.radius,t.corner,t.cornerSides)}}});function FK(t,e=new Y){let i=t.length();return e.set(-t.y/i,t.x/i)}function CCt(t){let e=new Y;e.addVectors(t.v0,kg.subVectors(t.v1,t.v0).multiplyScalar(2/3));let i=new Y;return i.addVectors(t.v2,tT.subVectors(t.v1,t.v2).multiplyScalar(2/3)),new Kl(t.v0,e,i,t.v2)}function m2(t,e,i=Number.EPSILON){return Math.abs(t-e)<i}function ECt(t,e,i=Number.EPSILON){return t.distanceTo(e)<i}function PCt(t,e,i=Number.EPSILON){return t.distanceTo(e)<i}function A0t(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 RCt(t,e,i){return jK(t,e)&&jK(e,i)&&wj(t.position,e.position,i.position)}function wj(t,e,i){return kg.copy(e).sub(t).cross(tT.copy(i).sub(t))===0}function DCt(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,h=Math.sqrt(Math.pow(i,2)-Math.pow(n/2,2))*(e.x-t.x)/n;return r.set(o+l,a+h),s.set(o-l,a-h),[r,s]}function OCt(t,e,i){return t.distanceTo(i)<e.distanceTo(i)?e:t}function ICt(t,e,i,r,s,n){let a,o=e.x-t.x,l=e.y-t.y,h=i.x-t.x,u=i.y-t.y,d=Math.sqrt((o+h)*(o+h)+(l+u)*(l+u));return A0t(e,t,i)>Math.PI&&(d*=-1),a=m2(u,l)?(l+u)*(r/d-.5)*8/3/(o-h):(o+h)*(r/d-.5)*8/3/(u-l),s.set(e.x-a*l,e.y+a*o),n.set(i.x+a*u,i.y-a*h),[s,n]}function UK(t,e){return t.position.equals(t.controls[1].position)&&e.position.equals(e.controls[0].position)}function jK(t,e){return wj(t.position,t.controls[1].position,e.position)&&wj(t.position,e.controls[0].position,e.position)}function GK(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*Bg(a.roundedCurveCorner,e);s>0&&(r[s-1]+=l),o+=l}a.curveAfter!==void 0&&(o+=Bg(a.curveAfter,e)),r.push(o)}return t.length>0&&i&&t[0].roundedCurveCorner!==void 0&&(r[t.length-1]+=.5*Bg(t[0].roundedCurveCorner,e)),r}function Bg(t,e=12){return t&&t instanceof i2?2*e:t&&(t instanceof pl||t instanceof nU)?1:t&&t instanceof ZP?e*t.points.length:e}var O1,eA,iA,Xg,pR,kg,tT,C0t,E0t,P0t,R0t,Sj,Tj,rA,WK,qK,HK,$K,XK,ps,D0t=U(()=>{ot(),O1=1e-12,eA=class{constructor(t){this.position=new Y,this.startPosition=new Y,this.uuid=zt.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 eA(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},iA=class extends eA{constructor(t){super(t.position),this.parent=t}copy(t){return super.copy(t),this}clone(){return new iA(this.parent).copy(this)}},Xg=class extends eA{constructor(t,e){super(e),this.controls=[],this.roundness=0,this.areControlsDirectionsMirrored=!0,this.uuid=t,this.controls.push(new iA(this),new iA(this))}static create(t,e){let i=new Xg(t,new Y(...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 Xg(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 Y,e=new Y){let[i,r]=this.computeTangents();return i&&r&&(FK(i,t),FK(r,e)),[t,e]}computeTangent(t=new Y){let[e,i]=this.computeTangents();return e&&i&&t.copy(e).add(i).normalize(),t}computeNormal(t=new Y){let[e,i]=this.computeNormals();return t.copy(e).add(i).normalize(),t}},pR=t=>t,kg=new Y,tT=new Y,C0t=new Y,E0t=new Y,P0t=new Y,R0t=new Y,Sj=new E,Tj=new E}),Am=U(()=>{ot(),D0t(),rA=new Y,WK=new Y,qK=new Y,HK=new Y,$K=new Y,XK=new Y,ps=class extends LS{constructor(t=100,e=100){super(),this.points=[],this.shapeHoles=[],this.plane=new Ca(new E(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=zt.generateUUID(),this.needsUpdate=!1,this.roundedCurves=[],this._width=t,this._height=e}static createFromState(t,e,i){let r=new ps;return r.isClosed=t.isClosed,r.points=t.points.map(s=>Xg.create(s.id,s.data)),typeof t.roundness=="number"&&(r.roundness=t.roundness),r.shapeHoles=t.shapeHoles.map(s=>ps.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=rA.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=zt.generateUUID()){let r;r=t instanceof Y?t:new Y(t,e);let s=new Xg(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,h=Tj.set(0,0,0),u=0,d=[];for(let c=0;c<n.length;c++){let p=pR(n[c]),m=kg,f=Bg(p,a);d.push(f);for(let g=0;g<=f;g++)if(p instanceof Kl||p instanceof lc||p instanceof pl){if(p.getPoint(g/f,m),h.set(m.x,m.y,0),l!==void 0&&PCt(l,h))continue;l===void 0&&(l=Sj),l.copy(h),s.setXYZ(u,h.x,h.y,h.z),u++}}o&&u>1&&(s.getX(u-1)!==s.getX(0)||s.getY(u-1)!==s.getY(0)||s.getZ(u-1)!==s.getZ(0))&&(s.setXYZ(u,s.getX(0),s.getY(0),s.getZ(0)),u++)}(t,i?this.roundedCurves:this.curves,e,this.autoClose),r.reduce((s,n)=>s+n,0)+1}computeCurveDivisions(t=12){return this.curveDivisions=GK(this.points,t,!1),this.roundedCurveDivisions=GK(this.points,t,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(t,e,i=12){return 2*function(r,s,n,a=12,o=!0){let l=Tj.set(0,0,0),h=0,u=[];for(let d=0;d<s.length;d++){if(n[d]===!1)continue;let c,p=pR(s[d]),m=kg,f=Bg(p,a);u.push(f);for(let g=0;g<=f;g++)if(p instanceof Kl||p instanceof lc||p instanceof pl){if(p.getPoint(g/f,m),l.set(m.x,m.y,0),c?.equals(l))continue;c===void 0?c=Sj:(r.setXYZ(h,c.x,c.y,c.z),h++,r.setXYZ(h,l.x,l.y,l.z),h++),c.copy(l)}}return o&&h>1&&!(r.getX(h-1)===r.getX(0)&&r.getY(h-1)===r.getY(0)&&r.getZ(h-1)===r.getZ(0))&&(r.setXYZ(h,r.getX(0),r.getY(0),r.getZ(0)),h++),u}(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 h=pR(r[l]),u=Bg(h,s),d=kg;for(let c=0;c<=u;c++)if(h instanceof Kl||h instanceof lc||h instanceof pl){if(h.getPoint(c/u,d),a!==void 0&&ECt(a,d,O1))continue;a===void 0&&(a=tT),a.copy(d),i.push(d.x,d.y),o++}}return m2(i[0],i[i.length-2],O1)&&m2(i[1],i[i.length-1],O1)&&(i.pop(),i.pop()),n&&o>1&&!(m2(i[o-1],i[1],O1)&&m2(i[o-2],i[0],O1))&&(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*Bg(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(UK(r,s)){let l=r.position.distanceTo(s.position);return r.position.distanceTo(rA.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){UK(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&&RCt(n,s,a);if(!s.controlsMoved()&&o>0&&!l){let h=s.curveBefore,u=s.curveAfter;if(h===void 0||u===void 0)continue;let d,c=s.roundedCurveBefore,p=s.roundedCurveAfter,m=h instanceof pl?h.v1.distanceTo(h.v2):h.getLength(),f=u instanceof pl?u.v1.distanceTo(u.v2):u.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=h.getPointAt(b,rA),S=u.getPointAt(_,WK);if(this._subSplitCurve(h,c,b,x,void 0),this._subSplitCurve(u,p,_,void 0,S),this.useCubicForRoundedCorners){let w=A0t(x,s.position,S)/2,T=Math.tan(w)*x.distanceTo(s.position),[C,M]=DCt(x,S,T,qK,HK),A=OCt(C,M,s.position),[P,O]=ICt(A,x,S,T,$K,XK);d=new Kl(x.clone(),P.clone(),O.clone(),S.clone())}else d=new lc(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 pl)){let n=t,a=e,o=n.getUtoTmapping(i,0),l=function(h,u,d,c,p=.5){let m=kg.subVectors(u,h).multiplyScalar(p).add(h),f=tT.subVectors(d,u).multiplyScalar(p).add(u),g=C0t.subVectors(c,d).multiplyScalar(p).add(d),y=m,v=E0t.subVectors(f,m).multiplyScalar(p).add(m),b=P0t.subVectors(g,f).multiplyScalar(p).add(f),_=g,x=R0t.subVectors(b,v).multiplyScalar(p).add(v);return[h.x,h.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 ps(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],h=t.points[r+5],u=t.points[r+6],d=new Xg(zt.generateUUID(),new Y(s,n));d.controls[0].position.set(a,o),d.controls[1].position.set(l,h),d.roundness=u,this.points.push(d)}return this.shapeHoles=t.shapeHoles?.length?t.shapeHoles.map(i=>{let r=new ps;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 lc&&(r[s]=CCt(r[s]));for(s=0,n=r.length;s<n;s++){let h,u=r[s],d=s>0?r[s-1]:null;u instanceof Kl?(h=this.createPoint(u.v0),h.controls[1].position.copy(u.v1)):u instanceof pl&&(h=this.createPoint(u.v1)),h!==void 0&&(d!==null&&i(h,d),a.push(h))}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 pl&&o.v2.equals(a[0].position)&&(l=!0),this.isClosed=l,a})(t.curves),t instanceof LS&&(this.shapeHoles=t.holes.map(r=>{let s=new ps;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 gN({x:t,y:e},i,r,s,n){return{x:t*i+s,y:e*r+n}}function NCt(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 YK(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 mR,BCt=U(()=>{mR=2*Math.PI});function qe(t,e){if(!t)throw e||"Assertion Failed!"}function pS(t){var e=t.windingRule,i=e===void 0?ns.ODD:e,r=t.elementType,s=r===void 0?Ma.POLYGONS:r,n=t.polySize,a=n===void 0?3:n,o=t.vertexSize,l=o===void 0?2:o,h=t.normal,u=h===void 0?[0,0,1]:h,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 O0t;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,u,m),{vertices:y.vertices,vertexIndices:y.vertexIndices,vertexCount:y.vertexCount,elements:y.elements,elementCount:y.elementCount,mesh:g?y.mesh:void 0}}}var ns,Ma,Le,X0,b_,lf,yN,vN,bN,KK,sA,_N,ZK,QK,O0t,wT=U(()=>{var t;(t=ns||(ns={}))[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"}(Ma||(Ma={})),Le=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){qe(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){qe(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){qe(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){qe(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,h;e.vertLeq(i,r)||(h=i,i=r,r=h),e.vertLeq(s,n)||(h=s,s=n,n=h),e.vertLeq(i,s)||(h=i,i=s,s=h,h=r,r=n,n=h),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)||(h=i,i=r,r=h),e.transLeq(s,n)||(h=s,s=n,n=h),e.transLeq(i,s)||(h=i,i=s,s=h,h=r,r=n,n=h),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}(),X0=function(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1},b_=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}(),lf=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},yN=function(){function e(){var i=new lf,r=new X0,s=new b_(0),n=new b_(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 b_(0),s=new b_(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;qe(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;qe(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 lf,r=new lf,s=new X0,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 lf;this.makeVertex_(a,r,i.Org),i.Org.anEdge=i}if(!s){var o=new X0;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 X0;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 lf;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 X0;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&&Le.vertCCW(s.Lprev.Org,s.Org,a.Lnext.Lnext.Org)&&Le.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,h=this.vHead,u=this.eHead;for(r=l,r=l;(i=r.next)!==l;r=i){qe(i.prev===r),a=i.anEdge;do qe(a.Sym!==a),qe(a.Sym.Sym===a),qe(a.Lnext.Onext.Sym===a),qe(a.Onext.Sym.Lnext===a),qe(a.Lface===i),a=a.Lnext;while(a!==i.anEdge)}for(qe(i.prev===r&&i.anEdge===null),n=h,n=h;(s=n.next)!==h;n=s){qe(s.prev===n),a=s.anEdge;do qe(a.Sym!==a),qe(a.Sym.Sym===a),qe(a.Lnext.Onext.Sym===a),qe(a.Onext.Sym.Lnext===a),qe(a.Org===s),a=a.Onext;while(a!==s.anEdge)}for(qe(s.prev===n&&s.anEdge===null),o=u,o=u;(a=o.next)!==u;o=a)qe(a.Sym.next===o.Sym),qe(a.Sym!==a),qe(a.Sym.Sym===a),qe(a.Org!==null),qe(a.Dst!==null),qe(a.Lnext.Onext.Sym===a),qe(a.Onext.Sym.Lnext===a);qe(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}(),vN=function(){this.handle=null},bN=function(){this.key=null,this.node=0},KK=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 vN,this.handles[s]=new bN;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,qe(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 vN;for(a=this.handles.length,this.handles.length=this.max+1,n=a;n<this.handles.length;n++)this.handles[n]=new bN}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;qe(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}(),sA=function(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1},_N=function(){this.key=null,this.next=null,this.prev=null},ZK=function(){function e(i,r){this.frame=i,this.leq=r,this.head=new _N,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 _N;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}(),QK=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?Le.vertLeq(a.Org,o.Org)?Le.edgeSign(o.Dst,a.Org,o.Org)<=0:Le.edgeSign(a.Dst,o.Org,a.Org)>=0:Le.edgeSign(o.Dst,n,o.Org)<=0:o.Dst===n?Le.edgeSign(a.Dst,n,a.Org)>=0:Le.edgeEval(a.Dst,n,a.Org)>=Le.edgeEval(o.Dst,n,o.Org)},e.deleteRegion=function(i,r){r.fixUpperEdge&&qe(r.eUp.winding===0),r.eUp.activeRegion=null,i.dict.delete(r.nodeUp)},e.fixUpperEdge=function(i,r,s){qe(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 sA;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 ns.ODD:return!!(1&r);case ns.NONZERO:return r!==0;case ns.POSITIVE:return r>0;case ns.NEGATIVE:return r<0;case ns.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,h,u,d,c=!0;u=s;do qe(Le.vertLeq(u.Org,u.Dst)),e.addRegionBelow(i,r,u.Sym),u=u.Onext;while(u!==n);for(a===null&&(a=e.regionBelow(r).eUp.Rprev),h=r,d=a;(u=(l=e.regionBelow(h)).eUp.Sym).Org===d.Org;)u.Onext!==d&&(i.mesh.splice(u.Oprev,u),i.mesh.splice(d.Oprev,u)),l.windingNumber=h.windingNumber-u.winding,l.inside=e.isWindingInside(i,l.windingNumber),h.dirty=!0,!c&&e.checkForRightSplice(i,h)&&(e.addWinding(u,d),e.deleteRegion(i,h),i.mesh.delete(d)),c=!1,h=l,d=u;h.dirty=!0,qe(h.windingNumber-u.winding===l.windingNumber),o&&e.walkDirtyRegions(i,h)},e.spliceMergeVertices=function(i,r,s){i.mesh.splice(r,s)},e.vertexWeights=function(i,r,s){var n=Le.vertL1dist(r,i),a=Le.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(Le.vertLeq(n.Org,a.Org)){if(Le.edgeSign(a.Dst,n.Org,a.Org)>0)return!1;Le.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(Le.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(qe(!Le.vertEq(a.Dst,o.Dst)),Le.vertLeq(a.Dst,o.Dst)){if(Le.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(Le.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,h=o.Org,u=l.Org,d=o.Dst,c=l.Dst,p=new lf;if(qe(!Le.vertEq(c,d)),qe(Le.edgeSign(d,i.event,h)<=0),qe(Le.edgeSign(c,i.event,u)>=0),qe(h!==i.event&&u!==i.event),qe(!r.fixUpperEdge&&!a.fixUpperEdge),h===u||Math.min(h.t,d.t)>Math.max(u.t,c.t))return!1;if(Le.vertLeq(h,u)){if(Le.edgeSign(c,h,u)>0)return!1}else if(Le.edgeSign(d,u,h)<0)return!1;return e.debugEvent(i),Le.intersect(d,h,c,u,p),qe(Math.min(h.t,d.t)<=p.t),qe(p.t<=Math.max(u.t,c.t)),qe(Math.min(c.s,d.s)<=p.s),qe(p.s<=Math.max(u.s,h.s)),Le.vertLeq(p,i.event)&&(p.s=i.event.s,p.t=i.event.t),s=Le.vertLeq(h,u)?h:u,Le.vertLeq(s,p)&&(p.s=s.s,p.t=s.t),Le.vertEq(p,h)||Le.vertEq(p,u)?(e.checkForRightSplice(i,r),!1):!Le.vertEq(d,i.event)&&Le.edgeSign(d,i.event,p)>=0||!Le.vertEq(c,i.event)&&Le.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):(Le.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),Le.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,h,d,u,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,h=o.eUp,u=!1;l.Dst!==h.Dst&&e.checkForIntersect(i,r),Le.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),u=!0),Le.vertEq(h.Org,i.event)&&(i.mesh.splice(s,h.Oprev),s=e.finishLeftRegions(i,o,null),u=!0),u?e.addRightEdges(i,r,s.Onext,a,a,!0):(n=Le.vertLeq(h.Org,l.Org)?h.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,h;return n=r.eUp,Le.vertEq(n.Org,s)?(qe(!1),void e.spliceMergeVertices(i,n,s.anEdge)):Le.vertEq(n.Dst,s)?(qe(!1),r=e.topRightRegion(r),a=l=(o=(h=e.regionBelow(r)).eUp.Sym).Onext,h.fixUpperEdge&&(qe(a!==o),e.deleteRegion(i,h),i.mesh.delete(o),o=a.Oprev),i.mesh.splice(s.anEdge,o),Le.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,h,u=new sA;if(u.eUp=r.anEdge.Sym,s=i.dict.search(u).key,n=e.regionBelow(s)){if(o=s.eUp,l=n.eUp,Le.edgeSign(o.Dst,r,o.Org)===0)return void e.connectLeftDegenerate(i,s,r);a=Le.vertLeq(l.Dst,o.Dst)?s:n,s.inside||a.fixUpperEdge?(h=a===s?i.mesh.connect(r.anEdge.Sym,o.Lnext):i.mesh.connect(l.Dnext,r.anEdge).Sym,a.fixUpperEdge?e.fixUpperEdge(i,a,h):e.computeWinding(i,e.addRegionBelow(i,s,h)),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);qe(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 sA,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 ZK(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||(qe(r.fixUpperEdge),qe(++s===1)),qe(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,Le.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 KK(a,Le.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,qe((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&&Le.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}(),O0t=function(){function e(){this.mesh=new yN,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=ns.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,h=[0,0,0],u=[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],u[y]=a,f[y]=r,h[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])<u[v]&&(u[v]=a,f[v]=r),a>h[v]&&(h[v]=a,m[v]=r);var b=0;if(h[1]-u[1]>h[0]-u[0]&&(b=1),h[2]-u[2]>h[b]-u[b]&&(b=2),u[b]>=h[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 h=!0,u=s.next;u!==s;u=u.next)h?(this.bmin[0]=this.bmax[0]=u.s,this.bmin[1]=this.bmax[1]=u.t,h=!1):(u.s<this.bmin[0]&&(this.bmin[0]=u.s),u.s>this.bmax[0]&&(this.bmax[0]=u.s),u.t<this.bmin[1]&&(this.bmin[1]=u.t),u.t>this.bmax[1]&&(this.bmax[1]=u.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(;Le.vertLeq(s.Dst,s.Org);s=s.Lprev);for(;Le.vertLeq(s.Org,s.Dst);s=s.Lnext);for(n=s.Lprev;s.Lnext!==n;)if(Le.vertLeq(s.Dst,n.Org)){for(;n.Lnext!==s&&(Le.edgeGoesLeft(n.Lnext)||Le.edgeSign(n.Org,n.Dst,n.Lnext.Dst)<=0);)n=i.connect(n.Lnext,n).Sym;n=n.Lprev}else{for(;n.Lnext!==s&&(Le.edgeGoesRight(s.Lprev)||Le.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,h=0;s>3&&i.mergeConvexFaces(s);for(var u=i.vHead.next;u!==i.vHead;u=u.next)u.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(u=a.Org).n===-1&&(u.n=h,h++),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===Ma.CONNECTED_POLYGONS&&(l*=2),this.elements=[],this.elements.length=l*s,this.vertexCount=h,this.vertices=[],this.vertices.length=h*n,this.vertexIndices=[],this.vertexIndices.length=h,u=i.vHead.next;u!==i.vHead;u=u.next)if(u.n!==-1){var c=u.n*n;this.vertices[c+0]=u.coords[0],this.vertices[c+1]=u.coords[1],n>2&&(this.vertices[c+2]=u.coords[2]),this.vertexIndices[u.n]=u.idx}var p=0;for(d=i.fHead.next;d!==i.fHead;d=d.next)if(d.inside){a=d.anEdge,o=0;do u=a.Org,this.elements[p++]=u.n,o++,a=a.Lnext;while(a!==d.anEdge);for(var m=o;m<s;++m)this.elements[p++]=-1;if(r===Ma.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 h=0,u=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[h++]=s.Org.coords[0],this.vertices[h++]=s.Org.coords[1],r>2&&(this.vertices[h++]=s.Org.coords[2]),this.vertexIndices[u++]=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 yN),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=ns.ODD),r===void 0&&(r=Ma.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_(),QK.computeInterior(this,o);var l=this.mesh;return r===Ma.BOUNDARY_CONTOURS?this.setWindingNumber_(l,1,!0):this.tessellateInterior_(l),o&&l.check(),r===Ma.BOUNDARY_CONTOURS?this.outputContours_(l,n):this.outputPolymesh_(l,r,s,n),!0},e}(),ns.ODD,ns.NONZERO,ns.POSITIVE,ns.NEGATIVE,ns.ABS_GEQ_TWO,Ma.POLYGONS,Ma.CONNECTED_POLYGONS,Ma.BOUNDARY_CONTOURS});function I0t(t,e){let i=t.length/2;if(i<2)return[];let r=0;for(let l=0;l<i;l++){let h=(l+1)%i;r+=t[2*l]*t[2*h+1]-t[2*h]*t[2*l+1]}let s=r>0!==e?1:-1,n=[];for(let l=0;l<i;l++){let h=(l+1)%i,u=t[2*h]-t[2*l],d=t[2*h+1]-t[2*l+1],c=Math.hypot(u,d);n.push(c>0?[s*d/c,-s*u/c]:[0,0])}let a=Math.cos(40*Math.PI/180),o=(l,h)=>{if(l[0]*h[0]+l[1]*h[1]<=a)return l;let[u,d]=[l[0]+h[0],l[1]+h[1]],c=Math.hypot(u,d);return c>0?[u/c,d/c]:l};return n.map((l,h)=>[o(l,n[(h+i-1)%i]),o(l,n[(h+1)%i])])}function N0t(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 B0t(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],h=t[n+2]-t[s+2],u=t[a]-t[s],d=t[a+1]-t[s+1],c=t[a+2]-t[s+2],p=h*u-o*c,m=o*d-l*u;if((l*c-h*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 xW,k0t,wW,V0t=U(()=>{}),SW=U(()=>{xW={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},k0t={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},wW={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}});function z0t(t,e){return t.normals[3*e+2]<.9999}function L0t(t){let e=Mj.get(t);if(e!==void 0)return e;if(!(t.rise>0))return t;let i=new Float32Array(t.normals),r=t.positions.length/3;for(let n=0;n<r;n++){if(!z0t(t,n))continue;let a=i[3*n],o=i[3*n+1],l=Math.hypot(a,o);if(l===0)continue;let h=t.rise-t.positions[3*n+2],u=Math.min(1,Math.max(0,1-h/t.rise)),d=Math.sqrt(1-u*u);i[3*n]=a/l*d,i[3*n+1]=o/l*d,i[3*n+2]=u}let s={...t,normals:i};return Mj.set(t,s),s}function F0t(t,e,i,r){let s=(e-t.minX)/t.spanX,n=(i-t.minY)/t.spanY;return r?[n,s]:[s,n]}var Mj,s5,Aj,TW=U(()=>{Mj=new WeakMap}),kCt=U(()=>{ot(),wT(),er(),V0t(),SW(),TW(),s5=class extends fe{constructor(t,e,i=12,r=ns.ODD,s,n=!1){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=n?void 0:s,this._legacy=n;let a,o=[t.extractShapePointsToFlatArray([],i),...t.shapeHoles.map(k=>k.extractShapePointsToFlatArray([],i))];try{a=pS({contours:o,windingRule:r,elementType:Ma.POLYGONS,polySize:3,vertexSize:2,strict:!0})}catch{a=wW}let l=a?.vertexCount??0,h=a?.elementCount??0,u=1/0,d=1/0,c=-1/0,p=-1/0;for(let k of o)for(let B=0;B<k.length;B+=2)k[B]<u&&(u=k[B]),k[B]>c&&(c=k[B]),k[B+1]<d&&(d=k[B+1]),k[B+1]>p&&(p=k[B+1]);let m=this._uvPitch,f=m??(c-u||1),g=m??(p-d||1),y=m===void 0?u:0,v=m===void 0?d:0,b=o.map((k,B)=>I0t(k,B>0)),_=0;for(let k of b)_+=k.length;let x=2*l+4*_,S=3*h*2+6*_,w=new Float32Array(3*x),T=new Float32Array(3*x),C=new Float32Array(2*x),M=new Uint32Array(S),A=new Uint8Array(x),P=0,O=0,D=0,N=!1,z=(k,B,V,q,W,H,rt=(k-y)/f,it=(B-v)/g)=>{let ft=3*O;w[ft]=k,w[ft+1]=B,w[ft+2]=V,T[ft]=q,T[ft+1]=W,T[ft+2]=H,A[O]=V===e?N?2:1:0,C[2*O]=rt,C[2*O+1]=it,O++};if(a!==void 0)for(let[k,B]of[[e,1],[0,-1]]){let V=O;for(let q=0;q<l;q++)z(a.vertices[2*q],a.vertices[2*q+1],k,0,0,B);for(let q=0;q<h;q++){let[W,H,rt]=[a.elements[3*q],a.elements[3*q+1],a.elements[3*q+2]];M[D++]=V+W,M[D++]=V+(B>0?H:rt),M[D++]=V+(B>0?rt:H)}}N=!0;for(let k=0;k<o.length;k++){let B=o[k],V=b[k],q=B.length/2,{u:W,vScale:H}=n?{u:new Float32Array(q+1),vScale:0}:N0t(B,f,g);P=H;let rt=H===0?0:e/H,it={minX:y,minY:v,spanX:f,spanY:g},ft=(dt,[K,lt],_t,xt)=>{let wt=B[2*dt],gt=B[2*dt+1],[Dt,Lt]=n?F0t(it,wt,gt,_t):[xt,_t?0:rt];z(wt,gt,_t?0:e,K,lt,0,Dt,Lt)};for(let dt=0;dt<V.length;dt++){let K=(dt+1)%q,[lt,_t]=V[dt],[xt,wt]=[W[dt],W[dt+1]],gt=O;ft(dt,lt,!1,xt),ft(dt,lt,!0,xt),ft(K,_t,!1,wt),ft(K,_t,!0,wt),M[D++]=gt,M[D++]=gt+1,M[D++]=gt+2,M[D++]=gt+3,M[D++]=gt+2,M[D++]=gt+1}}B0t(w,T,M),this.setAttribute("position",new ve(w,3)),this.setAttribute("normal",new ve(T,3)),this.setAttribute("uv",new ve(C,2)),this.setIndex(new ve(M,1)),this._nearSide=A,this._vScale=P}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 h=o[l];h!==0&&(r[3*l+2]+=e,h===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 s5(this._shape,this._depth,this._curveSegments,this._windingRule,this._uvPitch,this._legacy);return t.userData=sD(this.userData),t}}}),U0t=U(()=>{ot(),wT(),er(),SW(),Aj=class extends fe{constructor(t,e=12,i={}){super(),this.type="ShapeGeometry",this.windingRule=ns.ODD,this.elementType=Ma.POLYGONS,this.polySize=3,this.vertexSize=2,this.strict=!0,this._shape=t,this._curveSegments=e,this._triangulationOptions=Object.assign({windingRule:ns.ODD,elementType:Ma.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,h=!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&&(h=!1),s=f,n=g,!l&&!h)break}if(!l&&!h)try{r=pS({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=xW}let u=r?.vertexCount??1,d=r?.elementCount??1;if(this._positionAttribute=new ve(new Float32Array(3*u),3),this._normalAttribute=new ve(new Float32Array(3*u),3),this._uvAttribute=new ve(new Float32Array(2*u),2),this._indexAttribute=new ve(new Uint32Array(3*d),1),r){let c=1/0,p=-1/0,m=1/0,f=-1/0;for(let v=0,b=u;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=u;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 Aj(this._shape,this._curveSegments);return t.userData=sD(this.userData),t}}});function VCt(t){return JK||(JK=async function(){let e=t??"https://unpkg.com/@splinetool/runtime@2.0.204/build",i=Promise.resolve().then(()=>(vH(),yH)),[r,s]=await Promise.all([i,fetch(`${e}/bevel.wasm`).then(n=>n.arrayBuffer())]);await r.default({module_or_path:s}),ST=r}())}function zCt(t){let e=!1;return t.scene.objects.traverse((i,r)=>{let s=r.geometry;if(s!==void 0&&(q0t.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 j0t(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 n5(t,e,i,r,s,n){let a=t.positions.length/3,o=s.elements,l=H0t.getNormalMatrix(s).elements;for(let u=0;u<a;u++){let d=3*u,c=3*(i+u),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+u);if(n===void 0)e.uvs[b]=t.uvs[2*u],e.uvs[b+1]=t.uvs[2*u+1];else{let[_,x]=n(p,m,t.uvs[2*u],t.uvs[2*u+1],u);e.uvs[b]=_,e.uvs[b+1]=x}}let h=s.determinant()<0;for(let u=0;u<t.indices.length;u+=3)e.indices[r+u]=t.indices[u]+i,e.indices[r+u+1]=t.indices[u+(h?2:1)]+i,e.indices[r+u+2]=t.indices[u+(h?1:2)]+i}function G0t(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}`,h=`${n}/${a}`,u=a5.get(l);if(u!==void 0&&u.outlineVersion===o&&u.capKey===h&&(t.stillServes?.(u)??1))return Cj.placements++,u.cap;let d=function(c,p,m,f,g){let{points:y,ends:v}=j0t(c,p);return ST.assemble_cap(y,v,m,f,0,Math.max(1,Math.floor(g)),W0t,40)}(i,r,s,n,a);Cj.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 a5.set(l,{outlineVersion:o,capKey:h,assembledAt:s,cap:c}),c}finally{d.free()}}function ev(t,e){return .5*e>1.001*t}var ST,W0t,JK,q0t,H0t,tZ,eZ,iZ,a5,Cj,Ej,Cm,lb=U(()=>{ot(),er(),V0t(),TW(),W0t=.4,q0t=new Set(["VectorGeometry","TextGeometry","InputGeometry","PolygonGeometry","RectangleGeometry","StarGeometry","TriangleGeometry","EllipseGeometry"]),H0t=new Ms,tZ=new bt,eZ=new bt,iZ=new bt().makeScale(1,1,-1),a5=new Map,Cj={assemblies:0,placements:0},Ej=class extends fe{constructor(t,e,i=0,r=12,s=3,n,a,o=!1){if(super(),this.type="ShapeGeometry",this._nearSide=new Uint8Array(0),this._effectiveBevel=0,this._vScale=0,ST===void 0)throw new Error("bevel-wasm is not loaded");this._shape=t,this._uvPitch=a,this._legacy=o,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&&ev(this._effectiveBevel,t)&&ev(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 h=o[l];h!==0&&(r[3*l+2]+=e,h===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=G0t({owner:this._ownerId,shape:this._shape,curveSegments:this._curveSegments,assembledAt:this._depth,bevel:this._bevel,bevelSegments:this._bevelSegments,stillServes:a=>ev(a.cap.rise,this._depth)&&ev(a.cap.rise,a.assembledAt)}),e=function(a,o,l,h,u,d=!1){let c=h.positions.length/3,p=l-h.rise,m=h.rise,{points:f,ends:g}=j0t(a,o),y=1/0,v=1/0,b=-1/0,_=-1/0;for(let it=0;it<f.length;it+=2)f[it]<y&&(y=f[it]),f[it]>b&&(b=f[it]),f[it+1]<v&&(v=f[it+1]),f[it+1]>_&&(_=f[it+1]);d&&(u=void 0);let x=u??b-y,S=u??_-v,w={minX:y,minY:v,spanX:b-y||1,spanY:_-v||1},T=[],C=0;for(let it of g)T.push({at:C,count:it-C}),C=it;let M=0;for(let it of T)M+=it.count;let A=2*c+4*M,P=new Float32Array(3*A),O=new Float32Array(3*A),D=new Float32Array(2*A),N=new Uint32Array(2*h.indices.length+6*M),z=new Uint8Array(A),k=0,B=u===void 0?void 0:(it,ft)=>[it/u,ft/u],V=d?(it,ft,dt,K,lt)=>z0t(h,lt)?[K,dt]:[dt,K]:B,q=d?L0t(h):h,W={positions:P,normals:O,uvs:D,indices:N};n5(q,W,0,0,tZ.makeTranslation(0,0,p),B),n5(q,W,c,h.indices.length,eZ.makeTranslation(0,0,m).multiply(iZ),V),z.fill(1,0,c);let H=2*c,rt=2*h.indices.length;for(let it=0;it<T.length;it++){let{at:ft,count:dt}=T[it],K=f.subarray(2*ft,2*(ft+dt)),lt=I0t(K,it>0),_t=d?{u:new Float32Array(dt+1),vScale:0}:N0t(K,x,S),xt=_t.u;k=_t.vScale;for(let wt=0;wt<dt;wt++){let gt=(wt+1)%dt,[Dt,Lt]=lt[wt],It=H;for(let[kt,Nt,Gt,qt,Ct,ne]of[[K[2*wt],K[2*wt+1],Dt,p,xt[wt],2],[K[2*gt],K[2*gt+1],Lt,p,xt[wt+1],2],[K[2*gt],K[2*gt+1],Lt,m,xt[wt+1],0],[K[2*wt],K[2*wt+1],Dt,m,xt[wt],0]]){let Ut=3*H;if(P[Ut]=kt,P[Ut+1]=Nt,P[Ut+2]=qt,O[Ut]=Gt[0],O[Ut+1]=Gt[1],O[Ut+2]=0,d){let[Yt,Zt]=F0t(w,kt,Nt,ne===0);D[2*H]=Yt,D[2*H+1]=Zt}else D[2*H]=Ct,D[2*H+1]=k===0?0:(qt-m)/k;z[H]=ne,H++}N[rt++]=It,N[rt++]=It+1,N[rt++]=It+2,N[rt++]=It,N[rt++]=It+2,N[rt++]=It+3}}return B0t(P,O,N),{positions:P,normals:O,uvs:D,indices:N,nearSide:z,vScale:k}}(this._shape,this._curveSegments,this._depth,t,this._uvPitch,this._legacy);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 ve(e.positions,3)),this.setAttribute("normal",new ve(e.normals,3)),this.setAttribute("uv",new ve(e.uvs,2)),this.setIndex(new ve(e.indices,1))}clone(){let t=new Ej(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegments,this._ownerId,this._uvPitch,this._legacy);return t.userData=sD(this.userData),t}}}),wm=U(()=>{Am(),kCt(),U0t(),lb(),wT(),Cm=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:ns.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 ps?(i=o,(i.width!==s||i.height!==n)&&i.applySize(s,n)):i=new ps(s,n).fromJSON(o),t.parameters?.roundness!==void 0&&t.parameters?.roundness>0&&i.update());let h=i??new ps(s,n);return{parameters:Object.assign(r,{width:s,height:n,depth:a,roundness:l}),shape:h,ownerId:t.ownerId??e?.ownerId}}static build(t){let e,{depth:i,extrudeBevelSize:r,extrudeBevelSegments:s,subdivisions:n,roundness:a,windingRule:o,uvPitch:l,extrusionVersion:h}=t.parameters,u=h===1;return t.shape.roundness=a,i<=0?e=new Aj(t.shape,n,{windingRule:o}):r<=0?e=new s5(t.shape,i,n,o,l,u):ST!==void 0?e=new Ej(t.shape,i,r,n,s,t.ownerId,l,u):(console.error("[extrude] engine not loaded \u2014 extruding without a bevel"),e=new s5(t.shape,i,n,o,l,u)),Object.assign(e,{userData:{...t,type:"VectorGeometry"}})}}});function LCt(t,e,i,r,s,n){if(r>=MW)return s>30||s%4==0?(function(u,d,c,p=0,m=0,f=0){let g=.5522847498,y=d*g,v=c*g;u.addPoint(nA(m-d,f,m-d,f-v,m-d,f+v)),u.addPoint(nA(m,f+c,m-y,f+c,m+y,f+c)),u.addPoint(nA(m+d,f,m+d,f+v,m+d,f-v)),u.addPoint(nA(m,f-c,m+y,f-c,m-y,f-c)),p>0&&X0t(u,d,c,p)}(t,e,i,n),Math.round(s/4)):rZ(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},h=function({px:u,py:d,cx:c,cy:p,rx:m,ry:f,largeArcFlag:g,sweepFlag:y}){let v=[];if(m===0||f===0)return[];let b=(u-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,D,N,z,k,B,V,q,W,H){let rt=Math.pow(k,2),it=Math.pow(B,2),ft=Math.pow(V,2),dt=Math.pow(q,2),K=rt*it-rt*dt-it*ft;K<0&&(K=0),K/=rt*dt+it*ft,K=Math.sqrt(K)*(W===H?-1:1);let lt=K*k/B*q,_t=K*-B/k*V,xt=lt+(O+N)/2,wt=_t+(D+z)/2,gt=(V-lt)/k,Dt=(q-_t)/B,Lt=(-V-lt)/k,It=(-q-_t)/B,kt=YK(1,0,gt,Dt),Nt=YK(gt,Dt,Lt,It);return!H&&Nt>0&&(Nt-=mR),H&&Nt<0&&(Nt+=mR),{centerx:xt,centery:wt,ang1:kt,ang2:Nt}}(u,d,c,p,m,f,b,_,g,y),{ang1:w,ang2:T}=S,{centerx:C,centery:M}=S,A=Math.abs(T)/(mR/4);Math.abs(1-A)<1e-7&&(A=1);let P=Math.max(Math.ceil(A),1);T/=P;for(let O=0;O<P;O++)v.push(NCt(w,T)),w+=T;return v.map(O=>{let{x:D,y:N}=gN(O[0],m,f,C,M),{x:z,y:k}=gN(O[1],m,f,C,M),{x:B,y:V}=gN(O[2],m,f,C,M);return{x1:D,y1:N,x2:z,y2:k,x:B,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%h.length===0?function(u,d,c,p,m,f,g,y){let v=Math.round(m/p.length);u.addPoint(bv(d,c));for(let b=0,_=p.length;b<_;b++){let x=p[b],S=u.points[b],w=bv(x.x,x.y);S.controls[1].position.set(x.x1,x.y1),w.controls[0].position.set(x.x2,x.y2),u.addPoint(w)}return y>0?$0t(u,f,g,y):u.addPoint(bv(0,0)),v}(t,a.x,a.y,h,s,e,i,n):rZ(t,r,s,e,i,n)}function rZ(t,e,i,r,s,n){let a=-e/i;for(let o=0;o<=i;o++){let l=a*o,h=Math.sin(l)*r,u=Math.cos(l)*s;t.addPoint(bv(h,u))}return e<MW?n>0?$0t(t,r,s,n):t.addPoint(bv(0,0)):(t.removePoint(t.points[t.points.length-1]),n>0&&X0t(t,r,s,n)),1}function bv(t,e){return new Xg(zt.generateUUID(),new Y(t,e))}function nA(t,e,i,r,s,n){let a=bv(t,e);return a.controls[0].position.set(i,r),a.controls[1].position.set(s,n),a}function $0t(t,e,i,r){Y0t(t,e,i,r).forEach(s=>t.addPoint(s))}function X0t(t,e,i,r){let s=Y0t(t,e,i,r),n=new ps;s.forEach(a=>n.addPoint(a)),n.isClosed=!0,t.shapeHoles.push(n)}function Y0t(t,e,i,r){let s=r*e/100,n=s*(Math.abs(i)/Math.abs(e)),a=new Y(s/e,n/i),o=t.points.map(l=>{let h=l.clone();return h.uuid=zt.generateUUID(),h}).reverse();return o.forEach(l=>{l.position.multiply(a);let h=l.controls[0].position.clone().multiply(a),u=l.controls[1].position.clone().multiply(a);l.controls[0].position.copy(u),l.controls[1].position.copy(h)}),o}var MW,xD,K0t,xN,Z0t,o5=U(()=>{Am(),D0t(),BCt(),wm(),ot(),MW=2*Math.PI,xD=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=zt.clamp(i.angle,0,360),{shape:t.shape&&t.shape instanceof ps?t.shape:new ps,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:h,extrusionVersion:u}=t.parameters,d=t.shape,c=LCt(d,.5*i,.5*r,n*Math.PI/180,s,a);return d.isClosed=!0,d.update(),n===0?(e=new fe,e.setAttribute("position",new me([],3))):e=Cm.create({shape:d,parameters:{subdivisions:c,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h,extrusionVersion:u}}),Object.assign(e,{userData:{...t,type:"EllipseGeometry"}})}}}),sZ=U(()=>{ot(),M0t(),K0t=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 xN(.5*e,n,a):new lU(.5*e,s),l=i/e,h=r/e;return(l!==1||h!==1)&&o.scale(1,l,h),Object.assign(o,{userData:{...t,type:"IcosahedronGeometry"}})}},xN=class extends i5{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 xN(t.radius,t.corner,t.cornerSides)}}}),nZ=U(()=>{ot(),Z0t=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 LS;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 hU(s.extractPoints(r).shape,i);return n.rotateZ(Math.PI),Object.assign(n,{userData:{...t,type:"LatheGeometry"}})}}});function Y0(t,e){return Math.abs(e-t)/2+Math.min(t,e)}function FCt(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,h=new Uint32Array(l),u=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=(D,N)=>{let z=(Math.imul(D,2654435761)^N)&g;for(;;){let k=y[z];if(k===-1)return y[z]=m,h[m]=D,u[m]=N,m++;if(h[k]===D&&u[k]===N)return k;z=z+1&g}},b=(D,N)=>{let z=D<N?D:N,k=D<N?N:D,B=(Math.imul(z,2654435761)^k)&g;for(;;){let V=y[B];if(h[V]===z&&u[V]===k)return V;B=B+1&g}},_=new Uint32Array(n),x=new Float64Array(3*n),S=(D,N,z)=>{let k=D<N?v(D,N):v(N,D),B=++d[k];B===1?c[k]=z:B===2&&(p[k]=z),_[D]++,_[N]++,x[3*D]+=e[3*N],x[3*D+1]+=e[3*N+1],x[3*D+2]+=e[3*N+2],x[3*N]+=e[3*D],x[3*N+1]+=e[3*D+1],x[3*N+2]+=e[3*D+2]};for(let D=0;D<a;D++){let N=i[3*D],z=i[3*D+1],k=i[3*D+2];S(N,z,k),S(z,k,N),S(k,N,z)}let w=new Float64Array(3*m);for(let D=0;D<m;D++){let N=3*h[D],z=3*u[D];if(d[D]===2){let k=3*c[D],B=3*p[D];w[3*D]=.375*(e[N]+e[z])+.125*(e[k]+e[B]),w[3*D+1]=.375*(e[N+1]+e[z+1])+.125*(e[k+1]+e[B+1]),w[3*D+2]=.375*(e[N+2]+e[z+2])+.125*(e[k+2]+e[B+2])}else w[3*D]=.5*(e[N]+e[z]),w[3*D+1]=.5*(e[N+1]+e[z+1]),w[3*D+2]=.5*(e[N+2]+e[z+2])}let T,C=new Float64Array(3*n);for(let D=0;D<n;D++){let N=_[D];N===3?T=3/16:N>3&&(T=3/(8*N));let z=1-N*Number(T),k=Number(T);N===2&&(z=3/4,k=1/8),C[3*D]=e[3*D]*z+x[3*D]*k,C[3*D+1]=e[3*D+1]*z+x[3*D+1]*k,C[3*D+2]=e[3*D+2]*z+x[3*D+2]*k}let M=new Float64Array(3*(n+m));M.set(C),M.set(w,3*n);let A=new Uint32Array(12*a),P=new Array(4*a),O=o?new Float64Array(24*a):null;for(let D=0;D<a;D++){let N=i[3*D],z=i[3*D+1],k=i[3*D+2],B=b(N,z)+n,V=b(z,k)+n,q=b(k,N)+n,W=12*D;A[W++]=B,A[W++]=V,A[W++]=q,A[W++]=N,A[W++]=B,A[W++]=q,A[W++]=z,A[W++]=V,A[W++]=B,A[W++]=k,A[W++]=q,A[W++]=V;let H=r[D];if(P[4*D]=H,P[4*D+1]=H,P[4*D+2]=H,P[4*D+3]=H,O!==null){let rt=6*D,it=s[rt],ft=s[rt+1],dt=s[rt+2],K=s[rt+3],lt=s[rt+4],_t=s[rt+5],xt=Y0(it,dt),wt=Y0(ft,K),gt=Y0(dt,lt),Dt=Y0(K,_t),Lt=Y0(it,lt),It=Y0(ft,_t),kt=24*D;O[kt++]=xt,O[kt++]=wt,O[kt++]=gt,O[kt++]=Dt,O[kt++]=Lt,O[kt++]=It,O[kt++]=it,O[kt++]=ft,O[kt++]=xt,O[kt++]=wt,O[kt++]=Lt,O[kt++]=It,O[kt++]=dt,O[kt++]=K,O[kt++]=gt,O[kt++]=Dt,O[kt++]=xt,O[kt++]=wt,O[kt++]=lt,O[kt++]=_t,O[kt++]=Lt,O[kt++]=It,O[kt++]=gt,O[kt++]=Dt}}return{positions:M,faces:A,materialIndices:P,uvs:O}}var aA,Q0t,rn,J0t,AW,UCt=U(()=>{ot(),aA=1e4,Q0t=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,h=new Uint32Array(o),u=[],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*aA),w=Math.round(_*aA),T=Math.round(x*aA),C=l.get(S);C===void 0&&(C=new Map,l.set(S,C));let M=C.get(w);M===void 0&&(M=new Map,C.set(w,M));let A=M.get(T);A===void 0&&(A=d++,M.set(T,A),u.push(b,_,x)),h[v]=A}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=h[_],T=h[x],C=h[S];w===T||T===C||C===w||(c.push(w,T,C),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(u),faces:Uint32Array.from(c),materialIndices:p,uvs:m===null?null:Float64Array.from(m)}}(t),i=this.subdivisions;for(;i-- >0;)e=FCt(e);return function(r,s){let{positions:n,faces:a,materialIndices:o,uvs:l}=r,h=n.length/3,u=a.length/3,d=new Float64Array(3*h);for(let y=0;y<u;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],C=n[v+1]-n[b+1],M=n[v+2]-n[b+2],A=S*M-w*C,P=w*T-x*M,O=x*C-S*T;d[v]+=A,d[v+1]+=P,d[v+2]+=O,d[b]+=A,d[b+1]+=P,d[b+2]+=O,d[_]+=A,d[_+1]+=P,d[_+2]+=O}for(let y=0;y<h;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*u,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 fe;g.setAttribute("position",new ve(p,3)),c>0&&(g.setAttribute("normal",new ve(m,3)),g.setAttribute("color",new ve(new Float32Array(3*c).fill(1),3))),f!==null&&g.setAttribute("uv",new ve(f,2));for(let y=0;y<u;){let v=o[y],b=y;do y++;while(y<u&&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)}}}),aZ=U(()=>{ot(),UCt(),rn=new E,J0t=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i,r=t.geometry??e?.geometry??new fe().copy(new Yh(100,100,100));e===void 0?(r.computeBoundingBox(),r.boundingBox.getSize(rn),i={width:rn.x,height:rn.y,depth:rn.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 fe().copy(new Yh(100,100,100)),a=n.userData.parameters;a===void 0?(n.boundingBox=function(l){let h=new dr,u=l.attributes.position;return u?(h.setFromBufferAttribute(u),h):(h.makeEmpty(),h)}(n),n.boundingBox.getSize(rn)):rn.set(a.width,a.height,a.depth),(e!==rn.x||i!==rn.y||r!==rn.z)&&n.scale(rn.x===0?1:e/rn.x,rn.y===0?1:i/rn.y,rn.z===0?1:r/rn.z);let o=n.originalGeometry;try{s>0?(o===void 0||a?.subdivisions!==s)&&(o===void 0&&(o=n),n=new Q0t(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 OG(i).load(t,r=>{let s=this.normalizeInputs({geometry:r});r.boundingBox.getSize(rn);let n=100/rn.x;Object.assign(s.parameters,{width:100,height:rn.y*n,depth:rn.z*n}),e(this.build(s))})}}}),Pj=U(()=>{Am(),wm(),AW=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 ps?t.shape:new ps,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,extrusionVersion:l}=t.parameters,h=t.shape,u=.5*e,d=.5*i,c=2*Math.PI/r;for(let m=0;m<r;m++){let f=c*m,g=0+Math.sin(f)*u,y=0+Math.cos(f)*d;h.addPoint(h.createPoint(g,y))}h.isClosed=!0;for(let m=0,f=h.points.length;m<f;m++)h.points[m].roundness=s;h.roundness=s,h.update();let p=Cm.create({shape:h,parameters:{roundness:s,depth:n,extrudeBevelSize:a,extrudeBevelSegments:o,extrusionVersion:l}});return Object.assign(p,{userData:{...t,type:"PolygonGeometry"}})}}});function __(t,e,i){i.x=t.x*e.x,i.y=t.y,i.z=t.x*e.y}function wN(t,e,i,r,s,n){let a=eyt.copy(e).sub(t),o=iyt.copy(i).sub(t),l=a.angleTo(o);if(a.normalize(),o.normalize(),r===s){let h=a.add(o).normalize();n.copy(t).addScaledVector(h,r/Math.sin(l/2))}else{let h=a.angleTo(o);n.copy(t),n.addScaledVector(a,s/Math.sin(h)),n.addScaledVector(o,r/Math.sin(h))}}function jCt(t,e,i){let r=t.clone().sub(e),s=i.clone().sub(e);return r.projectOnVector(s),r.add(e)}var tyt,eyt,iyt,oZ,wD,ryt,syt,nyt,lZ,CW,ayt,oyt,lyt,hyt,hZ=U(()=>{ot(),tyt=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,h=new oZ(.5*e,i,s,n,a,o,l),u=r/e;return u!==1&&h.scale(1,1,u),Object.assign(h,{userData:{...t,type:"PyramidGeometry"}})}},eyt=new E,iyt=new E,oZ=class extends fe{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=[],h=[],u=[],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 E(0,-p,0),_=new E(0,p,0),x=new Y(t,-p),S=new Y(f,-p),w=new Y(0,_.y).sub(S),T=new Y(0,_.y).sub(x),C=new Y(w.y,-w.x).normalize(),M=new Y(T.y,-T.x).normalize(),A=t*Math.cos(Math.PI/i)*Math.tan((Math.PI-w.angle())/2)-1e-8;n=Math.min(n,A);{let B=new E(C.x,C.y,0),V=new E(Math.cos(g)*B.x,B.y,Math.sin(g)*B.x);o=B.angleTo(V)}let P=n/Math.tan((Math.PI-w.angle())/2),O=n/Math.tan((Math.PI-o)/2),D=new E;if(!s){h.push(b.x,b.y,b.z),u.push(0,-1,0),d.push(0,0);let B=c++,V=[],q=x.clone(),W=P/Math.cos(Math.PI/i);q.x-=W;for(let H=0;H<i;H++){let rt=H/i*Math.PI*2+m;__(q,new Y(Math.sin(rt),Math.cos(rt)),D),h.push(D.x,D.y,D.z),u.push(0,-1,0),d.push(0,0),V.push(c++)}for(let H=0;H<V.length;H++)l.push(V[H],B,V[(H+1)%V.length])}let N=[];{let B=new E,V=new E,q=new E,W=new E,H=new E,rt=new E;for(let it=0;it<i;it++){let ft=it/i*Math.PI*2+m,dt=(it+.5)/i*Math.PI*2+m,K=(it+1)/i*Math.PI*2+m,lt=new Y(Math.sin(ft),Math.cos(ft)),_t=new Y(Math.sin(dt),Math.cos(dt)),xt=new Y(Math.sin(K),Math.cos(K));__(x,lt,V),__(x,xt,q),__(C,_t,B),wN(_,V,q,O,O,W),h.push(W.x,W.y,W.z),wN(V,_,q,O,P,H),h.push(H.x,H.y,H.z),wN(q,V,_,P,O,rt),h.push(rt.x,rt.y,rt.z),u.push(B.x,B.y,B.z),u.push(B.x,B.y,B.z),u.push(B.x,B.y,B.z),d.push(0,0),d.push(0,0),d.push(0,0);let wt=c++,gt=c++,Dt=c++;if(l.push(wt,gt,Dt),n>0){{let kt=V.clone().add(q).multiplyScalar(.5),Nt=_.clone().sub(kt).normalize(),Gt=b.clone().sub(kt).normalize().add(Nt).normalize().multiplyScalar(-1);z(kt,rt.clone().sub(H),Gt,w.angle())}let Lt,It;{let kt=new E;__(M,xt,kt);let Nt=rt.clone().add(W).multiplyScalar(.5);Nt=jCt(Nt,q,_);let Gt=rt.clone().sub(W);[Lt,It]=z(Nt,Gt,kt,o,W.y)}{let kt=Lt,Nt=kt.clone().setY(0).normalize(),Gt=new E(0,-1,0),qt=Nt.clone().cross(Gt);k(kt,Nt,Gt,qt)}N.concat(It);{let kt=w.angle(),Nt=Math.PI-kt,Gt=_.clone();Gt.y-=n/Math.sin(kt-Math.PI/2);let qt=new E,Ct=[];for(let Ut=0;Ut<a;Ut++){let Yt=[],Zt=Math.PI/2-Nt*Ut/a,$=Math.cos(Zt),ie=Math.sin(Zt),Ce=dt;for(let Be=0;Be<=Ut;Be++){let te=Math.cos(Ce),ni=Math.sin(Ce);B.x=$*ni,B.y=ie,B.z=$*te,qt.copy(Gt).addScaledVector(B,n),h.push(qt.x,qt.y,qt.z),u.push(B.x,B.y,B.z),d.push(0,0),Yt.push(c++),Ce+=2*Math.PI/Ut/i}Ct.push(Yt)}It.reverse(),Ct.push(It);let ne=Ct.length-1;for(let Ut=0;Ut<ne;Ut++){let Yt=Ct[Ut],Zt=Ct[Ut+1],$=Yt.length-1;l.push(Zt[1],Yt[0],Zt[0]);for(let ie=1;ie<=$;ie++)l.push(Yt[ie],Yt[ie-1],Zt[ie]),l.push(Zt[ie+1],Yt[ie],Zt[ie])}}}}}function z(B,V,q,W,H){let rt=-W/2,it=(Math.PI-W)/2,ft=V.clone().normalize().cross(q);B.addScaledVector(q,-n/Math.sin(it));let dt=new E,K=new E,lt=c,_t=[];for(let xt=0;xt<=a;xt++){let wt=rt+xt/a*W;K.set(0,0,0),K.addScaledVector(ft,Math.sin(wt)),K.addScaledVector(q,Math.cos(wt));for(let gt=0;gt<=1;gt++){let Dt=gt/1-.5;if(dt.copy(B),dt.addScaledVector(V,Dt),dt.addScaledVector(K,n),H!=null){let Lt=Math.max(0,dt.y-H);dt.addScaledVector(V,-Lt/V.y)}h.push(dt.x,dt.y,dt.z),u.push(K.x,K.y,K.z),d.push(0,0),gt===0&&_t.push(c),c++}}for(let xt=0;xt<a;xt++)for(let wt=0;wt<1;wt++){let gt=lt+wt+2*xt,Dt=gt+2,Lt=Dt+1,It=gt+1;l.push(gt,Dt,It),l.push(Dt,Lt,It)}return[B.clone().addScaledVector(V,.5),_t]}function k(B,V,q,W){let H=Math.PI/2,rt=T.angle()-H,it=[],ft=new E,dt=new E;for(let lt=0;lt<=a;lt++){let _t=[],xt=lt/a;for(let wt=0;wt<=lt;wt++){let gt=((lt?wt/lt:0)-.5)*v,Dt=Math.cos(gt),Lt=Math.sin(gt),It=(H+Math.atan(Math.tan(rt)*Dt))*xt,kt=Math.cos(It),Nt=Math.sin(It);ft.set(0,0,0),ft.addScaledVector(V,Nt*Dt),ft.addScaledVector(q,kt),ft.addScaledVector(W,Nt*Lt),dt.copy(B).addScaledVector(ft,n),h.push(dt.x,dt.y,dt.z),u.push(ft.x,ft.y,ft.z),d.push(0,0),_t.push(c++)}it.push(_t)}let K=it.length-1;for(let lt=0;lt<K;lt++){let _t=it[lt],xt=it[lt+1],wt=_t.length-1;l.push(_t[0],xt[1],xt[0]);for(let gt=1;gt<=wt;gt++)l.push(_t[gt-1],_t[gt],xt[gt]),l.push(_t[gt],xt[gt+1],xt[gt])}}this.setIndex(l),this.setAttribute("position",new me(h,3)),this.setAttribute("normal",new me(u,3)),this.setAttribute("uv",new me(d,2))}}}),l5=U(()=>{Am(),wm(),wD=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 ps?t.shape:new ps,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,extrusionVersion:h}=t.parameters,u={x:.5*i,y:.5*r},d={x:-u.x,y:-u.y},c={x:u.x,y:u.y};function p(x,S,w){return S>i&&w>r?Math.min(x*i/S,x*r/w):S>i?x*i/S:w>r?x*r/w:x}let m=[];m[0]=s[0]===0?0:p(s[0],s[0]+s[3],s[0]+s[1]),m[1]=s[1]===0?0:p(s[1],s[1]+s[2],s[1]+s[0]),m[2]=s[2]===0?0:p(s[2],s[2]+s[1],s[2]+s[3]),m[3]=s[3]===0?0:p(s[3],s[3]+s[0],s[3]+s[2]);let f=d.x,g=c.x,y=c.y,v=d.y;e.addPoint(e.createPoint(f,y)),e.addPoint(e.createPoint(g,y)),e.addPoint(e.createPoint(g,v)),e.addPoint(e.createPoint(f,v)),e.isClosed=!0;let b=!0;for(let x=0,S=e.points.length;x<S;x++)e.points[x].roundness=m[x],x>0&&m[x]!==m[x-1]&&(b=!1);b&&(e.roundness=m[0]),e.useCubicForRoundedCorners=n!==1,e.update();let _=Cm.create({shape:e,parameters:{depth:a,extrudeBevelSize:o,extrudeBevelSegments:l,extrusionVersion:h}});return Object.assign(_,{userData:{...t,type:"RectangleGeometry"}})}}}),uZ=U(()=>{ot(),ryt=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=zt.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:h,thetaLength:u}=t.parameters;return u===0?(e=new fe,e.setAttribute("position",new me([],3))):e=new Ac(.5*i,n,a,o,l,h,u*zt.DEG2RAD),e.scale(1,r/i,s/i),Object.assign(e,{userData:{...t,type:"SphereGeometry"}})}}}),dZ=U(()=>{ot(),syt=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 Rc(e,i,r,s);return n.scale(1,1,1),Object.assign(n,{userData:{...t,type:"PlaneGeometry"}})}}}),cZ=U(()=>{ot(),nyt=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 lZ(e,i,r,s,n,a);return Object.assign(o,{userData:{...t,type:"BackdropGeometry"}})}},lZ=class extends fe{constructor(t=1,e=1,i=1,r=90,s=10,n=24){super(),this.type="BackdropGeometry";let a=[],o=[],l=[],h=.001;s==0&&(n=1),n=Math.max(1,Math.floor(n)),s=Math.min(s,100),r=Math.min(180-h,r),r*=Math.PI/180;let u=[],d=Math.PI/2,c=(dt=0,K=0,lt=0)=>new E(dt,K,lt),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=(dt,K=!1)=>Math.sin(dt-Math.PI/(+K+1)),T=(dt,K=!1)=>Math.cos(dt-Math.PI/(+K+1));S.y=Math.sin(r)*e-f;let C=Math.cos(r)*e-y,M=_.z-h;r<=d?(S.z=Math.min(C,M),S.z==M&&(S.y-=(C-M)/Math.tan(d-r))):x.z=Math.min(x.z-C-y,_.z-h),p.subVectors(_,x),m.subVectors(S,x);let A=Math.min(p.length(),m.length())*s/100,P=A*Math.tan(r/2),O=A/Math.cos(r/2),D=p.clone().normalize().add(m.normalize()).setLength(O).add(x);p.set(0,w(r,!0),T(r,!0)),u.push([S,p.clone()]);let N=(Math.PI-r)/n;for(let dt=0;dt<=n;dt++){let K=d+r+dt*N;p.set(0,Math.sin(K)*P,Math.cos(K)*P),p.add(D),m.set(0,w(K),T(K)),u.push([p.clone(),m.clone()])}u.push([_,c(0,1,0)]);let z=Math.sin(N/2)*P*2,k=u.length-1,B=u[0][0].distanceTo(u[1][0]),V=B+z*n+u[k-1][0].distanceTo(u[k][0]);u[0].push(1);for(let dt=0;dt<=n;dt++)u[dt+1].push(1-(B+dt*z)/V);u[k].push(0);let q,W,H,[rt,it,ft]=u[0];for(let dt=1;dt<u.length;dt++)[q,W,H]=u[dt],a.push(v,rt.y,rt.z,v,q.y,q.z,b,rt.y,rt.z,b,rt.y,rt.z,v,q.y,q.z,b,q.y,q.z),o.push(0,it.y,it.z,0,W.y,W.z,0,it.y,it.z,0,it.y,it.z,0,W.y,W.z,0,W.y,W.z),l.push(0,ft,0,H,1,ft,1,ft,0,H,1,H),[rt,it,ft]=[q,W,H];this.setAttribute("position",new me(a,3)),this.setAttribute("normal",new me(o,3)),this.setAttribute("uv",new me(l,2))}}}),Rj=U(()=>{Am(),wm(),CW=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 ps?t.shape:new ps,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:h,extrusionVersion:u}=t.parameters,d=t.shape,c=.5*e,p=.5*i,m=a*Math.PI/360/s,f=Math.PI/2*3*-1,g=c*r/100,y=p*r/100;if(s===3&&r===50){m=2*Math.PI/s;for(let b=0;b<s;b++){let _=m*b,x=0+Math.sin(_)*c,S=0+Math.cos(_)*p;d.addPoint(d.createPoint(x,S))}}else for(let b=0;b<s;b++){let _=0+Math.cos(f)*c,x=0+Math.sin(f)*p;d.addPoint(d.createPoint(_,x)),f+=m,_=0+Math.cos(f)*g,x=0+Math.sin(f)*y,d.addPoint(d.createPoint(_,x)),f+=m}d.isClosed=!0;for(let b=0,_=d.points.length;b<_;b++)d.points[b].roundness=n;d.roundness=n,d.update();let v=Cm.create({shape:d,parameters:{roundness:n,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h,extrusionVersion:u}});return Object.assign(v,{userData:{...t,type:"StarGeometry"}})}}}),pZ=U(()=>{ot(),ayt=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 Rc(e,i);return Object.assign(r,{userData:{...t,type:"TextFrameGeometry"}})}}}),mZ=U(()=>{ot(),ZS(),oyt=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,h=function(u,d,c,p,m,f,g,y,v,b,_){[d,c]=[c,d],g=d/2;let x=zt.clamp(m/360,0,1);if(x===0){let S=new fe;return S.setAttribute("position",new me([],3)),S}return x===1&&(b=0),new fj(!0,u,d,c,p,x,f,g,0,v,b,_)}(e,i,r,.5*e,a,n,0,0,s,o,l);return h.scale(1,i/e,1),Object.assign(h,{userData:{...t,type:"TorusGeometry"}})}}}),fZ=U(()=>{ot(),lyt=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 uU(o,i,r,s,n,a);return Object.assign(l,{userData:{...t,type:"TorusKnotGeometry"}})}}}),gZ=U(()=>{Am(),wm(),hyt=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 ps?t.shape:new ps,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,extrusionVersion:l}=t.parameters,h=t.shape,u=.5*e,d=.5*i;o?(h.addPoint(h.createPoint(-u,d)),h.addPoint(h.createPoint(u,-d)),h.addPoint(h.createPoint(-u,-d))):(h.addPoint(h.createPoint(0,d)),h.addPoint(h.createPoint(u,-d)),h.addPoint(h.createPoint(-u,-d))),h.isClosed=!0;for(let p=0,m=h.points.length;p<m;p++)h.points[p].roundness=r;h.roundness=r,h.update();let c=Cm.create({shape:h,parameters:{roundness:r,depth:s,extrudeBevelSize:n,extrudeBevelSegments:a,extrusionVersion:l}});return Object.assign(c,{userData:{...t,type:"TriangleGeometry"}})}}}),GCt=U(()=>{ot()}),WCt=U(()=>{ot(),new Zn,new bt,new mc,new E,new E,new E,new E});function yZ(){let t=new fe;return t.setAttribute("position",new ve(new Float32Array([]),3)),t.setIndex(new ve(new Uint16Array([]),1)),t}var vZ,Dj,uyt=U(()=>{dn(),De(),wT(),ot(),bT(),Am(),wm(),lb(),vZ=yZ().attributes,Dj=class extends fe{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,vZ),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:h,fontSize:u,extrusionVersion:d}=t,c=Pa.getDisplayedValue(l),p=function(S,w,T,C){let M=typeof S.width=="string"?Number(C.getVariable(S.width)):S.width,A=[""],P="";for(let O of T)P+=O,O===" "||O===`
|
|
385
|
+
`;return 2&x.valid||e(3,"missing format specifier"),4&x.valid||e(3,"missing image size specifier"),x}(n),u=h.width,d=h.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,C=0;for(;C<_&&b<p.byteLength;){T=p[b++];let A=T>128;if(A&&(T-=128),(T===0||C+T>_)&&e(3,"bad scanline data"),A){let P=p[b++];for(let O=0;O<T;O++)S[C++]=P}else S.set(p.subarray(b,b+T),C),C+=T,b+=T}let M=g;for(let A=0;A<M;A++){let P=0;y[v]=S[A+P],P+=g,y[v+1]=S[A+P],P+=g,y[v+2]=S[A+P],P+=g,y[v+3]=S[A+P],v+=4}w--}return y}(n.subarray(n.pos),u,d);switch(this.type){case Ye: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=Ye;break;case si: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=si;break;default:throw new Error("THREE.HDRLoader: Unsupported type: "+this.type)}return{width:u,height:d,data:a,header:h.string,gamma:h.gamma,exposure:h.exposure,type:o,colorSpace:Hu,minFilter:pe,magFilter:pe,generateMipmaps:!1,flipY:!0}}setDataType(t){return this.type=t,this}}});function PK(t){return t.length>2&&t[0]===35&&t[1]===63}function mN(t){return typeof t=="object"&&t!==null&&t.isSplineHdr===!0}function f0t(t){let e=new yr(t.data,t.width,t.height,hn,si);return e.flipY=!1,e.image.isSplineHdr=!0,e.needsUpdate=!0,e}var RK,gW,Sg,g0t=U(()=>{ot(),wCt()}),y0t=U(()=>{ot(),p0t(),m0t(),g0t(),RK=0,gW=class extends h0t{constructor(t,e){super(t,e.imageHolderCache),this.data=t,this.shared=e,this.instanceId=++RK,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?PK(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&&PK(r)?function(n){try{let a=new d0t().parse(n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength));if(!a||!a.width||!a.height)return null;let{width:o,height:l}=a,h=a.data,u=new Uint16Array(h.length),d=4*o,c=f=>Xh.toHalfFloat(Math.pow(Math.max(Xh.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)u[y+v]=m(h[g+v]),u[y+v+1]=m(h[g+v+1]),u[y+v+2]=m(h[g+v+2]),u[y+v+3]=h[g+v+3]}return{isSplineHdr:!0,data:u,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:(cS||(cS=new l0t),cS.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 RG(this.img,void 0,t,t):this.isHdr?(s=f0t(this.img),s.wrapS=t,s.wrapT=t,s.magFilter=i,s.minFilter=e):s=new di(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()}}}),v0t=U(()=>{y0t(),Sg=class extends gW{}});function SCt(t){if(typeof t=="string")return t;let e=bj.get(t);return e||(e={url:URL.createObjectURL(new Blob([t]))},bj.set(t,e)),e.url}var bj,TCt=U(()=>{bj=new Map});function MCt(){if(!_j)return DK||(DK=async function(){await Promise.resolve().then(()=>(cH(),g2t)),b0t(window!==void 0?window:global),_j=!0}())}var b0t,_0t,_j,DK,x0t=U(()=>{_0t=new Promise(t=>{b0t=t}),_j=!1});function OK(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 ACt(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;OK(a.events,i),e=e||i.some(o=>o.data.type==="Audio")}),s.events===void 0||Array.isArray(s.events)===!1)return!0;OK(s.events,i),e=e||i.some(n=>n.data.type==="Audio")}),e}var IK,tv,yW=U(()=>{TCt(),x0t(),_0t.then(t=>IK=t),tv=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:SCt(t),format:"wav"},this.sound=new IK.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 NK(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 vW,bW=U(()=>{vW=null});function BK(t){return new Y(t.y,-t.x)}var _W,xj,w0t,S0t,tA,kK,i5,T0t,fN,r5=U(()=>{ot(),_W=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=zt.clamp(s.thetaLength,0,360),s.hollow=zt.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:h,radiusTop:u,radiusBottom:d,cornerRadius:c,cornerSegments:p,hollow:m}=t.parameters;h===0?(e=new fe,e.setAttribute("position",new me([],3))):e=c||m?new xj(u,d,s,n,a,o,l,h*Math.PI/180,c,c,p,m):new eS(u,d,s,n,a,o,l,h*Math.PI/180);let f=r/i;return f!==1&&e.scale(1,1,f),Object.assign(e,{userData:{...t,type:"CylinderGeometry"}})}},xj=class extends fe{constructor(t,e,i,r,s,n,a,o,l,h,u,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,h=0);let p=i/2;c&&t==0&&(t=l),c&&e==0&&(e=h);let m=new Y(t,p),f=new Y(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 C=Math.PI-_.angle(),M=_.angle(),A=Math.tan(M/2),P=Math.tan(C/2),O=A+P,D=d?O:P,N=d?O:A;if(l=Math.min(l,(t-S)/D,_.length()/O),h=Math.min(h,(e-w)/N,_.length()/O),l>0){let Nt=l/A;g=m.clone().sub(new Y(Nt,l)),d&&(v=g.clone(),v.x-=x-O*l),m.sub(_.clone().setLength(Nt))}if(h>0){let Nt=h/P;y=f.clone().sub(new Y(Nt,-h)),f.add(_.clone().setLength(Nt)),d&&(b=y.clone(),b.x-=x-O*h,T.sub(_.clone().setLength(Nt)))}_=m.clone().sub(f);let z=_.length()<.5,k=[],B=[],V=[],q=[],W=[],H=[],rt=(Nt,Gt,qt,Ct,ne)=>{for(let Ut=0;Ut<u+1;Ut++){let Yt=Ut/u,Zt=Ct<0?Yt:1-Yt;ne&&(Zt-=1),Zt*=Nt;let $=Math.sin(Zt),ie=Math.cos(Zt)*Ct,Ce=ie*Gt+qt.y;k.push($*Gt+qt.x),B.push(Ce),V.push($),q.push(ie),W.push(.5+Ce/i),H.push(!1)}},it=(Nt,Gt,qt)=>{let Ct=[Nt,Gt];qt<0&&Ct.reverse();for(let ne of Ct)k.push(ne),B.push(p*qt),V.push(0),q.push(qt),W.push(.5),H.push(!0)};if(b&&y?(rt(C,h,b,-1,!0),rt(M,h,y,-1,!1)):y?(it(y.x,0,-1),rt(M,h,y,-1,!1)):n||it(e,w,-1),!z){let Nt=BK(_).normalize();for(let Gt=0;Gt<=s;Gt++){let qt=Gt/s,Ct=_.y*qt+f.y;k.push(_.x*qt+f.x),B.push(Ct),V.push(Nt.x),q.push(Nt.y),W.push(.5+Ct/i),H.push(!1)}}if(v&&g?(rt(C,l,g,1,!1),rt(M,l,v,1,!0)):g?(rt(C,l,g,1,!1),it(g.x,0,1)):n||it(t,S,1),d&&!z){let Nt=BK(_).multiplyScalar(-1).normalize();for(let Gt=0;Gt<=s;Gt++){let qt=Gt/s,Ct=_.y*-qt+T.y;k.push(_.x*-qt+T.x),B.push(Ct),V.push(Nt.x),q.push(Nt.y),W.push(.5+Ct/i),H.push(!1)}}let ft=k.length,dt=ft+(d&&!n?1:0),K=(Nt,Gt)=>Nt*ft+(Gt===ft?0:Gt),lt=o<2*Math.PI,_t=(r+1)*ft+(lt?2*(1+dt):0),xt=new Float32Array(3*_t),wt=new Float32Array(3*_t),gt=new Float32Array(2*_t),Dt=_t-1>65535?new Uint32Array(r*Math.max(0,dt-1)*6+(lt?2*(dt+1)*3:0)):new Uint16Array(r*Math.max(0,dt-1)*6+(lt?2*(dt+1)*3:0)),Lt=0,It=0;for(let Nt=0;Nt<=r;Nt++){let Gt=Nt/r,qt=Gt*o+a,Ct=Math.sin(qt),ne=Math.cos(qt);for(let Ut=0;Ut<ft;Ut++){let Yt=3*It,Zt=2*It,$=k[Ut],ie=V[Ut];xt[Yt]=$*Ct,xt[Yt+1]=B[Ut],xt[Yt+2]=$*ne,wt[Yt]=ie*Ct,wt[Yt+1]=q[Ut],wt[Yt+2]=ie*ne,H[Ut]?(gt[Zt]=.5,gt[Zt+1]=.5):(gt[Zt]=Gt,gt[Zt+1]=W[Ut]),It++}}for(let Nt=0;Nt<r;Nt++)for(let Gt=0;Gt<dt-1;Gt++){if(n&&d&&Gt==s)continue;let qt=K(Nt,Gt),Ct=K(Nt+1,Gt),ne=K(Nt+1,Gt+1),Ut=K(Nt,Gt+1),Yt=xt[3*ne+0],Zt=xt[3*ne+2];Dt[Lt++]=qt,Dt[Lt++]=Ct,Dt[Lt++]=Ut,(Yt!=0||Zt!=0)&&(Dt[Lt++]=Ct,Dt[Lt++]=ne,Dt[Lt++]=Ut)}function kt(Nt,Gt,qt){let Ct=Math.sin(qt),ne=Math.cos(qt),Ut=-ne,Yt=Ct,Zt=Nt<0?(te,ni,bi)=>{Dt[Lt++]=te,Dt[Lt++]=ni,Dt[Lt++]=bi}:(te,ni,bi)=>{Dt[Lt++]=te,Dt[Lt++]=bi,Dt[Lt++]=ni},$=(t+e+S+w)/4,ie=3*It,Ce=2*It;xt[ie]=$*Ct,xt[ie+1]=0,xt[ie+2]=$*ne,wt[ie]=Ut,wt[ie+1]=0,wt[ie+2]=Yt,gt[Ce]=.5,gt[Ce+1]=.5;let Be=It++;for(let te=0;te<dt;te++){let ni=3*(Gt+(te===ft?0:te));ie=3*It,Ce=2*It,xt[ie]=xt[ni],xt[ie+1]=xt[ni+1],xt[ie+2]=xt[ni+2],wt[ie]=Ut,wt[ie+1]=0,wt[ie+2]=Yt;let bi=ni/3*2|0;gt[Ce]=gt[bi],gt[Ce+1]=gt[bi+1],It++}for(let te=Be+1;te<It-1;te++)Zt(Be,te,te+1);Zt(Be,It-1,Be+1)}lt&&(kt(-1,0,a),kt(1,r*ft,a+o)),this.setIndex(new ve(Dt.slice(0,Lt),1)),this.setAttribute("position",new ve(xt,3)),this.setAttribute("normal",new ve(wt,3)),this.setAttribute("uv",new ve(gt,2))}}}),VK=U(()=>{ot(),r5(),w0t=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=zt.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:h,cornerRadiusTop:u,cornerRadiusBottom:d,cornerSegments:c}=t.parameters;h===0?(e=new fe,e.setAttribute("position",new me([],3))):e=u>0||d>0||h<360?new xj(0,i/2,s,n,a,o,l,h*Math.PI/180,u,d,c,0,!0):new w4(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"}})}}}),zK=U(()=>{ot(),S0t=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:h}=t.parameters;return e=l===0?new Yh(i,r,s,n,a,o):new kK(i,r,s,n,a,o,l,h),Object.assign(e,{userData:{...t,type:"CubeGeometry"}})}},tA=Math.PI/2,kK=class extends fe{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,h=o+1,u=2*((n+1)*(s+1)+(r+1)*(n+1)+(r+1)*(s+1))+(l?4*h*(n+1+(r+1)+(s+1))+h*(h+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*u),m=new Float32Array(3*u),f=new Float32Array(2*u),g=u-1>65535?new Uint32Array(6*d+3*c):new Uint16Array(6*d+3*c),y=0,v=0,b=new Float64Array(h),_=new Float64Array(h),x=new Float64Array(h),S=new Float64Array(h);for(let O=0;O<h;O++){let D=O/o*tA;b[O]=Math.sin(D)*a,_[O]=(1-Math.cos(D))*a,x[O]=Math.sin(D),S[O]=Math.cos(D)}let w=h*(h+1)/2,T=new Float64Array(3*w),C=new Float64Array(3*w);{let O=new E(t/2,e/2,i/2);O.subScalar(a);let D=0;for(let N=0;N<=o;N++){let z=tA*(1-N/o),k=Math.cos(z),B=Math.sin(z),V=0;for(let q=0;q<=N;q++){let W=k*Math.cos(V),H=B,rt=k*Math.sin(V);T[3*D]=W,T[3*D+1]=H,T[3*D+2]=rt,C[3*D]=O.x+W*a,C[3*D+1]=O.y+H*a,C[3*D+2]=O.z+rt*a,D++,V+=tA/N}}}function M(O,D,N,z,k,B,V,q,W,H){let rt=(B-2*a)/W,it=(V-2*a)/H,ft=B/2-a,dt=V/2-a,K=q/2,lt=W+1,_t=H+1,xt=0,wt=new E;for(let gt=0;gt<_t;gt++){let Dt=gt*it-dt;for(let Lt=0;Lt<lt;Lt++){let It=Lt*rt-ft,kt=3*(y+xt),Nt=2*(y+xt);wt[O]=It*z,wt[D]=Dt*k,wt[N]=K,p[kt]=wt.x,p[kt+1]=wt.y,p[kt+2]=wt.z,wt[O]=0,wt[D]=0,wt[N]=q>0?1:-1,m[kt]=wt.x,m[kt+1]=wt.y,m[kt+2]=wt.z,f[Nt]=Lt/W,f[Nt+1]=1-gt/H,xt+=1}}for(let gt=0;gt<H;gt++)for(let Dt=0;Dt<W;Dt++){let Lt=y+Dt+lt*gt,It=y+Dt+lt*(gt+1),kt=y+(Dt+1)+lt*(gt+1),Nt=y+(Dt+1)+lt*gt;g[v++]=Lt,g[v++]=It,g[v++]=Nt,g[v++]=It,g[v++]=kt,g[v++]=Nt}y+=xt}function A(O,D,N,z,k,B,V,q,W,H){let rt=(V-2*a)/H,it=V/2-a,ft=q/2-a,dt=W/2,K=H+1,lt=0,_t=new E,xt=new E;for(let wt=0;wt<o+1;wt++){_t[D]=(ft+b[wt])*k,_t[N]=(dt-_[wt])*B,xt[O]=0,xt[D]=x[wt]*Math.sign(_t[D]),xt[N]=S[wt]*Math.sign(_t[N]);for(let gt=0;gt<K;gt++){let Dt=gt*rt-it;_t[O]=Dt*z;let Lt=3*(y+lt),It=2*(y+lt);p[Lt]=_t.x,p[Lt+1]=_t.y,p[Lt+2]=_t.z,m[Lt]=xt.x,m[Lt+1]=xt.y,m[Lt+2]=xt.z,f[It]=gt/H,f[It+1]=0,lt+=1}}for(let wt=0;wt<o;wt++)for(let gt=0;gt<H;gt++){let Dt=y+gt+K*wt,Lt=y+gt+K*(wt+1),It=y+(gt+1)+K*(wt+1),kt=y+(gt+1)+K*wt;g[v++]=Dt,g[v++]=Lt,g[v++]=kt,g[v++]=Lt,g[v++]=It,g[v++]=kt}y+=lt}function P(O,D,N){let z=O*D*N>0?(B,V,q)=>{g[v++]=B,g[v++]=V,g[v++]=q}:(B,V,q)=>{g[v++]=B,g[v++]=q,g[v++]=V},k=y;for(let B=0;B<w;B++){let V=3*B,q=3*y,W=2*y;p[q]=O*C[V],p[q+1]=D*C[V+1],p[q+2]=N*C[V+2],m[q]=O*T[V],m[q+1]=D*T[V+1],m[q+2]=N*T[V+2],f[W]=0,f[W+1]=0,y++}for(let B=0;B<o;B++){let V=k+B*(B+1)/2,q=k+(B+1)*(B+2)/2;z(V,q+1,q);for(let W=1;W<=B;W++)z(V+W-1,V+W,q+W),z(V+W,q+W+1,q+W)}}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&&(A("z","y","x",-1,-1,1,i,e,t,n),A("z","y","x",1,-1,-1,i,e,t,n),A("z","y","x",-1,1,-1,i,e,t,n),A("z","y","x",1,1,1,i,e,t,n),A("x","y","z",-1,-1,-1,t,e,i,r),A("x","y","z",1,-1,1,t,e,i,r),A("x","y","z",-1,1,1,t,e,i,r),A("x","y","z",1,1,-1,t,e,i,r),A("y","x","z",-1,-1,1,e,t,i,s),A("y","x","z",1,-1,-1,e,t,i,s),A("y","x","z",1,1,1,e,t,i,s),A("y","x","z",-1,1,-1,e,t,i,s),P(1,1,1),P(-1,1,1),P(1,-1,1),P(-1,-1,1),P(1,1,-1),P(-1,1,-1),P(1,-1,-1),P(-1,-1,-1)),this.setIndex(new ve(g,1)),this.setAttribute("position",new ve(p,3)),this.setAttribute("normal",new ve(m,3)),this.setAttribute("uv",new ve(f,2))}}}),M0t=U(()=>{ot(),i5=class extends fe{constructor(t=[],e=[],i="",r=1,s=.2,n=4){super(),this.type="PolyhedronGeometryRound";let a,o,l,h=0;return function(){(s=Math.min(.99999,s))==0&&(n=0);let u={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[i],d=new E,c=d.clone(),p=new ks,m=s*r,f=r-m,g=n+1,y=new E,v=(K,lt)=>y.subVectors(K,lt).normalize(),b=(K,lt)=>Array(K).fill(void 0).map(lt),_=b(t.length/3,(K,lt)=>new E().fromArray(t,3*lt).setLength(r)),x=[],S=1e6;for(let K=0;K<_.length;K++){let lt,_t,xt,wt=_[K],gt=[],Dt=1e10,Lt=-1;for(;(Lt=e.indexOf(K,Lt+1))!=-1;){let Gt=Lt-Lt%3;lt=e[Gt+(Lt+1)%3],_t=e[Gt+(Lt+2)%3],xt=wt.distanceToSquared(_[lt]),Dt=Math.min(Dt,xt),gt.push([lt,_t,xt])}Dt+=1e-6;let It=[],kt=0,Nt=gt.length;for(let Gt=0;Gt<Nt;Gt++){[lt,_t,xt]=gt[kt];let qt=x[lt]?.includes(K)==1;xt<=Dt&&It.push(lt+ +qt*S),kt=gt.findIndex(Ct=>Ct[0]==_t)}x.push(It)}let w=[];{let K,lt,_t=0,xt=0,wt=u==3;for(let gt=0;gt<=n;gt++){K=gt*(gt+1)/2,lt=(gt+1)*(gt+2)/2;for(let Dt=0;Dt<n-gt;Dt++)[_t,xt]=[K+Dt+gt+2,lt+Dt+gt+3],w.push(K,lt,...wt?[xt,K]:[_t,lt],xt,_t),[K,lt]=[_t,xt];w.push(K,lt,K+n+2)}}let T=0;for(let K=0;K<x.length;K++)for(let lt=0;lt<u;lt++)x[K][lt]<S&&T++;let C=_.length*u*w.length*3+T*g*6*3+2*T*3*3;a=new Float64Array(C),o=new Float64Array(C),l=new Float64Array(C/3*2);let M=(K,lt,_t)=>{let xt=h/3*2;l[xt]=Math.atan2(_t,-K)/2/Math.PI+.5,l[xt+1]=1-(Math.atan2(-lt,Math.sqrt(K*K+_t*_t))/Math.PI+.5)},A=K=>{a[h]=K.x,a[h+1]=K.y,a[h+2]=K.z,o[h]=y.x,o[h+1]=y.y,o[h+2]=y.z,M(K.x,K.y,K.z),h+=3},P=K=>{a[h]=K[0].x,a[h+1]=K[0].y,a[h+2]=K[0].z,o[h]=K[1].x,o[h+1]=K[1].y,o[h+2]=K[1].z,M(K[0].x,K[0].y,K[0].z),h+=3},O=(n+2)*(n+3)/2,D=new Float64Array(3*O),N=new Float64Array(3*O),z=new Float64Array(2*O),k=b(2*u*g,()=>new E),B=b(n*Math.max(0,n-1)/2,()=>new E),V=d.clone(),q=d.clone(),W=d.clone(),H=d.clone(),rt=d.clone(),it=[],ft=b(_.length,()=>b(u,()=>d.clone()));for(let K=0;K<_.length;K++){d.copy(_[K]).normalize(),V.copy(d).multiplyScalar(f);let lt=x[K];for(let It=0;It<lt.length;It++){let kt=lt[It],Nt=lt[(It+1)%u];p.setFromPointsAndIndices(_,K,kt%S,Nt%S),p.b.sub(p.a).setLength(1e10).add(p.a),p.c.sub(p.a).setLength(1e10).add(p.a),p.closestPointToPoint(V,ft[K][It])}let _t=0,xt=[],wt=[],gt=new E;n==0&&[...ft[K]].reduce((It,kt)=>It.add(kt),gt).multiplyScalar(1/u);for(let It=0;It<u;It++){let kt=[],Nt=(It-1+u)%u,Gt=ft[K][Nt],qt=ft[K][It];d.copy(Gt).sub(V),c.copy(qt).sub(V);let Ct=V.angleTo(d),ne=d.angleTo(c),Ut=Math.cos(Ct)*m;n==0?q.copy(gt):q.copy(V).setLength(f+Ut),xt.push(Ut);let Yt=[q,Gt,qt];for(let Zt=0;Zt<2;Zt++){let $=Yt[Zt],ie=Yt[Zt+1];H.subVectors($,V),rt.subVectors(ie,V),W.crossVectors(H,rt).normalize();for(let Ce=0;Ce<g;Ce++){let Be=[Ct,ne][Zt]*Ce/g;d.copy(H).applyAxisAngle(W,Be).add(V),k[_t++].copy(d),Zt&&(v(d,V),kt.push([Ce==0?$:d.clone(),y.clone()]))}Zt&&(v(ie,V),kt.push([ie,y.clone()]))}wt.push(kt)}it.push(wt);let Dt=2*g,Lt=2;for(let It=0;It<u;It++){let kt=Dt*It,Nt=Dt*((It+1)%u),Gt=0,qt=[k[kt]];for(let Ct=1;Ct<g;Ct++){let ne=k[kt+Ct],Ut=k[Nt+Ct];qt.push(ne);for(let Yt=1,Zt=Ct-Lt+1;Yt<=Zt;Yt++)d.lerpVectors(ne,Ut,Yt/(Zt+1)),d.sub(V).setLength(xt[It]).add(V),qt.push(B[Gt++].copy(d));qt.push(Ut)}for(let Ct=0;Ct<g;Ct++)qt.push(k[Ct+g+kt]);qt.push(k[Nt+g]);for(let Ct=0,ne=qt.length;Ct<ne;Ct++){let Ut=qt[Ct],Yt=3*Ct,Zt=2*Ct;D[Yt]=Ut.x,D[Yt+1]=Ut.y,D[Yt+2]=Ut.z,v(Ut,V),N[Yt]=y.x,N[Yt+1]=y.y,N[Yt+2]=y.z,z[Zt]=Math.atan2(Ut.z,-Ut.x)/2/Math.PI+.5,z[Zt+1]=1-(Math.atan2(-Ut.y,Math.sqrt(Ut.x*Ut.x+Ut.z*Ut.z))/Math.PI+.5)}for(let Ct=0,ne=w.length;Ct<ne;Ct++){let Ut=3*w[Ct],Yt=2*w[Ct],Zt=h/3*2;a[h]=D[Ut],a[h+1]=D[Ut+1],a[h+2]=D[Ut+2],o[h]=N[Ut],o[h+1]=N[Ut+1],o[h+2]=N[Ut+2],l[Zt]=z[Yt],l[Zt+1]=z[Yt+1],h+=3}}}let dt=[];for(let K=0;K<x.length;K++)for(let lt=0;lt<u;lt++){let _t=x[K][lt];if(_t<S){let xt=x[_t].findIndex(Dt=>Dt%S==K),wt=it[K][lt],gt=it[_t][xt];for(let Dt=0;Dt<g;Dt++){let Lt=wt[Dt],It=gt[g-Dt],kt=wt[Dt+1],Nt=gt[g-(Dt+1)];P(Lt),P(It),P(kt),P(kt),P(It),P(Nt)}dt.push(wt[0][0],gt[g][0],wt[g][0],gt[0][0])}}for(;dt.length;){let K,lt,_t,[xt,wt]=dt.splice(0,2);K=wt;let gt=[xt];for(;xt!=K;)gt.push(K),lt=dt.indexOf(K),_t=lt%2,K=dt.splice(lt-_t,2)[1-_t];y.subVectors(gt[0],gt[1]).cross(d.subVectors(gt[0],gt[2])).normalize();let Dt=y.dot(gt[0])<0;Dt&&y.negate();for(let Lt=1;Lt<=gt.length-2;Lt++)A(gt[Lt+ +Dt]),A(gt[Lt+1-+Dt]),A(gt[0])}}(),function(){let u=new E,d=new E,c=new E,p=new E,m=new Y,f=new Y,g=new Y,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;_<h;_+=9,x+=6){u.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(u).add(d).add(c).divideScalar(3);let S=b(p);y(m,x+0,u,S),y(f,x+2,d,S),y(g,x+4,c,S)}let v=h/3*2;for(let _=0;_<v;_+=6){let x=l[_+0],S=l[_+2],w=l[_+4],T=Math.max(x,S,w),C=Math.min(x,S,w);T>.9&&C<.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 ve(new Float32Array(a.subarray(0,h)),3)),this.setAttribute("normal",new ve(new Float32Array(o.subarray(0,h)),3)),void this.setAttribute("uv",new ve(new Float32Array(l.subarray(0,h/3*2)),2))}static fromJSON(t){return new i5(t.vertices,t.indices,t.radius,t.corner,t.cornerSides)}}}),LK=U(()=>{M0t(),ot(),T0t=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 fN(.5*e,n,a):new sU(.5*e,s),l=i/e,h=r/e;return(l!==1||h!==1)&&o.scale(1,l,h),Object.assign(o,{userData:{...t,type:"DodecahedronGeometry"}})}},fN=class extends i5{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 fN(t.radius,t.corner,t.cornerSides)}}});function FK(t,e=new Y){let i=t.length();return e.set(-t.y/i,t.x/i)}function CCt(t){let e=new Y;e.addVectors(t.v0,kg.subVectors(t.v1,t.v0).multiplyScalar(2/3));let i=new Y;return i.addVectors(t.v2,tT.subVectors(t.v1,t.v2).multiplyScalar(2/3)),new Kl(t.v0,e,i,t.v2)}function m2(t,e,i=Number.EPSILON){return Math.abs(t-e)<i}function ECt(t,e,i=Number.EPSILON){return t.distanceTo(e)<i}function PCt(t,e,i=Number.EPSILON){return t.distanceTo(e)<i}function A0t(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 RCt(t,e,i){return jK(t,e)&&jK(e,i)&&wj(t.position,e.position,i.position)}function wj(t,e,i){return kg.copy(e).sub(t).cross(tT.copy(i).sub(t))===0}function DCt(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,h=Math.sqrt(Math.pow(i,2)-Math.pow(n/2,2))*(e.x-t.x)/n;return r.set(o+l,a+h),s.set(o-l,a-h),[r,s]}function OCt(t,e,i){return t.distanceTo(i)<e.distanceTo(i)?e:t}function ICt(t,e,i,r,s,n){let a,o=e.x-t.x,l=e.y-t.y,h=i.x-t.x,u=i.y-t.y,d=Math.sqrt((o+h)*(o+h)+(l+u)*(l+u));return A0t(e,t,i)>Math.PI&&(d*=-1),a=m2(u,l)?(l+u)*(r/d-.5)*8/3/(o-h):(o+h)*(r/d-.5)*8/3/(u-l),s.set(e.x-a*l,e.y+a*o),n.set(i.x+a*u,i.y-a*h),[s,n]}function UK(t,e){return t.position.equals(t.controls[1].position)&&e.position.equals(e.controls[0].position)}function jK(t,e){return wj(t.position,t.controls[1].position,e.position)&&wj(t.position,e.controls[0].position,e.position)}function GK(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*Bg(a.roundedCurveCorner,e);s>0&&(r[s-1]+=l),o+=l}a.curveAfter!==void 0&&(o+=Bg(a.curveAfter,e)),r.push(o)}return t.length>0&&i&&t[0].roundedCurveCorner!==void 0&&(r[t.length-1]+=.5*Bg(t[0].roundedCurveCorner,e)),r}function Bg(t,e=12){return t&&t instanceof i2?2*e:t&&(t instanceof pl||t instanceof nU)?1:t&&t instanceof ZP?e*t.points.length:e}var O1,eA,iA,Xg,pR,kg,tT,C0t,E0t,P0t,R0t,Sj,Tj,rA,WK,qK,HK,$K,XK,ps,D0t=U(()=>{ot(),O1=1e-12,eA=class{constructor(t){this.position=new Y,this.startPosition=new Y,this.uuid=zt.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 eA(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},iA=class extends eA{constructor(t){super(t.position),this.parent=t}copy(t){return super.copy(t),this}clone(){return new iA(this.parent).copy(this)}},Xg=class extends eA{constructor(t,e){super(e),this.controls=[],this.roundness=0,this.areControlsDirectionsMirrored=!0,this.uuid=t,this.controls.push(new iA(this),new iA(this))}static create(t,e){let i=new Xg(t,new Y(...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 Xg(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 Y,e=new Y){let[i,r]=this.computeTangents();return i&&r&&(FK(i,t),FK(r,e)),[t,e]}computeTangent(t=new Y){let[e,i]=this.computeTangents();return e&&i&&t.copy(e).add(i).normalize(),t}computeNormal(t=new Y){let[e,i]=this.computeNormals();return t.copy(e).add(i).normalize(),t}},pR=t=>t,kg=new Y,tT=new Y,C0t=new Y,E0t=new Y,P0t=new Y,R0t=new Y,Sj=new E,Tj=new E}),Am=U(()=>{ot(),D0t(),rA=new Y,WK=new Y,qK=new Y,HK=new Y,$K=new Y,XK=new Y,ps=class extends LS{constructor(t=100,e=100){super(),this.points=[],this.shapeHoles=[],this.plane=new Ca(new E(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=zt.generateUUID(),this.needsUpdate=!1,this.roundedCurves=[],this._width=t,this._height=e}static createFromState(t,e,i){let r=new ps;return r.isClosed=t.isClosed,r.points=t.points.map(s=>Xg.create(s.id,s.data)),typeof t.roundness=="number"&&(r.roundness=t.roundness),r.shapeHoles=t.shapeHoles.map(s=>ps.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=rA.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=zt.generateUUID()){let r;r=t instanceof Y?t:new Y(t,e);let s=new Xg(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,h=Tj.set(0,0,0),u=0,d=[];for(let c=0;c<n.length;c++){let p=pR(n[c]),m=kg,f=Bg(p,a);d.push(f);for(let g=0;g<=f;g++)if(p instanceof Kl||p instanceof lc||p instanceof pl){if(p.getPoint(g/f,m),h.set(m.x,m.y,0),l!==void 0&&PCt(l,h))continue;l===void 0&&(l=Sj),l.copy(h),s.setXYZ(u,h.x,h.y,h.z),u++}}o&&u>1&&(s.getX(u-1)!==s.getX(0)||s.getY(u-1)!==s.getY(0)||s.getZ(u-1)!==s.getZ(0))&&(s.setXYZ(u,s.getX(0),s.getY(0),s.getZ(0)),u++)}(t,i?this.roundedCurves:this.curves,e,this.autoClose),r.reduce((s,n)=>s+n,0)+1}computeCurveDivisions(t=12){return this.curveDivisions=GK(this.points,t,!1),this.roundedCurveDivisions=GK(this.points,t,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(t,e,i=12){return 2*function(r,s,n,a=12,o=!0){let l=Tj.set(0,0,0),h=0,u=[];for(let d=0;d<s.length;d++){if(n[d]===!1)continue;let c,p=pR(s[d]),m=kg,f=Bg(p,a);u.push(f);for(let g=0;g<=f;g++)if(p instanceof Kl||p instanceof lc||p instanceof pl){if(p.getPoint(g/f,m),l.set(m.x,m.y,0),c?.equals(l))continue;c===void 0?c=Sj:(r.setXYZ(h,c.x,c.y,c.z),h++,r.setXYZ(h,l.x,l.y,l.z),h++),c.copy(l)}}return o&&h>1&&!(r.getX(h-1)===r.getX(0)&&r.getY(h-1)===r.getY(0)&&r.getZ(h-1)===r.getZ(0))&&(r.setXYZ(h,r.getX(0),r.getY(0),r.getZ(0)),h++),u}(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 h=pR(r[l]),u=Bg(h,s),d=kg;for(let c=0;c<=u;c++)if(h instanceof Kl||h instanceof lc||h instanceof pl){if(h.getPoint(c/u,d),a!==void 0&&ECt(a,d,O1))continue;a===void 0&&(a=tT),a.copy(d),i.push(d.x,d.y),o++}}return m2(i[0],i[i.length-2],O1)&&m2(i[1],i[i.length-1],O1)&&(i.pop(),i.pop()),n&&o>1&&!(m2(i[o-1],i[1],O1)&&m2(i[o-2],i[0],O1))&&(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*Bg(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(UK(r,s)){let l=r.position.distanceTo(s.position);return r.position.distanceTo(rA.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){UK(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&&RCt(n,s,a);if(!s.controlsMoved()&&o>0&&!l){let h=s.curveBefore,u=s.curveAfter;if(h===void 0||u===void 0)continue;let d,c=s.roundedCurveBefore,p=s.roundedCurveAfter,m=h instanceof pl?h.v1.distanceTo(h.v2):h.getLength(),f=u instanceof pl?u.v1.distanceTo(u.v2):u.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=h.getPointAt(b,rA),S=u.getPointAt(_,WK);if(this._subSplitCurve(h,c,b,x,void 0),this._subSplitCurve(u,p,_,void 0,S),this.useCubicForRoundedCorners){let w=A0t(x,s.position,S)/2,T=Math.tan(w)*x.distanceTo(s.position),[C,M]=DCt(x,S,T,qK,HK),A=OCt(C,M,s.position),[P,O]=ICt(A,x,S,T,$K,XK);d=new Kl(x.clone(),P.clone(),O.clone(),S.clone())}else d=new lc(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 pl)){let n=t,a=e,o=n.getUtoTmapping(i,0),l=function(h,u,d,c,p=.5){let m=kg.subVectors(u,h).multiplyScalar(p).add(h),f=tT.subVectors(d,u).multiplyScalar(p).add(u),g=C0t.subVectors(c,d).multiplyScalar(p).add(d),y=m,v=E0t.subVectors(f,m).multiplyScalar(p).add(m),b=P0t.subVectors(g,f).multiplyScalar(p).add(f),_=g,x=R0t.subVectors(b,v).multiplyScalar(p).add(v);return[h.x,h.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 ps(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],h=t.points[r+5],u=t.points[r+6],d=new Xg(zt.generateUUID(),new Y(s,n));d.controls[0].position.set(a,o),d.controls[1].position.set(l,h),d.roundness=u,this.points.push(d)}return this.shapeHoles=t.shapeHoles?.length?t.shapeHoles.map(i=>{let r=new ps;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 lc&&(r[s]=CCt(r[s]));for(s=0,n=r.length;s<n;s++){let h,u=r[s],d=s>0?r[s-1]:null;u instanceof Kl?(h=this.createPoint(u.v0),h.controls[1].position.copy(u.v1)):u instanceof pl&&(h=this.createPoint(u.v1)),h!==void 0&&(d!==null&&i(h,d),a.push(h))}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 pl&&o.v2.equals(a[0].position)&&(l=!0),this.isClosed=l,a})(t.curves),t instanceof LS&&(this.shapeHoles=t.holes.map(r=>{let s=new ps;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 gN({x:t,y:e},i,r,s,n){return{x:t*i+s,y:e*r+n}}function NCt(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 YK(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 mR,BCt=U(()=>{mR=2*Math.PI});function qe(t,e){if(!t)throw e||"Assertion Failed!"}function pS(t){var e=t.windingRule,i=e===void 0?ns.ODD:e,r=t.elementType,s=r===void 0?Ma.POLYGONS:r,n=t.polySize,a=n===void 0?3:n,o=t.vertexSize,l=o===void 0?2:o,h=t.normal,u=h===void 0?[0,0,1]:h,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 O0t;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,u,m),{vertices:y.vertices,vertexIndices:y.vertexIndices,vertexCount:y.vertexCount,elements:y.elements,elementCount:y.elementCount,mesh:g?y.mesh:void 0}}}var ns,Ma,Le,X0,b_,lf,yN,vN,bN,KK,sA,_N,ZK,QK,O0t,wT=U(()=>{var t;(t=ns||(ns={}))[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"}(Ma||(Ma={})),Le=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){qe(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){qe(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){qe(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){qe(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,h;e.vertLeq(i,r)||(h=i,i=r,r=h),e.vertLeq(s,n)||(h=s,s=n,n=h),e.vertLeq(i,s)||(h=i,i=s,s=h,h=r,r=n,n=h),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)||(h=i,i=r,r=h),e.transLeq(s,n)||(h=s,s=n,n=h),e.transLeq(i,s)||(h=i,i=s,s=h,h=r,r=n,n=h),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}(),X0=function(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1},b_=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}(),lf=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},yN=function(){function e(){var i=new lf,r=new X0,s=new b_(0),n=new b_(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 b_(0),s=new b_(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;qe(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;qe(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 lf,r=new lf,s=new X0,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 lf;this.makeVertex_(a,r,i.Org),i.Org.anEdge=i}if(!s){var o=new X0;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 X0;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 lf;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 X0;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&&Le.vertCCW(s.Lprev.Org,s.Org,a.Lnext.Lnext.Org)&&Le.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,h=this.vHead,u=this.eHead;for(r=l,r=l;(i=r.next)!==l;r=i){qe(i.prev===r),a=i.anEdge;do qe(a.Sym!==a),qe(a.Sym.Sym===a),qe(a.Lnext.Onext.Sym===a),qe(a.Onext.Sym.Lnext===a),qe(a.Lface===i),a=a.Lnext;while(a!==i.anEdge)}for(qe(i.prev===r&&i.anEdge===null),n=h,n=h;(s=n.next)!==h;n=s){qe(s.prev===n),a=s.anEdge;do qe(a.Sym!==a),qe(a.Sym.Sym===a),qe(a.Lnext.Onext.Sym===a),qe(a.Onext.Sym.Lnext===a),qe(a.Org===s),a=a.Onext;while(a!==s.anEdge)}for(qe(s.prev===n&&s.anEdge===null),o=u,o=u;(a=o.next)!==u;o=a)qe(a.Sym.next===o.Sym),qe(a.Sym!==a),qe(a.Sym.Sym===a),qe(a.Org!==null),qe(a.Dst!==null),qe(a.Lnext.Onext.Sym===a),qe(a.Onext.Sym.Lnext===a);qe(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}(),vN=function(){this.handle=null},bN=function(){this.key=null,this.node=0},KK=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 vN,this.handles[s]=new bN;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,qe(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 vN;for(a=this.handles.length,this.handles.length=this.max+1,n=a;n<this.handles.length;n++)this.handles[n]=new bN}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;qe(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}(),sA=function(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1},_N=function(){this.key=null,this.next=null,this.prev=null},ZK=function(){function e(i,r){this.frame=i,this.leq=r,this.head=new _N,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 _N;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}(),QK=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?Le.vertLeq(a.Org,o.Org)?Le.edgeSign(o.Dst,a.Org,o.Org)<=0:Le.edgeSign(a.Dst,o.Org,a.Org)>=0:Le.edgeSign(o.Dst,n,o.Org)<=0:o.Dst===n?Le.edgeSign(a.Dst,n,a.Org)>=0:Le.edgeEval(a.Dst,n,a.Org)>=Le.edgeEval(o.Dst,n,o.Org)},e.deleteRegion=function(i,r){r.fixUpperEdge&&qe(r.eUp.winding===0),r.eUp.activeRegion=null,i.dict.delete(r.nodeUp)},e.fixUpperEdge=function(i,r,s){qe(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 sA;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 ns.ODD:return!!(1&r);case ns.NONZERO:return r!==0;case ns.POSITIVE:return r>0;case ns.NEGATIVE:return r<0;case ns.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,h,u,d,c=!0;u=s;do qe(Le.vertLeq(u.Org,u.Dst)),e.addRegionBelow(i,r,u.Sym),u=u.Onext;while(u!==n);for(a===null&&(a=e.regionBelow(r).eUp.Rprev),h=r,d=a;(u=(l=e.regionBelow(h)).eUp.Sym).Org===d.Org;)u.Onext!==d&&(i.mesh.splice(u.Oprev,u),i.mesh.splice(d.Oprev,u)),l.windingNumber=h.windingNumber-u.winding,l.inside=e.isWindingInside(i,l.windingNumber),h.dirty=!0,!c&&e.checkForRightSplice(i,h)&&(e.addWinding(u,d),e.deleteRegion(i,h),i.mesh.delete(d)),c=!1,h=l,d=u;h.dirty=!0,qe(h.windingNumber-u.winding===l.windingNumber),o&&e.walkDirtyRegions(i,h)},e.spliceMergeVertices=function(i,r,s){i.mesh.splice(r,s)},e.vertexWeights=function(i,r,s){var n=Le.vertL1dist(r,i),a=Le.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(Le.vertLeq(n.Org,a.Org)){if(Le.edgeSign(a.Dst,n.Org,a.Org)>0)return!1;Le.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(Le.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(qe(!Le.vertEq(a.Dst,o.Dst)),Le.vertLeq(a.Dst,o.Dst)){if(Le.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(Le.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,h=o.Org,u=l.Org,d=o.Dst,c=l.Dst,p=new lf;if(qe(!Le.vertEq(c,d)),qe(Le.edgeSign(d,i.event,h)<=0),qe(Le.edgeSign(c,i.event,u)>=0),qe(h!==i.event&&u!==i.event),qe(!r.fixUpperEdge&&!a.fixUpperEdge),h===u||Math.min(h.t,d.t)>Math.max(u.t,c.t))return!1;if(Le.vertLeq(h,u)){if(Le.edgeSign(c,h,u)>0)return!1}else if(Le.edgeSign(d,u,h)<0)return!1;return e.debugEvent(i),Le.intersect(d,h,c,u,p),qe(Math.min(h.t,d.t)<=p.t),qe(p.t<=Math.max(u.t,c.t)),qe(Math.min(c.s,d.s)<=p.s),qe(p.s<=Math.max(u.s,h.s)),Le.vertLeq(p,i.event)&&(p.s=i.event.s,p.t=i.event.t),s=Le.vertLeq(h,u)?h:u,Le.vertLeq(s,p)&&(p.s=s.s,p.t=s.t),Le.vertEq(p,h)||Le.vertEq(p,u)?(e.checkForRightSplice(i,r),!1):!Le.vertEq(d,i.event)&&Le.edgeSign(d,i.event,p)>=0||!Le.vertEq(c,i.event)&&Le.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):(Le.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),Le.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,h,d,u,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,h=o.eUp,u=!1;l.Dst!==h.Dst&&e.checkForIntersect(i,r),Le.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),u=!0),Le.vertEq(h.Org,i.event)&&(i.mesh.splice(s,h.Oprev),s=e.finishLeftRegions(i,o,null),u=!0),u?e.addRightEdges(i,r,s.Onext,a,a,!0):(n=Le.vertLeq(h.Org,l.Org)?h.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,h;return n=r.eUp,Le.vertEq(n.Org,s)?(qe(!1),void e.spliceMergeVertices(i,n,s.anEdge)):Le.vertEq(n.Dst,s)?(qe(!1),r=e.topRightRegion(r),a=l=(o=(h=e.regionBelow(r)).eUp.Sym).Onext,h.fixUpperEdge&&(qe(a!==o),e.deleteRegion(i,h),i.mesh.delete(o),o=a.Oprev),i.mesh.splice(s.anEdge,o),Le.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,h,u=new sA;if(u.eUp=r.anEdge.Sym,s=i.dict.search(u).key,n=e.regionBelow(s)){if(o=s.eUp,l=n.eUp,Le.edgeSign(o.Dst,r,o.Org)===0)return void e.connectLeftDegenerate(i,s,r);a=Le.vertLeq(l.Dst,o.Dst)?s:n,s.inside||a.fixUpperEdge?(h=a===s?i.mesh.connect(r.anEdge.Sym,o.Lnext):i.mesh.connect(l.Dnext,r.anEdge).Sym,a.fixUpperEdge?e.fixUpperEdge(i,a,h):e.computeWinding(i,e.addRegionBelow(i,s,h)),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);qe(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 sA,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 ZK(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||(qe(r.fixUpperEdge),qe(++s===1)),qe(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,Le.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 KK(a,Le.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,qe((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&&Le.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}(),O0t=function(){function e(){this.mesh=new yN,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=ns.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,h=[0,0,0],u=[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],u[y]=a,f[y]=r,h[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])<u[v]&&(u[v]=a,f[v]=r),a>h[v]&&(h[v]=a,m[v]=r);var b=0;if(h[1]-u[1]>h[0]-u[0]&&(b=1),h[2]-u[2]>h[b]-u[b]&&(b=2),u[b]>=h[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 h=!0,u=s.next;u!==s;u=u.next)h?(this.bmin[0]=this.bmax[0]=u.s,this.bmin[1]=this.bmax[1]=u.t,h=!1):(u.s<this.bmin[0]&&(this.bmin[0]=u.s),u.s>this.bmax[0]&&(this.bmax[0]=u.s),u.t<this.bmin[1]&&(this.bmin[1]=u.t),u.t>this.bmax[1]&&(this.bmax[1]=u.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(;Le.vertLeq(s.Dst,s.Org);s=s.Lprev);for(;Le.vertLeq(s.Org,s.Dst);s=s.Lnext);for(n=s.Lprev;s.Lnext!==n;)if(Le.vertLeq(s.Dst,n.Org)){for(;n.Lnext!==s&&(Le.edgeGoesLeft(n.Lnext)||Le.edgeSign(n.Org,n.Dst,n.Lnext.Dst)<=0);)n=i.connect(n.Lnext,n).Sym;n=n.Lprev}else{for(;n.Lnext!==s&&(Le.edgeGoesRight(s.Lprev)||Le.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,h=0;s>3&&i.mergeConvexFaces(s);for(var u=i.vHead.next;u!==i.vHead;u=u.next)u.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(u=a.Org).n===-1&&(u.n=h,h++),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===Ma.CONNECTED_POLYGONS&&(l*=2),this.elements=[],this.elements.length=l*s,this.vertexCount=h,this.vertices=[],this.vertices.length=h*n,this.vertexIndices=[],this.vertexIndices.length=h,u=i.vHead.next;u!==i.vHead;u=u.next)if(u.n!==-1){var c=u.n*n;this.vertices[c+0]=u.coords[0],this.vertices[c+1]=u.coords[1],n>2&&(this.vertices[c+2]=u.coords[2]),this.vertexIndices[u.n]=u.idx}var p=0;for(d=i.fHead.next;d!==i.fHead;d=d.next)if(d.inside){a=d.anEdge,o=0;do u=a.Org,this.elements[p++]=u.n,o++,a=a.Lnext;while(a!==d.anEdge);for(var m=o;m<s;++m)this.elements[p++]=-1;if(r===Ma.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 h=0,u=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[h++]=s.Org.coords[0],this.vertices[h++]=s.Org.coords[1],r>2&&(this.vertices[h++]=s.Org.coords[2]),this.vertexIndices[u++]=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 yN),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=ns.ODD),r===void 0&&(r=Ma.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_(),QK.computeInterior(this,o);var l=this.mesh;return r===Ma.BOUNDARY_CONTOURS?this.setWindingNumber_(l,1,!0):this.tessellateInterior_(l),o&&l.check(),r===Ma.BOUNDARY_CONTOURS?this.outputContours_(l,n):this.outputPolymesh_(l,r,s,n),!0},e}(),ns.ODD,ns.NONZERO,ns.POSITIVE,ns.NEGATIVE,ns.ABS_GEQ_TWO,Ma.POLYGONS,Ma.CONNECTED_POLYGONS,Ma.BOUNDARY_CONTOURS});function I0t(t,e){let i=t.length/2;if(i<2)return[];let r=0;for(let l=0;l<i;l++){let h=(l+1)%i;r+=t[2*l]*t[2*h+1]-t[2*h]*t[2*l+1]}let s=r>0!==e?1:-1,n=[];for(let l=0;l<i;l++){let h=(l+1)%i,u=t[2*h]-t[2*l],d=t[2*h+1]-t[2*l+1],c=Math.hypot(u,d);n.push(c>0?[s*d/c,-s*u/c]:[0,0])}let a=Math.cos(40*Math.PI/180),o=(l,h)=>{if(l[0]*h[0]+l[1]*h[1]<=a)return l;let[u,d]=[l[0]+h[0],l[1]+h[1]],c=Math.hypot(u,d);return c>0?[u/c,d/c]:l};return n.map((l,h)=>[o(l,n[(h+i-1)%i]),o(l,n[(h+1)%i])])}function N0t(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 B0t(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],h=t[n+2]-t[s+2],u=t[a]-t[s],d=t[a+1]-t[s+1],c=t[a+2]-t[s+2],p=h*u-o*c,m=o*d-l*u;if((l*c-h*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 xW,k0t,wW,V0t=U(()=>{}),SW=U(()=>{xW={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},k0t={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},wW={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}});function z0t(t,e){return t.normals[3*e+2]<.9999}function L0t(t){let e=Mj.get(t);if(e!==void 0)return e;if(!(t.rise>0))return t;let i=new Float32Array(t.normals),r=t.positions.length/3;for(let n=0;n<r;n++){if(!z0t(t,n))continue;let a=i[3*n],o=i[3*n+1],l=Math.hypot(a,o);if(l===0)continue;let h=t.rise-t.positions[3*n+2],u=Math.min(1,Math.max(0,1-h/t.rise)),d=Math.sqrt(1-u*u);i[3*n]=a/l*d,i[3*n+1]=o/l*d,i[3*n+2]=u}let s={...t,normals:i};return Mj.set(t,s),s}function F0t(t,e,i,r){let s=(e-t.minX)/t.spanX,n=(i-t.minY)/t.spanY;return r?[n,s]:[s,n]}var Mj,s5,Aj,TW=U(()=>{Mj=new WeakMap}),kCt=U(()=>{ot(),wT(),er(),V0t(),SW(),TW(),s5=class extends fe{constructor(t,e,i=12,r=ns.ODD,s,n=!1){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=n?void 0:s,this._legacy=n;let a,o=[t.extractShapePointsToFlatArray([],i),...t.shapeHoles.map(k=>k.extractShapePointsToFlatArray([],i))];try{a=pS({contours:o,windingRule:r,elementType:Ma.POLYGONS,polySize:3,vertexSize:2,strict:!0})}catch{a=wW}let l=a?.vertexCount??0,h=a?.elementCount??0,u=1/0,d=1/0,c=-1/0,p=-1/0;for(let k of o)for(let B=0;B<k.length;B+=2)k[B]<u&&(u=k[B]),k[B]>c&&(c=k[B]),k[B+1]<d&&(d=k[B+1]),k[B+1]>p&&(p=k[B+1]);let m=this._uvPitch,f=m??(c-u||1),g=m??(p-d||1),y=m===void 0?u:0,v=m===void 0?d:0,b=o.map((k,B)=>I0t(k,B>0)),_=0;for(let k of b)_+=k.length;let x=2*l+4*_,S=3*h*2+6*_,w=new Float32Array(3*x),T=new Float32Array(3*x),C=new Float32Array(2*x),M=new Uint32Array(S),A=new Uint8Array(x),P=0,O=0,D=0,N=!1,z=(k,B,V,q,W,H,rt=(k-y)/f,it=(B-v)/g)=>{let ft=3*O;w[ft]=k,w[ft+1]=B,w[ft+2]=V,T[ft]=q,T[ft+1]=W,T[ft+2]=H,A[O]=V===e?N?2:1:0,C[2*O]=rt,C[2*O+1]=it,O++};if(a!==void 0)for(let[k,B]of[[e,1],[0,-1]]){let V=O;for(let q=0;q<l;q++)z(a.vertices[2*q],a.vertices[2*q+1],k,0,0,B);for(let q=0;q<h;q++){let[W,H,rt]=[a.elements[3*q],a.elements[3*q+1],a.elements[3*q+2]];M[D++]=V+W,M[D++]=V+(B>0?H:rt),M[D++]=V+(B>0?rt:H)}}N=!0;for(let k=0;k<o.length;k++){let B=o[k],V=b[k],q=B.length/2,{u:W,vScale:H}=n?{u:new Float32Array(q+1),vScale:0}:N0t(B,f,g);P=H;let rt=H===0?0:e/H,it={minX:y,minY:v,spanX:f,spanY:g},ft=(dt,[K,lt],_t,xt)=>{let wt=B[2*dt],gt=B[2*dt+1],[Dt,Lt]=n?F0t(it,wt,gt,_t):[xt,_t?0:rt];z(wt,gt,_t?0:e,K,lt,0,Dt,Lt)};for(let dt=0;dt<V.length;dt++){let K=(dt+1)%q,[lt,_t]=V[dt],[xt,wt]=[W[dt],W[dt+1]],gt=O;ft(dt,lt,!1,xt),ft(dt,lt,!0,xt),ft(K,_t,!1,wt),ft(K,_t,!0,wt),M[D++]=gt,M[D++]=gt+1,M[D++]=gt+2,M[D++]=gt+3,M[D++]=gt+2,M[D++]=gt+1}}B0t(w,T,M),this.setAttribute("position",new ve(w,3)),this.setAttribute("normal",new ve(T,3)),this.setAttribute("uv",new ve(C,2)),this.setIndex(new ve(M,1)),this._nearSide=A,this._vScale=P}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 h=o[l];h!==0&&(r[3*l+2]+=e,h===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 s5(this._shape,this._depth,this._curveSegments,this._windingRule,this._uvPitch,this._legacy);return t.userData=sD(this.userData),t}}}),U0t=U(()=>{ot(),wT(),er(),SW(),Aj=class extends fe{constructor(t,e=12,i={}){super(),this.type="ShapeGeometry",this.windingRule=ns.ODD,this.elementType=Ma.POLYGONS,this.polySize=3,this.vertexSize=2,this.strict=!0,this._shape=t,this._curveSegments=e,this._triangulationOptions=Object.assign({windingRule:ns.ODD,elementType:Ma.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,h=!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&&(h=!1),s=f,n=g,!l&&!h)break}if(!l&&!h)try{r=pS({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=xW}let u=r?.vertexCount??1,d=r?.elementCount??1;if(this._positionAttribute=new ve(new Float32Array(3*u),3),this._normalAttribute=new ve(new Float32Array(3*u),3),this._uvAttribute=new ve(new Float32Array(2*u),2),this._indexAttribute=new ve(new Uint32Array(3*d),1),r){let c=1/0,p=-1/0,m=1/0,f=-1/0;for(let v=0,b=u;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=u;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 Aj(this._shape,this._curveSegments);return t.userData=sD(this.userData),t}}});function VCt(t){return JK||(JK=async function(){let e=t??"https://unpkg.com/@splinetool/runtime@2.0.206/build",i=Promise.resolve().then(()=>(vH(),yH)),[r,s]=await Promise.all([i,fetch(`${e}/bevel.wasm`).then(n=>n.arrayBuffer())]);await r.default({module_or_path:s}),ST=r}())}function zCt(t){let e=!1;return t.scene.objects.traverse((i,r)=>{let s=r.geometry;if(s!==void 0&&(q0t.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 j0t(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 n5(t,e,i,r,s,n){let a=t.positions.length/3,o=s.elements,l=H0t.getNormalMatrix(s).elements;for(let u=0;u<a;u++){let d=3*u,c=3*(i+u),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+u);if(n===void 0)e.uvs[b]=t.uvs[2*u],e.uvs[b+1]=t.uvs[2*u+1];else{let[_,x]=n(p,m,t.uvs[2*u],t.uvs[2*u+1],u);e.uvs[b]=_,e.uvs[b+1]=x}}let h=s.determinant()<0;for(let u=0;u<t.indices.length;u+=3)e.indices[r+u]=t.indices[u]+i,e.indices[r+u+1]=t.indices[u+(h?2:1)]+i,e.indices[r+u+2]=t.indices[u+(h?1:2)]+i}function G0t(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}`,h=`${n}/${a}`,u=a5.get(l);if(u!==void 0&&u.outlineVersion===o&&u.capKey===h&&(t.stillServes?.(u)??1))return Cj.placements++,u.cap;let d=function(c,p,m,f,g){let{points:y,ends:v}=j0t(c,p);return ST.assemble_cap(y,v,m,f,0,Math.max(1,Math.floor(g)),W0t,40)}(i,r,s,n,a);Cj.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 a5.set(l,{outlineVersion:o,capKey:h,assembledAt:s,cap:c}),c}finally{d.free()}}function ev(t,e){return .5*e>1.001*t}var ST,W0t,JK,q0t,H0t,tZ,eZ,iZ,a5,Cj,Ej,Cm,lb=U(()=>{ot(),er(),V0t(),TW(),W0t=.4,q0t=new Set(["VectorGeometry","TextGeometry","InputGeometry","PolygonGeometry","RectangleGeometry","StarGeometry","TriangleGeometry","EllipseGeometry"]),H0t=new Ms,tZ=new bt,eZ=new bt,iZ=new bt().makeScale(1,1,-1),a5=new Map,Cj={assemblies:0,placements:0},Ej=class extends fe{constructor(t,e,i=0,r=12,s=3,n,a,o=!1){if(super(),this.type="ShapeGeometry",this._nearSide=new Uint8Array(0),this._effectiveBevel=0,this._vScale=0,ST===void 0)throw new Error("bevel-wasm is not loaded");this._shape=t,this._uvPitch=a,this._legacy=o,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&&ev(this._effectiveBevel,t)&&ev(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 h=o[l];h!==0&&(r[3*l+2]+=e,h===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=G0t({owner:this._ownerId,shape:this._shape,curveSegments:this._curveSegments,assembledAt:this._depth,bevel:this._bevel,bevelSegments:this._bevelSegments,stillServes:a=>ev(a.cap.rise,this._depth)&&ev(a.cap.rise,a.assembledAt)}),e=function(a,o,l,h,u,d=!1){let c=h.positions.length/3,p=l-h.rise,m=h.rise,{points:f,ends:g}=j0t(a,o),y=1/0,v=1/0,b=-1/0,_=-1/0;for(let it=0;it<f.length;it+=2)f[it]<y&&(y=f[it]),f[it]>b&&(b=f[it]),f[it+1]<v&&(v=f[it+1]),f[it+1]>_&&(_=f[it+1]);d&&(u=void 0);let x=u??b-y,S=u??_-v,w={minX:y,minY:v,spanX:b-y||1,spanY:_-v||1},T=[],C=0;for(let it of g)T.push({at:C,count:it-C}),C=it;let M=0;for(let it of T)M+=it.count;let A=2*c+4*M,P=new Float32Array(3*A),O=new Float32Array(3*A),D=new Float32Array(2*A),N=new Uint32Array(2*h.indices.length+6*M),z=new Uint8Array(A),k=0,B=u===void 0?void 0:(it,ft)=>[it/u,ft/u],V=d?(it,ft,dt,K,lt)=>z0t(h,lt)?[K,dt]:[dt,K]:B,q=d?L0t(h):h,W={positions:P,normals:O,uvs:D,indices:N};n5(q,W,0,0,tZ.makeTranslation(0,0,p),B),n5(q,W,c,h.indices.length,eZ.makeTranslation(0,0,m).multiply(iZ),V),z.fill(1,0,c);let H=2*c,rt=2*h.indices.length;for(let it=0;it<T.length;it++){let{at:ft,count:dt}=T[it],K=f.subarray(2*ft,2*(ft+dt)),lt=I0t(K,it>0),_t=d?{u:new Float32Array(dt+1),vScale:0}:N0t(K,x,S),xt=_t.u;k=_t.vScale;for(let wt=0;wt<dt;wt++){let gt=(wt+1)%dt,[Dt,Lt]=lt[wt],It=H;for(let[kt,Nt,Gt,qt,Ct,ne]of[[K[2*wt],K[2*wt+1],Dt,p,xt[wt],2],[K[2*gt],K[2*gt+1],Lt,p,xt[wt+1],2],[K[2*gt],K[2*gt+1],Lt,m,xt[wt+1],0],[K[2*wt],K[2*wt+1],Dt,m,xt[wt],0]]){let Ut=3*H;if(P[Ut]=kt,P[Ut+1]=Nt,P[Ut+2]=qt,O[Ut]=Gt[0],O[Ut+1]=Gt[1],O[Ut+2]=0,d){let[Yt,Zt]=F0t(w,kt,Nt,ne===0);D[2*H]=Yt,D[2*H+1]=Zt}else D[2*H]=Ct,D[2*H+1]=k===0?0:(qt-m)/k;z[H]=ne,H++}N[rt++]=It,N[rt++]=It+1,N[rt++]=It+2,N[rt++]=It,N[rt++]=It+2,N[rt++]=It+3}}return B0t(P,O,N),{positions:P,normals:O,uvs:D,indices:N,nearSide:z,vScale:k}}(this._shape,this._curveSegments,this._depth,t,this._uvPitch,this._legacy);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 ve(e.positions,3)),this.setAttribute("normal",new ve(e.normals,3)),this.setAttribute("uv",new ve(e.uvs,2)),this.setIndex(new ve(e.indices,1))}clone(){let t=new Ej(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegments,this._ownerId,this._uvPitch,this._legacy);return t.userData=sD(this.userData),t}}}),wm=U(()=>{Am(),kCt(),U0t(),lb(),wT(),Cm=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:ns.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 ps?(i=o,(i.width!==s||i.height!==n)&&i.applySize(s,n)):i=new ps(s,n).fromJSON(o),t.parameters?.roundness!==void 0&&t.parameters?.roundness>0&&i.update());let h=i??new ps(s,n);return{parameters:Object.assign(r,{width:s,height:n,depth:a,roundness:l}),shape:h,ownerId:t.ownerId??e?.ownerId}}static build(t){let e,{depth:i,extrudeBevelSize:r,extrudeBevelSegments:s,subdivisions:n,roundness:a,windingRule:o,uvPitch:l,extrusionVersion:h}=t.parameters,u=h===1;return t.shape.roundness=a,i<=0?e=new Aj(t.shape,n,{windingRule:o}):r<=0?e=new s5(t.shape,i,n,o,l,u):ST!==void 0?e=new Ej(t.shape,i,r,n,s,t.ownerId,l,u):(console.error("[extrude] engine not loaded \u2014 extruding without a bevel"),e=new s5(t.shape,i,n,o,l,u)),Object.assign(e,{userData:{...t,type:"VectorGeometry"}})}}});function LCt(t,e,i,r,s,n){if(r>=MW)return s>30||s%4==0?(function(u,d,c,p=0,m=0,f=0){let g=.5522847498,y=d*g,v=c*g;u.addPoint(nA(m-d,f,m-d,f-v,m-d,f+v)),u.addPoint(nA(m,f+c,m-y,f+c,m+y,f+c)),u.addPoint(nA(m+d,f,m+d,f+v,m+d,f-v)),u.addPoint(nA(m,f-c,m+y,f-c,m-y,f-c)),p>0&&X0t(u,d,c,p)}(t,e,i,n),Math.round(s/4)):rZ(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},h=function({px:u,py:d,cx:c,cy:p,rx:m,ry:f,largeArcFlag:g,sweepFlag:y}){let v=[];if(m===0||f===0)return[];let b=(u-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,D,N,z,k,B,V,q,W,H){let rt=Math.pow(k,2),it=Math.pow(B,2),ft=Math.pow(V,2),dt=Math.pow(q,2),K=rt*it-rt*dt-it*ft;K<0&&(K=0),K/=rt*dt+it*ft,K=Math.sqrt(K)*(W===H?-1:1);let lt=K*k/B*q,_t=K*-B/k*V,xt=lt+(O+N)/2,wt=_t+(D+z)/2,gt=(V-lt)/k,Dt=(q-_t)/B,Lt=(-V-lt)/k,It=(-q-_t)/B,kt=YK(1,0,gt,Dt),Nt=YK(gt,Dt,Lt,It);return!H&&Nt>0&&(Nt-=mR),H&&Nt<0&&(Nt+=mR),{centerx:xt,centery:wt,ang1:kt,ang2:Nt}}(u,d,c,p,m,f,b,_,g,y),{ang1:w,ang2:T}=S,{centerx:C,centery:M}=S,A=Math.abs(T)/(mR/4);Math.abs(1-A)<1e-7&&(A=1);let P=Math.max(Math.ceil(A),1);T/=P;for(let O=0;O<P;O++)v.push(NCt(w,T)),w+=T;return v.map(O=>{let{x:D,y:N}=gN(O[0],m,f,C,M),{x:z,y:k}=gN(O[1],m,f,C,M),{x:B,y:V}=gN(O[2],m,f,C,M);return{x1:D,y1:N,x2:z,y2:k,x:B,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%h.length===0?function(u,d,c,p,m,f,g,y){let v=Math.round(m/p.length);u.addPoint(bv(d,c));for(let b=0,_=p.length;b<_;b++){let x=p[b],S=u.points[b],w=bv(x.x,x.y);S.controls[1].position.set(x.x1,x.y1),w.controls[0].position.set(x.x2,x.y2),u.addPoint(w)}return y>0?$0t(u,f,g,y):u.addPoint(bv(0,0)),v}(t,a.x,a.y,h,s,e,i,n):rZ(t,r,s,e,i,n)}function rZ(t,e,i,r,s,n){let a=-e/i;for(let o=0;o<=i;o++){let l=a*o,h=Math.sin(l)*r,u=Math.cos(l)*s;t.addPoint(bv(h,u))}return e<MW?n>0?$0t(t,r,s,n):t.addPoint(bv(0,0)):(t.removePoint(t.points[t.points.length-1]),n>0&&X0t(t,r,s,n)),1}function bv(t,e){return new Xg(zt.generateUUID(),new Y(t,e))}function nA(t,e,i,r,s,n){let a=bv(t,e);return a.controls[0].position.set(i,r),a.controls[1].position.set(s,n),a}function $0t(t,e,i,r){Y0t(t,e,i,r).forEach(s=>t.addPoint(s))}function X0t(t,e,i,r){let s=Y0t(t,e,i,r),n=new ps;s.forEach(a=>n.addPoint(a)),n.isClosed=!0,t.shapeHoles.push(n)}function Y0t(t,e,i,r){let s=r*e/100,n=s*(Math.abs(i)/Math.abs(e)),a=new Y(s/e,n/i),o=t.points.map(l=>{let h=l.clone();return h.uuid=zt.generateUUID(),h}).reverse();return o.forEach(l=>{l.position.multiply(a);let h=l.controls[0].position.clone().multiply(a),u=l.controls[1].position.clone().multiply(a);l.controls[0].position.copy(u),l.controls[1].position.copy(h)}),o}var MW,xD,K0t,xN,Z0t,o5=U(()=>{Am(),D0t(),BCt(),wm(),ot(),MW=2*Math.PI,xD=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=zt.clamp(i.angle,0,360),{shape:t.shape&&t.shape instanceof ps?t.shape:new ps,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:h,extrusionVersion:u}=t.parameters,d=t.shape,c=LCt(d,.5*i,.5*r,n*Math.PI/180,s,a);return d.isClosed=!0,d.update(),n===0?(e=new fe,e.setAttribute("position",new me([],3))):e=Cm.create({shape:d,parameters:{subdivisions:c,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h,extrusionVersion:u}}),Object.assign(e,{userData:{...t,type:"EllipseGeometry"}})}}}),sZ=U(()=>{ot(),M0t(),K0t=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 xN(.5*e,n,a):new lU(.5*e,s),l=i/e,h=r/e;return(l!==1||h!==1)&&o.scale(1,l,h),Object.assign(o,{userData:{...t,type:"IcosahedronGeometry"}})}},xN=class extends i5{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 xN(t.radius,t.corner,t.cornerSides)}}}),nZ=U(()=>{ot(),Z0t=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 LS;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 hU(s.extractPoints(r).shape,i);return n.rotateZ(Math.PI),Object.assign(n,{userData:{...t,type:"LatheGeometry"}})}}});function Y0(t,e){return Math.abs(e-t)/2+Math.min(t,e)}function FCt(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,h=new Uint32Array(l),u=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=(D,N)=>{let z=(Math.imul(D,2654435761)^N)&g;for(;;){let k=y[z];if(k===-1)return y[z]=m,h[m]=D,u[m]=N,m++;if(h[k]===D&&u[k]===N)return k;z=z+1&g}},b=(D,N)=>{let z=D<N?D:N,k=D<N?N:D,B=(Math.imul(z,2654435761)^k)&g;for(;;){let V=y[B];if(h[V]===z&&u[V]===k)return V;B=B+1&g}},_=new Uint32Array(n),x=new Float64Array(3*n),S=(D,N,z)=>{let k=D<N?v(D,N):v(N,D),B=++d[k];B===1?c[k]=z:B===2&&(p[k]=z),_[D]++,_[N]++,x[3*D]+=e[3*N],x[3*D+1]+=e[3*N+1],x[3*D+2]+=e[3*N+2],x[3*N]+=e[3*D],x[3*N+1]+=e[3*D+1],x[3*N+2]+=e[3*D+2]};for(let D=0;D<a;D++){let N=i[3*D],z=i[3*D+1],k=i[3*D+2];S(N,z,k),S(z,k,N),S(k,N,z)}let w=new Float64Array(3*m);for(let D=0;D<m;D++){let N=3*h[D],z=3*u[D];if(d[D]===2){let k=3*c[D],B=3*p[D];w[3*D]=.375*(e[N]+e[z])+.125*(e[k]+e[B]),w[3*D+1]=.375*(e[N+1]+e[z+1])+.125*(e[k+1]+e[B+1]),w[3*D+2]=.375*(e[N+2]+e[z+2])+.125*(e[k+2]+e[B+2])}else w[3*D]=.5*(e[N]+e[z]),w[3*D+1]=.5*(e[N+1]+e[z+1]),w[3*D+2]=.5*(e[N+2]+e[z+2])}let T,C=new Float64Array(3*n);for(let D=0;D<n;D++){let N=_[D];N===3?T=3/16:N>3&&(T=3/(8*N));let z=1-N*Number(T),k=Number(T);N===2&&(z=3/4,k=1/8),C[3*D]=e[3*D]*z+x[3*D]*k,C[3*D+1]=e[3*D+1]*z+x[3*D+1]*k,C[3*D+2]=e[3*D+2]*z+x[3*D+2]*k}let M=new Float64Array(3*(n+m));M.set(C),M.set(w,3*n);let A=new Uint32Array(12*a),P=new Array(4*a),O=o?new Float64Array(24*a):null;for(let D=0;D<a;D++){let N=i[3*D],z=i[3*D+1],k=i[3*D+2],B=b(N,z)+n,V=b(z,k)+n,q=b(k,N)+n,W=12*D;A[W++]=B,A[W++]=V,A[W++]=q,A[W++]=N,A[W++]=B,A[W++]=q,A[W++]=z,A[W++]=V,A[W++]=B,A[W++]=k,A[W++]=q,A[W++]=V;let H=r[D];if(P[4*D]=H,P[4*D+1]=H,P[4*D+2]=H,P[4*D+3]=H,O!==null){let rt=6*D,it=s[rt],ft=s[rt+1],dt=s[rt+2],K=s[rt+3],lt=s[rt+4],_t=s[rt+5],xt=Y0(it,dt),wt=Y0(ft,K),gt=Y0(dt,lt),Dt=Y0(K,_t),Lt=Y0(it,lt),It=Y0(ft,_t),kt=24*D;O[kt++]=xt,O[kt++]=wt,O[kt++]=gt,O[kt++]=Dt,O[kt++]=Lt,O[kt++]=It,O[kt++]=it,O[kt++]=ft,O[kt++]=xt,O[kt++]=wt,O[kt++]=Lt,O[kt++]=It,O[kt++]=dt,O[kt++]=K,O[kt++]=gt,O[kt++]=Dt,O[kt++]=xt,O[kt++]=wt,O[kt++]=lt,O[kt++]=_t,O[kt++]=Lt,O[kt++]=It,O[kt++]=gt,O[kt++]=Dt}}return{positions:M,faces:A,materialIndices:P,uvs:O}}var aA,Q0t,rn,J0t,AW,UCt=U(()=>{ot(),aA=1e4,Q0t=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,h=new Uint32Array(o),u=[],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*aA),w=Math.round(_*aA),T=Math.round(x*aA),C=l.get(S);C===void 0&&(C=new Map,l.set(S,C));let M=C.get(w);M===void 0&&(M=new Map,C.set(w,M));let A=M.get(T);A===void 0&&(A=d++,M.set(T,A),u.push(b,_,x)),h[v]=A}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=h[_],T=h[x],C=h[S];w===T||T===C||C===w||(c.push(w,T,C),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(u),faces:Uint32Array.from(c),materialIndices:p,uvs:m===null?null:Float64Array.from(m)}}(t),i=this.subdivisions;for(;i-- >0;)e=FCt(e);return function(r,s){let{positions:n,faces:a,materialIndices:o,uvs:l}=r,h=n.length/3,u=a.length/3,d=new Float64Array(3*h);for(let y=0;y<u;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],C=n[v+1]-n[b+1],M=n[v+2]-n[b+2],A=S*M-w*C,P=w*T-x*M,O=x*C-S*T;d[v]+=A,d[v+1]+=P,d[v+2]+=O,d[b]+=A,d[b+1]+=P,d[b+2]+=O,d[_]+=A,d[_+1]+=P,d[_+2]+=O}for(let y=0;y<h;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*u,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 fe;g.setAttribute("position",new ve(p,3)),c>0&&(g.setAttribute("normal",new ve(m,3)),g.setAttribute("color",new ve(new Float32Array(3*c).fill(1),3))),f!==null&&g.setAttribute("uv",new ve(f,2));for(let y=0;y<u;){let v=o[y],b=y;do y++;while(y<u&&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)}}}),aZ=U(()=>{ot(),UCt(),rn=new E,J0t=class{static create(t){return this.build(this.normalizeInputs(t))}static normalizeInputs(t,e){let i,r=t.geometry??e?.geometry??new fe().copy(new Yh(100,100,100));e===void 0?(r.computeBoundingBox(),r.boundingBox.getSize(rn),i={width:rn.x,height:rn.y,depth:rn.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 fe().copy(new Yh(100,100,100)),a=n.userData.parameters;a===void 0?(n.boundingBox=function(l){let h=new dr,u=l.attributes.position;return u?(h.setFromBufferAttribute(u),h):(h.makeEmpty(),h)}(n),n.boundingBox.getSize(rn)):rn.set(a.width,a.height,a.depth),(e!==rn.x||i!==rn.y||r!==rn.z)&&n.scale(rn.x===0?1:e/rn.x,rn.y===0?1:i/rn.y,rn.z===0?1:r/rn.z);let o=n.originalGeometry;try{s>0?(o===void 0||a?.subdivisions!==s)&&(o===void 0&&(o=n),n=new Q0t(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 OG(i).load(t,r=>{let s=this.normalizeInputs({geometry:r});r.boundingBox.getSize(rn);let n=100/rn.x;Object.assign(s.parameters,{width:100,height:rn.y*n,depth:rn.z*n}),e(this.build(s))})}}}),Pj=U(()=>{Am(),wm(),AW=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 ps?t.shape:new ps,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,extrusionVersion:l}=t.parameters,h=t.shape,u=.5*e,d=.5*i,c=2*Math.PI/r;for(let m=0;m<r;m++){let f=c*m,g=0+Math.sin(f)*u,y=0+Math.cos(f)*d;h.addPoint(h.createPoint(g,y))}h.isClosed=!0;for(let m=0,f=h.points.length;m<f;m++)h.points[m].roundness=s;h.roundness=s,h.update();let p=Cm.create({shape:h,parameters:{roundness:s,depth:n,extrudeBevelSize:a,extrudeBevelSegments:o,extrusionVersion:l}});return Object.assign(p,{userData:{...t,type:"PolygonGeometry"}})}}});function __(t,e,i){i.x=t.x*e.x,i.y=t.y,i.z=t.x*e.y}function wN(t,e,i,r,s,n){let a=eyt.copy(e).sub(t),o=iyt.copy(i).sub(t),l=a.angleTo(o);if(a.normalize(),o.normalize(),r===s){let h=a.add(o).normalize();n.copy(t).addScaledVector(h,r/Math.sin(l/2))}else{let h=a.angleTo(o);n.copy(t),n.addScaledVector(a,s/Math.sin(h)),n.addScaledVector(o,r/Math.sin(h))}}function jCt(t,e,i){let r=t.clone().sub(e),s=i.clone().sub(e);return r.projectOnVector(s),r.add(e)}var tyt,eyt,iyt,oZ,wD,ryt,syt,nyt,lZ,CW,ayt,oyt,lyt,hyt,hZ=U(()=>{ot(),tyt=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,h=new oZ(.5*e,i,s,n,a,o,l),u=r/e;return u!==1&&h.scale(1,1,u),Object.assign(h,{userData:{...t,type:"PyramidGeometry"}})}},eyt=new E,iyt=new E,oZ=class extends fe{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=[],h=[],u=[],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 E(0,-p,0),_=new E(0,p,0),x=new Y(t,-p),S=new Y(f,-p),w=new Y(0,_.y).sub(S),T=new Y(0,_.y).sub(x),C=new Y(w.y,-w.x).normalize(),M=new Y(T.y,-T.x).normalize(),A=t*Math.cos(Math.PI/i)*Math.tan((Math.PI-w.angle())/2)-1e-8;n=Math.min(n,A);{let B=new E(C.x,C.y,0),V=new E(Math.cos(g)*B.x,B.y,Math.sin(g)*B.x);o=B.angleTo(V)}let P=n/Math.tan((Math.PI-w.angle())/2),O=n/Math.tan((Math.PI-o)/2),D=new E;if(!s){h.push(b.x,b.y,b.z),u.push(0,-1,0),d.push(0,0);let B=c++,V=[],q=x.clone(),W=P/Math.cos(Math.PI/i);q.x-=W;for(let H=0;H<i;H++){let rt=H/i*Math.PI*2+m;__(q,new Y(Math.sin(rt),Math.cos(rt)),D),h.push(D.x,D.y,D.z),u.push(0,-1,0),d.push(0,0),V.push(c++)}for(let H=0;H<V.length;H++)l.push(V[H],B,V[(H+1)%V.length])}let N=[];{let B=new E,V=new E,q=new E,W=new E,H=new E,rt=new E;for(let it=0;it<i;it++){let ft=it/i*Math.PI*2+m,dt=(it+.5)/i*Math.PI*2+m,K=(it+1)/i*Math.PI*2+m,lt=new Y(Math.sin(ft),Math.cos(ft)),_t=new Y(Math.sin(dt),Math.cos(dt)),xt=new Y(Math.sin(K),Math.cos(K));__(x,lt,V),__(x,xt,q),__(C,_t,B),wN(_,V,q,O,O,W),h.push(W.x,W.y,W.z),wN(V,_,q,O,P,H),h.push(H.x,H.y,H.z),wN(q,V,_,P,O,rt),h.push(rt.x,rt.y,rt.z),u.push(B.x,B.y,B.z),u.push(B.x,B.y,B.z),u.push(B.x,B.y,B.z),d.push(0,0),d.push(0,0),d.push(0,0);let wt=c++,gt=c++,Dt=c++;if(l.push(wt,gt,Dt),n>0){{let kt=V.clone().add(q).multiplyScalar(.5),Nt=_.clone().sub(kt).normalize(),Gt=b.clone().sub(kt).normalize().add(Nt).normalize().multiplyScalar(-1);z(kt,rt.clone().sub(H),Gt,w.angle())}let Lt,It;{let kt=new E;__(M,xt,kt);let Nt=rt.clone().add(W).multiplyScalar(.5);Nt=jCt(Nt,q,_);let Gt=rt.clone().sub(W);[Lt,It]=z(Nt,Gt,kt,o,W.y)}{let kt=Lt,Nt=kt.clone().setY(0).normalize(),Gt=new E(0,-1,0),qt=Nt.clone().cross(Gt);k(kt,Nt,Gt,qt)}N.concat(It);{let kt=w.angle(),Nt=Math.PI-kt,Gt=_.clone();Gt.y-=n/Math.sin(kt-Math.PI/2);let qt=new E,Ct=[];for(let Ut=0;Ut<a;Ut++){let Yt=[],Zt=Math.PI/2-Nt*Ut/a,$=Math.cos(Zt),ie=Math.sin(Zt),Ce=dt;for(let Be=0;Be<=Ut;Be++){let te=Math.cos(Ce),ni=Math.sin(Ce);B.x=$*ni,B.y=ie,B.z=$*te,qt.copy(Gt).addScaledVector(B,n),h.push(qt.x,qt.y,qt.z),u.push(B.x,B.y,B.z),d.push(0,0),Yt.push(c++),Ce+=2*Math.PI/Ut/i}Ct.push(Yt)}It.reverse(),Ct.push(It);let ne=Ct.length-1;for(let Ut=0;Ut<ne;Ut++){let Yt=Ct[Ut],Zt=Ct[Ut+1],$=Yt.length-1;l.push(Zt[1],Yt[0],Zt[0]);for(let ie=1;ie<=$;ie++)l.push(Yt[ie],Yt[ie-1],Zt[ie]),l.push(Zt[ie+1],Yt[ie],Zt[ie])}}}}}function z(B,V,q,W,H){let rt=-W/2,it=(Math.PI-W)/2,ft=V.clone().normalize().cross(q);B.addScaledVector(q,-n/Math.sin(it));let dt=new E,K=new E,lt=c,_t=[];for(let xt=0;xt<=a;xt++){let wt=rt+xt/a*W;K.set(0,0,0),K.addScaledVector(ft,Math.sin(wt)),K.addScaledVector(q,Math.cos(wt));for(let gt=0;gt<=1;gt++){let Dt=gt/1-.5;if(dt.copy(B),dt.addScaledVector(V,Dt),dt.addScaledVector(K,n),H!=null){let Lt=Math.max(0,dt.y-H);dt.addScaledVector(V,-Lt/V.y)}h.push(dt.x,dt.y,dt.z),u.push(K.x,K.y,K.z),d.push(0,0),gt===0&&_t.push(c),c++}}for(let xt=0;xt<a;xt++)for(let wt=0;wt<1;wt++){let gt=lt+wt+2*xt,Dt=gt+2,Lt=Dt+1,It=gt+1;l.push(gt,Dt,It),l.push(Dt,Lt,It)}return[B.clone().addScaledVector(V,.5),_t]}function k(B,V,q,W){let H=Math.PI/2,rt=T.angle()-H,it=[],ft=new E,dt=new E;for(let lt=0;lt<=a;lt++){let _t=[],xt=lt/a;for(let wt=0;wt<=lt;wt++){let gt=((lt?wt/lt:0)-.5)*v,Dt=Math.cos(gt),Lt=Math.sin(gt),It=(H+Math.atan(Math.tan(rt)*Dt))*xt,kt=Math.cos(It),Nt=Math.sin(It);ft.set(0,0,0),ft.addScaledVector(V,Nt*Dt),ft.addScaledVector(q,kt),ft.addScaledVector(W,Nt*Lt),dt.copy(B).addScaledVector(ft,n),h.push(dt.x,dt.y,dt.z),u.push(ft.x,ft.y,ft.z),d.push(0,0),_t.push(c++)}it.push(_t)}let K=it.length-1;for(let lt=0;lt<K;lt++){let _t=it[lt],xt=it[lt+1],wt=_t.length-1;l.push(_t[0],xt[1],xt[0]);for(let gt=1;gt<=wt;gt++)l.push(_t[gt-1],_t[gt],xt[gt]),l.push(_t[gt],xt[gt+1],xt[gt])}}this.setIndex(l),this.setAttribute("position",new me(h,3)),this.setAttribute("normal",new me(u,3)),this.setAttribute("uv",new me(d,2))}}}),l5=U(()=>{Am(),wm(),wD=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 ps?t.shape:new ps,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,extrusionVersion:h}=t.parameters,u={x:.5*i,y:.5*r},d={x:-u.x,y:-u.y},c={x:u.x,y:u.y};function p(x,S,w){return S>i&&w>r?Math.min(x*i/S,x*r/w):S>i?x*i/S:w>r?x*r/w:x}let m=[];m[0]=s[0]===0?0:p(s[0],s[0]+s[3],s[0]+s[1]),m[1]=s[1]===0?0:p(s[1],s[1]+s[2],s[1]+s[0]),m[2]=s[2]===0?0:p(s[2],s[2]+s[1],s[2]+s[3]),m[3]=s[3]===0?0:p(s[3],s[3]+s[0],s[3]+s[2]);let f=d.x,g=c.x,y=c.y,v=d.y;e.addPoint(e.createPoint(f,y)),e.addPoint(e.createPoint(g,y)),e.addPoint(e.createPoint(g,v)),e.addPoint(e.createPoint(f,v)),e.isClosed=!0;let b=!0;for(let x=0,S=e.points.length;x<S;x++)e.points[x].roundness=m[x],x>0&&m[x]!==m[x-1]&&(b=!1);b&&(e.roundness=m[0]),e.useCubicForRoundedCorners=n!==1,e.update();let _=Cm.create({shape:e,parameters:{depth:a,extrudeBevelSize:o,extrudeBevelSegments:l,extrusionVersion:h}});return Object.assign(_,{userData:{...t,type:"RectangleGeometry"}})}}}),uZ=U(()=>{ot(),ryt=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=zt.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:h,thetaLength:u}=t.parameters;return u===0?(e=new fe,e.setAttribute("position",new me([],3))):e=new Ac(.5*i,n,a,o,l,h,u*zt.DEG2RAD),e.scale(1,r/i,s/i),Object.assign(e,{userData:{...t,type:"SphereGeometry"}})}}}),dZ=U(()=>{ot(),syt=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 Rc(e,i,r,s);return n.scale(1,1,1),Object.assign(n,{userData:{...t,type:"PlaneGeometry"}})}}}),cZ=U(()=>{ot(),nyt=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 lZ(e,i,r,s,n,a);return Object.assign(o,{userData:{...t,type:"BackdropGeometry"}})}},lZ=class extends fe{constructor(t=1,e=1,i=1,r=90,s=10,n=24){super(),this.type="BackdropGeometry";let a=[],o=[],l=[],h=.001;s==0&&(n=1),n=Math.max(1,Math.floor(n)),s=Math.min(s,100),r=Math.min(180-h,r),r*=Math.PI/180;let u=[],d=Math.PI/2,c=(dt=0,K=0,lt=0)=>new E(dt,K,lt),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=(dt,K=!1)=>Math.sin(dt-Math.PI/(+K+1)),T=(dt,K=!1)=>Math.cos(dt-Math.PI/(+K+1));S.y=Math.sin(r)*e-f;let C=Math.cos(r)*e-y,M=_.z-h;r<=d?(S.z=Math.min(C,M),S.z==M&&(S.y-=(C-M)/Math.tan(d-r))):x.z=Math.min(x.z-C-y,_.z-h),p.subVectors(_,x),m.subVectors(S,x);let A=Math.min(p.length(),m.length())*s/100,P=A*Math.tan(r/2),O=A/Math.cos(r/2),D=p.clone().normalize().add(m.normalize()).setLength(O).add(x);p.set(0,w(r,!0),T(r,!0)),u.push([S,p.clone()]);let N=(Math.PI-r)/n;for(let dt=0;dt<=n;dt++){let K=d+r+dt*N;p.set(0,Math.sin(K)*P,Math.cos(K)*P),p.add(D),m.set(0,w(K),T(K)),u.push([p.clone(),m.clone()])}u.push([_,c(0,1,0)]);let z=Math.sin(N/2)*P*2,k=u.length-1,B=u[0][0].distanceTo(u[1][0]),V=B+z*n+u[k-1][0].distanceTo(u[k][0]);u[0].push(1);for(let dt=0;dt<=n;dt++)u[dt+1].push(1-(B+dt*z)/V);u[k].push(0);let q,W,H,[rt,it,ft]=u[0];for(let dt=1;dt<u.length;dt++)[q,W,H]=u[dt],a.push(v,rt.y,rt.z,v,q.y,q.z,b,rt.y,rt.z,b,rt.y,rt.z,v,q.y,q.z,b,q.y,q.z),o.push(0,it.y,it.z,0,W.y,W.z,0,it.y,it.z,0,it.y,it.z,0,W.y,W.z,0,W.y,W.z),l.push(0,ft,0,H,1,ft,1,ft,0,H,1,H),[rt,it,ft]=[q,W,H];this.setAttribute("position",new me(a,3)),this.setAttribute("normal",new me(o,3)),this.setAttribute("uv",new me(l,2))}}}),Rj=U(()=>{Am(),wm(),CW=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 ps?t.shape:new ps,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:h,extrusionVersion:u}=t.parameters,d=t.shape,c=.5*e,p=.5*i,m=a*Math.PI/360/s,f=Math.PI/2*3*-1,g=c*r/100,y=p*r/100;if(s===3&&r===50){m=2*Math.PI/s;for(let b=0;b<s;b++){let _=m*b,x=0+Math.sin(_)*c,S=0+Math.cos(_)*p;d.addPoint(d.createPoint(x,S))}}else for(let b=0;b<s;b++){let _=0+Math.cos(f)*c,x=0+Math.sin(f)*p;d.addPoint(d.createPoint(_,x)),f+=m,_=0+Math.cos(f)*g,x=0+Math.sin(f)*y,d.addPoint(d.createPoint(_,x)),f+=m}d.isClosed=!0;for(let b=0,_=d.points.length;b<_;b++)d.points[b].roundness=n;d.roundness=n,d.update();let v=Cm.create({shape:d,parameters:{roundness:n,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h,extrusionVersion:u}});return Object.assign(v,{userData:{...t,type:"StarGeometry"}})}}}),pZ=U(()=>{ot(),ayt=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 Rc(e,i);return Object.assign(r,{userData:{...t,type:"TextFrameGeometry"}})}}}),mZ=U(()=>{ot(),ZS(),oyt=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,h=function(u,d,c,p,m,f,g,y,v,b,_){[d,c]=[c,d],g=d/2;let x=zt.clamp(m/360,0,1);if(x===0){let S=new fe;return S.setAttribute("position",new me([],3)),S}return x===1&&(b=0),new fj(!0,u,d,c,p,x,f,g,0,v,b,_)}(e,i,r,.5*e,a,n,0,0,s,o,l);return h.scale(1,i/e,1),Object.assign(h,{userData:{...t,type:"TorusGeometry"}})}}}),fZ=U(()=>{ot(),lyt=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 uU(o,i,r,s,n,a);return Object.assign(l,{userData:{...t,type:"TorusKnotGeometry"}})}}}),gZ=U(()=>{Am(),wm(),hyt=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 ps?t.shape:new ps,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,extrusionVersion:l}=t.parameters,h=t.shape,u=.5*e,d=.5*i;o?(h.addPoint(h.createPoint(-u,d)),h.addPoint(h.createPoint(u,-d)),h.addPoint(h.createPoint(-u,-d))):(h.addPoint(h.createPoint(0,d)),h.addPoint(h.createPoint(u,-d)),h.addPoint(h.createPoint(-u,-d))),h.isClosed=!0;for(let p=0,m=h.points.length;p<m;p++)h.points[p].roundness=r;h.roundness=r,h.update();let c=Cm.create({shape:h,parameters:{roundness:r,depth:s,extrudeBevelSize:n,extrudeBevelSegments:a,extrusionVersion:l}});return Object.assign(c,{userData:{...t,type:"TriangleGeometry"}})}}}),GCt=U(()=>{ot()}),WCt=U(()=>{ot(),new Zn,new bt,new mc,new E,new E,new E,new E});function yZ(){let t=new fe;return t.setAttribute("position",new ve(new Float32Array([]),3)),t.setIndex(new ve(new Uint16Array([]),1)),t}var vZ,Dj,uyt=U(()=>{dn(),De(),wT(),ot(),bT(),Am(),wm(),lb(),vZ=yZ().attributes,Dj=class extends fe{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,vZ),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:h,fontSize:u,extrusionVersion:d}=t,c=Pa.getDisplayedValue(l),p=function(S,w,T,C){let M=typeof S.width=="string"?Number(C.getVariable(S.width)):S.width,A=[""],P="";for(let O of T)P+=O,O===" "||O===`
|
|
386
386
|
`?(A[A.length-1]+=P,P="",O===`
|
|
387
|
-
`&&A.push("")):w.getTextWidth(A[A.length-1]+P,S)>M&&(A[A.length-1].length&&A.push(""),w.getTextWidth(A[A.length-1]+P,S)>M&&(P.length===1?(A[A.length-1]+=P,P=""):(A[A.length-1]+=P.slice(0,-1),P=P[P.length-1],A.push(""))));return A[A.length-1]+=P,A}(t,i,h===2?c.toUpperCase():h===3?c.toLowerCase():c,e),{shapes:m,charWidths:f,charCoords:g}=i.generateShapes(p,t,e),y=.5*(typeof r=="number"?r:Number(e.getVariable(r))),v=.5*(typeof s=="number"?s:Number(e.getVariable(s))),b=m.map(S=>new ps().fromShape(S,!0));this.vectorShapes=b;let _=b.map(S=>Cm.create({shape:S,parameters:{depth:n,extrudeBevelSegments:o,extrudeBevelSize:a,uvPitch:d===1?void 0:u,extrusionVersion:d,windingRule:n<=0?ns.NONZERO:ns.ODD,subdivisions:this.isLowResolution&&n>0?1:12}})),x=_.length?Ig(_):yZ();x.translate(-y,v,0),this.dispose(),this.wrappedText=p,this.charCoords=g,this.charWidths=f,this.deleteAttribute("extrudeNormal"),Object.entries(x.attributes).forEach(([S,w])=>{this.setAttribute(S,w)}),this.setIndex(x.index),this.adoptNearSide(_,n),this.computeBoundingSphere()}adoptNearSide(t,e){this._depth=e;let i=0,r=0,s=0;for(let o of t){let l=o,h=l._nearSide;if(h===void 0||h.length===0)return this._nearSide=new Uint8Array(0),this._effectiveBevel=0,void(this._vScale=0);i+=h.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&&ev(this._effectiveBevel,t)&&ev(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 h=o[l];h!==0&&(r[3*l+2]+=e,h===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=qa(new fe,Dj.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 qCt(t){if(!Oj)return bZ||(bZ=async function(){let e=t??"https://cdn.spline.design/@splinetool/runtime@2.0.204/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});dyt(a),Oj=!0}())}var dyt,EW,Oj,bZ,SD=U(()=>{EW=new Promise(t=>{dyt=t}),Oj=!1});function SN(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 h=t.attributes[l],u=e.attributes[l];if(h===void 0||h.isInterleavedBufferAttribute===!0||u.isInterleavedBufferAttribute===!0||h.itemSize!==u.itemSize||h.normalized!==u.normalized||h.array.constructor!==u.array.constructor||h.array.length!==u.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,h=n.array.constructor;if(l!==h){if(l!==Uint32Array||h!==Uint16Array)return!1;a=!0}}if(t.groups.length!==e.groups.length)return!1;for(let l=0;l<e.groups.length;l++){let h=t.groups[l],u=e.groups[l];if(h.start!==u.start||h.count!==u.count||h.materialIndex!==u.materialIndex)return!1}for(let l of r){let h=t.attributes[l],u=e.attributes[l];h.array.set(u.array),h.needsUpdate=!0}let o=t.takeDepthStateFrom;if(typeof o=="function"&&o.call(t,e),s!==null&&n!==null){if(a){let l=s.array,h=n.array;for(let u=0,d=h.length;u<d;u++){let c=h[u];l[u]=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 Ij(t,e,i,r){let s,n,a,o=t.position.array,l=t.normal.array,h=cyt.makeScale(e,i,r).invert().elements;for(let u=0,d=o.length;u<d;u+=3)o[u]*=e,o[u+1]*=i,o[u+2]*=r,s=l[u],n=l[u+1],a=l[u+2],l[u]=h[0]*s+h[4]*n+h[8]*a,l[u+1]=h[1]*s+h[5]*n+h[9]*a,l[u+2]=h[2]*s+h[6]*n+h[10]*a;t.position.needsUpdate=!0,t.normal.needsUpdate=!0}var cyt,pyt=U(()=>{ot(),cyt=new bt});function Nj(t){let e=Number(t);return Number.isInteger(e)&&e>=0&&String(e)===t?e:-1}function oA(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=Nj(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 TN(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=>Nj(l)===-1),r=0;for(let l of e){let h=Nj(l);h>=r&&(r=h+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 myt(t){let e=Object.keys(t);return e.length===1&&e[0]==="subdivisions"}function PW(t,e){let i=e?e.count:t.count,r=0,s=1e4,n=new Map,a=new Uint32Array(i),o=[];for(let u=0;u<i;u++){let d=e?e.getX(u):u,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[u]=_}let l=[],h=[];for(let u=0;u<a.length;u+=3)a[u]===a[u+1]||a[u]===a[u+2]||a[u+1]===a[u+2]||(l.push(a[u],a[u+1],a[u+2]),h.push(e?e.getX(u):u,e?e.getX(u+1):u+1,e?e.getX(u+2):u+2));return{positions:o,triIndices:l,triOriginals:h}}var x_,hf,Ie,MN,AN,CN,cs,w_,lA,hA,uA,Bj,fR,hb=U(()=>{ot(),SD(),De(),TD(),pyt(),ZS(),x_=new dr,hf=new E,EW.then(t=>{Ie=t}),MN=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),AN=new Uint32Array([0,1,2,3]),CN=new Uint8Array([4]),cs=class extends fe{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=fm.div(e.map(a=>typeof a=="number"?a:0),i);if(r.every(a=>a===1))return;this.subdividedGeometry&&Ij(this.subdividedGeometry.attributes,...r),this.originalGeometry&&Ij(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(hf.fromArray(r));let n=hf.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=cs.allocate(t),i=cs.buildRefined(s,t.subdivisions,e)}catch(n){console.error(n,t)}finally{s&&cs.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}=cs.build(this.data,void 0,!this.flatShading,void 0))}catch{t=new Yh(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&&(cs.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let t=this.originalGeometry;t.boundingSphere===null&&(t.boundingSphere=new Zn,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=t.boundingSphere));let e=t.attributes.position,i=t.boundingSphere.center;x_.setFromBufferAttribute(e),x_.getCenter(i),t.boundingSphere.radius=i.distanceTo(x_.max),isNaN(t.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),x_.getSize(hf);let r={width:hf.x,height:hf.y,depth:hf.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=cs.allocate(t,r)}catch(l){console.error(l,t),s=cs.allocate({positionWASM:MN,indexWASM:AN,verticesPerFaceWASM:CN},r)}Ie.set_destination_refinement_level(s,0);let o=cs.buildLevel(s,!0,a);return n=t.subdivisions>0?cs.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),cs.buildLevel(t,!1,i)??null}catch{try{return Ie.set_destination_refinement_level(t,e-1),cs.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:om(t,i,!1,e);r=e0t(t)?s.getClosedTorusIndicesForBooleanOrSubdiv():s.getIndex();let n,{positions:a,triIndices:o,triOriginals:l}=PW(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:h,verticesPerFace:u,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 C=g[T];_.push(b.getX(C),b.getY(C))}};if(m.userData.shape!==void 0&&m.userData.parameters.depth===0&&m.userData.shape.shapeHoles.length===0){let T=m.userData.shape.extractShapePointsToFlatArray([]),C=m.userData.parameters.spikes;if(m.userData.type==="EllipseGeometry"&&C<=24&&C%4==0&&m.userData.parameters.angle>=360){let P=T.length/2/C;T=T.filter((O,D)=>Math.floor(D/2)%P===0)}let M=0;for(let P=0;P<T.length;P+=2)M+=(T[P]-T[(P===0?T.length:P)-2])*(T[P+1]+T[(P===0?T.length:P)-1]);c.length=0;let A=0;if(M<0)for(let P=0;P<T.length;P+=2)c.push(T[P],T[P+1],0),y.push(A++);else for(let P=T.length-2;P>=0;P-=2)c.push(T[P],T[P+1],0),y.push(A++);return v.push(A),{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]){w_.set(c[3*p[w]],c[3*p[w]+1],c[3*p[w]+2]),lA.set(c[3*p[w+1]],c[3*p[w+1]+1],c[3*p[w+1]+2]),hA.set(c[3*p[w+4]],c[3*p[w+4]+1],c[3*p[w+4]+2]),uA.set(c[3*p[w+5]],c[3*p[w+5]+1],c[3*p[w+5]+2]),lA.sub(w_).normalize(),hA.sub(w_).normalize(),uA.sub(w_).normalize();let T=lA.cross(hA).dot(uA),C=w;Math.abs(T)>.005||f&&f.some((M,A)=>A%2!=1&&C>=f[A]&&C<f[A+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=[],C=[],M=0;for(let A=0,P=0;A<c.length;A+=3,P++)c[A+2]===0&&(T.push(P),M++),c[A+2]===S&&C.push(P);if(m.userData.parameters.extrudeBevelSize===0){let A=C[0];C[0]=C[1],C[1]=A}T.reverse(),y.push(...T,...C),v.push(M,M),_=void 0}return{indices:y,verticesPerFace:v,uvs:_}}(a,o,s,n,l);return{positions:a,indices:h,verticesPerFace:u,uvs:d}}static allocate(t,e){let i,r,s,n=[],a=[],o=oA(t.positionWASM),l=oA(t.indexWASM),h=oA(t.verticesPerFaceWASM);if(o&&o.length>0){if(!l?.length||!h?.length)throw new Error(`SubdivGeometry.allocate: unusable cage topology \u2014 positionWASM ${TN(t.positionWASM)}, indexWASM ${TN(t.indexWASM)}, verticesPerFaceWASM ${TN(t.verticesPerFaceWASM)}`);i=o,r=l,s=h;let w=oA(t.uvWASM);Ie.alloc_subdivision_surface_uvs&&w&&w.length===2*r.length&&(a=w)}else i=MN,r=AN,s=CN;let u=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,u,y+g,d,y+g+r.length*Uint32Array.BYTES_PER_ELEMENT,c,x,a.length,v.elements):Ie.alloc_subdivision_surface_uvs(y,u,y+g,d,y+g+r.length*Uint32Array.BYTES_PER_ELEMENT,c,x,a.length):v?Ie.alloc_subdivision_surface2(y,u,y+g,d,y+g+r.length*Uint32Array.BYTES_PER_ELEMENT,c,v.elements):Ie.alloc_subdivision_surface(y,u,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),h=0,u=Ie.HEAPU32[o[h]>>2],d=Ie.HEAPF32.subarray(u>>2,(u>>2)+l[h]);h++;let c=Ie.HEAPU32[o[h]>>2],p=Ie.HEAPF32.subarray(c>>2,(c>>2)+l[h]);h++;let m=Ie.HEAPU32[o[h]>>2],f=Ie.HEAPU32.subarray(m>>2,(m>>2)+l[h]);h++;let g,y=Ie.HEAPU32[o[h]>>2],v=Ie.HEAPU32.subarray(y>>2,(y>>2)+l[h]);if(h++,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 fe;if(_.setIndex(new pm(v,1)),_.setAttribute("position",new me(d,3)),_.setAttribute("normal",new me(p,3)),g&&_.setAttribute("uv",new me(g,2)),e){_.setAttribute("faceMap",new pm(f,1));let x=new Float32Array(p.length/3*4).fill(0);_.setAttribute("color",new ve(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 h=Ie.HEAPU32[s[a]>>2],u=Ie.HEAPU32.subarray(h>>2,(h>>2)+n[a]);if(e===void 0){let d=new fe;d.setAttribute("position",new me(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 ve(c,3)),d.setIndex(new pm(u,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],h=new Float32Array(Ie.HEAPF32.subarray(l>>2,(l>>2)+a[o]));o++;let u=Ie.HEAPU32[n[o]>>2],d=new Uint32Array(Ie.HEAPU32.subarray(u>>2,(u>>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:h,indices:d,verticesPerFace:m,uvs:c}}},w_=new E,lA=new E,hA=new E,uA=new E}),fyt=U(()=>{VK(),zK(),r5(),LK(),o5(),ZS(),sZ(),nZ(),aZ(),Pj(),hZ(),l5(),uZ(),dZ(),cZ(),Rj(),pZ(),mZ(),fZ(),gZ(),wm(),Oi(),VK(),zK(),r5(),LK(),o5(),GCt(),ZS(),sZ(),nZ(),aZ(),Pj(),hZ(),l5(),uZ(),dZ(),cZ(),Rj(),pZ(),mZ(),fZ(),gZ(),wm(),WCt(),U0t(),uyt(),hb(),SD(),_D(),lb(),Bj={ConeGeometry:w0t,CubeGeometry:S0t,CylinderGeometry:_W,DodecahedronGeometry:T0t,EllipseGeometry:xD,HelixGeometry:i0t,IcosahedronGeometry:K0t,LatheGeometry:Z0t,NonParametricGeometry:J0t,PolygonGeometry:AW,PyramidGeometry:tyt,RectangleGeometry:wD,SphereGeometry:ryt,PlaneGeometry:syt,BackdropGeometry:nyt,StarGeometry:CW,TextFrameGeometry:ayt,TorusGeometry:oyt,TorusKnotGeometry:lyt,TriangleGeometry:hyt,VectorGeometry:Cm},fR=t=>{let e=Bj[t.type]??qgt(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 om(t,e,i,r){let s,n,a;t.type==="PathGeometry"?(n={...t,extrusion:{...t.extrusion}},a=[[],["extrusion"]]):(n={...t},a=[[]]);for(let h of a){let u=n;for(let d of h)u=u[d];for(s in u){let d=u[s];LU(d)&&!gyt.includes(s)&&(u[s]=e.getVariable(d,[r.uuid,"geometry",...h,s]),LU(u[s])&&(u[s]=1))}}let o,l={parameters:n,type:n.type};if(n.type==="PathGeometry"){l.path=n.path;let h=r.profileShape;h!==void 0&&(l.shapeData=h),l.ownerId=r.uuid}else if(n.type==="VectorGeometry"){let h=ps.createFromState(n.shape,n.width,n.height);l.shape=h,l.ownerId=r.uuid}else if(n.type==="NonParametricGeometry"){if(n.data.groups&&n.data.groups?.forEach(h=>h.materialIndex=Math.max(h.materialIndex??0,0)),l.geometry=new OG().parse(n),l.geometry.groups.length===0){let h=l.geometry;h.addGroup(0,Math.max(h.getIndex()?.count??0,h.getAttribute("position").count),0)}}else{if(n.type==="SubdivGeometry"){let h=new cs(n,i);return h.data=t,h}if(n.type==="TextGeometry"||n.type==="InputGeometry"){let h=qgt(n.type);if(h)return h.create(n,e);On("text",`a ${n.type}`);let u=ps.createFromState(jv.defaultData(),100,100);return fR({...n,shape:u,type:"VectorGeometry"})}if(n.type==="UIGeometry")return wD.create({parameters:{width:n.width,height:n.height,cornerRadius:n.cornerRadius,cornerType:n.cornerType}})}try{o=fR(l)}catch(h){console.error(h),console.error(`Error generating geometry with inputs: ${l}`);let u=ps.createFromState(jv.defaultData(),100,100);l.shape=u,l.type="VectorGeometry",o=fR(l)}return o}var gyt,TD=U(()=>{De(),ot(),fyt(),Oi(),l5(),Am(),hb(),gyt=["font"]});function kj(t){switch(typeof t){case"number":return Number.isFinite(t)?JSON.stringify(t):void 0;case"boolean":return JSON.stringify(t);case"string":return LU(t)?void 0:JSON.stringify(t);case"object":{if(t===null)return"null";if(Array.isArray(t)){let s="[";for(let n=0;n<t.length;n++){let a=kj(t[n]);if(a===void 0)return;s+=(n>0?",":"")+a}return s+"]"}let e=t,i="{",r=!0;for(let s of Object.keys(e).sort()){if(e[s]===void 0)continue;let n=kj(e[s]);if(n===void 0)return;i+=`${r?"":","}${JSON.stringify(s)}:${n}`,r=!1}return i+"}"}default:return}}var yyt,_Z,Vj,HCt=U(()=>{De(),yyt=new Set(["CubeGeometry","SphereGeometry","CylinderGeometry","ConeGeometry","TorusGeometry","TorusKnotGeometry","IcosahedronGeometry","DodecahedronGeometry","PyramidGeometry","PlaneGeometry","BackdropGeometry","HelixGeometry"])}),$Ct=U(()=>{TD(),HCt(),_Z=class{constructor(){this.objects=new Map,this.refs=new Map,this.sharedByKey=new WeakSet,this.unreachable=new Set}resolveObject(t,e,i){return this.createObject(t,e,i)}onObjectDisposed(t){}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.resolveObject(t,e,i),this.objects.set(t,r),this.retain(r)):(this.sharedByKey.add(r),r.isShared=!0),r}forceDelete(t){let e=this.objects.get(t);e&&(this.objects.delete(t),this.release(e))}adopt(t,e){this.replace(t,e),this.retain(e)}mutateIfUnique(t,e){let i=this.objects.get(t);if(i&&i.isShared!==!0)return this.objects.delete(t),this.replace(e,i),i}replace(t,e){let i=this.objects.get(t);this.objects.set(t,e),i!==void 0&&i!==e&&this.release(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=>{let e=this.objects.get(t);this.objects.delete(t),this.release(e)}),this.unreachable.clear()}dispose(){new Set(this.objects.values()).forEach(t=>{this.disposeObject(t),this.onObjectDisposed(t)}),this.objects.clear(),this.refs.clear()}retain(t){let e=(this.refs.get(t)??0)+1;this.refs.set(t,e),e>1&&(t.isShared=!0)}release(t){let e=(this.refs.get(t)??1)-1;if(e>0)return this.refs.set(t,e),void(e===1&&!this.sharedByKey.has(t)&&(t.isShared=!1));this.refs.delete(t),this.disposeObject(t),this.onObjectDisposed(t)}},Vj=class extends _Z{constructor(t){super(),this.flatShading=t,this.dedupeByValue=!1,this.byValue=new Map,this.valueKeyOf=new Map}disposeObject(t){t.dispose()}createObject(t,e,i){let r=om(t,e,this.flatShading,i);return r.computeBoundingSphere(),r}resolveObject(t,e,i){let r=this.dedupeByValue?function(n,a,o){if(!yyt.has(n.type))return;let l=n;if(l.shapeBlendNode!=null||o.isTransientGeometryKey(n))return;let h=a.material;if(h===void 0||Array.isArray(h))return;let u=h;if(typeof u.getLayersOfType!="function"||u.getLayersOfType("outline").length>0||u.getLayersOfType("cavity").length>0)return;let d=n.type;for(let c of Object.keys(l).sort()){let p=l[c];if(p===void 0||c==="type")continue;let m=kj(p);if(m===void 0)return;d+=`|${c}=${m}`}return d}(t,i,e):void 0;if(r!==void 0){let n=this.byValue.get(r);if(n!==void 0)return n}let s=this.createObject(t,e,i);return r!==void 0&&(this.byValue.set(r,s),this.valueKeyOf.set(s,r)),s}mutateIfUnique(t,e){let i=super.mutateIfUnique(t,e);return i!==void 0&&this.forgetValue(i),i}onObjectDisposed(t){this.forgetValue(t)}forgetValue(t){let e=this.valueKeyOf.get(t);e!==void 0&&(this.valueKeyOf.delete(t),this.byValue.get(e)===t&&this.byValue.delete(e))}}});function h5(){return TT}function vyt(){if(TT==="webgpu"){if(Lj!==void 0)return Lj;Fj||(Fj=!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(SZ===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 SZ}function byt(t,e){return vyt().createRootMaterial(t,e)}function xZ(t,e,i){return vyt().createSharedMaterial(t,e,i)}function wZ(t){return t.getLayersOfType===void 0&&Object.assign(t,{layers:[],getLayersOfType:()=>[],hasAO:!1,assetsLoaded:()=>!0}),t}function zj(){return _yt}var TT,Lj,SZ,Fj,Uj,_yt,xyt,Em=U(()=>{TT="webgl",Fj=!1}),XCt=U(()=>{xyt={markNeedsUpdateRendererDirty:()=>{}}});function TZ(t){return t.data.type!=="displace"&&!!t.data.isMask}function lm(t,e){let i=0;if(!t.layers||t.layers.length===0)return!1;let r=t.layers?.find(n=>n.data.type==="light");if(r){let n=r.data,a=Number(e.getVariable(n.alphaOverride));if((typeof n.alphaOverride=="string"?a/100:n.alphaOverride)<1)return!0}let s=t.layers;for(let n=0;n<s.length;n++){let a=s[n];if(!TZ(a)){if(n>0&&TZ(s[n-1])){if(a.data.type==="light"&&!a.data.visible)return!0;continue}if(a.data.type!=="displace"&&"alpha"in a.data&&a.data.type!=="light"&&a.data.type!=="fresnel"&&a.data.type!=="cavity"&&a.data.type!=="dust"&&a.data.type!=="texture"&&a.data.type!=="matcap"&&a.data.type!=="rainbow"&&a.data.type!=="outline"&&a.data.type!=="pattern"){let o=a.data.visible?a.data.alpha:0;if(typeof o=="string"&&(o=Math.max(0,Math.min(1,Number(e.getVariable(o)??100)/100))),o===1&&a.data.type==="depth"||a.data.type==="gradient"){for(let l of a.data.colors)if(l[3]<1){o=l[3];break}}else if(o===1&&a.data.type==="noise"){let l=e.color(a.data.colorA).a,h=e.color(a.data.colorB).a,u=e.color(a.data.colorC).a,d=e.color(a.data.colorD).a,c=Math.min(l,Math.min(h,Math.min(u,d)));c<1&&(o=c)}i+=(1-i)*o}}}return i<1}var MD=U(()=>{});function _v(t){return typeof t=="string"||typeof t=="number"&&t!==0}var Wv,as,wyt,Syt,MT,Tyt,MZ,AZ,Za,ub=U(()=>{ot(),Wv=(t,e,i)=>Math.max(0,Math.min(1,Number(e.getVariable(typeof t=="number"?100*t:t,i)??100)/100))??1,as=(t,e,i)=>typeof t=="number"?t:e.getVariable(t,i),wyt=(t,e)=>(t||(t=new E),t.x=as(t.x,e)??0,t.y=as(t.y,e)??0,t.z=as(t.z,e)??0,t),Syt=(t,e)=>(t||(t=new Y),t.x=as(t.x,e)??0,t.y=as(t.y,e)??0,t),MT={noise:["noiseType"],texture:["projection","axis","projectionAxis","uvChannel","side"],video:["projection","axis","projectionAxis","uvChannel","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"]},Tyt={depth:["colors"],gradient:["colors","steps"],toon:["colors","steps"]}}),db=U(()=>{ot(),ob(),Jr(),MZ=class extends yD(ur){},AZ=t=>t.type==="Mesh",Za=class extends MZ{constructor(t){super(),this.object=t,this.isClone=!0,this.matrixAutoUpdate=!1}raycast(t,e){}expand(){let t=0,e=this.object.entityChildren(t);for(;e;){let i=this.children[t];(!(i instanceof Za)||i.object!==e)&&(i=new Za(e),this._replaceChildAt(t,i),i.matrixWorldNeedsUpdate=!0,i.matrixAutoUpdate=!1,i.matrix=e.matrix,i.shearMatrix=e.shearMatrix,i.pivotMatrix=e.pivotMatrix),i.expand(),t+=1,e=this.object.entityChildren(t)}for(let i of this.object.children){if(!nm(i)||i.object.parent!==this.object)continue;let r=this.children[t];r?.source!==i&&(r=i.createCopy(),this._replaceChildAt(t,r)),r.expand(),t+=1}for(;this.children.length>t;)this.remove(this.children[t]);this.pivotMatrix=this.object.pivotMatrix}_replaceChildAt(t,e){let i=this.children[t];i&&this.remove(i),this.add(e),this.children.splice(t,0,this.children.pop())}get visible(){let t=this.parent,e=nm(t)&&t.object===this.object;return(!e||!t.instancingActive&&!t.insideBoolean)&&(this.playModeVisible!==void 0?this.playModeVisible:this.object.visible||e&&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 AZ(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 CZ(){return RW}var RW,DW,OW=U(()=>{RW=null,DW=null});function jj(t){return"variable_"+t}var EN,PN,RN,EZ,DN,PZ,ON,RZ,u5,IW=U(()=>{De(),_Ct(),y0t(),v0t(),Nc(),yW(),bW(),$Ct(),Em(),m0t(),XCt(),MD(),ub(),yo(),db(),Li(),ot(),OW(),Oi(),EN=new bt,PN=new E,RN=new we,EZ=new E,DN=new zi,PZ=class extends u0t{constructor(t){super(),this.shared=t}create(t){return new gW(t,this.shared)}},ON=new Set,(u5=RZ=class{constructor(t,e={},i=!0,r=!1){if(this.data=t,this.needsJitter=i,this.enableLocalStorageForPersistentVariables=r,this.geometryCache=new Vj(!0),this.geometryCache2=new Vj(!1),this.imageHolderCache=new PZ(this),this.thisContext={scene:xyt,shared:this},this.deletedImage=new Sg(L4.emptyImage,this),this.deletedVideo=new Sg(F4.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=xZ(Qr.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=Qr.withRepairedLayers(e),this.materials[t]){let i=this.materials[t];i.reset(e,this.thisContext),i.dispose()}else{let i=xZ(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):byt(Qr.withRepairedLayers(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 Sg(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 Sg(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 h=l.getTexture(a.texture.wrapping??(a.type==="texture"?1e3:1001),a.texture.minFilter??1008,a.texture.magFilter??1006),u=l.img;return{texture:h,width:u?.width??0,height:u?.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 Sg(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 vj(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 tv)return e;{let i=new tv({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 tv&&e.dispose(),delete this.audios[t])}addFont(t,e){let i=vW;i!==null?(this.fonts[t]=new i(e),this.fonts[t].loadingPromise.then(()=>this.requestRender())):On("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 tv&&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(jj(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(jj(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,h={scene:r,shared:this},u=a.slice(2);r.traverseMaterial(c=>{let p=c.root??c;p.uuid===o&&p.onVariableUpdate(u,l,h)});let d=this.materials[o];d&&d.onVariableUpdate(u,l,h)}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*zt.DEG2RAD:o[a[a.length-1]]=i}if(o=r.find(a[0]),o.type==="ParticleEmitter"&&o.updateVariableState(i,a),vi.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 h=l.dataPatched;l.chooseGeoemtryCache(this).forceDelete(h.geometry),l.createGeometryDelayed(this.entityOpContext),l.onVariableUpdate(!0),l.invalidateDownstreamBooleanData(),l.instances.forEach(u=>{let d=u.dataPatched;u.chooseGeoemtryCache(this).forceDelete(d.geometry),u.createGeometryDelayed(this.entityOpContext),u.onVariableUpdate(!0),u.invalidateDownstreamBooleanData()})}else a[1]==="morphTargetInfluences"&&o.updateMorphInfluences(a[2],i)}}return s&&r.markShadowsDirty(),this.requestRender(),!0}isTransientGeometryKey(t){return this.transientGeometryKeys.has(t)}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=h=>h.toLowerCase().replace(/[\s_.-]+/g,""),a=new Map;for(let h of Object.keys(s))a.set(n(h),h);let o={};for(let[h,u]of Object.entries(e??{})){let d=a.get(n(h));if(d===void 0||d==="type"||d==="font"||d==="shape"||d==="path"||d==="data")continue;if(d==="text"){(typeof u=="string"||typeof u=="number")&&(o[d]={textValue:String(u)});continue}let c=s[d];typeof u=="number"&&isFinite(u)&&(typeof c=="number"||typeof c=="string")&&(o[d]=u)}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>RZ.MAX_TRANSIENT_VERTICES)return!1;let a,o,l,h=n instanceof Float32Array?n:Float32Array.from(n),u=h.length/3;if(e.normals!==void 0){if(e.normals.length!==h.length)return!1;a=e.normals instanceof Float32Array?e.normals:Float32Array.from(e.normals)}if(e.uvs!==void 0){if(e.uvs.length!==2*u)return!1;o=e.uvs instanceof Float32Array?e.uvs:Float32Array.from(e.uvs)}if(e.indices!==void 0){let x=u>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]>=u)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(u!==w)return function(T,C){let M=`${T}/${C}`;ON.has(M)||(ON.add(M),console.warn(`[spline] updateObject: ignoring a geometry update of ${T} vertices for a mesh that holds ${C}. 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.`))}(u,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<h.length;x+=3){let S=h[x],w=h[x+1],T=h[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(h,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 h=e[l],u=s[l];if(h==null){u.transformOverride!==void 0&&(u.transformOverride=void 0,a=!0);continue}let d=u.transformOverride??{position:[u.position.x,u.position.y,u.position.z],rotation:[u.rotation.x,u.rotation.y,u.rotation.z],scale:[u.scale.x,u.scale.y,u.scale.z]};h.position&&(typeof h.position.x=="number"&&(d.position[0]=h.position.x),typeof h.position.y=="number"&&(d.position[1]=h.position.y),typeof h.position.z=="number"&&(d.position[2]=h.position.z)),h.rotation&&(typeof h.rotation.x=="number"&&(d.rotation[0]=h.rotation.x*n),typeof h.rotation.y=="number"&&(d.rotation[1]=h.rotation.y*n),typeof h.rotation.z=="number"&&(d.rotation[2]=h.rotation.z*n)),h.scale&&(typeof h.scale.x=="number"&&(d.scale[0]=h.scale.x),typeof h.scale.y=="number"&&(d.scale[1]=h.scale.y),typeof h.scale.z=="number"&&(d.scale[2]=h.scale.z)),u.transformOverride=d,u.position.fromArray(d.position),u.rotation.fromArray(d.rotation),u.scale.fromArray(d.scale),u.updateMatrix(),u.hasNonUniformScale&&(u.updateMatrixWorld(),u.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 Za(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.shearMatrix.copy(t.shearMatrix),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 h of Array.isArray(i)?i:[i]){let u=h.root??h;u&&Array.isArray(u.layers)&&u.data&&!r.includes(u)&&r.push(u)}if(r.length===0)return!1;let s={scene:this.entityOpContext.scene,shared:this},n=h=>h.toLowerCase().replace(/[\s_.-]+/g,""),a=h=>{if(typeof h=="string"){let u=new Dr(1,1,1,1);try{u.set(h)}catch{return null}return{r:u.r,g:u.g,b:u.b,a:void 0}}if(h&&typeof h=="object"&&"r"in h){let u=h;if([u.r,u.g,u.b].some(c=>typeof c!="number"||!isFinite(c)))return null;let d=Math.max(u.r,u.g,u.b)>1?1/255:1;return{r:u.r*d,g:u.g*d,b:u.b*d,a:typeof u.a=="number"?Math.max(0,Math.min(u.a,1)):void 0}}return null},o=(h,u,d)=>{if(!h.hasValue(u))return!1;let c=h.getValue(u);if(!c||typeof c!="object"||!c.isColor)return!1;let p=d.a??(typeof c.a=="number"?c.a:1);return c instanceof vj?h.setValue(u,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 h of r){let u=h.data.layers??[],d=c=>h.layers.find(p=>p.uuid===c);if(e.color!==void 0){let c=a(e.color),p=u.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||lm(h.data,this);h.setTransparent?h.setTransparent(f,s.scene):h.transparent=f}}typeof e.alpha=="number"&&isFinite(e.alpha)&&(h.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"?u.find(y=>y.id===c.id):typeof c.index=="number"?u[c.index]:typeof c.type=="string"?u.find(y=>y.data.type===c.type):void 0,m=p&&d(p.id);if(!p||!m)continue;let f=MT[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))h.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)=>{h.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]}referencesMissingObject(t){return Array.isArray(t)&&t[0]!=="mouse"&&t[0]!=="raycast"&&this.entityOpContext.scene.find(t[0])===void 0}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(i===void 0)return;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?.(EN))return EN.decompose(PN,RN,EZ),t[1]==="position"?PN[t[2]]:(DN.setFromQuaternion(RN,i.rotation.order),DN[t[2]]*zt.RAD2DEG);for(let r=1;r<t.length;r++)i=i[t[r]];return t[1]==="rotation"&&(i*=zt.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(Qn.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(Qn.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=DW;return i===null?(On("ai-assistant","a voice-assistant integration"),!1):(this.openAIRealtime=i(e,t,this),!1)}{let i=CZ();return i===null?(On("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=CZ();return i===null?(On("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 u5(Zl.emptyData())});function d5(t){return a0t(t)||t?.isTSLNodeMaterial===!0}function DZ(t){return function(e){return e?.isClassicSharedMaterial===!0}(t)||t?.isTSLSharedMaterial===!0}function Myt(t){let e=t?.root;return DZ(t)||e!==void 0&&DZ(e)}var go,IN,NN,BN,OZ,kN,dd,IZ,NZ,S_,wr,NW=U(()=>{c0t()}),d0=U(()=>{De(),na(),Em(),NW(),Li(),dn(),go=class extends Ks{setMaterialOverride(t,e){this.materialOverride=wZ(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),tr(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&&go.disposeOneMaterial(n),this.material[Number(r)]=a}else if(tr(t.path,["material"])){let r=this.material;!Array.isArray(r)&&typeof r?.updateByOp=="function"&&"material"in e&&typeof e.material!="string"&&r.updateByOp(Qn.drop(t,1),e.material,i)}else if(tr(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(Qn.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=TT==="webgpu"&&Uj!==void 0?Uj:void 0;return r===void 0?null:wZ(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){d5(t)&&!Myt(t)&&t.nodeMaterialDispose()}disposeMaterial(){this.material&&mft(this.material).forEach(t=>{go.disposeOneMaterial(t)})}dispose(){this.disposeMaterial(),this.shadowCatcherMaterial?.dispose(),super.dispose()}}}),vo=U(()=>{De(),Li(),IW(),d0(),ot(),TD(),lb(),hb(),pyt(),IN=new E,NN=new Se,BN=new Se,OZ=new E,kN=new bt,dd=new gr,IZ=dd.geometry,NZ=dd.material,S_=new E,wr=class extends go{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 fe&&this.chooseGeoemtryCache(t).markAsReachable(this.dataPatched.geometry,this.geometryCreateDeleyed)}get builtSharedGeometry(){if(this.localGeometry===void 0)return this.geometryCreateDeleyed instanceof fe?this.geometryCreateDeleyed:void 0}get geometry(){if(this.localGeometry!==void 0)return this.localGeometry;if(this.geometryCreateDeleyed instanceof u5){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 G4.is2DParametricMesh(t.type)&&t.depth===0}get is2DType(){return G4.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),tr(t.path,["geometry"])&&this.updateByPatchedOpGeometry(Qn.drop(t,1),e.geometry,i)}removeInteractionGeometry(t){this.localGeometry?.dispose(),this.localGeometry=void 0}dispose(){var t;super.dispose(),t=this.uuid,a5.delete(t),this._posed=void 0}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=om(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,h=typeof s=="number"?s:1,u=typeof n=="number"?n:1;o.sxPrev!==void 0&&Ij(this.localGeometry.attributes,l/o.sxPrev,h/o.syPrev,u/o.szPrev),o.sxPrev=l,o.syPrev=h,o.szPrev=u}else if(!this.absorbDepthInteraction(t)){let r=om(i==="VectorGeometry"?W4.merge(this.data.geometry,t):{...this.data.geometry,...t},e,this.data.flatShading,this);this.localGeometry!==void 0&&this.supportsInPlaceGeometryUpdate(this.localGeometry)&&SN(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 cs&&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&&myt(t.props)&&this.geometryCreateDeleyed instanceof cs&&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 fe&&!(this.geometryCreateDeleyed instanceof cs)&&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=om(o,s,this.data.flatShading,this);SN(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 fe&&!(this.geometryCreateDeleyed instanceof cs)&&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=om(r,i,this.data.flatShading,this);return SN(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.posedGeometry()?.boundingBox;if(i)return i.getCenter(t),void i.getSize(e).multiplyScalar(.5);let r=this.geometry.userData.parameters;this.is2DType||this.isTextType?t.set(0,0,.5*r.depth):this.isNonParametric?(t.setScalar(0),this.geometry.boundingSphere&&t.copy(this.geometry.boundingSphere.center),e.set(r.width,r.height,r.depth??0).multiplyScalar(.5)):r.centerOffset?t.fromArray(r.centerOffset):t.setScalar(0),e.set(r.width,r.height,r.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()}rebindSkeleton(t){let e=this.dataPatched,i=e.bones?.map(t),r=this.isSkinnedMesh;if(!i?.length||i.some(s=>!s)||e.boneInverses?.length!==i.length?this.isSkinnedMesh=!1:(this.bindMatrix||(this.bindMatrix=new bt,this.bindMatrixInverse=new bt),this.bindMode=e.bindMode??"attached",e.bindMatrix&&this.bindMatrix.fromArray(e.bindMatrix),this.bind(new zS(i,e.boneInverses.map(s=>new bt().fromArray(s))),this.bindMatrix)),r!==this.isSkinnedMesh)for(let s of Array.isArray(this.material)?this.material:[this.material])s.needsUpdate=!0}normalizeSkinWeights(t){let e=new Se,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;NN.fromBufferAttribute(r.attributes.skinIndex,t),BN.fromBufferAttribute(r.attributes.skinWeight,t),IN.copy(e).applyMatrix4(this.bindMatrix),e.set(0,0,0);for(let s=0;s<4;s++){let n=BN.getComponent(s);if(n!==0){let a=NN.getComponent(s);kN.multiplyMatrices(i.bones[a].matrixWorld,i.boneInverses[a]),e.addScaledVector(OZ.copy(IN).applyMatrix4(kN),n)}}return e.applyMatrix4(this.bindMatrixInverse)}raycastDeformed(t,e){let i=this.posedGeometry();if(i===void 0)return!1;dd.geometry=i,dd.material=this.material,dd.matrixWorld.copy(this.matrixWorld);let r=e.length;dd.raycast(t,e);for(let s=r;s<e.length;s++)e[s].object=this;return dd.geometry=IZ,dd.material=NZ,!0}posedGeometry(){let t=this.skeleton;if(!this.isSkinnedMesh||t===void 0)return;let e=this.geometry,{position:i,skinIndex:r,skinWeight:s}=e.attributes;if(!i||!r||!s)return;let n=[...this.bindMatrix.elements,...this.bindMatrixInverse.elements,...this.morphTargetInfluences??[]];for(let d=0;d<t.bones.length;d++){let c=t.bones[d];if(!c||!t.boneInverses[d])return;n.push(...c.matrixWorld.elements)}let a=this._posed;if(a?.source===e&&a.version===i.version&&a.pose.length===n.length&&a.pose.every((d,c)=>d===n[c]))return a.geometry;let o=i.count,l=a?.geometry.attributes.position,h=l?.count===o?l:new ve(new Float32Array(3*o),3);for(let d=0;d<o;d++)this.boneTransform(d,this.getVertexPosition(d,S_)),h.setXYZ(d,S_.x,S_.y,S_.z);let u=new fe;u.setAttribute("position",h);for(let d of["normal","uv","uv1"]){let c=e.attributes[d];c&&u.setAttribute(d,c)}return u.setIndex(e.index),u.groups=e.groups,u.drawRange=e.drawRange,u.computeBoundingSphere(),u.computeBoundingBox(),this._posed={source:e,version:i.version,pose:n,geometry:u},u}}});function xv(t){if(Array.isArray(t.material)){for(let e of t.material)if(e.getLayersOfType("outline").length===0)return}else if(!a0t(t.material)||t.material.getLayersOfType("outline").length===0)return;t instanceof wr&&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 E;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 me(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]}`,h=new E(n[o],n[o+1],n[o+2]);i.has(l)?i.get(l)?.normals.push(h):i.set(l,{normals:[h],result:new E})}i.forEach((o,l)=>{for(let h of o.normals)o.result.add(h);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]}`,h=i.get(l)?.result;h&&(a[o]=h.x,a[o+1]=h.y,a[o+2]=h.z)}e.geometry.setAttribute("extrudeNormal",new me(a,3))}(t)}function VN(t){return Math.min(2047,Math.max(1,Math.round(2048*t)))/2048}function wv(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=[VN(zt.seededRandom(n)),VN(zt.seededRandom(n+1e4)),VN(zt.seededRandom(n+2e4))];for(let o=0;o<i.length;o++)s[o]=a[o%3];t.geometry.setAttribute("randomColor",new ve(s,3))}var AD=U(()=>{ot(),c0t(),vo()});function BZ(t){let e=!1;return t.scene.objects.traverse((i,r)=>{r.geometry?.type==="BooleanGeometry"&&(e=!0)}),e}function YCt(t,e){let i=t.cloner;return i!==void 0&&i.parent===e?i:void 0}function kZ(t,e,i,r){let s=16*(e.children.length+1);f2.length<s&&(f2=new Float32Array(s));let n=0,a=l=>{l.toArray(f2,16*n),n++},o=e.parameters.hideBase!==!0;o&&a(r),Gj.copy(t.matrix);for(let l of e.children)!am(l)||l.playModeVisible===!1||(Wj.copy(l.matrix).multiply(l.pivotMatrix),gR.multiplyMatrices(Gj,Wj),(!o||!gR.equals(r))&&a(gR));try{return n===0?0:function(l,h){return mW(e5().instanced_union(pW(l),h))}(i,f2.subarray(0,16*n))}finally{r0t(i)}}var cd,VZ,Gj,Wj,gR,f2,vm,AT=U(()=>{na(),ot(),_D(),AD(),d0(),Jr(),cd=new bt,VZ=new bt,Gj=new bt,Wj=new bt,gR=new bt,f2=new Float32Array(0),vm=class extends go{constructor(t,e,i){super(t,e),this.data=e,this.meshSetAddresses=[],this.needsTransformForDownstream=!1,this.geometry=new fe,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 vm&&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 Ks&&s.dataPatched.visible===!0&&s.geometry.attributes.position?.count>0&&s.geometry.drawRange.count>0&&s.booleanMeshSetAddress!==0){cd.copy(s.matrix).multiply(s.pivotMatrix);try{let n=YCt(s,this);if(s.booleanMeshSetAddress===-1){if((s.geometry.index??s.geometry.getAttribute("position")).count/3<15e5){let a=yCt(s.geometry,t===!0);s.booleanMeshSetAddress=n===void 0||a===-1?a:kZ(s,n,a,cd)}if(s.booleanMeshSetAddress===-1)return;n===void 0&&pN(s.booleanMeshSetAddress,cd),s.booleanMatrixInvOld.copy(cd).invert(),s.booleanWasTransformed=!1}else s instanceof vm&&s.needsTransformForDownstream===!0?(n===void 0?pN(s.booleanMeshSetAddress,cd):s.booleanMeshSetAddress=kZ(s,n,s.booleanMeshSetAddress,cd),s.needsTransformForDownstream=!1):s.booleanWasTransformed===!0&&(pN(s.booleanMeshSetAddress,VZ.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 fe,this.geometry.userData=r.userData,this.geometry.boundingSphere=r.boundingSphere,this.geometry.setAttribute("position",new me([],3))}return void this.geometry.setDrawRange(0,0)}if(t===!0)return function(r,s){let n=e5(),a=MK(r,s),o=n.mesh_topological_data(a),l=o.positions(),h=o.indices();return o.free(),a.free(),{positions:l,indices:h,verticesPerFace:new Uint8Array(h.length/3).fill(3)}}(this.meshSetAddresses,this.booleanOp);let i=this.geometry;i.dispose(),this.geometry=new fe,this.geometry.userData=i.userData,this.geometry.boundingSphere=i.boundingSphere;try{this.booleanMeshSetAddress=function(r,s,n,a){let o=e5(),l=MK(r,s),h=o.mesh_render_data(l,Math.max(a,0));if(n.setAttribute("position",new me(h.positions(),3)),n.setAttribute("normal",new me(h.normals(),3)),h.free(),n.boundingSphere===null&&(n.boundingSphere=new Zn),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 u=l.bounds();n.boundingSphere.center.set(u[0],u[1],u[2]),n.boundingSphere.radius=(u[3]**2+u[4]**2+u[5]**2)**.5,n.userData.parameters={width:2*u[3],height:2*u[4],depth:2*u[5]}}return mW(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,xv(this),wv(this)}dispose(){super.dispose(),this.geometry.dispose()}}});function KCt(t){return t.isPointLight?yR.PointLight:t.isSpotLight?yR.SpotLight:yR.DirectionalLight}function zZ(t){return t.isDirectionalLight?0:t.isSpotLight?1:2}var yR,mS,mg,c5,CD,Wh,Wu,p5,Ayt=U(()=>{yR={PointLight:1,SpotLight:3,DirectionalLight:3},mS=new WeakSet,mg=[]}),CT=U(()=>{ot(),Ayt(),yo(),u0(),(c5||(c5={})).is=function(t){return vi.is(t)&&t instanceof Hd},CD=(t,e)=>class extends h0(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&&(function(s){mS.delete(s)}(this),this.castShadow=i.shadows)}}}),Pm=U(()=>{ot(),AT(),na(),u0(),Wh=t=>t instanceof Ks,Wu=t=>t!==null&&t instanceof vm,p5=t=>mj.is(t)});function _a(t,e){return e.color(t)}function LZ(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,h,u=a;switch(e.format12h24h!=="24"&&(u=a%12,u===0&&(u=12)),i){case"HH:mm:ss":l=[u,o,r];break;case"HH:mm":l=[u,o];break;case"HH":l=[u],n=void 0;break;case"mm":l=[o],n=void 0;break;case"ss":l=[r],n=void 0;break;case"year":h=s.getFullYear();break;case"month":h=s.getMonth()+1;break;case"dayOfYear":h=Math.floor((s.getTime()-new Date(s.getFullYear(),0,0).getTime())/864e5);break;case"dayOfMonth":h=s.getDate();break;case"secondOfDay":h=60*a*60+60*o+r;break;default:console.error("Unknown time format",i),h=0}return l!==void 0?{textValue:l,suffix:n}:h}var qj,cb,BW=U(()=>{}),ZCt=U(()=>{ot(),_T(),xT(),qj=class extends sb(aft){constructor(t,e=15,i=10066329){super(t,e,i),this.object=t,this.added=!1,this.name=`DirectionalLightHelper: ${t.uuid}`}raycast(t,e){nb(this.object,qj.geometryHelper,t,e)}}}),ED=U(()=>{ot(),ZCt(),CT(),cb=class extends CD(US,qj){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 jS(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 jS&&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 kW(t){return t instanceof go&&t.needsAO&&!Dc(t)&&t.isDecalObject!==!0}function VW(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 zW(t){return t.getLayersOfType("reflection").filter(e=>e.data.visible).length}function QCt(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 JCt(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 FZ(t,e){let i={outline:!1,cavity:!1},r=t.layers.mask&PD,s=e.getLayersOfType("transmission"),n=e.getLayersOfType("outline"),a=zW(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,wv(t),xv(t)),s.length===0&&n.length===0&&o.length===0&&a===0&&t.layers.set(0),r&&t.layers.set(9),!r&&kW(t)&&t.layers.enable(5),VW(t),i}function UZ(t,e){if(!e.layers)return!1;let i=t.layers.mask&PD,r=!1,s=e.getLayersOfType("transmission").filter(l=>l.data.visible),n=e.getLayersOfType("outline").filter(l=>l.data.visible),a=zW(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&&kW(t)&&t.layers.enable(5),VW(t),r}function jZ(t,e){var i;if(!e.layers)return!1;let r=t.layers.mask&PD,s=!1,n=zW(e),a=e.getLayersOfType("transmission").filter(h=>h.data.visible),o=e.getLayersOfType("outline").filter(h=>h.data.visible),l=e.getLayersOfType("cavity").filter(h=>h.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&&kW(t)&&t.layers.enable(5),VW(t),s}function Hj(t,e,i,r=!1){let s=t.cloner;if(s){let n=null;if((t.raycast===gr.prototype.raycast||t.raycast===Ks.prototype.raycast)&&t.isSkinnedMesh!==!0){let a=t.geometry;a&&(a.boundingSphere===null&&a.computeBoundingSphere(),n=a.boundingSphere)}for(let a of s.children){if(n!==null&&($j.copy(n).applyMatrix4(a.matrixWorld),!e.ray.intersectsSphere($j)))continue;let o=Eyt.copy(a.matrixWorld).invert(),l=Pyt.copy(e.ray).applyMatrix4(o),h=t.matrixWorld;l.applyMatrix4(h);let u=Cyt;u.set(l.origin,l.direction),u.near=e.near,u.far=e.far,u.layers.mask=e.layers.mask;let d=u.intersectObject(t,!1);d.length>0&&i.push({...d[0],object:r?a:t})}}}var PD,Cyt,Eyt,Pyt,$j,dA,Ryt,zN,LN,FN,pb,Or,LW=U(()=>{Jr(),AD(),na(),d0(),ot(),PD=512,Cyt=new rD,Eyt=new bt,Pyt=new mc,$j=new Zn}),tEt=U(()=>{ot(),_T(),xT(),dA=class extends sb(sft){constructor(t,e=6710886){super(t,e),this.object=t,this.matrix=t.matrixWorld,this.name=`SpotLightHelper: ${t.uuid}`}raycast(t,e){nb(this.object,dA.geometryHelper,t,e)}update(){if(this.object!==void 0){let t=dA._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)}}},(Ryt=dA)._vector=new E}),RD=U(()=>{ot(),tEt(),CT(),zN=new E,LN=new E,FN=new we,pb=class extends CD(Wg,Ryt){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*zt.RAD2DEG*this.angle,r.aspect=1,r.near=100,r.far=2500;let s=new jS(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 jS&&e.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),LN.setFromMatrixPosition(this.matrixWorld),FN.setFromRotationMatrix(this.matrixWorld),zN.copy(this.up).applyQuaternion(FN).negate().multiplyScalar(this.distance),this.target.position.copy(LN).add(zN),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))}}}),rh=U(()=>{De(),Kh(),ot(),yo(),Nc(),BW(),pD(),ED(),Li(),Em(),ot(),d0(),Pm(),LW(),RD(),Oi(),AT(),Or=class extends vD($u){constructor(t,e,i){if(super(),this.data=e,this.bgColor=new Dr(1,1,1,1),this.fog=null,this.backupFog=new X8(16777215,.1,2e3),this.fogUseBGColor=!1,this.fogMode="linear",this.fogDensity=Jn.getDensity({}),this.fogHeightFalloff=Jn.getHeightFalloff({}),this.fogHeightBase=Jn.getHeightBase({}),this.isActive=!1,this.skyState=null,this.skyStateVersion=0,this.gradingState=null,this.skyHdriHolder=null,this.aoColor=new se,this.penumbraSizeArrayCache=null,this.super_Entity(t,e),this.personalCamera=new zs(l0,{...lS.defaultData,...e.camera,name:"Personal Camera"}),this.personalCamera.objectHelper.visible=!1,this.add(this.personalCamera),this.activeCamera=this.personalCamera,this.ambientLight=new iD(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=lj();r===null?On("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=lj();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()})):On("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=_a(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 vm&&e.recomputeBoolean()}),this.updateShadow(this.data.shadow)}forceMaterialsUpdate(){this.traverseEntity(t=>{if(t instanceof go)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;gv.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=_a(t.color,e),this.backupFog.near=t.near,this.backupFog.far=t.far,this.fogMode=Jn.getMode(t),this.fogDensity=Jn.getDensity(t),this.fogHeightFalloff=Jn.getHeightFalloff(t),this.fogHeightBase=Jn.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=_a(t.aoColor,e))}updateByOp(t,e,i,r){let s=this.data.uiFrame;super.updateByOp(t,e,i,r);let n=e;tr(t.path,["fog"])?this.updateFog(n.fog,i.shared):tr(t.path,["sky"])?this.updateSky(n.sky,i.shared):tr(t.path,["grading"])?this.gradingState=n.grading??null:tr(t.path,["ao"])?this.updateAo(n.ao,i.shared):tr(t.path,["ambient"])?this.updateAmbientLight(n.ambient,i.shared):tr(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(_a(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 instanceof zs&&t.isDescendantOf(this)&&(this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=t,t.objectHelper.visible=!1)}get playCamera(){let t=this.scene?.find(this.data.publish.playCamera);return t instanceof zs?t:this.personalCamera}switchToPlayCamera(){this.switchActiveCamera(this.playCamera)}get penumbraSizeArray(){return this.penumbraSizeArrayCache===null&&this.updatePenumbraSizeArray(),this.penumbraSizeArrayCache}updatePenumbraSizeArray(){this.penumbraSizeArrayCache=new Array(nj).fill(.5);let t=0,e=0;this.traverseEntity(i=>{if(!i.visible)return!0;i instanceof cb&&i.visible&&t<hR&&(this.penumbraSizeArrayCache[t]=i.data.penumbraSize??.5,t+=1),i instanceof pb&&i.visible&&t<nj-hR&&(this.penumbraSizeArrayCache[hR+e]=i.data.penumbraSize??.5,e+=1)})}raycastWithClones(t){let e=[],i=r=>{for(let s of r.children){let n=s.cloner;vi.is(s)&&(s.visible||n?.object.data.visible)&&((Wh(s)||p5(s)&&this.scene.enableHelpers&&s.objectHelper.visible)&&(t.intersectObject(s,!1,e),Hj(s,t,e,!0)),i(s))}};return i(this),e}updateEntity2DByOp(t,e,i,r){this.uiCanvas?.updateEntity2DByOp(t,e,i,r)}}});function GZ(){return FW}function UN(){if(Xj===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 Xj}function jN(t){return t?.isWebGPUSplineRenderer===!0}var FW,Xj,Dyt=U(()=>{FW=null,Xj=null});function Yj(){return jW}var UW,jW,GW=U(()=>{UW=null,jW=null});function WZ(t,e,i){return g2.setRGB(t,e,i,Ns),{r:g2.r,g:g2.g,b:g2.b}}function eEt(t,e,i){let r,s=eT(t.angle,0),[n,a]=Kj(t.offset),[o,l]=Kj(t.morph),h=t.colors??[],u=t.steps??[],d=Math.min(10,h.length,u.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=h[0][0],p=h[0][1],m=h[0][2],f=h[0][3];for(let g=1;g<d;g++){let y=u[g-1],v=u[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+=(h[g][0]-c)*b,p+=(h[g][1]-p)*b,m+=(h[g][2]-m)*b,f+=(h[g][3]-f)*b}return[c,p,m,f]}function iEt(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=eT(o.alpha,1);if(!(l<=0))if(o.type==="color"){let h,u=o.color;typeof u=="string"?h=typeof s?.color=="function"?s.color(u):void 0:u&&typeof u.r=="number"&&(h=u),h&&n.push({kind:"color",layer:o,rgb:{...WZ(h.r,h.g,h.b),a:h.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,h=1,u=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]=eEt(c.layer,a,o);({r:p,g:m,b:f}=WZ(v,b,_)),g=x}let y=d?1:Math.min(1,Math.max(0,g*c.alpha));l+=(p-l)*y,h+=(m-h)*y,u+=(f-u)*y,d=!1}return{r:l,g:h,b:u}}}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 g2,eT,Kj,rEt=U(()=>{ot(),g2=new se,eT=(t,e)=>typeof t=="number"&&Number.isFinite(t)?t:e,Kj=t=>Array.isArray(t)&&typeof t[0]=="number"&&typeof t[1]=="number"?[t[0],t[1]]:[0,0]});function sEt(t,e){if(t==="torus"){let l=e()*Math.PI*2,h=e()*Math.PI*2,u=Math.cos(l),d=Math.sin(l),c=Math.cos(h),p=Math.sin(h);return{x:(1.4+.7*c)*u,y:-(1.4+.7*c)*d,z:.7*p,nx:c*u,ny:-c*d,nz:p,cr:1,cg:1,cb:1}}if(t==="cylinder"){let l=e()*Math.PI*2,h=Math.cos(l),u=Math.sin(l);return{x:.8*h,y:1.6*(e()-.5),z:.8*u,nx:h,ny:0,nz:u,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 nEt(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 h=(y,v)=>o?o.getX(3*y+v):3*y+v,u=i?i.elements:null,d=i?new Ms().getNormalMatrix(i).elements:null,c=y=>{let v=r.getX(y),b=r.getY(y),_=r.getZ(y);return u?u[0]*v+u[4]*b+u[8]*_+u[12]:v},p=y=>{let v=r.getX(y),b=r.getY(y),_=r.getZ(y);return u?u[1]*v+u[5]*b+u[9]*_+u[13]:b},m=y=>{let v=r.getX(y),b=r.getY(y),_=r.getZ(y);return u?u[2]*v+u[6]*b+u[10]*_+u[14]:_},f=new Float64Array(l),g=0;for(let y=0;y<l;y++){let v=h(y,0),b=h(y,1),_=h(y,2),x=c(v),S=p(v),w=m(v),T=c(b)-x,C=p(b)-S,M=m(b)-w,A=c(_)-x,P=p(_)-S,O=m(_)-w,D=C*O-M*P,N=M*A-T*O,z=T*P-C*A;g+=.5*Math.sqrt(D*D+N*N+z*z),f[y]=g}return g<=0?null:{total:g,sample:(y,v)=>{let b=0,_=l-1;for(;b<_;){let H=b+_>>1;f[H]<y?b=H+1:_=H}let x=b,S=h(x,0),w=h(x,1),T=h(x,2),C=v(),M=v();C+M>1&&(C=1-C,M=1-M);let A,P,O,D=1-C-M,N=c(S)*D+c(w)*C+c(T)*M,z=p(S)*D+p(w)*C+p(T)*M,k=m(S)*D+m(w)*C+m(T)*M;if(s){if(A=s.getX(S)*D+s.getX(w)*C+s.getX(T)*M,P=s.getY(S)*D+s.getY(w)*C+s.getY(T)*M,O=s.getZ(S)*D+s.getZ(w)*C+s.getZ(T)*M,d){let H=d[0]*A+d[3]*P+d[6]*O,rt=d[1]*A+d[4]*P+d[7]*O,it=d[2]*A+d[5]*P+d[8]*O;A=H,P=rt,O=it}}else{let H=c(S),rt=p(S),it=m(S),ft=c(w)-H,dt=p(w)-rt,K=m(w)-it,lt=c(T)-H,_t=p(T)-rt,xt=m(T)-it;A=dt*xt-K*_t,P=K*lt-ft*xt,O=ft*_t-dt*lt}let B=Math.sqrt(A*A+P*P+O*O)||1,V=1,q=1,W=1;if(a)V=a.getX(S)*D+a.getX(w)*C+a.getX(T)*M,q=a.getY(S)*D+a.getY(w)*C+a.getY(T)*M,W=a.getZ(S)*D+a.getZ(w)*C+a.getZ(T)*M;else if(t.sampleColor){let H=n?n.getX(S)*D+n.getX(w)*C+n.getX(T)*M:.5,rt=n?n.getY(S)*D+n.getY(w)*C+n.getY(T)*M:.5,it=t.sampleColor(H,rt);it&&(V=it.r,q=it.g,W=it.b)}return{x:N,y:z,z:k,nx:A/B,ny:P/B,nz:O/B,cr:V,cg:q,cb:W}}}}function qZ(t){let e=Math.min(Math.max(1,Math.floor(t.guideStrands)),Sv),i=function(l){let h=l>>>0;return()=>{h|=0,h=h+1831565813|0;let u=Math.imul(h^h>>>15,1|h);return u=u+Math.imul(u^u>>>7,61|u)^u,((u^u>>>14)>>>0)/4294967296}}(t.seed??1337),r=t.shape==="object"&&t.sampler,s=r?t.samplerRadius??Lh:Lh,n=new Float32Array(4*ic),a=new Float32Array(ic),o=new Float32Array(4*Sv).fill(1);for(let l=0;l<e;l++){let h=r?t.sampler(i):sEt(t.shape,i),u=r?h.x:h.x*s,d=r?h.y:h.y*s,c=r?h.z:h.z*s,{nx:p,ny:m,nz:f}=h;o[4*l+0]=h.cr,o[4*l+1]=h.cg,o[4*l+2]=h.cb;let g,y,v,b=l*Tg,_=(1.8+.8*i())*t.hairLength*s/(Tg-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<Tg;T++){let C=T/(Tg-1),M=C*C*.4*s,A=S*Math.sin(C*x*Math.PI*2),P=4*(b+T);n[P+0]=u+p*_*T+A*g/w,n[P+1]=d+m*_*T-M+A*y/w,n[P+2]=c+f*_*T+A*v/w,n[P+3]=T===0?0:1,T<Tg-1&&(a[b+T]=_)}}return{initialPositions:n,restLengths:a,unitScale:s,rootColors:o}}var Tg,Sv,ic,Lh,Wp,T_,K0,uf,Z0,vR,Oyt=U(()=>{ot(),ic=(Sv=16384)*(Tg=32),Lh=100}),Iyt=U(()=>{ot(),na(),GW(),rEt(),Oyt(),Wp=1/60,T_=new bt,K0=new we,uf=new E,Z0=new E,vR=class extends Ks{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 we,this.lastBonePos=new E,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 ve(new Float32Array(0),3)),this.material=new jo({colorWrite:!1,depthWrite:!1}),this.frustumCulled=!1,this.scalpMesh=new gr(new Ac(Lh,48,32),new jo({color:5448477})),this.scalpMesh.name="HairScalp",this.add(this.scalpMesh);let r=new T4;r.setAttribute("position",new ve(new Float32Array(12),3)),r.setIndex([0,2,1,2,3,1]),r.instanceCount=0,this.ribbonMesh=new gr(r,new jo({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*Wp*2),this.trackMotionRest(t/1e3))}trackMotionRest(t){this.boneTransform(K0,uf);let e=this.hasLastBone&&(Math.abs(this.lastBoneQuat.dot(K0))<.9999995||this.lastBonePos.distanceToSquared(uf)>1e-8),i=this.motionFingerprint(),r=!this.hasLastBone||e||this.resetRequested||i!==this.lastMotionFingerprint||this.data.windStrength>.001;this.lastBoneQuat.copy(K0),this.lastBonePos.copy(uf),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,Ns)}(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=nEt(d);c&&l.push(c)}if(l.length===0)return null;let h=new Float64Array(l.length),u=0;for(let d=0;d<l.length;d++)u+=l[d].total,h[d]=u;return u<=0?null:d=>{let c=d()*u,p=0,m=l.length-1;for(;p<m;){let g=p+m>>1;h[g]<c?p=g+1:m=g}let f=p===0?c:c-h[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 h=o;return qZ({shape:"object",guideStrands:i,hairLength:r,sampler:u=>{let d=a(u);return{...d,x:d.x*h,y:d.y*h,z:d.z*h}},samplerRadius:l})}}}return qZ({shape:t==="object"?"sphere":t,guideStrands:i,hairLength:r})}collectBaseSources(t){let e=[],i=[],r=0,s=0;T_.copy(t.matrixWorld).invert();let n=T_.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 h=o===t?void 0:new bt().multiplyMatrices(n,o.matrixWorld),u=Array.isArray(o.material)?o.material[0]:o.material;e.push({geometry:l,matrix:h,sampleColor:iEt(u,this.context.shared)??void 0}),i.push(vR.matrixHash(h)),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(eT(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(eT(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}(u,this.context.shared),l.boundingSphere===null&&l.computeBoundingSphere();let d=l.boundingSphere;if(d){let c=0,p=1;h?(uf.copy(d.center).applyMatrix4(h),c=uf.length(),p=vR.matrixMaxScale(h)):c=d.center.length(),r=Math.max(r,c+d.radius*p)}}for(let h of o.children)a(h)};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 T_.copy(t.matrixWorld).decompose(uf,K0,Z0),Math.max(Math.abs(Z0.x),Math.abs(Z0.y),Math.abs(Z0.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 S4(1.4*Lh,.7*Lh,24,48):t==="cylinder"?new eS(.8*Lh,.8*Lh,1.6*Lh,48,1):new Ac(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)}T_.copy(i).decompose(e,t,Z0)}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(K0,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?.(),Yj()?.release(this)}}});function bR(){return{shapeInput:()=>`
|
|
387
|
+
`&&A.push("")):w.getTextWidth(A[A.length-1]+P,S)>M&&(A[A.length-1].length&&A.push(""),w.getTextWidth(A[A.length-1]+P,S)>M&&(P.length===1?(A[A.length-1]+=P,P=""):(A[A.length-1]+=P.slice(0,-1),P=P[P.length-1],A.push(""))));return A[A.length-1]+=P,A}(t,i,h===2?c.toUpperCase():h===3?c.toLowerCase():c,e),{shapes:m,charWidths:f,charCoords:g}=i.generateShapes(p,t,e),y=.5*(typeof r=="number"?r:Number(e.getVariable(r))),v=.5*(typeof s=="number"?s:Number(e.getVariable(s))),b=m.map(S=>new ps().fromShape(S,!0));this.vectorShapes=b;let _=b.map(S=>Cm.create({shape:S,parameters:{depth:n,extrudeBevelSegments:o,extrudeBevelSize:a,uvPitch:d===1?void 0:u,extrusionVersion:d,windingRule:n<=0?ns.NONZERO:ns.ODD,subdivisions:this.isLowResolution&&n>0?1:12}})),x=_.length?Ig(_):yZ();x.translate(-y,v,0),this.dispose(),this.wrappedText=p,this.charCoords=g,this.charWidths=f,this.deleteAttribute("extrudeNormal"),Object.entries(x.attributes).forEach(([S,w])=>{this.setAttribute(S,w)}),this.setIndex(x.index),this.adoptNearSide(_,n),this.computeBoundingSphere()}adoptNearSide(t,e){this._depth=e;let i=0,r=0,s=0;for(let o of t){let l=o,h=l._nearSide;if(h===void 0||h.length===0)return this._nearSide=new Uint8Array(0),this._effectiveBevel=0,void(this._vScale=0);i+=h.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&&ev(this._effectiveBevel,t)&&ev(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 h=o[l];h!==0&&(r[3*l+2]+=e,h===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=qa(new fe,Dj.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 qCt(t){if(!Oj)return bZ||(bZ=async function(){let e=t??"https://cdn.spline.design/@splinetool/runtime@2.0.206/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});dyt(a),Oj=!0}())}var dyt,EW,Oj,bZ,SD=U(()=>{EW=new Promise(t=>{dyt=t}),Oj=!1});function SN(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 h=t.attributes[l],u=e.attributes[l];if(h===void 0||h.isInterleavedBufferAttribute===!0||u.isInterleavedBufferAttribute===!0||h.itemSize!==u.itemSize||h.normalized!==u.normalized||h.array.constructor!==u.array.constructor||h.array.length!==u.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,h=n.array.constructor;if(l!==h){if(l!==Uint32Array||h!==Uint16Array)return!1;a=!0}}if(t.groups.length!==e.groups.length)return!1;for(let l=0;l<e.groups.length;l++){let h=t.groups[l],u=e.groups[l];if(h.start!==u.start||h.count!==u.count||h.materialIndex!==u.materialIndex)return!1}for(let l of r){let h=t.attributes[l],u=e.attributes[l];h.array.set(u.array),h.needsUpdate=!0}let o=t.takeDepthStateFrom;if(typeof o=="function"&&o.call(t,e),s!==null&&n!==null){if(a){let l=s.array,h=n.array;for(let u=0,d=h.length;u<d;u++){let c=h[u];l[u]=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 Ij(t,e,i,r){let s,n,a,o=t.position.array,l=t.normal.array,h=cyt.makeScale(e,i,r).invert().elements;for(let u=0,d=o.length;u<d;u+=3)o[u]*=e,o[u+1]*=i,o[u+2]*=r,s=l[u],n=l[u+1],a=l[u+2],l[u]=h[0]*s+h[4]*n+h[8]*a,l[u+1]=h[1]*s+h[5]*n+h[9]*a,l[u+2]=h[2]*s+h[6]*n+h[10]*a;t.position.needsUpdate=!0,t.normal.needsUpdate=!0}var cyt,pyt=U(()=>{ot(),cyt=new bt});function Nj(t){let e=Number(t);return Number.isInteger(e)&&e>=0&&String(e)===t?e:-1}function oA(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=Nj(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 TN(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=>Nj(l)===-1),r=0;for(let l of e){let h=Nj(l);h>=r&&(r=h+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 myt(t){let e=Object.keys(t);return e.length===1&&e[0]==="subdivisions"}function PW(t,e){let i=e?e.count:t.count,r=0,s=1e4,n=new Map,a=new Uint32Array(i),o=[];for(let u=0;u<i;u++){let d=e?e.getX(u):u,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[u]=_}let l=[],h=[];for(let u=0;u<a.length;u+=3)a[u]===a[u+1]||a[u]===a[u+2]||a[u+1]===a[u+2]||(l.push(a[u],a[u+1],a[u+2]),h.push(e?e.getX(u):u,e?e.getX(u+1):u+1,e?e.getX(u+2):u+2));return{positions:o,triIndices:l,triOriginals:h}}var x_,hf,Ie,MN,AN,CN,cs,w_,lA,hA,uA,Bj,fR,hb=U(()=>{ot(),SD(),De(),TD(),pyt(),ZS(),x_=new dr,hf=new E,EW.then(t=>{Ie=t}),MN=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),AN=new Uint32Array([0,1,2,3]),CN=new Uint8Array([4]),cs=class extends fe{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=fm.div(e.map(a=>typeof a=="number"?a:0),i);if(r.every(a=>a===1))return;this.subdividedGeometry&&Ij(this.subdividedGeometry.attributes,...r),this.originalGeometry&&Ij(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(hf.fromArray(r));let n=hf.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=cs.allocate(t),i=cs.buildRefined(s,t.subdivisions,e)}catch(n){console.error(n,t)}finally{s&&cs.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}=cs.build(this.data,void 0,!this.flatShading,void 0))}catch{t=new Yh(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&&(cs.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let t=this.originalGeometry;t.boundingSphere===null&&(t.boundingSphere=new Zn,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=t.boundingSphere));let e=t.attributes.position,i=t.boundingSphere.center;x_.setFromBufferAttribute(e),x_.getCenter(i),t.boundingSphere.radius=i.distanceTo(x_.max),isNaN(t.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),x_.getSize(hf);let r={width:hf.x,height:hf.y,depth:hf.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=cs.allocate(t,r)}catch(l){console.error(l,t),s=cs.allocate({positionWASM:MN,indexWASM:AN,verticesPerFaceWASM:CN},r)}Ie.set_destination_refinement_level(s,0);let o=cs.buildLevel(s,!0,a);return n=t.subdivisions>0?cs.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),cs.buildLevel(t,!1,i)??null}catch{try{return Ie.set_destination_refinement_level(t,e-1),cs.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:om(t,i,!1,e);r=e0t(t)?s.getClosedTorusIndicesForBooleanOrSubdiv():s.getIndex();let n,{positions:a,triIndices:o,triOriginals:l}=PW(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:h,verticesPerFace:u,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 C=g[T];_.push(b.getX(C),b.getY(C))}};if(m.userData.shape!==void 0&&m.userData.parameters.depth===0&&m.userData.shape.shapeHoles.length===0){let T=m.userData.shape.extractShapePointsToFlatArray([]),C=m.userData.parameters.spikes;if(m.userData.type==="EllipseGeometry"&&C<=24&&C%4==0&&m.userData.parameters.angle>=360){let P=T.length/2/C;T=T.filter((O,D)=>Math.floor(D/2)%P===0)}let M=0;for(let P=0;P<T.length;P+=2)M+=(T[P]-T[(P===0?T.length:P)-2])*(T[P+1]+T[(P===0?T.length:P)-1]);c.length=0;let A=0;if(M<0)for(let P=0;P<T.length;P+=2)c.push(T[P],T[P+1],0),y.push(A++);else for(let P=T.length-2;P>=0;P-=2)c.push(T[P],T[P+1],0),y.push(A++);return v.push(A),{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]){w_.set(c[3*p[w]],c[3*p[w]+1],c[3*p[w]+2]),lA.set(c[3*p[w+1]],c[3*p[w+1]+1],c[3*p[w+1]+2]),hA.set(c[3*p[w+4]],c[3*p[w+4]+1],c[3*p[w+4]+2]),uA.set(c[3*p[w+5]],c[3*p[w+5]+1],c[3*p[w+5]+2]),lA.sub(w_).normalize(),hA.sub(w_).normalize(),uA.sub(w_).normalize();let T=lA.cross(hA).dot(uA),C=w;Math.abs(T)>.005||f&&f.some((M,A)=>A%2!=1&&C>=f[A]&&C<f[A+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=[],C=[],M=0;for(let A=0,P=0;A<c.length;A+=3,P++)c[A+2]===0&&(T.push(P),M++),c[A+2]===S&&C.push(P);if(m.userData.parameters.extrudeBevelSize===0){let A=C[0];C[0]=C[1],C[1]=A}T.reverse(),y.push(...T,...C),v.push(M,M),_=void 0}return{indices:y,verticesPerFace:v,uvs:_}}(a,o,s,n,l);return{positions:a,indices:h,verticesPerFace:u,uvs:d}}static allocate(t,e){let i,r,s,n=[],a=[],o=oA(t.positionWASM),l=oA(t.indexWASM),h=oA(t.verticesPerFaceWASM);if(o&&o.length>0){if(!l?.length||!h?.length)throw new Error(`SubdivGeometry.allocate: unusable cage topology \u2014 positionWASM ${TN(t.positionWASM)}, indexWASM ${TN(t.indexWASM)}, verticesPerFaceWASM ${TN(t.verticesPerFaceWASM)}`);i=o,r=l,s=h;let w=oA(t.uvWASM);Ie.alloc_subdivision_surface_uvs&&w&&w.length===2*r.length&&(a=w)}else i=MN,r=AN,s=CN;let u=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,u,y+g,d,y+g+r.length*Uint32Array.BYTES_PER_ELEMENT,c,x,a.length,v.elements):Ie.alloc_subdivision_surface_uvs(y,u,y+g,d,y+g+r.length*Uint32Array.BYTES_PER_ELEMENT,c,x,a.length):v?Ie.alloc_subdivision_surface2(y,u,y+g,d,y+g+r.length*Uint32Array.BYTES_PER_ELEMENT,c,v.elements):Ie.alloc_subdivision_surface(y,u,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),h=0,u=Ie.HEAPU32[o[h]>>2],d=Ie.HEAPF32.subarray(u>>2,(u>>2)+l[h]);h++;let c=Ie.HEAPU32[o[h]>>2],p=Ie.HEAPF32.subarray(c>>2,(c>>2)+l[h]);h++;let m=Ie.HEAPU32[o[h]>>2],f=Ie.HEAPU32.subarray(m>>2,(m>>2)+l[h]);h++;let g,y=Ie.HEAPU32[o[h]>>2],v=Ie.HEAPU32.subarray(y>>2,(y>>2)+l[h]);if(h++,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 fe;if(_.setIndex(new pm(v,1)),_.setAttribute("position",new me(d,3)),_.setAttribute("normal",new me(p,3)),g&&_.setAttribute("uv",new me(g,2)),e){_.setAttribute("faceMap",new pm(f,1));let x=new Float32Array(p.length/3*4).fill(0);_.setAttribute("color",new ve(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 h=Ie.HEAPU32[s[a]>>2],u=Ie.HEAPU32.subarray(h>>2,(h>>2)+n[a]);if(e===void 0){let d=new fe;d.setAttribute("position",new me(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 ve(c,3)),d.setIndex(new pm(u,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],h=new Float32Array(Ie.HEAPF32.subarray(l>>2,(l>>2)+a[o]));o++;let u=Ie.HEAPU32[n[o]>>2],d=new Uint32Array(Ie.HEAPU32.subarray(u>>2,(u>>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:h,indices:d,verticesPerFace:m,uvs:c}}},w_=new E,lA=new E,hA=new E,uA=new E}),fyt=U(()=>{VK(),zK(),r5(),LK(),o5(),ZS(),sZ(),nZ(),aZ(),Pj(),hZ(),l5(),uZ(),dZ(),cZ(),Rj(),pZ(),mZ(),fZ(),gZ(),wm(),Oi(),VK(),zK(),r5(),LK(),o5(),GCt(),ZS(),sZ(),nZ(),aZ(),Pj(),hZ(),l5(),uZ(),dZ(),cZ(),Rj(),pZ(),mZ(),fZ(),gZ(),wm(),WCt(),U0t(),uyt(),hb(),SD(),_D(),lb(),Bj={ConeGeometry:w0t,CubeGeometry:S0t,CylinderGeometry:_W,DodecahedronGeometry:T0t,EllipseGeometry:xD,HelixGeometry:i0t,IcosahedronGeometry:K0t,LatheGeometry:Z0t,NonParametricGeometry:J0t,PolygonGeometry:AW,PyramidGeometry:tyt,RectangleGeometry:wD,SphereGeometry:ryt,PlaneGeometry:syt,BackdropGeometry:nyt,StarGeometry:CW,TextFrameGeometry:ayt,TorusGeometry:oyt,TorusKnotGeometry:lyt,TriangleGeometry:hyt,VectorGeometry:Cm},fR=t=>{let e=Bj[t.type]??qgt(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 om(t,e,i,r){let s,n,a;t.type==="PathGeometry"?(n={...t,extrusion:{...t.extrusion}},a=[[],["extrusion"]]):(n={...t},a=[[]]);for(let h of a){let u=n;for(let d of h)u=u[d];for(s in u){let d=u[s];LU(d)&&!gyt.includes(s)&&(u[s]=e.getVariable(d,[r.uuid,"geometry",...h,s]),LU(u[s])&&(u[s]=1))}}let o,l={parameters:n,type:n.type};if(n.type==="PathGeometry"){l.path=n.path;let h=r.profileShape;h!==void 0&&(l.shapeData=h),l.ownerId=r.uuid}else if(n.type==="VectorGeometry"){let h=ps.createFromState(n.shape,n.width,n.height);l.shape=h,l.ownerId=r.uuid}else if(n.type==="NonParametricGeometry"){if(n.data.groups&&n.data.groups?.forEach(h=>h.materialIndex=Math.max(h.materialIndex??0,0)),l.geometry=new OG().parse(n),l.geometry.groups.length===0){let h=l.geometry;h.addGroup(0,Math.max(h.getIndex()?.count??0,h.getAttribute("position").count),0)}}else{if(n.type==="SubdivGeometry"){let h=new cs(n,i);return h.data=t,h}if(n.type==="TextGeometry"||n.type==="InputGeometry"){let h=qgt(n.type);if(h)return h.create(n,e);On("text",`a ${n.type}`);let u=ps.createFromState(jv.defaultData(),100,100);return fR({...n,shape:u,type:"VectorGeometry"})}if(n.type==="UIGeometry")return wD.create({parameters:{width:n.width,height:n.height,cornerRadius:n.cornerRadius,cornerType:n.cornerType}})}try{o=fR(l)}catch(h){console.error(h),console.error(`Error generating geometry with inputs: ${l}`);let u=ps.createFromState(jv.defaultData(),100,100);l.shape=u,l.type="VectorGeometry",o=fR(l)}return o}var gyt,TD=U(()=>{De(),ot(),fyt(),Oi(),l5(),Am(),hb(),gyt=["font"]});function kj(t){switch(typeof t){case"number":return Number.isFinite(t)?JSON.stringify(t):void 0;case"boolean":return JSON.stringify(t);case"string":return LU(t)?void 0:JSON.stringify(t);case"object":{if(t===null)return"null";if(Array.isArray(t)){let s="[";for(let n=0;n<t.length;n++){let a=kj(t[n]);if(a===void 0)return;s+=(n>0?",":"")+a}return s+"]"}let e=t,i="{",r=!0;for(let s of Object.keys(e).sort()){if(e[s]===void 0)continue;let n=kj(e[s]);if(n===void 0)return;i+=`${r?"":","}${JSON.stringify(s)}:${n}`,r=!1}return i+"}"}default:return}}var yyt,_Z,Vj,HCt=U(()=>{De(),yyt=new Set(["CubeGeometry","SphereGeometry","CylinderGeometry","ConeGeometry","TorusGeometry","TorusKnotGeometry","IcosahedronGeometry","DodecahedronGeometry","PyramidGeometry","PlaneGeometry","BackdropGeometry","HelixGeometry"])}),$Ct=U(()=>{TD(),HCt(),_Z=class{constructor(){this.objects=new Map,this.refs=new Map,this.sharedByKey=new WeakSet,this.unreachable=new Set}resolveObject(t,e,i){return this.createObject(t,e,i)}onObjectDisposed(t){}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.resolveObject(t,e,i),this.objects.set(t,r),this.retain(r)):(this.sharedByKey.add(r),r.isShared=!0),r}forceDelete(t){let e=this.objects.get(t);e&&(this.objects.delete(t),this.release(e))}adopt(t,e){this.replace(t,e),this.retain(e)}mutateIfUnique(t,e){let i=this.objects.get(t);if(i&&i.isShared!==!0)return this.objects.delete(t),this.replace(e,i),i}replace(t,e){let i=this.objects.get(t);this.objects.set(t,e),i!==void 0&&i!==e&&this.release(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=>{let e=this.objects.get(t);this.objects.delete(t),this.release(e)}),this.unreachable.clear()}dispose(){new Set(this.objects.values()).forEach(t=>{this.disposeObject(t),this.onObjectDisposed(t)}),this.objects.clear(),this.refs.clear()}retain(t){let e=(this.refs.get(t)??0)+1;this.refs.set(t,e),e>1&&(t.isShared=!0)}release(t){let e=(this.refs.get(t)??1)-1;if(e>0)return this.refs.set(t,e),void(e===1&&!this.sharedByKey.has(t)&&(t.isShared=!1));this.refs.delete(t),this.disposeObject(t),this.onObjectDisposed(t)}},Vj=class extends _Z{constructor(t){super(),this.flatShading=t,this.dedupeByValue=!1,this.byValue=new Map,this.valueKeyOf=new Map}disposeObject(t){t.dispose()}createObject(t,e,i){let r=om(t,e,this.flatShading,i);return r.computeBoundingSphere(),r}resolveObject(t,e,i){let r=this.dedupeByValue?function(n,a,o){if(!yyt.has(n.type))return;let l=n;if(l.shapeBlendNode!=null||o.isTransientGeometryKey(n))return;let h=a.material;if(h===void 0||Array.isArray(h))return;let u=h;if(typeof u.getLayersOfType!="function"||u.getLayersOfType("outline").length>0||u.getLayersOfType("cavity").length>0)return;let d=n.type;for(let c of Object.keys(l).sort()){let p=l[c];if(p===void 0||c==="type")continue;let m=kj(p);if(m===void 0)return;d+=`|${c}=${m}`}return d}(t,i,e):void 0;if(r!==void 0){let n=this.byValue.get(r);if(n!==void 0)return n}let s=this.createObject(t,e,i);return r!==void 0&&(this.byValue.set(r,s),this.valueKeyOf.set(s,r)),s}mutateIfUnique(t,e){let i=super.mutateIfUnique(t,e);return i!==void 0&&this.forgetValue(i),i}onObjectDisposed(t){this.forgetValue(t)}forgetValue(t){let e=this.valueKeyOf.get(t);e!==void 0&&(this.valueKeyOf.delete(t),this.byValue.get(e)===t&&this.byValue.delete(e))}}});function h5(){return TT}function vyt(){if(TT==="webgpu"){if(Lj!==void 0)return Lj;Fj||(Fj=!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(SZ===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 SZ}function byt(t,e){return vyt().createRootMaterial(t,e)}function xZ(t,e,i){return vyt().createSharedMaterial(t,e,i)}function wZ(t){return t.getLayersOfType===void 0&&Object.assign(t,{layers:[],getLayersOfType:()=>[],hasAO:!1,assetsLoaded:()=>!0}),t}function zj(){return _yt}var TT,Lj,SZ,Fj,Uj,_yt,xyt,Em=U(()=>{TT="webgl",Fj=!1}),XCt=U(()=>{xyt={markNeedsUpdateRendererDirty:()=>{}}});function TZ(t){return t.data.type!=="displace"&&!!t.data.isMask}function lm(t,e){let i=0;if(!t.layers||t.layers.length===0)return!1;let r=t.layers?.find(n=>n.data.type==="light");if(r){let n=r.data,a=Number(e.getVariable(n.alphaOverride));if((typeof n.alphaOverride=="string"?a/100:n.alphaOverride)<1)return!0}let s=t.layers;for(let n=0;n<s.length;n++){let a=s[n];if(!TZ(a)){if(n>0&&TZ(s[n-1])){if(a.data.type==="light"&&!a.data.visible)return!0;continue}if(a.data.type!=="displace"&&"alpha"in a.data&&a.data.type!=="light"&&a.data.type!=="fresnel"&&a.data.type!=="cavity"&&a.data.type!=="dust"&&a.data.type!=="texture"&&a.data.type!=="matcap"&&a.data.type!=="rainbow"&&a.data.type!=="outline"&&a.data.type!=="pattern"){let o=a.data.visible?a.data.alpha:0;if(typeof o=="string"&&(o=Math.max(0,Math.min(1,Number(e.getVariable(o)??100)/100))),o===1&&a.data.type==="depth"||a.data.type==="gradient"){for(let l of a.data.colors)if(l[3]<1){o=l[3];break}}else if(o===1&&a.data.type==="noise"){let l=e.color(a.data.colorA).a,h=e.color(a.data.colorB).a,u=e.color(a.data.colorC).a,d=e.color(a.data.colorD).a,c=Math.min(l,Math.min(h,Math.min(u,d)));c<1&&(o=c)}i+=(1-i)*o}}}return i<1}var MD=U(()=>{});function _v(t){return typeof t=="string"||typeof t=="number"&&t!==0}var Wv,as,wyt,Syt,MT,Tyt,MZ,AZ,Za,ub=U(()=>{ot(),Wv=(t,e,i)=>Math.max(0,Math.min(1,Number(e.getVariable(typeof t=="number"?100*t:t,i)??100)/100))??1,as=(t,e,i)=>typeof t=="number"?t:e.getVariable(t,i),wyt=(t,e)=>(t||(t=new E),t.x=as(t.x,e)??0,t.y=as(t.y,e)??0,t.z=as(t.z,e)??0,t),Syt=(t,e)=>(t||(t=new Y),t.x=as(t.x,e)??0,t.y=as(t.y,e)??0,t),MT={noise:["noiseType"],texture:["projection","axis","projectionAxis","uvChannel","side"],video:["projection","axis","projectionAxis","uvChannel","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"]},Tyt={depth:["colors"],gradient:["colors","steps"],toon:["colors","steps"]}}),db=U(()=>{ot(),ob(),Jr(),MZ=class extends yD(ur){},AZ=t=>t.type==="Mesh",Za=class extends MZ{constructor(t){super(),this.object=t,this.isClone=!0,this.matrixAutoUpdate=!1}raycast(t,e){}expand(){let t=0,e=this.object.entityChildren(t);for(;e;){let i=this.children[t];(!(i instanceof Za)||i.object!==e)&&(i=new Za(e),this._replaceChildAt(t,i),i.matrixWorldNeedsUpdate=!0,i.matrixAutoUpdate=!1,i.matrix=e.matrix,i.shearMatrix=e.shearMatrix,i.pivotMatrix=e.pivotMatrix),i.expand(),t+=1,e=this.object.entityChildren(t)}for(let i of this.object.children){if(!nm(i)||i.object.parent!==this.object)continue;let r=this.children[t];r?.source!==i&&(r=i.createCopy(),this._replaceChildAt(t,r)),r.expand(),t+=1}for(;this.children.length>t;)this.remove(this.children[t]);this.pivotMatrix=this.object.pivotMatrix}_replaceChildAt(t,e){let i=this.children[t];i&&this.remove(i),this.add(e),this.children.splice(t,0,this.children.pop())}get visible(){let t=this.parent,e=nm(t)&&t.object===this.object;return(!e||!t.instancingActive&&!t.insideBoolean)&&(this.playModeVisible!==void 0?this.playModeVisible:this.object.visible||e&&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 AZ(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 CZ(){return RW}var RW,DW,OW=U(()=>{RW=null,DW=null});function jj(t){return"variable_"+t}var EN,PN,RN,EZ,DN,PZ,ON,RZ,u5,IW=U(()=>{De(),_Ct(),y0t(),v0t(),Nc(),yW(),bW(),$Ct(),Em(),m0t(),XCt(),MD(),ub(),yo(),db(),Li(),ot(),OW(),Oi(),EN=new bt,PN=new E,RN=new we,EZ=new E,DN=new zi,PZ=class extends u0t{constructor(t){super(),this.shared=t}create(t){return new gW(t,this.shared)}},ON=new Set,(u5=RZ=class{constructor(t,e={},i=!0,r=!1){if(this.data=t,this.needsJitter=i,this.enableLocalStorageForPersistentVariables=r,this.geometryCache=new Vj(!0),this.geometryCache2=new Vj(!1),this.imageHolderCache=new PZ(this),this.thisContext={scene:xyt,shared:this},this.deletedImage=new Sg(L4.emptyImage,this),this.deletedVideo=new Sg(F4.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=xZ(Qr.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=Qr.withRepairedLayers(e),this.materials[t]){let i=this.materials[t];i.reset(e,this.thisContext),i.dispose()}else{let i=xZ(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):byt(Qr.withRepairedLayers(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 Sg(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 Sg(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 h=l.getTexture(a.texture.wrapping??(a.type==="texture"?1e3:1001),a.texture.minFilter??1008,a.texture.magFilter??1006),u=l.img;return{texture:h,width:u?.width??0,height:u?.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 Sg(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 vj(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 tv)return e;{let i=new tv({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 tv&&e.dispose(),delete this.audios[t])}addFont(t,e){let i=vW;i!==null?(this.fonts[t]=new i(e),this.fonts[t].loadingPromise.then(()=>this.requestRender())):On("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 tv&&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(jj(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(jj(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,h={scene:r,shared:this},u=a.slice(2);r.traverseMaterial(c=>{let p=c.root??c;p.uuid===o&&p.onVariableUpdate(u,l,h)});let d=this.materials[o];d&&d.onVariableUpdate(u,l,h)}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*zt.DEG2RAD:o[a[a.length-1]]=i}if(o=r.find(a[0]),o.type==="ParticleEmitter"&&o.updateVariableState(i,a),vi.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 h=l.dataPatched;l.chooseGeoemtryCache(this).forceDelete(h.geometry),l.createGeometryDelayed(this.entityOpContext),l.onVariableUpdate(!0),l.invalidateDownstreamBooleanData(),l.instances.forEach(u=>{let d=u.dataPatched;u.chooseGeoemtryCache(this).forceDelete(d.geometry),u.createGeometryDelayed(this.entityOpContext),u.onVariableUpdate(!0),u.invalidateDownstreamBooleanData()})}else a[1]==="morphTargetInfluences"&&o.updateMorphInfluences(a[2],i)}}return s&&r.markShadowsDirty(),this.requestRender(),!0}isTransientGeometryKey(t){return this.transientGeometryKeys.has(t)}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=h=>h.toLowerCase().replace(/[\s_.-]+/g,""),a=new Map;for(let h of Object.keys(s))a.set(n(h),h);let o={};for(let[h,u]of Object.entries(e??{})){let d=a.get(n(h));if(d===void 0||d==="type"||d==="font"||d==="shape"||d==="path"||d==="data")continue;if(d==="text"){(typeof u=="string"||typeof u=="number")&&(o[d]={textValue:String(u)});continue}let c=s[d];typeof u=="number"&&isFinite(u)&&(typeof c=="number"||typeof c=="string")&&(o[d]=u)}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>RZ.MAX_TRANSIENT_VERTICES)return!1;let a,o,l,h=n instanceof Float32Array?n:Float32Array.from(n),u=h.length/3;if(e.normals!==void 0){if(e.normals.length!==h.length)return!1;a=e.normals instanceof Float32Array?e.normals:Float32Array.from(e.normals)}if(e.uvs!==void 0){if(e.uvs.length!==2*u)return!1;o=e.uvs instanceof Float32Array?e.uvs:Float32Array.from(e.uvs)}if(e.indices!==void 0){let x=u>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]>=u)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(u!==w)return function(T,C){let M=`${T}/${C}`;ON.has(M)||(ON.add(M),console.warn(`[spline] updateObject: ignoring a geometry update of ${T} vertices for a mesh that holds ${C}. 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.`))}(u,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<h.length;x+=3){let S=h[x],w=h[x+1],T=h[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(h,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 h=e[l],u=s[l];if(h==null){u.transformOverride!==void 0&&(u.transformOverride=void 0,a=!0);continue}let d=u.transformOverride??{position:[u.position.x,u.position.y,u.position.z],rotation:[u.rotation.x,u.rotation.y,u.rotation.z],scale:[u.scale.x,u.scale.y,u.scale.z]};h.position&&(typeof h.position.x=="number"&&(d.position[0]=h.position.x),typeof h.position.y=="number"&&(d.position[1]=h.position.y),typeof h.position.z=="number"&&(d.position[2]=h.position.z)),h.rotation&&(typeof h.rotation.x=="number"&&(d.rotation[0]=h.rotation.x*n),typeof h.rotation.y=="number"&&(d.rotation[1]=h.rotation.y*n),typeof h.rotation.z=="number"&&(d.rotation[2]=h.rotation.z*n)),h.scale&&(typeof h.scale.x=="number"&&(d.scale[0]=h.scale.x),typeof h.scale.y=="number"&&(d.scale[1]=h.scale.y),typeof h.scale.z=="number"&&(d.scale[2]=h.scale.z)),u.transformOverride=d,u.position.fromArray(d.position),u.rotation.fromArray(d.rotation),u.scale.fromArray(d.scale),u.updateMatrix(),u.hasNonUniformScale&&(u.updateMatrixWorld(),u.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 Za(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.shearMatrix.copy(t.shearMatrix),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 h of Array.isArray(i)?i:[i]){let u=h.root??h;u&&Array.isArray(u.layers)&&u.data&&!r.includes(u)&&r.push(u)}if(r.length===0)return!1;let s={scene:this.entityOpContext.scene,shared:this},n=h=>h.toLowerCase().replace(/[\s_.-]+/g,""),a=h=>{if(typeof h=="string"){let u=new Dr(1,1,1,1);try{u.set(h)}catch{return null}return{r:u.r,g:u.g,b:u.b,a:void 0}}if(h&&typeof h=="object"&&"r"in h){let u=h;if([u.r,u.g,u.b].some(c=>typeof c!="number"||!isFinite(c)))return null;let d=Math.max(u.r,u.g,u.b)>1?1/255:1;return{r:u.r*d,g:u.g*d,b:u.b*d,a:typeof u.a=="number"?Math.max(0,Math.min(u.a,1)):void 0}}return null},o=(h,u,d)=>{if(!h.hasValue(u))return!1;let c=h.getValue(u);if(!c||typeof c!="object"||!c.isColor)return!1;let p=d.a??(typeof c.a=="number"?c.a:1);return c instanceof vj?h.setValue(u,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 h of r){let u=h.data.layers??[],d=c=>h.layers.find(p=>p.uuid===c);if(e.color!==void 0){let c=a(e.color),p=u.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||lm(h.data,this);h.setTransparent?h.setTransparent(f,s.scene):h.transparent=f}}typeof e.alpha=="number"&&isFinite(e.alpha)&&(h.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"?u.find(y=>y.id===c.id):typeof c.index=="number"?u[c.index]:typeof c.type=="string"?u.find(y=>y.data.type===c.type):void 0,m=p&&d(p.id);if(!p||!m)continue;let f=MT[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))h.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)=>{h.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]}referencesMissingObject(t){return Array.isArray(t)&&t[0]!=="mouse"&&t[0]!=="raycast"&&this.entityOpContext.scene.find(t[0])===void 0}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(i===void 0)return;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?.(EN))return EN.decompose(PN,RN,EZ),t[1]==="position"?PN[t[2]]:(DN.setFromQuaternion(RN,i.rotation.order),DN[t[2]]*zt.RAD2DEG);for(let r=1;r<t.length;r++)i=i[t[r]];return t[1]==="rotation"&&(i*=zt.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(Qn.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(Qn.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=DW;return i===null?(On("ai-assistant","a voice-assistant integration"),!1):(this.openAIRealtime=i(e,t,this),!1)}{let i=CZ();return i===null?(On("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=CZ();return i===null?(On("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 u5(Zl.emptyData())});function d5(t){return a0t(t)||t?.isTSLNodeMaterial===!0}function DZ(t){return function(e){return e?.isClassicSharedMaterial===!0}(t)||t?.isTSLSharedMaterial===!0}function Myt(t){let e=t?.root;return DZ(t)||e!==void 0&&DZ(e)}var go,IN,NN,BN,OZ,kN,dd,IZ,NZ,S_,wr,NW=U(()=>{c0t()}),d0=U(()=>{De(),na(),Em(),NW(),Li(),dn(),go=class extends Ks{setMaterialOverride(t,e){this.materialOverride=wZ(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),tr(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&&go.disposeOneMaterial(n),this.material[Number(r)]=a}else if(tr(t.path,["material"])){let r=this.material;!Array.isArray(r)&&typeof r?.updateByOp=="function"&&"material"in e&&typeof e.material!="string"&&r.updateByOp(Qn.drop(t,1),e.material,i)}else if(tr(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(Qn.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=TT==="webgpu"&&Uj!==void 0?Uj:void 0;return r===void 0?null:wZ(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){d5(t)&&!Myt(t)&&t.nodeMaterialDispose()}disposeMaterial(){this.material&&mft(this.material).forEach(t=>{go.disposeOneMaterial(t)})}dispose(){this.disposeMaterial(),this.shadowCatcherMaterial?.dispose(),super.dispose()}}}),vo=U(()=>{De(),Li(),IW(),d0(),ot(),TD(),lb(),hb(),pyt(),IN=new E,NN=new Se,BN=new Se,OZ=new E,kN=new bt,dd=new gr,IZ=dd.geometry,NZ=dd.material,S_=new E,wr=class extends go{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 fe&&this.chooseGeoemtryCache(t).markAsReachable(this.dataPatched.geometry,this.geometryCreateDeleyed)}get builtSharedGeometry(){if(this.localGeometry===void 0)return this.geometryCreateDeleyed instanceof fe?this.geometryCreateDeleyed:void 0}get geometry(){if(this.localGeometry!==void 0)return this.localGeometry;if(this.geometryCreateDeleyed instanceof u5){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 G4.is2DParametricMesh(t.type)&&t.depth===0}get is2DType(){return G4.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),tr(t.path,["geometry"])&&this.updateByPatchedOpGeometry(Qn.drop(t,1),e.geometry,i)}removeInteractionGeometry(t){this.localGeometry?.dispose(),this.localGeometry=void 0}dispose(){var t;super.dispose(),t=this.uuid,a5.delete(t),this._posed=void 0}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=om(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,h=typeof s=="number"?s:1,u=typeof n=="number"?n:1;o.sxPrev!==void 0&&Ij(this.localGeometry.attributes,l/o.sxPrev,h/o.syPrev,u/o.szPrev),o.sxPrev=l,o.syPrev=h,o.szPrev=u}else if(!this.absorbDepthInteraction(t)){let r=om(i==="VectorGeometry"?W4.merge(this.data.geometry,t):{...this.data.geometry,...t},e,this.data.flatShading,this);this.localGeometry!==void 0&&this.supportsInPlaceGeometryUpdate(this.localGeometry)&&SN(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 cs&&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&&myt(t.props)&&this.geometryCreateDeleyed instanceof cs&&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 fe&&!(this.geometryCreateDeleyed instanceof cs)&&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=om(o,s,this.data.flatShading,this);SN(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 fe&&!(this.geometryCreateDeleyed instanceof cs)&&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=om(r,i,this.data.flatShading,this);return SN(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.posedGeometry()?.boundingBox;if(i)return i.getCenter(t),void i.getSize(e).multiplyScalar(.5);let r=this.geometry.userData.parameters;this.is2DType||this.isTextType?t.set(0,0,.5*r.depth):this.isNonParametric?(t.setScalar(0),this.geometry.boundingSphere&&t.copy(this.geometry.boundingSphere.center),e.set(r.width,r.height,r.depth??0).multiplyScalar(.5)):r.centerOffset?t.fromArray(r.centerOffset):t.setScalar(0),e.set(r.width,r.height,r.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()}rebindSkeleton(t){let e=this.dataPatched,i=e.bones?.map(t),r=this.isSkinnedMesh;if(!i?.length||i.some(s=>!s)||e.boneInverses?.length!==i.length?this.isSkinnedMesh=!1:(this.bindMatrix||(this.bindMatrix=new bt,this.bindMatrixInverse=new bt),this.bindMode=e.bindMode??"attached",e.bindMatrix&&this.bindMatrix.fromArray(e.bindMatrix),this.bind(new zS(i,e.boneInverses.map(s=>new bt().fromArray(s))),this.bindMatrix)),r!==this.isSkinnedMesh)for(let s of Array.isArray(this.material)?this.material:[this.material])s.needsUpdate=!0}normalizeSkinWeights(t){let e=new Se,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;NN.fromBufferAttribute(r.attributes.skinIndex,t),BN.fromBufferAttribute(r.attributes.skinWeight,t),IN.copy(e).applyMatrix4(this.bindMatrix),e.set(0,0,0);for(let s=0;s<4;s++){let n=BN.getComponent(s);if(n!==0){let a=NN.getComponent(s);kN.multiplyMatrices(i.bones[a].matrixWorld,i.boneInverses[a]),e.addScaledVector(OZ.copy(IN).applyMatrix4(kN),n)}}return e.applyMatrix4(this.bindMatrixInverse)}raycastDeformed(t,e){let i=this.posedGeometry();if(i===void 0)return!1;dd.geometry=i,dd.material=this.material,dd.matrixWorld.copy(this.matrixWorld);let r=e.length;dd.raycast(t,e);for(let s=r;s<e.length;s++)e[s].object=this;return dd.geometry=IZ,dd.material=NZ,!0}posedGeometry(){let t=this.skeleton;if(!this.isSkinnedMesh||t===void 0)return;let e=this.geometry,{position:i,skinIndex:r,skinWeight:s}=e.attributes;if(!i||!r||!s)return;let n=[...this.bindMatrix.elements,...this.bindMatrixInverse.elements,...this.morphTargetInfluences??[]];for(let d=0;d<t.bones.length;d++){let c=t.bones[d];if(!c||!t.boneInverses[d])return;n.push(...c.matrixWorld.elements)}let a=this._posed;if(a?.source===e&&a.version===i.version&&a.pose.length===n.length&&a.pose.every((d,c)=>d===n[c]))return a.geometry;let o=i.count,l=a?.geometry.attributes.position,h=l?.count===o?l:new ve(new Float32Array(3*o),3);for(let d=0;d<o;d++)this.boneTransform(d,this.getVertexPosition(d,S_)),h.setXYZ(d,S_.x,S_.y,S_.z);let u=new fe;u.setAttribute("position",h);for(let d of["normal","uv","uv1"]){let c=e.attributes[d];c&&u.setAttribute(d,c)}return u.setIndex(e.index),u.groups=e.groups,u.drawRange=e.drawRange,u.computeBoundingSphere(),u.computeBoundingBox(),this._posed={source:e,version:i.version,pose:n,geometry:u},u}}});function xv(t){if(Array.isArray(t.material)){for(let e of t.material)if(e.getLayersOfType("outline").length===0)return}else if(!a0t(t.material)||t.material.getLayersOfType("outline").length===0)return;t instanceof wr&&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 E;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 me(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]}`,h=new E(n[o],n[o+1],n[o+2]);i.has(l)?i.get(l)?.normals.push(h):i.set(l,{normals:[h],result:new E})}i.forEach((o,l)=>{for(let h of o.normals)o.result.add(h);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]}`,h=i.get(l)?.result;h&&(a[o]=h.x,a[o+1]=h.y,a[o+2]=h.z)}e.geometry.setAttribute("extrudeNormal",new me(a,3))}(t)}function VN(t){return Math.min(2047,Math.max(1,Math.round(2048*t)))/2048}function wv(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=[VN(zt.seededRandom(n)),VN(zt.seededRandom(n+1e4)),VN(zt.seededRandom(n+2e4))];for(let o=0;o<i.length;o++)s[o]=a[o%3];t.geometry.setAttribute("randomColor",new ve(s,3))}var AD=U(()=>{ot(),c0t(),vo()});function BZ(t){let e=!1;return t.scene.objects.traverse((i,r)=>{r.geometry?.type==="BooleanGeometry"&&(e=!0)}),e}function YCt(t,e){let i=t.cloner;return i!==void 0&&i.parent===e?i:void 0}function kZ(t,e,i,r){let s=16*(e.children.length+1);f2.length<s&&(f2=new Float32Array(s));let n=0,a=l=>{l.toArray(f2,16*n),n++},o=e.parameters.hideBase!==!0;o&&a(r),Gj.copy(t.matrix);for(let l of e.children)!am(l)||l.playModeVisible===!1||(Wj.copy(l.matrix).multiply(l.pivotMatrix),gR.multiplyMatrices(Gj,Wj),(!o||!gR.equals(r))&&a(gR));try{return n===0?0:function(l,h){return mW(e5().instanced_union(pW(l),h))}(i,f2.subarray(0,16*n))}finally{r0t(i)}}var cd,VZ,Gj,Wj,gR,f2,vm,AT=U(()=>{na(),ot(),_D(),AD(),d0(),Jr(),cd=new bt,VZ=new bt,Gj=new bt,Wj=new bt,gR=new bt,f2=new Float32Array(0),vm=class extends go{constructor(t,e,i){super(t,e),this.data=e,this.meshSetAddresses=[],this.needsTransformForDownstream=!1,this.geometry=new fe,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 vm&&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 Ks&&s.dataPatched.visible===!0&&s.geometry.attributes.position?.count>0&&s.geometry.drawRange.count>0&&s.booleanMeshSetAddress!==0){cd.copy(s.matrix).multiply(s.pivotMatrix);try{let n=YCt(s,this);if(s.booleanMeshSetAddress===-1){if((s.geometry.index??s.geometry.getAttribute("position")).count/3<15e5){let a=yCt(s.geometry,t===!0);s.booleanMeshSetAddress=n===void 0||a===-1?a:kZ(s,n,a,cd)}if(s.booleanMeshSetAddress===-1)return;n===void 0&&pN(s.booleanMeshSetAddress,cd),s.booleanMatrixInvOld.copy(cd).invert(),s.booleanWasTransformed=!1}else s instanceof vm&&s.needsTransformForDownstream===!0?(n===void 0?pN(s.booleanMeshSetAddress,cd):s.booleanMeshSetAddress=kZ(s,n,s.booleanMeshSetAddress,cd),s.needsTransformForDownstream=!1):s.booleanWasTransformed===!0&&(pN(s.booleanMeshSetAddress,VZ.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 fe,this.geometry.userData=r.userData,this.geometry.boundingSphere=r.boundingSphere,this.geometry.setAttribute("position",new me([],3))}return void this.geometry.setDrawRange(0,0)}if(t===!0)return function(r,s){let n=e5(),a=MK(r,s),o=n.mesh_topological_data(a),l=o.positions(),h=o.indices();return o.free(),a.free(),{positions:l,indices:h,verticesPerFace:new Uint8Array(h.length/3).fill(3)}}(this.meshSetAddresses,this.booleanOp);let i=this.geometry;i.dispose(),this.geometry=new fe,this.geometry.userData=i.userData,this.geometry.boundingSphere=i.boundingSphere;try{this.booleanMeshSetAddress=function(r,s,n,a){let o=e5(),l=MK(r,s),h=o.mesh_render_data(l,Math.max(a,0));if(n.setAttribute("position",new me(h.positions(),3)),n.setAttribute("normal",new me(h.normals(),3)),h.free(),n.boundingSphere===null&&(n.boundingSphere=new Zn),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 u=l.bounds();n.boundingSphere.center.set(u[0],u[1],u[2]),n.boundingSphere.radius=(u[3]**2+u[4]**2+u[5]**2)**.5,n.userData.parameters={width:2*u[3],height:2*u[4],depth:2*u[5]}}return mW(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,xv(this),wv(this)}dispose(){super.dispose(),this.geometry.dispose()}}});function KCt(t){return t.isPointLight?yR.PointLight:t.isSpotLight?yR.SpotLight:yR.DirectionalLight}function zZ(t){return t.isDirectionalLight?0:t.isSpotLight?1:2}var yR,mS,mg,c5,CD,Wh,Wu,p5,Ayt=U(()=>{yR={PointLight:1,SpotLight:3,DirectionalLight:3},mS=new WeakSet,mg=[]}),CT=U(()=>{ot(),Ayt(),yo(),u0(),(c5||(c5={})).is=function(t){return vi.is(t)&&t instanceof Hd},CD=(t,e)=>class extends h0(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&&(function(s){mS.delete(s)}(this),this.castShadow=i.shadows)}}}),Pm=U(()=>{ot(),AT(),na(),u0(),Wh=t=>t instanceof Ks,Wu=t=>t!==null&&t instanceof vm,p5=t=>mj.is(t)});function _a(t,e){return e.color(t)}function LZ(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,h,u=a;switch(e.format12h24h!=="24"&&(u=a%12,u===0&&(u=12)),i){case"HH:mm:ss":l=[u,o,r];break;case"HH:mm":l=[u,o];break;case"HH":l=[u],n=void 0;break;case"mm":l=[o],n=void 0;break;case"ss":l=[r],n=void 0;break;case"year":h=s.getFullYear();break;case"month":h=s.getMonth()+1;break;case"dayOfYear":h=Math.floor((s.getTime()-new Date(s.getFullYear(),0,0).getTime())/864e5);break;case"dayOfMonth":h=s.getDate();break;case"secondOfDay":h=60*a*60+60*o+r;break;default:console.error("Unknown time format",i),h=0}return l!==void 0?{textValue:l,suffix:n}:h}var qj,cb,BW=U(()=>{}),ZCt=U(()=>{ot(),_T(),xT(),qj=class extends sb(aft){constructor(t,e=15,i=10066329){super(t,e,i),this.object=t,this.added=!1,this.name=`DirectionalLightHelper: ${t.uuid}`}raycast(t,e){nb(this.object,qj.geometryHelper,t,e)}}}),ED=U(()=>{ot(),ZCt(),CT(),cb=class extends CD(US,qj){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 jS(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 jS&&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 kW(t){return t instanceof go&&t.needsAO&&!Dc(t)&&t.isDecalObject!==!0}function VW(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 zW(t){return t.getLayersOfType("reflection").filter(e=>e.data.visible).length}function QCt(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 JCt(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 FZ(t,e){let i={outline:!1,cavity:!1},r=t.layers.mask&PD,s=e.getLayersOfType("transmission"),n=e.getLayersOfType("outline"),a=zW(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,wv(t),xv(t)),s.length===0&&n.length===0&&o.length===0&&a===0&&t.layers.set(0),r&&t.layers.set(9),!r&&kW(t)&&t.layers.enable(5),VW(t),i}function UZ(t,e){if(!e.layers)return!1;let i=t.layers.mask&PD,r=!1,s=e.getLayersOfType("transmission").filter(l=>l.data.visible),n=e.getLayersOfType("outline").filter(l=>l.data.visible),a=zW(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&&kW(t)&&t.layers.enable(5),VW(t),r}function jZ(t,e){var i;if(!e.layers)return!1;let r=t.layers.mask&PD,s=!1,n=zW(e),a=e.getLayersOfType("transmission").filter(h=>h.data.visible),o=e.getLayersOfType("outline").filter(h=>h.data.visible),l=e.getLayersOfType("cavity").filter(h=>h.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&&kW(t)&&t.layers.enable(5),VW(t),s}function Hj(t,e,i,r=!1){let s=t.cloner;if(s){let n=null;if((t.raycast===gr.prototype.raycast||t.raycast===Ks.prototype.raycast)&&t.isSkinnedMesh!==!0){let a=t.geometry;a&&(a.boundingSphere===null&&a.computeBoundingSphere(),n=a.boundingSphere)}for(let a of s.children){if(n!==null&&($j.copy(n).applyMatrix4(a.matrixWorld),!e.ray.intersectsSphere($j)))continue;let o=Eyt.copy(a.matrixWorld).invert(),l=Pyt.copy(e.ray).applyMatrix4(o),h=t.matrixWorld;l.applyMatrix4(h);let u=Cyt;u.set(l.origin,l.direction),u.near=e.near,u.far=e.far,u.layers.mask=e.layers.mask;let d=u.intersectObject(t,!1);d.length>0&&i.push({...d[0],object:r?a:t})}}}var PD,Cyt,Eyt,Pyt,$j,dA,Ryt,zN,LN,FN,pb,Or,LW=U(()=>{Jr(),AD(),na(),d0(),ot(),PD=512,Cyt=new rD,Eyt=new bt,Pyt=new mc,$j=new Zn}),tEt=U(()=>{ot(),_T(),xT(),dA=class extends sb(sft){constructor(t,e=6710886){super(t,e),this.object=t,this.matrix=t.matrixWorld,this.name=`SpotLightHelper: ${t.uuid}`}raycast(t,e){nb(this.object,dA.geometryHelper,t,e)}update(){if(this.object!==void 0){let t=dA._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)}}},(Ryt=dA)._vector=new E}),RD=U(()=>{ot(),tEt(),CT(),zN=new E,LN=new E,FN=new we,pb=class extends CD(Wg,Ryt){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*zt.RAD2DEG*this.angle,r.aspect=1,r.near=100,r.far=2500;let s=new jS(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 jS&&e.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),LN.setFromMatrixPosition(this.matrixWorld),FN.setFromRotationMatrix(this.matrixWorld),zN.copy(this.up).applyQuaternion(FN).negate().multiplyScalar(this.distance),this.target.position.copy(LN).add(zN),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))}}}),rh=U(()=>{De(),Kh(),ot(),yo(),Nc(),BW(),pD(),ED(),Li(),Em(),ot(),d0(),Pm(),LW(),RD(),Oi(),AT(),Or=class extends vD($u){constructor(t,e,i){if(super(),this.data=e,this.bgColor=new Dr(1,1,1,1),this.fog=null,this.backupFog=new X8(16777215,.1,2e3),this.fogUseBGColor=!1,this.fogMode="linear",this.fogDensity=Jn.getDensity({}),this.fogHeightFalloff=Jn.getHeightFalloff({}),this.fogHeightBase=Jn.getHeightBase({}),this.isActive=!1,this.skyState=null,this.skyStateVersion=0,this.gradingState=null,this.skyHdriHolder=null,this.aoColor=new se,this.penumbraSizeArrayCache=null,this.super_Entity(t,e),this.personalCamera=new zs(l0,{...lS.defaultData,...e.camera,name:"Personal Camera"}),this.personalCamera.objectHelper.visible=!1,this.add(this.personalCamera),this.activeCamera=this.personalCamera,this.ambientLight=new iD(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=lj();r===null?On("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=lj();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()})):On("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=_a(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 vm&&e.recomputeBoolean()}),this.updateShadow(this.data.shadow)}forceMaterialsUpdate(){this.traverseEntity(t=>{if(t instanceof go)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;gv.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=_a(t.color,e),this.backupFog.near=t.near,this.backupFog.far=t.far,this.fogMode=Jn.getMode(t),this.fogDensity=Jn.getDensity(t),this.fogHeightFalloff=Jn.getHeightFalloff(t),this.fogHeightBase=Jn.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=_a(t.aoColor,e))}updateByOp(t,e,i,r){let s=this.data.uiFrame;super.updateByOp(t,e,i,r);let n=e;tr(t.path,["fog"])?this.updateFog(n.fog,i.shared):tr(t.path,["sky"])?this.updateSky(n.sky,i.shared):tr(t.path,["grading"])?this.gradingState=n.grading??null:tr(t.path,["ao"])?this.updateAo(n.ao,i.shared):tr(t.path,["ambient"])?this.updateAmbientLight(n.ambient,i.shared):tr(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(_a(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 instanceof zs&&t.isDescendantOf(this)&&(this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=t,t.objectHelper.visible=!1)}get playCamera(){let t=this.scene?.find(this.data.publish.playCamera);return t instanceof zs?t:this.personalCamera}switchToPlayCamera(){this.switchActiveCamera(this.playCamera)}get penumbraSizeArray(){return this.penumbraSizeArrayCache===null&&this.updatePenumbraSizeArray(),this.penumbraSizeArrayCache}updatePenumbraSizeArray(){this.penumbraSizeArrayCache=new Array(nj).fill(.5);let t=0,e=0;this.traverseEntity(i=>{if(!i.visible)return!0;i instanceof cb&&i.visible&&t<hR&&(this.penumbraSizeArrayCache[t]=i.data.penumbraSize??.5,t+=1),i instanceof pb&&i.visible&&t<nj-hR&&(this.penumbraSizeArrayCache[hR+e]=i.data.penumbraSize??.5,e+=1)})}raycastWithClones(t){let e=[],i=r=>{for(let s of r.children){let n=s.cloner;vi.is(s)&&(s.visible||n?.object.data.visible)&&((Wh(s)||p5(s)&&this.scene.enableHelpers&&s.objectHelper.visible)&&(t.intersectObject(s,!1,e),Hj(s,t,e,!0)),i(s))}};return i(this),e}updateEntity2DByOp(t,e,i,r){this.uiCanvas?.updateEntity2DByOp(t,e,i,r)}}});function GZ(){return FW}function UN(){if(Xj===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 Xj}function jN(t){return t?.isWebGPUSplineRenderer===!0}var FW,Xj,Dyt=U(()=>{FW=null,Xj=null});function Yj(){return jW}var UW,jW,GW=U(()=>{UW=null,jW=null});function WZ(t,e,i){return g2.setRGB(t,e,i,Ns),{r:g2.r,g:g2.g,b:g2.b}}function eEt(t,e,i){let r,s=eT(t.angle,0),[n,a]=Kj(t.offset),[o,l]=Kj(t.morph),h=t.colors??[],u=t.steps??[],d=Math.min(10,h.length,u.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=h[0][0],p=h[0][1],m=h[0][2],f=h[0][3];for(let g=1;g<d;g++){let y=u[g-1],v=u[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+=(h[g][0]-c)*b,p+=(h[g][1]-p)*b,m+=(h[g][2]-m)*b,f+=(h[g][3]-f)*b}return[c,p,m,f]}function iEt(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=eT(o.alpha,1);if(!(l<=0))if(o.type==="color"){let h,u=o.color;typeof u=="string"?h=typeof s?.color=="function"?s.color(u):void 0:u&&typeof u.r=="number"&&(h=u),h&&n.push({kind:"color",layer:o,rgb:{...WZ(h.r,h.g,h.b),a:h.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,h=1,u=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]=eEt(c.layer,a,o);({r:p,g:m,b:f}=WZ(v,b,_)),g=x}let y=d?1:Math.min(1,Math.max(0,g*c.alpha));l+=(p-l)*y,h+=(m-h)*y,u+=(f-u)*y,d=!1}return{r:l,g:h,b:u}}}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 g2,eT,Kj,rEt=U(()=>{ot(),g2=new se,eT=(t,e)=>typeof t=="number"&&Number.isFinite(t)?t:e,Kj=t=>Array.isArray(t)&&typeof t[0]=="number"&&typeof t[1]=="number"?[t[0],t[1]]:[0,0]});function sEt(t,e){if(t==="torus"){let l=e()*Math.PI*2,h=e()*Math.PI*2,u=Math.cos(l),d=Math.sin(l),c=Math.cos(h),p=Math.sin(h);return{x:(1.4+.7*c)*u,y:-(1.4+.7*c)*d,z:.7*p,nx:c*u,ny:-c*d,nz:p,cr:1,cg:1,cb:1}}if(t==="cylinder"){let l=e()*Math.PI*2,h=Math.cos(l),u=Math.sin(l);return{x:.8*h,y:1.6*(e()-.5),z:.8*u,nx:h,ny:0,nz:u,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 nEt(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 h=(y,v)=>o?o.getX(3*y+v):3*y+v,u=i?i.elements:null,d=i?new Ms().getNormalMatrix(i).elements:null,c=y=>{let v=r.getX(y),b=r.getY(y),_=r.getZ(y);return u?u[0]*v+u[4]*b+u[8]*_+u[12]:v},p=y=>{let v=r.getX(y),b=r.getY(y),_=r.getZ(y);return u?u[1]*v+u[5]*b+u[9]*_+u[13]:b},m=y=>{let v=r.getX(y),b=r.getY(y),_=r.getZ(y);return u?u[2]*v+u[6]*b+u[10]*_+u[14]:_},f=new Float64Array(l),g=0;for(let y=0;y<l;y++){let v=h(y,0),b=h(y,1),_=h(y,2),x=c(v),S=p(v),w=m(v),T=c(b)-x,C=p(b)-S,M=m(b)-w,A=c(_)-x,P=p(_)-S,O=m(_)-w,D=C*O-M*P,N=M*A-T*O,z=T*P-C*A;g+=.5*Math.sqrt(D*D+N*N+z*z),f[y]=g}return g<=0?null:{total:g,sample:(y,v)=>{let b=0,_=l-1;for(;b<_;){let H=b+_>>1;f[H]<y?b=H+1:_=H}let x=b,S=h(x,0),w=h(x,1),T=h(x,2),C=v(),M=v();C+M>1&&(C=1-C,M=1-M);let A,P,O,D=1-C-M,N=c(S)*D+c(w)*C+c(T)*M,z=p(S)*D+p(w)*C+p(T)*M,k=m(S)*D+m(w)*C+m(T)*M;if(s){if(A=s.getX(S)*D+s.getX(w)*C+s.getX(T)*M,P=s.getY(S)*D+s.getY(w)*C+s.getY(T)*M,O=s.getZ(S)*D+s.getZ(w)*C+s.getZ(T)*M,d){let H=d[0]*A+d[3]*P+d[6]*O,rt=d[1]*A+d[4]*P+d[7]*O,it=d[2]*A+d[5]*P+d[8]*O;A=H,P=rt,O=it}}else{let H=c(S),rt=p(S),it=m(S),ft=c(w)-H,dt=p(w)-rt,K=m(w)-it,lt=c(T)-H,_t=p(T)-rt,xt=m(T)-it;A=dt*xt-K*_t,P=K*lt-ft*xt,O=ft*_t-dt*lt}let B=Math.sqrt(A*A+P*P+O*O)||1,V=1,q=1,W=1;if(a)V=a.getX(S)*D+a.getX(w)*C+a.getX(T)*M,q=a.getY(S)*D+a.getY(w)*C+a.getY(T)*M,W=a.getZ(S)*D+a.getZ(w)*C+a.getZ(T)*M;else if(t.sampleColor){let H=n?n.getX(S)*D+n.getX(w)*C+n.getX(T)*M:.5,rt=n?n.getY(S)*D+n.getY(w)*C+n.getY(T)*M:.5,it=t.sampleColor(H,rt);it&&(V=it.r,q=it.g,W=it.b)}return{x:N,y:z,z:k,nx:A/B,ny:P/B,nz:O/B,cr:V,cg:q,cb:W}}}}function qZ(t){let e=Math.min(Math.max(1,Math.floor(t.guideStrands)),Sv),i=function(l){let h=l>>>0;return()=>{h|=0,h=h+1831565813|0;let u=Math.imul(h^h>>>15,1|h);return u=u+Math.imul(u^u>>>7,61|u)^u,((u^u>>>14)>>>0)/4294967296}}(t.seed??1337),r=t.shape==="object"&&t.sampler,s=r?t.samplerRadius??Lh:Lh,n=new Float32Array(4*ic),a=new Float32Array(ic),o=new Float32Array(4*Sv).fill(1);for(let l=0;l<e;l++){let h=r?t.sampler(i):sEt(t.shape,i),u=r?h.x:h.x*s,d=r?h.y:h.y*s,c=r?h.z:h.z*s,{nx:p,ny:m,nz:f}=h;o[4*l+0]=h.cr,o[4*l+1]=h.cg,o[4*l+2]=h.cb;let g,y,v,b=l*Tg,_=(1.8+.8*i())*t.hairLength*s/(Tg-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<Tg;T++){let C=T/(Tg-1),M=C*C*.4*s,A=S*Math.sin(C*x*Math.PI*2),P=4*(b+T);n[P+0]=u+p*_*T+A*g/w,n[P+1]=d+m*_*T-M+A*y/w,n[P+2]=c+f*_*T+A*v/w,n[P+3]=T===0?0:1,T<Tg-1&&(a[b+T]=_)}}return{initialPositions:n,restLengths:a,unitScale:s,rootColors:o}}var Tg,Sv,ic,Lh,Wp,T_,K0,uf,Z0,vR,Oyt=U(()=>{ot(),ic=(Sv=16384)*(Tg=32),Lh=100}),Iyt=U(()=>{ot(),na(),GW(),rEt(),Oyt(),Wp=1/60,T_=new bt,K0=new we,uf=new E,Z0=new E,vR=class extends Ks{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 we,this.lastBonePos=new E,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 ve(new Float32Array(0),3)),this.material=new jo({colorWrite:!1,depthWrite:!1}),this.frustumCulled=!1,this.scalpMesh=new gr(new Ac(Lh,48,32),new jo({color:5448477})),this.scalpMesh.name="HairScalp",this.add(this.scalpMesh);let r=new T4;r.setAttribute("position",new ve(new Float32Array(12),3)),r.setIndex([0,2,1,2,3,1]),r.instanceCount=0,this.ribbonMesh=new gr(r,new jo({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*Wp*2),this.trackMotionRest(t/1e3))}trackMotionRest(t){this.boneTransform(K0,uf);let e=this.hasLastBone&&(Math.abs(this.lastBoneQuat.dot(K0))<.9999995||this.lastBonePos.distanceToSquared(uf)>1e-8),i=this.motionFingerprint(),r=!this.hasLastBone||e||this.resetRequested||i!==this.lastMotionFingerprint||this.data.windStrength>.001;this.lastBoneQuat.copy(K0),this.lastBonePos.copy(uf),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,Ns)}(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=nEt(d);c&&l.push(c)}if(l.length===0)return null;let h=new Float64Array(l.length),u=0;for(let d=0;d<l.length;d++)u+=l[d].total,h[d]=u;return u<=0?null:d=>{let c=d()*u,p=0,m=l.length-1;for(;p<m;){let g=p+m>>1;h[g]<c?p=g+1:m=g}let f=p===0?c:c-h[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 h=o;return qZ({shape:"object",guideStrands:i,hairLength:r,sampler:u=>{let d=a(u);return{...d,x:d.x*h,y:d.y*h,z:d.z*h}},samplerRadius:l})}}}return qZ({shape:t==="object"?"sphere":t,guideStrands:i,hairLength:r})}collectBaseSources(t){let e=[],i=[],r=0,s=0;T_.copy(t.matrixWorld).invert();let n=T_.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 h=o===t?void 0:new bt().multiplyMatrices(n,o.matrixWorld),u=Array.isArray(o.material)?o.material[0]:o.material;e.push({geometry:l,matrix:h,sampleColor:iEt(u,this.context.shared)??void 0}),i.push(vR.matrixHash(h)),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(eT(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(eT(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}(u,this.context.shared),l.boundingSphere===null&&l.computeBoundingSphere();let d=l.boundingSphere;if(d){let c=0,p=1;h?(uf.copy(d.center).applyMatrix4(h),c=uf.length(),p=vR.matrixMaxScale(h)):c=d.center.length(),r=Math.max(r,c+d.radius*p)}}for(let h of o.children)a(h)};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 T_.copy(t.matrixWorld).decompose(uf,K0,Z0),Math.max(Math.abs(Z0.x),Math.abs(Z0.y),Math.abs(Z0.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 S4(1.4*Lh,.7*Lh,24,48):t==="cylinder"?new eS(.8*Lh,.8*Lh,1.6*Lh,48,1):new Ac(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)}T_.copy(i).decompose(e,t,Z0)}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(K0,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?.(),Yj()?.release(this)}}});function bR(){return{shapeInput:()=>`
|
|
388
388
|
const float posRowCoord = ${.5/dc};
|
|
389
389
|
const float quatRowCoord = ${1.5/dc};
|
|
390
390
|
const float param1RowCoord = ${2.5/dc};
|
|
@@ -1581,7 +1581,7 @@ function sortWorker(self) {
|
|
|
1581
1581
|
gl_FragColor = vec4(color.rgb, A);
|
|
1582
1582
|
gVelocity = vec4(0.0);
|
|
1583
1583
|
}`,transparent:!0,alphaTest:1,blending:Ql,depthTest:!0,depthWrite:!1,side:Xs})}static buildGeomtery(t){let e=new fe;e.setIndex([0,1,2,0,2,3]);let i=new Float32Array(12),r=new ve(i,3);e.setAttribute("position",r),r.setXYZ(0,-1,-1,0),r.setXYZ(1,-1,1,0),r.setXYZ(2,1,1,0),r.setXYZ(3,1,-1,0),r.needsUpdate=!0;let s=new T4().copy(e),n=new Uint32Array(t),a=new co(n,1,!1);return a.setUsage($h),s.setAttribute("splatIndex",a),s.instanceCount=t,s}resetLocalSplatDataAndTexturesFromSplatBuffer(){this.updateLocalSplatDataFromSplatBuffer(),this.allocateAndStoreLocalSplatDataInTextures()}updateLocalSplatDataFromSplatBuffer(){this.splatBuffers.forEach(r=>r.buildPreComputedBuffers()),this.covariances=new Float32Array(6*this.splatCount),this.colors=new Uint8Array(4*this.splatCount),this.centers=new Float32Array(3*this.splatCount);let t=0,e=0,i=0;for(let r of this.splatBuffers){let s=r.nsplats;this.colors.subarray(t,t+4*s).set(r.colorsA),t+=4*s,this.centers.subarray(e,e+3*s).set(r.decoded.xyz.denormDequant().data),e+=3*s,this.covariances.subarray(i,i+6*s).set(new Float32Array(r.precomputedCovarianceBufferData)),i+=6*s}}allocateAndStoreLocalSplatDataInTextures(){let t=this.splatCount,e=new Y(4096,1024);for(;e.x*e.y*2<6*t;)e.y*=2;let i,r,s=new Y(4096,1024);for(;s.x*s.y*4<4*t;)s.y*=2;if(this.halfPrecisionCovariancesOnGPU){r=new Uint16Array(e.x*e.y*2);for(let h=0;h<this.covariances.length;h++)r[h]=Xh.toHalfFloat(this.covariances[h]);i=new yr(r,e.x,e.y,Bo,si)}else r=new Float32Array(e.x*e.y*2),r.set(this.covariances),i=new yr(r,e.x,e.y,Bo,Ye);i.needsUpdate=!0,this.material.uniforms.covariancesTexture.value=i,this.material.uniforms.covariancesTextureSize.value.copy(e);let n=new Uint32Array(s.x*s.y*4);for(let h=0;h<t;h++){let u=4*h,d=3*h,c=4*h;n[c]=p1t(this.colors[u],this.colors[u+1],this.colors[u+2],this.colors[u+3]),n[c+1]=SR(this.centers[d]),n[c+2]=SR(this.centers[d+1]),n[c+3]=SR(this.centers[d+2])}let a=new yr(n,s.x,s.y,CG,En);h5()!=="webgpu"&&(a.internalFormat="RGBA32UI"),a.needsUpdate=!0,this.material.uniforms.centersColorsTexture.value=a,this.material.uniforms.centersColorsTextureSize.value.copy(s);let o=new Float32Array(4096);for(let h=0;h<this.meshMatrixWorlds.length;h++)o.set(this.meshMatrixWorlds[h].elements,16*h);let l=new yr(o,1024,1,hn,Ye);l.needsUpdate=!0,this.material.uniforms.meshMatrixWorldsTexture.value=l,this.material.uniformsNeedUpdate=!0,this.splatDataTextures={covariances:{data:r,texture:i,size:e},centerColors:{data:n,texture:a,size:s},meshMatrixWorlds:{data:o,texture:l}}}updateIndexes(t){let e=this.geometry;e.attributes.splatIndex.set(t),e.attributes.splatIndex.needsUpdate=!0,e.instanceCount=t.length}updateUniforms(t,e,i,r){this.splatCount>0&&(E_.set(t.x*this.devicePixelRatio,t.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(E_),this.material.uniforms.basisViewport.value.set(2/E_.x,2/E_.y),this.material.uniforms.focal.value.set(e,i),this.material.uniforms.orthoZoom.value=r,this.material.uniformsNeedUpdate=!0)}getSplatDataTextures(){return this.splatDataTextures}getSplatCount(){return this.splatCount}getCenters(){return this.centers}getColors(){return this.colors}getCovariances(){return this.covariances}dispose(){this.geometry.dispose(),this.material.dispose(),this.splatDataTextures&&(this.splatDataTextures.covariances.texture.dispose(),this.splatDataTextures.centerColors.texture.dispose(),this.splatDataTextures.meshMatrixWorlds.texture.dispose()),this.removeFromParent()}}});function OEt(){if(!n9)return aQ||(aQ=async function(){let t=await Promise.resolve().then(()=>($H(),HH));g1t(t),n9=!0}())}var g1t,y1t,n9,aQ,oQ,v1t,b1t,aB,Vg,_1t=U(()=>{y1t=new Promise(t=>{g1t=t}),n9=!1}),IEt=U(()=>{REt(),ot(),f1t(),_1t(),y1t.then(t=>oQ=t),v1t=class{constructor(t={}){pc(this,"updateView",function(){let e=new bt,i=[],r=new E(0,0,-1),s=new E(0,0,-1),n=new E,a=new E;return function(o=!1,l){let h=this.updateMatrixWorldsInWorkerIfNeeded(),u=this.cropsChanged();if(!o){s.set(0,0,-1).applyQuaternion(l.quaternion);let c=!1,p=!1;if(s.dot(r)<=.95&&(c=!0),a.copy(l.position).sub(n).length()>=1&&(p=!0),!(c||p||h||u||this.needsInitialRender))return}this.needsInitialRender=!1,n.copy(l.position),r.copy(s),e.copy(l.matrixWorld).invert(),e.premultiply(this.dummyPerspectiveMatrix),i[0]=l.position.x,i[1]=l.position.y,i[2]=l.position.z;let d={sort:{view:e.elements,cameraPosition:i,splatRenderCount:this.splatRenderCount,splatSortCount:this.splatRenderCount},...h?{newMatrixWorlds:this.meshMatrixWorlds}:{},...u?{newCropsArray:this.cropsArray}:{}};this.sortRunning?this.queuedMessage=d:(this.queuedMessage=null,this.sortRunning=!0,this.sortWorker.postMessage(d))}}()),this.scene=t.scene,this.currentPage=null,this.devicePixelRatio=window.devicePixelRatio,this.sortWorker=null,this.splatRenderCount=0,this.splatSortCount=0,this.splatMesh=null,this.sortRunning=!1,this.meshMatrixWorlds=null,this.meshMatrixWorldsOld=null,this.cropsArray=null,this.splatEntries=null,this.queuedMessage=null,this.needsInitialRender=!0,this.dummyPerspectiveMatrix=new bt().makePerspective(-1,1,-1,1,.1,1e3)}updateSplatMeshUniforms(t,e){let i=new Y;this.splatMesh!==null&&this.splatMesh.getSplatCount()>0&&(t.getSize(i),this.cameraFocalLengthX=e.projectionMatrix.elements[0]*this.devicePixelRatio*i.x*.45,this.cameraFocalLengthY=e.projectionMatrix.elements[5]*this.devicePixelRatio*i.y*.45,this.splatMesh.updateUniforms(i,this.cameraFocalLengthX,this.cameraFocalLengthY,e.isPerspectiveCamera?-1:e.zoom*this.devicePixelRatio))}loadSplat(t={}){this.activePage=this.scene.activePage,t.position&&(t.position=new E().fromArray(t.position)),t.orientation&&(t.orientation=new we().fromArray(t.orientation)),t.halfPrecisionCovariances=!!t.halfPrecisionCovariances;let e=[];if(this.splatEntries=e,this.activePage.traverseVisibleEntity(n=>{n.data.type==="Splat"&&e.push(n)}),this.splatMesh&&this.splatMesh.dispose(),e.length===0)return this.splatMesh=null,!1;this.meshMatrixWorlds=e.map(n=>n.matrixWorld),this.meshMatrixWorldsOld=e.map(n=>n.matrixWorld.clone()),this.cropsArray=e.map(n=>n.data.crops.map(a=>a.data)),this._splatBufferCache??(this._splatBufferCache=new WeakMap);let i=e.map(n=>{let a=this._splatBufferCache.get(n.data.buffer);return a===void 0&&(a=new oQ.GSplineBuffer(new Uint8Array(n.data.buffer).buffer),this._splatBufferCache.set(n.data.buffer,a)),a}),r=0,s=[0];for(let n of i)r+=n.getSplatCount(),s.push(r);return this.setupSplatMesh(i,r,t.position,t.orientation,t.halfPrecisionCovariances,this.devicePixelRatio,s,this.meshMatrixWorlds),this.setupSortWorker(r),!0}updateMatrixWorldsInWorkerIfNeeded(){let t=this.splatDataTextures.meshMatrixWorlds.data;for(let e=0;e<this.meshMatrixWorlds.length;e++)t.set(this.meshMatrixWorlds[e].elements,16*e);return this.splatDataTextures.meshMatrixWorlds.texture.needsUpdate=!0,!this.meshMatrixWorlds.every((e,i)=>e.equals(this.meshMatrixWorldsOld[i]))&&(this.meshMatrixWorldsOld=this.meshMatrixWorlds.map(e=>e.clone()),!0)}cropsChanged(){let t=!1;return this.splatEntries.forEach((e,i)=>{e.data.crops.forEach((r,s)=>{this.cropsArray[i][s]===void 0?(t=!0,this.cropsArray[i][s]=r.data):Object.entries(r.data).forEach(([n,a])=>{(Array.isArray(a)&&a.some((o,l)=>o!==this.cropsArray[i][s][n][l])||a!==this.cropsArray[i][s]?.[n])&&(t=!0,this.cropsArray[i][s][n]=a)})}),e.data.crops.length!==this.cropsArray[i]?.length&&(this.cropsArray[i].length=e.data.crops.length,t=!0)}),t}setupSplatMesh(t,e,i=new E,r=new we,s=!1,n=1,a,o){this.splatMesh=S2.buildMesh(t,e,s,n,a,o),this.splatMesh.position.copy(i),this.splatMesh.quaternion.copy(r),this.splatMesh.frustumCulled=!1,this.splatMesh.renderOrder=99999,this.splatRenderCount=e,this.splatMesh.onBeforeRender=(l,h,u)=>this.update(l,u),this.splatMesh.runBeforeRenderWhenBundled=!0}setupSortWorker(t){this.sortWorker=function(e){let i=new Worker(URL.createObjectURL(new Blob(["(",c1t,")(self)"],{type:"application/javascript"}))),r=atob(d1t),s=new Uint8Array(r.length);for(let n=0;n<r.length;n++)s[n]=r.charCodeAt(n);return i.postMessage({init:{sorterWasmBytes:s.buffer,splatCount:e,Constants:{BytesPerFloat:hm.BytesPerFloat,BytesPerInt:hm.BytesPerInt,DepthMapRange:hm.DepthMapRange,MemoryPageSize:hm.MemoryPageSize}}}),i}(t),this.sortWorker.onmessage=e=>{e.data.sortDone?(this.sortRunning=!1,this.splatMesh?.updateIndexes(new Uint32Array(e.data.indexesBuffer)),this.lastSortTime=e.data.sortTime,this.queuedMessage&&(this.sortWorker.postMessage(this.queuedMessage),this.queuedMessage=null)):e.data.sortCanceled?this.sortRunning=!1:e.data.sortSetupPhase1Complete?this.sortWorker.postMessage({positions:this.splatMesh.getCenters().buffer,meshMatrixWorlds:this.splatMesh.meshMatrixWorlds,meshIndexIntervals:this.splatMesh.meshIndexIntervals,cropsArray:this.cropsArray}):e.data.sortSetupComplete&&(this.splatDataTextures=this.splatMesh.getSplatDataTextures(),this.scene.activePage.add(this.splatMesh),this.needsInitialRender=!0)}}update(t,e){this.splatMesh!==null&&(this.updateSplatMeshUniforms(t,e),this.updateView(!1,e))}getSplatMesh(){return this.splatMesh}}}),tq=U(()=>{ot(),Kh(),yo(),Pm(),De(),n1t(),Li(),LW(),NW(),na(),AT(),AEt(),bD(),vo(),Jr(),rh(),Jyt(),Jr(),dn(),ob(),CEt(),IEt(),(b1t=new jo).wireframe=!0,aB=new E,Vg=class extends $u{constructor(t,e){super(),this.data=t,this.sharedAssets=e,this.enableHelpers=!1,this.wireframeState=!1,this.needsTransmissionDirty=!0,this.needsNormalDirty=!0,this.needsReflectionDirty=!0,this._needsTransmission=!1,this._needsNormal=!1,this._normalPassNeeds={outline:!1,cavity:!1},this._needsReflection=!1,this.geometryCacheChanged=!1,this.splatViewer=null,this.shapeBlendIntances=[],this.hairInstances=[],this.shadowsDirty=!0,this.instanceGroupsDirty=!0,this._autoInstancing=null,this.entityByUuid={},this.entityIdentityToEntity={},this.toExpandCloner=new Set,this.toUpdateCloner=new Set,this.pendingCommands=[],this.pathConstraints=new u1t,this.invisibleObjects=new ku("jflkdsafjasdifjaslk",{...H4.defaultData,visible:!1,name:"buildin invisible"}),this.needsRecomputeInstances=!1,this.init(t,e),this.matrixAutoUpdate=!1,this.errorPage=new Or("fdasfa",{...Hg.defaultData,name:""},{shared:e,scene:this})}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markShadowsDirty(){this.shadowsDirty=!0}markInstanceGroupsDirty(){this.instanceGroupsDirty=!0}get autoInstancing(){return this._autoInstancing}updateInstanceGroups(t,e){let i=this._autoInstancing;(i===null||i.minGroupSize!==e)&&(i?.dispose(),i=new s1t(e),this._autoInstancing=i);let r=this.instanceGroupsDirty;return this.instanceGroupsDirty=!1,i.update(t,r),i.stats}releaseInstanceGroups(){this._autoInstancing?.teardown(),this.instanceGroupsDirty=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0,this.needsReflectionDirty=!0,this.shadowsDirty=!0,this.instanceGroupsDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=function(t){let e=!1;return t.traverseEntity(i=>{if(i instanceof go)if(Array.isArray(i.material))for(let r=0;r<i.material.length;r++)UZ(i,i.material[r])&&(e=!0);else UZ(i,i.material)&&(e=!0)}),e}(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._normalPassNeeds=function(t){let e={outline:!1,cavity:!1},i=r=>{e.outline=e.outline||r.outline,e.cavity=e.cavity||r.cavity};return t.traverseEntity(r=>{if(r instanceof go)if(Array.isArray(r.material))for(let s=0;s<r.material.length;s++)i(FZ(r,r.material[s]));else i(FZ(r,r.material))}),e}(this),this._needsNormal=this._normalPassNeeds.outline||this._normalPassNeeds.cavity,this.needsNormalDirty=!1),this._needsNormal}normalPassNeeds(){return this.needsNormal(),this._normalPassNeeds}needsReflection(){return this.needsReflectionDirty&&(this._needsReflection=function(t){let e=!1;return t.traverseEntity(i=>{if(i instanceof go)if(Array.isArray(i.material))for(let r=0;r<i.material.length;r++)jZ(i,i.material[r])&&(e=!0);else jZ(i,i.material)&&(e=!0)}),e}(this),this.needsReflectionDirty=!1),this._needsReflection}registerInstanceAndSetUuid(t){let e=t.identity.join("-"),i=this.entityIdentityToEntity[e];i&&(t.uuid=i.uuid),this.entityIdentityToEntity[e]=t,this.entityByUuid[t.uuid]=t}markPenumbraSizeDirty(){for(let t of this.children)t instanceof Or&&(t.penumbraSizeArrayCache=null)}findInstance(t){return this.entityIdentityToEntity[t.join("-")]}findInInstance(t,e){let i=e??null;if(!vi.is(i))return;let r=i.data.type==="Instance";if(!r&&!i.isVirtualEntity)return;let s=typeof i.identity=="string"?[i.identity]:i.identity;for(let n=s.length-(r?0:1);n>=1;n--){let a=this.findInstance([...s.slice(0,n),t]);if(a)return a}for(let n=i;vi.is(n);n=n.parent)if(n.data.type==="Instance"&&n.data.component===t)return n}findFrom(t,e){return this.findInInstance(t,e)??this.find(t)}syncInstancePathConstraint(t){let e=t.data.pathSnapping?.pathId;if(e){let i=this.findFrom(e,t);this.pathConstraints.setConstraint(t.uuid,i?.uuid??e)}else this.pathConstraints.removeDependencies(t.uuid)}get bgColor(){return this.activePage.bgColor}get postprocessing(){return this.activePage.data.postprocessing}getWithSortKey(t){let e=this.find(t);if(e===void 0)return;let i=[],r=e;for(;r!==this;){let s=r;r=r.parent;let n=r.children.indexOf(s);i.splice(0,0,n)}return{entity:e,sortKey:i}}getAllSorted(t){let e=[];for(let i of t){let r=this.getWithSortKey(i.id);r!==void 0&&e.push(r)}return e.sort((i,r)=>M4(i.sortKey,r.sortKey)),e.map(i=>i.entity)}nonExistOrDescendantOf(t,e){let i=this.find(t);if(i===void 0)return!0;for(;i;){if(i.uuid===e)return!0;i=i.parent}return!1}find(t){if(this.activePage&&this.activePage.personalCamera.parent){if(t==="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera")return this.activePage.personalCamera;if(t===l0)return this.activePage.personalCamera}if(t===""||t===void 0)return;let e=this.entityByUuid[t];return e===void 0?this.getObjectByProperty("uuid",t):e}find2D(t){for(let e of this.children)if(e instanceof Or&&e.uiScene){let i=e.uiScene.find(t);if(i)return i}}findScene2DfromObject2D(t){for(let e of this.children)if(e instanceof Or&&e.uiScene&&e.uiScene.find(t))return e.uiScene}find2DInUIObjects(t){let e;return this.traverseEntity(i=>{e===void 0&&$a(i)&&(e=i.uiCanvas.find(t))}),e}traverse2D(t){for(let e of this.children)e instanceof Or&&e.uiScene&&e.uiScene.traverse(t)}debugEnsureEntity(t){let e=this.find(t);e?Array.isArray(e.identity)&&this.findInstance(e.identity)===void 0&&console.error("not found instance"):console.error("not found")}addPendingExpandCloner(t){this.toExpandCloner.add(t)}addPendingUpdateCloner(t){this.toUpdateCloner.add(t)}markToExpandCloner(t){this.toExpandCloner.add(t),t.traverseEntityAncestors(e=>{this.toExpandCloner.add(e)})}doPendingExpandCloner(t){this.toExpandCloner.forEach(e=>{e.expandCloner(t)}),this.toExpandCloner.clear()}doPendingUpdateCloner(t){this.toUpdateCloner.forEach(e=>{e.cloner?.update(t)}),this.toUpdateCloner.clear()}doPendingUpdates(t){this.doPendingExpandCloner(t),this.doPendingUpdateCloner(t),this.applyPendingCommands()}addPendingCommand(t){this.pendingCommands.push(t)}applyPendingCommands(){this.pendingCommands.forEach(t=>t()),this.pendingCommands.length=0}updateByLibOp(t,e){t.path.length===1&&t.path[0]==="components"&&t.type===1&&this.createChildrenObjects([{...t.data.asset,id:t.id}],this.invisibleObjects,e)}updateTreeByOp(t,e){if(t.path.length===0&&t.type===7){let i=t.parent===null?this:this.find(t.parent);if(i===void 0)throw new Error(`scene tree add: parent ${t.parent} not found for object ${t.id}`);let r=this.createObject(t.id,t.data,t.children,i,t.localIndex,e);r.updateVisible(this),r.resetBBoxNeedsUpdate(),Wh(r)&&Wu(r.parent)&&(r.invalidateUpstreamBooleanData(),r.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(i),this.markNeedsRecomputeInstancesForChildren(r),this.markToExpandCloner(r),this.markPenumbraSizeDirty(),r.updatePathSnapping()}else if(t.path.length===0&&t.type===8){let i=this.find(t.id);if(i===void 0)throw new Error(`scene tree delete: object ${t.id} not found`);i.traverseEntity(s=>{Dc(s)&&(this.shapeBlendIntances=this.shapeBlendIntances.filter(n=>n!==s)),n0(s)&&(this.hairInstances=this.hairInstances.filter(n=>n!==s))}),this.markToExpandCloner(i),i.resetBBoxNeedsUpdate(),this.unregisterObject(i);let r=i.parent;this.markNeedsRecomputeInstancesForAncessors(r),this.markNeedsRecomputeInstancesForChildren(i),this.markPenumbraSizeDirty(),i.parent.remove(i),Wu(i.parent)&&(i.parent.invalidateUpstreamBooleanData(),i.parent.invalidateDownstreamBooleanData().recomputeBoolean()),Wh(i)&&(i.freeBooleanPointer(),r instanceof vm&&r.invalidateDownstreamBooleanData().recomputeBoolean()),fD(i)&&i.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(i),this.pathConstraints.removeDependencies(i.uuid),i.updatePathSnapping()}else if(t.path.length===0&&t.type===9){let i=this.find(t.id);if(i===void 0)throw new Error(`scene tree move: object ${t.id} not found`);this.markNeedsRecomputeInstancesForChildren(i);let r=i.parent;this.markNeedsRecomputeInstancesForAncessors(r),i.cloner?.resetOnMove(),this.markToExpandCloner(i);let s=t.parent===null?this:this.find(t.parent);if(s===void 0)throw new Error(`scene tree move: new parent ${t.parent} not found for object ${t.id}`);s.add(i),this.markNeedsRecomputeInstancesForAncessors(s),this.markToExpandCloner(i),i.invalidateClonerTransform(i),i.updateVisible(this),i.resetBBoxNeedsUpdate(),this.markPenumbraSizeDirty();let n=t.localIndex;s.children.splice(n,0,s.children.pop()),Wh(i)&&(i.invalidateUpstreamBooleanData(),Wu(i.parent)?i.parent.invalidateDownstreamBooleanData().recomputeBoolean():r instanceof vm&&r.invalidateDownstreamBooleanData().recomputeBoolean()),i.updatePathSnapping()}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}get playPage(){return this.find(this.data.publish.playPage)??this.errorPage}updatePage(t){this.shadowsDirty=!0,this.activePage&&this.activePage.onDeactive(),this.activePage=this.errorPage;for(let e of this.children)e instanceof Or&&(e.visible=e.uuid===t,e.visible&&(this.activePage=e,this.activePage.onActive(this)));this.activePage!==this.splatViewer?.activePage&&this.reloadSplats()}updateEntityByOp(t,e,i,r){if(this.shadowsDirty=!0,e.type===0){if(("overrides"in e.props||"component"in e.props)&&this.markNeedsRecomputeInstances(),"visible"in e.props&&this.markPenumbraSizeDirty(),e.path.includes("overrides")&&"states"in e.props){let{rest:n}=e.props;e={...e,props:n},this.markNeedsRecomputeInstances()}e.path[0]==="pathSnapping"&&e.props.pathId!==void 0&&this.pathConstraints.setConstraint(t,e.props.pathId)}let s=this.find(t);if(s)try{(function(n,a,o,l){n.updateByOp(a,o,l,!1)})(s,e,i,{scene:this,shared:r}),s instanceof wr&&s.updateGeometryGroupsIfNeeded()}catch(n){console.error(n)}}updateEntity2DByOp(t,e,i,r,s,n=[]){t.updateEntityByOp(e,i,r,s),this.traverseEntity(a=>{($a(a)||a instanceof Or)&&(n.includes(a.frameId??"")||a.frameId===e)&&a.updateEntity2DByOp(e,i,r,s)})}get activeCamera(){return this.activePage.activeCamera}switchActiveCamera(t){this.activePage.switchActiveCamera(t)}isInvisibleObjects(t){return t===this.invisibleObjects||t.hasAnccestor(this.invisibleObjects)}init(t,e){let i=Object.entries(e.data.lib.components).map((r,s)=>({data:r[1].asset.data,children:r[1].asset.children,id:r[0],fi:s}));this.invisibleObjects.updateState(this.invisibleObjects.data,{scene:this,shared:e}),this.add(this.invisibleObjects),this.createChildrenObjects(i,this.invisibleObjects,e),this.createChildrenObjects(t.objects,this,e),this.updatePage(t.publish.playPage),this.activePage.switchToPlayCamera(),this.expandInstances(e,!0),this.traverseEntity(r=>{r instanceof zs&&r.updateUp()}),this.doPendingExpandCloner({scene:this,shared:e}),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(t){t.traverseEntity(e=>{(e.data.type==="Component"||e.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(t){vi.is(t)&&(t.data.type==="Component"&&this.markNeedsRecomputeInstances(),t.traverseAncestors(e=>{vi.is(e)&&e.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(t,e,i,r,s,n,a){if(t){let o=r.find(t);o&&o!==r&&s.forInstancesRec(l=>{l.data=E4(l.data,h=>{let u=h.events.data(a.id),d=l.goUp(n);if(d){let c=[...mft(d.identity),t].join("-"),p=this.entityIdentityToEntity[c];if(p){let m=p.uuid;Dn.zoom(u,e)[i]=m}else console.warn("cannot find instance")}}).data})}}rewriteActions(t,e,i,r,s,n){t.forEach(a=>{a.data.type==="Transition"||a.data.type==="Animation"&&a.data.object?this.relativeizeInner(a.data.object,[...e,a.id],"object",i,r,s,n):a.data.type==="Conditional"&&(this.rewriteActions(a.data.ifActions,[...e,a.id,"ifActions"],i,r,s,n),this.rewriteActions(a.data.elseActions,[...e,a.id,"elseActions"],i,r,s,n))})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(t=>{if(uR(t)&&typeof t.identity=="string"&&t.data.type==="Component")return t.traverseEntity((e,i)=>{e.data.events.forEach(r=>{if(r.data.type==="GameControl"){let s=!1;if(e.forInstancesRec(n=>{n.data=E4(n.data,a=>{n.isInstanceRoot||(a.events.delete(r.id),s=!0)}).data}),s===!1)for(let n of K4.list)this.rewriteActions(r.data.gameActions[n],["gameActions",n],t,e,i,r)}else r.data.type==="Conditional"?(r.data.condition.type==="Distance"?(this.relativeizeInner(r.data.condition.fromObject,["condition"],"fromObject",t,e,i,r),this.relativeizeInner(r.data.condition.toObject,["condition"],"toObject",t,e,i,r)):r.data.condition.type==="State"?this.relativeizeInner(r.data.condition.object,["condition"],"object",t,e,i,r):r.data.condition.type==="Comparison"&&(r.data.condition.lOperand.type==="Property"&&this.relativeizeInner(r.data.condition.lOperand.value[0],["condition","lOperand","value"],0,t,e,i,r),r.data.condition.rOperand.type==="Property"&&this.relativeizeInner(r.data.condition.rOperand.value[0],["condition","rOperand","value"],0,t,e,i,r)),this.rewriteActions(r.data.inActions,["inActions"],t,e,i,r),this.rewriteActions(r.data.outActions,["outActions"],t,e,i,r)):"actions"in r.data&&this.rewriteActions(r.data.actions,["actions"],t,e,i,r)})}),!0})}expandInstances(t,e,i){let r=new Set;this.traverseEntity(s=>{if(uR(s)&&s.isInstanceRoot)return s.expandInstanceChildren({scene:this,shared:t,pendingDeletes:r}),e||s.resetBBoxNeedsUpdate(),i&&s.traverseEntity(n=>{i.addClip(n)}),!0});for(let s of r)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(s),KW(s)}recomputeInstances(t,e){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(i=>{uR(i)&&i.isInstanceRoot&&(i.component=void 0)}),this.expandInstances(t,!1,e))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(t){t.traverseEntity(e=>{let i=typeof e.identity=="string"?e.identity:e.identity.join("-");this.entityIdentityToEntity[i]===e&&(delete this.entityByUuid[e.uuid],delete this.entityIdentityToEntity[i],this.pathConstraints.removeDependencies(e.uuid)),e.dispose()})}clearScene(){this._autoInstancing?.dispose(),this._autoInstancing=null,this.instanceGroupsDirty=!0;for(let t of this.children)vi.is(t)&&t.disposeRecursively();this.children.length=0}resetAfterClear(t,e){this.init(t,e)}raycast(t){return this.raycast1(t,!1)}raycast1(t,e){let i=[],r=s=>{for(let n of s.children){let a=n.cloner;if(vi.is(n)&&!n.raycastLock&&(n.visible||a?.object.data.visible))if(e===!0&&n.isInstanceRoot){let o=[];if(t.intersectObject(n,!0,o),o.length){let l=o[0];l.object=n,l.point.applyMatrix4(l.object.matrixWorld);let h=n.matrixWorld.clone().invert();l.point.applyMatrix4(h),i.push(l)}}else(Wh(n)||p5(n)&&this.enableHelpers&&n.objectHelper.visible)&&(t.intersectObject(n,!1,i),Hj(n,t,i)),r(n)}};return r(this.activePage),i}raycastWithClones(t){let e=[],i=r=>{for(let s of r.children){let n=s.cloner;vi.is(s)&&(s.visible||n?.object.data.visible)&&((Wh(s)||p5(s)&&this.enableHelpers&&s.objectHelper.visible)&&(t.intersectObject(s,!1,e),Hj(s,t,e,!0)),i(s))}};return i(this),e}forEachEntity(t){for(let e of this.children)vi.is(e)&&t(e)}traverseConcreteEntity(t){for(let e of this.children)vi.is(e)&&e.isConcreteEntity&&e.traverseEntity(t)}traverseEntity(t){for(let e of this.children)vi.is(e)&&e.traverseEntity(t)}updateFont(t,e){this.traverseEntity(i=>{if(i instanceof wr&&i.data.type==="Mesh"&&(i.data.geometry.type==="TextGeometry"||i.data.geometry.type==="InputGeometry")&&i.data.geometry.font===t){let r=i.geometry,s=i.data.geometry;r.updateFont(t,e).then(()=>{r.update(s,e);let n=i.invalidateDownstreamBooleanData();Wu(n)&&n.recomputeBoolean()})}})}traverseObject(t){for(let e of this.children)Ng.is(e)&&e.traverseObject(t)}traverseVisibleEntity(t){for(let e of this.children)vi.is(e)&&e.visible&&e.traverseVisibleEntity(t)}dispose(){this.clearScene()}createChildrenObjects(t,e,i){let r=0;for(let s of t)this.createObject(s.id,s.data,s.children,e,r,i),r+=1}registerObjectCreatedInLegacy(t){this.entityByUuid[t.uuid]=t}unregisterObject(t){delete this.entityByUuid[t.uuid];for(let e of t.children)this.unregisterObject(e)}createObject(t,e,i,r,s,n){let a={scene:this,shared:n},o=JW(t,e,a);return Dc(o)&&this.shapeBlendIntances.push(o),n0(o)&&this.hairInstances.push(o),o&&(this.entityByUuid[t]=o,r.add(o),r.children.splice(s,0,r.children.pop()),i.length>0&&(o.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(i,o,n)),o.updateState(e,a),o instanceof wr&&o.updateGeometryGroupsIfNeeded(),o.updateVisible(this),o.cloner&&this.toExpandCloner.add(o),e.pathSnapping?.pathId&&this.pathConstraints.setConstraint(t,e.pathSnapping.pathId)),e.type==="Empty"&&e.animations&&o.traverseEntity(l=>{let h=l.dataPatched;if(l instanceof wr&&h.bones&&h.boneInverses){let u=h.bones.map(p=>this.find(p)),d=h.boneInverses.map(p=>new bt().fromArray(p)),c=new zS(u,d);l.bind(c,l.bindMatrix)}else l.matrixAutoUpdate=!0}),o}getCenter(t){let e=[];for(let r=0,s=t.length;r<s;++r){let{id:n,recursive:a}=t[r],o=this.find(n),l=a?o.recursiveBBox:o.singleBBox;e.push(...l.vertices)}let i=new dr;return i.setFromPoints(e),i.getCenter(aB),aB}copyMatrixWorld(t,e){if(t===null)return void e.identity();let i=this.find(t);i?(i.updateWorldMatrix(!0,!1),e.copy(i.matrixWorld)):e.identity()}copyParentMatrixWorld(t,e){if(t===null)return void e.identity();let i=this.find(t)?.parent;i?(i.updateWorldMatrix(!0,!1),e.copy(i.matrixWorld)):e.identity()}traverseMaterial(t){this.traverseEntity(e=>{if(e instanceof Ks)if(Array.isArray(e.material))for(let i of e.material)d5(i)&&t(i);else d5(e.material)&&t(e.material)})}updateViewPlaneSize(t,e,i=!1){this.traverseConcreteEntity(r=>{r instanceof zs&&r.setViewplaneSize(t,e,i)})}initializeSplatViewer(){this.splatViewer=new v1t({scene:this}),this.reloadSplats()}reloadSplats(){this.splatViewer?.loadSplat()}}}),x1t={};function NEt(){let t,e;function i(r,s,n,a,o,l){let h=n.num_points(),u=l.num_components(),d=function(_,x){switch(x){case Float32Array:return _.DT_FLOAT32;case Int8Array:return _.DT_INT8;case Int16Array:return _.DT_INT16;case Int32Array:return _.DT_INT32;case Uint8Array:return _.DT_UINT8;case Uint16Array:return _.DT_UINT16;case Uint32Array:return _.DT_UINT32}}(r,o),c=u*o.BYTES_PER_ELEMENT,p=4*Math.ceil(c/4),m=p/o.BYTES_PER_ELEMENT,f=h*c,g=h*p,y=r._malloc(f);s.GetAttributeDataArrayForAllPoints(n,l,d,f,y);let v,b=new o(r.HEAPF32.buffer,y,f/o.BYTES_PER_ELEMENT);if(c===p)v=b.slice();else{v=new o(g/o.BYTES_PER_ELEMENT);let _=0;for(let x=0,S=b.length;x<S;x++){for(let w=0;w<u;w++)v[_+w]=b[x*u+w];_+=m}}return r._free(y),{name:a,count:h,itemSize:u,array:v,stride:m}}onmessage=function(r){let s=r.data;switch(s.type){case"init":t=s.decoderConfig,e=new Promise(function(o){t.onModuleLoaded=function(l){o({draco:l})},DracoDecoderModule(t)});break;case"decode":let n=s.buffer,a=s.taskConfig;e.then(o=>{let l=o.draco,h=new l.Decoder;try{let u=function(c,p,m,f){let g,y,v=f.attributeIDs,b=f.attributeTypes,_=p.GetEncodedGeometryType(m);if(_===c.TRIANGULAR_MESH)g=new c.Mesh,y=p.DecodeArrayToMesh(m,m.byteLength,g);else{if(_!==c.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");g=new c.PointCloud,y=p.DecodeArrayToPointCloud(m,m.byteLength,g)}if(!y.ok()||g.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+y.error_msg());let x={index:null,attributes:[]};for(let S in v){let w,T,C=self[b[S]];if(f.useUniqueIDs)T=v[S],w=p.GetAttributeByUniqueId(g,T);else{if(T=p.GetAttributeId(g,c[v[S]]),T===-1)continue;w=p.GetAttribute(g,T)}let M=i(c,p,g,S,C,w);S==="color"&&(M.vertexColorSpace=f.vertexColorSpace),x.attributes.push(M)}return _===c.TRIANGULAR_MESH&&(x.index=function(S,w,T){let C=3*T.num_faces(),M=4*C,A=S._malloc(M);w.GetTrianglesUInt32Array(T,M,A);let P=new Uint32Array(S.HEAPF32.buffer,A,C).slice();return S._free(A),{array:P,itemSize:1}}(c,p,g)),c.destroy(g),x}(l,h,new Int8Array(n),a),d=u.attributes.map(c=>c.array.buffer);u.index&&d.push(u.index.array.buffer),self.postMessage({type:"decode",id:s.id,geometry:u},d)}catch(u){console.error(u),self.postMessage({type:"error",id:s.id,error:u.message})}finally{l.destroy(h)}})}}}pT(x1t,{DRACOLoader:()=>S1t,DRACO_GLTF_CONFIG:()=>w1t});var _A,w1t,S1t,BEt=U(()=>{ot(),_A=new WeakMap,w1t={js:"",wasm:""},S1t=class extends ug{constructor(t){super(t),this.decoderPaths={js:"",wasm:"",dep_js:""},this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(t){let{decoderPaths:e}=this;return typeof t=="object"?(e.js=t.js,e.wasm=t.wasm,e.dep_js=null):(e.js=JP.resolveURL("draco_wasm_wrapper.js",t),e.wasm=JP.resolveURL("draco_decoder.wasm",t),e.dep_js=JP.resolveURL("draco_decoder.js",t)),this}setDecoderConfig(t){return console.warn("THREE.DRACOLoader: setDecoderConfig to has been deprecated and will be removed in r194."),this.decoderConfig=t,this}setWorkerLimit(t){return this.workerLimit=t,this}load(t,e,i,r){let s=new sS(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(t,n=>{this.parse(n,e,r)},i,r)}parse(t,e,i=()=>{}){this.decodeDracoFile(t,e,null,null,Ns,i).catch(i)}decodeDracoFile(t,e,i,r,s=Hu,n=()=>{}){let a={attributeIDs:i||this.defaultAttributeIDs,attributeTypes:r||this.defaultAttributeTypes,useUniqueIDs:!!i,vertexColorSpace:s};return this.decodeGeometry(t,a).then(e).catch(n)}decodeGeometry(t,e){let i=JSON.stringify(e);if(_A.has(t)){let o=_A.get(t);if(o.key===i)return o.promise;if(t.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let r,s=this.workerNextTaskID++,n=t.byteLength,a=this._getWorker(s,n).then(o=>(r=o,new Promise((l,h)=>{r._callbacks[s]={resolve:l,reject:h},r.postMessage({type:"decode",id:s,taskConfig:e,buffer:t},[t])}))).then(o=>this._createGeometry(o.geometry));return a.catch(()=>!0).then(()=>{r&&s&&this._releaseTask(r,s)}),_A.set(t,{key:i,promise:a}),a}_createGeometry(t){let e=new fe;t.index&&e.setIndex(new ve(t.index.array,1));for(let i=0;i<t.attributes.length;i++){let r,{name:s,array:n,itemSize:a,stride:o,vertexColorSpace:l}=t.attributes[i];if(a===o)r=new ve(n,a);else{let h=new K1(n,o);r=new jp(h,a,0)}s==="color"&&(this._assignVertexColorSpace(r,l),r.normalized=!(n instanceof Float32Array)),e.setAttribute(s,r)}return e}_assignVertexColorSpace(t,e){if(e!==Ns)return;let i=new se;for(let r=0,s=t.count;r<s;r++)i.fromBufferAttribute(t,r),Zi.colorSpaceToWorking(i,Ns),t.setXYZ(r,i.r,i.g,i.b)}_loadLibrary(t,e){let i=new sS(this.manager);return i.setResponseType(e),i.setWithCredentials(this.withCredentials),new Promise((r,s)=>{i.load(t,r,void 0,s)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;let t=typeof WebAssembly!="object"||this.decoderConfig.type==="js",e=[],{decoderPaths:i}=this;if(t){if(i.dep_js===null)throw new Error("THREE.DRACOLoader: WebAssembly is required when using a custom decoder paths.");e.push(this._loadLibrary(i.dep_js,"text"))}else e.push(this._loadLibrary(i.js,"text")),e.push(this._loadLibrary(i.wasm,"arraybuffer"));return this.decoderPending=Promise.all(e).then(r=>{let s=r[0];t||(this.decoderConfig.wasmBinary=r[1]);let n=NEt.toString(),a=["/* draco decoder */",s,"","/* worker */",n.substring(n.indexOf("{")+1,n.lastIndexOf("}"))].join(`
|
|
1584
|
-
`);this.workerSourceURL=URL.createObjectURL(new Blob([a]))}),this.decoderPending}_getWorker(t,e){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){let r=new Worker(this.workerSourceURL);r._callbacks={},r._taskCosts={},r._taskLoad=0,r.postMessage({type:"init",decoderConfig:this.decoderConfig}),r.onmessage=function(s){let n=s.data;switch(n.type){case"decode":r._callbacks[n.id].resolve(n);break;case"error":r._callbacks[n.id].reject(n);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+n.type+'"')}},this.workerPool.push(r)}else this.workerPool.sort(function(r,s){return r._taskLoad>s._taskLoad?-1:1});let i=this.workerPool[this.workerPool.length-1];return i._taskCosts[t]=e,i._taskLoad+=e,i})}_releaseTask(t,e){t._taskLoad-=t._taskCosts[e],delete t._callbacks[e],delete t._taskCosts[e]}debug(){console.log("Task load: ",this.workerPool.map(t=>t._taskLoad))}dispose(){for(let t=0;t<this.workerPool.length;++t)this.workerPool[t].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}}}),kEt=U(()=>{});function T1t(t){return function(e,{basePath:i,moduleUrl:r,cdnBuild:s}){if(i!==void 0)return{url:`${i}/${e}`};let n=`${s}/${e}`;if(r===void 0||r.startsWith("file:"))return{url:n};let a=r.slice(0,r.lastIndexOf("/")+1)+e;return a===n?{url:a}:{url:a,fallback:n}}(t,{basePath:M1t,moduleUrl:typeof import.meta.url=="string"?import.meta.url:void 0,cdnBuild:"https://cdn.spline.design/@splinetool/runtime@2.0.204/build"})}function lQ(t,e){let{url:i,fallback:r}=T1t(e);r!==void 0&&t.addEventListener("error",()=>{t.src=r},{once:!0}),t.src=i}var M1t,eq=U(()=>{kEt()});function A1t(t,e){iq.set(t,e)}function hQ(t){return iq.get(t)}function uQ(t,e){let i=`${e}:${t}`;a9.has(i)||a9.add(i)}var iq,a9,rq=U(()=>{iq=new Map,a9=new Set});function oB(t,e=0){let i=3735928559^e,r=1103547991^e;if(Array.isArray(t))for(let s,n=0;n<t.length;n++)s=t[n],i=Math.imul(i^s,2654435761),r=Math.imul(r^s,1597334677);else for(let s,n=0;n<t.length;n++)s=t.charCodeAt(n),i=Math.imul(i^s,2654435761),r=Math.imul(r^s,1597334677);return i=Math.imul(i^i>>>16,2246822507),i^=Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507),r^=Math.imul(i^i>>>13,3266489909),4294967296*(2097151&r)+(i>>>0)}function dQ(t){return B1t.get(t)}function xA(t){if(/[iu]?vec\d/.test(t))return t.startsWith("ivec")?Int32Array:t.startsWith("uvec")?Uint32Array:Float32Array;if(/mat\d/.test(t)||/float/.test(t))return Float32Array;if(/uint/.test(t))return Uint32Array;if(/int/.test(t))return Int32Array;throw new Error(`THREE.NodeUtils: Unsupported type: ${t}`)}function cQ(t){return/float|int|uint|bool/.test(t)?1:/vec2/.test(t)?2:/vec3/.test(t)?3:/vec4/.test(t)||/mat2/.test(t)?4:/mat3/.test(t)?9:/mat4/.test(t)?16:void Ht(`TSL: Unsupported type: ${t}`,new Ss)}function VEt(t){return/float|int|uint|bool/.test(t)?1:/vec2/.test(t)?2:/vec3/.test(t)?3:/vec4/.test(t)||/mat2/.test(t)?4:/mat3/.test(t)?12:/mat4/.test(t)?16:void Ht(`TSL: Unsupported type: ${t}`,new Ss)}function zEt(t){return/float|int|uint|bool/.test(t)?1:/vec2/.test(t)?2:/vec3/.test(t)||/vec4/.test(t)?4:/mat2/.test(t)?2:/mat3/.test(t)||/mat4/.test(t)?4:void Ht(`TSL: Unsupported type: ${t}`,new Ss)}function Kc(t){if(t==null)return null;let e=typeof t;return t.isNode===!0?"node":e==="number"?"float":e==="boolean"?"bool":e==="string"?"string":e==="function"?"shader":t.isVector2===!0?"vec2":t.isVector3===!0?"vec3":t.isVector4===!0?"vec4":t.isMatrix2===!0?"mat2":t.isMatrix3===!0?"mat3":t.isMatrix4===!0?"mat4":t.isColor===!0?"color":t instanceof ArrayBuffer?"ArrayBuffer":null}function lB(t,...e){let i=t?t.slice(-4):void 0;return e.length===1&&(i==="vec2"?e=[e[0],e[0]]:i==="vec3"?e=[e[0],e[0],e[0]]:i==="vec4"&&(e=[e[0],e[0],e[0],e[0]])),t==="color"?new se(...e):i==="vec2"?new Y(...e):i==="vec3"?new E(...e):i==="vec4"?new Se(...e):i==="mat2"?new NG(...e):i==="mat3"?new Ms(...e):i==="mat4"?new bt(...e):t==="bool"?e[0]||!1:t==="float"||t==="int"||t==="uint"?e[0]||0:t==="string"?e[0]||"":t==="ArrayBuffer"?function(r){return Uint8Array.from(atob(r),s=>s.charCodeAt(0)).buffer}(e[0]):null}function pQ(t){let e=l9.get(t);return e===void 0&&(e={},l9.set(t,e)),e}function Tt(t,e){if(_5.has(t))re(`TSL: Redefinition of method chaining '${t}'.`);else{if(typeof e!="function")throw new Error(`THREE.TSL: Node element ${t} is not a function`);_5.set(t,e),t!=="assign"&&(Ae.prototype[t]=function(...i){return this.isStackNode?this.addToStack(e(...i)):e(this,...i)},Ae.prototype[t+"Assign"]=function(...i){return this.isStackNode?this.assign(i[0],e(...i)):this.assign(e(this,...i))})}}function wA(t,e,i){Mv[t]=Mv[e]=Mv[i]={get(){this._cache=this._cache||{};let a=this._cache[t];return a===void 0&&(a=new h9(this,t),this._cache[t]=a),a},set(a){this[t].assign(ge(a))}};let r=t.toUpperCase(),s=e.toUpperCase(),n=i.toUpperCase();Ae.prototype["set"+r]=Ae.prototype["set"+s]=Ae.prototype["set"+n]=function(a){let o=u9(t);return new k1t(this,o,ge(a))},Ae.prototype["flip"+r]=Ae.prototype["flip"+s]=Ae.prototype["flip"+n]=function(){let a=u9(t);return new V1t(this,a)}}function mQ(t){return t[0]&&(t[0].isNode||Object.getPrototypeOf(t[0])!==Object.prototype)}function ty(t){return t&&t.isNode&&t.traverse(e=>{e.isConstNode&&(t=e.value)}),Boolean(t)}function ey(t,e){return new z1t(t,e)}function tt(t,e=null){let i=new L1t(t,e);return new Proxy(()=>{},{apply:(r,s,n)=>i.call(...n),get:(r,s,n)=>Reflect.get(i,s,n),set:(r,s,n,a)=>Reflect.set(i,s,n,a)})}function SA(t){return Jd&&Jd.addToStack(t),t}function fQ(t,e,i=null){return rc(i,{getShadow:({light:r,shadowColorNode:s})=>e===r?s.mul(t):s})}function gQ(t,e=null){return rc(e,{getAO:(i,{material:r})=>r.transparent===!0?i:i!==null?i.mul(t):t})}function yQ(t,e){return re('TSL: "label()" has been deprecated. Use "setName()" instead.'),MR(t,e)}function vQ(t,e){let i=d9.get(t);return i===void 0&&(i=new K1(t,e),d9.set(t,i)),i}function TA(t,e=null,i=0,r=0,s=Cg,n=!1){return e==="mat3"||e===null&&t.itemSize===9?Sn(new Yd(t,"vec3",9,0).setUsage(s).setInstanced(n),new Yd(t,"vec3",9,3).setUsage(s).setInstanced(n),new Yd(t,"vec3",9,6).setUsage(s).setInstanced(n)):e==="mat4"||e===null&&t.itemSize===16?tc(new Yd(t,"vec4",16,0).setUsage(s).setInstanced(n),new Yd(t,"vec4",16,4).setUsage(s).setInstanced(n),new Yd(t,"vec4",16,8).setUsage(s).setInstanced(n),new Yd(t,"vec4",16,12).setUsage(s).setInstanced(n)):new Yd(t,e,i,r).setUsage(s)}function bQ(t,e=!0){return re('TSL: "cache()" has been deprecated. Use "isolate()" instead.'),gg(t).setParent(e)}function _Q(t,e,i,r=F(0),s=F(1)){return c9(t,e,i,r,s,!0)}function xQ(t,e="",i=null){return(t=ge(t)).before(new F1t(t,e,i))}function LEt(t){re("TSL: AddNodeElement has been removed in favor of tree-shaking. Trying add",t)}function wQ(t,e,i){let r;if(e.isStorageInstancedBufferAttribute===!0)r=Kd(e,"mat4",Math.max(i,1)).element(Xl);else if(16*i*4<=t.getUniformBufferLimit())r=Mg(e.array,"mat4",Math.max(i,1)).element(Xl);else{let s=x5.get(e);s||(s=new IG(e.array,16,1),x5.set(e,s));let n=e.usage===$h?AR:T2,a=[n(s,"vec4",16,0),n(s,"vec4",16,4),n(s,"vec4",16,8),n(s,"vec4",16,12)];r=tc(...a)}return r}function o9(t,e,i,r,s,n){let a=t.element(s.x),o=t.element(s.y),l=t.element(s.z),h=t.element(s.w),u=i.mul(e),d=Ds(a.mul(n.x).mul(u),o.mul(n.y).mul(u),l.mul(n.z).mul(u),h.mul(n.w).mul(u));return r.mul(d).xyz}function SQ(t,e,i,r,s,n,a){let o=t.element(n.x),l=t.element(n.y),h=t.element(n.z),u=t.element(n.w),d=Ds(a.x.mul(o),a.y.mul(l),a.z.mul(h),a.w.mul(u));return d=s.mul(d).mul(r),{skinNormal:d.transformDirection(e).xyz,skinTangent:d.transformDirection(i).xyz}}function TQ(t,e,i,r,s){let n=t.skeleton,a=_S.get(n);if(a===void 0){n.update();let o=new Float32Array(n.boneMatrices);a={previousBoneMatrices:o,node:Mg(o,"mat4",n.bones.length)},_S.set(n,a)}return o9(a.node,zp,e,i,r,s)}function C1t(t){let e=t.target;e.removeEventListener("dispose",C1t);let i=iv.get(e);i!==void 0&&(iv.delete(e),i.dispose())}function MQ(t,e){e===f4?t.mapping=jg:e===g4&&(t.mapping=$2)}function AQ(t,e,i){let r=new ii(t,e,{magFilter:pe,minFilter:pe,generateMipmaps:!1,type:si,format:hn,colorSpace:Hu,depthBuffer:i});return r.texture.mapping=X2,r.texture.name="PMREM.cubeUv",r.texture.isPMREMTexture=!0,r.scissorTest=!0,r}function b5(t){let e=new Pe;return e.depthTest=!1,e.depthWrite=!1,e.blending=Wi,e.name=`PMREM_${t}`,e}function CQ(t){let e=b5("cubemap");return e.fragmentNode=Wa(t,xS),e}function EQ(t){let e=b5("equirect");return e.fragmentNode=Pi(t,CR(xS),0),e}function PQ(t){return Object.freeze({isMaterial:!0,isDrawState:!0,id:t.id,name:t.name,type:t.type,transparent:t.transparent,blending:t.blending,premultipliedAlpha:t.premultipliedAlpha,blendSrc:t.blendSrc,blendDst:t.blendDst,blendEquation:t.blendEquation,blendSrcAlpha:t.blendSrcAlpha,blendDstAlpha:t.blendDstAlpha,blendEquationAlpha:t.blendEquationAlpha,blendColor:t.blendColor,blendAlpha:t.blendAlpha,colorWrite:t.colorWrite,mrtWriteMask:t.mrtWriteMask,depthWrite:t.depthWrite,depthTest:t.depthTest,depthFunc:t.depthFunc,stencilWrite:t.stencilWrite,stencilFunc:t.stencilFunc,stencilRef:t.stencilRef,stencilFail:t.stencilFail,stencilZFail:t.stencilZFail,stencilZPass:t.stencilZPass,stencilFuncMask:t.stencilFuncMask,stencilWriteMask:t.stencilWriteMask,side:t.side,wireframe:t.wireframe===!0,alphaToCoverage:t.alphaToCoverage,forceSinglePass:t.forceSinglePass,polygonOffset:t.polygonOffset,polygonOffsetFactor:t.polygonOffsetFactor,polygonOffsetUnits:t.polygonOffsetUnits})}function RQ(t,e){if(t===null||e===null)return t===e;for(let i in t)if(t[i]!==e[i])return!1;return!0}function E1t(t){return t.index!==null?t.index.version:t.attributes.position.version}function P1t(t){return t.index!==null?t.index.id:t.attributes.position.id}function DQ(t){let e=[],i=t.index,r=t.attributes.position;if(i!==null){let n=i.array;for(let a=0,o=n.length;a<o;a+=3){let l=n[a+0],h=n[a+1],u=n[a+2];e.push(l,h,h,u,u,l)}}else for(let n=0,a=r.array.length/3-1;n<a;n+=3){let o=n+0,l=n+1,h=n+2;e.push(o,l,l,h,h,o)}let s=new(r.count>=65535?pm:Y8)(e,1);return s.version=E1t(t),s.__id=P1t(t),s}function FEt(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?t.z-e.z:t.id-e.id}function OQ(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:t.id-e.id}function IQ(t){return!!(t.transparent===!0||t.transmission>0||t.transmissionNode&&t.transmissionNode.isNode||t.backdropNode&&t.backdropNode.isNode)}function NQ(t){return(t.transmission>0||t.transmissionNode&&t.transmissionNode.isNode)&&t.side===Xs&&t.forceSinglePass===!1}function BQ(t,e=null,i=null){if(e&&e.isNode){let r=e;e=()=>r}return new aq(new Map([[t,e]]),i)}function kQ(t,e=null){let i=new Map;for(let[r,s]of t){let n=s!==null?typeof s=="function"?s:()=>s:null;i.set(r,n)}return new aq(i,e)}function VQ(t,e){for(let i=0;i<t.length;i++)if(t[i].name===e)return i;return-1}function UEt(t,e=null){return rc(e,{getUV:typeof t=="function"?t:()=>t})}function R1t(t){let e=T9.get(t);return e===void 0&&(e={},T9.set(t,e)),e}function zQ(t,e=0){let i=R1t(t),r=i[e];return r===void 0&&(i[e]=r=new bt,i[e].copy(t.matrixWorld)),r}function hB(t){let e,i=t.context.getViewZ;return i!==void 0&&(e=i(this)),(e||ws.z).negate()}function ND(t){let e=(M6=M6||new WeakMap).get(t);return e===void 0&&M6.set(t,e={}),e}function TR(t){let e=ND(t);return e.shadowMatrix||(e.shadowMatrix=_e("mat4").setGroup(Me).onRenderUpdate(i=>((t.castShadow!==!0||i.renderer.shadowMap.enabled===!1)&&(t.shadow.camera.coordinateSystem!==i.camera.coordinateSystem&&(t.shadow.camera.coordinateSystem=i.camera.coordinateSystem,t.shadow.camera.updateProjectionMatrix()),t.shadow.updateMatrices(t)),t.shadow.matrix)))}function LQ(t,e=Dh){let i=TR(t).mul(e);return i.xyz.div(i.w)}function uB(t){let e=ND(t);return e.position||(e.position=_e(new E).setGroup(Me).onRenderUpdate((i,r)=>r.value.setFromMatrixPosition(t.matrixWorld)))}function FQ(t){let e=ND(t);return e.targetPosition||(e.targetPosition=_e(new E).setGroup(Me).onRenderUpdate((i,r)=>r.value.setFromMatrixPosition(t.target.matrixWorld)))}function dB(t){let e=ND(t);return e.viewPosition||(e.viewPosition=_e(new E).setGroup(Me).onRenderUpdate(({camera:i},r)=>{r.value=r.value||new E,r.value.setFromMatrixPosition(t.matrixWorld),r.value.applyMatrix4(i.matrixWorldInverse)}))}function sq(t,e={}){return e.toneMapping=t.toneMapping,e.toneMappingExposure=t.toneMappingExposure,e.outputColorSpace=t.outputColorSpace,e.renderTarget=t.getRenderTarget(),e.activeCubeFace=t.getActiveCubeFace(),e.activeMipmapLevel=t.getActiveMipmapLevel(),e.renderObjectFunction=t.getRenderObjectFunction(),e.pixelRatio=t.getPixelRatio(),e.mrt=t.getMRT(),e.clearColor=t.getClearColor(e.clearColor||new se),e.clearAlpha=t.getClearAlpha(),e.autoClear=t.autoClear,e.scissorTest=t.getScissorTest(),e}function D1t(t,e){return e=sq(t,e),t.setMRT(null),t.setRenderObjectFunction(null),t.setClearColor(0,1),t.autoClear=!0,e}function O1t(t,e){t.toneMapping=e.toneMapping,t.toneMappingExposure=e.toneMappingExposure,t.outputColorSpace=e.outputColorSpace,t.setRenderTarget(e.renderTarget,e.activeCubeFace,e.activeMipmapLevel),t.setRenderObjectFunction(e.renderObjectFunction),t.setPixelRatio(e.pixelRatio),t.setMRT(e.mrt),t.setClearColor(e.clearColor,e.clearAlpha),t.autoClear=e.autoClear,t.setScissorTest(e.scissorTest)}function nq(t,e={}){return e.background=t.background,e.backgroundNode=t.backgroundNode,e.overrideMaterial=t.overrideMaterial,e}function I1t(t,e){return e=nq(t,e),t.background=null,t.backgroundNode=null,t.overrideMaterial=null,e}function N1t(t,e){t.background=e.background,t.backgroundNode=e.backgroundNode,t.overrideMaterial=e.overrideMaterial}function jEt(t,e,i={}){return nq(e,i=sq(t,i))}function UQ(t,e,i){return I1t(e,i=D1t(t,i))}function jQ(t,e,i){O1t(t,i),N1t(e,i)}function GQ(t){return t+(sc-t%sc)%sc}function iy(){return DR===null&&((DR=new yr(new Uint8Array([255,255,255,255]),1,1)).needsUpdate=!0),DR}function hu(t,e){OR[0]=e,t.queue.submit(OR),OR[0]=null}function WQ(t,e,i,r,s,n,a,o,l,h){Sa.texture=e,Sa.mipLevel=i,Sa.origin.z=r,Lu.offset=r*n,Lu.bytesPerRow=a,Lu.rowsPerImage=o,xa.width=l,xa.height=h,t.queue.writeTexture(Sa,s.data,Lu,xa),Sa.reset(),Lu.reset(),xa.reset()}function cB(t,e){let i,r=t.format,s=t.type,n=t.normalized,a=t.colorSpace,o=Zi.getTransfer(a),l=!1;if(n&&(l=e.features.has(wS.TextureFormatsTier1),l===!1&&re("WebGPURenderer: Unable to use normalized textures without texture-formats-tier1 feature.")),t.isCompressedTexture===!0||t.isCompressedArrayTexture===!0)switch(r){case Vpt:case zpt:i=o===xr?Q.BC1RGBAUnormSRGB:Q.BC1RGBAUnorm;break;case Lpt:i=o===xr?Q.BC2RGBAUnormSRGB:Q.BC2RGBAUnorm;break;case Fpt:i=o===xr?Q.BC3RGBAUnormSRGB:Q.BC3RGBAUnorm;break;case umt:i=Q.BC4RUnorm;break;case dmt:i=Q.BC4RSnorm;break;case PG:i=Q.BC5RGUnorm;break;case cmt:i=Q.BC5RGSnorm;break;case omt:i=o===xr?Q.BC7RGBAUnormSRGB:Q.BC7RGBAUnorm;break;case lmt:i=Q.BC6HRGBFloat;break;case hmt:i=Q.BC6HRGBUFloat;break;case jpt:case Upt:i=o===xr?Q.ETC2RGB8UnormSRGB:Q.ETC2RGB8Unorm;break;case Gpt:i=o===xr?Q.ETC2RGBA8UnormSRGB:Q.ETC2RGBA8Unorm;break;case Wpt:i=Q.EACR11Unorm;break;case qpt:i=Q.EACR11Snorm;break;case EG:i=Q.EACRG11Unorm;break;case Hpt:i=Q.EACRG11Snorm;break;case $pt:i=o===xr?Q.ASTC4x4UnormSRGB:Q.ASTC4x4Unorm;break;case Xpt:i=o===xr?Q.ASTC5x4UnormSRGB:Q.ASTC5x4Unorm;break;case Ypt:i=o===xr?Q.ASTC5x5UnormSRGB:Q.ASTC5x5Unorm;break;case Kpt:i=o===xr?Q.ASTC6x5UnormSRGB:Q.ASTC6x5Unorm;break;case Zpt:i=o===xr?Q.ASTC6x6UnormSRGB:Q.ASTC6x6Unorm;break;case Qpt:i=o===xr?Q.ASTC8x5UnormSRGB:Q.ASTC8x5Unorm;break;case Jpt:i=o===xr?Q.ASTC8x6UnormSRGB:Q.ASTC8x6Unorm;break;case tmt:i=o===xr?Q.ASTC8x8UnormSRGB:Q.ASTC8x8Unorm;break;case emt:i=o===xr?Q.ASTC10x5UnormSRGB:Q.ASTC10x5Unorm;break;case imt:i=o===xr?Q.ASTC10x6UnormSRGB:Q.ASTC10x6Unorm;break;case rmt:i=o===xr?Q.ASTC10x8UnormSRGB:Q.ASTC10x8Unorm;break;case smt:i=o===xr?Q.ASTC10x10UnormSRGB:Q.ASTC10x10Unorm;break;case nmt:i=o===xr?Q.ASTC12x10UnormSRGB:Q.ASTC12x10Unorm;break;case amt:i=o===xr?Q.ASTC12x12UnormSRGB:Q.ASTC12x12Unorm;break;case hn:i=o===xr?Q.RGBA8UnormSRGB:Q.RGBA8Unorm;break;default:Ht("WebGPURenderer: Unsupported texture format.",r)}else switch(r){case hn:switch(s){case Y2:i=Q.RGBA8Snorm;break;case K2:i=l?Q.RGBA16Snorm:Q.RGBA16Sint;break;case Y1:i=l?Q.RGBA16Unorm:Q.RGBA16Uint;break;case En:i=Q.RGBA32Uint;break;case yl:i=Q.RGBA32Sint;break;case bl:i=o===xr?Q.RGBA8UnormSRGB:Q.RGBA8Unorm;break;case si:i=Q.RGBA16Float;break;case Ye:i=Q.RGBA32Float;break;default:Ht("WebGPURenderer: Unsupported texture type with RGBAFormat.",s)}break;case y4:switch(s){case MG:i=Q.RGB9E5UFloat;break;case AG:i=Q.RG11B10UFloat;break;default:Ht("WebGPURenderer: Unsupported texture type with RGBFormat.",s)}break;case Ka:switch(s){case Y2:i=Q.R8Snorm;break;case K2:i=l?Q.R16Snorm:Q.R16Sint;break;case Y1:i=l?Q.R16Unorm:Q.R16Uint;break;case En:i=Q.R32Uint;break;case yl:i=Q.R32Sint;break;case bl:i=Q.R8Unorm;break;case si:i=Q.R16Float;break;case Ye:i=Q.R32Float;break;default:Ht("WebGPURenderer: Unsupported texture type with RedFormat.",s)}break;case Bo:switch(s){case Y2:i=Q.RG8Snorm;break;case K2:i=l?Q.RG16Snorm:Q.RG16Sint;break;case Y1:i=l?Q.RG16Unorm:Q.RG16Uint;break;case En:i=Q.RG32Uint;break;case yl:i=Q.RG32Sint;break;case bl:i=Q.RG8Unorm;break;case si:i=Q.RG16Float;break;case Ye:i=Q.RG32Float;break;default:Ht("WebGPURenderer: Unsupported texture type with RGFormat.",s)}break;case Jp:switch(s){case Y1:i=Q.Depth16Unorm;break;case En:i=Q.Depth24Plus;break;case Ye:i=Q.Depth32Float;break;default:Ht("WebGPURenderer: Unsupported texture type with DepthFormat.",s)}break;case dv:switch(s){case Z2:i=Q.Depth24PlusStencil8;break;case Ye:e&&e.features.has(wS.Depth32FloatStencil8)===!1&&Ht('WebGPURenderer: Depth textures with DepthStencilFormat + FloatType can only be used with the "depth32float-stencil8" GPU feature.'),i=Q.Depth32FloatStencil8;break;default:Ht("WebGPURenderer: Unsupported texture type with DepthStencilFormat.",s)}break;case v4:switch(s){case yl:i=Q.R32Sint;break;case En:i=Q.R32Uint;break;default:Ht("WebGPURenderer: Unsupported texture type with RedIntegerFormat.",s)}break;case b4:switch(s){case yl:i=Q.RG32Sint;break;case En:i=Q.RG32Uint;break;default:Ht("WebGPURenderer: Unsupported texture type with RGIntegerFormat.",s)}break;case CG:switch(s){case yl:i=Q.RGBA32Sint;break;case En:i=Q.RGBA32Uint;break;default:Ht("WebGPURenderer: Unsupported texture type with RGBAIntegerFormat.",s)}break;default:Ht("WebGPURenderer: Unsupported texture format.",r)}return i}var qQ,pB,mB,fB,HQ,$Q,Ss,df,ry,cf,B1t,l9,pf,ze,XQ,Fn,gB,P_,R_,mf,YQ,KQ,Ae,Zc,yB,Cr,ZQ,QQ,h9,k1t,V1t,MA,vB,ph,JQ,Jd,_5,tJ,u9,Mv,mh,fh,gh,eJ,iJ,rJ,bB,sJ,nJ,z1t,aJ,oJ,lJ,_B,AA,CA,EA,D_,O_,xB,PA,Gs,wB,ge,sy,I_,Qc,oi,Qt,jt,RA,hJ,L1t,ny,DA,xe,uJ,SB,F,Z,Ft,So,Xt,rs,OA,TB,et,IA,Jc,NA,oe,BA,kA,MB,N_,Sn,tc,AB,CB,dJ,cJ,Ui,uu,tp,Ai,ep,VA,yh,du,B_,ff,To,fd,k_,V_,z_,L_,gd,ay,ip,yd,rp,sp,F_,gf,np,oy,pJ,ly,U_,zA,LA,FA,UA,jA,EB,PB,GA,mJ,Me,RB,hy,_e,DB,OB,fJ,gJ,yJ,vJ,vs,Ds,wi,Ge,Mo,j_,IB,NB,BB,WA,kB,VB,zB,LB,FB,UB,jB,GB,WB,qB,HB,$B,XB,YB,KB,ZB,ut,G_,bJ,W_,_J,xJ,wJ,QB,JB,tk,ek,qA,yf,q_,vh,Na,HA,bh,H_,ua,Ol,Ba,ik,Il,rk,sk,nk,ak,ok,$A,lk,XA,hk,_r,YA,_h,KA,uk,ZA,QA,dk,ck,JA,t3,pk,mk,fk,so,ss,ap,gk,yk,vk,Ko,cu,Zo,e3,bk,i3,_k,xk,wk,Sk,r3,gi,Nl,$_,s3,Ao,n3,Tk,Mk,Ak,Ck,SJ,TJ,ka,a3,rc,Ek,MR,o3,l3,MJ,Pk,Rk,AJ,op,vd,Dk,Ok,Ik,h3,u3,CJ,X_,EJ,PJ,Nk,RJ,DJ,Bk,OJ,kk,Vk,d9,Yd,d3,IJ,T2,AR,ds,zk,Xl,NJ,BJ,kJ,Lk,VJ,c3,zJ,bS,gg,LJ,c9,p3,Co,FJ,UJ,m3,Fk,jJ,Uk,GJ,WJ,jk,F1t,Gk,Va,$i,lp,f3,Wk,g3,bd,qJ,Pi,HJ,bs,$J,XJ,YJ,y3,Mg,KJ,ZJ,Un,pu,Y_,K_,qr,v3,Bl,hp,up,vf,b3,qk,QJ,JJ,_3,Z_,x3,Q_,w3,J_,S3,tx,T3,ex,M3,ix,A3,rx,_d,xd,wd,za,Hk,Sd,uy,ttt,$k,ett,Xk,Ii,itt,rtt,stt,ntt,att,ott,kl,ltt,Qo,htt,utt,dtt,ctt,Yk,ptt,xh,Kk,C3,E3,Zk,jn,Hr,zp,Dh,P3,ws,mr,Qk,R3,dp,mtt,sx,da,Jk,bf,tV,Ci,Td,Md,eV,D3,ftt,gtt,ytt,O3,iV,nx,ax,rV,sV,nV,aV,oV,I3,Wa,vtt,btt,ox,Mr,lV,_tt,mu,hV,xtt,wtt,uV,dV,cV,pV,mV,N3,B3,fV,gV,Stt,Ttt,lx,Ad,hx,yV,ux,Mtt,Att,vV,Ctt,cp,bV,Ett,_V,k3,xV,V3,Ptt,Rtt,z3,Dtt,Ott,L3,wV,Et,SV,TV,MV,AV,F3,CV,U3,EV,dy,dx,PV,RV,DV,OV,IV,NV,BV,kV,VV,zV,LV,FV,UV,jV,GV,WV,qV,HV,j3,G3,W3,cx,q3,$V,XV,H3,YV,_f,KV,Ps,pp,px,Itt,ZV,Ntt,Btt,ktt,Vtt,ztt,Ltt,Kd,x5,QV,$3,X3,JV,tz,Ftt,Utt,Y3,ez,mx,_S,iz,jtt,Gtt,Xi,Wtt,rz,K3,Eo,sz,nz,az,xf,qtt,oz,Htt,mp,Z3,$tt,Q3,Xtt,J3,tC,eC,Jo,fp,Ytt,lz,iC,hz,fx,gx,Ktt,uz,rC,yx,Ztt,wh,Qtt,Jtt,tet,dz,cz,eet,iet,pz,Pe,ret,p9,set,m9,net,vx,sC,mz,gp,fz,aet,oet,het,U1t,uet,f9,CR,nC,gz,iv,yz,aC,det,Ag,vz,cet,g9,wf,yp,pet,met,fet,Av,get,y9,yet,v9,bz,oC,_z,vet,xz,bet,_et,lC,xet,fu,cy,wet,wz,hC,Tet,Met,Aet,Sz,Cet,bx,uC,_x,Tz,dC,Mz,cC,Az,Cz,Ez,Pz,Rz,pC,Eet,Dz,Pet,Ret,Det,Oz,Iz,Oet,Iet,Net,Nz,Bet,Bz,py,my,xx,ER,kz,mC,wx,fC,Sx,gC,Tx,yC,Vz,ket,zz,Vet,zet,Let,Fet,Lz,Fz,fy,vC,Uz,Uet,jet,Get,jz,Gz,gy,yy,Wet,Wz,bC,_C,xC,qet,Mx,Het,wC,xS,$et,qz,SC,Hz,b9,$z,Xet,Yet,PR,Ket,_9,Zet,Qet,Jet,x9,Xz,tit,w9,vy,eit,RR,iit,rit,iT,sit,nit,ait,S9,oit,Cd,lit,Yz,hit,uit,dit,cit,pit,Kz,mit,Ed,tl,sc,fit,git,yit,Zz,Qz,vit,bit,Jz,_it,xit,wit,Ax,Sit,Sf,Tit,Mit,Ait,Cit,Eit,Pit,TC,aq,t6,Rit,Cx,Dit,Oit,Iit,Nit,Bit,rT,kit,Vit,zit,e6,Ex,i6,Lit,r6,Fit,Uit,Px,Vl,jit,Git,Wit,qit,MC,Hit,$it,Xit,s6,Yit,Kit,Zit,n6,Qit,Jit,trt,gu,ert,irt,rrt,Gn,Tf,srt,a6,nrt,art,ort,lrt,hrt,urt,drt,crt,prt,o6,mrt,Mf,vp,Af,AC,by,Rx,Sh,_y,Dx,xy,Ox,Ix,frt,Nx,l6,grt,yrt,CC,vrt,Pr,brt,_rt,h6,xrt,Cf,wrt,Srt,EC,zl,Trt,Mrt,Art,Crt,Ert,Prt,Rrt,PC,u6,RC,d6,Drt,c6,Ort,Irt,Nrt,DC,Brt,krt,Vrt,zrt,T9,j1t,Lrt,Frt,Urt,jrt,Grt,Wrt,qrt,Hrt,$rt,Xrt,OC,Yrt,Krt,Bx,Zrt,kx,p6,m6,yu,Qrt,Jrt,tst,est,ist,f6,g6,y6,rst,v6,sst,nst,ast,b6,_6,$r,Vx,ost,lst,hst,x6,w6,ust,dst,S6,T6,cst,IC,bp,_p,pst,mst,zx,fst,gst,yst,vst,bst,NC,_st,xst,wst,Sst,Tst,Mst,_n,Ast,Th,Cst,Est,Pst,Rst,Dst,Ost,Ist,Nst,Bst,ae,kst,Vst,zst,Lst,Fst,Ust,jst,Gst,Wst,qst,Hst,$st,Xst,Yst,Kst,Zst,Qst,Jst,tnt,ent,int,rnt,snt,nnt,ant,M6,BC,ont,lnt,hnt,unt,dnt,kC,wy,VC,cnt,pnt,zC,M9,Lx,A6,C6,E6,P6,R6,D6,O6,Ef,I6,mnt,fnt,gnt,N6,Fx,B6,k6,ynt,V6,Sy,LC,vnt,bnt,_nt,xnt,z6,L6,wnt,Snt,F6,xp,FC,U6,A9,Tnt,Mnt,Ty,Ux,Rs,Xr,Ant,Cnt,j6,Ent,Pnt,G6,Rnt,Dnt,xn,Ont,Int,el,Nnt,Bnt,knt,W6,Vnt,q6,Po,H6,My,ca,Mh,znt,Lnt,Fnt,Unt,jnt,nr,Gnt,Wnt,il,qnt,Hnt,UC,$nt,Xnt,Ay,Ynt,Knt,Znt,Qnt,Jnt,tat,eat,iat,rat,jx,Gx,Wx,sat,nat,aat,oat,Pf,lat,hat,uat,dat,cat,pat,mat,fat,jC,gat,yat,vat,bat,_at,$6,X6,xat,wat,Sat,Y6,Tat,Mat,Aat,Cat,Eat,Pat,Rat,Dat,Oat,Iat,Nat,Bat,kat,Vat,zat,Lat,Fat,Uat,jat,Gat,Wat,qat,Hat,$at,Xat,Yat,Kat,Zat,Qat,Jat,tot,eot,iot,rot,sot,not,aot,K6,R,Ll,oot,lot,GC,hot,Z6,uot,Q6,dot,cot,pot,WC,mot,Pd,fot,got,yot,vot,bot,_ot,xot,wot,Sot,Tot,Mot,Aot,Cot,Eot,Pot,Rot,Dot,J6,tL,Oot,Iot,qx,eL,Not,iL,Bot,kot,C9,E9,M2,Vot,zot,Lot,Fot,qC,Hx,Cy,Uot,jot,Got,rl,vu,rL,Wot,HC,$C,qot,Rd,Hot,sL,$ot,nL,Xot,Yot,aL,Rf,XC,$x,Xx,Df,bu,Kot,Zot,oL,lL,hL,Qot,Jot,tlt,elt,ilt,uL,rlt,slt,DR,YC,nlt,dL,KC,Of,alt,olt,If,Ah,Wn,La,Yi,cL,pL,ZC,Q,QC,sl,Ei,wp,Yx,Dd,mL,JC,fL,Sp,gL,qn,llt,Kx,wS,yL,hlt,ult,dlt,clt,OR,plt,vL,Nf,Ey,bL,Py,Ry,_L,mlt,xL,tE,eE,Od,Id,Zx,iE,rE,Bf,Dy,Qx,kf,_s,flt,glt,Jx,ylt,vlt,blt,_lt,wL,tw,xlt,pa,Sa,ew,Lu,iw,Vf,Nd,xa,wlt,Slt,Tlt,Mlt,Alt,SL,Clt,Elt,Plt,Rlt,TL,sE,ML,Dlt,Olt,AL,Oy,Ilt,CL,Nlt,ma,nE,EL,Blt,klt,Vlt,Fa,Iy,zf,zlt,Llt,Flt,Ult,jlt,Ny,Lf,Ff,Ro,Glt,PL,Ch,Wlt,By,qlt,Hlt,rw,$lt,Fl,Do,Ua,sw,ky,nw,aw,nl,Eh,Yr,_u,Xlt,Ylt,Klt,Zlt,IR,G1t,W1t,Yg,ea,NR,At,vt,Qi,q1t,P9,H1t,fr,ke,BR,oq,lq,wc,hl,yg,Oo,kR,Hv,$1t,X1t,Y1t,K1t,Oc,mb,Z1t,ih,w5,Te,Q1t,J1t,hq,tvt,evt,Xa,Kr,ivt,$v,Xv,BD,ko,rvt,Bt,R9,kD,k1,VD,I,de,svt,Di,nvt,D9,Pc,Sm,uq,ho,Rn,Zr,qp,avt,ct,dq,VR,ovt,lvt,hvt,Yn,Kn,ci,uvt,dvt,zR,Yv,zD,bm,cq,cvt,LR,pvt,Kt,mvt,ti,$t,qh,fvt,gvt,yvt,FR,LD,vvt,Kv,bvt,O9,_vt,xvt,pq,Ra,sT,wvt,be,mq,Rr,Svt,Tvt,Mvt,Avt,Cvt,Evt,Pvt,FD,Zv,UD,Ic,Qv,Wo,Lo,Rvt,Dvt,fq,Ovt,nT,Ivt,V1,gq,Nvt,zg,Qa,th,pi,Bvt,kvt,S5,Xu,Bn,Ji,rv,I9,xl,Si,Vvt,Hp,A2,zvt,Lvt,Jt,Sc,Fvt,Uvt,yq,T5,Vi,mt,aT,$p,ui,jvt,Gvt,Lr,st,j,at,Wvt,SS,N9,B9,Lg,cc,qvt,z1,UR,cr=U(()=>{ot(),ot(),qQ=["alphaMap","alphaTest","anisotropy","anisotropyMap","anisotropyRotation","aoMap","aoMapIntensity","attenuationColor","attenuationDistance","bumpMap","clearcoat","clearcoatMap","clearcoatNormalMap","clearcoatNormalScale","clearcoatRoughness","color","dispersion","displacementMap","emissive","emissiveIntensity","emissiveMap","envMap","envMapIntensity","envMapRotation","gradientMap","ior","iridescence","iridescenceIOR","iridescenceMap","iridescenceThicknessMap","lightMap","lightMapIntensity","map","matcap","metalness","metalnessMap","normalMap","normalScale","opacity","roughness","roughnessMap","sheen","sheenColor","sheenColorMap","sheenRoughnessMap","shininess","specular","specularColor","specularColorMap","specularIntensity","specularIntensityMap","specularMap","thickness","transmission","transmissionMap"],pB=new WeakMap,mB=new WeakMap,fB=new WeakMap,HQ=class{constructor(t){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(t),this.hasAnimation=t.object.isSkinnedMesh===!0,this.refreshUniforms=qQ,this.renderId=0}firstInitialization(t){return this.renderObjects.has(t)===!1&&(this.getRenderObjectData(t),!0)}needsVelocity(t){let e=t.getMRT();return e!==null&&e.has("velocity")}getRenderObjectData(t){let e=this.renderObjects.get(t);if(e===void 0){let{geometry:i,object:r}=t;if(e={geometryId:i.id,worldMatrix:r.matrixWorld.clone()},r.center&&(e.center=r.center.clone()),r.morphTargetInfluences&&(e.morphTargetInfluences=r.morphTargetInfluences.slice()),t.bundle!==null&&(e.version=t.bundle.version),t.material.transmission>0){let{width:a,height:o}=t.context;e.bufferWidth=a,e.bufferHeight=o}let{environmentIntensity:s,environmentRotation:n}=t.scene;e.environmentIntensity=s,e.environmentRotation=n.clone(),e.lights=this.getLightsData(t.lightsNode.getLights(),[]),this.renderObjects.set(t,e)}return e}getAttributesData(t){let e={};for(let i in t){let r=t[i];e[i]={id:r.isInterleavedBufferAttribute?r.data.uuid:r.id,version:r.isInterleavedBufferAttribute?r.data.version:r.version}}return e}containsNode(t){let e=t.material;for(let i in e)if(e[i]&&e[i].isNode)return!0;return!!(t.context.modelViewMatrix||t.context.modelNormalViewMatrix||t.context.getAO||t.context.getShadow)}getGeometryData(t){let e=fB.get(t);return e===void 0&&(e={_renderId:-1,_equal:!1,attributes:this.getAttributesData(t.attributes),indexId:t.index?t.index.id:null,indexVersion:t.index?t.index.version:null,drawRange:{start:t.drawRange.start,count:t.drawRange.count}},fB.set(t,e)),e}getMaterialData(t){let e=mB.get(t);if(e===void 0){e={_renderId:-1,_equal:!1};for(let i of this.refreshUniforms){let r=t[i];r!=null&&(typeof r=="object"&&r.clone!==void 0?r.isTexture===!0?e[i]={id:r.id,version:0}:e[i]=r.clone():e[i]=r)}mB.set(t,e)}return e}equals(t,e,i){let{object:r,material:s,geometry:n}=t,a=this.getRenderObjectData(t);if(a.worldMatrix.equals(r.matrixWorld)!==!0)return a.worldMatrix.copy(r.matrixWorld),!1;let o=this.getMaterialData(t.material);if(o._renderId!==i){o._renderId=i;for(let u in o){let d=o[u],c=s[u];if(u!=="_renderId"&&u!=="_equal"){if(d.equals!==void 0){if(d.equals(c)===!1)return d.copy(c),o._equal=!1,!1}else if(c.isTexture===!0){if(d.id!==c.id||d.version!==c.version)return d.id=c.id,d.version=c.version,o._equal=!1,!1}else if(d!==c)return o[u]=c,o._equal=!1,!1}}if(o.transmission>0){let{width:u,height:d}=t.context;if(a.bufferWidth!==u||a.bufferHeight!==d)return a.bufferWidth=u,a.bufferHeight=d,o._equal=!1,!1}o._equal=!0}else if(o._equal===!1)return!1;if(a.geometryId!==n.id)return a.geometryId=n.id,!1;let l=this.getGeometryData(t.geometry);if(l._renderId!==i){l._renderId=i;let u=n.attributes,d=l.attributes,c=0,p=0;for(let b in u)c++;for(let b in d){p++;let _=d[b],x=u[b];if(x===void 0)return delete d[b],l._equal=!1,!1;let S=x.isInterleavedBufferAttribute?x.data.uuid:x.id,w=x.isInterleavedBufferAttribute?x.data.version:x.version;if(_.id!==S||_.version!==w)return _.id=S,_.version=w,l._equal=!1,!1}if(p!==c)return l.attributes=this.getAttributesData(u),l._equal=!1,!1;let m=n.index,f=l.indexId,g=l.indexVersion,y=m?m.id:null,v=m?m.version:null;if(f!==y||g!==v)return l.indexId=y,l.indexVersion=v,l._equal=!1,!1;if(l.drawRange.start!==n.drawRange.start||l.drawRange.count!==n.drawRange.count)return l.drawRange.start=n.drawRange.start,l.drawRange.count=n.drawRange.count,l._equal=!1,!1;l._equal=!0}else if(l._equal===!1)return!1;if(a.morphTargetInfluences){let u=!1;for(let d=0;d<a.morphTargetInfluences.length;d++)a.morphTargetInfluences[d]!==r.morphTargetInfluences[d]&&(a.morphTargetInfluences[d]=r.morphTargetInfluences[d],u=!0);if(u)return!1}if(a.lights){for(let u=0;u<e.length;u++)if(a.lights[u].map!==e[u].map)return!1}let h=t.scene;return h.environment===null||s.envMap!==null||a.environmentIntensity===h.environmentIntensity&&a.environmentRotation.equals(h.environmentRotation)!==!1?a.center&&a.center.equals(r.center)===!1?(a.center.copy(r.center),!1):(t.bundle!==null&&(a.version=t.bundle.version),!0):(a.environmentIntensity=h.environmentIntensity,a.environmentRotation.copy(h.environmentRotation),!1)}getLightsData(t,e){e.length=0;for(let i of t)i.isSpotLight===!0&&i.map!==null&&e.push({map:i.map.version});return e}getLights(t,e){let i=pB.get(t);return i===void 0&&(i={renderId:-1,lightsData:[]},pB.set(t,i)),i.renderId===e||(i.renderId=e,this.getLightsData(t.getLights(),i.lightsData)),i.lightsData}needsRefresh(t,e){if(this.hasNode||this.hasAnimation||this.firstInitialization(t)||this.needsVelocity(e.renderer))return!0;let{renderId:i}=e;if(this.renderId!==i){this.renderId=i;let a=this.getRenderObjectData(t);if(a.worldMatrix.copy(t.object.matrixWorld),a.morphTargetInfluences){let o=t.object.morphTargetInfluences;for(let l=0;l<a.morphTargetInfluences.length;l++)a.morphTargetInfluences[l]=o[l]}return a.center&&t.object.center&&a.center.copy(t.object.center),!0}let r=t.object.static===!0,s=t.bundle!==null&&t.bundle.static===!0&&this.getRenderObjectData(t).version===t.bundle.version;if(r||s)return!1;let n=this.getLights(t.lightsNode,i);return this.equals(t,n,i)!==!0}},$Q=[/^StackTrace\.js$/,/^TSLCore\.js$/,/^.*Node\.js$/,/^three\.webgpu.*\.js$/],Ss=class{constructor(t=null){this.isStackTrace=!0,this.stack=function(e){let i=/(?:at\s+(.+?)\s+\()?(?:(.+?)@)?([^@\s()]+):(\d+):(\d+)/;return e.split(`
|
|
1584
|
+
`);this.workerSourceURL=URL.createObjectURL(new Blob([a]))}),this.decoderPending}_getWorker(t,e){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){let r=new Worker(this.workerSourceURL);r._callbacks={},r._taskCosts={},r._taskLoad=0,r.postMessage({type:"init",decoderConfig:this.decoderConfig}),r.onmessage=function(s){let n=s.data;switch(n.type){case"decode":r._callbacks[n.id].resolve(n);break;case"error":r._callbacks[n.id].reject(n);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+n.type+'"')}},this.workerPool.push(r)}else this.workerPool.sort(function(r,s){return r._taskLoad>s._taskLoad?-1:1});let i=this.workerPool[this.workerPool.length-1];return i._taskCosts[t]=e,i._taskLoad+=e,i})}_releaseTask(t,e){t._taskLoad-=t._taskCosts[e],delete t._callbacks[e],delete t._taskCosts[e]}debug(){console.log("Task load: ",this.workerPool.map(t=>t._taskLoad))}dispose(){for(let t=0;t<this.workerPool.length;++t)this.workerPool[t].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}}}),kEt=U(()=>{});function T1t(t){return function(e,{basePath:i,moduleUrl:r,cdnBuild:s}){if(i!==void 0)return{url:`${i}/${e}`};let n=`${s}/${e}`;if(r===void 0||r.startsWith("file:"))return{url:n};let a=r.slice(0,r.lastIndexOf("/")+1)+e;return a===n?{url:a}:{url:a,fallback:n}}(t,{basePath:M1t,moduleUrl:typeof import.meta.url=="string"?import.meta.url:void 0,cdnBuild:"https://cdn.spline.design/@splinetool/runtime@2.0.206/build"})}function lQ(t,e){let{url:i,fallback:r}=T1t(e);r!==void 0&&t.addEventListener("error",()=>{t.src=r},{once:!0}),t.src=i}var M1t,eq=U(()=>{kEt()});function A1t(t,e){iq.set(t,e)}function hQ(t){return iq.get(t)}function uQ(t,e){let i=`${e}:${t}`;a9.has(i)||a9.add(i)}var iq,a9,rq=U(()=>{iq=new Map,a9=new Set});function oB(t,e=0){let i=3735928559^e,r=1103547991^e;if(Array.isArray(t))for(let s,n=0;n<t.length;n++)s=t[n],i=Math.imul(i^s,2654435761),r=Math.imul(r^s,1597334677);else for(let s,n=0;n<t.length;n++)s=t.charCodeAt(n),i=Math.imul(i^s,2654435761),r=Math.imul(r^s,1597334677);return i=Math.imul(i^i>>>16,2246822507),i^=Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507),r^=Math.imul(i^i>>>13,3266489909),4294967296*(2097151&r)+(i>>>0)}function dQ(t){return B1t.get(t)}function xA(t){if(/[iu]?vec\d/.test(t))return t.startsWith("ivec")?Int32Array:t.startsWith("uvec")?Uint32Array:Float32Array;if(/mat\d/.test(t)||/float/.test(t))return Float32Array;if(/uint/.test(t))return Uint32Array;if(/int/.test(t))return Int32Array;throw new Error(`THREE.NodeUtils: Unsupported type: ${t}`)}function cQ(t){return/float|int|uint|bool/.test(t)?1:/vec2/.test(t)?2:/vec3/.test(t)?3:/vec4/.test(t)||/mat2/.test(t)?4:/mat3/.test(t)?9:/mat4/.test(t)?16:void Ht(`TSL: Unsupported type: ${t}`,new Ss)}function VEt(t){return/float|int|uint|bool/.test(t)?1:/vec2/.test(t)?2:/vec3/.test(t)?3:/vec4/.test(t)||/mat2/.test(t)?4:/mat3/.test(t)?12:/mat4/.test(t)?16:void Ht(`TSL: Unsupported type: ${t}`,new Ss)}function zEt(t){return/float|int|uint|bool/.test(t)?1:/vec2/.test(t)?2:/vec3/.test(t)||/vec4/.test(t)?4:/mat2/.test(t)?2:/mat3/.test(t)||/mat4/.test(t)?4:void Ht(`TSL: Unsupported type: ${t}`,new Ss)}function Kc(t){if(t==null)return null;let e=typeof t;return t.isNode===!0?"node":e==="number"?"float":e==="boolean"?"bool":e==="string"?"string":e==="function"?"shader":t.isVector2===!0?"vec2":t.isVector3===!0?"vec3":t.isVector4===!0?"vec4":t.isMatrix2===!0?"mat2":t.isMatrix3===!0?"mat3":t.isMatrix4===!0?"mat4":t.isColor===!0?"color":t instanceof ArrayBuffer?"ArrayBuffer":null}function lB(t,...e){let i=t?t.slice(-4):void 0;return e.length===1&&(i==="vec2"?e=[e[0],e[0]]:i==="vec3"?e=[e[0],e[0],e[0]]:i==="vec4"&&(e=[e[0],e[0],e[0],e[0]])),t==="color"?new se(...e):i==="vec2"?new Y(...e):i==="vec3"?new E(...e):i==="vec4"?new Se(...e):i==="mat2"?new NG(...e):i==="mat3"?new Ms(...e):i==="mat4"?new bt(...e):t==="bool"?e[0]||!1:t==="float"||t==="int"||t==="uint"?e[0]||0:t==="string"?e[0]||"":t==="ArrayBuffer"?function(r){return Uint8Array.from(atob(r),s=>s.charCodeAt(0)).buffer}(e[0]):null}function pQ(t){let e=l9.get(t);return e===void 0&&(e={},l9.set(t,e)),e}function Tt(t,e){if(_5.has(t))re(`TSL: Redefinition of method chaining '${t}'.`);else{if(typeof e!="function")throw new Error(`THREE.TSL: Node element ${t} is not a function`);_5.set(t,e),t!=="assign"&&(Ae.prototype[t]=function(...i){return this.isStackNode?this.addToStack(e(...i)):e(this,...i)},Ae.prototype[t+"Assign"]=function(...i){return this.isStackNode?this.assign(i[0],e(...i)):this.assign(e(this,...i))})}}function wA(t,e,i){Mv[t]=Mv[e]=Mv[i]={get(){this._cache=this._cache||{};let a=this._cache[t];return a===void 0&&(a=new h9(this,t),this._cache[t]=a),a},set(a){this[t].assign(ge(a))}};let r=t.toUpperCase(),s=e.toUpperCase(),n=i.toUpperCase();Ae.prototype["set"+r]=Ae.prototype["set"+s]=Ae.prototype["set"+n]=function(a){let o=u9(t);return new k1t(this,o,ge(a))},Ae.prototype["flip"+r]=Ae.prototype["flip"+s]=Ae.prototype["flip"+n]=function(){let a=u9(t);return new V1t(this,a)}}function mQ(t){return t[0]&&(t[0].isNode||Object.getPrototypeOf(t[0])!==Object.prototype)}function ty(t){return t&&t.isNode&&t.traverse(e=>{e.isConstNode&&(t=e.value)}),Boolean(t)}function ey(t,e){return new z1t(t,e)}function tt(t,e=null){let i=new L1t(t,e);return new Proxy(()=>{},{apply:(r,s,n)=>i.call(...n),get:(r,s,n)=>Reflect.get(i,s,n),set:(r,s,n,a)=>Reflect.set(i,s,n,a)})}function SA(t){return Jd&&Jd.addToStack(t),t}function fQ(t,e,i=null){return rc(i,{getShadow:({light:r,shadowColorNode:s})=>e===r?s.mul(t):s})}function gQ(t,e=null){return rc(e,{getAO:(i,{material:r})=>r.transparent===!0?i:i!==null?i.mul(t):t})}function yQ(t,e){return re('TSL: "label()" has been deprecated. Use "setName()" instead.'),MR(t,e)}function vQ(t,e){let i=d9.get(t);return i===void 0&&(i=new K1(t,e),d9.set(t,i)),i}function TA(t,e=null,i=0,r=0,s=Cg,n=!1){return e==="mat3"||e===null&&t.itemSize===9?Sn(new Yd(t,"vec3",9,0).setUsage(s).setInstanced(n),new Yd(t,"vec3",9,3).setUsage(s).setInstanced(n),new Yd(t,"vec3",9,6).setUsage(s).setInstanced(n)):e==="mat4"||e===null&&t.itemSize===16?tc(new Yd(t,"vec4",16,0).setUsage(s).setInstanced(n),new Yd(t,"vec4",16,4).setUsage(s).setInstanced(n),new Yd(t,"vec4",16,8).setUsage(s).setInstanced(n),new Yd(t,"vec4",16,12).setUsage(s).setInstanced(n)):new Yd(t,e,i,r).setUsage(s)}function bQ(t,e=!0){return re('TSL: "cache()" has been deprecated. Use "isolate()" instead.'),gg(t).setParent(e)}function _Q(t,e,i,r=F(0),s=F(1)){return c9(t,e,i,r,s,!0)}function xQ(t,e="",i=null){return(t=ge(t)).before(new F1t(t,e,i))}function LEt(t){re("TSL: AddNodeElement has been removed in favor of tree-shaking. Trying add",t)}function wQ(t,e,i){let r;if(e.isStorageInstancedBufferAttribute===!0)r=Kd(e,"mat4",Math.max(i,1)).element(Xl);else if(16*i*4<=t.getUniformBufferLimit())r=Mg(e.array,"mat4",Math.max(i,1)).element(Xl);else{let s=x5.get(e);s||(s=new IG(e.array,16,1),x5.set(e,s));let n=e.usage===$h?AR:T2,a=[n(s,"vec4",16,0),n(s,"vec4",16,4),n(s,"vec4",16,8),n(s,"vec4",16,12)];r=tc(...a)}return r}function o9(t,e,i,r,s,n){let a=t.element(s.x),o=t.element(s.y),l=t.element(s.z),h=t.element(s.w),u=i.mul(e),d=Ds(a.mul(n.x).mul(u),o.mul(n.y).mul(u),l.mul(n.z).mul(u),h.mul(n.w).mul(u));return r.mul(d).xyz}function SQ(t,e,i,r,s,n,a){let o=t.element(n.x),l=t.element(n.y),h=t.element(n.z),u=t.element(n.w),d=Ds(a.x.mul(o),a.y.mul(l),a.z.mul(h),a.w.mul(u));return d=s.mul(d).mul(r),{skinNormal:d.transformDirection(e).xyz,skinTangent:d.transformDirection(i).xyz}}function TQ(t,e,i,r,s){let n=t.skeleton,a=_S.get(n);if(a===void 0){n.update();let o=new Float32Array(n.boneMatrices);a={previousBoneMatrices:o,node:Mg(o,"mat4",n.bones.length)},_S.set(n,a)}return o9(a.node,zp,e,i,r,s)}function C1t(t){let e=t.target;e.removeEventListener("dispose",C1t);let i=iv.get(e);i!==void 0&&(iv.delete(e),i.dispose())}function MQ(t,e){e===f4?t.mapping=jg:e===g4&&(t.mapping=$2)}function AQ(t,e,i){let r=new ii(t,e,{magFilter:pe,minFilter:pe,generateMipmaps:!1,type:si,format:hn,colorSpace:Hu,depthBuffer:i});return r.texture.mapping=X2,r.texture.name="PMREM.cubeUv",r.texture.isPMREMTexture=!0,r.scissorTest=!0,r}function b5(t){let e=new Pe;return e.depthTest=!1,e.depthWrite=!1,e.blending=Wi,e.name=`PMREM_${t}`,e}function CQ(t){let e=b5("cubemap");return e.fragmentNode=Wa(t,xS),e}function EQ(t){let e=b5("equirect");return e.fragmentNode=Pi(t,CR(xS),0),e}function PQ(t){return Object.freeze({isMaterial:!0,isDrawState:!0,id:t.id,name:t.name,type:t.type,transparent:t.transparent,blending:t.blending,premultipliedAlpha:t.premultipliedAlpha,blendSrc:t.blendSrc,blendDst:t.blendDst,blendEquation:t.blendEquation,blendSrcAlpha:t.blendSrcAlpha,blendDstAlpha:t.blendDstAlpha,blendEquationAlpha:t.blendEquationAlpha,blendColor:t.blendColor,blendAlpha:t.blendAlpha,colorWrite:t.colorWrite,mrtWriteMask:t.mrtWriteMask,depthWrite:t.depthWrite,depthTest:t.depthTest,depthFunc:t.depthFunc,stencilWrite:t.stencilWrite,stencilFunc:t.stencilFunc,stencilRef:t.stencilRef,stencilFail:t.stencilFail,stencilZFail:t.stencilZFail,stencilZPass:t.stencilZPass,stencilFuncMask:t.stencilFuncMask,stencilWriteMask:t.stencilWriteMask,side:t.side,wireframe:t.wireframe===!0,alphaToCoverage:t.alphaToCoverage,forceSinglePass:t.forceSinglePass,polygonOffset:t.polygonOffset,polygonOffsetFactor:t.polygonOffsetFactor,polygonOffsetUnits:t.polygonOffsetUnits})}function RQ(t,e){if(t===null||e===null)return t===e;for(let i in t)if(t[i]!==e[i])return!1;return!0}function E1t(t){return t.index!==null?t.index.version:t.attributes.position.version}function P1t(t){return t.index!==null?t.index.id:t.attributes.position.id}function DQ(t){let e=[],i=t.index,r=t.attributes.position;if(i!==null){let n=i.array;for(let a=0,o=n.length;a<o;a+=3){let l=n[a+0],h=n[a+1],u=n[a+2];e.push(l,h,h,u,u,l)}}else for(let n=0,a=r.array.length/3-1;n<a;n+=3){let o=n+0,l=n+1,h=n+2;e.push(o,l,l,h,h,o)}let s=new(r.count>=65535?pm:Y8)(e,1);return s.version=E1t(t),s.__id=P1t(t),s}function FEt(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?t.z-e.z:t.id-e.id}function OQ(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:t.id-e.id}function IQ(t){return!!(t.transparent===!0||t.transmission>0||t.transmissionNode&&t.transmissionNode.isNode||t.backdropNode&&t.backdropNode.isNode)}function NQ(t){return(t.transmission>0||t.transmissionNode&&t.transmissionNode.isNode)&&t.side===Xs&&t.forceSinglePass===!1}function BQ(t,e=null,i=null){if(e&&e.isNode){let r=e;e=()=>r}return new aq(new Map([[t,e]]),i)}function kQ(t,e=null){let i=new Map;for(let[r,s]of t){let n=s!==null?typeof s=="function"?s:()=>s:null;i.set(r,n)}return new aq(i,e)}function VQ(t,e){for(let i=0;i<t.length;i++)if(t[i].name===e)return i;return-1}function UEt(t,e=null){return rc(e,{getUV:typeof t=="function"?t:()=>t})}function R1t(t){let e=T9.get(t);return e===void 0&&(e={},T9.set(t,e)),e}function zQ(t,e=0){let i=R1t(t),r=i[e];return r===void 0&&(i[e]=r=new bt,i[e].copy(t.matrixWorld)),r}function hB(t){let e,i=t.context.getViewZ;return i!==void 0&&(e=i(this)),(e||ws.z).negate()}function ND(t){let e=(M6=M6||new WeakMap).get(t);return e===void 0&&M6.set(t,e={}),e}function TR(t){let e=ND(t);return e.shadowMatrix||(e.shadowMatrix=_e("mat4").setGroup(Me).onRenderUpdate(i=>((t.castShadow!==!0||i.renderer.shadowMap.enabled===!1)&&(t.shadow.camera.coordinateSystem!==i.camera.coordinateSystem&&(t.shadow.camera.coordinateSystem=i.camera.coordinateSystem,t.shadow.camera.updateProjectionMatrix()),t.shadow.updateMatrices(t)),t.shadow.matrix)))}function LQ(t,e=Dh){let i=TR(t).mul(e);return i.xyz.div(i.w)}function uB(t){let e=ND(t);return e.position||(e.position=_e(new E).setGroup(Me).onRenderUpdate((i,r)=>r.value.setFromMatrixPosition(t.matrixWorld)))}function FQ(t){let e=ND(t);return e.targetPosition||(e.targetPosition=_e(new E).setGroup(Me).onRenderUpdate((i,r)=>r.value.setFromMatrixPosition(t.target.matrixWorld)))}function dB(t){let e=ND(t);return e.viewPosition||(e.viewPosition=_e(new E).setGroup(Me).onRenderUpdate(({camera:i},r)=>{r.value=r.value||new E,r.value.setFromMatrixPosition(t.matrixWorld),r.value.applyMatrix4(i.matrixWorldInverse)}))}function sq(t,e={}){return e.toneMapping=t.toneMapping,e.toneMappingExposure=t.toneMappingExposure,e.outputColorSpace=t.outputColorSpace,e.renderTarget=t.getRenderTarget(),e.activeCubeFace=t.getActiveCubeFace(),e.activeMipmapLevel=t.getActiveMipmapLevel(),e.renderObjectFunction=t.getRenderObjectFunction(),e.pixelRatio=t.getPixelRatio(),e.mrt=t.getMRT(),e.clearColor=t.getClearColor(e.clearColor||new se),e.clearAlpha=t.getClearAlpha(),e.autoClear=t.autoClear,e.scissorTest=t.getScissorTest(),e}function D1t(t,e){return e=sq(t,e),t.setMRT(null),t.setRenderObjectFunction(null),t.setClearColor(0,1),t.autoClear=!0,e}function O1t(t,e){t.toneMapping=e.toneMapping,t.toneMappingExposure=e.toneMappingExposure,t.outputColorSpace=e.outputColorSpace,t.setRenderTarget(e.renderTarget,e.activeCubeFace,e.activeMipmapLevel),t.setRenderObjectFunction(e.renderObjectFunction),t.setPixelRatio(e.pixelRatio),t.setMRT(e.mrt),t.setClearColor(e.clearColor,e.clearAlpha),t.autoClear=e.autoClear,t.setScissorTest(e.scissorTest)}function nq(t,e={}){return e.background=t.background,e.backgroundNode=t.backgroundNode,e.overrideMaterial=t.overrideMaterial,e}function I1t(t,e){return e=nq(t,e),t.background=null,t.backgroundNode=null,t.overrideMaterial=null,e}function N1t(t,e){t.background=e.background,t.backgroundNode=e.backgroundNode,t.overrideMaterial=e.overrideMaterial}function jEt(t,e,i={}){return nq(e,i=sq(t,i))}function UQ(t,e,i){return I1t(e,i=D1t(t,i))}function jQ(t,e,i){O1t(t,i),N1t(e,i)}function GQ(t){return t+(sc-t%sc)%sc}function iy(){return DR===null&&((DR=new yr(new Uint8Array([255,255,255,255]),1,1)).needsUpdate=!0),DR}function hu(t,e){OR[0]=e,t.queue.submit(OR),OR[0]=null}function WQ(t,e,i,r,s,n,a,o,l,h){Sa.texture=e,Sa.mipLevel=i,Sa.origin.z=r,Lu.offset=r*n,Lu.bytesPerRow=a,Lu.rowsPerImage=o,xa.width=l,xa.height=h,t.queue.writeTexture(Sa,s.data,Lu,xa),Sa.reset(),Lu.reset(),xa.reset()}function cB(t,e){let i,r=t.format,s=t.type,n=t.normalized,a=t.colorSpace,o=Zi.getTransfer(a),l=!1;if(n&&(l=e.features.has(wS.TextureFormatsTier1),l===!1&&re("WebGPURenderer: Unable to use normalized textures without texture-formats-tier1 feature.")),t.isCompressedTexture===!0||t.isCompressedArrayTexture===!0)switch(r){case Vpt:case zpt:i=o===xr?Q.BC1RGBAUnormSRGB:Q.BC1RGBAUnorm;break;case Lpt:i=o===xr?Q.BC2RGBAUnormSRGB:Q.BC2RGBAUnorm;break;case Fpt:i=o===xr?Q.BC3RGBAUnormSRGB:Q.BC3RGBAUnorm;break;case umt:i=Q.BC4RUnorm;break;case dmt:i=Q.BC4RSnorm;break;case PG:i=Q.BC5RGUnorm;break;case cmt:i=Q.BC5RGSnorm;break;case omt:i=o===xr?Q.BC7RGBAUnormSRGB:Q.BC7RGBAUnorm;break;case lmt:i=Q.BC6HRGBFloat;break;case hmt:i=Q.BC6HRGBUFloat;break;case jpt:case Upt:i=o===xr?Q.ETC2RGB8UnormSRGB:Q.ETC2RGB8Unorm;break;case Gpt:i=o===xr?Q.ETC2RGBA8UnormSRGB:Q.ETC2RGBA8Unorm;break;case Wpt:i=Q.EACR11Unorm;break;case qpt:i=Q.EACR11Snorm;break;case EG:i=Q.EACRG11Unorm;break;case Hpt:i=Q.EACRG11Snorm;break;case $pt:i=o===xr?Q.ASTC4x4UnormSRGB:Q.ASTC4x4Unorm;break;case Xpt:i=o===xr?Q.ASTC5x4UnormSRGB:Q.ASTC5x4Unorm;break;case Ypt:i=o===xr?Q.ASTC5x5UnormSRGB:Q.ASTC5x5Unorm;break;case Kpt:i=o===xr?Q.ASTC6x5UnormSRGB:Q.ASTC6x5Unorm;break;case Zpt:i=o===xr?Q.ASTC6x6UnormSRGB:Q.ASTC6x6Unorm;break;case Qpt:i=o===xr?Q.ASTC8x5UnormSRGB:Q.ASTC8x5Unorm;break;case Jpt:i=o===xr?Q.ASTC8x6UnormSRGB:Q.ASTC8x6Unorm;break;case tmt:i=o===xr?Q.ASTC8x8UnormSRGB:Q.ASTC8x8Unorm;break;case emt:i=o===xr?Q.ASTC10x5UnormSRGB:Q.ASTC10x5Unorm;break;case imt:i=o===xr?Q.ASTC10x6UnormSRGB:Q.ASTC10x6Unorm;break;case rmt:i=o===xr?Q.ASTC10x8UnormSRGB:Q.ASTC10x8Unorm;break;case smt:i=o===xr?Q.ASTC10x10UnormSRGB:Q.ASTC10x10Unorm;break;case nmt:i=o===xr?Q.ASTC12x10UnormSRGB:Q.ASTC12x10Unorm;break;case amt:i=o===xr?Q.ASTC12x12UnormSRGB:Q.ASTC12x12Unorm;break;case hn:i=o===xr?Q.RGBA8UnormSRGB:Q.RGBA8Unorm;break;default:Ht("WebGPURenderer: Unsupported texture format.",r)}else switch(r){case hn:switch(s){case Y2:i=Q.RGBA8Snorm;break;case K2:i=l?Q.RGBA16Snorm:Q.RGBA16Sint;break;case Y1:i=l?Q.RGBA16Unorm:Q.RGBA16Uint;break;case En:i=Q.RGBA32Uint;break;case yl:i=Q.RGBA32Sint;break;case bl:i=o===xr?Q.RGBA8UnormSRGB:Q.RGBA8Unorm;break;case si:i=Q.RGBA16Float;break;case Ye:i=Q.RGBA32Float;break;default:Ht("WebGPURenderer: Unsupported texture type with RGBAFormat.",s)}break;case y4:switch(s){case MG:i=Q.RGB9E5UFloat;break;case AG:i=Q.RG11B10UFloat;break;default:Ht("WebGPURenderer: Unsupported texture type with RGBFormat.",s)}break;case Ka:switch(s){case Y2:i=Q.R8Snorm;break;case K2:i=l?Q.R16Snorm:Q.R16Sint;break;case Y1:i=l?Q.R16Unorm:Q.R16Uint;break;case En:i=Q.R32Uint;break;case yl:i=Q.R32Sint;break;case bl:i=Q.R8Unorm;break;case si:i=Q.R16Float;break;case Ye:i=Q.R32Float;break;default:Ht("WebGPURenderer: Unsupported texture type with RedFormat.",s)}break;case Bo:switch(s){case Y2:i=Q.RG8Snorm;break;case K2:i=l?Q.RG16Snorm:Q.RG16Sint;break;case Y1:i=l?Q.RG16Unorm:Q.RG16Uint;break;case En:i=Q.RG32Uint;break;case yl:i=Q.RG32Sint;break;case bl:i=Q.RG8Unorm;break;case si:i=Q.RG16Float;break;case Ye:i=Q.RG32Float;break;default:Ht("WebGPURenderer: Unsupported texture type with RGFormat.",s)}break;case Jp:switch(s){case Y1:i=Q.Depth16Unorm;break;case En:i=Q.Depth24Plus;break;case Ye:i=Q.Depth32Float;break;default:Ht("WebGPURenderer: Unsupported texture type with DepthFormat.",s)}break;case dv:switch(s){case Z2:i=Q.Depth24PlusStencil8;break;case Ye:e&&e.features.has(wS.Depth32FloatStencil8)===!1&&Ht('WebGPURenderer: Depth textures with DepthStencilFormat + FloatType can only be used with the "depth32float-stencil8" GPU feature.'),i=Q.Depth32FloatStencil8;break;default:Ht("WebGPURenderer: Unsupported texture type with DepthStencilFormat.",s)}break;case v4:switch(s){case yl:i=Q.R32Sint;break;case En:i=Q.R32Uint;break;default:Ht("WebGPURenderer: Unsupported texture type with RedIntegerFormat.",s)}break;case b4:switch(s){case yl:i=Q.RG32Sint;break;case En:i=Q.RG32Uint;break;default:Ht("WebGPURenderer: Unsupported texture type with RGIntegerFormat.",s)}break;case CG:switch(s){case yl:i=Q.RGBA32Sint;break;case En:i=Q.RGBA32Uint;break;default:Ht("WebGPURenderer: Unsupported texture type with RGBAIntegerFormat.",s)}break;default:Ht("WebGPURenderer: Unsupported texture format.",r)}return i}var qQ,pB,mB,fB,HQ,$Q,Ss,df,ry,cf,B1t,l9,pf,ze,XQ,Fn,gB,P_,R_,mf,YQ,KQ,Ae,Zc,yB,Cr,ZQ,QQ,h9,k1t,V1t,MA,vB,ph,JQ,Jd,_5,tJ,u9,Mv,mh,fh,gh,eJ,iJ,rJ,bB,sJ,nJ,z1t,aJ,oJ,lJ,_B,AA,CA,EA,D_,O_,xB,PA,Gs,wB,ge,sy,I_,Qc,oi,Qt,jt,RA,hJ,L1t,ny,DA,xe,uJ,SB,F,Z,Ft,So,Xt,rs,OA,TB,et,IA,Jc,NA,oe,BA,kA,MB,N_,Sn,tc,AB,CB,dJ,cJ,Ui,uu,tp,Ai,ep,VA,yh,du,B_,ff,To,fd,k_,V_,z_,L_,gd,ay,ip,yd,rp,sp,F_,gf,np,oy,pJ,ly,U_,zA,LA,FA,UA,jA,EB,PB,GA,mJ,Me,RB,hy,_e,DB,OB,fJ,gJ,yJ,vJ,vs,Ds,wi,Ge,Mo,j_,IB,NB,BB,WA,kB,VB,zB,LB,FB,UB,jB,GB,WB,qB,HB,$B,XB,YB,KB,ZB,ut,G_,bJ,W_,_J,xJ,wJ,QB,JB,tk,ek,qA,yf,q_,vh,Na,HA,bh,H_,ua,Ol,Ba,ik,Il,rk,sk,nk,ak,ok,$A,lk,XA,hk,_r,YA,_h,KA,uk,ZA,QA,dk,ck,JA,t3,pk,mk,fk,so,ss,ap,gk,yk,vk,Ko,cu,Zo,e3,bk,i3,_k,xk,wk,Sk,r3,gi,Nl,$_,s3,Ao,n3,Tk,Mk,Ak,Ck,SJ,TJ,ka,a3,rc,Ek,MR,o3,l3,MJ,Pk,Rk,AJ,op,vd,Dk,Ok,Ik,h3,u3,CJ,X_,EJ,PJ,Nk,RJ,DJ,Bk,OJ,kk,Vk,d9,Yd,d3,IJ,T2,AR,ds,zk,Xl,NJ,BJ,kJ,Lk,VJ,c3,zJ,bS,gg,LJ,c9,p3,Co,FJ,UJ,m3,Fk,jJ,Uk,GJ,WJ,jk,F1t,Gk,Va,$i,lp,f3,Wk,g3,bd,qJ,Pi,HJ,bs,$J,XJ,YJ,y3,Mg,KJ,ZJ,Un,pu,Y_,K_,qr,v3,Bl,hp,up,vf,b3,qk,QJ,JJ,_3,Z_,x3,Q_,w3,J_,S3,tx,T3,ex,M3,ix,A3,rx,_d,xd,wd,za,Hk,Sd,uy,ttt,$k,ett,Xk,Ii,itt,rtt,stt,ntt,att,ott,kl,ltt,Qo,htt,utt,dtt,ctt,Yk,ptt,xh,Kk,C3,E3,Zk,jn,Hr,zp,Dh,P3,ws,mr,Qk,R3,dp,mtt,sx,da,Jk,bf,tV,Ci,Td,Md,eV,D3,ftt,gtt,ytt,O3,iV,nx,ax,rV,sV,nV,aV,oV,I3,Wa,vtt,btt,ox,Mr,lV,_tt,mu,hV,xtt,wtt,uV,dV,cV,pV,mV,N3,B3,fV,gV,Stt,Ttt,lx,Ad,hx,yV,ux,Mtt,Att,vV,Ctt,cp,bV,Ett,_V,k3,xV,V3,Ptt,Rtt,z3,Dtt,Ott,L3,wV,Et,SV,TV,MV,AV,F3,CV,U3,EV,dy,dx,PV,RV,DV,OV,IV,NV,BV,kV,VV,zV,LV,FV,UV,jV,GV,WV,qV,HV,j3,G3,W3,cx,q3,$V,XV,H3,YV,_f,KV,Ps,pp,px,Itt,ZV,Ntt,Btt,ktt,Vtt,ztt,Ltt,Kd,x5,QV,$3,X3,JV,tz,Ftt,Utt,Y3,ez,mx,_S,iz,jtt,Gtt,Xi,Wtt,rz,K3,Eo,sz,nz,az,xf,qtt,oz,Htt,mp,Z3,$tt,Q3,Xtt,J3,tC,eC,Jo,fp,Ytt,lz,iC,hz,fx,gx,Ktt,uz,rC,yx,Ztt,wh,Qtt,Jtt,tet,dz,cz,eet,iet,pz,Pe,ret,p9,set,m9,net,vx,sC,mz,gp,fz,aet,oet,het,U1t,uet,f9,CR,nC,gz,iv,yz,aC,det,Ag,vz,cet,g9,wf,yp,pet,met,fet,Av,get,y9,yet,v9,bz,oC,_z,vet,xz,bet,_et,lC,xet,fu,cy,wet,wz,hC,Tet,Met,Aet,Sz,Cet,bx,uC,_x,Tz,dC,Mz,cC,Az,Cz,Ez,Pz,Rz,pC,Eet,Dz,Pet,Ret,Det,Oz,Iz,Oet,Iet,Net,Nz,Bet,Bz,py,my,xx,ER,kz,mC,wx,fC,Sx,gC,Tx,yC,Vz,ket,zz,Vet,zet,Let,Fet,Lz,Fz,fy,vC,Uz,Uet,jet,Get,jz,Gz,gy,yy,Wet,Wz,bC,_C,xC,qet,Mx,Het,wC,xS,$et,qz,SC,Hz,b9,$z,Xet,Yet,PR,Ket,_9,Zet,Qet,Jet,x9,Xz,tit,w9,vy,eit,RR,iit,rit,iT,sit,nit,ait,S9,oit,Cd,lit,Yz,hit,uit,dit,cit,pit,Kz,mit,Ed,tl,sc,fit,git,yit,Zz,Qz,vit,bit,Jz,_it,xit,wit,Ax,Sit,Sf,Tit,Mit,Ait,Cit,Eit,Pit,TC,aq,t6,Rit,Cx,Dit,Oit,Iit,Nit,Bit,rT,kit,Vit,zit,e6,Ex,i6,Lit,r6,Fit,Uit,Px,Vl,jit,Git,Wit,qit,MC,Hit,$it,Xit,s6,Yit,Kit,Zit,n6,Qit,Jit,trt,gu,ert,irt,rrt,Gn,Tf,srt,a6,nrt,art,ort,lrt,hrt,urt,drt,crt,prt,o6,mrt,Mf,vp,Af,AC,by,Rx,Sh,_y,Dx,xy,Ox,Ix,frt,Nx,l6,grt,yrt,CC,vrt,Pr,brt,_rt,h6,xrt,Cf,wrt,Srt,EC,zl,Trt,Mrt,Art,Crt,Ert,Prt,Rrt,PC,u6,RC,d6,Drt,c6,Ort,Irt,Nrt,DC,Brt,krt,Vrt,zrt,T9,j1t,Lrt,Frt,Urt,jrt,Grt,Wrt,qrt,Hrt,$rt,Xrt,OC,Yrt,Krt,Bx,Zrt,kx,p6,m6,yu,Qrt,Jrt,tst,est,ist,f6,g6,y6,rst,v6,sst,nst,ast,b6,_6,$r,Vx,ost,lst,hst,x6,w6,ust,dst,S6,T6,cst,IC,bp,_p,pst,mst,zx,fst,gst,yst,vst,bst,NC,_st,xst,wst,Sst,Tst,Mst,_n,Ast,Th,Cst,Est,Pst,Rst,Dst,Ost,Ist,Nst,Bst,ae,kst,Vst,zst,Lst,Fst,Ust,jst,Gst,Wst,qst,Hst,$st,Xst,Yst,Kst,Zst,Qst,Jst,tnt,ent,int,rnt,snt,nnt,ant,M6,BC,ont,lnt,hnt,unt,dnt,kC,wy,VC,cnt,pnt,zC,M9,Lx,A6,C6,E6,P6,R6,D6,O6,Ef,I6,mnt,fnt,gnt,N6,Fx,B6,k6,ynt,V6,Sy,LC,vnt,bnt,_nt,xnt,z6,L6,wnt,Snt,F6,xp,FC,U6,A9,Tnt,Mnt,Ty,Ux,Rs,Xr,Ant,Cnt,j6,Ent,Pnt,G6,Rnt,Dnt,xn,Ont,Int,el,Nnt,Bnt,knt,W6,Vnt,q6,Po,H6,My,ca,Mh,znt,Lnt,Fnt,Unt,jnt,nr,Gnt,Wnt,il,qnt,Hnt,UC,$nt,Xnt,Ay,Ynt,Knt,Znt,Qnt,Jnt,tat,eat,iat,rat,jx,Gx,Wx,sat,nat,aat,oat,Pf,lat,hat,uat,dat,cat,pat,mat,fat,jC,gat,yat,vat,bat,_at,$6,X6,xat,wat,Sat,Y6,Tat,Mat,Aat,Cat,Eat,Pat,Rat,Dat,Oat,Iat,Nat,Bat,kat,Vat,zat,Lat,Fat,Uat,jat,Gat,Wat,qat,Hat,$at,Xat,Yat,Kat,Zat,Qat,Jat,tot,eot,iot,rot,sot,not,aot,K6,R,Ll,oot,lot,GC,hot,Z6,uot,Q6,dot,cot,pot,WC,mot,Pd,fot,got,yot,vot,bot,_ot,xot,wot,Sot,Tot,Mot,Aot,Cot,Eot,Pot,Rot,Dot,J6,tL,Oot,Iot,qx,eL,Not,iL,Bot,kot,C9,E9,M2,Vot,zot,Lot,Fot,qC,Hx,Cy,Uot,jot,Got,rl,vu,rL,Wot,HC,$C,qot,Rd,Hot,sL,$ot,nL,Xot,Yot,aL,Rf,XC,$x,Xx,Df,bu,Kot,Zot,oL,lL,hL,Qot,Jot,tlt,elt,ilt,uL,rlt,slt,DR,YC,nlt,dL,KC,Of,alt,olt,If,Ah,Wn,La,Yi,cL,pL,ZC,Q,QC,sl,Ei,wp,Yx,Dd,mL,JC,fL,Sp,gL,qn,llt,Kx,wS,yL,hlt,ult,dlt,clt,OR,plt,vL,Nf,Ey,bL,Py,Ry,_L,mlt,xL,tE,eE,Od,Id,Zx,iE,rE,Bf,Dy,Qx,kf,_s,flt,glt,Jx,ylt,vlt,blt,_lt,wL,tw,xlt,pa,Sa,ew,Lu,iw,Vf,Nd,xa,wlt,Slt,Tlt,Mlt,Alt,SL,Clt,Elt,Plt,Rlt,TL,sE,ML,Dlt,Olt,AL,Oy,Ilt,CL,Nlt,ma,nE,EL,Blt,klt,Vlt,Fa,Iy,zf,zlt,Llt,Flt,Ult,jlt,Ny,Lf,Ff,Ro,Glt,PL,Ch,Wlt,By,qlt,Hlt,rw,$lt,Fl,Do,Ua,sw,ky,nw,aw,nl,Eh,Yr,_u,Xlt,Ylt,Klt,Zlt,IR,G1t,W1t,Yg,ea,NR,At,vt,Qi,q1t,P9,H1t,fr,ke,BR,oq,lq,wc,hl,yg,Oo,kR,Hv,$1t,X1t,Y1t,K1t,Oc,mb,Z1t,ih,w5,Te,Q1t,J1t,hq,tvt,evt,Xa,Kr,ivt,$v,Xv,BD,ko,rvt,Bt,R9,kD,k1,VD,I,de,svt,Di,nvt,D9,Pc,Sm,uq,ho,Rn,Zr,qp,avt,ct,dq,VR,ovt,lvt,hvt,Yn,Kn,ci,uvt,dvt,zR,Yv,zD,bm,cq,cvt,LR,pvt,Kt,mvt,ti,$t,qh,fvt,gvt,yvt,FR,LD,vvt,Kv,bvt,O9,_vt,xvt,pq,Ra,sT,wvt,be,mq,Rr,Svt,Tvt,Mvt,Avt,Cvt,Evt,Pvt,FD,Zv,UD,Ic,Qv,Wo,Lo,Rvt,Dvt,fq,Ovt,nT,Ivt,V1,gq,Nvt,zg,Qa,th,pi,Bvt,kvt,S5,Xu,Bn,Ji,rv,I9,xl,Si,Vvt,Hp,A2,zvt,Lvt,Jt,Sc,Fvt,Uvt,yq,T5,Vi,mt,aT,$p,ui,jvt,Gvt,Lr,st,j,at,Wvt,SS,N9,B9,Lg,cc,qvt,z1,UR,cr=U(()=>{ot(),ot(),qQ=["alphaMap","alphaTest","anisotropy","anisotropyMap","anisotropyRotation","aoMap","aoMapIntensity","attenuationColor","attenuationDistance","bumpMap","clearcoat","clearcoatMap","clearcoatNormalMap","clearcoatNormalScale","clearcoatRoughness","color","dispersion","displacementMap","emissive","emissiveIntensity","emissiveMap","envMap","envMapIntensity","envMapRotation","gradientMap","ior","iridescence","iridescenceIOR","iridescenceMap","iridescenceThicknessMap","lightMap","lightMapIntensity","map","matcap","metalness","metalnessMap","normalMap","normalScale","opacity","roughness","roughnessMap","sheen","sheenColor","sheenColorMap","sheenRoughnessMap","shininess","specular","specularColor","specularColorMap","specularIntensity","specularIntensityMap","specularMap","thickness","transmission","transmissionMap"],pB=new WeakMap,mB=new WeakMap,fB=new WeakMap,HQ=class{constructor(t){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(t),this.hasAnimation=t.object.isSkinnedMesh===!0,this.refreshUniforms=qQ,this.renderId=0}firstInitialization(t){return this.renderObjects.has(t)===!1&&(this.getRenderObjectData(t),!0)}needsVelocity(t){let e=t.getMRT();return e!==null&&e.has("velocity")}getRenderObjectData(t){let e=this.renderObjects.get(t);if(e===void 0){let{geometry:i,object:r}=t;if(e={geometryId:i.id,worldMatrix:r.matrixWorld.clone()},r.center&&(e.center=r.center.clone()),r.morphTargetInfluences&&(e.morphTargetInfluences=r.morphTargetInfluences.slice()),t.bundle!==null&&(e.version=t.bundle.version),t.material.transmission>0){let{width:a,height:o}=t.context;e.bufferWidth=a,e.bufferHeight=o}let{environmentIntensity:s,environmentRotation:n}=t.scene;e.environmentIntensity=s,e.environmentRotation=n.clone(),e.lights=this.getLightsData(t.lightsNode.getLights(),[]),this.renderObjects.set(t,e)}return e}getAttributesData(t){let e={};for(let i in t){let r=t[i];e[i]={id:r.isInterleavedBufferAttribute?r.data.uuid:r.id,version:r.isInterleavedBufferAttribute?r.data.version:r.version}}return e}containsNode(t){let e=t.material;for(let i in e)if(e[i]&&e[i].isNode)return!0;return!!(t.context.modelViewMatrix||t.context.modelNormalViewMatrix||t.context.getAO||t.context.getShadow)}getGeometryData(t){let e=fB.get(t);return e===void 0&&(e={_renderId:-1,_equal:!1,attributes:this.getAttributesData(t.attributes),indexId:t.index?t.index.id:null,indexVersion:t.index?t.index.version:null,drawRange:{start:t.drawRange.start,count:t.drawRange.count}},fB.set(t,e)),e}getMaterialData(t){let e=mB.get(t);if(e===void 0){e={_renderId:-1,_equal:!1};for(let i of this.refreshUniforms){let r=t[i];r!=null&&(typeof r=="object"&&r.clone!==void 0?r.isTexture===!0?e[i]={id:r.id,version:0}:e[i]=r.clone():e[i]=r)}mB.set(t,e)}return e}equals(t,e,i){let{object:r,material:s,geometry:n}=t,a=this.getRenderObjectData(t);if(a.worldMatrix.equals(r.matrixWorld)!==!0)return a.worldMatrix.copy(r.matrixWorld),!1;let o=this.getMaterialData(t.material);if(o._renderId!==i){o._renderId=i;for(let u in o){let d=o[u],c=s[u];if(u!=="_renderId"&&u!=="_equal"){if(d.equals!==void 0){if(d.equals(c)===!1)return d.copy(c),o._equal=!1,!1}else if(c.isTexture===!0){if(d.id!==c.id||d.version!==c.version)return d.id=c.id,d.version=c.version,o._equal=!1,!1}else if(d!==c)return o[u]=c,o._equal=!1,!1}}if(o.transmission>0){let{width:u,height:d}=t.context;if(a.bufferWidth!==u||a.bufferHeight!==d)return a.bufferWidth=u,a.bufferHeight=d,o._equal=!1,!1}o._equal=!0}else if(o._equal===!1)return!1;if(a.geometryId!==n.id)return a.geometryId=n.id,!1;let l=this.getGeometryData(t.geometry);if(l._renderId!==i){l._renderId=i;let u=n.attributes,d=l.attributes,c=0,p=0;for(let b in u)c++;for(let b in d){p++;let _=d[b],x=u[b];if(x===void 0)return delete d[b],l._equal=!1,!1;let S=x.isInterleavedBufferAttribute?x.data.uuid:x.id,w=x.isInterleavedBufferAttribute?x.data.version:x.version;if(_.id!==S||_.version!==w)return _.id=S,_.version=w,l._equal=!1,!1}if(p!==c)return l.attributes=this.getAttributesData(u),l._equal=!1,!1;let m=n.index,f=l.indexId,g=l.indexVersion,y=m?m.id:null,v=m?m.version:null;if(f!==y||g!==v)return l.indexId=y,l.indexVersion=v,l._equal=!1,!1;if(l.drawRange.start!==n.drawRange.start||l.drawRange.count!==n.drawRange.count)return l.drawRange.start=n.drawRange.start,l.drawRange.count=n.drawRange.count,l._equal=!1,!1;l._equal=!0}else if(l._equal===!1)return!1;if(a.morphTargetInfluences){let u=!1;for(let d=0;d<a.morphTargetInfluences.length;d++)a.morphTargetInfluences[d]!==r.morphTargetInfluences[d]&&(a.morphTargetInfluences[d]=r.morphTargetInfluences[d],u=!0);if(u)return!1}if(a.lights){for(let u=0;u<e.length;u++)if(a.lights[u].map!==e[u].map)return!1}let h=t.scene;return h.environment===null||s.envMap!==null||a.environmentIntensity===h.environmentIntensity&&a.environmentRotation.equals(h.environmentRotation)!==!1?a.center&&a.center.equals(r.center)===!1?(a.center.copy(r.center),!1):(t.bundle!==null&&(a.version=t.bundle.version),!0):(a.environmentIntensity=h.environmentIntensity,a.environmentRotation.copy(h.environmentRotation),!1)}getLightsData(t,e){e.length=0;for(let i of t)i.isSpotLight===!0&&i.map!==null&&e.push({map:i.map.version});return e}getLights(t,e){let i=pB.get(t);return i===void 0&&(i={renderId:-1,lightsData:[]},pB.set(t,i)),i.renderId===e||(i.renderId=e,this.getLightsData(t.getLights(),i.lightsData)),i.lightsData}needsRefresh(t,e){if(this.hasNode||this.hasAnimation||this.firstInitialization(t)||this.needsVelocity(e.renderer))return!0;let{renderId:i}=e;if(this.renderId!==i){this.renderId=i;let a=this.getRenderObjectData(t);if(a.worldMatrix.copy(t.object.matrixWorld),a.morphTargetInfluences){let o=t.object.morphTargetInfluences;for(let l=0;l<a.morphTargetInfluences.length;l++)a.morphTargetInfluences[l]=o[l]}return a.center&&t.object.center&&a.center.copy(t.object.center),!0}let r=t.object.static===!0,s=t.bundle!==null&&t.bundle.static===!0&&this.getRenderObjectData(t).version===t.bundle.version;if(r||s)return!1;let n=this.getLights(t.lightsNode,i);return this.equals(t,n,i)!==!0}},$Q=[/^StackTrace\.js$/,/^TSLCore\.js$/,/^.*Node\.js$/,/^three\.webgpu.*\.js$/],Ss=class{constructor(t=null){this.isStackTrace=!0,this.stack=function(e){let i=/(?:at\s+(.+?)\s+\()?(?:(.+?)@)?([^@\s()]+):(\d+):(\d+)/;return e.split(`
|
|
1585
1585
|
`).map(r=>{let s=r.match(i);if(!s)return null;let n=s[1]||s[2]||"",a=s[3].split("?")[0],o=parseInt(s[4],10),l=parseInt(s[5],10);return{fn:n,file:a.split("/").pop(),line:o,column:l}}).filter(r=>r&&!$Q.some(s=>s.test(r.file)))}(t||new Error().stack)}getLocation(){if(this.stack.length===0)return"[Unknown location]";let t=this.stack[0],e=t.fn;return`${e?`"${e}()" at `:""}"${t.file}:${t.line}"`}getError(t){return this.stack.length===0?t:`${t}
|
|
1586
1586
|
${this.stack.map(e=>{let i=`${e.file}:${e.line}:${e.column}`;return e.fn?` at ${e.fn} (${i})`:` at ${i}`}).join(`
|
|
1587
1587
|
`)}`}},df=t=>oB(t),ry=t=>oB(t),cf=(...t)=>oB(t),B1t=new Map([[1,"float"],[2,"vec2"],[3,"vec3"],[4,"vec4"],[9,"mat3"],[16,"mat4"]]),l9=new WeakMap,pf={VERTEX:"vertex",FRAGMENT:"fragment"},ze={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},XQ={BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},Fn={READ_ONLY:"readOnly",WRITE_ONLY:"writeOnly",READ_WRITE:"readWrite"},gB=["fragment","vertex"],P_=["setup","analyze","generate"],R_=[...gB,"compute"],mf=["x","y","z","w"],YQ={analyze:"setup",generate:"analyze"},KQ=0,(Ae=class extends Pn{static get type(){return"Node"}constructor(t=null){super(),this.nodeType=t,this.updateType=ze.NONE,this.updateBeforeType=ze.NONE,this.updateAfterType=ze.NONE,this.version=0,this.name="",this.global=!1,this.parents=!1,this.isNode=!0,this._beforeNodes=null,this._cacheKey=null,this._uuid=null,this._cacheKeyVersion=0,this.id=KQ++,this.stackTrace=null,Ae.captureStackTrace===!0&&(this.stackTrace=new Ss)}set needsUpdate(t){t===!0&&this.version++}get uuid(){return this._uuid===null&&(this._uuid=zt.generateUUID()),this._uuid}get type(){return this.constructor.type}onUpdate(t,e){return this.updateType=e,this.update=t.bind(this),this}onFrameUpdate(t){return this.onUpdate(t,ze.FRAME)}onRenderUpdate(t){return this.onUpdate(t,ze.RENDER)}onObjectUpdate(t){return this.onUpdate(t,ze.OBJECT)}onReference(t){return this.updateReference=t.bind(this),this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(let{childNode:t}of this._getChildren())yield t}dispose(){this.dispatchEvent({type:"dispose"})}traverse(t){t(this);for(let e of this.getChildren())e.traverse(t)}_getChildren(t=new Set){let e=[];t.add(this);for(let i of Object.getOwnPropertyNames(this)){let r=this[i];if(i.startsWith("_")!==!0&&!t.has(r)){if(Array.isArray(r)===!0)for(let s=0;s<r.length;s++){let n=r[s];n&&n.isNode===!0&&e.push({property:i,index:s,childNode:n})}else if(r&&r.isNode===!0)e.push({property:i,childNode:r});else if(r&&Object.getPrototypeOf(r)===Object.prototype)for(let s in r){if(s.startsWith("_")===!0)continue;let n=r[s];n&&n.isNode===!0&&e.push({property:i,index:s,childNode:n})}}}return e}getCacheKey(t=!1,e=null){if((t=t||this.version!==this._cacheKeyVersion)===!0||this._cacheKey===null){e===null&&(e=new Set);let i=[];for(let{property:r,childNode:s}of this._getChildren(e))i.push(df(r.slice(0,-4)),s.getCacheKey(t,e));this._cacheKey=cf(ry(i),this.customCacheKey()),this._cacheKeyVersion=this.version}return this._cacheKey}customCacheKey(){return this.id}getScope(){return this}getHash(){return String(this.id)}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(t){let e=this.getNodeType(t);return t.getElementType(e)}getMemberType(){return"void"}getNodeType(t,e=null){let i,r=t.getDataFromNode(this);return e!==null?(r.typeFromOutput=r.typeFromOutput||{},i=r.typeFromOutput[e],i===void 0&&(i=this.generateNodeType(t,e),r.typeFromOutput[e]=i)):(i=r.type,i===void 0&&(i=this.generateNodeType(t),r.type=i)),i}generateNodeType(t,e=null){let i=t.getNodeProperties(this);return i.outputNode?i.outputNode.getNodeType(t,e):this.nodeType}getShared(t){let e=this.getHash(t),i=t.getNodeFromHash(e),r=null;if(i&&i!==this)r=i;else if(t.context.overrideNodes){let s=t.context.overrideNodes.get(this);if(s){let n=t.getDataFromNode(this);n.isOverwritten!==!0?(n.isOverwritten=!0,r=s(t).overrideNode(this,null),n.sharedNode=r):r=n.sharedNode}}return r||this}getArrayCount(){return null}setup(t){let e=t.getNodeProperties(this),i=0;for(let r of this.getChildren())e["node"+i++]=r;return e.outputNode||null}analyze(t,e=null){let i=t.increaseUsage(this);if(this.parents===!0){let r=t.getDataFromNode(this,"any");r.stages=r.stages||{},r.stages[t.shaderStage]=r.stages[t.shaderStage]||[],r.stages[t.shaderStage].push(e)}if(i===1){let r=t.getNodeProperties(this);for(let s of Object.values(r))s&&s.isNode===!0&&s.build(t,this)}}generate(t,e){let{outputNode:i}=t.getNodeProperties(this);if(i&&i.isNode===!0)return i.build(t,e)}updateBefore(){re("Abstract function.")}updateAfter(){re("Abstract function.")}update(){re("Abstract function.")}before(t){return this._beforeNodes===null&&(this._beforeNodes=[]),this._beforeNodes.push(t),this}build(t,e=null){let i=this.getShared(t);if(this!==i)return i.build(t,e);if(this._beforeNodes!==null){let o=this._beforeNodes;this._beforeNodes=null;for(let l of o)l.build(t,e);this._beforeNodes=o}let r=t.getDataFromNode(this);r.buildStages=r.buildStages||{},r.buildStages[t.buildStage]=!0;let s=YQ[t.buildStage];if(s&&r.buildStages[s]!==!0){let o=t.getBuildStage();t.setBuildStage(s),this.build(t),t.setBuildStage(o)}t.addChain(this);let n=null,a=t.getBuildStage();if(a==="setup"){t.addNode(this),this.updateReference(t);let o=t.getNodeProperties(this);if(o.initialized!==!0){o.initialized=!0,o.outputNode=this.setup(t)||o.outputNode||null;for(let l of Object.values(o))if(l&&l.isNode===!0){if(l.parents===!0){let h=t.getNodeProperties(l);h.parents=h.parents||[],h.parents.push(this)}l.build(t)}t.addSequentialNode(this)}n=o.outputNode}else if(a==="analyze")this.analyze(t,e);else if(a==="generate"){if(this.generate.length<2){let o=this.getNodeType(t),l=t.getDataFromNode(this);n=l.snippet,n===void 0?l.generated===void 0?(l.generated=!0,n=this.generate(t)||"",l.snippet=n):(re("Node: Recursion detected.",this),n="/* Recursion detected. */"):l.flowCodes!==void 0&&t.context.nodeBlock!==void 0&&t.addFlowCodeHierarchy(this,t.context.nodeBlock),n=t.format(n,o,e)}else n=this.generate(t,e)||"";n===""&&e!==null&&e!=="void"&&e!=="OutputType"&&(Ht(`TSL: Invalid generated code, expected a "${e}".`),n=t.generateConst(e))}return t.removeChain(this),n}getSerializeChildren(){return this._getChildren()}serialize(t){let e=this.getSerializeChildren(),i={};for(let{property:r,index:s,childNode:n}of e)s!==void 0?(i[r]===void 0&&(i[r]=Number.isInteger(s)?[]:{}),i[r][s]=n.toJSON(t.meta).uuid):i[r]=n.toJSON(t.meta).uuid;Object.keys(i).length>0&&(t.inputNodes=i)}deserialize(t){if(t.inputNodes!==void 0){let e=t.meta.nodes;for(let i in t.inputNodes)if(Array.isArray(t.inputNodes[i])){let r=[];for(let s of t.inputNodes[i])r.push(e[s]);this[i]=r}else if(typeof t.inputNodes[i]=="object"){let r={};for(let s in t.inputNodes[i]){let n=t.inputNodes[i][s];r[s]=e[n]}this[i]=r}else{let r=t.inputNodes[i];this[i]=e[r]}}}toJSON(t){let{uuid:e,type:i}=this,r=t===void 0||typeof t=="string";r&&(t={textures:{},images:{},nodes:{}});let s=t.nodes[e];function n(a){let o=[];for(let l in a){let h=a[l];delete h.metadata,o.push(h)}return o}if(s===void 0&&(s={uuid:e,type:i,meta:t,metadata:{version:4.7,type:"Node",generator:"Node.toJSON"}},r!==!0&&(t.nodes[s.uuid]=s),this.serialize(s),delete s.meta),r){let a=n(t.textures),o=n(t.images),l=n(t.nodes);a.length>0&&(s.textures=a),o.length>0&&(s.images=o),l.length>0&&(s.nodes=l)}return s}}).captureStackTrace=!1,Zc=class extends Ae{static get type(){return"ArrayElementNode"}constructor(t,e){super(),this.node=t,this.indexNode=e,this.isArrayElementNode=!0}generateNodeType(t){return this.node.getElementType(t)}getMemberType(t,e){return this.node.getMemberType(t,e)}generate(t){let e=this.indexNode.getNodeType(t);return`${this.node.build(t)}[ ${this.indexNode.build(t,!t.isVector(e)&&t.isInteger(e)?e:"uint")} ]`}},yB=class extends Ae{static get type(){return"ConvertNode"}constructor(t,e){super(),this.node=t,this.convertTo=e}generateNodeType(t){let e=this.node.getNodeType(t),i=null;for(let r of this.convertTo.split("|"))(i===null||t.getTypeLength(e)===t.getTypeLength(r))&&(i=r);return i}serialize(t){super.serialize(t),t.convertTo=this.convertTo}deserialize(t){super.deserialize(t),this.convertTo=t.convertTo}generate(t,e){let i=this.node,r=this.getNodeType(t),s=i.build(t,r);return t.format(s,r,e)}},Cr=class extends Ae{static get type(){return"TempNode"}constructor(t=null){super(t),this.isTempNode=!0}hasDependencies(t){return t.getDataFromNode(this).usageCount>1}build(t,e){if(t.getBuildStage()==="generate"){let i=t.getVectorType(this.getNodeType(t,e)),r=t.getDataFromNode(this);if(r.propertyName!==void 0)return t.format(r.propertyName,i,e);if(i!=="void"&&e!=="void"&&this.hasDependencies(t)){let s=super.build(t,i),n=t.getVarFromNode(this,null,i),a=t.getPropertyName(n);return t.addLineFlowCode(`${a} = ${s}`,this),r.snippet=s,r.propertyName=a,t.format(r.propertyName,i,e)}}return super.build(t,e)}},ZQ=class extends Cr{static get type(){return"JoinNode"}constructor(t=[],e=null){super(e),this.nodes=t}generateNodeType(t){return this.nodeType!==null?t.getVectorType(this.nodeType):t.getTypeFromLength(this.nodes.reduce((e,i)=>e+t.getTypeLength(i.getNodeType(t)),0))}generate(t,e){let i=this.getNodeType(t),r=t.getTypeLength(i),s=this.nodes,n=t.getComponentType(i),a=[],o=0;for(let h of s){if(o>=r){Ht(`TSL: Length of parameters exceeds maximum length of function '${i}()' type.`,this.stackTrace);break}let u,d=h.getNodeType(t),c=t.getTypeLength(d);if(o+c>r&&(Ht(`TSL: Length of '${i}()' data exceeds maximum length of output type.`,this.stackTrace),c=r-o,d=t.getTypeFromLength(c)),o+=c,u=h.build(t,d),t.getComponentType(d)!==n){let p=t.getTypeFromLength(c,n);u=t.format(u,d,p)}a.push(u)}let l=`${t.getType(i)}( ${a.join(", ")} )`;return t.format(l,i,e)}},QQ=mf.join(""),h9=class extends Ae{static get type(){return"SplitNode"}constructor(t,e="x"){super(),this.node=t,this.components=e,this.isSplitNode=!0}getVectorLength(){let t=this.components.length;for(let e of this.components)t=Math.max(mf.indexOf(e)+1,t);return t}getComponentType(t){return t.getComponentType(this.node.getNodeType(t))}generateNodeType(t){return t.getTypeFromLength(this.components.length,this.getComponentType(t))}getScope(){return this.node.getScope()}generate(t,e){let i=this.node,r=t.getTypeLength(i.getNodeType(t)),s=null;if(r>1){let n=null;this.getVectorLength()>=r&&(n=t.getTypeFromLength(this.getVectorLength(),this.getComponentType(t)));let a=i.build(t,n);s=this.components.length===r&&this.components===QQ.slice(0,this.components.length)?t.format(a,n,e):t.format(`${a}.${this.components}`,this.getNodeType(t),e)}else s=i.build(t,e);return s}serialize(t){super.serialize(t),t.components=this.components}deserialize(t){super.deserialize(t),this.components=t.components}},k1t=class extends Cr{static get type(){return"SetNode"}constructor(t,e,i){super(),this.sourceNode=t,this.components=e,this.targetNode=i}generateNodeType(t){return this.sourceNode.getNodeType(t)}generate(t){let{sourceNode:e,components:i,targetNode:r}=this,s=this.getNodeType(t),n=t.getComponentType(r.getNodeType(t)),a=t.getTypeFromLength(i.length,n),o=r.build(t,a),l=e.build(t,s),h=t.getTypeLength(s),u=[];for(let d=0;d<h;d++){let c=mf[d];c===i[0]?(u.push(o),d+=i.length-1):u.push(l+"."+c)}return`${t.getType(s)}( ${u.join(", ")} )`}},V1t=class extends Cr{static get type(){return"FlipNode"}constructor(t,e){super(),this.sourceNode=t,this.components=e}generateNodeType(t){return this.sourceNode.getNodeType(t)}generate(t){let{components:e,sourceNode:i}=this,r=this.getNodeType(t),s=i.build(t),n=t.getVarFromNode(this),a=t.getPropertyName(n);t.addLineFlowCode(a+" = "+s,this);let o=t.getTypeLength(r),l=[],h=0;for(let u=0;u<o;u++){let d=mf[u];d===e[h]?(l.push("1.0 - "+a+"."+d),h++):l.push(a+"."+d)}return`${t.getType(r)}( ${l.join(", ")} )`}},MA=class extends Ae{static get type(){return"InputNode"}constructor(t,e=null){super(e),this.isInputNode=!0,this.value=t,this.precision=null}generateNodeType(){return this.nodeType===null?Kc(this.value):this.nodeType}getInputType(t){return this.getNodeType(t)}setPrecision(t){return this.precision=t,this}serialize(t){super.serialize(t),t.value=this.value,this.value&&this.value.toArray&&(t.value=this.value.toArray()),t.valueType=Kc(this.value),t.nodeType=this.nodeType,t.valueType==="ArrayBuffer"&&(t.value=function(e){let i="",r=new Uint8Array(e);for(let s=0;s<r.length;s++)i+=String.fromCharCode(r[s]);return btoa(i)}(t.value)),t.precision=this.precision}deserialize(t){super.deserialize(t),this.nodeType=t.nodeType,this.value=Array.isArray(t.value)?lB(t.valueType,...t.value):t.value,this.precision=t.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(t.value))}generate(){re("Abstract function.")}},vB=/float|u?int/,ph=class extends MA{static get type(){return"ConstNode"}constructor(t,e=null){super(t,e),this.isConstNode=!0}generateConst(t){return t.generateConst(this.getNodeType(t),this.value)}generate(t,e){let i=this.getNodeType(t);return vB.test(i)&&vB.test(e)?t.generateConst(e,this.value):t.format(this.generateConst(t),i,e)}},JQ=class extends Ae{static get type(){return"MemberNode"}constructor(t,e){super(),this.structNode=t,this.property=e,this.isMemberNode=!0}hasMember(t){return(!this.structNode.isMemberNode||this.structNode.hasMember(t)!==!1)&&this.structNode.getMemberType(t,this.property)!=="void"}generateNodeType(t){return this.hasMember(t)===!1?"float":this.structNode.getMemberType(t,this.property)}getMemberType(t,e){if(this.hasMember(t)===!1)return"float";let i=this.getNodeType(t);return t.getStructTypeNode(i).getMemberType(t,e)}generate(t){if(this.hasMember(t)===!1){re(`TSL: Member "${this.property}" does not exist in struct.`,this.stackTrace);let e=this.getNodeType(t);return t.generateConst(e)}return this.structNode.build(t)+"."+this.property}},Jd=null,_5=new Map,tJ=t=>t.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),u9=t=>tJ(t).split("").sort().join(""),Ae.prototype.assign=function(...t){if(this.isStackNode!==!0)return Jd!==null?Jd.assign(this,...t):Ht("TSL: No stack defined for assign operation. Make sure the assign is inside a Fn().",new Ss),this;{let e=_5.get("assign");return this.addToStack(e(...t))}},Ae.prototype.toVarIntent=function(){return this},Ae.prototype.get=function(t){return new JQ(this,t)},Mv={},mh=["x","y","z","w"],fh=["r","g","b","a"],gh=["s","t","p","q"];for(let t=0;t<4;t++){let e=mh[t],i=fh[t],r=gh[t];wA(e,i,r);for(let s=0;s<4;s++){e=mh[t]+mh[s],i=fh[t]+fh[s],r=gh[t]+gh[s],wA(e,i,r);for(let n=0;n<4;n++){e=mh[t]+mh[s]+mh[n],i=fh[t]+fh[s]+fh[n],r=gh[t]+gh[s]+gh[n],wA(e,i,r);for(let a=0;a<4;a++)e=mh[t]+mh[s]+mh[n]+mh[a],i=fh[t]+fh[s]+fh[n]+fh[a],r=gh[t]+gh[s]+gh[n]+gh[a],wA(e,i,r)}}}for(let t=0;t<32;t++)Mv[t]={get(){this._cache=this._cache||{};let e=this._cache[t];return e===void 0&&(e=new Zc(this,new ph(t,"uint")),this._cache[t]=e),e},set(e){this[t].assign(ge(e))}};Object.defineProperties(Ae.prototype,Mv),eJ=function(t,e=null){let i=Kc(t);return i==="node"?t:e===null&&(i==="float"||i==="boolean")||i&&i!=="shader"&&i!=="string"?ge(PA(t,e)):i==="shader"?t.isFn?t:tt(t):t},iJ=function(t,e=null){for(let i in t)t[i]=ge(t[i],e);return t},rJ=function(t,e=null){let i=t.length;for(let r=0;r<i;r++)t[r]=ge(t[r],e);return t},bB=function(t,e=null,i=null,r=null){function s(u){return r!==null?(u=ge(Object.assign(u,r)),r.intent===!0&&(u=u.toVarIntent())):u=ge(u),u}let n,a,o,l=e;function h(u){let d;return d=l?/[a-z]/i.test(l)?l+"()":l:t.type,a!==void 0&&u.length<a?(Ht(`TSL: "${d}" parameter length is less than minimum required.`,new Ss),u.concat(new Array(a-u.length).fill(0))):o!==void 0&&u.length>o?(Ht(`TSL: "${d}" parameter length exceeds limit.`,new Ss),u.slice(0,o)):u}return e===null?n=(...u)=>s(new t(...Qc(h(u)))):i!==null?(i=ge(i),n=(...u)=>s(new t(e,...Qc(h(u)),i))):n=(...u)=>s(new t(e,...Qc(h(u)))),n.setParameterLength=(...u)=>(u.length===1?a=o=u[0]:u.length===2&&([a,o]=u),n),n.setName=u=>(l=u,n),n},sJ=function(t,...e){return new t(...Qc(e))},nJ=class extends Ae{constructor(t,e){super(),this.shaderNode=t,this.rawInputs=e,this.isShaderCallNodeInternal=!0}generateNodeType(t){return this.shaderNode.nodeType||this.getOutputNode(t).getNodeType(t)}getElementType(t){return this.getOutputNode(t).getElementType(t)}getMemberType(t,e){return this.getOutputNode(t).getMemberType(t,e)}call(t){let{shaderNode:e,rawInputs:i}=this,r=t.getNodeProperties(e),s=t.getClosestSubBuild(e.subBuilds)||"",n=s||"default";if(r[n])return r[n];let a=t.subBuildFn,o=t.fnCall;t.subBuildFn=s,t.fnCall=this;let l=null;if(e.layout){if(i){let d=e.layout.inputs;if(mQ(i)){let c=i;for(let p=0;p<d.length;p++){let m=c[p];m&&m.isNode&&m.build(t)}}else{let c=i[0];for(let p of d){let m=c[p.name];m&&m.isNode&&m.build(t)}}}let h=t.buildFunctionNode(e);t.addInclude(h);let u=i?function(d){let c;return I_(d),c=mQ(d)?[...d]:d[0],c}(i):null;l=h.call(u)}else{let h=new Proxy(t,{get:(m,f,g)=>{let y;return y=Symbol.iterator===f?function*(){yield}:Reflect.get(m,f,g),y}}),u=i?function(m){let f=0;return I_(m),new Proxy(m,{get:(g,y,v)=>{let b;if(y==="length")return b=m.length,b;if(Symbol.iterator===y)b=function*(){for(let _ of m)yield ge(_)};else{if(m.length>0)if(Object.getPrototypeOf(m[0])===Object.prototype){let _=m[0];b=_[y]===void 0?_[f++]:Reflect.get(_,y,v)}else m[0]instanceof Ae&&(b=m[y]===void 0?m[f++]:Reflect.get(m,y,v));else b=Reflect.get(g,y,v);b=ge(b)}return b}})}(i):null,d=Array.isArray(i)?i.length>0:i!==null,c=e.jsFunc,p=d||c.length>1?c(u,h):c(h);l=ge(p)}return t.subBuildFn=a,t.fnCall=o,e.once&&(r[n]=l),l}setupOutput(t){return t.addStack(),t.stack.outputNode=this.call(t),t.removeStack()}getOutputNode(t){let e=t.getNodeProperties(this),i=t.getSubBuildOutput(this);return e[i]=e[i]||this.setupOutput(t),e[i].subBuild=t.getClosestSubBuild(this),e[i]}build(t,e=null){let i=null,r=t.getBuildStage(),s=t.getNodeProperties(this),n=t.getSubBuildOutput(this),a=this.getOutputNode(t),o=t.fnCall;if(t.fnCall=this,r==="setup"){let l=t.getSubBuildProperty("initialized",this);if(s[l]!==!0&&(s[l]=!0,s[n]=this.getOutputNode(t),s[n].build(t),this.shaderNode.subBuilds))for(let h of t.chaining){let u=t.getDataFromNode(h,"any");u.subBuilds=u.subBuilds||new Set;for(let d of this.shaderNode.subBuilds)u.subBuilds.add(d)}i=s[n]}else r==="analyze"?a.build(t,e):r==="generate"&&(i=a.build(t,e)||"");return t.fnCall=o,i}},z1t=class extends Ae{constructor(t,e){super(e),this.jsFunc=t,this.layout=null,this.global=!0,this.once=!1}setLayout(t){return this.layout=t,this}getLayout(){return this.layout}call(t=null){return new nJ(this,t)}setup(){return this.call()}},aJ=[!1,!0],oJ=[0,1,2,3],lJ=[-1,-2],_B=[.5,1.5,1/3,1e-6,1e6,Math.PI,2*Math.PI,1/Math.PI,2/Math.PI,1/(2*Math.PI),Math.PI/2],AA=new Map;for(let t of aJ)AA.set(t,new ph(t));CA=new Map;for(let t of oJ)CA.set(t,new ph(t,"uint"));EA=new Map([...CA].map(t=>new ph(t.value,"int")));for(let t of lJ)EA.set(t,new ph(t,"int"));D_=new Map([...EA].map(t=>new ph(t.value)));for(let t of _B)D_.set(t,new ph(t));for(let t of _B)D_.set(-t,new ph(-t));O_={bool:AA,uint:CA,ints:EA,float:D_},xB=new Map([...AA,...D_]),PA=(t,e)=>xB.has(t)?xB.get(t):t.isNode===!0?t:new ph(t,e),Gs=function(t,e=null){return(...i)=>{for(let s of i)if(s===void 0)return Ht(`TSL: Invalid parameter for the type "${t}".`,new Ss),new ph(0,t);if((i.length===0||!["bool","float","int","uint"].includes(t)&&i.every(s=>{let n=typeof s;return n!=="object"&&n!=="function"}))&&(i=[lB(t,...i)]),i.length===1&&e!==null&&e.has(i[0]))return sy(e.get(i[0]));if(i.length===1){let s=PA(i[0],t);return s.nodeType===t?sy(s):sy(new yB(s,t))}let r=i.map(s=>PA(s));return sy(new ZQ(r,t))}},wB=t=>t!=null?t.nodeType||t.convertTo||(typeof t=="string"?t:null):null,ge=(t,e=null)=>eJ(t,e),sy=(t,e=null)=>ge(t,e).toVarIntent(),I_=(t,e=null)=>new iJ(t,e),Qc=(t,e=null)=>new rJ(t,e),oi=(t,e=null,i=null,r=null)=>new bB(t,e,i,r),Qt=(t,...e)=>new sJ(t,...e),jt=(t,e=null,i=null,r={})=>new bB(t,e,i,{...r,intent:!0}),RA=(t,e)=>new Proxy(t,{get:(i,r,s)=>Reflect.get(e,r,s),set:(i,r,s)=>Reflect.set(e,r,s)}),hJ=0,L1t=class extends Ae{constructor(t,e=null){super();let i=null;e!==null&&(typeof e=="object"?i=e.return:(typeof e=="string"?i=e:Ht("TSL: Invalid layout type.",new Ss),e=null)),this.shaderNode=new ey(t,i),e!==null&&this.setLayout(e),this.isFn=!0}setLayout(t){let e=this.shaderNode.nodeType;if(typeof t.inputs!="object"){let i={name:"fn"+hJ++,type:e,inputs:[]};for(let r in t)r!=="return"&&i.inputs.push({name:r,type:t[r]});t=i}return this.shaderNode.setLayout(t),this}generateNodeType(t){return this.shaderNode.getNodeType(t)||"float"}call(...t){let e=this.shaderNode.call(t);return this.shaderNode.nodeType==="void"&&e.toStack(),e.toVarIntent()}once(t=null){return this.shaderNode.once=!0,this.shaderNode.subBuilds=t,this}generate(t){let e=this.getNodeType(t);return Ht('TSL: "Fn()" was declared but not invoked. Try calling it like "Fn()( ...params )".',this.stackTrace),t.generateConst(e)}},ny=t=>{Jd=t},DA=()=>Jd,xe=(...t)=>Jd.If(...t),uJ=(...t)=>Jd.Switch(...t),Tt("toStack",SA),SB=new Gs("color"),F=new Gs("float",O_.float),Z=new Gs("int",O_.ints),Ft=new Gs("uint",O_.uint),So=new Gs("bool",O_.bool),Xt=new Gs("vec2"),rs=new Gs("ivec2"),OA=new Gs("uvec2"),TB=new Gs("bvec2"),et=new Gs("vec3"),IA=new Gs("ivec3"),Jc=new Gs("uvec3"),NA=new Gs("bvec3"),oe=new Gs("vec4"),BA=new Gs("ivec4"),kA=new Gs("uvec4"),MB=new Gs("bvec4"),N_=new Gs("mat2"),Sn=new Gs("mat3"),tc=new Gs("mat4"),Tt("toColor",SB),Tt("toFloat",F),Tt("toInt",Z),Tt("toUint",Ft),Tt("toBool",So),Tt("toVec2",Xt),Tt("toIVec2",rs),Tt("toUVec2",OA),Tt("toBVec2",TB),Tt("toVec3",et),Tt("toIVec3",IA),Tt("toUVec3",Jc),Tt("toBVec3",NA),Tt("toVec4",oe),Tt("toIVec4",BA),Tt("toUVec4",kA),Tt("toBVec4",MB),Tt("toMat2",N_),Tt("toMat3",Sn),Tt("toMat4",tc),AB=oi(Zc).setParameterLength(2),CB=(t,e)=>new yB(ge(t),e),dJ=(t,e)=>new h9(ge(t),e),Tt("element",AB),Tt("convert",CB),cJ=t=>(re("TSL: append() has been renamed to Stack().",new Ss),SA(t)),Tt("append",t=>(re("TSL: .append() has been renamed to .toStack().",new Ss),SA(t))),uu=(t,e,i=null)=>new Ui(t,e,!1,i),tp=(t,e,i=null)=>new Ui(t,e,!0,i),Ai=Qt(Ui=class extends Ae{static get type(){return"PropertyNode"}constructor(t,e=null,i=!1,r=null){super(t),this.name=e,this.varying=i,this.placeholderNode=ge(r),this.isPropertyNode=!0,this.global=!0}getNodeType(t){let e=super.getNodeType(t);return e==="output"?t.getOutputType():e}customCacheKey(){return df(this.type+":"+(this.name||"")+":"+(this.varying?"1":"0"))}getHash(t){return this.name||super.getHash(t)}generate(t){let e;if(this.varying===!0)e=t.getVaryingFromNode(this,this.name),e.needsInterpolation=!0;else if(e=t.getVarFromNode(this,this.name),this.placeholderNode!==null&&t.hasWriteUsage(this)===!1){let i=this.placeholderNode.build(t,this.getNodeType(t));t.addLineFlowCode(`${t.getPropertyName(e)} = ${i}`,this)}return t.getPropertyName(e)}},"vec4","DiffuseColor"),ep=Qt(Ui,"vec3","DiffuseContribution"),VA=Qt(Ui,"vec3","EmissiveColor"),yh=Qt(Ui,"float","Roughness"),du=Qt(Ui,"float","Metalness"),B_=Qt(Ui,"float","Clearcoat"),ff=Qt(Ui,"float","ClearcoatRoughness"),To=Qt(Ui,"vec3","Sheen"),fd=Qt(Ui,"float","SheenRoughness"),k_=Qt(Ui,"float","Iridescence"),V_=Qt(Ui,"float","IridescenceIOR"),z_=Qt(Ui,"float","IridescenceThickness"),L_=Qt(Ui,"float","AlphaT"),gd=Qt(Ui,"float","Anisotropy"),ay=Qt(Ui,"vec3","AnisotropyT"),ip=Qt(Ui,"vec3","AnisotropyB"),yd=Qt(Ui,"color","SpecularColor"),rp=Qt(Ui,"color","SpecularColorBlended"),sp=Qt(Ui,"float","SpecularF90"),F_=Qt(Ui,"float","Shininess"),gf=Qt(Ui,"output","Output"),np=Qt(Ui,"float","dashSize"),oy=Qt(Ui,"float","gapSize"),pJ=Qt(Ui,"float","pointWidth"),ly=Qt(Ui,"float","IOR"),U_=Qt(Ui,"float","Transmission"),zA=Qt(Ui,"float","Thickness"),LA=Qt(Ui,"float","AttenuationDistance"),FA=Qt(Ui,"color","AttenuationColor"),UA=Qt(Ui,"float","Dispersion"),jA=Qt(Ui,"float","AmbientOcclusion",!1,1),EB=class extends Ae{static get type(){return"UniformGroupNode"}constructor(t,e=!1,i=1,r=null){super("string"),this.name=t,this.shared=e,this.order=i,this.updateType=r,this.isUniformGroup=!0}update(){this.needsUpdate=!0}serialize(t){super.serialize(t),t.name=this.name,t.version=this.version,t.shared=this.shared}deserialize(t){super.deserialize(t),this.name=t.name,this.version=t.version,this.shared=t.shared}},PB=(t,e=1,i=null)=>new EB(t,!1,e,i),mJ=(GA=(t,e=0,i=null)=>new EB(t,!0,e,i))("frame",0,ze.FRAME),Me=GA("render",0,ze.RENDER),RB=PB("object",1,ze.OBJECT),hy=class extends MA{static get type(){return"UniformNode"}constructor(t,e=null){super(t,e),this.isUniformNode=!0,this.name="",this.groupNode=RB}setName(t){return this.name=t,this}label(t){return re('TSL: "label()" has been deprecated. Use "setName()" instead.',new Ss),this.setName(t)}setGroup(t){return this.groupNode=t,this}getGroup(){return this.groupNode}getUniformHash(t){return this.getHash(t)}onUpdate(t,e){return t=t.bind(this),super.onUpdate(i=>{let r=t(i,this);r!==void 0&&(this.value=r)},e)}getInputType(t){let e=super.getInputType(t);return e==="bool"&&(e="uint"),e}generate(t,e){let i=this.getNodeType(t),r=this.getUniformHash(t),s=t.getNodeFromHash(r);s===void 0&&(t.setHashNode(this,r),s=this);let n=s.getInputType(t),a=t.getUniformFromNode(s,n,t.shaderStage,this.name||t.context.nodeName),o=t.getPropertyName(a);t.context.nodeName!==void 0&&delete t.context.nodeName;let l=o;if(i==="bool"){let h=t.getDataFromNode(this),u=h.propertyName;if(u===void 0){let d=t.getVarFromNode(this,null,"bool");u=t.getPropertyName(d),h.propertyName=u,l=t.format(o,n,i),t.addLineFlowCode(`${u} = ${l}`,this)}l=u}return t.format(l,i,e)}},_e=(t,e)=>{let i=wB(e||t);if(i===t&&(t=lB(i)),t&&t.isNode===!0){let r=t.value;t.traverse(s=>{s.isConstNode===!0&&(r=s.value)}),t=r}return new hy(t,i)},DB=class extends Cr{static get type(){return"ArrayNode"}constructor(t,e,i=null){super(t),this.count=e,this.values=i,this.isArrayNode=!0}getArrayCount(){return this.count}generateNodeType(t){return this.nodeType===null?this.values[0].getNodeType(t):this.nodeType}getElementType(t){return this.getNodeType(t)}getMemberType(t,e){return this.nodeType===null?this.values[0].getMemberType(t,e):super.getMemberType(t,e)}generate(t){let e=this.getNodeType(t);return t.generateArray(e,this.count,this.values)}},OB=(...t)=>{let e;if(t.length===1){let i=t[0];e=new DB(null,i.length,i)}else{let i=t[0],r=t[1];e=new DB(i,r)}return ge(e)},Tt("toArray",(t,e)=>OB(Array(e).fill(t))),Tt("assign",fJ=oi(class extends Cr{static get type(){return"AssignNode"}constructor(t,e){super(),this.targetNode=t,this.sourceNode=e,this.isAssignNode=!0}hasDependencies(){return!1}generateNodeType(t,e){return e!=="void"?this.targetNode.getNodeType(t):"void"}needsSplitAssign(t){let{targetNode:e}=this;if(t.isAvailable("swizzleAssign")===!1&&e.isSplitNode&&e.components.length>1){let i=t.getTypeLength(e.node.getNodeType(t));return mf.join("").slice(0,i)!==e.components}return!1}setup(t){let{targetNode:e,sourceNode:i}=this,r=e.getScope();t.getDataFromNode(r).assign=!0;let s=t.getNodeProperties(this);s.sourceNode=i,s.targetNode=e.context({assign:!0})}generate(t,e){let i,{targetNode:r,sourceNode:s}=t.getNodeProperties(this),n=this.needsSplitAssign(t),a=r.build(t),o=r.getNodeType(t),l=s.build(t,o),h=s.getNodeType(t),u=t.getDataFromNode(this);if(u.initialized===!0)e!=="void"&&(i=a);else if(n){let d=t.getVarFromNode(this,null,o),c=t.getPropertyName(d);t.addLineFlowCode(`${c} = ${l}`,this);let p=r.node,m=p.node.context({assign:!0}).build(t);for(let f=0;f<p.components.length;f++){let g=p.components[f];t.addLineFlowCode(`${m}.${g} = ${c}[ ${f} ]`,this)}e!=="void"&&(i=a)}else i=`${a} = ${l}`,(e==="void"||h==="void")&&(t.addLineFlowCode(i,this),e!=="void"&&(i=a));return u.initialized=!0,t.format(i,o,e)}}).setParameterLength(2)),gJ=class extends Cr{static get type(){return"FunctionCallNode"}constructor(t=null,e={}){super(),this.functionNode=t,this.parameters=e}setParameters(t){return this.parameters=t,this}getParameters(){return this.parameters}generateNodeType(t){return this.functionNode.getNodeType(t)}getMemberType(t,e){return this.functionNode.getMemberType(t,e)}generate(t){let e=[],i=this.functionNode,r=i.getInputs(t),s=this.parameters,n=(a,o)=>{let l,h=o.type;return l=h==="pointer"?"&"+a.build(t):a.build(t,h),l};if(Array.isArray(s)){if(s.length>r.length)Ht("TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'."),s.length=r.length;else if(s.length<r.length)for(Ht("TSL: The number of provided parameters is less than the expected number of inputs in 'Fn()'.");s.length<r.length;)s.push(F(0));for(let a=0;a<s.length;a++)e.push(n(s[a],r[a]))}else for(let a of r){let o=s[a.name];o!==void 0?e.push(n(o,a)):(Ht(`TSL: Input '${a.name}' not found in 'Fn()'.`),e.push(n(F(0),a)))}return`${i.build(t,"property")}( ${e.join(", ")} )`}},Tt("call",yJ=(t,...e)=>(e=e.length>1||e[0]&&e[0].isNode===!0?Qc(e):I_(e[0]),new gJ(ge(t),e))),vJ={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"},Ds=jt(vs=class extends Cr{static get type(){return"OperatorNode"}constructor(t,e,i,...r){if(super(),r.length>0){let s=new vs(t,e,i);for(let n=0;n<r.length-1;n++)s=new vs(t,s,r[n]);e=s,i=r[r.length-1]}this.op=t,this.aNode=e,this.bNode=i,this.isOperatorNode=!0}getOperatorMethod(t,e){return t.getMethod(vJ[this.op],e)}generateNodeType(t,e=null){let i=this.op,r=this.aNode,s=this.bNode,n=r.getNodeType(t),a=s?s.getNodeType(t):null;if(n==="void"||a==="void")return e||"void";if(i==="%")return n;if(i==="~"||i==="&"||i==="|"||i==="^"||i===">>"||i==="<<")return t.getIntegerType(n);if(i==="&&"||i==="||"||i==="^^")return"bool";if(i==="!"){let o=t.getTypeLength(n);return o>1?`bvec${o}`:"bool"}if(i==="=="||i==="!="||i==="<"||i===">"||i==="<="||i===">="){let o=Math.max(t.getTypeLength(n),t.getTypeLength(a));return o>1?`bvec${o}`:"bool"}if(t.isMatrix(n)){if(a==="float")return n;if(t.isVector(a))return t.getVectorFromMatrix(n);if(t.isMatrix(a))return n}else if(t.isMatrix(a)){if(n==="float")return a;if(t.isVector(n))return t.getVectorFromMatrix(a)}return t.getTypeLength(a)>t.getTypeLength(n)?a:n}generate(t,e){let i=this.op,{aNode:r,bNode:s}=this,n=this.getNodeType(t,e),a=null,o=null;n!=="void"?(a=r.getNodeType(t),o=s?s.getNodeType(t):null,i==="<"||i===">"||i==="<="||i===">="||i==="=="||i==="!="?t.isVector(a)?o=a:t.isVector(o)?a=o:a!==o&&(a=o="float"):i===">>"||i==="<<"?(a=n,o=t.changeComponentType(o,"uint")):i==="%"?(a=n,o=t.isInteger(a)&&t.isInteger(o)?o:a):t.isMatrix(a)?o==="float"?o="float":t.isVector(o)?o=t.getVectorFromMatrix(a):t.isMatrix(o)||(a=o=n):a=t.isMatrix(o)?a==="float"?"float":t.isVector(a)?t.getVectorFromMatrix(o):o=n:o=n):a=o=n;let l=r.build(t,a),h=s?s.build(t,o):null,u=t.getFunctionOperator(i);if(e!=="void"){let d=t.renderer.coordinateSystem===No;if(i==="=="||i==="!="||i==="<"||i===">"||i==="<="||i===">=")return d&&t.isVector(a)?t.format(`${this.getOperatorMethod(t,e)}( ${l}, ${h} )`,n,e):t.format(`( ${l} ${i} ${h} )`,n,e);if(i==="%")return t.isInteger(o)?t.format(`( ${l} % ${h} )`,n,e):t.format(`${this.getOperatorMethod(t,n)}( ${l}, ${h} )`,n,e);if(i==="!")return d&&t.isVector(a)?t.format(`not( ${l} )`,e):t.format(`( ${i} ${l} )`,a,e);if(i==="~")return t.format(`( ${i} ${l} )`,a,e);if(u)return t.format(`${u}( ${l}, ${h} )`,n,e);if(t.isMatrix(a)&&o==="float")return t.format(`( ${h} ${i} ${l} )`,n,e);if(a==="float"&&t.isMatrix(o))return t.format(`${l} ${i} ${h}`,n,e);{let c=`( ${l} ${i} ${h} )`;return!d&&n==="bool"&&t.isVector(a)&&t.isVector(o)&&(c=`all${c}`),t.format(c,n,e)}}if(a!=="void")return u?t.format(`${u}( ${l}, ${h} )`,n,e):t.isMatrix(a)&&o==="float"?t.format(`${h} ${i} ${l}`,n,e):t.format(`${l} ${i} ${h}`,n,e)}serialize(t){super.serialize(t),t.op=this.op}deserialize(t){super.deserialize(t),this.op=t.op}},"+").setParameterLength(2,1/0).setName("add"),wi=jt(vs,"-").setParameterLength(2,1/0).setName("sub"),Ge=jt(vs,"*").setParameterLength(2,1/0).setName("mul"),Mo=jt(vs,"/").setParameterLength(2,1/0).setName("div"),j_=jt(vs,"%").setParameterLength(2).setName("mod"),IB=jt(vs,"==").setParameterLength(2).setName("equal"),NB=jt(vs,"!=").setParameterLength(2).setName("notEqual"),BB=jt(vs,"<").setParameterLength(2).setName("lessThan"),WA=jt(vs,">").setParameterLength(2).setName("greaterThan"),kB=jt(vs,"<=").setParameterLength(2).setName("lessThanEqual"),VB=jt(vs,">=").setParameterLength(2).setName("greaterThanEqual"),zB=jt(vs,"&&").setParameterLength(2,1/0).setName("and"),LB=jt(vs,"||").setParameterLength(2,1/0).setName("or"),FB=jt(vs,"!").setParameterLength(1).setName("not"),UB=jt(vs,"^^").setParameterLength(2).setName("xor"),jB=jt(vs,"&").setParameterLength(2).setName("bitAnd"),GB=jt(vs,"~").setParameterLength(1).setName("bitNot"),WB=jt(vs,"|").setParameterLength(2).setName("bitOr"),qB=jt(vs,"^").setParameterLength(2).setName("bitXor"),HB=jt(vs,"<<").setParameterLength(2).setName("shiftLeft"),$B=jt(vs,">>").setParameterLength(2).setName("shiftRight"),XB=tt(([t])=>(t.addAssign(1),t)),YB=tt(([t])=>(t.subAssign(1),t)),KB=tt(([t])=>{let e=Z(t).toConst();return t.addAssign(1),e}),ZB=tt(([t])=>{let e=Z(t).toConst();return t.subAssign(1),e}),Tt("add",Ds),Tt("sub",wi),Tt("mul",Ge),Tt("div",Mo),Tt("mod",j_),Tt("equal",IB),Tt("notEqual",NB),Tt("lessThan",BB),Tt("greaterThan",WA),Tt("lessThanEqual",kB),Tt("greaterThanEqual",VB),Tt("and",zB),Tt("or",LB),Tt("not",FB),Tt("xor",UB),Tt("bitAnd",jB),Tt("bitNot",GB),Tt("bitOr",WB),Tt("bitXor",qB),Tt("shiftLeft",HB),Tt("shiftRight",$B),Tt("incrementBefore",XB),Tt("decrementBefore",YB),Tt("increment",KB),Tt("decrement",ZB),(ut=class extends Cr{static get type(){return"MathNode"}constructor(t,e,i=null,r=null){if(super(),(t===ut.MAX||t===ut.MIN)&&arguments.length>3){let s=new ut(t,e,i);for(let n=3;n<arguments.length-1;n++)s=new ut(t,s,arguments[n]);e=s,i=arguments[arguments.length-1],r=null}this.method=t,this.aNode=e,this.bNode=i,this.cNode=r,this.isMathNode=!0}getInputType(t){let e=this.aNode.getNodeType(t),i=this.bNode?this.bNode.getNodeType(t):null,r=this.cNode?this.cNode.getNodeType(t):null,s=t.isMatrix(e)?0:t.getTypeLength(e),n=t.isMatrix(i)?0:t.getTypeLength(i),a=t.isMatrix(r)?0:t.getTypeLength(r);return s>n&&s>a?e:n>a?i:a>s?r:e}generateNodeType(t){let e=this.method;return e===ut.LENGTH||e===ut.DISTANCE||e===ut.DOT?"float":e===ut.CROSS?"vec3":e===ut.ALL||e===ut.ANY?"bool":e===ut.EQUALS?t.changeComponentType(this.aNode.getNodeType(t),"bool"):this.getInputType(t)}setup(t){let{aNode:e,bNode:i,method:r}=this,s=null;if(r===ut.ONE_MINUS)s=wi(1,e);else if(r===ut.RECIPROCAL)s=Mo(1,e);else if(r===ut.DIFFERENCE)s=_r(wi(e,i));else if(r===ut.TRANSFORM_DIRECTION){let n,a;t.isMatrix(e.getNodeType(t))?(n=e,a=i):(n=i,a=e),s=ua(Ge(n,oe(et(a),0)).xyz)}return s!==null?s:super.setup(t)}generate(t,e){if(t.getNodeProperties(this).outputNode)return super.generate(t,e);let i=this.method,r=this.getNodeType(t),s=this.getInputType(t),n=this.aNode,a=this.bNode,o=this.cNode,l=t.renderer.coordinateSystem;if(i===ut.NEGATE)return t.format("( - "+n.build(t,s)+" )",r,e);{let h=[];return i===ut.CROSS?h.push(n.build(t,r),a.build(t,r)):l===No&&i===ut.STEP?h.push(n.build(t,t.getTypeLength(n.getNodeType(t))===1?"float":s),a.build(t,s)):l!==No||i!==ut.MIN&&i!==ut.MAX?i===ut.REFRACT?h.push(n.build(t,s),a.build(t,s),o.build(t,"float")):i===ut.MIX?h.push(n.build(t,s),a.build(t,s),o.build(t,t.getTypeLength(o.getNodeType(t))===1?"float":s)):(l===zo&&i===ut.ATAN&&a!==null&&(i="atan2"),t.shaderStage!=="fragment"&&(i===ut.DFDX||i===ut.DFDY)&&(re(`TSL: '${i}' is not supported in the ${t.shaderStage} stage.`,this.stackTrace),i="/*"+i+"*/"),h.push(n.build(t,s)),a!==null&&h.push(a.build(t,s)),o!==null&&h.push(o.build(t,s))):h.push(n.build(t,s),a.build(t,t.getTypeLength(a.getNodeType(t))===1?"float":s)),t.format(`${t.getMethod(i,r)}( ${h.join(", ")} )`,r,e)}}serialize(t){super.serialize(t),t.method=this.method}deserialize(t){super.deserialize(t),this.method=t.method}}).ALL="all",ut.ANY="any",ut.RADIANS="radians",ut.DEGREES="degrees",ut.EXP="exp",ut.EXP2="exp2",ut.LOG="log",ut.LOG2="log2",ut.SQRT="sqrt",ut.INVERSE_SQRT="inversesqrt",ut.FLOOR="floor",ut.CEIL="ceil",ut.NORMALIZE="normalize",ut.FRACT="fract",ut.SIN="sin",ut.SINH="sinh",ut.COS="cos",ut.COSH="cosh",ut.TAN="tan",ut.TANH="tanh",ut.ASIN="asin",ut.ASINH="asinh",ut.ACOS="acos",ut.ACOSH="acosh",ut.ATAN="atan",ut.ATANH="atanh",ut.ABS="abs",ut.SIGN="sign",ut.LENGTH="length",ut.NEGATE="negate",ut.ONE_MINUS="oneMinus",ut.DFDX="dFdx",ut.DFDY="dFdy",ut.ROUND="round",ut.RECIPROCAL="reciprocal",ut.TRUNC="trunc",ut.FWIDTH="fwidth",ut.TRANSPOSE="transpose",ut.DETERMINANT="determinant",ut.INVERSE="inverse",ut.EQUALS="equals",ut.MIN="min",ut.MAX="max",ut.STEP="step",ut.REFLECT="reflect",ut.DISTANCE="distance",ut.DIFFERENCE="difference",ut.DOT="dot",ut.CROSS="cross",ut.POW="pow",ut.TRANSFORM_DIRECTION="transformDirection",ut.MIX="mix",ut.CLAMP="clamp",ut.REFRACT="refract",ut.SMOOTHSTEP="smoothstep",ut.FACEFORWARD="faceforward",G_=F(1e-6),bJ=F(1e6),W_=F(Math.PI),_J=F(2*Math.PI),xJ=F(2*Math.PI),wJ=F(.5*Math.PI),QB=jt(ut,ut.ALL).setParameterLength(1),JB=jt(ut,ut.ANY).setParameterLength(1),tk=jt(ut,ut.RADIANS).setParameterLength(1),ek=jt(ut,ut.DEGREES).setParameterLength(1),qA=jt(ut,ut.EXP).setParameterLength(1),yf=jt(ut,ut.EXP2).setParameterLength(1),q_=jt(ut,ut.LOG).setParameterLength(1),vh=jt(ut,ut.LOG2).setParameterLength(1),Na=jt(ut,ut.SQRT).setParameterLength(1),HA=jt(ut,ut.INVERSE_SQRT).setParameterLength(1),bh=jt(ut,ut.FLOOR).setParameterLength(1),H_=jt(ut,ut.CEIL).setParameterLength(1),ua=jt(ut,ut.NORMALIZE).setParameterLength(1),Ol=jt(ut,ut.FRACT).setParameterLength(1),Ba=jt(ut,ut.SIN).setParameterLength(1),ik=jt(ut,ut.SINH).setParameterLength(1),Il=jt(ut,ut.COS).setParameterLength(1),rk=jt(ut,ut.COSH).setParameterLength(1),sk=jt(ut,ut.TAN).setParameterLength(1),nk=jt(ut,ut.TANH).setParameterLength(1),ak=jt(ut,ut.ASIN).setParameterLength(1),ok=jt(ut,ut.ASINH).setParameterLength(1),$A=jt(ut,ut.ACOS).setParameterLength(1),lk=jt(ut,ut.ACOSH).setParameterLength(1),XA=jt(ut,ut.ATAN).setParameterLength(1,2),hk=jt(ut,ut.ATANH).setParameterLength(1),_r=jt(ut,ut.ABS).setParameterLength(1),YA=jt(ut,ut.SIGN).setParameterLength(1),_h=jt(ut,ut.LENGTH).setParameterLength(1),KA=jt(ut,ut.NEGATE).setParameterLength(1),uk=jt(ut,ut.ONE_MINUS).setParameterLength(1),ZA=jt(ut,ut.DFDX).setParameterLength(1),QA=jt(ut,ut.DFDY).setParameterLength(1),dk=jt(ut,ut.ROUND).setParameterLength(1),ck=jt(ut,ut.RECIPROCAL).setParameterLength(1),JA=jt(ut,ut.TRUNC).setParameterLength(1),t3=jt(ut,ut.FWIDTH).setParameterLength(1),pk=jt(ut,ut.TRANSPOSE).setParameterLength(1),mk=jt(ut,ut.DETERMINANT).setParameterLength(1),fk=jt(ut,ut.INVERSE).setParameterLength(1),so=jt(ut,ut.MIN).setParameterLength(2,1/0),ss=jt(ut,ut.MAX).setParameterLength(2,1/0),ap=jt(ut,ut.STEP).setParameterLength(2),gk=jt(ut,ut.REFLECT).setParameterLength(2),yk=jt(ut,ut.DISTANCE).setParameterLength(2),vk=jt(ut,ut.DIFFERENCE).setParameterLength(2),Ko=jt(ut,ut.DOT).setParameterLength(2),cu=jt(ut,ut.CROSS).setParameterLength(2),Zo=jt(ut,ut.POW).setParameterLength(2),e3=t=>Ge(t,t),bk=t=>Ge(t,t,t),i3=t=>Ge(t,t,t,t),_k=jt(ut,ut.TRANSFORM_DIRECTION).setParameterLength(2),xk=(t,e)=>ua(Ge(e,oe(et(t),0)).xyz),wk=(t,e)=>ua(oe(et(t),0).mul(e).xyz),Sk=t=>Ge(YA(t),Zo(_r(t),1/3)),r3=t=>Ko(t,t),gi=jt(ut,ut.MIX).setParameterLength(3),Nl=(t,e=0,i=1)=>new ut(ut.CLAMP,ge(t),ge(e),ge(i)),$_=t=>Nl(t),s3=jt(ut,ut.REFRACT).setParameterLength(3),Ao=jt(ut,ut.SMOOTHSTEP).setParameterLength(3),n3=jt(ut,ut.FACEFORWARD).setParameterLength(3),Tk=tt(([t])=>{let e=Ko(t.xy,Xt(12.9898,78.233)),i=j_(e,W_);return Ol(Ba(i).mul(43758.5453))}),Mk=(t,e,i)=>gi(e,i,t),Ak=(t,e,i)=>Ao(e,i,t),Ck=(t,e)=>ap(e,t),SJ=n3,TJ=HA,Tt("all",QB),Tt("any",JB),Tt("radians",tk),Tt("degrees",ek),Tt("exp",qA),Tt("exp2",yf),Tt("log",q_),Tt("log2",vh),Tt("sqrt",Na),Tt("inverseSqrt",HA),Tt("floor",bh),Tt("ceil",H_),Tt("normalize",ua),Tt("fract",Ol),Tt("sin",Ba),Tt("sinh",ik),Tt("cos",Il),Tt("cosh",rk),Tt("tan",sk),Tt("tanh",nk),Tt("asin",ak),Tt("asinh",ok),Tt("acos",$A),Tt("acosh",lk),Tt("atan",XA),Tt("atanh",hk),Tt("abs",_r),Tt("sign",YA),Tt("length",_h),Tt("lengthSq",r3),Tt("negate",KA),Tt("oneMinus",uk),Tt("dFdx",ZA),Tt("dFdy",QA),Tt("round",dk),Tt("reciprocal",ck),Tt("trunc",JA),Tt("fwidth",t3),Tt("min",so),Tt("max",ss),Tt("step",Ck),Tt("reflect",gk),Tt("distance",yk),Tt("dot",Ko),Tt("cross",cu),Tt("pow",Zo),Tt("pow2",e3),Tt("pow3",bk),Tt("pow4",i3),Tt("transformDirection",_k),Tt("transformNormalByViewMatrix",xk),Tt("transformNormalByInverseViewMatrix",wk),Tt("mix",Mk),Tt("clamp",Nl),Tt("refract",s3),Tt("smoothstep",Ak),Tt("faceForward",n3),Tt("difference",vk),Tt("saturate",$_),Tt("cbrt",Sk),Tt("transpose",pk),Tt("determinant",mk),Tt("inverse",fk),Tt("rand",Tk),Tt("select",ka=oi(class extends Ae{static get type(){return"ConditionalNode"}constructor(t,e,i=null){super(),this.condNode=t,this.ifNode=e,this.elseNode=i}generateNodeType(t){let{ifNode:e,elseNode:i}=t.getNodeProperties(this);if(e===void 0)return t.flowBuildStage(this,"setup"),this.getNodeType(t);let r=e.getNodeType(t);if(i!==null){let s=i.getNodeType(t);if(t.getTypeLength(s)>t.getTypeLength(r))return s}return r}setup(t){let e=this.condNode,i=this.ifNode.isolate(),r=this.elseNode?this.elseNode.isolate():null,s=t.context.nodeBlock;t.getDataFromNode(i).parentNodeBlock=s,r!==null&&(t.getDataFromNode(r).parentNodeBlock=s);let n=t.context.uniformFlow,a=t.getNodeProperties(this);a.condNode=e,a.ifNode=n?i:i.context({nodeBlock:i}),a.elseNode=r?n?r:r.context({nodeBlock:r}):null}generate(t,e){let i=this.getNodeType(t),r=t.getDataFromNode(this);if(r.nodeProperty!==void 0)return r.nodeProperty;let{condNode:s,ifNode:n,elseNode:a}=t.getNodeProperties(this),o=t.currentFunctionNode,l=e!=="void",h=l?uu(i).build(t):"";r.nodeProperty=h;let u=s.build(t,"bool");if(t.context.uniformFlow&&a!==null){let c=n.build(t,i),p=a.build(t,i),m=t.getTernary(u,c,p);return t.format(m,i,e)}t.addFlowCode(`
|
|
@@ -2012,7 +2012,7 @@ var<${i}> ${t} : ${n};`}},ma=new Nf,nE=new Ey,EL=new Map([[Int8Array,["sint8","s
|
|
|
2012
2012
|
${n[a.lineNum-1]}`,a.linePos>0&&(h+=`
|
|
2013
2013
|
${" ".repeat(a.linePos-1)}^`)),(a.type==="error"?Ht:re)(l+h)}}}_getBlending(t){let e,i,r=t.blending,s=t.blendSrc,n=t.blendDst,a=t.blendEquation;if(r===VS){let o=t.blendSrcAlpha!==null?t.blendSrcAlpha:s,l=t.blendDstAlpha!==null?t.blendDstAlpha:n,h=t.blendEquationAlpha!==null?t.blendEquationAlpha:a;e={srcFactor:this._getBlendFactor(s),dstFactor:this._getBlendFactor(n),operation:this._getBlendOperation(a)},i={srcFactor:this._getBlendFactor(o),dstFactor:this._getBlendFactor(l),operation:this._getBlendOperation(h)}}else{let o=(l,h,u,d)=>{e={srcFactor:l,dstFactor:h,operation:wp.Add},i={srcFactor:u,dstFactor:d,operation:wp.Add}};if(t.premultipliedAlpha)switch(r){case Ql:o(Ei.One,Ei.OneMinusSrcAlpha,Ei.One,Ei.OneMinusSrcAlpha);break;case c4:o(Ei.One,Ei.One,Ei.One,Ei.One);break;case p4:o(Ei.Zero,Ei.OneMinusSrc,Ei.Zero,Ei.One);break;case m4:o(Ei.Dst,Ei.OneMinusSrcAlpha,Ei.Zero,Ei.One)}else switch(r){case Ql:o(Ei.SrcAlpha,Ei.OneMinusSrcAlpha,Ei.One,Ei.OneMinusSrcAlpha);break;case c4:o(Ei.SrcAlpha,Ei.One,Ei.One,Ei.One);break;case p4:Ht(`WebGPURenderer: "SubtractiveBlending" requires "${t.isMaterial?"material":"blendMode"}.premultipliedAlpha = true".`);break;case m4:Ht(`WebGPURenderer: "MultiplyBlending" requires "${t.isMaterial?"material":"blendMode"}.premultipliedAlpha = true".`)}}if(e!==void 0&&i!==void 0)return{color:e,alpha:i};Ht("WebGPURenderer: Invalid blending: ",r)}_getBlendFactor(t){let e;switch(t){case X1:e=Ei.Zero;break;case kv:e=Ei.One;break;case wpt:e=Ei.Src;break;case Spt:e=Ei.OneMinusSrc;break;case H2:e=Ei.SrcAlpha;break;case Ug:e=Ei.OneMinusSrcAlpha;break;case Tpt:e=Ei.Dst;break;case Mpt:e=Ei.OneMinusDst;break;case _G:e=Ei.DstAlpha;break;case xG:e=Ei.OneMinusDstAlpha;break;case Apt:e=Ei.SrcAlphaSaturated;break;case 211:e=Ei.Constant;break;case 212:e=Ei.OneMinusConstant;break;default:Ht("WebGPURenderer: Blend factor not supported.",t)}return e}_getStencilCompare(t){let e,i=t.stencilFunc;switch(i){case wmt:e=Wn.Never;break;case $P:e=Wn.Always;break;case Smt:e=Wn.Less;break;case Mmt:e=Wn.LessEqual;break;case Tmt:e=Wn.Equal;break;case Emt:e=Wn.GreaterEqual;break;case Amt:e=Wn.Greater;break;case Cmt:e=Wn.NotEqual;break;default:Ht("WebGPURenderer: Invalid stencil function.",i)}return e}_getStencilOperation(t){let e;switch(t){case Op:e=Dd.Keep;break;case fmt:e=Dd.Zero;break;case gmt:e=Dd.Replace;break;case xmt:e=Dd.Invert;break;case ymt:e=Dd.IncrementClamp;break;case vmt:e=Dd.DecrementClamp;break;case bmt:e=Dd.IncrementWrap;break;case _mt:e=Dd.DecrementWrap;break;default:Ht("WebGPURenderer: Invalid stencil operation.",e)}return e}_getBlendOperation(t){let e;switch(t){case uv:e=wp.Add;break;case vpt:e=wp.Subtract;break;case bpt:e=wp.ReverseSubtract;break;case _pt:e=wp.Min;break;case xpt:e=wp.Max;break;default:Ht("WebGPUPipelineUtils: Blend equation not supported.",t)}return e}_getPrimitiveState(t,e,i){let r={},s=this.backend.utils;r.topology=s.getPrimitiveTopology(t,i),e.index!==null&&t.isLine===!0&&t.isLineSegments!==!0&&(r.stripIndexFormat=ZC.Uint32);let n=i.side===ln;return t.isMesh&&t.matrixWorld.determinantAffine()<0&&(n=!n),r.frontFace=n===!0?cL.CW:cL.CCW,r.cullMode=i.side===Xs?pL.None:pL.Back,r}_getColorWriteMask(t){return t.colorWrite===!0?Yx.All:Yx.None}_getDepthCompare(t){let e;if(t.depthTest===!1)e=Wn.Always;else{let i=this.backend.parameters.reversedDepthBuffer?Vmt[t.depthFunc]:t.depthFunc;switch(i){case zP:e=Wn.Never;break;case LP:e=Wn.Always;break;case FP:e=Wn.Less;break;case b1:e=Wn.LessEqual;break;case UP:e=Wn.Equal;break;case jP:e=Wn.GreaterEqual;break;case GP:e=Wn.Greater;break;case WP:e=Wn.NotEqual;break;default:Ht("WebGPUPipelineUtils: Invalid depth function.",i)}}return e}},PL=class{constructor(){this.label="",this.type=void 0,this.count=0}reset(){this.label="",this.type=void 0,this.count=0}},Ch=new Nf,Wlt=new Ey,By=new PL,qlt=class extends olt{constructor(t,e,i=2048){super(i),this.device=t,this.type=e,By.label=`queryset_global_timestamp_${e}`,By.type="timestamp",By.count=this.maxQueries,this.querySet=this.device.createQuerySet(By),By.reset();let r=8*this.maxQueries;Ch.label=`buffer_timestamp_resolve_${e}`,Ch.size=r,Ch.usage=GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC,this.resolveBuffer=this.device.createBuffer(Ch),Ch.reset(),Ch.label=`buffer_timestamp_result_${e}`,Ch.size=r,Ch.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ,this.resultBuffer=this.device.createBuffer(Ch),Ch.reset()}allocateQueriesForContext(t){if(!this.trackTimestamp||this.isDisposed)return null;if(this.currentQueryIndex+2>this.maxQueries)return Ki(`WebGPUTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;let e=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryOffsets.set(t,e),e}async resolveQueriesAsync(){if(!this.trackTimestamp||this.currentQueryIndex===0||this.isDisposed)return this.lastValue;if(this.pendingResolve)return this.pendingResolve;this.pendingResolve=this._resolveQueries();try{return await this.pendingResolve}finally{this.pendingResolve=null}}async _resolveQueries(){if(this.isDisposed)return this.lastValue;try{if(this.resultBuffer.mapState!=="unmapped")return this.lastValue;let t=new Map(this.queryOffsets),e=this.currentQueryIndex,i=8*e;this.currentQueryIndex=0,this.queryOffsets.clear();let r=this.device.createCommandEncoder(Wlt);r.resolveQuerySet(this.querySet,0,e,this.resolveBuffer,0),r.copyBufferToBuffer(this.resolveBuffer,0,this.resultBuffer,0,i);let s=r.finish();if(hu(this.device,s),this.resultBuffer.mapState!=="unmapped")return this.lastValue;if(await this.resultBuffer.mapAsync(GPUMapMode.READ,0,i),this.isDisposed)return this.resultBuffer.mapState==="mapped"&&this.resultBuffer.unmap(),this.lastValue;let n=new BigUint64Array(this.resultBuffer.getMappedRange(0,i)),a={},o=[];for(let[h,u]of t){let d=h.match(/^(.*):f(\d+)$/),c=parseInt(d[2]);o.includes(c)===!1&&o.push(c),a[c]===void 0&&(a[c]=0);let p=n[u],m=n[u+1],f=Number(m-p)/1e6;this.timestamps.set(h,f),a[c]+=f}let l=a[o[o.length-1]];return this.resultBuffer.unmap(),this.lastValue=l,this.frames=o,l}catch(t){return Ht("Error resolving queries:",t),this.resultBuffer.mapState==="mapped"&&this.resultBuffer.unmap(),this.lastValue}}async dispose(){if(!this.isDisposed){if(this.isDisposed=!0,this.pendingResolve)try{await this.pendingResolve}catch(t){Ht("Error waiting for pending resolve:",t)}if(this.resultBuffer&&this.resultBuffer.mapState==="mapped")try{this.resultBuffer.unmap()}catch(t){Ht("Error unmapping buffer:",t)}this.querySet&&(this.querySet.destroy(),this.querySet=null),this.resolveBuffer&&(this.resolveBuffer.destroy(),this.resolveBuffer=null),this.resultBuffer&&(this.resultBuffer.destroy(),this.resultBuffer=null),this.queryOffsets.clear(),this.pendingResolve=null}}},Hlt=class{constructor(){this.label="",this.timestampWrites=void 0}reset(){this.label="",this.timestampWrites=void 0}},rw=class{constructor(){this.view=null,this.depthLoadOp=void 0,this.depthStoreOp=void 0,this.depthClearValue=void 0,this.depthReadOnly=!1,this.stencilLoadOp=void 0,this.stencilStoreOp=void 0,this.stencilClearValue=0,this.stencilReadOnly=!1}reset(){this.view=null,this.depthLoadOp=void 0,this.depthStoreOp=void 0,this.depthClearValue=void 0,this.depthReadOnly=!1,this.stencilLoadOp=void 0,this.stencilStoreOp=void 0,this.stencilClearValue=0,this.stencilReadOnly=!1}},$lt=class{constructor(){this.querySet=null,this.beginningOfPassWriteIndex=void 0,this.endOfPassWriteIndex=void 0}reset(){this.querySet=null,this.beginningOfPassWriteIndex=void 0,this.endOfPassWriteIndex=void 0}},Fl={r:0,g:0,b:0,a:1},Do=new Nf,Ua=new Ey,sw=new Hlt,ky=new PL,nw=new xL,aw=new $lt,nl=new Jx,Eh=new Jx,Yr=new eE,_u=new wL,Xlt=class extends alt{constructor(t={}){super(t),this.isWebGPUBackend=!0,this.parameters.alpha=t.alpha===void 0||t.alpha,this.parameters.requiredLimits=t.requiredLimits===void 0?{}:t.requiredLimits,this.compatibilityMode=null,this.device=null,this.defaultRenderPassdescriptor=null,this.utils=new plt(this),this.attributeUtils=new Vlt(this),this.bindingUtils=new Llt(this),this.capabilities=new Flt(this),this.pipelineUtils=new Glt(this),this.textureUtils=new Tlt(this),this.occludedResolveCache=new Map;let e=typeof navigator>"u"||/Android/.test(navigator.userAgent)===!1;this._compatibility={[lg.TEXTURE_COMPARE]:e}}async init(t){await super.init(t);let e,i=this.parameters;if(i.device===void 0){let r={powerPreference:i.powerPreference,featureLevel:"compatibility",xrCompatible:t.xr.enabled},s=typeof navigator<"u"?await navigator.gpu.requestAdapter(r):null;if(s===null)throw new Error("THREE.WebGPUBackend: Unable to create WebGPU adapter.");let n=Object.values(wS),a=[];for(let l of n)s.features.has(l)&&a.push(l);let o={requiredFeatures:a,requiredLimits:i.requiredLimits};this.adapter=s,e=await s.requestDevice(o)}else e=i.device;this.compatibilityMode=!e.features.has("core-features-and-limits"),this.compatibilityMode&&(t._samples=0),e.lost.then(r=>{if(r.reason==="destroyed")return;let s={api:"WebGPU",message:r.message||"Unknown reason",reason:r.reason||null,originalEvent:r};t.onDeviceLost(s)}),e.onuncapturederror=r=>{let s=r.error,n=s&&s.constructor?s.constructor.name:"GPUError",a=s&&s.message||"Unknown uncaptured GPU error";t.onError({api:"WebGPU",type:n,message:a,originalEvent:r})},this.device=e,this.trackTimestamp=this.trackTimestamp&&this.hasFeature(wS.TimestampQuery),this.updateSize()}setXRRenderTargetTextures(t,e,i=null){this.set(t.texture,{texture:e,format:e.format,externalTexture:!0,xrViewDescriptors:i,initialized:!0})}get context(){let t=this.renderer.getCanvasTarget(),e=this.get(t),i=e.context;if(i===void 0){let r=this.parameters;i=t.isDefaultCanvasTarget===!0&&r.context!==void 0?r.context:t.domElement.getContext("webgpu"),"setAttribute"in t.domElement&&t.domElement.setAttribute("data-engine",`three.js r${cm} webgpu`);let s=r.alpha?"premultiplied":"opaque",n=r.outputType===si?"extended":"standard";i.configure({device:this.device,format:this.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,alphaMode:s,colorSpace:r.canvasColorSpace||"srgb",toneMapping:{mode:n}}),e.context=i}return i}get coordinateSystem(){return zo}get hasTimestamp(){return!0}async getArrayBufferAsync(t,e=null,i=0,r=-1){return await this.attributeUtils.getArrayBufferAsync(t,e,i,r)}getContext(){return this.context}_getDefaultRenderPassDescriptor(){let t=this.renderer,e=t.getCanvasTarget(),i=this.get(e),r=t.currentSamples,s=i.descriptor;if(s===void 0||i.samples!==r){if(s=new Ry,s.colorAttachments.push(new Py),t.depth===!0||t.stencil===!0){let o=new rw;o.view=this.textureUtils.getDepthBuffer(t.depth,t.stencil).createView(),s.depthStencilAttachment=o}let a=s.colorAttachments[0];r>0?a.view=this.textureUtils.getColorBuffer().createView():a.resolveTarget=void 0,i.descriptor=s,i.samples=r}let n=s.colorAttachments[0];return r>0?n.resolveTarget=this.context.getCurrentTexture().createView():n.view=this.context.getCurrentTexture().createView(),s}_isRenderCameraDepthArray(t){let e=t.camera;return t.depthTexture&&t.depthTexture.isArrayTexture===!0&&e!==null&&e.isArrayCamera===!0}_hasExternalTexture(t){let e=t.textures;if(e===null)return!1;for(let i=0;i<e.length;i++)if(this.get(e[i]).externalTexture===!0)return!0;return!1}_createExternalTextureViews(t,e){let i=[],r=t.camera;if(e.xrViewDescriptors&&r!==null&&r.isArrayCamera===!0)for(let s=0;s<e.xrViewDescriptors.length;s++)i.push({view:e.texture.createView(e.xrViewDescriptors[s]),resolveTarget:void 0,depthSlice:void 0});else i.push({view:e.texture.createView({dimension:qn.TwoD,baseArrayLayer:t.activeCubeFace,arrayLayerCount:1}),resolveTarget:void 0,depthSlice:void 0});return i}_getRenderPassDescriptor(t,e={}){let i=t.renderTarget,r=this.get(i),s=this._hasExternalTexture(t),n=r.descriptors;(n===void 0||r.width!==i.width||r.height!==i.height||r.samples!==i.samples||s)&&(n={},r.descriptors=n);let a=t.getCacheKey(),o=n[a];if(o===void 0||s){let h,u=t.textures,d=[],c=this._isRenderCameraDepthArray(t);for(let m=0;m<u.length;m++){let f=this.get(u[m]);if(f.externalTexture!==!0){if(Yr.label=`colorAttachment_${m}`,Yr.baseMipLevel=t.activeMipmapLevel,Yr.mipLevelCount=1,Yr.baseArrayLayer=t.activeCubeFace,Yr.arrayLayerCount=1,Yr.dimension=qn.TwoD,i.isRenderTarget3D)h=t.activeCubeFace,Yr.baseArrayLayer=0,Yr.dimension=qn.ThreeD;else if(i.isRenderTarget&&u[m].image.depth>1)if(c===!0){let g=t.camera.cameras;for(let y=0;y<g.length;y++){Yr.baseArrayLayer=y,Yr.arrayLayerCount=1,Yr.dimension=qn.TwoD;let v=f.texture.createView(Yr);d.push({view:v,resolveTarget:void 0,depthSlice:void 0})}}else Yr.dimension=qn.TwoDArray;if(c!==!0){let g,y,v=f.texture.createView(Yr);f.msaaTexture!==void 0?(g=f.msaaTexture.createView(),y=v):(g=v,y=void 0),d.push({view:g,resolveTarget:y,depthSlice:h})}Yr.reset()}else d.push(...this._createExternalTextureViews(t,f))}let p=[];for(let m=0;m<d.length;m++){let f=d[m],g=new Py;g.view=f.view,g.depthSlice=f.depthSlice,g.resolveTarget=f.resolveTarget,p.push(g)}if(o={textureViews:d,colorAttachments:p,descriptor:new Ry},t.depth){let m=this.get(t.depthTexture);(t.depthTexture.isArrayTexture||t.depthTexture.isCubeTexture)&&(Yr.dimension=qn.TwoD,Yr.arrayLayerCount=1,Yr.baseArrayLayer=t.activeCubeFace);let f=new rw;f.view=m.texture.createView(Yr),o.depthStencilAttachment=f,Yr.reset()}n[a]=o,r.width=i.width,r.height=i.height,r.samples=i.samples,r.activeMipmapLevel=t.activeMipmapLevel,r.activeCubeFace=t.activeCubeFace}let l=o.descriptor;l.reset();for(let h=0;h<o.colorAttachments.length;h++){let u=o.colorAttachments[h],d={r:0,g:0,b:0,a:1};h===0&&e.clearValue&&(d=e.clearValue),u.loadOp=e.loadOp||Yi.Load,u.storeOp=e.storeOp||La.Store,u.clearValue=d,l.colorAttachments.push(u)}return o.depthStencilAttachment&&(l.depthStencilAttachment=o.depthStencilAttachment),l}beginRender(t){let e,i,r=this.get(t),s=this.device,n=t.occlusionQueryCount;n>0&&(r.currentOcclusionQuerySet&&r.currentOcclusionQuerySet.destroy(),r.currentOcclusionQueryBuffer&&r.currentOcclusionQueryBuffer.destroy(),r.currentOcclusionQuerySet=r.occlusionQuerySet,r.currentOcclusionQueryBuffer=r.occlusionQueryBuffer,r.currentOcclusionQueryObjects=r.occlusionQueryObjects,ky.label=`occlusionQuerySet_${t.id}`,ky.type="occlusion",ky.count=n,e=s.createQuerySet(ky),ky.reset(),r.occlusionQuerySet=e,r.occlusionQueryIndex=0,r.occlusionQueryObjects=new Array(n),r.lastOcclusionObject=null),i=t.textures===null?this._getDefaultRenderPassDescriptor():this._getRenderPassDescriptor(t,{loadOp:Yi.Load}),this.initTimestampQuery(og.RENDER,this.getTimestampUID(t),i),i.occlusionQuerySet=e;let a=i.depthStencilAttachment;if(t.textures!==null){let l=i.colorAttachments;for(let h=0;h<l.length;h++){let u=l[h];t.clearColor?(h===0?u.clearValue=t.clearColorValue:(Fl.r=0,Fl.g=0,Fl.b=0,Fl.a=1,u.clearValue=Fl),u.loadOp=Yi.Clear):u.loadOp=Yi.Load,u.storeOp=La.Store}}else{let l=i.colorAttachments[0];t.clearColor?(l.clearValue=t.clearColorValue,l.loadOp=Yi.Clear):l.loadOp=Yi.Load,l.storeOp=La.Store}t.depth&&(t.clearDepth?(a.depthClearValue=t.clearDepthValue,a.depthLoadOp=Yi.Clear):a.depthLoadOp=Yi.Load,a.depthStoreOp=La.Store),t.stencil&&(t.clearStencil?(a.stencilClearValue=t.clearStencilValue,a.stencilLoadOp=Yi.Clear):a.stencilLoadOp=Yi.Load,a.stencilStoreOp=La.Store),Ua.label="renderContext_"+t.id;let o=s.createCommandEncoder(Ua);if(Ua.reset(),this._isRenderCameraDepthArray(t)===!0){let l=t.camera.cameras;r.layerDescriptors&&r.layerDescriptors.length===l.length?this._updateArrayCameraLayerDescriptors(t,r,l):this._createArrayCameraLayerDescriptors(t,r,i,l),r.bundleEncoders=[],r.bundleSets=[];for(let h=0;h<l.length;h++){let u=this.pipelineUtils.createBundleEncoder(t,"renderBundleArrayCamera_"+h),d={attributes:{},bindingGroups:[],pipeline:null,index:null};r.bundleEncoders.push(u),r.bundleSets.push(d)}r.currentPass=null}else{let l=o.beginRenderPass(i);r.currentPass=l,t.viewport&&this.updateViewport(t),t.scissor&&this.updateScissor(t)}r.descriptor=i,r.encoder=o,r.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},r.renderBundles=[]}_createArrayCameraLayerDescriptors(t,e,i,r){let s=i.depthStencilAttachment;e.layerDescriptors=[];let n=this.get(t.depthTexture);n.viewCache||(n.viewCache=[]);for(let a=0;a<r.length;a++){let o=i.colorAttachments[0],l=new Py;l.view=i.colorAttachments[a].view,l.depthSlice=o.depthSlice,l.resolveTarget=o.resolveTarget,l.loadOp=o.loadOp,l.storeOp=o.storeOp,l.clearValue=o.clearValue;let h=new Ry;if(h.label=i.label,h.occlusionQuerySet=i.occlusionQuerySet,h.timestampWrites=i.timestampWrites,h.colorAttachments.push(l),i.depthStencilAttachment){let u=a;n.viewCache[u]||(Yr.dimension=qn.TwoD,Yr.baseArrayLayer=a,Yr.arrayLayerCount=1,n.viewCache[u]=n.texture.createView(Yr),Yr.reset());let d=new rw;d.view=n.viewCache[u],d.depthLoadOp=s.depthLoadOp||Yi.Clear,d.depthStoreOp=s.depthStoreOp||La.Store,d.depthClearValue=s.depthClearValue||1,t.stencil&&(d.stencilLoadOp=s.stencilLoadOp,d.stencilStoreOp=s.stencilStoreOp,d.stencilClearValue=s.stencilClearValue),h.depthStencilAttachment=d}else{let u=new rw;u.view=s.view,u.depthLoadOp=s.depthLoadOp,u.depthStoreOp=s.depthStoreOp,u.depthClearValue=s.depthClearValue,u.depthReadOnly=s.depthReadOnly,u.stencilLoadOp=s.stencilLoadOp,u.stencilStoreOp=s.stencilStoreOp,u.stencilClearValue=s.stencilClearValue,u.stencilReadOnly=s.stencilReadOnly,h.depthStencilAttachment=u}e.layerDescriptors.push(h)}}_updateArrayCameraLayerDescriptors(t,e,i){for(let r=0;r<i.length;r++){let s=e.layerDescriptors[r];if(s.depthStencilAttachment){let n=s.depthStencilAttachment;t.depth&&(t.clearDepth?(n.depthClearValue=t.clearDepthValue,n.depthLoadOp=Yi.Clear):n.depthLoadOp=Yi.Load),t.stencil&&(t.clearStencil?(n.stencilClearValue=t.clearStencilValue,n.stencilLoadOp=Yi.Clear):n.stencilLoadOp=Yi.Load)}}}finishRender(t){let e=this.get(t),i=t.occlusionQueryCount;e.renderBundles.length>0&&e.currentPass.executeBundles(e.renderBundles),i>e.occlusionQueryIndex&&e.currentPass.endOcclusionQuery();let r=e.encoder;if(this._isRenderCameraDepthArray(t)===!0){let s=[];for(let n=0;n<e.bundleEncoders.length;n++){let a=e.bundleEncoders[n];s.push(a.finish())}for(let n=0;n<e.layerDescriptors.length;n++)if(n<s.length){let a=e.layerDescriptors[n],o=r.beginRenderPass(a);if(t.viewport){let{x:l,y:h,width:u,height:d,minDepth:c,maxDepth:p}=t.viewportValue;o.setViewport(l,h,u,d,c,p)}if(t.scissor){let{x:l,y:h,width:u,height:d}=t.scissorValue;o.setScissorRect(l,h,u,d)}o.executeBundles([s[n]]),o.end()}}else e.currentPass&&e.currentPass.end();if(i>0){let s=8*i,n=this.occludedResolveCache.get(s);n===void 0&&(Do.size=s,Do.usage=GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC,n=this.device.createBuffer(Do),Do.reset(),this.occludedResolveCache.set(s,n)),Do.size=s,Do.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ;let a=this.device.createBuffer(Do);Do.reset(),e.encoder.resolveQuerySet(e.occlusionQuerySet,0,i,n,0),e.encoder.copyBufferToBuffer(n,0,a,0,s),e.occlusionQueryBuffer=a,this.resolveOccludedAsync(t)}if(hu(this.device,e.encoder.finish()),t.textures!==null){let s=t.textures;for(let n=0;n<s.length;n++){let a=s[n];a.generateMipmaps===!0&&this.textureUtils.generateMipmaps(a)}}}isOccluded(t,e){let i=this.get(t);return i.occluded&&i.occluded.has(e)}async resolveOccludedAsync(t){let e=this.get(t),{currentOcclusionQueryBuffer:i,currentOcclusionQueryObjects:r}=e;if(i&&r){let s=new WeakSet;e.currentOcclusionQueryObjects=null,e.currentOcclusionQueryBuffer=null,await i.mapAsync(GPUMapMode.READ);let n=i.getMappedRange(),a=new BigUint64Array(n);for(let o=0;o<r.length;o++)a[o]===BigInt(0)&&s.add(r[o]);i.destroy(),e.occluded=s}}updateViewport(t){let{currentPass:e}=this.get(t),{x:i,y:r,width:s,height:n,minDepth:a,maxDepth:o}=t.viewportValue;e.setViewport(i,r,s,n,a,o)}updateScissor(t){let{currentPass:e}=this.get(t),{x:i,y:r,width:s,height:n}=t.scissorValue;e.setScissorRect(i,r,s,n)}getClearColor(){let t=super.getClearColor();return this.renderer.alpha===!0&&(t.r*=t.a,t.g*=t.a,t.b*=t.a),t}clear(t,e,i,r=null){let s,n,a,o=this.device,l=this.renderer,h=[];if(t){let d=this.getClearColor();Fl.r=d.r,Fl.g=d.g,Fl.b=d.b,Fl.a=d.a}if(r===null){n=l.depth,a=l.stencil;let d=this._getDefaultRenderPassDescriptor();if(t){h=d.colorAttachments;let c=h[0];c.clearValue=Fl,c.loadOp=Yi.Clear,c.storeOp=La.Store}(n||a)&&(s=d.depthStencilAttachment)}else{n=r.depth,a=r.stencil;let d={loadOp:t?Yi.Clear:Yi.Load,clearValue:t?Fl:void 0};n&&(d.depthLoadOp=e?Yi.Clear:Yi.Load,d.depthClearValue=e?l.getClearDepth():void 0,d.depthStoreOp=La.Store),a&&(d.stencilLoadOp=i?Yi.Clear:Yi.Load,d.stencilClearValue=i?l.getClearStencil():void 0,d.stencilStoreOp=La.Store);let c=this._getRenderPassDescriptor(r,d);h=c.colorAttachments,s=c.depthStencilAttachment}n&&s&&(e?(s.depthLoadOp=Yi.Clear,s.depthClearValue=l.getClearDepth(),s.depthStoreOp=La.Store):(s.depthLoadOp=Yi.Load,s.depthStoreOp=La.Store)),a&&s&&(i?(s.stencilLoadOp=Yi.Clear,s.stencilClearValue=l.getClearStencil(),s.stencilStoreOp=La.Store):(s.stencilLoadOp=Yi.Load,s.stencilStoreOp=La.Store)),Ua.label="clear";let u=o.createCommandEncoder(Ua);Ua.reset(),u.beginRenderPass({colorAttachments:h,depthStencilAttachment:s}).end(),hu(o,u.finish())}beginCompute(t){let e=this.get(t),i="computeGroup_"+t.id;sw.label=i,Ua.label=i,this.initTimestampQuery(og.COMPUTE,this.getTimestampUID(t),sw),e.cmdEncoderGPU=this.device.createCommandEncoder(Ua),e.passEncoderGPU=e.cmdEncoderGPU.beginComputePass(sw),e.currentPipeline=null,Ua.reset(),sw.reset()}compute(t,e,i,r,s=null){let n=this.get(e),a=this.get(t),{passEncoderGPU:o}=a,l=this.get(r).pipeline;a.currentPipeline!==l&&(o.setPipeline(l),a.currentPipeline=l);for(let h=0,u=i.length;h<u;h++){let d=i[h],c=this.get(d);o.setBindGroup(h,c.group)}if(s===null&&(s=e.dispatchSize||e.count),s&&s.isIndirectStorageBufferAttribute){let h=this.get(s).buffer;return void o.dispatchWorkgroupsIndirect(h,0)}if(typeof s=="number"){let h=s;if(n.dispatchSize===void 0||n.count!==h){n.dispatchSize=[0,1,1],n.count=h;let u=e.workgroupSize,d=u[0];for(let m=1;m<u.length;m++)d*=u[m];let c=Math.ceil(h/d),p=this.device.limits.maxComputeWorkgroupsPerDimension;s=[c,1,1],c>p&&(s[0]=Math.min(c,p),s[1]=Math.ceil(c/p)),n.dispatchSize=s}s=n.dispatchSize}o.dispatchWorkgroups(s[0],s[1]||1,s[2]||1)}finishCompute(t){let e=this.get(t);e.passEncoderGPU.end(),hu(this.device,e.cmdEncoderGPU.finish())}_draw(t,e,i,r,s,n,a,o,l){let{object:h,context:u}=t,d=t.drawMaterial,c=t.getIndex(),p=c!==null;l.pipeline!==r&&(o.setPipeline(r),l.pipeline=r);let m=l.bindingGroups;for(let f=0,g=s.length;f<g;f++){let y=s[f];if(m[f]!==y.id){let v=this.get(y);o.setBindGroup(f,v.group),m[f]=y.id}}if(p===!0&&l.index!==c){let f=this.get(c).buffer,g=c.array instanceof Uint16Array?ZC.Uint16:ZC.Uint32;o.setIndexBuffer(f,g),l.index=c}for(let f=0,g=n.length;f<g;f++){let y=n[f];if(l.attributes[f]!==y){let v=this.get(y).buffer;o.setVertexBuffer(f,v),l.attributes[f]=y}}if(u.stencil===!0&&d.stencilWrite===!0&&i.currentStencilRef!==d.stencilRef&&(o.setStencilReference(d.stencilRef),i.currentStencilRef=d.stencilRef),h.isBatchedMesh===!0){let f=h._multiDrawStarts,g=h._multiDrawCounts,y=h._multiDrawCount,v=p===!0?c.array.BYTES_PER_ELEMENT:1;d.wireframe&&(v=h.geometry.attributes.position.count>65535?4:2);for(let b=0;b<y;b++)p===!0?o.drawIndexed(g[b],1,f[b]/v,0,b):o.draw(g[b],1,f[b],b),e.update(h,g[b],1)}else if(p===!0){let{vertexCount:f,instanceCount:g,firstVertex:y}=a,v=t.getIndirect();if(v!==null){let b=this.get(v).buffer,_=t.getIndirectOffset(),x=Array.isArray(_)?_:[_];for(let S=0;S<x.length;S++)o.drawIndexedIndirect(b,x[S])}else o.drawIndexed(f,g,y,0,0);e.update(h,f,g)}else{let{vertexCount:f,instanceCount:g,firstVertex:y}=a,v=t.getIndirect();if(v!==null){let b=this.get(v).buffer,_=t.getIndirectOffset(),x=Array.isArray(_)?_:[_];for(let S=0;S<x.length;S++)o.drawIndirect(b,x[S])}else o.draw(f,g,y,0);e.update(h,f,g)}}draw(t,e){let{object:i,context:r,pipeline:s}=t,n=this.get(r),a=this.get(s),o=a.pipeline;if(a.error===!0)return;let l=t.getDrawParameters();if(l===null)return;let h=t.getBindings(),u=t.getVertexBuffers();if(t.camera.isArrayCamera&&t.camera.cameras.length>0){let d=this.get(t.camera),c=t.camera.cameras,p=t.getBindingGroup("cameraIndex");if(d.indexesGPU===void 0||d.indexesGPU.length!==c.length){let f=this.get(p),g=[],y=new Uint32Array([0,0,0,0]);for(let v=0,b=c.length;v<b;v++){y[0]=v;let{layoutGPU:_}=f.layout,x=this.bindingUtils.createBindGroupIndex(y,_);g.push(x)}d.indexesGPU=g}let m=this.renderer.getPixelRatio();for(let f=0,g=c.length;f<g;f++){let y=c[f];if(i.layers.test(y.layers)){let v=y.viewport,b=n.currentPass,_=n.currentSets,x=n.bundleEncoders!==void 0;if(x&&(b=n.bundleEncoders[f],_=n.bundleSets[f]),v&&!x&&b.setViewport(Math.floor(v.x*m),Math.floor(v.y*m),Math.floor(v.width*m),Math.floor(v.height*m),r.viewportValue.minDepth,r.viewportValue.maxDepth),p&&d.indexesGPU){let S=h.indexOf(p);b.setBindGroup(S,d.indexesGPU[f]),_.bindingGroups[S]=p.id}this._draw(t,e,n,o,h,u,l,b,_)}}}else if(n.currentPass){if(n.occlusionQuerySet!==void 0){let d=n.lastOcclusionObject;d!==i&&(d!==null&&d.occlusionTest===!0&&(n.currentPass.endOcclusionQuery(),n.occlusionQueryIndex++),i.occlusionTest===!0&&(n.currentPass.beginOcclusionQuery(n.occlusionQueryIndex),n.occlusionQueryObjects[n.occlusionQueryIndex]=i),n.lastOcclusionObject=i)}this._draw(t,e,n,o,h,u,l,n.currentPass,n.currentSets)}}needsRenderUpdate(t){let e=this.get(t),i=t.material,r=!1;return(e.material!==i||e.materialVersion!==i.version)&&(e.material=i,e.materialVersion=i.version,r=!0),this._syncStructuralState(e,t,i)||r}_syncStructuralState(t,e,i){let{object:r}=e,s=this.utils,n=s.getSampleCountRenderContext(e.context),a=s.getCurrentColorSpace(e.context),o=s.getCurrentColorFormat(e.context),l=s.getCurrentDepthStencilFormat(e.context),h=s.getPrimitiveTopology(r,i),u=r.isMesh&&r.matrixWorld.determinantAffine()<0,d=!1;return(t.transparent!==i.transparent||t.blending!==i.blending||t.premultipliedAlpha!==i.premultipliedAlpha||t.blendSrc!==i.blendSrc||t.blendDst!==i.blendDst||t.blendEquation!==i.blendEquation||t.blendSrcAlpha!==i.blendSrcAlpha||t.blendDstAlpha!==i.blendDstAlpha||t.blendEquationAlpha!==i.blendEquationAlpha||t.colorWrite!==i.colorWrite||t.depthWrite!==i.depthWrite||t.depthTest!==i.depthTest||t.depthFunc!==i.depthFunc||t.stencilWrite!==i.stencilWrite||t.stencilFunc!==i.stencilFunc||t.stencilFail!==i.stencilFail||t.stencilZFail!==i.stencilZFail||t.stencilZPass!==i.stencilZPass||t.stencilFuncMask!==i.stencilFuncMask||t.stencilWriteMask!==i.stencilWriteMask||t.side!==i.side||t.alphaToCoverage!==i.alphaToCoverage||t.polygonOffset!==i.polygonOffset||t.polygonOffsetFactor!==i.polygonOffsetFactor||t.polygonOffsetUnits!==i.polygonOffsetUnits||t.sampleCount!==n||t.colorSpace!==a||t.colorFormat!==o||t.depthStencilFormat!==l||t.primitiveTopology!==h||t.frontFaceCW!==u||t.clippingContextCacheKey!==e.clippingContextCacheKey)&&(t.transparent=i.transparent,t.blending=i.blending,t.premultipliedAlpha=i.premultipliedAlpha,t.blendSrc=i.blendSrc,t.blendDst=i.blendDst,t.blendEquation=i.blendEquation,t.blendSrcAlpha=i.blendSrcAlpha,t.blendDstAlpha=i.blendDstAlpha,t.blendEquationAlpha=i.blendEquationAlpha,t.colorWrite=i.colorWrite,t.depthWrite=i.depthWrite,t.depthTest=i.depthTest,t.depthFunc=i.depthFunc,t.stencilWrite=i.stencilWrite,t.stencilFunc=i.stencilFunc,t.stencilFail=i.stencilFail,t.stencilZFail=i.stencilZFail,t.stencilZPass=i.stencilZPass,t.stencilFuncMask=i.stencilFuncMask,t.stencilWriteMask=i.stencilWriteMask,t.side=i.side,t.alphaToCoverage=i.alphaToCoverage,t.polygonOffset=i.polygonOffset,t.polygonOffsetFactor=i.polygonOffsetFactor,t.polygonOffsetUnits=i.polygonOffsetUnits,t.sampleCount=n,t.colorSpace=a,t.colorFormat=o,t.depthStencilFormat=l,t.primitiveTopology=h,t.frontFaceCW=u,t.clippingContextCacheKey=e.clippingContextCacheKey,d=!0),d}detectStructuralChange(t){return this._syncStructuralState(this.get(t),t,t.material)}getAttachmentStateKey(t){let e=this.utils,i=t.context;return e.getSampleCountRenderContext(i)+","+e.getCurrentColorSpace(i)+","+e.getCurrentColorFormat(i)+","+e.getCurrentDepthStencilFormat(i)}syncRenderUpdateState(t,e){let i=this.get(t);i.material=t.material,i.materialVersion=t.material.version,this._syncStructuralState(i,t,e)}getVertexLayoutCacheKey(t){let{object:e,geometry:i}=t,r="";for(let s of this.attributeUtils.createShaderVertexBuffers(t)){r+=s.stepMode+":"+s.arrayStride+":";for(let n of s.attributes)r+=n.shaderLocation+"-"+n.offset+"-"+n.format+",";r+=";"}return i.index!==null&&e.isLine===!0&&e.isLineSegments!==!0&&(r+=i.index.array instanceof Uint16Array?"index-u16":"index-u32"),r}getRenderCacheKey(t){let{object:e}=t,i=t.drawMaterial,r=this.utils,s=t.context,n=e.isMesh&&e.matrixWorld.determinantAffine()<0,a=r.getSampleCountRenderContext(s),o=i.blending!==Wi&&(i.blending!==Ql||i.transparent!==!1),l=o&&i.blending===VS,h=s.depth===!0,u=s.stencil===!0,d=u&&i.stencilWrite===!0,c=r.getPrimitiveTopology(e,i),p=(h||u)&&i.polygonOffset===!0&&c===If.TriangleList;return[o?i.blending:-1,o&&l===!1?i.premultipliedAlpha:-1,l?i.blendSrc:-1,l?i.blendDst:-1,l?i.blendEquation:-1,l?i.blendSrcAlpha!==null?i.blendSrcAlpha:i.blendSrc:-1,l?i.blendDstAlpha!==null?i.blendDstAlpha:i.blendDst:-1,l?i.blendEquationAlpha!==null?i.blendEquationAlpha:i.blendEquation:-1,i.colorWrite,h?i.depthWrite:-1,h&&i.depthTest===!0?i.depthFunc:-1,d?i.stencilFunc:-1,d?i.stencilFail:-1,d?i.stencilZFail:-1,d?i.stencilZPass:-1,u?i.stencilFuncMask:-1,u?i.stencilWriteMask:-1,p?i.polygonOffsetUnits:0,p?i.polygonOffsetFactor:0,i.alphaToCoverage===!0&&a>1,i.side,n,a,r.getCurrentColorSpace(s),r.getCurrentColorFormat(s),r.getCurrentDepthStencilFormat(s),c,this.getVertexLayoutCacheKey(t),t.clippingContextCacheKey,s.mrt!==null&&i.mrtWriteMask?JSON.stringify(i.mrtWriteMask):""].join()}updateSampler(t){return this.textureUtils.updateSampler(t)}destroySampler(t){this.textureUtils.destroySampler(t)}createDefaultTexture(t){return this.textureUtils.createDefaultTexture(t)}createTexture(t,e){this.textureUtils.createTexture(t,e)}updateTexture(t,e){this.textureUtils.updateTexture(t,e)}generateMipmaps(t){this.textureUtils.generateMipmaps(t)}destroyTexture(t,e=!1){this.textureUtils.destroyTexture(t,e)}async copyTextureToBuffer(t,e,i,r,s,n){return this.textureUtils.copyTextureToBuffer(t,e,i,r,s,n)}initTimestampQuery(t,e,i){if(!this.trackTimestamp)return;this.timestampQueryPool[t]||(this.timestampQueryPool[t]=new qlt(this.device,t,2048));let r=this.timestampQueryPool[t],s=r.allocateQueriesForContext(e);aw.querySet=r.querySet,aw.beginningOfPassWriteIndex=s,aw.endOfPassWriteIndex=s+1,i.timestampWrites=aw}createNodeBuilder(t,e){return new Nlt(t,e)}createProgram(t){let e=this.get(t);nw.label=t.stage+(t.name!==""?`_${t.name}`:""),nw.code=t.code,e.module={module:this.device.createShaderModule(nw),entryPoint:"main"},nw.reset()}destroyProgram(t){this.delete(t)}createRenderPipeline(t,e){this.pipelineUtils.createRenderPipeline(t,e)}createComputePipeline(t,e){this.pipelineUtils.createComputePipeline(t,e)}beginBundle(t){let e=this.get(t);e._currentPass=e.currentPass,e._currentSets=e.currentSets,e.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},e.currentPass=this.pipelineUtils.createBundleEncoder(t)}finishBundle(t,e){let i=this.get(t),r=i.currentPass.finish();this.get(e).bundleGPU=r,i.currentSets=i._currentSets,i.currentPass=i._currentPass}addBundle(t,e){this.get(t).renderBundles.push(this.get(e).bundleGPU)}createUniformBuffer(t){let e=this.get(t);if(e.buffer===void 0){let i=t.byteLength,r=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,s=[];t.visibility&Ah.VERTEX&&s.push("vertex"),t.visibility&Ah.FRAGMENT&&s.push("fragment"),t.visibility&Ah.COMPUTE&&s.push("compute");let n=`(${s.join(",")})`;Do.label=`bindingBuffer${t.id}_${t.name}_${n}`,Do.size=i,Do.usage=r;let a=this.device.createBuffer(Do);Do.reset(),e.buffer=a}}destroyUniformBuffer(t){this.get(t).buffer.destroy(),this.delete(t)}createBindings(t,e,i,r){this.bindingUtils.createBindings(t,e,i,r)}updateBindings(t,e,i,r){this.bindingUtils.createBindings(t,e,i,r)}updateBinding(t){this.bindingUtils.updateBinding(t)}deleteBindGroupData(t){this.bindingUtils.deleteBindGroupData(t)}createIndexAttribute(t){let e=GPUBufferUsage.INDEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST;(t.isStorageBufferAttribute||t.isStorageInstancedBufferAttribute)&&(e|=GPUBufferUsage.STORAGE),this.attributeUtils.createAttribute(t,e)}createAttribute(t){this.attributeUtils.createAttribute(t,GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createStorageAttribute(t){this.attributeUtils.createAttribute(t,GPUBufferUsage.STORAGE|GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createIndirectStorageAttribute(t){this.attributeUtils.createAttribute(t,GPUBufferUsage.STORAGE|GPUBufferUsage.INDIRECT|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}updateAttribute(t){this.attributeUtils.updateAttribute(t)}destroyAttribute(t){this.attributeUtils.destroyAttribute(t)}updateSize(){this.delete(this.renderer.getCanvasTarget())}hasFeature(t){return yL[t]!==void 0&&(t=yL[t]),this.device.features.has(t)}copyTextureToTexture(t,e,i=null,r=null,s=0,n=0){let a=0,o=0,l=0,h=0,u=0,d=0,c=t.image.width,p=t.image.height,m=1;i!==null&&(i.isBox3===!0?(h=i.min.x,u=i.min.y,d=i.min.z,c=i.max.x-i.min.x,p=i.max.y-i.min.y,m=i.max.z-i.min.z):(h=i.min.x,u=i.min.y,c=i.max.x-i.min.x,p=i.max.y-i.min.y,m=1)),r!==null&&(a=r.x,o=r.y,l=r.z||0),Ua.label="copyTextureToTexture_"+t.id+"_"+e.id;let f=this.device.createCommandEncoder(Ua);Ua.reset();let g=this.get(t).texture,y=this.get(e).texture;nl.texture=g,nl.mipLevel=s,nl.origin.x=h,nl.origin.y=u,nl.origin.z=d,Eh.texture=y,Eh.mipLevel=n,Eh.origin.x=a,Eh.origin.y=o,Eh.origin.z=l,_u.width=c,_u.height=p,_u.depthOrArrayLayers=m,f.copyTextureToTexture(nl,Eh,_u),nl.reset(),Eh.reset(),_u.reset(),hu(this.device,f.finish()),n===0&&e.generateMipmaps&&this.textureUtils.generateMipmaps(e)}copyFramebufferToTexture(t,e,i){let r=this.get(e),s=null;s=e.renderTarget?t.isDepthTexture?this.get(e.depthTexture).texture:this.get(e.textures[0]).texture:t.isDepthTexture?this.textureUtils.getDepthBuffer(e.depth,e.stencil):this.context.getCurrentTexture();let n,a=this.get(t).texture;if(s.format===a.format)if(r.currentPass?(r.currentPass.end(),n=r.encoder):(Ua.label="copyFramebufferToTexture_"+t.id,n=this.device.createCommandEncoder(Ua),Ua.reset()),nl.texture=s,nl.origin.x=i.x,nl.origin.y=i.y,Eh.texture=a,_u.width=i.z,_u.height=i.w,n.copyTextureToTexture(nl,Eh,_u),nl.reset(),Eh.reset(),_u.reset(),t.generateMipmaps&&this.textureUtils.generateMipmaps(t,n),r.currentPass){let{descriptor:o}=r;for(let l=0;l<o.colorAttachments.length;l++)o.colorAttachments[l].loadOp=Yi.Load;e.depth&&(o.depthStencilAttachment.depthLoadOp=Yi.Load),e.stencil&&(o.depthStencilAttachment.stencilLoadOp=Yi.Load),r.currentPass=n.beginRenderPass(o),r.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},e.viewport&&this.updateViewport(e),e.scissor&&this.updateScissor(e)}else hu(this.device,n.finish());else Ht("WebGPUBackend: copyFramebufferToTexture: Source and destination formats do not match.",s.format,a.format)}hasCompatibility(t){return this._compatibility[t]!==void 0?this._compatibility[t]:super.hasCompatibility(t)}dispose(){if(this.bindingUtils.dispose(),this.textureUtils.dispose(),this.occludedResolveCache){for(let t of this.occludedResolveCache.values())t.destroy();this.occludedResolveCache.clear()}if(this.timestampQueryPool)for(let t of Object.values(this.timestampQueryPool))t!==null&&t.dispose();this.parameters.device===void 0&&this.device!==null&&this.device.destroy()}},Ylt=class extends Wg{constructor(t,e,i,r,s,n){super(t,e,i,r,s,n),this.iesMap=null}copy(t,e){return super.copy(t,e),this.iesMap=t.iesMap,this}},Klt=class extends Wg{constructor(t,e,i,r,s,n){super(t,e,i,r,s,n),this.aspect=null}copy(t,e){return super.copy(t,e),this.aspect=t.aspect,this}},Zlt=class extends sL{constructor(){super(),this.addMaterial(v9,"MeshPhongMaterial"),this.addMaterial(PR,"MeshStandardMaterial"),this.addMaterial(_9,"MeshPhysicalMaterial"),this.addMaterial(x9,"MeshToonMaterial"),this.addMaterial(g9,"MeshBasicMaterial"),this.addMaterial(y9,"MeshLambertMaterial"),this.addMaterial(f9,"MeshNormalMaterial"),this.addMaterial(w9,"MeshMatcapMaterial"),this.addMaterial(p9,"LineBasicMaterial"),this.addMaterial(m9,"LineDashedMaterial"),this.addMaterial(iT,"PointsMaterial"),this.addMaterial(RR,"SpriteMaterial"),this.addMaterial(S9,"ShadowMaterial"),this.addLight(A9,FS),this.addLight(C9,US),this.addLight(Uot,eft),this.addLight(M2,Wg),this.addLight(kot,tft),this.addLight(E9,iD),this.addLight(zot,ift),this.addLight(Vot,Ylt),this.addLight(Fot,Klt),this.addToneMapping(f6,Ppt),this.addToneMapping(g6,Rpt),this.addToneMapping(y6,Dpt),this.addToneMapping(v6,wG),this.addToneMapping(b6,SG),this.addToneMapping(_6,TG)}},IR=class extends Zot{constructor(t={}){if(t.forceWebGL)throw new Error("WebGPURenderer: forceWebGL is not supported in this WebGPU-only build.");let e=Xlt;t.getFallback=i=>{throw new Error("WebGPURenderer: WebGPU is not available, and this WebGPU-only build has no WebGL2 fallback. "+(i&&i.message?i.message:i))},super(new e(t),t),this.library=new Zlt,this.isWebGPURenderer=!0,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}},G1t=class{constructor(t,e=oe(0,0,1,1)){this.renderer=t,this.outputNode=e,this.outputColorTransform=!0,this.needsUpdate=!0;let i=new Pe;i.name="RenderPipeline",this._quadMesh=new Pr(i),this._quadMesh.name="Render Pipeline",this._context=null,this._toneMapping=t.toneMapping,this._outputColorSpace=t.outputColorSpace}render(){let t=this.renderer;this._update(),this._context.onBeforeRenderPipeline!==null&&this._context.onBeforeRenderPipeline();let e=t.toneMapping,i=t.outputColorSpace;t.toneMapping=cl,t.outputColorSpace=Zi.workingColorSpace;let r=t.xr.enabled;t.xr.enabled=!1,this._quadMesh.render(t),t.xr.enabled=r,t.toneMapping=e,t.outputColorSpace=i,this._context.onAfterRenderPipeline!==null&&this._context.onAfterRenderPipeline()}get context(){return this._context}dispose(){this._quadMesh.material.dispose()}_update(){if(this._toneMapping!==this.renderer.toneMapping&&(this._toneMapping=this.renderer.toneMapping,this.needsUpdate=!0),this._outputColorSpace!==this.renderer.outputColorSpace&&(this._outputColorSpace=this.renderer.outputColorSpace,this.needsUpdate=!0),this.needsUpdate===!0){let t=this._toneMapping,e=this._outputColorSpace,i={renderPipeline:this,onBeforeRenderPipeline:null,onAfterRenderPipeline:null},r=this.outputNode;this.outputColorTransform===!0?(r=r.context(i),r=Uk(r,t,e)):(i.toneMapping=t,i.outputColorSpace=e,r=r.context(i)),this._context=i,this._quadMesh.material.fragmentNode=r,this._quadMesh.material.needsUpdate=!0,this.needsUpdate=!1}}async renderAsync(){Ki('RenderPipeline: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.'),await this.renderer.init(),this.render()}},W1t=class extends di{constructor(t=1,e=1){super(),this.image={width:t,height:e},this.magFilter=pe,this.minFilter=pe,this.isStorageTexture=!0,this.mipmapsAutoUpdate=!0}setSize(t,e){(this.image.width!==t||this.image.height!==e)&&(this.image.width=t,this.image.height=e,this.dispose())}},Yg=class extends di{constructor(t=1,e=1,i=1){super(),this.isArrayTexture=!1,this.image={width:t,height:e,depth:i},this.magFilter=pe,this.minFilter=pe,this.wrapR=Cn,this.isStorageTexture=!0,this.is3DTexture=!0}setSize(t,e,i){(this.image.width!==t||this.image.height!==e||this.image.depth!==i)&&(this.image.width=t,this.image.height=e,this.image.depth=i,this.dispose())}}}),je=U(()=>{cr(),R.BRDF_GGX,R.BRDF_Lambert,R.BasicPointShadowFilter,R.BasicShadowFilter,ea=R.Break,R.Const,R.Continue,R.DFGLUT,R.D_GGX,NR=R.Discard,R.EPSILON,R.F_Schlick,At=R.Fn,R.INFINITY,vt=R.If,Qi=R.Loop,R.NodeAccess,R.NodeShaderStage,R.NodeType,q1t=R.NodeUpdateType,R.PCFShadowFilter,R.PCFSoftShadowFilter,P9=R.PI,R.PI2,R.TWO_PI,R.HALF_PI,H1t=R.PointShadowFilter,fr=R.Return,R.Schlick_to_F0,R.ShaderNode,R.Stack,R.Switch,R.TBNViewMatrix,R.VSMShadowFilter,R.V_GGX_SmithCorrelated,R.Var,R.VarIntent,ke=R.abs,R.acesFilmicToneMapping,BR=R.acos,R.acosh,R.add,R.addMethodChaining,R.addNodeElement,R.agxToneMapping,R.all,R.alphaT,R.ambientOcclusion,R.and,R.anisotropy,R.anisotropyB,R.anisotropyT,oq=R.any,R.append,R.array,lq=R.asin,R.asinh,R.assign,wc=R.atan,R.atanh,hl=R.atomicAdd,R.atomicAnd,R.atomicFunc,yg=R.atomicLoad,R.atomicMax,R.atomicMin,R.atomicOr,Oo=R.atomicStore,kR=R.atomicSub,R.atomicXor,R.attenuationColor,R.attenuationDistance,Hv=R.attribute,R.attributeArray,R.backgroundBlurriness,R.backgroundIntensity,R.backgroundRotation,R.batch,R.bentNormalView,R.billboarding,R.bitAnd,R.bitNot,R.bitOr,R.bitXor,R.bitangentGeometry,R.bitangentLocal,R.bitangentView,R.bitangentWorld,$1t=R.bitcast,R.blendBurn,R.blendColor,R.blendDodge,R.blendOverlay,R.blendScreen,R.blur,X1t=R.bool,Y1t=R.buffer,R.bufferAttribute,R.bumpMap,R.builtin,R.builtinAOContext,R.builtinShadowContext,R.bvec2,R.bvec3,R.bvec4,R.bypass,R.cache,R.call,R.cameraFar,R.cameraIndex,K1t=R.cameraNear,R.cameraNormalMatrix,Oc=R.cameraPosition,mb=R.cameraProjectionMatrix,Z1t=R.cameraProjectionMatrixInverse,ih=R.cameraViewMatrix,R.cameraViewport,w5=R.cameraWorldMatrix,R.cbrt,R.cdl,R.ceil,R.checker,R.cineonToneMapping,Te=R.clamp,Q1t=R.clearcoat,J1t=R.clearcoatNormalView,hq=R.clearcoatRoughness,R.clipSpace,R.code,tvt=R.color,R.colorSpaceToWorking,R.colorToDirection,R.compute,R.computeKernel,R.computeSkinning,R.context,R.convert,R.convertColorSpace,evt=R.convertToTexture,R.countLeadingZeros,R.countOneBits,R.countTrailingZeros,Xa=R.cos,R.cosh,Kr=R.cross,ivt=R.cubeTexture,R.cubeTextureBase,$v=R.dFdx,Xv=R.dFdy,R.dashSize,R.debug,R.decrement,R.decrementBefore,R.defaultBuildStages,R.defaultShaderStages,R.defined,R.degrees,R.deltaTime,R.densityFog,R.densityFogFactor,BD=R.depth,R.depthPass,R.determinant,R.difference,ko=R.diffuseColor,R.directPointLight,R.directionToColor,R.directionToFaceDirection,R.dispersion,rvt=R.distance,R.div,Bt=R.dot,R.drawIndex,R.dynamicBufferAttribute,R.element,R9=R.emissive,R.equal,R.equirectDirection,R.equirectUV,kD=R.exp,k1=R.exp2,R.exponentialHeightFogFactor,R.expression,VD=R.faceDirection,R.faceForward,R.faceforward,I=R.float,R.floatBitsToInt,R.floatBitsToUint,de=R.floor,svt=R.fog,Di=R.fract,R.frameGroup,R.frameId,nvt=R.frontFacing,D9=R.fwidth,R.gain,R.gapSize,R.getConstNodeType,R.getCurrentStack,R.getDirection,R.getDistanceAttenuation,R.getGeometryRoughness,R.getNormalFromDepth,Pc=R.interleavedGradientNoise,Sm=R.vogelDiskSample,R.getParallaxCorrectNormal,R.getRoughness,R.getScreenPosition,R.getShIrradianceAt,R.getShadowMaterial,R.getShadowRenderObjectFunction,R.getTextureIndex,uq=R.getViewPosition,ho=R.globalId,R.glsl,R.glslFn,R.grayscale,R.greaterThan,R.greaterThanEqual,R.hash,R.highpModelNormalViewMatrix,R.highpModelViewMatrix,R.hue,R.increment,R.incrementBefore,R.instance,Rn=R.instanceIndex,Zr=R.instancedArray,qp=R.instancedBufferAttribute,avt=R.instancedDynamicBufferAttribute,R.instancedMesh,ct=R.int,R.intBitsToFloat,R.inverse,dq=R.inverseSqrt,R.inversesqrt,R.invocationLocalIndex,R.invocationSubgroupIndex,VR=R.ior,ovt=R.iridescence,lvt=R.iridescenceIOR,hvt=R.iridescenceThickness,Yn=R.ivec2,Kn=R.ivec3,R.ivec4,R.js,R.label,ci=R.length,R.lengthSq,R.lessThan,R.lessThanEqual,R.lightPosition,R.lightProjectionUV,R.lightShadowMatrix,uvt=R.lightTargetDirection,R.lightTargetPosition,R.lightViewPosition,dvt=R.lightingContext,R.lights,R.linearDepth,R.linearToneMapping,zR=R.localId,R.log,Yv=R.log2,R.logarithmicDepthToViewZ,zD=R.luminance,R.mat2,bm=R.mat3,cq=R.mat4,R.matcapUV,R.materialAO,R.materialAlphaTest,R.materialAnisotropy,R.materialAnisotropyVector,R.materialAttenuationColor,R.materialAttenuationDistance,R.materialClearcoat,R.materialClearcoatNormal,R.materialClearcoatRoughness,cvt=R.materialColor,R.materialDispersion,R.materialEmissive,LR=R.materialEnvIntensity,R.materialEnvRotation,R.materialIOR,R.materialIridescence,R.materialIridescenceIOR,R.materialIridescenceThickness,R.materialLightMap,R.materialLineDashOffset,R.materialLineDashSize,R.materialLineGapSize,R.materialLineScale,R.materialLineWidth,R.materialMetalness,R.materialNormal,R.materialOpacity,R.materialPointSize,pvt=R.materialReference,R.materialReflectivity,R.materialRefractionRatio,R.materialRotation,R.materialRoughness,R.materialSheen,R.materialSheenRoughness,R.materialShininess,R.materialSpecular,R.materialSpecularColor,R.materialSpecularIntensity,R.materialSpecularStrength,R.materialThickness,R.materialTransmission,Kt=R.max,R.maxMipLevel,R.mediumpModelViewMatrix,mvt=R.metalness,ti=R.min,$t=R.mix,R.mixElement,qh=R.mod,R.modelDirection,fvt=R.modelNormalMatrix,R.modelPosition,R.modelRadius,gvt=R.modelScale,yvt=R.modelViewMatrix,R.modelViewPosition,FR=R.modelViewProjection,LD=R.modelWorldMatrix,vvt=R.modelWorldMatrixInverse,R.morphReference,Kv=R.mrt,bvt=R.mul,R.mx_aastep,R.mx_add,R.mx_atan2,R.mx_cell_noise_float,R.mx_contrast,R.mx_divide,R.mx_fractal_noise_float,R.mx_fractal_noise_vec2,R.mx_fractal_noise_vec3,R.mx_fractal_noise_vec4,R.mx_frame,R.mx_heighttonormal,R.mx_hsvtorgb,R.mx_ifequal,R.mx_ifgreater,R.mx_ifgreatereq,R.mx_invert,R.mx_modulo,R.mx_multiply,R.mx_noise_float,R.mx_noise_vec3,R.mx_noise_vec4,R.mx_place2d,R.mx_power,R.mx_ramp4,R.mx_ramplr,R.mx_ramptb,R.mx_rgbtohsv,R.mx_rotate2d,R.mx_rotate3d,R.mx_safepower,R.mx_separate,R.mx_splitlr,R.mx_splittb,R.mx_srgb_texture_to_lin_rec709,R.mx_subtract,R.mx_timer,R.mx_transform_uv,R.mx_unifiednoise2d,R.mx_unifiednoise3d,R.mx_worley_noise_float,R.mx_worley_noise_vec2,R.mx_worley_noise_vec3,R.negate,O9=R.negateOnBackSide,R.neutralToneMapping,R.nodeArray,_vt=R.nodeImmutable,R.nodeObject,R.nodeObjectIntent,R.nodeObjects,R.nodeProxy,R.nodeProxyIntent,R.normalFlat,xvt=R.normalGeometry,pq=R.normalLocal,R.normalMap,Ra=R.normalView,R.normalViewGeometry,sT=R.normalWorld,wvt=R.normalWorldGeometry,be=R.normalize,R.not,mq=R.notEqual,R.numWorkgroups,R.objectDirection,R.objectGroup,R.objectPosition,R.objectRadius,R.objectScale,R.objectViewPosition,R.objectWorldMatrix,R.OnBeforeObjectUpdate,R.OnBeforeMaterialUpdate,R.OnObjectUpdate,R.OnMaterialUpdate,Rr=R.oneMinus,R.or,Svt=R.orthographicDepthToViewZ,R.oscSawtooth,R.oscSine,R.oscSquare,R.oscTriangle,Tvt=R.output,R.outputStruct,R.overloadingFn,R.overrideNode,R.overrideNodes,R.packHalf2x16,R.packSnorm2x16,R.packUnorm2x16,Mvt=R.packNormalToRGB,R.parabola,R.parallaxDirection,R.parallaxUV,R.parameter,Avt=R.pass,Cvt=R.passTexture,R.pcurve,Evt=R.perspectiveDepthToViewZ,Pvt=R.pmremTexture,R.pointShadow,R.pointUV,R.pointWidth,FD=R.positionGeometry,Zv=R.positionLocal,UD=R.positionPrevious,Ic=R.positionView,Qv=R.positionViewDirection,Wo=R.positionWorld,R.positionWorldDirection,R.posterize,Lo=R.pow,Rvt=R.pow2,R.pow3,Dvt=R.pow4,R.premultiplyAlpha,R.property,R.radians,fq=R.rand,R.range,R.rangeFog,Ovt=R.rangeFogFactor,R.reciprocal,R.reference,R.referenceBuffer,nT=R.reflect,R.reflectVector,R.reflectView,R.reflector,Ivt=R.refract,R.refractVector,R.refractView,R.reinhardToneMapping,R.remap,R.remapClamp,V1=R.renderGroup,R.renderOutput,R.rendererReference,R.replaceDefaultUV,R.rotate,R.rotateUV,gq=R.roughness,Nvt=R.round,R.rtt,R.sRGBTransferEOTF,R.sRGBTransferOETF,R.sample,zg=R.sampler,R.samplerComparison,R.saturate,R.saturation,R.screen,Qa=R.screenCoordinate,R.screenDPR,R.screenSize,th=R.screenUV,pi=R.select,R.setCurrentStack,R.setName,R.shaderStages,R.shadow,R.shadowPositionWorld,R.shapeCircle,R.sharedUniformGroup,Bvt=R.sheen,kvt=R.sheenRoughness,R.shiftLeft,R.shiftRight,S5=R.shininess,Xu=R.sign,Bn=R.sin,R.sinh,R.sinc,R.skinning,Ji=R.smoothstep,R.smoothstepElement,rv=R.specularColor,I9=R.specularF90,R.spherizeUV,R.split,R.spritesheetUV,xl=R.sqrt,R.stack,Si=R.step,R.stepElement,Vvt=R.storage,R.storageBarrier,R.storageTexture,Hp=R.storageTexture3D,R.struct,A2=R.sub,R.subgroupAdd,R.subgroupAll,R.subgroupAnd,R.subgroupAny,R.subgroupBallot,R.subgroupBroadcast,R.subgroupBroadcastFirst,zvt=R.subBuild,R.subgroupElect,R.subgroupExclusiveAdd,R.subgroupExclusiveMul,R.subgroupInclusiveAdd,R.subgroupInclusiveMul,R.subgroupIndex,R.subgroupMax,R.subgroupMin,R.subgroupMul,R.subgroupOr,R.subgroupShuffle,R.subgroupShuffleDown,R.subgroupShuffleUp,R.subgroupShuffleXor,R.subgroupSize,R.subgroupXor,Lvt=R.tan,R.tanh,R.tangentGeometry,R.tangentLocal,R.tangentView,R.tangentWorld,Jt=R.texture,Sc=R.texture3D,R.textureBarrier,R.textureBicubic,R.textureBicubicLevel,R.textureCubeUV,R.textureLoad,Fvt=R.textureSize,R.textureLevel,R.textureStore,R.thickness,Uvt=R.time,R.toneMapping,R.toneMappingExposure,R.toonOutlinePass,yq=R.transformDirection,R.transformNormal,R.transformNormalByInverseViewMatrix,R.transformNormalByViewMatrix,T5=R.transformNormalToView,R.transformedClearcoatNormalView,R.transformedNormalView,R.transformedNormalWorld,R.transmission,R.transpose,R.triNoise3D,R.triplanarTexture,R.triplanarTextures,R.trunc,Vi=R.uint,R.uintBitsToFloat,mt=R.uniform,aT=R.uniformArray,R.uniformCubeTexture,R.uniformGroup,R.uniformFlow,R.uniformTexture,R.unpackHalf2x16,R.unpackSnorm2x16,R.unpackUnorm2x16,R.unpackRGBToNormal,R.unpremultiplyAlpha,$p=R.userData,ui=R.uv,R.uvec2,jvt=R.uvec3,R.uvec4,Gvt=R.varying,Lr=R.varyingProperty,st=R.vec2,j=R.vec3,at=R.vec4,R.vectorComponents,R.velocity,Wvt=R.vertexColor,SS=R.vertexIndex,N9=R.vertexStage,R.vibrance,R.viewZToLogarithmicDepth,B9=R.viewZToOrthographicDepth,R.viewZToPerspectiveDepth,R.viewZToReversedOrthographicDepth,R.viewZToReversedPerspectiveDepth,R.viewport,R.viewportCoordinate,R.viewportDepthTexture,R.viewportLinearDepth,R.viewportMipTexture,R.viewportOpaqueMipTexture,R.viewportResolution,R.viewportSafeUV,R.viewportSharedTexture,R.viewportSize,R.viewportTexture,R.viewportUV,Lg=R.wgsl,cc=R.wgslFn,qvt=R.workgroupArray,z1=R.workgroupBarrier,UR=R.workgroupId,R.workingToColorSpace,R.xor});function jD(){try{return new URLSearchParams(window.location.search).get("dbgsrgb8")!=="0"}catch{return!0}}var k9,Vo,Fu,V9,Qlt,Jlt,He,Vt,pn=U(()=>{ot(),je(),k9=8,Vo=new di,Fu=(()=>{let t=new yr(new Uint8Array([0,0,0,255]),1,1);return t.minFilter=pe,t.magFilter=pe,t.needsUpdate=!0,t})(),V9=(()=>{let t=new yr(new Uint8Array([0,0,0,255]),1,1);return t.minFilter=pe,t.magFilter=pe,t.needsUpdate=!0,t})(),Qlt=(()=>{let t=new yr(new Uint8Array([255,255,255,255]),1,1);return t.minFilter=pe,t.magFilter=pe,t.needsUpdate=!0,t})(),Jlt=(()=>{let t=new yr(new Uint8Array([0,0,0,0]),1,1);return t.minFilter=pe,t.magFilter=pe,t.needsUpdate=!0,t})(),He={chainBuilds:0,lastChainBuildReason:"",taaResolves:0,taaJitterIndex:0,taaJitterApplies:0,taaHistoryValid:!1,taaResolveSize:"",helperOverlayMode:"",deviceLost:"",outputInterpositions:0,bundleChecks:0,bundleRebuilds:0,bundleDisabled:!1,bundleResourceRebuilds:0,bundleIncompleteRecords:0,bundleRecords:0,bundleReplays:0,instancingGroups:0,instancedDrawsSaved:0,instancingRegroups:0,instancingParks:0,instancingIneligible:{},skippedAsyncDraws:0,stalledSkipFrames:0,compilationBurst:!1,pcssLights:0,pcssInstalled:0,pcssForeignFilter:0,pcssPyramidBuilds:0,pcssPyramidActive:0,shadowMaskResolves:0,shadowMaskActive:0,pcssHookServes:0,pcssRadius0:0,pcssPenumbra0:0,nodeResurrections:0,shadowTypeSoft:!0,depthPrepassDraws:0,depthOfFieldTwinDraws:0},typeof window<"u"&&(window.__SPLINE_WEBGPU_STATS=He),Vt={resolution:mt(new Y(1,1)),pixelRatio:mt(1),frameIndex:mt(0),aspectRatio:mt(new Y(1,1)),transmissionRenderTarget:Jt(Vo),normalRenderTarget:Jt(Vo),normalRenderTargetDepth:Jt(Vo),normalViewRenderTarget:Jt(Vo),aoRenderTarget:Jt(Vo),reflectionRenderTarget:Jt(Fu),reflectionDepthPyramid:Jt(Fu),reflectionDepthSize:mt(new Y(1,1)),reflectionDepthLevels:mt(1,"int"),reflectionEnvMap:Jt(Fu),reflectionEnvEnabled:mt(0),reflectionPlanarTarget:Jt(Fu),reflectionPlanarEnabled:mt(0),reflectionMissColor:mt(new E(0,0,0)),reflectionResolveTarget:Jt(V9),reflectionResolveEnabled:mt(0),shadowMaskTexture:Jt(Qlt),shadowMaskGBuffer:Jt(Jlt),shadowMaskEnabled:mt(0),shadowMaskResolution:mt(new Y(1,1)),shadowMaskFullResolution:mt(new Y(1,1)),transmissionSamplerSize:mt(new Y(2048,2048)),transmissionActualSize:mt(new Y(1,1)),orthographicUniform:mt(0),unjitteredProjection:mt(new bt),aoEnabledUniform:mt(0),pcssHalton:mt(new Y(0,-.333334)),tapAngle:mt(0),tapAngle2:mt(0),cameraJitterPx:mt(new Y(0,0)),toonLightData:aT(Array.from({length:k9},()=>new Se),"vec4"),toonLightCount:mt(0,"int"),taaEnabled:{value:!1},aoEnabled:{value:!1},transmissionLod:{value:2}}});function GEt(t,e){return new Hvt(t,e)}var Uf,aE,ow,oE,Hvt,jR,WEt=U(()=>{ot(),cr(),je(),pn(),Uf=new Pr,aE=new Y,ow=[[0,0],[0,1,1],[0,1,1,2],[0,1,2,2,3],[0,1,2,3,4,4,5],[0,1,2,3,4,5,7,8,9,10]],oE=[.2126729,.7151522,.072175],Hvt=class extends Cr{constructor(t,e){super("vec4"),this._width=0,this._height=0,this._materials=[],this._input=t,this._opts=e,this._rtL=this._makeRT(1,1,"SplineBloom.L"),this._rtA=this._makeRT(1,1,"SplineBloom.A"),this._rtB=this._makeRT(1,1,"SplineBloom.B"),this._outputTexNode=Jt(this._rtL.texture),this._buildMaterials()}static get type(){return"SplineBloomNode"}_makeRT(t,e,i){let r=new ii(t,e,{minFilter:pe,magFilter:pe,depthBuffer:!1});return jD()&&(r.texture.internalFormat="rgba8unorm-srgb"),r.texture.name=i,r}_buildMaterials(){for(let h of this._materials)h.dispose();this._materials=[];let t=(h,u)=>{let d=new Pe;return d.name=h,d.colorNode=u,d.depthTest=!1,d.depthWrite=!1,d.blending=Wi,d.needsUpdate=!0,d},e=this._opts.luminanceThreshold,i=Math.max(this._opts.luminanceSmoothing,1e-4),r=this._input,s=At(()=>{let h=r.sample(ui()),u=Ji(I(e),I(e+i),Bt(h.rgb,j(oE[0],oE[1],oE[2])));return at(h.rgb.mul(u),u)});this._materials.push(t("SplineBloom.luminance",s()));let n=ow[this._opts.kernelSize]??ow[3],a=1/Math.max(1,this._width),o=1/Math.max(1,this._height),l=this._passSequence(n.length);for(let h=0;h<n.length;h++){let u=a*(n[h]+.5)*this._opts.blurScale,d=o*(n[h]+.5)*this._opts.blurScale,c=Jt(l[h].from.texture),p=At(()=>{let m=ui();return c.sample(m.add(st(-u,d))).add(c.sample(m.add(st(u,d)))).add(c.sample(m.add(st(u,-d)))).add(c.sample(m.add(st(-u,-d)))).mul(.25)});this._materials.push(t(`SplineBloom.blur${h}`,p()))}}_passSequence(t){let e=[],i=this._rtL;for(let r=0;r<t-1;r++){let s=1&r?this._rtB:this._rtA;e.push({from:i,to:s}),i=s}return e.push({from:i,to:this._rtL}),e}renderBloom(t){t.getDrawingBufferSize(aE);let e=Math.max(1,Math.round(.5*aE.x)),i=Math.max(1,Math.round(.5*aE.y));(e!==this._width||i!==this._height)&&(this._width=e,this._height=i,this._rtL.dispose(),this._rtA.dispose(),this._rtB.dispose(),this._rtL=this._makeRT(e,i,"SplineBloom.L"),this._rtA=this._makeRT(e,i,"SplineBloom.A"),this._rtB=this._makeRT(e,i,"SplineBloom.B"),this._outputTexNode.value=this._rtL.texture,this._buildMaterials());let r=ow[this._opts.kernelSize]??ow[3],s=this._passSequence(r.length),n=t.getRenderTarget(),a=t.getMRT();t.setMRT(null),t.setRenderTarget(this._rtL),Uf.material=this._materials[0],Uf.name="SplineBloom.luminance",Uf.render(t);for(let o=0;o<s.length;o++)t.setRenderTarget(s[o].to),Uf.material=this._materials[o+1],Uf.name=`SplineBloom.blur${o}`,Uf.render(t);t.setRenderTarget(n),t.setMRT(a)}setup(){return this._outputTexNode}dispose(){for(let t of this._materials)t.dispose();this._materials=[],this._rtL.dispose(),this._rtA.dispose(),this._rtB.dispose()}}}),qEt={},HEt=U(()=>{rq(),WEt(),A1t("bloom",GEt)}),$vt=U(()=>{jR={focusDistance:0,focalLength:200,bokehScale:1}});function $Et(t,e,i,r,s){return new Xvt(t,e,i,r,s)}var lE,hE,lw,Xvt,XEt=U(()=>{ot(),cr(),je(),pn(),$vt(),lE=new Pr,hE=new Y,lw=[0,1,1,2],Xvt=class extends Cr{constructor(t,e,i,r,s){super("vec4"),this._width=0,this._height=0,this._halfWidth=0,this._halfHeight=0,this._materials=[],this._inputColor=t,this._input=e,this._depth=i,this._params=r,this._opts=s,this._rtCoC=this._makeRT(1,1,"DoF.CoC","coc"),this._rtMasked=this._makeRT(1,1,"DoF.Masked.Far","color"),this._rtCoCBlurred=this._makeRT(1,1,"DoF.CoC.Blurred","coc"),this._rtBlurA=this._makeRT(1,1,"DoF.Blur.Target.A","blur"),this._rtBlurB=this._makeRT(1,1,"DoF.Blur.Target.B","blur"),this._rtIntermediate=this._makeRT(1,1,"DoF.Intermediate","color"),this._rtNear=this._makeRT(1,1,"DoF.Bokeh.Near","color"),this._rtFar=this._makeRT(1,1,"DoF.Bokeh.Far","color"),this._nearTexNode=Jt(this._rtNear.texture),this._farTexNode=Jt(this._rtFar.texture),this._cocBlurredTexNode=Jt(this._rtCoCBlurred.texture),this._buildMaterials()}static get type(){return"SplineDepthOfFieldNode"}_makeRT(t,e,i,r){let s=new ii(t,e,{minFilter:pe,magFilter:pe,depthBuffer:!1,type:r==="color"&&this._opts.halfFloat?si:void 0});return r!=="coc"&&s.texture.type!==si&&jD()&&(s.texture.internalFormat="rgba8unorm-srgb"),s.texture.name=i,s}_buildMaterials(){for(let x of this._materials)x.dispose();this._materials=[];let t=(x,S)=>{let w=new Pe;return w.name=x,w.colorNode=S,w.depthTest=!1,w.depthWrite=!1,w.blending=Wi,w.needsUpdate=!0,w},{focusDistance:e,focusRange:i,bokehScale:r,cameraNear:s,cameraFar:n}=this._params,a=this._params.orthographic,o=this._input,l=this._depth,h=this._opts.inputUv??(x=>x),u=x=>x,d=1/Math.max(1,this._halfWidth),c=1/Math.max(1,this._halfHeight),p=At(()=>{let x=ui().toVar(),S=l.sample(x).toVar(),w=B9(Evt(S,s,n),s,n),T=B9(Svt(S,s,n),s,n),C=pi(a.greaterThan(.5),T,w).sub(e).toVar(),M=Ji(I(0),i,ke(C)).toVar();return at(M.mul(Si(C,I(0))),M.mul(Si(I(0),C)),0,1)});this._materials.push(t("SplineDoF.coc",p()));let m=this._cocBlurSequence();for(let x=0;x<lw.length;x++){let S=d*lw[x]+.5*d,w=c*lw[x]+.5*c,T=Jt(m[x].from.texture),C=At(()=>{let M=ui();return T.sample(M.add(st(-S,w))).add(T.sample(M.add(st(S,w)))).add(T.sample(M.add(st(S,-w)))).add(T.sample(M.add(st(-S,-w)))).mul(.25)});this._materials.push(t(`SplineDoF.cocBlur${x}`,C()))}let f=Jt(this._rtCoC.texture),g=At(()=>{let x=ui().toVar(),S=Te(f.sample(x).g.mul(r),0,1);return o.sample(h(x)).mul(S)});this._materials.push(t("SplineDoF.mask",g()));let y=function(){let x=new Float32Array(128),S=0;for(let w=0;w<80;++w){if(w%5==0)continue;let T=2.39996323*w,C=Math.sqrt(w)/Math.sqrt(80);x[S++]=C*Math.cos(T),x[S++]=C*Math.sin(T)}return x}(),v=(x,S,w,T,C)=>{let M=At(()=>{let A=ui().toVar(),P=w.sample(A).toVar(),O=(T?P.r:P.g).mul(r).toVar(),D=at(0).toVar();return vt(O.equal(0),()=>{D.assign(S.sample(C(A)))}).Else(()=>{let N=T?Kt(O,P.g.mul(r)):O,z=st(d,c).mul(N).toVar(),k=at(0).toVar();for(let B=0;B<y.length;B+=2)k.addAssign(S.sample(C(A.add(z.mul(st(y[B],y[B+1]))))));D.assign(k.div(64))}),D});return t(x,M())},b=Jt(this._rtCoCBlurred.texture),_=Jt(this._rtIntermediate.texture);this._materials.push(v("SplineDoF.farBase",Jt(this._rtMasked.texture),f,!1,u),v("SplineDoF.farFill",_,f,!1,u),v("SplineDoF.nearBase",o,b,!0,h),v("SplineDoF.nearFill",_,b,!0,u))}_cocBlurSequence(){let t=[],e=this._rtCoC;for(let i=0;i<lw.length-1;i++){let r=1&i?this._rtBlurB:this._rtBlurA;t.push({from:e,to:r}),e=r}return t.push({from:e,to:this._rtCoCBlurred}),t}renderDoF(t){t.getDrawingBufferSize(hE);let e=Math.max(1,Math.round(hE.x)),i=Math.max(1,Math.round(hE.y));if(e!==this._width||i!==this._height){this._width=e,this._height=i,this._halfWidth=Math.max(1,Math.round(.5*e)),this._halfHeight=Math.max(1,Math.round(.5*i)),this._disposeTargets();let o=this._halfWidth,l=this._halfHeight;this._rtCoC=this._makeRT(e,i,"DoF.CoC","coc"),this._rtMasked=this._makeRT(e,i,"DoF.Masked.Far","color"),this._rtCoCBlurred=this._makeRT(o,l,"DoF.CoC.Blurred","coc"),this._rtBlurA=this._makeRT(o,l,"DoF.Blur.Target.A","blur"),this._rtBlurB=this._makeRT(o,l,"DoF.Blur.Target.B","blur"),this._rtIntermediate=this._makeRT(o,l,"DoF.Intermediate","color"),this._rtNear=this._makeRT(o,l,"DoF.Bokeh.Near","color"),this._rtFar=this._makeRT(o,l,"DoF.Bokeh.Far","color"),this._nearTexNode.value=this._rtNear.texture,this._farTexNode.value=this._rtFar.texture,this._cocBlurredTexNode.value=this._rtCoCBlurred.texture,this._buildMaterials()}let r=this._cocBlurSequence(),s=[this._rtCoC,...r.map(o=>o.to),this._rtMasked,this._rtIntermediate,this._rtFar,this._rtIntermediate,this._rtNear],n=t.getRenderTarget(),a=t.getMRT();t.setMRT(null);for(let o=0;o<s.length;o++)t.setRenderTarget(s[o]),lE.material=this._materials[o],lE.name=this._materials[o].name,lE.render(t);t.setRenderTarget(n),t.setMRT(a)}setup(){let t=this._nearTexNode,e=this._farTexNode,i=ti(this._cocBlurredTexNode.r.mul(this._params.bokehScale),1),r=this._inputColor.mul(e.a.oneMinus()).add(e);return $t(r,t,i)}_disposeTargets(){this._rtCoC.dispose(),this._rtMasked.dispose(),this._rtCoCBlurred.dispose(),this._rtBlurA.dispose(),this._rtBlurB.dispose(),this._rtIntermediate.dispose(),this._rtNear.dispose(),this._rtFar.dispose()}dispose(){for(let t of this._materials)t.dispose();this._materials=[],this._disposeTargets()}}}),YEt={},KEt=U(()=>{rq(),XEt(),A1t("depthOfField",$Et)}),ZEt=eb((t,e)=>{e.exports=function(i,r){for(var s=i.split("."),n=r.split("."),a=0;a<3;a++){var o=Number(s[a]),l=Number(n[a]);if(o>l)return 1;if(l>o)return-1;if(!isNaN(o)&&isNaN(l))return 1;if(isNaN(o)&&!isNaN(l))return-1}return 0}}),Yvt={};pT(Yvt,{Perfs:()=>Kvt});var Kvt,Zvt,QEt=U(()=>{Kvt=class{constructor({x:t=10,y:e=10}){this._startTime=0;let i=document.getElementById("spe-perfs");i?this.element=i:(this.element=document.createElement("div"),document.body.appendChild(this.element),this.element.style.position="absolute",this.element.style.zIndex="10000",this.element.style.fontFamily="monospace",this.element.style.background="black",this.element.style.color="white",this.element.style.padding="10px",this.element.style.opacity="0.5",this.element.style.fontSize="11px",this.element.setAttribute("id","spe-perfs")),this.element.style.left=`${t}px`,this.element.style.top=`${e}px`}dispose(){this.element.parentElement?.removeChild(this.element)}start(){this._startTime=performance.now()}end(){let t=performance.now()-this._startTime;this.element.innerHTML=t.toFixed(3)+" ms"}}}),JEt=U(()=>{Zvt=[[.478712,.875764],[-.337956,-.793959],[-.955259,-.028164],[.864527,.325689],[.209342,-.395657],[-.106779,.672585],[.156213,.235113],[-.413644,-.082856],[-.415667,.323909],[.141896,-.93998],[.954932,-.182516],[-.766184,.410799],[-.434912,-.458845],[.415242,-.078724],[.728335,-.491777],[-.058086,-.066401],[.20299,.686837],[-.808362,-.556402],[.507386,-.640839],[-.723494,-.22924],[.48974,.317826],[-.622663,.765301],[-.01064,.929347],[.663146,.647618],[-.096674,-.413835],[.525945,-.321063],[-.122533,.366019],[.195235,-.687983],[-.563203,.098748],[.418563,.561335],[-.378595,.800367],[.826922,.001024],[-.085372,-.766651],[-.92192,.183673],[-.590008,-.721799],[.167751,-.164393],[.032961,-.56253],[.6329,-.107059],[-.46408,.569669],[-.173676,-.958758],[-.242648,-.234303],[-.275362,.157163],[.382295,-.795131],[.562955,.115562],[.190586,.470121],[.770764,-.297576],[.237281,.93105],[-.666642,-.455871],[-.905649,-.298379],[.33952,.157829],[.701438,-.7041],[-.062758,.160346],[-.220674,.957141],[.642692,.432706],[-.77339,-.015272],[-.671467,.24688],[.158051,.062859],[.806009,.527232],[-.05762,-.247071],[.333436,-.51671],[-.550658,-.315773],[-.652078,.589846],[.008818,.530556],[-.210004,.519896]]});function tht(t){let{fog:e,backupFog:i}=t,r=[t,t.scene!==t?t.scene:void 0];if(e!=null&&i!==void 0){for(let s of r)s&&(s.fogNode=Qvt);z9.value.copy(i.color),L9.value=i.near,F9.value=i.far,C2.value=Jn.getModeIndex({mode:t.fogMode}),U9.value.set(t.fogDensity??Jn.getDensity({}),t.fogHeightFalloff??Jn.getHeightFalloff({}),t.fogHeightBase??Jn.getHeightBase({}))}else if(e===null)for(let s of r)s?.fogNode&&(s.fogNode=null)}var z9,L9,F9,C2,U9,j9,eht,Qvt,RL,iht,DL,uE,jf,rht,Jvt,tbt=U(()=>{ot(),De(),je(),z9=mt(new se(1,1,1)).setGroup(V1),L9=mt(.1).setGroup(V1),F9=mt(2e3).setGroup(V1),C2=mt(0).setGroup(V1),U9=mt(new E(.005,.01,0)).setGroup(V1),j9=At(([t,e,i,r])=>{let s=r.x,n=r.y,a=i.y.sub(r.z),o=s.mul(n.mul(a).negate().clamp(-60,60).exp()),l=n.mul(t.y).clamp(-60,60).toVar(),h=pi(l.greaterThanEqual(0),I(1),I(-1)).mul(l.abs().max(1e-4));return o.mul(e).mul(I(1).sub(h.negate().exp())).div(h).max(0).negate().exp().oneMinus()}),eht=At(()=>{let t=Wo.sub(Oc).toVar(),e=t.length().max(1e-6);return j9(t,e,Oc,U9)}),Qvt=(()=>{let t=I(1).sub(Si(.5,C2)).add(Si(1.5,C2)),e=Si(.5,C2),i=I(1).sub(I(1).sub(Ovt(L9,F9).mul(t)).mul(I(1).sub(eht().mul(e))));return svt(z9,i)})()}),tPt=U(()=>{ot(),cr(),je(),JEt(),tbt(),RL=t=>t,iht=t=>t,DL=t=>t,uE=(t,e,i)=>de(t.add(.5).mul(e)).add(.5).div(i),jf=new Pr,rht=new se,Jvt=class{constructor(){this._gBuffer=null,this._aoBuffer=null,this._hbaoMaterial=null,this._resolveMaterial=null,this._boundBlueNoise=null,this._frameIndex=0,this._projectionMatrixInverse=mt(new bt),this._isOrtho=mt(0),this._resolution=mt(new Y(1,1)),this._fullResolution=mt(new Y(1,1)),this._radiusOfInfluence=mt(128),this._radiusInScreenSpace=mt(1),this._exponent=mt(1),this._aoColor=mt(new se(0,0,0)),this._bias=mt(.5),this._frame=mt(0),this._fogEnabled=mt(0),this._fogNear=mt(1),this._fogFar=mt(1e3),this._fogMode=mt(0),this._fogHeightParams=mt(new E(.005,.01,0)),this._cameraWorldMatrix=mt(new bt);let t=new Pe;t.name="SplineHBAO.gbuffer",t.side=Xs,t.fragmentNode=at(Ra.mul(VD),1),t.lights=!1,t.blending=Wi,t.needsUpdate=!0,this._normalMaterial=t}_ensureTarget(t,e,i,r){return t&&t.width===e&&t.height===i?{target:t,changed:!1}:(t?.dispose(),{target:r(),changed:!0})}_buildHBAOMaterial(t,e){let i=Jt(this._gBuffer.depthTexture),r=Jt(this._gBuffer.texture),s=Jt(e),n=this._projectionMatrixInverse,a=this._isOrtho,o=this._resolution,l=this._fullResolution,h=this._radiusOfInfluence,u=this._radiusInScreenSpace,d=this._exponent,c=this._aoColor,p=this._bias,m=this._frame,f=this._fogEnabled,g=this._fogNear,y=this._fogFar,v=this._fogMode,b=this._fogHeightParams,_=this._cameraWorldMatrix,x=t.reversedDepthBuffer===!0,S=A=>i.sample(A),w=(A,P)=>uq(A,P,n),T=A=>w(A,S(A)),C=At(()=>{let A=ui().toVar(),P=o,O=l,D=de(A.mul(P)).toVar(),N=O.div(P).toVar(),z=uE(D,N,O).toVar(),k=S(z).toVar(),B=w(z,k).toVar(),V=be(r.sample(z).xyz).toVar(),q=Kt(u.div($t(B.z.negate(),I(1),a)),I(5)).toVar(),W=Yn(ct(Qa.xy.x).bitAnd(ct(127)),ct(Qa.xy.y).bitAnd(ct(127))),H=s.load(W).xyz.x,rt=Di(H.add(I(.61803398875).mul(m))).mul(6.283),it=Xa(rt).toVar(),ft=Bn(rt).toVar(),dt=q.div(5).toVar(),K=I(0).toVar();for(let Ut=0;Ut<4;Ut++){let Yt=dt.add(1).toVar();for(let Zt=0;Zt<4;Zt++){let[$,ie]=Zvt[4*Ut+Zt],Ce=st(it.mul($).sub(ft.mul(ie)),ft.mul($).add(it.mul(ie))),Be=iht(D.add(Nvt(Ce.mul(Yt)))).toVar(),te=DL(T(uE(Be,N,O))).toVar();Yt.addAssign(dt);let ni=DL(te.sub(B)).toVar(),bi=RL(ni.dot(ni)).toVar(),Zs=xl(bi),Hi=RL(V.dot(ni)).div(Kt(Zs,I(1e-4))),ai=bi.mul(I(-1).div(h.mul(h))).add(1);K.addAssign(Te(Hi.sub(p),0,1).mul(Te(ai,0,1)))}}let lt=I(1).div(I(1).sub(p));K.mulAssign(lt.div(16));let _t=Te(I(1).sub(K.mul(2)),0,1),xt=Lo(_t,d).toVar(),wt=x?k.lessThanEqual(0):k.greaterThanEqual(1);xt.assign(wt.select(I(1),xt));let gt=j($t(c,j(1),xt)).toVar(),Dt=Ji(g,y,B.z.negate()),Lt=_.mul(at(B,1)).xyz,It=_.mul(at(0,0,0,1)).xyz,kt=Lt.sub(It).toVar(),Nt=j9(kt,kt.length().max(1e-6),It,b),Gt=v,qt=I(1).sub(Si(.5,Gt)).add(Si(1.5,Gt)),Ct=Si(.5,Gt),ne=I(1).sub(I(1).sub(Dt.mul(qt)).mul(I(1).sub(Nt.mul(Ct)))).mul(f);return gt.assign($t(gt,j(1),ne)),at(gt,1)}),M=new Pe;return M.name="SplineHBAO.hbao",M.colorNode=C(),M.depthTest=!1,M.depthWrite=!1,M.blending=Wi,M.needsUpdate=!0,M}_buildResolveMaterial(){let t=Jt(this._aoBuffer.texture),e=Jt(this._gBuffer.depthTexture),i=this._resolution,r=this._fullResolution,s=At(()=>{let a=ui().toVar(),o=i,l=r,h=st(I(1).div(o.x),I(1).div(o.y)).toVar(),u=a.sub(h.mul(.5)).toVar(),d=u.add(st(h.x,0)).toVar(),c=u.add(st(0,h.y)).toVar(),p=u.add(h).toVar(),m=e.sample(a).toVar(),f=l.div(o).toVar(),g=T=>e.sample(uE(T,f,l)),y=de(u.mul(o)).toVar(),v=m.sub(g(y)).abs().toVar(),b=m.sub(g(y.add(st(1,0)))).abs().toVar(),_=m.sub(g(y.add(st(0,1)))).abs().toVar(),x=m.sub(g(y.add(st(1,1)))).abs().toVar(),S=v.min(b).min(_).min(x).toVar(),w=p.toVar();return w.assign(S.equal(_).select(c,w)),w.assign(S.equal(b).select(d,w)),w.assign(S.equal(v).select(u,w)),t.sample(w)}),n=new Pe;return n.name="SplineHBAO.resolve",n.colorNode=s(),n.depthTest=!1,n.depthWrite=!1,n.blending=Wi,n.needsUpdate=!0,n}render(t,e,i,r,s,n){let a=n.width,o=n.height,l=r.aoFullRes!==!0,h=l?.5:1,u=Math.max(1,Math.round(a*h)),d=Math.max(1,Math.round(o*h)),c=this._hbaoMaterial===null,p=this._ensureTarget(this._gBuffer,a,o,()=>new ii(a,o,{type:si,depthTexture:new Ha(a,o),minFilter:pe,magFilter:pe}));if(this._gBuffer=p.target,c=c||p.changed,l){let M=this._ensureTarget(this._aoBuffer,u,d,()=>new ii(u,d,{minFilter:pe,magFilter:pe,depthBuffer:!1}));this._aoBuffer=M.target,c=c||M.changed}c=c||this._boundBlueNoise!==s;let m=l;(c||m&&this._resolveMaterial===null)&&(this._hbaoMaterial?.dispose(),this._resolveMaterial?.dispose(),this._hbaoMaterial=this._buildHBAOMaterial(t,s),this._resolveMaterial=m?this._buildResolveMaterial():null,this._boundBlueNoise=s);let f=i,g=f.projectionMatrix.elements,y=g[11]===0;if(this._projectionMatrixInverse.value.copy(f.projectionMatrixInverse),this._isOrtho.value=y?1:0,this._resolution.value.set(u,d),this._fullResolution.value.set(a,o),this._radiusOfInfluence.value=r.radius,y){let M=2/g[5];this._radiusInScreenSpace.value=r.radius*(d/M*.5)}else{let M=d*g[5]/2;this._radiusInScreenSpace.value=.5*r.radius*M}this._bias.value=r.bias,this._aoColor.value.setRGB(r.aoColor.r,r.aoColor.g,r.aoColor.b),this._fogEnabled.value=r.fogEnabled?1:0,this._fogNear.value=r.fogNear,this._fogFar.value=r.fogFar,this._fogMode.value=r.fogMode,this._fogHeightParams.value.set(r.fogDensity,r.fogHeightFalloff,r.fogHeightBase),this._cameraWorldMatrix.value.copy(i.matrixWorld),this._frame.value=this._frameIndex,this._frameIndex++;let v=t,b=e,_=b.overrideMaterial,x=v.getRenderTarget(),S=v.getMRT(),w=v.getClearColor(rht),T=v.getClearAlpha(),C=i.layers.mask;i.layers.set(5),b.overrideMaterial=this._normalMaterial,v.setMRT(null),v.setClearColor(0,0),v.setRenderTarget(this._gBuffer),v.render(e,i),b.overrideMaterial=_,i.layers.mask=C,jf.material=this._hbaoMaterial,jf.name="SplineHBAO.hbao",v.setRenderTarget(l?this._aoBuffer:n),jf.render(t),l&&(jf.material=this._resolveMaterial,jf.name="SplineHBAO.resolve",v.setRenderTarget(n),jf.render(t)),v.setRenderTarget(x),v.setMRT(S),v.setClearColor(w,T)}dispose(){this._gBuffer?.dispose(),this._gBuffer=null,this._aoBuffer?.dispose(),this._aoBuffer=null,this._normalMaterial.dispose(),this._hbaoMaterial?.dispose(),this._hbaoMaterial=null,this._resolveMaterial?.dispose(),this._resolveMaterial=null,this._boundBlueNoise=null}}});function Cv(t){let e=G9.get(t);return e||(e={texture:null,version:0,rotation:new zi,quality:"full"},G9.set(t,e)),e}function GR(t){let e=Cv(t.environmentScope),i=e.texture,r=t.lights&&t.category==="physical"&&i!==null&&(e.quality==="full"||t.envReflectiveInLow?.()!==!1),s=t.envNode instanceof Jv;r?(!s||t.envNode.sourceTexture!==i)&&(t.envNode=new Jv(i),t.needsUpdate=!0):s&&(t.envNode=null,t.needsUpdate=!0)}function OL(t){for(let e of oT){let i=e.deref();i===void 0?oT.delete(e):i.environmentScope===t&&GR(i)}}function sht(t,e){let i=null;return{getUV:()=>{if(i===null){let r=E2(Qv.negate().reflect(e));r=Dvt(t).mix(E2(r),e),r=E2(r).normalize(),i=E2(r).transformDirection(w5)}return i},getTextureLevel:()=>t}}var E2,G9,ebt,vq,oT,P2,IL,Jv,M5,ibt,bq=U(()=>{ot(),cr(),je(),E2=t=>t,G9=new WeakMap,ebt={},vq=0,oT=new Set,P2=new WeakMap,IL=new WeakMap,Jv=class extends b9{constructor(t){super(null),this.sourceTexture=t}static get type(){return"SplineEnvironmentNode"}setup(t){let e=function(a){let o=IL.get(a);return o===void 0&&(o=Pvt(a),IL.set(a,o)),o}(this.sourceTexture),i=t.context,r=e.context(sht(gq,Ra)).mul(LR);i.radiance.addAssign(new bS(r));let s=e.context({getUV:()=>sT,getTextureLevel:()=>I(1)}).mul(Math.PI).mul(LR);i.iblIrradiance.addAssign(new bS(s));let n=i.lightingModel?.clearcoatRadiance;if(n){let a=e.context(sht(hq,J1t)).mul(LR);n.addAssign(new bS(a))}return null}},M5=class extends iD{},ibt=class extends E9{static get type(){return"SplineSkyHemisphereLightNode"}setup(t){return t.material?.envNode instanceof Jv?null:super.setup(t)}}});function _q(){return Gvt(Hv("randomColor","vec3")).setInterpolation(Nmt.FLAT,Bmt.EITHER)}var xq=U(()=>{ot(),je()}),ePt=U(()=>{n1t()});function nht(t){return t?.depthPrepass===!0}var W9,hw,NL,aht,oht,dE,lht,q9,H9,vg,$9,wq,Gf,BL,Sq,rbt=U(()=>{W9=!0;try{W9=new URLSearchParams(window.location.search).get("dbgdepthprepass")!=="0"}catch{}}),sbt=U(()=>{je(),pn(),hw=t=>t,NL=t=>t,aht=t=>t,oht=t=>t,dE=.25,lht=256/(2*Math.PI),q9=.075,H9=(t,e,i,r,s)=>{let n=j(0).toVar();return vt(r.lessThan(.5),()=>{n.assign(t.sample(e).level(s).rgb)}).Else(()=>{let a=j(0).toVar(),o=I(0).toVar();for(let l=0;l<12;l++){let h=Math.sqrt((l+.5)/12),u=2.399963229728653*l,d=h*Math.cos(u),c=h*Math.sin(u),p=Math.exp(-2.5*h*h),m=aht(oht(t.sample(st(hw(e.x).add(i.mul(d)),hw(e.y).add(i.mul(c)))).level(s)).rgb);a.addAssign(m.mul(p)),o.addAssign(I(p))}n.assign(a.div(o))}),n},vg=(t,e,i,r)=>{let s=at(e.mul(2).sub(1),I(1).sub(i).mul(2).sub(1),r,1),n=t.mul(s).toVar();return n.xyz.div(n.w)},$9=(t,e,i,r)=>{let s=Vt.reflectionEnvEnabled,n=Vt.reflectionMissColor,a=i.greaterThan(.05),o=r??pi(a,I(.6),I(1)),l=wc(e.z,e.x).div(2*Math.PI).add(.5),h=lq(Te(e.y,I(-1),I(1))).div(Math.PI).add(.5),u=ti(Yv(i.mul(o).mul(dE*lht).add(1)),I(8)),d=t.sample(st(l,h)).level(u).rgb;return pi(s.greaterThan(.5),d,n)},wq=t=>{let{dials:e,surface:i,camera:r,resources:s}=t,{blur:n,thickness:a,steps:o,stepSize:l,tracingMode:h}=e,{colorMap:u,depthPyramid:d,depthPyramidNode:c,envMap:p}=s,m=t.usePlanar,f=Vt.reflectionDepthSize,g=Vt.reflectionDepthLevels,y=(W,H)=>d.load(W).level(H).r.add(1e-6),v=Vt.orthographicUniform.greaterThan(.5),b=pi(v,j(0,0,-1),be(i.originView)).toVar(),_=i.normalV.toVar(),x=nT(b,_).toVar(),S=Te(n.mul(.1),I(0),I(1)).toVar(),w=Vt.resolution,T=S.greaterThan(.05),C=t.singleRay?I(1):pi(T,I(.6),I(1)),M=(W,H,rt,it)=>{let ft=be(yq(W,r.worldMatrix)).toVar(),dt=I(1).sub(Ji(I(.85),I(.99),W.z)).toVar(),K=i.originView.toVar(),lt=K.z.negate().max(r.near).toVar(),_t=I(lt.mul(10)).toVar();vt(W.z.greaterThan(1e-5),()=>{let Yt=r.near.negate().sub(K.z).div(W.z);_t.assign(ti(_t,Yt.mul(.95).max(1e-4)))});let xt,wt=K.add(W.mul(_t)).toVar(),gt=j(i.screenUv,i.fragWindowZ).toVar(),Dt=(Yt=>{let Zt=r.projectionMatrix.mul(at(Yt,1)).toVar(),$=Zt.xyz.div(Zt.w);return j($.x.mul(.5).add(.5),$.y.mul(-.5).add(.5),$.z)})(wt).toVar(),Lt=S.mul(w.y).mul(q9).toVar();if(it){let Yt=Lt.mul(f.y.div(w.y)).toVar(),Zt=ti(I(.8),I(12).div(Yt.max(.001))).toVar();it.assign(Yt.mul(Zt)),xt=I(1).sub(Zt.mul(Zt)).max(0).sqrt().toVar()}let It=Dt.sub(gt).toVar(),kt=Kt(It.xy.length(),I(1e-5)).toVar(),Nt=I(0).toVar(),Gt=j(0).toVar(),qt=()=>{let Yt=g.sub(1).toVar(),Zt=ct(1).toVar(),$=ct(0).toVar(),ie=(Fi,Ti)=>ti(Fi,Ti),Ce=It,Be=Ce.div(Ce.z).toVar(),te=j(gt).toVar(),ni=st(pi(Ce.x.greaterThanEqual(0),I(1),I(-1)),pi(Ce.y.greaterThanEqual(0),I(1),I(-1))).toVar(),bi=ni.mul(1e-5).toVar();ni.assign(Te(ni,st(0),st(1)));let Zs=Fi=>st(Fvt(c,Fi)),Hi=(Fi,Ti)=>Fi.mul(Ti).floor(),ai=(Fi,Ti,Qs)=>{let ms=st(1).div(Qs),vr=Ti.div(Qs).add(ms.mul(ni)).sub(Fi.xy).div(Ce.xy).toVar(),ir=Fi.add(Ce.mul(ti(vr.x,vr.y))).toVar();return ir.xy.addAssign(pi(vr.x.lessThan(vr.y),st(bi.x,0),st(0,bi.y))),ir},Fr=Zs(Zt),ts=Hi(te.xy,Fr);te.assign(ai(te,ts,Fr)),Qi(256,()=>{vt(Zt.lessThan(ct(0)).or($.greaterThanEqual(H)),()=>{ea()});let Fi=Zs(Zt).toVar(),Ti=Hi(te.xy,Fi).toVar(),Qs=y(Yn(ct(Ti.x),ct(Ti.y)),Zt).toVar(),ms=j(te).toVar();vt(Ce.z.greaterThan(0),()=>{let vr=Qs.sub(te.z).toVar();vt(vr.greaterThan(0),()=>{ms.assign(te.add(Be.mul(vr)))});let ir=Hi(ms.xy,Fi).toVar();vt(((Br,Zh)=>ct(Br.x).notEqual(ct(Zh.x)).or(ct(Br.y).notEqual(ct(Zh.y))))(Ti,ir),()=>{ms.assign(ai(te,Ti,Fi)),Zt.assign(ie(Yt,Zt.add(ct(2))))}).Else(()=>{vt(Zt.equal(ct(1)).and(vr.abs().greaterThan(a)),()=>{ms.assign(ai(te,Ti,Fi)),Zt.assign(ct(2))})})}).Else(()=>{vt(te.z.lessThan(Qs),()=>{ms.assign(ai(te,Ti,Fi)),Zt.assign(ie(Yt,Zt.add(ct(2))))})}),te.assign(ms),Zt.subAssign(ct(1)),$.addAssign(ct(1))});let Ur=te.x.greaterThan(0).and(te.x.lessThan(1)).and(te.y.greaterThan(0)).and(te.y.lessThan(1)).and(te.z.greaterThan(0)).and(te.z.lessThan(1));vt(Zt.lessThan(ct(0)).and($.lessThan(H)).and(Ur),()=>{Nt.assign(1),Gt.assign(te);let Fi=te.xy.sub(gt.xy).length().div(kt).clamp(0,1),Ti=Fi.sub(I(2).div(f.y).div(kt)).max(0),Qs=j(gt.add(It.mul(Ti))).toVar(),ms=j(gt.add(It.mul(Fi))).toVar(),vr=j(ms).toVar();for(let ir=0;ir<4;ir++){vr.assign($t(Qs,ms,.5));let Br=hw(y(Yn(NL(vr.xy).mul(f)),ct(0)));vt(vr.z.sub(Br).greaterThan(0),()=>{ms.assign(vr)}).Else(()=>{Qs.assign(vr)})}Gt.assign(vr)})},Ct=()=>{let Yt=Kt(l,I(1e-4)),Zt=I(Yt).toVar(),$=j(gt).toVar(),ie=j(gt).toVar(),Ce=I(-1).toVar();Qi(256,({i:Be})=>{vt(Be.greaterThanEqual(H),()=>{ea()});let te=I(Be).mul(Zt).div(kt).toVar();vt(te.greaterThan(1),()=>{ea()}),ie.assign(It.mul(te).add(gt));let ni=ie.x.lessThan(0).or(ie.x.greaterThan(1)).or(ie.y.lessThan(0)).or(ie.y.greaterThan(1)).or(ie.z.lessThan(0)).or(ie.z.greaterThan(1));vt(ni,()=>{ea()});let bi=y(Yn(ie.xy.mul(f)),ct(0)).toVar(),Zs=ie.z.sub(bi).toVar();vt(Ce.lessThanEqual(0).and(Zs.greaterThan(0)),()=>{let Hi=j($).toVar(),ai=j(ie).toVar(),Fr=j(ie).toVar(),ts=I(Zs).toVar();for(let Ur=0;Ur<4;Ur++){Fr.assign($t(Hi,ai,.5));let Fi=hw(y(Yn(NL(Fr.xy).mul(f)),ct(0)));ts.assign(Fr.z.sub(Fi)),vt(ts.greaterThan(0),()=>{ai.assign(Fr)}).Else(()=>{Hi.assign(Fr)})}vt(ts.abs().lessThan(a),()=>{Nt.assign(1),Gt.assign(Fr),ea()})}),Ce.assign(Zs),$.assign(ie),Zt.addAssign(Yt.div(2))})};vt(dt.greaterThan(0).and(m.not()),()=>{typeof h=="number"?h===1?qt():Ct():vt(h.greaterThan(.5),()=>{qt()}).Else(()=>{Ct()})});let ne=$9(p,ft,S,xt).toVar(),Ut=j(ne).toVar();return vt(Nt.greaterThan(.5),()=>{let Yt=Gt.xy.sub(gt.xy).length().div(kt).clamp(0,1).toVar(),Zt=K.z.negate().max(1e-4).toVar(),$=wt.z.negate().max(1e-4).toVar(),ie=$t(I(1).div(Zt),I(1).div($),Yt).toVar(),Ce=$t(K.div(Zt),wt.div($),Yt).div(ie),Be=$t(K,wt,Yt),te=pi(v,Be,Ce).toVar(),ni=te.sub(K).length().toVar(),bi=r.projectionMatrix.element(1).y.mul(w.y).mul(.5),Zs=pi(v,I(1),te.z.abs().max(1e-4)),Hi=S.mul(C).mul(dE).mul(ni).mul(bi).div(Zs),ai=Kt(Hi,Lt).toVar(),Fr=ai.mul(f.y.div(w.y)).toVar(),ts=Fr.toVar(),Ur=ai.toVar();if(it){let St=ti(I(.8),I(12).div(Fr.max(.001))).toVar();it.assign(Fr.mul(St)),ts.assign(Fr.mul(I(1).sub(St.mul(St)).max(0).sqrt())),Ur.assign(ts.mul(w.y.div(f.y)))}let Fi=I(g.sub(1)),Ti=ti(Yv(ts.add(1)),Fi),Qs=rt?H9(u,Gt.xy,Ur.mul(.75).div(w.y),ts.mul(.75),Ti.sub(1).max(0).floor()).toVar():u.sample(Gt.xy).level(Ti).rgb.toVar(),ms=St=>Ji(I(0),I(.07),St).mul(Ji(I(0),I(.07),I(1).sub(St))),vr=ms(Gt.x).mul(ms(Gt.y)),ir=Gt.xy.mul(f),Br=y(Yn(ir),ct(0)),Zh=vg(r.projectionMatrixInverse,Gt.x,Gt.y,Br).toVar(),Qh=Bt(Zh.sub(K),_),Om=Ji(lt.mul(-.05),lt.mul(-.005),Qh),rr=I(1).div(f.x),sh=I(1).div(f.y),b0=y(Yn(ir.sub(st(1,0))),ct(0)),Im=y(Yn(ir.add(st(1,0))),ct(0)),Nm=y(Yn(ir.sub(st(0,1))),ct(0)),nh=y(Yn(ir.add(st(0,1))),ct(0)),yi=vg(r.projectionMatrixInverse,Gt.x.sub(rr),Gt.y,b0),Bm=vg(r.projectionMatrixInverse,Gt.x.add(rr),Gt.y,Im),km=vg(r.projectionMatrixInverse,Gt.x,Gt.y.sub(sh),Nm),_0=vg(r.projectionMatrixInverse,Gt.x,Gt.y.add(sh),nh),Vn=be(Kr(Bm.sub(yi),_0.sub(km))).toVar(),kc=pi(Vn.z.lessThan(0),Vn.negate(),Vn),kr=Ji(I(.02),I(.12),Bt(kc,W).negate()),X=dt.mul(vr).mul(Om).mul(kr);Ut.assign($t(ne,Qs,X))}),Ut};if(t.singleRay)return M(x,o,!0,t.singleRay.footprintOut).toVar();let A=t.noisePixel,P=Di(I(52.9829189).mul(Di(A.x.mul(.06711056).add(A.y.mul(.00583715))))).mul(2*Math.PI).toVar(),O=pi(x.y.abs().greaterThan(.99),j(1,0,0),j(0,1,0)),D=be(Kr(O,x)).toVar(),N=Kr(x,D).toVar(),z=(W,H=4)=>{let rt=S.mul(dE*Math.sqrt((W+.5)/H)),it=P.add(2.399963229728653*W);return be(x.mul(Xa(rt)).add(D.mul(Xa(it)).add(N.mul(Bn(it))).mul(Bn(rt)))).toVar()},k=T.and(m.not()),B=pi(k,z(0),x).toVar(),V=j(0).toVar();V.addAssign(M(B,o,!0));let q=I(1).toVar();return vt(k,()=>{V.addAssign(M(z(2),o,!1)),q.assign(2),vt(S.greaterThan(.35),()=>{V.addAssign(M(z(1),o,!1)),V.addAssign(M(z(3),o,!1)),q.assign(4)})}),V.div(q).toVar()}}),nbt=U(()=>{ot(),je(),De(),pn(),Gf=new Y,(Sq=BL=class extends Pn{constructor(t){super(),this.postprocessingState=q4.defaultData,this.sceneTransitionPass={uniforms:{mixRatio:mt(0),uDPR:{value:1},uResolution:{value:new Y}}},this.sceneTransitionFromTexture=null,this.watermarkTexture=null,this.uiCanvasTexture=null,this.uiOverlayEnabled=!1,this._isUIOverlayEnabled=!1,this._helpersEnabled=!0,this._renderToScreen=!0,this._rt=null,this._effectChain=null,this._effectChainDirty=!1,this.blueNoiseTexture=new yr,this._rebuildCount=0,this._rebuildLogAt=0,this._chainUiTexture=null,this._chainWatermark=null,this._chainTransitionTexture=null,this._chainHdr=!1,this.lastOutputTarget=null,this._renderer=t}get renderToScreen(){return this._renderToScreen}set renderToScreen(t){this._renderToScreen=t}get texture(){return this._rt&&this._rt.texture}get renderTarget(){return this._rt}get depthOfFieldDepthTexture(){let t=this._effectChain;return t?.renderDoFPasses?t.sceneDepthTexture():null}get isUIOverlayEnabled(){return this._isUIOverlayEnabled}enableUIOverlay(){this._isUIOverlayEnabled=!0}disableUIOverlay(){this._isUIOverlayEnabled=!1}enableHelpers(){this._helpersEnabled=!0}disableHelpers(){this._helpersEnabled=!1}get helpersEnabled(){return this._helpersEnabled}setWatermark(t){this.watermarkTexture=t,this._effectChainDirty=!0}updateBlueNoiseTexture(t){this.blueNoiseTexture.dispose();let e=new yr(t,128,128);e.wrapS=An,e.wrapT=An,e.minFilter=Re,e.magFilter=Re,e.needsUpdate=!0,this.blueNoiseTexture=e}static _topologyJSON(t){let e=t,i={};for(let r of Object.keys(e)){let s=e[r],n=BL.UNIFORM_BACKED_FIELDS[r];if(n&&s&&typeof s=="object"){let a={...s};for(let o of n)delete a[o];i[r]=a}else i[r]=s}return JSON.stringify(i)}updatePostprocessing(t){this.postprocessingState=t;let e=BL._topologyJSON(t);this._postprocessingJSON!==e&&(this._postprocessingJSON=e,this._effectChainDirty=!0)}_needsEffectChain(){if(this._renderer.temporalAAEnabled||this.uiOverlayEnabled&&this.uiCanvasTexture||this.watermarkTexture||this.sceneTransitionFromTexture)return!0;if(this.postprocessingState.enabled!==!0)return!1;let t=this.postprocessingState;for(let e of Object.keys(t)){let i=t[e];if(i&&typeof i=="object"&&i.enabled===!0)return!0}return!1}render(){let{scene:t,camera:e}=this;if(!t||!e)return;let i=this._renderer;if(i.warmupInFlight)return;let r=!1;if(!this._renderToScreen&&i.getRenderTarget()===null){i.getDrawingBufferSize(Gf);let s=Math.max(1,Math.round(Gf.x)),n=Math.max(1,Math.round(Gf.y));this._rt===null?this._rt=new ii(s,n,{depthBuffer:!0}):(this._rt.width!==s||this._rt.height!==n)&&(this._rt.dispose(),this._rt=new ii(s,n,{depthBuffer:!0})),i.setRenderTarget(this._rt),r=!0}this.lastOutputTarget=r?this._rt:i.getRenderTarget();try{this._renderFrame(t,e)}finally{r&&i.setRenderTarget(null)}}_renderFrame(t,e){let i=this._renderer;i.renderStarted=!0,i.normalizeCameraCoordinateSystem(e);let r=this._needsEffectChain(),s=null;this._effectChainDirty?s="postprocessing/watermark":r!==(this._effectChain!==null)?s="chain presence":this._effectChain!==null&&(this._chainUiTexture!==(this.uiOverlayEnabled?this.uiCanvasTexture:null)?s="ui overlay texture":this._chainWatermark!==this.watermarkTexture?s="watermark texture":this.sceneTransitionFromTexture!==null&&this._chainTransitionTexture!==this.sceneTransitionFromTexture?s="transition texture":this._chainHdr!==i.hdrChainActive&&(s="grading pipeline"));let n=s!==null;if(n&&this._effectChain!==null){this._rebuildCount++;let a=Date.now();a-this._rebuildLogAt>1e3&&(this._rebuildLogAt=a,this._rebuildCount=0)}if(n&&(this._effectChain,this._effectChain?.dispose(),this._effectChain=null,this._effectChainDirty=!1,r&&(this._effectChain=i.createEffectChain(),He.chainBuilds++,He.lastChainBuildReason=s??"initial",this._chainUiTexture=this.uiOverlayEnabled?this.uiCanvasTexture:null,this._chainWatermark=this.watermarkTexture,this._chainTransitionTexture=this.sceneTransitionFromTexture,this._chainHdr=i.hdrChainActive)),this._effectChain){this._effectChain.syncValues(this.postprocessingState,i),this._chainTransitionTexture!==null&&this.sceneTransitionFromTexture===null&&(this.sceneTransitionPass.uniforms.mixRatio.value=1);let a=i.temporalAAEnabled?i.taaHistory:null;a&&(i.getDrawingBufferSize(Gf),a.beginJitter(e,Gf.x,Gf.y)),this._effectChain.renderTAAResolve?.(i),this._effectChain.renderBloomPasses?.(i),this._effectChain.renderDoFPasses?.(i),this._effectChain.render(),a?.endJitter()}else i.renderScenePass(t,e);this._helpersEnabled&&(this.sceneHelpers||this.sceneHelpersOnTop)&&i.renderHelperOverlay(this.sceneHelpers,this.sceneHelpersOnTop,e,this._effectChain?this._effectChain.sceneDepthTexture():null)}resize(t,e,i){this._effectChain?.resize()}setViewport(t,e,i,r){t instanceof Se?this._renderer.setViewport(t.x,t.y,t.z,t.w):this._renderer.setViewport(t,e,i,r)}setScissor(t,e,i,r){t instanceof Se?this._renderer.setScissor(t.x,t.y,t.z,t.w):this._renderer.setScissor(t,e,i,r)}setScissorTest(t){this._renderer.setScissorTest(t)}dispose(){this._effectChain?.dispose(),this._effectChain=null,this._rt?.dispose(),this._rt=null,this.blueNoiseTexture.dispose()}}).UNIFORM_BACKED_FIELDS={bloom:["intensity","opacity"],chromaticAberration:["offset","opacity"],vignette:["offset","darkness","opacity"],noise:["opacity"],hueSaturation:["hue","saturation","opacity"],brightnessContrast:["brightness","contrast","opacity"],depthOfField:["focusDistance","focalLength","bokehScale","opacity"],pixelation:["granularity","opacity"]}});function hht(t,e,i){Ev.push({t:Math.round(performance.now()),frame:A5(),kind:t,label:e||"(unlabeled)",size:i,stack:(new Error().stack??"").split(`
|
|
2014
2014
|
`).slice(2,9).join(`
|
|
2015
|
-
`)}),Ev.length>abt&&Ev.shift()}var X9,abt,Ev,Y9,A5,K9,Z9,iPt=U(()=>{X9=(()=>{try{return new URLSearchParams(window.location.search).get("dbgdestroys")==="1"}catch{return!1}})(),abt=32,Ev=[],Y9=6,A5=()=>-1,K9=!1,Z9=null}),rPt=U(()=>{});function uht(t,e,i,r=Tq){if(e===void 0||!(i>0))return!1;let{image:s,width:n,height:a}=e;if(s==null||n===void 0||a===void 0||n<=i&&a<=i||!function(d){return!(d.isRenderTargetTexture||d.isDepthTexture||d.isFramebufferTexture||d.isStorageTexture||d.isExternalTexture||d.isHTMLTexture||d.isDataTexture||d.isCompressedTexture||d.isCompressedArrayTexture||d.isCubeTexture||d.isArrayTexture||d.isDataArrayTexture||d.isData3DTexture||d.is3DTexture||d.mipmaps!==void 0&&d.mipmaps.length>0)}(t))return!1;let o=i/Math.max(n,a),l=Math.max(1,Math.min(i,Math.floor(n*o))),h=Math.max(1,Math.min(i,Math.floor(a*o))),u=null;try{u=r(s,l,h)}catch{u=null}return u!==null&&(e.image=u,e.width=l,e.height=h,e.needsMipmaps===!0&&(e.levels=Math.floor(Math.log2(Math.max(l,h)))+1),!0)}var Tq,sPt=U(()=>{Tq=(t,e,i)=>{let r;if(typeof OffscreenCanvas<"u")r=new OffscreenCanvas(e,i);else{if(!(typeof document<"u"))return null;r=document.createElement("canvas"),r.width=e,r.height=i}let s=r.getContext("2d");return s?(s.imageSmoothingEnabled=!0,s.imageSmoothingQuality="high",s.drawImage(t,0,0,e,i),r):null}});function Q9(t,e){let i=new ii(t,e,{depthBuffer:!1,type:Ye,format:Bo});return i.texture.generateMipmaps=!1,i.texture.minFilter=Re,i.texture.magFilter=Re,i}function J9(){return Kg===null&&((Kg=Q9(Tc*C5,Tc)).texture.name="SplinePCSSPyramidAtlas"),Kg.texture}function dht(t,e,i,r,s,n){let a=new Pe,o=Jt(e),l=At(()=>{let h=Qa,u=n!==0?R2(h.x).sub(n):R2(h.x),d=ct(u).mul(i).toVar(),c=ct(h.y).mul(i).toVar(),p=I(1e9).toVar(),m=I(-1e9).toVar();return Qi(e7("ly",i),e7("lx",i),f=>{let{lx:g,ly:y}=f,v=t7(i7(d.add(g),ct(0),ct(r))),b=t7(i7(c.add(y),ct(0),ct(r))),_=o.load(Yn(v,b));p.assign(ti(p,R2(_.x))),m.assign(Kt(m,R2(s?_.y:_.x)))}),at(p,m,0,1)})();return a.fragmentNode=l,a.name=t,a.lights=!1,a.blending=Wi,a.depthTest=!1,a.depthWrite=!1,a.needsUpdate=!0,a}function cht(t){let e=t;if(!e.__spePcssPyramid){e.__spePcssPyramid={fresh:!1,slot:-1,passKey:"",mid:null,small:null,toMid:null,toSmall:null};for(let i of Pv)i.deref()===void 0&&Pv.delete(i);Pv.add(new WeakRef(e.__spePcssPyramid))}return e.__spePcssPyramid}function pht(t){return t.__spePcssPyramid?.fresh===!0}function nPt(t){return t.__spePcssPyramid?.slot??-1}var Tc,C5,L1,R2,t7,e7,i7,Kg,Pv,WR,qR,r7,obt=U(()=>{ot(),cr(),je(),pn(),Tc=8,C5=8,L1=64,R2=t=>t,t7=t=>t,e7=(t,e)=>({start:ct(0),end:ct(e),type:"int",condition:"<",name:t}),i7=Te,Kg=null,Pv=new Set,WR=new Array(C5).fill(null),qR=!1,r7=new E});function Rv(t){let e=t;return e.__spePcssKnobs||(e.__spePcssKnobs={mapSize:mt(2048),radius:mt(1),penumbraSize:mt(.5),depthEps:mt(1e-4),penumbraFrameScale:mt(1),penumbraFrameOffset:mt(0),pyramidEnabled:mt(0),pyramidSlot:mt(0),maskChannel:mt(new Se(0,0,0,0)),planeNormalMat:mt(new Ms().set(0,0,0,0,0,0,0,0,0))}),e.__spePcssKnobs}function lbt(t,e){Rv(t).maskChannel.value.set(e===0?1:0,e===1?1:0,e===2?1:0,e===3?1:0)}function mht(t,e,i){let r=t,s=Rv(t);s.mapSize.value=r.mapSize?.x??2048,s.radius.value=r.radius??1,s.penumbraSize.value=e??r.penumbraSize??.5,r.camera?.isOrthographicCamera&&r.matrix?s.planeNormalMat.value.getNormalMatrix(r.matrix):s.planeNormalMat.value.set(0,0,0,0,0,0,0,0,0);let n=typeof r.camera?.far=="number"&&typeof r.camera?.near=="number"?r.camera.far-r.camera.near:0;s.depthEps.value=n>.001?pbt/n:1e-4;let a=t.__speRangeEnvelope,o=a?a.far-a.near:0;a&&o>.001&&n>.001&&r.camera?(s.penumbraFrameScale.value=n/o,s.penumbraFrameOffset.value=(r.camera.near-a.near)/o):(s.penumbraFrameScale.value=1,s.penumbraFrameOffset.value=0);let l=0;if(i&&i.fresh&&i.slot>=0&&E5()){let h=s.mapSize.value;Mq/1024+(2*s.radius.value+2)/Math.max(1,h)<=1/Tc&&(l=1)}return s.pyramidEnabled.value=mbt??l,s.pyramidSlot.value=Math.max(0,i?.slot??0),s.pyramidEnabled.value===1}function hbt(t,e){let i=F1(t.planeNormalMat.mul(e)).toVar(),r=$e(i.z),s=$e(Xu(r).add(Si(ke(r),I(0))).mul(Kt(ke(r),I(1e-4))));return zr(st($e(i.x).negate().div(s),$e(i.y).div(s))).toVar()}function s7(t,e,i,r,s,n,a){let o=dbt(),l=cbt(),h=n7(),u=Rv(e),d=$e(u.mapSize),c=zr(st(d,d)),p=$e(u.radius),m=$e(u.penumbraSize),f=Jt(t),g=S=>$e(f.load(Yn(Te(S,st(0),st(1)).mul(c))).x),y=I(1).div(c.x).toVar(),v=I(Mq).div(y.mul(1024)).toVar(),b=$e(u.depthEps),_=hbt(u,a),x=()=>{let S=I(0).toVar(),w=I(0).toVar();for(let M=0;M<l;M++){let A=zr(Sm(ct(M),ct(l),s)).mul(y).mul(v),P=g(zr(i.add(A))).toVar();vt(P.lessThan(r.add(P5(_,A)).add(b)),()=>{S.addAssign(P),w.addAssign(1)})}let T=I(0).toVar();vt(w.greaterThan(0),()=>{let M=S.div(w).toVar(),A=$e(u.penumbraFrameScale),P=$e(u.penumbraFrameOffset),O=r.sub(M).mul(A).div(M.mul(A).add(P)).toVar();T.assign(Te(O.mul(O).mul(200).mul(m),I(0),I(1)))});let C=I(0).toVar();for(let M=0;M<o;M++){let A=zr(Sm(ct(M),ct(o),s)).mul(y),P=zr(A.mul(p.mul(2)).add(A.mul(T.mul(v)))),O=$e(r.add(P5(_,P)));h?C.addAssign($e(Jt(t,zr(i.add(P))).compare(O))):C.addAssign(Si(O,g(zr(i.add(P)))))}n.assign(C.div(o))};if(E5()){let S=Jt(J9()),w=$e(u.pyramidEnabled),T=$e(u.pyramidSlot),C=I(Tc),M=I(0).toVar();vt(w.greaterThan(.5),()=>{let A=zr(Te(i,st(0),st(1))),P=$e(A.x.mul(C)).toVar(),O=$e(A.y.mul(C)).toVar(),D=T.mul(C),N=I(1e9).toVar(),z=I(-1e9).toVar();for(let V=-1;V<=1;V++)for(let q=-1;q<=1;q++){let W=Te(P.add(I(q)),I(0),C.sub(1)),H=Te(O.add(I(V)),I(0),C.sub(1)),rt=zr(st(W.add(D),H)),it=S.load(Yn(rt));N.assign(ti(N,$e(it.x))),z.assign(Kt(z,$e(it.y)))}let k=$e(y.mul(p.mul(2).add(v))),B=$e(ti(ci(_).mul(k),I(.05))).toVar();vt(N.greaterThanEqual(r.add(b).add(B)),()=>{M.assign(1)}).ElseIf(z.lessThan(r.sub(B)),()=>{M.assign(2)})}),vt(M.equal(1),()=>{n.assign(1)}).ElseIf(M.equal(2),()=>{n.assign(0)}).Else(x)}else x()}function aPt(t,e){let i=e;return i.isPointLight?(He.pcssHookServes++,D5):i.isSpotLight||i.isDirectionalLight?(He.pcssHookServes++,R5):null}function fht(t){Aq.value=t?1:0}function ght(t,e){return i=>{let r=function(a){let o=a,l={};if(o==null)return l;for(let h of fbt){let u=o[h];u!==void 0&&(l[h]=u)}return l}(i),s=$e(l7(t,r)),n=$e(l7(e,r));return At(()=>{let a=I(1).toVar();return vt($e(Aq).greaterThan(.5),()=>{a.assign(s)}).Else(()=>{a.assign(n)}),a})()}}var $e,zr,F1,cE,pE,mE,fE,D2,n7,E5,kL,a7,o7,ubt,Mq,nc,dbt,cbt,pbt,mbt,P5,yht,vht,bht,Aq,l7,fbt,R5,D5,gE,_ht,xht,gbt,ybt,vbt,bbt,_bt=U(()=>{je(),ot(),pn(),obt(),$e=t=>t,zr=t=>t,F1=t=>t,cE=!0,pE=!0,mE=!0,fE=!0;try{let t=new URLSearchParams(window.location.search),e=t.get("dbgpcss");e==="classic"||e==="0"?(cE=!1,pE=!1,mE=!1,fE=!1):(cE=t.get("dbgpcsssplit")!=="0",pE=t.get("dbgpcsshw")!=="0",mE=t.get("dbgpcsshiz")!=="0",fE=t.get("dbgshadowmask")!=="0")}catch{}D2=!1,n7=()=>pE&&D2,E5=()=>mE&&D2,kL=()=>fE&&D2,a7=()=>E5(),o7=()=>kL(),ubt=[[0,-.333334],[-.5,.333334],[.5,-.777778],[-.75,-.111112],[.25,.555556],[-.25,-.555556],[.75,.111112],[-.875,.777778],[.125,-.925926],[-.375,-.25926],[.625,.407408],[-.625,-.703704],[.375,-.037038],[-.125,.62963],[.875,-.481482],[-.9375,.185186]],Mq=80,nc=16,dbt=()=>n7()?Math.max(4,nc>>1):nc,cbt=()=>cE?Math.max(4,nc>>1):nc,pbt=1.25,mbt=null,P5=(t,e)=>$e(Te(Bt(t,e),I(-.05),I(.05))),yht=At(t=>{let{depthTexture:e,shadowCoord:i,shadow:r}=t,s=Rv(r),n=zr(i.xy).toVar(),a=$e(i.z).toVar(),o=F1(sT).toVar(),l=zr(Vt.pcssHalton),h=$e(Pc(Qa.xy.add(l))).mul(6.28318530718).toVar(),u=I(1).toVar();if(kL()){let d=s.maskChannel,c=$e(Vt.shadowMaskEnabled),p=Vt.shadowMaskGBuffer,m=Vt.shadowMaskTexture,f=I(0).toVar(),g=I(1).toVar();vt(c.greaterThan(.5).and($e(Bt(d,at(1,1,1,1))).greaterThan(.5)),()=>{let y=zr(th),v=zr(Vt.shadowMaskResolution),b=zr(Vt.shadowMaskFullResolution),_=$e(Ic.z),x=zr(y.mul(v).sub(st(.5,.5))).toVar(),S=zr(de(x)).toVar(),w=zr(x.sub(S)).toVar(),T=$e(Kt(ke(_).mul(.02),I(.05))),C=I(0).toVar(),M=I(0).toVar();for(let A=0;A<=1;A++)for(let P=0;P<=1;P++){let O=zr(Te(S.add(st(P,A)),st(0,0),v.sub(st(1,1)))),D=zr(O.add(st(.5,.5)).div(v)),N=zr(de(D.mul(b)).add(st(.5,.5)).div(b)),z=$e(p.sample(N).w),k=$e(Bt(m.sample(D),d)),B=$e(P===0?I(1).sub(w.x):$e(w.x)),V=$e(A===0?I(1).sub(w.y):$e(w.y)),q=$e(Si(ke(z.sub(_)),T)),W=$e(B.mul(V).mul(q)).toVar();C.addAssign(W),M.addAssign(k.mul(W))}vt(C.greaterThan(.001),()=>{f.assign(1),g.assign(M.div(C))})}),vt(f.greaterThan(.5),()=>{u.assign(g)}).Else(()=>{s7(e,r,n,a,h,u,o)})}else s7(e,r,n,a,h,u,o);return u}),vht=At(t=>{let{depthTexture:e,shadowCoord:i,shadow:r}=t,s=Rv(r),n=zr(i.xy).toVar(),a=$e(i.z).toVar(),o=hbt(s,F1(sT).toVar()),l=$e(s.mapSize),h=$e(s.radius),u=$e(h.mul(I(1).div(l))).toVar(),d=$e(Pc(Qa.xy)).mul(6.28318530718).toVar(),c=I(0).toVar();for(let p=0;p<5;p++){let m=zr(Sm(ct(p),ct(5),d)).mul(u).toVar();c.addAssign($e(Jt(e,zr(n.add(m))).compare(a.add(P5(o,m)))))}return c.mul(.2)}),bht=At(t=>{let{depthTexture:e,bd3D:i,dp:r,shadow:s}=t,n=nc,a=Rv(s),o=$e(a.mapSize),l=$e(a.radius),h=I(1).div(o).toVar(),u=zr(Vt.pcssHalton),d=$e(Pc(Qa.xy.add(u))).mul(6.28318530718).toVar(),c=$e(l.add(5)).toVar(),p=I(0).toVar();for(let m=0;m<n;m++){let f=zr(Sm(ct(m),ct(n),d)).mul(h).toVar(),g=F1(j(f.x,f.y,$e(f.x).negate()).mul(c)),y=F1(i.add(g));p.addAssign($e(ivt(e,y).compare(r)))}return p.div(n)}),Aq=mt(1),l7=(t,e)=>t(e),fbt=["depthTexture","shadowCoord","shadow","depthLayer","bd3D","dp"],R5=ght(yht,vht),D5=ght(bht,H1t)}),oPt=U(()=>{ot(),cr(),je(),pn(),_bt(),gE=new Pr,_ht=new se,xht=new Y,gbt=class{constructor(){this._gBuffer=null,this._maskTarget=null,this._resolveMaterial=null,this._resolveKey="",this._cameraWorld=mt(new bt),this._projInv=mt(new bt),this._lightRows=[];let t=new Pe;t.name="SplineShadowMask.gbuffer",t.fragmentNode=at(Ra,Ic.z),t.lights=!1,t.blending=Wi,t.needsUpdate=!0,this._gBufferMaterial=t}_ensureTarget(t,e,i,r){return t&&t.width===e&&t.height===i?{target:t,changed:!1}:(t?.dispose(),{target:r(),changed:!0})}_buildResolveMaterial(t){let e=new Pe;e.name="SplineShadowMask.resolve";let i=Jt(this._gBuffer.depthTexture),r=Jt(this._gBuffer.texture),s=this._cameraWorld,n=this._projInv,a=this._gBuffer.width,o=this._gBuffer.height;this._lightRows=t.map(()=>({matrix:mt(new bt),bias:mt(0),normalBias:mt(0)}));let l=this._lightRows,h=At(()=>{let u=ui(),d=de(u.mul(st(a,o))).add(st(.5,.5)).div(st(a,o)).toVar(),c=i.sample(d),p=uq(d,c,n).toVar(),m=r.sample(d).toVar(),f=s,g=f.mul(at(p,1)).xyz.toVar(),y=be(f.mul(at(m.xyz,0)).xyz).toVar(),v=Vt.pcssHalton,b=Pc(Qa.xy.add(v)).mul(6.28318530718).toVar(),_=[I(1).toVar(),I(1).toVar(),I(1).toVar(),I(1).toVar()];return t.forEach((x,S)=>{let w=l[S],T=g.add(y.mul(w.normalBias)),C=w.matrix.mul(at(T,1)).toVar(),M=C.xyz.div(C.w),A=j(M.x,I(1).sub(M.y),M.z).toVar(),P=A.z.add(w.bias).toVar(),O=A.x.greaterThanEqual(0).and(A.x.lessThanEqual(1)).and(A.y.greaterThanEqual(0)).and(A.y.lessThanEqual(1)).and(P.lessThanEqual(1));vt(O,()=>{s7(x.shadow.map.depthTexture,x.shadow,A.xy,P,b,_[S],y)})}),at(_[0],_[1],_[2],_[3])})();return e.fragmentNode=h,e.lights=!1,e.blending=Wi,e.depthTest=!1,e.depthWrite=!1,e.needsUpdate=!0,e}render(t,e,i,r,s){let n=s??t.getDrawingBufferSize(xht),a=Math.max(1,Math.round(n.x)),o=Math.max(1,Math.round(n.y)),l=Math.max(1,Math.round(a/2)),h=Math.max(1,Math.round(o/2)),u=!1,d=this._ensureTarget(this._gBuffer,a,o,()=>{let C=new ii(a,o,{type:si,depthTexture:new Ha(a,o),minFilter:pe,magFilter:pe});return C.texture.name="SplineShadowMask.gbuffer",C});this._gBuffer=d.target,u=u||d.changed;let c=this._ensureTarget(this._maskTarget,l,h,()=>{let C=new ii(l,h,{depthBuffer:!1,minFilter:pe,magFilter:pe});return C.texture.name="SplineShadowMask.mask",C});this._maskTarget=c.target,u=u||c.changed;let p=`${this._gBuffer.texture.uuid}:${r.map(C=>C.shadow.map?.depthTexture?.uuid??"none").join(",")}`;(this._resolveMaterial===null||this._resolveKey!==p)&&(this._resolveMaterial?.dispose(),this._resolveMaterial=this._buildResolveMaterial(r),this._resolveKey=p),this._cameraWorld.value.copy(i.matrixWorld),this._projInv.value.copy(i.projectionMatrix).invert(),r.forEach((C,M)=>{C.shadow.updateMatrices?.(C.light);let A=this._lightRows[M];C.shadow.matrix&&A.matrix.value.copy(C.shadow.matrix),A.bias.value=C.shadow.bias??0,A.normalBias.value=C.shadow.normalBias??0});let m=e,f=m.isScene===!0,g=[],y=[];m.traverse(C=>{let M=C;if(M.isMesh===!0&&M.visible!==!1){if((Array.isArray(M.material)?M.material:[M.material]).some(A=>A?.transparent===!0))g.push(M),M.visible=!1;else if(!f){let A=M;y.push({obj:A,material:A.material}),A.material=this._gBufferMaterial}}});let v=m.overrideMaterial,b=t.getRenderTarget(),_=t.getMRT(),x=t.getClearColor(_ht),S=t.getClearAlpha(),w=i.layers,T=w.mask;w.disable(3),m.overrideMaterial=this._gBufferMaterial,t.setMRT(null),t.setClearColor(0,0),t.setRenderTarget(this._gBuffer),t.render(e,i),m.overrideMaterial=v,w.mask=T;for(let C of g)C.visible=!0;for(let C of y)C.obj.material=C.material;return gE.material=this._resolveMaterial,gE.name="SplineShadowMask.resolve",t.setRenderTarget(this._maskTarget),gE.render(t),t.setRenderTarget(b),t.setMRT(_),t.setClearColor(x,S),Vt.shadowMaskTexture.value=this._maskTarget.texture,Vt.shadowMaskGBuffer.value=this._gBuffer.texture,Vt.shadowMaskResolution.value.set(l,h),Vt.shadowMaskFullResolution.value.set(a,o),r.forEach((C,M)=>{lbt(C.shadow,M)}),He.shadowMaskResolves++,{targetsChanged:u}}dispose(){this._gBuffer?.dispose(),this._gBuffer=null,this._maskTarget?.dispose(),this._maskTarget=null,this._gBufferMaterial.dispose(),this._resolveMaterial?.dispose(),this._resolveMaterial=null,this._resolveKey=""}}}),lPt=U(()=>{ot(),ybt=1,vbt={src:kv,dst:X1,srcAlpha:X1,dstAlpha:X1},bbt={src:_G,dst:xG,srcAlpha:X1,dstAlpha:kv}});function wht(t){let e=t;return e.isSkinnedMesh===!0&&e.bindMatrixInverse?e.bindMatrixInverse:null}function Sht(t){let e=new rT(VS);return e.blendSrc=t.src,e.blendDst=t.dst,e.blendSrcAlpha=t.srcAlpha,e.blendDstAlpha=t.dstAlpha,e}var yE,Tht,O5,xbt,Mht,Aht,Cht,wbt,Sbt=U(()=>{ot(),je(),cr(),lPt(),yE=new WeakMap,Tht=new bt,O5=_vt(class extends j1t{update(t){super.update(t);let{frameId:e,object:i}=t,r=wht(i),s=yE.get(i);s===void 0?(s={frameId:e,prev:i.matrixWorld.clone(),last:i.matrixWorld.clone(),prevBind:r?.clone()??null,lastBind:r?.clone()??null},yE.set(i,s)):s.frameId!==e&&(s.frameId=e,s.prev.copy(s.last),s.prevBind&&s.lastBind&&s.prevBind.copy(s.lastBind));let n=this.previousModelWorldMatrix.value.copy(s.prev);r!==null&&(s.prevBind===null&&(s.prevBind=r.clone(),s.lastBind=r.clone()),n.multiply(s.prevBind).multiply(Tht.copy(r).invert()))}updateAfter(t){let{object:e}=t,i=yE.get(e);if(i===void 0)return;i.last.copy(e.matrixWorld);let r=wht(e);r!==null&&i.lastBind?.copy(r)}}),xbt=at(O5,0,ybt),Mht=Sht(vbt),Aht=new rT(Wi),Cht=Sht(bbt),wbt=new class extends rT{resolveForMaterial(t){return t.depthWrite?Mht:function(e){return!e.depthWrite&&e.blending!==Wi&&(e.blending!==Ql||e.transparent)}(t)?Cht:Aht}}(Wi)});function I5(t,e){let i=0,r=1,s=t;for(;s>0;)r/=e,i+=r*(s%e),s=Math.floor(s/e);return i}function VL(t){return j(t.x.div(4).add(t.y.div(2)).add(t.z.div(4)),t.x.div(2).sub(t.z.div(2)),t.x.div(-4).add(t.y.div(2)).sub(t.z.div(4)))}function Eht(t,e=!0){let i=j(t.x.add(t.y).sub(t.z),t.x.add(t.z),t.x.sub(t.y).sub(t.z));return e?Te(i,j(0),j(1)):Kt(i,j(0))}function Tbt(){let t=!1;try{let c=new URLSearchParams(window.location.search).get("dbgfp16");t=c==="1"||c==="hist"||c==="st"}catch{}let e=!1,i=()=>t||e,r=(c,p,m)=>{let f=new ii(c,p,{minFilter:pe,magFilter:pe,depthBuffer:!1});return i()?f.texture.type=si:jD()&&(f.texture.internalFormat="rgba8unorm-srgb"),f.texture.name=m,f},s=r(1,1,"SplineTAA.A"),n=r(1,1,"SplineTAA.B"),a=null,o=!1,l=0,h=0,u=0,d=0;return{rtA:s,rtB:n,flip:!1,valid:!1,jitterIndex:0,unjitteredProjection:new bt,jitterOffsetUV:new Y(0,0),beginJitter(c,p,m){if(o)return;let f,g;if(o=!0,(a===null||a.cam!==c)&&(a?.clearViewOffset(),a=new Mbt(c)),this.unjitteredProjection.copy(c.projectionMatrix),Vt.unjitteredProjection.value.copy(c.projectionMatrix),sv==="r2"){let y=++this.jitterIndex;f=(.5+Abt*y)%1,g=(.5+Cbt*y)%1}else if(sv==="white")this.jitterIndex++,f=Math.random(),g=Math.random();else if(sv==="h64")f=I5(this.jitterIndex%64+1,2),g=I5(this.jitterIndex%64+1,3),this.jitterIndex=(this.jitterIndex+1)%64;else if(sv==="half"){let[y,v]=O2[this.jitterIndex];f=.5+.5*(y-.5),g=.5+.5*(v-.5),this.jitterIndex=(this.jitterIndex+1)%O2.length}else[f,g]=O2[this.jitterIndex],this.jitterIndex=(this.jitterIndex+1)%O2.length;l=p,h=m,u=f-.5,d=g-.5,Vt.cameraJitterPx.value.set(2*u,2*d),a.setViewOffset(p,m,u,d),this.jitterOffsetUV.set(-(f-.5)/p,-(g-.5)/m),He.taaJitterIndex=this.jitterIndex,He.taaJitterApplies++},suspendJitter(){o&&a?.clearViewOffset()},resumeJitter(){o&&a!==null&&a.setViewOffset(l,h,u,d)},endJitter(){o=!1,this.jitterOffsetUV.set(0,0),a?.clearViewOffset()},resize(c,p){this.rtA.dispose(),this.rtB.dispose(),this.rtA=r(c,p,"SplineTAA.A"),this.rtB=r(c,p,"SplineTAA.B"),this.valid=!1},setHdr(c){if(e===c)return;let p=i();e=c,i()!==p&&this.resize(this.rtA.width,this.rtA.height)},dispose(){this.rtA.dispose(),this.rtB.dispose(),this.valid=!1,o=!1,a?.clearViewOffset(),a=null}}}var Pht,Rht,vE,Mbt,O2,sv,Abt,Cbt,Ebt,Pbt,Wf,Dht,zL,Oht,Rbt,bE,LL,Dbt,Obt=U(()=>{ot(),Sbt(),pn(),cr(),je(),Pht=t=>t,Rht=t=>t,vE=new Pr,Mbt=class{constructor(t){this.cam=t,this._savedSkewX=0,this._savedSkewY=0,this._savedShiftX=0,this._savedShiftY=0,this._jitterActive=!1}setViewOffset(t,e,i,r){this.clearViewOffset();let s=this.cam.projectionMatrix.elements,n=-2*i/t,a=2*r/e;this._savedSkewX=s[8],this._savedSkewY=s[9],this._savedShiftX=s[12],this._savedShiftY=s[13],s[8]+=n*s[11],s[9]+=a*s[11],s[12]+=n*s[15],s[13]+=a*s[15],this.cam.projectionMatrixInverse.copy(this.cam.projectionMatrix).invert(),this._jitterActive=!0}clearViewOffset(){if(!this._jitterActive)return;let t=this.cam.projectionMatrix.elements;t[8]=this._savedSkewX,t[9]=this._savedSkewY,t[12]=this._savedShiftX,t[13]=this._savedShiftY,this.cam.projectionMatrixInverse.copy(this.cam.projectionMatrix).invert(),this._jitterActive=!1}},O2=Array.from({length:16},(t,e)=>[I5(e+1,2),I5(e+1,3)]),sv="h16";try{let t=new URLSearchParams(window.location.search).get("dbgjitseq");(t==="r2"||t==="h64"||t==="white"||t==="half")&&(sv=t)}catch{}Abt=.7548776662466927,Cbt=.5698402909980532,Ebt=class extends Cr{constructor(t,e,i,r,s=!1){super("vec4"),this._resolution=mt(new Y(1,1)),this._historyValid=mt(0),this._jitterUV=mt(new Y(0,0)),this._resolveMaterials=null,this._rebuildResolveMaterials=null,this.beautyNode=t,this.depthNode=e,this.velocityNode=i,this._hdr=s,this._history=r??Tbt(),this._ownsHistory=r===void 0,this._outputTexNode=Jt(this._history.rtA.texture)}static get type(){return"SplineTAANode"}get outputTextureNode(){return this._outputTexNode}renderResolve(t){O5.setProjectionMatrix(this._history.unjitteredProjection);let e=this.beautyNode.passNode.renderTarget,i=e.texture.width,r=e.texture.height,s=this._history;(s.rtA.width!==i||s.rtA.height!==r)&&(s.resize(i,r),this._rebuildResolveMaterials?.()),this._resolution.value.set(i,r),this._historyValid.value=s.valid?1:0,this._jitterUV.value.copy(s.jitterOffsetUV);let n=s.flip?s.rtB:s.rtA,a=this._resolveMaterials?this._resolveMaterials[s.flip?1:0]:null,o=t.getRenderTarget(),l=t.getMRT();t.setMRT(null),s.valid||(t.setRenderTarget(s.rtA),t.clear(!0,!1,!1),t.setRenderTarget(s.rtB),t.clear(!0,!1,!1)),t.setRenderTarget(n),a&&(vE.material=a,vE.name="SplineTAA.resolve",vE.render(t)),t.setRenderTarget(o),t.setMRT(l),this._outputTexNode.value=n.texture,s.valid=!0,s.flip=!s.flip,He.taaResolves++,He.taaJitterIndex=s.jitterIndex,He.taaHistoryValid=!0,He.taaResolveSize=`${i}x${r}`}setup(t){let e=t.renderer.reversedDepthBuffer===!0,i=t.renderer.backend?.isWebGLBackend===!0,r=!1,s=!1,n=!1,a=!1,o=!1,l=!1,h=!1,u=!1,d=!1,c=!1;try{let x=new URLSearchParams(window.location.search).get("dbgtaa");r=x==="1",s=x==="zv",n=x==="nc",a=x==="err",o=x==="hist",l=x==="red",h=x==="ns",u=x==="fb90",d=new URLSearchParams(window.location.search).get("dbgjit")==="mark",c=x==="hold"}catch{}let p=this.beautyNode,m=this.velocityNode,f=this.depthNode,g=this._resolution,y=this._historyValid,v=this._jitterUV,b=x=>{let S=p.sample(x);return at(VL(S.rgb),S.a)},_=x=>{let S=At(()=>{let T=ui().toVar();if(d)return at(v.x.mul(400).add(.5),v.y.mul(400).add(.5),I(.5),I(1));let C=T,M=st(I(1).div(g.x),I(1).div(g.y)).toVar(),A=[[-1,1],[0,1],[1,1],[-1,0],[0,0],[1,0],[-1,-1],[0,-1],[1,-1]].map(([Hi,ai])=>T.add(st(M.x.mul(Hi),M.y.mul(ai))).toVar()),P=A,O=I(e?-1e3:1e3).toVar(),D=st(A[4]).toVar();for(let Hi=0;Hi<9;Hi++){let ai=Pht(f.load(Yn(A[Hi].mul(Rht(g)))).r).toVar(),Fr=e?ai.greaterThan(O):ai.lessThan(O);O.assign(Fr.select(ai,O)),D.assign(Fr.select(A[Hi],D))}let N=m.load(Yn(D.mul(g))).xy.mul(st(.5,-.5)).toVar();s&&N.assign(st(0,0));let z=T.sub(N).toVar(),k=i?st(z.x,I(1).sub(z.y)).toVar():z,B=b(C).toVar();if(r)return at(N.x.mul(20).add(.5),N.y.mul(20).add(.5),y,I(1));if(l){let Hi=new yr(new Uint8Array([255,0,0,255,255,0,0,255,255,0,0,255,255,0,0,255]),2,2);return Hi.needsUpdate=!0,Jt(Hi).sample(T)}if(o){let Hi=i?st(T.x,I(1).sub(T.y)):T;return x.sample(Hi)}if(a){let Hi=i?st(T.x,I(1).sub(T.y)):T,ai=x.sample(k),Fr=x.sample(Hi),ts=B.x,Ur=Fi=>VL(Fi.rgb).x;return at(Ur(ai).sub(ts).abs().mul(8),Ur(Fr).sub(ts).abs().mul(8),I(0),I(1))}let V=k.mul(g).toVar(),q=de(V.sub(.5)).add(.5).toVar(),W=V.sub(q).toVar(),H=W.mul(W.mul(W.mul(-.5).add(1)).add(-.5)).toVar(),rt=W.mul(W).mul(W.mul(1.5).add(-2.5)).add(1).toVar(),it=W.mul(W.mul(W.mul(-1.5).add(2)).add(.5)).toVar(),ft=W.mul(W).mul(W.mul(.5).add(-.5)).toVar(),dt=rt.add(it).toVar(),K=it.div(dt).toVar(),lt=q.sub(1).div(g).toVar(),_t=q.add(2).div(g).toVar(),xt=q.add(K).div(g).toVar(),wt=at(0).toVar();wt.addAssign(x.sample(st(xt.x,lt.y)).mul(dt.x.mul(H.y))),wt.addAssign(x.sample(st(lt.x,xt.y)).mul(H.x.mul(dt.y))),wt.addAssign(x.sample(st(xt.x,xt.y)).mul(dt.x.mul(dt.y))),wt.addAssign(x.sample(st(_t.x,xt.y)).mul(ft.x.mul(dt.y))),wt.addAssign(x.sample(st(xt.x,_t.y)).mul(dt.x.mul(ft.y)));let gt=at(VL(wt.rgb),wt.a).toVar();if(c)return at(Eht(gt.rgb).mul(j(1,.55,.55)),wt.a);let Dt=b(P[0]).toVar(),Lt=b(P[1]).toVar(),It=b(P[2]).toVar(),kt=b(P[3]).toVar(),Nt=b(P[4]).toVar(),Gt=b(P[5]).toVar(),qt=b(P[6]).toVar(),Ct=b(P[7]).toVar(),ne=b(P[8]).toVar(),Ut=at(ti(Dt,ti(Lt,ti(It,ti(kt,ti(Nt,ti(Gt,ti(qt,ti(Ct,ne))))))))).toVar(),Yt=at(Kt(Dt,Kt(Lt,Kt(It,Kt(kt,Kt(Nt,Kt(Gt,Kt(qt,Kt(Ct,ne))))))))).toVar(),Zt=at(ti(Lt,ti(kt,ti(Nt,ti(Gt,Ct))))).toVar(),$=at(Kt(Lt,Kt(kt,Kt(Nt,Kt(Gt,Ct))))).toVar();Ut.assign(Ut.add(Zt).mul(.5)),Yt.assign(Yt.add($).mul(.5));let ie=Yt.r.sub(Ut.r).mul(.25).mul(.5).toVar(),Ce=B.gb.toVar();h||(Ut.y.assign(Ce.x.sub(ie)),Ut.z.assign(Ce.y.sub(ie)),Yt.y.assign(Ce.x.add(ie)),Yt.z.assign(Ce.y.add(ie)));let Be=at(n?gt:Te(gt,Ut,Yt)).toVar(),te=u||n?I(.9):I(.9).mul(y),ni=at($t(B,Be,te)).toVar(),bi=Vt.tapAngle,Zs=fq(T.mul(g).add(st(bi.mul(127.1),bi.mul(311.7)))).sub(.5).mul(1/255);return at(Eht(ni.rgb,!this._hdr).add(j(Zs)),ni.a)}),w=new Pe;return w.name="SplineTAA.resolve",w.colorNode=S(),w.depthTest=!1,w.depthWrite=!1,w.blending=Wi,w.needsUpdate=!0,w};return this._rebuildResolveMaterials=()=>{this._resolveMaterials&&(this._resolveMaterials[0].dispose(),this._resolveMaterials[1].dispose()),this._resolveMaterials=[_(Jt(this._history.rtB.texture)),_(Jt(this._history.rtA.texture))]},this._rebuildResolveMaterials(),this._outputTexNode}dispose(){this._ownsHistory&&this._history.dispose(),this._resolveMaterials&&(this._resolveMaterials[0].dispose(),this._resolveMaterials[1].dispose(),this._resolveMaterials=null),O5.setProjectionMatrix(null)}}}),hPt=U(()=>{Pbt=class{constructor(){this._frames=0}get frames(){return this._frames}get stalled(){return this._frames>=3}update(t,e){this._frames=t>0&&!e?this._frames+1:0}}}),uPt=U(()=>{}),dPt=U(()=>{eq(),cr(),je(),Wf=new Pr,Dht=new Y,Oht=class extends Cr{static get type(){return"SMAANode"}constructor(t){super("vec4"),this.textureNode=t,this.updateBeforeType=q1t.FRAME,this._renderTargetEdges=new ii(1,1,{depthBuffer:!1,type:si}),this._renderTargetEdges.texture.name="SMAANode.edges",this._renderTargetWeights=new ii(1,1,{depthBuffer:!1,type:si}),this._renderTargetWeights.texture.name="SMAANode.weights",this._renderTargetBlend=new ii(1,1,{depthBuffer:!1,type:si}),this._renderTargetBlend.texture.name="SMAANode.blend";let e=this,i=new Image;i.crossOrigin="anonymous",lQ(i,"smaa-node-area.png"),i.onload=function(){e._areaTexture.needsUpdate=!0},this._areaTexture=new di,this._areaTexture.name="SMAANode.area",this._areaTexture.image=i,this._areaTexture.minFilter=pe,this._areaTexture.generateMipmaps=!1,this._areaTexture.flipY=!1;let r=new Image;r.crossOrigin="anonymous",lQ(r,"smaa-node-search.png"),r.onload=function(){e._searchTexture.needsUpdate=!0},this._searchTexture=new di,this._searchTexture.name="SMAANode.search",this._searchTexture.image=r,this._searchTexture.magFilter=Re,this._searchTexture.minFilter=Re,this._searchTexture.generateMipmaps=!1,this._searchTexture.flipY=!1,this._invSize=mt(new Y),this._areaTextureUniform=Jt(this._areaTexture),this._searchTextureUniform=Jt(this._searchTexture),this._edgesTextureUniform=Jt(this._renderTargetEdges.texture),this._weightsTextureUniform=Jt(this._renderTargetWeights.texture),this._materialEdges=new Pe,this._materialEdges.name="SMAANode.edges",this._materialWeights=new Pe,this._materialWeights.name="SMAANode.weights",this._materialBlend=new Pe,this._materialBlend.name="SMAANode.blend",this._textureNode=Cvt(this,this._renderTargetBlend.texture)}getTextureNode(){return this._textureNode}setSize(t,e){this._invSize.value.set(1/t,1/e),this._renderTargetEdges.setSize(t,e),this._renderTargetWeights.setSize(t,e),this._renderTargetBlend.setSize(t,e)}updateBefore(t){let{renderer:e}=t;zL=M9.resetRendererState(e,zL);let i=e.getDrawingBufferSize(Dht);this.setSize(i.width,i.height),e.setRenderTarget(this._renderTargetEdges),Wf.material=this._materialEdges,Wf.render(e),e.setRenderTarget(this._renderTargetWeights),Wf.material=this._materialWeights,Wf.render(e),e.setRenderTarget(this._renderTargetBlend),Wf.material=this._materialBlend,Wf.render(e),M9.restoreRendererState(e,zL)}setup(t){let e=st(.00625,.0017857142857142857),i=1/7,r=this.textureNode.uvNode||ui(),s=At(()=>{let g=at(r.xy,r.xy).add(at(this._invSize.xy,this._invSize.xy).mul(at(-1,0,0,-1))),y=at(r.xy,r.xy).add(at(this._invSize.xy,this._invSize.xy).mul(at(1,0,0,1))),v=at(r.xy,r.xy).add(at(this._invSize.xy,this._invSize.xy).mul(at(-2,0,0,-2)));return Lr("vec4","vOffset0").assign(g),Lr("vec4","vOffset1").assign(y),Lr("vec4","vOffset2").assign(v),FR}),n=At(()=>{let g=Lr("vec4","vOffset0"),y=Lr("vec4","vOffset1"),v=Lr("vec4","vOffset2"),b=st(.1,.1),_=at().toVar(),x=this.textureNode.sample(r).rgb.toVar(),S=this.textureNode.sample(g.xy).rgb.toVar(),w=ke(x.sub(S));_.x=Kt(w.r,w.g,w.b);let T=this.textureNode.sample(g.zw).rgb.toVar();w=ke(x.sub(T)),_.y=Kt(w.r,w.g,w.b);let C=Si(b,_.xy).toVar();Bt(C,st(1,1)).equal(0).discard();let M=this.textureNode.sample(y.xy).rgb.toVar();w=ke(x.sub(M)),_.z=Kt(w.r,w.g,w.b);let A=this.textureNode.sample(y.zw).rgb.toVar();w=ke(x.sub(A)),_.w=Kt(w.r,w.g,w.b);let P=Kt(_.x,_.y,_.z,_.w).toVar(),O=this.textureNode.sample(v.xy).rgb.toVar();w=ke(x.sub(O)),_.z=Kt(w.r,w.g,w.b);let D=this.textureNode.sample(v.zw).rgb.toVar();return w=ke(x.sub(D)),_.w=Kt(w.r,w.g,w.b),P=Kt(P,_.z,_.w),C.xy.mulAssign(st(Si(I(.5).mul(P),_.xy))),at(C,0,0)}),a=At(([g,y,v,b])=>{let _=st(y).toVar();return _.r=v.add(_.r.mul(b)),I(255).mul(g.sample(_)).r}),o=At(([g,y,v,b,_])=>{let x=I(16).mul(I(4).mul(st(v,b)).round()).add(y);return x=e.mul(x).add(I(.5).mul(e)),x.y.addAssign(I(i).mul(_)),g.sample(x).rg}),l=At(([g,y,v,b])=>{let _=st(0,1).toVar(),x=st(v).toVar();return Qi({start:ct(0),end:ct(8),type:"int",condition:"<"},()=>{_.assign(g.sample(x).rg),x.subAssign(st(2,0).mul(this._invSize)),vt(x.x.lessThanEqual(b).or(_.g.lessThanEqual(I(.8281)).or(_.r.notEqual(I(0)))),()=>{ea()})}),x.x.addAssign(I(.25).mul(this._invSize.x)),x.x.addAssign(this._invSize.x),x.x.addAssign(I(2).mul(this._invSize.x)),x.x.subAssign(this._invSize.x.mul(a(y,_,0,.5))),x.x}),h=At(([g,y,v,b])=>{let _=st(0,1).toVar(),x=st(v).toVar();return Qi({start:ct(0),end:ct(8),type:"int",condition:"<"},()=>{_.assign(g.sample(x).rg),x.addAssign(st(2,0).mul(this._invSize)),vt(x.x.greaterThanEqual(b).or(_.g.lessThanEqual(I(.8281)).or(_.r.notEqual(I(0)))),()=>{ea()})}),x.x.subAssign(I(.25).mul(this._invSize.x)),x.x.subAssign(this._invSize.x),x.x.subAssign(I(2).mul(this._invSize.x)),x.x.addAssign(this._invSize.x.mul(a(y,_,.5,.5))),x.x}),u=At(([g,y,v,b])=>{let _=st(1,0).toVar(),x=st(v).toVar();return Qi({start:ct(0),end:ct(8),type:"int",condition:"<"},()=>{_.assign(g.sample(x).rg),x.addAssign(st(0,-2).mul(this._invSize)),vt(x.y.lessThanEqual(b).or(_.r.lessThanEqual(I(.8281)).or(_.g.notEqual(I(0)))),()=>{ea()})}),x.y.addAssign(I(.25).mul(this._invSize.y)),x.y.addAssign(this._invSize.y),x.y.addAssign(I(2).mul(this._invSize.y)),x.y.subAssign(this._invSize.y.mul(a(y,_.gr,0,.5))),x.y}),d=At(([g,y,v,b])=>{let _=st(1,0).toVar(),x=st(v).toVar();return Qi({start:ct(0),end:ct(8),type:"int",condition:"<"},()=>{_.assign(g.sample(x).rg),x.subAssign(st(0,-2).mul(this._invSize)),vt(x.y.greaterThanEqual(b).or(_.r.lessThanEqual(I(.8281)).or(_.g.notEqual(I(0)))),()=>{ea()})}),x.y.subAssign(I(.25).mul(this._invSize.y)),x.y.subAssign(this._invSize.y),x.y.subAssign(I(2).mul(this._invSize.y)),x.y.addAssign(this._invSize.y.mul(a(y,_.gr,.5,.5))),x.y}),c=At(()=>{let g=r.xy.div(this._invSize),y=at(r.xy,r.xy).add(at(this._invSize.xy,this._invSize.xy).mul(at(-.25,-.125,1.25,-.125))).toVar(),v=at(r.xy,r.xy).add(at(this._invSize.xy,this._invSize.xy).mul(at(-.125,-.25,-.125,1.25))).toVar(),b=at(y.xz,v.yw).add(at(-2,2,-2,2).mul(at(this._invSize.xx,this._invSize.yy)).mul(I(8))).toVar();return Lr("vec2","vPixcoord").assign(g),Lr("vec4","vOffset0").assign(y),Lr("vec4","vOffset1").assign(v),Lr("vec4","vOffset2").assign(b),FR}),p=At(()=>{let g=Lr("vec2","vPixcoord"),y=Lr("vec4","vOffset0"),v=Lr("vec4","vOffset1"),b=Lr("vec4","vOffset2"),_=at(0,0,0,0).toVar(),x=at(0,0,0,0).toVar(),S=this._edgesTextureUniform.sample(r).rg.toVar();return vt(S.g.greaterThan(I(0)),()=>{let w=st().toVar(),T=st().toVar();T.x=l(this._edgesTextureUniform,this._searchTextureUniform,y.xy,b.x),T.y=v.y,w.x=T.x;let C=this._edgesTextureUniform.sample(T).r.toVar(),M=st().toVar();M.x=h(this._edgesTextureUniform,this._searchTextureUniform,y.zw,b.y),M.y=v.y,w.y=M.x,w=w.div(this._invSize.x).sub(g.x);let A=xl(ke(w)),P=this._edgesTextureUniform.sample(M.add(st(1,0).mul(this._invSize))).r.toVar();_.r=P,_.rg=o(this._areaTextureUniform,A,C,P,I(x.y))}),vt(S.r.greaterThan(I(0)),()=>{let w=st().toVar(),T=st().toVar();T.y=u(this._edgesTextureUniform,this._searchTextureUniform,v.xy,b.z),T.x=y.x,w.x=T.y;let C=this._edgesTextureUniform.sample(T).g.toVar(),M=st().toVar();M.y=d(this._edgesTextureUniform,this._searchTextureUniform,v.zw,b.w),M.x=y.x,w.y=M.y,w=w.div(this._invSize.y).sub(g.y);let A=xl(ke(w)),P=this._edgesTextureUniform.sample(M.add(st(0,1).mul(this._invSize))).g.toVar();_.ba=o(this._areaTextureUniform,A,C,P,I(x.x))}),_}),m=At(()=>{let g=at(r.xy,r.xy).add(at(this._invSize.xy,this._invSize.xy).mul(at(1,0,0,1)));return Lr("vec4","vOffset1").assign(g),FR}),f=At(()=>{let g=Lr("vec4","vOffset1"),y=at().toVar(),v=at().toVar();return v.xz=this._weightsTextureUniform.sample(r).xz,v.y=this._weightsTextureUniform.sample(g.zw).g,v.w=this._weightsTextureUniform.sample(g.xy).a,vt(Bt(v,at(1)).lessThan(1e-5),()=>{y.assign(this.textureNode.sample(r))}).Else(()=>{let b=st().toVar();b.x=v.a.greaterThan(v.b).select(v.a,v.b.negate()),b.y=v.g.greaterThan(v.r).select(v.g,v.r.negate()),vt(ke(b.x).greaterThan(ke(b.y)),()=>{b.y.assign(0)}).Else(()=>{b.x.assign(0)});let _=this.textureNode.sample(r).toVar(),x=st(r).toVar();x.addAssign(Xu(b).mul(this._invSize));let S=this.textureNode.sample(x).toVar(),w=ke(b.x).greaterThan(ke(b.y)).select(ke(b.x),ke(b.y)).toVar(),T=$t(_,S,w);y.assign(T)}),y});return this._materialEdges.vertexNode=s().context(t.getSharedContext()),this._materialEdges.fragmentNode=n().context(t.getSharedContext()),this._materialEdges.needsUpdate=!0,this._materialWeights.vertexNode=c().context(t.getSharedContext()),this._materialWeights.fragmentNode=p().context(t.getSharedContext()),this._materialWeights.needsUpdate=!0,this._materialBlend.vertexNode=m().context(t.getSharedContext()),this._materialBlend.fragmentNode=f().context(t.getSharedContext()),this._materialBlend.needsUpdate=!0,this._textureNode}dispose(){this._renderTargetEdges.dispose(),this._renderTargetWeights.dispose(),this._renderTargetBlend.dispose(),this._areaTexture.dispose(),this._searchTexture.dispose(),this._materialEdges.dispose(),this._materialWeights.dispose(),this._materialBlend.dispose()}_getAreaTexture(){return""}_getSearchTexture(){return""}},Rbt=t=>new Oht(evt(t))}),cPt=U(()=>{ot(),cr(),je(),dPt(),pn(),bE=new Y,LL=new se,Dbt=class{constructor(){this._rt=null,this._texNode=null,this._smaaNode=null,this._material=null,this._quad=null,this._depthTexNode=null,this._seedMaterial=null,this._seedQuad=null}_ensureTarget(t,e,i){if(this._rt===null||this._rt.width!==t||this._rt.height!==e){this._rt?.dispose();let r=new ii(t,e,{depthBuffer:!0,stencilBuffer:!1,samples:0});r.texture.name="SplineHelperOverlay.color",this._rt=r}if(this._texNode===null){this._texNode=Jt(this._rt.texture),this._smaaNode=Rbt(this._texNode);let r=new Pe;r.name="SplineHelperOverlayComposite",r.fragmentNode=this._smaaNode,r.transparent=!0,r.blending=VS,r.blendEquation=uv,r.blendSrc=kv,r.blendDst=Ug,r.blendSrcAlpha=kv,r.blendDstAlpha=Ug,r.depthTest=!1,r.depthWrite=!1,this._material=r,this._quad=new Pr(r);let s=new Pe;s.name="SplineHelperOverlayDepthSeed",this._depthTexNode=Jt(i),s.depthNode=this._depthTexNode.x,s.fragmentNode=at(0),s.colorWrite=!1,s.depthTest=!1,s.depthWrite=!0,this._seedMaterial=s,this._seedQuad=new Pr(s)}else this._texNode.value!==this._rt.texture&&(this._texNode.value=this._rt.texture),this._depthTexNode.value!==i&&(this._depthTexNode.value=i);return this._rt}render(t,e,i,r,s){t.getDrawingBufferSize(bE);let n=this._ensureTarget(bE.x,bE.y,s),a=t.getRenderTarget(),o=t.autoClear;t.getClearColor(LL);let l=t.getClearAlpha();if(t.autoClear=!1,t.setRenderTarget(n),t.setClearColor(0,0),t.clear(!0,!0,!1),this._seedQuad.render(t),e&&t.render(e,r),t.clear(!1,!0,!1),i&&t.render(i,r),t.setRenderTarget(a),t.setClearColor(LL,l),function(){try{return new URLSearchParams(window.location.search).get("dbgoutguard")!=="0"}catch{return!0}}()){let h=t.toneMapping,u=t.outputColorSpace;t.toneMapping=cl,t.outputColorSpace=Zi.workingColorSpace,this._quad.render(t),t.toneMapping=h,t.outputColorSpace=u}else this._quad.render(t);t.autoClear=o}dispose(){this._rt?.dispose(),this._rt=null,this._smaaNode?.dispose(),this._material?.dispose(),this._seedMaterial?.dispose()}}}),h7,HR,$R,pPt=U(()=>{cr(),h7=new WeakMap,HR=new Set,$R=0});function Iht(t){let e=t.parent?.selectedTexture;return e&&e.isTexture===!0?e:null}function _E(t){let e=t.src.array,i=t.attr.array;for(let r=0,s=Math.min(e.length,i.length);r<s;r++)i[r]=e[r];t.attr.needsUpdate=!0}var u7,I2,U1,d7,mPt=U(()=>{ot(),cr(),je(),u7=new WeakMap,I2=new Set,U1=0,d7=new WeakMap});function fPt(t,e){(function(){if(c7)return;c7=!0;let r=Pn.prototype,s=r.addEventListener;r.addEventListener=function(n,a){return n==="dispose"&&j1!==null&&typeof a=="function"&&j1.record(this,a),s.call(this,n,a)}})();let i=j1;j1=t;try{return e()}finally{j1=i}}var Ibt,xE,j1,c7,gPt=U(()=>{ot(),Ibt=class{constructor(){this._entries=[],this._pruneAt=xE}record(t,e){this._entries.push({target:new WeakRef(t),listener:new WeakRef(e)}),this._entries.length>=this._pruneAt&&(this._entries=this._entries.filter(i=>i.target.deref()!==void 0),this._pruneAt=Math.max(xE,2*this._entries.length))}release(){for(let{target:t,listener:e}of this._entries){let i=t.deref(),r=e.deref();i&&r&&i.removeEventListener("dispose",r)}this._entries=[],this._pruneAt=xE}},xE=1024,j1=null,c7=!1}),yPt=U(()=>{});function Nbt(t,e,i,r){let s=t.num(0),n=t.num(1),a=t.num(.5),o=t.num(2),l=t.num(Bbt),h=u=>t.sub(n,u);switch(e){case 0:return i;case 1:return t.min(t.add(i,r),n);case 3:return t.mul(t.add(i,r),a);case 4:{let u=t.max(h(t.div(h(i),t.max(r,l))),s);return t.mix(r,u,t.step(l,r))}case 5:{let u=t.min(t.div(i,t.max(h(r),l)),n);return t.mix(u,r,t.step(n,r))}case 6:return t.min(i,r);case 7:return t.abs(t.sub(i,r));case 8:return t.sub(t.add(i,r),t.mul(o,t.mul(i,r)));case 9:return t.max(i,r);case 10:return t.mul(i,r);case 11:{let u=t.min(t.div(i,t.max(r,l)),n);return t.mix(n,u,t.step(l,r))}case 12:return h(t.abs(t.sub(h(i),r)));case 14:{let u=t.mul(o,t.mul(i,r)),d=h(t.mul(o,t.mul(h(i),h(r))));return t.mix(u,d,t.step(a,i))}case 15:{let u=t.min(t.div(t.mul(i,i),t.max(h(r),l)),n);return t.mix(u,r,t.step(n,r))}case 16:return h(t.mul(h(i),h(r)));case 17:{let u=t.mul(o,r),d=t.add(t.mul(i,u),t.mul(t.mul(i,i),h(u))),c=t.add(t.mul(t.sqrt(t.max(i,s)),t.sub(u,n)),t.mul(t.mul(o,i),h(r)));return t.mix(d,c,t.step(a,r))}case 18:return t.max(t.sub(t.add(i,r),n),s);default:return r}}var Bbt,vPt=U(()=>{Bbt=1e-6});function qf(t,e,i,r,s){if(i===0)return t;if(i===2)return $t(t,e,ti(s,r));let n=Nbt(kbt,i,t,e);return $t(t,n,r)}function FL(t,e,i,r){if(i===0)return t;if(i===2)return Kt(t,ti(e,r));let s=Nbt(Vbt,i,t,e);return $t(t,s,r)}function UL(){return YR===null&&(YR=Kv({output:Tvt,velocity:xbt})).setBlendMode("velocity",wbt),YR}var Oh,XR,kbt,Vbt,YR,N2,p7,KR,jL,m7,f7,Cq,bPt=U(()=>{ot(),cr(),je(),Obt(),Sbt(),$vt(),yPt(),rq(),pn(),vPt(),De(),Oh=t=>t,XR=t=>t,Vbt=kbt={num:t=>I(t),add:(t,e)=>t.add(e),sub:(t,e)=>t.sub(e),mul:(t,e)=>t.mul(e),div:(t,e)=>t.div(e),min:(t,e)=>ti(t,e),max:(t,e)=>Kt(t,e),abs:t=>ke(t),sqrt:t=>xl(t),step:(t,e)=>Si(t,e),mix:(t,e,i)=>$t(t,e,i)},YR=null}),_Pt=U(()=>{N2={enabled:!1},p7=new WeakMap,KR=new WeakSet}),xPt=U(()=>{ot(),cr(),je(),QW(),RD(),ED(),jL=At(t=>{let e=t.lightDistance,i=t.cutoffDistance,r=t.decayExponent,s=i.greaterThan(0).and(r.greaterThan(0));return pi(s,e.div(i).oneMinus().clamp().pow(r),I(1))}),m7=class extends A9{static get type(){return"SplinePointLightNode"}setupDirect(t){let e=this.getLightVector(t),i=e.normalize(),r=jL({lightDistance:e.length(),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode});return{lightColor:this.colorNode.mul(r),lightDirection:i}}},f7=class extends M2{static get type(){return"SplineSpotLightNode"}setupDirect(t){let e,i,r=this.light,s=this.getLightVector(t),n=s.normalize(),a=n.dot(uvt(r)),o=this.getSpotAttenuation(t,a),l=jL({lightDistance:s.length(),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode}),h=this.colorNode.mul(o).mul(l),u=r;if(u.colorNode?(i=this.getLightCoord(t),e=u.colorNode(i)):u.map&&(i=this.getLightCoord(t),e=Jt(u.map,i.xy).onRenderUpdate(()=>u.map)),e&&i){let d=i.mul(2).sub(1).abs().lessThan(1).all();h=pi(d,h.mul(e),h)}return{lightColor:h,lightDirection:n}}}}),zbt=U(()=>{Cq=null});function Lbt(){return typeof requestAnimationFrame!="function"||typeof document<"u"&&document.hidden===!0}function wPt(){return Lbt()?Promise.resolve():new Promise(t=>{let e=!1,i=()=>{e||(e=!0,clearTimeout(r),t())},r=setTimeout(i,250);requestAnimationFrame(i)})}var Nht,Vy,Bht,kht,Vht,GL,WL,zht,Lht,Fht,Uht,Bd,Tp,uw,Mp,wE,qL,dw,Hf,xu,zy,jht,$f,wu,cw,Ly,SE,Xf,Su,HL,TE,$L,ME,XL,YL,AE,CE,Ap,KL,ZL,QL,JL,tF,eF,iF,Yf,Ght,rF,N5,Wht=U(()=>{ot(),cr(),je(),tPt(),tbt(),tq(),DD(),bq(),xq(),GW(),Kh(),ePt(),De(),rbt(),t1t(),LW(),sbt(),nbt(),iPt(),rPt(),sPt(),pn(),_bt(),obt(),oPt(),Obt(),hPt(),uPt(),cPt(),pPt(),mPt(),gPt(),bPt(),_Pt(),Ayt(),xPt(),zbt(),Nht=new E,Vy=new E,Bht=new se,kht=new se,Vht=new se,GL=new E,WL=new E,zht=new Y,Lht=new E(1,0,0),Fht=new E(0,1,0),Uht=new E(0,0,1),Bd=new E,Tp=new E,uw=new E,Mp=new E,wE=new bt,qL=new E,dw=new E,Hf=new Ca,xu=new Se,zy=new Se,jht=new Y,$f=new Y,wu=new E,cw=new E,Ly=new E,SE=new E,Xf=new E,Su=[],HL=!1,TE=!1,$L=!1,ME="full",XL="g16",YL=!1,AE=!1,CE=!1,Ap="default",KL=!1,ZL=!0,QL=!0,JL=!0,tF=!0,eF=!0,iF=r9;try{let t=new URLSearchParams(window.location.search),e=t.get("instancing");if(e!==null)if(e==="off"||e==="0"||e==="false"||e==="no")eF=!1;else{let s=Number.parseInt(e,10);Number.isFinite(s)&&s>1&&(iF=s)}HL=t.get("dbgao")==="0",TE=t.get("dbgshadow")==="0",$L=t.get("dbgfp16")==="1",YL=t.get("dbgsky")==="0",AE=t.get("dbgssr")==="0",CE=t.get("dbgibl")==="0";let i=t.get("pbrcolor");i==="0"?Ap="off":(i==="linear"||i==="aces"||i==="agx"||i==="neutral")&&(Ap=i),KL=t.get("dbgplanar")==="0",ZL=t.get("dbgplanarpyr")!=="0",QL=t.get("dbgssrpyr")!=="0",JL=t.get("dbgssrhalf")!=="0",tF=t.get("dbgssrresolve")!=="0";let r=t.get("dbgprefilter");r==="0"?ME="off":r==="base"?ME="base":r==="k4"&&(XL="k4")}catch{}Yf=[null,null,null,null],Ght=IR.prototype._projectObject,(N5=rF=class extends IR{constructor(t={}){var e;super({canvas:t.canvas,alpha:t.alpha??!0,antialias:t.antialias??!1,forceWebGL:t.forceWebGL??!1,powerPreference:t.powerPreference,trackTimestamp:t.trackTimestamp??globalThis.__SPLINE_TRACK_TIMESTAMP__===!0,stencil:!1,requiredLimits:t.requiredLimits,canvasColorSpace:"display-p3",outputBufferType:$L?si:bl,asyncCompilation:t.asyncCompilation===!0||t.asyncCompilation==="load"}),this.viewportWidth=1,this.viewportHeight=1,this.resolution=new Y,this.dummyCamera=new zs,this.sceneTransitionDuration=0,this.sceneTransitionTimeRemaining=-1,this.manageShadowUpdates=!1,this.forceShadowUpdates=!1,this._shadowMapMissingAtSync=!1,this._shadowSyncPromotions=-1,this._lightShadowStateDirty=!1,this._lightShadowSignatures=new WeakMap,this._shadowMapIds=new WeakMap,this._shadowMapIdSeq=0,this.temporalAAEnabled=!0,this.hdrChainActive=!1,this.isWebGPUSplineRenderer=!0,this.shadowFilterHook=aPt,this._gaugeSnapshot="",this._gaugeChangedAt=0,this._gaugeStallWarned=!1,this._skipStalls=new Pbt,this._stallWarned=!1,this._asyncCompilationMode=!1,this._asyncLoadWarmupsInFlight=0,this.sceneBundlesEnabled=!1,this.sceneBundlesForceRerecord=!1,this.disposeListenerLedger=new Ibt,this._appliedWidth=-1,this._appliedHeight=-1,this._appliedRatio=-1,this._bundleLists=null,this._bundleStates=new WeakMap,this._skySystem=null,this._envClaimScope=null,this._envClaimEpoch=-1,this._skyFeatureWarned=!1,this.skyAnimationAllowed=!1,this.skyEnvironmentNeeded=!0,this._bundledPages=new Set,this._bundleValveArmed=!1,this._destroyedSubmitErrors=0,this._destroyedSubmitLastFrame=-10,this._warmupTarget=null,this.renderStarted=!1,this._warmupInFlight=!1,this._warmupPendingTarget=null,this._warmupPendingMRT=null,this._grabWarmupTarget=null,this._warnedHelperIncompat=new WeakSet,this._maskLights=[],this._maskBlocked=!1,this.suppressShadowMask=!1,this._grabTargetEpoch=0,this._retiredGrabTargets=[],this._retiredGpuBuffers=[],this._bundleEpochDirty=!1,this._encodeMaterials={},this._transmissionChain=[],this._reflectionColorChain=[],this._reflectionDepthChain=[],this._reflectionPassesKey="",this._reflectionResolveMarchKey="",this._planarChain=[],this._frameSerial=0,this._asyncCompilationMode=t.asyncCompilation??!1,this._updateCompilationBurst(),X9&&function(){if(!K9){if(K9=!0,A5=()=>Vt.frameIndex.value,typeof GPUBuffer<"u"){let i=GPUBuffer.prototype.destroy;GPUBuffer.prototype.destroy=function(){return hht("buffer",this.label,this.size),i.call(this)}}if(typeof GPUTexture<"u"){let i=GPUTexture.prototype.destroy;GPUTexture.prototype.destroy=function(){return hht("texture",this.label,`${this.width}x${this.height}`),i.call(this)}}console.info("[spline/webgpu] ?dbgdestroys=1 \u2014 GPU resource destroy logging armed; reproduce the error and read the [dbgdestroys] dumps")}}(),this.pipeline=new Sq(this),this.library.addLight(ibt,M5),this.shadowMap.enabled=!0,this.shadowMap.type=d4,e=this.backend?.isWebGPUBackend===!0,D2=e,this._deferGpuBufferDestruction(),function(i){let r=i;if(r==null||typeof r._draw!="function"||r.__splineDrawGuardInstalled===!0)return;r.__splineDrawGuardInstalled=!0;let s=r._draw.bind(r);r._draw=function(n,a,o,l,h,u,d,c,p){if(d.vertexCount>0&&n.getIndex()===null&&n.getIndirect()===null&&n.object.isBatchedMesh!==!0){let m=d.firstVertex+d.vertexCount;for(let f=0;f<u.length;f++){let g=u[f];if(g.isInstancedBufferAttribute!==!0&&g.isInstancedInterleavedBuffer!==!0&&g.count!==void 0&&g.count<m)return}}return s(n,a,o,l,h,u,d,c,p)}}(this.backend),this.outputColorSpace=Hu,this.toneMapping=cl,function(i){let r=i.library;r.addLight(m7,PT),r.addLight(f7,pb),r.addLight(C9,cb),r.lightNodes.delete(FS),r.lightNodes.delete(Wg),r.addLight(m7,FS),r.addLight(f7,Wg)}(this),this.sceneBundlesEnabled=t.sceneBundles===!0||t.sceneBundles==="rerecord",this.sceneBundlesForceRerecord=t.sceneBundles==="rerecord",this.auxiliary=t.auxiliary===!0,this.domElement.removeAttribute?.("data-engine")}advanceFrame(){let t=this._nodes,e=this.info;e.autoReset===!0&&e.reset(),t.nodeFrame.update(),e.frame=t.nodeFrame.frameId}get lastFrameIncomplete(){return!!(this._warmupInFlight||this._compilationHasWork&&!this._gaugesStalled)||(this._skippedAsyncDraws??0)!==0&&!this._skipStalls.stalled}get _gaugesStalled(){return this._gaugeChangedAt>0&&performance.now()-this._gaugeChangedAt>rF._GAUGE_STALL_MS}_trackGaugeStall(){let t=this._asyncCompilationGauges,e=t!==void 0&&(t.queued>0||t.pipelines>0),i=e?`${t.queued}/${t.pipelines}`:"";return e?i!==this._gaugeSnapshot?(this._gaugeSnapshot=i,void(this._gaugeChangedAt=performance.now())):void(this._gaugesStalled&&!this._gaugeStallWarned&&(this._gaugeStallWarned=!0,console.warn(`[spline/webgpu] async pipeline driver stalled (${i} in flight, no movement for ${rF._GAUGE_STALL_MS}ms) \u2014 treating frames as final so screenshots, thumbnails and the on-demand render loop keep working.`))):(this._gaugeSnapshot="",void(this._gaugeChangedAt=0))}_trackStalledSkips(t){let e=this._compilationHasWork&&!this._gaugesStalled;this._skipStalls.update(t,e),He.stalledSkipFrames=this._skipStalls.frames,this._skipStalls.stalled&&!this._stallWarned&&(this._stallWarned=!0,console.warn(`[spline/webgpu] ${t} draw(s) are permanently skipped \u2014 their render pipelines never became ready (look for "pipeline creation failed" above). Those objects will not appear; the frame is treated as final so screenshots, thumbnails and the on-demand render loop keep working.`))}get _asyncCompilationGauges(){return this.info.asyncCompilation}get _compilationHasWork(){let t=this._asyncCompilationGauges;return t!==void 0&&(t.queued>0||t.pipelines>0)}get asyncCompilationEnabled(){return this._asyncCompilation===!0}setAsyncCompilationPolicy(t){this._asyncCompilationMode!==t&&(this._asyncCompilationMode=t,this._setThreeAsyncCompilation(t),this._updateCompilationBurst())}get taaHistory(){return this._taaHistory||(this._taaHistory=Tbt()),this._taaHistory}async init(){await super.init(),function(e,i=Tq){if(!function(a){return a.isWebGPUBackend===!0}(e)||e.__splineTextureClampInstalled===!0)return;e.__splineTextureClampInstalled=!0;let r=e.createTexture.bind(e),s=e.updateTexture.bind(e),n=()=>e.device?.limits.maxTextureDimension2D??0;e.createTexture=(a,o)=>{uht(a,o,n(),i),r(a,o)},e.updateTexture=(a,o)=>{uht(a,o,n(),i),s(a,o)}}(this.backend);let t=this.backend.gl;if(t&&"drawingBufferColorSpace"in t)try{t.drawingBufferColorSpace="display-p3"}catch(e){console.warn(e)}return this.backend.device?.lost?.then(e=>{He.deviceLost=`${e?.reason??"unknown"}: ${e?.message??""}`.trim()}),this}setSize(t,e,i=!0){if(this._appliedWidth!==t||this._appliedHeight!==e||this._appliedRatio!==this.getPixelRatio()){this._appliedWidth=t,this._appliedHeight=e,this._appliedRatio=this.getPixelRatio();let r=this.viewportWidth!==t||this.viewportHeight!==e;this.viewportWidth=t,this.viewportHeight=e,super.setSize(t,e,i),r&&this.pipeline.resize(t,e,i)}return this}setPixelRatio(t=1){return this.getPixelRatio()!==t&&super.setPixelRatio(t),this}get hdTransmission(){return Vt.transmissionLod.value===1}set hdTransmission(t){Vt.transmissionLod.value=t===!0?1:2}renderScenePass(t,e){this.render(t,e)}_projectObject(t,e,i,r,s){let n=this,a=n._renderLists;t.isBundleGroup===!0&&r===a.get(t,e)&&(n._renderLists=this._bundleLists??(this._bundleLists=new a.constructor(a.lighting,a.objects)));try{Ght.call(this,t,e,i,r,s)}finally{n._renderLists=a}}_renderObjects(t,e,i,r,s=null){let n=this,a=s===null&&i.overrideMaterial===null;for(let o=0,l=t.length;o<l;o++){let{object:h,geometry:u,material:d,group:c,clippingContext:p}=t[o];if(a&&nht(d))this._renderWithDepthPrepass(h,i,e,u,d,c,r,p);else{if(a&&this._drawsStalePrepass(h,d,r,s)){let m=d,f=(g,y)=>n._handleObjectFunction(h,g,i,e,r,c,p,y);d.side!==Xs||d.forceSinglePass?f(m.getDepthPrepassTwin(d.side),null):(f(m.getDepthPrepassTwin(ln),null),d.side=ln,f(d,"backSide"),d.side=Xs,f(m.getDepthPrepassTwin(Fo),null))}n._currentRenderObjectFunction(h,i,e,u,d,c,r,p,s)}}}_renderTransparents(t,e,i,r,s){IR.prototype._renderTransparents.call(this,t,e,i,r,s);let n=this.pipeline.depthOfFieldDepthTexture;if(n===null||this.getRenderTarget()?.depthTexture!==n)return;let a=this;for(let{object:o,material:l,group:h,clippingContext:u}of t)!nht(l)||l.getDepthOfFieldTwin===void 0||(a._handleObjectFunction(o,l.getDepthOfFieldTwin(l.side),r,i,s,h,u,null),He.depthOfFieldTwinDraws++)}_drawsStalePrepass(t,e,i,r){if(e.transparent||!this.asyncCompilationEnabled||!("getDepthPrepassTwin"in e))return!1;Yf[0]=t,Yf[1]=e,Yf[2]=this._currentRenderContext,Yf[3]=i;let s=this._objects.getChainMap(r).get(Yf)?.drawMaterial;return Yf.fill(null),s?.transparent===!0&&s.depthWrite===!1}_renderWithDepthPrepass(t,e,i,r,s,n,a,o){let l=this,h=(d,c)=>l._handleObjectFunction(t,d,e,i,a,n,o,c),u=n;t.onBeforeRender(this,e,i,r,s,u),s.side===Xs&&s.forceSinglePass===!1?(h(s.getDepthPrepassTwin(ln),null),s.side=ln,h(s,"backSide"),h(s.getDepthPrepassTwin(Fo),null),s.side=Fo,h(s,null),s.side=Xs,He.depthPrepassDraws+=2):(h(s.getDepthPrepassTwin(s.side),null),h(s,null),He.depthPrepassDraws++),t.onAfterRender(this,e,i,r,s,u)}get skySystem(){return this._skySystem}get skyAnimationActive(){return this._skySystem?.animationActive===!0}*_liveBundledPages(){for(let t of this._bundledPages){let e=t.deref();e===void 0?this._bundledPages.delete(t):yield e}}_armBundleValve(){if(this._bundleValveArmed)return;let t=this.backend.device;typeof t?.addEventListener=="function"&&(this._bundleValveArmed=!0,t.addEventListener("uncapturederror",e=>{if(!this.sceneBundlesEnabled||!(e?.error?.message??"").toLowerCase().includes("destroyed"))return;let i=Vt.frameIndex.value,r=(i-this._destroyedSubmitLastFrame+16)%16;if(this._destroyedSubmitErrors=r<=2?this._destroyedSubmitErrors+1:1,this._destroyedSubmitLastFrame=i,!(this._destroyedSubmitErrors<4)){this.sceneBundlesEnabled=!1,He.bundleDisabled=!0;for(let s of this._liveBundledPages()){let n=this._bundleStates.get(s);n&&(n.disabled=!0),s.isBundleGroup=!1}this._bundledPages.clear()}}))}_updateSceneBundle(t,e){if(this.backend.beginBundle===void 0)return;let i=this._bundleStates.get(t);if(i===void 0){let d={signature:-1,rebuilds:0,resourceRebuilds:0,checks:0,disabled:!1,camHash:0,prevCamHash:0,epoch:0,lastEpoch:0,bufferIds:new WeakMap,bufferIdSeq:0,watched:new WeakSet,onResourceDispose:()=>{d.epoch++}};i=d,this._bundleStates.set(t,i),this._bundledPages.add(new WeakRef(t)),this._armBundleValve()}let r=t;if(i.disabled)return;{let d=e.matrixWorld.elements,c=e.projectionMatrix.elements,p=-2128831035;for(let m=0;m<16;m++)p^=1e4*d[m]|0,p=Math.imul(p,16777619),p^=1e4*c[m]|0,p=Math.imul(p,16777619);i.camHash=p}let s=-2128831035,n=d=>{s^=0|d,s=Math.imul(s,16777619)};n(this._grabTargetEpoch),n(t.fog!==null?1:0),n(this.pipeline.depthOfFieldDepthTexture!==null?1:0);let a=i,o=d=>{let c=d;!c||typeof c.addEventListener!="function"||a.watched.has(c)||(a.watched.add(c),c.addEventListener("dispose",a.onResourceDispose))},l=d=>{if(!d)return 0;let c=a.bufferIds.get(d);return c===void 0&&(c=++a.bufferIdSeq,a.bufferIds.set(d,c)),c},h=d=>{o(d),n(d.id),n(d.version),n(d.transparent===!0?1:0),typeof d.assetsLoaded=="function"&&n(d.assetsLoaded()?1:0)},u=!1;if(t.traverse(d=>{let c=d;if(c.isMesh===!0||c.isLine===!0||c.isPoints===!0||c.isSprite===!0){let p=c;p.isDecalObject===!0&&typeof p.updateDecal=="function"&&p.updateDecal()&&(u=!0),c.runBeforeRenderWhenBundled===!0&&c.onBeforeRender(this,t,e,c.geometry,c.material,null),c.frustumCulled&&(c.frustumCulled=!1),n(c.id),n(c.visible?1:0),n(c.layers.mask),n(c.renderOrder),n(c.matrixWorld.determinantAffine()<0?1:0);let m=c.geometry;o(m),n(m.id),n(m.drawRange.start),n(m.drawRange.count===1/0?-1:m.drawRange.count),n(l(m.index)),n(l(m.attributes.position)),n(m.instanceCount??-1),n(c.count===void 0?-1:c.count);let f=c;n(f.isSkinnedMesh===!0&&f.skeleton?f.skeleton.bones.length:-1);let g=c.material;if(Array.isArray(g))for(let y of g)h(y);else g&&h(g)}else d.isLight===!0?(n(d.id),n(d.visible?1:0),n(d.castShadow?1:0)):(n(d.id),n(d.visible?1:0))}),n(i.epoch),i.checks++,He.bundleChecks=i.checks,i.checks%600==0){let d=this._bundleDebug;He.bundleIncompleteRecords=d?.incompleteRecords??0,He.bundleRecords=d?.records??0,He.bundleReplays=d?.replays??0,i.prevCamHash=i.camHash}if(r.isBundleGroup!==!0)return function(d){let c=d;Object.getOwnPropertyDescriptor(c,"needsUpdate")?.set||Object.defineProperty(c,"needsUpdate",{configurable:!0,enumerable:!1,get:()=>!1,set(p){p===!0&&(this.version=(this.version??0)+1)}}),c.isBundleGroup=!0,c.static=!0,typeof c.version!="number"&&(c.version=0)}(t),void(i.signature=s);if(this.sceneBundlesForceRerecord)return r.version=(r.version??0)+1,void(i.signature=s);if(s!==i.signature){if(i.signature=s,r.version=(r.version??0)+1,i.epoch!==i.lastEpoch||u)return i.lastEpoch=i.epoch,i.resourceRebuilds++,void(He.bundleResourceRebuilds=i.resourceRebuilds);i.rebuilds++,He.bundleRebuilds=i.rebuilds,i.checks>30&&i.rebuilds/i.checks>.1&&(i.disabled=!0,r.isBundleGroup=!1,He.bundleDisabled=!0)}}_ensureWarmupTarget(){if(this._warmupTarget===null){let t=new ii(2,2,{count:2});t.textures[0].name="output",t.textures[0].type=bl,t.textures[1].name="velocity",t.textures[1].type=si;let e=new Ha(2,2);e.isRenderTargetTexture=!0,t.depthTexture=e,this._warmupTarget=t}return this._warmupTarget}get warmupInFlight(){return this._warmupInFlight}setRenderTarget(t,e=0,i=0){this._warmupInFlight?this._warmupPendingTarget=[t,e,i]:super.setRenderTarget(t,e,i)}setMRT(t){return this._warmupInFlight?(this._warmupPendingMRT=[t],this):(super.setMRT(t),this)}async compileSceneAsync(t,e){if(!e)return;{let s=t instanceof Vg?t.activePage:t;fht(gv.isSoft(s?.data?.shadow)),s&&tht(s)}if(this._asyncCompilationMode!==!1)return this._asyncCompilationMode==="load"&&(this._setThreeAsyncCompilation(!0),this._updateCompilationBurst()),this._compileSceneAsyncBackground(t,e);if(this.renderStarted||this._warmupInFlight)return;let i=this.getRenderTarget(),r=this.getMRT();this._warmupInFlight=!0,this._warmupPendingTarget=null,this._warmupPendingMRT=null,this._updateCompilationBurst();try{this.normalizeCameraCoordinateSystem(e),this.temporalAAEnabled&&(super.setRenderTarget(this._ensureWarmupTarget()),super.setMRT(UL())),await this.compileAsync(t,e)}catch(s){console.warn("[spline/webgpu] pipeline warm-up failed:",s)}finally{let s=this._warmupPendingTarget,n=this._warmupPendingMRT;this._warmupInFlight=!1,this._warmupPendingTarget=null,this._warmupPendingMRT=null,this._updateCompilationBurst(),s!==null?super.setRenderTarget(s[0],s[1],s[2]):super.setRenderTarget(i),n!==null?super.setMRT(n[0]):super.setMRT(r)}}async _compileSceneAsyncBackground(t,e){this._asyncLoadWarmupsInFlight++,this._updateCompilationBurst();try{await this.init(),this.normalizeCameraCoordinateSystem(e);let i,r=this.getRenderTarget(),s=this.getMRT();try{this.temporalAAEnabled&&(super.setRenderTarget(this._ensureWarmupTarget()),super.setMRT(UL())),i=this.compileAsync(t,e)}finally{super.setRenderTarget(r),super.setMRT(s)}let n=this._warmupGrabContext(t,e);await i,await n}catch(i){console.warn("[spline/webgpu] pipeline warm-up failed:",i)}finally{this._asyncLoadWarmupsInFlight--,this._updateCompilationBurst(),this._maybeCloseAsyncLoadWindow()}}_disposeWarmupTargets(){this._warmupTarget?.depthTexture?.dispose(),this._warmupTarget?.dispose(),this._warmupTarget=null,this._grabWarmupTarget?.depthTexture?.dispose(),this._grabWarmupTarget?.dispose(),this._grabWarmupTarget=null}_warmupGrabContext(t,e){let i=t instanceof Vg?t:t.scene;if(i.needsTransmission?.()!==!0&&i.needsReflection?.()!==!0)return null;if(this._grabWarmupTarget===null){let n=new ii(2,2);n.texture.type=bl;let a=new Ha(2,2);a.isRenderTargetTexture=!0,n.depthTexture=a,this._grabWarmupTarget=n}let r=this.getRenderTarget(),s=this.getMRT();try{return super.setRenderTarget(this._grabWarmupTarget),super.setMRT(null),this.compileAsync(t,e)}finally{super.setRenderTarget(r),super.setMRT(s)}}_setThreeAsyncCompilation(t){this.setAsyncCompilation(t)}_updateCompilationBurst(){let t=this._warmupInFlight||this._asyncLoadWarmupsInFlight>0||this._asyncCompilationMode==="load"&&this.asyncCompilationEnabled;this.setCompilationBurst(t),He.compilationBurst=t}_maybeCloseAsyncLoadWindow(){this._asyncCompilationMode==="load"&&(!this.asyncCompilationEnabled||this._asyncLoadWarmupsInFlight>0||this._frameSerial!==0&&((this._skippedAsyncDraws??0)>0&&!this._skipStalls.stalled||this._compilationHasWork||(this._setThreeAsyncCompilation(!1),this._updateCompilationBurst())))}normalizeCameraCoordinateSystem(t){let e=t;(e.coordinateSystem!==this.coordinateSystem||e.perspCamera!==void 0&&e.perspCamera.coordinateSystem!==this.coordinateSystem||e.orthoCamera!==void 0&&e.orthoCamera.coordinateSystem!==this.coordinateSystem)&&(e.coordinateSystem=this.coordinateSystem,e.perspCamera!==void 0&&(e.perspCamera.coordinateSystem=this.coordinateSystem),e.orthoCamera!==void 0&&(e.orthoCamera.coordinateSystem=this.coordinateSystem),t.updateProjectionMatrix?.())}_prepareHelpers(t,e,i){t.traverse(r=>{let s=r;if(r.isPoints===!0){let l=function(h){if(Array.isArray(h.material)||h.parent===null||h.geometry.getAttribute("position")===void 0)return null;let u=h.material;return u.isNodeMaterial===!0?null:u.isPointsMaterial===!0?function(d,c){if(c.size<=1)return null;let p=u7.get(d);return p&&(p.epoch!==U1||p.srcMaterial!==c||p.geometry!==d.geometry||p.position.src!==d.geometry.getAttribute("position")||p.map!==c.map||p.selectedMap!==Iht(d))&&(p.sprite.removeFromParent(),p.material.dispose(),p=void 0),p||(p=function(m,f){let g=m.geometry,y=g.getAttribute("position"),v=g.getAttribute("aSelection"),b=g.getAttribute("aVisibility"),_=f.map,x=Iht(m),S=new co(y.array,3);S.setUsage($h);let w={src:y,attr:S,version:y.version},T=[],C=k=>{let B=new co(new Float32Array(k.count),1);B.setUsage($h);let V={src:k,attr:B,version:k.version};return _E(V),T.push(V),V},M=v?C(v):null,A=b?C(b):null,P=new iT;P.name=`SplinePointsTwin(${f.name||f.type})`,P.positionNode=qp(w.attr,"vec3"),P.size=f.size,P.sizeAttenuation=f.sizeAttenuation,P.transparent=f.transparent,P.depthTest=f.depthTest,P.depthWrite=f.depthWrite,P.blending=f.blending,P.fog=!1;let O=M?qp(M.attr,"float"):null,D=A?qp(A.attr,"float"):null;P.colorNode=At(()=>{D!==null?NR(D.lessThan(.5)):O!==null&&NR(O.greaterThan(.5));let k=_!==null?Jt(_,ui()):at(1);return(O!==null&&_!==null&&x!==null?$t(k,Jt(x,ui()),O):k).mul(at(cvt,1))})();let N=new J8(P);N.name=`SplinePointsTwin(${m.name||m.type})`,N.frustumCulled=!1,N.raycast=()=>{};let z={sprite:N,material:P,srcMaterial:f,geometry:g,map:_,selectedMap:x,position:w,mirrors:T,epoch:U1};return I2.add(new WeakRef(z)),z}(d,c),u7.set(d,p)),p.sprite.parent!==d.parent&&d.parent.add(p.sprite),function(m,f){let{sprite:g,position:y,srcMaterial:v}=f;y.version!==y.src.version&&(f.position.attr.needsUpdate=!0,y.version=y.src.version);for(let _ of f.mirrors)_.version!==_.src.version&&(_E(_),_.version=_.src.version);let b=Math.max(0,Math.min(f.geometry.drawRange.count,y.src.count));g.count=b,f.material.size=v.size,f.material.opacity=v.opacity,f.material.color.copy(v.color),g.layers.mask=m.layers.mask,g.renderOrder=m.renderOrder}(d,p),p.sprite}(h,u):function(d,c){if(c.isShaderMaterial!==!0)return!1;let p=c.uniforms,m=p?.pointSize?.value,f=p?.color?.value;return typeof m=="number"&&m>1&&Array.isArray(f)&&f.length>=3&&d.geometry.getAttribute("hover")!==void 0&&d.geometry.getAttribute("selected")!==void 0}(h,u)?function(d,c){let p=d7.get(d);return p&&(p.epoch!==U1||p.srcMaterial!==c||p.geometry!==d.geometry||!function(m,f){let g=[[m.position,"position"],[m.hover,"hover"],[m.selected,"selected"]];for(let[y,v]of g){let b=f.getAttribute(v);if(b===void 0)return!1;if(y.src!==b){if(b.count!==y.attr.count)return!1;y.src=b,y.version=-1}}return!0}(p,d.geometry))&&(p.sprite.removeFromParent(),p.material.dispose(),p=void 0),p||(p=function(m,f){let g=m.geometry,y=f.uniforms,v=(O,D)=>{let N=new co(new Float32Array(O.count*D),D);N.setUsage($h);let z={src:O,attr:N,version:O.version};return _E(z),z},b=v(g.getAttribute("position"),3),_=v(g.getAttribute("hover"),1),x=v(g.getAttribute("selected"),1),S=mt(y.pointSize.value),w=mt(new se().fromArray(y.color.value)),T=new iT;T.name=`SplinePointsTwin(${f.name||f.type})`,T.positionNode=qp(b.attr,"vec3");let C=qp(_.attr,"float"),M=qp(x.attr,"float");T.sizeNode=S.add(C.mul(4)),T.sizeAttenuation=!1,T.transparent=f.transparent,T.depthTest=f.depthTest,T.depthWrite=f.depthWrite,T.blending=f.blending,T.fog=!1,T.colorNode=At(()=>{let O=ci(ui().mul(2).sub(1)).toVar();NR(O.greaterThan(1));let D=pi(M.equal(1),j(.22,.9,.7),w.add(C.mul(.25)));return at(pi(O.greaterThan(.75),j(1),D),1)})();let A=new J8(T);A.name=`SplinePointsTwin(${m.name||m.type})`,A.frustumCulled=!1,A.raycast=()=>{};let P={sprite:A,material:T,srcMaterial:f,geometry:g,pointSize:S,color:w,position:b,hover:_,selected:x,epoch:U1};return I2.add(new WeakRef(P)),P}(d,c),d7.set(d,p)),p.sprite.parent!==d.parent&&d.parent.add(p.sprite),function(m,f){for(let v of[f.position,f.hover,f.selected])v.version!==v.src.version&&(_E(v),v.version=v.src.version);let g=f.srcMaterial.uniforms;f.pointSize.value=g.pointSize.value,f.color.value.fromArray(g.color.value);let y=Math.max(0,Math.min(f.geometry.drawRange.count,f.position.src.count));f.sprite.count=y,f.material.opacity=f.srcMaterial.opacity,f.sprite.layers.mask=m.layers.mask,f.sprite.renderOrder=m.renderOrder}(d,p),p.sprite}(h,u):null}(r);if(l!==null)return l.visible=s.visible,void(s.visible&&(e.push(s),s.visible=!1))}let n=!1,a="",o=Array.isArray(s.material)?s.material:s.material?[s.material]:[];for(let l of o){let h=l;if(h.isShaderMaterial===!0&&h.isNodeMaterial!==!0){n=!0,a=`WebGL-only material "${h.type}"`;break}}if(n&&!Array.isArray(s.material)){let l=function(h){return h.isLineMaterial===!0?function(u){let d=h7.get(u);if(!d||d.epoch!==$R){let g=new U1t;g.name=`SplineHelperTwin(${u.name||u.type})`,g.worldUnits=!1,d={twin:g,epoch:$R},h7.set(u,d),HR.add(new WeakRef(g))}let c=d.twin,p=u;c.color.copy(p.color),c.linewidth=p.linewidth,c.opacity=p.opacity,c.transparent=p.transparent,c.depthTest=p.depthTest,c.depthWrite=p.depthWrite,c.side=p.side;let m=p.dashed===!0;if(c.dashed!==m&&(c.dashed=m,c.needsUpdate=!0),m){let g=c;g.dashScale=p.dashScale??1,g.dashSize=p.dashSize??1,g.gapSize=p.gapSize??1}let f=p.vertexColors===!0||p.vertexColors===2;return c.vertexColors!==f&&(c.vertexColors=f,c.needsUpdate=!0),c}(h):null}(s.material);if(l)return i.push({object:s,original:s.material}),void(s.material=l)}!n&&s.geometry?.isInstancedBufferGeometry===!0&&!Number.isFinite(s.geometry.instanceCount??0)&&(n=!0,a="infinite instanceCount geometry"),n&&s.visible&&(this._warnedHelperIncompat.has(r)||this._warnedHelperIncompat.add(r),e.push(s),s.visible=!1)})}renderHelperOverlay(t,e,i,r){let s=[],n=[];if(t&&this._prepareHelpers(t,s,n),e&&this._prepareHelpers(e,s,n),r)this._helperOverlay??(this._helperOverlay=new Dbt),this._helperOverlay.render(this,t,e,i,r),He.helperOverlayMode="smaa";else{let a=this.autoClear;this.autoClear=!1,t&&this.render(t,i),e&&(this.clearDepth(),this.render(e,i)),this.autoClear=a,He.helperOverlayMode="direct"}for(let a of n)a.object.material=a.original;for(let a of s)a.visible=!0}createEffectChain(){return function(t){let e=t.pipeline,i=e.postprocessingState,r=i.enabled===!0,s=Avt(e.scene,e.camera),n=t.hdrChainActive;try{let M=new URLSearchParams(window.location.search).get("dbgfp16");(M==="scene"||M==="st")&&(n=!0)}catch{}let a=s.getTextureNode(),o=a,l=null;if(t.temporalAAEnabled){s.setMRT(UL()),l=function(M,A,P,O,D=!1){return new Ebt(M,A,P,O,D)}(a,s.getTextureNode("depth"),s.getTextureNode("velocity"),t.taaHistory,n),o=l,s.getTexture("velocity").type=si;try{if(new URLSearchParams(window.location.search).get("dbgvel")==="1"){let M=Oh(s.getTextureNode("velocity"));o=at(XR(M.x).mul(20).add(.5),XR(M.y).mul(20).add(.5),I(.5),I(1))}}catch{}}n?s.getTexture("output").type=si:jD()&&(s.getTexture("output").internalFormat="rgba8unorm-srgb");let h=(M,A)=>typeof M=="number"&&Number.isFinite(M)?M:A,u={bloomIntensity:mt(1),caOffset:mt(new Y(0,0)),caAspect:mt(1),vignetteOffset:mt(0),vignetteDarkness:mt(0),hueVector:mt(new E(1,0,0)),saturationFactor:mt(0),brightness:mt(0),bcContrastScale:mt(1),dofFocusDistance:mt(0),dofFocalLength:mt(0),dofBokehScale:mt(1),dofCameraNear:mt(50),dofCameraFar:mt(1e4),dofOrtho:mt(0),pixelCells:mt(new Y(1,1)),bloomOpacity:mt(1),caOpacity:mt(1),vignetteOpacity:mt(1),noiseOpacity:mt(1),hueSaturationOpacity:mt(1),brightnessContrastOpacity:mt(1),dofOpacity:mt(1)},d=M=>XR(M),c=(M,A)=>{u.bloomIntensity.value=h(M.bloom.intensity,1),u.bloomOpacity.value=h(M.bloom.opacity,1),u.caOffset.value.set(h(M.chromaticAberration.offset?.[0],10),h(M.chromaticAberration.offset?.[1],10)),u.caOpacity.value=h(M.chromaticAberration.opacity,1),u.vignetteOffset.value=h(M.vignette.offset,.5),u.vignetteDarkness.value=h(M.vignette.darkness,.5),u.vignetteOpacity.value=h(M.vignette.opacity,1),u.noiseOpacity.value=h(M.noise.opacity,1),u.hueVector.value.fromArray(function(V){let q=Math.sin(V),W=Math.cos(V);return[(2*W+1)/3,(-Math.sqrt(3)*q-W+1)/3,(Math.sqrt(3)*q-W+1)/3]}(h(M.hueSaturation.hue,0))),u.saturationFactor.value=function(V){return V>0?1-1/(1.001-V):-V}(h(M.hueSaturation.saturation,0)),u.hueSaturationOpacity.value=h(M.hueSaturation.opacity,1),u.brightness.value=h(M.brightnessContrast.brightness,0);let P=Math.min(h(M.brightnessContrast.contrast,0),.9999);u.bcContrastScale.value=P>0?1/(1-P):1+P,u.brightnessContrastOpacity.value=h(M.brightnessContrast.opacity,1);let O=e.camera,D=O?.isPerspectiveCamera===!0,N=function(V,q,W){return{focusDistance:W?V/2e3:(V+992)/2e3,focusRange:Math.max(q/2e3,1e-6)}}(h(M.depthOfField.focusDistance,jR.focusDistance),h(M.depthOfField.focalLength,jR.focalLength),D);u.dofFocusDistance.value=N.focusDistance,u.dofFocalLength.value=N.focusRange,u.dofBokehScale.value=h(M.depthOfField.bokehScale,jR.bokehScale),u.dofOpacity.value=h(M.depthOfField.opacity,1),u.dofCameraNear.value=h(O?.near,50),u.dofCameraFar.value=h(O?.far,1e4),u.dofOrtho.value=D?0:1;let z=A.resolution.x?A.resolution:new Y(A.viewportWidth*A.getPixelRatio(),A.viewportHeight*A.getPixelRatio());u.caAspect.value=z.y>0?z.x/z.y:1;let k=Math.floor(h(M.pixelation.granularity,30));k%2>0&&(k+=1);let B=k>0;u.pixelCells.value.set(B?z.x/k:z.x,B?z.y/k:z.y)};c(i,t);let p=Oh(o),m=p.rgb,f=p.a,g=r&&i.pixelation.enabled,y=u.pixelCells,v=M=>M.mul(y).floor().add(.5).div(y),b=l?l.outputTextureNode:a;if(g){let M=Oh(b.sample(v(ui())));m=$t(m,M.rgb,1),f=$t(f,M.a,1)}if(r&&i.chromaticAberration.enabled){let M=i.chromaticAberration,A=u.caOffset.mul(.001).mul(st(1,d(u.caAspect))),P=z=>g?v(z):z,O=Oh(b.sample(P(ui().add(A)))),D=Oh(b.sample(P(ui().sub(A)))),N=Kt(Kt(O.a,D.a),f);m=qf(m,j(O.r,m.g,D.b),M.blendFunction,d(u.caOpacity),N),f=FL(f,N,M.blendFunction,d(u.caOpacity))}let _=null;if(r&&i.depthOfField.enabled){let M=hQ("depthOfField");if(M){let A=i.depthOfField;_=M(at(m,f),b,s.getTextureNode("depth"),{focusDistance:d(u.dofFocusDistance),focusRange:d(u.dofFocalLength),bokehScale:d(u.dofBokehScale),cameraNear:d(u.dofCameraNear),cameraFar:d(u.dofCameraFar),orthographic:d(u.dofOrtho)},{halfFloat:n,inputUv:g?v:void 0});let P=Oh(_);m=qf(m,P.rgb,A.blendFunction,d(u.dofOpacity),P.a),f=FL(f,P.a,A.blendFunction,d(u.dofOpacity))}else uQ("depthOfField","webgpu")}let x=null;if(r&&i.bloom.enabled){let M=hQ("bloom");if(M){let A=i.bloom;x=M(l?l.outputTextureNode:a,{kernelSize:I3t(A.kernelSize),blurScale:h(A.blurScale,1),luminanceThreshold:h(A.luminanceThreshold,.9),luminanceSmoothing:h(A.luminanceSmoothing,.025)});let P=Te(Oh(x).mul(d(u.bloomIntensity)),0,1);m=qf(m,P.rgb,A.blendFunction,d(u.bloomOpacity),P.a),f=FL(f,P.a,A.blendFunction,d(u.bloomOpacity))}else uQ("bloom","webgpu")}if(r&&i.hueSaturation.enabled){let M=i.hueSaturation,A=u.hueVector,P=j(Bt(m,A),Bt(m,A.zxy),Bt(m,A.yzx)),O=P.r.add(P.g).add(P.b).div(3);m=qf(m,P.add(j(O).sub(P).mul(d(u.saturationFactor))).min(1),M.blendFunction,d(u.hueSaturationOpacity),f)}if(r&&i.brightnessContrast.enabled){let M=i.brightnessContrast,A=m.add(j(d(u.brightness)));A=A.sub(.5).mul(d(u.bcContrastScale)).add(.5),m=qf(m,A.min(1),M.blendFunction,d(u.brightnessContrastOpacity),f)}if(r&&i.vignette.enabled){let M=i.vignette,A=ci(ui().sub(.5)).mul(d(u.vignetteDarkness).add(d(u.vignetteOffset))),P=Ji(d(u.vignetteOffset).mul(.799),I(.8),A).oneMinus();m=qf(m,m.mul(P),M.blendFunction,d(u.vignetteOpacity),f)}if(r&&i.noise.enabled){let M=i.noise,A=Di(Bn(qh(Bt(ui().mul(Uvt),st(12.9898,78.233)),Math.PI)).mul(43758.5453));m=qf(m,j(A),M.blendFunction,d(u.noiseOpacity),f)}r&&(n?m=m.max(0):(m=Te(m,0,1),f=Te(f,0,1)));let S=at(m,f);if(e.uiOverlayEnabled&&e.uiCanvasTexture){let M=Oh(Jt(e.uiCanvasTexture,ui().flipY())),A=$t(S.rgb,M.rgb,M.a),P=Te(S.a.add(M.a),0,1);S=at(A,P)}let w=e.sceneTransitionFromTexture;if(w){let M=Oh(Jt(w,ui())),A=e.sceneTransitionPass.uniforms.mixRatio;S=$t(M,S,A)}let T=e.watermarkTexture;if(T){let M=T.image,A=M?.width||128,P=M?.height||32,O=new Y(t.viewportWidth*t.getPixelRatio(),t.viewportHeight*t.getPixelRatio()),D=12*t.getPixelRatio(),N=.5*A*t.getPixelRatio(),z=.5*P*t.getPixelRatio(),k=st((O.x-N-D)/O.x,D/O.y),B=st(N/O.x,z/O.y),V=ui().flipY().sub(k).div(B),q=V.x.greaterThanEqual(0).and(V.x.lessThanEqual(1)).and(V.y.greaterThanEqual(0)).and(V.y.lessThanEqual(1)),W=Te(V,0,1),H=Oh(Jt(T,W)),rt=H.a.mul(q.select(I(1),I(0)));S=at($t(S.rgb,H.rgb,rt),Te(S.a.add(rt),0,1))}let C=new G1t(t,S);return{syncValues:c,render(){s.scene=e.scene,s.camera=e.camera,C.render()},renderTAAResolve:l?M=>{s.scene=e.scene,s.camera=e.camera,l.renderResolve(M)}:null,renderBloomPasses:x?M=>{s.scene=e.scene,s.camera=e.camera,x.renderBloom(M)}:null,renderDoFPasses:_?M=>{s.scene=e.scene,s.camera=e.camera,_.renderDoF(M)}:null,resize(){},sceneDepthTexture:()=>s.renderTarget?.depthTexture??null,dispose(){l?.dispose(),x?.dispose(),_?.dispose(),s.dispose(),C.dispose()}}}(this)}renderSplineSceneWithDummyCamera(t,e,i=1){this.dummyCamera.updateCameraState(e.dataPatched),this.dummyCamera.matrix.copy(e.matrixWorld);let r=e.height,s=e.width,n=this.viewportWidth/this.viewportHeight;s<r?s=r*n:r=s/n,this.dummyCamera.setViewplaneSize(s,r);for(let a=0;a<i;a++)this.renderSplineScene(t,this.dummyCamera)}renderSplineScene(t,e,{sceneHelpers:i=this.sceneHelpers,sceneHelpersOnTop:r=this.sceneHelpersOnTop}={}){if(this._warmupInFlight)return;this._maybeCloseAsyncLoadWindow(),this._frameSerial++,this._disposeRetiredGrabTargets(),(Yj()?.drainRetired()??0)+(Zj()?.drainRetired()??0)>0&&this._retireBundleRecords(),X9&&function(y){if(y==null||y===Z9)return;let v=y;typeof v.addEventListener=="function"&&(Z9=y,v.addEventListener("uncapturederror",b=>{let _=b?.error?.message??"";!_.toLowerCase().includes("destroyed")||Y9<=0||(Y9--,console.warn(`[spline/webgpu][dbgdestroys] submit rejected at frame ${A5()} (t=${Math.round(performance.now())}ms):
|
|
2015
|
+
`)}),Ev.length>abt&&Ev.shift()}var X9,abt,Ev,Y9,A5,K9,Z9,iPt=U(()=>{X9=(()=>{try{return new URLSearchParams(window.location.search).get("dbgdestroys")==="1"}catch{return!1}})(),abt=32,Ev=[],Y9=6,A5=()=>-1,K9=!1,Z9=null}),rPt=U(()=>{});function uht(t,e,i,r=Tq){if(e===void 0||!(i>0))return!1;let{image:s,width:n,height:a}=e;if(s==null||n===void 0||a===void 0||n<=i&&a<=i||!function(d){return!(d.isRenderTargetTexture||d.isDepthTexture||d.isFramebufferTexture||d.isStorageTexture||d.isExternalTexture||d.isHTMLTexture||d.isDataTexture||d.isCompressedTexture||d.isCompressedArrayTexture||d.isCubeTexture||d.isArrayTexture||d.isDataArrayTexture||d.isData3DTexture||d.is3DTexture||d.mipmaps!==void 0&&d.mipmaps.length>0)}(t))return!1;let o=i/Math.max(n,a),l=Math.max(1,Math.min(i,Math.floor(n*o))),h=Math.max(1,Math.min(i,Math.floor(a*o))),u=null;try{u=r(s,l,h)}catch{u=null}return u!==null&&(e.image=u,e.width=l,e.height=h,e.needsMipmaps===!0&&(e.levels=Math.floor(Math.log2(Math.max(l,h)))+1),!0)}var Tq,sPt=U(()=>{Tq=(t,e,i)=>{let r;if(typeof OffscreenCanvas<"u")r=new OffscreenCanvas(e,i);else{if(!(typeof document<"u"))return null;r=document.createElement("canvas"),r.width=e,r.height=i}let s=r.getContext("2d");return s?(s.imageSmoothingEnabled=!0,s.imageSmoothingQuality="high",s.drawImage(t,0,0,e,i),r):null}});function Q9(t,e){let i=new ii(t,e,{depthBuffer:!1,type:Ye,format:Bo});return i.texture.generateMipmaps=!1,i.texture.minFilter=Re,i.texture.magFilter=Re,i}function J9(){return Kg===null&&((Kg=Q9(Tc*C5,Tc)).texture.name="SplinePCSSPyramidAtlas"),Kg.texture}function dht(t,e,i,r,s,n){let a=new Pe,o=Jt(e),l=At(()=>{let h=Qa,u=n!==0?R2(h.x).sub(n):R2(h.x),d=ct(u).mul(i).toVar(),c=ct(h.y).mul(i).toVar(),p=I(1e9).toVar(),m=I(-1e9).toVar();return Qi(e7("ly",i),e7("lx",i),f=>{let{lx:g,ly:y}=f,v=t7(i7(d.add(g),ct(0),ct(r))),b=t7(i7(c.add(y),ct(0),ct(r))),_=o.load(Yn(v,b));p.assign(ti(p,R2(_.x))),m.assign(Kt(m,R2(s?_.y:_.x)))}),at(p,m,0,1)})();return a.fragmentNode=l,a.name=t,a.lights=!1,a.blending=Wi,a.depthTest=!1,a.depthWrite=!1,a.needsUpdate=!0,a}function cht(t){let e=t;if(!e.__spePcssPyramid){e.__spePcssPyramid={fresh:!1,slot:-1,passKey:"",mid:null,small:null,toMid:null,toSmall:null};for(let i of Pv)i.deref()===void 0&&Pv.delete(i);Pv.add(new WeakRef(e.__spePcssPyramid))}return e.__spePcssPyramid}function pht(t){return t.__spePcssPyramid?.fresh===!0}function nPt(t){return t.__spePcssPyramid?.slot??-1}var Tc,C5,L1,R2,t7,e7,i7,Kg,Pv,WR,qR,r7,obt=U(()=>{ot(),cr(),je(),pn(),Tc=8,C5=8,L1=64,R2=t=>t,t7=t=>t,e7=(t,e)=>({start:ct(0),end:ct(e),type:"int",condition:"<",name:t}),i7=Te,Kg=null,Pv=new Set,WR=new Array(C5).fill(null),qR=!1,r7=new E});function Rv(t){let e=t;return e.__spePcssKnobs||(e.__spePcssKnobs={mapSize:mt(2048),radius:mt(1),penumbraSize:mt(.5),depthEps:mt(1e-4),penumbraFrameScale:mt(1),penumbraFrameOffset:mt(0),pyramidEnabled:mt(0),pyramidSlot:mt(0),maskChannel:mt(new Se(0,0,0,0)),planeNormalMat:mt(new Ms().set(0,0,0,0,0,0,0,0,0))}),e.__spePcssKnobs}function lbt(t,e){Rv(t).maskChannel.value.set(e===0?1:0,e===1?1:0,e===2?1:0,e===3?1:0)}function mht(t,e,i){let r=t,s=Rv(t);s.mapSize.value=r.mapSize?.x??2048,s.radius.value=r.radius??1,s.penumbraSize.value=e??r.penumbraSize??.5,r.camera?.isOrthographicCamera&&r.matrix?s.planeNormalMat.value.getNormalMatrix(r.matrix):s.planeNormalMat.value.set(0,0,0,0,0,0,0,0,0);let n=typeof r.camera?.far=="number"&&typeof r.camera?.near=="number"?r.camera.far-r.camera.near:0;s.depthEps.value=n>.001?pbt/n:1e-4;let a=t.__speRangeEnvelope,o=a?a.far-a.near:0;a&&o>.001&&n>.001&&r.camera?(s.penumbraFrameScale.value=n/o,s.penumbraFrameOffset.value=(r.camera.near-a.near)/o):(s.penumbraFrameScale.value=1,s.penumbraFrameOffset.value=0);let l=0;if(i&&i.fresh&&i.slot>=0&&E5()){let h=s.mapSize.value;Mq/1024+(2*s.radius.value+2)/Math.max(1,h)<=1/Tc&&(l=1)}return s.pyramidEnabled.value=mbt??l,s.pyramidSlot.value=Math.max(0,i?.slot??0),s.pyramidEnabled.value===1}function hbt(t,e){let i=F1(t.planeNormalMat.mul(e)).toVar(),r=$e(i.z),s=$e(Xu(r).add(Si(ke(r),I(0))).mul(Kt(ke(r),I(1e-4))));return zr(st($e(i.x).negate().div(s),$e(i.y).div(s))).toVar()}function s7(t,e,i,r,s,n,a){let o=dbt(),l=cbt(),h=n7(),u=Rv(e),d=$e(u.mapSize),c=zr(st(d,d)),p=$e(u.radius),m=$e(u.penumbraSize),f=Jt(t),g=S=>$e(f.load(Yn(Te(S,st(0),st(1)).mul(c))).x),y=I(1).div(c.x).toVar(),v=I(Mq).div(y.mul(1024)).toVar(),b=$e(u.depthEps),_=hbt(u,a),x=()=>{let S=I(0).toVar(),w=I(0).toVar();for(let M=0;M<l;M++){let A=zr(Sm(ct(M),ct(l),s)).mul(y).mul(v),P=g(zr(i.add(A))).toVar();vt(P.lessThan(r.add(P5(_,A)).add(b)),()=>{S.addAssign(P),w.addAssign(1)})}let T=I(0).toVar();vt(w.greaterThan(0),()=>{let M=S.div(w).toVar(),A=$e(u.penumbraFrameScale),P=$e(u.penumbraFrameOffset),O=r.sub(M).mul(A).div(M.mul(A).add(P)).toVar();T.assign(Te(O.mul(O).mul(200).mul(m),I(0),I(1)))});let C=I(0).toVar();for(let M=0;M<o;M++){let A=zr(Sm(ct(M),ct(o),s)).mul(y),P=zr(A.mul(p.mul(2)).add(A.mul(T.mul(v)))),O=$e(r.add(P5(_,P)));h?C.addAssign($e(Jt(t,zr(i.add(P))).compare(O))):C.addAssign(Si(O,g(zr(i.add(P)))))}n.assign(C.div(o))};if(E5()){let S=Jt(J9()),w=$e(u.pyramidEnabled),T=$e(u.pyramidSlot),C=I(Tc),M=I(0).toVar();vt(w.greaterThan(.5),()=>{let A=zr(Te(i,st(0),st(1))),P=$e(A.x.mul(C)).toVar(),O=$e(A.y.mul(C)).toVar(),D=T.mul(C),N=I(1e9).toVar(),z=I(-1e9).toVar();for(let V=-1;V<=1;V++)for(let q=-1;q<=1;q++){let W=Te(P.add(I(q)),I(0),C.sub(1)),H=Te(O.add(I(V)),I(0),C.sub(1)),rt=zr(st(W.add(D),H)),it=S.load(Yn(rt));N.assign(ti(N,$e(it.x))),z.assign(Kt(z,$e(it.y)))}let k=$e(y.mul(p.mul(2).add(v))),B=$e(ti(ci(_).mul(k),I(.05))).toVar();vt(N.greaterThanEqual(r.add(b).add(B)),()=>{M.assign(1)}).ElseIf(z.lessThan(r.sub(B)),()=>{M.assign(2)})}),vt(M.equal(1),()=>{n.assign(1)}).ElseIf(M.equal(2),()=>{n.assign(0)}).Else(x)}else x()}function aPt(t,e){let i=e;return i.isPointLight?(He.pcssHookServes++,D5):i.isSpotLight||i.isDirectionalLight?(He.pcssHookServes++,R5):null}function fht(t){Aq.value=t?1:0}function ght(t,e){return i=>{let r=function(a){let o=a,l={};if(o==null)return l;for(let h of fbt){let u=o[h];u!==void 0&&(l[h]=u)}return l}(i),s=$e(l7(t,r)),n=$e(l7(e,r));return At(()=>{let a=I(1).toVar();return vt($e(Aq).greaterThan(.5),()=>{a.assign(s)}).Else(()=>{a.assign(n)}),a})()}}var $e,zr,F1,cE,pE,mE,fE,D2,n7,E5,kL,a7,o7,ubt,Mq,nc,dbt,cbt,pbt,mbt,P5,yht,vht,bht,Aq,l7,fbt,R5,D5,gE,_ht,xht,gbt,ybt,vbt,bbt,_bt=U(()=>{je(),ot(),pn(),obt(),$e=t=>t,zr=t=>t,F1=t=>t,cE=!0,pE=!0,mE=!0,fE=!0;try{let t=new URLSearchParams(window.location.search),e=t.get("dbgpcss");e==="classic"||e==="0"?(cE=!1,pE=!1,mE=!1,fE=!1):(cE=t.get("dbgpcsssplit")!=="0",pE=t.get("dbgpcsshw")!=="0",mE=t.get("dbgpcsshiz")!=="0",fE=t.get("dbgshadowmask")!=="0")}catch{}D2=!1,n7=()=>pE&&D2,E5=()=>mE&&D2,kL=()=>fE&&D2,a7=()=>E5(),o7=()=>kL(),ubt=[[0,-.333334],[-.5,.333334],[.5,-.777778],[-.75,-.111112],[.25,.555556],[-.25,-.555556],[.75,.111112],[-.875,.777778],[.125,-.925926],[-.375,-.25926],[.625,.407408],[-.625,-.703704],[.375,-.037038],[-.125,.62963],[.875,-.481482],[-.9375,.185186]],Mq=80,nc=16,dbt=()=>n7()?Math.max(4,nc>>1):nc,cbt=()=>cE?Math.max(4,nc>>1):nc,pbt=1.25,mbt=null,P5=(t,e)=>$e(Te(Bt(t,e),I(-.05),I(.05))),yht=At(t=>{let{depthTexture:e,shadowCoord:i,shadow:r}=t,s=Rv(r),n=zr(i.xy).toVar(),a=$e(i.z).toVar(),o=F1(sT).toVar(),l=zr(Vt.pcssHalton),h=$e(Pc(Qa.xy.add(l))).mul(6.28318530718).toVar(),u=I(1).toVar();if(kL()){let d=s.maskChannel,c=$e(Vt.shadowMaskEnabled),p=Vt.shadowMaskGBuffer,m=Vt.shadowMaskTexture,f=I(0).toVar(),g=I(1).toVar();vt(c.greaterThan(.5).and($e(Bt(d,at(1,1,1,1))).greaterThan(.5)),()=>{let y=zr(th),v=zr(Vt.shadowMaskResolution),b=zr(Vt.shadowMaskFullResolution),_=$e(Ic.z),x=zr(y.mul(v).sub(st(.5,.5))).toVar(),S=zr(de(x)).toVar(),w=zr(x.sub(S)).toVar(),T=$e(Kt(ke(_).mul(.02),I(.05))),C=I(0).toVar(),M=I(0).toVar();for(let A=0;A<=1;A++)for(let P=0;P<=1;P++){let O=zr(Te(S.add(st(P,A)),st(0,0),v.sub(st(1,1)))),D=zr(O.add(st(.5,.5)).div(v)),N=zr(de(D.mul(b)).add(st(.5,.5)).div(b)),z=$e(p.sample(N).w),k=$e(Bt(m.sample(D),d)),B=$e(P===0?I(1).sub(w.x):$e(w.x)),V=$e(A===0?I(1).sub(w.y):$e(w.y)),q=$e(Si(ke(z.sub(_)),T)),W=$e(B.mul(V).mul(q)).toVar();C.addAssign(W),M.addAssign(k.mul(W))}vt(C.greaterThan(.001),()=>{f.assign(1),g.assign(M.div(C))})}),vt(f.greaterThan(.5),()=>{u.assign(g)}).Else(()=>{s7(e,r,n,a,h,u,o)})}else s7(e,r,n,a,h,u,o);return u}),vht=At(t=>{let{depthTexture:e,shadowCoord:i,shadow:r}=t,s=Rv(r),n=zr(i.xy).toVar(),a=$e(i.z).toVar(),o=hbt(s,F1(sT).toVar()),l=$e(s.mapSize),h=$e(s.radius),u=$e(h.mul(I(1).div(l))).toVar(),d=$e(Pc(Qa.xy)).mul(6.28318530718).toVar(),c=I(0).toVar();for(let p=0;p<5;p++){let m=zr(Sm(ct(p),ct(5),d)).mul(u).toVar();c.addAssign($e(Jt(e,zr(n.add(m))).compare(a.add(P5(o,m)))))}return c.mul(.2)}),bht=At(t=>{let{depthTexture:e,bd3D:i,dp:r,shadow:s}=t,n=nc,a=Rv(s),o=$e(a.mapSize),l=$e(a.radius),h=I(1).div(o).toVar(),u=zr(Vt.pcssHalton),d=$e(Pc(Qa.xy.add(u))).mul(6.28318530718).toVar(),c=$e(l.add(5)).toVar(),p=I(0).toVar();for(let m=0;m<n;m++){let f=zr(Sm(ct(m),ct(n),d)).mul(h).toVar(),g=F1(j(f.x,f.y,$e(f.x).negate()).mul(c)),y=F1(i.add(g));p.addAssign($e(ivt(e,y).compare(r)))}return p.div(n)}),Aq=mt(1),l7=(t,e)=>t(e),fbt=["depthTexture","shadowCoord","shadow","depthLayer","bd3D","dp"],R5=ght(yht,vht),D5=ght(bht,H1t)}),oPt=U(()=>{ot(),cr(),je(),pn(),_bt(),gE=new Pr,_ht=new se,xht=new Y,gbt=class{constructor(){this._gBuffer=null,this._maskTarget=null,this._resolveMaterial=null,this._resolveKey="",this._cameraWorld=mt(new bt),this._projInv=mt(new bt),this._lightRows=[];let t=new Pe;t.name="SplineShadowMask.gbuffer",t.fragmentNode=at(Ra,Ic.z),t.lights=!1,t.blending=Wi,t.needsUpdate=!0,this._gBufferMaterial=t}_ensureTarget(t,e,i,r){return t&&t.width===e&&t.height===i?{target:t,changed:!1}:(t?.dispose(),{target:r(),changed:!0})}_buildResolveMaterial(t){let e=new Pe;e.name="SplineShadowMask.resolve";let i=Jt(this._gBuffer.depthTexture),r=Jt(this._gBuffer.texture),s=this._cameraWorld,n=this._projInv,a=this._gBuffer.width,o=this._gBuffer.height;this._lightRows=t.map(()=>({matrix:mt(new bt),bias:mt(0),normalBias:mt(0)}));let l=this._lightRows,h=At(()=>{let u=ui(),d=de(u.mul(st(a,o))).add(st(.5,.5)).div(st(a,o)).toVar(),c=i.sample(d),p=uq(d,c,n).toVar(),m=r.sample(d).toVar(),f=s,g=f.mul(at(p,1)).xyz.toVar(),y=be(f.mul(at(m.xyz,0)).xyz).toVar(),v=Vt.pcssHalton,b=Pc(Qa.xy.add(v)).mul(6.28318530718).toVar(),_=[I(1).toVar(),I(1).toVar(),I(1).toVar(),I(1).toVar()];return t.forEach((x,S)=>{let w=l[S],T=g.add(y.mul(w.normalBias)),C=w.matrix.mul(at(T,1)).toVar(),M=C.xyz.div(C.w),A=j(M.x,I(1).sub(M.y),M.z).toVar(),P=A.z.add(w.bias).toVar(),O=A.x.greaterThanEqual(0).and(A.x.lessThanEqual(1)).and(A.y.greaterThanEqual(0)).and(A.y.lessThanEqual(1)).and(P.lessThanEqual(1));vt(O,()=>{s7(x.shadow.map.depthTexture,x.shadow,A.xy,P,b,_[S],y)})}),at(_[0],_[1],_[2],_[3])})();return e.fragmentNode=h,e.lights=!1,e.blending=Wi,e.depthTest=!1,e.depthWrite=!1,e.needsUpdate=!0,e}render(t,e,i,r,s){let n=s??t.getDrawingBufferSize(xht),a=Math.max(1,Math.round(n.x)),o=Math.max(1,Math.round(n.y)),l=Math.max(1,Math.round(a/2)),h=Math.max(1,Math.round(o/2)),u=!1,d=this._ensureTarget(this._gBuffer,a,o,()=>{let C=new ii(a,o,{type:si,depthTexture:new Ha(a,o),minFilter:pe,magFilter:pe});return C.texture.name="SplineShadowMask.gbuffer",C});this._gBuffer=d.target,u=u||d.changed;let c=this._ensureTarget(this._maskTarget,l,h,()=>{let C=new ii(l,h,{depthBuffer:!1,minFilter:pe,magFilter:pe});return C.texture.name="SplineShadowMask.mask",C});this._maskTarget=c.target,u=u||c.changed;let p=`${this._gBuffer.texture.uuid}:${r.map(C=>C.shadow.map?.depthTexture?.uuid??"none").join(",")}`;(this._resolveMaterial===null||this._resolveKey!==p)&&(this._resolveMaterial?.dispose(),this._resolveMaterial=this._buildResolveMaterial(r),this._resolveKey=p),this._cameraWorld.value.copy(i.matrixWorld),this._projInv.value.copy(i.projectionMatrix).invert(),r.forEach((C,M)=>{C.shadow.updateMatrices?.(C.light);let A=this._lightRows[M];C.shadow.matrix&&A.matrix.value.copy(C.shadow.matrix),A.bias.value=C.shadow.bias??0,A.normalBias.value=C.shadow.normalBias??0});let m=e,f=m.isScene===!0,g=[],y=[];m.traverse(C=>{let M=C;if(M.isMesh===!0&&M.visible!==!1){if((Array.isArray(M.material)?M.material:[M.material]).some(A=>A?.transparent===!0))g.push(M),M.visible=!1;else if(!f){let A=M;y.push({obj:A,material:A.material}),A.material=this._gBufferMaterial}}});let v=m.overrideMaterial,b=t.getRenderTarget(),_=t.getMRT(),x=t.getClearColor(_ht),S=t.getClearAlpha(),w=i.layers,T=w.mask;w.disable(3),m.overrideMaterial=this._gBufferMaterial,t.setMRT(null),t.setClearColor(0,0),t.setRenderTarget(this._gBuffer),t.render(e,i),m.overrideMaterial=v,w.mask=T;for(let C of g)C.visible=!0;for(let C of y)C.obj.material=C.material;return gE.material=this._resolveMaterial,gE.name="SplineShadowMask.resolve",t.setRenderTarget(this._maskTarget),gE.render(t),t.setRenderTarget(b),t.setMRT(_),t.setClearColor(x,S),Vt.shadowMaskTexture.value=this._maskTarget.texture,Vt.shadowMaskGBuffer.value=this._gBuffer.texture,Vt.shadowMaskResolution.value.set(l,h),Vt.shadowMaskFullResolution.value.set(a,o),r.forEach((C,M)=>{lbt(C.shadow,M)}),He.shadowMaskResolves++,{targetsChanged:u}}dispose(){this._gBuffer?.dispose(),this._gBuffer=null,this._maskTarget?.dispose(),this._maskTarget=null,this._gBufferMaterial.dispose(),this._resolveMaterial?.dispose(),this._resolveMaterial=null,this._resolveKey=""}}}),lPt=U(()=>{ot(),ybt=1,vbt={src:kv,dst:X1,srcAlpha:X1,dstAlpha:X1},bbt={src:_G,dst:xG,srcAlpha:X1,dstAlpha:kv}});function wht(t){let e=t;return e.isSkinnedMesh===!0&&e.bindMatrixInverse?e.bindMatrixInverse:null}function Sht(t){let e=new rT(VS);return e.blendSrc=t.src,e.blendDst=t.dst,e.blendSrcAlpha=t.srcAlpha,e.blendDstAlpha=t.dstAlpha,e}var yE,Tht,O5,xbt,Mht,Aht,Cht,wbt,Sbt=U(()=>{ot(),je(),cr(),lPt(),yE=new WeakMap,Tht=new bt,O5=_vt(class extends j1t{update(t){super.update(t);let{frameId:e,object:i}=t,r=wht(i),s=yE.get(i);s===void 0?(s={frameId:e,prev:i.matrixWorld.clone(),last:i.matrixWorld.clone(),prevBind:r?.clone()??null,lastBind:r?.clone()??null},yE.set(i,s)):s.frameId!==e&&(s.frameId=e,s.prev.copy(s.last),s.prevBind&&s.lastBind&&s.prevBind.copy(s.lastBind));let n=this.previousModelWorldMatrix.value.copy(s.prev);r!==null&&(s.prevBind===null&&(s.prevBind=r.clone(),s.lastBind=r.clone()),n.multiply(s.prevBind).multiply(Tht.copy(r).invert()))}updateAfter(t){let{object:e}=t,i=yE.get(e);if(i===void 0)return;i.last.copy(e.matrixWorld);let r=wht(e);r!==null&&i.lastBind?.copy(r)}}),xbt=at(O5,0,ybt),Mht=Sht(vbt),Aht=new rT(Wi),Cht=Sht(bbt),wbt=new class extends rT{resolveForMaterial(t){return t.depthWrite?Mht:function(e){return!e.depthWrite&&e.blending!==Wi&&(e.blending!==Ql||e.transparent)}(t)?Cht:Aht}}(Wi)});function I5(t,e){let i=0,r=1,s=t;for(;s>0;)r/=e,i+=r*(s%e),s=Math.floor(s/e);return i}function VL(t){return j(t.x.div(4).add(t.y.div(2)).add(t.z.div(4)),t.x.div(2).sub(t.z.div(2)),t.x.div(-4).add(t.y.div(2)).sub(t.z.div(4)))}function Eht(t,e=!0){let i=j(t.x.add(t.y).sub(t.z),t.x.add(t.z),t.x.sub(t.y).sub(t.z));return e?Te(i,j(0),j(1)):Kt(i,j(0))}function Tbt(){let t=!1;try{let c=new URLSearchParams(window.location.search).get("dbgfp16");t=c==="1"||c==="hist"||c==="st"}catch{}let e=!1,i=()=>t||e,r=(c,p,m)=>{let f=new ii(c,p,{minFilter:pe,magFilter:pe,depthBuffer:!1});return i()?f.texture.type=si:jD()&&(f.texture.internalFormat="rgba8unorm-srgb"),f.texture.name=m,f},s=r(1,1,"SplineTAA.A"),n=r(1,1,"SplineTAA.B"),a=null,o=!1,l=0,h=0,u=0,d=0;return{rtA:s,rtB:n,flip:!1,valid:!1,jitterIndex:0,unjitteredProjection:new bt,jitterOffsetUV:new Y(0,0),beginJitter(c,p,m){if(o)return;let f,g;if(o=!0,(a===null||a.cam!==c)&&(a?.clearViewOffset(),a=new Mbt(c)),this.unjitteredProjection.copy(c.projectionMatrix),Vt.unjitteredProjection.value.copy(c.projectionMatrix),sv==="r2"){let y=++this.jitterIndex;f=(.5+Abt*y)%1,g=(.5+Cbt*y)%1}else if(sv==="white")this.jitterIndex++,f=Math.random(),g=Math.random();else if(sv==="h64")f=I5(this.jitterIndex%64+1,2),g=I5(this.jitterIndex%64+1,3),this.jitterIndex=(this.jitterIndex+1)%64;else if(sv==="half"){let[y,v]=O2[this.jitterIndex];f=.5+.5*(y-.5),g=.5+.5*(v-.5),this.jitterIndex=(this.jitterIndex+1)%O2.length}else[f,g]=O2[this.jitterIndex],this.jitterIndex=(this.jitterIndex+1)%O2.length;l=p,h=m,u=f-.5,d=g-.5,Vt.cameraJitterPx.value.set(2*u,2*d),a.setViewOffset(p,m,u,d),this.jitterOffsetUV.set(-(f-.5)/p,-(g-.5)/m),He.taaJitterIndex=this.jitterIndex,He.taaJitterApplies++},suspendJitter(){o&&a?.clearViewOffset()},resumeJitter(){o&&a!==null&&a.setViewOffset(l,h,u,d)},endJitter(){o=!1,this.jitterOffsetUV.set(0,0),a?.clearViewOffset()},resize(c,p){this.rtA.dispose(),this.rtB.dispose(),this.rtA=r(c,p,"SplineTAA.A"),this.rtB=r(c,p,"SplineTAA.B"),this.valid=!1},setHdr(c){if(e===c)return;let p=i();e=c,i()!==p&&this.resize(this.rtA.width,this.rtA.height)},dispose(){this.rtA.dispose(),this.rtB.dispose(),this.valid=!1,o=!1,a?.clearViewOffset(),a=null}}}var Pht,Rht,vE,Mbt,O2,sv,Abt,Cbt,Ebt,Pbt,Wf,Dht,zL,Oht,Rbt,bE,LL,Dbt,Obt=U(()=>{ot(),Sbt(),pn(),cr(),je(),Pht=t=>t,Rht=t=>t,vE=new Pr,Mbt=class{constructor(t){this.cam=t,this._savedSkewX=0,this._savedSkewY=0,this._savedShiftX=0,this._savedShiftY=0,this._jitterActive=!1}setViewOffset(t,e,i,r){this.clearViewOffset();let s=this.cam.projectionMatrix.elements,n=-2*i/t,a=2*r/e;this._savedSkewX=s[8],this._savedSkewY=s[9],this._savedShiftX=s[12],this._savedShiftY=s[13],s[8]+=n*s[11],s[9]+=a*s[11],s[12]+=n*s[15],s[13]+=a*s[15],this.cam.projectionMatrixInverse.copy(this.cam.projectionMatrix).invert(),this._jitterActive=!0}clearViewOffset(){if(!this._jitterActive)return;let t=this.cam.projectionMatrix.elements;t[8]=this._savedSkewX,t[9]=this._savedSkewY,t[12]=this._savedShiftX,t[13]=this._savedShiftY,this.cam.projectionMatrixInverse.copy(this.cam.projectionMatrix).invert(),this._jitterActive=!1}},O2=Array.from({length:16},(t,e)=>[I5(e+1,2),I5(e+1,3)]),sv="h16";try{let t=new URLSearchParams(window.location.search).get("dbgjitseq");(t==="r2"||t==="h64"||t==="white"||t==="half")&&(sv=t)}catch{}Abt=.7548776662466927,Cbt=.5698402909980532,Ebt=class extends Cr{constructor(t,e,i,r,s=!1){super("vec4"),this._resolution=mt(new Y(1,1)),this._historyValid=mt(0),this._jitterUV=mt(new Y(0,0)),this._resolveMaterials=null,this._rebuildResolveMaterials=null,this.beautyNode=t,this.depthNode=e,this.velocityNode=i,this._hdr=s,this._history=r??Tbt(),this._ownsHistory=r===void 0,this._outputTexNode=Jt(this._history.rtA.texture)}static get type(){return"SplineTAANode"}get outputTextureNode(){return this._outputTexNode}renderResolve(t){O5.setProjectionMatrix(this._history.unjitteredProjection);let e=this.beautyNode.passNode.renderTarget,i=e.texture.width,r=e.texture.height,s=this._history;(s.rtA.width!==i||s.rtA.height!==r)&&(s.resize(i,r),this._rebuildResolveMaterials?.()),this._resolution.value.set(i,r),this._historyValid.value=s.valid?1:0,this._jitterUV.value.copy(s.jitterOffsetUV);let n=s.flip?s.rtB:s.rtA,a=this._resolveMaterials?this._resolveMaterials[s.flip?1:0]:null,o=t.getRenderTarget(),l=t.getMRT();t.setMRT(null),s.valid||(t.setRenderTarget(s.rtA),t.clear(!0,!1,!1),t.setRenderTarget(s.rtB),t.clear(!0,!1,!1)),t.setRenderTarget(n),a&&(vE.material=a,vE.name="SplineTAA.resolve",vE.render(t)),t.setRenderTarget(o),t.setMRT(l),this._outputTexNode.value=n.texture,s.valid=!0,s.flip=!s.flip,He.taaResolves++,He.taaJitterIndex=s.jitterIndex,He.taaHistoryValid=!0,He.taaResolveSize=`${i}x${r}`}setup(t){let e=t.renderer.reversedDepthBuffer===!0,i=t.renderer.backend?.isWebGLBackend===!0,r=!1,s=!1,n=!1,a=!1,o=!1,l=!1,h=!1,u=!1,d=!1,c=!1;try{let x=new URLSearchParams(window.location.search).get("dbgtaa");r=x==="1",s=x==="zv",n=x==="nc",a=x==="err",o=x==="hist",l=x==="red",h=x==="ns",u=x==="fb90",d=new URLSearchParams(window.location.search).get("dbgjit")==="mark",c=x==="hold"}catch{}let p=this.beautyNode,m=this.velocityNode,f=this.depthNode,g=this._resolution,y=this._historyValid,v=this._jitterUV,b=x=>{let S=p.sample(x);return at(VL(S.rgb),S.a)},_=x=>{let S=At(()=>{let T=ui().toVar();if(d)return at(v.x.mul(400).add(.5),v.y.mul(400).add(.5),I(.5),I(1));let C=T,M=st(I(1).div(g.x),I(1).div(g.y)).toVar(),A=[[-1,1],[0,1],[1,1],[-1,0],[0,0],[1,0],[-1,-1],[0,-1],[1,-1]].map(([Hi,ai])=>T.add(st(M.x.mul(Hi),M.y.mul(ai))).toVar()),P=A,O=I(e?-1e3:1e3).toVar(),D=st(A[4]).toVar();for(let Hi=0;Hi<9;Hi++){let ai=Pht(f.load(Yn(A[Hi].mul(Rht(g)))).r).toVar(),Fr=e?ai.greaterThan(O):ai.lessThan(O);O.assign(Fr.select(ai,O)),D.assign(Fr.select(A[Hi],D))}let N=m.load(Yn(D.mul(g))).xy.mul(st(.5,-.5)).toVar();s&&N.assign(st(0,0));let z=T.sub(N).toVar(),k=i?st(z.x,I(1).sub(z.y)).toVar():z,B=b(C).toVar();if(r)return at(N.x.mul(20).add(.5),N.y.mul(20).add(.5),y,I(1));if(l){let Hi=new yr(new Uint8Array([255,0,0,255,255,0,0,255,255,0,0,255,255,0,0,255]),2,2);return Hi.needsUpdate=!0,Jt(Hi).sample(T)}if(o){let Hi=i?st(T.x,I(1).sub(T.y)):T;return x.sample(Hi)}if(a){let Hi=i?st(T.x,I(1).sub(T.y)):T,ai=x.sample(k),Fr=x.sample(Hi),ts=B.x,Ur=Fi=>VL(Fi.rgb).x;return at(Ur(ai).sub(ts).abs().mul(8),Ur(Fr).sub(ts).abs().mul(8),I(0),I(1))}let V=k.mul(g).toVar(),q=de(V.sub(.5)).add(.5).toVar(),W=V.sub(q).toVar(),H=W.mul(W.mul(W.mul(-.5).add(1)).add(-.5)).toVar(),rt=W.mul(W).mul(W.mul(1.5).add(-2.5)).add(1).toVar(),it=W.mul(W.mul(W.mul(-1.5).add(2)).add(.5)).toVar(),ft=W.mul(W).mul(W.mul(.5).add(-.5)).toVar(),dt=rt.add(it).toVar(),K=it.div(dt).toVar(),lt=q.sub(1).div(g).toVar(),_t=q.add(2).div(g).toVar(),xt=q.add(K).div(g).toVar(),wt=at(0).toVar();wt.addAssign(x.sample(st(xt.x,lt.y)).mul(dt.x.mul(H.y))),wt.addAssign(x.sample(st(lt.x,xt.y)).mul(H.x.mul(dt.y))),wt.addAssign(x.sample(st(xt.x,xt.y)).mul(dt.x.mul(dt.y))),wt.addAssign(x.sample(st(_t.x,xt.y)).mul(ft.x.mul(dt.y))),wt.addAssign(x.sample(st(xt.x,_t.y)).mul(dt.x.mul(ft.y)));let gt=at(VL(wt.rgb),wt.a).toVar();if(c)return at(Eht(gt.rgb).mul(j(1,.55,.55)),wt.a);let Dt=b(P[0]).toVar(),Lt=b(P[1]).toVar(),It=b(P[2]).toVar(),kt=b(P[3]).toVar(),Nt=b(P[4]).toVar(),Gt=b(P[5]).toVar(),qt=b(P[6]).toVar(),Ct=b(P[7]).toVar(),ne=b(P[8]).toVar(),Ut=at(ti(Dt,ti(Lt,ti(It,ti(kt,ti(Nt,ti(Gt,ti(qt,ti(Ct,ne))))))))).toVar(),Yt=at(Kt(Dt,Kt(Lt,Kt(It,Kt(kt,Kt(Nt,Kt(Gt,Kt(qt,Kt(Ct,ne))))))))).toVar(),Zt=at(ti(Lt,ti(kt,ti(Nt,ti(Gt,Ct))))).toVar(),$=at(Kt(Lt,Kt(kt,Kt(Nt,Kt(Gt,Ct))))).toVar();Ut.assign(Ut.add(Zt).mul(.5)),Yt.assign(Yt.add($).mul(.5));let ie=Yt.r.sub(Ut.r).mul(.25).mul(.5).toVar(),Ce=B.gb.toVar();h||(Ut.y.assign(Ce.x.sub(ie)),Ut.z.assign(Ce.y.sub(ie)),Yt.y.assign(Ce.x.add(ie)),Yt.z.assign(Ce.y.add(ie)));let Be=at(n?gt:Te(gt,Ut,Yt)).toVar(),te=u||n?I(.9):I(.9).mul(y),ni=at($t(B,Be,te)).toVar(),bi=Vt.tapAngle,Zs=fq(T.mul(g).add(st(bi.mul(127.1),bi.mul(311.7)))).sub(.5).mul(1/255);return at(Eht(ni.rgb,!this._hdr).add(j(Zs)),ni.a)}),w=new Pe;return w.name="SplineTAA.resolve",w.colorNode=S(),w.depthTest=!1,w.depthWrite=!1,w.blending=Wi,w.needsUpdate=!0,w};return this._rebuildResolveMaterials=()=>{this._resolveMaterials&&(this._resolveMaterials[0].dispose(),this._resolveMaterials[1].dispose()),this._resolveMaterials=[_(Jt(this._history.rtB.texture)),_(Jt(this._history.rtA.texture))]},this._rebuildResolveMaterials(),this._outputTexNode}dispose(){this._ownsHistory&&this._history.dispose(),this._resolveMaterials&&(this._resolveMaterials[0].dispose(),this._resolveMaterials[1].dispose(),this._resolveMaterials=null),O5.setProjectionMatrix(null)}}}),hPt=U(()=>{Pbt=class{constructor(){this._frames=0}get frames(){return this._frames}get stalled(){return this._frames>=3}update(t,e){this._frames=t>0&&!e?this._frames+1:0}}}),uPt=U(()=>{}),dPt=U(()=>{eq(),cr(),je(),Wf=new Pr,Dht=new Y,Oht=class extends Cr{static get type(){return"SMAANode"}constructor(t){super("vec4"),this.textureNode=t,this.updateBeforeType=q1t.FRAME,this._renderTargetEdges=new ii(1,1,{depthBuffer:!1,type:si}),this._renderTargetEdges.texture.name="SMAANode.edges",this._renderTargetWeights=new ii(1,1,{depthBuffer:!1,type:si}),this._renderTargetWeights.texture.name="SMAANode.weights",this._renderTargetBlend=new ii(1,1,{depthBuffer:!1,type:si}),this._renderTargetBlend.texture.name="SMAANode.blend";let e=this,i=new Image;i.crossOrigin="anonymous",lQ(i,"smaa-node-area.png"),i.onload=function(){e._areaTexture.needsUpdate=!0},this._areaTexture=new di,this._areaTexture.name="SMAANode.area",this._areaTexture.image=i,this._areaTexture.minFilter=pe,this._areaTexture.generateMipmaps=!1,this._areaTexture.flipY=!1;let r=new Image;r.crossOrigin="anonymous",lQ(r,"smaa-node-search.png"),r.onload=function(){e._searchTexture.needsUpdate=!0},this._searchTexture=new di,this._searchTexture.name="SMAANode.search",this._searchTexture.image=r,this._searchTexture.magFilter=Re,this._searchTexture.minFilter=Re,this._searchTexture.generateMipmaps=!1,this._searchTexture.flipY=!1,this._invSize=mt(new Y),this._areaTextureUniform=Jt(this._areaTexture),this._searchTextureUniform=Jt(this._searchTexture),this._edgesTextureUniform=Jt(this._renderTargetEdges.texture),this._weightsTextureUniform=Jt(this._renderTargetWeights.texture),this._materialEdges=new Pe,this._materialEdges.name="SMAANode.edges",this._materialWeights=new Pe,this._materialWeights.name="SMAANode.weights",this._materialBlend=new Pe,this._materialBlend.name="SMAANode.blend",this._textureNode=Cvt(this,this._renderTargetBlend.texture)}getTextureNode(){return this._textureNode}setSize(t,e){this._invSize.value.set(1/t,1/e),this._renderTargetEdges.setSize(t,e),this._renderTargetWeights.setSize(t,e),this._renderTargetBlend.setSize(t,e)}updateBefore(t){let{renderer:e}=t;zL=M9.resetRendererState(e,zL);let i=e.getDrawingBufferSize(Dht);this.setSize(i.width,i.height),e.setRenderTarget(this._renderTargetEdges),Wf.material=this._materialEdges,Wf.render(e),e.setRenderTarget(this._renderTargetWeights),Wf.material=this._materialWeights,Wf.render(e),e.setRenderTarget(this._renderTargetBlend),Wf.material=this._materialBlend,Wf.render(e),M9.restoreRendererState(e,zL)}setup(t){let e=st(.00625,.0017857142857142857),i=1/7,r=this.textureNode.uvNode||ui(),s=At(()=>{let g=at(r.xy,r.xy).add(at(this._invSize.xy,this._invSize.xy).mul(at(-1,0,0,-1))),y=at(r.xy,r.xy).add(at(this._invSize.xy,this._invSize.xy).mul(at(1,0,0,1))),v=at(r.xy,r.xy).add(at(this._invSize.xy,this._invSize.xy).mul(at(-2,0,0,-2)));return Lr("vec4","vOffset0").assign(g),Lr("vec4","vOffset1").assign(y),Lr("vec4","vOffset2").assign(v),FR}),n=At(()=>{let g=Lr("vec4","vOffset0"),y=Lr("vec4","vOffset1"),v=Lr("vec4","vOffset2"),b=st(.1,.1),_=at().toVar(),x=this.textureNode.sample(r).rgb.toVar(),S=this.textureNode.sample(g.xy).rgb.toVar(),w=ke(x.sub(S));_.x=Kt(w.r,w.g,w.b);let T=this.textureNode.sample(g.zw).rgb.toVar();w=ke(x.sub(T)),_.y=Kt(w.r,w.g,w.b);let C=Si(b,_.xy).toVar();Bt(C,st(1,1)).equal(0).discard();let M=this.textureNode.sample(y.xy).rgb.toVar();w=ke(x.sub(M)),_.z=Kt(w.r,w.g,w.b);let A=this.textureNode.sample(y.zw).rgb.toVar();w=ke(x.sub(A)),_.w=Kt(w.r,w.g,w.b);let P=Kt(_.x,_.y,_.z,_.w).toVar(),O=this.textureNode.sample(v.xy).rgb.toVar();w=ke(x.sub(O)),_.z=Kt(w.r,w.g,w.b);let D=this.textureNode.sample(v.zw).rgb.toVar();return w=ke(x.sub(D)),_.w=Kt(w.r,w.g,w.b),P=Kt(P,_.z,_.w),C.xy.mulAssign(st(Si(I(.5).mul(P),_.xy))),at(C,0,0)}),a=At(([g,y,v,b])=>{let _=st(y).toVar();return _.r=v.add(_.r.mul(b)),I(255).mul(g.sample(_)).r}),o=At(([g,y,v,b,_])=>{let x=I(16).mul(I(4).mul(st(v,b)).round()).add(y);return x=e.mul(x).add(I(.5).mul(e)),x.y.addAssign(I(i).mul(_)),g.sample(x).rg}),l=At(([g,y,v,b])=>{let _=st(0,1).toVar(),x=st(v).toVar();return Qi({start:ct(0),end:ct(8),type:"int",condition:"<"},()=>{_.assign(g.sample(x).rg),x.subAssign(st(2,0).mul(this._invSize)),vt(x.x.lessThanEqual(b).or(_.g.lessThanEqual(I(.8281)).or(_.r.notEqual(I(0)))),()=>{ea()})}),x.x.addAssign(I(.25).mul(this._invSize.x)),x.x.addAssign(this._invSize.x),x.x.addAssign(I(2).mul(this._invSize.x)),x.x.subAssign(this._invSize.x.mul(a(y,_,0,.5))),x.x}),h=At(([g,y,v,b])=>{let _=st(0,1).toVar(),x=st(v).toVar();return Qi({start:ct(0),end:ct(8),type:"int",condition:"<"},()=>{_.assign(g.sample(x).rg),x.addAssign(st(2,0).mul(this._invSize)),vt(x.x.greaterThanEqual(b).or(_.g.lessThanEqual(I(.8281)).or(_.r.notEqual(I(0)))),()=>{ea()})}),x.x.subAssign(I(.25).mul(this._invSize.x)),x.x.subAssign(this._invSize.x),x.x.subAssign(I(2).mul(this._invSize.x)),x.x.addAssign(this._invSize.x.mul(a(y,_,.5,.5))),x.x}),u=At(([g,y,v,b])=>{let _=st(1,0).toVar(),x=st(v).toVar();return Qi({start:ct(0),end:ct(8),type:"int",condition:"<"},()=>{_.assign(g.sample(x).rg),x.addAssign(st(0,-2).mul(this._invSize)),vt(x.y.lessThanEqual(b).or(_.r.lessThanEqual(I(.8281)).or(_.g.notEqual(I(0)))),()=>{ea()})}),x.y.addAssign(I(.25).mul(this._invSize.y)),x.y.addAssign(this._invSize.y),x.y.addAssign(I(2).mul(this._invSize.y)),x.y.subAssign(this._invSize.y.mul(a(y,_.gr,0,.5))),x.y}),d=At(([g,y,v,b])=>{let _=st(1,0).toVar(),x=st(v).toVar();return Qi({start:ct(0),end:ct(8),type:"int",condition:"<"},()=>{_.assign(g.sample(x).rg),x.subAssign(st(0,-2).mul(this._invSize)),vt(x.y.greaterThanEqual(b).or(_.r.lessThanEqual(I(.8281)).or(_.g.notEqual(I(0)))),()=>{ea()})}),x.y.subAssign(I(.25).mul(this._invSize.y)),x.y.subAssign(this._invSize.y),x.y.subAssign(I(2).mul(this._invSize.y)),x.y.addAssign(this._invSize.y.mul(a(y,_.gr,.5,.5))),x.y}),c=At(()=>{let g=r.xy.div(this._invSize),y=at(r.xy,r.xy).add(at(this._invSize.xy,this._invSize.xy).mul(at(-.25,-.125,1.25,-.125))).toVar(),v=at(r.xy,r.xy).add(at(this._invSize.xy,this._invSize.xy).mul(at(-.125,-.25,-.125,1.25))).toVar(),b=at(y.xz,v.yw).add(at(-2,2,-2,2).mul(at(this._invSize.xx,this._invSize.yy)).mul(I(8))).toVar();return Lr("vec2","vPixcoord").assign(g),Lr("vec4","vOffset0").assign(y),Lr("vec4","vOffset1").assign(v),Lr("vec4","vOffset2").assign(b),FR}),p=At(()=>{let g=Lr("vec2","vPixcoord"),y=Lr("vec4","vOffset0"),v=Lr("vec4","vOffset1"),b=Lr("vec4","vOffset2"),_=at(0,0,0,0).toVar(),x=at(0,0,0,0).toVar(),S=this._edgesTextureUniform.sample(r).rg.toVar();return vt(S.g.greaterThan(I(0)),()=>{let w=st().toVar(),T=st().toVar();T.x=l(this._edgesTextureUniform,this._searchTextureUniform,y.xy,b.x),T.y=v.y,w.x=T.x;let C=this._edgesTextureUniform.sample(T).r.toVar(),M=st().toVar();M.x=h(this._edgesTextureUniform,this._searchTextureUniform,y.zw,b.y),M.y=v.y,w.y=M.x,w=w.div(this._invSize.x).sub(g.x);let A=xl(ke(w)),P=this._edgesTextureUniform.sample(M.add(st(1,0).mul(this._invSize))).r.toVar();_.r=P,_.rg=o(this._areaTextureUniform,A,C,P,I(x.y))}),vt(S.r.greaterThan(I(0)),()=>{let w=st().toVar(),T=st().toVar();T.y=u(this._edgesTextureUniform,this._searchTextureUniform,v.xy,b.z),T.x=y.x,w.x=T.y;let C=this._edgesTextureUniform.sample(T).g.toVar(),M=st().toVar();M.y=d(this._edgesTextureUniform,this._searchTextureUniform,v.zw,b.w),M.x=y.x,w.y=M.y,w=w.div(this._invSize.y).sub(g.y);let A=xl(ke(w)),P=this._edgesTextureUniform.sample(M.add(st(0,1).mul(this._invSize))).g.toVar();_.ba=o(this._areaTextureUniform,A,C,P,I(x.x))}),_}),m=At(()=>{let g=at(r.xy,r.xy).add(at(this._invSize.xy,this._invSize.xy).mul(at(1,0,0,1)));return Lr("vec4","vOffset1").assign(g),FR}),f=At(()=>{let g=Lr("vec4","vOffset1"),y=at().toVar(),v=at().toVar();return v.xz=this._weightsTextureUniform.sample(r).xz,v.y=this._weightsTextureUniform.sample(g.zw).g,v.w=this._weightsTextureUniform.sample(g.xy).a,vt(Bt(v,at(1)).lessThan(1e-5),()=>{y.assign(this.textureNode.sample(r))}).Else(()=>{let b=st().toVar();b.x=v.a.greaterThan(v.b).select(v.a,v.b.negate()),b.y=v.g.greaterThan(v.r).select(v.g,v.r.negate()),vt(ke(b.x).greaterThan(ke(b.y)),()=>{b.y.assign(0)}).Else(()=>{b.x.assign(0)});let _=this.textureNode.sample(r).toVar(),x=st(r).toVar();x.addAssign(Xu(b).mul(this._invSize));let S=this.textureNode.sample(x).toVar(),w=ke(b.x).greaterThan(ke(b.y)).select(ke(b.x),ke(b.y)).toVar(),T=$t(_,S,w);y.assign(T)}),y});return this._materialEdges.vertexNode=s().context(t.getSharedContext()),this._materialEdges.fragmentNode=n().context(t.getSharedContext()),this._materialEdges.needsUpdate=!0,this._materialWeights.vertexNode=c().context(t.getSharedContext()),this._materialWeights.fragmentNode=p().context(t.getSharedContext()),this._materialWeights.needsUpdate=!0,this._materialBlend.vertexNode=m().context(t.getSharedContext()),this._materialBlend.fragmentNode=f().context(t.getSharedContext()),this._materialBlend.needsUpdate=!0,this._textureNode}dispose(){this._renderTargetEdges.dispose(),this._renderTargetWeights.dispose(),this._renderTargetBlend.dispose(),this._areaTexture.dispose(),this._searchTexture.dispose(),this._materialEdges.dispose(),this._materialWeights.dispose(),this._materialBlend.dispose()}_getAreaTexture(){return""}_getSearchTexture(){return""}},Rbt=t=>new Oht(evt(t))}),cPt=U(()=>{ot(),cr(),je(),dPt(),pn(),bE=new Y,LL=new se,Dbt=class{constructor(){this._rt=null,this._texNode=null,this._smaaNode=null,this._material=null,this._quad=null,this._depthTexNode=null,this._seedMaterial=null,this._seedQuad=null}_ensureTarget(t,e,i){if(this._rt===null||this._rt.width!==t||this._rt.height!==e){this._rt?.dispose();let r=new ii(t,e,{depthBuffer:!0,stencilBuffer:!1,samples:0});r.texture.name="SplineHelperOverlay.color",this._rt=r}if(this._texNode===null){this._texNode=Jt(this._rt.texture),this._smaaNode=Rbt(this._texNode);let r=new Pe;r.name="SplineHelperOverlayComposite",r.fragmentNode=this._smaaNode,r.transparent=!0,r.blending=VS,r.blendEquation=uv,r.blendSrc=kv,r.blendDst=Ug,r.blendSrcAlpha=kv,r.blendDstAlpha=Ug,r.depthTest=!1,r.depthWrite=!1,this._material=r,this._quad=new Pr(r);let s=new Pe;s.name="SplineHelperOverlayDepthSeed",this._depthTexNode=Jt(i),s.depthNode=this._depthTexNode.x,s.fragmentNode=at(0),s.colorWrite=!1,s.depthTest=!1,s.depthWrite=!0,this._seedMaterial=s,this._seedQuad=new Pr(s)}else this._texNode.value!==this._rt.texture&&(this._texNode.value=this._rt.texture),this._depthTexNode.value!==i&&(this._depthTexNode.value=i);return this._rt}render(t,e,i,r,s){t.getDrawingBufferSize(bE);let n=this._ensureTarget(bE.x,bE.y,s),a=t.getRenderTarget(),o=t.autoClear;t.getClearColor(LL);let l=t.getClearAlpha();if(t.autoClear=!1,t.setRenderTarget(n),t.setClearColor(0,0),t.clear(!0,!0,!1),this._seedQuad.render(t),e&&t.render(e,r),t.clear(!1,!0,!1),i&&t.render(i,r),t.setRenderTarget(a),t.setClearColor(LL,l),function(){try{return new URLSearchParams(window.location.search).get("dbgoutguard")!=="0"}catch{return!0}}()){let h=t.toneMapping,u=t.outputColorSpace;t.toneMapping=cl,t.outputColorSpace=Zi.workingColorSpace,this._quad.render(t),t.toneMapping=h,t.outputColorSpace=u}else this._quad.render(t);t.autoClear=o}dispose(){this._rt?.dispose(),this._rt=null,this._smaaNode?.dispose(),this._material?.dispose(),this._seedMaterial?.dispose()}}}),h7,HR,$R,pPt=U(()=>{cr(),h7=new WeakMap,HR=new Set,$R=0});function Iht(t){let e=t.parent?.selectedTexture;return e&&e.isTexture===!0?e:null}function _E(t){let e=t.src.array,i=t.attr.array;for(let r=0,s=Math.min(e.length,i.length);r<s;r++)i[r]=e[r];t.attr.needsUpdate=!0}var u7,I2,U1,d7,mPt=U(()=>{ot(),cr(),je(),u7=new WeakMap,I2=new Set,U1=0,d7=new WeakMap});function fPt(t,e){(function(){if(c7)return;c7=!0;let r=Pn.prototype,s=r.addEventListener;r.addEventListener=function(n,a){return n==="dispose"&&j1!==null&&typeof a=="function"&&j1.record(this,a),s.call(this,n,a)}})();let i=j1;j1=t;try{return e()}finally{j1=i}}var Ibt,xE,j1,c7,gPt=U(()=>{ot(),Ibt=class{constructor(){this._entries=[],this._pruneAt=xE}record(t,e){this._entries.push({target:new WeakRef(t),listener:new WeakRef(e)}),this._entries.length>=this._pruneAt&&(this._entries=this._entries.filter(i=>i.target.deref()!==void 0),this._pruneAt=Math.max(xE,2*this._entries.length))}release(){for(let{target:t,listener:e}of this._entries){let i=t.deref(),r=e.deref();i&&r&&i.removeEventListener("dispose",r)}this._entries=[],this._pruneAt=xE}},xE=1024,j1=null,c7=!1}),yPt=U(()=>{});function Nbt(t,e,i,r){let s=t.num(0),n=t.num(1),a=t.num(.5),o=t.num(2),l=t.num(Bbt),h=u=>t.sub(n,u);switch(e){case 0:return i;case 1:return t.min(t.add(i,r),n);case 3:return t.mul(t.add(i,r),a);case 4:{let u=t.max(h(t.div(h(i),t.max(r,l))),s);return t.mix(r,u,t.step(l,r))}case 5:{let u=t.min(t.div(i,t.max(h(r),l)),n);return t.mix(u,r,t.step(n,r))}case 6:return t.min(i,r);case 7:return t.abs(t.sub(i,r));case 8:return t.sub(t.add(i,r),t.mul(o,t.mul(i,r)));case 9:return t.max(i,r);case 10:return t.mul(i,r);case 11:{let u=t.min(t.div(i,t.max(r,l)),n);return t.mix(n,u,t.step(l,r))}case 12:return h(t.abs(t.sub(h(i),r)));case 14:{let u=t.mul(o,t.mul(i,r)),d=h(t.mul(o,t.mul(h(i),h(r))));return t.mix(u,d,t.step(a,i))}case 15:{let u=t.min(t.div(t.mul(i,i),t.max(h(r),l)),n);return t.mix(u,r,t.step(n,r))}case 16:return h(t.mul(h(i),h(r)));case 17:{let u=t.mul(o,r),d=t.add(t.mul(i,u),t.mul(t.mul(i,i),h(u))),c=t.add(t.mul(t.sqrt(t.max(i,s)),t.sub(u,n)),t.mul(t.mul(o,i),h(r)));return t.mix(d,c,t.step(a,r))}case 18:return t.max(t.sub(t.add(i,r),n),s);default:return r}}var Bbt,vPt=U(()=>{Bbt=1e-6});function qf(t,e,i,r,s){if(i===0)return t;if(i===2)return $t(t,e,ti(s,r));let n=Nbt(kbt,i,t,e);return $t(t,n,r)}function FL(t,e,i,r){if(i===0)return t;if(i===2)return Kt(t,ti(e,r));let s=Nbt(Vbt,i,t,e);return $t(t,s,r)}function UL(){return YR===null&&(YR=Kv({output:Tvt,velocity:xbt})).setBlendMode("velocity",wbt),YR}var Oh,XR,kbt,Vbt,YR,N2,p7,KR,jL,m7,f7,Cq,bPt=U(()=>{ot(),cr(),je(),Obt(),Sbt(),$vt(),yPt(),rq(),pn(),vPt(),De(),Oh=t=>t,XR=t=>t,Vbt=kbt={num:t=>I(t),add:(t,e)=>t.add(e),sub:(t,e)=>t.sub(e),mul:(t,e)=>t.mul(e),div:(t,e)=>t.div(e),min:(t,e)=>ti(t,e),max:(t,e)=>Kt(t,e),abs:t=>ke(t),sqrt:t=>xl(t),step:(t,e)=>Si(t,e),mix:(t,e,i)=>$t(t,e,i)},YR=null}),_Pt=U(()=>{N2={enabled:!1},p7=new WeakMap,KR=new WeakSet}),xPt=U(()=>{ot(),cr(),je(),QW(),RD(),ED(),jL=At(t=>{let e=t.lightDistance,i=t.cutoffDistance,r=t.decayExponent,s=i.greaterThan(0).and(r.greaterThan(0));return pi(s,e.div(i).oneMinus().clamp().pow(r),I(1))}),m7=class extends A9{static get type(){return"SplinePointLightNode"}setupDirect(t){let e=this.getLightVector(t),i=e.normalize(),r=jL({lightDistance:e.length(),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode});return{lightColor:this.colorNode.mul(r),lightDirection:i}}},f7=class extends M2{static get type(){return"SplineSpotLightNode"}setupDirect(t){let e,i,r=this.light,s=this.getLightVector(t),n=s.normalize(),a=n.dot(uvt(r)),o=this.getSpotAttenuation(t,a),l=jL({lightDistance:s.length(),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode}),h=this.colorNode.mul(o).mul(l),u=r;if(u.colorNode?(i=this.getLightCoord(t),e=u.colorNode(i)):u.map&&(i=this.getLightCoord(t),e=Jt(u.map,i.xy).onRenderUpdate(()=>u.map)),e&&i){let d=i.mul(2).sub(1).abs().lessThan(1).all();h=pi(d,h.mul(e),h)}return{lightColor:h,lightDirection:n}}}}),zbt=U(()=>{Cq=null});function Lbt(){return typeof requestAnimationFrame!="function"||typeof document<"u"&&document.hidden===!0}function wPt(){return Lbt()?Promise.resolve():new Promise(t=>{let e=!1,i=()=>{e||(e=!0,clearTimeout(r),t())},r=setTimeout(i,250);requestAnimationFrame(i)})}var Nht,Vy,Bht,kht,Vht,GL,WL,zht,Lht,Fht,Uht,Bd,Tp,uw,Mp,wE,qL,dw,Hf,xu,zy,jht,$f,wu,cw,Ly,SE,Xf,Su,HL,TE,$L,ME,XL,YL,AE,CE,Ap,KL,ZL,QL,JL,tF,eF,iF,Yf,Ght,rF,N5,Wht=U(()=>{ot(),cr(),je(),tPt(),tbt(),tq(),DD(),bq(),xq(),GW(),Kh(),ePt(),De(),rbt(),t1t(),LW(),sbt(),nbt(),iPt(),rPt(),sPt(),pn(),_bt(),obt(),oPt(),Obt(),hPt(),uPt(),cPt(),pPt(),mPt(),gPt(),bPt(),_Pt(),Ayt(),xPt(),zbt(),Nht=new E,Vy=new E,Bht=new se,kht=new se,Vht=new se,GL=new E,WL=new E,zht=new Y,Lht=new E(1,0,0),Fht=new E(0,1,0),Uht=new E(0,0,1),Bd=new E,Tp=new E,uw=new E,Mp=new E,wE=new bt,qL=new E,dw=new E,Hf=new Ca,xu=new Se,zy=new Se,jht=new Y,$f=new Y,wu=new E,cw=new E,Ly=new E,SE=new E,Xf=new E,Su=[],HL=!1,TE=!1,$L=!1,ME="full",XL="g16",YL=!1,AE=!1,CE=!1,Ap="default",KL=!1,ZL=!0,QL=!0,JL=!0,tF=!0,eF=!0,iF=r9;try{let t=new URLSearchParams(window.location.search),e=t.get("instancing");if(e!==null)if(e==="off"||e==="0"||e==="false"||e==="no")eF=!1;else{let s=Number.parseInt(e,10);Number.isFinite(s)&&s>1&&(iF=s)}HL=t.get("dbgao")==="0",TE=t.get("dbgshadow")==="0",$L=t.get("dbgfp16")==="1",YL=t.get("dbgsky")==="0",AE=t.get("dbgssr")==="0",CE=t.get("dbgibl")==="0";let i=t.get("pbrcolor");i==="0"?Ap="off":(i==="linear"||i==="aces"||i==="agx"||i==="neutral")&&(Ap=i),KL=t.get("dbgplanar")==="0",ZL=t.get("dbgplanarpyr")!=="0",QL=t.get("dbgssrpyr")!=="0",JL=t.get("dbgssrhalf")!=="0",tF=t.get("dbgssrresolve")!=="0";let r=t.get("dbgprefilter");r==="0"?ME="off":r==="base"?ME="base":r==="k4"&&(XL="k4")}catch{}Yf=[null,null,null,null],Ght=IR.prototype._projectObject,(N5=rF=class extends IR{constructor(t={}){var e;super({canvas:t.canvas,alpha:t.alpha??!0,antialias:t.antialias??!1,forceWebGL:t.forceWebGL??!1,powerPreference:t.powerPreference,trackTimestamp:t.trackTimestamp??globalThis.__SPLINE_TRACK_TIMESTAMP__===!0,stencil:!1,requiredLimits:t.requiredLimits,canvasColorSpace:"display-p3",outputBufferType:$L?si:bl,asyncCompilation:t.asyncCompilation===!0||t.asyncCompilation==="load"}),this.viewportWidth=1,this.viewportHeight=1,this.resolution=new Y,this.dummyCamera=new zs,this.sceneTransitionDuration=0,this.sceneTransitionTimeRemaining=-1,this.manageShadowUpdates=!1,this.forceShadowUpdates=!1,this._shadowMapMissingAtSync=!1,this._shadowSyncPromotions=-1,this._lightShadowStateDirty=!1,this._lightShadowSignatures=new WeakMap,this._shadowMapIds=new WeakMap,this._shadowMapIdSeq=0,this.temporalAAEnabled=!0,this.hdrChainActive=!1,this.isWebGPUSplineRenderer=!0,this.shadowFilterHook=aPt,this._gaugeSnapshot="",this._gaugeChangedAt=0,this._gaugeStallWarned=!1,this._skipStalls=new Pbt,this._stallWarned=!1,this._asyncCompilationMode=!1,this._asyncLoadWarmupsInFlight=0,this.sceneBundlesEnabled=!1,this.sceneBundlesForceRerecord=!1,this.disposeListenerLedger=new Ibt,this._appliedWidth=-1,this._appliedHeight=-1,this._appliedRatio=-1,this._bundleLists=null,this._bundleStates=new WeakMap,this._skySystem=null,this._envClaimScope=null,this._envClaimEpoch=-1,this._skyFeatureWarned=!1,this.skyAnimationAllowed=!1,this.skyEnvironmentNeeded=!0,this._bundledPages=new Set,this._bundleValveArmed=!1,this._destroyedSubmitErrors=0,this._destroyedSubmitLastFrame=-10,this._warmupTarget=null,this.renderStarted=!1,this._warmupInFlight=!1,this._warmupPendingTarget=null,this._warmupPendingMRT=null,this._grabWarmupTarget=null,this._warnedHelperIncompat=new WeakSet,this._maskLights=[],this._maskBlocked=!1,this.suppressShadowMask=!1,this._grabTargetEpoch=0,this._retiredGrabTargets=[],this._retiredGpuBuffers=[],this._bundleEpochDirty=!1,this._encodeMaterials={},this._transmissionChain=[],this._reflectionColorChain=[],this._reflectionDepthChain=[],this._reflectionPassesKey="",this._reflectionResolveMarchKey="",this._planarChain=[],this._frameSerial=0,this._asyncCompilationMode=t.asyncCompilation??!1,this._updateCompilationBurst(),X9&&function(){if(!K9){if(K9=!0,A5=()=>Vt.frameIndex.value,typeof GPUBuffer<"u"){let i=GPUBuffer.prototype.destroy;GPUBuffer.prototype.destroy=function(){return hht("buffer",this.label,this.size),i.call(this)}}if(typeof GPUTexture<"u"){let i=GPUTexture.prototype.destroy;GPUTexture.prototype.destroy=function(){return hht("texture",this.label,`${this.width}x${this.height}`),i.call(this)}}console.info("[spline/webgpu] ?dbgdestroys=1 \u2014 GPU resource destroy logging armed; reproduce the error and read the [dbgdestroys] dumps")}}(),this.pipeline=new Sq(this),this.library.addLight(ibt,M5),this.shadowMap.enabled=!0,this.shadowMap.type=d4,e=this.backend?.isWebGPUBackend===!0,D2=e,this._deferGpuBufferDestruction(),function(i){let r=i;if(r==null||typeof r._draw!="function"||r.__splineDrawGuardInstalled===!0)return;r.__splineDrawGuardInstalled=!0;let s=r._draw.bind(r);r._draw=function(n,a,o,l,h,u,d,c,p){if(d.vertexCount>0&&n.getIndex()===null&&n.getIndirect()===null&&n.object.isBatchedMesh!==!0){let m=d.firstVertex+d.vertexCount;for(let f=0;f<u.length;f++){let g=u[f];if(g.isInstancedBufferAttribute!==!0&&g.isInstancedInterleavedBuffer!==!0&&g.count!==void 0&&g.count<m)return}}return s(n,a,o,l,h,u,d,c,p)}}(this.backend),this.outputColorSpace=Hu,this.toneMapping=cl,function(i){let r=i.library;r.addLight(m7,PT),r.addLight(f7,pb),r.addLight(C9,cb),r.lightNodes.delete(FS),r.lightNodes.delete(Wg),r.addLight(m7,FS),r.addLight(f7,Wg)}(this),this.sceneBundlesEnabled=t.sceneBundles===!0||t.sceneBundles==="rerecord",this.sceneBundlesForceRerecord=t.sceneBundles==="rerecord",this.auxiliary=t.auxiliary===!0,this.domElement.removeAttribute?.("data-engine")}advanceFrame(){let t=this._nodes,e=this.info;e.autoReset===!0&&e.reset(),t.nodeFrame.update(),e.frame=t.nodeFrame.frameId}get lastFrameIncomplete(){return!!(this._warmupInFlight||this._compilationHasWork&&!this._gaugesStalled)||(this._skippedAsyncDraws??0)!==0&&!this._skipStalls.stalled}get _gaugesStalled(){return this._gaugeChangedAt>0&&performance.now()-this._gaugeChangedAt>rF._GAUGE_STALL_MS}_trackGaugeStall(){let t=this._asyncCompilationGauges,e=t!==void 0&&(t.queued>0||t.pipelines>0),i=e?`${t.queued}/${t.pipelines}`:"";return e?i!==this._gaugeSnapshot?(this._gaugeSnapshot=i,void(this._gaugeChangedAt=performance.now())):void(this._gaugesStalled&&!this._gaugeStallWarned&&(this._gaugeStallWarned=!0,console.warn(`[spline/webgpu] async pipeline driver stalled (${i} in flight, no movement for ${rF._GAUGE_STALL_MS}ms) \u2014 treating frames as final so screenshots, thumbnails and the on-demand render loop keep working.`))):(this._gaugeSnapshot="",void(this._gaugeChangedAt=0))}_trackStalledSkips(t){let e=this._compilationHasWork&&!this._gaugesStalled;this._skipStalls.update(t,e),He.stalledSkipFrames=this._skipStalls.frames,this._skipStalls.stalled&&!this._stallWarned&&(this._stallWarned=!0,console.warn(`[spline/webgpu] ${t} draw(s) are permanently skipped \u2014 their render pipelines never became ready (look for "pipeline creation failed" above). Those objects will not appear; the frame is treated as final so screenshots, thumbnails and the on-demand render loop keep working.`))}get _asyncCompilationGauges(){return this.info.asyncCompilation}get _compilationHasWork(){let t=this._asyncCompilationGauges;return t!==void 0&&(t.queued>0||t.pipelines>0)}get asyncCompilationEnabled(){return this._asyncCompilation===!0}setAsyncCompilationPolicy(t){this._asyncCompilationMode!==t&&(this._asyncCompilationMode=t,this._setThreeAsyncCompilation(t),this._updateCompilationBurst())}get taaHistory(){return this._taaHistory||(this._taaHistory=Tbt()),this._taaHistory}async init(){await super.init(),function(e,i=Tq){if(!function(a){return a.isWebGPUBackend===!0}(e)||e.__splineTextureClampInstalled===!0)return;e.__splineTextureClampInstalled=!0;let r=e.createTexture.bind(e),s=e.updateTexture.bind(e),n=()=>e.device?.limits.maxTextureDimension2D??0;e.createTexture=(a,o)=>{uht(a,o,n(),i),r(a,o)},e.updateTexture=(a,o)=>{uht(a,o,n(),i),s(a,o)}}(this.backend);let t=this.backend.gl;if(t&&"drawingBufferColorSpace"in t)try{t.drawingBufferColorSpace="display-p3"}catch(e){console.warn(e)}return this.backend.device?.lost?.then(e=>{He.deviceLost=`${e?.reason??"unknown"}: ${e?.message??""}`.trim()}),this}setSize(t,e,i=!0){if(this._appliedWidth!==t||this._appliedHeight!==e||this._appliedRatio!==this.getPixelRatio()){this._appliedWidth=t,this._appliedHeight=e,this._appliedRatio=this.getPixelRatio();let r=this.viewportWidth!==t||this.viewportHeight!==e;this.viewportWidth=t,this.viewportHeight=e,super.setSize(t,e,i),r&&this.pipeline.resize(t,e,i)}return this}setPixelRatio(t=1){return this.getPixelRatio()!==t&&super.setPixelRatio(t),this}get hdTransmission(){return Vt.transmissionLod.value===1}set hdTransmission(t){Vt.transmissionLod.value=t===!0?1:2}renderScenePass(t,e){this.render(t,e)}_projectObject(t,e,i,r,s){let n=this,a=n._renderLists,o=null;if(t.isBundleGroup===!0&&r===a.get(t,e)){let l=this._bundleLists??(this._bundleLists=new a.constructor(a.lighting,a.objects));n._renderLists=l;let h=this.backend.get(n._bundles.get(t,e,n._currentRenderContext));n.sortObjects&&n._bundleNeedsUpdate(t,h)&&(o=l.get(t,e))}try{Ght.call(this,t,e,i,r,s)}finally{n._renderLists=a}o?.sort(n._opaqueSort,n._transparentSort,e.reversedDepth)}_renderObjects(t,e,i,r,s=null){let n=this,a=s===null&&i.overrideMaterial===null;for(let o=0,l=t.length;o<l;o++){let{object:h,geometry:u,material:d,group:c,clippingContext:p}=t[o];if(a&&nht(d))this._renderWithDepthPrepass(h,i,e,u,d,c,r,p);else{if(a&&this._drawsStalePrepass(h,d,r,s)){let m=d,f=(g,y)=>n._handleObjectFunction(h,g,i,e,r,c,p,y);d.side!==Xs||d.forceSinglePass?f(m.getDepthPrepassTwin(d.side),null):(f(m.getDepthPrepassTwin(ln),null),d.side=ln,f(d,"backSide"),d.side=Xs,f(m.getDepthPrepassTwin(Fo),null))}n._currentRenderObjectFunction(h,i,e,u,d,c,r,p,s)}}}_renderTransparents(t,e,i,r,s){IR.prototype._renderTransparents.call(this,t,e,i,r,s);let n=this.pipeline.depthOfFieldDepthTexture;if(n===null||this.getRenderTarget()?.depthTexture!==n)return;let a=this;for(let{object:o,material:l,group:h,clippingContext:u}of t)!nht(l)||l.getDepthOfFieldTwin===void 0||(a._handleObjectFunction(o,l.getDepthOfFieldTwin(l.side),r,i,s,h,u,null),He.depthOfFieldTwinDraws++)}_drawsStalePrepass(t,e,i,r){if(e.transparent||!this.asyncCompilationEnabled||!("getDepthPrepassTwin"in e))return!1;Yf[0]=t,Yf[1]=e,Yf[2]=this._currentRenderContext,Yf[3]=i;let s=this._objects.getChainMap(r).get(Yf)?.drawMaterial;return Yf.fill(null),s?.transparent===!0&&s.depthWrite===!1}_renderWithDepthPrepass(t,e,i,r,s,n,a,o){let l=this,h=(d,c)=>l._handleObjectFunction(t,d,e,i,a,n,o,c),u=n;t.onBeforeRender(this,e,i,r,s,u),s.side===Xs&&s.forceSinglePass===!1?(h(s.getDepthPrepassTwin(ln),null),s.side=ln,h(s,"backSide"),h(s.getDepthPrepassTwin(Fo),null),s.side=Fo,h(s,null),s.side=Xs,He.depthPrepassDraws+=2):(h(s.getDepthPrepassTwin(s.side),null),h(s,null),He.depthPrepassDraws++),t.onAfterRender(this,e,i,r,s,u)}get skySystem(){return this._skySystem}get skyAnimationActive(){return this._skySystem?.animationActive===!0}*_liveBundledPages(){for(let t of this._bundledPages){let e=t.deref();e===void 0?this._bundledPages.delete(t):yield e}}_armBundleValve(){if(this._bundleValveArmed)return;let t=this.backend.device;typeof t?.addEventListener=="function"&&(this._bundleValveArmed=!0,t.addEventListener("uncapturederror",e=>{if(!this.sceneBundlesEnabled||!(e?.error?.message??"").toLowerCase().includes("destroyed"))return;let i=Vt.frameIndex.value,r=(i-this._destroyedSubmitLastFrame+16)%16;if(this._destroyedSubmitErrors=r<=2?this._destroyedSubmitErrors+1:1,this._destroyedSubmitLastFrame=i,!(this._destroyedSubmitErrors<4)){this.sceneBundlesEnabled=!1,He.bundleDisabled=!0;for(let s of this._liveBundledPages()){let n=this._bundleStates.get(s);n&&(n.disabled=!0),s.isBundleGroup=!1}this._bundledPages.clear()}}))}_updateSceneBundle(t,e){if(this.backend.beginBundle===void 0)return;let i=this._bundleStates.get(t);if(i===void 0){let d={signature:-1,rebuilds:0,resourceRebuilds:0,checks:0,disabled:!1,camHash:0,prevCamHash:0,epoch:0,lastEpoch:0,bufferIds:new WeakMap,bufferIdSeq:0,watched:new WeakSet,onResourceDispose:()=>{d.epoch++}};i=d,this._bundleStates.set(t,i),this._bundledPages.add(new WeakRef(t)),this._armBundleValve()}let r=t;if(i.disabled)return;{let d=e.matrixWorld.elements,c=e.projectionMatrix.elements,p=-2128831035;for(let m=0;m<16;m++)p^=1e4*d[m]|0,p=Math.imul(p,16777619),p^=1e4*c[m]|0,p=Math.imul(p,16777619);i.camHash=p}let s=-2128831035,n=d=>{s^=0|d,s=Math.imul(s,16777619)};n(this._grabTargetEpoch),n(t.fog!==null?1:0),n(this.pipeline.depthOfFieldDepthTexture!==null?1:0);let a=i,o=d=>{let c=d;!c||typeof c.addEventListener!="function"||a.watched.has(c)||(a.watched.add(c),c.addEventListener("dispose",a.onResourceDispose))},l=d=>{if(!d)return 0;let c=a.bufferIds.get(d);return c===void 0&&(c=++a.bufferIdSeq,a.bufferIds.set(d,c)),c},h=d=>{o(d),n(d.id),n(d.version),n(d.transparent===!0?1:0),typeof d.assetsLoaded=="function"&&n(d.assetsLoaded()?1:0)},u=!1;if(t.traverse(d=>{let c=d;if(c.isMesh===!0||c.isLine===!0||c.isPoints===!0||c.isSprite===!0){let p=c;p.isDecalObject===!0&&typeof p.updateDecal=="function"&&p.updateDecal()&&(u=!0),c.runBeforeRenderWhenBundled===!0&&c.onBeforeRender(this,t,e,c.geometry,c.material,null),c.frustumCulled&&(c.frustumCulled=!1),n(c.id),n(c.visible?1:0),n(c.layers.mask),n(c.renderOrder),n(c.matrixWorld.determinantAffine()<0?1:0);let m=c.geometry;o(m),n(m.id),n(m.drawRange.start),n(m.drawRange.count===1/0?-1:m.drawRange.count),n(l(m.index)),n(l(m.attributes.position)),n(m.instanceCount??-1),n(c.count===void 0?-1:c.count);let f=c;n(f.isSkinnedMesh===!0&&f.skeleton?f.skeleton.bones.length:-1);let g=c.material;if(Array.isArray(g))for(let y of g)h(y);else g&&h(g)}else d.isLight===!0?(n(d.id),n(d.visible?1:0),n(d.castShadow?1:0)):(n(d.id),n(d.visible?1:0))}),n(i.epoch),i.checks++,He.bundleChecks=i.checks,i.checks%600==0){let d=this._bundleDebug;He.bundleIncompleteRecords=d?.incompleteRecords??0,He.bundleRecords=d?.records??0,He.bundleReplays=d?.replays??0,i.prevCamHash=i.camHash}if(r.isBundleGroup!==!0)return function(d){let c=d;Object.getOwnPropertyDescriptor(c,"needsUpdate")?.set||Object.defineProperty(c,"needsUpdate",{configurable:!0,enumerable:!1,get:()=>!1,set(p){p===!0&&(this.version=(this.version??0)+1)}}),c.isBundleGroup=!0,c.static=!0,typeof c.version!="number"&&(c.version=0)}(t),void(i.signature=s);if(this.sceneBundlesForceRerecord)return r.version=(r.version??0)+1,void(i.signature=s);if(s!==i.signature){if(i.signature=s,r.version=(r.version??0)+1,i.epoch!==i.lastEpoch||u)return i.lastEpoch=i.epoch,i.resourceRebuilds++,void(He.bundleResourceRebuilds=i.resourceRebuilds);i.rebuilds++,He.bundleRebuilds=i.rebuilds,i.checks>30&&i.rebuilds/i.checks>.1&&(i.disabled=!0,r.isBundleGroup=!1,He.bundleDisabled=!0)}}_ensureWarmupTarget(){if(this._warmupTarget===null){let t=new ii(2,2,{count:2});t.textures[0].name="output",t.textures[0].type=bl,t.textures[1].name="velocity",t.textures[1].type=si;let e=new Ha(2,2);e.isRenderTargetTexture=!0,t.depthTexture=e,this._warmupTarget=t}return this._warmupTarget}get warmupInFlight(){return this._warmupInFlight}setRenderTarget(t,e=0,i=0){this._warmupInFlight?this._warmupPendingTarget=[t,e,i]:super.setRenderTarget(t,e,i)}setMRT(t){return this._warmupInFlight?(this._warmupPendingMRT=[t],this):(super.setMRT(t),this)}async compileSceneAsync(t,e){if(!e)return;{let s=t instanceof Vg?t.activePage:t;fht(gv.isSoft(s?.data?.shadow)),s&&tht(s)}if(this._asyncCompilationMode!==!1)return this._asyncCompilationMode==="load"&&(this._setThreeAsyncCompilation(!0),this._updateCompilationBurst()),this._compileSceneAsyncBackground(t,e);if(this.renderStarted||this._warmupInFlight)return;let i=this.getRenderTarget(),r=this.getMRT();this._warmupInFlight=!0,this._warmupPendingTarget=null,this._warmupPendingMRT=null,this._updateCompilationBurst();try{this.normalizeCameraCoordinateSystem(e),this.temporalAAEnabled&&(super.setRenderTarget(this._ensureWarmupTarget()),super.setMRT(UL())),await this.compileAsync(t,e)}catch(s){console.warn("[spline/webgpu] pipeline warm-up failed:",s)}finally{let s=this._warmupPendingTarget,n=this._warmupPendingMRT;this._warmupInFlight=!1,this._warmupPendingTarget=null,this._warmupPendingMRT=null,this._updateCompilationBurst(),s!==null?super.setRenderTarget(s[0],s[1],s[2]):super.setRenderTarget(i),n!==null?super.setMRT(n[0]):super.setMRT(r)}}async _compileSceneAsyncBackground(t,e){this._asyncLoadWarmupsInFlight++,this._updateCompilationBurst();try{await this.init(),this.normalizeCameraCoordinateSystem(e);let i,r=this.getRenderTarget(),s=this.getMRT();try{this.temporalAAEnabled&&(super.setRenderTarget(this._ensureWarmupTarget()),super.setMRT(UL())),i=this.compileAsync(t,e)}finally{super.setRenderTarget(r),super.setMRT(s)}let n=this._warmupGrabContext(t,e);await i,await n}catch(i){console.warn("[spline/webgpu] pipeline warm-up failed:",i)}finally{this._asyncLoadWarmupsInFlight--,this._updateCompilationBurst(),this._maybeCloseAsyncLoadWindow()}}_disposeWarmupTargets(){this._warmupTarget?.depthTexture?.dispose(),this._warmupTarget?.dispose(),this._warmupTarget=null,this._grabWarmupTarget?.depthTexture?.dispose(),this._grabWarmupTarget?.dispose(),this._grabWarmupTarget=null}_warmupGrabContext(t,e){let i=t instanceof Vg?t:t.scene;if(i.needsTransmission?.()!==!0&&i.needsReflection?.()!==!0)return null;if(this._grabWarmupTarget===null){let n=new ii(2,2);n.texture.type=bl;let a=new Ha(2,2);a.isRenderTargetTexture=!0,n.depthTexture=a,this._grabWarmupTarget=n}let r=this.getRenderTarget(),s=this.getMRT();try{return super.setRenderTarget(this._grabWarmupTarget),super.setMRT(null),this.compileAsync(t,e)}finally{super.setRenderTarget(r),super.setMRT(s)}}_setThreeAsyncCompilation(t){this.setAsyncCompilation(t)}_updateCompilationBurst(){let t=this._warmupInFlight||this._asyncLoadWarmupsInFlight>0||this._asyncCompilationMode==="load"&&this.asyncCompilationEnabled;this.setCompilationBurst(t),He.compilationBurst=t}_maybeCloseAsyncLoadWindow(){this._asyncCompilationMode==="load"&&(!this.asyncCompilationEnabled||this._asyncLoadWarmupsInFlight>0||this._frameSerial!==0&&((this._skippedAsyncDraws??0)>0&&!this._skipStalls.stalled||this._compilationHasWork||(this._setThreeAsyncCompilation(!1),this._updateCompilationBurst())))}normalizeCameraCoordinateSystem(t){let e=t;(e.coordinateSystem!==this.coordinateSystem||e.perspCamera!==void 0&&e.perspCamera.coordinateSystem!==this.coordinateSystem||e.orthoCamera!==void 0&&e.orthoCamera.coordinateSystem!==this.coordinateSystem)&&(e.coordinateSystem=this.coordinateSystem,e.perspCamera!==void 0&&(e.perspCamera.coordinateSystem=this.coordinateSystem),e.orthoCamera!==void 0&&(e.orthoCamera.coordinateSystem=this.coordinateSystem),t.updateProjectionMatrix?.())}_prepareHelpers(t,e,i){t.traverse(r=>{let s=r;if(r.isPoints===!0){let l=function(h){if(Array.isArray(h.material)||h.parent===null||h.geometry.getAttribute("position")===void 0)return null;let u=h.material;return u.isNodeMaterial===!0?null:u.isPointsMaterial===!0?function(d,c){if(c.size<=1)return null;let p=u7.get(d);return p&&(p.epoch!==U1||p.srcMaterial!==c||p.geometry!==d.geometry||p.position.src!==d.geometry.getAttribute("position")||p.map!==c.map||p.selectedMap!==Iht(d))&&(p.sprite.removeFromParent(),p.material.dispose(),p=void 0),p||(p=function(m,f){let g=m.geometry,y=g.getAttribute("position"),v=g.getAttribute("aSelection"),b=g.getAttribute("aVisibility"),_=f.map,x=Iht(m),S=new co(y.array,3);S.setUsage($h);let w={src:y,attr:S,version:y.version},T=[],C=k=>{let B=new co(new Float32Array(k.count),1);B.setUsage($h);let V={src:k,attr:B,version:k.version};return _E(V),T.push(V),V},M=v?C(v):null,A=b?C(b):null,P=new iT;P.name=`SplinePointsTwin(${f.name||f.type})`,P.positionNode=qp(w.attr,"vec3"),P.size=f.size,P.sizeAttenuation=f.sizeAttenuation,P.transparent=f.transparent,P.depthTest=f.depthTest,P.depthWrite=f.depthWrite,P.blending=f.blending,P.fog=!1;let O=M?qp(M.attr,"float"):null,D=A?qp(A.attr,"float"):null;P.colorNode=At(()=>{D!==null?NR(D.lessThan(.5)):O!==null&&NR(O.greaterThan(.5));let k=_!==null?Jt(_,ui()):at(1);return(O!==null&&_!==null&&x!==null?$t(k,Jt(x,ui()),O):k).mul(at(cvt,1))})();let N=new J8(P);N.name=`SplinePointsTwin(${m.name||m.type})`,N.frustumCulled=!1,N.raycast=()=>{};let z={sprite:N,material:P,srcMaterial:f,geometry:g,map:_,selectedMap:x,position:w,mirrors:T,epoch:U1};return I2.add(new WeakRef(z)),z}(d,c),u7.set(d,p)),p.sprite.parent!==d.parent&&d.parent.add(p.sprite),function(m,f){let{sprite:g,position:y,srcMaterial:v}=f;y.version!==y.src.version&&(f.position.attr.needsUpdate=!0,y.version=y.src.version);for(let _ of f.mirrors)_.version!==_.src.version&&(_E(_),_.version=_.src.version);let b=Math.max(0,Math.min(f.geometry.drawRange.count,y.src.count));g.count=b,f.material.size=v.size,f.material.opacity=v.opacity,f.material.color.copy(v.color),g.layers.mask=m.layers.mask,g.renderOrder=m.renderOrder}(d,p),p.sprite}(h,u):function(d,c){if(c.isShaderMaterial!==!0)return!1;let p=c.uniforms,m=p?.pointSize?.value,f=p?.color?.value;return typeof m=="number"&&m>1&&Array.isArray(f)&&f.length>=3&&d.geometry.getAttribute("hover")!==void 0&&d.geometry.getAttribute("selected")!==void 0}(h,u)?function(d,c){let p=d7.get(d);return p&&(p.epoch!==U1||p.srcMaterial!==c||p.geometry!==d.geometry||!function(m,f){let g=[[m.position,"position"],[m.hover,"hover"],[m.selected,"selected"]];for(let[y,v]of g){let b=f.getAttribute(v);if(b===void 0)return!1;if(y.src!==b){if(b.count!==y.attr.count)return!1;y.src=b,y.version=-1}}return!0}(p,d.geometry))&&(p.sprite.removeFromParent(),p.material.dispose(),p=void 0),p||(p=function(m,f){let g=m.geometry,y=f.uniforms,v=(O,D)=>{let N=new co(new Float32Array(O.count*D),D);N.setUsage($h);let z={src:O,attr:N,version:O.version};return _E(z),z},b=v(g.getAttribute("position"),3),_=v(g.getAttribute("hover"),1),x=v(g.getAttribute("selected"),1),S=mt(y.pointSize.value),w=mt(new se().fromArray(y.color.value)),T=new iT;T.name=`SplinePointsTwin(${f.name||f.type})`,T.positionNode=qp(b.attr,"vec3");let C=qp(_.attr,"float"),M=qp(x.attr,"float");T.sizeNode=S.add(C.mul(4)),T.sizeAttenuation=!1,T.transparent=f.transparent,T.depthTest=f.depthTest,T.depthWrite=f.depthWrite,T.blending=f.blending,T.fog=!1,T.colorNode=At(()=>{let O=ci(ui().mul(2).sub(1)).toVar();NR(O.greaterThan(1));let D=pi(M.equal(1),j(.22,.9,.7),w.add(C.mul(.25)));return at(pi(O.greaterThan(.75),j(1),D),1)})();let A=new J8(T);A.name=`SplinePointsTwin(${m.name||m.type})`,A.frustumCulled=!1,A.raycast=()=>{};let P={sprite:A,material:T,srcMaterial:f,geometry:g,pointSize:S,color:w,position:b,hover:_,selected:x,epoch:U1};return I2.add(new WeakRef(P)),P}(d,c),d7.set(d,p)),p.sprite.parent!==d.parent&&d.parent.add(p.sprite),function(m,f){for(let v of[f.position,f.hover,f.selected])v.version!==v.src.version&&(_E(v),v.version=v.src.version);let g=f.srcMaterial.uniforms;f.pointSize.value=g.pointSize.value,f.color.value.fromArray(g.color.value);let y=Math.max(0,Math.min(f.geometry.drawRange.count,f.position.src.count));f.sprite.count=y,f.material.opacity=f.srcMaterial.opacity,f.sprite.layers.mask=m.layers.mask,f.sprite.renderOrder=m.renderOrder}(d,p),p.sprite}(h,u):null}(r);if(l!==null)return l.visible=s.visible,void(s.visible&&(e.push(s),s.visible=!1))}let n=!1,a="",o=Array.isArray(s.material)?s.material:s.material?[s.material]:[];for(let l of o){let h=l;if(h.isShaderMaterial===!0&&h.isNodeMaterial!==!0){n=!0,a=`WebGL-only material "${h.type}"`;break}}if(n&&!Array.isArray(s.material)){let l=function(h){return h.isLineMaterial===!0?function(u){let d=h7.get(u);if(!d||d.epoch!==$R){let g=new U1t;g.name=`SplineHelperTwin(${u.name||u.type})`,g.worldUnits=!1,d={twin:g,epoch:$R},h7.set(u,d),HR.add(new WeakRef(g))}let c=d.twin,p=u;c.color.copy(p.color),c.linewidth=p.linewidth,c.opacity=p.opacity,c.transparent=p.transparent,c.depthTest=p.depthTest,c.depthWrite=p.depthWrite,c.side=p.side;let m=p.dashed===!0;if(c.dashed!==m&&(c.dashed=m,c.needsUpdate=!0),m){let g=c;g.dashScale=p.dashScale??1,g.dashSize=p.dashSize??1,g.gapSize=p.gapSize??1}let f=p.vertexColors===!0||p.vertexColors===2;return c.vertexColors!==f&&(c.vertexColors=f,c.needsUpdate=!0),c}(h):null}(s.material);if(l)return i.push({object:s,original:s.material}),void(s.material=l)}!n&&s.geometry?.isInstancedBufferGeometry===!0&&!Number.isFinite(s.geometry.instanceCount??0)&&(n=!0,a="infinite instanceCount geometry"),n&&s.visible&&(this._warnedHelperIncompat.has(r)||this._warnedHelperIncompat.add(r),e.push(s),s.visible=!1)})}renderHelperOverlay(t,e,i,r){let s=[],n=[];if(t&&this._prepareHelpers(t,s,n),e&&this._prepareHelpers(e,s,n),r)this._helperOverlay??(this._helperOverlay=new Dbt),this._helperOverlay.render(this,t,e,i,r),He.helperOverlayMode="smaa";else{let a=this.autoClear;this.autoClear=!1,t&&this.render(t,i),e&&(this.clearDepth(),this.render(e,i)),this.autoClear=a,He.helperOverlayMode="direct"}for(let a of n)a.object.material=a.original;for(let a of s)a.visible=!0}createEffectChain(){return function(t){let e=t.pipeline,i=e.postprocessingState,r=i.enabled===!0,s=Avt(e.scene,e.camera),n=t.hdrChainActive;try{let M=new URLSearchParams(window.location.search).get("dbgfp16");(M==="scene"||M==="st")&&(n=!0)}catch{}let a=s.getTextureNode(),o=a,l=null;if(t.temporalAAEnabled){s.setMRT(UL()),l=function(M,A,P,O,D=!1){return new Ebt(M,A,P,O,D)}(a,s.getTextureNode("depth"),s.getTextureNode("velocity"),t.taaHistory,n),o=l,s.getTexture("velocity").type=si;try{if(new URLSearchParams(window.location.search).get("dbgvel")==="1"){let M=Oh(s.getTextureNode("velocity"));o=at(XR(M.x).mul(20).add(.5),XR(M.y).mul(20).add(.5),I(.5),I(1))}}catch{}}n?s.getTexture("output").type=si:jD()&&(s.getTexture("output").internalFormat="rgba8unorm-srgb");let h=(M,A)=>typeof M=="number"&&Number.isFinite(M)?M:A,u={bloomIntensity:mt(1),caOffset:mt(new Y(0,0)),caAspect:mt(1),vignetteOffset:mt(0),vignetteDarkness:mt(0),hueVector:mt(new E(1,0,0)),saturationFactor:mt(0),brightness:mt(0),bcContrastScale:mt(1),dofFocusDistance:mt(0),dofFocalLength:mt(0),dofBokehScale:mt(1),dofCameraNear:mt(50),dofCameraFar:mt(1e4),dofOrtho:mt(0),pixelCells:mt(new Y(1,1)),bloomOpacity:mt(1),caOpacity:mt(1),vignetteOpacity:mt(1),noiseOpacity:mt(1),hueSaturationOpacity:mt(1),brightnessContrastOpacity:mt(1),dofOpacity:mt(1)},d=M=>XR(M),c=(M,A)=>{u.bloomIntensity.value=h(M.bloom.intensity,1),u.bloomOpacity.value=h(M.bloom.opacity,1),u.caOffset.value.set(h(M.chromaticAberration.offset?.[0],10),h(M.chromaticAberration.offset?.[1],10)),u.caOpacity.value=h(M.chromaticAberration.opacity,1),u.vignetteOffset.value=h(M.vignette.offset,.5),u.vignetteDarkness.value=h(M.vignette.darkness,.5),u.vignetteOpacity.value=h(M.vignette.opacity,1),u.noiseOpacity.value=h(M.noise.opacity,1),u.hueVector.value.fromArray(function(V){let q=Math.sin(V),W=Math.cos(V);return[(2*W+1)/3,(-Math.sqrt(3)*q-W+1)/3,(Math.sqrt(3)*q-W+1)/3]}(h(M.hueSaturation.hue,0))),u.saturationFactor.value=function(V){return V>0?1-1/(1.001-V):-V}(h(M.hueSaturation.saturation,0)),u.hueSaturationOpacity.value=h(M.hueSaturation.opacity,1),u.brightness.value=h(M.brightnessContrast.brightness,0);let P=Math.min(h(M.brightnessContrast.contrast,0),.9999);u.bcContrastScale.value=P>0?1/(1-P):1+P,u.brightnessContrastOpacity.value=h(M.brightnessContrast.opacity,1);let O=e.camera,D=O?.isPerspectiveCamera===!0,N=function(V,q,W){return{focusDistance:W?V/2e3:(V+992)/2e3,focusRange:Math.max(q/2e3,1e-6)}}(h(M.depthOfField.focusDistance,jR.focusDistance),h(M.depthOfField.focalLength,jR.focalLength),D);u.dofFocusDistance.value=N.focusDistance,u.dofFocalLength.value=N.focusRange,u.dofBokehScale.value=h(M.depthOfField.bokehScale,jR.bokehScale),u.dofOpacity.value=h(M.depthOfField.opacity,1),u.dofCameraNear.value=h(O?.near,50),u.dofCameraFar.value=h(O?.far,1e4),u.dofOrtho.value=D?0:1;let z=A.resolution.x?A.resolution:new Y(A.viewportWidth*A.getPixelRatio(),A.viewportHeight*A.getPixelRatio());u.caAspect.value=z.y>0?z.x/z.y:1;let k=Math.floor(h(M.pixelation.granularity,30));k%2>0&&(k+=1);let B=k>0;u.pixelCells.value.set(B?z.x/k:z.x,B?z.y/k:z.y)};c(i,t);let p=Oh(o),m=p.rgb,f=p.a,g=r&&i.pixelation.enabled,y=u.pixelCells,v=M=>M.mul(y).floor().add(.5).div(y),b=l?l.outputTextureNode:a;if(g){let M=Oh(b.sample(v(ui())));m=$t(m,M.rgb,1),f=$t(f,M.a,1)}if(r&&i.chromaticAberration.enabled){let M=i.chromaticAberration,A=u.caOffset.mul(.001).mul(st(1,d(u.caAspect))),P=z=>g?v(z):z,O=Oh(b.sample(P(ui().add(A)))),D=Oh(b.sample(P(ui().sub(A)))),N=Kt(Kt(O.a,D.a),f);m=qf(m,j(O.r,m.g,D.b),M.blendFunction,d(u.caOpacity),N),f=FL(f,N,M.blendFunction,d(u.caOpacity))}let _=null;if(r&&i.depthOfField.enabled){let M=hQ("depthOfField");if(M){let A=i.depthOfField;_=M(at(m,f),b,s.getTextureNode("depth"),{focusDistance:d(u.dofFocusDistance),focusRange:d(u.dofFocalLength),bokehScale:d(u.dofBokehScale),cameraNear:d(u.dofCameraNear),cameraFar:d(u.dofCameraFar),orthographic:d(u.dofOrtho)},{halfFloat:n,inputUv:g?v:void 0});let P=Oh(_);m=qf(m,P.rgb,A.blendFunction,d(u.dofOpacity),P.a),f=FL(f,P.a,A.blendFunction,d(u.dofOpacity))}else uQ("depthOfField","webgpu")}let x=null;if(r&&i.bloom.enabled){let M=hQ("bloom");if(M){let A=i.bloom;x=M(l?l.outputTextureNode:a,{kernelSize:I3t(A.kernelSize),blurScale:h(A.blurScale,1),luminanceThreshold:h(A.luminanceThreshold,.9),luminanceSmoothing:h(A.luminanceSmoothing,.025)});let P=Te(Oh(x).mul(d(u.bloomIntensity)),0,1);m=qf(m,P.rgb,A.blendFunction,d(u.bloomOpacity),P.a),f=FL(f,P.a,A.blendFunction,d(u.bloomOpacity))}else uQ("bloom","webgpu")}if(r&&i.hueSaturation.enabled){let M=i.hueSaturation,A=u.hueVector,P=j(Bt(m,A),Bt(m,A.zxy),Bt(m,A.yzx)),O=P.r.add(P.g).add(P.b).div(3);m=qf(m,P.add(j(O).sub(P).mul(d(u.saturationFactor))).min(1),M.blendFunction,d(u.hueSaturationOpacity),f)}if(r&&i.brightnessContrast.enabled){let M=i.brightnessContrast,A=m.add(j(d(u.brightness)));A=A.sub(.5).mul(d(u.bcContrastScale)).add(.5),m=qf(m,A.min(1),M.blendFunction,d(u.brightnessContrastOpacity),f)}if(r&&i.vignette.enabled){let M=i.vignette,A=ci(ui().sub(.5)).mul(d(u.vignetteDarkness).add(d(u.vignetteOffset))),P=Ji(d(u.vignetteOffset).mul(.799),I(.8),A).oneMinus();m=qf(m,m.mul(P),M.blendFunction,d(u.vignetteOpacity),f)}if(r&&i.noise.enabled){let M=i.noise,A=Di(Bn(qh(Bt(ui().mul(Uvt),st(12.9898,78.233)),Math.PI)).mul(43758.5453));m=qf(m,j(A),M.blendFunction,d(u.noiseOpacity),f)}r&&(n?m=m.max(0):(m=Te(m,0,1),f=Te(f,0,1)));let S=at(m,f);if(e.uiOverlayEnabled&&e.uiCanvasTexture){let M=Oh(Jt(e.uiCanvasTexture,ui().flipY())),A=$t(S.rgb,M.rgb,M.a),P=Te(S.a.add(M.a),0,1);S=at(A,P)}let w=e.sceneTransitionFromTexture;if(w){let M=Oh(Jt(w,ui())),A=e.sceneTransitionPass.uniforms.mixRatio;S=$t(M,S,A)}let T=e.watermarkTexture;if(T){let M=T.image,A=M?.width||128,P=M?.height||32,O=new Y(t.viewportWidth*t.getPixelRatio(),t.viewportHeight*t.getPixelRatio()),D=12*t.getPixelRatio(),N=.5*A*t.getPixelRatio(),z=.5*P*t.getPixelRatio(),k=st((O.x-N-D)/O.x,D/O.y),B=st(N/O.x,z/O.y),V=ui().flipY().sub(k).div(B),q=V.x.greaterThanEqual(0).and(V.x.lessThanEqual(1)).and(V.y.greaterThanEqual(0)).and(V.y.lessThanEqual(1)),W=Te(V,0,1),H=Oh(Jt(T,W)),rt=H.a.mul(q.select(I(1),I(0)));S=at($t(S.rgb,H.rgb,rt),Te(S.a.add(rt),0,1))}let C=new G1t(t,S);return{syncValues:c,render(){s.scene=e.scene,s.camera=e.camera,C.render()},renderTAAResolve:l?M=>{s.scene=e.scene,s.camera=e.camera,l.renderResolve(M)}:null,renderBloomPasses:x?M=>{s.scene=e.scene,s.camera=e.camera,x.renderBloom(M)}:null,renderDoFPasses:_?M=>{s.scene=e.scene,s.camera=e.camera,_.renderDoF(M)}:null,resize(){},sceneDepthTexture:()=>s.renderTarget?.depthTexture??null,dispose(){l?.dispose(),x?.dispose(),_?.dispose(),s.dispose(),C.dispose()}}}(this)}renderSplineSceneWithDummyCamera(t,e,i=1){this.dummyCamera.updateCameraState(e.dataPatched),this.dummyCamera.matrix.copy(e.matrixWorld);let r=e.height,s=e.width,n=this.viewportWidth/this.viewportHeight;s<r?s=r*n:r=s/n,this.dummyCamera.setViewplaneSize(s,r);for(let a=0;a<i;a++)this.renderSplineScene(t,this.dummyCamera)}renderSplineScene(t,e,{sceneHelpers:i=this.sceneHelpers,sceneHelpersOnTop:r=this.sceneHelpersOnTop}={}){if(this._warmupInFlight)return;this._maybeCloseAsyncLoadWindow(),this._frameSerial++,this._disposeRetiredGrabTargets(),(Yj()?.drainRetired()??0)+(Zj()?.drainRetired()??0)>0&&this._retireBundleRecords(),X9&&function(y){if(y==null||y===Z9)return;let v=y;typeof v.addEventListener=="function"&&(Z9=y,v.addEventListener("uncapturederror",b=>{let _=b?.error?.message??"";!_.toLowerCase().includes("destroyed")||Y9<=0||(Y9--,console.warn(`[spline/webgpu][dbgdestroys] submit rejected at frame ${A5()} (t=${Math.round(performance.now())}ms):
|
|
2016
2016
|
${_.slice(0,400)}
|
|
2017
2017
|
\u2014 last ${Ev.length} destroy() calls, newest last (a stack WITHOUT _disposeRetiredGrabTargets bypassed the deferral):`,Ev.map(x=>({...x}))))}))}(this.backend.device);let s=this._skippedAsyncDraws??0;He.skippedAsyncDraws=s,this._skippedAsyncDraws=0,this._trackStalledSkips(s),this._trackGaugeStall(),function(y){if(vS.size===0)return;let v=Array.from(vS);vS.clear();for(let b of v)b.render(y)}(this);let n=t instanceof Vg?t.activePage:t,a=n.visible;n.visible=!0;let o=n.scene;if(tht(n),this.renderStarted=!0,eF&&t instanceof Vg){let y=t.updateInstanceGroups(n,iF);He.instancingGroups=y.instancingGroups,He.instancedDrawsSaved=y.instancedDrawsSaved,He.instancingRegroups=y.instancingRegroups,He.instancingParks=y.instancingParks,He.instancingIneligible=y.instancingIneligible}this.sceneBundlesEnabled&&this._bundleEpochDirty&&(this._bundleEpochDirty=!1,this._updateSceneBundle(n,e)),this.normalizeCameraCoordinateSystem(e),this._applyCIOffscreenTargetIfRequested(),this.setClearColor(n.bgColor,n.bgColor.a),this.clearAlphaOverride!==void 0&&this.setClearAlpha(this.clearAlphaOverride);let l=YL?null:n.skyState;if(l?.enabled===!0){if(this.skyEnvironmentNeeded=!this.auxiliary&&(!AE&&(o.needsReflectionDirty||o.needsReflection())||!CE&&l.lighting===!0),this._skySystem===null){let y=Cq;y===null?this._skyFeatureWarned||(this._skyFeatureWarned=!0,console.warn("[spline] scene uses the atmospheric sky, but the sky feature is compiled out of this build")):this._skySystem=y(this)}this._skySystem?.update(n,e)}else this._skySystem?.attached&&this._skySystem.detach();if(!this.auxiliary){let y=null,v=0;!CE&&l?.enabled===!0&&this._skySystem&&(y=this._skySystem.iblTexture??null,v=this._skySystem.iblRotationY??0);let b=n.scene??n,_=vq;if(this._envClaimScope!==b||this._envClaimEpoch!==_){this._envClaimScope=b,this._envClaimEpoch=_;let x=!1;b.traverse(S=>{let w=S.material,T=Array.isArray(w)?w:[w];for(let C of T)C?.claimEnvironmentScope?.(b)&&(x=!0)}),x&&OL(b)}(function(x,S){let w=Cv(x);w.quality!==S&&(w.quality=S,OL(x))})(b,l?.lightingQuality==="low"?"low":"full"),function(x,S){let w=Cv(x);w.texture!==S&&(w.texture=S,w.version++,OL(x))}(b,y),Cv(b).rotation.set(0,-v,0),n.environmentIntensity=l?.enabled===!0?l.lightingIntensity??1:1}{let y=Ap==="off"?null:n.gradingState,v=Ap!=="default"&&Ap!=="off",b=v||y?.pipeline==="linear",_=v?Ap==="linear"?"none":Ap:y?.toneMapping??"aces";this.toneMapping=b?_==="aces"?wG:_==="agx"?SG:_==="neutral"?TG:cl:cl,this.toneMappingExposure=b?y?.exposure??1:1,this.outputColorSpace=b?Ns:Hu,this.hdrChainActive=b,this.temporalAAEnabled&&this.taaHistory.setHdr(b)}Vt.pixelRatio.value=this.getPixelRatio(),this.resolution.x!==0&&this.resolution.y!==0?Vt.resolution.value.set(this.resolution.x,this.resolution.y):Vt.resolution.value.set(this.viewportWidth*this.getPixelRatio(),this.viewportHeight*this.getPixelRatio());let h=(Vt.frameIndex.value+1)%16;Vt.frameIndex.value=h;let u=ubt[h];Vt.pcssHalton.value.set(u[0],u[1]),Vt.tapAngle.value=Math.random()*Math.PI*2,Vt.tapAngle2.value=Math.random()*Math.PI*2,this._syncLightState(n),this.sceneBundlesEnabled&&this._lightShadowStateDirty&&(this._lightShadowStateDirty=!1,this._updateSceneBundle(n,e)),Vt.unjitteredProjection.value.copy(e.projectionMatrix);let d=this.temporalAAEnabled?this.taaHistory:null;if(d){let y=this.getDrawingBufferSize($f);d.beginJitter(e,y.x,y.y)}this._renderShadowMaskPass(n,e),Vt.orthographicUniform.value=e.projectionMatrix.elements[11]===0?1:0;let c=o.shapeBlendIntances.length>0?qW:null;if(c!==null)for(let y of o.shapeBlendIntances)c(y).update(y,this,e);let p=o.hairInstances.length>0?UW:null;if(p!==null)for(let y of o.hairInstances)p(y).update(y,this);o.needsTransmission()&&this._renderTransmissionPass(n,e),o.needsNormal()&&this._renderNormalPass(n,e,o.normalPassNeeds()),n.overrideMaterial=o.wireframeState?b1t:null,e.layers.enable(3),e.layers.enable(8),e.layers.enable(4);let m=n.data.ao,f=m.occlusion&&!HL&&!N2.enabled;if(Vt.aoEnabled.value=f,Vt.aoEnabledUniform.value=f?1:0,f){let y=this,v=y._skippedAsyncDraws??0;this._renderAOPass(n,e,m),(y._skippedAsyncDraws??0)>v&&(Vt.aoEnabledUniform.value=0)}if(!AE&&o.needsReflection()?(this._renderReflectionPass(n,e),KL?Vt.reflectionPlanarEnabled.value=0:this._renderPlanarReflectionPass(n,e),this._renderReflectionResolvePass(n,e)):Vt.reflectionResolveEnabled.value=0,this.sceneBundlesEnabled&&this._updateSceneBundle(n,e),this.pipeline.isUIOverlayEnabled&&n.uiCanvas?.enabled&&n.uiCanvas.texture&&n.uiCanvas.texture.image.width>0){let y=this.getPixelRatio();(n.uiCanvas.width!==this.viewportWidth||n.uiCanvas.height!==this.viewportHeight||n.uiCanvas.dpr!==y)&&n.uiCanvas.applySize({width:this.viewportWidth,height:this.viewportHeight},y),n.uiCanvas.render(this),this.pipeline.uiCanvasTexture=n.uiCanvas.texture,this.pipeline.uiOverlayEnabled=!0}else this.pipeline.uiOverlayEnabled=!1;this.pipeline.sceneHelpers=i,this.pipeline.sceneHelpersOnTop=r,this.pipeline.scene=n,this.pipeline.camera=e;let g=function(y){if(!N2.enabled)return y;let v=p7.get(y);return v||(v={...y,bloom:{...y.bloom,kernelSize:0},depthOfField:{...y.depthOfField,enabled:!1}},p7.set(y,v)),v}(n.postprocessing);if(this.pipeline.postprocessingState!==g&&this.pipeline.updatePostprocessing(g),this.pipeline.render(),d?.endJitter(),this._skySystem?.endFrame?.(),He.outputInterpositions=this._frameBufferTargets?.size??0,this.manageShadowUpdates){let y=(this._skippedAsyncDraws??0)>0&&!this._skipStalls.stalled,v=this.info.asyncCompilation?.promotions??0,b=v!==this._shadowSyncPromotions;this._shadowSyncPromotions=v,o.shadowsDirty=this._shadowMapMissingAtSync||this._warmupInFlight||y||b}e instanceof zs&&e.copyHistory(),n.visible=a}_fitDirectionalShadowRange(t,e,i){if(i===0)return;let r=t.shadow.camera,s=t.shadow;s.__speRangeEnvelope||(s.__speRangeEnvelope={near:r.near,far:r.far});let n=s.__speRangeEnvelope.near,a=t.data?.depth??s.__speRangeEnvelope.far;if(s.__speRangeEnvelope.far=a,Ly.setFromMatrixPosition(t.matrixWorld),t.target?(t.target.updateMatrixWorld(),SE.setFromMatrixPosition(t.target.matrixWorld)):SE.set(0,0,0),Xf.subVectors(SE,Ly),Xf.lengthSq()<1e-10)return;Xf.normalize();let o=1/0,l=-1/0;for(let c=0;c<i;c++){let p=4*c,m=(e[p]-Ly.x)*Xf.x+(e[p+1]-Ly.y)*Xf.y+(e[p+2]-Ly.z)*Xf.z,f=e[p+3];m-f<o&&(o=m-f),m+f>l&&(l=m+f)}let h=Math.max(10,.05*(l-o)),u=25*Math.floor((o-h)/25),d=25*Math.ceil((l+h)/25);u=Math.max(u,n),d=Math.min(d,a),d-u>=1&&(r.near!==u||r.far!==d)&&(r.near=u,r.far=d,r.updateProjectionMatrix())}_gatherShadowBounds(t){let e=0;return t.traverseVisible(i=>{let r=i;if(r.castShadow!==!0&&r.receiveShadow!==!0)return;if(r.isHairSystem===!0){let l=r.shadowBoundsRadius??0;if(l>0){r.getShadowBoundsCenter?r.getShadowBoundsCenter(wu):wu.setFromMatrixPosition(r.matrixWorld);let h=4*e;Su[h]=wu.x,Su[h+1]=wu.y,Su[h+2]=wu.z,Su[h+3]=l,e++}return}if(r.isMesh!==!0||!r.geometry||r.isInstanceGroup===!0)return;let s=r.geometry.boundingSphere;s===null&&(r.geometry.computeBoundingSphere(),s=r.geometry.boundingSphere);let n=r;if(n.isInstancedMesh===!0&&(n.boundingSphere===null&&n.computeBoundingSphere(),s=n.boundingSphere??s),!s||!Number.isFinite(s.radius)||s.radius<=0)return;wu.copy(s.center).applyMatrix4(r.matrixWorld),cw.setFromMatrixScale(r.matrixWorld);let a=s.radius*Math.max(Math.abs(cw.x),Math.abs(cw.y),Math.abs(cw.z)),o=4*e;Su[o]=wu.x,Su[o+1]=wu.y,Su[o+2]=wu.z,Su[o+3]=a,e++}),e}_syncLightState(t){let e=gv.isSoft(t.data.shadow);fht(e),He.shadowTypeSoft=e,function(d){switch(d){case"low":nc=8;break;case"high":nc=32;break;default:nc=16}}(t.data.shadow?.softShadowQuality),e&&a7()&&(qR||(this.initTexture?.(J9()),qR=!0));let i=-1;He.pcssLights=0,He.pcssPyramidActive=0,this._maskLights.length=0,this._maskBlocked=!1,He.nodeResurrections=this._nodes?._spResurrections??0;let r=!1,s=Vt.toonLightData.array,n=0;!N2.enabled&&!TE&&function(d){mg.length=0,d.traverseVisible(m=>{(function(f){let g=f;return g.isPointLight===!0||g.isSpotLight===!0||g.isDirectionalLight===!0})(m)&&(m.castShadow===!0||mS.has(m))&&mg.push(m)});let c=!1;if(mg.length===0)return c;mg.sort((m,f)=>zZ(m)-zZ(f)||m.id-f.id);let p=12;for(let m of mg){let f=KCt(m);f<=p?(p-=f,mS.delete(m)&&(m.castShadow=!0,c=!0)):m.castShadow===!0&&(m.castShadow=!1,mS.add(m))}return mg.length=0,c}(t)&&(t.scene.shadowsDirty=!0);let a=this.manageShadowUpdates,o=t.scene.shadowsDirty||this.forceShadowUpdates;this._shadowMapMissingAtSync=!1;let l=-2128831035,h=d=>{l^=0|d,l=Math.imul(l,16777619)};t.traverseVisible(d=>{let c=d;if(function(p){if(!p.isPointLight&&!p.isSpotLight&&!p.isDirectionalLight)return!1;if(N2.enabled){if(p.castShadow===!0)return p.castShadow=!1,KR.add(p),!0}else if(KR.has(p)&&(KR.delete(p),p.castShadow===!1))return p.castShadow=!0,!0;return!1}(c)&&(t.scene.shadowsDirty=!0),a&&(c.isPointLight||c.isSpotLight||c.isDirectionalLight)&&c.shadow&&(c.shadow.autoUpdate=o,o&&c.castShadow===!0&&!this._shadowMapRendered(c.shadow)&&(this._shadowMapMissingAtSync=!0)),TE&&(c.isPointLight||c.isSpotLight||c.isDirectionalLight)&&c.castShadow&&(c.castShadow=!1),(c.isPointLight||c.isSpotLight||c.isDirectionalLight)&&(h(d.id),h(c.castShadow===!0?1:0),h(this._shadowMapId(c.shadow?.map))),c.isPointLight&&c.castShadow&&c.shadow&&(function(p){p.filterNode!==void 0&&p.filterNode!==null?p.filterNode!==D5&&He.pcssForeignFilter++:(p.filterNode=D5,He.pcssInstalled++)}(c.shadow),mht(c.shadow),He.pcssLights++),(c.isSpotLight||c.isDirectionalLight)&&c.castShadow&&c.shadow){c.isDirectionalLight&&(i<0&&(i=this._gatherShadowBounds(t)),this._fitDirectionalShadowRange(c,Su,i)),function(f){f.filterNode!==void 0&&f.filterNode!==null?f.filterNode!==R5&&He.pcssForeignFilter++:(Object.defineProperty(f,"penumbraSize",{get:()=>c.data?.penumbraSize??.5,configurable:!0}),f.filterNode=R5,He.pcssInstalled++)}(c.shadow);let p,m=!a||o||c.shadow.needsUpdate===!0;if(e&&a7()&&(m?function(f){let g=f;g.__spePcssPyramid&&(g.__spePcssPyramid.fresh=!1)}(c.shadow):pht(c.shadow)||function(f,g){let y=g,v=y.map?.depthTexture??null;if(v==null)return!1;let b=cht(g);if(function(T){let C=cht(T);if(C.slot>=0)return C.slot;for(let M=0;M<C5;M++){let A=WR[M];if(A===null||A.deref()===void 0)return WR[M]=new WeakRef(T),C.slot=M,M}return-1}(g)<0)return!1;let _=Math.max(1,Math.round(y.mapSize?.x??2048)),x=b.slot*Tc,S=`${v.uuid}:${_}`;b.passKey!==S&&(b.toMid?.material?.dispose(),b.toSmall?.material?.dispose(),b.mid===null&&(b.mid=Q9(L1,L1),b.mid.texture.name="SplinePCSSPyramidMid"),b.small===null&&(b.small=Q9(Tc,Tc),b.small.texture.name="SplinePCSSPyramidSmall"),b.toMid=new Pr(dht(`SplinePCSSPyramidToMid${_}`,v,Math.ceil(_/L1),_-1,!1,0)),b.toSmall=new Pr(dht("SplinePCSSPyramidToSmall",b.mid.texture,L1/Tc,L1-1,!0,0)),b.passKey=S),J9();let w=f.getRenderTarget();f.setRenderTarget(b.mid),b.toMid.render(f),f.setRenderTarget(b.small),b.toSmall.render(f),f.setRenderTarget(w),r7.set(x,0,0),f.copyTextureToTexture(b.small.texture,Kg.texture,null,r7),b.fresh=!0,He.pcssPyramidBuilds++}(this,c.shadow),p={slot:nPt(c.shadow),fresh:pht(c.shadow)}),e&&o7()&&(lbt(c.shadow,-1),this._maskLights.push({light:c,shadow:c.shadow}),(m||c.shadow.map==null)&&(this._maskBlocked=!0)),mht(c.shadow,c.data?.penumbraSize??.5,p)&&He.pcssPyramidActive++,!r){r=!0;let f=c.shadow;He.pcssRadius0=f.radius??-1,He.pcssPenumbra0=f.penumbraSize??-1}He.pcssLights++}if(!(n>=k9)){if(c.isPointLight||c.isSpotLight)Vy.setFromMatrixPosition(c.matrixWorld),s[n].set(Vy.x,Vy.y,Vy.z,0),n++;else if(c.isDirectionalLight&&c.target){c.target.updateMatrixWorld();let p=Vy;p.setFromMatrixPosition(c.matrixWorld),p.sub(Nht.setFromMatrixPosition(c.target.matrixWorld)).normalize(),s[n].set(p.x,p.y,p.z,1),n++}}}),Vt.toonLightCount.value=n;let u=this._lightShadowSignatures.get(t);this._lightShadowSignatures.set(t,l),this._lightShadowStateDirty=u!==void 0&&u!==l}_shadowMapId(t){if(t==null)return 0;let e=this._shadowMapIds.get(t);return e===void 0&&(e=++this._shadowMapIdSeq,this._shadowMapIds.set(t,e)),e}_renderShadowMaskPass(t,e){let i=0;if(o7()&&!this.suppressShadowMask&&this.manageShadowUpdates&&!this._maskBlocked&&this._maskLights.length>=1&&this._maskLights.length<=4&&this._maskLights.every(r=>r.shadow.map?.depthTexture!=null)){this._shadowMask??(this._shadowMask=new gbt);let{targetsChanged:r}=this._shadowMask.render(this,t,e,this._maskLights);r&&this._grabTargetEpoch++,i=this._maskLights.length}Vt.shadowMaskEnabled.value=i>0?1:0,He.shadowMaskActive=i}retireRenderTarget(t){t&&this._retiredGrabTargets.push(t),this._grabTargetEpoch++}_disposeRetiredGrabTargets(){if(this._retiredGrabTargets.length>0){for(let t of this._retiredGrabTargets)t.dispose();this._retiredGrabTargets.length=0}if(this._retiredGpuBuffers.length>0){for(let t of this._retiredGpuBuffers)try{t.destroy()}catch{}this._retiredGpuBuffers.length=0}}_retireBundleRecords(){for(let t of this._liveBundledPages())this._bundleStates.get(t)?.onResourceDispose();this._bundleEpochDirty=!0}_deferGpuBufferDestruction(){let t=this.backend,e=this._retiredGpuBuffers;t.destroyUniformBuffer=r=>{let s=t.get(r);s?.buffer&&e.push(s.buffer),t.delete(r),this._retireBundleRecords()};let i=t.attributeUtils;if(i){let r=i._getBufferAttribute.bind(i);i.destroyAttribute=s=>{let n=t.get(r(s));n?.buffer&&e.push(n.buffer),t.delete(s),this._retireBundleRecords()}}}_reallocGrabTarget(t,e,i,r){return t&&t.width===e&&t.height===i?t:(this.retireRenderTarget(t),r())}_shadowMapRendered(t){return t.map!=null&&this._textures.get(t.map).initialized===!0}_withShadowUpdatesSuspended(t,e){let i=[];t.traverse(r=>{let s=r;if(s.isLight&&s.shadow){if(!this._shadowMapRendered(s.shadow))return;i.push({shadow:s.shadow,auto:s.shadow.autoUpdate,needs:s.shadow.needsUpdate}),s.shadow.autoUpdate=!1,s.shadow.needsUpdate=!1}});try{e()}finally{for(let r of i)r.shadow.autoUpdate=r.auto,r.shadow.needsUpdate=r.needs}}_renderPrepass(t,e){this._withShadowUpdatesSuspended(t,()=>{this.render(t,e)})}_renderAOPass(t,e,i){let r=this.getDrawingBufferSize($f),s=Math.max(1,Math.round(r.x)),n=Math.max(1,Math.round(r.y));this._aoRenderTarget=this._reallocGrabTarget(this._aoRenderTarget,s,n,()=>new ii(s,n,{depthBuffer:!1})),Vt.aoRenderTarget.value=this._aoRenderTarget.texture,this._hbao||(this._hbao=new Jvt);let a=t;this._hbao.render(this,t,e,{radius:i.radius,bias:i.bias??.5,aoFullRes:i.aoFullRes===!0,aoColor:a.aoColor??{r:0,g:0,b:0},fogEnabled:(a.fog??null)!==null,fogNear:a.backupFog?.near??1,fogFar:a.backupFog?.far??1e3,fogMode:Jn.getModeIndex({mode:t.fogMode}),fogDensity:t.fogDensity??Jn.getDensity({}),fogHeightFalloff:t.fogHeightFalloff??Jn.getHeightFalloff({}),fogHeightBase:t.fogHeightBase??Jn.getHeightBase({})},this.pipeline.blueNoiseTexture,this._aoRenderTarget)}_renderNormalPass(t,e,i){let r=i.outline&&i.cavity?"both":i.cavity?"normals":"hash",s=this.getDrawingBufferSize($f),n=Math.max(1,Math.round(s.x)),a=Math.max(1,Math.round(s.y));this._normalTarget!==void 0&&this._normalTargetFlavor!==r&&(this.retireRenderTarget(this._normalTarget),this._normalTarget=void 0),this._normalTargetFlavor=r,this._normalTarget=this._reallocGrabTarget(this._normalTarget,n,a,()=>{let p=new ii(n,a,{count:r==="both"?2:1,type:r==="normals"?si:Ye,depthTexture:new Ha(n,a)});r==="both"&&(p.textures[0].name="g0",p.textures[1].name="g1",p.textures[1].type=si);for(let m of p.textures)m.minFilter=Re,m.magFilter=Re;return p});let o=this._encodeMaterials[r];if(o===void 0){this._depthContrastUniform??(this._depthContrastUniform=mt(1));let p=new Pe;p.name=`SplineNormalPassEncode_${r}`;let m=_q(),f=()=>{let y=be(sT),v=BD.sub(.5).mul(this._depthContrastUniform).add(.5),b=$t($t(m,y,.2),j(v),.4);return at(b,m.x)},g=()=>{let y=be(Ra),v=pi(nvt,y,y.negate());return at(v,m.x)};p.fragmentNode=r==="both"?Kv({g0:f(),g1:g()}):r==="normals"?g():f(),p.lights=!1,p.blending=Wi,p.needsUpdate=!0,this._encodeMaterials[r]=p,o=p}this._depthContrastUniform.value=e instanceof zs?(e.far-e.near)/1e4:1;let l=t.overrideMaterial,h=this.getRenderTarget(),u=this.getClearColor(Bht),d=this.getClearAlpha();e.layers.enable(8),e.layers.disable(0),e.layers.disable(3),t.overrideMaterial=o,this.setClearColor(0,0),this.setRenderTarget(this._normalTarget),this._renderPrepass(t,e),this.setRenderTarget(h),this.setClearColor(u,d),t.overrideMaterial=l,e.layers.enable(0),e.layers.enable(3);let c=this._normalTarget.textures;Vt.normalRenderTarget.value=r==="normals"?Vo:c[0],Vt.normalRenderTargetDepth.value=this._normalTarget.depthTexture,Vt.normalViewRenderTarget.value=r==="both"?c[1]:r==="normals"?c[0]:Vo}blitTextureToTarget(t,e){let i=this._uiBlitPass;if(!i){let n=Jt(Vo),a=new Pe;a.name="SplineUICanvasBlit",a.fragmentNode=n.sample(ui()),a.lights=!1,a.blending=Wi,a.depthTest=!1,a.depthWrite=!1,a.needsUpdate=!0,i={quad:new Pr(a),input:n},this._uiBlitPass=i}let r=this.getRenderTarget(),s=this.getMRT();i.input.value=t,this.setMRT(null),this.setRenderTarget(e),this.clear(),i.quad.render(this),this.setRenderTarget(r),this.setMRT(s)}_getPrefilterPass(t){this._prefilterPasses||(this._prefilterPasses=[]);let e=this._prefilterPasses[t];if(e)return e;let i=Jt(Vo),r=mt(new Y(1,0)),s=new Pe;s.name="SplineTransmissionPrefilter";let n=ui(),a=r,o=h=>i.sample(n.add(a.mul(h))).rgb,l=o(0).mul(.40262).add(o(1.182408).mul(.29869)).add(o(-1.182408).mul(.29869));return s.fragmentNode=at(l,1),s.lights=!1,s.blending=Wi,s.depthTest=!1,s.depthWrite=!1,s.needsUpdate=!0,e={quad:new Pr(s),input:i,step:r},this._prefilterPasses[t]=e,e}_getDownsamplePass(t){this._downsamplePasses||(this._downsamplePasses=[]);let e=this._downsamplePasses[t];return e||(e=this._buildDownsamplePassEntry(XL,"SplineTransmissionDownsample"),this._downsamplePasses[t]=e,e)}_buildDownsamplePassEntry(t,e){let i=Jt(Vo),r=mt(new Y(1,1)),s=new Pe;s.name=e;let n=ui(),a=r,o=(h,u)=>i.sample(n.add(st(h,u).mul(a))).rgb,l=null;if(t==="k4")for(let h=-1;h<=1;h++)for(let u=-1;u<=1;u++){let d=(u===0?2:1)*(h===0?2:1)/16,c=o(u,h).mul(d);l=l?l.add(c):c}else{let h=[-1.5,-.5,.5,1.5],u=[.1665,.3335,.3335,.1665];for(let d=0;d<4;d++)for(let c=0;c<4;c++){let p=u[c]*u[d],m=o(h[c],h[d]).mul(p);l=l?l.add(m):m}}return s.fragmentNode=at(l,1),s.lights=!1,s.blending=Wi,s.depthTest=!1,s.depthWrite=!1,s.needsUpdate=!0,{quad:new Pr(s),input:i,step:r}}_getPlanarDownsamplePass(t){this._planarDownsamplePasses||(this._planarDownsamplePasses=[]);let e=this._planarDownsamplePasses[t];return e||(e=this._buildDownsamplePassEntry("g16","SplinePlanarDownsample"),this._planarDownsamplePasses[t]=e,e)}_batchedMipCopies(t){let e=this.backend,i=e?.device;if(!i||typeof e?.get!="function"){for(let n of t)this.copyTextureToTexture(n.src,n.dst,null,null,0,n.dstLevel);return}let r=i.createCommandEncoder({label:"SplineCascadeMipCopies"}),s=0;for(let n of t){let a=e.get(n.src)?.texture,o=e.get(n.dst)?.texture;a&&o?(r.copyTextureToTexture({texture:a,mipLevel:0,origin:{x:0,y:0,z:0}},{texture:o,mipLevel:n.dstLevel,origin:{x:0,y:0,z:0}},{width:n.width,height:n.height,depthOrArrayLayers:1}),s++):this.copyTextureToTexture(n.src,n.dst,null,null,0,n.dstLevel)}s>0&&i.queue.submit([r.finish()])}_getReflectionDownsamplePass(t){this._reflectionDownsamplePasses||(this._reflectionDownsamplePasses=[]);let e=this._reflectionDownsamplePasses[t];return e||(e=this._buildDownsamplePassEntry("g16","SplineReflectionDownsample"),this._reflectionDownsamplePasses[t]=e,e)}_renderTransmissionPass(t,e){let i=this.getDrawingBufferSize($f),r=this.hdTransmission?1:2,s=Math.max(1,Math.round(i.x/r)),n=Math.max(1,Math.round(i.y/r)),a=this.backend?.isWebGPUBackend===!0?ME:"off";this._transmissionTarget=this._reallocGrabTarget(this._transmissionTarget,s,n,()=>{let u=new ii(s,n,{depthBuffer:!0}),d=u.texture;return a==="off"?(d.generateMipmaps=!0,d.minFilter=ta):(d.generateMipmaps=!1,d.minFilter=pe),d.magFilter=pe,u});let o=[];t.traverse(u=>{let d=u;if(!(d.isMesh||d.isLine||d.isPoints||d.isSprite))return;let c=d.layers;c&&8&c.mask&&c.mask!==8&&(o.push({layers:c,mask:c.mask}),c.mask=8)});let l=this.getRenderTarget();e.layers.disable(3),this.setRenderTarget(this._transmissionTarget),this._renderPrepass(t,e),this.setRenderTarget(l),e.layers.enable(3);for(let u of o)u.layers.mask=u.mask;let h=this._transmissionTarget.texture;if(a!=="off"){let u=(f,g)=>{let y=new ii(f,g,{depthBuffer:!1});return y.texture.generateMipmaps=!1,y.texture.minFilter=pe,y.texture.magFilter=pe,y};this._transmissionBlurTmp=this._reallocGrabTarget(this._transmissionBlurTmp,s,n,()=>u(s,n));let d=Math.floor(Math.log2(Math.max(s,n)))+1,c=this._transmissionBlurTarget;this._transmissionBlurTarget=this._reallocGrabTarget(this._transmissionBlurTarget,s,n,()=>{let f=new ii(s,n,{depthBuffer:!1}),g=f.texture;return g.minFilter=ta,g.magFilter=pe,a==="base"?g.generateMipmaps=!0:(g.generateMipmaps=!1,g.mipmaps=Array.from({length:d},(y,v)=>({width:Math.max(1,s>>v),height:Math.max(1,n>>v)}))),f}),a==="full"&&this._transmissionBlurTarget!==c&&this.initTexture(this._transmissionBlurTarget.texture);let p=this._getPrefilterPass(0);p.input.value=this._transmissionTarget.texture,p.step.value.set(1/s,0),this.setRenderTarget(this._transmissionBlurTmp),p.quad.render(this);let m=this._getPrefilterPass(1);if(m.input.value=this._transmissionBlurTmp.texture,m.step.value.set(0,1/n),a==="base")this.setRenderTarget(this._transmissionBlurTarget),m.quad.render(this);else{for(let f=0;f<d;f++)this._transmissionChain[f]=this._reallocGrabTarget(this._transmissionChain[f],Math.max(1,s>>f),Math.max(1,n>>f),()=>u(Math.max(1,s>>f),Math.max(1,n>>f)));for(let f=d;f<this._transmissionChain.length;f++)this._transmissionChain[f]?.dispose(),this._transmissionChain[f]=void 0;this._transmissionChain.length=d,this.setRenderTarget(this._transmissionChain[0]),m.quad.render(this);for(let f=1;f<d;f++){let g=this._transmissionChain[f-1],y=this._getDownsamplePass(f-1);y.input.value=g.texture,y.step.value.set(1/g.width,1/g.height),this.setRenderTarget(this._transmissionChain[f]),y.quad.render(this)}for(let f=0;f<d;f++)this.copyTextureToTexture(this._transmissionChain[f].texture,this._transmissionBlurTarget.texture,null,null,0,f)}this.setRenderTarget(l),h=this._transmissionBlurTarget.texture}Vt.transmissionRenderTarget.value=h,Vt.transmissionActualSize.value.set(s,n),Vt.aspectRatio.value=i.x>=i.y?Vt.aspectRatio.value.set(i.y/i.x,1):Vt.aspectRatio.value.set(1,i.x/i.y)}_buildReflectionDepthPasses(t,e,i){if(this._reflectionDepthPasses)for(let s of this._reflectionDepthPasses)s?.quad.material?.dispose();let r=[];{let s=new Pe;s.name="SplineReflectionDepthBlit";let n=Jt(this._reflectionTarget.depthTexture);s.fragmentNode=at(j(n.sample(ui())),1),s.lights=!1,s.blending=Wi,s.depthTest=!1,s.depthWrite=!1,s.needsUpdate=!0,r.push({quad:new Pr(s)})}for(let s=1;s<i;s++){let n=Math.max(1,t>>s-1),a=Math.max(1,e>>s-1),o=new Pe;o.name=`SplineReflectionDepthMin${s}`;let l=Jt(this._reflectionDepthChain[s-1].texture),h=Qa,u=ct(h.x).mul(2),d=ct(h.y).mul(2),c=(y,v)=>l.load(Yn(u.add(y),d.add(v))).x,p=(y,v)=>ti(y,v),m=p(p(c(0,0),c(1,0)),p(c(1,1),c(0,1))),f=!!(1&n),g=!!(1&a);f&&(m=p(m,p(c(2,0),c(2,1)))),g&&(m=p(m,p(c(0,2),c(1,2)))),f&&g&&(m=p(m,c(2,2))),o.fragmentNode=at(j(m),1),o.lights=!1,o.blending=Wi,o.depthTest=!1,o.depthWrite=!1,o.needsUpdate=!0,r.push({quad:new Pr(o)})}this._reflectionDepthPasses=r}_renderReflectionPass(t,e){let i=this.getDrawingBufferSize($f),r=1/0,s=0,n=0;t.traverse(x=>{let S=x;if(!(S.isMesh&&16&S.layers.mask))return;let w=this._reflectiveMeshCoverage(S,e,i.y),T=Array.isArray(S.material)?S.material:[S.material];for(let C of T){if(!C?.layers)continue;let M=QCt(C);!M||(r=Math.min(r,M.min*w.scale),s=Math.max(s,M.max*w.scale),M.max*w.scale>.45&&(n=Math.max(n,w.diameterPx)))}});let a=1;if(JL&&r!==1/0)for(r>=6?a=4:r>=2&&(a=2);a>1&&n>0&&n/a<128;)a>>=1;let o=Math.max(1,Math.round(i.x/a)),l=Math.max(1,Math.round(i.y/a)),h=Math.floor(Math.log2(Math.max(o,l)))+1,u=this.backend?.isWebGPUBackend===!0&&QL;this._reflectionTarget=this._reallocGrabTarget(this._reflectionTarget,o,l,()=>{let x=new ii(o,l,{depthTexture:new Ha(o,l)});return u?(x.texture.generateMipmaps=!1,x.texture.minFilter=pe):(x.texture.generateMipmaps=!0,x.texture.minFilter=ta),x.texture.magFilter=pe,x});let d=(x,S)=>{let w=new ii(x,S,{depthBuffer:!1,type:Ye,format:Ka});return w.texture.generateMipmaps=!1,w.texture.minFilter=Re,w.texture.magFilter=Re,w},c=this._reflectionDepthPyramid;this._reflectionDepthPyramid=this._reallocGrabTarget(this._reflectionDepthPyramid,o,l,()=>{let x=d(o,l);return x.texture.mipmaps=Array.from({length:h},(S,w)=>({width:Math.max(1,o>>w),height:Math.max(1,l>>w)})),x}),this._reflectionDepthPyramid!==c&&this.initTexture(this._reflectionDepthPyramid.texture);for(let x=0;x<h;x++)this._reflectionDepthChain[x]=this._reallocGrabTarget(this._reflectionDepthChain[x],Math.max(1,o>>x),Math.max(1,l>>x),()=>d(Math.max(1,o>>x),Math.max(1,l>>x)));for(let x=h;x<this._reflectionDepthChain.length;x++)this._reflectionDepthChain[x]?.dispose(),this._reflectionDepthChain[x]=void 0;this._reflectionDepthChain.length=h;let p=this.auxiliary||this._skySystem?.attached!==!0?null:this._skySystem.environmentTexture??null,m=Vt.reflectionEnvMap,f=p??Fu;!this.auxiliary&&m.value!==f&&(m.value=f,this._grabTargetEpoch++),Vt.reflectionEnvEnabled.value=p!==null?1:0;let g=this.getClearColor(kht);Vt.reflectionMissColor.value.set(g.r,g.g,g.b);let y=[];t.traverse(x=>{let S=x;if(!(S.isMesh||S.isLine||S.isPoints||S.isSprite))return;let w=S.layers;w&&16&w.mask&&w.mask!==16&&(y.push({layers:w,mask:w.mask}),w.mask=16)});let v=this.getRenderTarget();e.layers.disable(4),this.setRenderTarget(this._reflectionTarget),this._renderPrepass(t,e),e.layers.enable(4);for(let x of y)x.layers.mask=x.mask;this._reflectionPassesKey!==`${o}x${l}`&&(this._buildReflectionDepthPasses(o,l,h),this._reflectionPassesKey=`${o}x${l}`);let b=this._reflectionDepthPasses;for(let x=0;x<h;x++)this.setRenderTarget(this._reflectionDepthChain[x]),b[x].quad.render(this);this._batchedMipCopies(Array.from({length:h},(x,S)=>({src:this._reflectionDepthChain[S].texture,dst:this._reflectionDepthPyramid.texture,dstLevel:S,width:Math.max(1,o>>S),height:Math.max(1,l>>S)})));let _=this._reflectionTarget.texture;if(u){let x=this._reflectionColorPyramid;this._reflectionColorPyramid=this._reallocGrabTarget(this._reflectionColorPyramid,o,l,()=>{let T=new ii(o,l,{depthBuffer:!1}),C=T.texture;return C.minFilter=ta,C.magFilter=pe,C.generateMipmaps=!1,C.mipmaps=Array.from({length:h},(M,A)=>({width:Math.max(1,o>>A),height:Math.max(1,l>>A)})),T}),this._reflectionColorPyramid!==x&&this.initTexture(this._reflectionColorPyramid.texture);let S=s>0?h:1,w=(T,C)=>{let M=new ii(T,C,{depthBuffer:!1});return M.texture.generateMipmaps=!1,M.texture.minFilter=pe,M.texture.magFilter=pe,M};for(let T=1;T<S;T++)this._reflectionColorChain[T]=this._reallocGrabTarget(this._reflectionColorChain[T],Math.max(1,o>>T),Math.max(1,l>>T),()=>w(Math.max(1,o>>T),Math.max(1,l>>T)));for(let T=S;T<this._reflectionColorChain.length;T++)this._reflectionColorChain[T]?.dispose(),this._reflectionColorChain[T]=void 0;this._reflectionColorChain.length=S;for(let T=1;T<S;T++){let C=T===1?this._reflectionTarget:this._reflectionColorChain[T-1],M=this._getReflectionDownsamplePass(T-1);M.input.value=C.texture,M.step.value.set(1/C.width,1/C.height),this.setRenderTarget(this._reflectionColorChain[T]),M.quad.render(this)}this._batchedMipCopies([{src:this._reflectionTarget.texture,dst:this._reflectionColorPyramid.texture,dstLevel:0,width:o,height:l},...Array.from({length:S-1},(T,C)=>({src:this._reflectionColorChain[C+1].texture,dst:this._reflectionColorPyramid.texture,dstLevel:C+1,width:Math.max(1,o>>C+1),height:Math.max(1,l>>C+1)}))]),_=this._reflectionColorPyramid.texture}this.setRenderTarget(v),Vt.reflectionRenderTarget.value=_,Vt.reflectionDepthPyramid.value=this._reflectionDepthPyramid.texture,Vt.reflectionDepthSize.value.set(o,l),Vt.reflectionDepthLevels.value=h,this._reflectionGrabInfo={div:a,w:o,h:l,minBlur:r,maxBlur:s}}_reflectiveMeshCoverage(t,e,i){let r=t.geometry;if(!r)return{diameterPx:i,scale:1};r.boundingSphere===null&&r.computeBoundingSphere();let s=r.boundingSphere;if(!s)return{diameterPx:i,scale:1};let n=t.matrixWorld.elements,a=Math.sqrt(Math.max(n[0]*n[0]+n[1]*n[1]+n[2]*n[2],n[4]*n[4]+n[5]*n[5]+n[6]*n[6],n[8]*n[8]+n[9]*n[9]+n[10]*n[10])),o=s.radius*a;GL.copy(s.center).applyMatrix4(t.matrixWorld);let l=e.projectionMatrix.elements[5]*i/2,h=1;e.isPerspectiveCamera===!0&&(WL.setFromMatrixPosition(e.matrixWorld),h=Math.max(GL.distanceTo(WL),e.near??.1));let u=2*o*l/h;return{diameterPx:u,scale:Math.min(1,u/(.66*i))}}_renderReflectionResolvePass(t,e){let i=this._reflectionGrabInfo,r=this.backend?.isWebGPUBackend===!0&&tF&&i!==void 0&&i.maxBlur>.45;if(r){let _=!0;t.traverse(x=>{let S=x;if(!(S.isMesh&&16&S.layers.mask))return;let w=Array.isArray(S.material)?S.material:[S.material],T=null;for(let C of w)if(C?.layers&&(T=JCt(C),T!==null))break;T!=="variable"?T!==null?(S.userData.__srMode=T.blur>.45?1+T.tracingMode:0,S.userData.__srBlur=T.blur*this._reflectiveMeshCoverage(S,e,this.getDrawingBufferSize(zht).y).scale,S.userData.__srThickness=T.thickness,S.userData.__srStepSize=T.stepSize,S.userData.__srSteps=T.steps):S.userData.__srMode=0:_=!1}),r=_}let s=r?i.w:4,n=r?i.h:4,a=(_,x)=>()=>{let S=new ii(_,x,{type:si,depthBuffer:!1});return S.texture.generateMipmaps=!1,S.texture.minFilter=pe,S.texture.magFilter=pe,S};if(this._reflectionResolveTarget=this._reallocGrabTarget(this._reflectionResolveTarget,s,n,a(s,n)),Vt.reflectionResolveTarget.value=this._reflectionResolveTarget.texture,!r)return void(Vt.reflectionResolveEnabled.value=0);let{w:o,h:l}=i;if(this._reflectionGBufferTarget=this._reallocGrabTarget(this._reflectionGBufferTarget,o,l,()=>{let _=new ii(o,l,{count:2,type:si,depthTexture:new Ha(o,l)});for(let x of _.textures)x.generateMipmaps=!1,x.minFilter=Re,x.magFilter=Re;return _.textures[0].name="g0",_.textures[1].name="g1",_}),this._reflectionResolveMarchTarget=this._reallocGrabTarget(this._reflectionResolveMarchTarget,o,l,a(o,l)),this._reflectionResolveBlurTmp=this._reallocGrabTarget(this._reflectionResolveBlurTmp,o,l,a(o,l)),!this._reflectionGBufferMaterial){let _=new Pe;_.name="SplineReflectionGBuffer";let x=$p("__splinePlanarMirror","float"),S=Vt.reflectionPlanarEnabled.greaterThan(.5),w=$p("__srMode","float"),T=pi(x.greaterThan(.5).and(S),I(0),w);_.fragmentNode=Kv({g0:at(be(Ra),T),g1:at($p("__srBlur","float"),$p("__srThickness","float"),$p("__srStepSize","float"),$p("__srSteps","float"))}),_.lights=!1,_.blending=Wi,_.needsUpdate=!0,this._reflectionGBufferMaterial=_}let h=this._skippedAsyncDraws??0,u=t.overrideMaterial,d=this.getRenderTarget(),c=this.getClearColor(Vht),p=this.getClearAlpha(),m=e.layers.mask;t.overrideMaterial=this._reflectionGBufferMaterial,e.layers.mask=16,this.setClearColor(0,0),this.setRenderTarget(this._reflectionGBufferTarget),this._renderPrepass(t,e),t.overrideMaterial=u,e.layers.mask=m,this.setClearColor(c,p);let f=Vt.reflectionRenderTarget.value,g=Vt.reflectionEnvMap.value,y=this._reflectionGBufferTarget,v=`${o}x${l}|${y.textures[0].uuid}|${f.uuid}|${this._reflectionDepthPyramid.texture.uuid}|${g.uuid}|${this._reflectionResolveMarchTarget.texture.uuid}|${this._reflectionResolveBlurTmp.texture.uuid}`;v!==this._reflectionResolveMarchKey&&(this._buildReflectionResolveMarch(f,g,o,l),this._reflectionResolveMarchKey=v);let b=this._reflectionResolveMarch;b.proj.value.copy(e.projectionMatrix),b.projInv.value.copy(e.projectionMatrix).invert(),b.camWorld.value.copy(e.matrixWorld),b.near.value=e.near??.1,this.setRenderTarget(this._reflectionResolveMarchTarget),b.quad.render(this),this.setRenderTarget(this._reflectionResolveBlurTmp),this._reflectionResolveBlur.h.render(this),this.setRenderTarget(this._reflectionResolveTarget),this._reflectionResolveBlur.v.render(this),this.setRenderTarget(d),Vt.reflectionResolveEnabled.value=1,(this._skippedAsyncDraws??0)>h&&(Vt.reflectionResolveEnabled.value=0)}_buildReflectionResolveMarch(t,e,i,r){this._reflectionResolveMarch&&this._reflectionResolveMarch.quad.material.dispose(),this._reflectionResolveBlur&&(this._reflectionResolveBlur.h.material.dispose(),this._reflectionResolveBlur.v.material.dispose());let s=mt(new bt),n=mt(new bt),a=mt(new bt),o=mt(.1),l=this._reflectionGBufferTarget,h=Jt(l.textures[0]),u=Jt(l.textures[1]),d=Jt(l.depthTexture),c=Jt(t),p=Jt(this._reflectionDepthPyramid.texture),m=Jt(e),f=new Pe;f.name="SplineReflectionResolve";let g=At(()=>{let _=Qa,x=Yn(ct(_.x),ct(_.y)),S=ui(),w=h.load(x).toVar(),T=d.sample(S).toVar(),C=at(0).toVar(),M=I(0).toVar();return vt(w.w.greaterThan(.5),()=>{let A=u.load(x).toVar(),P=vg(n,S.x,S.y,T),O=wq({dials:{blur:A.x,thickness:A.y,stepSize:A.z,steps:ct(A.w),tracingMode:w.w.sub(1)},surface:{originView:P,normalV:be(w.xyz),screenUv:S,fragWindowZ:T},camera:{projectionMatrix:s,projectionMatrixInverse:n,worldMatrix:a,near:o},resources:{colorMap:c,depthPyramid:p,depthPyramidNode:p,envMap:m},usePlanar:X1t(!1),noisePixel:st(x),singleRay:{footprintOut:M}});C.assign(at(O,M.add(1)))}),C});f.fragmentNode=g(),f.lights=!1,f.blending=Wi,f.depthTest=!1,f.depthWrite=!1,f.needsUpdate=!0,this._reflectionResolveMarch={quad:new Pr(f),proj:s,projInv:n,camWorld:a,near:o};let y=Jt(this._reflectionResolveMarchTarget.texture),v=Jt(this._reflectionResolveBlurTmp.texture),b=_=>{let x=new Pe;x.name=`SplineReflectionResolveBlur${_.toUpperCase()}`;let S=_==="x"?y:v,w=_==="x"?1/i:1/r,T=At(()=>{let C=ui(),M=y.sample(C).toVar().w.sub(1).max(0).clamp(.5,12).toVar(),A=at(0).toVar(),P=0;for(let O=-6;O<=6;O++){let D=Math.exp(O/3*-.5*(O/3));P+=D;let N=_==="x"?st(M.mul(O/6*w),0):st(0,M.mul(O/6*w)),z=S.sample(C.add(N)).toVar(),k=_==="x"?z.w.min(1):z.w;A.addAssign(at(z.rgb,k).mul(D))}return A.div(P)});return x.fragmentNode=T(),x.lights=!1,x.blending=Wi,x.depthTest=!1,x.depthWrite=!1,x.needsUpdate=!0,new Pr(x)};this._reflectionResolveBlur={h:b("x"),v:b("y")}}_renderPlanarReflectionPass(t,e){let i=null;if(t.traverse(m=>{let f=m;if(!(f.isMesh&&16&f.layers.mask&&(f.userData.__splinePlanarMirror=0,(Array.isArray(f.material)?f.material:[f.material]).some(A=>A?.layers&&A.getLayersOfType("reflection").some(P=>P.data.visible&&P.data.mirror===1)))))return;let g=f.geometry;if(!g)return;g.boundingBox===null&&g.computeBoundingBox();let y,v,b=g.boundingBox,_=b.max.x-b.min.x,x=b.max.y-b.min.y,S=b.max.z-b.min.z,w=f.matrixWorld.elements,T=Math.hypot(w[0],w[1],w[2]),C=Math.hypot(w[4],w[5],w[6]),M=Math.hypot(w[8],w[9],w[10]);_<=x&&_<=S?(y=Lht,v=x*C*(S*M)):x<=_&&x<=S?(y=Fht,v=_*T*(S*M)):(y=Uht,v=_*T*(x*C)),(!i||v>i.area)&&(i={mesh:f,normalAxis:y,area:v})}),!i)return void(Vt.reflectionPlanarEnabled.value=0);let r=i.mesh,s=i.mesh.matrixWorld;if(Bd.copy(i.normalAxis).transformDirection(s),Tp.setFromMatrixPosition(s),uw.setFromMatrixPosition(e.matrixWorld),Mp.subVectors(Tp,uw),Mp.dot(Bd)>0&&Bd.negate(),Mp.dot(Bd)>0)return void(Vt.reflectionPlanarEnabled.value=0);r.userData.__splinePlanarMirror=1,(!this._planarVirtualCamera||this._planarVirtualCamera.type!==e.type)&&(this._planarVirtualCamera=e.clone());let n=this._planarVirtualCamera;if(Mp.subVectors(Tp,uw),Mp.reflect(Bd).negate(),Mp.add(Tp),wE.extractRotation(e.matrixWorld),qL.set(0,0,-1).applyMatrix4(wE).add(uw),dw.subVectors(Tp,qL),dw.reflect(Bd).negate(),dw.add(Tp),n.position.copy(Mp),n.up.set(0,1,0).applyMatrix4(wE),n.up.reflect(Bd),n.lookAt(dw),n.updateMatrixWorld(),n.projectionMatrix.copy(e.projectionMatrix),n.projectionMatrixInverse.copy(n.projectionMatrix).invert(),e.isPerspectiveCamera===!0){Hf.setFromNormalAndCoplanarPoint(Bd,Tp),Hf.applyMatrix4(n.matrixWorldInverse),xu.set(Hf.normal.x,Hf.normal.y,Hf.normal.z,Hf.constant);let m=n.projectionMatrix.elements;zy.x=(Math.sign(xu.x)+m[8])/m[0],zy.y=(Math.sign(xu.y)+m[9])/m[5],zy.z=-1,zy.w=(1+m[10])/m[14],xu.multiplyScalar(1/xu.dot(zy)),m[2]=xu.x,m[6]=xu.y,m[10]=xu.z,m[14]=xu.w}let a=this.getDrawingBufferSize(jht),o=Math.max(1,Math.round(a.x)),l=Math.max(1,Math.round(a.y)),h=this.backend?.isWebGPUBackend===!0&&ZL;this._planarTarget=this._reallocGrabTarget(this._planarTarget,o,l,()=>{let m=new ii(o,l);return h?(m.texture.generateMipmaps=!1,m.texture.minFilter=pe):(m.texture.generateMipmaps=!0,m.texture.minFilter=ta),m.texture.magFilter=pe,m});let u=[];t.traverse(m=>{let f=m;if(!(f.isMesh||f.isLine||f.isPoints||f.isSprite))return;let g=f.layers;g&&16&g.mask&&g.mask!==16&&(u.push({layers:g,mask:g.mask}),g.mask=16)}),n.layers.mask=-17&e.layers.mask;let d=this.getRenderTarget();this.setRenderTarget(this._planarTarget),this._renderPrepass(t,n),this.setRenderTarget(d);for(let m of u)m.layers.mask=m.mask;let c=this._planarTarget.texture;if(h){let m=Math.floor(Math.log2(Math.max(o,l)))+1,f=this._planarPyramid;this._planarPyramid=this._reallocGrabTarget(this._planarPyramid,o,l,()=>{let y=new ii(o,l,{depthBuffer:!1}),v=y.texture;return v.minFilter=ta,v.magFilter=pe,v.generateMipmaps=!1,v.mipmaps=Array.from({length:m},(b,_)=>({width:Math.max(1,o>>_),height:Math.max(1,l>>_)})),y}),this._planarPyramid!==f&&this.initTexture(this._planarPyramid.texture);let g=(y,v)=>{let b=new ii(y,v,{depthBuffer:!1});return b.texture.generateMipmaps=!1,b.texture.minFilter=pe,b.texture.magFilter=pe,b};for(let y=1;y<m;y++)this._planarChain[y]=this._reallocGrabTarget(this._planarChain[y],Math.max(1,o>>y),Math.max(1,l>>y),()=>g(Math.max(1,o>>y),Math.max(1,l>>y)));for(let y=m;y<this._planarChain.length;y++)this._planarChain[y]?.dispose(),this._planarChain[y]=void 0;this._planarChain.length=m;for(let y=1;y<m;y++){let v=y===1?this._planarTarget:this._planarChain[y-1],b=this._getPlanarDownsamplePass(y-1);b.input.value=v.texture,b.step.value.set(1/v.width,1/v.height),this.setRenderTarget(this._planarChain[y]),b.quad.render(this)}this.setRenderTarget(d),this._batchedMipCopies([{src:this._planarTarget.texture,dst:this._planarPyramid.texture,dstLevel:0,width:o,height:l},...Array.from({length:m-1},(y,v)=>({src:this._planarChain[v+1].texture,dst:this._planarPyramid.texture,dstLevel:v+1,width:Math.max(1,o>>v+1),height:Math.max(1,l>>v+1)}))]),c=this._planarPyramid.texture}let p=Vt.reflectionPlanarTarget;p.value!==c&&(p.value=c,this._grabTargetEpoch++),Vt.reflectionPlanarEnabled.value=1}renderFromSceneForSceneTransitionPass(t,e,i){let r=this.getDrawingBufferSize($f),s=Math.max(1,Math.round(r.x)),n=Math.max(1,Math.round(r.y));this._transitionCaptureTarget=this._reallocGrabTarget(this._transitionCaptureTarget,s,n,()=>new ii(s,n,{depthBuffer:!0}));let a=this.getRenderTarget();this.setRenderTarget(this._transitionCaptureTarget);try{this.renderSplineScene(t,e)}finally{this.setRenderTarget(a)}this.pipeline.sceneTransitionFromTexture=this._transitionCaptureTarget.texture,this.sceneTransitionDuration=i,this.sceneTransitionTimeRemaining=i;let o=this.pipeline.sceneTransitionPass.uniforms;o.uDPR.value=this.getPixelRatio(),o.uResolution.value.set(r.x,r.y).divideScalar(this.getPixelRatio())}async captureFrame(t,{includeHelpers:e=!1,settleFrames:i=0}={}){if(this.xr?.isPresenting===!0)return null;let r=this._frameSerial,s=this.getRenderTarget(),n=this.pipeline.renderToScreen,a=this.pipeline.helpersEnabled,o=this.suppressShadowMask;this.suppressShadowMask=!0,e||this.pipeline.disableHelpers(),this.pipeline.renderToScreen=!1,this.setRenderTarget(null);try{let g=Lbt();for(let y=0;y<i;y++)g&&this.advanceFrame(),t(),await wPt();g&&this.advanceFrame(),t()}finally{this.suppressShadowMask=o,this.pipeline.renderToScreen=n,this.setRenderTarget(s),a&&this.pipeline.enableHelpers()}if(this._frameSerial===r||this.lastFrameIncomplete)return null;let l=this.pipeline.lastOutputTarget;if(!l||!this.backend.get(l.textures[0])?.textureDescriptorGPU)return null;let h=l.width,u=l.height,d=this,c=new Uint8Array(h*u*4),p=4*h,m=256*Math.ceil(p/256),f=Math.max(1,Math.min(u,Math.floor((1<<20)/m)));for(let g=0;g<u;g+=f){let y=Math.min(f,u-g),v=await d.readRenderTargetPixelsAsync(l,0,g,h,y);if(m===p)c.set(v.subarray(0,y*p),g*p);else for(let b=0;b<y;b++){let _=b*m;c.set(v.subarray(_,_+p),(g+b)*p)}}return{pixels:c,width:h,height:u}}_applyCIOffscreenTargetIfRequested(){if(globalThis.__SPLINE_RENDER_OFFSCREEN__!==!0)return;let t=Math.max(1,Math.round(this.viewportWidth*this.getPixelRatio())),e=Math.max(1,Math.round(this.viewportHeight*this.getPixelRatio()));this._ciOffscreenTarget?(this._ciOffscreenTarget.width!==t||this._ciOffscreenTarget.height!==e)&&(this._ciOffscreenTarget.dispose(),this._ciOffscreenTarget=new ii(t,e,{depthBuffer:!0})):(this._ciOffscreenTarget=new ii(t,e,{depthBuffer:!0}),globalThis.__splineReadOffscreenPixels=async()=>{let i=this._ciOffscreenTarget,r=await this.readRenderTargetPixelsAsync(i,0,0,i.width,i.height);return{width:i.width,height:i.height,pixels:Array.from(r)}}),this.getRenderTarget()===null&&this.setRenderTarget(this._ciOffscreenTarget)}dispose(){this._disposeRetiredGrabTargets(),this._disposeWarmupTargets(),Yj()?.drainRetired(),Zj()?.drainRetired(),this._skySystem?.dispose(),this._skySystem=null,this._hbao?.dispose(),this._hbao=void 0,this._shadowMask?.dispose(),this._shadowMask=void 0,function(){for(let t of Pv){let e=t.deref();e!==void 0&&(e.mid?.dispose(),e.mid=null,e.small?.dispose(),e.small=null,e.toMid?.material?.dispose(),e.toSmall?.material?.dispose(),e.toMid=null,e.toSmall=null,e.passKey="",e.fresh=!1,e.slot=-1)}Pv.clear(),WR.fill(null),Kg?.dispose(),Kg=null,qR=!1}(),this._aoRenderTarget?.dispose(),this._aoRenderTarget=void 0,this._normalTarget?.dispose(),this._normalTarget=void 0,this._ciOffscreenTarget?.dispose(),this._ciOffscreenTarget=void 0,this._transitionCaptureTarget?.dispose(),this._transitionCaptureTarget=void 0,this._transmissionTarget?.dispose(),this._transmissionTarget=void 0,this._transmissionBlurTmp?.dispose(),this._transmissionBlurTmp=void 0,this._transmissionBlurTarget?.dispose(),this._transmissionBlurTarget=void 0;for(let t of this._transmissionChain)t?.dispose();this._transmissionChain.length=0,this._reflectionTarget?.depthTexture?.dispose(),this._reflectionTarget?.dispose(),this._reflectionTarget=void 0,this._reflectionColorPyramid?.dispose(),this._reflectionColorPyramid=void 0;for(let t of this._reflectionColorChain)t?.dispose();if(this._reflectionColorChain.length=0,this._reflectionDownsamplePasses){for(let t of this._reflectionDownsamplePasses)t?.quad.material?.dispose();this._reflectionDownsamplePasses=void 0}this._planarTarget?.dispose(),this._planarTarget=void 0,this._planarPyramid?.dispose(),this._planarPyramid=void 0;for(let t of this._planarChain)t?.dispose();if(this._planarChain.length=0,this._planarDownsamplePasses){for(let t of this._planarDownsamplePasses)t?.quad.material?.dispose();this._planarDownsamplePasses=void 0}this._reflectionDepthPyramid?.dispose(),this._reflectionDepthPyramid=void 0;for(let t of this._reflectionDepthChain)t?.dispose();if(this._reflectionDepthChain.length=0,this._reflectionDepthPasses){for(let t of this._reflectionDepthPasses)t?.quad.material?.dispose();this._reflectionDepthPasses=void 0}if(this._reflectionPassesKey="",this._reflectionGBufferTarget?.depthTexture?.dispose(),this._reflectionGBufferTarget?.dispose(),this._reflectionGBufferTarget=void 0,this._reflectionResolveMarchTarget?.dispose(),this._reflectionResolveMarchTarget=void 0,this._reflectionResolveBlurTmp?.dispose(),this._reflectionResolveBlurTmp=void 0,this._reflectionResolveTarget?.dispose(),this._reflectionResolveTarget=void 0,this._reflectionGBufferMaterial?.dispose(),this._reflectionGBufferMaterial=void 0,this._reflectionResolveMarch&&(this._reflectionResolveMarch.quad.material.dispose(),this._reflectionResolveMarch=void 0),this._reflectionResolveBlur&&(this._reflectionResolveBlur.h.material.dispose(),this._reflectionResolveBlur.v.material.dispose(),this._reflectionResolveBlur=void 0),this._reflectionResolveMarchKey="",this._reflectionGrabInfo=void 0,this._prefilterPasses){for(let t of this._prefilterPasses)t?.quad.material?.dispose();this._prefilterPasses=void 0}if(this._downsamplePasses){for(let t of this._downsamplePasses)t?.quad.material?.dispose();this._downsamplePasses=void 0}this._uiBlitPass&&(this._uiBlitPass.quad.material.dispose(),this._uiBlitPass=void 0),this._helperOverlay?.dispose(),this._helperOverlay=void 0,function(){for(let t of HR)t.deref()?.dispose();HR.clear(),$R++}(),function(){for(let t of I2){let e=t.deref();e!==void 0&&(e.sprite.removeFromParent(),e.material.dispose())}I2.clear(),U1++}(),this._taaHistory?.dispose(),this._taaHistory=void 0;for(let t of Object.values(this._encodeMaterials))t?.dispose();this._encodeMaterials={},this._bundledPages.clear(),this.pipeline.dispose(),this.dummyCamera.dispose(),super.dispose(),this._disposeRetiredGrabTargets(),Vt.transmissionRenderTarget.value=Vo,Vt.normalRenderTarget.value=Vo,Vt.aoRenderTarget.value=Vo,Vt.reflectionRenderTarget.value=Fu,Vt.reflectionDepthPyramid.value=Fu,Vt.reflectionEnvMap.value=Fu,Vt.reflectionPlanarTarget.value=Fu,Vt.reflectionPlanarEnabled.value=0,Vt.reflectionResolveTarget.value=V9,Vt.reflectionResolveEnabled.value=0,this.disposeListenerLedger.release(),this.onBackgroundWorkReady=null}})._GAUGE_STALL_MS=3e3,function(){let t=N5.prototype;for(let e of["init","render","compute","compileAsync","clear","initTexture","initRenderTarget","copyFramebufferToTexture","copyTextureToTexture","getArrayBufferAsync","readRenderTargetPixelsAsync"]){let i=t[e];if(typeof i!="function")throw new Error(`recordDisposeListenersIn: no method ${e}`);t[e]=function(...r){return fPt(this.disposeListenerLedger,()=>i.apply(this,r))}}}()});function SPt(t){return{type:t.type}}function no(t,e){let{alpha:i,mode:r,isMask:s}=t,n=typeof i=="string"?Number(e.getVariable(i)??100)/100:i;return{...SPt(t),alpha:n,mode:r,isMask:s}}var TPt=U(()=>{ot(),BW(),ub()});function Fy(t){let e=t;return e!=null&&e.isInstancedMesh===!0&&e.instanceMatrix!=null&&e.instanceMatrix.isInstancedBufferAttribute===!0}function EE(t){return jh(jh(LD).mul(function(e){let i=e.spInstanceMatrixNode;if(i!==void 0)return jh(i);let r=e.object,s=r.instanceMatrix,n=Math.max(r.count??1,1);if(s.isStorageInstancedBufferAttribute===!0)return jh(B5(Vvt(s,"mat4",n),Rn));if(16*n*4<=e.getUniformBufferLimit())return jh(B5(Y1t(s.array,"mat4",n),Rn));let a=g7.get(s);a===void 0&&(a=new IG(s.array,16,1),g7.set(s,a));let o=s.usage===$h?avt:qp;return jh(cq(o(a,"vec4",16,0),o(a,"vec4",16,4),o(a,"vec4",16,8),o(a,"vec4",16,12)))}(t)))}var jh,B5,g7,Ya,RT,Fbt,Ubt=U(()=>{ot(),je(),jh=t=>t,B5=(t,e)=>t.element(e),g7=new WeakMap,Ya=At(t=>Fy(t.object)?FD:Zv).once()().toVar("speObjectPosition"),RT=At(t=>t.material?.shapeBlendObjectNormal||(Fy(t.object)?t.geometry.hasAttribute("normal")?xvt:j(0,1,0):pq)).once()().toVar("speObjectNormal"),jh(At(t=>jh(Fy(t.object)?EE(t):LD)).once()()),Fbt=At(t=>{if(!Fy(t.object))return gvt;let e=EE(t),i=r=>B5(e,r).xyz;return j(i(0).length(),i(1).length(),i(2).length()).toVarying("v_speModelScale")}).once()().toVar("speModelScale"),At(t=>Fy(t.object)?bm(EE(t)).inverse().transpose():fvt).once()(),jh(At(t=>jh(Fy(t.object)?EE(t).inverse():vvt)).once()())});function Eq(t){if(lT.has(t))return;let e={own:t.value,render:t.value};lT.set(t,e),Object.defineProperty(t,"value",{configurable:!0,enumerable:!0,get:()=>e.render,set:i=>{e.render=i,e.own=i}})}function y7(t){let e=lT.get(t);return e!==void 0?e.own:t.value}function Pq(t,e){let i=lT.get(t);i!==void 0?i.render=e:t.value=e}var lT,Rq,jbt=U(()=>{lT=new WeakMap}),MPt=U(()=>{jbt(),Rq=class{constructor(t){this.layerId=t,this.uniforms={},this.byName=new Map,this.liveValues=new Map}set(t,e,i){return this.byName.set(t,e),this.uniforms[`f${this.layerId}_${t}`]=e,i!==void 0&&this.liveValues.set(t,i),this}has(t){return this.byName.has(t)}names(){return[...this.byName.keys()]}get(t){let e=this.byName.get(t);if(e===void 0)throw new Error(`TSLLayerParams: unknown param "${t}" (layer f${this.layerId})`);return e}getFloat(t){return this.get(t)}getInt(t){return this.get(t)}getBool(t){return this.get(t)}getVec2(t){return this.get(t)}getVec3(t){return this.get(t)}getVec4(t){return this.get(t)}getColor(t){return this.get(t)}getValue(t){if(this.liveValues.has(t))return this.liveValues.get(t);let e=this.byName.get(t);return e===void 0?void 0:y7(e)}getLiveValue(t){return this.liveValues.get(t)}getNodeValue(t){let e=this.byName.get(t);return e===void 0?void 0:y7(e)}setValue(t,e){let i=this.byName.get(t);i===void 0||e===void 0||(this.liveValues.has(t)&&this.liveValues.set(t,e),i.value=e)}}});function Zu(t,e,i){let r=I(t).toVar(),s=I($t(r.div(Te(r.add(e.accumAlpha),I(1e-5),I(1))),r,i)).toVar();return e.accumAlpha.addAssign(Rr(e.accumAlpha).mul(r).mul(Rr(i))),s}function fb(t,e){let i=I(t).toVar(),r=I(i.div(Te(i.add(e.accumAlpha),I(1e-5),I(1)))).toVar();return e.accumAlpha.addAssign(Rr(e.accumAlpha).mul(i)),r}function ZR(t,e,i,r){return Wbt({a:t,b:e,alpha:i,mode:r})}function kn(t,e){GD.set(t,e)}function Gbt(t){let e=GD.get(t);return e!==void 0?e:(w7.has(t)||(w7.add(t),console.warn(`[spe] Material layer type "${t}" is not available in this runtime build (no WebGPU port, or compiled out) \u2014 rendering flat red.`)),Dq)}function APt(t){return GD.has(t)}var v7,b7,_7,x7,Wbt,GD,w7,Dq,mn=U(()=>{je(),Ubt(),MPt(),jbt(),v7=0,b7=1,_7=2,x7=3,Wbt=At(t=>{let e=t.a.toVar(),i=t.b.toVar(),r=t.alpha.toVar(),s=t.mode,n=j(1).toVar();return vt(s.equal(ct(v7)),()=>{n.assign($t(e,i,r))}).ElseIf(s.equal(ct(b7)),()=>{n.assign($t(e,e.mul(i),r))}).ElseIf(s.equal(ct(_7)),()=>{n.assign($t(e,Rr(Rr(e).mul(Rr(i))),r))}).ElseIf(s.equal(ct(x7)),()=>{let a=Si(e,j(.5)),o=$t(Rr(Rr(e).mul(Rr(i)).mul(2)),e.mul(i).mul(2),a);n.assign($t(e,o,r).clamp(0,1))}),n}),GD=new Map,w7=new Set,Dq=(t,e,i)=>{let r=e.alpha.mul(e.mask);return{color:j(1,0,0),calpha:fb(r,i)}}});function qbt(t){let e=uo(Vt.aoRenderTarget.sample(th).rgb),i=tb(Vt.aoEnabledUniform);return t!==null&&(i=tb(i.mul(pi(t,I(1),I(0))))),uo($t(j(1),e,i))}var S7,T7,uo,tb,qht,Hht,Hbt,$bt,Xbt=U(()=>{var t;cr(),je(),pn(),mn(),{diffuseContribution:S7,specularColorBlended:T7}=R,uo=e=>e,tb=e=>e,qht=At(e=>{let i=Ra.dot(uo(e.lightDirection)),r=st(i.mul(.5).add(.5),0),s=r.fwidth().mul(.5);return $t(j(.7),j(1),Ji(I(.7).sub(s.x),I(.7).add(s.x),r.x))}),Hht=At(e=>{let i=uo(e.lightDirection).add(Qv).normalize(),r=Ra.dot(i).clamp(),s=Qv.dot(i).clamp(),n=s.mul(-5.55473).sub(6.98316).mul(s).exp2(),a=rv.mul(n.oneMinus()).add(n),o=I(.25),l=S5.mul(.5).add(1).mul(1/Math.PI).mul(r.pow(S5));return a.mul(o).mul(l)}),t=class extends Av{direct(e){let{lightDirection:i,lightColor:r,reflectedLight:s}=e,n=uo(qht({lightDirection:i})).mul(r);s.directDiffuse.addAssign(n.mul(uo(ko.rgb).mul(1/Math.PI))),s.directSpecular.addAssign(n.mul(tb(Hht({lightDirection:i}))))}},Hbt=class extends t{constructor(){super(...arguments),this.aoOcclusionGate=null}finish(e,...i){super.finish?.call(this,e,...i);let{reflectedLight:r,outgoingLight:s}=e.context,n=qbt(this.aoOcclusionGate),a=uo(r.directDiffuse.add(r.indirectDiffuse));s.subAssign(a.mul(Rr(n)))}},$bt=class extends ER{constructor(){super(...arguments),this.envIrradianceActive=!1}direct(e,i){let r=e;if(r.lightNode?.light?.userData?.splineDiffuseOnly===!0){if(this.envIrradianceActive)return;let s=uo(Ra).dot(r.lightDirection).clamp().mul(r.lightColor),n=R.BRDF_Lambert({diffuseColor:S7});return void r.reflectedLight.directDiffuse.addAssign(s.mul(n))}super.direct(e,i)}}});function Uy(t,e){return qu(e==="x"?t.x:e==="y"?t.y:t.z)}function pw(t,e){return on(bvt(t,j(e,1)).div(2).add(.5).xy)}function CPt(t,e,i){let r=I(t.div(Te(t.add(e.accumAlpha),I(1e-5),I(1)))).toVar();return e.accumAlpha.addAssign(Rr(e.accumAlpha).mul(t).mul(Rr(i))),r}function TS(t){let e=t.getValue("projection")??0,i=t.getValue("axis")??0,r=i>=0&&i<=2?i:0,s=t.getValue("projectionAxis")??-1,n=s>=0&&s<=2?s:1,a=Ybt(t.get("mat")),o=t.getVec2("size");if(e===1){let u=Ya,d=r===0?u.zy:r===1?u.xz:u.xy,c=st(d.add(1).div(2)).toVar(),p=st(pw(a,on(c.mul(2).sub(1).div(o.mul(.5))))).toVar();return{uvs:[on(p)],weights:null}}if(e===2){let u=j(be(Ya)).toVar(),{a:d,b:c,pole:p}=M7[n],m=I(wc(Uy(u,d),Uy(u,c)).div(6.283).add(.5)).toVar(),f=I(lq(Uy(u,p)).div(3.1415).add(.5)).toVar(),g=st(m,f).toVar(),y=st(pw(a,on(g.mul(2).sub(1)))).toVar();return{uvs:[on(y)],weights:null}}if(e===3){let u=j(be(Ya)).toVar(),{a:d,b:c,pole:p}=M7[n],m=I(wc(Uy(u,d),Uy(u,c)).div(6.283).add(.5)).toVar(),f=I(Uy(hr(Ya),p).div(o.y.mul(.5))).toVar(),g=I(f.div(2).add(.5)).toVar(),y=st(m,g).toVar(),v=st(pw(a,on(y.mul(2).sub(1)))).toVar();return{uvs:[on(v)],weights:null}}if(e===4){let u=t.getFloat("blending"),d=j(Ya).toVar(),c=st(d.xy.add(1).div(2)).toVar(),p=st(d.zy.add(1).div(2)).toVar(),m=st(d.xz.add(1).div(2)).toVar();for(let v of[c,p,m])v.assign(pw(a,on(v.mul(2).sub(1).div(o.mul(.5)))));let f=I(Rr(u).mul(125).add(3)).toVar(),g=j(RT).toVar(),y=j(ke(be(g))).toVar();return y.assign(Lo(y,j(f))),y.divAssign(Bt(y,j(1))),{uvs:[on(c),on(p),on(m)],weights:hr(y)}}let l=Uv.of(t.getValue("uvChannel")),h=st(pw(a,on(function(u){if(u===0)return on(ui());let d=Uv.attributeName(u);return on(At(c=>c.geometry?.getAttribute(d)!==void 0?ui(u):ui())())}(l).mul(2).sub(1)))).toVar();return{uvs:[on(h)],weights:null}}function PE(t,e,i){let r=st(e).toVar(),s=st($v(r)).toVar(),n=st(Xv(r)).toVar(),a=u=>qu(i.mul(zD(Aa(t.sample(u)).rgb))),o=I(a(on(r))).toVar(),l=I(a(on(r.add(s))).sub(o)).toVar(),h=I(a(on(r.add(n))).sub(o)).toVar();return on(st(l,h))}function RE(t,e,i){let r=j($v(t)).toVar(),s=j(Xv(t)).toVar(),n=j(be(e)).toVar(),a=j(be(Kr(s,n))).toVar(),o=j(be(Kr(n,r))).toVar(),l=I(Bt(r,a).mul(VD)).toVar(),h=j(Xu(l).mul(i.x.mul(a).add(i.y.mul(o)))).toVar();return hr(be(ke(l).mul(n).sub(h)))}function sF(t,e){let i,r=t.get("texture"),s=t.has("loaded")?t.getFloat("loaded"):I(1),n=l=>{let h=Aa(r.sample(l)),u=e==="luminance"?zD(h.rgb):h[e];return I(u).toVar()},{uvs:a,weights:o}=TS(t);if(o!==null){let l=n(a[0]),h=n(a[1]),u=n(a[2]);i=qu(l.mul(o.z).add(h.mul(o.x)).add(u.mul(o.y)))}else i=qu(n(a[0]));return qu($t(I(1),i,s))}var qu,on,hr,Aa,Ybt,M7,$ht,Kbt=U(()=>{cr(),je(),De(),mn(),qu=t=>t,on=t=>t,hr=t=>t,Aa=t=>t,Ybt=t=>t,M7=[{a:"y",b:"z",pole:"x"},{a:"z",b:"x",pole:"y"},{a:"x",b:"y",pole:"z"}],kn("texture",$ht=(t,e,i)=>{let r,s=t.getValue("projection")??0,n=t.getValue("axis")??0,a=n>=0&&n<=2?n:0,o=t.getValue("side")??0,l=t.get("texture"),h=t.getFloat("crop"),{uvs:u,weights:d}=TS(t),c=[...u],p=null;if(s===1){if(r=Aa(l.sample(u[0])),o!==2){let v=a===0?j(1,0,0):a===1?j(0,1,0):j(0,0,1),b=Bt(RT,v);p=qu(Si(I(0),o===1?b.mul(-1):b))}}else if(s===2||s===3)r=function(v,b){if(v.value.minFilter===Re&&v.value.magFilter===Re)return Aa(v.sample(b));let _=st($v(b)).toVar(),x=st(Xv(b)).toVar();return _.x.subAssign(de(_.x.add(.5))),x.x.subAssign(de(x.x.add(.5))),Aa(v.sample(b).grad(_,x))}(l,u[0]);else if(s===4){let v=d,b=Aa(l.sample(u[0])),_=Aa(l.sample(u[1])),x=Aa(l.sample(u[2]));r=Aa(b.mul(v.z).add(_.mul(v.x)).add(x.mul(v.y)))}else r=Aa(l.sample(u[0]));let m=t.has("loaded")?t.getFloat("loaded"):I(1),f=at($t(at(0,0,0,1),Aa(r),m)).toVar(),g=j(f.rgb).toVar(),y=I(e.alpha.mul(f.a)).toVar();return p!==null&&y.mulAssign(p),function(v,b,_){vt(v.greaterThan(.5),()=>{for(let x of _)vt(x.x.lessThan(0).or(x.x.greaterThan(1)).or(x.y.lessThan(0)).or(x.y.greaterThan(1)),()=>{b.assign(0)})})}(h,qu(y),c),y.mulAssign(e.mask),{color:hr(g),calpha:CPt(qu(y),i,e.isMask)}}),kn("video",$ht)});function DE(t){return t_t({c:t})}function Qp(t){return e_t({p:t})}function EPt(t){return i_t({m:t})}function Kf(t){return r_t({x:t})}function nF(t){return s_t({r:t})}function Dv(t){return n_t({v:t})}function OE(t){return a_t({x:t})}function PPt(t){return o_t({x:t})}function QR(t){return l_t({P:t})}function aF(t){return h_t({p3:t})}function MS(t,e,i){return u_t({a:t,b:e,k:i})}function Zbt(t,e,i){return d_t({a:t,b:e,k:i})}function Qbt(t,e,i,r,s){return c_t({value:t,input_min:e,input_max:i,output_min:r,output_max:s})}function Jbt(t,e,i,r,s){return p_t({x:t,style:e,smoothness:i,seed:r,quality:s})}var Xht,oF,mw,t_t,e_t,i_t,r_t,s_t,n_t,Yht,a_t,Kht,o_t,Zht,l_t,Qht,h_t,u_t,d_t,c_t,p_t,hT,DT=U(()=>{je(),Xht=mq,oF=Qi,mw=.1666667,t_t=At(t=>{let e=t.c,i=Bn(Bt(e,j(17,59.4,15))).mul(4096),r=Di(i.mul(512)),s=i.mul(.125),n=Di(s.mul(512)),a=s.mul(.125),o=Di(a.mul(512));return j(n,o,r).sub(.5)}).setLayout({name:"spe_random3",type:"vec3",inputs:[{name:"c",type:"vec3"}]}),e_t=At(t=>{let e=t.p,i=de(e.add(Bt(e,j(.3333333)))).toVar(),r=e.sub(i).add(Bt(i,j(mw))).toVar(),s=Si(j(0),r.sub(r.yzx)).toVar(),n=s.mul(Rr(s.zxy)).toVar(),a=Rr(s.zxy.mul(Rr(s))).toVar(),o=r.sub(n).add(mw).toVar(),l=r.sub(a).add(2*mw).toVar(),h=r.sub(1).add(3*mw).toVar(),u=at(Bt(r,r),Bt(o,o),Bt(l,l),Bt(h,h)).toVar();u.assign(at(.6).sub(u).max(0));let d=at(Bt(DE(i),r),Bt(DE(i.add(n)),o),Bt(DE(i.add(a)),l),Bt(DE(i.add(1)),h)).toVar();return u.mulAssign(u),u.mulAssign(u),d.mulAssign(u),Bt(d,at(52))}).setLayout({name:"spe_simplexFast",type:"float",inputs:[{name:"p",type:"vec3"}]}),i_t=At(t=>{let e=t.m,i=bm(j(-.37,.36,.85),j(-.14,-.93,.34),j(.92,.01,.4)),r=bm(j(-.55,-.39,.74),j(.33,-.91,-.24),j(.77,.12,.63)),s=bm(j(-.71,.52,-.47),j(-.08,-.72,-.68),j(-.7,-.45,.56));return Qp(e.mul(i)).mul(.5333333).add(Qp(e.mul(2).mul(r)).mul(.2666667)).add(Qp(e.mul(4).mul(s)).mul(.1333333)).add(Qp(e.mul(8)).mul(.0666667))}).setLayout({name:"spe_simplexFractal",type:"float",inputs:[{name:"m",type:"vec3"}]}),r_t=At(t=>{let e=t.x;return qh(e.mul(34).add(1).mul(e),289)}).setLayout({name:"spe_permute",type:"vec4",inputs:[{name:"x",type:"vec4"}]}),s_t=At(t=>A2(1.79284291400159,t.r.mul(.85373472095314))).setLayout({name:"spe_taylorInvSqrt",type:"vec4",inputs:[{name:"r",type:"vec4"}]}),n_t=At(t=>{let e=t.v,i=st(1/6,1/3),r=at(0,.5,1,2),s=de(e.add(Bt(e,i.yyy))).toVar(),n=e.sub(s).add(Bt(s,i.xxx)).toVar(),a=Si(n.yzx,n.xyz).toVar(),o=Rr(a).toVar(),l=ti(a.xyz,o.zxy).toVar(),h=Kt(a.xyz,o.zxy).toVar(),u=n.sub(l).add(i.xxx.mul(1)).toVar(),d=n.sub(h).add(i.xxx.mul(2)).toVar(),c=n.sub(1).add(i.xxx.mul(3)).toVar();s.assign(qh(s,289));let p=Kf(Kf(Kf(s.z.add(at(0,l.z,h.z,1))).add(s.y).add(at(0,l.y,h.y,1))).add(s.x).add(at(0,l.x,h.x,1))).toVar(),m=r.wyz.mul(1/7).sub(r.xzx).toVar(),f=p.sub(de(p.mul(m.z).mul(m.z)).mul(49)).toVar(),g=de(f.mul(m.z)).toVar(),y=de(f.sub(g.mul(7))).toVar(),v=g.mul(m.x).add(m.yyyy).toVar(),b=y.mul(m.x).add(m.yyyy).toVar(),_=A2(1,ke(v)).sub(ke(b)).toVar(),x=at(v.xy,b.xy).toVar(),S=at(v.zw,b.zw).toVar(),w=de(x).mul(2).add(1).toVar(),T=de(S).mul(2).add(1).toVar(),C=Si(_,at(0)).negate().toVar(),M=x.xzyw.add(w.xzyw.mul(C.xxyy)).toVar(),A=S.xzyw.add(T.xzyw.mul(C.zzww)).toVar(),P=j(M.xy,_.x).toVar(),O=j(M.zw,_.y).toVar(),D=j(A.xy,_.z).toVar(),N=j(A.zw,_.w).toVar(),z=nF(at(Bt(P,P),Bt(O,O),Bt(D,D),Bt(N,N))).toVar();P.mulAssign(z.x),O.mulAssign(z.y),D.mulAssign(z.z),N.mulAssign(z.w);let k=Kt(A2(.6,at(Bt(n,n),Bt(u,u),Bt(d,d),Bt(c,c))),0).toVar();return k.mulAssign(k),Bt(k.mul(k),at(Bt(P,n),Bt(O,u),Bt(D,d),Bt(N,c))).mul(42)}).setLayout({name:"spe_simplexAshima",type:"float",inputs:[{name:"v",type:"vec3"}]}),Yht=At(t=>{let e=t.x;return e.sub(de(e.mul(1/289)).mul(289))}).setLayout({name:"spe_mod289",type:"vec4",inputs:[{name:"x",type:"vec4"}]}),a_t=At(t=>{let e=t.x;return Yht({x:e.mul(34).add(1).mul(e)})}).setLayout({name:"spe_perm",type:"vec4",inputs:[{name:"x",type:"vec4"}]}),Kht=At(t=>{let e=t.p,i=de(e).toVar(),r=e.sub(i).toVar();r.assign(r.mul(r).mul(A2(3,r.mul(2))));let s=i.xxyy.add(at(0,1,0,1)).toVar(),n=OE(s.xyxy).toVar(),a=OE(n.xyxy.add(s.zzww)).toVar().add(i.zzzz).toVar(),o=OE(a).toVar(),l=OE(a.add(1)).toVar(),h=Di(o.mul(1/41)).toVar(),u=Di(l.mul(1/41)).toVar().mul(r.z).add(h.mul(Rr(r.z))).toVar(),d=u.yw.mul(r.x).add(u.xz.mul(Rr(r.x))).toVar();return d.y.mul(r.y).add(d.x.mul(Rr(r.y)))}).setLayout({name:"spe_valueNoise",type:"float",inputs:[{name:"p",type:"vec3"}]}),o_t=At(t=>{let e=j(t.x).toVar(),i=I(0).toVar(),r=I(.5).toVar(),s=j(100).toVar();return Qi(5,()=>{i.addAssign(r.mul(function(n){return Kht({p:n})}(e))),e.assign(e.mul(2).add(s)),r.mulAssign(.5)}),i}).setLayout({name:"spe_fbm",type:"float",inputs:[{name:"x",type:"vec3"}]}),Zht=At(t=>{let e=t.t;return e.mul(e).mul(e).mul(e.mul(e.mul(6).sub(15)).add(10))}).setLayout({name:"spe_fade",type:"vec3",inputs:[{name:"t",type:"vec3"}]}),l_t=At(t=>{let e=t.P,i=de(e).toVar(),r=i.add(j(1)).toVar();i.assign(qh(i,289)),r.assign(qh(r,289));let s=Di(e).toVar(),n=s.sub(j(1)).toVar(),a=at(i.x,r.x,i.x,r.x).toVar(),o=at(i.yy,r.yy).toVar(),l=at(i.zzzz).toVar(),h=at(r.zzzz).toVar(),u=Kf(Kf(a).add(o)).toVar(),d=Kf(u.add(l)).toVar(),c=Kf(u.add(h)).toVar(),p=d.div(7).toVar(),m=Di(de(p).div(7)).sub(.5).toVar();p.assign(Di(p));let f=at(.5).sub(ke(p)).sub(ke(m)).toVar(),g=Si(f,at(0)).toVar();p.subAssign(g.mul(Si(0,p).sub(.5))),m.subAssign(g.mul(Si(0,m).sub(.5)));let y=c.div(7).toVar(),v=Di(de(y).div(7)).sub(.5).toVar();y.assign(Di(y));let b=at(.5).sub(ke(y)).sub(ke(v)).toVar(),_=Si(b,at(0)).toVar();y.subAssign(_.mul(Si(0,y).sub(.5))),v.subAssign(_.mul(Si(0,v).sub(.5)));let x=j(p.x,m.x,f.x).toVar(),S=j(p.y,m.y,f.y).toVar(),w=j(p.z,m.z,f.z).toVar(),T=j(p.w,m.w,f.w).toVar(),C=j(y.x,v.x,b.x).toVar(),M=j(y.y,v.y,b.y).toVar(),A=j(y.z,v.z,b.z).toVar(),P=j(y.w,v.w,b.w).toVar(),O=nF(at(Bt(x,x),Bt(w,w),Bt(S,S),Bt(T,T))).toVar();x.mulAssign(O.x),w.mulAssign(O.y),S.mulAssign(O.z),T.mulAssign(O.w);let D=nF(at(Bt(C,C),Bt(A,A),Bt(M,M),Bt(P,P))).toVar();C.mulAssign(D.x),A.mulAssign(D.y),M.mulAssign(D.z),P.mulAssign(D.w);let N=Bt(x,s).toVar(),z=Bt(S,j(n.x,s.yz)).toVar(),k=Bt(w,j(s.x,n.y,s.z)).toVar(),B=Bt(T,j(n.xy,s.z)).toVar(),V=Bt(C,j(s.xy,n.z)).toVar(),q=Bt(M,j(n.x,s.y,n.z)).toVar(),W=Bt(A,j(s.x,n.yz)).toVar(),H=Bt(P,n).toVar(),rt=function(dt){return Zht({t:dt})}(s).toVar(),it=$t(at(N,z,k,B),at(V,q,W,H),rt.z).toVar(),ft=$t(it.xy,it.zw,rt.y).toVar();return $t(ft.x,ft.y,rt.x).toVar().mul(2.2)}).setLayout({name:"spe_perlin",type:"float",inputs:[{name:"P",type:"vec3"}]}),Qht=At(t=>{let e=Di(t.p3.mul(.1031)).toVar();return e.addAssign(Bt(e,e.yzx.add(33.33))),Di(e.x.add(e.y).mul(e.z))}).setLayout({name:"spe_hashwithoutsine13",type:"float",inputs:[{name:"p3",type:"vec3"}]}),h_t=At(t=>{let e=Di(t.p3.mul(j(.1031,.103,.0973))).toVar();return e.addAssign(Bt(e,e.yxz.add(33.33))),Di(e.xxy.add(e.yxx).mul(e.zyx))}).setLayout({name:"spe_hashwithoutsine33",type:"vec3",inputs:[{name:"p3",type:"vec3"}]}),u_t=At(t=>{let{a:e,b:i,k:r}=t,s=Ji(0,1,i.sub(e).mul(.5).div(r).add(.5)).toVar(),n=r.mul(s).mul(Rr(s)).toVar();return $t(i,e,s).sub(n)}).setLayout({name:"spe_smin",type:"float",inputs:[{name:"a",type:"float"},{name:"b",type:"float"},{name:"k",type:"float"}]}),d_t=At(t=>{let{a:e,b:i,k:r}=t,s=Ji(1,0,e.sub(i).mul(.5).div(r).add(.5)).toVar(),n=r.mul(s).mul(Rr(s)).toVar();return $t(e,i,s).add(n)}).setLayout({name:"spe_smax",type:"float",inputs:[{name:"a",type:"float"},{name:"b",type:"float"},{name:"k",type:"float"}]}),c_t=At(t=>{let{value:e,input_min:i,input_max:r,output_min:s,output_max:n}=t,a=r.sub(i).toVar(),o=n.sub(s).toVar(),l=e.sub(i).div(a).toVar();return s.add(l.mul(o))}).setLayout({name:"spe_remap",type:"float",inputs:[{name:"value",type:"float"},{name:"input_min",type:"float"},{name:"input_max",type:"float"},{name:"output_min",type:"float"},{name:"output_max",type:"float"}]}),p_t=At(t=>{let{x:e,style:i,smoothness:r,seed:s,quality:n}=t,a=Kn(de(e)).toVar(),o=Di(e).toVar(),l=I(8).toVar(),h=I(8).toVar(),u=I(8).toVar(),d=I(8).toVar(),c=I(8).toVar(),p=I(8).toVar(),m=Kn(0).toVar(),f=j(0).toVar(),g=ct(n).toVar(),y=()=>({start:g.negate(),end:g,condition:"<=",type:"int"});oF(y(),y(),y(),({i:b,j:_,k:x})=>{let S=Kn(b,_,x).toVar(),w=j(S).add(aF(j(a.add(S)).add(s))).sub(o).toVar(),T=ci(w).toVar();l.assign(MS(T,l,r)),vt(T.lessThan(h),()=>{d.assign(h),h.assign(T),m.assign(Kn(b,_,x)),f.assign(w)}).ElseIf(T.lessThan(d),()=>{d.assign(T)})}),vt(i.notEqual(ct(0)).and(i.notEqual(ct(5))).and(i.notEqual(ct(7))),()=>{oF(y(),y(),y(),({i:b,j:_,k:x})=>{let S=m.add(Kn(b,_,x)).toVar(),w=j(S).add(aF(j(a.add(S)).add(s))).sub(o).toVar(),T=Bt(f.add(w).mul(.5),w.sub(f)).toVar(),C=Bt(f.add(w).mul(.5),be(w.sub(f))).toVar();c.assign(MS(T,c,r)),p.assign(ti(p,C));let M=Kn(b,_,x).toVar();vt(oq(Xht(M,m)),()=>{let A=j(M).add(aF(j(a.add(M)).add(s))).sub(o).toVar(),P=ci(A).toVar();u.assign(MS(P,u,r))})})});let v=I(0).toVar();return vt(i.equal(ct(0)),()=>{v.assign(l)}).ElseIf(i.equal(ct(1)),()=>{v.assign(u)}).ElseIf(i.equal(ct(2)),()=>{v.assign(u.sub(l))}).ElseIf(i.equal(ct(3)),()=>{let b=I(3).toVar(),_=Kt(b.sub(ke(h.sub(d))),0).div(b).toVar();v.assign(ti(h,d).sub(_.mul(_).mul(b).mul(1/4)))}).ElseIf(i.equal(ct(4)),()=>{v.assign(kD(c.mul(5)))}).ElseIf(i.equal(ct(5)),()=>{v.assign(Lo(l,3))}).ElseIf(i.equal(ct(6)),()=>{let b=r.mul(.25).add(.0125).toVar(),_=Lo(r,3).mul(.25).add(.0125).toVar();v.assign(Ji(b.sub(b.mul(_)),b.add(b.mul(_)),p))}).ElseIf(i.equal(ct(7)),()=>{v.assign(function(b){return Qht({p3:b})}(j(a.add(m)).add(s)))}),v}).setLayout({name:"spe_voronoi",type:"float",inputs:[{name:"x",type:"vec3"},{name:"style",type:"int"},{name:"smoothness",type:"float"},{name:"seed",type:"float"},{name:"quality",type:"int"}]}),hT=[Qp,EPt,Dv,PPt,QR]});function m_t(t,e,i,r){return po(t.add(e).mul(i).mul(.001).add(f_t).add(r.mul(.1)))}function RPt(t,e,i){let r=function(h,u){let d=Math.trunc(h.getValue("noiseType")??0),c={n:u,scale:h.getFloat("scale"),intensity:h.getFloat("intensity"),offset:h.getVec3("offset"),movement:h.getFloat("movement")};if(d===5)return m=>po(y_t({...c,p:m,voronoiStyle:h.getInt("voronoiStyle"),smoothness:h.getFloat("smoothness"),seed:h.getFloat("seed"),highCut:h.getFloat("highCut"),lowCut:h.getFloat("lowCut"),quality:h.getInt("quality")}));let p=function(m){let f=A7.get(m);if(f===void 0){let g=hT[m]??hT[0];f=At(y=>{let{n:v,scale:b,intensity:_,offset:x,movement:S}=y,w=po(y.p);return w.add(v.mul(g(m_t(w,x,b,S))).mul(_))}).setLayout({name:`spe_displaceScalar${m}`,type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"n",type:"vec3"},{name:"scale",type:"float"},{name:"intensity",type:"float"},{name:"offset",type:"vec3"},{name:"movement",type:"float"}]}),A7.set(m,f)}return f}(d);return m=>po(p({...c,p:m}))}(t,i),s=j(r(e)).toVar(),n=j(function(h){return g_t({v:h})}(i)).toVar(),a=be(Kr(i,n)).toVar(),o=j(r(po(e.add(n)))).toVar(),l=j(r(po(e.add(a)))).toVar();return{position:s,normal:po(be(Kr(o.sub(s),l.sub(s))))}}var po,f_t,g_t,A7,y_t,lF,Jht,c0,fw,IE,tut,DPt=U(()=>{je(),DT(),po=t=>t,f_t=1e-4,g_t=At(t=>{let e=po(t.v);return be(po(pi(ke(e.x).greaterThan(ke(e.z)),j(e.y.negate(),e.x,0),j(0,e.z.negate(),e.y))))}).setLayout({name:"spe_displaceOrthogonal",type:"vec3",inputs:[{name:"v",type:"vec3"}]}),A7=new Map,y_t=At(t=>{let{n:e,scale:i,intensity:r,offset:s,movement:n,smoothness:a}=t,o=po(t.p),l=I(Jbt(m_t(o,s,i,n),t.voronoiStyle,a,t.seed,t.quality)).toVar();return l.assign(Qbt(l,t.lowCut,t.highCut,I(0),I(1))),l.assign(Zbt(l,I(0),a.mul(.25))),l.assign(MS(l,I(1),a.mul(.25))),o.add(e.mul(l).mul(r))}).setLayout({name:"spe_displaceVoronoi",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"n",type:"vec3"},{name:"scale",type:"float"},{name:"intensity",type:"float"},{name:"offset",type:"vec3"},{name:"movement",type:"float"},{name:"voronoiStyle",type:"int"},{name:"smoothness",type:"float"},{name:"seed",type:"float"},{name:"highCut",type:"float"},{name:"lowCut",type:"float"},{name:"quality",type:"int"}]})}),OPt=U(()=>{mn(),kn("color",(t,e,i)=>{let r=e.alpha.mul(e.mask);return{color:t.getColor("color"),calpha:fb(r,i)}})}),IPt=U(()=>{je(),mn(),lF=t=>t,Jht=t=>t,kn("depth",(t,e,i)=>{let r,s=t.get("colors"),n=t.get("steps"),a=(t.getValue("colors")??s.array).length,o=t.getValue("smooth")===!0,l=(t.getValue("isVector")??1)>.5,h=(t.getValue("gradientType")??0)===0,u=(t.getValue("isWorldSpace")??0)>.5,d=t.getFloat("near"),c=t.getFloat("far");if(l){let g=t.getVec3("origin"),y=u?Wo:Ya;if(h){let v=be(t.getVec3("direction"));r=Bt(v,y.sub(g))}else r=ci(y.sub(g))}else r=ci(Wo.sub(Oc));let p=r.sub(d).div(c.sub(d)).toVar(),m=at(s.element(0)).toVar();for(let g=1;g<a;g++){let y=lF(n.element(g-1)),v=lF(n.element(g)),b=Te(p.sub(y).div(v.sub(y)),I(0),I(1)),_=o?Ji(I(0),I(1),b):b;m.assign($t(m,Jht(s.element(g)),_))}let f=e.alpha.mul(m.a).mul(e.mask);return{color:m.rgb,calpha:Zu(f,i,e.isMask)}})}),NPt=U(()=>{je(),mn(),xq(),pn(),kn("cavity",(t,e,i)=>{let r=Te(t.getFloat("ridge"),0,2),s=Te(t.getFloat("valley"),0,2),n=Vt.normalViewRenderTarget,a=Vt.resolution,o=_q().x.toVar(),l=th.toVar(),h=st(I(1).div(a.x),I(1).div(a.y)).toVar(),u=(M,A)=>n.sample(l.add(st(M,A)).toVar()).toVar(),d=u(I(0),h.y.negate()),c=u(I(0),h.y),p=u(h.x.negate(),I(0)),m=u(h.x,I(0)),f=M=>M.a.equal(o).and(Bt(M.xyz,M.xyz).greaterThan(.5)),g=f(d).and(f(c)).and(f(p)).and(f(m)),y=d.y.sub(c.y).add(m.x.sub(p.x)).toVar(),v=I(.5).div(Kt(r.mul(r),I(1e-4))).toVar(),b=I(.7).div(Kt(s.mul(s),I(1e-4))).toVar(),_=(M,A)=>pi(M.lessThan(I(.5).div(A)),M.mul(I(1).sub(M.mul(A))),I(.25).div(A)),x=pi(g,pi(y.greaterThan(0),_(y,v).mul(2),_(y.negate(),b).mul(-2)),I(0)).toVar(),S=pi(x.abs().lessThan(.001),I(0),x).toVar(),w=j(Te(S.mul(.5).add(.5),0,1)),T=pi(S.notEqual(0),I(1),I(0)),C=pi(e.isMask,I(1),T);return{color:w,calpha:Zu(e.alpha.mul(e.mask).mul(C),i,e.isMask)}})}),gb=U(()=>{je(),c0=At(t=>{let e=t.material?.vertexObjectNormal??null;return e?T5(e).transformNormalByInverseViewMatrix(ih).normalize():wvt}).once()().toVar("speVertexNormalWorld")}),BPt=U(()=>{je(),gb(),mn(),DT(),kn("dust",(t,e,i)=>{let r=t.getFloat("coverage"),s=t.getFloat("softness"),n=t.getFloat("noiseStrength"),a=t.getFloat("noiseScale"),o=Bt(be(c0),j(0,1,0)),l=I(0).toVar();vt(n.notEqual(0),()=>{let c=Qp(Ya.div(a).toVar().add(j(1.7,9.2,1)));l.assign(c.mul(n))});let h=Kt(s,1e-4).toVar(),u=$t(h.add(1),h.add(1).negate(),Te(r,0,1)).toVar(),d=Ji(u.sub(h),u.add(h),o.add(l)).mul(e.alpha).mul(e.mask);return{color:t.getColor("color"),calpha:Zu(d,i,e.isMask)}})}),kPt=U(()=>{je(),gb(),mn(),fw=(t,e)=>t.element(e),kn("fresnel",(t,e,i)=>{let r=fw(mb,2).w.equal(-1),s=j(fw(ih,0).z,fw(ih,1).z,fw(ih,2).z).negate(),n=Wo.sub(Oc),a=pi(r,n,s),o=t.getFloat("bias").add(t.getFloat("scale").mul(Lo(ke(t.getFloat("factor").add(Bt(be(a),be(c0)))),t.getFloat("intensity")))),l=Te(o,0,1).mul(e.alpha).mul(e.mask);return{color:t.getColor("color"),calpha:Zu(l,i,e.isMask)}})}),VPt=U(()=>{je(),mn(),IE=t=>t,tut=t=>t,kn("gradient",(t,e,i)=>{let r=t.get("colors"),s=t.get("steps"),n=(t.getValue("colors")??r.array).length,a=(t.getValue("steps")??s.array).length,o=Math.min(10,n,a),l=t.getInt("gradientType"),h=t.getBool("smooth"),u=t.getVec2("offset"),d=t.getVec2("morph"),c=t.getFloat("angle"),p=ui(),m=at(r.element(0)).toVar(),f=st(d.div(p)).toVar(),g=st(I(.5).add(f.x),f.y).toVar(),y=st(Xa(c).mul(g.x).sub(Bn(c).mul(g.y)),Bn(c).mul(g.x).add(Xa(c).mul(g.y))).toVar(),v=st(p.sub(.5).add(u).div(2).add(y.div(2))),b=I(Bt(v,y).div(Bt(y,y))).toVar();vt(l.equal(ct(1)),()=>{b.assign(rvt(p.add(d).mul(3),p.add(u).add(1)).add(c))}).ElseIf(l.equal(ct(2)),()=>{let x=wc(p.x.add(d.x).sub(.5).add(u.x),p.y.add(d.y).sub(.5).add(u.y)).mul(-1);b.assign(Di(c.div(P9).div(-2).add(x.div(P9).mul(.5))))});for(let x=1;x<o;x++){let S=IE(s.element(x-1)),w=IE(s.element(x)),T=Te(b.sub(S).div(w.sub(S)),I(0),I(1)),C=IE(pi(h,Ji(I(0),I(1),T),T));m.assign($t(m,tut(r.element(x)),C))}let _=e.alpha.mul(m.a).mul(e.mask);return{color:m.rgb,calpha:Zu(_,i,e.isMask)}})}),zPt=U(()=>{je(),mn(),kn("matcap",(t,e,i)=>{let r=t.getFloat("rotation"),s=be(Ic.negate()),n=be(j(s.z,0,s.x.negate())),a=Kr(s,n),o=st(Bt(n,Ra),Bt(a,Ra)),l=Xa(r),h=Bn(r),u=st(l.mul(o.x).sub(h.mul(o.y)),h.mul(o.x).add(l.mul(o.y))).mul(.495).add(.5),d=t.get("texture").sample(u),c=e.alpha.mul(e.mask);return{color:d.rgb,calpha:Zu(c,i,e.isMask)}})}),LPt=U(()=>{je(),mn(),DT(),kn("noise",(t,e,i)=>{try{if(new URLSearchParams(window.location.search).get("dbgnoise")==="0")return{color:j(0),calpha:I(0)}}catch{}let r=Math.trunc(t.getValue("noiseType")??0),s=I(Kt(ke(t.getFloat("scale")),.001)).toVar(),n=j(Ya.div(t.getVec3("size"))).toVar();n.divAssign(s);let a=t.getFloat("move"),o=t.getVec4("colorA"),l=t.getVec4("colorC"),h=at(0).toVar();if(r===5){let d=t.getFloat("smoothness"),c=I(Jbt(n.add(a),t.getInt("voronoiStyle"),d,t.getFloat("seed"),t.getInt("quality"))).toVar();c.assign(Qbt(c,t.getFloat("lowCut"),t.getFloat("highCut"),I(0),I(1))),c.assign(Zbt(c,I(0),d.mul(.25))),c.assign(MS(c,I(1),d.mul(.25))),h.assign($t(o,l,c))}else{let d=hT[r]??hT[0],c=t.getVec4("colorB"),p=t.getVec4("colorD"),m=j(t.getVec2("distortion"),1).toVar(),f=j(t.getVec2("fA"),1).toVar(),g=j(t.getVec2("fB"),1).toVar(),y=j(d(n),d(n.add(j(1))),d(n.add(j(1)))).toVar(),v=j(d(n.add(m.mul(y)).add(f).add(a)),d(n.add(m.mul(y)).add(g).add(a)),d(n.mul(y))).toVar(),b=I(d(n.add(v))).toVar();h.assign($t(o,c,Te(b.mul(b).mul(4),I(0),I(1)))),h.assign($t(h,l,Te(ci(y),I(0),I(1)))),h.assign($t(h,p,Te(ci(v.x),I(0),I(1))))}let u=e.alpha.mul(h.a).mul(e.mask);return{color:Te(h,I(0),I(1)).rgb,calpha:Zu(u,i,e.isMask)}})}),FPt=U(()=>{je(),mn(),kn("normal",(t,e,i)=>({color:Mvt(be(Ra)).mul(Si(j(.5),t.getVec3("cnormal"))),calpha:fb(e.alpha.mul(e.mask),i)}))});function hF(t){return v_t({p:t})}function NE(t,e){return b_t({uv:t,a:e})}function jy(t,e,i,r,s){return __t({uv:t,frequency:e,variation:i,zigzag:r,rotation:s})}function BE(t,e){let i={uv:e.uv,frequency:e.frequency,size:e.size,variation:e.variation,smoothness:e.smoothness,zigzag:e.zigzag,rotation:e.rotation};switch(t){case 1:return w_t(i);case 2:return S_t({...i,sides:e.sides});case 3:return T_t(i);case 4:return M_t(i);case 5:return A_t(i);case 6:return C_t(i);case 7:return E_t(i);default:return x_t(i)}}var Gy,eut,v_t,b_t,__t,x_t,w_t,iut,S_t,rut,T_t,sut,M_t,A_t,C_t,nut,E_t,gw,uF,aut,out,lut,hut,uut,dF,dut,Zf,cut,put,cF,mut,UPt=U(()=>{je(),mn(),Gy=2*Math.PI,eut=Math.PI/180,v_t=At(t=>{let e=Di(t.p.xyx.mul(.1031)).toVar();return e.addAssign(Bt(e,e.yzx.add(33.33))),Di(e.x.add(e.y).mul(e.z))}).setLayout({name:"spe_pattern_hash12",type:"float",inputs:[{name:"p",type:"vec2"}]}),b_t=At(t=>{let e=t.uv,i=.5,r=I(t.a.mul(eut)).toVar(),s=st(Xa(r).mul(e.x.sub(i)).add(Bn(r).mul(e.y.sub(i))).add(i),Xa(r).mul(e.y.sub(i)).sub(Bn(r).mul(e.x.sub(i))).add(i));return Di(s)}).setLayout({name:"spe_pattern_rotate_uv",type:"vec2",inputs:[{name:"uv",type:"vec2"},{name:"a",type:"float"}]}),__t=At(t=>{let e=st(t.uv.mul(t.frequency)).toVar(),i=st(de(e)).toVar(),r=I(qh(i.y,2)).toVar();e.x.addAssign(r.mul(t.zigzag));let s=st(Di(e)).toVar();s.assign(s.mul(2).sub(1)),i.assign(de(e));let n=I(hF(i).mul(5).add(1)).toVar(),a=I($t(I(1),n,t.variation)).toVar();return s.mulAssign(a),s}).setLayout({name:"spe_pattern_tile_and_center",type:"vec2",inputs:[{name:"uv",type:"vec2"},{name:"frequency",type:"vec2"},{name:"variation",type:"float"},{name:"zigzag",type:"float"},{name:"rotation",type:"float"}]}),x_t=At(t=>{let e=st(jy(t.uv,t.frequency,t.variation,t.zigzag,t.rotation)).toVar();return Ji(t.smoothness.negate(),t.smoothness,ci(e).sub(t.size))}).setLayout({name:"spe_pattern_circle",type:"float",inputs:[{name:"uv",type:"vec2"},{name:"frequency",type:"vec2"},{name:"size",type:"float"},{name:"variation",type:"float"},{name:"smoothness",type:"float"},{name:"zigzag",type:"float"},{name:"rotation",type:"float"}]}),w_t=At(t=>{let e=st(jy(t.uv,t.frequency,t.variation,t.zigzag,t.rotation)).toVar(),i=I(ci(e)).toVar(),r=I(Ji(t.smoothness.negate(),t.smoothness,i.sub(t.size))).toVar(),s=I(Ji(t.smoothness.negate(),t.smoothness,i.sub(t.size.mul(.5)))).toVar();return r.add(Rr(s))}).setLayout({name:"spe_pattern_ring",type:"float",inputs:[{name:"uv",type:"vec2"},{name:"frequency",type:"vec2"},{name:"size",type:"float"},{name:"variation",type:"float"},{name:"smoothness",type:"float"},{name:"zigzag",type:"float"},{name:"rotation",type:"float"}]}),iut=At(t=>{let e=I(I(Gy).div(I(t.n))).toVar(),i=I(t.r.mul(Lvt(e.mul(.5)))).toVar(),r=st(t.p.yx.negate()).toVar(),s=I(e.mul(de(wc(r.y,r.x).add(e.mul(.5)).div(e)))).toVar(),n=st(Xa(s),Bn(s)).toVar();return r.assign(st(n.x.mul(r.x).add(n.y.mul(r.y)),n.y.negate().mul(r.x).add(n.x.mul(r.y)))),ci(r.sub(st(t.r,Te(r.y,i.negate(),i)))).mul(Xu(r.x.sub(t.r)))}).setLayout({name:"spe_pattern_sdf_ngon",type:"float",inputs:[{name:"p",type:"vec2"},{name:"r",type:"float"},{name:"n",type:"int"}]}),S_t=At(t=>{let e=st(jy(t.uv,t.frequency,t.variation,t.zigzag,t.rotation)).toVar();return Ji(t.smoothness.negate(),t.smoothness,iut({p:e,r:t.size,n:t.sides}))}).setLayout({name:"spe_pattern_polygon",type:"float",inputs:[{name:"uv",type:"vec2"},{name:"frequency",type:"vec2"},{name:"size",type:"float"},{name:"variation",type:"float"},{name:"smoothness",type:"float"},{name:"zigzag",type:"float"},{name:"rotation",type:"float"},{name:"sides",type:"int"}]}),rut=At(t=>{let e=t.b,i=st(ke(t.p)).toVar();i.assign(pi(i.y.greaterThan(i.x),i.yx,i.xy));let r=st(i.sub(e)).toVar(),s=I(Kt(r.y,r.x)).toVar(),n=st(pi(s.greaterThan(0),r,st(e.y.sub(i.x),s.negate()))).toVar();return Xu(s).mul(ci(Kt(n,st(0)))).add(t.r)}).setLayout({name:"spe_pattern_sdf_cross",type:"float",inputs:[{name:"p",type:"vec2"},{name:"b",type:"vec2"},{name:"r",type:"float"}]}),T_t=At(t=>{let e=st(jy(t.uv,t.frequency,t.variation,t.zigzag,t.rotation)).toVar();return Ji(t.smoothness.negate(),t.smoothness,rut({p:e,b:st(t.size,t.size.mul(.25)),r:t.smoothness}))}).setLayout({name:"spe_pattern_xcross",type:"float",inputs:[{name:"uv",type:"vec2"},{name:"frequency",type:"vec2"},{name:"size",type:"float"},{name:"variation",type:"float"},{name:"smoothness",type:"float"},{name:"zigzag",type:"float"},{name:"rotation",type:"float"}]}),sut=At(t=>{let e=t.b,i=st(ke(t.p)).toVar(),r=st(e.sub(i.mul(2))).toVar(),s=r.x.mul(e.x).sub(r.y.mul(e.y)),n=I(Te(s.div(Bt(e,e)),I(-1),I(1))).toVar();return I(ci(i.sub(e.mul(.5).mul(st(Rr(n),n.add(1)))))).toVar().mul(Xu(i.x.mul(e.y).add(i.y.mul(e.x)).sub(e.x.mul(e.y))))}).setLayout({name:"spe_pattern_sdf_diamond",type:"float",inputs:[{name:"p",type:"vec2"},{name:"b",type:"vec2"}]}),M_t=At(t=>{let e=st(jy(t.uv,t.frequency,t.variation,t.zigzag,t.rotation)).toVar();return Ji(t.smoothness.negate(),t.smoothness,sut({p:e,b:st(t.size)}))}).setLayout({name:"spe_pattern_diamond",type:"float",inputs:[{name:"uv",type:"vec2"},{name:"frequency",type:"vec2"},{name:"size",type:"float"},{name:"variation",type:"float"},{name:"smoothness",type:"float"},{name:"zigzag",type:"float"},{name:"rotation",type:"float"}]}),A_t=At(t=>{let e=st(t.uv.mul(t.frequency)).toVar(),i=st(de(e)).toVar(),r=I(qh(i.y,2)).toVar();e.x.addAssign(r.add(t.zigzag.mul(r)));let s=I(de(e.x)).toVar();return qh(s,2)}).setLayout({name:"spe_pattern_checkerboard",type:"float",inputs:[{name:"uv",type:"vec2"},{name:"frequency",type:"vec2"},{name:"size",type:"float"},{name:"variation",type:"float"},{name:"smoothness",type:"float"},{name:"zigzag",type:"float"},{name:"rotation",type:"float"}]}),C_t=At(t=>{let e=st(jy(t.uv,t.frequency,I(0),t.zigzag,t.rotation)).toVar(),i=I(de(t.uv.mul(t.frequency)).y).toVar(),r=I(hF(st(i))).toVar(),s=I($t(t.size,t.size.mul(r),t.variation)).toVar();return Ji(s.sub(t.smoothness),s.add(t.smoothness),ke(e.y))}).setLayout({name:"spe_pattern_line",type:"float",inputs:[{name:"uv",type:"vec2"},{name:"frequency",type:"vec2"},{name:"size",type:"float"},{name:"variation",type:"float"},{name:"smoothness",type:"float"},{name:"zigzag",type:"float"},{name:"rotation",type:"float"}]}),nut=At(t=>{let{a:e,b:i,c:r,d:s}=t,n=st(t.p.sub(st(s,e)).mul(r)).toVar();n.x.assign(qh(n.x,Gy)),vt(n.x.greaterThan(Math.PI),()=>{n.x.assign(I(Gy).sub(n.x))});let a=I(0).toVar(),o=I(Gy).toVar();Qi(24,()=>{let u=I(a.add(o).mul(.5)).toVar(),d=I(u.sub(n.x).add(i.mul(r).mul(Bn(u)).mul(n.y.sub(i.mul(r).mul(Xa(u)))))).toVar();vt(d.lessThan(0),()=>{a.assign(u)}).Else(()=>{o.assign(u)})});let l=I(a.add(o).mul(.5)).toVar(),h=st(l,i.mul(r).mul(Xa(l))).toVar();return ci(n.sub(h)).div(r)}).setLayout({name:"spe_pattern_udf_cos",type:"float",inputs:[{name:"p",type:"vec2"},{name:"a",type:"float"},{name:"b",type:"float"},{name:"c",type:"float"},{name:"d",type:"float"}]}),E_t=At(t=>{let e=I(t.frequency.x).toVar(),i=st(t.uv.mul(e)).toVar(),r=st(de(i)).toVar(),s=I(qh(r.y,2)).toVar();i.x.addAssign(s.mul(t.zigzag));let n=st(i.x,Di(i.y)).toVar(),a=I(t.frequency.y.mul(.1)).toVar(),o=I(nut({p:n,a:I(.5),b:I(.125),c:a.mul(Gy),d:I(0)})).toVar(),l=I(hF(st(r.y))).toVar(),h=I($t(t.size,t.size.mul(l),t.variation)).toVar();return Ji(t.smoothness.negate(),t.smoothness,o.sub(h.mul(.5)))}).setLayout({name:"spe_pattern_wave",type:"float",inputs:[{name:"uv",type:"vec2"},{name:"frequency",type:"vec2"},{name:"size",type:"float"},{name:"variation",type:"float"},{name:"smoothness",type:"float"},{name:"zigzag",type:"float"},{name:"rotation",type:"float"}]}),kn("pattern",(t,e,i)=>{let r,s,n=t.getValue("style")??0,a=t.getValue("projection")??0,o=t.getValue("axis")??0,l=t.getFloat("blending"),h=t.getVec2("offset"),u=t.getVec4("colorA"),d=t.getVec4("colorB"),c=t.getVec2("frequency"),p=t.getFloat("size"),m=t.getFloat("variation"),f=t.getFloat("smoothness"),g=t.getFloat("zigzag"),y=t.getFloat("rotation"),v=t.getVec2("vertical"),b=t.getVec2("horizontal"),_=t.getInt("sides"),x={frequency:c,size:p,variation:m,smoothness:I(Lo(f,5)).toVar(),zigzag:g,rotation:y,sides:_};if(a===4){let T=j(Ya).toVar(),C=I(.0125).toVar(),M=st(Di(T.xy.mul(C))).toVar(),A=st(Di(T.zy.mul(C))).toVar(),P=st(Di(T.xz.mul(C))).toVar();M.assign(NE(M.add(h),y)),A.assign(NE(A.add(h),y)),P.assign(NE(P.add(h),y));let O=I(BE(n,{uv:M,...x})).toVar(),D=I(BE(n,{uv:A,...x})).toVar(),N=I(BE(n,{uv:P,...x})).toVar(),z=I(Rr(l).mul(125).add(3)).toVar(),k=j(RT).toVar(),B=j(ke(be(k))).toVar();B.assign(Lo(B,j(z))),B.divAssign(Bt(B,j(1))),O.mulAssign(B.z),D.mulAssign(B.x),N.mulAssign(B.y),r=I(O.add(D).add(N)).toVar(),s=st(M.mul(B.z).add(A.mul(B.x)).add(P.mul(B.y))).toVar()}else{let T=st(0).toVar();if(a===0)T.assign(ui());else if(a===2){let C,M,A=j(Ya).toVar(),P=I(ci(A)).toVar();o===0?(C=I(wc(A.y,A.z)).toVar(),M=I(BR(A.x.div(P))).toVar()):o===1?(C=I(wc(A.x,A.z)).toVar(),M=I(BR(A.y.div(P))).toVar()):(C=I(wc(A.y,A.x)).toVar(),M=I(BR(A.z.div(P))).toVar()),T.assign(st(C,M).div(Math.PI))}T.addAssign(h),T.assign(Di(T)),T.assign(NE(T,y)),r=BE(n,{uv:T,...x}),s=T}let S=at($t(u,d,r)).toVar();S.a.assign(Te(S.a,I(0),I(1))),S.a.mulAssign(Si(v.x,s.y).mul(Si(s.y,v.y))),S.a.mulAssign(Si(b.x,ke(s.x)).mul(Si(ke(s.x),b.y)));let w=e.alpha.mul(Te(S.a,I(0),I(1))).mul(e.mask);return{color:Te(S,at(0),at(1)).rgb,calpha:Zu(w,i,e.isMask)}})}),jPt=U(()=>{je(),gb(),mn(),DT(),gw=(t,e)=>t.element(e),kn("rainbow",(t,e,i)=>{let r=t.getFloat("filmThickness"),s=t.getFloat("movement"),n=t.getVec3("wavelengths"),a=t.getFloat("noiseStrength"),o=t.getFloat("noiseScale"),l=t.getVec3("offset"),h=I(0).toVar();e.noiseCompiledIn!==!1&&vt(a.notEqual(0),()=>{let b=Ya.div(o).toVar(),_=Qp(b.mul(1.6).add(j(1.8,1.5,1.9).mul(Qp(b))).add(j(1.7,9.2,1)));h.assign(_.mul(a))});let u=n.mul(j(1,.8,.6)).add(1),d=gw(mb,2).w.equal(-1),c=j(gw(ih,0).z,gw(ih,1).z,gw(ih,2).z).negate(),p=Wo.sub(Oc),m=pi(d,p,c),f=Bt(be(m.add(l.mul(-.001))),be(c0)),g=Xa(r.add(h).div(u).mul(f).add(s)).mul(.5).add(.5),y=j(Te(g,0,2)).toVar(),v=Te(y.r.add(y.g).add(y.b),0,1);return{color:y,calpha:Zu(e.alpha.mul(v).mul(e.mask),i,e.isMask)}})}),GPt=U(()=>{je(),gb(),mn(),pn(),uF=t=>t,aut=t=>t,out=Qi,lut=Qi,hut=At(t=>{let e=t.x,i=j(Bt(e,j(127.1,311.7,74.7)),Bt(e,j(269.5,183.3,246.1)),Bt(e,j(113.5,271.9,124.6)));return Di(Bn(i).mul(43758.5453123))}).setLayout({name:"spe_toonHash3",type:"vec3",inputs:[{name:"x",type:"vec3"}]}),uut=At(t=>{let e=t.x,i=de(e).toVar(),r=Di(e).toVar(),s=I(100).toVar(),n=()=>({start:ct(-1),end:ct(1),condition:"<=",type:"int"});return lut(n(),n(),n(),({i:a,j:o,k:l})=>{let h=j(a,o,l).toVar(),u=h.sub(r).add(function(c){return hut({x:c})}(i.add(h))).toVar(),d=Bt(u,u).toVar();vt(d.lessThan(s),()=>{s.assign(d)})}),s.sqrt()}).setLayout({name:"spe_toonVoronoiF1",type:"float",inputs:[{name:"x",type:"vec3"}]}),kn("toon",(t,e,i)=>{let r=t.getInt("positioning"),s=t.get("colors"),n=t.get("steps"),a=t.getVec3("source"),o=t.getBool("isWorldSpace"),l=t.getFloat("noiseStrength"),h=t.getFloat("noiseScale"),u=t.getVec4("shadowColor"),d=t.getVec3("offset"),c=be(c0).toVar(),p=I(0).toVar();i.lightsAvailable===!0&&vt(r.equal(ct(0)),()=>{out({start:ct(0),end:Vt.toonLightCount,condition:"<",type:"int"},({i:b})=>{let _=Vt.toonLightData.element(b).toVar(),x=_.xyz,S=_.w,w=pi(S.greaterThan(.5),be(x),be(x.sub(Wo))),T=Bt(w,c).mul(.5).add(.5);p.assign(Kt(p,T))}),p.assign(Te(p,0,1))}),vt(r.equal(ct(1)),()=>{let b=$t(Ya,Wo,pi(o,I(1),I(0))),_=be(a.sub(b));p.assign(Bt(_,c).mul(.5).add(.5))}).ElseIf(r.equal(ct(2)),()=>{let b=Oc.sub(d),_=be(b.sub(Wo));p.assign(Bt(_,c).mul(.5).add(.5))}),vt(l.greaterThan(0),()=>{let b=Ya.div(h),_=I(1).sub(uut({x:b}));p.addAssign(_.mul(l))}),p.assign(Te(p,0,1));let m=(t.getValue("colors")??s.array).length,f=(t.getValue("steps")??n.array).length,g=Math.min(10,m,f),y=at(s.element(0)).toVar();for(let b=1;b<g;b++){let _=uF(n.element(b-1)),x=uF(n.element(b)),S=Te(p.sub(_).div(x.sub(_)),I(0),I(1));y.assign($t(y,aut(s.element(b)),Ji(0,1,S)))}i.lightsAvailable===!0&&vt(r.equal(ct(0)),()=>{let b=I(1),_=$t(y.rgb,u.rgb,u.a);y.rgb.assign($t(_,y.rgb,b))});let v=e.alpha.mul(y.a).mul(e.mask);return{color:y.rgb,calpha:fb(v,i)}})}),WPt=U(()=>{je(),gb(),mn(),Ubt(),pn(),dF=t=>t,dut=(t,e)=>t.element(e),Zf=t=>t,cut=t=>t,put=t=>t,kn("transmission",(t,e,i)=>{let r=t.getFloat("thickness"),s=t.getFloat("ior"),n=t.getFloat("roughness"),a=Vt.transmissionRenderTarget,o=Vt.transmissionSamplerSize,l=V=>dut(ih,V),h=be(j(l(0).z.negate(),l(1).z.negate(),l(2).z.negate())),u=be(Wo.sub(Oc)),d=Vt.orthographicUniform,c=pi(d.greaterThan(.5),h,u).toVar(),p=be(c0).toVar(),m=Ivt(c,p,I(1).div(s)).toVar(),f=be(m).mul(r).mul(Fbt).toVar(),g=V=>{let q=Vt.unjitteredProjection.mul(ih).mul(at(V,1)),W=q.xy.div(q.w);return st(W.x.mul(.5).add(.5),W.y.mul(-.5).add(.5))},y=g(Wo.add(f).toVar()).toVar(),v=(g(Wo).toVar(),n.mul(Te(s.mul(2).sub(2),I(0),I(1))).toVar()),b=Yv(o.x).mul(v).toVar(),_=v,x=ti(b.div(5.5),I(8.5)).toVar(),S=null,w="fit",T=!0,C=!1,M=12,A="white",P=1;try{let V=new URLSearchParams(window.location.search),q=V.get("dbglod");q!==null&&(S=Number(q));let W=V.get("dbgtap");W==="ring"&&(w="ring"),(W==="single"||W==="1")&&(w="single"),(W==="r50"||W==="r75"||W==="full")&&(w=W),W==="singlewide"&&(w="singlewide"),(W==="fit"||W==="singlefit")&&(w="fit");let H=V.get("dbgwidth");H!==null&&Number.isFinite(Number(H))&&(P=Math.max(0,Number(H))),W==="6"&&(w="ring",M=6),V.get("dbgwarp")==="0"&&(T=!1),V.get("dbgdither")==="1"&&(C=!0);let rt=V.get("dbgangle");(rt==="classic"||rt==="0")&&(A=rt)}catch{}S!==null&&Number.isFinite(S)&&x.assign(I(S));let O,D=(()=>{if(w==="singlewide")return ti(x.add(1),I(8.5)).toVar();if(w!=="fit")return x;let V=Vt.transmissionActualSize.x.div(Vt.resolution.x),q=_.mul(x).mul(5*P).mul(V).toVar();return ti(Yv(k1(x.mul(2)).add(q.mul(q).mul(3))).mul(.5),I(8.5)).toVar()})(),N=V=>a.sample(T?(q=>{let W=Vt.transmissionActualSize.div(k1(de(D))),H=q.mul(W).sub(.5),rt=de(H),it=H.sub(rt),ft=it.mul(it).mul(st(3,3).sub(it.mul(2)));return rt.add(.5).add(ft).div(W)})(V):V).level(D).rgb,z=w==="r50"?.5:w==="r75"?.75:1;if(w==="single"||w==="singlewide"||w==="fit")if(w==="fit"){let V=de(D).toVar(),q=D.sub(V).toVar(),W=xl(k1(q.mul(2)).sub(1)).mul(1.1547).toVar(),H=st(k1(V)).div(Vt.transmissionActualSize).mul(W).toVar(),rt=j(0).toVar(),it=12;for(let ft=0;ft<it;ft++){let dt=Zf(Sm(ft,it,I(0))),K=Zf(y.add(dt.mul(H)));rt.addAssign(cut(put(a.sample(K).level(V)).rgb))}O=rt.div(it).toVar()}else O=N(y).toVar();else{let V=st(I(1).div(Vt.resolution.x),I(1).div(Vt.resolution.y)).toVar(),q=Pc(A==="classic"?Qa.xy.add(Vt.cameraJitterPx):Qa.xy).mul(6.28318530718);A==="white"&&(q=q.add(Vt.tapAngle));let W=q.toVar(),H=Vt.tapAngle.mul(13.7).toVar(),rt=Vt.tapAngle2.mul(5.3).toVar(),it=st(k1(de(D).add(1))).div(Vt.transmissionActualSize).toVar(),ft=Pc(Qa.xy.add(st(H,rt))).toVar(),dt=Pc(Qa.xy.add(st(rt.mul(1.71),H.mul(2.39)))).toVar(),K=j(0).toVar();for(let lt=0;lt<M;lt++){let _t=Zf(Sm(lt,M,W)).mul(V).mul(_).mul(x.mul(10)).mul(z),xt=Zf(y.add(_t));if(C){let wt=dF(Di(ft.add(.7548776662*lt))),gt=dF(Di(dt.add(.5698402911*lt))),Dt=Zf(st(wt.sub(.5),gt.sub(.5)).mul(it));xt=Zf(xt.add(Dt))}K.addAssign(N(xt))}O=K.div(M).toVar()}if(t.has("attenuationDistance")){let V=t.getFloat("attenuationDistance"),q=j(t.getColor("attenuationColor")).toVar();vt(V.greaterThan(0),()=>{let W=Lo(Kt(q,j(1e-4)),j(r.div(V)));O.mulAssign(W)})}let k=e.alpha.mul(e.mask).toVar(),B=k.div(Te(k.add(i.accumAlpha),I(1e-5),I(1))).toVar();return i.accumAlpha.addAssign(I(1).sub(i.accumAlpha).mul(e.alpha)),{color:O,calpha:B}})}),qPt=U(()=>{je(),mn(),pn(),sbt(),kn("reflection",(t,e,i)=>{let r=t.getFloat("blur"),s=t.getFloat("thickness"),n=t.getInt("steps"),a=t.getFloat("stepSize"),o=t.getValue("tracingMode")??0,l=Vt.reflectionRenderTarget,h=Vt.reflectionDepthPyramid,u=Vt.reflectionDepthPyramid,d=Vt.reflectionDepthLevels,c=Vt.reflectionEnvMap,p=Vt.reflectionPlanarTarget,m=Vt.reflectionPlanarEnabled,f=$p("__splinePlanarMirror","float"),g=m.greaterThan(.5).and(f.greaterThan(.5)),y=Vt.reflectionResolveTarget,v=Vt.reflectionResolveEnabled,b=Vt.orthographicUniform.greaterThan(.5),_=pi(b,j(0,0,-1),be(Ic)).toVar(),x=be(Ra).toVar(),S=nT(_,x).toVar(),w=Te(r.mul(.1),I(0),I(1)).toVar(),T=Vt.resolution,C=j(0).toVar(),M=v.greaterThan(.5).and(w.greaterThan(.05)).and(g.not()),A=be(yq(S,w5)).toVar(),P=$9(c,A,w).toVar(),O=y.sample(th).level(I(0)).toVar();vt(M,()=>{let z=O.a.toVar();C.assign($t(P,O.rgb.div(z.max(1e-4)),Te(z.mul(2),I(0),I(1))))}).Else(()=>{C.assign(wq({dials:{blur:r,thickness:s,steps:n,stepSize:a,tracingMode:o},surface:{originView:Ic,normalV:x,screenUv:th,fragWindowZ:BD},camera:{projectionMatrix:mb,projectionMatrixInverse:Z1t,worldMatrix:w5,near:K1t},resources:{colorMap:l,depthPyramid:h,depthPyramidNode:u,envMap:c},usePlanar:g,noisePixel:th.mul(T).floor()}))}),vt(g,()=>{let z=st(I(1).sub(th.x),th.y).toVar(),k=I(d.sub(1)),B=ti(Yv(w.mul(T.y).mul(q9).add(1)),k).toVar(),V=B.sub(1).max(0).floor().toVar(),q=I(2).pow(B).sub(1).max(0).toVar(),W=q.mul(.75).div(T.y).toVar();C.assign(H9(p,z,W,q.mul(.75),V))});let D=e.alpha.mul(e.mask).toVar(),N=D.div(Te(D.add(i.accumAlpha),I(1e-5),I(1))).toVar();return i.accumAlpha.addAssign(I(1).sub(i.accumAlpha).mul(D)),{color:C,calpha:N}})}),HPt=U(()=>{je(),gb(),mn(),xq(),pn(),cF=t=>t,mut=t=>t,kn("outline",(t,e,i)=>{let r=t.getColor("outlineColor"),s=t.getColor("contourColor"),n=t.getFloat("outlineWidth"),a=t.getFloat("contourWidth"),o=t.getFloat("outlineThreshold"),l=t.getFloat("contourThreshold"),h=t.getFloat("outlineSmoothing"),u=t.getFloat("contourFrequency"),d=t.getVec3("contourDirection"),c=t.getBool("positionalLines"),p=t.getBool("compensation"),m=Vt.normalRenderTarget,f=Vt.normalRenderTargetDepth,g=Vt.resolution,y=Vt.pixelRatio,v=_q().x.toVar(),b=BD.toVar(),_=th.toVar(),x=st(I(1).div(g.x),I(1).div(g.y)).toVar(),S=Vt.pcssHalton,w=Pc(Qa.xy.add(S)).mul(6.28318530718).toVar(),T=p.select(n.div(2),n),C=x.mul(T).mul(y).toVar(),M=[[-1,-1],[0,-1],[1,-1],[-1,0],[0,0],[1,0],[-1,1],[0,1],[1,1]],A=ft=>Sm(ft,9,w).mul(x),P=[],O=I(0).toVar();for(let ft=0;ft<9;ft++){let[dt,K]=M[ft],lt=ft===4?_:cF(_.add(st(C.x.mul(dt),C.y.mul(K))).add(A(ft))),_t=cF(lt).toVar(),xt=mut(m.sample(_t)).toVar();P.push(xt),vt(xt.a.notEqual(v).and(xt.a.notEqual(0)),()=>{let wt=f.sample(_t).r.add(1e-4);vt(b.greaterThan(wt),()=>{O.assign(1)})})}let D=P[2].rgb.add(P[5].rgb.mul(2)).add(P[8].rgb).sub(P[0].rgb.add(P[3].rgb.mul(2)).add(P[6].rgb)),N=P[0].rgb.add(P[1].rgb.mul(2)).add(P[2].rgb).sub(P[6].rgb.add(P[7].rgb.mul(2)).add(P[8].rgb)),z=xl(Bt(D,D).add(Bt(N,N))).mul(O.oneMinus()).toVar(),k=j(r).toVar(),B=o.sub(h).toVar(),V=o.add(h).toVar(),q=V.greaterThan(B).select(Ji(B,V,z),z.greaterThan(o).select(I(1),I(0))).toVar(),W=be(c0).toVar(),H=I(1).sub(l).toVar();vt(c,()=>{let ft=Ya.mul(d),dt=ft.x.add(ft.y).add(ft.z).toVar(),K=Di(dt.mul(u).mul(.01)),lt=D9(dt.mul(u)),_t=Ji(lt.mul(a.mul(.01)),lt.mul(a.mul(.02)),K).toVar();vt(_t.lessThan(1).and(q.equal(0)),()=>{k.assign(s),q.assign(1)})}).Else(()=>{let ft=W.mul(d),dt=ft.x.add(ft.y).add(ft.z).toVar(),K=D9(dt.mul(l)).toVar(),lt=Bn(dt.mul(u)).toVar(),_t=Ji(I(0),K.mul(a),I(1).sub(lt)).toVar();vt(K.greaterThan(H.mul(.5)).and(_t.lessThan(1)).and(q.equal(0)),()=>{k.assign(s),q.assign(I(1).sub(_t))})});let rt=e.alpha.mul(q).mul(e.mask).toVar(),it=rt.div(Te(rt.add(i.accumAlpha),I(1e-5),I(1))).toVar();return i.accumAlpha.addAssign(I(1).sub(i.accumAlpha).mul(rt)),{color:k,calpha:it}})}),$Pt=U(()=>{je(),mn(),kn("vertexColor",(t,e,i)=>{let r=Wvt(),s=e.alpha.mul(e.mask).mul(r.a);return{color:r.rgb,calpha:fb(s,i)}})}),P_t=U(()=>{OPt(),IPt(),NPt(),BPt(),kPt(),VPt(),zPt(),LPt(),FPt(),UPt(),jPt(),Kbt(),GPt(),WPt(),qPt(),HPt(),$Pt(),Xbt()});function fut(t){let e=t.data,i=[t.kind,t.type,`v=${!!e.visible}`,`m=${!!e.isMask}`,`p=${t.params.names().join(",")}`];if(t.type!=="light"){let r=MT[t.type];if(r!==void 0)for(let s of r)i.push(`${s}=${String(e[s])}`)}for(let[r,s]of t.uniformKinds)(s==="vec4array"||s==="floatArray")&&i.push(`${r}#${(t.params.getValue(r)??[]).length}`);if(t.type==="rainbow"&&i.push(`noise=${t.noiseCompiledIn!==!1}`,`forced=${t.noiseForced===!0}`),t.type==="displace"&&i.push(`dt=${String(e.displacementType)}`),t.type==="texture"||t.type==="video"||t.type==="matcap"){if(t.holders.length===0)throw new Error(`structuralKey: ${t.type} layer has no holder`);let r=e.texture??{};i.push(`holder=${t.holders.map(s=>s.instanceId).join(",")}`,`wrap=${String(r.wrapping)}`,`min=${String(r.minFilter)}`,`mag=${String(r.magFilter)}`)}return i.join(";")}var XPt=U(()=>{ub()});function Xn(t,e=1){let i=new se(t);return new Dr(i.r,i.g,i.b,e)}function C7(t,e){if(t instanceof Dr)return t;if(t instanceof se)return new Dr(t.r,t.g,t.b,1);if(typeof t=="number")return Xn(t);if(typeof t=="object"&&t!==null&&"r"in t&&"g"in t&&"b"in t){let i=t;return new Dr(i.r,i.g,i.b,i.a??1)}return e()}function gut(){let t=new Array(10).fill(new Se(0,0,0,1)).map(e=>e.clone());return t[1]=new Se(1,1,1,1),t}function yut(){let t=new Array(10).fill(1);return t[0]=0,t}function B2(t,e){let i=t.material;if((i==null||i.isTSLNodeMaterial!==!0)&&(i=t.object?.material,i==null||i.isTSLNodeMaterial!==!0))return e;if(e.kind==="light"){let s=i.lightLayer;if(s==null)return e;let n=s.data?.category,a=e.data?.category;return n===a?s:e}let r=i.layers?.[e.structIndex];return r!==void 0&&r.type===e.type?r:e}function vut(t,e){if(typeof e!="number"||!Number.isInteger(e)||e<0)throw new Error(`[spe] ${t}.element() needs a build-time constant index (got ${String(e)}). Array params are inlined as per-slot uniforms; a dynamic index needs a real uniformArray.`);return e}function Fe(t,e,i,r){let s,n,a=t.params;switch(i){case"float":s=mt(Number(r??0));break;case"int":s=mt(Number(r??0),"int");break;case"axis":s=mt(["x","y","z"].indexOf(String(r)),"int");break;case"bool":s=mt(!!r);break;case"vec2":s=mt(r instanceof Y?r:new Y);break;case"vec3":s=mt(r instanceof E?r:new E);break;case"vec4":s=mt(r instanceof Se?r:new Se);break;case"color":{let o=C7(r,()=>Xn(16777215));s=mt(o),n=o;break}case"colorVec4":{let o=C7(r,()=>new Dr(1,1,1,1)),l=new Se(o.r,o.g,o.b,o.a),h=mt(l);h.onObjectUpdate(u=>{let d=B2(u,t).params.getLiveValue(e)??o;l.set(d.r,d.g,d.b,d.a)}),s=h,n=o;break}case"vec4array":{let o=Array.isArray(r)?r:[];s=function(l,h,u){let d=new Map;return{element(c){let p=vut(h,c),m=d.get(p);if(m===void 0){let f=mt(u[p]??new Se);f.onObjectUpdate(g=>(B2(g,l).params.getValue(h)??u)[p]??I_t),m=f,d.set(p,m)}return m},array:u,get value(){return u},set value(c){if(Array.isArray(c))for(let p=0;p<Math.min(u.length,c.length);p++){let m=c[p];Array.isArray(m)?u[p].set(m[0]??0,m[1]??0,m[2]??0,m[3]??1):m&&typeof m=="object"&&u[p].set(m.x??0,m.y??0,m.z??0,m.w??1)}}}}(t,e,o.length>0?o:[new Se]),n=o;break}case"floatArray":{let o=Array.isArray(r)?r:[0];s=function(l,h,u){let d=new Map;return{element(c){let p=vut(h,c),m=d.get(p);if(m===void 0){let f=mt(u[p]??0);f.onObjectUpdate(g=>{let y=B2(g,l).params.getValue(h);return Number((y??u)[p]??0)}),m=f,d.set(p,m)}return m},array:u,get value(){return u},set value(c){if(Array.isArray(c))for(let p=0;p<Math.min(u.length,c.length);p++)u[p]=Number(c[p])}}}(t,e,o.length>0?o:[0]),n=o;break}}i!=="vec4array"&&i!=="floatArray"&&i!=="colorVec4"&&(Eq(s),s.onObjectUpdate(o=>{let l=B2(o,t).params.getValue(e);l!==void 0&&Pq(s,l)})),a.set(e,s,n),t.uniformKinds.set(e,i)}function uT(t,e){let i=t.data;i.type!=="displace"?("alpha"in i&&t.params.has("alpha")&&t.params.setValue("alpha",Wv(i.alpha,e)*(i.visible?1:0)),i.type==="outline"&&t.params.has("compensation")&&t.params.setValue("compensation",!!i.compensation&&!!i.visible)):t.params.has("intensity")&&t.params.setValue("intensity",(as(i.intensity,e)??1)*(i.visible?1:0))}function R_t(t,e){Fe(t,"alpha","float",e.alpha??1),Fe(t,"mode","int",e.mode??0),Fe(t,"isMask","float",e.isMask?1:0)}function D_t(t,e,i,r){let s=new k2(t,e,i),n=i;if(Fe(s,"alpha","float",Wv(n.alpha,r)),Fe(s,"mode","int",n.mode??0),Fe(s,"bumpMapIntensity","float",n.bumpMapIntensity??5),Fe(s,"alphaOverride","float",Wv(n.alphaOverride,r)),i.visible)if(n.category==="lambert")Fe(s,"emissive","color",r.color(n.emissive)??Xn(0)),Fe(s,"occlusion","bool",n.occlusion??!0);else if(n.category==="toon")Fe(s,"shininess","float",n.shininess??30),Fe(s,"specular","color",r.color(n.specular)??Xn(1118481));else if(n.category==="physical"){Fe(s,"roughness","float",n.roughness??.3),Fe(s,"metalness","float",n.metalness??0),Fe(s,"reflectivity","float",n.reflectivity??.5),Fe(s,"occlusion","bool",n.occlusion??!0),Fe(s,"normalScale","float",n.normalScale??1),Fe(s,"aoMapIntensity","float",n.aoMapIntensity??1),Fe(s,"emissive","color",n.emissive!==void 0?r.color(n.emissive)??Xn(0):Xn(0)),Fe(s,"emissiveIntensity","float",n.emissiveIntensity??1);let a=n;a.clearcoat!==void 0&&(Fe(s,"clearcoat","float",a.clearcoat),Fe(s,"clearcoatRoughness","float",a.clearcoatRoughness??.1)),a.sheen!==void 0&&(Fe(s,"sheen","float",a.sheen),Fe(s,"sheenColor","color",a.sheenColor!==void 0?r.color(a.sheenColor)??Xn(16777215):Xn(16777215)),Fe(s,"sheenRoughness","float",a.sheenRoughness??.5)),a.ior!==void 0&&(Fe(s,"ior","float",a.ior),Fe(s,"specularIntensity","float",a.specularIntensity??1),Fe(s,"specularColor","color",a.specularColor!==void 0?r.color(a.specularColor)??Xn(16777215):Xn(16777215))),a.iridescence!==void 0&&(Fe(s,"iridescence","float",a.iridescence),Fe(s,"iridescenceIOR","float",a.iridescenceIOR??1.3),Fe(s,"iridescenceThickness","float",a.iridescenceThickness??400))}else Fe(s,"shininess","float",n.shininess??30),Fe(s,"specular","color",n.specular!==void 0?r.color(n.specular)??Xn(1118481):Xn(1118481)),Fe(s,"occlusion","bool",n.occlusion??!0);return s.node.alphaOverride=s.params.get("alphaOverride"),uT(s,r),s}function O_t(t,e,i,r){let s=new dT("fragment",t,e,i),n=i.type==="texture"?i.texture.image!=null?r.uiBuffer(i.texture.image)??r.image(i.texture.image):r.getImage(""):i.type==="video"?r.video(i.texture.video):i.texture.image!=null?r.image(i.texture.image):r.getImage("");s.holders.push(n);let a=i.texture.wrapping??(i.type==="texture"?1e3:1001),o=function(h,u,d,c){let p=Jt(h.getTexture(u,d,c));return p.onRenderUpdate(()=>h.getTexture(u,d,c)),p}(n,a,i.texture.minFilter??1008,i.texture.magFilter??1006);s.params.set("texture",o);let l=as(i.texture.rotation??0,r)??0;if(i.type==="matcap")Fe(s,"rotation","float",l*zt.DEG2RAD);else{let h=mt(new Y(1,1));h.onRenderUpdate(()=>{let f=n.getTexture(a,i.texture.minFilter??1008,i.texture.magFilter??1006).image;h.value.set(f?.width??1,f?.height??1)}),s.params.set("textureSize",h),s.uniformKinds.set("textureSize","vec2");let u=mt(n.loaded||n.isBuffer?1:0);u.onRenderUpdate(()=>n.loaded||n.isBuffer?1:0),s.params.set("loaded",u),s.uniformKinds.set("loaded","float"),Fe(s,"crop","float",i.crop?1:0),Fe(s,"projection","int",i.projection??0),Fe(s,"axis","axis",i.axis),Fe(s,"projectionAxis","axis",i.projectionAxis),Fe(s,"uvChannel","int",Uv.of(i.uvChannel)),Fe(s,"side","int",i.side??0);let d=i.size?new Y(as(i.size[0],r)??0,as(i.size[1],r)??0):new Y(100,100);Fe(s,"size","vec2",d),Fe(s,"blending","float",i.blending??0);let c=new Ms,p=new N_t([as(i.texture.repeat?.[0]??1,r)??1,as(i.texture.repeat?.[1]??1,r)??1],[as(i.texture.offset?.[0]??0,r)??0,as(i.texture.offset?.[1]??0,r)??0],l,c),m=mt(c);Eq(m),m.onObjectUpdate(f=>{let g=B2(f,s).params.getNodeValue("mat");g!==void 0&&Pq(m,g)}),s.params.set("mat",m,p)}return R_t(s,{alpha:Wv(i.alpha,r),mode:i.mode??0,isMask:i.isMask??!1}),uT(s,r),s}function YPt(t,e,i){return typeof t!="string"||e!=="float"&&e!=="int"?t instanceof E?wyt(t,i):t instanceof Y?Syt(t,i):t:as(t,i)}function KPt(t,e,i,r){if(i.type==="light")return D_t(t,e,i,r);if(i.type==="texture"||i.type==="video"||i.type==="matcap")return O_t(t,e,i,r);if(i.type==="displace")return function(o,l,h,u){if(h.displacementType!=="noise")throw new Error;let d=new dT("vertex",o,l,h),c=(p,m)=>as(p,u)??m;return Fe(d,"offset","vec3",new E(...h.offset.map(p=>c(p,0)))),Fe(d,"scale","float",c(h.scale,10)),Fe(d,"intensity","float",c(h.intensity,8)),Fe(d,"movement","float",c(h.movement,1)),Fe(d,"noiseType","int",h.noiseType??0),Fe(d,"voronoiStyle","int",h.voronoiStyle??0),Fe(d,"smoothness","float",c(h.smoothness,.5)),Fe(d,"seed","float",c(h.seed,0)),Fe(d,"highCut","float",c(h.highCut,1)),Fe(d,"lowCut","float",c(h.lowCut,0)),Fe(d,"quality","int",as(h.quality,u)??1),uT(d,u),d}(t,e,i,r);let s=new dT("fragment",t,e,i),n=function(o,l){switch(o.type){case"cavity":return function(h,u){return{...no(h,u),ridge:h.ridge,valley:h.valley}}(o,l);case"dust":return function(h,u){return{...no(h,u),color:_a(h.color,u),coverage:as(h.coverage,u)??.2,softness:as(h.softness,u)??.2,noiseStrength:as(h.noiseStrength,u)??.2,noiseScale:as(h.noiseScale,u)??1}}(o,l);case"fresnel":return function(h,u){let{bias:d,scale:c,intensity:p,factor:m,color:f}=h;return{...no(h,u),color:_a(f,u),bias:d,scale:c,intensity:p,factor:m}}(o,l);case"gradient":return function(h,u){let{gradientType:d,smooth:c,colors:p,steps:m,angle:f,offset:g,morph:y}=h;return{...no(h,u),gradientType:d,smooth:c,colors:p.map(v=>new Se(v[0],v[1],v[2],v[3])),num:p.length,steps:m,offset:new Y(...g.map(v=>typeof v=="number"?v:0)),morph:new Y(...y.map(v=>typeof v=="number"?v:0)),angle:f}}(o,l);case"depth":return function(h,u){let{gradientType:d,near:c,far:p,isVector:m,isWorldSpace:f,origin:g,direction:y,colors:v,steps:b,smooth:_}=h;return{...no(h,u),gradientType:d,near:c,far:p,isVector:m,isWorldSpace:f,origin:new E(...g),direction:y?new E(...y):new E(1,0,0),colors:v.map(x=>x!==void 0?new Se(x[0],x[1],x[2],x[3]):new Se(0,0,0,0)),steps:b.slice(0,v.length),smooth:_}}(o,l);case"normal":return function(h,u){let{cnormal:d}=h;return{...no(h,u),cnormal:new E(d[0],d[1],d[2])}}(o,l);case"noise":return function(h,u){return{...no(h,u),scale:h.scale,move:h.move,fA:new Y(...h.fA.map(d=>typeof d=="number"?d:0)),fB:new Y(...h.fB.map(d=>typeof d=="number"?d:0)),size:new E(...h.size),distortion:new Y(...h.distortion.map(d=>typeof d=="number"?d:0)),colorA:_a(h.colorA,u),colorB:_a(h.colorB,u),colorC:_a(h.colorC,u),colorD:_a(h.colorD,u),noiseType:h.noiseType,voronoiStyle:h.voronoiStyle,highCut:h.highCut,lowCut:h.lowCut,smoothness:h.smoothness,seed:h.seed,quality:h.quality}}(o,l);case"rainbow":return function(h,u){return{...no(h,u),filmThickness:h.filmThickness,movement:h.movement,wavelengths:new E(...h.wavelengths),noiseStrength:h.noiseStrength,noiseScale:h.noiseScale,offset:new E(...h.offset)}}(o,l);case"toon":return function(h,u){return{...no(h,u),positioning:h.positioning,colors:h.colors.map(d=>new Se(d[0],d[1],d[2],d[3])),num:h.colors.length,steps:h.steps,source:new E(...h.source),isWorldSpace:h.isWorldSpace,noiseStrength:h.noiseStrength,noiseScale:h.noiseScale,shadowColor:_a(h.shadowColor,u),offset:new E(...h.offset)}}(o,l);case"outline":return function(h,u){return{...no(h,u),outlineColor:_a(h.outlineColor,u),contourColor:_a(h.contourColor,u),outlineWidth:h.outlineWidth,contourWidth:h.contourWidth,outlineThreshold:h.outlineThreshold,contourThreshold:h.contourThreshold,outlineSmoothing:h.outlineSmoothing,contourFrequency:h.contourFrequency,contourDirection:new E(...h.contourDirection),positionalLines:h.positionalLines,compensation:h.compensation}}(o,l);case"transmission":return function(h,u){return{...no(h,u),thickness:h.thickness,ior:h.ior,roughness:h.roughness,attenuationColor:h.attenuationColor!==void 0?_a(h.attenuationColor,u):{r:1,g:1,b:1,a:1},attenuationDistance:h.attenuationDistance??0}}(o,l);case"reflection":return function(h,u){return{...no(h,u),blur:as(h.blur,u)??0,thickness:as(h.thickness,u)??.001,steps:as(h.steps,u)??60,stepSize:as(h.stepSize,u)??.005,tracingMode:h.tracingMode,mirror:h.mirror??0}}(o,l);case"pattern":return function(h,u){return{...no(h,u),style:h.style,projection:h.projection,axis:h.axis,blending:h.blending,offset:new Y(...h.offset.map(d=>typeof d=="number"?d:0)),colorA:_a(h.colorA,u),colorB:_a(h.colorB,u),frequency:new Y(...h.frequency.map(d=>typeof d=="number"?d:0)),size:h.size,variation:h.variation,smoothness:h.smoothness,zigzag:h.zigzag,rotation:h.rotation,vertical:new Y(...h.vertical.map(d=>typeof d=="number"?d:0)),horizontal:new Y(...h.horizontal.map(d=>typeof d=="number"?d:0)),sides:h.sides}}(o,l);case"vertexColor":return no(o,l);default:return function(h,u){return{...no(h,u),color:_a(h.color,u)}}(o,l)}}(i,r),a=E7[i.type]??E7.color;for(let[o,l]of Object.entries(a))Fe(s,o,l.kind,YPt(n[o],l.kind,r)??l.def());if(i.type==="transmission"){let o=typeof window<"u"?window.innerWidth:1,l=typeof window<"u"?window.innerHeight:1;Fe(s,"aspectRatio","vec2",o>=l?new Y(l/o,1):new Y(1,o/l))}return R_t(s,n),uT(s,r),s}var but,pF,E7,I_t,N_t,dT,k2,_ut,Xp,Oq,ZPt=U(()=>{ot(),cr(),pD(),rbt(),je(),De(),MD(),TPt(),ub(),Nc(),v0t(),mn(),Xbt(),bq(),Kbt(),DPt(),P_t(),DD(),XPt(),but=t=>t,pF=t=>t,E7={color:{color:{kind:"color",def:()=>Xn(i0)}},vertexColor:{},cavity:{ridge:{kind:"float",def:()=>1},valley:{kind:"float",def:()=>1}},fresnel:{color:{kind:"color",def:()=>Xn(16777215)},bias:{kind:"float",def:()=>.1},scale:{kind:"float",def:()=>1},intensity:{kind:"float",def:()=>2},factor:{kind:"float",def:()=>1}},dust:{color:{kind:"color",def:()=>Xn(10323813)},coverage:{kind:"float",def:()=>.2},softness:{kind:"float",def:()=>.2},noiseStrength:{kind:"float",def:()=>.2},noiseScale:{kind:"float",def:()=>1}},rainbow:{filmThickness:{kind:"float",def:()=>30},movement:{kind:"float",def:()=>0},wavelengths:{kind:"vec3",def:()=>new E},noiseStrength:{kind:"float",def:()=>0},noiseScale:{kind:"float",def:()=>1},offset:{kind:"vec3",def:()=>new E}},transmission:{thickness:{kind:"float",def:()=>10},ior:{kind:"float",def:()=>1.5},roughness:{kind:"float",def:()=>.5},attenuationColor:{kind:"color",def:()=>Xn(16777215)},attenuationDistance:{kind:"float",def:()=>0}},reflection:{blur:{kind:"float",def:()=>0},thickness:{kind:"float",def:()=>.001},steps:{kind:"int",def:()=>60},stepSize:{kind:"float",def:()=>.005},tracingMode:{kind:"int",def:()=>1}},toon:{positioning:{kind:"int",def:()=>0},colors:{kind:"vec4array",def:gut},steps:{kind:"floatArray",def:yut},source:{kind:"vec3",def:()=>new E},isWorldSpace:{kind:"bool",def:()=>!0},noiseStrength:{kind:"float",def:()=>0},noiseScale:{kind:"float",def:()=>1},shadowColor:{kind:"colorVec4",def:()=>new Dr(0,0,0,0)},offset:{kind:"vec3",def:()=>new E}},outline:{outlineColor:{kind:"color",def:()=>Xn(16777215)},contourColor:{kind:"color",def:()=>Xn(16777215)},outlineWidth:{kind:"float",def:()=>.1},contourWidth:{kind:"float",def:()=>.1},outlineThreshold:{kind:"float",def:()=>.1},contourThreshold:{kind:"float",def:()=>.1},outlineSmoothing:{kind:"float",def:()=>.1},contourFrequency:{kind:"float",def:()=>.1},contourDirection:{kind:"vec3",def:()=>new E(0,1,0)},positionalLines:{kind:"bool",def:()=>!1},compensation:{kind:"bool",def:()=>!0}},depth:{gradientType:{kind:"int",def:()=>0},smooth:{kind:"bool",def:()=>!1},near:{kind:"float",def:()=>50},far:{kind:"float",def:()=>200},isVector:{kind:"float",def:()=>1},isWorldSpace:{kind:"float",def:()=>0},origin:{kind:"vec3",def:()=>new E},direction:{kind:"vec3",def:()=>new E(1,0,0)},colors:{kind:"vec4array",def:()=>[new Se(0,0,0,1),new Se(1,1,1,1)]},steps:{kind:"floatArray",def:()=>[0,1]}},noise:{scale:{kind:"float",def:()=>1},size:{kind:"vec3",def:()=>new E(100,100,100)},move:{kind:"float",def:()=>1},fA:{kind:"vec2",def:()=>new Y(1.7,9.2)},fB:{kind:"vec2",def:()=>new Y(8.3,2.8)},distortion:{kind:"vec2",def:()=>new Y(1,1)},colorA:{kind:"colorVec4",def:()=>new Dr(.4,.4,.4,1)},colorB:{kind:"colorVec4",def:()=>new Dr(.4,.4,.4,1)},colorC:{kind:"colorVec4",def:()=>new Dr(1,1,1,1)},colorD:{kind:"colorVec4",def:()=>new Dr(1,1,1,1)},noiseType:{kind:"int",def:()=>0},voronoiStyle:{kind:"int",def:()=>0},highCut:{kind:"float",def:()=>1},lowCut:{kind:"float",def:()=>0},smoothness:{kind:"float",def:()=>.5},seed:{kind:"float",def:()=>.5},quality:{kind:"int",def:()=>1}},normal:{cnormal:{kind:"vec3",def:()=>new E(1,1,1)}},gradient:{gradientType:{kind:"int",def:()=>0},smooth:{kind:"bool",def:()=>!1},colors:{kind:"vec4array",def:gut},steps:{kind:"floatArray",def:yut},offset:{kind:"vec2",def:()=>new Y},morph:{kind:"vec2",def:()=>new Y},angle:{kind:"float",def:()=>0}},pattern:{style:{kind:"int",def:()=>0},projection:{kind:"int",def:()=>0},axis:{kind:"axis",def:()=>"x"},blending:{kind:"float",def:()=>0},offset:{kind:"vec2",def:()=>new Y},colorA:{kind:"colorVec4",def:()=>new Dr(0,0,0,1)},colorB:{kind:"colorVec4",def:()=>new Dr(1,1,1,1)},frequency:{kind:"vec2",def:()=>new Y(10,10)},size:{kind:"float",def:()=>.5},variation:{kind:"float",def:()=>0},smoothness:{kind:"float",def:()=>.5},zigzag:{kind:"float",def:()=>0},rotation:{kind:"float",def:()=>0},vertical:{kind:"vec2",def:()=>new Y(0,1)},horizontal:{kind:"vec2",def:()=>new Y(0,1)},sides:{kind:"int",def:()=>6}}},I_t=new Se,N_t=class{constructor(t,e,i,r){this.repeat=t,this.offset=e,this.rotation=i,this.target=r,this.updateMatrix()}updateMatrix(){this.target.setUvTransform(this.offset[0],this.offset[1],this.repeat[0],this.repeat[1],0,0,0).premultiply(new Ms().makeRotation(this.rotation*zt.DEG2RAD))}},dT=class{constructor(t,e,i,r){this.kind=t,this.id=e,this.uuid=i,this.data=r,this.uniformKinds=new Map,this.holders=[],this.structIndex=-1,this.params=new Rq(e)}get type(){return this.data.type}get uniforms(){return this.params.uniforms}get alphaNode(){return this.params.getFloat("alpha")}get modeNode(){return this.params.getInt("mode")}get isMaskNode(){return this.params.getFloat("isMask")}get isMaskEnabled(){return"isMask"in this.data&&!!this.data.isMask}hasValue(t){return this.params.has(t)}setValue(t,e){if(t==="noiseStrength"&&this.noiseCompiledIn===!1&&typeof e=="number"&&e!==0&&this.onNoiseMismatch!==void 0){let i=this.onNoiseMismatch;return this.onNoiseMismatch=void 0,this.params.setValue(t,e),void(i(e)&&(this.noiseCompiledIn=!0))}this.params.setValue(t,e)}getNode(t){return this.params.has(t)?this.params.get(t):void 0}getValue(t){return this.params.getValue(t)}getName(t){let e=/f\d+_(.*)/.exec(t);if(e&&e.length>1)return e[1];console.log(`Layer.getName: error ${t}`)}getNames(){return this.params.names()}get assetsLoaded(){return this.holders.every(t=>t.loaded)}dispose(){for(let t of this.holders)t instanceof Sg||t.deref();this.holders.length=0}},k2=class extends dT{constructor(t,e,i){super("light",t,e,i),this.node={alphaOverride:void 0,alpha:{value:1}}}get lightData(){return this.data}get category(){return this.lightData.category??"phong"}},_ut={displace_noise:[{nums:["intensity","scale","movement","smoothness","seed","highCut","lowCut"],vecs:["offset"]}],displace_map:[{nums:["intensity"],vecs:[]}],depth:[{nums:["near","far"],vecs:["origin","direction"]}],cavity:[{nums:["ridge","valley"],vecs:[]}],fresnel:[{nums:["bias","scale","intensity","factor"],vecs:[]}],dust:[{nums:["coverage","softness","noiseStrength","noiseScale"],vecs:[]}],rainbow:[{nums:["filmThickness","movement","noiseStrength","noiseScale"],vecs:["offset","wavelengths"]}],noise:[{nums:["scale","move","seed","highCut","lowCut","smoothness"],vecs:["size","distortion","fA","fB"]}],pattern:[{nums:["blending","size","variation","smoothness","zigzag","rotation"],vecs:["offset","frequency","vertical","horizontal"]}],outline:[{nums:["outlineWidth","contourWidth","outlineThreshold","contourThreshold","outlineSmoothing","contourFrequency"],vecs:["contourDirection"]}],toon:[{nums:["noiseStrength","noiseScale"],vecs:["offset","source"]}],transmission:[{nums:["roughness","thickness","ior"],vecs:[]}],reflection:[{nums:["blur","thickness","steps","stepSize"],vecs:[]}],texture:[{nums:[],vecs:["size"]},{nums:["rotation"],vecs:["repeat","offset"],path:["texture"]}],video:[{nums:[],vecs:["size"]},{nums:["rotation"],vecs:["repeat","offset"],path:["texture"]}],gradient:[{nums:["angle"],vecs:["offset","morph"]}],matcap:[{nums:["rotation"],vecs:[],path:["texture"]}]},Xp=class extends Pe{constructor(t,e,i=!0,r,s=!1){super(),this.allowVariableSaves=i,this.isTSLNodeMaterial=!0,this.layerIdGen=0,this.layers=[],this.flavors=[],this.depthTwins=[],this.depthPrepass=!1,this.depthPrepassCutoff=0,this.depthPrepassTwins=[],this.depthOfFieldTwins=[],this.mrtWriteMask=void 0,this.flatShading=!1,this.wireframe=!1,this.emissiveNode=null,this.shapeBlendOptions=null,this._environmentScope=ebt,this._shapeBlendResources=null,this._shapeBlendColorNode=null,this.shapeBlendObjectNormal=null,this.displacedObjectNormal=null,this.syntheticMapLayers=new Map,this._structuralKey=null,this._structuralKeyVersion=-1,this.forceRainbowNoise=new Set,this.root=r??this,this.isDepthPrepassTwin=s,this.fog=!0,this.dithering=!0,this.vertexColors=!1,this.transparent=!0,r?(this.lastContext=r.lastContext,this.syncFromRoot()):this.reset0(t,e),function(n){if(!P2.has(n)){let a=new WeakRef(n);P2.set(n,a),oT.add(a)}vq++}(this),this.addEventListener("dispose",()=>function(n){let a=P2.get(n);a&&(oT.delete(a),P2.delete(n))}(this))}get envMapRotation(){return Cv(this.environmentScope).rotation}get environmentRoot(){return this.root===this?this:this.root.environmentRoot}get environmentScope(){return this.environmentRoot._environmentScope}claimEnvironmentScope(t){let e=this.environmentRoot;return e._environmentScope!==t&&(e._environmentScope=t,!0)}_invalidateStructuralKey(){this._structuralKey=null,this._structuralKeyVersion=-1}customProgramCacheKey(){let t=this._structuralKey;if(t===null||this._structuralKeyVersion!==this.version){try{t=function(r){let s=r.lightLayer,n=s.data,a=h=>{if(!h)return-1;if(typeof h!="string"){let c=r.syntheticMapLayers?.get(h);return c!==void 0?`img(${fut(c)};o=${JSON.stringify(h.offset??null)};r=${JSON.stringify(h.repeat??null)};rot=${JSON.stringify(h.rotation??null)})`:"img"}let u=r.layers.findIndex(c=>c.uuid===h);if(u===-1||r.layers[u].kind!=="fragment")return-1;let d=r.layers[u].type;return d==="texture"||d==="video"?u:-1},o=r.category==="physical",l=["spe-tsl-v1",`lights=${r.lights}`,`cat=${r.category}`,`lvis=${n.visible===!0}`,`lidx=${r.layers.indexOf(s)}`,`bump=${a(n.bumpMap)}`,`rough=${o?a(n.roughnessMap):-1}`,`metal=${o?a(n.metalnessMap):-1}`,`nrm=${o?a(n.normalMap):-1}`,`ao=${o?a(n.aoMap):-1}`,`emis=${o?a(n.emissiveMap):-1}`,`rch=${o?n.roughnessMapChannel??"luminance":""}`,`mch=${o?n.metalnessMapChannel??"b":""}`,`ach=${o?n.aoMapChannel??"r":""}`];for(let h of r.layers)l.push(fut(h));return l.join("|")}(this),this.shapeBlendOptions!==null&&(t+=`|sb:${this.uuid}:${this._shapeBlendResources!==null?1:0}`)}catch{t=super.customProgramCacheKey()}this._structuralKey=t,this._structuralKeyVersion=this.version}let e=this.envNode instanceof Jv?Cv(this.environmentScope).version:0,i=this.physicalLobes();return`${t}|env${e}|lobes${(i.clearcoat?1:0)|(i.sheen?2:0)|(i.iridescence?4:0)}`}get isRoot(){return this.root===this}applyDepthPrepassPolicy(){if(this.isDepthPrepassTwin)return this.depthPrepass=!1,this.colorWrite=!1,void(this.depthWrite=!0);let t=(e={transparent:this.transparent,depthTest:this.depthTest,wireframe:this.wireframe,shapeBlend:this.shapeBlendOptions!==null,data:this.root.data},W9&&e.transparent&&e.depthTest&&!e.wireframe&&!e.shapeBlend&&!function(i){let r=i?.layers;if(!r)return!1;for(let s of r)if(s.data.type==="transmission"&&s.data.visible)return!0;return!1}(e.data));var e;this.depthPrepass=t,this.depthWrite=!t}getDepthPrepassTwin(t){var e;return(e=this.depthPrepassTwins)[t]??(e[t]=this.createDepthTwin(t,!1))}getDepthOfFieldTwin(t){var e;return(e=this.depthOfFieldTwins)[t]??(e[t]=this.createDepthTwin(t,!0))}createDepthTwin(t,e){let i=this.root,r=new Xp(i.data,i.lastContext,i.allowVariableSaves,i,!0);return r.flatShading=this.flatShading,r.side=t,r.wireframe=!1,r.depthPrepassCutoff=Ggt,e||(r.mrtWriteMask={velocity:!0}),r.applyDepthPrepassPolicy(),i.depthTwins.push(r),r}get vertexObjectNormal(){return this.shapeBlendObjectNormal??this.root.displacedObjectNormal}get category(){return this.lightLayer.category}envReflectiveInLow(){let t=!1;for(let e of this.layers){let i=e.data;if(i?.category==="physical"&&(t=!0,i.roughnessMap!==void 0||i.metalnessMap!==void 0||typeof i.roughness!="number"||typeof i.metalness!="number"||i.clearcoat!==void 0||i.sheen!==void 0||i.iridescence!==void 0||i.ior!==void 0||i.metalness>.3||i.roughness<.4))return!0}return!t}get hasAO(){return this.lightLayer.getValue("occlusion")??!1}get fragment(){}reset(t,e,i=!1){(this.data!==t||i)&&this.reset0(t,e)}reset0(t,e){this.lastContext=e,this.data=t;let i=t.layers??Qr.defaultTwoLayerData("phong").layers;for(let n of this.layers)n.dispose();for(let n of this.syntheticMapLayers.values())n.dispose();this.syntheticMapLayers.clear();let r=[];for(let n of i)try{let a=KPt(this.layerIdGen++,n.id,n.data,e.shared);a.type==="rainbow"&&this.armRainbowNoiseSpecialization(a),r.push(a)}catch(a){console.warn(`[spe] material layer '${n?.data?.type}' (${n?.id}) failed to build \u2014 skipping this layer`,a)}this.layers=r,this.layers.reverse();for(let n=0;n<this.layers.length;n++)this.layers[n].structIndex=n;this.name=t.name??"Untitled Material";let s=this.layers.find(n=>n instanceof k2);if(s===void 0&&(s=D_t(0,"",{...Is.defaultData("light","phong"),visible:!1},e.shared)),this.lightLayer=s,this.lights=!!this.lightLayer.data.visible,this.ctx={accumAlpha:I(0).toVar("accumAlpha"),lightsAvailable:this.lights&&(this.category==="phong"||this.category==="lambert"||this.category==="physical")},this.colorNode=At(()=>this.buildColorStack())(),this.buildVertexStack(),this.normalNode=this.buildNormalNode(this.displacedNormalView()),this.emissiveNode=this.lights&&this.category==="lambert"&&this.lightLayer.params.has("emissive")?this.lightLayer.params.get("emissive"):null,this.aoNode=null,this.lights&&this.category==="physical"){let n=this.lightLayer.params,a=this.lightLayer.lightData;if(n.has("emissive")){let l=this.findTextureMapLayer(a.emissiveMap);this.emissiveNode=At(()=>{let h=j(n.getColor("emissive")).mul(n.getFloat("emissiveIntensity"));return l!==null&&(h=h.mul(function(u){let d,c=u.get("texture"),p=u.has("loaded")?u.getFloat("loaded"):I(1),{uvs:m,weights:f}=TS(u);if(f!==null){let g=j(Aa(c.sample(m[0])).rgb).toVar(),y=j(Aa(c.sample(m[1])).rgb).toVar(),v=j(Aa(c.sample(m[2])).rgb).toVar();d=hr(g.mul(f.z).add(y.mul(f.x)).add(v.mul(f.y)))}else d=hr(j(Aa(c.sample(m[0])).rgb));return hr($t(j(0),d,p))}(l.params))),h})()}let o=this.findTextureMapLayer(a.aoMap);o!==null&&(this.aoNode=At(()=>$t(I(1),sF(o.params,a.aoMapChannel??"r"),n.getFloat("aoMapIntensity")))())}this.transparent=lm(t,e.shared),this.applyDepthPrepassPolicy(),GR(this),this.needsUpdate=!0;for(let n of this.flavors)n?.syncFromRoot();for(let n of this.depthTwins)n.syncFromRoot();this.saveVariableLocations(e)}setTransparent(t,e){if(!this.isRoot)return void this.root.setTransparent(t,e);let i=this.transparent!==t;if(i){this.transparent=t,this.needsUpdate=!0;for(let r of this.flavors)r!==void 0&&(r.transparent=t,r.needsUpdate=!0);for(let r of this.depthTwins)r.transparent=t,r.needsUpdate=!0}this.applyDepthPrepassPolicy();for(let r of this.flavors)r?.applyDepthPrepassPolicy();!i||e?.markNeedsUpdateRendererDirty()}syncFromRoot(){let t=this.root;this.data=t.data,this.layers=t.layers,this.lightLayer=t.lightLayer,this.ctx=t.ctx,this.name=t.name,this.lights=t.lights,this.colorNode=t.colorNode,this.positionNode=t.positionNode,this.normalNode=this.buildNormalNode(this.displacedNormalView()),this.emissiveNode=t.emissiveNode,this.aoNode=t.aoNode,this.transparent=t.transparent,this.applyDepthPrepassPolicy(),this._applyShapeBlendGraph(),GR(this),this.needsUpdate=!0}getFlavor(t,e,i,r){if(!this.isRoot)return this.root.getFlavor(t,e,i,r);let s=i?6:(t?3:0)+e;if(s+=7*((r?.resolutionLevel??0)-(r?.useChildrenColors?4:0)),s===0)return this;s-=1;let n=this.flavors[s];return n===void 0&&(n=new Xp(this.data,this.lastContext,this.allowVariableSaves,this),n.flatShading=t,n.side=e,n.wireframe=i,r&&(n.shapeBlendOptions={...r},n.defines={SHAPEBLEND:r.resolutionLevel,SHAPEBLEND_C:r.useChildrenColors?1:0},n._invalidateStructuralKey()),n.applyDepthPrepassPolicy(),this.flavors[s]=n),n}getShapeBlendBaseColor(){let t=this.layers.find(r=>r.kind==="fragment"&&r.type==="color"),e=t?.getValue("color"),i=t?.getValue("alpha");return{r:e?.r??1,g:e?.g??1,b:e?.b??1,a:i??1}}setShapeBlendResources(t){this._shapeBlendResources=t,this._applyShapeBlendGraph()}_applyShapeBlendGraph(){if(!this.shapeBlendOptions||!this._shapeBlendResources||m5===null)return;let t=m5(this._shapeBlendResources);this.positionNode=t.position,this.shapeBlendObjectNormal=t.normal,this.normalNode=this.buildNormalNode(O9(T5(t.normal))),this.castShadowPositionNode=t.position,this.shapeBlendOptions.useChildrenColors&&(this._shapeBlendColorNode=t.color,this.colorNode=At(()=>this.buildColorStack())()),this.needsUpdate=!0}lightLayerIndex(){return this.layers.findIndex(t=>t instanceof k2)}findTextureMapLayer(t){if(!t)return null;if(typeof t!="string")return XU.is(t)?this.syntheticMapLayer(t):null;let e=this.layers.find(i=>i.uuid===t);return e===void 0||e.kind!=="fragment"?null:e.type==="texture"||e.type==="video"?e:null}syntheticMapLayer(t){if(!this.isRoot)return this.root.syntheticMapLayer(t);let e=this.syntheticMapLayers.get(t);if(e!==void 0)return e;try{let i=Is.defaultData("texture"),r={...i,visible:!1,texture:{...i.texture,image:t.image,wrapping:t.wrapping??1e3,offset:t.offset??[0,0],repeat:t.repeat??[1,1],rotation:t.rotation??0,minFilter:t.minFilter??1008,magFilter:t.magFilter??1006},uvChannel:Uv.of(t.uvChannel)},s=O_t(this.layerIdGen++,`mapImage${this.layerIdGen}`,r,this.lastContext.shared);return this.syntheticMapLayers.set(t,s),s}catch(i){return console.warn("[spe] light-layer map image failed to build \u2014 skipped",i),null}}buildNormalNode(t){if(this.lights&&this.category==="physical"&&!this.wireframe){let s=this.lightLayer.lightData,n=this.findTextureMapLayer(s.normalMap);if(n!==null){let a=this.lightLayer.params.getFloat("normalScale");return At(()=>function(o,l,h){let u=j(h??Ra).toVar(),d=hr(Ic),c=o.get("texture"),p=o.has("loaded")?o.getFloat("loaded"):I(1),m=y=>{let v=st(y).toVar(),b=j(Aa(c.sample(v)).rgb.mul(2).sub(1)).toVar(),_=j($t(j(0,0,1),hr(b),p)).toVar();_.xy.mulAssign(l);let x=j($v(d)).toVar(),S=j(Xv(d)).toVar(),w=st($v(v)).toVar(),T=st(Xv(v)).toVar(),C=j(be(hr(u))).toVar(),M=j(Kr(hr(S),C)).toVar(),A=j(Kr(C,hr(x))).toVar(),P=j(hr(M).mul(w.x).add(hr(A).mul(T.x))).toVar(),O=j(hr(M).mul(w.y).add(hr(A).mul(T.y))).toVar(),D=I(Kt(Bt(hr(P),hr(P)),Bt(hr(O),hr(O)))).toVar(),N=I(pi(D.equal(0),I(0),qu(VD).mul(dq(D)))).toVar();return hr(be(hr(P).mul(_.x.mul(N)).add(hr(O).mul(_.y.mul(N))).add(C.mul(_.z))))},{uvs:f,weights:g}=TS(o);if(g!==null){let y=m(f[0]),v=m(f[1]),b=m(f[2]);return hr(be(y.mul(g.z).add(v.mul(g.x)).add(b.mul(g.y))))}return m(f[0])}(n.params,a,t))()}}let e=this.findTextureMapLayer(this.lightLayer.lightData.bumpMap),i=this.lights&&this.category!=="lambert";if(e===null||!i||this.wireframe)return t;let r=this.lightLayer.params.getFloat("bumpMapIntensity");return At(()=>function(s,n,a){let o=j(a??Ra).toVar(),l=hr(Ic),h=s.get("texture"),{uvs:u,weights:d}=TS(s);if(d!==null){let c=RE(l,hr(o),PE(h,u[0],n)),p=RE(l,hr(o),PE(h,u[1],n)),m=RE(l,hr(o),PE(h,u[2],n));return hr(be(c.mul(d.z).add(p.mul(d.x)).add(m.mul(d.y))))}return RE(l,hr(o),PE(h,u[0],n))}(e.params,r,t))()}buildVertexStack(){let t=this.layers.filter(i=>i.kind==="vertex");if(t.length===0)return this.positionNode=null,void(this.displacedObjectNormal=null);let e=function(i){let r=Lr("vec3","vDisplacedNormal");return{position:At(s=>{let n=po(Zv),a=po(pq);for(let l=0;l<i.length;l++){let h=RPt(i[l],po(Zv),a);n=l===0?h.position:po(n.add(h.position).mul(.5)),a=h.normal}let o=j(n).toVar();return r.assign(a),s.needsPreviousData?.()===!0&&UD.assign(o),o})(),normal:r}}(t.map(i=>i.params));this.positionNode=e.position,this.displacedObjectNormal=e.normal}displacedNormalView(){let t=this.root.displacedObjectNormal;return t===null?null:O9(T5(t))}maskSourceFor(t){let e=this.layers[t];if(e.kind==="fragment"&&e.isMaskEnabled)return null;let i=this.layers[t+1];return i!==void 0&&i.kind==="fragment"&&i.isMaskEnabled&&i.data.visible?i:null}runLayerBuilder(t,e,i){let r=I(1);e!==null&&(r=this.evaluateMask(e));let s={alpha:i?.alpha??t.alphaNode,isMask:t.isMaskNode,mask:r,mode:t.modeNode,noiseCompiledIn:t.noiseCompiledIn},n=Gbt(t.type)(t.params,s,this.ctx);return i?.color?{...n,color:i.color}:n}evaluateMask(t){let e=this.runLayerBuilder(t,null);return zD(e.color.mul(e.calpha))}buildColorStack(){let t=this.lightLayerIndex(),e=t===-1?0:t,i=null;for(let r=0;r<e;r++){let s=this.layers[r];if(s.kind!=="fragment")continue;if(i===null){let a=this._shapeBlendColorNode;i=pF(this.runLayerBuilder(s,this.maskSourceFor(r),a?{color:pF(a.rgb),alpha:but(a.w)}:void 0).color);continue}if(s.isMaskEnabled)continue;let n=this.runLayerBuilder(s,this.maskSourceFor(r));i=ZR(i,n.color,n.calpha,s.modeNode)}return i??tvt(i0)}setup(t){t.context.setupClearcoatNormal=()=>zvt(Ra,"NORMAL","vec3"),super.setup(t)}setupLightingModel(){let t=this.lightLayer.params.has("occlusion")?this.lightLayer.params.getBool("occlusion"):null;return function(e,i=null,r=null,s=!1){switch(e){case"physical":{let n=new $bt(r?.clearcoat===!0,r?.sheen===!0,r?.iridescence===!0,!1,!1,!1);return n.envIrradianceActive=s,n}case"lambert":return new Av(!1);case"toon":{let n=new Hbt;return n.aoOcclusionGate=i,n}default:return new Av}}(this.category,t,this.physicalLobes(),this.envNode instanceof Jv)}physicalLobes(){let t=this.lightLayer.params;return{clearcoat:t.has("clearcoat"),sheen:t.has("sheen"),iridescence:t.has("iridescence")}}setupVariants(t){if(!this.lights)return;let e=null,i=null;if(this.category==="physical"){let r=this.lightLayer.lightData,s=this.findTextureMapLayer(r.roughnessMap);s!==null&&(e=At(()=>sF(s.params,r.roughnessMapChannel??"luminance"))());let n=this.findTextureMapLayer(r.metalnessMap);n!==null&&(i=At(()=>sF(n.params,r.metalnessMapChannel??"b"))())}(function(r,s,n=null,a=null){if(r==="phong"||r==="toon")S5.assign(s.getFloat("shininess").max(1e-4)),rv.assign(s.getColor("specular"));else if(r==="physical"){let o=s.getFloat("metalness"),l=s.getFloat("roughness"),h=s.getFloat("reflectivity");if(n!==null&&(l=tb(n.mul(l))),a!==null&&(o=tb(Te(a.mul(o),I(0),I(1)))),mvt.assign(o),gq.assign(Te(l,I(.0525),I(1))),s.has("ior")){let u=s.getFloat("ior"),d=s.has("specularColor")?j(s.getColor("specularColor")):j(1),c=s.has("specularIntensity")?s.getFloat("specularIntensity"):I(1);VR.assign(u),rv.assign(ti(Rvt(VR.sub(1).div(VR.add(1))).mul(d),j(1)).mul(c)),T7.assign($t(uo(rv),uo(ko.rgb),o)),I9.assign($t(c,I(1),o))}else{let u=j(h.pow(2).mul(.16));rv.assign(u),T7.assign($t(u,uo(ko.rgb),o)),I9.assign(I(1))}if(S7.assign(uo(ko.rgb).mul(Rr(o))),s.has("clearcoat")&&(Q1t.assign(s.getFloat("clearcoat")),hq.assign(Te(s.getFloat("clearcoatRoughness"),I(.0525),I(1)))),s.has("sheen")){let u=s.has("sheenColor")?j(s.getColor("sheenColor")):j(1);Bvt.assign(u.mul(s.getFloat("sheen"))),kvt.assign(Te(s.getFloat("sheenRoughness"),I(.07),I(1)))}s.has("iridescence")&&(ovt.assign(s.getFloat("iridescence")),lvt.assign(s.getFloat("iridescenceIOR")),hvt.assign(s.getFloat("iridescenceThickness")))}})(this.category,this.lightLayer.params,e,i)}setupLighting(t){let e=this.lights===!0||this.lightsNode!==null,i=this.lights===!0?this.setupMaterialLightings(t):[],r=e?this.lightsNode??t.lightsNode:null,s=this.lights===!0?j(0):ko.rgb,n=j(0),a=j(0);if(r&&(i.length>0||r.getScope().hasLights)){let o=this.setupLightingModel()||null,l=dvt(r,o,i,this.backdropNode,this.backdropAlphaNode),h=l,u=h._value??(h._value=h.getContext());n=u.reflectedLight.directSpecular,a=u.reflectedLight.indirectSpecular,s=l}return this.emissiveNode!==null&&this.emissiveNode!==void 0&&(R9.assign(j(this.emissiveNode)),s=s.add(R9)),At(()=>this.applyPostLighting(s,n,a))()}applyPostLighting(t,e,i){let r,s=this.ctx.accumAlpha,n=this.lights===!0,a=this.lightLayerIndex(),o=a===-1?0:a+1,l=I(1);if(n){let p=a===-1?null:this.maskSourceFor(a);p!==null&&(l=this.evaluateMask(p)),r=function(m){let{outgoing:f,directSpecular:g,indirectSpecular:y,shadingAlpha:v,shadingBlend:b,mask:_,occlusion:x=null,ctx:S}=m,w=j(f).toVar();return vt(oq(mq(w,uo(ko.rgb))),()=>{let T=Te(ci(g.add(y)),I(0),I(1));S.accumAlpha.addAssign(Rr(S.accumAlpha).mul(v).mul(_).mul(T)),w.assign(ZR(uo(ko.rgb),w,v.mul(_),b)),w.mulAssign(qbt(x))}),w}({outgoing:t,directSpecular:e,indirectSpecular:i,shadingAlpha:this.lightLayer.alphaNode,shadingBlend:this.lightLayer.modeNode,mask:l,occlusion:this.lightLayer.params.has("occlusion")?this.lightLayer.params.getBool("occlusion"):null,ctx:this.ctx})}else r=j(t).toVar();let h=r,u=!1;for(let p=o;p<this.layers.length;p++){let m=this.layers[p];if(m.kind!=="fragment"||m.isMaskEnabled)continue;let f=this.runLayerBuilder(m,this.maskSourceFor(p));h=ZR(h,f.color,f.calpha,m.modeNode),u=!0}if(u&&r.assign(h),!n){let p=a===-1?null:this.maskSourceFor(a);p!==null&&(l=this.evaluateMask(p))}let d=this.lightLayer.params.has("alphaOverride")?this.lightLayer.params.getFloat("alphaOverride"):I(1),c=n?s:s.mul(l);if(ko.a.assign(c.mul(d)),ko.a.lessThanEqual(0).or(c.lessThanEqual(pvt("depthPrepassCutoff","float"))).discard(),this.dithering){let p=fq(Qa.xy),m=j(.25/255,-.25/255,.25/255),f=$t(m.mul(2),m.mul(-2),p);r.assign(r.add(f))}return r}getLayersOfType(t){return this.layers.filter(e=>e.type===t)}getLayerByUuid(t){return this.layers.find(e=>e.uuid===t)}armRainbowNoiseSpecialization(t){let e=this.root.forceRainbowNoise.has(t.uuid),i=t.data;if(t.noiseForced=e,t.noiseCompiledIn=e||_v(i.noiseStrength),t.noiseCompiledIn===!1){let r=t.uuid;t.onNoiseMismatch=s=>this.root.ensureRainbowNoiseCompiled(r,s)}}ensureRainbowNoiseCompiled(t,e){if(!this.isRoot)return this.root.ensureRainbowNoiseCompiled(t,e);let i=this.data.layers?.data(t);return i!==void 0&&i.type==="rainbow"&&(!this.forceRainbowNoise.has(t)&&!_v(i.noiseStrength)||this.getLayerByUuid(t)?.noiseCompiledIn===!1)&&(this.forceRainbowNoise.add(t),this.reset0(this.data,this.lastContext),e!==void 0&&this.getLayerByUuid(t)?.setValue("noiseStrength",e),!0)}updateByOp(t,e,i){if(this.isRoot)if(e!==void 0?this.data=e:e=this.data,this.setTransparent(lm(e,i.shared),i.scene),t.path[0]==="layers"){let r=t.path[1];if(r===void 0)return i.scene.markNeedsUpdateRendererDirty(),void this.reset0(e,i);t.type===0&&t.props.occlusion!==void 0&&i.scene.markNeedsUpdateRendererDirty();let s=this.layers.find(a=>a.uuid===r);if(!s)return;let n=e.layers.data(r);if(!n)return;this.updateLayerByOp(s,{...t,path:t.path.slice(2)},n,i)?this.reset0(e,i):GR(this)}else this.reset0(e,i);else this.root.updateByOp(t,e,i)}static hasVariableString(t){return typeof t=="string"||Array.isArray(t)&&t.some(e=>typeof e=="string")}updateLayerTextureByOp(t,e,i){if(e.path.length!==1||e.type!==0)return!0;let r=e.props,s=i.texture;if(!s)return!0;let n=t.data.texture;for(let o of Object.keys(r))if(o!=="repeat"&&o!=="offset"&&o!=="rotation"||Xp.hasVariableString(s[o])||Xp.hasVariableString(n?.[o]))return!0;if(t.type==="matcap")return"repeat"in r||"offset"in r||(t.data=i,t.setValue("rotation",(s.rotation??0)*zt.DEG2RAD),!1);let a=t.getValue("mat");if(!a)return!0;if(t.data=i,"repeat"in r){let o=s.repeat;a.repeat=[o?.[0]??1,o?.[1]??1]}if("offset"in r){let o=s.offset;a.offset=[o?.[0]??0,o?.[1]??0]}return"rotation"in r&&(a.rotation=s.rotation??0),a.updateMatrix(),!1}updateLayerByOp(t,e,i,r){if(e.path[0]==="texture")return this.updateLayerTextureByOp(t,e,i);if(e.path[0]!==void 0||e.type!==0)return!0;let s=e.props;if("type"in s||"category"in s||"visible"in s||"noiseType"in s)return r.scene.markNeedsUpdateRendererDirty(),!0;for(let n of Object.keys(s)){if(n==="isMask")return!0;if(t.type==="rainbow"&&n==="noiseStrength"&&t.noiseCompiledIn!==void 0){let u=i[n];if((t.noiseForced===!0||_v(u))!==t.noiseCompiledIn)return!0}let a=MT[t.type];if(a!==void 0&&a.includes(n))return!0;let o=Tyt[t.type];if(o!==void 0&&o.includes(n)){let u=t.getValue(n),d=s[n];if(Array.isArray(u)&&Array.isArray(d)&&u.length!==d.length)return!0}let l=i[n],h=t.data[n];if(n!=="axis"&&(typeof l=="string"||typeof h=="string")||Array.isArray(l)&&l.some(u=>typeof u=="string")||Array.isArray(h)&&h.some(u=>typeof u=="string"))return!0}t.data=i;for(let n of Object.keys(s))this.applyLayerValue(t,n,i,r.shared);return!1}applyLayerValue(t,e,i,r){let s=i;if((e==="alpha"||e==="visible"||e==="intensity")&&(uT(t,r),e!=="intensity"||t.type==="displace"))return;if(e==="alphaOverride"&&t instanceof k2)return void t.setValue("alphaOverride",Wv(s[e],r));if(!t.hasValue(e))return;let n=t.uniformKinds.get(e),a=s[e];switch(n){case"color":case"colorVec4":{let o=t.getValue(e),l=typeof a=="string"?r.color(a):C7(a,()=>o??new Dr(1,1,1,1));o&&l&&o.setRGBA(l.r,l.g,l.b,"a"in l?l.a:1);break}case"vec2":{let o=t.getValue(e);o&&Array.isArray(a)&&o.set(Number(a[0]??o.x),Number(a[1]??o.y));break}case"vec3":{let o=t.getValue(e);o&&Array.isArray(a)&&o.set(Number(a[0]??o.x),Number(a[1]??o.y),Number(a[2]??o.z));break}case"vec4array":{let o=t.getValue(e);if(o&&Array.isArray(a))for(let l=0;l<Math.min(o.length,a.length);l++){let h=a[l];o[l].set(h[0],h[1],h[2],h[3])}break}case"floatArray":{let o=t.getValue(e);if(o&&Array.isArray(a))for(let l=0;l<Math.min(o.length,a.length);l++)o[l]=Number(a[l]);break}case"axis":t.setValue(e,["x","y","z"].indexOf(String(a)));break;case"bool":t.setValue(e,!!a);break;default:(typeof a=="number"||typeof a=="boolean")&&t.setValue(e,a)}}onVariableUpdate(t,e,i){if(t[0]==="alphaOverride")return this.setTransparent(lm(this.data,i.shared),i.scene),void this.lightLayer.setValue("alphaOverride",Math.max(0,Math.min(Number(e)/100,1)));if(t[0]!=="layer")return;let r=t[1],s=t[2];if(!r||!s)return;let n=this.layers.find(h=>h.uuid===r);if(!n?.hasValue(s))return;if(a=s,n.type==="displace"?a==="intensity":a==="alpha")return s==="alpha"&&this.setTransparent(lm(this.data,i.shared),i.scene),void n.setValue(s,function(h,u,d){let c=h==="alpha"?Math.max(0,Math.min(Number(u)/100,1)):Number(u);return d?c:0}(s,e,n.data.visible));var a;let o=n.getValue(s),l=t[3];(l==="x"||l==="y"||l==="z")&&o?.isVector3||(l==="x"||l==="y")&&o?.isVector2?o[l]=Number(e):o instanceof di||n.setValue(s,e)}saveVariableLocations(t){if(!this.allowVariableSaves)return;let e=this.data.layers?.find(i=>i.data.type==="light");e&&t.shared.getVariable(e.data.alphaOverride,["material",this.uuid,"alphaOverride"]),this.data.layers?.forEach(i=>{let r=i.data;"alpha"in r&&typeof r.alpha=="string"&&t.shared.getVariable(r.alpha,["material",this.uuid,"layer",i.id,"alpha"]);let s=i.data.type==="displace"?r.displacementType==="noise"?"displace_noise":"displace_map":i.data.type,n=_ut[s];if(n)for(let a of n){let o=r;for(let l of a.path??[])l in o&&(o=o[l]);for(let l of a.nums)l in o&&t.shared.getVariable(o[l],["material",this.uuid,"layer",i.id,...a.path??[],l]);for(let l of a.vecs)Array.isArray(o[l])&&o[l].forEach((h,u)=>{t.shared.getVariable(h,["material",this.uuid,"layer",i.id,...a.path??[],l,u===0?"x":u===1?"y":"z"])})}})}clampUniformsForPreview(t,e){let i=(r,s,n)=>Math.min(Math.max(r,s),n);for(let r of this.layers)if(r.type==="displace"){let s=r.uniforms[`f${r.id}_intensity`];s.value=i(s.value,t,e)}}updateFrame(){}assetsLoaded(){if(!this.layers.every(t=>t.assetsLoaded))return!1;for(let t of this.root.syntheticMapLayers.values())if(!t.assetsLoaded)return!1;return!0}nodeMaterialDispose(){if(this.isRoot){for(let t of this.layers)t.dispose();for(let t of this.syntheticMapLayers.values())t.dispose();this.syntheticMapLayers.clear()}this.dispose();for(let t of this.flavors)t?.dispose();for(let t of this.depthTwins)t.dispose()}},Oq=class extends Xp{constructor(t,e,i){super(t,e,!1),this.isTSLSharedMaterial=!0,this.uuid=i,this.allowVariableSaves=!0,this.saveVariableLocations(e)}}});function Ul(t,e){let i=hi(t.xyz);return hi(e.add(Kr(i,Kr(i,e).add(e.mul(t.w))).mul(2)))}function Wy(t){let e=Dv(t),i=Dv(j(t.y.sub(19.1),t.z.add(33.4),t.x.add(47.2))),r=Dv(j(t.z.add(74.2),t.x.sub(124.5),t.y.add(99.4)));return j(e,i,r)}function xut(t,e){return B_t({p:t,seed:e})}function wut(t,e,i){return j(QR(hi(t.add(j(i)).mul(e))),QR(hi(t.add(j(i.add(20))).mul(e))),QR(hi(t.add(j(i.sub(30))).mul(e))))}function mF(t){return{f:(e,i=0)=>ul(t.node(e)??t.getUniform(e,i)),v3:e=>hi(t.node(e)??t.getUniform(e,null)),v4:e=>Io(t.node(e)??t.getUniform(e,null)),tex:e=>t.node(e)??t.getTexture(e,null)}}function QPt(t,e){switch(t){case"position":return function(i){let r=mF(i.registry);return At(()=>{let s=ui(),n=i.depTexture("uCurrentPosition"),a=i.depTexture("uCurrentVelocity"),o=i.depTexture("uCurrentEmissionRate"),l=Io(n.sample(s)).toVar(),h=hi(l.xyz).toVar(),u=Io(o.sample(s)).toVar(),d=ul(u.x).toVar(),c=ul(u.y).toVar(),p=ul(u.z).toVar(),m=hi(Io(r.tex("uOriginalPosition").sample(s)).xyz.mul(r.v3("uEmitterSize"))).toVar(),f=Io(a.sample(s)).toVar(),g=hi(f.xyz).toVar(),y=ul(f.w).toVar(),v=r.f("uMaxLifeTime",1),b=Si(.5,y),_=I(3).mul(b),x=g.mul(I(1).add(_)),S=g.mul(ti(r.f("uFPSRatio",1),I(5)));h.addAssign($t(S,x,b));let w=Ul(r.v4("uWorldQuaternion"),m).add(r.v3("uWorldOffset"));h.assign($t(h,w,d)),p.assign($t(p,r.f("uTime"),d));let T=Kt(v.sub(r.f("uTime").sub(p)),I(0)).div(v);return $t(at(0),at(h,T),c)})()}(e);case"velocity":return function(i){let r=mF(i.registry),s=i.features;return At(()=>{let n=ui(),a=i.depTexture("uCurrentPosition"),o=i.depTexture("uCurrentVelocity"),l=i.depTexture("uCurrentEmissionRate"),h=hi(Io(a.sample(n)).xyz).toVar(),u=hi(Io(r.tex("uOriginalPosition").sample(n)).xyz).toVar(),d=hi(Io(r.tex("uDirections").sample(n)).xyz).toVar(),c=hi(Io(o.sample(n)).xyz).toVar(),p=Io(l.sample(n)).toVar(),m=ul(p.x).toVar(),f=ul(p.y).toVar(),g=ul(Io(o.sample(n)).w).toVar(),y=I(1).sub(r.f("uRandomMassFactor").mul(function(w){return ul(w.dot(st(12.9898,78.233)).sin().mul(43758.5453).fract())}(function(w){return w.xy}(u)).mul(.5).add(.5))).toVar(),v=r.f("uSpeed",1),b=r.f("uNoiseStrength"),_=r.f("uNoiseScale"),x=r.f("uNoiseSeed");vt(f.equal(1),()=>{s.USE_CURL_NOISE&&(vt(_.greaterThan(0),()=>{c.assign(xut(hi(h.mul(_).mul(.002)),x).mul(b.add(1)).mul(.05).mul(v))}),vt(b.greaterThan(0).and(_.equal(0)),()=>{c.addAssign(xut(h,x).mul(b).mul(.05).mul(v))})),s.USE_SIMPLEX_NOISE&&(vt(_.greaterThan(0),()=>{c.assign(j(Dv(hi(h.mul(_).mul(.001))).mul(b.add(1)).mul(.1)).mul(v))}),vt(b.greaterThan(0).and(_.equal(0)),()=>{c.addAssign(j(Dv(hi(h.mul(b).mul(.001))).mul(.05)).mul(v))})),s.USE_FBM_NOISE&&(vt(_.greaterThan(0),()=>{c.assign(wut(hi(h.mul(_).mul(.001)),b.add(1),x).mul(v))}),vt(b.greaterThan(0).and(_.equal(0)),()=>{c.addAssign(wut(hi(h.mul(b).mul(.001)),b.add(1),x).mul(.1).mul(v))})),function(w,T,C,M,A){if(!w.features.USE_COLLIDER)return;let P=Kt(T.f("uBounce").mul(2),I(.01)).toVar(),O=T.f("particleSize");if(w.features.USE_SPHERE_COLLIDER){let D=T.v3("uColliderSize"),N=Ul(T.v4("uColliderQuaternionInvert"),hi(C.sub(T.v3("uColliderPos")))).toVar(),z=hi(N.div(D)).toVar(),k=ci(z).toVar();vt(k.lessThanEqual(I(1).add(O.div(ci(D)))).and(A.equal(0)),()=>{let B=z.mul(I(1).add(O.div(ci(D)))),V=be(hi(B.div(D.mul(D))));V=Ul(T.v4("uColliderQuaternion"),V),M.assign(nT(M,V).mul(P)),A.assign(1)}).Else(()=>{A.assign(0)})}if(w.features.USE_BOX_COLLIDER){let D=hi(T.v3("uColliderSize").div(2)),N=Ul(T.v4("uColliderQuaternionInvert"),hi(C.sub(T.v3("uColliderPos")))).toVar(),z=hi(ke(N).sub(D)).toVar(),k=Kt(z.x,Kt(z.y,z.z)).toVar();vt(k.lessThanEqual(O.mul(.5)).and(A.equal(0)),()=>{let B=j(0).toVar();vt(z.x.greaterThan(z.y).and(z.x.greaterThan(z.z)),()=>{B.assign(j(Xu(N.x),0,0))}).ElseIf(z.y.greaterThan(z.z),()=>{B.assign(j(0,Xu(N.y),0))}).Else(()=>{B.assign(j(0,0,Xu(N.z)))});let V=Ul(T.v4("uColliderQuaternion"),hi(B));M.assign(nT(M,V).mul(P)),A.assign(1)}).Else(()=>{A.assign(0)})}}(i,r,h,c,g),function(w,T,C,M){if(!w.features.USE_ATTRACTOR)return;let A=T.f("uForceIntensity"),P=T.f("uForceDamping");if(w.features.USE_FORCE_LOCAL_SPACE){let O,D,N=T.f("particleSize");if(w.features.USE_SPHERE_COLLIDER){let z=T.v3("uColliderSize"),k=Ul(T.v4("uColliderQuaternionInvert"),hi(C.sub(T.v3("uColliderPos"))));O=ci(hi(k.div(z))).toVar(),D=I(1)}else{let z=hi(T.v3("uColliderSize").div(2)),k=Ul(T.v4("uColliderQuaternionInvert"),hi(C.sub(T.v3("uColliderPos")))),B=hi(ke(k).sub(z));O=Kt(B.x,Kt(B.y,B.z)).toVar(),D=N}vt(O.lessThanEqual(D),()=>{let z=w.features.USE_SPHERE_COLLIDER?I(1).sub(O).mul(A):Kt(I(1).sub(D.div(O)),I(0)).mul(A),k=hi(C.sub(T.v3("uColliderPos"))),B=be(k).mul(z);M.subAssign(B),M.mulAssign(P)})}else{let O=hi(C.sub(T.v3("uColliderPos"))),D=be(O).mul(A);M.subAssign(D),M.mulAssign(P)}}(i,r,h,c),function(w,T,C,M,A,P,O){if(!w.features.USE_VORTEX)return;let D=T.f("particleSize"),N=hi(T.v3("uColliderSize").div(2)),z=Ul(T.v4("uColliderQuaternionInvert"),hi(C.sub(T.v3("uColliderPos")))).toVar(),k=hi(ke(z).sub(N)).toVar(),B=Kt(k.x,Kt(k.y,k.z)).toVar();vt(B.lessThanEqual(D),()=>{let V=T.f("uForceIntensity"),q=T.v3("uColliderPos").add(Ul(T.v4("uColliderQuaternion"),j(0))),W=hi(q.sub(C)).toVar(),H=j(0,1,.01),rt=be(Kr(H,Ul(T.v4("uColliderQuaternion"),W))).toVar(),it=ci(W.mul(V).mul(3)).toVar();M.assign(rt.mul(it).mul(.005));let ft=Ul(T.v4("uWorldQuaternion"),A);M.addAssign(ft.mul(O).mul(I(1).sub(T.f("uForceDamping"))).div(P.mul(.5)))})}(i,r,h,c,d,y,v)});let S=s.USE_NORMALS?d:r.v3("uDirectionsAxis");return c.assign($t(c,Ul(r.v4("uWorldQuaternion"),S).mul(v),m)),c.addAssign(r.v3("uGravity").div(y.mul(.5)).mul(I(1).sub(g))),at(c,g)})()}(e);case"emissionRate":return function(i){let r=mF(i.registry);return At(()=>{let s=ui(),n=i.depTexture("uCurrentEmissionRate"),a=ul(Io(r.tex("uIndex").sample(s)).x).toVar(),o=Io(n.sample(s)).toVar(),l=ul(o.y).toVar(),h=ul(o.z).toVar(),u=r.f("uLastIndexEmitted"),d=r.f("uParticlesToEmit"),c=Si(u,a),p=Si(a,u.add(d).sub(1)),m=c.mul(p);return h.assign($t(h,r.f("uTime"),m)),at(m,$t(l,I(1),m),h,1)})()}(e)}}var ul,hi,Io,B_t,Sut,Tut,fF,k_t,JPt=U(()=>{je(),DT(),ul=t=>t,hi=t=>t,Io=t=>t,B_t=At(t=>{let e=hi(t.p.add(t.seed)).toVar(),i=j(.1,0,0),r=j(0,.1,0),s=j(0,0,.1),n=Wy(hi(e.sub(i))).toVar(),a=Wy(hi(e.add(i))).toVar(),o=Wy(hi(e.sub(r))).toVar(),l=Wy(hi(e.add(r))).toVar(),h=Wy(hi(e.sub(s))).toVar(),u=Wy(hi(e.add(s))).toVar(),d=l.z.sub(o.z).sub(u.y).add(h.y),c=u.x.sub(h.x).sub(a.z).add(n.z),p=a.y.sub(n.y).sub(l.x).add(o.x);return be(j(d,c,p).mul(5))})}),tRt=U(()=>{ot(),cr(),je(),JPt(),Sut=class{constructor(){this.nodes=new Map,this.textureNodes=new Map}getUniform(t,e){let i=this.nodes.get(t);return i||(i=mt(e),this.nodes.set(t,i)),i}getTexture(t,e){let i=this.textureNodes.get(t);return i||(i=Jt(e??new di),this.textureNodes.set(t,i)),i}node(t){return this.nodes.get(t)??this.textureNodes.get(t)}adopt(t){for(let e of Object.keys(t)){let i=t[e].value;if(i instanceof di||i&&typeof i=="object"&&i.isTexture){let r=this.getTexture(e,i);r.value=i,Object.defineProperty(t,e,{configurable:!0,enumerable:!0,value:{get value(){return r.value},set value(s){r.value=s}}})}else{let r=this.getUniform(e,i);r.value=i,Object.defineProperty(t,e,{configurable:!0,enumerable:!0,value:{get value(){return r.value},set value(s){r.value=s}}})}}}},Tut=class{constructor(t,e,i,r){this.name=t,this.kind=e,this.initialTexture=i,this.currentIndex=0,this.registry=new Sut,this.depTextureNodes=new Map,this.dependencies=[],this.nodeMaterial=null,this._uniformsStore={};let s=()=>new ii(r,r,{type:Ye,minFilter:Re,magFilter:Re,wrapS:Cn,wrapT:Cn,depthBuffer:!1});this.renderTargets=[s(),s()],this.material=Object.defineProperty({},"uniforms",{get:()=>this._uniformsStore,set:n=>{this.registry.adopt(n),this._uniformsStore=n}})}get currentRenderTarget(){return this.renderTargets[this.currentIndex]}get nextRenderTarget(){return this.renderTargets[1-this.currentIndex]}advance(){this.currentIndex=1-this.currentIndex}dispose(){this.renderTargets[0].dispose(),this.renderTargets[1].dispose(),this.nodeMaterial?.dispose()}},fF=new Pr,k_t=class{constructor(t,e,i,r){this.sizeX=t,this.sizeY=e,this.renderer=i,this.features=r,this.variables=[],this._copyMaterial=null,this._copyTextureNode=Jt(new di)}addVariable(t,e,i){let r=new Tut(t,t==="uCurrentPosition"?"position":t==="uCurrentVelocity"?"velocity":"emissionRate",i,this.sizeX);return this.variables.push(r),r}setVariableDependencies(t,e){t.dependencies=e;for(let i of e)t.depTextureNodes.has(i.name)||t.depTextureNodes.set(i.name,Jt(i.currentRenderTarget.texture))}init(){if(!this._copyMaterial){let t=new Pe;t.name="WebGPUComputation.copy",t.fragmentNode=at(this._copyTextureNode),t.depthTest=!1,t.depthWrite=!1,t.blending=Wi,this._copyMaterial=t}for(let t of this.variables){this._copyTextureNode.value=t.initialTexture;for(let i of t.renderTargets)this._renderQuad(this._copyMaterial,i);let e=new Pe;e.name=`WebGPUComputation.${t.kind}`,e.fragmentNode=QPt(t.kind,{features:this.features,registry:t.registry,depTexture:i=>{let r=t.depTextureNodes.get(i);if(!r)throw new Error(`WebGPUComputationRenderer: variable "${t.name}" reads undeclared dependency "${i}"`);return r},resolution:new Y(this.sizeX,this.sizeY)}),e.depthTest=!1,e.depthWrite=!1,e.blending=Wi,e.needsUpdate=!0,t.nodeMaterial=e}}compute(){for(let t of this.variables)if(t.nodeMaterial){for(let e of t.dependencies)t.depTextureNodes.get(e.name).value=e.currentRenderTarget.texture;this._renderQuad(t.nodeMaterial,t.nextRenderTarget)}for(let t of this.variables)t.advance()}getCurrentRenderTarget(t){return t.currentRenderTarget}_renderQuad(t,e){let i=this.renderer,r=i.getRenderTarget(),s=i.getMRT();i.setMRT(null),i.setRenderTarget(e),fF.material=t,fF.render(i),i.setRenderTarget(r),i.setMRT(s)}dispose(){for(let t of this.variables)t.dispose();this._copyMaterial?.dispose()}}});function Mut(t,e){switch(t){case"linearFadeOut":return dl(I(1).sub(e));case"linearInOut":return dl(e.lessThan(.5).select(e,I(1).sub(e)));case"exponentialInOut":return dl(e.lessThan(.4).select(e.div(.4),e.greaterThan(.6).select(I(1).sub(e.sub(.6).div(.4)),I(1))));case"constant":return I(1);default:return e}}function Aut(t){return dl(t.dot(st(12.9898,78.233)).sin().mul(43758.5453).fract())}var dl,V_t,eRt=U(()=>{ot(),cr(),je(),dl=t=>t,V_t=class extends Pe{constructor(t,e){super(),this.easeOpacity="linearFadeIn",this.easeSize="linearFadeIn",this.useSizeEnd=!1,this.isColoringRandom=!1,this._uniformsStore={},this._uPosition=Jt(new di),this._uTexture=Jt(new di),this._uColor=mt(new Se(1,1,1,1)),this._uColor2=mt(new Se(1,1,1,1)),this._uSize=mt(1),this._uSizeEnd=mt(1),this._uWorldOffset=mt(new E),this._uWorldQuaternion=mt(new Se(0,0,0,1)),this._uRotation=mt(0),this._uRotationEnd=mt(0),this._center=mt(new Y(.5,.5)),this._uRandScaleFactor=mt(0),this._uRandRotationFactor=mt(0),this.context=e,this.name="WebGPUParticleMaterial",this.transparent=!0,this.depthTest=!0,this.depthWrite=!1,this.lights=!1;let i=n=>({get value(){return n.value},set value(a){n.value=a}}),r=n=>({get value(){return n.value},set value(a){((o,l)=>{if(Array.isArray(o))l.set(Number(o[0]??1),Number(o[1]??1),Number(o[2]??1),Number(o[3]??1));else if(o&&typeof o=="object"&&"r"in o){let h=o;l.set(h.r,h.g,h.b,h.a??1)}})(a,n.value)}}),s=n=>({get value(){return n.value},set value(a){a&&a.isTexture&&(n.value=a)}});this._binders={uPosition:s(this._uPosition),uTexture:s(this._uTexture),uColor:r(this._uColor),uColor2:r(this._uColor2),uSize:i(this._uSize),uSizeEnd:i(this._uSizeEnd),uWorldOffset:i(this._uWorldOffset),uWorldQuaternion:i(this._uWorldQuaternion),uRotation:i(this._uRotation),uRotationEnd:i(this._uRotationEnd),center:i(this._center),uRandScaleFactor:i(this._uRandScaleFactor),uRandRotationFactor:i(this._uRandRotationFactor)},this._uniformsStore={...this._binders},this.updateState(t),this._rebuildGraph()}get uniforms(){return this._uniformsStore}set uniforms(t){for(let e of Object.keys(t)){let i=this._binders[e];if(!i)continue;let r=t[e]?.value;Object.defineProperty(t,e,{configurable:!0,enumerable:!0,value:i}),r!==void 0&&(i.value=r)}this._uniformsStore=t}updateState(t){let e=!1;if(t.coloring!==void 0){let i=t.coloring==="random";e||(e=i!==this.isColoringRandom),this.isColoringRandom=i}if(t.color!==void 0&&(this.uniforms.uColor.value=Array.isArray(t.color)?t.color:this.context.shared.color(t.color)),t.color2!==void 0&&(this.uniforms.uColor2.value=Array.isArray(t.color2)?t.color2:this.context.shared.color(t.color2)),t.size!==void 0){this.uniforms.uSize.value=t.size[0],this.uniforms.uSizeEnd.value=t.size[1];let i=t.size[0]!==t.size[1];e||(e=i!==this.useSizeEnd),this.useSizeEnd=i}t.ease!==void 0&&t.ease!==this.easeOpacity&&(this.easeOpacity=t.ease,e=!0),t.easeSize!==void 0&&t.easeSize!==this.easeSize&&(this.easeSize=t.easeSize,e=!0),e&&this._rebuildGraph(),this.needsUpdate=!0}_rebuildGraph(){let t=Hv("particleRef","vec2"),e=this._uPosition,i=At(()=>{let s=e.sample(t).toVar(),n=dl(s.w).toVar(),a=s.xyz.sub(this._uWorldOffset);a=function(C,M){let A=C.xyz;return M.add(A.cross(A.cross(M).add(M.mul(C.w))).mul(2))}(this._uWorldQuaternion,a);let o=Hv("position","vec3"),l=I(1).sub(n),h=this.useSizeEnd?o.mul(j($t(this._uSize,this._uSizeEnd,l))):o.mul(j(dl(this._uSize).mul(Mut(this.easeSize,l)))),u=LD,d=u.element(0).xyz.length(),c=u.element(1).xyz.length(),p=Aut(t).toVar(),m=I(1).sub(dl(this._uRandScaleFactor).mul(p)),f=st(d,c).mul(m).toVar(),g=2*Math.PI,y=p.mul(dl(this._uRandRotationFactor)).mul(g),v=I(1).sub(dl(this._uRotation)).mul(g),b=I(1).sub(dl(this._uRotationEnd)).mul(g),_=$t(v.add(y),b.add(y),n).toVar(),x=this._center,S=h.xy.sub(x.sub(st(.5))).mul(f).toVar(),w=st(Xa(_).mul(S.x).sub(Bn(_).mul(S.y)),Bn(_).mul(S.x).add(Xa(_).mul(S.y))).toVar(),T=yvt.mul(at(a,1)).toVar();return T.xy.addAssign(w),mb.mul(T)}),r=At(()=>{let s=e.sample(t),n=dl(s.w).toVar();n.lessThanEqual(.005).discard();let a=I(1).sub(n),o=this.isColoringRandom?Aut(t):a,l=$t(this._uColor,this._uColor2,o).toVar(),h=Mut(this.easeOpacity,a).toVar(),u=this._uTexture.sample(ui()).toVar();return at(u.rgb.mul(l.rgb),dl(l.a).mul(u.a).mul(h))});this.vertexNode=i(),this.colorNode=r(),this.needsUpdate=!0}nodeMaterialDispose(){this.dispose()}}}),iRt=U(()=>{Dyt(),tRt(),eRt(),FW={createComputation:(t,e,i,r)=>new k_t(t,e,i,r),createMaterial:(t,e)=>new V_t(t,e)}});function z_t(t,e){return(i,r,s,n)=>{let a=s.mod(e).add(i.add(.5).div(t)).div(e),o=de(s.div(e)).add(r.add(.5).div(t)).div(e);return nv(n.sample(st(a,o)))}}function Cut(t){let e=Vi(lr(t.x).mul(65535).add(.5)),i=e.bitAnd(Vi(255)).toFloat().mul(.00392156862),r=e.shiftRight(Vi(8)).bitAnd(Vi(255)).toFloat().mul(.00392156862);return at(r,i,t.y,t.z)}function L_t(t){let{levelShiftX:e,scale:i,originOffset:r}=function(f){switch(f){case 5:return{levelShiftX:[4,6,12,24,48,96,192],scale:8*V2,originOffset:16};case 7:return{levelShiftX:[4,6,12,24,48,96,192,384,768,1536],scale:2*V2,originOffset:64};case 8:return{levelShiftX:[4,8,16,32,64,128,256,512,1024,2048,4096],scale:V2,originOffset:128};default:return{levelShiftX:[4,8,16,32,64,128,256,512],scale:4*V2,originOffset:32}}}(t.resolutionLevel),s=t.pyramidLevelSizes.length,n=s%2==0?s-3:s-2,a=s%2==0,o=Math.pow(2,t.resolutionLevel),l=t.pyramidLevelSizes[s-1]/o,h=z_t(o,l),u=t.pyramid1Size.width,d=t.pyramid1Size.height,c=t.pyramid2Size.width,p=t.pyramid2Size.height,m=aT(Iq.map(([f,g,y])=>new E(f,g,y)));return f=>{let g=j(0).toVar(),y=j(0,0,1).toVar(),v=at(0).toVar(),b=f.toVar(),_=de(b.div(3)).toVar(),x=(A,P)=>st(lr(A.x).add(P).add(.5).div(u),lr(A.y).add(.5).div(d)),S=(A,P)=>st(lr(A.x).add(P).add(.5).div(c),lr(A.y).add(.5).div(p)),w=u-2,T=c-1,C=st(0,0).toVar(),M=nv(t.pyramid2.sample(S(JR(C),T))).toVar();return vt(_.lessThan(lr(M.x)),()=>{let A=I(0).toVar(),P=K=>{let lt=nv(M.add(at(A))).toVar(),_t=at(ec(lt.yzw),A),xt=nv(at(at(_).greaterThanEqual(_t)).mul(at(at(_).lessThan(lt)))).toVar();C.mulAssign(2),C.addAssign(st(0,1).mul(lr(xt.x)).add(st(1,1).mul(lr(xt.y))).add(st(1,0).mul(lr(xt.z)))),A.assign(xt.dot(_t)),K?.()};for(let K=0;K<n;){let lt=e[K];P(()=>{T-=lt,M.assign(t.pyramid1.sample(x(JR(C),w)))}),K++;let _t=e[K];P(()=>{w-=_t,M.assign(t.pyramid2.sample(S(JR(C),T)))}),K++}a&&P(null);let O=lr(C.x).mod(o).toVar(),D=lr(C.y).mod(o).toVar(),N=de(lr(C.x).div(o)).add(de(lr(C.y).div(o)).mul(l)).toVar(),z=b.sub(A.mul(3)).mul(.0625).add(.03125),k=h(O,D,N,t.voxel).toVar(),B=lr(k.w).add(.5).mul(.00390625),V=lr(nv(t.triTable.sample(st(z,B))).x).mul(2).toInt().toVar(),q=j(O,D,N).add(ec(m.element(V))).toVar(),W=j(O,D,N).add(ec(m.element(V.add(1)))).toVar(),H=h(lr(q.x),lr(q.y),lr(q.z),t.potential).toVar(),rt=h(lr(W.x),lr(W.y),lr(W.z),t.potential).toVar(),it=lr(H.x).div(lr(H.x).sub(lr(rt.x)));v.assign($t(Cut(ec(H.yzw)),Cut(ec(rt.yzw)),it)),g.assign(q.add(W.sub(q).mul(it)).sub(j(r)).mul(i));let ft=h(lr(q.x),lr(q.y),lr(q.z),t.voxel),dt=h(lr(W.x),lr(W.y),lr(W.z),t.voxel);y.assign(be($t(ec(ft.xyz),ec(dt.xyz),it)))}),{position:g,normal:y,color:v}}}function Eut(t,e){t.needsPreviousData?.()===!0&&UD.assign(e)}function rRt(t){if(t.cached)return function(s){let n=()=>s.drawIndex?s.drawIndex.element(SS):SS;return{position:At(a=>{let o=ec(s.positions.element(n()).xyz).toVar();return Eut(a,o),o})(),normal:N9(s.normals.element(n()).xyz),color:N9(s.colors.element(n()))}}(t.cached);let e=L_t(t),i=Lr("vec3","vShapeBlendNormal"),r=Lr("vec4","vShapeBlendColor");return{position:At(s=>{let{position:n,normal:a,color:o}=e(SS.toFloat());return i.assign(a),r.assign(o),Eut(s,n),n})(),normal:i,color:r}}var lr,JR,ec,nv,V2,Iq,Nq=U(()=>{ot(),je(),lr=t=>t,JR=t=>t,ec=t=>t,nv=t=>t,V2=2,Iq=[[0,0,0],[1,0,0],[1,0,0],[1,1,0],[0,1,0],[1,1,0],[0,0,0],[0,1,0],[0,0,1],[1,0,1],[1,0,1],[1,1,1],[0,1,1],[1,1,1],[0,0,1],[0,1,1],[0,0,0],[0,0,1],[1,0,0],[1,0,1],[1,1,0],[1,1,1],[0,1,0],[0,1,1]]});function F_t(t,e){let i=le(t.xyz);return le(e.add(i.cross(i.cross(e).add(e.mul(nt(t.w)))).mul(2)))}function U_t(t,e,i,r){let s=Te(t,-1,1),n=t.sub(s).mul(2).add(1),a=Te(I(.5).add(s.mul(.5).mul(e.sub(s.mul(n).mul(i))).div(r)),0,1);return nt($t(e,s.mul(n).mul(i),a).sub(s.mul(r).mul(a).mul(I(1).sub(a))))}function j_t(t,e,i,r,s){let n=I(0).toVar(),a=nt(i.y),o=nt(i.z),l=nt(i.w),h=vt(t.lessThan(.5),()=>{n.assign(ci(e).sub(a))}).ElseIf(t.lessThan(1.5),()=>{let d=j(a,o,l),c=ci(e.div(d)),p=ci(e.div(d.mul(d)));n.assign(c.mul(c.sub(1)).div(p))}).ElseIf(t.lessThan(2.5),()=>{let d=j(a,o,l),c=ke(e).sub(d).toVar();n.assign(ci(Kt(c,j(0))).add(ti(Kt(nt(c.x),Kt(nt(c.y),nt(c.z))),0)))}).ElseIf(t.lessThan(3.5),()=>{let d=ke(st(ci(t4(e.xz)),nt(e.y))).sub(st(o,a)).toVar();n.assign(ti(Kt(nt(d.x),nt(d.y)),0).add(ci(Kt(d,st(0)))))}).ElseIf(t.lessThan(4.5),()=>{let d=a,c=o,p=l,m=st(ci(t4(e.xz)),nt(e.y)).toVar(),f=st(p,d),g=st(p.sub(c),d.mul(2)),y=st(nt(m.x).sub(ti(nt(m.x),nt(m.y).lessThan(0).select(c,p))),ke(nt(m.y)).sub(d)).toVar(),v=m.sub(f).add(g.mul(Te(Bt(f.sub(m),g).div(Bt(g,g)),0,1))).toVar(),b=nt(v.x).lessThan(0).and(nt(y.y).lessThan(0)).select(I(-1),I(1));n.assign(b.mul(xl(ti(Bt(y,y),Bt(v,v)))))}).ElseIf(t.lessThan(5.5),()=>{let d=st(ci(t4(e.xy)).sub(a),nt(e.z));n.assign(ci(d).sub(o))}),u=()=>{let d=ke(nt(e.x)).toVar(),c=st(a,o),p=l,m=nt(r.w),f=nt(c.y).mul(d).greaterThan(nt(c.x).mul(nt(e.y))).select(Bt(st(d,nt(e.y)),c),ci(st(d,nt(e.y)))),g=j(d,nt(e.y),nt(e.z));n.assign(xl(Bt(g,g).add(p.mul(p)).sub(p.mul(f).mul(2))).sub(m))};return s?h.ElseIf(t.lessThan(6.5),u).Else(()=>{n.assign(s(e,i,r))}):h.Else(u),n}function P7(t,e=!0){let i=t.spatialDivisions,r=t.spatialn;return(s,n)=>{let a=e?at(0).toVar():at(0),o=I(1e3).toVar(),l=e?I(0).toVar():I(0),h=e?I(0).toVar():I(0),u=nt(n.y).add(nt(n.z).mul(i)).add(.5).div(i*i),d=(m,f)=>{let g=f.toVar();Qi(G1,({i:y})=>{vt(g.lessThan(1),()=>{ea()}),g.mulAssign(.5),vt(Di(g).greaterThanEqual(.5),()=>{let v=I(y).add(m).add(.5).mul(1/k5),b=t.shapeRow(v,0).toVar(),_=t.shapeRow(v,1).toVar(),x=t.shapeRow(v,2).toVar(),S=t.shapeRow(v,3).toVar(),w=F_t(Ta(_),le(s.sub(le(b.xyz)))).div(nt(S.z)).toVar(),T=j_t(nt(x.x),le(w),Ta(x),Ta(S),t.meshSdf).sub(nt(S.y)).mul(nt(S.z)).toVar(),C=nt(S.x).toVar(),M=nt(b.w);if(o.assign(U_t(M,o,T,C)),e){let A=Si(-1.5,M).mul(Si(M,-.5)),P=Ji(h,0,T.negate()),O=$t(I(1),P,A);a.mulAssign(O),l.mulAssign(O),h.assign(Kt(h,C)),C.addAssign(t.colorKBump);let D=t.shapeRow(v,4).toVar(),N=Ji(C,0,T).mul(nt(D.a).greaterThanEqual(0).toFloat()).toVar();l.addAssign(N),a.addAssign(D.mul(N))}})})},c=m=>{let f=m.mul(4*G1).toVar(),g=Ta(t.spatialTex.sample(st(nt(n.x).mul(r).add(m).add(.5).div(r*i),u))).toVar();d(nt(f),nt(g.x)),d(nt(f.add(G1)),nt(g.y)),d(nt(f.add(2*G1)),nt(g.z)),d(nt(f.add(3*G1)),nt(g.w))};r===1?c(I(0)):Qi(r,({i:m})=>{c(I(m).toVar())}),e&&a.divAssign(l);let p=$t(o,I(0),Si(1e20,o)).toVar();return{sdf:nt(p),color:Ta(a),colorDivisor:nt(l)}}}function Put(t){let e=t.resolution,i=e-1,r=t.colorResolution,s=t.capacity,n=e/4,a=n-1,o=mt(t.bboxHalf),l=mt(t.bboxOffset),h=mt(1e30),u=mt(new E(0,0,0)),d=mt(new E(n,n,n)),c=t.env.spatialDivisions,p=I(t.buildSeq).mul(0),m=t.sparseStorage??null,f=m?m.poolBricks:0,g=m?Math.ceil(f/4096):0,y=m?.meshlet??null,v=y?y.drawIndex:null,b=y?Math.floor(s/24):0,_=y?y.vertexBlocks:0,x=(L,J,yt,ht)=>{let Ot=new Yg(L,J,yt);return Ot.format=Ka,Ot.type=Ye,Ot.minFilter=Re,Ot.magFilter=Re,Ot.name=ht,Ot},S=m?x(256,256,4*Math.max(g,1),"SplineShapeBlend.ultraSdfPool"):t.reuseTextures?.sdfTexture??x(e,e,e,"SplineShapeBlend.ultraSdf");S.format=Ka,S.type=Ye,S.minFilter=Re,S.magFilter=Re;let w=t.reuseTextures?.colorTexture??new Yg(r,r,r);w.name="SplineShapeBlend.ultraColor";let T=t.reuseTextures?.coarseTexture??new Yg(n,n,n);T.format=Ka,T.type=Ye,T.minFilter=Re,T.magFilter=Re,T.name="SplineShapeBlend.ultraCoarse";let C=Zr(8,"uint").toAtomic(),M=(L=0)=>C.element(L),A=m?Zr(y?12:4,"int").toAtomic():null,P=L=>A.element(L),O=m?Zr(Math.max(f,1),"float"):null,D=n*n*n,N=m?Zr(D*(y?4:1),"float"):null,z=L=>ct(nt(L.x).add(nt(L.y).mul(n)).add(nt(L.z).mul(n*n))),k=L=>N.element(z(L)),B=L=>N.element(z(L).add(ct(D))),V=L=>N.element(z(L).add(ct(2*D))),q=L=>N.element(z(L).add(ct(3*D))),W=L=>N.element(L.add(ct(3*D))),H=m?Zr(Math.max(f,1),"float"):null,rt=y?Zr(3*Math.max(b,1),"float"):null,it=L=>rt.element(L),ft=L=>it(ct(L)),dt=L=>it(ct(L.add(b))),K=L=>it(L.add(ct(2*b))),lt=y?Zr(Math.max(_,1),"float"):null,_t=L=>lt.element(L),xt=y?Zr(24*Math.max(b,1),"uint"):null,wt=L=>xt.element(L),gt=y?mt(0):null,Dt=y?mt(new bt):null,Lt=y?mt(2):null,It=aT(Array.from(t.numTrisTable)),kt=aT(Iq.map(([L,J,yt])=>new E(L,J,yt))),Nt=P7(t.env,!1),Gt=P7(t.env),qt=(L,J)=>le(L.div(J).mul(2).sub(1)),Ct=(L,J)=>le(L.div(J).mul(c-1).floor()),ne=At(()=>{for(let L=0;L<8;L++)Oo(M(L),Vi(0))})(),Ut=At(()=>{vt(ct(Rn).greaterThanEqual(ct(s)),()=>{fr()}),t.buffers.positions.element(ct(Rn)).assign(at(0))})(),Yt=y?At(()=>{vt(ct(Rn).greaterThanEqual(ct(s)),()=>{fr()}),v.element(ct(Rn)).assign(Vi(p))})():null,Zt=Sc(T),$=L=>nt(Ta(Zt.load(Kn(Te(L,j(0),j(a))))).x),ie=L=>nt(k(le(Te(L,j(0),j(a))))),Ce=(L,J)=>{let yt=Kt(L,0),ht=de(yt.div(4096)),Ot=yt.sub(ht.mul(4096)),he=de(Ot.div(64)),ye=Ot.sub(he.mul(64));return le(j(ye,he,ht).mul(4).add(J))},Be=At(()=>{let L=j(ho).add(u).toVar();vt(nt(L.x).greaterThan(a).or(nt(L.y).greaterThan(a)).or(nt(L.z).greaterThan(a)),()=>{fr()});let J=le(L.mul(4).add(j(1.5))),yt=(ht=>{let Ot=I(1e3).toVar();return Qi(k5,({i:he})=>{vt(I(he).greaterThanEqual(nt(t.npart)),()=>{ea()});let ye=I(he).add(.5).mul(1/k5),Wt=t.env.shapeRow(ye,0).toVar(),Mt=t.env.shapeRow(ye,1).toVar(),ee=t.env.shapeRow(ye,2).toVar(),We=t.env.shapeRow(ye,3).toVar(),es=F_t(Ta(Mt),le(ht.sub(le(Wt.xyz)))).div(nt(We.z)).toVar(),Vr=j_t(nt(ee.x),le(es),Ta(ee),Ta(We),t.env.meshSdf).sub(nt(We.y)).mul(nt(We.z)).toVar();Ot.assign(U_t(nt(Wt.w),Ot,Vr,nt(We.x)))}),nt(Ot)})(qt(J,i));Hp(T,Kn(L),at(nt(yt.add(p)),0,0,0)).toStack()})(),te=L=>{vt(nt(L.x).greaterThan(a).or(nt(L.y).greaterThan(a)).or(nt(L.z).greaterThan(a)),()=>{fr()})},ni=m?At(()=>{let L=j(ho).toVar();te(le(L)),k(le(L)).assign(nt(I(-1).add(p))),y&&(B(le(L)).assign(nt(I(-1).add(p))),V(le(L)).assign(nt(I(-1).add(p))))})():null,bi=m?At(()=>{let L=j(ho).add(u).toVar();te(le(L));let J=$(le(L)).toVar(),yt=ie(le(L)).toVar();vt(ke(J).greaterThan(h).and(yt.greaterThan(-.5)),()=>{let ht=hl(P(1),ct(1)).toVar();O.element(ht).assign(yt),k(le(L)).assign(nt(I(-1).add(p)))})})():null,Zs=m?At(()=>{let L=j(ho).add(u).toVar();te(le(L));let J=$(le(L)).toVar(),yt=ie(le(L)).toVar();vt(ke(J).lessThanEqual(h).and(yt.lessThan(-.5)),()=>{let ht=I(-1).toVar(),Ot=kR(P(1),ct(1)).toVar();vt(Ot.greaterThanEqual(1),()=>{ht.assign(nt(O.element(Ot.sub(1))))}).Else(()=>{hl(P(1),ct(1));let he=hl(P(0),ct(1)).toVar();vt(he.lessThan(ct(f)),()=>{ht.assign(he.toFloat())}).Else(()=>{Oo(P(2),ct(1))})}),vt(ht.greaterThan(-.5),()=>{H.element(ct(ht)).assign((he=>nt(nt(he.x).add(nt(he.y).mul(256)).add(nt(he.z).mul(65536))))(le(L))),k(le(L)).assign(nt(ht.add(p)))})})})():null,Hi=m?At(()=>{let L=yg(P(0)).toVar(),J=yg(P(2)).toVar();if(Oo(M(1),Vi(L)),Oo(M(2),Vi(J)),Oo(P(2),ct(0)),y){let yt=yg(P(3)).toVar(),ht=yg(P(5)).toVar();Oo(M(4),Vi(yt)),Oo(M(5),Vi(ht)),Oo(P(5),ct(0));let Ot=yg(P(6)).toVar(),he=yg(P(8)).toVar();Oo(M(6),Vi(Ot)),Oo(M(7),Vi(he)),Oo(P(8),ct(0))}})():null,ai=y?At(()=>{let L=j(ho).toVar();vt(nt(L.x).greaterThanEqual(nt(d.x)).or(nt(L.y).greaterThanEqual(nt(d.y))).or(nt(L.z).greaterThanEqual(nt(d.z))),()=>{fr()});let J=le(L.add(u)).toVar();te(le(J));let yt=nt(V(le(J))).toVar();vt(yt.greaterThan(-.5),()=>{let Ot=hl(P(7),ct(1)).toVar();_t(Ot).assign(yt),V(le(J)).assign(nt(I(-1).add(p)))});let ht=nt(B(le(J))).toVar();vt(ht.lessThan(-.5),()=>{fr()}),B(le(J)).assign(nt(I(-1).add(p))),Qi(48,()=>{vt(ht.lessThan(-.5),()=>{ea()});let Ot=hl(P(4),ct(1)).toVar();K(Ot).assign(ht),ht.assign(nt(ft(ht)))})})():null,Fr=y?At(()=>{let L=j(ho).add(u).toVar();te(le(L));let J=I(0).toVar();vt(ie(le(L)).greaterThan(-.5),()=>{let yt=le(L.mul(4)).toVar(),ht=sh.map(([Wt,Mt,ee])=>Br(le(j(nt(yt.x).add(4*Wt),nt(yt.y).add(4*Mt),nt(yt.z).add(4*ee)))).toVar()),Ot=ht[0];for(let Wt=1;Wt<8;Wt++)Ot=Ot.add(ht[Wt]);let he=be(Ot).toVar(),ye=Bt(ht[0],he);for(let Wt=1;Wt<8;Wt++)ye=ti(ye,Bt(ht[Wt],he));vt(nt(ye).greaterThan(nt(Lt)),()=>{J.assign(I(1))})}),q(le(L)).assign(nt(J.add(p)))})():null,ts=Math.min(4096,Math.max(f,1)),Ur=()=>{let L=j(ho).toVar(),J=de(nt(L.x).mul(.25)).toVar(),yt=de(nt(L.y).mul(.25)).toVar(),ht=yt.mul(ts).add(J).toVar(),Ot=j(nt(L.x).sub(J.mul(4)),nt(L.y).sub(yt.mul(4)),nt(L.z)).toVar();return{slot:nt(ht),local:le(Ot)}},Fi=L=>(J=>{let yt=de(J.div(65536)),ht=J.sub(yt.mul(65536)),Ot=de(ht.div(256)),he=ht.sub(Ot.mul(256));return le(j(he,Ot,yt))})(nt(H.element(ct(L)))),Ti=m?At(()=>{let L=j(ho).add(u.mul(4)).toVar(),J=le(L.mul(.25).floor()).toVar(),yt=ie(J).toVar();vt(yt.lessThan(-.5),()=>{fr()});let{sdf:ht}=Nt(qt(le(L),i),Ct(le(L),i));Hp(S,Kn(Ce(yt,le(L.sub(J.mul(4))))),at(nt(ht.add(p)),0,0,0)).toStack()})():null,Qs=m?At(()=>{let{slot:L,local:J}=Ur();vt(L.greaterThanEqual(f),()=>{fr()});let yt=Fi(L).toVar();vt(ie(le(yt)).notEqual(L),()=>{fr()});let ht=le(yt.mul(4).add(J)).toVar(),{sdf:Ot}=Nt(qt(le(ht),i),Ct(le(ht),i));Hp(S,Kn(Ce(L,le(J))),at(nt(Ot.add(p)),0,0,0)).toStack()})():At(()=>{let L=j(ho).add(u.mul(4)).toVar(),J=$(le(L.mul(.25).floor())).toVar();vt(ke(J).greaterThan(h),()=>{Hp(S,Kn(L),at(nt(J.add(p)),0,0,0)).toStack(),fr()});let{sdf:yt}=Nt(qt(le(L),i),Ct(le(L),i));Hp(S,Kn(L),at(nt(yt.add(p)),0,0,0)).toStack()})(),ms=At(()=>{let L=j(ho).add(u.mul(2)).toVar();vt(nt(L.x).greaterThan(r-1).or(nt(L.y).greaterThan(r-1)).or(nt(L.z).greaterThan(r-1)),()=>{fr()}),vt(ke($(le(L.mul(.5).floor()))).greaterThan(h),()=>{fr()});let{color:J,colorDivisor:yt}=Gt(qt(le(L),r-1),Ct(le(L),r-1)),ht=Ta(yt.greaterThan(0).select(J,at(0)));Hp(w,Kn(L),Te(Ta(ht.add(p)),at(0),at(1))).toStack()})(),vr=Sc(S),ir=m?(L,J,yt)=>{let ht=Te(j(L,J,yt),j(0),j(i)),Ot=ht.mul(.25).floor(),he=ie(le(Ot)),ye=nt(Ta(vr.load(Kn(Ce(he,le(ht.sub(Ot.mul(4))))))).x);return nt(he.lessThan(-.5).select($(le(Ot)),ye))}:(L,J,yt)=>nt(Ta(vr.load(Kn(Te(j(L,J,yt),j(0),j(i))))).x),Br=L=>{let J=nt(L.x),yt=nt(L.y),ht=nt(L.z),Ot=ir(J.add(1),yt,ht).sub(ir(J.sub(1),yt,ht)),he=ir(J,yt.add(1),ht).sub(ir(J,yt.sub(1),ht)),ye=ir(J,yt,ht.add(1)).sub(ir(J,yt,ht.sub(1))),Wt=Ot.equal(0).and(he.equal(0)).and(ye.equal(0));return le(Wt.select(j(.199,.299,.399),be(j(Ot,he,ye))))},Zh=(L,J,yt)=>{let ht=((ye,Wt,Mt)=>{let ee=(We,es,Vr,br)=>ir(ye.add(We),Wt.add(es),Mt.add(Vr)).lessThan(0).toFloat().mul(br);return ee(0,0,0,1).add(ee(1,0,0,2)).add(ee(0,1,0,8)).add(ee(1,1,0,4)).add(ee(0,0,1,16)).add(ee(1,0,1,32)).add(ee(0,1,1,128)).add(ee(1,1,1,64))})(L,J,yt).toVar(),Ot=nt(It.element(ct(ht))).toVar();vt(Ot.lessThan(.5),()=>{fr()});let he=hl(M(),Vi(Ot)).toVar();vt(I(he).add(Ot).mul(3).lessThanEqual(s),()=>{let ye=nt(ht).add(.5).mul(.00390625);Qi(5,({i:Wt})=>{vt(I(Wt).greaterThanEqual(Ot),()=>{ea()});let Mt=I(Wt).toVar();Qi(3,({i:ee})=>{let We=I(ee).toVar();((es,Vr,br,ls,zn,Ho)=>{let Ln=zn.mul(.0625).add(.03125),is=nt(Ta(t.triTable.sample(st(Ln,ls))).x).mul(2).toInt().toVar(),fs=j(es,Vr,br).add(le(kt.element(is))).toVar(),Sr=j(es,Vr,br).add(le(kt.element(is.add(1)))).toVar(),Js=ir(nt(fs.x),nt(fs.y),nt(fs.z)).toVar(),oa=ir(nt(Sr.x),nt(Sr.y),nt(Sr.z)).toVar(),pr=Js.div(Js.sub(oa)).toVar(),Ls=fs.add(Sr.sub(fs).mul(pr)).toVar(),fn=le(Ls.div(i).mul(2).sub(1)).toVar(),la=fn.mul(o).add(j(l)),jr=be($t(Br(le(fs)),Br(le(Sr)),pr)),gn=fn.add(1).mul(.5),Gr=Ta(Sc(w,gn,ct(0))),tn=Ho.toVar();t.buffers.positions.element(tn).assign(at(la,1)),t.buffers.normals.element(tn).assign(at(jr,0)),t.buffers.colors.element(tn).assign(Gr)})(L,J,yt,ye,Mt.mul(3).add(We),ct(he).add(ct(Mt)).mul(3).add(ct(We)))})})})},Qh=m?At(()=>{let{slot:L,local:J}=Ur();vt(L.greaterThanEqual(f),()=>{fr()});let yt=Fi(L).toVar();vt(ie(le(yt)).notEqual(L),()=>{fr()});let ht=nt(yt.x).mul(4).add(nt(J.x)).toVar(),Ot=nt(yt.y).mul(4).add(nt(J.y)).toVar(),he=nt(yt.z).mul(4).add(nt(J.z)).toVar();vt(ht.greaterThanEqual(i).or(Ot.greaterThanEqual(i)).or(he.greaterThanEqual(i)),()=>{fr()}),Zh(ht,Ot,he)})():At(()=>{let L=nt(j(ho).x).toVar(),J=nt(j(ho).y).toVar(),yt=nt(j(ho).z).toVar();vt(L.greaterThanEqual(i).or(J.greaterThanEqual(i)).or(yt.greaterThanEqual(i)),()=>{fr()}),vt(ke($(le(j(L,J,yt).mul(.25).floor()))).greaterThan(h),()=>{fr()}),Zh(L,J,yt)})(),Om=()=>{let L=j(UR).toVar(),J=nt(L.y).mul(ts).add(nt(L.x)).toVar(),yt=j(0).toVar(),ht=I(0).toVar();return vt(J.lessThan(f),()=>{yt.assign(Fi(J)),vt(ie(le(yt)).equal(J),()=>{ht.assign(I(1))})}),{brick:le(yt),valid:nt(ht)}},rr=()=>{let L=j(UR).add(u).toVar(),J=I(0).toVar();return vt(nt(L.x).lessThanEqual(a).and(nt(L.y).lessThanEqual(a)).and(nt(L.z).lessThanEqual(a)),()=>{vt(ie(le(L)).greaterThan(-.5),()=>{J.assign(I(1))})}),{brick:le(L),valid:nt(J)}},sh=[[0,0,0],[1,0,0],[0,1,0],[1,1,0],[0,0,1],[1,0,1],[0,1,1],[1,1,1]],b0=[[0,1],[2,3],[4,5],[6,7],[0,2],[1,3],[4,6],[5,7],[0,4],[1,5],[2,6],[3,7]],Im=L=>At(()=>{let J=Lp("float",64),yt=Lp("float",1),ht=j(zR).toVar(),Ot=ct(nt(ht.x).add(nt(ht.y).mul(4)).add(nt(ht.z).mul(16))).toVar(),{brick:he,valid:ye}=L(),Wt=nt(q(le(he))).toVar(),Mt=I(1).add(Wt).toVar(),ee=Wt.greaterThan(.5),We=ee.and(nt(ht.x).lessThan(2).and(nt(ht.y).lessThan(2)).and(nt(ht.z).lessThan(2))).or(ee.not()),es=nt(he.x).mul(4).add(nt(ht.x).mul(Mt)).toVar(),Vr=nt(he.y).mul(4).add(nt(ht.y).mul(Mt)).toVar(),br=nt(he.z).mul(4).add(nt(ht.z).mul(Mt)).toVar(),ls=sh.map(([Sr,Js,oa])=>ir(es.add(Mt.mul(Sr)),Vr.add(Mt.mul(Js)),br.add(Mt.mul(oa))).toVar()),zn=ls[0].lessThan(0).toFloat();for(let Sr=1;Sr<8;Sr++)zn=zn.add(ls[Sr].lessThan(0).toFloat());let Ho=zn.toVar(),Ln=I(0).toVar();vt(ye.greaterThan(.5).and(We).and(es.add(Mt).lessThanEqual(i)).and(Vr.add(Mt).lessThanEqual(i)).and(br.add(Mt).lessThanEqual(i)).and(Ho.greaterThan(.5)).and(Ho.lessThan(7.5)),()=>{Ln.assign(I(1))}),J.element(Ot).assign(Ln.add(p)),z1(),vt(Ot.equal(ct(0)).and(ye.greaterThan(.5)),()=>{let Sr=I(0).toVar();Qi(64,({i:oa})=>{Sr.addAssign(nt(J.element(oa)))});let Js=I(-1).toVar();vt(Sr.greaterThan(.5),()=>{let oa=kR(P(7),ct(1)).toVar();vt(oa.greaterThanEqual(1),()=>{Js.assign(nt(_t(oa.sub(1))))}).Else(()=>{hl(P(7),ct(1));let pr=hl(P(6),ct(1)).toVar();vt(pr.lessThan(ct(_)),()=>{Js.assign(pr.toFloat())}).Else(()=>{Oo(P(8),ct(1))})}),vt(Js.greaterThan(-.5),()=>{V(le(he)).assign(nt(Js.add(p)))})}),yt.element(ct(0)).assign(Js)}),z1();let is=nt(yt.element(ct(0))).toVar(),fs=Ln.greaterThan(.5).or(ee.and(We).and(ye.greaterThan(.5)).and(es.add(Mt).lessThanEqual(i)).and(Vr.add(Mt).lessThanEqual(i)).and(br.add(Mt).lessThanEqual(i)));vt(fs.and(is.greaterThan(-.5)),()=>{let Sr=j(0).toVar(),Js=I(0).toVar();for(let[Tl,Jh]of b0)vt(ls[Tl].lessThan(0).toFloat().notEqual(ls[Jh].lessThan(0).toFloat()),()=>{let UT=ls[Tl].div(ls[Tl].sub(ls[Jh])),[_b,jT,GT]=sh[Tl],[eO,p2t,m2t]=sh[Jh];Sr.addAssign(j(_b,jT,GT).add(j(eO-_b,p2t-jT,m2t-GT).mul(UT)).mul(Mt)),Js.addAssign(1)});let oa=le(Sr.div(Kt(Js,1))).toVar();vt(Js.lessThan(.5),()=>{oa.assign(j(Mt.mul(.5)))});let pr=j(es,Vr,br).add(oa).toVar(),Ls=le(pr.div(i).mul(2).sub(1)).toVar(),fn=Ls.mul(o).add(j(l)),la=j(0).toVar(),jr=le(oa.div(Mt)).toVar();for(let Tl=0;Tl<8;Tl++){let[Jh,UT,_b]=sh[Tl],jT=Jh?nt(jr.x):I(1).sub(nt(jr.x)),GT=UT?nt(jr.y):I(1).sub(nt(jr.y)),eO=_b?nt(jr.z):I(1).sub(nt(jr.z));la.addAssign(Br(le(j(es.add(Mt.mul(Jh)),Vr.add(Mt.mul(UT)),br.add(Mt.mul(_b))))).mul(jT.mul(GT).mul(eO)))}let gn=be(la),Gr=Ls.add(1).mul(.5),tn=Ta(Sc(w,Gr,ct(0))),yn=ct(ee.select(nt(ht.x).add(nt(ht.y).mul(2)).add(nt(ht.z).mul(4)),I(Ot))).toVar(),Da=ct(is.mul(64)).add(yn).toVar();t.buffers.positions.element(Da).assign(at(fn,1)),t.buffers.normals.element(Da).assign(at(gn,0)),t.buffers.colors.element(Da).assign(tn)})})(),Nm=y?Im(Om):null,nh=y?Im(rr):null,yi=L=>At(()=>{let J=Lp("float",64),yt=Lp("float",64),ht=Lp("float",48),Ot=j(zR).toVar(),he=ct(nt(Ot.x).add(nt(Ot.y).mul(4)).add(nt(Ot.z).mul(16))).toVar(),{brick:ye,valid:Wt}=L(),Mt=nt(ye.x).mul(4).add(nt(Ot.x)).toVar(),ee=nt(ye.y).mul(4).add(nt(Ot.y)).toVar(),We=nt(ye.z).mul(4).add(nt(Ot.z)).toVar(),es=ir(Mt,ee,We).lessThan(0).toFloat().toVar(),Vr=(pr,Ls,fn)=>nt(W(ct(de(pr.mul(.25))).add(ct(de(Ls.mul(.25))).mul(n)).add(ct(de(fn.mul(.25))).mul(n*n)))),br=pr=>pr.mul(.5).fract().lessThan(.25),ls=(pr,Ls)=>pr.greaterThanEqual(Ls).and(pr.add(Ls).lessThanEqual(i)),zn=I(0).toVar(),Ho=I(0).toVar(),Ln=I(0).toVar(),is=I(1).toVar(),fs=I(1).toVar(),Sr=I(1).toVar(),Js=(pr,Ls,fn,la,jr,gn,Gr,tn,yn)=>{let Da=Vr(...yn[0]).add(Vr(...yn[1])).add(Vr(...yn[2])).add(Vr(...yn[3])).greaterThan(3.5).toVar(),Tl=ir(Mt.add(fn),ee.add(la),We.add(jr)).lessThan(0).toFloat(),Jh=ir(Mt.add(2*fn),ee.add(2*la),We.add(2*jr)).lessThan(0).toFloat();vt(Wt.greaterThan(.5).and(Da.not()).and(tn.add(1).lessThanEqual(i)).and(ls(gn,I(1))).and(ls(Gr,I(1))).and(es.notEqual(Tl)),()=>{pr.assign(I(1)),Ls.assign(I(1))}),vt(Wt.greaterThan(.5).and(Da).and(br(Mt)).and(br(ee)).and(br(We)).and(tn.add(2).lessThanEqual(i)).and(ls(gn,I(2))).and(ls(Gr,I(2))).and(es.notEqual(Jh)),()=>{pr.assign(I(1)),Ls.assign(I(2))})};Js(zn,is,1,0,0,ee,We,Mt,[[Mt,ee.sub(1),We.sub(1)],[Mt,ee,We.sub(1)],[Mt,ee,We],[Mt,ee.sub(1),We]]),Js(Ho,fs,0,1,0,We,Mt,ee,[[Mt.sub(1),ee,We.sub(1)],[Mt.sub(1),ee,We],[Mt,ee,We],[Mt,ee,We.sub(1)]]),Js(Ln,Sr,0,0,1,Mt,ee,We,[[Mt.sub(1),ee.sub(1),We],[Mt,ee.sub(1),We],[Mt,ee,We],[Mt.sub(1),ee,We]]);let oa=zn.add(Ho).add(Ln).mul(2).toVar();J.element(he).assign(oa.add(p)),z1(),vt(he.equal(ct(0)).and(Wt.greaterThan(.5)),()=>{let pr=I(0).toVar();Qi(64,({i:jr})=>{yt.element(jr).assign(pr),pr.addAssign(nt(J.element(jr)))}),hl(M(0),Vi(pr));let Ls=de(pr.add(7).mul(1/8)).toVar(),fn=I(-1).toVar(),la=I(-1).toVar();Qi(48,({i:jr})=>{vt(I(jr).greaterThanEqual(Ls),()=>{ea()});let gn=I(jr).toVar(),Gr=I(-1).toVar(),tn=kR(P(4),ct(1)).toVar();vt(tn.greaterThanEqual(1),()=>{Gr.assign(nt(K(tn.sub(1))))}).Else(()=>{hl(P(4),ct(1));let yn=hl(P(3),ct(1)).toVar();vt(yn.lessThan(ct(b)),()=>{Gr.assign(yn.toFloat())}).Else(()=>{Oo(P(5),ct(1))})}),ht.element(ct(gn)).assign(Gr),vt(Gr.greaterThan(-.5),()=>{dt(Gr).assign(ti(pr.sub(gn.mul(8)),8)),ft(Gr).assign(I(-1)),vt(la.greaterThan(-.5),()=>{ft(la).assign(Gr)}).Else(()=>{fn.assign(Gr)}),la.assign(Gr)})}),B(le(ye)).assign(fn)}),z1(),vt(oa.greaterThan(.5),()=>{let pr=(jr,gn,Gr)=>{let tn=de(jr.mul(.25)),yn=de(gn.mul(.25)),Da=de(Gr.mul(.25)),Tl=ct(tn).add(ct(yn).mul(n)).add(ct(Da).mul(n*n)),Jh=ct(jr.sub(tn.mul(4))).add(ct(gn.sub(yn.mul(4))).mul(4)).add(ct(Gr.sub(Da.mul(4))).mul(16));return Vi(Tl.mul(64).add(Jh))},Ls=nt(yt.element(he)).toVar(),fn=(jr,gn,Gr)=>{let tn=nt(ht.element(ct(de(Ls.mul(.125))))).toVar();vt(tn.greaterThan(-.5),()=>{let yn=Ls.sub(de(Ls.mul(.125)).mul(8)),Da=ct(tn.mul(24).add(yn.mul(3))).toVar();wt(Da).assign(jr),wt(Da.add(ct(1))).assign(gn),wt(Da.add(ct(2))).assign(Gr)}),Ls.addAssign(1)},la=(jr,gn)=>{vt(jr.greaterThan(.5),()=>{let Gr=pr(...gn[0]).toVar(),tn=pr(...gn[1]).toVar(),yn=pr(...gn[2]).toVar(),Da=pr(...gn[3]).toVar();vt(es.greaterThan(.5),()=>{fn(Gr,tn,yn),fn(Gr,yn,Da)}).Else(()=>{fn(Gr,Da,yn),fn(Gr,yn,tn)})})};la(zn,[[Mt,ee.sub(is),We.sub(is)],[Mt,ee,We.sub(is)],[Mt,ee,We],[Mt,ee.sub(is),We]]),la(Ho,[[Mt.sub(fs),ee,We.sub(fs)],[Mt.sub(fs),ee,We],[Mt,ee,We],[Mt,ee,We.sub(fs)]]),la(Ln,[[Mt.sub(Sr),ee.sub(Sr),We],[Mt,ee.sub(Sr),We],[Mt,ee,We],[Mt.sub(Sr),ee,We]])})})(),Bm=y?yi(Om):null,km=y?yi(rr):null,_0=y?At(()=>{let L=Lp("float",48),J=Lp("float",2),yt=j(zR).toVar(),ht=ct(nt(yt.x).add(nt(yt.y).mul(4)).add(nt(yt.z).mul(16))).toVar(),Ot=j(UR).toVar(),he=nt(Ot.y).mul(ts).add(nt(Ot.x)).toVar();vt(ht.equal(ct(0)),()=>{let ee=I(0).toVar();vt(he.lessThan(f),()=>{let es=Fi(he).toVar();vt(ie(le(es)).equal(he),()=>{let Vr=I(0).toVar();vt(nt(gt).greaterThan(.5),()=>{let br=j(0).toVar(),ls=j(0).toVar();for(let zn=0;zn<8;zn++){let Ho=le(es.mul(4).add(j(4*(1&zn),4*(zn>>1&1),4*(zn>>2&1)))),Ln=le(Ho.div(i).mul(2).sub(1)).mul(o).add(j(l)),is=Dt.mul(at(Ln,1)).toVar(),fs=nt(is.w);br.addAssign(j(nt(is.x).lessThan(fs.negate()).toFloat(),nt(is.y).lessThan(fs.negate()).toFloat(),nt(is.z).lessThan(0).toFloat())),ls.addAssign(j(nt(is.x).greaterThan(fs).toFloat(),nt(is.y).greaterThan(fs).toFloat(),nt(is.z).greaterThan(fs).toFloat()))}vt(Kt(Kt(nt(br.x),Kt(nt(br.y),nt(br.z))),Kt(nt(ls.x),Kt(nt(ls.y),nt(ls.z)))).greaterThan(7.5),()=>{Vr.assign(I(1))})}),vt(Vr.lessThan(.5),()=>{let br=nt(B(le(es))).toVar();Qi(48,({i:ls})=>{vt(br.lessThan(-.5),()=>{ea()}),L.element(ls).assign(br),ee.addAssign(nt(dt(br))),br.assign(nt(ft(br)))})})})});let We=I(0).toVar();vt(ee.greaterThan(.5),()=>{let es=hl(M(3),Vi(ee.mul(3))).toVar();We.assign(I(es))}),J.element(ct(0)).assign(We.add(p)),J.element(ct(1)).assign(ee)}),z1();let ye=nt(J.element(ct(1))).toVar(),Wt=nt(J.element(ct(0))).toVar(),Mt=I(ht).toVar();Qi(6,()=>{vt(Mt.greaterThanEqual(ye),()=>{ea()});let ee=nt(L.element(ct(de(Mt.mul(1/8))))).toVar(),We=Mt.sub(de(Mt.mul(1/8)).mul(8)),es=ct(ee.mul(24).add(We.mul(3))).toVar(),Vr=ct(Wt.add(Mt.mul(3))).toVar(),br=Ln=>{let is=wt(Ln===0?es:es.add(ct(Ln))).toVar(),fs=ct(is.shiftRight(Vi(6))).toVar(),Sr=ct(is.bitAnd(Vi(63))).toVar(),Js=nt((jr=>N.element(jr.add(ct(2*D))))(fs)).toVar(),oa=nt(W(fs)),pr=Sr.bitAnd(ct(3)),Ls=Sr.shiftRight(ct(2)).bitAnd(ct(3)),fn=Sr.shiftRight(ct(4)).bitAnd(ct(3)),la=pr.shiftRight(ct(1)).add(Ls.shiftRight(ct(1)).mul(ct(2))).add(fn.shiftRight(ct(1)).mul(ct(4)));return{blockF:Js,li:ct(oa.greaterThan(.5).select(la,Sr)).toVar()}},ls=br(0),zn=br(1),Ho=br(2);vt(ls.blockF.greaterThan(-.5).and(zn.blockF.greaterThan(-.5)).and(Ho.blockF.greaterThan(-.5)),()=>{let Ln=is=>Vi(ct(is.blockF.mul(64)).add(is.li));v.element(Vr).assign(Ln(ls)),v.element(Vr.add(ct(1))).assign(Ln(zn)),v.element(Vr.add(ct(2))).assign(Ln(Ho))}).Else(()=>{v.element(Vr).assign(Vi(0)),v.element(Vr.add(ct(1))).assign(Vi(0)),v.element(Vr.add(ct(2))).assign(Vi(0))}),Mt.addAssign(64)})})():null,Vn=Math.ceil(e/z2[0]),kc=Math.ceil(r/z2[0]),kr=Math.ceil(n/z2[0]),X=(L,J)=>L.compute(J,Array.isArray(J)?z2:void 0),St=[ts,Math.max(1,Math.ceil(f/ts)),1];return{resolution:e,sparse:m!==null,poolBricks:f,meshlet:y!==null,vertexBlocks:_,needsInit:m!==null,sdfTexture:S,colorTexture:w,coarseTexture:T,counterAttribute:C.value,storageAttributes:[C,A,O,N,H,rt,lt,xt].filter(L=>L!==null).map(L=>L.value),uniforms:{bboxHalf:o,bboxOffset:l,activeThreshold:h,windowOrigin:u,...y?{windowSize:d,cullEnabled:gt,cullMVP:Dt,adaptCos:Lt}:{}},kernels:{zero:X(ne,1),clear:Ut.compute([Math.ceil(s/256),1,1],[256,1,1]),coarse:X(Be,[kr,kr,kr]),...ni?{init:X(ni,[kr,kr,kr])}:{},...bi?{release:X(bi,[kr,kr,kr])}:{},...Zs?{alloc:X(Zs,[kr,kr,kr])}:{},...Hi?{stats:X(Hi,1)}:{},sdf:X(Qs,m?St:[Vn,Vn,Vn]),...Ti?{sdfWindow:X(Ti,[Vn,Vn,Vn])}:{},color:X(ms,[kc,kc,kc]),extract:y?X(Bm,St):X(Qh,m?St:[Vn,Vn,Vn]),...y?{clearDraw:Yt.compute([Math.ceil(s/256),1,1],[256,1,1]),meshRelease:X(ai,[kr,kr,kr]),verts:X(Nm,St),vertsWindow:X(nh,[n,n,n]),extractWindow:X(km,[n,n,n]),classify:X(Fr,[kr,kr,kr]),gather:X(_0,St)}:{}}}}var nt,t4,le,Ta,G1,k5,z2,Lp,sRt=U(()=>{ot(),cr(),je(),YW(),Nq(),nt=t=>t,t4=t=>t,le=t=>t,Ta=t=>t,G1=24,k5=XW,z2=[4,4,4],Lp=(t,e)=>qvt(t,e)});function nRt(t){let e=t.getAttribute("position");if(!e||e.count<3)return null;let i=t.getIndex(),r=Math.floor((i?i.count:e.count)/3);if(r===0)return null;let s=Math.max(1,Math.ceil(r/V5));s>1&&console.warn(`Spline shape blend: mesh child has ${r} triangles \u2014 baking every ${s}th (SDF detail reduced).`);let n=Math.floor(r/s),a=new Float32Array(12*n),o=new E(0,0,0),l=new E,h=0;for(let d=0;d<n;d++){let c=d*s*3;for(let p=0;p<3;p++){let m=i?i.getX(c+p):c+p;l.fromBufferAttribute(e,m),a[h++]=l.x,a[h++]=l.y,a[h++]=l.z,a[h++]=0,o.x=Math.max(o.x,Math.abs(l.x)),o.y=Math.max(o.y,Math.abs(l.y)),o.z=Math.max(o.z,Math.abs(l.z))}}if(o.x===0&&o.y===0&&o.z===0)return null;let u=Math.max(o.x,o.y,o.z);return o.x=Math.max(o.x,.05*u)*(1+e4),o.y=Math.max(o.y,.05*u)*(1+e4),o.z=Math.max(o.z,.05*u)*(1+e4),{data:a,triCount:n,boxHalf:o}}function aRt(t){let e=Sc(t),i=WD;return(r,s,n)=>{let a=Kt(j(Hs(s.z),Hs(s.w),Hs(n.w)),j(1e-5)).toVar(),o=Hs(s.y),l=j(o.mod(Mc).mul(i),de(o.div(Mc)).mul(i),0).toVar(),h=Te(AS(r.div(a).mul(.5).add(.5)),j(0),j(1)).mul(i-1).toVar(),u=ti(de(h),j(i-2)).toVar(),d=h.sub(u).toVar(),c=l.add(u).toVar(),p=(C,M,A)=>Hs(G_t(e.load(Kn(c.add(j(C,M,A))))).x),m=Hs(d.x),f=Hs(d.y),g=Hs(d.z),y=$t(p(0,0,0),p(1,0,0),m),v=$t(p(0,1,0),p(1,1,0),m),b=$t(p(0,0,1),p(1,0,1),m),_=$t(p(0,1,1),p(1,1,1),m),x=$t($t(y,v,f),$t(b,_,f),g),S=Kt(Hs(a.x),Kt(Hs(a.y),Hs(a.z))),w=ke(r).sub(a),T=ci(Kt(w,j(0)));return Hs(x.mul(S).add(T))}}function oRt(t){let e=WD;return new E(t%Mc*e,Math.floor(t/Mc)*e,0)}var Hs,AS,G_t,WD,Mc,e4,V5,lRt=U(()=>{ot(),ot(),cr(),je(),Hs=t=>t,AS=t=>t,G_t=t=>t,WD=48,Mc=4,e4=.08,V5=24576});function hRt(){if(i4!==null)return i4;let t=At(()=>{let i=st(Xe(R7),Xe(D7)),r=st(1).div(i),s=ui().mul(Xe(O7)).sub(st(.5)).mul(2).add(st(.5)).toVar();s.x.addAssign(Xe(L2));let n=s.div(i).toVar(),a=Xe(av.sample(n).x).toVar();n.x.addAssign(Xe(r.x));let o=Xe(av.sample(n).x).toVar();n.y.addAssign(Xe(r.y));let l=Xe(av.sample(n).x).toVar();n.x.subAssign(Xe(r.x));let h=Xe(av.sample(n).x).toVar(),u=a,d=u.add(o),c=d.add(l),p=c.add(h);return at(p,c,d,u)})(),e=new Pe;return e.name="SplineShapeBlend.pyramid",e.fragmentNode=t,e.depthTest=!1,e.depthWrite=!1,e.blending=Wi,e.needsUpdate=!0,i4=e,e}function yw(t,e,i=1){return new ii(t,e,{count:i,format:hn,type:Ye,depthBuffer:!1,stencilBuffer:!1,generateMipmaps:!1,minFilter:Re,magFilter:Re,wrapS:Cn,wrapT:Cn})}function uRt(){let t=Ov.length;if(t>0){for(let e of Ov)e.dispose();Ov.length=0}return t}var Xe,Rut,kd,av,R7,D7,L2,qy,O7,i4,gF,yF,Cp,kE,vF,bF,_F,xF,wF,SF,TF,VE,ar,vw,Dut,I7,W1,F2,Ov,dRt=U(()=>{ot(),cr(),je(),YW(),Byt(),Nq(),sRt(),lRt(),pn(),Xe=t=>t,Rut=t=>t,kd=new Pr,av=Jt(new di),R7=mt(1),D7=mt(1),L2=mt(0),qy=mt(0),O7=mt(1),i4=null,gF=!1,yF=!1,Cp="",kE=!1,vF=!1,bF=!1,_F=!1,xF=!1,wF=!1,SF=!1,TF=!1,VE=!1;try{let t=new URLSearchParams(window.location.search);gF=t.get("dbgsbmarch")==="vertex",yF=t.get("dbgsbultra")==="0",Cp=t.get("dbgsbchain")??"",kE=t.get("dbgsbnoclear")==="1",vF=t.get("dbgsbsparse")==="0",bF=t.get("dbgsbincr")==="0",_F=t.get("dbgsblod")==="1",xF=t.get("dbgsbpool")==="1",wF=t.get("dbgsbpool")==="0",SF=t.get("dbgsbmesh")==="0",TF=t.get("dbgsbadapt")==="0",VE=t.get("dbgsbcull")==="1"}catch{}ar={updates:0,skips:0,computes:0,readbacksResolved:0,readbackErrors:0,fieldsFull:0,fieldsWindowed:0,lastWindowBricks:0,refines:0,lastDispatchRes:0,regathers:0,readbackPending:!1,lastTotal:-1,lastPass:"",staleConfigSkips:0,marchPositions:null},vw=24576,Dut=Math.cos(8*Math.PI/180),I7=class{constructor(t=0,e=0,i=0){this.wantsReplacement=!1,this.capacityHint=0,this._builtOnce=!1,this.level=-1,this.spatialnAtBuild=-1,this._passesRenderer=null,this._marchCapacity=0,this._marchBuffers=null,this._computeNode=null,this._computeNodeKey="",this._legacyMaterialsLevel=-1,this._computeDirty=!1,this._cachedAtBuild=!1,this._ultra=null,this._ultraDrag=null,this._lastDispatched=null,this._refinePending=!1,this._lastFieldChangeMs=0,this._ultraResAtBuild=0,this._ultraReadbackPending=!1,this._ultraReadbackQueued=!1,this._ultraWantedCapacity=0,this._poolAtBuild=0,this._ultraWantedPoolBricks=0,this.poolHint=0,this._drawIndex=null,this._vertexBuffers=null,this._vertBlocksAtBuild=0,this._ultraWantedVertexBlocks=0,this.vertHint=0,this._cullCamera=null,this._lastGatherMVP=new bt,this._hasGatherMVP=!1,this._ultraRetired=[],this._retiredStorage=[],this._ultraBuildSeq=0,this._lastRenderer=null,this._meshBaker=null,this._meshAtBuild=!1,this._meshSlots=new Map,this._meshBakeFailed=new Map,this._meshWarnedFull=!1,this.shapesTex=Jt(new di),this.spatialTexNode=Jt(new di),this.potentialTexNode=Jt(new di),this.voxelTexNode=Jt(new di),this.pyramid1TexNode=Jt(new di),this.pyramid2TexNode=Jt(new di),this.npartUniform=mt(0),this.spatialnUniform=mt(1),this.spanUniform=mt(0),this.spatialMaterial=null,this.potentialMaterial=null,this.voxelMaterial=null,this.spatialTargets=[],this.potentialTargets=[],this.voxelTargets=[],this.pyramidTargets=[],this.retired=!1,this._onSettled=[],this.capacityHint=t,this.poolHint=e,this.vertHint=i;let r=bR(),s=new yr(r.triTable,16,256,Ka,Ye);s.needsUpdate=!0;let n=new yr(r.numTrisTable,256,1,Ka,Ye);n.needsUpdate=!0,this.triTableTexNode=Jt(s),this.numTrisTableTexNode=Jt(n)}shapeRow(t,e){return this.shapesTex.sample(st(t,(e+.5)/5))}_quadMaterial(t,e){let i=new Pe;return i.name=t,i.fragmentNode=e,i.depthTest=!1,i.depthWrite=!1,i.blending=Wi,i.needsUpdate=!0,i}_buildSpatialMaterial(t){let e=t.spatialDivisions,i=XW,r=this.npartUniform,s=this.spatialnUniform,n=this.spanUniform,a=t.spatialn,o=At(()=>{let l=st(e*a,e**2),h=de(ui().mul(l)).toVar(),u=Xe(h.y).toVar(),d=u.sub(de(u.div(e)).mul(e)).toVar();u.assign(de(u.div(e)));let c=u,p=Xe(h.x).toVar(),m=p.sub(de(p.div(s)).mul(Xe(s))).toVar().mul(96).toVar();p.assign(de(p.div(s)));let f=j(p,d,c),g=f.div(e).mul(2).sub(1).sub(Xe(n)).toVar(),y=f.add(1).div(e).mul(2).sub(1).add(Xe(n)).toVar(),v=b=>{let _=I(0).toVar();for(let x=23;x>=0;x--){let S=b.add(x),w=S.add(.5).div(i),T=this.shapeRow(w,0),C=Rut(T.xyz),M=Xe(T.w);_.mulAssign(2);let A=Xe(g.x).lessThan(Xe(C.x)).and(Xe(C.x).lessThan(Xe(y.x))).and(Xe(g.y).lessThan(Xe(C.y))).and(Xe(C.y).lessThan(Xe(y.y))).and(Xe(g.z).lessThan(Xe(C.z))).and(Xe(C.z).lessThan(Xe(y.z))).and(S.lessThan(Xe(r))).or(M.equal(-2));_.addAssign(A.select(I(1),I(0)))}return _};return at(v(m),v(m.add(24)),v(m.add(48)),v(m.add(72)))})();return this._quadMaterial("SplineShapeBlend.spatial",o)}_fieldEnv(t,e){return{shapeRow:(i,r)=>this.shapeRow(i,r),spatialTex:this.spatialTexNode,spatialDivisions:t.spatialDivisions,spatialn:t.spatialn,colorKBump:e,meshSdf:this._meshBaker?aRt(this._meshBaker.atlas):void 0}}_buildPotentialMaterial(t){let e=t.spatialDivisions,i=t.resolution,r=i-1,s=1/i,n=t.zLayersPerRow,a=t.basePyramidSize,o=P7(this._fieldEnv(t,2*s)),l=At(()=>{let h=de(ui().mul(st(a,a))).toVar(),u=Xe(h.x).mod(i),d=Xe(h.y).mod(i),c=de(Xe(h.x).mul(s)).add(de(Xe(h.y).mul(s)).mul(n)),p=j(u,d,c),m=p.div(r).mul(2).sub(1).toVar(),f=de(p.div(r).mul(e-1)).toVar(),{sdf:g,color:y}=o(m,f),v=Vi(Xe(y.x).mul(255)),b=Vi(Xe(y.y).mul(255)),_=v.shiftLeft(Vi(8)).bitOr(b);return at(g,_.toFloat().mul(1525902e-11),Xe(y.z),Xe(y.w))})();return this._quadMaterial("SplineShapeBlend.potential",l)}_buildVoxelMaterial(t){let e=t.resolution,i=e-1,r=1/e,s=t.zLayersPerRow,n=t.basePyramidSize,a=z_t(e,s),o=this.potentialTexNode,l=()=>{let c=de(ui().mul(st(n,n))).toVar();return{xi:Xe(c.x).mod(e).toVar(),yi:Xe(c.y).mod(e).toVar(),zi:de(Xe(c.x).mul(r)).add(de(Xe(c.y).mul(r)).mul(s)).toVar()}},h=(c,p,m)=>{let f=(g,y,v,b)=>Xe(a(c.add(g),p.add(y),m.add(v),o).x).lessThan(0).toFloat().mul(b);return f(0,0,0,1).add(f(1,0,0,2)).add(f(0,1,0,8)).add(f(1,1,0,4)).add(f(0,0,1,16)).add(f(1,0,1,32)).add(f(0,1,1,128)).add(f(1,1,1,64))},u=At(()=>{let{xi:c,yi:p,zi:m}=l(),f=((v,b,_)=>{let x=Xe(a(v.add(1),b,_,o).x).sub(Xe(a(v.sub(1),b,_,o).x)),S=Xe(a(v,b.add(1),_,o).x).sub(Xe(a(v,b.sub(1),_,o).x)),w=Xe(a(v,b,_.add(1),o).x).sub(Xe(a(v,b,_.sub(1),o).x));return x.equal(0).and(S.equal(0)).and(w.equal(0)).select(j(.199,.299,.399),be(j(x,S,w)))})(c,p,m).toVar(),g=at(f,0).toVar(),y=c.greaterThanEqual(i).or(p.greaterThanEqual(i)).or(m.greaterThanEqual(i));return vt(y.not(),()=>{g.assign(at(f,h(c,p,m)))}),g})(),d=At(()=>{let{xi:c,yi:p,zi:m}=l(),f=at(0).toVar(),g=c.greaterThanEqual(i).or(p.greaterThanEqual(i)).or(m.greaterThanEqual(i));return vt(g.not(),()=>{let y=h(c,p,m);f.assign(this.numTrisTableTexNode.sample(st(y.add(.5).div(256),.5)))}),f})();return this._quadMaterial("SplineShapeBlend.voxel",Kv({output:u,numTris:d}))}_spatialTargetFor(t){let e=t.resolutionLevel,i=this.spatialTargets[e];return i||(i=yw(t.spatialDivisions*t.spatialn,t.spatialDivisions**2),this.spatialTargets[e]=i),i}_targetsFor(t){let e=t.resolutionLevel,i=this._spatialTargetFor(t),r=this.potentialTargets[e];r||(r=yw(t.basePyramidSize,t.basePyramidSize),this.potentialTargets[e]=r);let s=this.voxelTargets[e];s||(s=yw(t.basePyramidSize,t.basePyramidSize,2),s.textures[0].name="output",s.textures[1].name="numTris",s.textures[1].format=Ka,this.voxelTargets[e]=s);let n=this.pyramidTargets[e];return n||(n=[yw(t.pyramidTexture1Width,t.pyramidTexture1Height),yw(t.pyramidTexture2Width,t.pyramidTexture2Height)],this.pyramidTargets[e]=n),{spatial:i,potential:r,voxel:s,pyramid:n}}_marchResources(t){let e=this._targetsFor(t),i=t.pyramidLevelSizes.length%2==0?0:1,r=1-i;return{resolutionLevel:t.resolutionLevel,pyramidLevelSizes:t.pyramidLevelSizes,triTable:this.triTableTexNode,potential:this.potentialTexNode,voxel:this.voxelTexNode,pyramid1:this.pyramid1TexNode,pyramid2:this.pyramid2TexNode,pyramid1Size:{width:e.pyramid[r].width,height:e.pyramid[r].height},pyramid2Size:{width:e.pyramid[i].width,height:e.pyramid[i].height}}}_maxMarchSlots(t){let e=t.backend?.device?.limits,i=Math.min(e?.maxStorageBufferBindingSize??134217728,e?.maxBufferSize??268435456);return 192*Math.floor(i/16/192)}_ensureMarchCapacity(t,e){if(this._marchBuffers!==null&&t<=this._marchCapacity)return!1;let i=Math.min(Math.max(e,vw),192*Math.ceil(1.5*t/192));if(this._marchBuffers!==null&&i<=this._marchCapacity)return!1;if(this._marchBuffers!==null)for(let r of[this._marchBuffers.positions,this._marchBuffers.normals,this._marchBuffers.colors]){let s=r.value;s&&this._retiredStorage.push(s)}return this._marchBuffers={positions:Zr(i,"vec4"),normals:Zr(i,"vec4"),colors:Zr(i,"vec4")},this._marchCapacity=i,this._computeNode=null,!0}update(t,e,i){if(ar.updates++,this._lastRenderer=e,i!==void 0&&(this._cullCamera=i),t._meshSdfBaked.size>0)for(let[T,C]of t._meshSdfBaked)C.owner!==this&&t._meshSdfBaked.delete(T);let r=(n=t,Xyt.call(n)),s=e.backend?.isWebGPUBackend===!0;var n;if(s&&t._meshSdfWanted.size>0&&this._meshBaker===null&&(this._meshBaker=function(T,C){let M=WD,A=new Yg(Mc*M,Math.ceil(T/Mc)*M,M);A.format=Ka,A.type=Ye,A.minFilter=Re,A.magFilter=Re,A.name="SplineShapeBlend.meshSdfAtlas";let P=I(C).mul(0),O=mt(new E(0,0,0)),D=mt(0),N=mt(new E(1,1,1)),z=Zr(3*V5,"vec4"),k=W=>z.element(W),B=At(()=>{let W=j(ho).toVar();vt(Hs(W.x).greaterThanEqual(M).or(Hs(W.y).greaterThanEqual(M)).or(Hs(W.z).greaterThanEqual(M)),()=>{fr()});let H=W.div(M-1).mul(2).sub(1).mul(N).toVar(),rt=I(1e30).toVar(),it=I(1e15).toVar();Qi(V5,({i:dt})=>{vt(I(dt).greaterThanEqual(Hs(D)),()=>{ea()});let K=ct(I(dt).toVar()).mul(3).toVar(),lt=AS(k(K).xyz).toVar(),_t=AS(k(K.add(ct(1))).xyz).toVar(),xt=AS(k(K.add(ct(2))).xyz).toVar(),wt=_t.sub(lt).toVar(),gt=xt.sub(lt).toVar(),Dt=H.sub(lt).toVar(),Lt=Bt(wt,Dt).toVar(),It=Bt(gt,Dt).toVar(),kt=H.sub(_t).toVar(),Nt=Bt(wt,kt).toVar(),Gt=Bt(gt,kt).toVar(),qt=H.sub(xt).toVar(),Ct=Bt(wt,qt).toVar(),ne=Bt(gt,qt).toVar(),Ut=j(0).toVar(),Yt=Nt.mul(ne).sub(Ct.mul(Gt)).toVar(),Zt=Ct.mul(It).sub(Lt.mul(ne)).toVar(),$=Lt.mul(Gt).sub(Nt.mul(It)).toVar();vt(Lt.lessThanEqual(0).and(It.lessThanEqual(0)),()=>{Ut.assign(lt)}).ElseIf(Nt.greaterThanEqual(0).and(Gt.lessThanEqual(Nt)),()=>{Ut.assign(_t)}).ElseIf(ne.greaterThanEqual(0).and(Ct.lessThanEqual(ne)),()=>{Ut.assign(xt)}).ElseIf($.lessThanEqual(0).and(Lt.greaterThanEqual(0)).and(Nt.lessThanEqual(0)),()=>{let Be=Lt.div(Lt.sub(Nt));Ut.assign(lt.add(wt.mul(Be)))}).ElseIf(Zt.lessThanEqual(0).and(It.greaterThanEqual(0)).and(ne.lessThanEqual(0)),()=>{let Be=It.div(It.sub(ne));Ut.assign(lt.add(gt.mul(Be)))}).ElseIf(Yt.lessThanEqual(0).and(Gt.sub(Nt).greaterThanEqual(0)).and(Ct.sub(ne).greaterThanEqual(0)),()=>{let Be=Gt.sub(Nt).div(Gt.sub(Nt).add(Ct.sub(ne)));Ut.assign(_t.add(xt.sub(_t).mul(Be)))}).Else(()=>{let Be=I(1).div(Yt.add(Zt).add($)),te=Zt.mul(Be),ni=$.mul(Be);Ut.assign(lt.add(wt.mul(te)).add(gt.mul(ni)))});let ie=H.sub(Ut).toVar(),Ce=Bt(ie,ie).toVar();vt(Ce.lessThan(rt),()=>{rt.assign(Ce);let Be=Kr(wt,gt),te=Bt(ie,Be).greaterThanEqual(0).select(I(1),I(-1));it.assign(xl(Ce).mul(te))})});let ft=Kt(Hs(N.x),Kt(Hs(N.y),Hs(N.z)));Hp(A,Kn(W.add(O)),at(Hs(it.div(ft).add(P)),0,0,0)).toStack()})(),V=Math.ceil(M/4),q=B.compute([V,V,V],[4,4,4]);return{atlas:A,slots:T,kernel:q,uniforms:{slotOrigin:O,triCount:D,boxHalf:N},setTriangles(W,H){let rt=z.value;rt.array.set(W.subarray(0,12*H)),rt.needsUpdate=!0}}}(Mc*Mc,++this._ultraBuildSeq)),t.npart===0)return this._meshBaker!==null&&t._meshSdfWanted.size>0&&this._bakeNextMeshChild(t,e),void(t.geometry.drawRange.count=0);this.npartUniform.value=t.npart,this.spatialnUniform.value=t.spatialn,this.spanUniform.value=t.spatialPassUniforms.span.value,t.shapesDataTexture.value&&(this.shapesTex.value=t.shapesDataTexture.value);let a=!gF&&s,o=a&&!yF&&t.ultraFieldResolution>0,l=o&&!wF&&(xF||t.ultraFieldResolution>=512)?Math.min(Math.pow(t.ultraFieldResolution/4,3),Math.max(function(T){let C=T/4;return Math.min(C*C*C,Math.max(8192,16*C*C))}(t.ultraFieldResolution),this._ultraWantedPoolBricks,this.poolHint)):0,h=l>0&&!SF,u=this._maxMarchSlots(e),d=h?Math.min(Math.floor(u/64),Math.max(function(T){let C=T/4;return Math.min(262144,Math.max(2048,2*C*C))}(t.ultraFieldResolution),this._ultraWantedVertexBlocks,this.vertHint)):0,c=this._meshBaker!==null,p=t.needsRebuild||this.level!==t.resolutionLevel||this.spatialnAtBuild!==t.spatialn||this._cachedAtBuild!==a||this._ultraResAtBuild!==(o?t.ultraFieldResolution:0)||this._poolAtBuild!==l||this._vertBlocksAtBuild!==d||this._meshAtBuild!==c;if(p&&this._builtOnce)return this.wantsReplacement=!0,this.capacityHint=Math.max(this._marchCapacity,this._ultraWantedCapacity),this.poolHint=Math.max(this.poolHint,this._ultraWantedPoolBricks),void(this.vertHint=Math.max(this.vertHint,this._ultraWantedVertexBlocks));let m=a&&this._ensureMarchCapacity(Math.min(Math.max(u,vw),Math.max(t.geometry.drawRange.count,this.capacityHint,o?Math.max(function(T){return Math.max(vw,192*Math.ceil(16*T*T/192))}(t.ultraFieldResolution),this._ultraWantedCapacity):vw)),u);if(m&&this._builtOnce)return this.wantsReplacement=!0,this.capacityHint=Math.max(this._marchCapacity,this._ultraWantedCapacity),this.poolHint=Math.max(this.poolHint,this._ultraWantedPoolBricks),void(this.vertHint=Math.max(this.vertHint,this._ultraWantedVertexBlocks));let f=this._spatialTargetFor(t),g=o?null:this._targetsFor(t),y=p||m,v=o&&this._ultra!==null&&this._ultraResAtBuild===t.ultraFieldResolution&&!m&&this.level===t.resolutionLevel&&this.spatialnAtBuild===t.spatialn&&this._cachedAtBuild===a;if(y&&v)t.needsRebuild=!1,this._ultra.uniforms.bboxHalf.value=t.bboxSize/2,this._ultra.uniforms.bboxOffset.value=t.bboxOffset,this._ultraDrag&&(this._ultraDrag.uniforms.bboxHalf.value=t.bboxSize/2,this._ultraDrag.uniforms.bboxOffset.value=t.bboxOffset);else if(y){t.needsRebuild=!1;let T=this.spatialnAtBuild!==t.spatialn;this.level=t.resolutionLevel,this.spatialnAtBuild=t.spatialn,this._meshAtBuild=c,(T||this.spatialMaterial===null)&&(this.spatialMaterial?.dispose(),this.spatialMaterial=this._buildSpatialMaterial(t)),this.spatialTexNode.value=f.texture;let C=this._ultra,M=this._ultraDrag;if(this._ultra=null,this._ultraDrag=null,this._lastDispatched=null,this._refinePending=!1,o){let O=t.ultraFieldResolution,D=C!==null&&this._ultraResAtBuild===O;if(D&&!m)this._ultra=C,C.uniforms.bboxHalf.value=t.bboxSize/2,C.uniforms.bboxOffset.value=t.bboxOffset,this._ultraDrag=M,M&&(M.uniforms.bboxHalf.value=t.bboxSize/2,M.uniforms.bboxOffset.value=t.bboxOffset);else{let N=D&&l===0&&!C.sparse;C&&!N&&this._ultraRetired.push(C.sdfTexture,C.colorTexture,C.coarseTexture),h&&this._drawIndex===null&&(this._drawIndex=Zr(this._marchCapacity,"uint")),h&&this._vertexBuffers===null&&(this._vertexBuffers={positions:Zr(64*d,"vec4"),normals:Zr(64*d,"vec4"),colors:Zr(64*d,"vec4")}),this._ultra=Put({resolution:O,colorResolution:O/2,bboxHalf:t.bboxSize/2,bboxOffset:t.bboxOffset,capacity:this._marchCapacity,env:this._fieldEnv(t,2/(O/2)),npart:this.npartUniform,triTable:this.triTableTexNode,numTrisTable:bR().numTrisTable,buffers:h?this._vertexBuffers:this._marchBuffers,buildSeq:++this._ultraBuildSeq,sparseStorage:l>0?{poolBricks:l,meshlet:h?{drawIndex:this._drawIndex,vertexBlocks:d}:void 0}:void 0,reuseTextures:N?{sdfTexture:C.sdfTexture,colorTexture:C.colorTexture,coarseTexture:C.coarseTexture}:void 0}),this._poolAtBuild=l,this._vertBlocksAtBuild=d;let z=_F&&O>=128&&!h?O/2:0;M&&(!D||z===0)&&this._ultraRetired.push(M.sdfTexture,M.colorTexture,M.coarseTexture),z>0&&(this._ultraDrag=Put({resolution:z,colorResolution:z/2,bboxHalf:t.bboxSize/2,bboxOffset:t.bboxOffset,capacity:this._marchCapacity,env:this._fieldEnv(t,2/(z/2)),npart:this.npartUniform,triTable:this.triTableTexNode,numTrisTable:bR().numTrisTable,buffers:this._marchBuffers,buildSeq:++this._ultraBuildSeq,reuseTextures:D&&M?{sdfTexture:M.sdfTexture,colorTexture:M.colorTexture,coarseTexture:M.coarseTexture}:void 0}))}this._ultraResAtBuild=O}else{C&&this._ultraRetired.push(C.sdfTexture,C.colorTexture,C.coarseTexture),M&&this._ultraRetired.push(M.sdfTexture,M.colorTexture,M.coarseTexture),(this._legacyMaterialsLevel!==t.resolutionLevel||T||this.potentialMaterial===null||this.voxelMaterial===null)&&(this.potentialMaterial?.dispose(),this.voxelMaterial?.dispose(),this.potentialMaterial=this._buildPotentialMaterial(t),this.voxelMaterial=this._buildVoxelMaterial(t),this._legacyMaterialsLevel=t.resolutionLevel),this.potentialTexNode.value=g.potential.texture,this.voxelTexNode.value=g.voxel.textures[0];let O=t.pyramidLevelSizes.length%2==0?0:1,D=1-O;this.pyramid1TexNode.value=g.pyramid[D].texture,this.pyramid2TexNode.value=g.pyramid[O].texture,this._ultraResAtBuild=0}let A=t.material;A.defines===void 0&&(A.defines={}),Cp.includes("nomat")||(A.defines.SHAPEBLEND=t.resolutionLevel),Cp.includes("nomat")||A.setShapeBlendResources?.(o?{resolutionLevel:t.resolutionLevel,pyramidLevelSizes:t.pyramidLevelSizes,triTable:this.triTableTexNode,potential:this.potentialTexNode,voxel:this.voxelTexNode,pyramid1:this.pyramid1TexNode,pyramid2:this.pyramid2TexNode,pyramid1Size:{width:1,height:1},pyramid2Size:{width:1,height:1},cached:h?{...this._vertexBuffers,drawIndex:this._drawIndex}:this._marchBuffers}:{...this._marchResources(t),cached:a?this._marchBuffers:void 0}),this._cachedAtBuild=a;let P=`${t.resolutionLevel}:${this._marchCapacity}`;this._computeNodeKey!==P&&(this._computeNode=null,this._computeNodeKey=P)}if(y)return this._builtOnce=!0,void(this._computeDirty=!0);this._meshBaker!==null&&t._meshSdfWanted.size>0&&this._bakeNextMeshChild(t,e);let b=this._passesRenderer!==e,_=r&&!bF&&!this._computeDirty&&!b&&!t._fieldDirtyFull;if(!(r||this._computeDirty||b)){if(o&&this._refinePending&&this._ultra!==null&&performance.now()-this._lastFieldChangeMs>250)return this._refinePending=!1,this._passesRenderer=e,ar.refines++,void this._runUltra(t,e,!1,this._ultra);if(o&&VE&&this._ultra!==null&&this._ultra.meshlet&&this._lastDispatched===this._ultra&&!this._ultraReadbackPending&&this._updateCullUniforms(t,this._ultra)&&(!this._hasGatherMVP||!this._lastGatherMVP.equals(this._ultra.uniforms.cullMVP.value))){this._lastGatherMVP.copy(this._ultra.uniforms.cullMVP.value),this._hasGatherMVP=!0,ar.regathers++;let T=e;return T.compute(this._ultra.kernels.zero),kE||T.compute(this._ultra.kernels.clearDraw),T.compute(this._ultra.kernels.gather),this._ultra.kernels.stats&&T.compute(this._ultra.kernels.stats),void this._runUltraReadback(t,e)}if(!t.drawRangeNeedsForceUpdate)return void ar.skips++;if(o)return void(this._ultraReadbackPending||this._runUltraReadback(t,e))}if(this._passesRenderer=e,Cp.includes("none")&&ar.readbacksResolved>0)return void(this._computeDirty=!1);let x=e.getRenderTarget(),S=e.getMRT(),w=e.autoClear;if(e.setMRT(null),e.autoClear=!1,ar.lastPass="spatial",e.setRenderTarget(f),kd.material=this.spatialMaterial,kd.render(e),o){e.autoClear=w,e.setRenderTarget(x),e.setMRT(S);let T=this._ultraDrag!==null&&r&&!this._computeDirty;return this._refinePending=T,this._lastFieldChangeMs=performance.now(),this._runUltra(t,e,_,T?this._ultraDrag:this._ultra),void(this._computeDirty=!1)}return Cp==="spatial"&&ar.readbacksResolved>0?(e.autoClear=w,e.setRenderTarget(x),e.setMRT(S),void(this._computeDirty=!1)):(ar.lastPass="potential",e.setRenderTarget(g.potential),kd.material=this.potentialMaterial,kd.render(e),Cp==="potential"&&ar.readbacksResolved>0?(e.autoClear=w,e.setRenderTarget(x),e.setMRT(S),void(this._computeDirty=!1)):(ar.lastPass="voxel",e.setRenderTarget(g.voxel),kd.material=this.voxelMaterial,kd.render(e),Cp==="voxel"&&ar.readbacksResolved>0?(e.autoClear=w,e.setRenderTarget(x),e.setMRT(S),void(this._computeDirty=!1)):(ar.lastPass="pyramid",this._renderPyramid(t,e,g.voxel,g.pyramid),e.autoClear=w,e.setRenderTarget(x),e.setMRT(S),ar.lastPass="march",a&&(this._computeNode===null&&(this._computeNode=function(T,C,M){let A=L_t(T);return At(()=>{let{position:P,normal:O,color:D}=A(Rn.toFloat());C.positions.element(Rn).assign(at(P,1)),C.normals.element(Rn).assign(at(O,0)),C.colors.element(Rn).assign(D)})().compute(M)}(this._marchResources(t),this._marchBuffers,this._marchCapacity)),e.compute(this._computeNode),ar.computes++),void(this._computeDirty=!1))))}_bakeNextMeshChild(t,e){let i=this._meshBaker;for(let[r,s]of t._meshSdfWanted){let n=Hyt(s);if(this._meshBakeFailed.get(r)===n)continue;let a=this._meshSlots.get(r);if(a===void 0){if(this._meshSlots.size>=i.slots)for(let h of this._meshSlots.keys())!t._meshSdfBaked.has(h)&&!t._meshSdfWanted.has(h)&&(this._meshSlots.delete(h),this._meshBakeFailed.delete(h));if(this._meshSlots.size>=i.slots){this._meshWarnedFull||(this._meshWarnedFull=!0,console.warn(`Spline shape blend: more than ${i.slots} distinct mesh children \u2014 the extra meshes are left out of the blend.`));continue}let l=new Set(this._meshSlots.values());for(a=0;l.has(a);)a++;this._meshSlots.set(r,a)}let o=nRt(s);if(o!==null)return i.setTriangles(o.data,o.triCount),i.uniforms.slotOrigin.value.copy(oRt(a)),i.uniforms.triCount.value=o.triCount,i.uniforms.boxHalf.value.copy(o.boxHalf),e.compute(i.kernel),t._meshSdfBaked.set(r,{slot:a,boxHalf:o.boxHalf.clone(),posVersion:n,owner:this}),void t._meshSdfWanted.delete(r);this._meshBakeFailed.set(r,n)}}_updateCullUniforms(t,e){if(!e.meshlet)return!1;let i=this._cullCamera;return VE&&i&&i.projectionMatrix!==void 0&&i.matrixWorldInverse!==void 0?(e.uniforms.cullMVP.value.multiplyMatrices(Vt.unjitteredProjection.value,i.matrixWorldInverse).multiply(t.matrixWorld),e.uniforms.cullEnabled.value=1,!0):(e.uniforms.cullEnabled.value=0,!1)}_runUltra(t,e,i,r){let s=e;ar.lastPass="ultra-kernels",ar.lastDispatchRes=r.resolution,ar.marchPositions=(r.meshlet?this._vertexBuffers:this._marchBuffers).positions.value,this._lastDispatched=r;let n=r.resolution,a=n/4,o=2/(n-1);r.uniforms.activeThreshold.value=vF?1e30:(3*Math.sqrt(3)+4)*o+.25*t._maxBlendK;let l=r.meshlet&&!TF;r.meshlet&&(r.uniforms.adaptCos.value=l?Dut:2);let h=0,u=0,d=0,c=a,p=a,m=a;if(i){let y=r.uniforms.activeThreshold.value+2/(t.spatialDivisions-1)+4/(n-1),v=x=>Math.floor(.5*(x+1)*(n-1)/4),b=x=>Math.min(a-1,Math.max(0,v(x))),_=x=>Math.min(a,Math.max(1,v(x)+1));if(h=b(t._fieldDirtyMin.x-y),u=b(t._fieldDirtyMin.y-y),d=b(t._fieldDirtyMin.z-y),c=_(t._fieldDirtyMax.x+y)-h,p=_(t._fieldDirtyMax.y+y)-u,m=_(t._fieldDirtyMax.z+y)-d,ar.fieldsWindowed++,l){let x=Math.min(a,h+c+1),S=Math.min(a,u+p+1),w=Math.min(a,d+m+1);h=Math.max(0,h-1),u=Math.max(0,u-1),d=Math.max(0,d-1),c=x-h,p=S-u,m=w-d}}else ar.fieldsFull++;ar.lastWindowBricks=c*p*m,r.uniforms.windowOrigin.value.set(h,u,d),r.uniforms.windowSize?.value.set(c,p,m);let f=h===0&&u===0&&d===0&&c===a&&p===a&&m===a,g=[Math.ceil(c/4),Math.ceil(p/4),Math.ceil(m/4)];r.meshlet&&this._updateCullUniforms(t,r)&&(this._lastGatherMVP.copy(r.uniforms.cullMVP.value),this._hasGatherMVP=!0),s.compute(r.kernels.zero),kE||s.compute(r.meshlet?r.kernels.clearDraw:r.kernels.clear),r.needsInit&&r.kernels.init&&(s.compute(r.kernels.init),r.needsInit=!1),s.compute(r.kernels.coarse,g),r.kernels.release&&s.compute(r.kernels.release,g),r.kernels.alloc&&s.compute(r.kernels.alloc,g),r.kernels.meshRelease&&s.compute(r.kernels.meshRelease,g),r.sparse?f?s.compute(r.kernels.sdf):s.compute(r.kernels.sdfWindow,[c,p,m]):s.compute(r.kernels.sdf,[c,p,m]),r.kernels.classify&&s.compute(r.kernels.classify,g),s.compute(r.kernels.color,[Math.ceil(c/2),Math.ceil(p/2),Math.ceil(m/2)]),r.meshlet?(f?(s.compute(r.kernels.verts),s.compute(r.kernels.extract)):(s.compute(r.kernels.vertsWindow,[c,p,m]),s.compute(r.kernels.extractWindow,[c,p,m])),s.compute(r.kernels.gather)):s.compute(r.kernels.extract),r.kernels.stats&&s.compute(r.kernels.stats),ar.computes++,this._ultraReadbackPending?this._ultraReadbackQueued=!0:this._runUltraReadback(t,e)}_disposeRetired(){for(let t of this._ultraRetired)t.dispose();if(this._ultraRetired.length=0,this._retiredStorage.length>0){let t=this._lastRenderer?.backend?.attributeUtils;if(t)for(let e of this._retiredStorage)t.destroyAttribute(e);this._retiredStorage.length=0}for(let t of this._onSettled)t();this._onSettled.length=0}runWhenSettled(t){this._onSettled.push(t)}transferSettleQueue(t){t._onSettled.push(...this._onSettled),this._onSettled.length=0}_runUltraReadback(t,e){let i=this._lastDispatched??this._ultra,r=e;this._ultraReadbackPending=!0,ar.readbackPending=!0,r.getArrayBufferAsync(i.counterAttribute).then(s=>{if(this._ultraReadbackPending=!1,ar.readbackPending=!1,this.retired)return;this._disposeRetired();let n=new Uint32Array(s),a=i.meshlet?Math.floor(n[3]/3):n[0];if(ar.readbacksResolved++,ar.lastTotal=a,i.sparse&&n.length>2&&n[2]>0&&(this._ultraWantedPoolBricks=Math.ceil(1.5*Math.max(n[1],i.poolBricks)),this._computeDirty=!0),i.meshlet&&n.length>5&&n[5]>0){let l=Math.min(24*n[4],this._maxMarchSlots(e));l>this._marchCapacity&&(this._ultraWantedCapacity=Math.max(this._ultraWantedCapacity,l),this._computeDirty=!0)}if(i.meshlet&&n.length>7&&n[7]>0){let l=Math.min(Math.ceil(1.5*n[6]),Math.floor(this._maxMarchSlots(e)/64));l>i.vertexBlocks&&(this._ultraWantedVertexBlocks=Math.max(this._ultraWantedVertexBlocks,l),this._computeDirty=!0)}let o=Math.floor(this._marchCapacity/3);if(t.geometry.drawRange.count=3*Math.min(Math.ceil(1.25*a),o),t.markSceneShadowsDirty(),t.drawRangeNeedsForceUpdate=!1,this._ultraReadbackQueued&&(this._ultraReadbackQueued=!1,this._runUltraReadback(t,e)),a>o){let l=Math.min(3*a,this._maxMarchSlots(e));l>this._marchCapacity&&(this._ultraWantedCapacity=l,this._computeDirty=!0)}}).catch(()=>{ar.readbackErrors++,this._ultraReadbackPending=!1,ar.readbackPending=!1})}_renderPyramid(t,e,i,r){let s=t.pyramidLevelSizes,n=s.length-1-1;L2.value=0,qy.value=0;for(let o=n;o>=0;o--){let l=o%2==n%2?r[0]:r[1],h=o===n?i:o%2==n%2?r[1]:r[0];av.value=h.textures.length>1?h.textures[1]:h.texture,R7.value=h.width,D7.value=h.height;let u=s[o];o===2&&t.resolutionLevel%2!=0&&(u=3),O7.value=u,l.viewport.set(qy.value,0,u,u),e.setRenderTarget(l),kd.material=hRt(),kd.render(e),l.viewport.set(0,0,l.width,l.height);let d=L2.value;L2.value=qy.value,qy.value=d,o<n&&(qy.value+=s[o+1])}ar.lastPass="pyramid-readback";let a=s.length%2==0?0:1;e.readRenderTargetPixelsAsync(r[a],r[a].width-1,0,1,1).then(o=>{let l=o[0];ar.readbacksResolved++,ar.lastTotal=l,!this.retired&&(this._disposeRetired(),(3*l>t.geometry.drawRange.count||t.drawRangeNeedsForceUpdate)&&(t.geometry.drawRange.count=3*Math.floor(1.2*l)),t.drawRangeNeedsForceUpdate=!1,this._marchBuffers!==null&&t.geometry.drawRange.count>this._marchCapacity&&(this._computeDirty=!0))}).catch(()=>{})}dispose(){for(let s of[...this.spatialTargets,...this.potentialTargets,...this.voxelTargets,...this.pyramidTargets.flat()])s?.dispose();this.spatialMaterial?.dispose(),this.potentialMaterial?.dispose(),this.voxelMaterial?.dispose();let t=this._lastRenderer?.backend?.attributeUtils,e=s=>{if(t&&s!==null)for(let n of[s.positions,s.normals,s.colors]){let a=n.value;a&&t.destroyAttribute(a)}},i=s=>{if(s!==null){for(let n of Object.values(s.kernels))n?.dispose?.();if(t)for(let n of s.storageAttributes)t.destroyAttribute(n)}};e(this._marchBuffers),e(this._vertexBuffers);let r=this._drawIndex?.value;t&&r&&t.destroyAttribute(r),this._drawIndex=null,this._computeNode?.dispose?.(),this._marchBuffers=null,this._vertexBuffers=null,this._computeNode=null,this._computeNodeKey="",this._marchCapacity=0,i(this._ultra),this._ultra?.sdfTexture.dispose(),this._ultra?.colorTexture.dispose(),this._ultra?.coarseTexture.dispose(),this._ultra=null,i(this._ultraDrag),this._ultraDrag?.sdfTexture.dispose(),this._ultraDrag?.colorTexture.dispose(),this._ultraDrag?.coarseTexture.dispose(),this._ultraDrag=null,this._meshBaker?.atlas.dispose(),this._meshBaker=null,this._lastDispatched=null,this._disposeRetired(),this._lastRenderer=null}},W1=new WeakMap,F2=new WeakMap,Ov=[]}),cRt=U(()=>{DD(),Nq(),dRt(),m5=rRt,qW=t=>function(e){let i=W1.get(e);if(i?.wantsReplacement){let r=F2.get(e);F2.set(e,i),i.retired=!0;let s=new I7(i.capacityHint,i.poolHint,i.vertHint);i.transferSettleQueue(s),r&&s.runWhenSettled(()=>r.dispose()),i=s,W1.set(e,i)}return i||(i=new I7,W1.set(e,i)),i}(t),function(t){HW=t}({release:t=>function(e){let i=W1.get(e),r=F2.get(e);W1.delete(e),F2.delete(e),r&&Ov.push(r),i&&(i.retired=!0,Ov.push(i))}(t),drainRetired:uRt})});function pRt(){let t=CS.length;if(t>0){for(let e of CS)e.dispose();CS.length=0}return t}var ao,fa,jl,Ze,Ph,Out,MF,Iut,Nut,zE,But,LE,kut,Vut,AF,Vd,Hy,bw,W_t,U2,CS,z5,$y,q_t,H_t,$_t,X_t,Y_t,K_t,mRt=U(()=>{ot(),cr(),je(),Iyt(),Oyt(),ao=[64,1,1],jl=(fa=Tg)-1,Ze=(t,e)=>e!==void 0?mt(t,e):mt(t),Ph=(t,e)=>{let i=t.xyz,r=Kr(i,e),s=Kr(i,r);return e.add(r.mul(t.w).mul(2)).add(s.mul(2))},Out=t=>{let e=Bt(t,t);return e.lessThan(1e-10).select(at(0,0,0,1),t.mul(dq(Kt(e,1e-20))))},MF=At(([t,e])=>{let i=t,r=e,s=Bt(i,r).add(1).toVar(),n=j(0).toVar();return vt(s.lessThan(1e-7),()=>{s.assign(0),vt(ke(i.x).greaterThan(ke(i.z)),()=>{n.assign(j(i.y.negate(),i.x,0))}).Else(()=>{n.assign(j(0,i.z.negate(),i.y))})}).Else(()=>{n.assign(Kr(i,r))}),Out(at(n,s))}),Iut=t=>t.sub(de(t.mul(1/289)).mul(289)),Nut=t=>t.sub(de(t.mul(1/289)).mul(289)),zE=t=>Nut(t.mul(34).add(10).mul(t)),But=t=>at(1.79284291400159).sub(t.mul(.85373472095314)),LE=At(([t])=>{let e=t,i=1/6,r=1/3,s=de(e.add(Bt(e,j(r)))).toVar(),n=e.sub(s).add(Bt(s,j(i))).toVar(),a=Si(n.yzx,n.xyz).toVar(),o=j(1).sub(a).toVar(),l=ti(a,o.zxy).toVar(),h=Kt(a,o.zxy).toVar(),u=n.sub(l).add(i).toVar(),d=n.sub(h).add(r).toVar(),c=n.sub(.5).toVar();s.assign(Iut(s));let p=zE(zE(zE(at(0,l.z,h.z,1).add(s.z)).add(s.y).add(at(0,l.y,h.y,1))).add(s.x).add(at(0,l.x,h.x,1))).toVar(),m=.142857142857,f=2*m,g=.5*m-1,y=m,v=p.sub(de(p.mul(y*y)).mul(49)).toVar(),b=de(v.mul(y)).toVar(),_=de(v.sub(b.mul(7))).toVar(),x=b.mul(f).add(g).toVar(),S=_.mul(f).add(g).toVar(),w=at(1).sub(ke(x)).sub(ke(S)).toVar(),T=at(x.xy,S.xy).toVar(),C=at(x.zw,S.zw).toVar(),M=de(T).mul(2).add(1).toVar(),A=de(C).mul(2).add(1).toVar(),P=Si(w,at(0)).negate().toVar(),O=T.xzyw.add(M.xzyw.mul(P.xxyy)).toVar(),D=C.xzyw.add(A.xzyw.mul(P.zzww)).toVar(),N=j(O.xy,w.x).toVar(),z=j(O.zw,w.y).toVar(),k=j(D.xy,w.z).toVar(),B=j(D.zw,w.w).toVar(),V=But(at(Bt(N,N),Bt(z,z),Bt(k,k),Bt(B,B))).toVar();N.assign(N.mul(V.x)),z.assign(z.mul(V.y)),k.assign(k.mul(V.z)),B.assign(B.mul(V.w));let q=Kt(at(.5).sub(at(Bt(n,n),Bt(u,u),Bt(d,d),Bt(c,c))),at(0)).toVar();return q.assign(q.mul(q)),Bt(q.mul(q),at(Bt(N,n),Bt(z,u),Bt(k,d),Bt(B,c))).mul(105)}),kut=class extends Ag{constructor(t,e,i,r,s){super(),this.tangentWorld=t,this.specularPower=e,this.specularIntensity=i,this.diffuseIntensity=r,this.ambientFloor=s}direct(t){let{lightDirection:e,lightColor:i,reflectedLight:r}=t,s=be(ih.mul(at(this.tangentWorld,0)).xyz),n=e,a=Qv,o=be(n.add(a)),l=Kt(ci(Kr(s,n)),0),h=Kt(ci(Kr(s,o)),0);r.directDiffuse.addAssign(i.mul(l).mul(this.diffuseIntensity).mul(ko.rgb)),r.directSpecular.addAssign(i.mul(Lo(h,this.specularPower)).mul(this.specularIntensity).mul(j(1,.95,.9)))}indirect(t){let{irradiance:e,ambientOcclusion:i,reflectedLight:r}=t.context;r.indirectDiffuse.addAssign(e.mul(1/Math.PI).add(this.ambientFloor).mul(ko.rgb)),r.indirectDiffuse.mulAssign(i)}},Vut=class extends Ag{direct(t){let{lightDirection:e,lightColor:i,reflectedLight:r}=t,s=e,n=Ra,a=Qv,o=be(s.add(a)),l=Bt(n,s).clamp(),h=Bt(n,o).clamp();r.directDiffuse.addAssign(i.mul(l).mul(.85).mul(ko.rgb)),r.directSpecular.addAssign(i.mul(Lo(h,60)).mul(.3).mul(j(.3,.28,.25)))}indirect(t){let{irradiance:e,ambientOcclusion:i,reflectedLight:r}=t.context;r.indirectDiffuse.addAssign(e.mul(1/Math.PI).add(.15).mul(ko.rgb)),r.indirectDiffuse.mulAssign(i)}},AF=class extends Pe{constructor(t){super(),this.model=t,this.lights=!0}setupLightingModel(){return this.model}},Vd=new we,Hy=new we,bw=new E,W_t=class{constructor(){this.uNumStrands=Ze(0,"int"),this.uNumVerts=Ze(0,"int"),this.uDamping=Ze(.03),this.uLocalStiffness=Ze(.67),this.uGlobalStiffness=Ze(.5),this.uGlobalRange=Ze(.15),this.uStiffnessFalloff=Ze(.1),this.uGravity=Ze(0),this.uVspCoeff=Ze(.01),this.uVspThreshold=Ze(50),this.uKink=Ze(0),this.uKinkFreq=Ze(0),this.uUnitScale=Ze(100),this.uClumpStrength=Ze(0),this.uClumpSize=Ze(32,"int"),this.uClumpTipScale=Ze(1.5),this.uReset=Ze(1),this.uHasWind=Ze(0),this.uWind0=Ze(new E),this.uWind1=Ze(new E),this.uWind2=Ze(new E),this.uWind3=Ze(new E),this.uBoneQuat=Ze(new Se(0,0,0,1)),this.uBoneTrans=Ze(new E),this.uDeltaQuat=Ze(new Se(0,0,0,1)),this.uPrevBoneTrans=Ze(new E),this.uHairRoot=Ze(new se),this.uHairMid=Ze(new se),this.uHairTip=Ze(new se),this.uHeadColor=Ze(new se),this.uNoiseA=Ze(new se),this.uNoiseB=Ze(new se),this.uNoiseC=Ze(new se),this.uNoiseD=Ze(new se),this.uNoiseScale=Ze(.018),this.uNoiseMixHair=Ze(0),this.uNoiseMixHead=Ze(0),this.uWidth=Ze(.525),this.uSpecPow=Ze(40),this.uSpecInt=Ze(.4),this.uDiffInt=Ze(.6),this.uAmbInt=Ze(.25),this.uOpacity=Ze(1),this.uTipFade=Ze(.4),this.uColorSource=Ze(0),this.uShadeRoot=Ze(.6),this.uShadeTip=Ze(1.15),this.uShadowTexelWorld=Ze(0),this._armed=!1,this._uploadedGeneration=-1,this._prevBoneQuat=new we,this._prevBonePos=new E,this._hasPrevBone=!1,this._renderer=null,this.initialPos=Zr(ic,"vec4"),this.rootColors=Zr(Sv,"vec4"),this.positions=Zr(ic,"vec4"),this.positionsPrev=Zr(ic,"vec4"),this.positionsPrevPrev=Zr(ic,"vec4"),this.tangents=Zr(ic,"vec4"),this.restLengths=Zr(ic,"float"),this.vspQuats=Zr(Sv,"vec4"),this.vspTrans=Zr(Sv,"vec4"),this.kIntegrate=this._buildIntegrate(),this.kStrandLevel=this._buildStrandLevel(),this.kVsp=this._buildVsp(),this.kLocalShape=this._buildLocalShape(),this.kLengthWind=this._buildLengthWind(),this.kClump=this._buildClump(),this.kRigidFollow=this._buildRigidFollow(),this.ribbonMaterial=this._buildRibbonMaterial(),this.scalpMaterial=this._buildScalpMaterial()}boneQuatNode(){return this.uBoneQuat}boneTransNode(){return this.uBoneTrans}_buildIntegrate(){return At(()=>{let t=ct(Rn).toVar();vt(t.greaterThanEqual(this.uNumVerts),()=>{fr()});let e=t.div(fa).toVar(),i=t.sub(e.mul(fa)).toVar(),r=this.boneQuatNode(),s=this.boneTransNode(),n=this.initialPos.element(t).toVar(),a=at(Ph(r,n.xyz).add(s),n.w).toVar(),o=this.positions.element(t).toVar(),l=this.positionsPrev.element(t).toVar(),h=l.toVar();vt(this.uReset.greaterThan(.5),()=>{o.assign(a),h.assign(a)});let u=a.toVar();vt(o.w.greaterThan(0),()=>{let d=I(Wp),c=kD(this.uDamping.negate().mul(d).mul(60)),p=o.xyz.add(o.xyz.sub(h.xyz).mul(c)).add(j(0,-1,0).mul(this.uGravity).mul(d).mul(d));u.assign(at(p,o.w))}),vt(this.uGlobalStiffness.greaterThan(0).and(this.uGlobalRange.greaterThan(0)).and(u.w.greaterThan(0)).and(i.toFloat().lessThan(this.uGlobalRange.mul(fa))),()=>{let d=t.sub(i),c=this.initialPos.element(d),p=be(Ph(r,c.xyz)).y.mul(.5).add(.5),m=this.uGlobalStiffness.mul(Lo(Kt(p,0),this.uStiffnessFalloff)),f=a.xyz.sub(u.xyz).mul(m);u.assign(at(u.xyz.add(f),u.w))}),vt(this.uKink.greaterThan(0).and(u.w.greaterThan(0)),()=>{let d=i.toFloat().div(fa),c=e.sub(e.div(256).mul(256)).toFloat().mul(.0245),p=d.mul(this.uKinkFreq).mul(6.2831853).add(c),m=this.uKink.mul(d).mul(.15).mul(this.uUnitScale),f=be(a.xyz.sub(s)).toVar(),g=j(0).toVar();vt(ke(f.y).lessThan(.99),()=>{g.assign(be(Kr(f,j(0,1,0))))}).Else(()=>{g.assign(be(Kr(f,j(1,0,0))))});let y=be(Kr(f,g)),v=g.mul(Bn(p)).mul(m).add(y.mul(Xa(p.mul(1.3).add(c))).mul(m).mul(.7));u.assign(at(u.xyz.add(v),u.w))}),this.positionsPrevPrev.element(t).assign(l),this.positionsPrev.element(t).assign(o),this.positions.element(t).assign(u)})().compute(ao[0],ao)}_buildStrandLevel(){return At(()=>{let t=ct(Rn).toVar();vt(t.greaterThanEqual(this.uNumStrands),()=>{fr()});let e=t.mul(fa).toVar(),i=this.positionsPrevPrev.element(e.add(1)),r=this.positionsPrev.element(e),s=this.positionsPrev.element(e.add(1)),n=this.positions.element(e),a=this.positions.element(e.add(1)),o=s.xyz.sub(r.xyz),l=a.xyz.sub(n.xyz),h=o.div(Kt(ci(o),1e-7)),u=l.div(Kt(ci(l),1e-7)),d=MF(h,u).toVar(),c=n.xyz.sub(Ph(d,r.xyz)),p=this.uVspCoeff.toVar(),m=ci(a.xyz.sub(s.xyz.mul(2)).add(i.xyz));vt(m.greaterThan(this.uVspThreshold),()=>{p.assign(1)}),this.vspQuats.element(t).assign(d),this.vspTrans.element(t).assign(at(c,p))})().compute(ao[0],ao)}_buildVsp(){return At(()=>{let t=ct(Rn).toVar();vt(t.greaterThanEqual(this.uNumVerts),()=>{fr()});let e=t.div(fa).toVar(),i=t.sub(e.mul(fa)).toVar();vt(i.lessThan(2),()=>{fr()});let r=this.vspQuats.element(e),s=this.vspTrans.element(e),n=s.w,a=this.positions.element(t).toVar(),o=this.positionsPrev.element(t).toVar(),l=h=>at(h.xyz.mul(I(1).sub(n)).add(Ph(r,h.xyz).add(s.xyz).mul(n)),h.w);this.positions.element(t).assign(l(a)),this.positionsPrev.element(t).assign(l(o))})().compute(ao[0],ao)}_buildLocalShape(){return At(()=>{let t=ct(Rn).toVar();vt(t.greaterThanEqual(this.uNumStrands),()=>{fr()});let e=t.mul(fa).toVar(),i=ti(this.uLocalStiffness,.95).mul(.5),r=this.boneQuatNode();Qi(jl-1,({i:s})=>{let n=e.add(s).add(1).toVar(),a=this.positions.element(n).toVar(),o=this.positions.element(n.add(1)).toVar(),l=this.positions.element(n.sub(1)),h=Ph(r,this.initialPos.element(n).xyz),u=Ph(r,this.initialPos.element(n.add(1)).xyz),d=Ph(r,this.initialPos.element(n.sub(1)).xyz),c=a.xyz.sub(l.xyz),p=u.sub(h),m=h.sub(d),f=MF(m.div(Kt(ci(m),1e-7)),c.div(Kt(ci(c),1e-7))),g=Ph(f,p).add(a.xyz).sub(o.xyz).mul(i);vt(a.w.greaterThan(0),()=>{a.assign(at(a.xyz.sub(g),a.w))}),vt(o.w.greaterThan(0),()=>{o.assign(at(o.xyz.add(g),o.w))}),this.positions.element(n).assign(a),this.positions.element(n.add(1)).assign(o)})})().compute(ao[0],ao)}_buildLengthWind(){return At(()=>{let t=ct(Rn).toVar();vt(t.greaterThanEqual(this.uNumStrands),()=>{fr()});let e=t.mul(fa).toVar();vt(this.uHasWind.greaterThan(.5),()=>{let i=t.sub(t.div(20).mul(20)).toFloat().div(20),r=this.uWind0.mul(i).add(this.uWind1.mul(I(1).sub(i))).add(this.uWind2.mul(i)).add(this.uWind3.mul(I(1).sub(i))).toVar();Qi(jl-2,({i:s})=>{let n=e.add(s).add(2).toVar(),a=this.positions.element(n).toVar(),o=this.positions.element(n.add(1)),l=a.xyz.sub(o.xyz),h=Kr(Kr(l,r),l).negate();a.assign(at(a.xyz.add(h.mul(Wp).mul(.1)),a.w)),this.positions.element(n).assign(a)})}),Qi(5,()=>{Qi(jl,({i})=>{let r=e.add(i).toVar(),s=this.positions.element(r).toVar(),n=this.positions.element(r.add(1)).toVar(),a=this.restLengths.element(r),o=n.xyz.sub(s.xyz),l=Kt(ci(o),1e-7),h=I(1).sub(a.div(l)),u=o.mul(h),d=s.w.greaterThan(0),c=n.w.greaterThan(0),p=d.select(c.select(I(.5),I(1)),I(0)),m=c.select(d.select(I(.5),I(1)),I(0));s.assign(at(s.xyz.add(u.mul(p)),s.w)),n.assign(at(n.xyz.sub(u.mul(m)),n.w)),this.positions.element(r).assign(s),this.positions.element(r.add(1)).assign(n)})}),Qi(jl,({i})=>{let r=e.add(i).add(1).toVar(),s=this.positions.element(r.sub(1)),n=this.positions.element(r).toVar(),a=n.xyz.sub(s.xyz),o=Kt(ci(a),1e-7),l=this.restLengths.element(r.sub(1));vt(o.greaterThan(l),()=>{n.assign(at(s.xyz.add(a.div(o).mul(l)),n.w)),this.positions.element(r).assign(n)})}),Qi(fa,({i})=>{let r=e.add(i).toVar(),s=i.equal(fa-1).select(r.sub(1),r).toVar(),n=be(this.positions.element(s.add(1)).xyz.sub(this.positions.element(s).xyz));this.tangents.element(r).assign(at(n,0))})})().compute(ao[0],ao)}_buildClump(){return At(()=>{let t=ct(Rn).toVar();vt(t.greaterThanEqual(this.uNumStrands),()=>{fr()});let e=this.uClumpSize.toVar(),i=t.div(e).mul(e).toVar();vt(t.equal(i),()=>{fr()}),vt(i.greaterThanEqual(this.uNumStrands),()=>{fr()});let r=t.mul(fa).toVar(),s=i.mul(fa).toVar();Qi(jl,({i:n})=>{let a=n.add(1).toVar(),o=a.toFloat().div(jl),l=this.uClumpStrength.mul(Lo(o,I(1).div(Kt(this.uClumpTipScale,.5)))),h=r.add(a).toVar(),u=this.positions.element(h).toVar(),d=this.positions.element(s.add(a));u.assign(at($t(u.xyz,d.xyz,l),u.w)),this.positions.element(h).assign(u)})})().compute(ao[0],ao)}_buildRigidFollow(){return At(()=>{let t=ct(Rn).toVar();vt(t.greaterThanEqual(this.uNumVerts),()=>{fr()});let e=this.uDeltaQuat,i=this.uPrevBoneTrans,r=this.boneTransNode(),s=a=>{let o=a.element(t).toVar();o.assign(at(Ph(e,o.xyz.sub(i)).add(r),o.w)),a.element(t).assign(o)};s(this.positions),s(this.positionsPrev),s(this.positionsPrevPrev);let n=this.tangents.element(t).toVar();n.assign(at(Ph(e,n.xyz),0)),this.tangents.element(t).assign(n)})().compute(ao[0],ao)}pastelNoise(t){let e=t.sub(this.boneTransNode()).mul(this.uNoiseScale),i=LE(e).mul(.5).add(.5),r=LE(e.add(j(31.7,17.3,53.1))).mul(.5).add(.5),s=LE(e.mul(.7).add(j(71.9,11.2,43.8))).mul(.5).add(.5),n=$t(this.uNoiseA,this.uNoiseB,i);return n=$t(n,this.uNoiseC,r.mul(.6)),n=$t(n,this.uNoiseD,s.mul(.25)),n}_buildRibbonMaterial(){let t=Lr("vec3","vHairTangent"),e=Lr("vec3","vHairNormal"),i=Lr("vec2","vHairUv"),r=Lr("float","vHairRand"),s=Lr("vec3","vHairInherit"),n=new AF(new kut(t,this.uSpecPow,this.uSpecInt,this.uDiffInt,this.uAmbInt));n.name="SplineHairRibbons",n.userData.hairShadowVariant="texel-floor-v6",n.transparent=!1,n.depthTest=!0,n.depthWrite=!0,n.side=Xs;let a=l=>At(()=>{let h=ct(Rn).toVar(),u=h.div(jl).toVar(),d=h.sub(u.mul(jl)).toVar(),c=u.mul(fa).add(d).toVar(),p=ct(SS).toVar(),m=p.bitAnd(1).toFloat().toVar(),f=p.shiftRight(1).bitAnd(1).toFloat().toVar(),g=this.positions.element(c).xyz.toVar(),y=this.positions.element(c.add(1)).xyz.toVar(),v=this.tangents.element(c).xyz,b=this.tangents.element(c.add(1)).xyz,_=$t(g,y,f).toVar(),x=$t(v,b,f).toVar(),S=be(Oc.sub(_)),w=Kr(x,S).toVar(),T=ci(w).toVar();w.assign(T.greaterThan(1e-7).select(w.div(T),j(1,0,0)));let C=d.toFloat().div(jl),M=d.add(1).toFloat().div(jl),A=$t(C,M,f).toVar(),P=this.uWidth.mul(I(1).sub(A.mul(this.uTipFade))).toVar(),O=l?(()=>{let V=this.uShadowTexelWorld,q=V.greaterThan(0).select(V.mul(1.5).clamp(I(2),I(8)),I(0));return Kt(q.sub(P),0).toVar()})():null;O&&P.addAssign(O);let D=m.mul(2).sub(1),N=_.add(w.mul(P).mul(D)).toVar();O&&N.assign(N.sub(S.mul(O)));let z=this.positionsPrev.element(c).xyz,k=this.positionsPrev.element(c.add(1)).xyz;UD.assign($t(z,k,f).add(w.mul(P).mul(D)));let B=Di(Bn(u.toFloat().mul(12.9898)).mul(43758.5453));return r.assign(B),s.assign(this.rootColors.element(u).xyz),t.assign(x),e.assign(be(S.sub(x.mul(Bt(x,S))))),i.assign(st(m,A)),N}),o=At(()=>{let l=i.y,h=$t(this.uHairRoot,this.uHairMid,ti(l.mul(2),1)),u=l.lessThan(.5).select(h,$t(this.uHairMid,this.uHairTip,l.sub(.5).mul(2))).toVar(),d=s.mul($t(this.uShadeRoot,this.uShadeTip,l));u.assign(this.uColorSource.greaterThan(.5).select(d,u)),u.assign($t(u,this.pastelNoise(Wo),this.uNoiseMixHair));let c=I(1).sub(ke(i.x.sub(.5)).mul(2));return I(1).sub(l.mul(this.uTipFade)).mul(Lo(Kt(c,0),.5)).toVar().lessThan(.25).discard(),r.greaterThanEqual(this.uOpacity).discard(),at(u,1)});return n.positionNode=a(!1)(),n.castShadowPositionNode=a(!0)(),n.normalNode=e,n.colorNode=o(),n.needsUpdate=!0,n}_buildScalpMaterial(){let t=new AF(new Vut);t.name="SplineHairScalp";let e=At(()=>{let i=$t(this.uHeadColor,this.pastelNoise(Wo),this.uNoiseMixHead);return at(i,1)});return t.colorNode=e(),t.needsUpdate=!0,t}update(t,e){let i=e;if(i.backend?.isWebGPUBackend!==!0||(this._renderer=i,t.visible===!1))return;if(!this._armed){this._armed=!0;let o=t.ribbonMesh.material;t.ribbonMesh.material=this.ribbonMaterial,o.dispose?.();let l=t.scalpMesh.material;t.scalpMesh.material=this.scalpMaterial,l.dispose?.(),t.ribbonMesh.visible=!0}t.checkDataDrift();let r=t.activeGuideStrands,s=r*fa;t.generation!==this._uploadedGeneration&&(this._uploadedGeneration=t.generation,this.initialPos.value.array.set(t.roots.initialPositions),this.initialPos.value.needsUpdate=!0,this.restLengths.value.array.set(t.roots.restLengths),this.restLengths.value.needsUpdate=!0,this.rootColors.value.array.set(t.roots.rootColors),this.rootColors.value.needsUpdate=!0,t.ribbonMesh.geometry.instanceCount=r*jl,t.resetRequested=!0),this._syncUniforms(t),t.boneTransform(Vd,bw),this.uBoneQuat.value.set(Vd.x,Vd.y,Vd.z,Vd.w),this.uBoneTrans.value.copy(bw);let n=this._hasPrevBone&&(Math.abs(this._prevBoneQuat.dot(Vd))<.9999995||this._prevBonePos.distanceToSquared(bw)>1e-8),a=Math.floor(t.pendingSimSeconds/Wp);a>4&&(a=4),t.pendingSimSeconds=Math.max(0,Math.min(t.pendingSimSeconds-a*Wp,Wp)),t.resetRequested&&a<1&&(a=1),a<1&&n&&(Hy.copy(this._prevBoneQuat).invert().premultiply(Vd),this.uDeltaQuat.value.set(Hy.x,Hy.y,Hy.z,Hy.w),this.uPrevBoneTrans.value.copy(this._prevBonePos),this._dispatch(i,this.kRigidFollow,s));for(let o=0;o<a;o++){this.uReset.value=t.resetRequested&&o===0?1:0,t.simTime+=Wp,this._updateWind(t),this._dispatch(i,this.kIntegrate,s),this._dispatch(i,this.kStrandLevel,r),this._dispatch(i,this.kVsp,s);for(let l=0;l<2;l++)this._dispatch(i,this.kLocalShape,r);this._dispatch(i,this.kLengthWind,r),t.data.clumpStrength>.001&&this._dispatch(i,this.kClump,r)}a>0&&(t.resetRequested=!1),this._prevBoneQuat.copy(Vd),this._prevBonePos.copy(bw),this._hasPrevBone=!0}_dispatch(t,e,i){e.count=i,t.compute(e)}_updateWind(t){let e=t.data,i=Math.max(t.roots.unitScale,.001),r=e.windStrength/i;this.uHasWind.value=e.windStrength>.001?1:0;let s=.7*t.simTime,n=Math.sin(s)*r,a=Math.cos(s)*r*.5;this.uWind0.value.set(n,0,a),this.uWind1.value.set(.7*n,.5*r,1.2*a),this.uWind2.value.set(.3*-n,0,.5*a),this.uWind3.value.set(.5*n,-.3*r,.8*-a)}_shadowTexelWorld(t){let e=t;for(;e.parent;)e=e.parent;let i=e;if(!i?.traverse)return 0;let r=0;return i.traverse(s=>{let n=s;if(n.isDirectionalLight!==!0||n.castShadow!==!0||n.visible===!1)return;let a=n.shadow?.camera,o=n.shadow?.mapSize?.x??0;typeof a?.right!="number"||typeof a?.left!="number"||o<=0||(r=Math.max(r,(a.right-a.left)/o))}),r}_syncUniforms(t){let e=t.data,i=t.roots.unitScale;this.uNumStrands.value=t.activeGuideStrands,this.uNumVerts.value=t.activeGuideStrands*fa,this.uDamping.value=e.damping,this.uLocalStiffness.value=e.localStiffness,this.uGlobalStiffness.value=e.globalStiffness,this.uGlobalRange.value=e.globalRange,this.uStiffnessFalloff.value=e.stiffnessFalloff,this.uGravity.value=e.gravity*i,this.uVspCoeff.value=e.vspCoefficient,this.uVspThreshold.value=.5*i,this.uKink.value=e.kink,this.uKinkFreq.value=e.kinkFrequency,this.uUnitScale.value=i,this.uClumpStrength.value=e.clumpStrength,this.uClumpSize.value=Math.max(1,Math.round(e.clumpSize)),this.uClumpTipScale.value=e.clumpTipScale;let r=(n,a)=>{n.value.setRGB(a.r,a.g,a.b,Ns)};r(this.uHairRoot,e.hairRootColor),r(this.uHairMid,e.hairMidColor),r(this.uHairTip,e.hairTipColor),r(this.uHeadColor,e.headColor),r(this.uNoiseA,e.noiseColorA),r(this.uNoiseB,e.noiseColorB),r(this.uNoiseC,e.noiseColorC),r(this.uNoiseD,e.noiseColorD);let s=e.noiseEnabled?1:0;this.uNoiseScale.value=e.noiseScale/Math.max(i,.001),this.uNoiseMixHair.value=e.noiseMixHair*s,this.uNoiseMixHead.value=e.noiseMixHead*s,this.uWidth.value=.003*e.hairWidth*Lh*t.widthWorldScale,this.uShadowTexelWorld.value=this._shadowTexelWorld(t),this.uColorSource.value=e.hairColorSource==="object"&&e.headShape==="object"&&e.baseObjectId?1:0,this.uShadeRoot.value=e.hairShadeRoot??.6,this.uShadeTip.value=e.hairShadeTip??1.15,this.uSpecPow.value=e.specularPower,this.uSpecInt.value=e.specularIntensity,this.uDiffInt.value=e.diffuseIntensity,this.uAmbInt.value=e.ambientIntensity,this.uOpacity.value=e.opacity,this.uTipFade.value=e.tipFade}dispose(){for(let e of[this.kIntegrate,this.kStrandLevel,this.kVsp,this.kLocalShape,this.kLengthWind,this.kClump,this.kRigidFollow])e.dispose();this.ribbonMaterial.dispose(),this.scalpMaterial.dispose();let t=this._renderer?.backend?.attributeUtils;if(t)for(let e of[this.initialPos,this.rootColors,this.positions,this.positionsPrev,this.positionsPrevPrev,this.tangents,this.restLengths,this.vspQuats,this.vspTrans])t.destroyAttribute(e.value);this._renderer=null}},U2=new WeakMap,CS=[]}),fRt=U(()=>{GW(),mRt(),UW=t=>function(e){let i=U2.get(e);return i===void 0&&(i=new W_t,U2.set(e,i)),i}(t),function(t){jW=t}({release:t=>function(e){let i=U2.get(e);i!==void 0&&(U2.delete(e),CS.push(i))}(t),drainRetired:pRt})}),Z_t=U(()=>{z5=`
|
|
2018
2018
|
const PI: f32 = 3.14159265358979323846;
|
|
@@ -5119,11 +5119,11 @@ void main() {
|
|
|
5119
5119
|
void main() {
|
|
5120
5120
|
vec4 texel = texture2D( tDiffuse, vUv );
|
|
5121
5121
|
gl_FragColor = texel;
|
|
5122
|
-
}`}),W4t=new class{constructor(t){this._mesh=new gr(G4t,t)}dispose(){this._mesh.geometry.dispose()}render(t){t.render(this._mesh,j4t)}get material(){return this._mesh.material}set material(t){this._mesh.material=t}}(twt),$F=null,XF=null,q4t=Je.identity(),ewt=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||vS.add(this),this.context.shared.requestRender()},this._innerApplySize=()=>{let n=this.width,a=this.height;this.renderer.dpr=Ndt(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 Lq(zt.generateUUID(),rj.defaultData,{dpr:window.devicePixelRatio,shared:r.shared}),this.canvas=($F===null&&($F=document.createElement("canvas")),$F),this.renderer=(s=this.canvas,XF===null&&(XF=new B4t(s)),XF),this.promise=this.init(),this.renderTarget=new xg(1,1,{type:si,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 DG(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{twt.uniforms.tDiffuse.value=this.canvasTexture;let e=t.getRenderTarget();t.setRenderTarget(this.renderTarget),t.clear(),W4t.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=q4t,this.isScreenSpace&&(this.frameOverride.fill.color=qi.from0to1([0,0,0,0])),this.frameOverride.data={...this.frameOverride.data,width:e,height:i},iwt({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 h=Ndt(n,a,o,l),u=Math.max(o,512/Math.min(n,a)),d=Math.min(u,h);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 Yu)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 iwt({objectOverride:t,objectRoot:e,newParentWidth:i,newParentHeight:r,initialParentWidth:s,initialParentHeight:n}){if(t instanceof Yu&&e instanceof Yu||t instanceof _m&&e instanceof _m)for(let a=0,o=t.children.length;a<o;a++){let l=t.children[a],h=e.children[a];l&&h&&l.uuid===h.uuid&&H4t({objectOverride:l,objectRoot:h,newParentWidth:i,newParentHeight:r,initialParentWidth:s,initialParentHeight:n})}}function H4t({objectOverride:t,objectRoot:e,newParentWidth:i,newParentHeight:r,initialParentWidth:s,initialParentHeight:n}){let[a,o]=function(d){if(YF(d))return[d.width,d.height];if(d instanceof X5){let[c,p]=d.getHalfSize();return[2*c,2*p]}if(d instanceof _m){let[c,p]=d.recursiveBBox.getHalfSize();return[2*c,2*p]}return[0,0]}(e),{width:l,height:h,position:u}=Jxt({constraints:t.data,newParentWidth:i,newParentHeight:r,initialParentWidth:s,initialParentHeight:n,objectInitialWidth:a,objectInitialHeight:o,objectInitialPosition:e.position});if(t.position=u,t.data={...t.data,position:u},t.states)for(let d in t.states)$4t({stateId:d,objectOverride:t,objectRoot:e,newParentWidth:i,newParentHeight:r,initialParentWidth:s,initialParentHeight:n});if(YF(t)||t instanceof _m)YF(t)&&(t.width=l,t.height=h,t.data={...t.data,width:l,height:h}),iwt({objectOverride:t,objectRoot:e,newParentWidth:l,newParentHeight:h,initialParentWidth:a,initialParentHeight:o});else if(t instanceof X5){let d=e,c=a!==0?l/a:1,p=o!==0?h/o:1;t.path=function(m,f=1,g=1){if(f<=0||g<=0)return m;if(Zxt(m))return console.warn("Cannot scale invalid path",m),HF([]);if(f===1&&g===1)return m;try{return HF((0,U4t.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),HF([])}}(d.path,c,p),t.data={...t.data,path:t.path}}}function $4t({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:h,height:u,position:d}=Jxt({constraints:e.data,newParentWidth:r,newParentHeight:s,initialParentWidth:n,initialParentHeight:a,objectInitialWidth:$g.isResizeable(l)?l.width:0,objectInitialHeight:$g.isResizeable(l)?l.height:0,objectInitialPosition:l.position});Object.assign(e.states[t],{position:d}),$g.isResizeable(o)&&Object.assign(e.states[t],{width:h,height:u})}}function YF(t){return t instanceof IT||t instanceof Yu||t instanceof Vq||t instanceof zq}TD();var Bdt,X4t=class extends wr{constructor(t,e,i){super(t,e,i),this.isUIObject=!0,this.uiCanvas=new ewt(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=om(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):tr(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=om(i,e,this.data.flatShading,this)}};Oi(),ab("UIGeometry",(t,e,i)=>new X4t(t,e,i)),gD=Bdt={Scene2D:Lq,UICanvas:ewt,loadHanaUIRUNTIME:function(){return q5||(q5=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(()=>(c$(),d$)),_dt??function(){let t=typeof process<"u"?"2.0.204":void 0;return`https://cdn.spline.design/@splinetool/runtime${t?`@${t}`:""}/build/hana-ui.wasm`}())),Yxt().then(()=>{})},setHanaUIWasmUrl:function(t){_dt=t}},t5!==null&&Bdt.setHanaUIWasmUrl(t5),Nr("ui-2d"),$W(),uyt(),ot();var rwt,KF,Y4t=class{constructor(){this.type="ShapePath",this.color=new se,this.subPaths=[],this.currentPath=null}moveTo(t,e){return this.currentPath=new rS,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(h,u,d,c){let p=h.x,m=u.x,f=d.x,g=c.x,y=h.y,v=u.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 C=0;C<2;C++){if(i(C===0?d:c,h,u),t.loc===0){let M=C===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 C=0;C<2;C++)if(i(C===0?d:c,h,u),t.loc===0){let M=C===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(h,u,d){let c,p=d.x-u.x,m=d.y-u.y,f=h.x-u.x,g=h.y-u.y,y=p*g-f*m;return h.x===u.x&&h.y===u.y?(t.loc=0,void(t.t=0)):h.x===d.x&&h.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(h=>{let u=h.getPoints(),d=-999999999,c=999999999,p=-999999999,m=999999999;for(let f=0;f<u.length;f++){let g=u[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),u.length&&a.push({curves:h.curves,points:u,isCW:oU.isClockWise(u),identifier:r++,boundingBox:new BG(new Y(m,c),new Y(p,d))})});let o=a.map(h=>function(u,d,c,p,m){(m==null||m==="")&&(m="nonzero");let f=new Y;u.boundingBox.getCenter(f);let g=function(S,w,T){let C=new Y;w.getCenter(C);let M=[];return T.forEach(A=>{A.boundingBox.containsPoint(C)&&function(P,O){let D=[],N=[];for(let z=1;z<P.length;z++){let k=P[z-1],B=P[z];for(let V=1;V<O.length;V++){let q=e(k,B,O[V-1],O[V]);q!==null&&D.find(W=>W.t<=q.t+Number.EPSILON&&W.t>=q.t-Number.EPSILON)===void 0&&(D.push(q),N.push(new Y(q.x,q.y)))}}return N}(S,A.points).forEach(P=>{M.push({identifier:A.identifier,isCW:A.isCW,point:P})})}),M.sort((A,P)=>A.point.x-P.point.x),M}([new Y(c,f.y),new Y(p,f.y)],u.boundingBox,d);g.sort((S,w)=>S.point.x-w.point.x);let y=[],v=[];g.forEach(S=>{S.identifier===u.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(u.identifier),m==="evenodd"){let S=_.length%2==0,w=_[_.length-2];return{identifier:u.identifier,isHole:S,for:w}}if(m==="nonzero"){let S=!0,w=null,T=null;for(let C=0;C<_.length;C++){let M=_[C];d[M]&&(S?(T=d[M].isCW,S=!1,w=M):T!==d[M].isCW&&(T=d[M].isCW,S=!0))}return{identifier:u.identifier,isHole:S,for:w}}console.warn('fill-rule: "'+m+'" is currently not implemented.')}(h,a,s,n,this.userData?.style.fillRule)),l=[];return a.forEach(h=>{let u=o[h.identifier];if(u&&!u.isHole){let d=new LS;d.curves=h.curves,o.filter(c=>c?.isHole&&c.for===h.identifier).forEach(c=>{if(c){let p=a[c.identifier],m=new rS;m.curves=p.curves,d.holes.push(m)}}),l.push(d)}}),l}},swt=!1,kdt=new Promise(t=>{rwt=t}),Vdt=!1;function zdt(){if(swt=!0,!Vdt)return KF||(KF=async function(){let t=await import("./opentype.js");rwt(t),Vdt=!0}(),KF)}var K4t=new class{async load(t,e,i=()=>{}){let{load:r}=await kdt;r(t,(s,n)=>{s||!n?i(s??"Something went wrong"):e(n)})}async parse(t){let{parse:e,Bidi:i}=await kdt;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 Z4t(t,e){return e.state.glyphIndex===t||e.state.fina===t||e.state.medi===t||e.state.init===t}ot(),bW(),Oi(),ab("TextGeometry",(t,e,i)=>new OD(t,e,i));var Ldt={create:(t,e)=>new Dj(t,e)};oj("TextGeometry",Ldt),oj("InputGeometry",Ldt),vW=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(!swt)return{font:void 0,url:s,intercepted:n,arr:r,bidi:null};{let a=await K4t.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 h=i[l].index,u=String.fromCharCode(i[l].unicode),d=s[a];if(Z4t(h,d)||o)n.push({char:u,index:h,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===h&&(g=!0),a>e.length&&(g=!0);n.push({char:u,index:h,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,h=this.getCharWidth(`
|
|
5122
|
+
}`}),W4t=new class{constructor(t){this._mesh=new gr(G4t,t)}dispose(){this._mesh.geometry.dispose()}render(t){t.render(this._mesh,j4t)}get material(){return this._mesh.material}set material(t){this._mesh.material=t}}(twt),$F=null,XF=null,q4t=Je.identity(),ewt=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||vS.add(this),this.context.shared.requestRender()},this._innerApplySize=()=>{let n=this.width,a=this.height;this.renderer.dpr=Ndt(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 Lq(zt.generateUUID(),rj.defaultData,{dpr:window.devicePixelRatio,shared:r.shared}),this.canvas=($F===null&&($F=document.createElement("canvas")),$F),this.renderer=(s=this.canvas,XF===null&&(XF=new B4t(s)),XF),this.promise=this.init(),this.renderTarget=new xg(1,1,{type:si,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 DG(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{twt.uniforms.tDiffuse.value=this.canvasTexture;let e=t.getRenderTarget();t.setRenderTarget(this.renderTarget),t.clear(),W4t.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=q4t,this.isScreenSpace&&(this.frameOverride.fill.color=qi.from0to1([0,0,0,0])),this.frameOverride.data={...this.frameOverride.data,width:e,height:i},iwt({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 h=Ndt(n,a,o,l),u=Math.max(o,512/Math.min(n,a)),d=Math.min(u,h);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 Yu)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 iwt({objectOverride:t,objectRoot:e,newParentWidth:i,newParentHeight:r,initialParentWidth:s,initialParentHeight:n}){if(t instanceof Yu&&e instanceof Yu||t instanceof _m&&e instanceof _m)for(let a=0,o=t.children.length;a<o;a++){let l=t.children[a],h=e.children[a];l&&h&&l.uuid===h.uuid&&H4t({objectOverride:l,objectRoot:h,newParentWidth:i,newParentHeight:r,initialParentWidth:s,initialParentHeight:n})}}function H4t({objectOverride:t,objectRoot:e,newParentWidth:i,newParentHeight:r,initialParentWidth:s,initialParentHeight:n}){let[a,o]=function(d){if(YF(d))return[d.width,d.height];if(d instanceof X5){let[c,p]=d.getHalfSize();return[2*c,2*p]}if(d instanceof _m){let[c,p]=d.recursiveBBox.getHalfSize();return[2*c,2*p]}return[0,0]}(e),{width:l,height:h,position:u}=Jxt({constraints:t.data,newParentWidth:i,newParentHeight:r,initialParentWidth:s,initialParentHeight:n,objectInitialWidth:a,objectInitialHeight:o,objectInitialPosition:e.position});if(t.position=u,t.data={...t.data,position:u},t.states)for(let d in t.states)$4t({stateId:d,objectOverride:t,objectRoot:e,newParentWidth:i,newParentHeight:r,initialParentWidth:s,initialParentHeight:n});if(YF(t)||t instanceof _m)YF(t)&&(t.width=l,t.height=h,t.data={...t.data,width:l,height:h}),iwt({objectOverride:t,objectRoot:e,newParentWidth:l,newParentHeight:h,initialParentWidth:a,initialParentHeight:o});else if(t instanceof X5){let d=e,c=a!==0?l/a:1,p=o!==0?h/o:1;t.path=function(m,f=1,g=1){if(f<=0||g<=0)return m;if(Zxt(m))return console.warn("Cannot scale invalid path",m),HF([]);if(f===1&&g===1)return m;try{return HF((0,U4t.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),HF([])}}(d.path,c,p),t.data={...t.data,path:t.path}}}function $4t({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:h,height:u,position:d}=Jxt({constraints:e.data,newParentWidth:r,newParentHeight:s,initialParentWidth:n,initialParentHeight:a,objectInitialWidth:$g.isResizeable(l)?l.width:0,objectInitialHeight:$g.isResizeable(l)?l.height:0,objectInitialPosition:l.position});Object.assign(e.states[t],{position:d}),$g.isResizeable(o)&&Object.assign(e.states[t],{width:h,height:u})}}function YF(t){return t instanceof IT||t instanceof Yu||t instanceof Vq||t instanceof zq}TD();var Bdt,X4t=class extends wr{constructor(t,e,i){super(t,e,i),this.isUIObject=!0,this.uiCanvas=new ewt(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=om(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):tr(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=om(i,e,this.data.flatShading,this)}};Oi(),ab("UIGeometry",(t,e,i)=>new X4t(t,e,i)),gD=Bdt={Scene2D:Lq,UICanvas:ewt,loadHanaUIRUNTIME:function(){return q5||(q5=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(()=>(c$(),d$)),_dt??function(){let t=typeof process<"u"?"2.0.206":void 0;return`https://cdn.spline.design/@splinetool/runtime${t?`@${t}`:""}/build/hana-ui.wasm`}())),Yxt().then(()=>{})},setHanaUIWasmUrl:function(t){_dt=t}},t5!==null&&Bdt.setHanaUIWasmUrl(t5),Nr("ui-2d"),$W(),uyt(),ot();var rwt,KF,Y4t=class{constructor(){this.type="ShapePath",this.color=new se,this.subPaths=[],this.currentPath=null}moveTo(t,e){return this.currentPath=new rS,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(h,u,d,c){let p=h.x,m=u.x,f=d.x,g=c.x,y=h.y,v=u.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 C=0;C<2;C++){if(i(C===0?d:c,h,u),t.loc===0){let M=C===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 C=0;C<2;C++)if(i(C===0?d:c,h,u),t.loc===0){let M=C===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(h,u,d){let c,p=d.x-u.x,m=d.y-u.y,f=h.x-u.x,g=h.y-u.y,y=p*g-f*m;return h.x===u.x&&h.y===u.y?(t.loc=0,void(t.t=0)):h.x===d.x&&h.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(h=>{let u=h.getPoints(),d=-999999999,c=999999999,p=-999999999,m=999999999;for(let f=0;f<u.length;f++){let g=u[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),u.length&&a.push({curves:h.curves,points:u,isCW:oU.isClockWise(u),identifier:r++,boundingBox:new BG(new Y(m,c),new Y(p,d))})});let o=a.map(h=>function(u,d,c,p,m){(m==null||m==="")&&(m="nonzero");let f=new Y;u.boundingBox.getCenter(f);let g=function(S,w,T){let C=new Y;w.getCenter(C);let M=[];return T.forEach(A=>{A.boundingBox.containsPoint(C)&&function(P,O){let D=[],N=[];for(let z=1;z<P.length;z++){let k=P[z-1],B=P[z];for(let V=1;V<O.length;V++){let q=e(k,B,O[V-1],O[V]);q!==null&&D.find(W=>W.t<=q.t+Number.EPSILON&&W.t>=q.t-Number.EPSILON)===void 0&&(D.push(q),N.push(new Y(q.x,q.y)))}}return N}(S,A.points).forEach(P=>{M.push({identifier:A.identifier,isCW:A.isCW,point:P})})}),M.sort((A,P)=>A.point.x-P.point.x),M}([new Y(c,f.y),new Y(p,f.y)],u.boundingBox,d);g.sort((S,w)=>S.point.x-w.point.x);let y=[],v=[];g.forEach(S=>{S.identifier===u.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(u.identifier),m==="evenodd"){let S=_.length%2==0,w=_[_.length-2];return{identifier:u.identifier,isHole:S,for:w}}if(m==="nonzero"){let S=!0,w=null,T=null;for(let C=0;C<_.length;C++){let M=_[C];d[M]&&(S?(T=d[M].isCW,S=!1,w=M):T!==d[M].isCW&&(T=d[M].isCW,S=!0))}return{identifier:u.identifier,isHole:S,for:w}}console.warn('fill-rule: "'+m+'" is currently not implemented.')}(h,a,s,n,this.userData?.style.fillRule)),l=[];return a.forEach(h=>{let u=o[h.identifier];if(u&&!u.isHole){let d=new LS;d.curves=h.curves,o.filter(c=>c?.isHole&&c.for===h.identifier).forEach(c=>{if(c){let p=a[c.identifier],m=new rS;m.curves=p.curves,d.holes.push(m)}}),l.push(d)}}),l}},swt=!1,kdt=new Promise(t=>{rwt=t}),Vdt=!1;function zdt(){if(swt=!0,!Vdt)return KF||(KF=async function(){let t=await import("./opentype.js");rwt(t),Vdt=!0}(),KF)}var K4t=new class{async load(t,e,i=()=>{}){let{load:r}=await kdt;r(t,(s,n)=>{s||!n?i(s??"Something went wrong"):e(n)})}async parse(t){let{parse:e,Bidi:i}=await kdt;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 Z4t(t,e){return e.state.glyphIndex===t||e.state.fina===t||e.state.medi===t||e.state.init===t}ot(),bW(),Oi(),ab("TextGeometry",(t,e,i)=>new OD(t,e,i));var Ldt={create:(t,e)=>new Dj(t,e)};oj("TextGeometry",Ldt),oj("InputGeometry",Ldt),vW=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(!swt)return{font:void 0,url:s,intercepted:n,arr:r,bidi:null};{let a=await K4t.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 h=i[l].index,u=String.fromCharCode(i[l].unicode),d=s[a];if(Z4t(h,d)||o)n.push({char:u,index:h,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===h&&(g=!0),a>e.length&&(g=!0);n.push({char:u,index:h,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,h=this.getCharWidth(`
|
|
5123
5123
|
`,e),u=e.horizontalAlign===1?h:0,d=this.getLineInitialOffsetX(a[0],o,e.horizontalAlign,t[0],h),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(C){this.warnLayoutError(C)}d=this.getLineInitialOffsetX(a[y],o,e.horizontalAlign,v,h);let x=[];try{x=this.reverseLigaturesTable(r,v,_)}catch(C){this.warnLayoutError(C)}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,(C,M,A,P,O)=>{let D=C.index===0?`
|
|
5124
5124
|
`:C.unicode?String.fromCharCode(C.unicode):void 0,N=x[w],z=0;if(D===`
|
|
5125
5125
|
`)z=u;else if(D===" ")z=S;else{let k=this.createPath(C,s,M,A,e);k&&(z=k.offsetX,p.push(k.path))}if(N&&N.replacements.length!==1){let k=N.replacements.map(W=>(r.glyphs.get(W).advanceWidth??0)*s),B=k.reduce((W,H)=>W+H,0),V=k.map(W=>W/B),q=M;for(let W=0;W<V.length;W++){let H=z*V[W];f[y].push([q,A]),m[y].push(H),q+=H}}else f[y].push([M,A]),m[y].push(z);w++})}catch(C){this.warnLayoutError(C)}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(`
|
|
5126
|
-
`)>=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 Y4t,o=(t.advanceWidth??1)*e;if(t)for(let l of n.commands){let h=a.currentPath?.currentPoint;if(!h||l.type==="Z"||h.x!==l.x||-h.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 h=function(u){if(u.length){let d=u[0];if(d instanceof pl)return d.v1;if(d instanceof Kl||d instanceof lc)return d.v0}}(l.curves);h!==void 0&&l.currentPoint.distanceTo(h)>0&&l.lineTo(h.x,h.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}},Nr("text"),De();var nwt=null;function Fdt(){return nwt}function Q4t(t){let e=!1;return t.scene.objects.forEach(i=>{i.data.type==="Page"&&!e&&i.data.publish.gameControlObject&&s0.traverseModuleInstances(t,i.id,(r,s,n)=>{for(let a of n)a.data.type==="GameControl"&&a.data.navmesh.enabled&&(e=!0)})}),e}er();var rP=(t,e)=>{let i=e.x-t.x,r=e.y-t.y;return Math.sqrt(i*i+r*r)},ZF=t=>t*(Math.PI/180),sP=new Map,Y5=(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)},K5=(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)},awt=t=>(t.preventDefault(),t.type.match(/^touch/)?t.changedTouches:t),Udt=()=>{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}},QF=(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")},JF=(t,e,i)=>{let r=owt(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},owt=t=>{let e={};return e[t]="",["webkit","Moz","o"].forEach(function(i){e[i+t.charAt(0).toUpperCase()+t.slice(1)]=""}),e},t8=(t,e)=>{for(let i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},K7=(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"&&(lwt="ontouchstart"in window,hwt=!!window.PointerEvent,uwt=!!window.MSPointerEvent);var lwt,hwt,uwt,i1,jdt={start:"mousedown",move:"mousemove",end:"mouseup"},Pw={};function bg(){}hwt?i1={start:"pointerdown",move:"pointermove",end:"pointerup, pointercancel"}:uwt?i1={start:"MSPointerDown",move:"MSPointerMove",end:"MSPointerUp"}:lwt?(i1={start:"touchstart",move:"touchmove",end:"touchend, touchcancel"},Pw=jdt):i1=jdt,bg.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},bg.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},bg.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)})},bg.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))},bg.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.')},Y5(t,i1[e],i._domHandlers_[e]),Pw[e]&&Y5(t,Pw[e],i._domHandlers_[e]),i},bg.prototype.unbindEvt=function(t,e){var i=this;return i._domHandlers_=i._domHandlers_||{},K5(t,i1[e],i._domHandlers_[e]),Pw[e]&&K5(t,Pw[e],i._domHandlers_[e]),delete i._domHandlers_[e],this};var Fq=bg;function Tn(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=Tn.id,Tn.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}Tn.prototype=new Fq,Tn.constructor=Tn,Tn.id=0,Tn.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},Tn.prototype.stylize=function(){if(this.options.dataOnly)return this;var t=this.options.fadeTime+"ms",e=(()=>{let s=owt("borderRadius");for(let n in s)Object.prototype.hasOwnProperty.call(s,n)&&(s[n]="50%");return s})(),i=JF("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)"},t8(r.el,i),this.options.shape==="circle"&&t8(r.back,e),t8(r.front,e),this.applyStyles(r),this},Tn.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},Tn.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)||this.options.zone.appendChild(this.ui.el),this},Tn.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)||this.options.zone.removeChild(this.ui.el),this},Tn.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},Tn.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},Tn.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},Tn.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=JF("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)},Tn.prototype.restCallback=function(){var t=this,e={};e.front=JF("transition","none",""),t.applyStyles(e),t.trigger("rested",t.instance)},Tn.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}},Tn.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 h={};for(o in this.direction={x:i,y:r,angle:e},t.direction=this.direction,l)l[o]===this.direction[o]&&(h[o]=!0);if(h.x&&h.y&&h.angle)return t;(!h.x||!h.y)&&this.trigger("plain",t),h.x||this.trigger("plain:"+i,t),h.y||this.trigger("plain:"+r,t),h.angle||this.trigger("dir dir:"+e,t)}else this.resetDirection();return t};var J4t=Tn;function qs(t,e){var i=this;i.nipples=[],i.idles=[],i.actives=[],i.ids=[],i.pressureIntervals={},i.manager=t,i.id=qs.id,qs.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}qs.prototype=new Fq,qs.constructor=qs,qs.id=0,qs.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}},qs.prototype.bindings=function(){var t=this;t.bindEvt(t.options.zone,"start"),t.options.zone.style.touchAction="none",t.options.zone.style.msTouchAction="none"},qs.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)}},qs.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 h=l.getBoundingClientRect();n.zone.removeChild(l),s=t,t={x:h.left+r.x,y:h.top+r.y}}var u=new J4t(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||(QF(u.ui.el,s),QF(u.ui.front,u.frontPosition)),i.nipples.push(u),i.trigger("added "+u.identifier+":added",u),i.manager.trigger("added "+u.identifier+":added",u),i.bindNipple(u),u},qs.prototype.updateBox=function(){this.box=this.options.zone.getBoundingClientRect()},qs.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)},qs.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)},qs.prototype.onstart=function(t){var e=this,i=e.options,r=t;return t=awt(t),e.updateBox(),K7(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},qs.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(h){h.trigger("start",h),i.trigger("start "+h.id+":start",h),h.show(),n>0&&i.pressureFn(t,h,h.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(!(rP(a,o.position)<=r.catchDistance))return o.destroy(),void i.processOnStart(t);l(o)}return o},qs.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)},qs.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 h,u,d=rP(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=ZF(c),m=d/o,f={distance:d,position:l};if(s.options.shape==="circle"?(h=Math.min(d,o),u=((b,_,x)=>{let S={x:0,y:0};return x=ZF(x),S.x=b.x-_*Math.cos(x),S.y=b.y-_*Math.sin(x),S})(s.position,h,c)):(u=((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),h=rP(u,s.position)),i.follow){if(d>o){let b=l.x-u.x,_=l.y-u.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=rP(l,s.position)}}else l=u,d=h;var g=l.x-s.position.x,y=l.y-s.position.y;s.frontPosition={x:g,y},i.dataOnly||QF(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:ZF(180-c),degree:180-c},s.trigger("move",v),e.trigger("move "+s.id+":move",v)}else this.processOnEnd(t)},qs.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))},qs.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()},qs.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 t5t=qs;function nn(t){var e=this;e.ids={},e.index=0,e.collections=[],e.scroll=Udt(),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=>{sP.has(r)&&clearTimeout(sP.get(r)),sP.set(r,setTimeout(function(){sP.delete(r),r()},100))})(i)},e._onScroll=function(){e.scroll=Udt()},e.collections}nn.prototype=new Fq,nn.constructor=nn,nn.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}},nn.prototype.create=function(t){return this.createCollection(t)},nn.prototype.bindWindowEvents=function(){var t=this;t._windowBound||typeof window>"u"||(t._windowBound=!0,Y5(window,"resize",t._onResize),Y5(window,"scroll",t._onScroll))},nn.prototype.unbindWindowEvents=function(){var t=this;!t._windowBound||typeof window>"u"||(t._windowBound=!1,K5(window,"resize",t._onResize),K5(window,"scroll",t._onScroll))},nn.prototype.createCollection=function(t){var e=this,i=new t5t(e,t);return e.bindCollection(i),e.collections.push(i),e.bindWindowEvents(),i},nn.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)},nn.prototype.bindDocument=function(){var t=this;t.binded||(t.bindEvt(document,"move").bindEvt(document,"end"),t.binded=!0)},nn.prototype.unbindDocument=function(t){var e=this;(!Object.keys(e.ids).length||t===!0)&&(e.unbindEvt(document,"move").unbindEvt(document,"end"),e.binded=!1)},nn.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]},nn.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},nn.prototype.onmove=function(t){return this.onAny("move",t),!1},nn.prototype.onend=function(t){return this.onAny("end",t),!1},nn.prototype.oncancel=function(t){return this.onAny("end",t),!1},nn.prototype.onAny=function(t,e){var i,r=this,s="processOn"+t.charAt(0).toUpperCase()+t.slice(1);e=awt(e);var n=function(a,o,l){l.ids.indexOf(o)>=0&&(l[s](a),a._found_=!0)};return K7(e,function(a){i=r.getIdentifier(a),K7(r.collections,n.bind(null,a,i)),a._found_||r.removeIdentifier(i)}),!1},nn.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()},nn.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 e5t=nn,Nv=null;function Gdt(){return Nv||(Nv=new e5t),Nv}var i5t={create:function(t){return Gdt().create(t)},destroy:function(){Nv&&(Nv.destroy(),Nv=null)},get factory(){return Gdt()}},r5t=i5t;er(),De(),ot(),Kh(),ob(),rh(),yo(),De();var dwt=null;function e8(){return dwt}var cwt,i8,s5t=new Promise(t=>{cwt=t});function n5t(t){return i8||(i8=async function(){let e=t??"https://cdn.spline.design/@splinetool/runtime@2.0.204/build",i=import("./physics.js"),[r,s]=await Promise.all([i,fetch(`${e}/physics.wasm`).then(n=>n.arrayBuffer())]);await r.init(s),cwt(r)}(),i8)}function pwt(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 oc(t,e){let i=new fe;if(e&&pwt(e))return i.setAttribute("position",new me([],3)),i.setIndex([]),i;if(!t.getAttribute("position"))return i.setAttribute("position",new me([],3)),i.setIndex([]),i;let{positions:r,triIndices:s}=PW(t.getAttribute("position"),t.getIndex());return i.setAttribute("position",new me(r,3)),i.setIndex(s),e&&i.applyMatrix4(e),i}Jr(),yo(),Oi(),WW(),ot(),ot(),hb(),bT();var Bi,a5t=class{constructor(t,e,i,r,s,n){this.id=t,this.data=e,this.object=i,this.initialDisabled=!1,this.actions=cn(e,e.actions,r,s,n,i),this.target=e.target}disconnect(){ia(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()))}},Wdt=class{constructor(t,e,i,r,s,n){this.id=t,this.data=e,this.object=i,this.page=r,this.currentIntersectedObjects=[],this.actions=cn(e,e.actions,r,s,n,i),this.target=e.target,this.triggeringObjects=[];for(let a of e.triggeringObjects){let o=r.scene.findFrom(a,i);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(){ia(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()))}};Jr(),vT(),dD(),s5t.then(t=>Bi=t);var sn=new E,Gl=new we,r8=new E,o5t=new E(1,1,1),s8=(new zi(0,0,0,"YXZ"),new zi(0,0,0,"XYZ")),Ld=new E,qdt=new E,Rw=new we,nP=new bt,Hdt=new bt,l5t={type:"updateMatrix"},n8=(new we,new Zn),a8=.01,Z7={type:"beginEvent",eventName:"Collision"},h5t={type:"beginEvent",eventName:"Trigger"},Z5=t=>t.states.some(e=>e.data.position!==void 0||e.data.rotation!==void 0||e.data.shear!==void 0||e.data.cloner!==void 0||e.data.pathSnapping!==void 0);function r1(t){return function(e){return typeof e=="object"&&e!==null&&"booleanOp"in e}(am(t)?t.object:t)}var u5t=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()!==Bi.RigidBodyType.Dynamic)return;e.isSleeping()||this.nActiveRigidBodies++;let[i,r]=this.rigidBodyToMesh.get(e.handle);if(sn.copy(e.translation()).multiplyScalar(this.pixelsPerMeter),Gl.copy(e.rotation()),i.matrixWorld.makeRotationFromQuaternion(Gl).setPosition(sn),i.matrixWorld.multiply(i.shearScale),i.dispatchEvent(l5t),r){let s=i.cloner;if(s&&s.objectForSample===void 0){s.matrixWorld.copy(i.matrixWorld);for(let n of s.children)n.updateMatrixWorld(!0)}for(let n of i.children)n.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 u of o)u.data.target==="scene"&&this.dispatchCollisionEvent(u,a,e);let l=this.sharedGameControlGlobals.colliderToEntity.get(i),h=this.sharedGameControlGlobals.entityToCollisionEvents[l?.uuid];if(h!==void 0)for(let u of h)u.data.target==="scene"&&this.dispatchCollisionEvent(u,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(e8()===null)return void On("collision-bvh","trigger/collision detection");let t=[],e=[];if(this.page.traverseChildren(i=>{let r,s=i instanceof Tv,n=uS(i);if(nm(i)||s||n)return;r=am(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,h=r.userData.hasDrag===!0;if(Z5(a)||l||h||r.dataPatched.events.some(u=>u.data.disabled!==!0&&(u.data.type==="GameControl"||u.data.type==="Follow")))return i.updateMatrixWorldRigid(),this.addBoundsTree(i),!0;if(o){let u=o.getAttribute("position");if(u!==void 0&&u.count>0){t.push({geometry:o,matrixWorld:i.matrixWorld}),e.push(o.id,this._staticBVHIdOf(u),u.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!!r1(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=Ig(t.map(n=>oc(n.geometry,n.matrixWorld)),!1),s=new(e8())(r);this._staticBVHCache={signature:e,bvh:s},this.sharedGameControlGlobals.staticMeshBVH=s}}addRigidBody(t,e,i){if(pwt(t.matrixWorld))return;let r=[],s="geometry"in t?t.geometry:void 0,n=e.dataPatched;if(s?.getAttribute("position")!==void 0&&r.push(oc(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=Bi.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=Bi.RigidBodyDesc.kinematicPositionBased(),o=!0):a=Bi.RigidBodyDesc.fixed();let h=Ig(r);sn.setFromMatrixPosition(t.matrixWorld),Gl.setFromRotationMatrix(t.matrixWorldRigid),t.position0=sn.clone().divideScalar(this.pixelsPerMeter),t.rotation0=Gl.clone(),sn.divideScalar(this.pixelsPerMeter),a.setTranslation(sn.x,sn.y,sn.z).setRotation(Gl),h?.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter);let u=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(u,n.physics,h,e,d)}catch{try{this.addCollider(u,n.physics,h,e,!1)}catch(c){console.error(c)}}if(u.numColliders()===0)return void this.sharedGameControlGlobals.rapierWorld.removeRigidBody(u);l?this.rigidBodyToMesh.set(u.handle,[t,n.physics.fusedBody]):o?(this.sharedGameControlGlobals.kinematicBodyToEntity.set(u.handle,t),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(t)):this.fixedBodiesToWatch.push([t,u,(t.hasNonUniformScale?t.matrixWorldRigid:t.matrixWorld).clone()]),t.rigidBody=u}}addBoundsTree(t){let e=[];if(t.geometry?.getAttribute("position")!==void 0&&t.geometry?.getAttribute("position").count>0&&e.push(oc(t.geometry,t.shearScale)),t.traverseObject(this.gatherChildrenGeom(t,e)),t.children.forEach(i=>i.updateMatrixWorld(!0)),e.length>0){let i=Ig(e,!1);t.bvhGeometry=i,i.getAttribute("position").count>0&&(t.bvhGeometry.boundsTree=new(e8())(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"?Bi.ColliderDesc.trimesh(i.getAttribute("position").array,i.getIndex().array):Bi.ColliderDesc.convexMesh(i.getAttribute("position").array,s?i.getIndex().array:void 0)),n.setFrictionCombineRule(Bi.CoefficientCombineRule.Average).setRestitutionCombineRule(Bi.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(Bi.ActiveEvents.COLLISION_EVENTS)}gatherChildrenGeom(t,e){let i=r1(t);return(r,s)=>{if(s===0)return;if(i&&r.parent===t)return!0;let n;if(nm(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(am(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?r.matrixWorld.copy(t.shearScale):r.matrixWorld.copy(r.parent.matrixWorld),r.matrixWorld.multiply(r.matrix);let o=r.geometry;return o?.getAttribute("position")!==void 0&&e.push(oc(o,r.matrixWorld)),!!r1(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=Fdt();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&&On("game-controls","the scene's game controls"),i===!1){let{enableRotate:a,enablePan:o,enableZoom:l,autoRotate:h,hoverRotatePanMode:u}=this.eventManager.publish.orbitControls;(a||o||l||h||u!==0)&&(this.orbitControls=new Wxt(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();Fdt()?.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 Bi.World(new Bi.Vector3(0,this.gravity,0)),this.events=new Bi.EventQueue(!0);let t=[],e=[];if(this.page.traverseChildren(a=>{let o;if(nm(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(am(a))o=a.object;else{if(uS(a)||n0(a)||a instanceof Tv)return;if(o=a,o.dataPatched.cloner?.disabled===!1&&o.dataPatched.cloner?.hideBase&&o.dataPatched.physics?.fusedBody!==!0)return!0}let l,h=o.dataPatched;for(let g of h.events)g.data.disabled!==!0&&g.data.type==="GameControl"&&(l=g.data);if(!h.physics||(h.physics.enabled==="visibility"?!h.visible:!h.physics.enabled))return!0;a.updateMatrixWorldRigid();let u=Z5(h),d=!1,c=o.userData.hasDestroy,p=o.userData.hasDrag,m=!1;for(let g of h.events)if(g.data.disabled!==!0){if(g.data.type==="Collision"){d=!0;let y=new a5t(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})}}h.physics.rigidBody==="dynamic"&&h.physics.fusedBody===!1&&(a.matrixWorldFusedFalse=a.matrixWorld.clone());let f=a.geometry;if(l!==void 0){let g=Bi.RigidBodyDesc.kinematicPositionBased();(a.hasNonUniformScale?a.matrixWorldRigid:a.matrixWorld).decompose(sn,Gl,r8),a.position0=sn.clone().divideScalar(this.pixelsPerMeter),a.rotation0=Gl.clone(),sn.divideScalar(this.pixelsPerMeter),g.setTranslation(sn.x,sn.y,sn.z).setRotation(Gl);let y,v=this.sharedGameControlGlobals.rapierWorld.createRigidBody(g);a.rigidBody=v,y=l.collider.type==="sphere"?Bi.ColliderDesc.ball(l.collider.radius/this.pixelsPerMeter):l.collider.type==="capsule"?Bi.ColliderDesc.capsule((l.collider.height/2-l.collider.radius)/this.pixelsPerMeter,l.collider.radius/this.pixelsPerMeter):Bi.ColliderDesc.cuboid(l.collider.width/this.pixelsPerMeter/2,l.collider.height/this.pixelsPerMeter/2,l.collider.depth/this.pixelsPerMeter/2),y.setFrictionCombineRule(Bi.CoefficientCombineRule.Average).setDensity(h.physics.density).setFriction(h.physics.friction).setRestitution(0).setRestitutionCombineRule(Bi.CoefficientCombineRule.Min);let b=this.sharedGameControlGlobals.rapierWorld.createCollider(y,v);this.sharedGameControlGlobals.colliderToEntity.set(b.handle,o),sn.fromArray(l.collider.position.map(x=>typeof x=="number"?x:0)).multiply(r8.setFromMatrixScale(o.matrixWorld)).divideScalar(this.pixelsPerMeter),b.setTranslationWrtParent(sn);let _=new we().setFromEuler(new zi().setFromVector3(new E().fromArray(l.collider.rotation.map(x=>typeof x=="number"?x:0))));b.setRotationWrtParent(_),b.setActiveEvents(Bi.ActiveEvents.COLLISION_EVENTS),this.generateSensorColliderDescs(o,!0)}else h.physics.rigidBody==="dynamic"||u||m||c||p||d?(this.addRigidBody(a,o,{hasFollow:m,hasTransformAnim:u,hasDrag:p}),this.generateSensorColliderDescs(o,h.physics.fusedBody)):(f&&t.push(oc(f,a.matrixWorld)),h.physics.fusedBody&&!r1(a)&&a.traverseObject((g,y)=>{if(y===0)return;let v;if(nm(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(uS(g)||n0(g)||g instanceof Tv)return;if(am(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(oc(_,g.matrixWorld)),!!r1(g)||void 0}),this.generateSensorColliderDescs(o,h.physics.fusedBody,e));return!(h.physics?.fusedBody!==!0&&!l&&!r1(a))||void 0}),t.length===0)return;let i=Ig(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=Bi.RigidBodyDesc.fixed(),n=this.sharedGameControlGlobals.rapierWorld.createRigidBody(s);if(r){let a=Bi.ColliderDesc.trimesh(i.getAttribute("position").array,i.getIndex().array).setFrictionCombineRule(Bi.CoefficientCombineRule.Multiply).setRestitutionCombineRule(Bi.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 Wdt(e.id,e.data,t,this.page,this.sharedAssets,this.eventManager),r=new bt().compose(Ld.fromArray(e.data.position.map(s=>typeof s=="number"?s:0)),Rw.setFromEuler(s8.fromArray(e.data.rotation.map(s=>typeof s=="number"?s:0))),o5t);if(e.data.triggerZone==="box"){let s=new dr;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(sn,Gl,r8);let e=t;e.prevQ===void 0?(e.prevQ=Gl.clone(),e.prevT=sn.clone()):(e.prevQ.copy(Gl),e.prevT.copy(sn))}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(Bi.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 h=l.translation(),u=-1/0,d=0,c=0;if(e.contactPair(a,o,y=>{let v=y.normal(),b=v.x*(h.x-r.x)+v.y*(h.y-r.y)+v.z*(h.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>u&&(u=w,d=_/S,c=x/S)}),u===-1/0)return;let p=i.x*d+i.z*c;if(p<-a8)return;let m=l.linvel();if(s>a8&&p>a8){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(sn.divideScalar(this.pixelsPerMeter)),i.rigidBody.setNextKinematicRotation(Gl)):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(Z7)}updateUseWindowEvents(t){this.orbitControls?.updateUseWindowEvents(t)}generateSensorColliderDescs(t,e,i){let r=Hdt.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 Wdt(a.id,a.data,s,this.page,this.sharedAssets,this.eventManager);if(o=a.data.triggerZone==="box"?Bi.ColliderDesc.cuboid(...a.data.size.map(h=>(typeof h=="number"?h:1)/(2*this.pixelsPerMeter))):Bi.ColliderDesc.ball(a.data.radius/this.pixelsPerMeter),o.setDensity(0).setSensor(!0).setActiveEvents(Bi.ActiveEvents.COLLISION_EVENTS),Ld.fromArray(a.data.position.map(h=>typeof h=="number"?h:0)),Rw.setFromEuler(s8.fromArray(a.data.rotation.map(h=>typeof h=="number"?h:0))),nP.makeRotationFromEuler(s8).setPosition(Ld).premultiply(s.matrixWorld),i?(_c(nP,{translation:Ld,quaternion:Rw,scale:qdt}),o.setActiveCollisionTypes(Bi.ActiveCollisionTypes.KINEMATIC_FIXED|Bi.ActiveCollisionTypes.DYNAMIC_FIXED)):(_c(nP.premultiply(r),{translation:Ld,quaternion:Rw,scale:qdt}),t.rigidBody.bodyType()===Bi.RigidBodyType.Dynamic||(t.rigidBody.bodyType()===Bi.RigidBodyType.Fixed?o.setActiveCollisionTypes(Bi.ActiveCollisionTypes.KINEMATIC_FIXED|Bi.ActiveCollisionTypes.DYNAMIC_FIXED):o.setActiveCollisionTypes(Bi.ActiveCollisionTypes.KINEMATIC_KINEMATIC|Bi.ActiveCollisionTypes.DYNAMIC_KINEMATIC))),Ld.divideScalar(this.pixelsPerMeter),o.setTranslation(Ld.x,Ld.y,Ld.z),o.setRotation(Rw),i)i.push([o,l]);else{let h=this.sharedGameControlGlobals.rapierWorld.createCollider(o,t.rigidBody);this.sensorToTriggerEvent[h.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(vi.is(o)?o:o.object)===!1)continue;let l=Hdt.copy(sgt(s.matrixWorld)).copyPosition(s.matrixWorld).multiply(r),h=nP.copy(o.matrixWorld).invert().multiply(l),u=o.bvhGeometry.boundsTree;i instanceof dr?t=u.intersectsBox(i,h):(n8.radius=i,n8.center.setFromMatrixPosition(h),t=u.intersectsSphere(n8)),t?n.currentIntersectedObjects.indexOf(o)===-1&&(n.currentIntersectedObjects.push(o),n.dispatch(),s.dispatchEvent(h5t)):n.currentIntersectedObjects=n.currentIntersectedObjects.filter(d=>d!==o)}}}};db(),ot(),r5(),Li(),vT(),Em();var o8=.02,$dt=new E,Xdt=new E,d5t=new E,ja=new E,Fd=new E,s1=new E,l8=new bt,Ydt=new bt,c5t=new bt,al=new we,tg=new we,n1=new zi(0,0,0,"YXZ"),p5t=new E(1,0,0),Au=new E(0,1,0),m5t=new E(0,0,1),Kdt=new E(1,1,1),Zdt=[],Qdt=t=>Zdt[t]??(Zdt[t]=new E),h8=new E,f5t=new E,g5t=new E,y5t=new E,Jdt=new we,v5t=new E,tct=new we,Hn=new vl,Wl=new dr,b5t={type:"requestRender"},_5t={type:"updateMatrix"},Q7=class extends Pn{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.target0=new E,this.zoom0=1,this.rotForce=1,this.moveForce=1,this.pixelsPerMeter=200,this.euler0=new zi(0,0,0,"YXZ"),this.shearMatrix0=new bt,this.cameraShearMatrix0=new bt,this.position0Cam=new E,this.quat0Cam=new we,this.scale0Cam=new E,this.threshEndTranslate=.01,this.threshEndRotate=1e-8,this.threshEndRotVel=.005,this.collider={type:"capsule",radius:40,segment:new vl(new E(0,-40,0),new E(0,40,0)),matrix:new bt,position:new E,rotation:new we},this.euler=new zi(0,0,0,"YXZ"),this.eulerDelta=new E,this.lastPosition=new E,this.lastCameraQuaternion=new we,this.lastCameraPosition=new E,this.PI_2=Math.PI/2,this.prevMouse=new Y,this.velocityTarget=new E,this.velocity=new E,this.directionXZ=new E,this.rotVelocityStick=new E,this.rotVelocityTarget=new E,this.rotVelocity=new E,this.rotDirection=new E,this.nonColliderRotOffset=new bt,this.nonColliderPosOffset=new bt,this.firstPointerId=-1,this.rot=new E,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 E,this.objectToTarget0=new E,this.objectToCamXZ=new E,this.objectToCamXZ0=new E,this.targetToCamera=new E,this.targetToCamera0=new E,this.cameraPolarAxis0=new E,this.targetPos=new E,this.targetQuat=new we,this.lerpFactorPos=new E().setScalar(.3),this.lerpFactorPosStart=.3,this.lerpFactorPosEnd=.3,this.lerpFactorRotStart=.3,this.lerpFactorRotEnd=.3,this.lerpFactorPosCamera=.3,this.lerpFactorRotCamera=.3,this.objXZQuat=new we,this.objXZQuatInv=new we,this.objXZRotMat=new bt,this.isFirstPerson=!1,this.didHit=!1,this.groundVelocity=new E,this.pushedVelocity=new E,this.groundYRotation=0,this.objectRealQuat=new we,this.colliderWorldQuat=new we,this.groundNormal=new E,this.groundTilt=new we,this.groundTiltInv=new we,this.lastHitObj=null,this.isFirstFrame=!0,this.rotationAccumWhenOrientWithCamera=0,this.navMeshPathDest=null,this.position=new E,this.quaternion=new we,this.scale=new E,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"&&!Uo&&!vU&&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"&&(vU&&uft<15.5&&!Uo?(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?Q7.isLocked=!0:Q7.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.object.parent instanceof Or||(this.object.matrixWorldAutoUpdate=!1,this.object.matrix.copy(this.object.matrixWorld)),this.shearMatrix0.copy(this.object.shearMatrix),_c(this.object.matrix,{translation:this.position,quaternion:this.quaternion,scale:this.scale,shearMatrix:this.object.shearMatrix}),this.euler0.setFromQuaternion(this.quaternion,"YXZ");let h=this.euler0.clone(),u=h.y;if(this.objectRealQuat.copy(this.quaternion),h.y=0,this.quaternion.setFromEuler(h),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),h.set(0,u,0),this.quaternion.setFromEuler(h),this.rot.setFromEuler(h),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.camera.parent instanceof Or||(this.camera.matrixWorldAutoUpdate=!1,this.camera.matrix.copy(this.camera.matrixWorld),this.cameraShearMatrix0.copy(this.camera.shearMatrix),_c(this.camera.matrix,{translation:this.camera.position,quaternion:this.camera.quaternion,scale:this.camera.scale,shearMatrix:this.camera.shearMatrix})),this.camera.matrixAutoUpdate=!1,this.offsetMatrix.copy(this.object.matrix).invert().multiply(this.camera.matrix);let m,f=new E(0,0,-1).applyQuaternion(this.camera.quaternion),g=new E().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 zi().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 zs&&(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??yv.defaultData.gravity),this.usePhysics=this.gloabalPhysics.usePhysics??yv.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??Z4.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*o8/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*o8/this.pixelsPerMeter,this.stepThresh=2*i.collider.radius*.3/this.pixelsPerMeter,this.colliderHeight=2*i.collider.radius):(this.offset=i.collider.height*o8/this.pixelsPerMeter,this.stepThresh=.3*i.collider.height/this.pixelsPerMeter,this.colliderHeight=i.collider.height),this.collider.type=i.collider.type;let d=new E().fromArray(i.collider.position.map(m=>typeof m=="number"?m:0)),c=new we().setFromEuler(new zi().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,Kdt),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 ue;m.push({fi:0,data:{...Is.defaultData("light","phong"),alpha:0},id:"layer1"}),m.push({fi:0,data:{...Is.defaultData("color"),color:i.navmesh.destinationHelperColor,alpha:i.navmesh.destinationHelperColor.a},id:"layer2"});let f=byt({layers:m},{scene:this.page.scene,shared:this.sharedAssets});this.navMeshPathDest=new gr(_W.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.matrixWorldAutoUpdate=!0,this.camera.matrixWorldAutoUpdate=!0,this.object.shearMatrix.copy(this.shearMatrix0),t){this.object.updateMatrix(),this.object.updateMatrixWorld(),this.object.parent instanceof Or||(this.object.matrixWorldAutoUpdate=!1,this.object.matrix.copy(this.object.matrixWorld)),_c(this.object.matrix,{translation:this.position,quaternion:this.quaternion,scale:this.scale,shearMatrix:this.object.shearMatrix});let e=new zi().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 zs?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.shearMatrix.copy(this.cameraShearMatrix0),t?(this.camera.updateMatrix(),this.camera.updateMatrixWorld(),this.camera.parent instanceof Or||(this.camera.matrixWorldAutoUpdate=!1,this.camera.matrix.copy(this.camera.matrixWorld),_c(this.camera.matrix,{translation:this.camera.position,quaternion:this.camera.quaternion,scale:this.camera.scale,shearMatrix:this.camera.shearMatrix}))):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={},K4.list.forEach(i=>{this.actions[i]=cn({...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"),ia(this.actions.idle),ia(this.actions.move),ia(this.actions.run),ia(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 ja.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=Fd.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,h=l===null?void 0:this.sharedGameControlGlobals.kinematicBodyToEntity.get(l.handle);if(l!==null&&h?.userData.isFollowingObj!==this.object.uuid){let u=this.object.getWorldPosition(ja).add(this.collider.position).divideScalar(this.pixelsPerMeter),d=l.velocityAtPoint(u);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=ja.subVectors(this.path[1],this.position),o=Fd.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=d5t.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1){let n=Fd.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=ja;this.camera.getWorldDirection(n);let a=s1.copy(Au).multiplyScalar(n.dot(Au));n.sub(a);let o=Fd.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(n1.setFromVector3(this.rot),this.moveMode==="walk"&&(n1.x=0),s.applyEuler(n1),r&&(tg.setFromUnitVectors(Au,this.groundNormal),s.applyQuaternion(tg)),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(h8,Jdt,f5t);let o=this.object.getWorldPosition(g5t).add(this.collider.position).sub(h8);tct.copy(a.prevQ).invert().premultiply(Jdt);let l=s1.subVectors(h8,a.prevT).add(y5t.copy(o).applyQuaternion(tct).sub(o)).divideScalar(e).divideScalar(this.pixelsPerMeter),h=a.rigidBody.collider(0).castCollider(l,this.object.rigidBody.collider(0),ja.copy(s).divideScalar(this.pixelsPerMeter),0,e,!1);l.multiplyScalar(this.pixelsPerMeter);let u=vi.is(a)?a:a.object;if(h!==null&&this.lastHitObj!==u){let d;a instanceof Za&&(d=a);let c=this.sharedGameControlGlobals.entityToCollisionEvents[u.uuid];if(c)for(let p of c)p.data.target==="character"&&(p.dispatch(d),u.dispatchEvent(Z7));this.lastHitObj=u}h!==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),Qdt(n++).copy(h.normal1).applyQuaternion(a.quaternion))}if(n>0){for(let a=0;a<n;a++){let o=Qdt(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(Au,this.euler.y-this.euler0.y);let n=Fd.copy(this.objectToCamXZ).normalize(),a=s1.copy(s).multiplyScalar(e);a.y=0;let o=a.sub(ja.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=zt.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):this.euler.x=zt.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset,this.PI_2+this.cameraPolarOffset):this.cameraXAxis==="Limit"&&(this.euler.x=zt.clamp(this.euler.x,-this.PI_2,this.PI_2))),this.moveMode==="fly"?this.rot.x=this.euler.x:this.isFirstPerson&&(n1.copy(this.euler),n1.y=0,this.nonColliderRotOffset.makeRotationFromEuler(n1)),al.setFromAxisAngle(p5t,this.rot.x),tg.setFromAxisAngle(Au,this.rot.y),tg.multiply(al),al.setFromAxisAngle(m5t,this.rot.z),tg.multiply(al),this.quaternion.copy(tg),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=Fd.copy(s).multiplyScalar(e/this.pixelsPerMeter),a=null;this.didHit=!1;let o=new E;for(let u=0;u<5;u++){let d=n.length(),c=s1.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){u===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&&u===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(Z7)}}}let m=$dt.set(a.normal2.x,a.normal2.y,a.normal2.z).applyQuaternion(this.colliderWorldQuat),f=Xdt.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=s1.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),ja.copy(this.position).divideScalar(this.pixelsPerMeter),al.copy(this.quaternion).premultiply(this.groundTilt).multiply(this.objXZQuat);let l=this.object.rigidBody,h=l!==void 0&&v5t.copy(ja).sub(l.translation()).lengthSq()>1;l!==void 0&&(h?(l.setTranslation(ja,!0),l.setRotation(al,!0)):(l.setNextKinematicTranslation(ja),l.setNextKinematicRotation(al)))}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),Hgt(this.position,this.quaternion,this.object.shearMatrix,this.scale,this.object.matrix).multiply(this.nonColliderPosOffset).multiply(this.nonColliderRotOffset),this.object.parent instanceof Or?this.object.matrixWorld.multiplyMatrices(this.object.parent.matrixWorld,this.object.matrix).multiply(this.object.pivotMatrix):this.object.matrixWorld.copy(this.object.matrix),this.object.children.forEach(n=>{n.updateMatrixWorld(!0)}),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);l8.lookAt(a,n,Au).setPosition(a),l8.decompose(this.targetPos,this.targetQuat,ja),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.matrixWorld.copy(this.camera.matrix),this.cameraYAxis==="Limit"&&this.orientMode==="cartesian"&&(this.euler.y=zt.clamp(this.euler.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel)),this.euler.x=zt.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(_5t),!(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(b5t),0))}updateFollowArms(){this.objectToTarget.copy(this.objectToTarget0),this.targetToCamera.copy(this.targetToCamera0);let t,e=al.setFromAxisAngle(Au,this.cameraYAxis==="Limit"&&this.orientMode!=="radial"?zt.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"?zt.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):zt.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset+1e-6,this.PI_2+this.cameraPolarOffset-1e-6);let i=ja.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&i.applyQuaternion(e);let r=tg.setFromAxisAngle(i,t);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(e),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(r)}groundTiltAdjustment(t){180*Au.angleTo(t)/Math.PI<15||180*Au.angleTo(t)/Math.PI>85?al.identity():al.setFromUnitVectors(Au,t),this.groundTilt.slerp(al,.06),this.groundTiltInv.copy(this.groundTilt).invert()}collisionAdjustment(t){let e=Xdt.set(0,0,0);this.object.matrix.compose(this.position,this.quaternion,this.scale);let i=l8.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(ja,al,Fd).compose(ja,al,Kdt);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(s=>{if(s===this.object||s.isDescendantOf(this.object)||!s.bvhGeometry||!s.bvhGeometry.boundsTree)return;Wl.makeEmpty(),s.updateMatrixWorldRigid();let n=s.matrixWorldRigid,a=Ydt.copy(n).invert(),o=c5t.copy(Ydt).multiply(i);Hn.copy(this.collider.segment),Hn.start.applyMatrix4(o),Hn.end.applyMatrix4(o);let l=$dt.copy(this.position).applyMatrix4(a);Wl.expandByPoint(Hn.start),Wl.expandByPoint(Hn.end),Wl.min.addScalar(-this.collider.radius),Wl.max.addScalar(this.collider.radius),s.bvhGeometry.boundsTree.shapecast({boundsTraverseOrder:h=>h.distanceToPoint(Hn.end),intersectsBounds:h=>h.intersectsBox(Wl),intersectsTriangle:h=>{let u=ja,d=Fd,c=h.closestPointToSegment(Hn,u,d);if(c<this.collider.radius){let p=this.collider.radius-c,m=d.sub(u).normalize(),f=s1.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)}}})}),Wl.makeEmpty(),Hn.copy(this.collider.segment),Hn.start.applyMatrix4(i),Hn.end.applyMatrix4(i),Wl.expandByPoint(Hn.start),Wl.expandByPoint(Hn.end),Wl.min.addScalar(-this.collider.radius),Wl.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({boundsTraverseOrder:s=>s.distanceToPoint(Hn.end),intersectsBounds:s=>s.intersectsBox(Wl),intersectsTriangle:s=>{let n=ja,a=Fd,o=s.closestPointToSegment(Hn,n,a);if(o<this.collider.radius){let l=this.collider.radius-o,h=a.sub(n).normalize();this.alignToGround&&this.groundTiltAdjustment(h),e.addScaledVector(h,l),Hn.start.addScaledVector(h,l),Hn.end.addScaledVector(h,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()}},mwt=Q7;mwt.isLocked=!1,ot(),bT(),ID(),db(),hb();var fwt,gwt,u8,x5t=new Promise(t=>{fwt=t});function w5t(t){return u8||(u8=async function(){let e=t??"https://cdn.spline.design/@splinetool/runtime@2.0.204/build";typeof window<"u"&&(gwt=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});fwt(a)}(),u8)}er();var ywt,Ri,ya,S5t=t=>`
|
|
5126
|
+
`)>=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 Y4t,o=(t.advanceWidth??1)*e;if(t)for(let l of n.commands){let h=a.currentPath?.currentPoint;if(!h||l.type==="Z"||h.x!==l.x||-h.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 h=function(u){if(u.length){let d=u[0];if(d instanceof pl)return d.v1;if(d instanceof Kl||d instanceof lc)return d.v0}}(l.curves);h!==void 0&&l.currentPoint.distanceTo(h)>0&&l.lineTo(h.x,h.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}},Nr("text"),De();var nwt=null;function Fdt(){return nwt}function Q4t(t){let e=!1;return t.scene.objects.forEach(i=>{i.data.type==="Page"&&!e&&i.data.publish.gameControlObject&&s0.traverseModuleInstances(t,i.id,(r,s,n)=>{for(let a of n)a.data.type==="GameControl"&&a.data.navmesh.enabled&&(e=!0)})}),e}er();var rP=(t,e)=>{let i=e.x-t.x,r=e.y-t.y;return Math.sqrt(i*i+r*r)},ZF=t=>t*(Math.PI/180),sP=new Map,Y5=(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)},K5=(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)},awt=t=>(t.preventDefault(),t.type.match(/^touch/)?t.changedTouches:t),Udt=()=>{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}},QF=(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")},JF=(t,e,i)=>{let r=owt(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},owt=t=>{let e={};return e[t]="",["webkit","Moz","o"].forEach(function(i){e[i+t.charAt(0).toUpperCase()+t.slice(1)]=""}),e},t8=(t,e)=>{for(let i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},K7=(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"&&(lwt="ontouchstart"in window,hwt=!!window.PointerEvent,uwt=!!window.MSPointerEvent);var lwt,hwt,uwt,i1,jdt={start:"mousedown",move:"mousemove",end:"mouseup"},Pw={};function bg(){}hwt?i1={start:"pointerdown",move:"pointermove",end:"pointerup, pointercancel"}:uwt?i1={start:"MSPointerDown",move:"MSPointerMove",end:"MSPointerUp"}:lwt?(i1={start:"touchstart",move:"touchmove",end:"touchend, touchcancel"},Pw=jdt):i1=jdt,bg.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},bg.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},bg.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)})},bg.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))},bg.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.')},Y5(t,i1[e],i._domHandlers_[e]),Pw[e]&&Y5(t,Pw[e],i._domHandlers_[e]),i},bg.prototype.unbindEvt=function(t,e){var i=this;return i._domHandlers_=i._domHandlers_||{},K5(t,i1[e],i._domHandlers_[e]),Pw[e]&&K5(t,Pw[e],i._domHandlers_[e]),delete i._domHandlers_[e],this};var Fq=bg;function Tn(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=Tn.id,Tn.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}Tn.prototype=new Fq,Tn.constructor=Tn,Tn.id=0,Tn.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},Tn.prototype.stylize=function(){if(this.options.dataOnly)return this;var t=this.options.fadeTime+"ms",e=(()=>{let s=owt("borderRadius");for(let n in s)Object.prototype.hasOwnProperty.call(s,n)&&(s[n]="50%");return s})(),i=JF("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)"},t8(r.el,i),this.options.shape==="circle"&&t8(r.back,e),t8(r.front,e),this.applyStyles(r),this},Tn.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},Tn.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)||this.options.zone.appendChild(this.ui.el),this},Tn.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)||this.options.zone.removeChild(this.ui.el),this},Tn.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},Tn.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},Tn.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},Tn.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=JF("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)},Tn.prototype.restCallback=function(){var t=this,e={};e.front=JF("transition","none",""),t.applyStyles(e),t.trigger("rested",t.instance)},Tn.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}},Tn.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 h={};for(o in this.direction={x:i,y:r,angle:e},t.direction=this.direction,l)l[o]===this.direction[o]&&(h[o]=!0);if(h.x&&h.y&&h.angle)return t;(!h.x||!h.y)&&this.trigger("plain",t),h.x||this.trigger("plain:"+i,t),h.y||this.trigger("plain:"+r,t),h.angle||this.trigger("dir dir:"+e,t)}else this.resetDirection();return t};var J4t=Tn;function qs(t,e){var i=this;i.nipples=[],i.idles=[],i.actives=[],i.ids=[],i.pressureIntervals={},i.manager=t,i.id=qs.id,qs.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}qs.prototype=new Fq,qs.constructor=qs,qs.id=0,qs.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}},qs.prototype.bindings=function(){var t=this;t.bindEvt(t.options.zone,"start"),t.options.zone.style.touchAction="none",t.options.zone.style.msTouchAction="none"},qs.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)}},qs.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 h=l.getBoundingClientRect();n.zone.removeChild(l),s=t,t={x:h.left+r.x,y:h.top+r.y}}var u=new J4t(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||(QF(u.ui.el,s),QF(u.ui.front,u.frontPosition)),i.nipples.push(u),i.trigger("added "+u.identifier+":added",u),i.manager.trigger("added "+u.identifier+":added",u),i.bindNipple(u),u},qs.prototype.updateBox=function(){this.box=this.options.zone.getBoundingClientRect()},qs.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)},qs.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)},qs.prototype.onstart=function(t){var e=this,i=e.options,r=t;return t=awt(t),e.updateBox(),K7(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},qs.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(h){h.trigger("start",h),i.trigger("start "+h.id+":start",h),h.show(),n>0&&i.pressureFn(t,h,h.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(!(rP(a,o.position)<=r.catchDistance))return o.destroy(),void i.processOnStart(t);l(o)}return o},qs.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)},qs.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 h,u,d=rP(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=ZF(c),m=d/o,f={distance:d,position:l};if(s.options.shape==="circle"?(h=Math.min(d,o),u=((b,_,x)=>{let S={x:0,y:0};return x=ZF(x),S.x=b.x-_*Math.cos(x),S.y=b.y-_*Math.sin(x),S})(s.position,h,c)):(u=((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),h=rP(u,s.position)),i.follow){if(d>o){let b=l.x-u.x,_=l.y-u.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=rP(l,s.position)}}else l=u,d=h;var g=l.x-s.position.x,y=l.y-s.position.y;s.frontPosition={x:g,y},i.dataOnly||QF(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:ZF(180-c),degree:180-c},s.trigger("move",v),e.trigger("move "+s.id+":move",v)}else this.processOnEnd(t)},qs.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))},qs.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()},qs.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 t5t=qs;function nn(t){var e=this;e.ids={},e.index=0,e.collections=[],e.scroll=Udt(),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=>{sP.has(r)&&clearTimeout(sP.get(r)),sP.set(r,setTimeout(function(){sP.delete(r),r()},100))})(i)},e._onScroll=function(){e.scroll=Udt()},e.collections}nn.prototype=new Fq,nn.constructor=nn,nn.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}},nn.prototype.create=function(t){return this.createCollection(t)},nn.prototype.bindWindowEvents=function(){var t=this;t._windowBound||typeof window>"u"||(t._windowBound=!0,Y5(window,"resize",t._onResize),Y5(window,"scroll",t._onScroll))},nn.prototype.unbindWindowEvents=function(){var t=this;!t._windowBound||typeof window>"u"||(t._windowBound=!1,K5(window,"resize",t._onResize),K5(window,"scroll",t._onScroll))},nn.prototype.createCollection=function(t){var e=this,i=new t5t(e,t);return e.bindCollection(i),e.collections.push(i),e.bindWindowEvents(),i},nn.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)},nn.prototype.bindDocument=function(){var t=this;t.binded||(t.bindEvt(document,"move").bindEvt(document,"end"),t.binded=!0)},nn.prototype.unbindDocument=function(t){var e=this;(!Object.keys(e.ids).length||t===!0)&&(e.unbindEvt(document,"move").unbindEvt(document,"end"),e.binded=!1)},nn.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]},nn.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},nn.prototype.onmove=function(t){return this.onAny("move",t),!1},nn.prototype.onend=function(t){return this.onAny("end",t),!1},nn.prototype.oncancel=function(t){return this.onAny("end",t),!1},nn.prototype.onAny=function(t,e){var i,r=this,s="processOn"+t.charAt(0).toUpperCase()+t.slice(1);e=awt(e);var n=function(a,o,l){l.ids.indexOf(o)>=0&&(l[s](a),a._found_=!0)};return K7(e,function(a){i=r.getIdentifier(a),K7(r.collections,n.bind(null,a,i)),a._found_||r.removeIdentifier(i)}),!1},nn.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()},nn.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 e5t=nn,Nv=null;function Gdt(){return Nv||(Nv=new e5t),Nv}var i5t={create:function(t){return Gdt().create(t)},destroy:function(){Nv&&(Nv.destroy(),Nv=null)},get factory(){return Gdt()}},r5t=i5t;er(),De(),ot(),Kh(),ob(),rh(),yo(),De();var dwt=null;function e8(){return dwt}var cwt,i8,s5t=new Promise(t=>{cwt=t});function n5t(t){return i8||(i8=async function(){let e=t??"https://cdn.spline.design/@splinetool/runtime@2.0.206/build",i=import("./physics.js"),[r,s]=await Promise.all([i,fetch(`${e}/physics.wasm`).then(n=>n.arrayBuffer())]);await r.init(s),cwt(r)}(),i8)}function pwt(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 oc(t,e){let i=new fe;if(e&&pwt(e))return i.setAttribute("position",new me([],3)),i.setIndex([]),i;if(!t.getAttribute("position"))return i.setAttribute("position",new me([],3)),i.setIndex([]),i;let{positions:r,triIndices:s}=PW(t.getAttribute("position"),t.getIndex());return i.setAttribute("position",new me(r,3)),i.setIndex(s),e&&i.applyMatrix4(e),i}Jr(),yo(),Oi(),WW(),ot(),ot(),hb(),bT();var Bi,a5t=class{constructor(t,e,i,r,s,n){this.id=t,this.data=e,this.object=i,this.initialDisabled=!1,this.actions=cn(e,e.actions,r,s,n,i),this.target=e.target}disconnect(){ia(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()))}},Wdt=class{constructor(t,e,i,r,s,n){this.id=t,this.data=e,this.object=i,this.page=r,this.currentIntersectedObjects=[],this.actions=cn(e,e.actions,r,s,n,i),this.target=e.target,this.triggeringObjects=[];for(let a of e.triggeringObjects){let o=r.scene.findFrom(a,i);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(){ia(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()))}};Jr(),vT(),dD(),s5t.then(t=>Bi=t);var sn=new E,Gl=new we,r8=new E,o5t=new E(1,1,1),s8=(new zi(0,0,0,"YXZ"),new zi(0,0,0,"XYZ")),Ld=new E,qdt=new E,Rw=new we,nP=new bt,Hdt=new bt,l5t={type:"updateMatrix"},n8=(new we,new Zn),a8=.01,Z7={type:"beginEvent",eventName:"Collision"},h5t={type:"beginEvent",eventName:"Trigger"},Z5=t=>t.states.some(e=>e.data.position!==void 0||e.data.rotation!==void 0||e.data.shear!==void 0||e.data.cloner!==void 0||e.data.pathSnapping!==void 0);function r1(t){return function(e){return typeof e=="object"&&e!==null&&"booleanOp"in e}(am(t)?t.object:t)}var u5t=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()!==Bi.RigidBodyType.Dynamic)return;e.isSleeping()||this.nActiveRigidBodies++;let[i,r]=this.rigidBodyToMesh.get(e.handle);if(sn.copy(e.translation()).multiplyScalar(this.pixelsPerMeter),Gl.copy(e.rotation()),i.matrixWorld.makeRotationFromQuaternion(Gl).setPosition(sn),i.matrixWorld.multiply(i.shearScale),i.dispatchEvent(l5t),r){let s=i.cloner;if(s&&s.objectForSample===void 0){s.matrixWorld.copy(i.matrixWorld);for(let n of s.children)n.updateMatrixWorld(!0)}for(let n of i.children)n.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 u of o)u.data.target==="scene"&&this.dispatchCollisionEvent(u,a,e);let l=this.sharedGameControlGlobals.colliderToEntity.get(i),h=this.sharedGameControlGlobals.entityToCollisionEvents[l?.uuid];if(h!==void 0)for(let u of h)u.data.target==="scene"&&this.dispatchCollisionEvent(u,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(e8()===null)return void On("collision-bvh","trigger/collision detection");let t=[],e=[];if(this.page.traverseChildren(i=>{let r,s=i instanceof Tv,n=uS(i);if(nm(i)||s||n)return;r=am(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,h=r.userData.hasDrag===!0;if(Z5(a)||l||h||r.dataPatched.events.some(u=>u.data.disabled!==!0&&(u.data.type==="GameControl"||u.data.type==="Follow")))return i.updateMatrixWorldRigid(),this.addBoundsTree(i),!0;if(o){let u=o.getAttribute("position");if(u!==void 0&&u.count>0){t.push({geometry:o,matrixWorld:i.matrixWorld}),e.push(o.id,this._staticBVHIdOf(u),u.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!!r1(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=Ig(t.map(n=>oc(n.geometry,n.matrixWorld)),!1),s=new(e8())(r);this._staticBVHCache={signature:e,bvh:s},this.sharedGameControlGlobals.staticMeshBVH=s}}addRigidBody(t,e,i){if(pwt(t.matrixWorld))return;let r=[],s="geometry"in t?t.geometry:void 0,n=e.dataPatched;if(s?.getAttribute("position")!==void 0&&r.push(oc(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=Bi.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=Bi.RigidBodyDesc.kinematicPositionBased(),o=!0):a=Bi.RigidBodyDesc.fixed();let h=Ig(r);sn.setFromMatrixPosition(t.matrixWorld),Gl.setFromRotationMatrix(t.matrixWorldRigid),t.position0=sn.clone().divideScalar(this.pixelsPerMeter),t.rotation0=Gl.clone(),sn.divideScalar(this.pixelsPerMeter),a.setTranslation(sn.x,sn.y,sn.z).setRotation(Gl),h?.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter);let u=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(u,n.physics,h,e,d)}catch{try{this.addCollider(u,n.physics,h,e,!1)}catch(c){console.error(c)}}if(u.numColliders()===0)return void this.sharedGameControlGlobals.rapierWorld.removeRigidBody(u);l?this.rigidBodyToMesh.set(u.handle,[t,n.physics.fusedBody]):o?(this.sharedGameControlGlobals.kinematicBodyToEntity.set(u.handle,t),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(t)):this.fixedBodiesToWatch.push([t,u,(t.hasNonUniformScale?t.matrixWorldRigid:t.matrixWorld).clone()]),t.rigidBody=u}}addBoundsTree(t){let e=[];if(t.geometry?.getAttribute("position")!==void 0&&t.geometry?.getAttribute("position").count>0&&e.push(oc(t.geometry,t.shearScale)),t.traverseObject(this.gatherChildrenGeom(t,e)),t.children.forEach(i=>i.updateMatrixWorld(!0)),e.length>0){let i=Ig(e,!1);t.bvhGeometry=i,i.getAttribute("position").count>0&&(t.bvhGeometry.boundsTree=new(e8())(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"?Bi.ColliderDesc.trimesh(i.getAttribute("position").array,i.getIndex().array):Bi.ColliderDesc.convexMesh(i.getAttribute("position").array,s?i.getIndex().array:void 0)),n.setFrictionCombineRule(Bi.CoefficientCombineRule.Average).setRestitutionCombineRule(Bi.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(Bi.ActiveEvents.COLLISION_EVENTS)}gatherChildrenGeom(t,e){let i=r1(t);return(r,s)=>{if(s===0)return;if(i&&r.parent===t)return!0;let n;if(nm(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(am(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?r.matrixWorld.copy(t.shearScale):r.matrixWorld.copy(r.parent.matrixWorld),r.matrixWorld.multiply(r.matrix);let o=r.geometry;return o?.getAttribute("position")!==void 0&&e.push(oc(o,r.matrixWorld)),!!r1(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=Fdt();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&&On("game-controls","the scene's game controls"),i===!1){let{enableRotate:a,enablePan:o,enableZoom:l,autoRotate:h,hoverRotatePanMode:u}=this.eventManager.publish.orbitControls;(a||o||l||h||u!==0)&&(this.orbitControls=new Wxt(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();Fdt()?.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 Bi.World(new Bi.Vector3(0,this.gravity,0)),this.events=new Bi.EventQueue(!0);let t=[],e=[];if(this.page.traverseChildren(a=>{let o;if(nm(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(am(a))o=a.object;else{if(uS(a)||n0(a)||a instanceof Tv)return;if(o=a,o.dataPatched.cloner?.disabled===!1&&o.dataPatched.cloner?.hideBase&&o.dataPatched.physics?.fusedBody!==!0)return!0}let l,h=o.dataPatched;for(let g of h.events)g.data.disabled!==!0&&g.data.type==="GameControl"&&(l=g.data);if(!h.physics||(h.physics.enabled==="visibility"?!h.visible:!h.physics.enabled))return!0;a.updateMatrixWorldRigid();let u=Z5(h),d=!1,c=o.userData.hasDestroy,p=o.userData.hasDrag,m=!1;for(let g of h.events)if(g.data.disabled!==!0){if(g.data.type==="Collision"){d=!0;let y=new a5t(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})}}h.physics.rigidBody==="dynamic"&&h.physics.fusedBody===!1&&(a.matrixWorldFusedFalse=a.matrixWorld.clone());let f=a.geometry;if(l!==void 0){let g=Bi.RigidBodyDesc.kinematicPositionBased();(a.hasNonUniformScale?a.matrixWorldRigid:a.matrixWorld).decompose(sn,Gl,r8),a.position0=sn.clone().divideScalar(this.pixelsPerMeter),a.rotation0=Gl.clone(),sn.divideScalar(this.pixelsPerMeter),g.setTranslation(sn.x,sn.y,sn.z).setRotation(Gl);let y,v=this.sharedGameControlGlobals.rapierWorld.createRigidBody(g);a.rigidBody=v,y=l.collider.type==="sphere"?Bi.ColliderDesc.ball(l.collider.radius/this.pixelsPerMeter):l.collider.type==="capsule"?Bi.ColliderDesc.capsule((l.collider.height/2-l.collider.radius)/this.pixelsPerMeter,l.collider.radius/this.pixelsPerMeter):Bi.ColliderDesc.cuboid(l.collider.width/this.pixelsPerMeter/2,l.collider.height/this.pixelsPerMeter/2,l.collider.depth/this.pixelsPerMeter/2),y.setFrictionCombineRule(Bi.CoefficientCombineRule.Average).setDensity(h.physics.density).setFriction(h.physics.friction).setRestitution(0).setRestitutionCombineRule(Bi.CoefficientCombineRule.Min);let b=this.sharedGameControlGlobals.rapierWorld.createCollider(y,v);this.sharedGameControlGlobals.colliderToEntity.set(b.handle,o),sn.fromArray(l.collider.position.map(x=>typeof x=="number"?x:0)).multiply(r8.setFromMatrixScale(o.matrixWorld)).divideScalar(this.pixelsPerMeter),b.setTranslationWrtParent(sn);let _=new we().setFromEuler(new zi().setFromVector3(new E().fromArray(l.collider.rotation.map(x=>typeof x=="number"?x:0))));b.setRotationWrtParent(_),b.setActiveEvents(Bi.ActiveEvents.COLLISION_EVENTS),this.generateSensorColliderDescs(o,!0)}else h.physics.rigidBody==="dynamic"||u||m||c||p||d?(this.addRigidBody(a,o,{hasFollow:m,hasTransformAnim:u,hasDrag:p}),this.generateSensorColliderDescs(o,h.physics.fusedBody)):(f&&t.push(oc(f,a.matrixWorld)),h.physics.fusedBody&&!r1(a)&&a.traverseObject((g,y)=>{if(y===0)return;let v;if(nm(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(uS(g)||n0(g)||g instanceof Tv)return;if(am(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(oc(_,g.matrixWorld)),!!r1(g)||void 0}),this.generateSensorColliderDescs(o,h.physics.fusedBody,e));return!(h.physics?.fusedBody!==!0&&!l&&!r1(a))||void 0}),t.length===0)return;let i=Ig(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=Bi.RigidBodyDesc.fixed(),n=this.sharedGameControlGlobals.rapierWorld.createRigidBody(s);if(r){let a=Bi.ColliderDesc.trimesh(i.getAttribute("position").array,i.getIndex().array).setFrictionCombineRule(Bi.CoefficientCombineRule.Multiply).setRestitutionCombineRule(Bi.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 Wdt(e.id,e.data,t,this.page,this.sharedAssets,this.eventManager),r=new bt().compose(Ld.fromArray(e.data.position.map(s=>typeof s=="number"?s:0)),Rw.setFromEuler(s8.fromArray(e.data.rotation.map(s=>typeof s=="number"?s:0))),o5t);if(e.data.triggerZone==="box"){let s=new dr;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(sn,Gl,r8);let e=t;e.prevQ===void 0?(e.prevQ=Gl.clone(),e.prevT=sn.clone()):(e.prevQ.copy(Gl),e.prevT.copy(sn))}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(Bi.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 h=l.translation(),u=-1/0,d=0,c=0;if(e.contactPair(a,o,y=>{let v=y.normal(),b=v.x*(h.x-r.x)+v.y*(h.y-r.y)+v.z*(h.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>u&&(u=w,d=_/S,c=x/S)}),u===-1/0)return;let p=i.x*d+i.z*c;if(p<-a8)return;let m=l.linvel();if(s>a8&&p>a8){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(sn.divideScalar(this.pixelsPerMeter)),i.rigidBody.setNextKinematicRotation(Gl)):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(Z7)}updateUseWindowEvents(t){this.orbitControls?.updateUseWindowEvents(t)}generateSensorColliderDescs(t,e,i){let r=Hdt.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 Wdt(a.id,a.data,s,this.page,this.sharedAssets,this.eventManager);if(o=a.data.triggerZone==="box"?Bi.ColliderDesc.cuboid(...a.data.size.map(h=>(typeof h=="number"?h:1)/(2*this.pixelsPerMeter))):Bi.ColliderDesc.ball(a.data.radius/this.pixelsPerMeter),o.setDensity(0).setSensor(!0).setActiveEvents(Bi.ActiveEvents.COLLISION_EVENTS),Ld.fromArray(a.data.position.map(h=>typeof h=="number"?h:0)),Rw.setFromEuler(s8.fromArray(a.data.rotation.map(h=>typeof h=="number"?h:0))),nP.makeRotationFromEuler(s8).setPosition(Ld).premultiply(s.matrixWorld),i?(_c(nP,{translation:Ld,quaternion:Rw,scale:qdt}),o.setActiveCollisionTypes(Bi.ActiveCollisionTypes.KINEMATIC_FIXED|Bi.ActiveCollisionTypes.DYNAMIC_FIXED)):(_c(nP.premultiply(r),{translation:Ld,quaternion:Rw,scale:qdt}),t.rigidBody.bodyType()===Bi.RigidBodyType.Dynamic||(t.rigidBody.bodyType()===Bi.RigidBodyType.Fixed?o.setActiveCollisionTypes(Bi.ActiveCollisionTypes.KINEMATIC_FIXED|Bi.ActiveCollisionTypes.DYNAMIC_FIXED):o.setActiveCollisionTypes(Bi.ActiveCollisionTypes.KINEMATIC_KINEMATIC|Bi.ActiveCollisionTypes.DYNAMIC_KINEMATIC))),Ld.divideScalar(this.pixelsPerMeter),o.setTranslation(Ld.x,Ld.y,Ld.z),o.setRotation(Rw),i)i.push([o,l]);else{let h=this.sharedGameControlGlobals.rapierWorld.createCollider(o,t.rigidBody);this.sensorToTriggerEvent[h.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(vi.is(o)?o:o.object)===!1)continue;let l=Hdt.copy(sgt(s.matrixWorld)).copyPosition(s.matrixWorld).multiply(r),h=nP.copy(o.matrixWorld).invert().multiply(l),u=o.bvhGeometry.boundsTree;i instanceof dr?t=u.intersectsBox(i,h):(n8.radius=i,n8.center.setFromMatrixPosition(h),t=u.intersectsSphere(n8)),t?n.currentIntersectedObjects.indexOf(o)===-1&&(n.currentIntersectedObjects.push(o),n.dispatch(),s.dispatchEvent(h5t)):n.currentIntersectedObjects=n.currentIntersectedObjects.filter(d=>d!==o)}}}};db(),ot(),r5(),Li(),vT(),Em();var o8=.02,$dt=new E,Xdt=new E,d5t=new E,ja=new E,Fd=new E,s1=new E,l8=new bt,Ydt=new bt,c5t=new bt,al=new we,tg=new we,n1=new zi(0,0,0,"YXZ"),p5t=new E(1,0,0),Au=new E(0,1,0),m5t=new E(0,0,1),Kdt=new E(1,1,1),Zdt=[],Qdt=t=>Zdt[t]??(Zdt[t]=new E),h8=new E,f5t=new E,g5t=new E,y5t=new E,Jdt=new we,v5t=new E,tct=new we,Hn=new vl,Wl=new dr,b5t={type:"requestRender"},_5t={type:"updateMatrix"},Q7=class extends Pn{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.target0=new E,this.zoom0=1,this.rotForce=1,this.moveForce=1,this.pixelsPerMeter=200,this.euler0=new zi(0,0,0,"YXZ"),this.shearMatrix0=new bt,this.cameraShearMatrix0=new bt,this.position0Cam=new E,this.quat0Cam=new we,this.scale0Cam=new E,this.threshEndTranslate=.01,this.threshEndRotate=1e-8,this.threshEndRotVel=.005,this.collider={type:"capsule",radius:40,segment:new vl(new E(0,-40,0),new E(0,40,0)),matrix:new bt,position:new E,rotation:new we},this.euler=new zi(0,0,0,"YXZ"),this.eulerDelta=new E,this.lastPosition=new E,this.lastCameraQuaternion=new we,this.lastCameraPosition=new E,this.PI_2=Math.PI/2,this.prevMouse=new Y,this.velocityTarget=new E,this.velocity=new E,this.directionXZ=new E,this.rotVelocityStick=new E,this.rotVelocityTarget=new E,this.rotVelocity=new E,this.rotDirection=new E,this.nonColliderRotOffset=new bt,this.nonColliderPosOffset=new bt,this.firstPointerId=-1,this.rot=new E,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 E,this.objectToTarget0=new E,this.objectToCamXZ=new E,this.objectToCamXZ0=new E,this.targetToCamera=new E,this.targetToCamera0=new E,this.cameraPolarAxis0=new E,this.targetPos=new E,this.targetQuat=new we,this.lerpFactorPos=new E().setScalar(.3),this.lerpFactorPosStart=.3,this.lerpFactorPosEnd=.3,this.lerpFactorRotStart=.3,this.lerpFactorRotEnd=.3,this.lerpFactorPosCamera=.3,this.lerpFactorRotCamera=.3,this.objXZQuat=new we,this.objXZQuatInv=new we,this.objXZRotMat=new bt,this.isFirstPerson=!1,this.didHit=!1,this.groundVelocity=new E,this.pushedVelocity=new E,this.groundYRotation=0,this.objectRealQuat=new we,this.colliderWorldQuat=new we,this.groundNormal=new E,this.groundTilt=new we,this.groundTiltInv=new we,this.lastHitObj=null,this.isFirstFrame=!0,this.rotationAccumWhenOrientWithCamera=0,this.navMeshPathDest=null,this.position=new E,this.quaternion=new we,this.scale=new E,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"&&!Uo&&!vU&&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"&&(vU&&uft<15.5&&!Uo?(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?Q7.isLocked=!0:Q7.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.object.parent instanceof Or||(this.object.matrixWorldAutoUpdate=!1,this.object.matrix.copy(this.object.matrixWorld)),this.shearMatrix0.copy(this.object.shearMatrix),_c(this.object.matrix,{translation:this.position,quaternion:this.quaternion,scale:this.scale,shearMatrix:this.object.shearMatrix}),this.euler0.setFromQuaternion(this.quaternion,"YXZ");let h=this.euler0.clone(),u=h.y;if(this.objectRealQuat.copy(this.quaternion),h.y=0,this.quaternion.setFromEuler(h),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),h.set(0,u,0),this.quaternion.setFromEuler(h),this.rot.setFromEuler(h),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.camera.parent instanceof Or||(this.camera.matrixWorldAutoUpdate=!1,this.camera.matrix.copy(this.camera.matrixWorld),this.cameraShearMatrix0.copy(this.camera.shearMatrix),_c(this.camera.matrix,{translation:this.camera.position,quaternion:this.camera.quaternion,scale:this.camera.scale,shearMatrix:this.camera.shearMatrix})),this.camera.matrixAutoUpdate=!1,this.offsetMatrix.copy(this.object.matrix).invert().multiply(this.camera.matrix);let m,f=new E(0,0,-1).applyQuaternion(this.camera.quaternion),g=new E().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 zi().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 zs&&(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??yv.defaultData.gravity),this.usePhysics=this.gloabalPhysics.usePhysics??yv.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??Z4.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*o8/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*o8/this.pixelsPerMeter,this.stepThresh=2*i.collider.radius*.3/this.pixelsPerMeter,this.colliderHeight=2*i.collider.radius):(this.offset=i.collider.height*o8/this.pixelsPerMeter,this.stepThresh=.3*i.collider.height/this.pixelsPerMeter,this.colliderHeight=i.collider.height),this.collider.type=i.collider.type;let d=new E().fromArray(i.collider.position.map(m=>typeof m=="number"?m:0)),c=new we().setFromEuler(new zi().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,Kdt),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 ue;m.push({fi:0,data:{...Is.defaultData("light","phong"),alpha:0},id:"layer1"}),m.push({fi:0,data:{...Is.defaultData("color"),color:i.navmesh.destinationHelperColor,alpha:i.navmesh.destinationHelperColor.a},id:"layer2"});let f=byt({layers:m},{scene:this.page.scene,shared:this.sharedAssets});this.navMeshPathDest=new gr(_W.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.matrixWorldAutoUpdate=!0,this.camera.matrixWorldAutoUpdate=!0,this.object.shearMatrix.copy(this.shearMatrix0),t){this.object.updateMatrix(),this.object.updateMatrixWorld(),this.object.parent instanceof Or||(this.object.matrixWorldAutoUpdate=!1,this.object.matrix.copy(this.object.matrixWorld)),_c(this.object.matrix,{translation:this.position,quaternion:this.quaternion,scale:this.scale,shearMatrix:this.object.shearMatrix});let e=new zi().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 zs?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.shearMatrix.copy(this.cameraShearMatrix0),t?(this.camera.updateMatrix(),this.camera.updateMatrixWorld(),this.camera.parent instanceof Or||(this.camera.matrixWorldAutoUpdate=!1,this.camera.matrix.copy(this.camera.matrixWorld),_c(this.camera.matrix,{translation:this.camera.position,quaternion:this.camera.quaternion,scale:this.camera.scale,shearMatrix:this.camera.shearMatrix}))):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={},K4.list.forEach(i=>{this.actions[i]=cn({...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"),ia(this.actions.idle),ia(this.actions.move),ia(this.actions.run),ia(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 ja.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=Fd.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,h=l===null?void 0:this.sharedGameControlGlobals.kinematicBodyToEntity.get(l.handle);if(l!==null&&h?.userData.isFollowingObj!==this.object.uuid){let u=this.object.getWorldPosition(ja).add(this.collider.position).divideScalar(this.pixelsPerMeter),d=l.velocityAtPoint(u);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=ja.subVectors(this.path[1],this.position),o=Fd.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=d5t.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1){let n=Fd.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=ja;this.camera.getWorldDirection(n);let a=s1.copy(Au).multiplyScalar(n.dot(Au));n.sub(a);let o=Fd.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(n1.setFromVector3(this.rot),this.moveMode==="walk"&&(n1.x=0),s.applyEuler(n1),r&&(tg.setFromUnitVectors(Au,this.groundNormal),s.applyQuaternion(tg)),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(h8,Jdt,f5t);let o=this.object.getWorldPosition(g5t).add(this.collider.position).sub(h8);tct.copy(a.prevQ).invert().premultiply(Jdt);let l=s1.subVectors(h8,a.prevT).add(y5t.copy(o).applyQuaternion(tct).sub(o)).divideScalar(e).divideScalar(this.pixelsPerMeter),h=a.rigidBody.collider(0).castCollider(l,this.object.rigidBody.collider(0),ja.copy(s).divideScalar(this.pixelsPerMeter),0,e,!1);l.multiplyScalar(this.pixelsPerMeter);let u=vi.is(a)?a:a.object;if(h!==null&&this.lastHitObj!==u){let d;a instanceof Za&&(d=a);let c=this.sharedGameControlGlobals.entityToCollisionEvents[u.uuid];if(c)for(let p of c)p.data.target==="character"&&(p.dispatch(d),u.dispatchEvent(Z7));this.lastHitObj=u}h!==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),Qdt(n++).copy(h.normal1).applyQuaternion(a.quaternion))}if(n>0){for(let a=0;a<n;a++){let o=Qdt(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(Au,this.euler.y-this.euler0.y);let n=Fd.copy(this.objectToCamXZ).normalize(),a=s1.copy(s).multiplyScalar(e);a.y=0;let o=a.sub(ja.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=zt.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):this.euler.x=zt.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset,this.PI_2+this.cameraPolarOffset):this.cameraXAxis==="Limit"&&(this.euler.x=zt.clamp(this.euler.x,-this.PI_2,this.PI_2))),this.moveMode==="fly"?this.rot.x=this.euler.x:this.isFirstPerson&&(n1.copy(this.euler),n1.y=0,this.nonColliderRotOffset.makeRotationFromEuler(n1)),al.setFromAxisAngle(p5t,this.rot.x),tg.setFromAxisAngle(Au,this.rot.y),tg.multiply(al),al.setFromAxisAngle(m5t,this.rot.z),tg.multiply(al),this.quaternion.copy(tg),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=Fd.copy(s).multiplyScalar(e/this.pixelsPerMeter),a=null;this.didHit=!1;let o=new E;for(let u=0;u<5;u++){let d=n.length(),c=s1.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){u===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&&u===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(Z7)}}}let m=$dt.set(a.normal2.x,a.normal2.y,a.normal2.z).applyQuaternion(this.colliderWorldQuat),f=Xdt.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=s1.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),ja.copy(this.position).divideScalar(this.pixelsPerMeter),al.copy(this.quaternion).premultiply(this.groundTilt).multiply(this.objXZQuat);let l=this.object.rigidBody,h=l!==void 0&&v5t.copy(ja).sub(l.translation()).lengthSq()>1;l!==void 0&&(h?(l.setTranslation(ja,!0),l.setRotation(al,!0)):(l.setNextKinematicTranslation(ja),l.setNextKinematicRotation(al)))}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),Hgt(this.position,this.quaternion,this.object.shearMatrix,this.scale,this.object.matrix).multiply(this.nonColliderPosOffset).multiply(this.nonColliderRotOffset),this.object.parent instanceof Or?this.object.matrixWorld.multiplyMatrices(this.object.parent.matrixWorld,this.object.matrix).multiply(this.object.pivotMatrix):this.object.matrixWorld.copy(this.object.matrix),this.object.children.forEach(n=>{n.updateMatrixWorld(!0)}),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);l8.lookAt(a,n,Au).setPosition(a),l8.decompose(this.targetPos,this.targetQuat,ja),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.matrixWorld.copy(this.camera.matrix),this.cameraYAxis==="Limit"&&this.orientMode==="cartesian"&&(this.euler.y=zt.clamp(this.euler.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel)),this.euler.x=zt.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(_5t),!(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(b5t),0))}updateFollowArms(){this.objectToTarget.copy(this.objectToTarget0),this.targetToCamera.copy(this.targetToCamera0);let t,e=al.setFromAxisAngle(Au,this.cameraYAxis==="Limit"&&this.orientMode!=="radial"?zt.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"?zt.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):zt.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset+1e-6,this.PI_2+this.cameraPolarOffset-1e-6);let i=ja.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&i.applyQuaternion(e);let r=tg.setFromAxisAngle(i,t);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(e),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(r)}groundTiltAdjustment(t){180*Au.angleTo(t)/Math.PI<15||180*Au.angleTo(t)/Math.PI>85?al.identity():al.setFromUnitVectors(Au,t),this.groundTilt.slerp(al,.06),this.groundTiltInv.copy(this.groundTilt).invert()}collisionAdjustment(t){let e=Xdt.set(0,0,0);this.object.matrix.compose(this.position,this.quaternion,this.scale);let i=l8.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(ja,al,Fd).compose(ja,al,Kdt);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(s=>{if(s===this.object||s.isDescendantOf(this.object)||!s.bvhGeometry||!s.bvhGeometry.boundsTree)return;Wl.makeEmpty(),s.updateMatrixWorldRigid();let n=s.matrixWorldRigid,a=Ydt.copy(n).invert(),o=c5t.copy(Ydt).multiply(i);Hn.copy(this.collider.segment),Hn.start.applyMatrix4(o),Hn.end.applyMatrix4(o);let l=$dt.copy(this.position).applyMatrix4(a);Wl.expandByPoint(Hn.start),Wl.expandByPoint(Hn.end),Wl.min.addScalar(-this.collider.radius),Wl.max.addScalar(this.collider.radius),s.bvhGeometry.boundsTree.shapecast({boundsTraverseOrder:h=>h.distanceToPoint(Hn.end),intersectsBounds:h=>h.intersectsBox(Wl),intersectsTriangle:h=>{let u=ja,d=Fd,c=h.closestPointToSegment(Hn,u,d);if(c<this.collider.radius){let p=this.collider.radius-c,m=d.sub(u).normalize(),f=s1.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)}}})}),Wl.makeEmpty(),Hn.copy(this.collider.segment),Hn.start.applyMatrix4(i),Hn.end.applyMatrix4(i),Wl.expandByPoint(Hn.start),Wl.expandByPoint(Hn.end),Wl.min.addScalar(-this.collider.radius),Wl.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({boundsTraverseOrder:s=>s.distanceToPoint(Hn.end),intersectsBounds:s=>s.intersectsBox(Wl),intersectsTriangle:s=>{let n=ja,a=Fd,o=s.closestPointToSegment(Hn,n,a);if(o<this.collider.radius){let l=this.collider.radius-o,h=a.sub(n).normalize();this.alignToGround&&this.groundTiltAdjustment(h),e.addScaledVector(h,l),Hn.start.addScaledVector(h,l),Hn.end.addScaledVector(h,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()}},mwt=Q7;mwt.isLocked=!1,ot(),bT(),ID(),db(),hb();var fwt,gwt,u8,x5t=new Promise(t=>{fwt=t});function w5t(t){return u8||(u8=async function(){let e=t??"https://cdn.spline.design/@splinetool/runtime@2.0.206/build";typeof window<"u"&&(gwt=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});fwt(a)}(),u8)}er();var ywt,Ri,ya,S5t=t=>`
|
|
5127
5127
|
(async function() {
|
|
5128
5128
|
const [wasmImport, wasmBinary] = await Promise.all([
|
|
5129
5129
|
import('${t}' + 'navmesh.js'),
|
|
@@ -5133,7 +5133,7 @@ void main() {
|
|
|
5133
5133
|
self.module = await wasmModule({ wasmBinary });
|
|
5134
5134
|
postMessage('ready');
|
|
5135
5135
|
})();
|
|
5136
|
-
`,T5t={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};x5t.then(t=>{ywt=t,Ri=new t.Vec3,ya=new t.Vec3});var M5t=new E,A5t=class{constructor(t=!1,e=!1){this.usePhysics=t,this.isExport=e,this.onPointerDown=i=>{if(Ue.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=M5t.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 Ec){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 Za)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=Z5(a),l=n.userData.hasDestroy,h=n.userData.hasDrag,u=!1,d=!1;for(let c of a.events)c.data.disabled!==!0&&(c.data.type==="GameControl"?u=!0:c.data.type==="Follow"&&(d=!0));if(u||o||d||l||h)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(oc(s.geometry,s.matrixWorld)),this.usePhysics&&a.physics?.fusedBody)return s.traverseObject((c,p)=>{if(p===0)return;let m;if(c instanceof Ec){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 Za)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(oc(c.geometry,c.matrixWorld))}),!0},this.traverseNoPhysics=(i,r)=>s=>{let n;if(s instanceof Ec)return;n=s instanceof Za?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,h=n.userData.hasDrag===!0;if(Z5(a)||l||h||n.dataPatched.events.some(u=>u.data.disabled!==!0&&u.data.type==="GameControl"))return!0;o&&i.push(oc(o,s.matrixWorld))},this.navmeshWasm=ywt,this.navMesh=new this.navmeshWasm.NavMesh,this._workerURL=URL.createObjectURL(new Blob([(e?S5t(gwt??"https://cdn.spline.design/@splinetool/runtime@2.0.
|
|
5136
|
+
`,T5t={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};x5t.then(t=>{ywt=t,Ri=new t.Vec3,ya=new t.Vec3});var M5t=new E,A5t=class{constructor(t=!1,e=!1){this.usePhysics=t,this.isExport=e,this.onPointerDown=i=>{if(Ue.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=M5t.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 Ec){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 Za)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=Z5(a),l=n.userData.hasDestroy,h=n.userData.hasDrag,u=!1,d=!1;for(let c of a.events)c.data.disabled!==!0&&(c.data.type==="GameControl"?u=!0:c.data.type==="Follow"&&(d=!0));if(u||o||d||l||h)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(oc(s.geometry,s.matrixWorld)),this.usePhysics&&a.physics?.fusedBody)return s.traverseObject((c,p)=>{if(p===0)return;let m;if(c instanceof Ec){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 Za)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(oc(c.geometry,c.matrixWorld))}),!0},this.traverseNoPhysics=(i,r)=>s=>{let n;if(s instanceof Ec)return;n=s instanceof Za?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,h=n.userData.hasDrag===!0;if(Z5(a)||l||h||n.dataPatched.events.some(u=>u.data.disabled!==!0&&u.data.type==="GameControl"))return!0;o&&i.push(oc(o,s.matrixWorld))},this.navmeshWasm=ywt,this.navMesh=new this.navmeshWasm.NavMesh,this._workerURL=URL.createObjectURL(new Blob([(e?S5t(gwt??"https://cdn.spline.design/@splinetool/runtime@2.0.206/build/"):`
|
|
5137
5137
|
(async function() {
|
|
5138
5138
|
const [wasmImport, wasmBinary] = await Promise.all([
|
|
5139
5139
|
import(self.location.origin + '/_libraries/navmesh.js'),
|
|
@@ -5208,7 +5208,7 @@ onmessage = function(messageEvent) {
|
|
|
5208
5208
|
[${h4}] { pointer-events: none; }
|
|
5209
5209
|
[${h4}] > * { pointer-events: auto; }
|
|
5210
5210
|
[${h4}] [data-spline-passthrough] { pointer-events: none; }
|
|
5211
|
-
`,Fwt=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(h4,"");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 h=document.createElement("style");h.textContent=YOt,n.appendChild(h);let u=new DOMParser().parseFromString(i,"text/html"),d=Array.from(u.querySelectorAll("script"));for(let v of d)v.remove();for(let v of Array.from(u.head.children))(v.tagName==="STYLE"||v.tagName==="LINK"&&v.rel==="stylesheet")&&n.appendChild(v);for(;u.body.firstChild;)n.appendChild(u.body.firstChild);s.insertBefore(n,e.nextSibling),n.addEventListener("wheel",v=>{v.ctrlKey&&!v.defaultPrevented&&!e.dispatchEvent(new WheelEvent("wheel",v))&&v.preventDefault()},{passive:!1});let c=new Map,p=new zG(zwt(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]),getAnimations:v=>m("getAnimations",[v]),playAnimation:(v,b,_)=>m("playAnimation",[v,b,_]),pauseAnimation:(v,b)=>m("pauseAnimation",[v,b]),stopAnimation:(v,b)=>m("stopAnimation",[v,b]),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),C=x.removeEventListener.bind(x);Object.defineProperty(x,"addEventListener",{configurable:!0,writable:!0,value:(M,A,P)=>{if(T(M,A,P),!S.includes(M)||A==null)return;let O={type:M,listener:A};w.add(O),queueMicrotask(()=>{!w.delete(O)||((D,N,z)=>{let k=new Event(z);try{typeof N=="function"?N.call(D,k):N.handleEvent?.(k)}catch(B){console.error(B)}})(x,O.listener,O.type)})}}),Object.defineProperty(x,"removeEventListener",{configurable:!0,writable:!0,value:(M,A,P)=>{C(M,A,P);for(let O of w)O.type===M&&O.listener===A&&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 Fwt(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 Uwt(t){return typeof t=="object"&&t!==null&&t.isMaterial===!0}function opt(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(!Uwt(t.material))return{options:t};let e=t.material;if(e.isNodeMaterial===!0){let i=zj()?.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}}De(),Li(),ot(),fyt(),Nc(),Li(),De(),lCt(),Em();var KOt=new Set(["name","parent","position","rotation","scale","visible","castShadow","receiveShadow","color","material"]),lpt="'Cube', 'Sphere', 'Plane', 'Rectangle', 'Ellipse', 'Triangle', 'Polygon', 'Star', 'Cone', 'Cylinder', 'Pyramid', 'Torus', 'TorusKnot', 'Dodecahedron', 'Icosahedron', 'Helix', 'Backdrop', 'Lathe', 'Text', 'CustomMesh', 'Group', 'PointLight', 'SpotLight', 'DirectionalLight'",ZOt={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"},QOt={group:"Empty",empty:"Empty",pointlight:"PointLight",spotlight:"SpotLight",directionallight:"DirectionalLight"},JOt={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')."},tIt={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"},eIt={Empty:"Group",PointLight:"Point Light",SpotLight:"Spot Light",DirectionalLight:"Directional Light"};function cT(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 jwt(t){return typeof t=="number"?[t,t,t]:cT(t,[1,1,1])}function bG(t){let e=new Dr(0,0,0,1);return e.setStyle(t),{r:e.r,g:e.g,b:e.b}}function hpt(t,e){let i=t.material??(t.color!==void 0?{color:t.color}:void 0);if(i===void 0)return Qr.defaultColorMaterial(upt(i0),"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)||se.NAMES[o]!==void 0}(i))return Qr.defaultColorMaterial(bG(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(Uwt(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?bG(i.color):upt(i0),s=Qr.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 upt(t){return{r:(t>>16&255)/255,g:(t>>8&255)/255,b:(255&t)/255}}function iIt(t){let e=hc.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 kP(t){return Array.isArray(t)?t:!ArrayBuffer.isView(t)||t instanceof DataView?null:Array.from(t)}function rIt(t,e){return Fgt({userData:{type:t,...Bj[t].normalizeInputs({parameters:e})}})}function sIt(t,e,i){let{objectType:r,geometryType:s}=t,n=function(l){let h={};for(let[u,d]of Object.entries(l))!KOt.has(u)&&d!==void 0&&(h[u]=d);return h}(e),a={states:new ue,events:new ue};if(r==="Mesh"&&s){if(s==="NonParametricGeometry"){let{geometry:l,doubleSide:h}=function(u){let d=kP(u.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=kP(u.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 fe;m.setAttribute("position",new me(d,3));let f=kP(u.normals),g=f!==null&&f.length===d.length;g&&m.setAttribute("normal",new me(f,3));let y=kP(u.uvs);y&&y.length===2*c&&m.setAttribute("uv",new me(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,C=new Map,M=new Array(T);for(let D=0;D<T;D++){let N=`${Math.round(1e4*S[3*D])},${Math.round(1e4*S[3*D+1])},${Math.round(1e4*S[3*D+2])}`,z=C.get(N);z===void 0?(C.set(N,D),M[D]=D):M[D]=z}let A=new Map;for(let D=0;D+2<w.length;D+=3){let N=M[w[D]],z=M[w[D+1]],k=M[w[D+2]];for(let[B,V]of[[N,z],[z,k],[k,N]]){if(B===V)continue;let q=B<V?B+"_"+V:V+"_"+B;A.set(q,(A.get(q)??0)+1)}}let P=A.size>0;for(let D of A.values())if(D!==2){P=!1;break}if(!P)return{closed:!1,inverted:!1};let O=0;for(let D=0;D+2<w.length;D+=3){let N=3*w[D],z=3*w[D+1],k=3*w[D+2],B=S[N],V=S[N+1],q=S[N+2],W=S[z],H=S[z+1],rt=S[z+2],it=S[k],ft=S[k+1],dt=S[k+2];O+=B*(H*dt-rt*ft)+V*(rt*it-W*dt)+q*(W*ft-H*it)}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:Fgt({userData:{type:"NonParametricGeometry",parameters:{subdivisions:0}},data:m.toJSON().data}),doubleSide:v}}(n);Object.assign(a,Iu.defaultData,{geometry:l,materials:[hpt(e,i)]}),h&&(a.side=2)}else Object.assign(a,Iu.defaultData,{geometry:s==="TextGeometry"?iIt(n):rIt(s,n),material:hpt(e,i)});e.castShadow!==void 0&&(a.castShadow=e.castShadow),e.receiveShadow!==void 0&&(a.receiveShadow=e.receiveShadow)}else r==="Empty"?Object.assign(a,H4.defaultData):(Object.assign(a,$4.defaultData(r),n),e.color!==void 0&&(a.color=bG(e.color)));a.visible=e.visible??!0,a.position=cT(e.position,[0,0,0]),a.rotation=cT(e.rotation,[0,0,0]),a.scale=jwt(e.scale);let o=(s&&tIt[s])??eIt[r]??r;return a.name=e.name??Gwt(o,i.scene.objects),a}function Gwt(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 Wwt(t,e){let i=zt.generateUUID();if(t.data.type==="Component")return{data:{...vc.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:U3t(r.animations,zt.generateUUID,e)}),{...t,id:i,data:r,children:t.children.map(s=>Wwt(s,e))}}function nIt(t){let e={};return function(i,r){return cv(i,r,null)??i}(Wwt(t,e),e)}function aIt(t){let e=Array.isArray(t)?t[0]:t,i=e.layers?.map(oIt)??[],r=e.layers?.find(s=>s.type==="light");return{layers:i,alpha:r?.node.alphaOverride?.value??1}}function oIt(t){return t.type==="texture"||t.type==="video"||t.type==="matcap"?{...t.data,updateTexture:e=>t.color.texture.image.updateSrc(e)}:{...t.data}}Em(),Jr(),yW(),Nc();var Gw=new Dr(0,0,0,1),lIt={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:[]};De(),De();var hIt=new Y;function dpt(t){let e=new Dr(0,0,0,1);try{e.setStyle(t)}catch(i){console.error(i)}return e}var qwt=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._startOrder=0,this._claimedOrder=0,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<jgt?this._skipRender=!1:this.currentTAAFrame=0):this.currentTAAFrame=0,this._scene?.traverseVisibleEntity(o=>{o.type==="ParticleSystem"&&(o.update(this.dt),this._skipRender=!1),n0(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=hIt.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=HS(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(()=>(QEt(),Yvt)).then(({Perfs:a})=>{this._perfs=new a({x:10,y:10})}),function(a){a.addEventListener("pointerdown",TX,!0),a.addEventListener("pointerdown",kM,!0),a.addEventListener("pointermove",kM,!0),a.addEventListener("pointerup",U0,!0),a.addEventListener("pointercancel",U0,!0),a.addEventListener("pointerleave",U0,!0),window.addEventListener("keydown",MX,!0),window.addEventListener("keyup",AX,!0)}(t)}async _ensureRenderer(){return this._renderer?this._renderer:(this._rendererInit||(this._rendererInit=this._initRenderer().then(t=>(this._rendererInit=void 0,t&&(this._renderer=t),t),t=>{throw this._rendererInit=void 0,t})),this._rendererInit)}async _initRenderer(){if(this.disposed)return null;let t=await this._createRenderer();return this.disposed?(this._disposeRenderer(t),null):t}_disposeRenderer(t){let e=function(r){let s=r.backend;if(s!==void 0)return s.isWebGLBackend===!0?s.gl??null:null;let n=r.getContext,a=typeof n=="function"?n.call(r):null;return a&&typeof a.getExtension=="function"?a:null}(t);if(e&&!function(r,s){return npt.get(r)===s}(this.canvas,this))return void(function(r){return r.backend?.isWebGLBackend===!0}(t)||t.dispose());let i=e?function(r,s){let n=s.getExtension("WEBGL_lose_context");if(!n||s.isContextLost())return()=>{};let a=()=>{},o=new Promise(l=>{a=apt(r,"webglcontextlost",h=>{h.preventDefault(),l(n)})});return IP.set(r,{gl:s,lost:o,stopListening:a}),()=>{s.isContextLost()||n.loseContext()}}(this.canvas,e):void 0;try{t.dispose()}finally{i?.()}}async _createRenderer(){if(function(t,e){npt.set(t,e)}(this.canvas,this),await async function(t){let e=IP.get(t);if(e&&(e.restoring??(e.restoring=async function(i,r){if(!r.gl.isContextLost())return void r.stopListening();let s,n=()=>{},a=r.lost.then(l=>new Promise(h=>{n=apt(i,"webglcontextrestored",()=>h()),l.restoreContext()})),o=new Promise(l=>{s=setTimeout(l,2e3)});await Promise.race([a,o]),clearTimeout(s),n(),r.stopListening()}(t,e).finally(()=>{e.restoring=void 0,!e.gl.isContextLost()&&IP.get(t)===e&&IP.delete(t)})),await e.restoring,e.gl.isContextLost()))throw new Error("[spline] The browser did not restore the WebGL context this canvas had before dispose(); the scene cannot render on it. Use a new canvas.")}(this.canvas),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(()=>(kF(),s4));e();let i=!0,r=!1;try{let n=new URLSearchParams(window.location.search),a=n.get("bundles");a==="rerecord"?i="rerecord":(a==="off"||a==="0"||a==="false"||a==="no")&&(i=!1),r=n.get("forcegl")==="1"}catch{}let s=await t({canvas:this.canvas,antialias:!1,alpha:!0,powerPreference:"high-performance",sceneBundles:!r&&i,forceWebGL:r,asyncCompilation:this._asyncShaderCompilation()});return s.onBackgroundWorkReady=()=>{this._skipRender=!1,this._renderRequested=!0},s.skyAnimationAllowed=!0,s}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.")}_asyncShaderCompilation(){let t=this._data?.scene.publish?.asyncShaderCompilation!==!1;try{let e=new URLSearchParams(window.location.search);if(e.get("forcegl")==="1")return!1;let i=e.get("asynccomp");i==="off"||i==="0"||i==="false"||i==="no"?t=!1:(i==="on"||i==="1"||i==="true"||i==="always")&&(t=!0)}catch{}return t}_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,e={}){if(this.disposed)return;let i,r=++this._startOrder,s=()=>this._claimedOrder>r;return i=this._start(t,e,s,()=>!s()&&(this._claimedOrder=r,this._claimedStart=i,!0)).then(()=>s()?this._claimedStart:void 0,n=>{if(!s())throw n;return this._claimedStart}),i}async _start(t,{interactive:e=!0,variables:i},r,s){Vs.init();let n=await async function(f){let[g,y]=s2($S.deserialize(new Uint8Array(f)));if((g.schema??0)!==136){let{updateDocumentSchema:v}=await Promise.resolve().then(()=>(cD(),Egt));v(g)}return y.result().data}(t);if(r())return;let a=function(f){let g=[];return f.scene.objects.traverse((y,v)=>{v.type==="Mesh"&&v.geometry.type==="NonParametricGeometry"&&v.geometry.data.draco!==void 0&&g.push(v)}),g}(n);n.version&&(0,$Ot.default)(n.version,"2.0.204")>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(f){M1t=f}(this._wasmPath));let o=async function(){}();if(await Promise.all([o,a.length&&rpt(this._wasmPath),BZ(n)&&gCt(this._wasmPath),zCt(n)&&VCt(this._wasmPath),hEt(n)&&qCt(this._wasmPath),s0.physicsEnabled(n.scene.objects)&&n5t(this._wasmPath),NK(n)&&zdt(),nQ(n)&&OEt(),ACt(n)&&MCt(),Rdt(n)&&o.then(()=>lj()?.loadHanaUIRUNTIME()),Q4t(n)&&w5t(this._wasmPath)].filter(Boolean)),r()||a.length&&(await spt(a),r())||!s())return;this._data=n,this._eventManager?.deactivate(),this._controls?.deactivate(),this._scene?.dispose();let l=n.scene.publish.renderer;if(this._rendererAuto&&l==="webgl")this._rendererBackend="webgl";else if(this._rendererAuto&&l==="webgpu"){let f=this._rendererBackend==="webgpu"&&await navigator.gpu?.requestAdapter().catch(()=>null);if(r())return;if(!f)return void this._failWebGPURequired();this._rendererAuto=!1}let h=function(f){let g=new Set;return f.scene.objects.traverse((y,v)=>{if(v.type!=="Page")return;let b=v.postprocessing;if(b&&typeof b=="object"&&b.enabled===!0)for(let[_,x]of Object.entries(b))_!=="enabled"&&x&&typeof x=="object"&&x.enabled===!0&&g.add(_)}),[...g]}(n);if(this._rendererBackend==="webgpu")try{await Promise.all([Promise.resolve().then(()=>(kF(),s4)),HOt(h)]);let f=await this._ensureRenderer();if(r()||!f)return}catch(f){console.error("[spline] Failed to load the WebGPU material backend, using WebGL:",f),this._rendererBackend="webgl"}if(this._rendererBackend!=="webgpu")return void this._failWebGPURequired();(function(f){TT=f})(this._rendererBackend==="webgpu"?"webgpu":"webgl");let u=new GOt(n,{},!0,{dedupeParametricGeometries:!0});if(u.resetPersonalCameraFromDocumentData(),this._scene=u.scene,this._sharedAssetsManager=u.sharedAssets,this._camera=this._scene.activeCamera,window.location.search.includes("merge-geometries")){let{mergeStaticGeometries:f}=await Promise.resolve().then(()=>(VRt(),Ext));if(r())return;let g=performance.now();f(n,u.scene);let y=performance.now();console.log("Merged geometries in ",y-g," ms")}BZ(n)&&this._scene.traverse(f=>{Wu(f)&&f.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this._requestRenderAutoMode(),this._scene?.traverse(f=>{nm(f)&&f.pendingMediaLoad&&f.update({scene:this._scene,shared:this._sharedAssetsManager})})}),this._scene?.traverse(f=>{f.type==="ParticleSystem"&&(f.wakeUp(),f.data.autoPlay?f.start():f.stop()),n0(f)&&f.setPlayMode(!0)});let d=Object.keys(n.shared.fonts).flatMap(f=>{let g=this._sharedAssetsManager.getFont(f);return g?[g.loadingPromise]:[]});if(Promise.all(d).then(()=>{this.disposed||(u.scene.markNeedsUpdateRendererDirty(),this._requestRenderAutoMode())}),NK(n)&&function(f){if(s0.physicsEnabled(f.scene.objects))return!0;let g=!1;return f.scene.objects.traverse((y,v)=>{if(v.events){if(Array.isArray(v.events)){for(let b of v.events)if(b.data.disabled!==!0&&b.data.type==="GameControl"&&b.data.collisionEnabled){g=!0;break}}else for(let b of Object.values(v.events))if(b.disabled!==!0&&b.type==="GameControl"&&b.collisionEnabled){g=!0;break}}}),g}(n)&&(await Promise.all(d),r()))return;if(Rdt(n)){let f=[];if(this._scene.traverseEntity(g=>{($a(g)||g instanceof Or)&&g.uiCanvas&&f.push(g.uiCanvas)}),await Promise.all(f.map(g=>g.promise)),r())return}this._scene.rewriteEventsBeforeGoToPlayMode(),Hq(this._scene.activePage,this._sharedAssetsManager);let c=await this._ensureRenderer();if(r()||!c)return;if(this._rendererConfigured||(this._rendererConfigured=!0,c.pipeline.enableUIOverlay(),c.pipeline.addEventListener("smaaloaded",this._requestRenderAutoMode)),c.hdTransmission=n.scene.publish.hdTransmission===!0,c.setPixelRatio(this._getPixelRatio(/Mobi|Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)?n.scene.publish.settings.web.pixelRatioMobile:n.scene.publish.settings.web.pixelRatioDesktop)),c.setAsyncCompilationPolicy?.(this._asyncShaderCompilation()),n.shared.images.SplineWatermark){let f=this._sharedAssetsManager.getImage("SplineWatermark");if(await f.loadPromise,r())return;let g=f.getTexture(1001);c.pipeline.setWatermark(g)}else c.pipeline.setWatermark(null);nQ(n)&&this._scene.initializeSplatViewer(),n.scene.blueNoiseTextureData!==void 0&&c.pipeline.updateBlueNoiseTexture(n.scene.blueNoiseTextureData);let p=Object.values(n.frames)[0];if(this._frameView?this._frameView.setCamera(this._camera):(p.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=p.size[0],this._viewportHeight=p.size[1],this.canvas.style.width=`${this._viewportWidth}px`,this.canvas.style.height=`${this._viewportHeight}px`),c.setSize(this._viewportWidth,this._viewportHeight,!1),this._frameView=new v4t(c,this._camera,new Y(this._viewportWidth,this._viewportHeight)),this._frameView.enableResponsive=(p.allowResponsive??!1)&&p.preset==="fullscreen"),e){let f=new ZRt(c,this.data.scene.publish,this._scene,()=>this._scene.activeCamera,this._sharedAssetsManager,this._requestRenderAutoMode,!0,p);this._scene.updateMatrixWorld(!0),this._controls=new u5t(f),this._animationControls=new NOt(this._scene,this._requestRenderAutoMode),this._eventManager=new c4t(n.scene.publish,this._controls,this._animationControls,f,n.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 m=n.scene.publish.htmlContent?.html;if(e&&m&&this._htmlContentMode!=="none"){let f={shared:this._sharedAssetsManager,findEntity:g=>this._scene?.getObjectByProperty("uuid",g)??this._scene?.getObjectByName(g),getAnimationControls:()=>this._animationControls};this._htmlContentOverlay=(this._htmlContentMode==="inline"?Fwt.mount(this,this.canvas,m,f):Lwt.mount(this,this.canvas,m,f))??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)){if(e==null)return void console.warn(`Variable ${t} was not updated: received ${e}. Pass a number, boolean or string.`);let r=e;if(typeof i.data.value=="number"){if(r=typeof e=="number"?e:typeof e=="boolean"?e===!0?1:0:parseFloat(e),!Number.isFinite(r))return void console.warn(`Variable ${t} is a number variable and ${JSON.stringify(e)} cannot be converted to a number. The variable was not updated.`)}else 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"&&Pa.isTextValue(t)?Pa.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===l0||this._scene.isInvisibleObjects(e)||e instanceof Or)){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 Wxt&&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=dpt(t);this._scene?.activePage.setBackgroundColor(e),this._requestRenderAutoMode()}dispose(){this.disposed=!0,this._claimedOrder=++this._startOrder,this._claimedStart=void 0,this._htmlContentOverlay?.dispose(),this._htmlContentOverlay=void 0,this._eventManager?.dispose(),this._scene?.dispose(),this._scene=void 0,this._camera=void 0,cS&&cS.disposeAll(),this._sharedAssetsManager?.setRequestRender(()=>{}),this._sharedAssetsManager?.dispose(),this._sharedAssetsManager=void 0,this._proxyObjectCache.forEach(t=>{VF.unsubscribe(t)}),this._proxyObjectCache.clear(),this._variablesCache.clear(),this._renderer?.pipeline.removeEventListener("smaaloaded",this._requestRenderAutoMode),this._renderer?.setAnimationLoop(null),this._renderer&&this._disposeRenderer(this._renderer),this._renderer=void 0,this._rendererConfigured=!1,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",TX,!0),t.removeEventListener("pointerdown",kM,!0),t.removeEventListener("pointermove",kM,!0),t.removeEventListener("pointerup",U0,!0),t.removeEventListener("pointercancel",U0,!0),t.removeEventListener("pointerleave",U0,!0),window.removeEventListener("keydown",MX,!0),window.removeEventListener("keyup",AX,!0)}(this.canvas),document.removeEventListener("scroll",this._onScroll),Vs.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(u=>{u instanceof Or&&(e=u.name)});let r=this._sharedAssetsManager,s={shared:r,scene:this._scene},n=u=>{if(u===null||u==="Base State")return null;if(u&&t.data.states){let d=t.data.states.find(c=>c.data.name===u);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?aIt(a):void 0),parentUuid:t.parent instanceof Or||t instanceof Vg?void 0:t.parent?.uuid,emitEvent(u){t.dispatchEvent({type:"userEvent",eventName:u})},emitEventReverse(u){t.dispatchEvent({type:"userEvent",eventName:u,reverse:!0})},hide(){t.visible&&(t.visible=!1,s.shared.requestRender())},show(){t.visible||(t.visible=!0,s.shared.requestRender())},get state(){let u=t.stateSelection;if(u!==null)return t.data.states.find(({id:d})=>d===u)?.data.name},set state(u){let d;if(u!==void 0){let c=typeof u=="string"?t.data.states.find(({id:p})=>p===u):t.data.states[u];if(c)d=c.id;else{let p=typeof u=="string"?n(u):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(u){let d=Vwt;if(d===null)return On("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 xwt({delay:0,delayDirection:"start-once",direction:"normal",repeat:0,runMode:"Repeat"},f.map(_=>_.runner))},v={update(_){p?.update(_),p?.isPlaying!==!0&&Vs.remove(v)}},b={transition({from:_,to:x,duration:S,delay:w,...T}){let C=n(_);C===void 0&&(C=c);let M=n(x);return c=M,f.push(new d(t,C,M,{state:M,repeat:0,delay:w??0,delayDirection:"start-once",direction:"normal",duration:S??1e3,...T,...T.easing===6?im.defaultData:T.easing===5?Fv.defaultData:{}},r,!1,i.activePage,{onBegin:()=>{(_&&C||_==="Base State"&&!C)&&(m.state=C??void 0)},onComplete:()=>{m.state=M??void 0}})),y(),this},play(){return p?(g=!0,p.play(Vs.time),p.isPlaying&&Vs.add(v),this):this},pause(){return p?.stop(),Vs.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(u),(u.autoPlay??!0)&&queueMicrotask(()=>{g||b.play()}),b},set color(u){let d=dpt(u);if(c5.is(t))return void(t.color=d);if(!(t.type==="Mesh"&&"material"in t&&t instanceof go))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(u),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:zt.generateUUID(),data:{...Is.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)}}},h=VF(l,(u,d)=>{let c=t[u],p=function(m){return m.split(".")}(u);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(C,M){return!!lIt[M]?.includes(C)}(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 C=parseInt(x[1]),M=w.getValue(T)?.[C];if(!M)throw new Error("Color index out of range");Gw.setStyle(S),M.set(Gw.r,Gw.g,Gw.b,Gw.a)}else w.getValue(T)?.setStyle(S);else if(T==="texture"||T==="video"){let C=w.color;(function(M,A,P,O){let D=M[0];if(D==="repeat"||D==="offset"||D==="rotation"){let N=O.getNode("mat"),z=N&&typeof N.updateMatrix=="function"?N:O.getValue("mat");if(!z)return;if(D==="rotation")z.rotation=parseFloat(A);else{let k=M[1];if(k===void 0)A instanceof Array&&A.length===2&&Object.assign(z,{[D]:A});else{let B=z[D],V=parseInt(k)===0?[parseFloat(A),B[1]]:[B[0],parseFloat(A)];Object.assign(z,{[D]:V})}}z.updateMatrix()}else D==="wrapping"||D==="minFilter"||D==="magFilter"?D==="wrapping"?P.texture.wrap=A:P.texture[D]=A:D==="image"&&M[1]==="data"&&P.texture.image.updateSrc(A)})(x.slice(1),S,C,w)}else{let C=x[1],M=w.getValue(T);M?.isVector3&&C!==void 0||M?.isVector2&&C!==void 0?M.setComponent(parseInt(C),S):w.setValue(T,S)}}catch(C){console.error("Error setting material value",C)}}(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,u)?.writable&&(t[u]=d),this._requestRenderAutoMode(),t.updateMatrix()});return this._proxyObjectCache.set(t.uuid,h),h}setUIWasmUrl(t){(function(e){t5=e,gD?.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=$S.deserialize(i),s="data"in r&&r.data.draco!==void 0;s&&await rpt(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 go))return void console.warn(`Object ${t} is not a mesh`);let a=n,o={...a.data,geometry:r};s&&await spt([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 h={...l.data};a.states||(a.states={}),a.states[l.id]=sm.patch(o,h)}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=zj();if(e===void 0&&(this._rendererBackend==="webgpu"&&(await Promise.resolve().then(()=>(kF(),s4)),e=zj()),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 go))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(h5()!=="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=opt({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 ${lpt}.`);let y=g.replace(/Geometry$/i,"").replace(/[\s_-]/g,"").toLowerCase(),v=QOt[y];if(v)return{objectType:v};let b=ZOt[y];if(b)return{objectType:"Mesh",geometryType:b};let _=JOt[y];throw _?new Error(`createObject: '${g}' is not supported \u2014 ${_}`):new Error(`createObject: '${g}' is not a creatable Spline type \u2014 use one of ${lpt}, 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}=opt(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(h5()!=="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(!hW.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 zdt(),a=e.font??E1,r.shared.fonts[a]===void 0){if(a!==E1){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:E1,url:Vft}}}let h=this._resolveParentId(e.parent),u=sIt(s,o,r),d=zt.generateUUID(),[c,p]=s2(r);n&&(c.shared.fonts[E1]=n),c.scene.objects.insertAfter(h,null,[{id:d,data:u,children:[]}]);let m=p.result();if(n&&this._sharedAssetsManager.addFont(E1,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 Or)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=cT(m.position,[0,0,0])),m.rotation!==void 0&&(g.rotation=cT(m.rotation,[0,0,0])),m.scale!==void 0&&(g.scale=jwt(m.scale)),m.visible!==void 0&&(g.visible=m.visible),g.name=m.name??Gwt(`${p.data.name??"Object"} Copy`,f),{...p,data:g}}(nIt(a),e,r.scene.objects),l=e.parent!==void 0?this._resolveParentId(e.parent):r.scene.objects.parent(n.uuid)??null,h=e.parent!==void 0?null:n.uuid,[u,d]=s2(r);u.scene.objects.insertAfter(l,h,[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 Or)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]=s2(i);a.scene.objects.delete(s.uuid),this._applyDocumentTransaction(o.result());for(let l of n){let h=this._proxyObjectCache.get(l);h&&(VF.unsubscribe(h),this._proxyObjectCache.delete(l))}return this._requestRenderAutoMode(),!0}};var YD=window,KD=YD.ShadowRoot&&(YD.ShadyCSS===void 0||YD.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,$q=Symbol(),Hwt=new WeakMap,NT=class{constructor(e,i,r){if(this._$cssResult$=!0,r!==$q)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(KD&&e===void 0){let r=i!==void 0&&i.length===1;r&&(e=Hwt.get(i)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),r&&Hwt.set(i,e))}return e}toString(){return this.cssText}},$wt=t=>new NT(typeof t=="string"?t:t+"",void 0,$q),Xq=(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 NT(i,t,$q)},Yq=(t,e)=>{KD?t.adoptedStyleSheets=e.map(i=>i instanceof CSSStyleSheet?i:i.styleSheet):e.forEach(i=>{let r=document.createElement("style"),s=YD.litNonce;s!==void 0&&r.setAttribute("nonce",s),r.textContent=i.cssText,t.appendChild(r)})},ZD=KD?t=>t:t=>t instanceof CSSStyleSheet?(e=>{let i="";for(let r of e.cssRules)i+=r.cssText;return $wt(i)})(t):t;var Kq,QD=window,Xwt=QD.trustedTypes,uIt=Xwt?Xwt.emptyScript:"",Ywt=QD.reactiveElementPolyfillSupport,Qq={toAttribute(t,e){switch(e){case Boolean:t=t?uIt: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}},Kwt=(t,e)=>e!==t&&(e==e||t==t),Zq={attribute:!0,type:String,converter:Qq,reflect:!1,hasChanged:Kwt},Jq="finalized",Bc=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=Zq){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)||Zq}static finalize(){if(this.hasOwnProperty(Jq))return!1;this[Jq]=!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(ZD(s))}else e!==void 0&&i.push(ZD(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 Yq(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=Zq){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:Qq).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:Qq;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||Kwt)(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){}};Bc[Jq]=!0,Bc.elementProperties=new Map,Bc.elementStyles=[],Bc.shadowRootOptions={mode:"open"},Ywt?.({ReactiveElement:Bc}),((Kq=QD.reactiveElementVersions)!==null&&Kq!==void 0?Kq:QD.reactiveElementVersions=[]).push("1.6.3");var tH,JD=window,yb=JD.trustedTypes,Zwt=yb?yb.createPolicy("lit-html",{createHTML:t=>t}):void 0,iH="$lit$",Rm=`lit$${(Math.random()+"").slice(9)}$`,s2t="?"+Rm,dIt=`<${s2t}>`,f0=document,kT=()=>f0.createComment(""),VT=t=>t===null||typeof t!="object"&&typeof t!="function",n2t=Array.isArray,cIt=t=>n2t(t)||typeof t?.[Symbol.iterator]=="function",eH=`[
|
|
5211
|
+
`,Fwt=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(h4,"");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 h=document.createElement("style");h.textContent=YOt,n.appendChild(h);let u=new DOMParser().parseFromString(i,"text/html"),d=Array.from(u.querySelectorAll("script"));for(let v of d)v.remove();for(let v of Array.from(u.head.children))(v.tagName==="STYLE"||v.tagName==="LINK"&&v.rel==="stylesheet")&&n.appendChild(v);for(;u.body.firstChild;)n.appendChild(u.body.firstChild);s.insertBefore(n,e.nextSibling),n.addEventListener("wheel",v=>{v.ctrlKey&&!v.defaultPrevented&&!e.dispatchEvent(new WheelEvent("wheel",v))&&v.preventDefault()},{passive:!1});let c=new Map,p=new zG(zwt(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]),getAnimations:v=>m("getAnimations",[v]),playAnimation:(v,b,_)=>m("playAnimation",[v,b,_]),pauseAnimation:(v,b)=>m("pauseAnimation",[v,b]),stopAnimation:(v,b)=>m("stopAnimation",[v,b]),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),C=x.removeEventListener.bind(x);Object.defineProperty(x,"addEventListener",{configurable:!0,writable:!0,value:(M,A,P)=>{if(T(M,A,P),!S.includes(M)||A==null)return;let O={type:M,listener:A};w.add(O),queueMicrotask(()=>{!w.delete(O)||((D,N,z)=>{let k=new Event(z);try{typeof N=="function"?N.call(D,k):N.handleEvent?.(k)}catch(B){console.error(B)}})(x,O.listener,O.type)})}}),Object.defineProperty(x,"removeEventListener",{configurable:!0,writable:!0,value:(M,A,P)=>{C(M,A,P);for(let O of w)O.type===M&&O.listener===A&&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 Fwt(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 Uwt(t){return typeof t=="object"&&t!==null&&t.isMaterial===!0}function opt(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(!Uwt(t.material))return{options:t};let e=t.material;if(e.isNodeMaterial===!0){let i=zj()?.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}}De(),Li(),ot(),fyt(),Nc(),Li(),De(),lCt(),Em();var KOt=new Set(["name","parent","position","rotation","scale","visible","castShadow","receiveShadow","color","material"]),lpt="'Cube', 'Sphere', 'Plane', 'Rectangle', 'Ellipse', 'Triangle', 'Polygon', 'Star', 'Cone', 'Cylinder', 'Pyramid', 'Torus', 'TorusKnot', 'Dodecahedron', 'Icosahedron', 'Helix', 'Backdrop', 'Lathe', 'Text', 'CustomMesh', 'Group', 'PointLight', 'SpotLight', 'DirectionalLight'",ZOt={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"},QOt={group:"Empty",empty:"Empty",pointlight:"PointLight",spotlight:"SpotLight",directionallight:"DirectionalLight"},JOt={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')."},tIt={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"},eIt={Empty:"Group",PointLight:"Point Light",SpotLight:"Spot Light",DirectionalLight:"Directional Light"};function cT(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 jwt(t){return typeof t=="number"?[t,t,t]:cT(t,[1,1,1])}function bG(t){let e=new Dr(0,0,0,1);return e.setStyle(t),{r:e.r,g:e.g,b:e.b}}function hpt(t,e){let i=t.material??(t.color!==void 0?{color:t.color}:void 0);if(i===void 0)return Qr.defaultColorMaterial(upt(i0),"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)||se.NAMES[o]!==void 0}(i))return Qr.defaultColorMaterial(bG(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(Uwt(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?bG(i.color):upt(i0),s=Qr.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 upt(t){return{r:(t>>16&255)/255,g:(t>>8&255)/255,b:(255&t)/255}}function iIt(t){let e=hc.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 kP(t){return Array.isArray(t)?t:!ArrayBuffer.isView(t)||t instanceof DataView?null:Array.from(t)}function rIt(t,e){return Fgt({userData:{type:t,...Bj[t].normalizeInputs({parameters:e})}})}function sIt(t,e,i){let{objectType:r,geometryType:s}=t,n=function(l){let h={};for(let[u,d]of Object.entries(l))!KOt.has(u)&&d!==void 0&&(h[u]=d);return h}(e),a={states:new ue,events:new ue};if(r==="Mesh"&&s){if(s==="NonParametricGeometry"){let{geometry:l,doubleSide:h}=function(u){let d=kP(u.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=kP(u.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 fe;m.setAttribute("position",new me(d,3));let f=kP(u.normals),g=f!==null&&f.length===d.length;g&&m.setAttribute("normal",new me(f,3));let y=kP(u.uvs);y&&y.length===2*c&&m.setAttribute("uv",new me(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,C=new Map,M=new Array(T);for(let D=0;D<T;D++){let N=`${Math.round(1e4*S[3*D])},${Math.round(1e4*S[3*D+1])},${Math.round(1e4*S[3*D+2])}`,z=C.get(N);z===void 0?(C.set(N,D),M[D]=D):M[D]=z}let A=new Map;for(let D=0;D+2<w.length;D+=3){let N=M[w[D]],z=M[w[D+1]],k=M[w[D+2]];for(let[B,V]of[[N,z],[z,k],[k,N]]){if(B===V)continue;let q=B<V?B+"_"+V:V+"_"+B;A.set(q,(A.get(q)??0)+1)}}let P=A.size>0;for(let D of A.values())if(D!==2){P=!1;break}if(!P)return{closed:!1,inverted:!1};let O=0;for(let D=0;D+2<w.length;D+=3){let N=3*w[D],z=3*w[D+1],k=3*w[D+2],B=S[N],V=S[N+1],q=S[N+2],W=S[z],H=S[z+1],rt=S[z+2],it=S[k],ft=S[k+1],dt=S[k+2];O+=B*(H*dt-rt*ft)+V*(rt*it-W*dt)+q*(W*ft-H*it)}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:Fgt({userData:{type:"NonParametricGeometry",parameters:{subdivisions:0}},data:m.toJSON().data}),doubleSide:v}}(n);Object.assign(a,Iu.defaultData,{geometry:l,materials:[hpt(e,i)]}),h&&(a.side=2)}else Object.assign(a,Iu.defaultData,{geometry:s==="TextGeometry"?iIt(n):rIt(s,n),material:hpt(e,i)});e.castShadow!==void 0&&(a.castShadow=e.castShadow),e.receiveShadow!==void 0&&(a.receiveShadow=e.receiveShadow)}else r==="Empty"?Object.assign(a,H4.defaultData):(Object.assign(a,$4.defaultData(r),n),e.color!==void 0&&(a.color=bG(e.color)));a.visible=e.visible??!0,a.position=cT(e.position,[0,0,0]),a.rotation=cT(e.rotation,[0,0,0]),a.scale=jwt(e.scale);let o=(s&&tIt[s])??eIt[r]??r;return a.name=e.name??Gwt(o,i.scene.objects),a}function Gwt(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 Wwt(t,e){let i=zt.generateUUID();if(t.data.type==="Component")return{data:{...vc.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:U3t(r.animations,zt.generateUUID,e)}),{...t,id:i,data:r,children:t.children.map(s=>Wwt(s,e))}}function nIt(t){let e={};return function(i,r){return cv(i,r,null)??i}(Wwt(t,e),e)}function aIt(t){let e=Array.isArray(t)?t[0]:t,i=e.layers?.map(oIt)??[],r=e.layers?.find(s=>s.type==="light");return{layers:i,alpha:r?.node.alphaOverride?.value??1}}function oIt(t){return t.type==="texture"||t.type==="video"||t.type==="matcap"?{...t.data,updateTexture:e=>t.color.texture.image.updateSrc(e)}:{...t.data}}Em(),Jr(),yW(),Nc();var Gw=new Dr(0,0,0,1),lIt={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:[]};De(),De();var hIt=new Y;function dpt(t){let e=new Dr(0,0,0,1);try{e.setStyle(t)}catch(i){console.error(i)}return e}var qwt=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._startOrder=0,this._claimedOrder=0,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<jgt?this._skipRender=!1:this.currentTAAFrame=0):this.currentTAAFrame=0,this._scene?.traverseVisibleEntity(o=>{o.type==="ParticleSystem"&&(o.update(this.dt),this._skipRender=!1),n0(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=hIt.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=HS(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(()=>(QEt(),Yvt)).then(({Perfs:a})=>{this._perfs=new a({x:10,y:10})}),function(a){a.addEventListener("pointerdown",TX,!0),a.addEventListener("pointerdown",kM,!0),a.addEventListener("pointermove",kM,!0),a.addEventListener("pointerup",U0,!0),a.addEventListener("pointercancel",U0,!0),a.addEventListener("pointerleave",U0,!0),window.addEventListener("keydown",MX,!0),window.addEventListener("keyup",AX,!0)}(t)}async _ensureRenderer(){return this._renderer?this._renderer:(this._rendererInit||(this._rendererInit=this._initRenderer().then(t=>(this._rendererInit=void 0,t&&(this._renderer=t),t),t=>{throw this._rendererInit=void 0,t})),this._rendererInit)}async _initRenderer(){if(this.disposed)return null;let t=await this._createRenderer();return this.disposed?(this._disposeRenderer(t),null):t}_disposeRenderer(t){let e=function(r){let s=r.backend;if(s!==void 0)return s.isWebGLBackend===!0?s.gl??null:null;let n=r.getContext,a=typeof n=="function"?n.call(r):null;return a&&typeof a.getExtension=="function"?a:null}(t);if(e&&!function(r,s){return npt.get(r)===s}(this.canvas,this))return void(function(r){return r.backend?.isWebGLBackend===!0}(t)||t.dispose());let i=e?function(r,s){let n=s.getExtension("WEBGL_lose_context");if(!n||s.isContextLost())return()=>{};let a=()=>{},o=new Promise(l=>{a=apt(r,"webglcontextlost",h=>{h.preventDefault(),l(n)})});return IP.set(r,{gl:s,lost:o,stopListening:a}),()=>{s.isContextLost()||n.loseContext()}}(this.canvas,e):void 0;try{t.dispose()}finally{i?.()}}async _createRenderer(){if(function(t,e){npt.set(t,e)}(this.canvas,this),await async function(t){let e=IP.get(t);if(e&&(e.restoring??(e.restoring=async function(i,r){if(!r.gl.isContextLost())return void r.stopListening();let s,n=()=>{},a=r.lost.then(l=>new Promise(h=>{n=apt(i,"webglcontextrestored",()=>h()),l.restoreContext()})),o=new Promise(l=>{s=setTimeout(l,2e3)});await Promise.race([a,o]),clearTimeout(s),n(),r.stopListening()}(t,e).finally(()=>{e.restoring=void 0,!e.gl.isContextLost()&&IP.get(t)===e&&IP.delete(t)})),await e.restoring,e.gl.isContextLost()))throw new Error("[spline] The browser did not restore the WebGL context this canvas had before dispose(); the scene cannot render on it. Use a new canvas.")}(this.canvas),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(()=>(kF(),s4));e();let i=!0,r=!1;try{let n=new URLSearchParams(window.location.search),a=n.get("bundles");a==="rerecord"?i="rerecord":(a==="off"||a==="0"||a==="false"||a==="no")&&(i=!1),r=n.get("forcegl")==="1"}catch{}let s=await t({canvas:this.canvas,antialias:!1,alpha:!0,powerPreference:"high-performance",sceneBundles:!r&&i,forceWebGL:r,asyncCompilation:this._asyncShaderCompilation()});return s.onBackgroundWorkReady=()=>{this._skipRender=!1,this._renderRequested=!0},s.skyAnimationAllowed=!0,s}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.")}_asyncShaderCompilation(){let t=this._data?.scene.publish?.asyncShaderCompilation!==!1;try{let e=new URLSearchParams(window.location.search);if(e.get("forcegl")==="1")return!1;let i=e.get("asynccomp");i==="off"||i==="0"||i==="false"||i==="no"?t=!1:(i==="on"||i==="1"||i==="true"||i==="always")&&(t=!0)}catch{}return t}_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,e={}){if(this.disposed)return;let i,r=++this._startOrder,s=()=>this._claimedOrder>r;return i=this._start(t,e,s,()=>!s()&&(this._claimedOrder=r,this._claimedStart=i,!0)).then(()=>s()?this._claimedStart:void 0,n=>{if(!s())throw n;return this._claimedStart}),i}async _start(t,{interactive:e=!0,variables:i},r,s){Vs.init();let n=await async function(f){let[g,y]=s2($S.deserialize(new Uint8Array(f)));if((g.schema??0)!==136){let{updateDocumentSchema:v}=await Promise.resolve().then(()=>(cD(),Egt));v(g)}return y.result().data}(t);if(r())return;let a=function(f){let g=[];return f.scene.objects.traverse((y,v)=>{v.type==="Mesh"&&v.geometry.type==="NonParametricGeometry"&&v.geometry.data.draco!==void 0&&g.push(v)}),g}(n);n.version&&(0,$Ot.default)(n.version,"2.0.206")>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(f){M1t=f}(this._wasmPath));let o=async function(){}();if(await Promise.all([o,a.length&&rpt(this._wasmPath),BZ(n)&&gCt(this._wasmPath),zCt(n)&&VCt(this._wasmPath),hEt(n)&&qCt(this._wasmPath),s0.physicsEnabled(n.scene.objects)&&n5t(this._wasmPath),NK(n)&&zdt(),nQ(n)&&OEt(),ACt(n)&&MCt(),Rdt(n)&&o.then(()=>lj()?.loadHanaUIRUNTIME()),Q4t(n)&&w5t(this._wasmPath)].filter(Boolean)),r()||a.length&&(await spt(a),r())||!s())return;this._data=n,this._eventManager?.deactivate(),this._controls?.deactivate(),this._scene?.dispose();let l=n.scene.publish.renderer;if(this._rendererAuto&&l==="webgl")this._rendererBackend="webgl";else if(this._rendererAuto&&l==="webgpu"){let f=this._rendererBackend==="webgpu"&&await navigator.gpu?.requestAdapter().catch(()=>null);if(r())return;if(!f)return void this._failWebGPURequired();this._rendererAuto=!1}let h=function(f){let g=new Set;return f.scene.objects.traverse((y,v)=>{if(v.type!=="Page")return;let b=v.postprocessing;if(b&&typeof b=="object"&&b.enabled===!0)for(let[_,x]of Object.entries(b))_!=="enabled"&&x&&typeof x=="object"&&x.enabled===!0&&g.add(_)}),[...g]}(n);if(this._rendererBackend==="webgpu")try{await Promise.all([Promise.resolve().then(()=>(kF(),s4)),HOt(h)]);let f=await this._ensureRenderer();if(r()||!f)return}catch(f){console.error("[spline] Failed to load the WebGPU material backend, using WebGL:",f),this._rendererBackend="webgl"}if(this._rendererBackend!=="webgpu")return void this._failWebGPURequired();(function(f){TT=f})(this._rendererBackend==="webgpu"?"webgpu":"webgl");let u=new GOt(n,{},!0,{dedupeParametricGeometries:!0});if(u.resetPersonalCameraFromDocumentData(),this._scene=u.scene,this._sharedAssetsManager=u.sharedAssets,this._camera=this._scene.activeCamera,window.location.search.includes("merge-geometries")){let{mergeStaticGeometries:f}=await Promise.resolve().then(()=>(VRt(),Ext));if(r())return;let g=performance.now();f(n,u.scene);let y=performance.now();console.log("Merged geometries in ",y-g," ms")}BZ(n)&&this._scene.traverse(f=>{Wu(f)&&f.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this._requestRenderAutoMode(),this._scene?.traverse(f=>{nm(f)&&f.pendingMediaLoad&&f.update({scene:this._scene,shared:this._sharedAssetsManager})})}),this._scene?.traverse(f=>{f.type==="ParticleSystem"&&(f.wakeUp(),f.data.autoPlay?f.start():f.stop()),n0(f)&&f.setPlayMode(!0)});let d=Object.keys(n.shared.fonts).flatMap(f=>{let g=this._sharedAssetsManager.getFont(f);return g?[g.loadingPromise]:[]});if(Promise.all(d).then(()=>{this.disposed||(u.scene.markNeedsUpdateRendererDirty(),this._requestRenderAutoMode())}),NK(n)&&function(f){if(s0.physicsEnabled(f.scene.objects))return!0;let g=!1;return f.scene.objects.traverse((y,v)=>{if(v.events){if(Array.isArray(v.events)){for(let b of v.events)if(b.data.disabled!==!0&&b.data.type==="GameControl"&&b.data.collisionEnabled){g=!0;break}}else for(let b of Object.values(v.events))if(b.disabled!==!0&&b.type==="GameControl"&&b.collisionEnabled){g=!0;break}}}),g}(n)&&(await Promise.all(d),r()))return;if(Rdt(n)){let f=[];if(this._scene.traverseEntity(g=>{($a(g)||g instanceof Or)&&g.uiCanvas&&f.push(g.uiCanvas)}),await Promise.all(f.map(g=>g.promise)),r())return}this._scene.rewriteEventsBeforeGoToPlayMode(),Hq(this._scene.activePage,this._sharedAssetsManager);let c=await this._ensureRenderer();if(r()||!c)return;if(this._rendererConfigured||(this._rendererConfigured=!0,c.pipeline.enableUIOverlay(),c.pipeline.addEventListener("smaaloaded",this._requestRenderAutoMode)),c.hdTransmission=n.scene.publish.hdTransmission===!0,c.setPixelRatio(this._getPixelRatio(/Mobi|Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)?n.scene.publish.settings.web.pixelRatioMobile:n.scene.publish.settings.web.pixelRatioDesktop)),c.setAsyncCompilationPolicy?.(this._asyncShaderCompilation()),n.shared.images.SplineWatermark){let f=this._sharedAssetsManager.getImage("SplineWatermark");if(await f.loadPromise,r())return;let g=f.getTexture(1001);c.pipeline.setWatermark(g)}else c.pipeline.setWatermark(null);nQ(n)&&this._scene.initializeSplatViewer(),n.scene.blueNoiseTextureData!==void 0&&c.pipeline.updateBlueNoiseTexture(n.scene.blueNoiseTextureData);let p=Object.values(n.frames)[0];if(this._frameView?this._frameView.setCamera(this._camera):(p.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=p.size[0],this._viewportHeight=p.size[1],this.canvas.style.width=`${this._viewportWidth}px`,this.canvas.style.height=`${this._viewportHeight}px`),c.setSize(this._viewportWidth,this._viewportHeight,!1),this._frameView=new v4t(c,this._camera,new Y(this._viewportWidth,this._viewportHeight)),this._frameView.enableResponsive=(p.allowResponsive??!1)&&p.preset==="fullscreen"),e){let f=new ZRt(c,this.data.scene.publish,this._scene,()=>this._scene.activeCamera,this._sharedAssetsManager,this._requestRenderAutoMode,!0,p);this._scene.updateMatrixWorld(!0),this._controls=new u5t(f),this._animationControls=new NOt(this._scene,this._requestRenderAutoMode),this._eventManager=new c4t(n.scene.publish,this._controls,this._animationControls,f,n.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 m=n.scene.publish.htmlContent?.html;if(e&&m&&this._htmlContentMode!=="none"){let f={shared:this._sharedAssetsManager,findEntity:g=>this._scene?.getObjectByProperty("uuid",g)??this._scene?.getObjectByName(g),getAnimationControls:()=>this._animationControls};this._htmlContentOverlay=(this._htmlContentMode==="inline"?Fwt.mount(this,this.canvas,m,f):Lwt.mount(this,this.canvas,m,f))??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)){if(e==null)return void console.warn(`Variable ${t} was not updated: received ${e}. Pass a number, boolean or string.`);let r=e;if(typeof i.data.value=="number"){if(r=typeof e=="number"?e:typeof e=="boolean"?e===!0?1:0:parseFloat(e),!Number.isFinite(r))return void console.warn(`Variable ${t} is a number variable and ${JSON.stringify(e)} cannot be converted to a number. The variable was not updated.`)}else 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"&&Pa.isTextValue(t)?Pa.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===l0||this._scene.isInvisibleObjects(e)||e instanceof Or)){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 Wxt&&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=dpt(t);this._scene?.activePage.setBackgroundColor(e),this._requestRenderAutoMode()}dispose(){this.disposed=!0,this._claimedOrder=++this._startOrder,this._claimedStart=void 0,this._htmlContentOverlay?.dispose(),this._htmlContentOverlay=void 0,this._eventManager?.dispose(),this._scene?.dispose(),this._scene=void 0,this._camera=void 0,cS&&cS.disposeAll(),this._sharedAssetsManager?.setRequestRender(()=>{}),this._sharedAssetsManager?.dispose(),this._sharedAssetsManager=void 0,this._proxyObjectCache.forEach(t=>{VF.unsubscribe(t)}),this._proxyObjectCache.clear(),this._variablesCache.clear(),this._renderer?.pipeline.removeEventListener("smaaloaded",this._requestRenderAutoMode),this._renderer?.setAnimationLoop(null),this._renderer&&this._disposeRenderer(this._renderer),this._renderer=void 0,this._rendererConfigured=!1,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",TX,!0),t.removeEventListener("pointerdown",kM,!0),t.removeEventListener("pointermove",kM,!0),t.removeEventListener("pointerup",U0,!0),t.removeEventListener("pointercancel",U0,!0),t.removeEventListener("pointerleave",U0,!0),window.removeEventListener("keydown",MX,!0),window.removeEventListener("keyup",AX,!0)}(this.canvas),document.removeEventListener("scroll",this._onScroll),Vs.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(u=>{u instanceof Or&&(e=u.name)});let r=this._sharedAssetsManager,s={shared:r,scene:this._scene},n=u=>{if(u===null||u==="Base State")return null;if(u&&t.data.states){let d=t.data.states.find(c=>c.data.name===u);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?aIt(a):void 0),parentUuid:t.parent instanceof Or||t instanceof Vg?void 0:t.parent?.uuid,emitEvent(u){t.dispatchEvent({type:"userEvent",eventName:u})},emitEventReverse(u){t.dispatchEvent({type:"userEvent",eventName:u,reverse:!0})},hide(){t.visible&&(t.visible=!1,s.shared.requestRender())},show(){t.visible||(t.visible=!0,s.shared.requestRender())},get state(){let u=t.stateSelection;if(u!==null)return t.data.states.find(({id:d})=>d===u)?.data.name},set state(u){let d;if(u!==void 0){let c=typeof u=="string"?t.data.states.find(({id:p})=>p===u):t.data.states[u];if(c)d=c.id;else{let p=typeof u=="string"?n(u):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(u){let d=Vwt;if(d===null)return On("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 xwt({delay:0,delayDirection:"start-once",direction:"normal",repeat:0,runMode:"Repeat"},f.map(_=>_.runner))},v={update(_){p?.update(_),p?.isPlaying!==!0&&Vs.remove(v)}},b={transition({from:_,to:x,duration:S,delay:w,...T}){let C=n(_);C===void 0&&(C=c);let M=n(x);return c=M,f.push(new d(t,C,M,{state:M,repeat:0,delay:w??0,delayDirection:"start-once",direction:"normal",duration:S??1e3,...T,...T.easing===6?im.defaultData:T.easing===5?Fv.defaultData:{}},r,!1,i.activePage,{onBegin:()=>{(_&&C||_==="Base State"&&!C)&&(m.state=C??void 0)},onComplete:()=>{m.state=M??void 0}})),y(),this},play(){return p?(g=!0,p.play(Vs.time),p.isPlaying&&Vs.add(v),this):this},pause(){return p?.stop(),Vs.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(u),(u.autoPlay??!0)&&queueMicrotask(()=>{g||b.play()}),b},set color(u){let d=dpt(u);if(c5.is(t))return void(t.color=d);if(!(t.type==="Mesh"&&"material"in t&&t instanceof go))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(u),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:zt.generateUUID(),data:{...Is.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)}}},h=VF(l,(u,d)=>{let c=t[u],p=function(m){return m.split(".")}(u);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(C,M){return!!lIt[M]?.includes(C)}(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 C=parseInt(x[1]),M=w.getValue(T)?.[C];if(!M)throw new Error("Color index out of range");Gw.setStyle(S),M.set(Gw.r,Gw.g,Gw.b,Gw.a)}else w.getValue(T)?.setStyle(S);else if(T==="texture"||T==="video"){let C=w.color;(function(M,A,P,O){let D=M[0];if(D==="repeat"||D==="offset"||D==="rotation"){let N=O.getNode("mat"),z=N&&typeof N.updateMatrix=="function"?N:O.getValue("mat");if(!z)return;if(D==="rotation")z.rotation=parseFloat(A);else{let k=M[1];if(k===void 0)A instanceof Array&&A.length===2&&Object.assign(z,{[D]:A});else{let B=z[D],V=parseInt(k)===0?[parseFloat(A),B[1]]:[B[0],parseFloat(A)];Object.assign(z,{[D]:V})}}z.updateMatrix()}else D==="wrapping"||D==="minFilter"||D==="magFilter"?D==="wrapping"?P.texture.wrap=A:P.texture[D]=A:D==="image"&&M[1]==="data"&&P.texture.image.updateSrc(A)})(x.slice(1),S,C,w)}else{let C=x[1],M=w.getValue(T);M?.isVector3&&C!==void 0||M?.isVector2&&C!==void 0?M.setComponent(parseInt(C),S):w.setValue(T,S)}}catch(C){console.error("Error setting material value",C)}}(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,u)?.writable&&(t[u]=d),this._requestRenderAutoMode(),t.updateMatrix()});return this._proxyObjectCache.set(t.uuid,h),h}setUIWasmUrl(t){(function(e){t5=e,gD?.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=$S.deserialize(i),s="data"in r&&r.data.draco!==void 0;s&&await rpt(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 go))return void console.warn(`Object ${t} is not a mesh`);let a=n,o={...a.data,geometry:r};s&&await spt([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 h={...l.data};a.states||(a.states={}),a.states[l.id]=sm.patch(o,h)}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=zj();if(e===void 0&&(this._rendererBackend==="webgpu"&&(await Promise.resolve().then(()=>(kF(),s4)),e=zj()),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 go))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(h5()!=="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=opt({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 ${lpt}.`);let y=g.replace(/Geometry$/i,"").replace(/[\s_-]/g,"").toLowerCase(),v=QOt[y];if(v)return{objectType:v};let b=ZOt[y];if(b)return{objectType:"Mesh",geometryType:b};let _=JOt[y];throw _?new Error(`createObject: '${g}' is not supported \u2014 ${_}`):new Error(`createObject: '${g}' is not a creatable Spline type \u2014 use one of ${lpt}, 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}=opt(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(h5()!=="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(!hW.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 zdt(),a=e.font??E1,r.shared.fonts[a]===void 0){if(a!==E1){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:E1,url:Vft}}}let h=this._resolveParentId(e.parent),u=sIt(s,o,r),d=zt.generateUUID(),[c,p]=s2(r);n&&(c.shared.fonts[E1]=n),c.scene.objects.insertAfter(h,null,[{id:d,data:u,children:[]}]);let m=p.result();if(n&&this._sharedAssetsManager.addFont(E1,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 Or)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=cT(m.position,[0,0,0])),m.rotation!==void 0&&(g.rotation=cT(m.rotation,[0,0,0])),m.scale!==void 0&&(g.scale=jwt(m.scale)),m.visible!==void 0&&(g.visible=m.visible),g.name=m.name??Gwt(`${p.data.name??"Object"} Copy`,f),{...p,data:g}}(nIt(a),e,r.scene.objects),l=e.parent!==void 0?this._resolveParentId(e.parent):r.scene.objects.parent(n.uuid)??null,h=e.parent!==void 0?null:n.uuid,[u,d]=s2(r);u.scene.objects.insertAfter(l,h,[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 Or)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]=s2(i);a.scene.objects.delete(s.uuid),this._applyDocumentTransaction(o.result());for(let l of n){let h=this._proxyObjectCache.get(l);h&&(VF.unsubscribe(h),this._proxyObjectCache.delete(l))}return this._requestRenderAutoMode(),!0}};var YD=window,KD=YD.ShadowRoot&&(YD.ShadyCSS===void 0||YD.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,$q=Symbol(),Hwt=new WeakMap,NT=class{constructor(e,i,r){if(this._$cssResult$=!0,r!==$q)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(KD&&e===void 0){let r=i!==void 0&&i.length===1;r&&(e=Hwt.get(i)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),r&&Hwt.set(i,e))}return e}toString(){return this.cssText}},$wt=t=>new NT(typeof t=="string"?t:t+"",void 0,$q),Xq=(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 NT(i,t,$q)},Yq=(t,e)=>{KD?t.adoptedStyleSheets=e.map(i=>i instanceof CSSStyleSheet?i:i.styleSheet):e.forEach(i=>{let r=document.createElement("style"),s=YD.litNonce;s!==void 0&&r.setAttribute("nonce",s),r.textContent=i.cssText,t.appendChild(r)})},ZD=KD?t=>t:t=>t instanceof CSSStyleSheet?(e=>{let i="";for(let r of e.cssRules)i+=r.cssText;return $wt(i)})(t):t;var Kq,QD=window,Xwt=QD.trustedTypes,uIt=Xwt?Xwt.emptyScript:"",Ywt=QD.reactiveElementPolyfillSupport,Qq={toAttribute(t,e){switch(e){case Boolean:t=t?uIt: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}},Kwt=(t,e)=>e!==t&&(e==e||t==t),Zq={attribute:!0,type:String,converter:Qq,reflect:!1,hasChanged:Kwt},Jq="finalized",Bc=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=Zq){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)||Zq}static finalize(){if(this.hasOwnProperty(Jq))return!1;this[Jq]=!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(ZD(s))}else e!==void 0&&i.push(ZD(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 Yq(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=Zq){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:Qq).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:Qq;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||Kwt)(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){}};Bc[Jq]=!0,Bc.elementProperties=new Map,Bc.elementStyles=[],Bc.shadowRootOptions={mode:"open"},Ywt?.({ReactiveElement:Bc}),((Kq=QD.reactiveElementVersions)!==null&&Kq!==void 0?Kq:QD.reactiveElementVersions=[]).push("1.6.3");var tH,JD=window,yb=JD.trustedTypes,Zwt=yb?yb.createPolicy("lit-html",{createHTML:t=>t}):void 0,iH="$lit$",Rm=`lit$${(Math.random()+"").slice(9)}$`,s2t="?"+Rm,dIt=`<${s2t}>`,f0=document,kT=()=>f0.createComment(""),VT=t=>t===null||typeof t!="object"&&typeof t!="function",n2t=Array.isArray,cIt=t=>n2t(t)||typeof t?.[Symbol.iterator]=="function",eH=`[
|
|
5212
5212
|
\f\r]`,BT=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Qwt=/-->/g,Jwt=/>/g,p0=RegExp(`>|${eH}(?:([^\\s"'>=/]+)(${eH}*=${eH}*(?:[^
|
|
5213
5213
|
\f\r"'\`<>=]|("|')|))|$)`,"g"),t2t=/'/g,e2t=/"/g,a2t=/^(?:script|style|textarea|title)$/i,o2t=t=>(e,...i)=>({_$litType$:t,strings:e,values:i}),l2t=o2t(1),MGt=o2t(2),g0=Symbol.for("lit-noChange"),aa=Symbol.for("lit-nothing"),i2t=new WeakMap,m0=f0.createTreeWalker(f0,129,null,!1);function h2t(t,e){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return Zwt!==void 0?Zwt.createHTML(e):e}var pIt=(t,e)=>{let i=t.length-1,r=[],s,n=e===2?"<svg>":"",a=BT;for(let o=0;o<i;o++){let l=t[o],h,u,d=-1,c=0;for(;c<l.length&&(a.lastIndex=c,u=a.exec(l),u!==null);)c=a.lastIndex,a===BT?u[1]==="!--"?a=Qwt:u[1]!==void 0?a=Jwt:u[2]!==void 0?(a2t.test(u[2])&&(s=RegExp("</"+u[2],"g")),a=p0):u[3]!==void 0&&(a=p0):a===p0?u[0]===">"?(a=s??BT,d=-1):u[1]===void 0?d=-2:(d=a.lastIndex-u[2].length,h=u[1],a=u[3]===void 0?p0:u[3]==='"'?e2t:t2t):a===e2t||a===t2t?a=p0:a===Qwt||a===Jwt?a=BT:(a=p0,s=void 0);let p=a===p0&&t[o+1].startsWith("/>")?" ":"";n+=a===BT?l+dIt:d>=0?(r.push(h),l.slice(0,d)+iH+l.slice(d)+Rm+p):l+Rm+(d===-2?(r.push(void 0),o):p)}return[h2t(t,n+(t[i]||"<?>")+(e===2?"</svg>":"")),r]},y0=class{constructor({strings:e,_$litType$:i},r){let s;this.parts=[];let n=0,a=0,o=e.length-1,l=this.parts,[h,u]=pIt(e,i);if(this.el=y0.createElement(h,r),m0.currentNode=this.el.content,i===2){let d=this.el.content,c=d.firstChild;c.remove(),d.append(...c.childNodes)}for(;(s=m0.nextNode())!==null&&l.length<o;){if(s.nodeType===1){if(s.hasAttributes()){let d=[];for(let c of s.getAttributeNames())if(c.endsWith(iH)||c.startsWith(Rm)){let p=u[a++];if(d.push(c),p!==void 0){let m=s.getAttribute(p.toLowerCase()+iH).split(Rm),f=/([.?@])?(.*)/.exec(p);l.push({type:1,index:n,name:f[2],strings:m,ctor:f[1]==="."?sH:f[1]==="?"?nH:f[1]==="@"?aH:bb})}else l.push({type:6,index:n})}for(let c of d)s.removeAttribute(c)}if(a2t.test(s.tagName)){let d=s.textContent.split(Rm),c=d.length-1;if(c>0){s.textContent=yb?yb.emptyScript:"";for(let p=0;p<c;p++)s.append(d[p],kT()),m0.nextNode(),l.push({type:2,index:++n});s.append(d[c],kT())}}}else if(s.nodeType===8)if(s.data===s2t)l.push({type:2,index:n});else{let d=-1;for(;(d=s.data.indexOf(Rm,d+1))!==-1;)l.push({type:7,index:n}),d+=Rm.length-1}n++}}static createElement(e,i){let r=f0.createElement("template");return r.innerHTML=e,r}};function vb(t,e,i=t,r){var s,n,a,o;if(e===g0)return e;let l=r!==void 0?(s=i._$Co)===null||s===void 0?void 0:s[r]:i._$Cl,h=VT(e)?void 0:e._$litDirective$;return l?.constructor!==h&&((n=l?._$AO)===null||n===void 0||n.call(l,!1),h===void 0?l=void 0:(l=new h(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=vb(t,l._$AS(t,e.values),l,r)),e}var rH=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:f0).importNode(r,!0);m0.currentNode=n;let a=m0.nextNode(),o=0,l=0,h=s[0];for(;h!==void 0;){if(o===h.index){let u;h.type===2?u=new v0(a,a.nextSibling,this,e):h.type===1?u=new h.ctor(a,h.name,h.strings,this,e):h.type===6&&(u=new oH(a,this,e)),this._$AV.push(u),h=s[++l]}o!==h?.index&&(a=m0.nextNode(),o++)}return m0.currentNode=f0,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++}},v0=class{constructor(e,i,r,s){var n;this.type=2,this._$AH=aa,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=vb(this,e,i),VT(e)?e===aa||e==null||e===""?(this._$AH!==aa&&this._$AR(),this._$AH=aa):e!==this._$AH&&e!==g0&&this._(e):e._$litType$!==void 0?this.g(e):e.nodeType!==void 0?this.$(e):cIt(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!==aa&&VT(this._$AH)?this._$AA.nextSibling.data=e:this.$(f0.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=y0.createElement(h2t(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 rH(n,this),o=a.u(this.options);a.v(r),this.$(o),this._$AH=a}}_$AC(e){let i=i2t.get(e.strings);return i===void 0&&i2t.set(e.strings,i=new y0(e)),i}T(e){n2t(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 v0(this.k(kT()),this.k(kT()),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))}},bb=class{constructor(e,i,r,s,n){this.type=1,this._$AH=aa,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=aa}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=vb(this,e,i,0),a=!VT(e)||e!==this._$AH&&e!==g0,a&&(this._$AH=e);else{let o=e,l,h;for(e=n[0],l=0;l<n.length-1;l++)h=vb(this,o[r+l],i,l),h===g0&&(h=this._$AH[l]),a||(a=!VT(h)||h!==this._$AH[l]),h===aa?e=aa:e!==aa&&(e+=(h??"")+n[l+1]),this._$AH[l]=h}a&&!s&&this.j(e)}j(e){e===aa?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}},sH=class extends bb{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===aa?void 0:e}},mIt=yb?yb.emptyScript:"",nH=class extends bb{constructor(){super(...arguments),this.type=4}j(e){e&&e!==aa?this.element.setAttribute(this.name,mIt):this.element.removeAttribute(this.name)}},aH=class extends bb{constructor(e,i,r,s,n){super(e,i,r,s,n),this.type=5}_$AI(e,i=this){var r;if((e=(r=vb(this,e,i,0))!==null&&r!==void 0?r:aa)===g0)return;let s=this._$AH,n=e===aa&&s!==aa||e.capture!==s.capture||e.once!==s.once||e.passive!==s.passive,a=e!==aa&&(s===aa||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)}},oH=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){vb(this,e)}};var r2t=JD.litHtmlPolyfillSupport;r2t?.(y0,v0),((tH=JD.litHtmlVersions)!==null&&tH!==void 0?tH:JD.litHtmlVersions=[]).push("2.8.0");var zT=(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 v0(e.insertBefore(kT(),o),o,void 0,i??{})}return a._$AI(t),a};var lH,hH;var Dm=class extends Bc{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=zT(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 g0}};Dm.finalized=!0,Dm._$litElement$=!0,(lH=globalThis.litElementHydrateSupport)===null||lH===void 0||lH.call(globalThis,{LitElement:Dm});var u2t=globalThis.litElementPolyfillSupport;u2t?.({LitElement:Dm});((hH=globalThis.litElementVersions)!==null&&hH!==void 0?hH:globalThis.litElementVersions=[]).push("3.3.3");var d2t=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 fIt=(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)}},gIt=(t,e,i)=>{e.constructor.createProperty(i,t)};function Sl(t){return(e,i)=>i!==void 0?gIt(t,e,i):fIt(t,e)}var uH,QGt=((uH=window.HTMLSlotElement)===null||uH===void 0?void 0:uH.prototype.assignedElements)!=null?(t,e)=>t.assignedElements(e):(t,e)=>t.assignedNodes(e).filter(i=>i.nodeType===Node.ELEMENT_NODE);var tO=window.IntersectionObserver!=null;var c2t=(t=32,e=2)=>{let i=t/2;return l2t` <style>
|
|
5214
5214
|
:host {
|