@splinetool/loader 0.9.439 → 0.9.440

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.
@@ -1,6 +1,6 @@
1
1
  "use strict";var q0=Object.create;var Ea=Object.defineProperty;var $0=Object.getOwnPropertyDescriptor;var Y0=Object.getOwnPropertyNames;var X0=Object.getPrototypeOf,K0=Object.prototype.hasOwnProperty;var En=(n,r)=>()=>(r||n((r={exports:{}}).exports,r),r.exports),Yd=(n,r)=>{for(var e in r)Ea(n,e,{get:r[e],enumerable:!0})},Xd=(n,r,e,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of Y0(r))!K0.call(n,o)&&o!==e&&Ea(n,o,{get:()=>r[o],enumerable:!(t=$0(r,o))||t.enumerable});return n};var Ts=(n,r,e)=>(e=n!=null?q0(X0(n)):{},Xd(r||!n||!n.__esModule?Ea(e,"default",{value:n,enumerable:!0}):e,n)),Z0=n=>Xd(Ea({},"__esModule",{value:!0}),n);var Ah=En((Pu,Oh)=>{(function(n,r){typeof Pu=="object"?Oh.exports=r():typeof define=="function"&&define.amd?define(r):n.Alea=r()})(Pu,function(){"use strict";return n.importState=function(e){var t=new n;return t.importState(e),t},n;function n(){return function(e){var t=0,o=0,i=0,s=1;e.length==0&&(e=[+new Date]);var a=r();t=a(" "),o=a(" "),i=a(" ");for(var c=0;c<e.length;c++)t-=a(e[c]),t<0&&(t+=1),o-=a(e[c]),o<0&&(o+=1),i-=a(e[c]),i<0&&(i+=1);a=null;var d=function(){var l=2091639*t+s*23283064365386963e-26;return t=o,o=i,i=l-(s=l|0)};return d.next=d,d.uint32=function(){return d()*4294967296},d.fract53=function(){return d()+(d()*2097152|0)*11102230246251565e-32},d.version="Alea 0.9",d.args=e,d.exportState=function(){return[t,o,i,s]},d.importState=function(l){t=+l[0]||0,o=+l[1]||0,i=+l[2]||0,s=+l[3]||0},d}(Array.prototype.slice.call(arguments))}function r(){var e=4022871197,t=function(o){o=o.toString();for(var i=0;i<o.length;i++){e+=o.charCodeAt(i);var s=.02519603282416938*e;e=s>>>0,s-=e,s*=e,e=s>>>0,s-=e,e+=s*4294967296}return(e>>>0)*23283064365386963e-26};return t.version="Mash 0.9",t}})});var Lh=En((Fl,Eh)=>{(function(n,r){typeof Fl=="object"&&typeof Eh<"u"?r(Fl):typeof define=="function"&&define.amd?define(["exports"],r):r((n=typeof globalThis<"u"?globalThis:n||self).SVDJS={})})(Fl,function(n){"use strict";n.SVD=function(r,e,t,o,i){if(e=e===void 0||e,t=t===void 0||t,i=1e-64/(o=o||Math.pow(2,-52)),!r)throw new TypeError("Matrix a is not defined");var s,a,c,d,l,u,p,f,m,h,y,g,x=r[0].length,S=r.length;if(S<x)throw new TypeError("Invalid matrix: m < n");for(var w=[],b=[],_=[],P=e==="f"?S:x,v=h=p=0;v<S;v++)b[v]=new Array(P).fill(0);for(v=0;v<x;v++)_[v]=new Array(x).fill(0);var N,T=new Array(x).fill(0);for(v=0;v<S;v++)for(s=0;s<x;s++)b[v][s]=r[v][s];for(v=0;v<x;v++){for(w[v]=p,m=0,c=v+1,s=v;s<S;s++)m+=Math.pow(b[s][v],2);if(m<i)p=0;else for(f=(u=b[v][v])*(p=u<0?Math.sqrt(m):-Math.sqrt(m))-m,b[v][v]=u-p,s=c;s<x;s++){for(m=0,a=v;a<S;a++)m+=b[a][v]*b[a][s];for(u=m/f,a=v;a<S;a++)b[a][s]=b[a][s]+u*b[a][v]}for(T[v]=p,m=0,s=c;s<x;s++)m+=Math.pow(b[v][s],2);if(m<i)p=0;else{for(f=(u=b[v][v+1])*(p=u<0?Math.sqrt(m):-Math.sqrt(m))-m,b[v][v+1]=u-p,s=c;s<x;s++)w[s]=b[v][s]/f;for(s=c;s<S;s++){for(m=0,a=c;a<x;a++)m+=b[s][a]*b[v][a];for(a=c;a<x;a++)b[s][a]=b[s][a]+m*w[a]}}h<(y=Math.abs(T[v])+Math.abs(w[v]))&&(h=y)}if(t)for(v=x-1;0<=v;v--){if(p!==0){for(f=b[v][v+1]*p,s=c;s<x;s++)_[s][v]=b[v][s]/f;for(s=c;s<x;s++){for(m=0,a=c;a<x;a++)m+=b[v][a]*_[a][s];for(a=c;a<x;a++)_[a][s]=_[a][s]+m*_[a][v]}}for(s=c;s<x;s++)_[v][s]=0,_[s][v]=0;_[v][v]=1,p=w[v],c=v}if(e){if(e==="f")for(v=x;v<S;v++){for(s=x;s<S;s++)b[v][s]=0;b[v][v]=1}for(v=x-1;0<=v;v--){for(c=v+1,p=T[v],s=c;s<P;s++)b[v][s]=0;if(p!==0){for(f=b[v][v]*p,s=c;s<P;s++){for(m=0,a=c;a<S;a++)m+=b[a][v]*b[a][s];for(u=m/f,a=v;a<S;a++)b[a][s]=b[a][s]+u*b[a][v]}for(s=v;s<S;s++)b[s][v]=b[s][v]/p}else for(s=v;s<S;s++)b[s][v]=0;b[v][v]=b[v][v]+1}}for(o*=h,a=x-1;0<=a;a--)for(var C=0;C<50;C++){for(N=!1,c=a;0<=c;c--){if(Math.abs(w[c])<=o){N=!0;break}if(Math.abs(T[c-1])<=o)break}if(!N){for(l=0,d=c-(m=1),v=c;v<a+1&&(u=m*w[v],w[v]=l*w[v],!(Math.abs(u)<=o));v++)if(p=T[v],T[v]=Math.sqrt(u*u+p*p),l=p/(f=T[v]),m=-u/f,e)for(s=0;s<S;s++)y=b[s][d],g=b[s][v],b[s][d]=y*l+g*m,b[s][v]=-y*m+g*l}if(g=T[a],c===a){if(g<0&&(T[a]=-g,t))for(s=0;s<x;s++)_[s][a]=-_[s][a];break}for(h=T[c],u=(((y=T[a-1])-g)*(y+g)+((p=w[a-1])-(f=w[a]))*(p+f))/(2*f*y),p=Math.sqrt(u*u+1),u=((h-g)*(h+g)+f*(y/(u<0?u-p:u+p)-f))/h,v=c+(m=l=1);v<a+1;v++){if(p=w[v],y=T[v],f=m*p,p*=l,g=Math.sqrt(u*u+f*f),u=h*(l=u/(w[v-1]=g))+p*(m=f/g),p=-h*m+p*l,f=y*m,y*=l,t)for(s=0;s<x;s++)h=_[s][v-1],g=_[s][v],_[s][v-1]=h*l+g*m,_[s][v]=-h*m+g*l;if(g=Math.sqrt(u*u+f*f),u=(l=u/(T[v-1]=g))*p+(m=f/g)*y,h=-m*p+l*y,e)for(s=0;s<S;s++)y=b[s][v-1],g=b[s][v],b[s][v-1]=y*l+g*m,b[s][v]=-y*m+g*l}w[c]=0,w[a]=u,T[a]=h}for(v=0;v<x;v++)T[v]<o&&(T[v]=0);return{u:b,q:T,v:_}},n.VERSION="1.1.1",Object.defineProperty(n,"__esModule",{value:!0})})});var uy=En((ku,Uu)=>{(function(n,r){typeof ku=="object"&&typeof Uu<"u"?Uu.exports=r():typeof define=="function"&&define.amd?define(r):(n=n||self,n.TinyQueue=r())})(ku,function(){"use strict";var n=function(t,o){if(t===void 0&&(t=[]),o===void 0&&(o=r),this.data=t,this.length=this.data.length,this.compare=o,this.length>0)for(var i=(this.length>>1)-1;i>=0;i--)this._down(i)};n.prototype.push=function(t){this.data.push(t),this.length++,this._up(this.length-1)},n.prototype.pop=function(){if(this.length!==0){var t=this.data[0],o=this.data.pop();return this.length--,this.length>0&&(this.data[0]=o,this._down(0)),t}},n.prototype.peek=function(){return this.data[0]},n.prototype._up=function(t){for(var o=this,i=o.data,s=o.compare,a=i[t];t>0;){var c=t-1>>1,d=i[c];if(s(a,d)>=0)break;i[t]=d,t=c}i[t]=a},n.prototype._down=function(t){for(var o=this,i=o.data,s=o.compare,a=this.length>>1,c=i[t];t<a;){var d=(t<<1)+1,l=i[d],u=d+1;if(u<this.length&&s(i[u],l)<0&&(d=u,l=i[u]),s(l,c)>=0)break;i[t]=l,t=d}i[t]=c};function r(e,t){return e<t?-1:e>t?1:0}return n})});var py=En((PV,Hu)=>{"use strict";var ql=uy();ql.default&&(ql=ql.default);Hu.exports=dy;Hu.exports.default=dy;function dy(n,r,e){r=r||1;for(var t,o,i,s,a=0;a<n[0].length;a++){var c=n[0][a];(!a||c[0]<t)&&(t=c[0]),(!a||c[1]<o)&&(o=c[1]),(!a||c[0]>i)&&(i=c[0]),(!a||c[1]>s)&&(s=c[1])}var d=i-t,l=s-o,u=Math.min(d,l),p=u/2;if(u===0){var f=[t,o];return f.distance=0,f}for(var m=new ql(void 0,BP),h=t;h<i;h+=u)for(var y=o;y<s;y+=u)m.push(new Uo(h+p,y+p,p,n));var g=GP(n),x=new Uo(t+d/2,o+l/2,0,n);x.d>g.d&&(g=x);for(var S=m.length;m.length;){var w=m.pop();w.d>g.d&&(g=w,e&&console.log("found best %d after %d probes",Math.round(1e4*w.d)/1e4,S)),!(w.max-g.d<=r)&&(p=w.h/2,m.push(new Uo(w.x-p,w.y-p,p,n)),m.push(new Uo(w.x+p,w.y-p,p,n)),m.push(new Uo(w.x-p,w.y+p,p,n)),m.push(new Uo(w.x+p,w.y+p,p,n)),S+=4)}e&&(console.log("num probes: "+S),console.log("best distance: "+g.d));var b=[g.x,g.y];return b.distance=g.d,b}function BP(n,r){return r.max-n.max}function Uo(n,r,e,t){this.x=n,this.y=r,this.h=e,this.d=RP(n,r,t),this.max=this.d+this.h*Math.SQRT2}function RP(n,r,e){for(var t=!1,o=1/0,i=0;i<e.length;i++)for(var s=e[i],a=0,c=s.length,d=c-1;a<c;d=a++){var l=s[a],u=s[d];l[1]>r!=u[1]>r&&n<(u[0]-l[0])*(r-l[1])/(u[1]-l[1])+l[0]&&(t=!t),o=Math.min(o,VP(n,r,l,u))}return o===0?0:(t?1:-1)*Math.sqrt(o)}function GP(n){for(var r=0,e=0,t=0,o=n[0],i=0,s=o.length,a=s-1;i<s;a=i++){var c=o[i],d=o[a],l=c[0]*d[1]-d[0]*c[1];e+=(c[0]+d[0])*l,t+=(c[1]+d[1])*l,r+=l*3}return r===0?new Uo(o[0][0],o[0][1],0,n):new Uo(e/r,t/r,0,n)}function VP(n,r,e,t){var o=e[0],i=e[1],s=t[0]-o,a=t[1]-i;if(s!==0||a!==0){var c=((n-o)*s+(r-i)*a)/(s*s+a*a);c>1?(o=t[0],i=t[1]):c>0&&(o+=s*c,i+=a*c)}return s=n-o,a=r-i,s*s+a*a}});var Tg=En(bc=>{(function(){"use strict";var n=function(){this.init()};n.prototype={init:function(){var l=this||r;return l._counter=1e3,l._html5AudioPool=[],l.html5PoolSize=10,l._codecs={},l._howls=[],l._muted=!1,l._volume=1,l._canPlayEvent="canplaythrough",l._navigator=typeof window<"u"&&window.navigator?window.navigator:null,l.masterGain=null,l.noAudio=!1,l.usingWebAudio=!0,l.autoSuspend=!0,l.ctx=null,l.autoUnlock=!0,l._setup(),l},volume:function(l){var u=this||r;if(l=parseFloat(l),u.ctx||d(),typeof l<"u"&&l>=0&&l<=1){if(u._volume=l,u._muted)return u;u.usingWebAudio&&u.masterGain.gain.setValueAtTime(l,r.ctx.currentTime);for(var p=0;p<u._howls.length;p++)if(!u._howls[p]._webAudio)for(var f=u._howls[p]._getSoundIds(),m=0;m<f.length;m++){var h=u._howls[p]._soundById(f[m]);h&&h._node&&(h._node.volume=h._volume*l)}return u}return u._volume},mute:function(l){var u=this||r;u.ctx||d(),u._muted=l,u.usingWebAudio&&u.masterGain.gain.setValueAtTime(l?0:u._volume,r.ctx.currentTime);for(var p=0;p<u._howls.length;p++)if(!u._howls[p]._webAudio)for(var f=u._howls[p]._getSoundIds(),m=0;m<f.length;m++){var h=u._howls[p]._soundById(f[m]);h&&h._node&&(h._node.muted=l?!0:h._muted)}return u},stop:function(){for(var l=this||r,u=0;u<l._howls.length;u++)l._howls[u].stop();return l},unload:function(){for(var l=this||r,u=l._howls.length-1;u>=0;u--)l._howls[u].unload();return l.usingWebAudio&&l.ctx&&typeof l.ctx.close<"u"&&(l.ctx.close(),l.ctx=null,d()),l},codecs:function(l){return(this||r)._codecs[l.replace(/^x-/,"")]},_setup:function(){var l=this||r;if(l.state=l.ctx&&l.ctx.state||"suspended",l._autoSuspend(),!l.usingWebAudio)if(typeof Audio<"u")try{var u=new Audio;typeof u.oncanplaythrough>"u"&&(l._canPlayEvent="canplay")}catch{l.noAudio=!0}else l.noAudio=!0;try{var u=new Audio;u.muted&&(l.noAudio=!0)}catch{}return l.noAudio||l._setupCodecs(),l},_setupCodecs:function(){var l=this||r,u=null;try{u=typeof Audio<"u"?new Audio:null}catch{return l}if(!u||typeof u.canPlayType!="function")return l;var p=u.canPlayType("audio/mpeg;").replace(/^no$/,""),f=l._navigator?l._navigator.userAgent:"",m=f.match(/OPR\/([0-6].)/g),h=m&&parseInt(m[0].split("/")[1],10)<33,y=f.indexOf("Safari")!==-1&&f.indexOf("Chrome")===-1,g=f.match(/Version\/(.*?) /),x=y&&g&&parseInt(g[1],10)<15;return l._codecs={mp3:!!(!h&&(p||u.canPlayType("audio/mp3;").replace(/^no$/,""))),mpeg:!!p,opus:!!u.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/,""),ogg:!!u.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),oga:!!u.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),wav:!!(u.canPlayType('audio/wav; codecs="1"')||u.canPlayType("audio/wav")).replace(/^no$/,""),aac:!!u.canPlayType("audio/aac;").replace(/^no$/,""),caf:!!u.canPlayType("audio/x-caf;").replace(/^no$/,""),m4a:!!(u.canPlayType("audio/x-m4a;")||u.canPlayType("audio/m4a;")||u.canPlayType("audio/aac;")).replace(/^no$/,""),m4b:!!(u.canPlayType("audio/x-m4b;")||u.canPlayType("audio/m4b;")||u.canPlayType("audio/aac;")).replace(/^no$/,""),mp4:!!(u.canPlayType("audio/x-mp4;")||u.canPlayType("audio/mp4;")||u.canPlayType("audio/aac;")).replace(/^no$/,""),weba:!!(!x&&u.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),webm:!!(!x&&u.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),dolby:!!u.canPlayType('audio/mp4; codecs="ec-3"').replace(/^no$/,""),flac:!!(u.canPlayType("audio/x-flac;")||u.canPlayType("audio/flac;")).replace(/^no$/,"")},l},_unlockAudio:function(){var l=this||r;if(!(l._audioUnlocked||!l.ctx)){l._audioUnlocked=!1,l.autoUnlock=!1,!l._mobileUnloaded&&l.ctx.sampleRate!==44100&&(l._mobileUnloaded=!0,l.unload()),l._scratchBuffer=l.ctx.createBuffer(1,1,22050);var u=function(p){for(;l._html5AudioPool.length<l.html5PoolSize;)try{var f=new Audio;f._unlocked=!0,l._releaseHtml5Audio(f)}catch{l.noAudio=!0;break}for(var m=0;m<l._howls.length;m++)if(!l._howls[m]._webAudio)for(var h=l._howls[m]._getSoundIds(),y=0;y<h.length;y++){var g=l._howls[m]._soundById(h[y]);g&&g._node&&!g._node._unlocked&&(g._node._unlocked=!0,g._node.load())}l._autoResume();var x=l.ctx.createBufferSource();x.buffer=l._scratchBuffer,x.connect(l.ctx.destination),typeof x.start>"u"?x.noteOn(0):x.start(0),typeof l.ctx.resume=="function"&&l.ctx.resume(),x.onended=function(){x.disconnect(0),l._audioUnlocked=!0,document.removeEventListener("touchstart",u,!0),document.removeEventListener("touchend",u,!0),document.removeEventListener("click",u,!0),document.removeEventListener("keydown",u,!0);for(var S=0;S<l._howls.length;S++)l._howls[S]._emit("unlock")}};return document.addEventListener("touchstart",u,!0),document.addEventListener("touchend",u,!0),document.addEventListener("click",u,!0),document.addEventListener("keydown",u,!0),l}},_obtainHtml5Audio:function(){var l=this||r;if(l._html5AudioPool.length)return l._html5AudioPool.pop();var u=new Audio().play();return u&&typeof Promise<"u"&&(u instanceof Promise||typeof u.then=="function")&&u.catch(function(){console.warn("HTML5 Audio pool exhausted, returning potentially locked audio object.")}),new Audio},_releaseHtml5Audio:function(l){var u=this||r;return l._unlocked&&u._html5AudioPool.push(l),u},_autoSuspend:function(){var l=this;if(!(!l.autoSuspend||!l.ctx||typeof l.ctx.suspend>"u"||!r.usingWebAudio)){for(var u=0;u<l._howls.length;u++)if(l._howls[u]._webAudio){for(var p=0;p<l._howls[u]._sounds.length;p++)if(!l._howls[u]._sounds[p]._paused)return l}return l._suspendTimer&&clearTimeout(l._suspendTimer),l._suspendTimer=setTimeout(function(){if(!!l.autoSuspend){l._suspendTimer=null,l.state="suspending";var f=function(){l.state="suspended",l._resumeAfterSuspend&&(delete l._resumeAfterSuspend,l._autoResume())};l.ctx.suspend().then(f,f)}},3e4),l}},_autoResume:function(){var l=this;if(!(!l.ctx||typeof l.ctx.resume>"u"||!r.usingWebAudio))return l.state==="running"&&l.ctx.state!=="interrupted"&&l._suspendTimer?(clearTimeout(l._suspendTimer),l._suspendTimer=null):l.state==="suspended"||l.state==="running"&&l.ctx.state==="interrupted"?(l.ctx.resume().then(function(){l.state="running";for(var u=0;u<l._howls.length;u++)l._howls[u]._emit("resume")}),l._suspendTimer&&(clearTimeout(l._suspendTimer),l._suspendTimer=null)):l.state==="suspending"&&(l._resumeAfterSuspend=!0),l}};var r=new n,e=function(l){var u=this;if(!l.src||l.src.length===0){console.error("An array of source files must be passed with any new Howl.");return}u.init(l)};e.prototype={init:function(l){var u=this;return r.ctx||d(),u._autoplay=l.autoplay||!1,u._format=typeof l.format!="string"?l.format:[l.format],u._html5=l.html5||!1,u._muted=l.mute||!1,u._loop=l.loop||!1,u._pool=l.pool||5,u._preload=typeof l.preload=="boolean"||l.preload==="metadata"?l.preload:!0,u._rate=l.rate||1,u._sprite=l.sprite||{},u._src=typeof l.src!="string"?l.src:[l.src],u._volume=l.volume!==void 0?l.volume:1,u._xhr={method:l.xhr&&l.xhr.method?l.xhr.method:"GET",headers:l.xhr&&l.xhr.headers?l.xhr.headers:null,withCredentials:l.xhr&&l.xhr.withCredentials?l.xhr.withCredentials:!1},u._duration=0,u._state="unloaded",u._sounds=[],u._endTimers={},u._queue=[],u._playLock=!1,u._onend=l.onend?[{fn:l.onend}]:[],u._onfade=l.onfade?[{fn:l.onfade}]:[],u._onload=l.onload?[{fn:l.onload}]:[],u._onloaderror=l.onloaderror?[{fn:l.onloaderror}]:[],u._onplayerror=l.onplayerror?[{fn:l.onplayerror}]:[],u._onpause=l.onpause?[{fn:l.onpause}]:[],u._onplay=l.onplay?[{fn:l.onplay}]:[],u._onstop=l.onstop?[{fn:l.onstop}]:[],u._onmute=l.onmute?[{fn:l.onmute}]:[],u._onvolume=l.onvolume?[{fn:l.onvolume}]:[],u._onrate=l.onrate?[{fn:l.onrate}]:[],u._onseek=l.onseek?[{fn:l.onseek}]:[],u._onunlock=l.onunlock?[{fn:l.onunlock}]:[],u._onresume=[],u._webAudio=r.usingWebAudio&&!u._html5,typeof r.ctx<"u"&&r.ctx&&r.autoUnlock&&r._unlockAudio(),r._howls.push(u),u._autoplay&&u._queue.push({event:"play",action:function(){u.play()}}),u._preload&&u._preload!=="none"&&u.load(),u},load:function(){var l=this,u=null;if(r.noAudio){l._emit("loaderror",null,"No audio support.");return}typeof l._src=="string"&&(l._src=[l._src]);for(var p=0;p<l._src.length;p++){var f,m;if(l._format&&l._format[p])f=l._format[p];else{if(m=l._src[p],typeof m!="string"){l._emit("loaderror",null,"Non-string found in selected audio sources - ignoring.");continue}f=/^data:audio\/([^;,]+);/i.exec(m),f||(f=/\.([^.]+)$/.exec(m.split("?",1)[0])),f&&(f=f[1].toLowerCase())}if(f||console.warn('No file extension was found. Consider using the "format" property or specify an extension.'),f&&r.codecs(f)){u=l._src[p];break}}if(!u){l._emit("loaderror",null,"No codec support for selected audio sources.");return}return l._src=u,l._state="loading",window.location.protocol==="https:"&&u.slice(0,5)==="http:"&&(l._html5=!0,l._webAudio=!1),new t(l),l._webAudio&&i(l),l},play:function(l,u){var p=this,f=null;if(typeof l=="number")f=l,l=null;else{if(typeof l=="string"&&p._state==="loaded"&&!p._sprite[l])return null;if(typeof l>"u"&&(l="__default",!p._playLock)){for(var m=0,h=0;h<p._sounds.length;h++)p._sounds[h]._paused&&!p._sounds[h]._ended&&(m++,f=p._sounds[h]._id);m===1?l=null:f=null}}var y=f?p._soundById(f):p._inactiveSound();if(!y)return null;if(f&&!l&&(l=y._sprite||"__default"),p._state!=="loaded"){y._sprite=l,y._ended=!1;var g=y._id;return p._queue.push({event:"play",action:function(){p.play(g)}}),g}if(f&&!y._paused)return u||p._loadQueue("play"),y._id;p._webAudio&&r._autoResume();var x=Math.max(0,y._seek>0?y._seek:p._sprite[l][0]/1e3),S=Math.max(0,(p._sprite[l][0]+p._sprite[l][1])/1e3-x),w=S*1e3/Math.abs(y._rate),b=p._sprite[l][0]/1e3,_=(p._sprite[l][0]+p._sprite[l][1])/1e3;y._sprite=l,y._ended=!1;var P=function(){y._paused=!1,y._seek=x,y._start=b,y._stop=_,y._loop=!!(y._loop||p._sprite[l][2])};if(x>=_){p._ended(y);return}var v=y._node;if(p._webAudio){var N=function(){p._playLock=!1,P(),p._refreshBuffer(y);var A=y._muted||p._muted?0:y._volume;v.gain.setValueAtTime(A,r.ctx.currentTime),y._playStart=r.ctx.currentTime,typeof v.bufferSource.start>"u"?y._loop?v.bufferSource.noteGrainOn(0,x,86400):v.bufferSource.noteGrainOn(0,x,S):y._loop?v.bufferSource.start(0,x,86400):v.bufferSource.start(0,x,S),w!==1/0&&(p._endTimers[y._id]=setTimeout(p._ended.bind(p,y),w)),u||setTimeout(function(){p._emit("play",y._id),p._loadQueue()},0)};r.state==="running"&&r.ctx.state!=="interrupted"?N():(p._playLock=!0,p.once("resume",N),p._clearTimer(y._id))}else{var T=function(){v.currentTime=x,v.muted=y._muted||p._muted||r._muted||v.muted,v.volume=y._volume*r.volume(),v.playbackRate=y._rate;try{var A=v.play();if(A&&typeof Promise<"u"&&(A instanceof Promise||typeof A.then=="function")?(p._playLock=!0,P(),A.then(function(){p._playLock=!1,v._unlocked=!0,u?p._loadQueue():p._emit("play",y._id)}).catch(function(){p._playLock=!1,p._emit("playerror",y._id,"Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction."),y._ended=!0,y._paused=!0})):u||(p._playLock=!1,P(),p._emit("play",y._id)),v.playbackRate=y._rate,v.paused){p._emit("playerror",y._id,"Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction.");return}l!=="__default"||y._loop?p._endTimers[y._id]=setTimeout(p._ended.bind(p,y),w):(p._endTimers[y._id]=function(){p._ended(y),v.removeEventListener("ended",p._endTimers[y._id],!1)},v.addEventListener("ended",p._endTimers[y._id],!1))}catch(M){p._emit("playerror",y._id,M)}};v.src==="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA"&&(v.src=p._src,v.load());var C=window&&window.ejecta||!v.readyState&&r._navigator.isCocoonJS;if(v.readyState>=3||C)T();else{p._playLock=!0,p._state="loading";var O=function(){p._state="loaded",T(),v.removeEventListener(r._canPlayEvent,O,!1)};v.addEventListener(r._canPlayEvent,O,!1),p._clearTimer(y._id)}}return y._id},pause:function(l){var u=this;if(u._state!=="loaded"||u._playLock)return u._queue.push({event:"pause",action:function(){u.pause(l)}}),u;for(var p=u._getSoundIds(l),f=0;f<p.length;f++){u._clearTimer(p[f]);var m=u._soundById(p[f]);if(m&&!m._paused&&(m._seek=u.seek(p[f]),m._rateSeek=0,m._paused=!0,u._stopFade(p[f]),m._node))if(u._webAudio){if(!m._node.bufferSource)continue;typeof m._node.bufferSource.stop>"u"?m._node.bufferSource.noteOff(0):m._node.bufferSource.stop(0),u._cleanBuffer(m._node)}else(!isNaN(m._node.duration)||m._node.duration===1/0)&&m._node.pause();arguments[1]||u._emit("pause",m?m._id:null)}return u},stop:function(l,u){var p=this;if(p._state!=="loaded"||p._playLock)return p._queue.push({event:"stop",action:function(){p.stop(l)}}),p;for(var f=p._getSoundIds(l),m=0;m<f.length;m++){p._clearTimer(f[m]);var h=p._soundById(f[m]);h&&(h._seek=h._start||0,h._rateSeek=0,h._paused=!0,h._ended=!0,p._stopFade(f[m]),h._node&&(p._webAudio?h._node.bufferSource&&(typeof h._node.bufferSource.stop>"u"?h._node.bufferSource.noteOff(0):h._node.bufferSource.stop(0),p._cleanBuffer(h._node)):(!isNaN(h._node.duration)||h._node.duration===1/0)&&(h._node.currentTime=h._start||0,h._node.pause(),h._node.duration===1/0&&p._clearSound(h._node))),u||p._emit("stop",h._id))}return p},mute:function(l,u){var p=this;if(p._state!=="loaded"||p._playLock)return p._queue.push({event:"mute",action:function(){p.mute(l,u)}}),p;if(typeof u>"u")if(typeof l=="boolean")p._muted=l;else return p._muted;for(var f=p._getSoundIds(u),m=0;m<f.length;m++){var h=p._soundById(f[m]);h&&(h._muted=l,h._interval&&p._stopFade(h._id),p._webAudio&&h._node?h._node.gain.setValueAtTime(l?0:h._volume,r.ctx.currentTime):h._node&&(h._node.muted=r._muted?!0:l),p._emit("mute",h._id))}return p},volume:function(){var l=this,u=arguments,p,f;if(u.length===0)return l._volume;if(u.length===1||u.length===2&&typeof u[1]>"u"){var m=l._getSoundIds(),h=m.indexOf(u[0]);h>=0?f=parseInt(u[0],10):p=parseFloat(u[0])}else u.length>=2&&(p=parseFloat(u[0]),f=parseInt(u[1],10));var y;if(typeof p<"u"&&p>=0&&p<=1){if(l._state!=="loaded"||l._playLock)return l._queue.push({event:"volume",action:function(){l.volume.apply(l,u)}}),l;typeof f>"u"&&(l._volume=p),f=l._getSoundIds(f);for(var g=0;g<f.length;g++)y=l._soundById(f[g]),y&&(y._volume=p,u[2]||l._stopFade(f[g]),l._webAudio&&y._node&&!y._muted?y._node.gain.setValueAtTime(p,r.ctx.currentTime):y._node&&!y._muted&&(y._node.volume=p*r.volume()),l._emit("volume",y._id))}else return y=f?l._soundById(f):l._sounds[0],y?y._volume:0;return l},fade:function(l,u,p,f){var m=this;if(m._state!=="loaded"||m._playLock)return m._queue.push({event:"fade",action:function(){m.fade(l,u,p,f)}}),m;l=Math.min(Math.max(0,parseFloat(l)),1),u=Math.min(Math.max(0,parseFloat(u)),1),p=parseFloat(p),m.volume(l,f);for(var h=m._getSoundIds(f),y=0;y<h.length;y++){var g=m._soundById(h[y]);if(g){if(f||m._stopFade(h[y]),m._webAudio&&!g._muted){var x=r.ctx.currentTime,S=x+p/1e3;g._volume=l,g._node.gain.setValueAtTime(l,x),g._node.gain.linearRampToValueAtTime(u,S)}m._startFadeInterval(g,l,u,p,h[y],typeof f>"u")}}return m},_startFadeInterval:function(l,u,p,f,m,h){var y=this,g=u,x=p-u,S=Math.abs(x/.01),w=Math.max(4,S>0?f/S:f),b=Date.now();l._fadeTo=p,l._interval=setInterval(function(){var _=(Date.now()-b)/f;b=Date.now(),g+=x*_,g=Math.round(g*100)/100,x<0?g=Math.max(p,g):g=Math.min(p,g),y._webAudio?l._volume=g:y.volume(g,l._id,!0),h&&(y._volume=g),(p<u&&g<=p||p>u&&g>=p)&&(clearInterval(l._interval),l._interval=null,l._fadeTo=null,y.volume(p,l._id),y._emit("fade",l._id))},w)},_stopFade:function(l){var u=this,p=u._soundById(l);return p&&p._interval&&(u._webAudio&&p._node.gain.cancelScheduledValues(r.ctx.currentTime),clearInterval(p._interval),p._interval=null,u.volume(p._fadeTo,l),p._fadeTo=null,u._emit("fade",l)),u},loop:function(){var l=this,u=arguments,p,f,m;if(u.length===0)return l._loop;if(u.length===1)if(typeof u[0]=="boolean")p=u[0],l._loop=p;else return m=l._soundById(parseInt(u[0],10)),m?m._loop:!1;else u.length===2&&(p=u[0],f=parseInt(u[1],10));for(var h=l._getSoundIds(f),y=0;y<h.length;y++)m=l._soundById(h[y]),m&&(m._loop=p,l._webAudio&&m._node&&m._node.bufferSource&&(m._node.bufferSource.loop=p,p&&(m._node.bufferSource.loopStart=m._start||0,m._node.bufferSource.loopEnd=m._stop,l.playing(h[y])&&(l.pause(h[y],!0),l.play(h[y],!0)))));return l},rate:function(){var l=this,u=arguments,p,f;if(u.length===0)f=l._sounds[0]._id;else if(u.length===1){var m=l._getSoundIds(),h=m.indexOf(u[0]);h>=0?f=parseInt(u[0],10):p=parseFloat(u[0])}else u.length===2&&(p=parseFloat(u[0]),f=parseInt(u[1],10));var y;if(typeof p=="number"){if(l._state!=="loaded"||l._playLock)return l._queue.push({event:"rate",action:function(){l.rate.apply(l,u)}}),l;typeof f>"u"&&(l._rate=p),f=l._getSoundIds(f);for(var g=0;g<f.length;g++)if(y=l._soundById(f[g]),y){l.playing(f[g])&&(y._rateSeek=l.seek(f[g]),y._playStart=l._webAudio?r.ctx.currentTime:y._playStart),y._rate=p,l._webAudio&&y._node&&y._node.bufferSource?y._node.bufferSource.playbackRate.setValueAtTime(p,r.ctx.currentTime):y._node&&(y._node.playbackRate=p);var x=l.seek(f[g]),S=(l._sprite[y._sprite][0]+l._sprite[y._sprite][1])/1e3-x,w=S*1e3/Math.abs(y._rate);(l._endTimers[f[g]]||!y._paused)&&(l._clearTimer(f[g]),l._endTimers[f[g]]=setTimeout(l._ended.bind(l,y),w)),l._emit("rate",y._id)}}else return y=l._soundById(f),y?y._rate:l._rate;return l},seek:function(){var l=this,u=arguments,p,f;if(u.length===0)l._sounds.length&&(f=l._sounds[0]._id);else if(u.length===1){var m=l._getSoundIds(),h=m.indexOf(u[0]);h>=0?f=parseInt(u[0],10):l._sounds.length&&(f=l._sounds[0]._id,p=parseFloat(u[0]))}else u.length===2&&(p=parseFloat(u[0]),f=parseInt(u[1],10));if(typeof f>"u")return 0;if(typeof p=="number"&&(l._state!=="loaded"||l._playLock))return l._queue.push({event:"seek",action:function(){l.seek.apply(l,u)}}),l;var y=l._soundById(f);if(y)if(typeof p=="number"&&p>=0){var g=l.playing(f);g&&l.pause(f,!0),y._seek=p,y._ended=!1,l._clearTimer(f),!l._webAudio&&y._node&&!isNaN(y._node.duration)&&(y._node.currentTime=p);var x=function(){g&&l.play(f,!0),l._emit("seek",f)};if(g&&!l._webAudio){var S=function(){l._playLock?setTimeout(S,0):x()};setTimeout(S,0)}else x()}else if(l._webAudio){var w=l.playing(f)?r.ctx.currentTime-y._playStart:0,b=y._rateSeek?y._rateSeek-y._seek:0;return y._seek+(b+w*Math.abs(y._rate))}else return y._node.currentTime;return l},playing:function(l){var u=this;if(typeof l=="number"){var p=u._soundById(l);return p?!p._paused:!1}for(var f=0;f<u._sounds.length;f++)if(!u._sounds[f]._paused)return!0;return!1},duration:function(l){var u=this,p=u._duration,f=u._soundById(l);return f&&(p=u._sprite[f._sprite][1]/1e3),p},state:function(){return this._state},unload:function(){for(var l=this,u=l._sounds,p=0;p<u.length;p++)u[p]._paused||l.stop(u[p]._id),l._webAudio||(l._clearSound(u[p]._node),u[p]._node.removeEventListener("error",u[p]._errorFn,!1),u[p]._node.removeEventListener(r._canPlayEvent,u[p]._loadFn,!1),u[p]._node.removeEventListener("ended",u[p]._endFn,!1),r._releaseHtml5Audio(u[p]._node)),delete u[p]._node,l._clearTimer(u[p]._id);var f=r._howls.indexOf(l);f>=0&&r._howls.splice(f,1);var m=!0;for(p=0;p<r._howls.length;p++)if(r._howls[p]._src===l._src||l._src.indexOf(r._howls[p]._src)>=0){m=!1;break}return o&&m&&delete o[l._src],r.noAudio=!1,l._state="unloaded",l._sounds=[],l=null,null},on:function(l,u,p,f){var m=this,h=m["_on"+l];return typeof u=="function"&&h.push(f?{id:p,fn:u,once:f}:{id:p,fn:u}),m},off:function(l,u,p){var f=this,m=f["_on"+l],h=0;if(typeof u=="number"&&(p=u,u=null),u||p)for(h=0;h<m.length;h++){var y=p===m[h].id;if(u===m[h].fn&&y||!u&&y){m.splice(h,1);break}}else if(l)f["_on"+l]=[];else{var g=Object.keys(f);for(h=0;h<g.length;h++)g[h].indexOf("_on")===0&&Array.isArray(f[g[h]])&&(f[g[h]]=[])}return f},once:function(l,u,p){var f=this;return f.on(l,u,p,1),f},_emit:function(l,u,p){for(var f=this,m=f["_on"+l],h=m.length-1;h>=0;h--)(!m[h].id||m[h].id===u||l==="load")&&(setTimeout(function(y){y.call(this,u,p)}.bind(f,m[h].fn),0),m[h].once&&f.off(l,m[h].fn,m[h].id));return f._loadQueue(l),f},_loadQueue:function(l){var u=this;if(u._queue.length>0){var p=u._queue[0];p.event===l&&(u._queue.shift(),u._loadQueue()),l||p.action()}return u},_ended:function(l){var u=this,p=l._sprite;if(!u._webAudio&&l._node&&!l._node.paused&&!l._node.ended&&l._node.currentTime<l._stop)return setTimeout(u._ended.bind(u,l),100),u;var f=!!(l._loop||u._sprite[p][2]);if(u._emit("end",l._id),!u._webAudio&&f&&u.stop(l._id,!0).play(l._id),u._webAudio&&f){u._emit("play",l._id),l._seek=l._start||0,l._rateSeek=0,l._playStart=r.ctx.currentTime;var m=(l._stop-l._start)*1e3/Math.abs(l._rate);u._endTimers[l._id]=setTimeout(u._ended.bind(u,l),m)}return u._webAudio&&!f&&(l._paused=!0,l._ended=!0,l._seek=l._start||0,l._rateSeek=0,u._clearTimer(l._id),u._cleanBuffer(l._node),r._autoSuspend()),!u._webAudio&&!f&&u.stop(l._id,!0),u},_clearTimer:function(l){var u=this;if(u._endTimers[l]){if(typeof u._endTimers[l]!="function")clearTimeout(u._endTimers[l]);else{var p=u._soundById(l);p&&p._node&&p._node.removeEventListener("ended",u._endTimers[l],!1)}delete u._endTimers[l]}return u},_soundById:function(l){for(var u=this,p=0;p<u._sounds.length;p++)if(l===u._sounds[p]._id)return u._sounds[p];return null},_inactiveSound:function(){var l=this;l._drain();for(var u=0;u<l._sounds.length;u++)if(l._sounds[u]._ended)return l._sounds[u].reset();return new t(l)},_drain:function(){var l=this,u=l._pool,p=0,f=0;if(!(l._sounds.length<u)){for(f=0;f<l._sounds.length;f++)l._sounds[f]._ended&&p++;for(f=l._sounds.length-1;f>=0;f--){if(p<=u)return;l._sounds[f]._ended&&(l._webAudio&&l._sounds[f]._node&&l._sounds[f]._node.disconnect(0),l._sounds.splice(f,1),p--)}}},_getSoundIds:function(l){var u=this;if(typeof l>"u"){for(var p=[],f=0;f<u._sounds.length;f++)p.push(u._sounds[f]._id);return p}else return[l]},_refreshBuffer:function(l){var u=this;return l._node.bufferSource=r.ctx.createBufferSource(),l._node.bufferSource.buffer=o[u._src],l._panner?l._node.bufferSource.connect(l._panner):l._node.bufferSource.connect(l._node),l._node.bufferSource.loop=l._loop,l._loop&&(l._node.bufferSource.loopStart=l._start||0,l._node.bufferSource.loopEnd=l._stop||0),l._node.bufferSource.playbackRate.setValueAtTime(l._rate,r.ctx.currentTime),u},_cleanBuffer:function(l){var u=this,p=r._navigator&&r._navigator.vendor.indexOf("Apple")>=0;if(r._scratchBuffer&&l.bufferSource&&(l.bufferSource.onended=null,l.bufferSource.disconnect(0),p))try{l.bufferSource.buffer=r._scratchBuffer}catch{}return l.bufferSource=null,u},_clearSound:function(l){var u=/MSIE |Trident\//.test(r._navigator&&r._navigator.userAgent);u||(l.src="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA")}};var t=function(l){this._parent=l,this.init()};t.prototype={init:function(){var l=this,u=l._parent;return l._muted=u._muted,l._loop=u._loop,l._volume=u._volume,l._rate=u._rate,l._seek=0,l._paused=!0,l._ended=!0,l._sprite="__default",l._id=++r._counter,u._sounds.push(l),l.create(),l},create:function(){var l=this,u=l._parent,p=r._muted||l._muted||l._parent._muted?0:l._volume;return u._webAudio?(l._node=typeof r.ctx.createGain>"u"?r.ctx.createGainNode():r.ctx.createGain(),l._node.gain.setValueAtTime(p,r.ctx.currentTime),l._node.paused=!0,l._node.connect(r.masterGain)):r.noAudio||(l._node=r._obtainHtml5Audio(),l._errorFn=l._errorListener.bind(l),l._node.addEventListener("error",l._errorFn,!1),l._loadFn=l._loadListener.bind(l),l._node.addEventListener(r._canPlayEvent,l._loadFn,!1),l._endFn=l._endListener.bind(l),l._node.addEventListener("ended",l._endFn,!1),l._node.src=u._src,l._node.preload=u._preload===!0?"auto":u._preload,l._node.volume=p*r.volume(),l._node.load()),l},reset:function(){var l=this,u=l._parent;return l._muted=u._muted,l._loop=u._loop,l._volume=u._volume,l._rate=u._rate,l._seek=0,l._rateSeek=0,l._paused=!0,l._ended=!0,l._sprite="__default",l._id=++r._counter,l},_errorListener:function(){var l=this;l._parent._emit("loaderror",l._id,l._node.error?l._node.error.code:0),l._node.removeEventListener("error",l._errorFn,!1)},_loadListener:function(){var l=this,u=l._parent;u._duration=Math.ceil(l._node.duration*10)/10,Object.keys(u._sprite).length===0&&(u._sprite={__default:[0,u._duration*1e3]}),u._state!=="loaded"&&(u._state="loaded",u._emit("load"),u._loadQueue()),l._node.removeEventListener(r._canPlayEvent,l._loadFn,!1)},_endListener:function(){var l=this,u=l._parent;u._duration===1/0&&(u._duration=Math.ceil(l._node.duration*10)/10,u._sprite.__default[1]===1/0&&(u._sprite.__default[1]=u._duration*1e3),u._ended(l)),l._node.removeEventListener("ended",l._endFn,!1)}};var o={},i=function(l){var u=l._src;if(o[u]){l._duration=o[u].duration,c(l);return}if(/^data:[^;]+;base64,/.test(u)){for(var p=atob(u.split(",")[1]),f=new Uint8Array(p.length),m=0;m<p.length;++m)f[m]=p.charCodeAt(m);a(f.buffer,l)}else{var h=new XMLHttpRequest;h.open(l._xhr.method,u,!0),h.withCredentials=l._xhr.withCredentials,h.responseType="arraybuffer",l._xhr.headers&&Object.keys(l._xhr.headers).forEach(function(y){h.setRequestHeader(y,l._xhr.headers[y])}),h.onload=function(){var y=(h.status+"")[0];if(y!=="0"&&y!=="2"&&y!=="3"){l._emit("loaderror",null,"Failed loading audio file with status: "+h.status+".");return}a(h.response,l)},h.onerror=function(){l._webAudio&&(l._html5=!0,l._webAudio=!1,l._sounds=[],delete o[u],l.load())},s(h)}},s=function(l){try{l.send()}catch{l.onerror()}},a=function(l,u){var p=function(){u._emit("loaderror",null,"Decoding audio data failed.")},f=function(m){m&&u._sounds.length>0?(o[u._src]=m,c(u,m)):p()};typeof Promise<"u"&&r.ctx.decodeAudioData.length===1?r.ctx.decodeAudioData(l).then(f).catch(p):r.ctx.decodeAudioData(l,f,p)},c=function(l,u){u&&!l._duration&&(l._duration=u.duration),Object.keys(l._sprite).length===0&&(l._sprite={__default:[0,l._duration*1e3]}),l._state!=="loaded"&&(l._state="loaded",l._emit("load"),l._loadQueue())},d=function(){if(!!r.usingWebAudio){try{typeof AudioContext<"u"?r.ctx=new AudioContext:typeof webkitAudioContext<"u"?r.ctx=new webkitAudioContext:r.usingWebAudio=!1}catch{r.usingWebAudio=!1}r.ctx||(r.usingWebAudio=!1);var l=/iP(hone|od|ad)/.test(r._navigator&&r._navigator.platform),u=r._navigator&&r._navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/),p=u?parseInt(u[1],10):null;if(l&&p&&p<9){var f=/safari/.test(r._navigator&&r._navigator.userAgent.toLowerCase());r._navigator&&!f&&(r.usingWebAudio=!1)}r.usingWebAudio&&(r.masterGain=typeof r.ctx.createGain>"u"?r.ctx.createGainNode():r.ctx.createGain(),r.masterGain.gain.setValueAtTime(r._muted?0:r._volume,r.ctx.currentTime),r.masterGain.connect(r.ctx.destination)),r._setup()}};typeof define=="function"&&define.amd&&define([],function(){return{Howler:r,Howl:e}}),typeof bc<"u"&&(bc.Howler=r,bc.Howl=e),typeof global<"u"?(global.HowlerGlobal=n,global.Howler=r,global.Howl=e,global.Sound=t):typeof window<"u"&&(window.HowlerGlobal=n,window.Howler=r,window.Howl=e,window.Sound=t)})();(function(){"use strict";HowlerGlobal.prototype._pos=[0,0,0],HowlerGlobal.prototype._orientation=[0,0,-1,0,1,0],HowlerGlobal.prototype.stereo=function(r){var e=this;if(!e.ctx||!e.ctx.listener)return e;for(var t=e._howls.length-1;t>=0;t--)e._howls[t].stereo(r);return e},HowlerGlobal.prototype.pos=function(r,e,t){var o=this;if(!o.ctx||!o.ctx.listener)return o;if(e=typeof e!="number"?o._pos[1]:e,t=typeof t!="number"?o._pos[2]:t,typeof r=="number")o._pos=[r,e,t],typeof o.ctx.listener.positionX<"u"?(o.ctx.listener.positionX.setTargetAtTime(o._pos[0],Howler.ctx.currentTime,.1),o.ctx.listener.positionY.setTargetAtTime(o._pos[1],Howler.ctx.currentTime,.1),o.ctx.listener.positionZ.setTargetAtTime(o._pos[2],Howler.ctx.currentTime,.1)):o.ctx.listener.setPosition(o._pos[0],o._pos[1],o._pos[2]);else return o._pos;return o},HowlerGlobal.prototype.orientation=function(r,e,t,o,i,s){var a=this;if(!a.ctx||!a.ctx.listener)return a;var c=a._orientation;if(e=typeof e!="number"?c[1]:e,t=typeof t!="number"?c[2]:t,o=typeof o!="number"?c[3]:o,i=typeof i!="number"?c[4]:i,s=typeof s!="number"?c[5]:s,typeof r=="number")a._orientation=[r,e,t,o,i,s],typeof a.ctx.listener.forwardX<"u"?(a.ctx.listener.forwardX.setTargetAtTime(r,Howler.ctx.currentTime,.1),a.ctx.listener.forwardY.setTargetAtTime(e,Howler.ctx.currentTime,.1),a.ctx.listener.forwardZ.setTargetAtTime(t,Howler.ctx.currentTime,.1),a.ctx.listener.upX.setTargetAtTime(o,Howler.ctx.currentTime,.1),a.ctx.listener.upY.setTargetAtTime(i,Howler.ctx.currentTime,.1),a.ctx.listener.upZ.setTargetAtTime(s,Howler.ctx.currentTime,.1)):a.ctx.listener.setOrientation(r,e,t,o,i,s);else return c;return a},Howl.prototype.init=function(r){return function(e){var t=this;return t._orientation=e.orientation||[1,0,0],t._stereo=e.stereo||null,t._pos=e.pos||null,t._pannerAttr={coneInnerAngle:typeof e.coneInnerAngle<"u"?e.coneInnerAngle:360,coneOuterAngle:typeof e.coneOuterAngle<"u"?e.coneOuterAngle:360,coneOuterGain:typeof e.coneOuterGain<"u"?e.coneOuterGain:0,distanceModel:typeof e.distanceModel<"u"?e.distanceModel:"inverse",maxDistance:typeof e.maxDistance<"u"?e.maxDistance:1e4,panningModel:typeof e.panningModel<"u"?e.panningModel:"HRTF",refDistance:typeof e.refDistance<"u"?e.refDistance:1,rolloffFactor:typeof e.rolloffFactor<"u"?e.rolloffFactor:1},t._onstereo=e.onstereo?[{fn:e.onstereo}]:[],t._onpos=e.onpos?[{fn:e.onpos}]:[],t._onorientation=e.onorientation?[{fn:e.onorientation}]:[],r.call(this,e)}}(Howl.prototype.init),Howl.prototype.stereo=function(r,e){var t=this;if(!t._webAudio)return t;if(t._state!=="loaded")return t._queue.push({event:"stereo",action:function(){t.stereo(r,e)}}),t;var o=typeof Howler.ctx.createStereoPanner>"u"?"spatial":"stereo";if(typeof e>"u")if(typeof r=="number")t._stereo=r,t._pos=[r,0,0];else return t._stereo;for(var i=t._getSoundIds(e),s=0;s<i.length;s++){var a=t._soundById(i[s]);if(a)if(typeof r=="number")a._stereo=r,a._pos=[r,0,0],a._node&&(a._pannerAttr.panningModel="equalpower",(!a._panner||!a._panner.pan)&&n(a,o),o==="spatial"?typeof a._panner.positionX<"u"?(a._panner.positionX.setValueAtTime(r,Howler.ctx.currentTime),a._panner.positionY.setValueAtTime(0,Howler.ctx.currentTime),a._panner.positionZ.setValueAtTime(0,Howler.ctx.currentTime)):a._panner.setPosition(r,0,0):a._panner.pan.setValueAtTime(r,Howler.ctx.currentTime)),t._emit("stereo",a._id);else return a._stereo}return t},Howl.prototype.pos=function(r,e,t,o){var i=this;if(!i._webAudio)return i;if(i._state!=="loaded")return i._queue.push({event:"pos",action:function(){i.pos(r,e,t,o)}}),i;if(e=typeof e!="number"?0:e,t=typeof t!="number"?-.5:t,typeof o>"u")if(typeof r=="number")i._pos=[r,e,t];else return i._pos;for(var s=i._getSoundIds(o),a=0;a<s.length;a++){var c=i._soundById(s[a]);if(c)if(typeof r=="number")c._pos=[r,e,t],c._node&&((!c._panner||c._panner.pan)&&n(c,"spatial"),typeof c._panner.positionX<"u"?(c._panner.positionX.setValueAtTime(r,Howler.ctx.currentTime),c._panner.positionY.setValueAtTime(e,Howler.ctx.currentTime),c._panner.positionZ.setValueAtTime(t,Howler.ctx.currentTime)):c._panner.setPosition(r,e,t)),i._emit("pos",c._id);else return c._pos}return i},Howl.prototype.orientation=function(r,e,t,o){var i=this;if(!i._webAudio)return i;if(i._state!=="loaded")return i._queue.push({event:"orientation",action:function(){i.orientation(r,e,t,o)}}),i;if(e=typeof e!="number"?i._orientation[1]:e,t=typeof t!="number"?i._orientation[2]:t,typeof o>"u")if(typeof r=="number")i._orientation=[r,e,t];else return i._orientation;for(var s=i._getSoundIds(o),a=0;a<s.length;a++){var c=i._soundById(s[a]);if(c)if(typeof r=="number")c._orientation=[r,e,t],c._node&&(c._panner||(c._pos||(c._pos=i._pos||[0,0,-.5]),n(c,"spatial")),typeof c._panner.orientationX<"u"?(c._panner.orientationX.setValueAtTime(r,Howler.ctx.currentTime),c._panner.orientationY.setValueAtTime(e,Howler.ctx.currentTime),c._panner.orientationZ.setValueAtTime(t,Howler.ctx.currentTime)):c._panner.setOrientation(r,e,t)),i._emit("orientation",c._id);else return c._orientation}return i},Howl.prototype.pannerAttr=function(){var r=this,e=arguments,t,o,i;if(!r._webAudio)return r;if(e.length===0)return r._pannerAttr;if(e.length===1)if(typeof e[0]=="object")t=e[0],typeof o>"u"&&(t.pannerAttr||(t.pannerAttr={coneInnerAngle:t.coneInnerAngle,coneOuterAngle:t.coneOuterAngle,coneOuterGain:t.coneOuterGain,distanceModel:t.distanceModel,maxDistance:t.maxDistance,refDistance:t.refDistance,rolloffFactor:t.rolloffFactor,panningModel:t.panningModel}),r._pannerAttr={coneInnerAngle:typeof t.pannerAttr.coneInnerAngle<"u"?t.pannerAttr.coneInnerAngle:r._coneInnerAngle,coneOuterAngle:typeof t.pannerAttr.coneOuterAngle<"u"?t.pannerAttr.coneOuterAngle:r._coneOuterAngle,coneOuterGain:typeof t.pannerAttr.coneOuterGain<"u"?t.pannerAttr.coneOuterGain:r._coneOuterGain,distanceModel:typeof t.pannerAttr.distanceModel<"u"?t.pannerAttr.distanceModel:r._distanceModel,maxDistance:typeof t.pannerAttr.maxDistance<"u"?t.pannerAttr.maxDistance:r._maxDistance,refDistance:typeof t.pannerAttr.refDistance<"u"?t.pannerAttr.refDistance:r._refDistance,rolloffFactor:typeof t.pannerAttr.rolloffFactor<"u"?t.pannerAttr.rolloffFactor:r._rolloffFactor,panningModel:typeof t.pannerAttr.panningModel<"u"?t.pannerAttr.panningModel:r._panningModel});else return i=r._soundById(parseInt(e[0],10)),i?i._pannerAttr:r._pannerAttr;else e.length===2&&(t=e[0],o=parseInt(e[1],10));for(var s=r._getSoundIds(o),a=0;a<s.length;a++)if(i=r._soundById(s[a]),i){var c=i._pannerAttr;c={coneInnerAngle:typeof t.coneInnerAngle<"u"?t.coneInnerAngle:c.coneInnerAngle,coneOuterAngle:typeof t.coneOuterAngle<"u"?t.coneOuterAngle:c.coneOuterAngle,coneOuterGain:typeof t.coneOuterGain<"u"?t.coneOuterGain:c.coneOuterGain,distanceModel:typeof t.distanceModel<"u"?t.distanceModel:c.distanceModel,maxDistance:typeof t.maxDistance<"u"?t.maxDistance:c.maxDistance,refDistance:typeof t.refDistance<"u"?t.refDistance:c.refDistance,rolloffFactor:typeof t.rolloffFactor<"u"?t.rolloffFactor:c.rolloffFactor,panningModel:typeof t.panningModel<"u"?t.panningModel:c.panningModel};var d=i._panner;d?(d.coneInnerAngle=c.coneInnerAngle,d.coneOuterAngle=c.coneOuterAngle,d.coneOuterGain=c.coneOuterGain,d.distanceModel=c.distanceModel,d.maxDistance=c.maxDistance,d.refDistance=c.refDistance,d.rolloffFactor=c.rolloffFactor,d.panningModel=c.panningModel):(i._pos||(i._pos=r._pos||[0,0,-.5]),n(i,"spatial"))}return r},Sound.prototype.init=function(r){return function(){var e=this,t=e._parent;e._orientation=t._orientation,e._stereo=t._stereo,e._pos=t._pos,e._pannerAttr=t._pannerAttr,r.call(this),e._stereo?t.stereo(e._stereo):e._pos&&t.pos(e._pos[0],e._pos[1],e._pos[2],e._id)}}(Sound.prototype.init),Sound.prototype.reset=function(r){return function(){var e=this,t=e._parent;return e._orientation=t._orientation,e._stereo=t._stereo,e._pos=t._pos,e._pannerAttr=t._pannerAttr,e._stereo?t.stereo(e._stereo):e._pos?t.pos(e._pos[0],e._pos[1],e._pos[2],e._id):e._panner&&(e._panner.disconnect(0),e._panner=void 0,t._refreshBuffer(e)),r.call(this)}}(Sound.prototype.reset);var n=function(r,e){e=e||"spatial",e==="spatial"?(r._panner=Howler.ctx.createPanner(),r._panner.coneInnerAngle=r._pannerAttr.coneInnerAngle,r._panner.coneOuterAngle=r._pannerAttr.coneOuterAngle,r._panner.coneOuterGain=r._pannerAttr.coneOuterGain,r._panner.distanceModel=r._pannerAttr.distanceModel,r._panner.maxDistance=r._pannerAttr.maxDistance,r._panner.refDistance=r._pannerAttr.refDistance,r._panner.rolloffFactor=r._pannerAttr.rolloffFactor,r._panner.panningModel=r._pannerAttr.panningModel,typeof r._panner.positionX<"u"?(r._panner.positionX.setValueAtTime(r._pos[0],Howler.ctx.currentTime),r._panner.positionY.setValueAtTime(r._pos[1],Howler.ctx.currentTime),r._panner.positionZ.setValueAtTime(r._pos[2],Howler.ctx.currentTime)):r._panner.setPosition(r._pos[0],r._pos[1],r._pos[2]),typeof r._panner.orientationX<"u"?(r._panner.orientationX.setValueAtTime(r._orientation[0],Howler.ctx.currentTime),r._panner.orientationY.setValueAtTime(r._orientation[1],Howler.ctx.currentTime),r._panner.orientationZ.setValueAtTime(r._orientation[2],Howler.ctx.currentTime)):r._panner.setOrientation(r._orientation[0],r._orientation[1],r._orientation[2])):(r._panner=Howler.ctx.createStereoPanner(),r._panner.pan.setValueAtTime(r._stereo,Howler.ctx.currentTime)),r._panner.connect(r._node),r._paused||r._parent.pause(r._id,!0).play(r._id,!0)}})()});var B0=En((bX,D0)=>{D0.exports=function(r,e){for(var t=r.split("."),o=e.split("."),i=0;i<3;i++){var s=Number(t[i]),a=Number(o[i]);if(s>a)return 1;if(a>s)return-1;if(!isNaN(s)&&isNaN(a))return 1;if(isNaN(s)&&!isNaN(a))return-1}return 0}});var SO={};Yd(SO,{default:()=>Fc});module.exports=Z0(SO);var kc=require("three");function Kd(n){for(let r of Object.keys(n))n[r]===void 0&&delete n[r];return n}function br(n,r){return Object.setPrototypeOf(n,r),n}function La(n){return Array.isArray(n)?n:[n]}function Zd(n,r){let e=0;for(;e<n.length&&e<r.length;){if(n[e]<r[e])return-1;if(n[e]>r[e])return 1;e+=1}return e!==r.length?-1:e!==n.length?1:0}var Q0=typeof global=="object"&&global&&global.Object===Object&&global,Da=Q0;var J0=typeof self=="object"&&self&&self.Object===Object&&self,ex=Da||J0||Function("return this")(),ct=ex;var tx=ct.Symbol,vt=tx;var Qd=Object.prototype,rx=Qd.hasOwnProperty,ox=Qd.toString,Os=vt?vt.toStringTag:void 0;function nx(n){var r=rx.call(n,Os),e=n[Os];try{n[Os]=void 0;var t=!0}catch{}var o=ox.call(n);return t&&(r?n[Os]=e:delete n[Os]),o}var Jd=nx;var ix=Object.prototype,sx=ix.toString;function ax(n){return sx.call(n)}var ep=ax;var lx="[object Null]",cx="[object Undefined]",tp=vt?vt.toStringTag:void 0;function ux(n){return n==null?n===void 0?cx:lx:tp&&tp in Object(n)?Jd(n):ep(n)}var or=ux;function dx(n){return n!=null&&typeof n=="object"}var At=dx;var px="[object Symbol]";function fx(n){return typeof n=="symbol"||At(n)&&or(n)==px}var Ln=fx;function mx(n,r){for(var e=-1,t=n==null?0:n.length,o=Array(t);++e<t;)o[e]=r(n[e],e,n);return o}var Ba=mx;var hx=Array.isArray,tt=hx;var yx=1/0,rp=vt?vt.prototype:void 0,op=rp?rp.toString:void 0;function np(n){if(typeof n=="string")return n;if(tt(n))return Ba(n,np)+"";if(Ln(n))return op?op.call(n):"";var r=n+"";return r=="0"&&1/n==-yx?"-0":r}var ip=np;function gx(n){var r=typeof n;return n!=null&&(r=="object"||r=="function")}var nr=gx;function xx(n){return n}var sp=xx;var vx="[object AsyncFunction]",bx="[object Function]",Sx="[object GeneratorFunction]",wx="[object Proxy]";function _x(n){if(!nr(n))return!1;var r=or(n);return r==bx||r==Sx||r==vx||r==wx}var Ra=_x;var Px=ct["__core-js_shared__"],Ga=Px;var ap=function(){var n=/[^.]+$/.exec(Ga&&Ga.keys&&Ga.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}();function Tx(n){return!!ap&&ap in n}var lp=Tx;var Ox=Function.prototype,Ax=Ox.toString;function Cx(n){if(n!=null){try{return Ax.call(n)}catch{}try{return n+""}catch{}}return""}var so=Cx;var Nx=/[\\^$.*+?()[\]{}|]/g,Ix=/^\[object .+?Constructor\]$/,Mx=Function.prototype,Ex=Object.prototype,Lx=Mx.toString,Dx=Ex.hasOwnProperty,Bx=RegExp("^"+Lx.call(Dx).replace(Nx,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Rx(n){if(!nr(n)||lp(n))return!1;var r=Ra(n)?Bx:Ix;return r.test(so(n))}var cp=Rx;function Gx(n,r){return n?.[r]}var up=Gx;function Vx(n,r){var e=up(n,r);return cp(e)?e:void 0}var $t=Vx;var zx=$t(ct,"WeakMap"),Va=zx;var dp=Object.create,jx=function(){function n(){}return function(r){if(!nr(r))return{};if(dp)return dp(r);n.prototype=r;var e=new n;return n.prototype=void 0,e}}(),pp=jx;function Fx(n,r,e){switch(e.length){case 0:return n.call(r);case 1:return n.call(r,e[0]);case 2:return n.call(r,e[0],e[1]);case 3:return n.call(r,e[0],e[1],e[2])}return n.apply(r,e)}var fp=Fx;function kx(n,r){var e=-1,t=n.length;for(r||(r=Array(t));++e<t;)r[e]=n[e];return r}var mp=kx;var Ux=800,Hx=16,Wx=Date.now;function qx(n){var r=0,e=0;return function(){var t=Wx(),o=Hx-(t-e);if(e=t,o>0){if(++r>=Ux)return arguments[0]}else r=0;return n.apply(void 0,arguments)}}var hp=qx;function $x(n){return function(){return n}}var yp=$x;var Yx=function(){try{var n=$t(Object,"defineProperty");return n({},"",{}),n}catch{}}(),Dn=Yx;var Xx=Dn?function(n,r){return Dn(n,"toString",{configurable:!0,enumerable:!1,value:yp(r),writable:!0})}:sp,gp=Xx;var Kx=hp(gp),xp=Kx;function Zx(n,r){for(var e=-1,t=n==null?0:n.length;++e<t&&r(n[e],e,n)!==!1;);return n}var vp=Zx;var Qx=9007199254740991,Jx=/^(?:0|[1-9]\d*)$/;function ev(n,r){var e=typeof n;return r=r??Qx,!!r&&(e=="number"||e!="symbol"&&Jx.test(n))&&n>-1&&n%1==0&&n<r}var Bn=ev;function tv(n,r,e){r=="__proto__"&&Dn?Dn(n,r,{configurable:!0,enumerable:!0,value:e,writable:!0}):n[r]=e}var za=tv;function rv(n,r){return n===r||n!==n&&r!==r}var Rn=rv;var ov=Object.prototype,nv=ov.hasOwnProperty;function iv(n,r,e){var t=n[r];(!(nv.call(n,r)&&Rn(t,e))||e===void 0&&!(r in n))&&za(n,r,e)}var Gn=iv;function sv(n,r,e,t){var o=!e;e||(e={});for(var i=-1,s=r.length;++i<s;){var a=r[i],c=t?t(e[a],n[a],a,e,n):void 0;c===void 0&&(c=n[a]),o?za(e,a,c):Gn(e,a,c)}return e}var Br=sv;var bp=Math.max;function av(n,r,e){return r=bp(r===void 0?n.length-1:r,0),function(){for(var t=arguments,o=-1,i=bp(t.length-r,0),s=Array(i);++o<i;)s[o]=t[r+o];o=-1;for(var a=Array(r+1);++o<r;)a[o]=t[o];return a[r]=e(s),fp(n,this,a)}}var Sp=av;var lv=9007199254740991;function cv(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=lv}var Vn=cv;function uv(n){return n!=null&&Vn(n.length)&&!Ra(n)}var ja=uv;var dv=Object.prototype;function pv(n){var r=n&&n.constructor,e=typeof r=="function"&&r.prototype||dv;return n===e}var zn=pv;function fv(n,r){for(var e=-1,t=Array(n);++e<n;)t[e]=r(e);return t}var wp=fv;var mv="[object Arguments]";function hv(n){return At(n)&&or(n)==mv}var Hc=hv;var _p=Object.prototype,yv=_p.hasOwnProperty,gv=_p.propertyIsEnumerable,xv=Hc(function(){return arguments}())?Hc:function(n){return At(n)&&yv.call(n,"callee")&&!gv.call(n,"callee")},jn=xv;function vv(){return!1}var Pp=vv;var Ap=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Tp=Ap&&typeof module=="object"&&module&&!module.nodeType&&module,bv=Tp&&Tp.exports===Ap,Op=bv?ct.Buffer:void 0,Sv=Op?Op.isBuffer:void 0,wv=Sv||Pp,tn=wv;var _v="[object Arguments]",Pv="[object Array]",Tv="[object Boolean]",Ov="[object Date]",Av="[object Error]",Cv="[object Function]",Nv="[object Map]",Iv="[object Number]",Mv="[object Object]",Ev="[object RegExp]",Lv="[object Set]",Dv="[object String]",Bv="[object WeakMap]",Rv="[object ArrayBuffer]",Gv="[object DataView]",Vv="[object Float32Array]",zv="[object Float64Array]",jv="[object Int8Array]",Fv="[object Int16Array]",kv="[object Int32Array]",Uv="[object Uint8Array]",Hv="[object Uint8ClampedArray]",Wv="[object Uint16Array]",qv="[object Uint32Array]",Ye={};Ye[Vv]=Ye[zv]=Ye[jv]=Ye[Fv]=Ye[kv]=Ye[Uv]=Ye[Hv]=Ye[Wv]=Ye[qv]=!0;Ye[_v]=Ye[Pv]=Ye[Rv]=Ye[Tv]=Ye[Gv]=Ye[Ov]=Ye[Av]=Ye[Cv]=Ye[Nv]=Ye[Iv]=Ye[Mv]=Ye[Ev]=Ye[Lv]=Ye[Dv]=Ye[Bv]=!1;function $v(n){return At(n)&&Vn(n.length)&&!!Ye[or(n)]}var Cp=$v;function Yv(n){return function(r){return n(r)}}var Fn=Yv;var Np=typeof exports=="object"&&exports&&!exports.nodeType&&exports,As=Np&&typeof module=="object"&&module&&!module.nodeType&&module,Xv=As&&As.exports===Np,Wc=Xv&&Da.process,Kv=function(){try{var n=As&&As.require&&As.require("util").types;return n||Wc&&Wc.binding&&Wc.binding("util")}catch{}}(),ao=Kv;var Ip=ao&&ao.isTypedArray,Zv=Ip?Fn(Ip):Cp,Fa=Zv;var Qv=Object.prototype,Jv=Qv.hasOwnProperty;function eb(n,r){var e=tt(n),t=!e&&jn(n),o=!e&&!t&&tn(n),i=!e&&!t&&!o&&Fa(n),s=e||t||o||i,a=s?wp(n.length,String):[],c=a.length;for(var d in n)(r||Jv.call(n,d))&&!(s&&(d=="length"||o&&(d=="offset"||d=="parent")||i&&(d=="buffer"||d=="byteLength"||d=="byteOffset")||Bn(d,c)))&&a.push(d);return a}var ka=eb;function tb(n,r){return function(e){return n(r(e))}}var Ua=tb;var rb=Ua(Object.keys,Object),Mp=rb;var ob=Object.prototype,nb=ob.hasOwnProperty;function ib(n){if(!zn(n))return Mp(n);var r=[];for(var e in Object(n))nb.call(n,e)&&e!="constructor"&&r.push(e);return r}var Ep=ib;function sb(n){return ja(n)?ka(n):Ep(n)}var kn=sb;function ab(n){var r=[];if(n!=null)for(var e in Object(n))r.push(e);return r}var Lp=ab;var lb=Object.prototype,cb=lb.hasOwnProperty;function ub(n){if(!nr(n))return Lp(n);var r=zn(n),e=[];for(var t in n)t=="constructor"&&(r||!cb.call(n,t))||e.push(t);return e}var Dp=ub;function db(n){return ja(n)?ka(n,!0):Dp(n)}var Un=db;var pb=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,fb=/^\w*$/;function mb(n,r){if(tt(n))return!1;var e=typeof n;return e=="number"||e=="symbol"||e=="boolean"||n==null||Ln(n)?!0:fb.test(n)||!pb.test(n)||r!=null&&n in Object(r)}var Bp=mb;var hb=$t(Object,"create"),lo=hb;function yb(){this.__data__=lo?lo(null):{},this.size=0}var Rp=yb;function gb(n){var r=this.has(n)&&delete this.__data__[n];return this.size-=r?1:0,r}var Gp=gb;var xb="__lodash_hash_undefined__",vb=Object.prototype,bb=vb.hasOwnProperty;function Sb(n){var r=this.__data__;if(lo){var e=r[n];return e===xb?void 0:e}return bb.call(r,n)?r[n]:void 0}var Vp=Sb;var wb=Object.prototype,_b=wb.hasOwnProperty;function Pb(n){var r=this.__data__;return lo?r[n]!==void 0:_b.call(r,n)}var zp=Pb;var Tb="__lodash_hash_undefined__";function Ob(n,r){var e=this.__data__;return this.size+=this.has(n)?0:1,e[n]=lo&&r===void 0?Tb:r,this}var jp=Ob;function Hn(n){var r=-1,e=n==null?0:n.length;for(this.clear();++r<e;){var t=n[r];this.set(t[0],t[1])}}Hn.prototype.clear=Rp;Hn.prototype.delete=Gp;Hn.prototype.get=Vp;Hn.prototype.has=zp;Hn.prototype.set=jp;var qc=Hn;function Ab(){this.__data__=[],this.size=0}var Fp=Ab;function Cb(n,r){for(var e=n.length;e--;)if(Rn(n[e][0],r))return e;return-1}var Po=Cb;var Nb=Array.prototype,Ib=Nb.splice;function Mb(n){var r=this.__data__,e=Po(r,n);if(e<0)return!1;var t=r.length-1;return e==t?r.pop():Ib.call(r,e,1),--this.size,!0}var kp=Mb;function Eb(n){var r=this.__data__,e=Po(r,n);return e<0?void 0:r[e][1]}var Up=Eb;function Lb(n){return Po(this.__data__,n)>-1}var Hp=Lb;function Db(n,r){var e=this.__data__,t=Po(e,n);return t<0?(++this.size,e.push([n,r])):e[t][1]=r,this}var Wp=Db;function Wn(n){var r=-1,e=n==null?0:n.length;for(this.clear();++r<e;){var t=n[r];this.set(t[0],t[1])}}Wn.prototype.clear=Fp;Wn.prototype.delete=kp;Wn.prototype.get=Up;Wn.prototype.has=Hp;Wn.prototype.set=Wp;var To=Wn;var Bb=$t(ct,"Map"),Oo=Bb;function Rb(){this.size=0,this.__data__={hash:new qc,map:new(Oo||To),string:new qc}}var qp=Rb;function Gb(n){var r=typeof n;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?n!=="__proto__":n===null}var $p=Gb;function Vb(n,r){var e=n.__data__;return $p(r)?e[typeof r=="string"?"string":"hash"]:e.map}var Ao=Vb;function zb(n){var r=Ao(this,n).delete(n);return this.size-=r?1:0,r}var Yp=zb;function jb(n){return Ao(this,n).get(n)}var Xp=jb;function Fb(n){return Ao(this,n).has(n)}var Kp=Fb;function kb(n,r){var e=Ao(this,n),t=e.size;return e.set(n,r),this.size+=e.size==t?0:1,this}var Zp=kb;function qn(n){var r=-1,e=n==null?0:n.length;for(this.clear();++r<e;){var t=n[r];this.set(t[0],t[1])}}qn.prototype.clear=qp;qn.prototype.delete=Yp;qn.prototype.get=Xp;qn.prototype.has=Kp;qn.prototype.set=Zp;var rn=qn;var Ub="Expected a function";function $c(n,r){if(typeof n!="function"||r!=null&&typeof r!="function")throw new TypeError(Ub);var e=function(){var t=arguments,o=r?r.apply(this,t):t[0],i=e.cache;if(i.has(o))return i.get(o);var s=n.apply(this,t);return e.cache=i.set(o,s)||i,s};return e.cache=new($c.Cache||rn),e}$c.Cache=rn;var Qp=$c;var Hb=500;function Wb(n){var r=Qp(n,function(t){return e.size===Hb&&e.clear(),t}),e=r.cache;return r}var Jp=Wb;var qb=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,$b=/\\(\\)?/g,Yb=Jp(function(n){var r=[];return n.charCodeAt(0)===46&&r.push(""),n.replace(qb,function(e,t,o,i){r.push(o?i.replace($b,"$1"):t||e)}),r}),ef=Yb;function Xb(n){return n==null?"":ip(n)}var tf=Xb;function Kb(n,r){return tt(n)?n:Bp(n,r)?[n]:ef(tf(n))}var ur=Kb;var Zb=1/0;function Qb(n){if(typeof n=="string"||Ln(n))return n;var r=n+"";return r=="0"&&1/n==-Zb?"-0":r}var Co=Qb;function Jb(n,r){r=ur(r,n);for(var e=0,t=r.length;n!=null&&e<t;)n=n[Co(r[e++])];return e&&e==t?n:void 0}var Ha=Jb;function eS(n,r){for(var e=-1,t=r.length,o=n.length;++e<t;)n[o+e]=r[e];return n}var $n=eS;var rf=vt?vt.isConcatSpreadable:void 0;function tS(n){return tt(n)||jn(n)||!!(rf&&n&&n[rf])}var of=tS;function nf(n,r,e,t,o){var i=-1,s=n.length;for(e||(e=of),o||(o=[]);++i<s;){var a=n[i];r>0&&e(a)?r>1?nf(a,r-1,e,t,o):$n(o,a):t||(o[o.length]=a)}return o}var sf=nf;function rS(n){var r=n==null?0:n.length;return r?sf(n,1):[]}var af=rS;function oS(n){return xp(Sp(n,void 0,af),n+"")}var Wa=oS;var nS=Ua(Object.getPrototypeOf,Object),Yn=nS;var iS="[object Object]",sS=Function.prototype,aS=Object.prototype,lf=sS.toString,lS=aS.hasOwnProperty,cS=lf.call(Object);function uS(n){if(!At(n)||or(n)!=iS)return!1;var r=Yn(n);if(r===null)return!0;var e=lS.call(r,"constructor")&&r.constructor;return typeof e=="function"&&e instanceof e&&lf.call(e)==cS}var cf=uS;function dS(n,r,e){var t=-1,o=n.length;r<0&&(r=-r>o?0:o+r),e=e>o?o:e,e<0&&(e+=o),o=r>e?0:e-r>>>0,r>>>=0;for(var i=Array(o);++t<o;)i[t]=n[t+r];return i}var uf=dS;function pS(){this.__data__=new To,this.size=0}var df=pS;function fS(n){var r=this.__data__,e=r.delete(n);return this.size=r.size,e}var pf=fS;function mS(n){return this.__data__.get(n)}var ff=mS;function hS(n){return this.__data__.has(n)}var mf=hS;var yS=200;function gS(n,r){var e=this.__data__;if(e instanceof To){var t=e.__data__;if(!Oo||t.length<yS-1)return t.push([n,r]),this.size=++e.size,this;e=this.__data__=new rn(t)}return e.set(n,r),this.size=e.size,this}var hf=gS;function Xn(n){var r=this.__data__=new To(n);this.size=r.size}Xn.prototype.clear=df;Xn.prototype.delete=pf;Xn.prototype.get=ff;Xn.prototype.has=mf;Xn.prototype.set=hf;var Kn=Xn;function xS(n,r){return n&&Br(r,kn(r),n)}var yf=xS;function vS(n,r){return n&&Br(r,Un(r),n)}var gf=vS;var Sf=typeof exports=="object"&&exports&&!exports.nodeType&&exports,xf=Sf&&typeof module=="object"&&module&&!module.nodeType&&module,bS=xf&&xf.exports===Sf,vf=bS?ct.Buffer:void 0,bf=vf?vf.allocUnsafe:void 0;function SS(n,r){if(r)return n.slice();var e=n.length,t=bf?bf(e):new n.constructor(e);return n.copy(t),t}var wf=SS;function wS(n,r){for(var e=-1,t=n==null?0:n.length,o=0,i=[];++e<t;){var s=n[e];r(s,e,n)&&(i[o++]=s)}return i}var _f=wS;function _S(){return[]}var qa=_S;var PS=Object.prototype,TS=PS.propertyIsEnumerable,Pf=Object.getOwnPropertySymbols,OS=Pf?function(n){return n==null?[]:(n=Object(n),_f(Pf(n),function(r){return TS.call(n,r)}))}:qa,Zn=OS;function AS(n,r){return Br(n,Zn(n),r)}var Tf=AS;var CS=Object.getOwnPropertySymbols,NS=CS?function(n){for(var r=[];n;)$n(r,Zn(n)),n=Yn(n);return r}:qa,$a=NS;function IS(n,r){return Br(n,$a(n),r)}var Of=IS;function MS(n,r,e){var t=r(n);return tt(n)?t:$n(t,e(n))}var Ya=MS;function ES(n){return Ya(n,kn,Zn)}var Cs=ES;function LS(n){return Ya(n,Un,$a)}var Xa=LS;var DS=$t(ct,"DataView"),Ka=DS;var BS=$t(ct,"Promise"),Za=BS;var RS=$t(ct,"Set"),Qa=RS;var Af="[object Map]",GS="[object Object]",Cf="[object Promise]",Nf="[object Set]",If="[object WeakMap]",Mf="[object DataView]",VS=so(Ka),zS=so(Oo),jS=so(Za),FS=so(Qa),kS=so(Va),on=or;(Ka&&on(new Ka(new ArrayBuffer(1)))!=Mf||Oo&&on(new Oo)!=Af||Za&&on(Za.resolve())!=Cf||Qa&&on(new Qa)!=Nf||Va&&on(new Va)!=If)&&(on=function(n){var r=or(n),e=r==GS?n.constructor:void 0,t=e?so(e):"";if(t)switch(t){case VS:return Mf;case zS:return Af;case jS:return Cf;case FS:return Nf;case kS:return If}return r});var co=on;var US=Object.prototype,HS=US.hasOwnProperty;function WS(n){var r=n.length,e=new n.constructor(r);return r&&typeof n[0]=="string"&&HS.call(n,"index")&&(e.index=n.index,e.input=n.input),e}var Ef=WS;var qS=ct.Uint8Array,Qn=qS;function $S(n){var r=new n.constructor(n.byteLength);return new Qn(r).set(new Qn(n)),r}var Jn=$S;function YS(n,r){var e=r?Jn(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.byteLength)}var Lf=YS;var XS=/\w*$/;function KS(n){var r=new n.constructor(n.source,XS.exec(n));return r.lastIndex=n.lastIndex,r}var Df=KS;var Bf=vt?vt.prototype:void 0,Rf=Bf?Bf.valueOf:void 0;function ZS(n){return Rf?Object(Rf.call(n)):{}}var Gf=ZS;function QS(n,r){var e=r?Jn(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.length)}var Vf=QS;var JS="[object Boolean]",ew="[object Date]",tw="[object Map]",rw="[object Number]",ow="[object RegExp]",nw="[object Set]",iw="[object String]",sw="[object Symbol]",aw="[object ArrayBuffer]",lw="[object DataView]",cw="[object Float32Array]",uw="[object Float64Array]",dw="[object Int8Array]",pw="[object Int16Array]",fw="[object Int32Array]",mw="[object Uint8Array]",hw="[object Uint8ClampedArray]",yw="[object Uint16Array]",gw="[object Uint32Array]";function xw(n,r,e){var t=n.constructor;switch(r){case aw:return Jn(n);case JS:case ew:return new t(+n);case lw:return Lf(n,e);case cw:case uw:case dw:case pw:case fw:case mw:case hw:case yw:case gw:return Vf(n,e);case tw:return new t;case rw:case iw:return new t(n);case ow:return Df(n);case nw:return new t;case sw:return Gf(n)}}var zf=xw;function vw(n){return typeof n.constructor=="function"&&!zn(n)?pp(Yn(n)):{}}var jf=vw;var bw="[object Map]";function Sw(n){return At(n)&&co(n)==bw}var Ff=Sw;var kf=ao&&ao.isMap,ww=kf?Fn(kf):Ff,Uf=ww;var _w="[object Set]";function Pw(n){return At(n)&&co(n)==_w}var Hf=Pw;var Wf=ao&&ao.isSet,Tw=Wf?Fn(Wf):Hf,qf=Tw;var Ow=1,Aw=2,Cw=4,$f="[object Arguments]",Nw="[object Array]",Iw="[object Boolean]",Mw="[object Date]",Ew="[object Error]",Yf="[object Function]",Lw="[object GeneratorFunction]",Dw="[object Map]",Bw="[object Number]",Xf="[object Object]",Rw="[object RegExp]",Gw="[object Set]",Vw="[object String]",zw="[object Symbol]",jw="[object WeakMap]",Fw="[object ArrayBuffer]",kw="[object DataView]",Uw="[object Float32Array]",Hw="[object Float64Array]",Ww="[object Int8Array]",qw="[object Int16Array]",$w="[object Int32Array]",Yw="[object Uint8Array]",Xw="[object Uint8ClampedArray]",Kw="[object Uint16Array]",Zw="[object Uint32Array]",We={};We[$f]=We[Nw]=We[Fw]=We[kw]=We[Iw]=We[Mw]=We[Uw]=We[Hw]=We[Ww]=We[qw]=We[$w]=We[Dw]=We[Bw]=We[Xf]=We[Rw]=We[Gw]=We[Vw]=We[zw]=We[Yw]=We[Xw]=We[Kw]=We[Zw]=!0;We[Ew]=We[Yf]=We[jw]=!1;function Ja(n,r,e,t,o,i){var s,a=r&Ow,c=r&Aw,d=r&Cw;if(e&&(s=o?e(n,t,o,i):e(n)),s!==void 0)return s;if(!nr(n))return n;var l=tt(n);if(l){if(s=Ef(n),!a)return mp(n,s)}else{var u=co(n),p=u==Yf||u==Lw;if(tn(n))return wf(n,a);if(u==Xf||u==$f||p&&!o){if(s=c||p?{}:jf(n),!a)return c?Of(n,gf(s,n)):Tf(n,yf(s,n))}else{if(!We[u])return o?n:{};s=zf(n,u,a)}}i||(i=new Kn);var f=i.get(n);if(f)return f;i.set(n,s),qf(n)?n.forEach(function(y){s.add(Ja(y,r,e,y,n,i))}):Uf(n)&&n.forEach(function(y,g){s.set(g,Ja(y,r,e,g,n,i))});var m=d?c?Xa:Cs:c?Un:kn,h=l?void 0:m(n);return vp(h||n,function(y,g){h&&(g=y,y=n[g]),Gn(s,g,Ja(y,r,e,g,n,i))}),s}var el=Ja;var Qw=1,Jw=4;function e1(n){return el(n,Qw|Jw)}var uo=e1;var t1="__lodash_hash_undefined__";function r1(n){return this.__data__.set(n,t1),this}var Kf=r1;function o1(n){return this.__data__.has(n)}var Zf=o1;function tl(n){var r=-1,e=n==null?0:n.length;for(this.__data__=new rn;++r<e;)this.add(n[r])}tl.prototype.add=tl.prototype.push=Kf;tl.prototype.has=Zf;var Qf=tl;function n1(n,r){for(var e=-1,t=n==null?0:n.length;++e<t;)if(r(n[e],e,n))return!0;return!1}var Jf=n1;function i1(n,r){return n.has(r)}var em=i1;var s1=1,a1=2;function l1(n,r,e,t,o,i){var s=e&s1,a=n.length,c=r.length;if(a!=c&&!(s&&c>a))return!1;var d=i.get(n),l=i.get(r);if(d&&l)return d==r&&l==n;var u=-1,p=!0,f=e&a1?new Qf:void 0;for(i.set(n,r),i.set(r,n);++u<a;){var m=n[u],h=r[u];if(t)var y=s?t(h,m,u,r,n,i):t(m,h,u,n,r,i);if(y!==void 0){if(y)continue;p=!1;break}if(f){if(!Jf(r,function(g,x){if(!em(f,x)&&(m===g||o(m,g,e,t,i)))return f.push(x)})){p=!1;break}}else if(!(m===h||o(m,h,e,t,i))){p=!1;break}}return i.delete(n),i.delete(r),p}var rl=l1;function c1(n){var r=-1,e=Array(n.size);return n.forEach(function(t,o){e[++r]=[o,t]}),e}var tm=c1;function u1(n){var r=-1,e=Array(n.size);return n.forEach(function(t){e[++r]=t}),e}var rm=u1;var d1=1,p1=2,f1="[object Boolean]",m1="[object Date]",h1="[object Error]",y1="[object Map]",g1="[object Number]",x1="[object RegExp]",v1="[object Set]",b1="[object String]",S1="[object Symbol]",w1="[object ArrayBuffer]",_1="[object DataView]",om=vt?vt.prototype:void 0,Yc=om?om.valueOf:void 0;function P1(n,r,e,t,o,i,s){switch(e){case _1:if(n.byteLength!=r.byteLength||n.byteOffset!=r.byteOffset)return!1;n=n.buffer,r=r.buffer;case w1:return!(n.byteLength!=r.byteLength||!i(new Qn(n),new Qn(r)));case f1:case m1:case g1:return Rn(+n,+r);case h1:return n.name==r.name&&n.message==r.message;case x1:case b1:return n==r+"";case y1:var a=tm;case v1:var c=t&d1;if(a||(a=rm),n.size!=r.size&&!c)return!1;var d=s.get(n);if(d)return d==r;t|=p1,s.set(n,r);var l=rl(a(n),a(r),t,o,i,s);return s.delete(n),l;case S1:if(Yc)return Yc.call(n)==Yc.call(r)}return!1}var nm=P1;var T1=1,O1=Object.prototype,A1=O1.hasOwnProperty;function C1(n,r,e,t,o,i){var s=e&T1,a=Cs(n),c=a.length,d=Cs(r),l=d.length;if(c!=l&&!s)return!1;for(var u=c;u--;){var p=a[u];if(!(s?p in r:A1.call(r,p)))return!1}var f=i.get(n),m=i.get(r);if(f&&m)return f==r&&m==n;var h=!0;i.set(n,r),i.set(r,n);for(var y=s;++u<c;){p=a[u];var g=n[p],x=r[p];if(t)var S=s?t(x,g,p,r,n,i):t(g,x,p,n,r,i);if(!(S===void 0?g===x||o(g,x,e,t,i):S)){h=!1;break}y||(y=p=="constructor")}if(h&&!y){var w=n.constructor,b=r.constructor;w!=b&&"constructor"in n&&"constructor"in r&&!(typeof w=="function"&&w instanceof w&&typeof b=="function"&&b instanceof b)&&(h=!1)}return i.delete(n),i.delete(r),h}var im=C1;var N1=1,sm="[object Arguments]",am="[object Array]",ol="[object Object]",I1=Object.prototype,lm=I1.hasOwnProperty;function M1(n,r,e,t,o,i){var s=tt(n),a=tt(r),c=s?am:co(n),d=a?am:co(r);c=c==sm?ol:c,d=d==sm?ol:d;var l=c==ol,u=d==ol,p=c==d;if(p&&tn(n)){if(!tn(r))return!1;s=!0,l=!1}if(p&&!l)return i||(i=new Kn),s||Fa(n)?rl(n,r,e,t,o,i):nm(n,r,c,e,t,o,i);if(!(e&N1)){var f=l&&lm.call(n,"__wrapped__"),m=u&&lm.call(r,"__wrapped__");if(f||m){var h=f?n.value():n,y=m?r.value():r;return i||(i=new Kn),o(h,y,e,t,i)}}return p?(i||(i=new Kn),im(n,r,e,t,o,i)):!1}var cm=M1;function um(n,r,e,t,o){return n===r?!0:n==null||r==null||!At(n)&&!At(r)?n!==n&&r!==r:cm(n,r,e,t,um,o)}var dm=um;function E1(n,r){return n!=null&&r in Object(n)}var pm=E1;function L1(n,r,e){r=ur(r,n);for(var t=-1,o=r.length,i=!1;++t<o;){var s=Co(r[t]);if(!(i=n!=null&&e(n,s)))break;n=n[s]}return i||++t!=o?i:(o=n==null?0:n.length,!!o&&Vn(o)&&Bn(s,o)&&(tt(n)||jn(n)))}var fm=L1;function D1(n,r){return n!=null&&fm(n,r,pm)}var mm=D1;function B1(n){var r=n==null?0:n.length;return r?n[r-1]:void 0}var hm=B1;function R1(n,r){return r.length<2?n:Ha(n,uf(r,0,-1))}var ym=R1;function G1(n,r){return dm(n,r)}var Ns=G1;function V1(n,r){return r=ur(r,n),n=ym(n,r),n==null||delete n[Co(hm(r))]}var gm=V1;function z1(n){return cf(n)?void 0:n}var xm=z1;var j1=1,F1=2,k1=4,U1=Wa(function(n,r){var e={};if(n==null)return e;var t=!1;r=Ba(r,function(i){return i=ur(i,n),t||(t=i.length>1),i}),Br(n,Xa(n),e),t&&(e=el(e,j1|F1|k1,xm));for(var o=r.length;o--;)gm(e,r[o]);return e}),ei=U1;function H1(n,r,e,t){if(!nr(n))return n;r=ur(r,n);for(var o=-1,i=r.length,s=i-1,a=n;a!=null&&++o<i;){var c=Co(r[o]),d=e;if(c==="__proto__"||c==="constructor"||c==="prototype")return n;if(o!=s){var l=a[c];d=t?t(l,c,a):void 0,d===void 0&&(d=nr(l)?l:Bn(r[o+1])?[]:{})}Gn(a,c,d),a=a[c]}return n}var vm=H1;function W1(n,r,e){for(var t=-1,o=r.length,i={};++t<o;){var s=r[t],a=Ha(n,s);e(a,s)&&vm(i,ur(s,n),a)}return i}var bm=W1;function q1(n,r){return bm(n,r,function(e,t){return mm(n,t)})}var Sm=q1;var $1=Wa(function(n,r){return n==null?{}:Sm(n,r)}),Sr=$1;var Ue=class{modifyById(r,e){let t=this;if(t[r]===void 0)throw new Error("not expected");{let i={...t,[r]:e};return Object.setPrototypeOf(i,Ue.prototype),i}}add(r,e){return this.runOp({type:1,id:r,data:e})?.data??this}runOp(r){let e=this;if(r.type===1){let t=e[r.id],o;t===void 0?o={type:2,id:r.id}:o={type:1,id:r.id,data:t};let{id:i,data:s}=r,a={...e,[i]:s};return Object.setPrototypeOf(a,Ue.prototype),{data:a,actual:r,reverse:o}}else if(r.type===2){let{id:t}=r,o=e[t];if(o===void 0)return null;{let i={...e};return Object.setPrototypeOf(i,Ue.prototype),delete i[t],{data:i,actual:r,reverse:{type:1,id:t,data:o}}}}return null}};function Is(n){if(n.deepFreeze!==void 0){n.deepFreeze(n);return}let r=Object.getOwnPropertyNames(n);for(let e of r){let t=n[e];t&&typeof t=="object"&&Is(t)}return Object.freeze(n)}function wm(n,r){let e=0;for(;e<n.length&&e<r.length;){if(n[e]<r[e])return-1;if(n[e]>r[e])return 1;e+=1}return e!==r.length?-1:e!==n.length?1:0}var ti=class extends Error{};function nl(n){let r={...n};return Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r}function Rr(n,r,e){if(n===void 0?r===void 0?(n=0,r=10):n=r-10:r===void 0&&(r=n+10),n>r){let i=n;n=r,r=i}let t=[],o=1/(e+1);for(let i=0;i<e;i++){let s=n+(r-n)*(i+.75+Math.random()*.5)*o;t.push(s)}return t}function ri(n){return n instanceof Uint8Array||n instanceof Uint16Array||n instanceof Uint32Array||n instanceof Int8Array||n instanceof Int16Array||n instanceof Int32Array||n instanceof Float32Array||n instanceof Float64Array}function _m(){return typeof process<"u"}function Pm(n,r){for(let e of n)r(e.id,e.data)!==!0&&Pm(e.children,r)}function Tm(n,r){if(r(n.id,n.data)!==!0)for(let e of n.children)Tm(e,r)}var Qe=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,Qe.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Is(this[e]),e++}fillCaches0(e,t){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,t);for(let o of e.children)this.fillCaches0(o,e.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let e of this)this.fillCaches0(e,null)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}nonExistOrDescendantOf(e,t){if(!this.has(e))return!0;for(;e;){let o=this.parent(e);if(o===t)return!0;e=o}return!1}rootAcestor(e){for(;e;){let t=this.parent(e);if(t)e=t;else return e}return e}isDescendantOf(e,t){for(;e;){let o=this.parent(e);if(o===t)return!0;e=o}return!1}data(e){return this.get(e)?.data}has(e){return this.childrenOf(e)!==void 0}get(e){return this.fillCaches(),this.objCaches.get(e)}childrenOf(e){return e===null?this:this.get(e)?.children}traverseFrom(e,t){if(e===null)this.traverse(t);else{let o=this.get(e);o&&Tm(o,t)}}traverse(e){Pm(this,e)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(e){return this.fillCaches(),this.parentCaches.get(e)}childrenArray(e){return e===null?this:this.get(e).children}modifyById(e,t){if(this.get(e)===void 0)throw new Error("not expected");{let i=this.parent(e),s=this.childrenArray(i),a=s.findIndex(l=>l.id===e);if(a<0)throw new Error("not expected");let c=s[a];return s=[...s],s[a]={...c,data:t},this.modifyArrayBy(i,s)}}modifyArrayBy(e,t){let o=e,i=t;for(;o!==null;){let a=i,c=o;if(o=this.parent(o),o===void 0)throw new Error;i=this.childrenArray(o);let d=i.findIndex(l=>l.id===c);if(d<0)throw new Error;i=[...i],i[d]={...i[d],children:a}}Object.setPrototypeOf(i,Qe.prototype);let s=i;return s.fillCaches(),s}runOp(e){switch(e.type){case 7:return this.addOp(e);case 8:return this.deleteOp(e);case 9:return this.moveOp(e)}return null}checkDuplicatedIdRec({id:e,children:t}){if(this.get(e)!==void 0)return!0;for(let o of t)if(this.checkDuplicatedIdRec(o))return!0;return!1}addOp(e){let{parent:t,fi:o,id:i,data:s,children:a}=e;if(t!==null&&this.get(t)===void 0)return null;if(this.checkDuplicatedIdRec(e))return null;{let c=t,d=this.childrenArray(c),l={fi:o,id:i,data:s,children:a};return d=[...d,l],d.sort((p,f)=>p.fi-f.fi),e.localIndex=d.indexOf(l),{data:this.modifyArrayBy(c,d),actual:e,reverse:{type:8,id:i}}}}deleteOp(e){let{id:t}=e;if(this.get(t)===null)return null;{let o=this.parent(t);if(o===void 0)return null;let i=this.childrenArray(o),s=i.findIndex(d=>d.id===t);e.localIndex=s,i=[...i];let a=i.splice(s,1)[0];return{data:this.modifyArrayBy(o,i),actual:e,reverse:{type:7,...a,parent:o}}}}moveOp(e){let{parent:t,fi:o,id:i}=e;if(t!==null&&this.get(t)===void 0)return this.deleteOp({type:8,id:i});if(t!==null){let f=t;for(;f!==null;){if(f===void 0)throw new Error;if(f===i)throw new ti("cyclic tree");f=this.parent(f)}}let s=this.parent(i);if(s===void 0)return null;let a=s,c=this.childrenArray(s),d=c.findIndex(f=>f.id===i);c=[...c];let l=c.splice(d,1)[0],u=this.modifyArrayBy(s,c);s=t,c=u.childrenArray(s);let p=l.fi;return l={...l,fi:o},c=[...c,l],c.sort((f,m)=>f.fi-m.fi),e.localIndex=c.indexOf(l),u=u.modifyArrayBy(s,c),{data:u,actual:e,reverse:{type:9,parent:a,fi:p,id:i}}}previous(e,t){if(t===null){let i=this.childrenArray(e);return i.length===0?null:i[i.length-1].id}let o=null;for(let i of this.childrenArray(e)){if(i.id===t)return o;o=i.id}return null}traverseSortNext(e){let t=this.parent(e);if(t!==void 0){let o=this.childrenArray(t),i=o.findIndex(s=>s.id===e)+1;if(i<o.length)return o[i].id;if(t)return this.traverseSortNext(t)}}sortNext(e){let t=this.childrenArray(e);return t.length>0?t[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let t=this.childrenArray(e);return t.length>0?this.traverseSortPrevious(t[t.length-1].id):e}sortPrevious(e){let t=this.parent(e);if(t!==void 0){let o=this.childrenArray(t),i=o.findIndex(s=>s.id===e)-1;return i>=0?this.traverseSortPrevious(o[i].id):t}}getAllSorted(e){let t=[];for(let o of e){let i=this.getWithSortKey(o.id);i!==void 0&&t.push({...o,...i})}t.sort((o,i)=>wm(o.sortKey,i.sortKey));for(let o of t)delete o.sortKey;return t}getWithSortKey(e){var t=e;let o=[],i=this.get(t),s=i;if(i!==void 0){for(;t;)o.splice(0,0,i.fi),t=this.parent(t),t!==null&&(i=this.get(t));return{...s,sortKey:o}}}insertBeforeHelper(e,t,o){return this.insertAfterHelper(e,this.previous(e,t),o)}insertAfterHelper(e,t,o){let i=this.childrenArray(e);if(t===null){if(i.length===0)return Rr(0,o,o);{let s=i[0].fi;return Rr(s-o,s,o)}}else{let s=this.get(t);if(s===void 0||this.parent(t)!==e)throw new Error("illegal args");let a=i.find(c=>c.fi>s.fi);if(a===void 0){let c=i[i.length-1].fi;return Rr(c,c+o,o)}else return Rr(s.fi,a.fi,o)}}};var oi;(r=>{function n(e,t){if(t.type!==0)return null;if(Array.isArray(e)){let o=t.props,i={},s=[...e],a=!1;if(o)for(let c of Object.keys(o)){let d=parseInt(c);if(isNaN(d))throw new Error("wrong index");i[c]=s[d],s[d]=o[c],a=!0}return a?{data:s,actual:t,reverse:{type:0,props:i}}:null}else{let o=t.props,i={},s={...e},a=!1;if(o)for(let c of Object.keys(o)){i[c]=s[c];let d=o[c];d===void 0?delete s[c]:s[c]=d,a=!0}return a?{data:s,actual:t,reverse:{type:0,props:i}}:null}}r.runOp=n})(oi||(oi={}));var ge=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,ge.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Is(this[e]),e++}fillCaches0(e){this.objCaches.set(e.id,e)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,Object.getOwnPropertyDescriptor(this,"objCaches").enumerable=!1;for(let e of this)this.fillCaches0(e)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}data(e){return this.get(e)?.data}get(e){return this.fillCaches(),this.objCaches.get(e)}modifyById(e,t){if(this.get(e)===void 0)throw new Error("not expected");{let i=this,s=i.findIndex(d=>d.id===e);if(s<0)throw new Error("not expected");let a=i[s];return i=[...i],i[s]={...a,data:t},this.modifyArrayBy(i)}}modifyArrayBy(e){Object.setPrototypeOf(e,ge.prototype);let t=e;return _m()||t.fillCaches(),t}runOp(e){switch(e.type){case 4:return this.addOp(e);case 5:return this.deleteOp(e);case 6:return this.moveOp(e)}return null}addOp(e){let{fi:t,id:o,data:i}=e,s=this,a={fi:t,id:o,data:i};return s=[...s,a],s.sort((d,l)=>d.fi-l.fi),e.localIndex=s.indexOf(a),{data:this.modifyArrayBy(s),actual:e,reverse:{type:5,id:o}}}deleteOp(e){let{id:t}=e,o=this,i=o.findIndex(c=>c.id===t);if(i===-1)return null;e.localIndex=i,o=[...o];let s=o.splice(i,1)[0];return{data:this.modifyArrayBy(o),actual:e,reverse:{type:4,...s}}}moveOp(e){let{fi:t,id:o}=e,i=this;i=[...i];let s=i.findIndex(l=>l.id===o);if(s===-1)return null;let a=i[s].fi,c={...i[s],fi:t};return i[s]=c,i.sort((l,u)=>l.fi-u.fi),e.localIndex=i.indexOf(c),{data:this.modifyArrayBy(i),actual:e,reverse:{type:6,fi:a,id:o}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let t=null;for(let o of this){if(o.id===e)return t;t=o.id}return null}insertBeforeHelper(e,t){return this.insertAfterHelper(this.previous(e),t)}insertAfterHelper(e,t){let o=this;if(e===null){if(o.length===0)return Rr(0,t,t);{let i=o[0].fi;return Rr(i-t,i,t)}}else{let i=this.get(e);if(i===void 0)throw new Error("illegal args");let s=o.find(a=>a.fi>i.fi);if(s===void 0){let a=o[o.length-1].fi;return Rr(a,a+t,t)}else return Rr(i.fi,s.fi,t)}}};function ni(n){return n&&typeof n=="object"&&n instanceof He}var He=class{unusedFunOverridesTable(r){}runOp(r){let e=[],t=this,o=0,i={};for(;o<r.path.length;){if(e.push(t),t=t===void 0?void 0:t[r.path[o]],t!==void 0&&!ni(t))return null;o+=1}t=t?nl(t):new He;for(let[c,d]of Object.entries(r.props)){let l=t[c];i[c]=l,d===void 0?delete t[c]:t[c]=d}for(;o>0;){if(Object.keys(t).length===0){let c=e[o-1];c&&(t=nl(c),delete t[r.path[o-1]])}else{let c=e[o-1];if(c){let d=nl(c);d[r.path[o-1]]=t,t=d}else{let d=new He;d[r.path[o-1]]=t,t=d}}o-=1}let s=Object.setPrototypeOf(t,He.prototype),a={...r,props:i};return{data:s,actual:r,reverse:a}}},Gr;(t=>{function n(o,i){return Ms(o,i)??o}t.apply=n;function r(o,i){return Kc(o,i)}t.merge=r;function e(o,i){let s=0,a=i.path,c=o;for(;s<a.length&&c!==void 0;){if(c=Vt.zoomOnce(c,a[s]),c===void 0)return i;if(!ni(c))return;s+=1}if(c===void 0)return i;if(!!ni(c))if(i.type===0){let d={...i.props};for(let l of Object.keys(c))delete d[l];return{...i,props:d}}else if(i.type===1||i.type===4||i.type===7){let d=Xc([i],c);return d?(console.log(d),d):i}else return i}t.filterOp=e})(Gr||(Gr={}));function Xc(n,r){if(r===void 0)return;let e=!1,t=n.map(o=>{let i=o.id,s=Ms(o.data,r[i]);if(e=e||s!==void 0,s===void 0&&(s=o.data),o.children){let a=Xc(o.children,r);return a!==void 0?e=!0:a=o.children,{...o,id:i,data:s,children:a}}else return{...o,id:i,data:s}});if(e)return t}function Y1(n,r){if(r===void 0)return;let e=!1,t=n.map(o=>{let i=o.id,s=Ms(o.data,r[i]);return e=e||s!==void 0,s===void 0&&(s=o.data),{...o,id:i,data:s}});if(e)return Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t}function Ms(n,r){if(!ni(r))return r;if(n instanceof Qe){let e=Xc(n,r);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e}else{if(n instanceof ge)return Y1(n,r);if(Array.isArray(n)){let e=!1,t=n.map((o,i)=>{let s=Ms(o,r[i]);return e=e||s!==void 0,s===void 0&&(s=o),s});return e?(Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t):void 0}else{if(n instanceof He)return Kc(n,r);if(n&&typeof n=="object"){let e={},t=!1;for(let[o,i]of Object.entries(n)){let s=Ms(i,r[o]);t=t||s!==void 0,s===void 0&&(s=i),e[o]=s}return t?(Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e):void 0}}}}function Kc(n,r){if(n===void 0)return r;if(r===void 0)return n;if(!ni(r))return r;if(!ni(n))return Gr.apply(n,r);let e=new Set;for(let o of Object.keys(n))e.add(o);for(let o of Object.keys(r))e.add(o);let t=new He;for(let o of e){let i=Kc(n===void 0?void 0:n[o],r===void 0?void 0:r[o]);t[o]=i}return t}function Om(n,r){let e={cur:[],result:[],len:0};return n=Es(n,r,e)??n,[n,e.result]}function il(n,r){return n===null?null:(n.cur[n.len]=r,n.len+=1,n)}function sl(n){n&&(n.len-=1)}function X1(n){if(n===null)return null;n.result.push(n.cur.slice(0,n.len))}function Am(n,r,e){let t=!1,o=n.map(i=>{let s=i.id,a=r[s];if(a!==void 0&&typeof a=="string"&&(t=!0,s=a,e!==null))throw new Error("not supported");let c=Es(i.data,r,il(e,s));sl(e),t=t||c!==void 0,c===void 0&&(c=i.data);let d=Am(i.children,r,e);return d!==void 0?t=!0:d=i.children,{...i,id:s,data:c,children:d}});if(t)return o}function K1(n,r,e){let t=!1,o=n.map(i=>{let s=i.id,a=r[s];if(a!==void 0&&typeof a=="string"&&(t=!0,s=a,e!==null))throw new Error("not supported");let c=Es(i.data,r,il(e,s));return sl(e),t=t||c!==void 0,c===void 0&&(c=i.data),{...i,id:s,data:c}});if(t)return Object.setPrototypeOf(o,Object.getPrototypeOf(n)),o}function Es(n,r,e){if(n instanceof Qe){let t=Am(n,r,e);return t!==void 0&&Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t}else{if(n instanceof ge)return K1(n,r,e);if(Array.isArray(n)){let t=!1,o=n.map((i,s)=>{let a=Es(i,r,il(e,s));return sl(e),t=t||a!==void 0,a===void 0&&(a=i),a});return t?(Object.setPrototypeOf(o,Object.getPrototypeOf(n)),o):void 0}else if(n&&typeof n=="object"&&!ri(n)){let t={},o=!1;for(let[i,s]of Object.entries(n))if(i!=="name"&&i!=="text"){let a=r[i];if(typeof a=="string"){if(e!==null)throw new Error("not supported");o=!0,i=a}let c=Es(s,r,il(e,i));sl(e),o=o||c!==void 0,c===void 0&&(c=s),t[i]=c}else t[i]=s;return o?(Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t):void 0}else if(typeof n=="string"){let t=r[n];if(t!==void 0){if(n.length!==36)throw new Error("for now you should only call this method when the key is a uuid");X1(e)}return t}else return}}var al;(r=>{function n(e,t){let o=Vt.zoom(t,e.path);if(typeof o=="object"){let i={};for(let s of Object.keys(e.props))i[s]=o[s];return{...e,props:i}}else return{...e,props:{}}}r.replaceProps=n})(al||(al={}));var Ct;(a=>{function n(c,d){return{...c,path:c.path.slice(d)}}a.drop=n;function r(c,d){return e(c,d)?.data??c}a.applySimple=r;function e(c,d){let l=d.path;for(var u=[];;){let p;if(c instanceof He&&d.type===0&&(p=c.runOp({...d,path:l.slice(u.length)}),p===null&&(p=void 0)),p===void 0&&u.length===l.length&&(c instanceof Qe||c instanceof ge||c instanceof Ue?p=c.runOp(d):p=oi.runOp(c,d)),p!==void 0)if(p!==null){let h=p.data;for(let y=u.length-1;y>=0;y--){let g=l[y],x=u[y];if(x instanceof Qe){if(typeof g=="number")throw new Error("illegal arg");h=x.modifyById(g,h)}else if(x instanceof ge){if(typeof g=="number")throw new Error("illegal arg");h=x.modifyById(g,h)}else if(x instanceof Ue){if(typeof g=="number")throw new Error("illegal arg");h=x.modifyById(g,h)}else if(x instanceof He){let S={...x,[g]:h};h=Object.setPrototypeOf(S,He.prototype)}else if(typeof x=="object")if(Array.isArray(x)){if(typeof g=="string"&&(g=parseInt(g),isNaN(g)))throw new Error("Invalid path");let S=h;h=[...x],h[g]=S}else h={...x,[g]:h};else return null}return{data:h,actual:{...p.actual,path:l},reverse:{...p.reverse,path:l}}}else return null;let f=l[u.length],m;if(c instanceof Qe){if(typeof f=="number")throw new Error("");m=c.get(f)?.data}else if(c instanceof ge){if(typeof f=="number")throw new Error("");m=c.get(f)?.data}else c!==null&&(m=c[f]);if(m!==void 0)u.push(c),c=m;else return null}}a.apply=e;function t(c,d){for(let l=0;l<c.length&&l<d.length;l++)if(c[l]!==d[l])return!0;return!1}a.pathDisjoint=t;function o(c,d){if(c.length!==d.length)return!1;for(let l=0;l<c.length;l++)if(c[l]!==d[l])return!1;return!0}a.pathEq=o;function i(c,d){return t(c.path,d.path)}a.commutative=i;function s(c,d){return c.type===0&&d.type===0&&o(c.path,d.path)?Object.keys(c.props).every(l=>d.props[l]!==void 0):!1}a.subsumed=s})(Ct||(Ct={}));var Zc;(c=>{function n(){return[]}c.empty=n;function r(d,l){let u=[];for(let p of d){let[f,...m]=p.path;f===l&&u.push({...p,path:m})}return u}c.removePrefix=r;function e(d,l){return d.map(u=>({...u,path:[l,...u.path]}))}c.addPrefix=e;function t(d,l){return[...d,...l]}c.concat=t;function o(d,l){return[...d.filter(p=>!l.some(f=>Ct.subsumed(p,f))),...l]}c.compress=o;function i(d,l){return d.every(u=>l.every(p=>Ct.commutative(u,p)))}c.commutative=i;function s(d,l){for(let u of l){let p=a(d,u);p!==null&&(d=p.data)}return d}c.applyAll=s;function a(d,l){var u=d;let p=[],f=[];for(let m of l)try{if(m.type===3){let h=Vt.zoom(u,[...m.path,m.id]),y=Ct.apply(u,{...m,type:2});if(y!==null){u=y.data;let[g,x]=Om(u,{[m.id]:h});u=g;for(let S of x){let w=S[S.length-1];S.splice(S.length-1,1),p.push({type:0,path:S,props:{[w]:h}}),f.push({type:0,path:S,props:{[w]:m.id}})}f.push(y.reverse),p.push(y.actual)}}else{let h=Ct.apply(u,m);h!==null&&(p.push(h.actual),u=h.data,f.push(h.reverse))}}catch(h){if(h instanceof ti)return null;throw h}return{data:u,actual:p,reverse:f.reverse()}}c.apply=a})(Zc||(Zc={}));var Cm=Symbol(),Z1=Symbol(),cl=Symbol(),nn=class{reportOp(r,e,t=[]){let o=this;if(e===null)return;o._current=e.data;let i=t;for(;!(o instanceof ll);){let s=o._path,a=o._current;if(s!==""&&i.splice(0,0,s),o=o._parent,o===null)return;o.update(s,a)}o.push(i,r,e.actual,e.reverse)}deleteChildren(r){if(this._children){let e=this._children[r];if(e){let t=e[cl];t&&t(),delete this._children[r]}}}},Jc=class extends nn{constructor(r,e,t){super(),this._parent=r,this._path=e,this._current=t}update(r,e){if(Array.isArray(this._current)){if(typeof r=="string"&&(r=parseInt(r),isNaN(r)))throw new Error("Invalid path");this._current=[...this._current],this._current[r]=e}else this._current={...this._current,[r]:e}}runOp(r){this.reportOp(r,oi.runOp(this._current,r),r.path)}},eu=class extends nn{constructor(r,e,t){super(),this._parent=r,this._path=e,this._current=t}update(r,e){this._current={...this._current,[r]:e},Object.setPrototypeOf(this._current,Ue.prototype)}runOp(r){this.reportOp(r,this._current.runOp(r))}},Nm={get(n,r){if(r===cl)return()=>{n._parent=null};if(r===Cm)return n._current;if(r===Z1)return n;let{_current:e,_children:t}=n;if(r==="push"&&Array.isArray(e))throw new Error("not supported to expand array");let o=t===void 0?void 0:t[r];if(o!==void 0)return o;let i=e[r],s=ul(n,r,i);return s!==i?(t===void 0&&(t={},n._children=t),t[r]=s,s):i},has(n,r){return r in n._current},ownKeys(n){return Reflect.ownKeys(n._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(n){return Object.getPrototypeOf(n._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(n,r){let e=n._current,t=Reflect.getOwnPropertyDescriptor(e,r);return t&&{writable:!0,configurable:!0,enumerable:t.enumerable,value:e[r]}}},Q1={...Nm,set(n,r,e){let t={type:0,props:{[r]:ut(e)??e}};return n.deleteChildren(r),n.runOp(t),!0},deleteProperty(n,r){let e={type:0,props:{[r]:void 0}};return n.deleteChildren(r),n.runOp(e),!0}},J1={...Nm,set(n,r,e){return e===void 0?this.deleteProperty(n,r):(n.deleteChildren(r),n.runOp({type:1,id:r,data:e})),!0},deleteProperty(n,r){return n.runOp({type:2,id:r}),!0}},ii=class extends nn{constructor(r,e,t){super(),this._children={},this._parent=r,this._path=e,this._current=t,this[cl]=()=>{this._parent=null}}unproxy(){return this._current}update(r,e){this._current=this._current.modifyById(r,e)}runOp(r){this.reportOp(r,this._current.runOp(r))}randomId(){return this._current.randomId()}isDescendantOf(r,e){return this._current.isDescendantOf(r,e)}childrenOf(r){return this._current.childrenOf(r)}traverse(r){return this._current.traverse(r)}get(r){return this._current.get(r)}parent(r){return this._current.parent(r)}traverse(r){this._current.traverse((e,t)=>{r(e,this.data(e))})}data(r){let{_current:e,_children:t}=this,o=t===void 0?void 0:t[r];if(o!==void 0)return o;let i=e.get(r)?.data,s=ul(this,r,i);return s!==i?(t===void 0&&(t={},this._children=t),t[r]=s,s):i}add(r,e,t,o,i){this.runOp({type:7,parent:r,fi:e,id:t,data:o,children:i})}move(r,e,t){this.runOp({type:9,parent:r,fi:e,id:t})}insertAfter(r,e,t){let o=this._current.insertAfterHelper(r,e,t.length);for(let i=0;i<t.length;i++){let s=t[i];this.add(r,o[i],s.id,s.data,s.children)}}insertBefore(r,e,t){let o=this._current.insertBeforeHelper(r,e,t.length);for(let i=0;i<t.length;i++){let s=t[i];this.add(r,o[i],s.id,s.data,s.children)}}moveAfter(r,e,t){let o=this._current.insertAfterHelper(r,e,t.length);for(let i=0;i<t.length;i++){let s=t[i];this.move(r,o[i],s)}}moveBefore(r,e,t){let o=this._current.insertBeforeHelper(r,e,t.length);for(let i=0;i<t.length;i++){let s=t[i];this.move(r,o[i],s)}}delete(r){this.deleteChildren(r),this.runOp({type:8,id:r})}sortNext(r){return this._current.sortNext(r)}sortPrevious(r){return this._current.sortPrevious(r)}getAllSorted(r){return this._current.getAllSorted(r)}},si=class extends nn{constructor(r,e,t){super(),this._children={},this._parent=r,this._path=e,this._current=t,this[cl]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(r){let e=this.length;for(let t=0;t<e;t++){let o=this._current[t].id,i=this._current[t].fi;r(this.data(this._current[t].id),o,i)}}find(r){let e=this.length;for(let t=0;t<e;t++){let o=this._current[t].id;if(r(this.data(o),o))return this.get(o)}}update(r,e){this._current=this._current.modifyById(r,e)}randomId(){return this._current.randomId()}get(r){return{...this._current.get(r),data:this.data(r)}}data(r){let{_current:e,_children:t}=this,o=t===void 0?void 0:t[r];if(o!==void 0)return o;let i=e.get(r)?.data,s=ul(this,r,i);return s!==i?(t===void 0&&(t={},this._children=t),t[r]=s,s):i}runOp(r){this.reportOp(r,this._current.runOp(r))}add(r,e,t){this.runOp({type:4,fi:r,id:e,data:t})}move(r,e){this.runOp({type:6,fi:r,id:e})}insertAfter(r,e){let t=this._current.insertAfterHelper(r,e.length);for(let o=0;o<e.length;o++){let i=e[o];this.add(t[o],i.id,i.data)}}insertBefore(r,e){let t=this._current.insertBeforeHelper(r,e.length);for(let o=0;o<e.length;o++){let i=e[o];this.add(t[o],i.id,i.data)}}moveAfter(r,e){let t=this._current.insertAfterHelper(r,e.length);for(let o=0;o<e.length;o++){let i=e[o];this.move(t[o],i)}}moveBefore(r,e){let t=this._current.insertBeforeHelper(r,e.length);for(let o=0;o<e.length;o++){let i=e[o];this.move(t[o],i)}}delete(r){this.deleteChildren(r),this.runOp({type:5,id:r})}};function Qc(n,r,e){if(n.length>0){let t=n[n.length-1];if(t.type===0&&r.type===0&&Vt.equal(t.path,e)){Object.assign(t.props,r.props);return}}n.push({...r,path:e})}var ll=class extends nn{constructor(r){super(),this.ts=[],this.actual=[],this.reverse=[],this._current=r}update(r,e){if(r!=="")throw new Error("");this._current=e}push(r,e,t,o){Qc(this.ts,e,r),Qc(this.actual,t,r),Qc(this.reverse,o,r)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function ul(n,r,e){return e instanceof Qe?new ii(n,r,e):e instanceof ge?new si(n,r,e):e instanceof Ue?new Proxy(new eu(n,r,e),J1):e!==null&&typeof e=="object"?ri(e)?e:new Proxy(new Jc(n,r,e),Q1):e}function tu(n){let r=new ll(n);return[ul(r,"",n),r]}function ai(n,r){let[e,t]=tu(n);return r(e),t.result()}function ut(n){return n instanceof ii||n instanceof si?n._current:n!==null&&typeof n=="object"?n[Cm]:n}var Vt;(o=>{function n(i,s){if(s.length===i.length)for(var a=0;a<i.length;){if(i[a]!==s[a])return!1;a+=1}else return!1;return!0}o.equal=n;function r(i,s,a){let c=t(a,i);if(c!==void 0&&typeof c=="object"&&c!==null){let d={...s};return Object.keys(c).forEach(l=>{delete d[l]}),d}else return s}o.removeOverridden=r;function e(i,s){if((i instanceof Qe||i instanceof ii)&&typeof s=="string")return i.data(s);if((i instanceof ge||i instanceof si)&&typeof s=="string")return i.data(s);if(typeof s=="number"&&Array.isArray(i))return i[s];if(typeof s=="string"&&typeof i=="object"&&i!==null)return i[s]}o.zoomOnce=e;function t(i,s,a=0){for(;a<s.length&&i!==void 0;)i=e(i,s[a]),a+=1;return i}o.zoom=t})(Vt||(Vt={}));function Im(n,r){let e=[];if(r.length===n.length)for(var t=0;t<n.length;){if(r[t]==="*")e.push(n[t]);else if(n[t]!==r[t])return null;t+=1}else return null;return e}function Rt(n,r){let e=[];if(r.length<=n.length)for(var t=0;t<r.length;){if(r[t]==="*")e.push(n[t]);else if(n[t]!==r[t])return null;t+=1}else return null;return e}var dl=class{},Ls=class extends dl{constructor(e){super();this.id=e}},Ds=class extends dl{constructor(e){super();this.data=e}};var ou;try{ou=new TextDecoder}catch{}var re,Io,I=0;var Vm=[],nu=Vm,iu=0,Yt={},De,No,dr=0,Vr=0,ir,po,zt=[],Ge,Mm={useRecords:!1,mapsAsObjects:!0},Bs=class{},au=new Bs;au.name="MessagePack 0xC1";var li=!1,zr=class{constructor(r){r&&(r.useRecords===!1&&r.mapsAsObjects===void 0&&(r.mapsAsObjects=!0),r.structures?r.structures.sharedLength=r.structures.length:r.getStructures&&((r.structures=[]).uninitialized=!0,r.structures.sharedLength=0)),Object.assign(this,r)}unpack(r,e){if(re)return Um(()=>(fl(),this?this.unpack(r,e):zr.prototype.unpack.call(Mm,r,e)));Io=e>-1?e:r.length,I=0,iu=0,Vr=0,No=null,nu=Vm,ir=null,re=r;try{Ge=r.dataView||(r.dataView=new DataView(r.buffer,r.byteOffset,r.byteLength))}catch(t){throw re=null,r instanceof Uint8Array?t:new Error("Source must be a Uint8Array or Buffer but was a "+(r&&typeof r=="object"?r.constructor.name:typeof r))}if(this instanceof zr){if(Yt=this,this.structures)return De=this.structures,pl();(!De||De.length>0)&&(De=[])}else Yt=Mm,(!De||De.length>0)&&(De=[]);return pl()}unpackMultiple(r,e){let t,o=0;try{li=!0;let i=r.length,s=this?this.unpack(r,i):yl.unpack(r,i);if(e){for(e(s);I<i;)if(o=I,e(pl())===!1)return}else{for(t=[s];I<i;)o=I,t.push(pl());return t}}catch(i){throw i.lastPosition=o,i.values=t,i}finally{li=!1,fl()}}_mergeStructures(r,e){r=r||[];for(let t=0,o=r.length;t<o;t++){let i=r[t];i&&(i.isShared=!0,t>=32&&(i.highByte=t-32>>5))}r.sharedLength=r.length;for(let t in e||[])if(t>=0){let o=r[t],i=e[t];i&&(o&&((r.restoreStructures||(r.restoreStructures=[]))[t]=o),r[t]=i)}return this.structures=r}decode(r,e){return this.unpack(r,e)}};function pl(){try{if(!Yt.trusted&&!li){let r=De.sharedLength||0;r<De.length&&(De.length=r)}let n=rt();if(I==Io)De.restoreStructures&&Em(),De=null,re=null,po&&(po=null);else if(I>Io){let r=new Error("Unexpected end of MessagePack data");throw r.incomplete=!0,r}else if(!li)throw new Error("Data read, but end of buffer not reached");return n}catch(n){throw De.restoreStructures&&Em(),fl(),(n instanceof RangeError||n.message.startsWith("Unexpected end of buffer"))&&(n.incomplete=!0),n}}function Em(){for(let n in De.restoreStructures)De[n]=De.restoreStructures[n];De.restoreStructures=null}function rt(){let n=re[I++];if(n<160)if(n<128){if(n<64)return n;{let r=De[n&63]||Yt.getStructures&&zm()[n&63];return r?(r.read||(r.read=lu(r,n&63)),r.read()):n}}else if(n<144)if(n-=128,Yt.mapsAsObjects){let r={};for(let e=0;e<n;e++)r[Fm()]=rt();return r}else{let r=new Map;for(let e=0;e<n;e++)r.set(rt(),rt());return r}else{n-=144;let r=new Array(n);for(let e=0;e<n;e++)r[e]=rt();return r}else if(n<192){let r=n-160;if(Vr>=I)return No.slice(I-dr,(I+=r)-dr);if(Vr==0&&Io<140){let e=r<16?cu(r):jm(r);if(e!=null)return e}return su(r)}else{let r;switch(n){case 192:return null;case 193:return ir?(r=rt(),r>0?ir[1].slice(ir.position1,ir.position1+=r):ir[0].slice(ir.position0,ir.position0-=r)):au;case 194:return!1;case 195:return!0;case 196:return ru(re[I++]);case 197:return r=Ge.getUint16(I),I+=2,ru(r);case 198:return r=Ge.getUint32(I),I+=4,ru(r);case 199:return sn(re[I++]);case 200:return r=Ge.getUint16(I),I+=2,sn(r);case 201:return r=Ge.getUint32(I),I+=4,sn(r);case 202:if(r=Ge.getFloat32(I),Yt.useFloat32>2){let e=hl[(re[I]&127)<<1|re[I+1]>>7];return I+=4,(e*r+(r>0?.5:-.5)>>0)/e}return I+=4,r;case 203:return r=Ge.getFloat64(I),I+=8,r;case 204:return re[I++];case 205:return r=Ge.getUint16(I),I+=2,r;case 206:return r=Ge.getUint32(I),I+=4,r;case 207:return Yt.int64AsNumber?(r=Ge.getUint32(I)*4294967296,r+=Ge.getUint32(I+4)):r=Ge.getBigUint64(I),I+=8,r;case 208:return Ge.getInt8(I++);case 209:return r=Ge.getInt16(I),I+=2,r;case 210:return r=Ge.getInt32(I),I+=4,r;case 211:return Yt.int64AsNumber?(r=Ge.getInt32(I)*4294967296,r+=Ge.getUint32(I+4)):r=Ge.getBigInt64(I),I+=8,r;case 212:if(r=re[I++],r==114)return Gm(re[I++]&63);{let e=zt[r];if(e)return e.read?(I++,e.read(rt())):e.noBuffer?(I++,e()):e(re.subarray(I,++I));throw new Error("Unknown extension "+r)}case 213:return r=re[I],r==114?(I++,Gm(re[I++]&63,re[I++])):sn(2);case 214:return sn(4);case 215:return sn(8);case 216:return sn(16);case 217:return r=re[I++],Vr>=I?No.slice(I-dr,(I+=r)-dr):t_(r);case 218:return r=Ge.getUint16(I),I+=2,Vr>=I?No.slice(I-dr,(I+=r)-dr):r_(r);case 219:return r=Ge.getUint32(I),I+=4,Vr>=I?No.slice(I-dr,(I+=r)-dr):o_(r);case 220:return r=Ge.getUint16(I),I+=2,Dm(r);case 221:return r=Ge.getUint32(I),I+=4,Dm(r);case 222:return r=Ge.getUint16(I),I+=2,Bm(r);case 223:return r=Ge.getUint32(I),I+=4,Bm(r);default:if(n>=224)return n-256;if(n===void 0){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}throw new Error("Unknown MessagePack token "+n)}}}var e_=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function lu(n,r){function e(){if(e.count++>2){let o=n.read=new Function("r","return function(){return {"+n.map(i=>e_.test(i)?i+":r()":"["+JSON.stringify(i)+"]:r()").join(",")+"}}")(rt);return n.highByte===0&&(n.read=Lm(r,n.read)),o()}let t={};for(let o=0,i=n.length;o<i;o++){let s=n[o];t[s]=rt()}return t}return e.count=0,n.highByte===0?Lm(r,e):e}var Lm=(n,r)=>function(){let e=re[I++];if(e===0)return r();let t=n<32?-(n+(e<<5)):n+(e<<5),o=De[t]||zm()[t];if(!o)throw new Error("Record id is not defined for "+t);return o.read||(o.read=lu(o,n)),o.read()};function zm(){let n=Um(()=>(re=null,Yt.getStructures()));return De=Yt._mergeStructures(n,De)}var su=ml,t_=ml,r_=ml,o_=ml;function ml(n){let r;if(n<16&&(r=cu(n)))return r;if(n>64&&ou)return ou.decode(re.subarray(I,I+=n));let e=I+n,t=[];for(r="";I<e;){let o=re[I++];if((o&128)===0)t.push(o);else if((o&224)===192){let i=re[I++]&63;t.push((o&31)<<6|i)}else if((o&240)===224){let i=re[I++]&63,s=re[I++]&63;t.push((o&31)<<12|i<<6|s)}else if((o&248)===240){let i=re[I++]&63,s=re[I++]&63,a=re[I++]&63,c=(o&7)<<18|i<<12|s<<6|a;c>65535&&(c-=65536,t.push(c>>>10&1023|55296),c=56320|c&1023),t.push(c)}else t.push(o);t.length>=4096&&(r+=bt.apply(String,t),t.length=0)}return t.length>0&&(r+=bt.apply(String,t)),r}function Dm(n){let r=new Array(n);for(let e=0;e<n;e++)r[e]=rt();return r}function Bm(n){if(Yt.mapsAsObjects){let r={};for(let e=0;e<n;e++)r[Fm()]=rt();return r}else{let r=new Map;for(let e=0;e<n;e++)r.set(rt(),rt());return r}}var bt=String.fromCharCode;function jm(n){let r=I,e=new Array(n);for(let t=0;t<n;t++){let o=re[I++];if((o&128)>0){I=r;return}e[t]=o}return bt.apply(String,e)}function cu(n){if(n<4)if(n<2){if(n===0)return"";{let r=re[I++];if((r&128)>1){I-=1;return}return bt(r)}}else{let r=re[I++],e=re[I++];if((r&128)>0||(e&128)>0){I-=2;return}if(n<3)return bt(r,e);let t=re[I++];if((t&128)>0){I-=3;return}return bt(r,e,t)}else{let r=re[I++],e=re[I++],t=re[I++],o=re[I++];if((r&128)>0||(e&128)>0||(t&128)>0||(o&128)>0){I-=4;return}if(n<6){if(n===4)return bt(r,e,t,o);{let i=re[I++];if((i&128)>0){I-=5;return}return bt(r,e,t,o,i)}}else if(n<8){let i=re[I++],s=re[I++];if((i&128)>0||(s&128)>0){I-=6;return}if(n<7)return bt(r,e,t,o,i,s);let a=re[I++];if((a&128)>0){I-=7;return}return bt(r,e,t,o,i,s,a)}else{let i=re[I++],s=re[I++],a=re[I++],c=re[I++];if((i&128)>0||(s&128)>0||(a&128)>0||(c&128)>0){I-=8;return}if(n<10){if(n===8)return bt(r,e,t,o,i,s,a,c);{let d=re[I++];if((d&128)>0){I-=9;return}return bt(r,e,t,o,i,s,a,c,d)}}else if(n<12){let d=re[I++],l=re[I++];if((d&128)>0||(l&128)>0){I-=10;return}if(n<11)return bt(r,e,t,o,i,s,a,c,d,l);let u=re[I++];if((u&128)>0){I-=11;return}return bt(r,e,t,o,i,s,a,c,d,l,u)}else{let d=re[I++],l=re[I++],u=re[I++],p=re[I++];if((d&128)>0||(l&128)>0||(u&128)>0||(p&128)>0){I-=12;return}if(n<14){if(n===12)return bt(r,e,t,o,i,s,a,c,d,l,u,p);{let f=re[I++];if((f&128)>0){I-=13;return}return bt(r,e,t,o,i,s,a,c,d,l,u,p,f)}}else{let f=re[I++],m=re[I++];if((f&128)>0||(m&128)>0){I-=14;return}if(n<15)return bt(r,e,t,o,i,s,a,c,d,l,u,p,f,m);let h=re[I++];if((h&128)>0){I-=15;return}return bt(r,e,t,o,i,s,a,c,d,l,u,p,f,m,h)}}}}}function ru(n){return Yt.copyBuffers?Uint8Array.prototype.slice.call(re,I,I+=n):re.subarray(I,I+=n)}function sn(n){let r=re[I++];if(zt[r])return zt[r](re.subarray(I,I+=n));throw new Error("Unknown extension type "+r)}var Rm=new Array(4096);function Fm(){let n=re[I++];if(n>=160&&n<192){if(n=n-160,Vr>=I)return No.slice(I-dr,(I+=n)-dr);if(!(Vr==0&&Io<180))return su(n)}else return I--,rt();let r=(n<<5^(n>1?Ge.getUint16(I):n>0?re[I]:0))&4095,e=Rm[r],t=I,o=I+n-3,i,s=0;if(e&&e.bytes==n){for(;t<o;){if(i=Ge.getUint32(t),i!=e[s++]){t=1879048192;break}t+=4}for(o+=3;t<o;)if(i=re[t++],i!=e[s++]){t=1879048192;break}if(t===o)return I=t,e.string;o-=3,t=I}for(e=[],Rm[r]=e,e.bytes=n;t<o;)i=Ge.getUint32(t),e.push(i),t+=4;for(o+=3;t<o;)i=re[t++],e.push(i);let a=n<16?cu(n):jm(n);return a!=null?e.string=a:e.string=su(n)}var Gm=(n,r)=>{var e=rt();let t=n;r!==void 0&&(n=n<32?-((r<<5)+n):(r<<5)+n,e.highByte=r);let o=De[n];return o&&o.isShared&&((De.restoreStructures||(De.restoreStructures=[]))[n]=o),De[n]=e,e.read=lu(e,t),e.read()},km=typeof self=="object"?self:global;zt[0]=()=>{};zt[0].noBuffer=!0;zt[101]=()=>{let n=rt();return(km[n[0]]||Error)(n[1])};zt[105]=n=>{let r=Ge.getUint32(I-4);po||(po=new Map);let e=re[I],t;e>=144&&e<160||e==220||e==221?t=[]:t={};let o={target:t};po.set(r,o);let i=rt();return o.used?Object.assign(t,i):(o.target=i,i)};zt[112]=n=>{let r=Ge.getUint32(I-4),e=po.get(r);return e.used=!0,e.target};zt[115]=()=>new Set(rt());var uu=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(n=>n+"Array");zt[116]=n=>{let r=n[0],e=uu[r];if(!e)throw new Error("Could not find typed array for code "+r);return new km[e](Uint8Array.prototype.slice.call(n,1).buffer)};zt[120]=()=>{let n=rt();return new RegExp(n[0],n[1])};zt[98]=n=>{let r=(n[0]<<24)+(n[1]<<16)+(n[2]<<8)+n[3],e=I;I+=r-4,ir=[rt(),rt()],ir.position0=0,ir.position1=0;let t=I;I=e;try{return rt()}finally{I=t}};zt[255]=n=>n.length==4?new Date((n[0]*16777216+(n[1]<<16)+(n[2]<<8)+n[3])*1e3):n.length==8?new Date(((n[0]<<22)+(n[1]<<14)+(n[2]<<6)+(n[3]>>2))/1e6+((n[3]&3)*4294967296+n[4]*16777216+(n[5]<<16)+(n[6]<<8)+n[7])*1e3):n.length==12?new Date(((n[0]<<24)+(n[1]<<16)+(n[2]<<8)+n[3])/1e6+((n[4]&128?-281474976710656:0)+n[6]*1099511627776+n[7]*4294967296+n[8]*16777216+(n[9]<<16)+(n[10]<<8)+n[11])*1e3):new Date("invalid");function Um(n){let r=Io,e=I,t=iu,o=dr,i=Vr,s=No,a=nu,c=po,d=ir,l=new Uint8Array(re.slice(0,Io)),u=De,p=De.slice(0,De.length),f=Yt,m=li,h=n();return Io=r,I=e,iu=t,dr=o,Vr=i,No=s,nu=a,po=c,ir=d,re=l,li=m,De=u,De.splice(0,De.length,...p),Yt=f,Ge=new DataView(re.buffer,re.byteOffset,re.byteLength),h}function fl(){re=null,po=null,De=null}function Hm(n){n.unpack?zt[n.type]=n.unpack:zt[n.type]=n}var hl=new Array(147);for(let n=0;n<256;n++)hl[n]=+("1e"+Math.floor(45.15-n*.30103));var yl=new zr({useRecords:!1}),n_=yl.unpack,i_=yl.unpackMultiple,s_=yl.unpack,gl={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},a_=new Float32Array(1),jL=new Uint8Array(a_.buffer,0,4);var xl;try{xl=new TextEncoder}catch{}var vl,pu,bl=typeof Buffer<"u",du=bl?Buffer.allocUnsafeSlow:Uint8Array,Ym=bl?Buffer:Uint8Array,Wm=bl?4294967296:2144337920,G,at,E=0,jr,Fr=null,l_=/[\u0080-\uFFFF]/,Rs=Symbol("record-id"),an=class extends zr{constructor(r){super(r),this.offset=0;let e,t,o,i,s,a,c=0,d=Ym.prototype.utf8Write?function(v,N,T){return G.utf8Write(v,N,T)}:xl&&xl.encodeInto?function(v,N){return xl.encodeInto(v,G.subarray(N)).written}:!1,l=this;r||(r={});let u=r&&r.sequential,p=r.structures||r.saveStructures,f=r.maxSharedStructures;if(f==null&&(f=p?32:0),f>8160)throw new Error("Maximum maxSharedStructure is 8160");let m=r.maxOwnStructures;m==null&&(m=p?32:64),u&&!r.saveStructures&&(this.structures=[]);let h=f>32||m+f>64,y=f+64,g=f+m+64;if(g>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let x=[],S=0,w=0;this.pack=this.encode=function(v,N){if(G||(G=new du(8192),at=new DataView(G.buffer,0,8192),E=0),jr=G.length-10,jr-E<2048?(G=new du(G.length),at=new DataView(G.buffer,0,G.length),jr=G.length-10,E=0):E=E+7&2147483640,t=E,a=l.structuredClone?new Map:null,l.bundleStrings?(Fr=["",""],G[E++]=214,G[E++]=98,Fr.position=E-t,E+=4):Fr=null,o=l.structures,o){o.uninitialized&&(o=l._mergeStructures(l.getStructures()));let T=o.sharedLength||0;if(T>f)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+o.sharedLength);if(!o.transitions){o.transitions=Object.create(null);for(let C=0;C<T;C++){let O=o[C];if(!O)continue;let A,M=o.transitions;for(let L=0,X=O.length;L<X;L++){let R=O[L];A=M[R],A||(A=M[R]=Object.create(null)),M=A}M[Rs]=C+64}c=T}u||(o.nextId=T+64)}i&&(i=!1),s=o||[];try{if(b(v),Fr){at.setUint32(Fr.position+t,E-Fr.position-t);let T=Fr;Fr=null,b(T[0]),b(T[1])}if(l.offset=E,a&&a.idsToInsert){E+=a.idsToInsert.length*6,E>jr&&P(E),l.offset=E;let T=u_(G.subarray(t,E),a.idsToInsert);return a=null,T}return N&Km?(G.start=t,G.end=E,G):G.subarray(t,E)}finally{if(o){if(w<10&&w++,S>1e4)o.transitions=null,w=0,S=0,x.length>0&&(x=[]);else if(x.length>0&&!u){for(let T=0,C=x.length;T<C;T++)x[T][Rs]=0;x=[]}if(i&&l.saveStructures){let T=o.sharedLength||f;o.length>T&&(o=o.slice(0,T));let C=G.subarray(t,E);return l.saveStructures(o,c)===!1?(l._mergeStructures(l.getStructures()),l.pack(v)):(c=T,C)}}N&g_&&(E=t)}};let b=v=>{E>jr&&(G=P(E));var N=typeof v,T;if(N==="string"){let C=v.length;if(Fr&&C>=8&&C<4096){let M=l_.test(v);Fr[M?0:1]+=v,G[E++]=193,b(M?-C:C);return}let O;C<32?O=1:C<256?O=2:C<65536?O=3:O=5;let A=C*3;if(E+A>jr&&(G=P(E+A)),C<64||!d){let M,L,X,R=E+O;for(M=0;M<C;M++)L=v.charCodeAt(M),L<128?G[R++]=L:L<2048?(G[R++]=L>>6|192,G[R++]=L&63|128):(L&64512)===55296&&((X=v.charCodeAt(M+1))&64512)===56320?(L=65536+((L&1023)<<10)+(X&1023),M++,G[R++]=L>>18|240,G[R++]=L>>12&63|128,G[R++]=L>>6&63|128,G[R++]=L&63|128):(G[R++]=L>>12|224,G[R++]=L>>6&63|128,G[R++]=L&63|128);T=R-E-O}else T=d(v,E+O,A);T<32?G[E++]=160|T:T<256?(O<2&&G.copyWithin(E+2,E+1,E+1+T),G[E++]=217,G[E++]=T):T<65536?(O<3&&G.copyWithin(E+3,E+2,E+2+T),G[E++]=218,G[E++]=T>>8,G[E++]=T&255):(O<5&&G.copyWithin(E+5,E+3,E+3+T),G[E++]=219,at.setUint32(E,T),E+=4),E+=T}else if(N==="number")if(v>>>0===v)v<64?G[E++]=v:v<256?(G[E++]=204,G[E++]=v):v<65536?(G[E++]=205,G[E++]=v>>8,G[E++]=v&255):(G[E++]=206,at.setUint32(E,v),E+=4);else if(v>>0===v)v>=-32?G[E++]=256+v:v>=-128?(G[E++]=208,G[E++]=v+256):v>=-32768?(G[E++]=209,at.setInt16(E,v),E+=2):(G[E++]=210,at.setInt32(E,v),E+=4);else{let C;if((C=this.useFloat32)>0&&v<4294967296&&v>=-2147483648){G[E++]=202,at.setFloat32(E,v);let O;if(C<4||(O=v*hl[(G[E]&127)<<1|G[E+1]>>7])>>0===O){E+=4;return}else E--}G[E++]=203,at.setFloat64(E,v),E+=8}else if(N==="object")if(!v)G[E++]=192;else{if(a){let O=a.get(v);if(O){if(!O.id){let A=a.idsToInsert||(a.idsToInsert=[]);O.id=A.push(O)}G[E++]=214,G[E++]=112,at.setUint32(E,O.id),E+=4;return}else a.set(v,{offset:E-t})}let C=v.constructor;if(C===Object)_(v,!0);else if(C===Array){T=v.length,T<16?G[E++]=144|T:T<65536?(G[E++]=220,G[E++]=T>>8,G[E++]=T&255):(G[E++]=221,at.setUint32(E,T),E+=4);for(let O=0;O<T;O++)b(v[O])}else if(C===Map){T=v.size,T<16?G[E++]=128|T:T<65536?(G[E++]=222,G[E++]=T>>8,G[E++]=T&255):(G[E++]=223,at.setUint32(E,T),E+=4);for(let[O,A]of v)b(O),b(A)}else{for(let O=0,A=vl.length;O<A;O++){let M=pu[O];if(v instanceof M){let L=vl[O];if(L.write){L.type&&(G[E++]=212,G[E++]=L.type,G[E++]=0),b(L.write.call(this,v));return}let X=G,R=at,Z=E;G=null;let z;try{z=L.pack.call(this,v,V=>(G=X,X=null,E+=V,E>jr&&P(E),{target:G,targetView:at,position:E-V}),b)}finally{X&&(G=X,at=R,E=Z,jr=G.length-10)}z&&(z.length+E>jr&&P(z.length+E),E=c_(z,G,E,L.type));return}}_(v,!v.hasOwnProperty)}}else if(N==="boolean")G[E++]=v?195:194;else if(N==="bigint"){if(v<BigInt(1)<<BigInt(63)&&v>=-(BigInt(1)<<BigInt(63)))G[E++]=211,at.setBigInt64(E,v);else if(v<BigInt(1)<<BigInt(64)&&v>0)G[E++]=207,at.setBigUint64(E,v);else if(this.largeBigIntToFloat)G[E++]=203,at.setFloat64(E,Number(v));else throw new RangeError(v+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");E+=8}else if(N==="undefined")this.encodeUndefinedAsNil?G[E++]=192:(G[E++]=212,G[E++]=0,G[E++]=0);else if(N==="function")b(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+N)},_=this.useRecords===!1?this.variableMapSize?v=>{let N=Object.keys(v),T=N.length;T<16?G[E++]=128|T:T<65536?(G[E++]=222,G[E++]=T>>8,G[E++]=T&255):(G[E++]=223,at.setUint32(E,T),E+=4);let C;for(let O=0;O<T;O++)b(C=N[O]),b(v[C])}:(v,N)=>{G[E++]=222;let T=E-t;E+=2;let C=0;for(let O in v)(N||v.hasOwnProperty(O))&&(b(O),b(v[O]),C++);G[T+++t]=C>>8,G[T+t]=C&255}:v=>{let N=Object.keys(v),T,C=s.transitions||(s.transitions=Object.create(null)),O=0;for(let M=0,L=N.length;M<L;M++){let X=N[M];T=C[X],T||(T=C[X]=Object.create(null),O++),C=T}let A=C[Rs];if(A)A>=96&&h?(G[E++]=((A-=96)&31)+96,G[E++]=A>>5):G[E++]=A;else{A=s.nextId,A||(A=64),A<y&&this.shouldShareStructure&&!this.shouldShareStructure(N)?(A=s.nextOwnId,A<g||(A=y),s.nextOwnId=A+1):(A>=g&&(A=y),s.nextId=A+1);let M=N.highByte=A>=96&&h?A-96>>5:-1;C[Rs]=A,s[A-64]=N,A<y?(N.isShared=!0,s.sharedLength=A-63,i=!0,M>=0?(G[E++]=(A&31)+96,G[E++]=M):G[E++]=A):(M>=0?(G[E++]=213,G[E++]=114,G[E++]=(A&31)+96,G[E++]=M):(G[E++]=212,G[E++]=114,G[E++]=A),O&&(S+=w*O),x.length>=m&&(x.shift()[Rs]=0),x.push(C),b(N))}for(let M=0,L=N.length;M<L;M++)b(v[N[M]])},P=v=>{let N;if(v>16777216){if(v-t>Wm)throw new Error("Packed buffer would be larger than maximum buffer size");N=Math.min(Wm,Math.round(Math.max((v-t)*(v>67108864?1.25:2),4194304)/4096)*4096)}else N=(Math.max(v-t<<2,G.length-1)>>12)+1<<12;let T=new du(N);return at=new DataView(T.buffer,0,N),G.copy?G.copy(T,0,t,v):T.set(G.slice(t,v)),E-=t,t=0,jr=T.length-10,G=T}}useBuffer(r){G=r,at=new DataView(G.buffer,G.byteOffset,G.byteLength),E=0}};pu=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,Bs];vl=[{pack(n,r,e){let t=n.getTime()/1e3;if((this.useTimestamp32||n.getMilliseconds()===0)&&t>=0&&t<4294967296){let{target:o,targetView:i,position:s}=r(6);o[s++]=214,o[s++]=255,i.setUint32(s,t)}else if(t>0&&t<17179869184){let{target:o,targetView:i,position:s}=r(10);o[s++]=215,o[s++]=255,i.setUint32(s,n.getMilliseconds()*4e6+(t/1e3/4294967296>>0)),i.setUint32(s+4,t)}else if(isNaN(t)){if(this.onInvalidDate)return r(0),e(this.onInvalidDate());let{target:o,targetView:i,position:s}=r(3);o[s++]=212,o[s++]=255,o[s++]=255}else{let{target:o,targetView:i,position:s}=r(15);o[s++]=199,o[s++]=12,o[s++]=255,i.setUint32(s,n.getMilliseconds()*1e6),i.setBigInt64(s+4,BigInt(Math.floor(t)))}}},{pack(n,r,e){let t=Array.from(n),{target:o,position:i}=r(this.structuredClone?3:0);this.structuredClone&&(o[i++]=212,o[i++]=115,o[i++]=0),e(t)}},{pack(n,r,e){let{target:t,position:o}=r(this.structuredClone?3:0);this.structuredClone&&(t[o++]=212,t[o++]=101,t[o++]=0),e([n.name,n.message])}},{pack(n,r,e){let{target:t,position:o}=r(this.structuredClone?3:0);this.structuredClone&&(t[o++]=212,t[o++]=120,t[o++]=0),e([n.source,n.flags])}},{pack(n,r){this.structuredClone?qm(n,16,r):$m(bl?Buffer.from(n):new Uint8Array(n),r)}},{pack(n,r){let e=n.constructor;e!==Ym&&this.structuredClone?qm(n,uu.indexOf(e.name),r):$m(n,r)}},{pack(n,r){let{target:e,position:t}=r(1);e[t]=193}}];function qm(n,r,e,t){let o=n.byteLength;if(o+1<256){var{target:i,position:s}=e(4+o);i[s++]=199,i[s++]=o+1}else if(o+1<65536){var{target:i,position:s}=e(5+o);i[s++]=200,i[s++]=o+1>>8,i[s++]=o+1&255}else{var{target:i,position:s,targetView:a}=e(7+o);i[s++]=201,a.setUint32(s,o+1),s+=4}i[s++]=116,i[s++]=r,i.set(new Uint8Array(n.buffer,n.byteOffset,n.byteLength),s)}function $m(n,r){let e=n.byteLength;var t,o;if(e<256){var{target:t,position:o}=r(e+2);t[o++]=196,t[o++]=e}else if(e<65536){var{target:t,position:o}=r(e+3);t[o++]=197,t[o++]=e>>8,t[o++]=e&255}else{var{target:t,position:o,targetView:i}=r(e+5);t[o++]=198,i.setUint32(o,e),o+=4}t.set(n,o)}function c_(n,r,e,t){let o=n.length;switch(o){case 1:r[e++]=212;break;case 2:r[e++]=213;break;case 4:r[e++]=214;break;case 8:r[e++]=215;break;case 16:r[e++]=216;break;default:o<256?(r[e++]=199,r[e++]=o):o<65536?(r[e++]=200,r[e++]=o>>8,r[e++]=o&255):(r[e++]=201,r[e++]=o>>24,r[e++]=o>>16&255,r[e++]=o>>8&255,r[e++]=o&255)}return r[e++]=t,r.set(n,e),e+=o,e}function u_(n,r){let e,t=r.length*6,o=n.length-t;for(r.sort((i,s)=>i.offset>s.offset?1:-1);e=r.pop();){let i=e.offset,s=e.id;n.copyWithin(i+t,i,o),t-=6;let a=i+t;n[a++]=214,n[a++]=105,n[a++]=s>>24,n[a++]=s>>16&255,n[a++]=s>>8&255,n[a++]=s&255,o=i}return n}function Mo(n){if(n.Class){if(!n.pack&&!n.write)throw new Error("Extension has no pack or write function");if(n.pack&&!n.type)throw new Error("Extension has no type (numeric code to identify the extension)");pu.unshift(n.Class),vl.unshift(n)}Hm(n)}var Xm=new an({useRecords:!1}),d_=Xm.pack,p_=Xm.pack;var{NEVER:f_,ALWAYS:m_,DECIMAL_ROUND:h_,DECIMAL_FIT:y_}=gl,Km=512,g_=1024;var Zm=new an({structuredClone:!0});Mo({Class:Ue.prototype.constructor,type:1,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,Ue.prototype),n}});Mo({Class:ge.prototype.constructor,type:2,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,ge.prototype),n}});Mo({Class:Qe.prototype.constructor,type:3,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,Qe.prototype),n}});Mo({Class:Ls.prototype.constructor,type:4,write(n){return n.id},read(n){return new Ls(n)}});Mo({Class:Ds.prototype.constructor,type:5,write(n){return n.data},read(n){return new Ds(n)}});Mo({Class:He.prototype.constructor,type:6,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,He.prototype),n}});function x_(n){var r=0;if(n.length===0)return r;for(let e=0;e<n.length;e++){let t=n[e];r=(r<<5)-r+t,r=r&r}return r}function fu(n){if(ri(n))return n;if(Array.isArray(n))return n.map(fu);if(typeof n=="object"&&n!==null){let r={};for(let e of Object.keys(n).sort())r[e]=fu(n[e]);return Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r}else return n}var Sl;(t=>{function n(o){return Zm.pack(o)}t.serialize=n;function r(o){return Zm.unpack(o)}t.deserialize=r;function e(o){return x_(n(fu(o))).toString()}t.checksum=e})(Sl||(Sl={}));var Do="personal camera",Bo="a218fcc3-276b-49b9-b485-49037fd14f5f",oh=2960946,ft=5526619;var Qm;(e=>{function n(t,o){return t[0]===o[0]&&t[1]===o[1]}e.isEqual=n;function r(t,o,i){return[t[0]+(o[0]-t[0])*i,t[1]+(o[1]-t[1])*i]}e.lerp=r})(Qm||(Qm={}));var Eo;(a=>{function n(c,d){return c[0]===d[0]&&c[1]===d[1]&&c[2]===d[2]}a.isEqual=n;function r(c,d){return[c[0]+d[0],c[1]+d[1],c[2]+d[2]]}a.add=r;function e(c,d){return[c[0]-d[0],c[1]-d[1],c[2]-d[2]]}a.sub=e;function t(c,d){return[c[0]/d[0],c[1]/d[1],c[2]/d[2]]}a.div=t;function o(c,d){return[c[0]*d[0],c[1]*d[1],c[2]*d[2]]}a.mul=o;function i(c,d){return Math.hypot(c[0]-d[0],c[1]-d[1],c[2]-d[2])}a.dist=i;function s(c,d,l){return[c[0]+(d[0]-c[0])*l,c[1]+(d[1]-c[1])*l,c[2]+(d[2]-c[2])*l]}a.lerp=s})(Eo||(Eo={}));var Jm;(e=>{function n(t,o){return t[0]===o[0]&&t[1]===o[1]&&t[2]===o[2]&&t[3]===o[3]}e.isEqual=n;function r(t,o,i){return[t[0]+(o[0]-t[0])*i,t[1]+(o[1]-t[1])*i,t[2]+(o[2]-t[2])*i,t[3]+(o[3]-t[3])*i]}e.lerp=r})(Jm||(Jm={}));var Lo;(o=>{o.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function r(i,s){for(let a=0;a<16;a++)if(i[a]!==s[a])return!1;return!0}o.isEqual=r;function e(i){return i??o.identity}o.simplify=e;function t(i,s){let a=s.slice(0);for(var c=0,d=s.length;c<d;c+=3){let l=i[3]*s[c]+i[7]*s[c+1]+i[11]*s[c+2]+i[15];a[c]=(i[0]*s[c]+i[4]*s[c+1]+i[8]*s[c+2]+i[12])/l,a[c+1]=(i[1]*s[c]+i[5]*s[c+1]+i[9]*s[c+2]+i[13])/l,a[c+2]=(i[2]*s[c]+i[6]*s[c+1]+i[10]*s[c+2]+i[14])/l}return a}o.applyMatrix4=t})(Lo||(Lo={}));var St;(l=>{function n(u){return typeof u=="object"&&typeof u.r=="number"&&typeof u.g=="number"&&typeof u.b=="number"}l.isRGB=n,l.white={r:1,g:1,b:1},l.red={r:1,g:0,b:0},l.black={r:0,g:0,b:0};function o(u){return{r:Math.round(u.r*255),g:Math.round(u.g*255),b:Math.round(u.b*255),a:1}}l.toRgb255a1=o;function i(u){return{r:u.r,g:u.g,b:u.b}}l.clone=i;function s(u){return u=Math.floor(u),{r:(u>>16&255)/255,g:(u>>8&255)/255,b:(u&255)/255}}l.fromHex=s;function a(u){return Math.round(u.r*255)*65536+Math.round(u.g*255)*256+Math.round(u.b*255)}l.toHex=a;function c(u,p){return u.r===p.r&&u.g===p.g&&u.b===p.b}l.equals=c;function d(u,p,f){return{r:u.r+(p.r-u.r)*f,g:u.g+(p.g-u.g)*f,b:u.b+(p.b-u.b)*f}}l.lerp=d})(St||(St={}));var jt;(a=>{a.white={...St.white,a:1},a.transparent={...St.white,a:0};function e(c){return{r:c[0],g:c[1],b:c[2],a:c[3]}}a.from0to1=e;function t(c,d){return{...St.fromHex(c),a:d}}a.fromHexAndA=t;function o(c){return{r:Math.round(c.r*255),g:Math.round(c.g*255),b:Math.round(c.b*255),a:c.a}}a.toRgb255a1=o;function i(c,d){return St.equals(c,d)&&c.a===d.a}a.equals=i;function s(c,d,l){return{r:c.r+(d.r-c.r)*l,g:c.g+(d.g-c.g)*l,b:c.b+(d.b-c.b)*l,a:c.a+(d.a-c.a)*l}}a.lerp=s})(jt||(jt={}));var wl;(r=>r.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(wl||(wl={}));var eh;(r=>r.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(eh||(eh={}));var th;(r=>r.defaultData={control1:[.5,0],control2:[.5,1]})(th||(th={}));var rh;(i=>(i.linear=[0,0,1,1],i.ease=[.25,.1,.25,1],i.easeIn=[.42,0,1,1],i.easeOut=[0,0,.58,1],i.easeInOut=[.42,0,.58,1]))(rh||(rh={}));var wr;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function r(t){return e.all.includes(t)}e.is=r})(wr||(wr={}));var Ro;(o=>{o.DefaultUp=[0,1,0],o.DefaultTargetOffset=1e3,o.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:o.DefaultUp,isUpVectorFlipped:!1,targetOffset:o.DefaultTargetOffset};function t(i){return i.type==="PerspectiveCamera"?i.perspective.zoom:i.orthographic.zoom}o.getZoom=t})(Ro||(Ro={}));var kr;(e=>{function n(t,o=.1){return{disabled:!1,type:"linear",hideBase:!1,count:3,radial:{radius:Math.max(t[0],t[1])*2,start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[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"},linear:{scale:[1,1,1],rotation:[0,0,0],position:[t[0]+t[0]*o,0,0]},grid:{count:[2,2,2],size:t.map(i=>i*(1+o)),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"}}}e.defaultData=n;function r(t,o){let i={...t};if(v_.forEach(s=>{Object.assign(i,{[s]:o[s]??t[s]})}),i.radial={...t.radial},o.radial){let s=t.radial,a=o.radial;b_.forEach(c=>{Object.assign(i.radial,{[c]:a[c]??s[c]})})}if(i.linear={...t.linear},o.linear){let s=t.linear,a=o.linear;S_.forEach(c=>{Object.assign(i.linear,{[c]:a[c]??s[c]})})}if(i.grid={...t.grid},o.grid){let s=t.grid,a=o.grid;w_.forEach(c=>{Object.assign(i.grid,{[c]:a[c]??s[c]})})}if(i.toObject={...t.toObject},o.toObject){let s=t.toObject,a=o.toObject;__.forEach(c=>{Object.assign(i.toObject,{[c]:a[c]??s[c]})})}if(i.randomnessObject={...t.randomnessObject},o.randomnessObject){let s=t.randomnessObject,a=o.randomnessObject;P_.forEach(c=>{Object.assign(i.randomnessObject,{[c]:a[c]??s[c]})})}return i}e.merge=r})(kr||(kr={}));var _l;(t=>{t.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let r=["radial","linear","grid","toObject","randomnessObject"];function e(o,i){let s=[];o.count!==void 0&&s.push({type:0,path:i,props:{count:o.count}});for(let a of r){let c=o[a];c&&Object.keys(c).length>0&&s.push({type:0,path:[...i,a],props:c})}return s}t.toOps=e})(_l||(_l={}));var v_=["count"],b_=["radius","start","end","position","scale","rotation"],S_=["position","scale","rotation"],w_=["count","size"],__=["count","position","scale","rotation"],P_=["strength","scale","rotation","position","movement","seed","freqScale"];var Pl;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function r(t){return e.all.includes(t)}e.is=r})(Pl||(Pl={}));var Tl;(e=>{function n(t){return r(t)}e.defaultData=n;function r(t){if(t==="PointLight")return{type:t,color:jt.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(t==="SpotLight")return{type:t,color:jt.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(t==="DirectionalLight")return{type:t,color:jt.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(Tl||(Tl={}));var Go;(r=>r.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]})(Go||(Go={}));var mu;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function r(t,o){return t.castShadow===o.castShadow&&t.receiveShadow===o.receiveShadow}e.equals=r})(mu||(mu={}));var hu;(e=>{e.defaultData={flatShading:!1,wireframe:!1,side:0};function r(t,o){return t.flatShading===o.flatShading&&t.side===o.side&&t.wireframe===o.wireframe}e.equals=r})(hu||(hu={}));var Ol;(r=>r.defaultData={...hu.defaultData,...mu.defaultData})(Ol||(Ol={}));var ci;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(ci||(ci={}));var nh;(r=>{function n(e){return e==="texture"||e==="video"||e==="color"||e==="depth"||e==="normal"||e==="gradient"||e==="noise"||e==="fresnel"||e==="rainbow"||e==="toon"||e==="outline"||e==="transmission"||e==="matcap"||e==="displace"||e==="pattern"||e==="light"}r.is=n})(nh||(nh={}));function sh(n){return n.type!=="displace"}var ih;(r=>{function n(e){return e==="phong"||e==="toon"||e==="lambert"||e==="physical"}r.is=n})(ih||(ih={}));var ah=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],lh=["wrapping","image","video","name"],Ft;(o=>{function n(i,s){let{texture:a,...c}=s;if(Object.assign(i,c),a){let d=i.texture;d&&Object.assign(d,a)}}o.patch=n;function r(i,s){return i==="light"&&s?e(s):t(i)}o.defaultData=r;function e(i){let s={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(i){case"phong":return{...s,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...s,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...s,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...s,category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0,occlusion:!0}}}function t(i){let s={alpha:1,mode:0,isMask:!1,visible:!0};switch(i){case"texture":return{...s,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]},crop:!1};case"video":return{...s,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:ci.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!1};case"color":return{...s,type:"color",color:St.fromHex(ft)};case"depth":return{...s,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{...s,type:"normal",cnormal:[1,1,1]};case"gradient":return{...s,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{...s,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...St.fromHex(6710886),a:1},colorB:{...St.fromHex(6710886),a:1},colorC:{...St.fromHex(16777215),a:1},colorD:{...St.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"fresnel":return{...s,type:"fresnel",color:jt.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{...s,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...s,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:jt.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...s,type:"outline",outlineColor:jt.fromHexAndA(0,1),contourColor:jt.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{...s,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0]}};case"transmission":return{...s,type:"transmission",thickness:10,ior:1.5,roughness:1};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{...s,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...St.fromHex(0),a:1},colorB:{...St.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}}}})(Ft||(Ft={}));var Nt;(c=>{function n(d){return!d.layers.some(u=>u.data.type==="texture"&&u.data.projection!==0||u.data.type==="depth"&&!u.data.isWorldSpace||u.data.type==="noise"||u.data.type==="displace")}c.isMergable=n;function r(d){let l="";return d.layers.forEach(u=>{Object.entries(u.data).forEach(([p,f])=>{l+=`${p}${f}`,Array.isArray(f)?f.forEach(m=>l+=`${m}`):typeof f=="object"?Object.values(f).forEach(m=>{typeof m=="number"?l+=`${m.toFixed(4)}`:l+=`${m}`}):l+=`${f}`})}),l}c.getHash=r;function e(){return{layers:new ge}}c.defaultEmptyData=e;function t(d="layer1",l="layer2"){return i("phong",d,l)}c.defaultData=t;function o(d,l){return{...d,name:l}}c.withName=o;function i(d,l="layer1",u="layer2"){let p=new ge;return p.push({fi:0,data:Ft.defaultData("light",d),id:l}),p.push({fi:1,data:Ft.defaultData("color"),id:u}),{layers:p}}c.defaultTwoLayerData=i;function s(d,l="phong",u="layer1",p="layer2"){let f=Ft.defaultData("texture");Object.assign(f.texture,{image:d});let m=new ge;return m.push({fi:0,data:f,id:u}),m.push({fi:1,data:Ft.defaultData("light",l),id:p}),{layers:m}}c.defaultTwoLayerTextureData=s;function a(d,l="phong",u="layer1",p="layer2"){let f=Ft.defaultData("video");Object.assign(f.texture,{video:d});let m=new ge;return m.push({fi:0,data:f,id:u}),m.push({fi:1,data:Ft.defaultData("light",l),id:p}),{layers:m}}c.defaultTwoLayerVideoTextureData=a})(Nt||(Nt={}));var ui;(r=>{function n(){return{points:new ge,roundness:0,shapeHoles:[],isClosed:!1}}r.defaultData=n})(ui||(ui={}));var di;(r=>{function n(){return{points:new ge,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}r.defaultData=n})(di||(di={}));var yu={type:"Ellipse",width:100,height:100,spikes:16,angle:360,innerRadius:0};var Al;(r=>{function n(e,t){let o={...e};return T_.forEach(i=>{Object.assign(o,{[i]:t[i]??e[i]})}),o}r.merge=n})(Al||(Al={}));var Cl={shape:yu,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},T_=["depth","offset","angle","twist","startScale","endScale"];var Gs;(e=>{function n(t){return t==="PolygonGeometry"||t==="RectangleGeometry"||t==="StarGeometry"||t==="TriangleGeometry"||t==="EllipseGeometry"}e.is2DParametricMesh=n;function r(t){return t==="PolygonGeometry"||t==="PolygonGeometry"||t==="RectangleGeometry"||t==="StarGeometry"||t==="TriangleGeometry"||t==="EllipseGeometry"||t==="PathGeometry"||t==="VectorGeometry"||t==="ConeGeometry"||t==="CubeGeometry"||t==="CylinderGeometry"||t==="DodecahedronGeometry"||t==="HelixGeometry"||t==="IcosahedronGeometry"||t==="LatheGeometry"||t==="PyramidGeometry"||t==="SphereGeometry"||t==="PlaneGeometry"||t==="BackdropGeometry"||t==="TorusGeometry"||t==="TorusKnotGeometry"||t==="BooleanGeometry"||t==="TextGeometry"}e.isParametricMesh=r})(Gs||(Gs={}));var Nl;(r=>{function n(e,t){let o={...e};return Object.assign(o,t),o.type==="PathGeometry"&&"extrusion"in t&&t.extrusion&&(o.extrusion={...e.extrusion},Object.assign(o.extrusion,Al.merge(o.extrusion,t.extrusion))),o}r.merge=n})(Nl||(Nl={}));var Vo;(r=>{function n(e){if(e==="RectangleGeometry")return{width:320,height:320,type:e,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="PathGeometry")return{type:e,width:1,height:1,depth:1,path:di.defaultData(),extrusion:Cl};if(e==="VectorGeometry")return{width:1,height:1,type:e,subdivisions:12,shape:ui.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="BooleanGeometry")return{type:e,operation:2,width:0,height:0,depth:0,phongAngle:35};if(e==="TextGeometry")return{type:e,width:100,height:100,depth:0,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.2,letterSpacing:0,text:"",textTransform:1,font:"Roboto_regular",extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="SphereGeometry")return{type:"SphereGeometry",width:100,height:100,depth:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI};throw new Error("not implemented")}r.defaultData=n})(Vo||(Vo={}));var Il;(r=>r.defaultData={enabled:!1,useBackgroundColor:!1,color:St.white,near:.1,far:2e3})(Il||(Il={}));var Ml;(e=>{let n={opacity:1,blendFunction:13,enabled:!1};e.defaultData={enabled:!1,pixelation:{...n,blendFunction:16,granularity:15},bloom:{...n,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...n,offset:[2,2]},vignette:{...n,darkness:1,offset:0},hueSaturation:{...n,hue:3,saturation:0},brightnessContrast:{...n,brightness:.25,contrast:0},depthOfField:{...n,focalLength:2,focusDistance:2,bokehScale:2},noise:{...n,blendFunction:16}}})(Ml||(Ml={}));var gu;(r=>r.defaultData={softShadowQuality:"low"})(gu||(gu={}));var xu;(r=>r.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(xu||(xu={}));var vu;(r=>r.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(vu||(vu={}));var Vs;(r=>r.defaultData={usePhysics:!1,gravity:-10})(Vs||(Vs={}));var bu;(r=>r.defaultData={playCamera:Do,gameControlObject:null})(bu||(bu={}));var El;(r=>r.defaultData={backgroundColor:jt.fromHexAndA(oh,1),postprocessing:Ml.defaultData,fog:Il.defaultData,globalPhysics:Vs.defaultData,ambient:xu.defaultData,ao:vu.defaultData,shadow:gu.defaultData,publish:bu.defaultData})(El||(El={}));var ch;(e=>{function n(t){return t==="Component"||t==="Instance"}e.isComponentRelated=n;function r(t){return t==="Empty"||t==="Instance"}e.isEmptyOrComponent=r})(ch||(ch={}));var pi;(o=>{o.identity={...wl.identity,hiddenMatrix:Lo.identity};function r(i){return{position:i.position,rotation:i.rotation,scale:i.scale,hiddenMatrix:i.hiddenMatrix}}o.fromObject=r;function e(i,s){return{position:s?.position||i.position,rotation:s?.rotation||i.rotation,scale:s?.scale||i.scale,hiddenMatrix:s?.hiddenMatrix||i.hiddenMatrix}}o.merge=e;function t(i,s){return Kd({position:Eo.isEqual(i.position,s.position)?void 0:s.position,rotation:Eo.isEqual(i.rotation,s.rotation)?void 0:s.rotation,scale:Eo.isEqual(i.scale,s.scale)?null:s.scale,hiddenMatrix:Lo.isEqual(i.hiddenMatrix,s.hiddenMatrix)?void 0:s.hiddenMatrix})}o.diff=t})(pi||(pi={}));var It;(r=>r.defaultData={states:new ge,events:new ge,visible:!0,raycastLock:!1,physics:Go.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...pi.identity,cloner:null})(It||(It={}));var uh;(r=>r.defaultData={type:"Empty",...It.defaultData})(uh||(uh={}));var dh;(r=>r.defaultData={type:"Component",...It.defaultData})(dh||(dh={}));var ln;(r=>r.defaultData={type:"Mesh",...It.defaultData,...Ol.defaultData})(ln||(ln={}));var cn;(r=>r.defaultData={...It.defaultData,...pi.identity,position:[0,0,Ro.DefaultTargetOffset],...Ro.defaultData})(cn||(cn={}));var Ll;(e=>{function n(t){return{...It.defaultData,...Tl.defaultData(t)}}e.defaultData=n,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(Ll||(Ll={}));var fi;(e=>{function n(t,o,i=0){for(;i<o.length;){let s=t?t[o[i]]:void 0;if(o.length===i+1)return s;if(s)t=s.descendants,i+=1;else return}}e.resolveWithDes=n;function r(t,o,i=0){let s=n(t,o,i);if(s){let a=Object.keys(s);if(a.length===1&&a[0]==="descendants")return}return s}e.resolve=r})(fi||(fi={}));var Ur;(i=>{i.rootOverrideProps=["physics","events"],i.compositeNonOptionalOverrideProps=["geometry"],i.compositeEntireOverrideOverrideProps=["material"];function t(s,a){return{...It.defaultData,...a,component:s,overrides:new He,physics:void 0,events:void 0,type:"Instance"}}i.ofComponent=t;function o(s){let a=pi.fromObject(s.data);return t(s.id,a)}i.fromComponentData=o})(Ur||(Ur={}));var fo;(r=>r.defaultData={type:"Page",...It.defaultData,physics:{...Go.defaultData,fusedBody:!1},...El.defaultData,camera:cn.defaultData})(fo||(fo={}));var Dl;(i=>(i.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:Lo.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:Go.defaultData,states:new ge,events:new ge,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...Ro.defaultData},i.KeysByResetCategory={States:["states"],Events:["events"],Material:["material","materials"],Geometry:["geometry"],Position:["position"],Rotation:["rotation"],Scale:["scale"],Transform:["position","scale","rotation","hiddenMatrix"],Name:["name"],Visibility:["visible","raycastLock","flatShading","wireframe","side"],Shadows:["castShadow","receiveShadow"],Cloner:["cloner"],Physics:["physics"]},i.defaultMeshObject={name:"Rectangle",...It.defaultData,...ln.defaultData,geometry:Vo.defaultData("RectangleGeometry"),material:Nt.defaultTwoLayerData("phong","layer1","layer2")},i.defaultBooleanObject={name:"Boolean",...It.defaultData,...ln.defaultData,geometry:Vo.defaultData("BooleanGeometry"),material:Nt.defaultTwoLayerData("phong","layer1","layer2")},i.defaultTextObject={name:"Text",...It.defaultData,...ln.defaultData,geometry:Vo.defaultData("TextGeometry"),material:Nt.defaultTwoLayerData("phong","layer1","layer2")}))(Dl||(Dl={}));var un;(o=>{function n(i,s){let a={name:s};return i.type==="Mesh"?(a.geometry={},"material"in i&&(a.material={layers:new He}),"materials"in i&&(a.materials=i.materials.map(c=>({layers:new He})))):wr.is(i.type)&&(a.perspective={},a.orthographic={}),a}o.newEmpty=n;function r(i,s){if(s===void 0)return i;let a={...i};return"material"in a&&"material"in s&&s.material&&(a.material=ai(a.material,c=>{if(typeof c!="string")for(let[d,l]of Object.entries(s.material.layers)){let u=c.layers.data(d);u&&Ft.patch(u,l)}}).data),a.materials&&s.materials&&(a.materials=ai(a.materials,c=>{for(let d=0;d<a.materials.length;d++){let l=s.materials[d];if(typeof l!="string")for(let[u,p]of Object.entries(l.layers)){let f=c[d]?.layers?.data(u);f&&Ft.patch(f,p)}}}).data),a}function e(i,s){let a,c=[],d={orthographic:0,perspective:0,geometry:0};function l(u,p){for(let[f,m]of Object.entries(p.layers)){let{texture:h,...y}=m;if(h!==void 0&&Object.keys(h).length>0){let g={path:[...u,"layers",f,"texture"],props:h,type:0};c.push(g)}if(Object.keys(y).length>0){let g={path:[...u,"layers",f],props:y,type:0};c.push(g)}}}for(let[u,p]of Object.entries(s))if(u!=="name")if(u==="cloner")c.push(..._l.toOps(p,["cloner"]));else if(u==="pathSnapping")c.push({path:[u],props:{slide:p.slide,offset:p.offset},type:0});else if(u==="material")l(["material"],p);else if(u==="materials")for(let[f,m]of Object.entries(p))l(["materials",f],m);else if(d[u]===0){if(u==="geometry"&&p.extrusion!==void 0){let f={path:[u,"extrusion"],props:p.extrusion,type:0};c.push(f),p={...p},delete p.extrusion}if(Object.keys(p).length>0){let f={path:[u],props:p,type:0};c.push(f)}}else a===void 0&&(a={path:[],props:{},type:0},c.push(a)),a.props[u]=p;return c}o.toOps=e;function t(i,s){if(s===void 0)return i;let a={...i};if(Object.assign(a,pi.merge(a,s)),Object.assign(a,{pathSnapping:Object.assign({},a.pathSnapping,{slide:s.pathSnapping?.slide??a.pathSnapping?.slide??0,offset:s.pathSnapping?.offset??a.pathSnapping?.offset??0})}),wr.is(i.type)){a.orthographic={...a.orthographic},a.perspective={...a.perspective};let c=s;c.orthographic?.zoom!==void 0&&(a.orthographic.zoom=c.orthographic.zoom),c.perspective?.zoom!==void 0&&(a.perspective.zoom=c.perspective.zoom),c.isUpVectorFlipped!==void 0&&(a.isUpVectorFlipped=c.isUpVectorFlipped),c.targetOffset!==void 0&&(a.targetOffset=c.targetOffset)}else if(i.type==="Mesh")"geometry"in s&&Object.assign(a,{geometry:Nl.merge(a.geometry,s.geometry)}),(s.material||s.materials)&&(a=r(a,s)),a.cloner&&"cloner"in s&&Object.assign(a,{cloner:kr.merge(a.cloner,s.cloner)});else if(i.type==="Empty")a.cloner&&"cloner"in s&&Object.assign(a,{cloner:kr.merge(a.cloner,s.cloner)});else if(Pl.is(i.type)){let c=s;c.intensity!==void 0&&(a.intensity=c.intensity),c.color!==void 0&&(typeof c.color=="string"?a.color=c.color:a.color=St.clone(c.color))}return a}o.patch=t})(un||(un={}));var mi;(r=>r.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,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,isTouchZoom:!0,orbitTouches:2,panTouches:3,resetHoverEffectOnPointerLeave:!0})(mi||(mi={}));var Hr;(r=>r.defaultData={orbitControls:mi.defaultData,playPage:Bo,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((e,t)=>{let o=0,i=0;return t<5?i=-30:t<10&&(i=30),t===0||t===10||t===5?o=30:(t===4||t===11||t===9)&&(o=-30),[120,[o,i],"show"]}),settings:{image:{format:"jpg",ratio:1},video:{format:"mp4",imageFormat:"jpg",fps:30,mbps:80,ratio:Math.max(1,typeof window<"u"?Math.floor(window.devicePixelRatio):1),stopMode:"manual",duration:5e3},web:{logo:!0,compress:!0,preset:1,preload:!0,hint:!1}},stopRaycast:!0,hdTransmission:!1})(Hr||(Hr={}));var Su;(r=>r.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(Su||(Su={}));var wu;(r=>r.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(wu||(wu={}));var zo;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...Su.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:wu.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(zo||(zo={}));var ph;(e=>{function n(t){return t.find(o=>o.data.type==="Page"&&o.data.globalPhysics.usePhysics)!==void 0}e.physicsEnabled=n;function r(t,o,i){t.traverseFrom(o,(s,a)=>{if(a.type==="Instance"){let c=t.data(a.component);c&&i(s,a,c.events)}else i(s,a,a.events)})}e.traverseModuleInstances=r})(ph||(ph={}));var Bl;(a=>{a.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222";function r(c={withLight:!0,withSquare:!0}){let d=[],l=Dl.defaultMeshObject;c.withLight===!0&&d.push({fi:-1,data:Ll.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]}),c.withSquare===!0&&d.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:l,children:[]});let u=new Qe;return u.push({fi:1,id:Bo,data:{...fo.defaultData,name:"Scene 1"},children:d}),u}a.defaultData={objects:r(),publish:Hr.defaultData,styles:zo.defaultData()},a.emptyDataWithoutPage=function(){return{objects:new Qe,publish:Hr.defaultData,styles:zo.defaultData()}},a.emptyDataWithPage=function(c){return{objects:r(c),publish:Hr.defaultData,styles:zo.defaultData()}};function i(c){return{...a.defaultData,objects:br(c,Qe.prototype)}}a.withObjs=i;function s(c,d){return i([{id:c,data:d,children:[],fi:0}])}a.withObj=s})(Bl||(Bl={}));var hi;(r=>r.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(hi||(hi={}));var Rl;(t=>{function n(){let o={};return o["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},br(o,Ue.prototype)}t.defaultColors=n;function r(o){let i={};return o?.withAITexture&&(i["a1b10010-844c-a8a3-11ec-0242ac2011ec"]={...hi.emptyImage,name:"AI generated image"}),br(i,Ue.prototype)}t.defaultImages=r;function e(){return{materials:new Ue,images:new Ue,videos:new Ue,colors:new Ue,audios:new Ue,fonts:new Ue}}t.emptyData=e})(Rl||(Rl={}));var js=require("three");var Gl;(r=>r.list=["idle","move","jump","run"])(Gl||(Gl={}));var Vl;(e=>(e.defaultColliderData={type:"capsule",height:200,radius:50,position:[0,0,0],rotation:[0,0,0]},e.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:e.defaultColliderData,colliderHelperVisible:!0,collisionEnabled:!0,jumpPower:100,resetYPosition:3e3,alignToGround:!1,autoOrientMove:!0,orientWith:"camera",orientMode:"radial",delayPosCamera:.3,delayRotCamera:.3,camera:"",cameraXAxis:"Limit",cameraYAxis:"Free",cameraRotXLimits:[0,Math.PI/2],cameraRotYLimits:[-Math.PI/2,Math.PI/2],gameActions:{idle:new ge,move:new ge,jump:new ge,run:new ge},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:jt.fromHexAndA(3728051,1)}}))(Vl||(Vl={}));function fh(n){n.layers.forEach(r=>{if(r.type==="depth"&&r.colorA!==void 0){let e=r.colorA,t=r.colorB,o=[[e.r,e.g,e.b,e.a],[t.r,t.g,t.b,t.a]],i=[0,1];for(let a=2;a<10;a++)o.push(o[1]),i.push(1);let s={...Sr(ut(r),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,r.near),far:Math.max(0,r.far),colors:o,steps:i,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(r,s)}else if(r.type==="depth"&&r.gradientType===1&&(r.near<0||r.far<0)){let e={...ut(r),near:Math.max(r.near,0),far:Math.max(r.far,0)};Object.assign(r,e)}})}function mo(n,r){Object.values(n.shared.materials).forEach(e=>r(e))}function ho(n,r){n.scene.objects.traverse((e,t)=>{"materials"in t?t.materials.forEach((o,i)=>{o===void 0&&(t.materials[i]=Nt.defaultData(),o=t.materials[i]),typeof o!="string"&&r(o)}):"material"in t?typeof t.material!="string"&&(t.material===void 0&&(t.material=Nt.defaultData()),r(t.material)):t.type==="Mesh"&&(t.material===void 0&&(t.material=Nt.defaultData()),r(t.material)),"overrides"in t&&Object.values(t.overrides).forEach(o=>{o.material&&typeof o.material!="string"&&r(o.material)})})}function O_(n){Object.assign(n.scene.publish,{orbitControls:{...mi.defaultData,...ut(n.scene.publish.orbitControls)}})}function A_(n){Object.assign(n.scene.publish.settings,{video:{...Hr.defaultData.settings.video,...ut(n.scene.publish.settings.video)}})}function C_(n){function r(e){if(e.layers){for(let t of Object.values(e.layers))if(t){for(let[o,i]of Object.entries(t))if((ah.includes(o)||typeof i=="boolean")&&delete t[o],o==="texture")for(let[s,a]of Object.entries(i))(lh.includes(s)||typeof a=="boolean")&&delete i[s]}}}n.scene.objects.traverse((e,t)=>{t.states.forEach(o=>{let i=o;i.material?r(i.material):i.materials&&i.materials.forEach(s=>{r(s)})})})}function N_(n){n.scene.publish.withBackground=!0}function I_(n){n.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function M_(n){n.scene.objects.traverse((r,e)=>{let t=e.cloner;t&&(t.radial.scale=t.radial.scale.map(o=>o+1),t.linear.scale=t.linear.scale.map(o=>o+1))})}function E_(n){n.scene.objects.traverse((r,e)=>{let t=e.geometry;t&&(t.type==="DodecahedronGeometry"||t.type==="IcosahedronGeometry")&&(t.detail=Math.round(t.detail))})}function L_(n){n.scene.objects.traverse((r,e)=>{let t=n.scene.objects.unproxy().parent(r);if(t){let o=ut(n.scene.objects.data(t));o&&o.type==="Mesh"&&o.geometry.type==="BooleanGeometry"&&e.type==="Mesh"&&(e.visible=ut(e).booleanExclude!==!0)}})}function D_(n){n.scene.objects.traverse((r,e)=>{if(e.type==="Mesh"){let t=e;e.geometry.type==="NonParametricGeometry"?t.material!==void 0&&delete t.material:t.materials!==void 0&&delete t.materials}})}function B_(n){function r(t){Object.setPrototypeOf(t,He.prototype),t.texture&&Object.setPrototypeOf(t.texture,He.prototype)}function e(t){Object.setPrototypeOf(t,He.prototype);for(let o in t)r(t[o])}n.scene.objects.traverse((t,o)=>{o.states.forEach(i=>{let s=i;if(s.material){let a=ut(s.material).layers;e(a),s.material.layers=a}if(s.materials)for(let a=0;a<s.materials.length;a++){let c=s.materials[a],d=ut(c).layers;e(d),c.layers=d}})})}function mh(n){n.layers===void 0&&Object.assign(n,Nt.defaultTwoLayerData("lambert"))}function _u(n){!n.layers||n.layers.forEach(r=>{if(r.type==="depth"&&r.colors.length===10){let e=[...r.colors];e.push(r.colors[9]);let t=[...r.steps];t.push(r.steps[9]);let o={...ut(r),colors:e,steps:t};Object.assign(r,o)}})}function R_(n){n.scene.objects.traverse((r,e)=>{e.type==="Mesh"&&(e.geometry.type==="BooleanGeometry"||e.geometry.type==="SubdivGeometry")&&(e.geometry.phongAngle=35)})}function hh(n){n.scene.objects.traverse((r,e)=>{"materials"in e?e.materials.forEach(t=>{typeof t!="string"&&_u(t)}):"material"in e&&typeof e.material!="string"&&_u(e.material)}),Object.values(n.shared.materials).forEach(r=>_u(r))}function G_(n){n.scene.environment.ambientLight.softShadows=!1,n.scene.environment.ambientLight.softShadowQuality="low",n.scene.objects.traverse((r,e)=>{(e.type==="DirectionalLight"||e.type==="SpotLight")&&(e.shadowResolution=1024,e.shadowRadius=1,e.depth=1e5)}),n.shared.penumbraSize=new Array(5).fill(.5)}function V_(n){n.shared.audios=br({},Ue.prototype)}function z_(n){n.shared.videos=br({},Ue.prototype)}function j_(n){let r=n.shared.materials;Object.entries(r).forEach(([e,t])=>{if(!t.layers){let o={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(r,{[e]:o})}})}function F_(n){Object.entries(ut(n.shared.images)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete n.shared.images[t]}),Object.entries(ut(n.shared.audios)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete n.shared.audios[t]})}function k_(n){n.scene.publish.settings.web.preload=!1}function yh(n){n.layers&&n.layers.forEach(r=>{r.type==="depth"&&r.num!==void 0&&(r.colors=r.colors.slice(0,r.num),r.steps=r.steps.slice(0,r.num),delete r.num)})}function gh(n){n.layers&&n.layers.forEach(r=>{sh(r)&&r.isMask===void 0&&(r.isMask=!1),(r.type==="texture"||r.type==="video")&&r.blending===void 0&&(r.blending=0),(r.type==="noise"||r.type==="displace"&&r.displacementType==="noise")&&(r.voronoiStyle===void 0&&(r.voronoiStyle=0),r.highCut===void 0&&(r.highCut=1),r.lowCut===void 0&&(r.lowCut=0),r.smoothness===void 0&&(r.smoothness=.3),r.seed===void 0&&(r.seed=0),r.quality===void 0&&(r.quality=1))})}function U_(n){n.shared.fonts=br({},Ue.prototype)}function H_(n){return n.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(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function W_(n){let r=[];n.scene.objects.traverse((e,t)=>{let o=t;if(o.type==="TextFrame"){let i=Nt.defaultTwoLayerData("phong"),s=typeof o.color=="string"?n.shared.colors[o.color]:o.color;i.layers[1].data.color={r:s.r,g:s.g,b:s.b},i.layers[1].data.alpha=o.alpha;let a=H_(o.font);n.shared.fonts[a]===void 0&&(n.shared.fonts[a]={name:a});let c={name:o.name,...It.defaultData,...ln.defaultData,flatShading:!1,wireframe:!1,geometry:{...Vo.defaultData("TextGeometry"),width:o.width,height:o.height,font:a,depth:0,horizontalAlign:o.horizontalAlign,verticalAlign:o.verticalAlign,fontSize:o.fontSize*1.40625,lineHeight:o.lineHeight/1.40625,letterSpacing:o.letterSpacing-1,text:o.text,textTransform:o.textTransform,extrudeBevelSize:0,extrudeBevelSegments:1},material:i,states:ut(o.states),events:ut(o.events),visible:o.visible,raycastLock:o.raycastLock,position:o.position,rotation:o.rotation,scale:o.scale,hiddenMatrix:o.hiddenMatrix},d=ut(n.scene.objects).parent(e);n.scene.objects.insertAfter(d??null,e,[{id:e+"new",data:c,children:[]}]),r.push(e)}}),r.forEach(e=>{n.scene.objects.delete(e)})}function q_(n){let r={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};n.scene.objects.traverse((e,t)=>{t.events.forEach(o=>{if(!!r[Number(o.type)])if(Object.assign(o,{type:r[Number(o.type)]}),o.type==="Audio"&&"audioEvent"in o&&(Object.assign(o,{playAudio:o.audioEvent}),delete o.audioEvent),o.type==="GameControl")Object.assign(o,{gameActions:{idle:new ge,move:new ge,jump:new ge}});else{let i=new ge;Object.assign(o,{actions:i}),(o.type==="MouseDown"||o.type==="MouseUp"||o.type==="KeyDown"||o.type==="KeyUp")&&"url"in o&&i.push({fi:0,id:js.MathUtils.generateUUID(),data:{type:"Link",url:o.url,delay:0}}),"targets"in o&&(o.targets.forEach((s,a,c)=>{let d={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},l={easing:s.easing,duration:s.duration};s.easing===6?Object.assign(l,Sr(s,"mass","stiffness","damping","velocity")):s.easing===5&&Object.assign(l,{control1:{...s.control1},control2:{...s.control2}});let u={repeat:s.repeat?-1:0,delay:s.delay,delayDirection:s.delayDirection,direction:s.cycle&&s.rewind?"pingpong-rewind":s.cycle?"pingpong":"normal"},p={state:s.state,...u,...l},f={allowSlerp:!0,type:"Transition",object:s.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new ge({fi:0,id:js.MathUtils.generateUUID(),data:d},{fi:1,id:js.MathUtils.generateUUID(),data:p})};i.push({fi:c,id:a,data:f})}),delete o.targets)}})})}function $_(n){n.scene.objects.traverse((r,e)=>{function t(o,i){let s=new ge,a=[];if(e.events.forEach((c,d,l)=>{if(c.type==="Audio"&&c.trigger===i){let u;a.push(d),c.interaction==="play"?u={...Sr(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")&&(u={...Sr(c,"interaction","delay","object","playAudio"),type:"Audio"}),u&&s.push({fi:l,id:d,data:u})}}),a.forEach(c=>e.events.delete(c)),s.length){let c=e.events.find(d=>d.type===o)?.data;c?"actions"in c&&c.actions.insertBefore(null,s):e.events.insertBefore(null,[{id:js.MathUtils.generateUUID(),data:{type:o,actions:s}}])}}t("Start","start"),t("MouseDown","mouseDown"),t("MouseUp","mouseUp"),t("KeyDown","keyDown"),t("KeyUp","keyUp")})}function xh(n){let r=n.layers.find(e=>e.type==="light")?.data;if(r?.category==="basic"){let e=Ft.defaultData("light","phong"),t=r;Object.assign(t,e),t.visible=!1}}function vh(n){mo(n,xh),ho(n,xh)}function Y_(n){n.scene.objects.traverse((r,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(e.geometry.scaleBaked||(e.geometry.scaleBaked=[1,1,1]))})}function X_(n){n.scene.objects.traverse((r,e)=>{(e.type==="Empty"||e.type==="Mesh")&&e.cloner&&!e.cloner.randomnessObject&&!e.cloner.toObject&&!e.cloner.randomness&&(e.cloner={...e.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"}})})}function K_(n){n.scene.objects.traverse((r,e)=>{e.type==="Mesh"&&e.geometry.type==="NonParametricGeometry"&&!("material"in e)&&!("materials"in e)&&(e.material=Nt.defaultTwoLayerData("phong"))})}function Z_(n){n.scene.publish.orbitControls.autoZoom===void 0&&(n.scene.publish.orbitControls.autoZoom=!1),n.scene.objects.traverse((r,e)=>{(e.type==="OrthographicCamera"||e.type==="PerspectiveCamera")&&(e.orthographic.autoZoom===void 0&&(e.orthographic.autoZoom=!1),e.orthographic.autoZoomFrustumSize===void 0&&(e.orthographic.autoZoomFrustumSize=790))})}function Q_(n){n.scene.objects.traverse((r,e)=>{e.pathSnapping===void 0&&(e.pathSnapping={pathId:null,slide:0,offset:0,orientation:"tangential"}),e.pathSnapping.offset===void 0&&(e.pathSnapping.offset=0)})}function J_(n){n.scene.publish.mouseEventTarget===void 0&&(n.scene.publish.mouseEventTarget="canvas"),n.scene.publish.settings.web.hint===void 0&&(n.scene.publish.settings.web.hint=!1)}function eP(n){let{video:r}=n.scene.publish.settings;r.format==="gif"&&r.fps>48&&(r.fps=15)}function tP(n){n.scene.objects.traverse((r,e)=>{e.events.forEach(t=>{t.type==="GameControl"&&(t.resetYPosition=Math.abs(t.resetYPosition-e.position[1]))})})}function rP(n){let r=n.scene.environment.usePhysics;n.scene.objects.traverse((e,t)=>{r&&t.physics===null?t.collision=!1:t.collision="visibility"})}function oP(n){n.scene.objects.traverse((r,e)=>{e.events.forEach(t=>{t.type==="GameControl"&&(t.navmesh=Vl.defaultDataThirdPerson.navmesh)})})}function nP(n){n.scene.styles||(n.scene.styles=zo.defaultData())}function bh(n){n.layers.forEach(r=>{r.type==="light"&&r.category!=="toon"&&r.occlusion===void 0&&(r.occlusion=!0)})}function iP(n){n.scene.environment.ambientLight.occlusion===void 0&&(n.scene.environment.ambientLight.occlusion=!1),n.scene.environment.ambientLight.aoFullRes===void 0&&(n.scene.environment.ambientLight.aoFullRes=!1),n.scene.environment.ambientLight.radius===void 0&&(n.scene.environment.ambientLight.radius=256),n.scene.environment.ambientLight.bias===void 0&&(n.scene.environment.ambientLight.bias=.5),n.scene.environment.ambientLight.aoColor===void 0&&(n.scene.environment.ambientLight.aoColor={r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}),ho(n,bh),mo(n,bh)}function sP(n){n.scene.objects.traverse((r,e)=>{e.events.forEach(t=>{t.type==="GameControl"&&Object.assign(t.gameActions,{run:new ge})})})}function aP(n){n.scene.objects.traverse((r,e)=>{e.events.forEach(t=>{t.type==="GameControl"&&(t.keyAssignments=[...t.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function Sh(n){n.layers&&n.layers.forEach(r=>{r.type==="light"&&r.bumpMapIntensity===void 0&&(r.bumpMapIntensity=5)})}function wh(n,r){if(r<1&&(ho(n,fh),mo(n,fh),n.schema=1),r<2&&(O_(n),n.schema=2),r<3&&(C_(n),n.schema=3),r<4&&(N_(n),n.schema=4),r<5&&(I_(n),n.schema=5),r<6&&(M_(n),n.schema=6),r<7&&(E_(n),n.schema=7),r<8&&(n.schema=8),r<9&&(hh(n),n.schema=9),r<10&&(R_(n),n.schema=10),r<11&&(G_(n),n.schema=11),r<12&&(hh(n),n.schema=12),r<13&&(V_(n),n.schema=13),r<14&&(j_(n),n.schema=14),r<15&&(F_(n),n.schema=15),r<16&&(k_(n),n.schema=16),r<17&&(ho(n,yh),mo(n,yh),n.schema=17),r<18&&(ho(n,mh),mo(n,mh),n.schema=18),r<19&&(A_(n),n.schema=19),r<20&&(U_(n),W_(n),n.schema=20),r<21&&(q_(n),$_(n),n.schema=21),r<22&&(vh(n),n.schema=22),r<23&&(Y_(n),n.schema=23),r<24&&(X_(n),n.schema=24),(r<25||n.shared.videos===void 0)&&(z_(n),r<25&&(n.schema=25)),r<26&&(L_(n),n.schema=26),r<27&&(D_(n),n.schema=27),r<28&&(vh(n),n.schema=28),r<29&&(B_(n),n.schema=29),r<30&&(K_(n),n.schema=30),r<31&&(Z_(n),n.schema=31),r<33&&(Q_(n),n.schema=33),r<34&&(J_(n),n.schema=34),r<35&&(eP(n),n.schema=35),r<36&&(tP(n),n.schema=36),r<37&&(rP(n),n.schema=37),r<38&&(ho(n,gh),mo(n,gh),n.schema=38),r<39&&(oP(n),n.schema=39),r<40&&(nP(n),n.schema=40),r<41&&(iP(n),n.schema=41),r<42&&(sP(n),n.schema=42),r<43&&(aP(n),n.schema=43),r<99){ho(n,Sh),mo(n,Sh),n.scene.publish.playCamera===null&&(n.scene.publish.playCamera=Do);let e=ut(n.scene.objects),t=n.scene.objects;n.scene.publish.playPage=Bo,t.insertBefore(null,null,[{id:Bo,data:{...fo.defaultData,backgroundColor:n.scene.backgroundColor,fog:n.scene.fog,postprocessing:n.scene.postprocessing,ao:Sr(n.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:n.scene.publish.playCamera,gameControlObject:n.scene.publish.gameControlObject},shadow:Sr(n.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...Vs.defaultData,...Sr(n.scene.environment,"usePhysics","gravity")},camera:ut(n.scene.ownerCamera)??fo.defaultData.camera,name:"Scene"},children:[]}]);for(let s of e)s.id!==Bl.TRASH_CAN_ID&&t.move(Bo,s.fi,s.id);let o=0,i=0;n.shared.penumbraSize&&n.scene.objects.traverse((s,a)=>{a.type==="DirectionalLight"?(a.penumbraSize=n.shared.penumbraSize[Math.min(o,2)],o+=1):a.type==="SpotLight"&&(a.penumbraSize=n.shared.penumbraSize[3+Math.min(i,1)],i+=1),(a.physics===void 0||a.physics===null)&&a.type!=="Instance"&&(a.physics={},Object.assign(a.physics,Go.defaultData)),a.physics!==void 0&&a.physics!==null&&(a.physics.enabled=a.collision??"visibility",delete a.collision)}),n.schema=99}}function _h(n){n.layers&&n.layers.forEach(r=>{r.type==="light"&&r.alphaOverride===void 0&&(r.alphaOverride=1)})}function lP(n){n.scene.objects.traverse((r,e)=>{let t=e.geometry;t&&t.type==="PathGeometry"&&(t.extrusion.capType="flat",t.extrusion.bevel=50,t.extrusion.bevelSides=6,t.extrusion.shape.type==="Custom"&&(t.extrusion.shape.shapeQuality="low"))})}var Ph=102;function Th(n){let r=n.schema??0;r!==Ph&&(console.warn("updating from ",r,"to ",Ph),wh(n,r),r<100&&(n.scene.publish.joystickSizeAndXYOffset===void 0&&(n.scene.publish.joystickSizeAndXYOffset=Hr.defaultData.joystickSizeAndXYOffset),n.schema=100),r<101&&(ho(n,_h),mo(n,_h),n.schema=101),r<102&&(lP(n),n.schema=102))}var Re=require("three"),ds=Ts(Ah());var cP=.5*(Math.sqrt(3)-1),Fs=(3-Math.sqrt(3))/6,uP=1/3,Wr=1/6,QR=(Math.sqrt(5)-1)/4,JR=(5-Math.sqrt(5))/20,ks=n=>Math.floor(n)|0,Ch=new Float64Array([1,1,-1,1,1,-1,-1,-1,1,0,-1,0,1,0,-1,0,0,1,0,-1,0,1,0,-1]),Tu=new Float64Array([1,1,0,-1,1,0,1,-1,0,-1,-1,0,1,0,1,-1,0,1,1,0,-1,-1,0,-1,0,1,1,0,-1,1,0,1,-1,0,-1,-1]);function zl(n=Math.random){let r=Ih(n),e=new Float64Array(r).map(o=>Ch[o%12*2]),t=new Float64Array(r).map(o=>Ch[o%12*2+1]);return function(i,s){let a=0,c=0,d=0,l=(i+s)*cP,u=ks(i+l),p=ks(s+l),f=(u+p)*Fs,m=u-f,h=p-f,y=i-m,g=s-h,x,S;y>g?(x=1,S=0):(x=0,S=1);let w=y-x+Fs,b=g-S+Fs,_=y-1+2*Fs,P=g-1+2*Fs,v=u&255,N=p&255,T=.5-y*y-g*g;if(T>=0){let A=v+r[N],M=e[A],L=t[A];T*=T,a=T*T*(M*y+L*g)}let C=.5-w*w-b*b;if(C>=0){let A=v+x+r[N+S],M=e[A],L=t[A];C*=C,c=C*C*(M*w+L*b)}let O=.5-_*_-P*P;if(O>=0){let A=v+1+r[N+1],M=e[A],L=t[A];O*=O,d=O*O*(M*_+L*P)}return 70*(a+c+d)}}function Nh(n=Math.random){let r=Ih(n),e=new Float64Array(r).map(i=>Tu[i%12*3]),t=new Float64Array(r).map(i=>Tu[i%12*3+1]),o=new Float64Array(r).map(i=>Tu[i%12*3+2]);return function(s,a,c){let d,l,u,p,f=(s+a+c)*uP,m=ks(s+f),h=ks(a+f),y=ks(c+f),g=(m+h+y)*Wr,x=m-g,S=h-g,w=y-g,b=s-x,_=a-S,P=c-w,v,N,T,C,O,A;b>=_?_>=P?(v=1,N=0,T=0,C=1,O=1,A=0):b>=P?(v=1,N=0,T=0,C=1,O=0,A=1):(v=0,N=0,T=1,C=1,O=0,A=1):_<P?(v=0,N=0,T=1,C=0,O=1,A=1):b<P?(v=0,N=1,T=0,C=0,O=1,A=1):(v=0,N=1,T=0,C=1,O=1,A=0);let M=b-v+Wr,L=_-N+Wr,X=P-T+Wr,R=b-C+2*Wr,Z=_-O+2*Wr,z=P-A+2*Wr,V=b-1+3*Wr,W=_-1+3*Wr,$=P-1+3*Wr,Y=m&255,q=h&255,k=y&255,U=.6-b*b-_*_-P*P;if(U<0)d=0;else{let D=Y+r[q+r[k]];U*=U,d=U*U*(e[D]*b+t[D]*_+o[D]*P)}let B=.6-M*M-L*L-X*X;if(B<0)l=0;else{let D=Y+v+r[q+N+r[k+T]];B*=B,l=B*B*(e[D]*M+t[D]*L+o[D]*X)}let F=.6-R*R-Z*Z-z*z;if(F<0)u=0;else{let D=Y+C+r[q+O+r[k+A]];F*=F,u=F*F*(e[D]*R+t[D]*Z+o[D]*z)}let j=.6-V*V-W*W-$*$;if(j<0)p=0;else{let D=Y+1+r[q+1+r[k+1]];j*=j,p=j*j*(e[D]*V+t[D]*W+o[D]*$)}return 32*(d+l+u+p)}}function Ih(n){let e=new Uint8Array(512);for(let t=0;t<512/2;t++)e[t]=t;for(let t=0;t<512/2-1;t++){let o=t+~~(n()*(256-t)),i=e[t];e[t]=e[o],e[o]=i}for(let t=256;t<512;t++)e[t]=e[t-256];return e}var Mh=require("three"),_r=new Mh.Triangle,jl=class{constructor(r){this.weightAttribute=null;let e=r.geometry;if(!e.isBufferGeometry||e.attributes.position.itemSize!==3)throw new Error("THREE.MeshSurfaceSampler: Requires BufferGeometry triangle mesh.");e.index&&(e=e.toNonIndexed()),this.geometry=e,this.randomFunction=Math.random,this.positionAttribute=this.geometry.getAttribute("position"),this.distribution=null}build(){let r=this.positionAttribute,e=new Float32Array(r.count/3);for(let o=0;o<r.count;o+=3){let i=1;_r.a.fromBufferAttribute(r,o),_r.b.fromBufferAttribute(r,o+1),_r.c.fromBufferAttribute(r,o+2),i*=_r.getArea(),e[o/3]=i}this.distribution=new Float32Array(r.count/3);let t=0;for(let o=0;o<e.length;o++)t+=e[o],this.distribution[o]=t;return this}setRandomGenerator(r){return this.randomFunction=r,this}sample(r,e){if(this.distribution){let t=this.distribution[this.distribution.length-1],o=this.binarySearch(this.randomFunction()*t);return this.sampleFace(o,r,e)}}binarySearch(r){if(!this.distribution)return 0;let e=this.distribution,t=0,o=e.length-1,i=-1;for(;t<=o;){let s=Math.ceil((t+o)/2);if(s===0||e[s-1]<=r&&e[s]>r){i=s;break}else r<e[s]?o=s-1:t=s+1}return i}sampleFace(r,e,t){let o=this.randomFunction(),i=this.randomFunction();return o+i>1&&(o=1-o,i=1-i),_r.a.fromBufferAttribute(this.positionAttribute,r*3),_r.b.fromBufferAttribute(this.positionAttribute,r*3+1),_r.c.fromBufferAttribute(this.positionAttribute,r*3+2),e.set(0,0,0).addScaledVector(_r.a,o).addScaledVector(_r.b,i).addScaledVector(_r.c,1-(o+i)),_r.getNormal(t),this}};var Bh=require("three");var sr=require("three"),Dh=Ts(Lh()),dP=new sr.Matrix4,pP=new sr.Matrix4,fP=new sr.Matrix4,yi;(r=>{function n(e){return e&&e.__isSPEObject}r.is=n})(yi||(yi={}));var gi=n=>class extends n{constructor(){super(...arguments);this.previousModelViewMatrix=new sr.Matrix4;this.copyPreviousMatrix=!0;this.hiddenMatrix=new sr.Matrix4;this.matrixWorldRigid=new sr.Matrix4;this.shearScale=new sr.Matrix4;this.shearScaleInv=new sr.Matrix4}get __isSPEObject(){return!0}isDescendantOf(t){t instanceof sr.Object3D&&(t=t.uuid);let o=this;for(;o.parent;){if(o.parent.uuid===t)return!0;o=o.parent}return!1}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);for(let o of this.children)o.updateMatrixWorld(t)}updateWorldMatrix(t,o){let i=this.parent;if(t&&i!==null&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),o)for(let s of this.children)s.updateWorldMatrix(!1,!0)}traverseChildren(t,o=0){for(let i of this.children)yi.is(i)&&i.traverseObject(t,o+1)}traverseObject(t,o=0){if(t(this,o)!==!0)for(let s of this.children)yi.is(s)&&s.traverseObject(t,o+1)}updateMatrixWorldSVD(){let t=this.matrixWorld.elements,o=[[t[0],t[4],t[8]],[t[1],t[5],t[9]],[t[2],t[6],t[10]]],{u:i,v:s,q:a}=(0,Dh.SVD)(o),c=dP.set(i[0][0],i[0][1],i[0][2],0,i[1][0],i[1][1],i[1][2],0,i[2][0],i[2][1],i[2][2],0,0,0,0,1),d=pP.set(s[0][0],s[0][1],s[0][2],0,s[1][0],s[1][1],s[1][2],0,s[2][0],s[2][1],s[2][2],0,0,0,0,1),l=fP.copy(d).transpose();this.shearScale.makeScale(a[0],a[1],a[2]).multiply(l).premultiply(d),this.shearScaleInv.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(c,l).copyPosition(this.matrixWorld),a.every(u=>Math.abs(a[0]-u)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(t,o){this.updateWorldMatrix(!0,!1);let i=new sr.Matrix4().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),i.multiply(t.parent.matrixWorld)),"hiddenMatrix"in t&&t.hiddenMatrix instanceof sr.Matrix4?t.hiddenMatrix.premultiply(i):t.applyMatrix4(i),t.updateWorldMatrix(!1,!1),this.add(t),o!==void 0&&(this.children.pop(),this.children.splice(o,0,t)),this}copy(t,o=!1){return super.copy(t,o),this.hasNonUniformScale=t.hasNonUniformScale,this}onAfterRender(t,o,i,s,a,c){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}};var Ou=class extends gi(Bh.Object3D){},mP=n=>n.type==="Mesh",yo=class extends Ou{constructor(e){super();this.object=e;this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,t){}expand(){let e=0,t=this.object.entityChildren(e);for(;t;){let o=this.children[e];o?.object!==t&&(o&&this.remove(o),o=new yo(t),this.add(o),this.children.splice(e,0,this.children.pop()),o.matrixWorldNeedsUpdate=!0,o.matrixAutoUpdate=!1,o.matrix=t.matrix,o.hiddenMatrix=t.hiddenMatrix),o.expand(),e+=1,t=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e])}get visible(){return this.playModeVisible!==void 0?this.playModeVisible:this.object.visible||this.object.dataPatched.visible&&this.object.dataPatched.cloner?.hideBase===!0}set visible(e){}get castShadow(){return this.object.castShadow}set castShadow(e){}get receiveShadow(){return this.object.receiveShadow}set receiveShadow(e){}get isMesh(){return mP(this.object)}get isLight(){return this.object.isLight}get layers(){return this.object.layers}set layers(e){}get isCamera(){return!1}get geometry(){if(this.object.geometry)return this.object.geometry}get material(){if(this.object.material)return this.object.material}};var Gi=require("three");var sc=require("three");var go=require("three");var ot=require("three"),dn=new ot.Vector3,pn=new ot.Vector3,xi=new ot.Matrix4,Gh=[new ot.Vector3(-1,1,1),new ot.Vector3(-1,-1,1),new ot.Vector3(1,-1,1),new ot.Vector3(1,1,1),new ot.Vector3(-1,1,-1),new ot.Vector3(-1,-1,-1),new ot.Vector3(1,-1,-1),new ot.Vector3(1,1,-1)],hP=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],yP=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],Rh=(n,r,e)=>{n.updateEntityBoxSize(dn,pn),xi.copy(r).multiply(n.matrixWorld),pn.x===0&&pn.y===0&&pn.z===0?e.push(new ot.Vector3(dn.x,dn.y,dn.z).applyMatrix4(xi)):Gh.forEach(t=>{e.push(t.clone().multiply(pn).add(dn).applyMatrix4(xi))})},Us=class extends ot.Box3{constructor(){super(...arguments);this.matrix=new ot.Matrix4;this.vertices=[];this.faces=[];this.edges=[];this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(t=>t.clone()),this.faces=e.faces.map(t=>t.clone()),this.edges=e.edges.map(t=>t.clone()),this.centerEdges=e.centerEdges.map(t=>t.clone()),this}setFromObjectSize(e,t=!1){e.updateWorldMatrix(!1,t),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let o=new ot.Matrix4().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,o,t)}expandByObjectSize(e,t,o=!1){let i=[];return o===!0?e.traverseEntity(s=>{if(s.visible||s.cloner&&s.data.visible){if(!("geometry"in s)){i.push(new ot.Vector3);return}Rh(s,t,i)}}):Rh(e,t,i),this.setFromPoints(i)}getCenter(e){return e=super.getCenter(e),e.applyMatrix4(this.matrix),e}getPositionToCenter(e){return e=super.getCenter(e),e.applyMatrix4(xi.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(pn).multiplyScalar(.5),this.getCenter(dn),xi.copy(this.matrix).setPosition(dn),this.vertices=Gh.map(e=>e.clone().multiply(pn).applyMatrix4(xi))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=hP.map(([e,t])=>new ot.Line3(this.vertices[e],this.vertices[t])),this.centerEdges=this.edges.map(e=>e.getCenter(new ot.Vector3))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=yP.map(([e,t])=>this.vertices[e].clone().add(this.vertices[t]).multiplyScalar(.5))}};var Pr={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}};var wt=require("three"),Cu=class extends wt.CurvePath{constructor(){super()}getPoints(r=12){let e=[],t,o=this.getCurveLengths(),s=o[o.length-1]/o.length;for(let a=0,c=this.curves;a<c.length;a++){let d=c[a],l=a===0?o[a]:o[a]-o[a-1],u=Math.ceil(r*l/s),p=d.getPoints(u);for(let f=0;f<p.length;f++){let m=p[f];t&&t.equals(m)||(e.push(m),t=m)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}};var Nu=.001;function Iu(n,r,e){return r.clone().sub(n).cross(r.clone().sub(e)).length()<=Nu}function Au(n,r){let e=new wt.Vector3(...n.position),t=new wt.Vector3(...n.controlNext.position),o=new wt.Vector3(...r.controlPrevious.position),i=new wt.Vector3(...r.position);return Iu(e,t,i)&&Iu(e,o,i)}function kl(n){let r=n.points.map(l=>new wt.Vector3(...l.data.position)),e=[n.points[0]],t=new wt.Vector3(...e[0].data.position);for(let l=0;l<n.points.length-1;l++)Iu(t,r[l],r[l+1])||(e.push(n.points[l]),t=r[l]);e.push(n.points[n.points.length-1]);let o=n.isClosed,i=e.length-(o?0:1),s=e.length,a=[];for(let l=0;l<s;l++){let u=e[l].data,p=new wt.Vector3(...u.position),f=new wt.Vector3(...u.controlPrevious.position),m=new wt.Vector3(...u.controlNext.position),h={position:p,baseRoundness:u.roundness,controlPrevious:f,controlNext:m};if(u.roundness===0||!n.isClosed&&(l===0||l===s-1)){a[l]={...h,removedLength:0};continue}let y=o&&l==0?s-1:l-1,g=o&&l==s-1?0:l+1,x=e[y].data,S=e[g].data,w=new wt.Vector3(...x.position),b=new wt.Vector3(...S.position),_=w.clone().sub(p).normalize(),P=b.clone().sub(p).normalize();Object.assign(h,{prevDir:_,nextDir:P});let v=Au(x,u),N=Au(u,S);if(!v||!N)a[l]={...h,removedLength:0};else{let T=_.clone().add(P).normalize(),C=T.clone().cross(_).length()/_.dot(T);a[l]={...h,tan:C,removedLength:u.roundness/C}}}for(let l=0;l<i;l++){let u=l,p=o&&l===s-1?0:l+1,f=a[u],m=a[p];if(f.removedLength!==0||m.removedLength!==0){let h=f.position.distanceTo(m.position);f.removedLength=Math.min(f.removedLength,h/2),m.removedLength=Math.min(m.removedLength,h/2)}}let c=[];for(let l=0;l<i;l++){let u=l,p=o&&l===s-1?0:l+1,f=a[u],m=a[p],h=null;if(!Au(e[u].data,e[p].data))f.position.distanceTo(m.position)>Nu&&(h=new wt.CubicBezierCurve3(f.position,f.controlNext,m.controlPrevious,m.position));else{let y=f.position.clone(),g=m.position.clone();(f.removedLength!==0||m.removedLength!==0)&&(f.nextDir&&y.add(f.nextDir.clone().setLength(f.removedLength)),m.prevDir&&g.add(m.prevDir.clone().setLength(m.removedLength))),y.distanceTo(g)>Nu&&(h=new wt.CubicBezierCurve3(y,y.clone().lerp(g,.3),g.clone().lerp(y,.3),g))}c[2*l+1]=h}for(let l=0;l<s;l++){let u=a[l];if(u.removedLength===0){c[2*l]=null;continue}let p=u.position,f=u.prevDir.clone().multiplyScalar(u.removedLength).add(p),m=u.nextDir.clone().multiplyScalar(u.removedLength).add(p),h=u.tan*u.removedLength,y=u.prevDir.clone().add(u.nextDir).normalize(),g=f.clone().lerp(m,.5),x=f.distanceTo(m)/2,S=y.clone().multiplyScalar(Math.sqrt(Math.pow(h,2)-Math.pow(x,2))).add(g),w=y.clone().multiplyScalar(-h).add(S),b=p.distanceTo(w)/p.distanceTo(g),_=u.prevDir.clone().multiplyScalar(b*p.distanceTo(f)).add(p),P=_.clone().lerp(w,2),v=f.clone().lerp(_,4/3),N=m.clone().lerp(P,4/3);c[2*l]=new wt.CubicBezierCurve3(f,v,N,m)}let d=new Cu;return c.forEach(l=>{l&&d.add(l)}),d}var Ne;(r=>{function n(e){return e&&e.__isEntity}r.is=n})(Ne||(Ne={}));var vi=n=>Ne.is(n),gP={type:"completeState",isfromEntity:!0},bi=n=>class extends gi(n){constructor(){super(...arguments);this.raycastLock=!1;this.scaleLock=!1;this.disposed=!1;this.stateSelection=null;this.instances=[];this.prevState=null;this.currentState=null;this.reversibleToState=null;this.currentTransitionEvent=null;this.previousAction=null;this._singleBBox=new Us;this._recursiveBBox=new Us;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this._needApplyPathSnapping=!0;this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(t){let o=this.children[t];if(Ne.is(o))return o}entityChildrenCount(){let t=this.children.length;for(;t--;)if(Ne.is(this.children[t]))return t+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 t=this;for(;t.data.type!=="Instance";){let o=t.parent;if(Ne.is(o))t=o;else return}return t}forInstancesRec(t){this.instances.forEach(o=>{o.disposed||t(o),o.forInstancesRec(t)})}super_Entity(t,o){typeof t=="string"&&(this.uuid=t),this.identity=t,this.data=o,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(t,o,i=!1){if(!(this.data.states.length===0&&!i)){for(let s of this.data.states)un.toOps(this.data,s.data).forEach(c=>{let d=al.replaceProps(c,this.data);this.dataPatched=this.data,this.updateByPatchedOp(d,this.data,o)});if(t!==null){let s=this.data.states.data(t);s&&(this.dataPatched=un.patch(this.data,s),un.toOps(this.data,s).forEach(c=>{this.updateByPatchedOp(c,this.dataPatched,o)}))}i&&this.updateTransformState(this.dataPatched),this.stateSelection=t,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(t,o){t.setScalar(0),o.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(t=>{vi(t)&&t.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(t=>{t.resetBBoxNeedsUpdateSelf()})}find(t){let o;return this.traverseEntity(i=>{i.uuid===t&&(o=i)}),o}traverseSortNextHelper(){let t=this.parent;if(t){let o=t.children,i=o.indexOf(this)+1;if(Ne.is(o[i]))return o[i];if(Ne.is(t))return t.traverseSortNextHelper()}}sortNext(){let t=this.children;return this.children.length>0&&Ne.is(this.children[0])?t[0]:this.traverseSortNextHelper()}goUp(t){let o=this;for(;t>0&&o!==null;)o=o.parent,t-=1;return o}hasAnccestorOrSelf(t){return this===t||this.hasAnccestor(t)}hasAnccestor(t){let o=this.parent;for(;o;){if(t===o)return!0;o=o.parent}return!1}countToAccestor(t){let o=0,i=this;for(;i!==t;){if(i===null)return-1;i=i.parent,o+=1}return o}forEachEntity(t){for(let o of this.children)vi(o)&&t(o)}traverseEntityAncestors(t){this.traverseAncestors(o=>{Ne.is(o)&&t(o)})}traverseConcreteEntity(t,o=0){if(t(this,o)!==!0)for(let s of this.children)vi(s)&&s.isConcreteEntity&&s.traverseEntity(t,o+1)}traverseEntity(t,o=0){if(t(this,o)!==!0)for(let s of this.children)vi(s)&&s.traverseEntity(t,o+1)}traverseVisibleEntity(t){t(this);for(let o of this.children)vi(o)&&o.visible&&o.traverseVisibleEntity(t)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}copy(t,o=!1){return super.copy(t,o),this.dataPatched=t.dataPatched,this.raycastLock=t.raycastLock,this.scaleLock=t.scaleLock,this.hiddenMatrix.copy(t.hiddenMatrix),this}hasEntityChild(){return this.children.some(t=>vi(t))}isAncestorOf(t){if(this.uuid===t)return!1;let o=!1;return this.traverseEntity(i=>{i.uuid===t&&(o=!0)}),o}toObjectTransformState(t=[]){this.updateWorldMatrix(!0,!1);let o={position:this.position.toArray(),rotation:[this.rotation.x,this.rotation.y,this.rotation.z],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return ei(o,t)}updateTransformState(t){let o=!1;return t.position&&(this.position.fromArray(t.position),o=!0),t.rotation&&(this.rotation.fromArray(t.rotation),o=!0),t.scale&&(o=!0,this.scale.fromArray(t.scale)),t.hiddenMatrix!==void 0&&(o=!0,this.hiddenMatrix.fromArray(t.hiddenMatrix??Lo.identity)),o&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(i=>{i.invalidateClonerTransform(this)})),t.position&&t.rotation&&t.scale&&t.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),o}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let t of this.children)Ne.is(t)&&t.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(t=>{Ne.is(t)&&t.disposeRecursively()})}toState(t=[]){let o={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(t)};return ei(o,t)}updateByObjUpdateOp(t,o){t!==void 0&&this.updateByOp({type:0,props:t,path:[]},{...this.data,...t},o,!1)}updateByOp(t,o,i,s){let a=this.data;this.data=o;let c=t,d=Rt(t.path,["states","*"]);if(d!==null){if(t.type===0){let[l]=d;if(this?.stateSelection===l){let u={...t.props};if(delete u.name,Object.values(t.props).some(p=>p===void 0)){let p=this.data;if(p!==void 0){let f=Vt.zoom(p,t.path.slice(2));if(f)for(let m in t.props)t.props[m]===void 0&&m in f&&(u[m]=f[m])}}c={...t,props:u,path:t.path.slice(2)}}}}else if(t.type===0){let l=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(l!==void 0){if(t.props.name!==void 0&&l.name){let{name:p,...f}=l;l=f}if(t.props.material!==void 0&&"material"in l){let{material:p,...f}=l;l=f}let u=Vt.removeOverridden(t.path,t.props,l);c={...t,props:u}}}if(this.updateByPatchedOpBase(c,un.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),i),Rt(t.path,["overrides"])){let l=[],u=[...t.path];for(l.push(u[1]),u.splice(0,2);u.length>0&&u[0]==="descendants";)l.push(u[1]),u.splice(0,2);if(l[l.length-1]===void 0){if(t.type===0)for(let p of Object.keys(t.props)){l[l.length-1]=p;let f=i.scene.findInstance([this.uuid,...l]);f&&(f.overrideData=t.props[p],f.updateState(Gr.apply(f.component.data,f.overrideData),i))}}else{let p=i.scene.findInstance([this.uuid,...l]);if(p){let f=Vt.zoom(p.component.data,u);if(t={...t,path:u},t.type===0){let m=t.props;if(f)for(let[h,y]of Object.entries(t.props))y===void 0&&(m===t.props&&(m={...t.props}),m[h]=f[h]);t={...t,props:m}}p.overrideData=fi.resolve(o.overrides,l),p.updateByOp(t,Ct.applySimple(p.data,t),i,!1)}}}else if(this.instances.length>0){let l;if(t.path.length===0&&t.type===0){let u;for(let p of Ur.rootOverrideProps)p in t.props&&(u===void 0&&(u={}),u[p]=t.props[p]);u&&(l={...t,props:u})}else for(let u of Ur.rootOverrideProps)if(Rt(t.path,[u])){l=t;break}l!==void 0&&this.instances.forEach(u=>{if(u.isInstanceRoot){let p=Gr.filterOp(u.overrideData,l);p&&u.updateByOp(p,Ct.applySimple(u.data,p),i,!0)}}),this.instances.forEach(u=>{if(!u.isInstanceRoot){let p=Gr.filterOp(u.overrideData,t);if(p){let f;a===u.data&&t===p?f=o:f=Ct.applySimple(u.data,p),u.updateByOp(p,f,i,!0)}}})}}updateByPatchedOpBase(t,o,i){if(this.dataPatched=o,t.path.length===0&&t.type===0)t.props.type!==void 0&&!wr.is(t.props.type)&&Pr.changeEntityProptotype(this,o,i);else if(t.path.length===1&&t.path[0]==="geometry"&&t.type===0&&"type"in t.props){Pr.changeEntityProptotype(this,o,i);for(let s of this.children)Ne.is(s)&&s.updateVisible()}this.updateByPatchedOp(t,o,i)}updateByPatchedOp(t,o,i){if(t.path.length===0&&t.type===0&&this.updateState(t.props,i),Rt(t.path,["pathSnapping"])!==null&&this.updatePathSnapping(o.pathSnapping),Rt(t.path,["cloner"])!==null){let s=Ct.drop(t,1);s.path.length===0&&s.type===0&&s.props.disabled===!0?this.setFromClonerState(null,i):this.cloner?this.cloner.updateState(o.cloner,i.scene):(this.setFromClonerState(o.cloner,i),this.expandCloner(i.scene)),this.updateVisible()}}updatePathSnapping(t){this._updatedPathSnapping=t,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(t){let o=this._updatedPathSnapping?.pathId??this.dataPatched.pathSnapping.pathId,i=this._updatedPathSnapping?.slide??this.dataPatched.pathSnapping.slide??0,s=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset,a=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(o===null)return;let c=t.find(o);if(!c||this._needApplyPathSnapping===!1)return;this._needApplyPathSnapping=!1;let d=c.data;if(d.geometry.path.points.length<=1)return;let l=kl(d.geometry.path),u=(i+s)%1;i+s===1&&u===0&&(u=1);let p=l.getPointAt(u),f=this.parent?this.parent?.matrixWorld:new go.Matrix4;c.updateMatrixWorld();let m=new go.Matrix4().multiplyMatrices(f.clone().invert(),c.matrixWorld);p.applyMatrix4(m);let h={position:p.toArray(),rotation:d.rotation};if(a==="tangential"){let y=new go.Matrix4().extractRotation(c.matrixWorld),g=l.getTangentAt(u).applyMatrix4(y).add(p),x=new go.Matrix4().lookAt(p,g,new go.Vector3(0,1,0)),S=new go.Euler().setFromRotationMatrix(x);h={...h,rotation:[S.x,S.y,S.z]}}this.updateTransformState(h),this.traverseEntity(y=>{y._cameraType&&y.dispatchEvent(gP)})}updateVisible(){this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0)}updateState_Entity(t,o){t.name!==void 0&&(this.name=t.name),t.raycastLock!==void 0&&(this.raycastLock=t.raycastLock),t.visible!==void 0&&(this.updateVisible(),this.resetBBoxNeedsUpdate()),o&&"cloner"in t&&t.cloner!==void 0&&(this.setFromClonerState(t.cloner,o),this.updateVisible()),this.updateTransformState(t)}get attachedSurfaceCloners(){return this.children.filter(t=>t instanceof Pr.Cloner&&t.parameters.type==="toObject")}setFromClonerState(t,o){this.disposed||(t===null||t.disabled?(this.cloner&&this.cloner.removeFromParent(),this.cloner=void 0):this.cloner===void 0?(this.cloner=new Pr.Cloner(this,t),o.scene.addPendingExpandCloner(this)):this.cloner.updateState(t,o.scene))}expandCloner(t){!this.disposed&&this.cloner&&this.cloner.expandClones(t)}invalidateClonerTransform(t){this.cloner&&this.cloner.invalidateTransform(t)}};var jh=require("three");var Xe=require("three"),zh=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},n.parameters),t=e.width/2,o=e.radiusTop??t,i=e.radiusBottom??t;return o===i?(o=t,i=t):o>i?(o=t,i=i*t/o):(o=o*t/i,i=t),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),radiusTop:o,radiusBottom:i})}}static build(n){let{width:r,depth:e,height:t,radialSegments:o,heightSegments:i,openEnded:s,thetaStart:a,thetaLength:c,radiusTop:d,radiusBottom:l,cornerRadius:u,cornerSegments:p,hollow:f}=n.parameters,m;return u||f?m=new Hs(d,l,t,o,i,s,a,c*Math.PI/180,u,u,p,f):m=new Xe.CylinderGeometry(d,l,t,o,i,s,a,c*Math.PI/180),m.scale(1,1,e/r),Object.assign(m,{userData:{...n,type:"CylinderGeometry"}})}};function jo(n,r,e){e.x=n.x*r.x,e.y=n.y,e.z=n.x*r.y}function Vh(n){return new Xe.Vector2(n.y,-n.x)}var Hs=class extends Xe.BufferGeometry{constructor(r,e,t,o,i,s,a,c,d,l,u,p,f=!1){super(),this.type="RoundedCylinderBufferGeometry",r=r!==void 0?r:1,e=e!==void 0?e:1,t=t||1,o=Math.floor(o)||8,i=Math.floor(i)||1,s=s!==void 0?s:!1,a=a!==void 0?a:0,c=c!==void 0?c:Math.PI*2,s&&(d=0,l=0);let m=[],h=[],y=[],g=[],x=0,S=t/2,w=new Xe.Vector3,b=new Xe.Vector3;f&&r==0&&(r=d),f&&e==0&&(e=l);let _=new Xe.Vector2(r,S),P=new Xe.Vector2(e,-S),v=null,N=null,T=null,C=null,O=_.clone().sub(P),A=0,M=0,L=0;p>0&&(A=Math.min(r,e)*(1-p),M=r-A,L=e-A);let X=_.clone();X.x-=A;let R=Math.PI-O.angle(),Z=O.angle(),z=Math.tan(Z/2),V=Math.tan(R/2),W=z+V,$=p?W:V,Y=p?W:z;if(d=Math.min(d,(r-M)/$,O.length()/W),l=Math.min(l,(e-L)/Y,O.length()/W),d>0){let j=d/z;v=_.clone().sub(new Xe.Vector2(j,d)),p&&(T=v.clone(),T.x-=A-W*d),_.sub(O.clone().setLength(j))}if(l>0){let j=l/V;N=P.clone().sub(new Xe.Vector2(j,-l)),P.add(O.clone().setLength(j)),p&&(C=N.clone(),C.x-=A-W*l,X.sub(O.clone().setLength(j)))}O=_.clone().sub(P);let q=O.length()<.5,k=[];for(let j=0;j<=o;j++){let D=[],ne=j/o,ee=ne*c+a,K=new Xe.Vector2(Math.sin(ee),Math.cos(ee));C&&N?(U(D,ne,K,R,l,C,-1,!0),U(D,ne,K,Z,l,N,-1,!1)):N?(B(D,K,N.x,0,-1),U(D,ne,K,Z,l,N,-1,!1)):s||B(D,K,e,L,-1);let te=Vh(O).normalize();if(jo(te,K,w),!q)for(let Q=0;Q<=i;Q++){let le=Q/i,ie=O.clone().multiplyScalar(le).add(P);jo(ie,K,b),h.push(b.x,b.y,b.z),y.push(w.x,w.y,w.z),g.push(ne,.5+b.y/t),D.push(x++)}if(T&&v?(U(D,ne,K,R,d,v,1,!1),U(D,ne,K,Z,d,T,1,!0)):v?(U(D,ne,K,R,d,v,1,!1),B(D,K,v.x,0,1)):s||B(D,K,r,M,1),p&&!q){let Q=Vh(O).multiplyScalar(-1).normalize();jo(Q,K,w);for(let le=0;le<=i;le++){let ie=le/i,se=O.clone().multiplyScalar(-ie).add(X);jo(se,K,b),h.push(b.x,b.y,b.z),y.push(w.x,w.y,w.z),g.push(ne,.5+b.y/t),D.push(x++)}}p&&!s&&D.push(D[0]),k.push(D)}for(let j=0;j<k.length-1;j++)for(let D=0;D<k[0].length-1;D++){if(s&&p&&D==i)continue;let ne=k[j][D],ee=k[j+1][D],K=k[j+1][D+1],te=k[j][D+1],Q=h[K*3+0],le=h[K*3+2];m.push(ne,ee,te),(Q!=0||le!=0)&&m.push(ee,K,te)}c<Math.PI*2&&(F(-1,k[0],a),F(1,k[k.length-1],a+c)),this.setIndex(m),this.setAttribute("position",new Xe.Float32BufferAttribute(h,3)),this.setAttribute("normal",new Xe.Float32BufferAttribute(y,3)),this.setAttribute("uv",new Xe.Float32BufferAttribute(g,2));function U(j,D,ne,ee,K,te,Q,le){for(let ie=0;ie<u+1;ie++){let se=ie/u,ue=Q<0?se:1-se;le&&(ue-=1),ue*=ee;let ce=new Xe.Vector2(Math.sin(ue),Math.cos(ue)*Q),de=ce.clone().multiplyScalar(K).add(te);jo(de,ne,b),h.push(b.x,b.y,b.z),jo(ce,ne,w),y.push(w.x,w.y,w.z),g.push(D,.5+b.y/t),j.push(x++)}}function B(j,D,ne,ee,K){let te=new Xe.Vector3,Q=new Xe.Vector2,le=[ne,ee];K<0&&le.reverse();for(let ie of le)Q.set(ie,S*K),jo(Q,D,te),h.push(te.x,te.y,te.z),y.push(0,K,0),g.push(.5,.5),j.push(x++)}function F(j,D,ne){let ee=new Xe.Vector2(Math.sin(ne),Math.cos(ne)),K=new Xe.Vector2(-Math.cos(ne),Math.sin(ne)),te=new Xe.Vector3,Q=j<0?(se,ue,ce)=>m.push(se,ue,ce):(se,ue,ce)=>m.push(se,ce,ue),le=new Xe.Vector2((r+e+M+L)/4,0);jo(le,ee,te),h.push(te.x,te.y,te.z),y.push(K.x,0,K.y),g.push(.5,.5);let ie=x++;for(let se of D){let ue=h.slice(se*3,se*3+3);h.push(...ue),y.push(K.x,0,K.y);let ce=g.slice(se*2,se*2+2);g.push(...ce),x++}for(let se=ie+1;se<x-1;se++)Q(ie,se,se+1);Q(ie,x-1,ie+1)}}};var Fh=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:8,cornerRadiusBottom:8,cornerSegments:8},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:r,depth:e,height:t,radialSegments:o,heightSegments:i,openEnded:s,thetaStart:a,thetaLength:c,cornerRadiusTop:d,cornerRadiusBottom:l,cornerSegments:u}=n.parameters,p;return d>0||l>0||c<360?p=new Hs(0,r/2,t,o,i,s,a,c*Math.PI/180,d,l,u,0,!0):p=new jh.ConeGeometry(r/2,t,o,i,s),p.scale(1,1,e/r),Object.assign(p,{userData:{...n,type:"ConeGeometry"}})}};var Xt=require("three"),kh=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:r,height:e,depth:t,widthSegments:o,heightSegments:i,depthSegments:s,cornerRadius:a,cornerSegments:c}=n.parameters,d;return a==0?d=new Xt.BoxGeometry(r,e,t,o,i,s):d=new Eu(r,e,t,o,i,s,a,c),Object.assign(d,{userData:{...n,type:"CubeGeometry"}})}},Mu=Math.PI/2,Eu=class extends Xt.BufferGeometry{constructor(r=1,e=1,t=1,o=1,i=1,s=1,a=0,c=4){super(),this.type="BoxGeometry";let d=this;o=Math.floor(o),i=Math.floor(i),s=Math.floor(s),c=Math.floor(c),a=Math.min(a,r/2,e/2,t/2);let l=[],u=[],p=[],f=[],m=0,h=0;y("z","y","x",-1,-1,t,e,r,s,i,0),y("z","y","x",1,-1,t,e,-r,s,i,1),y("x","z","y",1,1,r,t,e,o,s,2),y("x","z","y",1,-1,r,t,-e,o,s,3),y("x","y","z",1,-1,r,e,t,o,i,4),y("x","y","z",-1,-1,r,e,-t,o,i,5),a>0&&(g("z","y","x",-1,-1,1,t,e,r,s,0),g("z","y","x",1,-1,-1,t,e,r,s,1),g("z","y","x",-1,1,-1,t,e,r,s,1),g("z","y","x",1,1,1,t,e,r,s,0),g("x","y","z",-1,-1,-1,r,e,t,o,0),g("x","y","z",1,-1,1,r,e,t,o,1),g("x","y","z",-1,1,1,r,e,t,o,0),g("x","y","z",1,1,-1,r,e,t,o,1),g("y","x","z",-1,-1,1,e,r,t,i,0),g("y","x","z",1,-1,-1,e,r,t,i,1),g("y","x","z",1,1,1,e,r,t,i,1),g("y","x","z",-1,1,-1,e,r,t,i,0),x(1,1,1),x(-1,1,1),x(1,-1,1),x(-1,-1,1),x(1,1,-1),x(-1,1,-1),x(1,-1,-1),x(-1,-1,-1)),this.setIndex(l),this.setAttribute("position",new Xt.Float32BufferAttribute(u,3)),this.setAttribute("normal",new Xt.Float32BufferAttribute(p,3)),this.setAttribute("uv",new Xt.Float32BufferAttribute(f,2));function y(S,w,b,_,P,v,N,T,C,O,A){let M=(v-2*a)/C,L=(N-2*a)/O,X=v/2-a,R=N/2-a,Z=T/2,z=C+1,V=O+1,W=0,$=0,Y=new Xt.Vector3;for(let q=0;q<V;q++){let k=q*L-R;for(let U=0;U<z;U++){let B=U*M-X;Y[S]=B*_,Y[w]=k*P,Y[b]=Z,u.push(Y.x,Y.y,Y.z),Y[S]=0,Y[w]=0,Y[b]=T>0?1:-1,p.push(Y.x,Y.y,Y.z),f.push(U/C),f.push(1-q/O),W+=1}}for(let q=0;q<O;q++)for(let k=0;k<C;k++){let U=m+k+z*q,B=m+k+z*(q+1),F=m+(k+1)+z*(q+1),j=m+(k+1)+z*q;l.push(U,B,j),l.push(B,F,j),$+=6}d.addGroup(h,$,A),h+=$,m+=W}function g(S,w,b,_,P,v,N,T,C,O,A){let M=(N-2*a)/O,L=N/2-a,X=T/2-a,R=C/2,Z=O+1,z=0,V=0,W=new Xt.Vector3,$=new Xt.Vector3;for(let Y=0;Y<c+1;Y++){let q=Y/c*Mu,k=Math.sin(q)*a,U=(1-Math.cos(q))*a,B=Math.sin(q),F=Math.cos(q);W[w]=(X+k)*P,W[b]=(R-U)*v,$[S]=0,$[w]=B*Math.sign(W[w]),$[b]=F*Math.sign(W[b]);for(let j=0;j<Z;j++){let D=j*M-L;W[S]=D*_,u.push(W.x,W.y,W.z),p.push($.x,$.y,$.z),f.push(j/O),f.push(0),z+=1}}for(let Y=0;Y<c;Y++)for(let q=0;q<O;q++){let k=m+q+Z*Y,U=m+q+Z*(Y+1),B=m+(q+1)+Z*(Y+1),F=m+(q+1)+Z*Y;l.push(k,U,F),l.push(U,B,F),V+=6}d.addGroup(h,V,A),h+=V,m+=z}function x(S,w,b){let _=new Xt.Vector3,P=new Xt.Vector3(r/2,e/2,t/2);P.subScalar(a);let v=[],N=S*w*b>0?(C,O,A)=>l.push(C,O,A):(C,O,A)=>l.push(C,A,O);for(let C=0;C<=c;C++){let O=[],A=Mu*(1-C/c),M=Math.cos(A),L=Math.sin(A),X=0;for(let R=0;R<=C;R++){let Z=Math.cos(X),z=Math.sin(X);_.x=M*Z,_.y=L,_.z=M*z;let V=P.clone().addScaledVector(_,a);u.push(S*V.x,w*V.y,b*V.z),p.push(S*_.x,w*_.y,b*_.z),f.push(0,0),O.push(m++),X+=Mu/C}v.push(O)}let T=v.length-1;for(let C=0;C<T;C++){let O=v[C],A=v[C+1],M=O.length-1;N(O[0],A[1],A[0]);for(let L=1;L<=M;L++)N(O[L-1],O[L],A[L]),N(O[L],A[L+1],A[L])}}}};var nt=require("three"),Fo=class extends nt.BufferGeometry{constructor(r=[],e=[],t="",o=1,i=.2,s=4){super(),this.type="PolyhedronGeometryRound";let a=[],c=[],d=[];l(),u(),this.setAttribute("position",new nt.Float32BufferAttribute(a,3)),this.setAttribute("normal",new nt.Float32BufferAttribute(d,3)),this.setAttribute("uv",new nt.Float32BufferAttribute(c,2));return;function l(){i=Math.min(1-1e-5,i),i==0&&(s=0);let f={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[t],m=new nt.Vector3,h=m.clone(),y=new nt.Triangle,g=i*o,x=o-g,S=s+1,w=new nt.Vector3,b=(z,V)=>w.subVectors(z,V).normalize(),_=(z,V)=>Array(z).fill(void 0).map(V),P=_(r.length/3,(z,V)=>new nt.Vector3().fromArray(r,V*3).setLength(o)),v=[],N=1e6;for(let z=0;z<P.length;z++){let V=P[z],W=[],$,Y,q,k=1e10,U=-1;for(;(U=e.indexOf(z,U+1))!=-1;){let D=U-U%3;$=e[D+(U+1)%3],Y=e[D+(U+2)%3],q=V.distanceToSquared(P[$]),k=Math.min(k,q),W.push([$,Y,q])}k+=1e-6;let B=[],F=0,j=W.length;for(let D=0;D<j;D++){[$,Y,q]=W[F];let ne=v[$]?.includes(z)==!0;q<=k&&B.push($+ +ne*N),F=W.findIndex(ee=>ee[0]==Y)}v.push(B)}let T=[];{let z=0,V=0,W,$,Y=f==3;for(let q=0;q<=s;q++){W=q*(q+1)/2,$=(q+1)*(q+2)/2;for(let k=0;k<s-q;k++)[z,V]=[W+k+q+2,$+k+q+3],T.push(W,$,...Y?[V,W]:[z,$],V,z),[W,$]=[z,V];T.push(W,$,W+s+2)}}let C=m.clone(),O=m.clone(),A=m.clone(),M=m.clone(),L=m.clone(),X=[],R=_(P.length,()=>_(f,()=>m.clone()));for(let z=0;z<P.length;z++){m.copy(P[z]).normalize(),C.copy(m).multiplyScalar(x);let V=v[z];for(let B=0;B<V.length;B++){let F=V[B],j=V[(B+1)%f];y.setFromPointsAndIndices(P,z,F%N,j%N),y.b.sub(y.a).setLength(1e10).add(y.a),y.c.sub(y.a).setLength(1e10).add(y.a),y.closestPointToPoint(C,R[z][B])}let W=[],$=[],Y=[],q=new nt.Vector3;s==0&&[...R[z]].reduce((B,F)=>B.add(F),q).multiplyScalar(1/f);for(let B=0;B<f;B++){let F=[],j=(B-1+f)%f,D=R[z][j],ne=R[z][B];m.copy(D).sub(C),h.copy(ne).sub(C);let ee=C.angleTo(m),K=m.angleTo(h),te=Math.cos(ee)*g;s==0?O.copy(q):O.copy(C).setLength(x+te),$.push(te);let Q=[O,D,ne];for(let le=0;le<2;le++){let ie=Q[le],se=Q[le+1];M.subVectors(ie,C),L.subVectors(se,C),A.crossVectors(M,L).normalize();for(let ue=0;ue<S;ue++){let ce=[ee,K][le]*ue/S;m.copy(M).applyAxisAngle(A,ce).add(C),W.push(m.clone()),le&&(b(m,C),F.push([ue==0?ie:m.clone(),w.clone()]))}le&&(b(se,C),F.push([se,w.clone()]))}Y.push(F)}X.push(Y);let k=2*S,U=2;for(let B=0;B<f;B++){let F=k*B,j=k*((B+1)%f),D=[W[F]];for(let ee=1;ee<S;ee++){M=W[F+ee],L=W[j+ee],D.push(M);for(let K=1,te=ee-U+1;K<=te;K++)m.lerpVectors(M,L,K/(te+1)),m.sub(C).setLength($[B]).add(C),D.push(m.clone());D.push(L)}for(let ee=0;ee<S;ee++)D.push(W[ee+S+F]);D.push(W[j+S]);let ne=T.map(ee=>D[ee]);a.push(...ne.map(ee=>[ee.x,ee.y,ee.z]).flat()),d.push(...ne.map(ee=>(b(ee,C),[w.x,w.y,w.z])).flat())}}let Z=[];for(let z=0;z<v.length;z++)for(let V=0;V<f;V++){let W=v[z][V];if(W<N){let $=v[W].findIndex(k=>k%N==z),Y=X[z][V],q=X[W][$];for(let k=0;k<S;k++){let U=Y[k],B=q[S-k],F=Y[k+1],j=q[S-(k+1)];[U,B,F,F,B,j].forEach(D=>{a.push(D[0].x,D[0].y,D[0].z),d.push(D[1].x,D[1].y,D[1].z)})}Z.push(Y[0][0],q[S][0],Y[S][0],q[0][0])}}for(;Z.length;){let z,V,W,$;[z,V]=Z.splice(0,2);let Y=[z];for(;z!=V;)Y.push(V),W=Z.indexOf(V),$=W%2,V=Z.splice(W-$,2)[1-$];w.subVectors(Y[0],Y[1]).cross(m.subVectors(Y[0],Y[2])).normalize();let q=w.dot(Y[0])<0;q&&w.negate();for(let k=1;k<=Y.length-2;k++)[Y[k+ +q],Y[k+1-+q],Y[0]].forEach(U=>{a.push(U.x,U.y,U.z),d.push(w.x,w.y,w.z)})}}function u(){let p=new nt.Vector3;for(let P=0;P<a.length;P+=3){p.x=a[P+0],p.y=a[P+1],p.z=a[P+2];let v=b(p)/2/Math.PI+.5,N=_(p)/Math.PI+.5;c.push(v,1-N)}let f=new nt.Vector3,m=new nt.Vector3,h=new nt.Vector3,y=new nt.Vector3,g=new nt.Vector2,x=new nt.Vector2,S=new nt.Vector2,w=(P,v,N,T)=>{T<0&&P.x===1&&(c[v]=P.x-1),N.x===0&&N.z===0&&(c[v]=T/2/Math.PI+.5)};for(let P=0,v=0;P<a.length;P+=9,v+=6){f.set(a[P+0],a[P+1],a[P+2]),m.set(a[P+3],a[P+4],a[P+5]),h.set(a[P+6],a[P+7],a[P+8]),g.set(c[v+0],c[v+1]),x.set(c[v+2],c[v+3]),S.set(c[v+4],c[v+5]),y.copy(f).add(m).add(h).divideScalar(3);let N=b(y);w(g,v+0,f,N),w(x,v+2,m,N),w(S,v+4,h,N)}for(let P=0;P<c.length;P+=6){let v=c[P+0],N=c[P+2],T=c[P+4],C=Math.max(v,N,T),O=Math.min(v,N,T);C>.9&&O<.1&&(v<.2&&(c[P+0]+=1),N<.2&&(c[P+2]+=1),T<.2&&(c[P+4]+=1))}function b(P){return Math.atan2(P.z,-P.x)}function _(P){return Math.atan2(-P.y,Math.sqrt(P.x*P.x+P.z*P.z))}}}static fromJSON(r){return new Fo(r.vertices,r.indices,r.radius,r.corner,r.cornerSides)}};var Uh=require("three"),Hh=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,detail:0,corner:0,cornerSides:4},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:r,height:e,depth:t,detail:o,corner:i,cornerSides:s}=n.parameters,a=o===0&&i!==0?new Ws(r*.5,i,s):new Uh.DodecahedronGeometry(r*.5,o);return a.scale(1,e/r,t/r),Object.assign(a,{userData:{...n,type:"DodecahedronGeometry"}})}},Ws=class extends Fo{constructor(r=1,e=.2,t=4){let o=(1+Math.sqrt(5))/2,i=1/o,s=[-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,-i,-o,0,-i,o,0,i,-o,0,i,o,-i,-o,0,-i,o,0,i,-o,0,i,o,0,-o,0,-i,o,0,-i,-o,0,i,o,0,i],a=[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],c="DodecahedronGeometry";super(s,a,c,r,e,t),this.type=c}static fromJSON(r){return new Ws(r.radius,r.corner,r.cornerSides)}};var Ee=require("three");var be=require("three"),qs=1e-12,Si=class{constructor(r){this.position=new be.Vector2;this.startPosition=new be.Vector2;this.uuid=be.MathUtils.generateUUID();this.position=r.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(r){this.position.copy(this.startPosition).add(r)}copy(r){return this.position.copy(r.position),this.startPosition.copy(r.startPosition),this}clone(){return new Si(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},wi=class extends Si{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new wi(this.parent).copy(this)}},Tr=class extends Si{constructor(e,t){super(t);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new wi(this),new wi(this))}static create(e,t){let o=new Tr(e,new be.Vector2(...t.position));return o.controls[0].position.set(...t.controlPrevious.position),o.controls[1].position.set(...t.controlNext.position),o.roundness=t.roundness,o.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored,o}getOppositeControl(e){let t=this.controls.indexOf(e);return t===0?this.controls[1]:t===1?this.controls[0]:null}applyOffsetToControls(e,t=1){for(let o=0,i=this.controls.length;o<i;o++){let s=this.controls[o];this.position.distanceTo(s.position)<=t?s.position.copy(this.position):s.applyOffset(e)}}controlsMoved(){return!(this.position.equals(this.controls[0].position)&&this.position.equals(this.controls[1].position))}copy(e){return super.copy(e),this.controls[0].copy(e.controls[0]),this.controls[1].copy(e.controls[1]),this.roundness=e.roundness,this.uuid=e.uuid,this}clone(){return new Tr(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}computeTangents(){let e=this.curveBefore?.getTangentAt(1),t=this.curveAfter?.getTangentAt(0);return[e,t]}computeNormals(e=new be.Vector2,t=new be.Vector2){let[o,i]=this.computeTangents();return o&&i&&(Wh(o,e),Wh(i,t)),[e,t]}computeTangent(e=new be.Vector2){let[t,o]=this.computeTangents();return t&&o&&e.copy(t).add(o).normalize(),e}computeNormal(e=new be.Vector2){let[t,o]=this.computeNormals();return e.copy(t).add(o).normalize(),e}};function Wh(n,r=new be.Vector2){let e=n.length();return r.set(-n.y/e,n.x/e)}var Du=n=>n,_i=new be.Vector2,Ul=new be.Vector2,xP=new be.Vector2,vP=new be.Vector2,bP=new be.Vector2,SP=new be.Vector2,$h=new be.Vector3,Yh=new be.Vector3;function Xh(n){let r=new be.Vector2;r.addVectors(n.v0,_i.subVectors(n.v1,n.v0).multiplyScalar(2/3));let e=new be.Vector2;return e.addVectors(n.v2,Ul.subVectors(n.v1,n.v2).multiplyScalar(2/3)),new be.CubicBezierCurve(n.v0,r,e,n.v2)}function $s(n,r,e=Number.EPSILON){return Math.abs(n-r)<e}function wP(n,r,e=Number.EPSILON){return n.distanceTo(r)<e}function _P(n,r,e=Number.EPSILON){return n.distanceTo(r)<e}function Bu(n,r,e){let t=Math.sqrt(Math.pow(r.x-n.x,2)+Math.pow(r.y-n.y,2)),o=Math.sqrt(Math.pow(r.x-e.x,2)+Math.pow(r.y-e.y,2)),i=Math.sqrt(Math.pow(e.x-n.x,2)+Math.pow(e.y-n.y,2));return Math.acos((o*o+t*t-i*i)/(2*o*t))}function Kh(n,r,e){return qh(n,r)&&qh(r,e)&&Lu(n.position,r.position,e.position)}function Lu(n,r,e){return _i.copy(r).sub(n).cross(Ul.copy(e).sub(n))===0}function Zh(n,r,e,t,o){let i=Math.sqrt(Math.pow(r.x-n.x,2)+Math.pow(r.y-n.y,2)),s=(n.y+r.y)/2,a=(n.x+r.x)/2,c=Math.sqrt(Math.pow(e,2)-Math.pow(i/2,2))*(n.y-r.y)/i,d=Math.sqrt(Math.pow(e,2)-Math.pow(i/2,2))*(r.x-n.x)/i;return t.set(a+c,s+d),o.set(a-c,s-d),[t,o]}function Qh(n,r,e){let t=n.distanceTo(e),o=r.distanceTo(e);return t<o?r:n}function Jh(n,r,e,t,o,i){let s=r.x-n.x,a=r.y-n.y,c=e.x-n.x,d=e.y-n.y,l=Math.sqrt((s+c)*(s+c)+(a+d)*(a+d)),u;return Bu(r,n,e)>Math.PI&&(l*=-1),$s(d,a)?u=(a+d)*(t/l-.5)*8/3/(s-c):u=(s+c)*(t/l-.5)*8/3/(d-a),o.set(r.x-u*a,r.y+u*s),i.set(e.x+u*d,e.y-u*c),[o,i]}function Ru(n,r){return n.position.equals(n.controls[1].position)&&r.position.equals(r.controls[0].position)}function qh(n,r){return Lu(n.position,n.controls[1].position,r.position)&&Lu(n.position,r.controls[0].position,r.position)}function ey(n,r,e,t,o=.5){let i=_i.subVectors(r,n).multiplyScalar(o).add(n),s=Ul.subVectors(e,r).multiplyScalar(o).add(r),a=xP.subVectors(t,e).multiplyScalar(o).add(e),c=i,d=vP.subVectors(s,i).multiplyScalar(o).add(i),l=bP.subVectors(a,s).multiplyScalar(o).add(s),u=a,p=SP.subVectors(l,d).multiplyScalar(o).add(d);return[n.x,n.y,c.x,c.y,d.x,d.y,p.x,p.y,l.x,l.y,u.x,u.y,t.x,t.y]}function ty(n,r,e=12,t=!0){let o=Yh.set(0,0,0),i,s=0,a=[];for(let c=0;c<r.length;c++){let d=Du(r[c]),l=_i,u=ko(d,e);a.push(u);for(let p=0;p<=u;p++)if(d instanceof be.CubicBezierCurve||d instanceof be.QuadraticBezierCurve||d instanceof be.LineCurve){if(d.getPoint(p/u,l),o.set(l.x,l.y,0),i!==void 0&&_P(i,o))continue;i===void 0&&(i=$h),i.copy(o),n.setXYZ(s,o.x,o.y,o.z),s++}}return t&&s>1&&!(n.getX(s-1)===n.getX(0)&&n.getY(s-1)===n.getY(0)&&n.getZ(s-1)===n.getZ(0))&&(n.setXYZ(s,n.getX(0),n.getY(0),n.getZ(0)),s++),n}function ry(n,r,e,t=12,o=!0){let i=Yh.set(0,0,0),s=0,a=[];for(let c=0;c<r.length;c++){if(e[c]===!1)continue;let d,l=Du(r[c]),u=_i,p=ko(l,t);a.push(p);for(let f=0;f<=p;f++)if(l instanceof be.CubicBezierCurve||l instanceof be.QuadraticBezierCurve||l instanceof be.LineCurve){if(l.getPoint(f/p,u),i.set(u.x,u.y,0),d?.equals(i))continue;d===void 0?d=$h:(n.setXYZ(s,d.x,d.y,d.z),s++,n.setXYZ(s,i.x,i.y,i.z),s++),d.copy(i)}}return o&&s>1&&!(n.getX(s-1)===n.getX(0)&&n.getY(s-1)===n.getY(0)&&n.getZ(s-1)===n.getZ(0))&&(n.setXYZ(s,n.getX(0),n.getY(0),n.getZ(0)),s++),a}function Gu(n,r=12,e=!1){let t=[];for(let o=0,i=n.length;o<i;o++){let s=n[o],a=0;if(e&&s.roundedCurveCorner!==void 0){let c=ko(s.roundedCurveCorner,r)*.5;o>0&&(t[o-1]+=c),a+=c}s.curveAfter!==void 0&&(a+=ko(s.curveAfter,r)),t.push(a)}return n.length>0&&e&&n[0].roundedCurveCorner!==void 0&&(t[n.length-1]+=ko(n[0].roundedCurveCorner,r)*.5),t}function ko(n,r=12){return n&&n instanceof be.EllipseCurve?r*2:n&&(n instanceof be.LineCurve||n instanceof be.LineCurve3)?1:n&&n instanceof be.SplineCurve?r*n.points.length:r}function oy(n,r,e=12,t=!0){let o,i=0;for(let s=0;s<r.length;s++){let a=Du(r[s]),c=ko(a,e),d=_i;for(let l=0;l<=c;l++)if(a instanceof be.CubicBezierCurve||a instanceof be.QuadraticBezierCurve||a instanceof be.LineCurve){if(a.getPoint(l/c,d),o!==void 0&&wP(o,d,qs))continue;o===void 0&&(o=Ul),o.copy(d),n.push(d.x,d.y),i++}}return $s(n[0],n[n.length-2],qs)&&$s(n[1],n[n.length-1],qs)&&(n.pop(),n.pop()),t&&i>1&&!($s(n[i-1],n[1],qs)&&$s(n[i-2],n[0],qs))&&(n.push(n[0],n[1]),i++),n}var Vu=new Ee.Vector2,PP=new Ee.Vector2,TP=new Ee.Vector2,OP=new Ee.Vector2,AP=new Ee.Vector2,CP=new Ee.Vector2,Me=class extends Ee.Shape{constructor(e=100,t=100){super();this.points=[];this.shapeHoles=[];this.plane=new Ee.Plane(new Ee.Vector3(0,0,-1));this.subdivision=0;this.controlSnapDistance=4;this.pointIDs=0;this.isMesh2D=!1;this._roundness=0;this.isClosed=!1;this.useCubicForRoundedCorners=!0;this.uuid=Ee.MathUtils.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=t}static createFromState(e,t,o){let i=new Me;return i.isClosed=e.isClosed,i.points=e.points.map(s=>Tr.create(s.id,s.data)),typeof e.roundness=="number"&&(i.roundness=e.roundness),i.shapeHoles=e.shapeHoles.map(s=>Me.createFromState(s)),t!==void 0&&o!==void 0&&i.applySize(t,o),i.update(),i}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(e){if(this._roundness!==e){this._roundness=e;for(let t=0,o=this.points.length;t<o;t++)this.points[t].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(t=>this.getPointIndexById(t)).filter(t=>t>=0)}getPointIndexById(e){let t=this.points.length,o=this.points.findIndex(i=>i.uuid===e);if(o<0){let i=t;for(let s=0,a=this.shapeHoles.length;s<a;s++){let c=this.shapeHoles[s],d=c.points.length,l=c.getPointIndexById(e);if(l<0)i+=d;else return l+i}}return o}getLineIndexById(e){return this.getPointIndexById(e)}getBezierPoint(e){if(e<=this.points.length-1)return this.points[e];if(this.shapeHoles.length>0){let t=this.points.length;for(let o=0,i=this.shapeHoles.length;o<i;o++){let s=this.shapeHoles[o],a=e-t;if(a<=s.points.length-1)return s.points[a];t+=s.points.length}}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let t=this.points.indexOf(e);if(t>=0)return t;if(t=this.points.length,this.shapeHoles.length>0)for(let o=0,i=this.shapeHoles.length;o<i;o++){let s=this.shapeHoles[o],a=s.points.indexOf(e);if(a>=0)return t+a;t+=s.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(t=>t.points));return[...this.points,...e]}applySize(e,t){e===0&&(e=.001),t===0&&(t=.001),this._width=e,this._height=t}applyScale(e,t){let o=Vu.set(e,t);for(let i=0,s=this.points.length;i<s;i++){let a=this.points[i];a.position.multiply(o),a.controls[0].position.multiply(o),a.controls[1].position.multiply(o)}for(let i=0,s=this.shapeHoles.length;i<s;i++)this.shapeHoles[i].applyScale(e,t);this._update()}createPoint(e,t=0,o=Ee.MathUtils.generateUUID()){let i;e instanceof Ee.Vector2?i=e:i=new Ee.Vector2(e,t);let s=new Tr(o,i);return s.roundness=this.roundness,s}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,t){this.points.splice(t,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let t=0,o=this.points.length;t<o;t++){let i=this.points[t];if(i.uuid===e)return i}for(let t=0,o=this.shapeHoles.length;t<o;t++){let s=this.shapeHoles[t].getPointByUuid(e);if(s)return s}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){let t=this.points.indexOf(e);t>=0&&this.points.splice(t,1),this.needsUpdate=!0}removePointById(e){let t=this.points.find(o=>o.uuid===e);t&&this.removePoint(t)}update(){for(let e=0,t=this.shapeHoles.length;e<t;e++)this.shapeHoles[e].update();this._update()}extractShapePointsToBuffer(e,t=12,o=!1){this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t);let i=o?this.roundedCurveDivisions:this.curveDivisions;return ty(e,o?this.roundedCurves:this.curves,t,this.autoClose),i.reduce((s,a)=>s+a,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=Gu(this.points,e,!1),this.roundedCurveDivisions=Gu(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,t,o=12){return ry(e,this.curves,t,o,this.autoClose).reduce((s,a)=>s+a,0)*2}extractShapePointsToFlatArray(e,t=12){return this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t),oy(e,this.roundedCurves,t,this.autoClose)}getCurveIndexFromVertexId(e,t=!1){let o=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let i=t?this.roundedCurveDivisions:this.curveDivisions,s=0;t&&this.points[0].roundedCurveCorner!==void 0&&(s=ko(this.points[0].roundedCurveCorner,this.subdivision)*.5);let a=e-s;a<0&&(a+=i.reduce((c,d)=>c+d,0));for(let c=0,d=i.length;c<d;c++){let l=i[c];if(a<o+l)return[c,(a-o+1)/l];o+=l}return[0,1]}getCurveT(e,t,o){let i=this.points[e],s=this.points[e>=this.points.length-1?0:e+1],a=this.curveDivisions,c=a[e];if(Ru(i,s)){let u=i.position.distanceTo(s.position);return i.position.distanceTo(Vu.set(o.x,o.y))/u}let d=0;for(let u=0;u<e;u++)d+=a[u];return(t-d)/c}dispose(){}_applyCurveForPoint(e,t){Ru(t,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(t.controls[1].position.x,t.controls[1].position.y,e.controls[0].position.x,e.controls[0].position.y,e.position.x,e.position.y);let o=this.curves[this.curves.length-1];e.curveBefore=o,t.curveAfter=o;let i=o.clone();e.roundedCurveBefore=i,t.roundedCurveAfter=i,e.roundedCurveCorner=void 0,this.roundedCurves.push(i)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let t=0,o=this.points.length;t<o;t++){let i=this.points[t];if(t===0)this.moveTo(i.position.x,i.position.y);else{let s=this.points[t-1];this._applyCurveForPoint(i,s)}}let e=this.getLastPoint();if(e?.curveAfter&&(e.curveAfter=void 0),this.isClosed){let t=this.points[0],o=this.points[this.points.length-1];this._applyCurveForPoint(t,o)}if(this.points.length>2){let t=0;for(let o=0,i=this.points.length;o<i;o++){let s=this.points[o],a=this.points[o-1]??this.points[this.points.length-1],c=this.points[o+1]??this.points[0],d=s.roundness,l=a&&c&&Kh(a,s,c);if(!s.controlsMoved()&&d>0&&!l){let u=s.curveBefore,p=s.curveAfter;if(u===void 0||p===void 0)continue;let f=s.roundedCurveBefore,m=s.roundedCurveAfter,h=u.getLength(),y=p.getLength(),g=Math.min(d,h*.499),x=Math.min(d,y*.499),S=Math.min(g,x),w=1-S/h,b=S/y,_=u.getPointAt(w,Vu),P=p.getPointAt(b,PP);this._subSplitCurve(u,f,w,_,void 0),this._subSplitCurve(p,m,b,void 0,P);let v;if(this.useCubicForRoundedCorners){let N=Bu(_,s.position,P)/2,T=Math.tan(N)*_.distanceTo(s.position),[C,O]=Zh(_,P,T,TP,OP),A=Qh(C,O,s.position),[M,L]=Jh(A,_,P,T,AP,CP);v=new Ee.CubicBezierCurve(_.clone(),M.clone(),L.clone(),P.clone())}else v=new Ee.QuadraticBezierCurve(_.clone(),s.position.clone(),P.clone());s.roundedCurveCorner=v,this.roundedCurves.splice(o+t,0,v),t++}}}}_subSplitCurve(e,t,o,i,s){if(e instanceof Ee.LineCurve)i!==void 0&&t.v2.copy(i),s!==void 0&&t.v1.copy(s);else{let a=e,c=t,d=a.getUtoTmapping(o,0),l=ey(a.v0,a.v1,a.v2,a.v3,d);return i!==void 0&&(c.v0.set(l[0],l[1]),c.v1.set(l[2],l[3]),c.v2.set(l[4],l[5]),c.v3.set(l[6],l[7])),s!==void 0&&(c.v0.set(l[6],l[7]),c.v1.set(l[8],l[9]),c.v2.set(l[10],l[11]),c.v3.set(l[12],l[13])),c}return t}clone(){let e=new Me(this._width,this._height);return e.points=this.points.map(t=>t.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(t=>t.clone()),e}toJSON(){return{points:this.points.reduce((e,t)=>e.concat(t.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){this.points=[],this.pointIDs=0;let t=e.points.length/7;for(let o=0;o<t;o++){let i=o*7,s=e.points[i+0],a=e.points[i+1],c=e.points[i+2],d=e.points[i+3],l=e.points[i+4],u=e.points[i+5],p=e.points[i+6],f=new Tr(Ee.MathUtils.generateUUID(),new Ee.Vector2(s,a));f.controls[0].position.set(c,d),f.controls[1].position.set(l,u),f.roundness=p,this.points.push(f)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(o=>{let i=new Me;return i.fromJSON(o),i}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e){let t=(i,s)=>{s instanceof Ee.CubicBezierCurve&&s.v3.equals(i.position)&&i.controls[0].position.copy(s.v2)},o=i=>{let s=[],a,c;for(a=0,c=i.length;a<c;a++)i[a]instanceof Ee.QuadraticBezierCurve&&(i[a]=Xh(i[a]));for(a=0,c=i.length;a<c;a++){let u=i[a],p=a>0?i[a-1]:null,f;u instanceof Ee.CubicBezierCurve?(f=this.createPoint(u.v0),f.controls[1].position.copy(u.v1)):u instanceof Ee.LineCurve&&(f=this.createPoint(u.v1)),f!==void 0&&(p!==null&&t(f,p),s.push(f))}let d=i[i.length-1],l=!1;return d instanceof Ee.CubicBezierCurve?d.v3.equals(s[0].position)&&(s[0].controls[0].position.copy(d.v2),l=!0):d instanceof Ee.LineCurve&&d.v2.equals(s[0].position)&&(l=!0),this.isClosed=l,s};return this.points=o(e.curves),e instanceof Ee.Shape&&(this.shapeHoles=e.holes.map(i=>{let s=new Me;return s.fromShape(i),s})),this.update(),this}updatePoint(e,t){let o=this.getPointByUuid(e);o&&(t.position!==void 0&&o.position.fromArray(t.position),t.roundness!==void 0&&(o.roundness=t.roundness),t.areControlsDirectionsMirrored!==void 0&&(o.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(e,t){let i=this.getPointByUuid(e)?.controls[0];i&&(t.position&&i.position.fromArray(t.position),this.needsUpdate=!0)}updateNextControl(e,t){let i=this.getPointByUuid(e)?.controls[1];i&&(t.position&&i.position.fromArray(t.position),this.needsUpdate=!0)}};var ju=Math.PI*2;function zu({x:n,y:r},e,t,o,i){return{x:n*e+o,y:r*t+i}}function NP(n,r){let e=r===1.5707963267948966?.551915024494:r===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(r/4),t=Math.cos(n),o=Math.sin(n),i=Math.cos(n+r),s=Math.sin(n+r);return[{x:t-o*e,y:o+t*e},{x:i+s*e,y:s-i*e},{x:i,y:s}]}function ny(n,r,e,t){let o=n*t-r*e<0?-1:1,i=Math.min(1,Math.max(-1,n*e+r*t));return o*Math.acos(i)}function IP(n,r,e,t,o,i,s,a,c,d){let l=Math.pow(o,2),u=Math.pow(i,2),p=Math.pow(s,2),f=Math.pow(a,2),m=l*u-l*f-u*p;m<0&&(m=0),m/=l*f+u*p,m=Math.sqrt(m)*(c===d?-1:1);let h=m*o/i*a,y=m*-i/o*s,g=h+(n+e)/2,x=y+(r+t)/2,S=(s-h)/o,w=(a-y)/i,b=(-s-h)/o,_=(-a-y)/i,P=ny(1,0,S,w),v=ny(S,w,b,_);return!d&&v>0&&(v-=ju),d&&v<0&&(v+=ju),{centerx:g,centery:x,ang1:P,ang2:v}}function iy({px:n,py:r,cx:e,cy:t,rx:o,ry:i,largeArcFlag:s,sweepFlag:a}){let c=[];if(o===0||i===0)return[];let d=(n-e)/2,l=(r-t)/2;if(d===0&&l===0)return[];o=Math.abs(o),i=Math.abs(i);let u=Math.pow(d,2)/Math.pow(o,2)+Math.pow(l,2)/Math.pow(i,2);u>1&&(o*=Math.sqrt(u),i*=Math.sqrt(u));let p=IP(n,r,e,t,o,i,d,l,s,a),{ang1:f,ang2:m}=p,{centerx:h,centery:y}=p,g=Math.abs(m)/(ju/4);Math.abs(1-g)<1e-7&&(g=1);let x=Math.max(Math.ceil(g),1);m/=x;for(let S=0;S<x;S++)c.push(NP(f,m)),f+=m;return c.map(S=>{let{x:w,y:b}=zu(S[0],o,i,h,y),{x:_,y:P}=zu(S[1],o,i,h,y),{x:v,y:N}=zu(S[2],o,i,h,y);return{x1:w,y1:b,x2:_,y2:P,x:v,y:N}})}var mn=require("three");var Oe;(function(n){n[n.ODD=0]="ODD",n[n.NONZERO=1]="NONZERO",n[n.POSITIVE=2]="POSITIVE",n[n.NEGATIVE=3]="NEGATIVE",n[n.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(Oe||(Oe={}));var Je;(function(n){n[n.POLYGONS=0]="POLYGONS",n[n.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",n[n.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(Je||(Je={}));function me(n,r){if(!n)throw r||"Assertion Failed!"}var pe=function(){function n(){}return n.vertEq=function(r,e){return r.s===e.s&&r.t===e.t},n.vertLeq=function(r,e){return r.s<e.s||r.s===e.s&&r.t<=e.t},n.transLeq=function(r,e){return r.t<e.t||r.t===e.t&&r.s<=e.s},n.edgeGoesLeft=function(r){return n.vertLeq(r.Dst,r.Org)},n.edgeGoesRight=function(r){return n.vertLeq(r.Org,r.Dst)},n.vertL1dist=function(r,e){return Math.abs(r.s-e.s)+Math.abs(r.t-e.t)},n.edgeEval=function(r,e,t){me(n.vertLeq(r,e)&&n.vertLeq(e,t));var o=e.s-r.s,i=t.s-e.s;return o+i>0?o<i?e.t-r.t+(r.t-t.t)*(o/(o+i)):e.t-t.t+(t.t-r.t)*(i/(o+i)):0},n.edgeSign=function(r,e,t){me(n.vertLeq(r,e)&&n.vertLeq(e,t));var o=e.s-r.s,i=t.s-e.s;return o+i>0?(e.t-t.t)*o+(e.t-r.t)*i:0},n.transEval=function(r,e,t){me(n.transLeq(r,e)&&n.transLeq(e,t));var o=e.t-r.t,i=t.t-e.t;return o+i>0?o<i?e.s-r.s+(r.s-t.s)*(o/(o+i)):e.s-t.s+(t.s-r.s)*(i/(o+i)):0},n.transSign=function(r,e,t){me(n.transLeq(r,e)&&n.transLeq(e,t));var o=e.t-r.t,i=t.t-e.t;return o+i>0?(e.s-t.s)*o+(e.s-r.s)*i:0},n.vertCCW=function(r,e,t){return r.s*(e.t-t.t)+e.s*(t.t-r.t)+t.s*(r.t-e.t)>=0},n.interpolate=function(r,e,t,o){return r=r<0?0:r,t=t<0?0:t,r<=t?t===0?(e+o)/2:e+(o-e)*(r/(r+t)):o+(e-o)*(t/(r+t))},n.intersect=function(r,e,t,o,i){var s,a,c;n.vertLeq(r,e)||(c=r,r=e,e=c),n.vertLeq(t,o)||(c=t,t=o,o=c),n.vertLeq(r,t)||(c=r,r=t,t=c,c=e,e=o,o=c),n.vertLeq(t,e)?n.vertLeq(e,o)?(s=n.edgeEval(r,t,e),a=n.edgeEval(t,e,o),s+a<0&&(s=-s,a=-a),i.s=n.interpolate(s,t.s,a,e.s)):(s=n.edgeSign(r,t,e),a=-n.edgeSign(r,o,e),s+a<0&&(s=-s,a=-a),i.s=n.interpolate(s,t.s,a,o.s)):i.s=(t.s+e.s)/2,n.transLeq(r,e)||(c=r,r=e,e=c),n.transLeq(t,o)||(c=t,t=o,o=c),n.transLeq(r,t)||(c=r,r=t,t=c,c=e,e=o,o=c),n.transLeq(t,e)?n.transLeq(e,o)?(s=n.transEval(r,t,e),a=n.transEval(t,e,o),s+a<0&&(s=-s,a=-a),i.t=n.interpolate(s,t.t,a,e.t)):(s=n.transSign(r,t,e),a=-n.transSign(r,o,e),s+a<0&&(s=-s,a=-a),i.t=n.interpolate(s,t.t,a,o.t)):i.t=(t.t+e.t)/2},n}(),Ys=function(){function n(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return n}(),Hl=function(){function n(r){this.side=r,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(n.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(r){this.Sym.Lface=r},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(r){this.Sym.Org=r},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(r){this.Sym.Lnext=r},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(r){this.Onext.Sym=r},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(r){this.Lnext.Sym=r},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(r){this.Sym.Onext=r},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(r){this.Sym.Onext.Sym=r},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(r){this.Sym.Lnext.Sym=r},enumerable:!0,configurable:!0}),n}(),Pi=function(){function n(){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}return n}(),sy=function(){function n(){var r=new Pi,e=new Ys,t=new Hl(0),o=new Hl(1);r.next=r.prev=r,r.anEdge=null,e.next=e.prev=e,t.next=t,t.Sym=o,o.next=o,o.Sym=t,this.vHead=r,this.fHead=e,this.eHead=t,this.eHeadSym=o}return n.prototype.makeEdge_=function(r){var e=new Hl(0),t=new Hl(1);r.Sym.side<r.side&&(r=r.Sym);var o=r.Sym.next;return t.next=o,o.Sym.next=e,e.next=r,r.Sym.next=t,e.Sym=t,e.Onext=e,e.Lnext=t,e.Org=null,e.Lface=null,e.winding=0,e.activeRegion=null,t.Sym=e,t.Onext=t,t.Lnext=e,t.Org=null,t.Lface=null,t.winding=0,t.activeRegion=null,e},n.prototype.splice_=function(r,e){var t=r.Onext,o=e.Onext;t.Sym.Lnext=e,o.Sym.Lnext=r,r.Onext=o,e.Onext=t},n.prototype.makeVertex_=function(r,e,t){var o=r;me(o,"Vertex can't be null!");var i=t.prev;o.prev=i,i.next=o,o.next=t,t.prev=o,o.anEdge=e;var s=e;do s.Org=o,s=s.Onext;while(s!==e)},n.prototype.makeFace_=function(r,e,t){var o=r;me(o,"Face can't be null");var i=t.prev;o.prev=i,i.next=o,o.next=t,t.prev=o,o.anEdge=e,o.trail=null,o.marked=!1,o.inside=t.inside;var s=e;do s.Lface=o,s=s.Lnext;while(s!==e)},n.prototype.killEdge_=function(r){r.Sym.side<r.side&&(r=r.Sym);var e=r.next,t=r.Sym.next;e.Sym.next=t,t.Sym.next=e},n.prototype.killVertex_=function(r,e){var t=r.anEdge,o=t;do o.Org=e,o=o.Onext;while(o!==t);var i=r.prev,s=r.next;s.prev=i,i.next=s},n.prototype.killFace_=function(r,e){var t=r.anEdge,o=t;do o.Lface=e,o=o.Lnext;while(o!==t);var i=r.prev,s=r.next;s.prev=i,i.next=s},n.prototype.makeEdge=function(){var r=new Pi,e=new Pi,t=new Ys,o=this.makeEdge_(this.eHead);return this.makeVertex_(r,o,this.vHead),this.makeVertex_(e,o.Sym,this.vHead),this.makeFace_(t,o,this.fHead),o},n.prototype.splice=function(r,e){var t=!1,o=!1;if(r!==e){if(e.Org!==r.Org&&(o=!0,this.killVertex_(e.Org,r.Org)),e.Lface!==r.Lface&&(t=!0,this.killFace_(e.Lface,r.Lface)),this.splice_(e,r),!o){var i=new Pi;this.makeVertex_(i,e,r.Org),r.Org.anEdge=r}if(!t){var s=new Ys;this.makeFace_(s,e,r.Lface),r.Lface.anEdge=r}}},n.prototype.delete=function(r){var e=r.Sym,t=!1;if(r.Lface!==r.Rface&&(t=!0,this.killFace_(r.Lface,r.Rface)),r.Onext===r)this.killVertex_(r.Org,null);else if(r.Rface.anEdge=r.Oprev,r.Org.anEdge=r.Onext,this.splice_(r,r.Oprev),!t){var o=new Ys;this.makeFace_(o,r,r.Lface)}e.Onext===e?(this.killVertex_(e.Org,null),this.killFace_(e.Lface,null)):(r.Lface.anEdge=e.Oprev,e.Org.anEdge=e.Onext,this.splice_(e,e.Oprev)),this.killEdge_(r)},n.prototype.addEdgeVertex=function(r){var e=this.makeEdge_(r),t=e.Sym;this.splice_(e,r.Lnext),e.Org=r.Dst;var o=new Pi;return this.makeVertex_(o,t,e.Org),e.Lface=t.Lface=r.Lface,e},n.prototype.splitEdge=function(r){var e=this.addEdgeVertex(r),t=e.Sym;return this.splice_(r.Sym,r.Sym.Oprev),this.splice_(r.Sym,t),r.Dst=t.Org,t.Dst.anEdge=t.Sym,t.Rface=r.Rface,t.winding=r.winding,t.Sym.winding=r.Sym.winding,t.idx=r.idx,t.Sym.idx=r.Sym.idx,t},n.prototype.connect=function(r,e){var t=!1,o=this.makeEdge_(r),i=o.Sym;if(e.Lface!==r.Lface&&(t=!0,this.killFace_(e.Lface,r.Lface)),this.splice_(o,r.Lnext),this.splice_(i,e),o.Org=r.Dst,i.Org=e.Org,o.Lface=i.Lface=r.Lface,r.Lface.anEdge=i,!t){var s=new Ys;this.makeFace_(s,o,r.Lface)}return o},n.prototype.zapFace=function(r){var e=r.anEdge,t,o,i,s,a;o=e.Lnext;do t=o,o=t.Lnext,t.Lface=null,t.Rface===null&&(t.Onext===t?this.killVertex_(t.Org,null):(t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev)),i=t.Sym,i.Onext===i?this.killVertex_(i.Org,null):(i.Org.anEdge=i.Onext,this.splice_(i,i.Oprev)),this.killEdge_(t));while(t!=e);s=r.prev,a=r.next,a.prev=s,s.next=a},n.prototype.countFaceVerts_=function(r){var e=r.anEdge,t=0;do t++,e=e.Lnext;while(e!==r.anEdge);return t},n.prototype.mergeConvexFaces=function(r){var e,t,o,i,s,a,c;for(e=this.fHead.next;e!==this.fHead;e=e.next)if(!!e.inside)for(t=e.anEdge,s=t.Org;o=t.Lnext,i=t.Sym,i&&i.Lface&&i.Lface.inside&&(a=this.countFaceVerts_(e),c=this.countFaceVerts_(i.Lface),a+c-2<=r&&pe.vertCCW(t.Lprev.Org,t.Org,i.Lnext.Lnext.Org)&&pe.vertCCW(i.Lprev.Org,i.Org,t.Lnext.Lnext.Org)&&(o=i.Lnext,this.delete(i),t=null,i=null)),!(t&&t.Lnext.Org===s);)t=o;return!0},n.prototype.check=function(){var r=this.fHead,e=this.vHead,t=this.eHead,o,i,s,a,c,d;for(i=r,i=r;(o=i.next)!==r;i=o){me(o.prev===i),c=o.anEdge;do me(c.Sym!==c),me(c.Sym.Sym===c),me(c.Lnext.Onext.Sym===c),me(c.Onext.Sym.Lnext===c),me(c.Lface===o),c=c.Lnext;while(c!==o.anEdge)}for(me(o.prev===i&&o.anEdge===null),a=e,a=e;(s=a.next)!==e;a=s){me(s.prev===a),c=s.anEdge;do me(c.Sym!==c),me(c.Sym.Sym===c),me(c.Lnext.Onext.Sym===c),me(c.Onext.Sym.Lnext===c),me(c.Org===s),c=c.Onext;while(c!==s.anEdge)}for(me(s.prev===a&&s.anEdge===null),d=t,d=t;(c=d.next)!==t;d=c)me(c.Sym.next===d.Sym),me(c.Sym!==c),me(c.Sym.Sym===c),me(c.Org!==null),me(c.Dst!==null),me(c.Lnext.Onext.Sym===c),me(c.Onext.Sym.Lnext===c);me(c.Sym.next===d.Sym&&c.Sym===this.eHeadSym&&c.Sym.Sym===c&&c.Org===null&&c.Dst===null&&c.Lface===null&&c.Rface===null)},n}(),ay=function(){function n(){this.handle=null}return n}(),ly=function(){function n(){this.key=null,this.node=0}return n}(),MP=function(){function n(r,e){this.leq=e,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=r,this.nodes=[],this.handles=[];for(var t=0;t<r+1;t++)this.nodes[t]=new ay,this.handles[t]=new ly;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return n.prototype.floatDown_=function(r){var e=this.nodes,t=this.handles,o,i,s;for(o=e[r].handle;;){if(s=r<<1,s<this.size&&this.leq(t[e[s+1].handle].key,t[e[s].handle].key)&&++s,me(s<=this.max),i=e[s].handle,s>this.size||this.leq(t[o].key,t[i].key)){e[r].handle=o,t[o].node=r;break}e[r].handle=i,t[i].node=r,r=s}},n.prototype.floatUp_=function(r){var e=this.nodes,t=this.handles,o,i,s;for(o=e[r].handle;;){if(s=r>>1,i=e[s].handle,s===0||this.leq(t[i].key,t[o].key)){e[r].handle=o,t[o].node=r;break}e[r].handle=i,t[i].node=r,r=s}},n.prototype.init=function(){for(var r=this.size;r>=1;--r)this.floatDown_(r);this.initialized=!0},n.prototype.min=function(){return this.handles[this.nodes[1].handle].key},n.prototype.insert=function(r){var e,t;if(e=++this.size,e*2>this.max){this.max*=2;var o,i;for(i=this.nodes.length,this.nodes.length=this.max+1,o=i;o<this.nodes.length;o++)this.nodes[o]=new ay;for(i=this.handles.length,this.handles.length=this.max+1,o=i;o<this.handles.length;o++)this.handles[o]=new ly}return this.freeList===0?t=e:(t=this.freeList,this.freeList=this.handles[t].node),this.nodes[e].handle=t,this.handles[t].node=e,this.handles[t].key=r,this.initialized&&this.floatUp_(e),t},n.prototype.extractMin=function(){var r=this.nodes,e=this.handles,t=r[1].handle,o=e[t].key;return this.size>0&&(r[1].handle=r[this.size].handle,e[r[1].handle].node=1,e[t].key=null,e[t].node=this.freeList,this.freeList=t,--this.size,this.size>0&&this.floatDown_(1)),o},n.prototype.delete=function(r){var e=this.nodes,t=this.handles,o;me(r>=1&&r<=this.max&&t[r].key!==null),o=t[r].node,e[o].handle=e[this.size].handle,t[e[o].handle].node=o,--this.size,o<=this.size&&(o<=1||this.leq(t[e[o>>1].handle].key,t[e[o].handle].key)?this.floatDown_(o):this.floatUp_(o)),t[r].key=null,t[r].node=this.freeList,this.freeList=r},n}(),Fu=function(){function n(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return n}(),cy=function(){function n(){this.key=null,this.next=null,this.prev=null}return n}(),EP=function(){function n(r,e){this.frame=r,this.leq=e,this.head=new cy,this.head.next=this.head,this.head.prev=this.head}return n.prototype.min=function(){return this.head.next},n.prototype.max=function(){return this.head.prev},n.prototype.insert=function(r){return this.insertBefore(this.head,r)},n.prototype.search=function(r){var e=this.head;do e=e.next;while(e.key!==null&&!this.leq(this.frame,r,e.key));return e},n.prototype.insertBefore=function(r,e){do r=r.prev;while(r.key!==null&&!this.leq(this.frame,r.key,e));var t=new cy;return t.key=e,t.next=r.next,r.next.prev=t,t.prev=r,r.next=t,t},n.prototype.delete=function(r){r.next.prev=r.prev,r.prev.next=r.next},n}(),LP=function(){function n(){}return n.regionBelow=function(r){return r.nodeUp.prev.key},n.regionAbove=function(r){return r.nodeUp.next.key},n.debugEvent=function(r){},n.addWinding=function(r,e){r.winding+=e.winding,r.Sym.winding+=e.Sym.winding},n.edgeLeq=function(r,e,t){var o=r.event,i=e.eUp,s=t.eUp;if(i.Dst===o)return s.Dst===o?pe.vertLeq(i.Org,s.Org)?pe.edgeSign(s.Dst,i.Org,s.Org)<=0:pe.edgeSign(i.Dst,s.Org,i.Org)>=0:pe.edgeSign(s.Dst,o,s.Org)<=0;if(s.Dst===o)return pe.edgeSign(i.Dst,o,i.Org)>=0;var a=pe.edgeEval(i.Dst,o,i.Org),c=pe.edgeEval(s.Dst,o,s.Org);return a>=c},n.deleteRegion=function(r,e){e.fixUpperEdge&&me(e.eUp.winding===0),e.eUp.activeRegion=null,r.dict.delete(e.nodeUp)},n.fixUpperEdge=function(r,e,t){me(e.fixUpperEdge),r.mesh.delete(e.eUp),e.fixUpperEdge=!1,e.eUp=t,t.activeRegion=e},n.topLeftRegion=function(r,e){var t=e.eUp.Org,o;do e=n.regionAbove(e);while(e.eUp.Org===t);if(e.fixUpperEdge){if(o=r.mesh.connect(n.regionBelow(e).eUp.Sym,e.eUp.Lnext),o===null)return null;n.fixUpperEdge(r,e,o),e=n.regionAbove(e)}return e},n.topRightRegion=function(r){var e=r.eUp.Dst;do r=n.regionAbove(r);while(r.eUp.Dst===e);return r},n.addRegionBelow=function(r,e,t){var o=new Fu;return o.eUp=t,o.nodeUp=r.dict.insertBefore(e.nodeUp,o),o.fixUpperEdge=!1,o.sentinel=!1,o.dirty=!1,t.activeRegion=o,o},n.isWindingInside=function(r,e){switch(r.windingRule){case Oe.ODD:return(e&1)!==0;case Oe.NONZERO:return e!==0;case Oe.POSITIVE:return e>0;case Oe.NEGATIVE:return e<0;case Oe.ABS_GEQ_TWO:return e>=2||e<=-2}throw new Error("Invalid winding rulle")},n.computeWinding=function(r,e){e.windingNumber=n.regionAbove(e).windingNumber+e.eUp.winding,e.inside=n.isWindingInside(r,e.windingNumber)},n.finishRegion=function(r,e){var t=e.eUp,o=t.Lface;o.inside=e.inside,o.anEdge=t,n.deleteRegion(r,e)},n.finishLeftRegions=function(r,e,t){for(var o,i=null,s=e,a=e.eUp;s!==t;){if(s.fixUpperEdge=!1,i=n.regionBelow(s),o=i.eUp,o.Org!=a.Org){if(!i.fixUpperEdge){n.finishRegion(r,s);break}o=r.mesh.connect(a.Lprev,o.Sym),n.fixUpperEdge(r,i,o)}a.Onext!==o&&(r.mesh.splice(o.Oprev,o),r.mesh.splice(a,o)),n.finishRegion(r,s),a=i.eUp,s=i}return a},n.addRightEdges=function(r,e,t,o,i,s){var a,c,d,l,u=!0;d=t;do me(pe.vertLeq(d.Org,d.Dst)),n.addRegionBelow(r,e,d.Sym),d=d.Onext;while(d!==o);for(i===null&&(i=n.regionBelow(e).eUp.Rprev),c=e,l=i;a=n.regionBelow(c),d=a.eUp.Sym,d.Org===l.Org;)d.Onext!==l&&(r.mesh.splice(d.Oprev,d),r.mesh.splice(l.Oprev,d)),a.windingNumber=c.windingNumber-d.winding,a.inside=n.isWindingInside(r,a.windingNumber),c.dirty=!0,!u&&n.checkForRightSplice(r,c)&&(n.addWinding(d,l),n.deleteRegion(r,c),r.mesh.delete(l)),u=!1,c=a,l=d;c.dirty=!0,me(c.windingNumber-d.winding===a.windingNumber),s&&n.walkDirtyRegions(r,c)},n.spliceMergeVertices=function(r,e,t){r.mesh.splice(e,t)},n.vertexWeights=function(r,e,t){var o=pe.vertL1dist(e,r),i=pe.vertL1dist(t,r),s=.5*i/(o+i),a=.5*o/(o+i);r.coords[0]+=s*e.coords[0]+a*t.coords[0],r.coords[1]+=s*e.coords[1]+a*t.coords[1],r.coords[2]+=s*e.coords[2]+a*t.coords[2]},n.getIntersectData=function(r,e,t,o,i,s){e.coords[0]=e.coords[1]=e.coords[2]=0,e.idx=-1,n.vertexWeights(e,t,o),n.vertexWeights(e,i,s)},n.checkForRightSplice=function(r,e){var t=n.regionBelow(e),o=e.eUp,i=t.eUp;if(pe.vertLeq(o.Org,i.Org)){if(pe.edgeSign(i.Dst,o.Org,i.Org)>0)return!1;pe.vertEq(o.Org,i.Org)?o.Org!==i.Org&&(r.pq.delete(o.Org.pqHandle),n.spliceMergeVertices(r,i.Oprev,o)):(r.mesh.splitEdge(i.Sym),r.mesh.splice(o,i.Oprev),e.dirty=t.dirty=!0)}else{if(pe.edgeSign(o.Dst,i.Org,o.Org)<0)return!1;n.regionAbove(e).dirty=e.dirty=!0,r.mesh.splitEdge(o.Sym),r.mesh.splice(i.Oprev,o)}return!0},n.checkForLeftSplice=function(r,e){var t=n.regionBelow(e),o=e.eUp,i=t.eUp,s;if(me(!pe.vertEq(o.Dst,i.Dst)),pe.vertLeq(o.Dst,i.Dst)){if(pe.edgeSign(o.Dst,i.Dst,o.Org)<0)return!1;n.regionAbove(e).dirty=e.dirty=!0,s=r.mesh.splitEdge(o),r.mesh.splice(i.Sym,s),s.Lface.inside=e.inside}else{if(pe.edgeSign(i.Dst,o.Dst,i.Org)>0)return!1;e.dirty=t.dirty=!0,s=r.mesh.splitEdge(i),r.mesh.splice(o.Lnext,i.Sym),s.Rface.inside=e.inside}return!0},n.checkForIntersect=function(r,e){var t=n.regionBelow(e),o=e.eUp,i=t.eUp,s=o.Org,a=i.Org,c=o.Dst,d=i.Dst,l,u,p=new Pi,f,m;if(me(!pe.vertEq(d,c)),me(pe.edgeSign(c,r.event,s)<=0),me(pe.edgeSign(d,r.event,a)>=0),me(s!==r.event&&a!==r.event),me(!e.fixUpperEdge&&!t.fixUpperEdge),s===a||(l=Math.min(s.t,c.t),u=Math.max(a.t,d.t),l>u))return!1;if(pe.vertLeq(s,a)){if(pe.edgeSign(d,s,a)>0)return!1}else if(pe.edgeSign(c,a,s)<0)return!1;return n.debugEvent(r),pe.intersect(c,s,d,a,p),me(Math.min(s.t,c.t)<=p.t),me(p.t<=Math.max(a.t,d.t)),me(Math.min(d.s,c.s)<=p.s),me(p.s<=Math.max(a.s,s.s)),pe.vertLeq(p,r.event)&&(p.s=r.event.s,p.t=r.event.t),f=pe.vertLeq(s,a)?s:a,pe.vertLeq(f,p)&&(p.s=f.s,p.t=f.t),pe.vertEq(p,s)||pe.vertEq(p,a)?(n.checkForRightSplice(r,e),!1):!pe.vertEq(c,r.event)&&pe.edgeSign(c,r.event,p)>=0||!pe.vertEq(d,r.event)&&pe.edgeSign(d,r.event,p)<=0?d===r.event?(r.mesh.splitEdge(o.Sym),r.mesh.splice(i.Sym,o),e=n.topLeftRegion(r,e),o=n.regionBelow(e).eUp,n.finishLeftRegions(r,n.regionBelow(e),t),n.addRightEdges(r,e,o.Oprev,o,o,!0),!0):c===r.event?(r.mesh.splitEdge(i.Sym),r.mesh.splice(o.Lnext,i.Oprev),t=e,e=n.topRightRegion(e),m=n.regionBelow(e).eUp.Rprev,t.eUp=i.Oprev,i=n.finishLeftRegions(r,t,null),n.addRightEdges(r,e,i.Onext,o.Rprev,m,!0),!0):(pe.edgeSign(c,r.event,p)>=0&&(n.regionAbove(e).dirty=e.dirty=!0,r.mesh.splitEdge(o.Sym),o.Org.s=r.event.s,o.Org.t=r.event.t),pe.edgeSign(d,r.event,p)<=0&&(e.dirty=t.dirty=!0,r.mesh.splitEdge(i.Sym),i.Org.s=r.event.s,i.Org.t=r.event.t),!1):(r.mesh.splitEdge(o.Sym),r.mesh.splitEdge(i.Sym),r.mesh.splice(i.Oprev,o),o.Org.s=p.s,o.Org.t=p.t,o.Org.pqHandle=r.pq.insert(o.Org),n.getIntersectData(r,o.Org,s,c,a,d),n.regionAbove(e).dirty=e.dirty=t.dirty=!0,!1)},n.walkDirtyRegions=function(r,e){for(var t=n.regionBelow(e),o,i;;){for(;t.dirty;)e=t,t=n.regionBelow(t);if(!e.dirty&&(t=e,e=n.regionAbove(e),e===null||!e.dirty))return;if(e.dirty=!1,o=e.eUp,i=t.eUp,o.Dst!==i.Dst&&n.checkForLeftSplice(r,e)&&(t.fixUpperEdge?(n.deleteRegion(r,t),r.mesh.delete(i),t=n.regionBelow(e),i=t.eUp):e.fixUpperEdge&&(n.deleteRegion(r,e),r.mesh.delete(o),e=n.regionAbove(t),o=e.eUp)),o.Org!==i.Org)if(o.Dst!==i.Dst&&!e.fixUpperEdge&&!t.fixUpperEdge&&(o.Dst===r.event||i.Dst===r.event)){if(n.checkForIntersect(r,e))return}else n.checkForRightSplice(r,e);o.Org===i.Org&&o.Dst===i.Dst&&(n.addWinding(i,o),n.deleteRegion(r,e),r.mesh.delete(o),e=n.regionAbove(t))}},n.connectRightVertex=function(r,e,t){var o,i=t.Onext,s=n.regionBelow(e),a=e.eUp,c=s.eUp,d=!1;if(a.Dst!==c.Dst&&n.checkForIntersect(r,e),pe.vertEq(a.Org,r.event)&&(r.mesh.splice(i.Oprev,a),e=n.topLeftRegion(r,e),i=n.regionBelow(e).eUp,n.finishLeftRegions(r,n.regionBelow(e),s),d=!0),pe.vertEq(c.Org,r.event)&&(r.mesh.splice(t,c.Oprev),t=n.finishLeftRegions(r,s,null),d=!0),d){n.addRightEdges(r,e,t.Onext,i,i,!0);return}pe.vertLeq(c.Org,a.Org)?o=c.Oprev:o=a,o=r.mesh.connect(t.Lprev,o),n.addRightEdges(r,e,o,o.Onext,o.Onext,!1),o.Sym.activeRegion.fixUpperEdge=!0,n.walkDirtyRegions(r,e)},n.connectLeftDegenerate=function(r,e,t){var o,i,s,a,c;if(o=e.eUp,pe.vertEq(o.Org,t)){me(!1),n.spliceMergeVertices(r,o,t.anEdge);return}if(!pe.vertEq(o.Dst,t)){r.mesh.splitEdge(o.Sym),e.fixUpperEdge&&(r.mesh.delete(o.Onext),e.fixUpperEdge=!1),r.mesh.splice(t.anEdge,o),n.sweepEvent(r,t);return}me(!1),e=n.topRightRegion(e),c=n.regionBelow(e),s=c.eUp.Sym,i=a=s.Onext,c.fixUpperEdge&&(me(i!==s),n.deleteRegion(r,c),r.mesh.delete(s),s=i.Oprev),r.mesh.splice(t.anEdge,s),pe.edgeGoesLeft(i)||(i=null),n.addRightEdges(r,e,s.Onext,a,i,!0)},n.connectLeftVertex=function(r,e){var t,o,i,s,a,c,d=new Fu;if(d.eUp=e.anEdge.Sym,t=r.dict.search(d).key,o=n.regionBelow(t),!!o){if(s=t.eUp,a=o.eUp,pe.edgeSign(s.Dst,e,s.Org)===0){n.connectLeftDegenerate(r,t,e);return}if(i=pe.vertLeq(a.Dst,s.Dst)?t:o,t.inside||i.fixUpperEdge){if(i===t)c=r.mesh.connect(e.anEdge.Sym,s.Lnext);else{var l=r.mesh.connect(a.Dnext,e.anEdge);c=l.Sym}i.fixUpperEdge?n.fixUpperEdge(r,i,c):n.computeWinding(r,n.addRegionBelow(r,t,c)),n.sweepEvent(r,e)}else n.addRightEdges(r,t,e.anEdge,e.anEdge,null,!0)}},n.sweepEvent=function(r,e){r.event=e,n.debugEvent(r);for(var t=e.anEdge;t.activeRegion===null;)if(t=t.Onext,t===e.anEdge){n.connectLeftVertex(r,e);return}var o=n.topLeftRegion(r,t.activeRegion);me(o!==null);var i=n.regionBelow(o),s=i.eUp,a=n.finishLeftRegions(r,i,null);a.Onext===s?n.connectRightVertex(r,o,a):n.addRightEdges(r,o,a.Onext,s,s,!0)},n.addSentinel=function(r,e,t,o){var i=new Fu,s=r.mesh.makeEdge();s.Org.s=t,s.Org.t=o,s.Dst.s=e,s.Dst.t=o,r.event=s.Dst,i.eUp=s,i.windingNumber=0,i.inside=!1,i.fixUpperEdge=!1,i.sentinel=!0,i.dirty=!1,i.nodeUp=r.dict.insert(i)},n.initEdgeDict=function(r){r.dict=new EP(r,n.edgeLeq);var e=r.bmax[0]-r.bmin[0],t=r.bmax[1]-r.bmin[1],o=r.bmin[0]-e,i=r.bmax[0]+e,s=r.bmin[1]-t,a=r.bmax[1]+t;n.addSentinel(r,o,i,s),n.addSentinel(r,o,i,a)},n.doneEdgeDict=function(r){for(var e,t=0;(e=r.dict.min().key)!==null;)e.sentinel||(me(e.fixUpperEdge),me(++t===1)),me(e.windingNumber===0),n.deleteRegion(r,e)},n.removeDegenerateEdges=function(r){var e,t,o,i=r.mesh.eHead;for(e=i.next;e!==i;e=t)t=e.next,o=e.Lnext,pe.vertEq(e.Org,e.Dst)&&e.Lnext.Lnext!==e&&(n.spliceMergeVertices(r,o,e),r.mesh.delete(e),e=o,o=e.Lnext),o.Lnext===e&&(o!==e&&((o===t||o===t.Sym)&&(t=t.next),r.mesh.delete(o)),(e===t||e===t.Sym)&&(t=t.next),r.mesh.delete(e))},n.initPriorityQ=function(r){var e,t,o,i=0;for(o=r.mesh.vHead,t=o.next;t!==o;t=t.next)i++;for(i+=8,e=r.pq=new MP(i,pe.vertLeq),o=r.mesh.vHead,t=o.next;t!==o;t=t.next)t.pqHandle=e.insert(t);return t!==o?!1:(e.init(),!0)},n.donePriorityQ=function(r){r.pq=null},n.removeDegenerateFaces=function(r,e){var t,o,i;for(t=e.fHead.next;t!==e.fHead;t=o)o=t.next,i=t.anEdge,me(i.Lnext!==i),i.Lnext.Lnext===i&&(n.addWinding(i.Onext,i),r.mesh.delete(i));return!0},n.computeInterior=function(r,e){e===void 0&&(e=!0);var t,o;if(n.removeDegenerateEdges(r),!n.initPriorityQ(r))return!1;for(n.initEdgeDict(r);(t=r.pq.extractMin())!==null;){for(;o=r.pq.min(),!(o===null||!pe.vertEq(o,t));)o=r.pq.extractMin(),n.spliceMergeVertices(r,t.anEdge,o.anEdge);n.sweepEvent(r,t)}return r.event=r.dict.min().key.eUp.Org,n.debugEvent(r),n.doneEdgeDict(r),n.donePriorityQ(r),n.removeDegenerateFaces(r,r.mesh)?(e&&r.mesh.check(),!0):!1},n}(),DP=function(){function n(){this.mesh=new sy,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=Oe.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 n.prototype.dot_=function(r,e){return r[0]*e[0]+r[1]*e[1]+r[2]*e[2]},n.prototype.normalize_=function(r){var e=r[0]*r[0]+r[1]*r[1]+r[2]*r[2];if(!e)throw"Zero-size vector!";e=Math.sqrt(e),r[0]/=e,r[1]/=e,r[2]/=e},n.prototype.longAxis_=function(r){var e=0;return Math.abs(r[1])>Math.abs(r[0])&&(e=1),Math.abs(r[2])>Math.abs(r[e])&&(e=2),e},n.prototype.computeNormal_=function(r){var e,t,o,i,s,a,c=[0,0,0],d=[0,0,0],l=[0,0,0],u=[0,0,0],p=[0,0,0],f=[null,null,null],m=[null,null,null],h=this.mesh.vHead;e=h.next;for(var y=0;y<3;++y)i=e.coords[y],d[y]=i,m[y]=e,c[y]=i,f[y]=e;for(e=h.next;e!==h;e=e.next)for(var g=0;g<3;++g)i=e.coords[g],i<d[g]&&(d[g]=i,m[g]=e),i>c[g]&&(c[g]=i,f[g]=e);var x=0;if(c[1]-d[1]>c[0]-d[0]&&(x=1),c[2]-d[2]>c[x]-d[x]&&(x=2),d[x]>=c[x]){r[0]=0,r[1]=0,r[2]=1;return}for(a=0,t=m[x],o=f[x],l[0]=t.coords[0]-o.coords[0],l[1]=t.coords[1]-o.coords[1],l[2]=t.coords[2]-o.coords[2],e=h.next;e!==h;e=e.next)u[0]=e.coords[0]-o.coords[0],u[1]=e.coords[1]-o.coords[1],u[2]=e.coords[2]-o.coords[2],p[0]=l[1]*u[2]-l[2]*u[1],p[1]=l[2]*u[0]-l[0]*u[2],p[2]=l[0]*u[1]-l[1]*u[0],s=p[0]*p[0]+p[1]*p[1]+p[2]*p[2],s>a&&(a=s,r[0]=p[0],r[1]=p[1],r[2]=p[2]);a<=0&&(r[0]=r[1]=r[2]=0,r[this.longAxis_(l)]=1)},n.prototype.checkOrientation_=function(){for(var r=this.mesh.fHead,e,t=this.mesh.vHead,o,i=0,s=r.next;s!==r;s=s.next)if(o=s.anEdge,!(o.winding<=0))do i+=(o.Org.s-o.Dst.s)*(o.Org.t+o.Dst.t),o=o.Lnext;while(o!==s.anEdge);if(i<0){for(e=t.next;e!==t;e=e.next)e.t=-e.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},n.prototype.projectPolygon_=function(){var r=this.mesh.vHead,e=[0,0,0],t,o,i=!1;e[0]=this.normal[0],e[1]=this.normal[1],e[2]=this.normal[2],!e[0]&&!e[1]&&!e[2]&&(this.computeNormal_(e),i=!0),t=this.sUnit,o=this.tUnit;var s=this.longAxis_(e);t[s]=0,t[(s+1)%3]=1,t[(s+2)%3]=0,o[s]=0,o[(s+1)%3]=0,o[(s+2)%3]=e[s]>0?1:-1;for(var a=r.next;a!==r;a=a.next)a.s=this.dot_(a.coords,t),a.t=this.dot_(a.coords,o);i&&this.checkOrientation_();for(var c=!0,d=r.next;d!==r;d=d.next)c?(this.bmin[0]=this.bmax[0]=d.s,this.bmin[1]=this.bmax[1]=d.t,c=!1):(d.s<this.bmin[0]&&(this.bmin[0]=d.s),d.s>this.bmax[0]&&(this.bmax[0]=d.s),d.t<this.bmin[1]&&(this.bmin[1]=d.t),d.t>this.bmax[1]&&(this.bmax[1]=d.t))},n.prototype.addWinding_=function(r,e){r.winding+=e.winding,r.Sym.winding+=e.Sym.winding},n.prototype.tessellateMonoRegion_=function(r,e){var t,o;if(t=e.anEdge,!(t.Lnext!==t&&t.Lnext.Lnext!==t))throw"Mono region invalid";for(;pe.vertLeq(t.Dst,t.Org);t=t.Lprev);for(;pe.vertLeq(t.Org,t.Dst);t=t.Lnext);o=t.Lprev;for(var i=void 0;t.Lnext!==o;)if(pe.vertLeq(t.Dst,o.Org)){for(;o.Lnext!==t&&(pe.edgeGoesLeft(o.Lnext)||pe.edgeSign(o.Org,o.Dst,o.Lnext.Dst)<=0);)i=r.connect(o.Lnext,o),o=i.Sym;o=o.Lprev}else{for(;o.Lnext!==t&&(pe.edgeGoesRight(t.Lprev)||pe.edgeSign(t.Dst,t.Org,t.Lprev.Org)>=0);)i=r.connect(t,t.Lprev),t=i.Sym;t=t.Lnext}if(o.Lnext===t)throw"Mono region invalid";for(;o.Lnext.Lnext!==t;)i=r.connect(o.Lnext,o),o=i.Sym;return!0},n.prototype.tessellateInterior_=function(r){for(var e,t=r.fHead.next;t!==r.fHead;t=e)if(e=t.next,t.inside&&!this.tessellateMonoRegion_(r,t))return!1;return!0},n.prototype.discardExterior_=function(r){for(var e,t=r.fHead.next;t!==r.fHead;t=e)e=t.next,t.inside||r.zapFace(t)},n.prototype.setWindingNumber_=function(r,e,t){for(var o,i=r.eHead.next;i!==r.eHead;i=o)o=i.next,i.Rface.inside!==i.Lface.inside?i.winding=i.Lface.inside?e:-e:t?r.delete(i):i.winding=0},n.prototype.getNeighbourFace_=function(r){return!r.Rface||!r.Rface.inside?-1:r.Rface.n},n.prototype.outputPolymesh_=function(r,e,t,o){var i,s=0,a=0,c;t>3&&r.mergeConvexFaces(t);for(var d=r.vHead.next;d!==r.vHead;d=d.next)d.n=-1;for(var l=r.fHead.next;l!==r.fHead;l=l.next)if(l.n=-1,!!l.inside){i=l.anEdge,c=0;do{var d=i.Org;d.n===-1&&(d.n=a,a++),c++,i=i.Lnext}while(i!==l.anEdge);if(c>t)throw"Face vertex greater that support polygon";l.n=s,++s}this.elementCount=s,e===Je.CONNECTED_POLYGONS&&(s*=2),this.elements=[],this.elements.length=s*t,this.vertexCount=a,this.vertices=[],this.vertices.length=a*o,this.vertexIndices=[],this.vertexIndices.length=a;for(var d=r.vHead.next;d!==r.vHead;d=d.next)if(d.n!==-1){var u=d.n*o;this.vertices[u+0]=d.coords[0],this.vertices[u+1]=d.coords[1],o>2&&(this.vertices[u+2]=d.coords[2]),this.vertexIndices[d.n]=d.idx}for(var p=0,l=r.fHead.next;l!==r.fHead;l=l.next)if(!!l.inside){i=l.anEdge,c=0;do{var d=i.Org;this.elements[p++]=d.n,c++,i=i.Lnext}while(i!==l.anEdge);for(var f=c;f<t;++f)this.elements[p++]=-1;if(e===Je.CONNECTED_POLYGONS){i=l.anEdge;do this.elements[p++]=this.getNeighbourFace_(i),i=i.Lnext;while(i!==l.anEdge);for(var m=c;m<t;++m)this.elements[p++]=-1}}},n.prototype.outputContours_=function(r,e){var t,o,i=0,s=0;this.vertexCount=0,this.elementCount=0;for(var a=r.fHead.next;a!==r.fHead;a=a.next)if(!!a.inside){o=t=a.anEdge;do this.vertexCount++,t=t.Lnext;while(t!==o);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*e,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var c=0,d=0,l=0;i=0;for(var a=r.fHead.next;a!==r.fHead;a=a.next)if(!!a.inside){s=0,o=t=a.anEdge;do this.vertices[c++]=t.Org.coords[0],this.vertices[c++]=t.Org.coords[1],e>2&&(this.vertices[c++]=t.Org.coords[2]),this.vertexIndices[d++]=this.vertexIdCallback?this.vertexIdCallback(t):t.Org.idx,s++,t=t.Lnext;while(t!==o);this.elements[l++]=i,this.elements[l++]=s,i+=s}},n.prototype.addContour=function(r,e){this.mesh===null&&(this.mesh=new sy),r<2&&(r=2),r>3&&(r=3);for(var t=null,o=0;o<e.length;o+=r)t===null?(t=this.mesh.makeEdge(),this.mesh.splice(t,t.Sym)):(this.mesh.splitEdge(t),t=t.Lnext),t.Org.coords[0]=e[o+0],t.Org.coords[1]=e[o+1],r>2?t.Org.coords[2]=e[o+2]:t.Org.coords[2]=0,t.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(t),t.winding=1,t.Sym.winding=-1},n.prototype.tesselate=function(r,e,t,o,i,s){if(r===void 0&&(r=Oe.ODD),e===void 0&&(e=Je.POLYGONS),s===void 0&&(s=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,i&&(this.normal[0]=i[0],this.normal[1]=i[1],this.normal[2]=i[2]),this.windingRule=r,o<2&&(o=2),o>3&&(o=3),!this.mesh)return!1;this.projectPolygon_(),LP.computeInterior(this,s);var a=this.mesh;return e===Je.BOUNDARY_CONTOURS?this.setWindingNumber_(a,1,!0):this.tessellateInterior_(a),s&&a.check(),e===Je.BOUNDARY_CONTOURS?this.outputContours_(a,o):this.outputPolymesh_(a,e,t,o),!0},n}();function Or(n){var r=n.windingRule,e=r===void 0?Oe.ODD:r,t=n.elementType,o=t===void 0?Je.POLYGONS:t,i=n.polySize,s=i===void 0?3:i,a=n.vertexSize,c=a===void 0?2:a,d=n.normal,l=d===void 0?[0,0,1]:d,u=n.contours,p=u===void 0?[]:u,f=n.strict,m=f===void 0?!0:f,h=n.debug,y=h===void 0?!1:h;if(!p&&m)throw new Error("Contours can't be empty");if(!!p){var g=new DP;n.edgeCreateCallback&&(g.edgeCreateCallback=n.edgeCreateCallback),n.vertexIdCallback&&(g.vertexIdCallback=n.vertexIdCallback);for(var x=0;x<p.length;x++)g.addContour(c||2,p[x]);return g.tesselate(e,o,s,c,l,m),{vertices:g.vertices,vertexIndices:g.vertexIndices,vertexCount:g.vertexCount,elements:g.elements,elementCount:g.elementCount,mesh:y?g.mesh:void 0}}}var mV=Oe.ODD,hV=Oe.NONZERO,yV=Oe.POSITIVE,gV=Oe.NEGATIVE,xV=Oe.ABS_GEQ_TWO,vV=Je.POLYGONS,bV=Je.CONNECTED_POLYGONS,SV=Je.BOUNDARY_CONTOURS;var fn=require("three");var Wl=class{constructor(r=256,e=!1){this.capacity=r,this.size=0,this.debug=e,this.debug&&console.log(`allocating with cap ${r}`);let t=r*Wl.eSize;this.buffer=new ArrayBuffer(t);let o=Float32Array.BYTES_PER_ELEMENT,i=0;this.positions=new Float32Array(this.buffer,i*o,3*r),i+=3*r,this.normals=new Float32Array(this.buffer,i*o,3*r),i+=3*r,this.uvs=new Float32Array(this.buffer,i*o,2*r)}realloc(r,e=!1){if(r<this.size)throw Error("cannot shrink buffer");if(r<=this.capacity&&!e)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${r}`);let t=r*Wl.eSize,o=new ArrayBuffer(t),i=Float32Array.BYTES_PER_ELEMENT,s=0,a=new Float32Array(o,s*i,3*r);s+=3*r;let c=new Float32Array(o,s*i,3*r);s+=3*r;let d=new Float32Array(o,s*i,2*r);e?(a.set(this.positions.subarray(0,this.size*3)),c.set(this.normals.subarray(0,this.size*3)),d.set(this.uvs.subarray(0,this.size*2))):(a.set(this.positions),c.set(this.normals),d.set(this.uvs)),this.buffer=o,this.positions=a,this.normals=c,this.uvs=d,this.capacity=r}get(r=1){let e=this.size+r;if(e>this.capacity){let o=this.capacity;for(;e>o;)o*=2;this.realloc(o)}let t=this.size;return this.size=e,t}reserve(r){let e=this.size+r;e>this.capacity&&this.realloc(e)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},Xs=Wl;Xs.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var fy=Ts(py()),Ks={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},qu={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},$u={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},Wu=(n,r)=>([e,t])=>(t<e&&(t+=r),(n>=e?n:n+r)<=t),Ho=class extends fn.BufferGeometry{constructor(e,t,o=0,i=12,s=3,a=Oe.ODD,c=!1){super();this.forPathBevel=c;this.type="ShapeGeometry";this.vertexCache={};this._shape=e,this._depth=t,this._curveSegments=i,this._bevelSegmentsInput=s;let d=this._shape.extractShapePointsToFlatArray([],i),l=this._shape.shapeHoles.map(C=>{let O=C.extractShapePointsToFlatArray([],i),A=[];for(let M=O.length-1;M>=1;M-=2){let L=O[M-1],X=O[M-0];A.push(L,X)}return A}),u=[],p=[];for(let C=0;C<d.length;C+=2)p.push([d[C],d[C+1]]);u.push(p);for(let C=0;C<l.length;C++){let O=l[C],A=[];for(let M=0;M<O.length;M+=2)A.push([O[M],O[M+1]]);u.push(A)}let f=u[0].length?(0,fy.default)(u).distance:o;o<=0?(this._bevel=0,this._bevelSegments=0):(this._bevel=Math.min(o,f,t/2),this._bevelSegments=Math.floor(s));let m;try{m=Or({windingRule:a,elementType:Je.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[d]})}catch{m=Ks}let h;try{h=Or({windingRule:Oe.ODD,elementType:Je.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...l]})}catch{h=qu}if(!m)throw new Error("error generating geometry");let y=m.elementCount;if(h){m.elementCount+=h.elementCount;for(let C=0;C<h.elements.length;C++){let O=h.elements[C],A=C%2===0?m.vertexCount:0;m.elements.push(O+A)}for(let C=0;C<h.vertexIndices.length;C++){let O=h.vertexIndices[C],A=m.vertexCount;m.vertexIndices.push(O+A)}for(let C=0;C<h.vertices.length;C++){let O=h.vertices[C];m.vertices.push(O)}}let g=1/0,x=-1/0,S=1/0,w=-1/0;for(let C=0,O=m.vertexCount;C<O;C++){let A=C*2,M=m.vertices[A+0],L=m.vertices[A+1];M<g&&(g=M),M>x&&(x=M),L<S&&(S=L),L>w&&(w=L)}this._minX=g,this._minY=S,this._width=x-g,this._height=w-S,this._buffer=new Xs(this._computeBufferEstimatedSize(m));let b=[],_=[];for(let C=m.elementCount-1;C>=0;C--){let O=C>=y,A=C*2,M=m.elements[A+0],L=m.elements[A+1],X=M+L,R={start:M,count:L,normals:[],continuous:[],concave:[]},Z=M,z=X-1,V=M+1,W=this._shape.roundedCurves.length;do{let U=Z-M,B=m.vertices[z*2+0],F=m.vertices[z*2+1],j=m.vertices[Z*2+0],D=m.vertices[Z*2+1],ne=m.vertices[V*2+0],ee=m.vertices[V*2+1],K=j-B,te=D-F,Q=Math.sqrt(K*K+te*te);K/=Q,te/=Q;let le=j-ne,ie=D-ee,se=Math.sqrt(le*le+ie*ie);le/=se,ie/=se,R.normals[U*2+0]=-ie,R.normals[U*2+1]=le,R.concave[U]=K*ie-te*le>0;let ue=m.vertexIndices[Z];if(Array.isArray(ue))R.continuous[U]=!1;else{let[ce,de]=this._shape.getCurveIndexFromVertexId(ue-1,!0);if(de>0&&de<1)R.continuous[U]=!0;else{let he=de===1?ce+1:ce-1;he=(he+W)%W;let Ae=de===1?0:1,$e=this._shape.roundedCurves[ce].getTangent(de),Ce=this._shape.roundedCurves[he].getTangent(Ae);R.continuous[U]=$e.dot(Ce)>.95}}O&&(R.normals[U*2+0]*=-1,R.normals[U*2+1]*=-1),[z,Z,V]=[Z,V,V+1],V>=X&&(V-=L)}while(V!==M+1);let $=[];$.push({bevelI:0,angle:0,size:0,boundary:{vertices:m.vertices.slice(M*2,X*2),vertexCount:L,vertexIndices:new Array(L).fill(!0).map((U,B)=>[B,B]),elements:[0,L],elementCount:1,mesh:null},reverseMap:[],insetPoints:m.vertices.slice(M*2,X*2)});let Y=0;for(let U=1;U<=this._bevelSegments;U++){let B=U/this._bevelSegments*Math.PI/2,F=(1-Math.cos(B))*this._bevel,j=[],D=[],ne=[],ee=[],K=0;for(let Q=0;Q<L;Q++){let le=Q*2,ie=(Q-1+L)%L*2,se=m.vertices[R.start*2+le+0],ue=m.vertices[R.start*2+le+1],ce=-R.normals[ie+0]*F,de=-R.normals[ie+1]*F,he=-R.normals[le+0]*F,Ae=-R.normals[le+1]*F;if(R.concave[Q]||!R.concave[Q]&&O){let $e=Math.atan2(de,ce),Ce=Math.atan2(Ae,he);Ce>$e&&(Ce-=Math.PI*2);let Fe=Ce-$e;if(R.continuous[Q]||O){let Wt=$e+Fe/2,we=Math.cos(Wt)*F,pt=Math.sin(Wt)*F;j[2*K+0]=se+we*(O?-1:1),j[2*K+1]=ue+pt*(O?-1:1),ee[K]=Q,K++}else{let Wt=Math.max(1,Math.floor(i/4*Math.abs(Fe)/Math.PI));for(let we=0;we<=Wt;we++){let pt=$e+Fe*(we/Wt),xt=Math.cos(pt)*F,Mn=Math.sin(pt)*F;j[2*K+0]=se+xt,j[2*K+1]=ue+Mn,ee[K]=Q,K++}}}else j[2*K+0]=se+ce,j[2*K+1]=ue+de,ee[K]=Q,D[Q]=K,K++,j[2*K+0]=se,j[2*K+1]=ue,ee[K]=Q,K++,j[2*K+0]=se+he,j[2*K+1]=ue+Ae,ee[K]=Q,ne[Q]=K,K++}let te=Or({windingRule:Oe.POSITIVE,elementType:Je.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[j],edgeCreateCallback:Q=>{let ie=Q.Org.idx,se=ee[ie],ue=ee[(ie+1)%ee.length];Q.idx=[se,ue],Q.Sym.idx=[ue,se]},vertexIdCallback:Q=>{let le=Q.Lprev.idx;return[le?le[1]:0,Q.idx?Q.idx[0]:0]}});if(!te)throw console.log("Error"),new Error(`error generating bevel geometry for ${U}'th loop`);if(!te.vertexCount){let Q=(U-1)/this._bevelSegments*Math.PI/2;Y=(1-Math.sin(Q))*this._bevel;break}for(let Q=0;Q<te.vertexIndices.length;Q++){let[le,ie]=te.vertexIndices[Q];if(le===ie)continue;let se=ie;ie<le&&(se+=L);for(let ue=le;ue<se;ue++){let ce=ue%L,de=(ue+1)%L;if(!R.continuous[ce]||!R.continuous[de]){te.vertexIndices[Q]=[le,ce],te.vertexIndices.splice(Q+1,0,[de,ie]),te.vertices.splice((Q+1)*2,0,te.vertices[Q*2],te.vertices[Q*2+1]);break}}}$.push({bevelI:U,angle:B,size:F,boundary:te,reverseMap:ee,insetPoints:j})}let q=(U,B,F)=>{let j=0,D=U.boundary.vertexIndices.length;for(;j<D&&F(U.boundary.vertexIndices[B]);)B=(B+1)%D,j++;return j},k=b.length;for(let U=1;U<$.length;U++){let B=$[U-1],F=$[U],j=B.boundary.vertexIndices.length,D=F.boundary.vertexIndices.length;if(!j||!D)break;let ne=R.concave.length,ee=0,K=Wu(ee,L);for(;!B.boundary.vertexIndices.filter(K).length||!F.boundary.vertexIndices.filter(K).length;)ee++,K=Wu(ee,L);let te=B.boundary.vertexIndices.findIndex(K),Q=F.boundary.vertexIndices.findIndex(K);do te=(te+1)%j;while(K(B.boundary.vertexIndices[te]));do Q=(Q+1)%D;while(K(F.boundary.vertexIndices[Q]));ee=(ee+1)%L;let le=ee,ie=0,se=this._buildBevelVert(R,B,(te-1+j)%j,void 0,ie),ue=this._buildBevelVert(R,F,(Q-1+D)%D,void 0,ie),ce=se,de=ue,he,Ae,$e=!1;do{ie=(ee||ne)/ne,K=Wu(ee,L);let Ce=q(B,te,K),Fe=q(F,Q,K),Wt=$e;if($e=!1,Ce&&!Fe){for(let we=0;we<Ce;we++)he=this._buildBevelVert(R,B,(te+we)%j,we/(Ce-1),ie),b.push(ce.topN,he.topP,de.topN),c===!1&&b.push(he.bottomP,ce.bottomN,de.bottomN),ce=he;$e=!0}else if(!Ce&&Fe)for(let we=0;we<Fe;we++)Ae=this._buildBevelVert(R,F,(Q+we)%D,we/(Fe-1),ie),b.push(de.topN,ce.topP,Ae.topP),c===!1&&b.push(ce.bottomP,de.bottomN,Ae.bottomP),de=Ae;else if(Ce&&Fe)if(he=this._buildBevelVert(R,B,te,0,ie),Ae=this._buildBevelVert(R,F,Q,0,ie),Wt?(b.push(ce.topN,Ae.topP,de.topN),b.push(ce.topN,he.topP,Ae.topP),c===!1&&(b.push(Ae.bottomP,ce.bottomN,de.bottomN),b.push(Ae.bottomP,he.bottomP,ce.bottomN))):(b.push(de.topN,ce.topN,he.topP),b.push(de.topN,he.topP,Ae.topP),c===!1&&(b.push(he.bottomP,ce.bottomN,de.bottomN),b.push(he.bottomP,de.bottomN,Ae.bottomP))),ce=he,de=Ae,Ce===Fe)for(let we=1;we<Ce;we++)he=this._buildBevelVert(R,B,(te+we)%j,we/(Ce-1),ie),Ae=this._buildBevelVert(R,F,(Q+we)%D,we/(Fe-1),ie),b.push(ce.topN,he.topP,de.topN),b.push(de.topN,he.topP,Ae.topP),c===!1&&(b.push(he.bottomP,ce.bottomN,de.bottomN),b.push(he.bottomP,de.bottomN,Ae.bottomP)),ce=he,de=Ae;else if(Ce>Fe){let we=Ce/Fe,pt=0;for(let xt=1;xt<Ce;xt++)he=this._buildBevelVert(R,B,(te+xt)%j,xt/(Ce-1),ie),b.push(ce.topN,he.topP,de.topN),c===!1&&b.push(he.bottomP,ce.bottomN,de.bottomN),ce=he,xt>(pt+1)*we&&(pt++,Ae=this._buildBevelVert(R,F,(Q+pt)%D,pt/(Fe-1),ie),b.push(de.topN,he.topP,Ae.topP),c===!1&&b.push(he.bottomP,de.bottomN,Ae.bottomP),de=Ae)}else{let we=Fe/Ce,pt=0;for(let xt=1;xt<Fe;xt++)Ae=this._buildBevelVert(R,F,(Q+xt)%D,xt/(Fe-1),ie),b.push(de.topN,he.topP,Ae.topP),c===!1&&b.push(he.bottomP,de.bottomN,Ae.bottomP),de=Ae,xt>(pt+1)*we&&(pt++,he=this._buildBevelVert(R,B,(te+pt)%j,pt/(Ce-1),ie),b.push(ce.topN,he.topP,de.topN),c===!1&&b.push(he.bottomP,ce.bottomN,de.bottomN),ce=he)}te=(te+Ce)%j,Q=(Q+Fe)%D,ee=(ee+1)%ne}while(ee!==le)}if(c===!1&&this._depth>this._bevel*2&&this._buildWall($,R,b),O){let U=[];for(let B=b.length-1;B>=k+2;B-=3){let F=b[B-2],j=b[B-1],D=b[B-0];U.push(D,j,F)}b.splice(k,b.length-k,...U)}if(O){let U=[];for(let B=$[$.length-1].boundary.vertices.length-1;B>=1;B-=2){let F=$[$.length-1].boundary.vertices[B-1],j=$[$.length-1].boundary.vertices[B-0];U.push(F,j)}_.push(U)}if(!O){let U=$[$.length-1],B;try{B=Or({windingRule:$.length>1?Oe.POSITIVE:Oe.ODD,elementType:Je.POLYGONS,vertexSize:2,strict:!0,contours:[U.insetPoints,..._]})}catch{B=$u}if(!B)throw new Error("Error generating geometry for surface");l.length===0&&this._bevel<f&&Object.assign(this,{useNgonForTopBottomFaceDuringBake:!0});for(let F=0;F<B.elementCount*3;F+=3){let j=this._buildSurfaceVert(B,B.elements[F+0],Y),D=this._buildSurfaceVert(B,B.elements[F+1],Y),ne=this._buildSurfaceVert(B,B.elements[F+2],Y);b.push(j.top,D.top,ne.top),c===!1&&b.push(ne.bottom,D.bottom,j.bottom)}}this.vertexCache={}}this._buffer.shrink();let P=new fn.BufferAttribute(Uint32Array.from(b),1),v=new fn.BufferAttribute(this._buffer.positions,3),N=new fn.BufferAttribute(this._buffer.normals,3),T=new fn.BufferAttribute(this._buffer.uvs,2);v.needsUpdate=!0,N.needsUpdate=!0,T.needsUpdate=!0,P.needsUpdate=!0,this.setAttribute("position",v),this.setAttribute("normal",N),this.setAttribute("uv",T),this.setIndex(P)}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,t,o){let i=e[0];for(let s=0,a=i.boundary.vertexCount;s<a;s++){let c=this._buildBevelVert(t,i,s),d=this._buildBevelVert(t,i,(s+1)%a);o.push(d.topP,c.topN,c.bottomN),o.push(d.topP,c.bottomN,d.bottomP)}}_buildSurfaceVert(e,t,o){let i=t.toString();if(i in this.vertexCache)return this.vertexCache[i];let s=e.vertices[t*2+0],a=e.vertices[t*2+1],c=(s-this._minX)/this._width,d=(a-this._minY)/this._height;this.forPathBevel&&(d=1);let l=this._buffer.get(this.forPathBevel?1:2),u=l*3,p=l*2,f={top:l+0,bottom:l+1};return this._buffer.positions[u+0]=s,this._buffer.positions[u+1]=a,this._buffer.positions[u+2]=this.forPathBevel?this._bevel:this._depth-o,this._buffer.normals[u+0]=0,this._buffer.normals[u+1]=0,this._buffer.normals[u+2]=1,this._buffer.uvs[p+0]=c,this._buffer.uvs[p+1]=d,this.forPathBevel===!1&&(this._buffer.positions[u+3]=s,this._buffer.positions[u+4]=a,this._buffer.positions[u+5]=o,this._buffer.normals[u+3]=0,this._buffer.normals[u+4]=0,this._buffer.normals[u+5]=-1,this._buffer.uvs[p+2]=c,this._buffer.uvs[p+3]=d),this.vertexCache[i]=f,f}_buildBevelVert(e,t,o,i=1,s){let a=`${t.bevelI}:${o}`;if(a in this.vertexCache&&s!==0&&s!==1&&(!s||s===this.vertexCache[a].pathBevelUCoord))return this.vertexCache[a];let[c,d]=t.boundary.vertexIndices[o],l,u,p,f;c!==d?(u=c,l=d,f=!1,p=e.continuous[u]&&e.continuous[l]):(l=c,u=(l-1+e.count)%e.count,f=e.concave[l]&&t.bevelI>0,p=e.continuous[l]||f);let m=Math.cos(t.angle),h=Math.sin(t.angle),y=o*2,g=l*2,x=u*2,S=t.boundary.vertices[y+0],w=t.boundary.vertices[y+1],b=(1-h)*this._bevel,_=(S-this._minX)/this._width,P=(w-this._minY)/this._height;this.forPathBevel&&(s!==void 0&&(_=s),P=1);let v=e.normals[g+0],N=e.normals[g+1],T=e.normals[x+0],C=e.normals[x+1];if(f){let X=T-v,R=C-N;v=v+X*(1-i),N=N+R*(1-i);let Z=Math.sqrt(v*v+N*N);v/=Z,N/=Z}let O=this.forPathBevel?this._buffer.get(p?1:2):this._buffer.get(p?2:4),A=O*3,M=O*2,L={i:o,fi:l,topP:O+0,topN:O+0,bottomP:O+1,bottomN:O+1,pathBevelUCoord:s};return this._buffer.positions[A+0]=S,this._buffer.positions[A+1]=w,this._buffer.positions[A+2]=(this.forPathBevel?this._bevel:this._depth)-b,this._buffer.normals[A+0]=v*m,this._buffer.normals[A+1]=N*m,this._buffer.normals[A+2]=h,this._buffer.uvs[M+0]=_,this._buffer.uvs[M+1]=P,this.forPathBevel===!1&&(this._buffer.positions[A+3]=S,this._buffer.positions[A+4]=w,this._buffer.positions[A+5]=b,this._buffer.normals[A+3]=v*m,this._buffer.normals[A+4]=N*m,this._buffer.normals[A+5]=-h,this._buffer.uvs[M+2]=P,this._buffer.uvs[M+3]=_),p||(this.forPathBevel?(O+=1,A+=3,M+=2):(O+=2,A+=6,M+=4),L.topP=O+0,L.bottomP=O+1,this._buffer.positions[A+0]=S,this._buffer.positions[A+1]=w,this._buffer.positions[A+2]=(this.forPathBevel?this._bevel:this._depth)-b,this._buffer.normals[A+0]=T*m,this._buffer.normals[A+1]=C*m,this._buffer.normals[A+2]=h,this._buffer.uvs[M+0]=_,this._buffer.uvs[M+1]=P,this.forPathBevel===!1&&(this._buffer.positions[A+3]=S,this._buffer.positions[A+4]=w,this._buffer.positions[A+5]=b,this._buffer.normals[A+3]=T*m,this._buffer.normals[A+4]=C*m,this._buffer.normals[A+5]=-h,this._buffer.uvs[M+2]=P,this._buffer.uvs[M+3]=_)),this.vertexCache[a]=L,L}clone(){let e=new Ho(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=uo(this.userData),e}};var Ti=class extends mn.BufferGeometry{constructor(e,t=12,o={}){super();this.type="ShapeGeometry";this.windingRule=Oe.ODD;this.elementType=Je.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=e,this._curveSegments=t,this._triangulationOptions=Object.assign({windingRule:Oe.ODD,elementType:Je.POLYGONS,polySize:3,vertexSize:2,strict:!0},o);let i=this._shape.extractShapePointsToFlatArray([],this._curveSegments),s=this._shape.shapeHoles.map(m=>m.extractShapePointsToFlatArray([],this._curveSegments)),a,c=!0,d=!0,l,u;for(let m=0,h=i.length/2;m<h;m++){let y=m*2,g=i[y+0],x=i[y+1];if(l!==void 0&&g!==l&&(c=!1),u!==void 0&&x!==u&&(d=!1),l=g,u=x,!c&&!d)break}if(!c&&!d)try{a=Or({contours:[i,...s],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})}catch{a=Ks}let p=a?.vertexCount??1,f=a?.elementCount??1;if(this._positionAttribute=new mn.BufferAttribute(new Float32Array(p*3),3),this._normalAttribute=new mn.BufferAttribute(new Float32Array(p*3),3),this._uvAttribute=new mn.BufferAttribute(new Float32Array(p*2),2),this._indexAttribute=new mn.BufferAttribute(new Uint32Array(f*3),1),a){let m=1/0,h=-1/0,y=1/0,g=-1/0;for(let w=0,b=p;w<b;w++){let _=w*2,P=a.vertices[_+0],v=a.vertices[_+1];P<m&&(m=P),P>h&&(h=P),v<y&&(y=v),v>g&&(g=v)}let x=h-m,S=g-y;for(let w=0,b=p;w<b;w++){let _=w*2,P=a.vertices[_+0],v=a.vertices[_+1],N=(P-m)/x,T=(v-y)/S;this._positionAttribute.setXYZ(w,P,v,0),this._normalAttribute.setXYZ(w,0,0,1),this._uvAttribute.setXY(w,N,T)}for(let w=0,b=f;w<b;w++){let _=w*3,P=a.elements[_+0],v=a.elements[_+1],N=a.elements[_+2];this._indexAttribute.setX(_+0,P),this._indexAttribute.setX(_+1,v),this._indexAttribute.setX(_+2,N)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,(a?.elementCount??1)*3)}clone(){let e=new Ti(this._shape,this._curveSegments);return e.userData=uo(this.userData),e}};var Oi=class extends Ho{constructor(e,t,o=0,i=12,s=3,a=Oe.ODD){super(e,t,o,i,s,a);this.type="ShapeGeometry"}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,t,o){let i=e[0];for(let s=0,a=i.boundary.vertexCount;s<a;s++){let c=this._buildBevelVert(t,i,s),d=this._buildBevelVert(t,i,(s+1)%a);o.push(d.topP,c.topN,c.bottomN),o.push(d.topP,c.bottomN,d.bottomP)}}clone(){let e=new Oi(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=uo(this.userData),e}};var Kt=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:Oe.ODD},n.parameters),t=Math.abs(e.width),o=Math.abs(e.height??e.width),i=Math.abs(e.depth??0),s=n.shape??r?.shape,a=s?.roundness??e.roundness;s!==void 0&&(s instanceof Me?(s.width!==t||s.height!==o)&&s.applySize(t,o):s=new Me(t,o).fromJSON(s),n.parameters?.roundness!==void 0&&n.parameters?.roundness>0&&s.update());let c=s??new Me(t,o);return{parameters:Object.assign(e,{width:t,height:o,depth:i,roundness:a}),shape:c}}static build(n){let{depth:r,extrudeBevelSize:e,extrudeBevelSegments:t,subdivisions:o,roundness:i,windingRule:s}=n.parameters;n.shape.roundness=i;let a;return r<=0?a=new Ti(n.shape,o,{windingRule:s}):a=new Oi(n.shape,r,e,o,t,s),Object.assign(a,{userData:{...n,type:"VectorGeometry"}})}};var Ci=require("three"),hy=Math.PI*2,Ni=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters);return{shape:n.shape&&n.shape instanceof Me?n.shape:new Me,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(n){let{width:r,height:e,spikes:t,angle:o,innerRadius:i,depth:s,extrudeBevelSize:a,extrudeBevelSegments:c}=n.parameters,d=n.shape,l=r*.5,u=e*.5,p=zP(d,l,u,o*Math.PI/180,t,i);d.isClosed=!0,d.update();let f=Kt.create({shape:d,parameters:{subdivisions:p,depth:s,extrudeBevelSize:a,extrudeBevelSegments:c}});return Object.assign(f,{userData:{...n,type:"EllipseGeometry"}})}};function zP(n,r,e,t,o,i){if(t>=hy)return o>30||o%4===0?(FP(n,r,e,i),Math.round(o/4)):my(n,t,o,r,e,i);t=Math.max(t,.001);let s={x:0,y:e},a=t+Math.PI*.5,c={x:Math.cos(a)*r,y:Math.sin(a)*e},d=iy({px:s.x,py:s.y,cx:c.x,cy:c.y,rx:r,ry:e,largeArcFlag:t>Math.PI,sweepFlag:!0});return o>30||o%d.length===0?jP(n,s.x,s.y,d,o,r,e,i):my(n,t,o,r,e,i)}function jP(n,r,e,t,o,i,s,a){let c=Math.round(o/t.length);n.addPoint(Ai(r,e));for(let d=0,l=t.length;d<l;d++){let u=t[d],p=n.points[d],f=Ai(u.x,u.y);p.controls[1].position.set(u.x1,u.y1),f.controls[0].position.set(u.x2,u.y2),n.addPoint(f)}return a>0?yy(n,i,s,a):n.addPoint(Ai(0,0)),c}function my(n,r,e,t,o,i){let s=-r/e;for(let a=0;a<=e;a++){let c=s*a,d=Math.sin(c)*t,l=Math.cos(c)*o;n.addPoint(Ai(d,l))}return r<hy?i>0?yy(n,t,o,i):n.addPoint(Ai(0,0)):(n.removePoint(n.points[n.points.length-1]),i>0&&gy(n,t,o,i)),1}function FP(n,r,e,t=0,o=0,i=0){let s=.5522847498,a=r*s,c=e*s;n.addPoint($l(o-r,i,o-r,i-c,o-r,i+c)),n.addPoint($l(o,i+e,o-a,i+e,o+a,i+e)),n.addPoint($l(o+r,i,o+r,i+c,o+r,i-c)),n.addPoint($l(o,i-e,o+a,i-e,o-a,i-e)),t>0&&gy(n,r,e,t)}function Ai(n,r){return new Tr(Ci.MathUtils.generateUUID(),new Ci.Vector2(n,r))}function $l(n,r,e,t,o,i){let s=Ai(n,r);return s.controls[0].position.set(e,t),s.controls[1].position.set(o,i),s}function yy(n,r,e,t){xy(n,r,e,t).forEach(i=>n.addPoint(i))}function gy(n,r,e,t){let o=xy(n,r,e,t),i=new Me;o.forEach(s=>i.addPoint(s)),i.isClosed=!0,n.shapeHoles.push(i)}function xy(n,r,e,t){let o=t*r/100,i=o*(Math.abs(e)/Math.abs(r)),s=new Ci.Vector2(o/r,i/e),a=n.points.map(c=>{let d=c.clone();return d.uuid=Ci.MathUtils.generateUUID(),d}).reverse();return a.forEach(c=>{c.position.multiply(s);let d=c.controls[0].position.clone().multiply(s),l=c.controls[1].position.clone().multiply(s);c.controls[0].position.copy(l),c.controls[1].position.copy(d)}),a}var Ar=require("three"),vy=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},n.parameters),t=Math.abs(e.width),o=Math.abs(e.height??t),i=Math.abs(e.depth??t),s=Math.abs(Math.min(t,i))/2;return{parameters:Object.assign(e,{width:t,height:o,depth:i,radius:s,segments:Math.round(e.segments),pathSegments:Math.round(e.pathSegments),cornerSegments:Math.round(e.cornerSegments)})}}static build(n){let{width:r,height:e,depth:t,radius:o,revolutions:i,segments:s,pathRadius:a,pathType:c,pathSegments:d,cornerRadius:l,cornerSegments:u}=n.parameters,p=new Zs(!1,r,e,t,o,i,s,a,c,d,l,u);return Object.assign(p,{userData:{...n,type:"HelixGeometry"}})}},Yu=new Ar.Uint32BufferAttribute([0,0,0],1),Zs=class extends Ar.BufferGeometry{constructor(r=!0,e=1,t=1,o=1,i=1,s=1,a=1,c=1,d=1,l=1,u=1,p=1){if(super(),s===0)return;let f=r&&s===1;f&&(p=0),u>100&&(u=100),u===0&&(p=0);let m=()=>new Ar.Vector3,h=new Ar.Vector3,y=m(),g=m(),x=m(),S,w,b,_,P,v,N,T,C=m(),O=m(),A=m(),M=m(),L=m(),X=m(),R=m(),Z=m(),z=t-2*c+.001,V=z/s,W=Math.ceil(a*s),$=W+1,Y=z/W,q=-z/2,k=l+1,U=2*Math.PI/l,B=Math.PI/2/p,F=.01,j=Math.min((1-u/100)*c,c-F),D=c-j,ne=0,ee=2,K=p*ee+ee,te=k*K/ee,Q=te+k*$,le=k*($+K),[ie,se,ue]=[3,3,2].map(st=>Array(le*st).fill(0)),ce=[],de=i-c;function he(st,rr){let Dr=Math.PI/2;v=rr*Y,T=2*Math.PI*(v%V)/V+Dr,v+=q,N=Math.sin(T)*de,P=Math.cos(T)*de,r?st.set(P,N,v):st.set(P,v,N)}he(h,-1e-10),he(y,0),C.copy(h),he(h,1);let Ae=h.distanceTo(y),$e=f?0:D+j,Ce=Ae*W+2*$e,Fe=j,Wt=Ce-$e;for(let st=0;st<=W;st++){he(g,st),Z.subVectors(g,C).normalize(),C.copy(g),X.copy(g).setComponent(+r+1,0).normalize(),R.crossVectors(Z,X).normalize();let rr=st===0,Dr=st===W,z0=rr?3*Math.PI/2:B,j0=rr?Fe:Wt,F0=rr?k:Q,k0=rr?0:le-k,U0=Z.clone().multiplyScalar(rr?-D:D).add(g),H0=Z.clone().multiplyScalar(rr?-1:1).normalize();for(let io=0;io<k;io++){let $d=io*U;if(O.addVectors(h.copy(X).multiplyScalar(c*Math.cos($d)),y.copy(R).multiplyScalar(c*Math.sin($d))),A.copy(O).normalize(),rr||Dr){f||(ne=k0+io,[0,1,2].forEach(qt=>{ie[ne*3+qt]=U0.getComponent(qt),se[ne*3+qt]=H0.getComponent(qt)}),ue[ne*2]=+Dr,ue[ne*2+1]=io/l),y.copy(A).multiplyScalar(j),x.addVectors(g,y);for(let qt=0;qt<p;qt++){let Uc=qt*B+z0;M.addVectors(h.copy(Z).multiplyScalar(D*Math.sin(Uc)),y.copy(A).multiplyScalar(D*Math.cos(Uc))),L.copy(M).normalize(),y.addVectors(x,M),M.normalize(),ne=F0+qt*k+io,[0,1,2].forEach(Ma=>{ie[ne*3+Ma]=y.getComponent(Ma),se[ne*3+Ma]=L.getComponent(Ma)});let W0=+rr+Math.sin(Uc);ue[ne*2]=(j0+D*W0)/Ce,ue[ne*2+1]=io/l}}y.addVectors(g,O),ne=te+st*k+io,[0,1,2].forEach(qt=>{ie[ne*3+qt]=y.getComponent(qt),se[ne*3+qt]=A.getComponent(qt)}),ue[ne*2]=($e+st*Ae)/Ce,ue[ne*2+1]=io/l}}let we=$+2*p+ee,pt=1,[xt,Mn]=[+f,we-1];for(let st=xt;st<=Mn-1;st++){let rr=f&&st===Mn-1;for(let Dr=0;Dr<k-1;Dr++)S=st*k+Dr,w=S+1,b=(rr?Dr:S)+k,_=(rr?Dr+1:w)+k,st===0?ce.push(w,_,b):st===we-2?ce.push(S,w,b):ce.push(S,w,b,w,_,b)}this.setIndex(ce),this.setAttribute("position",new Ar.Float32BufferAttribute(ie,3)),this.setAttribute("normal",new Ar.Float32BufferAttribute(se,3)),this.setAttribute("uv",new Ar.Float32BufferAttribute(ue,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let r=this.userData.parameters,e=Math.ceil(r.tubularSegments),t=r.radialSegments+1,o=Array.from(this.getIndex().array),i,s,a,c,d=6*(e-1)*r.radialSegments,l=e,u=l===e;for(let p=0;p<r.radialSegments;p++)i=l*t+p,s=i+1,a=(u?p:i)+t,c=(u?p+1:s)+t,o[d++]=i,o[d++]=s,o[d++]=a,o[d++]=s,o[d++]=c,o[d++]=a;return o.length=d,Yu.array=o,Yu.count=o.length,Yu}};var by=require("three");var Sy=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,detail:0,corner:0,cornerSides:4},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:r,height:e,depth:t,detail:o,corner:i,cornerSides:s}=n.parameters,a=o===0&&i!==0?new Qs(r*.5,i,s):new by.IcosahedronGeometry(r*.5,o);return a.scale(1,e/r,t/r),Object.assign(a,{userData:{...n,type:"IcosahedronGeometry"}})}},Qs=class extends Fo{constructor(r=1,e=.2,t=4){let o=(1+Math.sqrt(5))/2,i=[-1,o,0,1,o,0,-1,-o,0,1,-o,0,0,-1,o,0,1,o,0,-1,-o,0,1,-o,o,0,-1,o,0,1,-o,0,-1,-o,0,1],s=[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],a="IcosahedronGeometry";super(i,s,a,r,e,t),this.type=a}static fromJSON(r){return new Qs(r.radius,r.corner,r.cornerSides)}};var Yl=require("three"),wy=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){(n.parameters?.points??[]).forEach(t=>{Array.isArray(t)&&(t.x=t[0],t.y=t[1])});let e=Object.assign({},r?.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}]},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{points:r,segments:e,verticalSegments:t}=n.parameters,o=new Yl.Shape;o.moveTo(r[0].x,r[0].y),o.bezierCurveTo(r[1].x,r[1].y,r[2].x,r[2].y,r[3].x,r[3].y);let i=new Yl.LatheGeometry(o.extractPoints(t).shape,e);return i.rotateZ(Math.PI),Object.assign(i,{userData:{...n,type:"LatheGeometry"}})}};var $r=require("three");var xo=require("three");var oe=require("three"),qr=new oe.Matrix4,Xu=new oe.Object3D,Xl=new oe.Vector3,Wo=class extends oe.EventDispatcher{constructor(){super(),this.uuid=oe.MathUtils.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}applyMatrix4(r){let e=new oe.Matrix3().getNormalMatrix(r);for(let t=0,o=this.vertices.length;t<o;t++)this.vertices[t].applyMatrix4(r);for(let t=0,o=this.faces.length;t<o;t++){let i=this.faces[t];i.normal.applyMatrix3(e).normalize();for(let s=0,a=i.vertexNormals.length;s<a;s++)i.vertexNormals[s].applyMatrix3(e).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this}rotateX(r){return qr.makeRotationX(r),this.applyMatrix4(qr),this}rotateY(r){return qr.makeRotationY(r),this.applyMatrix4(qr),this}rotateZ(r){return qr.makeRotationZ(r),this.applyMatrix4(qr),this}translate(r,e,t){return qr.makeTranslation(r,e,t),this.applyMatrix4(qr),this}scale(r,e,t){return qr.makeScale(r,e,t),this.applyMatrix4(qr),this}lookAt(r){return Xu.lookAt(r),Xu.updateMatrix(),this.applyMatrix4(Xu.matrix),this}fromBufferGeometry(r){let e=this,t=r.index!==null?r.index:void 0,o=r.attributes;if(o.position===void 0)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;let i=o.position,s=o.normal,a=o.color,c=o.uv,d=o.uv2;d!==void 0&&(this.faceVertexUvs[1]=[]);for(let p=0;p<i.count;p++)e.vertices.push(new oe.Vector3().fromBufferAttribute(i,p)),a!==void 0&&e.colors.push(new oe.Color().fromBufferAttribute(a,p));function l(p,f,m,h){let y=a===void 0?[]:[e.colors[p].clone(),e.colors[f].clone(),e.colors[m].clone()],g=s===void 0?[]:[new oe.Vector3().fromBufferAttribute(s,p),new oe.Vector3().fromBufferAttribute(s,f),new oe.Vector3().fromBufferAttribute(s,m)],x=new Ii(p,f,m,g,y,h);e.faces.push(x),c!==void 0&&e.faceVertexUvs[0].push([new oe.Vector2().fromBufferAttribute(c,p),new oe.Vector2().fromBufferAttribute(c,f),new oe.Vector2().fromBufferAttribute(c,m)]),d!==void 0&&e.faceVertexUvs[1].push([new oe.Vector2().fromBufferAttribute(d,p),new oe.Vector2().fromBufferAttribute(d,f),new oe.Vector2().fromBufferAttribute(d,m)])}let u=r.groups;if(u.length>0)for(let p=0;p<u.length;p++){let f=u[p],m=f.start,h=f.count;for(let y=m,g=m+h;y<g;y+=3)t!==void 0?l(t.getX(y),t.getX(y+1),t.getX(y+2),f.materialIndex):l(y,y+1,y+2,f.materialIndex)}else if(t!==void 0)for(let p=0;p<t.count;p+=3)l(t.getX(p),t.getX(p+1),t.getX(p+2));else for(let p=0;p<i.count;p+=3)l(p,p+1,p+2);return this.computeFaceNormals(),r.boundingBox!==null&&(this.boundingBox=r.boundingBox.clone()),r.boundingSphere!==null&&(this.boundingSphere=r.boundingSphere.clone()),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Xl).negate(),this.translate(Xl.x,Xl.y,Xl.z),this}normalize(){this.computeBoundingSphere();let r=this.boundingSphere.center,e=this.boundingSphere.radius,t=e===0?1:1/e,o=new oe.Matrix4;return o.set(t,0,0,-t*r.x,0,t,0,-t*r.y,0,0,t,-t*r.z,0,0,0,1),this.applyMatrix4(o),this}computeFaceNormals(){let r=new oe.Vector3,e=new oe.Vector3;for(let t=0,o=this.faces.length;t<o;t++){let i=this.faces[t],s=this.vertices[i.a],a=this.vertices[i.b],c=this.vertices[i.c];r.subVectors(c,a),e.subVectors(s,a),r.cross(e),r.normalize(),i.normal.copy(r)}}computeVertexNormals(r=!0){let e=new Array(this.vertices.length);for(let t=0,o=this.vertices.length;t<o;t++)e[t]=new oe.Vector3;if(r){let t=new oe.Vector3,o=new oe.Vector3;for(let i=0,s=this.faces.length;i<s;i++){let a=this.faces[i],c=this.vertices[a.a],d=this.vertices[a.b],l=this.vertices[a.c];t.subVectors(l,d),o.subVectors(c,d),t.cross(o),e[a.a].add(t),e[a.b].add(t),e[a.c].add(t)}}else{this.computeFaceNormals();for(let t=0,o=this.faces.length;t<o;t++){let i=this.faces[t];e[i.a].add(i.normal),e[i.b].add(i.normal),e[i.c].add(i.normal)}}for(let t=0,o=this.vertices.length;t<o;t++)e[t].normalize();for(let t=0,o=this.faces.length;t<o;t++){let i=this.faces[t],s=i.vertexNormals;s.length===3?(s[0].copy(e[i.a]),s[1].copy(e[i.b]),s[2].copy(e[i.c])):(s[0]=e[i.a].clone(),s[1]=e[i.b].clone(),s[2]=e[i.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeFlatVertexNormals(){this.computeFaceNormals();for(let r=0,e=this.faces.length;r<e;r++){let t=this.faces[r],o=t.vertexNormals;o.length===3?(o[0].copy(t.normal),o[1].copy(t.normal),o[2].copy(t.normal)):(o[0]=t.normal.clone(),o[1]=t.normal.clone(),o[2]=t.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let e=0,t=this.faces.length;e<t;e++){let o=this.faces[e];o.__originalFaceNormal?o.__originalFaceNormal.copy(o.normal):o.__originalFaceNormal=o.normal.clone(),o.__originalVertexNormals||(o.__originalVertexNormals=[]);for(let i=0,s=o.vertexNormals.length;i<s;i++)o.__originalVertexNormals[i]?o.__originalVertexNormals[i].copy(o.vertexNormals[i]):o.__originalVertexNormals[i]=o.vertexNormals[i].clone()}let r=new Wo;r.faces=this.faces;for(let e=0,t=this.morphTargets.length;e<t;e++){if(!this.morphNormals[e]){this.morphNormals[e]={},this.morphNormals[e].faceNormals=[],this.morphNormals[e].vertexNormals=[];let i=this.morphNormals[e].faceNormals,s=this.morphNormals[e].vertexNormals;for(let a=0,c=this.faces.length;a<c;a++){let d=new oe.Vector3,l={a:new oe.Vector3,b:new oe.Vector3,c:new oe.Vector3};i.push(d),s.push(l)}}let o=this.morphNormals[e];r.vertices=this.morphTargets[e].vertices,r.computeFaceNormals(),r.computeVertexNormals();for(let i=0,s=this.faces.length;i<s;i++){let a=this.faces[i],c=o.faceNormals[i],d=o.vertexNormals[i];c.copy(a.normal),d.a.copy(a.vertexNormals[0]),d.b.copy(a.vertexNormals[1]),d.c.copy(a.vertexNormals[2])}}for(let e=0,t=this.faces.length;e<t;e++){let o=this.faces[e];o.normal=o.__originalFaceNormal,o.vertexNormals=o.__originalVertexNormals}}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new oe.Box3),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new oe.Sphere),this.boundingSphere.setFromPoints(this.vertices)}merge(r,e,t=0){if(!(r&&r.isGeometry)){console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",r);return}let o,i=this.vertices.length,s=this.vertices,a=r.vertices,c=this.faces,d=r.faces,l=this.colors,u=r.colors;e!==void 0&&(o=new oe.Matrix3().getNormalMatrix(e));for(let p=0,f=a.length;p<f;p++){let h=a[p].clone();e!==void 0&&h.applyMatrix4(e),s.push(h)}for(let p=0,f=u.length;p<f;p++)l.push(u[p].clone());for(let p=0,f=d.length;p<f;p++){let m=d[p],h,y,g=m.vertexNormals,x=m.vertexColors,S=new Ii(m.a+i,m.b+i,m.c+i);S.normal.copy(m.normal),o!==void 0&&S.normal.applyMatrix3(o).normalize();for(let w=0,b=g.length;w<b;w++)h=g[w].clone(),o!==void 0&&h.applyMatrix3(o).normalize(),S.vertexNormals.push(h);S.color.copy(m.color);for(let w=0,b=x.length;w<b;w++)y=x[w],S.vertexColors.push(y.clone());S.materialIndex=m.materialIndex+t,c.push(S)}for(let p=0,f=r.faceVertexUvs.length;p<f;p++){let m=r.faceVertexUvs[p];this.faceVertexUvs[p]===void 0&&(this.faceVertexUvs[p]=[]);for(let h=0,y=m.length;h<y;h++){let g=m[h],x=[];for(let S=0,w=g.length;S<w;S++)x.push(g[S].clone());this.faceVertexUvs[p].push(x)}}}mergeMesh(r){if(!(r&&r.isMesh)){console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",r);return}r.matrixAutoUpdate&&r.updateMatrix(),this.merge(r.geometry,r.matrix)}mergeVertices(r=4){let e={},t=[],o=[],i=Math.pow(10,r);for(let c=0,d=this.vertices.length;c<d;c++){let l=this.vertices[c],u=Math.round(l.x*i)+"_"+Math.round(l.y*i)+"_"+Math.round(l.z*i);e[u]===void 0?(e[u]=c,t.push(this.vertices[c]),o[c]=t.length-1):o[c]=o[e[u]]}let s=[];for(let c=0,d=this.faces.length;c<d;c++){let l=this.faces[c];l.a=o[l.a],l.b=o[l.b],l.c=o[l.c];let u=[l.a,l.b,l.c];for(let p=0;p<3;p++)if(u[p]===u[(p+1)%3]){s.push(c);break}}for(let c=s.length-1;c>=0;c--){let d=s[c];this.faces.splice(d,1);for(let l=0,u=this.faceVertexUvs.length;l<u;l++)this.faceVertexUvs[l].splice(d,1)}let a=this.vertices.length-t.length;return this.vertices=t,a}setFromPoints(r){this.vertices=[];for(let e=0,t=r.length;e<t;e++){let o=r[e];this.vertices.push(new oe.Vector3(o.x,o.y,o.z||0))}return this}sortFacesByMaterialIndex(){let r=this.faces,e=r.length;for(let c=0;c<e;c++)r[c]._id=c;function t(c,d){return c.materialIndex-d.materialIndex}r.sort(t);let o=this.faceVertexUvs[0],i=this.faceVertexUvs[1],s,a;o&&o.length===e&&(s=[]),i&&i.length===e&&(a=[]);for(let c=0;c<e;c++){let d=r[c]._id;s&&s.push(o[d]),a&&a.push(i[d])}s&&(this.faceVertexUvs[0]=s),a&&(this.faceVertexUvs[1]=a)}toJSON(){let r={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.parameters!==void 0){let m=this.parameters;for(let h in m)m[h]!==void 0&&(r[h]=m[h]);return r}let e=[];for(let m=0;m<this.vertices.length;m++){let h=this.vertices[m];e.push(h.x,h.y,h.z)}let t=[],o=[],i={},s=[],a={},c=[],d={};for(let m=0;m<this.faces.length;m++){let h=this.faces[m],y=!0,g=!1,x=this.faceVertexUvs[0][m]!==void 0,S=h.normal.length()>0,w=h.vertexNormals.length>0,b=h.color.r!==1||h.color.g!==1||h.color.b!==1,_=h.vertexColors.length>0,P=0;if(P=l(P,0,0),P=l(P,1,y),P=l(P,2,g),P=l(P,3,x),P=l(P,4,S),P=l(P,5,w),P=l(P,6,b),P=l(P,7,_),t.push(P),t.push(h.a,h.b,h.c),t.push(h.materialIndex),x){let v=this.faceVertexUvs[0][m];t.push(f(v[0]),f(v[1]),f(v[2]))}if(S&&t.push(u(h.normal)),w){let v=h.vertexNormals;t.push(u(v[0]),u(v[1]),u(v[2]))}if(b&&t.push(p(h.color)),_){let v=h.vertexColors;t.push(p(v[0]),p(v[1]),p(v[2]))}}function l(m,h,y){return y?m|1<<h:m&~(1<<h)}function u(m){let h=m.x.toString()+m.y.toString()+m.z.toString();return i[h]!==void 0||(i[h]=o.length/3,o.push(m.x,m.y,m.z)),i[h]}function p(m){let h=m.r.toString()+m.g.toString()+m.b.toString();return a[h]!==void 0||(a[h]=s.length,s.push(m.getHex())),a[h]}function f(m){let h=m.x.toString()+m.y.toString();return d[h]!==void 0||(d[h]=c.length/2,c.push(m.x,m.y)),d[h]}return r.data={},r.data.vertices=e,r.data.normals=o,s.length>0&&(r.data.colors=s),c.length>0&&(r.data.uvs=[c]),r.data.faces=t,r}clone(){return new Wo().copy(this)}copy(r){this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=r.name;let e=r.vertices;for(let p=0,f=e.length;p<f;p++)this.vertices.push(e[p].clone());let t=r.colors;for(let p=0,f=t.length;p<f;p++)this.colors.push(t[p].clone());let o=r.faces;for(let p=0,f=o.length;p<f;p++)this.faces.push(o[p].clone());for(let p=0,f=r.faceVertexUvs.length;p<f;p++){let m=r.faceVertexUvs[p];this.faceVertexUvs[p]===void 0&&(this.faceVertexUvs[p]=[]);for(let h=0,y=m.length;h<y;h++){let g=m[h],x=[];for(let S=0,w=g.length;S<w;S++){let b=g[S];x.push(b.clone())}this.faceVertexUvs[p].push(x)}}let i=r.morphTargets;for(let p=0,f=i.length;p<f;p++){let m={};if(m.name=i[p].name,i[p].vertices!==void 0){m.vertices=[];for(let h=0,y=i[p].vertices.length;h<y;h++)m.vertices.push(i[p].vertices[h].clone())}if(i[p].normals!==void 0){m.normals=[];for(let h=0,y=i[p].normals.length;h<y;h++)m.normals.push(i[p].normals[h].clone())}this.morphTargets.push(m)}let s=r.morphNormals;for(let p=0,f=s.length;p<f;p++){let m={};if(s[p].vertexNormals!==void 0){m.vertexNormals=[];for(let h=0,y=s[p].vertexNormals.length;h<y;h++){let g=s[p].vertexNormals[h],x={};x.a=g.a.clone(),x.b=g.b.clone(),x.c=g.c.clone(),m.vertexNormals.push(x)}}if(s[p].faceNormals!==void 0){m.faceNormals=[];for(let h=0,y=s[p].faceNormals.length;h<y;h++)m.faceNormals.push(s[p].faceNormals[h].clone())}this.morphNormals.push(m)}let a=r.skinWeights;for(let p=0,f=a.length;p<f;p++)this.skinWeights.push(a[p].clone());let c=r.skinIndices;for(let p=0,f=c.length;p<f;p++)this.skinIndices.push(c[p].clone());let d=r.lineDistances;for(let p=0,f=d.length;p<f;p++)this.lineDistances.push(d[p]);let l=r.boundingBox;l!==null&&(this.boundingBox=l.clone());let u=r.boundingSphere;return u!==null&&(this.boundingSphere=u.clone()),this.elementsNeedUpdate=r.elementsNeedUpdate,this.verticesNeedUpdate=r.verticesNeedUpdate,this.uvsNeedUpdate=r.uvsNeedUpdate,this.normalsNeedUpdate=r.normalsNeedUpdate,this.colorsNeedUpdate=r.colorsNeedUpdate,this.lineDistancesNeedUpdate=r.lineDistancesNeedUpdate,this.groupsNeedUpdate=r.groupsNeedUpdate,this}toBufferGeometry(){let r=new Ku().fromGeometry(this),e=new oe.BufferGeometry,t=new Float32Array(r.vertices.length*3);if(e.setAttribute("position",Kl.call(new oe.BufferAttribute(t,3),r.vertices)),r.normals.length>0){let o=new Float32Array(r.normals.length*3);e.setAttribute("normal",Kl.call(new oe.BufferAttribute(o,3),r.normals))}if(r.colors.length>0){let o=new Float32Array(r.colors.length*3);e.setAttribute("color",_y.call(new oe.BufferAttribute(o,3),r.colors))}if(r.uvs.length>0){let o=new Float32Array(r.uvs.length*2);e.setAttribute("uv",Py.call(new oe.BufferAttribute(o,2),r.uvs))}if(r.uvs2.length>0){let o=new Float32Array(r.uvs2.length*2);e.setAttribute("uv2",Py.call(new oe.BufferAttribute(o,2),r.uvs2))}e.groups=r.groups;for(let o in r.morphTargets){let i=[],s=r.morphTargets[o];for(let a=0,c=s.length;a<c;a++){let d=s[a],l=new oe.Float32BufferAttribute(d.data.length*3,3);l.name=d.name,i.push(Kl.call(l,d.data))}e.morphAttributes[o]=i}if(r.skinIndices.length>0){let o=new oe.Float32BufferAttribute(r.skinIndices.length*4,4);e.setAttribute("skinIndex",Ty.call(o,r.skinIndices))}if(r.skinWeights.length>0){let o=new oe.Float32BufferAttribute(r.skinWeights.length*4,4);e.setAttribute("skinWeight",Ty.call(o,r.skinWeights))}return r.boundingSphere!==null&&(e.boundingSphere=r.boundingSphere.clone()),r.boundingBox!==null&&(e.boundingBox=r.boundingBox.clone()),e}computeTangents(){console.error("THREE.Geometry: .computeTangents() has been removed.")}computeLineDistances(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")}applyMatrix(r){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(r)}dispose(){this.dispatchEvent({type:"dispose"})}static createBufferGeometryFromObject(r){let e=new oe.BufferGeometry,t=r.geometry;if(r.isPoints||r.isLine){let o=new oe.Float32BufferAttribute(t.vertices.length*3,3),i=new oe.Float32BufferAttribute(t.colors.length*3,3);if(e.setAttribute("position",Kl.call(o,t.vertices)),e.setAttribute("color",_y.call(i,t.colors)),t.lineDistances&&t.lineDistances.length===t.vertices.length){let s=new oe.Float32BufferAttribute(t.lineDistances.length,1);e.setAttribute("lineDistance",kP.call(s,t.lineDistances))}t.boundingSphere!==null&&(e.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(e.boundingBox=t.boundingBox.clone())}else r.isMesh&&(e=t.toBufferGeometry());return e}};Wo.prototype.isGeometry=!0;var Ku=class{constructor(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}computeGroups(r){let e=[],t,o,i,s=r.faces;for(o=0;o<s.length;o++){let a=s[o];a.materialIndex!==i&&(i=a.materialIndex,t!==void 0&&(t.count=o*3-t.start,e.push(t)),t={start:o*3,materialIndex:i})}t!==void 0&&(t.count=o*3-t.start,e.push(t)),this.groups=e}fromGeometry(r){let e=r.faces,t=r.vertices,o=r.faceVertexUvs,i=o[0]&&o[0].length>0,s=o[1]&&o[1].length>0,a=r.morphTargets,c=a.length,d;if(c>0){d=[];for(let g=0;g<c;g++)d[g]={name:a[g].name,data:[]};this.morphTargets.position=d}let l=r.morphNormals,u=l.length,p;if(u>0){p=[];for(let g=0;g<u;g++)p[g]={name:l[g].name,data:[]};this.morphTargets.normal=p}let f=r.skinIndices,m=r.skinWeights,h=f.length===t.length,y=m.length===t.length;t.length>0&&e.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let g=0;g<e.length;g++){let x=e[g];this.vertices.push(t[x.a],t[x.b],t[x.c]);let S=x.vertexNormals;if(S.length===3)this.normals.push(S[0],S[1],S[2]);else{let b=x.normal;this.normals.push(b,b,b)}let w=x.vertexColors;if(w.length===3)this.colors.push(w[0],w[1],w[2]);else{let b=x.color;this.colors.push(b,b,b)}if(i===!0){let b=o[0][g];b!==void 0?this.uvs.push(b[0],b[1],b[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",g),this.uvs.push(new oe.Vector2,new oe.Vector2,new oe.Vector2))}if(s===!0){let b=o[1][g];b!==void 0?this.uvs2.push(b[0],b[1],b[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",g),this.uvs2.push(new oe.Vector2,new oe.Vector2,new oe.Vector2))}for(let b=0;b<c;b++){let _=a[b].vertices;d[b].data.push(_[x.a],_[x.b],_[x.c])}for(let b=0;b<u;b++){let _=l[b].vertexNormals[g];p[b].data.push(_.a,_.b,_.c)}h&&this.skinIndices.push(f[x.a],f[x.b],f[x.c]),y&&this.skinWeights.push(m[x.a],m[x.b],m[x.c])}return this.computeGroups(r),this.verticesNeedUpdate=r.verticesNeedUpdate,this.normalsNeedUpdate=r.normalsNeedUpdate,this.colorsNeedUpdate=r.colorsNeedUpdate,this.uvsNeedUpdate=r.uvsNeedUpdate,this.groupsNeedUpdate=r.groupsNeedUpdate,r.boundingSphere!==null&&(this.boundingSphere=r.boundingSphere.clone()),r.boundingBox!==null&&(this.boundingBox=r.boundingBox.clone()),this}},Ii=class{constructor(r,e,t,o,i,s=0){this.a=r,this.b=e,this.c=t,this.normal=o&&o.isVector3?o:new oe.Vector3,this.vertexNormals=Array.isArray(o)?o:[],this.color=i&&i.isColor?i:new oe.Color,this.vertexColors=Array.isArray(i)?i:[],this.materialIndex=s}clone(){return new this.constructor().copy(this)}copy(r){this.a=r.a,this.b=r.b,this.c=r.c,this.normal.copy(r.normal),this.color.copy(r.color),this.materialIndex=r.materialIndex;for(let e=0,t=r.vertexNormals.length;e<t;e++)this.vertexNormals[e]=r.vertexNormals[e].clone();for(let e=0,t=r.vertexColors.length;e<t;e++)this.vertexColors[e]=r.vertexColors[e].clone();return this}};function kP(n){return this.array.set(n),this}function _y(n){let r=this.array,e=0;for(let t=0,o=n.length;t<o;t++){let i=n[t];i===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",t),i=new oe.Color),r[e++]=i.r,r[e++]=i.g,r[e++]=i.b}return this}function Py(n){let r=this.array,e=0;for(let t=0,o=n.length;t<o;t++){let i=n[t];i===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",t),i=new oe.Vector2),r[e++]=i.x,r[e++]=i.y}return this}function Kl(n){let r=this.array,e=0;for(let t=0,o=n.length;t<o;t++){let i=n[t];i===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",t),i=new oe.Vector3),r[e++]=i.x,r[e++]=i.y,r[e++]=i.z}return this}function Ty(n){let r=this.array,e=0;for(let t=0,o=n.length;t<o;t++){let i=n[t];i===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",t),i=new oe.Vector4),r[e++]=i.x,r[e++]=i.y,r[e++]=i.z,r[e++]=i.w}return this}var UP=["a","b","c"];function HP(n,r){switch(r){case"c":return n.c;case"b":return n.b;case"a":default:return n.a}}function Zu(n,r,e){let t=Math.min(n,r),o=Math.max(n,r),i=t+"_"+o;return e.get(i)}function Qu(n,r,e,t,o,i){let s=Math.min(n,r),a=Math.max(n,r),c=s+"_"+a,d;if(t.has(c))d=t.get(c);else{let l=e[s],u=e[a];d={a:l,b:u,newEdge:null,faces:[]},t.set(c,d)}d.faces.push(o),i[n].edges.push(d),i[r].edges.push(d)}function WP(n,r,e,t){let o,i,s;for(o=0,i=n.length;o<i;o++)e[o]={edges:[]};for(o=0,i=r.length;o<i;o++)s=r[o],Qu(s.a,s.b,n,t,s,e),Qu(s.b,s.c,n,t,s,e),Qu(s.c,s.a,n,t,s,e)}function Zl(n,r,e,t,o){n.push(new Ii(r,e,t,void 0,void 0,o))}function Mi(n,r){return Math.abs(r-n)/2+Math.min(n,r)}function Ql(n,r,e,t){n.push([r.clone(),e.clone(),t.clone()])}var Jl=class{constructor(r=1){this.subdivisions=r}modify(r){r instanceof xo.BufferGeometry?r=new Wo().fromBufferGeometry(r):r=r.clone(),r.mergeVertices();let e=this.subdivisions;for(;e-- >0;)this._smooth(r);return r.computeFaceNormals(),r.computeVertexNormals(),r}_smooth(r){let e=new xo.Vector3,t,o,i,s,a,c=r.vertices,d=r.faces,l=r.faceVertexUvs[0],u=l!==void 0&&l.length>0,p=[],f=new Map;WP(c,d,p,f);let m=[],h,y,g,x,S,w,b;for(let F of Array.from(f.keys())){for(y=f.get(F),g=new xo.Vector3,S=3/8,w=1/8,b=y.faces.length,b!=2&&(S=.5,w=0,b!=1),g.addVectors(y.a,y.b).multiplyScalar(S),e.set(0,0,0),s=0;s<b;s++){for(x=y.faces[s],a=0;a<3&&(h=c[HP(x,UP[a])],!(h!==y.a&&h!==y.b));a++);h&&e.add(h)}e.multiplyScalar(w),g.add(e),y.newEdge=m.length,m.push(g)}let _,P,v,N,T,C,O,A=[];for(o=0,i=c.length;o<i;o++){for(C=c[o],T=p[o].edges,t=T.length,t==3?_=3/16:t>3&&(_=3/(8*t)),P=1-t*Number(_),v=_,t<=2&&(t==2?(P=3/4,v=1/8):t==1||t==0),O=C.clone().multiplyScalar(P),e.set(0,0,0),s=0;s<t;s++)N=T[s],h=N.a!==C?N.a:N.b,e.add(h);e.multiplyScalar(Number(v)),O.add(e),A.push(O)}let M=A.concat(m),L=A.length,X,R,Z,z=[],V=[],W,$,Y,q,k=new xo.Vector2,U=new xo.Vector2,B=new xo.Vector2;for(o=0,i=d.length;o<i;o++)x=d[o],X=Number(Zu(x.a,x.b,f).newEdge)+L,R=Number(Zu(x.b,x.c,f).newEdge)+L,Z=Number(Zu(x.c,x.a,f).newEdge)+L,Zl(z,X,R,Z,x.materialIndex),Zl(z,x.a,X,Z,x.materialIndex),Zl(z,x.b,R,X,x.materialIndex),Zl(z,x.c,Z,R,x.materialIndex),u&&(W=l[o],$=W[0],Y=W[1],q=W[2],k.set(Mi($.x,Y.x),Mi($.y,Y.y)),U.set(Mi(Y.x,q.x),Mi(Y.y,q.y)),B.set(Mi($.x,q.x),Mi($.y,q.y)),Ql(V,k,U,B),Ql(V,$,k,B),Ql(V,Y,U,k),Ql(V,q,B,U));r.vertices=M,r.faces=z,u&&(r.faceVertexUvs[0]=V)}};var mt=new $r.Vector3,Oy=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=n.geometry??r?.geometry??new $r.BufferGeometry().copy(new $r.BoxGeometry(100,100,100)),t;r===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(mt),t={width:mt.x,height:mt.y,depth:mt.z,subdivisions:0}):t=r.parameters;let o={...t,...n.parameters};return{parameters:{width:Math.abs(o.width),height:Math.abs(o.height),depth:Math.abs(o.depth),subdivisions:Math.abs(o.subdivisions)},geometry:e}}static build(n){let{width:r,height:e,depth:t,subdivisions:o}=n.parameters,i=n.geometry??new $r.BufferGeometry().copy(new $r.BoxGeometry(100,100,100)),s=i.userData.parameters;s===void 0?(i.computeBoundingBox(),i.boundingBox.getSize(mt)):mt.set(s.width,s.height,s.depth),(r!==mt.x||e!==mt.y||t!==mt.z)&&i.scale(mt.x===0?1:r/mt.x,mt.y===0?1:e/mt.y,mt.z===0?1:t/mt.z);let a=i.originalGeometry;try{o>0?(a===void 0||s?.subdivisions!==o)&&(a===void 0&&(a=i),i=new Jl(o).modify(a).toBufferGeometry()):(a!==void 0&&(i=a),a=void 0,i.getAttribute("normal")===void 0&&i.computeVertexNormals())}catch{a!==void 0&&(i=a),a=void 0,i.getAttribute("normal")===void 0&&i.computeVertexNormals()}return a!==void 0&&Object.assign(i,{originalGeometry:a}),delete n.geometry,Object.assign(i,{userData:{...n,type:"NonParametricGeometry"}})}static loadFromUrl(n,r,e){new $r.BufferGeometryLoader(e).load(n,o=>{let i=this.normalizeInputs({geometry:o});o.boundingBox.getSize(mt);let s=100/mt.x;Object.assign(i.parameters,{width:100,height:mt.y*s,depth:mt.z*s}),r(this.build(i))})}};var ec=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},n.parameters);return{shape:n.shape&&n.shape instanceof Me?n.shape:new Me,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(n){let{width:r,height:e,spikes:t,cornerRadius:o,depth:i,extrudeBevelSize:s,extrudeBevelSegments:a}=n.parameters,c=n.shape,d=r*.5,l=e*.5,u=0,p=0,f=2*Math.PI/t;for(let h=0;h<t;h++){let y=f*h,g=u+Math.sin(y)*d,x=p+Math.cos(y)*l;c.addPoint(c.createPoint(g,x))}c.isClosed=!0;for(let h=0,y=c.points.length;h<y;h++)c.points[h].roundness=o;c.roundness=o,c.update();let m=Kt.create({shape:c,parameters:{roundness:o,depth:i,extrudeBevelSize:s,extrudeBevelSegments:a}});return Object.assign(m,{userData:{...n,type:"PolygonGeometry"}})}};var Te=require("three"),Ay=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:r,height:e,depth:t,radialSegments:o,heightSegments:i,openEnded:s,cornerRadius:a,cornerSegments:c}=n.parameters,d=new ed(r*.5,e,o,i,s,a,c);return d.scale(1,1,t/r),Object.assign(d,{userData:{...n,type:"PyramidGeometry"}})}};function Js(n,r,e){e.x=n.x*r.x,e.y=n.y,e.z=n.x*r.y}function Ju(n,r,e,t,o,i){let s=r.clone().sub(n),a=e.clone().sub(n),c=s.angleTo(a);if(s.normalize(),a.normalize(),t===o){let d=s.add(a).normalize();i.copy(n).addScaledVector(d,t/Math.sin(c/2))}else{let d=s.angleTo(a);i.copy(n),i.addScaledVector(s,o/Math.sin(d)),i.addScaledVector(a,t/Math.sin(d))}}function qP(n,r,e){let t=n.clone().sub(r),o=e.clone().sub(r);return t.projectOnVector(o),t.add(r)}var ed=class extends Te.BufferGeometry{constructor(r=.5,e=1,t=4,o=1,i=!1,s=0,a=4){super(),t=Math.floor(Math.max(3,t)),o=Math.floor(o),a=Math.floor(a);let c=[],d=[],l=[],u=[],p=0,f=e/2,m=Math.PI/t,h=r*Math.cos(Math.PI/t),y=2*Math.PI/t,g=(t-2)*Math.PI/t,x=Math.PI-g,S=new Te.Vector3(0,-f,0),w=new Te.Vector3(0,f,0),b=new Te.Vector2(r,-f),_=new Te.Vector2(h,-f),P=new Te.Vector2(0,w.y).sub(_),v=new Te.Vector2(0,w.y).sub(b),N=new Te.Vector2(P.y,-P.x).normalize(),T=new Te.Vector2(v.y,-v.x).normalize(),O=r*Math.cos(Math.PI/t)*Math.tan((Math.PI-P.angle())/2)-1e-8;s=Math.min(s,O);let A;{let V=new Te.Vector3(N.x,N.y,0),W=new Te.Vector3(Math.cos(y)*V.x,V.y,Math.sin(y)*V.x);A=V.angleTo(W)}let M=s/Math.tan((Math.PI-P.angle())/2),L=s/Math.tan((Math.PI-A)/2),X=new Te.Vector3;if(!i){d.push(S.x,S.y,S.z),l.push(0,-1,0),u.push(0,0);let V=p++,W=[],$=b.clone(),Y=M/Math.cos(Math.PI/t);$.x-=Y;for(let q=0;q<t;q++){let k=q/t*Math.PI*2+m,U=new Te.Vector2(Math.sin(k),Math.cos(k));Js($,U,X),d.push(X.x,X.y,X.z),l.push(0,-1,0),u.push(0,0),W.push(p++)}for(let q=0;q<W.length;q++)c.push(W[q],V,W[(q+1)%W.length])}let R=[];{let V=new Te.Vector3,W=new Te.Vector3,$=new Te.Vector3,Y=new Te.Vector3,q=new Te.Vector3,k=new Te.Vector3;for(let U=0;U<t;U++){let B=U/t*Math.PI*2+m,F=(U+.5)/t*Math.PI*2+m,j=(U+1)/t*Math.PI*2+m,D=new Te.Vector2(Math.sin(B),Math.cos(B)),ne=new Te.Vector2(Math.sin(F),Math.cos(F)),ee=new Te.Vector2(Math.sin(j),Math.cos(j));Js(b,D,W),Js(b,ee,$),Js(N,ne,V),Ju(w,W,$,L,L,Y),d.push(Y.x,Y.y,Y.z),Ju(W,w,$,L,M,q),d.push(q.x,q.y,q.z),Ju($,W,w,M,L,k),d.push(k.x,k.y,k.z),l.push(V.x,V.y,V.z),l.push(V.x,V.y,V.z),l.push(V.x,V.y,V.z),u.push(0,0),u.push(0,0),u.push(0,0);let K=p++,te=p++,Q=p++;if(c.push(K,te,Q),s>0){{let se=W.clone().add($).multiplyScalar(.5),ue=w.clone().sub(se).normalize(),de=S.clone().sub(se).normalize().add(ue).normalize().multiplyScalar(-1),he=k.clone().sub(q);Z(se,he,de,P.angle())}let le,ie;{let se=new Te.Vector3;Js(T,ee,se);let ue=k.clone().add(Y).multiplyScalar(.5);ue=qP(ue,$,w);let ce=k.clone().sub(Y);[le,ie]=Z(ue,ce,se,A,Y.y)}{let se=le,ue=se.clone().setY(0).normalize(),ce=new Te.Vector3(0,-1,0),de=ue.clone().cross(ce);z(se,ue,ce,de)}R.concat(ie);{let se=P.angle(),ue=Math.PI-se,ce=w.clone();ce.y-=s/Math.sin(se-Math.PI/2);let de=new Te.Vector3,he=[];for(let $e=0;$e<a;$e++){let Ce=[],Fe=Math.PI/2-ue*$e/a,Wt=Math.cos(Fe),we=Math.sin(Fe),pt=F;for(let xt=0;xt<=$e;xt++){let Mn=Math.cos(pt),st=Math.sin(pt);V.x=Wt*st,V.y=we,V.z=Wt*Mn,de.copy(ce).addScaledVector(V,s),d.push(de.x,de.y,de.z),l.push(V.x,V.y,V.z),u.push(0,0),Ce.push(p++),pt+=Math.PI*2/$e/t}he.push(Ce)}ie.reverse(),he.push(ie);let Ae=he.length-1;for(let $e=0;$e<Ae;$e++){let Ce=he[$e],Fe=he[$e+1],Wt=Ce.length-1;c.push(Fe[1],Ce[0],Fe[0]);for(let we=1;we<=Wt;we++)c.push(Ce[we],Ce[we-1],Fe[we]),c.push(Fe[we+1],Ce[we],Fe[we])}}}}}this.setIndex(c),this.setAttribute("position",new Te.Float32BufferAttribute(d,3)),this.setAttribute("normal",new Te.Float32BufferAttribute(l,3)),this.setAttribute("uv",new Te.Float32BufferAttribute(u,2));function Z(V,W,$,Y,q){let k=-Y/2,U=(Math.PI-Y)/2,B=W.clone().normalize().cross($);V.addScaledVector($,-s/Math.sin(U));let F=new Te.Vector3,j=new Te.Vector3,D=1,ne=p,ee=[];for(let K=0;K<=a;K++){let te=k+K/a*Y;j.set(0,0,0),j.addScaledVector(B,Math.sin(te)),j.addScaledVector($,Math.cos(te));for(let Q=0;Q<=D;Q++){let le=Q/D-.5;if(F.copy(V),F.addScaledVector(W,le),F.addScaledVector(j,s),q!=null){let ie=Math.max(0,F.y-q);F.addScaledVector(W,-ie/W.y)}d.push(F.x,F.y,F.z),l.push(j.x,j.y,j.z),u.push(0,0),Q===0&&ee.push(p),p++}}for(let K=0;K<a;K++)for(let te=0;te<D;te++){let Q=ne+te+(D+1)*K,le=Q+(D+1),ie=le+1,se=Q+1;c.push(Q,le,se),c.push(le,ie,se)}return[V.clone().addScaledVector(W,.5),ee]}function z(V,W,$,Y){let q=Math.PI/2,k=v.angle()-q,U=[],B=new Te.Vector3,F=new Te.Vector3;for(let D=0;D<=a;D++){let ne=[],ee=D/a;for(let K=0;K<=D;K++){let Q=((D?K/D:0)-.5)*x,le=Math.cos(Q),ie=Math.sin(Q),se=Math.atan(Math.tan(k)*le),ue=(q+se)*ee,ce=Math.cos(ue),de=Math.sin(ue);B.set(0,0,0),B.addScaledVector(W,de*le),B.addScaledVector($,ce),B.addScaledVector(Y,de*ie),F.copy(V).addScaledVector(B,s),d.push(F.x,F.y,F.z),l.push(B.x,B.y,B.z),u.push(0,0),ne.push(p++)}U.push(ne)}let j=U.length-1;for(let D=0;D<j;D++){let ne=U[D],ee=U[D+1],K=ne.length-1;c.push(ne[0],ee[1],ee[0]);for(let te=1;te<=K;te++)c.push(ne[te-1],ne[te],ee[te]),c.push(ne[te],ee[te+1],ee[te])}}}};var tc=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters),t=Object.assign(r?.ui??{enabledIndieCorners:!1},n.ui);return{shape:n.shape&&n.shape instanceof Me?n.shape:new Me,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)}),ui:t}}static build(n){let r=n.shape,{width:e,height:t,cornerRadius:o,cornerType:i,depth:s,extrudeBevelSize:a,extrudeBevelSegments:c}=n.parameters,d={x:e*.5,y:t*.5},l={x:-d.x,y:-d.y},u={x:d.x,y:d.y};function p(w,b,_){return b>e&&_>t?Math.min(w*e/b,w*t/_):b>e?w*e/b:_>t?w*t/_:w}let f=[];f[0]=o[0]===0?0:p(o[0],o[0]+o[3],o[0]+o[1]),f[1]=o[1]===0?0:p(o[1],o[1]+o[2],o[1]+o[0]),f[2]=o[2]===0?0:p(o[2],o[2]+o[1],o[2]+o[3]),f[3]=o[3]===0?0:p(o[3],o[3]+o[0],o[3]+o[2]);let m=l.x,h=u.x,y=u.y,g=l.y;r.addPoint(r.createPoint(m,y)),r.addPoint(r.createPoint(h,y)),r.addPoint(r.createPoint(h,g)),r.addPoint(r.createPoint(m,g)),r.isClosed=!0;let x=!0;for(let w=0,b=r.points.length;w<b;w++)r.points[w].roundness=f[w],w>0&&f[w]!==f[w-1]&&(x=!1);x&&(r.roundness=f[0]),r.useCubicForRoundedCorners=i!==1,r.update();let S=Kt.create({shape:r,parameters:{depth:s,extrudeBevelSize:a,extrudeBevelSegments:c}});return Object.assign(S,{userData:{...n,type:"RectangleGeometry"}})}};var Cy=require("three"),Ny=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:r=100,height:e=r,depth:t=r,widthSegments:o=64,heightSegments:i=64,phiStart:s,phiLength:a,thetaStart:c,thetaLength:d}=n.parameters,l=new Cy.SphereGeometry(.5*r,o,i,s,a,c,d);return l.scale(1,e/r,t/r),Object.assign(l,{userData:{...n,type:"SphereGeometry"}})}};var Iy=require("three"),My=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:0})}}static build(n){let{width:r=100,height:e=r,widthSegments:t=8,heightSegments:o=8}=n.parameters,i=new Iy.PlaneGeometry(r,e,t,o);return i.scale(1,1,1),Object.assign(i,{userData:{...n,type:"PlaneGeometry"}})}};var qo=require("three"),Ey=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:r,height:e,depth:t,angle:o,cornerRadius:i,cornerSegments:s}=n.parameters,a=new td(r,e,t,o,i,s);return Object.assign(a,{userData:{...n,type:"BackdropGeometry"}})}},td=class extends qo.BufferGeometry{constructor(r=1,e=1,t=1,o=90,i=10,s=24){super(),this.type="BackdropGeometry";let a=[],c=[],d=[],l=.001;i==0&&(s=1),s=Math.max(1,Math.floor(s)),i=Math.min(i,100),o=Math.min(180-l,o),o*=Math.PI/180;let u=[],p=Math.PI/2,f=(F=0,j=0,D=0)=>new qo.Vector3(F,j,D),m=f(),h=f(),[y,g,x]=[e/2,r/2,t/2],S=-g,w=+g,[b,_,P]=[f(S,-y,+x),f(S,-y,-x),f(S,+y,-x)],v=(F,j=!1)=>Math.sin(F-Math.PI/(1+ +j)),N=(F,j=!1)=>Math.cos(F-Math.PI/(1+ +j));P.y=Math.sin(o)*e-y;let T=Math.cos(o)*e-x,C=b.z-l;o<=p?(P.z=Math.min(T,C),P.z==C&&(P.y-=(T-C)/Math.tan(p-o))):_.z=Math.min(_.z-T-x,b.z-l),m.subVectors(b,_),h.subVectors(P,_);let O=Math.min(m.length(),h.length())*i/100,A=O*Math.tan(o/2),M=O/Math.cos(o/2),L=m.clone().normalize().add(h.normalize()).setLength(M).add(_);m.set(0,v(o,!0),N(o,!0)),u.push([P,m.clone()]);let X=(Math.PI-o)/s;for(let F=0;F<=s;F++){let j=p+o+F*X;m.set(0,Math.sin(j)*A,Math.cos(j)*A),m.add(L),h.set(0,v(j),N(j)),u.push([m.clone(),h.clone()])}u.push([b,f(0,1,0)]);let R=Math.sin(X/2)*A*2,Z=u.length-1,z=u[0][0].distanceTo(u[1][0]),V=u[Z-1][0].distanceTo(u[Z][0]),W=z+R*s+V;u[0].push(1);for(let F=0;F<=s;F++)u[F+1].push(1-(z+F*R)/W);u[Z].push(0);let[$,Y,q]=u[0],k,U,B;for(let F=1;F<u.length;F++)[k,U,B]=u[F],a.push(S,$.y,$.z,S,k.y,k.z,w,$.y,$.z,w,$.y,$.z,S,k.y,k.z,w,k.y,k.z),c.push(0,Y.y,Y.z,0,U.y,U.z,0,Y.y,Y.z,0,Y.y,Y.z,0,U.y,U.z,0,U.y,U.z),d.push(0,q,0,B,1,q,1,q,0,B,1,B),[$,Y,q]=[k,U,B];this.setAttribute("position",new qo.Float32BufferAttribute(a,3)),this.setAttribute("normal",new qo.Float32BufferAttribute(c,3)),this.setAttribute("uv",new qo.Float32BufferAttribute(d,2))}};var rc=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters);return{shape:n.shape&&n.shape instanceof Me?n.shape:new Me,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(n){let{width:r,height:e,innerRadiusPercent:t,spikes:o,cornerRadius:i,angle:s,depth:a,extrudeBevelSize:c,extrudeBevelSegments:d}=n.parameters,l=n.shape,u=r*.5,p=e*.5,f=0,m=0,h=s*Math.PI/360/o,y=Math.PI/2*3*-1,g=u*t/100,x=p*t/100;if(o===3&&t===50){h=2*Math.PI/o;for(let w=0;w<o;w++){let b=h*w,_=f+Math.sin(b)*u,P=m+Math.cos(b)*p;l.addPoint(l.createPoint(_,P))}}else for(let w=0;w<o;w++){let b=f+Math.cos(y)*u,_=m+Math.sin(y)*p;l.addPoint(l.createPoint(b,_)),y+=h,b=f+Math.cos(y)*g,_=m+Math.sin(y)*x,w<=o,l.addPoint(l.createPoint(b,_)),y+=h}l.isClosed=!0;for(let w=0,b=l.points.length;w<b;w++)l.points[w].roundness=i;l.roundness=i,l.update();let S=Kt.create({shape:l,parameters:{roundness:i,depth:a,extrudeBevelSize:c,extrudeBevelSegments:d}});return Object.assign(S,{userData:{...n,type:"StarGeometry"}})}};var Ly=require("three"),Dy=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,depth:0},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(n){let{width:r,height:e}=n.parameters,t=new Ly.PlaneGeometry(r,e);return Object.assign(t,{userData:{...n,type:"TextFrameGeometry"}})}};var By=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:Math.PI*2,cornerRadius:30,cornerSegments:8},n.parameters),t=Math.abs(e.width),o=Math.abs(e.height??e.width),i=Math.round(Math.abs(e.depth??e.width*.25));return{parameters:Object.assign(e,{width:t,height:o,depth:i})}}static build(n){let{width:r,height:e,depth:t,radialSegments:o,tubularSegments:i,arc:s,cornerRadius:a,cornerSegments:c}=n.parameters,d=$P(r,e,t,r*.5,s,i,0,0,o,a,c);return d.scale(1,e/r,1),Object.assign(d,{userData:{...n,type:"TorusGeometry"}})}};function $P(n,r,e,t,o,i,s,a,c,d,l){return[r,e]=[e,r],s=r/2,o/=2*Math.PI,o==1&&(d=0),new Zs(!0,n,r,e,t,o,i,s,a,c,d,l)}var Ry=require("three"),Gy=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),tube:e.tube??e.width*.125})}}static build(n){let{width:r,tube:e,tubularSegments:t,radialSegments:o,p:i,q:s}=n.parameters,a=r*.5;a!==e&&(a-=e);let c=new Ry.TorusKnotGeometry(a,e,t,o,i,s);return Object.assign(c,{userData:{...n,type:"TorusKnotGeometry"}})}};var Vy=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},n.parameters);return{shape:n.shape&&n.shape instanceof Me?n.shape:new Me,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width*(e.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(e.depth??0)})}}static build(n){let{width:r=100,height:e,cornerRadius:t,depth:o,extrudeBevelSize:i,extrudeBevelSegments:s,isRect:a}=n.parameters,c=n.shape,d=r*.5,l=e*.5;a?(c.addPoint(c.createPoint(-d,l)),c.addPoint(c.createPoint(d,-l)),c.addPoint(c.createPoint(-d,-l))):(c.addPoint(c.createPoint(0,l)),c.addPoint(c.createPoint(d,-l)),c.addPoint(c.createPoint(-d,-l))),c.isClosed=!0;for(let p=0,f=c.points.length;p<f;p++)c.points[p].roundness=t;c.roundness=t,c.update();let u=Kt.create({shape:c,parameters:{roundness:t,depth:o,extrudeBevelSize:i,extrudeBevelSegments:s}});return Object.assign(u,{userData:{...n,type:"TriangleGeometry"}})}};var xe=require("three");function zy(n,r){let e=2*Math.PI;return(n%e+e)%e===(r%e+e)%e}var YP=new xe.Matrix4,XP=new xe.Matrix4;function KP(n,r,e){let t=[new xe.Vector3,new xe.Vector3,new xe.Vector3],o=[new xe.Vector3,new xe.Vector3,new xe.Vector3];return n.extractBasis(t[0],t[1],t[2]),r.extractBasis(o[0],o[1],o[2]),t.forEach((i,s)=>{let a=o[s],c=xe.MathUtils.lerp(i.length(),a.length(),e);i.lerp(a,e).setLength(c)}),new xe.Matrix4().makeBasis(t[0],t[1],t[2])}var jy=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},n.parameters),t=Math.abs(e.width),o=Math.abs(e.height??e.width),i=Math.abs(e.depth??0),s=r?.shapeData??Ni.create({parameters:yu}).userData.shape;return{path:n.path??di.defaultData(),parameters:Object.assign(e,{width:t,height:o,depth:i,extrusion:{...Cl,...e.extrusion}}),shapeData:s}}static build(n){if(n.path.points.length>=2){let e=new rd(n);return Object.assign(e,{userData:{...n,type:"PathGeometry"}})}else return Object.assign(new xe.BufferGeometry,{userData:{...n,type:"PathGeometry"}})}},rd=class extends xe.BufferGeometry{constructor(e){super();this.type="PathExtrusionGeometry",this.inputs=e,this.build()}_isGeometryClosed(){return this.inputs.path.isClosed&&this.inputs.parameters.extrusion.depth===1}_isOpenEnded(){let e=this.inputs.parameters.extrusion;return!(this.inputs.path.isClosed&&e.depth===1)||!zy(e.twist,0)||e.startScale!==e.endScale}build(){let e=this._extractPathPoints();if(e.length<2)return;let t=this._computeBasisMatrices(e),{depth:o,offset:i}=this.inputs.parameters.extrusion,s=this.inputs.path.isClosed?e.length:e.length-1,a=Math.floor(i*s),c=this.inputs.path.isClosed?Math.ceil((o+i)*s):Math.ceil(Math.min(1,o+i)*s),d=Math.min(Math.max(2,c-a+1),s+2),l=[],u=[];for(let z=0;z<d;z++){let V=this.inputs.path.isClosed?(z+a)%e.length:Math.min(z+a,e.length-1);l.push(e[V].clone()),u.push(t[V].clone())}let p=(z,V,W)=>{l[z]=l[z].clone().lerp(l[V],W),u[z]=KP(u[z],u[V],W)},f=0,m=i*s%1;(!this.inputs.path.isClosed||o<=1)&&(m||i===0)&&(f=m,p(0,1,f));let h=0,y=(i+o)*s%1;if((this.inputs.path.isClosed&&o<=1||!this.inputs.path.isClosed&&i+o<1)&&y&&(h=y,p(l.length-1,l.length-2,1-h)),o===0){let z=l.length-1;l[z].copy(l[0]),u[z].copy(u[0])}this._applyPathModifiers(u,f,h);let{bevel:g,bevelSides:x}=this.inputs.parameters.extrusion,S=g>0?this.inputs.parameters.extrusion.capType:"flat",w=5;this.inputs.parameters.extrusion.shape.type==="Custom"&&(w=this.inputs.parameters.extrusion.shape.shapeQuality==="low"?5:12);let{regions:b,infos:_,vertices:P}=this._computeShapePoints(w),v=0,N;S==="round"&&(N=new Ho(this.inputs.shapeData,2*g,g,w,x,void 0,!0),v=N.getAttribute("position").count);let T=0,C=0;_.sort((z,V)=>z.start-V.start),_.forEach(z=>{z.verticesStart=T,z.verticesCount=z.continuous.reduce((V,W,$)=>V+($===0||!W?2:1),0),C+=z.verticesCount,T=C});let O=C*d,A,M=0;if(this._isOpenEnded()&&S==="flat"){try{A=Or({windingRule:Oe.ODD,elementType:Je.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:b})}catch{A=$u}M=A.vertexCount}let L=O+2*M+v*2,X=O+2*M,R={positions:new Float32Array(L*3),normals:new Float32Array(L*3),uvs:new Float32Array(L*2)},Z=[];if(_.forEach(z=>{this._extrudeRegion(z,P,u,l,R,Z,this._isGeometryClosed()&&!this._isOpenEnded())}),A&&(this._closeEnd(A,O,Z,R,u[0],l[0],!1),this._closeEnd(A,O+M,Z,R,u[u.length-1],l[l.length-1],!0)),N){R.positions.set(N.getAttribute("position").array,X*3),R.normals.set(N.getAttribute("normal").array,X*3),R.uvs.set(N.getAttribute("uv").array,X*2);let z=Z.length;Z.push(...N.getIndex().array.map($=>$+X)),X+=v,R.positions.set(N.getAttribute("position").array,X*3),R.normals.set(N.getAttribute("normal").array,X*3),R.uvs.set(N.getAttribute("uv").array,X*2);let V=Z.length;Z.push(...N.getIndex().array.map($=>$+X)),this.setAttribute("position",new xe.BufferAttribute(R.positions,3)),this.setAttribute("normal",new xe.BufferAttribute(R.normals,3)),this.setAttribute("uv",new xe.BufferAttribute(R.uvs,2)),this.setIndex(Z);let W=YP;W.copy(u[u.length-1]).setPosition(l[l.length-1]),this.applyMatrix4OnRange(W,X,L),W.copy(u[0]).setPosition(l[0]).multiply(XP.makeScale(1,1,-1)),this.applyMatrix4OnRange(W,X-v,X),this.reverseIndicesOnRange(z,V)}else this.setAttribute("position",new xe.BufferAttribute(R.positions,3)),this.setAttribute("normal",new xe.BufferAttribute(R.normals,3)),this.setAttribute("uv",new xe.BufferAttribute(R.uvs,2)),this.setIndex(Z)}_extractPathPoints(){let t=kl(this.inputs.path).getPoints(this.inputs.path.subdivisions);if(t.length<2)return[];let o=[t[0]];return t.forEach(s=>{o[o.length-1].distanceToSquared(s)>.001&&o.push(s)}),this.inputs.path.isClosed&&o[o.length-1].distanceTo(o[0])<.001&&o.pop(),o}_computeBasisMatrices(e){let t=[],o=e.length,i=this.inputs.path.isClosed,s=new xe.Vector3,a=new xe.Vector3,c=new xe.Vector3,d=new xe.Vector3,l=new xe.Vector3(0,1,0);for(let y=0;y<o;y++){let g=e[y],x;y===0?x=i?e[e.length-2]:g.clone().multiplyScalar(2).sub(e[1]):x=e[y-1];let S;y===o-1?S=i?e[1]:g.clone().multiplyScalar(2).sub(e[y-1]):S=e[y+1];let w=g.clone().sub(x).normalize(),b=S.clone().sub(g).normalize(),_=w.clone().add(b).normalize();c.copy(_),y===0&&(_.equals(l)||_.clone().negate().equals(l))&&l.set(0,0,1);let P=l.clone().cross(_).normalize(),v=_.clone().cross(P).normalize();l.copy(v),d.copy(P),y===0&&(s.copy(v),a.copy(_));let N=new xe.Matrix4().makeBasis(P,v,_);t.push(N)}let u=i?a:c,p=i?s:new xe.Vector3(0,1,0),f=u.clone().cross(d).normalize(),m=Math.acos(p.dot(f));if(isNaN(m))return t;let h=p.clone().cross(f);u.dot(h)>0&&(m*=-1);for(let y=1;y<t.length;y++){let g=new xe.Matrix4().makeRotationZ(m*y/t.length);t[y].multiply(g)}return t}_applyPathModifiers(e,t,o){let i=e.length,{angle:s,twist:a,startScale:c,endScale:d}=this.inputs.parameters.extrusion,l=new xe.Matrix4,u=new xe.Matrix4;return e.forEach((p,f)=>{let m=f===0?0:f===i-1?1:(f-t)/(i-(o===0?0:1)-(t+(1-o)));l.makeRotationZ(xe.MathUtils.lerp(s,s+a,m));let h=xe.MathUtils.lerp(c,d,m);u.makeScale(h,h,h),p.multiply(l).multiply(u)}),e}_computeShapePoints(e=12,t=Oe.ODD){let o=this.inputs.shapeData,i=o.extractShapePointsToFlatArray([],e),s=o.shapeHoles.map(h=>{let y=h.extractShapePointsToFlatArray([],e),g=[];for(let x=y.length-1;x>=1;x-=2){let S=y[x-1],w=y[x-0];g.push(S,w)}return g}),a;try{a=Or({windingRule:t,elementType:Je.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[i]})}catch{a=Ks}let c;try{c=Or({windingRule:Oe.ODD,elementType:Je.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...s]})}catch{c=qu}if(!a)throw new Error("error generating geometry");let d=a.elementCount;if(c){a.elementCount+=c.elementCount;for(let h=0;h<c.elements.length;h++){let y=c.elements[h],g=h%2===0?a.vertexCount:0;a.elements.push(y+g)}for(let h=0;h<c.vertexIndices.length;h++){let y=c.vertexIndices[h],g=a.vertexCount;a.vertexIndices.push(y+g)}for(let h=0;h<c.vertices.length;h++){let y=c.vertices[h];a.vertices.push(y)}}let l=1/0,u=-1/0,p=1/0,f=-1/0;for(let h=0,y=a.vertexCount;h<y;h++){let g=h*2,x=a.vertices[g+0],S=a.vertices[g+1];x<l&&(l=x),x>u&&(u=x),S<p&&(p=S),S>f&&(f=S)}let m=[];for(let h=a.elementCount-1;h>=0;h--){let y=h>=d,g=h*2,x=a.elements[g+0],S=a.elements[g+1],w=x+S,b={start:x,count:S,normals:[],isHole:y,continuous:[],verticesStart:0,verticesCount:0};m.push(b);let _=x,P=w-1,v=x+1,N=o.roundedCurves.length;do{let T=_-x,C=a.vertices[P*2+0],O=a.vertices[P*2+1],A=a.vertices[_*2+0],M=a.vertices[_*2+1],L=a.vertices[v*2+0],X=a.vertices[v*2+1],R=A-C,Z=M-O,z=Math.sqrt(R*R+Z*Z);R/=z,Z/=z;let V=A-L,W=M-X,$=Math.sqrt(V*V+W*W);V/=$,W/=$,b.normals[T*2+0]=-W,b.normals[T*2+1]=V;let Y=a.vertexIndices[_];if(Array.isArray(Y))b.continuous[T]=!1;else{let[q,k]=o.getCurveIndexFromVertexId(Y-1,!0);if(k>0&&k<1)b.continuous[T]=!0;else{let U=k===1?q+1:q-1;U=(U+N)%N;let B=k===1?0:1,F=o.roundedCurves[q].getTangent(k),j=o.roundedCurves[U].getTangent(B);b.continuous[T]=F.dot(j)>.95}}y&&(b.normals[T*2+0]*=-1,b.normals[T*2+1]*=-1),[P,_,v]=[_,v,v+1],v>=w&&(v-=S)}while(v!==x+1)}return{regions:[i,...s],infos:m,vertices:a.vertices}}_insertVertex(e,t,o,i,s){let a=t*2,c=t*3;e.positions[c+0]=o.x,e.positions[c+1]=o.y,e.positions[c+2]=o.z,e.normals[c+0]=i.x,e.normals[c+1]=i.y,e.normals[c+2]=i.z,e.uvs[a+0]=s.x,e.uvs[a+1]=s.y}_extrudeRegion(e,t,o,i,s,a,c){let d=new xe.Vector3,l=new xe.Vector3,u=new xe.Vector3,p=new xe.Vector3,f=new xe.Vector2;o.forEach((h,y)=>{let g=i[y],x=e.verticesStart*o.length+e.verticesCount*y;for(let S=0;S<e.count;S++){let w=(e.start+S)*2;if(d.set(t[w+0],t[w+1],0),u.copy(d).applyMatrix4(h).add(g),e.continuous[S])p.set(e.normals[S*2+0],e.normals[S*2+1],0);else{let b=S===0?(e.start+e.count-1)*2:w-2;l.set(t[b+0],t[b+1],0),p.copy(d).sub(l),p.set(-p.y,p.x,0),e.isHole||p.negate()}if(p.applyMatrix4(h).normalize(),f.set(S===0?1:S/e.count,y/(o.length-1)),this._insertVertex(s,x,u,p,f),x++,!e.continuous[S]||S===0){if(S===0)p.set(e.normals[S*2+0],e.normals[S*2+1],0),f.set(0,y/(o.length-1));else{let b=S===e.count-1?e.start*2:w+2;l.set(t[b+0],t[b+1],0),p.copy(l).sub(d),p.set(-p.y,p.x,0),e.isHole||p.negate()}p.applyMatrix4(h).normalize(),this._insertVertex(s,x,u,p,f),x++}}});let m=o.length-1;for(let h=0;h<m;h++){let y=e.verticesStart*o.length+e.verticesCount*h,g=e.verticesStart*o.length+e.verticesCount*(h+1),x=0;for(let S=0;S<e.count;S++){(!e.continuous[S]||S===0)&&x++;let w=S===e.count-1?0:x+1,b=y+x,_=y+w,P=g+w,v=g+x;e.isHole?a.push(b,P,_,b,v,P):a.push(b,_,P,b,P,v),x++}}}_closeEnd(e,t,o,i,s,a,c){let d=e.vertexCount,l=new xe.Vector3(0,0,c?-1:1).applyMatrix4(s),u=new xe.Vector3,p=new xe.Vector2;for(let m=0;m<d;m++){let h=2*m;u.set(e.vertices[h+0],e.vertices[h+1],0).applyMatrix4(s).add(a),this._insertVertex(i,t+m,u,l,p)}let f=e.elements;for(let m=0;m<e.elementCount;m++){let h=3*m,y=f[h+0]+t,g=f[h+(c?1:2)]+t,x=f[h+(c?2:1)]+t;o.push(y,g,x)}}applyMatrix4OnRange(e,t,o){let i=e.elements,s=new xe.Matrix3().getNormalMatrix(e).elements,a,c,d,l,u=this.attributes.position,p=this.attributes.normal;if(!u||!p)return;let f=u.array,m=p.array,h=u.itemSize;for(let y=t*h,g=o*h;y<g;y+=h){if(y===t)debugger;a=f[y+0],c=f[y+1],d=f[y+2],l=1/(i[3]*a+i[7]*c+i[11]*d+i[15]),f[y+0]=(i[0]*a+i[4]*c+i[8]*d+i[12])*l,f[y+1]=(i[1]*a+i[5]*c+i[9]*d+i[13])*l,f[y+2]=(i[2]*a+i[6]*c+i[10]*d+i[14])*l,a=m[y+0],c=m[y+1],d=m[y+2],m[y+0]=s[0]*a+s[3]*c+s[6]*d,m[y+1]=s[1]*a+s[4]*c+s[7]*d,m[y+2]=s[2]*a+s[5]*c+s[8]*d}u.needsUpdate=!0,p.needsUpdate=!0}reverseIndicesOnRange(e,t){let o=this.index;if(o){for(let i=e;i<t;i+=3){let s=o.getX(i),a=o.getX(i+1),c=o.getX(i+2);o.setXYZ(i,c,a,s)}o.needsUpdate=!0}}};var hn=require("three"),Fy=require("three/examples/jsm/utils/BufferGeometryUtils.js");function ky(){let n=new hn.BufferGeometry;return n.setAttribute("position",new hn.BufferAttribute(new Float32Array([]),3)),n.setIndex(new hn.BufferAttribute(new Uint16Array([]),1)),n}var ZP=ky().attributes,QP=12,JP=1,Ei=class extends hn.BufferGeometry{constructor(e,t){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];Object.assign(this.attributes,ZP),this.userData={parameters:e,type:"TextGeometry"};let o=t.getFont(e.font);o?.isLoaded?(this.font=o,this.update(e)):this.updateFont(e.font,t).then(()=>{this.update(e),t?.requestRender()})}async updateFont(e,t){let o=t.getFont(e);o&&(this.font=o,await o.loadingPromise)}update(e){let t=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!t?.isLoaded){console.warn("Cannot update text because its font is not loaded");return}let{width:o,height:i,depth:s,extrudeBevelSize:a,extrudeBevelSegments:c,text:d,textTransform:l}=e,u=l===2?d.toUpperCase():l===3?d.toLowerCase():d,p=eT(e,t,u),{shapes:f,charWidths:m,charCoords:h}=t.generateShapes(p,e),y=o*.5,g=i*.5,x=f.map(b=>new Me().fromShape(b));this.vectorShapes=x;let S=x.map(b=>Kt.create({shape:b,parameters:{depth:s,extrudeBevelSegments:c,extrudeBevelSize:a,windingRule:s<=0?Oe.NONZERO:Oe.ODD,subdivisions:this.isLowResolution&&s>0?JP:QP}})),w=S.length?(0,Fy.mergeBufferGeometries)(S):ky();w.translate(-y,g,0),this.dispose(),this.wrappedText=p,this.charCoords=h,this.charWidths=m,this.deleteAttribute("extrudeNormal"),Object.entries(w.attributes).forEach(([b,_])=>{this.setAttribute(b,_)}),this.setIndex(w.index),this.computeBoundingSphere()}clone(){let e=br(new hn.BufferGeometry,Ei.prototype);return e.copy(this),console.log("CloneGeometry",this,e),e}copy(e){return Object.entries(e.attributes).forEach(([t,o])=>{this.setAttribute(t,o)}),this.setIndex(e.index),this.userData={parameters:{...e.userData.parameters},type:"TextGeometry"},this}async setText(e){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:e})}get text(){return this.userData.parameters.text??""}};function eT(n,r,e){e=e??n.text;let t=[""],o="";for(let i of e)o+=i,i===" "||i===`
2
2
  `?(t[t.length-1]+=o,o="",i===`
3
- `&&t.push("")):r.getTextWidth(t[t.length-1]+o,n)>n.width&&(t[t.length-1].length&&t.push(""),r.getTextWidth(t[t.length-1]+o,n)>n.width&&(o.length===1?(t[t.length-1]+=o,o=""):(t[t.length-1]+=o.slice(0,-1),o=o[o.length-1],t.push(""))));return t[t.length-1]+=o,t}var ke=require("three");var Hy,Li=new Promise(n=>{Hy=n}),Uy=!1;var oc;function Wy(){if(Uy)return;if(oc)return oc;async function n(){let e=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@0.9.439/build",o=import("./process.js"),[i,s]=await Promise.all([o,fetch(`${e}/process.wasm`).then(d=>d.arrayBuffer())]),a=i.default,c=await a({wasmBinary:s});Hy(c),Uy=!0}return oc=n(),oc}var qy=require("three");function gn(n,r,e){let t={parameters:n,type:n.type};if(n.type==="PathGeometry")t.path=n.path;else if(n.type==="VectorGeometry"){let i=Me.createFromState(n.shape,n.width,n.height);t.shape=i}else if(n.type==="NonParametricGeometry")n.data.groups&&n.data.groups.forEach(i=>i.materialIndex=Math.max(i.materialIndex??0,0)),t.geometry=new qy.BufferGeometryLoader().parse(n);else{if(n.type==="SubdivGeometry")return new lt(n,e);if(n.type==="TextGeometry")return new Ei(n,r)}let o;try{o=od(t)}catch(i){console.error(i)}if(!o){let i=Me.createFromState(ui.defaultData(),100,100);t.shape=i,o=od(t)}return o}var $y=require("three"),tT=new $y.Matrix4;function ea(n,r,e,t){let o=n.position.array,i=n.normal.array,s=tT.makeScale(r,e,t).invert().elements,a,c,d;for(var l=0,u=o.length;l<u;l+=3)o[l]*=r,o[l+1]*=e,o[l+2]*=t,a=i[l],c=i[l+1],d=i[l+2],i[l]=s[0]*a+s[4]*c+s[8]*d,i[l+1]=s[1]*a+s[5]*c+s[9]*d,i[l+2]=s[2]*a+s[6]*c+s[10]*d;n.position.needsUpdate=!0,n.normal.needsUpdate=!0}var nc=new ke.Box3,Di=new ke.Vector3,fe;Li.then(n=>{fe=n});var Yy=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),Xy=new Uint32Array([0,1,2,3]),Ky=new Uint8Array([4]),lt=class extends ke.BufferGeometry{constructor(e,t){super();this.data=e;this.flatShading=t;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,t){this.freeSubdivPointer();let o=this.data.scaleBaked,i=Eo.div(t,o);this.subdividedGeometry&&ea(this.subdividedGeometry.attributes,...i),this.originalGeometry&&ea(this.originalGeometry.attributes,...i),this.data=e;let s=this.userData.parameters;this.userData.parameters={width:s.width*i[0],height:s.height*i[1],depth:s.depth*i[2]},this.originalGeometry.boundingSphere.center.multiply(Di.fromArray(i));let a=Di.set(s.width,s.height,s.depth).length();this.originalGeometry.boundingSphere.radius=a/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,t,o;try{({originalGeometry:e,subdividedGeometry:t,subdivPointer:o}=lt.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new ke.BoxGeometry(100,100,100),o=0}this.subdivPointer=o,this.originalGeometry=e,this.subdividedGeometry=t??void 0;let i=this.subdividedGeometry??this.originalGeometry;Object.assign(this,i),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(lt.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new ke.Sphere,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,o=e.boundingSphere.center;nc.setFromBufferAttribute(t),nc.getCenter(o),e.boundingSphere.radius=o.distanceTo(nc.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),nc.getSize(Di);let i={width:Di.x,height:Di.y,depth:Di.z};return this.userData.parameters=i,i}static build(e,t,o,i){let s,a,c,d=e?.phongAngle??35;o===!1&&(d=-1),t&&(fe.free_bvh(t),fe.free_subdivision_surface(t));try{s=lt.allocate(e,i)}catch(l){console.error(l,e),s=lt.allocate({positionWASM:Yy,indexWASM:Xy,verticesPerFaceWASM:Ky},i)}if(fe.set_destination_refinement_level(s,0),a=lt.buildLevel(s,!0,d),e.subdivisions>0)try{fe.set_destination_refinement_level(s,e.subdivisions),c=lt.buildLevel(s,!1,d)}catch{try{fe.set_destination_refinement_level(s,e.subdivisions-1),c=lt.buildLevel(s,!1,d)}catch{c=null}}else c=null;return{subdivPointer:s,originalGeometry:a,subdividedGeometry:c}}static primitiveToQuads(e,t,o){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let i=e.shape!==void 0||e.path!==void 0?t.geometry:gn(e,o,!1),s;e.type==="TorusGeometry"&&e.arc===Math.PI*2?s=i.getClosedTorusIndicesForBooleanOrSubdiv():s=i.getIndex();let a,c,d,l;({positions:a,triIndices:l}=ad(i.getAttribute("position"),s));let u;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let p=e.radialSegments*e.heightSegments*3*2,f=p+e.radialSegments*3;u=[p,f]}return{indices:c,verticesPerFace:d}=ld(a,l,i,u),{positions:a,indices:c,verticesPerFace:d}}static allocate(e,t){let o,i,s,a=[],c=[];e.positionWASM&&e.positionWASM.length>0?(o=e.positionWASM,i=e.indexWASM,s=e.verticesPerFaceWASM):(o=Yy,i=Xy,s=Ky);let d=o.length,l=i.length,u=s.length,p=o.length+a.length+c.length,f=i.length+s.length,m=p*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,h=p*Float32Array.BYTES_PER_ELEMENT,y=f*Uint32Array.BYTES_PER_ELEMENT,g=fe._malloc(m),x=new Float32Array(fe.HEAPF32.buffer,g,p),S=new Uint32Array(fe.HEAPU32.buffer,g+h,f);x.set(o,0),x.set(a,o.length),x.set(c,o.length+a.length),S.set(i,0),S.set(s,i.length);let w;e?.scaleBaked?.some(_=>_!==1)&&(w=new ke.Matrix4().makeScale(...e.scaleBaked)),t&&(w?w.premultiply(t):w=t);let b=w?fe.alloc_subdivision_surface2(g,d,g+h,l,g+h+i.length*Uint32Array.BYTES_PER_ELEMENT,u,w.elements):fe.alloc_subdivision_surface(g,d,g+h,l,g+h+i.length*Uint32Array.BYTES_PER_ELEMENT,u);return fe._free(g),b}static buildLevel(e,t,o,i,s){let a=s?fe.get_mesh_data2(e,t?fe.Level.CONTROL:fe.Level.REFINED,o,s.elements):fe.get_mesh_data(e,t?fe.Level.CONTROL:fe.Level.REFINED,o),c=8,d=fe.HEAPU32.subarray(a>>2,(a>>2)+c),l=d.subarray(4,4+4),u=0,p=fe.HEAPU32[d[u]>>2],f=fe.HEAPF32.subarray(p>>2,(p>>2)+l[u]);u++;let m=fe.HEAPU32[d[u]>>2],h=fe.HEAPF32.subarray(m>>2,(m>>2)+l[u]);u++;let y=fe.HEAPU32[d[u]>>2],g=fe.HEAPU32.subarray(y>>2,(y>>2)+l[u]);u++;let x=fe.HEAPU32[d[u]>>2],S=fe.HEAPU32.subarray(x>>2,(x>>2)+l[u]);if(u++,i===void 0){let w=new ke.BufferGeometry;if(w.setIndex(new ke.Uint32BufferAttribute(S,1)),w.setAttribute("position",new ke.Float32BufferAttribute(f,3)),w.setAttribute("normal",new ke.Float32BufferAttribute(h,3)),t){w.setAttribute("faceMap",new ke.Uint32BufferAttribute(g,1));let b=new Float32Array(h.length/3*4).fill(0);w.setAttribute("color",new ke.BufferAttribute(b,4))}return fe.free_mesh_data(a),w.userData.type="SubdivGeometry",w}i.getAttribute("position").copyArray(f),i.getAttribute("normal").copyArray(h),i.attributes.position.needsUpdate=!0,i.attributes.normal.needsUpdate=!0,fe.free_mesh_data(a)}static freeSubdivPointer(e){fe.free_bvh(e),fe.free_subdivision_surface(e)}static buildControlCageWireframe(e,t,o){let i=fe.get_wireframe_data_for_base_level(e),s=4,a=fe.HEAPU32.subarray(i>>2,(i>>2)+s),c=a.subarray(2,2+2),d=0,l=fe.HEAPU32[a[d]>>2],u=fe.HEAPF32.subarray(l>>2,(l>>2)+c[d]);d++;let p=fe.HEAPU32[a[d]>>2],f=fe.HEAPU32.subarray(p>>2,(p>>2)+c[d]);if(t===void 0){let m=new ke.BufferGeometry;m.setAttribute("position",new ke.Float32BufferAttribute(u,3));let h=new Float32Array(u.length);for(let y=0,g=u.length;y<g;)h[y++]=o.r,h[y++]=o.g,h[y++]=o.b;return m.setAttribute("color",new ke.BufferAttribute(h,3)),m.setIndex(new ke.Uint32BufferAttribute(f,1)),fe.free_wireframe_data_for_base_level(i),m}t.getAttribute("position").copyArray(u),t.attributes.position.needsUpdate=!0,fe.free_wireframe_data_for_base_level(i)}static updateCollabMesh(e,t,o){let i=t===0;i||fe.set_destination_refinement_level(e,t);let s=o?fe.get_topological_data2(e,i?fe.Level.CONTROL:fe.Level.REFINED,o.elements):fe.get_topological_data(e,i?fe.Level.CONTROL:fe.Level.REFINED),a=6,c=fe.HEAPU32.subarray(s>>2,(s>>2)+a),d=c.subarray(3,3+3),l=0,u=fe.HEAPU32[c[l]>>2],p=new Float32Array(fe.HEAPF32.subarray(u>>2,(u>>2)+d[l]));l++;let f=fe.HEAPU32[c[l]>>2],m=new Uint32Array(fe.HEAPU32.subarray(f>>2,(f>>2)+d[l]));l++;let h=fe.HEAPU32[c[l]>>2],y=new Uint8Array(fe.HEAPU32.subarray(h>>2,(h>>2)+d[l]));return fe.free_topological_data(s),{positions:p,indices:m,verticesPerFace:y}}};var Zy=["getX","getY","getZ"];function ad(n,r){let e={},t=r?r.count:n.count,o=0,i=[],s=[],a=1e4;for(let d=0;d<t;d++){let l=r?r.getX(d):d,u="";for(let p=0;p<3;p++)u+=`${~~(n[Zy[p]](l)*a)},`;if(u in e)i.push(e[u]);else{for(let p=0;p<3;p++)s.push(n[Zy[p]](l));e[u]=o,i.push(o),o++}}let c=[];for(let d=0;d<i.length;d+=3)i[d]===i[d+1]||i[d]===i[d+2]||i[d+1]===i[d+2]||c.push(i[d],i[d+1],i[d+2]);return{positions:s,triIndices:c}}var ic=new ke.Vector3,nd=new ke.Vector3,id=new ke.Vector3,sd=new ke.Vector3;function ld(n,r,e,t){let o=[],i=[];if(e.userData.shape!==void 0&&e.userData.parameters.depth===0&&e.userData.shape.shapeHoles.length===0){let c=e.userData.shape.extractShapePointsToFlatArray([]),d=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&d<=24&&d%4===0&&e.userData.parameters.angle>=360){let p=c.length/2/d;c=c.filter((f,m)=>Math.floor(m/2)%p===0)}let l=0;for(let p=0;p<c.length;p+=2)l+=(c[p]-c[(p===0?c.length:p)-2])*(c[p+1]+c[(p===0?c.length:p)-1]);n.length=0;let u=0;if(l<0)for(let p=0;p<c.length;p+=2)n.push(c[p],c[p+1],0),o.push(u++);else for(let p=c.length-2;p>=0;p-=2)n.push(c[p],c[p+1],0),o.push(u++);return i.push(u),{indices:o,verticesPerFace:i}}let s=new Float32Array([e.userData.parameters.depth])[0],a=0;for(;a<r.length;){if(e.useNgonForTopBottomFaceDuringBake){let c=0;if((n[r[a]*3+2]===s||n[r[a]*3+2]===0)&&c++,(n[r[a+1]*3+2]===s||n[r[a+1]*3+2]===0)&&c++,(n[r[a+2]*3+2]===s||n[r[a+2]*3+2]===0)&&c++,c===3)break}if(r[a+1]===r[a+3]&&r[a+2]===r[a+5]||r[a+0]===r[a+3]&&r[a+2]===r[a+4]){ic.set(n[r[a]*3],n[r[a]*3+1],n[r[a]*3+2]),nd.set(n[r[a+1]*3],n[r[a+1]*3+1],n[r[a+1]*3+2]),id.set(n[r[a+4]*3],n[r[a+4]*3+1],n[r[a+4]*3+2]),sd.set(n[r[a+5]*3],n[r[a+5]*3+1],n[r[a+5]*3+2]),nd.sub(ic).normalize(),id.sub(ic).normalize(),sd.sub(ic).normalize();let c=nd.cross(id).dot(sd);Math.abs(c)>.005||t&&t.some((d,l)=>l%2===1?!1:a>=t[l]&&a<t[l+1])?(o.push(r[a],r[a+1],r[a+2]),i.push(3),a+=3):(o.push(r[a],r[a+1],r[a+4],r[a+5]),i.push(4),a+=6)}else o.push(r[a],r[a+1],r[a+2]),i.push(3),a+=3}if(e.useNgonForTopBottomFaceDuringBake){let c=[],d=[],l=0;for(let u=0,p=0;u<n.length;u+=3,p++)n[u+2]===0&&(c.push(p),l++),n[u+2]===s&&d.push(p);if(e.userData.parameters.extrudeBevelSize===0){let u=d[0];d[0]=d[1],d[1]=u}c.reverse(),o.push(...c,...d),i.push(l,l)}return{indices:o,verticesPerFace:i}}var pr={};Yd(pr,{calcBoolean:()=>iT,calcBooleanTopological:()=>nT,freeMeshSet:()=>cT,getMeshSet:()=>sT,hasOpenEdges:()=>aT,transformMeshSet:()=>lT});var rT,Qy=new Promise(n=>{rT=n});var ta=require("three");var _e,Bi;Qy.then(n=>_e=n);function oT(n,r,e){let t,o;n.userData.parameters.type==="TorusGeometry"&&n.userData.parameters.arc===Math.PI*2?o=n.getClosedTorusIndicesForBooleanOrSubdiv():o=n.getIndex();let{positions:i,triIndices:s}=ad(n.getAttribute("position"),o),a;if(r&&e){let{indices:c,verticesPerFace:d}=ld(i,s,n);a=d.length,t=[];for(let l=0,u=0;l<a;l++){t.push(d[l]);for(let p=0;p<d[l];p++)t.push(c[u++])}}else{let c=s.length;t=Array(c+c/3),a=0;for(let d=0,l=0;l<t.length;)t[l++]=3,a++,t[l++]=s[d++],t[l++]=s[d++],t[l++]=s[d++]}return{positions:i,faceIndices:t,nFaces:a}}function Jy(n){let r=n.length,e=r*Uint32Array.BYTES_PER_ELEMENT,t=r*Float32Array.BYTES_PER_ELEMENT,o=Number.isInteger(n[0])?e:t,i=_e._malloc(o);return(Number.isInteger(n[0])?new Uint32Array(_e.HEAPU32.buffer,i,r):new Float32Array(_e.HEAPF32.buffer,i,r)).set(n,0),i}function eg(n){switch(n){case 0:return _e.OP.UNION;case 1:return _e.OP.INTERSECTION;case 2:return _e.OP.A_MINUS_B;case 3:return _e.OP.B_MINUS_A;case 4:return _e.OP.SYMMETRIC_DIFFERENCE;case 5:return _e.OP.ALL;default:throw new Error("Unknown boolean operation "+n)}}function nT(n,r){Bi===void 0&&(Bi=_e.init_csg());let e=Jy(n),t=_e.csg_calc_topological(Bi,e,n.length,eg(r));_e._free(e);let o=6,i=_e.HEAPU32.subarray(t>>2,(t>>2)+o),s=i.subarray(3,3+3),a=0,c=_e.HEAPU32[i[a]>>2],d=new Float32Array(_e.HEAPF32.subarray(c>>2,(c>>2)+s[a]));a++;let l=_e.HEAPU32[i[a]>>2],u=new Uint32Array(_e.HEAPU32.subarray(l>>2,(l>>2)+s[a]));a++;let p=_e.HEAPU32[i[a]>>2],f=new Uint8Array(_e.HEAPU32.subarray(p>>2,(p>>2)+s[a]));return _e.free_mesh_data(t),{positions:d,indices:u,verticesPerFace:f}}function iT(n,r,e,t){Bi===void 0&&(Bi=_e.init_csg());let o=Jy(n),i=_e.csg_calc(Bi,o,n.length,t,eg(r));_e._free(o);let s=5,a=_e.HEAPU32.subarray(i>>2,(i>>2)+s),c=a.subarray(2,2+3),d=0,l=_e.HEAPU32[a[d]>>2],u=_e.HEAPF32.subarray(l>>2,(l>>2)+c[d]);d++;let p=_e.HEAPU32[a[d]>>2],f=_e.HEAPF32.subarray(p>>2,(p>>2)+c[d]);d++;let m=c[d];e.setAttribute("position",new ta.Float32BufferAttribute(u,3)),e.setAttribute("normal",new ta.Float32BufferAttribute(f,3));let h=_e.HEAPF32.subarray((i>>2)+5,(i>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new ta.Sphere),e.boundingSphere.center.set(h[0],h[1],h[2]),e.boundingSphere.radius=(h[3]**2+h[4]**2+h[5]**2)**.5,e.userData.parameters={width:h[3]*2,height:h[4]*2,depth:h[5]*2},_e.free_mesh_data(i),m}function sT(n,r,e){if(_e===void 0)return-1;let t,o,i;if(r&&n.userData.positions!==void 0){let y=n.userData;i=y.verticesPerFace.length,t=y.positions,o=Array(y.verticesPerFace.reduce((g,x)=>g+x,0)+i);for(let g=0,x=0,S=0;g<y.verticesPerFace.length;g++){o[S++]=y.verticesPerFace[g];for(let w=0;w<y.verticesPerFace[g];w++)o[S++]=y.indices[x++]}}else({positions:t,faceIndices:o,nFaces:i}=oT(n,r,e));let s=t.length,a=o.length,c=t.length,d=o.length,l=c*Float32Array.BYTES_PER_ELEMENT+d*Uint32Array.BYTES_PER_ELEMENT,u=c*Float32Array.BYTES_PER_ELEMENT,p=d*Uint32Array.BYTES_PER_ELEMENT,f=_e._malloc(l),m=new Float32Array(_e.HEAPF32.buffer,f,c),h=new Uint32Array(_e.HEAPU32.buffer,f+u,d);return m.set(t,0),h.set(o,0),_e.get_csg_mesh(f,s,f+u,a,i)}function aT(n){return _e.has_open_edges(n)}function lT(n,r){_e.transform_csg_mesh(n,r.elements)}function cT(n){_e.free_csg_mesh(n)}var uT={ConeGeometry:Fh,CubeGeometry:kh,CylinderGeometry:zh,DodecahedronGeometry:Hh,EllipseGeometry:Ni,HelixGeometry:vy,IcosahedronGeometry:Sy,LatheGeometry:wy,NonParametricGeometry:Oy,PolygonGeometry:ec,PyramidGeometry:Ay,RectangleGeometry:tc,SphereGeometry:Ny,PlaneGeometry:My,BackdropGeometry:Ey,StarGeometry:rc,TextFrameGeometry:Dy,TorusGeometry:By,TorusKnotGeometry:Gy,TriangleGeometry:Vy,PathGeometry:jy,VectorGeometry:Kt},od=n=>uT[n.type].create(n);function ra(n){return n!==null&&"booleanOp"in n}var Ri=class extends bi(sc.Mesh){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new sc.Matrix4}updateVisible(){super.updateVisible(),this.visible=!ra(this.parent)&&this.visible,ra(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(pr.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),ra(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof Ri&&(e.freeBooleanPointer(),ra(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e){let t=super.updateTransformState(e);return t&&ra(this.parent)&&this.invalidateDownstreamBooleanData(!0),t}};var ac=new Gi.Box3;function oa(n,r=0,e=n.count,t,o){let i=1/0,s=1/0,a=1/0,c=-1/0,d=-1/0,l=-1/0;for(let u=r;u<e;u++){let p=n.getX(u),f=n.getY(u),m=n.getZ(u);p<i&&(i=p),f<s&&(s=f),m<a&&(a=m),p>c&&(c=p),f>d&&(d=f),m>l&&(l=m)}ac.min.set(i,s,a),ac.max.set(c,d,l),ac.getCenter(t),ac.getSize(o).multiplyScalar(.5)}var dT=new Gi.BufferGeometry,pT=new Gi.MeshBasicMaterial,Mt=class extends Ri{constructor(r,e){super(dT,pT),this.super_Entity(r,e)}updateState(r,e){this.updateState_Entity(r,e)}updateEntityBoxSize(r,e){let t=this.geometry.getAttribute("position");t!==void 0?oa(t,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:t.count,r,e):super.updateEntityBoxSize(r,e)}};var bo=require("three");var cr=require("three");var Pg=require("three");var Nr=require("three");var na=class{constructor(r){r=r??{},this.name=r.name,this.type=r.type,this.node=r.node,this.size=r.size,this.needsUpdate=r.needsUpdate}get value(){return this.node.value}set value(r){this.node.value=r}};var tg=require("three"),_t=class{constructor(r){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=tg.MathUtils.generateUUID(),this.type=r,this.name=""}analyze(r,e){e=e??{},r.analyzing=!0,this.build(r.addFlow(e.slot,e.cache,e.context),"v4"),r.clearVertexNodeCode(),r.clearFragmentNodeCode(),r.removeFlow(),r.analyzing=!1}analyzeAndFlow(r,e,t){return t=t??{},this.analyze(r,t),this.flow(r,e,t)}flow(r,e,t){t=t??{},r.addFlow(t.slot,t.cache,t.context);let o={result:this.build(r,e),code:r.clearNodeCode(),extra:r.context.extra};return r.removeFlow(),o}build(r,e,t){e=e??this.getType(r,e);let o=r.getNodeData(t??this);return r.analyzing&&this.appendDepsNode(r,o,e),r.nodes.indexOf(this)===-1&&r.nodes.push(this),this.updateFrame!==void 0&&r.updaters.indexOf(this)===-1&&r.updaters.push(this),this.generate(r,e,t)}updateFrame(r){}generateReadonly(r,e,t,o,i,s){return""}generate(r,e,t,o,i){return""}parse(r,e,t,o){}appendDepsNode(r,e,t){e.deps=(e.deps||0)+1;let o=r.getTypeLength(t);(o>(e.outputMax||0)||this.getType(r,t))&&(e.outputMax=o,e.output=t)}setName(r){this.name=r}getName(){return this.name}getType(r,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}getHash(){let r="{",e,t;for(e in this)t=this[e],t instanceof _t&&(r+='"'+e+'":'+t.getHash()+",");if(this.hashProperties)for(let o=0;o<this.hashProperties.length;o++)e=this.hashProperties[o],t=this[e],r+='"'+e+'":"'+String(t)+'",';return r+='"id":"'+this.uuid+'"}',r}};var cd=class{constructor(){this.nodes={};this.keywords={}}add(r){this.nodes[r.name]=r}addKeyword(r,e,t){t=t!==void 0?t:!0,this.keywords[r]={callback:e,cache:t}}remove(r){delete this.nodes[r.name]}removeKeyword(r){delete this.keywords[r]}get(r){return this.nodes[r]}getKeyword(r,e){return this.keywords[r].callback(e)}getKeywordData(r){return this.keywords[r]}contains(r){return this.nodes[r]!==void 0}containsKeyword(r){return this.keywords[r]!==void 0}},ht=new cd;var ud=require("three");var rg=require("three"),ae=class extends _t{constructor(e,t){super(e);this.scope="";t=t??{},this.shared=t.shared!==void 0?t.shared:!0,this.unique=t.unique!==void 0?t.unique:!1}build(e,t,o,i){if(t=t??this.getType(e),this.getShared(e,t)){let s=this.getUnique(e,t);s&&this.uuid===void 0&&(this.uuid=rg.MathUtils.generateUUID()),o=e.getUUID(o??this.getUUID(),!s);let a=e.getNodeData(o),c=a.output||this.getType(e);if(e.analyzing)return(a.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,a,t),this.generate(e,t,o)):super.build(e,t,o);if(s)return a.name=a.name||super.build(e,t,o),a.name;if(!this.getLabel()&&(!this.getShared(e,c)||e.context.ignoreCache||a.deps===1))return super.build(e,t,o);o=this.getUUID(!1);let d=this.getTemp(e,o);if(d)return e.format(d,c,t);{d=super.generate(e,t,o,a.output,i);let l=this.generate(e,c,o);return e.addNodeCode(d+" = "+l+";"),e.format(d,c,t)}}return super.build(e,t,o)}getShared(e,t){return t!=="sampler2D"&&t!=="samplerCube"&&this.shared}getUnique(e,t){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let t=this.uuid;return typeof this.scope=="string"&&(t=this.scope+"-"+t),t}getTemp(e,t){t=t||this.uuid;let o=e.getVars()[t];return o?o.name:void 0}generate(e,t,o,i,s){return this.getShared(e,t)||console.error("TempNode is not shared"),o=o??this.uuid,e.getTempVar(o,i??this.getType(e),s,this.getLabel()).name}};var Ve=class extends ae{constructor(e,t){t=t??{},t.shared=t.shared!==void 0?t.shared:!1;super(e,t);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,t,o,i,s,a){o=e.getUUID(o??this.getUUID()),i=i??this.getType(e);let c=e.getNodeData(o);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,t,o,i,s,a):e.isShader("vertex")?(c.vertex||(c.vertex=e.createVertexUniform(i,this,s,a,this.getLabel())),e.format(c.vertex.name,i,t)):(c.fragment||(c.fragment=e.createFragmentUniform(i,this,s,a,this.getLabel())),e.format(c.fragment.name,i,t))}};var et=class extends Ve{constructor(e=0,t){super("v2");this.nodeType="Vector2";this.value=e instanceof ud.Vector2?e:new ud.Vector2(e,t)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,t,o,i,s,a){return e.format("vec2("+this.value.x+", "+this.value.y+")",i,t)}};var dd=require("three");var Et=class extends Ve{constructor(e=0,t,o){super("v3");this.nodeType="Vector3";this.value=e instanceof dd.Vector3?e:new dd.Vector3(e,t,o)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,t,o,i,s,a){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",i,t)}};var og=require("three"),yt=class extends og.Color{constructor(e,t,o,i){super(e,t,o);this.isColorA=!0;this.a=i}setRGBA(e,t,o,i){super.setRGB(e,t,o),this.a=i}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}setStyle(e,t="srgb"){let o;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(o=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let i,s=o[1],a=o[2];switch(s){case"rgb":case"rgba":if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.a=s==="rgba"?parseFloat(i[4]):1,super.setStyle(e,t);break;case"hsl":case"hsla":if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.a=s==="hsla"?parseFloat(i[4]):1,super.setStyle(e,t);break}}return super.setStyle(e,t)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(e){this.r=e}set y(e){this.g=e}set z(e){this.b=e}set w(e){this.a=e}};var Zt=class extends Ve{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof yt?e:new yt(e.r,e.g,e.b,e.a)}generateReadonly(e,t,o,i,s,a){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",i,t)}};var fT=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,ng=/[a-z_0-9]+/gi,H=class extends ae{constructor(e,t,o,i,s){super(s);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=s===void 0,this.isInterface=!1,this.parse(e,t,o,i)}getShared(e,t){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}}getIncludeByName(e){if(this.includes){let t=this.includes.length;for(;t--;)if(this.includes[t].name===e)return this.includes[t]}}generate(e,t,o,i,s){let a,c=0,d=this.src;if(this.includes)for(let u=0;u<this.includes.length;u++)e.include(this.includes[u],this);for(let u in this.extensions)e.extensions[u]=!0;let l=[];for(;a=ng.exec(this.src);)l.push(a);for(let u=0;u<l.length;u++){let p=l[u],f=p[0],m=this.isMethod?!this.getInputByName(f):!0,h=f;if(this.keywords[f]||this.useKeywords&&m&&ht.containsKeyword(f)){let y=this.keywords[f];if(!y){let g=ht.getKeywordData(f);g.cache&&(y=e.keywords[f]),y=y||ht.getKeyword(f,e),g.cache&&(e.keywords[f]=y)}h=y.build(e)}f!==h&&d[p.index+c-1]!=="."&&(d=d.substring(0,p.index+c)+h+d.substring(p.index+f.length+c),c+=h.length-f.length),this.getIncludeByName(h)===void 0&&ht.contains(h)&&e.include(ht.get(h))}return t==="source"?d:this.isMethod?(this.isInterface||e.include(this,void 0,d),this.name):e.format("( "+d+" )",this.getType(e),t)}parse(e,t,o,i){if(this.src=e||"",this.includes=t??[],this.extensions=o??{},this.keywords=i??{},this.isMethod){let s=fT.exec(this.src);if(this.inputs=[],s&&s.length==4){this.type=s[1],this.name=s[2];let a=s[3].match(ng);if(a){let c=0;for(;c<a.length;){let d=a[c++],l;d==="in"||d==="out"||d==="inout"?l=a[c++]:(l=d,d="");let u=a[c++];this.inputs.push({name:u,type:l,qualifier:d})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var mT=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,pd=class extends ae{constructor(e="",t){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||pd.PI,void 0,void 0,void 0,t)}getType(e){return e.getTypeByFormat(this.type)}parse(e,t,o,i,s){this.src=e||"";let a,c,d="",l=mT.exec(e);this.useDefine=s??this.src.charAt(0)==="#",l&&l.length>1?(c=l[1],a=l[2],d=l[3]):(a=this.src,c="f"),this.name=a,this.type=c,this.value=d}build(e,t){if(t==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),t)}generate(e,t,o,i,s){return e.format(this.name,this.getType(e),t)}},Ie=pd;Ie.PI="PI",Ie.PI2="PI2",Ie.RECIPROCAL_PI="RECIPROCAL_PI",Ie.RECIPROCAL_PI2="RECIPROCAL_PI2",Ie.LOG2="LOG2",Ie.EPSILON="EPSILON";var hT=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
3
+ `&&t.push("")):r.getTextWidth(t[t.length-1]+o,n)>n.width&&(t[t.length-1].length&&t.push(""),r.getTextWidth(t[t.length-1]+o,n)>n.width&&(o.length===1?(t[t.length-1]+=o,o=""):(t[t.length-1]+=o.slice(0,-1),o=o[o.length-1],t.push(""))));return t[t.length-1]+=o,t}var ke=require("three");var Hy,Li=new Promise(n=>{Hy=n}),Uy=!1;var oc;function Wy(){if(Uy)return;if(oc)return oc;async function n(){let e=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@0.9.440/build",o=import("./process.js"),[i,s]=await Promise.all([o,fetch(`${e}/process.wasm`).then(d=>d.arrayBuffer())]),a=i.default,c=await a({wasmBinary:s});Hy(c),Uy=!0}return oc=n(),oc}var qy=require("three");function gn(n,r,e){let t={parameters:n,type:n.type};if(n.type==="PathGeometry")t.path=n.path;else if(n.type==="VectorGeometry"){let i=Me.createFromState(n.shape,n.width,n.height);t.shape=i}else if(n.type==="NonParametricGeometry")n.data.groups&&n.data.groups.forEach(i=>i.materialIndex=Math.max(i.materialIndex??0,0)),t.geometry=new qy.BufferGeometryLoader().parse(n);else{if(n.type==="SubdivGeometry")return new lt(n,e);if(n.type==="TextGeometry")return new Ei(n,r)}let o;try{o=od(t)}catch(i){console.error(i)}if(!o){let i=Me.createFromState(ui.defaultData(),100,100);t.shape=i,o=od(t)}return o}var $y=require("three"),tT=new $y.Matrix4;function ea(n,r,e,t){let o=n.position.array,i=n.normal.array,s=tT.makeScale(r,e,t).invert().elements,a,c,d;for(var l=0,u=o.length;l<u;l+=3)o[l]*=r,o[l+1]*=e,o[l+2]*=t,a=i[l],c=i[l+1],d=i[l+2],i[l]=s[0]*a+s[4]*c+s[8]*d,i[l+1]=s[1]*a+s[5]*c+s[9]*d,i[l+2]=s[2]*a+s[6]*c+s[10]*d;n.position.needsUpdate=!0,n.normal.needsUpdate=!0}var nc=new ke.Box3,Di=new ke.Vector3,fe;Li.then(n=>{fe=n});var Yy=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),Xy=new Uint32Array([0,1,2,3]),Ky=new Uint8Array([4]),lt=class extends ke.BufferGeometry{constructor(e,t){super();this.data=e;this.flatShading=t;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,t){this.freeSubdivPointer();let o=this.data.scaleBaked,i=Eo.div(t,o);this.subdividedGeometry&&ea(this.subdividedGeometry.attributes,...i),this.originalGeometry&&ea(this.originalGeometry.attributes,...i),this.data=e;let s=this.userData.parameters;this.userData.parameters={width:s.width*i[0],height:s.height*i[1],depth:s.depth*i[2]},this.originalGeometry.boundingSphere.center.multiply(Di.fromArray(i));let a=Di.set(s.width,s.height,s.depth).length();this.originalGeometry.boundingSphere.radius=a/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,t,o;try{({originalGeometry:e,subdividedGeometry:t,subdivPointer:o}=lt.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new ke.BoxGeometry(100,100,100),o=0}this.subdivPointer=o,this.originalGeometry=e,this.subdividedGeometry=t??void 0;let i=this.subdividedGeometry??this.originalGeometry;Object.assign(this,i),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(lt.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new ke.Sphere,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,o=e.boundingSphere.center;nc.setFromBufferAttribute(t),nc.getCenter(o),e.boundingSphere.radius=o.distanceTo(nc.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),nc.getSize(Di);let i={width:Di.x,height:Di.y,depth:Di.z};return this.userData.parameters=i,i}static build(e,t,o,i){let s,a,c,d=e?.phongAngle??35;o===!1&&(d=-1),t&&(fe.free_bvh(t),fe.free_subdivision_surface(t));try{s=lt.allocate(e,i)}catch(l){console.error(l,e),s=lt.allocate({positionWASM:Yy,indexWASM:Xy,verticesPerFaceWASM:Ky},i)}if(fe.set_destination_refinement_level(s,0),a=lt.buildLevel(s,!0,d),e.subdivisions>0)try{fe.set_destination_refinement_level(s,e.subdivisions),c=lt.buildLevel(s,!1,d)}catch{try{fe.set_destination_refinement_level(s,e.subdivisions-1),c=lt.buildLevel(s,!1,d)}catch{c=null}}else c=null;return{subdivPointer:s,originalGeometry:a,subdividedGeometry:c}}static primitiveToQuads(e,t,o){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let i=e.shape!==void 0||e.path!==void 0?t.geometry:gn(e,o,!1),s;e.type==="TorusGeometry"&&e.arc===Math.PI*2?s=i.getClosedTorusIndicesForBooleanOrSubdiv():s=i.getIndex();let a,c,d,l;({positions:a,triIndices:l}=ad(i.getAttribute("position"),s));let u;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let p=e.radialSegments*e.heightSegments*3*2,f=p+e.radialSegments*3;u=[p,f]}return{indices:c,verticesPerFace:d}=ld(a,l,i,u),{positions:a,indices:c,verticesPerFace:d}}static allocate(e,t){let o,i,s,a=[],c=[];e.positionWASM&&e.positionWASM.length>0?(o=e.positionWASM,i=e.indexWASM,s=e.verticesPerFaceWASM):(o=Yy,i=Xy,s=Ky);let d=o.length,l=i.length,u=s.length,p=o.length+a.length+c.length,f=i.length+s.length,m=p*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,h=p*Float32Array.BYTES_PER_ELEMENT,y=f*Uint32Array.BYTES_PER_ELEMENT,g=fe._malloc(m),x=new Float32Array(fe.HEAPF32.buffer,g,p),S=new Uint32Array(fe.HEAPU32.buffer,g+h,f);x.set(o,0),x.set(a,o.length),x.set(c,o.length+a.length),S.set(i,0),S.set(s,i.length);let w;e?.scaleBaked?.some(_=>_!==1)&&(w=new ke.Matrix4().makeScale(...e.scaleBaked)),t&&(w?w.premultiply(t):w=t);let b=w?fe.alloc_subdivision_surface2(g,d,g+h,l,g+h+i.length*Uint32Array.BYTES_PER_ELEMENT,u,w.elements):fe.alloc_subdivision_surface(g,d,g+h,l,g+h+i.length*Uint32Array.BYTES_PER_ELEMENT,u);return fe._free(g),b}static buildLevel(e,t,o,i,s){let a=s?fe.get_mesh_data2(e,t?fe.Level.CONTROL:fe.Level.REFINED,o,s.elements):fe.get_mesh_data(e,t?fe.Level.CONTROL:fe.Level.REFINED,o),c=8,d=fe.HEAPU32.subarray(a>>2,(a>>2)+c),l=d.subarray(4,4+4),u=0,p=fe.HEAPU32[d[u]>>2],f=fe.HEAPF32.subarray(p>>2,(p>>2)+l[u]);u++;let m=fe.HEAPU32[d[u]>>2],h=fe.HEAPF32.subarray(m>>2,(m>>2)+l[u]);u++;let y=fe.HEAPU32[d[u]>>2],g=fe.HEAPU32.subarray(y>>2,(y>>2)+l[u]);u++;let x=fe.HEAPU32[d[u]>>2],S=fe.HEAPU32.subarray(x>>2,(x>>2)+l[u]);if(u++,i===void 0){let w=new ke.BufferGeometry;if(w.setIndex(new ke.Uint32BufferAttribute(S,1)),w.setAttribute("position",new ke.Float32BufferAttribute(f,3)),w.setAttribute("normal",new ke.Float32BufferAttribute(h,3)),t){w.setAttribute("faceMap",new ke.Uint32BufferAttribute(g,1));let b=new Float32Array(h.length/3*4).fill(0);w.setAttribute("color",new ke.BufferAttribute(b,4))}return fe.free_mesh_data(a),w.userData.type="SubdivGeometry",w}i.getAttribute("position").copyArray(f),i.getAttribute("normal").copyArray(h),i.attributes.position.needsUpdate=!0,i.attributes.normal.needsUpdate=!0,fe.free_mesh_data(a)}static freeSubdivPointer(e){fe.free_bvh(e),fe.free_subdivision_surface(e)}static buildControlCageWireframe(e,t,o){let i=fe.get_wireframe_data_for_base_level(e),s=4,a=fe.HEAPU32.subarray(i>>2,(i>>2)+s),c=a.subarray(2,2+2),d=0,l=fe.HEAPU32[a[d]>>2],u=fe.HEAPF32.subarray(l>>2,(l>>2)+c[d]);d++;let p=fe.HEAPU32[a[d]>>2],f=fe.HEAPU32.subarray(p>>2,(p>>2)+c[d]);if(t===void 0){let m=new ke.BufferGeometry;m.setAttribute("position",new ke.Float32BufferAttribute(u,3));let h=new Float32Array(u.length);for(let y=0,g=u.length;y<g;)h[y++]=o.r,h[y++]=o.g,h[y++]=o.b;return m.setAttribute("color",new ke.BufferAttribute(h,3)),m.setIndex(new ke.Uint32BufferAttribute(f,1)),fe.free_wireframe_data_for_base_level(i),m}t.getAttribute("position").copyArray(u),t.attributes.position.needsUpdate=!0,fe.free_wireframe_data_for_base_level(i)}static updateCollabMesh(e,t,o){let i=t===0;i||fe.set_destination_refinement_level(e,t);let s=o?fe.get_topological_data2(e,i?fe.Level.CONTROL:fe.Level.REFINED,o.elements):fe.get_topological_data(e,i?fe.Level.CONTROL:fe.Level.REFINED),a=6,c=fe.HEAPU32.subarray(s>>2,(s>>2)+a),d=c.subarray(3,3+3),l=0,u=fe.HEAPU32[c[l]>>2],p=new Float32Array(fe.HEAPF32.subarray(u>>2,(u>>2)+d[l]));l++;let f=fe.HEAPU32[c[l]>>2],m=new Uint32Array(fe.HEAPU32.subarray(f>>2,(f>>2)+d[l]));l++;let h=fe.HEAPU32[c[l]>>2],y=new Uint8Array(fe.HEAPU32.subarray(h>>2,(h>>2)+d[l]));return fe.free_topological_data(s),{positions:p,indices:m,verticesPerFace:y}}};var Zy=["getX","getY","getZ"];function ad(n,r){let e={},t=r?r.count:n.count,o=0,i=[],s=[],a=1e4;for(let d=0;d<t;d++){let l=r?r.getX(d):d,u="";for(let p=0;p<3;p++)u+=`${~~(n[Zy[p]](l)*a)},`;if(u in e)i.push(e[u]);else{for(let p=0;p<3;p++)s.push(n[Zy[p]](l));e[u]=o,i.push(o),o++}}let c=[];for(let d=0;d<i.length;d+=3)i[d]===i[d+1]||i[d]===i[d+2]||i[d+1]===i[d+2]||c.push(i[d],i[d+1],i[d+2]);return{positions:s,triIndices:c}}var ic=new ke.Vector3,nd=new ke.Vector3,id=new ke.Vector3,sd=new ke.Vector3;function ld(n,r,e,t){let o=[],i=[];if(e.userData.shape!==void 0&&e.userData.parameters.depth===0&&e.userData.shape.shapeHoles.length===0){let c=e.userData.shape.extractShapePointsToFlatArray([]),d=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&d<=24&&d%4===0&&e.userData.parameters.angle>=360){let p=c.length/2/d;c=c.filter((f,m)=>Math.floor(m/2)%p===0)}let l=0;for(let p=0;p<c.length;p+=2)l+=(c[p]-c[(p===0?c.length:p)-2])*(c[p+1]+c[(p===0?c.length:p)-1]);n.length=0;let u=0;if(l<0)for(let p=0;p<c.length;p+=2)n.push(c[p],c[p+1],0),o.push(u++);else for(let p=c.length-2;p>=0;p-=2)n.push(c[p],c[p+1],0),o.push(u++);return i.push(u),{indices:o,verticesPerFace:i}}let s=new Float32Array([e.userData.parameters.depth])[0],a=0;for(;a<r.length;){if(e.useNgonForTopBottomFaceDuringBake){let c=0;if((n[r[a]*3+2]===s||n[r[a]*3+2]===0)&&c++,(n[r[a+1]*3+2]===s||n[r[a+1]*3+2]===0)&&c++,(n[r[a+2]*3+2]===s||n[r[a+2]*3+2]===0)&&c++,c===3)break}if(r[a+1]===r[a+3]&&r[a+2]===r[a+5]||r[a+0]===r[a+3]&&r[a+2]===r[a+4]){ic.set(n[r[a]*3],n[r[a]*3+1],n[r[a]*3+2]),nd.set(n[r[a+1]*3],n[r[a+1]*3+1],n[r[a+1]*3+2]),id.set(n[r[a+4]*3],n[r[a+4]*3+1],n[r[a+4]*3+2]),sd.set(n[r[a+5]*3],n[r[a+5]*3+1],n[r[a+5]*3+2]),nd.sub(ic).normalize(),id.sub(ic).normalize(),sd.sub(ic).normalize();let c=nd.cross(id).dot(sd);Math.abs(c)>.005||t&&t.some((d,l)=>l%2===1?!1:a>=t[l]&&a<t[l+1])?(o.push(r[a],r[a+1],r[a+2]),i.push(3),a+=3):(o.push(r[a],r[a+1],r[a+4],r[a+5]),i.push(4),a+=6)}else o.push(r[a],r[a+1],r[a+2]),i.push(3),a+=3}if(e.useNgonForTopBottomFaceDuringBake){let c=[],d=[],l=0;for(let u=0,p=0;u<n.length;u+=3,p++)n[u+2]===0&&(c.push(p),l++),n[u+2]===s&&d.push(p);if(e.userData.parameters.extrudeBevelSize===0){let u=d[0];d[0]=d[1],d[1]=u}c.reverse(),o.push(...c,...d),i.push(l,l)}return{indices:o,verticesPerFace:i}}var pr={};Yd(pr,{calcBoolean:()=>iT,calcBooleanTopological:()=>nT,freeMeshSet:()=>cT,getMeshSet:()=>sT,hasOpenEdges:()=>aT,transformMeshSet:()=>lT});var rT,Qy=new Promise(n=>{rT=n});var ta=require("three");var _e,Bi;Qy.then(n=>_e=n);function oT(n,r,e){let t,o;n.userData.parameters.type==="TorusGeometry"&&n.userData.parameters.arc===Math.PI*2?o=n.getClosedTorusIndicesForBooleanOrSubdiv():o=n.getIndex();let{positions:i,triIndices:s}=ad(n.getAttribute("position"),o),a;if(r&&e){let{indices:c,verticesPerFace:d}=ld(i,s,n);a=d.length,t=[];for(let l=0,u=0;l<a;l++){t.push(d[l]);for(let p=0;p<d[l];p++)t.push(c[u++])}}else{let c=s.length;t=Array(c+c/3),a=0;for(let d=0,l=0;l<t.length;)t[l++]=3,a++,t[l++]=s[d++],t[l++]=s[d++],t[l++]=s[d++]}return{positions:i,faceIndices:t,nFaces:a}}function Jy(n){let r=n.length,e=r*Uint32Array.BYTES_PER_ELEMENT,t=r*Float32Array.BYTES_PER_ELEMENT,o=Number.isInteger(n[0])?e:t,i=_e._malloc(o);return(Number.isInteger(n[0])?new Uint32Array(_e.HEAPU32.buffer,i,r):new Float32Array(_e.HEAPF32.buffer,i,r)).set(n,0),i}function eg(n){switch(n){case 0:return _e.OP.UNION;case 1:return _e.OP.INTERSECTION;case 2:return _e.OP.A_MINUS_B;case 3:return _e.OP.B_MINUS_A;case 4:return _e.OP.SYMMETRIC_DIFFERENCE;case 5:return _e.OP.ALL;default:throw new Error("Unknown boolean operation "+n)}}function nT(n,r){Bi===void 0&&(Bi=_e.init_csg());let e=Jy(n),t=_e.csg_calc_topological(Bi,e,n.length,eg(r));_e._free(e);let o=6,i=_e.HEAPU32.subarray(t>>2,(t>>2)+o),s=i.subarray(3,3+3),a=0,c=_e.HEAPU32[i[a]>>2],d=new Float32Array(_e.HEAPF32.subarray(c>>2,(c>>2)+s[a]));a++;let l=_e.HEAPU32[i[a]>>2],u=new Uint32Array(_e.HEAPU32.subarray(l>>2,(l>>2)+s[a]));a++;let p=_e.HEAPU32[i[a]>>2],f=new Uint8Array(_e.HEAPU32.subarray(p>>2,(p>>2)+s[a]));return _e.free_mesh_data(t),{positions:d,indices:u,verticesPerFace:f}}function iT(n,r,e,t){Bi===void 0&&(Bi=_e.init_csg());let o=Jy(n),i=_e.csg_calc(Bi,o,n.length,t,eg(r));_e._free(o);let s=5,a=_e.HEAPU32.subarray(i>>2,(i>>2)+s),c=a.subarray(2,2+3),d=0,l=_e.HEAPU32[a[d]>>2],u=_e.HEAPF32.subarray(l>>2,(l>>2)+c[d]);d++;let p=_e.HEAPU32[a[d]>>2],f=_e.HEAPF32.subarray(p>>2,(p>>2)+c[d]);d++;let m=c[d];e.setAttribute("position",new ta.Float32BufferAttribute(u,3)),e.setAttribute("normal",new ta.Float32BufferAttribute(f,3));let h=_e.HEAPF32.subarray((i>>2)+5,(i>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new ta.Sphere),e.boundingSphere.center.set(h[0],h[1],h[2]),e.boundingSphere.radius=(h[3]**2+h[4]**2+h[5]**2)**.5,e.userData.parameters={width:h[3]*2,height:h[4]*2,depth:h[5]*2},_e.free_mesh_data(i),m}function sT(n,r,e){if(_e===void 0)return-1;let t,o,i;if(r&&n.userData.positions!==void 0){let y=n.userData;i=y.verticesPerFace.length,t=y.positions,o=Array(y.verticesPerFace.reduce((g,x)=>g+x,0)+i);for(let g=0,x=0,S=0;g<y.verticesPerFace.length;g++){o[S++]=y.verticesPerFace[g];for(let w=0;w<y.verticesPerFace[g];w++)o[S++]=y.indices[x++]}}else({positions:t,faceIndices:o,nFaces:i}=oT(n,r,e));let s=t.length,a=o.length,c=t.length,d=o.length,l=c*Float32Array.BYTES_PER_ELEMENT+d*Uint32Array.BYTES_PER_ELEMENT,u=c*Float32Array.BYTES_PER_ELEMENT,p=d*Uint32Array.BYTES_PER_ELEMENT,f=_e._malloc(l),m=new Float32Array(_e.HEAPF32.buffer,f,c),h=new Uint32Array(_e.HEAPU32.buffer,f+u,d);return m.set(t,0),h.set(o,0),_e.get_csg_mesh(f,s,f+u,a,i)}function aT(n){return _e.has_open_edges(n)}function lT(n,r){_e.transform_csg_mesh(n,r.elements)}function cT(n){_e.free_csg_mesh(n)}var uT={ConeGeometry:Fh,CubeGeometry:kh,CylinderGeometry:zh,DodecahedronGeometry:Hh,EllipseGeometry:Ni,HelixGeometry:vy,IcosahedronGeometry:Sy,LatheGeometry:wy,NonParametricGeometry:Oy,PolygonGeometry:ec,PyramidGeometry:Ay,RectangleGeometry:tc,SphereGeometry:Ny,PlaneGeometry:My,BackdropGeometry:Ey,StarGeometry:rc,TextFrameGeometry:Dy,TorusGeometry:By,TorusKnotGeometry:Gy,TriangleGeometry:Vy,PathGeometry:jy,VectorGeometry:Kt},od=n=>uT[n.type].create(n);function ra(n){return n!==null&&"booleanOp"in n}var Ri=class extends bi(sc.Mesh){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new sc.Matrix4}updateVisible(){super.updateVisible(),this.visible=!ra(this.parent)&&this.visible,ra(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(pr.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),ra(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof Ri&&(e.freeBooleanPointer(),ra(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e){let t=super.updateTransformState(e);return t&&ra(this.parent)&&this.invalidateDownstreamBooleanData(!0),t}};var ac=new Gi.Box3;function oa(n,r=0,e=n.count,t,o){let i=1/0,s=1/0,a=1/0,c=-1/0,d=-1/0,l=-1/0;for(let u=r;u<e;u++){let p=n.getX(u),f=n.getY(u),m=n.getZ(u);p<i&&(i=p),f<s&&(s=f),m<a&&(a=m),p>c&&(c=p),f>d&&(d=f),m>l&&(l=m)}ac.min.set(i,s,a),ac.max.set(c,d,l),ac.getCenter(t),ac.getSize(o).multiplyScalar(.5)}var dT=new Gi.BufferGeometry,pT=new Gi.MeshBasicMaterial,Mt=class extends Ri{constructor(r,e){super(dT,pT),this.super_Entity(r,e)}updateState(r,e){this.updateState_Entity(r,e)}updateEntityBoxSize(r,e){let t=this.geometry.getAttribute("position");t!==void 0?oa(t,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:t.count,r,e):super.updateEntityBoxSize(r,e)}};var bo=require("three");var cr=require("three");var Pg=require("three");var Nr=require("three");var na=class{constructor(r){r=r??{},this.name=r.name,this.type=r.type,this.node=r.node,this.size=r.size,this.needsUpdate=r.needsUpdate}get value(){return this.node.value}set value(r){this.node.value=r}};var tg=require("three"),_t=class{constructor(r){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=tg.MathUtils.generateUUID(),this.type=r,this.name=""}analyze(r,e){e=e??{},r.analyzing=!0,this.build(r.addFlow(e.slot,e.cache,e.context),"v4"),r.clearVertexNodeCode(),r.clearFragmentNodeCode(),r.removeFlow(),r.analyzing=!1}analyzeAndFlow(r,e,t){return t=t??{},this.analyze(r,t),this.flow(r,e,t)}flow(r,e,t){t=t??{},r.addFlow(t.slot,t.cache,t.context);let o={result:this.build(r,e),code:r.clearNodeCode(),extra:r.context.extra};return r.removeFlow(),o}build(r,e,t){e=e??this.getType(r,e);let o=r.getNodeData(t??this);return r.analyzing&&this.appendDepsNode(r,o,e),r.nodes.indexOf(this)===-1&&r.nodes.push(this),this.updateFrame!==void 0&&r.updaters.indexOf(this)===-1&&r.updaters.push(this),this.generate(r,e,t)}updateFrame(r){}generateReadonly(r,e,t,o,i,s){return""}generate(r,e,t,o,i){return""}parse(r,e,t,o){}appendDepsNode(r,e,t){e.deps=(e.deps||0)+1;let o=r.getTypeLength(t);(o>(e.outputMax||0)||this.getType(r,t))&&(e.outputMax=o,e.output=t)}setName(r){this.name=r}getName(){return this.name}getType(r,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}getHash(){let r="{",e,t;for(e in this)t=this[e],t instanceof _t&&(r+='"'+e+'":'+t.getHash()+",");if(this.hashProperties)for(let o=0;o<this.hashProperties.length;o++)e=this.hashProperties[o],t=this[e],r+='"'+e+'":"'+String(t)+'",';return r+='"id":"'+this.uuid+'"}',r}};var cd=class{constructor(){this.nodes={};this.keywords={}}add(r){this.nodes[r.name]=r}addKeyword(r,e,t){t=t!==void 0?t:!0,this.keywords[r]={callback:e,cache:t}}remove(r){delete this.nodes[r.name]}removeKeyword(r){delete this.keywords[r]}get(r){return this.nodes[r]}getKeyword(r,e){return this.keywords[r].callback(e)}getKeywordData(r){return this.keywords[r]}contains(r){return this.nodes[r]!==void 0}containsKeyword(r){return this.keywords[r]!==void 0}},ht=new cd;var ud=require("three");var rg=require("three"),ae=class extends _t{constructor(e,t){super(e);this.scope="";t=t??{},this.shared=t.shared!==void 0?t.shared:!0,this.unique=t.unique!==void 0?t.unique:!1}build(e,t,o,i){if(t=t??this.getType(e),this.getShared(e,t)){let s=this.getUnique(e,t);s&&this.uuid===void 0&&(this.uuid=rg.MathUtils.generateUUID()),o=e.getUUID(o??this.getUUID(),!s);let a=e.getNodeData(o),c=a.output||this.getType(e);if(e.analyzing)return(a.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,a,t),this.generate(e,t,o)):super.build(e,t,o);if(s)return a.name=a.name||super.build(e,t,o),a.name;if(!this.getLabel()&&(!this.getShared(e,c)||e.context.ignoreCache||a.deps===1))return super.build(e,t,o);o=this.getUUID(!1);let d=this.getTemp(e,o);if(d)return e.format(d,c,t);{d=super.generate(e,t,o,a.output,i);let l=this.generate(e,c,o);return e.addNodeCode(d+" = "+l+";"),e.format(d,c,t)}}return super.build(e,t,o)}getShared(e,t){return t!=="sampler2D"&&t!=="samplerCube"&&this.shared}getUnique(e,t){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let t=this.uuid;return typeof this.scope=="string"&&(t=this.scope+"-"+t),t}getTemp(e,t){t=t||this.uuid;let o=e.getVars()[t];return o?o.name:void 0}generate(e,t,o,i,s){return this.getShared(e,t)||console.error("TempNode is not shared"),o=o??this.uuid,e.getTempVar(o,i??this.getType(e),s,this.getLabel()).name}};var Ve=class extends ae{constructor(e,t){t=t??{},t.shared=t.shared!==void 0?t.shared:!1;super(e,t);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,t,o,i,s,a){o=e.getUUID(o??this.getUUID()),i=i??this.getType(e);let c=e.getNodeData(o);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,t,o,i,s,a):e.isShader("vertex")?(c.vertex||(c.vertex=e.createVertexUniform(i,this,s,a,this.getLabel())),e.format(c.vertex.name,i,t)):(c.fragment||(c.fragment=e.createFragmentUniform(i,this,s,a,this.getLabel())),e.format(c.fragment.name,i,t))}};var et=class extends Ve{constructor(e=0,t){super("v2");this.nodeType="Vector2";this.value=e instanceof ud.Vector2?e:new ud.Vector2(e,t)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,t,o,i,s,a){return e.format("vec2("+this.value.x+", "+this.value.y+")",i,t)}};var dd=require("three");var Et=class extends Ve{constructor(e=0,t,o){super("v3");this.nodeType="Vector3";this.value=e instanceof dd.Vector3?e:new dd.Vector3(e,t,o)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,t,o,i,s,a){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",i,t)}};var og=require("three"),yt=class extends og.Color{constructor(e,t,o,i){super(e,t,o);this.isColorA=!0;this.a=i}setRGBA(e,t,o,i){super.setRGB(e,t,o),this.a=i}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}setStyle(e,t="srgb"){let o;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(o=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let i,s=o[1],a=o[2];switch(s){case"rgb":case"rgba":if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.a=s==="rgba"?parseFloat(i[4]):1,super.setStyle(e,t);break;case"hsl":case"hsla":if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.a=s==="hsla"?parseFloat(i[4]):1,super.setStyle(e,t);break}}return super.setStyle(e,t)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(e){this.r=e}set y(e){this.g=e}set z(e){this.b=e}set w(e){this.a=e}};var Zt=class extends Ve{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof yt?e:new yt(e.r,e.g,e.b,e.a)}generateReadonly(e,t,o,i,s,a){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",i,t)}};var fT=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,ng=/[a-z_0-9]+/gi,H=class extends ae{constructor(e,t,o,i,s){super(s);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=s===void 0,this.isInterface=!1,this.parse(e,t,o,i)}getShared(e,t){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}}getIncludeByName(e){if(this.includes){let t=this.includes.length;for(;t--;)if(this.includes[t].name===e)return this.includes[t]}}generate(e,t,o,i,s){let a,c=0,d=this.src;if(this.includes)for(let u=0;u<this.includes.length;u++)e.include(this.includes[u],this);for(let u in this.extensions)e.extensions[u]=!0;let l=[];for(;a=ng.exec(this.src);)l.push(a);for(let u=0;u<l.length;u++){let p=l[u],f=p[0],m=this.isMethod?!this.getInputByName(f):!0,h=f;if(this.keywords[f]||this.useKeywords&&m&&ht.containsKeyword(f)){let y=this.keywords[f];if(!y){let g=ht.getKeywordData(f);g.cache&&(y=e.keywords[f]),y=y||ht.getKeyword(f,e),g.cache&&(e.keywords[f]=y)}h=y.build(e)}f!==h&&d[p.index+c-1]!=="."&&(d=d.substring(0,p.index+c)+h+d.substring(p.index+f.length+c),c+=h.length-f.length),this.getIncludeByName(h)===void 0&&ht.contains(h)&&e.include(ht.get(h))}return t==="source"?d:this.isMethod?(this.isInterface||e.include(this,void 0,d),this.name):e.format("( "+d+" )",this.getType(e),t)}parse(e,t,o,i){if(this.src=e||"",this.includes=t??[],this.extensions=o??{},this.keywords=i??{},this.isMethod){let s=fT.exec(this.src);if(this.inputs=[],s&&s.length==4){this.type=s[1],this.name=s[2];let a=s[3].match(ng);if(a){let c=0;for(;c<a.length;){let d=a[c++],l;d==="in"||d==="out"||d==="inout"?l=a[c++]:(l=d,d="");let u=a[c++];this.inputs.push({name:u,type:l,qualifier:d})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var mT=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,pd=class extends ae{constructor(e="",t){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||pd.PI,void 0,void 0,void 0,t)}getType(e){return e.getTypeByFormat(this.type)}parse(e,t,o,i,s){this.src=e||"";let a,c,d="",l=mT.exec(e);this.useDefine=s??this.src.charAt(0)==="#",l&&l.length>1?(c=l[1],a=l[2],d=l[3]):(a=this.src,c="f"),this.name=a,this.type=c,this.value=d}build(e,t){if(t==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),t)}generate(e,t,o,i,s){return e.format(this.name,this.getType(e),t)}},Ie=pd;Ie.PI="PI",Ie.PI2="PI2",Ie.RECIPROCAL_PI="RECIPROCAL_PI",Ie.RECIPROCAL_PI2="RECIPROCAL_PI2",Ie.LOG2="LOG2",Ie.EPSILON="EPSILON";var hT=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
4
4
  )*?)}`,"gim"),yT=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),Vi=class extends ae{constructor(e=""){super();this.inputs=[];this.src="";this.nodeType="Struct";this.parse(e)}getType(e){return e.getTypeByFormat(this.name)}getInputByName(e){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}generate(e,t,o,i,s){return t==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),t)}parse(e=""){this.src=e,this.inputs=[];let t=hT.exec(e);if(t){let o=t[2],i;for(;i=yT.exec(o);)this.inputs.push({type:i[1],name:i[2]});this.name=t[1]}else this.name="";this.type=this.name}};var zi=class extends ae{constructor(e){super("v2",{shared:!1});this.nodeType="UV";this.index=e??0}generate(e,t){e.requires.uv[this.index]=!0;let o=this.index>0?this.index+1:"",i=e.isShader("vertex")?"uv"+o:"vUv"+o;return e.format(i,this.getType(e),t)}};ht.addKeyword("uv",function(){return new zi});ht.addKeyword("uv2",function(){return new zi(1)});var lc=require("three");var xn=class extends ae{constructor(e,t){super("v4");this.nodeType="ColorSpace";this.input=e,this.method=t??xn.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case lc.LinearEncoding:return["Linear"];case lc.sRGBEncoding:return["sRGB"];default:return[]}}generate(e,t){let o=this.input.build(e,"v4"),i=this.getType(e),s=xn.Nodes[this.method],a=e.include(s);if(a===xn.LINEAR_TO_LINEAR)return e.format(o,i,t);if(s.inputs?.length===2){let c=this.factor.build(e,"f");return e.format(a+"( "+o+", "+c+" )",i,t)}else return e.format(a+"( "+o+" )",i,t)}fromEncoding(e){let t=xn.getEncodingComponents(e);this.method="LinearTo"+t[0],this.factor=t[1]}fromDecoding(e){let t=xn.getEncodingComponents(e);this.method=t[0]+"ToLinear",this.factor=t[1]}},kt=xn;kt.Nodes={LinearToLinear:new H(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
5
5
  `)),sRGBToLinear:new H(["vec4 sRGBToLinear( in vec4 value ) {"," return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );","}"].join(`
6
6
  `)),LinearTosRGB:new H(["vec4 LinearTosRGB( in vec4 value ) {"," return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );","}"].join(`
@@ -2590,4 +2590,4 @@ float vogelShadow(int index, sampler2D shadowMap, vec2 uv, float texelSize, floa
2590
2590
  }
2591
2591
 
2592
2592
  #endif
2593
- `,oO=ys.ShaderChunk.lights_fragment_begin,nO=ys.ShaderChunk.shadowmask_pars_fragment,a0=null,iO=n=>{switch(n){case"low":return 8;case"medium":return 16;case"high":return 32;default:return 16}},l0=(n="medium")=>{if(a0===n)return!1;a0=n;let r=iO(n);ys.ShaderChunk.shadowmap_pars_fragment=rO(r);let e=oO.slice();e=e.replace("getShadow( spotShadowMap[ i ]",`getShadow( UNROLLED_LOOP_INDEX + ${3}, spotShadowMap[ i ]`),e=e.replace("getShadow( directionalShadowMap[ i ]","getShadow( UNROLLED_LOOP_INDEX, directionalShadowMap[ i ]"),ys.ShaderChunk.lights_fragment_begin=e;let t=nO.slice();return t=t.replaceAll("getShadow(","getShadow( UNROLLED_LOOP_INDEX, "),ys.ShaderChunk.shadowmask_pars_fragment=t,!0};var Aa=require("three");var c0=require("three");var gs=class extends to(c0.DirectionalLightHelper){constructor(e,t=15,o=10066329){super(e,t,o);this.object=e;this.added=!1;this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,t){ro(this.object,gs.geometryHelper,e,t)}};var u0=require("three");var xs=class extends to(u0.PointLightHelper){constructor(e,t=15,o=6710886){super(e,t,o);this.object=e;this.name=`PointLightHelper: ${e.uuid}`}raycast(e,t){ro(this.object,xs.geometryHelper,e,t)}};var Lc=require("three");var Ec=class extends to(Lc.SpotLightHelper){constructor(e,t=6710886){super(e,t);this.object=e;this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,t){ro(this.object,Ec.geometryHelper,e,t)}update(){if(this.object!==void 0){let e=Ec._vector,t=this.object.distance?this.object.distance:1e3,o=t*Math.tan(this.object.angle);this.cone.scale.set(o,o,t),e.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(e);let i=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let s=0,a=this.cone.material.length;s<a;s++)this.cone.material[s].color.set(i);else this.cone.material.color.set(i)}}},Oa=Ec;Oa._vector=new Lc.Vector3;function sO(n,r){n.shadow.camera.right=r/2,n.shadow.camera.left=-r/2,n.shadow.camera.top=r/2,n.shadow.camera.bottom=-r/2,n.shadow.needsUpdate=!0}var vs=class extends hs(Aa.DirectionalLight,gs){constructor(r,e,t){super(),this.super_Entity(r,e),this.castShadow=!0,this.shadow.mapSize.width=2048,this.shadow.mapSize.height=2048,this.shadow.normalBias=1,this.layers.enable(3);let i=this.shadow.camera;i.top=1250,i.bottom=-1250,i.right=1250,i.left=-1250,i.near=-1e4,i.far=2500;let s=new Aa.CameraHelper(this.shadow.camera);s.visible=!1,this.gizmos.shadowmap=s}update(){this.shadow.camera.updateProjectionMatrix();for(let r in this.gizmos){let e=this.gizmos[r];e instanceof Aa.CameraHelper&&e.update()}}updateMatrixWorld(r){super.updateMatrixWorld(r),this.objectHelper&&this.objectHelper.update()}updateState(r,e){this.updateState_Light(r,e);let t=r.depth!==void 0&&r.depth!==this.shadow.camera.far||r.size!==void 0&&r.size/2!==this.shadow.camera.right;r.size!==void 0&&sO(this,r.size),r.shadowRadius!==void 0&&(this.shadow.radius=r.shadowRadius),r.shadowResolution!==void 0&&(this.shadow.mapSize.set(r.shadowResolution,r.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),r.penumbraSize!==void 0&&e.scene.markPenumbraSizeDirty(),t&&this.update()}};var m0=require("three");var xr=require("three");var d0=new xr.Vector3,p0=new xr.Vector3,f0=new xr.Quaternion,bs=class extends hs(xr.SpotLight,Oa){constructor(r,e,t){super(),this.super_Entity(r,e),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let i=this.shadow.camera;i.fov=xr.MathUtils.RAD2DEG*2*this.angle,i.aspect=1,i.near=100,i.far=2500;let s=new xr.CameraHelper(this.shadow.camera);s.visible=!1,this.gizmos.shadowmap=s,this.update()}update(){this.shadow.camera.updateProjectionMatrix();for(let r in this.gizmos){let e=this.gizmos[r];e instanceof xr.CameraHelper&&e.update()}}updateMatrixWorld(r){super.updateMatrixWorld(r),p0.setFromMatrixPosition(this.matrixWorld),f0.setFromRotationMatrix(this.matrixWorld),d0.copy(this.up).applyQuaternion(f0).negate().multiplyScalar(this.distance),this.target.position.copy(p0).add(d0),this.target.updateMatrixWorld(),this.objectHelper&&this.objectHelper.update()}updateState(r,e){this.updateState_Light(r,e),r.distance!==void 0&&(this.distance=r.distance),r.decay!==void 0&&(this.decay=r.decay),r.angle!==void 0&&(this.angle=r.angle),r.penumbra!==void 0&&(this.penumbra=r.penumbra),r.shadowRadius!==void 0&&(this.shadow.radius=r.shadowRadius),r.penumbraSize!==void 0&&e.scene.markPenumbraSizeDirty(),r.shadowResolution!==void 0&&(this.shadow.mapSize.set(r.shadowResolution,r.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};var Jo=class extends bi(m0.Scene){constructor(e,t){super();this.data=t;this.bgColor=new yt(1,1,1,1);this.fog=null;this.backupFog=new Ss.Fog(16777215,.1,2e3);this.fogUseBGColor=!1;this.isActive=!1;this.aoColor=new Ss.Color;this.penumbraSizeArrayCache=null;this.super_Entity(e,t),this.personalCamera=new wo(Do,{...cn.defaultData,...t.camera,name:"Personal Camera"}),this.personalCamera.objectHelper.visible=!1,this.add(this.personalCamera),this.activeCamera=this.personalCamera,this.ambientLight=new Ss.HemisphereLight(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.ambientLight.removeFromParent(),this.add(this.ambientLight)}get scene(){return this.parent}get postprocessing(){return this.data.postprocessing}updateVisible(){}setBackgroundColor(e){this.bgColor=e,this.fogUseBGColor===!0&&(this.backupFog.color=e)}updateAmbientLight(e,t){e.color!==void 0&&(this.ambientLight.color=Dt(e.color,t)),e.intensity!==void 0&&(this.ambientLight.intensity=e.intensity),e.enabled!==void 0&&(e.enabled?this.add(this.ambientLight):this.remove(this.ambientLight))}onDeactive(){this.isActive=!1}onActive(e){this.isActive=!0,e.fog=this.fog,this.updateShadow(this.data.shadow)}forceMaterialsUpdate(){this.traverseEntity(e=>{if(e instanceof er)if(Array.isArray(e.material))for(let t of e.material)t.needsUpdate=!0;else e.material.needsUpdate=!0,e.material.dispose()})}updateShadow(e){e.softShadowQuality!==void 0&&this.isActive&&l0(e.softShadowQuality)&&this.forceMaterialsUpdate()}updateFog(e,t){if(e.enabled?this.fog=this.backupFog:this.fog=null,this.isActive){let o=this.scene;o.fog=this.fog}this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=Dt(e.color,t),this.backupFog.near=e.near,this.backupFog.far=e.far}updateAo(e,t){e.aoColor!==void 0&&(this.aoColor=Dt(e.aoColor,t))}updateByOp(e,t,o,i){super.updateByOp(e,t,o,i);let s=t;Rt(e.path,["fog"])?this.updateFog(s.fog,o.shared):Rt(e.path,["ao"])?this.updateAo(s.ao,o.shared):Rt(e.path,["ambient"])?this.updateAmbientLight(s.ambient,o.shared):Rt(e.path,["shadow"])&&this.updateShadow(s.shadow)}updateState(e,t){this.updateState_Entity(e,t),e.backgroundColor!==void 0&&this.setBackgroundColor(Dt(e.backgroundColor,t.shared)),e.fog!==void 0&&this.updateFog(e.fog,t.shared),e.ambient!==void 0&&this.updateAmbientLight(e.ambient,t.shared),e.ao!==void 0&&this.updateAo(e.ao,t.shared),e.shadow!==void 0&&this.updateShadow(e.shadow)}raycast(e,t){super.raycast(e,t)}switchActiveCamera(e){e&&e.isDescendantOf(this)&&(this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=e,e.objectHelper.visible=!1)}get playCamera(){return this.scene?.find(this.data.publish.playCamera)??this.personalCamera}switchToPlayCamera(){this.switchActiveCamera(this.playCamera)}get penumbraSizeArray(){return this.penumbraSizeArrayCache===null&&this.updatePenumbraSizeArray(),this.penumbraSizeArrayCache}updatePenumbraSizeArray(){this.penumbraSizeArrayCache=new Array(5).fill(.5);let e=0,t=0;this.traverseEntity(o=>{if(!o.visible)return!0;o instanceof vs&&o.visible&&e<3&&(this.penumbraSizeArrayCache[e]=o.data.penumbraSize,e+=1),o instanceof bs&&o.visible&&e<5-3&&(this.penumbraSizeArrayCache[3+t]=o.data.penumbraSize,t+=1)})}raycastWithClones(e){let t=[],o=i=>{for(let s of i.children){let a=s.cloner;Ne.is(s)&&(s.visible||a?.object.data.visible)&&((Qo(s)||Pa(s)&&this.scene.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,t),Na(s,e,t,!0)),o(s))}};return o(this),t}};var tr=require("three");var Dc=class extends hs(tr.PointLight,xs){constructor(r,e,t){super(),this.super_Entity(r,e),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let i=this.shadow.camera;i.fov=90,i.aspect=1,i.near=100,i.far=2500;let s=new tr.Vector3(-i.far+this.position.x,-i.far+this.position.y,-i.far+this.position.z),a=new tr.Vector3(i.far+this.position.x,i.far+this.position.y,i.far+this.position.z),c=new tr.Box3(s,a),d=new tr.Box3Helper(c,new tr.Color(16755200));d.visible=!1,this.gizmos.shadowmap=d,this.update()}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this.gizmos))for(let r in this.gizmos){let e=this.gizmos[r];if(e instanceof tr.Box3Helper){let t=this.shadow.camera,o=new tr.Vector3(-t.far+this.position.x,-t.far+this.position.y,-t.far+this.position.z),i=new tr.Vector3(t.far+this.position.x,t.far+this.position.y,t.far+this.position.z);e.box.set(o,i),e.updateMatrixWorld(!0)}}}updateMatrixWorld(r){super.updateMatrixWorld(r),this.objectHelper&&this.objectHelper.update()}updateState(r,e){this.updateState_Light(r,e),r.distance!==void 0&&(this.distance=r.distance),r.decay!==void 0&&(this.decay=r.decay),r.shadowRadius!==void 0&&(this.shadow.radius=r.shadowRadius),r.shadowResolution!==void 0&&(this.shadow.mapSize.set(r.shadowResolution,r.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};var Bc=class extends dt{get forceComputeSize(){return!0}get shape(){return this.geometry.userData.shape}updateEntityBoxSize(r,e){let t=this.geometry.getAttribute("position");t!==void 0?oa(t,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:t.count,r,e):super.updateEntityBoxSize(r,e)}};var ws=class extends dt{constructor(e,t,o){super(e,t,o);this._shapeId=null;this._context=o}updateState(e,t){super.updateState(e,t),this.updateShape()}updateShape(){let e=this.data.geometry.extrusion.shape,t;if(e.type==="Custom"){let i=e.shapeId;if(i!==this._shapeId&&this.detachShape(),i){this._shapeId=i;let s=this._context.scene.find(i);s?.data&&(s.attachedPaths.add(this),t=s.geometry.userData?.shape),t||this._context.scene.addPendingCommand(()=>this.updateShape())}}else{let i;switch(e.type){case"Rectangle":i=tc;break;case"Ellipse":i=Ni;break;case"Polygon":i=ec;break;case"Star":i=rc;break;default:throw new Error(`Unknown shape type: ${e.type}`)}t=i.create({parameters:e}).userData.shape}let o=this.geometry;t&&o.inputs&&(o.inputs.shapeData=t,o.build(),this.attachedSurfaceCloners.forEach(i=>i.update()))}detachShape(){this._shapeId!==null&&this._context.scene.find(this._shapeId)?.attachedPaths.delete(this)}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.updateShape(),this.refreshAttachedPaths(e)}updateTransformState(e){return super.updateTransformState(e)}updateGeometryInteractions(e,t){super.updateGeometryInteractions(e,t),this.updateShape()}updateEntityBoxSize(e,t){let o=this.geometry.getAttribute("position");o!==void 0?oa(o,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:o.count,e,t):super.updateEntityBoxSize(e,t)}};var _s=require("three");var _o=class extends oo(_s.Group,no){constructor(e,t,o){super();t.type==="Instance"&&typeof e=="string"&&(t=this.transformAssignData(t,o)),this.super_Entity(e,t),this.objectHelper.update()}get isComponentRoot(){return this.data.type==="Component"&&typeof this.identity=="string"}get isInstanceRoot(){return this.data.type==="Instance"&&typeof this.identity=="string"}transformAssignData(e,t){let o=t.scene.data.objects.get(e.component);if(o){let i,s;for(let a of Ur.rootOverrideProps)e[a]===void 0?(i===void 0&&(i={...e}),i[a]=o.data[a]):(s===void 0&&(s={}),s[a]=e[a],i===void 0&&(i={...e}),i[a]=Gr.apply(o.data[a],e[a]));return this.overrideData=s,i}else return{...It.defaultData,...e,...Sr(It.defaultData,Ur.rootOverrideProps)}}updateByOp(e,t,o,i){let s;if(this.isInstanceRoot&&!i){if(t=this.transformAssignData(t,o),e.type===0&&e.path.length===0&&this.component)for(let a of Ur.rootOverrideProps)a in e.props&&e.props[a]===void 0&&(s===void 0&&(s={...e,props:{...e.props}}),s.props[a]=this.component.data[a]);else if(e.type===0&&e.path.length>0&&Ur.rootOverrideProps.includes(e.path[0])){let a=e.path[0];s===void 0&&(s={...e,path:[],props:{[a]:t[a]}})}}super.updateByOp(s??e,t,o,i)}updateState(e,t){this.updateState_Entity(e,t)}expandInstanceChildren(e){let t=this.data;if(this.component===void 0){let o=e.scene.find(t.component)??null,i=!1;if(o!==this.oldComponent){if(this.oldComponent){let s=0;for(let a of this.children)if(Ne.is(a))e.scene.disposeAndUnregisterEntityRecursivelyIfNotReregistered(a),Rc(a),s+=1;else break;this.children.splice(0,s)}i=!0}if(o){let s={};y0(e,[this.uuid],t.overrides,this,o,o,0,i,s);for(let a of this.children)if(Ne.is(a)){let c=a.data;c.type==="Empty"&&c.animations&&a.traverseEntity(d=>{if(d instanceof dt&&d.isSkinnedMesh){let l=d.dataPatched;if(l.bones&&l.boneInverses){let u=l.bones.map(m=>e.scene.find(s[m])),p=l.boneInverses.map(m=>new _s.Matrix4().fromArray(m)),f=new _s.Skeleton(u,p);d.bind(f,d.bindMatrix)}}else d.matrixAutoUpdate=!0})}}this.oldComponent=this.component}}};function Rc(n){if(n.component){let r=n.component.instances.indexOf(n);r>=0&&n.component.instances.splice(r,1);for(let e of n.children)Ne.is(e)&&Rc(e)}}function h0(n,r,e,t){return n.component===r&&Ns(n.identity,t)?n.overrideData===e?2:1:0}function y0(n,r,e,t,o,i,s,a,c){if(s>50)return!1;if(t.component!==o){if(t.component){let l=t.component.instances.indexOf(t);l>=0&&t.component.instances.splice(l,1)}o.instances.push(t),t.component=o}o instanceof _o&&o.isInstanceRoot&&o.expandInstanceChildren(n);let d=0;for(let l of o.children)if(Ne.is(l)){let u=[...r,...typeof l.identity=="string"?[l.identity]:l.identity],p=fi.resolve(e,u,1);if(p!=null&&!(p instanceof He)){if(Object.setPrototypeOf(p,He.prototype),!1)debugger;console.error("wrong prototype")}let f=null,m;if(!a){let h=t.children[d];if(f=Ne.is(h)?h:null,f!==null){let y=h0(f,l,p,u);m=y>=1?f.stateSelection:void 0,y!==2&&(f=null)}if(f===null&&(f=n.scene.findInstance(u)??null,f!==null)){let y=h0(f,l,p,u);if(m=y>=1?f.stateSelection:void 0,y!==2)f=null;else{let g=f.parent.children.indexOf(f);f.parent.children.splice(g,1),t.children.splice(d,0,f),f.parent===t?(g<=d&&console.error("not possible"),void 0):(f.parent=t,f.matrixWorldNeedsUpdate=!0,f.resetBBoxNeedsUpdate(),f.updateVisible(),n.pendingDeletes.delete(f),void 0)}}}if(f===null){let h=p?Gr.apply(l.data,p):l.data;wr.is(h.type)&&(h={...h,type:"Empty"}),f=Pr.createEntity(u,h,n),f.overrideData=p,t.add(f),t.children.splice(t.children.length-1,1),t.children.splice(d,0,f),f.updateState(f.data,n),m&&f.changeSelectedState(m,n),n.scene.registerInstanceAndSetUuid(f)}if(f.isBone){let h=f.identity[f.identity.length-1];c[h]=f.uuid}d+=1,y0(n,r,e,f,l,i,s+1,a,c)}if(!a){let l=d;for(;;){let u=t.children[d];if(Ne.is(u))n.pendingDeletes.add(u);else break;d+=1}t.children.splice(l,d-l)}return!0}var g0=require("three");var Gc=class extends oo(g0.Bone,no){constructor(r,e){super(),this.super_Entity(r,e),this.objectHelper.update(),this.matrixAutoUpdate=!0}updateState(r,e){this.updateState_Entity(r,e)}};function aO(n,r,e){let t;return r.geometry.type==="TextGeometry"?new cs(n,r,e):(r.geometry.type==="SubdivGeometry"?t=new Cn(n,r,e):r.geometry.type==="PathGeometry"?t=new ws(n,r,e):r.geometry.type==="VectorGeometry"?t=new Bc(n,r,e):r.geometry.type==="BooleanGeometry"?t=new gr(n,r,e):t=new dt(n,r,e),t)}function Vc(n,r,e){return r.type==="Mesh"?aO(n,r,e):r.type==="Empty"?new Ta(n,r):r.type==="Bone"?new Gc(n,r):r.type==="Page"?new Jo(n,r):r.type==="PointLight"?new Dc(n,r,e):r.type==="SpotLight"?new bs(n,r,e):r.type==="DirectionalLight"?new vs(n,r,e):r.type==="Component"||r.type==="Instance"?new _o(n,r,e):wr.is(r.type)?new wo(n,r):(console.error(r),new Ta(n,r))}Pr.createEntity=Vc;function lO(n,r,e){let t=Vc(n.identity,r,e),o=n.children,i=n.attachedPaths,s=n.parent,a=n.component,c=n.instances,d=n.overrideData,l=n.uuid,u=n.stateSelection;n.dispose();for(let p of Object.keys(n))delete n[p];Object.setPrototypeOf(n,Object.getPrototypeOf(t));for(let p of Object.keys(t))n[p]=t[p];n.children=[...n.children,...o],n.attachedPaths=i,n.parent=s,n.component=a,n.instances=c,n.uuid=l,n.overrideData=d,n.updateState(n.data,e),u&&n.changeSelectedState(u,e),n.resetBBoxNeedsUpdate()}Pr.changeEntityProptotype=lO;Pr.Cloner=ps;function x0(n,r,e,t){n.updateByOp(r,e,t,!1)}var Ps=require("three");function v0(n,r){let e=!1,t=r.getLayersOfType("transmission"),o=r.getLayersOfType("outline");return o.length>0&&(n.layers.set(8),t.length>0&&n.layers.enable(3),e=!0,as(n),ss(n)),t.length===0&&o.length===0&&n.layers.set(0),n instanceof er&&n.needsAO&&n.layers.enable(5),e}function b0(n,r){if(!r.layers)return!1;let e=!1,t=r.getLayersOfType("transmission").filter(i=>i.data.visible),o=r.getLayersOfType("outline").filter(i=>i.data.visible);return t.length>0&&(n.layers.set(3),o.length>0&&n.layers.enable(8),e=!0),t.length===0&&o.length===0&&n.layers.set(0),n.needsAO&&n.layers.enable(5),e}function S0(n){let r=!1;return n.traverseEntity(e=>{if(e instanceof er)if(Array.isArray(e.material))for(let t=0;t<e.material.length;t++)v0(e,e.material[t])&&(r=!0);else v0(e,e.material)&&(r=!0)}),r}function w0(n){let r=!1;return n.traverseEntity(e=>{if(e instanceof er)if(Array.isArray(e.material))for(let t=0;t<e.material.length;t++)b0(e,e.material[t])&&(r=!0);else b0(e,e.material)&&(r=!0)}),r}var dO=new Ps.Raycaster,pO=new Ps.Matrix4,fO=new Ps.Ray;function Na(n,r,e,t=!1){let o=n.cloner;if(o)for(let i of o.children){let s=pO.copy(i.matrixWorld).invert(),a=fO.copy(r.ray).applyMatrix4(s),c=n.matrixWorld;a.applyMatrix4(c);let d=dO;d.set(a.origin,a.direction),d.near=r.near,d.far=r.far;let l=d.intersectObject(n,!1);l.length>0&&e.push({...l[0],object:t?i:n})}}var zc=class{constructor(){this._constraints=new Map}setConstraint(r,e){e===null?this._constraints.delete(r):this._constraints.set(r,e)}removeDependencies(r){this._constraints.delete(r)}applyConstraints(r){let e=new Set;this._constraints.forEach((t,o)=>{let i=[o,t],s=t;for(;this._constraints.has(s);)s=this._constraints.get(s),e.has(s)||i.push(s);for(let a=i.length-2;a>=0;a--)if(!e.has(i[a])){let c=r.find(i[a]);c?c.applyPathSnapping(r):console.warn(`missing entity ${i[a]}`),e.add(i[a])}})}findDependency(r,e){let t=r;for(;this._constraints.has(t);)if(t=this._constraints.get(t),t===e)return!0;return!1}};var mO=new vr.MeshBasicMaterial;mO.wireframe=!0;var _0=new vr.Vector3,jc=class extends vr.Scene{constructor(e,t){super();this.data=e;this.enableHelpers=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this.needsNormalDirty=!0;this._needsTransmission=!1;this._needsNormal=!1;this.geometryCacheChanged=!1;this.entityByUuid={};this.entityIdentityToEntity={};this.toExpandCloner=new Set;this.toUpdateCloner=new Set;this.pendingCommands=[];this.pathConstraints=new zc;this.errorPage=new Jo("fdasfa",{...fo.defaultData,name:""});this.needsRecomputeInstances=!1;this.init(e,t),this.matrixAutoUpdate=!1}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=w0(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=S0(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let t=e.identity.join("-"),o=this.entityIdentityToEntity[t];o&&(e.uuid=o.uuid),this.entityIdentityToEntity[t]=e,this.entityByUuid[e.uuid]=e}markPenumbraSizeDirty(){for(let e of this.children)e instanceof Jo&&(e.penumbraSizeArrayCache=null)}findInstance(e){return this.entityIdentityToEntity[e.join("-")]}get bgColor(){return this.activePage.bgColor}get postprocessing(){return this.activePage.data.postprocessing}getWithSortKey(e){let t=this.find(e);if(t===void 0)return;let o=[],i=t;for(;i!==this;){let s=i;i=i.parent;let a=i.children.indexOf(s);o.splice(0,0,a)}return{entity:t,sortKey:o}}getAllSorted(e){let t=[];for(let o of e){let i=this.getWithSortKey(o.id);i!==void 0&&t.push(i)}return t.sort((o,i)=>Zd(o.sortKey,i.sortKey)),t.map(o=>o.entity)}nonExistOrDescendantOf(e,t){let o=this.find(e);if(o===void 0)return!0;for(;o;){if(o.uuid===t)return!0;o=o.parent}return!1}find(e){if(this.activePage&&this.activePage.personalCamera.parent){if(e==="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera")return this.activePage.personalCamera;if(e===Do)return this.activePage.personalCamera}if(e===""||e===void 0)return;let t=this.entityByUuid[e];return t===void 0?this.getObjectByProperty("uuid",e):t}debugEnsureEntity(e){let t=this.find(e);if(t){if(Array.isArray(t.identity)&&this.findInstance(t.identity)===void 0){console.error("not found instance");debugger}}else{console.error("not found");debugger}}addPendingExpandCloner(e){this.toExpandCloner.add(e)}addPendingUpdateCloner(e){this.toUpdateCloner.add(e)}markToExpandCloner(e){this.toExpandCloner.add(e),e.traverseEntityAncestors(t=>{this.toExpandCloner.add(t)})}doPendingExpandCloner(){this.toExpandCloner.forEach(e=>{e.expandCloner(this)}),this.toExpandCloner.clear()}doPendingUpdateCloner(){this.toUpdateCloner.forEach(e=>{e.cloner?.update()}),this.toUpdateCloner.clear()}doPendingUpdates(){this.doPendingExpandCloner(),this.doPendingUpdateCloner(),this.applyPendingCommands()}addPendingCommand(e){this.pendingCommands.push(e)}applyPendingCommands(){this.pendingCommands.forEach(e=>e()),this.pendingCommands.length=0}updateTreeByOp(e,t){if(e.path.length===0&&e.type===7){let o=e.parent===null?this:this.find(e.parent);if(o===void 0)throw new Error("unexpected");let i=this.createObject(e.id,e.data,e.children,o,e.localIndex,t);i.updateVisible(),i.resetBBoxNeedsUpdate(),Qo(i)&&_a(i.parent)&&(i.invalidateUpstreamBooleanData(),i.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(o),this.markNeedsRecomputeInstancesForChildren(i),this.markToExpandCloner(i),this.markPenumbraSizeDirty()}else if(e.path.length===0&&e.type===8){let o=this.find(e.id);if(o===void 0)throw new Error("unexpected");this.markToExpandCloner(o),o.resetBBoxNeedsUpdate(),this.unregisterObject(o);let i=o.parent;this.markNeedsRecomputeInstancesForAncessors(i),this.markNeedsRecomputeInstancesForChildren(o),this.markPenumbraSizeDirty(),o.parent.remove(o),_a(o.parent)&&(o.parent.invalidateUpstreamBooleanData(),o.parent.invalidateDownstreamBooleanData().recomputeBoolean()),Qo(o)&&(o.freeBooleanPointer(),i instanceof gr&&i.invalidateDownstreamBooleanData().recomputeBoolean()),o instanceof ws&&o.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(o),this.pathConstraints.removeDependencies(o.uuid)}else if(e.path.length===0&&e.type===9){let o=this.find(e.id);if(o===void 0)throw new Error("unexpected");this.markNeedsRecomputeInstancesForChildren(o);let i=o.parent;this.markNeedsRecomputeInstancesForAncessors(i),o.cloner?.resetOnMove(),this.markToExpandCloner(o);let s=e.parent===null?this:this.find(e.parent);if(s===void 0)throw new Error("unexpected");s.add(o),this.markNeedsRecomputeInstancesForAncessors(s),this.markToExpandCloner(o),o.invalidateClonerTransform(o),o.updateVisible(),o.resetBBoxNeedsUpdate(),this.markPenumbraSizeDirty();let a=e.localIndex;s.children.splice(a,0,s.children.pop()),Qo(o)&&(o.invalidateUpstreamBooleanData(),_a(o.parent)?o.parent.invalidateDownstreamBooleanData().recomputeBoolean():i instanceof gr&&i.invalidateDownstreamBooleanData().recomputeBoolean())}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}get playPage(){return this.find(this.data.publish.playPage)??this.errorPage}updatePage(e){this.activePage&&this.activePage.onDeactive(),this.activePage=this.errorPage;for(let t of this.children)t instanceof Jo&&(t.visible=t.uuid===e,t.visible&&(this.activePage=t,this.activePage.onActive(this)))}updateEntityByOp(e,t,o,i){if(t.type===0){if(("overrides"in t.props||"component"in t.props)&&this.markNeedsRecomputeInstances(),"visible"in t.props&&this.markPenumbraSizeDirty(),t.path.includes("overrides")&&"states"in t.props){let{rest:a}=t.props;t={...t,props:a},this.markNeedsRecomputeInstances()}t.path[0]==="pathSnapping"&&t.props.pathId!==void 0&&this.pathConstraints.setConstraint(e,t.props.pathId)}let s=this.find(e);if(s)try{x0(s,t,o,{scene:this,shared:i}),s instanceof dt&&s.updateGeometryGroupsIfNeeded()}catch(a){console.error(a)}}get activeCamera(){return this.activePage.activeCamera}switchActiveCamera(e){this.activePage.switchActiveCamera(e)}init(e,t){this.createChildrenObjects(e.objects,this,t),this.updatePage(e.publish.playPage),this.activePage.switchToPlayCamera(),this.expandInstances(t,!0),this.traverseEntity(o=>{_a(o)&&o.recomputeBoolean(),o instanceof wo&&o.updateUp()}),this.doPendingExpandCloner(),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(t=>{(t.data.type==="Component"||t.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){Ne.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(t=>{Ne.is(t)&&t.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,t,o,i,s,a,c){if(e){let d=i.find(e);d&&d!==i&&s.forInstancesRec(l=>{l.data=ai(l.data,u=>{let p=u.events.data(c.id),f=l.goUp(a);if(f){let m=[...La(f.identity),e].join("-"),h=this.entityIdentityToEntity[m];if(h){let y=h.uuid,g=Vt.zoom(p,t);g[o]=y}else{if(!1)debugger;console.warn("cannot find instance")}}}).data})}}rewriteActions(e,t,o,i,s,a){e.forEach(c=>{c.data.type==="Transition"?this.relativeizeInner(c.data.object,[...t,c.id],"object",o,i,s,a):c.data.type==="Animation"&&this.relativeizeInner(c.data.object,[...t,c.id],"object",o,i,s,a)})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof _o&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((t,o)=>{t.data.events.forEach(i=>{if(i.data.type==="GameControl"){let s=!1;if(t.forInstancesRec(a=>{a.data=ai(a.data,c=>{a.isInstanceRoot||(c.events.delete(i.id),s=!0)}).data}),s===!1)for(let a of Gl.list)this.rewriteActions(i.data.gameActions[a],["gameActions",a],e,t,o,i)}else i.data.type==="Conditional"?(i.data.condition.type==="Distance"?(this.relativeizeInner(i.data.condition.fromObject,["condition"],"fromObject",e,t,o,i),this.relativeizeInner(i.data.condition.toObject,["condition"],"toObject",e,t,o,i)):i.data.condition.type==="State"?this.relativeizeInner(i.data.condition.object,["condition"],"object",e,t,o,i):i.data.condition.type==="Comparison"&&(i.data.condition.lOperand.type==="Property"&&this.relativeizeInner(i.data.condition.lOperand.value[0],["condition","lOperand","value"],0,e,t,o,i),i.data.condition.rOperand.type==="Property"&&this.relativeizeInner(i.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,t,o,i)),this.rewriteActions(i.data.inActions,["inActions"],e,t,o,i),this.rewriteActions(i.data.outActions,["outActions"],e,t,o,i)):"actions"in i.data&&this.rewriteActions(i.data.actions,["actions"],e,t,o,i)})}),!0})}expandInstances(e,t,o){let i=new Set;this.traverseEntity(s=>{if(s instanceof _o&&s.isInstanceRoot)return s.expandInstanceChildren({scene:this,shared:e,pendingDeletes:i}),t||s.resetBBoxNeedsUpdate(),o&&s.traverseEntity(a=>{o.addClip(a)}),!0});for(let s of i)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(s),Rc(s)}recomputeInstances(e,t){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(o=>{o instanceof _o&&o.isInstanceRoot&&(o.component=void 0)}),this.expandInstances(e,!1,t))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(t=>{let o=typeof t.identity=="string"?t.identity:t.identity.join("-");this.entityIdentityToEntity[o]===t&&(delete this.entityByUuid[t.uuid],delete this.entityIdentityToEntity[o]),t.dispose()})}clearScene(){for(let e of this.children)Ne.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,t){this.init(e,t)}raycast(e){return this.raycast1(e,!1)}raycast1(e,t){let o=[],i=s=>{for(let a of s.children){let c=a.cloner;if(Ne.is(a)&&!a.raycastLock&&(a.visible||c?.object.data.visible))if(t===!0&&a.isInstanceRoot){let d=[];if(e.intersectObject(a,!0,d),d.length){let l=d[0];l.object=a,l.point.applyMatrix4(l.object.matrixWorld);let u=a.matrixWorld.clone().invert();l.point.applyMatrix4(u),o.push(l)}}else(Qo(a)||Pa(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,o),Na(a,e,o)),i(a)}};return i(this),o}raycastWithClones(e){let t=[],o=i=>{for(let s of i.children){let a=s.cloner;Ne.is(s)&&(s.visible||a?.object.data.visible)&&((Qo(s)||Pa(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,t),Na(s,e,t,!0)),o(s))}};return o(this),t}forEachEntity(e){for(let t of this.children)Ne.is(t)&&e(t)}traverseConcreteEntity(e){for(let t of this.children)Ne.is(t)&&t.isConcreteEntity&&t.traverseEntity(e)}traverseEntity(e){for(let t of this.children)Ne.is(t)&&t.traverseEntity(e)}traverseObject(e){for(let t of this.children)yi.is(t)&&t.traverseObject(e)}traverseVisibleEntity(e){for(let t of this.children)Ne.is(t)&&t.visible&&t.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,t,o){let i=0;for(let s of e)this.createObject(s.id,s.data,s.children,t,i,o),i+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let t of e.children)this.unregisterObject(t)}createObject(e,t,o,i,s,a){let c={scene:this,shared:a},d=Vc(e,t,c);return d&&(this.entityByUuid[e]=d,i.add(d),i.children.splice(s,0,i.children.pop()),o.length>0&&(d.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(o,d,a)),d.updateState(t,c),d instanceof dt&&d.updateGeometryGroupsIfNeeded(),d.updateVisible(),d.cloner&&this.toExpandCloner.add(d),t.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,t.pathSnapping.pathId)),t.type==="Empty"&&t.animations&&d.traverseEntity(l=>{if(l instanceof dt&&l.isSkinnedMesh){let u=l.dataPatched;if(u.bones&&u.boneInverses){let p=u.bones.map(h=>this.find(h)),f=u.boneInverses.map(h=>new vr.Matrix4().fromArray(h)),m=new vr.Skeleton(p,f);l.bind(m,l.bindMatrix)}}else l.matrixAutoUpdate=!0}),d}getCenter(e){let t=[];for(let i=0,s=e.length;i<s;++i){let{id:a,recursive:c}=e[i],d=this.find(a),l=c?d.recursiveBBox:d.singleBBox;t.push(...l.vertices)}let o=new vr.Box3;return o.setFromPoints(t),o.getCenter(_0),_0}copyMatrixWorld(e,t){if(e===null){t.identity();return}let o=this.find(e);o?t.copy(o.matrixWorld):t.identity()}copyParentMatrixWorld(e,t){if(e===null){t.identity();return}let o=this.find(e)?.parent;o?t.copy(o.matrixWorld):t.identity()}traverseMaterial(e){this.traverseEntity(t=>{if(t instanceof Mt)if(Array.isArray(t.material))for(let o=0;o<t.material.length;o++)t.material[o]instanceof Jt&&e(t.material[o]);else t.material instanceof Jt&&e(t.material)})}updateViewPlaneSize(e,t,o=!1){this.traverseConcreteEntity(i=>{i instanceof wo&&i.setViewplaneSize(e,t,o)})}};var P0=require("three/examples/jsm/loaders/DRACOLoader.js");var en;function hO(){return en||(en=new P0.DRACOLoader,en.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),en.decoderPending}async function yO(n){if(en){let r={attributeIDs:en.defaultAttributeIDs,attributeTypes:en.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await en.decodeGeometry(new Int8Array(n).buffer,r)}catch(t){console.error(t)}if(e)return{index:e.index?{array:e.index.array}:void 0,attributes:Object.entries(e.attributes).map(([t,o])=>({name:t,itemSize:o.itemSize,array:o.array}))}}return null}async function T0(n,r){let[e,t]=tu(Sl.deserialize(new Uint8Array(n)));Th(e);let o=[];e.scene.objects.traverse((i,s)=>{s.type==="Mesh"&&s.geometry.type==="NonParametricGeometry"&&s.geometry.data.draco!==void 0&&o.push(s)}),o.length&&await hO();for(let i of o){let s=await yO(ut(i.geometry.data.draco));if(s){s.index&&(i.geometry.data.index={array:s.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let a={};s.attributes.forEach(({name:c,array:d,itemSize:l})=>{a[c]={array:d,itemSize:l,type:"Float32Array",normalized:!1}}),i.geometry.data.attributes=a,i.geometry.data.draco=void 0}}return r&&r(e),t.result().data}var gO=require("three"),xO=require("three/examples/jsm/utils/BufferGeometryUtils.js");function O0(n){let r;if(!!n.index)for(let e=0;e<n.index.array.length;e+=3)r=n.index.array[e],n.index.array[e]=n.index.array[e+2],n.index.array[e+2]=r}var Ia=require("three");function A0(n){let r=new Set;return n.traverse(e=>{if(e instanceof er)if(tt(e.material))e.material.forEach(t=>{let o=t;r.has(o)||r.add(o)});else{let t=e.material;r.has(t)||r.add(t)}}),r.forEach(e=>{if(e instanceof Array)return;let t=e.onBeforeCompile.bind(e);if(vO(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new Ia.Color,specularColor:new Ia.Color});let o=0;e.onBeforeCompile=(i,s)=>{t&&t(i,s),i.uniforms=Object.assign({},Ia.ShaderLib.physical.uniforms,i.uniforms),e.getLayersOfType("transmission").forEach(a=>{if(i.uniforms.transmissionSamplerMap.value){let c=a.color;c&&(c.transmissionSamplerMap.value=i.uniforms.transmissionSamplerMap.value,c.transmissionSamplerSize.value=i.uniforms.transmissionSamplerSize.value,c.aspectRatio.value=xg(window.innerWidth,window.innerHeight),e.defines.IS_THREEJS_EXPORT=!0)}else o++,o<2&&(e.needsUpdate=!0)})}}else bO(e)||(e.onBeforeCompile=(o,i)=>{t&&t(o,i),e.transparent=!1})}),n}function vO(n){return n.getLayersOfType("transmission").length>0}function bO(n){let r=0;for(let e of n.layers){if(e.data.type!=="displace"&&e.data.isMask)return!0;if(e.type!=="light"&&e.type!=="fresnel"){let o=e.uniforms["f"+e.id+"_alpha"];o&&(r+=(1-r)*o.value)}}return r<1}function C0(n){return n.traverse(r=>{if(r.type==="Camera"){let e=r;e.type=e.cameraType}}),n}function N0(n){let r=[],e=(t,o=0)=>{let i=o>0?t+o:t;return r.includes(i)?e(t,o+1):i};return n.traverse(t=>{if(r.includes(t.name)){let o=t.name,i=e(t.name);if(t.name=i,t.isMesh){let s=t;s.material instanceof Array?s.material.forEach(a=>{a.name=a.name.replace(o,i)}):s.material.isAsset||(s.material.name=s.material.name.replace(o,i))}}r.push(t.name)}),n}var I0=require("three/examples/jsm/utils/BufferGeometryUtils.js");function M0(n){let r=[];return n.traverse(e=>{e instanceof ps&&r.push(e)}),r.forEach(e=>{let t=e.object,s=[...e.children.map(a=>{a.updateMatrix();let c;if(a.geometry!==void 0)try{c=a.geometry.clone().applyMatrix4(a.matrix)}catch(d){console.error(d)}return c!==void 0&&a.matrix.determinant()<0&&O0(c),c}).filter(a=>a!==void 0)];if(!e.parameters.hideBase&&t instanceof Mt&&s.unshift(t.geometry),s.length){let a=(0,I0.mergeBufferGeometries)(s);t instanceof Mt&&(t.geometry=a)}e.removeFromParent(),t.setFromClonerState(null,{scene:n,shared:Lg})}),n}function E0(n){return n.traverse(r=>{r.matrixAutoUpdate=!0}),n}function L0(n){Object.values(n.shared.materials).forEach(r=>{qd(r)}),n.scene.objects.traverse((r,e)=>{"material"in e?qd(e.material):"materials"in e&&e.materials.forEach(t=>{qd(t)})})}function qd(n){if(typeof n=="string")return;let r=[];n.layers.forEach((e,t)=>{e.type==="outline"&&r.push(t)}),r.reverse().forEach(e=>{n.layers.delete(e)}),r.length&&console.warn("The Spline Loader currently does not support the outline layer.")}var V0=Ts(B0(),1);function R0(n){return n.traverseMaterial(r=>{r.needsJitter=!1}),n}var G0="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",Fc=class extends kc.Loader{load(r,e,t,o=console.error){let i=new kc.FileLoader(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),r.endsWith(".spline")?console.warn(G0+" The .spline files are only meant to be used by the Editor."):r.endsWith(".splinecode")||console.warn(G0),i.load(r,async s=>{try{if(typeof s=="string")throw new Error("The .spline file is not binary!");let a=await this.parse(s);e(a)}catch(a){o(a)}},t,o)}async parse(r){let e=await T0(r,L0);e.version&&(0,V0.default)(e.version,"0.9.439")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/loader to the latest version."),await Promise.all([Vg(e)&&Wy(),Xg(e)&&Mg()].filter(Boolean));let t=new An(e.shared);Object.values(t.getMaterials()).forEach(s=>Object.assign(s,{isAsset:!0}));let o=new jc(e.scene,t),i=o.activeCamera;return i&&Object.assign(i,{makeDefault:!0}),o=M0(o),o=A0(o),o=C0(o),o=N0(o),o=E0(o),o=R0(o),o}};
2593
+ `,oO=ys.ShaderChunk.lights_fragment_begin,nO=ys.ShaderChunk.shadowmask_pars_fragment,a0=null,iO=n=>{switch(n){case"low":return 8;case"medium":return 16;case"high":return 32;default:return 16}},l0=(n="medium")=>{if(a0===n)return!1;a0=n;let r=iO(n);ys.ShaderChunk.shadowmap_pars_fragment=rO(r);let e=oO.slice();e=e.replace("getShadow( spotShadowMap[ i ]",`getShadow( UNROLLED_LOOP_INDEX + ${3}, spotShadowMap[ i ]`),e=e.replace("getShadow( directionalShadowMap[ i ]","getShadow( UNROLLED_LOOP_INDEX, directionalShadowMap[ i ]"),ys.ShaderChunk.lights_fragment_begin=e;let t=nO.slice();return t=t.replaceAll("getShadow(","getShadow( UNROLLED_LOOP_INDEX, "),ys.ShaderChunk.shadowmask_pars_fragment=t,!0};var Aa=require("three");var c0=require("three");var gs=class extends to(c0.DirectionalLightHelper){constructor(e,t=15,o=10066329){super(e,t,o);this.object=e;this.added=!1;this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,t){ro(this.object,gs.geometryHelper,e,t)}};var u0=require("three");var xs=class extends to(u0.PointLightHelper){constructor(e,t=15,o=6710886){super(e,t,o);this.object=e;this.name=`PointLightHelper: ${e.uuid}`}raycast(e,t){ro(this.object,xs.geometryHelper,e,t)}};var Lc=require("three");var Ec=class extends to(Lc.SpotLightHelper){constructor(e,t=6710886){super(e,t);this.object=e;this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,t){ro(this.object,Ec.geometryHelper,e,t)}update(){if(this.object!==void 0){let e=Ec._vector,t=this.object.distance?this.object.distance:1e3,o=t*Math.tan(this.object.angle);this.cone.scale.set(o,o,t),e.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(e);let i=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let s=0,a=this.cone.material.length;s<a;s++)this.cone.material[s].color.set(i);else this.cone.material.color.set(i)}}},Oa=Ec;Oa._vector=new Lc.Vector3;function sO(n,r){n.shadow.camera.right=r/2,n.shadow.camera.left=-r/2,n.shadow.camera.top=r/2,n.shadow.camera.bottom=-r/2,n.shadow.needsUpdate=!0}var vs=class extends hs(Aa.DirectionalLight,gs){constructor(r,e,t){super(),this.super_Entity(r,e),this.castShadow=!0,this.shadow.mapSize.width=2048,this.shadow.mapSize.height=2048,this.shadow.normalBias=1,this.layers.enable(3);let i=this.shadow.camera;i.top=1250,i.bottom=-1250,i.right=1250,i.left=-1250,i.near=-1e4,i.far=2500;let s=new Aa.CameraHelper(this.shadow.camera);s.visible=!1,this.gizmos.shadowmap=s}update(){this.shadow.camera.updateProjectionMatrix();for(let r in this.gizmos){let e=this.gizmos[r];e instanceof Aa.CameraHelper&&e.update()}}updateMatrixWorld(r){super.updateMatrixWorld(r),this.objectHelper&&this.objectHelper.update()}updateState(r,e){this.updateState_Light(r,e);let t=r.depth!==void 0&&r.depth!==this.shadow.camera.far||r.size!==void 0&&r.size/2!==this.shadow.camera.right;r.size!==void 0&&sO(this,r.size),r.shadowRadius!==void 0&&(this.shadow.radius=r.shadowRadius),r.shadowResolution!==void 0&&(this.shadow.mapSize.set(r.shadowResolution,r.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),r.penumbraSize!==void 0&&e.scene.markPenumbraSizeDirty(),t&&this.update()}};var m0=require("three");var xr=require("three");var d0=new xr.Vector3,p0=new xr.Vector3,f0=new xr.Quaternion,bs=class extends hs(xr.SpotLight,Oa){constructor(r,e,t){super(),this.super_Entity(r,e),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let i=this.shadow.camera;i.fov=xr.MathUtils.RAD2DEG*2*this.angle,i.aspect=1,i.near=100,i.far=2500;let s=new xr.CameraHelper(this.shadow.camera);s.visible=!1,this.gizmos.shadowmap=s,this.update()}update(){this.shadow.camera.updateProjectionMatrix();for(let r in this.gizmos){let e=this.gizmos[r];e instanceof xr.CameraHelper&&e.update()}}updateMatrixWorld(r){super.updateMatrixWorld(r),p0.setFromMatrixPosition(this.matrixWorld),f0.setFromRotationMatrix(this.matrixWorld),d0.copy(this.up).applyQuaternion(f0).negate().multiplyScalar(this.distance),this.target.position.copy(p0).add(d0),this.target.updateMatrixWorld(),this.objectHelper&&this.objectHelper.update()}updateState(r,e){this.updateState_Light(r,e),r.distance!==void 0&&(this.distance=r.distance),r.decay!==void 0&&(this.decay=r.decay),r.angle!==void 0&&(this.angle=r.angle),r.penumbra!==void 0&&(this.penumbra=r.penumbra),r.shadowRadius!==void 0&&(this.shadow.radius=r.shadowRadius),r.penumbraSize!==void 0&&e.scene.markPenumbraSizeDirty(),r.shadowResolution!==void 0&&(this.shadow.mapSize.set(r.shadowResolution,r.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};var Jo=class extends bi(m0.Scene){constructor(e,t){super();this.data=t;this.bgColor=new yt(1,1,1,1);this.fog=null;this.backupFog=new Ss.Fog(16777215,.1,2e3);this.fogUseBGColor=!1;this.isActive=!1;this.aoColor=new Ss.Color;this.penumbraSizeArrayCache=null;this.super_Entity(e,t),this.personalCamera=new wo(Do,{...cn.defaultData,...t.camera,name:"Personal Camera"}),this.personalCamera.objectHelper.visible=!1,this.add(this.personalCamera),this.activeCamera=this.personalCamera,this.ambientLight=new Ss.HemisphereLight(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.ambientLight.removeFromParent(),this.add(this.ambientLight)}get scene(){return this.parent}get postprocessing(){return this.data.postprocessing}updateVisible(){}setBackgroundColor(e){this.bgColor=e,this.fogUseBGColor===!0&&(this.backupFog.color=e)}updateAmbientLight(e,t){e.color!==void 0&&(this.ambientLight.color=Dt(e.color,t)),e.intensity!==void 0&&(this.ambientLight.intensity=e.intensity),e.enabled!==void 0&&(e.enabled?this.add(this.ambientLight):this.remove(this.ambientLight))}onDeactive(){this.isActive=!1}onActive(e){this.isActive=!0,e.fog=this.fog,this.updateShadow(this.data.shadow)}forceMaterialsUpdate(){this.traverseEntity(e=>{if(e instanceof er)if(Array.isArray(e.material))for(let t of e.material)t.needsUpdate=!0;else e.material.needsUpdate=!0,e.material.dispose()})}updateShadow(e){e.softShadowQuality!==void 0&&this.isActive&&l0(e.softShadowQuality)&&this.forceMaterialsUpdate()}updateFog(e,t){if(e.enabled?this.fog=this.backupFog:this.fog=null,this.isActive){let o=this.scene;o.fog=this.fog}this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=Dt(e.color,t),this.backupFog.near=e.near,this.backupFog.far=e.far}updateAo(e,t){e.aoColor!==void 0&&(this.aoColor=Dt(e.aoColor,t))}updateByOp(e,t,o,i){super.updateByOp(e,t,o,i);let s=t;Rt(e.path,["fog"])?this.updateFog(s.fog,o.shared):Rt(e.path,["ao"])?this.updateAo(s.ao,o.shared):Rt(e.path,["ambient"])?this.updateAmbientLight(s.ambient,o.shared):Rt(e.path,["shadow"])&&this.updateShadow(s.shadow)}updateState(e,t){this.updateState_Entity(e,t),e.backgroundColor!==void 0&&this.setBackgroundColor(Dt(e.backgroundColor,t.shared)),e.fog!==void 0&&this.updateFog(e.fog,t.shared),e.ambient!==void 0&&this.updateAmbientLight(e.ambient,t.shared),e.ao!==void 0&&this.updateAo(e.ao,t.shared),e.shadow!==void 0&&this.updateShadow(e.shadow)}raycast(e,t){super.raycast(e,t)}switchActiveCamera(e){e&&e.isDescendantOf(this)&&(this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=e,e.objectHelper.visible=!1)}get playCamera(){return this.scene?.find(this.data.publish.playCamera)??this.personalCamera}switchToPlayCamera(){this.switchActiveCamera(this.playCamera)}get penumbraSizeArray(){return this.penumbraSizeArrayCache===null&&this.updatePenumbraSizeArray(),this.penumbraSizeArrayCache}updatePenumbraSizeArray(){this.penumbraSizeArrayCache=new Array(5).fill(.5);let e=0,t=0;this.traverseEntity(o=>{if(!o.visible)return!0;o instanceof vs&&o.visible&&e<3&&(this.penumbraSizeArrayCache[e]=o.data.penumbraSize,e+=1),o instanceof bs&&o.visible&&e<5-3&&(this.penumbraSizeArrayCache[3+t]=o.data.penumbraSize,t+=1)})}raycastWithClones(e){let t=[],o=i=>{for(let s of i.children){let a=s.cloner;Ne.is(s)&&(s.visible||a?.object.data.visible)&&((Qo(s)||Pa(s)&&this.scene.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,t),Na(s,e,t,!0)),o(s))}};return o(this),t}};var tr=require("three");var Dc=class extends hs(tr.PointLight,xs){constructor(r,e,t){super(),this.super_Entity(r,e),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let i=this.shadow.camera;i.fov=90,i.aspect=1,i.near=100,i.far=2500;let s=new tr.Vector3(-i.far+this.position.x,-i.far+this.position.y,-i.far+this.position.z),a=new tr.Vector3(i.far+this.position.x,i.far+this.position.y,i.far+this.position.z),c=new tr.Box3(s,a),d=new tr.Box3Helper(c,new tr.Color(16755200));d.visible=!1,this.gizmos.shadowmap=d,this.update()}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this.gizmos))for(let r in this.gizmos){let e=this.gizmos[r];if(e instanceof tr.Box3Helper){let t=this.shadow.camera,o=new tr.Vector3(-t.far+this.position.x,-t.far+this.position.y,-t.far+this.position.z),i=new tr.Vector3(t.far+this.position.x,t.far+this.position.y,t.far+this.position.z);e.box.set(o,i),e.updateMatrixWorld(!0)}}}updateMatrixWorld(r){super.updateMatrixWorld(r),this.objectHelper&&this.objectHelper.update()}updateState(r,e){this.updateState_Light(r,e),r.distance!==void 0&&(this.distance=r.distance),r.decay!==void 0&&(this.decay=r.decay),r.shadowRadius!==void 0&&(this.shadow.radius=r.shadowRadius),r.shadowResolution!==void 0&&(this.shadow.mapSize.set(r.shadowResolution,r.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};var Bc=class extends dt{get forceComputeSize(){return!0}get shape(){return this.geometry.userData.shape}updateEntityBoxSize(r,e){let t=this.geometry.getAttribute("position");t!==void 0?oa(t,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:t.count,r,e):super.updateEntityBoxSize(r,e)}};var ws=class extends dt{constructor(e,t,o){super(e,t,o);this._shapeId=null;this._context=o}updateState(e,t){super.updateState(e,t),this.updateShape()}updateShape(){let e=this.data.geometry.extrusion.shape,t;if(e.type==="Custom"){let i=e.shapeId;if(i!==this._shapeId&&this.detachShape(),i){this._shapeId=i;let s=this._context.scene.find(i);s?.data&&(s.attachedPaths.add(this),t=s.geometry.userData?.shape),t||this._context.scene.addPendingCommand(()=>this.updateShape())}}else{let i;switch(e.type){case"Rectangle":i=tc;break;case"Ellipse":i=Ni;break;case"Polygon":i=ec;break;case"Star":i=rc;break;default:throw new Error(`Unknown shape type: ${e.type}`)}t=i.create({parameters:e}).userData.shape}let o=this.geometry;t&&o.inputs&&(o.inputs.shapeData=t,o.build(),this.attachedSurfaceCloners.forEach(i=>i.update()))}detachShape(){this._shapeId!==null&&this._context.scene.find(this._shapeId)?.attachedPaths.delete(this)}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.updateShape(),this.refreshAttachedPaths(e)}updateTransformState(e){return super.updateTransformState(e)}updateGeometryInteractions(e,t){super.updateGeometryInteractions(e,t),this.updateShape()}updateEntityBoxSize(e,t){let o=this.geometry.getAttribute("position");o!==void 0?oa(o,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:o.count,e,t):super.updateEntityBoxSize(e,t)}};var _s=require("three");var _o=class extends oo(_s.Group,no){constructor(e,t,o){super();t.type==="Instance"&&typeof e=="string"&&(t=this.transformAssignData(t,o)),this.super_Entity(e,t),this.objectHelper.update()}get isComponentRoot(){return this.data.type==="Component"&&typeof this.identity=="string"}get isInstanceRoot(){return this.data.type==="Instance"&&typeof this.identity=="string"}transformAssignData(e,t){let o=t.scene.data.objects.get(e.component);if(o){let i,s;for(let a of Ur.rootOverrideProps)e[a]===void 0?(i===void 0&&(i={...e}),i[a]=o.data[a]):(s===void 0&&(s={}),s[a]=e[a],i===void 0&&(i={...e}),i[a]=Gr.apply(o.data[a],e[a]));return this.overrideData=s,i}else return{...It.defaultData,...e,...Sr(It.defaultData,Ur.rootOverrideProps)}}updateByOp(e,t,o,i){let s;if(this.isInstanceRoot&&!i){if(t=this.transformAssignData(t,o),e.type===0&&e.path.length===0&&this.component)for(let a of Ur.rootOverrideProps)a in e.props&&e.props[a]===void 0&&(s===void 0&&(s={...e,props:{...e.props}}),s.props[a]=this.component.data[a]);else if(e.type===0&&e.path.length>0&&Ur.rootOverrideProps.includes(e.path[0])){let a=e.path[0];s===void 0&&(s={...e,path:[],props:{[a]:t[a]}})}}super.updateByOp(s??e,t,o,i)}updateState(e,t){this.updateState_Entity(e,t)}expandInstanceChildren(e){let t=this.data;if(this.component===void 0){let o=e.scene.find(t.component)??null,i=!1;if(o!==this.oldComponent){if(this.oldComponent){let s=0;for(let a of this.children)if(Ne.is(a))e.scene.disposeAndUnregisterEntityRecursivelyIfNotReregistered(a),Rc(a),s+=1;else break;this.children.splice(0,s)}i=!0}if(o){let s={};y0(e,[this.uuid],t.overrides,this,o,o,0,i,s);for(let a of this.children)if(Ne.is(a)){let c=a.data;c.type==="Empty"&&c.animations&&a.traverseEntity(d=>{if(d instanceof dt&&d.isSkinnedMesh){let l=d.dataPatched;if(l.bones&&l.boneInverses){let u=l.bones.map(m=>e.scene.find(s[m])),p=l.boneInverses.map(m=>new _s.Matrix4().fromArray(m)),f=new _s.Skeleton(u,p);d.bind(f,d.bindMatrix)}}else d.matrixAutoUpdate=!0})}}this.oldComponent=this.component}}};function Rc(n){if(n.component){let r=n.component.instances.indexOf(n);r>=0&&n.component.instances.splice(r,1);for(let e of n.children)Ne.is(e)&&Rc(e)}}function h0(n,r,e,t){return n.component===r&&Ns(n.identity,t)?n.overrideData===e?2:1:0}function y0(n,r,e,t,o,i,s,a,c){if(s>50)return!1;if(t.component!==o){if(t.component){let l=t.component.instances.indexOf(t);l>=0&&t.component.instances.splice(l,1)}o.instances.push(t),t.component=o}o instanceof _o&&o.isInstanceRoot&&o.expandInstanceChildren(n);let d=0;for(let l of o.children)if(Ne.is(l)){let u=[...r,...typeof l.identity=="string"?[l.identity]:l.identity],p=fi.resolve(e,u,1);if(p!=null&&!(p instanceof He)){if(Object.setPrototypeOf(p,He.prototype),!1)debugger;console.error("wrong prototype")}let f=null,m;if(!a){let h=t.children[d];if(f=Ne.is(h)?h:null,f!==null){let y=h0(f,l,p,u);m=y>=1?f.stateSelection:void 0,y!==2&&(f=null)}if(f===null&&(f=n.scene.findInstance(u)??null,f!==null)){let y=h0(f,l,p,u);if(m=y>=1?f.stateSelection:void 0,y!==2)f=null;else{let g=f.parent.children.indexOf(f);f.parent.children.splice(g,1),t.children.splice(d,0,f),f.parent===t?(g<=d&&console.error("not possible"),void 0):(f.parent=t,f.matrixWorldNeedsUpdate=!0,f.resetBBoxNeedsUpdate(),f.updateVisible(),n.pendingDeletes.delete(f),void 0)}}}if(f===null){let h=p?Gr.apply(l.data,p):l.data;wr.is(h.type)&&(h={...h,type:"Empty"}),f=Pr.createEntity(u,h,n),f.overrideData=p,t.add(f),t.children.splice(t.children.length-1,1),t.children.splice(d,0,f),f.updateState(f.data,n),m&&f.changeSelectedState(m,n),n.scene.registerInstanceAndSetUuid(f)}if(f.isBone){let h=f.identity[f.identity.length-1];c[h]=f.uuid}d+=1,y0(n,r,e,f,l,i,s+1,a,c)}if(!a){let l=d;for(;;){let u=t.children[d];if(Ne.is(u))n.pendingDeletes.add(u);else break;d+=1}t.children.splice(l,d-l)}return!0}var g0=require("three");var Gc=class extends oo(g0.Bone,no){constructor(r,e){super(),this.super_Entity(r,e),this.objectHelper.update(),this.matrixAutoUpdate=!0}updateState(r,e){this.updateState_Entity(r,e)}};function aO(n,r,e){let t;return r.geometry.type==="TextGeometry"?new cs(n,r,e):(r.geometry.type==="SubdivGeometry"?t=new Cn(n,r,e):r.geometry.type==="PathGeometry"?t=new ws(n,r,e):r.geometry.type==="VectorGeometry"?t=new Bc(n,r,e):r.geometry.type==="BooleanGeometry"?t=new gr(n,r,e):t=new dt(n,r,e),t)}function Vc(n,r,e){return r.type==="Mesh"?aO(n,r,e):r.type==="Empty"?new Ta(n,r):r.type==="Bone"?new Gc(n,r):r.type==="Page"?new Jo(n,r):r.type==="PointLight"?new Dc(n,r,e):r.type==="SpotLight"?new bs(n,r,e):r.type==="DirectionalLight"?new vs(n,r,e):r.type==="Component"||r.type==="Instance"?new _o(n,r,e):wr.is(r.type)?new wo(n,r):(console.error(r),new Ta(n,r))}Pr.createEntity=Vc;function lO(n,r,e){let t=Vc(n.identity,r,e),o=n.children,i=n.attachedPaths,s=n.parent,a=n.component,c=n.instances,d=n.overrideData,l=n.uuid,u=n.stateSelection;n.dispose();for(let p of Object.keys(n))delete n[p];Object.setPrototypeOf(n,Object.getPrototypeOf(t));for(let p of Object.keys(t))n[p]=t[p];n.children=[...n.children,...o],n.attachedPaths=i,n.parent=s,n.component=a,n.instances=c,n.uuid=l,n.overrideData=d,n.updateState(n.data,e),u&&n.changeSelectedState(u,e),n.resetBBoxNeedsUpdate()}Pr.changeEntityProptotype=lO;Pr.Cloner=ps;function x0(n,r,e,t){n.updateByOp(r,e,t,!1)}var Ps=require("three");function v0(n,r){let e=!1,t=r.getLayersOfType("transmission"),o=r.getLayersOfType("outline");return o.length>0&&(n.layers.set(8),t.length>0&&n.layers.enable(3),e=!0,as(n),ss(n)),t.length===0&&o.length===0&&n.layers.set(0),n instanceof er&&n.needsAO&&n.layers.enable(5),e}function b0(n,r){if(!r.layers)return!1;let e=!1,t=r.getLayersOfType("transmission").filter(i=>i.data.visible),o=r.getLayersOfType("outline").filter(i=>i.data.visible);return t.length>0&&(n.layers.set(3),o.length>0&&n.layers.enable(8),e=!0),t.length===0&&o.length===0&&n.layers.set(0),n.needsAO&&n.layers.enable(5),e}function S0(n){let r=!1;return n.traverseEntity(e=>{if(e instanceof er)if(Array.isArray(e.material))for(let t=0;t<e.material.length;t++)v0(e,e.material[t])&&(r=!0);else v0(e,e.material)&&(r=!0)}),r}function w0(n){let r=!1;return n.traverseEntity(e=>{if(e instanceof er)if(Array.isArray(e.material))for(let t=0;t<e.material.length;t++)b0(e,e.material[t])&&(r=!0);else b0(e,e.material)&&(r=!0)}),r}var dO=new Ps.Raycaster,pO=new Ps.Matrix4,fO=new Ps.Ray;function Na(n,r,e,t=!1){let o=n.cloner;if(o)for(let i of o.children){let s=pO.copy(i.matrixWorld).invert(),a=fO.copy(r.ray).applyMatrix4(s),c=n.matrixWorld;a.applyMatrix4(c);let d=dO;d.set(a.origin,a.direction),d.near=r.near,d.far=r.far;let l=d.intersectObject(n,!1);l.length>0&&e.push({...l[0],object:t?i:n})}}var zc=class{constructor(){this._constraints=new Map}setConstraint(r,e){e===null?this._constraints.delete(r):this._constraints.set(r,e)}removeDependencies(r){this._constraints.delete(r)}applyConstraints(r){let e=new Set;this._constraints.forEach((t,o)=>{let i=[o,t],s=t;for(;this._constraints.has(s);)s=this._constraints.get(s),e.has(s)||i.push(s);for(let a=i.length-2;a>=0;a--)if(!e.has(i[a])){let c=r.find(i[a]);c?c.applyPathSnapping(r):console.warn(`missing entity ${i[a]}`),e.add(i[a])}})}findDependency(r,e){let t=r;for(;this._constraints.has(t);)if(t=this._constraints.get(t),t===e)return!0;return!1}};var mO=new vr.MeshBasicMaterial;mO.wireframe=!0;var _0=new vr.Vector3,jc=class extends vr.Scene{constructor(e,t){super();this.data=e;this.enableHelpers=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this.needsNormalDirty=!0;this._needsTransmission=!1;this._needsNormal=!1;this.geometryCacheChanged=!1;this.entityByUuid={};this.entityIdentityToEntity={};this.toExpandCloner=new Set;this.toUpdateCloner=new Set;this.pendingCommands=[];this.pathConstraints=new zc;this.errorPage=new Jo("fdasfa",{...fo.defaultData,name:""});this.needsRecomputeInstances=!1;this.init(e,t),this.matrixAutoUpdate=!1}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=w0(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=S0(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let t=e.identity.join("-"),o=this.entityIdentityToEntity[t];o&&(e.uuid=o.uuid),this.entityIdentityToEntity[t]=e,this.entityByUuid[e.uuid]=e}markPenumbraSizeDirty(){for(let e of this.children)e instanceof Jo&&(e.penumbraSizeArrayCache=null)}findInstance(e){return this.entityIdentityToEntity[e.join("-")]}get bgColor(){return this.activePage.bgColor}get postprocessing(){return this.activePage.data.postprocessing}getWithSortKey(e){let t=this.find(e);if(t===void 0)return;let o=[],i=t;for(;i!==this;){let s=i;i=i.parent;let a=i.children.indexOf(s);o.splice(0,0,a)}return{entity:t,sortKey:o}}getAllSorted(e){let t=[];for(let o of e){let i=this.getWithSortKey(o.id);i!==void 0&&t.push(i)}return t.sort((o,i)=>Zd(o.sortKey,i.sortKey)),t.map(o=>o.entity)}nonExistOrDescendantOf(e,t){let o=this.find(e);if(o===void 0)return!0;for(;o;){if(o.uuid===t)return!0;o=o.parent}return!1}find(e){if(this.activePage&&this.activePage.personalCamera.parent){if(e==="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera")return this.activePage.personalCamera;if(e===Do)return this.activePage.personalCamera}if(e===""||e===void 0)return;let t=this.entityByUuid[e];return t===void 0?this.getObjectByProperty("uuid",e):t}debugEnsureEntity(e){let t=this.find(e);if(t){if(Array.isArray(t.identity)&&this.findInstance(t.identity)===void 0){console.error("not found instance");debugger}}else{console.error("not found");debugger}}addPendingExpandCloner(e){this.toExpandCloner.add(e)}addPendingUpdateCloner(e){this.toUpdateCloner.add(e)}markToExpandCloner(e){this.toExpandCloner.add(e),e.traverseEntityAncestors(t=>{this.toExpandCloner.add(t)})}doPendingExpandCloner(){this.toExpandCloner.forEach(e=>{e.expandCloner(this)}),this.toExpandCloner.clear()}doPendingUpdateCloner(){this.toUpdateCloner.forEach(e=>{e.cloner?.update()}),this.toUpdateCloner.clear()}doPendingUpdates(){this.doPendingExpandCloner(),this.doPendingUpdateCloner(),this.applyPendingCommands()}addPendingCommand(e){this.pendingCommands.push(e)}applyPendingCommands(){this.pendingCommands.forEach(e=>e()),this.pendingCommands.length=0}updateTreeByOp(e,t){if(e.path.length===0&&e.type===7){let o=e.parent===null?this:this.find(e.parent);if(o===void 0)throw new Error("unexpected");let i=this.createObject(e.id,e.data,e.children,o,e.localIndex,t);i.updateVisible(),i.resetBBoxNeedsUpdate(),Qo(i)&&_a(i.parent)&&(i.invalidateUpstreamBooleanData(),i.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(o),this.markNeedsRecomputeInstancesForChildren(i),this.markToExpandCloner(i),this.markPenumbraSizeDirty()}else if(e.path.length===0&&e.type===8){let o=this.find(e.id);if(o===void 0)throw new Error("unexpected");this.markToExpandCloner(o),o.resetBBoxNeedsUpdate(),this.unregisterObject(o);let i=o.parent;this.markNeedsRecomputeInstancesForAncessors(i),this.markNeedsRecomputeInstancesForChildren(o),this.markPenumbraSizeDirty(),o.parent.remove(o),_a(o.parent)&&(o.parent.invalidateUpstreamBooleanData(),o.parent.invalidateDownstreamBooleanData().recomputeBoolean()),Qo(o)&&(o.freeBooleanPointer(),i instanceof gr&&i.invalidateDownstreamBooleanData().recomputeBoolean()),o instanceof ws&&o.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(o),this.pathConstraints.removeDependencies(o.uuid)}else if(e.path.length===0&&e.type===9){let o=this.find(e.id);if(o===void 0)throw new Error("unexpected");this.markNeedsRecomputeInstancesForChildren(o);let i=o.parent;this.markNeedsRecomputeInstancesForAncessors(i),o.cloner?.resetOnMove(),this.markToExpandCloner(o);let s=e.parent===null?this:this.find(e.parent);if(s===void 0)throw new Error("unexpected");s.add(o),this.markNeedsRecomputeInstancesForAncessors(s),this.markToExpandCloner(o),o.invalidateClonerTransform(o),o.updateVisible(),o.resetBBoxNeedsUpdate(),this.markPenumbraSizeDirty();let a=e.localIndex;s.children.splice(a,0,s.children.pop()),Qo(o)&&(o.invalidateUpstreamBooleanData(),_a(o.parent)?o.parent.invalidateDownstreamBooleanData().recomputeBoolean():i instanceof gr&&i.invalidateDownstreamBooleanData().recomputeBoolean())}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}get playPage(){return this.find(this.data.publish.playPage)??this.errorPage}updatePage(e){this.activePage&&this.activePage.onDeactive(),this.activePage=this.errorPage;for(let t of this.children)t instanceof Jo&&(t.visible=t.uuid===e,t.visible&&(this.activePage=t,this.activePage.onActive(this)))}updateEntityByOp(e,t,o,i){if(t.type===0){if(("overrides"in t.props||"component"in t.props)&&this.markNeedsRecomputeInstances(),"visible"in t.props&&this.markPenumbraSizeDirty(),t.path.includes("overrides")&&"states"in t.props){let{rest:a}=t.props;t={...t,props:a},this.markNeedsRecomputeInstances()}t.path[0]==="pathSnapping"&&t.props.pathId!==void 0&&this.pathConstraints.setConstraint(e,t.props.pathId)}let s=this.find(e);if(s)try{x0(s,t,o,{scene:this,shared:i}),s instanceof dt&&s.updateGeometryGroupsIfNeeded()}catch(a){console.error(a)}}get activeCamera(){return this.activePage.activeCamera}switchActiveCamera(e){this.activePage.switchActiveCamera(e)}init(e,t){this.createChildrenObjects(e.objects,this,t),this.updatePage(e.publish.playPage),this.activePage.switchToPlayCamera(),this.expandInstances(t,!0),this.traverseEntity(o=>{_a(o)&&o.recomputeBoolean(),o instanceof wo&&o.updateUp()}),this.doPendingExpandCloner(),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(t=>{(t.data.type==="Component"||t.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){Ne.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(t=>{Ne.is(t)&&t.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,t,o,i,s,a,c){if(e){let d=i.find(e);d&&d!==i&&s.forInstancesRec(l=>{l.data=ai(l.data,u=>{let p=u.events.data(c.id),f=l.goUp(a);if(f){let m=[...La(f.identity),e].join("-"),h=this.entityIdentityToEntity[m];if(h){let y=h.uuid,g=Vt.zoom(p,t);g[o]=y}else{if(!1)debugger;console.warn("cannot find instance")}}}).data})}}rewriteActions(e,t,o,i,s,a){e.forEach(c=>{c.data.type==="Transition"?this.relativeizeInner(c.data.object,[...t,c.id],"object",o,i,s,a):c.data.type==="Animation"&&this.relativeizeInner(c.data.object,[...t,c.id],"object",o,i,s,a)})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof _o&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((t,o)=>{t.data.events.forEach(i=>{if(i.data.type==="GameControl"){let s=!1;if(t.forInstancesRec(a=>{a.data=ai(a.data,c=>{a.isInstanceRoot||(c.events.delete(i.id),s=!0)}).data}),s===!1)for(let a of Gl.list)this.rewriteActions(i.data.gameActions[a],["gameActions",a],e,t,o,i)}else i.data.type==="Conditional"?(i.data.condition.type==="Distance"?(this.relativeizeInner(i.data.condition.fromObject,["condition"],"fromObject",e,t,o,i),this.relativeizeInner(i.data.condition.toObject,["condition"],"toObject",e,t,o,i)):i.data.condition.type==="State"?this.relativeizeInner(i.data.condition.object,["condition"],"object",e,t,o,i):i.data.condition.type==="Comparison"&&(i.data.condition.lOperand.type==="Property"&&this.relativeizeInner(i.data.condition.lOperand.value[0],["condition","lOperand","value"],0,e,t,o,i),i.data.condition.rOperand.type==="Property"&&this.relativeizeInner(i.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,t,o,i)),this.rewriteActions(i.data.inActions,["inActions"],e,t,o,i),this.rewriteActions(i.data.outActions,["outActions"],e,t,o,i)):"actions"in i.data&&this.rewriteActions(i.data.actions,["actions"],e,t,o,i)})}),!0})}expandInstances(e,t,o){let i=new Set;this.traverseEntity(s=>{if(s instanceof _o&&s.isInstanceRoot)return s.expandInstanceChildren({scene:this,shared:e,pendingDeletes:i}),t||s.resetBBoxNeedsUpdate(),o&&s.traverseEntity(a=>{o.addClip(a)}),!0});for(let s of i)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(s),Rc(s)}recomputeInstances(e,t){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(o=>{o instanceof _o&&o.isInstanceRoot&&(o.component=void 0)}),this.expandInstances(e,!1,t))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(t=>{let o=typeof t.identity=="string"?t.identity:t.identity.join("-");this.entityIdentityToEntity[o]===t&&(delete this.entityByUuid[t.uuid],delete this.entityIdentityToEntity[o]),t.dispose()})}clearScene(){for(let e of this.children)Ne.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,t){this.init(e,t)}raycast(e){return this.raycast1(e,!1)}raycast1(e,t){let o=[],i=s=>{for(let a of s.children){let c=a.cloner;if(Ne.is(a)&&!a.raycastLock&&(a.visible||c?.object.data.visible))if(t===!0&&a.isInstanceRoot){let d=[];if(e.intersectObject(a,!0,d),d.length){let l=d[0];l.object=a,l.point.applyMatrix4(l.object.matrixWorld);let u=a.matrixWorld.clone().invert();l.point.applyMatrix4(u),o.push(l)}}else(Qo(a)||Pa(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,o),Na(a,e,o)),i(a)}};return i(this),o}raycastWithClones(e){let t=[],o=i=>{for(let s of i.children){let a=s.cloner;Ne.is(s)&&(s.visible||a?.object.data.visible)&&((Qo(s)||Pa(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,t),Na(s,e,t,!0)),o(s))}};return o(this),t}forEachEntity(e){for(let t of this.children)Ne.is(t)&&e(t)}traverseConcreteEntity(e){for(let t of this.children)Ne.is(t)&&t.isConcreteEntity&&t.traverseEntity(e)}traverseEntity(e){for(let t of this.children)Ne.is(t)&&t.traverseEntity(e)}traverseObject(e){for(let t of this.children)yi.is(t)&&t.traverseObject(e)}traverseVisibleEntity(e){for(let t of this.children)Ne.is(t)&&t.visible&&t.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,t,o){let i=0;for(let s of e)this.createObject(s.id,s.data,s.children,t,i,o),i+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let t of e.children)this.unregisterObject(t)}createObject(e,t,o,i,s,a){let c={scene:this,shared:a},d=Vc(e,t,c);return d&&(this.entityByUuid[e]=d,i.add(d),i.children.splice(s,0,i.children.pop()),o.length>0&&(d.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(o,d,a)),d.updateState(t,c),d instanceof dt&&d.updateGeometryGroupsIfNeeded(),d.updateVisible(),d.cloner&&this.toExpandCloner.add(d),t.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,t.pathSnapping.pathId)),t.type==="Empty"&&t.animations&&d.traverseEntity(l=>{if(l instanceof dt&&l.isSkinnedMesh){let u=l.dataPatched;if(u.bones&&u.boneInverses){let p=u.bones.map(h=>this.find(h)),f=u.boneInverses.map(h=>new vr.Matrix4().fromArray(h)),m=new vr.Skeleton(p,f);l.bind(m,l.bindMatrix)}}else l.matrixAutoUpdate=!0}),d}getCenter(e){let t=[];for(let i=0,s=e.length;i<s;++i){let{id:a,recursive:c}=e[i],d=this.find(a),l=c?d.recursiveBBox:d.singleBBox;t.push(...l.vertices)}let o=new vr.Box3;return o.setFromPoints(t),o.getCenter(_0),_0}copyMatrixWorld(e,t){if(e===null){t.identity();return}let o=this.find(e);o?t.copy(o.matrixWorld):t.identity()}copyParentMatrixWorld(e,t){if(e===null){t.identity();return}let o=this.find(e)?.parent;o?t.copy(o.matrixWorld):t.identity()}traverseMaterial(e){this.traverseEntity(t=>{if(t instanceof Mt)if(Array.isArray(t.material))for(let o=0;o<t.material.length;o++)t.material[o]instanceof Jt&&e(t.material[o]);else t.material instanceof Jt&&e(t.material)})}updateViewPlaneSize(e,t,o=!1){this.traverseConcreteEntity(i=>{i instanceof wo&&i.setViewplaneSize(e,t,o)})}};var P0=require("three/examples/jsm/loaders/DRACOLoader.js");var en;function hO(){return en||(en=new P0.DRACOLoader,en.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),en.decoderPending}async function yO(n){if(en){let r={attributeIDs:en.defaultAttributeIDs,attributeTypes:en.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await en.decodeGeometry(new Int8Array(n).buffer,r)}catch(t){console.error(t)}if(e)return{index:e.index?{array:e.index.array}:void 0,attributes:Object.entries(e.attributes).map(([t,o])=>({name:t,itemSize:o.itemSize,array:o.array}))}}return null}async function T0(n,r){let[e,t]=tu(Sl.deserialize(new Uint8Array(n)));Th(e);let o=[];e.scene.objects.traverse((i,s)=>{s.type==="Mesh"&&s.geometry.type==="NonParametricGeometry"&&s.geometry.data.draco!==void 0&&o.push(s)}),o.length&&await hO();for(let i of o){let s=await yO(ut(i.geometry.data.draco));if(s){s.index&&(i.geometry.data.index={array:s.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let a={};s.attributes.forEach(({name:c,array:d,itemSize:l})=>{a[c]={array:d,itemSize:l,type:"Float32Array",normalized:!1}}),i.geometry.data.attributes=a,i.geometry.data.draco=void 0}}return r&&r(e),t.result().data}var gO=require("three"),xO=require("three/examples/jsm/utils/BufferGeometryUtils.js");function O0(n){let r;if(!!n.index)for(let e=0;e<n.index.array.length;e+=3)r=n.index.array[e],n.index.array[e]=n.index.array[e+2],n.index.array[e+2]=r}var Ia=require("three");function A0(n){let r=new Set;return n.traverse(e=>{if(e instanceof er)if(tt(e.material))e.material.forEach(t=>{let o=t;r.has(o)||r.add(o)});else{let t=e.material;r.has(t)||r.add(t)}}),r.forEach(e=>{if(e instanceof Array)return;let t=e.onBeforeCompile.bind(e);if(vO(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new Ia.Color,specularColor:new Ia.Color});let o=0;e.onBeforeCompile=(i,s)=>{t&&t(i,s),i.uniforms=Object.assign({},Ia.ShaderLib.physical.uniforms,i.uniforms),e.getLayersOfType("transmission").forEach(a=>{if(i.uniforms.transmissionSamplerMap.value){let c=a.color;c&&(c.transmissionSamplerMap.value=i.uniforms.transmissionSamplerMap.value,c.transmissionSamplerSize.value=i.uniforms.transmissionSamplerSize.value,c.aspectRatio.value=xg(window.innerWidth,window.innerHeight),e.defines.IS_THREEJS_EXPORT=!0)}else o++,o<2&&(e.needsUpdate=!0)})}}else bO(e)||(e.onBeforeCompile=(o,i)=>{t&&t(o,i),e.transparent=!1})}),n}function vO(n){return n.getLayersOfType("transmission").length>0}function bO(n){let r=0;for(let e of n.layers){if(e.data.type!=="displace"&&e.data.isMask)return!0;if(e.type!=="light"&&e.type!=="fresnel"){let o=e.uniforms["f"+e.id+"_alpha"];o&&(r+=(1-r)*o.value)}}return r<1}function C0(n){return n.traverse(r=>{if(r.type==="Camera"){let e=r;e.type=e.cameraType}}),n}function N0(n){let r=[],e=(t,o=0)=>{let i=o>0?t+o:t;return r.includes(i)?e(t,o+1):i};return n.traverse(t=>{if(r.includes(t.name)){let o=t.name,i=e(t.name);if(t.name=i,t.isMesh){let s=t;s.material instanceof Array?s.material.forEach(a=>{a.name=a.name.replace(o,i)}):s.material.isAsset||(s.material.name=s.material.name.replace(o,i))}}r.push(t.name)}),n}var I0=require("three/examples/jsm/utils/BufferGeometryUtils.js");function M0(n){let r=[];return n.traverse(e=>{e instanceof ps&&r.push(e)}),r.forEach(e=>{let t=e.object,s=[...e.children.map(a=>{a.updateMatrix();let c;if(a.geometry!==void 0)try{c=a.geometry.clone().applyMatrix4(a.matrix)}catch(d){console.error(d)}return c!==void 0&&a.matrix.determinant()<0&&O0(c),c}).filter(a=>a!==void 0)];if(!e.parameters.hideBase&&t instanceof Mt&&s.unshift(t.geometry),s.length){let a=(0,I0.mergeBufferGeometries)(s);t instanceof Mt&&(t.geometry=a)}e.removeFromParent(),t.setFromClonerState(null,{scene:n,shared:Lg})}),n}function E0(n){return n.traverse(r=>{r.matrixAutoUpdate=!0}),n}function L0(n){Object.values(n.shared.materials).forEach(r=>{qd(r)}),n.scene.objects.traverse((r,e)=>{"material"in e?qd(e.material):"materials"in e&&e.materials.forEach(t=>{qd(t)})})}function qd(n){if(typeof n=="string")return;let r=[];n.layers.forEach((e,t)=>{e.type==="outline"&&r.push(t)}),r.reverse().forEach(e=>{n.layers.delete(e)}),r.length&&console.warn("The Spline Loader currently does not support the outline layer.")}var V0=Ts(B0(),1);function R0(n){return n.traverseMaterial(r=>{r.needsJitter=!1}),n}var G0="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",Fc=class extends kc.Loader{load(r,e,t,o=console.error){let i=new kc.FileLoader(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),r.endsWith(".spline")?console.warn(G0+" The .spline files are only meant to be used by the Editor."):r.endsWith(".splinecode")||console.warn(G0),i.load(r,async s=>{try{if(typeof s=="string")throw new Error("The .spline file is not binary!");let a=await this.parse(s);e(a)}catch(a){o(a)}},t,o)}async parse(r){let e=await T0(r,L0);e.version&&(0,V0.default)(e.version,"0.9.440")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/loader to the latest version."),await Promise.all([Vg(e)&&Wy(),Xg(e)&&Mg()].filter(Boolean));let t=new An(e.shared);Object.values(t.getMaterials()).forEach(s=>Object.assign(s,{isAsset:!0}));let o=new jc(e.scene,t),i=o.activeCamera;return i&&Object.assign(i,{makeDefault:!0}),o=M0(o),o=A0(o),o=C0(o),o=N0(o),o=E0(o),o=R0(o),o}};