@splinetool/loader 1.0.40 → 1.0.41

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,25 +1,25 @@
1
- var U1=Object.create;var $l=Object.defineProperty;var H1=Object.getOwnPropertyDescriptor;var q1=Object.getOwnPropertyNames;var W1=Object.getPrototypeOf,$1=Object.prototype.hasOwnProperty;var Y1=(n,t,e)=>t in n?$l(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var Zt=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports),X1=(n,t)=>{for(var e in t)$l(n,e,{get:t[e],enumerable:!0})},Q1=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of q1(t))!$1.call(n,o)&&o!==e&&$l(n,o,{get:()=>t[o],enumerable:!(r=H1(t,o))||r.enumerable});return n};var Ht=(n,t,e)=>(e=n!=null?U1(W1(n)):{},Q1(t||!n||!n.__esModule?$l(e,"default",{value:n,enumerable:!0}):e,n));var Lt=(n,t,e)=>(Y1(n,typeof t!="symbol"?t+"":t,e),e);var L0=Zt((Mp,B0)=>{(function(n,t){typeof Mp=="object"?B0.exports=t():typeof define=="function"&&define.amd?define(t):n.Alea=t()})(Mp,function(){"use strict";return n.importState=function(e){var r=new n;return r.importState(e),r},n;function n(){return function(e){var r=0,o=0,i=0,a=1;e.length==0&&(e=[+new Date]);var s=t();r=s(" "),o=s(" "),i=s(" ");for(var l=0;l<e.length;l++)r-=s(e[l]),r<0&&(r+=1),o-=s(e[l]),o<0&&(o+=1),i-=s(e[l]),i<0&&(i+=1);s=null;var u=function(){var c=2091639*r+a*23283064365386963e-26;return r=o,o=i,i=c-(a=c|0)};return u.next=u,u.uint32=function(){return u()*4294967296},u.fract53=function(){return u()+(u()*2097152|0)*11102230246251565e-32},u.version="Alea 0.9",u.args=e,u.exportState=function(){return[r,o,i,a]},u.importState=function(c){r=+c[0]||0,o=+c[1]||0,i=+c[2]||0,a=+c[3]||0},u}(Array.prototype.slice.call(arguments))}function t(){var e=4022871197,r=function(o){o=o.toString();for(var i=0;i<o.length;i++){e+=o.charCodeAt(i);var a=.02519603282416938*e;e=a>>>0,a-=e,a*=e,e=a>>>0,a-=e,e+=a*4294967296}return(e>>>0)*23283064365386963e-26};return r.version="Mash 0.9",r}})});var F0=Zt((uu,G0)=>{(function(n,t){typeof uu=="object"&&typeof G0<"u"?t(uu):typeof define=="function"&&define.amd?define(["exports"],t):t((n=typeof globalThis<"u"?globalThis:n||self).SVDJS={})})(uu,function(n){"use strict";n.SVD=function(t,e,r,o,i){if(e=e===void 0||e,r=r===void 0||r,i=1e-64/(o=o||Math.pow(2,-52)),!t)throw new TypeError("Matrix a is not defined");var a,s,l,u,c,d,p,f,h,m,y,g,b=t[0].length,w=t.length;if(w<b)throw new TypeError("Invalid matrix: m < n");for(var _=[],S=[],P=[],O=e==="f"?w:b,x=m=p=0;x<w;x++)S[x]=new Array(O).fill(0);for(x=0;x<b;x++)P[x]=new Array(b).fill(0);var D,N=new Array(b).fill(0);for(x=0;x<w;x++)for(a=0;a<b;a++)S[x][a]=t[x][a];for(x=0;x<b;x++){for(_[x]=p,h=0,l=x+1,a=x;a<w;a++)h+=Math.pow(S[a][x],2);if(h<i)p=0;else for(f=(d=S[x][x])*(p=d<0?Math.sqrt(h):-Math.sqrt(h))-h,S[x][x]=d-p,a=l;a<b;a++){for(h=0,s=x;s<w;s++)h+=S[s][x]*S[s][a];for(d=h/f,s=x;s<w;s++)S[s][a]=S[s][a]+d*S[s][x]}for(N[x]=p,h=0,a=l;a<b;a++)h+=Math.pow(S[x][a],2);if(h<i)p=0;else{for(f=(d=S[x][x+1])*(p=d<0?Math.sqrt(h):-Math.sqrt(h))-h,S[x][x+1]=d-p,a=l;a<b;a++)_[a]=S[x][a]/f;for(a=l;a<w;a++){for(h=0,s=l;s<b;s++)h+=S[a][s]*S[x][s];for(s=l;s<b;s++)S[a][s]=S[a][s]+h*_[s]}}m<(y=Math.abs(N[x])+Math.abs(_[x]))&&(m=y)}if(r)for(x=b-1;0<=x;x--){if(p!==0){for(f=S[x][x+1]*p,a=l;a<b;a++)P[a][x]=S[x][a]/f;for(a=l;a<b;a++){for(h=0,s=l;s<b;s++)h+=S[x][s]*P[s][a];for(s=l;s<b;s++)P[s][a]=P[s][a]+h*P[s][x]}}for(a=l;a<b;a++)P[x][a]=0,P[a][x]=0;P[x][x]=1,p=_[x],l=x}if(e){if(e==="f")for(x=b;x<w;x++){for(a=b;a<w;a++)S[x][a]=0;S[x][x]=1}for(x=b-1;0<=x;x--){for(l=x+1,p=N[x],a=l;a<O;a++)S[x][a]=0;if(p!==0){for(f=S[x][x]*p,a=l;a<O;a++){for(h=0,s=l;s<w;s++)h+=S[s][x]*S[s][a];for(d=h/f,s=x;s<w;s++)S[s][a]=S[s][a]+d*S[s][x]}for(a=x;a<w;a++)S[a][x]=S[a][x]/p}else for(a=x;a<w;a++)S[a][x]=0;S[x][x]=S[x][x]+1}}for(o*=m,s=b-1;0<=s;s--)for(var T=0;T<50;T++){for(D=!1,l=s;0<=l;l--){if(Math.abs(_[l])<=o){D=!0;break}if(Math.abs(N[l-1])<=o)break}if(!D){for(c=0,u=l-(h=1),x=l;x<s+1&&(d=h*_[x],_[x]=c*_[x],!(Math.abs(d)<=o));x++)if(p=N[x],N[x]=Math.sqrt(d*d+p*p),c=p/(f=N[x]),h=-d/f,e)for(a=0;a<w;a++)y=S[a][u],g=S[a][x],S[a][u]=y*c+g*h,S[a][x]=-y*h+g*c}if(g=N[s],l===s){if(g<0&&(N[s]=-g,r))for(a=0;a<b;a++)P[a][s]=-P[a][s];break}for(m=N[l],d=(((y=N[s-1])-g)*(y+g)+((p=_[s-1])-(f=_[s]))*(p+f))/(2*f*y),p=Math.sqrt(d*d+1),d=((m-g)*(m+g)+f*(y/(d<0?d-p:d+p)-f))/m,x=l+(h=c=1);x<s+1;x++){if(p=_[x],y=N[x],f=h*p,p*=c,g=Math.sqrt(d*d+f*f),d=m*(c=d/(_[x-1]=g))+p*(h=f/g),p=-m*h+p*c,f=y*h,y*=c,r)for(a=0;a<b;a++)m=P[a][x-1],g=P[a][x],P[a][x-1]=m*c+g*h,P[a][x]=-m*h+g*c;if(g=Math.sqrt(d*d+f*f),d=(c=d/(N[x-1]=g))*p+(h=f/g)*y,m=-h*p+c*y,e)for(a=0;a<w;a++)y=S[a][x-1],g=S[a][x],S[a][x-1]=y*c+g*h,S[a][x]=-y*h+g*c}_[l]=0,_[s]=d,N[s]=m}for(x=0;x<b;x++)N[x]<o&&(N[x]=0);return{u:S,q:N,v:P}},n.VERSION="1.1.1",Object.defineProperty(n,"__esModule",{value:!0})})});var bx=Zt((rf,of)=>{(function(n,t){typeof rf=="object"&&typeof of<"u"?of.exports=t():typeof define=="function"&&define.amd?define(t):(n=n||self,n.TinyQueue=t())})(rf,function(){"use strict";var n=function(r,o){if(r===void 0&&(r=[]),o===void 0&&(o=t),this.data=r,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(r){this.data.push(r),this.length++,this._up(this.length-1)},n.prototype.pop=function(){if(this.length!==0){var r=this.data[0],o=this.data.pop();return this.length--,this.length>0&&(this.data[0]=o,this._down(0)),r}},n.prototype.peek=function(){return this.data[0]},n.prototype._up=function(r){for(var o=this,i=o.data,a=o.compare,s=i[r];r>0;){var l=r-1>>1,u=i[l];if(a(s,u)>=0)break;i[r]=u,r=l}i[r]=s},n.prototype._down=function(r){for(var o=this,i=o.data,a=o.compare,s=this.length>>1,l=i[r];r<s;){var u=(r<<1)+1,c=i[u],d=u+1;if(d<this.length&&a(i[d],c)<0&&(u=d,c=i[d]),a(c,l)>=0)break;i[r]=c,r=u}i[r]=l};function t(e,r){return e<r?-1:e>r?1:0}return n})});var Sx=Zt((JW,nf)=>{"use strict";var Su=bx();Su.default&&(Su=Su.default);nf.exports=vx;nf.exports.default=vx;function vx(n,t,e){t=t||1;for(var r,o,i,a,s=0;s<n[0].length;s++){var l=n[0][s];(!s||l[0]<r)&&(r=l[0]),(!s||l[1]<o)&&(o=l[1]),(!s||l[0]>i)&&(i=l[0]),(!s||l[1]>a)&&(a=l[1])}var u=i-r,c=a-o,d=Math.min(u,c),p=d/2;if(d===0){var f=[r,o];return f.distance=0,f}for(var h=new Su(void 0,pM),m=r;m<i;m+=d)for(var y=o;y<a;y+=d)h.push(new Cn(m+p,y+p,p,n));var g=hM(n),b=new Cn(r+u/2,o+c/2,0,n);b.d>g.d&&(g=b);for(var w=h.length;h.length;){var _=h.pop();_.d>g.d&&(g=_,e&&console.log("found best %d after %d probes",Math.round(1e4*_.d)/1e4,w)),!(_.max-g.d<=t)&&(p=_.h/2,h.push(new Cn(_.x-p,_.y-p,p,n)),h.push(new Cn(_.x+p,_.y-p,p,n)),h.push(new Cn(_.x-p,_.y+p,p,n)),h.push(new Cn(_.x+p,_.y+p,p,n)),w+=4)}e&&(console.log("num probes: "+w),console.log("best distance: "+g.d));var S=[g.x,g.y];return S.distance=g.d,S}function pM(n,t){return t.max-n.max}function Cn(n,t,e,r){this.x=n,this.y=t,this.h=e,this.d=fM(n,t,r),this.max=this.d+this.h*Math.SQRT2}function fM(n,t,e){for(var r=!1,o=1/0,i=0;i<e.length;i++)for(var a=e[i],s=0,l=a.length,u=l-1;s<l;u=s++){var c=a[s],d=a[u];c[1]>t!=d[1]>t&&n<(d[0]-c[0])*(t-c[1])/(d[1]-c[1])+c[0]&&(r=!r),o=Math.min(o,mM(n,t,c,d))}return o===0?0:(r?1:-1)*Math.sqrt(o)}function hM(n){for(var t=0,e=0,r=0,o=n[0],i=0,a=o.length,s=a-1;i<a;s=i++){var l=o[i],u=o[s],c=l[0]*u[1]-u[0]*l[1];e+=(l[0]+u[0])*c,r+=(l[1]+u[1])*c,t+=c*3}return t===0?new Cn(o[0][0],o[0][1],0,n):new Cn(e/t,r/t,0,n)}function mM(n,t,e,r){var o=e[0],i=e[1],a=r[0]-o,s=r[1]-i;if(a!==0||s!==0){var l=((n-o)*a+(t-i)*s)/(a*a+s*s);l>1?(o=r[0],i=r[1]):l>0&&(o+=a*l,i+=s*l)}return a=n-o,s=t-i,a*a+s*s}});var Gb=Zt(Yu=>{(function(){"use strict";var n=function(){this.init()};n.prototype={init:function(){var c=this||t;return c._counter=1e3,c._html5AudioPool=[],c.html5PoolSize=10,c._codecs={},c._howls=[],c._muted=!1,c._volume=1,c._canPlayEvent="canplaythrough",c._navigator=typeof window<"u"&&window.navigator?window.navigator:null,c.masterGain=null,c.noAudio=!1,c.usingWebAudio=!0,c.autoSuspend=!0,c.ctx=null,c.autoUnlock=!0,c._setup(),c},volume:function(c){var d=this||t;if(c=parseFloat(c),d.ctx||u(),typeof c<"u"&&c>=0&&c<=1){if(d._volume=c,d._muted)return d;d.usingWebAudio&&d.masterGain.gain.setValueAtTime(c,t.ctx.currentTime);for(var p=0;p<d._howls.length;p++)if(!d._howls[p]._webAudio)for(var f=d._howls[p]._getSoundIds(),h=0;h<f.length;h++){var m=d._howls[p]._soundById(f[h]);m&&m._node&&(m._node.volume=m._volume*c)}return d}return d._volume},mute:function(c){var d=this||t;d.ctx||u(),d._muted=c,d.usingWebAudio&&d.masterGain.gain.setValueAtTime(c?0:d._volume,t.ctx.currentTime);for(var p=0;p<d._howls.length;p++)if(!d._howls[p]._webAudio)for(var f=d._howls[p]._getSoundIds(),h=0;h<f.length;h++){var m=d._howls[p]._soundById(f[h]);m&&m._node&&(m._node.muted=c?!0:m._muted)}return d},stop:function(){for(var c=this||t,d=0;d<c._howls.length;d++)c._howls[d].stop();return c},unload:function(){for(var c=this||t,d=c._howls.length-1;d>=0;d--)c._howls[d].unload();return c.usingWebAudio&&c.ctx&&typeof c.ctx.close<"u"&&(c.ctx.close(),c.ctx=null,u()),c},codecs:function(c){return(this||t)._codecs[c.replace(/^x-/,"")]},_setup:function(){var c=this||t;if(c.state=c.ctx&&c.ctx.state||"suspended",c._autoSuspend(),!c.usingWebAudio)if(typeof Audio<"u")try{var d=new Audio;typeof d.oncanplaythrough>"u"&&(c._canPlayEvent="canplay")}catch{c.noAudio=!0}else c.noAudio=!0;try{var d=new Audio;d.muted&&(c.noAudio=!0)}catch{}return c.noAudio||c._setupCodecs(),c},_setupCodecs:function(){var c=this||t,d=null;try{d=typeof Audio<"u"?new Audio:null}catch{return c}if(!d||typeof d.canPlayType!="function")return c;var p=d.canPlayType("audio/mpeg;").replace(/^no$/,""),f=c._navigator?c._navigator.userAgent:"",h=f.match(/OPR\/([0-6].)/g),m=h&&parseInt(h[0].split("/")[1],10)<33,y=f.indexOf("Safari")!==-1&&f.indexOf("Chrome")===-1,g=f.match(/Version\/(.*?) /),b=y&&g&&parseInt(g[1],10)<15;return c._codecs={mp3:!!(!m&&(p||d.canPlayType("audio/mp3;").replace(/^no$/,""))),mpeg:!!p,opus:!!d.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/,""),ogg:!!d.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),oga:!!d.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),wav:!!(d.canPlayType('audio/wav; codecs="1"')||d.canPlayType("audio/wav")).replace(/^no$/,""),aac:!!d.canPlayType("audio/aac;").replace(/^no$/,""),caf:!!d.canPlayType("audio/x-caf;").replace(/^no$/,""),m4a:!!(d.canPlayType("audio/x-m4a;")||d.canPlayType("audio/m4a;")||d.canPlayType("audio/aac;")).replace(/^no$/,""),m4b:!!(d.canPlayType("audio/x-m4b;")||d.canPlayType("audio/m4b;")||d.canPlayType("audio/aac;")).replace(/^no$/,""),mp4:!!(d.canPlayType("audio/x-mp4;")||d.canPlayType("audio/mp4;")||d.canPlayType("audio/aac;")).replace(/^no$/,""),weba:!!(!b&&d.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),webm:!!(!b&&d.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),dolby:!!d.canPlayType('audio/mp4; codecs="ec-3"').replace(/^no$/,""),flac:!!(d.canPlayType("audio/x-flac;")||d.canPlayType("audio/flac;")).replace(/^no$/,"")},c},_unlockAudio:function(){var c=this||t;if(!(c._audioUnlocked||!c.ctx)){c._audioUnlocked=!1,c.autoUnlock=!1,!c._mobileUnloaded&&c.ctx.sampleRate!==44100&&(c._mobileUnloaded=!0,c.unload()),c._scratchBuffer=c.ctx.createBuffer(1,1,22050);var d=function(p){for(;c._html5AudioPool.length<c.html5PoolSize;)try{var f=new Audio;f._unlocked=!0,c._releaseHtml5Audio(f)}catch{c.noAudio=!0;break}for(var h=0;h<c._howls.length;h++)if(!c._howls[h]._webAudio)for(var m=c._howls[h]._getSoundIds(),y=0;y<m.length;y++){var g=c._howls[h]._soundById(m[y]);g&&g._node&&!g._node._unlocked&&(g._node._unlocked=!0,g._node.load())}c._autoResume();var b=c.ctx.createBufferSource();b.buffer=c._scratchBuffer,b.connect(c.ctx.destination),typeof b.start>"u"?b.noteOn(0):b.start(0),typeof c.ctx.resume=="function"&&c.ctx.resume(),b.onended=function(){b.disconnect(0),c._audioUnlocked=!0,document.removeEventListener("touchstart",d,!0),document.removeEventListener("touchend",d,!0),document.removeEventListener("click",d,!0),document.removeEventListener("keydown",d,!0);for(var w=0;w<c._howls.length;w++)c._howls[w]._emit("unlock")}};return document.addEventListener("touchstart",d,!0),document.addEventListener("touchend",d,!0),document.addEventListener("click",d,!0),document.addEventListener("keydown",d,!0),c}},_obtainHtml5Audio:function(){var c=this||t;if(c._html5AudioPool.length)return c._html5AudioPool.pop();var d=new Audio().play();return d&&typeof Promise<"u"&&(d instanceof Promise||typeof d.then=="function")&&d.catch(function(){console.warn("HTML5 Audio pool exhausted, returning potentially locked audio object.")}),new Audio},_releaseHtml5Audio:function(c){var d=this||t;return c._unlocked&&d._html5AudioPool.push(c),d},_autoSuspend:function(){var c=this;if(!(!c.autoSuspend||!c.ctx||typeof c.ctx.suspend>"u"||!t.usingWebAudio)){for(var d=0;d<c._howls.length;d++)if(c._howls[d]._webAudio){for(var p=0;p<c._howls[d]._sounds.length;p++)if(!c._howls[d]._sounds[p]._paused)return c}return c._suspendTimer&&clearTimeout(c._suspendTimer),c._suspendTimer=setTimeout(function(){if(!!c.autoSuspend){c._suspendTimer=null,c.state="suspending";var f=function(){c.state="suspended",c._resumeAfterSuspend&&(delete c._resumeAfterSuspend,c._autoResume())};c.ctx.suspend().then(f,f)}},3e4),c}},_autoResume:function(){var c=this;if(!(!c.ctx||typeof c.ctx.resume>"u"||!t.usingWebAudio))return c.state==="running"&&c.ctx.state!=="interrupted"&&c._suspendTimer?(clearTimeout(c._suspendTimer),c._suspendTimer=null):c.state==="suspended"||c.state==="running"&&c.ctx.state==="interrupted"?(c.ctx.resume().then(function(){c.state="running";for(var d=0;d<c._howls.length;d++)c._howls[d]._emit("resume")}),c._suspendTimer&&(clearTimeout(c._suspendTimer),c._suspendTimer=null)):c.state==="suspending"&&(c._resumeAfterSuspend=!0),c}};var t=new n,e=function(c){var d=this;if(!c.src||c.src.length===0){console.error("An array of source files must be passed with any new Howl.");return}d.init(c)};e.prototype={init:function(c){var d=this;return t.ctx||u(),d._autoplay=c.autoplay||!1,d._format=typeof c.format!="string"?c.format:[c.format],d._html5=c.html5||!1,d._muted=c.mute||!1,d._loop=c.loop||!1,d._pool=c.pool||5,d._preload=typeof c.preload=="boolean"||c.preload==="metadata"?c.preload:!0,d._rate=c.rate||1,d._sprite=c.sprite||{},d._src=typeof c.src!="string"?c.src:[c.src],d._volume=c.volume!==void 0?c.volume:1,d._xhr={method:c.xhr&&c.xhr.method?c.xhr.method:"GET",headers:c.xhr&&c.xhr.headers?c.xhr.headers:null,withCredentials:c.xhr&&c.xhr.withCredentials?c.xhr.withCredentials:!1},d._duration=0,d._state="unloaded",d._sounds=[],d._endTimers={},d._queue=[],d._playLock=!1,d._onend=c.onend?[{fn:c.onend}]:[],d._onfade=c.onfade?[{fn:c.onfade}]:[],d._onload=c.onload?[{fn:c.onload}]:[],d._onloaderror=c.onloaderror?[{fn:c.onloaderror}]:[],d._onplayerror=c.onplayerror?[{fn:c.onplayerror}]:[],d._onpause=c.onpause?[{fn:c.onpause}]:[],d._onplay=c.onplay?[{fn:c.onplay}]:[],d._onstop=c.onstop?[{fn:c.onstop}]:[],d._onmute=c.onmute?[{fn:c.onmute}]:[],d._onvolume=c.onvolume?[{fn:c.onvolume}]:[],d._onrate=c.onrate?[{fn:c.onrate}]:[],d._onseek=c.onseek?[{fn:c.onseek}]:[],d._onunlock=c.onunlock?[{fn:c.onunlock}]:[],d._onresume=[],d._webAudio=t.usingWebAudio&&!d._html5,typeof t.ctx<"u"&&t.ctx&&t.autoUnlock&&t._unlockAudio(),t._howls.push(d),d._autoplay&&d._queue.push({event:"play",action:function(){d.play()}}),d._preload&&d._preload!=="none"&&d.load(),d},load:function(){var c=this,d=null;if(t.noAudio){c._emit("loaderror",null,"No audio support.");return}typeof c._src=="string"&&(c._src=[c._src]);for(var p=0;p<c._src.length;p++){var f,h;if(c._format&&c._format[p])f=c._format[p];else{if(h=c._src[p],typeof h!="string"){c._emit("loaderror",null,"Non-string found in selected audio sources - ignoring.");continue}f=/^data:audio\/([^;,]+);/i.exec(h),f||(f=/\.([^.]+)$/.exec(h.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&&t.codecs(f)){d=c._src[p];break}}if(!d){c._emit("loaderror",null,"No codec support for selected audio sources.");return}return c._src=d,c._state="loading",window.location.protocol==="https:"&&d.slice(0,5)==="http:"&&(c._html5=!0,c._webAudio=!1),new r(c),c._webAudio&&i(c),c},play:function(c,d){var p=this,f=null;if(typeof c=="number")f=c,c=null;else{if(typeof c=="string"&&p._state==="loaded"&&!p._sprite[c])return null;if(typeof c>"u"&&(c="__default",!p._playLock)){for(var h=0,m=0;m<p._sounds.length;m++)p._sounds[m]._paused&&!p._sounds[m]._ended&&(h++,f=p._sounds[m]._id);h===1?c=null:f=null}}var y=f?p._soundById(f):p._inactiveSound();if(!y)return null;if(f&&!c&&(c=y._sprite||"__default"),p._state!=="loaded"){y._sprite=c,y._ended=!1;var g=y._id;return p._queue.push({event:"play",action:function(){p.play(g)}}),g}if(f&&!y._paused)return d||p._loadQueue("play"),y._id;p._webAudio&&t._autoResume();var b=Math.max(0,y._seek>0?y._seek:p._sprite[c][0]/1e3),w=Math.max(0,(p._sprite[c][0]+p._sprite[c][1])/1e3-b),_=w*1e3/Math.abs(y._rate),S=p._sprite[c][0]/1e3,P=(p._sprite[c][0]+p._sprite[c][1])/1e3;y._sprite=c,y._ended=!1;var O=function(){y._paused=!1,y._seek=b,y._start=S,y._stop=P,y._loop=!!(y._loop||p._sprite[c][2])};if(b>=P){p._ended(y);return}var x=y._node;if(p._webAudio){var D=function(){p._playLock=!1,O(),p._refreshBuffer(y);var E=y._muted||p._muted?0:y._volume;x.gain.setValueAtTime(E,t.ctx.currentTime),y._playStart=t.ctx.currentTime,typeof x.bufferSource.start>"u"?y._loop?x.bufferSource.noteGrainOn(0,b,86400):x.bufferSource.noteGrainOn(0,b,w):y._loop?x.bufferSource.start(0,b,86400):x.bufferSource.start(0,b,w),_!==1/0&&(p._endTimers[y._id]=setTimeout(p._ended.bind(p,y),_)),d||setTimeout(function(){p._emit("play",y._id),p._loadQueue()},0)};t.state==="running"&&t.ctx.state!=="interrupted"?D():(p._playLock=!0,p.once("resume",D),p._clearTimer(y._id))}else{var N=function(){x.currentTime=b,x.muted=y._muted||p._muted||t._muted||x.muted,x.volume=y._volume*t.volume(),x.playbackRate=y._rate;try{var E=x.play();if(E&&typeof Promise<"u"&&(E instanceof Promise||typeof E.then=="function")?(p._playLock=!0,O(),E.then(function(){p._playLock=!1,x._unlocked=!0,d?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})):d||(p._playLock=!1,O(),p._emit("play",y._id)),x.playbackRate=y._rate,x.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}c!=="__default"||y._loop?p._endTimers[y._id]=setTimeout(p._ended.bind(p,y),_):(p._endTimers[y._id]=function(){p._ended(y),x.removeEventListener("ended",p._endTimers[y._id],!1)},x.addEventListener("ended",p._endTimers[y._id],!1))}catch(B){p._emit("playerror",y._id,B)}};x.src==="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA"&&(x.src=p._src,x.load());var T=window&&window.ejecta||!x.readyState&&t._navigator.isCocoonJS;if(x.readyState>=3||T)N();else{p._playLock=!0,p._state="loading";var I=function(){p._state="loaded",N(),x.removeEventListener(t._canPlayEvent,I,!1)};x.addEventListener(t._canPlayEvent,I,!1),p._clearTimer(y._id)}}return y._id},pause:function(c){var d=this;if(d._state!=="loaded"||d._playLock)return d._queue.push({event:"pause",action:function(){d.pause(c)}}),d;for(var p=d._getSoundIds(c),f=0;f<p.length;f++){d._clearTimer(p[f]);var h=d._soundById(p[f]);if(h&&!h._paused&&(h._seek=d.seek(p[f]),h._rateSeek=0,h._paused=!0,d._stopFade(p[f]),h._node))if(d._webAudio){if(!h._node.bufferSource)continue;typeof h._node.bufferSource.stop>"u"?h._node.bufferSource.noteOff(0):h._node.bufferSource.stop(0),d._cleanBuffer(h._node)}else(!isNaN(h._node.duration)||h._node.duration===1/0)&&h._node.pause();arguments[1]||d._emit("pause",h?h._id:null)}return d},stop:function(c,d){var p=this;if(p._state!=="loaded"||p._playLock)return p._queue.push({event:"stop",action:function(){p.stop(c)}}),p;for(var f=p._getSoundIds(c),h=0;h<f.length;h++){p._clearTimer(f[h]);var m=p._soundById(f[h]);m&&(m._seek=m._start||0,m._rateSeek=0,m._paused=!0,m._ended=!0,p._stopFade(f[h]),m._node&&(p._webAudio?m._node.bufferSource&&(typeof m._node.bufferSource.stop>"u"?m._node.bufferSource.noteOff(0):m._node.bufferSource.stop(0),p._cleanBuffer(m._node)):(!isNaN(m._node.duration)||m._node.duration===1/0)&&(m._node.currentTime=m._start||0,m._node.pause(),m._node.duration===1/0&&p._clearSound(m._node))),d||p._emit("stop",m._id))}return p},mute:function(c,d){var p=this;if(p._state!=="loaded"||p._playLock)return p._queue.push({event:"mute",action:function(){p.mute(c,d)}}),p;if(typeof d>"u")if(typeof c=="boolean")p._muted=c;else return p._muted;for(var f=p._getSoundIds(d),h=0;h<f.length;h++){var m=p._soundById(f[h]);m&&(m._muted=c,m._interval&&p._stopFade(m._id),p._webAudio&&m._node?m._node.gain.setValueAtTime(c?0:m._volume,t.ctx.currentTime):m._node&&(m._node.muted=t._muted?!0:c),p._emit("mute",m._id))}return p},volume:function(){var c=this,d=arguments,p,f;if(d.length===0)return c._volume;if(d.length===1||d.length===2&&typeof d[1]>"u"){var h=c._getSoundIds(),m=h.indexOf(d[0]);m>=0?f=parseInt(d[0],10):p=parseFloat(d[0])}else d.length>=2&&(p=parseFloat(d[0]),f=parseInt(d[1],10));var y;if(typeof p<"u"&&p>=0&&p<=1){if(c._state!=="loaded"||c._playLock)return c._queue.push({event:"volume",action:function(){c.volume.apply(c,d)}}),c;typeof f>"u"&&(c._volume=p),f=c._getSoundIds(f);for(var g=0;g<f.length;g++)y=c._soundById(f[g]),y&&(y._volume=p,d[2]||c._stopFade(f[g]),c._webAudio&&y._node&&!y._muted?y._node.gain.setValueAtTime(p,t.ctx.currentTime):y._node&&!y._muted&&(y._node.volume=p*t.volume()),c._emit("volume",y._id))}else return y=f?c._soundById(f):c._sounds[0],y?y._volume:0;return c},fade:function(c,d,p,f){var h=this;if(h._state!=="loaded"||h._playLock)return h._queue.push({event:"fade",action:function(){h.fade(c,d,p,f)}}),h;c=Math.min(Math.max(0,parseFloat(c)),1),d=Math.min(Math.max(0,parseFloat(d)),1),p=parseFloat(p),h.volume(c,f);for(var m=h._getSoundIds(f),y=0;y<m.length;y++){var g=h._soundById(m[y]);if(g){if(f||h._stopFade(m[y]),h._webAudio&&!g._muted){var b=t.ctx.currentTime,w=b+p/1e3;g._volume=c,g._node.gain.setValueAtTime(c,b),g._node.gain.linearRampToValueAtTime(d,w)}h._startFadeInterval(g,c,d,p,m[y],typeof f>"u")}}return h},_startFadeInterval:function(c,d,p,f,h,m){var y=this,g=d,b=p-d,w=Math.abs(b/.01),_=Math.max(4,w>0?f/w:f),S=Date.now();c._fadeTo=p,c._interval=setInterval(function(){var P=(Date.now()-S)/f;S=Date.now(),g+=b*P,g=Math.round(g*100)/100,b<0?g=Math.max(p,g):g=Math.min(p,g),y._webAudio?c._volume=g:y.volume(g,c._id,!0),m&&(y._volume=g),(p<d&&g<=p||p>d&&g>=p)&&(clearInterval(c._interval),c._interval=null,c._fadeTo=null,y.volume(p,c._id),y._emit("fade",c._id))},_)},_stopFade:function(c){var d=this,p=d._soundById(c);return p&&p._interval&&(d._webAudio&&p._node.gain.cancelScheduledValues(t.ctx.currentTime),clearInterval(p._interval),p._interval=null,d.volume(p._fadeTo,c),p._fadeTo=null,d._emit("fade",c)),d},loop:function(){var c=this,d=arguments,p,f,h;if(d.length===0)return c._loop;if(d.length===1)if(typeof d[0]=="boolean")p=d[0],c._loop=p;else return h=c._soundById(parseInt(d[0],10)),h?h._loop:!1;else d.length===2&&(p=d[0],f=parseInt(d[1],10));for(var m=c._getSoundIds(f),y=0;y<m.length;y++)h=c._soundById(m[y]),h&&(h._loop=p,c._webAudio&&h._node&&h._node.bufferSource&&(h._node.bufferSource.loop=p,p&&(h._node.bufferSource.loopStart=h._start||0,h._node.bufferSource.loopEnd=h._stop,c.playing(m[y])&&(c.pause(m[y],!0),c.play(m[y],!0)))));return c},rate:function(){var c=this,d=arguments,p,f;if(d.length===0)f=c._sounds[0]._id;else if(d.length===1){var h=c._getSoundIds(),m=h.indexOf(d[0]);m>=0?f=parseInt(d[0],10):p=parseFloat(d[0])}else d.length===2&&(p=parseFloat(d[0]),f=parseInt(d[1],10));var y;if(typeof p=="number"){if(c._state!=="loaded"||c._playLock)return c._queue.push({event:"rate",action:function(){c.rate.apply(c,d)}}),c;typeof f>"u"&&(c._rate=p),f=c._getSoundIds(f);for(var g=0;g<f.length;g++)if(y=c._soundById(f[g]),y){c.playing(f[g])&&(y._rateSeek=c.seek(f[g]),y._playStart=c._webAudio?t.ctx.currentTime:y._playStart),y._rate=p,c._webAudio&&y._node&&y._node.bufferSource?y._node.bufferSource.playbackRate.setValueAtTime(p,t.ctx.currentTime):y._node&&(y._node.playbackRate=p);var b=c.seek(f[g]),w=(c._sprite[y._sprite][0]+c._sprite[y._sprite][1])/1e3-b,_=w*1e3/Math.abs(y._rate);(c._endTimers[f[g]]||!y._paused)&&(c._clearTimer(f[g]),c._endTimers[f[g]]=setTimeout(c._ended.bind(c,y),_)),c._emit("rate",y._id)}}else return y=c._soundById(f),y?y._rate:c._rate;return c},seek:function(){var c=this,d=arguments,p,f;if(d.length===0)c._sounds.length&&(f=c._sounds[0]._id);else if(d.length===1){var h=c._getSoundIds(),m=h.indexOf(d[0]);m>=0?f=parseInt(d[0],10):c._sounds.length&&(f=c._sounds[0]._id,p=parseFloat(d[0]))}else d.length===2&&(p=parseFloat(d[0]),f=parseInt(d[1],10));if(typeof f>"u")return 0;if(typeof p=="number"&&(c._state!=="loaded"||c._playLock))return c._queue.push({event:"seek",action:function(){c.seek.apply(c,d)}}),c;var y=c._soundById(f);if(y)if(typeof p=="number"&&p>=0){var g=c.playing(f);g&&c.pause(f,!0),y._seek=p,y._ended=!1,c._clearTimer(f),!c._webAudio&&y._node&&!isNaN(y._node.duration)&&(y._node.currentTime=p);var b=function(){g&&c.play(f,!0),c._emit("seek",f)};if(g&&!c._webAudio){var w=function(){c._playLock?setTimeout(w,0):b()};setTimeout(w,0)}else b()}else if(c._webAudio){var _=c.playing(f)?t.ctx.currentTime-y._playStart:0,S=y._rateSeek?y._rateSeek-y._seek:0;return y._seek+(S+_*Math.abs(y._rate))}else return y._node.currentTime;return c},playing:function(c){var d=this;if(typeof c=="number"){var p=d._soundById(c);return p?!p._paused:!1}for(var f=0;f<d._sounds.length;f++)if(!d._sounds[f]._paused)return!0;return!1},duration:function(c){var d=this,p=d._duration,f=d._soundById(c);return f&&(p=d._sprite[f._sprite][1]/1e3),p},state:function(){return this._state},unload:function(){for(var c=this,d=c._sounds,p=0;p<d.length;p++)d[p]._paused||c.stop(d[p]._id),c._webAudio||(c._clearSound(d[p]._node),d[p]._node.removeEventListener("error",d[p]._errorFn,!1),d[p]._node.removeEventListener(t._canPlayEvent,d[p]._loadFn,!1),d[p]._node.removeEventListener("ended",d[p]._endFn,!1),t._releaseHtml5Audio(d[p]._node)),delete d[p]._node,c._clearTimer(d[p]._id);var f=t._howls.indexOf(c);f>=0&&t._howls.splice(f,1);var h=!0;for(p=0;p<t._howls.length;p++)if(t._howls[p]._src===c._src||c._src.indexOf(t._howls[p]._src)>=0){h=!1;break}return o&&h&&delete o[c._src],t.noAudio=!1,c._state="unloaded",c._sounds=[],c=null,null},on:function(c,d,p,f){var h=this,m=h["_on"+c];return typeof d=="function"&&m.push(f?{id:p,fn:d,once:f}:{id:p,fn:d}),h},off:function(c,d,p){var f=this,h=f["_on"+c],m=0;if(typeof d=="number"&&(p=d,d=null),d||p)for(m=0;m<h.length;m++){var y=p===h[m].id;if(d===h[m].fn&&y||!d&&y){h.splice(m,1);break}}else if(c)f["_on"+c]=[];else{var g=Object.keys(f);for(m=0;m<g.length;m++)g[m].indexOf("_on")===0&&Array.isArray(f[g[m]])&&(f[g[m]]=[])}return f},once:function(c,d,p){var f=this;return f.on(c,d,p,1),f},_emit:function(c,d,p){for(var f=this,h=f["_on"+c],m=h.length-1;m>=0;m--)(!h[m].id||h[m].id===d||c==="load")&&(setTimeout(function(y){y.call(this,d,p)}.bind(f,h[m].fn),0),h[m].once&&f.off(c,h[m].fn,h[m].id));return f._loadQueue(c),f},_loadQueue:function(c){var d=this;if(d._queue.length>0){var p=d._queue[0];p.event===c&&(d._queue.shift(),d._loadQueue()),c||p.action()}return d},_ended:function(c){var d=this,p=c._sprite;if(!d._webAudio&&c._node&&!c._node.paused&&!c._node.ended&&c._node.currentTime<c._stop)return setTimeout(d._ended.bind(d,c),100),d;var f=!!(c._loop||d._sprite[p][2]);if(d._emit("end",c._id),!d._webAudio&&f&&d.stop(c._id,!0).play(c._id),d._webAudio&&f){d._emit("play",c._id),c._seek=c._start||0,c._rateSeek=0,c._playStart=t.ctx.currentTime;var h=(c._stop-c._start)*1e3/Math.abs(c._rate);d._endTimers[c._id]=setTimeout(d._ended.bind(d,c),h)}return d._webAudio&&!f&&(c._paused=!0,c._ended=!0,c._seek=c._start||0,c._rateSeek=0,d._clearTimer(c._id),d._cleanBuffer(c._node),t._autoSuspend()),!d._webAudio&&!f&&d.stop(c._id,!0),d},_clearTimer:function(c){var d=this;if(d._endTimers[c]){if(typeof d._endTimers[c]!="function")clearTimeout(d._endTimers[c]);else{var p=d._soundById(c);p&&p._node&&p._node.removeEventListener("ended",d._endTimers[c],!1)}delete d._endTimers[c]}return d},_soundById:function(c){for(var d=this,p=0;p<d._sounds.length;p++)if(c===d._sounds[p]._id)return d._sounds[p];return null},_inactiveSound:function(){var c=this;c._drain();for(var d=0;d<c._sounds.length;d++)if(c._sounds[d]._ended)return c._sounds[d].reset();return new r(c)},_drain:function(){var c=this,d=c._pool,p=0,f=0;if(!(c._sounds.length<d)){for(f=0;f<c._sounds.length;f++)c._sounds[f]._ended&&p++;for(f=c._sounds.length-1;f>=0;f--){if(p<=d)return;c._sounds[f]._ended&&(c._webAudio&&c._sounds[f]._node&&c._sounds[f]._node.disconnect(0),c._sounds.splice(f,1),p--)}}},_getSoundIds:function(c){var d=this;if(typeof c>"u"){for(var p=[],f=0;f<d._sounds.length;f++)p.push(d._sounds[f]._id);return p}else return[c]},_refreshBuffer:function(c){var d=this;return c._node.bufferSource=t.ctx.createBufferSource(),c._node.bufferSource.buffer=o[d._src],c._panner?c._node.bufferSource.connect(c._panner):c._node.bufferSource.connect(c._node),c._node.bufferSource.loop=c._loop,c._loop&&(c._node.bufferSource.loopStart=c._start||0,c._node.bufferSource.loopEnd=c._stop||0),c._node.bufferSource.playbackRate.setValueAtTime(c._rate,t.ctx.currentTime),d},_cleanBuffer:function(c){var d=this,p=t._navigator&&t._navigator.vendor.indexOf("Apple")>=0;if(t._scratchBuffer&&c.bufferSource&&(c.bufferSource.onended=null,c.bufferSource.disconnect(0),p))try{c.bufferSource.buffer=t._scratchBuffer}catch{}return c.bufferSource=null,d},_clearSound:function(c){var d=/MSIE |Trident\//.test(t._navigator&&t._navigator.userAgent);d||(c.src="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA")}};var r=function(c){this._parent=c,this.init()};r.prototype={init:function(){var c=this,d=c._parent;return c._muted=d._muted,c._loop=d._loop,c._volume=d._volume,c._rate=d._rate,c._seek=0,c._paused=!0,c._ended=!0,c._sprite="__default",c._id=++t._counter,d._sounds.push(c),c.create(),c},create:function(){var c=this,d=c._parent,p=t._muted||c._muted||c._parent._muted?0:c._volume;return d._webAudio?(c._node=typeof t.ctx.createGain>"u"?t.ctx.createGainNode():t.ctx.createGain(),c._node.gain.setValueAtTime(p,t.ctx.currentTime),c._node.paused=!0,c._node.connect(t.masterGain)):t.noAudio||(c._node=t._obtainHtml5Audio(),c._errorFn=c._errorListener.bind(c),c._node.addEventListener("error",c._errorFn,!1),c._loadFn=c._loadListener.bind(c),c._node.addEventListener(t._canPlayEvent,c._loadFn,!1),c._endFn=c._endListener.bind(c),c._node.addEventListener("ended",c._endFn,!1),c._node.src=d._src,c._node.preload=d._preload===!0?"auto":d._preload,c._node.volume=p*t.volume(),c._node.load()),c},reset:function(){var c=this,d=c._parent;return c._muted=d._muted,c._loop=d._loop,c._volume=d._volume,c._rate=d._rate,c._seek=0,c._rateSeek=0,c._paused=!0,c._ended=!0,c._sprite="__default",c._id=++t._counter,c},_errorListener:function(){var c=this;c._parent._emit("loaderror",c._id,c._node.error?c._node.error.code:0),c._node.removeEventListener("error",c._errorFn,!1)},_loadListener:function(){var c=this,d=c._parent;d._duration=Math.ceil(c._node.duration*10)/10,Object.keys(d._sprite).length===0&&(d._sprite={__default:[0,d._duration*1e3]}),d._state!=="loaded"&&(d._state="loaded",d._emit("load"),d._loadQueue()),c._node.removeEventListener(t._canPlayEvent,c._loadFn,!1)},_endListener:function(){var c=this,d=c._parent;d._duration===1/0&&(d._duration=Math.ceil(c._node.duration*10)/10,d._sprite.__default[1]===1/0&&(d._sprite.__default[1]=d._duration*1e3),d._ended(c)),c._node.removeEventListener("ended",c._endFn,!1)}};var o={},i=function(c){var d=c._src;if(o[d]){c._duration=o[d].duration,l(c);return}if(/^data:[^;]+;base64,/.test(d)){for(var p=atob(d.split(",")[1]),f=new Uint8Array(p.length),h=0;h<p.length;++h)f[h]=p.charCodeAt(h);s(f.buffer,c)}else{var m=new XMLHttpRequest;m.open(c._xhr.method,d,!0),m.withCredentials=c._xhr.withCredentials,m.responseType="arraybuffer",c._xhr.headers&&Object.keys(c._xhr.headers).forEach(function(y){m.setRequestHeader(y,c._xhr.headers[y])}),m.onload=function(){var y=(m.status+"")[0];if(y!=="0"&&y!=="2"&&y!=="3"){c._emit("loaderror",null,"Failed loading audio file with status: "+m.status+".");return}s(m.response,c)},m.onerror=function(){c._webAudio&&(c._html5=!0,c._webAudio=!1,c._sounds=[],delete o[d],c.load())},a(m)}},a=function(c){try{c.send()}catch{c.onerror()}},s=function(c,d){var p=function(){d._emit("loaderror",null,"Decoding audio data failed.")},f=function(h){h&&d._sounds.length>0?(o[d._src]=h,l(d,h)):p()};typeof Promise<"u"&&t.ctx.decodeAudioData.length===1?t.ctx.decodeAudioData(c).then(f).catch(p):t.ctx.decodeAudioData(c,f,p)},l=function(c,d){d&&!c._duration&&(c._duration=d.duration),Object.keys(c._sprite).length===0&&(c._sprite={__default:[0,c._duration*1e3]}),c._state!=="loaded"&&(c._state="loaded",c._emit("load"),c._loadQueue())},u=function(){if(!!t.usingWebAudio){try{typeof AudioContext<"u"?t.ctx=new AudioContext:typeof webkitAudioContext<"u"?t.ctx=new webkitAudioContext:t.usingWebAudio=!1}catch{t.usingWebAudio=!1}t.ctx||(t.usingWebAudio=!1);var c=/iP(hone|od|ad)/.test(t._navigator&&t._navigator.platform),d=t._navigator&&t._navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/),p=d?parseInt(d[1],10):null;if(c&&p&&p<9){var f=/safari/.test(t._navigator&&t._navigator.userAgent.toLowerCase());t._navigator&&!f&&(t.usingWebAudio=!1)}t.usingWebAudio&&(t.masterGain=typeof t.ctx.createGain>"u"?t.ctx.createGainNode():t.ctx.createGain(),t.masterGain.gain.setValueAtTime(t._muted?0:t._volume,t.ctx.currentTime),t.masterGain.connect(t.ctx.destination)),t._setup()}};typeof define=="function"&&define.amd&&define([],function(){return{Howler:t,Howl:e}}),typeof Yu<"u"&&(Yu.Howler=t,Yu.Howl=e),typeof global<"u"?(global.HowlerGlobal=n,global.Howler=t,global.Howl=e,global.Sound=r):typeof window<"u"&&(window.HowlerGlobal=n,window.Howler=t,window.Howl=e,window.Sound=r)})();(function(){"use strict";HowlerGlobal.prototype._pos=[0,0,0],HowlerGlobal.prototype._orientation=[0,0,-1,0,1,0],HowlerGlobal.prototype.stereo=function(t){var e=this;if(!e.ctx||!e.ctx.listener)return e;for(var r=e._howls.length-1;r>=0;r--)e._howls[r].stereo(t);return e},HowlerGlobal.prototype.pos=function(t,e,r){var o=this;if(!o.ctx||!o.ctx.listener)return o;if(e=typeof e!="number"?o._pos[1]:e,r=typeof r!="number"?o._pos[2]:r,typeof t=="number")o._pos=[t,e,r],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(t,e,r,o,i,a){var s=this;if(!s.ctx||!s.ctx.listener)return s;var l=s._orientation;if(e=typeof e!="number"?l[1]:e,r=typeof r!="number"?l[2]:r,o=typeof o!="number"?l[3]:o,i=typeof i!="number"?l[4]:i,a=typeof a!="number"?l[5]:a,typeof t=="number")s._orientation=[t,e,r,o,i,a],typeof s.ctx.listener.forwardX<"u"?(s.ctx.listener.forwardX.setTargetAtTime(t,Howler.ctx.currentTime,.1),s.ctx.listener.forwardY.setTargetAtTime(e,Howler.ctx.currentTime,.1),s.ctx.listener.forwardZ.setTargetAtTime(r,Howler.ctx.currentTime,.1),s.ctx.listener.upX.setTargetAtTime(o,Howler.ctx.currentTime,.1),s.ctx.listener.upY.setTargetAtTime(i,Howler.ctx.currentTime,.1),s.ctx.listener.upZ.setTargetAtTime(a,Howler.ctx.currentTime,.1)):s.ctx.listener.setOrientation(t,e,r,o,i,a);else return l;return s},Howl.prototype.init=function(t){return function(e){var r=this;return r._orientation=e.orientation||[1,0,0],r._stereo=e.stereo||null,r._pos=e.pos||null,r._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},r._onstereo=e.onstereo?[{fn:e.onstereo}]:[],r._onpos=e.onpos?[{fn:e.onpos}]:[],r._onorientation=e.onorientation?[{fn:e.onorientation}]:[],t.call(this,e)}}(Howl.prototype.init),Howl.prototype.stereo=function(t,e){var r=this;if(!r._webAudio)return r;if(r._state!=="loaded")return r._queue.push({event:"stereo",action:function(){r.stereo(t,e)}}),r;var o=typeof Howler.ctx.createStereoPanner>"u"?"spatial":"stereo";if(typeof e>"u")if(typeof t=="number")r._stereo=t,r._pos=[t,0,0];else return r._stereo;for(var i=r._getSoundIds(e),a=0;a<i.length;a++){var s=r._soundById(i[a]);if(s)if(typeof t=="number")s._stereo=t,s._pos=[t,0,0],s._node&&(s._pannerAttr.panningModel="equalpower",(!s._panner||!s._panner.pan)&&n(s,o),o==="spatial"?typeof s._panner.positionX<"u"?(s._panner.positionX.setValueAtTime(t,Howler.ctx.currentTime),s._panner.positionY.setValueAtTime(0,Howler.ctx.currentTime),s._panner.positionZ.setValueAtTime(0,Howler.ctx.currentTime)):s._panner.setPosition(t,0,0):s._panner.pan.setValueAtTime(t,Howler.ctx.currentTime)),r._emit("stereo",s._id);else return s._stereo}return r},Howl.prototype.pos=function(t,e,r,o){var i=this;if(!i._webAudio)return i;if(i._state!=="loaded")return i._queue.push({event:"pos",action:function(){i.pos(t,e,r,o)}}),i;if(e=typeof e!="number"?0:e,r=typeof r!="number"?-.5:r,typeof o>"u")if(typeof t=="number")i._pos=[t,e,r];else return i._pos;for(var a=i._getSoundIds(o),s=0;s<a.length;s++){var l=i._soundById(a[s]);if(l)if(typeof t=="number")l._pos=[t,e,r],l._node&&((!l._panner||l._panner.pan)&&n(l,"spatial"),typeof l._panner.positionX<"u"?(l._panner.positionX.setValueAtTime(t,Howler.ctx.currentTime),l._panner.positionY.setValueAtTime(e,Howler.ctx.currentTime),l._panner.positionZ.setValueAtTime(r,Howler.ctx.currentTime)):l._panner.setPosition(t,e,r)),i._emit("pos",l._id);else return l._pos}return i},Howl.prototype.orientation=function(t,e,r,o){var i=this;if(!i._webAudio)return i;if(i._state!=="loaded")return i._queue.push({event:"orientation",action:function(){i.orientation(t,e,r,o)}}),i;if(e=typeof e!="number"?i._orientation[1]:e,r=typeof r!="number"?i._orientation[2]:r,typeof o>"u")if(typeof t=="number")i._orientation=[t,e,r];else return i._orientation;for(var a=i._getSoundIds(o),s=0;s<a.length;s++){var l=i._soundById(a[s]);if(l)if(typeof t=="number")l._orientation=[t,e,r],l._node&&(l._panner||(l._pos||(l._pos=i._pos||[0,0,-.5]),n(l,"spatial")),typeof l._panner.orientationX<"u"?(l._panner.orientationX.setValueAtTime(t,Howler.ctx.currentTime),l._panner.orientationY.setValueAtTime(e,Howler.ctx.currentTime),l._panner.orientationZ.setValueAtTime(r,Howler.ctx.currentTime)):l._panner.setOrientation(t,e,r)),i._emit("orientation",l._id);else return l._orientation}return i},Howl.prototype.pannerAttr=function(){var t=this,e=arguments,r,o,i;if(!t._webAudio)return t;if(e.length===0)return t._pannerAttr;if(e.length===1)if(typeof e[0]=="object")r=e[0],typeof o>"u"&&(r.pannerAttr||(r.pannerAttr={coneInnerAngle:r.coneInnerAngle,coneOuterAngle:r.coneOuterAngle,coneOuterGain:r.coneOuterGain,distanceModel:r.distanceModel,maxDistance:r.maxDistance,refDistance:r.refDistance,rolloffFactor:r.rolloffFactor,panningModel:r.panningModel}),t._pannerAttr={coneInnerAngle:typeof r.pannerAttr.coneInnerAngle<"u"?r.pannerAttr.coneInnerAngle:t._coneInnerAngle,coneOuterAngle:typeof r.pannerAttr.coneOuterAngle<"u"?r.pannerAttr.coneOuterAngle:t._coneOuterAngle,coneOuterGain:typeof r.pannerAttr.coneOuterGain<"u"?r.pannerAttr.coneOuterGain:t._coneOuterGain,distanceModel:typeof r.pannerAttr.distanceModel<"u"?r.pannerAttr.distanceModel:t._distanceModel,maxDistance:typeof r.pannerAttr.maxDistance<"u"?r.pannerAttr.maxDistance:t._maxDistance,refDistance:typeof r.pannerAttr.refDistance<"u"?r.pannerAttr.refDistance:t._refDistance,rolloffFactor:typeof r.pannerAttr.rolloffFactor<"u"?r.pannerAttr.rolloffFactor:t._rolloffFactor,panningModel:typeof r.pannerAttr.panningModel<"u"?r.pannerAttr.panningModel:t._panningModel});else return i=t._soundById(parseInt(e[0],10)),i?i._pannerAttr:t._pannerAttr;else e.length===2&&(r=e[0],o=parseInt(e[1],10));for(var a=t._getSoundIds(o),s=0;s<a.length;s++)if(i=t._soundById(a[s]),i){var l=i._pannerAttr;l={coneInnerAngle:typeof r.coneInnerAngle<"u"?r.coneInnerAngle:l.coneInnerAngle,coneOuterAngle:typeof r.coneOuterAngle<"u"?r.coneOuterAngle:l.coneOuterAngle,coneOuterGain:typeof r.coneOuterGain<"u"?r.coneOuterGain:l.coneOuterGain,distanceModel:typeof r.distanceModel<"u"?r.distanceModel:l.distanceModel,maxDistance:typeof r.maxDistance<"u"?r.maxDistance:l.maxDistance,refDistance:typeof r.refDistance<"u"?r.refDistance:l.refDistance,rolloffFactor:typeof r.rolloffFactor<"u"?r.rolloffFactor:l.rolloffFactor,panningModel:typeof r.panningModel<"u"?r.panningModel:l.panningModel};var u=i._panner;u?(u.coneInnerAngle=l.coneInnerAngle,u.coneOuterAngle=l.coneOuterAngle,u.coneOuterGain=l.coneOuterGain,u.distanceModel=l.distanceModel,u.maxDistance=l.maxDistance,u.refDistance=l.refDistance,u.rolloffFactor=l.rolloffFactor,u.panningModel=l.panningModel):(i._pos||(i._pos=t._pos||[0,0,-.5]),n(i,"spatial"))}return t},Sound.prototype.init=function(t){return function(){var e=this,r=e._parent;e._orientation=r._orientation,e._stereo=r._stereo,e._pos=r._pos,e._pannerAttr=r._pannerAttr,t.call(this),e._stereo?r.stereo(e._stereo):e._pos&&r.pos(e._pos[0],e._pos[1],e._pos[2],e._id)}}(Sound.prototype.init),Sound.prototype.reset=function(t){return function(){var e=this,r=e._parent;return e._orientation=r._orientation,e._stereo=r._stereo,e._pos=r._pos,e._pannerAttr=r._pannerAttr,e._stereo?r.stereo(e._stereo):e._pos?r.pos(e._pos[0],e._pos[1],e._pos[2],e._id):e._panner&&(e._panner.disconnect(0),e._panner=void 0,r._refreshBuffer(e)),t.call(this)}}(Sound.prototype.reset);var n=function(t,e){e=e||"spatial",e==="spatial"?(t._panner=Howler.ctx.createPanner(),t._panner.coneInnerAngle=t._pannerAttr.coneInnerAngle,t._panner.coneOuterAngle=t._pannerAttr.coneOuterAngle,t._panner.coneOuterGain=t._pannerAttr.coneOuterGain,t._panner.distanceModel=t._pannerAttr.distanceModel,t._panner.maxDistance=t._pannerAttr.maxDistance,t._panner.refDistance=t._pannerAttr.refDistance,t._panner.rolloffFactor=t._pannerAttr.rolloffFactor,t._panner.panningModel=t._pannerAttr.panningModel,typeof t._panner.positionX<"u"?(t._panner.positionX.setValueAtTime(t._pos[0],Howler.ctx.currentTime),t._panner.positionY.setValueAtTime(t._pos[1],Howler.ctx.currentTime),t._panner.positionZ.setValueAtTime(t._pos[2],Howler.ctx.currentTime)):t._panner.setPosition(t._pos[0],t._pos[1],t._pos[2]),typeof t._panner.orientationX<"u"?(t._panner.orientationX.setValueAtTime(t._orientation[0],Howler.ctx.currentTime),t._panner.orientationY.setValueAtTime(t._orientation[1],Howler.ctx.currentTime),t._panner.orientationZ.setValueAtTime(t._orientation[2],Howler.ctx.currentTime)):t._panner.setOrientation(t._orientation[0],t._orientation[1],t._orientation[2])):(t._panner=Howler.ctx.createStereoPanner(),t._panner.pan.setValueAtTime(t._stereo,Howler.ctx.currentTime)),t._panner.connect(t._node),t._paused||t._parent.pause(t._id,!0).play(t._id,!0)}})()});var Yv=Zt((Rae,$v)=>{"use strict";function ZN(n,t){function e(){this.constructor=n}e.prototype=t.prototype,n.prototype=new e}function Ai(n,t,e,r){this.message=n,this.expected=t,this.found=e,this.location=r,this.name="SyntaxError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,Ai)}ZN(Ai,Error);Ai.buildMessage=function(n,t){var e={literal:function(u){return'"'+o(u.text)+'"'},class:function(u){var c="",d;for(d=0;d<u.parts.length;d++)c+=u.parts[d]instanceof Array?i(u.parts[d][0])+"-"+i(u.parts[d][1]):i(u.parts[d]);return"["+(u.inverted?"^":"")+c+"]"},any:function(u){return"any character"},end:function(u){return"end of input"},other:function(u){return u.description}};function r(u){return u.charCodeAt(0).toString(16).toUpperCase()}function o(u){return u.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(c){return"\\x0"+r(c)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(c){return"\\x"+r(c)})}function i(u){return u.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(c){return"\\x0"+r(c)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(c){return"\\x"+r(c)})}function a(u){return e[u.type](u)}function s(u){var c=new Array(u.length),d,p;for(d=0;d<u.length;d++)c[d]=a(u[d]);if(c.sort(),c.length>0){for(d=1,p=1;d<c.length;d++)c[d-1]!==c[d]&&(c[p]=c[d],p++);c.length=p}switch(c.length){case 1:return c[0];case 2:return c[0]+" or "+c[1];default:return c.slice(0,-1).join(", ")+", or "+c[c.length-1]}}function l(u){return u?'"'+o(u)+'"':"end of input"}return"Expected "+s(n)+" but "+l(t)+" found."};function JN(n,t){t=t!==void 0?t:{};var e={},r={svg_path:Bs},o=Bs,i=function(v){if(!v)return[];for(var A=[],L=0;L<v.length;L++)A=A.concat.apply(A,v[L]);var M=A[0];return M&&M.code=="m"&&(delete M.relative,M.code="M"),A},a=function(v,A){return j1(v,A)},s=/^[Mm]/,l=Ke(["M","m"],!1,!1),u=function(v,A,L){var M=Di(v,[A]);return L&&(M=M.concat(Di(v=="M"?"L":"l",L[1]))),M},c=/^[Zz]/,d=Ke(["Z","z"],!1,!1),p=function(){return Di("Z")},f=/^[Ll]/,h=Ke(["L","l"],!1,!1),m=function(v,A){return Di(v,A)},y=/^[Hh]/,g=Ke(["H","h"],!1,!1),b=function(v,A){return Di(v,A.map(function(L){return{x:L}}))},w=/^[Vv]/,_=Ke(["V","v"],!1,!1),S=function(v,A){return Di(v,A.map(function(L){return{y:L}}))},P=/^[Cc]/,O=Ke(["C","c"],!1,!1),x=function(v,A,L){return{x1:v.x,y1:v.y,x2:A.x,y2:A.y,x:L.x,y:L.y}},D=/^[Ss]/,N=Ke(["S","s"],!1,!1),T=function(v,A){return{x2:v.x,y2:v.y,x:A.x,y:A.y}},I=/^[Qq]/,E=Ke(["Q","q"],!1,!1),B=function(v,A){return{x1:v.x,y1:v.y,x:A.x,y:A.y}},R=/^[Tt]/,F=Ke(["T","t"],!1,!1),V=/^[Aa]/,q=Ke(["A","a"],!1,!1),k=function(v,A,L,M,z,oe){return{rx:v,ry:A,xAxisRotation:L,largeArc:M,sweep:z,x:oe.x,y:oe.y}},U=function(v,A){return{x:v,y:A}},H=function(v){return v*1},$=function(v){return v.join("")*1},J=/^[01]/,K=Ke(["0","1"],!1,!1),X=function(v){return v=="1"},te=function(){return""},Y=",",ee=st(",",!1),Q=function(v){return v.join("")},W=".",ue=st(".",!1),le=/^[eE]/,ne=Ke(["e","E"],!1,!1),ce=/^[+\-]/,ae=Ke(["+","-"],!1,!1),he=/^[0-9]/,pe=Ke([["0","9"]],!1,!1),fe=function(v){return v.join("")},ge=/^[ \t\n\r]/,me=Ke([" "," ",`
2
- `,"\r"],!1,!1),C=0,ie=0,De=[{line:1,column:1}],Ge=0,Ee=[],_e=0,Ct;if("startRule"in t){if(!(t.startRule in r))throw new Error(`Can't start parsing from rule "`+t.startRule+'".');o=r[t.startRule]}function Me(){return n.substring(ie,C)}function At(){return $n(ie,C)}function Tt(v,A){throw A=A!==void 0?A:$n(ie,C),Cr([Dd(v)],n.substring(ie,C),A)}function Wn(v,A){throw A=A!==void 0?A:$n(ie,C),Ed(v,A)}function st(v,A){return{type:"literal",text:v,ignoreCase:A}}function Ke(v,A,L){return{type:"class",parts:v,inverted:A,ignoreCase:L}}function kr(){return{type:"any"}}function Nd(){return{type:"end"}}function Dd(v){return{type:"other",description:v}}function jl(v){var A=De[v],L;if(A)return A;for(L=v-1;!De[L];)L--;for(A=De[L],A={line:A.line,column:A.column};L<v;)n.charCodeAt(L)===10?(A.line++,A.column=1):A.column++,L++;return De[v]=A,A}function $n(v,A){var L=jl(v),M=jl(A);return{start:{offset:v,line:L.line,column:L.column},end:{offset:A,line:M.line,column:M.column}}}function mt(v){C<Ge||(C>Ge&&(Ge=C,Ee=[]),Ee.push(v))}function Ed(v,A){return new Ai(v,null,null,A)}function Cr(v,A,L){return new Ai(Ai.buildMessage(v,A),v,A,L)}function Bs(){var v,A,L,M,z;for(v=C,A=[],L=Fe();L!==e;)A.push(L),L=Fe();if(A!==e)if(L=Kt(),L===e&&(L=null),L!==e){for(M=[],z=Fe();z!==e;)M.push(z),z=Fe();M!==e?(ie=v,A=i(L),v=A):(C=v,v=e)}else C=v,v=e;else C=v,v=e;return v}function Kt(){var v,A,L,M,z,oe;if(v=C,A=Yn(),A!==e){for(L=[],M=C,z=[],oe=Fe();oe!==e;)z.push(oe),oe=Fe();for(z!==e?(oe=Yn(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);M!==e;){for(L.push(M),M=C,z=[],oe=Fe();oe!==e;)z.push(oe),oe=Fe();z!==e?(oe=Yn(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e)}L!==e?(ie=v,A=a(A,L),v=A):(C=v,v=e)}else C=v,v=e;return v}function Yn(){var v,A,L,M,z,oe;if(v=C,A=Ii(),A!==e){for(L=[],M=C,z=[],oe=Fe();oe!==e;)z.push(oe),oe=Fe();for(z!==e?(oe=Ul(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);M!==e;){for(L.push(M),M=C,z=[],oe=Fe();oe!==e;)z.push(oe),oe=Fe();z!==e?(oe=Ul(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e)}L!==e?(ie=v,A=a(A,L),v=A):(C=v,v=e)}else C=v,v=e;return v}function Ul(){var v;return v=C1(),v===e&&(v=T1(),v===e&&(v=M1(),v===e&&(v=I1(),v===e&&(v=N1(),v===e&&(v=E1(),v===e&&(v=L1(),v===e&&(v=V1(),v===e&&(v=G1())))))))),v}function Ii(){var v,A,L,M,z,oe,Ei;if(v=C,s.test(n.charAt(C))?(A=n.charAt(C),C++):(A=e,_e===0&&mt(l)),A!==e){for(L=[],M=Fe();M!==e;)L.push(M),M=Fe();L!==e?(M=tr(),M!==e?(z=C,oe=nt(),oe===e&&(oe=null),oe!==e?(Ei=$h(),Ei!==e?(oe=[oe,Ei],z=oe):(C=z,z=e)):(C=z,z=e),z===e&&(z=null),z!==e?(ie=v,A=u(A,M,z),v=A):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function C1(){var v,A;return v=C,c.test(n.charAt(C))?(A=n.charAt(C),C++):(A=e,_e===0&&mt(d)),A!==e&&(ie=v,A=p()),v=A,v}function T1(){var v,A,L,M;if(v=C,f.test(n.charAt(C))?(A=n.charAt(C),C++):(A=e,_e===0&&mt(h)),A!==e){for(L=[],M=Fe();M!==e;)L.push(M),M=Fe();L!==e?(M=$h(),M!==e?(ie=v,A=m(A,M),v=A):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function $h(){var v,A,L,M,z,oe;if(v=C,A=tr(),A!==e){for(L=[],M=C,z=nt(),z===e&&(z=null),z!==e?(oe=tr(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);M!==e;)L.push(M),M=C,z=nt(),z===e&&(z=null),z!==e?(oe=tr(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);L!==e?(ie=v,A=a(A,L),v=A):(C=v,v=e)}else C=v,v=e;return v}function M1(){var v,A,L,M;if(v=C,y.test(n.charAt(C))?(A=n.charAt(C),C++):(A=e,_e===0&&mt(g)),A!==e){for(L=[],M=Fe();M!==e;)L.push(M),M=Fe();L!==e?(M=Yh(),M!==e?(ie=v,A=b(A,M),v=A):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function Yh(){var v,A,L,M,z,oe;if(v=C,A=Ni(),A!==e){for(L=[],M=C,z=nt(),z===e&&(z=null),z!==e?(oe=Ni(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);M!==e;)L.push(M),M=C,z=nt(),z===e&&(z=null),z!==e?(oe=Ni(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);L!==e?(ie=v,A=a(A,L),v=A):(C=v,v=e)}else C=v,v=e;return v}function I1(){var v,A,L,M;if(v=C,w.test(n.charAt(C))?(A=n.charAt(C),C++):(A=e,_e===0&&mt(_)),A!==e){for(L=[],M=Fe();M!==e;)L.push(M),M=Fe();L!==e?(M=Yh(),M!==e?(ie=v,A=S(A,M),v=A):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function N1(){var v,A,L,M;if(v=C,P.test(n.charAt(C))?(A=n.charAt(C),C++):(A=e,_e===0&&mt(O)),A!==e){for(L=[],M=Fe();M!==e;)L.push(M),M=Fe();L!==e?(M=D1(),M!==e?(ie=v,A=m(A,M),v=A):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function D1(){var v,A,L,M,z,oe;if(v=C,A=Bd(),A!==e){for(L=[],M=C,z=nt(),z===e&&(z=null),z!==e?(oe=Bd(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);M!==e;)L.push(M),M=C,z=nt(),z===e&&(z=null),z!==e?(oe=Bd(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);L!==e?(ie=v,A=a(A,L),v=A):(C=v,v=e)}else C=v,v=e;return v}function Bd(){var v,A,L,M,z,oe;return v=C,A=tr(),A!==e?(L=nt(),L===e&&(L=null),L!==e?(M=tr(),M!==e?(z=nt(),z===e&&(z=null),z!==e?(oe=tr(),oe!==e?(ie=v,A=x(A,M,oe),v=A):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e),v}function E1(){var v,A,L,M;if(v=C,D.test(n.charAt(C))?(A=n.charAt(C),C++):(A=e,_e===0&&mt(N)),A!==e){for(L=[],M=Fe();M!==e;)L.push(M),M=Fe();L!==e?(M=B1(),M!==e?(ie=v,A=m(A,M),v=A):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function B1(){var v,A,L,M,z,oe;if(v=C,A=Ld(),A!==e){for(L=[],M=C,z=nt(),z===e&&(z=null),z!==e?(oe=Ld(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);M!==e;)L.push(M),M=C,z=nt(),z===e&&(z=null),z!==e?(oe=Ld(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);L!==e?(ie=v,A=a(A,L),v=A):(C=v,v=e)}else C=v,v=e;return v}function Ld(){var v,A,L,M;return v=C,A=tr(),A!==e?(L=nt(),L===e&&(L=null),L!==e?(M=tr(),M!==e?(ie=v,A=T(A,M),v=A):(C=v,v=e)):(C=v,v=e)):(C=v,v=e),v}function L1(){var v,A,L,M;if(v=C,I.test(n.charAt(C))?(A=n.charAt(C),C++):(A=e,_e===0&&mt(E)),A!==e){for(L=[],M=Fe();M!==e;)L.push(M),M=Fe();L!==e?(M=R1(),M!==e?(ie=v,A=m(A,M),v=A):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function R1(){var v,A,L,M,z,oe;if(v=C,A=Rd(),A!==e){for(L=[],M=C,z=nt(),z===e&&(z=null),z!==e?(oe=Rd(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);M!==e;)L.push(M),M=C,z=nt(),z===e&&(z=null),z!==e?(oe=Rd(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);L!==e?(ie=v,A=a(A,L),v=A):(C=v,v=e)}else C=v,v=e;return v}function Rd(){var v,A,L,M;return v=C,A=tr(),A!==e?(L=nt(),L===e&&(L=null),L!==e?(M=tr(),M!==e?(ie=v,A=B(A,M),v=A):(C=v,v=e)):(C=v,v=e)):(C=v,v=e),v}function V1(){var v,A,L,M;if(v=C,R.test(n.charAt(C))?(A=n.charAt(C),C++):(A=e,_e===0&&mt(F)),A!==e){for(L=[],M=Fe();M!==e;)L.push(M),M=Fe();L!==e?(M=z1(),M!==e?(ie=v,A=m(A,M),v=A):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function z1(){var v,A,L,M,z,oe;if(v=C,A=tr(),A!==e){for(L=[],M=C,z=nt(),z===e&&(z=null),z!==e?(oe=tr(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);M!==e;)L.push(M),M=C,z=nt(),z===e&&(z=null),z!==e?(oe=tr(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);L!==e?(ie=v,A=a(A,L),v=A):(C=v,v=e)}else C=v,v=e;return v}function G1(){var v,A,L,M;if(v=C,V.test(n.charAt(C))?(A=n.charAt(C),C++):(A=e,_e===0&&mt(q)),A!==e){for(L=[],M=Fe();M!==e;)L.push(M),M=Fe();L!==e?(M=F1(),M!==e?(ie=v,A=m(A,M),v=A):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function F1(){var v,A,L,M,z,oe;if(v=C,A=Vd(),A!==e){for(L=[],M=C,z=nt(),z===e&&(z=null),z!==e?(oe=Vd(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);M!==e;)L.push(M),M=C,z=nt(),z===e&&(z=null),z!==e?(oe=Vd(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);L!==e?(ie=v,A=a(A,L),v=A):(C=v,v=e)}else C=v,v=e;return v}function Vd(){var v,A,L,M,z,oe,Ei,Gd,ql,Fd,Wl,kd;return v=C,A=Xh(),A!==e?(L=nt(),L===e&&(L=null),L!==e?(M=Xh(),M!==e?(z=nt(),z===e&&(z=null),z!==e?(oe=Ni(),oe!==e?(Ei=nt(),Ei!==e?(Gd=Qh(),Gd!==e?(ql=nt(),ql===e&&(ql=null),ql!==e?(Fd=Qh(),Fd!==e?(Wl=nt(),Wl===e&&(Wl=null),Wl!==e?(kd=tr(),kd!==e?(ie=v,A=k(A,M,oe,Gd,Fd,kd),v=A):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e),v}function tr(){var v,A,L,M;return v=C,A=Ni(),A!==e?(L=nt(),L===e&&(L=null),L!==e?(M=Ni(),M!==e?(ie=v,A=U(A,M),v=A):(C=v,v=e)):(C=v,v=e)):(C=v,v=e),v}function Xh(){var v,A;return v=C,A=Zh(),A===e&&(A=Xn()),A!==e&&(ie=v,A=H(A)),v=A,v}function Ni(){var v,A,L,M;return v=C,A=C,L=zd(),L===e&&(L=null),L!==e?(M=Zh(),M!==e?(L=[L,M],A=L):(C=A,A=e)):(C=A,A=e),A===e&&(A=C,L=zd(),L===e&&(L=null),L!==e?(M=Xn(),M!==e?(L=[L,M],A=L):(C=A,A=e)):(C=A,A=e)),A!==e&&(ie=v,A=$(A)),v=A,v}function Qh(){var v,A;return v=C,J.test(n.charAt(C))?(A=n.charAt(C),C++):(A=e,_e===0&&mt(K)),A!==e&&(ie=v,A=X(A)),v=A,v}function nt(){var v,A,L,M,z;if(v=C,A=[],L=Fe(),L!==e)for(;L!==e;)A.push(L),L=Fe();else A=e;if(A!==e)if(L=Kh(),L===e&&(L=null),L!==e){for(M=[],z=Fe();z!==e;)M.push(z),z=Fe();M!==e?(A=[A,L,M],v=A):(C=v,v=e)}else C=v,v=e;else C=v,v=e;if(v===e){if(v=C,A=C,L=Kh(),L!==e){for(M=[],z=Fe();z!==e;)M.push(z),z=Fe();M!==e?(L=[L,M],A=L):(C=A,A=e)}else C=A,A=e;A!==e&&(ie=v,A=te()),v=A}return v}function Kh(){var v;return n.charCodeAt(C)===44?(v=Y,C++):(v=e,_e===0&&mt(ee)),v}function Zh(){var v,A,L,M;return v=C,A=C,L=k1(),L!==e?(M=Jh(),M===e&&(M=null),M!==e?(L=[L,M],A=L):(C=A,A=e)):(C=A,A=e),A===e&&(A=C,L=Xn(),L!==e?(M=Jh(),M!==e?(L=[L,M],A=L):(C=A,A=e)):(C=A,A=e)),A!==e&&(ie=v,A=Q(A)),v=A,v}function k1(){var v,A,L,M,z;return v=C,A=C,L=Xn(),L===e&&(L=null),L!==e?(n.charCodeAt(C)===46?(M=W,C++):(M=e,_e===0&&mt(ue)),M!==e?(z=Xn(),z!==e?(L=[L,M,z],A=L):(C=A,A=e)):(C=A,A=e)):(C=A,A=e),A===e&&(A=C,L=Xn(),L!==e?(n.charCodeAt(C)===46?(M=W,C++):(M=e,_e===0&&mt(ue)),M!==e?(L=[L,M],A=L):(C=A,A=e)):(C=A,A=e)),A!==e&&(ie=v,A=Q(A)),v=A,v}function Jh(){var v,A,L,M,z;return v=C,A=C,le.test(n.charAt(C))?(L=n.charAt(C),C++):(L=e,_e===0&&mt(ne)),L!==e?(M=zd(),M===e&&(M=null),M!==e?(z=Xn(),z!==e?(L=[L,M,z],A=L):(C=A,A=e)):(C=A,A=e)):(C=A,A=e),A!==e&&(ie=v,A=Q(A)),v=A,v}function zd(){var v;return ce.test(n.charAt(C))?(v=n.charAt(C),C++):(v=e,_e===0&&mt(ae)),v}function Xn(){var v,A,L;if(v=C,A=[],he.test(n.charAt(C))?(L=n.charAt(C),C++):(L=e,_e===0&&mt(pe)),L!==e)for(;L!==e;)A.push(L),he.test(n.charAt(C))?(L=n.charAt(C),C++):(L=e,_e===0&&mt(pe));else A=e;return A!==e&&(ie=v,A=fe(A)),v=A,v}function Fe(){var v,A;return v=C,ge.test(n.charAt(C))?(A=n.charAt(C),C++):(A=e,_e===0&&mt(me)),A!==e&&(ie=v,A=te()),v=A,v}function j1(v,A){if(!A)return[v];for(var L=[v],M=0,z=A.length;M<z;M++)L[M+1]=A[M][1];return L}var Hl={m:"moveto",l:"lineto",h:"horizontal lineto",v:"vertical lineto",c:"curveto",s:"smooth curveto",q:"quadratic curveto",t:"smooth quadratic curveto",a:"elliptical arc",z:"closepath"};for(var em in Hl)Hl[em.toUpperCase()]=Hl[em];function Di(v,A){A||(A=[{}]);for(var L=A.length;L--;){var M={code:v,command:Hl[v]};v==v.toLowerCase()&&(M.relative=!0);for(var z in A[L])M[z]=A[L][z];A[L]=M}return A}if(Ct=o(),Ct!==e&&C===n.length)return Ct;throw Ct!==e&&C<n.length&&mt(Nd()),Cr(Ee,Ge<n.length?n.charAt(Ge):null,Ge<n.length?$n(Ge,Ge+1):$n(Ge,Ge))}$v.exports={SyntaxError:Ai,parse:JN}});var Ph=Zt((Vae,Xv)=>{var hd=Yv().parse;hd.parseSVG=hd;hd.makeAbsolute=eD;Xv.exports=hd;function eD(n){var t,e={x:0,y:0},r={x:"x0",y:"y0",x1:"x0",y1:"y0",x2:"x0",y2:"y0"};return n.forEach(function(o){o.command==="moveto"&&(t=o),o.x0=e.x,o.y0=e.y;for(var i in r)i in o&&(o[i]+=o.relative?o[r[i]]:0);"x"in o||(o.x=e.x),"y"in o||(o.y=e.y),o.relative=!1,o.code=o.code.toUpperCase(),o.command=="closepath"&&(o.x=t.x,o.y=t.y),e=o}),n}});var DS=Zt((gde,NS)=>{"use strict";function YD(n){for(var t=new Array(n),e=0;e<n;++e)t[e]=e;return t}NS.exports=YD});var LS=Zt((xde,BS)=>{BS.exports=function(n){return n!=null&&(ES(n)||XD(n)||!!n._isBuffer)};function ES(n){return!!n.constructor&&typeof n.constructor.isBuffer=="function"&&n.constructor.isBuffer(n)}function XD(n){return typeof n.readFloatLE=="function"&&typeof n.slice=="function"&&ES(n.slice(0,0))}});var Ns=Zt((bde,RS)=>{var QD=DS(),KD=LS(),ZD=typeof Float64Array<"u";function JD(n,t){return n[0]-t[0]}function eE(){var n=this.stride,t=new Array(n.length),e;for(e=0;e<t.length;++e)t[e]=[Math.abs(n[e]),e];t.sort(JD);var r=new Array(t.length);for(e=0;e<r.length;++e)r[e]=t[e][1];return r}function tE(n,t){var e=["View",t,"d",n].join("");t<0&&(e="View_Nil"+n);var r=n==="generic";if(t===-1){var o="function "+e+"(a){this.data=a;};var proto="+e+".prototype;proto.dtype='"+n+"';proto.index=function(){return -1};proto.size=0;proto.dimension=-1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function(){return new "+e+"(this.data);};proto.get=proto.set=function(){};proto.pick=function(){return null};return function construct_"+e+"(a){return new "+e+"(a);}",m=new Function(o);return m()}else if(t===0){var o="function "+e+"(a,d) {this.data = a;this.offset = d};var proto="+e+".prototype;proto.dtype='"+n+"';proto.index=function(){return this.offset};proto.dimension=0;proto.size=1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function "+e+"_copy() {return new "+e+"(this.data,this.offset)};proto.pick=function "+e+"_pick(){return TrivialArray(this.data);};proto.valueOf=proto.get=function "+e+"_get(){return "+(r?"this.data.get(this.offset)":"this.data[this.offset]")+"};proto.set=function "+e+"_set(v){return "+(r?"this.data.set(this.offset,v)":"this.data[this.offset]=v")+"};return function construct_"+e+"(a,b,c,d){return new "+e+"(a,d)}",m=new Function("TrivialArray",o);return m(Pd[n][0])}var o=["'use strict'"],i=QD(t),a=i.map(function(y){return"i"+y}),s="this.offset+"+i.map(function(y){return"this.stride["+y+"]*i"+y}).join("+"),l=i.map(function(y){return"b"+y}).join(","),u=i.map(function(y){return"c"+y}).join(",");o.push("function "+e+"(a,"+l+","+u+",d){this.data=a","this.shape=["+l+"]","this.stride=["+u+"]","this.offset=d|0}","var proto="+e+".prototype","proto.dtype='"+n+"'","proto.dimension="+t),o.push("Object.defineProperty(proto,'size',{get:function "+e+"_size(){return "+i.map(function(y){return"this.shape["+y+"]"}).join("*"),"}})"),t===1?o.push("proto.order=[0]"):(o.push("Object.defineProperty(proto,'order',{get:"),t<4?(o.push("function "+e+"_order(){"),t===2?o.push("return (Math.abs(this.stride[0])>Math.abs(this.stride[1]))?[1,0]:[0,1]}})"):t===3&&o.push("var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);if(s0>s1){if(s1>s2){return [2,1,0];}else if(s0>s2){return [1,2,0];}else{return [1,0,2];}}else if(s0>s2){return [2,0,1];}else if(s2>s1){return [0,1,2];}else{return [0,2,1];}}})")):o.push("ORDER})")),o.push("proto.set=function "+e+"_set("+a.join(",")+",v){"),r?o.push("return this.data.set("+s+",v)}"):o.push("return this.data["+s+"]=v}"),o.push("proto.get=function "+e+"_get("+a.join(",")+"){"),r?o.push("return this.data.get("+s+")}"):o.push("return this.data["+s+"]}"),o.push("proto.index=function "+e+"_index(",a.join(),"){return "+s+"}"),o.push("proto.hi=function "+e+"_hi("+a.join(",")+"){return new "+e+"(this.data,"+i.map(function(y){return["(typeof i",y,"!=='number'||i",y,"<0)?this.shape[",y,"]:i",y,"|0"].join("")}).join(",")+","+i.map(function(y){return"this.stride["+y+"]"}).join(",")+",this.offset)}");var c=i.map(function(y){return"a"+y+"=this.shape["+y+"]"}),d=i.map(function(y){return"c"+y+"=this.stride["+y+"]"});o.push("proto.lo=function "+e+"_lo("+a.join(",")+"){var b=this.offset,d=0,"+c.join(",")+","+d.join(","));for(var p=0;p<t;++p)o.push("if(typeof i"+p+"==='number'&&i"+p+">=0){d=i"+p+"|0;b+=c"+p+"*d;a"+p+"-=d}");o.push("return new "+e+"(this.data,"+i.map(function(y){return"a"+y}).join(",")+","+i.map(function(y){return"c"+y}).join(",")+",b)}"),o.push("proto.step=function "+e+"_step("+a.join(",")+"){var "+i.map(function(y){return"a"+y+"=this.shape["+y+"]"}).join(",")+","+i.map(function(y){return"b"+y+"=this.stride["+y+"]"}).join(",")+",c=this.offset,d=0,ceil=Math.ceil");for(var p=0;p<t;++p)o.push("if(typeof i"+p+"==='number'){d=i"+p+"|0;if(d<0){c+=b"+p+"*(a"+p+"-1);a"+p+"=ceil(-a"+p+"/d)}else{a"+p+"=ceil(a"+p+"/d)}b"+p+"*=d}");o.push("return new "+e+"(this.data,"+i.map(function(y){return"a"+y}).join(",")+","+i.map(function(y){return"b"+y}).join(",")+",c)}");for(var f=new Array(t),h=new Array(t),p=0;p<t;++p)f[p]="a[i"+p+"]",h[p]="b[i"+p+"]";o.push("proto.transpose=function "+e+"_transpose("+a+"){"+a.map(function(y,g){return y+"=("+y+"===undefined?"+g+":"+y+"|0)"}).join(";"),"var a=this.shape,b=this.stride;return new "+e+"(this.data,"+f.join(",")+","+h.join(",")+",this.offset)}"),o.push("proto.pick=function "+e+"_pick("+a+"){var a=[],b=[],c=this.offset");for(var p=0;p<t;++p)o.push("if(typeof i"+p+"==='number'&&i"+p+">=0){c=(c+this.stride["+p+"]*i"+p+")|0}else{a.push(this.shape["+p+"]);b.push(this.stride["+p+"])}");o.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}"),o.push("return function construct_"+e+"(data,shape,stride,offset){return new "+e+"(data,"+i.map(function(y){return"shape["+y+"]"}).join(",")+","+i.map(function(y){return"stride["+y+"]"}).join(",")+",offset)}");var m=new Function("CTOR_LIST","ORDER",o.join(`
3
- `));return m(Pd[n],eE)}function rE(n){if(KD(n))return"buffer";if(ZD)switch(Object.prototype.toString.call(n)){case"[object Float64Array]":return"float64";case"[object Float32Array]":return"float32";case"[object Int8Array]":return"int8";case"[object Int16Array]":return"int16";case"[object Int32Array]":return"int32";case"[object Uint8Array]":return"uint8";case"[object Uint16Array]":return"uint16";case"[object Uint32Array]":return"uint32";case"[object Uint8ClampedArray]":return"uint8_clamped";case"[object BigInt64Array]":return"bigint64";case"[object BigUint64Array]":return"biguint64"}return Array.isArray(n)?"array":"generic"}var Pd={float32:[],float64:[],int8:[],int16:[],int32:[],uint8:[],uint16:[],uint32:[],array:[],uint8_clamped:[],bigint64:[],biguint64:[],buffer:[],generic:[]};function oE(n,t,e,r){if(n===void 0){var u=Pd.array[0];return u([])}else typeof n=="number"&&(n=[n]);t===void 0&&(t=[n.length]);var o=t.length;if(e===void 0){e=new Array(o);for(var i=o-1,a=1;i>=0;--i)e[i]=a,a*=t[i]}if(r===void 0){r=0;for(var i=0;i<o;++i)e[i]<0&&(r-=(t[i]-1)*e[i])}for(var s=rE(n),l=Pd[s];l.length<=o+1;)l.push(tE(s,l.length-1));var u=l[o+1];return u(n,t,e,r)}RS.exports=oE});var zS=Zt((vde,VS)=>{"use strict";function nE(n,t){for(var e=1,r=n.length,o=n[0],i=n[0],a=1;a<r;++a)if(i=o,o=n[a],t(o,i)){if(a===e){e++;continue}n[e++]=o}return n.length=e,n}function iE(n){for(var t=1,e=n.length,r=n[0],o=n[0],i=1;i<e;++i,o=r)if(o=r,r=n[i],r!==o){if(i===t){t++;continue}n[t++]=r}return n.length=t,n}function aE(n,t,e){return n.length===0?n:t?(e||n.sort(t),nE(n,t)):(e||n.sort(),iE(n))}VS.exports=aE});var kS=Zt((Sde,FS)=>{"use strict";var sE=zS();function GS(n,t,e){var r=n.length,o=t.arrayArgs.length,i=t.indexArgs.length>0,a=[],s=[],l=0,u=0,c,d;for(c=0;c<r;++c)s.push(["i",c,"=0"].join(""));for(d=0;d<o;++d)for(c=0;c<r;++c)u=l,l=n[c],c===0?s.push(["d",d,"s",c,"=t",d,"p",l].join("")):s.push(["d",d,"s",c,"=(t",d,"p",l,"-s",u,"*t",d,"p",u,")"].join(""));for(s.length>0&&a.push("var "+s.join(",")),c=r-1;c>=0;--c)l=n[c],a.push(["for(i",c,"=0;i",c,"<s",l,";++i",c,"){"].join(""));for(a.push(e),c=0;c<r;++c){for(u=l,l=n[c],d=0;d<o;++d)a.push(["p",d,"+=d",d,"s",c].join(""));i&&(c>0&&a.push(["index[",u,"]-=s",u].join("")),a.push(["++index[",l,"]"].join(""))),a.push("}")}return a.join(`
4
- `)}function lE(n,t,e,r){for(var o=t.length,i=e.arrayArgs.length,a=e.blockSize,s=e.indexArgs.length>0,l=[],u=0;u<i;++u)l.push(["var offset",u,"=p",u].join(""));for(var u=n;u<o;++u)l.push(["for(var j"+u+"=SS[",t[u],"]|0;j",u,">0;){"].join("")),l.push(["if(j",u,"<",a,"){"].join("")),l.push(["s",t[u],"=j",u].join("")),l.push(["j",u,"=0"].join("")),l.push(["}else{s",t[u],"=",a].join("")),l.push(["j",u,"-=",a,"}"].join("")),s&&l.push(["index[",t[u],"]=j",u].join(""));for(var u=0;u<i;++u){for(var c=["offset"+u],d=n;d<o;++d)c.push(["j",d,"*t",u,"p",t[d]].join(""));l.push(["p",u,"=(",c.join("+"),")"].join(""))}l.push(GS(t,e,r));for(var u=n;u<o;++u)l.push("}");return l.join(`
5
- `)}function cE(n){for(var t=0,e=n[0].length;t<e;){for(var r=1;r<n.length;++r)if(n[r][t]!==n[0][t])return t;++t}return t}function Vh(n,t,e){for(var r=n.body,o=[],i=[],a=0;a<n.args.length;++a){var s=n.args[a];if(!(s.count<=0)){var l=new RegExp(s.name,"g"),u="",c=t.arrayArgs.indexOf(a);switch(t.argTypes[a]){case"offset":var d=t.offsetArgIndex.indexOf(a),p=t.offsetArgs[d];c=p.array,u="+q"+d;case"array":u="p"+c+u;var f="l"+a,h="a"+c;if(t.arrayBlockIndices[c]===0)s.count===1?e[c]==="generic"?s.lvalue?(o.push(["var ",f,"=",h,".get(",u,")"].join("")),r=r.replace(l,f),i.push([h,".set(",u,",",f,")"].join(""))):r=r.replace(l,[h,".get(",u,")"].join("")):r=r.replace(l,[h,"[",u,"]"].join("")):e[c]==="generic"?(o.push(["var ",f,"=",h,".get(",u,")"].join("")),r=r.replace(l,f),s.lvalue&&i.push([h,".set(",u,",",f,")"].join(""))):(o.push(["var ",f,"=",h,"[",u,"]"].join("")),r=r.replace(l,f),s.lvalue&&i.push([h,"[",u,"]=",f].join("")));else{for(var m=[s.name],y=[u],g=0;g<Math.abs(t.arrayBlockIndices[c]);g++)m.push("\\s*\\[([^\\]]+)\\]"),y.push("$"+(g+1)+"*t"+c+"b"+g);if(l=new RegExp(m.join(""),"g"),u=y.join("+"),e[c]==="generic")throw new Error("cwise: Generic arrays not supported in combination with blocks!");r=r.replace(l,[h,"[",u,"]"].join(""))}break;case"scalar":r=r.replace(l,"Y"+t.scalarArgs.indexOf(a));break;case"index":r=r.replace(l,"index");break;case"shape":r=r.replace(l,"shape");break}}}return[o.join(`
1
+ var $1=Object.create;var $l=Object.defineProperty;var Y1=Object.getOwnPropertyDescriptor;var X1=Object.getOwnPropertyNames;var Q1=Object.getPrototypeOf,K1=Object.prototype.hasOwnProperty;var Z1=(n,t,e)=>t in n?$l(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var Zt=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports),J1=(n,t)=>{for(var e in t)$l(n,e,{get:t[e],enumerable:!0})},ew=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of X1(t))!K1.call(n,o)&&o!==e&&$l(n,o,{get:()=>t[o],enumerable:!(r=Y1(t,o))||r.enumerable});return n};var Ht=(n,t,e)=>(e=n!=null?$1(Q1(n)):{},ew(t||!n||!n.__esModule?$l(e,"default",{value:n,enumerable:!0}):e,n));var Lt=(n,t,e)=>(Z1(n,typeof t!="symbol"?t+"":t,e),e);var R0=Zt((Ip,L0)=>{(function(n,t){typeof Ip=="object"?L0.exports=t():typeof define=="function"&&define.amd?define(t):n.Alea=t()})(Ip,function(){"use strict";return n.importState=function(e){var r=new n;return r.importState(e),r},n;function n(){return function(e){var r=0,o=0,i=0,a=1;e.length==0&&(e=[+new Date]);var s=t();r=s(" "),o=s(" "),i=s(" ");for(var l=0;l<e.length;l++)r-=s(e[l]),r<0&&(r+=1),o-=s(e[l]),o<0&&(o+=1),i-=s(e[l]),i<0&&(i+=1);s=null;var u=function(){var c=2091639*r+a*23283064365386963e-26;return r=o,o=i,i=c-(a=c|0)};return u.next=u,u.uint32=function(){return u()*4294967296},u.fract53=function(){return u()+(u()*2097152|0)*11102230246251565e-32},u.version="Alea 0.9",u.args=e,u.exportState=function(){return[r,o,i,a]},u.importState=function(c){r=+c[0]||0,o=+c[1]||0,i=+c[2]||0,a=+c[3]||0},u}(Array.prototype.slice.call(arguments))}function t(){var e=4022871197,r=function(o){o=o.toString();for(var i=0;i<o.length;i++){e+=o.charCodeAt(i);var a=.02519603282416938*e;e=a>>>0,a-=e,a*=e,e=a>>>0,a-=e,e+=a*4294967296}return(e>>>0)*23283064365386963e-26};return r.version="Mash 0.9",r}})});var k0=Zt((uu,F0)=>{(function(n,t){typeof uu=="object"&&typeof F0<"u"?t(uu):typeof define=="function"&&define.amd?define(["exports"],t):t((n=typeof globalThis<"u"?globalThis:n||self).SVDJS={})})(uu,function(n){"use strict";n.SVD=function(t,e,r,o,i){if(e=e===void 0||e,r=r===void 0||r,i=1e-64/(o=o||Math.pow(2,-52)),!t)throw new TypeError("Matrix a is not defined");var a,s,l,u,c,d,p,f,h,m,y,g,b=t[0].length,w=t.length;if(w<b)throw new TypeError("Invalid matrix: m < n");for(var A=[],S=[],P=[],O=e==="f"?w:b,x=m=p=0;x<w;x++)S[x]=new Array(O).fill(0);for(x=0;x<b;x++)P[x]=new Array(b).fill(0);var D,N=new Array(b).fill(0);for(x=0;x<w;x++)for(a=0;a<b;a++)S[x][a]=t[x][a];for(x=0;x<b;x++){for(A[x]=p,h=0,l=x+1,a=x;a<w;a++)h+=Math.pow(S[a][x],2);if(h<i)p=0;else for(f=(d=S[x][x])*(p=d<0?Math.sqrt(h):-Math.sqrt(h))-h,S[x][x]=d-p,a=l;a<b;a++){for(h=0,s=x;s<w;s++)h+=S[s][x]*S[s][a];for(d=h/f,s=x;s<w;s++)S[s][a]=S[s][a]+d*S[s][x]}for(N[x]=p,h=0,a=l;a<b;a++)h+=Math.pow(S[x][a],2);if(h<i)p=0;else{for(f=(d=S[x][x+1])*(p=d<0?Math.sqrt(h):-Math.sqrt(h))-h,S[x][x+1]=d-p,a=l;a<b;a++)A[a]=S[x][a]/f;for(a=l;a<w;a++){for(h=0,s=l;s<b;s++)h+=S[a][s]*S[x][s];for(s=l;s<b;s++)S[a][s]=S[a][s]+h*A[s]}}m<(y=Math.abs(N[x])+Math.abs(A[x]))&&(m=y)}if(r)for(x=b-1;0<=x;x--){if(p!==0){for(f=S[x][x+1]*p,a=l;a<b;a++)P[a][x]=S[x][a]/f;for(a=l;a<b;a++){for(h=0,s=l;s<b;s++)h+=S[x][s]*P[s][a];for(s=l;s<b;s++)P[s][a]=P[s][a]+h*P[s][x]}}for(a=l;a<b;a++)P[x][a]=0,P[a][x]=0;P[x][x]=1,p=A[x],l=x}if(e){if(e==="f")for(x=b;x<w;x++){for(a=b;a<w;a++)S[x][a]=0;S[x][x]=1}for(x=b-1;0<=x;x--){for(l=x+1,p=N[x],a=l;a<O;a++)S[x][a]=0;if(p!==0){for(f=S[x][x]*p,a=l;a<O;a++){for(h=0,s=l;s<w;s++)h+=S[s][x]*S[s][a];for(d=h/f,s=x;s<w;s++)S[s][a]=S[s][a]+d*S[s][x]}for(a=x;a<w;a++)S[a][x]=S[a][x]/p}else for(a=x;a<w;a++)S[a][x]=0;S[x][x]=S[x][x]+1}}for(o*=m,s=b-1;0<=s;s--)for(var T=0;T<50;T++){for(D=!1,l=s;0<=l;l--){if(Math.abs(A[l])<=o){D=!0;break}if(Math.abs(N[l-1])<=o)break}if(!D){for(c=0,u=l-(h=1),x=l;x<s+1&&(d=h*A[x],A[x]=c*A[x],!(Math.abs(d)<=o));x++)if(p=N[x],N[x]=Math.sqrt(d*d+p*p),c=p/(f=N[x]),h=-d/f,e)for(a=0;a<w;a++)y=S[a][u],g=S[a][x],S[a][u]=y*c+g*h,S[a][x]=-y*h+g*c}if(g=N[s],l===s){if(g<0&&(N[s]=-g,r))for(a=0;a<b;a++)P[a][s]=-P[a][s];break}for(m=N[l],d=(((y=N[s-1])-g)*(y+g)+((p=A[s-1])-(f=A[s]))*(p+f))/(2*f*y),p=Math.sqrt(d*d+1),d=((m-g)*(m+g)+f*(y/(d<0?d-p:d+p)-f))/m,x=l+(h=c=1);x<s+1;x++){if(p=A[x],y=N[x],f=h*p,p*=c,g=Math.sqrt(d*d+f*f),d=m*(c=d/(A[x-1]=g))+p*(h=f/g),p=-m*h+p*c,f=y*h,y*=c,r)for(a=0;a<b;a++)m=P[a][x-1],g=P[a][x],P[a][x-1]=m*c+g*h,P[a][x]=-m*h+g*c;if(g=Math.sqrt(d*d+f*f),d=(c=d/(N[x-1]=g))*p+(h=f/g)*y,m=-h*p+c*y,e)for(a=0;a<w;a++)y=S[a][x-1],g=S[a][x],S[a][x-1]=y*c+g*h,S[a][x]=-y*h+g*c}A[l]=0,A[s]=d,N[s]=m}for(x=0;x<b;x++)N[x]<o&&(N[x]=0);return{u:S,q:N,v:P}},n.VERSION="1.1.1",Object.defineProperty(n,"__esModule",{value:!0})})});var vx=Zt((of,nf)=>{(function(n,t){typeof of=="object"&&typeof nf<"u"?nf.exports=t():typeof define=="function"&&define.amd?define(t):(n=n||self,n.TinyQueue=t())})(of,function(){"use strict";var n=function(r,o){if(r===void 0&&(r=[]),o===void 0&&(o=t),this.data=r,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(r){this.data.push(r),this.length++,this._up(this.length-1)},n.prototype.pop=function(){if(this.length!==0){var r=this.data[0],o=this.data.pop();return this.length--,this.length>0&&(this.data[0]=o,this._down(0)),r}},n.prototype.peek=function(){return this.data[0]},n.prototype._up=function(r){for(var o=this,i=o.data,a=o.compare,s=i[r];r>0;){var l=r-1>>1,u=i[l];if(a(s,u)>=0)break;i[r]=u,r=l}i[r]=s},n.prototype._down=function(r){for(var o=this,i=o.data,a=o.compare,s=this.length>>1,l=i[r];r<s;){var u=(r<<1)+1,c=i[u],d=u+1;if(d<this.length&&a(i[d],c)<0&&(u=d,c=i[d]),a(c,l)>=0)break;i[r]=c,r=u}i[r]=l};function t(e,r){return e<r?-1:e>r?1:0}return n})});var wx=Zt((n6,af)=>{"use strict";var Su=vx();Su.default&&(Su=Su.default);af.exports=Sx;af.exports.default=Sx;function Sx(n,t,e){t=t||1;for(var r,o,i,a,s=0;s<n[0].length;s++){var l=n[0][s];(!s||l[0]<r)&&(r=l[0]),(!s||l[1]<o)&&(o=l[1]),(!s||l[0]>i)&&(i=l[0]),(!s||l[1]>a)&&(a=l[1])}var u=i-r,c=a-o,d=Math.min(u,c),p=d/2;if(d===0){var f=[r,o];return f.distance=0,f}for(var h=new Su(void 0,yM),m=r;m<i;m+=d)for(var y=o;y<a;y+=d)h.push(new Cn(m+p,y+p,p,n));var g=xM(n),b=new Cn(r+u/2,o+c/2,0,n);b.d>g.d&&(g=b);for(var w=h.length;h.length;){var A=h.pop();A.d>g.d&&(g=A,e&&console.log("found best %d after %d probes",Math.round(1e4*A.d)/1e4,w)),!(A.max-g.d<=t)&&(p=A.h/2,h.push(new Cn(A.x-p,A.y-p,p,n)),h.push(new Cn(A.x+p,A.y-p,p,n)),h.push(new Cn(A.x-p,A.y+p,p,n)),h.push(new Cn(A.x+p,A.y+p,p,n)),w+=4)}e&&(console.log("num probes: "+w),console.log("best distance: "+g.d));var S=[g.x,g.y];return S.distance=g.d,S}function yM(n,t){return t.max-n.max}function Cn(n,t,e,r){this.x=n,this.y=t,this.h=e,this.d=gM(n,t,r),this.max=this.d+this.h*Math.SQRT2}function gM(n,t,e){for(var r=!1,o=1/0,i=0;i<e.length;i++)for(var a=e[i],s=0,l=a.length,u=l-1;s<l;u=s++){var c=a[s],d=a[u];c[1]>t!=d[1]>t&&n<(d[0]-c[0])*(t-c[1])/(d[1]-c[1])+c[0]&&(r=!r),o=Math.min(o,bM(n,t,c,d))}return o===0?0:(r?1:-1)*Math.sqrt(o)}function xM(n){for(var t=0,e=0,r=0,o=n[0],i=0,a=o.length,s=a-1;i<a;s=i++){var l=o[i],u=o[s],c=l[0]*u[1]-u[0]*l[1];e+=(l[0]+u[0])*c,r+=(l[1]+u[1])*c,t+=c*3}return t===0?new Cn(o[0][0],o[0][1],0,n):new Cn(e/t,r/t,0,n)}function bM(n,t,e,r){var o=e[0],i=e[1],a=r[0]-o,s=r[1]-i;if(a!==0||s!==0){var l=((n-o)*a+(t-i)*s)/(a*a+s*s);l>1?(o=r[0],i=r[1]):l>0&&(o+=a*l,i+=s*l)}return a=n-o,s=t-i,a*a+s*s}});var Fb=Zt(Yu=>{(function(){"use strict";var n=function(){this.init()};n.prototype={init:function(){var c=this||t;return c._counter=1e3,c._html5AudioPool=[],c.html5PoolSize=10,c._codecs={},c._howls=[],c._muted=!1,c._volume=1,c._canPlayEvent="canplaythrough",c._navigator=typeof window<"u"&&window.navigator?window.navigator:null,c.masterGain=null,c.noAudio=!1,c.usingWebAudio=!0,c.autoSuspend=!0,c.ctx=null,c.autoUnlock=!0,c._setup(),c},volume:function(c){var d=this||t;if(c=parseFloat(c),d.ctx||u(),typeof c<"u"&&c>=0&&c<=1){if(d._volume=c,d._muted)return d;d.usingWebAudio&&d.masterGain.gain.setValueAtTime(c,t.ctx.currentTime);for(var p=0;p<d._howls.length;p++)if(!d._howls[p]._webAudio)for(var f=d._howls[p]._getSoundIds(),h=0;h<f.length;h++){var m=d._howls[p]._soundById(f[h]);m&&m._node&&(m._node.volume=m._volume*c)}return d}return d._volume},mute:function(c){var d=this||t;d.ctx||u(),d._muted=c,d.usingWebAudio&&d.masterGain.gain.setValueAtTime(c?0:d._volume,t.ctx.currentTime);for(var p=0;p<d._howls.length;p++)if(!d._howls[p]._webAudio)for(var f=d._howls[p]._getSoundIds(),h=0;h<f.length;h++){var m=d._howls[p]._soundById(f[h]);m&&m._node&&(m._node.muted=c?!0:m._muted)}return d},stop:function(){for(var c=this||t,d=0;d<c._howls.length;d++)c._howls[d].stop();return c},unload:function(){for(var c=this||t,d=c._howls.length-1;d>=0;d--)c._howls[d].unload();return c.usingWebAudio&&c.ctx&&typeof c.ctx.close<"u"&&(c.ctx.close(),c.ctx=null,u()),c},codecs:function(c){return(this||t)._codecs[c.replace(/^x-/,"")]},_setup:function(){var c=this||t;if(c.state=c.ctx&&c.ctx.state||"suspended",c._autoSuspend(),!c.usingWebAudio)if(typeof Audio<"u")try{var d=new Audio;typeof d.oncanplaythrough>"u"&&(c._canPlayEvent="canplay")}catch{c.noAudio=!0}else c.noAudio=!0;try{var d=new Audio;d.muted&&(c.noAudio=!0)}catch{}return c.noAudio||c._setupCodecs(),c},_setupCodecs:function(){var c=this||t,d=null;try{d=typeof Audio<"u"?new Audio:null}catch{return c}if(!d||typeof d.canPlayType!="function")return c;var p=d.canPlayType("audio/mpeg;").replace(/^no$/,""),f=c._navigator?c._navigator.userAgent:"",h=f.match(/OPR\/([0-6].)/g),m=h&&parseInt(h[0].split("/")[1],10)<33,y=f.indexOf("Safari")!==-1&&f.indexOf("Chrome")===-1,g=f.match(/Version\/(.*?) /),b=y&&g&&parseInt(g[1],10)<15;return c._codecs={mp3:!!(!m&&(p||d.canPlayType("audio/mp3;").replace(/^no$/,""))),mpeg:!!p,opus:!!d.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/,""),ogg:!!d.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),oga:!!d.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),wav:!!(d.canPlayType('audio/wav; codecs="1"')||d.canPlayType("audio/wav")).replace(/^no$/,""),aac:!!d.canPlayType("audio/aac;").replace(/^no$/,""),caf:!!d.canPlayType("audio/x-caf;").replace(/^no$/,""),m4a:!!(d.canPlayType("audio/x-m4a;")||d.canPlayType("audio/m4a;")||d.canPlayType("audio/aac;")).replace(/^no$/,""),m4b:!!(d.canPlayType("audio/x-m4b;")||d.canPlayType("audio/m4b;")||d.canPlayType("audio/aac;")).replace(/^no$/,""),mp4:!!(d.canPlayType("audio/x-mp4;")||d.canPlayType("audio/mp4;")||d.canPlayType("audio/aac;")).replace(/^no$/,""),weba:!!(!b&&d.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),webm:!!(!b&&d.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),dolby:!!d.canPlayType('audio/mp4; codecs="ec-3"').replace(/^no$/,""),flac:!!(d.canPlayType("audio/x-flac;")||d.canPlayType("audio/flac;")).replace(/^no$/,"")},c},_unlockAudio:function(){var c=this||t;if(!(c._audioUnlocked||!c.ctx)){c._audioUnlocked=!1,c.autoUnlock=!1,!c._mobileUnloaded&&c.ctx.sampleRate!==44100&&(c._mobileUnloaded=!0,c.unload()),c._scratchBuffer=c.ctx.createBuffer(1,1,22050);var d=function(p){for(;c._html5AudioPool.length<c.html5PoolSize;)try{var f=new Audio;f._unlocked=!0,c._releaseHtml5Audio(f)}catch{c.noAudio=!0;break}for(var h=0;h<c._howls.length;h++)if(!c._howls[h]._webAudio)for(var m=c._howls[h]._getSoundIds(),y=0;y<m.length;y++){var g=c._howls[h]._soundById(m[y]);g&&g._node&&!g._node._unlocked&&(g._node._unlocked=!0,g._node.load())}c._autoResume();var b=c.ctx.createBufferSource();b.buffer=c._scratchBuffer,b.connect(c.ctx.destination),typeof b.start>"u"?b.noteOn(0):b.start(0),typeof c.ctx.resume=="function"&&c.ctx.resume(),b.onended=function(){b.disconnect(0),c._audioUnlocked=!0,document.removeEventListener("touchstart",d,!0),document.removeEventListener("touchend",d,!0),document.removeEventListener("click",d,!0),document.removeEventListener("keydown",d,!0);for(var w=0;w<c._howls.length;w++)c._howls[w]._emit("unlock")}};return document.addEventListener("touchstart",d,!0),document.addEventListener("touchend",d,!0),document.addEventListener("click",d,!0),document.addEventListener("keydown",d,!0),c}},_obtainHtml5Audio:function(){var c=this||t;if(c._html5AudioPool.length)return c._html5AudioPool.pop();var d=new Audio().play();return d&&typeof Promise<"u"&&(d instanceof Promise||typeof d.then=="function")&&d.catch(function(){console.warn("HTML5 Audio pool exhausted, returning potentially locked audio object.")}),new Audio},_releaseHtml5Audio:function(c){var d=this||t;return c._unlocked&&d._html5AudioPool.push(c),d},_autoSuspend:function(){var c=this;if(!(!c.autoSuspend||!c.ctx||typeof c.ctx.suspend>"u"||!t.usingWebAudio)){for(var d=0;d<c._howls.length;d++)if(c._howls[d]._webAudio){for(var p=0;p<c._howls[d]._sounds.length;p++)if(!c._howls[d]._sounds[p]._paused)return c}return c._suspendTimer&&clearTimeout(c._suspendTimer),c._suspendTimer=setTimeout(function(){if(!!c.autoSuspend){c._suspendTimer=null,c.state="suspending";var f=function(){c.state="suspended",c._resumeAfterSuspend&&(delete c._resumeAfterSuspend,c._autoResume())};c.ctx.suspend().then(f,f)}},3e4),c}},_autoResume:function(){var c=this;if(!(!c.ctx||typeof c.ctx.resume>"u"||!t.usingWebAudio))return c.state==="running"&&c.ctx.state!=="interrupted"&&c._suspendTimer?(clearTimeout(c._suspendTimer),c._suspendTimer=null):c.state==="suspended"||c.state==="running"&&c.ctx.state==="interrupted"?(c.ctx.resume().then(function(){c.state="running";for(var d=0;d<c._howls.length;d++)c._howls[d]._emit("resume")}),c._suspendTimer&&(clearTimeout(c._suspendTimer),c._suspendTimer=null)):c.state==="suspending"&&(c._resumeAfterSuspend=!0),c}};var t=new n,e=function(c){var d=this;if(!c.src||c.src.length===0){console.error("An array of source files must be passed with any new Howl.");return}d.init(c)};e.prototype={init:function(c){var d=this;return t.ctx||u(),d._autoplay=c.autoplay||!1,d._format=typeof c.format!="string"?c.format:[c.format],d._html5=c.html5||!1,d._muted=c.mute||!1,d._loop=c.loop||!1,d._pool=c.pool||5,d._preload=typeof c.preload=="boolean"||c.preload==="metadata"?c.preload:!0,d._rate=c.rate||1,d._sprite=c.sprite||{},d._src=typeof c.src!="string"?c.src:[c.src],d._volume=c.volume!==void 0?c.volume:1,d._xhr={method:c.xhr&&c.xhr.method?c.xhr.method:"GET",headers:c.xhr&&c.xhr.headers?c.xhr.headers:null,withCredentials:c.xhr&&c.xhr.withCredentials?c.xhr.withCredentials:!1},d._duration=0,d._state="unloaded",d._sounds=[],d._endTimers={},d._queue=[],d._playLock=!1,d._onend=c.onend?[{fn:c.onend}]:[],d._onfade=c.onfade?[{fn:c.onfade}]:[],d._onload=c.onload?[{fn:c.onload}]:[],d._onloaderror=c.onloaderror?[{fn:c.onloaderror}]:[],d._onplayerror=c.onplayerror?[{fn:c.onplayerror}]:[],d._onpause=c.onpause?[{fn:c.onpause}]:[],d._onplay=c.onplay?[{fn:c.onplay}]:[],d._onstop=c.onstop?[{fn:c.onstop}]:[],d._onmute=c.onmute?[{fn:c.onmute}]:[],d._onvolume=c.onvolume?[{fn:c.onvolume}]:[],d._onrate=c.onrate?[{fn:c.onrate}]:[],d._onseek=c.onseek?[{fn:c.onseek}]:[],d._onunlock=c.onunlock?[{fn:c.onunlock}]:[],d._onresume=[],d._webAudio=t.usingWebAudio&&!d._html5,typeof t.ctx<"u"&&t.ctx&&t.autoUnlock&&t._unlockAudio(),t._howls.push(d),d._autoplay&&d._queue.push({event:"play",action:function(){d.play()}}),d._preload&&d._preload!=="none"&&d.load(),d},load:function(){var c=this,d=null;if(t.noAudio){c._emit("loaderror",null,"No audio support.");return}typeof c._src=="string"&&(c._src=[c._src]);for(var p=0;p<c._src.length;p++){var f,h;if(c._format&&c._format[p])f=c._format[p];else{if(h=c._src[p],typeof h!="string"){c._emit("loaderror",null,"Non-string found in selected audio sources - ignoring.");continue}f=/^data:audio\/([^;,]+);/i.exec(h),f||(f=/\.([^.]+)$/.exec(h.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&&t.codecs(f)){d=c._src[p];break}}if(!d){c._emit("loaderror",null,"No codec support for selected audio sources.");return}return c._src=d,c._state="loading",window.location.protocol==="https:"&&d.slice(0,5)==="http:"&&(c._html5=!0,c._webAudio=!1),new r(c),c._webAudio&&i(c),c},play:function(c,d){var p=this,f=null;if(typeof c=="number")f=c,c=null;else{if(typeof c=="string"&&p._state==="loaded"&&!p._sprite[c])return null;if(typeof c>"u"&&(c="__default",!p._playLock)){for(var h=0,m=0;m<p._sounds.length;m++)p._sounds[m]._paused&&!p._sounds[m]._ended&&(h++,f=p._sounds[m]._id);h===1?c=null:f=null}}var y=f?p._soundById(f):p._inactiveSound();if(!y)return null;if(f&&!c&&(c=y._sprite||"__default"),p._state!=="loaded"){y._sprite=c,y._ended=!1;var g=y._id;return p._queue.push({event:"play",action:function(){p.play(g)}}),g}if(f&&!y._paused)return d||p._loadQueue("play"),y._id;p._webAudio&&t._autoResume();var b=Math.max(0,y._seek>0?y._seek:p._sprite[c][0]/1e3),w=Math.max(0,(p._sprite[c][0]+p._sprite[c][1])/1e3-b),A=w*1e3/Math.abs(y._rate),S=p._sprite[c][0]/1e3,P=(p._sprite[c][0]+p._sprite[c][1])/1e3;y._sprite=c,y._ended=!1;var O=function(){y._paused=!1,y._seek=b,y._start=S,y._stop=P,y._loop=!!(y._loop||p._sprite[c][2])};if(b>=P){p._ended(y);return}var x=y._node;if(p._webAudio){var D=function(){p._playLock=!1,O(),p._refreshBuffer(y);var E=y._muted||p._muted?0:y._volume;x.gain.setValueAtTime(E,t.ctx.currentTime),y._playStart=t.ctx.currentTime,typeof x.bufferSource.start>"u"?y._loop?x.bufferSource.noteGrainOn(0,b,86400):x.bufferSource.noteGrainOn(0,b,w):y._loop?x.bufferSource.start(0,b,86400):x.bufferSource.start(0,b,w),A!==1/0&&(p._endTimers[y._id]=setTimeout(p._ended.bind(p,y),A)),d||setTimeout(function(){p._emit("play",y._id),p._loadQueue()},0)};t.state==="running"&&t.ctx.state!=="interrupted"?D():(p._playLock=!0,p.once("resume",D),p._clearTimer(y._id))}else{var N=function(){x.currentTime=b,x.muted=y._muted||p._muted||t._muted||x.muted,x.volume=y._volume*t.volume(),x.playbackRate=y._rate;try{var E=x.play();if(E&&typeof Promise<"u"&&(E instanceof Promise||typeof E.then=="function")?(p._playLock=!0,O(),E.then(function(){p._playLock=!1,x._unlocked=!0,d?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})):d||(p._playLock=!1,O(),p._emit("play",y._id)),x.playbackRate=y._rate,x.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}c!=="__default"||y._loop?p._endTimers[y._id]=setTimeout(p._ended.bind(p,y),A):(p._endTimers[y._id]=function(){p._ended(y),x.removeEventListener("ended",p._endTimers[y._id],!1)},x.addEventListener("ended",p._endTimers[y._id],!1))}catch(B){p._emit("playerror",y._id,B)}};x.src==="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA"&&(x.src=p._src,x.load());var T=window&&window.ejecta||!x.readyState&&t._navigator.isCocoonJS;if(x.readyState>=3||T)N();else{p._playLock=!0,p._state="loading";var I=function(){p._state="loaded",N(),x.removeEventListener(t._canPlayEvent,I,!1)};x.addEventListener(t._canPlayEvent,I,!1),p._clearTimer(y._id)}}return y._id},pause:function(c){var d=this;if(d._state!=="loaded"||d._playLock)return d._queue.push({event:"pause",action:function(){d.pause(c)}}),d;for(var p=d._getSoundIds(c),f=0;f<p.length;f++){d._clearTimer(p[f]);var h=d._soundById(p[f]);if(h&&!h._paused&&(h._seek=d.seek(p[f]),h._rateSeek=0,h._paused=!0,d._stopFade(p[f]),h._node))if(d._webAudio){if(!h._node.bufferSource)continue;typeof h._node.bufferSource.stop>"u"?h._node.bufferSource.noteOff(0):h._node.bufferSource.stop(0),d._cleanBuffer(h._node)}else(!isNaN(h._node.duration)||h._node.duration===1/0)&&h._node.pause();arguments[1]||d._emit("pause",h?h._id:null)}return d},stop:function(c,d){var p=this;if(p._state!=="loaded"||p._playLock)return p._queue.push({event:"stop",action:function(){p.stop(c)}}),p;for(var f=p._getSoundIds(c),h=0;h<f.length;h++){p._clearTimer(f[h]);var m=p._soundById(f[h]);m&&(m._seek=m._start||0,m._rateSeek=0,m._paused=!0,m._ended=!0,p._stopFade(f[h]),m._node&&(p._webAudio?m._node.bufferSource&&(typeof m._node.bufferSource.stop>"u"?m._node.bufferSource.noteOff(0):m._node.bufferSource.stop(0),p._cleanBuffer(m._node)):(!isNaN(m._node.duration)||m._node.duration===1/0)&&(m._node.currentTime=m._start||0,m._node.pause(),m._node.duration===1/0&&p._clearSound(m._node))),d||p._emit("stop",m._id))}return p},mute:function(c,d){var p=this;if(p._state!=="loaded"||p._playLock)return p._queue.push({event:"mute",action:function(){p.mute(c,d)}}),p;if(typeof d>"u")if(typeof c=="boolean")p._muted=c;else return p._muted;for(var f=p._getSoundIds(d),h=0;h<f.length;h++){var m=p._soundById(f[h]);m&&(m._muted=c,m._interval&&p._stopFade(m._id),p._webAudio&&m._node?m._node.gain.setValueAtTime(c?0:m._volume,t.ctx.currentTime):m._node&&(m._node.muted=t._muted?!0:c),p._emit("mute",m._id))}return p},volume:function(){var c=this,d=arguments,p,f;if(d.length===0)return c._volume;if(d.length===1||d.length===2&&typeof d[1]>"u"){var h=c._getSoundIds(),m=h.indexOf(d[0]);m>=0?f=parseInt(d[0],10):p=parseFloat(d[0])}else d.length>=2&&(p=parseFloat(d[0]),f=parseInt(d[1],10));var y;if(typeof p<"u"&&p>=0&&p<=1){if(c._state!=="loaded"||c._playLock)return c._queue.push({event:"volume",action:function(){c.volume.apply(c,d)}}),c;typeof f>"u"&&(c._volume=p),f=c._getSoundIds(f);for(var g=0;g<f.length;g++)y=c._soundById(f[g]),y&&(y._volume=p,d[2]||c._stopFade(f[g]),c._webAudio&&y._node&&!y._muted?y._node.gain.setValueAtTime(p,t.ctx.currentTime):y._node&&!y._muted&&(y._node.volume=p*t.volume()),c._emit("volume",y._id))}else return y=f?c._soundById(f):c._sounds[0],y?y._volume:0;return c},fade:function(c,d,p,f){var h=this;if(h._state!=="loaded"||h._playLock)return h._queue.push({event:"fade",action:function(){h.fade(c,d,p,f)}}),h;c=Math.min(Math.max(0,parseFloat(c)),1),d=Math.min(Math.max(0,parseFloat(d)),1),p=parseFloat(p),h.volume(c,f);for(var m=h._getSoundIds(f),y=0;y<m.length;y++){var g=h._soundById(m[y]);if(g){if(f||h._stopFade(m[y]),h._webAudio&&!g._muted){var b=t.ctx.currentTime,w=b+p/1e3;g._volume=c,g._node.gain.setValueAtTime(c,b),g._node.gain.linearRampToValueAtTime(d,w)}h._startFadeInterval(g,c,d,p,m[y],typeof f>"u")}}return h},_startFadeInterval:function(c,d,p,f,h,m){var y=this,g=d,b=p-d,w=Math.abs(b/.01),A=Math.max(4,w>0?f/w:f),S=Date.now();c._fadeTo=p,c._interval=setInterval(function(){var P=(Date.now()-S)/f;S=Date.now(),g+=b*P,g=Math.round(g*100)/100,b<0?g=Math.max(p,g):g=Math.min(p,g),y._webAudio?c._volume=g:y.volume(g,c._id,!0),m&&(y._volume=g),(p<d&&g<=p||p>d&&g>=p)&&(clearInterval(c._interval),c._interval=null,c._fadeTo=null,y.volume(p,c._id),y._emit("fade",c._id))},A)},_stopFade:function(c){var d=this,p=d._soundById(c);return p&&p._interval&&(d._webAudio&&p._node.gain.cancelScheduledValues(t.ctx.currentTime),clearInterval(p._interval),p._interval=null,d.volume(p._fadeTo,c),p._fadeTo=null,d._emit("fade",c)),d},loop:function(){var c=this,d=arguments,p,f,h;if(d.length===0)return c._loop;if(d.length===1)if(typeof d[0]=="boolean")p=d[0],c._loop=p;else return h=c._soundById(parseInt(d[0],10)),h?h._loop:!1;else d.length===2&&(p=d[0],f=parseInt(d[1],10));for(var m=c._getSoundIds(f),y=0;y<m.length;y++)h=c._soundById(m[y]),h&&(h._loop=p,c._webAudio&&h._node&&h._node.bufferSource&&(h._node.bufferSource.loop=p,p&&(h._node.bufferSource.loopStart=h._start||0,h._node.bufferSource.loopEnd=h._stop,c.playing(m[y])&&(c.pause(m[y],!0),c.play(m[y],!0)))));return c},rate:function(){var c=this,d=arguments,p,f;if(d.length===0)f=c._sounds[0]._id;else if(d.length===1){var h=c._getSoundIds(),m=h.indexOf(d[0]);m>=0?f=parseInt(d[0],10):p=parseFloat(d[0])}else d.length===2&&(p=parseFloat(d[0]),f=parseInt(d[1],10));var y;if(typeof p=="number"){if(c._state!=="loaded"||c._playLock)return c._queue.push({event:"rate",action:function(){c.rate.apply(c,d)}}),c;typeof f>"u"&&(c._rate=p),f=c._getSoundIds(f);for(var g=0;g<f.length;g++)if(y=c._soundById(f[g]),y){c.playing(f[g])&&(y._rateSeek=c.seek(f[g]),y._playStart=c._webAudio?t.ctx.currentTime:y._playStart),y._rate=p,c._webAudio&&y._node&&y._node.bufferSource?y._node.bufferSource.playbackRate.setValueAtTime(p,t.ctx.currentTime):y._node&&(y._node.playbackRate=p);var b=c.seek(f[g]),w=(c._sprite[y._sprite][0]+c._sprite[y._sprite][1])/1e3-b,A=w*1e3/Math.abs(y._rate);(c._endTimers[f[g]]||!y._paused)&&(c._clearTimer(f[g]),c._endTimers[f[g]]=setTimeout(c._ended.bind(c,y),A)),c._emit("rate",y._id)}}else return y=c._soundById(f),y?y._rate:c._rate;return c},seek:function(){var c=this,d=arguments,p,f;if(d.length===0)c._sounds.length&&(f=c._sounds[0]._id);else if(d.length===1){var h=c._getSoundIds(),m=h.indexOf(d[0]);m>=0?f=parseInt(d[0],10):c._sounds.length&&(f=c._sounds[0]._id,p=parseFloat(d[0]))}else d.length===2&&(p=parseFloat(d[0]),f=parseInt(d[1],10));if(typeof f>"u")return 0;if(typeof p=="number"&&(c._state!=="loaded"||c._playLock))return c._queue.push({event:"seek",action:function(){c.seek.apply(c,d)}}),c;var y=c._soundById(f);if(y)if(typeof p=="number"&&p>=0){var g=c.playing(f);g&&c.pause(f,!0),y._seek=p,y._ended=!1,c._clearTimer(f),!c._webAudio&&y._node&&!isNaN(y._node.duration)&&(y._node.currentTime=p);var b=function(){g&&c.play(f,!0),c._emit("seek",f)};if(g&&!c._webAudio){var w=function(){c._playLock?setTimeout(w,0):b()};setTimeout(w,0)}else b()}else if(c._webAudio){var A=c.playing(f)?t.ctx.currentTime-y._playStart:0,S=y._rateSeek?y._rateSeek-y._seek:0;return y._seek+(S+A*Math.abs(y._rate))}else return y._node.currentTime;return c},playing:function(c){var d=this;if(typeof c=="number"){var p=d._soundById(c);return p?!p._paused:!1}for(var f=0;f<d._sounds.length;f++)if(!d._sounds[f]._paused)return!0;return!1},duration:function(c){var d=this,p=d._duration,f=d._soundById(c);return f&&(p=d._sprite[f._sprite][1]/1e3),p},state:function(){return this._state},unload:function(){for(var c=this,d=c._sounds,p=0;p<d.length;p++)d[p]._paused||c.stop(d[p]._id),c._webAudio||(c._clearSound(d[p]._node),d[p]._node.removeEventListener("error",d[p]._errorFn,!1),d[p]._node.removeEventListener(t._canPlayEvent,d[p]._loadFn,!1),d[p]._node.removeEventListener("ended",d[p]._endFn,!1),t._releaseHtml5Audio(d[p]._node)),delete d[p]._node,c._clearTimer(d[p]._id);var f=t._howls.indexOf(c);f>=0&&t._howls.splice(f,1);var h=!0;for(p=0;p<t._howls.length;p++)if(t._howls[p]._src===c._src||c._src.indexOf(t._howls[p]._src)>=0){h=!1;break}return o&&h&&delete o[c._src],t.noAudio=!1,c._state="unloaded",c._sounds=[],c=null,null},on:function(c,d,p,f){var h=this,m=h["_on"+c];return typeof d=="function"&&m.push(f?{id:p,fn:d,once:f}:{id:p,fn:d}),h},off:function(c,d,p){var f=this,h=f["_on"+c],m=0;if(typeof d=="number"&&(p=d,d=null),d||p)for(m=0;m<h.length;m++){var y=p===h[m].id;if(d===h[m].fn&&y||!d&&y){h.splice(m,1);break}}else if(c)f["_on"+c]=[];else{var g=Object.keys(f);for(m=0;m<g.length;m++)g[m].indexOf("_on")===0&&Array.isArray(f[g[m]])&&(f[g[m]]=[])}return f},once:function(c,d,p){var f=this;return f.on(c,d,p,1),f},_emit:function(c,d,p){for(var f=this,h=f["_on"+c],m=h.length-1;m>=0;m--)(!h[m].id||h[m].id===d||c==="load")&&(setTimeout(function(y){y.call(this,d,p)}.bind(f,h[m].fn),0),h[m].once&&f.off(c,h[m].fn,h[m].id));return f._loadQueue(c),f},_loadQueue:function(c){var d=this;if(d._queue.length>0){var p=d._queue[0];p.event===c&&(d._queue.shift(),d._loadQueue()),c||p.action()}return d},_ended:function(c){var d=this,p=c._sprite;if(!d._webAudio&&c._node&&!c._node.paused&&!c._node.ended&&c._node.currentTime<c._stop)return setTimeout(d._ended.bind(d,c),100),d;var f=!!(c._loop||d._sprite[p][2]);if(d._emit("end",c._id),!d._webAudio&&f&&d.stop(c._id,!0).play(c._id),d._webAudio&&f){d._emit("play",c._id),c._seek=c._start||0,c._rateSeek=0,c._playStart=t.ctx.currentTime;var h=(c._stop-c._start)*1e3/Math.abs(c._rate);d._endTimers[c._id]=setTimeout(d._ended.bind(d,c),h)}return d._webAudio&&!f&&(c._paused=!0,c._ended=!0,c._seek=c._start||0,c._rateSeek=0,d._clearTimer(c._id),d._cleanBuffer(c._node),t._autoSuspend()),!d._webAudio&&!f&&d.stop(c._id,!0),d},_clearTimer:function(c){var d=this;if(d._endTimers[c]){if(typeof d._endTimers[c]!="function")clearTimeout(d._endTimers[c]);else{var p=d._soundById(c);p&&p._node&&p._node.removeEventListener("ended",d._endTimers[c],!1)}delete d._endTimers[c]}return d},_soundById:function(c){for(var d=this,p=0;p<d._sounds.length;p++)if(c===d._sounds[p]._id)return d._sounds[p];return null},_inactiveSound:function(){var c=this;c._drain();for(var d=0;d<c._sounds.length;d++)if(c._sounds[d]._ended)return c._sounds[d].reset();return new r(c)},_drain:function(){var c=this,d=c._pool,p=0,f=0;if(!(c._sounds.length<d)){for(f=0;f<c._sounds.length;f++)c._sounds[f]._ended&&p++;for(f=c._sounds.length-1;f>=0;f--){if(p<=d)return;c._sounds[f]._ended&&(c._webAudio&&c._sounds[f]._node&&c._sounds[f]._node.disconnect(0),c._sounds.splice(f,1),p--)}}},_getSoundIds:function(c){var d=this;if(typeof c>"u"){for(var p=[],f=0;f<d._sounds.length;f++)p.push(d._sounds[f]._id);return p}else return[c]},_refreshBuffer:function(c){var d=this;return c._node.bufferSource=t.ctx.createBufferSource(),c._node.bufferSource.buffer=o[d._src],c._panner?c._node.bufferSource.connect(c._panner):c._node.bufferSource.connect(c._node),c._node.bufferSource.loop=c._loop,c._loop&&(c._node.bufferSource.loopStart=c._start||0,c._node.bufferSource.loopEnd=c._stop||0),c._node.bufferSource.playbackRate.setValueAtTime(c._rate,t.ctx.currentTime),d},_cleanBuffer:function(c){var d=this,p=t._navigator&&t._navigator.vendor.indexOf("Apple")>=0;if(t._scratchBuffer&&c.bufferSource&&(c.bufferSource.onended=null,c.bufferSource.disconnect(0),p))try{c.bufferSource.buffer=t._scratchBuffer}catch{}return c.bufferSource=null,d},_clearSound:function(c){var d=/MSIE |Trident\//.test(t._navigator&&t._navigator.userAgent);d||(c.src="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA")}};var r=function(c){this._parent=c,this.init()};r.prototype={init:function(){var c=this,d=c._parent;return c._muted=d._muted,c._loop=d._loop,c._volume=d._volume,c._rate=d._rate,c._seek=0,c._paused=!0,c._ended=!0,c._sprite="__default",c._id=++t._counter,d._sounds.push(c),c.create(),c},create:function(){var c=this,d=c._parent,p=t._muted||c._muted||c._parent._muted?0:c._volume;return d._webAudio?(c._node=typeof t.ctx.createGain>"u"?t.ctx.createGainNode():t.ctx.createGain(),c._node.gain.setValueAtTime(p,t.ctx.currentTime),c._node.paused=!0,c._node.connect(t.masterGain)):t.noAudio||(c._node=t._obtainHtml5Audio(),c._errorFn=c._errorListener.bind(c),c._node.addEventListener("error",c._errorFn,!1),c._loadFn=c._loadListener.bind(c),c._node.addEventListener(t._canPlayEvent,c._loadFn,!1),c._endFn=c._endListener.bind(c),c._node.addEventListener("ended",c._endFn,!1),c._node.src=d._src,c._node.preload=d._preload===!0?"auto":d._preload,c._node.volume=p*t.volume(),c._node.load()),c},reset:function(){var c=this,d=c._parent;return c._muted=d._muted,c._loop=d._loop,c._volume=d._volume,c._rate=d._rate,c._seek=0,c._rateSeek=0,c._paused=!0,c._ended=!0,c._sprite="__default",c._id=++t._counter,c},_errorListener:function(){var c=this;c._parent._emit("loaderror",c._id,c._node.error?c._node.error.code:0),c._node.removeEventListener("error",c._errorFn,!1)},_loadListener:function(){var c=this,d=c._parent;d._duration=Math.ceil(c._node.duration*10)/10,Object.keys(d._sprite).length===0&&(d._sprite={__default:[0,d._duration*1e3]}),d._state!=="loaded"&&(d._state="loaded",d._emit("load"),d._loadQueue()),c._node.removeEventListener(t._canPlayEvent,c._loadFn,!1)},_endListener:function(){var c=this,d=c._parent;d._duration===1/0&&(d._duration=Math.ceil(c._node.duration*10)/10,d._sprite.__default[1]===1/0&&(d._sprite.__default[1]=d._duration*1e3),d._ended(c)),c._node.removeEventListener("ended",c._endFn,!1)}};var o={},i=function(c){var d=c._src;if(o[d]){c._duration=o[d].duration,l(c);return}if(/^data:[^;]+;base64,/.test(d)){for(var p=atob(d.split(",")[1]),f=new Uint8Array(p.length),h=0;h<p.length;++h)f[h]=p.charCodeAt(h);s(f.buffer,c)}else{var m=new XMLHttpRequest;m.open(c._xhr.method,d,!0),m.withCredentials=c._xhr.withCredentials,m.responseType="arraybuffer",c._xhr.headers&&Object.keys(c._xhr.headers).forEach(function(y){m.setRequestHeader(y,c._xhr.headers[y])}),m.onload=function(){var y=(m.status+"")[0];if(y!=="0"&&y!=="2"&&y!=="3"){c._emit("loaderror",null,"Failed loading audio file with status: "+m.status+".");return}s(m.response,c)},m.onerror=function(){c._webAudio&&(c._html5=!0,c._webAudio=!1,c._sounds=[],delete o[d],c.load())},a(m)}},a=function(c){try{c.send()}catch{c.onerror()}},s=function(c,d){var p=function(){d._emit("loaderror",null,"Decoding audio data failed.")},f=function(h){h&&d._sounds.length>0?(o[d._src]=h,l(d,h)):p()};typeof Promise<"u"&&t.ctx.decodeAudioData.length===1?t.ctx.decodeAudioData(c).then(f).catch(p):t.ctx.decodeAudioData(c,f,p)},l=function(c,d){d&&!c._duration&&(c._duration=d.duration),Object.keys(c._sprite).length===0&&(c._sprite={__default:[0,c._duration*1e3]}),c._state!=="loaded"&&(c._state="loaded",c._emit("load"),c._loadQueue())},u=function(){if(!!t.usingWebAudio){try{typeof AudioContext<"u"?t.ctx=new AudioContext:typeof webkitAudioContext<"u"?t.ctx=new webkitAudioContext:t.usingWebAudio=!1}catch{t.usingWebAudio=!1}t.ctx||(t.usingWebAudio=!1);var c=/iP(hone|od|ad)/.test(t._navigator&&t._navigator.platform),d=t._navigator&&t._navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/),p=d?parseInt(d[1],10):null;if(c&&p&&p<9){var f=/safari/.test(t._navigator&&t._navigator.userAgent.toLowerCase());t._navigator&&!f&&(t.usingWebAudio=!1)}t.usingWebAudio&&(t.masterGain=typeof t.ctx.createGain>"u"?t.ctx.createGainNode():t.ctx.createGain(),t.masterGain.gain.setValueAtTime(t._muted?0:t._volume,t.ctx.currentTime),t.masterGain.connect(t.ctx.destination)),t._setup()}};typeof define=="function"&&define.amd&&define([],function(){return{Howler:t,Howl:e}}),typeof Yu<"u"&&(Yu.Howler=t,Yu.Howl=e),typeof global<"u"?(global.HowlerGlobal=n,global.Howler=t,global.Howl=e,global.Sound=r):typeof window<"u"&&(window.HowlerGlobal=n,window.Howler=t,window.Howl=e,window.Sound=r)})();(function(){"use strict";HowlerGlobal.prototype._pos=[0,0,0],HowlerGlobal.prototype._orientation=[0,0,-1,0,1,0],HowlerGlobal.prototype.stereo=function(t){var e=this;if(!e.ctx||!e.ctx.listener)return e;for(var r=e._howls.length-1;r>=0;r--)e._howls[r].stereo(t);return e},HowlerGlobal.prototype.pos=function(t,e,r){var o=this;if(!o.ctx||!o.ctx.listener)return o;if(e=typeof e!="number"?o._pos[1]:e,r=typeof r!="number"?o._pos[2]:r,typeof t=="number")o._pos=[t,e,r],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(t,e,r,o,i,a){var s=this;if(!s.ctx||!s.ctx.listener)return s;var l=s._orientation;if(e=typeof e!="number"?l[1]:e,r=typeof r!="number"?l[2]:r,o=typeof o!="number"?l[3]:o,i=typeof i!="number"?l[4]:i,a=typeof a!="number"?l[5]:a,typeof t=="number")s._orientation=[t,e,r,o,i,a],typeof s.ctx.listener.forwardX<"u"?(s.ctx.listener.forwardX.setTargetAtTime(t,Howler.ctx.currentTime,.1),s.ctx.listener.forwardY.setTargetAtTime(e,Howler.ctx.currentTime,.1),s.ctx.listener.forwardZ.setTargetAtTime(r,Howler.ctx.currentTime,.1),s.ctx.listener.upX.setTargetAtTime(o,Howler.ctx.currentTime,.1),s.ctx.listener.upY.setTargetAtTime(i,Howler.ctx.currentTime,.1),s.ctx.listener.upZ.setTargetAtTime(a,Howler.ctx.currentTime,.1)):s.ctx.listener.setOrientation(t,e,r,o,i,a);else return l;return s},Howl.prototype.init=function(t){return function(e){var r=this;return r._orientation=e.orientation||[1,0,0],r._stereo=e.stereo||null,r._pos=e.pos||null,r._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},r._onstereo=e.onstereo?[{fn:e.onstereo}]:[],r._onpos=e.onpos?[{fn:e.onpos}]:[],r._onorientation=e.onorientation?[{fn:e.onorientation}]:[],t.call(this,e)}}(Howl.prototype.init),Howl.prototype.stereo=function(t,e){var r=this;if(!r._webAudio)return r;if(r._state!=="loaded")return r._queue.push({event:"stereo",action:function(){r.stereo(t,e)}}),r;var o=typeof Howler.ctx.createStereoPanner>"u"?"spatial":"stereo";if(typeof e>"u")if(typeof t=="number")r._stereo=t,r._pos=[t,0,0];else return r._stereo;for(var i=r._getSoundIds(e),a=0;a<i.length;a++){var s=r._soundById(i[a]);if(s)if(typeof t=="number")s._stereo=t,s._pos=[t,0,0],s._node&&(s._pannerAttr.panningModel="equalpower",(!s._panner||!s._panner.pan)&&n(s,o),o==="spatial"?typeof s._panner.positionX<"u"?(s._panner.positionX.setValueAtTime(t,Howler.ctx.currentTime),s._panner.positionY.setValueAtTime(0,Howler.ctx.currentTime),s._panner.positionZ.setValueAtTime(0,Howler.ctx.currentTime)):s._panner.setPosition(t,0,0):s._panner.pan.setValueAtTime(t,Howler.ctx.currentTime)),r._emit("stereo",s._id);else return s._stereo}return r},Howl.prototype.pos=function(t,e,r,o){var i=this;if(!i._webAudio)return i;if(i._state!=="loaded")return i._queue.push({event:"pos",action:function(){i.pos(t,e,r,o)}}),i;if(e=typeof e!="number"?0:e,r=typeof r!="number"?-.5:r,typeof o>"u")if(typeof t=="number")i._pos=[t,e,r];else return i._pos;for(var a=i._getSoundIds(o),s=0;s<a.length;s++){var l=i._soundById(a[s]);if(l)if(typeof t=="number")l._pos=[t,e,r],l._node&&((!l._panner||l._panner.pan)&&n(l,"spatial"),typeof l._panner.positionX<"u"?(l._panner.positionX.setValueAtTime(t,Howler.ctx.currentTime),l._panner.positionY.setValueAtTime(e,Howler.ctx.currentTime),l._panner.positionZ.setValueAtTime(r,Howler.ctx.currentTime)):l._panner.setPosition(t,e,r)),i._emit("pos",l._id);else return l._pos}return i},Howl.prototype.orientation=function(t,e,r,o){var i=this;if(!i._webAudio)return i;if(i._state!=="loaded")return i._queue.push({event:"orientation",action:function(){i.orientation(t,e,r,o)}}),i;if(e=typeof e!="number"?i._orientation[1]:e,r=typeof r!="number"?i._orientation[2]:r,typeof o>"u")if(typeof t=="number")i._orientation=[t,e,r];else return i._orientation;for(var a=i._getSoundIds(o),s=0;s<a.length;s++){var l=i._soundById(a[s]);if(l)if(typeof t=="number")l._orientation=[t,e,r],l._node&&(l._panner||(l._pos||(l._pos=i._pos||[0,0,-.5]),n(l,"spatial")),typeof l._panner.orientationX<"u"?(l._panner.orientationX.setValueAtTime(t,Howler.ctx.currentTime),l._panner.orientationY.setValueAtTime(e,Howler.ctx.currentTime),l._panner.orientationZ.setValueAtTime(r,Howler.ctx.currentTime)):l._panner.setOrientation(t,e,r)),i._emit("orientation",l._id);else return l._orientation}return i},Howl.prototype.pannerAttr=function(){var t=this,e=arguments,r,o,i;if(!t._webAudio)return t;if(e.length===0)return t._pannerAttr;if(e.length===1)if(typeof e[0]=="object")r=e[0],typeof o>"u"&&(r.pannerAttr||(r.pannerAttr={coneInnerAngle:r.coneInnerAngle,coneOuterAngle:r.coneOuterAngle,coneOuterGain:r.coneOuterGain,distanceModel:r.distanceModel,maxDistance:r.maxDistance,refDistance:r.refDistance,rolloffFactor:r.rolloffFactor,panningModel:r.panningModel}),t._pannerAttr={coneInnerAngle:typeof r.pannerAttr.coneInnerAngle<"u"?r.pannerAttr.coneInnerAngle:t._coneInnerAngle,coneOuterAngle:typeof r.pannerAttr.coneOuterAngle<"u"?r.pannerAttr.coneOuterAngle:t._coneOuterAngle,coneOuterGain:typeof r.pannerAttr.coneOuterGain<"u"?r.pannerAttr.coneOuterGain:t._coneOuterGain,distanceModel:typeof r.pannerAttr.distanceModel<"u"?r.pannerAttr.distanceModel:t._distanceModel,maxDistance:typeof r.pannerAttr.maxDistance<"u"?r.pannerAttr.maxDistance:t._maxDistance,refDistance:typeof r.pannerAttr.refDistance<"u"?r.pannerAttr.refDistance:t._refDistance,rolloffFactor:typeof r.pannerAttr.rolloffFactor<"u"?r.pannerAttr.rolloffFactor:t._rolloffFactor,panningModel:typeof r.pannerAttr.panningModel<"u"?r.pannerAttr.panningModel:t._panningModel});else return i=t._soundById(parseInt(e[0],10)),i?i._pannerAttr:t._pannerAttr;else e.length===2&&(r=e[0],o=parseInt(e[1],10));for(var a=t._getSoundIds(o),s=0;s<a.length;s++)if(i=t._soundById(a[s]),i){var l=i._pannerAttr;l={coneInnerAngle:typeof r.coneInnerAngle<"u"?r.coneInnerAngle:l.coneInnerAngle,coneOuterAngle:typeof r.coneOuterAngle<"u"?r.coneOuterAngle:l.coneOuterAngle,coneOuterGain:typeof r.coneOuterGain<"u"?r.coneOuterGain:l.coneOuterGain,distanceModel:typeof r.distanceModel<"u"?r.distanceModel:l.distanceModel,maxDistance:typeof r.maxDistance<"u"?r.maxDistance:l.maxDistance,refDistance:typeof r.refDistance<"u"?r.refDistance:l.refDistance,rolloffFactor:typeof r.rolloffFactor<"u"?r.rolloffFactor:l.rolloffFactor,panningModel:typeof r.panningModel<"u"?r.panningModel:l.panningModel};var u=i._panner;u?(u.coneInnerAngle=l.coneInnerAngle,u.coneOuterAngle=l.coneOuterAngle,u.coneOuterGain=l.coneOuterGain,u.distanceModel=l.distanceModel,u.maxDistance=l.maxDistance,u.refDistance=l.refDistance,u.rolloffFactor=l.rolloffFactor,u.panningModel=l.panningModel):(i._pos||(i._pos=t._pos||[0,0,-.5]),n(i,"spatial"))}return t},Sound.prototype.init=function(t){return function(){var e=this,r=e._parent;e._orientation=r._orientation,e._stereo=r._stereo,e._pos=r._pos,e._pannerAttr=r._pannerAttr,t.call(this),e._stereo?r.stereo(e._stereo):e._pos&&r.pos(e._pos[0],e._pos[1],e._pos[2],e._id)}}(Sound.prototype.init),Sound.prototype.reset=function(t){return function(){var e=this,r=e._parent;return e._orientation=r._orientation,e._stereo=r._stereo,e._pos=r._pos,e._pannerAttr=r._pannerAttr,e._stereo?r.stereo(e._stereo):e._pos?r.pos(e._pos[0],e._pos[1],e._pos[2],e._id):e._panner&&(e._panner.disconnect(0),e._panner=void 0,r._refreshBuffer(e)),t.call(this)}}(Sound.prototype.reset);var n=function(t,e){e=e||"spatial",e==="spatial"?(t._panner=Howler.ctx.createPanner(),t._panner.coneInnerAngle=t._pannerAttr.coneInnerAngle,t._panner.coneOuterAngle=t._pannerAttr.coneOuterAngle,t._panner.coneOuterGain=t._pannerAttr.coneOuterGain,t._panner.distanceModel=t._pannerAttr.distanceModel,t._panner.maxDistance=t._pannerAttr.maxDistance,t._panner.refDistance=t._pannerAttr.refDistance,t._panner.rolloffFactor=t._pannerAttr.rolloffFactor,t._panner.panningModel=t._pannerAttr.panningModel,typeof t._panner.positionX<"u"?(t._panner.positionX.setValueAtTime(t._pos[0],Howler.ctx.currentTime),t._panner.positionY.setValueAtTime(t._pos[1],Howler.ctx.currentTime),t._panner.positionZ.setValueAtTime(t._pos[2],Howler.ctx.currentTime)):t._panner.setPosition(t._pos[0],t._pos[1],t._pos[2]),typeof t._panner.orientationX<"u"?(t._panner.orientationX.setValueAtTime(t._orientation[0],Howler.ctx.currentTime),t._panner.orientationY.setValueAtTime(t._orientation[1],Howler.ctx.currentTime),t._panner.orientationZ.setValueAtTime(t._orientation[2],Howler.ctx.currentTime)):t._panner.setOrientation(t._orientation[0],t._orientation[1],t._orientation[2])):(t._panner=Howler.ctx.createStereoPanner(),t._panner.pan.setValueAtTime(t._stereo,Howler.ctx.currentTime)),t._panner.connect(t._node),t._paused||t._parent.pause(t._id,!0).play(t._id,!0)}})()});var Zv=Zt((Uae,Kv)=>{"use strict";function oD(n,t){function e(){this.constructor=n}e.prototype=t.prototype,n.prototype=new e}function Ai(n,t,e,r){this.message=n,this.expected=t,this.found=e,this.location=r,this.name="SyntaxError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,Ai)}oD(Ai,Error);Ai.buildMessage=function(n,t){var e={literal:function(u){return'"'+o(u.text)+'"'},class:function(u){var c="",d;for(d=0;d<u.parts.length;d++)c+=u.parts[d]instanceof Array?i(u.parts[d][0])+"-"+i(u.parts[d][1]):i(u.parts[d]);return"["+(u.inverted?"^":"")+c+"]"},any:function(u){return"any character"},end:function(u){return"end of input"},other:function(u){return u.description}};function r(u){return u.charCodeAt(0).toString(16).toUpperCase()}function o(u){return u.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(c){return"\\x0"+r(c)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(c){return"\\x"+r(c)})}function i(u){return u.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(c){return"\\x0"+r(c)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(c){return"\\x"+r(c)})}function a(u){return e[u.type](u)}function s(u){var c=new Array(u.length),d,p;for(d=0;d<u.length;d++)c[d]=a(u[d]);if(c.sort(),c.length>0){for(d=1,p=1;d<c.length;d++)c[d-1]!==c[d]&&(c[p]=c[d],p++);c.length=p}switch(c.length){case 1:return c[0];case 2:return c[0]+" or "+c[1];default:return c.slice(0,-1).join(", ")+", or "+c[c.length-1]}}function l(u){return u?'"'+o(u)+'"':"end of input"}return"Expected "+s(n)+" but "+l(t)+" found."};function nD(n,t){t=t!==void 0?t:{};var e={},r={svg_path:Ls},o=Ls,i=function(v){if(!v)return[];for(var _=[],L=0;L<v.length;L++)_=_.concat.apply(_,v[L]);var M=_[0];return M&&M.code=="m"&&(delete M.relative,M.code="M"),_},a=function(v,_){return W1(v,_)},s=/^[Mm]/,l=Ke(["M","m"],!1,!1),u=function(v,_,L){var M=Di(v,[_]);return L&&(M=M.concat(Di(v=="M"?"L":"l",L[1]))),M},c=/^[Zz]/,d=Ke(["Z","z"],!1,!1),p=function(){return Di("Z")},f=/^[Ll]/,h=Ke(["L","l"],!1,!1),m=function(v,_){return Di(v,_)},y=/^[Hh]/,g=Ke(["H","h"],!1,!1),b=function(v,_){return Di(v,_.map(function(L){return{x:L}}))},w=/^[Vv]/,A=Ke(["V","v"],!1,!1),S=function(v,_){return Di(v,_.map(function(L){return{y:L}}))},P=/^[Cc]/,O=Ke(["C","c"],!1,!1),x=function(v,_,L){return{x1:v.x,y1:v.y,x2:_.x,y2:_.y,x:L.x,y:L.y}},D=/^[Ss]/,N=Ke(["S","s"],!1,!1),T=function(v,_){return{x2:v.x,y2:v.y,x:_.x,y:_.y}},I=/^[Qq]/,E=Ke(["Q","q"],!1,!1),B=function(v,_){return{x1:v.x,y1:v.y,x:_.x,y:_.y}},R=/^[Tt]/,F=Ke(["T","t"],!1,!1),V=/^[Aa]/,q=Ke(["A","a"],!1,!1),k=function(v,_,L,M,z,oe){return{rx:v,ry:_,xAxisRotation:L,largeArc:M,sweep:z,x:oe.x,y:oe.y}},U=function(v,_){return{x:v,y:_}},H=function(v){return v*1},Y=function(v){return v.join("")*1},J=/^[01]/,Z=Ke(["0","1"],!1,!1),X=function(v){return v=="1"},te=function(){return""},$=",",ee=st(",",!1),Q=function(v){return v.join("")},W=".",ue=st(".",!1),le=/^[eE]/,ne=Ke(["e","E"],!1,!1),ce=/^[+\-]/,ae=Ke(["+","-"],!1,!1),he=/^[0-9]/,pe=Ke([["0","9"]],!1,!1),fe=function(v){return v.join("")},ge=/^[ \t\n\r]/,me=Ke([" "," ",`
2
+ `,"\r"],!1,!1),C=0,ie=0,De=[{line:1,column:1}],Ge=0,Ee=[],_e=0,Ct;if("startRule"in t){if(!(t.startRule in r))throw new Error(`Can't start parsing from rule "`+t.startRule+'".');o=r[t.startRule]}function Me(){return n.substring(ie,C)}function At(){return $n(ie,C)}function Tt(v,_){throw _=_!==void 0?_:$n(ie,C),Cr([Ed(v)],n.substring(ie,C),_)}function Wn(v,_){throw _=_!==void 0?_:$n(ie,C),Bd(v,_)}function st(v,_){return{type:"literal",text:v,ignoreCase:_}}function Ke(v,_,L){return{type:"class",parts:v,inverted:_,ignoreCase:L}}function kr(){return{type:"any"}}function Dd(){return{type:"end"}}function Ed(v){return{type:"other",description:v}}function jl(v){var _=De[v],L;if(_)return _;for(L=v-1;!De[L];)L--;for(_=De[L],_={line:_.line,column:_.column};L<v;)n.charCodeAt(L)===10?(_.line++,_.column=1):_.column++,L++;return De[v]=_,_}function $n(v,_){var L=jl(v),M=jl(_);return{start:{offset:v,line:L.line,column:L.column},end:{offset:_,line:M.line,column:M.column}}}function mt(v){C<Ge||(C>Ge&&(Ge=C,Ee=[]),Ee.push(v))}function Bd(v,_){return new Ai(v,null,null,_)}function Cr(v,_,L){return new Ai(Ai.buildMessage(v,_),v,_,L)}function Ls(){var v,_,L,M,z;for(v=C,_=[],L=Fe();L!==e;)_.push(L),L=Fe();if(_!==e)if(L=Kt(),L===e&&(L=null),L!==e){for(M=[],z=Fe();z!==e;)M.push(z),z=Fe();M!==e?(ie=v,_=i(L),v=_):(C=v,v=e)}else C=v,v=e;else C=v,v=e;return v}function Kt(){var v,_,L,M,z,oe;if(v=C,_=Yn(),_!==e){for(L=[],M=C,z=[],oe=Fe();oe!==e;)z.push(oe),oe=Fe();for(z!==e?(oe=Yn(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);M!==e;){for(L.push(M),M=C,z=[],oe=Fe();oe!==e;)z.push(oe),oe=Fe();z!==e?(oe=Yn(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e)}L!==e?(ie=v,_=a(_,L),v=_):(C=v,v=e)}else C=v,v=e;return v}function Yn(){var v,_,L,M,z,oe;if(v=C,_=Ii(),_!==e){for(L=[],M=C,z=[],oe=Fe();oe!==e;)z.push(oe),oe=Fe();for(z!==e?(oe=Ul(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);M!==e;){for(L.push(M),M=C,z=[],oe=Fe();oe!==e;)z.push(oe),oe=Fe();z!==e?(oe=Ul(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e)}L!==e?(ie=v,_=a(_,L),v=_):(C=v,v=e)}else C=v,v=e;return v}function Ul(){var v;return v=N1(),v===e&&(v=D1(),v===e&&(v=E1(),v===e&&(v=B1(),v===e&&(v=L1(),v===e&&(v=V1(),v===e&&(v=G1(),v===e&&(v=k1(),v===e&&(v=U1())))))))),v}function Ii(){var v,_,L,M,z,oe,Ei;if(v=C,s.test(n.charAt(C))?(_=n.charAt(C),C++):(_=e,_e===0&&mt(l)),_!==e){for(L=[],M=Fe();M!==e;)L.push(M),M=Fe();L!==e?(M=tr(),M!==e?(z=C,oe=nt(),oe===e&&(oe=null),oe!==e?(Ei=Yh(),Ei!==e?(oe=[oe,Ei],z=oe):(C=z,z=e)):(C=z,z=e),z===e&&(z=null),z!==e?(ie=v,_=u(_,M,z),v=_):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function N1(){var v,_;return v=C,c.test(n.charAt(C))?(_=n.charAt(C),C++):(_=e,_e===0&&mt(d)),_!==e&&(ie=v,_=p()),v=_,v}function D1(){var v,_,L,M;if(v=C,f.test(n.charAt(C))?(_=n.charAt(C),C++):(_=e,_e===0&&mt(h)),_!==e){for(L=[],M=Fe();M!==e;)L.push(M),M=Fe();L!==e?(M=Yh(),M!==e?(ie=v,_=m(_,M),v=_):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function Yh(){var v,_,L,M,z,oe;if(v=C,_=tr(),_!==e){for(L=[],M=C,z=nt(),z===e&&(z=null),z!==e?(oe=tr(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);M!==e;)L.push(M),M=C,z=nt(),z===e&&(z=null),z!==e?(oe=tr(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);L!==e?(ie=v,_=a(_,L),v=_):(C=v,v=e)}else C=v,v=e;return v}function E1(){var v,_,L,M;if(v=C,y.test(n.charAt(C))?(_=n.charAt(C),C++):(_=e,_e===0&&mt(g)),_!==e){for(L=[],M=Fe();M!==e;)L.push(M),M=Fe();L!==e?(M=Xh(),M!==e?(ie=v,_=b(_,M),v=_):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function Xh(){var v,_,L,M,z,oe;if(v=C,_=Ni(),_!==e){for(L=[],M=C,z=nt(),z===e&&(z=null),z!==e?(oe=Ni(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);M!==e;)L.push(M),M=C,z=nt(),z===e&&(z=null),z!==e?(oe=Ni(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);L!==e?(ie=v,_=a(_,L),v=_):(C=v,v=e)}else C=v,v=e;return v}function B1(){var v,_,L,M;if(v=C,w.test(n.charAt(C))?(_=n.charAt(C),C++):(_=e,_e===0&&mt(A)),_!==e){for(L=[],M=Fe();M!==e;)L.push(M),M=Fe();L!==e?(M=Xh(),M!==e?(ie=v,_=S(_,M),v=_):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function L1(){var v,_,L,M;if(v=C,P.test(n.charAt(C))?(_=n.charAt(C),C++):(_=e,_e===0&&mt(O)),_!==e){for(L=[],M=Fe();M!==e;)L.push(M),M=Fe();L!==e?(M=R1(),M!==e?(ie=v,_=m(_,M),v=_):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function R1(){var v,_,L,M,z,oe;if(v=C,_=Ld(),_!==e){for(L=[],M=C,z=nt(),z===e&&(z=null),z!==e?(oe=Ld(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);M!==e;)L.push(M),M=C,z=nt(),z===e&&(z=null),z!==e?(oe=Ld(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);L!==e?(ie=v,_=a(_,L),v=_):(C=v,v=e)}else C=v,v=e;return v}function Ld(){var v,_,L,M,z,oe;return v=C,_=tr(),_!==e?(L=nt(),L===e&&(L=null),L!==e?(M=tr(),M!==e?(z=nt(),z===e&&(z=null),z!==e?(oe=tr(),oe!==e?(ie=v,_=x(_,M,oe),v=_):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e),v}function V1(){var v,_,L,M;if(v=C,D.test(n.charAt(C))?(_=n.charAt(C),C++):(_=e,_e===0&&mt(N)),_!==e){for(L=[],M=Fe();M!==e;)L.push(M),M=Fe();L!==e?(M=z1(),M!==e?(ie=v,_=m(_,M),v=_):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function z1(){var v,_,L,M,z,oe;if(v=C,_=Rd(),_!==e){for(L=[],M=C,z=nt(),z===e&&(z=null),z!==e?(oe=Rd(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);M!==e;)L.push(M),M=C,z=nt(),z===e&&(z=null),z!==e?(oe=Rd(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);L!==e?(ie=v,_=a(_,L),v=_):(C=v,v=e)}else C=v,v=e;return v}function Rd(){var v,_,L,M;return v=C,_=tr(),_!==e?(L=nt(),L===e&&(L=null),L!==e?(M=tr(),M!==e?(ie=v,_=T(_,M),v=_):(C=v,v=e)):(C=v,v=e)):(C=v,v=e),v}function G1(){var v,_,L,M;if(v=C,I.test(n.charAt(C))?(_=n.charAt(C),C++):(_=e,_e===0&&mt(E)),_!==e){for(L=[],M=Fe();M!==e;)L.push(M),M=Fe();L!==e?(M=F1(),M!==e?(ie=v,_=m(_,M),v=_):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function F1(){var v,_,L,M,z,oe;if(v=C,_=Vd(),_!==e){for(L=[],M=C,z=nt(),z===e&&(z=null),z!==e?(oe=Vd(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);M!==e;)L.push(M),M=C,z=nt(),z===e&&(z=null),z!==e?(oe=Vd(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);L!==e?(ie=v,_=a(_,L),v=_):(C=v,v=e)}else C=v,v=e;return v}function Vd(){var v,_,L,M;return v=C,_=tr(),_!==e?(L=nt(),L===e&&(L=null),L!==e?(M=tr(),M!==e?(ie=v,_=B(_,M),v=_):(C=v,v=e)):(C=v,v=e)):(C=v,v=e),v}function k1(){var v,_,L,M;if(v=C,R.test(n.charAt(C))?(_=n.charAt(C),C++):(_=e,_e===0&&mt(F)),_!==e){for(L=[],M=Fe();M!==e;)L.push(M),M=Fe();L!==e?(M=j1(),M!==e?(ie=v,_=m(_,M),v=_):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function j1(){var v,_,L,M,z,oe;if(v=C,_=tr(),_!==e){for(L=[],M=C,z=nt(),z===e&&(z=null),z!==e?(oe=tr(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);M!==e;)L.push(M),M=C,z=nt(),z===e&&(z=null),z!==e?(oe=tr(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);L!==e?(ie=v,_=a(_,L),v=_):(C=v,v=e)}else C=v,v=e;return v}function U1(){var v,_,L,M;if(v=C,V.test(n.charAt(C))?(_=n.charAt(C),C++):(_=e,_e===0&&mt(q)),_!==e){for(L=[],M=Fe();M!==e;)L.push(M),M=Fe();L!==e?(M=H1(),M!==e?(ie=v,_=m(_,M),v=_):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function H1(){var v,_,L,M,z,oe;if(v=C,_=zd(),_!==e){for(L=[],M=C,z=nt(),z===e&&(z=null),z!==e?(oe=zd(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);M!==e;)L.push(M),M=C,z=nt(),z===e&&(z=null),z!==e?(oe=zd(),oe!==e?(z=[z,oe],M=z):(C=M,M=e)):(C=M,M=e);L!==e?(ie=v,_=a(_,L),v=_):(C=v,v=e)}else C=v,v=e;return v}function zd(){var v,_,L,M,z,oe,Ei,Fd,ql,kd,Wl,jd;return v=C,_=Qh(),_!==e?(L=nt(),L===e&&(L=null),L!==e?(M=Qh(),M!==e?(z=nt(),z===e&&(z=null),z!==e?(oe=Ni(),oe!==e?(Ei=nt(),Ei!==e?(Fd=Kh(),Fd!==e?(ql=nt(),ql===e&&(ql=null),ql!==e?(kd=Kh(),kd!==e?(Wl=nt(),Wl===e&&(Wl=null),Wl!==e?(jd=tr(),jd!==e?(ie=v,_=k(_,M,oe,Fd,kd,jd),v=_):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e),v}function tr(){var v,_,L,M;return v=C,_=Ni(),_!==e?(L=nt(),L===e&&(L=null),L!==e?(M=Ni(),M!==e?(ie=v,_=U(_,M),v=_):(C=v,v=e)):(C=v,v=e)):(C=v,v=e),v}function Qh(){var v,_;return v=C,_=Jh(),_===e&&(_=Xn()),_!==e&&(ie=v,_=H(_)),v=_,v}function Ni(){var v,_,L,M;return v=C,_=C,L=Gd(),L===e&&(L=null),L!==e?(M=Jh(),M!==e?(L=[L,M],_=L):(C=_,_=e)):(C=_,_=e),_===e&&(_=C,L=Gd(),L===e&&(L=null),L!==e?(M=Xn(),M!==e?(L=[L,M],_=L):(C=_,_=e)):(C=_,_=e)),_!==e&&(ie=v,_=Y(_)),v=_,v}function Kh(){var v,_;return v=C,J.test(n.charAt(C))?(_=n.charAt(C),C++):(_=e,_e===0&&mt(Z)),_!==e&&(ie=v,_=X(_)),v=_,v}function nt(){var v,_,L,M,z;if(v=C,_=[],L=Fe(),L!==e)for(;L!==e;)_.push(L),L=Fe();else _=e;if(_!==e)if(L=Zh(),L===e&&(L=null),L!==e){for(M=[],z=Fe();z!==e;)M.push(z),z=Fe();M!==e?(_=[_,L,M],v=_):(C=v,v=e)}else C=v,v=e;else C=v,v=e;if(v===e){if(v=C,_=C,L=Zh(),L!==e){for(M=[],z=Fe();z!==e;)M.push(z),z=Fe();M!==e?(L=[L,M],_=L):(C=_,_=e)}else C=_,_=e;_!==e&&(ie=v,_=te()),v=_}return v}function Zh(){var v;return n.charCodeAt(C)===44?(v=$,C++):(v=e,_e===0&&mt(ee)),v}function Jh(){var v,_,L,M;return v=C,_=C,L=q1(),L!==e?(M=em(),M===e&&(M=null),M!==e?(L=[L,M],_=L):(C=_,_=e)):(C=_,_=e),_===e&&(_=C,L=Xn(),L!==e?(M=em(),M!==e?(L=[L,M],_=L):(C=_,_=e)):(C=_,_=e)),_!==e&&(ie=v,_=Q(_)),v=_,v}function q1(){var v,_,L,M,z;return v=C,_=C,L=Xn(),L===e&&(L=null),L!==e?(n.charCodeAt(C)===46?(M=W,C++):(M=e,_e===0&&mt(ue)),M!==e?(z=Xn(),z!==e?(L=[L,M,z],_=L):(C=_,_=e)):(C=_,_=e)):(C=_,_=e),_===e&&(_=C,L=Xn(),L!==e?(n.charCodeAt(C)===46?(M=W,C++):(M=e,_e===0&&mt(ue)),M!==e?(L=[L,M],_=L):(C=_,_=e)):(C=_,_=e)),_!==e&&(ie=v,_=Q(_)),v=_,v}function em(){var v,_,L,M,z;return v=C,_=C,le.test(n.charAt(C))?(L=n.charAt(C),C++):(L=e,_e===0&&mt(ne)),L!==e?(M=Gd(),M===e&&(M=null),M!==e?(z=Xn(),z!==e?(L=[L,M,z],_=L):(C=_,_=e)):(C=_,_=e)):(C=_,_=e),_!==e&&(ie=v,_=Q(_)),v=_,v}function Gd(){var v;return ce.test(n.charAt(C))?(v=n.charAt(C),C++):(v=e,_e===0&&mt(ae)),v}function Xn(){var v,_,L;if(v=C,_=[],he.test(n.charAt(C))?(L=n.charAt(C),C++):(L=e,_e===0&&mt(pe)),L!==e)for(;L!==e;)_.push(L),he.test(n.charAt(C))?(L=n.charAt(C),C++):(L=e,_e===0&&mt(pe));else _=e;return _!==e&&(ie=v,_=fe(_)),v=_,v}function Fe(){var v,_;return v=C,ge.test(n.charAt(C))?(_=n.charAt(C),C++):(_=e,_e===0&&mt(me)),_!==e&&(ie=v,_=te()),v=_,v}function W1(v,_){if(!_)return[v];for(var L=[v],M=0,z=_.length;M<z;M++)L[M+1]=_[M][1];return L}var Hl={m:"moveto",l:"lineto",h:"horizontal lineto",v:"vertical lineto",c:"curveto",s:"smooth curveto",q:"quadratic curveto",t:"smooth quadratic curveto",a:"elliptical arc",z:"closepath"};for(var tm in Hl)Hl[tm.toUpperCase()]=Hl[tm];function Di(v,_){_||(_=[{}]);for(var L=_.length;L--;){var M={code:v,command:Hl[v]};v==v.toLowerCase()&&(M.relative=!0);for(var z in _[L])M[z]=_[L][z];_[L]=M}return _}if(Ct=o(),Ct!==e&&C===n.length)return Ct;throw Ct!==e&&C<n.length&&mt(Dd()),Cr(Ee,Ge<n.length?n.charAt(Ge):null,Ge<n.length?$n(Ge,Ge+1):$n(Ge,Ge))}Kv.exports={SyntaxError:Ai,parse:nD}});var Oh=Zt((Hae,Jv)=>{var md=Zv().parse;md.parseSVG=md;md.makeAbsolute=iD;Jv.exports=md;function iD(n){var t,e={x:0,y:0},r={x:"x0",y:"y0",x1:"x0",y1:"y0",x2:"x0",y2:"y0"};return n.forEach(function(o){o.command==="moveto"&&(t=o),o.x0=e.x,o.y0=e.y;for(var i in r)i in o&&(o[i]+=o.relative?o[r[i]]:0);"x"in o||(o.x=e.x),"y"in o||(o.y=e.y),o.relative=!1,o.code=o.code.toUpperCase(),o.command=="closepath"&&(o.x=t.x,o.y=t.y),e=o}),n}});var RS=Zt((_de,LS)=>{"use strict";function JD(n){for(var t=new Array(n),e=0;e<n;++e)t[e]=e;return t}LS.exports=JD});var GS=Zt((Pde,zS)=>{zS.exports=function(n){return n!=null&&(VS(n)||eE(n)||!!n._isBuffer)};function VS(n){return!!n.constructor&&typeof n.constructor.isBuffer=="function"&&n.constructor.isBuffer(n)}function eE(n){return typeof n.readFloatLE=="function"&&typeof n.slice=="function"&&VS(n.slice(0,0))}});var Ds=Zt((Ode,FS)=>{var tE=RS(),rE=GS(),oE=typeof Float64Array<"u";function nE(n,t){return n[0]-t[0]}function iE(){var n=this.stride,t=new Array(n.length),e;for(e=0;e<t.length;++e)t[e]=[Math.abs(n[e]),e];t.sort(nE);var r=new Array(t.length);for(e=0;e<r.length;++e)r[e]=t[e][1];return r}function aE(n,t){var e=["View",t,"d",n].join("");t<0&&(e="View_Nil"+n);var r=n==="generic";if(t===-1){var o="function "+e+"(a){this.data=a;};var proto="+e+".prototype;proto.dtype='"+n+"';proto.index=function(){return -1};proto.size=0;proto.dimension=-1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function(){return new "+e+"(this.data);};proto.get=proto.set=function(){};proto.pick=function(){return null};return function construct_"+e+"(a){return new "+e+"(a);}",m=new Function(o);return m()}else if(t===0){var o="function "+e+"(a,d) {this.data = a;this.offset = d};var proto="+e+".prototype;proto.dtype='"+n+"';proto.index=function(){return this.offset};proto.dimension=0;proto.size=1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function "+e+"_copy() {return new "+e+"(this.data,this.offset)};proto.pick=function "+e+"_pick(){return TrivialArray(this.data);};proto.valueOf=proto.get=function "+e+"_get(){return "+(r?"this.data.get(this.offset)":"this.data[this.offset]")+"};proto.set=function "+e+"_set(v){return "+(r?"this.data.set(this.offset,v)":"this.data[this.offset]=v")+"};return function construct_"+e+"(a,b,c,d){return new "+e+"(a,d)}",m=new Function("TrivialArray",o);return m(Od[n][0])}var o=["'use strict'"],i=tE(t),a=i.map(function(y){return"i"+y}),s="this.offset+"+i.map(function(y){return"this.stride["+y+"]*i"+y}).join("+"),l=i.map(function(y){return"b"+y}).join(","),u=i.map(function(y){return"c"+y}).join(",");o.push("function "+e+"(a,"+l+","+u+",d){this.data=a","this.shape=["+l+"]","this.stride=["+u+"]","this.offset=d|0}","var proto="+e+".prototype","proto.dtype='"+n+"'","proto.dimension="+t),o.push("Object.defineProperty(proto,'size',{get:function "+e+"_size(){return "+i.map(function(y){return"this.shape["+y+"]"}).join("*"),"}})"),t===1?o.push("proto.order=[0]"):(o.push("Object.defineProperty(proto,'order',{get:"),t<4?(o.push("function "+e+"_order(){"),t===2?o.push("return (Math.abs(this.stride[0])>Math.abs(this.stride[1]))?[1,0]:[0,1]}})"):t===3&&o.push("var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);if(s0>s1){if(s1>s2){return [2,1,0];}else if(s0>s2){return [1,2,0];}else{return [1,0,2];}}else if(s0>s2){return [2,0,1];}else if(s2>s1){return [0,1,2];}else{return [0,2,1];}}})")):o.push("ORDER})")),o.push("proto.set=function "+e+"_set("+a.join(",")+",v){"),r?o.push("return this.data.set("+s+",v)}"):o.push("return this.data["+s+"]=v}"),o.push("proto.get=function "+e+"_get("+a.join(",")+"){"),r?o.push("return this.data.get("+s+")}"):o.push("return this.data["+s+"]}"),o.push("proto.index=function "+e+"_index(",a.join(),"){return "+s+"}"),o.push("proto.hi=function "+e+"_hi("+a.join(",")+"){return new "+e+"(this.data,"+i.map(function(y){return["(typeof i",y,"!=='number'||i",y,"<0)?this.shape[",y,"]:i",y,"|0"].join("")}).join(",")+","+i.map(function(y){return"this.stride["+y+"]"}).join(",")+",this.offset)}");var c=i.map(function(y){return"a"+y+"=this.shape["+y+"]"}),d=i.map(function(y){return"c"+y+"=this.stride["+y+"]"});o.push("proto.lo=function "+e+"_lo("+a.join(",")+"){var b=this.offset,d=0,"+c.join(",")+","+d.join(","));for(var p=0;p<t;++p)o.push("if(typeof i"+p+"==='number'&&i"+p+">=0){d=i"+p+"|0;b+=c"+p+"*d;a"+p+"-=d}");o.push("return new "+e+"(this.data,"+i.map(function(y){return"a"+y}).join(",")+","+i.map(function(y){return"c"+y}).join(",")+",b)}"),o.push("proto.step=function "+e+"_step("+a.join(",")+"){var "+i.map(function(y){return"a"+y+"=this.shape["+y+"]"}).join(",")+","+i.map(function(y){return"b"+y+"=this.stride["+y+"]"}).join(",")+",c=this.offset,d=0,ceil=Math.ceil");for(var p=0;p<t;++p)o.push("if(typeof i"+p+"==='number'){d=i"+p+"|0;if(d<0){c+=b"+p+"*(a"+p+"-1);a"+p+"=ceil(-a"+p+"/d)}else{a"+p+"=ceil(a"+p+"/d)}b"+p+"*=d}");o.push("return new "+e+"(this.data,"+i.map(function(y){return"a"+y}).join(",")+","+i.map(function(y){return"b"+y}).join(",")+",c)}");for(var f=new Array(t),h=new Array(t),p=0;p<t;++p)f[p]="a[i"+p+"]",h[p]="b[i"+p+"]";o.push("proto.transpose=function "+e+"_transpose("+a+"){"+a.map(function(y,g){return y+"=("+y+"===undefined?"+g+":"+y+"|0)"}).join(";"),"var a=this.shape,b=this.stride;return new "+e+"(this.data,"+f.join(",")+","+h.join(",")+",this.offset)}"),o.push("proto.pick=function "+e+"_pick("+a+"){var a=[],b=[],c=this.offset");for(var p=0;p<t;++p)o.push("if(typeof i"+p+"==='number'&&i"+p+">=0){c=(c+this.stride["+p+"]*i"+p+")|0}else{a.push(this.shape["+p+"]);b.push(this.stride["+p+"])}");o.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}"),o.push("return function construct_"+e+"(data,shape,stride,offset){return new "+e+"(data,"+i.map(function(y){return"shape["+y+"]"}).join(",")+","+i.map(function(y){return"stride["+y+"]"}).join(",")+",offset)}");var m=new Function("CTOR_LIST","ORDER",o.join(`
3
+ `));return m(Od[n],iE)}function sE(n){if(rE(n))return"buffer";if(oE)switch(Object.prototype.toString.call(n)){case"[object Float64Array]":return"float64";case"[object Float32Array]":return"float32";case"[object Int8Array]":return"int8";case"[object Int16Array]":return"int16";case"[object Int32Array]":return"int32";case"[object Uint8Array]":return"uint8";case"[object Uint16Array]":return"uint16";case"[object Uint32Array]":return"uint32";case"[object Uint8ClampedArray]":return"uint8_clamped";case"[object BigInt64Array]":return"bigint64";case"[object BigUint64Array]":return"biguint64"}return Array.isArray(n)?"array":"generic"}var Od={float32:[],float64:[],int8:[],int16:[],int32:[],uint8:[],uint16:[],uint32:[],array:[],uint8_clamped:[],bigint64:[],biguint64:[],buffer:[],generic:[]};function lE(n,t,e,r){if(n===void 0){var u=Od.array[0];return u([])}else typeof n=="number"&&(n=[n]);t===void 0&&(t=[n.length]);var o=t.length;if(e===void 0){e=new Array(o);for(var i=o-1,a=1;i>=0;--i)e[i]=a,a*=t[i]}if(r===void 0){r=0;for(var i=0;i<o;++i)e[i]<0&&(r-=(t[i]-1)*e[i])}for(var s=sE(n),l=Od[s];l.length<=o+1;)l.push(aE(s,l.length-1));var u=l[o+1];return u(n,t,e,r)}FS.exports=lE});var jS=Zt((Cde,kS)=>{"use strict";function cE(n,t){for(var e=1,r=n.length,o=n[0],i=n[0],a=1;a<r;++a)if(i=o,o=n[a],t(o,i)){if(a===e){e++;continue}n[e++]=o}return n.length=e,n}function uE(n){for(var t=1,e=n.length,r=n[0],o=n[0],i=1;i<e;++i,o=r)if(o=r,r=n[i],r!==o){if(i===t){t++;continue}n[t++]=r}return n.length=t,n}function dE(n,t,e){return n.length===0?n:t?(e||n.sort(t),cE(n,t)):(e||n.sort(),uE(n))}kS.exports=dE});var qS=Zt((Tde,HS)=>{"use strict";var pE=jS();function US(n,t,e){var r=n.length,o=t.arrayArgs.length,i=t.indexArgs.length>0,a=[],s=[],l=0,u=0,c,d;for(c=0;c<r;++c)s.push(["i",c,"=0"].join(""));for(d=0;d<o;++d)for(c=0;c<r;++c)u=l,l=n[c],c===0?s.push(["d",d,"s",c,"=t",d,"p",l].join("")):s.push(["d",d,"s",c,"=(t",d,"p",l,"-s",u,"*t",d,"p",u,")"].join(""));for(s.length>0&&a.push("var "+s.join(",")),c=r-1;c>=0;--c)l=n[c],a.push(["for(i",c,"=0;i",c,"<s",l,";++i",c,"){"].join(""));for(a.push(e),c=0;c<r;++c){for(u=l,l=n[c],d=0;d<o;++d)a.push(["p",d,"+=d",d,"s",c].join(""));i&&(c>0&&a.push(["index[",u,"]-=s",u].join("")),a.push(["++index[",l,"]"].join(""))),a.push("}")}return a.join(`
4
+ `)}function fE(n,t,e,r){for(var o=t.length,i=e.arrayArgs.length,a=e.blockSize,s=e.indexArgs.length>0,l=[],u=0;u<i;++u)l.push(["var offset",u,"=p",u].join(""));for(var u=n;u<o;++u)l.push(["for(var j"+u+"=SS[",t[u],"]|0;j",u,">0;){"].join("")),l.push(["if(j",u,"<",a,"){"].join("")),l.push(["s",t[u],"=j",u].join("")),l.push(["j",u,"=0"].join("")),l.push(["}else{s",t[u],"=",a].join("")),l.push(["j",u,"-=",a,"}"].join("")),s&&l.push(["index[",t[u],"]=j",u].join(""));for(var u=0;u<i;++u){for(var c=["offset"+u],d=n;d<o;++d)c.push(["j",d,"*t",u,"p",t[d]].join(""));l.push(["p",u,"=(",c.join("+"),")"].join(""))}l.push(US(t,e,r));for(var u=n;u<o;++u)l.push("}");return l.join(`
5
+ `)}function hE(n){for(var t=0,e=n[0].length;t<e;){for(var r=1;r<n.length;++r)if(n[r][t]!==n[0][t])return t;++t}return t}function zh(n,t,e){for(var r=n.body,o=[],i=[],a=0;a<n.args.length;++a){var s=n.args[a];if(!(s.count<=0)){var l=new RegExp(s.name,"g"),u="",c=t.arrayArgs.indexOf(a);switch(t.argTypes[a]){case"offset":var d=t.offsetArgIndex.indexOf(a),p=t.offsetArgs[d];c=p.array,u="+q"+d;case"array":u="p"+c+u;var f="l"+a,h="a"+c;if(t.arrayBlockIndices[c]===0)s.count===1?e[c]==="generic"?s.lvalue?(o.push(["var ",f,"=",h,".get(",u,")"].join("")),r=r.replace(l,f),i.push([h,".set(",u,",",f,")"].join(""))):r=r.replace(l,[h,".get(",u,")"].join("")):r=r.replace(l,[h,"[",u,"]"].join("")):e[c]==="generic"?(o.push(["var ",f,"=",h,".get(",u,")"].join("")),r=r.replace(l,f),s.lvalue&&i.push([h,".set(",u,",",f,")"].join(""))):(o.push(["var ",f,"=",h,"[",u,"]"].join("")),r=r.replace(l,f),s.lvalue&&i.push([h,"[",u,"]=",f].join("")));else{for(var m=[s.name],y=[u],g=0;g<Math.abs(t.arrayBlockIndices[c]);g++)m.push("\\s*\\[([^\\]]+)\\]"),y.push("$"+(g+1)+"*t"+c+"b"+g);if(l=new RegExp(m.join(""),"g"),u=y.join("+"),e[c]==="generic")throw new Error("cwise: Generic arrays not supported in combination with blocks!");r=r.replace(l,[h,"[",u,"]"].join(""))}break;case"scalar":r=r.replace(l,"Y"+t.scalarArgs.indexOf(a));break;case"index":r=r.replace(l,"index");break;case"shape":r=r.replace(l,"shape");break}}}return[o.join(`
6
6
  `),r,i.join(`
7
7
  `)].join(`
8
- `).trim()}function uE(n){for(var t=new Array(n.length),e=!0,r=0;r<n.length;++r){var o=n[r],i=o.match(/\d+/);i?i=i[0]:i="",o.charAt(0)===0?t[r]="u"+o.charAt(1)+i:t[r]=o.charAt(0)+i,r>0&&(e=e&&t[r]===t[r-1])}return e?t[0]:t.join("")}function dE(n,t){for(var e=t[1].length-Math.abs(n.arrayBlockIndices[0])|0,r=new Array(n.arrayArgs.length),o=new Array(n.arrayArgs.length),i=0;i<n.arrayArgs.length;++i)o[i]=t[2*i],r[i]=t[2*i+1];for(var a=[],s=[],l=[],u=[],c=[],i=0;i<n.arrayArgs.length;++i){n.arrayBlockIndices[i]<0?(l.push(0),u.push(e),a.push(e),s.push(e+n.arrayBlockIndices[i])):(l.push(n.arrayBlockIndices[i]),u.push(n.arrayBlockIndices[i]+e),a.push(0),s.push(n.arrayBlockIndices[i]));for(var d=[],p=0;p<r[i].length;p++)l[i]<=r[i][p]&&r[i][p]<u[i]&&d.push(r[i][p]-l[i]);c.push(d)}for(var f=["SS"],h=["'use strict'"],m=[],p=0;p<e;++p)m.push(["s",p,"=SS[",p,"]"].join(""));for(var i=0;i<n.arrayArgs.length;++i){f.push("a"+i),f.push("t"+i),f.push("p"+i);for(var p=0;p<e;++p)m.push(["t",i,"p",p,"=t",i,"[",l[i]+p,"]"].join(""));for(var p=0;p<Math.abs(n.arrayBlockIndices[i]);++p)m.push(["t",i,"b",p,"=t",i,"[",a[i]+p,"]"].join(""))}for(var i=0;i<n.scalarArgs.length;++i)f.push("Y"+i);if(n.shapeArgs.length>0&&m.push("shape=SS.slice(0)"),n.indexArgs.length>0){for(var y=new Array(e),i=0;i<e;++i)y[i]="0";m.push(["index=[",y.join(","),"]"].join(""))}for(var i=0;i<n.offsetArgs.length;++i){for(var g=n.offsetArgs[i],b=[],p=0;p<g.offset.length;++p)g.offset[p]!==0&&(g.offset[p]===1?b.push(["t",g.array,"p",p].join("")):b.push([g.offset[p],"*t",g.array,"p",p].join("")));b.length===0?m.push("q"+i+"=0"):m.push(["q",i,"=",b.join("+")].join(""))}var w=sE([].concat(n.pre.thisVars).concat(n.body.thisVars).concat(n.post.thisVars));m=m.concat(w),m.length>0&&h.push("var "+m.join(","));for(var i=0;i<n.arrayArgs.length;++i)h.push("p"+i+"|=0");n.pre.body.length>3&&h.push(Vh(n.pre,n,o));var _=Vh(n.body,n,o),S=cE(c);S<e?h.push(lE(S,c[0],n,_)):h.push(GS(c[0],n,_)),n.post.body.length>3&&h.push(Vh(n.post,n,o)),n.debug&&console.log("-----Generated cwise routine for ",t,`:
8
+ `).trim()}function mE(n){for(var t=new Array(n.length),e=!0,r=0;r<n.length;++r){var o=n[r],i=o.match(/\d+/);i?i=i[0]:i="",o.charAt(0)===0?t[r]="u"+o.charAt(1)+i:t[r]=o.charAt(0)+i,r>0&&(e=e&&t[r]===t[r-1])}return e?t[0]:t.join("")}function yE(n,t){for(var e=t[1].length-Math.abs(n.arrayBlockIndices[0])|0,r=new Array(n.arrayArgs.length),o=new Array(n.arrayArgs.length),i=0;i<n.arrayArgs.length;++i)o[i]=t[2*i],r[i]=t[2*i+1];for(var a=[],s=[],l=[],u=[],c=[],i=0;i<n.arrayArgs.length;++i){n.arrayBlockIndices[i]<0?(l.push(0),u.push(e),a.push(e),s.push(e+n.arrayBlockIndices[i])):(l.push(n.arrayBlockIndices[i]),u.push(n.arrayBlockIndices[i]+e),a.push(0),s.push(n.arrayBlockIndices[i]));for(var d=[],p=0;p<r[i].length;p++)l[i]<=r[i][p]&&r[i][p]<u[i]&&d.push(r[i][p]-l[i]);c.push(d)}for(var f=["SS"],h=["'use strict'"],m=[],p=0;p<e;++p)m.push(["s",p,"=SS[",p,"]"].join(""));for(var i=0;i<n.arrayArgs.length;++i){f.push("a"+i),f.push("t"+i),f.push("p"+i);for(var p=0;p<e;++p)m.push(["t",i,"p",p,"=t",i,"[",l[i]+p,"]"].join(""));for(var p=0;p<Math.abs(n.arrayBlockIndices[i]);++p)m.push(["t",i,"b",p,"=t",i,"[",a[i]+p,"]"].join(""))}for(var i=0;i<n.scalarArgs.length;++i)f.push("Y"+i);if(n.shapeArgs.length>0&&m.push("shape=SS.slice(0)"),n.indexArgs.length>0){for(var y=new Array(e),i=0;i<e;++i)y[i]="0";m.push(["index=[",y.join(","),"]"].join(""))}for(var i=0;i<n.offsetArgs.length;++i){for(var g=n.offsetArgs[i],b=[],p=0;p<g.offset.length;++p)g.offset[p]!==0&&(g.offset[p]===1?b.push(["t",g.array,"p",p].join("")):b.push([g.offset[p],"*t",g.array,"p",p].join("")));b.length===0?m.push("q"+i+"=0"):m.push(["q",i,"=",b.join("+")].join(""))}var w=pE([].concat(n.pre.thisVars).concat(n.body.thisVars).concat(n.post.thisVars));m=m.concat(w),m.length>0&&h.push("var "+m.join(","));for(var i=0;i<n.arrayArgs.length;++i)h.push("p"+i+"|=0");n.pre.body.length>3&&h.push(zh(n.pre,n,o));var A=zh(n.body,n,o),S=hE(c);S<e?h.push(fE(S,c[0],n,A)):h.push(US(c[0],n,A)),n.post.body.length>3&&h.push(zh(n.post,n,o)),n.debug&&console.log("-----Generated cwise routine for ",t,`:
9
9
  `+h.join(`
10
10
  `)+`
11
- ----------`);var P=[n.funcName||"unnamed","_cwise_loop_",r[0].join("s"),"m",S,uE(o)].join(""),O=new Function(["function ",P,"(",f.join(","),"){",h.join(`
12
- `),"} return ",P].join(""));return O()}FS.exports=dE});var US=Zt((wde,jS)=>{"use strict";var pE=kS();function fE(n){var t=["'use strict'","var CACHED={}"],e=[],r=n.funcName+"_cwise_thunk";t.push(["return function ",r,"(",n.shimArgs.join(","),"){"].join(""));for(var o=[],i=[],a=[["array",n.arrayArgs[0],".shape.slice(",Math.max(0,n.arrayBlockIndices[0]),n.arrayBlockIndices[0]<0?","+n.arrayBlockIndices[0]+")":")"].join("")],s=[],l=[],u=0;u<n.arrayArgs.length;++u){var c=n.arrayArgs[u];e.push(["t",c,"=array",c,".dtype,","r",c,"=array",c,".order"].join("")),o.push("t"+c),o.push("r"+c),i.push("t"+c),i.push("r"+c+".join()"),a.push("array"+c+".data"),a.push("array"+c+".stride"),a.push("array"+c+".offset|0"),u>0&&(s.push("array"+n.arrayArgs[0]+".shape.length===array"+c+".shape.length+"+(Math.abs(n.arrayBlockIndices[0])-Math.abs(n.arrayBlockIndices[u]))),l.push("array"+n.arrayArgs[0]+".shape[shapeIndex+"+Math.max(0,n.arrayBlockIndices[0])+"]===array"+c+".shape[shapeIndex+"+Math.max(0,n.arrayBlockIndices[u])+"]"))}n.arrayArgs.length>1&&(t.push("if (!("+s.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same dimensionality!')"),t.push("for(var shapeIndex=array"+n.arrayArgs[0]+".shape.length-"+Math.abs(n.arrayBlockIndices[0])+"; shapeIndex-->0;) {"),t.push("if (!("+l.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same shape!')"),t.push("}"));for(var u=0;u<n.scalarArgs.length;++u)a.push("scalar"+n.scalarArgs[u]);e.push(["type=[",i.join(","),"].join()"].join("")),e.push("proc=CACHED[type]"),t.push("var "+e.join(",")),t.push(["if(!proc){","CACHED[type]=proc=compile([",o.join(","),"])}","return proc(",a.join(","),")}"].join("")),n.debug&&console.log(`-----Generated thunk:
11
+ ----------`);var P=[n.funcName||"unnamed","_cwise_loop_",r[0].join("s"),"m",S,mE(o)].join(""),O=new Function(["function ",P,"(",f.join(","),"){",h.join(`
12
+ `),"} return ",P].join(""));return O()}HS.exports=yE});var $S=Zt((Mde,WS)=>{"use strict";var gE=qS();function xE(n){var t=["'use strict'","var CACHED={}"],e=[],r=n.funcName+"_cwise_thunk";t.push(["return function ",r,"(",n.shimArgs.join(","),"){"].join(""));for(var o=[],i=[],a=[["array",n.arrayArgs[0],".shape.slice(",Math.max(0,n.arrayBlockIndices[0]),n.arrayBlockIndices[0]<0?","+n.arrayBlockIndices[0]+")":")"].join("")],s=[],l=[],u=0;u<n.arrayArgs.length;++u){var c=n.arrayArgs[u];e.push(["t",c,"=array",c,".dtype,","r",c,"=array",c,".order"].join("")),o.push("t"+c),o.push("r"+c),i.push("t"+c),i.push("r"+c+".join()"),a.push("array"+c+".data"),a.push("array"+c+".stride"),a.push("array"+c+".offset|0"),u>0&&(s.push("array"+n.arrayArgs[0]+".shape.length===array"+c+".shape.length+"+(Math.abs(n.arrayBlockIndices[0])-Math.abs(n.arrayBlockIndices[u]))),l.push("array"+n.arrayArgs[0]+".shape[shapeIndex+"+Math.max(0,n.arrayBlockIndices[0])+"]===array"+c+".shape[shapeIndex+"+Math.max(0,n.arrayBlockIndices[u])+"]"))}n.arrayArgs.length>1&&(t.push("if (!("+s.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same dimensionality!')"),t.push("for(var shapeIndex=array"+n.arrayArgs[0]+".shape.length-"+Math.abs(n.arrayBlockIndices[0])+"; shapeIndex-->0;) {"),t.push("if (!("+l.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same shape!')"),t.push("}"));for(var u=0;u<n.scalarArgs.length;++u)a.push("scalar"+n.scalarArgs[u]);e.push(["type=[",i.join(","),"].join()"].join("")),e.push("proc=CACHED[type]"),t.push("var "+e.join(",")),t.push(["if(!proc){","CACHED[type]=proc=compile([",o.join(","),"])}","return proc(",a.join(","),")}"].join("")),n.debug&&console.log(`-----Generated thunk:
13
13
  `+t.join(`
14
14
  `)+`
15
15
  ----------`);var d=new Function("compile",t.join(`
16
- `));return d(pE.bind(void 0,n))}jS.exports=fE});var qS=Zt((Ade,HS)=>{"use strict";var hE=US();function mE(){this.argTypes=[],this.shimArgs=[],this.arrayArgs=[],this.arrayBlockIndices=[],this.scalarArgs=[],this.offsetArgs=[],this.offsetArgIndex=[],this.indexArgs=[],this.shapeArgs=[],this.funcName="",this.pre=null,this.body=null,this.post=null,this.debug=!1}function yE(n){var t=new mE;t.pre=n.pre,t.body=n.body,t.post=n.post;var e=n.args.slice(0);t.argTypes=e;for(var r=0;r<e.length;++r){var o=e[r];if(o==="array"||typeof o=="object"&&o.blockIndices){if(t.argTypes[r]="array",t.arrayArgs.push(r),t.arrayBlockIndices.push(o.blockIndices?o.blockIndices:0),t.shimArgs.push("array"+r),r<t.pre.args.length&&t.pre.args[r].count>0)throw new Error("cwise: pre() block may not reference array args");if(r<t.post.args.length&&t.post.args[r].count>0)throw new Error("cwise: post() block may not reference array args")}else if(o==="scalar")t.scalarArgs.push(r),t.shimArgs.push("scalar"+r);else if(o==="index"){if(t.indexArgs.push(r),r<t.pre.args.length&&t.pre.args[r].count>0)throw new Error("cwise: pre() block may not reference array index");if(r<t.body.args.length&&t.body.args[r].lvalue)throw new Error("cwise: body() block may not write to array index");if(r<t.post.args.length&&t.post.args[r].count>0)throw new Error("cwise: post() block may not reference array index")}else if(o==="shape"){if(t.shapeArgs.push(r),r<t.pre.args.length&&t.pre.args[r].lvalue)throw new Error("cwise: pre() block may not write to array shape");if(r<t.body.args.length&&t.body.args[r].lvalue)throw new Error("cwise: body() block may not write to array shape");if(r<t.post.args.length&&t.post.args[r].lvalue)throw new Error("cwise: post() block may not write to array shape")}else if(typeof o=="object"&&o.offset)t.argTypes[r]="offset",t.offsetArgs.push({array:o.array,offset:o.offset}),t.offsetArgIndex.push(r);else throw new Error("cwise: Unknown argument type "+e[r])}if(t.arrayArgs.length<=0)throw new Error("cwise: No array arguments specified");if(t.pre.args.length>e.length)throw new Error("cwise: Too many arguments in pre() block");if(t.body.args.length>e.length)throw new Error("cwise: Too many arguments in body() block");if(t.post.args.length>e.length)throw new Error("cwise: Too many arguments in post() block");return t.debug=!!n.printCode||!!n.debug,t.funcName=n.funcName||"cwise",t.blockSize=n.blockSize||64,hE(t)}HS.exports=yE});var Ds=Zt(Ve=>{"use strict";var xr=qS(),Od={body:"",args:[],thisVars:[],localVars:[]};function zh(n){if(!n)return Od;for(var t=0;t<n.args.length;++t){var e=n.args[t];t===0?n.args[t]={name:e,lvalue:!0,rvalue:!!n.rvalue,count:n.count||1}:n.args[t]={name:e,lvalue:!1,rvalue:!0,count:1}}return n.thisVars||(n.thisVars=[]),n.localVars||(n.localVars=[]),n}function gE(n){return xr({args:n.args,pre:zh(n.pre),body:zh(n.body),post:zh(n.proc),funcName:n.funcName})}function ht(n){for(var t=[],e=0;e<n.args.length;++e)t.push("a"+e);var r=new Function("P",["return function ",n.funcName,"_ndarrayops(",t.join(","),") {P(",t.join(","),");return a0}"].join(""));return r(gE(n))}var WS={add:"+",sub:"-",mul:"*",div:"/",mod:"%",band:"&",bor:"|",bxor:"^",lshift:"<<",rshift:">>",rrshift:">>>"};(function(){for(var n in WS){var t=WS[n];Ve[n]=ht({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+t+"c"},funcName:n}),Ve[n+"eq"]=ht({args:["array","array"],body:{args:["a","b"],body:"a"+t+"=b"},rvalue:!0,funcName:n+"eq"}),Ve[n+"s"]=ht({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+t+"s"},funcName:n+"s"}),Ve[n+"seq"]=ht({args:["array","scalar"],body:{args:["a","s"],body:"a"+t+"=s"},rvalue:!0,funcName:n+"seq"})}})();var $S={not:"!",bnot:"~",neg:"-",recip:"1.0/"};(function(){for(var n in $S){var t=$S[n];Ve[n]=ht({args:["array","array"],body:{args:["a","b"],body:"a="+t+"b"},funcName:n}),Ve[n+"eq"]=ht({args:["array"],body:{args:["a"],body:"a="+t+"a"},rvalue:!0,count:2,funcName:n+"eq"})}})();var YS={and:"&&",or:"||",eq:"===",neq:"!==",lt:"<",gt:">",leq:"<=",geq:">="};(function(){for(var n in YS){var t=YS[n];Ve[n]=ht({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+t+"c"},funcName:n}),Ve[n+"s"]=ht({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+t+"s"},funcName:n+"s"}),Ve[n+"eq"]=ht({args:["array","array"],body:{args:["a","b"],body:"a=a"+t+"b"},rvalue:!0,count:2,funcName:n+"eq"}),Ve[n+"seq"]=ht({args:["array","scalar"],body:{args:["a","s"],body:"a=a"+t+"s"},rvalue:!0,count:2,funcName:n+"seq"})}})();var XS=["abs","acos","asin","atan","ceil","cos","exp","floor","log","round","sin","sqrt","tan"];(function(){for(var n=0;n<XS.length;++n){var t=XS[n];Ve[t]=ht({args:["array","array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b)",thisVars:["this_f"]},funcName:t}),Ve[t+"eq"]=ht({args:["array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a"],body:"a=this_f(a)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:t+"eq"})}})();var QS=["max","min","atan2","pow"];(function(){for(var n=0;n<QS.length;++n){var t=QS[n];Ve[t]=ht({args:["array","array","array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(b,c)",thisVars:["this_f"]},funcName:t}),Ve[t+"s"]=ht({args:["array","array","scalar"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(b,c)",thisVars:["this_f"]},funcName:t+"s"}),Ve[t+"eq"]=ht({args:["array","array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(a,b)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:t+"eq"}),Ve[t+"seq"]=ht({args:["array","scalar"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(a,b)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:t+"seq"})}})();var KS=["atan2","pow"];(function(){for(var n=0;n<KS.length;++n){var t=KS[n];Ve[t+"op"]=ht({args:["array","array","array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(c,b)",thisVars:["this_f"]},funcName:t+"op"}),Ve[t+"ops"]=ht({args:["array","array","scalar"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(c,b)",thisVars:["this_f"]},funcName:t+"ops"}),Ve[t+"opeq"]=ht({args:["array","array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b,a)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:t+"opeq"}),Ve[t+"opseq"]=ht({args:["array","scalar"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b,a)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:t+"opseq"})}})();Ve.any=xr({args:["array"],pre:Od,body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"if(a){return true}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return false"},funcName:"any"});Ve.all=xr({args:["array"],pre:Od,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1}],body:"if(!x){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"all"});Ve.sum=xr({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"this_s+=a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"sum"});Ve.prod=xr({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=1"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"this_s*=a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"prod"});Ve.norm2squared=xr({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:2}],body:"this_s+=a*a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm2squared"});Ve.norm2=xr({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:2}],body:"this_s+=a*a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return Math.sqrt(this_s)"},funcName:"norm2"});Ve.norminf=xr({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:4}],body:"if(-a>this_s){this_s=-a}else if(a>this_s){this_s=a}",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norminf"});Ve.norm1=xr({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:3}],body:"this_s+=a<0?-a:a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm1"});Ve.sup=xr({args:["array"],pre:{body:"this_h=-Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_>this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}});Ve.inf=xr({args:["array"],pre:{body:"this_h=Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_<this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}});Ve.argmin=xr({args:["index","array","shape"],pre:{body:"{this_v=Infinity;this_i=_inline_0_arg2_.slice(0)}",args:[{name:"_inline_0_arg0_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg1_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg2_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_i","this_v"],localVars:[]},body:{body:"{if(_inline_1_arg1_<this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}});Ve.argmax=xr({args:["index","array","shape"],pre:{body:"{this_v=-Infinity;this_i=_inline_0_arg2_.slice(0)}",args:[{name:"_inline_0_arg0_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg1_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg2_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_i","this_v"],localVars:[]},body:{body:"{if(_inline_1_arg1_>this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}});Ve.random=ht({args:["array"],pre:{args:[],body:"this_f=Math.random",thisVars:["this_f"]},body:{args:["a"],body:"a=this_f()",thisVars:["this_f"]},funcName:"random"});Ve.assign=ht({args:["array","array"],body:{args:["a","b"],body:"a=b"},funcName:"assign"});Ve.assigns=ht({args:["array","scalar"],body:{args:["a","b"],body:"a=b"},funcName:"assigns"});Ve.equals=xr({args:["array","array"],pre:Od,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1},{name:"y",lvalue:!1,rvalue:!0,count:1}],body:"if(x!==y){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"equals"})});var A1=Zt((uhe,w1)=>{w1.exports=function(t,e){for(var r=t.split("."),o=e.split("."),i=0;i<3;i++){var a=Number(r[i]),s=Number(o[i]);if(a>s)return 1;if(s>a)return-1;if(!isNaN(a)&&isNaN(s))return 1;if(isNaN(a)&&!isNaN(s))return-1}return 0}});import{FileLoader as tB,Loader as rB}from"three";function Yl(n){for(let t of Object.keys(n))n[t]===void 0&&delete n[t];return n}function rr(n,t){return Object.setPrototypeOf(n,t),n}function Xl(n){return Array.isArray(n)?n:[n]}function Ql(n,t){let e=0;for(;e<n.length&&e<t.length;){if(n[e]<t[e])return-1;if(n[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==n.length?1:0}var K1=typeof global=="object"&&global&&global.Object===Object&&global,Kl=K1;var Z1=typeof self=="object"&&self&&self.Object===Object&&self,J1=Kl||Z1||Function("return this")(),_t=J1;var ew=_t.Symbol,Rt=ew;var tm=Object.prototype,tw=tm.hasOwnProperty,rw=tm.toString,Ls=Rt?Rt.toStringTag:void 0;function ow(n){var t=tw.call(n,Ls),e=n[Ls];try{n[Ls]=void 0;var r=!0}catch{}var o=rw.call(n);return r&&(t?n[Ls]=e:delete n[Ls]),o}var rm=ow;var nw=Object.prototype,iw=nw.toString;function aw(n){return iw.call(n)}var om=aw;var sw="[object Null]",lw="[object Undefined]",nm=Rt?Rt.toStringTag:void 0;function cw(n){return n==null?n===void 0?lw:sw:nm&&nm in Object(n)?rm(n):om(n)}var br=cw;function uw(n){return n!=null&&typeof n=="object"}var qt=uw;var dw="[object Symbol]";function pw(n){return typeof n=="symbol"||qt(n)&&br(n)==dw}var Bi=pw;function fw(n,t){for(var e=-1,r=n==null?0:n.length,o=Array(r);++e<r;)o[e]=t(n[e],e,n);return o}var Zl=fw;var hw=Array.isArray,yt=hw;var mw=1/0,im=Rt?Rt.prototype:void 0,am=im?im.toString:void 0;function sm(n){if(typeof n=="string")return n;if(yt(n))return Zl(n,sm)+"";if(Bi(n))return am?am.call(n):"";var t=n+"";return t=="0"&&1/n==-mw?"-0":t}var lm=sm;function yw(n){var t=typeof n;return n!=null&&(t=="object"||t=="function")}var vr=yw;function gw(n){return n}var cm=gw;var xw="[object AsyncFunction]",bw="[object Function]",vw="[object GeneratorFunction]",Sw="[object Proxy]";function ww(n){if(!vr(n))return!1;var t=br(n);return t==bw||t==vw||t==xw||t==Sw}var Jl=ww;var Aw=_t["__core-js_shared__"],ec=Aw;var um=function(){var n=/[^.]+$/.exec(ec&&ec.keys&&ec.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}();function _w(n){return!!um&&um in n}var dm=_w;var Pw=Function.prototype,Ow=Pw.toString;function Cw(n){if(n!=null){try{return Ow.call(n)}catch{}try{return n+""}catch{}}return""}var Eo=Cw;var Tw=/[\\^$.*+?()[\]{}|]/g,Mw=/^\[object .+?Constructor\]$/,Iw=Function.prototype,Nw=Object.prototype,Dw=Iw.toString,Ew=Nw.hasOwnProperty,Bw=RegExp("^"+Dw.call(Ew).replace(Tw,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Lw(n){if(!vr(n)||dm(n))return!1;var t=Jl(n)?Bw:Mw;return t.test(Eo(n))}var pm=Lw;function Rw(n,t){return n?.[t]}var fm=Rw;function Vw(n,t){var e=fm(n,t);return pm(e)?e:void 0}var cr=Vw;var zw=cr(_t,"WeakMap"),tc=zw;var hm=Object.create,Gw=function(){function n(){}return function(t){if(!vr(t))return{};if(hm)return hm(t);n.prototype=t;var e=new n;return n.prototype=void 0,e}}(),mm=Gw;function Fw(n,t,e){switch(e.length){case 0:return n.call(t);case 1:return n.call(t,e[0]);case 2:return n.call(t,e[0],e[1]);case 3:return n.call(t,e[0],e[1],e[2])}return n.apply(t,e)}var ym=Fw;function kw(n,t){var e=-1,r=n.length;for(t||(t=Array(r));++e<r;)t[e]=n[e];return t}var gm=kw;var jw=800,Uw=16,Hw=Date.now;function qw(n){var t=0,e=0;return function(){var r=Hw(),o=Uw-(r-e);if(e=r,o>0){if(++t>=jw)return arguments[0]}else t=0;return n.apply(void 0,arguments)}}var xm=qw;function Ww(n){return function(){return n}}var bm=Ww;var $w=function(){try{var n=cr(Object,"defineProperty");return n({},"",{}),n}catch{}}(),Li=$w;var Yw=Li?function(n,t){return Li(n,"toString",{configurable:!0,enumerable:!1,value:bm(t),writable:!0})}:cm,vm=Yw;var Xw=xm(vm),Sm=Xw;function Qw(n,t){for(var e=-1,r=n==null?0:n.length;++e<r&&t(n[e],e,n)!==!1;);return n}var wm=Qw;var Kw=9007199254740991,Zw=/^(?:0|[1-9]\d*)$/;function Jw(n,t){var e=typeof n;return t=t??Kw,!!t&&(e=="number"||e!="symbol"&&Zw.test(n))&&n>-1&&n%1==0&&n<t}var Ri=Jw;function e2(n,t,e){t=="__proto__"&&Li?Li(n,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):n[t]=e}var rc=e2;function t2(n,t){return n===t||n!==n&&t!==t}var Vi=t2;var r2=Object.prototype,o2=r2.hasOwnProperty;function n2(n,t,e){var r=n[t];(!(o2.call(n,t)&&Vi(r,e))||e===void 0&&!(t in n))&&rc(n,t,e)}var zi=n2;function i2(n,t,e,r){var o=!e;e||(e={});for(var i=-1,a=t.length;++i<a;){var s=t[i],l=r?r(e[s],n[s],s,e,n):void 0;l===void 0&&(l=n[s]),o?rc(e,s,l):zi(e,s,l)}return e}var io=i2;var Am=Math.max;function a2(n,t,e){return t=Am(t===void 0?n.length-1:t,0),function(){for(var r=arguments,o=-1,i=Am(r.length-t,0),a=Array(i);++o<i;)a[o]=r[t+o];o=-1;for(var s=Array(t+1);++o<t;)s[o]=r[o];return s[t]=e(a),ym(n,this,s)}}var _m=a2;var s2=9007199254740991;function l2(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=s2}var Gi=l2;function c2(n){return n!=null&&Gi(n.length)&&!Jl(n)}var oc=c2;var u2=Object.prototype;function d2(n){var t=n&&n.constructor,e=typeof t=="function"&&t.prototype||u2;return n===e}var Fi=d2;function p2(n,t){for(var e=-1,r=Array(n);++e<n;)r[e]=t(e);return r}var Pm=p2;var f2="[object Arguments]";function h2(n){return qt(n)&&br(n)==f2}var jd=h2;var Om=Object.prototype,m2=Om.hasOwnProperty,y2=Om.propertyIsEnumerable,g2=jd(function(){return arguments}())?jd:function(n){return qt(n)&&m2.call(n,"callee")&&!y2.call(n,"callee")},ki=g2;function x2(){return!1}var Cm=x2;var Im=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Tm=Im&&typeof module=="object"&&module&&!module.nodeType&&module,b2=Tm&&Tm.exports===Im,Mm=b2?_t.Buffer:void 0,v2=Mm?Mm.isBuffer:void 0,S2=v2||Cm,Qn=S2;var w2="[object Arguments]",A2="[object Array]",_2="[object Boolean]",P2="[object Date]",O2="[object Error]",C2="[object Function]",T2="[object Map]",M2="[object Number]",I2="[object Object]",N2="[object RegExp]",D2="[object Set]",E2="[object String]",B2="[object WeakMap]",L2="[object ArrayBuffer]",R2="[object DataView]",V2="[object Float32Array]",z2="[object Float64Array]",G2="[object Int8Array]",F2="[object Int16Array]",k2="[object Int32Array]",j2="[object Uint8Array]",U2="[object Uint8ClampedArray]",H2="[object Uint16Array]",q2="[object Uint32Array]",it={};it[V2]=it[z2]=it[G2]=it[F2]=it[k2]=it[j2]=it[U2]=it[H2]=it[q2]=!0;it[w2]=it[A2]=it[L2]=it[_2]=it[R2]=it[P2]=it[O2]=it[C2]=it[T2]=it[M2]=it[I2]=it[N2]=it[D2]=it[E2]=it[B2]=!1;function W2(n){return qt(n)&&Gi(n.length)&&!!it[br(n)]}var Nm=W2;function $2(n){return function(t){return n(t)}}var ji=$2;var Dm=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Rs=Dm&&typeof module=="object"&&module&&!module.nodeType&&module,Y2=Rs&&Rs.exports===Dm,Ud=Y2&&Kl.process,X2=function(){try{var n=Rs&&Rs.require&&Rs.require("util").types;return n||Ud&&Ud.binding&&Ud.binding("util")}catch{}}(),Bo=X2;var Em=Bo&&Bo.isTypedArray,Q2=Em?ji(Em):Nm,nc=Q2;var K2=Object.prototype,Z2=K2.hasOwnProperty;function J2(n,t){var e=yt(n),r=!e&&ki(n),o=!e&&!r&&Qn(n),i=!e&&!r&&!o&&nc(n),a=e||r||o||i,s=a?Pm(n.length,String):[],l=s.length;for(var u in n)(t||Z2.call(n,u))&&!(a&&(u=="length"||o&&(u=="offset"||u=="parent")||i&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||Ri(u,l)))&&s.push(u);return s}var ic=J2;function eA(n,t){return function(e){return n(t(e))}}var ac=eA;var tA=ac(Object.keys,Object),Bm=tA;var rA=Object.prototype,oA=rA.hasOwnProperty;function nA(n){if(!Fi(n))return Bm(n);var t=[];for(var e in Object(n))oA.call(n,e)&&e!="constructor"&&t.push(e);return t}var Lm=nA;function iA(n){return oc(n)?ic(n):Lm(n)}var Ui=iA;function aA(n){var t=[];if(n!=null)for(var e in Object(n))t.push(e);return t}var Rm=aA;var sA=Object.prototype,lA=sA.hasOwnProperty;function cA(n){if(!vr(n))return Rm(n);var t=Fi(n),e=[];for(var r in n)r=="constructor"&&(t||!lA.call(n,r))||e.push(r);return e}var Vm=cA;function uA(n){return oc(n)?ic(n,!0):Vm(n)}var Hi=uA;var dA=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,pA=/^\w*$/;function fA(n,t){if(yt(n))return!1;var e=typeof n;return e=="number"||e=="symbol"||e=="boolean"||n==null||Bi(n)?!0:pA.test(n)||!dA.test(n)||t!=null&&n in Object(t)}var zm=fA;var hA=cr(Object,"create"),Lo=hA;function mA(){this.__data__=Lo?Lo(null):{},this.size=0}var Gm=mA;function yA(n){var t=this.has(n)&&delete this.__data__[n];return this.size-=t?1:0,t}var Fm=yA;var gA="__lodash_hash_undefined__",xA=Object.prototype,bA=xA.hasOwnProperty;function vA(n){var t=this.__data__;if(Lo){var e=t[n];return e===gA?void 0:e}return bA.call(t,n)?t[n]:void 0}var km=vA;var SA=Object.prototype,wA=SA.hasOwnProperty;function AA(n){var t=this.__data__;return Lo?t[n]!==void 0:wA.call(t,n)}var jm=AA;var _A="__lodash_hash_undefined__";function PA(n,t){var e=this.__data__;return this.size+=this.has(n)?0:1,e[n]=Lo&&t===void 0?_A:t,this}var Um=PA;function qi(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}qi.prototype.clear=Gm;qi.prototype.delete=Fm;qi.prototype.get=km;qi.prototype.has=jm;qi.prototype.set=Um;var Hd=qi;function OA(){this.__data__=[],this.size=0}var Hm=OA;function CA(n,t){for(var e=n.length;e--;)if(Vi(n[e][0],t))return e;return-1}var ln=CA;var TA=Array.prototype,MA=TA.splice;function IA(n){var t=this.__data__,e=ln(t,n);if(e<0)return!1;var r=t.length-1;return e==r?t.pop():MA.call(t,e,1),--this.size,!0}var qm=IA;function NA(n){var t=this.__data__,e=ln(t,n);return e<0?void 0:t[e][1]}var Wm=NA;function DA(n){return ln(this.__data__,n)>-1}var $m=DA;function EA(n,t){var e=this.__data__,r=ln(e,n);return r<0?(++this.size,e.push([n,t])):e[r][1]=t,this}var Ym=EA;function Wi(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}Wi.prototype.clear=Hm;Wi.prototype.delete=qm;Wi.prototype.get=Wm;Wi.prototype.has=$m;Wi.prototype.set=Ym;var cn=Wi;var BA=cr(_t,"Map"),un=BA;function LA(){this.size=0,this.__data__={hash:new Hd,map:new(un||cn),string:new Hd}}var Xm=LA;function RA(n){var t=typeof n;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?n!=="__proto__":n===null}var Qm=RA;function VA(n,t){var e=n.__data__;return Qm(t)?e[typeof t=="string"?"string":"hash"]:e.map}var dn=VA;function zA(n){var t=dn(this,n).delete(n);return this.size-=t?1:0,t}var Km=zA;function GA(n){return dn(this,n).get(n)}var Zm=GA;function FA(n){return dn(this,n).has(n)}var Jm=FA;function kA(n,t){var e=dn(this,n),r=e.size;return e.set(n,t),this.size+=e.size==r?0:1,this}var ey=kA;function $i(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}$i.prototype.clear=Xm;$i.prototype.delete=Km;$i.prototype.get=Zm;$i.prototype.has=Jm;$i.prototype.set=ey;var Kn=$i;var jA="Expected a function";function qd(n,t){if(typeof n!="function"||t!=null&&typeof t!="function")throw new TypeError(jA);var e=function(){var r=arguments,o=t?t.apply(this,r):r[0],i=e.cache;if(i.has(o))return i.get(o);var a=n.apply(this,r);return e.cache=i.set(o,a)||i,a};return e.cache=new(qd.Cache||Kn),e}qd.Cache=Kn;var ty=qd;var UA=500;function HA(n){var t=ty(n,function(r){return e.size===UA&&e.clear(),r}),e=t.cache;return t}var ry=HA;var qA=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,WA=/\\(\\)?/g,$A=ry(function(n){var t=[];return n.charCodeAt(0)===46&&t.push(""),n.replace(qA,function(e,r,o,i){t.push(o?i.replace(WA,"$1"):r||e)}),t}),oy=$A;function YA(n){return n==null?"":lm(n)}var ny=YA;function XA(n,t){return yt(n)?n:zm(n,t)?[n]:oy(ny(n))}var Tr=XA;var QA=1/0;function KA(n){if(typeof n=="string"||Bi(n))return n;var t=n+"";return t=="0"&&1/n==-QA?"-0":t}var pn=KA;function ZA(n,t){t=Tr(t,n);for(var e=0,r=t.length;n!=null&&e<r;)n=n[pn(t[e++])];return e&&e==r?n:void 0}var sc=ZA;function JA(n,t){for(var e=-1,r=t.length,o=n.length;++e<r;)n[o+e]=t[e];return n}var Yi=JA;var iy=Rt?Rt.isConcatSpreadable:void 0;function e_(n){return yt(n)||ki(n)||!!(iy&&n&&n[iy])}var ay=e_;function sy(n,t,e,r,o){var i=-1,a=n.length;for(e||(e=ay),o||(o=[]);++i<a;){var s=n[i];t>0&&e(s)?t>1?sy(s,t-1,e,r,o):Yi(o,s):r||(o[o.length]=s)}return o}var ly=sy;function t_(n){var t=n==null?0:n.length;return t?ly(n,1):[]}var cy=t_;function r_(n){return Sm(_m(n,void 0,cy),n+"")}var lc=r_;var o_=ac(Object.getPrototypeOf,Object),Xi=o_;var n_="[object Object]",i_=Function.prototype,a_=Object.prototype,uy=i_.toString,s_=a_.hasOwnProperty,l_=uy.call(Object);function c_(n){if(!qt(n)||br(n)!=n_)return!1;var t=Xi(n);if(t===null)return!0;var e=s_.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&&uy.call(e)==l_}var dy=c_;function u_(n,t,e){var r=-1,o=n.length;t<0&&(t=-t>o?0:o+t),e=e>o?o:e,e<0&&(e+=o),o=t>e?0:e-t>>>0,t>>>=0;for(var i=Array(o);++r<o;)i[r]=n[r+t];return i}var py=u_;function d_(){this.__data__=new cn,this.size=0}var fy=d_;function p_(n){var t=this.__data__,e=t.delete(n);return this.size=t.size,e}var hy=p_;function f_(n){return this.__data__.get(n)}var my=f_;function h_(n){return this.__data__.has(n)}var yy=h_;var m_=200;function y_(n,t){var e=this.__data__;if(e instanceof cn){var r=e.__data__;if(!un||r.length<m_-1)return r.push([n,t]),this.size=++e.size,this;e=this.__data__=new Kn(r)}return e.set(n,t),this.size=e.size,this}var gy=y_;function Qi(n){var t=this.__data__=new cn(n);this.size=t.size}Qi.prototype.clear=fy;Qi.prototype.delete=hy;Qi.prototype.get=my;Qi.prototype.has=yy;Qi.prototype.set=gy;var Ki=Qi;function g_(n,t){return n&&io(t,Ui(t),n)}var xy=g_;function x_(n,t){return n&&io(t,Hi(t),n)}var by=x_;var Ay=typeof exports=="object"&&exports&&!exports.nodeType&&exports,vy=Ay&&typeof module=="object"&&module&&!module.nodeType&&module,b_=vy&&vy.exports===Ay,Sy=b_?_t.Buffer:void 0,wy=Sy?Sy.allocUnsafe:void 0;function v_(n,t){if(t)return n.slice();var e=n.length,r=wy?wy(e):new n.constructor(e);return n.copy(r),r}var _y=v_;function S_(n,t){for(var e=-1,r=n==null?0:n.length,o=0,i=[];++e<r;){var a=n[e];t(a,e,n)&&(i[o++]=a)}return i}var Py=S_;function w_(){return[]}var cc=w_;var A_=Object.prototype,__=A_.propertyIsEnumerable,Oy=Object.getOwnPropertySymbols,P_=Oy?function(n){return n==null?[]:(n=Object(n),Py(Oy(n),function(t){return __.call(n,t)}))}:cc,Zi=P_;function O_(n,t){return io(n,Zi(n),t)}var Cy=O_;var C_=Object.getOwnPropertySymbols,T_=C_?function(n){for(var t=[];n;)Yi(t,Zi(n)),n=Xi(n);return t}:cc,uc=T_;function M_(n,t){return io(n,uc(n),t)}var Ty=M_;function I_(n,t,e){var r=t(n);return yt(n)?r:Yi(r,e(n))}var dc=I_;function N_(n){return dc(n,Ui,Zi)}var Vs=N_;function D_(n){return dc(n,Hi,uc)}var pc=D_;var E_=cr(_t,"DataView"),fc=E_;var B_=cr(_t,"Promise"),hc=B_;var L_=cr(_t,"Set"),mc=L_;var My="[object Map]",R_="[object Object]",Iy="[object Promise]",Ny="[object Set]",Dy="[object WeakMap]",Ey="[object DataView]",V_=Eo(fc),z_=Eo(un),G_=Eo(hc),F_=Eo(mc),k_=Eo(tc),Zn=br;(fc&&Zn(new fc(new ArrayBuffer(1)))!=Ey||un&&Zn(new un)!=My||hc&&Zn(hc.resolve())!=Iy||mc&&Zn(new mc)!=Ny||tc&&Zn(new tc)!=Dy)&&(Zn=function(n){var t=br(n),e=t==R_?n.constructor:void 0,r=e?Eo(e):"";if(r)switch(r){case V_:return Ey;case z_:return My;case G_:return Iy;case F_:return Ny;case k_:return Dy}return t});var Ro=Zn;var j_=Object.prototype,U_=j_.hasOwnProperty;function H_(n){var t=n.length,e=new n.constructor(t);return t&&typeof n[0]=="string"&&U_.call(n,"index")&&(e.index=n.index,e.input=n.input),e}var By=H_;var q_=_t.Uint8Array,Ji=q_;function W_(n){var t=new n.constructor(n.byteLength);return new Ji(t).set(new Ji(n)),t}var ea=W_;function $_(n,t){var e=t?ea(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.byteLength)}var Ly=$_;var Y_=/\w*$/;function X_(n){var t=new n.constructor(n.source,Y_.exec(n));return t.lastIndex=n.lastIndex,t}var Ry=X_;var Vy=Rt?Rt.prototype:void 0,zy=Vy?Vy.valueOf:void 0;function Q_(n){return zy?Object(zy.call(n)):{}}var Gy=Q_;function K_(n,t){var e=t?ea(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.length)}var Fy=K_;var Z_="[object Boolean]",J_="[object Date]",eP="[object Map]",tP="[object Number]",rP="[object RegExp]",oP="[object Set]",nP="[object String]",iP="[object Symbol]",aP="[object ArrayBuffer]",sP="[object DataView]",lP="[object Float32Array]",cP="[object Float64Array]",uP="[object Int8Array]",dP="[object Int16Array]",pP="[object Int32Array]",fP="[object Uint8Array]",hP="[object Uint8ClampedArray]",mP="[object Uint16Array]",yP="[object Uint32Array]";function gP(n,t,e){var r=n.constructor;switch(t){case aP:return ea(n);case Z_:case J_:return new r(+n);case sP:return Ly(n,e);case lP:case cP:case uP:case dP:case pP:case fP:case hP:case mP:case yP:return Fy(n,e);case eP:return new r;case tP:case nP:return new r(n);case rP:return Ry(n);case oP:return new r;case iP:return Gy(n)}}var ky=gP;function xP(n){return typeof n.constructor=="function"&&!Fi(n)?mm(Xi(n)):{}}var jy=xP;var bP="[object Map]";function vP(n){return qt(n)&&Ro(n)==bP}var Uy=vP;var Hy=Bo&&Bo.isMap,SP=Hy?ji(Hy):Uy,qy=SP;var wP="[object Set]";function AP(n){return qt(n)&&Ro(n)==wP}var Wy=AP;var $y=Bo&&Bo.isSet,_P=$y?ji($y):Wy,Yy=_P;var PP=1,OP=2,CP=4,Xy="[object Arguments]",TP="[object Array]",MP="[object Boolean]",IP="[object Date]",NP="[object Error]",Qy="[object Function]",DP="[object GeneratorFunction]",EP="[object Map]",BP="[object Number]",Ky="[object Object]",LP="[object RegExp]",RP="[object Set]",VP="[object String]",zP="[object Symbol]",GP="[object WeakMap]",FP="[object ArrayBuffer]",kP="[object DataView]",jP="[object Float32Array]",UP="[object Float64Array]",HP="[object Int8Array]",qP="[object Int16Array]",WP="[object Int32Array]",$P="[object Uint8Array]",YP="[object Uint8ClampedArray]",XP="[object Uint16Array]",QP="[object Uint32Array]",ot={};ot[Xy]=ot[TP]=ot[FP]=ot[kP]=ot[MP]=ot[IP]=ot[jP]=ot[UP]=ot[HP]=ot[qP]=ot[WP]=ot[EP]=ot[BP]=ot[Ky]=ot[LP]=ot[RP]=ot[VP]=ot[zP]=ot[$P]=ot[YP]=ot[XP]=ot[QP]=!0;ot[NP]=ot[Qy]=ot[GP]=!1;function yc(n,t,e,r,o,i){var a,s=t&PP,l=t&OP,u=t&CP;if(e&&(a=o?e(n,r,o,i):e(n)),a!==void 0)return a;if(!vr(n))return n;var c=yt(n);if(c){if(a=By(n),!s)return gm(n,a)}else{var d=Ro(n),p=d==Qy||d==DP;if(Qn(n))return _y(n,s);if(d==Ky||d==Xy||p&&!o){if(a=l||p?{}:jy(n),!s)return l?Ty(n,by(a,n)):Cy(n,xy(a,n))}else{if(!ot[d])return o?n:{};a=ky(n,d,s)}}i||(i=new Ki);var f=i.get(n);if(f)return f;i.set(n,a),Yy(n)?n.forEach(function(y){a.add(yc(y,t,e,y,n,i))}):qy(n)&&n.forEach(function(y,g){a.set(g,yc(y,t,e,g,n,i))});var h=u?l?pc:Vs:l?Hi:Ui,m=c?void 0:h(n);return wm(m||n,function(y,g){m&&(g=y,y=n[g]),zi(a,g,yc(y,t,e,g,n,i))}),a}var gc=yc;var KP=1,ZP=4;function JP(n){return gc(n,KP|ZP)}var Vo=JP;var eO="__lodash_hash_undefined__";function tO(n){return this.__data__.set(n,eO),this}var Zy=tO;function rO(n){return this.__data__.has(n)}var Jy=rO;function xc(n){var t=-1,e=n==null?0:n.length;for(this.__data__=new Kn;++t<e;)this.add(n[t])}xc.prototype.add=xc.prototype.push=Zy;xc.prototype.has=Jy;var eg=xc;function oO(n,t){for(var e=-1,r=n==null?0:n.length;++e<r;)if(t(n[e],e,n))return!0;return!1}var tg=oO;function nO(n,t){return n.has(t)}var rg=nO;var iO=1,aO=2;function sO(n,t,e,r,o,i){var a=e&iO,s=n.length,l=t.length;if(s!=l&&!(a&&l>s))return!1;var u=i.get(n),c=i.get(t);if(u&&c)return u==t&&c==n;var d=-1,p=!0,f=e&aO?new eg:void 0;for(i.set(n,t),i.set(t,n);++d<s;){var h=n[d],m=t[d];if(r)var y=a?r(m,h,d,t,n,i):r(h,m,d,n,t,i);if(y!==void 0){if(y)continue;p=!1;break}if(f){if(!tg(t,function(g,b){if(!rg(f,b)&&(h===g||o(h,g,e,r,i)))return f.push(b)})){p=!1;break}}else if(!(h===m||o(h,m,e,r,i))){p=!1;break}}return i.delete(n),i.delete(t),p}var bc=sO;function lO(n){var t=-1,e=Array(n.size);return n.forEach(function(r,o){e[++t]=[o,r]}),e}var og=lO;function cO(n){var t=-1,e=Array(n.size);return n.forEach(function(r){e[++t]=r}),e}var ng=cO;var uO=1,dO=2,pO="[object Boolean]",fO="[object Date]",hO="[object Error]",mO="[object Map]",yO="[object Number]",gO="[object RegExp]",xO="[object Set]",bO="[object String]",vO="[object Symbol]",SO="[object ArrayBuffer]",wO="[object DataView]",ig=Rt?Rt.prototype:void 0,Wd=ig?ig.valueOf:void 0;function AO(n,t,e,r,o,i,a){switch(e){case wO:if(n.byteLength!=t.byteLength||n.byteOffset!=t.byteOffset)return!1;n=n.buffer,t=t.buffer;case SO:return!(n.byteLength!=t.byteLength||!i(new Ji(n),new Ji(t)));case pO:case fO:case yO:return Vi(+n,+t);case hO:return n.name==t.name&&n.message==t.message;case gO:case bO:return n==t+"";case mO:var s=og;case xO:var l=r&uO;if(s||(s=ng),n.size!=t.size&&!l)return!1;var u=a.get(n);if(u)return u==t;r|=dO,a.set(n,t);var c=bc(s(n),s(t),r,o,i,a);return a.delete(n),c;case vO:if(Wd)return Wd.call(n)==Wd.call(t)}return!1}var ag=AO;var _O=1,PO=Object.prototype,OO=PO.hasOwnProperty;function CO(n,t,e,r,o,i){var a=e&_O,s=Vs(n),l=s.length,u=Vs(t),c=u.length;if(l!=c&&!a)return!1;for(var d=l;d--;){var p=s[d];if(!(a?p in t:OO.call(t,p)))return!1}var f=i.get(n),h=i.get(t);if(f&&h)return f==t&&h==n;var m=!0;i.set(n,t),i.set(t,n);for(var y=a;++d<l;){p=s[d];var g=n[p],b=t[p];if(r)var w=a?r(b,g,p,t,n,i):r(g,b,p,n,t,i);if(!(w===void 0?g===b||o(g,b,e,r,i):w)){m=!1;break}y||(y=p=="constructor")}if(m&&!y){var _=n.constructor,S=t.constructor;_!=S&&"constructor"in n&&"constructor"in t&&!(typeof _=="function"&&_ instanceof _&&typeof S=="function"&&S instanceof S)&&(m=!1)}return i.delete(n),i.delete(t),m}var sg=CO;var TO=1,lg="[object Arguments]",cg="[object Array]",vc="[object Object]",MO=Object.prototype,ug=MO.hasOwnProperty;function IO(n,t,e,r,o,i){var a=yt(n),s=yt(t),l=a?cg:Ro(n),u=s?cg:Ro(t);l=l==lg?vc:l,u=u==lg?vc:u;var c=l==vc,d=u==vc,p=l==u;if(p&&Qn(n)){if(!Qn(t))return!1;a=!0,c=!1}if(p&&!c)return i||(i=new Ki),a||nc(n)?bc(n,t,e,r,o,i):ag(n,t,l,e,r,o,i);if(!(e&TO)){var f=c&&ug.call(n,"__wrapped__"),h=d&&ug.call(t,"__wrapped__");if(f||h){var m=f?n.value():n,y=h?t.value():t;return i||(i=new Ki),o(m,y,e,r,i)}}return p?(i||(i=new Ki),sg(n,t,e,r,o,i)):!1}var dg=IO;function pg(n,t,e,r,o){return n===t?!0:n==null||t==null||!qt(n)&&!qt(t)?n!==n&&t!==t:dg(n,t,e,r,pg,o)}var fg=pg;function NO(n,t){return n!=null&&t in Object(n)}var hg=NO;function DO(n,t,e){t=Tr(t,n);for(var r=-1,o=t.length,i=!1;++r<o;){var a=pn(t[r]);if(!(i=n!=null&&e(n,a)))break;n=n[a]}return i||++r!=o?i:(o=n==null?0:n.length,!!o&&Gi(o)&&Ri(a,o)&&(yt(n)||ki(n)))}var mg=DO;function EO(n,t){return n!=null&&mg(n,t,hg)}var yg=EO;function BO(n){var t=n==null?0:n.length;return t?n[t-1]:void 0}var gg=BO;function LO(n,t){return t.length<2?n:sc(n,py(t,0,-1))}var xg=LO;function RO(n,t){return fg(n,t)}var $d=RO;function VO(n,t){return t=Tr(t,n),n=xg(n,t),n==null||delete n[pn(gg(t))]}var bg=VO;function zO(n){return dy(n)?void 0:n}var vg=zO;var GO=1,FO=2,kO=4,jO=lc(function(n,t){var e={};if(n==null)return e;var r=!1;t=Zl(t,function(i){return i=Tr(i,n),r||(r=i.length>1),i}),io(n,pc(n),e),r&&(e=gc(e,GO|FO|kO,vg));for(var o=t.length;o--;)bg(e,t[o]);return e}),ta=jO;function UO(n,t,e,r){if(!vr(n))return n;t=Tr(t,n);for(var o=-1,i=t.length,a=i-1,s=n;s!=null&&++o<i;){var l=pn(t[o]),u=e;if(l==="__proto__"||l==="constructor"||l==="prototype")return n;if(o!=a){var c=s[l];u=r?r(c,l,s):void 0,u===void 0&&(u=vr(c)?c:Ri(t[o+1])?[]:{})}zi(s,l,u),s=s[l]}return n}var Sg=UO;function HO(n,t,e){for(var r=-1,o=t.length,i={};++r<o;){var a=t[r],s=sc(n,a);e(s,a)&&Sg(i,Tr(a,n),s)}return i}var wg=HO;function qO(n,t){return wg(n,t,function(e,r){return yg(n,r)})}var Ag=qO;var WO=lc(function(n,t){return n==null?{}:Ag(n,t)}),jr=WO;var xe=class{modifyById(t,e){let r=this;if(r[t]===void 0)throw new Error("not expected");{let i={...r,[t]:e};return Object.setPrototypeOf(i,xe.prototype),i}}add(t,e){return this.runOp({type:1,id:t,data:e})?.data??this}runOp(t){let e=this;if(t.type===1){let r=e[t.id],o;r===void 0?o={type:2,id:t.id}:o={type:1,id:t.id,data:r};let{id:i,data:a}=t,s={...e,[i]:a};return Object.setPrototypeOf(s,xe.prototype),{data:s,actual:t,reverse:o}}else if(t.type===2){let{id:r}=t,o=e[r];if(o===void 0)return null;{let i={...e};return Object.setPrototypeOf(i,xe.prototype),delete i[r],{data:i,actual:t,reverse:{type:1,id:r,data:o}}}}return null}};function zs(n){if(n.deepFreeze!==void 0){n.deepFreeze(n);return}let t=Object.getOwnPropertyNames(n);for(let e of t){let r=n[e];r&&typeof r=="object"&&zs(r)}return Object.freeze(n)}function _g(n,t){let e=0;for(;e<n.length&&e<t.length;){if(n[e]<t[e])return-1;if(n[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==n.length?1:0}var ra=class extends Error{};function Sc(n){let t={...n};return Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t}function ao(n,t,e){if(n===void 0?t===void 0?(n=0,t=10):n=t-10:t===void 0&&(t=n+10),n>t){let i=n;n=t,t=i}let r=[],o=1/(e+1);for(let i=0;i<e;i++){let a=n+(t-n)*(i+.75+Math.random()*.5)*o;r.push(a)}return r}function oa(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 Pg(){return typeof process<"u"}function Og(n,t){for(let e of n)t(e.id,e.data)!==!0&&Og(e.children,t)}function Cg(n,t){if(t(n.id,n.data)!==!0)for(let e of n.children)Cg(e,t)}var Je=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,Je.prototype)}deepFreeze(){let e=0;for(;e<this.length;)zs(this[e]),e++}fillCaches0(e,r){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,r);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,r){if(!this.has(e))return!0;for(;e;){let o=this.parent(e);if(o===r)return!0;e=o}return!1}rootAcestor(e){for(;e;){let r=this.parent(e);if(r)e=r;else return e}return e}isDescendantOf(e,r){for(;e;){let o=this.parent(e);if(o===r)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,r){if(e===null)this.traverse(r);else{let o=this.get(e);o&&Cg(o,r)}}traverse(e){Og(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,r){if(this.get(e)===void 0)throw new Error("not expected");{let i=this.parent(e),a=this.childrenArray(i),s=a.findIndex(c=>c.id===e);if(s<0)throw new Error("not expected");let l=a[s];return a=[...a],a[s]={...l,data:r},this.modifyArrayBy(i,a)}}modifyArrayBy(e,r){let o=e,i=r;for(;o!==null;){let s=i,l=o;if(o=this.parent(o),o===void 0)throw new Error;i=this.childrenArray(o);let u=i.findIndex(c=>c.id===l);if(u<0)throw new Error;i=[...i],i[u]={...i[u],children:s}}Object.setPrototypeOf(i,Je.prototype);let a=i;return a.fillCaches(),a}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:r}){if(this.get(e)!==void 0)return!0;for(let o of r)if(this.checkDuplicatedIdRec(o))return!0;return!1}addOp(e){let{parent:r,fi:o,id:i,data:a,children:s}=e;if(r!==null&&this.get(r)===void 0)return null;if(this.checkDuplicatedIdRec(e))return null;{let l=r,u=this.childrenArray(l),c={fi:o,id:i,data:a,children:s};return u=[...u,c],u.sort((p,f)=>p.fi-f.fi),e.localIndex=u.indexOf(c),{data:this.modifyArrayBy(l,u),actual:e,reverse:{type:8,id:i}}}}deleteOp(e){let{id:r}=e;if(this.get(r)===null)return null;{let o=this.parent(r);if(o===void 0)return null;let i=this.childrenArray(o),a=i.findIndex(u=>u.id===r);e.localIndex=a,i=[...i];let s=i.splice(a,1)[0];return{data:this.modifyArrayBy(o,i),actual:e,reverse:{type:7,...s,parent:o}}}}moveOp(e){let{parent:r,fi:o,id:i}=e;if(r!==null&&this.get(r)===void 0)return this.deleteOp({type:8,id:i});if(r!==null){let f=r;for(;f!==null;){if(f===void 0)throw new Error;if(f===i)throw new ra("cyclic tree");f=this.parent(f)}}let a=this.parent(i);if(a===void 0)return null;let s=a,l=this.childrenArray(a),u=l.findIndex(f=>f.id===i);l=[...l];let c=l.splice(u,1)[0],d=this.modifyArrayBy(a,l);a=r,l=d.childrenArray(a);let p=c.fi;return c={...c,fi:o},l=[...l,c],l.sort((f,h)=>f.fi-h.fi),e.localIndex=l.indexOf(c),d=d.modifyArrayBy(a,l),{data:d,actual:e,reverse:{type:9,parent:s,fi:p,id:i}}}previous(e,r){if(r===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===r)return o;o=i.id}return null}traverseSortNext(e){let r=this.parent(e);if(r!==void 0){let o=this.childrenArray(r),i=o.findIndex(a=>a.id===e)+1;if(i<o.length)return o[i].id;if(r)return this.traverseSortNext(r)}}sortNext(e){let r=this.childrenArray(e);return r.length>0?r[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let r=this.childrenArray(e);return r.length>0?this.traverseSortPrevious(r[r.length-1].id):e}sortPrevious(e){let r=this.parent(e);if(r!==void 0){let o=this.childrenArray(r),i=o.findIndex(a=>a.id===e)-1;return i>=0?this.traverseSortPrevious(o[i].id):r}}getAllSorted(e){let r=[];for(let o of e){let i=this.getWithSortKey(o.id);i!==void 0&&r.push({...o,...i})}r.sort((o,i)=>_g(o.sortKey,i.sortKey));for(let o of r)delete o.sortKey;return r}getWithSortKey(e){var r=e;let o=[],i=this.get(r),a=i;if(i!==void 0){for(;r;)o.splice(0,0,i.fi),r=this.parent(r),r!==null&&(i=this.get(r));return{...a,sortKey:o}}}insertBeforeHelper(e,r,o){return this.insertAfterHelper(e,this.previous(e,r),o)}insertAfterHelper(e,r,o){let i=this.childrenArray(e);if(r===null){if(i.length===0)return ao(0,o,o);{let a=i[0].fi;return ao(a-o,a,o)}}else{let a=this.get(r);if(a===void 0||this.parent(r)!==e)throw new Error("illegal args");let s=i.find(l=>l.fi>a.fi);if(s===void 0){let l=i[i.length-1].fi;return ao(l,l+o,o)}else return ao(a.fi,s.fi,o)}}};var na;(t=>{function n(e,r){if(r.type!==0)return null;if(Array.isArray(e)){let o=r.props,i={},a=[...e],s=!1;if(o)for(let l of Object.keys(o)){let u=parseInt(l);if(isNaN(u))throw new Error("wrong index");i[l]=a[u],a[u]=o[l],s=!0}return s?{data:a,actual:r,reverse:{type:0,props:i}}:null}else{let o=r.props,i={},a={...e},s=!1;if(o)for(let l of Object.keys(o)){i[l]=a[l];let u=o[l];u===void 0?delete a[l]:a[l]=u,s=!0}return s?{data:a,actual:r,reverse:{type:0,props:i}}:null}}t.runOp=n})(na||(na={}));var Se=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,Se.prototype)}deepFreeze(){let e=0;for(;e<this.length;)zs(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,r){if(this.get(e)===void 0)throw new Error("not expected");{let i=this,a=i.findIndex(u=>u.id===e);if(a<0)throw new Error("not expected");let s=i[a];return i=[...i],i[a]={...s,data:r},this.modifyArrayBy(i)}}modifyArrayBy(e){Object.setPrototypeOf(e,Se.prototype);let r=e;return Pg()||r.fillCaches(),r}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:r,id:o,data:i}=e,a=this,s={fi:r,id:o,data:i};return a=[...a,s],a.sort((u,c)=>u.fi-c.fi),e.localIndex=a.indexOf(s),{data:this.modifyArrayBy(a),actual:e,reverse:{type:5,id:o}}}deleteOp(e){let{id:r}=e,o=this,i=o.findIndex(l=>l.id===r);if(i===-1)return null;e.localIndex=i,o=[...o];let a=o.splice(i,1)[0];return{data:this.modifyArrayBy(o),actual:e,reverse:{type:4,...a}}}moveOp(e){let{fi:r,id:o}=e,i=this;i=[...i];let a=i.findIndex(c=>c.id===o);if(a===-1)return null;let s=i[a].fi,l={...i[a],fi:r};return i[a]=l,i.sort((c,d)=>c.fi-d.fi),e.localIndex=i.indexOf(l),{data:this.modifyArrayBy(i),actual:e,reverse:{type:6,fi:s,id:o}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let r=null;for(let o of this){if(o.id===e)return r;r=o.id}return null}insertBeforeHelper(e,r){return this.insertAfterHelper(this.previous(e),r)}insertAfterHelper(e,r){let o=this;if(e===null){if(o.length===0)return ao(0,r,r);{let i=o[0].fi;return ao(i-r,i,r)}}else{let i=this.get(e);if(i===void 0)throw new Error("illegal args");let a=o.find(s=>s.fi>i.fi);if(a===void 0){let s=o[o.length-1].fi;return ao(s,s+r,r)}else return ao(i.fi,a.fi,r)}}};function ia(n){return n&&typeof n=="object"&&n instanceof et}var et=class{unusedFunOverridesTable(t){}runOp(t){let e=[],r=this,o=0,i={};for(;o<t.path.length;){if(e.push(r),r=r===void 0?void 0:r[t.path[o]],r!==void 0&&!ia(r))return null;o+=1}r=r?Sc(r):new et;for(let[l,u]of Object.entries(t.props)){let c=r[l];i[l]=c,u===void 0?delete r[l]:r[l]=u}for(;o>0;){if(Object.keys(r).length===0){let l=e[o-1];l&&(r=Sc(l),delete r[t.path[o-1]])}else{let l=e[o-1];if(l){let u=Sc(l);u[t.path[o-1]]=r,r=u}else{let u=new et;u[t.path[o-1]]=r,r=u}}o-=1}let a=Object.setPrototypeOf(r,et.prototype),s={...t,props:i};return{data:a,actual:t,reverse:s}}},so;(r=>{function n(o,i){return Gs(o,i)??o}r.apply=n;function t(o,i){return Xd(o,i)}r.merge=t;function e(o,i){let a=0,s=i.path,l=o;for(;a<s.length&&l!==void 0;){if(l=lt.zoomOnce(l,s[a]),l===void 0)return i;if(!ia(l))return;a+=1}if(l===void 0)return i;if(!!ia(l))if(i.type===0){let u={...i.props};for(let c of Object.keys(l))delete u[c];return{...i,props:u}}else if(i.type===1||i.type===4||i.type===7){let u=Yd([i],l);return u?(console.log(u),u):i}else return i}r.filterOp=e})(so||(so={}));function Yd(n,t){if(t===void 0)return;let e=!1,r=n.map(o=>{let i=o.id,a=Gs(o.data,t[i]);if(e=e||a!==void 0,a===void 0&&(a=o.data),o.children){let s=Yd(o.children,t);return s!==void 0?e=!0:s=o.children,{...o,id:i,data:a,children:s}}else return{...o,id:i,data:a}});if(e)return r}function $O(n,t){if(t===void 0)return;let e=!1,r=n.map(o=>{let i=o.id,a=Gs(o.data,t[i]);return e=e||a!==void 0,a===void 0&&(a=o.data),{...o,id:i,data:a}});if(e)return Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r}function Gs(n,t){if(!ia(t))return t;if(n instanceof Je){let e=Yd(n,t);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e}else{if(n instanceof Se)return $O(n,t);if(Array.isArray(n)){let e=!1,r=n.map((o,i)=>{let a=Gs(o,t[i]);return e=e||a!==void 0,a===void 0&&(a=o),a});return e?(Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r):void 0}else{if(n instanceof et)return Xd(n,t);if(n&&typeof n=="object"){let e={},r=!1;for(let[o,i]of Object.entries(n)){let a=Gs(i,t[o]);r=r||a!==void 0,a===void 0&&(a=i),e[o]=a}return r?(Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e):void 0}}}}function Xd(n,t){if(n===void 0)return t;if(t===void 0)return n;if(!ia(t))return t;if(!ia(n))return so.apply(n,t);let e=new Set;for(let o of Object.keys(n))e.add(o);for(let o of Object.keys(t))e.add(o);let r=new et;for(let o of e){let i=Xd(n===void 0?void 0:n[o],t===void 0?void 0:t[o]);r[o]=i}return r}function Tg(n,t){let e={cur:[],result:[],len:0};return n=Fs(n,t,e)??n,[n,e.result]}function wc(n,t){return n===null?null:(n.cur[n.len]=t,n.len+=1,n)}function Ac(n){n&&(n.len-=1)}function YO(n){if(n===null)return null;n.result.push(n.cur.slice(0,n.len))}function Mg(n,t,e){let r=!1,o=n.map(i=>{let a=i.id,s=t[a];if(s!==void 0&&typeof s=="string"&&(r=!0,a=s,e!==null))throw new Error("not supported");let l=Fs(i.data,t,wc(e,a));Ac(e),r=r||l!==void 0,l===void 0&&(l=i.data);let u=Mg(i.children,t,e);return u!==void 0?r=!0:u=i.children,{...i,id:a,data:l,children:u}});if(r)return o}function XO(n,t,e){let r=!1,o=n.map(i=>{let a=i.id,s=t[a];if(s!==void 0&&typeof s=="string"&&(r=!0,a=s,e!==null))throw new Error("not supported");let l=Fs(i.data,t,wc(e,a));return Ac(e),r=r||l!==void 0,l===void 0&&(l=i.data),{...i,id:a,data:l}});if(r)return Object.setPrototypeOf(o,Object.getPrototypeOf(n)),o}function Fs(n,t,e){if(n instanceof Je){let r=Mg(n,t,e);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r}else{if(n instanceof Se)return XO(n,t,e);if(Array.isArray(n)){let r=!1,o=n.map((i,a)=>{let s=Fs(i,t,wc(e,a));return Ac(e),r=r||s!==void 0,s===void 0&&(s=i),s});return r?(Object.setPrototypeOf(o,Object.getPrototypeOf(n)),o):void 0}else if(n&&typeof n=="object"&&!oa(n)){let r={},o=!1;for(let[i,a]of Object.entries(n))if(i!=="name"){let s=t[i];if(typeof s=="string"){if(e!==null)throw new Error("not supported");o=!0,i=s}let l=Fs(a,t,wc(e,i));Ac(e),o=o||l!==void 0,l===void 0&&(l=a),r[i]=l}else r[i]=a;return o?(Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r):void 0}else if(typeof n=="string"){let r=t[n];return r!==void 0&&YO(e),r}else return}}var aa;(t=>{function n(e,r){let o=lt.zoom(r,e.path);if(typeof o=="object"){let i={};for(let a of Object.keys(e.props))i[a]=o[a];return{...e,props:i}}else return{...e,props:{}}}t.replaceProps=n})(aa||(aa={}));var ct;(s=>{function n(l,u){return{...l,path:l.path.slice(u)}}s.drop=n;function t(l,u){return e(l,u)?.data??l}s.applySimple=t;function e(l,u){let c=u.path;for(var d=[];;){let p;if(l instanceof et&&u.type===0&&(p=l.runOp({...u,path:c.slice(d.length)}),p===null&&(p=void 0)),p===void 0&&d.length===c.length&&(l instanceof Je||l instanceof Se||l instanceof xe?p=l.runOp(u):p=na.runOp(l,u)),p!==void 0)if(p!==null){let m=p.data;for(let y=d.length-1;y>=0;y--){let g=c[y],b=d[y];if(b instanceof Je){if(typeof g=="number")throw new Error("illegal arg");m=b.modifyById(g,m)}else if(b instanceof Se){if(typeof g=="number")throw new Error("illegal arg");m=b.modifyById(g,m)}else if(b instanceof xe){if(typeof g=="number")throw new Error("illegal arg");m=b.modifyById(g,m)}else if(b instanceof et){let w={...b,[g]:m};m=Object.setPrototypeOf(w,et.prototype)}else if(typeof b=="object")if(Array.isArray(b)){if(typeof g=="string"&&(g=parseInt(g),isNaN(g)))throw new Error("Invalid path");let w=m;m=[...b],m[g]=w}else m={...b,[g]:m};else return null}return{data:m,actual:{...p.actual,path:c},reverse:{...p.reverse,path:c}}}else return null;let f=c[d.length],h;if(l instanceof Je){if(typeof f=="number")throw new Error("");h=l.get(f)?.data}else if(l instanceof Se){if(typeof f=="number")throw new Error("");h=l.get(f)?.data}else l!==null&&(h=l[f]);if(h!==void 0)d.push(l),l=h;else return null}}s.apply=e;function r(l,u){for(let c=0;c<l.length&&c<u.length;c++)if(l[c]!==u[c])return!0;return!1}s.pathDisjoint=r;function o(l,u){if(l.length!==u.length)return!1;for(let c=0;c<l.length;c++)if(l[c]!==u[c])return!1;return!0}s.pathEq=o;function i(l,u){return r(l.path,u.path)}s.commutative=i;function a(l,u){return l.type===0&&u.type===0&&o(l.path,u.path)?Object.keys(l.props).every(c=>u.props[c]!==void 0):!1}s.subsumed=a})(ct||(ct={}));var ks;(l=>{function n(){return[]}l.empty=n;function t(u,c){let d=[];for(let p of u){let[f,...h]=p.path;f===c&&d.push({...p,path:h})}return d}l.removePrefix=t;function e(u,c){return u.map(d=>({...d,path:[c,...d.path]}))}l.addPrefix=e;function r(u,c){return[...u,...c]}l.concat=r;function o(u,c){return[...u.filter(p=>!c.some(f=>ct.subsumed(p,f))),...c]}l.compress=o;function i(u,c){return u.every(d=>c.every(p=>ct.commutative(d,p)))}l.commutative=i;function a(u,c){for(let d of c){let p=s(u,d);p!==null&&(u=p.data)}return u}l.applyAll=a;function s(u,c){var d=u;let p=[],f=[];for(let h of c)try{if(h.type===3||h.type===5&&h.path[h.path.length-1]==="variables"){let m,y,g;if(h.type===3?(m=lt.zoom(d,[...h.path,h.id]),g=ct.apply(d,{...h,type:2})):(m=lt.zoom(d,[...h.path,h.id,"value"]),g=ct.apply(d,h)),g!==null){d=g.data;let[b,w]=Tg(d,{[h.id]:m});d=b;for(let _=0;_<w.length;_++){let S=w[_],P=S.pop();if(typeof P=="number"){let O=[P];for(let D=_+1;D<w.length;D++){let N=w[D],T=N[N.length-1];if(typeof T=="number"&&lt.equal(S,N.slice(0,N.length-1)))O.push(T),w.splice(D,1);else break}let x=lt.zoom(d,S);y=x.map((D,N)=>O.includes(N)?h.id:D),m=x,P=S.pop()}else{if(P==="alphaOverride"||P==="alpha"){m/=100;let O=m,x=lt.zoom(d,S.slice(0,S.length-2)),D=x.layers.map(N=>N.id===S[S.length-1]?{...N,data:{...N.data,[P]:O}}:N);Object.setPrototypeOf(D,Object.getPrototypeOf(x.layers)),x.layers=D}y=h.id}p.push({type:0,path:S,props:{[P]:m}}),f.push({type:0,path:S,props:{[P]:y}})}f.push(g.reverse),p.push(g.actual)}}else{let m=ct.apply(d,h);m!==null&&(p.push(m.actual),d=m.data,f.push(m.reverse))}}catch(m){if(m instanceof ra)return null;throw m}return{data:d,actual:p,reverse:f.reverse()}}l.apply=s})(ks||(ks={}));var Ig=Symbol(),QO=Symbol(),Pc=Symbol(),Jn=class{reportOp(t,e,r=[]){let o=this;if(e===null)return;o._current=e.data;let i=r;for(;!(o instanceof _c);){let a=o._path,s=o._current;if(a!==""&&i.splice(0,0,a),o=o._parent,o===null)return;o.update(a,s)}o.push(i,t,e.actual,e.reverse)}deleteChildren(t){if(this._children){let e=this._children[t];if(e){let r=e[Pc];r&&r(),delete this._children[t]}}}},Kd=class extends Jn{constructor(t,e,r){super(),this._parent=t,this._path=e,this._current=r}update(t,e){if(Array.isArray(this._current)){if(typeof t=="string"&&(t=parseInt(t),isNaN(t)))throw new Error("Invalid path");this._current=[...this._current],this._current[t]=e}else this._current={...this._current,[t]:e}}runOp(t){this.reportOp(t,na.runOp(this._current,t),t.path)}},Zd=class extends Jn{constructor(t,e,r){super(),this._parent=t,this._path=e,this._current=r}update(t,e){this._current={...this._current,[t]:e},Object.setPrototypeOf(this._current,xe.prototype)}runOp(t){this.reportOp(t,this._current.runOp(t))}},Ng={get(n,t){if(t===Pc)return()=>{n._parent=null};if(t===Ig)return n._current;if(t===QO)return n;let{_current:e,_children:r}=n;if(t==="push"&&Array.isArray(e))throw new Error("not supported to expand array");let o=r===void 0?void 0:r[t];if(o!==void 0)return o;let i=e[t],a=Oc(n,t,i);return a!==i?(r===void 0&&(r={},n._children=r),r[t]=a,a):i},has(n,t){return t 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,t){let e=n._current,r=Reflect.getOwnPropertyDescriptor(e,t);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:e[t]}}},KO={...Ng,set(n,t,e){let r={type:0,props:{[t]:ut(e)??e}};return n.deleteChildren(t),n.runOp(r),!0},deleteProperty(n,t){let e={type:0,props:{[t]:void 0}};return n.deleteChildren(t),n.runOp(e),!0}},ZO={...Ng,set(n,t,e){return e===void 0?this.deleteProperty(n,t):(n.deleteChildren(t),n.runOp({type:1,id:t,data:e})),!0},deleteProperty(n,t){return n.runOp({type:2,id:t}),!0}},sa=class extends Jn{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[Pc]=()=>{this._parent=null}}unproxy(){return this._current}update(t,e){this._current=this._current.modifyById(t,e)}runOp(t){this.reportOp(t,this._current.runOp(t))}randomId(){return this._current.randomId()}isDescendantOf(t,e){return this._current.isDescendantOf(t,e)}childrenOf(t){return this._current.childrenOf(t)}traverse(t){return this._current.traverse(t)}get(t){return this._current.get(t)}parent(t){return this._current.parent(t)}traverse(t){this._current.traverse((e,r)=>{t(e,this.data(e))})}data(t){let{_current:e,_children:r}=this,o=r===void 0?void 0:r[t];if(o!==void 0)return o;let i=e.get(t)?.data,a=Oc(this,t,i);return a!==i?(r===void 0&&(r={},this._children=r),r[t]=a,a):i}add(t,e,r,o,i){this.runOp({type:7,parent:t,fi:e,id:r,data:o,children:i})}move(t,e,r){this.runOp({type:9,parent:t,fi:e,id:r})}insertAfter(t,e,r){let o=this._current.insertAfterHelper(t,e,r.length);for(let i=0;i<r.length;i++){let a=r[i];this.add(t,o[i],a.id,a.data,a.children)}}insertBefore(t,e,r){let o=this._current.insertBeforeHelper(t,e,r.length);for(let i=0;i<r.length;i++){let a=r[i];this.add(t,o[i],a.id,a.data,a.children)}}moveAfter(t,e,r){let o=this._current.insertAfterHelper(t,e,r.length);for(let i=0;i<r.length;i++){let a=r[i];this.move(t,o[i],a)}}moveBefore(t,e,r){let o=this._current.insertBeforeHelper(t,e,r.length);for(let i=0;i<r.length;i++){let a=r[i];this.move(t,o[i],a)}}delete(t){this.deleteChildren(t),this.runOp({type:8,id:t})}sortNext(t){return this._current.sortNext(t)}sortPrevious(t){return this._current.sortPrevious(t)}getAllSorted(t){return this._current.getAllSorted(t)}},la=class extends Jn{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[Pc]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(t){let e=this.length;for(let r=0;r<e;r++){let o=this._current[r].id,i=this._current[r].fi;t(this.data(this._current[r].id),o,i)}}find(t){let e=this.length;for(let r=0;r<e;r++){let o=this._current[r].id;if(t(this.data(o),o))return this.get(o)}}update(t,e){this._current=this._current.modifyById(t,e)}randomId(){return this._current.randomId()}get(t){return{...this._current.get(t),data:this.data(t)}}data(t){let{_current:e,_children:r}=this,o=r===void 0?void 0:r[t];if(o!==void 0)return o;let i=e.get(t)?.data,a=Oc(this,t,i);return a!==i?(r===void 0&&(r={},this._children=r),r[t]=a,a):i}runOp(t){this.reportOp(t,this._current.runOp(t))}add(t,e,r){this.runOp({type:4,fi:t,id:e,data:r})}move(t,e){this.runOp({type:6,fi:t,id:e})}insertAfter(t,e){let r=this._current.insertAfterHelper(t,e.length);for(let o=0;o<e.length;o++){let i=e[o];this.add(r[o],i.id,i.data)}}insertBefore(t,e){let r=this._current.insertBeforeHelper(t,e.length);for(let o=0;o<e.length;o++){let i=e[o];this.add(r[o],i.id,i.data)}}moveAfter(t,e){let r=this._current.insertAfterHelper(t,e.length);for(let o=0;o<e.length;o++){let i=e[o];this.move(r[o],i)}}moveBefore(t,e){let r=this._current.insertBeforeHelper(t,e.length);for(let o=0;o<e.length;o++){let i=e[o];this.move(r[o],i)}}delete(t){this.deleteChildren(t),this.runOp({type:5,id:t})}};function Qd(n,t,e){if(n.length>0){let r=n[n.length-1];if(r.type===0&&t.type===0&&lt.equal(r.path,e)){Object.assign(r.props,t.props);return}}n.push({...t,path:e})}var _c=class extends Jn{constructor(t){super(),this.ts=[],this.actual=[],this.reverse=[],this._current=t}update(t,e){if(t!=="")throw new Error("");this._current=e}push(t,e,r,o){Qd(this.ts,e,t),Qd(this.actual,r,t),Qd(this.reverse,o,t)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function Oc(n,t,e){return e instanceof Je?new sa(n,t,e):e instanceof Se?new la(n,t,e):e instanceof xe?new Proxy(new Zd(n,t,e),ZO):e!==null&&typeof e=="object"?oa(e)?e:new Proxy(new Kd(n,t,e),KO):e}function Jd(n){let t=new _c(n);return[Oc(t,"",n),t]}function fn(n,t){let[e,r]=Jd(n);return t(e),r.result()}function ut(n){return n instanceof sa||n instanceof la?n._current:n!==null&&typeof n=="object"?n[Ig]:n}var lt;(o=>{function n(i,a){if(a.length===i.length)for(var s=0;s<i.length;){if(i[s]!==a[s])return!1;s+=1}else return!1;return!0}o.equal=n;function t(i,a,s){let l=r(s,i);if(l!==void 0&&typeof l=="object"&&l!==null){let u={...a};return Object.keys(l).forEach(c=>{delete u[c]}),u}else return a}o.removeOverridden=t;function e(i,a){if((i instanceof Je||i instanceof sa)&&typeof a=="string")return i.data(a);if((i instanceof Se||i instanceof la)&&typeof a=="string")return i.data(a);if(typeof a=="number"&&Array.isArray(i))return i[a];if(typeof a=="string"&&typeof i=="object"&&i!==null)return i[a]}o.zoomOnce=e;function r(i,a,s=0){for(;s<a.length&&i!==void 0;)i=e(i,a[s]),s+=1;return i}o.zoom=r})(lt||(lt={}));function Dg(n,t){let e=[];if(t.length===n.length)for(var r=0;r<n.length;){if(t[r]==="*")e.push(n[r]);else if(n[r]!==t[r])return null;r+=1}else return null;return e}function Le(n,t){let e=[];if(t.length<=n.length)for(var r=0;r<t.length;){if(t[r]==="*")e.push(n[r]);else if(n[r]!==t[r])return null;r+=1}else return null;return e}var Cc=class{},js=class extends Cc{constructor(e){super();this.id=e}},Us=class extends Cc{constructor(e){super();this.data=e}};var tp;try{tp=new TextDecoder}catch{}var de,mn,G=0;var Fg=[],rp=Fg,op=0,ur={},We,hn,Mr=0,lo=0,Sr,zo,or=[],Ye,Eg={useRecords:!1,mapsAsObjects:!0},Hs=class{},ip=new Hs;ip.name="MessagePack 0xC1";var ca=!1,co=class{constructor(t){t&&(t.useRecords===!1&&t.mapsAsObjects===void 0&&(t.mapsAsObjects=!0),t.structures?t.structures.sharedLength=t.structures.length:t.getStructures&&((t.structures=[]).uninitialized=!0,t.structures.sharedLength=0)),Object.assign(this,t)}unpack(t,e){if(de)return qg(()=>(Mc(),this?this.unpack(t,e):co.prototype.unpack.call(Eg,t,e)));mn=e>-1?e:t.length,G=0,op=0,lo=0,hn=null,rp=Fg,Sr=null,de=t;try{Ye=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(r){throw de=null,t instanceof Uint8Array?r:new Error("Source must be a Uint8Array or Buffer but was a "+(t&&typeof t=="object"?t.constructor.name:typeof t))}if(this instanceof co){if(ur=this,this.structures)return We=this.structures,Tc();(!We||We.length>0)&&(We=[])}else ur=Eg,(!We||We.length>0)&&(We=[]);return Tc()}unpackMultiple(t,e){let r,o=0;try{ca=!0;let i=t.length,a=this?this.unpack(t,i):Dc.unpack(t,i);if(e){for(e(a);G<i;)if(o=G,e(Tc())===!1)return}else{for(r=[a];G<i;)o=G,r.push(Tc());return r}}catch(i){throw i.lastPosition=o,i.values=r,i}finally{ca=!1,Mc()}}_mergeStructures(t,e){t=t||[];for(let r=0,o=t.length;r<o;r++){let i=t[r];i&&(i.isShared=!0,r>=32&&(i.highByte=r-32>>5))}t.sharedLength=t.length;for(let r in e||[])if(r>=0){let o=t[r],i=e[r];i&&(o&&((t.restoreStructures||(t.restoreStructures=[]))[r]=o),t[r]=i)}return this.structures=t}decode(t,e){return this.unpack(t,e)}};function Tc(){try{if(!ur.trusted&&!ca){let t=We.sharedLength||0;t<We.length&&(We.length=t)}let n=gt();if(G==mn)We.restoreStructures&&Bg(),We=null,de=null,zo&&(zo=null);else if(G>mn){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!ca)throw new Error("Data read, but end of buffer not reached");return n}catch(n){throw We.restoreStructures&&Bg(),Mc(),(n instanceof RangeError||n.message.startsWith("Unexpected end of buffer"))&&(n.incomplete=!0),n}}function Bg(){for(let n in We.restoreStructures)We[n]=We.restoreStructures[n];We.restoreStructures=null}function gt(){let n=de[G++];if(n<160)if(n<128){if(n<64)return n;{let t=We[n&63]||ur.getStructures&&kg()[n&63];return t?(t.read||(t.read=ap(t,n&63)),t.read()):n}}else if(n<144)if(n-=128,ur.mapsAsObjects){let t={};for(let e=0;e<n;e++)t[Ug()]=gt();return t}else{let t=new Map;for(let e=0;e<n;e++)t.set(gt(),gt());return t}else{n-=144;let t=new Array(n);for(let e=0;e<n;e++)t[e]=gt();return t}else if(n<192){let t=n-160;if(lo>=G)return hn.slice(G-Mr,(G+=t)-Mr);if(lo==0&&mn<140){let e=t<16?sp(t):jg(t);if(e!=null)return e}return np(t)}else{let t;switch(n){case 192:return null;case 193:return Sr?(t=gt(),t>0?Sr[1].slice(Sr.position1,Sr.position1+=t):Sr[0].slice(Sr.position0,Sr.position0-=t)):ip;case 194:return!1;case 195:return!0;case 196:return ep(de[G++]);case 197:return t=Ye.getUint16(G),G+=2,ep(t);case 198:return t=Ye.getUint32(G),G+=4,ep(t);case 199:return ei(de[G++]);case 200:return t=Ye.getUint16(G),G+=2,ei(t);case 201:return t=Ye.getUint32(G),G+=4,ei(t);case 202:if(t=Ye.getFloat32(G),ur.useFloat32>2){let e=Nc[(de[G]&127)<<1|de[G+1]>>7];return G+=4,(e*t+(t>0?.5:-.5)>>0)/e}return G+=4,t;case 203:return t=Ye.getFloat64(G),G+=8,t;case 204:return de[G++];case 205:return t=Ye.getUint16(G),G+=2,t;case 206:return t=Ye.getUint32(G),G+=4,t;case 207:return ur.int64AsNumber?(t=Ye.getUint32(G)*4294967296,t+=Ye.getUint32(G+4)):t=Ye.getBigUint64(G),G+=8,t;case 208:return Ye.getInt8(G++);case 209:return t=Ye.getInt16(G),G+=2,t;case 210:return t=Ye.getInt32(G),G+=4,t;case 211:return ur.int64AsNumber?(t=Ye.getInt32(G)*4294967296,t+=Ye.getUint32(G+4)):t=Ye.getBigInt64(G),G+=8,t;case 212:if(t=de[G++],t==114)return Gg(de[G++]&63);{let e=or[t];if(e)return e.read?(G++,e.read(gt())):e.noBuffer?(G++,e()):e(de.subarray(G,++G));throw new Error("Unknown extension "+t)}case 213:return t=de[G],t==114?(G++,Gg(de[G++]&63,de[G++])):ei(2);case 214:return ei(4);case 215:return ei(8);case 216:return ei(16);case 217:return t=de[G++],lo>=G?hn.slice(G-Mr,(G+=t)-Mr):eC(t);case 218:return t=Ye.getUint16(G),G+=2,lo>=G?hn.slice(G-Mr,(G+=t)-Mr):tC(t);case 219:return t=Ye.getUint32(G),G+=4,lo>=G?hn.slice(G-Mr,(G+=t)-Mr):rC(t);case 220:return t=Ye.getUint16(G),G+=2,Rg(t);case 221:return t=Ye.getUint32(G),G+=4,Rg(t);case 222:return t=Ye.getUint16(G),G+=2,Vg(t);case 223:return t=Ye.getUint32(G),G+=4,Vg(t);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 JO=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function ap(n,t){function e(){if(e.count++>2){let o=n.read=new Function("r","return function(){return {"+n.map(i=>JO.test(i)?i+":r()":"["+JSON.stringify(i)+"]:r()").join(",")+"}}")(gt);return n.highByte===0&&(n.read=Lg(t,n.read)),o()}let r={};for(let o=0,i=n.length;o<i;o++){let a=n[o];r[a]=gt()}return r}return e.count=0,n.highByte===0?Lg(t,e):e}var Lg=(n,t)=>function(){let e=de[G++];if(e===0)return t();let r=n<32?-(n+(e<<5)):n+(e<<5),o=We[r]||kg()[r];if(!o)throw new Error("Record id is not defined for "+r);return o.read||(o.read=ap(o,n)),o.read()};function kg(){let n=qg(()=>(de=null,ur.getStructures()));return We=ur._mergeStructures(n,We)}var np=Ic,eC=Ic,tC=Ic,rC=Ic;function Ic(n){let t;if(n<16&&(t=sp(n)))return t;if(n>64&&tp)return tp.decode(de.subarray(G,G+=n));let e=G+n,r=[];for(t="";G<e;){let o=de[G++];if((o&128)===0)r.push(o);else if((o&224)===192){let i=de[G++]&63;r.push((o&31)<<6|i)}else if((o&240)===224){let i=de[G++]&63,a=de[G++]&63;r.push((o&31)<<12|i<<6|a)}else if((o&248)===240){let i=de[G++]&63,a=de[G++]&63,s=de[G++]&63,l=(o&7)<<18|i<<12|a<<6|s;l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|l&1023),r.push(l)}else r.push(o);r.length>=4096&&(t+=Vt.apply(String,r),r.length=0)}return r.length>0&&(t+=Vt.apply(String,r)),t}function Rg(n){let t=new Array(n);for(let e=0;e<n;e++)t[e]=gt();return t}function Vg(n){if(ur.mapsAsObjects){let t={};for(let e=0;e<n;e++)t[Ug()]=gt();return t}else{let t=new Map;for(let e=0;e<n;e++)t.set(gt(),gt());return t}}var Vt=String.fromCharCode;function jg(n){let t=G,e=new Array(n);for(let r=0;r<n;r++){let o=de[G++];if((o&128)>0){G=t;return}e[r]=o}return Vt.apply(String,e)}function sp(n){if(n<4)if(n<2){if(n===0)return"";{let t=de[G++];if((t&128)>1){G-=1;return}return Vt(t)}}else{let t=de[G++],e=de[G++];if((t&128)>0||(e&128)>0){G-=2;return}if(n<3)return Vt(t,e);let r=de[G++];if((r&128)>0){G-=3;return}return Vt(t,e,r)}else{let t=de[G++],e=de[G++],r=de[G++],o=de[G++];if((t&128)>0||(e&128)>0||(r&128)>0||(o&128)>0){G-=4;return}if(n<6){if(n===4)return Vt(t,e,r,o);{let i=de[G++];if((i&128)>0){G-=5;return}return Vt(t,e,r,o,i)}}else if(n<8){let i=de[G++],a=de[G++];if((i&128)>0||(a&128)>0){G-=6;return}if(n<7)return Vt(t,e,r,o,i,a);let s=de[G++];if((s&128)>0){G-=7;return}return Vt(t,e,r,o,i,a,s)}else{let i=de[G++],a=de[G++],s=de[G++],l=de[G++];if((i&128)>0||(a&128)>0||(s&128)>0||(l&128)>0){G-=8;return}if(n<10){if(n===8)return Vt(t,e,r,o,i,a,s,l);{let u=de[G++];if((u&128)>0){G-=9;return}return Vt(t,e,r,o,i,a,s,l,u)}}else if(n<12){let u=de[G++],c=de[G++];if((u&128)>0||(c&128)>0){G-=10;return}if(n<11)return Vt(t,e,r,o,i,a,s,l,u,c);let d=de[G++];if((d&128)>0){G-=11;return}return Vt(t,e,r,o,i,a,s,l,u,c,d)}else{let u=de[G++],c=de[G++],d=de[G++],p=de[G++];if((u&128)>0||(c&128)>0||(d&128)>0||(p&128)>0){G-=12;return}if(n<14){if(n===12)return Vt(t,e,r,o,i,a,s,l,u,c,d,p);{let f=de[G++];if((f&128)>0){G-=13;return}return Vt(t,e,r,o,i,a,s,l,u,c,d,p,f)}}else{let f=de[G++],h=de[G++];if((f&128)>0||(h&128)>0){G-=14;return}if(n<15)return Vt(t,e,r,o,i,a,s,l,u,c,d,p,f,h);let m=de[G++];if((m&128)>0){G-=15;return}return Vt(t,e,r,o,i,a,s,l,u,c,d,p,f,h,m)}}}}}function ep(n){return ur.copyBuffers?Uint8Array.prototype.slice.call(de,G,G+=n):de.subarray(G,G+=n)}function ei(n){let t=de[G++];if(or[t])return or[t](de.subarray(G,G+=n));throw new Error("Unknown extension type "+t)}var zg=new Array(4096);function Ug(){let n=de[G++];if(n>=160&&n<192){if(n=n-160,lo>=G)return hn.slice(G-Mr,(G+=n)-Mr);if(!(lo==0&&mn<180))return np(n)}else return G--,gt();let t=(n<<5^(n>1?Ye.getUint16(G):n>0?de[G]:0))&4095,e=zg[t],r=G,o=G+n-3,i,a=0;if(e&&e.bytes==n){for(;r<o;){if(i=Ye.getUint32(r),i!=e[a++]){r=1879048192;break}r+=4}for(o+=3;r<o;)if(i=de[r++],i!=e[a++]){r=1879048192;break}if(r===o)return G=r,e.string;o-=3,r=G}for(e=[],zg[t]=e,e.bytes=n;r<o;)i=Ye.getUint32(r),e.push(i),r+=4;for(o+=3;r<o;)i=de[r++],e.push(i);let s=n<16?sp(n):jg(n);return s!=null?e.string=s:e.string=np(n)}var Gg=(n,t)=>{var e=gt();let r=n;t!==void 0&&(n=n<32?-((t<<5)+n):(t<<5)+n,e.highByte=t);let o=We[n];return o&&o.isShared&&((We.restoreStructures||(We.restoreStructures=[]))[n]=o),We[n]=e,e.read=ap(e,r),e.read()},Hg=typeof self=="object"?self:global;or[0]=()=>{};or[0].noBuffer=!0;or[101]=()=>{let n=gt();return(Hg[n[0]]||Error)(n[1])};or[105]=n=>{let t=Ye.getUint32(G-4);zo||(zo=new Map);let e=de[G],r;e>=144&&e<160||e==220||e==221?r=[]:r={};let o={target:r};zo.set(t,o);let i=gt();return o.used?Object.assign(r,i):(o.target=i,i)};or[112]=n=>{let t=Ye.getUint32(G-4),e=zo.get(t);return e.used=!0,e.target};or[115]=()=>new Set(gt());var lp=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(n=>n+"Array");or[116]=n=>{let t=n[0],e=lp[t];if(!e)throw new Error("Could not find typed array for code "+t);return new Hg[e](Uint8Array.prototype.slice.call(n,1).buffer)};or[120]=()=>{let n=gt();return new RegExp(n[0],n[1])};or[98]=n=>{let t=(n[0]<<24)+(n[1]<<16)+(n[2]<<8)+n[3],e=G;G+=t-4,Sr=[gt(),gt()],Sr.position0=0,Sr.position1=0;let r=G;G=e;try{return gt()}finally{G=r}};or[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 qg(n){let t=mn,e=G,r=op,o=Mr,i=lo,a=hn,s=rp,l=zo,u=Sr,c=new Uint8Array(de.slice(0,mn)),d=We,p=We.slice(0,We.length),f=ur,h=ca,m=n();return mn=t,G=e,op=r,Mr=o,lo=i,hn=a,rp=s,zo=l,Sr=u,de=c,ca=h,We=d,We.splice(0,We.length,...p),ur=f,Ye=new DataView(de.buffer,de.byteOffset,de.byteLength),m}function Mc(){de=null,zo=null,We=null}function Wg(n){n.unpack?or[n.type]=n.unpack:or[n.type]=n}var Nc=new Array(147);for(let n=0;n<256;n++)Nc[n]=+("1e"+Math.floor(45.15-n*.30103));var Dc=new co({useRecords:!1}),oC=Dc.unpack,nC=Dc.unpackMultiple,iC=Dc.unpack,Ec={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},aC=new Float32Array(1),SU=new Uint8Array(aC.buffer,0,4);var Bc;try{Bc=new TextEncoder}catch{}var Lc,up,Rc=typeof Buffer<"u",cp=Rc?Buffer.allocUnsafeSlow:Uint8Array,Qg=Rc?Buffer:Uint8Array,$g=Rc?4294967296:2144337920,Z,vt,j=0,uo,po=null,sC=/[\u0080-\uFFFF]/,qs=Symbol("record-id"),ti=class extends co{constructor(t){super(t),this.offset=0;let e,r,o,i,a,s,l=0,u=Qg.prototype.utf8Write?function(x,D,N){return Z.utf8Write(x,D,N)}:Bc&&Bc.encodeInto?function(x,D){return Bc.encodeInto(x,Z.subarray(D)).written}:!1,c=this;t||(t={});let d=t&&t.sequential,p=t.structures||t.saveStructures,f=t.maxSharedStructures;if(f==null&&(f=p?32:0),f>8160)throw new Error("Maximum maxSharedStructure is 8160");let h=t.maxOwnStructures;h==null&&(h=p?32:64),d&&!t.saveStructures&&(this.structures=[]);let m=f>32||h+f>64,y=f+64,g=f+h+64;if(g>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let b=[],w=0,_=0;this.pack=this.encode=function(x,D){if(Z||(Z=new cp(8192),vt=new DataView(Z.buffer,0,8192),j=0),uo=Z.length-10,uo-j<2048?(Z=new cp(Z.length),vt=new DataView(Z.buffer,0,Z.length),uo=Z.length-10,j=0):j=j+7&2147483640,r=j,s=c.structuredClone?new Map:null,c.bundleStrings?(po=["",""],Z[j++]=214,Z[j++]=98,po.position=j-r,j+=4):po=null,o=c.structures,o){o.uninitialized&&(o=c._mergeStructures(c.getStructures()));let N=o.sharedLength||0;if(N>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 T=0;T<N;T++){let I=o[T];if(!I)continue;let E,B=o.transitions;for(let R=0,F=I.length;R<F;R++){let V=I[R];E=B[V],E||(E=B[V]=Object.create(null)),B=E}B[qs]=T+64}l=N}d||(o.nextId=N+64)}i&&(i=!1),a=o||[];try{if(S(x),po){vt.setUint32(po.position+r,j-po.position-r);let N=po;po=null,S(N[0]),S(N[1])}if(c.offset=j,s&&s.idsToInsert){j+=s.idsToInsert.length*6,j>uo&&O(j),c.offset=j;let N=cC(Z.subarray(r,j),s.idsToInsert);return s=null,N}return D&Zg?(Z.start=r,Z.end=j,Z):Z.subarray(r,j)}finally{if(o){if(_<10&&_++,w>1e4)o.transitions=null,_=0,w=0,b.length>0&&(b=[]);else if(b.length>0&&!d){for(let N=0,T=b.length;N<T;N++)b[N][qs]=0;b=[]}if(i&&c.saveStructures){let N=o.sharedLength||f;o.length>N&&(o=o.slice(0,N));let T=Z.subarray(r,j);return c.saveStructures(o,l)===!1?(c._mergeStructures(c.getStructures()),c.pack(x)):(l=N,T)}}D&yC&&(j=r)}};let S=x=>{j>uo&&(Z=O(j));var D=typeof x,N;if(D==="string"){let T=x.length;if(po&&T>=8&&T<4096){let B=sC.test(x);po[B?0:1]+=x,Z[j++]=193,S(B?-T:T);return}let I;T<32?I=1:T<256?I=2:T<65536?I=3:I=5;let E=T*3;if(j+E>uo&&(Z=O(j+E)),T<64||!u){let B,R,F,V=j+I;for(B=0;B<T;B++)R=x.charCodeAt(B),R<128?Z[V++]=R:R<2048?(Z[V++]=R>>6|192,Z[V++]=R&63|128):(R&64512)===55296&&((F=x.charCodeAt(B+1))&64512)===56320?(R=65536+((R&1023)<<10)+(F&1023),B++,Z[V++]=R>>18|240,Z[V++]=R>>12&63|128,Z[V++]=R>>6&63|128,Z[V++]=R&63|128):(Z[V++]=R>>12|224,Z[V++]=R>>6&63|128,Z[V++]=R&63|128);N=V-j-I}else N=u(x,j+I,E);N<32?Z[j++]=160|N:N<256?(I<2&&Z.copyWithin(j+2,j+1,j+1+N),Z[j++]=217,Z[j++]=N):N<65536?(I<3&&Z.copyWithin(j+3,j+2,j+2+N),Z[j++]=218,Z[j++]=N>>8,Z[j++]=N&255):(I<5&&Z.copyWithin(j+5,j+3,j+3+N),Z[j++]=219,vt.setUint32(j,N),j+=4),j+=N}else if(D==="number")if(x>>>0===x)x<64?Z[j++]=x:x<256?(Z[j++]=204,Z[j++]=x):x<65536?(Z[j++]=205,Z[j++]=x>>8,Z[j++]=x&255):(Z[j++]=206,vt.setUint32(j,x),j+=4);else if(x>>0===x)x>=-32?Z[j++]=256+x:x>=-128?(Z[j++]=208,Z[j++]=x+256):x>=-32768?(Z[j++]=209,vt.setInt16(j,x),j+=2):(Z[j++]=210,vt.setInt32(j,x),j+=4);else{let T;if((T=this.useFloat32)>0&&x<4294967296&&x>=-2147483648){Z[j++]=202,vt.setFloat32(j,x);let I;if(T<4||(I=x*Nc[(Z[j]&127)<<1|Z[j+1]>>7])>>0===I){j+=4;return}else j--}Z[j++]=203,vt.setFloat64(j,x),j+=8}else if(D==="object")if(!x)Z[j++]=192;else{if(s){let I=s.get(x);if(I){if(!I.id){let E=s.idsToInsert||(s.idsToInsert=[]);I.id=E.push(I)}Z[j++]=214,Z[j++]=112,vt.setUint32(j,I.id),j+=4;return}else s.set(x,{offset:j-r})}let T=x.constructor;if(T===Object)P(x,!0);else if(T===Array){N=x.length,N<16?Z[j++]=144|N:N<65536?(Z[j++]=220,Z[j++]=N>>8,Z[j++]=N&255):(Z[j++]=221,vt.setUint32(j,N),j+=4);for(let I=0;I<N;I++)S(x[I])}else if(T===Map){N=x.size,N<16?Z[j++]=128|N:N<65536?(Z[j++]=222,Z[j++]=N>>8,Z[j++]=N&255):(Z[j++]=223,vt.setUint32(j,N),j+=4);for(let[I,E]of x)S(I),S(E)}else{for(let I=0,E=Lc.length;I<E;I++){let B=up[I];if(x instanceof B){let R=Lc[I];if(R.write){R.type&&(Z[j++]=212,Z[j++]=R.type,Z[j++]=0),S(R.write.call(this,x));return}let F=Z,V=vt,q=j;Z=null;let k;try{k=R.pack.call(this,x,U=>(Z=F,F=null,j+=U,j>uo&&O(j),{target:Z,targetView:vt,position:j-U}),S)}finally{F&&(Z=F,vt=V,j=q,uo=Z.length-10)}k&&(k.length+j>uo&&O(k.length+j),j=lC(k,Z,j,R.type));return}}P(x,!x.hasOwnProperty)}}else if(D==="boolean")Z[j++]=x?195:194;else if(D==="bigint"){if(x<BigInt(1)<<BigInt(63)&&x>=-(BigInt(1)<<BigInt(63)))Z[j++]=211,vt.setBigInt64(j,x);else if(x<BigInt(1)<<BigInt(64)&&x>0)Z[j++]=207,vt.setBigUint64(j,x);else if(this.largeBigIntToFloat)Z[j++]=203,vt.setFloat64(j,Number(x));else throw new RangeError(x+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");j+=8}else if(D==="undefined")this.encodeUndefinedAsNil?Z[j++]=192:(Z[j++]=212,Z[j++]=0,Z[j++]=0);else if(D==="function")S(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+D)},P=this.useRecords===!1?this.variableMapSize?x=>{let D=Object.keys(x),N=D.length;N<16?Z[j++]=128|N:N<65536?(Z[j++]=222,Z[j++]=N>>8,Z[j++]=N&255):(Z[j++]=223,vt.setUint32(j,N),j+=4);let T;for(let I=0;I<N;I++)S(T=D[I]),S(x[T])}:(x,D)=>{Z[j++]=222;let N=j-r;j+=2;let T=0;for(let I in x)(D||x.hasOwnProperty(I))&&(S(I),S(x[I]),T++);Z[N+++r]=T>>8,Z[N+r]=T&255}:x=>{let D=Object.keys(x),N,T=a.transitions||(a.transitions=Object.create(null)),I=0;for(let B=0,R=D.length;B<R;B++){let F=D[B];N=T[F],N||(N=T[F]=Object.create(null),I++),T=N}let E=T[qs];if(E)E>=96&&m?(Z[j++]=((E-=96)&31)+96,Z[j++]=E>>5):Z[j++]=E;else{E=a.nextId,E||(E=64),E<y&&this.shouldShareStructure&&!this.shouldShareStructure(D)?(E=a.nextOwnId,E<g||(E=y),a.nextOwnId=E+1):(E>=g&&(E=y),a.nextId=E+1);let B=D.highByte=E>=96&&m?E-96>>5:-1;T[qs]=E,a[E-64]=D,E<y?(D.isShared=!0,a.sharedLength=E-63,i=!0,B>=0?(Z[j++]=(E&31)+96,Z[j++]=B):Z[j++]=E):(B>=0?(Z[j++]=213,Z[j++]=114,Z[j++]=(E&31)+96,Z[j++]=B):(Z[j++]=212,Z[j++]=114,Z[j++]=E),I&&(w+=_*I),b.length>=h&&(b.shift()[qs]=0),b.push(T),S(D))}for(let B=0,R=D.length;B<R;B++)S(x[D[B]])},O=x=>{let D;if(x>16777216){if(x-r>$g)throw new Error("Packed buffer would be larger than maximum buffer size");D=Math.min($g,Math.round(Math.max((x-r)*(x>67108864?1.25:2),4194304)/4096)*4096)}else D=(Math.max(x-r<<2,Z.length-1)>>12)+1<<12;let N=new cp(D);return vt=new DataView(N.buffer,0,D),Z.copy?Z.copy(N,0,r,x):N.set(Z.slice(r,x)),j-=r,r=0,uo=N.length-10,Z=N}}useBuffer(t){Z=t,vt=new DataView(Z.buffer,Z.byteOffset,Z.byteLength),j=0}};up=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,Hs];Lc=[{pack(n,t,e){let r=n.getTime()/1e3;if((this.useTimestamp32||n.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:o,targetView:i,position:a}=t(6);o[a++]=214,o[a++]=255,i.setUint32(a,r)}else if(r>0&&r<17179869184){let{target:o,targetView:i,position:a}=t(10);o[a++]=215,o[a++]=255,i.setUint32(a,n.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),i.setUint32(a+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),e(this.onInvalidDate());let{target:o,targetView:i,position:a}=t(3);o[a++]=212,o[a++]=255,o[a++]=255}else{let{target:o,targetView:i,position:a}=t(15);o[a++]=199,o[a++]=12,o[a++]=255,i.setUint32(a,n.getMilliseconds()*1e6),i.setBigInt64(a+4,BigInt(Math.floor(r)))}}},{pack(n,t,e){let r=Array.from(n),{target:o,position:i}=t(this.structuredClone?3:0);this.structuredClone&&(o[i++]=212,o[i++]=115,o[i++]=0),e(r)}},{pack(n,t,e){let{target:r,position:o}=t(this.structuredClone?3:0);this.structuredClone&&(r[o++]=212,r[o++]=101,r[o++]=0),e([n.name,n.message])}},{pack(n,t,e){let{target:r,position:o}=t(this.structuredClone?3:0);this.structuredClone&&(r[o++]=212,r[o++]=120,r[o++]=0),e([n.source,n.flags])}},{pack(n,t){this.structuredClone?Yg(n,16,t):Xg(Rc?Buffer.from(n):new Uint8Array(n),t)}},{pack(n,t){let e=n.constructor;e!==Qg&&this.structuredClone?Yg(n,lp.indexOf(e.name),t):Xg(n,t)}},{pack(n,t){let{target:e,position:r}=t(1);e[r]=193}}];function Yg(n,t,e,r){let o=n.byteLength;if(o+1<256){var{target:i,position:a}=e(4+o);i[a++]=199,i[a++]=o+1}else if(o+1<65536){var{target:i,position:a}=e(5+o);i[a++]=200,i[a++]=o+1>>8,i[a++]=o+1&255}else{var{target:i,position:a,targetView:s}=e(7+o);i[a++]=201,s.setUint32(a,o+1),a+=4}i[a++]=116,i[a++]=t,i.set(new Uint8Array(n.buffer,n.byteOffset,n.byteLength),a)}function Xg(n,t){let e=n.byteLength;var r,o;if(e<256){var{target:r,position:o}=t(e+2);r[o++]=196,r[o++]=e}else if(e<65536){var{target:r,position:o}=t(e+3);r[o++]=197,r[o++]=e>>8,r[o++]=e&255}else{var{target:r,position:o,targetView:i}=t(e+5);r[o++]=198,i.setUint32(o,e),o+=4}r.set(n,o)}function lC(n,t,e,r){let o=n.length;switch(o){case 1:t[e++]=212;break;case 2:t[e++]=213;break;case 4:t[e++]=214;break;case 8:t[e++]=215;break;case 16:t[e++]=216;break;default:o<256?(t[e++]=199,t[e++]=o):o<65536?(t[e++]=200,t[e++]=o>>8,t[e++]=o&255):(t[e++]=201,t[e++]=o>>24,t[e++]=o>>16&255,t[e++]=o>>8&255,t[e++]=o&255)}return t[e++]=r,t.set(n,e),e+=o,e}function cC(n,t){let e,r=t.length*6,o=n.length-r;for(t.sort((i,a)=>i.offset>a.offset?1:-1);e=t.pop();){let i=e.offset,a=e.id;n.copyWithin(i+r,i,o),r-=6;let s=i+r;n[s++]=214,n[s++]=105,n[s++]=a>>24,n[s++]=a>>16&255,n[s++]=a>>8&255,n[s++]=a&255,o=i}return n}function yn(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)");up.unshift(n.Class),Lc.unshift(n)}Wg(n)}var Kg=new ti({useRecords:!1}),uC=Kg.pack,dC=Kg.pack;var{NEVER:pC,ALWAYS:fC,DECIMAL_ROUND:hC,DECIMAL_FIT:mC}=Ec,Zg=512,yC=1024;var Jg=new ti({structuredClone:!0});yn({Class:xe.prototype.constructor,type:1,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,xe.prototype),n}});yn({Class:Se.prototype.constructor,type:2,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,Se.prototype),n}});yn({Class:Je.prototype.constructor,type:3,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,Je.prototype),n}});yn({Class:js.prototype.constructor,type:4,write(n){return n.id},read(n){return new js(n)}});yn({Class:Us.prototype.constructor,type:5,write(n){return n.data},read(n){return new Us(n)}});yn({Class:et.prototype.constructor,type:6,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,et.prototype),n}});function gC(n){var t=0;if(n.length===0)return t;for(let e=0;e<n.length;e++){let r=n[e];t=(t<<5)-t+r,t=t&t}return t}function dp(n){if(oa(n))return n;if(Array.isArray(n))return n.map(dp);if(typeof n=="object"&&n!==null){let t={};for(let e of Object.keys(n).sort())t[e]=dp(n[e]);return Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t}else return n}var Vc;(r=>{function n(o){return Jg.pack(o)}r.serialize=n;function t(o){return Jg.unpack(o)}r.deserialize=t;function e(o){return gC(n(dp(o))).toString()}r.checksum=e})(Vc||(Vc={}));var bn="personal camera",vn="a218fcc3-276b-49b9-b485-49037fd14f5f",n0=2960946,St=5526619;var Ws;(d=>{function n(p,f){return p[0]===f[0]&&p[1]===f[1]}d.isEqual=n;function t(p,f,h){return[p[0]+(f[0]-p[0])*h,p[1]+(f[1]-p[1])*h]}d.lerp=t;function e(p,f){return[p[0]+f[0],p[1]+f[1]]}d.add=e;function r(p,f){return[p[0]-f[0],p[1]-f[1]]}d.sub=r;function o(p,f){return Math.pow(f[0]-p[0],2)+Math.pow(f[1]-p[1],2)}d.distanceSquared=o;function i(p,f){return Math.sqrt(o(p,f))}d.distance=i;function a(p,f){return p[0]*f[0]+p[1]*f[1]}d.dot=a;function s(p,f){return[p[0]*f,p[1]*f]}d.scalarMultiply=s;function l(p,f,h){let m=d.sub(f,p),y=d.sub(h,p),g=d.dot(m,y)/d.dot(m,m),b=d.scalarMultiply(m,g);return d.add(p,b)}d.projectionOnto=l;function u(p,f,h){return i(p,l(p,f,h))}d.projectionOntoDistance=u;function c(p,f){return[(p[0]+f[0])*.5,(p[1]+f[1])*.5]}d.center=c})(Ws||(Ws={}));var gn;(s=>{function n(l,u){return l[0]===u[0]&&l[1]===u[1]&&l[2]===u[2]}s.isEqual=n;function t(l,u){return[l[0]+u[0],l[1]+u[1],l[2]+u[2]]}s.add=t;function e(l,u){return[l[0]-u[0],l[1]-u[1],l[2]-u[2]]}s.sub=e;function r(l,u){return[l[0]/u[0],l[1]/u[1],l[2]/u[2]]}s.div=r;function o(l,u){return[l[0]*u[0],l[1]*u[1],l[2]*u[2]]}s.mul=o;function i(l,u){return Math.hypot(l[0]-u[0],l[1]-u[1],l[2]-u[2])}s.dist=i;function a(l,u,c){return[l[0]+(u[0]-l[0])*c,l[1]+(u[1]-l[1])*c,l[2]+(u[2]-l[2])*c]}s.lerp=a})(gn||(gn={}));var e0;(e=>{function n(r,o){return r[0]===o[0]&&r[1]===o[1]&&r[2]===o[2]&&r[3]===o[3]}e.isEqual=n;function t(r,o,i){return[r[0]+(o[0]-r[0])*i,r[1]+(o[1]-r[1])*i,r[2]+(o[2]-r[2])*i,r[3]+(o[3]-r[3])*i]}e.lerp=t})(e0||(e0={}));var xn;(o=>{o.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function t(i,a){for(let s=0;s<16;s++)if(i[s]!==a[s])return!1;return!0}o.isEqual=t;function e(i){return i??o.identity}o.simplify=e;function r(i,a){let s=a.slice(0);for(var l=0,u=a.length;l<u;l+=3){let c=i[3]*a[l]+i[7]*a[l+1]+i[11]*a[l+2]+i[15];s[l]=(i[0]*a[l]+i[4]*a[l+1]+i[8]*a[l+2]+i[12])/c,s[l+1]=(i[1]*a[l]+i[5]*a[l+1]+i[9]*a[l+2]+i[13])/c,s[l+2]=(i[2]*a[l]+i[6]*a[l+1]+i[10]*a[l+2]+i[14])/c}return s}o.applyMatrix4=r})(xn||(xn={}));var Mt;(d=>{function n(p){return typeof p=="object"&&typeof p.r=="number"&&typeof p.g=="number"&&typeof p.b=="number"}d.isRGB=n,d.white={r:1,g:1,b:1},d.red={r:1,g:0,b:0},d.black={r:0,g:0,b:0};function o(p){return{r:Math.round(p.r*255),g:Math.round(p.g*255),b:Math.round(p.b*255),a:1}}d.toRgb255a1=o;function i(p){return{r:p.r,g:p.g,b:p.b}}d.clone=i;function a(p){return p=Math.floor(p),{r:(p>>16&255)/255,g:(p>>8&255)/255,b:(p&255)/255}}d.fromHex=a;function s(p){return Math.round(p.r*255)*65536+Math.round(p.g*255)*256+Math.round(p.b*255)}d.toHex=s;function l(p,f){return p.r===f.r&&p.g===f.g&&p.b===f.b}d.equals=l;function u(p,f){return p.r.toFixed(2)===f.r.toFixed(2)&&p.g.toFixed(2)===f.g.toFixed(2)&&p.b.toFixed(2)===f.b.toFixed(2)}d.equalsFixed=u;function c(p,f,h){return{r:p.r+(f.r-p.r)*h,g:p.g+(f.g-p.g)*h,b:p.b+(f.b-p.b)*h}}d.lerp=c})(Mt||(Mt={}));var Ie;(u=>{u.white={...Mt.white,a:1},u.transparent={...Mt.white,a:0};function e(c){return{r:c[0],g:c[1],b:c[2],a:c[3]}}u.from0to1=e;function r(c,d){return{...Mt.fromHex(c),a:d}}u.fromHexAndA=r;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}}u.toRgb255a1=o;function i(c,d){return Mt.equals(c,d)&&c.a===d.a}u.equals=i;function a(c,d){return Mt.equalsFixed(c,d)&&c.a.toFixed(2)===d.a.toFixed(2)}u.equalsFixed=a;function s(c,d,p){return{r:c.r+(d.r-c.r)*p,g:c.g+(d.g-c.g)*p,b:c.b+(d.b-c.b)*p,a:c.a+(d.a-c.a)*p}}u.lerp=s;function l({r:c,g:d,b:p,a:f}=u.white){return`rgba(${c*255}, ${d*255}, ${p*255}, ${f})`}u.toStyle=l})(Ie||(Ie={}));var zc;(t=>t.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(zc||(zc={}));var t0;(t=>t.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(t0||(t0={}));var r0;(t=>t.defaultData={control1:[.5,0],control2:[.5,1]})(r0||(r0={}));var o0;(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]))(o0||(o0={}));function pp(n){return typeof n=="string"&&n.length===36?/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(n):!1}var Ur;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(r){return e.all.includes(r)}e.is=t})(Ur||(Ur={}));var Sn;(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 r(i){return i.type==="PerspectiveCamera"?i.perspective.zoom:i.orthographic.zoom}o.getZoom=r})(Sn||(Sn={}));var fo;(e=>{function n(r,o=.1){return{disabled:!1,type:"linear",hideBase:!1,count:3,radial:{radius:Math.max(r[0],r[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:[r[0]+r[0]*o,0,0]},grid:{count:[2,2,2],size:r.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 t(r,o){let i={...r};if(xC.forEach(a=>{Object.assign(i,{[a]:o[a]??r[a]})}),i.radial={...r.radial},o.radial){let a=r.radial,s=o.radial;bC.forEach(l=>{Object.assign(i.radial,{[l]:s[l]??a[l]})})}if(i.linear={...r.linear},o.linear){let a=r.linear,s=o.linear;vC.forEach(l=>{Object.assign(i.linear,{[l]:s[l]??a[l]})})}if(i.grid={...r.grid},o.grid){let a=r.grid,s=o.grid;SC.forEach(l=>{Object.assign(i.grid,{[l]:s[l]??a[l]})})}if(i.toObject={...r.toObject},o.toObject){let a=r.toObject,s=o.toObject;wC.forEach(l=>{Object.assign(i.toObject,{[l]:s[l]??a[l]})})}if(i.randomnessObject={...r.randomnessObject},o.randomnessObject){let a=r.randomnessObject,s=o.randomnessObject;AC.forEach(l=>{Object.assign(i.randomnessObject,{[l]:s[l]??a[l]})})}return i}e.merge=t})(fo||(fo={}));var Gc;(r=>{r.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let t=["radial","linear","grid","toObject","randomnessObject"];function e(o,i){let a=[];o.count!==void 0&&a.push({type:0,path:i,props:{count:o.count}});for(let s of t){let l=o[s];l&&Object.keys(l).length>0&&a.push({type:0,path:[...i,s],props:l})}return a}r.toOps=e})(Gc||(Gc={}));var xC=["count"],bC=["radius","start","end","position","scale","rotation"],vC=["position","scale","rotation"],SC=["count","size"],wC=["count","position","scale","rotation"],AC=["strength","scale","rotation","position","movement","seed","freqScale"];var Fc;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(r){return e.all.includes(r)}e.is=t})(Fc||(Fc={}));var kc;(e=>{function n(r){return t(r)}e.defaultData=n;function t(r){if(r==="PointLight")return{type:r,color:Ie.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(r==="SpotLight")return{type:r,color:Ie.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(r==="DirectionalLight")return{type:r,color:Ie.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(kc||(kc={}));var ua;(r=>(r.defaultShapeData={type:"PlaneEmitterShape",size:[100,100,100]},r.defaultCollisionData={colliderEntityId:null,collisionBounce:.75},r.defaultData={renderMaterial:{type:"particleMaterial",color:{r:1,g:.2,b:.545,a:1},color2:{r:.945,g:.714,b:.184,a:1},coloring:"gradient",ease:"linearFadeOut",easeSize:"linearFadeOut",transparent:!0,size:[40,40],texture:"pt_default_particle",spriteRotation:[0,0]},birthRatePerSec:50,gravity:1,noiseStrength:0,noiseScale:0,noiseSeed:1,noiseType:"curl",randomRotation:0,randomScale:.2,randomMass:.5,rootObjectType:"instancedMesh",life:1,direction:[0,0,0],directionMode:"axis",speed:10,shape:r.defaultShapeData,autoPlay:!0,emitTimeDelay:0,emitTimeCycle:"infinity",emitTimeLoopDelayStart:"end",emitTimeDuration:1,...r.defaultCollisionData}))(ua||(ua={}));var wn;(t=>t.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]})(wn||(wn={}));var fp;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(r,o){return r.castShadow===o.castShadow&&r.receiveShadow===o.receiveShadow}e.equals=t})(fp||(fp={}));var hp;(e=>{e.defaultData={flatShading:!1,wireframe:!1,side:0};function t(r,o){return r.flatShading===o.flatShading&&r.side===o.side&&r.wireframe===o.wireframe}e.equals=t})(hp||(hp={}));var jc;(t=>t.defaultData={...hp.defaultData,...fp.defaultData})(jc||(jc={}));var i0;(t=>{function n(e,r){let o=[];if("material"in e){let i=typeof e.material=="string"?r.materials[e.material]??r.lib.materials[e.material]?.asset:e.material;i&&o.push(i)}else if("materials"in e)for(let i of e.materials){let a=typeof i=="string"?r.materials[i]??r.lib.materials[i]?.asset:i;a&&o.push(a)}return o}t.getMaterialData=n})(i0||(i0={}));var da;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(da||(da={}));var a0;(t=>{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==="particle"||e==="transmission"||e==="matcap"||e==="displace"||e==="pattern"||e==="light"}t.is=n})(a0||(a0={}));function l0(n){return n.type!=="displace"}var s0;(t=>{function n(e){return e==="phong"||e==="toon"||e==="lambert"||e==="physical"}t.is=n})(s0||(s0={}));var c0=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],u0=["wrapping","image","video","name","minFilter"],Pt;(o=>{function n(i,a){let{texture:s,...l}=a;if(Object.assign(i,l),s){let u=i.texture;u&&Object.assign(u,s)}}o.patch=n;function t(i,a){return i==="light"&&a?e(a):r(i)}o.defaultData=t;function e(i){let a={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(i){case"phong":return{...a,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...a,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...a,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...a,category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0,occlusion:!0}}}function r(i){let a={alpha:1,mode:0,isMask:!1,visible:!0};switch(i){case"texture":return{...a,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],minFilter:1008},crop:!1};case"video":return{...a,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:da.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0],minFilter:1008},crop:!1};case"color":return{...a,type:"color",color:Mt.fromHex(St)};case"depth":return{...a,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{...a,type:"normal",cnormal:[1,1,1]};case"gradient":return{...a,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{...a,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...Mt.fromHex(6710886),a:1},colorB:{...Mt.fromHex(6710886),a:1},colorC:{...Mt.fromHex(16777215),a:1},colorD:{...Mt.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{...a,type:"fresnel",color:Ie.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{...a,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...a,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:Ie.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...a,type:"outline",outlineColor:Ie.fromHexAndA(0,1),contourColor:Ie.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{...a,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0],minFilter:1008}};case"transmission":return{...a,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{...a,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...Mt.fromHex(0),a:1},colorB:{...Mt.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}}}})(Pt||(Pt={}));var Wt;(u=>{function n(c){return!c.layers.some(p=>p.data.type==="texture"&&p.data.projection!==0||p.data.type==="depth"&&!p.data.isWorldSpace||p.data.type==="noise"||p.data.type==="displace")}u.isMergable=n;function t(c){let d="";return c.layers.forEach(p=>{Object.entries(p.data).forEach(([f,h])=>{d+=`${f}${h}`,Array.isArray(h)?h.forEach(m=>d+=`${m}`):typeof h=="object"?Object.values(h).forEach(m=>{typeof m=="number"?d+=`${m.toFixed(4)}`:d+=`${m}`}):d+=`${h}`})}),d}u.getHash=t;function e(){return{layers:new Se}}u.defaultEmptyData=e;function r(c="layer1",d="layer2"){return i("phong",c,d)}u.defaultData=r;function o(c,d){return{...c,name:d}}u.withName=o;function i(c,d="layer1",p="layer2"){let f=new Se;return f.push({fi:0,data:Pt.defaultData("light",c),id:d}),f.push({fi:1,data:Pt.defaultData("color"),id:p}),{layers:f}}u.defaultTwoLayerData=i;function a(c){let d=Pt.defaultData("texture");c&&Object.assign(d.texture,{image:c});let p=new Se;return p.push({fi:0,data:d,id:"layer1"}),p.push({fi:1,data:{...Pt.defaultData("transmission"),alpha:1},id:"layer2"}),p.push({fi:2,data:{...Pt.defaultData("light","lambert"),alpha:0},id:"layer3"}),{layers:p}}u.defaultUIObjectMaterial=a;function s(c,d="phong",p="layer1",f="layer2"){let h=Pt.defaultData("texture");Object.assign(h.texture,{image:c});let m=new Se;return m.push({fi:0,data:h,id:p}),m.push({fi:1,data:Pt.defaultData("light",d),id:f}),{layers:m}}u.defaultTwoLayerTextureData=s;function l(c,d="phong",p="layer1",f="layer2"){let h=Pt.defaultData("video");Object.assign(h.texture,{video:c});let m=new Se;return m.push({fi:0,data:h,id:p}),m.push({fi:1,data:Pt.defaultData("light",d),id:f}),{layers:m}}u.defaultTwoLayerVideoTextureData=l})(Wt||(Wt={}));var pa;(t=>{function n(){return{points:new Se,roundness:0,shapeHoles:[],isClosed:!1}}t.defaultData=n})(pa||(pa={}));var fa;(t=>{function n(){return{points:new Se,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}t.defaultData=n})(fa||(fa={}));var mp={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0};var Uc;(t=>{function n(e,r){let o={...e};return _C.forEach(i=>{Object.assign(o,{[i]:r[i]??e[i]})}),o}t.merge=n})(Uc||(Uc={}));var Hc={shape:mp,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},_C=["depth","offset","angle","twist","startScale","endScale"];var $s;(e=>{function n(r){return r==="PolygonGeometry"||r==="RectangleGeometry"||r==="StarGeometry"||r==="TriangleGeometry"||r==="EllipseGeometry"||r==="UIGeometry"}e.is2DParametricMesh=n;function t(r){return r==="PolygonGeometry"||r==="PolygonGeometry"||r==="RectangleGeometry"||r==="StarGeometry"||r==="TriangleGeometry"||r==="EllipseGeometry"||r==="PathGeometry"||r==="VectorGeometry"||r==="ConeGeometry"||r==="CubeGeometry"||r==="CylinderGeometry"||r==="DodecahedronGeometry"||r==="HelixGeometry"||r==="IcosahedronGeometry"||r==="LatheGeometry"||r==="PyramidGeometry"||r==="SphereGeometry"||r==="PlaneGeometry"||r==="BackdropGeometry"||r==="TorusGeometry"||r==="TorusKnotGeometry"||r==="BooleanGeometry"||r==="TextGeometry"}e.isParametricMesh=t})($s||($s={}));var qc;(t=>{function n(e,r){let o={...e};return Object.assign(o,r),o.type==="PathGeometry"&&"extrusion"in r&&r.extrusion&&(o.extrusion={...e.extrusion},Object.assign(o.extrusion,Uc.merge(o.extrusion,r.extrusion))),o}t.merge=n})(qc||(qc={}));var An;(t=>{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==="UIGeometry")return{type:e,frame:"",cornerRadius:[0,0,0,0],cornerType:0,width:1,height:1};if(e==="PathGeometry")return{type:e,width:1,height:1,depth:1,path:fa.defaultData(),extrusion:Hc};if(e==="VectorGeometry")return{width:1,height:1,type:e,subdivisions:12,shape:pa.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:{textValue:""},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:180};throw new Error("not implemented")}t.defaultData=n})(An||(An={}));var Wc;(t=>t.defaultData={enabled:!1,useBackgroundColor:!1,color:Mt.white,near:.1,far:2e3})(Wc||(Wc={}));var $c;(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}}})($c||($c={}));var yp;(t=>t.defaultData={softShadowQuality:"low"})(yp||(yp={}));var gp;(t=>t.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(gp||(gp={}));var xp;(t=>t.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(xp||(xp={}));var Ys;(t=>t.defaultData={usePhysics:!1,gravity:-10})(Ys||(Ys={}));var bp;(t=>t.defaultData={playCamera:bn,gameControlObject:null})(bp||(bp={}));var Yc;(t=>t.defaultData={backgroundColor:Ie.fromHexAndA(n0,1),postprocessing:$c.defaultData,fog:Wc.defaultData,globalPhysics:Ys.defaultData,ambient:gp.defaultData,ao:xp.defaultData,shadow:yp.defaultData,publish:bp.defaultData})(Yc||(Yc={}));var Xc;(t=>t.defaultData={colliderType:"box",size:[100,100,100],colliderHelperVisible:!0,forceType:"collider",forceRange:"global",forceIntensity:.5,forceDambing:.95})(Xc||(Xc={}));var d0;(e=>{function n(r){return r==="Component"||r==="Instance"}e.isComponentRelated=n;function t(r){return r==="Empty"||r==="Instance"}e.isEmptyOrComponent=t})(d0||(d0={}));var ha;(o=>{o.identity={...zc.identity,hiddenMatrix:xn.identity};function t(i){return{position:i.position,rotation:i.rotation,scale:i.scale,hiddenMatrix:i.hiddenMatrix}}o.fromObject=t;function e(i,a){return{position:a?.position||i.position,rotation:a?.rotation||i.rotation,scale:a?.scale||i.scale,hiddenMatrix:a?.hiddenMatrix||i.hiddenMatrix}}o.merge=e;function r(i,a){return Yl({position:gn.isEqual(i.position,a.position)?void 0:a.position,rotation:gn.isEqual(i.rotation,a.rotation)?void 0:a.rotation,scale:gn.isEqual(i.scale,a.scale)?null:a.scale,hiddenMatrix:xn.isEqual(i.hiddenMatrix,a.hiddenMatrix)?void 0:a.hiddenMatrix})}o.diff=r})(ha||(ha={}));var It;(t=>t.defaultData={states:new Se,events:new Se,visible:!0,raycastLock:!1,physics:wn.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...ha.identity,cloner:null})(It||(It={}));var Qc;(t=>t.defaultData={type:"Empty",...It.defaultData})(Qc||(Qc={}));var p0;(t=>t.defaultData={type:"ParticleCollider",...Xc.defaultData,...It.defaultData})(p0||(p0={}));var f0;(t=>t.defaultData={type:"Component",...It.defaultData})(f0||(f0={}));var h0;(t=>t.defaultData={type:"Particle",...It.defaultData,...ua.defaultData})(h0||(h0={}));var ri;(t=>t.defaultData={type:"Mesh",...It.defaultData,...jc.defaultData})(ri||(ri={}));var oi;(t=>t.defaultData={...It.defaultData,...ha.identity,position:[0,0,Sn.DefaultTargetOffset],...Sn.defaultData})(oi||(oi={}));var Kc;(e=>{function n(r){return{...It.defaultData,...kc.defaultData(r)}}e.defaultData=n,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(Kc||(Kc={}));var ma;(e=>{function n(r,o,i=0){for(;i<o.length;){let a=r?r[o[i]]:void 0;if(o.length===i+1)return a;if(a)r=a.descendants,i+=1;else return}}e.resolveWithDes=n;function t(r,o,i=0){let a=n(r,o,i);if(a){let s=Object.keys(a);if(s.length===1&&s[0]==="descendants")return}return a}e.resolve=t})(ma||(ma={}));var ho;(i=>{i.rootOverrideProps=["physics","events"],i.compositeNonOptionalOverrideProps=["geometry"],i.compositeEntireOverrideOverrideProps=["material"];function r(a,s){return{...It.defaultData,...s,component:a,overrides:new et,physics:void 0,events:void 0,type:"Instance"}}i.ofComponent=r;function o(a){let s=ha.fromObject(a.data);return r(a.id,s)}i.fromComponentData=o})(ho||(ho={}));var Go;(e=>{e.defaultData={type:"Page",...It.defaultData,physics:{...wn.defaultData,fusedBody:!1},...Yc.defaultData,camera:oi.defaultData};function t(r){return r.uiScene!==void 0}e.isUIPage=t})(Go||(Go={}));var Zc;(i=>(i.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:xn.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:wn.defaultData,states:new Se,events:new Se,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...Sn.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,...ri.defaultData,geometry:An.defaultData("RectangleGeometry"),material:Wt.defaultTwoLayerData("phong","layer1","layer2")},i.defaultBooleanObject={name:"Boolean",...It.defaultData,...ri.defaultData,geometry:An.defaultData("BooleanGeometry"),material:Wt.defaultTwoLayerData("phong","layer1","layer2")},i.defaultTextObject={name:"Text",...It.defaultData,...ri.defaultData,geometry:An.defaultData("TextGeometry"),material:Wt.defaultTwoLayerData("phong","layer1","layer2")}))(Zc||(Zc={}));var ni;(o=>{function n(i,a){let s={name:a};return i.type==="Mesh"?(s.geometry={},"material"in i&&(s.material={layers:new et}),"materials"in i&&(s.materials=i.materials.map(l=>({layers:new et})))):Ur.is(i.type)&&(s.perspective={},s.orthographic={}),s}o.newEmpty=n;function t(i,a){if(a===void 0)return i;let s={...i};return"material"in s&&"material"in a&&a.material&&(s.material=fn(s.material,l=>{if(typeof l!="string")for(let[u,c]of Object.entries(a.material.layers)){let d=l.layers.data(u);d&&Pt.patch(d,c)}}).data),s.materials&&a.materials&&(s.materials=fn(s.materials,l=>{for(let u=0;u<s.materials.length;u++){let c=a.materials[u];if(typeof c!="string")for(let[d,p]of Object.entries(c.layers)){let f=l[u]?.layers?.data(d);f&&Pt.patch(f,p)}}}).data),s}function e(i,a){let s,l=[],u={orthographic:0,perspective:0,geometry:0};function c(d,p){for(let[f,h]of Object.entries(p.layers)){let{texture:m,...y}=h;if(m!==void 0&&Object.keys(m).length>0){let g={path:[...d,"layers",f,"texture"],props:m,type:0};l.push(g)}if(Object.keys(y).length>0){let g={path:[...d,"layers",f],props:y,type:0};l.push(g)}}}for(let[d,p]of Object.entries(a))if(d!=="name")if(d==="cloner")l.push(...Gc.toOps(p,["cloner"]));else if(d==="pathSnapping")l.push({path:[d],props:{slide:p.slide,offset:p.offset},type:0});else if(d==="material")c(["material"],p);else if(d==="materials")for(let[f,h]of Object.entries(p))c(["materials",f],h);else if(u[d]===0){if(d==="geometry"&&p.extrusion!==void 0){let f={path:[d,"extrusion"],props:p.extrusion,type:0};l.push(f),p={...p},delete p.extrusion}if(Object.keys(p).length>0){let f={path:[d],props:p,type:0};l.push(f)}}else s===void 0&&(s={path:[],props:{},type:0},l.push(s)),s.props[d]=p;return l}o.toOps=e;function r(i,a){if(a===void 0)return i;let s={...i};if(Object.assign(s,ha.merge(s,a)),Object.assign(s,{pathSnapping:Object.assign({},s.pathSnapping,{slide:a.pathSnapping?.slide??s.pathSnapping?.slide??0,offset:a.pathSnapping?.offset??s.pathSnapping?.offset??0})}),Ur.is(i.type)){s.orthographic={...s.orthographic},s.perspective={...s.perspective};let l=a;l.orthographic?.zoom!==void 0&&(s.orthographic.zoom=l.orthographic.zoom),l.perspective?.zoom!==void 0&&(s.perspective.zoom=l.perspective.zoom),l.isUpVectorFlipped!==void 0&&(s.isUpVectorFlipped=l.isUpVectorFlipped),l.targetOffset!==void 0&&(s.targetOffset=l.targetOffset)}else if(i.type==="Mesh")"geometry"in a&&Object.assign(s,{geometry:qc.merge(s.geometry,a.geometry)}),(a.material||a.materials)&&(s=t(s,a)),s.cloner&&"cloner"in a&&Object.assign(s,{cloner:fo.merge(s.cloner,a.cloner)});else if(i.type==="Empty")s.cloner&&"cloner"in a&&Object.assign(s,{cloner:fo.merge(s.cloner,a.cloner)});else if(Fc.is(i.type)){let l=a;l.intensity!==void 0&&(s.intensity=l.intensity),l.color!==void 0&&(typeof l.color=="string"?s.color=l.color:s.color=Mt.clone(l.color))}return s}o.patch=r})(ni||(ni={}));var ya;(t=>t.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,hoverRotateDamping:.125,isTouchZoom:!0,orbitTouches:2,panTouches:3,resetHoverEffectOnPointerLeave:!0})(ya||(ya={}));var Hr;(t=>t.defaultData={orbitControls:ya.defaultData,playPage:vn,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((e,r)=>{let o=0,i=0;return r<5?i=-30:r<10&&(i=30),r===0||r===10||r===5?o=30:(r===4||r===11||r===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 vp;(t=>t.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(vp||(vp={}));var Sp;(t=>t.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(Sp||(Sp={}));var Fo;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...vp.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:Sp.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(Fo||(Fo={}));var m0;(e=>{function n(r){return r.find(o=>o.data.type==="Page"&&o.data.globalPhysics.usePhysics)!==void 0}e.physicsEnabled=n;function t(r,o,i){r.scene.objects.traverseFrom(o,(a,s)=>{if(s.type==="Instance"){let l=ga.getComponentData(r,s.component)?.data;l&&i(a,s,l.events)}else i(a,s,s.events)})}e.traverseModuleInstances=t})(m0||(m0={}));var ko;(l=>{l.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222";function t(u={withLight:!0,withSquare:!0}){let c=[],d=Zc.defaultMeshObject;u.withLight===!0&&c.push({fi:-1,data:Kc.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]}),u.withSquare===!0&&c.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:d,children:[]});let p=new Je;return p.push({fi:1,id:vn,data:{...Go.defaultData,name:"Scene 1"},children:c}),p}l.defaultData={objects:t(),publish:Hr.defaultData,styles:Fo.defaultData()},l.emptyDataWithoutPage=function(){return{objects:new Je,publish:Hr.defaultData,styles:Fo.defaultData()}},l.emptyDataWithPage=function(u){return{objects:t(u),publish:Hr.defaultData,styles:Fo.defaultData()}},l.emptyData=function(){return{objects:new Je,publish:{...Hr.defaultData},styles:Fo.defaultData()}};function a(u){return{...l.defaultData,objects:rr(u,Je.prototype)}}l.withObjs=a;function s(u,c){return a([{id:u,data:c,children:[],fi:0}])}l.withObj=s})(ko||(ko={}));var xa;(t=>t.defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}})(xa||(xa={}));var ba;(t=>t.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(ba||(ba={}));var Jc;(i=>{function n(a){return a.textValue!==void 0}i.isTextValue=n;function t(a){return typeof a=="number"}i.isNumber=t;function e(a){return typeof a=="boolean"}i.isBoolean=e;function r(a){return n(a)?"string":e(a)?"boolean":"number"}i.typeOfVariable=r;function o(a){return i.isTextValue(a)?Array.isArray(a.textValue)?a.textValue.map(s=>s.toString().padStart(a.padding??2,"0")).join(a.deliminator??":")+(a.suffix!==void 0?" "+a.suffix:""):a.textValue.toString():i.isBoolean(a)?a?"True":"False":i.isNumber(a)?parseFloat(a.toFixed(3)).toString():a.toString()}i.getDisplayedValue=o})(Jc||(Jc={}));var wp;(t=>t.all=["images","videos","colors","audios","particles","fonts","materials","variables"])(wp||(wp={}));var y0;(t=>t.all=[...wp.all,"components"])(y0||(y0={}));var g0;(t=>{function n(){return{images:new xe,videos:new xe,colors:new xe,audios:new xe,particles:new xe,fonts:new xe,materials:new xe,components:new xe,variables:new xe}}t.defaultData=n})(g0||(g0={}));var jo;(t=>{function n(){return{images:new xe,videos:new xe,colors:new xe,audios:new xe,particles:new xe,fonts:new xe,materials:new xe,components:new xe,variables:new xe}}t.defaultData=n})(jo||(jo={}));var Nr;(i=>{function n(){let a={};return a["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},rr(a,xe.prototype)}i.defaultColors=n;function t(a){let s={};return a?.withAITexture&&(s["a1b10010-844c-a8a3-11ec-0242ac2011ec"]={...ba.emptyImage,name:"AI generated image"}),rr(s,xe.prototype)}i.defaultImages=t;function e(){return{catelogs:new xe,materials:new xe,images:new xe,videos:new xe,colors:new xe,audios:new xe,particles:new xe,fonts:new xe,variables:new Se,lib:jo.defaultData()}}i.emptyData=e;function r(a){switch(a){case"number":return{value:0,name:"Number"};case"boolean":return{value:!1,name:"Boolean"};case"string":return{value:{textValue:"String value"},name:"String"};case"time":let s=[0,0,0];return{name:"Time",value:{textValue:s,deliminator:":",padding:2,suffix:"AM"},dynamicVariableType:"time",format:"HH:mm:ss",format12h24h:"12ampm",timeZone:null,hasEnd:!1,endValue:{textValue:s,deliminator:":",padding:2,suffix:"AM"},autoStart:!0,repeat:!1};case"counter":return{name:"Counter",value:0,dynamicVariableType:"counter",updateInterval:1e3,increment:1,autoStart:!0,hasEnd:!0,endValue:60,repeat:!0,randomStart:!1,range:[0,100],decimals:0};case"random":return{name:"Random",value:0,dynamicVariableType:"random",updateInterval:1e3,increment:1,autoStart:!0,isStatic:!1,hasEnd:!0,endValue:60,repeat:!0,min:0,max:100,decimals:0};default:console.error("Unknown variable type",a)}}i.defaultVariables=r;function o(a,s){if(s.format==="HH:mm:ss"){let l=Math.floor(a/3600),u=Math.floor((a-l*3600)/60),c=Math.round(a-l*3600-u*60);return{textValue:[l,u,c]}}else if(s.format==="mm:ss"){let l=Math.floor(a/60),u=Math.round(a-l*60);return{textValue:[l,u]}}else return s.format==="number"?a=Math.round(a):a=Math.round(a*1e3)/1e3,a}i.getFormattedTimerTime=o})(Nr||(Nr={}));import{MathUtils as ru}from"three";var eu;(t=>t.list=["idle","move","jump","run"])(eu||(eu={}));var tu;(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 Se,move:new Se,jump:new Se,run:new Se},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:Ie.fromHexAndA(3728051,1)}}))(tu||(tu={}));function x0(n){n.layers.forEach(t=>{if(t.type==="depth"&&t.colorA!==void 0){let e=t.colorA,r=t.colorB,o=[[e.r,e.g,e.b,e.a],[r.r,r.g,r.b,r.a]],i=[0,1];for(let s=2;s<10;s++)o.push(o[1]),i.push(1);let a={...jr(ut(t),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,t.near),far:Math.max(0,t.far),colors:o,steps:i,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(t,a)}else if(t.type==="depth"&&t.gradientType===1&&(t.near<0||t.far<0)){let e={...ut(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,e)}})}function Uo(n,t){Object.values(n.shared.materials).forEach(e=>t(e))}function Ho(n,t){n.scene.objects.traverse((e,r)=>{"materials"in r?r.materials.forEach((o,i)=>{o===void 0&&(r.materials[i]=Wt.defaultData(),o=r.materials[i]),typeof o!="string"&&t(o)}):"material"in r?typeof r.material!="string"&&(r.material===void 0&&(r.material=Wt.defaultData()),t(r.material)):r.type==="Mesh"&&(r.material===void 0&&(r.material=Wt.defaultData()),t(r.material)),"overrides"in r&&Object.values(r.overrides).forEach(o=>{o.material&&typeof o.material!="string"&&Object.getPrototypeOf(o.material)!==et.prototype&&t(o.material)})})}function PC(n){Object.assign(n.scene.publish,{orbitControls:{...ya.defaultData,...ut(n.scene.publish.orbitControls)}})}function OC(n){Object.assign(n.scene.publish.settings,{video:{...Hr.defaultData.settings.video,...ut(n.scene.publish.settings.video)}})}function CC(n){function t(e){if(e.layers){for(let r of Object.values(e.layers))if(r){for(let[o,i]of Object.entries(r))if((c0.includes(o)||typeof i=="boolean")&&delete r[o],o==="texture")for(let[a,s]of Object.entries(i))(u0.includes(a)||typeof s=="boolean")&&delete i[a]}}}n.scene.objects.traverse((e,r)=>{r.states.forEach(o=>{let i=o;i.material?t(i.material):i.materials&&i.materials.forEach(a=>{t(a)})})})}function TC(n){n.scene.publish.withBackground=!0}function MC(n){n.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function IC(n){n.scene.objects.traverse((t,e)=>{let r=e.cloner;r&&(r.radial.scale=r.radial.scale.map(o=>o+1),r.linear.scale=r.linear.scale.map(o=>o+1))})}function NC(n){n.scene.objects.traverse((t,e)=>{let r=e.geometry;r&&(r.type==="DodecahedronGeometry"||r.type==="IcosahedronGeometry")&&(r.detail=Math.round(r.detail))})}function DC(n){n.scene.objects.traverse((t,e)=>{let r=n.scene.objects.unproxy().parent(t);if(r){let o=ut(n.scene.objects.data(r));o&&o.type==="Mesh"&&o.geometry.type==="BooleanGeometry"&&e.type==="Mesh"&&(e.visible=ut(e).booleanExclude!==!0)}})}function EC(n){n.scene.objects.traverse((t,e)=>{if(e.type==="Mesh"){let r=e;e.geometry.type==="NonParametricGeometry"?r.material!==void 0&&delete r.material:r.materials!==void 0&&delete r.materials}})}function BC(n){function t(r){Object.setPrototypeOf(r,et.prototype),r.texture&&Object.setPrototypeOf(r.texture,et.prototype)}function e(r){Object.setPrototypeOf(r,et.prototype);for(let o in r)t(r[o])}n.scene.objects.traverse((r,o)=>{o.states.forEach(i=>{let a=i;if(a.material){let s=ut(a.material).layers;e(s),a.material.layers=s}if(a.materials)for(let s=0;s<a.materials.length;s++){let l=a.materials[s],u=ut(l).layers;e(u),l.layers=u}})})}function b0(n){n.layers===void 0&&Object.assign(n,Wt.defaultTwoLayerData("lambert"))}function Ap(n){!n.layers||n.layers.forEach(t=>{if(t.type==="depth"&&t.colors.length===10){let e=[...t.colors];e.push(t.colors[9]);let r=[...t.steps];r.push(t.steps[9]);let o={...ut(t),colors:e,steps:r};Object.assign(t,o)}})}function LC(n){n.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&(e.geometry.type==="BooleanGeometry"||e.geometry.type==="SubdivGeometry")&&(e.geometry.phongAngle=35)})}function v0(n){n.scene.objects.traverse((t,e)=>{"materials"in e?e.materials.forEach(r=>{typeof r!="string"&&Ap(r)}):"material"in e&&typeof e.material!="string"&&Ap(e.material)}),Object.values(n.shared.materials).forEach(t=>Ap(t))}function RC(n){n.scene.environment.ambientLight.softShadows=!1,n.scene.environment.ambientLight.softShadowQuality="low",n.scene.objects.traverse((t,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 VC(n){n.shared.audios=rr({},xe.prototype)}function zC(n){n.shared.videos=rr({},xe.prototype)}function GC(n){let t=n.shared.materials;Object.entries(t).forEach(([e,r])=>{if(!r.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(t,{[e]:o})}})}function FC(n){Object.entries(ut(n.shared.images)).filter(r=>r[1].asset===!1).map(r=>r[0]).forEach(r=>{delete n.shared.images[r]}),Object.entries(ut(n.shared.audios)).filter(r=>r[1].asset===!1).map(r=>r[0]).forEach(r=>{delete n.shared.audios[r]})}function kC(n){n.scene.publish.settings.web.preload=!1}function S0(n){n.layers&&n.layers.forEach(t=>{t.type==="depth"&&t.num!==void 0&&(t.colors=t.colors.slice(0,t.num),t.steps=t.steps.slice(0,t.num),delete t.num)})}function w0(n){n.layers&&n.layers.forEach(t=>{l0(t)&&t.isMask===void 0&&(t.isMask=!1),(t.type==="texture"||t.type==="video")&&t.blending===void 0&&(t.blending=0),(t.type==="noise"||t.type==="displace"&&t.displacementType==="noise")&&(t.voronoiStyle===void 0&&(t.voronoiStyle=0),t.highCut===void 0&&(t.highCut=1),t.lowCut===void 0&&(t.lowCut=0),t.smoothness===void 0&&(t.smoothness=.3),t.seed===void 0&&(t.seed=0),t.quality===void 0&&(t.quality=1))})}function jC(n){n.shared.fonts=rr({},xe.prototype)}function UC(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 HC(n){let t=[];n.scene.objects.traverse((e,r)=>{let o=r;if(o.type==="TextFrame"){let i=Wt.defaultTwoLayerData("phong"),a=typeof o.color=="string"?n.shared.colors[o.color]:o.color;i.layers[1].data.color={r:a.r,g:a.g,b:a.b},i.layers[1].data.alpha=o.alpha;let s=UC(o.font);n.shared.fonts[s]===void 0&&(n.shared.fonts[s]={name:s});let l={name:o.name,...It.defaultData,...ri.defaultData,flatShading:!1,wireframe:!1,geometry:{...An.defaultData("TextGeometry"),width:o.width,height:o.height,font:s,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},u=ut(n.scene.objects).parent(e);n.scene.objects.insertAfter(u??null,e,[{id:e+"new",data:l,children:[]}]),t.push(e)}}),t.forEach(e=>{n.scene.objects.delete(e)})}function qC(n){let t={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,r)=>{r.events.forEach(o=>{if(!!t[Number(o.type)])if(Object.assign(o,{type:t[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 Se,move:new Se,jump:new Se}});else{let i=new Se;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:ru.generateUUID(),data:{type:"Link",url:o.url,delay:0}}),"targets"in o&&(o.targets.forEach((a,s,l)=>{let u={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},c={easing:a.easing,duration:a.duration};a.easing===6?Object.assign(c,jr(a,"mass","stiffness","damping","velocity")):a.easing===5&&Object.assign(c,{control1:{...a.control1},control2:{...a.control2}});let d={repeat:a.repeat?-1:0,delay:a.delay,delayDirection:a.delayDirection,direction:a.cycle&&a.rewind?"pingpong-rewind":a.cycle?"pingpong":"normal"},p={state:a.state,...d,...c},f={allowSlerp:!0,type:"Transition",object:a.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new Se({fi:0,id:ru.generateUUID(),data:u},{fi:1,id:ru.generateUUID(),data:p})};i.push({fi:l,id:s,data:f})}),delete o.targets)}})})}function WC(n){n.scene.objects.traverse((t,e)=>{function r(o,i){let a=new Se,s=[];if(e.events.forEach((l,u,c)=>{if(l.type==="Audio"&&l.trigger===i){let d;s.push(u),l.interaction==="play"?d={...jr(l,"interaction","audio","delay","volume","loop"),triggerAfter:"after"in l?l.after:void 0,toggle:"after"in l?l.toggle:void 0,type:"Audio"}:(l.interaction==="pause"||l.interaction==="stop")&&(d={...jr(l,"interaction","delay","object","playAudio"),type:"Audio"}),d&&a.push({fi:c,id:u,data:d})}}),s.forEach(l=>e.events.delete(l)),a.length){let l=e.events.find(u=>u.type===o)?.data;l?"actions"in l&&l.actions.insertBefore(null,a):e.events.insertBefore(null,[{id:ru.generateUUID(),data:{type:o,actions:a}}])}}r("Start","start"),r("MouseDown","mouseDown"),r("MouseUp","mouseUp"),r("KeyDown","keyDown"),r("KeyUp","keyUp")})}function A0(n){let t=n.layers.find(e=>e.type==="light")?.data;if(t?.category==="basic"){let e=Pt.defaultData("light","phong"),r=t;Object.assign(r,e),r.visible=!1}}function _0(n){Uo(n,A0),Ho(n,A0)}function $C(n){n.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(e.geometry.scaleBaked||(e.geometry.scaleBaked=[1,1,1]))})}function YC(n){n.scene.objects.traverse((t,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 XC(n){n.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="NonParametricGeometry"&&!("material"in e)&&!("materials"in e)&&(e.material=Wt.defaultTwoLayerData("phong"))})}function QC(n){n.scene.publish.orbitControls.autoZoom===void 0&&(n.scene.publish.orbitControls.autoZoom=!1),n.scene.objects.traverse((t,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 KC(n){n.scene.objects.traverse((t,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 ZC(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 JC(n){let{video:t}=n.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function eT(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.resetYPosition=Math.abs(r.resetYPosition-e.position[1]))})})}function tT(n){let t=n.scene.environment.usePhysics;n.scene.objects.traverse((e,r)=>{t&&r.physics===null?r.collision=!1:r.collision="visibility"})}function rT(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.navmesh=tu.defaultDataThirdPerson.navmesh)})})}function oT(n){n.scene.styles||(n.scene.styles=Fo.defaultData())}function P0(n){n.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function nT(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,P0),Uo(n,P0)}function iT(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&Object.assign(r.gameActions,{run:new Se})})})}function aT(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.keyAssignments=[...r.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function O0(n){n.layers&&n.layers.forEach(t=>{t.type==="light"&&t.bumpMapIntensity===void 0&&(t.bumpMapIntensity=5)})}function C0(n,t){if(t<1&&(Ho(n,x0),Uo(n,x0),n.schema=1),t<2&&(PC(n),n.schema=2),t<3&&(CC(n),n.schema=3),t<4&&(TC(n),n.schema=4),t<5&&(MC(n),n.schema=5),t<6&&(IC(n),n.schema=6),t<7&&(NC(n),n.schema=7),t<8&&(n.schema=8),t<9&&(v0(n),n.schema=9),t<10&&(LC(n),n.schema=10),t<11&&(RC(n),n.schema=11),t<12&&(v0(n),n.schema=12),t<13&&(VC(n),n.schema=13),t<14&&(GC(n),n.schema=14),t<15&&(FC(n),n.schema=15),t<16&&(kC(n),n.schema=16),t<17&&(Ho(n,S0),Uo(n,S0),n.schema=17),t<18&&(Ho(n,b0),Uo(n,b0),n.schema=18),t<19&&(OC(n),n.schema=19),t<20&&(jC(n),HC(n),n.schema=20),t<21&&(qC(n),WC(n),n.schema=21),t<22&&(_0(n),n.schema=22),t<23&&($C(n),n.schema=23),t<24&&(YC(n),n.schema=24),(t<25||n.shared.videos===void 0)&&(zC(n),t<25&&(n.schema=25)),t<26&&(DC(n),n.schema=26),t<27&&(EC(n),n.schema=27),t<28&&(_0(n),n.schema=28),t<29&&(BC(n),n.schema=29),t<30&&(XC(n),n.schema=30),t<31&&(QC(n),n.schema=31),t<33&&(KC(n),n.schema=33),t<34&&(ZC(n),n.schema=34),t<35&&(JC(n),n.schema=35),t<36&&(eT(n),n.schema=36),t<37&&(tT(n),n.schema=37),t<38&&(Ho(n,w0),Uo(n,w0),n.schema=38),t<39&&(rT(n),n.schema=39),t<40&&(oT(n),n.schema=40),t<41&&(nT(n),n.schema=41),t<42&&(iT(n),n.schema=42),t<43&&(aT(n),n.schema=43),t<99){Ho(n,O0),Uo(n,O0),n.scene.publish.playCamera===null&&(n.scene.publish.playCamera=bn);let e=ut(n.scene.objects),r=n.scene.objects;n.scene.publish.playPage=vn,r.insertBefore(null,null,[{id:vn,data:{...Go.defaultData,backgroundColor:n.scene.backgroundColor,fog:n.scene.fog,postprocessing:n.scene.postprocessing,ao:jr(n.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:n.scene.publish.playCamera,gameControlObject:n.scene.publish.gameControlObject},shadow:jr(n.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...Ys.defaultData,...jr(n.scene.environment,"usePhysics","gravity")},camera:ut(n.scene.ownerCamera)??Go.defaultData.camera,name:"Scene"},children:[]}]);for(let a of e)a.id!==ko.TRASH_CAN_ID&&r.move(vn,a.fi,a.id);let o=0,i=0;n.shared.penumbraSize&&n.scene.objects.traverse((a,s)=>{s.type==="DirectionalLight"?(s.penumbraSize=n.shared.penumbraSize[Math.min(o,2)],o+=1):s.type==="SpotLight"&&(s.penumbraSize=n.shared.penumbraSize[3+Math.min(i,1)],i+=1),(s.physics===void 0||s.physics===null)&&s.type!=="Instance"&&(s.physics={},Object.assign(s.physics,wn.defaultData)),s.physics!==void 0&&s.physics!==null&&(s.physics.enabled=s.collision??"visibility",delete s.collision)}),n.schema=99}}function T0(n){n.layers&&n.layers.forEach(t=>{t.type==="light"&&t.alphaOverride===void 0&&(t.alphaOverride=1)})}function sT(n){n.scene.objects.traverse((t,e)=>{let r=e.geometry;r&&r.type==="PathGeometry"&&(r.extrusion.capType="flat",r.extrusion.bevel=50,r.extrusion.bevelSides=6,r.extrusion.shape.type==="Custom"&&(r.extrusion.shape.shapeQuality="low"))})}function lT(n){Array.isArray(ut(n.events))&&n.events?.forEach(t=>{"disabled"in t||(t.disabled=!1),(t.type==="MouseDown"||t.type==="MouseUp"||t.type==="MousePress")&&(t.mode=t.mode||"Object")})}var va=180/Math.PI;function M0(n){n.rotation=n.rotation.slice(0,3).map(t=>t*va)}function I0(n){M0(n),n.type==="Page"&&M0(n.camera),n.states?.forEach(e=>{e.rotation===void 0||e.rotation===null||(e.rotation=e.rotation.slice(0,3).map(r=>r*va))});let t=n.geometry;t&&t.type==="SphereGeometry"&&(t.thetaLength=(t.thetaLength??180)*va),t&&t.type==="TorusGeometry"&&(t.arc=t.arc*va),t&&t.type==="PathGeometry"&&(t.extrusion.angle*=va,t.extrusion.twist*=va),n.type==="Mesh"&&n.geometry.type==="TextGeometry"&&(n.geometry.text={textValue:n.geometry.text}),Array.isArray(ut(n.events))&&n.events?.forEach(e=>{(e.type==="MouseDown"||e.type==="MouseUp"||e.type==="MousePress"||e.type==="KeyDown"||e.type==="KeyUp"||e.type==="KeyPress"||e.type==="Collision"||e.type==="Trigger")&&(e.runMode=e.toggle?"Toggle":"Repeat")})}function cT(n){n.shared.variables=rr({},xe.prototype)}function uT(n){let t=ut(n.shared.variables);n.shared.variables=rr(Object.entries(t??{}).map(([e,r],o)=>({fi:o,id:e,data:r})),Se.prototype)}var mo=111;function N0(n,t){t(n.data);for(let e of n.children)N0(e,t)}function dT(n){let t=n.schema??104;t!==mo&&t<105&&(N0(n.asset,I0),n.schema=105)}function pT(n){n.shared.particles=rr({},xe.prototype),n.shared.lib&&(n.shared.lib.particles=jo.defaultData().particles)}function fT(n){n.scene.objects.traverse((t,e)=>{e.type==="Particle"&&typeof e.renderMaterial.size=="number"&&Object.assign(e.renderMaterial,{size:[e.renderMaterial.size,e.renderMaterial.size]})})}function ou(n){let t=n.schema??0;if(t!==mo){console.warn("updating from ",t,"to ",mo),C0(n,t),t<100&&(n.scene.publish.joystickSizeAndXYOffset===void 0&&(n.scene.publish.joystickSizeAndXYOffset=Hr.defaultData.joystickSizeAndXYOffset),n.schema=100),t<101&&(Ho(n,T0),Uo(n,T0),n.schema=101),t<102&&(sT(n),n.schema=102),t<104&&(n.shared.catelogs=new xe,n.shared.lib=jo.defaultData(),n.schema=104),t<105&&(cT(n),n.scene.objects.traverse((e,r)=>{I0(r)}),n.schema=105);for(let e of Object.values(n.shared.lib.components))dT(e);t<106&&(uT(n),n.schema=106),t<107&&(n.shared.lib.variables=jo.defaultData().variables,n.schema=107),t<109&&(pT(n),n.schema=109),t<110&&(fT(n),n.schema=110),t<111&&(n.scene.objects.traverse((e,r)=>{lT(r)}),n.schema=111)}}var ga;(l=>{l.defaultData={schema:mo,scene:ko.defaultData,frames:new xe().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",xa.defaultData),shared:{...Nr.emptyData(),colors:Nr.defaultColors()}},l.emptyDataForImports=function(u){let c=ko.emptyDataWithPage(u);return{schema:mo,scene:c,frames:new xe().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",xa.defaultData),shared:{...Nr.emptyData(),colors:Nr.defaultColors(),images:Nr.defaultImages(u)}}},l.emptyData=function(){return{schema:mo,scene:ko.emptyDataWithPage(),frames:new xe().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",xa.defaultData),shared:Nr.emptyData()}},l.clipboard2dData=function(){return{schema:mo,scene:ko.emptyData(),frames:new xe,shared:Nr.emptyData()}},l.collabHelper={...ks,updateSchema(u){return(u.schema??0)<mo?fn(u,ou):(u.schema??0)-mo}};function i(u){let c=l.collabHelper.updateSchema(u);return typeof c=="number"?c===0?u:null:c.data}l.updateSchemaDirectly=i;function a(u){return{...u,shared:{...u.shared,lib:jo.defaultData()}}}l.withoutLib=a;function s(u,c){let d=u.scene.objects.get(c);if(d&&d.data.type==="Component")return d;{let p=u.shared.lib.components[c];if(p)return p.asset}}l.getComponentData=s})(ga||(ga={}));var D0;(t=>{function n(e){return!0}t.is=n})(D0||(D0={}));var nu;(r=>{r.defaultData={position:[0,0],scale:[1,1],rotation:0};function t(o,i){return{position:i?.position??o.position,rotation:i?.rotation??o.rotation,scale:i?.scale??o.scale}}r.merge=t;function e(o,i){return Yl({position:Ws.isEqual(o.position,i.position)?void 0:i.position,rotation:o.rotation===i.rotation?void 0:i.rotation,scale:Ws.isEqual(o.scale,i.scale)?void 0:i.scale})}r.diff=e})(nu||(nu={}));var _p;(t=>t.defaultData={horizontalConstraint:0,verticalConstraint:0})(_p||(_p={}));var iu;(t=>t.defaultData={opacity:1,fill:{color:Ie.white,enabled:!0},stroke:{color:Ie.from0to1([0,0,0,1]),thickness:1,enabled:!1,mode:"inside"},layerBlur:{radius:2,enabled:!1},backgroundBlur:{radius:2,enabled:!1},dropShadow:{offset:[10,10],blurRadius:10,color:Ie.from0to1([0,0,0,1]),enabled:!1,spread:0},innerShadow:{offset:[10,10],blurRadius:10,color:Ie.from0to1([0,0,0,1]),enabled:!1,spread:0}})(iu||(iu={}));var ii;(i=>{function n(a,s){return{name:s}}i.newEmpty=n;function t(a,s){if(s===void 0)return a;let l={...a},u=["width","height","cornerRadius"];for(let c of u)c in l&&c in s&&s[c]!==void 0&&Object.assign(l,{[c]:s[c]});return l}function e(a,s){if(s===void 0)return a;let l={...a};return"fill"in l&&"fill"in s&&s.fill!==void 0&&Object.assign(l,{fill:{...l.fill,...s.fill}}),"stroke"in l&&"stroke"in s&&s.stroke!==void 0&&Object.assign(l,{stroke:{...l.stroke,...s.stroke}}),"layerBlur"in l&&"layerBlur"in s&&s.layerBlur!==void 0&&Object.assign(l,{layerBlur:{...l.layerBlur,...s.layerBlur}}),"backgroundBlur"in l&&"backgroundBlur"in s&&s.backgroundBlur!==void 0&&Object.assign(l,{backgroundBlur:{...l.backgroundBlur,...s.backgroundBlur}}),"dropShadow"in l&&"dropShadow"in s&&s.dropShadow!==void 0&&Object.assign(l,{dropShadow:{...l.dropShadow,...s.dropShadow}}),"innerShadow"in l&&"innerShadow"in s&&s.innerShadow!==void 0&&Object.assign(l,{innerShadow:{...l.innerShadow,...s.innerShadow}}),l}function r(a,s){if(s===void 0)return a;let l={...a};return Object.assign(l,nu.merge(l,s)),l=t(l,s),l=e(l,s),l}i.patch=r;function o(a,s){let l,u=[];for(let[c,d]of Object.entries(s))c!=="name"&&(l===void 0&&(l={path:[],props:{},type:0},u.push(l)),l.props[c]=d);return u}i.toOps=o})(ii||(ii={}));var Xs;(t=>t.defaultData={...nu.defaultData,..._p.defaultData,states:new Se,events:new Se,visible:!0,raycastLock:!1})(Xs||(Xs={}));var Sa;(t=>t.defaultData={...Xs.defaultData,...iu.defaultData})(Sa||(Sa={}));var au;(t=>t.defaultData={cornerRadius:[0,0,0,0]})(au||(au={}));var Pp;(t=>t.defaultData={...Sa.defaultData,type:"ellipse2d",width:100,height:100,name:"Ellipse"})(Pp||(Pp={}));var wa;(t=>t.defaultData={...Sa.defaultData,...au.defaultData,type:"rectangle2d",width:100,height:100,name:"Rectangle"})(wa||(wa={}));var Op;(t=>t.defaultData={...Sa.defaultData,type:"text2d",width:100,height:100,fontSize:12,lineHeight:1.2,letterSpacing:0,text:{textValue:"Hello world"},horizontalAlign:1,verticalAlign:1,textTransform:1,font:"Roboto_regular",name:"Text"})(Op||(Op={}));var Cp;(t=>t.defaultData={...Sa.defaultData,type:"path2d",path:"",name:"Path"})(Cp||(Cp={}));var E0;(t=>{function n(e){return e.type==="ellipse2d"||e.type==="rectangle2d"||e.type==="text2d"||e.type==="vector2d"||e.type==="path2d"}t.is=n})(E0||(E0={}));var Qs;(t=>t.defaultData={...Xs.defaultData,name:"Group",type:"group2d"})(Qs||(Qs={}));var Tp;(t=>t.defaultData={...Xs.defaultData,...au.defaultData,...iu.defaultData,name:"Frame",type:"frame2d",clipped:!0,width:200,height:200,fill:{color:Ie.fromHexAndA(St,1),enabled:!0},stroke:{color:Ie.fromHexAndA(0,1),thickness:1,enabled:!1,mode:"inside"},backgroundBlur:{radius:2,enabled:!1},layerBlur:{radius:2,enabled:!1}})(Tp||(Tp={}));var qo;(o=>{function n(i){switch(i){case"rectangle2d":return{...wa.defaultData};case"ellipse2d":return{...Pp.defaultData};case"text2d":return{...Op.defaultData};case"vector2d":return{...wa.defaultData};case"path2d":return{...Cp.defaultData};case"frame2d":return{...Tp.defaultData};case"group2d":return{...Qs.defaultData}}}o.defaultData=n;function t(i){return"width"in i&&"height"in i?[typeof i.width=="number"?i.width*.5:0,typeof i.height=="number"?i.height*.5:0]:[0,0]}o.getPivot=t;function e(i){return i.type==="rectangle2d"||i.type==="ellipse2d"||i.type==="text2d"||i.type==="frame2d"}o.isResizeable=e;function r(i){return i.type==="rectangle2d"||i.type==="frame2d"}o.hasCorners=r})(qo||(qo={}));var su;(e=>(e.defaultData={name:"UI",type:"scene2d",objects:new Je},e.emptyData=function(){return{type:"scene2d",objects:new Je}}))(su||(su={}));var xs=Ht(L0());import{Object3D as cN,Vector3 as Pr,Euler as dh,MathUtils as mv,Matrix4 as wi}from"three";var hT=.5*(Math.sqrt(3)-1),Ks=(3-Math.sqrt(3))/6,mT=1/3,yo=1/6,hq=(Math.sqrt(5)-1)/4,mq=(5-Math.sqrt(5))/20,Zs=n=>Math.floor(n)|0,R0=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]),Ip=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 lu(n=Math.random){let t=z0(n),e=new Float64Array(t).map(o=>R0[o%12*2]),r=new Float64Array(t).map(o=>R0[o%12*2+1]);return function(i,a){let s=0,l=0,u=0,c=(i+a)*hT,d=Zs(i+c),p=Zs(a+c),f=(d+p)*Ks,h=d-f,m=p-f,y=i-h,g=a-m,b,w;y>g?(b=1,w=0):(b=0,w=1);let _=y-b+Ks,S=g-w+Ks,P=y-1+2*Ks,O=g-1+2*Ks,x=d&255,D=p&255,N=.5-y*y-g*g;if(N>=0){let E=x+t[D],B=e[E],R=r[E];N*=N,s=N*N*(B*y+R*g)}let T=.5-_*_-S*S;if(T>=0){let E=x+b+t[D+w],B=e[E],R=r[E];T*=T,l=T*T*(B*_+R*S)}let I=.5-P*P-O*O;if(I>=0){let E=x+1+t[D+1],B=e[E],R=r[E];I*=I,u=I*I*(B*P+R*O)}return 70*(s+l+u)}}function V0(n=Math.random){let t=z0(n),e=new Float64Array(t).map(i=>Ip[i%12*3]),r=new Float64Array(t).map(i=>Ip[i%12*3+1]),o=new Float64Array(t).map(i=>Ip[i%12*3+2]);return function(a,s,l){let u,c,d,p,f=(a+s+l)*mT,h=Zs(a+f),m=Zs(s+f),y=Zs(l+f),g=(h+m+y)*yo,b=h-g,w=m-g,_=y-g,S=a-b,P=s-w,O=l-_,x,D,N,T,I,E;S>=P?P>=O?(x=1,D=0,N=0,T=1,I=1,E=0):S>=O?(x=1,D=0,N=0,T=1,I=0,E=1):(x=0,D=0,N=1,T=1,I=0,E=1):P<O?(x=0,D=0,N=1,T=0,I=1,E=1):S<O?(x=0,D=1,N=0,T=0,I=1,E=1):(x=0,D=1,N=0,T=1,I=1,E=0);let B=S-x+yo,R=P-D+yo,F=O-N+yo,V=S-T+2*yo,q=P-I+2*yo,k=O-E+2*yo,U=S-1+3*yo,H=P-1+3*yo,$=O-1+3*yo,J=h&255,K=m&255,X=y&255,te=.6-S*S-P*P-O*O;if(te<0)u=0;else{let W=J+t[K+t[X]];te*=te,u=te*te*(e[W]*S+r[W]*P+o[W]*O)}let Y=.6-B*B-R*R-F*F;if(Y<0)c=0;else{let W=J+x+t[K+D+t[X+N]];Y*=Y,c=Y*Y*(e[W]*B+r[W]*R+o[W]*F)}let ee=.6-V*V-q*q-k*k;if(ee<0)d=0;else{let W=J+T+t[K+I+t[X+E]];ee*=ee,d=ee*ee*(e[W]*V+r[W]*q+o[W]*k)}let Q=.6-U*U-H*H-$*$;if(Q<0)p=0;else{let W=J+1+t[K+1+t[X+1]];Q*=Q,p=Q*Q*(e[W]*U+r[W]*H+o[W]*$)}return 32*(u+c+d+p)}}function z0(n){let e=new Uint8Array(512);for(let r=0;r<512/2;r++)e[r]=r;for(let r=0;r<512/2-1;r++){let o=r+~~(n()*(256-r)),i=e[r];e[r]=e[o],e[o]=i}for(let r=256;r<512;r++)e[r]=e[r-256];return e}import{Triangle as yT}from"three";var qr=new yT,cu=class{constructor(t){this.weightAttribute=null;let e=t.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 t=this.positionAttribute,e=new Float32Array(t.count/3);for(let o=0;o<t.count;o+=3){let i=1;qr.a.fromBufferAttribute(t,o),qr.b.fromBufferAttribute(t,o+1),qr.c.fromBufferAttribute(t,o+2),i*=qr.getArea(),e[o/3]=i}this.distribution=new Float32Array(t.count/3);let r=0;for(let o=0;o<e.length;o++)r+=e[o],this.distribution[o]=r;return this}setRandomGenerator(t){return this.randomFunction=t,this}sample(t,e){if(this.distribution){let r=this.distribution[this.distribution.length-1],o=this.binarySearch(this.randomFunction()*r);return this.sampleFace(o,t,e)}}binarySearch(t){if(!this.distribution)return 0;let e=this.distribution,r=0,o=e.length-1,i=-1;for(;r<=o;){let a=Math.ceil((r+o)/2);if(a===0||e[a-1]<=t&&e[a]>t){i=a;break}else t<e[a]?o=a-1:r=a+1}return i}sampleFace(t,e,r){let o=this.randomFunction(),i=this.randomFunction();return o+i>1&&(o=1-o,i=1-i),qr.a.fromBufferAttribute(this.positionAttribute,t*3),qr.b.fromBufferAttribute(this.positionAttribute,t*3+1),qr.c.fromBufferAttribute(this.positionAttribute,t*3+2),e.set(0,0,0).addScaledVector(qr.a,o).addScaledVector(qr.b,i).addScaledVector(qr.c,1-(o+i)),qr.getNormal(r),this}};import{Object3D as ST}from"three";var k0=Ht(F0());import{Object3D as gT,Matrix4 as go}from"three";var xT=new go,bT=new go,vT=new go,Aa;(t=>{function n(e){return e&&e.__isSPEObject}t.is=n})(Aa||(Aa={}));var _a=n=>class extends n{constructor(){super(...arguments);this.previousModelViewMatrix=new go;this.copyPreviousMatrix=!0;this.hiddenMatrix=new go;this.matrixWorldRigid=new go;this.shearScale=new go;this.shearScaleInv=new go}get __isSPEObject(){return!0}isDescendantOf(r){r instanceof gT&&(r=r.uuid);let o=this;for(;o.parent;){if(o.parent.uuid===r)return!0;o=o.parent}return!1}updateMatrixWorld(r){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||r)&&(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,r=!0);for(let o of this.children)o.updateMatrixWorld(r)}updateWorldMatrix(r,o){let i=this.parent;if(r&&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 a of this.children)a.updateWorldMatrix(!1,!0)}traverseChildren(r,o=0){for(let i of this.children)Aa.is(i)&&i.traverseObject(r,o+1)}traverseObject(r,o=0){if(r(this,o)!==!0)for(let a of this.children)Aa.is(a)&&a.traverseObject(r,o+1)}updateMatrixWorldSVD(){let r=this.matrixWorld.elements,o=[[r[0],r[4],r[8]],[r[1],r[5],r[9]],[r[2],r[6],r[10]]],{u:i,v:a,q:s}=(0,k0.SVD)(o),l=xT.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),u=bT.set(a[0][0],a[0][1],a[0][2],0,a[1][0],a[1][1],a[1][2],0,a[2][0],a[2][1],a[2][2],0,0,0,0,1),c=vT.copy(u).transpose();this.shearScale.makeScale(s[0],s[1],s[2]).multiply(c).premultiply(u),this.shearScaleInv.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(l,c).copyPosition(this.matrixWorld),s.every(d=>Math.abs(s[0]-d)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(r,o){this.updateWorldMatrix(!0,!1);let i=new go().copy(this.matrixWorld).invert();return r.parent!==null&&(r.parent.updateWorldMatrix(!0,!1),i.multiply(r.parent.matrixWorld)),"hiddenMatrix"in r&&r.hiddenMatrix instanceof go?r.hiddenMatrix.premultiply(i):r.applyMatrix4(i),r.updateWorldMatrix(!1,!1),this.add(r),o!==void 0&&(this.children.pop(),this.children.splice(o,0,r)),this}copy(r,o=!1){return super.copy(r,o),this.hasNonUniformScale=r.hasNonUniformScale,this}onAfterRender(r,o,i,a,s,l){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}};var Np=class extends _a(ST){},wT=n=>n.type==="Mesh",Wo=class extends Np{constructor(e){super();this.object=e;this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,r){}expand(){let e=0,r=this.object.entityChildren(e);for(;r;){let o=this.children[e];o?.object!==r&&(o&&this.remove(o),o=new Wo(r),this.add(o),this.children.splice(e,0,this.children.pop()),o.matrixWorldNeedsUpdate=!0,o.matrixAutoUpdate=!1,o.matrix=r.matrix,o.hiddenMatrix=r.hiddenMatrix),o.expand(),e+=1,r=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 wT(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}};import{Box3 as EI,BufferGeometry as BI,MeshBasicMaterial as LI}from"three";import{Matrix4 as NI,Mesh as DI}from"three";import{Matrix4 as pu,Vector3 as H0,Euler as TT,MathUtils as el}from"three";import{Box3 as AT,Line3 as _T,Matrix4 as Dp,Vector3 as wr}from"three";var ai=new wr,si=new wr,Pa=new Dp,U0=[new wr(-1,1,1),new wr(-1,-1,1),new wr(1,-1,1),new wr(1,1,1),new wr(-1,1,-1),new wr(-1,-1,-1),new wr(1,-1,-1),new wr(1,1,-1)],PT=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],OT=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],j0=(n,t,e)=>{n.updateEntityBoxSize(ai,si),Pa.copy(t).multiply(n.matrixWorld),si.x===0&&si.y===0&&si.z===0?e.push(new wr(ai.x,ai.y,ai.z).applyMatrix4(Pa)):U0.forEach(r=>{e.push(r.clone().multiply(si).add(ai).applyMatrix4(Pa))})},Js=class extends AT{constructor(){super(...arguments);this.matrix=new Dp;this.vertices=[];this.faces=[];this.edges=[];this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(r=>r.clone()),this.faces=e.faces.map(r=>r.clone()),this.edges=e.edges.map(r=>r.clone()),this.centerEdges=e.centerEdges.map(r=>r.clone()),this}setFromObjectSize(e,r=!1){e.updateWorldMatrix(!1,r),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let o=new Dp().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,o,r)}expandByObjectSize(e,r,o=!1){let i=[];return o===!0?e.traverseEntity(a=>{if(a.visible||a.cloner&&a.data.visible){if(!("geometry"in a)){i.push(new wr);return}j0(a,r,i)}}):j0(e,r,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(Pa.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(si).multiplyScalar(.5),this.getCenter(ai),Pa.copy(this.matrix).setPosition(ai),this.vertices=U0.map(e=>e.clone().multiply(si).applyMatrix4(Pa))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=PT.map(([e,r])=>new _T(this.vertices[e],this.vertices[r])),this.centerEdges=this.edges.map(e=>e.getCenter(new wr))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=OT.map(([e,r])=>this.vertices[e].clone().add(this.vertices[r]).multiplyScalar(.5))}};var Wr={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}};import{CurvePath as CT,CubicBezierCurve3 as Ep,Vector3 as $r}from"three";var Lp=class extends CT{constructor(){super()}getPoints(t=12){let e=[],r,o=this.getCurveLengths(),a=o[o.length-1]/o.length;for(let s=0,l=this.curves;s<l.length;s++){let u=l[s],c=s===0?o[s]:o[s]-o[s-1],d=Math.ceil(t*c/a),p=u.getPoints(d);for(let f=0;f<p.length;f++){let h=p[f];r&&r.equals(h)||(e.push(h),r=h)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}};var Rp=.001;function Vp(n,t,e){return t.clone().sub(n).cross(t.clone().sub(e)).length()<=Rp}function Bp(n,t){let e=new $r(...n.position),r=new $r(...n.controlNext.position),o=new $r(...t.controlPrevious.position),i=new $r(...t.position);return Vp(e,r,i)&&Vp(e,o,i)}function du(n){let t=n.points.map(c=>new $r(...c.data.position)),e=[n.points[0]],r=new $r(...e[0].data.position);for(let c=0;c<n.points.length-1;c++)Vp(r,t[c],t[c+1])||(e.push(n.points[c]),r=t[c]);e.push(n.points[n.points.length-1]);let o=n.isClosed,i=e.length-(o?0:1),a=e.length,s=[];for(let c=0;c<a;c++){let d=e[c].data,p=new $r(...d.position),f=new $r(...d.controlPrevious.position),h=new $r(...d.controlNext.position),m={position:p,baseRoundness:d.roundness,controlPrevious:f,controlNext:h};if(d.roundness===0||!n.isClosed&&(c===0||c===a-1)){s[c]={...m,removedLength:0};continue}let y=o&&c==0?a-1:c-1,g=o&&c==a-1?0:c+1,b=e[y].data,w=e[g].data,_=new $r(...b.position),S=new $r(...w.position),P=_.clone().sub(p).normalize(),O=S.clone().sub(p).normalize();Object.assign(m,{prevDir:P,nextDir:O});let x=Bp(b,d),D=Bp(d,w);if(!x||!D)s[c]={...m,removedLength:0};else{let N=P.clone().add(O).normalize(),T=N.clone().cross(P).length()/P.dot(N);s[c]={...m,tan:T,removedLength:d.roundness/T}}}for(let c=0;c<i;c++){let d=c,p=o&&c===a-1?0:c+1,f=s[d],h=s[p];if(f.removedLength!==0||h.removedLength!==0){let m=f.position.distanceTo(h.position);f.removedLength=Math.min(f.removedLength,m/2),h.removedLength=Math.min(h.removedLength,m/2)}}let l=[];for(let c=0;c<i;c++){let d=c,p=o&&c===a-1?0:c+1,f=s[d],h=s[p],m=null;if(!Bp(e[d].data,e[p].data))f.position.distanceTo(h.position)>Rp&&(m=new Ep(f.position,f.controlNext,h.controlPrevious,h.position));else{let y=f.position.clone(),g=h.position.clone();(f.removedLength!==0||h.removedLength!==0)&&(f.nextDir&&y.add(f.nextDir.clone().setLength(f.removedLength)),h.prevDir&&g.add(h.prevDir.clone().setLength(h.removedLength))),y.distanceTo(g)>Rp&&(m=new Ep(y,y.clone().lerp(g,.3),g.clone().lerp(y,.3),g))}l[2*c+1]=m}for(let c=0;c<a;c++){let d=s[c];if(d.removedLength===0){l[2*c]=null;continue}let p=d.position,f=d.prevDir.clone().multiplyScalar(d.removedLength).add(p),h=d.nextDir.clone().multiplyScalar(d.removedLength).add(p),m=d.tan*d.removedLength,y=d.prevDir.clone().add(d.nextDir).normalize(),g=f.clone().lerp(h,.5),b=f.distanceTo(h)/2,w=y.clone().multiplyScalar(Math.sqrt(Math.pow(m,2)-Math.pow(b,2))).add(g),_=y.clone().multiplyScalar(-m).add(w),S=p.distanceTo(_)/p.distanceTo(g),P=d.prevDir.clone().multiplyScalar(S*p.distanceTo(f)).add(p),O=P.clone().lerp(_,2),x=f.clone().lerp(P,4/3),D=h.clone().lerp(O,4/3);l[2*c]=new Ep(f,x,D,h)}let u=new Lp;return l.forEach(c=>{c&&u.add(c)}),u}var Re;(t=>{function n(e){return e&&e.__isEntity}t.is=n})(Re||(Re={}));var Oa=n=>Re.is(n),MT={type:"completeState",isfromEntity:!0},IT=["x","y","z"],zp=new H0,NT=new H0().set(0,1,0),Ca=n=>class extends _a(n){constructor(){super(...arguments);this.raycastLock=!1;this.scaleLock=!1;this.disposed=!1;this.stateSelection=null;this.destroyedInAction=!1;this.instances=[];this.prevState=null;this.currentState=null;this.reversibleToState=null;this.currentTransitionEvent=null;this.previousAction=null;this._singleBBox=new Js;this._recursiveBBox=new Js;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this._needApplyPathSnapping=!0;this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(r){let o=this.children[r];if(Re.is(o))return o}entityChildrenCount(){let r=this.children.length;for(;r--;)if(Re.is(this.children[r]))return r+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 r=this;for(;r.data.type!=="Instance";){let o=r.parent;if(Re.is(o))r=o;else return}return r}forInstancesRec(r){this.instances.forEach(o=>{o.disposed||r(o),o.forInstancesRec(r)})}super_Entity(r,o){typeof r=="string"&&(this.uuid=r),this.identity=r,this.data=o,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(r,o,i=!1){if(!(this.data.states.length===0&&!i)){for(let a of this.data.states)ni.toOps(this.data,a.data).forEach(l=>{let u=aa.replaceProps(l,this.data);this.dataPatched=this.data,this.updateByPatchedOp(u,this.data,o)});if(r!==null){let a=this.data.states.data(r);a&&(this.dataPatched=ni.patch(this.data,a),ni.toOps(this.data,a).forEach(l=>{this.updateByPatchedOp(l,this.dataPatched,o)}))}i&&this.updateTransformState(this.dataPatched,o),this.stateSelection=r,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(r,o){r.setScalar(0),o.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(r=>{Oa(r)&&r.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(r=>{r.resetBBoxNeedsUpdateSelf()})}find(r){let o;return this.traverseEntity(i=>{i.uuid===r&&(o=i)}),o}traverseSortNextHelper(){let r=this.parent;if(r){let o=r.children,i=o.indexOf(this)+1;if(Re.is(o[i]))return o[i];if(Re.is(r))return r.traverseSortNextHelper()}}sortNext(){let r=this.children;return this.children.length>0&&Re.is(this.children[0])?r[0]:this.traverseSortNextHelper()}goUp(r){let o=this;for(;r>0&&o!==null;)o=o.parent,r-=1;return o}hasAnccestorOrSelf(r){return this===r||this.hasAnccestor(r)}hasAnccestor(r){let o=this.parent;for(;o;){if(r===o)return!0;o=o.parent}return!1}countToAccestor(r){let o=0,i=this;for(;i!==r;){if(i===null)return-1;i=i.parent,o+=1}return o}forEachEntity(r){for(let o of this.children)Oa(o)&&r(o)}traverseEntityAncestors(r){this.traverseAncestors(o=>{Re.is(o)&&r(o)})}traverseConcreteEntity(r,o=0){if(r(this,o)!==!0)for(let a of this.children)Oa(a)&&a.isConcreteEntity&&a.traverseEntity(r,o+1)}traverseEntity(r,o=0){if(r(this,o)!==!0)for(let a of this.children)Oa(a)&&a.traverseEntity(r,o+1)}traverseVisibleEntity(r){r(this);for(let o of this.children)Oa(o)&&o.visible&&o.traverseVisibleEntity(r)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}updateMatrixWorld(r){super.updateMatrixWorld(r),this.dispatchEvent({type:"updateMatrixWorld"})}copy(r,o=!1){return super.copy(r,o),this.dataPatched=r.dataPatched,this.raycastLock=r.raycastLock,this.scaleLock=r.scaleLock,this.hiddenMatrix.copy(r.hiddenMatrix),this}hasEntityChild(){return this.children.some(r=>Oa(r))}isAncestorOf(r){if(this.uuid===r)return!1;let o=!1;return this.traverseEntity(i=>{i.uuid===r&&(o=!0)}),o}toObjectTransformState(r=[]){this.updateWorldMatrix(!0,!1);let o={position:this.position.toArray(),rotation:[this.rotation.x*el.RAD2DEG,this.rotation.y*el.RAD2DEG,this.rotation.z*el.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return ta(o,r)}getTransformValues(r,o,i){return o[r].map((a,s)=>i?.shared.getVariable(a,[this.uuid,r,IT[s]])??a)}updateTransformState(r,o){let i=!1;return r.position&&(this.position.fromArray(this.getTransformValues("position",r,o)),i=!0),r.rotation&&(zp.fromArray(this.getTransformValues("rotation",r,o)).multiplyScalar(el.DEG2RAD),this.rotation.setFromVector3(zp),i=!0),r.scale&&(this.scale.fromArray(this.getTransformValues("scale",r,o)),i=!0),r.hiddenMatrix!==void 0&&(i=!0,this.hiddenMatrix.fromArray(r.hiddenMatrix??xn.identity)),i&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(a=>{a.invalidateClonerTransform(this)})),r.position&&r.rotation&&r.scale&&r.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),i}onVariableUpdate(r=!1){if(r){this.resetBBoxNeedsUpdate();return}this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(o=>{o.invalidateClonerTransform(this)})}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let r of this.children)Re.is(r)&&r.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(r=>{Re.is(r)&&r.disposeRecursively()})}toState(r=[]){let o={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(r)};return ta(o,r)}updateByObjUpdateOp(r,o){r!==void 0&&this.updateByOp({type:0,props:r,path:[]},{...this.data,...r},o,!1)}updateByOp(r,o,i,a){let s=this.data;this.data=o;let l=r,u=Le(r.path,["states","*"]);if(u!==null){if(r.type===0){let[c]=u;if(this?.stateSelection===c){let d={...r.props};if(delete d.name,Object.values(r.props).some(p=>p===void 0)){let p=this.data;if(p!==void 0){let f=lt.zoom(p,r.path.slice(2));if(f)for(let h in r.props)r.props[h]===void 0&&h in f&&(d[h]=f[h])}}l={...r,props:d,path:r.path.slice(2)}}}}else if(r.type===0){let c=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(c!==void 0){if(r.props.name!==void 0&&c.name){let{name:p,...f}=c;c=f}if(r.props.material!==void 0&&"material"in c){let{material:p,...f}=c;c=f}let d=lt.removeOverridden(r.path,r.props,c);l={...r,props:d}}}if(this.updateByPatchedOpBase(l,ni.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),i),Le(r.path,["overrides"])){let c=[],d=[...r.path];for(c.push(d[1]),d.splice(0,2);d.length>0&&d[0]==="descendants";)c.push(d[1]),d.splice(0,2);if(c[c.length-1]===void 0){if(r.type===0)for(let p of Object.keys(r.props)){c[c.length-1]=p;let f=i.scene.findInstance([this.uuid,...c]);f&&(f.overrideData=r.props[p],f.updateState(so.apply(f.component.data,f.overrideData),i))}}else{let p=i.scene.findInstance([this.uuid,...c]);if(p){let f=lt.zoom(p.component.data,d);if(r={...r,path:d},r.type===0){let h=r.props;if(f)for(let[m,y]of Object.entries(r.props))y===void 0&&(h===r.props&&(h={...r.props}),h[m]=f[m]);r={...r,props:h}}p.overrideData=ma.resolve(o.overrides,c),p.updateByOp(r,ct.applySimple(p.data,r),i,!1)}}}else if(this.instances.length>0){let c;if(r.path.length===0&&r.type===0){let d;for(let p of ho.rootOverrideProps)p in r.props&&(d===void 0&&(d={}),d[p]=r.props[p]);d&&(c={...r,props:d})}else for(let d of ho.rootOverrideProps)if(Le(r.path,[d])){c=r;break}c!==void 0&&this.instances.forEach(d=>{if(d.isInstanceRoot){let p=so.filterOp(d.overrideData,c);p&&d.updateByOp(p,ct.applySimple(d.data,p),i,!0)}}),this.instances.forEach(d=>{if(!d.isInstanceRoot){let p=so.filterOp(d.overrideData,r);if(p){let f;s===d.data&&r===p?f=o:f=ct.applySimple(d.data,p),d.updateByOp(p,f,i,!0)}}})}}updateByPatchedOpBase(r,o,i){if(this.dataPatched=o,r.path.length===0&&r.type===0)r.props.type!==void 0&&!Ur.is(r.props.type)&&Wr.changeEntityProptotype(this,o,i);else if(r.path.length===1&&r.path[0]==="geometry"&&r.type===0&&"type"in r.props){Wr.changeEntityProptotype(this,o,i);for(let a of this.children)Re.is(a)&&a.updateVisible(i.scene)}this.updateByPatchedOp(r,o,i)}updateByPatchedOp(r,o,i){if(r.path.length===0&&r.type===0&&this.updateState(r.props,i),Le(r.path,["pathSnapping"])!==null&&this.updatePathSnapping(o.pathSnapping),Le(r.path,["cloner"])!==null){let a=ct.drop(r,1);a.path.length===0&&a.type===0&&a.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(i.scene)}}updatePathSnapping(r=this.dataPatched.pathSnapping){this._updatedPathSnapping=r,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(r){let o=this._updatedPathSnapping?.pathId??this.dataPatched.pathSnapping.pathId,i=this._updatedPathSnapping?.slide??this.dataPatched.pathSnapping.slide??0,a=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset??0,s=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(o===null)return;let l=r.find(o);if(!l||this._needApplyPathSnapping===!1)return;this._needApplyPathSnapping=!1;let u=l.data;if(u.geometry.path.points.length<=1)return;let c=du(u.geometry.path),d=(i+a)%1;i+a===1&&d===0&&(d=1);let p=c.getPointAt(d);if(p===null)return;let f=this.parent?this.parent?.matrixWorld:new pu;l.updateMatrixWorld();let h=new pu().multiplyMatrices(f.clone().invert(),l.matrixWorld);p.applyMatrix4(h);let m={position:p.toArray(),rotation:u.rotation};if(s==="tangential"){let y=new pu().extractRotation(l.matrixWorld),g=c.getTangentAt(d).applyMatrix4(y).add(p),b=new pu().lookAt(p,g,NT),w=zp.setFromEuler(new TT().setFromRotationMatrix(b)).multiplyScalar(el.RAD2DEG);m={...m,rotation:w.toArray()}}this.updateTransformState(m),this.traverseEntity(y=>{y._cameraType&&y.dispatchEvent(MT)})}updateVisible(r){if(this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0),!r)return;let o=!1;this.traverseEntity(i=>{if(i.data.type==="Splat")return o=!0,!0}),o&&r.reloadSplats()}updateState_Entity(r,o){r.name!==void 0&&(this.name=r.name),r.raycastLock!==void 0&&(this.raycastLock=r.raycastLock),r.visible!==void 0&&(this.updateVisible(o?.scene),this.resetBBoxNeedsUpdate()),o&&"cloner"in r&&r.cloner!==void 0&&(this.setFromClonerState(r.cloner,o),this.updateVisible(o.scene)),this.updateTransformState(r,o)}get attachedSurfaceCloners(){return this.children.filter(r=>r instanceof Wr.Cloner&&r.parameters.type==="toObject")}setFromClonerState(r,o){this.disposed||(r===null||r.disabled?(this.cloner&&this.cloner.removeFromParent(),this.cloner=void 0):this.cloner===void 0?(this.cloner=new Wr.Cloner(this,r),o.scene.addPendingExpandCloner(this)):this.cloner.updateState(r,o.scene))}expandCloner(r){!this.disposed&&this.cloner&&this.cloner.expandClones(r)}invalidateClonerTransform(r){this.cloner&&this.cloner.invalidateTransform(r)}requestRender(){this.dispatchEvent({type:"requestRender"})}};import{BufferGeometry as BT,ConeGeometry as LT,Float32BufferAttribute as RT,MathUtils as VT}from"three";import{BufferGeometry as W0,CylinderGeometry as DT,Float32BufferAttribute as hu,MathUtils as ET,Vector2 as Yr,Vector3 as fu}from"three";var $0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},n.parameters);e.thetaLength=ET.clamp(e.thetaLength,0,360);let r=e.width/2,o=e.radiusTop??r,i=e.radiusBottom??r;return o===i?(o=r,i=r):o>i?(o=r,i=i*r/o):(o=o*r/i,i=r),{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:t,depth:e,height:r,radialSegments:o,heightSegments:i,openEnded:a,thetaStart:s,thetaLength:l,radiusTop:u,radiusBottom:c,cornerRadius:d,cornerSegments:p,hollow:f}=n.parameters,h;return l===0?(h=new W0,h.setAttribute("position",new hu([],3))):d||f?h=new tl(u,c,r,o,i,a,s,l*Math.PI/180,d,d,p,f):h=new DT(u,c,r,o,i,a,s,l*Math.PI/180),h.scale(1,1,e/t),Object.assign(h,{userData:{...n,type:"CylinderGeometry"}})}};function _n(n,t,e){e.x=n.x*t.x,e.y=n.y,e.z=n.x*t.y}function q0(n){return new Yr(n.y,-n.x)}var tl=class extends W0{constructor(t,e,r,o,i,a,s,l,u,c,d,p,f=!1){super(),this.type="RoundedCylinderBufferGeometry",t=t!==void 0?t:1,e=e!==void 0?e:1,r=r||1,o=Math.floor(o)||8,i=Math.floor(i)||1,a=a!==void 0?a:!1,s=s!==void 0?s:0,l=l!==void 0?l:Math.PI*2,a&&(u=0,c=0);let h=[],m=[],y=[],g=[],b=0,w=r/2,_=new fu,S=new fu;f&&t==0&&(t=u),f&&e==0&&(e=c);let P=new Yr(t,w),O=new Yr(e,-w),x=null,D=null,N=null,T=null,I=P.clone().sub(O),E=0,B=0,R=0;p>0&&(E=Math.min(t,e)*(1-p),B=t-E,R=e-E);let F=P.clone();F.x-=E;let V=Math.PI-I.angle(),q=I.angle(),k=Math.tan(q/2),U=Math.tan(V/2),H=k+U,$=p?H:U,J=p?H:k;if(u=Math.min(u,(t-B)/$,I.length()/H),c=Math.min(c,(e-R)/J,I.length()/H),u>0){let Q=u/k;x=P.clone().sub(new Yr(Q,u)),p&&(N=x.clone(),N.x-=E-H*u),P.sub(I.clone().setLength(Q))}if(c>0){let Q=c/U;D=O.clone().sub(new Yr(Q,-c)),O.add(I.clone().setLength(Q)),p&&(T=D.clone(),T.x-=E-H*c,F.sub(I.clone().setLength(Q)))}I=P.clone().sub(O);let K=I.length()<.5,X=[];for(let Q=0;Q<=o;Q++){let W=[],ue=Q/o,le=ue*l+s,ne=new Yr(Math.sin(le),Math.cos(le));T&&D?(te(W,ue,ne,V,c,T,-1,!0),te(W,ue,ne,q,c,D,-1,!1)):D?(Y(W,ne,D.x,0,-1),te(W,ue,ne,q,c,D,-1,!1)):a||Y(W,ne,e,R,-1);let ce=q0(I).normalize();if(_n(ce,ne,_),!K)for(let ae=0;ae<=i;ae++){let he=ae/i,pe=I.clone().multiplyScalar(he).add(O);_n(pe,ne,S),m.push(S.x,S.y,S.z),y.push(_.x,_.y,_.z),g.push(ue,.5+S.y/r),W.push(b++)}if(N&&x?(te(W,ue,ne,V,u,x,1,!1),te(W,ue,ne,q,u,N,1,!0)):x?(te(W,ue,ne,V,u,x,1,!1),Y(W,ne,x.x,0,1)):a||Y(W,ne,t,B,1),p&&!K){let ae=q0(I).multiplyScalar(-1).normalize();_n(ae,ne,_);for(let he=0;he<=i;he++){let pe=he/i,fe=I.clone().multiplyScalar(-pe).add(F);_n(fe,ne,S),m.push(S.x,S.y,S.z),y.push(_.x,_.y,_.z),g.push(ue,.5+S.y/r),W.push(b++)}}p&&!a&&W.push(W[0]),X.push(W)}for(let Q=0;Q<X.length-1;Q++)for(let W=0;W<X[0].length-1;W++){if(a&&p&&W==i)continue;let ue=X[Q][W],le=X[Q+1][W],ne=X[Q+1][W+1],ce=X[Q][W+1],ae=m[ne*3+0],he=m[ne*3+2];h.push(ue,le,ce),(ae!=0||he!=0)&&h.push(le,ne,ce)}l<Math.PI*2&&(ee(-1,X[0],s),ee(1,X[X.length-1],s+l)),this.setIndex(h),this.setAttribute("position",new hu(m,3)),this.setAttribute("normal",new hu(y,3)),this.setAttribute("uv",new hu(g,2));function te(Q,W,ue,le,ne,ce,ae,he){for(let pe=0;pe<d+1;pe++){let fe=pe/d,ge=ae<0?fe:1-fe;he&&(ge-=1),ge*=le;let me=new Yr(Math.sin(ge),Math.cos(ge)*ae),C=me.clone().multiplyScalar(ne).add(ce);_n(C,ue,S),m.push(S.x,S.y,S.z),_n(me,ue,_),y.push(_.x,_.y,_.z),g.push(W,.5+S.y/r),Q.push(b++)}}function Y(Q,W,ue,le,ne){let ce=new fu,ae=new Yr,he=[ue,le];ne<0&&he.reverse();for(let pe of he)ae.set(pe,w*ne),_n(ae,W,ce),m.push(ce.x,ce.y,ce.z),y.push(0,ne,0),g.push(.5,.5),Q.push(b++)}function ee(Q,W,ue){let le=new Yr(Math.sin(ue),Math.cos(ue)),ne=new Yr(-Math.cos(ue),Math.sin(ue)),ce=new fu,ae=Q<0?(fe,ge,me)=>h.push(fe,ge,me):(fe,ge,me)=>h.push(fe,me,ge),he=new Yr((t+e+B+R)/4,0);_n(he,le,ce),m.push(ce.x,ce.y,ce.z),y.push(ne.x,0,ne.y),g.push(.5,.5);let pe=b++;for(let fe of W){let ge=m.slice(fe*3,fe*3+3);m.push(...ge),y.push(ne.x,0,ne.y);let me=g.slice(fe*2,fe*2+2);g.push(...me),b++}for(let fe=pe+1;fe<b-1;fe++)ae(pe,fe,fe+1);ae(pe,b-1,pe+1)}}};var Y0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:8,cornerRadiusBottom:8,cornerSegments:8},n.parameters);return e.thetaLength=VT.clamp(e.thetaLength,0,360),{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:t,depth:e,height:r,radialSegments:o,heightSegments:i,openEnded:a,thetaStart:s,thetaLength:l,cornerRadiusTop:u,cornerRadiusBottom:c,cornerSegments:d}=n.parameters,p;return l===0?(p=new BT,p.setAttribute("position",new RT([],3))):u>0||c>0||l<360?p=new tl(0,t/2,r,o,i,a,s,l*Math.PI/180,u,c,d,0,!0):p=new LT(t/2,r,o,i,a),p.scale(1,1,e/t),Object.assign(p,{userData:{...n,type:"ConeGeometry"}})}};import{BoxGeometry as zT,BufferGeometry as GT,Float32BufferAttribute as Gp,Vector3 as rl}from"three";var X0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.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:t,height:e,depth:r,widthSegments:o,heightSegments:i,depthSegments:a,cornerRadius:s,cornerSegments:l}=n.parameters,u;return s==0?u=new zT(t,e,r,o,i,a):u=new kp(t,e,r,o,i,a,s,l),Object.assign(u,{userData:{...n,type:"CubeGeometry"}})}},Fp=Math.PI/2,kp=class extends GT{constructor(t=1,e=1,r=1,o=1,i=1,a=1,s=0,l=4){super(),this.type="BoxGeometry";let u=this;o=Math.floor(o),i=Math.floor(i),a=Math.floor(a),l=Math.floor(l),s=Math.min(s,t/2,e/2,r/2);let c=[],d=[],p=[],f=[],h=0,m=0;y("z","y","x",-1,-1,r,e,t,a,i,0),y("z","y","x",1,-1,r,e,-t,a,i,1),y("x","z","y",1,1,t,r,e,o,a,2),y("x","z","y",1,-1,t,r,-e,o,a,3),y("x","y","z",1,-1,t,e,r,o,i,4),y("x","y","z",-1,-1,t,e,-r,o,i,5),s>0&&(g("z","y","x",-1,-1,1,r,e,t,a,0),g("z","y","x",1,-1,-1,r,e,t,a,1),g("z","y","x",-1,1,-1,r,e,t,a,1),g("z","y","x",1,1,1,r,e,t,a,0),g("x","y","z",-1,-1,-1,t,e,r,o,0),g("x","y","z",1,-1,1,t,e,r,o,1),g("x","y","z",-1,1,1,t,e,r,o,0),g("x","y","z",1,1,-1,t,e,r,o,1),g("y","x","z",-1,-1,1,e,t,r,i,0),g("y","x","z",1,-1,-1,e,t,r,i,1),g("y","x","z",1,1,1,e,t,r,i,1),g("y","x","z",-1,1,-1,e,t,r,i,0),b(1,1,1),b(-1,1,1),b(1,-1,1),b(-1,-1,1),b(1,1,-1),b(-1,1,-1),b(1,-1,-1),b(-1,-1,-1)),this.setIndex(c),this.setAttribute("position",new Gp(d,3)),this.setAttribute("normal",new Gp(p,3)),this.setAttribute("uv",new Gp(f,2));function y(w,_,S,P,O,x,D,N,T,I,E){let B=(x-2*s)/T,R=(D-2*s)/I,F=x/2-s,V=D/2-s,q=N/2,k=T+1,U=I+1,H=0,$=0,J=new rl;for(let K=0;K<U;K++){let X=K*R-V;for(let te=0;te<k;te++){let Y=te*B-F;J[w]=Y*P,J[_]=X*O,J[S]=q,d.push(J.x,J.y,J.z),J[w]=0,J[_]=0,J[S]=N>0?1:-1,p.push(J.x,J.y,J.z),f.push(te/T),f.push(1-K/I),H+=1}}for(let K=0;K<I;K++)for(let X=0;X<T;X++){let te=h+X+k*K,Y=h+X+k*(K+1),ee=h+(X+1)+k*(K+1),Q=h+(X+1)+k*K;c.push(te,Y,Q),c.push(Y,ee,Q),$+=6}u.addGroup(m,$,E),m+=$,h+=H}function g(w,_,S,P,O,x,D,N,T,I,E){let B=(D-2*s)/I,R=D/2-s,F=N/2-s,V=T/2,q=I+1,k=0,U=0,H=new rl,$=new rl;for(let J=0;J<l+1;J++){let K=J/l*Fp,X=Math.sin(K)*s,te=(1-Math.cos(K))*s,Y=Math.sin(K),ee=Math.cos(K);H[_]=(F+X)*O,H[S]=(V-te)*x,$[w]=0,$[_]=Y*Math.sign(H[_]),$[S]=ee*Math.sign(H[S]);for(let Q=0;Q<q;Q++){let W=Q*B-R;H[w]=W*P,d.push(H.x,H.y,H.z),p.push($.x,$.y,$.z),f.push(Q/I),f.push(0),k+=1}}for(let J=0;J<l;J++)for(let K=0;K<I;K++){let X=h+K+q*J,te=h+K+q*(J+1),Y=h+(K+1)+q*(J+1),ee=h+(K+1)+q*J;c.push(X,te,ee),c.push(te,Y,ee),U+=6}u.addGroup(m,U,E),m+=U,h+=k}function b(w,_,S){let P=new rl,O=new rl(t/2,e/2,r/2);O.subScalar(s);let x=[],D=w*_*S>0?(T,I,E)=>c.push(T,I,E):(T,I,E)=>c.push(T,E,I);for(let T=0;T<=l;T++){let I=[],E=Fp*(1-T/l),B=Math.cos(E),R=Math.sin(E),F=0;for(let V=0;V<=T;V++){let q=Math.cos(F),k=Math.sin(F);P.x=B*q,P.y=R,P.z=B*k;let U=O.clone().addScaledVector(P,s);d.push(w*U.x,_*U.y,S*U.z),p.push(w*P.x,_*P.y,S*P.z),f.push(0,0),I.push(h++),F+=Fp/T}x.push(I)}let N=x.length-1;for(let T=0;T<N;T++){let I=x[T],E=x[T+1],B=I.length-1;D(I[0],E[1],E[0]);for(let R=1;R<=B;R++)D(I[R-1],I[R],E[R]),D(I[R],E[R+1],E[R])}}}};import{BufferGeometry as FT,Float32BufferAttribute as jp,Triangle as kT,Vector3 as $o,Vector2 as Up}from"three";var Pn=class extends FT{constructor(t=[],e=[],r="",o=1,i=.2,a=4){super(),this.type="PolyhedronGeometryRound";let s=[],l=[],u=[];c(),d(),this.setAttribute("position",new jp(s,3)),this.setAttribute("normal",new jp(u,3)),this.setAttribute("uv",new jp(l,2));return;function c(){i=Math.min(1-1e-5,i),i==0&&(a=0);let f={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[r],h=new $o,m=h.clone(),y=new kT,g=i*o,b=o-g,w=a+1,_=new $o,S=(k,U)=>_.subVectors(k,U).normalize(),P=(k,U)=>Array(k).fill(void 0).map(U),O=P(t.length/3,(k,U)=>new $o().fromArray(t,U*3).setLength(o)),x=[],D=1e6;for(let k=0;k<O.length;k++){let U=O[k],H=[],$,J,K,X=1e10,te=-1;for(;(te=e.indexOf(k,te+1))!=-1;){let W=te-te%3;$=e[W+(te+1)%3],J=e[W+(te+2)%3],K=U.distanceToSquared(O[$]),X=Math.min(X,K),H.push([$,J,K])}X+=1e-6;let Y=[],ee=0,Q=H.length;for(let W=0;W<Q;W++){[$,J,K]=H[ee];let ue=x[$]?.includes(k)==!0;K<=X&&Y.push($+ +ue*D),ee=H.findIndex(le=>le[0]==J)}x.push(Y)}let N=[];{let k=0,U=0,H,$,J=f==3;for(let K=0;K<=a;K++){H=K*(K+1)/2,$=(K+1)*(K+2)/2;for(let X=0;X<a-K;X++)[k,U]=[H+X+K+2,$+X+K+3],N.push(H,$,...J?[U,H]:[k,$],U,k),[H,$]=[k,U];N.push(H,$,H+a+2)}}let T=h.clone(),I=h.clone(),E=h.clone(),B=h.clone(),R=h.clone(),F=[],V=P(O.length,()=>P(f,()=>h.clone()));for(let k=0;k<O.length;k++){h.copy(O[k]).normalize(),T.copy(h).multiplyScalar(b);let U=x[k];for(let Y=0;Y<U.length;Y++){let ee=U[Y],Q=U[(Y+1)%f];y.setFromPointsAndIndices(O,k,ee%D,Q%D),y.b.sub(y.a).setLength(1e10).add(y.a),y.c.sub(y.a).setLength(1e10).add(y.a),y.closestPointToPoint(T,V[k][Y])}let H=[],$=[],J=[],K=new $o;a==0&&[...V[k]].reduce((Y,ee)=>Y.add(ee),K).multiplyScalar(1/f);for(let Y=0;Y<f;Y++){let ee=[],Q=(Y-1+f)%f,W=V[k][Q],ue=V[k][Y];h.copy(W).sub(T),m.copy(ue).sub(T);let le=T.angleTo(h),ne=h.angleTo(m),ce=Math.cos(le)*g;a==0?I.copy(K):I.copy(T).setLength(b+ce),$.push(ce);let ae=[I,W,ue];for(let he=0;he<2;he++){let pe=ae[he],fe=ae[he+1];B.subVectors(pe,T),R.subVectors(fe,T),E.crossVectors(B,R).normalize();for(let ge=0;ge<w;ge++){let me=[le,ne][he]*ge/w;h.copy(B).applyAxisAngle(E,me).add(T),H.push(h.clone()),he&&(S(h,T),ee.push([ge==0?pe:h.clone(),_.clone()]))}he&&(S(fe,T),ee.push([fe,_.clone()]))}J.push(ee)}F.push(J);let X=2*w,te=2;for(let Y=0;Y<f;Y++){let ee=X*Y,Q=X*((Y+1)%f),W=[H[ee]];for(let le=1;le<w;le++){B=H[ee+le],R=H[Q+le],W.push(B);for(let ne=1,ce=le-te+1;ne<=ce;ne++)h.lerpVectors(B,R,ne/(ce+1)),h.sub(T).setLength($[Y]).add(T),W.push(h.clone());W.push(R)}for(let le=0;le<w;le++)W.push(H[le+w+ee]);W.push(H[Q+w]);let ue=N.map(le=>W[le]);s.push(...ue.map(le=>[le.x,le.y,le.z]).flat()),u.push(...ue.map(le=>(S(le,T),[_.x,_.y,_.z])).flat())}}let q=[];for(let k=0;k<x.length;k++)for(let U=0;U<f;U++){let H=x[k][U];if(H<D){let $=x[H].findIndex(X=>X%D==k),J=F[k][U],K=F[H][$];for(let X=0;X<w;X++){let te=J[X],Y=K[w-X],ee=J[X+1],Q=K[w-(X+1)];[te,Y,ee,ee,Y,Q].forEach(W=>{s.push(W[0].x,W[0].y,W[0].z),u.push(W[1].x,W[1].y,W[1].z)})}q.push(J[0][0],K[w][0],J[w][0],K[0][0])}}for(;q.length;){let k,U,H,$;[k,U]=q.splice(0,2);let J=[k];for(;k!=U;)J.push(U),H=q.indexOf(U),$=H%2,U=q.splice(H-$,2)[1-$];_.subVectors(J[0],J[1]).cross(h.subVectors(J[0],J[2])).normalize();let K=_.dot(J[0])<0;K&&_.negate();for(let X=1;X<=J.length-2;X++)[J[X+ +K],J[X+1-+K],J[0]].forEach(te=>{s.push(te.x,te.y,te.z),u.push(_.x,_.y,_.z)})}}function d(){let p=new $o;for(let O=0;O<s.length;O+=3){p.x=s[O+0],p.y=s[O+1],p.z=s[O+2];let x=S(p)/2/Math.PI+.5,D=P(p)/Math.PI+.5;l.push(x,1-D)}let f=new $o,h=new $o,m=new $o,y=new $o,g=new Up,b=new Up,w=new Up,_=(O,x,D,N)=>{N<0&&O.x===1&&(l[x]=O.x-1),D.x===0&&D.z===0&&(l[x]=N/2/Math.PI+.5)};for(let O=0,x=0;O<s.length;O+=9,x+=6){f.set(s[O+0],s[O+1],s[O+2]),h.set(s[O+3],s[O+4],s[O+5]),m.set(s[O+6],s[O+7],s[O+8]),g.set(l[x+0],l[x+1]),b.set(l[x+2],l[x+3]),w.set(l[x+4],l[x+5]),y.copy(f).add(h).add(m).divideScalar(3);let D=S(y);_(g,x+0,f,D),_(b,x+2,h,D),_(w,x+4,m,D)}for(let O=0;O<l.length;O+=6){let x=l[O+0],D=l[O+2],N=l[O+4],T=Math.max(x,D,N),I=Math.min(x,D,N);T>.9&&I<.1&&(x<.2&&(l[O+0]+=1),D<.2&&(l[O+2]+=1),N<.2&&(l[O+4]+=1))}function S(O){return Math.atan2(O.z,-O.x)}function P(O){return Math.atan2(-O.y,Math.sqrt(O.x*O.x+O.z*O.z))}}}static fromJSON(t){return new Pn(t.vertices,t.indices,t.radius,t.corner,t.cornerSides)}};import{DodecahedronGeometry as jT}from"three";var Q0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.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:t,height:e,depth:r,detail:o,corner:i,cornerSides:a}=n.parameters,s=o===0&&i!==0?new ol(t*.5,i,a):new jT(t*.5,o);return s.scale(1,e/t,r/t),Object.assign(s,{userData:{...n,type:"DodecahedronGeometry"}})}},ol=class extends Pn{constructor(t=1,e=.2,r=4){let o=(1+Math.sqrt(5))/2,i=1/o,a=[-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],s=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],l="DodecahedronGeometry";super(a,s,l,t,e,r),this.type=l}static fromJSON(t){return new ol(t.radius,t.corner,t.cornerSides)}};import{Plane as JT,Shape as dx,Vector2 as Yo,Vector3 as eM,MathUtils as Qp,LineCurve as Kp,QuadraticBezierCurve as px,CubicBezierCurve as xu}from"three";import{CubicBezierCurve as mu,EllipseCurve as UT,LineCurve as yu,LineCurve3 as HT,MathUtils as qT,QuadraticBezierCurve as qp,SplineCurve as WT,Vector2 as Jt,Vector3 as J0}from"three";var nl=1e-12,Ta=class{constructor(t){this.position=new Jt;this.startPosition=new Jt;this.uuid=qT.generateUUID();this.position=t.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(t){this.position.copy(this.startPosition).add(t)}copy(t){return this.position.copy(t.position),this.startPosition.copy(t.startPosition),this}clone(){return new Ta(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},Ma=class extends Ta{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new Ma(this.parent).copy(this)}},Xr=class extends Ta{constructor(e,r){super(r);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new Ma(this),new Ma(this))}static create(e,r){let o=new Xr(e,new Jt(...r.position));return o.controls[0].position.set(...r.controlPrevious.position),o.controls[1].position.set(...r.controlNext.position),o.roundness=r.roundness,o.areControlsDirectionsMirrored=r.areControlsDirectionsMirrored,o}getOppositeControl(e){let r=this.controls.indexOf(e);return r===0?this.controls[1]:r===1?this.controls[0]:null}applyOffsetToControls(e,r=1){for(let o=0,i=this.controls.length;o<i;o++){let a=this.controls[o];this.position.distanceTo(a.position)<=r?a.position.copy(this.position):a.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 Xr(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),r=this.curveAfter?.getTangentAt(0);return[e,r]}computeNormals(e=new Jt,r=new Jt){let[o,i]=this.computeTangents();return o&&i&&(K0(o,e),K0(i,r)),[e,r]}computeTangent(e=new Jt){let[r,o]=this.computeTangents();return r&&o&&e.copy(r).add(o).normalize(),e}computeNormal(e=new Jt){let[r,o]=this.computeNormals();return e.copy(r).add(o).normalize(),e}};function K0(n,t=new Jt){let e=n.length();return t.set(-n.y/e,n.x/e)}var Wp=n=>n,Ia=new Jt,gu=new Jt,$T=new Jt,YT=new Jt,XT=new Jt,QT=new Jt,ex=new J0,tx=new J0;function rx(n){let t=new Jt;t.addVectors(n.v0,Ia.subVectors(n.v1,n.v0).multiplyScalar(2/3));let e=new Jt;return e.addVectors(n.v2,gu.subVectors(n.v1,n.v2).multiplyScalar(2/3)),new mu(n.v0,t,e,n.v2)}function il(n,t,e=Number.EPSILON){return Math.abs(n-t)<e}function KT(n,t,e=Number.EPSILON){return n.distanceTo(t)<e}function ZT(n,t,e=Number.EPSILON){return n.distanceTo(t)<e}function $p(n,t,e){let r=Math.sqrt(Math.pow(t.x-n.x,2)+Math.pow(t.y-n.y,2)),o=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.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+r*r-i*i)/(2*o*r))}function ox(n,t,e){return Z0(n,t)&&Z0(t,e)&&Hp(n.position,t.position,e.position)}function Hp(n,t,e){return Ia.copy(t).sub(n).cross(gu.copy(e).sub(n))===0}function nx(n,t,e,r,o){let i=Math.sqrt(Math.pow(t.x-n.x,2)+Math.pow(t.y-n.y,2)),a=(n.y+t.y)/2,s=(n.x+t.x)/2,l=Math.sqrt(Math.pow(e,2)-Math.pow(i/2,2))*(n.y-t.y)/i,u=Math.sqrt(Math.pow(e,2)-Math.pow(i/2,2))*(t.x-n.x)/i;return r.set(s+l,a+u),o.set(s-l,a-u),[r,o]}function ix(n,t,e){let r=n.distanceTo(e),o=t.distanceTo(e);return r<o?t:n}function ax(n,t,e,r,o,i){let a=t.x-n.x,s=t.y-n.y,l=e.x-n.x,u=e.y-n.y,c=Math.sqrt((a+l)*(a+l)+(s+u)*(s+u)),d;return $p(t,n,e)>Math.PI&&(c*=-1),il(u,s)?d=(s+u)*(r/c-.5)*8/3/(a-l):d=(a+l)*(r/c-.5)*8/3/(u-s),o.set(t.x-d*s,t.y+d*a),i.set(e.x+d*u,e.y-d*l),[o,i]}function Yp(n,t){return n.position.equals(n.controls[1].position)&&t.position.equals(t.controls[0].position)}function Z0(n,t){return Hp(n.position,n.controls[1].position,t.position)&&Hp(n.position,t.controls[0].position,t.position)}function sx(n,t,e,r,o=.5){let i=Ia.subVectors(t,n).multiplyScalar(o).add(n),a=gu.subVectors(e,t).multiplyScalar(o).add(t),s=$T.subVectors(r,e).multiplyScalar(o).add(e),l=i,u=YT.subVectors(a,i).multiplyScalar(o).add(i),c=XT.subVectors(s,a).multiplyScalar(o).add(a),d=s,p=QT.subVectors(c,u).multiplyScalar(o).add(u);return[n.x,n.y,l.x,l.y,u.x,u.y,p.x,p.y,c.x,c.y,d.x,d.y,r.x,r.y]}function lx(n,t,e=12,r=!0){let o=tx.set(0,0,0),i,a=0,s=[];for(let l=0;l<t.length;l++){let u=Wp(t[l]),c=Ia,d=On(u,e);s.push(d);for(let p=0;p<=d;p++)if(u instanceof mu||u instanceof qp||u instanceof yu){if(u.getPoint(p/d,c),o.set(c.x,c.y,0),i!==void 0&&ZT(i,o))continue;i===void 0&&(i=ex),i.copy(o),n.setXYZ(a,o.x,o.y,o.z),a++}}return r&&a>1&&!(n.getX(a-1)===n.getX(0)&&n.getY(a-1)===n.getY(0)&&n.getZ(a-1)===n.getZ(0))&&(n.setXYZ(a,n.getX(0),n.getY(0),n.getZ(0)),a++),n}function cx(n,t,e,r=12,o=!0){let i=tx.set(0,0,0),a=0,s=[];for(let l=0;l<t.length;l++){if(e[l]===!1)continue;let u,c=Wp(t[l]),d=Ia,p=On(c,r);s.push(p);for(let f=0;f<=p;f++)if(c instanceof mu||c instanceof qp||c instanceof yu){if(c.getPoint(f/p,d),i.set(d.x,d.y,0),u?.equals(i))continue;u===void 0?u=ex:(n.setXYZ(a,u.x,u.y,u.z),a++,n.setXYZ(a,i.x,i.y,i.z),a++),u.copy(i)}}return o&&a>1&&!(n.getX(a-1)===n.getX(0)&&n.getY(a-1)===n.getY(0)&&n.getZ(a-1)===n.getZ(0))&&(n.setXYZ(a,n.getX(0),n.getY(0),n.getZ(0)),a++),s}function Xp(n,t=12,e=!1){let r=[];for(let o=0,i=n.length;o<i;o++){let a=n[o],s=0;if(e&&a.roundedCurveCorner!==void 0){let l=On(a.roundedCurveCorner,t)*.5;o>0&&(r[o-1]+=l),s+=l}a.curveAfter!==void 0&&(s+=On(a.curveAfter,t)),r.push(s)}return n.length>0&&e&&n[0].roundedCurveCorner!==void 0&&(r[n.length-1]+=On(n[0].roundedCurveCorner,t)*.5),r}function On(n,t=12){return n&&n instanceof UT?t*2:n&&(n instanceof yu||n instanceof HT)?1:n&&n instanceof WT?t*n.points.length:t}function ux(n,t,e=12,r=!0){let o,i=0;for(let a=0;a<t.length;a++){let s=Wp(t[a]),l=On(s,e),u=Ia;for(let c=0;c<=l;c++)if(s instanceof mu||s instanceof qp||s instanceof yu){if(s.getPoint(c/l,u),o!==void 0&&KT(o,u,nl))continue;o===void 0&&(o=gu),o.copy(u),n.push(u.x,u.y),i++}}return il(n[0],n[n.length-2],nl)&&il(n[1],n[n.length-1],nl)&&(n.pop(),n.pop()),r&&i>1&&!(il(n[i-1],n[1],nl)&&il(n[i-2],n[0],nl))&&(n.push(n[0],n[1]),i++),n}var Zp=new Yo,tM=new Yo,rM=new Yo,oM=new Yo,nM=new Yo,iM=new Yo,He=class extends dx{constructor(e=100,r=100){super();this.points=[];this.shapeHoles=[];this.plane=new JT(new eM(0,0,-1));this.subdivision=0;this.controlSnapDistance=4;this.pointIDs=0;this.isMesh2D=!1;this.isText=!1;this._roundness=0;this.isClosed=!1;this.useCubicForRoundedCorners=!0;this.uuid=Qp.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=r}static createFromState(e,r,o){let i=new He;return i.isClosed=e.isClosed,i.points=e.points.map(a=>Xr.create(a.id,a.data)),typeof e.roundness=="number"&&(i.roundness=e.roundness),i.shapeHoles=e.shapeHoles.map(a=>He.createFromState(a)),r!==void 0&&o!==void 0&&i.applySize(r,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 r=0,o=this.points.length;r<o;r++)this.points[r].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(r=>this.getPointIndexById(r)).filter(r=>r>=0)}getPointIndexById(e){let r=this.points.length,o=this.points.findIndex(i=>i.uuid===e);if(o<0){let i=r;for(let a=0,s=this.shapeHoles.length;a<s;a++){let l=this.shapeHoles[a],u=l.points.length,c=l.getPointIndexById(e);if(c<0)i+=u;else return c+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 r=this.points.length;for(let o=0,i=this.shapeHoles.length;o<i;o++){let a=this.shapeHoles[o],s=e-r;if(s<=a.points.length-1)return a.points[s];r+=a.points.length}}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let r=this.points.indexOf(e);if(r>=0)return r;if(r=this.points.length,this.shapeHoles.length>0)for(let o=0,i=this.shapeHoles.length;o<i;o++){let a=this.shapeHoles[o],s=a.points.indexOf(e);if(s>=0)return r+s;r+=a.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(r=>r.points));return[...this.points,...e]}applySize(e,r){e===0&&(e=.001),r===0&&(r=.001),this._width=e,this._height=r}applyScale(e,r){let o=Zp.set(e,r);for(let i=0,a=this.points.length;i<a;i++){let s=this.points[i];s.position.multiply(o),s.controls[0].position.multiply(o),s.controls[1].position.multiply(o)}for(let i=0,a=this.shapeHoles.length;i<a;i++)this.shapeHoles[i].applyScale(e,r);this._update()}createPoint(e,r=0,o=Qp.generateUUID()){let i;e instanceof Yo?i=e:i=new Yo(e,r);let a=new Xr(o,i);return a.roundness=this.roundness,a}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,r){this.points.splice(r,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let r=0,o=this.points.length;r<o;r++){let i=this.points[r];if(i.uuid===e)return i}for(let r=0,o=this.shapeHoles.length;r<o;r++){let a=this.shapeHoles[r].getPointByUuid(e);if(a)return a}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){let r=this.points.indexOf(e);r>=0&&this.points.splice(r,1),this.needsUpdate=!0}removePointById(e){let r=this.points.find(o=>o.uuid===e);r&&this.removePoint(r)}update(){for(let e=0,r=this.shapeHoles.length;e<r;e++)this.shapeHoles[e].update();this._update()}extractShapePointsToBuffer(e,r=12,o=!1){this.subdivision=r,this.curveDivisions===void 0&&this.computeCurveDivisions(r);let i=o?this.roundedCurveDivisions:this.curveDivisions;return lx(e,o?this.roundedCurves:this.curves,r,this.autoClose),i.reduce((a,s)=>a+s,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=Xp(this.points,e,!1),this.roundedCurveDivisions=Xp(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,r,o=12){return cx(e,this.curves,r,o,this.autoClose).reduce((a,s)=>a+s,0)*2}extractShapePointsToFlatArray(e,r=12){return this.subdivision=r,this.curveDivisions===void 0&&this.computeCurveDivisions(r),ux(e,this.roundedCurves,r,this.autoClose)}getCurveIndexFromVertexId(e,r=!1){let o=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let i=r?this.roundedCurveDivisions:this.curveDivisions,a=0;r&&this.points[0].roundedCurveCorner!==void 0&&(a=On(this.points[0].roundedCurveCorner,this.subdivision)*.5);let s=e-a;s<0&&(s+=i.reduce((l,u)=>l+u,0));for(let l=0,u=i.length;l<u;l++){let c=i[l];if(s<o+c)return[l,(s-o+1)/c];o+=c}return[0,1]}getCurveT(e,r,o){let i=this.points[e],a=this.points[e>=this.points.length-1?0:e+1],s=this.curveDivisions,l=s[e];if(Yp(i,a)){let d=i.position.distanceTo(a.position);return i.position.distanceTo(Zp.set(o.x,o.y))/d}let u=0;for(let d=0;d<e;d++)u+=s[d];return(r-u)/l}dispose(){}_applyCurveForPoint(e,r){Yp(r,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(r.controls[1].position.x,r.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,r.curveAfter=o;let i=o.clone();e.roundedCurveBefore=i,r.roundedCurveAfter=i,e.roundedCurveCorner=void 0,this.roundedCurves.push(i)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let r=0,o=this.points.length;r<o;r++){let i=this.points[r];if(r===0)this.moveTo(i.position.x,i.position.y);else{let a=this.points[r-1];this._applyCurveForPoint(i,a)}}let e=this.getLastPoint();if(e?.curveAfter&&(e.curveAfter=void 0),this.isClosed){let r=this.points[0],o=this.points[this.points.length-1];this._applyCurveForPoint(r,o)}if(this.points.length>2){let r=0;for(let o=0,i=this.points.length;o<i;o++){let a=this.points[o],s=this.points[o-1]??this.points[this.points.length-1],l=this.points[o+1]??this.points[0],u=a.roundness,c=s&&l&&ox(s,a,l);if(!a.controlsMoved()&&u>0&&!c){let d=a.curveBefore,p=a.curveAfter;if(d===void 0||p===void 0)continue;let f=a.roundedCurveBefore,h=a.roundedCurveAfter,m=d.getLength(),y=p.getLength(),g=Math.min(u,m*.499),b=Math.min(u,y*.499),w=Math.min(g,b),_=1-w/m,S=w/y,P=d.getPointAt(_,Zp),O=p.getPointAt(S,tM);this._subSplitCurve(d,f,_,P,void 0),this._subSplitCurve(p,h,S,void 0,O);let x;if(this.useCubicForRoundedCorners){let D=$p(P,a.position,O)/2,N=Math.tan(D)*P.distanceTo(a.position),[T,I]=nx(P,O,N,rM,oM),E=ix(T,I,a.position),[B,R]=ax(E,P,O,N,nM,iM);x=new xu(P.clone(),B.clone(),R.clone(),O.clone())}else x=new px(P.clone(),a.position.clone(),O.clone());a.roundedCurveCorner=x,this.roundedCurves.splice(o+r,0,x),r++}}}}_subSplitCurve(e,r,o,i,a){if(e instanceof Kp)i!==void 0&&r.v2.copy(i),a!==void 0&&r.v1.copy(a);else{let s=e,l=r,u=s.getUtoTmapping(o,0),c=sx(s.v0,s.v1,s.v2,s.v3,u);return i!==void 0&&(l.v0.set(c[0],c[1]),l.v1.set(c[2],c[3]),l.v2.set(c[4],c[5]),l.v3.set(c[6],c[7])),a!==void 0&&(l.v0.set(c[6],c[7]),l.v1.set(c[8],c[9]),l.v2.set(c[10],c[11]),l.v3.set(c[12],c[13])),l}return r}clone(){let e=new He(this._width,this._height);return e.points=this.points.map(r=>r.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(r=>r.clone()),e}toJSON(){return{points:this.points.reduce((e,r)=>e.concat(r.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){this.points=[],this.pointIDs=0;let r=e.points.length/7;for(let o=0;o<r;o++){let i=o*7,a=e.points[i+0],s=e.points[i+1],l=e.points[i+2],u=e.points[i+3],c=e.points[i+4],d=e.points[i+5],p=e.points[i+6],f=new Xr(Qp.generateUUID(),new Yo(a,s));f.controls[0].position.set(l,u),f.controls[1].position.set(c,d),f.roundness=p,this.points.push(f)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(o=>{let i=new He;return i.fromJSON(o),i}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e,r=!1){this.isText=r;let o=(a,s)=>{s instanceof xu&&s.v3.equals(a.position)&&a.controls[0].position.copy(s.v2)},i=a=>{let s=[],l,u;for(l=0,u=a.length;l<u;l++)a[l]instanceof px&&(a[l]=rx(a[l]));for(l=0,u=a.length;l<u;l++){let p=a[l],f=l>0?a[l-1]:null,h;p instanceof xu?(h=this.createPoint(p.v0),h.controls[1].position.copy(p.v1)):p instanceof Kp&&(h=this.createPoint(p.v1)),h!==void 0&&(f!==null&&o(h,f),s.push(h))}let c=a[a.length-1],d=!1;return c instanceof xu?c.v3.equals(s[0].position)&&(s[0].controls[0].position.copy(c.v2),d=!0):c instanceof Kp&&c.v2.equals(s[0].position)&&(d=!0),this.isClosed=d,s};return this.points=i(e.curves),e instanceof dx&&(this.shapeHoles=e.holes.map(a=>{let s=new He;return s.fromShape(a),s})),this.update(),this}updatePoint(e,r){let o=this.getPointByUuid(e);o&&(r.position!==void 0&&o.position.fromArray(r.position),r.roundness!==void 0&&(o.roundness=r.roundness),r.areControlsDirectionsMirrored!==void 0&&(o.areControlsDirectionsMirrored=r.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(e,r){let i=this.getPointByUuid(e)?.controls[0];i&&(r.position&&i.position.fromArray(r.position),this.needsUpdate=!0)}updateNextControl(e,r){let i=this.getPointByUuid(e)?.controls[1];i&&(r.position&&i.position.fromArray(r.position),this.needsUpdate=!0)}};var ef=Math.PI*2;function Jp({x:n,y:t},e,r,o,i){return{x:n*e+o,y:t*r+i}}function aM(n,t){let e=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),r=Math.cos(n),o=Math.sin(n),i=Math.cos(n+t),a=Math.sin(n+t);return[{x:r-o*e,y:o+r*e},{x:i+a*e,y:a-i*e},{x:i,y:a}]}function fx(n,t,e,r){let o=n*r-t*e<0?-1:1,i=Math.min(1,Math.max(-1,n*e+t*r));return o*Math.acos(i)}function sM(n,t,e,r,o,i,a,s,l,u){let c=Math.pow(o,2),d=Math.pow(i,2),p=Math.pow(a,2),f=Math.pow(s,2),h=c*d-c*f-d*p;h<0&&(h=0),h/=c*f+d*p,h=Math.sqrt(h)*(l===u?-1:1);let m=h*o/i*s,y=h*-i/o*a,g=m+(n+e)/2,b=y+(t+r)/2,w=(a-m)/o,_=(s-y)/i,S=(-a-m)/o,P=(-s-y)/i,O=fx(1,0,w,_),x=fx(w,_,S,P);return!u&&x>0&&(x-=ef),u&&x<0&&(x+=ef),{centerx:g,centery:b,ang1:O,ang2:x}}function hx({px:n,py:t,cx:e,cy:r,rx:o,ry:i,largeArcFlag:a,sweepFlag:s}){let l=[];if(o===0||i===0)return[];let u=(n-e)/2,c=(t-r)/2;if(u===0&&c===0)return[];o=Math.abs(o),i=Math.abs(i);let d=Math.pow(u,2)/Math.pow(o,2)+Math.pow(c,2)/Math.pow(i,2);d>1&&(o*=Math.sqrt(d),i*=Math.sqrt(d));let p=sM(n,t,e,r,o,i,u,c,a,s),{ang1:f,ang2:h}=p,{centerx:m,centery:y}=p,g=Math.abs(h)/(ef/4);Math.abs(1-g)<1e-7&&(g=1);let b=Math.max(Math.ceil(g),1);h/=b;for(let w=0;w<b;w++)l.push(aM(f,h)),f+=h;return l.map(w=>{let{x:_,y:S}=Jp(w[0],o,i,m,y),{x:P,y:O}=Jp(w[1],o,i,m,y),{x,y:D}=Jp(w[2],o,i,m,y);return{x1:_,y1:S,x2:P,y2:O,x,y:D}})}import{BufferAttribute as Au,BufferGeometry as bM}from"three";var je;(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"})(je||(je={}));var dt;(function(n){n[n.POLYGONS=0]="POLYGONS",n[n.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",n[n.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(dt||(dt={}));function Ae(n,t){if(!n)throw t||"Assertion Failed!"}var ve=function(){function n(){}return n.vertEq=function(t,e){return t.s===e.s&&t.t===e.t},n.vertLeq=function(t,e){return t.s<e.s||t.s===e.s&&t.t<=e.t},n.transLeq=function(t,e){return t.t<e.t||t.t===e.t&&t.s<=e.s},n.edgeGoesLeft=function(t){return n.vertLeq(t.Dst,t.Org)},n.edgeGoesRight=function(t){return n.vertLeq(t.Org,t.Dst)},n.vertL1dist=function(t,e){return Math.abs(t.s-e.s)+Math.abs(t.t-e.t)},n.edgeEval=function(t,e,r){Ae(n.vertLeq(t,e)&&n.vertLeq(e,r));var o=e.s-t.s,i=r.s-e.s;return o+i>0?o<i?e.t-t.t+(t.t-r.t)*(o/(o+i)):e.t-r.t+(r.t-t.t)*(i/(o+i)):0},n.edgeSign=function(t,e,r){Ae(n.vertLeq(t,e)&&n.vertLeq(e,r));var o=e.s-t.s,i=r.s-e.s;return o+i>0?(e.t-r.t)*o+(e.t-t.t)*i:0},n.transEval=function(t,e,r){Ae(n.transLeq(t,e)&&n.transLeq(e,r));var o=e.t-t.t,i=r.t-e.t;return o+i>0?o<i?e.s-t.s+(t.s-r.s)*(o/(o+i)):e.s-r.s+(r.s-t.s)*(i/(o+i)):0},n.transSign=function(t,e,r){Ae(n.transLeq(t,e)&&n.transLeq(e,r));var o=e.t-t.t,i=r.t-e.t;return o+i>0?(e.s-r.s)*o+(e.s-t.s)*i:0},n.vertCCW=function(t,e,r){return t.s*(e.t-r.t)+e.s*(r.t-t.t)+r.s*(t.t-e.t)>=0},n.interpolate=function(t,e,r,o){return t=t<0?0:t,r=r<0?0:r,t<=r?r===0?(e+o)/2:e+(o-e)*(t/(t+r)):o+(e-o)*(r/(t+r))},n.intersect=function(t,e,r,o,i){var a,s,l;n.vertLeq(t,e)||(l=t,t=e,e=l),n.vertLeq(r,o)||(l=r,r=o,o=l),n.vertLeq(t,r)||(l=t,t=r,r=l,l=e,e=o,o=l),n.vertLeq(r,e)?n.vertLeq(e,o)?(a=n.edgeEval(t,r,e),s=n.edgeEval(r,e,o),a+s<0&&(a=-a,s=-s),i.s=n.interpolate(a,r.s,s,e.s)):(a=n.edgeSign(t,r,e),s=-n.edgeSign(t,o,e),a+s<0&&(a=-a,s=-s),i.s=n.interpolate(a,r.s,s,o.s)):i.s=(r.s+e.s)/2,n.transLeq(t,e)||(l=t,t=e,e=l),n.transLeq(r,o)||(l=r,r=o,o=l),n.transLeq(t,r)||(l=t,t=r,r=l,l=e,e=o,o=l),n.transLeq(r,e)?n.transLeq(e,o)?(a=n.transEval(t,r,e),s=n.transEval(r,e,o),a+s<0&&(a=-a,s=-s),i.t=n.interpolate(a,r.t,s,e.t)):(a=n.transSign(t,r,e),s=-n.transSign(t,o,e),a+s<0&&(a=-a,s=-s),i.t=n.interpolate(a,r.t,s,o.t)):i.t=(r.t+e.t)/2},n}(),al=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}(),bu=function(){function n(t){this.side=t,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(t){this.Sym.Lface=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(t){this.Sym.Org=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(t){this.Sym.Lnext=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(t){this.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(t){this.Lnext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(t){this.Sym.Onext=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(t){this.Sym.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(t){this.Sym.Lnext.Sym=t},enumerable:!0,configurable:!0}),n}(),Na=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}(),mx=function(){function n(){var t=new Na,e=new al,r=new bu(0),o=new bu(1);t.next=t.prev=t,t.anEdge=null,e.next=e.prev=e,r.next=r,r.Sym=o,o.next=o,o.Sym=r,this.vHead=t,this.fHead=e,this.eHead=r,this.eHeadSym=o}return n.prototype.makeEdge_=function(t){var e=new bu(0),r=new bu(1);t.Sym.side<t.side&&(t=t.Sym);var o=t.Sym.next;return r.next=o,o.Sym.next=e,e.next=t,t.Sym.next=r,e.Sym=r,e.Onext=e,e.Lnext=r,e.Org=null,e.Lface=null,e.winding=0,e.activeRegion=null,r.Sym=e,r.Onext=r,r.Lnext=e,r.Org=null,r.Lface=null,r.winding=0,r.activeRegion=null,e},n.prototype.splice_=function(t,e){var r=t.Onext,o=e.Onext;r.Sym.Lnext=e,o.Sym.Lnext=t,t.Onext=o,e.Onext=r},n.prototype.makeVertex_=function(t,e,r){var o=t;Ae(o,"Vertex can't be null!");var i=r.prev;o.prev=i,i.next=o,o.next=r,r.prev=o,o.anEdge=e;var a=e;do a.Org=o,a=a.Onext;while(a!==e)},n.prototype.makeFace_=function(t,e,r){var o=t;Ae(o,"Face can't be null");var i=r.prev;o.prev=i,i.next=o,o.next=r,r.prev=o,o.anEdge=e,o.trail=null,o.marked=!1,o.inside=r.inside;var a=e;do a.Lface=o,a=a.Lnext;while(a!==e)},n.prototype.killEdge_=function(t){t.Sym.side<t.side&&(t=t.Sym);var e=t.next,r=t.Sym.next;e.Sym.next=r,r.Sym.next=e},n.prototype.killVertex_=function(t,e){var r=t.anEdge,o=r;do o.Org=e,o=o.Onext;while(o!==r);var i=t.prev,a=t.next;a.prev=i,i.next=a},n.prototype.killFace_=function(t,e){var r=t.anEdge,o=r;do o.Lface=e,o=o.Lnext;while(o!==r);var i=t.prev,a=t.next;a.prev=i,i.next=a},n.prototype.makeEdge=function(){var t=new Na,e=new Na,r=new al,o=this.makeEdge_(this.eHead);return this.makeVertex_(t,o,this.vHead),this.makeVertex_(e,o.Sym,this.vHead),this.makeFace_(r,o,this.fHead),o},n.prototype.splice=function(t,e){var r=!1,o=!1;if(t!==e){if(e.Org!==t.Org&&(o=!0,this.killVertex_(e.Org,t.Org)),e.Lface!==t.Lface&&(r=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(e,t),!o){var i=new Na;this.makeVertex_(i,e,t.Org),t.Org.anEdge=t}if(!r){var a=new al;this.makeFace_(a,e,t.Lface),t.Lface.anEdge=t}}},n.prototype.delete=function(t){var e=t.Sym,r=!1;if(t.Lface!==t.Rface&&(r=!0,this.killFace_(t.Lface,t.Rface)),t.Onext===t)this.killVertex_(t.Org,null);else if(t.Rface.anEdge=t.Oprev,t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev),!r){var o=new al;this.makeFace_(o,t,t.Lface)}e.Onext===e?(this.killVertex_(e.Org,null),this.killFace_(e.Lface,null)):(t.Lface.anEdge=e.Oprev,e.Org.anEdge=e.Onext,this.splice_(e,e.Oprev)),this.killEdge_(t)},n.prototype.addEdgeVertex=function(t){var e=this.makeEdge_(t),r=e.Sym;this.splice_(e,t.Lnext),e.Org=t.Dst;var o=new Na;return this.makeVertex_(o,r,e.Org),e.Lface=r.Lface=t.Lface,e},n.prototype.splitEdge=function(t){var e=this.addEdgeVertex(t),r=e.Sym;return this.splice_(t.Sym,t.Sym.Oprev),this.splice_(t.Sym,r),t.Dst=r.Org,r.Dst.anEdge=r.Sym,r.Rface=t.Rface,r.winding=t.winding,r.Sym.winding=t.Sym.winding,r.idx=t.idx,r.Sym.idx=t.Sym.idx,r},n.prototype.connect=function(t,e){var r=!1,o=this.makeEdge_(t),i=o.Sym;if(e.Lface!==t.Lface&&(r=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(o,t.Lnext),this.splice_(i,e),o.Org=t.Dst,i.Org=e.Org,o.Lface=i.Lface=t.Lface,t.Lface.anEdge=i,!r){var a=new al;this.makeFace_(a,o,t.Lface)}return o},n.prototype.zapFace=function(t){var e=t.anEdge,r,o,i,a,s;o=e.Lnext;do r=o,o=r.Lnext,r.Lface=null,r.Rface===null&&(r.Onext===r?this.killVertex_(r.Org,null):(r.Org.anEdge=r.Onext,this.splice_(r,r.Oprev)),i=r.Sym,i.Onext===i?this.killVertex_(i.Org,null):(i.Org.anEdge=i.Onext,this.splice_(i,i.Oprev)),this.killEdge_(r));while(r!=e);a=t.prev,s=t.next,s.prev=a,a.next=s},n.prototype.countFaceVerts_=function(t){var e=t.anEdge,r=0;do r++,e=e.Lnext;while(e!==t.anEdge);return r},n.prototype.mergeConvexFaces=function(t){var e,r,o,i,a,s,l;for(e=this.fHead.next;e!==this.fHead;e=e.next)if(!!e.inside)for(r=e.anEdge,a=r.Org;o=r.Lnext,i=r.Sym,i&&i.Lface&&i.Lface.inside&&(s=this.countFaceVerts_(e),l=this.countFaceVerts_(i.Lface),s+l-2<=t&&ve.vertCCW(r.Lprev.Org,r.Org,i.Lnext.Lnext.Org)&&ve.vertCCW(i.Lprev.Org,i.Org,r.Lnext.Lnext.Org)&&(o=i.Lnext,this.delete(i),r=null,i=null)),!(r&&r.Lnext.Org===a);)r=o;return!0},n.prototype.check=function(){var t=this.fHead,e=this.vHead,r=this.eHead,o,i,a,s,l,u;for(i=t,i=t;(o=i.next)!==t;i=o){Ae(o.prev===i),l=o.anEdge;do Ae(l.Sym!==l),Ae(l.Sym.Sym===l),Ae(l.Lnext.Onext.Sym===l),Ae(l.Onext.Sym.Lnext===l),Ae(l.Lface===o),l=l.Lnext;while(l!==o.anEdge)}for(Ae(o.prev===i&&o.anEdge===null),s=e,s=e;(a=s.next)!==e;s=a){Ae(a.prev===s),l=a.anEdge;do Ae(l.Sym!==l),Ae(l.Sym.Sym===l),Ae(l.Lnext.Onext.Sym===l),Ae(l.Onext.Sym.Lnext===l),Ae(l.Org===a),l=l.Onext;while(l!==a.anEdge)}for(Ae(a.prev===s&&a.anEdge===null),u=r,u=r;(l=u.next)!==r;u=l)Ae(l.Sym.next===u.Sym),Ae(l.Sym!==l),Ae(l.Sym.Sym===l),Ae(l.Org!==null),Ae(l.Dst!==null),Ae(l.Lnext.Onext.Sym===l),Ae(l.Onext.Sym.Lnext===l);Ae(l.Sym.next===u.Sym&&l.Sym===this.eHeadSym&&l.Sym.Sym===l&&l.Org===null&&l.Dst===null&&l.Lface===null&&l.Rface===null)},n}(),yx=function(){function n(){this.handle=null}return n}(),gx=function(){function n(){this.key=null,this.node=0}return n}(),lM=function(){function n(t,e){this.leq=e,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=t,this.nodes=[],this.handles=[];for(var r=0;r<t+1;r++)this.nodes[r]=new yx,this.handles[r]=new gx;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return n.prototype.floatDown_=function(t){var e=this.nodes,r=this.handles,o,i,a;for(o=e[t].handle;;){if(a=t<<1,a<this.size&&this.leq(r[e[a+1].handle].key,r[e[a].handle].key)&&++a,Ae(a<=this.max),i=e[a].handle,a>this.size||this.leq(r[o].key,r[i].key)){e[t].handle=o,r[o].node=t;break}e[t].handle=i,r[i].node=t,t=a}},n.prototype.floatUp_=function(t){var e=this.nodes,r=this.handles,o,i,a;for(o=e[t].handle;;){if(a=t>>1,i=e[a].handle,a===0||this.leq(r[i].key,r[o].key)){e[t].handle=o,r[o].node=t;break}e[t].handle=i,r[i].node=t,t=a}},n.prototype.init=function(){for(var t=this.size;t>=1;--t)this.floatDown_(t);this.initialized=!0},n.prototype.min=function(){return this.handles[this.nodes[1].handle].key},n.prototype.insert=function(t){var e,r;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 yx;for(i=this.handles.length,this.handles.length=this.max+1,o=i;o<this.handles.length;o++)this.handles[o]=new gx}return this.freeList===0?r=e:(r=this.freeList,this.freeList=this.handles[r].node),this.nodes[e].handle=r,this.handles[r].node=e,this.handles[r].key=t,this.initialized&&this.floatUp_(e),r},n.prototype.extractMin=function(){var t=this.nodes,e=this.handles,r=t[1].handle,o=e[r].key;return this.size>0&&(t[1].handle=t[this.size].handle,e[t[1].handle].node=1,e[r].key=null,e[r].node=this.freeList,this.freeList=r,--this.size,this.size>0&&this.floatDown_(1)),o},n.prototype.delete=function(t){var e=this.nodes,r=this.handles,o;Ae(t>=1&&t<=this.max&&r[t].key!==null),o=r[t].node,e[o].handle=e[this.size].handle,r[e[o].handle].node=o,--this.size,o<=this.size&&(o<=1||this.leq(r[e[o>>1].handle].key,r[e[o].handle].key)?this.floatDown_(o):this.floatUp_(o)),r[t].key=null,r[t].node=this.freeList,this.freeList=t},n}(),tf=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}(),xx=function(){function n(){this.key=null,this.next=null,this.prev=null}return n}(),cM=function(){function n(t,e){this.frame=t,this.leq=e,this.head=new xx,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(t){return this.insertBefore(this.head,t)},n.prototype.search=function(t){var e=this.head;do e=e.next;while(e.key!==null&&!this.leq(this.frame,t,e.key));return e},n.prototype.insertBefore=function(t,e){do t=t.prev;while(t.key!==null&&!this.leq(this.frame,t.key,e));var r=new xx;return r.key=e,r.next=t.next,t.next.prev=r,r.prev=t,t.next=r,r},n.prototype.delete=function(t){t.next.prev=t.prev,t.prev.next=t.next},n}(),uM=function(){function n(){}return n.regionBelow=function(t){return t.nodeUp.prev.key},n.regionAbove=function(t){return t.nodeUp.next.key},n.debugEvent=function(t){},n.addWinding=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},n.edgeLeq=function(t,e,r){var o=t.event,i=e.eUp,a=r.eUp;if(i.Dst===o)return a.Dst===o?ve.vertLeq(i.Org,a.Org)?ve.edgeSign(a.Dst,i.Org,a.Org)<=0:ve.edgeSign(i.Dst,a.Org,i.Org)>=0:ve.edgeSign(a.Dst,o,a.Org)<=0;if(a.Dst===o)return ve.edgeSign(i.Dst,o,i.Org)>=0;var s=ve.edgeEval(i.Dst,o,i.Org),l=ve.edgeEval(a.Dst,o,a.Org);return s>=l},n.deleteRegion=function(t,e){e.fixUpperEdge&&Ae(e.eUp.winding===0),e.eUp.activeRegion=null,t.dict.delete(e.nodeUp)},n.fixUpperEdge=function(t,e,r){Ae(e.fixUpperEdge),t.mesh.delete(e.eUp),e.fixUpperEdge=!1,e.eUp=r,r.activeRegion=e},n.topLeftRegion=function(t,e){var r=e.eUp.Org,o;do e=n.regionAbove(e);while(e.eUp.Org===r);if(e.fixUpperEdge){if(o=t.mesh.connect(n.regionBelow(e).eUp.Sym,e.eUp.Lnext),o===null)return null;n.fixUpperEdge(t,e,o),e=n.regionAbove(e)}return e},n.topRightRegion=function(t){var e=t.eUp.Dst;do t=n.regionAbove(t);while(t.eUp.Dst===e);return t},n.addRegionBelow=function(t,e,r){var o=new tf;return o.eUp=r,o.nodeUp=t.dict.insertBefore(e.nodeUp,o),o.fixUpperEdge=!1,o.sentinel=!1,o.dirty=!1,r.activeRegion=o,o},n.isWindingInside=function(t,e){switch(t.windingRule){case je.ODD:return(e&1)!==0;case je.NONZERO:return e!==0;case je.POSITIVE:return e>0;case je.NEGATIVE:return e<0;case je.ABS_GEQ_TWO:return e>=2||e<=-2}throw new Error("Invalid winding rulle")},n.computeWinding=function(t,e){e.windingNumber=n.regionAbove(e).windingNumber+e.eUp.winding,e.inside=n.isWindingInside(t,e.windingNumber)},n.finishRegion=function(t,e){var r=e.eUp,o=r.Lface;o.inside=e.inside,o.anEdge=r,n.deleteRegion(t,e)},n.finishLeftRegions=function(t,e,r){for(var o,i=null,a=e,s=e.eUp;a!==r;){if(a.fixUpperEdge=!1,i=n.regionBelow(a),o=i.eUp,o.Org!=s.Org){if(!i.fixUpperEdge){n.finishRegion(t,a);break}o=t.mesh.connect(s.Lprev,o.Sym),n.fixUpperEdge(t,i,o)}s.Onext!==o&&(t.mesh.splice(o.Oprev,o),t.mesh.splice(s,o)),n.finishRegion(t,a),s=i.eUp,a=i}return s},n.addRightEdges=function(t,e,r,o,i,a){var s,l,u,c,d=!0;u=r;do Ae(ve.vertLeq(u.Org,u.Dst)),n.addRegionBelow(t,e,u.Sym),u=u.Onext;while(u!==o);for(i===null&&(i=n.regionBelow(e).eUp.Rprev),l=e,c=i;s=n.regionBelow(l),u=s.eUp.Sym,u.Org===c.Org;)u.Onext!==c&&(t.mesh.splice(u.Oprev,u),t.mesh.splice(c.Oprev,u)),s.windingNumber=l.windingNumber-u.winding,s.inside=n.isWindingInside(t,s.windingNumber),l.dirty=!0,!d&&n.checkForRightSplice(t,l)&&(n.addWinding(u,c),n.deleteRegion(t,l),t.mesh.delete(c)),d=!1,l=s,c=u;l.dirty=!0,Ae(l.windingNumber-u.winding===s.windingNumber),a&&n.walkDirtyRegions(t,l)},n.spliceMergeVertices=function(t,e,r){t.mesh.splice(e,r)},n.vertexWeights=function(t,e,r){var o=ve.vertL1dist(e,t),i=ve.vertL1dist(r,t),a=.5*i/(o+i),s=.5*o/(o+i);t.coords[0]+=a*e.coords[0]+s*r.coords[0],t.coords[1]+=a*e.coords[1]+s*r.coords[1],t.coords[2]+=a*e.coords[2]+s*r.coords[2]},n.getIntersectData=function(t,e,r,o,i,a){e.coords[0]=e.coords[1]=e.coords[2]=0,e.idx=-1,n.vertexWeights(e,r,o),n.vertexWeights(e,i,a)},n.checkForRightSplice=function(t,e){var r=n.regionBelow(e),o=e.eUp,i=r.eUp;if(ve.vertLeq(o.Org,i.Org)){if(ve.edgeSign(i.Dst,o.Org,i.Org)>0)return!1;ve.vertEq(o.Org,i.Org)?o.Org!==i.Org&&(t.pq.delete(o.Org.pqHandle),n.spliceMergeVertices(t,i.Oprev,o)):(t.mesh.splitEdge(i.Sym),t.mesh.splice(o,i.Oprev),e.dirty=r.dirty=!0)}else{if(ve.edgeSign(o.Dst,i.Org,o.Org)<0)return!1;n.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(o.Sym),t.mesh.splice(i.Oprev,o)}return!0},n.checkForLeftSplice=function(t,e){var r=n.regionBelow(e),o=e.eUp,i=r.eUp,a;if(Ae(!ve.vertEq(o.Dst,i.Dst)),ve.vertLeq(o.Dst,i.Dst)){if(ve.edgeSign(o.Dst,i.Dst,o.Org)<0)return!1;n.regionAbove(e).dirty=e.dirty=!0,a=t.mesh.splitEdge(o),t.mesh.splice(i.Sym,a),a.Lface.inside=e.inside}else{if(ve.edgeSign(i.Dst,o.Dst,i.Org)>0)return!1;e.dirty=r.dirty=!0,a=t.mesh.splitEdge(i),t.mesh.splice(o.Lnext,i.Sym),a.Rface.inside=e.inside}return!0},n.checkForIntersect=function(t,e){var r=n.regionBelow(e),o=e.eUp,i=r.eUp,a=o.Org,s=i.Org,l=o.Dst,u=i.Dst,c,d,p=new Na,f,h;if(Ae(!ve.vertEq(u,l)),Ae(ve.edgeSign(l,t.event,a)<=0),Ae(ve.edgeSign(u,t.event,s)>=0),Ae(a!==t.event&&s!==t.event),Ae(!e.fixUpperEdge&&!r.fixUpperEdge),a===s||(c=Math.min(a.t,l.t),d=Math.max(s.t,u.t),c>d))return!1;if(ve.vertLeq(a,s)){if(ve.edgeSign(u,a,s)>0)return!1}else if(ve.edgeSign(l,s,a)<0)return!1;return n.debugEvent(t),ve.intersect(l,a,u,s,p),Ae(Math.min(a.t,l.t)<=p.t),Ae(p.t<=Math.max(s.t,u.t)),Ae(Math.min(u.s,l.s)<=p.s),Ae(p.s<=Math.max(s.s,a.s)),ve.vertLeq(p,t.event)&&(p.s=t.event.s,p.t=t.event.t),f=ve.vertLeq(a,s)?a:s,ve.vertLeq(f,p)&&(p.s=f.s,p.t=f.t),ve.vertEq(p,a)||ve.vertEq(p,s)?(n.checkForRightSplice(t,e),!1):!ve.vertEq(l,t.event)&&ve.edgeSign(l,t.event,p)>=0||!ve.vertEq(u,t.event)&&ve.edgeSign(u,t.event,p)<=0?u===t.event?(t.mesh.splitEdge(o.Sym),t.mesh.splice(i.Sym,o),e=n.topLeftRegion(t,e),o=n.regionBelow(e).eUp,n.finishLeftRegions(t,n.regionBelow(e),r),n.addRightEdges(t,e,o.Oprev,o,o,!0),!0):l===t.event?(t.mesh.splitEdge(i.Sym),t.mesh.splice(o.Lnext,i.Oprev),r=e,e=n.topRightRegion(e),h=n.regionBelow(e).eUp.Rprev,r.eUp=i.Oprev,i=n.finishLeftRegions(t,r,null),n.addRightEdges(t,e,i.Onext,o.Rprev,h,!0),!0):(ve.edgeSign(l,t.event,p)>=0&&(n.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(o.Sym),o.Org.s=t.event.s,o.Org.t=t.event.t),ve.edgeSign(u,t.event,p)<=0&&(e.dirty=r.dirty=!0,t.mesh.splitEdge(i.Sym),i.Org.s=t.event.s,i.Org.t=t.event.t),!1):(t.mesh.splitEdge(o.Sym),t.mesh.splitEdge(i.Sym),t.mesh.splice(i.Oprev,o),o.Org.s=p.s,o.Org.t=p.t,o.Org.pqHandle=t.pq.insert(o.Org),n.getIntersectData(t,o.Org,a,l,s,u),n.regionAbove(e).dirty=e.dirty=r.dirty=!0,!1)},n.walkDirtyRegions=function(t,e){for(var r=n.regionBelow(e),o,i;;){for(;r.dirty;)e=r,r=n.regionBelow(r);if(!e.dirty&&(r=e,e=n.regionAbove(e),e===null||!e.dirty))return;if(e.dirty=!1,o=e.eUp,i=r.eUp,o.Dst!==i.Dst&&n.checkForLeftSplice(t,e)&&(r.fixUpperEdge?(n.deleteRegion(t,r),t.mesh.delete(i),r=n.regionBelow(e),i=r.eUp):e.fixUpperEdge&&(n.deleteRegion(t,e),t.mesh.delete(o),e=n.regionAbove(r),o=e.eUp)),o.Org!==i.Org)if(o.Dst!==i.Dst&&!e.fixUpperEdge&&!r.fixUpperEdge&&(o.Dst===t.event||i.Dst===t.event)){if(n.checkForIntersect(t,e))return}else n.checkForRightSplice(t,e);o.Org===i.Org&&o.Dst===i.Dst&&(n.addWinding(i,o),n.deleteRegion(t,e),t.mesh.delete(o),e=n.regionAbove(r))}},n.connectRightVertex=function(t,e,r){var o,i=r.Onext,a=n.regionBelow(e),s=e.eUp,l=a.eUp,u=!1;if(s.Dst!==l.Dst&&n.checkForIntersect(t,e),ve.vertEq(s.Org,t.event)&&(t.mesh.splice(i.Oprev,s),e=n.topLeftRegion(t,e),i=n.regionBelow(e).eUp,n.finishLeftRegions(t,n.regionBelow(e),a),u=!0),ve.vertEq(l.Org,t.event)&&(t.mesh.splice(r,l.Oprev),r=n.finishLeftRegions(t,a,null),u=!0),u){n.addRightEdges(t,e,r.Onext,i,i,!0);return}ve.vertLeq(l.Org,s.Org)?o=l.Oprev:o=s,o=t.mesh.connect(r.Lprev,o),n.addRightEdges(t,e,o,o.Onext,o.Onext,!1),o.Sym.activeRegion.fixUpperEdge=!0,n.walkDirtyRegions(t,e)},n.connectLeftDegenerate=function(t,e,r){var o,i,a,s,l;if(o=e.eUp,ve.vertEq(o.Org,r)){Ae(!1),n.spliceMergeVertices(t,o,r.anEdge);return}if(!ve.vertEq(o.Dst,r)){t.mesh.splitEdge(o.Sym),e.fixUpperEdge&&(t.mesh.delete(o.Onext),e.fixUpperEdge=!1),t.mesh.splice(r.anEdge,o),n.sweepEvent(t,r);return}Ae(!1),e=n.topRightRegion(e),l=n.regionBelow(e),a=l.eUp.Sym,i=s=a.Onext,l.fixUpperEdge&&(Ae(i!==a),n.deleteRegion(t,l),t.mesh.delete(a),a=i.Oprev),t.mesh.splice(r.anEdge,a),ve.edgeGoesLeft(i)||(i=null),n.addRightEdges(t,e,a.Onext,s,i,!0)},n.connectLeftVertex=function(t,e){var r,o,i,a,s,l,u=new tf;if(u.eUp=e.anEdge.Sym,r=t.dict.search(u).key,o=n.regionBelow(r),!!o){if(a=r.eUp,s=o.eUp,ve.edgeSign(a.Dst,e,a.Org)===0){n.connectLeftDegenerate(t,r,e);return}if(i=ve.vertLeq(s.Dst,a.Dst)?r:o,r.inside||i.fixUpperEdge){if(i===r)l=t.mesh.connect(e.anEdge.Sym,a.Lnext);else{var c=t.mesh.connect(s.Dnext,e.anEdge);l=c.Sym}i.fixUpperEdge?n.fixUpperEdge(t,i,l):n.computeWinding(t,n.addRegionBelow(t,r,l)),n.sweepEvent(t,e)}else n.addRightEdges(t,r,e.anEdge,e.anEdge,null,!0)}},n.sweepEvent=function(t,e){t.event=e,n.debugEvent(t);for(var r=e.anEdge;r.activeRegion===null;)if(r=r.Onext,r===e.anEdge){n.connectLeftVertex(t,e);return}var o=n.topLeftRegion(t,r.activeRegion);Ae(o!==null);var i=n.regionBelow(o),a=i.eUp,s=n.finishLeftRegions(t,i,null);s.Onext===a?n.connectRightVertex(t,o,s):n.addRightEdges(t,o,s.Onext,a,a,!0)},n.addSentinel=function(t,e,r,o){var i=new tf,a=t.mesh.makeEdge();a.Org.s=r,a.Org.t=o,a.Dst.s=e,a.Dst.t=o,t.event=a.Dst,i.eUp=a,i.windingNumber=0,i.inside=!1,i.fixUpperEdge=!1,i.sentinel=!0,i.dirty=!1,i.nodeUp=t.dict.insert(i)},n.initEdgeDict=function(t){t.dict=new cM(t,n.edgeLeq);var e=t.bmax[0]-t.bmin[0],r=t.bmax[1]-t.bmin[1],o=t.bmin[0]-e,i=t.bmax[0]+e,a=t.bmin[1]-r,s=t.bmax[1]+r;n.addSentinel(t,o,i,a),n.addSentinel(t,o,i,s)},n.doneEdgeDict=function(t){for(var e,r=0;(e=t.dict.min().key)!==null;)e.sentinel||(Ae(e.fixUpperEdge),Ae(++r===1)),Ae(e.windingNumber===0),n.deleteRegion(t,e)},n.removeDegenerateEdges=function(t){var e,r,o,i=t.mesh.eHead;for(e=i.next;e!==i;e=r)r=e.next,o=e.Lnext,ve.vertEq(e.Org,e.Dst)&&e.Lnext.Lnext!==e&&(n.spliceMergeVertices(t,o,e),t.mesh.delete(e),e=o,o=e.Lnext),o.Lnext===e&&(o!==e&&((o===r||o===r.Sym)&&(r=r.next),t.mesh.delete(o)),(e===r||e===r.Sym)&&(r=r.next),t.mesh.delete(e))},n.initPriorityQ=function(t){var e,r,o,i=0;for(o=t.mesh.vHead,r=o.next;r!==o;r=r.next)i++;for(i+=8,e=t.pq=new lM(i,ve.vertLeq),o=t.mesh.vHead,r=o.next;r!==o;r=r.next)r.pqHandle=e.insert(r);return r!==o?!1:(e.init(),!0)},n.donePriorityQ=function(t){t.pq=null},n.removeDegenerateFaces=function(t,e){var r,o,i;for(r=e.fHead.next;r!==e.fHead;r=o)o=r.next,i=r.anEdge,Ae(i.Lnext!==i),i.Lnext.Lnext===i&&(n.addWinding(i.Onext,i),t.mesh.delete(i));return!0},n.computeInterior=function(t,e){e===void 0&&(e=!0);var r,o;if(n.removeDegenerateEdges(t),!n.initPriorityQ(t))return!1;for(n.initEdgeDict(t);(r=t.pq.extractMin())!==null;){for(;o=t.pq.min(),!(o===null||!ve.vertEq(o,r));)o=t.pq.extractMin(),n.spliceMergeVertices(t,r.anEdge,o.anEdge);n.sweepEvent(t,r)}return t.event=t.dict.min().key.eUp.Org,n.debugEvent(t),n.doneEdgeDict(t),n.donePriorityQ(t),n.removeDegenerateFaces(t,t.mesh)?(e&&t.mesh.check(),!0):!1},n}(),dM=function(){function n(){this.mesh=new mx,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=je.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(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},n.prototype.normalize_=function(t){var e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2];if(!e)throw"Zero-size vector!";e=Math.sqrt(e),t[0]/=e,t[1]/=e,t[2]/=e},n.prototype.longAxis_=function(t){var e=0;return Math.abs(t[1])>Math.abs(t[0])&&(e=1),Math.abs(t[2])>Math.abs(t[e])&&(e=2),e},n.prototype.computeNormal_=function(t){var e,r,o,i,a,s,l=[0,0,0],u=[0,0,0],c=[0,0,0],d=[0,0,0],p=[0,0,0],f=[null,null,null],h=[null,null,null],m=this.mesh.vHead;e=m.next;for(var y=0;y<3;++y)i=e.coords[y],u[y]=i,h[y]=e,l[y]=i,f[y]=e;for(e=m.next;e!==m;e=e.next)for(var g=0;g<3;++g)i=e.coords[g],i<u[g]&&(u[g]=i,h[g]=e),i>l[g]&&(l[g]=i,f[g]=e);var b=0;if(l[1]-u[1]>l[0]-u[0]&&(b=1),l[2]-u[2]>l[b]-u[b]&&(b=2),u[b]>=l[b]){t[0]=0,t[1]=0,t[2]=1;return}for(s=0,r=h[b],o=f[b],c[0]=r.coords[0]-o.coords[0],c[1]=r.coords[1]-o.coords[1],c[2]=r.coords[2]-o.coords[2],e=m.next;e!==m;e=e.next)d[0]=e.coords[0]-o.coords[0],d[1]=e.coords[1]-o.coords[1],d[2]=e.coords[2]-o.coords[2],p[0]=c[1]*d[2]-c[2]*d[1],p[1]=c[2]*d[0]-c[0]*d[2],p[2]=c[0]*d[1]-c[1]*d[0],a=p[0]*p[0]+p[1]*p[1]+p[2]*p[2],a>s&&(s=a,t[0]=p[0],t[1]=p[1],t[2]=p[2]);s<=0&&(t[0]=t[1]=t[2]=0,t[this.longAxis_(c)]=1)},n.prototype.checkOrientation_=function(){for(var t=this.mesh.fHead,e,r=this.mesh.vHead,o,i=0,a=t.next;a!==t;a=a.next)if(o=a.anEdge,!(o.winding<=0))do i+=(o.Org.s-o.Dst.s)*(o.Org.t+o.Dst.t),o=o.Lnext;while(o!==a.anEdge);if(i<0){for(e=r.next;e!==r;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 t=this.mesh.vHead,e=[0,0,0],r,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),r=this.sUnit,o=this.tUnit;var a=this.longAxis_(e);r[a]=0,r[(a+1)%3]=1,r[(a+2)%3]=0,o[a]=0,o[(a+1)%3]=0,o[(a+2)%3]=e[a]>0?1:-1;for(var s=t.next;s!==t;s=s.next)s.s=this.dot_(s.coords,r),s.t=this.dot_(s.coords,o);i&&this.checkOrientation_();for(var l=!0,u=t.next;u!==t;u=u.next)l?(this.bmin[0]=this.bmax[0]=u.s,this.bmin[1]=this.bmax[1]=u.t,l=!1):(u.s<this.bmin[0]&&(this.bmin[0]=u.s),u.s>this.bmax[0]&&(this.bmax[0]=u.s),u.t<this.bmin[1]&&(this.bmin[1]=u.t),u.t>this.bmax[1]&&(this.bmax[1]=u.t))},n.prototype.addWinding_=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},n.prototype.tessellateMonoRegion_=function(t,e){var r,o;if(r=e.anEdge,!(r.Lnext!==r&&r.Lnext.Lnext!==r))throw"Mono region invalid";for(;ve.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;ve.vertLeq(r.Org,r.Dst);r=r.Lnext);o=r.Lprev;for(var i=void 0;r.Lnext!==o;)if(ve.vertLeq(r.Dst,o.Org)){for(;o.Lnext!==r&&(ve.edgeGoesLeft(o.Lnext)||ve.edgeSign(o.Org,o.Dst,o.Lnext.Dst)<=0);)i=t.connect(o.Lnext,o),o=i.Sym;o=o.Lprev}else{for(;o.Lnext!==r&&(ve.edgeGoesRight(r.Lprev)||ve.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)i=t.connect(r,r.Lprev),r=i.Sym;r=r.Lnext}if(o.Lnext===r)throw"Mono region invalid";for(;o.Lnext.Lnext!==r;)i=t.connect(o.Lnext,o),o=i.Sym;return!0},n.prototype.tessellateInterior_=function(t){for(var e,r=t.fHead.next;r!==t.fHead;r=e)if(e=r.next,r.inside&&!this.tessellateMonoRegion_(t,r))return!1;return!0},n.prototype.discardExterior_=function(t){for(var e,r=t.fHead.next;r!==t.fHead;r=e)e=r.next,r.inside||t.zapFace(r)},n.prototype.setWindingNumber_=function(t,e,r){for(var o,i=t.eHead.next;i!==t.eHead;i=o)o=i.next,i.Rface.inside!==i.Lface.inside?i.winding=i.Lface.inside?e:-e:r?t.delete(i):i.winding=0},n.prototype.getNeighbourFace_=function(t){return!t.Rface||!t.Rface.inside?-1:t.Rface.n},n.prototype.outputPolymesh_=function(t,e,r,o){var i,a=0,s=0,l;r>3&&t.mergeConvexFaces(r);for(var u=t.vHead.next;u!==t.vHead;u=u.next)u.n=-1;for(var c=t.fHead.next;c!==t.fHead;c=c.next)if(c.n=-1,!!c.inside){i=c.anEdge,l=0;do{var u=i.Org;u.n===-1&&(u.n=s,s++),l++,i=i.Lnext}while(i!==c.anEdge);if(l>r)throw"Face vertex greater that support polygon";c.n=a,++a}this.elementCount=a,e===dt.CONNECTED_POLYGONS&&(a*=2),this.elements=[],this.elements.length=a*r,this.vertexCount=s,this.vertices=[],this.vertices.length=s*o,this.vertexIndices=[],this.vertexIndices.length=s;for(var u=t.vHead.next;u!==t.vHead;u=u.next)if(u.n!==-1){var d=u.n*o;this.vertices[d+0]=u.coords[0],this.vertices[d+1]=u.coords[1],o>2&&(this.vertices[d+2]=u.coords[2]),this.vertexIndices[u.n]=u.idx}for(var p=0,c=t.fHead.next;c!==t.fHead;c=c.next)if(!!c.inside){i=c.anEdge,l=0;do{var u=i.Org;this.elements[p++]=u.n,l++,i=i.Lnext}while(i!==c.anEdge);for(var f=l;f<r;++f)this.elements[p++]=-1;if(e===dt.CONNECTED_POLYGONS){i=c.anEdge;do this.elements[p++]=this.getNeighbourFace_(i),i=i.Lnext;while(i!==c.anEdge);for(var h=l;h<r;++h)this.elements[p++]=-1}}},n.prototype.outputContours_=function(t,e){var r,o,i=0,a=0;this.vertexCount=0,this.elementCount=0;for(var s=t.fHead.next;s!==t.fHead;s=s.next)if(!!s.inside){o=r=s.anEdge;do this.vertexCount++,r=r.Lnext;while(r!==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 l=0,u=0,c=0;i=0;for(var s=t.fHead.next;s!==t.fHead;s=s.next)if(!!s.inside){a=0,o=r=s.anEdge;do this.vertices[l++]=r.Org.coords[0],this.vertices[l++]=r.Org.coords[1],e>2&&(this.vertices[l++]=r.Org.coords[2]),this.vertexIndices[u++]=this.vertexIdCallback?this.vertexIdCallback(r):r.Org.idx,a++,r=r.Lnext;while(r!==o);this.elements[c++]=i,this.elements[c++]=a,i+=a}},n.prototype.addContour=function(t,e){this.mesh===null&&(this.mesh=new mx),t<2&&(t=2),t>3&&(t=3);for(var r=null,o=0;o<e.length;o+=t)r===null?(r=this.mesh.makeEdge(),this.mesh.splice(r,r.Sym)):(this.mesh.splitEdge(r),r=r.Lnext),r.Org.coords[0]=e[o+0],r.Org.coords[1]=e[o+1],t>2?r.Org.coords[2]=e[o+2]:r.Org.coords[2]=0,r.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(r),r.winding=1,r.Sym.winding=-1},n.prototype.tesselate=function(t,e,r,o,i,a){if(t===void 0&&(t=je.ODD),e===void 0&&(e=dt.POLYGONS),a===void 0&&(a=!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=t,o<2&&(o=2),o>3&&(o=3),!this.mesh)return!1;this.projectPolygon_(),uM.computeInterior(this,a);var s=this.mesh;return e===dt.BOUNDARY_CONTOURS?this.setWindingNumber_(s,1,!0):this.tessellateInterior_(s),a&&s.check(),e===dt.BOUNDARY_CONTOURS?this.outputContours_(s,o):this.outputPolymesh_(s,e,r,o),!0},n}();function Qr(n){var t=n.windingRule,e=t===void 0?je.ODD:t,r=n.elementType,o=r===void 0?dt.POLYGONS:r,i=n.polySize,a=i===void 0?3:i,s=n.vertexSize,l=s===void 0?2:s,u=n.normal,c=u===void 0?[0,0,1]:u,d=n.contours,p=d===void 0?[]:d,f=n.strict,h=f===void 0?!0:f,m=n.debug,y=m===void 0?!1:m;if(!p&&h)throw new Error("Contours can't be empty");if(!!p){var g=new dM;n.edgeCreateCallback&&(g.edgeCreateCallback=n.edgeCreateCallback),n.vertexIdCallback&&(g.vertexIdCallback=n.vertexIdCallback);for(var b=0;b<p.length;b++)g.addContour(l||2,p[b]);return g.tesselate(e,o,a,l,c,h),{vertices:g.vertices,vertexIndices:g.vertexIndices,vertexCount:g.vertexCount,elements:g.elements,elementCount:g.elementCount,mesh:y?g.mesh:void 0}}}var UW=je.ODD,HW=je.NONZERO,qW=je.POSITIVE,WW=je.NEGATIVE,$W=je.ABS_GEQ_TWO,YW=dt.POLYGONS,XW=dt.CONNECTED_POLYGONS,QW=dt.BOUNDARY_CONTOURS;import{Box2 as yM,BufferAttribute as wu,BufferGeometry as gM,Vector2 as xM}from"three";var vu=class{constructor(t=256,e=!1){this.capacity=t,this.size=0,this.debug=e,this.debug&&console.log(`allocating with cap ${t}`);let r=t*vu.eSize;this.buffer=new ArrayBuffer(r);let o=Float32Array.BYTES_PER_ELEMENT,i=0;this.positions=new Float32Array(this.buffer,i*o,3*t),i+=3*t,this.normals=new Float32Array(this.buffer,i*o,3*t),i+=3*t,this.uvs=new Float32Array(this.buffer,i*o,2*t)}realloc(t,e=!1){if(t<this.size)throw Error("cannot shrink buffer");if(t<=this.capacity&&!e)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${t}`);let r=t*vu.eSize,o=new ArrayBuffer(r),i=Float32Array.BYTES_PER_ELEMENT,a=0,s=new Float32Array(o,a*i,3*t);a+=3*t;let l=new Float32Array(o,a*i,3*t);a+=3*t;let u=new Float32Array(o,a*i,2*t);e?(s.set(this.positions.subarray(0,this.size*3)),l.set(this.normals.subarray(0,this.size*3)),u.set(this.uvs.subarray(0,this.size*2))):(s.set(this.positions),l.set(this.normals),u.set(this.uvs)),this.buffer=o,this.positions=s,this.normals=l,this.uvs=u,this.capacity=t}get(t=1){let e=this.size+t;if(e>this.capacity){let o=this.capacity;for(;e>o;)o*=2;this.realloc(o)}let r=this.size;return this.size=e,r}reserve(t){let e=this.size+t;e>this.capacity&&this.realloc(e)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},sl=vu;sl.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var wx=Ht(Sx()),ll={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},sf={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},lf={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},af=(n,t)=>([e,r])=>(r<e&&(r+=t),(n>=e?n:n+t)<=r),Tn=class extends gM{constructor(e,r,o=0,i=12,a=3,s=je.ODD,l=!1){super();this.forPathBevel=l;this.type="ShapeGeometry";this.vertexCache={};this._shape=e,this._depth=r,this._curveSegments=i,this._bevelSegmentsInput=a;let u=this._shape.extractShapePointsToFlatArray([],i),c=this._shape.shapeHoles.map(T=>{let I=T.extractShapePointsToFlatArray([],i),E=[];for(let B=I.length-1;B>=1;B-=2){let R=I[B-1],F=I[B-0];E.push(R,F)}return E}),d=[],p=[];for(let T=0;T<u.length;T+=2)p.push([u[T],u[T+1]]);d.push(p);for(let T=0;T<c.length;T++){let I=c[T],E=[];for(let B=0;B<I.length;B+=2)E.push([I[B],I[B+1]]);d.push(E)}let f;e.isText?f=new yM().setFromPoints(e.points.map(I=>I.position)).getSize(new xM).length()*.1:d[0].length===0?f=o:f=(0,wx.default)(d).distance,o<=0?(this._bevel=0,this._bevelSegments=0):(this._bevel=Math.min(o,f,r/2),this._bevelSegments=Math.floor(a));let h;try{h=Qr({windingRule:s,elementType:dt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[u]})}catch{h=ll}let m;try{m=Qr({windingRule:je.ODD,elementType:dt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...c]})}catch{m=sf}if(!h)throw new Error("error generating geometry");let y=h.elementCount;if(m){h.elementCount+=m.elementCount;for(let T=0;T<m.elements.length;T++){let I=m.elements[T],E=T%2===0?h.vertexCount:0;h.elements.push(I+E)}for(let T=0;T<m.vertexIndices.length;T++){let I=m.vertexIndices[T],E=h.vertexCount;h.vertexIndices.push(I+E)}for(let T=0;T<m.vertices.length;T++){let I=m.vertices[T];h.vertices.push(I)}}let g=1/0,b=-1/0,w=1/0,_=-1/0;for(let T=0,I=h.vertexCount;T<I;T++){let E=T*2,B=h.vertices[E+0],R=h.vertices[E+1];B<g&&(g=B),B>b&&(b=B),R<w&&(w=R),R>_&&(_=R)}this._minX=g,this._minY=w,this._width=b-g,this._height=_-w,this._buffer=new sl(this._computeBufferEstimatedSize(h));let S=[],P=[];for(let T=h.elementCount-1;T>=0;T--){let I=T>=y,E=T*2,B=h.elements[E+0],R=h.elements[E+1],F=B+R,V={start:B,count:R,normals:[],continuous:[],concave:[]},q=B,k=F-1,U=B+1,H=this._shape.roundedCurves.length;do{let te=q-B,Y=h.vertices[k*2+0],ee=h.vertices[k*2+1],Q=h.vertices[q*2+0],W=h.vertices[q*2+1],ue=h.vertices[U*2+0],le=h.vertices[U*2+1],ne=Q-Y,ce=W-ee,ae=Math.sqrt(ne*ne+ce*ce);ne/=ae,ce/=ae;let he=Q-ue,pe=W-le,fe=Math.sqrt(he*he+pe*pe);he/=fe,pe/=fe,V.normals[te*2+0]=-pe,V.normals[te*2+1]=he,V.concave[te]=ne*pe-ce*he>0;let ge=h.vertexIndices[q];if(Array.isArray(ge))V.continuous[te]=!1;else{let[me,C]=this._shape.getCurveIndexFromVertexId(ge-1,!0);if(C>0&&C<1)V.continuous[te]=!0;else{let ie=C===1?me+1:me-1;ie=(ie+H)%H;let De=C===1?0:1,Ge=this._shape.roundedCurves[me].getTangent(C),Ee=this._shape.roundedCurves[ie].getTangent(De);V.continuous[te]=Ge.dot(Ee)>.95}}I&&(V.normals[te*2+0]*=-1,V.normals[te*2+1]*=-1),[k,q,U]=[q,U,U+1],U>=F&&(U-=R)}while(U!==B+1);let $=[];$.push({bevelI:0,angle:0,size:0,boundary:{vertices:h.vertices.slice(B*2,F*2),vertexCount:R,vertexIndices:new Array(R).fill(!0).map((te,Y)=>[Y,Y]),elements:[0,R],elementCount:1,mesh:null},reverseMap:[],insetPoints:h.vertices.slice(B*2,F*2)});let J=0;for(let te=1;te<=this._bevelSegments;te++){let Y=te/this._bevelSegments*Math.PI/2,ee=(1-Math.cos(Y))*this._bevel,Q=[],W=[],ue=[],le=[],ne=0;for(let ae=0;ae<R;ae++){let he=ae*2,pe=(ae-1+R)%R*2,fe=h.vertices[V.start*2+he+0],ge=h.vertices[V.start*2+he+1],me=-V.normals[pe+0]*ee,C=-V.normals[pe+1]*ee,ie=-V.normals[he+0]*ee,De=-V.normals[he+1]*ee;if(V.concave[ae]||!V.concave[ae]&&I){let Ge=Math.atan2(C,me),Ee=Math.atan2(De,ie);Ee>Ge&&(Ee-=Math.PI*2);let _e=Ee-Ge;if(V.continuous[ae]||I){let Ct=Ge+_e/2,Me=Math.cos(Ct)*ee,At=Math.sin(Ct)*ee;Q[2*ne+0]=fe+Me*(I?-1:1),Q[2*ne+1]=ge+At*(I?-1:1),le[ne]=ae,ne++}else{let Ct=Math.max(1,Math.floor(i/4*Math.abs(_e)/Math.PI));for(let Me=0;Me<=Ct;Me++){let At=Ge+_e*(Me/Ct),Tt=Math.cos(At)*ee,Wn=Math.sin(At)*ee;Q[2*ne+0]=fe+Tt,Q[2*ne+1]=ge+Wn,le[ne]=ae,ne++}}}else Q[2*ne+0]=fe+me,Q[2*ne+1]=ge+C,le[ne]=ae,W[ae]=ne,ne++,Q[2*ne+0]=fe,Q[2*ne+1]=ge,le[ne]=ae,ne++,Q[2*ne+0]=fe+ie,Q[2*ne+1]=ge+De,le[ne]=ae,ue[ae]=ne,ne++}let ce=Qr({windingRule:je.POSITIVE,elementType:dt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[Q],edgeCreateCallback:ae=>{let pe=ae.Org.idx,fe=le[pe],ge=le[(pe+1)%le.length];ae.idx=[fe,ge],ae.Sym.idx=[ge,fe]},vertexIdCallback:ae=>{let he=ae.Lprev.idx;return[he?he[1]:0,ae.idx?ae.idx[0]:0]}});if(!ce)throw console.log("Error"),new Error(`error generating bevel geometry for ${te}'th loop`);if(!ce.vertexCount){let ae=(te-1)/this._bevelSegments*Math.PI/2;J=(1-Math.sin(ae))*this._bevel;break}for(let ae=0;ae<ce.vertexIndices.length;ae++){let[he,pe]=ce.vertexIndices[ae];if(he===pe)continue;let fe=pe;pe<he&&(fe+=R);for(let ge=he;ge<fe;ge++){let me=ge%R,C=(ge+1)%R;if(!V.continuous[me]||!V.continuous[C]){ce.vertexIndices[ae]=[he,me],ce.vertexIndices.splice(ae+1,0,[C,pe]),ce.vertices.splice((ae+1)*2,0,ce.vertices[ae*2],ce.vertices[ae*2+1]);break}}}$.push({bevelI:te,angle:Y,size:ee,boundary:ce,reverseMap:le,insetPoints:Q})}let K=(te,Y,ee)=>{let Q=0,W=te.boundary.vertexIndices.length;for(;Q<W&&ee(te.boundary.vertexIndices[Y]);)Y=(Y+1)%W,Q++;return Q},X=S.length;for(let te=1;te<$.length;te++){let Y=$[te-1],ee=$[te],Q=Y.boundary.vertexIndices.length,W=ee.boundary.vertexIndices.length;if(!Q||!W)break;let ue=V.concave.length,le=0,ne=af(le,R);for(;!Y.boundary.vertexIndices.filter(ne).length||!ee.boundary.vertexIndices.filter(ne).length;)le++,ne=af(le,R);let ce=Y.boundary.vertexIndices.findIndex(ne),ae=ee.boundary.vertexIndices.findIndex(ne);do ce=(ce+1)%Q;while(ne(Y.boundary.vertexIndices[ce]));do ae=(ae+1)%W;while(ne(ee.boundary.vertexIndices[ae]));le=(le+1)%R;let he=le,pe=0,fe=this._buildBevelVert(V,Y,(ce-1+Q)%Q,void 0,pe),ge=this._buildBevelVert(V,ee,(ae-1+W)%W,void 0,pe),me=fe,C=ge,ie,De,Ge=!1;do{pe=(le||ue)/ue,ne=af(le,R);let Ee=K(Y,ce,ne),_e=K(ee,ae,ne),Ct=Ge;if(Ge=!1,Ee&&!_e){for(let Me=0;Me<Ee;Me++)ie=this._buildBevelVert(V,Y,(ce+Me)%Q,Me/(Ee-1),pe),S.push(me.topN,ie.topP,C.topN),l===!1&&S.push(ie.bottomP,me.bottomN,C.bottomN),me=ie;Ge=!0}else if(!Ee&&_e)for(let Me=0;Me<_e;Me++)De=this._buildBevelVert(V,ee,(ae+Me)%W,Me/(_e-1),pe),S.push(C.topN,me.topP,De.topP),l===!1&&S.push(me.bottomP,C.bottomN,De.bottomP),C=De;else if(Ee&&_e)if(ie=this._buildBevelVert(V,Y,ce,0,pe),De=this._buildBevelVert(V,ee,ae,0,pe),Ct?(S.push(me.topN,De.topP,C.topN),S.push(me.topN,ie.topP,De.topP),l===!1&&(S.push(De.bottomP,me.bottomN,C.bottomN),S.push(De.bottomP,ie.bottomP,me.bottomN))):(S.push(C.topN,me.topN,ie.topP),S.push(C.topN,ie.topP,De.topP),l===!1&&(S.push(ie.bottomP,me.bottomN,C.bottomN),S.push(ie.bottomP,C.bottomN,De.bottomP))),me=ie,C=De,Ee===_e)for(let Me=1;Me<Ee;Me++)ie=this._buildBevelVert(V,Y,(ce+Me)%Q,Me/(Ee-1),pe),De=this._buildBevelVert(V,ee,(ae+Me)%W,Me/(_e-1),pe),S.push(me.topN,ie.topP,C.topN),S.push(C.topN,ie.topP,De.topP),l===!1&&(S.push(ie.bottomP,me.bottomN,C.bottomN),S.push(ie.bottomP,C.bottomN,De.bottomP)),me=ie,C=De;else if(Ee>_e){let Me=Ee/_e,At=0;for(let Tt=1;Tt<Ee;Tt++)ie=this._buildBevelVert(V,Y,(ce+Tt)%Q,Tt/(Ee-1),pe),S.push(me.topN,ie.topP,C.topN),l===!1&&S.push(ie.bottomP,me.bottomN,C.bottomN),me=ie,Tt>(At+1)*Me&&(At++,De=this._buildBevelVert(V,ee,(ae+At)%W,At/(_e-1),pe),S.push(C.topN,ie.topP,De.topP),l===!1&&S.push(ie.bottomP,C.bottomN,De.bottomP),C=De)}else{let Me=_e/Ee,At=0;for(let Tt=1;Tt<_e;Tt++)De=this._buildBevelVert(V,ee,(ae+Tt)%W,Tt/(_e-1),pe),S.push(C.topN,ie.topP,De.topP),l===!1&&S.push(ie.bottomP,C.bottomN,De.bottomP),C=De,Tt>(At+1)*Me&&(At++,ie=this._buildBevelVert(V,Y,(ce+At)%Q,At/(Ee-1),pe),S.push(me.topN,ie.topP,C.topN),l===!1&&S.push(ie.bottomP,me.bottomN,C.bottomN),me=ie)}ce=(ce+Ee)%Q,ae=(ae+_e)%W,le=(le+1)%ue}while(le!==he)}if(l===!1&&this._depth>this._bevel*2&&this._buildWall($,V,S),I){let te=[];for(let Y=S.length-1;Y>=X+2;Y-=3){let ee=S[Y-2],Q=S[Y-1],W=S[Y-0];te.push(W,Q,ee)}S.splice(X,S.length-X,...te)}if(I){let te=[];for(let Y=$[$.length-1].boundary.vertices.length-1;Y>=1;Y-=2){let ee=$[$.length-1].boundary.vertices[Y-1],Q=$[$.length-1].boundary.vertices[Y-0];te.push(ee,Q)}P.push(te)}if(!I){let te=$[$.length-1],Y;try{Y=Qr({windingRule:$.length>1?je.POSITIVE:je.ODD,elementType:dt.POLYGONS,vertexSize:2,strict:!0,contours:[te.insetPoints,...P]})}catch{Y=lf}if(!Y)throw new Error("Error generating geometry for surface");c.length===0&&this._bevel<f&&Object.assign(this,{useNgonForTopBottomFaceDuringBake:!0});for(let ee=0;ee<Y.elementCount*3;ee+=3){let Q=this._buildSurfaceVert(Y,Y.elements[ee+0],J),W=this._buildSurfaceVert(Y,Y.elements[ee+1],J),ue=this._buildSurfaceVert(Y,Y.elements[ee+2],J);S.push(Q.top,W.top,ue.top),l===!1&&S.push(ue.bottom,W.bottom,Q.bottom)}}this.vertexCache={}}this._buffer.shrink();let O=new wu(Uint32Array.from(S),1),x=new wu(this._buffer.positions,3),D=new wu(this._buffer.normals,3),N=new wu(this._buffer.uvs,2);x.needsUpdate=!0,D.needsUpdate=!0,N.needsUpdate=!0,O.needsUpdate=!0,this.setAttribute("position",x),this.setAttribute("normal",D),this.setAttribute("uv",N),this.setIndex(O)}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,r,o){let i=e[0];for(let a=0,s=i.boundary.vertexCount;a<s;a++){let l=this._buildBevelVert(r,i,a),u=this._buildBevelVert(r,i,(a+1)%s);o.push(u.topP,l.topN,l.bottomN),o.push(u.topP,l.bottomN,u.bottomP)}}_buildSurfaceVert(e,r,o){let i=r.toString();if(i in this.vertexCache)return this.vertexCache[i];let a=e.vertices[r*2+0],s=e.vertices[r*2+1],l=(a-this._minX)/this._width,u=(s-this._minY)/this._height;this.forPathBevel&&(u=1);let c=this._buffer.get(this.forPathBevel?1:2),d=c*3,p=c*2,f={top:c+0,bottom:c+1};return this._buffer.positions[d+0]=a,this._buffer.positions[d+1]=s,this._buffer.positions[d+2]=this.forPathBevel?this._bevel:this._depth-o,this._buffer.normals[d+0]=0,this._buffer.normals[d+1]=0,this._buffer.normals[d+2]=1,this._buffer.uvs[p+0]=l,this._buffer.uvs[p+1]=u,this.forPathBevel===!1&&(this._buffer.positions[d+3]=a,this._buffer.positions[d+4]=s,this._buffer.positions[d+5]=o,this._buffer.normals[d+3]=0,this._buffer.normals[d+4]=0,this._buffer.normals[d+5]=-1,this._buffer.uvs[p+2]=l,this._buffer.uvs[p+3]=u),this.vertexCache[i]=f,f}_buildBevelVert(e,r,o,i=1,a){let s=`${r.bevelI}:${o}`;if(s in this.vertexCache&&a!==0&&a!==1&&(!a||a===this.vertexCache[s].pathBevelUCoord))return this.vertexCache[s];let[l,u]=r.boundary.vertexIndices[o],c,d,p,f;l!==u?(d=l,c=u,f=!1,p=e.continuous[d]&&e.continuous[c]):(c=l,d=(c-1+e.count)%e.count,f=e.concave[c]&&r.bevelI>0,p=e.continuous[c]||f);let h=Math.cos(r.angle),m=Math.sin(r.angle),y=o*2,g=c*2,b=d*2,w=r.boundary.vertices[y+0],_=r.boundary.vertices[y+1],S=(1-m)*this._bevel,P=(w-this._minX)/this._width,O=(_-this._minY)/this._height;this.forPathBevel&&(a!==void 0&&(P=a),O=1);let x=e.normals[g+0],D=e.normals[g+1],N=e.normals[b+0],T=e.normals[b+1];if(f){let F=N-x,V=T-D;x=x+F*(1-i),D=D+V*(1-i);let q=Math.sqrt(x*x+D*D);x/=q,D/=q}let I=this.forPathBevel?this._buffer.get(p?1:2):this._buffer.get(p?2:4),E=I*3,B=I*2,R={i:o,fi:c,topP:I+0,topN:I+0,bottomP:I+1,bottomN:I+1,pathBevelUCoord:a};return this._buffer.positions[E+0]=w,this._buffer.positions[E+1]=_,this._buffer.positions[E+2]=(this.forPathBevel?this._bevel:this._depth)-S,this._buffer.normals[E+0]=x*h,this._buffer.normals[E+1]=D*h,this._buffer.normals[E+2]=m,this._buffer.uvs[B+0]=P,this._buffer.uvs[B+1]=O,this.forPathBevel===!1&&(this._buffer.positions[E+3]=w,this._buffer.positions[E+4]=_,this._buffer.positions[E+5]=S,this._buffer.normals[E+3]=x*h,this._buffer.normals[E+4]=D*h,this._buffer.normals[E+5]=-m,this._buffer.uvs[B+2]=O,this._buffer.uvs[B+3]=P),p||(this.forPathBevel?(I+=1,E+=3,B+=2):(I+=2,E+=6,B+=4),R.topP=I+0,R.bottomP=I+1,this._buffer.positions[E+0]=w,this._buffer.positions[E+1]=_,this._buffer.positions[E+2]=(this.forPathBevel?this._bevel:this._depth)-S,this._buffer.normals[E+0]=N*h,this._buffer.normals[E+1]=T*h,this._buffer.normals[E+2]=m,this._buffer.uvs[B+0]=P,this._buffer.uvs[B+1]=O,this.forPathBevel===!1&&(this._buffer.positions[E+3]=w,this._buffer.positions[E+4]=_,this._buffer.positions[E+5]=S,this._buffer.normals[E+3]=N*h,this._buffer.normals[E+4]=T*h,this._buffer.normals[E+5]=-m,this._buffer.uvs[B+2]=O,this._buffer.uvs[B+3]=P)),this.vertexCache[s]=R,R}clone(){let e=new Tn(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Vo(this.userData),e}};var Da=class extends bM{constructor(e,r=12,o={}){super();this.type="ShapeGeometry";this.windingRule=je.ODD;this.elementType=dt.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=e,this._curveSegments=r,this._triangulationOptions=Object.assign({windingRule:je.ODD,elementType:dt.POLYGONS,polySize:3,vertexSize:2,strict:!0},o);let i=this._shape.extractShapePointsToFlatArray([],this._curveSegments),a=this._shape.shapeHoles.map(h=>h.extractShapePointsToFlatArray([],this._curveSegments)),s,l=!0,u=!0,c,d;for(let h=0,m=i.length/2;h<m;h++){let y=h*2,g=i[y+0],b=i[y+1];if(c!==void 0&&g!==c&&(l=!1),d!==void 0&&b!==d&&(u=!1),c=g,d=b,!l&&!u)break}if(!l&&!u)try{s=Qr({contours:[i,...a],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})}catch{s=ll}let p=s?.vertexCount??1,f=s?.elementCount??1;if(this._positionAttribute=new Au(new Float32Array(p*3),3),this._normalAttribute=new Au(new Float32Array(p*3),3),this._uvAttribute=new Au(new Float32Array(p*2),2),this._indexAttribute=new Au(new Uint32Array(f*3),1),s){let h=1/0,m=-1/0,y=1/0,g=-1/0;for(let _=0,S=p;_<S;_++){let P=_*2,O=s.vertices[P+0],x=s.vertices[P+1];O<h&&(h=O),O>m&&(m=O),x<y&&(y=x),x>g&&(g=x)}let b=m-h,w=g-y;for(let _=0,S=p;_<S;_++){let P=_*2,O=s.vertices[P+0],x=s.vertices[P+1],D=(O-h)/b,N=(x-y)/w;this._positionAttribute.setXYZ(_,O,x,0),this._normalAttribute.setXYZ(_,0,0,1),this._uvAttribute.setXY(_,D,N)}for(let _=0,S=f;_<S;_++){let P=_*3,O=s.elements[P+0],x=s.elements[P+1],D=s.elements[P+2];this._indexAttribute.setX(P+0,O),this._indexAttribute.setX(P+1,x),this._indexAttribute.setX(P+2,D)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,(s?.elementCount??1)*3)}clone(){let e=new Da(this._shape,this._curveSegments);return e.userData=Vo(this.userData),e}};var Ea=class extends Tn{constructor(e,r,o=0,i=12,a=3,s=je.ODD){super(e,r,o,i,a,s);this.type="ShapeGeometry"}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,r,o){let i=e[0];for(let a=0,s=i.boundary.vertexCount;a<s;a++){let l=this._buildBevelVert(r,i,a),u=this._buildBevelVert(r,i,(a+1)%s);o.push(u.topP,l.topN,l.bottomN),o.push(u.topP,l.bottomN,u.bottomP)}}clone(){let e=new Ea(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Vo(this.userData),e}};var dr=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:je.ODD},n.parameters),r=Math.abs(e.width),o=Math.abs(e.height??e.width),i=Math.abs(e.depth??0),a=n.shape??t?.shape,s=a?.roundness??e.roundness;a!==void 0&&(a instanceof He?(a.width!==r||a.height!==o)&&a.applySize(r,o):a=new He(r,o).fromJSON(a),n.parameters?.roundness!==void 0&&n.parameters?.roundness>0&&a.update());let l=a??new He(r,o);return{parameters:Object.assign(e,{width:r,height:o,depth:i,roundness:s}),shape:l}}static build(n){let{depth:t,extrudeBevelSize:e,extrudeBevelSegments:r,subdivisions:o,roundness:i,windingRule:a}=n.parameters;n.shape.roundness=i;let s;return t<=0?s=new Da(n.shape,o,{windingRule:a}):s=new Ea(n.shape,t,e,o,r,a),Object.assign(s,{userData:{...n,type:"VectorGeometry"}})}};import{BufferGeometry as vM,Float32BufferAttribute as SM,MathUtils as cf,Vector2 as _x}from"three";var Px=Math.PI*2,La=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters);return e.angle=cf.clamp(e.angle,0,360),{shape:n.shape&&n.shape instanceof He?n.shape:new He,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:t,height:e,spikes:r,angle:o,innerRadius:i,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}=n.parameters,u=n.shape,c=t*.5,d=e*.5,p=wM(u,c,d,o*Math.PI/180,r,i);u.isClosed=!0,u.update();let f;return o===0?(f=new vM,f.setAttribute("position",new SM([],3))):f=dr.create({shape:u,parameters:{subdivisions:p,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}}),Object.assign(f,{userData:{...n,type:"EllipseGeometry"}})}};function wM(n,t,e,r,o,i){if(r>=Px)return o>30||o%4===0?(_M(n,t,e,i),Math.round(o/4)):Ax(n,r,o,t,e,i);r=Math.max(r,.001);let a={x:0,y:e},s=r+Math.PI*.5,l={x:Math.cos(s)*t,y:Math.sin(s)*e},u=hx({px:a.x,py:a.y,cx:l.x,cy:l.y,rx:t,ry:e,largeArcFlag:r>Math.PI,sweepFlag:!0});return o>30||o%u.length===0?AM(n,a.x,a.y,u,o,t,e,i):Ax(n,r,o,t,e,i)}function AM(n,t,e,r,o,i,a,s){let l=Math.round(o/r.length);n.addPoint(Ba(t,e));for(let u=0,c=r.length;u<c;u++){let d=r[u],p=n.points[u],f=Ba(d.x,d.y);p.controls[1].position.set(d.x1,d.y1),f.controls[0].position.set(d.x2,d.y2),n.addPoint(f)}return s>0?Ox(n,i,a,s):n.addPoint(Ba(0,0)),l}function Ax(n,t,e,r,o,i){let a=-t/e;for(let s=0;s<=e;s++){let l=a*s,u=Math.sin(l)*r,c=Math.cos(l)*o;n.addPoint(Ba(u,c))}return t<Px?i>0?Ox(n,r,o,i):n.addPoint(Ba(0,0)):(n.removePoint(n.points[n.points.length-1]),i>0&&Cx(n,r,o,i)),1}function _M(n,t,e,r=0,o=0,i=0){let a=.5522847498,s=t*a,l=e*a;n.addPoint(_u(o-t,i,o-t,i-l,o-t,i+l)),n.addPoint(_u(o,i+e,o-s,i+e,o+s,i+e)),n.addPoint(_u(o+t,i,o+t,i+l,o+t,i-l)),n.addPoint(_u(o,i-e,o+s,i-e,o-s,i-e)),r>0&&Cx(n,t,e,r)}function Ba(n,t){return new Xr(cf.generateUUID(),new _x(n,t))}function _u(n,t,e,r,o,i){let a=Ba(n,t);return a.controls[0].position.set(e,r),a.controls[1].position.set(o,i),a}function Ox(n,t,e,r){Tx(n,t,e,r).forEach(i=>n.addPoint(i))}function Cx(n,t,e,r){let o=Tx(n,t,e,r),i=new He;o.forEach(a=>i.addPoint(a)),i.isClosed=!0,n.shapeHoles.push(i)}function Tx(n,t,e,r){let o=r*t/100,i=o*(Math.abs(e)/Math.abs(t)),a=new _x(o/t,i/e),s=n.points.map(l=>{let u=l.clone();return u.uuid=cf.generateUUID(),u}).reverse();return s.forEach(l=>{l.position.multiply(a);let u=l.controls[0].position.clone().multiply(a),c=l.controls[1].position.clone().multiply(a);l.controls[0].position.copy(c),l.controls[1].position.copy(u)}),s}import{BufferGeometry as PM,Float32BufferAttribute as uf,Uint32BufferAttribute as OM,Vector3 as Mx}from"three";var Ix=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},n.parameters),r=Math.abs(e.width),o=Math.abs(e.height??r),i=Math.abs(e.depth??r),a=Math.abs(Math.min(r,i))/2;return{parameters:Object.assign(e,{width:r,height:o,depth:i,radius:a,segments:Math.round(e.segments),pathSegments:Math.round(e.pathSegments),cornerSegments:Math.round(e.cornerSegments)})}}static build(n){let{width:t,height:e,depth:r,radius:o,revolutions:i,segments:a,pathRadius:s,pathType:l,pathSegments:u,cornerRadius:c,cornerSegments:d}=n.parameters,p=new cl(!1,t,e,r,o,i,a,s,l,u,c,d);return Object.assign(p,{userData:{...n,type:"HelixGeometry"}})}},df=new OM([0,0,0],1),cl=class extends PM{constructor(t=!0,e=1,r=1,o=1,i=1,a=1,s=1,l=1,u=1,c=1,d=1,p=1){if(super(),a===0)return;let f=t&&a===1;f&&(p=0),d>100&&(d=100),d===0&&(p=0);let h=()=>new Mx,m=new Mx,y=h(),g=h(),b=h(),w,_,S,P,O,x,D,N,T=h(),I=h(),E=h(),B=h(),R=h(),F=h(),V=h(),q=h(),k=r-2*l+.001,U=k/a,H=Math.ceil(s*a),$=H+1,J=k/H,K=-k/2,X=c+1,te=2*Math.PI/c,Y=Math.PI/2/p,ee=.01,Q=Math.min((1-d/100)*l,l-ee),W=l-Q,ue=0,le=2,ne=p*le+le,ce=X*ne/le,ae=ce+X*$,he=Math.max(0,X*($+ne)),[pe,fe,ge]=[3,3,2].map(st=>Array(he*st).fill(0)),me=[],C=i-l;function ie(st,Ke){let kr=Math.PI/2;x=Ke*J,N=2*Math.PI*(x%U)/U+kr,x+=K,D=Math.sin(N)*C,O=Math.cos(N)*C,t?st.set(O,D,x):st.set(O,x,D)}ie(m,-1e-10),ie(y,0),T.copy(m),ie(m,1);let De=m.distanceTo(y),Ge=f?0:W+Q,Ee=De*H+2*Ge,_e=Q,Ct=Ee-Ge;for(let st=0;st<=H;st++){ie(g,st),q.subVectors(g,T).normalize(),T.copy(g),F.copy(g).setComponent(+t+1,0).normalize(),V.crossVectors(q,F).normalize();let Ke=st===0,kr=st===H,Nd=Ke?3*Math.PI/2:Y,Dd=Ke?_e:Ct,jl=Ke?X:ae,$n=Ke?0:he-X,mt=q.clone().multiplyScalar(Ke?-W:W).add(g),Ed=q.clone().multiplyScalar(Ke?-1:1).normalize();for(let Cr=0;Cr<X;Cr++){let Bs=Cr*te;if(I.addVectors(m.copy(F).multiplyScalar(l*Math.cos(Bs)),y.copy(V).multiplyScalar(l*Math.sin(Bs))),E.copy(I).normalize(),Ke||kr){f||(ue=$n+Cr,[0,1,2].forEach(Kt=>{pe[ue*3+Kt]=mt.getComponent(Kt),fe[ue*3+Kt]=Ed.getComponent(Kt)}),ge[ue*2]=+kr,ge[ue*2+1]=Cr/c),y.copy(E).multiplyScalar(Q),b.addVectors(g,y);for(let Kt=0;Kt<p;Kt++){let Yn=Kt*Y+Nd;B.addVectors(m.copy(q).multiplyScalar(W*Math.sin(Yn)),y.copy(E).multiplyScalar(W*Math.cos(Yn))),R.copy(B).normalize(),y.addVectors(b,B),B.normalize(),ue=jl+Kt*X+Cr,[0,1,2].forEach(Ii=>{pe[ue*3+Ii]=y.getComponent(Ii),fe[ue*3+Ii]=R.getComponent(Ii)});let Ul=+Ke+Math.sin(Yn);ge[ue*2]=(Dd+W*Ul)/Ee,ge[ue*2+1]=Cr/c}}y.addVectors(g,I),ue=ce+st*X+Cr,[0,1,2].forEach(Kt=>{pe[ue*3+Kt]=y.getComponent(Kt),fe[ue*3+Kt]=E.getComponent(Kt)}),ge[ue*2]=(Ge+st*De)/Ee,ge[ue*2+1]=Cr/c}}let Me=$+2*p+le,At=1,[Tt,Wn]=[+f,Me-1];for(let st=Tt;st<=Wn-1;st++){let Ke=f&&st===Wn-1;for(let kr=0;kr<X-1;kr++)w=st*X+kr,_=w+1,S=(Ke?kr:w)+X,P=(Ke?kr+1:_)+X,st===0?me.push(_,P,S):st===Me-2?me.push(w,_,S):me.push(w,_,S,_,P,S)}this.setIndex(me),this.setAttribute("position",new uf(pe,3)),this.setAttribute("normal",new uf(fe,3)),this.setAttribute("uv",new uf(ge,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let t=this.userData.parameters,e=Math.ceil(t.tubularSegments),r=t.radialSegments+1,o=Array.from(this.getIndex().array),i,a,s,l,u=6*(e-1)*t.radialSegments,c=e,d=c===e;for(let p=0;p<t.radialSegments;p++)i=c*r+p,a=i+1,s=(d?p:i)+r,l=(d?p+1:a)+r,o[u++]=i,o[u++]=a,o[u++]=s,o[u++]=a,o[u++]=l,o[u++]=s;return o.length=u,df.array=o,df.count=o.length,df}};import{IcosahedronGeometry as CM}from"three";var Nx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.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:t,height:e,depth:r,detail:o,corner:i,cornerSides:a}=n.parameters,s=o===0&&i!==0?new ul(t*.5,i,a):new CM(t*.5,o);return s.scale(1,e/t,r/t),Object.assign(s,{userData:{...n,type:"IcosahedronGeometry"}})}},ul=class extends Pn{constructor(t=1,e=.2,r=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],a=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],s="IcosahedronGeometry";super(i,a,s,t,e,r),this.type=s}static fromJSON(t){return new ul(t.radius,t.corner,t.cornerSides)}};import{LatheGeometry as TM,Shape as MM}from"three";var Dx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){(n.parameters?.points??[]).forEach(r=>{Array.isArray(r)&&(r.x=r[0],r.y=r[1])});let e=Object.assign({},t?.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:t,segments:e,verticalSegments:r}=n.parameters,o=new MM;o.moveTo(t[0].x,t[0].y),o.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y);let i=new TM(o.extractPoints(r).shape,e);return i.rotateZ(Math.PI),Object.assign(i,{userData:{...n,type:"LatheGeometry"}})}};import{BufferGeometry as Fx,BufferGeometryLoader as kM,Vector3 as jM,BoxGeometry as kx}from"three";import{BufferGeometry as VM,Vector2 as mf,Vector3 as Gx}from"three";import{Box3 as IM,BufferAttribute as dl,BufferGeometry as Ex,Color as hf,EventDispatcher as NM,Float32BufferAttribute as Ra,Matrix3 as Bx,Matrix4 as zx,MathUtils as DM,Object3D as EM,Sphere as BM,Vector2 as Ar,Vector3 as $t,Vector4 as LM}from"three";var xo=new zx,pf=new EM,Pu=new $t,Mn=class extends NM{constructor(){super(),this.uuid=DM.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(t){let e=new Bx().getNormalMatrix(t);for(let r=0,o=this.vertices.length;r<o;r++)this.vertices[r].applyMatrix4(t);for(let r=0,o=this.faces.length;r<o;r++){let i=this.faces[r];i.normal.applyMatrix3(e).normalize();for(let a=0,s=i.vertexNormals.length;a<s;a++)i.vertexNormals[a].applyMatrix3(e).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this}rotateX(t){return xo.makeRotationX(t),this.applyMatrix4(xo),this}rotateY(t){return xo.makeRotationY(t),this.applyMatrix4(xo),this}rotateZ(t){return xo.makeRotationZ(t),this.applyMatrix4(xo),this}translate(t,e,r){return xo.makeTranslation(t,e,r),this.applyMatrix4(xo),this}scale(t,e,r){return xo.makeScale(t,e,r),this.applyMatrix4(xo),this}lookAt(t){return pf.lookAt(t),pf.updateMatrix(),this.applyMatrix4(pf.matrix),this}fromBufferGeometry(t){let e=this,r=t.index!==null?t.index:void 0,o=t.attributes;if(o.position===void 0)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;let i=o.position,a=o.normal,s=o.color,l=o.uv,u=o.uv2;u!==void 0&&(this.faceVertexUvs[1]=[]);for(let p=0;p<i.count;p++)e.vertices.push(new $t().fromBufferAttribute(i,p)),s!==void 0&&e.colors.push(new hf().fromBufferAttribute(s,p));function c(p,f,h,m){let y=s===void 0?[]:[e.colors[p].clone(),e.colors[f].clone(),e.colors[h].clone()],g=a===void 0?[]:[new $t().fromBufferAttribute(a,p),new $t().fromBufferAttribute(a,f),new $t().fromBufferAttribute(a,h)],b=new Va(p,f,h,g,y,m);e.faces.push(b),l!==void 0&&e.faceVertexUvs[0].push([new Ar().fromBufferAttribute(l,p),new Ar().fromBufferAttribute(l,f),new Ar().fromBufferAttribute(l,h)]),u!==void 0&&e.faceVertexUvs[1].push([new Ar().fromBufferAttribute(u,p),new Ar().fromBufferAttribute(u,f),new Ar().fromBufferAttribute(u,h)])}let d=t.groups;if(d.length>0)for(let p=0;p<d.length;p++){let f=d[p],h=f.start,m=f.count;for(let y=h,g=h+m;y<g;y+=3)r!==void 0?c(r.getX(y),r.getX(y+1),r.getX(y+2),f.materialIndex):c(y,y+1,y+2,f.materialIndex)}else if(r!==void 0)for(let p=0;p<r.count;p+=3)c(r.getX(p),r.getX(p+1),r.getX(p+2));else for(let p=0;p<i.count;p+=3)c(p,p+1,p+2);return this.computeFaceNormals(),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Pu).negate(),this.translate(Pu.x,Pu.y,Pu.z),this}normalize(){this.computeBoundingSphere();let t=this.boundingSphere.center,e=this.boundingSphere.radius,r=e===0?1:1/e,o=new zx;return o.set(r,0,0,-r*t.x,0,r,0,-r*t.y,0,0,r,-r*t.z,0,0,0,1),this.applyMatrix4(o),this}computeFaceNormals(){let t=new $t,e=new $t;for(let r=0,o=this.faces.length;r<o;r++){let i=this.faces[r],a=this.vertices[i.a],s=this.vertices[i.b],l=this.vertices[i.c];t.subVectors(l,s),e.subVectors(a,s),t.cross(e),t.normalize(),i.normal.copy(t)}}computeVertexNormals(t=!0){let e=new Array(this.vertices.length);for(let r=0,o=this.vertices.length;r<o;r++)e[r]=new $t;if(t){let r=new $t,o=new $t;for(let i=0,a=this.faces.length;i<a;i++){let s=this.faces[i],l=this.vertices[s.a],u=this.vertices[s.b],c=this.vertices[s.c];r.subVectors(c,u),o.subVectors(l,u),r.cross(o),e[s.a].add(r),e[s.b].add(r),e[s.c].add(r)}}else{this.computeFaceNormals();for(let r=0,o=this.faces.length;r<o;r++){let i=this.faces[r];e[i.a].add(i.normal),e[i.b].add(i.normal),e[i.c].add(i.normal)}}for(let r=0,o=this.vertices.length;r<o;r++)e[r].normalize();for(let r=0,o=this.faces.length;r<o;r++){let i=this.faces[r],a=i.vertexNormals;a.length===3?(a[0].copy(e[i.a]),a[1].copy(e[i.b]),a[2].copy(e[i.c])):(a[0]=e[i.a].clone(),a[1]=e[i.b].clone(),a[2]=e[i.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeFlatVertexNormals(){this.computeFaceNormals();for(let t=0,e=this.faces.length;t<e;t++){let r=this.faces[t],o=r.vertexNormals;o.length===3?(o[0].copy(r.normal),o[1].copy(r.normal),o[2].copy(r.normal)):(o[0]=r.normal.clone(),o[1]=r.normal.clone(),o[2]=r.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let e=0,r=this.faces.length;e<r;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,a=o.vertexNormals.length;i<a;i++)o.__originalVertexNormals[i]?o.__originalVertexNormals[i].copy(o.vertexNormals[i]):o.__originalVertexNormals[i]=o.vertexNormals[i].clone()}let t=new Mn;t.faces=this.faces;for(let e=0,r=this.morphTargets.length;e<r;e++){if(!this.morphNormals[e]){this.morphNormals[e]={},this.morphNormals[e].faceNormals=[],this.morphNormals[e].vertexNormals=[];let i=this.morphNormals[e].faceNormals,a=this.morphNormals[e].vertexNormals;for(let s=0,l=this.faces.length;s<l;s++){let u=new $t,c={a:new $t,b:new $t,c:new $t};i.push(u),a.push(c)}}let o=this.morphNormals[e];t.vertices=this.morphTargets[e].vertices,t.computeFaceNormals(),t.computeVertexNormals();for(let i=0,a=this.faces.length;i<a;i++){let s=this.faces[i],l=o.faceNormals[i],u=o.vertexNormals[i];l.copy(s.normal),u.a.copy(s.vertexNormals[0]),u.b.copy(s.vertexNormals[1]),u.c.copy(s.vertexNormals[2])}}for(let e=0,r=this.faces.length;e<r;e++){let o=this.faces[e];o.normal=o.__originalFaceNormal,o.vertexNormals=o.__originalVertexNormals}}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new IM),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new BM),this.boundingSphere.setFromPoints(this.vertices)}merge(t,e,r=0){if(!(t&&t.isGeometry)){console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",t);return}let o,i=this.vertices.length,a=this.vertices,s=t.vertices,l=this.faces,u=t.faces,c=this.colors,d=t.colors;e!==void 0&&(o=new Bx().getNormalMatrix(e));for(let p=0,f=s.length;p<f;p++){let m=s[p].clone();e!==void 0&&m.applyMatrix4(e),a.push(m)}for(let p=0,f=d.length;p<f;p++)c.push(d[p].clone());for(let p=0,f=u.length;p<f;p++){let h=u[p],m,y,g=h.vertexNormals,b=h.vertexColors,w=new Va(h.a+i,h.b+i,h.c+i);w.normal.copy(h.normal),o!==void 0&&w.normal.applyMatrix3(o).normalize();for(let _=0,S=g.length;_<S;_++)m=g[_].clone(),o!==void 0&&m.applyMatrix3(o).normalize(),w.vertexNormals.push(m);w.color.copy(h.color);for(let _=0,S=b.length;_<S;_++)y=b[_],w.vertexColors.push(y.clone());w.materialIndex=h.materialIndex+r,l.push(w)}for(let p=0,f=t.faceVertexUvs.length;p<f;p++){let h=t.faceVertexUvs[p];this.faceVertexUvs[p]===void 0&&(this.faceVertexUvs[p]=[]);for(let m=0,y=h.length;m<y;m++){let g=h[m],b=[];for(let w=0,_=g.length;w<_;w++)b.push(g[w].clone());this.faceVertexUvs[p].push(b)}}}mergeMesh(t){if(!(t&&t.isMesh)){console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",t);return}t.matrixAutoUpdate&&t.updateMatrix(),this.merge(t.geometry,t.matrix)}mergeVertices(t=4){let e={},r=[],o=[],i=Math.pow(10,t);for(let l=0,u=this.vertices.length;l<u;l++){let c=this.vertices[l],d=Math.round(c.x*i)+"_"+Math.round(c.y*i)+"_"+Math.round(c.z*i);e[d]===void 0?(e[d]=l,r.push(this.vertices[l]),o[l]=r.length-1):o[l]=o[e[d]]}let a=[];for(let l=0,u=this.faces.length;l<u;l++){let c=this.faces[l];c.a=o[c.a],c.b=o[c.b],c.c=o[c.c];let d=[c.a,c.b,c.c];for(let p=0;p<3;p++)if(d[p]===d[(p+1)%3]){a.push(l);break}}for(let l=a.length-1;l>=0;l--){let u=a[l];this.faces.splice(u,1);for(let c=0,d=this.faceVertexUvs.length;c<d;c++)this.faceVertexUvs[c].splice(u,1)}let s=this.vertices.length-r.length;return this.vertices=r,s}setFromPoints(t){this.vertices=[];for(let e=0,r=t.length;e<r;e++){let o=t[e];this.vertices.push(new $t(o.x,o.y,o.z||0))}return this}sortFacesByMaterialIndex(){let t=this.faces,e=t.length;for(let l=0;l<e;l++)t[l]._id=l;function r(l,u){return l.materialIndex-u.materialIndex}t.sort(r);let o=this.faceVertexUvs[0],i=this.faceVertexUvs[1],a,s;o&&o.length===e&&(a=[]),i&&i.length===e&&(s=[]);for(let l=0;l<e;l++){let u=t[l]._id;a&&a.push(o[u]),s&&s.push(i[u])}a&&(this.faceVertexUvs[0]=a),s&&(this.faceVertexUvs[1]=s)}toJSON(){let t={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),this.parameters!==void 0){let h=this.parameters;for(let m in h)h[m]!==void 0&&(t[m]=h[m]);return t}let e=[];for(let h=0;h<this.vertices.length;h++){let m=this.vertices[h];e.push(m.x,m.y,m.z)}let r=[],o=[],i={},a=[],s={},l=[],u={};for(let h=0;h<this.faces.length;h++){let m=this.faces[h],y=!0,g=!1,b=this.faceVertexUvs[0][h]!==void 0,w=m.normal.length()>0,_=m.vertexNormals.length>0,S=m.color.r!==1||m.color.g!==1||m.color.b!==1,P=m.vertexColors.length>0,O=0;if(O=c(O,0,0),O=c(O,1,y),O=c(O,2,g),O=c(O,3,b),O=c(O,4,w),O=c(O,5,_),O=c(O,6,S),O=c(O,7,P),r.push(O),r.push(m.a,m.b,m.c),r.push(m.materialIndex),b){let x=this.faceVertexUvs[0][h];r.push(f(x[0]),f(x[1]),f(x[2]))}if(w&&r.push(d(m.normal)),_){let x=m.vertexNormals;r.push(d(x[0]),d(x[1]),d(x[2]))}if(S&&r.push(p(m.color)),P){let x=m.vertexColors;r.push(p(x[0]),p(x[1]),p(x[2]))}}function c(h,m,y){return y?h|1<<m:h&~(1<<m)}function d(h){let m=h.x.toString()+h.y.toString()+h.z.toString();return i[m]!==void 0||(i[m]=o.length/3,o.push(h.x,h.y,h.z)),i[m]}function p(h){let m=h.r.toString()+h.g.toString()+h.b.toString();return s[m]!==void 0||(s[m]=a.length,a.push(h.getHex())),s[m]}function f(h){let m=h.x.toString()+h.y.toString();return u[m]!==void 0||(u[m]=l.length/2,l.push(h.x,h.y)),u[m]}return t.data={},t.data.vertices=e,t.data.normals=o,a.length>0&&(t.data.colors=a),l.length>0&&(t.data.uvs=[l]),t.data.faces=r,t}clone(){return new Mn().copy(this)}copy(t){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=t.name;let e=t.vertices;for(let p=0,f=e.length;p<f;p++)this.vertices.push(e[p].clone());let r=t.colors;for(let p=0,f=r.length;p<f;p++)this.colors.push(r[p].clone());let o=t.faces;for(let p=0,f=o.length;p<f;p++)this.faces.push(o[p].clone());for(let p=0,f=t.faceVertexUvs.length;p<f;p++){let h=t.faceVertexUvs[p];this.faceVertexUvs[p]===void 0&&(this.faceVertexUvs[p]=[]);for(let m=0,y=h.length;m<y;m++){let g=h[m],b=[];for(let w=0,_=g.length;w<_;w++){let S=g[w];b.push(S.clone())}this.faceVertexUvs[p].push(b)}}let i=t.morphTargets;for(let p=0,f=i.length;p<f;p++){let h={};if(h.name=i[p].name,i[p].vertices!==void 0){h.vertices=[];for(let m=0,y=i[p].vertices.length;m<y;m++)h.vertices.push(i[p].vertices[m].clone())}if(i[p].normals!==void 0){h.normals=[];for(let m=0,y=i[p].normals.length;m<y;m++)h.normals.push(i[p].normals[m].clone())}this.morphTargets.push(h)}let a=t.morphNormals;for(let p=0,f=a.length;p<f;p++){let h={};if(a[p].vertexNormals!==void 0){h.vertexNormals=[];for(let m=0,y=a[p].vertexNormals.length;m<y;m++){let g=a[p].vertexNormals[m],b={};b.a=g.a.clone(),b.b=g.b.clone(),b.c=g.c.clone(),h.vertexNormals.push(b)}}if(a[p].faceNormals!==void 0){h.faceNormals=[];for(let m=0,y=a[p].faceNormals.length;m<y;m++)h.faceNormals.push(a[p].faceNormals[m].clone())}this.morphNormals.push(h)}let s=t.skinWeights;for(let p=0,f=s.length;p<f;p++)this.skinWeights.push(s[p].clone());let l=t.skinIndices;for(let p=0,f=l.length;p<f;p++)this.skinIndices.push(l[p].clone());let u=t.lineDistances;for(let p=0,f=u.length;p<f;p++)this.lineDistances.push(u[p]);let c=t.boundingBox;c!==null&&(this.boundingBox=c.clone());let d=t.boundingSphere;return d!==null&&(this.boundingSphere=d.clone()),this.elementsNeedUpdate=t.elementsNeedUpdate,this.verticesNeedUpdate=t.verticesNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.lineDistancesNeedUpdate=t.lineDistancesNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,this}toBufferGeometry(){let t=new ff().fromGeometry(this),e=new Ex,r=new Float32Array(t.vertices.length*3);if(e.setAttribute("position",Ou.call(new dl(r,3),t.vertices)),t.normals.length>0){let o=new Float32Array(t.normals.length*3);e.setAttribute("normal",Ou.call(new dl(o,3),t.normals))}if(t.colors.length>0){let o=new Float32Array(t.colors.length*3);e.setAttribute("color",Lx.call(new dl(o,3),t.colors))}if(t.uvs.length>0){let o=new Float32Array(t.uvs.length*2);e.setAttribute("uv",Rx.call(new dl(o,2),t.uvs))}if(t.uvs2.length>0){let o=new Float32Array(t.uvs2.length*2);e.setAttribute("uv2",Rx.call(new dl(o,2),t.uvs2))}e.groups=t.groups;for(let o in t.morphTargets){let i=[],a=t.morphTargets[o];for(let s=0,l=a.length;s<l;s++){let u=a[s],c=new Ra(u.data.length*3,3);c.name=u.name,i.push(Ou.call(c,u.data))}e.morphAttributes[o]=i}if(t.skinIndices.length>0){let o=new Ra(t.skinIndices.length*4,4);e.setAttribute("skinIndex",Vx.call(o,t.skinIndices))}if(t.skinWeights.length>0){let o=new Ra(t.skinWeights.length*4,4);e.setAttribute("skinWeight",Vx.call(o,t.skinWeights))}return t.boundingSphere!==null&&(e.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(e.boundingBox=t.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(t){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(t)}dispose(){this.dispatchEvent({type:"dispose"})}static createBufferGeometryFromObject(t){let e=new Ex,r=t.geometry;if(t.isPoints||t.isLine){let o=new Ra(r.vertices.length*3,3),i=new Ra(r.colors.length*3,3);if(e.setAttribute("position",Ou.call(o,r.vertices)),e.setAttribute("color",Lx.call(i,r.colors)),r.lineDistances&&r.lineDistances.length===r.vertices.length){let a=new Ra(r.lineDistances.length,1);e.setAttribute("lineDistance",RM.call(a,r.lineDistances))}r.boundingSphere!==null&&(e.boundingSphere=r.boundingSphere.clone()),r.boundingBox!==null&&(e.boundingBox=r.boundingBox.clone())}else t.isMesh&&(e=r.toBufferGeometry());return e}};Mn.prototype.isGeometry=!0;var ff=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(t){let e=[],r,o,i,a=t.faces;for(o=0;o<a.length;o++){let s=a[o];s.materialIndex!==i&&(i=s.materialIndex,r!==void 0&&(r.count=o*3-r.start,e.push(r)),r={start:o*3,materialIndex:i})}r!==void 0&&(r.count=o*3-r.start,e.push(r)),this.groups=e}fromGeometry(t){let e=t.faces,r=t.vertices,o=t.faceVertexUvs,i=o[0]&&o[0].length>0,a=o[1]&&o[1].length>0,s=t.morphTargets,l=s.length,u;if(l>0){u=[];for(let g=0;g<l;g++)u[g]={name:s[g].name,data:[]};this.morphTargets.position=u}let c=t.morphNormals,d=c.length,p;if(d>0){p=[];for(let g=0;g<d;g++)p[g]={name:c[g].name,data:[]};this.morphTargets.normal=p}let f=t.skinIndices,h=t.skinWeights,m=f.length===r.length,y=h.length===r.length;r.length>0&&e.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let g=0;g<e.length;g++){let b=e[g];this.vertices.push(r[b.a],r[b.b],r[b.c]);let w=b.vertexNormals;if(w.length===3)this.normals.push(w[0],w[1],w[2]);else{let S=b.normal;this.normals.push(S,S,S)}let _=b.vertexColors;if(_.length===3)this.colors.push(_[0],_[1],_[2]);else{let S=b.color;this.colors.push(S,S,S)}if(i===!0){let S=o[0][g];S!==void 0?this.uvs.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",g),this.uvs.push(new Ar,new Ar,new Ar))}if(a===!0){let S=o[1][g];S!==void 0?this.uvs2.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",g),this.uvs2.push(new Ar,new Ar,new Ar))}for(let S=0;S<l;S++){let P=s[S].vertices;u[S].data.push(P[b.a],P[b.b],P[b.c])}for(let S=0;S<d;S++){let P=c[S].vertexNormals[g];p[S].data.push(P.a,P.b,P.c)}m&&this.skinIndices.push(f[b.a],f[b.b],f[b.c]),y&&this.skinWeights.push(h[b.a],h[b.b],h[b.c])}return this.computeGroups(t),this.verticesNeedUpdate=t.verticesNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),this}},Va=class{constructor(t,e,r,o,i,a=0){this.a=t,this.b=e,this.c=r,this.normal=o&&o.isVector3?o:new $t,this.vertexNormals=Array.isArray(o)?o:[],this.color=i&&i.isColor?i:new hf,this.vertexColors=Array.isArray(i)?i:[],this.materialIndex=a}clone(){return new this.constructor().copy(this)}copy(t){this.a=t.a,this.b=t.b,this.c=t.c,this.normal.copy(t.normal),this.color.copy(t.color),this.materialIndex=t.materialIndex;for(let e=0,r=t.vertexNormals.length;e<r;e++)this.vertexNormals[e]=t.vertexNormals[e].clone();for(let e=0,r=t.vertexColors.length;e<r;e++)this.vertexColors[e]=t.vertexColors[e].clone();return this}};function RM(n){return this.array.set(n),this}function Lx(n){let t=this.array,e=0;for(let r=0,o=n.length;r<o;r++){let i=n[r];i===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",r),i=new hf),t[e++]=i.r,t[e++]=i.g,t[e++]=i.b}return this}function Rx(n){let t=this.array,e=0;for(let r=0,o=n.length;r<o;r++){let i=n[r];i===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",r),i=new Ar),t[e++]=i.x,t[e++]=i.y}return this}function Ou(n){let t=this.array,e=0;for(let r=0,o=n.length;r<o;r++){let i=n[r];i===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",r),i=new $t),t[e++]=i.x,t[e++]=i.y,t[e++]=i.z}return this}function Vx(n){let t=this.array,e=0;for(let r=0,o=n.length;r<o;r++){let i=n[r];i===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",r),i=new LM),t[e++]=i.x,t[e++]=i.y,t[e++]=i.z,t[e++]=i.w}return this}var zM=["a","b","c"];function GM(n,t){switch(t){case"c":return n.c;case"b":return n.b;case"a":default:return n.a}}function yf(n,t,e){let r=Math.min(n,t),o=Math.max(n,t),i=r+"_"+o;return e.get(i)}function gf(n,t,e,r,o,i){let a=Math.min(n,t),s=Math.max(n,t),l=a+"_"+s,u;if(r.has(l))u=r.get(l);else{let c=e[a],d=e[s];u={a:c,b:d,newEdge:null,faces:[]},r.set(l,u)}u.faces.push(o),i[n].edges.push(u),i[t].edges.push(u)}function FM(n,t,e,r){let o,i,a;for(o=0,i=n.length;o<i;o++)e[o]={edges:[]};for(o=0,i=t.length;o<i;o++)a=t[o],gf(a.a,a.b,n,r,a,e),gf(a.b,a.c,n,r,a,e),gf(a.c,a.a,n,r,a,e)}function Cu(n,t,e,r,o){n.push(new Va(t,e,r,void 0,void 0,o))}function za(n,t){return Math.abs(t-n)/2+Math.min(n,t)}function Tu(n,t,e,r){n.push([t.clone(),e.clone(),r.clone()])}var Mu=class{constructor(t=1){this.subdivisions=t}modify(t){t instanceof VM?t=new Mn().fromBufferGeometry(t):t=t.clone(),t.mergeVertices();let e=this.subdivisions;for(;e-- >0;)this._smooth(t);return t.computeFaceNormals(),t.computeVertexNormals(),t}_smooth(t){let e=new Gx,r,o,i,a,s,l=t.vertices,u=t.faces,c=t.faceVertexUvs[0],d=c!==void 0&&c.length>0,p=[],f=new Map;FM(l,u,p,f);let h=[],m,y,g,b,w,_,S;for(let ee of Array.from(f.keys())){for(y=f.get(ee),g=new Gx,w=3/8,_=1/8,S=y.faces.length,S!=2&&(w=.5,_=0,S!=1),g.addVectors(y.a,y.b).multiplyScalar(w),e.set(0,0,0),a=0;a<S;a++){for(b=y.faces[a],s=0;s<3&&(m=l[GM(b,zM[s])],!(m!==y.a&&m!==y.b));s++);m&&e.add(m)}e.multiplyScalar(_),g.add(e),y.newEdge=h.length,h.push(g)}let P,O,x,D,N,T,I,E=[];for(o=0,i=l.length;o<i;o++){for(T=l[o],N=p[o].edges,r=N.length,r==3?P=3/16:r>3&&(P=3/(8*r)),O=1-r*Number(P),x=P,r<=2&&(r==2?(O=3/4,x=1/8):r==1||r==0),I=T.clone().multiplyScalar(O),e.set(0,0,0),a=0;a<r;a++)D=N[a],m=D.a!==T?D.a:D.b,e.add(m);e.multiplyScalar(Number(x)),I.add(e),E.push(I)}let B=E.concat(h),R=E.length,F,V,q,k=[],U=[],H,$,J,K,X=new mf,te=new mf,Y=new mf;for(o=0,i=u.length;o<i;o++)b=u[o],F=Number(yf(b.a,b.b,f).newEdge)+R,V=Number(yf(b.b,b.c,f).newEdge)+R,q=Number(yf(b.c,b.a,f).newEdge)+R,Cu(k,F,V,q,b.materialIndex),Cu(k,b.a,F,q,b.materialIndex),Cu(k,b.b,V,F,b.materialIndex),Cu(k,b.c,q,V,b.materialIndex),d&&(H=c[o],$=H[0],J=H[1],K=H[2],X.set(za($.x,J.x),za($.y,J.y)),te.set(za(J.x,K.x),za(J.y,K.y)),Y.set(za($.x,K.x),za($.y,K.y)),Tu(U,X,te,Y),Tu(U,$,X,Y),Tu(U,J,te,X),Tu(U,K,Y,te));t.vertices=B,t.faces=k,d&&(t.faceVertexUvs[0]=U)}};var Nt=new jM,jx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=n.geometry??t?.geometry??new Fx().copy(new kx(100,100,100)),r;t===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(Nt),r={width:Nt.x,height:Nt.y,depth:Nt.z,subdivisions:0}):r=t.parameters;let o={...r,...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:t,height:e,depth:r,subdivisions:o}=n.parameters,i=n.geometry??new Fx().copy(new kx(100,100,100)),a=i.userData.parameters;a===void 0?(i.computeBoundingBox(),i.boundingBox.getSize(Nt)):Nt.set(a.width,a.height,a.depth),(t!==Nt.x||e!==Nt.y||r!==Nt.z)&&i.scale(Nt.x===0?1:t/Nt.x,Nt.y===0?1:e/Nt.y,Nt.z===0?1:r/Nt.z);let s=i.originalGeometry;try{o>0?(s===void 0||a?.subdivisions!==o)&&(s===void 0&&(s=i),i=new Mu(o).modify(s).toBufferGeometry()):(s!==void 0&&(i=s),s=void 0,i.getAttribute("normal")===void 0&&i.computeVertexNormals())}catch{s!==void 0&&(i=s),s=void 0,i.getAttribute("normal")===void 0&&i.computeVertexNormals()}return s!==void 0&&Object.assign(i,{originalGeometry:s}),delete n.geometry,Object.assign(i,{userData:{...n,type:"NonParametricGeometry"}})}static loadFromUrl(n,t,e){new kM(e).load(n,o=>{let i=this.normalizeInputs({geometry:o});o.boundingBox.getSize(Nt);let a=100/Nt.x;Object.assign(i.parameters,{width:100,height:Nt.y*a,depth:Nt.z*a}),t(this.build(i))})}};var Iu=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},n.parameters);return{shape:n.shape&&n.shape instanceof He?n.shape:new He,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:t,height:e,spikes:r,cornerRadius:o,depth:i,extrudeBevelSize:a,extrudeBevelSegments:s}=n.parameters,l=n.shape,u=t*.5,c=e*.5,d=0,p=0,f=2*Math.PI/r;for(let m=0;m<r;m++){let y=f*m,g=d+Math.sin(y)*u,b=p+Math.cos(y)*c;l.addPoint(l.createPoint(g,b))}l.isClosed=!0;for(let m=0,y=l.points.length;m<y;m++)l.points[m].roundness=o;l.roundness=o,l.update();let h=dr.create({shape:l,parameters:{roundness:o,depth:i,extrudeBevelSize:a,extrudeBevelSegments:s}});return Object.assign(h,{userData:{...n,type:"PolygonGeometry"}})}};import{BufferGeometry as UM,Float32BufferAttribute as xf,Vector2 as bo,Vector3 as zt}from"three";var Ux=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.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:t,height:e,depth:r,radialSegments:o,heightSegments:i,openEnded:a,cornerRadius:s,cornerSegments:l}=n.parameters,u=new vf(t*.5,e,o,i,a,s,l);return u.scale(1,1,r/t),Object.assign(u,{userData:{...n,type:"PyramidGeometry"}})}};function pl(n,t,e){e.x=n.x*t.x,e.y=n.y,e.z=n.x*t.y}function bf(n,t,e,r,o,i){let a=t.clone().sub(n),s=e.clone().sub(n),l=a.angleTo(s);if(a.normalize(),s.normalize(),r===o){let u=a.add(s).normalize();i.copy(n).addScaledVector(u,r/Math.sin(l/2))}else{let u=a.angleTo(s);i.copy(n),i.addScaledVector(a,o/Math.sin(u)),i.addScaledVector(s,r/Math.sin(u))}}function HM(n,t,e){let r=n.clone().sub(t),o=e.clone().sub(t);return r.projectOnVector(o),r.add(t)}var vf=class extends UM{constructor(t=.5,e=1,r=4,o=1,i=!1,a=0,s=4){super(),r=Math.floor(Math.max(3,r)),o=Math.floor(o),s=Math.floor(s);let l=[],u=[],c=[],d=[],p=0,f=e/2,h=Math.PI/r,m=t*Math.cos(Math.PI/r),y=2*Math.PI/r,g=(r-2)*Math.PI/r,b=Math.PI-g,w=new zt(0,-f,0),_=new zt(0,f,0),S=new bo(t,-f),P=new bo(m,-f),O=new bo(0,_.y).sub(P),x=new bo(0,_.y).sub(S),D=new bo(O.y,-O.x).normalize(),N=new bo(x.y,-x.x).normalize(),I=t*Math.cos(Math.PI/r)*Math.tan((Math.PI-O.angle())/2)-1e-8;a=Math.min(a,I);let E;{let U=new zt(D.x,D.y,0),H=new zt(Math.cos(y)*U.x,U.y,Math.sin(y)*U.x);E=U.angleTo(H)}let B=a/Math.tan((Math.PI-O.angle())/2),R=a/Math.tan((Math.PI-E)/2),F=new zt;if(!i){u.push(w.x,w.y,w.z),c.push(0,-1,0),d.push(0,0);let U=p++,H=[],$=S.clone(),J=B/Math.cos(Math.PI/r);$.x-=J;for(let K=0;K<r;K++){let X=K/r*Math.PI*2+h,te=new bo(Math.sin(X),Math.cos(X));pl($,te,F),u.push(F.x,F.y,F.z),c.push(0,-1,0),d.push(0,0),H.push(p++)}for(let K=0;K<H.length;K++)l.push(H[K],U,H[(K+1)%H.length])}let V=[];{let U=new zt,H=new zt,$=new zt,J=new zt,K=new zt,X=new zt;for(let te=0;te<r;te++){let Y=te/r*Math.PI*2+h,ee=(te+.5)/r*Math.PI*2+h,Q=(te+1)/r*Math.PI*2+h,W=new bo(Math.sin(Y),Math.cos(Y)),ue=new bo(Math.sin(ee),Math.cos(ee)),le=new bo(Math.sin(Q),Math.cos(Q));pl(S,W,H),pl(S,le,$),pl(D,ue,U),bf(_,H,$,R,R,J),u.push(J.x,J.y,J.z),bf(H,_,$,R,B,K),u.push(K.x,K.y,K.z),bf($,H,_,B,R,X),u.push(X.x,X.y,X.z),c.push(U.x,U.y,U.z),c.push(U.x,U.y,U.z),c.push(U.x,U.y,U.z),d.push(0,0),d.push(0,0),d.push(0,0);let ne=p++,ce=p++,ae=p++;if(l.push(ne,ce,ae),a>0){{let fe=H.clone().add($).multiplyScalar(.5),ge=_.clone().sub(fe).normalize(),C=w.clone().sub(fe).normalize().add(ge).normalize().multiplyScalar(-1),ie=X.clone().sub(K);q(fe,ie,C,O.angle())}let he,pe;{let fe=new zt;pl(N,le,fe);let ge=X.clone().add(J).multiplyScalar(.5);ge=HM(ge,$,_);let me=X.clone().sub(J);[he,pe]=q(ge,me,fe,E,J.y)}{let fe=he,ge=fe.clone().setY(0).normalize(),me=new zt(0,-1,0),C=ge.clone().cross(me);k(fe,ge,me,C)}V.concat(pe);{let fe=O.angle(),ge=Math.PI-fe,me=_.clone();me.y-=a/Math.sin(fe-Math.PI/2);let C=new zt,ie=[];for(let Ge=0;Ge<s;Ge++){let Ee=[],_e=Math.PI/2-ge*Ge/s,Ct=Math.cos(_e),Me=Math.sin(_e),At=ee;for(let Tt=0;Tt<=Ge;Tt++){let Wn=Math.cos(At),st=Math.sin(At);U.x=Ct*st,U.y=Me,U.z=Ct*Wn,C.copy(me).addScaledVector(U,a),u.push(C.x,C.y,C.z),c.push(U.x,U.y,U.z),d.push(0,0),Ee.push(p++),At+=Math.PI*2/Ge/r}ie.push(Ee)}pe.reverse(),ie.push(pe);let De=ie.length-1;for(let Ge=0;Ge<De;Ge++){let Ee=ie[Ge],_e=ie[Ge+1],Ct=Ee.length-1;l.push(_e[1],Ee[0],_e[0]);for(let Me=1;Me<=Ct;Me++)l.push(Ee[Me],Ee[Me-1],_e[Me]),l.push(_e[Me+1],Ee[Me],_e[Me])}}}}}this.setIndex(l),this.setAttribute("position",new xf(u,3)),this.setAttribute("normal",new xf(c,3)),this.setAttribute("uv",new xf(d,2));function q(U,H,$,J,K){let X=-J/2,te=(Math.PI-J)/2,Y=H.clone().normalize().cross($);U.addScaledVector($,-a/Math.sin(te));let ee=new zt,Q=new zt,W=1,ue=p,le=[];for(let ne=0;ne<=s;ne++){let ce=X+ne/s*J;Q.set(0,0,0),Q.addScaledVector(Y,Math.sin(ce)),Q.addScaledVector($,Math.cos(ce));for(let ae=0;ae<=W;ae++){let he=ae/W-.5;if(ee.copy(U),ee.addScaledVector(H,he),ee.addScaledVector(Q,a),K!=null){let pe=Math.max(0,ee.y-K);ee.addScaledVector(H,-pe/H.y)}u.push(ee.x,ee.y,ee.z),c.push(Q.x,Q.y,Q.z),d.push(0,0),ae===0&&le.push(p),p++}}for(let ne=0;ne<s;ne++)for(let ce=0;ce<W;ce++){let ae=ue+ce+(W+1)*ne,he=ae+(W+1),pe=he+1,fe=ae+1;l.push(ae,he,fe),l.push(he,pe,fe)}return[U.clone().addScaledVector(H,.5),le]}function k(U,H,$,J){let K=Math.PI/2,X=x.angle()-K,te=[],Y=new zt,ee=new zt;for(let W=0;W<=s;W++){let ue=[],le=W/s;for(let ne=0;ne<=W;ne++){let ae=((W?ne/W:0)-.5)*b,he=Math.cos(ae),pe=Math.sin(ae),fe=Math.atan(Math.tan(X)*he),ge=(K+fe)*le,me=Math.cos(ge),C=Math.sin(ge);Y.set(0,0,0),Y.addScaledVector(H,C*he),Y.addScaledVector($,me),Y.addScaledVector(J,C*pe),ee.copy(U).addScaledVector(Y,a),u.push(ee.x,ee.y,ee.z),c.push(Y.x,Y.y,Y.z),d.push(0,0),ue.push(p++)}te.push(ue)}let Q=te.length-1;for(let W=0;W<Q;W++){let ue=te[W],le=te[W+1],ne=ue.length-1;l.push(ue[0],le[1],le[0]);for(let ce=1;ce<=ne;ce++)l.push(ue[ce-1],ue[ce],le[ce]),l.push(ue[ce],le[ce+1],le[ce])}}}};var Ga=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters),r=Object.assign(t?.ui??{enabledIndieCorners:!1},n.ui);return{shape:n.shape&&n.shape instanceof He?n.shape:new He,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)}),ui:r}}static build(n){let t=n.shape,{width:e,height:r,cornerRadius:o,cornerType:i,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}=n.parameters,u={x:e*.5,y:r*.5},c={x:-u.x,y:-u.y},d={x:u.x,y:u.y};function p(_,S,P){return S>e&&P>r?Math.min(_*e/S,_*r/P):S>e?_*e/S:P>r?_*r/P:_}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 h=c.x,m=d.x,y=d.y,g=c.y;t.addPoint(t.createPoint(h,y)),t.addPoint(t.createPoint(m,y)),t.addPoint(t.createPoint(m,g)),t.addPoint(t.createPoint(h,g)),t.isClosed=!0;let b=!0;for(let _=0,S=t.points.length;_<S;_++)t.points[_].roundness=f[_],_>0&&f[_]!==f[_-1]&&(b=!1);b&&(t.roundness=f[0]),t.useCubicForRoundedCorners=i!==1,t.update();let w=dr.create({shape:t,parameters:{depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}});return Object.assign(w,{userData:{...n,type:"RectangleGeometry"}})}};import{BufferGeometry as qM,Float32BufferAttribute as WM,MathUtils as Hx,SphereGeometry as $M}from"three";var qx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180},n.parameters);return e.thetaLength=Hx.clamp(e.thetaLength,0,180),{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:t=100,height:e=t,depth:r=t,widthSegments:o=64,heightSegments:i=64,phiStart:a,phiLength:s,thetaStart:l,thetaLength:u}=n.parameters,c;return u===0?(c=new qM,c.setAttribute("position",new WM([],3))):c=new $M(.5*t,o,i,a,s,l,u*Hx.DEG2RAD),c.scale(1,e/t,r/t),Object.assign(c,{userData:{...n,type:"SphereGeometry"}})}};import{PlaneGeometry as YM}from"three";var Wx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.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:t=100,height:e=t,widthSegments:r=8,heightSegments:o=8}=n.parameters,i=new YM(t,e,r,o);return i.scale(1,1,1),Object.assign(i,{userData:{...n,type:"PlaneGeometry"}})}};import{BufferGeometry as XM,Float32BufferAttribute as Sf,Vector3 as QM}from"three";var $x=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.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:t,height:e,depth:r,angle:o,cornerRadius:i,cornerSegments:a}=n.parameters,s=new wf(t,e,r,o,i,a);return Object.assign(s,{userData:{...n,type:"BackdropGeometry"}})}},wf=class extends XM{constructor(t=1,e=1,r=1,o=90,i=10,a=24){super(),this.type="BackdropGeometry";let s=[],l=[],u=[],c=.001;i==0&&(a=1),a=Math.max(1,Math.floor(a)),i=Math.min(i,100),o=Math.min(180-c,o),o*=Math.PI/180;let d=[],p=Math.PI/2,f=(ee=0,Q=0,W=0)=>new QM(ee,Q,W),h=f(),m=f(),[y,g,b]=[e/2,t/2,r/2],w=-g,_=+g,[S,P,O]=[f(w,-y,+b),f(w,-y,-b),f(w,+y,-b)],x=(ee,Q=!1)=>Math.sin(ee-Math.PI/(1+ +Q)),D=(ee,Q=!1)=>Math.cos(ee-Math.PI/(1+ +Q));O.y=Math.sin(o)*e-y;let N=Math.cos(o)*e-b,T=S.z-c;o<=p?(O.z=Math.min(N,T),O.z==T&&(O.y-=(N-T)/Math.tan(p-o))):P.z=Math.min(P.z-N-b,S.z-c),h.subVectors(S,P),m.subVectors(O,P);let I=Math.min(h.length(),m.length())*i/100,E=I*Math.tan(o/2),B=I/Math.cos(o/2),R=h.clone().normalize().add(m.normalize()).setLength(B).add(P);h.set(0,x(o,!0),D(o,!0)),d.push([O,h.clone()]);let F=(Math.PI-o)/a;for(let ee=0;ee<=a;ee++){let Q=p+o+ee*F;h.set(0,Math.sin(Q)*E,Math.cos(Q)*E),h.add(R),m.set(0,x(Q),D(Q)),d.push([h.clone(),m.clone()])}d.push([S,f(0,1,0)]);let V=Math.sin(F/2)*E*2,q=d.length-1,k=d[0][0].distanceTo(d[1][0]),U=d[q-1][0].distanceTo(d[q][0]),H=k+V*a+U;d[0].push(1);for(let ee=0;ee<=a;ee++)d[ee+1].push(1-(k+ee*V)/H);d[q].push(0);let[$,J,K]=d[0],X,te,Y;for(let ee=1;ee<d.length;ee++)[X,te,Y]=d[ee],s.push(w,$.y,$.z,w,X.y,X.z,_,$.y,$.z,_,$.y,$.z,w,X.y,X.z,_,X.y,X.z),l.push(0,J.y,J.z,0,te.y,te.z,0,J.y,J.z,0,J.y,J.z,0,te.y,te.z,0,te.y,te.z),u.push(0,K,0,Y,1,K,1,K,0,Y,1,Y),[$,J,K]=[X,te,Y];this.setAttribute("position",new Sf(s,3)),this.setAttribute("normal",new Sf(l,3)),this.setAttribute("uv",new Sf(u,2))}};var Nu=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.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 He?n.shape:new He,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:t,height:e,innerRadiusPercent:r,spikes:o,cornerRadius:i,angle:a,depth:s,extrudeBevelSize:l,extrudeBevelSegments:u}=n.parameters,c=n.shape,d=t*.5,p=e*.5,f=0,h=0,m=a*Math.PI/360/o,y=Math.PI/2*3*-1,g=d*r/100,b=p*r/100;if(o===3&&r===50){m=2*Math.PI/o;for(let _=0;_<o;_++){let S=m*_,P=f+Math.sin(S)*d,O=h+Math.cos(S)*p;c.addPoint(c.createPoint(P,O))}}else for(let _=0;_<o;_++){let S=f+Math.cos(y)*d,P=h+Math.sin(y)*p;c.addPoint(c.createPoint(S,P)),y+=m,S=f+Math.cos(y)*g,P=h+Math.sin(y)*b,_<=o,c.addPoint(c.createPoint(S,P)),y+=m}c.isClosed=!0;for(let _=0,S=c.points.length;_<S;_++)c.points[_].roundness=i;c.roundness=i,c.update();let w=dr.create({shape:c,parameters:{roundness:i,depth:s,extrudeBevelSize:l,extrudeBevelSegments:u}});return Object.assign(w,{userData:{...n,type:"StarGeometry"}})}};import{PlaneGeometry as KM}from"three";var Yx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.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:t,height:e}=n.parameters,r=new KM(t,e);return Object.assign(r,{userData:{...n,type:"TextFrameGeometry"}})}};import{BufferGeometry as ZM,Float32BufferAttribute as JM,MathUtils as eI}from"three";var Xx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:360,cornerRadius:30,cornerSegments:8},n.parameters),r=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:r,height:o,depth:i})}}static build(n){let{width:t,height:e,depth:r,radialSegments:o,tubularSegments:i,arc:a,cornerRadius:s,cornerSegments:l}=n.parameters,u=tI(t,e,r,t*.5,a,i,0,0,o,s,l);return u.scale(1,e/t,1),Object.assign(u,{userData:{...n,type:"TorusGeometry"}})}};function tI(n,t,e,r,o,i,a,s,l,u,c){[t,e]=[e,t],a=t/2;let d=eI.clamp(o/360,0,1);if(d===0){let p=new ZM;return p.setAttribute("position",new JM([],3)),p}return d===1&&(u=0),new cl(!0,n,t,e,r,d,i,a,s,l,u,c)}import{TorusKnotGeometry as rI}from"three";var Qx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.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:t,tube:e,tubularSegments:r,radialSegments:o,p:i,q:a}=n.parameters,s=t*.5;s!==e&&(s-=e);let l=new rI(s,e,r,o,i,a);return Object.assign(l,{userData:{...n,type:"TorusKnotGeometry"}})}};var Kx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},n.parameters);return{shape:n.shape&&n.shape instanceof He?n.shape:new He,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:t=100,height:e,cornerRadius:r,depth:o,extrudeBevelSize:i,extrudeBevelSegments:a,isRect:s}=n.parameters,l=n.shape,u=t*.5,c=e*.5;s?(l.addPoint(l.createPoint(-u,c)),l.addPoint(l.createPoint(u,-c)),l.addPoint(l.createPoint(-u,-c))):(l.addPoint(l.createPoint(0,c)),l.addPoint(l.createPoint(u,-c)),l.addPoint(l.createPoint(-u,-c))),l.isClosed=!0;for(let p=0,f=l.points.length;p<f;p++)l.points[p].roundness=r;l.roundness=r,l.update();let d=dr.create({shape:l,parameters:{roundness:r,depth:o,extrudeBevelSize:i,extrudeBevelSegments:a}});return Object.assign(d,{userData:{...n,type:"TriangleGeometry"}})}};import{Vector2 as Jx,Vector3 as Gt,Matrix3 as oI,Matrix4 as li,BufferGeometry as eb,BufferAttribute as Fa,MathUtils as Du}from"three";function Zx(n,t){let e=2*Math.PI;return(n%e+e)%e===(t%e+e)%e}var nI=new li,iI=new li;function aI(n,t,e){let r=[new Gt,new Gt,new Gt],o=[new Gt,new Gt,new Gt];return n.extractBasis(r[0],r[1],r[2]),t.extractBasis(o[0],o[1],o[2]),r.forEach((i,a)=>{let s=o[a],l=Du.lerp(i.length(),s.length(),e);i.lerp(s,e).setLength(l)}),new li().makeBasis(r[0],r[1],r[2])}var tb=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},n.parameters),r=Math.abs(e.width),o=Math.abs(e.height??e.width),i=Math.abs(e.depth??0),a=t?.shapeData??La.create({parameters:mp}).userData.shape;return{path:n.path??fa.defaultData(),parameters:Object.assign(e,{width:r,height:o,depth:i,extrusion:{...Hc,...e.extrusion}}),shapeData:a}}static build(n){if(n.path.points.length>=2){let e=new Af(n);return Object.assign(e,{userData:{...n,type:"PathGeometry"}})}else return Object.assign(new eb,{userData:{...n,type:"PathGeometry"}})}},Af=class extends eb{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)||!Zx(e.twist,0)||e.startScale!==e.endScale}build(){let e=this._extractPathPoints();if(e.length<2)return;let r=this._computeBasisMatrices(e),{depth:o,offset:i}=this.inputs.parameters.extrusion;o=Math.max(0,Math.min(o,1)),i=Math.max(0,Math.min(i,1));let a=this.inputs.path.isClosed?e.length:e.length-1,s=Math.floor(i*a),l=this.inputs.path.isClosed?Math.ceil((o+i)*a):Math.ceil(Math.min(1,o+i)*a),u=Math.min(Math.max(2,l-s+1),a+2),c=[],d=[];for(let k=0;k<u;k++){let U=this.inputs.path.isClosed?(k+s)%e.length:Math.min(k+s,e.length-1);c.push(e[U].clone()),d.push(r[U].clone())}let p=(k,U,H)=>{c[k]=c[k].clone().lerp(c[U],H),d[k]=aI(d[k],d[U],H)},f=0,h=i*a%1;(!this.inputs.path.isClosed||o<=1)&&(h||i===0)&&(f=h,p(0,1,f));let m=0,y=(i+o)*a%1;if((this.inputs.path.isClosed&&o<=1||!this.inputs.path.isClosed&&i+o<1)&&y&&(m=y,p(c.length-1,c.length-2,1-m)),o===0){let k=c.length-1;c[k].copy(c[0]),d[k].copy(d[0])}this._applyPathModifiers(d,f,m);let{bevel:g,bevelSides:b}=this.inputs.parameters.extrusion,w=g>0?this.inputs.parameters.extrusion.capType:"flat",_=5;this.inputs.parameters.extrusion.shape.type==="Custom"&&(_=this.inputs.parameters.extrusion.shape.shapeQuality==="low"?5:12);let{regions:S,infos:P,vertices:O}=this._computeShapePoints(_),x=0,D;w==="round"&&(D=new Tn(this.inputs.shapeData,2*g,g,_,b,void 0,!0),x=D.getAttribute("position").count);let N=0,T=0;P.sort((k,U)=>k.start-U.start),P.forEach(k=>{k.verticesStart=N,k.verticesCount=k.continuous.reduce((U,H,$)=>U+($===0||!H?2:1),0),T+=k.verticesCount,N=T});let I=T*u,E,B=0;if(this._isOpenEnded()&&w==="flat"){try{E=Qr({windingRule:je.ODD,elementType:dt.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:S})}catch{E=lf}B=E.vertexCount}let R=I+2*B+x*2,F=I+2*B,V={positions:new Float32Array(R*3),normals:new Float32Array(R*3),uvs:new Float32Array(R*2)},q=[];if(P.forEach(k=>{this._extrudeRegion(k,O,d,c,V,q,this._isGeometryClosed()&&!this._isOpenEnded())}),E&&(this._closeEnd(E,I,q,V,d[0],c[0],!1),this._closeEnd(E,I+B,q,V,d[d.length-1],c[c.length-1],!0)),D){V.positions.set(D.getAttribute("position").array,F*3),V.normals.set(D.getAttribute("normal").array,F*3),V.uvs.set(D.getAttribute("uv").array,F*2);let k=q.length;q.push(...D.getIndex().array.map($=>$+F)),F+=x,V.positions.set(D.getAttribute("position").array,F*3),V.normals.set(D.getAttribute("normal").array,F*3),V.uvs.set(D.getAttribute("uv").array,F*2);let U=q.length;q.push(...D.getIndex().array.map($=>$+F)),this.setAttribute("position",new Fa(V.positions,3)),this.setAttribute("normal",new Fa(V.normals,3)),this.setAttribute("uv",new Fa(V.uvs,2)),this.setIndex(q);let H=nI;H.copy(d[d.length-1]).setPosition(c[c.length-1]),this.applyMatrix4OnRange(H,F,R),H.copy(d[0]).setPosition(c[0]).multiply(iI.makeScale(1,1,-1)),this.applyMatrix4OnRange(H,F-x,F),this.reverseIndicesOnRange(k,U)}else this.setAttribute("position",new Fa(V.positions,3)),this.setAttribute("normal",new Fa(V.normals,3)),this.setAttribute("uv",new Fa(V.uvs,2)),this.setIndex(q)}_extractPathPoints(){let r=du(this.inputs.path).getPoints(this.inputs.path.subdivisions);if(r.length<2)return[];let o=[r[0]];return r.forEach(a=>{o[o.length-1].distanceToSquared(a)>.001&&o.push(a)}),this.inputs.path.isClosed&&o[o.length-1].distanceTo(o[0])<.001&&o.pop(),o}_computeBasisMatrices(e){let r=[],o=e.length,i=this.inputs.path.isClosed,a=new Gt,s=new Gt,l=new Gt,u=new Gt,c=new Gt(0,1,0);for(let y=0;y<o;y++){let g=e[y],b;y===0?b=i?e[e.length-2]:g.clone().multiplyScalar(2).sub(e[1]):b=e[y-1];let w;y===o-1?w=i?e[1]:g.clone().multiplyScalar(2).sub(e[y-1]):w=e[y+1];let _=g.clone().sub(b).normalize(),S=w.clone().sub(g).normalize(),P=_.clone().add(S).normalize();l.copy(P),y===0&&(P.equals(c)||P.clone().negate().equals(c))&&c.set(0,0,1);let O=c.clone().cross(P).normalize(),x=P.clone().cross(O).normalize();c.copy(x),u.copy(O),y===0&&(a.copy(x),s.copy(P));let D=new li().makeBasis(O,x,P);r.push(D)}let d=i?s:l,p=i?a:new Gt(0,1,0),f=d.clone().cross(u).normalize(),h=Math.acos(p.dot(f));if(isNaN(h))return r;let m=p.clone().cross(f);d.dot(m)>0&&(h*=-1);for(let y=1;y<r.length;y++){let g=new li().makeRotationZ(h*y/r.length);r[y].multiply(g)}return r}_applyPathModifiers(e,r,o){let i=e.length,{angle:a,twist:s,startScale:l,endScale:u}=this.inputs.parameters.extrusion,c=new li,d=new li;return e.forEach((p,f)=>{let h=f===0?0:f===i-1?1:(f-r)/(i-(o===0?0:1)-(r+(1-o)));c.makeRotationZ(Du.lerp(a,a+s,h)*Du.DEG2RAD);let m=Du.lerp(l,u,h);d.makeScale(m,m,m),p.multiply(c).multiply(d)}),e}_computeShapePoints(e=12,r=je.ODD){let o=this.inputs.shapeData,i=o.extractShapePointsToFlatArray([],e),a=o.shapeHoles.map(m=>{let y=m.extractShapePointsToFlatArray([],e),g=[];for(let b=y.length-1;b>=1;b-=2){let w=y[b-1],_=y[b-0];g.push(w,_)}return g}),s;try{s=Qr({windingRule:r,elementType:dt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[i]})}catch{s=ll}let l;try{l=Qr({windingRule:je.ODD,elementType:dt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...a]})}catch{l=sf}if(!s)throw new Error("error generating geometry");let u=s.elementCount;if(l){s.elementCount+=l.elementCount;for(let m=0;m<l.elements.length;m++){let y=l.elements[m],g=m%2===0?s.vertexCount:0;s.elements.push(y+g)}for(let m=0;m<l.vertexIndices.length;m++){let y=l.vertexIndices[m],g=s.vertexCount;s.vertexIndices.push(y+g)}for(let m=0;m<l.vertices.length;m++){let y=l.vertices[m];s.vertices.push(y)}}let c=1/0,d=-1/0,p=1/0,f=-1/0;for(let m=0,y=s.vertexCount;m<y;m++){let g=m*2,b=s.vertices[g+0],w=s.vertices[g+1];b<c&&(c=b),b>d&&(d=b),w<p&&(p=w),w>f&&(f=w)}let h=[];for(let m=s.elementCount-1;m>=0;m--){let y=m>=u,g=m*2,b=s.elements[g+0],w=s.elements[g+1],_=b+w,S={start:b,count:w,normals:[],isHole:y,continuous:[],verticesStart:0,verticesCount:0};h.push(S);let P=b,O=_-1,x=b+1,D=o.roundedCurves.length;do{let N=P-b,T=s.vertices[O*2+0],I=s.vertices[O*2+1],E=s.vertices[P*2+0],B=s.vertices[P*2+1],R=s.vertices[x*2+0],F=s.vertices[x*2+1],V=E-T,q=B-I,k=Math.sqrt(V*V+q*q);V/=k,q/=k;let U=E-R,H=B-F,$=Math.sqrt(U*U+H*H);U/=$,H/=$,S.normals[N*2+0]=-H,S.normals[N*2+1]=U;let J=s.vertexIndices[P];if(Array.isArray(J))S.continuous[N]=!1;else{let[K,X]=o.getCurveIndexFromVertexId(J-1,!0);if(X>0&&X<1)S.continuous[N]=!0;else{let te=X===1?K+1:K-1;te=(te+D)%D;let Y=X===1?0:1,ee=o.roundedCurves[K].getTangent(X),Q=o.roundedCurves[te].getTangent(Y);S.continuous[N]=ee.dot(Q)>.95}}y&&(S.normals[N*2+0]*=-1,S.normals[N*2+1]*=-1),[O,P,x]=[P,x,x+1],x>=_&&(x-=w)}while(x!==b+1)}return{regions:[i,...a],infos:h,vertices:s.vertices}}_insertVertex(e,r,o,i,a){let s=r*2,l=r*3;e.positions[l+0]=o.x,e.positions[l+1]=o.y,e.positions[l+2]=o.z,e.normals[l+0]=i.x,e.normals[l+1]=i.y,e.normals[l+2]=i.z,e.uvs[s+0]=a.x,e.uvs[s+1]=a.y}_extrudeRegion(e,r,o,i,a,s,l){let u=new Gt,c=new Gt,d=new Gt,p=new Gt,f=new Jx;o.forEach((m,y)=>{let g=i[y],b=e.verticesStart*o.length+e.verticesCount*y;for(let w=0;w<e.count;w++){let _=(e.start+w)*2;if(u.set(r[_+0],r[_+1],0),d.copy(u).applyMatrix4(m).add(g),e.continuous[w])p.set(e.normals[w*2+0],e.normals[w*2+1],0);else{let S=w===0?(e.start+e.count-1)*2:_-2;c.set(r[S+0],r[S+1],0),p.copy(u).sub(c),p.set(-p.y,p.x,0),e.isHole||p.negate()}if(p.applyMatrix4(m).normalize(),f.set(w===0?1:w/e.count,y/(o.length-1)),this._insertVertex(a,b,d,p,f),b++,!e.continuous[w]||w===0){if(w===0)p.set(e.normals[w*2+0],e.normals[w*2+1],0),f.set(0,y/(o.length-1));else{let S=w===e.count-1?e.start*2:_+2;c.set(r[S+0],r[S+1],0),p.copy(c).sub(u),p.set(-p.y,p.x,0),e.isHole||p.negate()}p.applyMatrix4(m).normalize(),this._insertVertex(a,b,d,p,f),b++}}});let h=o.length-1;for(let m=0;m<h;m++){let y=e.verticesStart*o.length+e.verticesCount*m,g=e.verticesStart*o.length+e.verticesCount*(m+1),b=0;for(let w=0;w<e.count;w++){(!e.continuous[w]||w===0)&&b++;let _=w===e.count-1?0:b+1,S=y+b,P=y+_,O=g+_,x=g+b;e.isHole?s.push(S,O,P,S,x,O):s.push(S,P,O,S,O,x),b++}}}_closeEnd(e,r,o,i,a,s,l){let u=e.vertexCount,c=new Gt(0,0,l?-1:1).applyMatrix4(a),d=new Gt,p=new Jx;for(let h=0;h<u;h++){let m=2*h;d.set(e.vertices[m+0],e.vertices[m+1],0).applyMatrix4(a).add(s),this._insertVertex(i,r+h,d,c,p)}let f=e.elements;for(let h=0;h<e.elementCount;h++){let m=3*h,y=f[m+0]+r,g=f[m+(l?1:2)]+r,b=f[m+(l?2:1)]+r;o.push(y,g,b)}}applyMatrix4OnRange(e,r,o){let i=e.elements,a=new oI().getNormalMatrix(e).elements,s,l,u,c,d=this.attributes.position,p=this.attributes.normal;if(!d||!p)return;let f=d.array,h=p.array,m=d.itemSize;for(let y=r*m,g=o*m;y<g;y+=m){if(y===r)debugger;s=f[y+0],l=f[y+1],u=f[y+2],c=1/(i[3]*s+i[7]*l+i[11]*u+i[15]),f[y+0]=(i[0]*s+i[4]*l+i[8]*u+i[12])*c,f[y+1]=(i[1]*s+i[5]*l+i[9]*u+i[13])*c,f[y+2]=(i[2]*s+i[6]*l+i[10]*u+i[14])*c,s=h[y+0],l=h[y+1],u=h[y+2],h[y+0]=a[0]*s+a[3]*l+a[6]*u,h[y+1]=a[1]*s+a[4]*l+a[7]*u,h[y+2]=a[2]*s+a[5]*l+a[8]*u}d.needsUpdate=!0,p.needsUpdate=!0}reverseIndicesOnRange(e,r){let o=this.index;if(o){for(let i=e;i<r;i+=3){let a=o.getX(i),s=o.getX(i+1),l=o.getX(i+2);o.setXYZ(i,l,s,a)}o.needsUpdate=!0}}};import{BufferAttribute as rb,BufferGeometry as _f}from"three";import{mergeBufferGeometries as lI}from"three/examples/jsm/utils/BufferGeometryUtils.js";function ob(){let n=new _f;return n.setAttribute("position",new rb(new Float32Array([]),3)),n.setIndex(new rb(new Uint16Array([]),1)),n}var cI=ob().attributes,uI=12,dI=1,ka=class extends _f{constructor(e,r){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];Object.assign(this.attributes,cI),this.userData={parameters:e,type:"TextGeometry"};let o=r.getFont(e.font);o?.isLoaded?(this.font=o,this.update(e)):this.updateFont(e.font,r).then(()=>{this.update(e),r?.requestRender()})}async updateFont(e,r){let o=r.getFont(e);o&&(this.font=o,await o.loadingPromise)}update(e){let r=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!r?.isLoaded){console.warn("Cannot update text because its font is not loaded");return}let{width:o,height:i,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l,text:u,textTransform:c}=e,d=Jc.getDisplayedValue(u),p=c===2?d.toUpperCase():c===3?d.toLowerCase():d,f=pI(e,r,p),{shapes:h,charWidths:m,charCoords:y}=r.generateShapes(f,e),g=(typeof o=="number"?o:1)*.5,b=(typeof i=="number"?i:1)*.5,w=h.map(P=>new He().fromShape(P,!0));this.vectorShapes=w;let _=w.map(P=>dr.create({shape:P,parameters:{depth:a,extrudeBevelSegments:l,extrudeBevelSize:s,windingRule:a<=0?je.NONZERO:je.ODD,subdivisions:this.isLowResolution&&a>0?dI:uI}})),S=_.length?lI(_):ob();S.translate(-g,b,0),this.dispose(),this.wrappedText=f,this.charCoords=y,this.charWidths=m,this.deleteAttribute("extrudeNormal"),Object.entries(S.attributes).forEach(([P,O])=>{this.setAttribute(P,O)}),this.setIndex(S.index),this.computeBoundingSphere()}clone(){let e=rr(new _f,ka.prototype);return e.copy(this),console.log("CloneGeometry",this,e),e}copy(e){return Object.entries(e.attributes).forEach(([r,o])=>{this.setAttribute(r,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 pI(n,t,e){let r=[""],o="";for(let i of e)o+=i,i===" "||i===`
16
+ `));return d(gE.bind(void 0,n))}WS.exports=xE});var XS=Zt((Ide,YS)=>{"use strict";var bE=$S();function vE(){this.argTypes=[],this.shimArgs=[],this.arrayArgs=[],this.arrayBlockIndices=[],this.scalarArgs=[],this.offsetArgs=[],this.offsetArgIndex=[],this.indexArgs=[],this.shapeArgs=[],this.funcName="",this.pre=null,this.body=null,this.post=null,this.debug=!1}function SE(n){var t=new vE;t.pre=n.pre,t.body=n.body,t.post=n.post;var e=n.args.slice(0);t.argTypes=e;for(var r=0;r<e.length;++r){var o=e[r];if(o==="array"||typeof o=="object"&&o.blockIndices){if(t.argTypes[r]="array",t.arrayArgs.push(r),t.arrayBlockIndices.push(o.blockIndices?o.blockIndices:0),t.shimArgs.push("array"+r),r<t.pre.args.length&&t.pre.args[r].count>0)throw new Error("cwise: pre() block may not reference array args");if(r<t.post.args.length&&t.post.args[r].count>0)throw new Error("cwise: post() block may not reference array args")}else if(o==="scalar")t.scalarArgs.push(r),t.shimArgs.push("scalar"+r);else if(o==="index"){if(t.indexArgs.push(r),r<t.pre.args.length&&t.pre.args[r].count>0)throw new Error("cwise: pre() block may not reference array index");if(r<t.body.args.length&&t.body.args[r].lvalue)throw new Error("cwise: body() block may not write to array index");if(r<t.post.args.length&&t.post.args[r].count>0)throw new Error("cwise: post() block may not reference array index")}else if(o==="shape"){if(t.shapeArgs.push(r),r<t.pre.args.length&&t.pre.args[r].lvalue)throw new Error("cwise: pre() block may not write to array shape");if(r<t.body.args.length&&t.body.args[r].lvalue)throw new Error("cwise: body() block may not write to array shape");if(r<t.post.args.length&&t.post.args[r].lvalue)throw new Error("cwise: post() block may not write to array shape")}else if(typeof o=="object"&&o.offset)t.argTypes[r]="offset",t.offsetArgs.push({array:o.array,offset:o.offset}),t.offsetArgIndex.push(r);else throw new Error("cwise: Unknown argument type "+e[r])}if(t.arrayArgs.length<=0)throw new Error("cwise: No array arguments specified");if(t.pre.args.length>e.length)throw new Error("cwise: Too many arguments in pre() block");if(t.body.args.length>e.length)throw new Error("cwise: Too many arguments in body() block");if(t.post.args.length>e.length)throw new Error("cwise: Too many arguments in post() block");return t.debug=!!n.printCode||!!n.debug,t.funcName=n.funcName||"cwise",t.blockSize=n.blockSize||64,bE(t)}YS.exports=SE});var Es=Zt(Ve=>{"use strict";var xr=XS(),Cd={body:"",args:[],thisVars:[],localVars:[]};function Gh(n){if(!n)return Cd;for(var t=0;t<n.args.length;++t){var e=n.args[t];t===0?n.args[t]={name:e,lvalue:!0,rvalue:!!n.rvalue,count:n.count||1}:n.args[t]={name:e,lvalue:!1,rvalue:!0,count:1}}return n.thisVars||(n.thisVars=[]),n.localVars||(n.localVars=[]),n}function wE(n){return xr({args:n.args,pre:Gh(n.pre),body:Gh(n.body),post:Gh(n.proc),funcName:n.funcName})}function ht(n){for(var t=[],e=0;e<n.args.length;++e)t.push("a"+e);var r=new Function("P",["return function ",n.funcName,"_ndarrayops(",t.join(","),") {P(",t.join(","),");return a0}"].join(""));return r(wE(n))}var QS={add:"+",sub:"-",mul:"*",div:"/",mod:"%",band:"&",bor:"|",bxor:"^",lshift:"<<",rshift:">>",rrshift:">>>"};(function(){for(var n in QS){var t=QS[n];Ve[n]=ht({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+t+"c"},funcName:n}),Ve[n+"eq"]=ht({args:["array","array"],body:{args:["a","b"],body:"a"+t+"=b"},rvalue:!0,funcName:n+"eq"}),Ve[n+"s"]=ht({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+t+"s"},funcName:n+"s"}),Ve[n+"seq"]=ht({args:["array","scalar"],body:{args:["a","s"],body:"a"+t+"=s"},rvalue:!0,funcName:n+"seq"})}})();var KS={not:"!",bnot:"~",neg:"-",recip:"1.0/"};(function(){for(var n in KS){var t=KS[n];Ve[n]=ht({args:["array","array"],body:{args:["a","b"],body:"a="+t+"b"},funcName:n}),Ve[n+"eq"]=ht({args:["array"],body:{args:["a"],body:"a="+t+"a"},rvalue:!0,count:2,funcName:n+"eq"})}})();var ZS={and:"&&",or:"||",eq:"===",neq:"!==",lt:"<",gt:">",leq:"<=",geq:">="};(function(){for(var n in ZS){var t=ZS[n];Ve[n]=ht({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+t+"c"},funcName:n}),Ve[n+"s"]=ht({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+t+"s"},funcName:n+"s"}),Ve[n+"eq"]=ht({args:["array","array"],body:{args:["a","b"],body:"a=a"+t+"b"},rvalue:!0,count:2,funcName:n+"eq"}),Ve[n+"seq"]=ht({args:["array","scalar"],body:{args:["a","s"],body:"a=a"+t+"s"},rvalue:!0,count:2,funcName:n+"seq"})}})();var JS=["abs","acos","asin","atan","ceil","cos","exp","floor","log","round","sin","sqrt","tan"];(function(){for(var n=0;n<JS.length;++n){var t=JS[n];Ve[t]=ht({args:["array","array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b)",thisVars:["this_f"]},funcName:t}),Ve[t+"eq"]=ht({args:["array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a"],body:"a=this_f(a)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:t+"eq"})}})();var e1=["max","min","atan2","pow"];(function(){for(var n=0;n<e1.length;++n){var t=e1[n];Ve[t]=ht({args:["array","array","array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(b,c)",thisVars:["this_f"]},funcName:t}),Ve[t+"s"]=ht({args:["array","array","scalar"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(b,c)",thisVars:["this_f"]},funcName:t+"s"}),Ve[t+"eq"]=ht({args:["array","array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(a,b)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:t+"eq"}),Ve[t+"seq"]=ht({args:["array","scalar"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(a,b)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:t+"seq"})}})();var t1=["atan2","pow"];(function(){for(var n=0;n<t1.length;++n){var t=t1[n];Ve[t+"op"]=ht({args:["array","array","array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(c,b)",thisVars:["this_f"]},funcName:t+"op"}),Ve[t+"ops"]=ht({args:["array","array","scalar"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(c,b)",thisVars:["this_f"]},funcName:t+"ops"}),Ve[t+"opeq"]=ht({args:["array","array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b,a)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:t+"opeq"}),Ve[t+"opseq"]=ht({args:["array","scalar"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b,a)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:t+"opseq"})}})();Ve.any=xr({args:["array"],pre:Cd,body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"if(a){return true}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return false"},funcName:"any"});Ve.all=xr({args:["array"],pre:Cd,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1}],body:"if(!x){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"all"});Ve.sum=xr({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"this_s+=a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"sum"});Ve.prod=xr({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=1"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"this_s*=a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"prod"});Ve.norm2squared=xr({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:2}],body:"this_s+=a*a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm2squared"});Ve.norm2=xr({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:2}],body:"this_s+=a*a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return Math.sqrt(this_s)"},funcName:"norm2"});Ve.norminf=xr({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:4}],body:"if(-a>this_s){this_s=-a}else if(a>this_s){this_s=a}",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norminf"});Ve.norm1=xr({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:3}],body:"this_s+=a<0?-a:a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm1"});Ve.sup=xr({args:["array"],pre:{body:"this_h=-Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_>this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}});Ve.inf=xr({args:["array"],pre:{body:"this_h=Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_<this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}});Ve.argmin=xr({args:["index","array","shape"],pre:{body:"{this_v=Infinity;this_i=_inline_0_arg2_.slice(0)}",args:[{name:"_inline_0_arg0_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg1_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg2_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_i","this_v"],localVars:[]},body:{body:"{if(_inline_1_arg1_<this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}});Ve.argmax=xr({args:["index","array","shape"],pre:{body:"{this_v=-Infinity;this_i=_inline_0_arg2_.slice(0)}",args:[{name:"_inline_0_arg0_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg1_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg2_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_i","this_v"],localVars:[]},body:{body:"{if(_inline_1_arg1_>this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}});Ve.random=ht({args:["array"],pre:{args:[],body:"this_f=Math.random",thisVars:["this_f"]},body:{args:["a"],body:"a=this_f()",thisVars:["this_f"]},funcName:"random"});Ve.assign=ht({args:["array","array"],body:{args:["a","b"],body:"a=b"},funcName:"assign"});Ve.assigns=ht({args:["array","scalar"],body:{args:["a","b"],body:"a=b"},funcName:"assigns"});Ve.equals=xr({args:["array","array"],pre:Cd,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1},{name:"y",lvalue:!1,rvalue:!0,count:1}],body:"if(x!==y){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"equals"})});var C1=Zt((ghe,O1)=>{O1.exports=function(t,e){for(var r=t.split("."),o=e.split("."),i=0;i<3;i++){var a=Number(r[i]),s=Number(o[i]);if(a>s)return 1;if(s>a)return-1;if(!isNaN(a)&&isNaN(s))return 1;if(isNaN(a)&&!isNaN(s))return-1}return 0}});import{FileLoader as aB,Loader as sB}from"three";function Yl(n){for(let t of Object.keys(n))n[t]===void 0&&delete n[t];return n}function rr(n,t){return Object.setPrototypeOf(n,t),n}function Xl(n){return Array.isArray(n)?n:[n]}function Ql(n,t){let e=0;for(;e<n.length&&e<t.length;){if(n[e]<t[e])return-1;if(n[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==n.length?1:0}var tw=typeof global=="object"&&global&&global.Object===Object&&global,Kl=tw;var rw=typeof self=="object"&&self&&self.Object===Object&&self,ow=Kl||rw||Function("return this")(),_t=ow;var nw=_t.Symbol,Rt=nw;var rm=Object.prototype,iw=rm.hasOwnProperty,aw=rm.toString,Rs=Rt?Rt.toStringTag:void 0;function sw(n){var t=iw.call(n,Rs),e=n[Rs];try{n[Rs]=void 0;var r=!0}catch{}var o=aw.call(n);return r&&(t?n[Rs]=e:delete n[Rs]),o}var om=sw;var lw=Object.prototype,cw=lw.toString;function uw(n){return cw.call(n)}var nm=uw;var dw="[object Null]",pw="[object Undefined]",im=Rt?Rt.toStringTag:void 0;function fw(n){return n==null?n===void 0?pw:dw:im&&im in Object(n)?om(n):nm(n)}var br=fw;function hw(n){return n!=null&&typeof n=="object"}var qt=hw;var mw="[object Symbol]";function yw(n){return typeof n=="symbol"||qt(n)&&br(n)==mw}var Bi=yw;function gw(n,t){for(var e=-1,r=n==null?0:n.length,o=Array(r);++e<r;)o[e]=t(n[e],e,n);return o}var Zl=gw;var xw=Array.isArray,yt=xw;var bw=1/0,am=Rt?Rt.prototype:void 0,sm=am?am.toString:void 0;function lm(n){if(typeof n=="string")return n;if(yt(n))return Zl(n,lm)+"";if(Bi(n))return sm?sm.call(n):"";var t=n+"";return t=="0"&&1/n==-bw?"-0":t}var cm=lm;function vw(n){var t=typeof n;return n!=null&&(t=="object"||t=="function")}var vr=vw;function Sw(n){return n}var um=Sw;var ww="[object AsyncFunction]",Aw="[object Function]",_w="[object GeneratorFunction]",Pw="[object Proxy]";function Ow(n){if(!vr(n))return!1;var t=br(n);return t==Aw||t==_w||t==ww||t==Pw}var Jl=Ow;var Cw=_t["__core-js_shared__"],ec=Cw;var dm=function(){var n=/[^.]+$/.exec(ec&&ec.keys&&ec.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}();function Tw(n){return!!dm&&dm in n}var pm=Tw;var Mw=Function.prototype,Iw=Mw.toString;function Nw(n){if(n!=null){try{return Iw.call(n)}catch{}try{return n+""}catch{}}return""}var Eo=Nw;var Dw=/[\\^$.*+?()[\]{}|]/g,Ew=/^\[object .+?Constructor\]$/,Bw=Function.prototype,Lw=Object.prototype,Rw=Bw.toString,Vw=Lw.hasOwnProperty,zw=RegExp("^"+Rw.call(Vw).replace(Dw,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Gw(n){if(!vr(n)||pm(n))return!1;var t=Jl(n)?zw:Ew;return t.test(Eo(n))}var fm=Gw;function Fw(n,t){return n?.[t]}var hm=Fw;function kw(n,t){var e=hm(n,t);return fm(e)?e:void 0}var cr=kw;var jw=cr(_t,"WeakMap"),tc=jw;var mm=Object.create,Uw=function(){function n(){}return function(t){if(!vr(t))return{};if(mm)return mm(t);n.prototype=t;var e=new n;return n.prototype=void 0,e}}(),ym=Uw;function Hw(n,t,e){switch(e.length){case 0:return n.call(t);case 1:return n.call(t,e[0]);case 2:return n.call(t,e[0],e[1]);case 3:return n.call(t,e[0],e[1],e[2])}return n.apply(t,e)}var gm=Hw;function qw(n,t){var e=-1,r=n.length;for(t||(t=Array(r));++e<r;)t[e]=n[e];return t}var xm=qw;var Ww=800,$w=16,Yw=Date.now;function Xw(n){var t=0,e=0;return function(){var r=Yw(),o=$w-(r-e);if(e=r,o>0){if(++t>=Ww)return arguments[0]}else t=0;return n.apply(void 0,arguments)}}var bm=Xw;function Qw(n){return function(){return n}}var vm=Qw;var Kw=function(){try{var n=cr(Object,"defineProperty");return n({},"",{}),n}catch{}}(),Li=Kw;var Zw=Li?function(n,t){return Li(n,"toString",{configurable:!0,enumerable:!1,value:vm(t),writable:!0})}:um,Sm=Zw;var Jw=bm(Sm),wm=Jw;function e2(n,t){for(var e=-1,r=n==null?0:n.length;++e<r&&t(n[e],e,n)!==!1;);return n}var Am=e2;var t2=9007199254740991,r2=/^(?:0|[1-9]\d*)$/;function o2(n,t){var e=typeof n;return t=t??t2,!!t&&(e=="number"||e!="symbol"&&r2.test(n))&&n>-1&&n%1==0&&n<t}var Ri=o2;function n2(n,t,e){t=="__proto__"&&Li?Li(n,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):n[t]=e}var rc=n2;function i2(n,t){return n===t||n!==n&&t!==t}var Vi=i2;var a2=Object.prototype,s2=a2.hasOwnProperty;function l2(n,t,e){var r=n[t];(!(s2.call(n,t)&&Vi(r,e))||e===void 0&&!(t in n))&&rc(n,t,e)}var zi=l2;function c2(n,t,e,r){var o=!e;e||(e={});for(var i=-1,a=t.length;++i<a;){var s=t[i],l=r?r(e[s],n[s],s,e,n):void 0;l===void 0&&(l=n[s]),o?rc(e,s,l):zi(e,s,l)}return e}var io=c2;var _m=Math.max;function u2(n,t,e){return t=_m(t===void 0?n.length-1:t,0),function(){for(var r=arguments,o=-1,i=_m(r.length-t,0),a=Array(i);++o<i;)a[o]=r[t+o];o=-1;for(var s=Array(t+1);++o<t;)s[o]=r[o];return s[t]=e(a),gm(n,this,s)}}var Pm=u2;var d2=9007199254740991;function p2(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=d2}var Gi=p2;function f2(n){return n!=null&&Gi(n.length)&&!Jl(n)}var oc=f2;var h2=Object.prototype;function m2(n){var t=n&&n.constructor,e=typeof t=="function"&&t.prototype||h2;return n===e}var Fi=m2;function y2(n,t){for(var e=-1,r=Array(n);++e<n;)r[e]=t(e);return r}var Om=y2;var g2="[object Arguments]";function x2(n){return qt(n)&&br(n)==g2}var Ud=x2;var Cm=Object.prototype,b2=Cm.hasOwnProperty,v2=Cm.propertyIsEnumerable,S2=Ud(function(){return arguments}())?Ud:function(n){return qt(n)&&b2.call(n,"callee")&&!v2.call(n,"callee")},ki=S2;function w2(){return!1}var Tm=w2;var Nm=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Mm=Nm&&typeof module=="object"&&module&&!module.nodeType&&module,A2=Mm&&Mm.exports===Nm,Im=A2?_t.Buffer:void 0,_2=Im?Im.isBuffer:void 0,P2=_2||Tm,Qn=P2;var O2="[object Arguments]",C2="[object Array]",T2="[object Boolean]",M2="[object Date]",I2="[object Error]",N2="[object Function]",D2="[object Map]",E2="[object Number]",B2="[object Object]",L2="[object RegExp]",R2="[object Set]",V2="[object String]",z2="[object WeakMap]",G2="[object ArrayBuffer]",F2="[object DataView]",k2="[object Float32Array]",j2="[object Float64Array]",U2="[object Int8Array]",H2="[object Int16Array]",q2="[object Int32Array]",W2="[object Uint8Array]",$2="[object Uint8ClampedArray]",Y2="[object Uint16Array]",X2="[object Uint32Array]",it={};it[k2]=it[j2]=it[U2]=it[H2]=it[q2]=it[W2]=it[$2]=it[Y2]=it[X2]=!0;it[O2]=it[C2]=it[G2]=it[T2]=it[F2]=it[M2]=it[I2]=it[N2]=it[D2]=it[E2]=it[B2]=it[L2]=it[R2]=it[V2]=it[z2]=!1;function Q2(n){return qt(n)&&Gi(n.length)&&!!it[br(n)]}var Dm=Q2;function K2(n){return function(t){return n(t)}}var ji=K2;var Em=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Vs=Em&&typeof module=="object"&&module&&!module.nodeType&&module,Z2=Vs&&Vs.exports===Em,Hd=Z2&&Kl.process,J2=function(){try{var n=Vs&&Vs.require&&Vs.require("util").types;return n||Hd&&Hd.binding&&Hd.binding("util")}catch{}}(),Bo=J2;var Bm=Bo&&Bo.isTypedArray,eA=Bm?ji(Bm):Dm,nc=eA;var tA=Object.prototype,rA=tA.hasOwnProperty;function oA(n,t){var e=yt(n),r=!e&&ki(n),o=!e&&!r&&Qn(n),i=!e&&!r&&!o&&nc(n),a=e||r||o||i,s=a?Om(n.length,String):[],l=s.length;for(var u in n)(t||rA.call(n,u))&&!(a&&(u=="length"||o&&(u=="offset"||u=="parent")||i&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||Ri(u,l)))&&s.push(u);return s}var ic=oA;function nA(n,t){return function(e){return n(t(e))}}var ac=nA;var iA=ac(Object.keys,Object),Lm=iA;var aA=Object.prototype,sA=aA.hasOwnProperty;function lA(n){if(!Fi(n))return Lm(n);var t=[];for(var e in Object(n))sA.call(n,e)&&e!="constructor"&&t.push(e);return t}var Rm=lA;function cA(n){return oc(n)?ic(n):Rm(n)}var Ui=cA;function uA(n){var t=[];if(n!=null)for(var e in Object(n))t.push(e);return t}var Vm=uA;var dA=Object.prototype,pA=dA.hasOwnProperty;function fA(n){if(!vr(n))return Vm(n);var t=Fi(n),e=[];for(var r in n)r=="constructor"&&(t||!pA.call(n,r))||e.push(r);return e}var zm=fA;function hA(n){return oc(n)?ic(n,!0):zm(n)}var Hi=hA;var mA=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,yA=/^\w*$/;function gA(n,t){if(yt(n))return!1;var e=typeof n;return e=="number"||e=="symbol"||e=="boolean"||n==null||Bi(n)?!0:yA.test(n)||!mA.test(n)||t!=null&&n in Object(t)}var Gm=gA;var xA=cr(Object,"create"),Lo=xA;function bA(){this.__data__=Lo?Lo(null):{},this.size=0}var Fm=bA;function vA(n){var t=this.has(n)&&delete this.__data__[n];return this.size-=t?1:0,t}var km=vA;var SA="__lodash_hash_undefined__",wA=Object.prototype,AA=wA.hasOwnProperty;function _A(n){var t=this.__data__;if(Lo){var e=t[n];return e===SA?void 0:e}return AA.call(t,n)?t[n]:void 0}var jm=_A;var PA=Object.prototype,OA=PA.hasOwnProperty;function CA(n){var t=this.__data__;return Lo?t[n]!==void 0:OA.call(t,n)}var Um=CA;var TA="__lodash_hash_undefined__";function MA(n,t){var e=this.__data__;return this.size+=this.has(n)?0:1,e[n]=Lo&&t===void 0?TA:t,this}var Hm=MA;function qi(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}qi.prototype.clear=Fm;qi.prototype.delete=km;qi.prototype.get=jm;qi.prototype.has=Um;qi.prototype.set=Hm;var qd=qi;function IA(){this.__data__=[],this.size=0}var qm=IA;function NA(n,t){for(var e=n.length;e--;)if(Vi(n[e][0],t))return e;return-1}var ln=NA;var DA=Array.prototype,EA=DA.splice;function BA(n){var t=this.__data__,e=ln(t,n);if(e<0)return!1;var r=t.length-1;return e==r?t.pop():EA.call(t,e,1),--this.size,!0}var Wm=BA;function LA(n){var t=this.__data__,e=ln(t,n);return e<0?void 0:t[e][1]}var $m=LA;function RA(n){return ln(this.__data__,n)>-1}var Ym=RA;function VA(n,t){var e=this.__data__,r=ln(e,n);return r<0?(++this.size,e.push([n,t])):e[r][1]=t,this}var Xm=VA;function Wi(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}Wi.prototype.clear=qm;Wi.prototype.delete=Wm;Wi.prototype.get=$m;Wi.prototype.has=Ym;Wi.prototype.set=Xm;var cn=Wi;var zA=cr(_t,"Map"),un=zA;function GA(){this.size=0,this.__data__={hash:new qd,map:new(un||cn),string:new qd}}var Qm=GA;function FA(n){var t=typeof n;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?n!=="__proto__":n===null}var Km=FA;function kA(n,t){var e=n.__data__;return Km(t)?e[typeof t=="string"?"string":"hash"]:e.map}var dn=kA;function jA(n){var t=dn(this,n).delete(n);return this.size-=t?1:0,t}var Zm=jA;function UA(n){return dn(this,n).get(n)}var Jm=UA;function HA(n){return dn(this,n).has(n)}var ey=HA;function qA(n,t){var e=dn(this,n),r=e.size;return e.set(n,t),this.size+=e.size==r?0:1,this}var ty=qA;function $i(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}$i.prototype.clear=Qm;$i.prototype.delete=Zm;$i.prototype.get=Jm;$i.prototype.has=ey;$i.prototype.set=ty;var Kn=$i;var WA="Expected a function";function Wd(n,t){if(typeof n!="function"||t!=null&&typeof t!="function")throw new TypeError(WA);var e=function(){var r=arguments,o=t?t.apply(this,r):r[0],i=e.cache;if(i.has(o))return i.get(o);var a=n.apply(this,r);return e.cache=i.set(o,a)||i,a};return e.cache=new(Wd.Cache||Kn),e}Wd.Cache=Kn;var ry=Wd;var $A=500;function YA(n){var t=ry(n,function(r){return e.size===$A&&e.clear(),r}),e=t.cache;return t}var oy=YA;var XA=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,QA=/\\(\\)?/g,KA=oy(function(n){var t=[];return n.charCodeAt(0)===46&&t.push(""),n.replace(XA,function(e,r,o,i){t.push(o?i.replace(QA,"$1"):r||e)}),t}),ny=KA;function ZA(n){return n==null?"":cm(n)}var iy=ZA;function JA(n,t){return yt(n)?n:Gm(n,t)?[n]:ny(iy(n))}var Tr=JA;var e_=1/0;function t_(n){if(typeof n=="string"||Bi(n))return n;var t=n+"";return t=="0"&&1/n==-e_?"-0":t}var pn=t_;function r_(n,t){t=Tr(t,n);for(var e=0,r=t.length;n!=null&&e<r;)n=n[pn(t[e++])];return e&&e==r?n:void 0}var sc=r_;function o_(n,t){for(var e=-1,r=t.length,o=n.length;++e<r;)n[o+e]=t[e];return n}var Yi=o_;var ay=Rt?Rt.isConcatSpreadable:void 0;function n_(n){return yt(n)||ki(n)||!!(ay&&n&&n[ay])}var sy=n_;function ly(n,t,e,r,o){var i=-1,a=n.length;for(e||(e=sy),o||(o=[]);++i<a;){var s=n[i];t>0&&e(s)?t>1?ly(s,t-1,e,r,o):Yi(o,s):r||(o[o.length]=s)}return o}var cy=ly;function i_(n){var t=n==null?0:n.length;return t?cy(n,1):[]}var uy=i_;function a_(n){return wm(Pm(n,void 0,uy),n+"")}var lc=a_;var s_=ac(Object.getPrototypeOf,Object),Xi=s_;var l_="[object Object]",c_=Function.prototype,u_=Object.prototype,dy=c_.toString,d_=u_.hasOwnProperty,p_=dy.call(Object);function f_(n){if(!qt(n)||br(n)!=l_)return!1;var t=Xi(n);if(t===null)return!0;var e=d_.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&&dy.call(e)==p_}var py=f_;function h_(n,t,e){var r=-1,o=n.length;t<0&&(t=-t>o?0:o+t),e=e>o?o:e,e<0&&(e+=o),o=t>e?0:e-t>>>0,t>>>=0;for(var i=Array(o);++r<o;)i[r]=n[r+t];return i}var fy=h_;function m_(){this.__data__=new cn,this.size=0}var hy=m_;function y_(n){var t=this.__data__,e=t.delete(n);return this.size=t.size,e}var my=y_;function g_(n){return this.__data__.get(n)}var yy=g_;function x_(n){return this.__data__.has(n)}var gy=x_;var b_=200;function v_(n,t){var e=this.__data__;if(e instanceof cn){var r=e.__data__;if(!un||r.length<b_-1)return r.push([n,t]),this.size=++e.size,this;e=this.__data__=new Kn(r)}return e.set(n,t),this.size=e.size,this}var xy=v_;function Qi(n){var t=this.__data__=new cn(n);this.size=t.size}Qi.prototype.clear=hy;Qi.prototype.delete=my;Qi.prototype.get=yy;Qi.prototype.has=gy;Qi.prototype.set=xy;var Ki=Qi;function S_(n,t){return n&&io(t,Ui(t),n)}var by=S_;function w_(n,t){return n&&io(t,Hi(t),n)}var vy=w_;var _y=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Sy=_y&&typeof module=="object"&&module&&!module.nodeType&&module,A_=Sy&&Sy.exports===_y,wy=A_?_t.Buffer:void 0,Ay=wy?wy.allocUnsafe:void 0;function __(n,t){if(t)return n.slice();var e=n.length,r=Ay?Ay(e):new n.constructor(e);return n.copy(r),r}var Py=__;function P_(n,t){for(var e=-1,r=n==null?0:n.length,o=0,i=[];++e<r;){var a=n[e];t(a,e,n)&&(i[o++]=a)}return i}var Oy=P_;function O_(){return[]}var cc=O_;var C_=Object.prototype,T_=C_.propertyIsEnumerable,Cy=Object.getOwnPropertySymbols,M_=Cy?function(n){return n==null?[]:(n=Object(n),Oy(Cy(n),function(t){return T_.call(n,t)}))}:cc,Zi=M_;function I_(n,t){return io(n,Zi(n),t)}var Ty=I_;var N_=Object.getOwnPropertySymbols,D_=N_?function(n){for(var t=[];n;)Yi(t,Zi(n)),n=Xi(n);return t}:cc,uc=D_;function E_(n,t){return io(n,uc(n),t)}var My=E_;function B_(n,t,e){var r=t(n);return yt(n)?r:Yi(r,e(n))}var dc=B_;function L_(n){return dc(n,Ui,Zi)}var zs=L_;function R_(n){return dc(n,Hi,uc)}var pc=R_;var V_=cr(_t,"DataView"),fc=V_;var z_=cr(_t,"Promise"),hc=z_;var G_=cr(_t,"Set"),mc=G_;var Iy="[object Map]",F_="[object Object]",Ny="[object Promise]",Dy="[object Set]",Ey="[object WeakMap]",By="[object DataView]",k_=Eo(fc),j_=Eo(un),U_=Eo(hc),H_=Eo(mc),q_=Eo(tc),Zn=br;(fc&&Zn(new fc(new ArrayBuffer(1)))!=By||un&&Zn(new un)!=Iy||hc&&Zn(hc.resolve())!=Ny||mc&&Zn(new mc)!=Dy||tc&&Zn(new tc)!=Ey)&&(Zn=function(n){var t=br(n),e=t==F_?n.constructor:void 0,r=e?Eo(e):"";if(r)switch(r){case k_:return By;case j_:return Iy;case U_:return Ny;case H_:return Dy;case q_:return Ey}return t});var Ro=Zn;var W_=Object.prototype,$_=W_.hasOwnProperty;function Y_(n){var t=n.length,e=new n.constructor(t);return t&&typeof n[0]=="string"&&$_.call(n,"index")&&(e.index=n.index,e.input=n.input),e}var Ly=Y_;var X_=_t.Uint8Array,Ji=X_;function Q_(n){var t=new n.constructor(n.byteLength);return new Ji(t).set(new Ji(n)),t}var ea=Q_;function K_(n,t){var e=t?ea(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.byteLength)}var Ry=K_;var Z_=/\w*$/;function J_(n){var t=new n.constructor(n.source,Z_.exec(n));return t.lastIndex=n.lastIndex,t}var Vy=J_;var zy=Rt?Rt.prototype:void 0,Gy=zy?zy.valueOf:void 0;function eP(n){return Gy?Object(Gy.call(n)):{}}var Fy=eP;function tP(n,t){var e=t?ea(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.length)}var ky=tP;var rP="[object Boolean]",oP="[object Date]",nP="[object Map]",iP="[object Number]",aP="[object RegExp]",sP="[object Set]",lP="[object String]",cP="[object Symbol]",uP="[object ArrayBuffer]",dP="[object DataView]",pP="[object Float32Array]",fP="[object Float64Array]",hP="[object Int8Array]",mP="[object Int16Array]",yP="[object Int32Array]",gP="[object Uint8Array]",xP="[object Uint8ClampedArray]",bP="[object Uint16Array]",vP="[object Uint32Array]";function SP(n,t,e){var r=n.constructor;switch(t){case uP:return ea(n);case rP:case oP:return new r(+n);case dP:return Ry(n,e);case pP:case fP:case hP:case mP:case yP:case gP:case xP:case bP:case vP:return ky(n,e);case nP:return new r;case iP:case lP:return new r(n);case aP:return Vy(n);case sP:return new r;case cP:return Fy(n)}}var jy=SP;function wP(n){return typeof n.constructor=="function"&&!Fi(n)?ym(Xi(n)):{}}var Uy=wP;var AP="[object Map]";function _P(n){return qt(n)&&Ro(n)==AP}var Hy=_P;var qy=Bo&&Bo.isMap,PP=qy?ji(qy):Hy,Wy=PP;var OP="[object Set]";function CP(n){return qt(n)&&Ro(n)==OP}var $y=CP;var Yy=Bo&&Bo.isSet,TP=Yy?ji(Yy):$y,Xy=TP;var MP=1,IP=2,NP=4,Qy="[object Arguments]",DP="[object Array]",EP="[object Boolean]",BP="[object Date]",LP="[object Error]",Ky="[object Function]",RP="[object GeneratorFunction]",VP="[object Map]",zP="[object Number]",Zy="[object Object]",GP="[object RegExp]",FP="[object Set]",kP="[object String]",jP="[object Symbol]",UP="[object WeakMap]",HP="[object ArrayBuffer]",qP="[object DataView]",WP="[object Float32Array]",$P="[object Float64Array]",YP="[object Int8Array]",XP="[object Int16Array]",QP="[object Int32Array]",KP="[object Uint8Array]",ZP="[object Uint8ClampedArray]",JP="[object Uint16Array]",eO="[object Uint32Array]",ot={};ot[Qy]=ot[DP]=ot[HP]=ot[qP]=ot[EP]=ot[BP]=ot[WP]=ot[$P]=ot[YP]=ot[XP]=ot[QP]=ot[VP]=ot[zP]=ot[Zy]=ot[GP]=ot[FP]=ot[kP]=ot[jP]=ot[KP]=ot[ZP]=ot[JP]=ot[eO]=!0;ot[LP]=ot[Ky]=ot[UP]=!1;function yc(n,t,e,r,o,i){var a,s=t&MP,l=t&IP,u=t&NP;if(e&&(a=o?e(n,r,o,i):e(n)),a!==void 0)return a;if(!vr(n))return n;var c=yt(n);if(c){if(a=Ly(n),!s)return xm(n,a)}else{var d=Ro(n),p=d==Ky||d==RP;if(Qn(n))return Py(n,s);if(d==Zy||d==Qy||p&&!o){if(a=l||p?{}:Uy(n),!s)return l?My(n,vy(a,n)):Ty(n,by(a,n))}else{if(!ot[d])return o?n:{};a=jy(n,d,s)}}i||(i=new Ki);var f=i.get(n);if(f)return f;i.set(n,a),Xy(n)?n.forEach(function(y){a.add(yc(y,t,e,y,n,i))}):Wy(n)&&n.forEach(function(y,g){a.set(g,yc(y,t,e,g,n,i))});var h=u?l?pc:zs:l?Hi:Ui,m=c?void 0:h(n);return Am(m||n,function(y,g){m&&(g=y,y=n[g]),zi(a,g,yc(y,t,e,g,n,i))}),a}var gc=yc;var tO=1,rO=4;function oO(n){return gc(n,tO|rO)}var Vo=oO;var nO="__lodash_hash_undefined__";function iO(n){return this.__data__.set(n,nO),this}var Jy=iO;function aO(n){return this.__data__.has(n)}var eg=aO;function xc(n){var t=-1,e=n==null?0:n.length;for(this.__data__=new Kn;++t<e;)this.add(n[t])}xc.prototype.add=xc.prototype.push=Jy;xc.prototype.has=eg;var tg=xc;function sO(n,t){for(var e=-1,r=n==null?0:n.length;++e<r;)if(t(n[e],e,n))return!0;return!1}var rg=sO;function lO(n,t){return n.has(t)}var og=lO;var cO=1,uO=2;function dO(n,t,e,r,o,i){var a=e&cO,s=n.length,l=t.length;if(s!=l&&!(a&&l>s))return!1;var u=i.get(n),c=i.get(t);if(u&&c)return u==t&&c==n;var d=-1,p=!0,f=e&uO?new tg:void 0;for(i.set(n,t),i.set(t,n);++d<s;){var h=n[d],m=t[d];if(r)var y=a?r(m,h,d,t,n,i):r(h,m,d,n,t,i);if(y!==void 0){if(y)continue;p=!1;break}if(f){if(!rg(t,function(g,b){if(!og(f,b)&&(h===g||o(h,g,e,r,i)))return f.push(b)})){p=!1;break}}else if(!(h===m||o(h,m,e,r,i))){p=!1;break}}return i.delete(n),i.delete(t),p}var bc=dO;function pO(n){var t=-1,e=Array(n.size);return n.forEach(function(r,o){e[++t]=[o,r]}),e}var ng=pO;function fO(n){var t=-1,e=Array(n.size);return n.forEach(function(r){e[++t]=r}),e}var ig=fO;var hO=1,mO=2,yO="[object Boolean]",gO="[object Date]",xO="[object Error]",bO="[object Map]",vO="[object Number]",SO="[object RegExp]",wO="[object Set]",AO="[object String]",_O="[object Symbol]",PO="[object ArrayBuffer]",OO="[object DataView]",ag=Rt?Rt.prototype:void 0,$d=ag?ag.valueOf:void 0;function CO(n,t,e,r,o,i,a){switch(e){case OO:if(n.byteLength!=t.byteLength||n.byteOffset!=t.byteOffset)return!1;n=n.buffer,t=t.buffer;case PO:return!(n.byteLength!=t.byteLength||!i(new Ji(n),new Ji(t)));case yO:case gO:case vO:return Vi(+n,+t);case xO:return n.name==t.name&&n.message==t.message;case SO:case AO:return n==t+"";case bO:var s=ng;case wO:var l=r&hO;if(s||(s=ig),n.size!=t.size&&!l)return!1;var u=a.get(n);if(u)return u==t;r|=mO,a.set(n,t);var c=bc(s(n),s(t),r,o,i,a);return a.delete(n),c;case _O:if($d)return $d.call(n)==$d.call(t)}return!1}var sg=CO;var TO=1,MO=Object.prototype,IO=MO.hasOwnProperty;function NO(n,t,e,r,o,i){var a=e&TO,s=zs(n),l=s.length,u=zs(t),c=u.length;if(l!=c&&!a)return!1;for(var d=l;d--;){var p=s[d];if(!(a?p in t:IO.call(t,p)))return!1}var f=i.get(n),h=i.get(t);if(f&&h)return f==t&&h==n;var m=!0;i.set(n,t),i.set(t,n);for(var y=a;++d<l;){p=s[d];var g=n[p],b=t[p];if(r)var w=a?r(b,g,p,t,n,i):r(g,b,p,n,t,i);if(!(w===void 0?g===b||o(g,b,e,r,i):w)){m=!1;break}y||(y=p=="constructor")}if(m&&!y){var A=n.constructor,S=t.constructor;A!=S&&"constructor"in n&&"constructor"in t&&!(typeof A=="function"&&A instanceof A&&typeof S=="function"&&S instanceof S)&&(m=!1)}return i.delete(n),i.delete(t),m}var lg=NO;var DO=1,cg="[object Arguments]",ug="[object Array]",vc="[object Object]",EO=Object.prototype,dg=EO.hasOwnProperty;function BO(n,t,e,r,o,i){var a=yt(n),s=yt(t),l=a?ug:Ro(n),u=s?ug:Ro(t);l=l==cg?vc:l,u=u==cg?vc:u;var c=l==vc,d=u==vc,p=l==u;if(p&&Qn(n)){if(!Qn(t))return!1;a=!0,c=!1}if(p&&!c)return i||(i=new Ki),a||nc(n)?bc(n,t,e,r,o,i):sg(n,t,l,e,r,o,i);if(!(e&DO)){var f=c&&dg.call(n,"__wrapped__"),h=d&&dg.call(t,"__wrapped__");if(f||h){var m=f?n.value():n,y=h?t.value():t;return i||(i=new Ki),o(m,y,e,r,i)}}return p?(i||(i=new Ki),lg(n,t,e,r,o,i)):!1}var pg=BO;function fg(n,t,e,r,o){return n===t?!0:n==null||t==null||!qt(n)&&!qt(t)?n!==n&&t!==t:pg(n,t,e,r,fg,o)}var hg=fg;function LO(n,t){return n!=null&&t in Object(n)}var mg=LO;function RO(n,t,e){t=Tr(t,n);for(var r=-1,o=t.length,i=!1;++r<o;){var a=pn(t[r]);if(!(i=n!=null&&e(n,a)))break;n=n[a]}return i||++r!=o?i:(o=n==null?0:n.length,!!o&&Gi(o)&&Ri(a,o)&&(yt(n)||ki(n)))}var yg=RO;function VO(n,t){return n!=null&&yg(n,t,mg)}var gg=VO;function zO(n){var t=n==null?0:n.length;return t?n[t-1]:void 0}var xg=zO;function GO(n,t){return t.length<2?n:sc(n,fy(t,0,-1))}var bg=GO;function FO(n,t){return hg(n,t)}var Yd=FO;function kO(n,t){return t=Tr(t,n),n=bg(n,t),n==null||delete n[pn(xg(t))]}var vg=kO;function jO(n){return py(n)?void 0:n}var Sg=jO;var UO=1,HO=2,qO=4,WO=lc(function(n,t){var e={};if(n==null)return e;var r=!1;t=Zl(t,function(i){return i=Tr(i,n),r||(r=i.length>1),i}),io(n,pc(n),e),r&&(e=gc(e,UO|HO|qO,Sg));for(var o=t.length;o--;)vg(e,t[o]);return e}),ta=WO;function $O(n,t,e,r){if(!vr(n))return n;t=Tr(t,n);for(var o=-1,i=t.length,a=i-1,s=n;s!=null&&++o<i;){var l=pn(t[o]),u=e;if(l==="__proto__"||l==="constructor"||l==="prototype")return n;if(o!=a){var c=s[l];u=r?r(c,l,s):void 0,u===void 0&&(u=vr(c)?c:Ri(t[o+1])?[]:{})}zi(s,l,u),s=s[l]}return n}var wg=$O;function YO(n,t,e){for(var r=-1,o=t.length,i={};++r<o;){var a=t[r],s=sc(n,a);e(s,a)&&wg(i,Tr(a,n),s)}return i}var Ag=YO;function XO(n,t){return Ag(n,t,function(e,r){return gg(n,r)})}var _g=XO;var QO=lc(function(n,t){return n==null?{}:_g(n,t)}),jr=QO;var xe=class{modifyById(t,e){let r=this;if(r[t]===void 0)throw new Error("not expected");{let i={...r,[t]:e};return Object.setPrototypeOf(i,xe.prototype),i}}add(t,e){return this.runOp({type:1,id:t,data:e})?.data??this}runOp(t){let e=this;if(t.type===1){let r=e[t.id],o;r===void 0?o={type:2,id:t.id}:o={type:1,id:t.id,data:r};let{id:i,data:a}=t,s={...e,[i]:a};return Object.setPrototypeOf(s,xe.prototype),{data:s,actual:t,reverse:o}}else if(t.type===2){let{id:r}=t,o=e[r];if(o===void 0)return null;{let i={...e};return Object.setPrototypeOf(i,xe.prototype),delete i[r],{data:i,actual:t,reverse:{type:1,id:r,data:o}}}}return null}};function Gs(n){if(n.deepFreeze!==void 0){n.deepFreeze(n);return}let t=Object.getOwnPropertyNames(n);for(let e of t){let r=n[e];r&&typeof r=="object"&&Gs(r)}return Object.freeze(n)}function Pg(n,t){let e=0;for(;e<n.length&&e<t.length;){if(n[e]<t[e])return-1;if(n[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==n.length?1:0}var ra=class extends Error{};function Sc(n){let t={...n};return Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t}function ao(n,t,e){if(n===void 0?t===void 0?(n=0,t=10):n=t-10:t===void 0&&(t=n+10),n>t){let i=n;n=t,t=i}let r=[],o=1/(e+1);for(let i=0;i<e;i++){let a=n+(t-n)*(i+.75+Math.random()*.5)*o;r.push(a)}return r}function oa(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 Og(){return typeof process<"u"}function Cg(n,t){for(let e of n)t(e.id,e.data)!==!0&&Cg(e.children,t)}function Tg(n,t){if(t(n.id,n.data)!==!0)for(let e of n.children)Tg(e,t)}var Je=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,Je.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Gs(this[e]),e++}fillCaches0(e,r){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,r);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,r){if(!this.has(e))return!0;for(;e;){let o=this.parent(e);if(o===r)return!0;e=o}return!1}rootAcestor(e){for(;e;){let r=this.parent(e);if(r)e=r;else return e}return e}isDescendantOf(e,r){for(;e;){let o=this.parent(e);if(o===r)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,r){if(e===null)this.traverse(r);else{let o=this.get(e);o&&Tg(o,r)}}traverse(e){Cg(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,r){if(this.get(e)===void 0)throw new Error("not expected");{let i=this.parent(e),a=this.childrenArray(i),s=a.findIndex(c=>c.id===e);if(s<0)throw new Error("not expected");let l=a[s];return a=[...a],a[s]={...l,data:r},this.modifyArrayBy(i,a)}}modifyArrayBy(e,r){let o=e,i=r;for(;o!==null;){let s=i,l=o;if(o=this.parent(o),o===void 0)throw new Error;i=this.childrenArray(o);let u=i.findIndex(c=>c.id===l);if(u<0)throw new Error;i=[...i],i[u]={...i[u],children:s}}Object.setPrototypeOf(i,Je.prototype);let a=i;return a.fillCaches(),a}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:r}){if(this.get(e)!==void 0)return!0;for(let o of r)if(this.checkDuplicatedIdRec(o))return!0;return!1}addOp(e){let{parent:r,fi:o,id:i,data:a,children:s}=e;if(r!==null&&this.get(r)===void 0)return null;if(this.checkDuplicatedIdRec(e))return null;{let l=r,u=this.childrenArray(l),c={fi:o,id:i,data:a,children:s};return u=[...u,c],u.sort((p,f)=>p.fi-f.fi),e.localIndex=u.indexOf(c),{data:this.modifyArrayBy(l,u),actual:e,reverse:{type:8,id:i}}}}deleteOp(e){let{id:r}=e;if(this.get(r)===null)return null;{let o=this.parent(r);if(o===void 0)return null;let i=this.childrenArray(o),a=i.findIndex(u=>u.id===r);e.localIndex=a,i=[...i];let s=i.splice(a,1)[0];return{data:this.modifyArrayBy(o,i),actual:e,reverse:{type:7,...s,parent:o}}}}moveOp(e){let{parent:r,fi:o,id:i}=e;if(r!==null&&this.get(r)===void 0)return this.deleteOp({type:8,id:i});if(r!==null){let f=r;for(;f!==null;){if(f===void 0)throw new Error;if(f===i)throw new ra("cyclic tree");f=this.parent(f)}}let a=this.parent(i);if(a===void 0)return null;let s=a,l=this.childrenArray(a),u=l.findIndex(f=>f.id===i);l=[...l];let c=l.splice(u,1)[0],d=this.modifyArrayBy(a,l);a=r,l=d.childrenArray(a);let p=c.fi;return c={...c,fi:o},l=[...l,c],l.sort((f,h)=>f.fi-h.fi),e.localIndex=l.indexOf(c),d=d.modifyArrayBy(a,l),{data:d,actual:e,reverse:{type:9,parent:s,fi:p,id:i}}}previous(e,r){if(r===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===r)return o;o=i.id}return null}traverseSortNext(e){let r=this.parent(e);if(r!==void 0){let o=this.childrenArray(r),i=o.findIndex(a=>a.id===e)+1;if(i<o.length)return o[i].id;if(r)return this.traverseSortNext(r)}}sortNext(e){let r=this.childrenArray(e);return r.length>0?r[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let r=this.childrenArray(e);return r.length>0?this.traverseSortPrevious(r[r.length-1].id):e}sortPrevious(e){let r=this.parent(e);if(r!==void 0){let o=this.childrenArray(r),i=o.findIndex(a=>a.id===e)-1;return i>=0?this.traverseSortPrevious(o[i].id):r}}getAllSorted(e){let r=[];for(let o of e){let i=this.getWithSortKey(o.id);i!==void 0&&r.push({...o,...i})}r.sort((o,i)=>Pg(o.sortKey,i.sortKey));for(let o of r)delete o.sortKey;return r}getWithSortKey(e){var r=e;let o=[],i=this.get(r),a=i;if(i!==void 0){for(;r;)o.splice(0,0,i.fi),r=this.parent(r),r!==null&&(i=this.get(r));return{...a,sortKey:o}}}insertBeforeHelper(e,r,o){return this.insertAfterHelper(e,this.previous(e,r),o)}insertAfterHelper(e,r,o){let i=this.childrenArray(e);if(r===null){if(i.length===0)return ao(0,o,o);{let a=i[0].fi;return ao(a-o,a,o)}}else{let a=this.get(r);if(a===void 0||this.parent(r)!==e)throw new Error("illegal args");let s=i.find(l=>l.fi>a.fi);if(s===void 0){let l=i[i.length-1].fi;return ao(l,l+o,o)}else return ao(a.fi,s.fi,o)}}};var na;(t=>{function n(e,r){if(r.type!==0)return null;if(Array.isArray(e)){let o=r.props,i={},a=[...e],s=!1;if(o)for(let l of Object.keys(o)){let u=parseInt(l);if(isNaN(u))throw new Error("wrong index");i[l]=a[u],a[u]=o[l],s=!0}return s?{data:a,actual:r,reverse:{type:0,props:i}}:null}else{let o=r.props,i={},a={...e},s=!1;if(o)for(let l of Object.keys(o)){i[l]=a[l];let u=o[l];u===void 0?delete a[l]:a[l]=u,s=!0}return s?{data:a,actual:r,reverse:{type:0,props:i}}:null}}t.runOp=n})(na||(na={}));var Se=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,Se.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Gs(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,r){if(this.get(e)===void 0)throw new Error("not expected");{let i=this,a=i.findIndex(u=>u.id===e);if(a<0)throw new Error("not expected");let s=i[a];return i=[...i],i[a]={...s,data:r},this.modifyArrayBy(i)}}modifyArrayBy(e){Object.setPrototypeOf(e,Se.prototype);let r=e;return Og()||r.fillCaches(),r}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:r,id:o,data:i}=e,a=this,s={fi:r,id:o,data:i};return a=[...a,s],a.sort((u,c)=>u.fi-c.fi),e.localIndex=a.indexOf(s),{data:this.modifyArrayBy(a),actual:e,reverse:{type:5,id:o}}}deleteOp(e){let{id:r}=e,o=this,i=o.findIndex(l=>l.id===r);if(i===-1)return null;e.localIndex=i,o=[...o];let a=o.splice(i,1)[0];return{data:this.modifyArrayBy(o),actual:e,reverse:{type:4,...a}}}moveOp(e){let{fi:r,id:o}=e,i=this;i=[...i];let a=i.findIndex(c=>c.id===o);if(a===-1)return null;let s=i[a].fi,l={...i[a],fi:r};return i[a]=l,i.sort((c,d)=>c.fi-d.fi),e.localIndex=i.indexOf(l),{data:this.modifyArrayBy(i),actual:e,reverse:{type:6,fi:s,id:o}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let r=null;for(let o of this){if(o.id===e)return r;r=o.id}return null}insertBeforeHelper(e,r){return this.insertAfterHelper(this.previous(e),r)}insertAfterHelper(e,r){let o=this;if(e===null){if(o.length===0)return ao(0,r,r);{let i=o[0].fi;return ao(i-r,i,r)}}else{let i=this.get(e);if(i===void 0)throw new Error("illegal args");let a=o.find(s=>s.fi>i.fi);if(a===void 0){let s=o[o.length-1].fi;return ao(s,s+r,r)}else return ao(i.fi,a.fi,r)}}};function ia(n){return n&&typeof n=="object"&&n instanceof et}var et=class{unusedFunOverridesTable(t){}runOp(t){let e=[],r=this,o=0,i={};for(;o<t.path.length;){if(e.push(r),r=r===void 0?void 0:r[t.path[o]],r!==void 0&&!ia(r))return null;o+=1}r=r?Sc(r):new et;for(let[l,u]of Object.entries(t.props)){let c=r[l];i[l]=c,u===void 0?delete r[l]:r[l]=u}for(;o>0;){if(Object.keys(r).length===0){let l=e[o-1];l&&(r=Sc(l),delete r[t.path[o-1]])}else{let l=e[o-1];if(l){let u=Sc(l);u[t.path[o-1]]=r,r=u}else{let u=new et;u[t.path[o-1]]=r,r=u}}o-=1}let a=Object.setPrototypeOf(r,et.prototype),s={...t,props:i};return{data:a,actual:t,reverse:s}}},so;(r=>{function n(o,i){return Fs(o,i)??o}r.apply=n;function t(o,i){return Qd(o,i)}r.merge=t;function e(o,i){let a=0,s=i.path,l=o;for(;a<s.length&&l!==void 0;){if(l=lt.zoomOnce(l,s[a]),l===void 0)return i;if(!ia(l))return;a+=1}if(l===void 0)return i;if(!!ia(l))if(i.type===0){let u={...i.props};for(let c of Object.keys(l))delete u[c];return{...i,props:u}}else if(i.type===1||i.type===4||i.type===7){let u=Xd([i],l);return u?(console.log(u),u):i}else return i}r.filterOp=e})(so||(so={}));function Xd(n,t){if(t===void 0)return;let e=!1,r=n.map(o=>{let i=o.id,a=Fs(o.data,t[i]);if(e=e||a!==void 0,a===void 0&&(a=o.data),o.children){let s=Xd(o.children,t);return s!==void 0?e=!0:s=o.children,{...o,id:i,data:a,children:s}}else return{...o,id:i,data:a}});if(e)return r}function KO(n,t){if(t===void 0)return;let e=!1,r=n.map(o=>{let i=o.id,a=Fs(o.data,t[i]);return e=e||a!==void 0,a===void 0&&(a=o.data),{...o,id:i,data:a}});if(e)return Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r}function Fs(n,t){if(!ia(t))return t;if(n instanceof Je){let e=Xd(n,t);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e}else{if(n instanceof Se)return KO(n,t);if(Array.isArray(n)){let e=!1,r=n.map((o,i)=>{let a=Fs(o,t[i]);return e=e||a!==void 0,a===void 0&&(a=o),a});return e?(Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r):void 0}else{if(n instanceof et)return Qd(n,t);if(n&&typeof n=="object"){let e={},r=!1;for(let[o,i]of Object.entries(n)){let a=Fs(i,t[o]);r=r||a!==void 0,a===void 0&&(a=i),e[o]=a}return r?(Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e):void 0}}}}function Qd(n,t){if(n===void 0)return t;if(t===void 0)return n;if(!ia(t))return t;if(!ia(n))return so.apply(n,t);let e=new Set;for(let o of Object.keys(n))e.add(o);for(let o of Object.keys(t))e.add(o);let r=new et;for(let o of e){let i=Qd(n===void 0?void 0:n[o],t===void 0?void 0:t[o]);r[o]=i}return r}function Mg(n,t){let e={cur:[],result:[],len:0};return n=ks(n,t,e)??n,[n,e.result]}function wc(n,t){return n===null?null:(n.cur[n.len]=t,n.len+=1,n)}function Ac(n){n&&(n.len-=1)}function ZO(n){if(n===null)return null;n.result.push(n.cur.slice(0,n.len))}function Ig(n,t,e){let r=!1,o=n.map(i=>{let a=i.id,s=t[a];if(s!==void 0&&typeof s=="string"&&(r=!0,a=s,e!==null))throw new Error("not supported");let l=ks(i.data,t,wc(e,a));Ac(e),r=r||l!==void 0,l===void 0&&(l=i.data);let u=Ig(i.children,t,e);return u!==void 0?r=!0:u=i.children,{...i,id:a,data:l,children:u}});if(r)return o}function JO(n,t,e){let r=!1,o=n.map(i=>{let a=i.id,s=t[a];if(s!==void 0&&typeof s=="string"&&(r=!0,a=s,e!==null))throw new Error("not supported");let l=ks(i.data,t,wc(e,a));return Ac(e),r=r||l!==void 0,l===void 0&&(l=i.data),{...i,id:a,data:l}});if(r)return Object.setPrototypeOf(o,Object.getPrototypeOf(n)),o}function ks(n,t,e){if(n instanceof Je){let r=Ig(n,t,e);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r}else{if(n instanceof Se)return JO(n,t,e);if(Array.isArray(n)){let r=!1,o=n.map((i,a)=>{let s=ks(i,t,wc(e,a));return Ac(e),r=r||s!==void 0,s===void 0&&(s=i),s});return r?(Object.setPrototypeOf(o,Object.getPrototypeOf(n)),o):void 0}else if(n&&typeof n=="object"&&!oa(n)){let r={},o=!1;for(let[i,a]of Object.entries(n))if(i!=="name"){let s=t[i];if(typeof s=="string"){if(e!==null)throw new Error("not supported");o=!0,i=s}let l=ks(a,t,wc(e,i));Ac(e),o=o||l!==void 0,l===void 0&&(l=a),r[i]=l}else r[i]=a;return o?(Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r):void 0}else if(typeof n=="string"){let r=t[n];return r!==void 0&&ZO(e),r}else return}}var aa;(t=>{function n(e,r){let o=lt.zoom(r,e.path);if(typeof o=="object"){let i={};for(let a of Object.keys(e.props))i[a]=o[a];return{...e,props:i}}else return{...e,props:{}}}t.replaceProps=n})(aa||(aa={}));var ct;(s=>{function n(l,u){return{...l,path:l.path.slice(u)}}s.drop=n;function t(l,u){return e(l,u)?.data??l}s.applySimple=t;function e(l,u){let c=u.path;for(var d=[];;){let p;if(l instanceof et&&u.type===0&&(p=l.runOp({...u,path:c.slice(d.length)}),p===null&&(p=void 0)),p===void 0&&d.length===c.length&&(l instanceof Je||l instanceof Se||l instanceof xe?p=l.runOp(u):p=na.runOp(l,u)),p!==void 0)if(p!==null){let m=p.data;for(let y=d.length-1;y>=0;y--){let g=c[y],b=d[y];if(b instanceof Je){if(typeof g=="number")throw new Error("illegal arg");m=b.modifyById(g,m)}else if(b instanceof Se){if(typeof g=="number")throw new Error("illegal arg");m=b.modifyById(g,m)}else if(b instanceof xe){if(typeof g=="number")throw new Error("illegal arg");m=b.modifyById(g,m)}else if(b instanceof et){let w={...b,[g]:m};m=Object.setPrototypeOf(w,et.prototype)}else if(typeof b=="object")if(Array.isArray(b)){if(typeof g=="string"&&(g=parseInt(g),isNaN(g)))throw new Error("Invalid path");let w=m;m=[...b],m[g]=w}else m={...b,[g]:m};else return null}return{data:m,actual:{...p.actual,path:c},reverse:{...p.reverse,path:c}}}else return null;let f=c[d.length],h;if(l instanceof Je){if(typeof f=="number")throw new Error("");h=l.get(f)?.data}else if(l instanceof Se){if(typeof f=="number")throw new Error("");h=l.get(f)?.data}else l!==null&&(h=l[f]);if(h!==void 0)d.push(l),l=h;else return null}}s.apply=e;function r(l,u){for(let c=0;c<l.length&&c<u.length;c++)if(l[c]!==u[c])return!0;return!1}s.pathDisjoint=r;function o(l,u){if(l.length!==u.length)return!1;for(let c=0;c<l.length;c++)if(l[c]!==u[c])return!1;return!0}s.pathEq=o;function i(l,u){return r(l.path,u.path)}s.commutative=i;function a(l,u){return l.type===0&&u.type===0&&o(l.path,u.path)?Object.keys(l.props).every(c=>u.props[c]!==void 0):!1}s.subsumed=a})(ct||(ct={}));var js;(l=>{function n(){return[]}l.empty=n;function t(u,c){let d=[];for(let p of u){let[f,...h]=p.path;f===c&&d.push({...p,path:h})}return d}l.removePrefix=t;function e(u,c){return u.map(d=>({...d,path:[c,...d.path]}))}l.addPrefix=e;function r(u,c){return[...u,...c]}l.concat=r;function o(u,c){return[...u.filter(p=>!c.some(f=>ct.subsumed(p,f))),...c]}l.compress=o;function i(u,c){return u.every(d=>c.every(p=>ct.commutative(d,p)))}l.commutative=i;function a(u,c){for(let d of c){let p=s(u,d);p!==null&&(u=p.data)}return u}l.applyAll=a;function s(u,c){var d=u;let p=[],f=[];for(let h of c)try{if(h.type===3||h.type===5&&h.path[h.path.length-1]==="variables"){let m,y,g;if(h.type===3?(m=lt.zoom(d,[...h.path,h.id]),g=ct.apply(d,{...h,type:2})):(m=lt.zoom(d,[...h.path,h.id,"value"]),g=ct.apply(d,h)),g!==null){d=g.data;let[b,w]=Mg(d,{[h.id]:m});d=b;for(let A=0;A<w.length;A++){let S=w[A],P=S.pop();if(typeof P=="number"){let O=[P];for(let D=A+1;D<w.length;D++){let N=w[D],T=N[N.length-1];if(typeof T=="number"&&lt.equal(S,N.slice(0,N.length-1)))O.push(T),w.splice(D,1);else break}let x=lt.zoom(d,S);y=x.map((D,N)=>O.includes(N)?h.id:D),m=x,P=S.pop()}else{if(P==="alphaOverride"||P==="alpha"){m/=100;let O=m,x=lt.zoom(d,S.slice(0,S.length-2)),D=x.layers.map(N=>N.id===S[S.length-1]?{...N,data:{...N.data,[P]:O}}:N);Object.setPrototypeOf(D,Object.getPrototypeOf(x.layers)),x.layers=D}y=h.id}p.push({type:0,path:S,props:{[P]:m}}),f.push({type:0,path:S,props:{[P]:y}})}f.push(g.reverse),p.push(g.actual)}}else{let m=ct.apply(d,h);m!==null&&(p.push(m.actual),d=m.data,f.push(m.reverse))}}catch(m){if(m instanceof ra)return null;throw m}return{data:d,actual:p,reverse:f.reverse()}}l.apply=s})(js||(js={}));var Ng=Symbol(),eC=Symbol(),Pc=Symbol(),Jn=class{reportOp(t,e,r=[]){let o=this;if(e===null)return;o._current=e.data;let i=r;for(;!(o instanceof _c);){let a=o._path,s=o._current;if(a!==""&&i.splice(0,0,a),o=o._parent,o===null)return;o.update(a,s)}o.push(i,t,e.actual,e.reverse)}deleteChildren(t){if(this._children){let e=this._children[t];if(e){let r=e[Pc];r&&r(),delete this._children[t]}}}},Zd=class extends Jn{constructor(t,e,r){super(),this._parent=t,this._path=e,this._current=r}update(t,e){if(Array.isArray(this._current)){if(typeof t=="string"&&(t=parseInt(t),isNaN(t)))throw new Error("Invalid path");this._current=[...this._current],this._current[t]=e}else this._current={...this._current,[t]:e}}runOp(t){this.reportOp(t,na.runOp(this._current,t),t.path)}},Jd=class extends Jn{constructor(t,e,r){super(),this._parent=t,this._path=e,this._current=r}update(t,e){this._current={...this._current,[t]:e},Object.setPrototypeOf(this._current,xe.prototype)}runOp(t){this.reportOp(t,this._current.runOp(t))}},Dg={get(n,t){if(t===Pc)return()=>{n._parent=null};if(t===Ng)return n._current;if(t===eC)return n;let{_current:e,_children:r}=n;if(t==="push"&&Array.isArray(e))throw new Error("not supported to expand array");let o=r===void 0?void 0:r[t];if(o!==void 0)return o;let i=e[t],a=Oc(n,t,i);return a!==i?(r===void 0&&(r={},n._children=r),r[t]=a,a):i},has(n,t){return t 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,t){let e=n._current,r=Reflect.getOwnPropertyDescriptor(e,t);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:e[t]}}},tC={...Dg,set(n,t,e){let r={type:0,props:{[t]:ut(e)??e}};return n.deleteChildren(t),n.runOp(r),!0},deleteProperty(n,t){let e={type:0,props:{[t]:void 0}};return n.deleteChildren(t),n.runOp(e),!0}},rC={...Dg,set(n,t,e){return e===void 0?this.deleteProperty(n,t):(n.deleteChildren(t),n.runOp({type:1,id:t,data:e})),!0},deleteProperty(n,t){return n.runOp({type:2,id:t}),!0}},sa=class extends Jn{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[Pc]=()=>{this._parent=null}}unproxy(){return this._current}update(t,e){this._current=this._current.modifyById(t,e)}runOp(t){this.reportOp(t,this._current.runOp(t))}randomId(){return this._current.randomId()}isDescendantOf(t,e){return this._current.isDescendantOf(t,e)}childrenOf(t){return this._current.childrenOf(t)}traverse(t){return this._current.traverse(t)}get(t){return this._current.get(t)}parent(t){return this._current.parent(t)}traverse(t){this._current.traverse((e,r)=>{t(e,this.data(e))})}data(t){let{_current:e,_children:r}=this,o=r===void 0?void 0:r[t];if(o!==void 0)return o;let i=e.get(t)?.data,a=Oc(this,t,i);return a!==i?(r===void 0&&(r={},this._children=r),r[t]=a,a):i}add(t,e,r,o,i){this.runOp({type:7,parent:t,fi:e,id:r,data:o,children:i})}move(t,e,r){this.runOp({type:9,parent:t,fi:e,id:r})}insertAfter(t,e,r){let o=this._current.insertAfterHelper(t,e,r.length);for(let i=0;i<r.length;i++){let a=r[i];this.add(t,o[i],a.id,a.data,a.children)}}insertBefore(t,e,r){let o=this._current.insertBeforeHelper(t,e,r.length);for(let i=0;i<r.length;i++){let a=r[i];this.add(t,o[i],a.id,a.data,a.children)}}moveAfter(t,e,r){let o=this._current.insertAfterHelper(t,e,r.length);for(let i=0;i<r.length;i++){let a=r[i];this.move(t,o[i],a)}}moveBefore(t,e,r){let o=this._current.insertBeforeHelper(t,e,r.length);for(let i=0;i<r.length;i++){let a=r[i];this.move(t,o[i],a)}}delete(t){this.deleteChildren(t),this.runOp({type:8,id:t})}sortNext(t){return this._current.sortNext(t)}sortPrevious(t){return this._current.sortPrevious(t)}getAllSorted(t){return this._current.getAllSorted(t)}},la=class extends Jn{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[Pc]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(t){let e=this.length;for(let r=0;r<e;r++){let o=this._current[r].id,i=this._current[r].fi;t(this.data(this._current[r].id),o,i)}}find(t){let e=this.length;for(let r=0;r<e;r++){let o=this._current[r].id;if(t(this.data(o),o))return this.get(o)}}update(t,e){this._current=this._current.modifyById(t,e)}randomId(){return this._current.randomId()}get(t){return{...this._current.get(t),data:this.data(t)}}data(t){let{_current:e,_children:r}=this,o=r===void 0?void 0:r[t];if(o!==void 0)return o;let i=e.get(t)?.data,a=Oc(this,t,i);return a!==i?(r===void 0&&(r={},this._children=r),r[t]=a,a):i}runOp(t){this.reportOp(t,this._current.runOp(t))}add(t,e,r){this.runOp({type:4,fi:t,id:e,data:r})}move(t,e){this.runOp({type:6,fi:t,id:e})}insertAfter(t,e){let r=this._current.insertAfterHelper(t,e.length);for(let o=0;o<e.length;o++){let i=e[o];this.add(r[o],i.id,i.data)}}insertBefore(t,e){let r=this._current.insertBeforeHelper(t,e.length);for(let o=0;o<e.length;o++){let i=e[o];this.add(r[o],i.id,i.data)}}moveAfter(t,e){let r=this._current.insertAfterHelper(t,e.length);for(let o=0;o<e.length;o++){let i=e[o];this.move(r[o],i)}}moveBefore(t,e){let r=this._current.insertBeforeHelper(t,e.length);for(let o=0;o<e.length;o++){let i=e[o];this.move(r[o],i)}}delete(t){this.deleteChildren(t),this.runOp({type:5,id:t})}};function Kd(n,t,e){if(n.length>0){let r=n[n.length-1];if(r.type===0&&t.type===0&&lt.equal(r.path,e)){Object.assign(r.props,t.props);return}}n.push({...t,path:e})}var _c=class extends Jn{constructor(t){super(),this.ts=[],this.actual=[],this.reverse=[],this._current=t}update(t,e){if(t!=="")throw new Error("");this._current=e}push(t,e,r,o){Kd(this.ts,e,t),Kd(this.actual,r,t),Kd(this.reverse,o,t)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function Oc(n,t,e){return e instanceof Je?new sa(n,t,e):e instanceof Se?new la(n,t,e):e instanceof xe?new Proxy(new Jd(n,t,e),rC):e!==null&&typeof e=="object"?oa(e)?e:new Proxy(new Zd(n,t,e),tC):e}function ep(n){let t=new _c(n);return[Oc(t,"",n),t]}function fn(n,t){let[e,r]=ep(n);return t(e),r.result()}function ut(n){return n instanceof sa||n instanceof la?n._current:n!==null&&typeof n=="object"?n[Ng]:n}var lt;(o=>{function n(i,a){if(a.length===i.length)for(var s=0;s<i.length;){if(i[s]!==a[s])return!1;s+=1}else return!1;return!0}o.equal=n;function t(i,a,s){let l=r(s,i);if(l!==void 0&&typeof l=="object"&&l!==null){let u={...a};return Object.keys(l).forEach(c=>{delete u[c]}),u}else return a}o.removeOverridden=t;function e(i,a){if((i instanceof Je||i instanceof sa)&&typeof a=="string")return i.data(a);if((i instanceof Se||i instanceof la)&&typeof a=="string")return i.data(a);if(typeof a=="number"&&Array.isArray(i))return i[a];if(typeof a=="string"&&typeof i=="object"&&i!==null)return i[a]}o.zoomOnce=e;function r(i,a,s=0){for(;s<a.length&&i!==void 0;)i=e(i,a[s]),s+=1;return i}o.zoom=r})(lt||(lt={}));function Eg(n,t){let e=[];if(t.length===n.length)for(var r=0;r<n.length;){if(t[r]==="*")e.push(n[r]);else if(n[r]!==t[r])return null;r+=1}else return null;return e}function Le(n,t){let e=[];if(t.length<=n.length)for(var r=0;r<t.length;){if(t[r]==="*")e.push(n[r]);else if(n[r]!==t[r])return null;r+=1}else return null;return e}var Cc=class{},Us=class extends Cc{constructor(e){super();this.id=e}},Hs=class extends Cc{constructor(e){super();this.data=e}};var rp;try{rp=new TextDecoder}catch{}var de,mn,G=0;var kg=[],op=kg,np=0,ur={},We,hn,Mr=0,lo=0,Sr,zo,or=[],Ye,Bg={useRecords:!1,mapsAsObjects:!0},qs=class{},ap=new qs;ap.name="MessagePack 0xC1";var ca=!1,co=class{constructor(t){t&&(t.useRecords===!1&&t.mapsAsObjects===void 0&&(t.mapsAsObjects=!0),t.structures?t.structures.sharedLength=t.structures.length:t.getStructures&&((t.structures=[]).uninitialized=!0,t.structures.sharedLength=0)),Object.assign(this,t)}unpack(t,e){if(de)return Wg(()=>(Mc(),this?this.unpack(t,e):co.prototype.unpack.call(Bg,t,e)));mn=e>-1?e:t.length,G=0,np=0,lo=0,hn=null,op=kg,Sr=null,de=t;try{Ye=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(r){throw de=null,t instanceof Uint8Array?r:new Error("Source must be a Uint8Array or Buffer but was a "+(t&&typeof t=="object"?t.constructor.name:typeof t))}if(this instanceof co){if(ur=this,this.structures)return We=this.structures,Tc();(!We||We.length>0)&&(We=[])}else ur=Bg,(!We||We.length>0)&&(We=[]);return Tc()}unpackMultiple(t,e){let r,o=0;try{ca=!0;let i=t.length,a=this?this.unpack(t,i):Dc.unpack(t,i);if(e){for(e(a);G<i;)if(o=G,e(Tc())===!1)return}else{for(r=[a];G<i;)o=G,r.push(Tc());return r}}catch(i){throw i.lastPosition=o,i.values=r,i}finally{ca=!1,Mc()}}_mergeStructures(t,e){t=t||[];for(let r=0,o=t.length;r<o;r++){let i=t[r];i&&(i.isShared=!0,r>=32&&(i.highByte=r-32>>5))}t.sharedLength=t.length;for(let r in e||[])if(r>=0){let o=t[r],i=e[r];i&&(o&&((t.restoreStructures||(t.restoreStructures=[]))[r]=o),t[r]=i)}return this.structures=t}decode(t,e){return this.unpack(t,e)}};function Tc(){try{if(!ur.trusted&&!ca){let t=We.sharedLength||0;t<We.length&&(We.length=t)}let n=gt();if(G==mn)We.restoreStructures&&Lg(),We=null,de=null,zo&&(zo=null);else if(G>mn){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!ca)throw new Error("Data read, but end of buffer not reached");return n}catch(n){throw We.restoreStructures&&Lg(),Mc(),(n instanceof RangeError||n.message.startsWith("Unexpected end of buffer"))&&(n.incomplete=!0),n}}function Lg(){for(let n in We.restoreStructures)We[n]=We.restoreStructures[n];We.restoreStructures=null}function gt(){let n=de[G++];if(n<160)if(n<128){if(n<64)return n;{let t=We[n&63]||ur.getStructures&&jg()[n&63];return t?(t.read||(t.read=sp(t,n&63)),t.read()):n}}else if(n<144)if(n-=128,ur.mapsAsObjects){let t={};for(let e=0;e<n;e++)t[Hg()]=gt();return t}else{let t=new Map;for(let e=0;e<n;e++)t.set(gt(),gt());return t}else{n-=144;let t=new Array(n);for(let e=0;e<n;e++)t[e]=gt();return t}else if(n<192){let t=n-160;if(lo>=G)return hn.slice(G-Mr,(G+=t)-Mr);if(lo==0&&mn<140){let e=t<16?lp(t):Ug(t);if(e!=null)return e}return ip(t)}else{let t;switch(n){case 192:return null;case 193:return Sr?(t=gt(),t>0?Sr[1].slice(Sr.position1,Sr.position1+=t):Sr[0].slice(Sr.position0,Sr.position0-=t)):ap;case 194:return!1;case 195:return!0;case 196:return tp(de[G++]);case 197:return t=Ye.getUint16(G),G+=2,tp(t);case 198:return t=Ye.getUint32(G),G+=4,tp(t);case 199:return ei(de[G++]);case 200:return t=Ye.getUint16(G),G+=2,ei(t);case 201:return t=Ye.getUint32(G),G+=4,ei(t);case 202:if(t=Ye.getFloat32(G),ur.useFloat32>2){let e=Nc[(de[G]&127)<<1|de[G+1]>>7];return G+=4,(e*t+(t>0?.5:-.5)>>0)/e}return G+=4,t;case 203:return t=Ye.getFloat64(G),G+=8,t;case 204:return de[G++];case 205:return t=Ye.getUint16(G),G+=2,t;case 206:return t=Ye.getUint32(G),G+=4,t;case 207:return ur.int64AsNumber?(t=Ye.getUint32(G)*4294967296,t+=Ye.getUint32(G+4)):t=Ye.getBigUint64(G),G+=8,t;case 208:return Ye.getInt8(G++);case 209:return t=Ye.getInt16(G),G+=2,t;case 210:return t=Ye.getInt32(G),G+=4,t;case 211:return ur.int64AsNumber?(t=Ye.getInt32(G)*4294967296,t+=Ye.getUint32(G+4)):t=Ye.getBigInt64(G),G+=8,t;case 212:if(t=de[G++],t==114)return Fg(de[G++]&63);{let e=or[t];if(e)return e.read?(G++,e.read(gt())):e.noBuffer?(G++,e()):e(de.subarray(G,++G));throw new Error("Unknown extension "+t)}case 213:return t=de[G],t==114?(G++,Fg(de[G++]&63,de[G++])):ei(2);case 214:return ei(4);case 215:return ei(8);case 216:return ei(16);case 217:return t=de[G++],lo>=G?hn.slice(G-Mr,(G+=t)-Mr):nC(t);case 218:return t=Ye.getUint16(G),G+=2,lo>=G?hn.slice(G-Mr,(G+=t)-Mr):iC(t);case 219:return t=Ye.getUint32(G),G+=4,lo>=G?hn.slice(G-Mr,(G+=t)-Mr):aC(t);case 220:return t=Ye.getUint16(G),G+=2,Vg(t);case 221:return t=Ye.getUint32(G),G+=4,Vg(t);case 222:return t=Ye.getUint16(G),G+=2,zg(t);case 223:return t=Ye.getUint32(G),G+=4,zg(t);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 oC=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function sp(n,t){function e(){if(e.count++>2){let o=n.read=new Function("r","return function(){return {"+n.map(i=>oC.test(i)?i+":r()":"["+JSON.stringify(i)+"]:r()").join(",")+"}}")(gt);return n.highByte===0&&(n.read=Rg(t,n.read)),o()}let r={};for(let o=0,i=n.length;o<i;o++){let a=n[o];r[a]=gt()}return r}return e.count=0,n.highByte===0?Rg(t,e):e}var Rg=(n,t)=>function(){let e=de[G++];if(e===0)return t();let r=n<32?-(n+(e<<5)):n+(e<<5),o=We[r]||jg()[r];if(!o)throw new Error("Record id is not defined for "+r);return o.read||(o.read=sp(o,n)),o.read()};function jg(){let n=Wg(()=>(de=null,ur.getStructures()));return We=ur._mergeStructures(n,We)}var ip=Ic,nC=Ic,iC=Ic,aC=Ic;function Ic(n){let t;if(n<16&&(t=lp(n)))return t;if(n>64&&rp)return rp.decode(de.subarray(G,G+=n));let e=G+n,r=[];for(t="";G<e;){let o=de[G++];if((o&128)===0)r.push(o);else if((o&224)===192){let i=de[G++]&63;r.push((o&31)<<6|i)}else if((o&240)===224){let i=de[G++]&63,a=de[G++]&63;r.push((o&31)<<12|i<<6|a)}else if((o&248)===240){let i=de[G++]&63,a=de[G++]&63,s=de[G++]&63,l=(o&7)<<18|i<<12|a<<6|s;l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|l&1023),r.push(l)}else r.push(o);r.length>=4096&&(t+=Vt.apply(String,r),r.length=0)}return r.length>0&&(t+=Vt.apply(String,r)),t}function Vg(n){let t=new Array(n);for(let e=0;e<n;e++)t[e]=gt();return t}function zg(n){if(ur.mapsAsObjects){let t={};for(let e=0;e<n;e++)t[Hg()]=gt();return t}else{let t=new Map;for(let e=0;e<n;e++)t.set(gt(),gt());return t}}var Vt=String.fromCharCode;function Ug(n){let t=G,e=new Array(n);for(let r=0;r<n;r++){let o=de[G++];if((o&128)>0){G=t;return}e[r]=o}return Vt.apply(String,e)}function lp(n){if(n<4)if(n<2){if(n===0)return"";{let t=de[G++];if((t&128)>1){G-=1;return}return Vt(t)}}else{let t=de[G++],e=de[G++];if((t&128)>0||(e&128)>0){G-=2;return}if(n<3)return Vt(t,e);let r=de[G++];if((r&128)>0){G-=3;return}return Vt(t,e,r)}else{let t=de[G++],e=de[G++],r=de[G++],o=de[G++];if((t&128)>0||(e&128)>0||(r&128)>0||(o&128)>0){G-=4;return}if(n<6){if(n===4)return Vt(t,e,r,o);{let i=de[G++];if((i&128)>0){G-=5;return}return Vt(t,e,r,o,i)}}else if(n<8){let i=de[G++],a=de[G++];if((i&128)>0||(a&128)>0){G-=6;return}if(n<7)return Vt(t,e,r,o,i,a);let s=de[G++];if((s&128)>0){G-=7;return}return Vt(t,e,r,o,i,a,s)}else{let i=de[G++],a=de[G++],s=de[G++],l=de[G++];if((i&128)>0||(a&128)>0||(s&128)>0||(l&128)>0){G-=8;return}if(n<10){if(n===8)return Vt(t,e,r,o,i,a,s,l);{let u=de[G++];if((u&128)>0){G-=9;return}return Vt(t,e,r,o,i,a,s,l,u)}}else if(n<12){let u=de[G++],c=de[G++];if((u&128)>0||(c&128)>0){G-=10;return}if(n<11)return Vt(t,e,r,o,i,a,s,l,u,c);let d=de[G++];if((d&128)>0){G-=11;return}return Vt(t,e,r,o,i,a,s,l,u,c,d)}else{let u=de[G++],c=de[G++],d=de[G++],p=de[G++];if((u&128)>0||(c&128)>0||(d&128)>0||(p&128)>0){G-=12;return}if(n<14){if(n===12)return Vt(t,e,r,o,i,a,s,l,u,c,d,p);{let f=de[G++];if((f&128)>0){G-=13;return}return Vt(t,e,r,o,i,a,s,l,u,c,d,p,f)}}else{let f=de[G++],h=de[G++];if((f&128)>0||(h&128)>0){G-=14;return}if(n<15)return Vt(t,e,r,o,i,a,s,l,u,c,d,p,f,h);let m=de[G++];if((m&128)>0){G-=15;return}return Vt(t,e,r,o,i,a,s,l,u,c,d,p,f,h,m)}}}}}function tp(n){return ur.copyBuffers?Uint8Array.prototype.slice.call(de,G,G+=n):de.subarray(G,G+=n)}function ei(n){let t=de[G++];if(or[t])return or[t](de.subarray(G,G+=n));throw new Error("Unknown extension type "+t)}var Gg=new Array(4096);function Hg(){let n=de[G++];if(n>=160&&n<192){if(n=n-160,lo>=G)return hn.slice(G-Mr,(G+=n)-Mr);if(!(lo==0&&mn<180))return ip(n)}else return G--,gt();let t=(n<<5^(n>1?Ye.getUint16(G):n>0?de[G]:0))&4095,e=Gg[t],r=G,o=G+n-3,i,a=0;if(e&&e.bytes==n){for(;r<o;){if(i=Ye.getUint32(r),i!=e[a++]){r=1879048192;break}r+=4}for(o+=3;r<o;)if(i=de[r++],i!=e[a++]){r=1879048192;break}if(r===o)return G=r,e.string;o-=3,r=G}for(e=[],Gg[t]=e,e.bytes=n;r<o;)i=Ye.getUint32(r),e.push(i),r+=4;for(o+=3;r<o;)i=de[r++],e.push(i);let s=n<16?lp(n):Ug(n);return s!=null?e.string=s:e.string=ip(n)}var Fg=(n,t)=>{var e=gt();let r=n;t!==void 0&&(n=n<32?-((t<<5)+n):(t<<5)+n,e.highByte=t);let o=We[n];return o&&o.isShared&&((We.restoreStructures||(We.restoreStructures=[]))[n]=o),We[n]=e,e.read=sp(e,r),e.read()},qg=typeof self=="object"?self:global;or[0]=()=>{};or[0].noBuffer=!0;or[101]=()=>{let n=gt();return(qg[n[0]]||Error)(n[1])};or[105]=n=>{let t=Ye.getUint32(G-4);zo||(zo=new Map);let e=de[G],r;e>=144&&e<160||e==220||e==221?r=[]:r={};let o={target:r};zo.set(t,o);let i=gt();return o.used?Object.assign(r,i):(o.target=i,i)};or[112]=n=>{let t=Ye.getUint32(G-4),e=zo.get(t);return e.used=!0,e.target};or[115]=()=>new Set(gt());var cp=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(n=>n+"Array");or[116]=n=>{let t=n[0],e=cp[t];if(!e)throw new Error("Could not find typed array for code "+t);return new qg[e](Uint8Array.prototype.slice.call(n,1).buffer)};or[120]=()=>{let n=gt();return new RegExp(n[0],n[1])};or[98]=n=>{let t=(n[0]<<24)+(n[1]<<16)+(n[2]<<8)+n[3],e=G;G+=t-4,Sr=[gt(),gt()],Sr.position0=0,Sr.position1=0;let r=G;G=e;try{return gt()}finally{G=r}};or[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 Wg(n){let t=mn,e=G,r=np,o=Mr,i=lo,a=hn,s=op,l=zo,u=Sr,c=new Uint8Array(de.slice(0,mn)),d=We,p=We.slice(0,We.length),f=ur,h=ca,m=n();return mn=t,G=e,np=r,Mr=o,lo=i,hn=a,op=s,zo=l,Sr=u,de=c,ca=h,We=d,We.splice(0,We.length,...p),ur=f,Ye=new DataView(de.buffer,de.byteOffset,de.byteLength),m}function Mc(){de=null,zo=null,We=null}function $g(n){n.unpack?or[n.type]=n.unpack:or[n.type]=n}var Nc=new Array(147);for(let n=0;n<256;n++)Nc[n]=+("1e"+Math.floor(45.15-n*.30103));var Dc=new co({useRecords:!1}),sC=Dc.unpack,lC=Dc.unpackMultiple,cC=Dc.unpack,Ec={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},uC=new Float32Array(1),OU=new Uint8Array(uC.buffer,0,4);var Bc;try{Bc=new TextEncoder}catch{}var Lc,dp,Rc=typeof Buffer<"u",up=Rc?Buffer.allocUnsafeSlow:Uint8Array,Kg=Rc?Buffer:Uint8Array,Yg=Rc?4294967296:2144337920,K,vt,j=0,uo,po=null,dC=/[\u0080-\uFFFF]/,Ws=Symbol("record-id"),ti=class extends co{constructor(t){super(t),this.offset=0;let e,r,o,i,a,s,l=0,u=Kg.prototype.utf8Write?function(x,D,N){return K.utf8Write(x,D,N)}:Bc&&Bc.encodeInto?function(x,D){return Bc.encodeInto(x,K.subarray(D)).written}:!1,c=this;t||(t={});let d=t&&t.sequential,p=t.structures||t.saveStructures,f=t.maxSharedStructures;if(f==null&&(f=p?32:0),f>8160)throw new Error("Maximum maxSharedStructure is 8160");let h=t.maxOwnStructures;h==null&&(h=p?32:64),d&&!t.saveStructures&&(this.structures=[]);let m=f>32||h+f>64,y=f+64,g=f+h+64;if(g>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let b=[],w=0,A=0;this.pack=this.encode=function(x,D){if(K||(K=new up(8192),vt=new DataView(K.buffer,0,8192),j=0),uo=K.length-10,uo-j<2048?(K=new up(K.length),vt=new DataView(K.buffer,0,K.length),uo=K.length-10,j=0):j=j+7&2147483640,r=j,s=c.structuredClone?new Map:null,c.bundleStrings?(po=["",""],K[j++]=214,K[j++]=98,po.position=j-r,j+=4):po=null,o=c.structures,o){o.uninitialized&&(o=c._mergeStructures(c.getStructures()));let N=o.sharedLength||0;if(N>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 T=0;T<N;T++){let I=o[T];if(!I)continue;let E,B=o.transitions;for(let R=0,F=I.length;R<F;R++){let V=I[R];E=B[V],E||(E=B[V]=Object.create(null)),B=E}B[Ws]=T+64}l=N}d||(o.nextId=N+64)}i&&(i=!1),a=o||[];try{if(S(x),po){vt.setUint32(po.position+r,j-po.position-r);let N=po;po=null,S(N[0]),S(N[1])}if(c.offset=j,s&&s.idsToInsert){j+=s.idsToInsert.length*6,j>uo&&O(j),c.offset=j;let N=fC(K.subarray(r,j),s.idsToInsert);return s=null,N}return D&Jg?(K.start=r,K.end=j,K):K.subarray(r,j)}finally{if(o){if(A<10&&A++,w>1e4)o.transitions=null,A=0,w=0,b.length>0&&(b=[]);else if(b.length>0&&!d){for(let N=0,T=b.length;N<T;N++)b[N][Ws]=0;b=[]}if(i&&c.saveStructures){let N=o.sharedLength||f;o.length>N&&(o=o.slice(0,N));let T=K.subarray(r,j);return c.saveStructures(o,l)===!1?(c._mergeStructures(c.getStructures()),c.pack(x)):(l=N,T)}}D&vC&&(j=r)}};let S=x=>{j>uo&&(K=O(j));var D=typeof x,N;if(D==="string"){let T=x.length;if(po&&T>=8&&T<4096){let B=dC.test(x);po[B?0:1]+=x,K[j++]=193,S(B?-T:T);return}let I;T<32?I=1:T<256?I=2:T<65536?I=3:I=5;let E=T*3;if(j+E>uo&&(K=O(j+E)),T<64||!u){let B,R,F,V=j+I;for(B=0;B<T;B++)R=x.charCodeAt(B),R<128?K[V++]=R:R<2048?(K[V++]=R>>6|192,K[V++]=R&63|128):(R&64512)===55296&&((F=x.charCodeAt(B+1))&64512)===56320?(R=65536+((R&1023)<<10)+(F&1023),B++,K[V++]=R>>18|240,K[V++]=R>>12&63|128,K[V++]=R>>6&63|128,K[V++]=R&63|128):(K[V++]=R>>12|224,K[V++]=R>>6&63|128,K[V++]=R&63|128);N=V-j-I}else N=u(x,j+I,E);N<32?K[j++]=160|N:N<256?(I<2&&K.copyWithin(j+2,j+1,j+1+N),K[j++]=217,K[j++]=N):N<65536?(I<3&&K.copyWithin(j+3,j+2,j+2+N),K[j++]=218,K[j++]=N>>8,K[j++]=N&255):(I<5&&K.copyWithin(j+5,j+3,j+3+N),K[j++]=219,vt.setUint32(j,N),j+=4),j+=N}else if(D==="number")if(x>>>0===x)x<64?K[j++]=x:x<256?(K[j++]=204,K[j++]=x):x<65536?(K[j++]=205,K[j++]=x>>8,K[j++]=x&255):(K[j++]=206,vt.setUint32(j,x),j+=4);else if(x>>0===x)x>=-32?K[j++]=256+x:x>=-128?(K[j++]=208,K[j++]=x+256):x>=-32768?(K[j++]=209,vt.setInt16(j,x),j+=2):(K[j++]=210,vt.setInt32(j,x),j+=4);else{let T;if((T=this.useFloat32)>0&&x<4294967296&&x>=-2147483648){K[j++]=202,vt.setFloat32(j,x);let I;if(T<4||(I=x*Nc[(K[j]&127)<<1|K[j+1]>>7])>>0===I){j+=4;return}else j--}K[j++]=203,vt.setFloat64(j,x),j+=8}else if(D==="object")if(!x)K[j++]=192;else{if(s){let I=s.get(x);if(I){if(!I.id){let E=s.idsToInsert||(s.idsToInsert=[]);I.id=E.push(I)}K[j++]=214,K[j++]=112,vt.setUint32(j,I.id),j+=4;return}else s.set(x,{offset:j-r})}let T=x.constructor;if(T===Object)P(x,!0);else if(T===Array){N=x.length,N<16?K[j++]=144|N:N<65536?(K[j++]=220,K[j++]=N>>8,K[j++]=N&255):(K[j++]=221,vt.setUint32(j,N),j+=4);for(let I=0;I<N;I++)S(x[I])}else if(T===Map){N=x.size,N<16?K[j++]=128|N:N<65536?(K[j++]=222,K[j++]=N>>8,K[j++]=N&255):(K[j++]=223,vt.setUint32(j,N),j+=4);for(let[I,E]of x)S(I),S(E)}else{for(let I=0,E=Lc.length;I<E;I++){let B=dp[I];if(x instanceof B){let R=Lc[I];if(R.write){R.type&&(K[j++]=212,K[j++]=R.type,K[j++]=0),S(R.write.call(this,x));return}let F=K,V=vt,q=j;K=null;let k;try{k=R.pack.call(this,x,U=>(K=F,F=null,j+=U,j>uo&&O(j),{target:K,targetView:vt,position:j-U}),S)}finally{F&&(K=F,vt=V,j=q,uo=K.length-10)}k&&(k.length+j>uo&&O(k.length+j),j=pC(k,K,j,R.type));return}}P(x,!x.hasOwnProperty)}}else if(D==="boolean")K[j++]=x?195:194;else if(D==="bigint"){if(x<BigInt(1)<<BigInt(63)&&x>=-(BigInt(1)<<BigInt(63)))K[j++]=211,vt.setBigInt64(j,x);else if(x<BigInt(1)<<BigInt(64)&&x>0)K[j++]=207,vt.setBigUint64(j,x);else if(this.largeBigIntToFloat)K[j++]=203,vt.setFloat64(j,Number(x));else throw new RangeError(x+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");j+=8}else if(D==="undefined")this.encodeUndefinedAsNil?K[j++]=192:(K[j++]=212,K[j++]=0,K[j++]=0);else if(D==="function")S(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+D)},P=this.useRecords===!1?this.variableMapSize?x=>{let D=Object.keys(x),N=D.length;N<16?K[j++]=128|N:N<65536?(K[j++]=222,K[j++]=N>>8,K[j++]=N&255):(K[j++]=223,vt.setUint32(j,N),j+=4);let T;for(let I=0;I<N;I++)S(T=D[I]),S(x[T])}:(x,D)=>{K[j++]=222;let N=j-r;j+=2;let T=0;for(let I in x)(D||x.hasOwnProperty(I))&&(S(I),S(x[I]),T++);K[N+++r]=T>>8,K[N+r]=T&255}:x=>{let D=Object.keys(x),N,T=a.transitions||(a.transitions=Object.create(null)),I=0;for(let B=0,R=D.length;B<R;B++){let F=D[B];N=T[F],N||(N=T[F]=Object.create(null),I++),T=N}let E=T[Ws];if(E)E>=96&&m?(K[j++]=((E-=96)&31)+96,K[j++]=E>>5):K[j++]=E;else{E=a.nextId,E||(E=64),E<y&&this.shouldShareStructure&&!this.shouldShareStructure(D)?(E=a.nextOwnId,E<g||(E=y),a.nextOwnId=E+1):(E>=g&&(E=y),a.nextId=E+1);let B=D.highByte=E>=96&&m?E-96>>5:-1;T[Ws]=E,a[E-64]=D,E<y?(D.isShared=!0,a.sharedLength=E-63,i=!0,B>=0?(K[j++]=(E&31)+96,K[j++]=B):K[j++]=E):(B>=0?(K[j++]=213,K[j++]=114,K[j++]=(E&31)+96,K[j++]=B):(K[j++]=212,K[j++]=114,K[j++]=E),I&&(w+=A*I),b.length>=h&&(b.shift()[Ws]=0),b.push(T),S(D))}for(let B=0,R=D.length;B<R;B++)S(x[D[B]])},O=x=>{let D;if(x>16777216){if(x-r>Yg)throw new Error("Packed buffer would be larger than maximum buffer size");D=Math.min(Yg,Math.round(Math.max((x-r)*(x>67108864?1.25:2),4194304)/4096)*4096)}else D=(Math.max(x-r<<2,K.length-1)>>12)+1<<12;let N=new up(D);return vt=new DataView(N.buffer,0,D),K.copy?K.copy(N,0,r,x):N.set(K.slice(r,x)),j-=r,r=0,uo=N.length-10,K=N}}useBuffer(t){K=t,vt=new DataView(K.buffer,K.byteOffset,K.byteLength),j=0}};dp=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,qs];Lc=[{pack(n,t,e){let r=n.getTime()/1e3;if((this.useTimestamp32||n.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:o,targetView:i,position:a}=t(6);o[a++]=214,o[a++]=255,i.setUint32(a,r)}else if(r>0&&r<17179869184){let{target:o,targetView:i,position:a}=t(10);o[a++]=215,o[a++]=255,i.setUint32(a,n.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),i.setUint32(a+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),e(this.onInvalidDate());let{target:o,targetView:i,position:a}=t(3);o[a++]=212,o[a++]=255,o[a++]=255}else{let{target:o,targetView:i,position:a}=t(15);o[a++]=199,o[a++]=12,o[a++]=255,i.setUint32(a,n.getMilliseconds()*1e6),i.setBigInt64(a+4,BigInt(Math.floor(r)))}}},{pack(n,t,e){let r=Array.from(n),{target:o,position:i}=t(this.structuredClone?3:0);this.structuredClone&&(o[i++]=212,o[i++]=115,o[i++]=0),e(r)}},{pack(n,t,e){let{target:r,position:o}=t(this.structuredClone?3:0);this.structuredClone&&(r[o++]=212,r[o++]=101,r[o++]=0),e([n.name,n.message])}},{pack(n,t,e){let{target:r,position:o}=t(this.structuredClone?3:0);this.structuredClone&&(r[o++]=212,r[o++]=120,r[o++]=0),e([n.source,n.flags])}},{pack(n,t){this.structuredClone?Xg(n,16,t):Qg(Rc?Buffer.from(n):new Uint8Array(n),t)}},{pack(n,t){let e=n.constructor;e!==Kg&&this.structuredClone?Xg(n,cp.indexOf(e.name),t):Qg(n,t)}},{pack(n,t){let{target:e,position:r}=t(1);e[r]=193}}];function Xg(n,t,e,r){let o=n.byteLength;if(o+1<256){var{target:i,position:a}=e(4+o);i[a++]=199,i[a++]=o+1}else if(o+1<65536){var{target:i,position:a}=e(5+o);i[a++]=200,i[a++]=o+1>>8,i[a++]=o+1&255}else{var{target:i,position:a,targetView:s}=e(7+o);i[a++]=201,s.setUint32(a,o+1),a+=4}i[a++]=116,i[a++]=t,i.set(new Uint8Array(n.buffer,n.byteOffset,n.byteLength),a)}function Qg(n,t){let e=n.byteLength;var r,o;if(e<256){var{target:r,position:o}=t(e+2);r[o++]=196,r[o++]=e}else if(e<65536){var{target:r,position:o}=t(e+3);r[o++]=197,r[o++]=e>>8,r[o++]=e&255}else{var{target:r,position:o,targetView:i}=t(e+5);r[o++]=198,i.setUint32(o,e),o+=4}r.set(n,o)}function pC(n,t,e,r){let o=n.length;switch(o){case 1:t[e++]=212;break;case 2:t[e++]=213;break;case 4:t[e++]=214;break;case 8:t[e++]=215;break;case 16:t[e++]=216;break;default:o<256?(t[e++]=199,t[e++]=o):o<65536?(t[e++]=200,t[e++]=o>>8,t[e++]=o&255):(t[e++]=201,t[e++]=o>>24,t[e++]=o>>16&255,t[e++]=o>>8&255,t[e++]=o&255)}return t[e++]=r,t.set(n,e),e+=o,e}function fC(n,t){let e,r=t.length*6,o=n.length-r;for(t.sort((i,a)=>i.offset>a.offset?1:-1);e=t.pop();){let i=e.offset,a=e.id;n.copyWithin(i+r,i,o),r-=6;let s=i+r;n[s++]=214,n[s++]=105,n[s++]=a>>24,n[s++]=a>>16&255,n[s++]=a>>8&255,n[s++]=a&255,o=i}return n}function yn(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)");dp.unshift(n.Class),Lc.unshift(n)}$g(n)}var Zg=new ti({useRecords:!1}),hC=Zg.pack,mC=Zg.pack;var{NEVER:yC,ALWAYS:gC,DECIMAL_ROUND:xC,DECIMAL_FIT:bC}=Ec,Jg=512,vC=1024;var e0=new ti({structuredClone:!0});yn({Class:xe.prototype.constructor,type:1,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,xe.prototype),n}});yn({Class:Se.prototype.constructor,type:2,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,Se.prototype),n}});yn({Class:Je.prototype.constructor,type:3,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,Je.prototype),n}});yn({Class:Us.prototype.constructor,type:4,write(n){return n.id},read(n){return new Us(n)}});yn({Class:Hs.prototype.constructor,type:5,write(n){return n.data},read(n){return new Hs(n)}});yn({Class:et.prototype.constructor,type:6,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,et.prototype),n}});function SC(n){var t=0;if(n.length===0)return t;for(let e=0;e<n.length;e++){let r=n[e];t=(t<<5)-t+r,t=t&t}return t}function pp(n){if(oa(n))return n;if(Array.isArray(n))return n.map(pp);if(typeof n=="object"&&n!==null){let t={};for(let e of Object.keys(n).sort())t[e]=pp(n[e]);return Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t}else return n}var Vc;(r=>{function n(o){return e0.pack(o)}r.serialize=n;function t(o){return e0.unpack(o)}r.deserialize=t;function e(o){return SC(n(pp(o))).toString()}r.checksum=e})(Vc||(Vc={}));var bn="personal camera",vn="a218fcc3-276b-49b9-b485-49037fd14f5f",i0=2960946,St=5526619;var ua;(f=>{function n(h,m){return h[0]===m[0]&&h[1]===m[1]}f.isEqual=n;function t(h,m,y){return[h[0]+(m[0]-h[0])*y,h[1]+(m[1]-h[1])*y]}f.lerp=t;function e(h,m){return[h[0]+m[0],h[1]+m[1]]}f.add=e;function r(h,m){return[h[0]-m[0],h[1]-m[1]]}f.sub=r;function o(h,m){return[h[0]*m[0],h[1]*m[1]]}f.multiply=o;function i(h,m){return[h[0]/m[0],h[1]/m[1]]}f.divide=i;function a(h,m){return Math.pow(m[0]-h[0],2)+Math.pow(m[1]-h[1],2)}f.distanceSquared=a;function s(h,m){return Math.sqrt(a(h,m))}f.distance=s;function l(h,m){return h[0]*m[0]+h[1]*m[1]}f.dot=l;function u(h,m){return[h[0]*m,h[1]*m]}f.scalarMultiply=u;function c(h,m,y){let g=f.sub(m,h),b=f.sub(y,h),w=f.dot(g,b)/f.dot(g,g),A=f.scalarMultiply(g,w);return f.add(h,A)}f.projectionOnto=c;function d(h,m,y){return s(h,c(h,m,y))}f.projectionOntoDistance=d;function p(h,m){return[(h[0]+m[0])*.5,(h[1]+m[1])*.5]}f.center=p})(ua||(ua={}));var gn;(s=>{function n(l,u){return l[0]===u[0]&&l[1]===u[1]&&l[2]===u[2]}s.isEqual=n;function t(l,u){return[l[0]+u[0],l[1]+u[1],l[2]+u[2]]}s.add=t;function e(l,u){return[l[0]-u[0],l[1]-u[1],l[2]-u[2]]}s.sub=e;function r(l,u){return[l[0]/u[0],l[1]/u[1],l[2]/u[2]]}s.div=r;function o(l,u){return[l[0]*u[0],l[1]*u[1],l[2]*u[2]]}s.mul=o;function i(l,u){return Math.hypot(l[0]-u[0],l[1]-u[1],l[2]-u[2])}s.dist=i;function a(l,u,c){return[l[0]+(u[0]-l[0])*c,l[1]+(u[1]-l[1])*c,l[2]+(u[2]-l[2])*c]}s.lerp=a})(gn||(gn={}));var t0;(e=>{function n(r,o){return r[0]===o[0]&&r[1]===o[1]&&r[2]===o[2]&&r[3]===o[3]}e.isEqual=n;function t(r,o,i){return[r[0]+(o[0]-r[0])*i,r[1]+(o[1]-r[1])*i,r[2]+(o[2]-r[2])*i,r[3]+(o[3]-r[3])*i]}e.lerp=t})(t0||(t0={}));var xn;(o=>{o.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function t(i,a){for(let s=0;s<16;s++)if(i[s]!==a[s])return!1;return!0}o.isEqual=t;function e(i){return i??o.identity}o.simplify=e;function r(i,a){let s=a.slice(0);for(var l=0,u=a.length;l<u;l+=3){let c=i[3]*a[l]+i[7]*a[l+1]+i[11]*a[l+2]+i[15];s[l]=(i[0]*a[l]+i[4]*a[l+1]+i[8]*a[l+2]+i[12])/c,s[l+1]=(i[1]*a[l]+i[5]*a[l+1]+i[9]*a[l+2]+i[13])/c,s[l+2]=(i[2]*a[l]+i[6]*a[l+1]+i[10]*a[l+2]+i[14])/c}return s}o.applyMatrix4=r})(xn||(xn={}));var Mt;(d=>{function n(p){return typeof p=="object"&&typeof p.r=="number"&&typeof p.g=="number"&&typeof p.b=="number"}d.isRGB=n,d.white={r:1,g:1,b:1},d.red={r:1,g:0,b:0},d.black={r:0,g:0,b:0};function o(p){return{r:Math.round(p.r*255),g:Math.round(p.g*255),b:Math.round(p.b*255),a:1}}d.toRgb255a1=o;function i(p){return{r:p.r,g:p.g,b:p.b}}d.clone=i;function a(p){return p=Math.floor(p),{r:(p>>16&255)/255,g:(p>>8&255)/255,b:(p&255)/255}}d.fromHex=a;function s(p){return Math.round(p.r*255)*65536+Math.round(p.g*255)*256+Math.round(p.b*255)}d.toHex=s;function l(p,f){return p.r===f.r&&p.g===f.g&&p.b===f.b}d.equals=l;function u(p,f){return p.r.toFixed(2)===f.r.toFixed(2)&&p.g.toFixed(2)===f.g.toFixed(2)&&p.b.toFixed(2)===f.b.toFixed(2)}d.equalsFixed=u;function c(p,f,h){return{r:p.r+(f.r-p.r)*h,g:p.g+(f.g-p.g)*h,b:p.b+(f.b-p.b)*h}}d.lerp=c})(Mt||(Mt={}));var Ie;(u=>{u.white={...Mt.white,a:1},u.transparent={...Mt.white,a:0};function e(c){return{r:c[0],g:c[1],b:c[2],a:c[3]}}u.from0to1=e;function r(c,d){return{...Mt.fromHex(c),a:d}}u.fromHexAndA=r;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}}u.toRgb255a1=o;function i(c,d){return Mt.equals(c,d)&&c.a===d.a}u.equals=i;function a(c,d){return Mt.equalsFixed(c,d)&&c.a.toFixed(2)===d.a.toFixed(2)}u.equalsFixed=a;function s(c,d,p){return{r:c.r+(d.r-c.r)*p,g:c.g+(d.g-c.g)*p,b:c.b+(d.b-c.b)*p,a:c.a+(d.a-c.a)*p}}u.lerp=s;function l({r:c,g:d,b:p,a:f}=u.white){return`rgba(${c*255}, ${d*255}, ${p*255}, ${f})`}u.toStyle=l})(Ie||(Ie={}));var zc;(t=>t.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(zc||(zc={}));var r0;(t=>t.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(r0||(r0={}));var o0;(t=>t.defaultData={control1:[.5,0],control2:[.5,1]})(o0||(o0={}));var n0;(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]))(n0||(n0={}));function fp(n){return typeof n=="string"&&n.length===36?/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(n):!1}var Ur;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(r){return e.all.includes(r)}e.is=t})(Ur||(Ur={}));var Sn;(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 r(i){return i.type==="PerspectiveCamera"?i.perspective.zoom:i.orthographic.zoom}o.getZoom=r})(Sn||(Sn={}));var fo;(e=>{function n(r,o=.1){return{disabled:!1,type:"linear",hideBase:!1,count:3,radial:{radius:Math.max(r[0],r[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:[r[0]+r[0]*o,0,0]},grid:{count:[2,2,2],size:r.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 t(r,o){let i={...r};if(wC.forEach(a=>{Object.assign(i,{[a]:o[a]??r[a]})}),i.radial={...r.radial},o.radial){let a=r.radial,s=o.radial;AC.forEach(l=>{Object.assign(i.radial,{[l]:s[l]??a[l]})})}if(i.linear={...r.linear},o.linear){let a=r.linear,s=o.linear;_C.forEach(l=>{Object.assign(i.linear,{[l]:s[l]??a[l]})})}if(i.grid={...r.grid},o.grid){let a=r.grid,s=o.grid;PC.forEach(l=>{Object.assign(i.grid,{[l]:s[l]??a[l]})})}if(i.toObject={...r.toObject},o.toObject){let a=r.toObject,s=o.toObject;OC.forEach(l=>{Object.assign(i.toObject,{[l]:s[l]??a[l]})})}if(i.randomnessObject={...r.randomnessObject},o.randomnessObject){let a=r.randomnessObject,s=o.randomnessObject;CC.forEach(l=>{Object.assign(i.randomnessObject,{[l]:s[l]??a[l]})})}return i}e.merge=t})(fo||(fo={}));var Gc;(r=>{r.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let t=["radial","linear","grid","toObject","randomnessObject"];function e(o,i){let a=[];o.count!==void 0&&a.push({type:0,path:i,props:{count:o.count}});for(let s of t){let l=o[s];l&&Object.keys(l).length>0&&a.push({type:0,path:[...i,s],props:l})}return a}r.toOps=e})(Gc||(Gc={}));var wC=["count"],AC=["radius","start","end","position","scale","rotation"],_C=["position","scale","rotation"],PC=["count","size"],OC=["count","position","scale","rotation"],CC=["strength","scale","rotation","position","movement","seed","freqScale"];var Fc;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(r){return e.all.includes(r)}e.is=t})(Fc||(Fc={}));var kc;(e=>{function n(r){return t(r)}e.defaultData=n;function t(r){if(r==="PointLight")return{type:r,color:Ie.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(r==="SpotLight")return{type:r,color:Ie.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(r==="DirectionalLight")return{type:r,color:Ie.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(kc||(kc={}));var da;(r=>(r.defaultShapeData={type:"PlaneEmitterShape",size:[100,100,100]},r.defaultCollisionData={colliderEntityId:null,collisionBounce:.75},r.defaultData={renderMaterial:{type:"particleMaterial",color:{r:1,g:.2,b:.545,a:1},color2:{r:.945,g:.714,b:.184,a:1},coloring:"gradient",ease:"linearFadeOut",easeSize:"linearFadeOut",transparent:!0,size:[40,40],texture:"pt_default_particle",spriteRotation:[0,0]},birthRatePerSec:50,gravity:1,noiseStrength:0,noiseScale:0,noiseSeed:1,noiseType:"curl",randomRotation:0,randomScale:.2,randomMass:.5,rootObjectType:"instancedMesh",life:1,direction:[0,0,0],directionMode:"axis",speed:10,shape:r.defaultShapeData,autoPlay:!0,emitTimeDelay:0,emitTimeCycle:"infinity",emitTimeLoopDelayStart:"end",emitTimeDuration:1,...r.defaultCollisionData}))(da||(da={}));var wn;(t=>t.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]})(wn||(wn={}));var hp;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(r,o){return r.castShadow===o.castShadow&&r.receiveShadow===o.receiveShadow}e.equals=t})(hp||(hp={}));var mp;(e=>{e.defaultData={flatShading:!1,wireframe:!1,side:0};function t(r,o){return r.flatShading===o.flatShading&&r.side===o.side&&r.wireframe===o.wireframe}e.equals=t})(mp||(mp={}));var jc;(t=>t.defaultData={...mp.defaultData,...hp.defaultData})(jc||(jc={}));var a0;(t=>{function n(e,r){let o=[];if("material"in e){let i=typeof e.material=="string"?r.materials[e.material]??r.lib.materials[e.material]?.asset:e.material;i&&o.push(i)}else if("materials"in e)for(let i of e.materials){let a=typeof i=="string"?r.materials[i]??r.lib.materials[i]?.asset:i;a&&o.push(a)}return o}t.getMaterialData=n})(a0||(a0={}));var pa;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(pa||(pa={}));var s0;(t=>{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==="particle"||e==="transmission"||e==="matcap"||e==="displace"||e==="pattern"||e==="light"}t.is=n})(s0||(s0={}));function c0(n){return n.type!=="displace"}var l0;(t=>{function n(e){return e==="phong"||e==="toon"||e==="lambert"||e==="physical"}t.is=n})(l0||(l0={}));var u0=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],d0=["wrapping","image","video","name","minFilter"],Pt;(o=>{function n(i,a){let{texture:s,...l}=a;if(Object.assign(i,l),s){let u=i.texture;u&&Object.assign(u,s)}}o.patch=n;function t(i,a){return i==="light"&&a?e(a):r(i)}o.defaultData=t;function e(i){let a={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(i){case"phong":return{...a,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...a,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...a,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...a,category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0,occlusion:!0}}}function r(i){let a={alpha:1,mode:0,isMask:!1,visible:!0};switch(i){case"texture":return{...a,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],minFilter:1008},crop:!1};case"video":return{...a,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:pa.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0],minFilter:1008},crop:!1};case"color":return{...a,type:"color",color:Mt.fromHex(St)};case"depth":return{...a,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{...a,type:"normal",cnormal:[1,1,1]};case"gradient":return{...a,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{...a,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...Mt.fromHex(6710886),a:1},colorB:{...Mt.fromHex(6710886),a:1},colorC:{...Mt.fromHex(16777215),a:1},colorD:{...Mt.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{...a,type:"fresnel",color:Ie.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{...a,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...a,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:Ie.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...a,type:"outline",outlineColor:Ie.fromHexAndA(0,1),contourColor:Ie.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{...a,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0],minFilter:1008}};case"transmission":return{...a,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{...a,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...Mt.fromHex(0),a:1},colorB:{...Mt.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}}}})(Pt||(Pt={}));var Wt;(u=>{function n(c){return!c.layers.some(p=>p.data.type==="texture"&&p.data.projection!==0||p.data.type==="depth"&&!p.data.isWorldSpace||p.data.type==="noise"||p.data.type==="displace")}u.isMergable=n;function t(c){let d="";return c.layers.forEach(p=>{Object.entries(p.data).forEach(([f,h])=>{d+=`${f}${h}`,Array.isArray(h)?h.forEach(m=>d+=`${m}`):typeof h=="object"?Object.values(h).forEach(m=>{typeof m=="number"?d+=`${m.toFixed(4)}`:d+=`${m}`}):d+=`${h}`})}),d}u.getHash=t;function e(){return{layers:new Se}}u.defaultEmptyData=e;function r(c="layer1",d="layer2"){return i("phong",c,d)}u.defaultData=r;function o(c,d){return{...c,name:d}}u.withName=o;function i(c,d="layer1",p="layer2"){let f=new Se;return f.push({fi:0,data:Pt.defaultData("light",c),id:d}),f.push({fi:1,data:Pt.defaultData("color"),id:p}),{layers:f}}u.defaultTwoLayerData=i;function a(c){let d=Pt.defaultData("texture");c&&Object.assign(d.texture,{image:c});let p=new Se;return p.push({fi:0,data:d,id:"layer1"}),p.push({fi:1,data:{...Pt.defaultData("transmission"),alpha:1},id:"layer2"}),p.push({fi:2,data:{...Pt.defaultData("light","lambert"),alpha:0},id:"layer3"}),{layers:p}}u.defaultUIObjectMaterial=a;function s(c,d="phong",p="layer1",f="layer2"){let h=Pt.defaultData("texture");Object.assign(h.texture,{image:c});let m=new Se;return m.push({fi:0,data:h,id:p}),m.push({fi:1,data:Pt.defaultData("light",d),id:f}),{layers:m}}u.defaultTwoLayerTextureData=s;function l(c,d="phong",p="layer1",f="layer2"){let h=Pt.defaultData("video");Object.assign(h.texture,{video:c});let m=new Se;return m.push({fi:0,data:h,id:p}),m.push({fi:1,data:Pt.defaultData("light",d),id:f}),{layers:m}}u.defaultTwoLayerVideoTextureData=l})(Wt||(Wt={}));var fa;(t=>{function n(){return{points:new Se,roundness:0,shapeHoles:[],isClosed:!1}}t.defaultData=n})(fa||(fa={}));var ha;(t=>{function n(){return{points:new Se,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}t.defaultData=n})(ha||(ha={}));var yp={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0};var Uc;(t=>{function n(e,r){let o={...e};return TC.forEach(i=>{Object.assign(o,{[i]:r[i]??e[i]})}),o}t.merge=n})(Uc||(Uc={}));var Hc={shape:yp,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},TC=["depth","offset","angle","twist","startScale","endScale"];var $s;(e=>{function n(r){return r==="PolygonGeometry"||r==="RectangleGeometry"||r==="StarGeometry"||r==="TriangleGeometry"||r==="EllipseGeometry"||r==="UIGeometry"}e.is2DParametricMesh=n;function t(r){return r==="PolygonGeometry"||r==="PolygonGeometry"||r==="RectangleGeometry"||r==="StarGeometry"||r==="TriangleGeometry"||r==="EllipseGeometry"||r==="PathGeometry"||r==="VectorGeometry"||r==="ConeGeometry"||r==="CubeGeometry"||r==="CylinderGeometry"||r==="DodecahedronGeometry"||r==="HelixGeometry"||r==="IcosahedronGeometry"||r==="LatheGeometry"||r==="PyramidGeometry"||r==="SphereGeometry"||r==="PlaneGeometry"||r==="BackdropGeometry"||r==="TorusGeometry"||r==="TorusKnotGeometry"||r==="BooleanGeometry"||r==="TextGeometry"}e.isParametricMesh=t})($s||($s={}));var qc;(t=>{function n(e,r){let o={...e};return Object.assign(o,r),o.type==="PathGeometry"&&"extrusion"in r&&r.extrusion&&(o.extrusion={...e.extrusion},Object.assign(o.extrusion,Uc.merge(o.extrusion,r.extrusion))),o}t.merge=n})(qc||(qc={}));var An;(t=>{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==="UIGeometry")return{type:e,frame:"",cornerRadius:[0,0,0,0],cornerType:0,width:1,height:1};if(e==="PathGeometry")return{type:e,width:1,height:1,depth:1,path:ha.defaultData(),extrusion:Hc};if(e==="VectorGeometry")return{width:1,height:1,type:e,subdivisions:12,shape:fa.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:{textValue:""},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:180};throw new Error("not implemented")}t.defaultData=n})(An||(An={}));var Wc;(t=>t.defaultData={enabled:!1,useBackgroundColor:!1,color:Mt.white,near:.1,far:2e3})(Wc||(Wc={}));var $c;(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}}})($c||($c={}));var gp;(t=>t.defaultData={softShadowQuality:"low"})(gp||(gp={}));var xp;(t=>t.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(xp||(xp={}));var bp;(t=>t.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(bp||(bp={}));var Ys;(t=>t.defaultData={usePhysics:!1,gravity:-10})(Ys||(Ys={}));var vp;(t=>t.defaultData={playCamera:bn,gameControlObject:null})(vp||(vp={}));var Yc;(t=>t.defaultData={backgroundColor:Ie.fromHexAndA(i0,1),postprocessing:$c.defaultData,fog:Wc.defaultData,globalPhysics:Ys.defaultData,ambient:xp.defaultData,ao:bp.defaultData,shadow:gp.defaultData,publish:vp.defaultData})(Yc||(Yc={}));var Xc;(t=>t.defaultData={colliderType:"box",size:[100,100,100],colliderHelperVisible:!0,forceType:"collider",forceRange:"global",forceIntensity:.5,forceDambing:.95})(Xc||(Xc={}));var p0;(e=>{function n(r){return r==="Component"||r==="Instance"}e.isComponentRelated=n;function t(r){return r==="Empty"||r==="Instance"}e.isEmptyOrComponent=t})(p0||(p0={}));var ma;(o=>{o.identity={...zc.identity,hiddenMatrix:xn.identity};function t(i){return{position:i.position,rotation:i.rotation,scale:i.scale,hiddenMatrix:i.hiddenMatrix}}o.fromObject=t;function e(i,a){return{position:a?.position||i.position,rotation:a?.rotation||i.rotation,scale:a?.scale||i.scale,hiddenMatrix:a?.hiddenMatrix||i.hiddenMatrix}}o.merge=e;function r(i,a){return Yl({position:gn.isEqual(i.position,a.position)?void 0:a.position,rotation:gn.isEqual(i.rotation,a.rotation)?void 0:a.rotation,scale:gn.isEqual(i.scale,a.scale)?null:a.scale,hiddenMatrix:xn.isEqual(i.hiddenMatrix,a.hiddenMatrix)?void 0:a.hiddenMatrix})}o.diff=r})(ma||(ma={}));var It;(t=>t.defaultData={states:new Se,events:new Se,visible:!0,raycastLock:!1,physics:wn.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...ma.identity,cloner:null})(It||(It={}));var Qc;(t=>t.defaultData={type:"Empty",...It.defaultData})(Qc||(Qc={}));var f0;(t=>t.defaultData={type:"ParticleCollider",...Xc.defaultData,...It.defaultData})(f0||(f0={}));var h0;(t=>t.defaultData={type:"Component",...It.defaultData})(h0||(h0={}));var m0;(t=>t.defaultData={type:"Particle",...It.defaultData,...da.defaultData})(m0||(m0={}));var ri;(t=>t.defaultData={type:"Mesh",...It.defaultData,...jc.defaultData})(ri||(ri={}));var oi;(t=>t.defaultData={...It.defaultData,...ma.identity,position:[0,0,Sn.DefaultTargetOffset],...Sn.defaultData})(oi||(oi={}));var Kc;(e=>{function n(r){return{...It.defaultData,...kc.defaultData(r)}}e.defaultData=n,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(Kc||(Kc={}));var ya;(e=>{function n(r,o,i=0){for(;i<o.length;){let a=r?r[o[i]]:void 0;if(o.length===i+1)return a;if(a)r=a.descendants,i+=1;else return}}e.resolveWithDes=n;function t(r,o,i=0){let a=n(r,o,i);if(a){let s=Object.keys(a);if(s.length===1&&s[0]==="descendants")return}return a}e.resolve=t})(ya||(ya={}));var ho;(i=>{i.rootOverrideProps=["physics","events"],i.compositeNonOptionalOverrideProps=["geometry"],i.compositeEntireOverrideOverrideProps=["material"];function r(a,s){return{...It.defaultData,...s,component:a,overrides:new et,physics:void 0,events:void 0,type:"Instance"}}i.ofComponent=r;function o(a){let s=ma.fromObject(a.data);return r(a.id,s)}i.fromComponentData=o})(ho||(ho={}));var Go;(e=>{e.defaultData={type:"Page",...It.defaultData,physics:{...wn.defaultData,fusedBody:!1},...Yc.defaultData,camera:oi.defaultData};function t(r){return r.uiScene!==void 0}e.isUIPage=t})(Go||(Go={}));var Zc;(i=>(i.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:xn.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:wn.defaultData,states:new Se,events:new Se,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...Sn.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,...ri.defaultData,geometry:An.defaultData("RectangleGeometry"),material:Wt.defaultTwoLayerData("phong","layer1","layer2")},i.defaultBooleanObject={name:"Boolean",...It.defaultData,...ri.defaultData,geometry:An.defaultData("BooleanGeometry"),material:Wt.defaultTwoLayerData("phong","layer1","layer2")},i.defaultTextObject={name:"Text",...It.defaultData,...ri.defaultData,geometry:An.defaultData("TextGeometry"),material:Wt.defaultTwoLayerData("phong","layer1","layer2")}))(Zc||(Zc={}));var ni;(o=>{function n(i,a){let s={name:a};return i.type==="Mesh"?(s.geometry={},"material"in i&&(s.material={layers:new et}),"materials"in i&&(s.materials=i.materials.map(l=>({layers:new et})))):Ur.is(i.type)&&(s.perspective={},s.orthographic={}),s}o.newEmpty=n;function t(i,a){if(a===void 0)return i;let s={...i};return"material"in s&&"material"in a&&a.material&&(s.material=fn(s.material,l=>{if(typeof l!="string")for(let[u,c]of Object.entries(a.material.layers)){let d=l.layers.data(u);d&&Pt.patch(d,c)}}).data),s.materials&&a.materials&&(s.materials=fn(s.materials,l=>{for(let u=0;u<s.materials.length;u++){let c=a.materials[u];if(typeof c!="string")for(let[d,p]of Object.entries(c.layers)){let f=l[u]?.layers?.data(d);f&&Pt.patch(f,p)}}}).data),s}function e(i,a){let s,l=[],u={orthographic:0,perspective:0,geometry:0};function c(d,p){for(let[f,h]of Object.entries(p.layers)){let{texture:m,...y}=h;if(m!==void 0&&Object.keys(m).length>0){let g={path:[...d,"layers",f,"texture"],props:m,type:0};l.push(g)}if(Object.keys(y).length>0){let g={path:[...d,"layers",f],props:y,type:0};l.push(g)}}}for(let[d,p]of Object.entries(a))if(d!=="name")if(d==="cloner")l.push(...Gc.toOps(p,["cloner"]));else if(d==="pathSnapping")l.push({path:[d],props:{slide:p.slide,offset:p.offset},type:0});else if(d==="material")c(["material"],p);else if(d==="materials")for(let[f,h]of Object.entries(p))c(["materials",f],h);else if(u[d]===0){if(d==="geometry"&&p.extrusion!==void 0){let f={path:[d,"extrusion"],props:p.extrusion,type:0};l.push(f),p={...p},delete p.extrusion}if(Object.keys(p).length>0){let f={path:[d],props:p,type:0};l.push(f)}}else s===void 0&&(s={path:[],props:{},type:0},l.push(s)),s.props[d]=p;return l}o.toOps=e;function r(i,a){if(a===void 0)return i;let s={...i};if(Object.assign(s,ma.merge(s,a)),Object.assign(s,{pathSnapping:Object.assign({},s.pathSnapping,{slide:a.pathSnapping?.slide??s.pathSnapping?.slide??0,offset:a.pathSnapping?.offset??s.pathSnapping?.offset??0})}),Ur.is(i.type)){s.orthographic={...s.orthographic},s.perspective={...s.perspective};let l=a;l.orthographic?.zoom!==void 0&&(s.orthographic.zoom=l.orthographic.zoom),l.perspective?.zoom!==void 0&&(s.perspective.zoom=l.perspective.zoom),l.isUpVectorFlipped!==void 0&&(s.isUpVectorFlipped=l.isUpVectorFlipped),l.targetOffset!==void 0&&(s.targetOffset=l.targetOffset)}else if(i.type==="Mesh")"geometry"in a&&Object.assign(s,{geometry:qc.merge(s.geometry,a.geometry)}),(a.material||a.materials)&&(s=t(s,a)),s.cloner&&"cloner"in a&&Object.assign(s,{cloner:fo.merge(s.cloner,a.cloner)});else if(i.type==="Empty")s.cloner&&"cloner"in a&&Object.assign(s,{cloner:fo.merge(s.cloner,a.cloner)});else if(Fc.is(i.type)){let l=a;l.intensity!==void 0&&(s.intensity=l.intensity),l.color!==void 0&&(typeof l.color=="string"?s.color=l.color:s.color=Mt.clone(l.color))}return s}o.patch=r})(ni||(ni={}));var ga;(t=>t.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,hoverRotateDamping:.125,isTouchZoom:!0,orbitTouches:2,panTouches:3,resetHoverEffectOnPointerLeave:!0})(ga||(ga={}));var Hr;(t=>t.defaultData={orbitControls:ga.defaultData,playPage:vn,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((e,r)=>{let o=0,i=0;return r<5?i=-30:r<10&&(i=30),r===0||r===10||r===5?o=30:(r===4||r===11||r===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 Sp;(t=>t.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(Sp||(Sp={}));var wp;(t=>t.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(wp||(wp={}));var Fo;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...Sp.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:wp.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(Fo||(Fo={}));var y0;(e=>{function n(r){return r.find(o=>o.data.type==="Page"&&o.data.globalPhysics.usePhysics)!==void 0}e.physicsEnabled=n;function t(r,o,i){r.scene.objects.traverseFrom(o,(a,s)=>{if(s.type==="Instance"){let l=xa.getComponentData(r,s.component)?.data;l&&i(a,s,l.events)}else i(a,s,s.events)})}e.traverseModuleInstances=t})(y0||(y0={}));var ko;(l=>{l.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222";function t(u={withLight:!0,withSquare:!0}){let c=[],d=Zc.defaultMeshObject;u.withLight===!0&&c.push({fi:-1,data:Kc.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]}),u.withSquare===!0&&c.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:d,children:[]});let p=new Je;return p.push({fi:1,id:vn,data:{...Go.defaultData,name:"Scene 1"},children:c}),p}l.defaultData={objects:t(),publish:Hr.defaultData,styles:Fo.defaultData()},l.emptyDataWithoutPage=function(){return{objects:new Je,publish:Hr.defaultData,styles:Fo.defaultData()}},l.emptyDataWithPage=function(u){return{objects:t(u),publish:Hr.defaultData,styles:Fo.defaultData()}},l.emptyData=function(){return{objects:new Je,publish:{...Hr.defaultData},styles:Fo.defaultData()}};function a(u){return{...l.defaultData,objects:rr(u,Je.prototype)}}l.withObjs=a;function s(u,c){return a([{id:u,data:c,children:[],fi:0}])}l.withObj=s})(ko||(ko={}));var ba;(t=>t.defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}})(ba||(ba={}));var va;(t=>t.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(va||(va={}));var Jc;(i=>{function n(a){return a.textValue!==void 0}i.isTextValue=n;function t(a){return typeof a=="number"}i.isNumber=t;function e(a){return typeof a=="boolean"}i.isBoolean=e;function r(a){return n(a)?"string":e(a)?"boolean":"number"}i.typeOfVariable=r;function o(a){return i.isTextValue(a)?Array.isArray(a.textValue)?a.textValue.map(s=>s.toString().padStart(a.padding??2,"0")).join(a.deliminator??":")+(a.suffix!==void 0?" "+a.suffix:""):a.textValue.toString():i.isBoolean(a)?a?"True":"False":i.isNumber(a)?parseFloat(a.toFixed(3)).toString():a.toString()}i.getDisplayedValue=o})(Jc||(Jc={}));var Ap;(t=>t.all=["images","videos","colors","audios","particles","fonts","materials","variables"])(Ap||(Ap={}));var g0;(t=>t.all=[...Ap.all,"components"])(g0||(g0={}));var x0;(t=>{function n(){return{images:new xe,videos:new xe,colors:new xe,audios:new xe,particles:new xe,fonts:new xe,materials:new xe,components:new xe,variables:new xe}}t.defaultData=n})(x0||(x0={}));var jo;(t=>{function n(){return{images:new xe,videos:new xe,colors:new xe,audios:new xe,particles:new xe,fonts:new xe,materials:new xe,components:new xe,variables:new xe}}t.defaultData=n})(jo||(jo={}));var Nr;(i=>{function n(){let a={};return a["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},rr(a,xe.prototype)}i.defaultColors=n;function t(a){let s={};return a?.withAITexture&&(s["a1b10010-844c-a8a3-11ec-0242ac2011ec"]={...va.emptyImage,name:"AI generated image"}),rr(s,xe.prototype)}i.defaultImages=t;function e(){return{catelogs:new xe,materials:new xe,images:new xe,videos:new xe,colors:new xe,audios:new xe,particles:new xe,fonts:new xe,variables:new Se,lib:jo.defaultData()}}i.emptyData=e;function r(a){switch(a){case"number":return{value:0,name:"Number"};case"boolean":return{value:!1,name:"Boolean"};case"string":return{value:{textValue:"String value"},name:"String"};case"time":let s=[0,0,0];return{name:"Time",value:{textValue:s,deliminator:":",padding:2,suffix:"AM"},dynamicVariableType:"time",format:"HH:mm:ss",format12h24h:"12ampm",timeZone:null,hasEnd:!1,endValue:{textValue:s,deliminator:":",padding:2,suffix:"AM"},autoStart:!0,repeat:!1};case"counter":return{name:"Counter",value:0,dynamicVariableType:"counter",updateInterval:1e3,increment:1,autoStart:!0,hasEnd:!0,endValue:60,repeat:!0,randomStart:!1,range:[0,100],decimals:0};case"random":return{name:"Random",value:0,dynamicVariableType:"random",updateInterval:1e3,increment:1,autoStart:!0,isStatic:!1,hasEnd:!0,endValue:60,repeat:!0,min:0,max:100,decimals:0};default:console.error("Unknown variable type",a)}}i.defaultVariables=r;function o(a,s){if(s.format==="HH:mm:ss"){let l=Math.floor(a/3600),u=Math.floor((a-l*3600)/60),c=Math.round(a-l*3600-u*60);return{textValue:[l,u,c]}}else if(s.format==="mm:ss"){let l=Math.floor(a/60),u=Math.round(a-l*60);return{textValue:[l,u]}}else return s.format==="number"?a=Math.round(a):a=Math.round(a*1e3)/1e3,a}i.getFormattedTimerTime=o})(Nr||(Nr={}));import{MathUtils as ru}from"three";var eu;(t=>t.list=["idle","move","jump","run"])(eu||(eu={}));var tu;(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 Se,move:new Se,jump:new Se,run:new Se},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:Ie.fromHexAndA(3728051,1)}}))(tu||(tu={}));function b0(n){n.layers.forEach(t=>{if(t.type==="depth"&&t.colorA!==void 0){let e=t.colorA,r=t.colorB,o=[[e.r,e.g,e.b,e.a],[r.r,r.g,r.b,r.a]],i=[0,1];for(let s=2;s<10;s++)o.push(o[1]),i.push(1);let a={...jr(ut(t),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,t.near),far:Math.max(0,t.far),colors:o,steps:i,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(t,a)}else if(t.type==="depth"&&t.gradientType===1&&(t.near<0||t.far<0)){let e={...ut(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,e)}})}function Uo(n,t){Object.values(n.shared.materials).forEach(e=>t(e))}function Ho(n,t){n.scene.objects.traverse((e,r)=>{"materials"in r?r.materials.forEach((o,i)=>{o===void 0&&(r.materials[i]=Wt.defaultData(),o=r.materials[i]),typeof o!="string"&&t(o)}):"material"in r?typeof r.material!="string"&&(r.material===void 0&&(r.material=Wt.defaultData()),t(r.material)):r.type==="Mesh"&&(r.material===void 0&&(r.material=Wt.defaultData()),t(r.material)),"overrides"in r&&Object.values(r.overrides).forEach(o=>{o.material&&typeof o.material!="string"&&Object.getPrototypeOf(o.material)!==et.prototype&&t(o.material)})})}function MC(n){Object.assign(n.scene.publish,{orbitControls:{...ga.defaultData,...ut(n.scene.publish.orbitControls)}})}function IC(n){Object.assign(n.scene.publish.settings,{video:{...Hr.defaultData.settings.video,...ut(n.scene.publish.settings.video)}})}function NC(n){function t(e){if(e.layers){for(let r of Object.values(e.layers))if(r){for(let[o,i]of Object.entries(r))if((u0.includes(o)||typeof i=="boolean")&&delete r[o],o==="texture")for(let[a,s]of Object.entries(i))(d0.includes(a)||typeof s=="boolean")&&delete i[a]}}}n.scene.objects.traverse((e,r)=>{r.states.forEach(o=>{let i=o;i.material?t(i.material):i.materials&&i.materials.forEach(a=>{t(a)})})})}function DC(n){n.scene.publish.withBackground=!0}function EC(n){n.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function BC(n){n.scene.objects.traverse((t,e)=>{let r=e.cloner;r&&(r.radial.scale=r.radial.scale.map(o=>o+1),r.linear.scale=r.linear.scale.map(o=>o+1))})}function LC(n){n.scene.objects.traverse((t,e)=>{let r=e.geometry;r&&(r.type==="DodecahedronGeometry"||r.type==="IcosahedronGeometry")&&(r.detail=Math.round(r.detail))})}function RC(n){n.scene.objects.traverse((t,e)=>{let r=n.scene.objects.unproxy().parent(t);if(r){let o=ut(n.scene.objects.data(r));o&&o.type==="Mesh"&&o.geometry.type==="BooleanGeometry"&&e.type==="Mesh"&&(e.visible=ut(e).booleanExclude!==!0)}})}function VC(n){n.scene.objects.traverse((t,e)=>{if(e.type==="Mesh"){let r=e;e.geometry.type==="NonParametricGeometry"?r.material!==void 0&&delete r.material:r.materials!==void 0&&delete r.materials}})}function zC(n){function t(r){Object.setPrototypeOf(r,et.prototype),r.texture&&Object.setPrototypeOf(r.texture,et.prototype)}function e(r){Object.setPrototypeOf(r,et.prototype);for(let o in r)t(r[o])}n.scene.objects.traverse((r,o)=>{o.states.forEach(i=>{let a=i;if(a.material){let s=ut(a.material).layers;e(s),a.material.layers=s}if(a.materials)for(let s=0;s<a.materials.length;s++){let l=a.materials[s],u=ut(l).layers;e(u),l.layers=u}})})}function v0(n){n.layers===void 0&&Object.assign(n,Wt.defaultTwoLayerData("lambert"))}function _p(n){!n.layers||n.layers.forEach(t=>{if(t.type==="depth"&&t.colors.length===10){let e=[...t.colors];e.push(t.colors[9]);let r=[...t.steps];r.push(t.steps[9]);let o={...ut(t),colors:e,steps:r};Object.assign(t,o)}})}function GC(n){n.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&(e.geometry.type==="BooleanGeometry"||e.geometry.type==="SubdivGeometry")&&(e.geometry.phongAngle=35)})}function S0(n){n.scene.objects.traverse((t,e)=>{"materials"in e?e.materials.forEach(r=>{typeof r!="string"&&_p(r)}):"material"in e&&typeof e.material!="string"&&_p(e.material)}),Object.values(n.shared.materials).forEach(t=>_p(t))}function FC(n){n.scene.environment.ambientLight.softShadows=!1,n.scene.environment.ambientLight.softShadowQuality="low",n.scene.objects.traverse((t,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 kC(n){n.shared.audios=rr({},xe.prototype)}function jC(n){n.shared.videos=rr({},xe.prototype)}function UC(n){let t=n.shared.materials;Object.entries(t).forEach(([e,r])=>{if(!r.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(t,{[e]:o})}})}function HC(n){Object.entries(ut(n.shared.images)).filter(r=>r[1].asset===!1).map(r=>r[0]).forEach(r=>{delete n.shared.images[r]}),Object.entries(ut(n.shared.audios)).filter(r=>r[1].asset===!1).map(r=>r[0]).forEach(r=>{delete n.shared.audios[r]})}function qC(n){n.scene.publish.settings.web.preload=!1}function w0(n){n.layers&&n.layers.forEach(t=>{t.type==="depth"&&t.num!==void 0&&(t.colors=t.colors.slice(0,t.num),t.steps=t.steps.slice(0,t.num),delete t.num)})}function A0(n){n.layers&&n.layers.forEach(t=>{c0(t)&&t.isMask===void 0&&(t.isMask=!1),(t.type==="texture"||t.type==="video")&&t.blending===void 0&&(t.blending=0),(t.type==="noise"||t.type==="displace"&&t.displacementType==="noise")&&(t.voronoiStyle===void 0&&(t.voronoiStyle=0),t.highCut===void 0&&(t.highCut=1),t.lowCut===void 0&&(t.lowCut=0),t.smoothness===void 0&&(t.smoothness=.3),t.seed===void 0&&(t.seed=0),t.quality===void 0&&(t.quality=1))})}function WC(n){n.shared.fonts=rr({},xe.prototype)}function $C(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 YC(n){let t=[];n.scene.objects.traverse((e,r)=>{let o=r;if(o.type==="TextFrame"){let i=Wt.defaultTwoLayerData("phong"),a=typeof o.color=="string"?n.shared.colors[o.color]:o.color;i.layers[1].data.color={r:a.r,g:a.g,b:a.b},i.layers[1].data.alpha=o.alpha;let s=$C(o.font);n.shared.fonts[s]===void 0&&(n.shared.fonts[s]={name:s});let l={name:o.name,...It.defaultData,...ri.defaultData,flatShading:!1,wireframe:!1,geometry:{...An.defaultData("TextGeometry"),width:o.width,height:o.height,font:s,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},u=ut(n.scene.objects).parent(e);n.scene.objects.insertAfter(u??null,e,[{id:e+"new",data:l,children:[]}]),t.push(e)}}),t.forEach(e=>{n.scene.objects.delete(e)})}function XC(n){let t={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,r)=>{r.events.forEach(o=>{if(!!t[Number(o.type)])if(Object.assign(o,{type:t[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 Se,move:new Se,jump:new Se}});else{let i=new Se;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:ru.generateUUID(),data:{type:"Link",url:o.url,delay:0}}),"targets"in o&&(o.targets.forEach((a,s,l)=>{let u={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},c={easing:a.easing,duration:a.duration};a.easing===6?Object.assign(c,jr(a,"mass","stiffness","damping","velocity")):a.easing===5&&Object.assign(c,{control1:{...a.control1},control2:{...a.control2}});let d={repeat:a.repeat?-1:0,delay:a.delay,delayDirection:a.delayDirection,direction:a.cycle&&a.rewind?"pingpong-rewind":a.cycle?"pingpong":"normal"},p={state:a.state,...d,...c},f={allowSlerp:!0,type:"Transition",object:a.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new Se({fi:0,id:ru.generateUUID(),data:u},{fi:1,id:ru.generateUUID(),data:p})};i.push({fi:l,id:s,data:f})}),delete o.targets)}})})}function QC(n){n.scene.objects.traverse((t,e)=>{function r(o,i){let a=new Se,s=[];if(e.events.forEach((l,u,c)=>{if(l.type==="Audio"&&l.trigger===i){let d;s.push(u),l.interaction==="play"?d={...jr(l,"interaction","audio","delay","volume","loop"),triggerAfter:"after"in l?l.after:void 0,toggle:"after"in l?l.toggle:void 0,type:"Audio"}:(l.interaction==="pause"||l.interaction==="stop")&&(d={...jr(l,"interaction","delay","object","playAudio"),type:"Audio"}),d&&a.push({fi:c,id:u,data:d})}}),s.forEach(l=>e.events.delete(l)),a.length){let l=e.events.find(u=>u.type===o)?.data;l?"actions"in l&&l.actions.insertBefore(null,a):e.events.insertBefore(null,[{id:ru.generateUUID(),data:{type:o,actions:a}}])}}r("Start","start"),r("MouseDown","mouseDown"),r("MouseUp","mouseUp"),r("KeyDown","keyDown"),r("KeyUp","keyUp")})}function _0(n){let t=n.layers.find(e=>e.type==="light")?.data;if(t?.category==="basic"){let e=Pt.defaultData("light","phong"),r=t;Object.assign(r,e),r.visible=!1}}function P0(n){Uo(n,_0),Ho(n,_0)}function KC(n){n.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(e.geometry.scaleBaked||(e.geometry.scaleBaked=[1,1,1]))})}function ZC(n){n.scene.objects.traverse((t,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 JC(n){n.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="NonParametricGeometry"&&!("material"in e)&&!("materials"in e)&&(e.material=Wt.defaultTwoLayerData("phong"))})}function eT(n){n.scene.publish.orbitControls.autoZoom===void 0&&(n.scene.publish.orbitControls.autoZoom=!1),n.scene.objects.traverse((t,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 tT(n){n.scene.objects.traverse((t,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 rT(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 oT(n){let{video:t}=n.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function nT(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.resetYPosition=Math.abs(r.resetYPosition-e.position[1]))})})}function iT(n){let t=n.scene.environment.usePhysics;n.scene.objects.traverse((e,r)=>{t&&r.physics===null?r.collision=!1:r.collision="visibility"})}function aT(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.navmesh=tu.defaultDataThirdPerson.navmesh)})})}function sT(n){n.scene.styles||(n.scene.styles=Fo.defaultData())}function O0(n){n.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function lT(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,O0),Uo(n,O0)}function cT(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&Object.assign(r.gameActions,{run:new Se})})})}function uT(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.keyAssignments=[...r.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function C0(n){n.layers&&n.layers.forEach(t=>{t.type==="light"&&t.bumpMapIntensity===void 0&&(t.bumpMapIntensity=5)})}function T0(n,t){if(t<1&&(Ho(n,b0),Uo(n,b0),n.schema=1),t<2&&(MC(n),n.schema=2),t<3&&(NC(n),n.schema=3),t<4&&(DC(n),n.schema=4),t<5&&(EC(n),n.schema=5),t<6&&(BC(n),n.schema=6),t<7&&(LC(n),n.schema=7),t<8&&(n.schema=8),t<9&&(S0(n),n.schema=9),t<10&&(GC(n),n.schema=10),t<11&&(FC(n),n.schema=11),t<12&&(S0(n),n.schema=12),t<13&&(kC(n),n.schema=13),t<14&&(UC(n),n.schema=14),t<15&&(HC(n),n.schema=15),t<16&&(qC(n),n.schema=16),t<17&&(Ho(n,w0),Uo(n,w0),n.schema=17),t<18&&(Ho(n,v0),Uo(n,v0),n.schema=18),t<19&&(IC(n),n.schema=19),t<20&&(WC(n),YC(n),n.schema=20),t<21&&(XC(n),QC(n),n.schema=21),t<22&&(P0(n),n.schema=22),t<23&&(KC(n),n.schema=23),t<24&&(ZC(n),n.schema=24),(t<25||n.shared.videos===void 0)&&(jC(n),t<25&&(n.schema=25)),t<26&&(RC(n),n.schema=26),t<27&&(VC(n),n.schema=27),t<28&&(P0(n),n.schema=28),t<29&&(zC(n),n.schema=29),t<30&&(JC(n),n.schema=30),t<31&&(eT(n),n.schema=31),t<33&&(tT(n),n.schema=33),t<34&&(rT(n),n.schema=34),t<35&&(oT(n),n.schema=35),t<36&&(nT(n),n.schema=36),t<37&&(iT(n),n.schema=37),t<38&&(Ho(n,A0),Uo(n,A0),n.schema=38),t<39&&(aT(n),n.schema=39),t<40&&(sT(n),n.schema=40),t<41&&(lT(n),n.schema=41),t<42&&(cT(n),n.schema=42),t<43&&(uT(n),n.schema=43),t<99){Ho(n,C0),Uo(n,C0),n.scene.publish.playCamera===null&&(n.scene.publish.playCamera=bn);let e=ut(n.scene.objects),r=n.scene.objects;n.scene.publish.playPage=vn,r.insertBefore(null,null,[{id:vn,data:{...Go.defaultData,backgroundColor:n.scene.backgroundColor,fog:n.scene.fog,postprocessing:n.scene.postprocessing,ao:jr(n.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:n.scene.publish.playCamera,gameControlObject:n.scene.publish.gameControlObject},shadow:jr(n.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...Ys.defaultData,...jr(n.scene.environment,"usePhysics","gravity")},camera:ut(n.scene.ownerCamera)??Go.defaultData.camera,name:"Scene"},children:[]}]);for(let a of e)a.id!==ko.TRASH_CAN_ID&&r.move(vn,a.fi,a.id);let o=0,i=0;n.shared.penumbraSize&&n.scene.objects.traverse((a,s)=>{s.type==="DirectionalLight"?(s.penumbraSize=n.shared.penumbraSize[Math.min(o,2)],o+=1):s.type==="SpotLight"&&(s.penumbraSize=n.shared.penumbraSize[3+Math.min(i,1)],i+=1),(s.physics===void 0||s.physics===null)&&s.type!=="Instance"&&(s.physics={},Object.assign(s.physics,wn.defaultData)),s.physics!==void 0&&s.physics!==null&&(s.physics.enabled=s.collision??"visibility",delete s.collision)}),n.schema=99}}function M0(n){n.layers&&n.layers.forEach(t=>{t.type==="light"&&t.alphaOverride===void 0&&(t.alphaOverride=1)})}function dT(n){n.scene.objects.traverse((t,e)=>{let r=e.geometry;r&&r.type==="PathGeometry"&&(r.extrusion.capType="flat",r.extrusion.bevel=50,r.extrusion.bevelSides=6,r.extrusion.shape.type==="Custom"&&(r.extrusion.shape.shapeQuality="low"))})}function pT(n){Array.isArray(ut(n.events))&&n.events?.forEach(t=>{"disabled"in t||(t.disabled=!1),(t.type==="MouseDown"||t.type==="MouseUp"||t.type==="MousePress")&&(t.mode=t.mode||"Object")})}var Sa=180/Math.PI;function I0(n){n.rotation=n.rotation.slice(0,3).map(t=>t*Sa)}function N0(n){I0(n),n.type==="Page"&&I0(n.camera),n.states?.forEach(e=>{e.rotation===void 0||e.rotation===null||(e.rotation=e.rotation.slice(0,3).map(r=>r*Sa))});let t=n.geometry;t&&t.type==="SphereGeometry"&&(t.thetaLength=(t.thetaLength??180)*Sa),t&&t.type==="TorusGeometry"&&(t.arc=t.arc*Sa),t&&t.type==="PathGeometry"&&(t.extrusion.angle*=Sa,t.extrusion.twist*=Sa),n.type==="Mesh"&&n.geometry.type==="TextGeometry"&&(n.geometry.text={textValue:n.geometry.text}),Array.isArray(ut(n.events))&&n.events?.forEach(e=>{(e.type==="MouseDown"||e.type==="MouseUp"||e.type==="MousePress"||e.type==="KeyDown"||e.type==="KeyUp"||e.type==="KeyPress"||e.type==="Collision"||e.type==="Trigger")&&(e.runMode=e.toggle?"Toggle":"Repeat")})}function fT(n){n.shared.variables=rr({},xe.prototype)}function hT(n){let t=ut(n.shared.variables);n.shared.variables=rr(Object.entries(t??{}).map(([e,r],o)=>({fi:o,id:e,data:r})),Se.prototype)}var mo=111;function D0(n,t){t(n.data);for(let e of n.children)D0(e,t)}function mT(n){let t=n.schema??104;t!==mo&&t<105&&(D0(n.asset,N0),n.schema=105)}function yT(n){n.shared.particles=rr({},xe.prototype),n.shared.lib&&(n.shared.lib.particles=jo.defaultData().particles)}function gT(n){n.scene.objects.traverse((t,e)=>{e.type==="Particle"&&typeof e.renderMaterial.size=="number"&&Object.assign(e.renderMaterial,{size:[e.renderMaterial.size,e.renderMaterial.size]})})}function ou(n){let t=n.schema??0;if(t!==mo){console.warn("updating from ",t,"to ",mo),T0(n,t),t<100&&(n.scene.publish.joystickSizeAndXYOffset===void 0&&(n.scene.publish.joystickSizeAndXYOffset=Hr.defaultData.joystickSizeAndXYOffset),n.schema=100),t<101&&(Ho(n,M0),Uo(n,M0),n.schema=101),t<102&&(dT(n),n.schema=102),t<104&&(n.shared.catelogs=new xe,n.shared.lib=jo.defaultData(),n.schema=104),t<105&&(fT(n),n.scene.objects.traverse((e,r)=>{N0(r)}),n.schema=105);for(let e of Object.values(n.shared.lib.components))mT(e);t<106&&(hT(n),n.schema=106),t<107&&(n.shared.lib.variables=jo.defaultData().variables,n.schema=107),t<109&&(yT(n),n.schema=109),t<110&&(gT(n),n.schema=110),t<111&&(n.scene.objects.traverse((e,r)=>{pT(r)}),n.schema=111)}}var xa;(l=>{l.defaultData={schema:mo,scene:ko.defaultData,frames:new xe().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",ba.defaultData),shared:{...Nr.emptyData(),colors:Nr.defaultColors()}},l.emptyDataForImports=function(u){let c=ko.emptyDataWithPage(u);return{schema:mo,scene:c,frames:new xe().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",ba.defaultData),shared:{...Nr.emptyData(),colors:Nr.defaultColors(),images:Nr.defaultImages(u)}}},l.emptyData=function(){return{schema:mo,scene:ko.emptyDataWithPage(),frames:new xe().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",ba.defaultData),shared:Nr.emptyData()}},l.clipboard2dData=function(){return{schema:mo,scene:ko.emptyData(),frames:new xe,shared:Nr.emptyData()}},l.collabHelper={...js,updateSchema(u){return(u.schema??0)<mo?fn(u,ou):(u.schema??0)-mo}};function i(u){let c=l.collabHelper.updateSchema(u);return typeof c=="number"?c===0?u:null:c.data}l.updateSchemaDirectly=i;function a(u){return{...u,shared:{...u.shared,lib:jo.defaultData()}}}l.withoutLib=a;function s(u,c){let d=u.scene.objects.get(c);if(d&&d.data.type==="Component")return d;{let p=u.shared.lib.components[c];if(p)return p.asset}}l.getComponentData=s})(xa||(xa={}));var E0;(t=>{function n(e){return!0}t.is=n})(E0||(E0={}));var nu;(r=>{r.defaultData={position:[0,0],scale:[1,1],rotation:0,shear:[0,0]};function t(o,i){return{position:i?.position??o.position,rotation:i?.rotation??o.rotation,scale:i?.scale??o.scale,shear:i?.shear??o.shear}}r.merge=t;function e(o,i){return Yl({position:ua.isEqual(o.position,i.position)?void 0:i.position,rotation:o.rotation===i.rotation?void 0:i.rotation,scale:ua.isEqual(o.scale,i.scale)?void 0:i.scale,shear:o.shear&&i.shear&&ua.isEqual(o.shear,i.shear)?void 0:i.shear})}r.diff=e})(nu||(nu={}));var Pp;(t=>t.defaultData={horizontalConstraint:0,verticalConstraint:0})(Pp||(Pp={}));var iu;(t=>t.defaultData={opacity:1,fill:{color:Ie.white,enabled:!0},stroke:{color:Ie.from0to1([0,0,0,1]),thickness:1,enabled:!1,mode:"inside"},layerBlur:{radius:2,enabled:!1},backgroundBlur:{radius:2,enabled:!1},dropShadow:{offset:[10,10],blurRadius:10,color:Ie.from0to1([0,0,0,1]),enabled:!1,spread:0},innerShadow:{offset:[10,10],blurRadius:10,color:Ie.from0to1([0,0,0,1]),enabled:!1,spread:0}})(iu||(iu={}));var ii;(i=>{function n(a,s){return{name:s}}i.newEmpty=n;function t(a,s){if(s===void 0)return a;let l={...a},u=["width","height","cornerRadius"];for(let c of u)c in l&&c in s&&s[c]!==void 0&&Object.assign(l,{[c]:s[c]});return l}function e(a,s){if(s===void 0)return a;let l={...a};return"fill"in l&&"fill"in s&&s.fill!==void 0&&Object.assign(l,{fill:{...l.fill,...s.fill}}),"stroke"in l&&"stroke"in s&&s.stroke!==void 0&&Object.assign(l,{stroke:{...l.stroke,...s.stroke}}),"layerBlur"in l&&"layerBlur"in s&&s.layerBlur!==void 0&&Object.assign(l,{layerBlur:{...l.layerBlur,...s.layerBlur}}),"backgroundBlur"in l&&"backgroundBlur"in s&&s.backgroundBlur!==void 0&&Object.assign(l,{backgroundBlur:{...l.backgroundBlur,...s.backgroundBlur}}),"dropShadow"in l&&"dropShadow"in s&&s.dropShadow!==void 0&&Object.assign(l,{dropShadow:{...l.dropShadow,...s.dropShadow}}),"innerShadow"in l&&"innerShadow"in s&&s.innerShadow!==void 0&&Object.assign(l,{innerShadow:{...l.innerShadow,...s.innerShadow}}),l}function r(a,s){if(s===void 0)return a;let l={...a};return Object.assign(l,nu.merge(l,s)),l=t(l,s),l=e(l,s),l}i.patch=r;function o(a,s){let l,u=[];for(let[c,d]of Object.entries(s))c!=="name"&&(l===void 0&&(l={path:[],props:{},type:0},u.push(l)),l.props[c]=d);return u}i.toOps=o})(ii||(ii={}));var Xs;(t=>t.defaultData={...nu.defaultData,...Pp.defaultData,states:new Se,events:new Se,visible:!0,raycastLock:!1})(Xs||(Xs={}));var wa;(t=>t.defaultData={...Xs.defaultData,...iu.defaultData})(wa||(wa={}));var au;(t=>t.defaultData={cornerRadius:[0,0,0,0]})(au||(au={}));var Op;(t=>t.defaultData={...wa.defaultData,type:"ellipse2d",width:100,height:100,name:"Ellipse"})(Op||(Op={}));var Aa;(t=>t.defaultData={...wa.defaultData,...au.defaultData,type:"rectangle2d",width:100,height:100,name:"Rectangle"})(Aa||(Aa={}));var Cp;(t=>t.defaultData={...wa.defaultData,type:"text2d",width:100,height:100,fontSize:12,lineHeight:1.2,letterSpacing:0,text:{textValue:"Hello world"},horizontalAlign:1,verticalAlign:1,textTransform:1,font:"Roboto_regular",name:"Text"})(Cp||(Cp={}));var Tp;(t=>t.defaultData={...wa.defaultData,type:"path2d",path:"",name:"Path"})(Tp||(Tp={}));var B0;(t=>{function n(e){return e.type==="ellipse2d"||e.type==="rectangle2d"||e.type==="text2d"||e.type==="vector2d"||e.type==="path2d"}t.is=n})(B0||(B0={}));var Qs;(t=>t.defaultData={...Xs.defaultData,name:"Group",type:"group2d"})(Qs||(Qs={}));var Mp;(t=>t.defaultData={...Xs.defaultData,...au.defaultData,...iu.defaultData,name:"Frame",type:"frame2d",clipped:!0,width:200,height:200,fill:{color:Ie.fromHexAndA(St,1),enabled:!0},stroke:{color:Ie.fromHexAndA(0,1),thickness:1,enabled:!1,mode:"inside"},backgroundBlur:{radius:2,enabled:!1},layerBlur:{radius:2,enabled:!1}})(Mp||(Mp={}));var qo;(o=>{function n(i){switch(i){case"rectangle2d":return{...Aa.defaultData};case"ellipse2d":return{...Op.defaultData};case"text2d":return{...Cp.defaultData};case"vector2d":return{...Aa.defaultData};case"path2d":return{...Tp.defaultData};case"frame2d":return{...Mp.defaultData};case"group2d":return{...Qs.defaultData}}}o.defaultData=n;function t(i){return"width"in i&&"height"in i?[typeof i.width=="number"?i.width*.5:0,typeof i.height=="number"?i.height*.5:0]:[0,0]}o.getPivot=t;function e(i){return i.type==="rectangle2d"||i.type==="ellipse2d"||i.type==="text2d"||i.type==="frame2d"}o.isResizeable=e;function r(i){return i.type==="rectangle2d"||i.type==="frame2d"}o.hasCorners=r})(qo||(qo={}));var su;(e=>(e.defaultData={name:"UI",type:"scene2d",objects:new Je},e.emptyData=function(){return{type:"scene2d",objects:new Je}}))(su||(su={}));var bs=Ht(R0());import{Object3D as fN,Vector3 as Pr,Euler as ph,MathUtils as yv,Matrix4 as wi}from"three";var xT=.5*(Math.sqrt(3)-1),Ks=(3-Math.sqrt(3))/6,bT=1/3,yo=1/6,bq=(Math.sqrt(5)-1)/4,vq=(5-Math.sqrt(5))/20,Zs=n=>Math.floor(n)|0,V0=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]),Np=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 lu(n=Math.random){let t=G0(n),e=new Float64Array(t).map(o=>V0[o%12*2]),r=new Float64Array(t).map(o=>V0[o%12*2+1]);return function(i,a){let s=0,l=0,u=0,c=(i+a)*xT,d=Zs(i+c),p=Zs(a+c),f=(d+p)*Ks,h=d-f,m=p-f,y=i-h,g=a-m,b,w;y>g?(b=1,w=0):(b=0,w=1);let A=y-b+Ks,S=g-w+Ks,P=y-1+2*Ks,O=g-1+2*Ks,x=d&255,D=p&255,N=.5-y*y-g*g;if(N>=0){let E=x+t[D],B=e[E],R=r[E];N*=N,s=N*N*(B*y+R*g)}let T=.5-A*A-S*S;if(T>=0){let E=x+b+t[D+w],B=e[E],R=r[E];T*=T,l=T*T*(B*A+R*S)}let I=.5-P*P-O*O;if(I>=0){let E=x+1+t[D+1],B=e[E],R=r[E];I*=I,u=I*I*(B*P+R*O)}return 70*(s+l+u)}}function z0(n=Math.random){let t=G0(n),e=new Float64Array(t).map(i=>Np[i%12*3]),r=new Float64Array(t).map(i=>Np[i%12*3+1]),o=new Float64Array(t).map(i=>Np[i%12*3+2]);return function(a,s,l){let u,c,d,p,f=(a+s+l)*bT,h=Zs(a+f),m=Zs(s+f),y=Zs(l+f),g=(h+m+y)*yo,b=h-g,w=m-g,A=y-g,S=a-b,P=s-w,O=l-A,x,D,N,T,I,E;S>=P?P>=O?(x=1,D=0,N=0,T=1,I=1,E=0):S>=O?(x=1,D=0,N=0,T=1,I=0,E=1):(x=0,D=0,N=1,T=1,I=0,E=1):P<O?(x=0,D=0,N=1,T=0,I=1,E=1):S<O?(x=0,D=1,N=0,T=0,I=1,E=1):(x=0,D=1,N=0,T=1,I=1,E=0);let B=S-x+yo,R=P-D+yo,F=O-N+yo,V=S-T+2*yo,q=P-I+2*yo,k=O-E+2*yo,U=S-1+3*yo,H=P-1+3*yo,Y=O-1+3*yo,J=h&255,Z=m&255,X=y&255,te=.6-S*S-P*P-O*O;if(te<0)u=0;else{let W=J+t[Z+t[X]];te*=te,u=te*te*(e[W]*S+r[W]*P+o[W]*O)}let $=.6-B*B-R*R-F*F;if($<0)c=0;else{let W=J+x+t[Z+D+t[X+N]];$*=$,c=$*$*(e[W]*B+r[W]*R+o[W]*F)}let ee=.6-V*V-q*q-k*k;if(ee<0)d=0;else{let W=J+T+t[Z+I+t[X+E]];ee*=ee,d=ee*ee*(e[W]*V+r[W]*q+o[W]*k)}let Q=.6-U*U-H*H-Y*Y;if(Q<0)p=0;else{let W=J+1+t[Z+1+t[X+1]];Q*=Q,p=Q*Q*(e[W]*U+r[W]*H+o[W]*Y)}return 32*(u+c+d+p)}}function G0(n){let e=new Uint8Array(512);for(let r=0;r<512/2;r++)e[r]=r;for(let r=0;r<512/2-1;r++){let o=r+~~(n()*(256-r)),i=e[r];e[r]=e[o],e[o]=i}for(let r=256;r<512;r++)e[r]=e[r-256];return e}import{Triangle as vT}from"three";var qr=new vT,cu=class{constructor(t){this.weightAttribute=null;let e=t.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 t=this.positionAttribute,e=new Float32Array(t.count/3);for(let o=0;o<t.count;o+=3){let i=1;qr.a.fromBufferAttribute(t,o),qr.b.fromBufferAttribute(t,o+1),qr.c.fromBufferAttribute(t,o+2),i*=qr.getArea(),e[o/3]=i}this.distribution=new Float32Array(t.count/3);let r=0;for(let o=0;o<e.length;o++)r+=e[o],this.distribution[o]=r;return this}setRandomGenerator(t){return this.randomFunction=t,this}sample(t,e){if(this.distribution){let r=this.distribution[this.distribution.length-1],o=this.binarySearch(this.randomFunction()*r);return this.sampleFace(o,t,e)}}binarySearch(t){if(!this.distribution)return 0;let e=this.distribution,r=0,o=e.length-1,i=-1;for(;r<=o;){let a=Math.ceil((r+o)/2);if(a===0||e[a-1]<=t&&e[a]>t){i=a;break}else t<e[a]?o=a-1:r=a+1}return i}sampleFace(t,e,r){let o=this.randomFunction(),i=this.randomFunction();return o+i>1&&(o=1-o,i=1-i),qr.a.fromBufferAttribute(this.positionAttribute,t*3),qr.b.fromBufferAttribute(this.positionAttribute,t*3+1),qr.c.fromBufferAttribute(this.positionAttribute,t*3+2),e.set(0,0,0).addScaledVector(qr.a,o).addScaledVector(qr.b,i).addScaledVector(qr.c,1-(o+i)),qr.getNormal(r),this}};import{Object3D as PT}from"three";var j0=Ht(k0());import{Object3D as ST,Matrix4 as go}from"three";var wT=new go,AT=new go,_T=new go,_a;(t=>{function n(e){return e&&e.__isSPEObject}t.is=n})(_a||(_a={}));var Pa=n=>class extends n{constructor(){super(...arguments);this.previousModelViewMatrix=new go;this.copyPreviousMatrix=!0;this.hiddenMatrix=new go;this.matrixWorldRigid=new go;this.shearScale=new go;this.shearScaleInv=new go}get __isSPEObject(){return!0}isDescendantOf(r){r instanceof ST&&(r=r.uuid);let o=this;for(;o.parent;){if(o.parent.uuid===r)return!0;o=o.parent}return!1}updateMatrixWorld(r){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||r)&&(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,r=!0);for(let o of this.children)o.updateMatrixWorld(r)}updateWorldMatrix(r,o){let i=this.parent;if(r&&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 a of this.children)a.updateWorldMatrix(!1,!0)}traverseChildren(r,o=0){for(let i of this.children)_a.is(i)&&i.traverseObject(r,o+1)}traverseObject(r,o=0){if(r(this,o)!==!0)for(let a of this.children)_a.is(a)&&a.traverseObject(r,o+1)}updateMatrixWorldSVD(){let r=this.matrixWorld.elements,o=[[r[0],r[4],r[8]],[r[1],r[5],r[9]],[r[2],r[6],r[10]]],{u:i,v:a,q:s}=(0,j0.SVD)(o),l=wT.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),u=AT.set(a[0][0],a[0][1],a[0][2],0,a[1][0],a[1][1],a[1][2],0,a[2][0],a[2][1],a[2][2],0,0,0,0,1),c=_T.copy(u).transpose();this.shearScale.makeScale(s[0],s[1],s[2]).multiply(c).premultiply(u),this.shearScaleInv.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(l,c).copyPosition(this.matrixWorld),s.every(d=>Math.abs(s[0]-d)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(r,o){this.updateWorldMatrix(!0,!1);let i=new go().copy(this.matrixWorld).invert();return r.parent!==null&&(r.parent.updateWorldMatrix(!0,!1),i.multiply(r.parent.matrixWorld)),"hiddenMatrix"in r&&r.hiddenMatrix instanceof go?r.hiddenMatrix.premultiply(i):r.applyMatrix4(i),r.updateWorldMatrix(!1,!1),this.add(r),o!==void 0&&(this.children.pop(),this.children.splice(o,0,r)),this}copy(r,o=!1){return super.copy(r,o),this.hasNonUniformScale=r.hasNonUniformScale,this}onAfterRender(r,o,i,a,s,l){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}};var Dp=class extends Pa(PT){},OT=n=>n.type==="Mesh",Wo=class extends Dp{constructor(e){super();this.object=e;this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,r){}expand(){let e=0,r=this.object.entityChildren(e);for(;r;){let o=this.children[e];o?.object!==r&&(o&&this.remove(o),o=new Wo(r),this.add(o),this.children.splice(e,0,this.children.pop()),o.matrixWorldNeedsUpdate=!0,o.matrixAutoUpdate=!1,o.matrix=r.matrix,o.hiddenMatrix=r.hiddenMatrix),o.expand(),e+=1,r=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 OT(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}};import{Box3 as VI,BufferGeometry as zI,MeshBasicMaterial as GI}from"three";import{Matrix4 as LI,Mesh as RI}from"three";import{Matrix4 as pu,Vector3 as q0,Euler as DT,MathUtils as el}from"three";import{Box3 as CT,Line3 as TT,Matrix4 as Ep,Vector3 as wr}from"three";var ai=new wr,si=new wr,Oa=new Ep,H0=[new wr(-1,1,1),new wr(-1,-1,1),new wr(1,-1,1),new wr(1,1,1),new wr(-1,1,-1),new wr(-1,-1,-1),new wr(1,-1,-1),new wr(1,1,-1)],MT=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],IT=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],U0=(n,t,e)=>{n.updateEntityBoxSize(ai,si),Oa.copy(t).multiply(n.matrixWorld),si.x===0&&si.y===0&&si.z===0?e.push(new wr(ai.x,ai.y,ai.z).applyMatrix4(Oa)):H0.forEach(r=>{e.push(r.clone().multiply(si).add(ai).applyMatrix4(Oa))})},Js=class extends CT{constructor(){super(...arguments);this.matrix=new Ep;this.vertices=[];this.faces=[];this.edges=[];this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(r=>r.clone()),this.faces=e.faces.map(r=>r.clone()),this.edges=e.edges.map(r=>r.clone()),this.centerEdges=e.centerEdges.map(r=>r.clone()),this}setFromObjectSize(e,r=!1){e.updateWorldMatrix(!1,r),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let o=new Ep().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,o,r)}expandByObjectSize(e,r,o=!1){let i=[];return o===!0?e.traverseEntity(a=>{if(a.visible||a.cloner&&a.data.visible){if(!("geometry"in a)){i.push(new wr);return}U0(a,r,i)}}):U0(e,r,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(Oa.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(si).multiplyScalar(.5),this.getCenter(ai),Oa.copy(this.matrix).setPosition(ai),this.vertices=H0.map(e=>e.clone().multiply(si).applyMatrix4(Oa))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=MT.map(([e,r])=>new TT(this.vertices[e],this.vertices[r])),this.centerEdges=this.edges.map(e=>e.getCenter(new wr))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=IT.map(([e,r])=>this.vertices[e].clone().add(this.vertices[r]).multiplyScalar(.5))}};var Wr={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}};import{CurvePath as NT,CubicBezierCurve3 as Bp,Vector3 as $r}from"three";var Rp=class extends NT{constructor(){super()}getPoints(t=12){let e=[],r,o=this.getCurveLengths(),a=o[o.length-1]/o.length;for(let s=0,l=this.curves;s<l.length;s++){let u=l[s],c=s===0?o[s]:o[s]-o[s-1],d=Math.ceil(t*c/a),p=u.getPoints(d);for(let f=0;f<p.length;f++){let h=p[f];r&&r.equals(h)||(e.push(h),r=h)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}};var Vp=.001;function zp(n,t,e){return t.clone().sub(n).cross(t.clone().sub(e)).length()<=Vp}function Lp(n,t){let e=new $r(...n.position),r=new $r(...n.controlNext.position),o=new $r(...t.controlPrevious.position),i=new $r(...t.position);return zp(e,r,i)&&zp(e,o,i)}function du(n){let t=n.points.map(c=>new $r(...c.data.position)),e=[n.points[0]],r=new $r(...e[0].data.position);for(let c=0;c<n.points.length-1;c++)zp(r,t[c],t[c+1])||(e.push(n.points[c]),r=t[c]);e.push(n.points[n.points.length-1]);let o=n.isClosed,i=e.length-(o?0:1),a=e.length,s=[];for(let c=0;c<a;c++){let d=e[c].data,p=new $r(...d.position),f=new $r(...d.controlPrevious.position),h=new $r(...d.controlNext.position),m={position:p,baseRoundness:d.roundness,controlPrevious:f,controlNext:h};if(d.roundness===0||!n.isClosed&&(c===0||c===a-1)){s[c]={...m,removedLength:0};continue}let y=o&&c==0?a-1:c-1,g=o&&c==a-1?0:c+1,b=e[y].data,w=e[g].data,A=new $r(...b.position),S=new $r(...w.position),P=A.clone().sub(p).normalize(),O=S.clone().sub(p).normalize();Object.assign(m,{prevDir:P,nextDir:O});let x=Lp(b,d),D=Lp(d,w);if(!x||!D)s[c]={...m,removedLength:0};else{let N=P.clone().add(O).normalize(),T=N.clone().cross(P).length()/P.dot(N);s[c]={...m,tan:T,removedLength:d.roundness/T}}}for(let c=0;c<i;c++){let d=c,p=o&&c===a-1?0:c+1,f=s[d],h=s[p];if(f.removedLength!==0||h.removedLength!==0){let m=f.position.distanceTo(h.position);f.removedLength=Math.min(f.removedLength,m/2),h.removedLength=Math.min(h.removedLength,m/2)}}let l=[];for(let c=0;c<i;c++){let d=c,p=o&&c===a-1?0:c+1,f=s[d],h=s[p],m=null;if(!Lp(e[d].data,e[p].data))f.position.distanceTo(h.position)>Vp&&(m=new Bp(f.position,f.controlNext,h.controlPrevious,h.position));else{let y=f.position.clone(),g=h.position.clone();(f.removedLength!==0||h.removedLength!==0)&&(f.nextDir&&y.add(f.nextDir.clone().setLength(f.removedLength)),h.prevDir&&g.add(h.prevDir.clone().setLength(h.removedLength))),y.distanceTo(g)>Vp&&(m=new Bp(y,y.clone().lerp(g,.3),g.clone().lerp(y,.3),g))}l[2*c+1]=m}for(let c=0;c<a;c++){let d=s[c];if(d.removedLength===0){l[2*c]=null;continue}let p=d.position,f=d.prevDir.clone().multiplyScalar(d.removedLength).add(p),h=d.nextDir.clone().multiplyScalar(d.removedLength).add(p),m=d.tan*d.removedLength,y=d.prevDir.clone().add(d.nextDir).normalize(),g=f.clone().lerp(h,.5),b=f.distanceTo(h)/2,w=y.clone().multiplyScalar(Math.sqrt(Math.pow(m,2)-Math.pow(b,2))).add(g),A=y.clone().multiplyScalar(-m).add(w),S=p.distanceTo(A)/p.distanceTo(g),P=d.prevDir.clone().multiplyScalar(S*p.distanceTo(f)).add(p),O=P.clone().lerp(A,2),x=f.clone().lerp(P,4/3),D=h.clone().lerp(O,4/3);l[2*c]=new Bp(f,x,D,h)}let u=new Rp;return l.forEach(c=>{c&&u.add(c)}),u}var Re;(t=>{function n(e){return e&&e.__isEntity}t.is=n})(Re||(Re={}));var Ca=n=>Re.is(n),ET={type:"completeState",isfromEntity:!0},BT=["x","y","z"],Gp=new q0,LT=new q0().set(0,1,0),Ta=n=>class extends Pa(n){constructor(){super(...arguments);this.raycastLock=!1;this.scaleLock=!1;this.disposed=!1;this.stateSelection=null;this.destroyedInAction=!1;this.instances=[];this.prevState=null;this.currentState=null;this.reversibleToState=null;this.currentTransitionEvent=null;this.previousAction=null;this._singleBBox=new Js;this._recursiveBBox=new Js;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this._needApplyPathSnapping=!0;this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(r){let o=this.children[r];if(Re.is(o))return o}entityChildrenCount(){let r=this.children.length;for(;r--;)if(Re.is(this.children[r]))return r+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 r=this;for(;r.data.type!=="Instance";){let o=r.parent;if(Re.is(o))r=o;else return}return r}forInstancesRec(r){this.instances.forEach(o=>{o.disposed||r(o),o.forInstancesRec(r)})}super_Entity(r,o){typeof r=="string"&&(this.uuid=r),this.identity=r,this.data=o,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(r,o,i=!1){if(!(this.data.states.length===0&&!i)){for(let a of this.data.states)ni.toOps(this.data,a.data).forEach(l=>{let u=aa.replaceProps(l,this.data);this.dataPatched=this.data,this.updateByPatchedOp(u,this.data,o)});if(r!==null){let a=this.data.states.data(r);a&&(this.dataPatched=ni.patch(this.data,a),ni.toOps(this.data,a).forEach(l=>{this.updateByPatchedOp(l,this.dataPatched,o)}))}i&&this.updateTransformState(this.dataPatched,o),this.stateSelection=r,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(r,o){r.setScalar(0),o.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(r=>{Ca(r)&&r.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(r=>{r.resetBBoxNeedsUpdateSelf()})}find(r){let o;return this.traverseEntity(i=>{i.uuid===r&&(o=i)}),o}traverseSortNextHelper(){let r=this.parent;if(r){let o=r.children,i=o.indexOf(this)+1;if(Re.is(o[i]))return o[i];if(Re.is(r))return r.traverseSortNextHelper()}}sortNext(){let r=this.children;return this.children.length>0&&Re.is(this.children[0])?r[0]:this.traverseSortNextHelper()}goUp(r){let o=this;for(;r>0&&o!==null;)o=o.parent,r-=1;return o}hasAnccestorOrSelf(r){return this===r||this.hasAnccestor(r)}hasAnccestor(r){let o=this.parent;for(;o;){if(r===o)return!0;o=o.parent}return!1}countToAccestor(r){let o=0,i=this;for(;i!==r;){if(i===null)return-1;i=i.parent,o+=1}return o}forEachEntity(r){for(let o of this.children)Ca(o)&&r(o)}traverseEntityAncestors(r){this.traverseAncestors(o=>{Re.is(o)&&r(o)})}traverseConcreteEntity(r,o=0){if(r(this,o)!==!0)for(let a of this.children)Ca(a)&&a.isConcreteEntity&&a.traverseEntity(r,o+1)}traverseEntity(r,o=0){if(r(this,o)!==!0)for(let a of this.children)Ca(a)&&a.traverseEntity(r,o+1)}traverseVisibleEntity(r){r(this);for(let o of this.children)Ca(o)&&o.visible&&o.traverseVisibleEntity(r)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}updateMatrixWorld(r){super.updateMatrixWorld(r),this.dispatchEvent({type:"updateMatrixWorld"})}copy(r,o=!1){return super.copy(r,o),this.dataPatched=r.dataPatched,this.raycastLock=r.raycastLock,this.scaleLock=r.scaleLock,this.hiddenMatrix.copy(r.hiddenMatrix),this}hasEntityChild(){return this.children.some(r=>Ca(r))}isAncestorOf(r){if(this.uuid===r)return!1;let o=!1;return this.traverseEntity(i=>{i.uuid===r&&(o=!0)}),o}toObjectTransformState(r=[]){this.updateWorldMatrix(!0,!1);let o={position:this.position.toArray(),rotation:[this.rotation.x*el.RAD2DEG,this.rotation.y*el.RAD2DEG,this.rotation.z*el.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return ta(o,r)}getTransformValues(r,o,i){return o[r].map((a,s)=>i?.shared.getVariable(a,[this.uuid,r,BT[s]])??a)}updateTransformState(r,o){let i=!1;return r.position&&(this.position.fromArray(this.getTransformValues("position",r,o)),i=!0),r.rotation&&(Gp.fromArray(this.getTransformValues("rotation",r,o)).multiplyScalar(el.DEG2RAD),this.rotation.setFromVector3(Gp),i=!0),r.scale&&(this.scale.fromArray(this.getTransformValues("scale",r,o)),i=!0),r.hiddenMatrix!==void 0&&(i=!0,this.hiddenMatrix.fromArray(r.hiddenMatrix??xn.identity)),i&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(a=>{a.invalidateClonerTransform(this)})),r.position&&r.rotation&&r.scale&&r.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),i}onVariableUpdate(r=!1){if(r){this.resetBBoxNeedsUpdate();return}this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(o=>{o.invalidateClonerTransform(this)})}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let r of this.children)Re.is(r)&&r.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(r=>{Re.is(r)&&r.disposeRecursively()})}toState(r=[]){let o={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(r)};return ta(o,r)}updateByObjUpdateOp(r,o){r!==void 0&&this.updateByOp({type:0,props:r,path:[]},{...this.data,...r},o,!1)}updateByOp(r,o,i,a){let s=this.data;this.data=o;let l=r,u=Le(r.path,["states","*"]);if(u!==null){if(r.type===0){let[c]=u;if(this?.stateSelection===c){let d={...r.props};if(delete d.name,Object.values(r.props).some(p=>p===void 0)){let p=this.data;if(p!==void 0){let f=lt.zoom(p,r.path.slice(2));if(f)for(let h in r.props)r.props[h]===void 0&&h in f&&(d[h]=f[h])}}l={...r,props:d,path:r.path.slice(2)}}}}else if(r.type===0){let c=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(c!==void 0){if(r.props.name!==void 0&&c.name){let{name:p,...f}=c;c=f}if(r.props.material!==void 0&&"material"in c){let{material:p,...f}=c;c=f}let d=lt.removeOverridden(r.path,r.props,c);l={...r,props:d}}}if(this.updateByPatchedOpBase(l,ni.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),i),Le(r.path,["overrides"])){let c=[],d=[...r.path];for(c.push(d[1]),d.splice(0,2);d.length>0&&d[0]==="descendants";)c.push(d[1]),d.splice(0,2);if(c[c.length-1]===void 0){if(r.type===0)for(let p of Object.keys(r.props)){c[c.length-1]=p;let f=i.scene.findInstance([this.uuid,...c]);f&&(f.overrideData=r.props[p],f.updateState(so.apply(f.component.data,f.overrideData),i))}}else{let p=i.scene.findInstance([this.uuid,...c]);if(p){let f=lt.zoom(p.component.data,d);if(r={...r,path:d},r.type===0){let h=r.props;if(f)for(let[m,y]of Object.entries(r.props))y===void 0&&(h===r.props&&(h={...r.props}),h[m]=f[m]);r={...r,props:h}}p.overrideData=ya.resolve(o.overrides,c),p.updateByOp(r,ct.applySimple(p.data,r),i,!1)}}}else if(this.instances.length>0){let c;if(r.path.length===0&&r.type===0){let d;for(let p of ho.rootOverrideProps)p in r.props&&(d===void 0&&(d={}),d[p]=r.props[p]);d&&(c={...r,props:d})}else for(let d of ho.rootOverrideProps)if(Le(r.path,[d])){c=r;break}c!==void 0&&this.instances.forEach(d=>{if(d.isInstanceRoot){let p=so.filterOp(d.overrideData,c);p&&d.updateByOp(p,ct.applySimple(d.data,p),i,!0)}}),this.instances.forEach(d=>{if(!d.isInstanceRoot){let p=so.filterOp(d.overrideData,r);if(p){let f;s===d.data&&r===p?f=o:f=ct.applySimple(d.data,p),d.updateByOp(p,f,i,!0)}}})}}updateByPatchedOpBase(r,o,i){if(this.dataPatched=o,r.path.length===0&&r.type===0)r.props.type!==void 0&&!Ur.is(r.props.type)&&Wr.changeEntityProptotype(this,o,i);else if(r.path.length===1&&r.path[0]==="geometry"&&r.type===0&&"type"in r.props){Wr.changeEntityProptotype(this,o,i);for(let a of this.children)Re.is(a)&&a.updateVisible(i.scene)}this.updateByPatchedOp(r,o,i)}updateByPatchedOp(r,o,i){if(r.path.length===0&&r.type===0&&this.updateState(r.props,i),Le(r.path,["pathSnapping"])!==null&&this.updatePathSnapping(o.pathSnapping),Le(r.path,["cloner"])!==null){let a=ct.drop(r,1);a.path.length===0&&a.type===0&&a.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(i.scene)}}updatePathSnapping(r=this.dataPatched.pathSnapping){this._updatedPathSnapping=r,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(r){let o=this._updatedPathSnapping?.pathId??this.dataPatched.pathSnapping.pathId,i=this._updatedPathSnapping?.slide??this.dataPatched.pathSnapping.slide??0,a=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset??0,s=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(o===null)return;let l=r.find(o);if(!l||this._needApplyPathSnapping===!1)return;this._needApplyPathSnapping=!1;let u=l.data;if(u.geometry.path.points.length<=1)return;let c=du(u.geometry.path),d=(i+a)%1;i+a===1&&d===0&&(d=1);let p=c.getPointAt(d);if(p===null)return;let f=this.parent?this.parent?.matrixWorld:new pu;l.updateMatrixWorld();let h=new pu().multiplyMatrices(f.clone().invert(),l.matrixWorld);p.applyMatrix4(h);let m={position:p.toArray(),rotation:u.rotation};if(s==="tangential"){let y=new pu().extractRotation(l.matrixWorld),g=c.getTangentAt(d).applyMatrix4(y).add(p),b=new pu().lookAt(p,g,LT),w=Gp.setFromEuler(new DT().setFromRotationMatrix(b)).multiplyScalar(el.RAD2DEG);m={...m,rotation:w.toArray()}}this.updateTransformState(m),this.traverseEntity(y=>{y._cameraType&&y.dispatchEvent(ET)})}updateVisible(r){if(this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0),!r)return;let o=!1;this.traverseEntity(i=>{if(i.data.type==="Splat")return o=!0,!0}),o&&r.reloadSplats()}updateState_Entity(r,o){r.name!==void 0&&(this.name=r.name),r.raycastLock!==void 0&&(this.raycastLock=r.raycastLock),r.visible!==void 0&&(this.updateVisible(o?.scene),this.resetBBoxNeedsUpdate()),o&&"cloner"in r&&r.cloner!==void 0&&(this.setFromClonerState(r.cloner,o),this.updateVisible(o.scene)),this.updateTransformState(r,o)}get attachedSurfaceCloners(){return this.children.filter(r=>r instanceof Wr.Cloner&&r.parameters.type==="toObject")}setFromClonerState(r,o){this.disposed||(r===null||r.disabled?(this.cloner&&this.cloner.removeFromParent(),this.cloner=void 0):this.cloner===void 0?(this.cloner=new Wr.Cloner(this,r),o.scene.addPendingExpandCloner(this)):this.cloner.updateState(r,o.scene))}expandCloner(r){!this.disposed&&this.cloner&&this.cloner.expandClones(r)}invalidateClonerTransform(r){this.cloner&&this.cloner.invalidateTransform(r)}requestRender(){this.dispatchEvent({type:"requestRender"})}};import{BufferGeometry as zT,ConeGeometry as GT,Float32BufferAttribute as FT,MathUtils as kT}from"three";import{BufferGeometry as $0,CylinderGeometry as RT,Float32BufferAttribute as hu,MathUtils as VT,Vector2 as Yr,Vector3 as fu}from"three";var Y0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},n.parameters);e.thetaLength=VT.clamp(e.thetaLength,0,360);let r=e.width/2,o=e.radiusTop??r,i=e.radiusBottom??r;return o===i?(o=r,i=r):o>i?(o=r,i=i*r/o):(o=o*r/i,i=r),{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:t,depth:e,height:r,radialSegments:o,heightSegments:i,openEnded:a,thetaStart:s,thetaLength:l,radiusTop:u,radiusBottom:c,cornerRadius:d,cornerSegments:p,hollow:f}=n.parameters,h;return l===0?(h=new $0,h.setAttribute("position",new hu([],3))):d||f?h=new tl(u,c,r,o,i,a,s,l*Math.PI/180,d,d,p,f):h=new RT(u,c,r,o,i,a,s,l*Math.PI/180),h.scale(1,1,e/t),Object.assign(h,{userData:{...n,type:"CylinderGeometry"}})}};function _n(n,t,e){e.x=n.x*t.x,e.y=n.y,e.z=n.x*t.y}function W0(n){return new Yr(n.y,-n.x)}var tl=class extends $0{constructor(t,e,r,o,i,a,s,l,u,c,d,p,f=!1){super(),this.type="RoundedCylinderBufferGeometry",t=t!==void 0?t:1,e=e!==void 0?e:1,r=r||1,o=Math.floor(o)||8,i=Math.floor(i)||1,a=a!==void 0?a:!1,s=s!==void 0?s:0,l=l!==void 0?l:Math.PI*2,a&&(u=0,c=0);let h=[],m=[],y=[],g=[],b=0,w=r/2,A=new fu,S=new fu;f&&t==0&&(t=u),f&&e==0&&(e=c);let P=new Yr(t,w),O=new Yr(e,-w),x=null,D=null,N=null,T=null,I=P.clone().sub(O),E=0,B=0,R=0;p>0&&(E=Math.min(t,e)*(1-p),B=t-E,R=e-E);let F=P.clone();F.x-=E;let V=Math.PI-I.angle(),q=I.angle(),k=Math.tan(q/2),U=Math.tan(V/2),H=k+U,Y=p?H:U,J=p?H:k;if(u=Math.min(u,(t-B)/Y,I.length()/H),c=Math.min(c,(e-R)/J,I.length()/H),u>0){let Q=u/k;x=P.clone().sub(new Yr(Q,u)),p&&(N=x.clone(),N.x-=E-H*u),P.sub(I.clone().setLength(Q))}if(c>0){let Q=c/U;D=O.clone().sub(new Yr(Q,-c)),O.add(I.clone().setLength(Q)),p&&(T=D.clone(),T.x-=E-H*c,F.sub(I.clone().setLength(Q)))}I=P.clone().sub(O);let Z=I.length()<.5,X=[];for(let Q=0;Q<=o;Q++){let W=[],ue=Q/o,le=ue*l+s,ne=new Yr(Math.sin(le),Math.cos(le));T&&D?(te(W,ue,ne,V,c,T,-1,!0),te(W,ue,ne,q,c,D,-1,!1)):D?($(W,ne,D.x,0,-1),te(W,ue,ne,q,c,D,-1,!1)):a||$(W,ne,e,R,-1);let ce=W0(I).normalize();if(_n(ce,ne,A),!Z)for(let ae=0;ae<=i;ae++){let he=ae/i,pe=I.clone().multiplyScalar(he).add(O);_n(pe,ne,S),m.push(S.x,S.y,S.z),y.push(A.x,A.y,A.z),g.push(ue,.5+S.y/r),W.push(b++)}if(N&&x?(te(W,ue,ne,V,u,x,1,!1),te(W,ue,ne,q,u,N,1,!0)):x?(te(W,ue,ne,V,u,x,1,!1),$(W,ne,x.x,0,1)):a||$(W,ne,t,B,1),p&&!Z){let ae=W0(I).multiplyScalar(-1).normalize();_n(ae,ne,A);for(let he=0;he<=i;he++){let pe=he/i,fe=I.clone().multiplyScalar(-pe).add(F);_n(fe,ne,S),m.push(S.x,S.y,S.z),y.push(A.x,A.y,A.z),g.push(ue,.5+S.y/r),W.push(b++)}}p&&!a&&W.push(W[0]),X.push(W)}for(let Q=0;Q<X.length-1;Q++)for(let W=0;W<X[0].length-1;W++){if(a&&p&&W==i)continue;let ue=X[Q][W],le=X[Q+1][W],ne=X[Q+1][W+1],ce=X[Q][W+1],ae=m[ne*3+0],he=m[ne*3+2];h.push(ue,le,ce),(ae!=0||he!=0)&&h.push(le,ne,ce)}l<Math.PI*2&&(ee(-1,X[0],s),ee(1,X[X.length-1],s+l)),this.setIndex(h),this.setAttribute("position",new hu(m,3)),this.setAttribute("normal",new hu(y,3)),this.setAttribute("uv",new hu(g,2));function te(Q,W,ue,le,ne,ce,ae,he){for(let pe=0;pe<d+1;pe++){let fe=pe/d,ge=ae<0?fe:1-fe;he&&(ge-=1),ge*=le;let me=new Yr(Math.sin(ge),Math.cos(ge)*ae),C=me.clone().multiplyScalar(ne).add(ce);_n(C,ue,S),m.push(S.x,S.y,S.z),_n(me,ue,A),y.push(A.x,A.y,A.z),g.push(W,.5+S.y/r),Q.push(b++)}}function $(Q,W,ue,le,ne){let ce=new fu,ae=new Yr,he=[ue,le];ne<0&&he.reverse();for(let pe of he)ae.set(pe,w*ne),_n(ae,W,ce),m.push(ce.x,ce.y,ce.z),y.push(0,ne,0),g.push(.5,.5),Q.push(b++)}function ee(Q,W,ue){let le=new Yr(Math.sin(ue),Math.cos(ue)),ne=new Yr(-Math.cos(ue),Math.sin(ue)),ce=new fu,ae=Q<0?(fe,ge,me)=>h.push(fe,ge,me):(fe,ge,me)=>h.push(fe,me,ge),he=new Yr((t+e+B+R)/4,0);_n(he,le,ce),m.push(ce.x,ce.y,ce.z),y.push(ne.x,0,ne.y),g.push(.5,.5);let pe=b++;for(let fe of W){let ge=m.slice(fe*3,fe*3+3);m.push(...ge),y.push(ne.x,0,ne.y);let me=g.slice(fe*2,fe*2+2);g.push(...me),b++}for(let fe=pe+1;fe<b-1;fe++)ae(pe,fe,fe+1);ae(pe,b-1,pe+1)}}};var X0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:8,cornerRadiusBottom:8,cornerSegments:8},n.parameters);return e.thetaLength=kT.clamp(e.thetaLength,0,360),{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:t,depth:e,height:r,radialSegments:o,heightSegments:i,openEnded:a,thetaStart:s,thetaLength:l,cornerRadiusTop:u,cornerRadiusBottom:c,cornerSegments:d}=n.parameters,p;return l===0?(p=new zT,p.setAttribute("position",new FT([],3))):u>0||c>0||l<360?p=new tl(0,t/2,r,o,i,a,s,l*Math.PI/180,u,c,d,0,!0):p=new GT(t/2,r,o,i,a),p.scale(1,1,e/t),Object.assign(p,{userData:{...n,type:"ConeGeometry"}})}};import{BoxGeometry as jT,BufferGeometry as UT,Float32BufferAttribute as Fp,Vector3 as rl}from"three";var Q0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.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:t,height:e,depth:r,widthSegments:o,heightSegments:i,depthSegments:a,cornerRadius:s,cornerSegments:l}=n.parameters,u;return s==0?u=new jT(t,e,r,o,i,a):u=new jp(t,e,r,o,i,a,s,l),Object.assign(u,{userData:{...n,type:"CubeGeometry"}})}},kp=Math.PI/2,jp=class extends UT{constructor(t=1,e=1,r=1,o=1,i=1,a=1,s=0,l=4){super(),this.type="BoxGeometry";let u=this;o=Math.floor(o),i=Math.floor(i),a=Math.floor(a),l=Math.floor(l),s=Math.min(s,t/2,e/2,r/2);let c=[],d=[],p=[],f=[],h=0,m=0;y("z","y","x",-1,-1,r,e,t,a,i,0),y("z","y","x",1,-1,r,e,-t,a,i,1),y("x","z","y",1,1,t,r,e,o,a,2),y("x","z","y",1,-1,t,r,-e,o,a,3),y("x","y","z",1,-1,t,e,r,o,i,4),y("x","y","z",-1,-1,t,e,-r,o,i,5),s>0&&(g("z","y","x",-1,-1,1,r,e,t,a,0),g("z","y","x",1,-1,-1,r,e,t,a,1),g("z","y","x",-1,1,-1,r,e,t,a,1),g("z","y","x",1,1,1,r,e,t,a,0),g("x","y","z",-1,-1,-1,t,e,r,o,0),g("x","y","z",1,-1,1,t,e,r,o,1),g("x","y","z",-1,1,1,t,e,r,o,0),g("x","y","z",1,1,-1,t,e,r,o,1),g("y","x","z",-1,-1,1,e,t,r,i,0),g("y","x","z",1,-1,-1,e,t,r,i,1),g("y","x","z",1,1,1,e,t,r,i,1),g("y","x","z",-1,1,-1,e,t,r,i,0),b(1,1,1),b(-1,1,1),b(1,-1,1),b(-1,-1,1),b(1,1,-1),b(-1,1,-1),b(1,-1,-1),b(-1,-1,-1)),this.setIndex(c),this.setAttribute("position",new Fp(d,3)),this.setAttribute("normal",new Fp(p,3)),this.setAttribute("uv",new Fp(f,2));function y(w,A,S,P,O,x,D,N,T,I,E){let B=(x-2*s)/T,R=(D-2*s)/I,F=x/2-s,V=D/2-s,q=N/2,k=T+1,U=I+1,H=0,Y=0,J=new rl;for(let Z=0;Z<U;Z++){let X=Z*R-V;for(let te=0;te<k;te++){let $=te*B-F;J[w]=$*P,J[A]=X*O,J[S]=q,d.push(J.x,J.y,J.z),J[w]=0,J[A]=0,J[S]=N>0?1:-1,p.push(J.x,J.y,J.z),f.push(te/T),f.push(1-Z/I),H+=1}}for(let Z=0;Z<I;Z++)for(let X=0;X<T;X++){let te=h+X+k*Z,$=h+X+k*(Z+1),ee=h+(X+1)+k*(Z+1),Q=h+(X+1)+k*Z;c.push(te,$,Q),c.push($,ee,Q),Y+=6}u.addGroup(m,Y,E),m+=Y,h+=H}function g(w,A,S,P,O,x,D,N,T,I,E){let B=(D-2*s)/I,R=D/2-s,F=N/2-s,V=T/2,q=I+1,k=0,U=0,H=new rl,Y=new rl;for(let J=0;J<l+1;J++){let Z=J/l*kp,X=Math.sin(Z)*s,te=(1-Math.cos(Z))*s,$=Math.sin(Z),ee=Math.cos(Z);H[A]=(F+X)*O,H[S]=(V-te)*x,Y[w]=0,Y[A]=$*Math.sign(H[A]),Y[S]=ee*Math.sign(H[S]);for(let Q=0;Q<q;Q++){let W=Q*B-R;H[w]=W*P,d.push(H.x,H.y,H.z),p.push(Y.x,Y.y,Y.z),f.push(Q/I),f.push(0),k+=1}}for(let J=0;J<l;J++)for(let Z=0;Z<I;Z++){let X=h+Z+q*J,te=h+Z+q*(J+1),$=h+(Z+1)+q*(J+1),ee=h+(Z+1)+q*J;c.push(X,te,ee),c.push(te,$,ee),U+=6}u.addGroup(m,U,E),m+=U,h+=k}function b(w,A,S){let P=new rl,O=new rl(t/2,e/2,r/2);O.subScalar(s);let x=[],D=w*A*S>0?(T,I,E)=>c.push(T,I,E):(T,I,E)=>c.push(T,E,I);for(let T=0;T<=l;T++){let I=[],E=kp*(1-T/l),B=Math.cos(E),R=Math.sin(E),F=0;for(let V=0;V<=T;V++){let q=Math.cos(F),k=Math.sin(F);P.x=B*q,P.y=R,P.z=B*k;let U=O.clone().addScaledVector(P,s);d.push(w*U.x,A*U.y,S*U.z),p.push(w*P.x,A*P.y,S*P.z),f.push(0,0),I.push(h++),F+=kp/T}x.push(I)}let N=x.length-1;for(let T=0;T<N;T++){let I=x[T],E=x[T+1],B=I.length-1;D(I[0],E[1],E[0]);for(let R=1;R<=B;R++)D(I[R-1],I[R],E[R]),D(I[R],E[R+1],E[R])}}}};import{BufferGeometry as HT,Float32BufferAttribute as Up,Triangle as qT,Vector3 as $o,Vector2 as Hp}from"three";var Pn=class extends HT{constructor(t=[],e=[],r="",o=1,i=.2,a=4){super(),this.type="PolyhedronGeometryRound";let s=[],l=[],u=[];c(),d(),this.setAttribute("position",new Up(s,3)),this.setAttribute("normal",new Up(u,3)),this.setAttribute("uv",new Up(l,2));return;function c(){i=Math.min(1-1e-5,i),i==0&&(a=0);let f={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[r],h=new $o,m=h.clone(),y=new qT,g=i*o,b=o-g,w=a+1,A=new $o,S=(k,U)=>A.subVectors(k,U).normalize(),P=(k,U)=>Array(k).fill(void 0).map(U),O=P(t.length/3,(k,U)=>new $o().fromArray(t,U*3).setLength(o)),x=[],D=1e6;for(let k=0;k<O.length;k++){let U=O[k],H=[],Y,J,Z,X=1e10,te=-1;for(;(te=e.indexOf(k,te+1))!=-1;){let W=te-te%3;Y=e[W+(te+1)%3],J=e[W+(te+2)%3],Z=U.distanceToSquared(O[Y]),X=Math.min(X,Z),H.push([Y,J,Z])}X+=1e-6;let $=[],ee=0,Q=H.length;for(let W=0;W<Q;W++){[Y,J,Z]=H[ee];let ue=x[Y]?.includes(k)==!0;Z<=X&&$.push(Y+ +ue*D),ee=H.findIndex(le=>le[0]==J)}x.push($)}let N=[];{let k=0,U=0,H,Y,J=f==3;for(let Z=0;Z<=a;Z++){H=Z*(Z+1)/2,Y=(Z+1)*(Z+2)/2;for(let X=0;X<a-Z;X++)[k,U]=[H+X+Z+2,Y+X+Z+3],N.push(H,Y,...J?[U,H]:[k,Y],U,k),[H,Y]=[k,U];N.push(H,Y,H+a+2)}}let T=h.clone(),I=h.clone(),E=h.clone(),B=h.clone(),R=h.clone(),F=[],V=P(O.length,()=>P(f,()=>h.clone()));for(let k=0;k<O.length;k++){h.copy(O[k]).normalize(),T.copy(h).multiplyScalar(b);let U=x[k];for(let $=0;$<U.length;$++){let ee=U[$],Q=U[($+1)%f];y.setFromPointsAndIndices(O,k,ee%D,Q%D),y.b.sub(y.a).setLength(1e10).add(y.a),y.c.sub(y.a).setLength(1e10).add(y.a),y.closestPointToPoint(T,V[k][$])}let H=[],Y=[],J=[],Z=new $o;a==0&&[...V[k]].reduce(($,ee)=>$.add(ee),Z).multiplyScalar(1/f);for(let $=0;$<f;$++){let ee=[],Q=($-1+f)%f,W=V[k][Q],ue=V[k][$];h.copy(W).sub(T),m.copy(ue).sub(T);let le=T.angleTo(h),ne=h.angleTo(m),ce=Math.cos(le)*g;a==0?I.copy(Z):I.copy(T).setLength(b+ce),Y.push(ce);let ae=[I,W,ue];for(let he=0;he<2;he++){let pe=ae[he],fe=ae[he+1];B.subVectors(pe,T),R.subVectors(fe,T),E.crossVectors(B,R).normalize();for(let ge=0;ge<w;ge++){let me=[le,ne][he]*ge/w;h.copy(B).applyAxisAngle(E,me).add(T),H.push(h.clone()),he&&(S(h,T),ee.push([ge==0?pe:h.clone(),A.clone()]))}he&&(S(fe,T),ee.push([fe,A.clone()]))}J.push(ee)}F.push(J);let X=2*w,te=2;for(let $=0;$<f;$++){let ee=X*$,Q=X*(($+1)%f),W=[H[ee]];for(let le=1;le<w;le++){B=H[ee+le],R=H[Q+le],W.push(B);for(let ne=1,ce=le-te+1;ne<=ce;ne++)h.lerpVectors(B,R,ne/(ce+1)),h.sub(T).setLength(Y[$]).add(T),W.push(h.clone());W.push(R)}for(let le=0;le<w;le++)W.push(H[le+w+ee]);W.push(H[Q+w]);let ue=N.map(le=>W[le]);s.push(...ue.map(le=>[le.x,le.y,le.z]).flat()),u.push(...ue.map(le=>(S(le,T),[A.x,A.y,A.z])).flat())}}let q=[];for(let k=0;k<x.length;k++)for(let U=0;U<f;U++){let H=x[k][U];if(H<D){let Y=x[H].findIndex(X=>X%D==k),J=F[k][U],Z=F[H][Y];for(let X=0;X<w;X++){let te=J[X],$=Z[w-X],ee=J[X+1],Q=Z[w-(X+1)];[te,$,ee,ee,$,Q].forEach(W=>{s.push(W[0].x,W[0].y,W[0].z),u.push(W[1].x,W[1].y,W[1].z)})}q.push(J[0][0],Z[w][0],J[w][0],Z[0][0])}}for(;q.length;){let k,U,H,Y;[k,U]=q.splice(0,2);let J=[k];for(;k!=U;)J.push(U),H=q.indexOf(U),Y=H%2,U=q.splice(H-Y,2)[1-Y];A.subVectors(J[0],J[1]).cross(h.subVectors(J[0],J[2])).normalize();let Z=A.dot(J[0])<0;Z&&A.negate();for(let X=1;X<=J.length-2;X++)[J[X+ +Z],J[X+1-+Z],J[0]].forEach(te=>{s.push(te.x,te.y,te.z),u.push(A.x,A.y,A.z)})}}function d(){let p=new $o;for(let O=0;O<s.length;O+=3){p.x=s[O+0],p.y=s[O+1],p.z=s[O+2];let x=S(p)/2/Math.PI+.5,D=P(p)/Math.PI+.5;l.push(x,1-D)}let f=new $o,h=new $o,m=new $o,y=new $o,g=new Hp,b=new Hp,w=new Hp,A=(O,x,D,N)=>{N<0&&O.x===1&&(l[x]=O.x-1),D.x===0&&D.z===0&&(l[x]=N/2/Math.PI+.5)};for(let O=0,x=0;O<s.length;O+=9,x+=6){f.set(s[O+0],s[O+1],s[O+2]),h.set(s[O+3],s[O+4],s[O+5]),m.set(s[O+6],s[O+7],s[O+8]),g.set(l[x+0],l[x+1]),b.set(l[x+2],l[x+3]),w.set(l[x+4],l[x+5]),y.copy(f).add(h).add(m).divideScalar(3);let D=S(y);A(g,x+0,f,D),A(b,x+2,h,D),A(w,x+4,m,D)}for(let O=0;O<l.length;O+=6){let x=l[O+0],D=l[O+2],N=l[O+4],T=Math.max(x,D,N),I=Math.min(x,D,N);T>.9&&I<.1&&(x<.2&&(l[O+0]+=1),D<.2&&(l[O+2]+=1),N<.2&&(l[O+4]+=1))}function S(O){return Math.atan2(O.z,-O.x)}function P(O){return Math.atan2(-O.y,Math.sqrt(O.x*O.x+O.z*O.z))}}}static fromJSON(t){return new Pn(t.vertices,t.indices,t.radius,t.corner,t.cornerSides)}};import{DodecahedronGeometry as WT}from"three";var K0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.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:t,height:e,depth:r,detail:o,corner:i,cornerSides:a}=n.parameters,s=o===0&&i!==0?new ol(t*.5,i,a):new WT(t*.5,o);return s.scale(1,e/t,r/t),Object.assign(s,{userData:{...n,type:"DodecahedronGeometry"}})}},ol=class extends Pn{constructor(t=1,e=.2,r=4){let o=(1+Math.sqrt(5))/2,i=1/o,a=[-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],s=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],l="DodecahedronGeometry";super(a,s,l,t,e,r),this.type=l}static fromJSON(t){return new ol(t.radius,t.corner,t.cornerSides)}};import{Plane as oM,Shape as px,Vector2 as Yo,Vector3 as nM,MathUtils as Kp,LineCurve as Zp,QuadraticBezierCurve as fx,CubicBezierCurve as xu}from"three";import{CubicBezierCurve as mu,EllipseCurve as $T,LineCurve as yu,LineCurve3 as YT,MathUtils as XT,QuadraticBezierCurve as Wp,SplineCurve as QT,Vector2 as Jt,Vector3 as ex}from"three";var nl=1e-12,Ma=class{constructor(t){this.position=new Jt;this.startPosition=new Jt;this.uuid=XT.generateUUID();this.position=t.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(t){this.position.copy(this.startPosition).add(t)}copy(t){return this.position.copy(t.position),this.startPosition.copy(t.startPosition),this}clone(){return new Ma(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},Ia=class extends Ma{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new Ia(this.parent).copy(this)}},Xr=class extends Ma{constructor(e,r){super(r);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new Ia(this),new Ia(this))}static create(e,r){let o=new Xr(e,new Jt(...r.position));return o.controls[0].position.set(...r.controlPrevious.position),o.controls[1].position.set(...r.controlNext.position),o.roundness=r.roundness,o.areControlsDirectionsMirrored=r.areControlsDirectionsMirrored,o}getOppositeControl(e){let r=this.controls.indexOf(e);return r===0?this.controls[1]:r===1?this.controls[0]:null}applyOffsetToControls(e,r=1){for(let o=0,i=this.controls.length;o<i;o++){let a=this.controls[o];this.position.distanceTo(a.position)<=r?a.position.copy(this.position):a.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 Xr(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),r=this.curveAfter?.getTangentAt(0);return[e,r]}computeNormals(e=new Jt,r=new Jt){let[o,i]=this.computeTangents();return o&&i&&(Z0(o,e),Z0(i,r)),[e,r]}computeTangent(e=new Jt){let[r,o]=this.computeTangents();return r&&o&&e.copy(r).add(o).normalize(),e}computeNormal(e=new Jt){let[r,o]=this.computeNormals();return e.copy(r).add(o).normalize(),e}};function Z0(n,t=new Jt){let e=n.length();return t.set(-n.y/e,n.x/e)}var $p=n=>n,Na=new Jt,gu=new Jt,KT=new Jt,ZT=new Jt,JT=new Jt,eM=new Jt,tx=new ex,rx=new ex;function ox(n){let t=new Jt;t.addVectors(n.v0,Na.subVectors(n.v1,n.v0).multiplyScalar(2/3));let e=new Jt;return e.addVectors(n.v2,gu.subVectors(n.v1,n.v2).multiplyScalar(2/3)),new mu(n.v0,t,e,n.v2)}function il(n,t,e=Number.EPSILON){return Math.abs(n-t)<e}function tM(n,t,e=Number.EPSILON){return n.distanceTo(t)<e}function rM(n,t,e=Number.EPSILON){return n.distanceTo(t)<e}function Yp(n,t,e){let r=Math.sqrt(Math.pow(t.x-n.x,2)+Math.pow(t.y-n.y,2)),o=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.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+r*r-i*i)/(2*o*r))}function nx(n,t,e){return J0(n,t)&&J0(t,e)&&qp(n.position,t.position,e.position)}function qp(n,t,e){return Na.copy(t).sub(n).cross(gu.copy(e).sub(n))===0}function ix(n,t,e,r,o){let i=Math.sqrt(Math.pow(t.x-n.x,2)+Math.pow(t.y-n.y,2)),a=(n.y+t.y)/2,s=(n.x+t.x)/2,l=Math.sqrt(Math.pow(e,2)-Math.pow(i/2,2))*(n.y-t.y)/i,u=Math.sqrt(Math.pow(e,2)-Math.pow(i/2,2))*(t.x-n.x)/i;return r.set(s+l,a+u),o.set(s-l,a-u),[r,o]}function ax(n,t,e){let r=n.distanceTo(e),o=t.distanceTo(e);return r<o?t:n}function sx(n,t,e,r,o,i){let a=t.x-n.x,s=t.y-n.y,l=e.x-n.x,u=e.y-n.y,c=Math.sqrt((a+l)*(a+l)+(s+u)*(s+u)),d;return Yp(t,n,e)>Math.PI&&(c*=-1),il(u,s)?d=(s+u)*(r/c-.5)*8/3/(a-l):d=(a+l)*(r/c-.5)*8/3/(u-s),o.set(t.x-d*s,t.y+d*a),i.set(e.x+d*u,e.y-d*l),[o,i]}function Xp(n,t){return n.position.equals(n.controls[1].position)&&t.position.equals(t.controls[0].position)}function J0(n,t){return qp(n.position,n.controls[1].position,t.position)&&qp(n.position,t.controls[0].position,t.position)}function lx(n,t,e,r,o=.5){let i=Na.subVectors(t,n).multiplyScalar(o).add(n),a=gu.subVectors(e,t).multiplyScalar(o).add(t),s=KT.subVectors(r,e).multiplyScalar(o).add(e),l=i,u=ZT.subVectors(a,i).multiplyScalar(o).add(i),c=JT.subVectors(s,a).multiplyScalar(o).add(a),d=s,p=eM.subVectors(c,u).multiplyScalar(o).add(u);return[n.x,n.y,l.x,l.y,u.x,u.y,p.x,p.y,c.x,c.y,d.x,d.y,r.x,r.y]}function cx(n,t,e=12,r=!0){let o=rx.set(0,0,0),i,a=0,s=[];for(let l=0;l<t.length;l++){let u=$p(t[l]),c=Na,d=On(u,e);s.push(d);for(let p=0;p<=d;p++)if(u instanceof mu||u instanceof Wp||u instanceof yu){if(u.getPoint(p/d,c),o.set(c.x,c.y,0),i!==void 0&&rM(i,o))continue;i===void 0&&(i=tx),i.copy(o),n.setXYZ(a,o.x,o.y,o.z),a++}}return r&&a>1&&!(n.getX(a-1)===n.getX(0)&&n.getY(a-1)===n.getY(0)&&n.getZ(a-1)===n.getZ(0))&&(n.setXYZ(a,n.getX(0),n.getY(0),n.getZ(0)),a++),n}function ux(n,t,e,r=12,o=!0){let i=rx.set(0,0,0),a=0,s=[];for(let l=0;l<t.length;l++){if(e[l]===!1)continue;let u,c=$p(t[l]),d=Na,p=On(c,r);s.push(p);for(let f=0;f<=p;f++)if(c instanceof mu||c instanceof Wp||c instanceof yu){if(c.getPoint(f/p,d),i.set(d.x,d.y,0),u?.equals(i))continue;u===void 0?u=tx:(n.setXYZ(a,u.x,u.y,u.z),a++,n.setXYZ(a,i.x,i.y,i.z),a++),u.copy(i)}}return o&&a>1&&!(n.getX(a-1)===n.getX(0)&&n.getY(a-1)===n.getY(0)&&n.getZ(a-1)===n.getZ(0))&&(n.setXYZ(a,n.getX(0),n.getY(0),n.getZ(0)),a++),s}function Qp(n,t=12,e=!1){let r=[];for(let o=0,i=n.length;o<i;o++){let a=n[o],s=0;if(e&&a.roundedCurveCorner!==void 0){let l=On(a.roundedCurveCorner,t)*.5;o>0&&(r[o-1]+=l),s+=l}a.curveAfter!==void 0&&(s+=On(a.curveAfter,t)),r.push(s)}return n.length>0&&e&&n[0].roundedCurveCorner!==void 0&&(r[n.length-1]+=On(n[0].roundedCurveCorner,t)*.5),r}function On(n,t=12){return n&&n instanceof $T?t*2:n&&(n instanceof yu||n instanceof YT)?1:n&&n instanceof QT?t*n.points.length:t}function dx(n,t,e=12,r=!0){let o,i=0;for(let a=0;a<t.length;a++){let s=$p(t[a]),l=On(s,e),u=Na;for(let c=0;c<=l;c++)if(s instanceof mu||s instanceof Wp||s instanceof yu){if(s.getPoint(c/l,u),o!==void 0&&tM(o,u,nl))continue;o===void 0&&(o=gu),o.copy(u),n.push(u.x,u.y),i++}}return il(n[0],n[n.length-2],nl)&&il(n[1],n[n.length-1],nl)&&(n.pop(),n.pop()),r&&i>1&&!(il(n[i-1],n[1],nl)&&il(n[i-2],n[0],nl))&&(n.push(n[0],n[1]),i++),n}var Jp=new Yo,iM=new Yo,aM=new Yo,sM=new Yo,lM=new Yo,cM=new Yo,He=class extends px{constructor(e=100,r=100){super();this.points=[];this.shapeHoles=[];this.plane=new oM(new nM(0,0,-1));this.subdivision=0;this.controlSnapDistance=4;this.pointIDs=0;this.isMesh2D=!1;this.isText=!1;this._roundness=0;this.isClosed=!1;this.useCubicForRoundedCorners=!0;this.uuid=Kp.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=r}static createFromState(e,r,o){let i=new He;return i.isClosed=e.isClosed,i.points=e.points.map(a=>Xr.create(a.id,a.data)),typeof e.roundness=="number"&&(i.roundness=e.roundness),i.shapeHoles=e.shapeHoles.map(a=>He.createFromState(a)),r!==void 0&&o!==void 0&&i.applySize(r,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 r=0,o=this.points.length;r<o;r++)this.points[r].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(r=>this.getPointIndexById(r)).filter(r=>r>=0)}getPointIndexById(e){let r=this.points.length,o=this.points.findIndex(i=>i.uuid===e);if(o<0){let i=r;for(let a=0,s=this.shapeHoles.length;a<s;a++){let l=this.shapeHoles[a],u=l.points.length,c=l.getPointIndexById(e);if(c<0)i+=u;else return c+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 r=this.points.length;for(let o=0,i=this.shapeHoles.length;o<i;o++){let a=this.shapeHoles[o],s=e-r;if(s<=a.points.length-1)return a.points[s];r+=a.points.length}}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let r=this.points.indexOf(e);if(r>=0)return r;if(r=this.points.length,this.shapeHoles.length>0)for(let o=0,i=this.shapeHoles.length;o<i;o++){let a=this.shapeHoles[o],s=a.points.indexOf(e);if(s>=0)return r+s;r+=a.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(r=>r.points));return[...this.points,...e]}applySize(e,r){e===0&&(e=.001),r===0&&(r=.001),this._width=e,this._height=r}applyScale(e,r){let o=Jp.set(e,r);for(let i=0,a=this.points.length;i<a;i++){let s=this.points[i];s.position.multiply(o),s.controls[0].position.multiply(o),s.controls[1].position.multiply(o)}for(let i=0,a=this.shapeHoles.length;i<a;i++)this.shapeHoles[i].applyScale(e,r);this._update()}createPoint(e,r=0,o=Kp.generateUUID()){let i;e instanceof Yo?i=e:i=new Yo(e,r);let a=new Xr(o,i);return a.roundness=this.roundness,a}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,r){this.points.splice(r,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let r=0,o=this.points.length;r<o;r++){let i=this.points[r];if(i.uuid===e)return i}for(let r=0,o=this.shapeHoles.length;r<o;r++){let a=this.shapeHoles[r].getPointByUuid(e);if(a)return a}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){let r=this.points.indexOf(e);r>=0&&this.points.splice(r,1),this.needsUpdate=!0}removePointById(e){let r=this.points.find(o=>o.uuid===e);r&&this.removePoint(r)}update(){for(let e=0,r=this.shapeHoles.length;e<r;e++)this.shapeHoles[e].update();this._update()}extractShapePointsToBuffer(e,r=12,o=!1){this.subdivision=r,this.curveDivisions===void 0&&this.computeCurveDivisions(r);let i=o?this.roundedCurveDivisions:this.curveDivisions;return cx(e,o?this.roundedCurves:this.curves,r,this.autoClose),i.reduce((a,s)=>a+s,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=Qp(this.points,e,!1),this.roundedCurveDivisions=Qp(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,r,o=12){return ux(e,this.curves,r,o,this.autoClose).reduce((a,s)=>a+s,0)*2}extractShapePointsToFlatArray(e,r=12){return this.subdivision=r,this.curveDivisions===void 0&&this.computeCurveDivisions(r),dx(e,this.roundedCurves,r,this.autoClose)}getCurveIndexFromVertexId(e,r=!1){let o=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let i=r?this.roundedCurveDivisions:this.curveDivisions,a=0;r&&this.points[0].roundedCurveCorner!==void 0&&(a=On(this.points[0].roundedCurveCorner,this.subdivision)*.5);let s=e-a;s<0&&(s+=i.reduce((l,u)=>l+u,0));for(let l=0,u=i.length;l<u;l++){let c=i[l];if(s<o+c)return[l,(s-o+1)/c];o+=c}return[0,1]}getCurveT(e,r,o){let i=this.points[e],a=this.points[e>=this.points.length-1?0:e+1],s=this.curveDivisions,l=s[e];if(Xp(i,a)){let d=i.position.distanceTo(a.position);return i.position.distanceTo(Jp.set(o.x,o.y))/d}let u=0;for(let d=0;d<e;d++)u+=s[d];return(r-u)/l}dispose(){}_applyCurveForPoint(e,r){Xp(r,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(r.controls[1].position.x,r.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,r.curveAfter=o;let i=o.clone();e.roundedCurveBefore=i,r.roundedCurveAfter=i,e.roundedCurveCorner=void 0,this.roundedCurves.push(i)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let r=0,o=this.points.length;r<o;r++){let i=this.points[r];if(r===0)this.moveTo(i.position.x,i.position.y);else{let a=this.points[r-1];this._applyCurveForPoint(i,a)}}let e=this.getLastPoint();if(e?.curveAfter&&(e.curveAfter=void 0),this.isClosed){let r=this.points[0],o=this.points[this.points.length-1];this._applyCurveForPoint(r,o)}if(this.points.length>2){let r=0;for(let o=0,i=this.points.length;o<i;o++){let a=this.points[o],s=this.points[o-1]??this.points[this.points.length-1],l=this.points[o+1]??this.points[0],u=a.roundness,c=s&&l&&nx(s,a,l);if(!a.controlsMoved()&&u>0&&!c){let d=a.curveBefore,p=a.curveAfter;if(d===void 0||p===void 0)continue;let f=a.roundedCurveBefore,h=a.roundedCurveAfter,m=d.getLength(),y=p.getLength(),g=Math.min(u,m*.499),b=Math.min(u,y*.499),w=Math.min(g,b),A=1-w/m,S=w/y,P=d.getPointAt(A,Jp),O=p.getPointAt(S,iM);this._subSplitCurve(d,f,A,P,void 0),this._subSplitCurve(p,h,S,void 0,O);let x;if(this.useCubicForRoundedCorners){let D=Yp(P,a.position,O)/2,N=Math.tan(D)*P.distanceTo(a.position),[T,I]=ix(P,O,N,aM,sM),E=ax(T,I,a.position),[B,R]=sx(E,P,O,N,lM,cM);x=new xu(P.clone(),B.clone(),R.clone(),O.clone())}else x=new fx(P.clone(),a.position.clone(),O.clone());a.roundedCurveCorner=x,this.roundedCurves.splice(o+r,0,x),r++}}}}_subSplitCurve(e,r,o,i,a){if(e instanceof Zp)i!==void 0&&r.v2.copy(i),a!==void 0&&r.v1.copy(a);else{let s=e,l=r,u=s.getUtoTmapping(o,0),c=lx(s.v0,s.v1,s.v2,s.v3,u);return i!==void 0&&(l.v0.set(c[0],c[1]),l.v1.set(c[2],c[3]),l.v2.set(c[4],c[5]),l.v3.set(c[6],c[7])),a!==void 0&&(l.v0.set(c[6],c[7]),l.v1.set(c[8],c[9]),l.v2.set(c[10],c[11]),l.v3.set(c[12],c[13])),l}return r}clone(){let e=new He(this._width,this._height);return e.points=this.points.map(r=>r.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(r=>r.clone()),e}toJSON(){return{points:this.points.reduce((e,r)=>e.concat(r.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){this.points=[],this.pointIDs=0;let r=e.points.length/7;for(let o=0;o<r;o++){let i=o*7,a=e.points[i+0],s=e.points[i+1],l=e.points[i+2],u=e.points[i+3],c=e.points[i+4],d=e.points[i+5],p=e.points[i+6],f=new Xr(Kp.generateUUID(),new Yo(a,s));f.controls[0].position.set(l,u),f.controls[1].position.set(c,d),f.roundness=p,this.points.push(f)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(o=>{let i=new He;return i.fromJSON(o),i}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e,r=!1){this.isText=r;let o=(a,s)=>{s instanceof xu&&s.v3.equals(a.position)&&a.controls[0].position.copy(s.v2)},i=a=>{let s=[],l,u;for(l=0,u=a.length;l<u;l++)a[l]instanceof fx&&(a[l]=ox(a[l]));for(l=0,u=a.length;l<u;l++){let p=a[l],f=l>0?a[l-1]:null,h;p instanceof xu?(h=this.createPoint(p.v0),h.controls[1].position.copy(p.v1)):p instanceof Zp&&(h=this.createPoint(p.v1)),h!==void 0&&(f!==null&&o(h,f),s.push(h))}let c=a[a.length-1],d=!1;return c instanceof xu?c.v3.equals(s[0].position)&&(s[0].controls[0].position.copy(c.v2),d=!0):c instanceof Zp&&c.v2.equals(s[0].position)&&(d=!0),this.isClosed=d,s};return this.points=i(e.curves),e instanceof px&&(this.shapeHoles=e.holes.map(a=>{let s=new He;return s.fromShape(a),s})),this.update(),this}updatePoint(e,r){let o=this.getPointByUuid(e);o&&(r.position!==void 0&&o.position.fromArray(r.position),r.roundness!==void 0&&(o.roundness=r.roundness),r.areControlsDirectionsMirrored!==void 0&&(o.areControlsDirectionsMirrored=r.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(e,r){let i=this.getPointByUuid(e)?.controls[0];i&&(r.position&&i.position.fromArray(r.position),this.needsUpdate=!0)}updateNextControl(e,r){let i=this.getPointByUuid(e)?.controls[1];i&&(r.position&&i.position.fromArray(r.position),this.needsUpdate=!0)}};var tf=Math.PI*2;function ef({x:n,y:t},e,r,o,i){return{x:n*e+o,y:t*r+i}}function uM(n,t){let e=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),r=Math.cos(n),o=Math.sin(n),i=Math.cos(n+t),a=Math.sin(n+t);return[{x:r-o*e,y:o+r*e},{x:i+a*e,y:a-i*e},{x:i,y:a}]}function hx(n,t,e,r){let o=n*r-t*e<0?-1:1,i=Math.min(1,Math.max(-1,n*e+t*r));return o*Math.acos(i)}function dM(n,t,e,r,o,i,a,s,l,u){let c=Math.pow(o,2),d=Math.pow(i,2),p=Math.pow(a,2),f=Math.pow(s,2),h=c*d-c*f-d*p;h<0&&(h=0),h/=c*f+d*p,h=Math.sqrt(h)*(l===u?-1:1);let m=h*o/i*s,y=h*-i/o*a,g=m+(n+e)/2,b=y+(t+r)/2,w=(a-m)/o,A=(s-y)/i,S=(-a-m)/o,P=(-s-y)/i,O=hx(1,0,w,A),x=hx(w,A,S,P);return!u&&x>0&&(x-=tf),u&&x<0&&(x+=tf),{centerx:g,centery:b,ang1:O,ang2:x}}function mx({px:n,py:t,cx:e,cy:r,rx:o,ry:i,largeArcFlag:a,sweepFlag:s}){let l=[];if(o===0||i===0)return[];let u=(n-e)/2,c=(t-r)/2;if(u===0&&c===0)return[];o=Math.abs(o),i=Math.abs(i);let d=Math.pow(u,2)/Math.pow(o,2)+Math.pow(c,2)/Math.pow(i,2);d>1&&(o*=Math.sqrt(d),i*=Math.sqrt(d));let p=dM(n,t,e,r,o,i,u,c,a,s),{ang1:f,ang2:h}=p,{centerx:m,centery:y}=p,g=Math.abs(h)/(tf/4);Math.abs(1-g)<1e-7&&(g=1);let b=Math.max(Math.ceil(g),1);h/=b;for(let w=0;w<b;w++)l.push(uM(f,h)),f+=h;return l.map(w=>{let{x:A,y:S}=ef(w[0],o,i,m,y),{x:P,y:O}=ef(w[1],o,i,m,y),{x,y:D}=ef(w[2],o,i,m,y);return{x1:A,y1:S,x2:P,y2:O,x,y:D}})}import{BufferAttribute as Au,BufferGeometry as AM}from"three";var je;(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"})(je||(je={}));var dt;(function(n){n[n.POLYGONS=0]="POLYGONS",n[n.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",n[n.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(dt||(dt={}));function Ae(n,t){if(!n)throw t||"Assertion Failed!"}var ve=function(){function n(){}return n.vertEq=function(t,e){return t.s===e.s&&t.t===e.t},n.vertLeq=function(t,e){return t.s<e.s||t.s===e.s&&t.t<=e.t},n.transLeq=function(t,e){return t.t<e.t||t.t===e.t&&t.s<=e.s},n.edgeGoesLeft=function(t){return n.vertLeq(t.Dst,t.Org)},n.edgeGoesRight=function(t){return n.vertLeq(t.Org,t.Dst)},n.vertL1dist=function(t,e){return Math.abs(t.s-e.s)+Math.abs(t.t-e.t)},n.edgeEval=function(t,e,r){Ae(n.vertLeq(t,e)&&n.vertLeq(e,r));var o=e.s-t.s,i=r.s-e.s;return o+i>0?o<i?e.t-t.t+(t.t-r.t)*(o/(o+i)):e.t-r.t+(r.t-t.t)*(i/(o+i)):0},n.edgeSign=function(t,e,r){Ae(n.vertLeq(t,e)&&n.vertLeq(e,r));var o=e.s-t.s,i=r.s-e.s;return o+i>0?(e.t-r.t)*o+(e.t-t.t)*i:0},n.transEval=function(t,e,r){Ae(n.transLeq(t,e)&&n.transLeq(e,r));var o=e.t-t.t,i=r.t-e.t;return o+i>0?o<i?e.s-t.s+(t.s-r.s)*(o/(o+i)):e.s-r.s+(r.s-t.s)*(i/(o+i)):0},n.transSign=function(t,e,r){Ae(n.transLeq(t,e)&&n.transLeq(e,r));var o=e.t-t.t,i=r.t-e.t;return o+i>0?(e.s-r.s)*o+(e.s-t.s)*i:0},n.vertCCW=function(t,e,r){return t.s*(e.t-r.t)+e.s*(r.t-t.t)+r.s*(t.t-e.t)>=0},n.interpolate=function(t,e,r,o){return t=t<0?0:t,r=r<0?0:r,t<=r?r===0?(e+o)/2:e+(o-e)*(t/(t+r)):o+(e-o)*(r/(t+r))},n.intersect=function(t,e,r,o,i){var a,s,l;n.vertLeq(t,e)||(l=t,t=e,e=l),n.vertLeq(r,o)||(l=r,r=o,o=l),n.vertLeq(t,r)||(l=t,t=r,r=l,l=e,e=o,o=l),n.vertLeq(r,e)?n.vertLeq(e,o)?(a=n.edgeEval(t,r,e),s=n.edgeEval(r,e,o),a+s<0&&(a=-a,s=-s),i.s=n.interpolate(a,r.s,s,e.s)):(a=n.edgeSign(t,r,e),s=-n.edgeSign(t,o,e),a+s<0&&(a=-a,s=-s),i.s=n.interpolate(a,r.s,s,o.s)):i.s=(r.s+e.s)/2,n.transLeq(t,e)||(l=t,t=e,e=l),n.transLeq(r,o)||(l=r,r=o,o=l),n.transLeq(t,r)||(l=t,t=r,r=l,l=e,e=o,o=l),n.transLeq(r,e)?n.transLeq(e,o)?(a=n.transEval(t,r,e),s=n.transEval(r,e,o),a+s<0&&(a=-a,s=-s),i.t=n.interpolate(a,r.t,s,e.t)):(a=n.transSign(t,r,e),s=-n.transSign(t,o,e),a+s<0&&(a=-a,s=-s),i.t=n.interpolate(a,r.t,s,o.t)):i.t=(r.t+e.t)/2},n}(),al=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}(),bu=function(){function n(t){this.side=t,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(t){this.Sym.Lface=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(t){this.Sym.Org=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(t){this.Sym.Lnext=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(t){this.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(t){this.Lnext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(t){this.Sym.Onext=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(t){this.Sym.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(t){this.Sym.Lnext.Sym=t},enumerable:!0,configurable:!0}),n}(),Da=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}(),yx=function(){function n(){var t=new Da,e=new al,r=new bu(0),o=new bu(1);t.next=t.prev=t,t.anEdge=null,e.next=e.prev=e,r.next=r,r.Sym=o,o.next=o,o.Sym=r,this.vHead=t,this.fHead=e,this.eHead=r,this.eHeadSym=o}return n.prototype.makeEdge_=function(t){var e=new bu(0),r=new bu(1);t.Sym.side<t.side&&(t=t.Sym);var o=t.Sym.next;return r.next=o,o.Sym.next=e,e.next=t,t.Sym.next=r,e.Sym=r,e.Onext=e,e.Lnext=r,e.Org=null,e.Lface=null,e.winding=0,e.activeRegion=null,r.Sym=e,r.Onext=r,r.Lnext=e,r.Org=null,r.Lface=null,r.winding=0,r.activeRegion=null,e},n.prototype.splice_=function(t,e){var r=t.Onext,o=e.Onext;r.Sym.Lnext=e,o.Sym.Lnext=t,t.Onext=o,e.Onext=r},n.prototype.makeVertex_=function(t,e,r){var o=t;Ae(o,"Vertex can't be null!");var i=r.prev;o.prev=i,i.next=o,o.next=r,r.prev=o,o.anEdge=e;var a=e;do a.Org=o,a=a.Onext;while(a!==e)},n.prototype.makeFace_=function(t,e,r){var o=t;Ae(o,"Face can't be null");var i=r.prev;o.prev=i,i.next=o,o.next=r,r.prev=o,o.anEdge=e,o.trail=null,o.marked=!1,o.inside=r.inside;var a=e;do a.Lface=o,a=a.Lnext;while(a!==e)},n.prototype.killEdge_=function(t){t.Sym.side<t.side&&(t=t.Sym);var e=t.next,r=t.Sym.next;e.Sym.next=r,r.Sym.next=e},n.prototype.killVertex_=function(t,e){var r=t.anEdge,o=r;do o.Org=e,o=o.Onext;while(o!==r);var i=t.prev,a=t.next;a.prev=i,i.next=a},n.prototype.killFace_=function(t,e){var r=t.anEdge,o=r;do o.Lface=e,o=o.Lnext;while(o!==r);var i=t.prev,a=t.next;a.prev=i,i.next=a},n.prototype.makeEdge=function(){var t=new Da,e=new Da,r=new al,o=this.makeEdge_(this.eHead);return this.makeVertex_(t,o,this.vHead),this.makeVertex_(e,o.Sym,this.vHead),this.makeFace_(r,o,this.fHead),o},n.prototype.splice=function(t,e){var r=!1,o=!1;if(t!==e){if(e.Org!==t.Org&&(o=!0,this.killVertex_(e.Org,t.Org)),e.Lface!==t.Lface&&(r=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(e,t),!o){var i=new Da;this.makeVertex_(i,e,t.Org),t.Org.anEdge=t}if(!r){var a=new al;this.makeFace_(a,e,t.Lface),t.Lface.anEdge=t}}},n.prototype.delete=function(t){var e=t.Sym,r=!1;if(t.Lface!==t.Rface&&(r=!0,this.killFace_(t.Lface,t.Rface)),t.Onext===t)this.killVertex_(t.Org,null);else if(t.Rface.anEdge=t.Oprev,t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev),!r){var o=new al;this.makeFace_(o,t,t.Lface)}e.Onext===e?(this.killVertex_(e.Org,null),this.killFace_(e.Lface,null)):(t.Lface.anEdge=e.Oprev,e.Org.anEdge=e.Onext,this.splice_(e,e.Oprev)),this.killEdge_(t)},n.prototype.addEdgeVertex=function(t){var e=this.makeEdge_(t),r=e.Sym;this.splice_(e,t.Lnext),e.Org=t.Dst;var o=new Da;return this.makeVertex_(o,r,e.Org),e.Lface=r.Lface=t.Lface,e},n.prototype.splitEdge=function(t){var e=this.addEdgeVertex(t),r=e.Sym;return this.splice_(t.Sym,t.Sym.Oprev),this.splice_(t.Sym,r),t.Dst=r.Org,r.Dst.anEdge=r.Sym,r.Rface=t.Rface,r.winding=t.winding,r.Sym.winding=t.Sym.winding,r.idx=t.idx,r.Sym.idx=t.Sym.idx,r},n.prototype.connect=function(t,e){var r=!1,o=this.makeEdge_(t),i=o.Sym;if(e.Lface!==t.Lface&&(r=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(o,t.Lnext),this.splice_(i,e),o.Org=t.Dst,i.Org=e.Org,o.Lface=i.Lface=t.Lface,t.Lface.anEdge=i,!r){var a=new al;this.makeFace_(a,o,t.Lface)}return o},n.prototype.zapFace=function(t){var e=t.anEdge,r,o,i,a,s;o=e.Lnext;do r=o,o=r.Lnext,r.Lface=null,r.Rface===null&&(r.Onext===r?this.killVertex_(r.Org,null):(r.Org.anEdge=r.Onext,this.splice_(r,r.Oprev)),i=r.Sym,i.Onext===i?this.killVertex_(i.Org,null):(i.Org.anEdge=i.Onext,this.splice_(i,i.Oprev)),this.killEdge_(r));while(r!=e);a=t.prev,s=t.next,s.prev=a,a.next=s},n.prototype.countFaceVerts_=function(t){var e=t.anEdge,r=0;do r++,e=e.Lnext;while(e!==t.anEdge);return r},n.prototype.mergeConvexFaces=function(t){var e,r,o,i,a,s,l;for(e=this.fHead.next;e!==this.fHead;e=e.next)if(!!e.inside)for(r=e.anEdge,a=r.Org;o=r.Lnext,i=r.Sym,i&&i.Lface&&i.Lface.inside&&(s=this.countFaceVerts_(e),l=this.countFaceVerts_(i.Lface),s+l-2<=t&&ve.vertCCW(r.Lprev.Org,r.Org,i.Lnext.Lnext.Org)&&ve.vertCCW(i.Lprev.Org,i.Org,r.Lnext.Lnext.Org)&&(o=i.Lnext,this.delete(i),r=null,i=null)),!(r&&r.Lnext.Org===a);)r=o;return!0},n.prototype.check=function(){var t=this.fHead,e=this.vHead,r=this.eHead,o,i,a,s,l,u;for(i=t,i=t;(o=i.next)!==t;i=o){Ae(o.prev===i),l=o.anEdge;do Ae(l.Sym!==l),Ae(l.Sym.Sym===l),Ae(l.Lnext.Onext.Sym===l),Ae(l.Onext.Sym.Lnext===l),Ae(l.Lface===o),l=l.Lnext;while(l!==o.anEdge)}for(Ae(o.prev===i&&o.anEdge===null),s=e,s=e;(a=s.next)!==e;s=a){Ae(a.prev===s),l=a.anEdge;do Ae(l.Sym!==l),Ae(l.Sym.Sym===l),Ae(l.Lnext.Onext.Sym===l),Ae(l.Onext.Sym.Lnext===l),Ae(l.Org===a),l=l.Onext;while(l!==a.anEdge)}for(Ae(a.prev===s&&a.anEdge===null),u=r,u=r;(l=u.next)!==r;u=l)Ae(l.Sym.next===u.Sym),Ae(l.Sym!==l),Ae(l.Sym.Sym===l),Ae(l.Org!==null),Ae(l.Dst!==null),Ae(l.Lnext.Onext.Sym===l),Ae(l.Onext.Sym.Lnext===l);Ae(l.Sym.next===u.Sym&&l.Sym===this.eHeadSym&&l.Sym.Sym===l&&l.Org===null&&l.Dst===null&&l.Lface===null&&l.Rface===null)},n}(),gx=function(){function n(){this.handle=null}return n}(),xx=function(){function n(){this.key=null,this.node=0}return n}(),pM=function(){function n(t,e){this.leq=e,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=t,this.nodes=[],this.handles=[];for(var r=0;r<t+1;r++)this.nodes[r]=new gx,this.handles[r]=new xx;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return n.prototype.floatDown_=function(t){var e=this.nodes,r=this.handles,o,i,a;for(o=e[t].handle;;){if(a=t<<1,a<this.size&&this.leq(r[e[a+1].handle].key,r[e[a].handle].key)&&++a,Ae(a<=this.max),i=e[a].handle,a>this.size||this.leq(r[o].key,r[i].key)){e[t].handle=o,r[o].node=t;break}e[t].handle=i,r[i].node=t,t=a}},n.prototype.floatUp_=function(t){var e=this.nodes,r=this.handles,o,i,a;for(o=e[t].handle;;){if(a=t>>1,i=e[a].handle,a===0||this.leq(r[i].key,r[o].key)){e[t].handle=o,r[o].node=t;break}e[t].handle=i,r[i].node=t,t=a}},n.prototype.init=function(){for(var t=this.size;t>=1;--t)this.floatDown_(t);this.initialized=!0},n.prototype.min=function(){return this.handles[this.nodes[1].handle].key},n.prototype.insert=function(t){var e,r;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 gx;for(i=this.handles.length,this.handles.length=this.max+1,o=i;o<this.handles.length;o++)this.handles[o]=new xx}return this.freeList===0?r=e:(r=this.freeList,this.freeList=this.handles[r].node),this.nodes[e].handle=r,this.handles[r].node=e,this.handles[r].key=t,this.initialized&&this.floatUp_(e),r},n.prototype.extractMin=function(){var t=this.nodes,e=this.handles,r=t[1].handle,o=e[r].key;return this.size>0&&(t[1].handle=t[this.size].handle,e[t[1].handle].node=1,e[r].key=null,e[r].node=this.freeList,this.freeList=r,--this.size,this.size>0&&this.floatDown_(1)),o},n.prototype.delete=function(t){var e=this.nodes,r=this.handles,o;Ae(t>=1&&t<=this.max&&r[t].key!==null),o=r[t].node,e[o].handle=e[this.size].handle,r[e[o].handle].node=o,--this.size,o<=this.size&&(o<=1||this.leq(r[e[o>>1].handle].key,r[e[o].handle].key)?this.floatDown_(o):this.floatUp_(o)),r[t].key=null,r[t].node=this.freeList,this.freeList=t},n}(),rf=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}(),bx=function(){function n(){this.key=null,this.next=null,this.prev=null}return n}(),fM=function(){function n(t,e){this.frame=t,this.leq=e,this.head=new bx,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(t){return this.insertBefore(this.head,t)},n.prototype.search=function(t){var e=this.head;do e=e.next;while(e.key!==null&&!this.leq(this.frame,t,e.key));return e},n.prototype.insertBefore=function(t,e){do t=t.prev;while(t.key!==null&&!this.leq(this.frame,t.key,e));var r=new bx;return r.key=e,r.next=t.next,t.next.prev=r,r.prev=t,t.next=r,r},n.prototype.delete=function(t){t.next.prev=t.prev,t.prev.next=t.next},n}(),hM=function(){function n(){}return n.regionBelow=function(t){return t.nodeUp.prev.key},n.regionAbove=function(t){return t.nodeUp.next.key},n.debugEvent=function(t){},n.addWinding=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},n.edgeLeq=function(t,e,r){var o=t.event,i=e.eUp,a=r.eUp;if(i.Dst===o)return a.Dst===o?ve.vertLeq(i.Org,a.Org)?ve.edgeSign(a.Dst,i.Org,a.Org)<=0:ve.edgeSign(i.Dst,a.Org,i.Org)>=0:ve.edgeSign(a.Dst,o,a.Org)<=0;if(a.Dst===o)return ve.edgeSign(i.Dst,o,i.Org)>=0;var s=ve.edgeEval(i.Dst,o,i.Org),l=ve.edgeEval(a.Dst,o,a.Org);return s>=l},n.deleteRegion=function(t,e){e.fixUpperEdge&&Ae(e.eUp.winding===0),e.eUp.activeRegion=null,t.dict.delete(e.nodeUp)},n.fixUpperEdge=function(t,e,r){Ae(e.fixUpperEdge),t.mesh.delete(e.eUp),e.fixUpperEdge=!1,e.eUp=r,r.activeRegion=e},n.topLeftRegion=function(t,e){var r=e.eUp.Org,o;do e=n.regionAbove(e);while(e.eUp.Org===r);if(e.fixUpperEdge){if(o=t.mesh.connect(n.regionBelow(e).eUp.Sym,e.eUp.Lnext),o===null)return null;n.fixUpperEdge(t,e,o),e=n.regionAbove(e)}return e},n.topRightRegion=function(t){var e=t.eUp.Dst;do t=n.regionAbove(t);while(t.eUp.Dst===e);return t},n.addRegionBelow=function(t,e,r){var o=new rf;return o.eUp=r,o.nodeUp=t.dict.insertBefore(e.nodeUp,o),o.fixUpperEdge=!1,o.sentinel=!1,o.dirty=!1,r.activeRegion=o,o},n.isWindingInside=function(t,e){switch(t.windingRule){case je.ODD:return(e&1)!==0;case je.NONZERO:return e!==0;case je.POSITIVE:return e>0;case je.NEGATIVE:return e<0;case je.ABS_GEQ_TWO:return e>=2||e<=-2}throw new Error("Invalid winding rulle")},n.computeWinding=function(t,e){e.windingNumber=n.regionAbove(e).windingNumber+e.eUp.winding,e.inside=n.isWindingInside(t,e.windingNumber)},n.finishRegion=function(t,e){var r=e.eUp,o=r.Lface;o.inside=e.inside,o.anEdge=r,n.deleteRegion(t,e)},n.finishLeftRegions=function(t,e,r){for(var o,i=null,a=e,s=e.eUp;a!==r;){if(a.fixUpperEdge=!1,i=n.regionBelow(a),o=i.eUp,o.Org!=s.Org){if(!i.fixUpperEdge){n.finishRegion(t,a);break}o=t.mesh.connect(s.Lprev,o.Sym),n.fixUpperEdge(t,i,o)}s.Onext!==o&&(t.mesh.splice(o.Oprev,o),t.mesh.splice(s,o)),n.finishRegion(t,a),s=i.eUp,a=i}return s},n.addRightEdges=function(t,e,r,o,i,a){var s,l,u,c,d=!0;u=r;do Ae(ve.vertLeq(u.Org,u.Dst)),n.addRegionBelow(t,e,u.Sym),u=u.Onext;while(u!==o);for(i===null&&(i=n.regionBelow(e).eUp.Rprev),l=e,c=i;s=n.regionBelow(l),u=s.eUp.Sym,u.Org===c.Org;)u.Onext!==c&&(t.mesh.splice(u.Oprev,u),t.mesh.splice(c.Oprev,u)),s.windingNumber=l.windingNumber-u.winding,s.inside=n.isWindingInside(t,s.windingNumber),l.dirty=!0,!d&&n.checkForRightSplice(t,l)&&(n.addWinding(u,c),n.deleteRegion(t,l),t.mesh.delete(c)),d=!1,l=s,c=u;l.dirty=!0,Ae(l.windingNumber-u.winding===s.windingNumber),a&&n.walkDirtyRegions(t,l)},n.spliceMergeVertices=function(t,e,r){t.mesh.splice(e,r)},n.vertexWeights=function(t,e,r){var o=ve.vertL1dist(e,t),i=ve.vertL1dist(r,t),a=.5*i/(o+i),s=.5*o/(o+i);t.coords[0]+=a*e.coords[0]+s*r.coords[0],t.coords[1]+=a*e.coords[1]+s*r.coords[1],t.coords[2]+=a*e.coords[2]+s*r.coords[2]},n.getIntersectData=function(t,e,r,o,i,a){e.coords[0]=e.coords[1]=e.coords[2]=0,e.idx=-1,n.vertexWeights(e,r,o),n.vertexWeights(e,i,a)},n.checkForRightSplice=function(t,e){var r=n.regionBelow(e),o=e.eUp,i=r.eUp;if(ve.vertLeq(o.Org,i.Org)){if(ve.edgeSign(i.Dst,o.Org,i.Org)>0)return!1;ve.vertEq(o.Org,i.Org)?o.Org!==i.Org&&(t.pq.delete(o.Org.pqHandle),n.spliceMergeVertices(t,i.Oprev,o)):(t.mesh.splitEdge(i.Sym),t.mesh.splice(o,i.Oprev),e.dirty=r.dirty=!0)}else{if(ve.edgeSign(o.Dst,i.Org,o.Org)<0)return!1;n.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(o.Sym),t.mesh.splice(i.Oprev,o)}return!0},n.checkForLeftSplice=function(t,e){var r=n.regionBelow(e),o=e.eUp,i=r.eUp,a;if(Ae(!ve.vertEq(o.Dst,i.Dst)),ve.vertLeq(o.Dst,i.Dst)){if(ve.edgeSign(o.Dst,i.Dst,o.Org)<0)return!1;n.regionAbove(e).dirty=e.dirty=!0,a=t.mesh.splitEdge(o),t.mesh.splice(i.Sym,a),a.Lface.inside=e.inside}else{if(ve.edgeSign(i.Dst,o.Dst,i.Org)>0)return!1;e.dirty=r.dirty=!0,a=t.mesh.splitEdge(i),t.mesh.splice(o.Lnext,i.Sym),a.Rface.inside=e.inside}return!0},n.checkForIntersect=function(t,e){var r=n.regionBelow(e),o=e.eUp,i=r.eUp,a=o.Org,s=i.Org,l=o.Dst,u=i.Dst,c,d,p=new Da,f,h;if(Ae(!ve.vertEq(u,l)),Ae(ve.edgeSign(l,t.event,a)<=0),Ae(ve.edgeSign(u,t.event,s)>=0),Ae(a!==t.event&&s!==t.event),Ae(!e.fixUpperEdge&&!r.fixUpperEdge),a===s||(c=Math.min(a.t,l.t),d=Math.max(s.t,u.t),c>d))return!1;if(ve.vertLeq(a,s)){if(ve.edgeSign(u,a,s)>0)return!1}else if(ve.edgeSign(l,s,a)<0)return!1;return n.debugEvent(t),ve.intersect(l,a,u,s,p),Ae(Math.min(a.t,l.t)<=p.t),Ae(p.t<=Math.max(s.t,u.t)),Ae(Math.min(u.s,l.s)<=p.s),Ae(p.s<=Math.max(s.s,a.s)),ve.vertLeq(p,t.event)&&(p.s=t.event.s,p.t=t.event.t),f=ve.vertLeq(a,s)?a:s,ve.vertLeq(f,p)&&(p.s=f.s,p.t=f.t),ve.vertEq(p,a)||ve.vertEq(p,s)?(n.checkForRightSplice(t,e),!1):!ve.vertEq(l,t.event)&&ve.edgeSign(l,t.event,p)>=0||!ve.vertEq(u,t.event)&&ve.edgeSign(u,t.event,p)<=0?u===t.event?(t.mesh.splitEdge(o.Sym),t.mesh.splice(i.Sym,o),e=n.topLeftRegion(t,e),o=n.regionBelow(e).eUp,n.finishLeftRegions(t,n.regionBelow(e),r),n.addRightEdges(t,e,o.Oprev,o,o,!0),!0):l===t.event?(t.mesh.splitEdge(i.Sym),t.mesh.splice(o.Lnext,i.Oprev),r=e,e=n.topRightRegion(e),h=n.regionBelow(e).eUp.Rprev,r.eUp=i.Oprev,i=n.finishLeftRegions(t,r,null),n.addRightEdges(t,e,i.Onext,o.Rprev,h,!0),!0):(ve.edgeSign(l,t.event,p)>=0&&(n.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(o.Sym),o.Org.s=t.event.s,o.Org.t=t.event.t),ve.edgeSign(u,t.event,p)<=0&&(e.dirty=r.dirty=!0,t.mesh.splitEdge(i.Sym),i.Org.s=t.event.s,i.Org.t=t.event.t),!1):(t.mesh.splitEdge(o.Sym),t.mesh.splitEdge(i.Sym),t.mesh.splice(i.Oprev,o),o.Org.s=p.s,o.Org.t=p.t,o.Org.pqHandle=t.pq.insert(o.Org),n.getIntersectData(t,o.Org,a,l,s,u),n.regionAbove(e).dirty=e.dirty=r.dirty=!0,!1)},n.walkDirtyRegions=function(t,e){for(var r=n.regionBelow(e),o,i;;){for(;r.dirty;)e=r,r=n.regionBelow(r);if(!e.dirty&&(r=e,e=n.regionAbove(e),e===null||!e.dirty))return;if(e.dirty=!1,o=e.eUp,i=r.eUp,o.Dst!==i.Dst&&n.checkForLeftSplice(t,e)&&(r.fixUpperEdge?(n.deleteRegion(t,r),t.mesh.delete(i),r=n.regionBelow(e),i=r.eUp):e.fixUpperEdge&&(n.deleteRegion(t,e),t.mesh.delete(o),e=n.regionAbove(r),o=e.eUp)),o.Org!==i.Org)if(o.Dst!==i.Dst&&!e.fixUpperEdge&&!r.fixUpperEdge&&(o.Dst===t.event||i.Dst===t.event)){if(n.checkForIntersect(t,e))return}else n.checkForRightSplice(t,e);o.Org===i.Org&&o.Dst===i.Dst&&(n.addWinding(i,o),n.deleteRegion(t,e),t.mesh.delete(o),e=n.regionAbove(r))}},n.connectRightVertex=function(t,e,r){var o,i=r.Onext,a=n.regionBelow(e),s=e.eUp,l=a.eUp,u=!1;if(s.Dst!==l.Dst&&n.checkForIntersect(t,e),ve.vertEq(s.Org,t.event)&&(t.mesh.splice(i.Oprev,s),e=n.topLeftRegion(t,e),i=n.regionBelow(e).eUp,n.finishLeftRegions(t,n.regionBelow(e),a),u=!0),ve.vertEq(l.Org,t.event)&&(t.mesh.splice(r,l.Oprev),r=n.finishLeftRegions(t,a,null),u=!0),u){n.addRightEdges(t,e,r.Onext,i,i,!0);return}ve.vertLeq(l.Org,s.Org)?o=l.Oprev:o=s,o=t.mesh.connect(r.Lprev,o),n.addRightEdges(t,e,o,o.Onext,o.Onext,!1),o.Sym.activeRegion.fixUpperEdge=!0,n.walkDirtyRegions(t,e)},n.connectLeftDegenerate=function(t,e,r){var o,i,a,s,l;if(o=e.eUp,ve.vertEq(o.Org,r)){Ae(!1),n.spliceMergeVertices(t,o,r.anEdge);return}if(!ve.vertEq(o.Dst,r)){t.mesh.splitEdge(o.Sym),e.fixUpperEdge&&(t.mesh.delete(o.Onext),e.fixUpperEdge=!1),t.mesh.splice(r.anEdge,o),n.sweepEvent(t,r);return}Ae(!1),e=n.topRightRegion(e),l=n.regionBelow(e),a=l.eUp.Sym,i=s=a.Onext,l.fixUpperEdge&&(Ae(i!==a),n.deleteRegion(t,l),t.mesh.delete(a),a=i.Oprev),t.mesh.splice(r.anEdge,a),ve.edgeGoesLeft(i)||(i=null),n.addRightEdges(t,e,a.Onext,s,i,!0)},n.connectLeftVertex=function(t,e){var r,o,i,a,s,l,u=new rf;if(u.eUp=e.anEdge.Sym,r=t.dict.search(u).key,o=n.regionBelow(r),!!o){if(a=r.eUp,s=o.eUp,ve.edgeSign(a.Dst,e,a.Org)===0){n.connectLeftDegenerate(t,r,e);return}if(i=ve.vertLeq(s.Dst,a.Dst)?r:o,r.inside||i.fixUpperEdge){if(i===r)l=t.mesh.connect(e.anEdge.Sym,a.Lnext);else{var c=t.mesh.connect(s.Dnext,e.anEdge);l=c.Sym}i.fixUpperEdge?n.fixUpperEdge(t,i,l):n.computeWinding(t,n.addRegionBelow(t,r,l)),n.sweepEvent(t,e)}else n.addRightEdges(t,r,e.anEdge,e.anEdge,null,!0)}},n.sweepEvent=function(t,e){t.event=e,n.debugEvent(t);for(var r=e.anEdge;r.activeRegion===null;)if(r=r.Onext,r===e.anEdge){n.connectLeftVertex(t,e);return}var o=n.topLeftRegion(t,r.activeRegion);Ae(o!==null);var i=n.regionBelow(o),a=i.eUp,s=n.finishLeftRegions(t,i,null);s.Onext===a?n.connectRightVertex(t,o,s):n.addRightEdges(t,o,s.Onext,a,a,!0)},n.addSentinel=function(t,e,r,o){var i=new rf,a=t.mesh.makeEdge();a.Org.s=r,a.Org.t=o,a.Dst.s=e,a.Dst.t=o,t.event=a.Dst,i.eUp=a,i.windingNumber=0,i.inside=!1,i.fixUpperEdge=!1,i.sentinel=!0,i.dirty=!1,i.nodeUp=t.dict.insert(i)},n.initEdgeDict=function(t){t.dict=new fM(t,n.edgeLeq);var e=t.bmax[0]-t.bmin[0],r=t.bmax[1]-t.bmin[1],o=t.bmin[0]-e,i=t.bmax[0]+e,a=t.bmin[1]-r,s=t.bmax[1]+r;n.addSentinel(t,o,i,a),n.addSentinel(t,o,i,s)},n.doneEdgeDict=function(t){for(var e,r=0;(e=t.dict.min().key)!==null;)e.sentinel||(Ae(e.fixUpperEdge),Ae(++r===1)),Ae(e.windingNumber===0),n.deleteRegion(t,e)},n.removeDegenerateEdges=function(t){var e,r,o,i=t.mesh.eHead;for(e=i.next;e!==i;e=r)r=e.next,o=e.Lnext,ve.vertEq(e.Org,e.Dst)&&e.Lnext.Lnext!==e&&(n.spliceMergeVertices(t,o,e),t.mesh.delete(e),e=o,o=e.Lnext),o.Lnext===e&&(o!==e&&((o===r||o===r.Sym)&&(r=r.next),t.mesh.delete(o)),(e===r||e===r.Sym)&&(r=r.next),t.mesh.delete(e))},n.initPriorityQ=function(t){var e,r,o,i=0;for(o=t.mesh.vHead,r=o.next;r!==o;r=r.next)i++;for(i+=8,e=t.pq=new pM(i,ve.vertLeq),o=t.mesh.vHead,r=o.next;r!==o;r=r.next)r.pqHandle=e.insert(r);return r!==o?!1:(e.init(),!0)},n.donePriorityQ=function(t){t.pq=null},n.removeDegenerateFaces=function(t,e){var r,o,i;for(r=e.fHead.next;r!==e.fHead;r=o)o=r.next,i=r.anEdge,Ae(i.Lnext!==i),i.Lnext.Lnext===i&&(n.addWinding(i.Onext,i),t.mesh.delete(i));return!0},n.computeInterior=function(t,e){e===void 0&&(e=!0);var r,o;if(n.removeDegenerateEdges(t),!n.initPriorityQ(t))return!1;for(n.initEdgeDict(t);(r=t.pq.extractMin())!==null;){for(;o=t.pq.min(),!(o===null||!ve.vertEq(o,r));)o=t.pq.extractMin(),n.spliceMergeVertices(t,r.anEdge,o.anEdge);n.sweepEvent(t,r)}return t.event=t.dict.min().key.eUp.Org,n.debugEvent(t),n.doneEdgeDict(t),n.donePriorityQ(t),n.removeDegenerateFaces(t,t.mesh)?(e&&t.mesh.check(),!0):!1},n}(),mM=function(){function n(){this.mesh=new yx,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=je.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(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},n.prototype.normalize_=function(t){var e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2];if(!e)throw"Zero-size vector!";e=Math.sqrt(e),t[0]/=e,t[1]/=e,t[2]/=e},n.prototype.longAxis_=function(t){var e=0;return Math.abs(t[1])>Math.abs(t[0])&&(e=1),Math.abs(t[2])>Math.abs(t[e])&&(e=2),e},n.prototype.computeNormal_=function(t){var e,r,o,i,a,s,l=[0,0,0],u=[0,0,0],c=[0,0,0],d=[0,0,0],p=[0,0,0],f=[null,null,null],h=[null,null,null],m=this.mesh.vHead;e=m.next;for(var y=0;y<3;++y)i=e.coords[y],u[y]=i,h[y]=e,l[y]=i,f[y]=e;for(e=m.next;e!==m;e=e.next)for(var g=0;g<3;++g)i=e.coords[g],i<u[g]&&(u[g]=i,h[g]=e),i>l[g]&&(l[g]=i,f[g]=e);var b=0;if(l[1]-u[1]>l[0]-u[0]&&(b=1),l[2]-u[2]>l[b]-u[b]&&(b=2),u[b]>=l[b]){t[0]=0,t[1]=0,t[2]=1;return}for(s=0,r=h[b],o=f[b],c[0]=r.coords[0]-o.coords[0],c[1]=r.coords[1]-o.coords[1],c[2]=r.coords[2]-o.coords[2],e=m.next;e!==m;e=e.next)d[0]=e.coords[0]-o.coords[0],d[1]=e.coords[1]-o.coords[1],d[2]=e.coords[2]-o.coords[2],p[0]=c[1]*d[2]-c[2]*d[1],p[1]=c[2]*d[0]-c[0]*d[2],p[2]=c[0]*d[1]-c[1]*d[0],a=p[0]*p[0]+p[1]*p[1]+p[2]*p[2],a>s&&(s=a,t[0]=p[0],t[1]=p[1],t[2]=p[2]);s<=0&&(t[0]=t[1]=t[2]=0,t[this.longAxis_(c)]=1)},n.prototype.checkOrientation_=function(){for(var t=this.mesh.fHead,e,r=this.mesh.vHead,o,i=0,a=t.next;a!==t;a=a.next)if(o=a.anEdge,!(o.winding<=0))do i+=(o.Org.s-o.Dst.s)*(o.Org.t+o.Dst.t),o=o.Lnext;while(o!==a.anEdge);if(i<0){for(e=r.next;e!==r;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 t=this.mesh.vHead,e=[0,0,0],r,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),r=this.sUnit,o=this.tUnit;var a=this.longAxis_(e);r[a]=0,r[(a+1)%3]=1,r[(a+2)%3]=0,o[a]=0,o[(a+1)%3]=0,o[(a+2)%3]=e[a]>0?1:-1;for(var s=t.next;s!==t;s=s.next)s.s=this.dot_(s.coords,r),s.t=this.dot_(s.coords,o);i&&this.checkOrientation_();for(var l=!0,u=t.next;u!==t;u=u.next)l?(this.bmin[0]=this.bmax[0]=u.s,this.bmin[1]=this.bmax[1]=u.t,l=!1):(u.s<this.bmin[0]&&(this.bmin[0]=u.s),u.s>this.bmax[0]&&(this.bmax[0]=u.s),u.t<this.bmin[1]&&(this.bmin[1]=u.t),u.t>this.bmax[1]&&(this.bmax[1]=u.t))},n.prototype.addWinding_=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},n.prototype.tessellateMonoRegion_=function(t,e){var r,o;if(r=e.anEdge,!(r.Lnext!==r&&r.Lnext.Lnext!==r))throw"Mono region invalid";for(;ve.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;ve.vertLeq(r.Org,r.Dst);r=r.Lnext);o=r.Lprev;for(var i=void 0;r.Lnext!==o;)if(ve.vertLeq(r.Dst,o.Org)){for(;o.Lnext!==r&&(ve.edgeGoesLeft(o.Lnext)||ve.edgeSign(o.Org,o.Dst,o.Lnext.Dst)<=0);)i=t.connect(o.Lnext,o),o=i.Sym;o=o.Lprev}else{for(;o.Lnext!==r&&(ve.edgeGoesRight(r.Lprev)||ve.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)i=t.connect(r,r.Lprev),r=i.Sym;r=r.Lnext}if(o.Lnext===r)throw"Mono region invalid";for(;o.Lnext.Lnext!==r;)i=t.connect(o.Lnext,o),o=i.Sym;return!0},n.prototype.tessellateInterior_=function(t){for(var e,r=t.fHead.next;r!==t.fHead;r=e)if(e=r.next,r.inside&&!this.tessellateMonoRegion_(t,r))return!1;return!0},n.prototype.discardExterior_=function(t){for(var e,r=t.fHead.next;r!==t.fHead;r=e)e=r.next,r.inside||t.zapFace(r)},n.prototype.setWindingNumber_=function(t,e,r){for(var o,i=t.eHead.next;i!==t.eHead;i=o)o=i.next,i.Rface.inside!==i.Lface.inside?i.winding=i.Lface.inside?e:-e:r?t.delete(i):i.winding=0},n.prototype.getNeighbourFace_=function(t){return!t.Rface||!t.Rface.inside?-1:t.Rface.n},n.prototype.outputPolymesh_=function(t,e,r,o){var i,a=0,s=0,l;r>3&&t.mergeConvexFaces(r);for(var u=t.vHead.next;u!==t.vHead;u=u.next)u.n=-1;for(var c=t.fHead.next;c!==t.fHead;c=c.next)if(c.n=-1,!!c.inside){i=c.anEdge,l=0;do{var u=i.Org;u.n===-1&&(u.n=s,s++),l++,i=i.Lnext}while(i!==c.anEdge);if(l>r)throw"Face vertex greater that support polygon";c.n=a,++a}this.elementCount=a,e===dt.CONNECTED_POLYGONS&&(a*=2),this.elements=[],this.elements.length=a*r,this.vertexCount=s,this.vertices=[],this.vertices.length=s*o,this.vertexIndices=[],this.vertexIndices.length=s;for(var u=t.vHead.next;u!==t.vHead;u=u.next)if(u.n!==-1){var d=u.n*o;this.vertices[d+0]=u.coords[0],this.vertices[d+1]=u.coords[1],o>2&&(this.vertices[d+2]=u.coords[2]),this.vertexIndices[u.n]=u.idx}for(var p=0,c=t.fHead.next;c!==t.fHead;c=c.next)if(!!c.inside){i=c.anEdge,l=0;do{var u=i.Org;this.elements[p++]=u.n,l++,i=i.Lnext}while(i!==c.anEdge);for(var f=l;f<r;++f)this.elements[p++]=-1;if(e===dt.CONNECTED_POLYGONS){i=c.anEdge;do this.elements[p++]=this.getNeighbourFace_(i),i=i.Lnext;while(i!==c.anEdge);for(var h=l;h<r;++h)this.elements[p++]=-1}}},n.prototype.outputContours_=function(t,e){var r,o,i=0,a=0;this.vertexCount=0,this.elementCount=0;for(var s=t.fHead.next;s!==t.fHead;s=s.next)if(!!s.inside){o=r=s.anEdge;do this.vertexCount++,r=r.Lnext;while(r!==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 l=0,u=0,c=0;i=0;for(var s=t.fHead.next;s!==t.fHead;s=s.next)if(!!s.inside){a=0,o=r=s.anEdge;do this.vertices[l++]=r.Org.coords[0],this.vertices[l++]=r.Org.coords[1],e>2&&(this.vertices[l++]=r.Org.coords[2]),this.vertexIndices[u++]=this.vertexIdCallback?this.vertexIdCallback(r):r.Org.idx,a++,r=r.Lnext;while(r!==o);this.elements[c++]=i,this.elements[c++]=a,i+=a}},n.prototype.addContour=function(t,e){this.mesh===null&&(this.mesh=new yx),t<2&&(t=2),t>3&&(t=3);for(var r=null,o=0;o<e.length;o+=t)r===null?(r=this.mesh.makeEdge(),this.mesh.splice(r,r.Sym)):(this.mesh.splitEdge(r),r=r.Lnext),r.Org.coords[0]=e[o+0],r.Org.coords[1]=e[o+1],t>2?r.Org.coords[2]=e[o+2]:r.Org.coords[2]=0,r.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(r),r.winding=1,r.Sym.winding=-1},n.prototype.tesselate=function(t,e,r,o,i,a){if(t===void 0&&(t=je.ODD),e===void 0&&(e=dt.POLYGONS),a===void 0&&(a=!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=t,o<2&&(o=2),o>3&&(o=3),!this.mesh)return!1;this.projectPolygon_(),hM.computeInterior(this,a);var s=this.mesh;return e===dt.BOUNDARY_CONTOURS?this.setWindingNumber_(s,1,!0):this.tessellateInterior_(s),a&&s.check(),e===dt.BOUNDARY_CONTOURS?this.outputContours_(s,o):this.outputPolymesh_(s,e,r,o),!0},n}();function Qr(n){var t=n.windingRule,e=t===void 0?je.ODD:t,r=n.elementType,o=r===void 0?dt.POLYGONS:r,i=n.polySize,a=i===void 0?3:i,s=n.vertexSize,l=s===void 0?2:s,u=n.normal,c=u===void 0?[0,0,1]:u,d=n.contours,p=d===void 0?[]:d,f=n.strict,h=f===void 0?!0:f,m=n.debug,y=m===void 0?!1:m;if(!p&&h)throw new Error("Contours can't be empty");if(!!p){var g=new mM;n.edgeCreateCallback&&(g.edgeCreateCallback=n.edgeCreateCallback),n.vertexIdCallback&&(g.vertexIdCallback=n.vertexIdCallback);for(var b=0;b<p.length;b++)g.addContour(l||2,p[b]);return g.tesselate(e,o,a,l,c,h),{vertices:g.vertices,vertexIndices:g.vertexIndices,vertexCount:g.vertexCount,elements:g.elements,elementCount:g.elementCount,mesh:y?g.mesh:void 0}}}var YW=je.ODD,XW=je.NONZERO,QW=je.POSITIVE,KW=je.NEGATIVE,ZW=je.ABS_GEQ_TWO,JW=dt.POLYGONS,e6=dt.CONNECTED_POLYGONS,t6=dt.BOUNDARY_CONTOURS;import{Box2 as vM,BufferAttribute as wu,BufferGeometry as SM,Vector2 as wM}from"three";var vu=class{constructor(t=256,e=!1){this.capacity=t,this.size=0,this.debug=e,this.debug&&console.log(`allocating with cap ${t}`);let r=t*vu.eSize;this.buffer=new ArrayBuffer(r);let o=Float32Array.BYTES_PER_ELEMENT,i=0;this.positions=new Float32Array(this.buffer,i*o,3*t),i+=3*t,this.normals=new Float32Array(this.buffer,i*o,3*t),i+=3*t,this.uvs=new Float32Array(this.buffer,i*o,2*t)}realloc(t,e=!1){if(t<this.size)throw Error("cannot shrink buffer");if(t<=this.capacity&&!e)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${t}`);let r=t*vu.eSize,o=new ArrayBuffer(r),i=Float32Array.BYTES_PER_ELEMENT,a=0,s=new Float32Array(o,a*i,3*t);a+=3*t;let l=new Float32Array(o,a*i,3*t);a+=3*t;let u=new Float32Array(o,a*i,2*t);e?(s.set(this.positions.subarray(0,this.size*3)),l.set(this.normals.subarray(0,this.size*3)),u.set(this.uvs.subarray(0,this.size*2))):(s.set(this.positions),l.set(this.normals),u.set(this.uvs)),this.buffer=o,this.positions=s,this.normals=l,this.uvs=u,this.capacity=t}get(t=1){let e=this.size+t;if(e>this.capacity){let o=this.capacity;for(;e>o;)o*=2;this.realloc(o)}let r=this.size;return this.size=e,r}reserve(t){let e=this.size+t;e>this.capacity&&this.realloc(e)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},sl=vu;sl.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var Ax=Ht(wx()),ll={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},lf={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},cf={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},sf=(n,t)=>([e,r])=>(r<e&&(r+=t),(n>=e?n:n+t)<=r),Tn=class extends SM{constructor(e,r,o=0,i=12,a=3,s=je.ODD,l=!1){super();this.forPathBevel=l;this.type="ShapeGeometry";this.vertexCache={};this._shape=e,this._depth=r,this._curveSegments=i,this._bevelSegmentsInput=a;let u=this._shape.extractShapePointsToFlatArray([],i),c=this._shape.shapeHoles.map(T=>{let I=T.extractShapePointsToFlatArray([],i),E=[];for(let B=I.length-1;B>=1;B-=2){let R=I[B-1],F=I[B-0];E.push(R,F)}return E}),d=[],p=[];for(let T=0;T<u.length;T+=2)p.push([u[T],u[T+1]]);d.push(p);for(let T=0;T<c.length;T++){let I=c[T],E=[];for(let B=0;B<I.length;B+=2)E.push([I[B],I[B+1]]);d.push(E)}let f;e.isText?f=new vM().setFromPoints(e.points.map(I=>I.position)).getSize(new wM).length()*.1:d[0].length===0?f=o:f=(0,Ax.default)(d).distance,o<=0?(this._bevel=0,this._bevelSegments=0):(this._bevel=Math.min(o,f,r/2),this._bevelSegments=Math.floor(a));let h;try{h=Qr({windingRule:s,elementType:dt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[u]})}catch{h=ll}let m;try{m=Qr({windingRule:je.ODD,elementType:dt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...c]})}catch{m=lf}if(!h)throw new Error("error generating geometry");let y=h.elementCount;if(m){h.elementCount+=m.elementCount;for(let T=0;T<m.elements.length;T++){let I=m.elements[T],E=T%2===0?h.vertexCount:0;h.elements.push(I+E)}for(let T=0;T<m.vertexIndices.length;T++){let I=m.vertexIndices[T],E=h.vertexCount;h.vertexIndices.push(I+E)}for(let T=0;T<m.vertices.length;T++){let I=m.vertices[T];h.vertices.push(I)}}let g=1/0,b=-1/0,w=1/0,A=-1/0;for(let T=0,I=h.vertexCount;T<I;T++){let E=T*2,B=h.vertices[E+0],R=h.vertices[E+1];B<g&&(g=B),B>b&&(b=B),R<w&&(w=R),R>A&&(A=R)}this._minX=g,this._minY=w,this._width=b-g,this._height=A-w,this._buffer=new sl(this._computeBufferEstimatedSize(h));let S=[],P=[];for(let T=h.elementCount-1;T>=0;T--){let I=T>=y,E=T*2,B=h.elements[E+0],R=h.elements[E+1],F=B+R,V={start:B,count:R,normals:[],continuous:[],concave:[]},q=B,k=F-1,U=B+1,H=this._shape.roundedCurves.length;do{let te=q-B,$=h.vertices[k*2+0],ee=h.vertices[k*2+1],Q=h.vertices[q*2+0],W=h.vertices[q*2+1],ue=h.vertices[U*2+0],le=h.vertices[U*2+1],ne=Q-$,ce=W-ee,ae=Math.sqrt(ne*ne+ce*ce);ne/=ae,ce/=ae;let he=Q-ue,pe=W-le,fe=Math.sqrt(he*he+pe*pe);he/=fe,pe/=fe,V.normals[te*2+0]=-pe,V.normals[te*2+1]=he,V.concave[te]=ne*pe-ce*he>0;let ge=h.vertexIndices[q];if(Array.isArray(ge))V.continuous[te]=!1;else{let[me,C]=this._shape.getCurveIndexFromVertexId(ge-1,!0);if(C>0&&C<1)V.continuous[te]=!0;else{let ie=C===1?me+1:me-1;ie=(ie+H)%H;let De=C===1?0:1,Ge=this._shape.roundedCurves[me].getTangent(C),Ee=this._shape.roundedCurves[ie].getTangent(De);V.continuous[te]=Ge.dot(Ee)>.95}}I&&(V.normals[te*2+0]*=-1,V.normals[te*2+1]*=-1),[k,q,U]=[q,U,U+1],U>=F&&(U-=R)}while(U!==B+1);let Y=[];Y.push({bevelI:0,angle:0,size:0,boundary:{vertices:h.vertices.slice(B*2,F*2),vertexCount:R,vertexIndices:new Array(R).fill(!0).map((te,$)=>[$,$]),elements:[0,R],elementCount:1,mesh:null},reverseMap:[],insetPoints:h.vertices.slice(B*2,F*2)});let J=0;for(let te=1;te<=this._bevelSegments;te++){let $=te/this._bevelSegments*Math.PI/2,ee=(1-Math.cos($))*this._bevel,Q=[],W=[],ue=[],le=[],ne=0;for(let ae=0;ae<R;ae++){let he=ae*2,pe=(ae-1+R)%R*2,fe=h.vertices[V.start*2+he+0],ge=h.vertices[V.start*2+he+1],me=-V.normals[pe+0]*ee,C=-V.normals[pe+1]*ee,ie=-V.normals[he+0]*ee,De=-V.normals[he+1]*ee;if(V.concave[ae]||!V.concave[ae]&&I){let Ge=Math.atan2(C,me),Ee=Math.atan2(De,ie);Ee>Ge&&(Ee-=Math.PI*2);let _e=Ee-Ge;if(V.continuous[ae]||I){let Ct=Ge+_e/2,Me=Math.cos(Ct)*ee,At=Math.sin(Ct)*ee;Q[2*ne+0]=fe+Me*(I?-1:1),Q[2*ne+1]=ge+At*(I?-1:1),le[ne]=ae,ne++}else{let Ct=Math.max(1,Math.floor(i/4*Math.abs(_e)/Math.PI));for(let Me=0;Me<=Ct;Me++){let At=Ge+_e*(Me/Ct),Tt=Math.cos(At)*ee,Wn=Math.sin(At)*ee;Q[2*ne+0]=fe+Tt,Q[2*ne+1]=ge+Wn,le[ne]=ae,ne++}}}else Q[2*ne+0]=fe+me,Q[2*ne+1]=ge+C,le[ne]=ae,W[ae]=ne,ne++,Q[2*ne+0]=fe,Q[2*ne+1]=ge,le[ne]=ae,ne++,Q[2*ne+0]=fe+ie,Q[2*ne+1]=ge+De,le[ne]=ae,ue[ae]=ne,ne++}let ce=Qr({windingRule:je.POSITIVE,elementType:dt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[Q],edgeCreateCallback:ae=>{let pe=ae.Org.idx,fe=le[pe],ge=le[(pe+1)%le.length];ae.idx=[fe,ge],ae.Sym.idx=[ge,fe]},vertexIdCallback:ae=>{let he=ae.Lprev.idx;return[he?he[1]:0,ae.idx?ae.idx[0]:0]}});if(!ce)throw console.log("Error"),new Error(`error generating bevel geometry for ${te}'th loop`);if(!ce.vertexCount){let ae=(te-1)/this._bevelSegments*Math.PI/2;J=(1-Math.sin(ae))*this._bevel;break}for(let ae=0;ae<ce.vertexIndices.length;ae++){let[he,pe]=ce.vertexIndices[ae];if(he===pe)continue;let fe=pe;pe<he&&(fe+=R);for(let ge=he;ge<fe;ge++){let me=ge%R,C=(ge+1)%R;if(!V.continuous[me]||!V.continuous[C]){ce.vertexIndices[ae]=[he,me],ce.vertexIndices.splice(ae+1,0,[C,pe]),ce.vertices.splice((ae+1)*2,0,ce.vertices[ae*2],ce.vertices[ae*2+1]);break}}}Y.push({bevelI:te,angle:$,size:ee,boundary:ce,reverseMap:le,insetPoints:Q})}let Z=(te,$,ee)=>{let Q=0,W=te.boundary.vertexIndices.length;for(;Q<W&&ee(te.boundary.vertexIndices[$]);)$=($+1)%W,Q++;return Q},X=S.length;for(let te=1;te<Y.length;te++){let $=Y[te-1],ee=Y[te],Q=$.boundary.vertexIndices.length,W=ee.boundary.vertexIndices.length;if(!Q||!W)break;let ue=V.concave.length,le=0,ne=sf(le,R);for(;!$.boundary.vertexIndices.filter(ne).length||!ee.boundary.vertexIndices.filter(ne).length;)le++,ne=sf(le,R);let ce=$.boundary.vertexIndices.findIndex(ne),ae=ee.boundary.vertexIndices.findIndex(ne);do ce=(ce+1)%Q;while(ne($.boundary.vertexIndices[ce]));do ae=(ae+1)%W;while(ne(ee.boundary.vertexIndices[ae]));le=(le+1)%R;let he=le,pe=0,fe=this._buildBevelVert(V,$,(ce-1+Q)%Q,void 0,pe),ge=this._buildBevelVert(V,ee,(ae-1+W)%W,void 0,pe),me=fe,C=ge,ie,De,Ge=!1;do{pe=(le||ue)/ue,ne=sf(le,R);let Ee=Z($,ce,ne),_e=Z(ee,ae,ne),Ct=Ge;if(Ge=!1,Ee&&!_e){for(let Me=0;Me<Ee;Me++)ie=this._buildBevelVert(V,$,(ce+Me)%Q,Me/(Ee-1),pe),S.push(me.topN,ie.topP,C.topN),l===!1&&S.push(ie.bottomP,me.bottomN,C.bottomN),me=ie;Ge=!0}else if(!Ee&&_e)for(let Me=0;Me<_e;Me++)De=this._buildBevelVert(V,ee,(ae+Me)%W,Me/(_e-1),pe),S.push(C.topN,me.topP,De.topP),l===!1&&S.push(me.bottomP,C.bottomN,De.bottomP),C=De;else if(Ee&&_e)if(ie=this._buildBevelVert(V,$,ce,0,pe),De=this._buildBevelVert(V,ee,ae,0,pe),Ct?(S.push(me.topN,De.topP,C.topN),S.push(me.topN,ie.topP,De.topP),l===!1&&(S.push(De.bottomP,me.bottomN,C.bottomN),S.push(De.bottomP,ie.bottomP,me.bottomN))):(S.push(C.topN,me.topN,ie.topP),S.push(C.topN,ie.topP,De.topP),l===!1&&(S.push(ie.bottomP,me.bottomN,C.bottomN),S.push(ie.bottomP,C.bottomN,De.bottomP))),me=ie,C=De,Ee===_e)for(let Me=1;Me<Ee;Me++)ie=this._buildBevelVert(V,$,(ce+Me)%Q,Me/(Ee-1),pe),De=this._buildBevelVert(V,ee,(ae+Me)%W,Me/(_e-1),pe),S.push(me.topN,ie.topP,C.topN),S.push(C.topN,ie.topP,De.topP),l===!1&&(S.push(ie.bottomP,me.bottomN,C.bottomN),S.push(ie.bottomP,C.bottomN,De.bottomP)),me=ie,C=De;else if(Ee>_e){let Me=Ee/_e,At=0;for(let Tt=1;Tt<Ee;Tt++)ie=this._buildBevelVert(V,$,(ce+Tt)%Q,Tt/(Ee-1),pe),S.push(me.topN,ie.topP,C.topN),l===!1&&S.push(ie.bottomP,me.bottomN,C.bottomN),me=ie,Tt>(At+1)*Me&&(At++,De=this._buildBevelVert(V,ee,(ae+At)%W,At/(_e-1),pe),S.push(C.topN,ie.topP,De.topP),l===!1&&S.push(ie.bottomP,C.bottomN,De.bottomP),C=De)}else{let Me=_e/Ee,At=0;for(let Tt=1;Tt<_e;Tt++)De=this._buildBevelVert(V,ee,(ae+Tt)%W,Tt/(_e-1),pe),S.push(C.topN,ie.topP,De.topP),l===!1&&S.push(ie.bottomP,C.bottomN,De.bottomP),C=De,Tt>(At+1)*Me&&(At++,ie=this._buildBevelVert(V,$,(ce+At)%Q,At/(Ee-1),pe),S.push(me.topN,ie.topP,C.topN),l===!1&&S.push(ie.bottomP,me.bottomN,C.bottomN),me=ie)}ce=(ce+Ee)%Q,ae=(ae+_e)%W,le=(le+1)%ue}while(le!==he)}if(l===!1&&this._depth>this._bevel*2&&this._buildWall(Y,V,S),I){let te=[];for(let $=S.length-1;$>=X+2;$-=3){let ee=S[$-2],Q=S[$-1],W=S[$-0];te.push(W,Q,ee)}S.splice(X,S.length-X,...te)}if(I){let te=[];for(let $=Y[Y.length-1].boundary.vertices.length-1;$>=1;$-=2){let ee=Y[Y.length-1].boundary.vertices[$-1],Q=Y[Y.length-1].boundary.vertices[$-0];te.push(ee,Q)}P.push(te)}if(!I){let te=Y[Y.length-1],$;try{$=Qr({windingRule:Y.length>1?je.POSITIVE:je.ODD,elementType:dt.POLYGONS,vertexSize:2,strict:!0,contours:[te.insetPoints,...P]})}catch{$=cf}if(!$)throw new Error("Error generating geometry for surface");c.length===0&&this._bevel<f&&Object.assign(this,{useNgonForTopBottomFaceDuringBake:!0});for(let ee=0;ee<$.elementCount*3;ee+=3){let Q=this._buildSurfaceVert($,$.elements[ee+0],J),W=this._buildSurfaceVert($,$.elements[ee+1],J),ue=this._buildSurfaceVert($,$.elements[ee+2],J);S.push(Q.top,W.top,ue.top),l===!1&&S.push(ue.bottom,W.bottom,Q.bottom)}}this.vertexCache={}}this._buffer.shrink();let O=new wu(Uint32Array.from(S),1),x=new wu(this._buffer.positions,3),D=new wu(this._buffer.normals,3),N=new wu(this._buffer.uvs,2);x.needsUpdate=!0,D.needsUpdate=!0,N.needsUpdate=!0,O.needsUpdate=!0,this.setAttribute("position",x),this.setAttribute("normal",D),this.setAttribute("uv",N),this.setIndex(O)}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,r,o){let i=e[0];for(let a=0,s=i.boundary.vertexCount;a<s;a++){let l=this._buildBevelVert(r,i,a),u=this._buildBevelVert(r,i,(a+1)%s);o.push(u.topP,l.topN,l.bottomN),o.push(u.topP,l.bottomN,u.bottomP)}}_buildSurfaceVert(e,r,o){let i=r.toString();if(i in this.vertexCache)return this.vertexCache[i];let a=e.vertices[r*2+0],s=e.vertices[r*2+1],l=(a-this._minX)/this._width,u=(s-this._minY)/this._height;this.forPathBevel&&(u=1);let c=this._buffer.get(this.forPathBevel?1:2),d=c*3,p=c*2,f={top:c+0,bottom:c+1};return this._buffer.positions[d+0]=a,this._buffer.positions[d+1]=s,this._buffer.positions[d+2]=this.forPathBevel?this._bevel:this._depth-o,this._buffer.normals[d+0]=0,this._buffer.normals[d+1]=0,this._buffer.normals[d+2]=1,this._buffer.uvs[p+0]=l,this._buffer.uvs[p+1]=u,this.forPathBevel===!1&&(this._buffer.positions[d+3]=a,this._buffer.positions[d+4]=s,this._buffer.positions[d+5]=o,this._buffer.normals[d+3]=0,this._buffer.normals[d+4]=0,this._buffer.normals[d+5]=-1,this._buffer.uvs[p+2]=l,this._buffer.uvs[p+3]=u),this.vertexCache[i]=f,f}_buildBevelVert(e,r,o,i=1,a){let s=`${r.bevelI}:${o}`;if(s in this.vertexCache&&a!==0&&a!==1&&(!a||a===this.vertexCache[s].pathBevelUCoord))return this.vertexCache[s];let[l,u]=r.boundary.vertexIndices[o],c,d,p,f;l!==u?(d=l,c=u,f=!1,p=e.continuous[d]&&e.continuous[c]):(c=l,d=(c-1+e.count)%e.count,f=e.concave[c]&&r.bevelI>0,p=e.continuous[c]||f);let h=Math.cos(r.angle),m=Math.sin(r.angle),y=o*2,g=c*2,b=d*2,w=r.boundary.vertices[y+0],A=r.boundary.vertices[y+1],S=(1-m)*this._bevel,P=(w-this._minX)/this._width,O=(A-this._minY)/this._height;this.forPathBevel&&(a!==void 0&&(P=a),O=1);let x=e.normals[g+0],D=e.normals[g+1],N=e.normals[b+0],T=e.normals[b+1];if(f){let F=N-x,V=T-D;x=x+F*(1-i),D=D+V*(1-i);let q=Math.sqrt(x*x+D*D);x/=q,D/=q}let I=this.forPathBevel?this._buffer.get(p?1:2):this._buffer.get(p?2:4),E=I*3,B=I*2,R={i:o,fi:c,topP:I+0,topN:I+0,bottomP:I+1,bottomN:I+1,pathBevelUCoord:a};return this._buffer.positions[E+0]=w,this._buffer.positions[E+1]=A,this._buffer.positions[E+2]=(this.forPathBevel?this._bevel:this._depth)-S,this._buffer.normals[E+0]=x*h,this._buffer.normals[E+1]=D*h,this._buffer.normals[E+2]=m,this._buffer.uvs[B+0]=P,this._buffer.uvs[B+1]=O,this.forPathBevel===!1&&(this._buffer.positions[E+3]=w,this._buffer.positions[E+4]=A,this._buffer.positions[E+5]=S,this._buffer.normals[E+3]=x*h,this._buffer.normals[E+4]=D*h,this._buffer.normals[E+5]=-m,this._buffer.uvs[B+2]=O,this._buffer.uvs[B+3]=P),p||(this.forPathBevel?(I+=1,E+=3,B+=2):(I+=2,E+=6,B+=4),R.topP=I+0,R.bottomP=I+1,this._buffer.positions[E+0]=w,this._buffer.positions[E+1]=A,this._buffer.positions[E+2]=(this.forPathBevel?this._bevel:this._depth)-S,this._buffer.normals[E+0]=N*h,this._buffer.normals[E+1]=T*h,this._buffer.normals[E+2]=m,this._buffer.uvs[B+0]=P,this._buffer.uvs[B+1]=O,this.forPathBevel===!1&&(this._buffer.positions[E+3]=w,this._buffer.positions[E+4]=A,this._buffer.positions[E+5]=S,this._buffer.normals[E+3]=N*h,this._buffer.normals[E+4]=T*h,this._buffer.normals[E+5]=-m,this._buffer.uvs[B+2]=O,this._buffer.uvs[B+3]=P)),this.vertexCache[s]=R,R}clone(){let e=new Tn(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Vo(this.userData),e}};var Ea=class extends AM{constructor(e,r=12,o={}){super();this.type="ShapeGeometry";this.windingRule=je.ODD;this.elementType=dt.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=e,this._curveSegments=r,this._triangulationOptions=Object.assign({windingRule:je.ODD,elementType:dt.POLYGONS,polySize:3,vertexSize:2,strict:!0},o);let i=this._shape.extractShapePointsToFlatArray([],this._curveSegments),a=this._shape.shapeHoles.map(h=>h.extractShapePointsToFlatArray([],this._curveSegments)),s,l=!0,u=!0,c,d;for(let h=0,m=i.length/2;h<m;h++){let y=h*2,g=i[y+0],b=i[y+1];if(c!==void 0&&g!==c&&(l=!1),d!==void 0&&b!==d&&(u=!1),c=g,d=b,!l&&!u)break}if(!l&&!u)try{s=Qr({contours:[i,...a],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})}catch{s=ll}let p=s?.vertexCount??1,f=s?.elementCount??1;if(this._positionAttribute=new Au(new Float32Array(p*3),3),this._normalAttribute=new Au(new Float32Array(p*3),3),this._uvAttribute=new Au(new Float32Array(p*2),2),this._indexAttribute=new Au(new Uint32Array(f*3),1),s){let h=1/0,m=-1/0,y=1/0,g=-1/0;for(let A=0,S=p;A<S;A++){let P=A*2,O=s.vertices[P+0],x=s.vertices[P+1];O<h&&(h=O),O>m&&(m=O),x<y&&(y=x),x>g&&(g=x)}let b=m-h,w=g-y;for(let A=0,S=p;A<S;A++){let P=A*2,O=s.vertices[P+0],x=s.vertices[P+1],D=(O-h)/b,N=(x-y)/w;this._positionAttribute.setXYZ(A,O,x,0),this._normalAttribute.setXYZ(A,0,0,1),this._uvAttribute.setXY(A,D,N)}for(let A=0,S=f;A<S;A++){let P=A*3,O=s.elements[P+0],x=s.elements[P+1],D=s.elements[P+2];this._indexAttribute.setX(P+0,O),this._indexAttribute.setX(P+1,x),this._indexAttribute.setX(P+2,D)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,(s?.elementCount??1)*3)}clone(){let e=new Ea(this._shape,this._curveSegments);return e.userData=Vo(this.userData),e}};var Ba=class extends Tn{constructor(e,r,o=0,i=12,a=3,s=je.ODD){super(e,r,o,i,a,s);this.type="ShapeGeometry"}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,r,o){let i=e[0];for(let a=0,s=i.boundary.vertexCount;a<s;a++){let l=this._buildBevelVert(r,i,a),u=this._buildBevelVert(r,i,(a+1)%s);o.push(u.topP,l.topN,l.bottomN),o.push(u.topP,l.bottomN,u.bottomP)}}clone(){let e=new Ba(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Vo(this.userData),e}};var dr=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:je.ODD},n.parameters),r=Math.abs(e.width),o=Math.abs(e.height??e.width),i=Math.abs(e.depth??0),a=n.shape??t?.shape,s=a?.roundness??e.roundness;a!==void 0&&(a instanceof He?(a.width!==r||a.height!==o)&&a.applySize(r,o):a=new He(r,o).fromJSON(a),n.parameters?.roundness!==void 0&&n.parameters?.roundness>0&&a.update());let l=a??new He(r,o);return{parameters:Object.assign(e,{width:r,height:o,depth:i,roundness:s}),shape:l}}static build(n){let{depth:t,extrudeBevelSize:e,extrudeBevelSegments:r,subdivisions:o,roundness:i,windingRule:a}=n.parameters;n.shape.roundness=i;let s;return t<=0?s=new Ea(n.shape,o,{windingRule:a}):s=new Ba(n.shape,t,e,o,r,a),Object.assign(s,{userData:{...n,type:"VectorGeometry"}})}};import{BufferGeometry as _M,Float32BufferAttribute as PM,MathUtils as uf,Vector2 as Px}from"three";var Ox=Math.PI*2,Ra=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters);return e.angle=uf.clamp(e.angle,0,360),{shape:n.shape&&n.shape instanceof He?n.shape:new He,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:t,height:e,spikes:r,angle:o,innerRadius:i,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}=n.parameters,u=n.shape,c=t*.5,d=e*.5,p=OM(u,c,d,o*Math.PI/180,r,i);u.isClosed=!0,u.update();let f;return o===0?(f=new _M,f.setAttribute("position",new PM([],3))):f=dr.create({shape:u,parameters:{subdivisions:p,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}}),Object.assign(f,{userData:{...n,type:"EllipseGeometry"}})}};function OM(n,t,e,r,o,i){if(r>=Ox)return o>30||o%4===0?(TM(n,t,e,i),Math.round(o/4)):_x(n,r,o,t,e,i);r=Math.max(r,.001);let a={x:0,y:e},s=r+Math.PI*.5,l={x:Math.cos(s)*t,y:Math.sin(s)*e},u=mx({px:a.x,py:a.y,cx:l.x,cy:l.y,rx:t,ry:e,largeArcFlag:r>Math.PI,sweepFlag:!0});return o>30||o%u.length===0?CM(n,a.x,a.y,u,o,t,e,i):_x(n,r,o,t,e,i)}function CM(n,t,e,r,o,i,a,s){let l=Math.round(o/r.length);n.addPoint(La(t,e));for(let u=0,c=r.length;u<c;u++){let d=r[u],p=n.points[u],f=La(d.x,d.y);p.controls[1].position.set(d.x1,d.y1),f.controls[0].position.set(d.x2,d.y2),n.addPoint(f)}return s>0?Cx(n,i,a,s):n.addPoint(La(0,0)),l}function _x(n,t,e,r,o,i){let a=-t/e;for(let s=0;s<=e;s++){let l=a*s,u=Math.sin(l)*r,c=Math.cos(l)*o;n.addPoint(La(u,c))}return t<Ox?i>0?Cx(n,r,o,i):n.addPoint(La(0,0)):(n.removePoint(n.points[n.points.length-1]),i>0&&Tx(n,r,o,i)),1}function TM(n,t,e,r=0,o=0,i=0){let a=.5522847498,s=t*a,l=e*a;n.addPoint(_u(o-t,i,o-t,i-l,o-t,i+l)),n.addPoint(_u(o,i+e,o-s,i+e,o+s,i+e)),n.addPoint(_u(o+t,i,o+t,i+l,o+t,i-l)),n.addPoint(_u(o,i-e,o+s,i-e,o-s,i-e)),r>0&&Tx(n,t,e,r)}function La(n,t){return new Xr(uf.generateUUID(),new Px(n,t))}function _u(n,t,e,r,o,i){let a=La(n,t);return a.controls[0].position.set(e,r),a.controls[1].position.set(o,i),a}function Cx(n,t,e,r){Mx(n,t,e,r).forEach(i=>n.addPoint(i))}function Tx(n,t,e,r){let o=Mx(n,t,e,r),i=new He;o.forEach(a=>i.addPoint(a)),i.isClosed=!0,n.shapeHoles.push(i)}function Mx(n,t,e,r){let o=r*t/100,i=o*(Math.abs(e)/Math.abs(t)),a=new Px(o/t,i/e),s=n.points.map(l=>{let u=l.clone();return u.uuid=uf.generateUUID(),u}).reverse();return s.forEach(l=>{l.position.multiply(a);let u=l.controls[0].position.clone().multiply(a),c=l.controls[1].position.clone().multiply(a);l.controls[0].position.copy(c),l.controls[1].position.copy(u)}),s}import{BufferGeometry as MM,Float32BufferAttribute as df,Uint32BufferAttribute as IM,Vector3 as Ix}from"three";var Nx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},n.parameters),r=Math.abs(e.width),o=Math.abs(e.height??r),i=Math.abs(e.depth??r),a=Math.abs(Math.min(r,i))/2;return{parameters:Object.assign(e,{width:r,height:o,depth:i,radius:a,segments:Math.round(e.segments),pathSegments:Math.round(e.pathSegments),cornerSegments:Math.round(e.cornerSegments)})}}static build(n){let{width:t,height:e,depth:r,radius:o,revolutions:i,segments:a,pathRadius:s,pathType:l,pathSegments:u,cornerRadius:c,cornerSegments:d}=n.parameters,p=new cl(!1,t,e,r,o,i,a,s,l,u,c,d);return Object.assign(p,{userData:{...n,type:"HelixGeometry"}})}},pf=new IM([0,0,0],1),cl=class extends MM{constructor(t=!0,e=1,r=1,o=1,i=1,a=1,s=1,l=1,u=1,c=1,d=1,p=1){if(super(),a===0)return;let f=t&&a===1;f&&(p=0),d>100&&(d=100),d===0&&(p=0);let h=()=>new Ix,m=new Ix,y=h(),g=h(),b=h(),w,A,S,P,O,x,D,N,T=h(),I=h(),E=h(),B=h(),R=h(),F=h(),V=h(),q=h(),k=r-2*l+.001,U=k/a,H=Math.ceil(s*a),Y=H+1,J=k/H,Z=-k/2,X=c+1,te=2*Math.PI/c,$=Math.PI/2/p,ee=.01,Q=Math.min((1-d/100)*l,l-ee),W=l-Q,ue=0,le=2,ne=p*le+le,ce=X*ne/le,ae=ce+X*Y,he=Math.max(0,X*(Y+ne)),[pe,fe,ge]=[3,3,2].map(st=>Array(he*st).fill(0)),me=[],C=i-l;function ie(st,Ke){let kr=Math.PI/2;x=Ke*J,N=2*Math.PI*(x%U)/U+kr,x+=Z,D=Math.sin(N)*C,O=Math.cos(N)*C,t?st.set(O,D,x):st.set(O,x,D)}ie(m,-1e-10),ie(y,0),T.copy(m),ie(m,1);let De=m.distanceTo(y),Ge=f?0:W+Q,Ee=De*H+2*Ge,_e=Q,Ct=Ee-Ge;for(let st=0;st<=H;st++){ie(g,st),q.subVectors(g,T).normalize(),T.copy(g),F.copy(g).setComponent(+t+1,0).normalize(),V.crossVectors(q,F).normalize();let Ke=st===0,kr=st===H,Dd=Ke?3*Math.PI/2:$,Ed=Ke?_e:Ct,jl=Ke?X:ae,$n=Ke?0:he-X,mt=q.clone().multiplyScalar(Ke?-W:W).add(g),Bd=q.clone().multiplyScalar(Ke?-1:1).normalize();for(let Cr=0;Cr<X;Cr++){let Ls=Cr*te;if(I.addVectors(m.copy(F).multiplyScalar(l*Math.cos(Ls)),y.copy(V).multiplyScalar(l*Math.sin(Ls))),E.copy(I).normalize(),Ke||kr){f||(ue=$n+Cr,[0,1,2].forEach(Kt=>{pe[ue*3+Kt]=mt.getComponent(Kt),fe[ue*3+Kt]=Bd.getComponent(Kt)}),ge[ue*2]=+kr,ge[ue*2+1]=Cr/c),y.copy(E).multiplyScalar(Q),b.addVectors(g,y);for(let Kt=0;Kt<p;Kt++){let Yn=Kt*$+Dd;B.addVectors(m.copy(q).multiplyScalar(W*Math.sin(Yn)),y.copy(E).multiplyScalar(W*Math.cos(Yn))),R.copy(B).normalize(),y.addVectors(b,B),B.normalize(),ue=jl+Kt*X+Cr,[0,1,2].forEach(Ii=>{pe[ue*3+Ii]=y.getComponent(Ii),fe[ue*3+Ii]=R.getComponent(Ii)});let Ul=+Ke+Math.sin(Yn);ge[ue*2]=(Ed+W*Ul)/Ee,ge[ue*2+1]=Cr/c}}y.addVectors(g,I),ue=ce+st*X+Cr,[0,1,2].forEach(Kt=>{pe[ue*3+Kt]=y.getComponent(Kt),fe[ue*3+Kt]=E.getComponent(Kt)}),ge[ue*2]=(Ge+st*De)/Ee,ge[ue*2+1]=Cr/c}}let Me=Y+2*p+le,At=1,[Tt,Wn]=[+f,Me-1];for(let st=Tt;st<=Wn-1;st++){let Ke=f&&st===Wn-1;for(let kr=0;kr<X-1;kr++)w=st*X+kr,A=w+1,S=(Ke?kr:w)+X,P=(Ke?kr+1:A)+X,st===0?me.push(A,P,S):st===Me-2?me.push(w,A,S):me.push(w,A,S,A,P,S)}this.setIndex(me),this.setAttribute("position",new df(pe,3)),this.setAttribute("normal",new df(fe,3)),this.setAttribute("uv",new df(ge,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let t=this.userData.parameters,e=Math.ceil(t.tubularSegments),r=t.radialSegments+1,o=Array.from(this.getIndex().array),i,a,s,l,u=6*(e-1)*t.radialSegments,c=e,d=c===e;for(let p=0;p<t.radialSegments;p++)i=c*r+p,a=i+1,s=(d?p:i)+r,l=(d?p+1:a)+r,o[u++]=i,o[u++]=a,o[u++]=s,o[u++]=a,o[u++]=l,o[u++]=s;return o.length=u,pf.array=o,pf.count=o.length,pf}};import{IcosahedronGeometry as NM}from"three";var Dx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.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:t,height:e,depth:r,detail:o,corner:i,cornerSides:a}=n.parameters,s=o===0&&i!==0?new ul(t*.5,i,a):new NM(t*.5,o);return s.scale(1,e/t,r/t),Object.assign(s,{userData:{...n,type:"IcosahedronGeometry"}})}},ul=class extends Pn{constructor(t=1,e=.2,r=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],a=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],s="IcosahedronGeometry";super(i,a,s,t,e,r),this.type=s}static fromJSON(t){return new ul(t.radius,t.corner,t.cornerSides)}};import{LatheGeometry as DM,Shape as EM}from"three";var Ex=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){(n.parameters?.points??[]).forEach(r=>{Array.isArray(r)&&(r.x=r[0],r.y=r[1])});let e=Object.assign({},t?.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:t,segments:e,verticalSegments:r}=n.parameters,o=new EM;o.moveTo(t[0].x,t[0].y),o.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y);let i=new DM(o.extractPoints(r).shape,e);return i.rotateZ(Math.PI),Object.assign(i,{userData:{...n,type:"LatheGeometry"}})}};import{BufferGeometry as kx,BufferGeometryLoader as qM,Vector3 as WM,BoxGeometry as jx}from"three";import{BufferGeometry as kM,Vector2 as yf,Vector3 as Fx}from"three";import{Box3 as BM,BufferAttribute as dl,BufferGeometry as Bx,Color as mf,EventDispatcher as LM,Float32BufferAttribute as Va,Matrix3 as Lx,Matrix4 as Gx,MathUtils as RM,Object3D as VM,Sphere as zM,Vector2 as Ar,Vector3 as $t,Vector4 as GM}from"three";var xo=new Gx,ff=new VM,Pu=new $t,Mn=class extends LM{constructor(){super(),this.uuid=RM.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(t){let e=new Lx().getNormalMatrix(t);for(let r=0,o=this.vertices.length;r<o;r++)this.vertices[r].applyMatrix4(t);for(let r=0,o=this.faces.length;r<o;r++){let i=this.faces[r];i.normal.applyMatrix3(e).normalize();for(let a=0,s=i.vertexNormals.length;a<s;a++)i.vertexNormals[a].applyMatrix3(e).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this}rotateX(t){return xo.makeRotationX(t),this.applyMatrix4(xo),this}rotateY(t){return xo.makeRotationY(t),this.applyMatrix4(xo),this}rotateZ(t){return xo.makeRotationZ(t),this.applyMatrix4(xo),this}translate(t,e,r){return xo.makeTranslation(t,e,r),this.applyMatrix4(xo),this}scale(t,e,r){return xo.makeScale(t,e,r),this.applyMatrix4(xo),this}lookAt(t){return ff.lookAt(t),ff.updateMatrix(),this.applyMatrix4(ff.matrix),this}fromBufferGeometry(t){let e=this,r=t.index!==null?t.index:void 0,o=t.attributes;if(o.position===void 0)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;let i=o.position,a=o.normal,s=o.color,l=o.uv,u=o.uv2;u!==void 0&&(this.faceVertexUvs[1]=[]);for(let p=0;p<i.count;p++)e.vertices.push(new $t().fromBufferAttribute(i,p)),s!==void 0&&e.colors.push(new mf().fromBufferAttribute(s,p));function c(p,f,h,m){let y=s===void 0?[]:[e.colors[p].clone(),e.colors[f].clone(),e.colors[h].clone()],g=a===void 0?[]:[new $t().fromBufferAttribute(a,p),new $t().fromBufferAttribute(a,f),new $t().fromBufferAttribute(a,h)],b=new za(p,f,h,g,y,m);e.faces.push(b),l!==void 0&&e.faceVertexUvs[0].push([new Ar().fromBufferAttribute(l,p),new Ar().fromBufferAttribute(l,f),new Ar().fromBufferAttribute(l,h)]),u!==void 0&&e.faceVertexUvs[1].push([new Ar().fromBufferAttribute(u,p),new Ar().fromBufferAttribute(u,f),new Ar().fromBufferAttribute(u,h)])}let d=t.groups;if(d.length>0)for(let p=0;p<d.length;p++){let f=d[p],h=f.start,m=f.count;for(let y=h,g=h+m;y<g;y+=3)r!==void 0?c(r.getX(y),r.getX(y+1),r.getX(y+2),f.materialIndex):c(y,y+1,y+2,f.materialIndex)}else if(r!==void 0)for(let p=0;p<r.count;p+=3)c(r.getX(p),r.getX(p+1),r.getX(p+2));else for(let p=0;p<i.count;p+=3)c(p,p+1,p+2);return this.computeFaceNormals(),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Pu).negate(),this.translate(Pu.x,Pu.y,Pu.z),this}normalize(){this.computeBoundingSphere();let t=this.boundingSphere.center,e=this.boundingSphere.radius,r=e===0?1:1/e,o=new Gx;return o.set(r,0,0,-r*t.x,0,r,0,-r*t.y,0,0,r,-r*t.z,0,0,0,1),this.applyMatrix4(o),this}computeFaceNormals(){let t=new $t,e=new $t;for(let r=0,o=this.faces.length;r<o;r++){let i=this.faces[r],a=this.vertices[i.a],s=this.vertices[i.b],l=this.vertices[i.c];t.subVectors(l,s),e.subVectors(a,s),t.cross(e),t.normalize(),i.normal.copy(t)}}computeVertexNormals(t=!0){let e=new Array(this.vertices.length);for(let r=0,o=this.vertices.length;r<o;r++)e[r]=new $t;if(t){let r=new $t,o=new $t;for(let i=0,a=this.faces.length;i<a;i++){let s=this.faces[i],l=this.vertices[s.a],u=this.vertices[s.b],c=this.vertices[s.c];r.subVectors(c,u),o.subVectors(l,u),r.cross(o),e[s.a].add(r),e[s.b].add(r),e[s.c].add(r)}}else{this.computeFaceNormals();for(let r=0,o=this.faces.length;r<o;r++){let i=this.faces[r];e[i.a].add(i.normal),e[i.b].add(i.normal),e[i.c].add(i.normal)}}for(let r=0,o=this.vertices.length;r<o;r++)e[r].normalize();for(let r=0,o=this.faces.length;r<o;r++){let i=this.faces[r],a=i.vertexNormals;a.length===3?(a[0].copy(e[i.a]),a[1].copy(e[i.b]),a[2].copy(e[i.c])):(a[0]=e[i.a].clone(),a[1]=e[i.b].clone(),a[2]=e[i.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeFlatVertexNormals(){this.computeFaceNormals();for(let t=0,e=this.faces.length;t<e;t++){let r=this.faces[t],o=r.vertexNormals;o.length===3?(o[0].copy(r.normal),o[1].copy(r.normal),o[2].copy(r.normal)):(o[0]=r.normal.clone(),o[1]=r.normal.clone(),o[2]=r.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let e=0,r=this.faces.length;e<r;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,a=o.vertexNormals.length;i<a;i++)o.__originalVertexNormals[i]?o.__originalVertexNormals[i].copy(o.vertexNormals[i]):o.__originalVertexNormals[i]=o.vertexNormals[i].clone()}let t=new Mn;t.faces=this.faces;for(let e=0,r=this.morphTargets.length;e<r;e++){if(!this.morphNormals[e]){this.morphNormals[e]={},this.morphNormals[e].faceNormals=[],this.morphNormals[e].vertexNormals=[];let i=this.morphNormals[e].faceNormals,a=this.morphNormals[e].vertexNormals;for(let s=0,l=this.faces.length;s<l;s++){let u=new $t,c={a:new $t,b:new $t,c:new $t};i.push(u),a.push(c)}}let o=this.morphNormals[e];t.vertices=this.morphTargets[e].vertices,t.computeFaceNormals(),t.computeVertexNormals();for(let i=0,a=this.faces.length;i<a;i++){let s=this.faces[i],l=o.faceNormals[i],u=o.vertexNormals[i];l.copy(s.normal),u.a.copy(s.vertexNormals[0]),u.b.copy(s.vertexNormals[1]),u.c.copy(s.vertexNormals[2])}}for(let e=0,r=this.faces.length;e<r;e++){let o=this.faces[e];o.normal=o.__originalFaceNormal,o.vertexNormals=o.__originalVertexNormals}}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new BM),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new zM),this.boundingSphere.setFromPoints(this.vertices)}merge(t,e,r=0){if(!(t&&t.isGeometry)){console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",t);return}let o,i=this.vertices.length,a=this.vertices,s=t.vertices,l=this.faces,u=t.faces,c=this.colors,d=t.colors;e!==void 0&&(o=new Lx().getNormalMatrix(e));for(let p=0,f=s.length;p<f;p++){let m=s[p].clone();e!==void 0&&m.applyMatrix4(e),a.push(m)}for(let p=0,f=d.length;p<f;p++)c.push(d[p].clone());for(let p=0,f=u.length;p<f;p++){let h=u[p],m,y,g=h.vertexNormals,b=h.vertexColors,w=new za(h.a+i,h.b+i,h.c+i);w.normal.copy(h.normal),o!==void 0&&w.normal.applyMatrix3(o).normalize();for(let A=0,S=g.length;A<S;A++)m=g[A].clone(),o!==void 0&&m.applyMatrix3(o).normalize(),w.vertexNormals.push(m);w.color.copy(h.color);for(let A=0,S=b.length;A<S;A++)y=b[A],w.vertexColors.push(y.clone());w.materialIndex=h.materialIndex+r,l.push(w)}for(let p=0,f=t.faceVertexUvs.length;p<f;p++){let h=t.faceVertexUvs[p];this.faceVertexUvs[p]===void 0&&(this.faceVertexUvs[p]=[]);for(let m=0,y=h.length;m<y;m++){let g=h[m],b=[];for(let w=0,A=g.length;w<A;w++)b.push(g[w].clone());this.faceVertexUvs[p].push(b)}}}mergeMesh(t){if(!(t&&t.isMesh)){console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",t);return}t.matrixAutoUpdate&&t.updateMatrix(),this.merge(t.geometry,t.matrix)}mergeVertices(t=4){let e={},r=[],o=[],i=Math.pow(10,t);for(let l=0,u=this.vertices.length;l<u;l++){let c=this.vertices[l],d=Math.round(c.x*i)+"_"+Math.round(c.y*i)+"_"+Math.round(c.z*i);e[d]===void 0?(e[d]=l,r.push(this.vertices[l]),o[l]=r.length-1):o[l]=o[e[d]]}let a=[];for(let l=0,u=this.faces.length;l<u;l++){let c=this.faces[l];c.a=o[c.a],c.b=o[c.b],c.c=o[c.c];let d=[c.a,c.b,c.c];for(let p=0;p<3;p++)if(d[p]===d[(p+1)%3]){a.push(l);break}}for(let l=a.length-1;l>=0;l--){let u=a[l];this.faces.splice(u,1);for(let c=0,d=this.faceVertexUvs.length;c<d;c++)this.faceVertexUvs[c].splice(u,1)}let s=this.vertices.length-r.length;return this.vertices=r,s}setFromPoints(t){this.vertices=[];for(let e=0,r=t.length;e<r;e++){let o=t[e];this.vertices.push(new $t(o.x,o.y,o.z||0))}return this}sortFacesByMaterialIndex(){let t=this.faces,e=t.length;for(let l=0;l<e;l++)t[l]._id=l;function r(l,u){return l.materialIndex-u.materialIndex}t.sort(r);let o=this.faceVertexUvs[0],i=this.faceVertexUvs[1],a,s;o&&o.length===e&&(a=[]),i&&i.length===e&&(s=[]);for(let l=0;l<e;l++){let u=t[l]._id;a&&a.push(o[u]),s&&s.push(i[u])}a&&(this.faceVertexUvs[0]=a),s&&(this.faceVertexUvs[1]=s)}toJSON(){let t={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),this.parameters!==void 0){let h=this.parameters;for(let m in h)h[m]!==void 0&&(t[m]=h[m]);return t}let e=[];for(let h=0;h<this.vertices.length;h++){let m=this.vertices[h];e.push(m.x,m.y,m.z)}let r=[],o=[],i={},a=[],s={},l=[],u={};for(let h=0;h<this.faces.length;h++){let m=this.faces[h],y=!0,g=!1,b=this.faceVertexUvs[0][h]!==void 0,w=m.normal.length()>0,A=m.vertexNormals.length>0,S=m.color.r!==1||m.color.g!==1||m.color.b!==1,P=m.vertexColors.length>0,O=0;if(O=c(O,0,0),O=c(O,1,y),O=c(O,2,g),O=c(O,3,b),O=c(O,4,w),O=c(O,5,A),O=c(O,6,S),O=c(O,7,P),r.push(O),r.push(m.a,m.b,m.c),r.push(m.materialIndex),b){let x=this.faceVertexUvs[0][h];r.push(f(x[0]),f(x[1]),f(x[2]))}if(w&&r.push(d(m.normal)),A){let x=m.vertexNormals;r.push(d(x[0]),d(x[1]),d(x[2]))}if(S&&r.push(p(m.color)),P){let x=m.vertexColors;r.push(p(x[0]),p(x[1]),p(x[2]))}}function c(h,m,y){return y?h|1<<m:h&~(1<<m)}function d(h){let m=h.x.toString()+h.y.toString()+h.z.toString();return i[m]!==void 0||(i[m]=o.length/3,o.push(h.x,h.y,h.z)),i[m]}function p(h){let m=h.r.toString()+h.g.toString()+h.b.toString();return s[m]!==void 0||(s[m]=a.length,a.push(h.getHex())),s[m]}function f(h){let m=h.x.toString()+h.y.toString();return u[m]!==void 0||(u[m]=l.length/2,l.push(h.x,h.y)),u[m]}return t.data={},t.data.vertices=e,t.data.normals=o,a.length>0&&(t.data.colors=a),l.length>0&&(t.data.uvs=[l]),t.data.faces=r,t}clone(){return new Mn().copy(this)}copy(t){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=t.name;let e=t.vertices;for(let p=0,f=e.length;p<f;p++)this.vertices.push(e[p].clone());let r=t.colors;for(let p=0,f=r.length;p<f;p++)this.colors.push(r[p].clone());let o=t.faces;for(let p=0,f=o.length;p<f;p++)this.faces.push(o[p].clone());for(let p=0,f=t.faceVertexUvs.length;p<f;p++){let h=t.faceVertexUvs[p];this.faceVertexUvs[p]===void 0&&(this.faceVertexUvs[p]=[]);for(let m=0,y=h.length;m<y;m++){let g=h[m],b=[];for(let w=0,A=g.length;w<A;w++){let S=g[w];b.push(S.clone())}this.faceVertexUvs[p].push(b)}}let i=t.morphTargets;for(let p=0,f=i.length;p<f;p++){let h={};if(h.name=i[p].name,i[p].vertices!==void 0){h.vertices=[];for(let m=0,y=i[p].vertices.length;m<y;m++)h.vertices.push(i[p].vertices[m].clone())}if(i[p].normals!==void 0){h.normals=[];for(let m=0,y=i[p].normals.length;m<y;m++)h.normals.push(i[p].normals[m].clone())}this.morphTargets.push(h)}let a=t.morphNormals;for(let p=0,f=a.length;p<f;p++){let h={};if(a[p].vertexNormals!==void 0){h.vertexNormals=[];for(let m=0,y=a[p].vertexNormals.length;m<y;m++){let g=a[p].vertexNormals[m],b={};b.a=g.a.clone(),b.b=g.b.clone(),b.c=g.c.clone(),h.vertexNormals.push(b)}}if(a[p].faceNormals!==void 0){h.faceNormals=[];for(let m=0,y=a[p].faceNormals.length;m<y;m++)h.faceNormals.push(a[p].faceNormals[m].clone())}this.morphNormals.push(h)}let s=t.skinWeights;for(let p=0,f=s.length;p<f;p++)this.skinWeights.push(s[p].clone());let l=t.skinIndices;for(let p=0,f=l.length;p<f;p++)this.skinIndices.push(l[p].clone());let u=t.lineDistances;for(let p=0,f=u.length;p<f;p++)this.lineDistances.push(u[p]);let c=t.boundingBox;c!==null&&(this.boundingBox=c.clone());let d=t.boundingSphere;return d!==null&&(this.boundingSphere=d.clone()),this.elementsNeedUpdate=t.elementsNeedUpdate,this.verticesNeedUpdate=t.verticesNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.lineDistancesNeedUpdate=t.lineDistancesNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,this}toBufferGeometry(){let t=new hf().fromGeometry(this),e=new Bx,r=new Float32Array(t.vertices.length*3);if(e.setAttribute("position",Ou.call(new dl(r,3),t.vertices)),t.normals.length>0){let o=new Float32Array(t.normals.length*3);e.setAttribute("normal",Ou.call(new dl(o,3),t.normals))}if(t.colors.length>0){let o=new Float32Array(t.colors.length*3);e.setAttribute("color",Rx.call(new dl(o,3),t.colors))}if(t.uvs.length>0){let o=new Float32Array(t.uvs.length*2);e.setAttribute("uv",Vx.call(new dl(o,2),t.uvs))}if(t.uvs2.length>0){let o=new Float32Array(t.uvs2.length*2);e.setAttribute("uv2",Vx.call(new dl(o,2),t.uvs2))}e.groups=t.groups;for(let o in t.morphTargets){let i=[],a=t.morphTargets[o];for(let s=0,l=a.length;s<l;s++){let u=a[s],c=new Va(u.data.length*3,3);c.name=u.name,i.push(Ou.call(c,u.data))}e.morphAttributes[o]=i}if(t.skinIndices.length>0){let o=new Va(t.skinIndices.length*4,4);e.setAttribute("skinIndex",zx.call(o,t.skinIndices))}if(t.skinWeights.length>0){let o=new Va(t.skinWeights.length*4,4);e.setAttribute("skinWeight",zx.call(o,t.skinWeights))}return t.boundingSphere!==null&&(e.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(e.boundingBox=t.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(t){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(t)}dispose(){this.dispatchEvent({type:"dispose"})}static createBufferGeometryFromObject(t){let e=new Bx,r=t.geometry;if(t.isPoints||t.isLine){let o=new Va(r.vertices.length*3,3),i=new Va(r.colors.length*3,3);if(e.setAttribute("position",Ou.call(o,r.vertices)),e.setAttribute("color",Rx.call(i,r.colors)),r.lineDistances&&r.lineDistances.length===r.vertices.length){let a=new Va(r.lineDistances.length,1);e.setAttribute("lineDistance",FM.call(a,r.lineDistances))}r.boundingSphere!==null&&(e.boundingSphere=r.boundingSphere.clone()),r.boundingBox!==null&&(e.boundingBox=r.boundingBox.clone())}else t.isMesh&&(e=r.toBufferGeometry());return e}};Mn.prototype.isGeometry=!0;var hf=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(t){let e=[],r,o,i,a=t.faces;for(o=0;o<a.length;o++){let s=a[o];s.materialIndex!==i&&(i=s.materialIndex,r!==void 0&&(r.count=o*3-r.start,e.push(r)),r={start:o*3,materialIndex:i})}r!==void 0&&(r.count=o*3-r.start,e.push(r)),this.groups=e}fromGeometry(t){let e=t.faces,r=t.vertices,o=t.faceVertexUvs,i=o[0]&&o[0].length>0,a=o[1]&&o[1].length>0,s=t.morphTargets,l=s.length,u;if(l>0){u=[];for(let g=0;g<l;g++)u[g]={name:s[g].name,data:[]};this.morphTargets.position=u}let c=t.morphNormals,d=c.length,p;if(d>0){p=[];for(let g=0;g<d;g++)p[g]={name:c[g].name,data:[]};this.morphTargets.normal=p}let f=t.skinIndices,h=t.skinWeights,m=f.length===r.length,y=h.length===r.length;r.length>0&&e.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let g=0;g<e.length;g++){let b=e[g];this.vertices.push(r[b.a],r[b.b],r[b.c]);let w=b.vertexNormals;if(w.length===3)this.normals.push(w[0],w[1],w[2]);else{let S=b.normal;this.normals.push(S,S,S)}let A=b.vertexColors;if(A.length===3)this.colors.push(A[0],A[1],A[2]);else{let S=b.color;this.colors.push(S,S,S)}if(i===!0){let S=o[0][g];S!==void 0?this.uvs.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",g),this.uvs.push(new Ar,new Ar,new Ar))}if(a===!0){let S=o[1][g];S!==void 0?this.uvs2.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",g),this.uvs2.push(new Ar,new Ar,new Ar))}for(let S=0;S<l;S++){let P=s[S].vertices;u[S].data.push(P[b.a],P[b.b],P[b.c])}for(let S=0;S<d;S++){let P=c[S].vertexNormals[g];p[S].data.push(P.a,P.b,P.c)}m&&this.skinIndices.push(f[b.a],f[b.b],f[b.c]),y&&this.skinWeights.push(h[b.a],h[b.b],h[b.c])}return this.computeGroups(t),this.verticesNeedUpdate=t.verticesNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),this}},za=class{constructor(t,e,r,o,i,a=0){this.a=t,this.b=e,this.c=r,this.normal=o&&o.isVector3?o:new $t,this.vertexNormals=Array.isArray(o)?o:[],this.color=i&&i.isColor?i:new mf,this.vertexColors=Array.isArray(i)?i:[],this.materialIndex=a}clone(){return new this.constructor().copy(this)}copy(t){this.a=t.a,this.b=t.b,this.c=t.c,this.normal.copy(t.normal),this.color.copy(t.color),this.materialIndex=t.materialIndex;for(let e=0,r=t.vertexNormals.length;e<r;e++)this.vertexNormals[e]=t.vertexNormals[e].clone();for(let e=0,r=t.vertexColors.length;e<r;e++)this.vertexColors[e]=t.vertexColors[e].clone();return this}};function FM(n){return this.array.set(n),this}function Rx(n){let t=this.array,e=0;for(let r=0,o=n.length;r<o;r++){let i=n[r];i===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",r),i=new mf),t[e++]=i.r,t[e++]=i.g,t[e++]=i.b}return this}function Vx(n){let t=this.array,e=0;for(let r=0,o=n.length;r<o;r++){let i=n[r];i===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",r),i=new Ar),t[e++]=i.x,t[e++]=i.y}return this}function Ou(n){let t=this.array,e=0;for(let r=0,o=n.length;r<o;r++){let i=n[r];i===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",r),i=new $t),t[e++]=i.x,t[e++]=i.y,t[e++]=i.z}return this}function zx(n){let t=this.array,e=0;for(let r=0,o=n.length;r<o;r++){let i=n[r];i===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",r),i=new GM),t[e++]=i.x,t[e++]=i.y,t[e++]=i.z,t[e++]=i.w}return this}var jM=["a","b","c"];function UM(n,t){switch(t){case"c":return n.c;case"b":return n.b;case"a":default:return n.a}}function gf(n,t,e){let r=Math.min(n,t),o=Math.max(n,t),i=r+"_"+o;return e.get(i)}function xf(n,t,e,r,o,i){let a=Math.min(n,t),s=Math.max(n,t),l=a+"_"+s,u;if(r.has(l))u=r.get(l);else{let c=e[a],d=e[s];u={a:c,b:d,newEdge:null,faces:[]},r.set(l,u)}u.faces.push(o),i[n].edges.push(u),i[t].edges.push(u)}function HM(n,t,e,r){let o,i,a;for(o=0,i=n.length;o<i;o++)e[o]={edges:[]};for(o=0,i=t.length;o<i;o++)a=t[o],xf(a.a,a.b,n,r,a,e),xf(a.b,a.c,n,r,a,e),xf(a.c,a.a,n,r,a,e)}function Cu(n,t,e,r,o){n.push(new za(t,e,r,void 0,void 0,o))}function Ga(n,t){return Math.abs(t-n)/2+Math.min(n,t)}function Tu(n,t,e,r){n.push([t.clone(),e.clone(),r.clone()])}var Mu=class{constructor(t=1){this.subdivisions=t}modify(t){t instanceof kM?t=new Mn().fromBufferGeometry(t):t=t.clone(),t.mergeVertices();let e=this.subdivisions;for(;e-- >0;)this._smooth(t);return t.computeFaceNormals(),t.computeVertexNormals(),t}_smooth(t){let e=new Fx,r,o,i,a,s,l=t.vertices,u=t.faces,c=t.faceVertexUvs[0],d=c!==void 0&&c.length>0,p=[],f=new Map;HM(l,u,p,f);let h=[],m,y,g,b,w,A,S;for(let ee of Array.from(f.keys())){for(y=f.get(ee),g=new Fx,w=3/8,A=1/8,S=y.faces.length,S!=2&&(w=.5,A=0,S!=1),g.addVectors(y.a,y.b).multiplyScalar(w),e.set(0,0,0),a=0;a<S;a++){for(b=y.faces[a],s=0;s<3&&(m=l[UM(b,jM[s])],!(m!==y.a&&m!==y.b));s++);m&&e.add(m)}e.multiplyScalar(A),g.add(e),y.newEdge=h.length,h.push(g)}let P,O,x,D,N,T,I,E=[];for(o=0,i=l.length;o<i;o++){for(T=l[o],N=p[o].edges,r=N.length,r==3?P=3/16:r>3&&(P=3/(8*r)),O=1-r*Number(P),x=P,r<=2&&(r==2?(O=3/4,x=1/8):r==1||r==0),I=T.clone().multiplyScalar(O),e.set(0,0,0),a=0;a<r;a++)D=N[a],m=D.a!==T?D.a:D.b,e.add(m);e.multiplyScalar(Number(x)),I.add(e),E.push(I)}let B=E.concat(h),R=E.length,F,V,q,k=[],U=[],H,Y,J,Z,X=new yf,te=new yf,$=new yf;for(o=0,i=u.length;o<i;o++)b=u[o],F=Number(gf(b.a,b.b,f).newEdge)+R,V=Number(gf(b.b,b.c,f).newEdge)+R,q=Number(gf(b.c,b.a,f).newEdge)+R,Cu(k,F,V,q,b.materialIndex),Cu(k,b.a,F,q,b.materialIndex),Cu(k,b.b,V,F,b.materialIndex),Cu(k,b.c,q,V,b.materialIndex),d&&(H=c[o],Y=H[0],J=H[1],Z=H[2],X.set(Ga(Y.x,J.x),Ga(Y.y,J.y)),te.set(Ga(J.x,Z.x),Ga(J.y,Z.y)),$.set(Ga(Y.x,Z.x),Ga(Y.y,Z.y)),Tu(U,X,te,$),Tu(U,Y,X,$),Tu(U,J,te,X),Tu(U,Z,$,te));t.vertices=B,t.faces=k,d&&(t.faceVertexUvs[0]=U)}};var Nt=new WM,Ux=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=n.geometry??t?.geometry??new kx().copy(new jx(100,100,100)),r;t===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(Nt),r={width:Nt.x,height:Nt.y,depth:Nt.z,subdivisions:0}):r=t.parameters;let o={...r,...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:t,height:e,depth:r,subdivisions:o}=n.parameters,i=n.geometry??new kx().copy(new jx(100,100,100)),a=i.userData.parameters;a===void 0?(i.computeBoundingBox(),i.boundingBox.getSize(Nt)):Nt.set(a.width,a.height,a.depth),(t!==Nt.x||e!==Nt.y||r!==Nt.z)&&i.scale(Nt.x===0?1:t/Nt.x,Nt.y===0?1:e/Nt.y,Nt.z===0?1:r/Nt.z);let s=i.originalGeometry;try{o>0?(s===void 0||a?.subdivisions!==o)&&(s===void 0&&(s=i),i=new Mu(o).modify(s).toBufferGeometry()):(s!==void 0&&(i=s),s=void 0,i.getAttribute("normal")===void 0&&i.computeVertexNormals())}catch{s!==void 0&&(i=s),s=void 0,i.getAttribute("normal")===void 0&&i.computeVertexNormals()}return s!==void 0&&Object.assign(i,{originalGeometry:s}),delete n.geometry,Object.assign(i,{userData:{...n,type:"NonParametricGeometry"}})}static loadFromUrl(n,t,e){new qM(e).load(n,o=>{let i=this.normalizeInputs({geometry:o});o.boundingBox.getSize(Nt);let a=100/Nt.x;Object.assign(i.parameters,{width:100,height:Nt.y*a,depth:Nt.z*a}),t(this.build(i))})}};var Iu=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},n.parameters);return{shape:n.shape&&n.shape instanceof He?n.shape:new He,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:t,height:e,spikes:r,cornerRadius:o,depth:i,extrudeBevelSize:a,extrudeBevelSegments:s}=n.parameters,l=n.shape,u=t*.5,c=e*.5,d=0,p=0,f=2*Math.PI/r;for(let m=0;m<r;m++){let y=f*m,g=d+Math.sin(y)*u,b=p+Math.cos(y)*c;l.addPoint(l.createPoint(g,b))}l.isClosed=!0;for(let m=0,y=l.points.length;m<y;m++)l.points[m].roundness=o;l.roundness=o,l.update();let h=dr.create({shape:l,parameters:{roundness:o,depth:i,extrudeBevelSize:a,extrudeBevelSegments:s}});return Object.assign(h,{userData:{...n,type:"PolygonGeometry"}})}};import{BufferGeometry as $M,Float32BufferAttribute as bf,Vector2 as bo,Vector3 as zt}from"three";var Hx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.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:t,height:e,depth:r,radialSegments:o,heightSegments:i,openEnded:a,cornerRadius:s,cornerSegments:l}=n.parameters,u=new Sf(t*.5,e,o,i,a,s,l);return u.scale(1,1,r/t),Object.assign(u,{userData:{...n,type:"PyramidGeometry"}})}};function pl(n,t,e){e.x=n.x*t.x,e.y=n.y,e.z=n.x*t.y}function vf(n,t,e,r,o,i){let a=t.clone().sub(n),s=e.clone().sub(n),l=a.angleTo(s);if(a.normalize(),s.normalize(),r===o){let u=a.add(s).normalize();i.copy(n).addScaledVector(u,r/Math.sin(l/2))}else{let u=a.angleTo(s);i.copy(n),i.addScaledVector(a,o/Math.sin(u)),i.addScaledVector(s,r/Math.sin(u))}}function YM(n,t,e){let r=n.clone().sub(t),o=e.clone().sub(t);return r.projectOnVector(o),r.add(t)}var Sf=class extends $M{constructor(t=.5,e=1,r=4,o=1,i=!1,a=0,s=4){super(),r=Math.floor(Math.max(3,r)),o=Math.floor(o),s=Math.floor(s);let l=[],u=[],c=[],d=[],p=0,f=e/2,h=Math.PI/r,m=t*Math.cos(Math.PI/r),y=2*Math.PI/r,g=(r-2)*Math.PI/r,b=Math.PI-g,w=new zt(0,-f,0),A=new zt(0,f,0),S=new bo(t,-f),P=new bo(m,-f),O=new bo(0,A.y).sub(P),x=new bo(0,A.y).sub(S),D=new bo(O.y,-O.x).normalize(),N=new bo(x.y,-x.x).normalize(),I=t*Math.cos(Math.PI/r)*Math.tan((Math.PI-O.angle())/2)-1e-8;a=Math.min(a,I);let E;{let U=new zt(D.x,D.y,0),H=new zt(Math.cos(y)*U.x,U.y,Math.sin(y)*U.x);E=U.angleTo(H)}let B=a/Math.tan((Math.PI-O.angle())/2),R=a/Math.tan((Math.PI-E)/2),F=new zt;if(!i){u.push(w.x,w.y,w.z),c.push(0,-1,0),d.push(0,0);let U=p++,H=[],Y=S.clone(),J=B/Math.cos(Math.PI/r);Y.x-=J;for(let Z=0;Z<r;Z++){let X=Z/r*Math.PI*2+h,te=new bo(Math.sin(X),Math.cos(X));pl(Y,te,F),u.push(F.x,F.y,F.z),c.push(0,-1,0),d.push(0,0),H.push(p++)}for(let Z=0;Z<H.length;Z++)l.push(H[Z],U,H[(Z+1)%H.length])}let V=[];{let U=new zt,H=new zt,Y=new zt,J=new zt,Z=new zt,X=new zt;for(let te=0;te<r;te++){let $=te/r*Math.PI*2+h,ee=(te+.5)/r*Math.PI*2+h,Q=(te+1)/r*Math.PI*2+h,W=new bo(Math.sin($),Math.cos($)),ue=new bo(Math.sin(ee),Math.cos(ee)),le=new bo(Math.sin(Q),Math.cos(Q));pl(S,W,H),pl(S,le,Y),pl(D,ue,U),vf(A,H,Y,R,R,J),u.push(J.x,J.y,J.z),vf(H,A,Y,R,B,Z),u.push(Z.x,Z.y,Z.z),vf(Y,H,A,B,R,X),u.push(X.x,X.y,X.z),c.push(U.x,U.y,U.z),c.push(U.x,U.y,U.z),c.push(U.x,U.y,U.z),d.push(0,0),d.push(0,0),d.push(0,0);let ne=p++,ce=p++,ae=p++;if(l.push(ne,ce,ae),a>0){{let fe=H.clone().add(Y).multiplyScalar(.5),ge=A.clone().sub(fe).normalize(),C=w.clone().sub(fe).normalize().add(ge).normalize().multiplyScalar(-1),ie=X.clone().sub(Z);q(fe,ie,C,O.angle())}let he,pe;{let fe=new zt;pl(N,le,fe);let ge=X.clone().add(J).multiplyScalar(.5);ge=YM(ge,Y,A);let me=X.clone().sub(J);[he,pe]=q(ge,me,fe,E,J.y)}{let fe=he,ge=fe.clone().setY(0).normalize(),me=new zt(0,-1,0),C=ge.clone().cross(me);k(fe,ge,me,C)}V.concat(pe);{let fe=O.angle(),ge=Math.PI-fe,me=A.clone();me.y-=a/Math.sin(fe-Math.PI/2);let C=new zt,ie=[];for(let Ge=0;Ge<s;Ge++){let Ee=[],_e=Math.PI/2-ge*Ge/s,Ct=Math.cos(_e),Me=Math.sin(_e),At=ee;for(let Tt=0;Tt<=Ge;Tt++){let Wn=Math.cos(At),st=Math.sin(At);U.x=Ct*st,U.y=Me,U.z=Ct*Wn,C.copy(me).addScaledVector(U,a),u.push(C.x,C.y,C.z),c.push(U.x,U.y,U.z),d.push(0,0),Ee.push(p++),At+=Math.PI*2/Ge/r}ie.push(Ee)}pe.reverse(),ie.push(pe);let De=ie.length-1;for(let Ge=0;Ge<De;Ge++){let Ee=ie[Ge],_e=ie[Ge+1],Ct=Ee.length-1;l.push(_e[1],Ee[0],_e[0]);for(let Me=1;Me<=Ct;Me++)l.push(Ee[Me],Ee[Me-1],_e[Me]),l.push(_e[Me+1],Ee[Me],_e[Me])}}}}}this.setIndex(l),this.setAttribute("position",new bf(u,3)),this.setAttribute("normal",new bf(c,3)),this.setAttribute("uv",new bf(d,2));function q(U,H,Y,J,Z){let X=-J/2,te=(Math.PI-J)/2,$=H.clone().normalize().cross(Y);U.addScaledVector(Y,-a/Math.sin(te));let ee=new zt,Q=new zt,W=1,ue=p,le=[];for(let ne=0;ne<=s;ne++){let ce=X+ne/s*J;Q.set(0,0,0),Q.addScaledVector($,Math.sin(ce)),Q.addScaledVector(Y,Math.cos(ce));for(let ae=0;ae<=W;ae++){let he=ae/W-.5;if(ee.copy(U),ee.addScaledVector(H,he),ee.addScaledVector(Q,a),Z!=null){let pe=Math.max(0,ee.y-Z);ee.addScaledVector(H,-pe/H.y)}u.push(ee.x,ee.y,ee.z),c.push(Q.x,Q.y,Q.z),d.push(0,0),ae===0&&le.push(p),p++}}for(let ne=0;ne<s;ne++)for(let ce=0;ce<W;ce++){let ae=ue+ce+(W+1)*ne,he=ae+(W+1),pe=he+1,fe=ae+1;l.push(ae,he,fe),l.push(he,pe,fe)}return[U.clone().addScaledVector(H,.5),le]}function k(U,H,Y,J){let Z=Math.PI/2,X=x.angle()-Z,te=[],$=new zt,ee=new zt;for(let W=0;W<=s;W++){let ue=[],le=W/s;for(let ne=0;ne<=W;ne++){let ae=((W?ne/W:0)-.5)*b,he=Math.cos(ae),pe=Math.sin(ae),fe=Math.atan(Math.tan(X)*he),ge=(Z+fe)*le,me=Math.cos(ge),C=Math.sin(ge);$.set(0,0,0),$.addScaledVector(H,C*he),$.addScaledVector(Y,me),$.addScaledVector(J,C*pe),ee.copy(U).addScaledVector($,a),u.push(ee.x,ee.y,ee.z),c.push($.x,$.y,$.z),d.push(0,0),ue.push(p++)}te.push(ue)}let Q=te.length-1;for(let W=0;W<Q;W++){let ue=te[W],le=te[W+1],ne=ue.length-1;l.push(ue[0],le[1],le[0]);for(let ce=1;ce<=ne;ce++)l.push(ue[ce-1],ue[ce],le[ce]),l.push(ue[ce],le[ce+1],le[ce])}}}};var Fa=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters),r=Object.assign(t?.ui??{enabledIndieCorners:!1},n.ui);return{shape:n.shape&&n.shape instanceof He?n.shape:new He,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)}),ui:r}}static build(n){let t=n.shape,{width:e,height:r,cornerRadius:o,cornerType:i,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}=n.parameters,u={x:e*.5,y:r*.5},c={x:-u.x,y:-u.y},d={x:u.x,y:u.y};function p(A,S,P){return S>e&&P>r?Math.min(A*e/S,A*r/P):S>e?A*e/S:P>r?A*r/P:A}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 h=c.x,m=d.x,y=d.y,g=c.y;t.addPoint(t.createPoint(h,y)),t.addPoint(t.createPoint(m,y)),t.addPoint(t.createPoint(m,g)),t.addPoint(t.createPoint(h,g)),t.isClosed=!0;let b=!0;for(let A=0,S=t.points.length;A<S;A++)t.points[A].roundness=f[A],A>0&&f[A]!==f[A-1]&&(b=!1);b&&(t.roundness=f[0]),t.useCubicForRoundedCorners=i!==1,t.update();let w=dr.create({shape:t,parameters:{depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}});return Object.assign(w,{userData:{...n,type:"RectangleGeometry"}})}};import{BufferGeometry as XM,Float32BufferAttribute as QM,MathUtils as qx,SphereGeometry as KM}from"three";var Wx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180},n.parameters);return e.thetaLength=qx.clamp(e.thetaLength,0,180),{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:t=100,height:e=t,depth:r=t,widthSegments:o=64,heightSegments:i=64,phiStart:a,phiLength:s,thetaStart:l,thetaLength:u}=n.parameters,c;return u===0?(c=new XM,c.setAttribute("position",new QM([],3))):c=new KM(.5*t,o,i,a,s,l,u*qx.DEG2RAD),c.scale(1,e/t,r/t),Object.assign(c,{userData:{...n,type:"SphereGeometry"}})}};import{PlaneGeometry as ZM}from"three";var $x=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.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:t=100,height:e=t,widthSegments:r=8,heightSegments:o=8}=n.parameters,i=new ZM(t,e,r,o);return i.scale(1,1,1),Object.assign(i,{userData:{...n,type:"PlaneGeometry"}})}};import{BufferGeometry as JM,Float32BufferAttribute as wf,Vector3 as eI}from"three";var Yx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.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:t,height:e,depth:r,angle:o,cornerRadius:i,cornerSegments:a}=n.parameters,s=new Af(t,e,r,o,i,a);return Object.assign(s,{userData:{...n,type:"BackdropGeometry"}})}},Af=class extends JM{constructor(t=1,e=1,r=1,o=90,i=10,a=24){super(),this.type="BackdropGeometry";let s=[],l=[],u=[],c=.001;i==0&&(a=1),a=Math.max(1,Math.floor(a)),i=Math.min(i,100),o=Math.min(180-c,o),o*=Math.PI/180;let d=[],p=Math.PI/2,f=(ee=0,Q=0,W=0)=>new eI(ee,Q,W),h=f(),m=f(),[y,g,b]=[e/2,t/2,r/2],w=-g,A=+g,[S,P,O]=[f(w,-y,+b),f(w,-y,-b),f(w,+y,-b)],x=(ee,Q=!1)=>Math.sin(ee-Math.PI/(1+ +Q)),D=(ee,Q=!1)=>Math.cos(ee-Math.PI/(1+ +Q));O.y=Math.sin(o)*e-y;let N=Math.cos(o)*e-b,T=S.z-c;o<=p?(O.z=Math.min(N,T),O.z==T&&(O.y-=(N-T)/Math.tan(p-o))):P.z=Math.min(P.z-N-b,S.z-c),h.subVectors(S,P),m.subVectors(O,P);let I=Math.min(h.length(),m.length())*i/100,E=I*Math.tan(o/2),B=I/Math.cos(o/2),R=h.clone().normalize().add(m.normalize()).setLength(B).add(P);h.set(0,x(o,!0),D(o,!0)),d.push([O,h.clone()]);let F=(Math.PI-o)/a;for(let ee=0;ee<=a;ee++){let Q=p+o+ee*F;h.set(0,Math.sin(Q)*E,Math.cos(Q)*E),h.add(R),m.set(0,x(Q),D(Q)),d.push([h.clone(),m.clone()])}d.push([S,f(0,1,0)]);let V=Math.sin(F/2)*E*2,q=d.length-1,k=d[0][0].distanceTo(d[1][0]),U=d[q-1][0].distanceTo(d[q][0]),H=k+V*a+U;d[0].push(1);for(let ee=0;ee<=a;ee++)d[ee+1].push(1-(k+ee*V)/H);d[q].push(0);let[Y,J,Z]=d[0],X,te,$;for(let ee=1;ee<d.length;ee++)[X,te,$]=d[ee],s.push(w,Y.y,Y.z,w,X.y,X.z,A,Y.y,Y.z,A,Y.y,Y.z,w,X.y,X.z,A,X.y,X.z),l.push(0,J.y,J.z,0,te.y,te.z,0,J.y,J.z,0,J.y,J.z,0,te.y,te.z,0,te.y,te.z),u.push(0,Z,0,$,1,Z,1,Z,0,$,1,$),[Y,J,Z]=[X,te,$];this.setAttribute("position",new wf(s,3)),this.setAttribute("normal",new wf(l,3)),this.setAttribute("uv",new wf(u,2))}};var Nu=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.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 He?n.shape:new He,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:t,height:e,innerRadiusPercent:r,spikes:o,cornerRadius:i,angle:a,depth:s,extrudeBevelSize:l,extrudeBevelSegments:u}=n.parameters,c=n.shape,d=t*.5,p=e*.5,f=0,h=0,m=a*Math.PI/360/o,y=Math.PI/2*3*-1,g=d*r/100,b=p*r/100;if(o===3&&r===50){m=2*Math.PI/o;for(let A=0;A<o;A++){let S=m*A,P=f+Math.sin(S)*d,O=h+Math.cos(S)*p;c.addPoint(c.createPoint(P,O))}}else for(let A=0;A<o;A++){let S=f+Math.cos(y)*d,P=h+Math.sin(y)*p;c.addPoint(c.createPoint(S,P)),y+=m,S=f+Math.cos(y)*g,P=h+Math.sin(y)*b,A<=o,c.addPoint(c.createPoint(S,P)),y+=m}c.isClosed=!0;for(let A=0,S=c.points.length;A<S;A++)c.points[A].roundness=i;c.roundness=i,c.update();let w=dr.create({shape:c,parameters:{roundness:i,depth:s,extrudeBevelSize:l,extrudeBevelSegments:u}});return Object.assign(w,{userData:{...n,type:"StarGeometry"}})}};import{PlaneGeometry as tI}from"three";var Xx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.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:t,height:e}=n.parameters,r=new tI(t,e);return Object.assign(r,{userData:{...n,type:"TextFrameGeometry"}})}};import{BufferGeometry as rI,Float32BufferAttribute as oI,MathUtils as nI}from"three";var Qx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:360,cornerRadius:30,cornerSegments:8},n.parameters),r=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:r,height:o,depth:i})}}static build(n){let{width:t,height:e,depth:r,radialSegments:o,tubularSegments:i,arc:a,cornerRadius:s,cornerSegments:l}=n.parameters,u=iI(t,e,r,t*.5,a,i,0,0,o,s,l);return u.scale(1,e/t,1),Object.assign(u,{userData:{...n,type:"TorusGeometry"}})}};function iI(n,t,e,r,o,i,a,s,l,u,c){[t,e]=[e,t],a=t/2;let d=nI.clamp(o/360,0,1);if(d===0){let p=new rI;return p.setAttribute("position",new oI([],3)),p}return d===1&&(u=0),new cl(!0,n,t,e,r,d,i,a,s,l,u,c)}import{TorusKnotGeometry as aI}from"three";var Kx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.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:t,tube:e,tubularSegments:r,radialSegments:o,p:i,q:a}=n.parameters,s=t*.5;s!==e&&(s-=e);let l=new aI(s,e,r,o,i,a);return Object.assign(l,{userData:{...n,type:"TorusKnotGeometry"}})}};var Zx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},n.parameters);return{shape:n.shape&&n.shape instanceof He?n.shape:new He,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:t=100,height:e,cornerRadius:r,depth:o,extrudeBevelSize:i,extrudeBevelSegments:a,isRect:s}=n.parameters,l=n.shape,u=t*.5,c=e*.5;s?(l.addPoint(l.createPoint(-u,c)),l.addPoint(l.createPoint(u,-c)),l.addPoint(l.createPoint(-u,-c))):(l.addPoint(l.createPoint(0,c)),l.addPoint(l.createPoint(u,-c)),l.addPoint(l.createPoint(-u,-c))),l.isClosed=!0;for(let p=0,f=l.points.length;p<f;p++)l.points[p].roundness=r;l.roundness=r,l.update();let d=dr.create({shape:l,parameters:{roundness:r,depth:o,extrudeBevelSize:i,extrudeBevelSegments:a}});return Object.assign(d,{userData:{...n,type:"TriangleGeometry"}})}};import{Vector2 as eb,Vector3 as Gt,Matrix3 as sI,Matrix4 as li,BufferGeometry as tb,BufferAttribute as ka,MathUtils as Du}from"three";function Jx(n,t){let e=2*Math.PI;return(n%e+e)%e===(t%e+e)%e}var lI=new li,cI=new li;function uI(n,t,e){let r=[new Gt,new Gt,new Gt],o=[new Gt,new Gt,new Gt];return n.extractBasis(r[0],r[1],r[2]),t.extractBasis(o[0],o[1],o[2]),r.forEach((i,a)=>{let s=o[a],l=Du.lerp(i.length(),s.length(),e);i.lerp(s,e).setLength(l)}),new li().makeBasis(r[0],r[1],r[2])}var rb=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},n.parameters),r=Math.abs(e.width),o=Math.abs(e.height??e.width),i=Math.abs(e.depth??0),a=t?.shapeData??Ra.create({parameters:yp}).userData.shape;return{path:n.path??ha.defaultData(),parameters:Object.assign(e,{width:r,height:o,depth:i,extrusion:{...Hc,...e.extrusion}}),shapeData:a}}static build(n){if(n.path.points.length>=2){let e=new _f(n);return Object.assign(e,{userData:{...n,type:"PathGeometry"}})}else return Object.assign(new tb,{userData:{...n,type:"PathGeometry"}})}},_f=class extends tb{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)||!Jx(e.twist,0)||e.startScale!==e.endScale}build(){let e=this._extractPathPoints();if(e.length<2)return;let r=this._computeBasisMatrices(e),{depth:o,offset:i}=this.inputs.parameters.extrusion;o=Math.max(0,Math.min(o,1)),i=Math.max(0,Math.min(i,1));let a=this.inputs.path.isClosed?e.length:e.length-1,s=Math.floor(i*a),l=this.inputs.path.isClosed?Math.ceil((o+i)*a):Math.ceil(Math.min(1,o+i)*a),u=Math.min(Math.max(2,l-s+1),a+2),c=[],d=[];for(let k=0;k<u;k++){let U=this.inputs.path.isClosed?(k+s)%e.length:Math.min(k+s,e.length-1);c.push(e[U].clone()),d.push(r[U].clone())}let p=(k,U,H)=>{c[k]=c[k].clone().lerp(c[U],H),d[k]=uI(d[k],d[U],H)},f=0,h=i*a%1;(!this.inputs.path.isClosed||o<=1)&&(h||i===0)&&(f=h,p(0,1,f));let m=0,y=(i+o)*a%1;if((this.inputs.path.isClosed&&o<=1||!this.inputs.path.isClosed&&i+o<1)&&y&&(m=y,p(c.length-1,c.length-2,1-m)),o===0){let k=c.length-1;c[k].copy(c[0]),d[k].copy(d[0])}this._applyPathModifiers(d,f,m);let{bevel:g,bevelSides:b}=this.inputs.parameters.extrusion,w=g>0?this.inputs.parameters.extrusion.capType:"flat",A=5;this.inputs.parameters.extrusion.shape.type==="Custom"&&(A=this.inputs.parameters.extrusion.shape.shapeQuality==="low"?5:12);let{regions:S,infos:P,vertices:O}=this._computeShapePoints(A),x=0,D;w==="round"&&(D=new Tn(this.inputs.shapeData,2*g,g,A,b,void 0,!0),x=D.getAttribute("position").count);let N=0,T=0;P.sort((k,U)=>k.start-U.start),P.forEach(k=>{k.verticesStart=N,k.verticesCount=k.continuous.reduce((U,H,Y)=>U+(Y===0||!H?2:1),0),T+=k.verticesCount,N=T});let I=T*u,E,B=0;if(this._isOpenEnded()&&w==="flat"){try{E=Qr({windingRule:je.ODD,elementType:dt.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:S})}catch{E=cf}B=E.vertexCount}let R=I+2*B+x*2,F=I+2*B,V={positions:new Float32Array(R*3),normals:new Float32Array(R*3),uvs:new Float32Array(R*2)},q=[];if(P.forEach(k=>{this._extrudeRegion(k,O,d,c,V,q,this._isGeometryClosed()&&!this._isOpenEnded())}),E&&(this._closeEnd(E,I,q,V,d[0],c[0],!1),this._closeEnd(E,I+B,q,V,d[d.length-1],c[c.length-1],!0)),D){V.positions.set(D.getAttribute("position").array,F*3),V.normals.set(D.getAttribute("normal").array,F*3),V.uvs.set(D.getAttribute("uv").array,F*2);let k=q.length;q.push(...D.getIndex().array.map(Y=>Y+F)),F+=x,V.positions.set(D.getAttribute("position").array,F*3),V.normals.set(D.getAttribute("normal").array,F*3),V.uvs.set(D.getAttribute("uv").array,F*2);let U=q.length;q.push(...D.getIndex().array.map(Y=>Y+F)),this.setAttribute("position",new ka(V.positions,3)),this.setAttribute("normal",new ka(V.normals,3)),this.setAttribute("uv",new ka(V.uvs,2)),this.setIndex(q);let H=lI;H.copy(d[d.length-1]).setPosition(c[c.length-1]),this.applyMatrix4OnRange(H,F,R),H.copy(d[0]).setPosition(c[0]).multiply(cI.makeScale(1,1,-1)),this.applyMatrix4OnRange(H,F-x,F),this.reverseIndicesOnRange(k,U)}else this.setAttribute("position",new ka(V.positions,3)),this.setAttribute("normal",new ka(V.normals,3)),this.setAttribute("uv",new ka(V.uvs,2)),this.setIndex(q)}_extractPathPoints(){let r=du(this.inputs.path).getPoints(this.inputs.path.subdivisions);if(r.length<2)return[];let o=[r[0]];return r.forEach(a=>{o[o.length-1].distanceToSquared(a)>.001&&o.push(a)}),this.inputs.path.isClosed&&o[o.length-1].distanceTo(o[0])<.001&&o.pop(),o}_computeBasisMatrices(e){let r=[],o=e.length,i=this.inputs.path.isClosed,a=new Gt,s=new Gt,l=new Gt,u=new Gt,c=new Gt(0,1,0);for(let y=0;y<o;y++){let g=e[y],b;y===0?b=i?e[e.length-2]:g.clone().multiplyScalar(2).sub(e[1]):b=e[y-1];let w;y===o-1?w=i?e[1]:g.clone().multiplyScalar(2).sub(e[y-1]):w=e[y+1];let A=g.clone().sub(b).normalize(),S=w.clone().sub(g).normalize(),P=A.clone().add(S).normalize();l.copy(P),y===0&&(P.equals(c)||P.clone().negate().equals(c))&&c.set(0,0,1);let O=c.clone().cross(P).normalize(),x=P.clone().cross(O).normalize();c.copy(x),u.copy(O),y===0&&(a.copy(x),s.copy(P));let D=new li().makeBasis(O,x,P);r.push(D)}let d=i?s:l,p=i?a:new Gt(0,1,0),f=d.clone().cross(u).normalize(),h=Math.acos(p.dot(f));if(isNaN(h))return r;let m=p.clone().cross(f);d.dot(m)>0&&(h*=-1);for(let y=1;y<r.length;y++){let g=new li().makeRotationZ(h*y/r.length);r[y].multiply(g)}return r}_applyPathModifiers(e,r,o){let i=e.length,{angle:a,twist:s,startScale:l,endScale:u}=this.inputs.parameters.extrusion,c=new li,d=new li;return e.forEach((p,f)=>{let h=f===0?0:f===i-1?1:(f-r)/(i-(o===0?0:1)-(r+(1-o)));c.makeRotationZ(Du.lerp(a,a+s,h)*Du.DEG2RAD);let m=Du.lerp(l,u,h);d.makeScale(m,m,m),p.multiply(c).multiply(d)}),e}_computeShapePoints(e=12,r=je.ODD){let o=this.inputs.shapeData,i=o.extractShapePointsToFlatArray([],e),a=o.shapeHoles.map(m=>{let y=m.extractShapePointsToFlatArray([],e),g=[];for(let b=y.length-1;b>=1;b-=2){let w=y[b-1],A=y[b-0];g.push(w,A)}return g}),s;try{s=Qr({windingRule:r,elementType:dt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[i]})}catch{s=ll}let l;try{l=Qr({windingRule:je.ODD,elementType:dt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...a]})}catch{l=lf}if(!s)throw new Error("error generating geometry");let u=s.elementCount;if(l){s.elementCount+=l.elementCount;for(let m=0;m<l.elements.length;m++){let y=l.elements[m],g=m%2===0?s.vertexCount:0;s.elements.push(y+g)}for(let m=0;m<l.vertexIndices.length;m++){let y=l.vertexIndices[m],g=s.vertexCount;s.vertexIndices.push(y+g)}for(let m=0;m<l.vertices.length;m++){let y=l.vertices[m];s.vertices.push(y)}}let c=1/0,d=-1/0,p=1/0,f=-1/0;for(let m=0,y=s.vertexCount;m<y;m++){let g=m*2,b=s.vertices[g+0],w=s.vertices[g+1];b<c&&(c=b),b>d&&(d=b),w<p&&(p=w),w>f&&(f=w)}let h=[];for(let m=s.elementCount-1;m>=0;m--){let y=m>=u,g=m*2,b=s.elements[g+0],w=s.elements[g+1],A=b+w,S={start:b,count:w,normals:[],isHole:y,continuous:[],verticesStart:0,verticesCount:0};h.push(S);let P=b,O=A-1,x=b+1,D=o.roundedCurves.length;do{let N=P-b,T=s.vertices[O*2+0],I=s.vertices[O*2+1],E=s.vertices[P*2+0],B=s.vertices[P*2+1],R=s.vertices[x*2+0],F=s.vertices[x*2+1],V=E-T,q=B-I,k=Math.sqrt(V*V+q*q);V/=k,q/=k;let U=E-R,H=B-F,Y=Math.sqrt(U*U+H*H);U/=Y,H/=Y,S.normals[N*2+0]=-H,S.normals[N*2+1]=U;let J=s.vertexIndices[P];if(Array.isArray(J))S.continuous[N]=!1;else{let[Z,X]=o.getCurveIndexFromVertexId(J-1,!0);if(X>0&&X<1)S.continuous[N]=!0;else{let te=X===1?Z+1:Z-1;te=(te+D)%D;let $=X===1?0:1,ee=o.roundedCurves[Z].getTangent(X),Q=o.roundedCurves[te].getTangent($);S.continuous[N]=ee.dot(Q)>.95}}y&&(S.normals[N*2+0]*=-1,S.normals[N*2+1]*=-1),[O,P,x]=[P,x,x+1],x>=A&&(x-=w)}while(x!==b+1)}return{regions:[i,...a],infos:h,vertices:s.vertices}}_insertVertex(e,r,o,i,a){let s=r*2,l=r*3;e.positions[l+0]=o.x,e.positions[l+1]=o.y,e.positions[l+2]=o.z,e.normals[l+0]=i.x,e.normals[l+1]=i.y,e.normals[l+2]=i.z,e.uvs[s+0]=a.x,e.uvs[s+1]=a.y}_extrudeRegion(e,r,o,i,a,s,l){let u=new Gt,c=new Gt,d=new Gt,p=new Gt,f=new eb;o.forEach((m,y)=>{let g=i[y],b=e.verticesStart*o.length+e.verticesCount*y;for(let w=0;w<e.count;w++){let A=(e.start+w)*2;if(u.set(r[A+0],r[A+1],0),d.copy(u).applyMatrix4(m).add(g),e.continuous[w])p.set(e.normals[w*2+0],e.normals[w*2+1],0);else{let S=w===0?(e.start+e.count-1)*2:A-2;c.set(r[S+0],r[S+1],0),p.copy(u).sub(c),p.set(-p.y,p.x,0),e.isHole||p.negate()}if(p.applyMatrix4(m).normalize(),f.set(w===0?1:w/e.count,y/(o.length-1)),this._insertVertex(a,b,d,p,f),b++,!e.continuous[w]||w===0){if(w===0)p.set(e.normals[w*2+0],e.normals[w*2+1],0),f.set(0,y/(o.length-1));else{let S=w===e.count-1?e.start*2:A+2;c.set(r[S+0],r[S+1],0),p.copy(c).sub(u),p.set(-p.y,p.x,0),e.isHole||p.negate()}p.applyMatrix4(m).normalize(),this._insertVertex(a,b,d,p,f),b++}}});let h=o.length-1;for(let m=0;m<h;m++){let y=e.verticesStart*o.length+e.verticesCount*m,g=e.verticesStart*o.length+e.verticesCount*(m+1),b=0;for(let w=0;w<e.count;w++){(!e.continuous[w]||w===0)&&b++;let A=w===e.count-1?0:b+1,S=y+b,P=y+A,O=g+A,x=g+b;e.isHole?s.push(S,O,P,S,x,O):s.push(S,P,O,S,O,x),b++}}}_closeEnd(e,r,o,i,a,s,l){let u=e.vertexCount,c=new Gt(0,0,l?-1:1).applyMatrix4(a),d=new Gt,p=new eb;for(let h=0;h<u;h++){let m=2*h;d.set(e.vertices[m+0],e.vertices[m+1],0).applyMatrix4(a).add(s),this._insertVertex(i,r+h,d,c,p)}let f=e.elements;for(let h=0;h<e.elementCount;h++){let m=3*h,y=f[m+0]+r,g=f[m+(l?1:2)]+r,b=f[m+(l?2:1)]+r;o.push(y,g,b)}}applyMatrix4OnRange(e,r,o){let i=e.elements,a=new sI().getNormalMatrix(e).elements,s,l,u,c,d=this.attributes.position,p=this.attributes.normal;if(!d||!p)return;let f=d.array,h=p.array,m=d.itemSize;for(let y=r*m,g=o*m;y<g;y+=m){if(y===r)debugger;s=f[y+0],l=f[y+1],u=f[y+2],c=1/(i[3]*s+i[7]*l+i[11]*u+i[15]),f[y+0]=(i[0]*s+i[4]*l+i[8]*u+i[12])*c,f[y+1]=(i[1]*s+i[5]*l+i[9]*u+i[13])*c,f[y+2]=(i[2]*s+i[6]*l+i[10]*u+i[14])*c,s=h[y+0],l=h[y+1],u=h[y+2],h[y+0]=a[0]*s+a[3]*l+a[6]*u,h[y+1]=a[1]*s+a[4]*l+a[7]*u,h[y+2]=a[2]*s+a[5]*l+a[8]*u}d.needsUpdate=!0,p.needsUpdate=!0}reverseIndicesOnRange(e,r){let o=this.index;if(o){for(let i=e;i<r;i+=3){let a=o.getX(i),s=o.getX(i+1),l=o.getX(i+2);o.setXYZ(i,l,s,a)}o.needsUpdate=!0}}};import{BufferAttribute as ob,BufferGeometry as Pf}from"three";import{mergeBufferGeometries as pI}from"three/examples/jsm/utils/BufferGeometryUtils.js";function nb(){let n=new Pf;return n.setAttribute("position",new ob(new Float32Array([]),3)),n.setIndex(new ob(new Uint16Array([]),1)),n}var fI=nb().attributes,hI=12,mI=1,ja=class extends Pf{constructor(e,r){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];Object.assign(this.attributes,fI),this.userData={parameters:e,type:"TextGeometry"};let o=r.getFont(e.font);o?.isLoaded?(this.font=o,this.update(e)):this.updateFont(e.font,r).then(()=>{this.update(e),r?.requestRender()})}async updateFont(e,r){let o=r.getFont(e);o&&(this.font=o,await o.loadingPromise)}update(e){let r=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!r?.isLoaded){console.warn("Cannot update text because its font is not loaded");return}let{width:o,height:i,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l,text:u,textTransform:c}=e,d=Jc.getDisplayedValue(u),p=c===2?d.toUpperCase():c===3?d.toLowerCase():d,f=yI(e,r,p),{shapes:h,charWidths:m,charCoords:y}=r.generateShapes(f,e),g=(typeof o=="number"?o:1)*.5,b=(typeof i=="number"?i:1)*.5,w=h.map(P=>new He().fromShape(P,!0));this.vectorShapes=w;let A=w.map(P=>dr.create({shape:P,parameters:{depth:a,extrudeBevelSegments:l,extrudeBevelSize:s,windingRule:a<=0?je.NONZERO:je.ODD,subdivisions:this.isLowResolution&&a>0?mI:hI}})),S=A.length?pI(A):nb();S.translate(-g,b,0),this.dispose(),this.wrappedText=f,this.charCoords=y,this.charWidths=m,this.deleteAttribute("extrudeNormal"),Object.entries(S.attributes).forEach(([P,O])=>{this.setAttribute(P,O)}),this.setIndex(S.index),this.computeBoundingSphere()}clone(){let e=rr(new Pf,ja.prototype);return e.copy(this),console.log("CloneGeometry",this,e),e}copy(e){return Object.entries(e.attributes).forEach(([r,o])=>{this.setAttribute(r,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 yI(n,t,e){let r=[""],o="";for(let i of e)o+=i,i===" "||i===`
17
17
  `?(r[r.length-1]+=o,o="",i===`
18
- `&&r.push("")):t.getTextWidth(r[r.length-1]+o,n)>n.width&&(r[r.length-1].length&&r.push(""),t.getTextWidth(r[r.length-1]+o,n)>n.width&&(o.length===1?(r[r.length-1]+=o,o=""):(r[r.length-1]+=o.slice(0,-1),o=o[o.length-1],r.push(""))));return r[r.length-1]+=o,r}import{BufferGeometry as Of,BufferAttribute as sb,Uint32BufferAttribute as Cf,Float32BufferAttribute as Tf,Matrix4 as gI,Vector3 as hl,Sphere as xI,Box3 as bI,BoxGeometry as vI}from"three";var ib,Bu=new Promise(n=>{ib=n}),nb=!1;var Eu;function ab(){if(nb)return;if(Eu)return Eu;async function n(){let e=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@1.0.40/build",o=import("./process.js"),[i,a]=await Promise.all([o,fetch(`${e}/process.wasm`).then(u=>u.arrayBuffer())]),s=i.default,l=await s({wasmBinary:a});ib(l),nb=!0}return Eu=n(),Eu}import{BufferGeometryLoader as fI}from"three";var hI=["font"];function Qo(n,t,e,r){let o,i,a;n.type==="PathGeometry"?(i=JSON.parse(JSON.stringify(n)),a=[[],["extrusion"]]):(i={...n},a=[[]]);for(let u of a){let c=i;for(let d of u)c=c[d];for(o in c){let d=c[o];pp(d)&&!hI.includes(o)&&(c[o]=t.getVariable(d,[r.uuid,"geometry",...u,o]),pp(c[o])&&(c[o]=1))}}let s={parameters:i,type:i.type};if(i.type==="PathGeometry")s.path=i.path;else if(i.type==="VectorGeometry"){let u=He.createFromState(i.shape,i.width,i.height);s.shape=u}else if(i.type==="NonParametricGeometry")i.data.groups&&i.data.groups?.forEach(u=>u.materialIndex=Math.max(u.materialIndex??0,0)),s.geometry=new fI().parse(i);else if(i.type==="SubdivGeometry"){let u=new wt(i,e);return u.data=n,u}else{if(i.type==="TextGeometry")return new ka(i,t);if(i.type==="UIGeometry")return Ga.create({parameters:{width:i.width,height:i.height,cornerRadius:i.cornerRadius,cornerType:i.cornerType}})}let l;try{l=Pf(s)}catch(u){console.error(u)}if(!l){let u=He.createFromState(pa.defaultData(),100,100);s.shape=u,l=Pf(s)}return l}import{Matrix4 as mI}from"three";var yI=new mI;function fl(n,t,e,r){let o=n.position.array,i=n.normal.array,a=yI.makeScale(t,e,r).invert().elements,s,l,u;for(var c=0,d=o.length;c<d;c+=3)o[c]*=t,o[c+1]*=e,o[c+2]*=r,s=i[c],l=i[c+1],u=i[c+2],i[c]=a[0]*s+a[4]*l+a[8]*u,i[c+1]=a[1]*s+a[5]*l+a[9]*u,i[c+2]=a[2]*s+a[6]*l+a[10]*u;n.position.needsUpdate=!0,n.normal.needsUpdate=!0}var Lu=new bI,ja=new hl,we;Bu.then(n=>{we=n});var lb=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),cb=new Uint32Array([0,1,2,3]),ub=new Uint8Array([4]),wt=class extends Of{constructor(e,r){super();this.data=e;this.flatShading=r;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,r){this.freeSubdivPointer();let o=this.data.scaleBaked,i=gn.div(r,o);this.subdividedGeometry&&fl(this.subdividedGeometry.attributes,...i),this.originalGeometry&&fl(this.originalGeometry.attributes,...i),this.data=e;let a=this.userData.parameters;this.userData.parameters={width:a.width*i[0],height:a.height*i[1],depth:a.depth*i[2]},this.originalGeometry.boundingSphere.center.multiply(ja.fromArray(i));let s=ja.set(a.width,a.height,a.depth).length();this.originalGeometry.boundingSphere.radius=s/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,r,o;try{({originalGeometry:e,subdividedGeometry:r,subdivPointer:o}=wt.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new vI(100,100,100),o=0}this.subdivPointer=o,this.originalGeometry=e,this.subdividedGeometry=r??void 0;let i=this.subdividedGeometry??this.originalGeometry;Object.assign(this,i),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(wt.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new xI,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,o=e.boundingSphere.center;Lu.setFromBufferAttribute(r),Lu.getCenter(o),e.boundingSphere.radius=o.distanceTo(Lu.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Lu.getSize(ja);let i={width:ja.x,height:ja.y,depth:ja.z};return this.userData.parameters=i,i}static build(e,r,o,i){let a,s,l,u=e?.phongAngle??35;o===!1&&(u=-1),r&&(we.free_bvh(r),we.free_subdivision_surface(r));try{a=wt.allocate(e,i)}catch(c){console.error(c,e),a=wt.allocate({positionWASM:lb,indexWASM:cb,verticesPerFaceWASM:ub},i)}if(we.set_destination_refinement_level(a,0),s=wt.buildLevel(a,!0,u),e.subdivisions>0)try{we.set_destination_refinement_level(a,e.subdivisions),l=wt.buildLevel(a,!1,u)}catch{try{we.set_destination_refinement_level(a,e.subdivisions-1),l=wt.buildLevel(a,!1,u)}catch{l=null}}else l=null;return{subdivPointer:a,originalGeometry:s,subdividedGeometry:l}}static primitiveToQuads(e,r,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?r.geometry:Qo(e,o,!1),a;e.type==="TorusGeometry"&&e.arc===Math.PI*2?a=i.getClosedTorusIndicesForBooleanOrSubdiv():a=i.getIndex();let s,l,u,c;({positions:s,triIndices:c}=Df(i.getAttribute("position"),a));let d;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;d=[p,f]}return{indices:l,verticesPerFace:u}=Ef(s,c,i,d),{positions:s,indices:l,verticesPerFace:u}}static allocate(e,r){let o,i,a,s=[],l=[];e.positionWASM&&e.positionWASM.length>0?(o=e.positionWASM,i=e.indexWASM,a=e.verticesPerFaceWASM):(o=lb,i=cb,a=ub);let u=o.length,c=i.length,d=a.length,p=o.length+s.length+l.length,f=i.length+a.length,h=p*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,m=p*Float32Array.BYTES_PER_ELEMENT,y=f*Uint32Array.BYTES_PER_ELEMENT,g=we._malloc(h),b=new Float32Array(we.HEAPF32.buffer,g,p),w=new Uint32Array(we.HEAPU32.buffer,g+m,f);b.set(o,0),b.set(s,o.length),b.set(l,o.length+s.length),w.set(i,0),w.set(a,i.length);let _;e?.scaleBaked?.some(P=>P!==1)&&(_=new gI().makeScale(...e.scaleBaked)),r&&(_?_.premultiply(r):_=r);let S=_?we.alloc_subdivision_surface2(g,u,g+m,c,g+m+i.length*Uint32Array.BYTES_PER_ELEMENT,d,_.elements):we.alloc_subdivision_surface(g,u,g+m,c,g+m+i.length*Uint32Array.BYTES_PER_ELEMENT,d);return we._free(g),S}static buildLevel(e,r,o,i,a){let s=a?we.get_mesh_data2(e,r?we.Level.CONTROL:we.Level.REFINED,o,a.elements):we.get_mesh_data(e,r?we.Level.CONTROL:we.Level.REFINED,o),l=8,u=we.HEAPU32.subarray(s>>2,(s>>2)+l),c=u.subarray(4,4+4),d=0,p=we.HEAPU32[u[d]>>2],f=we.HEAPF32.subarray(p>>2,(p>>2)+c[d]);d++;let h=we.HEAPU32[u[d]>>2],m=we.HEAPF32.subarray(h>>2,(h>>2)+c[d]);d++;let y=we.HEAPU32[u[d]>>2],g=we.HEAPU32.subarray(y>>2,(y>>2)+c[d]);d++;let b=we.HEAPU32[u[d]>>2],w=we.HEAPU32.subarray(b>>2,(b>>2)+c[d]);if(d++,i===void 0){let _=new Of;if(_.setIndex(new Cf(w,1)),_.setAttribute("position",new Tf(f,3)),_.setAttribute("normal",new Tf(m,3)),r){_.setAttribute("faceMap",new Cf(g,1));let S=new Float32Array(m.length/3*4).fill(0);_.setAttribute("color",new sb(S,4))}return we.free_mesh_data(s),_.userData.type="SubdivGeometry",_}i.getAttribute("position").copyArray(f),i.getAttribute("normal").copyArray(m),i.attributes.position.needsUpdate=!0,i.attributes.normal.needsUpdate=!0,we.free_mesh_data(s)}static freeSubdivPointer(e){we.free_bvh(e),we.free_subdivision_surface(e)}static buildControlCageWireframe(e,r,o){let i=we.get_wireframe_data_for_base_level(e),a=4,s=we.HEAPU32.subarray(i>>2,(i>>2)+a),l=s.subarray(2,2+2),u=0,c=we.HEAPU32[s[u]>>2],d=we.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let p=we.HEAPU32[s[u]>>2],f=we.HEAPU32.subarray(p>>2,(p>>2)+l[u]);if(r===void 0){let h=new Of;h.setAttribute("position",new Tf(d,3));let m=new Float32Array(d.length);for(let y=0,g=d.length;y<g;)m[y++]=o.r,m[y++]=o.g,m[y++]=o.b;return h.setAttribute("color",new sb(m,3)),h.setIndex(new Cf(f,1)),we.free_wireframe_data_for_base_level(i),h}r.getAttribute("position").copyArray(d),r.attributes.position.needsUpdate=!0,we.free_wireframe_data_for_base_level(i)}static updateCollabMesh(e,r,o){let i=r===0;i||we.set_destination_refinement_level(e,r);let a=o?we.get_topological_data2(e,i?we.Level.CONTROL:we.Level.REFINED,o.elements):we.get_topological_data(e,i?we.Level.CONTROL:we.Level.REFINED),s=6,l=we.HEAPU32.subarray(a>>2,(a>>2)+s),u=l.subarray(3,3+3),c=0,d=we.HEAPU32[l[c]>>2],p=new Float32Array(we.HEAPF32.subarray(d>>2,(d>>2)+u[c]));c++;let f=we.HEAPU32[l[c]>>2],h=new Uint32Array(we.HEAPU32.subarray(f>>2,(f>>2)+u[c]));c++;let m=we.HEAPU32[l[c]>>2],y=new Uint8Array(we.HEAPU32.subarray(m>>2,(m>>2)+u[c]));return we.free_topological_data(a),{positions:p,indices:h,verticesPerFace:y}}};var db=["getX","getY","getZ"];function Df(n,t){let e={},r=t?t.count:n.count,o=0,i=[],a=[],s=1e4;for(let u=0;u<r;u++){let c=t?t.getX(u):u,d="";for(let p=0;p<3;p++)d+=`${~~(n[db[p]](c)*s)},`;if(d in e)i.push(e[d]);else{for(let p=0;p<3;p++)a.push(n[db[p]](c));e[d]=o,i.push(o),o++}}let l=[];for(let u=0;u<i.length;u+=3)i[u]===i[u+1]||i[u]===i[u+2]||i[u+1]===i[u+2]||l.push(i[u],i[u+1],i[u+2]);return{positions:a,triIndices:l}}var Ru=new hl,Mf=new hl,If=new hl,Nf=new hl;function Ef(n,t,e,r){let o=[],i=[];if(e.userData.shape!==void 0&&e.userData.parameters.depth===0&&e.userData.shape.shapeHoles.length===0){let l=e.userData.shape.extractShapePointsToFlatArray([]),u=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&u<=24&&u%4===0&&e.userData.parameters.angle>=360){let p=l.length/2/u;l=l.filter((f,h)=>Math.floor(h/2)%p===0)}let c=0;for(let p=0;p<l.length;p+=2)c+=(l[p]-l[(p===0?l.length:p)-2])*(l[p+1]+l[(p===0?l.length:p)-1]);n.length=0;let d=0;if(c<0)for(let p=0;p<l.length;p+=2)n.push(l[p],l[p+1],0),o.push(d++);else for(let p=l.length-2;p>=0;p-=2)n.push(l[p],l[p+1],0),o.push(d++);return i.push(d),{indices:o,verticesPerFace:i}}let a=new Float32Array([e.userData.parameters.depth])[0],s=0;for(;s<t.length;){if(e.useNgonForTopBottomFaceDuringBake){let l=0;if((n[t[s]*3+2]===a||n[t[s]*3+2]===0)&&l++,(n[t[s+1]*3+2]===a||n[t[s+1]*3+2]===0)&&l++,(n[t[s+2]*3+2]===a||n[t[s+2]*3+2]===0)&&l++,l===3)break}if(t[s+1]===t[s+3]&&t[s+2]===t[s+5]||t[s+0]===t[s+3]&&t[s+2]===t[s+4]){Ru.set(n[t[s]*3],n[t[s]*3+1],n[t[s]*3+2]),Mf.set(n[t[s+1]*3],n[t[s+1]*3+1],n[t[s+1]*3+2]),If.set(n[t[s+4]*3],n[t[s+4]*3+1],n[t[s+4]*3+2]),Nf.set(n[t[s+5]*3],n[t[s+5]*3+1],n[t[s+5]*3+2]),Mf.sub(Ru).normalize(),If.sub(Ru).normalize(),Nf.sub(Ru).normalize();let l=Mf.cross(If).dot(Nf);Math.abs(l)>.005||r&&r.some((u,c)=>c%2===1?!1:s>=r[c]&&s<r[c+1])?(o.push(t[s],t[s+1],t[s+2]),i.push(3),s+=3):(o.push(t[s],t[s+1],t[s+4],t[s+5]),i.push(4),s+=6)}else o.push(t[s],t[s+1],t[s+2]),i.push(3),s+=3}if(e.useNgonForTopBottomFaceDuringBake){let l=[],u=[],c=0;for(let d=0,p=0;d<n.length;d+=3,p++)n[d+2]===0&&(l.push(p),c++),n[d+2]===a&&u.push(p);if(e.userData.parameters.extrudeBevelSize===0){let d=u[0];u[0]=u[1],u[1]=d}l.reverse(),o.push(...l,...u),i.push(c,c)}return{indices:o,verticesPerFace:i}}var Dr={};X1(Dr,{calcBoolean:()=>PI,calcBooleanTopological:()=>_I,freeMeshSet:()=>MI,getMeshSet:()=>OI,hasOpenEdges:()=>CI,transformMeshSet:()=>TI});var SI,pb=new Promise(n=>{SI=n});import{Float32BufferAttribute as fb,Sphere as wI}from"three";var Ne,Ua;pb.then(n=>Ne=n);function AI(n,t,e){let r,o;n.userData.parameters.type==="TorusGeometry"&&n.userData.parameters.arc===Math.PI*2?o=n.getClosedTorusIndicesForBooleanOrSubdiv():o=n.getIndex();let{positions:i,triIndices:a}=Df(n.getAttribute("position"),o),s;if(t&&e){let{indices:l,verticesPerFace:u}=Ef(i,a,n);s=u.length,r=[];for(let c=0,d=0;c<s;c++){r.push(u[c]);for(let p=0;p<u[c];p++)r.push(l[d++])}}else{let l=a.length;r=Array(l+l/3),s=0;for(let u=0,c=0;c<r.length;)r[c++]=3,s++,r[c++]=a[u++],r[c++]=a[u++],r[c++]=a[u++]}return{positions:i,faceIndices:r,nFaces:s}}function hb(n){let t=n.length,e=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,o=Number.isInteger(n[0])?e:r,i=Ne._malloc(o);return(Number.isInteger(n[0])?new Uint32Array(Ne.HEAPU32.buffer,i,t):new Float32Array(Ne.HEAPF32.buffer,i,t)).set(n,0),i}function mb(n){switch(n){case 0:return Ne.OP.UNION;case 1:return Ne.OP.INTERSECTION;case 2:return Ne.OP.A_MINUS_B;case 3:return Ne.OP.B_MINUS_A;case 4:return Ne.OP.SYMMETRIC_DIFFERENCE;case 5:return Ne.OP.ALL;default:throw new Error("Unknown boolean operation "+n)}}function _I(n,t){Ua===void 0&&(Ua=Ne.init_csg());let e=hb(n),r=Ne.csg_calc_topological(Ua,e,n.length,mb(t));Ne._free(e);let o=6,i=Ne.HEAPU32.subarray(r>>2,(r>>2)+o),a=i.subarray(3,3+3),s=0,l=Ne.HEAPU32[i[s]>>2],u=new Float32Array(Ne.HEAPF32.subarray(l>>2,(l>>2)+a[s]));s++;let c=Ne.HEAPU32[i[s]>>2],d=new Uint32Array(Ne.HEAPU32.subarray(c>>2,(c>>2)+a[s]));s++;let p=Ne.HEAPU32[i[s]>>2],f=new Uint8Array(Ne.HEAPU32.subarray(p>>2,(p>>2)+a[s]));return Ne.free_mesh_data(r),{positions:u,indices:d,verticesPerFace:f}}function PI(n,t,e,r){Ua===void 0&&(Ua=Ne.init_csg());let o=hb(n),i=Ne.csg_calc(Ua,o,n.length,r,mb(t));Ne._free(o);let a=5,s=Ne.HEAPU32.subarray(i>>2,(i>>2)+a),l=s.subarray(2,2+3),u=0,c=Ne.HEAPU32[s[u]>>2],d=Ne.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let p=Ne.HEAPU32[s[u]>>2],f=Ne.HEAPF32.subarray(p>>2,(p>>2)+l[u]);u++;let h=l[u];e.setAttribute("position",new fb(d,3)),e.setAttribute("normal",new fb(f,3));let m=Ne.HEAPF32.subarray((i>>2)+5,(i>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new wI),e.boundingSphere.center.set(m[0],m[1],m[2]),e.boundingSphere.radius=(m[3]**2+m[4]**2+m[5]**2)**.5,e.userData.parameters={width:m[3]*2,height:m[4]*2,depth:m[5]*2},Ne.free_mesh_data(i),h}function OI(n,t,e){if(Ne===void 0)return-1;let r,o,i;if(t&&n.userData.positions!==void 0){let g=n.userData;i=g.verticesPerFace.length,r=g.positions,o=Array(g.verticesPerFace.reduce((b,w)=>b+w,0)+i);for(let b=0,w=0,_=0;b<g.verticesPerFace.length;b++){o[_++]=g.verticesPerFace[b];for(let S=0;S<g.verticesPerFace[b];S++)o[_++]=g.indices[w++]}}else({positions:r,faceIndices:o,nFaces:i}=AI(n,t,e));let a=r.length,s=o.length,l=r.length,u=o.length,c=l*Float32Array.BYTES_PER_ELEMENT+u*Uint32Array.BYTES_PER_ELEMENT,d=l*Float32Array.BYTES_PER_ELEMENT,p=u*Uint32Array.BYTES_PER_ELEMENT,f=Ne._malloc(c),h=new Float32Array(Ne.HEAPF32.buffer,f,l),m=new Uint32Array(Ne.HEAPU32.buffer,f+d,u);h.set(r,0),m.set(o,0);let y=Ne.get_csg_mesh(f,a,f+d,s,i);return Ne._free(f),y}function CI(n){return Ne.has_open_edges(n)}function TI(n,t){Ne.transform_csg_mesh(n,t.elements)}function MI(n){Ne.free_csg_mesh(n)}var II={ConeGeometry:Y0,CubeGeometry:X0,CylinderGeometry:$0,DodecahedronGeometry:Q0,EllipseGeometry:La,HelixGeometry:Ix,IcosahedronGeometry:Nx,LatheGeometry:Dx,NonParametricGeometry:jx,PolygonGeometry:Iu,PyramidGeometry:Ux,RectangleGeometry:Ga,SphereGeometry:qx,PlaneGeometry:Wx,BackdropGeometry:$x,StarGeometry:Nu,TextFrameGeometry:Yx,TorusGeometry:Xx,TorusKnotGeometry:Qx,TriangleGeometry:Kx,PathGeometry:tb,VectorGeometry:dr},Pf=n=>II[n.type].create(n);function Ha(n){return n!==null&&"booleanOp"in n}var qa=class extends Ca(DI){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new NI}updateVisible(e){super.updateVisible(e),this.visible=!Ha(this.parent)&&this.visible,Ha(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Dr.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),Ha(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof qa&&(e.freeBooleanPointer(),Ha(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,r){let o=super.updateTransformState(e,r);return o&&Ha(this.parent)&&this.invalidateDownstreamBooleanData(!0),o}onVariableUpdate(e=!1){super.onVariableUpdate(e),Ha(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var Vu=new EI;function ml(n,t=0,e=n.count,r,o){let i=1/0,a=1/0,s=1/0,l=-1/0,u=-1/0,c=-1/0;for(let d=t;d<e;d++){let p=n.getX(d),f=n.getY(d),h=n.getZ(d);p<i&&(i=p),f<a&&(a=f),h<s&&(s=h),p>l&&(l=p),f>u&&(u=f),h>c&&(c=h)}Vu.min.set(i,a,s),Vu.max.set(l,u,c),Vu.getCenter(r),Vu.getSize(o).multiplyScalar(.5)}var RI=new BI,VI=new LI,Dt=class extends qa{constructor(t,e){super(RI,VI),this.super_Entity(t,e)}updateState(t,e){this.updateState_Entity(t,e)}updateEntityBoxSize(t,e){let r=this.geometry.getAttribute("position");r!==void 0?ml(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};import{Box3 as Q3,Matrix4 as K3,Sphere as rv,Vector3 as Z3}from"three";import{BufferAttribute as $3,Float32BufferAttribute as tv,MathUtils as sh,Vector3 as lh}from"three";import{ShaderMaterial as D3}from"three";import{CubeReflectionMapping as XI,CubeRefractionMapping as QI,CubeUVReflectionMapping as KI,LinearEncoding as Pb,sRGBEncoding as ZI}from"three";var yl=class{constructor(t){t=t??{},this.name=t.name,this.type=t.type,this.node=t.node,this.size=t.size,this.needsUpdate=t.needsUpdate}get value(){return this.node.value}set value(t){this.node.value=t}};import{MathUtils as zI}from"three";var Ft=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=zI.generateUUID(),this.type=t,this.name=""}analyze(t,e){e=e??{},t.analyzing=!0,this.build(t.addFlow(e.slot,e.cache,e.context),"v4"),t.clearVertexNodeCode(),t.clearFragmentNodeCode(),t.removeFlow(),t.analyzing=!1}analyzeAndFlow(t,e,r){return r=r??{},this.analyze(t,r),this.flow(t,e,r)}flow(t,e,r){r=r??{},t.addFlow(r.slot,r.cache,r.context);let o={result:this.build(t,e),code:t.clearNodeCode(),extra:t.context.extra};return t.removeFlow(),o}build(t,e,r){e=e??this.getType(t,e);let o=t.getNodeData(r??this);return t.analyzing&&this.appendDepsNode(t,o,e),t.nodes.indexOf(this)===-1&&t.nodes.push(this),this.updateFrame!==void 0&&t.updaters.indexOf(this)===-1&&t.updaters.push(this),this.generate(t,e,r)}updateFrame(t){}generateReadonly(t,e,r,o,i,a){return""}generate(t,e,r,o,i){return""}parse(t,e,r,o){}appendDepsNode(t,e,r){e.deps=(e.deps||0)+1;let o=t.getTypeLength(r);(o>(e.outputMax||0)||this.getType(t,r))&&(e.outputMax=o,e.output=r)}setName(t){this.name=t}getName(){return this.name}getType(t,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}getHash(){let t="{",e,r;for(e in this)r=this[e],r instanceof Ft&&(t+='"'+e+'":'+r.getHash()+",");if(this.hashProperties)for(let o=0;o<this.hashProperties.length;o++)e=this.hashProperties[o],r=this[e],t+='"'+e+'":"'+String(r)+'",';return t+='"id":"'+this.uuid+'"}',t}};var Bf=class{constructor(){this.nodes={};this.keywords={}}add(t){this.nodes[t.name]=t}addKeyword(t,e,r){r=r!==void 0?r:!0,this.keywords[t]={callback:e,cache:r}}remove(t){delete this.nodes[t.name]}removeKeyword(t){delete this.keywords[t]}get(t){return this.nodes[t]}getKeyword(t,e){return this.keywords[t].callback(e)}getKeywordData(t){return this.keywords[t]}contains(t){return this.nodes[t]!==void 0}containsKeyword(t){return this.keywords[t]!==void 0}},Et=new Bf;import{Vector2 as yb}from"three";import{MathUtils as GI}from"three";var ye=class extends Ft{constructor(e,r){super(e);this.scope="";r=r??{},this.shared=r.shared!==void 0?r.shared:!0,this.unique=r.unique!==void 0?r.unique:!1}build(e,r,o,i){if(r=r??this.getType(e),this.getShared(e,r)){let a=this.getUnique(e,r);a&&this.uuid===void 0&&(this.uuid=GI.generateUUID()),o=e.getUUID(o??this.getUUID(),!a);let s=e.getNodeData(o),l=s.output||this.getType(e);if(e.analyzing)return(s.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,s,r),this.generate(e,r,o)):super.build(e,r,o);if(a)return s.name=s.name||super.build(e,r,o),s.name;if(!this.getLabel()&&(!this.getShared(e,l)||e.context.ignoreCache||s.deps===1))return super.build(e,r,o);o=this.getUUID(!1);let u=this.getTemp(e,o);if(u)return e.format(u,l,r);{u=super.generate(e,r,o,s.output,i);let c=this.generate(e,l,o);return e.addNodeCode(u+" = "+c+";"),e.format(u,l,r)}}return super.build(e,r,o)}getShared(e,r){return r!=="sampler2D"&&r!=="samplerCube"&&this.shared}getUnique(e,r){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let r=this.uuid;return typeof this.scope=="string"&&(r=this.scope+"-"+r),r}getTemp(e,r){r=r||this.uuid;let o=e.getVars()[r];return o?o.name:void 0}generate(e,r,o,i,a){return this.getShared(e,r)||console.error("TempNode is not shared"),o=o??this.uuid,e.getTempVar(o,i??this.getType(e),a,this.getLabel()).name}};var Xe=class extends ye{constructor(e,r){r=r??{},r.shared=r.shared!==void 0?r.shared:!1;super(e,r);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,r,o,i,a,s){o=e.getUUID(o??this.getUUID()),i=i??this.getType(e);let l=e.getNodeData(o);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,r,o,i,a,s):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(i,this,a,s,this.getLabel())),e.format(l.vertex.name,i,r)):(l.fragment||(l.fragment=e.createFragmentUniform(i,this,a,s,this.getLabel())),e.format(l.fragment.name,i,r))}};var pt=class extends Xe{constructor(e=0,r){super("v2");this.nodeType="Vector2";this.value=e instanceof yb?e:new yb(e,r)}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,r,o,i,a,s){return e.format("vec2("+this.value.x+", "+this.value.y+")",i,r)}};import{Vector3 as gb}from"three";var Yt=class extends Xe{constructor(e=0,r,o){super("v3");this.nodeType="Vector3";this.value=e instanceof gb?e:new gb(e,r,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,r,o,i,a,s){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",i,r)}};import{Color as FI}from"three";var Bt=class extends FI{constructor(e,r,o,i){super(e,r,o);this.isColorA=!0;this.a=i}setRGBA(e,r,o,i){super.setRGB(e,r,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)}equals(e){return super.equals(e)&&this.a===e.a}setStyle(e,r="srgb"){let o;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(o=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let i,a=o[1],s=o[2];switch(a){case"rgb":case"rgba":if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=a==="rgba"?parseFloat(i[4]):1,super.setStyle(e,r);break;case"hsl":case"hsla":if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=a==="hsla"?parseFloat(i[4]):1,super.setStyle(e,r);break}}return super.setStyle(e,r)}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 pr=class extends Xe{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof Bt?e:new Bt(e.r,e.g,e.b,e.a)}generateReadonly(e,r,o,i,a,s){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",i,r)}};var kI=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,xb=/[a-z_0-9]+/gi,re=class extends ye{constructor(e,r,o,i,a){super(a);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=a===void 0,this.isInterface=!1,this.parse(e,r,o,i)}getShared(e,r){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}}getIncludeByName(e){if(this.includes){let r=this.includes.length;for(;r--;)if(this.includes[r].name===e)return this.includes[r]}}generate(e,r,o,i,a){let s,l=0,u=this.src;if(this.includes)for(let d=0;d<this.includes.length;d++)e.include(this.includes[d],this);for(let d in this.extensions)e.extensions[d]=!0;let c=[];for(;s=xb.exec(this.src);)c.push(s);for(let d=0;d<c.length;d++){let p=c[d],f=p[0],h=this.isMethod?!this.getInputByName(f):!0,m=f;if(this.keywords[f]||this.useKeywords&&h&&Et.containsKeyword(f)){let y=this.keywords[f];if(!y){let g=Et.getKeywordData(f);g.cache&&(y=e.keywords[f]),y=y||Et.getKeyword(f,e),g.cache&&(e.keywords[f]=y)}m=y.build(e)}f!==m&&u[p.index+l-1]!=="."&&(u=u.substring(0,p.index+l)+m+u.substring(p.index+f.length+l),l+=m.length-f.length),this.getIncludeByName(m)===void 0&&Et.contains(m)&&e.include(Et.get(m))}return r==="source"?u:this.isMethod?(this.isInterface||e.include(this,void 0,u),this.name):e.format("( "+u+" )",this.getType(e),r)}parse(e,r,o,i){if(this.src=e||"",this.includes=r??[],this.extensions=o??{},this.keywords=i??{},this.isMethod){let a=kI.exec(this.src);if(this.inputs=[],a&&a.length==4){this.type=a[1],this.name=a[2];let s=a[3].match(xb);if(s){let l=0;for(;l<s.length;){let u=s[l++],c;u==="in"||u==="out"||u==="inout"?c=s[l++]:(c=u,u="");let d=s[l++];this.inputs.push({name:d,type:c,qualifier:u})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var jI=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,Lf=class extends ye{constructor(e="",r){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||Lf.PI,void 0,void 0,void 0,r)}getType(e){return e.getTypeByFormat(this.type)}parse(e,r,o,i,a){this.src=e||"";let s,l,u="",c=jI.exec(e);this.useDefine=a??this.src.charAt(0)==="#",c&&c.length>1?(l=c[1],s=c[2],u=c[3]):(s=this.src,l="f"),this.name=s,this.type=l,this.value=u}build(e,r){if(r==="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),r)}generate(e,r,o,i,a){return e.format(this.name,this.getType(e),r)}},Ue=Lf;Ue.PI="PI",Ue.PI2="PI2",Ue.RECIPROCAL_PI="RECIPROCAL_PI",Ue.RECIPROCAL_PI2="RECIPROCAL_PI2",Ue.LOG2="LOG2",Ue.EPSILON="EPSILON";var UI=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
19
- )*?)}`,"gim"),HI=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),Wa=class extends ye{constructor(e=""){super();this.inputs=[];this.src="";this.nodeType="Struct";this.parse(e)}getType(e){return e.getTypeByFormat(this.name)}getInputByName(e){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}generate(e,r,o,i,a){return r==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),r)}parse(e=""){this.src=e,this.inputs=[];let r=UI.exec(e);if(r){let o=r[2],i;for(;i=HI.exec(o);)this.inputs.push({type:i[1],name:i[2]});this.name=r[1]}else this.name="";this.type=this.name}};var $a=class extends ye{constructor(e){super("v2",{shared:!1});this.nodeType="UV";this.index=e??0}generate(e,r){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),r)}};Et.addKeyword("uv",function(){return new $a});Et.addKeyword("uv2",function(){return new $a(1)});import{LinearEncoding as qI,sRGBEncoding as WI}from"three";var ci=class extends ye{constructor(e,r){super("v4");this.nodeType="ColorSpace";this.input=e,this.method=r??ci.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case qI:return["Linear"];case WI:return["sRGB"];default:return[]}}generate(e,r){let o=this.input.build(e,"v4"),i=this.getType(e),a=ci.Nodes[this.method],s=e.include(a);if(s===ci.LINEAR_TO_LINEAR)return e.format(o,i,r);if(a.inputs?.length===2){let l=this.factor.build(e,"f");return e.format(s+"( "+o+", "+l+" )",i,r)}else return e.format(s+"( "+o+" )",i,r)}fromEncoding(e){let r=ci.getEncodingComponents(e);this.method="LinearTo"+r[0],this.factor=r[1]}fromDecoding(e){let r=ci.getEncodingComponents(e);this.method=r[0]+"ToLinear",this.factor=r[1]}},nr=ci;nr.Nodes={LinearToLinear:new re(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
18
+ `&&r.push("")):t.getTextWidth(r[r.length-1]+o,n)>n.width&&(r[r.length-1].length&&r.push(""),t.getTextWidth(r[r.length-1]+o,n)>n.width&&(o.length===1?(r[r.length-1]+=o,o=""):(r[r.length-1]+=o.slice(0,-1),o=o[o.length-1],r.push(""))));return r[r.length-1]+=o,r}import{BufferGeometry as Cf,BufferAttribute as lb,Uint32BufferAttribute as Tf,Float32BufferAttribute as Mf,Matrix4 as SI,Vector3 as hl,Sphere as wI,Box3 as AI,BoxGeometry as _I}from"three";var ab,Bu=new Promise(n=>{ab=n}),ib=!1;var Eu;function sb(){if(ib)return;if(Eu)return Eu;async function n(){let e=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@1.0.41/build",o=import("./process.js"),[i,a]=await Promise.all([o,fetch(`${e}/process.wasm`).then(u=>u.arrayBuffer())]),s=i.default,l=await s({wasmBinary:a});ab(l),ib=!0}return Eu=n(),Eu}import{BufferGeometryLoader as gI}from"three";var xI=["font"];function Qo(n,t,e,r){let o,i,a;n.type==="PathGeometry"?(i=JSON.parse(JSON.stringify(n)),a=[[],["extrusion"]]):(i={...n},a=[[]]);for(let u of a){let c=i;for(let d of u)c=c[d];for(o in c){let d=c[o];fp(d)&&!xI.includes(o)&&(c[o]=t.getVariable(d,[r.uuid,"geometry",...u,o]),fp(c[o])&&(c[o]=1))}}let s={parameters:i,type:i.type};if(i.type==="PathGeometry")s.path=i.path;else if(i.type==="VectorGeometry"){let u=He.createFromState(i.shape,i.width,i.height);s.shape=u}else if(i.type==="NonParametricGeometry")i.data.groups&&i.data.groups?.forEach(u=>u.materialIndex=Math.max(u.materialIndex??0,0)),s.geometry=new gI().parse(i);else if(i.type==="SubdivGeometry"){let u=new wt(i,e);return u.data=n,u}else{if(i.type==="TextGeometry")return new ja(i,t);if(i.type==="UIGeometry")return Fa.create({parameters:{width:i.width,height:i.height,cornerRadius:i.cornerRadius,cornerType:i.cornerType}})}let l;try{l=Of(s)}catch(u){console.error(u)}if(!l){let u=He.createFromState(fa.defaultData(),100,100);s.shape=u,l=Of(s)}return l}import{Matrix4 as bI}from"three";var vI=new bI;function fl(n,t,e,r){let o=n.position.array,i=n.normal.array,a=vI.makeScale(t,e,r).invert().elements,s,l,u;for(var c=0,d=o.length;c<d;c+=3)o[c]*=t,o[c+1]*=e,o[c+2]*=r,s=i[c],l=i[c+1],u=i[c+2],i[c]=a[0]*s+a[4]*l+a[8]*u,i[c+1]=a[1]*s+a[5]*l+a[9]*u,i[c+2]=a[2]*s+a[6]*l+a[10]*u;n.position.needsUpdate=!0,n.normal.needsUpdate=!0}var Lu=new AI,Ua=new hl,we;Bu.then(n=>{we=n});var cb=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),ub=new Uint32Array([0,1,2,3]),db=new Uint8Array([4]),wt=class extends Cf{constructor(e,r){super();this.data=e;this.flatShading=r;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,r){this.freeSubdivPointer();let o=this.data.scaleBaked,i=gn.div(r,o);this.subdividedGeometry&&fl(this.subdividedGeometry.attributes,...i),this.originalGeometry&&fl(this.originalGeometry.attributes,...i),this.data=e;let a=this.userData.parameters;this.userData.parameters={width:a.width*i[0],height:a.height*i[1],depth:a.depth*i[2]},this.originalGeometry.boundingSphere.center.multiply(Ua.fromArray(i));let s=Ua.set(a.width,a.height,a.depth).length();this.originalGeometry.boundingSphere.radius=s/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,r,o;try{({originalGeometry:e,subdividedGeometry:r,subdivPointer:o}=wt.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new _I(100,100,100),o=0}this.subdivPointer=o,this.originalGeometry=e,this.subdividedGeometry=r??void 0;let i=this.subdividedGeometry??this.originalGeometry;Object.assign(this,i),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(wt.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new wI,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,o=e.boundingSphere.center;Lu.setFromBufferAttribute(r),Lu.getCenter(o),e.boundingSphere.radius=o.distanceTo(Lu.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Lu.getSize(Ua);let i={width:Ua.x,height:Ua.y,depth:Ua.z};return this.userData.parameters=i,i}static build(e,r,o,i){let a,s,l,u=e?.phongAngle??35;o===!1&&(u=-1),r&&(we.free_bvh(r),we.free_subdivision_surface(r));try{a=wt.allocate(e,i)}catch(c){console.error(c,e),a=wt.allocate({positionWASM:cb,indexWASM:ub,verticesPerFaceWASM:db},i)}if(we.set_destination_refinement_level(a,0),s=wt.buildLevel(a,!0,u),e.subdivisions>0)try{we.set_destination_refinement_level(a,e.subdivisions),l=wt.buildLevel(a,!1,u)}catch{try{we.set_destination_refinement_level(a,e.subdivisions-1),l=wt.buildLevel(a,!1,u)}catch{l=null}}else l=null;return{subdivPointer:a,originalGeometry:s,subdividedGeometry:l}}static primitiveToQuads(e,r,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?r.geometry:Qo(e,o,!1),a;e.type==="TorusGeometry"&&e.arc===Math.PI*2?a=i.getClosedTorusIndicesForBooleanOrSubdiv():a=i.getIndex();let s,l,u,c;({positions:s,triIndices:c}=Ef(i.getAttribute("position"),a));let d;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;d=[p,f]}return{indices:l,verticesPerFace:u}=Bf(s,c,i,d),{positions:s,indices:l,verticesPerFace:u}}static allocate(e,r){let o,i,a,s=[],l=[];e.positionWASM&&e.positionWASM.length>0?(o=e.positionWASM,i=e.indexWASM,a=e.verticesPerFaceWASM):(o=cb,i=ub,a=db);let u=o.length,c=i.length,d=a.length,p=o.length+s.length+l.length,f=i.length+a.length,h=p*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,m=p*Float32Array.BYTES_PER_ELEMENT,y=f*Uint32Array.BYTES_PER_ELEMENT,g=we._malloc(h),b=new Float32Array(we.HEAPF32.buffer,g,p),w=new Uint32Array(we.HEAPU32.buffer,g+m,f);b.set(o,0),b.set(s,o.length),b.set(l,o.length+s.length),w.set(i,0),w.set(a,i.length);let A;e?.scaleBaked?.some(P=>P!==1)&&(A=new SI().makeScale(...e.scaleBaked)),r&&(A?A.premultiply(r):A=r);let S=A?we.alloc_subdivision_surface2(g,u,g+m,c,g+m+i.length*Uint32Array.BYTES_PER_ELEMENT,d,A.elements):we.alloc_subdivision_surface(g,u,g+m,c,g+m+i.length*Uint32Array.BYTES_PER_ELEMENT,d);return we._free(g),S}static buildLevel(e,r,o,i,a){let s=a?we.get_mesh_data2(e,r?we.Level.CONTROL:we.Level.REFINED,o,a.elements):we.get_mesh_data(e,r?we.Level.CONTROL:we.Level.REFINED,o),l=8,u=we.HEAPU32.subarray(s>>2,(s>>2)+l),c=u.subarray(4,4+4),d=0,p=we.HEAPU32[u[d]>>2],f=we.HEAPF32.subarray(p>>2,(p>>2)+c[d]);d++;let h=we.HEAPU32[u[d]>>2],m=we.HEAPF32.subarray(h>>2,(h>>2)+c[d]);d++;let y=we.HEAPU32[u[d]>>2],g=we.HEAPU32.subarray(y>>2,(y>>2)+c[d]);d++;let b=we.HEAPU32[u[d]>>2],w=we.HEAPU32.subarray(b>>2,(b>>2)+c[d]);if(d++,i===void 0){let A=new Cf;if(A.setIndex(new Tf(w,1)),A.setAttribute("position",new Mf(f,3)),A.setAttribute("normal",new Mf(m,3)),r){A.setAttribute("faceMap",new Tf(g,1));let S=new Float32Array(m.length/3*4).fill(0);A.setAttribute("color",new lb(S,4))}return we.free_mesh_data(s),A.userData.type="SubdivGeometry",A}i.getAttribute("position").copyArray(f),i.getAttribute("normal").copyArray(m),i.attributes.position.needsUpdate=!0,i.attributes.normal.needsUpdate=!0,we.free_mesh_data(s)}static freeSubdivPointer(e){we.free_bvh(e),we.free_subdivision_surface(e)}static buildControlCageWireframe(e,r,o){let i=we.get_wireframe_data_for_base_level(e),a=4,s=we.HEAPU32.subarray(i>>2,(i>>2)+a),l=s.subarray(2,2+2),u=0,c=we.HEAPU32[s[u]>>2],d=we.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let p=we.HEAPU32[s[u]>>2],f=we.HEAPU32.subarray(p>>2,(p>>2)+l[u]);if(r===void 0){let h=new Cf;h.setAttribute("position",new Mf(d,3));let m=new Float32Array(d.length);for(let y=0,g=d.length;y<g;)m[y++]=o.r,m[y++]=o.g,m[y++]=o.b;return h.setAttribute("color",new lb(m,3)),h.setIndex(new Tf(f,1)),we.free_wireframe_data_for_base_level(i),h}r.getAttribute("position").copyArray(d),r.attributes.position.needsUpdate=!0,we.free_wireframe_data_for_base_level(i)}static updateCollabMesh(e,r,o){let i=r===0;i||we.set_destination_refinement_level(e,r);let a=o?we.get_topological_data2(e,i?we.Level.CONTROL:we.Level.REFINED,o.elements):we.get_topological_data(e,i?we.Level.CONTROL:we.Level.REFINED),s=6,l=we.HEAPU32.subarray(a>>2,(a>>2)+s),u=l.subarray(3,3+3),c=0,d=we.HEAPU32[l[c]>>2],p=new Float32Array(we.HEAPF32.subarray(d>>2,(d>>2)+u[c]));c++;let f=we.HEAPU32[l[c]>>2],h=new Uint32Array(we.HEAPU32.subarray(f>>2,(f>>2)+u[c]));c++;let m=we.HEAPU32[l[c]>>2],y=new Uint8Array(we.HEAPU32.subarray(m>>2,(m>>2)+u[c]));return we.free_topological_data(a),{positions:p,indices:h,verticesPerFace:y}}};var pb=["getX","getY","getZ"];function Ef(n,t){let e={},r=t?t.count:n.count,o=0,i=[],a=[],s=1e4;for(let u=0;u<r;u++){let c=t?t.getX(u):u,d="";for(let p=0;p<3;p++)d+=`${~~(n[pb[p]](c)*s)},`;if(d in e)i.push(e[d]);else{for(let p=0;p<3;p++)a.push(n[pb[p]](c));e[d]=o,i.push(o),o++}}let l=[];for(let u=0;u<i.length;u+=3)i[u]===i[u+1]||i[u]===i[u+2]||i[u+1]===i[u+2]||l.push(i[u],i[u+1],i[u+2]);return{positions:a,triIndices:l}}var Ru=new hl,If=new hl,Nf=new hl,Df=new hl;function Bf(n,t,e,r){let o=[],i=[];if(e.userData.shape!==void 0&&e.userData.parameters.depth===0&&e.userData.shape.shapeHoles.length===0){let l=e.userData.shape.extractShapePointsToFlatArray([]),u=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&u<=24&&u%4===0&&e.userData.parameters.angle>=360){let p=l.length/2/u;l=l.filter((f,h)=>Math.floor(h/2)%p===0)}let c=0;for(let p=0;p<l.length;p+=2)c+=(l[p]-l[(p===0?l.length:p)-2])*(l[p+1]+l[(p===0?l.length:p)-1]);n.length=0;let d=0;if(c<0)for(let p=0;p<l.length;p+=2)n.push(l[p],l[p+1],0),o.push(d++);else for(let p=l.length-2;p>=0;p-=2)n.push(l[p],l[p+1],0),o.push(d++);return i.push(d),{indices:o,verticesPerFace:i}}let a=new Float32Array([e.userData.parameters.depth])[0],s=0;for(;s<t.length;){if(e.useNgonForTopBottomFaceDuringBake){let l=0;if((n[t[s]*3+2]===a||n[t[s]*3+2]===0)&&l++,(n[t[s+1]*3+2]===a||n[t[s+1]*3+2]===0)&&l++,(n[t[s+2]*3+2]===a||n[t[s+2]*3+2]===0)&&l++,l===3)break}if(t[s+1]===t[s+3]&&t[s+2]===t[s+5]||t[s+0]===t[s+3]&&t[s+2]===t[s+4]){Ru.set(n[t[s]*3],n[t[s]*3+1],n[t[s]*3+2]),If.set(n[t[s+1]*3],n[t[s+1]*3+1],n[t[s+1]*3+2]),Nf.set(n[t[s+4]*3],n[t[s+4]*3+1],n[t[s+4]*3+2]),Df.set(n[t[s+5]*3],n[t[s+5]*3+1],n[t[s+5]*3+2]),If.sub(Ru).normalize(),Nf.sub(Ru).normalize(),Df.sub(Ru).normalize();let l=If.cross(Nf).dot(Df);Math.abs(l)>.005||r&&r.some((u,c)=>c%2===1?!1:s>=r[c]&&s<r[c+1])?(o.push(t[s],t[s+1],t[s+2]),i.push(3),s+=3):(o.push(t[s],t[s+1],t[s+4],t[s+5]),i.push(4),s+=6)}else o.push(t[s],t[s+1],t[s+2]),i.push(3),s+=3}if(e.useNgonForTopBottomFaceDuringBake){let l=[],u=[],c=0;for(let d=0,p=0;d<n.length;d+=3,p++)n[d+2]===0&&(l.push(p),c++),n[d+2]===a&&u.push(p);if(e.userData.parameters.extrudeBevelSize===0){let d=u[0];u[0]=u[1],u[1]=d}l.reverse(),o.push(...l,...u),i.push(c,c)}return{indices:o,verticesPerFace:i}}var Dr={};J1(Dr,{calcBoolean:()=>MI,calcBooleanTopological:()=>TI,freeMeshSet:()=>EI,getMeshSet:()=>II,hasOpenEdges:()=>NI,transformMeshSet:()=>DI});var PI,fb=new Promise(n=>{PI=n});import{Float32BufferAttribute as hb,Sphere as OI}from"three";var Ne,Ha;fb.then(n=>Ne=n);function CI(n,t,e){let r,o;n.userData.parameters.type==="TorusGeometry"&&n.userData.parameters.arc===Math.PI*2?o=n.getClosedTorusIndicesForBooleanOrSubdiv():o=n.getIndex();let{positions:i,triIndices:a}=Ef(n.getAttribute("position"),o),s;if(t&&e){let{indices:l,verticesPerFace:u}=Bf(i,a,n);s=u.length,r=[];for(let c=0,d=0;c<s;c++){r.push(u[c]);for(let p=0;p<u[c];p++)r.push(l[d++])}}else{let l=a.length;r=Array(l+l/3),s=0;for(let u=0,c=0;c<r.length;)r[c++]=3,s++,r[c++]=a[u++],r[c++]=a[u++],r[c++]=a[u++]}return{positions:i,faceIndices:r,nFaces:s}}function mb(n){let t=n.length,e=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,o=Number.isInteger(n[0])?e:r,i=Ne._malloc(o);return(Number.isInteger(n[0])?new Uint32Array(Ne.HEAPU32.buffer,i,t):new Float32Array(Ne.HEAPF32.buffer,i,t)).set(n,0),i}function yb(n){switch(n){case 0:return Ne.OP.UNION;case 1:return Ne.OP.INTERSECTION;case 2:return Ne.OP.A_MINUS_B;case 3:return Ne.OP.B_MINUS_A;case 4:return Ne.OP.SYMMETRIC_DIFFERENCE;case 5:return Ne.OP.ALL;default:throw new Error("Unknown boolean operation "+n)}}function TI(n,t){Ha===void 0&&(Ha=Ne.init_csg());let e=mb(n),r=Ne.csg_calc_topological(Ha,e,n.length,yb(t));Ne._free(e);let o=6,i=Ne.HEAPU32.subarray(r>>2,(r>>2)+o),a=i.subarray(3,3+3),s=0,l=Ne.HEAPU32[i[s]>>2],u=new Float32Array(Ne.HEAPF32.subarray(l>>2,(l>>2)+a[s]));s++;let c=Ne.HEAPU32[i[s]>>2],d=new Uint32Array(Ne.HEAPU32.subarray(c>>2,(c>>2)+a[s]));s++;let p=Ne.HEAPU32[i[s]>>2],f=new Uint8Array(Ne.HEAPU32.subarray(p>>2,(p>>2)+a[s]));return Ne.free_mesh_data(r),{positions:u,indices:d,verticesPerFace:f}}function MI(n,t,e,r){Ha===void 0&&(Ha=Ne.init_csg());let o=mb(n),i=Ne.csg_calc(Ha,o,n.length,r,yb(t));Ne._free(o);let a=5,s=Ne.HEAPU32.subarray(i>>2,(i>>2)+a),l=s.subarray(2,2+3),u=0,c=Ne.HEAPU32[s[u]>>2],d=Ne.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let p=Ne.HEAPU32[s[u]>>2],f=Ne.HEAPF32.subarray(p>>2,(p>>2)+l[u]);u++;let h=l[u];e.setAttribute("position",new hb(d,3)),e.setAttribute("normal",new hb(f,3));let m=Ne.HEAPF32.subarray((i>>2)+5,(i>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new OI),e.boundingSphere.center.set(m[0],m[1],m[2]),e.boundingSphere.radius=(m[3]**2+m[4]**2+m[5]**2)**.5,e.userData.parameters={width:m[3]*2,height:m[4]*2,depth:m[5]*2},Ne.free_mesh_data(i),h}function II(n,t,e){if(Ne===void 0)return-1;let r,o,i;if(t&&n.userData.positions!==void 0){let g=n.userData;i=g.verticesPerFace.length,r=g.positions,o=Array(g.verticesPerFace.reduce((b,w)=>b+w,0)+i);for(let b=0,w=0,A=0;b<g.verticesPerFace.length;b++){o[A++]=g.verticesPerFace[b];for(let S=0;S<g.verticesPerFace[b];S++)o[A++]=g.indices[w++]}}else({positions:r,faceIndices:o,nFaces:i}=CI(n,t,e));let a=r.length,s=o.length,l=r.length,u=o.length,c=l*Float32Array.BYTES_PER_ELEMENT+u*Uint32Array.BYTES_PER_ELEMENT,d=l*Float32Array.BYTES_PER_ELEMENT,p=u*Uint32Array.BYTES_PER_ELEMENT,f=Ne._malloc(c),h=new Float32Array(Ne.HEAPF32.buffer,f,l),m=new Uint32Array(Ne.HEAPU32.buffer,f+d,u);h.set(r,0),m.set(o,0);let y=Ne.get_csg_mesh(f,a,f+d,s,i);return Ne._free(f),y}function NI(n){return Ne.has_open_edges(n)}function DI(n,t){Ne.transform_csg_mesh(n,t.elements)}function EI(n){Ne.free_csg_mesh(n)}var BI={ConeGeometry:X0,CubeGeometry:Q0,CylinderGeometry:Y0,DodecahedronGeometry:K0,EllipseGeometry:Ra,HelixGeometry:Nx,IcosahedronGeometry:Dx,LatheGeometry:Ex,NonParametricGeometry:Ux,PolygonGeometry:Iu,PyramidGeometry:Hx,RectangleGeometry:Fa,SphereGeometry:Wx,PlaneGeometry:$x,BackdropGeometry:Yx,StarGeometry:Nu,TextFrameGeometry:Xx,TorusGeometry:Qx,TorusKnotGeometry:Kx,TriangleGeometry:Zx,PathGeometry:rb,VectorGeometry:dr},Of=n=>BI[n.type].create(n);function qa(n){return n!==null&&"booleanOp"in n}var Wa=class extends Ta(RI){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new LI}updateVisible(e){super.updateVisible(e),this.visible=!qa(this.parent)&&this.visible,qa(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Dr.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),qa(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof Wa&&(e.freeBooleanPointer(),qa(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,r){let o=super.updateTransformState(e,r);return o&&qa(this.parent)&&this.invalidateDownstreamBooleanData(!0),o}onVariableUpdate(e=!1){super.onVariableUpdate(e),qa(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var Vu=new VI;function ml(n,t=0,e=n.count,r,o){let i=1/0,a=1/0,s=1/0,l=-1/0,u=-1/0,c=-1/0;for(let d=t;d<e;d++){let p=n.getX(d),f=n.getY(d),h=n.getZ(d);p<i&&(i=p),f<a&&(a=f),h<s&&(s=h),p>l&&(l=p),f>u&&(u=f),h>c&&(c=h)}Vu.min.set(i,a,s),Vu.max.set(l,u,c),Vu.getCenter(r),Vu.getSize(o).multiplyScalar(.5)}var FI=new zI,kI=new GI,Dt=class extends Wa{constructor(t,e){super(FI,kI),this.super_Entity(t,e)}updateState(t,e){this.updateState_Entity(t,e)}updateEntityBoxSize(t,e){let r=this.geometry.getAttribute("position");r!==void 0?ml(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};import{Box3 as eN,Matrix4 as tN,Sphere as ov,Vector3 as rN}from"three";import{BufferAttribute as K3,Float32BufferAttribute as rv,MathUtils as lh,Vector3 as ch}from"three";import{ShaderMaterial as R3}from"three";import{CubeReflectionMapping as JI,CubeRefractionMapping as e3,CubeUVReflectionMapping as t3,LinearEncoding as Ob,sRGBEncoding as r3}from"three";var yl=class{constructor(t){t=t??{},this.name=t.name,this.type=t.type,this.node=t.node,this.size=t.size,this.needsUpdate=t.needsUpdate}get value(){return this.node.value}set value(t){this.node.value=t}};import{MathUtils as jI}from"three";var Ft=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=jI.generateUUID(),this.type=t,this.name=""}analyze(t,e){e=e??{},t.analyzing=!0,this.build(t.addFlow(e.slot,e.cache,e.context),"v4"),t.clearVertexNodeCode(),t.clearFragmentNodeCode(),t.removeFlow(),t.analyzing=!1}analyzeAndFlow(t,e,r){return r=r??{},this.analyze(t,r),this.flow(t,e,r)}flow(t,e,r){r=r??{},t.addFlow(r.slot,r.cache,r.context);let o={result:this.build(t,e),code:t.clearNodeCode(),extra:t.context.extra};return t.removeFlow(),o}build(t,e,r){e=e??this.getType(t,e);let o=t.getNodeData(r??this);return t.analyzing&&this.appendDepsNode(t,o,e),t.nodes.indexOf(this)===-1&&t.nodes.push(this),this.updateFrame!==void 0&&t.updaters.indexOf(this)===-1&&t.updaters.push(this),this.generate(t,e,r)}updateFrame(t){}generateReadonly(t,e,r,o,i,a){return""}generate(t,e,r,o,i){return""}parse(t,e,r,o){}appendDepsNode(t,e,r){e.deps=(e.deps||0)+1;let o=t.getTypeLength(r);(o>(e.outputMax||0)||this.getType(t,r))&&(e.outputMax=o,e.output=r)}setName(t){this.name=t}getName(){return this.name}getType(t,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}getHash(){let t="{",e,r;for(e in this)r=this[e],r instanceof Ft&&(t+='"'+e+'":'+r.getHash()+",");if(this.hashProperties)for(let o=0;o<this.hashProperties.length;o++)e=this.hashProperties[o],r=this[e],t+='"'+e+'":"'+String(r)+'",';return t+='"id":"'+this.uuid+'"}',t}};var Lf=class{constructor(){this.nodes={};this.keywords={}}add(t){this.nodes[t.name]=t}addKeyword(t,e,r){r=r!==void 0?r:!0,this.keywords[t]={callback:e,cache:r}}remove(t){delete this.nodes[t.name]}removeKeyword(t){delete this.keywords[t]}get(t){return this.nodes[t]}getKeyword(t,e){return this.keywords[t].callback(e)}getKeywordData(t){return this.keywords[t]}contains(t){return this.nodes[t]!==void 0}containsKeyword(t){return this.keywords[t]!==void 0}},Et=new Lf;import{Vector2 as gb}from"three";import{MathUtils as UI}from"three";var ye=class extends Ft{constructor(e,r){super(e);this.scope="";r=r??{},this.shared=r.shared!==void 0?r.shared:!0,this.unique=r.unique!==void 0?r.unique:!1}build(e,r,o,i){if(r=r??this.getType(e),this.getShared(e,r)){let a=this.getUnique(e,r);a&&this.uuid===void 0&&(this.uuid=UI.generateUUID()),o=e.getUUID(o??this.getUUID(),!a);let s=e.getNodeData(o),l=s.output||this.getType(e);if(e.analyzing)return(s.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,s,r),this.generate(e,r,o)):super.build(e,r,o);if(a)return s.name=s.name||super.build(e,r,o),s.name;if(!this.getLabel()&&(!this.getShared(e,l)||e.context.ignoreCache||s.deps===1))return super.build(e,r,o);o=this.getUUID(!1);let u=this.getTemp(e,o);if(u)return e.format(u,l,r);{u=super.generate(e,r,o,s.output,i);let c=this.generate(e,l,o);return e.addNodeCode(u+" = "+c+";"),e.format(u,l,r)}}return super.build(e,r,o)}getShared(e,r){return r!=="sampler2D"&&r!=="samplerCube"&&this.shared}getUnique(e,r){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let r=this.uuid;return typeof this.scope=="string"&&(r=this.scope+"-"+r),r}getTemp(e,r){r=r||this.uuid;let o=e.getVars()[r];return o?o.name:void 0}generate(e,r,o,i,a){return this.getShared(e,r)||console.error("TempNode is not shared"),o=o??this.uuid,e.getTempVar(o,i??this.getType(e),a,this.getLabel()).name}};var Xe=class extends ye{constructor(e,r){r=r??{},r.shared=r.shared!==void 0?r.shared:!1;super(e,r);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,r,o,i,a,s){o=e.getUUID(o??this.getUUID()),i=i??this.getType(e);let l=e.getNodeData(o);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,r,o,i,a,s):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(i,this,a,s,this.getLabel())),e.format(l.vertex.name,i,r)):(l.fragment||(l.fragment=e.createFragmentUniform(i,this,a,s,this.getLabel())),e.format(l.fragment.name,i,r))}};var pt=class extends Xe{constructor(e=0,r){super("v2");this.nodeType="Vector2";this.value=e instanceof gb?e:new gb(e,r)}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,r,o,i,a,s){return e.format("vec2("+this.value.x+", "+this.value.y+")",i,r)}};import{Vector3 as xb}from"three";var Yt=class extends Xe{constructor(e=0,r,o){super("v3");this.nodeType="Vector3";this.value=e instanceof xb?e:new xb(e,r,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,r,o,i,a,s){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",i,r)}};import{Color as HI}from"three";var Bt=class extends HI{constructor(e,r,o,i){super(e,r,o);this.isColorA=!0;this.a=i}setRGBA(e,r,o,i){super.setRGB(e,r,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)}equals(e){return super.equals(e)&&this.a===e.a}setStyle(e,r="srgb"){let o;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(o=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let i,a=o[1],s=o[2];switch(a){case"rgb":case"rgba":if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=a==="rgba"?parseFloat(i[4]):1,super.setStyle(e,r);break;case"hsl":case"hsla":if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=a==="hsla"?parseFloat(i[4]):1,super.setStyle(e,r);break}}return super.setStyle(e,r)}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 pr=class extends Xe{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof Bt?e:new Bt(e.r,e.g,e.b,e.a)}generateReadonly(e,r,o,i,a,s){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",i,r)}};var qI=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,bb=/[a-z_0-9]+/gi,re=class extends ye{constructor(e,r,o,i,a){super(a);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=a===void 0,this.isInterface=!1,this.parse(e,r,o,i)}getShared(e,r){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}}getIncludeByName(e){if(this.includes){let r=this.includes.length;for(;r--;)if(this.includes[r].name===e)return this.includes[r]}}generate(e,r,o,i,a){let s,l=0,u=this.src;if(this.includes)for(let d=0;d<this.includes.length;d++)e.include(this.includes[d],this);for(let d in this.extensions)e.extensions[d]=!0;let c=[];for(;s=bb.exec(this.src);)c.push(s);for(let d=0;d<c.length;d++){let p=c[d],f=p[0],h=this.isMethod?!this.getInputByName(f):!0,m=f;if(this.keywords[f]||this.useKeywords&&h&&Et.containsKeyword(f)){let y=this.keywords[f];if(!y){let g=Et.getKeywordData(f);g.cache&&(y=e.keywords[f]),y=y||Et.getKeyword(f,e),g.cache&&(e.keywords[f]=y)}m=y.build(e)}f!==m&&u[p.index+l-1]!=="."&&(u=u.substring(0,p.index+l)+m+u.substring(p.index+f.length+l),l+=m.length-f.length),this.getIncludeByName(m)===void 0&&Et.contains(m)&&e.include(Et.get(m))}return r==="source"?u:this.isMethod?(this.isInterface||e.include(this,void 0,u),this.name):e.format("( "+u+" )",this.getType(e),r)}parse(e,r,o,i){if(this.src=e||"",this.includes=r??[],this.extensions=o??{},this.keywords=i??{},this.isMethod){let a=qI.exec(this.src);if(this.inputs=[],a&&a.length==4){this.type=a[1],this.name=a[2];let s=a[3].match(bb);if(s){let l=0;for(;l<s.length;){let u=s[l++],c;u==="in"||u==="out"||u==="inout"?c=s[l++]:(c=u,u="");let d=s[l++];this.inputs.push({name:d,type:c,qualifier:u})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var WI=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,Rf=class extends ye{constructor(e="",r){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||Rf.PI,void 0,void 0,void 0,r)}getType(e){return e.getTypeByFormat(this.type)}parse(e,r,o,i,a){this.src=e||"";let s,l,u="",c=WI.exec(e);this.useDefine=a??this.src.charAt(0)==="#",c&&c.length>1?(l=c[1],s=c[2],u=c[3]):(s=this.src,l="f"),this.name=s,this.type=l,this.value=u}build(e,r){if(r==="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),r)}generate(e,r,o,i,a){return e.format(this.name,this.getType(e),r)}},Ue=Rf;Ue.PI="PI",Ue.PI2="PI2",Ue.RECIPROCAL_PI="RECIPROCAL_PI",Ue.RECIPROCAL_PI2="RECIPROCAL_PI2",Ue.LOG2="LOG2",Ue.EPSILON="EPSILON";var $I=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
19
+ )*?)}`,"gim"),YI=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),$a=class extends ye{constructor(e=""){super();this.inputs=[];this.src="";this.nodeType="Struct";this.parse(e)}getType(e){return e.getTypeByFormat(this.name)}getInputByName(e){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}generate(e,r,o,i,a){return r==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),r)}parse(e=""){this.src=e,this.inputs=[];let r=$I.exec(e);if(r){let o=r[2],i;for(;i=YI.exec(o);)this.inputs.push({type:i[1],name:i[2]});this.name=r[1]}else this.name="";this.type=this.name}};var Ya=class extends ye{constructor(e){super("v2",{shared:!1});this.nodeType="UV";this.index=e??0}generate(e,r){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),r)}};Et.addKeyword("uv",function(){return new Ya});Et.addKeyword("uv2",function(){return new Ya(1)});import{LinearEncoding as XI,sRGBEncoding as QI}from"three";var ci=class extends ye{constructor(e,r){super("v4");this.nodeType="ColorSpace";this.input=e,this.method=r??ci.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case XI:return["Linear"];case QI:return["sRGB"];default:return[]}}generate(e,r){let o=this.input.build(e,"v4"),i=this.getType(e),a=ci.Nodes[this.method],s=e.include(a);if(s===ci.LINEAR_TO_LINEAR)return e.format(o,i,r);if(a.inputs?.length===2){let l=this.factor.build(e,"f");return e.format(s+"( "+o+", "+l+" )",i,r)}else return e.format(s+"( "+o+" )",i,r)}fromEncoding(e){let r=ci.getEncodingComponents(e);this.method="LinearTo"+r[0],this.factor=r[1]}fromDecoding(e){let r=ci.getEncodingComponents(e);this.method=r[0]+"ToLinear",this.factor=r[1]}},nr=ci;nr.Nodes={LinearToLinear:new re(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
20
20
  `)),sRGBToLinear:new re(["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(`
21
21
  `)),LinearTosRGB:new re(["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(`
22
- `))},nr.LINEAR_TO_LINEAR="LinearToLinear",nr.SRGB_TO_LINEAR="sRGBToLinear",nr.LINEAR_TO_SRGB="LinearTosRGB";var qe=class extends re{constructor(e="",r,o,i,a){super(e,a,i,o,r);this.nodeType="Expression"}};import{Texture as $I}from"three";var ir=class extends Xe{constructor(e=new $I,r,o,i){super("v4",{shared:!0});this.nodeType="Texture";this.value=e,this.uv=r??new $a,this.bias=o,this.project=i!==void 0?i:!1}getTexture(e,r){return super.generate(e,r,this.value.uuid,"t")}generate(e,r){if(r==="sampler2D")return this.getTexture(e,r);let o=this.getTexture(e,r),i=this.uv.build(e,this.project?"v4":"v2"),a=this.bias?this.bias.build(e,"f"):void 0;a===void 0&&e.context.bias&&(a=e.context.bias.setTexture(this).build(e,"f"));let s,l;this.project?s="texture2DProj":s=a?"tex2DBias":"tex2D",a?l=s+"( "+o+", "+i+", "+a+" )":l=s+"( "+o+", "+i+" )";let u={include:e.isShader("vertex"),ignoreCache:!0},c=this.getType(e);return e.addContext(u),this.colorSpace=this.colorSpace??new nr(new qe("",c)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(l),l=this.colorSpace.build(e,c),e.removeContext(),e.format(l,c,r)}};var se=class extends Xe{constructor(e){super("f");this.nodeType="Float";this.value=e??0}generateReadonly(e,r,o,i,a,s){return e.format(this.value+(this.value%1?"":".0"),i,r)}};var gl=class extends ye{constructor(e,r){super();this.inputs=[];this.nodeType="FunctionCall";this.value=e,this.inputs=r??[]}getFunction(){return this.value}getType(e){return this.value.getType(e)}generate(e,r,o,i,a){i=this.getType(e);let s=this.value,l=s.build(e,r)+"( ",u=[];if(s.inputs){for(let c=0;c<s.inputs.length;c++){let d=s.inputs[c],p=this.inputs[c]||this.inputs[d.name];u.push(p.build(e,e.getTypeByFormat(d.type)))}l+=u.join(", ")+" )"}return e.format(l,i,r)}};var Rf=class extends ye{constructor(e,r,o=Rf.ADD){super();this.nodeType="Operator";this.type=e.type,this.a=e,this.b=r,this.op=o}getType(e){let r=this.a.getType(e),o=this.b.getType(e);return e.isTypeMatrix(r)?"v4":e.getTypeLength(o)>e.getTypeLength(r)?o:r}generate(e,r){let o=this.getType(e);this.type=o;let i=this.a.build(e,o),a=this.b.build(e,o);return e.format("( "+i+" "+this.op+" "+a+" )",o,r)}},kt=Rf;kt.ADD="+",kt.SUB="-",kt.MUL="*",kt.DIV="/";var Qe=class extends ye{constructor(e,r=Qe.ABS,o,i){super();this.nodeType="Math";this.a=e,typeof r!="string"?this.b=r:i=r,typeof o!="string"?this.c=o:i=o,this.method=i,this.hashProperties=["method"]}getNumInputs(e){switch(this.method){case Qe.MIX:case Qe.CLAMP:case Qe.REFRACT:case Qe.SMOOTHSTEP:case Qe.FACEFORWARD:return 3;case Qe.MIN:case Qe.MAX:case Qe.MOD:case Qe.STEP:case Qe.REFLECT:case Qe.DISTANCE:case Qe.DOT:case Qe.CROSS:case Qe.POW:return 2;default:return 1}}getInputType(e){let r=e.getTypeLength(this.a.getType(e)),o=this.b?e.getTypeLength(this.b.getType(e)):0,i=this.c?e.getTypeLength(this.c.getType(e)):0;return r>o&&r>i?this.a.getType(e):o>i?this.b.getType(e):this.c.getType(e)}getType(e){switch(this.method){case Qe.LENGTH:case Qe.DISTANCE:case Qe.DOT:return"f";case Qe.CROSS:return"v3"}return this.getInputType(e)}generate(e,r){let o,i,a,s=this.a?e.getTypeLength(this.a.getType(e)):0,l=this.b?e.getTypeLength(this.b.getType(e)):0,u=this.c?e.getTypeLength(this.c.getType(e)):0,c=this.getInputType(e),d=this.getType(e);switch(this.type=d,this.method){case Qe.NEGATE:return e.format("( -"+this.a.build(e,c)+" )",c,r);case Qe.INVERT:return e.format("( 1.0 - "+this.a.build(e,c)+" )",c,r);case Qe.CROSS:o=this.a.build(e,"v3"),i=this.b.build(e,"v3");break;case Qe.STEP:o=this.a.build(e,s===1?"f":c),i=this.b.build(e,c);break;case Qe.MIN:case Qe.MAX:case Qe.MOD:o=this.a.build(e,c),i=this.b.build(e,l===1?"f":c);break;case Qe.REFRACT:o=this.a.build(e,c),i=this.b.build(e,c),a=this.c.build(e,"f");break;case Qe.MIX:o=this.a.build(e,c),i=this.b.build(e,c),a=this.c.build(e,u===1?"f":c);break;default:o=this.a.build(e,c),this.b&&(i=this.b.build(e,c)),this.c&&(a=this.c.build(e,c));break}let p=[];p.push(o),i&&p.push(i),a&&p.push(a);let f=this.getNumInputs(e);if(p.length!==f)throw Error(`Arguments not match used in "${this.method}". Require ${f}, currently ${p.length}.`);return e.format(this.method+"( "+p.join(", ")+" )",d,r)}},Pe=Qe;Pe.RAD="radians",Pe.DEG="degrees",Pe.EXP="exp",Pe.EXP2="exp2",Pe.LOG="log",Pe.LOG2="log2",Pe.SQRT="sqrt",Pe.INV_SQRT="inversesqrt",Pe.FLOOR="floor",Pe.CEIL="ceil",Pe.NORMALIZE="normalize",Pe.FRACT="fract",Pe.SATURATE="saturate",Pe.SIN="sin",Pe.COS="cos",Pe.TAN="tan",Pe.ASIN="asin",Pe.ACOS="acos",Pe.ARCTAN="atan",Pe.ABS="abs",Pe.SIGN="sign",Pe.LENGTH="length",Pe.NEGATE="negate",Pe.INVERT="invert",Pe.MIN="min",Pe.MAX="max",Pe.MOD="mod",Pe.STEP="step",Pe.REFLECT="reflect",Pe.DISTANCE="distance",Pe.DOT="dot",Pe.CROSS="cross",Pe.POW="pow",Pe.MIX="mix",Pe.CLAMP="clamp",Pe.REFRACT="refract",Pe.SMOOTHSTEP="smoothstep",Pe.FACEFORWARD="faceforward";var Ya=class extends ye{constructor(e,r,o){super("v4");this.nodeType="TextureCubeUV";this.value=e,this.uv=r,this.bias=o}bilinearCubeUV(e,r,o,i){let a=new gl(Ya.Nodes.bilinearCubeUV,[r,o,i]);this.colorSpaceTL=this.colorSpaceTL??new nr(new qe("","v4")),this.colorSpaceTL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTL.input.parse(a.build(e)+".tl"),this.colorSpaceTR=this.colorSpaceTR??new nr(new qe("","v4")),this.colorSpaceTR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTR.input.parse(a.build(e)+".tr"),this.colorSpaceBL=this.colorSpaceBL??new nr(new qe("","v4")),this.colorSpaceBL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBL.input.parse(a.build(e)+".bl"),this.colorSpaceBR=this.colorSpaceBR??new nr(new qe("","v4")),this.colorSpaceBR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBR.input.parse(a.build(e)+".br");let s={include:e.isShader("vertex"),ignoreCache:!0};e.addContext(s),this.colorSpaceTLExp=new qe(this.colorSpaceTL.build(e,"v4"),"v4"),this.colorSpaceTRExp=new qe(this.colorSpaceTR.build(e,"v4"),"v4"),this.colorSpaceBLExp=new qe(this.colorSpaceBL.build(e,"v4"),"v4"),this.colorSpaceBRExp=new qe(this.colorSpaceBR.build(e,"v4"),"v4"),e.removeContext();let l=new qe("mix( mix( cubeUV_TL, cubeUV_TR, cubeUV.f.x ), mix( cubeUV_BL, cubeUV_BR, cubeUV.f.x ), cubeUV.f.y )","v4");return l.keywords.cubeUV_TL=this.colorSpaceTLExp,l.keywords.cubeUV_TR=this.colorSpaceTRExp,l.keywords.cubeUV_BL=this.colorSpaceBLExp,l.keywords.cubeUV_BR=this.colorSpaceBRExp,l.keywords.cubeUV=a,l}generate(e,r){if(e.isShader("fragment")){let o=this.uv,i=this.bias||e.context.roughness,a=new gl(Ya.Nodes.roughnessToMip,[i]),s=new Pe(a,Ya.Nodes.m0,Ya.Nodes.cubeUV_maxMipLevel,Pe.CLAMP),l=new Pe(s,Pe.FLOOR),u=new Pe(s,Pe.FRACT),c=this.bilinearCubeUV(e,this.value,o,l),d=this.bilinearCubeUV(e,this.value,o,new kt(l,new se(1).setReadonly(!0),kt.ADD)),p=new Pe(c,d,u,Pe.MIX);return e.format(p.build(e),"v4",r)}else return console.warn("TextureCubeUVNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),r)}},Xa=Ya;Xa.Nodes=function(){let e=new Wa(`struct TextureCubeUVData {
22
+ `))},nr.LINEAR_TO_LINEAR="LinearToLinear",nr.SRGB_TO_LINEAR="sRGBToLinear",nr.LINEAR_TO_SRGB="LinearTosRGB";var qe=class extends re{constructor(e="",r,o,i,a){super(e,a,i,o,r);this.nodeType="Expression"}};import{Texture as KI}from"three";var ir=class extends Xe{constructor(e=new KI,r,o,i){super("v4",{shared:!0});this.nodeType="Texture";this.value=e,this.uv=r??new Ya,this.bias=o,this.project=i!==void 0?i:!1}getTexture(e,r){return super.generate(e,r,this.value.uuid,"t")}generate(e,r){if(r==="sampler2D")return this.getTexture(e,r);let o=this.getTexture(e,r),i=this.uv.build(e,this.project?"v4":"v2"),a=this.bias?this.bias.build(e,"f"):void 0;a===void 0&&e.context.bias&&(a=e.context.bias.setTexture(this).build(e,"f"));let s,l;this.project?s="texture2DProj":s=a?"tex2DBias":"tex2D",a?l=s+"( "+o+", "+i+", "+a+" )":l=s+"( "+o+", "+i+" )";let u={include:e.isShader("vertex"),ignoreCache:!0},c=this.getType(e);return e.addContext(u),this.colorSpace=this.colorSpace??new nr(new qe("",c)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(l),l=this.colorSpace.build(e,c),e.removeContext(),e.format(l,c,r)}};var se=class extends Xe{constructor(e){super("f");this.nodeType="Float";this.value=e??0}generateReadonly(e,r,o,i,a,s){return e.format(this.value+(this.value%1?"":".0"),i,r)}};var gl=class extends ye{constructor(e,r){super();this.inputs=[];this.nodeType="FunctionCall";this.value=e,this.inputs=r??[]}getFunction(){return this.value}getType(e){return this.value.getType(e)}generate(e,r,o,i,a){i=this.getType(e);let s=this.value,l=s.build(e,r)+"( ",u=[];if(s.inputs){for(let c=0;c<s.inputs.length;c++){let d=s.inputs[c],p=this.inputs[c]||this.inputs[d.name];u.push(p.build(e,e.getTypeByFormat(d.type)))}l+=u.join(", ")+" )"}return e.format(l,i,r)}};var Vf=class extends ye{constructor(e,r,o=Vf.ADD){super();this.nodeType="Operator";this.type=e.type,this.a=e,this.b=r,this.op=o}getType(e){let r=this.a.getType(e),o=this.b.getType(e);return e.isTypeMatrix(r)?"v4":e.getTypeLength(o)>e.getTypeLength(r)?o:r}generate(e,r){let o=this.getType(e);this.type=o;let i=this.a.build(e,o),a=this.b.build(e,o);return e.format("( "+i+" "+this.op+" "+a+" )",o,r)}},kt=Vf;kt.ADD="+",kt.SUB="-",kt.MUL="*",kt.DIV="/";var Qe=class extends ye{constructor(e,r=Qe.ABS,o,i){super();this.nodeType="Math";this.a=e,typeof r!="string"?this.b=r:i=r,typeof o!="string"?this.c=o:i=o,this.method=i,this.hashProperties=["method"]}getNumInputs(e){switch(this.method){case Qe.MIX:case Qe.CLAMP:case Qe.REFRACT:case Qe.SMOOTHSTEP:case Qe.FACEFORWARD:return 3;case Qe.MIN:case Qe.MAX:case Qe.MOD:case Qe.STEP:case Qe.REFLECT:case Qe.DISTANCE:case Qe.DOT:case Qe.CROSS:case Qe.POW:return 2;default:return 1}}getInputType(e){let r=e.getTypeLength(this.a.getType(e)),o=this.b?e.getTypeLength(this.b.getType(e)):0,i=this.c?e.getTypeLength(this.c.getType(e)):0;return r>o&&r>i?this.a.getType(e):o>i?this.b.getType(e):this.c.getType(e)}getType(e){switch(this.method){case Qe.LENGTH:case Qe.DISTANCE:case Qe.DOT:return"f";case Qe.CROSS:return"v3"}return this.getInputType(e)}generate(e,r){let o,i,a,s=this.a?e.getTypeLength(this.a.getType(e)):0,l=this.b?e.getTypeLength(this.b.getType(e)):0,u=this.c?e.getTypeLength(this.c.getType(e)):0,c=this.getInputType(e),d=this.getType(e);switch(this.type=d,this.method){case Qe.NEGATE:return e.format("( -"+this.a.build(e,c)+" )",c,r);case Qe.INVERT:return e.format("( 1.0 - "+this.a.build(e,c)+" )",c,r);case Qe.CROSS:o=this.a.build(e,"v3"),i=this.b.build(e,"v3");break;case Qe.STEP:o=this.a.build(e,s===1?"f":c),i=this.b.build(e,c);break;case Qe.MIN:case Qe.MAX:case Qe.MOD:o=this.a.build(e,c),i=this.b.build(e,l===1?"f":c);break;case Qe.REFRACT:o=this.a.build(e,c),i=this.b.build(e,c),a=this.c.build(e,"f");break;case Qe.MIX:o=this.a.build(e,c),i=this.b.build(e,c),a=this.c.build(e,u===1?"f":c);break;default:o=this.a.build(e,c),this.b&&(i=this.b.build(e,c)),this.c&&(a=this.c.build(e,c));break}let p=[];p.push(o),i&&p.push(i),a&&p.push(a);let f=this.getNumInputs(e);if(p.length!==f)throw Error(`Arguments not match used in "${this.method}". Require ${f}, currently ${p.length}.`);return e.format(this.method+"( "+p.join(", ")+" )",d,r)}},Pe=Qe;Pe.RAD="radians",Pe.DEG="degrees",Pe.EXP="exp",Pe.EXP2="exp2",Pe.LOG="log",Pe.LOG2="log2",Pe.SQRT="sqrt",Pe.INV_SQRT="inversesqrt",Pe.FLOOR="floor",Pe.CEIL="ceil",Pe.NORMALIZE="normalize",Pe.FRACT="fract",Pe.SATURATE="saturate",Pe.SIN="sin",Pe.COS="cos",Pe.TAN="tan",Pe.ASIN="asin",Pe.ACOS="acos",Pe.ARCTAN="atan",Pe.ABS="abs",Pe.SIGN="sign",Pe.LENGTH="length",Pe.NEGATE="negate",Pe.INVERT="invert",Pe.MIN="min",Pe.MAX="max",Pe.MOD="mod",Pe.STEP="step",Pe.REFLECT="reflect",Pe.DISTANCE="distance",Pe.DOT="dot",Pe.CROSS="cross",Pe.POW="pow",Pe.MIX="mix",Pe.CLAMP="clamp",Pe.REFRACT="refract",Pe.SMOOTHSTEP="smoothstep",Pe.FACEFORWARD="faceforward";var Xa=class extends ye{constructor(e,r,o){super("v4");this.nodeType="TextureCubeUV";this.value=e,this.uv=r,this.bias=o}bilinearCubeUV(e,r,o,i){let a=new gl(Xa.Nodes.bilinearCubeUV,[r,o,i]);this.colorSpaceTL=this.colorSpaceTL??new nr(new qe("","v4")),this.colorSpaceTL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTL.input.parse(a.build(e)+".tl"),this.colorSpaceTR=this.colorSpaceTR??new nr(new qe("","v4")),this.colorSpaceTR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTR.input.parse(a.build(e)+".tr"),this.colorSpaceBL=this.colorSpaceBL??new nr(new qe("","v4")),this.colorSpaceBL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBL.input.parse(a.build(e)+".bl"),this.colorSpaceBR=this.colorSpaceBR??new nr(new qe("","v4")),this.colorSpaceBR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBR.input.parse(a.build(e)+".br");let s={include:e.isShader("vertex"),ignoreCache:!0};e.addContext(s),this.colorSpaceTLExp=new qe(this.colorSpaceTL.build(e,"v4"),"v4"),this.colorSpaceTRExp=new qe(this.colorSpaceTR.build(e,"v4"),"v4"),this.colorSpaceBLExp=new qe(this.colorSpaceBL.build(e,"v4"),"v4"),this.colorSpaceBRExp=new qe(this.colorSpaceBR.build(e,"v4"),"v4"),e.removeContext();let l=new qe("mix( mix( cubeUV_TL, cubeUV_TR, cubeUV.f.x ), mix( cubeUV_BL, cubeUV_BR, cubeUV.f.x ), cubeUV.f.y )","v4");return l.keywords.cubeUV_TL=this.colorSpaceTLExp,l.keywords.cubeUV_TR=this.colorSpaceTRExp,l.keywords.cubeUV_BL=this.colorSpaceBLExp,l.keywords.cubeUV_BR=this.colorSpaceBRExp,l.keywords.cubeUV=a,l}generate(e,r){if(e.isShader("fragment")){let o=this.uv,i=this.bias||e.context.roughness,a=new gl(Xa.Nodes.roughnessToMip,[i]),s=new Pe(a,Xa.Nodes.m0,Xa.Nodes.cubeUV_maxMipLevel,Pe.CLAMP),l=new Pe(s,Pe.FLOOR),u=new Pe(s,Pe.FRACT),c=this.bilinearCubeUV(e,this.value,o,l),d=this.bilinearCubeUV(e,this.value,o,new kt(l,new se(1).setReadonly(!0),kt.ADD)),p=new Pe(c,d,u,Pe.MIX);return e.format(p.build(e),"v4",r)}else return console.warn("TextureCubeUVNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),r)}},Qa=Xa;Qa.Nodes=function(){let e=new $a(`struct TextureCubeUVData {
23
23
  vec4 tl;
24
24
  vec4 tr;
25
25
  vec4 br;
@@ -84,7 +84,7 @@ var U1=Object.create;var $l=Object.defineProperty;var H1=Object.getOwnPropertyDe
84
84
  uv.x -= texelSize;
85
85
  vec4 bl = texture2D(envMap, uv);
86
86
  return TextureCubeUVData( tl, tr, br, bl, f );
87
- }`,[e,s,l,r,o,i,a]);u.useKeywords=!1;let c=new Ue("float r0 1.0",!0),d=new Ue("float v0 0.339",!0),p=new Ue("float m0 -2.0",!0),f=new Ue("float r1 0.8",!0),h=new Ue("float v1 0.276",!0),m=new Ue("float m1 -1.0",!0),y=new Ue("float r4 0.4",!0),g=new Ue("float v4 0.046",!0),b=new Ue("float m4 2.0",!0),w=new Ue("float r5 0.305",!0),_=new Ue("float v5 0.016",!0),S=new Ue("float m5 3.0",!0),P=new Ue("float r6 0.21",!0),O=new Ue("float v6 0.0038",!0),x=new Ue("float m6 4.0",!0),D=[c,d,p,f,h,m,y,g,b,w,_,S,P,O,x],N=new re(`float roughnessToMip(float roughness) {
87
+ }`,[e,s,l,r,o,i,a]);u.useKeywords=!1;let c=new Ue("float r0 1.0",!0),d=new Ue("float v0 0.339",!0),p=new Ue("float m0 -2.0",!0),f=new Ue("float r1 0.8",!0),h=new Ue("float v1 0.276",!0),m=new Ue("float m1 -1.0",!0),y=new Ue("float r4 0.4",!0),g=new Ue("float v4 0.046",!0),b=new Ue("float m4 2.0",!0),w=new Ue("float r5 0.305",!0),A=new Ue("float v5 0.016",!0),S=new Ue("float m5 3.0",!0),P=new Ue("float r6 0.21",!0),O=new Ue("float v6 0.0038",!0),x=new Ue("float m6 4.0",!0),D=[c,d,p,f,h,m,y,g,b,w,A,S,P,O,x],N=new re(`float roughnessToMip(float roughness) {
88
88
  float mip = 0.0;
89
89
  if (roughness >= r1) {
90
90
  mip = (r0 - roughness) * (m1 - m0) / (r0 - r1) + m0;
@@ -98,7 +98,7 @@ var U1=Object.create;var $l=Object.defineProperty;var H1=Object.getOwnPropertyDe
98
98
  mip = -2.0 * log2(1.16 * roughness);// 1.16 = 1.79^0.25
99
99
  }
100
100
  return mip;
101
- }`,D);return{bilinearCubeUV:u,roughnessToMip:N,m0:p,cubeUV_maxMipLevel:r}}();var ui=class extends ye{constructor(e){super("v3");this.nodeType="Normal";this.scope=e??ui.VIEW}getShared(){return this.scope===ui.WORLD}build(e,r,o,i){let a=e.context[this.scope+"Normal"];return a?a.build(e,r,o,i):super.build(e,r,o)}generate(e,r,o,i,a){let s;switch(this.scope){case ui.VIEW:e.isShader("vertex")?s="transformedNormal":s="geometryNormal";break;case ui.LOCAL:e.isShader("vertex")?s="objectNormal":(e.requires.normal=!0,s="vObjectNormal");break;case ui.WORLD:e.isShader("vertex")?s="inverseTransformDirection( transformedNormal, viewMatrix ).xyz":(e.requires.worldNormal=!0,s="vWNormal");break}return e.format(s,this.getType(e),r)}},jt=ui;jt.LOCAL="local",jt.WORLD="world",jt.VIEW="view",jt.NORMAL="normal";Et.addKeyword("viewNormal",function(){return new jt(jt.VIEW)});Et.addKeyword("localNormal",function(){return new jt(jt.NORMAL)});Et.addKeyword("worldNormal",function(){return new jt(jt.WORLD)});var vo=class extends ye{constructor(e){super("v3");this.nodeType="Position";this.scope=e??vo.LOCAL}getType(){switch(this.scope){case vo.PROJECTION:return"v4"}return this.type}getShader(){switch(this.scope){case vo.LOCAL:case vo.WORLD:return!1}return!0}generate(e,r,o,i,a){let s;switch(this.scope){case vo.LOCAL:e.isShader("vertex")?s="transformed":(e.requires.position=!0,s="vPosition");break;case vo.WORLD:if(e.isShader("vertex"))return"( modelMatrix * vec4( transformed, 1.0 ) ).xyz";e.requires.worldPosition=!0,s="vWPosition";break;case vo.VIEW:s=e.isShader("vertex")?"-mvPosition.xyz":"vViewPosition";break;case vo.PROJECTION:s=e.isShader("vertex")?"( projectionMatrix * modelViewMatrix * vec4( position, 1.0 ) )":"vec4( 0.0 )";break}return e.format(s,this.getType(),r)}},fr=vo;fr.LOCAL="local",fr.WORLD="world",fr.VIEW="view",fr.PROJECTION="projection";Et.addKeyword("position",function(){return new fr});Et.addKeyword("worldPosition",function(){return new fr(fr.WORLD)});Et.addKeyword("viewPosition",function(){return new fr(fr.VIEW)});var Kr=class extends ye{constructor(e){super("v3");this.nodeType="Reflect";this.scope=e??Kr.CUBE}getUnique(e){return!e.context.viewNormal}getType(){switch(this.scope){case Kr.SPHERE:return"v2"}return this.type}generate(e,r){let o=this.getUnique(e);if(e.isShader("fragment")){let i;switch(this.scope){case Kr.VECTOR:{let a=new jt(jt.VIEW),s=e.context.roughness,l=a.build(e,"v3"),u=new fr(fr.VIEW).build(e,"v3"),c=s?s.build(e,"f"):void 0,d=`reflect( -normalize( ${u} ), ${l} )`;c&&(d=`normalize( mix( ${d}, ${l}, ${c} * ${c} ) )`);let p=`inverseTransformDirection( ${d}, viewMatrix )`;o?(e.addNodeCode(`vec3 reflectVec = ${p};`),i="reflectVec"):i=p;break}case Kr.CUBE:{let a=new Kr(Kr.VECTOR).build(e,"v3"),s="vec3( -"+a+".x, "+a+".yz )";o?(e.addNodeCode(`vec3 reflectCubeVec = ${s};`),i="reflectCubeVec"):i=s;break}case Kr.SPHERE:{let s="normalize( ( viewMatrix * vec4( "+new Kr(Kr.VECTOR).build(e,"v3")+", 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) ).xy * 0.5 + 0.5";o?(e.addNodeCode(`vec2 reflectSphereVec = ${s};`),i="reflectSphereVec"):i=s;break}}return e.format(i,this.getType(),r)}else return console.warn("ReflectNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.type,r)}},So=Kr;So.CUBE="cube",So.SPHERE="sphere",So.VECTOR="vector";var zu=class extends ye{constructor(e=new ir,r,o){super("v4");this.nodeType="TextureCube";this.value=e,this.radianceNode=new Xa(this.value,r??new So(So.VECTOR),o),this.irradianceNode=new Xa(this.value,new jt(jt.WORLD),new se(1).setReadonly(!0))}generate(e,r){return e.isShader("fragment")?(e.require("irradiance"),e.context.bias&&e.context.bias.setTexture(this.value),(e.slot==="irradiance"?this.irradianceNode:this.radianceNode).build(e,r)):(console.warn("TextureCubeNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),r))}};import{CubeTexture as YI}from"three";var Gu=class extends Xe{constructor(e=new YI,r,o){super("v4",{shared:!0});this.nodeType="CubeTexture";this.value=e,this.uv=r??new So,this.bias=o}getTexture(e,r){return super.generate(e,r,this.value.uuid,"tc")}generate(e,r){if(r==="samplerCube")return this.getTexture(e,r);let o=this.getTexture(e,r),i=this.uv?.build(e,"v3"),a=this.bias?this.bias.build(e,"f"):void 0;a===void 0&&e.context.bias&&(a=e.context.bias.setTexture(this).build(e,"f"));let s;a?s="texCubeBias( "+o+", "+i+", "+a+" )":s="texCube( "+o+", "+i+" )";let l={include:e.isShader("vertex"),ignoreCache:!0},u=this.getType(e);return e.addContext(l),this.colorSpace=this.colorSpace??new nr(new qe("",u)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(s),s=this.colorSpace.build(e,u),e.removeContext(),e.format(s,u,r)}};var bb=`
101
+ }`,D);return{bilinearCubeUV:u,roughnessToMip:N,m0:p,cubeUV_maxMipLevel:r}}();var ui=class extends ye{constructor(e){super("v3");this.nodeType="Normal";this.scope=e??ui.VIEW}getShared(){return this.scope===ui.WORLD}build(e,r,o,i){let a=e.context[this.scope+"Normal"];return a?a.build(e,r,o,i):super.build(e,r,o)}generate(e,r,o,i,a){let s;switch(this.scope){case ui.VIEW:e.isShader("vertex")?s="transformedNormal":s="geometryNormal";break;case ui.LOCAL:e.isShader("vertex")?s="objectNormal":(e.requires.normal=!0,s="vObjectNormal");break;case ui.WORLD:e.isShader("vertex")?s="inverseTransformDirection( transformedNormal, viewMatrix ).xyz":(e.requires.worldNormal=!0,s="vWNormal");break}return e.format(s,this.getType(e),r)}},jt=ui;jt.LOCAL="local",jt.WORLD="world",jt.VIEW="view",jt.NORMAL="normal";Et.addKeyword("viewNormal",function(){return new jt(jt.VIEW)});Et.addKeyword("localNormal",function(){return new jt(jt.NORMAL)});Et.addKeyword("worldNormal",function(){return new jt(jt.WORLD)});var vo=class extends ye{constructor(e){super("v3");this.nodeType="Position";this.scope=e??vo.LOCAL}getType(){switch(this.scope){case vo.PROJECTION:return"v4"}return this.type}getShader(){switch(this.scope){case vo.LOCAL:case vo.WORLD:return!1}return!0}generate(e,r,o,i,a){let s;switch(this.scope){case vo.LOCAL:e.isShader("vertex")?s="transformed":(e.requires.position=!0,s="vPosition");break;case vo.WORLD:if(e.isShader("vertex"))return"( modelMatrix * vec4( transformed, 1.0 ) ).xyz";e.requires.worldPosition=!0,s="vWPosition";break;case vo.VIEW:s=e.isShader("vertex")?"-mvPosition.xyz":"vViewPosition";break;case vo.PROJECTION:s=e.isShader("vertex")?"( projectionMatrix * modelViewMatrix * vec4( position, 1.0 ) )":"vec4( 0.0 )";break}return e.format(s,this.getType(),r)}},fr=vo;fr.LOCAL="local",fr.WORLD="world",fr.VIEW="view",fr.PROJECTION="projection";Et.addKeyword("position",function(){return new fr});Et.addKeyword("worldPosition",function(){return new fr(fr.WORLD)});Et.addKeyword("viewPosition",function(){return new fr(fr.VIEW)});var Kr=class extends ye{constructor(e){super("v3");this.nodeType="Reflect";this.scope=e??Kr.CUBE}getUnique(e){return!e.context.viewNormal}getType(){switch(this.scope){case Kr.SPHERE:return"v2"}return this.type}generate(e,r){let o=this.getUnique(e);if(e.isShader("fragment")){let i;switch(this.scope){case Kr.VECTOR:{let a=new jt(jt.VIEW),s=e.context.roughness,l=a.build(e,"v3"),u=new fr(fr.VIEW).build(e,"v3"),c=s?s.build(e,"f"):void 0,d=`reflect( -normalize( ${u} ), ${l} )`;c&&(d=`normalize( mix( ${d}, ${l}, ${c} * ${c} ) )`);let p=`inverseTransformDirection( ${d}, viewMatrix )`;o?(e.addNodeCode(`vec3 reflectVec = ${p};`),i="reflectVec"):i=p;break}case Kr.CUBE:{let a=new Kr(Kr.VECTOR).build(e,"v3"),s="vec3( -"+a+".x, "+a+".yz )";o?(e.addNodeCode(`vec3 reflectCubeVec = ${s};`),i="reflectCubeVec"):i=s;break}case Kr.SPHERE:{let s="normalize( ( viewMatrix * vec4( "+new Kr(Kr.VECTOR).build(e,"v3")+", 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) ).xy * 0.5 + 0.5";o?(e.addNodeCode(`vec2 reflectSphereVec = ${s};`),i="reflectSphereVec"):i=s;break}}return e.format(i,this.getType(),r)}else return console.warn("ReflectNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.type,r)}},So=Kr;So.CUBE="cube",So.SPHERE="sphere",So.VECTOR="vector";var zu=class extends ye{constructor(e=new ir,r,o){super("v4");this.nodeType="TextureCube";this.value=e,this.radianceNode=new Qa(this.value,r??new So(So.VECTOR),o),this.irradianceNode=new Qa(this.value,new jt(jt.WORLD),new se(1).setReadonly(!0))}generate(e,r){return e.isShader("fragment")?(e.require("irradiance"),e.context.bias&&e.context.bias.setTexture(this.value),(e.slot==="irradiance"?this.irradianceNode:this.radianceNode).build(e,r)):(console.warn("TextureCubeNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),r))}};import{CubeTexture as ZI}from"three";var Gu=class extends Xe{constructor(e=new ZI,r,o){super("v4",{shared:!0});this.nodeType="CubeTexture";this.value=e,this.uv=r??new So,this.bias=o}getTexture(e,r){return super.generate(e,r,this.value.uuid,"tc")}generate(e,r){if(r==="samplerCube")return this.getTexture(e,r);let o=this.getTexture(e,r),i=this.uv?.build(e,"v3"),a=this.bias?this.bias.build(e,"f"):void 0;a===void 0&&e.context.bias&&(a=e.context.bias.setTexture(this).build(e,"f"));let s;a?s="texCubeBias( "+o+", "+i+", "+a+" )":s="texCube( "+o+", "+i+" )";let l={include:e.isShader("vertex"),ignoreCache:!0},u=this.getType(e);return e.addContext(l),this.colorSpace=this.colorSpace??new nr(new qe("",u)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(s),s=this.colorSpace.build(e,u),e.removeContext(),e.format(s,u,r)}};var vb=`
102
102
  uniform int frameIndex;
103
103
  uniform vec2 resolution;
104
104
  uniform mat4 previousModelViewMatrix;
@@ -106,7 +106,7 @@ uniform mat4 previousProjectionMatrix;
106
106
 
107
107
  varying vec4 vCurrentPosition;
108
108
  varying vec4 vPreviousPosition;
109
- `,vb=`
109
+ `,Sb=`
110
110
  layout(location = 1) out vec4 gVelocity;
111
111
 
112
112
  uniform int frameIndex;
@@ -148,7 +148,7 @@ float getNoiseInterleavedGradient(vec2 screenPos) {
148
148
  return fract(magic.z * fract(dot(screenPos, magic.xy)));
149
149
  }
150
150
 
151
- `,Sb=`
151
+ `,wb=`
152
152
  // TODO: This could be generated CPU side and passed to the shader every frame
153
153
  const vec2 haltonSequence[16] = vec2[16](
154
154
  vec2( 0.000000,-0.333334),
@@ -185,7 +185,7 @@ vPreviousPosition.xy += OUTLINE_COMPENSATION;
185
185
  #endif
186
186
  gl_Position = currentPositionJittered;
187
187
 
188
- `,wb=`
188
+ `,Ab=`
189
189
  vec2 oldPos = vPreviousPosition.xy;
190
190
  oldPos /= vPreviousPosition.w;
191
191
  oldPos.xy = (oldPos.xy+1.)/2.0;
@@ -200,14 +200,14 @@ vec2 velocity = (newPos - oldPos);
200
200
  if (gl_FragColor.a <= 0.0) discard;
201
201
 
202
202
  gVelocity = vec4(velocity, 0.0, 1.0);
203
- `,Ab=`
204
- layout(location = 1) out vec4 gVelocity;
205
203
  `,_b=`
204
+ layout(location = 1) out vec4 gVelocity;
205
+ `,Pb=`
206
206
  // Discard fully transparent pixels
207
207
  if (gl_FragColor.a <= 0.0) discard;
208
208
 
209
209
  gVelocity = vec4(0.0, 0.0, 0.0, 1.0);
210
- `;var Ob=["x","y","z","w"],JI=["float","vec2","vec3","vec4"],e3={float:"f",vec2:"v2",vec3:"v3",vec4:"v4",mat4:"v4",int:"i",bool:"b","float[]":"f[]","vec4[]":"v4[]"},t3={t:"sampler2D",tc:"samplerCube",b:"bool",i:"int",f:"float",c:"vec3",v2:"vec2",v3:"vec3",v4:"vec4",m3:"mat3",m4:"mat4","f[]":"float[]","v4[]":"vec4[]"},Qa=class{constructor(){this.includes={consts:{},functions:{},structs:{}};this.cache="";this.slot="";this.shader="";this.context={};this.needsJitter=!0;this.getIncludesCode=function(){function t(e,r){return e.deps.length-r.deps.length}return function(r,o){let i=this.getIncludes(r,o);if(!i)return"";let a="";i=i.sort(t);for(let s=0;s<i.length;s++)i[s].src&&(a+=i[s].src+`
210
+ `;var Cb=["x","y","z","w"],o3=["float","vec2","vec3","vec4"],n3={float:"f",vec2:"v2",vec3:"v3",vec4:"v4",mat4:"v4",int:"i",bool:"b","float[]":"f[]","vec4[]":"v4[]"},i3={t:"sampler2D",tc:"samplerCube",b:"bool",i:"int",f:"float",c:"vec3",v2:"vec2",v3:"vec3",v4:"vec4",m3:"mat3",m4:"mat4","f[]":"float[]","v4[]":"vec4[]"},Ka=class{constructor(){this.includes={consts:{},functions:{},structs:{}};this.cache="";this.slot="";this.shader="";this.context={};this.needsJitter=!0;this.getIncludesCode=function(){function t(e,r){return e.deps.length-r.deps.length}return function(r,o){let i=this.getIncludes(r,o);if(!i)return"";let a="";i=i.sort(t);for(let s=0;s<i.length;s++)i[s].src&&(a+=i[s].src+`
211
211
  `);return a}}();this.slots=[],this.caches=[],this.contexts=[],this.keywords={},this.nodeData={},this.fragmentVariables={},this.fragmentParsVariables={},this.vertexParsVariables={},this.requires={uv:[],color:[],transparent:!1,irradiance:!1,position:!1,worldPosition:!1,normal:!1,worldNormal:!1,vWorldViewDir:!1,modelMatrix:!1,viewMatrix:!1,projectionMatrix:!1},this.includes={consts:[],functions:[],structs:[]},this.attributes={},this.prefixCode=["#ifdef TEXTURE_LOD_EXT"," #define texCube(a, b) textureCube(a, b)"," #define texCubeBias(a, b, c) textureCubeLodEXT(a, b, c)"," #define tex2D(a, b) texture2D(a, b)"," #define tex2DBias(a, b, c) texture2DLodEXT(a, b, c)","#else"," #define texCube(a, b) textureCube(a, b)"," #define texCubeBias(a, b, c) textureCube(a, b, c)"," #define tex2D(a, b) texture2D(a, b)"," #define tex2DBias(a, b, c) texture2D(a, b, c)","#endif",`
212
212
  // NOTE: Include Spline's blending modes. This could be part of BlendNode
213
213
  #define SPE_BLENDING_NORMAL 0
@@ -245,20 +245,20 @@ layout(location = 1) out vec4 gVelocity;
245
245
  `),fragment:["float accumAlpha = 0.0;",`void accumulateAlpha(float alpha) {
246
246
  accumAlpha += (1.0 - accumAlpha) * alpha;
247
247
  }`,""].join(`
248
- `)},this.code={vertex:"",fragment:""},this.nodeCode={vertex:"",fragment:""},this.resultCode={vertex:"",fragment:""},this.finalCode={vertex:"",fragment:""},this.inputs={uniforms:{list:[],vertex:[],fragment:[]},arrayUniforms:{list:[],vertex:[],fragment:[]},vars:{varying:[],vertex:[],fragment:[]}},this.defines={},this.uniforms={},this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.updaters=[],this.nodes=[],this.analyzing=!1}build(t,e){this.addVertexParsCode(bb),this.addFragmentParsCode(vb),this.buildShader("vertex",t),this.buildShader("fragment",e);for(let r=0;r<this.requires.uv.length;r++)if(this.requires.uv[r]){let o=r>0?r+1:"";this.addVaryCode("varying vec2 vUv"+o+";"),r>0&&this.addVertexParsCode("attribute vec2 uv"+o+";"),this.addVertexFinalCode("vUv"+o+" = uv"+o+";")}return this.requires.color[0]&&(this.addVaryCode("varying vec4 vColor;"),this.addVertexParsCode("attribute vec4 color;"),this.addVertexFinalCode("vColor = color;")),this.requires.color[1]&&(this.addVaryCode("varying vec4 vColor2;"),this.addVertexParsCode("attribute vec4 color2;"),this.addVertexFinalCode("vColor2 = color2;")),this.requires.position&&(this.addVaryCode("varying vec3 vPosition;"),this.addVertexFinalCode("vPosition = transformed;")),this.requires.worldPosition,this.requires.normal&&(this.addVaryCode("varying vec3 vObjectNormal;"),this.addVertexFinalCode("vObjectNormal = normal;")),this.requires.modelMatrix&&this.addFragmentParsCode("uniform mat4 modelMatrix;"),this.requires.viewMatrix&&this.addFragmentParsCode("uniform mat4 viewMatrix;"),this.requires.projectionMatrix&&this.addFragmentParsCode("uniform mat4 projectionMatrix;"),this.requires.worldNormal&&(this.addVaryCode("varying vec3 vWNormal;"),this.addVertexFinalCode("vWNormal = inverseTransformDirection( transformedNormal, viewMatrix ).xyz;")),this.requires.vWorldViewDir&&(this.addVaryCode("varying vec3 vWorldViewDir;"),this.addVertexFinalCode("vWorldViewDir = isPerspectiveMatrix( projectionMatrix ) ? ( (modelMatrix * vec4(position, 1.0)).xyz - cameraPosition ) : vec3( -viewMatrix[0][2], -viewMatrix[1][2], -viewMatrix[2][2] );")),this.needsJitter&&(this.addVertexFinalCode(Sb),this.addFragmentFinalCode(wb)),this}buildShader(t,e){this.resultCode[t]=e.build(this.setShader(t),"v4")}setMaterial(t,e){return this.defines={},this}addFlow(t,e,r){return this.addSlot(t).addCache(e).addContext(r)}removeFlow(){return this.removeSlot().removeCache().removeContext()}addCache(t){return this.cache=t??"",this.caches.push(this.cache),this}removeCache(){return this.caches.pop(),this.cache=this.caches[this.caches.length-1]||"",this}addContext(t){return this.context=Object.assign({},this.context,t),this.context.extra=this.context.extra||{},this.contexts.push(this.context),this}removeContext(){return this.contexts.pop(),this.context=this.contexts[this.contexts.length-1]||{},this}addSlot(t){return this.slot=t||"",this.slots.push(this.slot),this}removeSlot(){return this.slots.pop(),this.slot=this.slots[this.slots.length-1]||"",this}addFragmentVariable(t,e){this.fragmentVariables[t]===void 0&&(this.addFragmentCode(`${e} ${t};`),this.fragmentVariables[t]="")}addFragmentParsVariable(t,e){this.fragmentParsVariables[t]===void 0&&(this.addFragmentParsCode(`${e} ${t};`),this.fragmentParsVariables[t]="")}addVertexParsVariable(t,e){this.vertexParsVariables[t]===void 0&&(this.addVertexParsCode(`${e} ${t};`),this.vertexParsVariables[t]="")}addVertexCode(t){this.addCode(t,"vertex")}addFragmentCode(t){this.addCode(t,"fragment")}addCode(t,e){this.code[e??this.shader]+=t+`
248
+ `)},this.code={vertex:"",fragment:""},this.nodeCode={vertex:"",fragment:""},this.resultCode={vertex:"",fragment:""},this.finalCode={vertex:"",fragment:""},this.inputs={uniforms:{list:[],vertex:[],fragment:[]},arrayUniforms:{list:[],vertex:[],fragment:[]},vars:{varying:[],vertex:[],fragment:[]}},this.defines={},this.uniforms={},this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.updaters=[],this.nodes=[],this.analyzing=!1}build(t,e){this.addVertexParsCode(vb),this.addFragmentParsCode(Sb),this.buildShader("vertex",t),this.buildShader("fragment",e);for(let r=0;r<this.requires.uv.length;r++)if(this.requires.uv[r]){let o=r>0?r+1:"";this.addVaryCode("varying vec2 vUv"+o+";"),r>0&&this.addVertexParsCode("attribute vec2 uv"+o+";"),this.addVertexFinalCode("vUv"+o+" = uv"+o+";")}return this.requires.color[0]&&(this.addVaryCode("varying vec4 vColor;"),this.addVertexParsCode("attribute vec4 color;"),this.addVertexFinalCode("vColor = color;")),this.requires.color[1]&&(this.addVaryCode("varying vec4 vColor2;"),this.addVertexParsCode("attribute vec4 color2;"),this.addVertexFinalCode("vColor2 = color2;")),this.requires.position&&(this.addVaryCode("varying vec3 vPosition;"),this.addVertexFinalCode("vPosition = transformed;")),this.requires.worldPosition,this.requires.normal&&(this.addVaryCode("varying vec3 vObjectNormal;"),this.addVertexFinalCode("vObjectNormal = normal;")),this.requires.modelMatrix&&this.addFragmentParsCode("uniform mat4 modelMatrix;"),this.requires.viewMatrix&&this.addFragmentParsCode("uniform mat4 viewMatrix;"),this.requires.projectionMatrix&&this.addFragmentParsCode("uniform mat4 projectionMatrix;"),this.requires.worldNormal&&(this.addVaryCode("varying vec3 vWNormal;"),this.addVertexFinalCode("vWNormal = inverseTransformDirection( transformedNormal, viewMatrix ).xyz;")),this.requires.vWorldViewDir&&(this.addVaryCode("varying vec3 vWorldViewDir;"),this.addVertexFinalCode("vWorldViewDir = isPerspectiveMatrix( projectionMatrix ) ? ( (modelMatrix * vec4(position, 1.0)).xyz - cameraPosition ) : vec3( -viewMatrix[0][2], -viewMatrix[1][2], -viewMatrix[2][2] );")),this.needsJitter&&(this.addVertexFinalCode(wb),this.addFragmentFinalCode(Ab)),this}buildShader(t,e){this.resultCode[t]=e.build(this.setShader(t),"v4")}setMaterial(t,e){return this.defines={},this}addFlow(t,e,r){return this.addSlot(t).addCache(e).addContext(r)}removeFlow(){return this.removeSlot().removeCache().removeContext()}addCache(t){return this.cache=t??"",this.caches.push(this.cache),this}removeCache(){return this.caches.pop(),this.cache=this.caches[this.caches.length-1]||"",this}addContext(t){return this.context=Object.assign({},this.context,t),this.context.extra=this.context.extra||{},this.contexts.push(this.context),this}removeContext(){return this.contexts.pop(),this.context=this.contexts[this.contexts.length-1]||{},this}addSlot(t){return this.slot=t||"",this.slots.push(this.slot),this}removeSlot(){return this.slots.pop(),this.slot=this.slots[this.slots.length-1]||"",this}addFragmentVariable(t,e){this.fragmentVariables[t]===void 0&&(this.addFragmentCode(`${e} ${t};`),this.fragmentVariables[t]="")}addFragmentParsVariable(t,e){this.fragmentParsVariables[t]===void 0&&(this.addFragmentParsCode(`${e} ${t};`),this.fragmentParsVariables[t]="")}addVertexParsVariable(t,e){this.vertexParsVariables[t]===void 0&&(this.addVertexParsCode(`${e} ${t};`),this.vertexParsVariables[t]="")}addVertexCode(t){this.addCode(t,"vertex")}addFragmentCode(t){this.addCode(t,"fragment")}addCode(t,e){this.code[e??this.shader]+=t+`
249
249
  `}addVertexNodeCode(t){this.addNodeCode(t,"vertex")}addFragmentNodeCode(t){this.addNodeCode(t,"fragment")}addNodeCode(t,e){this.nodeCode[e??this.shader]+=t+`
250
250
  `}clearNodeCode(t){t=t??this.shader;let e=this.nodeCode[t];return this.nodeCode[t]="",e}clearVertexNodeCode(){return this.clearNodeCode("vertex")}clearFragmentNodeCode(){return this.clearNodeCode("fragment")}addVertexFinalCode(t){this.addFinalCode(t,"vertex")}addFragmentFinalCode(t){this.addFinalCode(t,"fragment")}addFinalCode(t,e){this.finalCode[e??this.shader]+=t+`
251
251
  `}addVertexParsCode(t){this.addParsCode(t,"vertex")}addFragmentParsCode(t){this.addParsCode(t,"fragment")}addParsCode(t,e){this.parsCode[e??this.shader]+=t+`
252
252
  `}addVaryCode(t){this.addVertexParsCode(t),this.addFragmentParsCode(t)}isCache(t){return this.caches.indexOf(t)!==-1}isSlot(t){return this.slots.indexOf(t)!==-1}define(t,e){this.defines[t]=e===void 0?1:e}require(t){this.requires[t]=!0}isDefined(t){return this.defines[t]!==void 0}getVar(t,e,r,o="varying",i="V",a=""){let s=this.getVars(o),l=s[t];if(!l){let u=s.length;l={name:r||"node"+i+u+(a?"_"+a:""),type:e},s.push(l),s[t]=l}return l}getTempVar(t,e,r,o){return this.getVar(t,e,r,this.shader,"T",o)}getAttribute(t,e){if(!this.attributes[t]){let r=this.getVar(t,e);this.addVertexParsCode("attribute "+e+" "+t+";"),this.addVertexFinalCode(r.name+" = "+t+";"),this.attributes[t]={varying:r,name:t,type:e}}return this.attributes[t]}getCode(t){return[this.prefixCode,this.parsCode[t],this.getVarListCode(this.getVars("varying"),"varying"),this.getVarListCode(this.inputs.uniforms[t],"uniform"),this.getVarListCode(this.inputs.arrayUniforms[t],"uniform"),this.getIncludesCode("consts",t),this.getIncludesCode("structs",t),this.getIncludesCode("functions",t),"void main() {",this.getVarListCode(this.getVars(t)),this.code[t],this.resultCode[t],this.finalCode[t],"}"].join(`
253
253
  `)}getVarListCode(t,e){e=e??"";let r="";for(let o=0,i=t.length;o<i;++o){let a=t[o],s=a.type,l=a.name,u=a.size,c=this.getFormatByType(s);if(c===void 0)throw new Error("Node pars "+c+" not found.");c.includes("[]")?r+=e+" "+c.substring(0,c.length-2)+" "+l+`[${u}];
254
254
  `:r+=e+" "+c+" "+l+`;
255
- `}return r}getVars(t){return this.inputs.vars[t??this.shader]}getNodeData(t){let e=t instanceof Ft?t.uuid:t;return this.nodeData[e]=this.nodeData[e]||{}}createUniform(t,e,r,o,i,a){if(e.includes("[]")){let s=this.inputs.arrayUniforms,l=s.list.length,u=new yl({type:e,size:r.size,name:o||"nodeUA"+l+(a?"_"+a:""),node:r,needsUpdate:i});return s.list.push(u),s[t].push(u),s[t][u.name]=u,this.uniforms[u.name]=u,u}else{let s=this.inputs.uniforms,l=s.list.length,u=new yl({type:e,name:o||"nodeU"+l+(a?"_"+a:""),node:r,needsUpdate:i});return s.list.push(u),s[t].push(u),s[t][u.name]=u,this.uniforms[u.name]=u,u}}createVertexUniform(t,e,r,o,i){return this.createUniform("vertex",t,e,r,o,i)}createFragmentUniform(t,e,r,o,i){return this.createUniform("fragment",t,e,r,o,i)}include(t,e,r){let o;if(t=typeof t=="string"?Et.get(t):t,this.context.include===!1)return t.name;t instanceof re?o=this.includes.functions:t instanceof Ue?o=this.includes.consts:t instanceof Wa&&(o=this.includes.structs);let i=o[this.shader]=o[this.shader]||[];if(t){let a=i[t.name];if(a||(a=i[t.name]={node:t,deps:[]},i.push(a),a.src=t.build(this,"source")),t instanceof re&&e&&i[e.name]&&i[e.name].deps.indexOf(t)===-1&&(i[e.name].deps.push(t),t.includes?.length)){let s=0;do this.include(t.includes[s++],e);while(s<t.includes.length)}return r&&(a.src=r),t.name}else throw new Error("Include not found.")}colorToVectorProperties(t){return t.replace("r","x").replace("g","y").replace("b","z").replace("a","w")}colorToVector(t){return t.replace(/c/g,"v3")}getIncludes(t,e){return this.includes[t][e||this.shader]}getConstructorFromLength(t){return JI[t-1]}isTypeMatrix(t){return/^m/.test(t)}getTypeLength(t){return t==="f"?1:parseInt(this.colorToVector(t).substr(1))}getTypeFromLength(t){return t===1?"f":"v"+t}findNode(...t){for(let e=0;e<arguments.length;e++){let r=t[e];if(r?.isNode)return r}}resolve(...t){for(let e=0;e<arguments.length;e++){let r=t[e];if(r!==void 0){if(r.isNode)return r;if(r.isTexture)switch(r.mapping){case XI:case QI:return new Gu(r);case KI:return new zu(new ir(r));default:return new ir(r)}else{if(r.isVector2)return new pt(r);if(r.isVector3)return new Yt(r);if(r.isVector4)return new pr(r)}}}}format(t,e,r){switch(this.colorToVector(r+" <- "+e)){case"f <- v2":return t+".x";case"f <- v3":return t+".x";case"f <- v4":return t+".x";case"f <- i":case"f <- b":return"float( "+t+" )";case"v2 <- f":return"vec2( "+t+" )";case"v2 <- v3":return t+".xy";case"v2 <- v4":return t+".xy";case"v2 <- i":case"v2 <- b":return"vec2( float( "+t+" ) )";case"v3 <- f":return"vec3( "+t+" )";case"v3 <- v2":return"vec3( "+t+", 0.0 )";case"v3 <- v4":return t+".xyz";case"v3 <- i":case"v3 <- b":return"vec2( float( "+t+" ) )";case"v4 <- f":return"vec4( "+t+" )";case"v4 <- v2":return"vec4( "+t+", 0.0, 1.0 )";case"v4 <- v3":return"vec4( "+t+", 1.0 )";case"v4 <- i":case"v4 <- b":return"vec4( float( "+t+" ) )";case"i <- f":case"i <- b":return"int( "+t+" )";case"i <- v2":return"int( "+t+".x )";case"i <- v3":return"int( "+t+".x )";case"i <- v4":return"int( "+t+".x )";case"b <- f":return"( "+t+" != 0.0 )";case"b <- v2":return"( "+t+" != vec2( 0.0 ) )";case"b <- v3":return"( "+t+" != vec3( 0.0 ) )";case"b <- v4":return"( "+t+" != vec4( 0.0 ) )";case"b <- i":return"( "+t+" != 0 )"}return t}getTypeByFormat(t){return e3[t]||t}getFormatByType(t){return t3[t]||t}getUUID(t,e){return e=e!==void 0?e:!0,e&&this.cache&&(t=this.cache+"-"+t),t}getElementByIndex(t){return Ob[t]}getIndexByElement(t){return Ob.indexOf(t)}isShader(t){return this.shader===t}setShader(t){return this.shader=t,this}mergeDefines(t){for(let e in t)this.defines[e]=t[e];return this.defines}mergeUniform(t){for(let e in t)this.uniforms[e]=t[e];return this.uniforms}getTextureEncodingFromMap(t){let e;return t?t.isTexture&&(e=t.encoding):e=Pb,e===Pb&&this.context.gamma&&(e=ZI),e}};import{Vector2 as to,Vector3 as _o,Vector4 as fs}from"three";var $e=class extends Xe{constructor(e=0,r,o,i){super("c");this.nodeType="Color";this.value=e instanceof Bt?e:new Bt(e||0,r,o,i)}setRGBA(e){this.value.setRGBA(e.r,e.g,e.b,e.a)}generate(e,r,o,i,a,s){o=e.getUUID(o??this.getUUID()),i=i??this.getType(e);let l=e.getNodeData(o),u=this.getReadonly()&&this.generateReadonly!==void 0;if(this.alpha){let c=this.alpha.build(e,"f");e.addFragmentNodeCode(`accumAlpha += ( 1.0 - accumAlpha ) * ${c};`)}return u?this.generateReadonly(e,r,o,i,a,s):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(i,this,a,s,this.getLabel())),e.format(l.vertex.name,i,r)):(l.fragment||(l.fragment=e.createFragmentUniform(i,this,a,s,this.getLabel())),e.format(l.fragment.name,i,r))}generateReadonly(e,r,o,i,a,s){return e.format("vec3("+this.value.r+", "+this.value.g+", "+this.value.b+")",i,r)}};var Be=class extends Xe{constructor(e){super("i");this.nodeType="Int";this.value=Math.floor(e??0)}generateReadonly(e,r,o,i,a,s){return e.format(this.value.toString(),i,r)}};import{UniformsLib as a3,UniformsUtils as s3}from"three";var xt=class extends Xe{constructor(e){super("b");this.nodeType="Bool";this.value=e??!1}generateReadonly(e,r,o,i){return e.format(this.value?"true":"false",i,r)}};var Zr=class extends Xe{constructor(e=1,r){super("f[]");this.nodeType="FloatArray";this.size=e,this.value=Array.isArray(r)?r:typeof r=="number"?new Array(e).fill(r):new Array(e).fill(0)}};import{Vector3 as r3}from"three";var In=class extends Xe{};var Fu=class extends In{constructor(e){super("v3");this.image=e;this._value=new r3}get value(){return this._value.x=this.image.isVideo?this.image.img.videoWidth??0:this.image.img.width,this._value.y=this.image.isVideo?this.image.img.videoHeight??0:this.image.img.height,this._value}};var di=class extends In{constructor(e,r,o=1008){super("t");this.image=e;this.wrap=r;this.minFilter=o}get value(){return this.image.getTexture(this.wrap,this.minFilter)}};import{Matrix3 as o3}from"three";var Ka=class extends Xe{constructor(e){super("m3");this.nodeType="Matrix3";this.value=e??new o3}generateReadonly(e,r,o,i,a,s){return e.format("mat3("+this.value.elements.join(", ")+")",i,r)}get elements(){return this.value.elements}set elements(e){this.value.fromArray(e)}};import{Matrix4 as n3}from"three";var Xt=class extends Xe{constructor(e){super("m4");this.nodeType="Matrix4";this.value=e??new n3}generateReadonly(e,r,o,i,a,s){return e.format("mat4("+this.value.elements.join(", ")+")",i,r)}get elements(){return this.value.elements}set elements(e){this.value.fromArray(e)}};import{Matrix3 as i3}from"three";function Cb(n,t,e){n.setUvTransform(e[0],e[1],t[0],t[1],0,0,0)}var ku=class extends Ka{constructor(e,r){super(new i3);this.repeat=e;this.offset=r;Cb(this.value,e,r)}updateMatrix(){Cb(this.value,this.repeat,this.offset)}};import{Vector4 as Tb}from"three";var Jr=class extends Xe{constructor(e=1,r){super("v4[]");this.nodeType="Vector4Array";this.size=e,this.value=Array.isArray(r)?r:r instanceof Tb?new Array(e).fill(r):new Array(e).fill(new Tb(0))}};var Za=class extends ye{constructor(e,r,o,i){super("v3");this.nodeType="Blend";this.a=e,this.b=r,this.alpha=o,this.mode=i}generate(e,r){if(e.isShader("fragment")){let o=[];return o.push(this.a.build(e,"c")),o.push(this.b.build(e,"c")),o.push(this.alpha.build(e,"f")),o.push(this.mode.build(e,"i")),e.format("spe_blend("+o.join(",")+")",this.getType(e),r)}else return console.warn("BlendNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}};var Vf=class extends ye{constructor(e,r){super("v3");this.nodeType="CustomColor";this.color=e,this.alpha=r,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.isShader("fragment")){let o=e.include(Vf.Nodes.customColor);e.addFragmentVariable(this.calpha,"float");let i=[];return i.push(this.color.build(e,"v3")),i.push(this.mask?`luminance(${this.mask.build(e,"v3")})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(o+"("+i.join(",")+")",this.getType(e),r)}else return console.warn("CustomColorNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},pi=Vf;pi.Nodes=function(){return{customColor:new re(`vec3 customColor(vec3 color, float mask, float alpha, out float calpha) {
255
+ `}return r}getVars(t){return this.inputs.vars[t??this.shader]}getNodeData(t){let e=t instanceof Ft?t.uuid:t;return this.nodeData[e]=this.nodeData[e]||{}}createUniform(t,e,r,o,i,a){if(e.includes("[]")){let s=this.inputs.arrayUniforms,l=s.list.length,u=new yl({type:e,size:r.size,name:o||"nodeUA"+l+(a?"_"+a:""),node:r,needsUpdate:i});return s.list.push(u),s[t].push(u),s[t][u.name]=u,this.uniforms[u.name]=u,u}else{let s=this.inputs.uniforms,l=s.list.length,u=new yl({type:e,name:o||"nodeU"+l+(a?"_"+a:""),node:r,needsUpdate:i});return s.list.push(u),s[t].push(u),s[t][u.name]=u,this.uniforms[u.name]=u,u}}createVertexUniform(t,e,r,o,i){return this.createUniform("vertex",t,e,r,o,i)}createFragmentUniform(t,e,r,o,i){return this.createUniform("fragment",t,e,r,o,i)}include(t,e,r){let o;if(t=typeof t=="string"?Et.get(t):t,this.context.include===!1)return t.name;t instanceof re?o=this.includes.functions:t instanceof Ue?o=this.includes.consts:t instanceof $a&&(o=this.includes.structs);let i=o[this.shader]=o[this.shader]||[];if(t){let a=i[t.name];if(a||(a=i[t.name]={node:t,deps:[]},i.push(a),a.src=t.build(this,"source")),t instanceof re&&e&&i[e.name]&&i[e.name].deps.indexOf(t)===-1&&(i[e.name].deps.push(t),t.includes?.length)){let s=0;do this.include(t.includes[s++],e);while(s<t.includes.length)}return r&&(a.src=r),t.name}else throw new Error("Include not found.")}colorToVectorProperties(t){return t.replace("r","x").replace("g","y").replace("b","z").replace("a","w")}colorToVector(t){return t.replace(/c/g,"v3")}getIncludes(t,e){return this.includes[t][e||this.shader]}getConstructorFromLength(t){return o3[t-1]}isTypeMatrix(t){return/^m/.test(t)}getTypeLength(t){return t==="f"?1:parseInt(this.colorToVector(t).substr(1))}getTypeFromLength(t){return t===1?"f":"v"+t}findNode(...t){for(let e=0;e<arguments.length;e++){let r=t[e];if(r?.isNode)return r}}resolve(...t){for(let e=0;e<arguments.length;e++){let r=t[e];if(r!==void 0){if(r.isNode)return r;if(r.isTexture)switch(r.mapping){case JI:case e3:return new Gu(r);case t3:return new zu(new ir(r));default:return new ir(r)}else{if(r.isVector2)return new pt(r);if(r.isVector3)return new Yt(r);if(r.isVector4)return new pr(r)}}}}format(t,e,r){switch(this.colorToVector(r+" <- "+e)){case"f <- v2":return t+".x";case"f <- v3":return t+".x";case"f <- v4":return t+".x";case"f <- i":case"f <- b":return"float( "+t+" )";case"v2 <- f":return"vec2( "+t+" )";case"v2 <- v3":return t+".xy";case"v2 <- v4":return t+".xy";case"v2 <- i":case"v2 <- b":return"vec2( float( "+t+" ) )";case"v3 <- f":return"vec3( "+t+" )";case"v3 <- v2":return"vec3( "+t+", 0.0 )";case"v3 <- v4":return t+".xyz";case"v3 <- i":case"v3 <- b":return"vec2( float( "+t+" ) )";case"v4 <- f":return"vec4( "+t+" )";case"v4 <- v2":return"vec4( "+t+", 0.0, 1.0 )";case"v4 <- v3":return"vec4( "+t+", 1.0 )";case"v4 <- i":case"v4 <- b":return"vec4( float( "+t+" ) )";case"i <- f":case"i <- b":return"int( "+t+" )";case"i <- v2":return"int( "+t+".x )";case"i <- v3":return"int( "+t+".x )";case"i <- v4":return"int( "+t+".x )";case"b <- f":return"( "+t+" != 0.0 )";case"b <- v2":return"( "+t+" != vec2( 0.0 ) )";case"b <- v3":return"( "+t+" != vec3( 0.0 ) )";case"b <- v4":return"( "+t+" != vec4( 0.0 ) )";case"b <- i":return"( "+t+" != 0 )"}return t}getTypeByFormat(t){return n3[t]||t}getFormatByType(t){return i3[t]||t}getUUID(t,e){return e=e!==void 0?e:!0,e&&this.cache&&(t=this.cache+"-"+t),t}getElementByIndex(t){return Cb[t]}getIndexByElement(t){return Cb.indexOf(t)}isShader(t){return this.shader===t}setShader(t){return this.shader=t,this}mergeDefines(t){for(let e in t)this.defines[e]=t[e];return this.defines}mergeUniform(t){for(let e in t)this.uniforms[e]=t[e];return this.uniforms}getTextureEncodingFromMap(t){let e;return t?t.isTexture&&(e=t.encoding):e=Ob,e===Ob&&this.context.gamma&&(e=r3),e}};import{Vector2 as to,Vector3 as _o,Vector4 as hs}from"three";var $e=class extends Xe{constructor(e=0,r,o,i){super("c");this.nodeType="Color";this.value=e instanceof Bt?e:new Bt(e||0,r,o,i)}setRGBA(e){this.value.setRGBA(e.r,e.g,e.b,e.a)}generate(e,r,o,i,a,s){o=e.getUUID(o??this.getUUID()),i=i??this.getType(e);let l=e.getNodeData(o),u=this.getReadonly()&&this.generateReadonly!==void 0;if(this.alpha){let c=this.alpha.build(e,"f");e.addFragmentNodeCode(`accumAlpha += ( 1.0 - accumAlpha ) * ${c};`)}return u?this.generateReadonly(e,r,o,i,a,s):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(i,this,a,s,this.getLabel())),e.format(l.vertex.name,i,r)):(l.fragment||(l.fragment=e.createFragmentUniform(i,this,a,s,this.getLabel())),e.format(l.fragment.name,i,r))}generateReadonly(e,r,o,i,a,s){return e.format("vec3("+this.value.r+", "+this.value.g+", "+this.value.b+")",i,r)}};var Be=class extends Xe{constructor(e){super("i");this.nodeType="Int";this.value=Math.floor(e??0)}generateReadonly(e,r,o,i,a,s){return e.format(this.value.toString(),i,r)}};import{UniformsLib as u3,UniformsUtils as d3}from"three";var xt=class extends Xe{constructor(e){super("b");this.nodeType="Bool";this.value=e??!1}generateReadonly(e,r,o,i){return e.format(this.value?"true":"false",i,r)}};var Zr=class extends Xe{constructor(e=1,r){super("f[]");this.nodeType="FloatArray";this.size=e,this.value=Array.isArray(r)?r:typeof r=="number"?new Array(e).fill(r):new Array(e).fill(0)}};import{Vector3 as a3}from"three";var In=class extends Xe{};var Fu=class extends In{constructor(e){super("v3");this.image=e;this._value=new a3}get value(){return this._value.x=this.image.isVideo?this.image.img.videoWidth??0:this.image.img.width,this._value.y=this.image.isVideo?this.image.img.videoHeight??0:this.image.img.height,this._value}};var di=class extends In{constructor(e,r,o=1008){super("t");this.image=e;this.wrap=r;this.minFilter=o}get value(){return this.image.getTexture(this.wrap,this.minFilter)}};import{Matrix3 as s3}from"three";var Za=class extends Xe{constructor(e){super("m3");this.nodeType="Matrix3";this.value=e??new s3}generateReadonly(e,r,o,i,a,s){return e.format("mat3("+this.value.elements.join(", ")+")",i,r)}get elements(){return this.value.elements}set elements(e){this.value.fromArray(e)}};import{Matrix4 as l3}from"three";var Xt=class extends Xe{constructor(e){super("m4");this.nodeType="Matrix4";this.value=e??new l3}generateReadonly(e,r,o,i,a,s){return e.format("mat4("+this.value.elements.join(", ")+")",i,r)}get elements(){return this.value.elements}set elements(e){this.value.fromArray(e)}};import{Matrix3 as c3}from"three";function Tb(n,t,e){n.setUvTransform(e[0],e[1],t[0],t[1],0,0,0)}var ku=class extends Za{constructor(e,r){super(new c3);this.repeat=e;this.offset=r;Tb(this.value,e,r)}updateMatrix(){Tb(this.value,this.repeat,this.offset)}};import{Vector4 as Mb}from"three";var Jr=class extends Xe{constructor(e=1,r){super("v4[]");this.nodeType="Vector4Array";this.size=e,this.value=Array.isArray(r)?r:r instanceof Mb?new Array(e).fill(r):new Array(e).fill(new Mb(0))}};var Ja=class extends ye{constructor(e,r,o,i){super("v3");this.nodeType="Blend";this.a=e,this.b=r,this.alpha=o,this.mode=i}generate(e,r){if(e.isShader("fragment")){let o=[];return o.push(this.a.build(e,"c")),o.push(this.b.build(e,"c")),o.push(this.alpha.build(e,"f")),o.push(this.mode.build(e,"i")),e.format("spe_blend("+o.join(",")+")",this.getType(e),r)}else return console.warn("BlendNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}};var zf=class extends ye{constructor(e,r){super("v3");this.nodeType="CustomColor";this.color=e,this.alpha=r,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.isShader("fragment")){let o=e.include(zf.Nodes.customColor);e.addFragmentVariable(this.calpha,"float");let i=[];return i.push(this.color.build(e,"v3")),i.push(this.mask?`luminance(${this.mask.build(e,"v3")})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(o+"("+i.join(",")+")",this.getType(e),r)}else return console.warn("CustomColorNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},pi=zf;pi.Nodes=function(){return{customColor:new re(`vec3 customColor(vec3 color, float mask, float alpha, out float calpha) {
256
256
  float lalpha = alpha * mask;
257
257
  calpha = lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0);
258
258
  accumAlpha += (1.0 - accumAlpha) * lalpha;
259
259
 
260
260
  return color;
261
- }`)}}();var zf=class extends ye{constructor(e,r){super("v3");this.nodeType="CustomNormal";this.cnormal=e,this.alpha=r,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.isShader("fragment")){let o=e.include(zf.Nodes.customNormal);e.addFragmentVariable(this.calpha,"float");let i=[];return i.push(this.cnormal.build(e,"v3")),i.push("normal"),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(o+"("+i.join(",")+")",this.getType(e),r)}else return console.warn("CustomNormalNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},Ja=zf;Ja.Nodes=function(){return{customNormal:new re(`vec3 customNormal(vec3 cnormal, vec3 norm, float mask, float alpha, out float calpha) {
261
+ }`)}}();var Gf=class extends ye{constructor(e,r){super("v3");this.nodeType="CustomNormal";this.cnormal=e,this.alpha=r,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.isShader("fragment")){let o=e.include(Gf.Nodes.customNormal);e.addFragmentVariable(this.calpha,"float");let i=[];return i.push(this.cnormal.build(e,"v3")),i.push("normal"),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(o+"("+i.join(",")+")",this.getType(e),r)}else return console.warn("CustomNormalNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},es=Gf;es.Nodes=function(){return{customNormal:new re(`vec3 customNormal(vec3 cnormal, vec3 norm, float mask, float alpha, out float calpha) {
262
262
  vec3 normal = packNormalToRGB( norm ).rgb;
263
263
  normal *= step( vec3(0.5), cnormal );
264
264
 
@@ -267,7 +267,7 @@ layout(location = 1) out vec4 gVelocity;
267
267
  accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
268
268
 
269
269
  return normal;
270
- }`)}}();var es=class extends ye{constructor(e,r,o,i,a,s,l,u,c,d,p,f){super("v3");this.nodeType="CustomTexture";this.texture=e,this.textureSize=r,this.crop=o,this.projection=i,this.axis=a,this.side=s,this.size=l,this.blending=u,this.mat=c,this.isMask=f,this.alpha=d,this.mode=p,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){e.require("position"),e.require("normal"),e.require("uv"),e.requires.uv=[!0],e.extensions.shaderTextureLOD=!0,e.extensions.derivatives=!0;let o=`g${this.uuid.toString().replace(/-/g,"")}`,i;switch(this.projection.value){case 3:i=e.include(es.Nodes.cylindrical);break;case 2:i=e.include(es.Nodes.spherical);break;case 1:let s=["vec3(1.0, 0.0, 0.0)","vec3(0.0, 1.0, 0.0)","vec3(0.0, 0.0, 1.0)"][this.axis.value],l=["zy","xz","xy"][this.axis.value],u=new re(`
270
+ }`)}}();var ts=class extends ye{constructor(e,r,o,i,a,s,l,u,c,d,p,f){super("v3");this.nodeType="CustomTexture";this.texture=e,this.textureSize=r,this.crop=o,this.projection=i,this.axis=a,this.side=s,this.size=l,this.blending=u,this.mat=c,this.isMask=f,this.alpha=d,this.mode=p,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){e.require("position"),e.require("normal"),e.require("uv"),e.requires.uv=[!0],e.extensions.shaderTextureLOD=!0,e.extensions.derivatives=!0;let o=`g${this.uuid.toString().replace(/-/g,"")}`,i;switch(this.projection.value){case 3:i=e.include(ts.Nodes.cylindrical);break;case 2:i=e.include(ts.Nodes.spherical);break;case 1:let s=["vec3(1.0, 0.0, 0.0)","vec3(0.0, 1.0, 0.0)","vec3(0.0, 0.0, 1.0)"][this.axis.value],l=["zy","xz","xy"][this.axis.value],u=new re(`
271
271
  vec3 ${o}_planarTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUv) {
272
272
  vec2 projected = (1. + (position.${l})) / 2.;
273
273
  vec2 uvs = ( mat * vec3( (projected * 2. - 1.) / (size * .5), 1. ) / 2. + 0.5 ).xy;
@@ -291,7 +291,7 @@ layout(location = 1) out vec4 gVelocity;
291
291
  accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
292
292
 
293
293
  return col;
294
- }`);i=e.include(u);break;case 4:i=e.include(es.Nodes.triplanar);break;default:i=e.include(es.Nodes.uv);break}e.addFragmentVariable(this.calpha,"float");let a=[];if(a.push("normal"),a.push(this.texture.generate(e,"t")),a.push(this.textureSize.build(e,"v2")),a.push(this.crop.build(e,"f")),a.push(this.mat.build(e,"mat3")),a.push(this.size.build(e,"v2")),a.push(this.blending.build(e,"f")),a.push(this.isMask.build(e,"b")),a.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),a.push(this.alpha.build(e,"f")),a.push(this.mode.build(e,"i")),a.push(this.calpha),this.projection.value===4){let s=`${o}_writeUvs`,l=s+"0",u=s+"1",c=s+"2",d=`${o}_triplanarWeights`;e.addFragmentVariable(l,"vec2"),e.addFragmentVariable(u,"vec2"),e.addFragmentVariable(c,"vec2"),e.addFragmentVariable(d,"vec3"),a.push(l),a.push(u),a.push(c),a.push(d)}else{let s=`${o}_writeUvs`;e.addFragmentVariable(s,"vec2"),a.push(s)}return e.format(i+"("+a.join(",")+")",this.getType(e),r)}},Nn=es;Nn.Nodes=function(){let e=new re(`
294
+ }`);i=e.include(u);break;case 4:i=e.include(ts.Nodes.triplanar);break;default:i=e.include(ts.Nodes.uv);break}e.addFragmentVariable(this.calpha,"float");let a=[];if(a.push("normal"),a.push(this.texture.generate(e,"t")),a.push(this.textureSize.build(e,"v2")),a.push(this.crop.build(e,"f")),a.push(this.mat.build(e,"mat3")),a.push(this.size.build(e,"v2")),a.push(this.blending.build(e,"f")),a.push(this.isMask.build(e,"b")),a.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),a.push(this.alpha.build(e,"f")),a.push(this.mode.build(e,"i")),a.push(this.calpha),this.projection.value===4){let s=`${o}_writeUvs`,l=s+"0",u=s+"1",c=s+"2",d=`${o}_triplanarWeights`;e.addFragmentVariable(l,"vec2"),e.addFragmentVariable(u,"vec2"),e.addFragmentVariable(c,"vec2"),e.addFragmentVariable(d,"vec3"),a.push(l),a.push(u),a.push(c),a.push(d)}else{let s=`${o}_writeUvs`;e.addFragmentVariable(s,"vec2"),a.push(s)}return e.format(i+"("+a.join(",")+")",this.getType(e),r)}},Nn=ts;Nn.Nodes=function(){let e=new re(`
295
295
  vec3 cylindricalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUv) {
296
296
  vec3 posN = normalize(position);
297
297
  float u = 0.5 + atan(posN.z, posN.x) / (2.*3.1415);
@@ -446,7 +446,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
446
446
 
447
447
  return col;//n * 0.5 + 0.5;
448
448
  }
449
- `);return{cylindrical:e,spherical:r,uv:o,triplanar:i}}();var ts=class extends ye{constructor(e,r,o,i,a,s,l,u,c,d,p,f){super("v3");this.nodeType="Depth";this.gradientType=e,this.smooth=r,this.near=o,this.far=i,this.isVector=a,this.isWorldSpace=s,this.origin=l,this.direction=u,this.colors=c,this.steps=d,this.isMask=f,this.alpha=p,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){let o=`g${this.uuid.toString().replace(/-/g,"")}`,i=new re(`vec3 ${o}_sdepth(float near, float far, vec3 origin, vec3 direction, vec4 colors[${o}_MAX_COLORS], float steps[${o}_MAX_COLORS], bool isMask, float mask, float alpha, out float calpha) {
449
+ `);return{cylindrical:e,spherical:r,uv:o,triplanar:i}}();var rs=class extends ye{constructor(e,r,o,i,a,s,l,u,c,d,p,f){super("v3");this.nodeType="Depth";this.gradientType=e,this.smooth=r,this.near=o,this.far=i,this.isVector=a,this.isWorldSpace=s,this.origin=l,this.direction=u,this.colors=c,this.steps=d,this.isMask=f,this.alpha=p,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){let o=`g${this.uuid.toString().replace(/-/g,"")}`,i=new re(`vec3 ${o}_sdepth(float near, float far, vec3 origin, vec3 direction, vec4 colors[${o}_MAX_COLORS], float steps[${o}_MAX_COLORS], bool isMask, float mask, float alpha, out float calpha) {
450
450
  vec4 color = colors[0];
451
451
  #ifdef ${o}_IS_VECTOR
452
452
  #ifdef ${o}_LINEAR
@@ -486,7 +486,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
486
486
  accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
487
487
 
488
488
  return color.rgb;
489
- }`,[ts.Nodes.vectorLinearWorldSpaceDepth,ts.Nodes.vectorLinearObjectSpaceDepth,ts.Nodes.vectorSphericalObjectSpaceDepth,ts.Nodes.vectorSphericalWorldSpaceDepth]);if(e.isShader("fragment")){e.define(`${o}_MAX_COLORS`,this.colors.value.length),this.smooth.value&&e.define(`${o}_SMOOTH`),this.isVector.value>.5&&e.define(`${o}_IS_VECTOR`),this.gradientType.value===0&&e.define(`${o}_LINEAR`),this.isWorldSpace.value>.5&&e.define(`${o}_WORLDSPACE`),e.require("worldPosition"),e.addFragmentVariable(this.calpha,"float");let a=e.include(i),s=[];return s.push(this.near.build(e,"f")),s.push(this.far.build(e,"f")),s.push(this.origin.build(e,"v3")),s.push(this.direction.build(e,"v3")),s.push(this.colors.build(e,"v4[]")),s.push(this.steps.build(e,"f[]")),s.push(this.isMask.build(e,"b")),s.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),s.push(this.alpha.build(e,"f")),s.push(this.calpha),e.format(a+"("+s.join(",")+")",this.getType(e),r)}else return console.warn("DepthNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},rs=ts;rs.Nodes=function(){let e=new re(`float vectorLinearWorldSpaceDepth(vec3 direction, vec3 origin, float near, float far) {
489
+ }`,[rs.Nodes.vectorLinearWorldSpaceDepth,rs.Nodes.vectorLinearObjectSpaceDepth,rs.Nodes.vectorSphericalObjectSpaceDepth,rs.Nodes.vectorSphericalWorldSpaceDepth]);if(e.isShader("fragment")){e.define(`${o}_MAX_COLORS`,this.colors.value.length),this.smooth.value&&e.define(`${o}_SMOOTH`),this.isVector.value>.5&&e.define(`${o}_IS_VECTOR`),this.gradientType.value===0&&e.define(`${o}_LINEAR`),this.isWorldSpace.value>.5&&e.define(`${o}_WORLDSPACE`),e.require("worldPosition"),e.addFragmentVariable(this.calpha,"float");let a=e.include(i),s=[];return s.push(this.near.build(e,"f")),s.push(this.far.build(e,"f")),s.push(this.origin.build(e,"v3")),s.push(this.direction.build(e,"v3")),s.push(this.colors.build(e,"v4[]")),s.push(this.steps.build(e,"f[]")),s.push(this.isMask.build(e,"b")),s.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),s.push(this.alpha.build(e,"f")),s.push(this.calpha),e.format(a+"("+s.join(",")+")",this.getType(e),r)}else return console.warn("DepthNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},os=rs;os.Nodes=function(){let e=new re(`float vectorLinearWorldSpaceDepth(vec3 direction, vec3 origin, float near, float far) {
490
490
  vec3 n = normalize(direction);
491
491
  float dist = (n.x*(vWPosition.x - origin.x) + n.y*(vWPosition.y - origin.y) + n.z*(vWPosition.z - origin.z));
492
492
  return ( dist - near ) / ( far - near );
@@ -508,7 +508,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
508
508
  accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
509
509
 
510
510
  return color;
511
- }`),i=e.include(o),a=[];return a.push(this.color.build(e,"c")),a.push(this.bias.build(e,"f")),a.push(this.scale.build(e,"f")),a.push(this.intensity.build(e,"f")),a.push(this.factor.build(e,"f")),a.push(this.isMask.build(e,"b")),a.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),a.push(this.alpha.build(e,"f")),a.push(this.mode.build(e,"i")),a.push(this.calpha),e.format(i+"("+a.join(",")+")",this.getType(e),r)}else return console.warn("FresnelNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}};var Gf=class extends ye{constructor(e,r,o,i,a,s,l,u,c){super("v3");this.nodeType="Gradient";this.gradientType=e,this.smooth=r,this.colors=o,this.steps=i,this.offset=a,this.morph=s,this.angle=l,this.isMask=c,this.alpha=u,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.isShader("fragment")){e.define("GRAD_MAX",10),e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let o=e.include(Gf.Nodes.gradient),i=[];return i.push(this.gradientType.build(e,"i")),i.push(this.smooth.build(e,"b")),i.push(this.colors.build(e,"v4[]")),i.push(this.steps.build(e,"f[]")),i.push(this.offset.build(e,"v2")),i.push(this.morph.build(e,"v2")),i.push(this.angle.build(e,"f")),i.push(this.isMask.build(e,"b")),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(o+"("+i.join(",")+")",this.getType(e),r)}else return console.warn("GradientNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},os=Gf;os.Nodes=function(){return{gradient:new re(`vec3 gradient(int gradientType, bool smoothed, vec4 colors[GRAD_MAX], float steps[GRAD_MAX], vec2 offset, vec2 morph, float angle, bool isMask, float mask, float alpha, out float calpha) {
511
+ }`),i=e.include(o),a=[];return a.push(this.color.build(e,"c")),a.push(this.bias.build(e,"f")),a.push(this.scale.build(e,"f")),a.push(this.intensity.build(e,"f")),a.push(this.factor.build(e,"f")),a.push(this.isMask.build(e,"b")),a.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),a.push(this.alpha.build(e,"f")),a.push(this.mode.build(e,"i")),a.push(this.calpha),e.format(i+"("+a.join(",")+")",this.getType(e),r)}else return console.warn("FresnelNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}};var Ff=class extends ye{constructor(e,r,o,i,a,s,l,u,c){super("v3");this.nodeType="Gradient";this.gradientType=e,this.smooth=r,this.colors=o,this.steps=i,this.offset=a,this.morph=s,this.angle=l,this.isMask=c,this.alpha=u,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.isShader("fragment")){e.define("GRAD_MAX",10),e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let o=e.include(Ff.Nodes.gradient),i=[];return i.push(this.gradientType.build(e,"i")),i.push(this.smooth.build(e,"b")),i.push(this.colors.build(e,"v4[]")),i.push(this.steps.build(e,"f[]")),i.push(this.offset.build(e,"v2")),i.push(this.morph.build(e,"v2")),i.push(this.angle.build(e,"f")),i.push(this.isMask.build(e,"b")),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(o+"("+i.join(",")+")",this.getType(e),r)}else return console.warn("GradientNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},ns=Ff;ns.Nodes=function(){return{gradient:new re(`vec3 gradient(int gradientType, bool smoothed, vec4 colors[GRAD_MAX], float steps[GRAD_MAX], vec2 offset, vec2 morph, float angle, bool isMask, float mask, float alpha, out float calpha) {
512
512
  vec4 color = colors[0];
513
513
  vec2 m = morph / vUv.xy;
514
514
  vec2 rot = vec2( 0.5 + m.x, m.y );
@@ -550,7 +550,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
550
550
  accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
551
551
 
552
552
  return color.xyz;
553
- }`)}}();var Ff=class extends ye{constructor(e,r,o,i){super("v3");this.nodeType="Matcap";this.texture=e,this.isMask=i,this.alpha=r,this.mode=o,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.isShader("fragment")){e.addFragmentVariable(this.calpha,"float");let o=e.include(Ff.Nodes.matcap);e.require("normal"),e.requires.normal=!0;let i=[];return i.push(this.texture.generate(e,"t")),i.push("normal"),i.push(this.isMask.build(e,"b")),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.mode.build(e,"i")),i.push(this.calpha),e.format(o+"("+i.join(",")+")",this.getType(e),r)}else return console.warn("MatcapNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},ns=Ff;ns.Nodes=function(){return{matcap:new re(`vec3 matcap(sampler2D matcapTex, vec3 normal, bool isMask, float mask, float alpha, int mode, out float calpha) {
553
+ }`)}}();var kf=class extends ye{constructor(e,r,o,i){super("v3");this.nodeType="Matcap";this.texture=e,this.isMask=i,this.alpha=r,this.mode=o,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.isShader("fragment")){e.addFragmentVariable(this.calpha,"float");let o=e.include(kf.Nodes.matcap);e.require("normal"),e.requires.normal=!0;let i=[];return i.push(this.texture.generate(e,"t")),i.push("normal"),i.push(this.isMask.build(e,"b")),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.mode.build(e,"i")),i.push(this.calpha),e.format(o+"("+i.join(",")+")",this.getType(e),r)}else return console.warn("MatcapNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},is=kf;is.Nodes=function(){return{matcap:new re(`vec3 matcap(sampler2D matcapTex, vec3 normal, bool isMask, float mask, float alpha, int mode, out float calpha) {
554
554
  vec3 viewDir = normalize( vViewPosition );
555
555
  vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
556
556
  vec3 y = cross( viewDir, x );
@@ -915,7 +915,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
915
915
  return hashwithoutsine13(vec3(p + mb) + seed);
916
916
  }
917
917
  }
918
- `,[f,h,m,y,g,b]);return{simplex:e,simplexFractal:r,simplexAshima:a,fbm:c,perlin:p,voronoi:w}}();var is=class extends ye{constructor(e,r,o,i,a,s,l,u,c,d,p,f,h,m,y,g,b,w,_){super("v3");this.nodeType="Noise";this.scale=e,this.size=r,this.move=o,this.fA=i,this.fB=a,this.distortion=s,this.colorA=l,this.colorB=u,this.colorC=c,this.colorD=d,this.noiseType=f,this.voronoiStyle=m,this.highCut=y,this.lowCut=g,this.smoothness=b,this.seed=w,this.quality=_,this.isMask=h,this.alpha=p,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r,o,i,a){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let s=Object.values(bl)[this.noiseType.value],l=s=="voronoi"?`
918
+ `,[f,h,m,y,g,b]);return{simplex:e,simplexFractal:r,simplexAshima:a,fbm:c,perlin:p,voronoi:w}}();var as=class extends ye{constructor(e,r,o,i,a,s,l,u,c,d,p,f,h,m,y,g,b,w,A){super("v3");this.nodeType="Noise";this.scale=e,this.size=r,this.move=o,this.fA=i,this.fB=a,this.distortion=s,this.colorA=l,this.colorB=u,this.colorC=c,this.colorD=d,this.noiseType=f,this.voronoiStyle=m,this.highCut=y,this.lowCut=g,this.smoothness=b,this.seed=w,this.quality=A,this.isMask=h,this.alpha=p,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r,o,i,a){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let s=Object.values(bl)[this.noiseType.value],l=s=="voronoi"?`
919
919
  float v = ${s}(st + move, voronoiStyle, smoothness, seed, quality);
920
920
 
921
921
  // Apply clipping to colors
@@ -952,7 +952,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
952
952
  accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
953
953
 
954
954
  return clamp(color, 0.0, 1.0).rgb;
955
- }`,[Ut.simplex,Ut.simplexFractal,Ut.simplexAshima,Ut.fbm,Ut.perlin,Ut.voronoi]),c=e.include(u),d=[];return d.push(this.scale.build(e,"f")),d.push(this.size.build(e,"v3")),d.push(this.move.build(e,"f")),d.push(this.fA.build(e,"v2")),d.push(this.fB.build(e,"v2")),d.push(this.distortion.build(e,"v2")),d.push(this.colorA.build(e,"v4")),d.push(this.colorB.build(e,"v4")),d.push(this.colorC.build(e,"v4")),d.push(this.colorD.build(e,"v4")),d.push(this.voronoiStyle.build(e,"i")),d.push(this.highCut.build(e,"f")),d.push(this.lowCut.build(e,"f")),d.push(this.smoothness.build(e,"f")),d.push(this.seed.build(e,"f")),d.push(this.quality.build(e,"i")),d.push(this.isMask.build(e,"b")),d.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),d.push(this.alpha.build(e,"f")),d.push(this.calpha),e.format(c+"("+d.join(",")+")",this.getType(e),r)}};is.numOctaves=5;var kf=class extends ye{constructor(e,r,o,i,a,s,l,u,c,d,p,f,h,m,y,g){super("v3");this.nodeType="Outline";this.firstTime=!0,this.outlineColor=e,this.contourColor=r,this.outlineWidth=o,this.contourWidth=i,this.contourThreshold=a,this.outlineThreshold=s,this.contourFrequency=l,this.outlineSmoothing=u,this.contourDirection=c,this.positionalLines=d,this.compensation=p,this.resolution=f,this.normalMap=h,this.depthMap=m,this.pixelRatio=y,this.alpha=g,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){let o=`g${this.uuid.toString().replace(/-/g,"")}`;if(e.require("vWorldViewDir"),e.require("worldNormal"),e.extensions.derivatives=!0,this.compensation.value&&e.define("OUTLINE_COMPENSATION",`${o}_offset`),this.firstTime){let i=this.outlineWidth.build(e,"f"),a=this.resolution.build(e,"v2"),s=this.compensation.build(e,"b"),l=this.pixelRatio.build(e,"f");e.addVertexParsVariable("randomColor","attribute vec3"),e.addVertexParsVariable("extrudeNormal","attribute vec3"),e.addVertexParsVariable(i,"uniform float"),e.addVertexParsVariable(a,"uniform vec2"),e.addVertexParsVariable(s,"uniform bool"),e.addVertexParsVariable(l,"uniform float"),e.addVertexParsVariable("vID","flat out float"),e.addFragmentParsVariable("vID","flat in float"),e.addVertexFinalCode(`
955
+ }`,[Ut.simplex,Ut.simplexFractal,Ut.simplexAshima,Ut.fbm,Ut.perlin,Ut.voronoi]),c=e.include(u),d=[];return d.push(this.scale.build(e,"f")),d.push(this.size.build(e,"v3")),d.push(this.move.build(e,"f")),d.push(this.fA.build(e,"v2")),d.push(this.fB.build(e,"v2")),d.push(this.distortion.build(e,"v2")),d.push(this.colorA.build(e,"v4")),d.push(this.colorB.build(e,"v4")),d.push(this.colorC.build(e,"v4")),d.push(this.colorD.build(e,"v4")),d.push(this.voronoiStyle.build(e,"i")),d.push(this.highCut.build(e,"f")),d.push(this.lowCut.build(e,"f")),d.push(this.smoothness.build(e,"f")),d.push(this.seed.build(e,"f")),d.push(this.quality.build(e,"i")),d.push(this.isMask.build(e,"b")),d.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),d.push(this.alpha.build(e,"f")),d.push(this.calpha),e.format(c+"("+d.join(",")+")",this.getType(e),r)}};as.numOctaves=5;var jf=class extends ye{constructor(e,r,o,i,a,s,l,u,c,d,p,f,h,m,y,g){super("v3");this.nodeType="Outline";this.firstTime=!0,this.outlineColor=e,this.contourColor=r,this.outlineWidth=o,this.contourWidth=i,this.contourThreshold=a,this.outlineThreshold=s,this.contourFrequency=l,this.outlineSmoothing=u,this.contourDirection=c,this.positionalLines=d,this.compensation=p,this.resolution=f,this.normalMap=h,this.depthMap=m,this.pixelRatio=y,this.alpha=g,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){let o=`g${this.uuid.toString().replace(/-/g,"")}`;if(e.require("vWorldViewDir"),e.require("worldNormal"),e.extensions.derivatives=!0,this.compensation.value&&e.define("OUTLINE_COMPENSATION",`${o}_offset`),this.firstTime){let i=this.outlineWidth.build(e,"f"),a=this.resolution.build(e,"v2"),s=this.compensation.build(e,"b"),l=this.pixelRatio.build(e,"f");e.addVertexParsVariable("randomColor","attribute vec3"),e.addVertexParsVariable("extrudeNormal","attribute vec3"),e.addVertexParsVariable(i,"uniform float"),e.addVertexParsVariable(a,"uniform vec2"),e.addVertexParsVariable(s,"uniform bool"),e.addVertexParsVariable(l,"uniform float"),e.addVertexParsVariable("vID","flat out float"),e.addFragmentParsVariable("vID","flat in float"),e.addVertexFinalCode(`
956
956
  vID = randomColor.r;
957
957
  vec2 ${o}_offset = vec2(0.0);
958
958
  if (${s}) {
@@ -967,7 +967,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
967
967
  // if this offset is the biggest of all the potential offsets
968
968
  gl_Position = ${o}_clipPosition;
969
969
  }
970
- `)}if(e.isShader("fragment")){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let i=e.include(kf.Nodes.outline),a=[];return a.push(this.outlineColor.build(e,"c")),a.push(this.contourColor.build(e,"c")),a.push(this.outlineWidth.build(e,"f")),a.push(this.contourWidth.build(e,"f")),a.push(this.contourThreshold.build(e,"f")),a.push(this.outlineThreshold.build(e,"f")),a.push(this.contourFrequency.build(e,"f")),a.push(this.outlineSmoothing.build(e,"f")),a.push(this.contourDirection.build(e,"v3")),a.push(this.positionalLines.build(e,"b")),a.push(this.resolution.build(e,"v2")),a.push(this.normalMap.getTexture(e,"t")),a.push(this.depthMap.getTexture(e,"t")),a.push(this.pixelRatio.build(e,"f")),a.push(this.compensation.build(e,"b")),a.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),a.push(this.alpha.build(e,"f")),a.push(this.calpha),this.firstTime=!this.firstTime,e.format(i+"("+a.join(",")+")",this.getType(e),r)}else return console.warn("OutlineNode is not compatible with "+e.shader+" shader."),""}},as=kf;as.Nodes=function(){let e=new re(`
970
+ `)}if(e.isShader("fragment")){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let i=e.include(jf.Nodes.outline),a=[];return a.push(this.outlineColor.build(e,"c")),a.push(this.contourColor.build(e,"c")),a.push(this.outlineWidth.build(e,"f")),a.push(this.contourWidth.build(e,"f")),a.push(this.contourThreshold.build(e,"f")),a.push(this.outlineThreshold.build(e,"f")),a.push(this.contourFrequency.build(e,"f")),a.push(this.outlineSmoothing.build(e,"f")),a.push(this.contourDirection.build(e,"v3")),a.push(this.positionalLines.build(e,"b")),a.push(this.resolution.build(e,"v2")),a.push(this.normalMap.getTexture(e,"t")),a.push(this.depthMap.getTexture(e,"t")),a.push(this.pixelRatio.build(e,"f")),a.push(this.compensation.build(e,"b")),a.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),a.push(this.alpha.build(e,"f")),a.push(this.calpha),this.firstTime=!this.firstTime,e.format(i+"("+a.join(",")+")",this.getType(e),r)}else return console.warn("OutlineNode is not compatible with "+e.shader+" shader."),""}},ss=jf;ss.Nodes=function(){let e=new re(`
971
971
  float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outlineWidth, float pixelRatio)
972
972
  {
973
973
  vec2 halton = haltonSequence[frameIndex];
@@ -1202,7 +1202,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1202
1202
  accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
1203
1203
 
1204
1204
  return clamp(color, 0.0, 1.0).rgb;
1205
- }`,[s,a,wo.DrawFunctions.circle,wo.DrawFunctions.ring,wo.DrawFunctions.polygon,wo.DrawFunctions.cross,wo.DrawFunctions.diamond,wo.DrawFunctions.checkerboard,wo.DrawFunctions.line,wo.DrawFunctions.wave]),c=e.include(u),d=[];return d.push("normal"),d.push(this.blending.build(e,"f")),d.push(this.style.build(e,"i")),d.push(this.offset.build(e,"v2")),d.push(this.colorA.build(e,"v4")),d.push(this.colorB.build(e,"v4")),d.push(this.frequency.build(e,"v2")),d.push(this.size.build(e,"f")),d.push(this.variation.build(e,"f")),d.push(this.smoothness.build(e,"f")),d.push(this.zigzag.build(e,"f")),d.push(this.rotation.build(e,"f")),d.push(this.vertical.build(e,"v2")),d.push(this.horizontal.build(e,"v2")),d.push(this.sides.build(e,"i")),d.push(this.isMask.build(e,"b")),d.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),d.push(this.alpha.build(e,"f")),d.push(this.calpha),e.format(c+"("+d.join(",")+")",this.getType(e),r)}else return console.warn("PatterNode is not compatible with "+e.shader+" shader."),e.format("vec3(0.0)",this.getType(e),r)}},ss=wo;ss.DrawFunctions=function(){let e=new re(`float hashwithoutsine12(vec2 p) {
1205
+ }`,[s,a,wo.DrawFunctions.circle,wo.DrawFunctions.ring,wo.DrawFunctions.polygon,wo.DrawFunctions.cross,wo.DrawFunctions.diamond,wo.DrawFunctions.checkerboard,wo.DrawFunctions.line,wo.DrawFunctions.wave]),c=e.include(u),d=[];return d.push("normal"),d.push(this.blending.build(e,"f")),d.push(this.style.build(e,"i")),d.push(this.offset.build(e,"v2")),d.push(this.colorA.build(e,"v4")),d.push(this.colorB.build(e,"v4")),d.push(this.frequency.build(e,"v2")),d.push(this.size.build(e,"f")),d.push(this.variation.build(e,"f")),d.push(this.smoothness.build(e,"f")),d.push(this.zigzag.build(e,"f")),d.push(this.rotation.build(e,"f")),d.push(this.vertical.build(e,"v2")),d.push(this.horizontal.build(e,"v2")),d.push(this.sides.build(e,"i")),d.push(this.isMask.build(e,"b")),d.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),d.push(this.alpha.build(e,"f")),d.push(this.calpha),e.format(c+"("+d.join(",")+")",this.getType(e),r)}else return console.warn("PatterNode is not compatible with "+e.shader+" shader."),e.format("vec3(0.0)",this.getType(e),r)}},ls=wo;ls.DrawFunctions=function(){let e=new re(`float hashwithoutsine12(vec2 p) {
1206
1206
  vec3 p3 = fract(vec3(p.xyx) * 0.1031);
1207
1207
  p3 += dot(p3, p3.yzx + 33.33);
1208
1208
  return fract((p3.x + p3.y) * p3.z);
@@ -1367,7 +1367,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1367
1367
  float s = mix(size, size * rand, variation);
1368
1368
 
1369
1369
  return smoothstep(-smoothness, smoothness, distance_estimate - s * 0.5);
1370
- }`);return{tileAndCenter:r,circle:o,ring:i,polygon:a,cross:s,diamond:l,checkerboard:u,line:c,wave:d}}();var jf=class extends ye{constructor(e,r,o,i,a,s,l,u){super("v3");this.nodeType="Rainbow";this.filmThickness=e,this.movement=r,this.wavelengths=o,this.noiseStrength=i,this.noiseScale=a,this.offset=s,this.isMask=u,this.alpha=l,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.require("vWorldViewDir"),e.require("worldNormal"),e.isShader("fragment")){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let o=e.include(jf.Nodes.rainbow),i=[];return i.push(this.filmThickness.build(e,"f")),i.push(this.movement.build(e,"f")),i.push(this.wavelengths.build(e,"v3")),i.push(this.noiseStrength.build(e,"f")),i.push(this.noiseScale.build(e,"f")),i.push(this.offset.build(e,"v3")),i.push(this.isMask.build(e,"b")),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(o+"("+i.join(",")+")",this.getType(e),r)}else return console.warn("RainbowNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},ls=jf;ls.Nodes=function(){let e=new re(`vec3 attenuation(vec3 wavelengths, float filmThickness, float movement, float noiseStrength, float noiseScale, vec3 offset) {
1370
+ }`);return{tileAndCenter:r,circle:o,ring:i,polygon:a,cross:s,diamond:l,checkerboard:u,line:c,wave:d}}();var Uf=class extends ye{constructor(e,r,o,i,a,s,l,u){super("v3");this.nodeType="Rainbow";this.filmThickness=e,this.movement=r,this.wavelengths=o,this.noiseStrength=i,this.noiseScale=a,this.offset=s,this.isMask=u,this.alpha=l,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.require("vWorldViewDir"),e.require("worldNormal"),e.isShader("fragment")){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let o=e.include(Uf.Nodes.rainbow),i=[];return i.push(this.filmThickness.build(e,"f")),i.push(this.movement.build(e,"f")),i.push(this.wavelengths.build(e,"v3")),i.push(this.noiseStrength.build(e,"f")),i.push(this.noiseScale.build(e,"f")),i.push(this.offset.build(e,"v3")),i.push(this.isMask.build(e,"b")),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(o+"("+i.join(",")+")",this.getType(e),r)}else return console.warn("RainbowNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},cs=Uf;cs.Nodes=function(){let e=new re(`vec3 attenuation(vec3 wavelengths, float filmThickness, float movement, float noiseStrength, float noiseScale, vec3 offset) {
1371
1371
  vec3 st = position / noiseScale;
1372
1372
  vec3 q = vec3(simplex3d(st),
1373
1373
  simplex3d(st + vec3(1.0)),
@@ -1390,7 +1390,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1390
1390
  accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
1391
1391
 
1392
1392
  return res;
1393
- }`,[e])}}();var Uf=class extends ye{constructor(e,r,o,i,a,s,l,u,c,d){super("v3");this.nodeType="Toon";this.positioning=e,this.colors=r,this.steps=o,this.source=i,this.isWorldSpace=a,this.noiseStrength=s,this.noiseScale=l,this.shadowColor=u,this.offset=c,this.alpha=d,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.require("worldNormal"),e.require("worldPosition"),e.isShader("fragment")){e.define("COLORS_MAX",10),e.addFragmentVariable(this.calpha,"float");let o=e.include(Uf.Nodes.toon),i=[];return i.push(this.positioning.build(e,"i")),i.push(this.colors.build(e,"v4[]")),i.push(this.steps.build(e,"f[]")),i.push(this.source.build(e,"v3")),i.push(this.isWorldSpace.build(e,"b")),i.push(this.noiseStrength.build(e,"f")),i.push(this.noiseScale.build(e,"f")),i.push(this.shadowColor.build(e,"v4")),i.push(this.offset.build(e,"v3")),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(o+"("+i.join(",")+")",this.getType(e),r)}else return console.warn("ToonNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},cs=Uf;cs.Nodes=function(){let e=new re(`float rand(float n) {
1393
+ }`,[e])}}();var Hf=class extends ye{constructor(e,r,o,i,a,s,l,u,c,d){super("v3");this.nodeType="Toon";this.positioning=e,this.colors=r,this.steps=o,this.source=i,this.isWorldSpace=a,this.noiseStrength=s,this.noiseScale=l,this.shadowColor=u,this.offset=c,this.alpha=d,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.require("worldNormal"),e.require("worldPosition"),e.isShader("fragment")){e.define("COLORS_MAX",10),e.addFragmentVariable(this.calpha,"float");let o=e.include(Hf.Nodes.toon),i=[];return i.push(this.positioning.build(e,"i")),i.push(this.colors.build(e,"v4[]")),i.push(this.steps.build(e,"f[]")),i.push(this.source.build(e,"v3")),i.push(this.isWorldSpace.build(e,"b")),i.push(this.noiseStrength.build(e,"f")),i.push(this.noiseScale.build(e,"f")),i.push(this.shadowColor.build(e,"v4")),i.push(this.offset.build(e,"v3")),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(o+"("+i.join(",")+")",this.getType(e),r)}else return console.warn("ToonNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},us=Hf;us.Nodes=function(){let e=new re(`float rand(float n) {
1394
1394
  return fract(sin(n) * 43758.5453123);
1395
1395
  }`),r=new re(`float hash1(float p) {
1396
1396
  p = fract(p * 0.011);
@@ -1626,7 +1626,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1626
1626
 
1627
1627
  return color.xyz;
1628
1628
 
1629
- }`,[Ut.simplex,e,o,a])}}();import{Vector2 as Ib}from"three";var Mb=function(){return{textureBicubic:new re(`float w0( float a ) {
1629
+ }`,[Ut.simplex,e,o,a])}}();import{Vector2 as Nb}from"three";var Ib=function(){return{textureBicubic:new re(`float w0( float a ) {
1630
1630
  return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
1631
1631
  }
1632
1632
 
@@ -1690,7 +1690,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1690
1690
  vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
1691
1691
  vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
1692
1692
  return mix( fSample, cSample, fract( lod ) );
1693
- }`)}}();function Nb(n,t){return n>=t?new Ib(t/n,1):new Ib(1,n/t)}var Hf=class extends ye{constructor(e,r,o,i,a,s,l,u){super("v3");this.nodeType="Transmission";this.thickness=e,this.ior=r,this.roughness=o,this.transmissionSamplerSize=i,this.transmissionSamplerMap=a,this.transmissionDepthMap=s,this.aspectRatio=l,this.alpha=u,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.extensions.shaderTextureLOD=!0,e.extensions.derivatives=!0,e.isShader("fragment")){e.define("NUM_SAMPLES",6),e.define("BLUR_SLOD",Math.pow(2,Te.transmissionLod.value)),e.require("worldPosition"),e.requires.worldNormal=!0,e.requires.modelMatrix=!0,e.requires.projectionMatrix=!0,e.addFragmentVariable(this.calpha,"float");let o=e.include(Hf.Nodes.transmission),i=[];return i.push(this.thickness.build(e,"f")),i.push(this.ior.build(e,"f")),i.push(this.roughness.build(e,"f")),i.push(this.transmissionSamplerSize.build(e,"v2")),i.push(this.transmissionSamplerMap.getTexture(e,"t")),i.push(this.transmissionDepthMap.getTexture(e,"t")),i.push(this.aspectRatio.build(e,"v2")),i.push("normal"),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(o+"("+i.join(",")+")",this.getType(e),r)}else return console.warn("TransmissionNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},us=Hf;us.Nodes=function(){let e=new re(`vec3 blur(sampler2D sp, vec2 U, vec2 scale, float lod, sampler2D dm, vec2 unrefractedU, vec2 aspectRatio) {
1693
+ }`)}}();function Db(n,t){return n>=t?new Nb(t/n,1):new Nb(1,n/t)}var qf=class extends ye{constructor(e,r,o,i,a,s,l,u){super("v3");this.nodeType="Transmission";this.thickness=e,this.ior=r,this.roughness=o,this.transmissionSamplerSize=i,this.transmissionSamplerMap=a,this.transmissionDepthMap=s,this.aspectRatio=l,this.alpha=u,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.extensions.shaderTextureLOD=!0,e.extensions.derivatives=!0,e.isShader("fragment")){e.define("NUM_SAMPLES",6),e.define("BLUR_SLOD",Math.pow(2,Te.transmissionLod.value)),e.require("worldPosition"),e.requires.worldNormal=!0,e.requires.modelMatrix=!0,e.requires.projectionMatrix=!0,e.addFragmentVariable(this.calpha,"float");let o=e.include(qf.Nodes.transmission),i=[];return i.push(this.thickness.build(e,"f")),i.push(this.ior.build(e,"f")),i.push(this.roughness.build(e,"f")),i.push(this.transmissionSamplerSize.build(e,"v2")),i.push(this.transmissionSamplerMap.getTexture(e,"t")),i.push(this.transmissionDepthMap.getTexture(e,"t")),i.push(this.aspectRatio.build(e,"v2")),i.push("normal"),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(o+"("+i.join(",")+")",this.getType(e),r)}else return console.warn("TransmissionNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},ds=qf;ds.Nodes=function(){let e=new re(`vec3 blur(sampler2D sp, vec2 U, vec2 scale, float lod, sampler2D dm, vec2 unrefractedU, vec2 aspectRatio) {
1694
1694
  // Slightly modified version of this:
1695
1695
  // https://www.shadertoy.com/view/ltScRG
1696
1696
 
@@ -1750,7 +1750,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1750
1750
  float lod = applyIorToRoughness(roughness, ior);
1751
1751
  return blur(transmissionSamplerMap, fragCoord, vec2(lod), min(framebufferLod / 5.5, 8.5), transmissionDepthMap, unrefractedCoords, aspectRatio);
1752
1752
  #endif
1753
- }`,[Mb.textureBicubic,o,e]),a=new re(`vec3 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat4 modelMatrix, mat4 viewMatrix, mat4 projMatrix, float ior, float thickness, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 aspectRatio ) {
1753
+ }`,[Ib.textureBicubic,o,e]),a=new re(`vec3 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat4 modelMatrix, mat4 viewMatrix, mat4 projMatrix, float ior, float thickness, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 aspectRatio ) {
1754
1754
  vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
1755
1755
  vec3 refractedRayExit = position + transmissionRay;
1756
1756
 
@@ -1781,7 +1781,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1781
1781
  accumAlpha += ( 1.0 - accumAlpha ) * alpha;
1782
1782
 
1783
1783
  return transmission;
1784
- }`,[a])}}();var qf=(e=>(e.NOISE="noise",e.MAP="map",e))(qf||{}),Wf=class extends ye{constructor(e,r,o,i,a,s,l,u,c,d,p){super("v3");this.displacementTypeIndex=new Be(0);this.nodeType="VertexDisplacement";this.intensity=e,this.movementOrTexture=r,Object.values(qf)[this.displacementTypeIndex.value]==="map"&&(this.mat=new Ka(this.movementOrTexture.value.matrix)),this.cropOrOffset=o,this.scale=d,this.noiseFunctionIndex=p,this.voronoiStyle=i,this.smoothness=a,this.seed=s,this.highCut=l,this.lowCut=u,this.quality=c}generate(e,r){if(e.isShader("vertex")){e.define("USE_LAYER_DISPLACE");let o,i=[];switch(i.push("displaced_position"),i.push("displaced_normal"),Object.values(qf)[this.displacementTypeIndex.value]){case"map":{o=e.include(Wf.Nodes.map),i.push(this.movementOrTexture.getTexture(e,"t")),i.push("uv"),i.push(this.cropOrOffset.build(e,"f")),this.mat&&i.push(this.mat.build(e,"mat3"));break}case"noise":{let s=Object.values(bl)[this.noiseFunctionIndex.value],l=new re(`vec3 orthogonal(vec3 v) {
1784
+ }`,[a])}}();var Wf=(e=>(e.NOISE="noise",e.MAP="map",e))(Wf||{}),$f=class extends ye{constructor(e,r,o,i,a,s,l,u,c,d,p){super("v3");this.displacementTypeIndex=new Be(0);this.nodeType="VertexDisplacement";this.intensity=e,this.movementOrTexture=r,Object.values(Wf)[this.displacementTypeIndex.value]==="map"&&(this.mat=new Za(this.movementOrTexture.value.matrix)),this.cropOrOffset=o,this.scale=d,this.noiseFunctionIndex=p,this.voronoiStyle=i,this.smoothness=a,this.seed=s,this.highCut=l,this.lowCut=u,this.quality=c}generate(e,r){if(e.isShader("vertex")){e.define("USE_LAYER_DISPLACE");let o,i=[];switch(i.push("displaced_position"),i.push("displaced_normal"),Object.values(Wf)[this.displacementTypeIndex.value]){case"map":{o=e.include($f.Nodes.map),i.push(this.movementOrTexture.getTexture(e,"t")),i.push("uv"),i.push(this.cropOrOffset.build(e,"f")),this.mat&&i.push(this.mat.build(e,"mat3"));break}case"noise":{let s=Object.values(bl)[this.noiseFunctionIndex.value],l=new re(`vec3 orthogonal(vec3 v) {
1785
1785
  return normalize(abs(v.x) > abs(v.z) ? vec3(-v.y, v.x, 0.0) : vec3(0.0, -v.z, v.y));
1786
1786
  }`),u=s=="voronoi"?`
1787
1787
  float v = ${s}((p + offset) * scale * 0.001 + neighbour_offset + (movement * 0.1), voronoiStyle, smoothness, seed, quality);
@@ -1810,7 +1810,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1810
1810
  vec3 distorted2 = distorted(nearby2, normal, scale, intensity, offset, neighbor_offset, movement, voronoiStyle, smoothness, seed, highCut, lowCut, quality);
1811
1811
  displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));
1812
1812
  return displaced_position;
1813
- }`,[c,l]);o=e.include(d),i.push(this.scale.build(e,"f")),i.push(this.cropOrOffset.build(e,"v3")),i.push(this.movementOrTexture.build(e,"f")),i.push(this.voronoiStyle.build(e,"i")),i.push(this.smoothness.build(e,"f")),i.push(this.seed.build(e,"f")),i.push(this.highCut.build(e,"f")),i.push(this.lowCut.build(e,"f")),i.push(this.quality.build(e,"i"));break}}return i.push(this.intensity.build(e,"f")),i.push("displaced_normal"),e.format(o+"("+i.join(",")+")",this.getType(e),r)}else return console.warn("VertexDisplacementNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},ds=Wf;ds.Nodes=function(){let e=new re(`vec3 orthogonal(vec3 v) {
1813
+ }`,[c,l]);o=e.include(d),i.push(this.scale.build(e,"f")),i.push(this.cropOrOffset.build(e,"v3")),i.push(this.movementOrTexture.build(e,"f")),i.push(this.voronoiStyle.build(e,"i")),i.push(this.smoothness.build(e,"f")),i.push(this.seed.build(e,"f")),i.push(this.highCut.build(e,"f")),i.push(this.lowCut.build(e,"f")),i.push(this.quality.build(e,"i"));break}}return i.push(this.intensity.build(e,"f")),i.push("displaced_normal"),e.format(o+"("+i.join(",")+")",this.getType(e),r)}else return console.warn("VertexDisplacementNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},ps=$f;ps.Nodes=function(){let e=new re(`vec3 orthogonal(vec3 v) {
1814
1814
  return normalize(abs(v.x) > abs(v.z) ? vec3(-v.y, v.x, 0.0) : vec3(0.0, -v.z, v.y));
1815
1815
  }`),r=new re(`float displacementMapTexture(sampler2D tex, float crop, vec2 uv, mat3 mat, vec2 offset) {
1816
1816
  vec2 uvs = (mat * vec3(uv * 2.0 - 1.0, 1.0) / 2.0 + 0.5).xy + offset;
@@ -1832,7 +1832,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1832
1832
  vec3 distorted2 = nearby2 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity;
1833
1833
  displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));
1834
1834
  return displaced_position;
1835
- }`,[e,r])}}();var Te={normalRenderTarget:new ir,normalRenderTargetDepth:new ir,transmissionRenderTarget:new ir,aspectRatio:new pt,transmissionSize:new pt(2048,2048),transmissionRenderTargetDepth:new ir,aoRenderTarget:new ir,aoEnabled:new xt,pixelRatioNode:new se(1),resolution:new pt,penumbraSize:new Zr(5,.5),frameIndex:new Be(0),transmissionLod:new Be(2)};for(let n of Object.values(Te))n.isRenderGlobal=!0;var Db={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.0.40/build/ui.wasm"};var Ko=class extends Ft{constructor(){super("basic");this.nodeType="Basic";this.color=new $e(St),this.shadingAlpha=new se(1),this.shadingBlend=new Be(0),this.previousModelViewMatrix=new Xt,this.previouseProjectionMatrix=new Xt}get category(){return"phong"}generate(e){let r;if(e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Te.frameIndex}),e.mergeUniform({resolution:Te.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(s3.merge([a3.fog])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>"].join(`
1835
+ }`,[e,r])}}();var Te={normalRenderTarget:new ir,normalRenderTargetDepth:new ir,transmissionRenderTarget:new ir,aspectRatio:new pt,transmissionSize:new pt(2048,2048),transmissionRenderTargetDepth:new ir,aoRenderTarget:new ir,aoEnabled:new xt,pixelRatioNode:new se(1),resolution:new pt,penumbraSize:new Zr(5,.5),frameIndex:new Be(0),transmissionLod:new Be(2)};for(let n of Object.values(Te))n.isRenderGlobal=!0;var Eb={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.0.41/build/ui.wasm"};var Ko=class extends Ft{constructor(){super("basic");this.nodeType="Basic";this.color=new $e(St),this.shadingAlpha=new se(1),this.shadingBlend=new Be(0),this.previousModelViewMatrix=new Xt,this.previouseProjectionMatrix=new Xt}get category(){return"phong"}generate(e){let r;if(e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Te.frameIndex}),e.mergeUniform({resolution:Te.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(d3.merge([u3.fog])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>"].join(`
1836
1836
  `));let i=["#include <beginnormal_vertex>",`
1837
1837
  #if !defined( USE_LAYER_DISPLACE )
1838
1838
  #include <defaultnormal_vertex>
@@ -1852,7 +1852,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1852
1852
  `];o&&i.push(o.code,o.result?"displaced_position = "+o.result+";":""),i.push("transformed = displaced_position;","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),i.push("#include <project_vertex>","#include <fog_vertex>","#include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;","#include <worldpos_vertex>"),i.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),r=i.join(`
1853
1853
  `)}else{this.color===void 0&&(this.color=new $e(St)),this.color.analyze(e,{slot:"color"}),this.alpha&&this.alpha.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"});let o=this.color.flow(e,"c",{slot:"color"}),i=this.alpha?this.alpha.flow(e,"f"):void 0,a=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0,s=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0;e.requires.transparent=i!==void 0,e.addParsCode(["varying vec3 vWPosition;","#include <fog_pars_fragment>","#include <dithering_pars_fragment>","varying vec3 vViewPosition;","#include <normal_pars_fragment>"].join(`
1854
1854
  `));let l=["#include <normal_fragment_begin>",o.code];i&&l.push(i.code,"#ifdef ALPHATEST"," if ( "+i.result+" <= ALPHATEST ) discard;","#endif"),s?l.push(s.code,`vec3 outgoingLight = ${o.result};`,`vec3 finalColor = spe_blend(outgoingLight, ${s.result}, 1.0, SPE_BLENDING_NORMAL);`):l.push(`vec3 finalColor = ${o.result};`);let u="1.0";this.mask&&(this.mask.analyze(e),u=`luminance(${this.mask.flow(e,"v3").result})`),i?l.push(`gl_FragColor = vec4( finalColor, accumAlpha * ${i.result} * ${u} );`):l.push("gl_FragColor = vec4("+o.result+", 1.0 );"),a&&l.push(`gl_FragColor.a *= ${a.result};`),l.push("#include <fog_fragment>","#include <dithering_fragment>"),r=l.join(`
1855
- `)}return r}};import{UniformsLib as Eb,UniformsUtils as l3}from"three";var vl=class extends Ft{constructor(){super("lambert");this.nodeType="Lambert";this.color=new $e(St),this.emissive=new $e(0),this.emissiveIntensity=new se(1),this.previousModelViewMatrix=new Xt,this.previouseProjectionMatrix=new Xt,this.shadingAlpha=new se(1),this.shadingBlend=new Be(0),this.occlusion=new xt(!0)}get category(){return"lambert"}build(e){let r;if(e.define("LAMBERT"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Te.frameIndex}),e.mergeUniform({resolution:Te.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(l3.merge([Eb.fog,Eb.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","varying vec3 vLightFront;","varying vec3 vIndirectFront;","#ifndef DOUBLE_SIDED"," #define DOUBLE_SIDED","#endif","#ifdef DOUBLE_SIDED"," varying vec3 vLightBack;"," varying vec3 vIndirectBack;","#endif","#include <bsdfs>","#include <lights_pars_begin>","#include <color_pars_vertex>","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
1855
+ `)}return r}};import{UniformsLib as Bb,UniformsUtils as p3}from"three";var vl=class extends Ft{constructor(){super("lambert");this.nodeType="Lambert";this.color=new $e(St),this.emissive=new $e(0),this.emissiveIntensity=new se(1),this.previousModelViewMatrix=new Xt,this.previouseProjectionMatrix=new Xt,this.shadingAlpha=new se(1),this.shadingBlend=new Be(0),this.occlusion=new xt(!0)}get category(){return"lambert"}build(e){let r;if(e.define("LAMBERT"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Te.frameIndex}),e.mergeUniform({resolution:Te.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(p3.merge([Bb.fog,Bb.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","varying vec3 vLightFront;","varying vec3 vIndirectFront;","#ifndef DOUBLE_SIDED"," #define DOUBLE_SIDED","#endif","#ifdef DOUBLE_SIDED"," varying vec3 vLightBack;"," varying vec3 vIndirectBack;","#endif","#include <bsdfs>","#include <lights_pars_begin>","#include <color_pars_vertex>","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
1856
1856
  `));let i=["#include <beginnormal_vertex>",`
1857
1857
  #ifndef USE_LAYER_DISPLACE
1858
1858
  #include <defaultnormal_vertex>
@@ -1961,7 +1961,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1961
1961
  outgoingLight *= ao;
1962
1962
  }
1963
1963
  `),c&&f.push(c.code,`outgoingLight = spe_blend(outgoingLight, ${c.result}, 1.0, SPE_BLENDING_NORMAL);`),d?f.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${d.result} );`):f.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),p&&f.push(`gl_FragColor.a *= ${p.result};`),f.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),r=f.join(`
1964
- `)}return r}};import{UniformsLib as Bb,UniformsUtils as c3}from"three";var Zo=function(){let n=new re(`vec2 dHdxy(sampler2D bumpMap, vec2 bumpMapUv, float bumpScale) {
1964
+ `)}return r}};import{UniformsLib as Lb,UniformsUtils as f3}from"three";var Zo=function(){let n=new re(`vec2 dHdxy(sampler2D bumpMap, vec2 bumpMapUv, float bumpScale) {
1965
1965
 
1966
1966
  // Gradient of UVs w.r.t. X coordinate (in screen-space)
1967
1967
  vec2 dSTdx = dFdx(bumpMapUv);
@@ -1992,7 +1992,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1992
1992
 
1993
1993
  vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
1994
1994
  return normalize( abs( fDet ) * vN - vGrad );
1995
- }`);return{dHdxy:n,perturbNormalArb:t}}();var Sl=class extends Ft{constructor(){super("phong");this.nodeType="Phong";this.color=new $e(St),this.specular=new $e(1118481),this.shininess=new se(30),this.previousModelViewMatrix=new Xt,this.previouseProjectionMatrix=new Xt,this.shadingAlpha=new se(1),this.shadingBlend=new Be(0),this.occlusion=new xt(!0)}get category(){return"phong"}build(e){let r;if(e.define("PHONG"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Te.frameIndex}),e.mergeUniform({resolution:Te.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(c3.merge([Bb.fog,Bb.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
1995
+ }`);return{dHdxy:n,perturbNormalArb:t}}();var Sl=class extends Ft{constructor(){super("phong");this.nodeType="Phong";this.color=new $e(St),this.specular=new $e(1118481),this.shininess=new se(30),this.previousModelViewMatrix=new Xt,this.previouseProjectionMatrix=new Xt,this.shadingAlpha=new se(1),this.shadingBlend=new Be(0),this.occlusion=new xt(!0)}get category(){return"phong"}build(e){let r;if(e.define("PHONG"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Te.frameIndex}),e.mergeUniform({resolution:Te.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(f3.merge([Lb.fog,Lb.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
1996
1996
  `));let i=["#include <beginnormal_vertex>",`
1997
1997
  #include <skinbase_vertex>
1998
1998
  #include <skinnormal_vertex>
@@ -2060,7 +2060,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
2060
2060
  outgoingLight *= ao;
2061
2061
  }
2062
2062
  `),c&&f.push(c.code,`outgoingLight = spe_blend(outgoingLight, ${c.result}, 1.0, SPE_BLENDING_NORMAL);`),d?f.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${d.result});`):f.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),p&&f.push(`gl_FragColor.a *= ${p.result};`),f.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),r=f.join(`
2063
- `)}return r}};import{UniformsLib as $f,UniformsUtils as u3}from"three";var wl=class extends Ft{constructor(){super("standard");this.nodeType="Standard";this.color=new $e(St),this.roughness=new se(.3),this.metalness=new se(0),this.reflectivity=new se(.5),this.previousModelViewMatrix=new Xt,this.previouseProjectionMatrix=new Xt,this.shadingAlpha=new se(1),this.shadingBlend=new Be(0),this.occlusion=new xt(!0)}get category(){return"physical"}build(e){let r;if(e.define("STANDARD"),e.requires.lights=!0,e.extensions.derivatives=!0,e.extensions.shaderTextureLOD=!0,e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Te.frameIndex}),e.mergeUniform({resolution:Te.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(u3.merge([$f.fog,$f.lights])),$f.LTC_1&&(e.uniforms.ltc_1={value:void 0},e.uniforms.ltc_2={value:void 0}),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
2063
+ `)}return r}};import{UniformsLib as Yf,UniformsUtils as h3}from"three";var wl=class extends Ft{constructor(){super("standard");this.nodeType="Standard";this.color=new $e(St),this.roughness=new se(.3),this.metalness=new se(0),this.reflectivity=new se(.5),this.previousModelViewMatrix=new Xt,this.previouseProjectionMatrix=new Xt,this.shadingAlpha=new se(1),this.shadingBlend=new Be(0),this.occlusion=new xt(!0)}get category(){return"physical"}build(e){let r;if(e.define("STANDARD"),e.requires.lights=!0,e.extensions.derivatives=!0,e.extensions.shaderTextureLOD=!0,e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Te.frameIndex}),e.mergeUniform({resolution:Te.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(h3.merge([Yf.fog,Yf.lights])),Yf.LTC_1&&(e.uniforms.ltc_1={value:void 0},e.uniforms.ltc_2={value:void 0}),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
2064
2064
  `));let i=["#include <beginnormal_vertex>",`
2065
2065
  #if !defined( USE_LAYER_DISPLACE )
2066
2066
  #include <defaultnormal_vertex>
@@ -2087,7 +2087,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
2087
2087
  if (dot(normal, faceNormal) < 0.0) {
2088
2088
  normal *= -1.0;
2089
2089
  }
2090
- `," PhysicalMaterial material;"," material.diffuseColor = vec3( 1.0 );"];if(this.bumpMap){e.include(Zo.dHdxy),e.include(Zo.perturbNormalArb);let g=this.bumpMap.texture.flow(e,"t"),b=this.bumpMap.flow(e,"v3"),w=this.bumpMapIntensity?this.bumpMapIntensity.flow(e,"f").result:"1.0",_="";this.bumpMap.projection.value===4?_=`
2090
+ `," PhysicalMaterial material;"," material.diffuseColor = vec3( 1.0 );"];if(this.bumpMap){e.include(Zo.dHdxy),e.include(Zo.perturbNormalArb);let g=this.bumpMap.texture.flow(e,"t"),b=this.bumpMap.flow(e,"v3"),w=this.bumpMapIntensity?this.bumpMapIntensity.flow(e,"f").result:"1.0",A="";this.bumpMap.projection.value===4?A=`
2091
2091
  vec3 bumpNormal = vec3(0.0);
2092
2092
  {
2093
2093
  vec2 uv0 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs0;
@@ -2109,13 +2109,13 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
2109
2109
  }
2110
2110
 
2111
2111
  normal = bumpNormal;
2112
- `:_=`
2112
+ `:A=`
2113
2113
  vec2 bumpMapCachedUv = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs;
2114
2114
  vec2 grad = dHdxy(${g.result}, bumpMapCachedUv, ${w});
2115
2115
  normal = perturbNormalArb( - vViewPosition, normal, grad, faceDirection );
2116
2116
  `,m.push(`// Call the Texture Layer's function once here so that it writes out its procedural UV coordinates
2117
2117
  ${b.result};
2118
- ${_}
2118
+ ${A}
2119
2119
  `)}if(m.push(a.code," vec3 diffuseColor = "+a.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );",l.code," float metalnessFactor = "+l.result+";"),this.roughnessMap){let g=this.roughnessMap.texture.flow(e,"t"),b=this.roughnessMap.flow(e,"v3"),w="";this.roughnessMap.projection.value===4?w=`
2120
2120
  float roughnessChange = 1.0;
2121
2121
  {
@@ -2151,7 +2151,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
2151
2151
  outgoingLight *= ao;
2152
2152
  }
2153
2153
  `),d&&m.push(d.code,`outgoingLight = spe_blend(outgoingLight, ${d.result}, 1.0, SPE_BLENDING_NORMAL);`),p?m.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${p.result} );`):m.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),f&&m.push(`gl_FragColor.a *= ${f.result};`),m.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),r=m.join(`
2154
- `)}return r}};import{UniformsLib as Lb,UniformsUtils as d3}from"three";var Al=class extends Ft{constructor(){super("toon");this.nodeType="Toon";this.color=new $e(St),this.specular=new $e(1118481),this.shininess=new se(30),this.previousModelViewMatrix=new Xt,this.previouseProjectionMatrix=new Xt,this.shadingAlpha=new se(1),this.shadingBlend=new Be(0)}get category(){return"toon"}build(e){let r;if(e.define("TOON"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Te.frameIndex}),e.mergeUniform({resolution:Te.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(d3.merge([Lb.fog,Lb.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
2154
+ `)}return r}};import{UniformsLib as Rb,UniformsUtils as m3}from"three";var Al=class extends Ft{constructor(){super("toon");this.nodeType="Toon";this.color=new $e(St),this.specular=new $e(1118481),this.shininess=new se(30),this.previousModelViewMatrix=new Xt,this.previouseProjectionMatrix=new Xt,this.shadingAlpha=new se(1),this.shadingBlend=new Be(0)}get category(){return"toon"}build(e){let r;if(e.define("TOON"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Te.frameIndex}),e.mergeUniform({resolution:Te.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(m3.merge([Rb.fog,Rb.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
2155
2155
  `));let i=["#include <beginnormal_vertex>",`
2156
2156
  #ifndef USE_LAYER_DISPLACE
2157
2157
  #include <defaultnormal_vertex>
@@ -2234,11 +2234,11 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
2234
2234
  outgoingLight = spe_blend( diffuseColor, outgoingLight, ${s.result} * ${f}, ${l.result} );
2235
2235
  }
2236
2236
  `),u&&p.push(u.code,`outgoingLight = spe_blend(outgoingLight, ${u.result}, 1.0, SPE_BLENDING_NORMAL);`),c?p.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${c.result} );`):p.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),d&&p.push(`gl_FragColor.a *= ${d.result};`),p.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),r=p.join(`
2237
- `)}return r}};import{VideoTexture as p3,Texture as f3,CanvasTexture as h3}from"three";var ju=class{constructor(t=1e3*10){this.timeout=t;this.cache=new Map;this.head={data:null,time:0,src:null,next:null,prev:null};this.tail={data:null,time:1/0,src:null,next:null,prev:null};this.hasClean=!1;this.head.next=this.tail,this.tail.prev=this.head}log(...t){}remove(t){let e=this.cache.get(t);e&&(this.dispose(t,e.data),this.cache.delete(t),e.prev.next=e.next,e.next.prev=e.prev)}scheduleCleanup(){this.hasClean||(this.log("scheduled cleanup"),this.hasClean=!0,setTimeout(()=>{this.hasClean=!1,this.log("cleaning");let t=Date.now(),e=this.head.next;for(;e.time<t-this.timeout;)this.dispose(e.src,e.data),this.cache.delete(e.src),e=e.next,e.prev=this.head,this.head.next=e;this.head.next!==this.tail?this.scheduleCleanup():this.log("no more cleanup")},this.timeout+1e3))}has(t){return this.cache.get(t)?.data}load(t){let e=Date.now(),r=this.cache.get(t);return r===void 0?(r={data:this.create(t),src:t,time:e,next:null,prev:null},this.cache.set(t,r)):(r.time=e,r.prev.next=r.next,r.next.prev=r.prev),r.prev=this.tail.prev,r.next=this.tail,this.tail.prev.next=r,this.tail.prev=r,this.scheduleCleanup(),r.data}};var Xf=class extends ju{create(t){return URL.createObjectURL(new Blob([t]))}dispose(t,e){URL.revokeObjectURL(e)}},Yf;function Rb(n){return typeof n=="string"?n:(Yf||(Yf=new Xf),Yf.load(n))}var Uu=class{constructor(t,e){this.data=t;this.cache=e;this.refCount=0}deref(){if(this.refCount===0&&!1)throw new Error("ref count -1?");this.refCount-=1,this.refCount===0&&(this.cache.remove(this),this.dispose())}dispose(){if(this.refCount!==0&&!1)throw new Error("ref count is not 0")}},Hu=class{constructor(){this.cache=new Map}remove(t){if(this.cache.delete(t.data)===!1&&!1)throw new Error("ref count remove non-exists")}load(t){let e=this.cache.get(t);return e===void 0&&(e=this.create(t),this.cache.set(t,e)),e.refCount+=1,e}};var ps=class extends Uu{constructor(e,r){super(e,r.imageHolderCache);this.data=e;this.shared=r;this.loaded=!1;this.isVideo=!1;this.isCanvas=!1;this._cache={[1e3]:{},[1001]:{},[1002]:{}};this.isVideo=e.type==="video",this.isCanvas=e.nodeName==="CANVAS",this.updateSrc(this.isCanvas?e:e.data)}async updateSrc(e){if(typeof document>"u")return;this.disposeTextures(),this.loaded=!1;let r=()=>{this.loaded=!0;for(let i of Object.values(this._cache))for(let a of Object.values(i))a&&(a.image=this.img,a.needsUpdate=!0);this.shared.requestRender()};if(this.isCanvas)this.img=e,this.loaded=!0;else if(this.isVideo){if(this.img=document.createElement("video"),this.img.preload="auto",this.img.playsInline=!0,this.img.currentTime=.01,typeof e!="string"){var o=new FileReader;o.readAsDataURL(new Blob([e],{type:"video/mp4"}));let i;await new Promise(a=>{o.onloadend=s=>{i=s.target?.result,a(null)}}),this.img.src=i}else this.img.src=e;this.img.onloadeddata=()=>{r()}}else this.img=new Image,this.img.src=Rb(e),this.img.onload=r}getTexture(e,r=1008){let o=this._cache[e]?.[r];if(o)return o;{let i;return this.isCanvas&&(i=new h3(this.img,void 0,e,e,void 0,r)),this.isVideo?i=new p3(this.img,void 0,e,e):i=new f3(this.img,void 0,e,e,void 0,r),this.loaded&&(i.needsUpdate=!0),this._cache[e]===void 0&&(this._cache[e]={}),this._cache[e][r]=i,i}}setNeedsUpdate(e){for(let r of Object.values(this._cache))for(let o of Object.values(r))o&&(o.needsUpdate=e)}disposeTextures(){for(let[e,r]of Object.entries(this._cache))for(let[o,i]of Object.entries(r))i?.dispose(),this._cache[e][o]=void 0}dispose(){super.dispose(),this.disposeTextures()}};var _r=class extends ps{};import{Vector2 as Jo,Vector3 as Ao,Vector4 as qu}from"three";function Qt(n,t){return t.color(n)}function Vb(n,t){switch(n.type){case"fresnel":return g3(n,t);case"gradient":return x3(n,t);case"depth":return b3(n,t);case"normal":return v3(n,t);case"noise":return S3(n,t);case"rainbow":return w3(n,t);case"toon":return A3(n,t);case"outline":return _3(n,t);case"transmission":return P3(n,t);case"color":return y3(n,t);case"pattern":return O3(n,t)}}function m3(n){return{type:n.type}}function eo(n,t){let{alpha:e,mode:r,isMask:o}=n,i=typeof e=="string"?(Number(t.getVariable(e))??100)/100:e;return{...m3(n),alpha:i,mode:r,isMask:o}}function y3(n,t){return{...eo(n,t),color:Qt(n.color,t)}}function g3(n,t){let{bias:e,scale:r,intensity:o,factor:i,color:a}=n;return{...eo(n,t),color:Qt(a,t),bias:e,scale:r,intensity:o,factor:i}}function x3(n,t){let{gradientType:e,smooth:r,colors:o,steps:i,angle:a,offset:s,morph:l}=n;return{...eo(n,t),gradientType:e,smooth:r,colors:o.map(u=>new qu(u[0],u[1],u[2],u[3])),num:o.length,steps:i,offset:new Jo(...s),morph:new Jo(...l),angle:a}}function b3(n,t){let{gradientType:e,near:r,far:o,isVector:i,isWorldSpace:a,origin:s,direction:l,colors:u,steps:c,smooth:d}=n;return{...eo(n,t),gradientType:e,near:r,far:o,isVector:i,isWorldSpace:a,origin:new Ao(...s),direction:l?new Ao(...l):new Ao(1,0,0),colors:u.map(p=>p!==void 0?new qu(p[0],p[1],p[2],p[3]):new qu(0,0,0,0)),steps:c.slice(0,u.length),smooth:d}}function v3(n,t){let{cnormal:e}=n;return{...eo(n,t),cnormal:new Ao(e[0],e[1],e[2])}}function S3(n,t){return{...eo(n,t),scale:n.scale,move:n.move,fA:new Jo(...n.fA),fB:new Jo(...n.fB),size:new Ao(...n.size),distortion:new Jo(...n.distortion),colorA:Qt(n.colorA,t),colorB:Qt(n.colorB,t),colorC:Qt(n.colorC,t),colorD:Qt(n.colorD,t),noiseType:n.noiseType,voronoiStyle:n.voronoiStyle,highCut:n.highCut,lowCut:n.lowCut,smoothness:n.smoothness,seed:n.seed,quality:n.quality}}function w3(n,t){return{...eo(n,t),filmThickness:n.filmThickness,movement:n.movement,wavelengths:new Ao(...n.wavelengths),noiseStrength:n.noiseStrength,noiseScale:n.noiseScale,offset:new Ao(...n.offset)}}function A3(n,t){return{...eo(n,t),positioning:n.positioning,colors:n.colors.map(e=>new qu(e[0],e[1],e[2],e[3])),num:n.colors.length,steps:n.steps,source:new Ao(...n.source),isWorldSpace:n.isWorldSpace,noiseStrength:n.noiseStrength,noiseScale:n.noiseScale,shadowColor:Qt(n.shadowColor,t),offset:new Ao(...n.offset)}}function _3(n,t){return{...eo(n,t),outlineColor:Qt(n.outlineColor,t),contourColor:Qt(n.contourColor,t),outlineWidth:n.outlineWidth,contourWidth:n.contourWidth,outlineThreshold:n.outlineThreshold,contourThreshold:n.contourThreshold,outlineSmoothing:n.outlineSmoothing,contourFrequency:n.contourFrequency,contourDirection:new Ao(...n.contourDirection),positionalLines:n.positionalLines,compensation:n.compensation}}function P3(n,t){return{...eo(n,t),thickness:n.thickness,ior:n.ior,roughness:n.roughness}}function O3(n,t){return{...eo(n,t),style:n.style,projection:n.projection,axis:n.axis,blending:n.blending,offset:new Jo(...n.offset),colorA:Qt(n.colorA,t),colorB:Qt(n.colorB,t),frequency:new Jo(...n.frequency),size:n.size,variation:n.variation,smoothness:n.smoothness,zigzag:n.zigzag,rotation:n.rotation,vertical:new Jo(...n.vertical),horizontal:new Jo(...n.horizontal),sides:n.sides}}var Dn=class extends Bt{};import{Vector4 as C3}from"three";var Qf={noise:["noiseType"],texture:["projection","axis","side"],video:["projection","axis","side"],displace:["noiseType"],light:["roughnessMap","bumpMap"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"]},Kf={depth:["colors"]};function T3(n,t,e){if(t==="isMask")return!0;let r=Qf[n.type],o=Kf[n.type];if(o!==void 0){let i=n.color;if(o.includes(t)){let a=i[t]?.value?.length;if(a!==void 0&&a!==e.length)return!0}}return r!==void 0?r.includes(t):!1}function Zf(n,t,e){let r=e.uniforms[`f${e.id}_texture`];if(!r)return!1;let o=!1,i=n;if("image"in i){let a=i.image,s=t.image(a),l=r;l.image instanceof _r||l.image.deref(),l.image=s}if("video"in i){let a=i.video,s=t.video(a),l=r;l.image instanceof _r||l.image.deref(),l.image=s}if("wrapping"in i){let a=r;a.wrap=i.wrapping}if("minFilter"in i){let a=r;a.minFilter=i.minFilter}if("repeat"in i||"offset"in i){let a="mat",s=e.uniforms[`f${e.id}_${a}`];"repeat"in i&&(s.repeat=i.repeat),"offset"in i&&(s.offset=i.offset),s.updateMatrix()}return o}function zb(n,t,e,r){let o=!1;for(let[i,a]of Object.entries(n)){if(i==="bumpMap"||i==="roughnessMap"){o=!0;continue}if(!i||a===void 0)continue;if(Jf(i,e,r,t)){i==="visible"&&e.type==="light"&&(o=!0);continue}e.visible=r.visible;let s=e.uniforms[`f${e.id}_${i}`];if(!!s&&!(s instanceof In))switch(o=o||T3(e,i,a),s.constructor){case $e:if(typeof a=="string"){let l=t.getColor(a);l&&(s.value=l);break}else{let l=a;s.value instanceof Dn?s.value=new Bt(l.r,l.g,l.b,l.a):s.setRGBA(l);break}case pr:if(typeof a=="string"){let l=t.getColor(a);l&&(s.value=l);break}else{let l=a;s.value instanceof Dn?s.value=new Bt(l.r,l.g,l.b,l.a):s.value.setRGBA(l.r,l.g,l.b,l.a);break}case pt:{let l=a;s.value.setX(l[0]),s.value.setY(l[1]);break}case Yt:{let l=a;s.value.setX(l[0]),s.value.setY(l[1]),s.value.setZ(l[2]);break}case ir:{Zf(a,t,e);break}case Jr:{s.value=a.map(l=>new C3(...l));break}default:{s.value=a;break}}}return o}var En=(n,t,e)=>Math.max(0,Math.min(1,Number(t.getVariable(typeof n=="number"?n*100:n,e)??100)/100))??1,Po=class{constructor(t,e,r,o,i){this.id=t;this.uuid=e;this.data=r;this.uniforms={};for(let a in o)this.uniforms[`f${this.id}_${a}`]=o[a];for(let a in r)Jf(a,this,r,i)}get type(){return this.data.type}static create(t,e,r,o){if(r.type==="light")return ar.createLigherLayer(t,e,r,o);if(r.type==="texture"||r.type==="video"){let i=r.type==="texture"?o.canvas(r.texture.image)??o.image(r.texture.image):o.video(r.texture.video),a=new di(i,r.texture.wrapping,r.texture.minFilter??1008),s=new Fu(i),l=new ku(r.texture.repeat,r.texture.offset),u=new se(r.crop?1:0),c=new Be(r.projection??0),d=new Be(["x","y","z"].indexOf(r.axis)??0),p=new Be(r.side??0),f=new pt(r.size?new to(r.size[0],r.size[1]):new to(100,100)),h=new se(r.blending??0),m=new se(En(r.alpha,o)),y=new Be(r.mode??0),g=new xt(r.isMask??!1),b=new Nn(a,s,u,c,d,p,f,h,l,m,y,g),w=new qe(b.calpha,"f");return new at(t,e,r,{texture:a,textureSize:s,crop:u,projection:c,axis:d,side:p,size:f,blending:h,mat:l,alpha:m,mode:y,isMask:g},b,y,w,g,o)}else if(r.type==="matcap"){let i=o.image(r.texture.image),a=new di(i,r.texture.wrapping,r.texture.minFilter??1008),s=new se(En(r.alpha,o)),l=new Be(r.mode??0),u=new xt(r.isMask??!1),c=new ns(a,s,l,u),d=new qe(c.calpha,"f");return new at(t,e,r,{texture:a,alpha:s,mode:l,isMask:u},c,l,d,u,o)}else if(r.type==="displace")if(r.displacementType==="noise"){let i=new Yt(new _o(...r.offset)),a=new se(r.scale??10),s=new se(r.intensity??8),l=new se(r.movement??1),u=new Be(r.noiseType??0),c=new Be(r.voronoiStyle??0),d=new se(r.smoothness??.5),p=new se(r.seed??0),f=new se(r.highCut??1),h=new se(r.lowCut??0),m=new Be(r.quality??1),y=new ds(s,l,i,c,d,p,f,h,m,a,u);return new _l(t,e,r,{offset:i,scale:a,intensity:s,movement:l,noiseType:u,voronoiStyle:c,smoothness:d,seed:p,highCut:f,lowCut:h,quality:m},y,o)}else throw new Error;else return N3(t,e,r,o)}updateByOp(t,e,r){let o=t;if(o.path[0]===void 0){if(o.type===0)return"type"in o.props||"category"in o.props||"visible"in o.props?(r.scene.markNeedsUpdateRendererDirty(),!0):zb(o.props,r.shared,this,e)}else if(o.path[0]==="texture")return"texture"in e||"video"in e?Zf(o.props,r.shared,this):!0;return!1}dispose(){if(M3(this)){let t=this.uniforms[`f${this.id}_texture`];if(!t)return!1;let e=t;e.image instanceof _r||e.image.deref()}}hasValueByKey(t){return this.uniforms[t]!==void 0}hasValue(t){return this.hasValueByKey(`f${this.id}_${t}`)}setValue(t,e){let r=`f${this.id}_${t}`;this.hasValueByKey(r)&&e!==void 0&&(this.uniforms[r].value=e)}getNode(t){let e=`f${this.id}_${t}`;if(this.hasValueByKey(e))return this.uniforms[e]}getValue(t){let e=`f${this.id}_${t}`;if(this.hasValueByKey(e))return this.uniforms[e].value}getName(t){let r=/f\d+_(.*)/.exec(t);if(r&&r.length>1)return r[1];console.log(`Layer.getName: error ${t}`)}getNames(){let t=[];for(let e in this.uniforms){let r=this.getName(e);r&&t.push(r)}return t}},at=class extends Po{constructor(e,r,o,i,a,s,l,u,c){super(e,r,o,i,c);this.params=i;this.color=a;this.mode=s;this.alpha=l;this.isMask=u}},_l=class extends Po{constructor(e,r,o,i,a,s){super(e,r,o,i,s);this.position=a}},ar=class extends Po{constructor(e,r,o,i,a,s){super(e,r,o,a,s);this.node=i}static createLigherLayer(e,r,o,i){let a,s=new se(En(o.alpha,i)),l=new Be(o.mode),u=new se(o.bumpMapIntensity),c=new se(En(o.alphaOverride,i)),d;if(!o.visible)a=new Ko,d={};else if(o.category==="lambert"){a=new vl;let p=new $e(i.color(o.emissive)??0),f=new xt(o.occlusion??!0);d={emissive:p,occlusion:f},a.emissive=p,a.occlusion=f}else if(o.category==="toon"){a=new Al;let p=new se(o.shininess??30),f=new $e(i.color(o.specular)??1118481);d={shininess:p,specular:f},a.shininess=p,a.specular=f}else if(o.category==="physical"){a=new wl;let p=new se(o.roughness??.3),f=new se(o.metalness??0),h=new se(o.reflectivity??.5),m=new xt(o.occlusion??!0);d={roughness:p,metalness:f,reflectivity:h,occlusion:m},a.roughness=p,a.metalness=f,a.reflectivity=h,a.occlusion=m}else{a=new Sl;let p=new se(o.shininess??30),f=new $e(o.specular!==void 0?i.color(o.specular)??1118481:1118481),h=new xt(o.occlusion??!0);d={shininess:p,specular:f,occlusion:h},a.shininess=p,a.specular=f,a.occlusion=h}return a.alpha=new se(1),a.shadingAlpha=s,a.shadingBlend=l,a.bumpMapIntensity=u,a.alphaOverride=c,d.alpha=a.shadingAlpha,d.mode=a.shadingBlend,d.bumpMapIntensity=a.bumpMapIntensity,d.alphaOverride=a.alphaOverride,new ar(e,r,o,a,d,i)}get category(){return this.node.category}};function M3(n){let t=n instanceof Po?n.type:n;return t==="texture"||t==="video"||t==="displace_map"||t==="matcap"}function Er(n){return{alpha:new se(n.alpha??1),mode:new Be(n.mode??0),isMask:new xt(n.isMask??!1)}}function I3(n,t,e,r,o){switch(n.type){case"color":{let i=new $e(r.color??St),a=Er(r),s=new pi(i,a.alpha),l=new qe(s.calpha,"f");return new at(t,e,n,{color:i,...a},s,a.mode,l,a.isMask,o)}case"fresnel":{let i=new $e(r.color??16777215),a=new se(r.bias??.1),s=new se(r.scale??1),l=new se(r.intensity??2),u=new se(r.factor??1),c=Er(r),d=new xl(i,a,s,l,u,c.alpha,c.mode,c.isMask),p=new qe(d.calpha,"f");return new at(t,e,n,{color:i,bias:a,scale:s,intensity:l,factor:u,...c},d,c.mode,p,c.isMask,o)}case"rainbow":{let i=new se(r.filmThickness??30),a=new se(r.movement??0),s=new Yt(r.wavelengths??new _o(0,0,0)),l=new se(r.noiseStrength??0),u=new se(r.noiseScale??1),c=new Yt(r.offset??new _o(0,0,0)),d=Er(r),p=new ls(i,a,s,l,u,c,d.alpha,d.isMask),f=new qe(p.calpha,"f");return new at(t,e,n,{filmThickness:i,movement:a,wavelengths:s,noiseStrength:l,noiseScale:u,offset:c,...d},p,d.mode,f,d.isMask,o)}case"transmission":{let i=new se(r.thickness??10),a=new se(r.ior??1.5),s=new se(r.roughness??.5),l=Te.transmissionSize,u=Te.transmissionRenderTarget,c=Te.transmissionRenderTargetDepth,d=window.innerWidth,p=window.innerHeight,f=d>=p?new pt(p/d,1):new pt(1,d/p),h=Er(r),m=new us(i,a,s,l,u,c,f,h.alpha),y=new qe(m.calpha,"f");return new at(t,e,n,{thickness:i,ior:a,roughness:s,aspectRatio:f,...h},m,h.mode,y,h.isMask,o)}case"toon":{let i=new Be(r.positioning??0),a;r.colors?a=new Jr(r.colors.length,r.colors):(a=new Jr(10,new fs(0,0,0,1)),a.value[1]=new fs(1,1,1,1));let s;r.steps?s=new Zr(r.steps.length,r.steps):(s=new Zr(10,1),s.value[0]=0);let l=new Yt(r.source??new _o(0,0,0)),u=new xt(r.isWorldSpace??!0),c=new se(r.noiseStrength??0),d=new se(r.noiseScale??1),p=new pr(r.shadowColor),f=new Yt(r.offset??new _o(0,0,0)),h=Er(r),m=new cs(i,a,s,l,u,c,d,p,f,h.alpha),y=new qe(m.calpha,"f");return new at(t,e,n,{positioning:i,colors:a,steps:s,source:l,isWorldSpace:u,noiseStrength:c,noiseScale:d,shadowColor:p,offset:f,...h},m,h.mode,y,h.isMask,o)}case"outline":{let i=new $e(r.outlineColor??16777215),a=new $e(r.contourColor??16777215),s=new se(r.outlineWidth??.1),l=new se(r.contourWidth??.1),u=new se(r.outlineThreshold??.1),c=new se(r.contourThreshold??.1),d=new se(r.outlineSmoothing??.1),p=new se(r.contourFrequency??.1),f=new Yt(r.contourDirection??new _o(0,1,0)),h=new xt(r.positionalLines??!1),m=new xt(r.compensation??!0),y=Te.normalRenderTarget,g=Te.normalRenderTargetDepth,b=Te.pixelRatioNode,w=Te.resolution,_=Er(r),S=new as(i,a,s,l,u,c,d,p,f,h,m,w,y,g,b,_.alpha),P=new qe(S.calpha,"f");return new at(t,e,n,{outlineColor:i,contourColor:a,outlineWidth:s,contourWidth:l,outlineThreshold:u,contourThreshold:c,outlineSmoothing:d,contourFrequency:p,contourDirection:f,positionalLines:h,compensation:m,..._},S,_.mode,P,_.isMask,o)}case"depth":{let i=new Be(r.gradientType??0),a=new xt(r.smooth??!1),s=new se(r.near??50),l=new se(r.far??200),u=new se(r.isVector??1),c=new se(r.isWorldSpace??0),d=new Yt(r.origin??new _o),p=new Yt(r.direction??new _o),f;r.colors?f=new Jr(r.colors.length,r.colors):(f=new Jr(2,new fs(0,0,0,1)),f.value[1]=new fs(1,1,1,1));let h;r.steps?h=new Zr(r.steps.length,r.steps):(h=new Zr(2,1),h.value[0]=0);let m=Er(r),y=new rs(i,a,s,l,u,c,d,p,f,h,m.alpha,m.isMask),g=new qe(y.calpha,"f");return new at(t,e,n,{gradientType:i,smooth:a,near:s,far:l,isVector:u,isWorldSpace:c,origin:d,direction:p,colors:f,steps:h,...m},y,m.mode,g,m.isMask,o)}case"noise":{let i=new se(r.scale??1),a=new Yt(r.size??new _o(100,100,100)),s=new se(r.move??1),l=new pt(r.fA??new to(1.7,9.2)),u=new pt(r.fB??new to(8.3,2.8)),c=new pt(r.distortion??new to(1,1)),d=new pr(r.colorA),p=new pr(r.colorB),f=new pr(r.colorC),h=new pr(r.colorD),m=new Be(r.noiseType??0),y=new Be(r.voronoiStyle??0),g=new se(r.highCut??1),b=new se(r.lowCut??0),w=new se(r.smoothness??.5),_=new se(r.seed??.5),S=new Be(r.quality??1),P=Er(r),O=new is(i,a,s,l,u,c,d,p,f,h,P.alpha,m,P.isMask,y,g,b,w,_,S),x=new qe(O.calpha,"f");return new at(t,e,n,{scale:i,size:a,move:s,fA:l,fB:u,distortion:c,colorA:d,colorB:p,colorC:f,colorD:h,noiseType:m,...P,voronoiStyle:y,highCut:g,lowCut:b,smoothness:w,seed:_,quality:S},O,P.mode,x,P.isMask,o)}case"normal":{let i=new Yt(r.cnormal??new _o(1,1,1)),a=Er(r),s=new Ja(i,a.alpha),l=new qe(s.calpha,"f");return new at(t,e,n,{cnormal:i,...a},s,a.mode,l,a.isMask,o)}case"gradient":{let i=new Be(r.gradientType??0),a=new xt(r.smooth??!1),s;r.colors?s=new Jr(r.colors.length,r.colors):(s=new Jr(10,new fs(0,0,0,1)),s.value[1]=new fs(1,1,1,1));let l;r.steps?l=new Zr(r.steps.length,r.steps):(l=new Zr(10,1),l.value[0]=0);let u=new pt(r.offset??new to(0,0)),c=new pt(r.morph??new to(0,0)),d=new se(r.angle??0),p=Er(r),f=new os(i,a,s,l,u,c,d,p.alpha,p.isMask),h=new qe(f.calpha,"f");return new at(t,e,n,{gradientType:i,smooth:a,colors:s,steps:l,offset:u,morph:c,angle:d,...p},f,p.mode,h,p.isMask,o)}case"pattern":{let i=new Be(r.style??0),a=new Be(r.projection??0),s=new Be(["x","y","z"].indexOf(r.axis)??0),l=new se(r.blending??0),u=new pt(r.offset??new to(0,0)),c=new pr(r.colorA),d=new pr(r.colorB),p=new pt(r.frequency??new to(10,10)),f=new se(r.size??.5),h=new se(r.variation??0),m=new se(r.smoothness??.5),y=new se(r.zigzag??0),g=new se(r.rotation??0),b=new pt(r.vertical??new to(0,1)),w=new pt(r.horizontal??new to(0,1)),_=new Be(r.sides??6),S=Er(r),P=new ss(i,a,s,l,u,c,d,p,f,h,m,y,g,b,w,_,S.alpha,S.isMask),O=new qe(P.calpha,"f");return new at(t,e,n,{style:i,projection:a,axis:s,blending:l,offset:u,colorA:c,colorB:d,frequency:p,size:f,variation:h,smoothness:m,zigzag:y,rotation:g,vertical:b,horizontal:w,sides:_,...S},P,S.mode,O,S.isMask,o)}default:{let i=new $e(1,0,0,1),a=Er(r),s=new pi(i,a.alpha),l=new qe(s.calpha,"f");return new at(t,e,n,{color:i,...a},s,a.mode,l,a.isMask,o)}}}function N3(n,t,e,r){let o=Vb(e,r);return I3(e,n,t,o,r)}function Jf(n,t,e,r){if(e.type==="displace"&&(n==="intensity"||n==="visible")){let o=t.uniforms[`f${t.id}_intensity`];return o?(o.value=e.intensity*(e.visible?1:0),o):void 0}if(e.type!=="displace"&&(n==="alpha"||n==="visible")){let o=t.uniforms[`f${t.id}_alpha`];if(!o)return;if(o.value=En(e.alpha,r)*(e.visible?1:0),e.type==="outline"&&n==="visible"){let i=t.uniforms[`f${t.id}_compensation`];i&&(i.value=e.compensation&&e.visible)}return o}}function Wu(n,t){let e=0,r=n.layers.find(o=>o.data.type==="light");if(r){let o=r.data,i=Number(t.getVariable(o.alphaOverride));if((typeof o.alphaOverride=="string"?i/100:o.alphaOverride)<1)return!0}for(let o of n.layers){if(o.data.type!=="displace"&&o.data.isMask)return!0;if(o.data.type!=="displace"&&"alpha"in o.data&&o.data.type!=="light"&&o.data.type!=="fresnel"&&o.data.type!=="texture"&&o.data.type!=="matcap"&&o.data.type!=="rainbow"&&o.data.type!=="outline"&&o.data.type!=="pattern"){let i=o.data.visible?o.data.alpha:0;if(typeof i=="string"&&(i=Math.max(0,Math.min(1,Number(t.getVariable(i)??100)/100))),i===1&&o.data.type==="depth"||o.data.type==="gradient"){for(let a of o.data.colors)if(a[3]<1){i=a[3];break}}else if(i===1&&o.data.type==="noise"){let a=t.color(o.data.colorA).a,s=t.color(o.data.colorB).a,l=t.color(o.data.colorC).a,u=t.color(o.data.colorD).a,c=Math.min(a,Math.min(s,Math.min(l,u)));c<1&&(i=c)}e+=(1-e)*i}}return e<1}var hr=class extends D3{constructor(){super(void 0);this.flatShading=!1;this.needsJitter=!0;this.cacheKey="";this.fog=!0,this.dithering=!0,this.vertexColors=!0,this.transparent=!0}customProgramCacheKey(){return this.cacheKey}},$u=class extends hr{constructor(e,r,o,i){super();this.flatShading=e;this.side=r;this.wireframe=o;this.root=i}updateAfterBuild(){let e=this.root;this.lights=e.lights,this.vertexShader=e.vertexShader,this.fragmentShader=e.fragmentShader,this.defines=e.defines,this.uniforms=e.uniforms,this.extensions=e.extensions,this.transparent=e.transparent,this.cacheKey=e.customProgramCacheKey()+"flat"+this.flatShading+this.side}onBeforeCompile(e,r){this.root.onBeforeCompile(e)}get data(){return this.root.data}get category(){return this.root.category}get hasAO(){return this.root.hasAO}getFlavor(e,r,o){return this.root.getFlavor(e,r,o)}get layers(){return this.root.layers}get fragment(){return this.root.fragment}getLayersOfType(e){return this.root.getLayersOfType(e)}getLayerByUuid(e){return this.root.getLayerByUuid(e)}updateByOp(e,r,o){this.root.updateByOp(e,r,o)}nodeMaterialDispose(){this.root.nodeMaterialDispose()}},hi=class extends hr{constructor(e,r,o=!0){super();this.data=e;this.allowVariableSaves=o;this.layerIdGen=0;this.flavors=[];this.masks={};this.type="NodeMaterial";this.updaters=[],this.reset0(e,r)}get nodeMaterial(){return this}getFlavor(e,r,o){let i=o?6:(e?3:0)+r;if(i===0)return this;this.flavors===void 0&&(this.flavors=[]),i-=1;let a=this.flavors[i];return a===void 0&&(a=new $u(e,r,o,this),this.flavors[i]=a,a.flatShading=e,a.side=r,a.updateAfterBuild()),a}get fragment(){return this.lightLayer.node}get category(){return this.lightLayer.category}get hasAO(){return this.lightLayer.getNode("occlusion")?.value??!1}reset(e,r,o=!1){(this.data!==e||o)&&this.reset0(e,r)}reset0(e,r){this.data=e;let o=e.layers??Wt.defaultTwoLayerData("phong").layers;try{this.layers=o.map(i=>Po.create(this.layerIdGen++,i.id,i.data,r.shared))}catch{this.layers=[]}this.layers.reverse(),this.name=e.name??"Untitled Material",this.onUpdate(r.shared),this.transparent=Wu(e,r.shared),this.saveVariableLocations(r)}onVariableUpdate(e,r,o){if(e[0]==="alphaOverride")this.transparent=Wu(this.data,o.shared),this.lightLayer.setValue("alphaOverride",Math.max(0,Math.min(Number(r)/100,1)));else if(e[0]==="layer"){let i=e[1],a=e[2];if(i&&a){let s=this.layers.find(l=>l.uuid===i);s?.hasValue(a)&&(a==="alpha"?(this.transparent=Wu(this.data,o.shared),s.setValue(a,Math.max(0,Math.min(Number(r)/100,1)))):s.setValue(a,r))}}}saveVariableLocations(e){if(!this.allowVariableSaves)return;let r=this.data.layers.find(o=>o.data.type==="light");r&&e.shared.getVariable(r.data.alphaOverride,["material",this.uuid,"alphaOverride"]),this.data.layers.forEach(o=>{"alpha"in o.data&&typeof o.data.alpha=="string"&&e.shared.getVariable(o.data.alpha,["material",this.uuid,"layer",o.id,"alpha"])})}getLayersOfType(e){return this.layers.filter(r=>r.type===e)}getLayerByUuid(e){return this.layers.find(r=>r.uuid===e)}onUpdate(e){this.cacheKey=this.computeCacheKey(),this.lightLayer=this.layers.find(r=>r instanceof ar),this.lightLayer===void 0&&(this.lightLayer=new ar(0,"",{...Pt.defaultData("light","phong"),visible:!1},new Ko,{},e)),this.dispose();for(let r of this.flavors)r&&r.dispose();this.applyTextureMaps(),this.applyMasks(),this.blendColors(),this.blendAfterColors(),this.blendPositions()}applyTextureMaps(){let e=this.layers.find(a=>a instanceof ar);if(!e)return;let r=e.data,o=r.bumpMap,i=r.roughnessMap;e.node.bumpMap=void 0,e.node.roughnessMap=void 0;for(let a=0;a<this.layers.length;++a){let s=this.layers[a];s instanceof at&&s.color instanceof Nn&&(s.uuid===o&&(e.node.bumpMap=s.color),s.uuid===i&&(e.node.roughnessMap=s.color))}}updateByOp(e,r,o){if(r!==void 0?this.data=r:r=this.data,this.transparent=Wu(r,o.shared),e.path[0]==="layers"){this.data=r;let i=o.shared,a=e.path[1];if(a===void 0){if(this.layers.reverse(),e.type===4){let s=Po.create(this.layerIdGen++,e.id,e.data,o.shared);this.layers.splice(e.localIndex,0,s),o.scene.markNeedsUpdateRendererDirty()}else if(e.type===5)this.layers.splice(e.localIndex,1)[0].dispose(),o.scene.markNeedsUpdateRendererDirty();else if(e.type===6){let s=this.layers.findIndex(u=>u.uuid===e.id),l=this.layers[s];this.layers.splice(s,1),this.layers.splice(e.localIndex,0,l),o.scene.markNeedsUpdateRendererDirty()}this.layers.reverse(),this.onUpdate(o.shared)}else{e.type===0&&e.props.occlusion!==void 0&&o.scene.markNeedsUpdateRendererDirty();let s=this.layers.find(l=>l.uuid===a);if(s){let l=r.layers.data(a),u;if(e.type===0&&("alpha"in e.props||"alphaOverride"in e.props)&&("alpha"in e.props?u={...e.props,alpha:En(e.props.alpha,i,["material",this.uuid,"layer",a,"alpha"])}:u={...e.props,alphaOverride:En(e.props.alphaOverride,i,["material",this.uuid,"alphaOverride"])}),s.updateByOp({...e,...u?{props:u}:{},path:e.path.slice(2)},l,o)){let d=Po.create(this.layerIdGen++,a,l,i);this.layers.splice(this.layers.findIndex(p=>p.uuid===a),1,d),this.onUpdate(o.shared)}}}}else this.reset(r,o)}applyMasks(){for(let e=0;e<this.layers.length;++e){let r=this.layers[e];r instanceof at?r.color.mask=void 0:r instanceof ar&&(r.node.mask=void 0)}for(let e=0;e<this.layers.length;++e){let r=this.layers[e];if(r instanceof at&&r.isMask.value&&r.data.visible&&e>0){let o=e-1,i=this.layers[o];i instanceof ar?i.node.mask=new kt(r.color,r.alpha,kt.MUL):i instanceof at&&(i.isMask.value||(i.color.mask=new kt(r.color,r.alpha,kt.MUL)))}}}blendColors(){let e=this.layers.findIndex(o=>o instanceof at),r=this.layers.findIndex(o=>o instanceof ar);if(e!==-1&&e<r){let o=this.layers[e].color;for(let i=e+1;i<r;++i){let a=this.layers[i];if(a instanceof at){if(a.isMask.value)continue;o=new Za(o,a.color,a.alpha,a.mode)}}this.fragment.color=o}else this.fragment.color=void 0}blendAfterColors(){let e=new qe("outgoingLight","f"),r=this.layers.findIndex(o=>o instanceof ar);if(this.layers.length>r+1){for(let o=r+1;o<this.layers.length;++o){let i=this.layers[o];if(i instanceof at){if(i.isMask.value)continue;e=new Za(e,i.color,i.alpha,i.mode)}}this.fragment.afterColor=e}else this.fragment.afterColor=void 0}blendPositions(){let e=this.layers.filter(r=>r instanceof _l);if(e.length>0){let r=e[0].position;for(let o=1;o<e.length;++o)e[o]&&(r=new kt(r,e[o].position,kt.ADD),r=new kt(r,new se(.5).setReadonly(!0),kt.MUL));this.fragment.position=r}else this.fragment.position=void 0}getDefines(){return this.defines}getUniforms(){return this.uniforms}getVertexShader(){return this.vertexShader}getFragmentShader(){return this.fragmentShader}onBeforeCompile(e){this.build(),e.defines=this.defines,e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.extensionDerivatives=this.extensions.derivatives===!0,e.extensionFragDepth=this.extensions.fragDepth===!0,e.extensionDrawBuffers=this.extensions.drawBuffers===!0,e.extensionShaderTextureLOD=this.extensions.shaderTextureLOD===!0}clampUniformsForPreview(e,r){let o=(i,a,s)=>Math.min(Math.max(i,a),s);for(let i of this.layers)if(i.type==="displace"){let a=o(i.uniforms[`f${i.id}_intensity`].value,e,r);i.uniforms[`f${i.id}_intensity`].value=a}}computeCacheKey(){let e="[";for(let{data:r}of this.data.layers)if(r.type==="light")e+=`"${r.visible?r.category.toUpperCase():"Basic"}"`;else{let o=(Qf[r.type]??[]).map(u=>r[u]),i=(Kf[r.type]??[]).map(u=>r[u]?.length??0),a=[...o,...i],s="isMask"in r&&r.isMask,l=`"${r.type}-${r.visible}-${s}"`;a.length?e+=`[${l}, "${a.join('","')}"],`:e+=l}return e=e.slice(0,-1)+"]",e}updateFrame(e){for(let r=0;r<this.updaters.length;++r)e.updateNode(this.updaters[r])}build(){let e=new Qa;e.needsJitter=this.needsJitter,this.lights=this.lightLayer.data.visible,e.build(this.fragment,this.fragment),this.vertexShader=e.getCode("vertex"),this.fragmentShader=e.getCode("fragment"),this.defines=e.defines,this.uniforms=e.uniforms,this.extensions=e.extensions,this.updaters=e.updaters;for(let r of this.flavors)r&&r.updateAfterBuild();return this}nodeMaterialDispose(){this.layers.forEach(e=>e.dispose()),super.dispose();for(let e of this.flavors)e&&e.dispose()}assetsLoaded(){for(let e of this.layers)if(e instanceof at){let r=e.params.texture;if(r instanceof di&&!r.image.loaded)return!1}return!0}getHash(){let e="{";return e+='"fragment":'+this.fragment.getHash(),e+="}",e}};Object.defineProperties(hr.prototype,{properties:{get:function(){return this.fragment.properties}}});var mi=class extends hi{constructor(t,e,r){super(t,e,!1),this.uuid=r,this.allowVariableSaves=!0,this.saveVariableLocations(e)}};var jb=Ht(Gb());var Fb=new Map;function kb(n){if(typeof n=="string")return n;let t=Fb.get(n);return t||(t={url:URL.createObjectURL(new Blob([n]))},Fb.set(n,t)),t.url}var yi=class{constructor({src:t,volume:e,delay:r,loop:o}){this._volume=1;this.delay=0;this._loop=1;this.loopsRemaining=0;this._status="stopped";this.onEnd=()=>{this.loopsRemaining===1/0?this.replay():this.loopsRemaining>1?(this.replay(),this.loopsRemaining--):(this._status="stopped",this.loopsRemaining=this._loop)};let i;typeof t=="string"?i={src:t}:i={src:kb(t),format:"wav"},this.sound=new jb.Howl(i),this.sound.on("end",this.onEnd),this.src=t,e!==void 0&&(this.volume=e),r!==void 0&&(this.delay=r),o!==void 0&&(this.loop=o)}get status(){return this._status}get volume(){return this._volume}set volume(t){this._volume=t,this.sound.volume(t)}get loop(){return this._loop}set loop(t){this._loop=t,this.loopsRemaining=t}replay(){this.clearDelay(),this.delayTimerId=window.setTimeout(()=>{this.sound.play(),this.clearDelay()},this.delay)}fade(t,e=1e3){t?(this.sound.volume(this._volume),this.clearFade(),this.fadeTimerId=window.setTimeout(()=>{this.sound.fade(this._volume,0,e),this.clearFade()},t)):this.sound.fade(this._volume,0,e)}on(t,e,r){this.sound.on(t,e,r)}off(t,e,r){this.sound.off(t,e,r)}play(){this._status==="playing"||this.sound.playing()||(this._status==="paused"?(this.sound.seek()===0?this.replay():this.sound.play(),this._status="playing"):this._status==="stopped"&&(this.replay(),this._status="playing"))}pause(){this._status==="playing"&&(this.sound.pause(),this.clearFade(),this.clearDelay(),this._status="paused")}stop(){this.sound.stop(),this.loopsRemaining=this._loop,this.clearFade(),this.clearDelay(),this._status="stopped"}clearFade(){this.fadeTimerId&&(clearTimeout(this.fadeTimerId),delete this.fadeTimerId)}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}dispose(t=!1){this.off(),this.stop(),this.clearFade(),this.clearDelay()}};import{Box2 as E3,Vector2 as gi,Path as Ub,Shape as B3,ShapeUtils as L3,Color as R3}from"three";var Xu=class{constructor(){this.type="ShapePath";this.color=new R3;this.subPaths=[];this.currentPath=null}moveTo(t,e){return this.currentPath=new Ub,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath?.lineTo(t,e),this}quadraticCurveTo(t,e,r,o){return this.currentPath?.quadraticCurveTo(t,e,r,o),this}bezierCurveTo(t,e,r,o,i,a){return this.currentPath?.bezierCurveTo(t,e,r,o,i,a),this}splineThru(t){return this.currentPath?.splineThru(t),this}toShapes(){let e={ORIGIN:0,DESTINATION:1,BETWEEN:2,LEFT:3,RIGHT:4,BEHIND:5,BEYOND:6},r={loc:e.ORIGIN,t:0};function o(m,y,g,b){let w=m.x,_=y.x,S=g.x,P=b.x,O=m.y,x=y.y,D=g.y,N=b.y,T=(P-S)*(O-D)-(N-D)*(w-S),I=(_-w)*(O-D)-(x-O)*(w-S),E=(N-D)*(_-w)-(P-S)*(x-O),B=T/E,R=I/E;if(E===0&&T!==0||B<=0||B>=1||R<0||R>1)return null;if(T===0&&E===0){for(let F=0;F<2;F++)if(i(F===0?g:b,m,y),r.loc===e.ORIGIN){let V=F===0?g:b;return{x:V.x,y:V.y,t:r.t}}else if(r.loc===e.BETWEEN){let V=+(w+r.t*(_-w)).toPrecision(10),q=+(O+r.t*(x-O)).toPrecision(10);return{x:V,y:q,t:r.t}}return null}else{for(let q=0;q<2;q++)if(i(q===0?g:b,m,y),r.loc===e.ORIGIN){let k=q===0?g:b;return{x:k.x,y:k.y,t:r.t}}let F=+(w+B*(_-w)).toPrecision(10),V=+(O+B*(x-O)).toPrecision(10);return{x:F,y:V,t:B}}}function i(m,y,g){let b=g.x-y.x,w=g.y-y.y,_=m.x-y.x,S=m.y-y.y,P=b*S-_*w;if(m.x===y.x&&m.y===y.y){r.loc=e.ORIGIN,r.t=0;return}if(m.x===g.x&&m.y===g.y){r.loc=e.DESTINATION,r.t=1;return}if(P<-Number.EPSILON){r.loc=e.LEFT;return}if(P>Number.EPSILON){r.loc=e.RIGHT;return}if(b*_<0||w*S<0){r.loc=e.BEHIND;return}if(Math.sqrt(b*b+w*w)<Math.sqrt(_*_+S*S)){r.loc=e.BEYOND;return}let O;b!==0?O=_/b:O=S/w,r.loc=e.BETWEEN,r.t=O}function a(m,y){let g=[],b=[];for(let w=1;w<m.length;w++){let _=m[w-1],S=m[w];for(let P=1;P<y.length;P++){let O=y[P-1],x=y[P],D=o(_,S,O,x);D!==null&&g.find(N=>N.t<=D.t+Number.EPSILON&&N.t>=D.t-Number.EPSILON)===void 0&&(g.push(D),b.push(new gi(D.x,D.y)))}}return b}function s(m,y,g){let b=new gi;y.getCenter(b);let w=[];return g.forEach(_=>{_.boundingBox.containsPoint(b)&&a(m,_.points).forEach(P=>{w.push({identifier:_.identifier,isCW:_.isCW,point:P})})}),w.sort((_,S)=>_.point.x-S.point.x),w}function l(m,y,g,b,w){(w==null||w==="")&&(w="nonzero");let _=new gi;m.boundingBox.getCenter(_);let S=[new gi(g,_.y),new gi(b,_.y)],P=s(S,m.boundingBox,y);P.sort((I,E)=>I.point.x-E.point.x);let O=[],x=[];P.forEach(I=>{I.identifier===m.identifier?O.push(I):x.push(I)});let D=O[0].point.x,N=[],T=0;for(;T<x.length&&x[T].point.x<D;)N.length>0&&N[N.length-1]===x[T].identifier?N.pop():N.push(x[T].identifier),T++;if(N.push(m.identifier),w==="evenodd"){let I=N.length%2===0,E=N[N.length-2];return{identifier:m.identifier,isHole:I,for:E}}else if(w==="nonzero"){let I=!0,E=null,B=null;for(let R=0;R<N.length;R++){let F=N[R];y[F]&&(I?(B=y[F].isCW,I=!1,E=F):B!==y[F].isCW&&(B=y[F].isCW,I=!0))}return{identifier:m.identifier,isHole:I,for:E}}else console.warn('fill-rule: "'+w+'" is currently not implemented.')}let u=0,c=999999999,d=-999999999,p=[];this.subPaths.forEach(m=>{let y=m.getPoints(),g=-999999999,b=999999999,w=-999999999,_=999999999;for(let S=0;S<y.length;S++){let P=y[S];P.y>g&&(g=P.y),P.y<b&&(b=P.y),P.x>w&&(w=P.x),P.x<_&&(_=P.x)}d<=w&&(d=w+1),c>=_&&(c=_-1),y.length&&p.push({curves:m.curves,points:y,isCW:L3.isClockWise(y),identifier:u++,boundingBox:new E3(new gi(_,b),new gi(w,g))})});let f=p.map(m=>l(m,p,c,d,this.userData?.style.fillRule)),h=[];return p.forEach(m=>{let y=f[m.identifier];if(y&&!y.isHole){let g=new B3;g.curves=m.curves,f.filter(w=>w?.isHole&&w.for===m.identifier).forEach(w=>{if(w){let _=p[w.identifier],S=new Ub;S.curves=_.curves,g.holes.push(S)}}),h.push(g)}}),h}};var eh=!1,qb,th=new Promise(n=>{qb=n}),Hb=!1;var Qu;function Wb(){if(eh=!0,Hb)return;if(Qu)return Qu;async function n(){let e=await import("./opentype.js");qb(e),Hb=!0}return Qu=n(),Qu}var Pl=class{async load(t,e,r=()=>{}){let{load:o}=await th;o(t,(i,a)=>{i||!a?r(i??"Something went wrong"):e(a)})}async parse(t){let{parse:e,Bidi:r}=await th;try{let o=e(t),i=new r,a=s=>o.charToGlyphIndex(s.char);return i.registerModifier("glyphIndex",null,a),i.applyFeatures(o,o.defaultRenderOptions.features),{font:o,bidi:i}}catch(o){console.error(o)}}};async function V3(n){return await(await fetch(n)).arrayBuffer()}var z3=new Pl;async function rh(n){let t,e,r=!1;if(n.url?(t=await V3(n.url),e=n.url,r=n.url.startsWith("/")):n.data&&(t=n.data.buffer.slice(n.data.byteOffset,n.data.byteOffset+n.data.byteLength)),t)if(eh){let o=await z3.parse(t);if(o)return{font:o.font,url:e,intercepted:r,arr:t,bidi:o.bidi}}else return{font:void 0,url:e,intercepted:r,arr:t,bidi:null}}import{CubicBezierCurve as G3,LineCurve as F3,QuadraticBezierCurve as k3}from"three";function j3(n,t){return t.state.glyphIndex===n||t.state.fina===n||t.state.medi===n||t.state.init===n}var Ku=class{constructor(t){this._arrayBuffer=new ArrayBuffer(1);this._isLoaded=!1;this._intercepted=!1;this._isUserFont=t.isUserFont??!1,this._loadingPromise=rh(t).then(e=>{e&&(this._arrayBuffer=e.arr,this._url=e.url,this.font=e.font,this._intercepted=e.intercepted,this._isLoaded=!0,this._bidi=e.bidi)})}update(t){this._isLoaded=!1,this._isUserFont=t.isUserFont??!1,this._loadingPromise=rh(t).then(e=>{e&&(this._arrayBuffer=e.arr,this._url=e.url,this.font=e.font,this._intercepted=e.intercepted,this._isLoaded=!0,this._bidi=e.bidi)})}get url(){return this._url}get intercepted(){return this._intercepted}get isLoaded(){return this._isLoaded}get loadingPromise(){return this._loadingPromise}reverseLigaturesTable(t,e,r){if(!this._bidi)return[];let o=this._bidi;o.getTextGlyphs(e);let i=o.tokenizer.tokens,a=[],s=0,l=r.length===i.length;for(let u=0;u<r.length;u++){let c=r[u].index,d=String.fromCharCode(r[u].unicode),p=i[s];if(j3(c,p)||l)a.push({char:d,index:c,replacements:[p.state.glyphIndex],replacementChars:[p.char]}),s++;else{let f=p.char,h="",m=[p.state.glyphIndex],y=[],g=!1;for(;!g;)s++,h=e.charAt(s),f+=h,m.push(t.charToGlyphIndex(h)),y=t.stringToGlyphs(f),y.length===1&&y[0].index===c&&(g=!0),s>e.length&&(g=!0);a.push({char:d,index:c,replacements:m,replacementChars:Array.from(f)}),s++}}return a}generateShapes(t,e){if(!this._isLoaded)return;let r=this.font,o=e.fontSize/this.unitsPerEm,i=e.fontSize*e.lineHeight,a=t.map(b=>this.getTextWidth(b,e)),s=e.width,l=this.getCharWidth(`
2238
- `,e),u=e.horizontalAlign===1?l:0,c=this.computeSpaceWidthForLine(t,0,e),d=this.getLineInitialOffsetX(a[0],s,e.horizontalAlign,t[0],l),p=this.getLineInitialOffsetY(i,t.length,e.height,o,e.verticalAlign),f=[],h=t.map(b=>[]),m=t.map(b=>[]),y;for(let b=0;b<t.length;b++){let w=t[b],_={features:{liga:!0}},S=[];try{S=r.stringToGlyphs(w,_)}catch(O){console.warn(O)}d=this.getLineInitialOffsetX(a[b],s,e.horizontalAlign,w,l);let P=[];try{P=this.reverseLigaturesTable(r,w,S)}catch(O){console.warn(O)}c=this.computeSpaceWidthForLine(t,b,e);for(let O=0;O<S.length;O++){let x=S[O],D=x.index===0?`
2237
+ `)}return r}};import{VideoTexture as y3,Texture as g3,CanvasTexture as x3}from"three";var ju=class{constructor(t=1e3*10){this.timeout=t;this.cache=new Map;this.head={data:null,time:0,src:null,next:null,prev:null};this.tail={data:null,time:1/0,src:null,next:null,prev:null};this.hasClean=!1;this.head.next=this.tail,this.tail.prev=this.head}log(...t){}remove(t){let e=this.cache.get(t);e&&(this.dispose(t,e.data),this.cache.delete(t),e.prev.next=e.next,e.next.prev=e.prev)}scheduleCleanup(){this.hasClean||(this.log("scheduled cleanup"),this.hasClean=!0,setTimeout(()=>{this.hasClean=!1,this.log("cleaning");let t=Date.now(),e=this.head.next;for(;e.time<t-this.timeout;)this.dispose(e.src,e.data),this.cache.delete(e.src),e=e.next,e.prev=this.head,this.head.next=e;this.head.next!==this.tail?this.scheduleCleanup():this.log("no more cleanup")},this.timeout+1e3))}has(t){return this.cache.get(t)?.data}load(t){let e=Date.now(),r=this.cache.get(t);return r===void 0?(r={data:this.create(t),src:t,time:e,next:null,prev:null},this.cache.set(t,r)):(r.time=e,r.prev.next=r.next,r.next.prev=r.prev),r.prev=this.tail.prev,r.next=this.tail,this.tail.prev.next=r,this.tail.prev=r,this.scheduleCleanup(),r.data}};var Qf=class extends ju{create(t){return URL.createObjectURL(new Blob([t]))}dispose(t,e){URL.revokeObjectURL(e)}},Xf;function Vb(n){return typeof n=="string"?n:(Xf||(Xf=new Qf),Xf.load(n))}var Uu=class{constructor(t,e){this.data=t;this.cache=e;this.refCount=0}deref(){if(this.refCount===0&&!1)throw new Error("ref count -1?");this.refCount-=1,this.refCount===0&&(this.cache.remove(this),this.dispose())}dispose(){if(this.refCount!==0&&!1)throw new Error("ref count is not 0")}},Hu=class{constructor(){this.cache=new Map}remove(t){if(this.cache.delete(t.data)===!1&&!1)throw new Error("ref count remove non-exists")}load(t){let e=this.cache.get(t);return e===void 0&&(e=this.create(t),this.cache.set(t,e)),e.refCount+=1,e}};var fs=class extends Uu{constructor(e,r){super(e,r.imageHolderCache);this.data=e;this.shared=r;this.loaded=!1;this.isVideo=!1;this.isCanvas=!1;this._cache={[1e3]:{},[1001]:{},[1002]:{}};this.isVideo=e.type==="video",this.isCanvas=e.nodeName==="CANVAS",this.updateSrc(this.isCanvas?e:e.data)}async updateSrc(e){if(typeof document>"u")return;this.disposeTextures(),this.loaded=!1;let r=()=>{this.loaded=!0;for(let i of Object.values(this._cache))for(let a of Object.values(i))a&&(a.image=this.img,a.needsUpdate=!0);this.shared.requestRender()};if(this.isCanvas)this.img=e,this.loaded=!0;else if(this.isVideo){if(this.img=document.createElement("video"),this.img.preload="auto",this.img.playsInline=!0,this.img.currentTime=.01,typeof e!="string"){var o=new FileReader;o.readAsDataURL(new Blob([e],{type:"video/mp4"}));let i;await new Promise(a=>{o.onloadend=s=>{i=s.target?.result,a(null)}}),this.img.src=i}else this.img.src=e;this.img.onloadeddata=()=>{r()}}else this.img=new Image,this.img.src=Vb(e),this.img.onload=r}getTexture(e,r=1008){let o=this._cache[e]?.[r];if(o)return o;{let i;return this.isCanvas&&(i=new x3(this.img,void 0,e,e,void 0,r)),this.isVideo?i=new y3(this.img,void 0,e,e):i=new g3(this.img,void 0,e,e,void 0,r),this.loaded&&(i.needsUpdate=!0),this._cache[e]===void 0&&(this._cache[e]={}),this._cache[e][r]=i,i}}setNeedsUpdate(e){for(let r of Object.values(this._cache))for(let o of Object.values(r))o&&(o.needsUpdate=e)}disposeTextures(){for(let[e,r]of Object.entries(this._cache))for(let[o,i]of Object.entries(r))i?.dispose(),this._cache[e][o]=void 0}dispose(){super.dispose(),this.disposeTextures()}};var _r=class extends fs{};import{Vector2 as Jo,Vector3 as Ao,Vector4 as qu}from"three";function Qt(n,t){return t.color(n)}function zb(n,t){switch(n.type){case"fresnel":return S3(n,t);case"gradient":return w3(n,t);case"depth":return A3(n,t);case"normal":return _3(n,t);case"noise":return P3(n,t);case"rainbow":return O3(n,t);case"toon":return C3(n,t);case"outline":return T3(n,t);case"transmission":return M3(n,t);case"color":return v3(n,t);case"pattern":return I3(n,t)}}function b3(n){return{type:n.type}}function eo(n,t){let{alpha:e,mode:r,isMask:o}=n,i=typeof e=="string"?(Number(t.getVariable(e))??100)/100:e;return{...b3(n),alpha:i,mode:r,isMask:o}}function v3(n,t){return{...eo(n,t),color:Qt(n.color,t)}}function S3(n,t){let{bias:e,scale:r,intensity:o,factor:i,color:a}=n;return{...eo(n,t),color:Qt(a,t),bias:e,scale:r,intensity:o,factor:i}}function w3(n,t){let{gradientType:e,smooth:r,colors:o,steps:i,angle:a,offset:s,morph:l}=n;return{...eo(n,t),gradientType:e,smooth:r,colors:o.map(u=>new qu(u[0],u[1],u[2],u[3])),num:o.length,steps:i,offset:new Jo(...s),morph:new Jo(...l),angle:a}}function A3(n,t){let{gradientType:e,near:r,far:o,isVector:i,isWorldSpace:a,origin:s,direction:l,colors:u,steps:c,smooth:d}=n;return{...eo(n,t),gradientType:e,near:r,far:o,isVector:i,isWorldSpace:a,origin:new Ao(...s),direction:l?new Ao(...l):new Ao(1,0,0),colors:u.map(p=>p!==void 0?new qu(p[0],p[1],p[2],p[3]):new qu(0,0,0,0)),steps:c.slice(0,u.length),smooth:d}}function _3(n,t){let{cnormal:e}=n;return{...eo(n,t),cnormal:new Ao(e[0],e[1],e[2])}}function P3(n,t){return{...eo(n,t),scale:n.scale,move:n.move,fA:new Jo(...n.fA),fB:new Jo(...n.fB),size:new Ao(...n.size),distortion:new Jo(...n.distortion),colorA:Qt(n.colorA,t),colorB:Qt(n.colorB,t),colorC:Qt(n.colorC,t),colorD:Qt(n.colorD,t),noiseType:n.noiseType,voronoiStyle:n.voronoiStyle,highCut:n.highCut,lowCut:n.lowCut,smoothness:n.smoothness,seed:n.seed,quality:n.quality}}function O3(n,t){return{...eo(n,t),filmThickness:n.filmThickness,movement:n.movement,wavelengths:new Ao(...n.wavelengths),noiseStrength:n.noiseStrength,noiseScale:n.noiseScale,offset:new Ao(...n.offset)}}function C3(n,t){return{...eo(n,t),positioning:n.positioning,colors:n.colors.map(e=>new qu(e[0],e[1],e[2],e[3])),num:n.colors.length,steps:n.steps,source:new Ao(...n.source),isWorldSpace:n.isWorldSpace,noiseStrength:n.noiseStrength,noiseScale:n.noiseScale,shadowColor:Qt(n.shadowColor,t),offset:new Ao(...n.offset)}}function T3(n,t){return{...eo(n,t),outlineColor:Qt(n.outlineColor,t),contourColor:Qt(n.contourColor,t),outlineWidth:n.outlineWidth,contourWidth:n.contourWidth,outlineThreshold:n.outlineThreshold,contourThreshold:n.contourThreshold,outlineSmoothing:n.outlineSmoothing,contourFrequency:n.contourFrequency,contourDirection:new Ao(...n.contourDirection),positionalLines:n.positionalLines,compensation:n.compensation}}function M3(n,t){return{...eo(n,t),thickness:n.thickness,ior:n.ior,roughness:n.roughness}}function I3(n,t){return{...eo(n,t),style:n.style,projection:n.projection,axis:n.axis,blending:n.blending,offset:new Jo(...n.offset),colorA:Qt(n.colorA,t),colorB:Qt(n.colorB,t),frequency:new Jo(...n.frequency),size:n.size,variation:n.variation,smoothness:n.smoothness,zigzag:n.zigzag,rotation:n.rotation,vertical:new Jo(...n.vertical),horizontal:new Jo(...n.horizontal),sides:n.sides}}var Dn=class extends Bt{};import{Vector4 as N3}from"three";var Kf={noise:["noiseType"],texture:["projection","axis","side"],video:["projection","axis","side"],displace:["noiseType"],light:["roughnessMap","bumpMap"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"]},Zf={depth:["colors"]};function D3(n,t,e){if(t==="isMask")return!0;let r=Kf[n.type],o=Zf[n.type];if(o!==void 0){let i=n.color;if(o.includes(t)){let a=i[t]?.value?.length;if(a!==void 0&&a!==e.length)return!0}}return r!==void 0?r.includes(t):!1}function Jf(n,t,e){let r=e.uniforms[`f${e.id}_texture`];if(!r)return!1;let o=!1,i=n;if("image"in i){let a=i.image,s=t.image(a),l=r;l.image instanceof _r||l.image.deref(),l.image=s}if("video"in i){let a=i.video,s=t.video(a),l=r;l.image instanceof _r||l.image.deref(),l.image=s}if("wrapping"in i){let a=r;a.wrap=i.wrapping}if("minFilter"in i){let a=r;a.minFilter=i.minFilter}if("repeat"in i||"offset"in i){let a="mat",s=e.uniforms[`f${e.id}_${a}`];"repeat"in i&&(s.repeat=i.repeat),"offset"in i&&(s.offset=i.offset),s.updateMatrix()}return o}function Gb(n,t,e,r){let o=!1;for(let[i,a]of Object.entries(n)){if(i==="bumpMap"||i==="roughnessMap"){o=!0;continue}if(!i||a===void 0)continue;if(eh(i,e,r,t)){i==="visible"&&e.type==="light"&&(o=!0);continue}e.visible=r.visible;let s=e.uniforms[`f${e.id}_${i}`];if(!!s&&!(s instanceof In))switch(o=o||D3(e,i,a),s.constructor){case $e:if(typeof a=="string"){let l=t.getColor(a);l&&(s.value=l);break}else{let l=a;s.value instanceof Dn?s.value=new Bt(l.r,l.g,l.b,l.a):s.setRGBA(l);break}case pr:if(typeof a=="string"){let l=t.getColor(a);l&&(s.value=l);break}else{let l=a;s.value instanceof Dn?s.value=new Bt(l.r,l.g,l.b,l.a):s.value.setRGBA(l.r,l.g,l.b,l.a);break}case pt:{let l=a;s.value.setX(l[0]),s.value.setY(l[1]);break}case Yt:{let l=a;s.value.setX(l[0]),s.value.setY(l[1]),s.value.setZ(l[2]);break}case ir:{Jf(a,t,e);break}case Jr:{s.value=a.map(l=>new N3(...l));break}default:{s.value=a;break}}}return o}var En=(n,t,e)=>Math.max(0,Math.min(1,Number(t.getVariable(typeof n=="number"?n*100:n,e)??100)/100))??1,Po=class{constructor(t,e,r,o,i){this.id=t;this.uuid=e;this.data=r;this.uniforms={};for(let a in o)this.uniforms[`f${this.id}_${a}`]=o[a];for(let a in r)eh(a,this,r,i)}get type(){return this.data.type}static create(t,e,r,o){if(r.type==="light")return ar.createLigherLayer(t,e,r,o);if(r.type==="texture"||r.type==="video"){let i=r.type==="texture"?o.canvas(r.texture.image)??o.image(r.texture.image):o.video(r.texture.video),a=new di(i,r.texture.wrapping,r.texture.minFilter??1008),s=new Fu(i),l=new ku(r.texture.repeat,r.texture.offset),u=new se(r.crop?1:0),c=new Be(r.projection??0),d=new Be(["x","y","z"].indexOf(r.axis)??0),p=new Be(r.side??0),f=new pt(r.size?new to(r.size[0],r.size[1]):new to(100,100)),h=new se(r.blending??0),m=new se(En(r.alpha,o)),y=new Be(r.mode??0),g=new xt(r.isMask??!1),b=new Nn(a,s,u,c,d,p,f,h,l,m,y,g),w=new qe(b.calpha,"f");return new at(t,e,r,{texture:a,textureSize:s,crop:u,projection:c,axis:d,side:p,size:f,blending:h,mat:l,alpha:m,mode:y,isMask:g},b,y,w,g,o)}else if(r.type==="matcap"){let i=o.image(r.texture.image),a=new di(i,r.texture.wrapping,r.texture.minFilter??1008),s=new se(En(r.alpha,o)),l=new Be(r.mode??0),u=new xt(r.isMask??!1),c=new is(a,s,l,u),d=new qe(c.calpha,"f");return new at(t,e,r,{texture:a,alpha:s,mode:l,isMask:u},c,l,d,u,o)}else if(r.type==="displace")if(r.displacementType==="noise"){let i=new Yt(new _o(...r.offset)),a=new se(r.scale??10),s=new se(r.intensity??8),l=new se(r.movement??1),u=new Be(r.noiseType??0),c=new Be(r.voronoiStyle??0),d=new se(r.smoothness??.5),p=new se(r.seed??0),f=new se(r.highCut??1),h=new se(r.lowCut??0),m=new Be(r.quality??1),y=new ps(s,l,i,c,d,p,f,h,m,a,u);return new _l(t,e,r,{offset:i,scale:a,intensity:s,movement:l,noiseType:u,voronoiStyle:c,smoothness:d,seed:p,highCut:f,lowCut:h,quality:m},y,o)}else throw new Error;else return L3(t,e,r,o)}updateByOp(t,e,r){let o=t;if(o.path[0]===void 0){if(o.type===0)return"type"in o.props||"category"in o.props||"visible"in o.props?(r.scene.markNeedsUpdateRendererDirty(),!0):Gb(o.props,r.shared,this,e)}else if(o.path[0]==="texture")return"texture"in e||"video"in e?Jf(o.props,r.shared,this):!0;return!1}dispose(){if(E3(this)){let t=this.uniforms[`f${this.id}_texture`];if(!t)return!1;let e=t;e.image instanceof _r||e.image.deref()}}hasValueByKey(t){return this.uniforms[t]!==void 0}hasValue(t){return this.hasValueByKey(`f${this.id}_${t}`)}setValue(t,e){let r=`f${this.id}_${t}`;this.hasValueByKey(r)&&e!==void 0&&(this.uniforms[r].value=e)}getNode(t){let e=`f${this.id}_${t}`;if(this.hasValueByKey(e))return this.uniforms[e]}getValue(t){let e=`f${this.id}_${t}`;if(this.hasValueByKey(e))return this.uniforms[e].value}getName(t){let r=/f\d+_(.*)/.exec(t);if(r&&r.length>1)return r[1];console.log(`Layer.getName: error ${t}`)}getNames(){let t=[];for(let e in this.uniforms){let r=this.getName(e);r&&t.push(r)}return t}},at=class extends Po{constructor(e,r,o,i,a,s,l,u,c){super(e,r,o,i,c);this.params=i;this.color=a;this.mode=s;this.alpha=l;this.isMask=u}},_l=class extends Po{constructor(e,r,o,i,a,s){super(e,r,o,i,s);this.position=a}},ar=class extends Po{constructor(e,r,o,i,a,s){super(e,r,o,a,s);this.node=i}static createLigherLayer(e,r,o,i){let a,s=new se(En(o.alpha,i)),l=new Be(o.mode),u=new se(o.bumpMapIntensity),c=new se(En(o.alphaOverride,i)),d;if(!o.visible)a=new Ko,d={};else if(o.category==="lambert"){a=new vl;let p=new $e(i.color(o.emissive)??0),f=new xt(o.occlusion??!0);d={emissive:p,occlusion:f},a.emissive=p,a.occlusion=f}else if(o.category==="toon"){a=new Al;let p=new se(o.shininess??30),f=new $e(i.color(o.specular)??1118481);d={shininess:p,specular:f},a.shininess=p,a.specular=f}else if(o.category==="physical"){a=new wl;let p=new se(o.roughness??.3),f=new se(o.metalness??0),h=new se(o.reflectivity??.5),m=new xt(o.occlusion??!0);d={roughness:p,metalness:f,reflectivity:h,occlusion:m},a.roughness=p,a.metalness=f,a.reflectivity=h,a.occlusion=m}else{a=new Sl;let p=new se(o.shininess??30),f=new $e(o.specular!==void 0?i.color(o.specular)??1118481:1118481),h=new xt(o.occlusion??!0);d={shininess:p,specular:f,occlusion:h},a.shininess=p,a.specular=f,a.occlusion=h}return a.alpha=new se(1),a.shadingAlpha=s,a.shadingBlend=l,a.bumpMapIntensity=u,a.alphaOverride=c,d.alpha=a.shadingAlpha,d.mode=a.shadingBlend,d.bumpMapIntensity=a.bumpMapIntensity,d.alphaOverride=a.alphaOverride,new ar(e,r,o,a,d,i)}get category(){return this.node.category}};function E3(n){let t=n instanceof Po?n.type:n;return t==="texture"||t==="video"||t==="displace_map"||t==="matcap"}function Er(n){return{alpha:new se(n.alpha??1),mode:new Be(n.mode??0),isMask:new xt(n.isMask??!1)}}function B3(n,t,e,r,o){switch(n.type){case"color":{let i=new $e(r.color??St),a=Er(r),s=new pi(i,a.alpha),l=new qe(s.calpha,"f");return new at(t,e,n,{color:i,...a},s,a.mode,l,a.isMask,o)}case"fresnel":{let i=new $e(r.color??16777215),a=new se(r.bias??.1),s=new se(r.scale??1),l=new se(r.intensity??2),u=new se(r.factor??1),c=Er(r),d=new xl(i,a,s,l,u,c.alpha,c.mode,c.isMask),p=new qe(d.calpha,"f");return new at(t,e,n,{color:i,bias:a,scale:s,intensity:l,factor:u,...c},d,c.mode,p,c.isMask,o)}case"rainbow":{let i=new se(r.filmThickness??30),a=new se(r.movement??0),s=new Yt(r.wavelengths??new _o(0,0,0)),l=new se(r.noiseStrength??0),u=new se(r.noiseScale??1),c=new Yt(r.offset??new _o(0,0,0)),d=Er(r),p=new cs(i,a,s,l,u,c,d.alpha,d.isMask),f=new qe(p.calpha,"f");return new at(t,e,n,{filmThickness:i,movement:a,wavelengths:s,noiseStrength:l,noiseScale:u,offset:c,...d},p,d.mode,f,d.isMask,o)}case"transmission":{let i=new se(r.thickness??10),a=new se(r.ior??1.5),s=new se(r.roughness??.5),l=Te.transmissionSize,u=Te.transmissionRenderTarget,c=Te.transmissionRenderTargetDepth,d=window.innerWidth,p=window.innerHeight,f=d>=p?new pt(p/d,1):new pt(1,d/p),h=Er(r),m=new ds(i,a,s,l,u,c,f,h.alpha),y=new qe(m.calpha,"f");return new at(t,e,n,{thickness:i,ior:a,roughness:s,aspectRatio:f,...h},m,h.mode,y,h.isMask,o)}case"toon":{let i=new Be(r.positioning??0),a;r.colors?a=new Jr(r.colors.length,r.colors):(a=new Jr(10,new hs(0,0,0,1)),a.value[1]=new hs(1,1,1,1));let s;r.steps?s=new Zr(r.steps.length,r.steps):(s=new Zr(10,1),s.value[0]=0);let l=new Yt(r.source??new _o(0,0,0)),u=new xt(r.isWorldSpace??!0),c=new se(r.noiseStrength??0),d=new se(r.noiseScale??1),p=new pr(r.shadowColor),f=new Yt(r.offset??new _o(0,0,0)),h=Er(r),m=new us(i,a,s,l,u,c,d,p,f,h.alpha),y=new qe(m.calpha,"f");return new at(t,e,n,{positioning:i,colors:a,steps:s,source:l,isWorldSpace:u,noiseStrength:c,noiseScale:d,shadowColor:p,offset:f,...h},m,h.mode,y,h.isMask,o)}case"outline":{let i=new $e(r.outlineColor??16777215),a=new $e(r.contourColor??16777215),s=new se(r.outlineWidth??.1),l=new se(r.contourWidth??.1),u=new se(r.outlineThreshold??.1),c=new se(r.contourThreshold??.1),d=new se(r.outlineSmoothing??.1),p=new se(r.contourFrequency??.1),f=new Yt(r.contourDirection??new _o(0,1,0)),h=new xt(r.positionalLines??!1),m=new xt(r.compensation??!0),y=Te.normalRenderTarget,g=Te.normalRenderTargetDepth,b=Te.pixelRatioNode,w=Te.resolution,A=Er(r),S=new ss(i,a,s,l,u,c,d,p,f,h,m,w,y,g,b,A.alpha),P=new qe(S.calpha,"f");return new at(t,e,n,{outlineColor:i,contourColor:a,outlineWidth:s,contourWidth:l,outlineThreshold:u,contourThreshold:c,outlineSmoothing:d,contourFrequency:p,contourDirection:f,positionalLines:h,compensation:m,...A},S,A.mode,P,A.isMask,o)}case"depth":{let i=new Be(r.gradientType??0),a=new xt(r.smooth??!1),s=new se(r.near??50),l=new se(r.far??200),u=new se(r.isVector??1),c=new se(r.isWorldSpace??0),d=new Yt(r.origin??new _o),p=new Yt(r.direction??new _o),f;r.colors?f=new Jr(r.colors.length,r.colors):(f=new Jr(2,new hs(0,0,0,1)),f.value[1]=new hs(1,1,1,1));let h;r.steps?h=new Zr(r.steps.length,r.steps):(h=new Zr(2,1),h.value[0]=0);let m=Er(r),y=new os(i,a,s,l,u,c,d,p,f,h,m.alpha,m.isMask),g=new qe(y.calpha,"f");return new at(t,e,n,{gradientType:i,smooth:a,near:s,far:l,isVector:u,isWorldSpace:c,origin:d,direction:p,colors:f,steps:h,...m},y,m.mode,g,m.isMask,o)}case"noise":{let i=new se(r.scale??1),a=new Yt(r.size??new _o(100,100,100)),s=new se(r.move??1),l=new pt(r.fA??new to(1.7,9.2)),u=new pt(r.fB??new to(8.3,2.8)),c=new pt(r.distortion??new to(1,1)),d=new pr(r.colorA),p=new pr(r.colorB),f=new pr(r.colorC),h=new pr(r.colorD),m=new Be(r.noiseType??0),y=new Be(r.voronoiStyle??0),g=new se(r.highCut??1),b=new se(r.lowCut??0),w=new se(r.smoothness??.5),A=new se(r.seed??.5),S=new Be(r.quality??1),P=Er(r),O=new as(i,a,s,l,u,c,d,p,f,h,P.alpha,m,P.isMask,y,g,b,w,A,S),x=new qe(O.calpha,"f");return new at(t,e,n,{scale:i,size:a,move:s,fA:l,fB:u,distortion:c,colorA:d,colorB:p,colorC:f,colorD:h,noiseType:m,...P,voronoiStyle:y,highCut:g,lowCut:b,smoothness:w,seed:A,quality:S},O,P.mode,x,P.isMask,o)}case"normal":{let i=new Yt(r.cnormal??new _o(1,1,1)),a=Er(r),s=new es(i,a.alpha),l=new qe(s.calpha,"f");return new at(t,e,n,{cnormal:i,...a},s,a.mode,l,a.isMask,o)}case"gradient":{let i=new Be(r.gradientType??0),a=new xt(r.smooth??!1),s;r.colors?s=new Jr(r.colors.length,r.colors):(s=new Jr(10,new hs(0,0,0,1)),s.value[1]=new hs(1,1,1,1));let l;r.steps?l=new Zr(r.steps.length,r.steps):(l=new Zr(10,1),l.value[0]=0);let u=new pt(r.offset??new to(0,0)),c=new pt(r.morph??new to(0,0)),d=new se(r.angle??0),p=Er(r),f=new ns(i,a,s,l,u,c,d,p.alpha,p.isMask),h=new qe(f.calpha,"f");return new at(t,e,n,{gradientType:i,smooth:a,colors:s,steps:l,offset:u,morph:c,angle:d,...p},f,p.mode,h,p.isMask,o)}case"pattern":{let i=new Be(r.style??0),a=new Be(r.projection??0),s=new Be(["x","y","z"].indexOf(r.axis)??0),l=new se(r.blending??0),u=new pt(r.offset??new to(0,0)),c=new pr(r.colorA),d=new pr(r.colorB),p=new pt(r.frequency??new to(10,10)),f=new se(r.size??.5),h=new se(r.variation??0),m=new se(r.smoothness??.5),y=new se(r.zigzag??0),g=new se(r.rotation??0),b=new pt(r.vertical??new to(0,1)),w=new pt(r.horizontal??new to(0,1)),A=new Be(r.sides??6),S=Er(r),P=new ls(i,a,s,l,u,c,d,p,f,h,m,y,g,b,w,A,S.alpha,S.isMask),O=new qe(P.calpha,"f");return new at(t,e,n,{style:i,projection:a,axis:s,blending:l,offset:u,colorA:c,colorB:d,frequency:p,size:f,variation:h,smoothness:m,zigzag:y,rotation:g,vertical:b,horizontal:w,sides:A,...S},P,S.mode,O,S.isMask,o)}default:{let i=new $e(1,0,0,1),a=Er(r),s=new pi(i,a.alpha),l=new qe(s.calpha,"f");return new at(t,e,n,{color:i,...a},s,a.mode,l,a.isMask,o)}}}function L3(n,t,e,r){let o=zb(e,r);return B3(e,n,t,o,r)}function eh(n,t,e,r){if(e.type==="displace"&&(n==="intensity"||n==="visible")){let o=t.uniforms[`f${t.id}_intensity`];return o?(o.value=e.intensity*(e.visible?1:0),o):void 0}if(e.type!=="displace"&&(n==="alpha"||n==="visible")){let o=t.uniforms[`f${t.id}_alpha`];if(!o)return;if(o.value=En(e.alpha,r)*(e.visible?1:0),e.type==="outline"&&n==="visible"){let i=t.uniforms[`f${t.id}_compensation`];i&&(i.value=e.compensation&&e.visible)}return o}}function Wu(n,t){let e=0,r=n.layers.find(o=>o.data.type==="light");if(r){let o=r.data,i=Number(t.getVariable(o.alphaOverride));if((typeof o.alphaOverride=="string"?i/100:o.alphaOverride)<1)return!0}for(let o of n.layers){if(o.data.type!=="displace"&&o.data.isMask)return!0;if(o.data.type!=="displace"&&"alpha"in o.data&&o.data.type!=="light"&&o.data.type!=="fresnel"&&o.data.type!=="texture"&&o.data.type!=="matcap"&&o.data.type!=="rainbow"&&o.data.type!=="outline"&&o.data.type!=="pattern"){let i=o.data.visible?o.data.alpha:0;if(typeof i=="string"&&(i=Math.max(0,Math.min(1,Number(t.getVariable(i)??100)/100))),i===1&&o.data.type==="depth"||o.data.type==="gradient"){for(let a of o.data.colors)if(a[3]<1){i=a[3];break}}else if(i===1&&o.data.type==="noise"){let a=t.color(o.data.colorA).a,s=t.color(o.data.colorB).a,l=t.color(o.data.colorC).a,u=t.color(o.data.colorD).a,c=Math.min(a,Math.min(s,Math.min(l,u)));c<1&&(i=c)}e+=(1-e)*i}}return e<1}var hr=class extends R3{constructor(){super(void 0);this.flatShading=!1;this.needsJitter=!0;this.cacheKey="";this.fog=!0,this.dithering=!0,this.vertexColors=!0,this.transparent=!0}customProgramCacheKey(){return this.cacheKey}},$u=class extends hr{constructor(e,r,o,i){super();this.flatShading=e;this.side=r;this.wireframe=o;this.root=i}updateAfterBuild(){let e=this.root;this.lights=e.lights,this.vertexShader=e.vertexShader,this.fragmentShader=e.fragmentShader,this.defines=e.defines,this.uniforms=e.uniforms,this.extensions=e.extensions,this.transparent=e.transparent,this.cacheKey=e.customProgramCacheKey()+"flat"+this.flatShading+this.side}onBeforeCompile(e,r){this.root.onBeforeCompile(e)}get data(){return this.root.data}get category(){return this.root.category}get hasAO(){return this.root.hasAO}getFlavor(e,r,o){return this.root.getFlavor(e,r,o)}get layers(){return this.root.layers}get fragment(){return this.root.fragment}getLayersOfType(e){return this.root.getLayersOfType(e)}getLayerByUuid(e){return this.root.getLayerByUuid(e)}updateByOp(e,r,o){this.root.updateByOp(e,r,o)}nodeMaterialDispose(){this.root.nodeMaterialDispose()}},hi=class extends hr{constructor(e,r,o=!0){super();this.data=e;this.allowVariableSaves=o;this.layerIdGen=0;this.flavors=[];this.masks={};this.type="NodeMaterial";this.updaters=[],this.reset0(e,r)}get nodeMaterial(){return this}getFlavor(e,r,o){let i=o?6:(e?3:0)+r;if(i===0)return this;this.flavors===void 0&&(this.flavors=[]),i-=1;let a=this.flavors[i];return a===void 0&&(a=new $u(e,r,o,this),this.flavors[i]=a,a.flatShading=e,a.side=r,a.updateAfterBuild()),a}get fragment(){return this.lightLayer.node}get category(){return this.lightLayer.category}get hasAO(){return this.lightLayer.getNode("occlusion")?.value??!1}reset(e,r,o=!1){(this.data!==e||o)&&this.reset0(e,r)}reset0(e,r){this.data=e;let o=e.layers??Wt.defaultTwoLayerData("phong").layers;try{this.layers=o.map(i=>Po.create(this.layerIdGen++,i.id,i.data,r.shared))}catch{this.layers=[]}this.layers.reverse(),this.name=e.name??"Untitled Material",this.onUpdate(r.shared),this.transparent=Wu(e,r.shared),this.saveVariableLocations(r)}onVariableUpdate(e,r,o){if(e[0]==="alphaOverride")this.transparent=Wu(this.data,o.shared),this.lightLayer.setValue("alphaOverride",Math.max(0,Math.min(Number(r)/100,1)));else if(e[0]==="layer"){let i=e[1],a=e[2];if(i&&a){let s=this.layers.find(l=>l.uuid===i);s?.hasValue(a)&&(a==="alpha"?(this.transparent=Wu(this.data,o.shared),s.setValue(a,Math.max(0,Math.min(Number(r)/100,1)))):s.setValue(a,r))}}}saveVariableLocations(e){if(!this.allowVariableSaves)return;let r=this.data.layers.find(o=>o.data.type==="light");r&&e.shared.getVariable(r.data.alphaOverride,["material",this.uuid,"alphaOverride"]),this.data.layers.forEach(o=>{"alpha"in o.data&&typeof o.data.alpha=="string"&&e.shared.getVariable(o.data.alpha,["material",this.uuid,"layer",o.id,"alpha"])})}getLayersOfType(e){return this.layers.filter(r=>r.type===e)}getLayerByUuid(e){return this.layers.find(r=>r.uuid===e)}onUpdate(e){this.cacheKey=this.computeCacheKey(),this.lightLayer=this.layers.find(r=>r instanceof ar),this.lightLayer===void 0&&(this.lightLayer=new ar(0,"",{...Pt.defaultData("light","phong"),visible:!1},new Ko,{},e)),this.dispose();for(let r of this.flavors)r&&r.dispose();this.applyTextureMaps(),this.applyMasks(),this.blendColors(),this.blendAfterColors(),this.blendPositions()}applyTextureMaps(){let e=this.layers.find(a=>a instanceof ar);if(!e)return;let r=e.data,o=r.bumpMap,i=r.roughnessMap;e.node.bumpMap=void 0,e.node.roughnessMap=void 0;for(let a=0;a<this.layers.length;++a){let s=this.layers[a];s instanceof at&&s.color instanceof Nn&&(s.uuid===o&&(e.node.bumpMap=s.color),s.uuid===i&&(e.node.roughnessMap=s.color))}}updateByOp(e,r,o){if(r!==void 0?this.data=r:r=this.data,this.transparent=Wu(r,o.shared),e.path[0]==="layers"){this.data=r;let i=o.shared,a=e.path[1];if(a===void 0){if(this.layers.reverse(),e.type===4){let s=Po.create(this.layerIdGen++,e.id,e.data,o.shared);this.layers.splice(e.localIndex,0,s),o.scene.markNeedsUpdateRendererDirty()}else if(e.type===5)this.layers.splice(e.localIndex,1)[0].dispose(),o.scene.markNeedsUpdateRendererDirty();else if(e.type===6){let s=this.layers.findIndex(u=>u.uuid===e.id),l=this.layers[s];this.layers.splice(s,1),this.layers.splice(e.localIndex,0,l),o.scene.markNeedsUpdateRendererDirty()}this.layers.reverse(),this.onUpdate(o.shared)}else{e.type===0&&e.props.occlusion!==void 0&&o.scene.markNeedsUpdateRendererDirty();let s=this.layers.find(l=>l.uuid===a);if(s){let l=r.layers.data(a),u;if(e.type===0&&("alpha"in e.props||"alphaOverride"in e.props)&&("alpha"in e.props?u={...e.props,alpha:En(e.props.alpha,i,["material",this.uuid,"layer",a,"alpha"])}:u={...e.props,alphaOverride:En(e.props.alphaOverride,i,["material",this.uuid,"alphaOverride"])}),s.updateByOp({...e,...u?{props:u}:{},path:e.path.slice(2)},l,o)){let d=Po.create(this.layerIdGen++,a,l,i);this.layers.splice(this.layers.findIndex(p=>p.uuid===a),1,d),this.onUpdate(o.shared)}}}}else this.reset(r,o)}applyMasks(){for(let e=0;e<this.layers.length;++e){let r=this.layers[e];r instanceof at?r.color.mask=void 0:r instanceof ar&&(r.node.mask=void 0)}for(let e=0;e<this.layers.length;++e){let r=this.layers[e];if(r instanceof at&&r.isMask.value&&r.data.visible&&e>0){let o=e-1,i=this.layers[o];i instanceof ar?i.node.mask=new kt(r.color,r.alpha,kt.MUL):i instanceof at&&(i.isMask.value||(i.color.mask=new kt(r.color,r.alpha,kt.MUL)))}}}blendColors(){let e=this.layers.findIndex(o=>o instanceof at),r=this.layers.findIndex(o=>o instanceof ar);if(e!==-1&&e<r){let o=this.layers[e].color;for(let i=e+1;i<r;++i){let a=this.layers[i];if(a instanceof at){if(a.isMask.value)continue;o=new Ja(o,a.color,a.alpha,a.mode)}}this.fragment.color=o}else this.fragment.color=void 0}blendAfterColors(){let e=new qe("outgoingLight","f"),r=this.layers.findIndex(o=>o instanceof ar);if(this.layers.length>r+1){for(let o=r+1;o<this.layers.length;++o){let i=this.layers[o];if(i instanceof at){if(i.isMask.value)continue;e=new Ja(e,i.color,i.alpha,i.mode)}}this.fragment.afterColor=e}else this.fragment.afterColor=void 0}blendPositions(){let e=this.layers.filter(r=>r instanceof _l);if(e.length>0){let r=e[0].position;for(let o=1;o<e.length;++o)e[o]&&(r=new kt(r,e[o].position,kt.ADD),r=new kt(r,new se(.5).setReadonly(!0),kt.MUL));this.fragment.position=r}else this.fragment.position=void 0}getDefines(){return this.defines}getUniforms(){return this.uniforms}getVertexShader(){return this.vertexShader}getFragmentShader(){return this.fragmentShader}onBeforeCompile(e){this.build(),e.defines=this.defines,e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.extensionDerivatives=this.extensions.derivatives===!0,e.extensionFragDepth=this.extensions.fragDepth===!0,e.extensionDrawBuffers=this.extensions.drawBuffers===!0,e.extensionShaderTextureLOD=this.extensions.shaderTextureLOD===!0}clampUniformsForPreview(e,r){let o=(i,a,s)=>Math.min(Math.max(i,a),s);for(let i of this.layers)if(i.type==="displace"){let a=o(i.uniforms[`f${i.id}_intensity`].value,e,r);i.uniforms[`f${i.id}_intensity`].value=a}}computeCacheKey(){let e="[";for(let{data:r}of this.data.layers)if(r.type==="light")e+=`"${r.visible?r.category.toUpperCase():"Basic"}"`;else{let o=(Kf[r.type]??[]).map(u=>r[u]),i=(Zf[r.type]??[]).map(u=>r[u]?.length??0),a=[...o,...i],s="isMask"in r&&r.isMask,l=`"${r.type}-${r.visible}-${s}"`;a.length?e+=`[${l}, "${a.join('","')}"],`:e+=l}return e=e.slice(0,-1)+"]",e}updateFrame(e){for(let r=0;r<this.updaters.length;++r)e.updateNode(this.updaters[r])}build(){let e=new Ka;e.needsJitter=this.needsJitter,this.lights=this.lightLayer.data.visible,e.build(this.fragment,this.fragment),this.vertexShader=e.getCode("vertex"),this.fragmentShader=e.getCode("fragment"),this.defines=e.defines,this.uniforms=e.uniforms,this.extensions=e.extensions,this.updaters=e.updaters;for(let r of this.flavors)r&&r.updateAfterBuild();return this}nodeMaterialDispose(){this.layers.forEach(e=>e.dispose()),super.dispose();for(let e of this.flavors)e&&e.dispose()}assetsLoaded(){for(let e of this.layers)if(e instanceof at){let r=e.params.texture;if(r instanceof di&&!r.image.loaded)return!1}return!0}getHash(){let e="{";return e+='"fragment":'+this.fragment.getHash(),e+="}",e}};Object.defineProperties(hr.prototype,{properties:{get:function(){return this.fragment.properties}}});var mi=class extends hi{constructor(t,e,r){super(t,e,!1),this.uuid=r,this.allowVariableSaves=!0,this.saveVariableLocations(e)}};var Ub=Ht(Fb());var kb=new Map;function jb(n){if(typeof n=="string")return n;let t=kb.get(n);return t||(t={url:URL.createObjectURL(new Blob([n]))},kb.set(n,t)),t.url}var yi=class{constructor({src:t,volume:e,delay:r,loop:o}){this._volume=1;this.delay=0;this._loop=1;this.loopsRemaining=0;this._status="stopped";this.onEnd=()=>{this.loopsRemaining===1/0?this.replay():this.loopsRemaining>1?(this.replay(),this.loopsRemaining--):(this._status="stopped",this.loopsRemaining=this._loop)};let i;typeof t=="string"?i={src:t}:i={src:jb(t),format:"wav"},this.sound=new Ub.Howl(i),this.sound.on("end",this.onEnd),this.src=t,e!==void 0&&(this.volume=e),r!==void 0&&(this.delay=r),o!==void 0&&(this.loop=o)}get status(){return this._status}get volume(){return this._volume}set volume(t){this._volume=t,this.sound.volume(t)}get loop(){return this._loop}set loop(t){this._loop=t,this.loopsRemaining=t}replay(){this.clearDelay(),this.delayTimerId=window.setTimeout(()=>{this.sound.play(),this.clearDelay()},this.delay)}fade(t,e=1e3){t?(this.sound.volume(this._volume),this.clearFade(),this.fadeTimerId=window.setTimeout(()=>{this.sound.fade(this._volume,0,e),this.clearFade()},t)):this.sound.fade(this._volume,0,e)}on(t,e,r){this.sound.on(t,e,r)}off(t,e,r){this.sound.off(t,e,r)}play(){this._status==="playing"||this.sound.playing()||(this._status==="paused"?(this.sound.seek()===0?this.replay():this.sound.play(),this._status="playing"):this._status==="stopped"&&(this.replay(),this._status="playing"))}pause(){this._status==="playing"&&(this.sound.pause(),this.clearFade(),this.clearDelay(),this._status="paused")}stop(){this.sound.stop(),this.loopsRemaining=this._loop,this.clearFade(),this.clearDelay(),this._status="stopped"}clearFade(){this.fadeTimerId&&(clearTimeout(this.fadeTimerId),delete this.fadeTimerId)}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}dispose(t=!1){this.off(),this.stop(),this.clearFade(),this.clearDelay()}};import{Box2 as V3,Vector2 as gi,Path as Hb,Shape as z3,ShapeUtils as G3,Color as F3}from"three";var Xu=class{constructor(){this.type="ShapePath";this.color=new F3;this.subPaths=[];this.currentPath=null}moveTo(t,e){return this.currentPath=new Hb,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath?.lineTo(t,e),this}quadraticCurveTo(t,e,r,o){return this.currentPath?.quadraticCurveTo(t,e,r,o),this}bezierCurveTo(t,e,r,o,i,a){return this.currentPath?.bezierCurveTo(t,e,r,o,i,a),this}splineThru(t){return this.currentPath?.splineThru(t),this}toShapes(){let e={ORIGIN:0,DESTINATION:1,BETWEEN:2,LEFT:3,RIGHT:4,BEHIND:5,BEYOND:6},r={loc:e.ORIGIN,t:0};function o(m,y,g,b){let w=m.x,A=y.x,S=g.x,P=b.x,O=m.y,x=y.y,D=g.y,N=b.y,T=(P-S)*(O-D)-(N-D)*(w-S),I=(A-w)*(O-D)-(x-O)*(w-S),E=(N-D)*(A-w)-(P-S)*(x-O),B=T/E,R=I/E;if(E===0&&T!==0||B<=0||B>=1||R<0||R>1)return null;if(T===0&&E===0){for(let F=0;F<2;F++)if(i(F===0?g:b,m,y),r.loc===e.ORIGIN){let V=F===0?g:b;return{x:V.x,y:V.y,t:r.t}}else if(r.loc===e.BETWEEN){let V=+(w+r.t*(A-w)).toPrecision(10),q=+(O+r.t*(x-O)).toPrecision(10);return{x:V,y:q,t:r.t}}return null}else{for(let q=0;q<2;q++)if(i(q===0?g:b,m,y),r.loc===e.ORIGIN){let k=q===0?g:b;return{x:k.x,y:k.y,t:r.t}}let F=+(w+B*(A-w)).toPrecision(10),V=+(O+B*(x-O)).toPrecision(10);return{x:F,y:V,t:B}}}function i(m,y,g){let b=g.x-y.x,w=g.y-y.y,A=m.x-y.x,S=m.y-y.y,P=b*S-A*w;if(m.x===y.x&&m.y===y.y){r.loc=e.ORIGIN,r.t=0;return}if(m.x===g.x&&m.y===g.y){r.loc=e.DESTINATION,r.t=1;return}if(P<-Number.EPSILON){r.loc=e.LEFT;return}if(P>Number.EPSILON){r.loc=e.RIGHT;return}if(b*A<0||w*S<0){r.loc=e.BEHIND;return}if(Math.sqrt(b*b+w*w)<Math.sqrt(A*A+S*S)){r.loc=e.BEYOND;return}let O;b!==0?O=A/b:O=S/w,r.loc=e.BETWEEN,r.t=O}function a(m,y){let g=[],b=[];for(let w=1;w<m.length;w++){let A=m[w-1],S=m[w];for(let P=1;P<y.length;P++){let O=y[P-1],x=y[P],D=o(A,S,O,x);D!==null&&g.find(N=>N.t<=D.t+Number.EPSILON&&N.t>=D.t-Number.EPSILON)===void 0&&(g.push(D),b.push(new gi(D.x,D.y)))}}return b}function s(m,y,g){let b=new gi;y.getCenter(b);let w=[];return g.forEach(A=>{A.boundingBox.containsPoint(b)&&a(m,A.points).forEach(P=>{w.push({identifier:A.identifier,isCW:A.isCW,point:P})})}),w.sort((A,S)=>A.point.x-S.point.x),w}function l(m,y,g,b,w){(w==null||w==="")&&(w="nonzero");let A=new gi;m.boundingBox.getCenter(A);let S=[new gi(g,A.y),new gi(b,A.y)],P=s(S,m.boundingBox,y);P.sort((I,E)=>I.point.x-E.point.x);let O=[],x=[];P.forEach(I=>{I.identifier===m.identifier?O.push(I):x.push(I)});let D=O[0].point.x,N=[],T=0;for(;T<x.length&&x[T].point.x<D;)N.length>0&&N[N.length-1]===x[T].identifier?N.pop():N.push(x[T].identifier),T++;if(N.push(m.identifier),w==="evenodd"){let I=N.length%2===0,E=N[N.length-2];return{identifier:m.identifier,isHole:I,for:E}}else if(w==="nonzero"){let I=!0,E=null,B=null;for(let R=0;R<N.length;R++){let F=N[R];y[F]&&(I?(B=y[F].isCW,I=!1,E=F):B!==y[F].isCW&&(B=y[F].isCW,I=!0))}return{identifier:m.identifier,isHole:I,for:E}}else console.warn('fill-rule: "'+w+'" is currently not implemented.')}let u=0,c=999999999,d=-999999999,p=[];this.subPaths.forEach(m=>{let y=m.getPoints(),g=-999999999,b=999999999,w=-999999999,A=999999999;for(let S=0;S<y.length;S++){let P=y[S];P.y>g&&(g=P.y),P.y<b&&(b=P.y),P.x>w&&(w=P.x),P.x<A&&(A=P.x)}d<=w&&(d=w+1),c>=A&&(c=A-1),y.length&&p.push({curves:m.curves,points:y,isCW:G3.isClockWise(y),identifier:u++,boundingBox:new V3(new gi(A,b),new gi(w,g))})});let f=p.map(m=>l(m,p,c,d,this.userData?.style.fillRule)),h=[];return p.forEach(m=>{let y=f[m.identifier];if(y&&!y.isHole){let g=new z3;g.curves=m.curves,f.filter(w=>w?.isHole&&w.for===m.identifier).forEach(w=>{if(w){let A=p[w.identifier],S=new Hb;S.curves=A.curves,g.holes.push(S)}}),h.push(g)}}),h}};var th=!1,Wb,rh=new Promise(n=>{Wb=n}),qb=!1;var Qu;function $b(){if(th=!0,qb)return;if(Qu)return Qu;async function n(){let e=await import("./opentype.js");Wb(e),qb=!0}return Qu=n(),Qu}var Pl=class{async load(t,e,r=()=>{}){let{load:o}=await rh;o(t,(i,a)=>{i||!a?r(i??"Something went wrong"):e(a)})}async parse(t){let{parse:e,Bidi:r}=await rh;try{let o=e(t),i=new r,a=s=>o.charToGlyphIndex(s.char);return i.registerModifier("glyphIndex",null,a),i.applyFeatures(o,o.defaultRenderOptions.features),{font:o,bidi:i}}catch(o){console.error(o)}}};async function k3(n){return await(await fetch(n)).arrayBuffer()}var j3=new Pl;async function oh(n){let t,e,r=!1;if(n.url?(t=await k3(n.url),e=n.url,r=n.url.startsWith("/")):n.data&&(t=n.data.buffer.slice(n.data.byteOffset,n.data.byteOffset+n.data.byteLength)),t)if(th){let o=await j3.parse(t);if(o)return{font:o.font,url:e,intercepted:r,arr:t,bidi:o.bidi}}else return{font:void 0,url:e,intercepted:r,arr:t,bidi:null}}import{CubicBezierCurve as U3,LineCurve as H3,QuadraticBezierCurve as q3}from"three";function W3(n,t){return t.state.glyphIndex===n||t.state.fina===n||t.state.medi===n||t.state.init===n}var Ku=class{constructor(t){this._arrayBuffer=new ArrayBuffer(1);this._isLoaded=!1;this._intercepted=!1;this._isUserFont=t.isUserFont??!1,this._loadingPromise=oh(t).then(e=>{e&&(this._arrayBuffer=e.arr,this._url=e.url,this.font=e.font,this._intercepted=e.intercepted,this._isLoaded=!0,this._bidi=e.bidi)})}update(t){this._isLoaded=!1,this._isUserFont=t.isUserFont??!1,this._loadingPromise=oh(t).then(e=>{e&&(this._arrayBuffer=e.arr,this._url=e.url,this.font=e.font,this._intercepted=e.intercepted,this._isLoaded=!0,this._bidi=e.bidi)})}get url(){return this._url}get intercepted(){return this._intercepted}get isLoaded(){return this._isLoaded}get loadingPromise(){return this._loadingPromise}reverseLigaturesTable(t,e,r){if(!this._bidi)return[];let o=this._bidi;o.getTextGlyphs(e);let i=o.tokenizer.tokens,a=[],s=0,l=r.length===i.length;for(let u=0;u<r.length;u++){let c=r[u].index,d=String.fromCharCode(r[u].unicode),p=i[s];if(W3(c,p)||l)a.push({char:d,index:c,replacements:[p.state.glyphIndex],replacementChars:[p.char]}),s++;else{let f=p.char,h="",m=[p.state.glyphIndex],y=[],g=!1;for(;!g;)s++,h=e.charAt(s),f+=h,m.push(t.charToGlyphIndex(h)),y=t.stringToGlyphs(f),y.length===1&&y[0].index===c&&(g=!0),s>e.length&&(g=!0);a.push({char:d,index:c,replacements:m,replacementChars:Array.from(f)}),s++}}return a}generateShapes(t,e){if(!this._isLoaded)return;let r=this.font,o=e.fontSize/this.unitsPerEm,i=e.fontSize*e.lineHeight,a=t.map(b=>this.getTextWidth(b,e)),s=e.width,l=this.getCharWidth(`
2238
+ `,e),u=e.horizontalAlign===1?l:0,c=this.computeSpaceWidthForLine(t,0,e),d=this.getLineInitialOffsetX(a[0],s,e.horizontalAlign,t[0],l),p=this.getLineInitialOffsetY(i,t.length,e.height,o,e.verticalAlign),f=[],h=t.map(b=>[]),m=t.map(b=>[]),y;for(let b=0;b<t.length;b++){let w=t[b],A={features:{liga:!0}},S=[];try{S=r.stringToGlyphs(w,A)}catch(O){console.warn(O)}d=this.getLineInitialOffsetX(a[b],s,e.horizontalAlign,w,l);let P=[];try{P=this.reverseLigaturesTable(r,w,S)}catch(O){console.warn(O)}c=this.computeSpaceWidthForLine(t,b,e);for(let O=0;O<S.length;O++){let x=S[O],D=x.index===0?`
2239
2239
  `:x.unicode?String.fromCharCode(x.unicode):void 0,N=P[O],T=0,I=0;O===0&&e.horizontalAlign===2&&x.leftSideBearing!==void 0&&(I=-x.leftSideBearing*o),y&&(T=r.getKerningValue(x,y)*o),d+=I+T;let E=0;if(D===`
2240
2240
  `)E=u;else if(D===" ")E=c;else{let B=this.createPath(x,o,d,p,e);B&&(E=B.offsetX-(T+I),f.push(B.path))}if(N.replacements.length===1)m[b].push([d,p]),h[b].push(E);else{let B=N.replacements.map(q=>(r.glyphs.get(q).advanceWidth??0)*o),R=B.reduce((q,k)=>q+=k,0),F=B.map(q=>q/R),V=d;for(let q=0;q<F.length;q++){let k=E*F[q];m[b].push([V,p]),h[b].push(k),V+=k}}d+=E,y=x}p-=i}let g=[];for(let b=0,w=f.length;b<w;b++)g.push(...f[b].toShapes());return{shapes:g,charWidths:h,lineWidths:a,charCoords:m}}get isUserFont(){return this._isUserFont}get arrayBuffer(){return this._arrayBuffer}get ascender(){return this.font?.ascender??0}get descender(){return this.font?.descender??0}get familyName(){return this.font?.names.fontFamily??""}get subfamilyName(){return this.font?.names.fontSubfamily??""}get unitsPerEm(){return this.font?.unitsPerEm??1}getLineInitialOffsetX(t,e,r,o,i){return(r===3||r===2)&&o.indexOf(`
2241
- `)>=0&&(t-=i),r===3?e*.5-t*.5:r===2?e-t:0}getLineInitialOffsetY(t,e,r,o,i){let a=e*t,s=Math.abs(this.ascender-this.descender)*o,l=t-s,u=-this.ascender*o-l/2;return i===3?-(r-a-u):i===2?-(r*.5-a*.5-u):u}createPath(t,e,r,o,i){let a=t.getPath(r,-o,i.fontSize,{kerning:!1,letterSpacing:i.letterSpacing});if(!a){console.error('THREE.Font: character "'+t+'" does not exists in font family '+this.familyName+".");return}let s=new Xu,l=(t.advanceWidth??1)*e;if(t)for(let u of a.commands){let c=s.currentPath?.currentPoint;if(!(c&&u.type!=="Z"&&c.x===u.x&&-c.y===u.y))switch(u.type){case"M":s.moveTo(u.x,-u.y);break;case"L":s.lineTo(u.x,-u.y);break;case"Q":s.quadraticCurveTo(u.x1,-u.y1,u.x,-u.y);break;case"C":s.bezierCurveTo(u.x1,-u.y1,u.x2,-u.y2,u.x,-u.y);break}}return s.subPaths.forEach(u=>{let c=U3(u.curves);c!==void 0&&u.currentPoint.distanceTo(c)>0&&u.lineTo(c.x,c.y)}),{offsetX:l+i.fontSize*i.letterSpacing,path:s}}getCharWidth(t,e){return this.font?.getAdvanceWidth(t,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}getTextWidth(t,e){return this.font?.getAdvanceWidth(t,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}computeSpaceWidthForLine(t,e,r){let o=this.getCharWidth(" ",r),i=t[e];if(i){let a=this.countSpaces(i.trimEnd());if(r.horizontalAlign===4&&e<t.length-1&&a){let s=r.width,l=this.getTextWidth(i,r);return(s-(l-a*o))/a}}return o}countSpaces(t){return(t.match(/ /g)||[]).length}};function U3(n){if(n.length){let t=n[0];if(t instanceof F3)return t.v1;if(t instanceof G3||t instanceof k3)return t.v0}}var oh=class{constructor(){this.objects=new Map;this.unreachable=new Set}getCached(t){return this.objects.get(t)}get size(){return this.objects.size}get(t,e,r){let o=this.objects.get(t);return o===void 0?(o=this.createObject(t,e,r),this.objects.set(t,o)):o.isShared=!0,o}forceDelete(t){let e=this.objects.get(t);e&&(this.disposeObject(e),this.objects.delete(t))}mutateIfUnique(t,e){let r=this.objects.get(t);if(r&&r.isShared!==!0)return this.objects.delete(t),this.objects.set(e,r),r}startGc(){this.unreachable=new Set(this.objects.keys())}markAsReachable(t,e){let r=this.objects.get(t);e===r?this.unreachable.delete(t):!1&&console.warn("Reachable but deleted",t)}endGc(){this.unreachable.forEach(t=>{this.disposeObject(this.objects.get(t)),this.objects.delete(t)}),this.unreachable.clear()}dispose(){this.objects.forEach(t=>{this.disposeObject(t)}),this.objects.clear()}},Ol=class extends oh{constructor(e){super();this.flatShading=e}disposeObject(e){e.dispose()}createObject(e,r,o){let i=Qo(e,r,this.flatShading,o);return i.computeBoundingSphere(),i}};var $b={markNeedsUpdateRendererDirty:()=>{}};import{MathUtils as Yb}from"three";var nh=class extends Hu{constructor(e){super();this.shared=e}create(e){return new ps(e,this.shared)}},xi=class{constructor(t,e={}){this.data=t;this.geometryCache=new Ol(!0);this.geometryCache2=new Ol(!1);this.imageHolderCache=new nh(this);this.thisContext={scene:$b,shared:this};this.deletedMaterial=new mi(Wt.defaultTwoLayerData("phong"),this.thisContext,"");this.deletedImage=new _r(ba.emptyImage,this);this.deletedVideo=new _r(da.defaultVideo,this);this.materials={};this.images={};this.canvases={};this.videos={};this.colors={};this.audios={};this.particles={};this.fonts={};this.variables={};this.mouseProperty=null;this.raycastProperty=null;this.requestRender=()=>{this._requestRender&&this._requestRender()};if(e.images)for(let[r,o]of Object.entries(e.images))this.addImage(r,o);if(e.videos)for(let[r,o]of Object.entries(e.videos))this.addVideo(r,o);if(e.audios)for(let[r,o]of Object.entries(e.audios))this.addAudio(r,o);if(e.particles)for(let[r,o]of Object.entries(e.particles))this.addParticle(r,o);this.reset(t)}setRequestRender(t){this._requestRender=t}setEntityOpContext(t){this.entityOpContext=t}reset(t,e=!1){this.resetLib(t.lib);for(let{id:r,data:o}of t.variables)this.addVariableHolder(r,o),e&&this.updateVariableHolder(r,o);for(let[r,o]of Object.entries(t.images))this.addImage(r,o);for(let[r,o]of Object.entries(t.videos))this.addVideo(r,o);for(let[r,o]of Object.entries(t.colors))this.addColor(r,o);for(let[r,o]of Object.entries(t.materials))this.addMaterial(r,o);for(let[r,o]of Object.entries(t.audios))this.addAudio(r,o);for(let[r,o]of Object.entries(t.particles))this.addParticle(r,o);for(let[r,o]of Object.entries(t.fonts))this.addFont(r,o)}addMaterial(t,e){if(this.materials[t]){let r=this.materials[t];r.reset(e,this.thisContext),r.dispose()}else{let r=new mi(e,this.thisContext,t);this.materials[t]=r}}deleteMaterial(t){this.materials[t]&&(this.materials[t].nodeMaterialDispose(),delete this.materials[t])}getMaterial(t){let e=this.materials[t];return e}getMaterialOrDeletedPlaceholder(t){return this.materials[t]??this.deletedMaterial}material(t){return typeof t=="string"?this.getMaterialOrDeletedPlaceholder(t):t==null?(console.error("material is undefined or null"),this.deletedMaterial):new hi(t,this.thisContext)}getMaterials(){return this.materials}addImage(t,e){return this.images[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.images[t].updateSrc(e.data),!0):(this.images[t]=new _r(e,this),!1)}deleteImage(t){let e=this.images[t];e&&(e.dispose(),delete this.images[t])}getDefaultImage(){return this.images.image_0}getImage(t){return this.images[t]??this.deletedImage}image(t){return typeof t=="string"?this.getImage(t):this.imageHolderCache.load(t)}addCanvas(t,e){return this.canvases[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.canvases[t].updateSrc(e),!0):(this.canvases[t]=new _r(e,this),!1)}canvas(t){return this.canvases[t]}addVideo(t,e){return this.videos[t]?(this.videos[t].updateSrc(e.data),!0):(this.videos[t]=new _r(e,this),!1)}deleteVideo(t){let e=this.videos[t];e&&(e.dispose(),delete this.videos[t])}getVideo(t){return this.videos[t]??this.deletedVideo}video(t){return typeof t=="string"?this.getVideo(t):this.imageHolderCache.load(t)}addColor(t,e){return this.colors[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),"a"in e?this.colors[t].setRGBA(e.r,e.g,e.b,e.a):this.colors[t].setRGBA(e.r,e.g,e.b,1),!0):("a"in e?this.colors[t]=new Dn(e.r,e.g,e.b,e.a):this.colors[t]=new Dn(e.r,e.g,e.b,1),!1)}updateColor(t,e){if(this.colors[t]){this.onColorOrImageUpdate&&this.onColorOrImageUpdate();let r=this.colors[t];return this.colors[t].r=e.r??r.r,this.colors[t].g=e.g??r.g,this.colors[t].b=e.b??r.b,this.colors[t].a=e.a??r.a,!0}return!1}deleteColor(t){this.colors[t]&&delete this.colors[t]}getColor(t){return this.colors[t]}color(t){let e;if(typeof t=="string"){let r=this.getColor(t);r?e=r:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),e=new Bt(0,0,0,0))}else return"a"in t?new Bt(t.r,t.g,t.b,t.a):new Bt(t.r,t.g,t.b,1);return e}addAudio(t,e){this.audios[t]=e}getAudio(t){let e=this.audios[t];if(e instanceof yi)return e;{let r=new yi({src:e.data});return this.audios[t]=r,r}}addParticle(t,e){this.particles[t]=e}getParticle(t){return this.particles[t]}deleteParticle(t){this.particles[t]&&delete this.particles[t]}deleteAudio(t){let e=this.audios[t];e&&(e instanceof yi&&e.dispose(),delete this.audios[t])}addFont(t,e){this.fonts[t]=new Ku(e),this.fonts[t].loadingPromise.then(()=>this.requestRender())}getFont(t){return this.fonts[t]}deleteFont(t){this.fonts[t]&&delete this.fonts[t]}dispose(){Object.keys(this.materials).forEach(e=>this.deleteMaterial(e)),this._requestRender=void 0,Object.values(this.audios).forEach(e=>{e instanceof yi&&e.dispose()}),this.audios={},this.particles={},this.geometryCache.dispose(),this.geometryCache2.dispose()}addVariableHolder(t,e){return this.variables[t]===void 0?(this.variables[t]={value:e.value,locations:[]},"dynamicVariableType"in e&&(this.variables[t].dynamicVariablePlayState="Playing",this.variables[t].dynamicVariableToggleIsForward=void 0),!0):(this.variables[t].value=e.value,!1)}resetDynamicVariablePlayState(){for(let t in this.variables)this.variables[t].dynamicVariablePlayState!==void 0&&(this.variables[t].dynamicVariablePlayState="Playing",this.variables[t].dynamicVariableToggleIsForward=void 0)}updateVariableHolder(t,e){this.updateVariable(t,e.value)}updateVariable(t,e){if(this.variables[t]===void 0)return!1;this.variables[t].value=e;let r=e;for(;typeof r=="string";)r=this.variables[r].value;let o=this.entityOpContext.scene;for(let i=this.variables[t].locations.length-1;i>=0;i--){let a=this.variables[t].locations[i];if(a[0]==="material"){let s=a[1],l=r,u={scene:o,shared:this},c=a.slice(2);o.traverseMaterial(p=>{let f=p.root??p;f.uuid===s&&f.onVariableUpdate(c,l,u)});let d=this.materials[s];d&&d.onVariableUpdate(c,l,u)}else{let s=o.find(a[0]);if(s===void 0){this.variables[t].locations.splice(i,1);continue}if(a[1]!=="geometry"&&a[1]!=="particles"){for(let l=1;l<a.length-1;l++)s=s[a[l]];a[1]==="rotation"?s[a[a.length-1]]=r*Yb.DEG2RAD:s[a[a.length-1]]=r}if(s=o.find(a[0]),s.type==="ParticleEmitter"&&s.updateVariableState(r,a),Re.is(s)){if(a[1]==="position"||a[1]==="rotation"||a[1]==="scale")s.onVariableUpdate();else if(a[1]==="geometry"){let l=s;s.component&&(l=s.component);let u=l.dataPatched;l.chooseGeoemtryCache(this).forceDelete(u.geometry),l.createGeometryDelayed(this.entityOpContext),l.onVariableUpdate(!0),l.instances.forEach(c=>{let d=c.dataPatched;c.chooseGeoemtryCache(this).forceDelete(d.geometry),c.createGeometryDelayed(this.entityOpContext),c.onVariableUpdate(!0)})}}}}return this.requestRender(),!0}deleteVariable(t){this.variables[t]&&delete this.variables[t]}getVariable(t,e){if(Array.isArray(t)){if(t[0]==="mouse")return this.mouseProperty?.[t[1]]??0;if(t[0]==="raycast")return this.raycastProperty?.[t[1]]??0;let r=this.entityOpContext.scene.find(t[0]);if(t[1]==="width"||t[1]==="height"||t[1]==="depth")return r.geometry.userData.parameters[t[1]];for(let o=1;o<t.length;o++)r=r[t[o]];return t[1]==="rotation"&&(r*=Yb.RAD2DEG),r}for(let r in this.variables){if(e===void 0)break;let o=this.variables[r],i=o.locations?.findIndex(a=>lt.equal(a,e));i!==void 0&&i!==-1&&o.locations.splice(i,1)}if(typeof t=="string"){let r=t,o=t;do{if(o=r,this.variables[r]===void 0)break;r=this.variables[r].value}while(typeof r=="string");return e&&this.variables[o]!==void 0&&this.variables[o].locations.push(e),r}else return t}getVariables(){return this.variables}getDynamicVariablePlayState(t){return this.variables[t]?.dynamicVariablePlayState}setDynamicVariablePlayState(t,e){this.variables[t]!==void 0&&(this.variables[t].dynamicVariablePlayState=e)}getDynamicVariableToggleIsForward(t){return this.variables[t]?.dynamicVariableToggleIsForward}setDynamicVariableToggleIsForward(t,e){this.variables[t]!==void 0&&(this.variables[t].dynamicVariableToggleIsForward=e)}resetLib(t){for(let[e,r]of Object.entries(t.images))this.addImage(e,r.asset);for(let[e,r]of Object.entries(t.audios))this.addAudio(e,r.asset);for(let[e,r]of Object.entries(t.particles))this.addParticle(e,r.asset);for(let[e,r]of Object.entries(t.colors))this.addColor(e,r.asset);for(let[e,r]of Object.entries(t.fonts))this.addFont(e,r.asset);for(let[e,r]of Object.entries(t.materials))this.addMaterial(e,r.asset);for(let[e,r]of Object.entries(t.videos))this.addVideo(e,r.asset);for(let[e,r]of Object.entries(t.variables))this.addVariableHolder(e,r.asset)}updateLibByOp(t,e){t.path[0]==="images"?t.path.length===1&&t.type===1?this.addImage(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteImage(t.id):t.path[0]==="videos"?t.path.length===1&&t.type===1?this.addVideo(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteVideo(t.id):t.path[0]==="audios"?t.path.length===1&&t.type===1?this.addAudio(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteAudio(t.id):t.path[0]==="particles"?t.path.length===1&&t.type===1?this.addParticle(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteParticle(t.id):t.path[0]==="colors"?t.path.length===1&&t.type===1?this.addColor(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteColor(t.id):t.path[0]==="materials"?t.path.length===1&&t.type===1?this.addMaterial(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteMaterial(t.id):t.path[0]==="fonts"?t.path.length===1&&t.type===1?this.addFont(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteFont(t.id):t.path[0]==="variables"?t.path.length===1&&t.type===1?this.addVariableHolder(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteVariable(t.id):t.path[0]==="components"&&e.updateByLibOp(t,this)}updateByOp(t,e,r){this.data=e,t.path[0]==="images"?t.path.length===2&&t.type===0?t.props.data&&this.getImage(t.path[1]).updateSrc(t.props.data):t.path.length===1&&t.type===1?this.addImage(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteImage(t.id):t.path[0]==="videos"?t.path.length===2&&t.type===0?t.props.data&&this.getVideo(t.path[1]).updateSrc(t.props.data):t.path.length===1&&t.type===1?this.addVideo(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteVideo(t.id):t.path[0]==="audios"?t.path.length===2&&t.type===0?t.props.data&&this.addAudio(t.path[1],e.audios[t.path[1]]):t.path.length===1&&t.type===1?this.addAudio(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteAudio(t.id):t.path[0]==="particles"?t.path.length===2&&t.type===0?t.props.data&&this.addParticle(t.path[1],e.particles[t.path[1]]):t.path.length===1&&t.type===1?this.addParticle(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteParticle(t.id):t.path[0]==="colors"?t.path.length===2&&t.type===0?this.updateColor(t.path[1],t.props):t.path.length===1&&t.type===1?this.addColor(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteColor(t.id):t.path[0]==="materials"?t.path.length===1&&t.type===1?this.addMaterial(t.id,t.data):t.path.length===1&&t.type===2?this.deleteMaterial(t.id):t.path.length>1&&this.getMaterial(t.path[1]).updateByOp(ct.drop(t,2),e.materials[t.path[1]],{shared:this,scene:r}):t.path[0]==="fonts"?t.path.length===2&&t.type===0?this.updateFont(t.path[1],t,r):t.path.length===1&&t.type===1?this.addFont(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteFont(t.id):t.path[0]==="variables"?t.path.length===2&&t.type===0&&"value"in t.props?this.updateVariable(t.path[1],t.props.value):t.path.length===1&&t.type===4?this.addVariableHolder(t.id,t.data):t.path.length===1&&t.type===5&&this.deleteVariable(t.id):t.path[0]==="lib"&&this.updateLibByOp(ct.drop(t,1),r)}updateFont(t,e,r){if(e.props.url){let o=this.getFont(t),i={...this.data.fonts[t],url:e.props.url};o.update(i),o.loadingPromise.then(()=>this.requestRender()),r.updateFont(t,this)}}},Xb=new xi(Nr.emptyData());var mr=class extends Dt{updateByPatchedOp(e,r,o){if(super.updateByPatchedOp(e,r,o),Dg(e.path,["materials"])!==null&&e.type===0&&Array.isArray(this.material))for(let[i,a]of Object.entries(e.props)){let s=o.shared.material(a);this.material[Number(i)]=s}else if(Le(e.path,["material"])&&this.material instanceof hr)"material"in r&&typeof r.material!="string"&&this.material.updateByOp(ct.drop(e,1),r.material,o);else if(Le(e.path,["materials","*"])&&Array.isArray(this.material)){let i=e.path[1];if("materials"in r&&i<this.material.length){let a=r.materials[i];typeof a!="string"&&this.material[i].updateByOp(ct.drop(e,2),a,o)}}}get needsAO(){return this.material!==void 0?(Array.isArray(this.material)?this.material[0]:this.material).hasAO:!1}updateState(e,r){super.updateState(e,r),e.castShadow!==void 0&&(this.castShadow=e.castShadow),e.receiveShadow!==void 0&&(this.receiveShadow=e.receiveShadow);let o=this.dataPatched;if(e.geometry?.type!=="NonParametricGeometry"&&"material"in e&&e.material!==void 0&&(this.disposeMaterial(),this.material=r.shared.material(e.material).getFlavor(o.flatShading,o.side,o.wireframe),r.scene.markNeedsUpdateRendererDirty()),(e.geometry?.type==="NonParametricGeometry"||"materials"in e)&&("materials"in e&&e.materials!==void 0?(this.disposeMaterial(),this.material=e.materials.map(i=>r.shared.material(i).getFlavor(o.flatShading,o.side,o.wireframe)),r.scene.markNeedsUpdateRendererDirty()):"material"in e&&e.material!==void 0&&(this.disposeMaterial(),this.material=[r.shared.material(e.material).getFlavor(o.flatShading,o.side,o.wireframe)],r.scene.markNeedsUpdateRendererDirty())),e.flatShading!==void 0||e.wireframe!==void 0||e.side!==void 0)if(Array.isArray(this.material))for(let i=0;i<this.material.length;i++)this.material[i]=this.material[i].getFlavor(o.flatShading,o.side,o.wireframe);else this.material=this.material.getFlavor(o.flatShading,o.side,o.wireframe)}disposeMaterial(){this.material&&Xl(this.material).forEach(e=>{e instanceof hr&&(e instanceof mi||e.nodeMaterialDispose())})}dispose(){this.disposeMaterial(),super.dispose()}};import{BufferGeometry as q3,Matrix4 as ih,Vector3 as ev,Vector4 as ah}from"three";var Qb=new ev,Kb=new ah,Zb=new ah,W3=new ev,Jb=new ih,ft=class extends mr{constructor(e,r,o){super(e,r);this.data=r;this.isSkinnedMesh=!1;this.localGeometry=void 0,r.bindMode&&r.bindMatrix&&(this.bindMode=r.bindMode,this.bindMatrix=new ih().fromArray(r.bindMatrix),this.bindMatrixInverse=new ih)}chooseGeoemtryCache(e){return e.geometryCache}markGeometryAsReachable(e){this.geometryCreateDeleyed instanceof q3&&this.chooseGeoemtryCache(e).markAsReachable(this.dataPatched.geometry,this.geometryCreateDeleyed)}get geometry(){if(this.localGeometry!==void 0)return this.localGeometry;if(this.geometryCreateDeleyed instanceof xi){let e=this.geometryCreateDeleyed,r=this.chooseGeoemtryCache(e);this.geometryCreateDeleyed=r.get(this.dataPatched.geometry,e,this)}return this.geometryCreateDeleyed}set geometry(e){this.localGeometry=e}get is2DAndNoDepth(){let e=this.dataPatched.geometry;return $s.is2DParametricMesh(e.type)&&e.depth===0}get is2DType(){return $s.is2DParametricMesh(this.geometry.userData.type)}get isNonParametric(){return this.geometry.userData.type==="NonParametricGeometry"}updateByPatchedOp(e,r,o){super.updateByPatchedOp(e,r,o),Le(e.path,["geometry"])&&this.updateByPatchedOpGeometry(ct.drop(e,1),r.geometry,o)}removeInteractionGeometry(e){this.localGeometry?.dispose(),this.localGeometry=void 0}updateGeometryInteractions(e,r){this.invalidateDownstreamBooleanData();let o=this.data.geometry.type;if(o==="NonParametricGeometry"||o==="SubdivGeometry"){let i=e;if(this.localGeometry===void 0){let c={...this.data.geometry,...i};this.localGeometry=Qo(c,r,this.data.flatShading,this)}let a,s,l;i.scaleBaked?[a,s,l]=i.scaleBaked:{width:a,height:s,depth:l}=i;let u=this.localGeometry.userData;u.sxPrev!==void 0&&fl(this.localGeometry.attributes,a/u.sxPrev,s/u.syPrev,l/u.szPrev),u.sxPrev=a,u.syPrev=s,u.szPrev=l}else{let i={...this.data.geometry,...e};this.localGeometry?.dispose(),this.localGeometry=Qo(i,r,this.data.flatShading,this)}}refreshAttachedCloners(e){for(let r of this.attachedSurfaceCloners)e.scene.addPendingUpdateCloner(r.object)}refreshAttachedPaths(e){for(let r of this.attachedPaths)e.scene.addPendingCommand(()=>r.updateShape())}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.refreshAttachedCloners(e),this.refreshAttachedPaths(e)}updateByPatchedOpGeometry(e,r,o){let i=!1;e.type===0&&e.path.length===0&&Object.keys(e.props).includes("scaleBaked")&&this.geometryCreateDeleyed instanceof wt&&this.chooseGeoemtryCache(o.shared).mutateIfUnique(this.geometryCreateDeleyed.data,r)===this.geometryCreateDeleyed&&(i=!0,this.geometryCreateDeleyed.mutateDirectlyScaleBaked(r,e.props.scaleBaked),this.refreshAttachedCloners(o),this.refreshAttachedPaths(o)),i||(o.scene?.markGeometryCacheDirty(),this.createGeometryDelayed(o)),this.resetBBoxNeedsUpdate(),this.invalidateDownstreamBooleanData()}updateGeometryOnStateUpdate(e,r){this.createGeometryDelayed(r)}updateState(e,r){e.geometry!==void 0&&this.updateGeometryOnStateUpdate(e.geometry,r),super.updateState(e,r)}updateGeometryGroupsIfNeeded(){Array.isArray(this.material)&&this.geometry.groups.length===0&&this.geometry.addGroup(0,Math.max(this.geometry.getIndex()?.count??0,this.geometry.getAttribute("position").count),0)}updateEntityBoxSize(e,r){let o=this.geometry.userData.parameters;this.is2DType?e.set(0,0,o.depth*.5):this.isNonParametric?(e.setScalar(0),this.geometry.boundingSphere&&e.copy(this.geometry.boundingSphere.center),r.set(o.width,o.height,o.depth??0).multiplyScalar(.5)):e.setScalar(0),r.set(o.width,o.height,o.depth??0).multiplyScalar(.5)}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode==="attached"?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode==="detached"&&this.bindMatrixInverse.copy(this.bindMatrix).invert()}bind(e,r){this.skeleton=e,this.isSkinnedMesh=!0,r===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),r=this.matrixWorld),this.bindMatrix.copy(r),this.bindMatrixInverse.copy(r).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(e){let r=new ah,o=this.geometry.attributes.skinWeight;for(let i=0,a=o.count;i<a;i++){r.fromBufferAttribute(o,i);let s=1/r.manhattanLength();s!==1/0?r.multiplyScalar(s):r.set(1,0,0,0),o.setXYZW(i,r.x,r.y,r.z,r.w)}}boneTransform(e,r){let o=this.skeleton;if(o===void 0)return;let i=this.geometry;Kb.fromBufferAttribute(i.attributes.skinIndex,e),Zb.fromBufferAttribute(i.attributes.skinWeight,e),Qb.copy(r).applyMatrix4(this.bindMatrix),r.set(0,0,0);for(let a=0;a<4;a++){let s=Zb.getComponent(a);if(s!==0){let l=Kb.getComponent(a);Jb.multiplyMatrices(o.bones[l].matrixWorld,o.boneInverses[l]),r.addScaledVector(W3.copy(Qb).applyMatrix4(Jb),s)}}return r.applyMatrix4(this.bindMatrixInverse)}};function Y3(n){if(n.geometry.attributes.extrudeNormal||!n.geometry.attributes.position||!n.geometry.attributes.normal)return;let t=new Map,e=n.geometry.attributes,r=e.position.array,o=e.normal.array,i=new Float32Array(r.length);for(let a=0;a<r.length;a+=3){let s=`${r[a]}_${r[a+1]}_${r[a+2]}`,l=new lh(o[a],o[a+1],o[a+2]);t.has(s)?t.get(s)?.normals.push(l):t.set(s,{normals:[l],result:new lh})}t.forEach((a,s)=>{for(let l of a.normals)a.result.add(l);a.result.divideScalar(a.normals.length)});for(let a=0;a<r.length;a+=3){let s=`${r[a]}_${r[a+1]}_${r[a+2]}`,l=t.get(s)?.result;l&&(i[a]=l.x,i[a+1]=l.y,i[a+2]=l.z)}n.geometry.setAttribute("extrudeNormal",new tv(i,3))}function X3(n){if(n.geometry.attributes.extrudeNormals||!n.geometry.attributes.position)return;let e=n.geometry.attributes.position.array,r=new Float32Array(e.length),o=new lh;for(let i=0;i<e.length;i+=3)o.set(e[i],e[i+1],e[i+2]).normalize(),r[i]=o.x,r[i+1]=o.y,r[i+2]=o.z;n.geometry.setAttribute("extrudeNormal",new tv(r,3))}function hs(n){if(Array.isArray(n.material)){for(let t of n.material)if(t.getLayersOfType("outline").length===0)return}else if(!(n.material instanceof hr)||n.material.getLayersOfType("outline").length===0)return;n instanceof ft&&n.is2DAndNoDepth?X3(n):Y3(n)}function ms(n){if(!n.geometry.attributes.position)return;let e=n.geometry.attributes.position.array,r=new Float32Array(e.length),o=parseInt(n.uuid.replace(/\D/g,"")),i=[sh.seededRandom(o),sh.seededRandom(o+1e4),sh.seededRandom(o+2e4)];for(let a=0;a<e.length;a++)r[a]=i[a%3];n.geometry.setAttribute("randomColor",new $3(r,3))}var Oo=new Q3,Cl=new Z3;function ov(n){let t=!1;return n.scene.objects.traverse((e,r)=>{r.type==="Mesh"&&r.geometry.type==="SubdivGeometry"&&(t=!0)}),t}var bi=class extends ft{constructor(e,r,o){super(e,r,o);this.data=r;this.hiddenMatrixOld=new K3;this.smoothShading=!0;this.skipReactionUpdate=!1}chooseGeoemtryCache(e){return this.dataPatched.flatShading?e.geometryCache:e.geometryCache2}get subdivPointerNew(){return this.localGeometry!==void 0?this.subdivPointer:this.geometry.ensureSubdivPointer()}get originalGeometryNew(){return this.localGeometry!==void 0?this.originalGeometry:this.geometry.originalGeometry}get phongAngle(){return this.data.geometry.phongAngle??45}updateEntityBoxSize(e,r){let o=this.geometry.userData.parameters;e.copy(this.originalGeometryNew.boundingSphere.center),r.set(o.width,o.height,o.depth??0).multiplyScalar(.5)}createGeometryByControls(e){if(this.skipReactionUpdate===!0)return;let r=this.localGeometry?.uuid,{originalGeometry:o,subdividedGeometry:i,subdivPointer:a}=wt.build(e,this.subdivPointer,this.smoothShading,this.hasNonUniformScale?this.shearScale:void 0);this.subdivPointer=a,o!==void 0&&(this.originalGeometry?.dispose(),this.originalGeometry=o),i!==void 0&&(this.subdividedGeometry?.dispose(),this.subdividedGeometry=i??void 0),this.localGeometry=this.subdividedGeometry??this.originalGeometry,hs(this),ms(this),this.calcBoundingBox(),r&&(this.localGeometry.uuid=r)}updateState(e,r){if(super.updateState(e,r),e.flatShading!==void 0){let o=this.material;this.material=Array.isArray(o)?o.map(i=>i.getFlavor(!1,i.side,i.wireframe)):o.getFlavor(!1,o.side,o.wireframe),this.smoothShading=!e.flatShading,this.createGeometryDelayed(r)}}updateMesh(e=!1){wt.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1,this.originalGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0),this.subdividedGeometry&&wt.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1,this.subdividedGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0)}updateTopology(){this.originalGeometry.dispose(),this.originalGeometry=wt.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=wt.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1)),this.localGeometry=this.subdividedGeometry??this.originalGeometry}raycast(e,r){let o=this.localGeometry;this.localGeometry=this.originalGeometryNew,Dt.prototype.raycast.call(this,e,r),this.localGeometry=o}activateSVDCompensation(){!this.hasNonUniformScale||(this.matrix.copy(this.matrixWorldRigid),this.hiddenMatrixOld.copy(this.hiddenMatrix),this.hiddenMatrix.copy(this.parent.matrixWorld).invert())}deactivateSVDCompensation(){!this.hasNonUniformScale||(this.updateMatrix(),this.hasNonUniformScale=void 0,this.hiddenMatrix.copy(this.hiddenMatrixOld))}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new rv,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,o=e.boundingSphere.center;Oo.setFromBufferAttribute(r),Oo.getCenter(o),e.boundingSphere.radius=o.distanceTo(Oo.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Oo.getSize(Cl),this.hasNonUniformScale&&Cl.divide(this.scale);let i={width:Cl.x,height:Cl.y,depth:Cl.z};return this.geometry.userData.parameters=i,i}updateBoundingSphere(e){let r=this.originalGeometry;Oo.min.set(e[0],e[2],e[4]),Oo.max.set(e[1],e[3],e[5]),this.hasNonUniformScale&&(Oo.min.applyMatrix4(this.shearScaleInv),Oo.max.applyMatrix4(this.shearScaleInv)),r.boundingSphere===null&&(r.boundingSphere=new rv);let o=r.boundingSphere.center;Oo.getCenter(o),r.boundingSphere.radius=o.distanceTo(Oo.max)}freeSubdivPointer(){this.subdivPointer&&(wt.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0),this.localGeometry=void 0,this.originalGeometry?.dispose(),this.subdividedGeometry?.dispose()}dispose(){super.dispose(),this.freeSubdivPointer()}updateByPatchedOpGeometry(e,r,o){super.updateByPatchedOpGeometry(e,r,o),this.localGeometry&&this.createGeometryByControls(r)}};import{Triangle as J3,Vector3 as Si}from"three";var nv=-1,eN=1,iv={x:[1,0,0],"-x":[-1,0,0],y:[0,1,0],"-y":[0,-1,0],z:[0,0,1],"-z":[0,0,-1]},av={polygon_center:0,edge:1,vertex:2},Tl=(n,t)=>(e,r)=>!t||e===0||n===0?0:n*r/100,Ce=(n,t)=>{let e=Math.abs(t),r=e*-1;return(n-nv)*(e-r)/(eN-nv)+r};function sv(n){let t=[],e={};for(var r=0,o=n.length;r<o;r++){var i=JSON.stringify(n[r].pos.map(a=>Math.round(a*1e4)/1e4));e[i]||(t.push(n[r]),e[i]=!0)}return t}var tN=new Si,Zu=new Si,rN=new Si,oN=new Si;function ys(n,t){let e=rN.fromArray(n),r=oN.fromArray(t);Zu.copy(r).sub(e);let o=Zu.length();return Zu.normalize().multiplyScalar(o*.5),tN.copy(e).add(Zu).toArray()}var Br=new J3,Ju=new Si,ed=new Si,vi=new Si;function lv(n){let t=[];for(let e=0;e<=n.index.count;e++)if(Ju.fromArray(n.index.array,e*3),Br.setFromAttributeAndIndices(n.attributes.position,Ju.x,Ju.y,Ju.z),Br.getNormal(ed),Br.getMidpoint(vi),!(isNaN(vi.x)||isNaN(vi.y)||isNaN(vi.z))){let{a:r,b:o,c:i}=Br,a=r.toArray(),s=o.toArray(),l=i.toArray(),u=r.distanceTo(o),c=o.distanceTo(i),d=i.distanceTo(r),p=ys(a,s),f=ys(s,l),h=ys(l,a),m=[u,c,d],y=Math.max(...m),g=m.filter(_=>Math.round(_)===Math.round(y)).length>1,b=[],w=Br.getMidpoint(vi).toArray();y===u&&!g&&(b=[f,h,h],w=p),y===c&&!g&&(b=[p,h,h],w=f),y===d&&!g&&(b=[p,f,f],w=h),g&&(b=[p,f,h]),t.push({vertices:[a,s,l],faceCenters:b,midpoint:w,norm:Br.getNormal(ed).toArray()})}return t}function cv(n){let t=[],{position:e}=n.attributes;for(let r=0;r<e.count;r++){Br.setFromAttributeAndIndices(e,r*3,r*3+1,r*3+2),Br.getNormal(ed),Br.getMidpoint(vi);let o=Br.a.toArray(),i=Br.b.toArray(),a=Br.c.toArray();t.push({vertices:[o,i,a],faceCenters:[ys(o,i),ys(i,a),ys(a,o)],midpoint:vi.toArray(),norm:ed.toArray()})}return t}var nN=4,iN=.5,ch=n=>.5*(1-Math.cos(n*Math.PI)),uh=class{constructor(){this.perlin=new Array(4095+1)}noise(t,e=0,r=0){if(this.perlin==null){this.perlin=new Array(4095+1);for(let g=0;g<4095+1;g++)this.perlin[g]=Math.random()}t<0&&(t=-t),e<0&&(e=-e),r<0&&(r=-r);let o=Math.floor(t),i=Math.floor(e),a=Math.floor(r),s=t-o,l=e-i,u=r-a,c,d,p=0,f=.5,h,m,y;for(let g=0;g<nN;g++){let b=o+(i<<4)+(a<<8);c=ch(s),d=ch(l),h=this.perlin[b&4095],h+=c*(this.perlin[b+1&4095]-h),m=this.perlin[b+16&4095],m+=c*(this.perlin[b+16+1&4095]-m),h+=d*(m-h),b+=256,m=this.perlin[b&4095],m+=c*(this.perlin[b+1&4095]-m),y=this.perlin[b+16&4095],y+=c*(this.perlin[b+16+1&4095]-y),m+=d*(y-m),h+=ch(u)*(m-h),p+=h*f,f*=iN,o<<=1,s*=2,i<<=1,l*=2,a<<=1,u*=2,s>=1&&(o++,s--),l>=1&&(i++,l--),u>=1&&(a++,u--)}return p}noiseSeed(t){let e=(()=>{let a,s;return{setSeed(l){s=a=(l??Math.random()*4294967296)>>>0},getSeed(){return a},rand(){return s=(1664525*s+1013904223)%4294967296,s/4294967296}}})();e.setSeed(t),this.perlin=new Array(4095+1);for(let r=0;r<4095+1;r++)this.perlin[r]=e.rand()}},uv=uh;import{Vector3 as aN,Matrix4 as sN,Ray as lN}from"three";var dv=new aN,pv=new sN,fv=new lN;function hv(n){let t=!1;return n.scene.objects.traverse((e,r)=>{r.type==="Mesh"&&r.geometry.type==="TextGeometry"&&(t=!0)}),t}var gs=class extends ft{constructor(e,r,o){super(e,r,o);this.data=r}get textGeometry(){return this.geometry}get charWidths(){return this.textGeometry.charWidths}get charCoords(){return this.textGeometry.charCoords}get wrappedText(){return this.textGeometry.wrappedText}get font(){return this.textGeometry.font}get initialOffsetY(){let e=this.dataPatched;return this.font?.getLineInitialOffsetY(this.lineHeight,this.wrappedText.length,e.geometry.height,this.fontScale,e.geometry.verticalAlign)??0}get fontScale(){let e=this.dataPatched;return this.font?e.geometry.fontSize/this.font.unitsPerEm:1}get AD(){return Math.abs(this.ascender-this.descender)}get ascender(){return(this.font?.ascender??1)*this.fontScale}get descender(){return(this.font?.descender??1)*this.fontScale}get lineHeight(){let e=this.dataPatched;return e.geometry.fontSize*e.geometry.lineHeight}raycast(e,r){let{matrixWorld:o}=this;if(!(isNaN(e.ray.origin.x)||this.scale.x===0||this.scale.y===0||this.scale.z===0)&&(pv.copy(o).invert(),fv.copy(e.ray).applyMatrix4(pv),fv.intersectBox(this.singleBBox,dv))){let i=dv.applyMatrix4(o),a=e.ray.origin.distanceTo(i);r.push({distance:a,point:i.clone(),object:this})}}};var sr=1e-4,Co,xv,bv,vv,yv=new Pr,gv=new Pr;Bu.then(n=>{Co=n,xv=[Co.get_face_center,Co.get_edge_midpoint,Co.get_vertex_position],bv=[Co.get_face_normal,Co.get_edge_normal,Co.get_vertex_normal],vv=[Co.face_count,Co.edge_count,Co.vertex_count]});var uN=new wi,dN=new wi,Bn=new Pr,td=new Pr,Ml=new Pr,ph=new Pr,pN=new Pr,fN=new Pr;var en=new uv,bs=class extends _a(cN){constructor(e,r){super();this.parameters=r;this.objectForSample=void 0;this._pendingMediaLoad=!1;this.object=e}resetOnMove(){this.removeFromParent(),this.parent=null}expandClones(e){if(this.parent===null)this.updateState(this.parameters,e);else for(let r of this.children)r instanceof Wo&&r.expand()}invalidateTransform(e){this.matrixWorldNeedsUpdate=!0,this.traverse(r=>{r instanceof Wo&&r.object===e&&(r.matrixWorldNeedsUpdate=!0)})}onObjUpdateMatrix(){this.parameters.type!=="toObject"&&(this.matrixWorldNeedsUpdate=!0)}update(){switch(this._updateCount(),this.parameters.type){case"radial":this._updateRadial(this.parameters);break;case"linear":this._updateLinear(this.parameters);break;case"grid":this._updateGrid(this.parameters);break;case"toObject":this._updateToObject(this.parameters)}for(let e of this.children)e.updateMatrix(),e.hasNonUniformScale&&(e.updateMatrixWorld(),e.updateMatrixWorldSVD())}_updateCount(e){let r;if(e!==void 0?r=e:r=this.parameters.type==="grid"?Math.round(this.parameters.grid.count[0])*Math.round(this.parameters.grid.count[1])*Math.round(this.parameters.grid.count[2]):this.parameters.count,this.parameters.type==="toObject"&&!this.parameters.toObject.object&&(r=0),this.parameters.type==="toObject"&&this.objectForSample){for(let i=0,a=this.children.length;i<a;++i)this.remove(this.children[0]);let o=this.children;if(o.length===r)return;if(o.length<r)for(let i=0,a=r-o.length;i<a;++i){let s=new Wo(this.object);s.expand(),this.add(s)}else for(let i=0,a=o.length-r;i<a;++i)this.remove(o[i])}else{if(this.children.length===r)return;if(this.children.length<r)for(let o=0,i=r-this.children.length;o<i;++o){let a=new Wo(this.object);a.expand(),this.add(a)}else for(let o=0,i=this.children.length-r;o<i;++o)this.remove(this.children[0])}}_updateRadial(e){let r=e.radial,o=r.start*mv.DEG2RAD,i=r.end*mv.DEG2RAD,a=o-i,s=new dh(r.rotation[0],r.rotation[1],r.rotation[2]),l;switch(r.axis){case"z":l=new Pr(0,0,1);break;case"y":l=new Pr(0,1,0);break;default:case"x":l=new Pr(1,0,0);break}let u=e.randomnessObject??fo.defaultData([1,1,1]).randomnessObject,c=u.noiseType==="perlin";en.noiseSeed(u.seed);let d=lu((0,xs.default)(u.seed)),p=Tl(u.strength,this.parameters.randomness);for(let[f,h]of this.children.entries()){let m=f*(u.freqScale/10)+u.movement,y=c?en.noise(m):d(m,m),g=f+1;h.scale.x=r.scale[0]+p(g,Ce(y,u.scale[0]))||sr,h.scale.y=r.scale[1]+p(g,Ce(y,u.scale[1]))||sr,h.scale.z=r.scale[2]+p(g,Ce(y,u.scale[2]))||sr,h.position.setScalar(0);let b=a/e.count*f-o;switch(r.axis){case"x":h.rotation.set(0,b,0);break;case"y":h.rotation.set(0,0,b);break;case"z":h.rotation.set(b,0,0);break}h.translateOnAxis(l,r.radius),h.position.x+=r.position[0]+p(g,Ce(y,u.position[0])),h.position.y+=r.position[1]+p(g,Ce(y,u.position[1])),h.position.z+=r.position[2]+p(g,Ce(y,u.position[2]));let w=p(g,Ce(y,u.rotation[0])),_=p(g,Ce(y,u.rotation[1])),S=p(g,Ce(y,u.rotation[2]));r.alignment===!0?(h.rotation.x+=s.x+w,h.rotation.y+=s.y+_,h.rotation.z+=s.z+S):h.rotation.set(s.x+w,s.y+_,s.z+S)}}_updateLinear(e){if(e.type!=="linear")throw new Error;let r=e.linear,o=new dh(r.rotation[0],r.rotation[1],r.rotation[2]),i=e.randomnessObject??fo.defaultData([1,1,1]).randomnessObject,a=i.noiseType==="perlin";en.noiseSeed(i.seed);let s=lu((0,xs.default)(i.seed)),l=Tl(i.strength,this.parameters.randomness);for(let[u,c]of this.children.entries()){let d=u*(i.freqScale/10)+i.movement,p=a?en.noise(d):s(d,d),f=u+1,h=l(f,Ce(p,i.rotation[0])),m=l(f,Ce(p,i.rotation[1])),y=l(f,Ce(p,i.rotation[2]));c.scale.x=1+(r.scale[0]-1)*u+l(f,Ce(p,i.scale[0]))||sr,c.scale.y=1+(r.scale[1]-1)*u+l(f,Ce(p,i.scale[1]))||sr,c.scale.z=1+(r.scale[2]-1)*u+l(f,Ce(p,i.scale[2]))||sr,c.rotation.x=o.x*u+h,c.rotation.y=o.y*u+m,c.rotation.z=o.z*u+y,c.position.x=r.position[0]*u+l(f,Ce(p,i.position[0])),c.position.y=r.position[1]*u+l(f,Ce(p,i.position[1])),c.position.z=r.position[2]*u+l(f,Ce(p,i.position[2]))}}_updateGrid(e){let r=0,o=e.grid,i=e.randomnessObject??fo.defaultData([1,1,1]).randomnessObject,a=Tl(i.strength,this.parameters.randomness),s=i.noiseType==="perlin";en.noiseSeed(i.seed);let l=V0((0,xs.default)(i.seed));if(o.useCenter===!0){let u={x:o.count[0]%2===0?2:1,y:o.count[1]%2===0?2:1,z:o.count[2]%2===0?2:1},c=new Pr(o.size[0]*(o.count[0]-u.x)*.5,o.size[1]*(o.count[1]-u.y)*.5,o.size[2]*(o.count[2]-u.z)*.5);for(let d=0;d<o.count[0];d++)for(let p=0;p<o.count[1];p++)for(let f=0;f<o.count[2];f++){let h=[(d+1)*(i.freqScale/10)+i.movement,(p+1)*(i.freqScale/10)+i.movement,(f+1)*(i.freqScale/10)+i.movement],m=s?en.noise(...h):l(...h),y=this.children[r++];y.scale.x=1+a(r,Ce(m,i.scale[0]))||sr,y.scale.y=1+a(r,Ce(m,i.scale[1]))||sr,y.scale.z=1+a(r,Ce(m,i.scale[2]))||sr;let g=a(r,Ce(m,i.rotation[0])),b=a(r,Ce(m,i.rotation[1])),w=a(r,Ce(m,i.rotation[2]));y.rotation.set(g,b,w),y.position.x=o.size[0]*d-c.x+a(r,Ce(m,i.position[0])),y.position.y=o.size[1]*p-c.y+a(r,Ce(m,i.position[1])),y.position.z=o.size[2]*f-c.z+a(r,Ce(m,i.position[2]))}}else for(let u=0;u<o.count[0];u++)for(let c=0;c<o.count[1];c++)for(let d=0;d<o.count[2];d++){let p=[(u+1)*(i.freqScale/10)+i.movement,(c+1)*(i.freqScale/10)+i.movement,(d+1)*(i.freqScale/10)+i.movement],f=s?en.noise(...p):l(...p),h=this.children[r++];h.scale.x=1+a(r,Ce(f,i.scale[0]))||sr,h.scale.y=1+a(r,Ce(f,i.scale[1]))||sr,h.scale.z=1+a(r,Ce(f,i.scale[2]))||sr;let m=a(r,Ce(f,i.rotation[0])),y=a(r,Ce(f,i.rotation[1])),g=a(r,Ce(f,i.rotation[2]));h.rotation.set(m,y,g),h.position.x=o.size[0]*u+a(r,Ce(f,i.position[0])),h.position.y=-o.size[1]*c+a(r,Ce(f,i.position[1])),h.position.z=-o.size[2]*d+a(r,Ce(f,i.position[2]))}}_updateToObject(e){if(e.type!=="toObject")throw new Error;let{toObject:r}=e,o=new dh(r.rotation[0],r.rotation[1],r.rotation[2]),i=e.randomnessObject??fo.defaultData([1,1,1]).randomnessObject,a=i.noiseType==="perlin";en.noiseSeed(i.seed);let s=lu((0,xs.default)(i.seed)),l=Tl(i.strength,this.parameters.randomness);if(!r.object){for(let[,g]of this.children.entries())g.position.set(0,0,0),g.scale.setScalar(1),g.rotation.set(0,0,0);this.objectForSample=void 0;return}if(!this.objectForSample)return;if(this.objectForSample instanceof gs)if(!this.objectForSample.font?.isLoaded||this.objectForSample.geometry.attributes.position===void 0){this._pendingMediaLoad=!0;return}else this._pendingMediaLoad=!1;if(this.objectForSample.geometry===void 0&&this.objectForSample.isAncestorOf(this.object.uuid)){console.warn(`Oh no! The object "${this.object.name}" (${this.object.uuid}) seem to be a child/descendant of the object it's being cloned to. Please re-parent it so that they are siblings instead.`);return}let u=this.getSubdivData(),c=[],d=g=>{let b=g.length,w=g.map(P=>P[0]).reduce((P,O)=>P+O,0),_=g.map(P=>P[1]).reduce((P,O)=>P+O,0),S=g.map(P=>P[2]).reduce((P,O)=>P+O,0);return[w/b,_/b,S/b]},p=g=>Math.round(g*1e6)/1e6;u.forEach(g=>{let b=u.filter(w=>p(g.pos[0])===p(w.pos[0])&&p(g.pos[1])===p(w.pos[1])&&p(g.pos[2])===p(w.pos[2]));b.length>1?c.push({pos:g.pos,norm:d(b.map(w=>w.norm))}):c.push(g)});let f=sv(c);if(f.length>0){let g=Math.round(f.length*r.count/100);this._updateCount(g)}else{let g=this.objectForSample.geometry.getAttribute("position");if(!g||isNaN(g.count)||g.count===0){console.warn(`Oh no! The object "${this.object.name}" (${this.object.uuid}) cannot be cloned on the surface of "${this.objectForSample.name}" (${this.objectForSample.uuid}) because the latter does not have a valid geometry.`);return}}this.objectForSample.updateMatrixWorld();let h=new cu(this.objectForSample).build(),m=iv[r.axis],y=this.children;h.setRandomGenerator((0,xs.default)(this.object.uuid+r.seed));for(let[g,b]of y.entries()){let w=g*(i.freqScale/10)+i.movement,_=a?en.noise(w):s(w,w),S=g+1,P=l(S,Ce(_,i.rotation[0])),O=l(S,Ce(_,i.rotation[1])),x=l(S,Ce(_,i.rotation[2]));r.spreadType==="random"?h.sample(Ml,ph):(f.length&&(Ml.fromArray(f[g].pos),ph.fromArray(f[g].norm)),this.objectForSample instanceof bi&&Ml.applyMatrix4(uN.copy(this.objectForSample.matrixWorld).invert())),Ml.applyMatrix4(this.object.hiddenMatrix.clone().invert()),b.position.copy(Ml),Bn.fromArray(m);let D=r.align==="normal"?ph:this.object.getWorldDirection(fN),N=td.fromArray(r.position);td.x+=l(S,Ce(_,i.position[0])),td.y+=l(S,Ce(_,i.position[1])),td.z+=l(S,Ce(_,i.position[2]));let T=Math.acos(D.dot(Bn)),I=pN.crossVectors(Bn,D).normalize(),E=dN.makeRotationAxis(I,T),B=D.clone().cross(this.object.up).normalize(),R=B.clone().cross(D).normalize(),F=new wi().makeBasis(B,D,R),V=new Pr(Bn.y,Bn.z,Bn.x).normalize(),q=V.clone().cross(Bn).normalize(),k=new wi().makeBasis(V,Bn,q).invert(),U=new wi().multiplyMatrices(F,k);b.rotation.setFromRotationMatrix(U),N.applyMatrix4(E),b.position.add(N),b.rotation.x=b.rotation.x+o.x+P,b.rotation.y=b.rotation.y+o.y+O,b.rotation.z=b.rotation.z+o.z+x,b.scale.setScalar(1),b.scale.x=b.scale.x+r.scale[0]+l(S,Ce(_,i.scale[0]))||sr,b.scale.y=b.scale.y+r.scale[1]+l(S,Ce(_,i.scale[1]))||sr,b.scale.z=b.scale.z+r.scale[2]+l(S,Ce(_,i.scale[2]))||sr,b.scale.multiply(this.object.scale),b.hiddenMatrix=this.object.hiddenMatrix}}getSubdivData(){if(!this.objectForSample)return[];let e=this.parameters.toObject.spreadType;if(e==="random")return[];if(this.objectForSample instanceof bi){let r=this.objectForSample,o=av[e],i=vv[o],a=xv[o],s=bv[o],l=[],u=i(r.subdivPointerNew);for(let c=0;c<=u-1;c++){let d=a(r.subdivPointerNew,c),p=s(r.subdivPointerNew,c);yv.fromArray(d).applyMatrix4(r.matrixWorld),gv.fromArray(p),l.push({pos:yv.toArray(),norm:gv.toArray()})}return l}else return(this.objectForSample.geometry.index?lv(this.objectForSample.geometry):cv(this.objectForSample.geometry)).map((o,i)=>e==="polygon_center"?{pos:o.midpoint,norm:o.norm}:e==="vertex"?[{pos:o.vertices[0],norm:o.norm},{pos:o.vertices[1],norm:o.norm},{pos:o.vertices[2],norm:o.norm}]:e==="edge"?[{pos:o.faceCenters[0],norm:o.norm},{pos:o.faceCenters[1],norm:o.norm},{pos:o.faceCenters[2],norm:o.norm}]:[]).flat()}updateState(e,r){if(this.parameters=Vo(e),this.parameters.type!=="toObject")(this.parent===null||this.parent!==this.object)&&(this.removeFromParent(),this.object.parent?.add(this),this.matrix=this.object.matrix,this.hiddenMatrix=this.object.hiddenMatrix,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1);else if(this.parent===null||this.parent.uuid!==this.parameters.toObject.object){this.removeFromParent();let o=r.find(this.parameters.toObject.object);o instanceof Dt?this.objectForSample=o:this.objectForSample=void 0,this.matrix=new wi,this.hiddenMatrix=new wi,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1,o&&o.add(this)}this.update()}get pendingMediaLoad(){return this._pendingMediaLoad}};import{Scene as kE,Vector3 as jE,Matrix4 as UE,Box3 as HE,MeshBasicMaterial as qE,Skeleton as WE}from"three";import{Camera as PN,OrthographicCamera as ON,PerspectiveCamera as CN,Vector3 as oo,Object3D as _v,Quaternion as TN,Matrix4 as MN}from"three";import{Camera as bN,LineSegments as vN,BufferGeometry as SN,LineBasicMaterial as wN,Color as hh,Vector3 as AN,Float32BufferAttribute as wv}from"three";import{BoxGeometry as hN}from"three";var To=n=>{var t;return t=class extends n{},t.geometryHelper=new hN(30,30,30),t};import{Ray as mN,Sphere as yN,Matrix4 as gN,Vector3 as tn}from"three";var rd=new mN,fh=new yN,Sv=new gN,Mo=(n,t,e,r,o=!1)=>{let i=t,a=n.matrixWorld;if(i.boundingSphere===null&&i.computeBoundingSphere(),fh.copy(i.boundingSphere),fh.applyMatrix4(a),e.ray.intersectsSphere(fh)===!1||(Sv.copy(a).invert(),rd.copy(e.ray).applyMatrix4(Sv),i.boundingBox!==null&&rd.intersectsBox(i.boundingBox)===!1))return;let s,l,u,c,d=i.index,p=i.attributes.position,f=i.drawRange,h,m;if(o===!1){let g=Math.max(0,f.start),b=Math.min(d.count,f.start+f.count);for(h=g,m=b;h<m;h+=3)if(l=d.getX(h),u=d.getX(h+1),c=d.getX(h+2),s=y(n,e,rd,p,l,u,c),s){s.faceIndex=Math.floor(h/3),r.push(s);return}}else{let b=i.attributes.position,w=new tn,_=new tn,S=new tn,P=new tn,O=2,D=1/((n.scale.x+n.scale.y+n.scale.z)/3),N=D*D,T=Math.max(0,f.start),I=Math.min(b.count,f.start+f.count);for(let E=T,B=I-1;E<B;E+=O){if(w.fromBufferAttribute(b,E),_.fromBufferAttribute(b,E+1),rd.distanceSqToSegment(w,_,P,S)>N)continue;P.applyMatrix4(n.matrixWorld);let F=e.ray.origin.distanceTo(P);F<e.near||F>e.far||r.push({distance:F,point:S.clone().applyMatrix4(n.matrixWorld),object:n})}}function y(g,b,w,_,S,P,O){let x=new tn,D=new tn,N=new tn,T=new tn,I=new tn;if(x.fromBufferAttribute(_,S),D.fromBufferAttribute(_,P),N.fromBufferAttribute(_,O),w.intersectTriangle(x,D,N,!1,T)===null)return null;I.copy(T),I.applyMatrix4(g.matrixWorld);let B=b.ray.origin.distanceTo(I);return B<b.near||B>b.far?null:{faceIndex:1,distance:B,point:I.clone(),object:g}}};var od=new AN,Lr=new bN,mh=class extends vN{constructor(e){let r=new SN,o=new wN({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],a=[],s={},l=new hh(15711266),u=new hh(15711266),c=new hh(2857471);d("n1","n2",l),d("n2","n4",l),d("n4","n3",l),d("n3","n1",l),d("f1","f2",l),d("f2","f4",l),d("f4","f3",l),d("f3","f1",l),d("n1","f1",l),d("n2","f2",l),d("n3","f3",l),d("n4","f4",l),d("p","n1",u),d("p","n2",u),d("p","n3",u),d("p","n4",u),d("u1","u2",c),d("u2","u3",c),d("u3","u1",c);function d(f,h,m){p(f,m),p(h,m)}function p(f,h){i.push(0,0,0),a.push(h.r,h.g,h.b),s[f]===void 0&&(s[f]=[]),s[f].push(i.length/3-1)}r.setAttribute("position",new wv(i,3)),r.setAttribute("color",new wv(a,3));super(r,o);this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=s,this.update()}update(){let e=this.geometry,r=this.pointMap,o=!0;Lr.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let i=1,a=1,s=o?.8:1e-4;ro("n1",r,e,Lr,-i,-a,s),ro("n2",r,e,Lr,i,-a,s),ro("n3",r,e,Lr,-i,a,s),ro("n4",r,e,Lr,i,a,s);let l=s;ro("f1",r,e,Lr,-i,-a,l),ro("f2",r,e,Lr,i,-a,l),ro("f3",r,e,Lr,-i,a,l),ro("f4",r,e,Lr,i,a,l);let u=l,c=.5;ro("u1",r,e,Lr,i*.7*c,a*1.1,u),ro("u2",r,e,Lr,-i*.7*c,a*1.1,u),ro("u3",r,e,Lr,0,a*(1.1+.9*c),u),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function ro(n,t,e,r,o,i,a){od.set(o,i,a).unproject(r);let s=t[n];if(s!==void 0){let l=e.getAttribute("position");for(let u=0,c=s.length;u<c;u++)l.setXYZ(s[u],od.x,od.y,od.z)}}var nd=class extends To(mh){constructor(e){super(e);this.object=e;this.object=e,this.name=`CombinedCameraHelper: ${e.uuid}`}updateMatrixWorld(e){super.updateMatrixWorld(e),this.updateTarget()}updateTarget(){let e=this.object.getTarget();this.updateWorldMatrix(!0,!1),this.worldToLocal(e)}raycast(e,r){Mo(this.object,this.geometry,e,r,!0)}};import{Box3Helper as Av,BoxGeometry as _N}from"three";var id;(t=>t.is=e=>"objectHelper"in e)(id||(id={}));var Rr=(n,t)=>class extends Ca(n){constructor(){super(...arguments);this.objectHelper=new t(this);this.gizmos={}}get geometryHelper(){return t.geometryHelper}raycast(o,i){this.objectHelper.raycast(o,i)}showGizmos(){for(let o in this.gizmos){let i=this.gizmos[o];i instanceof Av&&(i.visible=!0)}}updateEntityBoxSize(o,i){this.objectHelper.visible&&this.geometryHelper instanceof _N?(o.setScalar(0),i.set(this.geometryHelper.parameters.width,this.geometryHelper.parameters.height,this.geometryHelper.parameters.height).multiplyScalar(.5)):super.updateEntityBoxSize(o,i)}hideGizmos(){for(let o in this.gizmos){let i=this.gizmos[o];i instanceof Av&&(i.visible=!1)}}};var ad=790,vs=new oo,yh=new oo,gh=new TN,xh=new oo,Il=new oo,bh=new oo,rn=class extends Rr(PN,nd){constructor(e="",r={...oi.defaultData,name:""}){super();this._cameraType="OrthographicCamera";this.targetOffset=Sn.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.wasMovedByUser=!1;this.wasMovedBySwitchCameraAction=!1;this.super_Entity(e,r),this.previousProjectionMatrix=new MN,this.matrixAutoUpdate=!0,this.width=window.innerWidth,this.height=window.innerHeight;let o=this.width,i=this.height;this.orthoCamera=new ON(o*-.5,o*.5,i*.5,i*-.5,-5e4,1e4),this.perspCamera=new CN(45,o/i,50,1e4),this.left=this.orthoCamera.left,this.right=this.orthoCamera.right,this.top=this.orthoCamera.top,this.bottom=this.orthoCamera.bottom,this.far=this.orthoCamera.far,this.view=this.orthoCamera.view,this.aspect=this.perspCamera.aspect,this.focus=this.perspCamera.focus,this.filmGauge=this.perspCamera.filmGauge,this.filmOffset=this.perspCamera.filmOffset,this.objectHelper.update()}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}set fov(e){this.perspCamera.fov=e}get fov(){return this.perspCamera.fov}setNear(e,r){e==="PerspectiveCamera"?this.perspCamera.near=r:this.orthoCamera.near=r}setZoom(e,r){r>=0&&(e==="PerspectiveCamera"?this.perspCamera.zoom=r:this.orthoCamera.zoom=r)}set cameraType(e){e==="PerspectiveCamera"?this.toPerspective():e==="OrthographicCamera"&&this.toOrthographic()}get near(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.near:this.orthoCamera.near}set near(e){this._cameraType==="PerspectiveCamera"?this.perspCamera.near=e:this.orthoCamera.near=e}get zoom(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(e){e>=0&&(this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom=e:this.orthoCamera.zoom=e)}lookAt(e,r,o){typeof e=="number"&&(e=new oo(e,r,o)),super.lookAt(e),this.getWorldPosition(vs),this.targetOffset=vs.distanceTo(e)}getTarget(e=new oo){return this.getWorldDirection(yh),this.getWorldPosition(vs),yh.multiplyScalar(this.targetOffset),e.copy(vs).add(yh),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(vs),vs.distanceTo(e)}updateUp(){this.getWorldQuaternion(gh),xh.set(0,0,1).applyQuaternion(gh),Il.copy(_v.DEFAULT_UP),this.isUpVectorFlipped&&Il.negate(),Il.applyQuaternion(gh),bh.copy(_v.DEFAULT_UP).projectOnPlane(xh),this.angleOffsetFromUp=bh.angleTo(Il),this.angleOffsetFromUp*=bh.cross(Il).dot(xh)>=0?1:-1}updateTransformState(e,r){let o=super.updateTransformState(e,r);return e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateUp(),o}getViewFrontToObject(e){let r=e.getWorldPosition(new oo),i=e.getWorldDirection(new oo).multiplyScalar(this.targetOffset);return{position:r.clone().add(i),target:r}}getViewToTarget(e){let o=this.getWorldDirection(new oo).multiplyScalar(this.targetOffset);return{position:e.clone().sub(o),target:e}}getViewToObject(e){let r=new oo,o=e.getWorldPosition(r);return this.getViewToTarget(r)}setViewplaneSize(e,r,o=!1){if(this.aspect=e/r,o){let i=e>r?this.aspect:1,a=e>r?1:this.aspect;this.left=-ad*.5*i,this.right=ad*.5*i,this.top=ad*.5*(1/a),this.bottom=-ad*.5*(1/a)}else this.left=-e*.5,this.right=e*.5,this.top=r*.5,this.bottom=-r*.5;this.updateProjectionMatrix()}copyViewPlaneSize(e){this.aspect=e.aspect,this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.updateProjectionMatrix()}toOrthographic(){this.orthoCamera.left=this.left,this.orthoCamera.right=this.right,this.orthoCamera.top=this.top,this.orthoCamera.bottom=this.bottom,this.orthoCamera.view=this.view,this.orthoCamera.far=this.far,this.orthoCamera.updateProjectionMatrix(),this.projectionMatrix=this.orthoCamera.projectionMatrix,this.projectionMatrixInverse=this.orthoCamera.projectionMatrixInverse,this._cameraType="OrthographicCamera",this.objectHelper&&this.objectHelper.update()}toPerspective(){this.perspCamera.aspect=this.aspect,this.perspCamera.fov=this.fov,this.perspCamera.view=this.view,this.perspCamera.far=this.far,this.perspCamera.updateProjectionMatrix(),this.projectionMatrix=this.perspCamera.projectionMatrix,this.projectionMatrixInverse=this.perspCamera.projectionMatrixInverse,this._cameraType="PerspectiveCamera",this.objectHelper&&this.objectHelper.update()}setFocalLength(e){this.perspCamera.setFocalLength(e),this.toPerspective()}getFocalLength(){return this.perspCamera.getFocalLength()}getEffectiveFOV(){return this.perspCamera.getEffectiveFOV()}getFilmWidth(){return this.perspCamera.getFilmWidth()}getFilmHeight(){return this.perspCamera.getFilmHeight()}setViewOffset(e,r,o,i,a,s){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(e,r,o,i,a,s):this.orthoCamera.setViewOffset(e,r,o,i,a,s)}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}copyHistory(){this.previousProjectionMatrix&&this.previousProjectionMatrix.copy(this.projectionMatrix)}updateProjectionMatrix(){this._cameraType==="PerspectiveCamera"?this.toPerspective():this._cameraType==="OrthographicCamera"&&this.toOrthographic()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,r){super.updateWorldMatrix(e,r),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(e,r){return super.copy(e,r),this.parent=e.parent,this.orthoCamera.copy(e.orthoCamera),this.perspCamera.copy(e.perspCamera),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.far=e.far,this.view=e.view===null?null:Object.assign({},e.view),this._cameraType=e._cameraType,this.aspect=e.aspect,this.fov=e.fov,this.focus=e.focus,this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this.targetOffset=e.targetOffset,this.updateProjectionMatrix(),this}toCameraState(e=[]){let r={type:this.cameraType,far:this.far,orthographic:{near:this.orthoCamera.near,zoom:this.orthoCamera.zoom},perspective:{near:this.perspCamera.near,fov:this.perspCamera.fov,zoom:this.perspCamera.zoom},up:this.up.toArray(),targetOffset:this.targetOffset,isUpVectorFlipped:this.isUpVectorFlipped};return ta(r,e)}updateCameraSubtype(e,r){let o=e==="perspective"?"PerspectiveCamera":"OrthographicCamera";r.zoom!==void 0&&this.setZoom(o,r.zoom),r.near!==void 0&&this.setNear(o,r.near),r.fov!==void 0&&o==="PerspectiveCamera"&&(this.fov=r.fov)}updateState(e,r){this.updateCameraState(e,r)}updateCameraState(e,r){this.updateState_Entity(e,r),e.far!==void 0&&(this.far=e.far),e.orthographic!==void 0&&this.updateCameraSubtype("orthographic",e.orthographic),e.perspective!==void 0&&this.updateCameraSubtype("perspective",e.perspective),e.type!==void 0&&(this.cameraType=e.type),e.up!==void 0&&this.up.fromArray(e.up),e.targetOffset!==void 0&&(this.targetOffset=e.targetOffset),e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateProjectionMatrix()}updateByPatchedOp(e,r,o){super.updateByPatchedOp(e,r,o),e.path.length===1&&e.type===0&&this.updateCameraSubtype(e.path[0],e.props)}toState(e){return{...super.toState(e),...this.toCameraState(e),type:this.cameraType}}};import{MathUtils as qoe}from"three";import{BufferGeometry as Pv,Matrix4 as Ov,Float32BufferAttribute as IN}from"three";var Ss=new Ov,NN=new Ov;var yr=class extends mr{constructor(e,r,o){super(e,r);this.data=r;this.meshSetAddresses=[];this.needsTransformForDownstream=!1;this.geometry=new Pv;this.onAfterRender=(e,r,o,i,a,s)=>{super.onAfterRender(e,r,o,i,a,s),this.recomputeBoolean()};this.geometry.userData.parameters={width:0,height:0,depth:0}}get booleanOp(){return this.data.geometry.operation}get phongAngle(){return this.data.geometry.phongAngle??45}get isLOD(){return this.recomputeBoolean(),!1}updateByPatchedOp(e,r,o){super.updateByPatchedOp(e,r,o),e.path.length===1&&e.path[0]==="geometry"&&e.type===0&&e.props.operation!==void 0&&(this.freeBooleanPointer(),this.resetBBoxNeedsUpdate())}freeBooleanPointer(){super.freeBooleanPointer(),this.geometry.dispose()}recomputeBoolean(e,r=!0){if(this.booleanMeshSetAddress!==-1&&!e)return;for(let i=0;i<this.children.length;i++){let a=this.children[i];a instanceof yr&&a.dataPatched.visible===!0&&a.recomputeBoolean(e===!0,r)}this.meshSetAddresses=[];for(let i=0;i<this.children.length;i++){let a=this.children[i];if(a instanceof Dt&&a.dataPatched.visible===!0&&a.geometry.attributes.position?.count>0&&a.geometry.drawRange.count>0&&a.booleanMeshSetAddress!==0){Ss.multiplyMatrices(a.hiddenMatrix,a.matrix);try{if(a.booleanMeshSetAddress===-1){if((a.geometry.index??a.geometry.getAttribute("position")).count/3<15e5&&(a.booleanMeshSetAddress=Dr.getMeshSet(a.geometry,e===!0,r)),a.booleanMeshSetAddress===-1)return;Dr.transformMeshSet(a.booleanMeshSetAddress,Ss),a.booleanMatrixInvOld.copy(Ss).invert(),a.booleanWasTransformed=!1}else a instanceof yr&&a.needsTransformForDownstream===!0?(Dr.transformMeshSet(a.booleanMeshSetAddress,Ss),a.needsTransformForDownstream=!1):a.booleanWasTransformed===!0&&(Dr.transformMeshSet(a.booleanMeshSetAddress,NN.multiplyMatrices(Ss,a.booleanMatrixInvOld)),a.booleanMatrixInvOld.copy(Ss).invert(),a.booleanWasTransformed=!1)}catch(s){console.error(s),a.booleanMeshSetAddress=0,a.geometry.userData.booleanOperationDidFail=!0;continue}Dr.hasOpenEdges(a.booleanMeshSetAddress)===!1||i===this.children.length-1&&this.booleanOp===2?(this.meshSetAddresses.push(a.booleanMeshSetAddress),a.geometry.userData.booleanOperationDidFail=!1):a.geometry.userData.booleanOperationDidFail="openEdges"}}if(this.meshSetAddresses.length===0){this.geometry.setAttribute("position",new IN([],0)),this.geometry.setDrawRange(0,0);return}if(e===!0)return Dr.calcBooleanTopological(this.meshSetAddresses,this.booleanOp);let o=this.geometry;o.dispose(),this.geometry=new Pv,this.geometry.userData=o.userData,this.geometry.boundingSphere=o.boundingSphere;try{this.booleanMeshSetAddress=Dr.calcBoolean(this.meshSetAddresses,this.booleanOp,this.geometry,this.phongAngle)}catch(i){this.booleanMeshSetAddress=0,this.geometry.userData.booleanOperationDidFail=!0,console.error(i)}this.booleanMatrixInvOld.copy(this.matrix).invert(),this.needsTransformForDownstream=!0,hs(this),ms(this)}dispose(){super.dispose(),this.geometry.dispose()}};import{Light as DN}from"three";var Cv;(t=>{function n(e){return Re.is(e)&&e instanceof DN}t.is=n})(Cv||(Cv={}));var ws=(n,t)=>class extends Rr(n,t){updateState_Light(r,o){this.updateState_Entity(r,o),r.color!==void 0&&(this.color=o.shared.color(r.color)),r.intensity!==void 0&&(this.intensity=r.intensity),r.depth!==void 0&&(this.shadow.camera.far=r.depth,this.shadow.needsUpdate=!0),r.shadows!==void 0&&(this.castShadow=r.shadows)}};var Ln=n=>n instanceof Dt,Nl=n=>n!==null&&n instanceof yr;var Dl=n=>id.is(n);import{Group as BN}from"three";import{AxesHelper as EN}from"three";var Vr=class extends To(EN){constructor(e,r=15){super(r);this.object=e;this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${e.uuid}`,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.object.isBone&&(this.visible=!1)}raycast(e,r){Mo(this.object,Vr.geometryHelper,e,r)}update(){}};var Rn=class extends Rr(BN,Vr){constructor(t,e){super(),this.super_Entity(t,e),this.objectHelper.update()}updateState(t,e){this.updateState_Entity(t,e),"buffer"in t&&Object.keys(t).length===1&&e.scene.reloadSplats()}};import{Group as LN}from"three";var sd=class extends Rr(LN,Vr){constructor(e,r,o){super();this.super_Entity(e,r),this.context=o,this.objectHelper.update()}updateState(e,r){this.updateState_Entity(e,r)}};import{Color as sD,Fog as lD,HemisphereLight as cD}from"three";import{ShaderChunk as El}from"three";var RN=n=>`
2241
+ `)>=0&&(t-=i),r===3?e*.5-t*.5:r===2?e-t:0}getLineInitialOffsetY(t,e,r,o,i){let a=e*t,s=Math.abs(this.ascender-this.descender)*o,l=t-s,u=-this.ascender*o-l/2;return i===3?-(r-a-u):i===2?-(r*.5-a*.5-u):u}createPath(t,e,r,o,i){let a=t.getPath(r,-o,i.fontSize,{kerning:!1,letterSpacing:i.letterSpacing});if(!a){console.error('THREE.Font: character "'+t+'" does not exists in font family '+this.familyName+".");return}let s=new Xu,l=(t.advanceWidth??1)*e;if(t)for(let u of a.commands){let c=s.currentPath?.currentPoint;if(!(c&&u.type!=="Z"&&c.x===u.x&&-c.y===u.y))switch(u.type){case"M":s.moveTo(u.x,-u.y);break;case"L":s.lineTo(u.x,-u.y);break;case"Q":s.quadraticCurveTo(u.x1,-u.y1,u.x,-u.y);break;case"C":s.bezierCurveTo(u.x1,-u.y1,u.x2,-u.y2,u.x,-u.y);break}}return s.subPaths.forEach(u=>{let c=$3(u.curves);c!==void 0&&u.currentPoint.distanceTo(c)>0&&u.lineTo(c.x,c.y)}),{offsetX:l+i.fontSize*i.letterSpacing,path:s}}getCharWidth(t,e){return this.font?.getAdvanceWidth(t,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}getTextWidth(t,e){return this.font?.getAdvanceWidth(t,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}computeSpaceWidthForLine(t,e,r){let o=this.getCharWidth(" ",r),i=t[e];if(i){let a=this.countSpaces(i.trimEnd());if(r.horizontalAlign===4&&e<t.length-1&&a){let s=r.width,l=this.getTextWidth(i,r);return(s-(l-a*o))/a}}return o}countSpaces(t){return(t.match(/ /g)||[]).length}};function $3(n){if(n.length){let t=n[0];if(t instanceof H3)return t.v1;if(t instanceof U3||t instanceof q3)return t.v0}}var nh=class{constructor(){this.objects=new Map;this.unreachable=new Set}getCached(t){return this.objects.get(t)}get size(){return this.objects.size}get(t,e,r){let o=this.objects.get(t);return o===void 0?(o=this.createObject(t,e,r),this.objects.set(t,o)):o.isShared=!0,o}forceDelete(t){let e=this.objects.get(t);e&&(this.disposeObject(e),this.objects.delete(t))}mutateIfUnique(t,e){let r=this.objects.get(t);if(r&&r.isShared!==!0)return this.objects.delete(t),this.objects.set(e,r),r}startGc(){this.unreachable=new Set(this.objects.keys())}markAsReachable(t,e){let r=this.objects.get(t);e===r?this.unreachable.delete(t):!1&&console.warn("Reachable but deleted",t)}endGc(){this.unreachable.forEach(t=>{this.disposeObject(this.objects.get(t)),this.objects.delete(t)}),this.unreachable.clear()}dispose(){this.objects.forEach(t=>{this.disposeObject(t)}),this.objects.clear()}},Ol=class extends nh{constructor(e){super();this.flatShading=e}disposeObject(e){e.dispose()}createObject(e,r,o){let i=Qo(e,r,this.flatShading,o);return i.computeBoundingSphere(),i}};var Yb={markNeedsUpdateRendererDirty:()=>{}};import{MathUtils as Xb}from"three";var ih=class extends Hu{constructor(e){super();this.shared=e}create(e){return new fs(e,this.shared)}},xi=class{constructor(t,e={}){this.data=t;this.geometryCache=new Ol(!0);this.geometryCache2=new Ol(!1);this.imageHolderCache=new ih(this);this.thisContext={scene:Yb,shared:this};this.deletedMaterial=new mi(Wt.defaultTwoLayerData("phong"),this.thisContext,"");this.deletedImage=new _r(va.emptyImage,this);this.deletedVideo=new _r(pa.defaultVideo,this);this.materials={};this.images={};this.canvases={};this.videos={};this.colors={};this.audios={};this.particles={};this.fonts={};this.variables={};this.mouseProperty=null;this.raycastProperty=null;this.requestRender=()=>{this._requestRender&&this._requestRender()};if(e.images)for(let[r,o]of Object.entries(e.images))this.addImage(r,o);if(e.videos)for(let[r,o]of Object.entries(e.videos))this.addVideo(r,o);if(e.audios)for(let[r,o]of Object.entries(e.audios))this.addAudio(r,o);if(e.particles)for(let[r,o]of Object.entries(e.particles))this.addParticle(r,o);this.reset(t)}setRequestRender(t){this._requestRender=t}setEntityOpContext(t){this.entityOpContext=t}reset(t,e=!1){this.resetLib(t.lib);for(let{id:r,data:o}of t.variables)this.addVariableHolder(r,o),e&&this.updateVariableHolder(r,o);for(let[r,o]of Object.entries(t.images))this.addImage(r,o);for(let[r,o]of Object.entries(t.videos))this.addVideo(r,o);for(let[r,o]of Object.entries(t.colors))this.addColor(r,o);for(let[r,o]of Object.entries(t.materials))this.addMaterial(r,o);for(let[r,o]of Object.entries(t.audios))this.addAudio(r,o);for(let[r,o]of Object.entries(t.particles))this.addParticle(r,o);for(let[r,o]of Object.entries(t.fonts))this.addFont(r,o)}addMaterial(t,e){if(this.materials[t]){let r=this.materials[t];r.reset(e,this.thisContext),r.dispose()}else{let r=new mi(e,this.thisContext,t);this.materials[t]=r}}deleteMaterial(t){this.materials[t]&&(this.materials[t].nodeMaterialDispose(),delete this.materials[t])}getMaterial(t){let e=this.materials[t];return e}getMaterialOrDeletedPlaceholder(t){return this.materials[t]??this.deletedMaterial}material(t){return typeof t=="string"?this.getMaterialOrDeletedPlaceholder(t):t==null?(console.error("material is undefined or null"),this.deletedMaterial):new hi(t,this.thisContext)}getMaterials(){return this.materials}addImage(t,e){return this.images[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.images[t].updateSrc(e.data),!0):(this.images[t]=new _r(e,this),!1)}deleteImage(t){let e=this.images[t];e&&(e.dispose(),delete this.images[t])}getDefaultImage(){return this.images.image_0}getImage(t){return this.images[t]??this.deletedImage}image(t){return typeof t=="string"?this.getImage(t):this.imageHolderCache.load(t)}addCanvas(t,e){return this.canvases[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.canvases[t].updateSrc(e),!0):(this.canvases[t]=new _r(e,this),!1)}canvas(t){return this.canvases[t]}addVideo(t,e){return this.videos[t]?(this.videos[t].updateSrc(e.data),!0):(this.videos[t]=new _r(e,this),!1)}deleteVideo(t){let e=this.videos[t];e&&(e.dispose(),delete this.videos[t])}getVideo(t){return this.videos[t]??this.deletedVideo}video(t){return typeof t=="string"?this.getVideo(t):this.imageHolderCache.load(t)}addColor(t,e){return this.colors[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),"a"in e?this.colors[t].setRGBA(e.r,e.g,e.b,e.a):this.colors[t].setRGBA(e.r,e.g,e.b,1),!0):("a"in e?this.colors[t]=new Dn(e.r,e.g,e.b,e.a):this.colors[t]=new Dn(e.r,e.g,e.b,1),!1)}updateColor(t,e){if(this.colors[t]){this.onColorOrImageUpdate&&this.onColorOrImageUpdate();let r=this.colors[t];return this.colors[t].r=e.r??r.r,this.colors[t].g=e.g??r.g,this.colors[t].b=e.b??r.b,this.colors[t].a=e.a??r.a,!0}return!1}deleteColor(t){this.colors[t]&&delete this.colors[t]}getColor(t){return this.colors[t]}color(t){let e;if(typeof t=="string"){let r=this.getColor(t);r?e=r:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),e=new Bt(0,0,0,0))}else return"a"in t?new Bt(t.r,t.g,t.b,t.a):new Bt(t.r,t.g,t.b,1);return e}addAudio(t,e){this.audios[t]=e}getAudio(t){let e=this.audios[t];if(e instanceof yi)return e;{let r=new yi({src:e.data});return this.audios[t]=r,r}}addParticle(t,e){this.particles[t]=e}getParticle(t){return this.particles[t]}deleteParticle(t){this.particles[t]&&delete this.particles[t]}deleteAudio(t){let e=this.audios[t];e&&(e instanceof yi&&e.dispose(),delete this.audios[t])}addFont(t,e){this.fonts[t]=new Ku(e),this.fonts[t].loadingPromise.then(()=>this.requestRender())}getFont(t){return this.fonts[t]}deleteFont(t){this.fonts[t]&&delete this.fonts[t]}dispose(){Object.keys(this.materials).forEach(e=>this.deleteMaterial(e)),this._requestRender=void 0,Object.values(this.audios).forEach(e=>{e instanceof yi&&e.dispose()}),this.audios={},this.particles={},this.geometryCache.dispose(),this.geometryCache2.dispose()}addVariableHolder(t,e){return this.variables[t]===void 0?(this.variables[t]={value:e.value,locations:[]},"dynamicVariableType"in e&&(this.variables[t].dynamicVariablePlayState="Playing",this.variables[t].dynamicVariableToggleIsForward=void 0),!0):(this.variables[t].value=e.value,!1)}resetDynamicVariablePlayState(){for(let t in this.variables)this.variables[t].dynamicVariablePlayState!==void 0&&(this.variables[t].dynamicVariablePlayState="Playing",this.variables[t].dynamicVariableToggleIsForward=void 0)}updateVariableHolder(t,e){this.updateVariable(t,e.value)}updateVariable(t,e){if(this.variables[t]===void 0)return!1;this.variables[t].value=e;let r=e;for(;typeof r=="string";)r=this.variables[r].value;let o=this.entityOpContext.scene;for(let i=this.variables[t].locations.length-1;i>=0;i--){let a=this.variables[t].locations[i];if(a[0]==="material"){let s=a[1],l=r,u={scene:o,shared:this},c=a.slice(2);o.traverseMaterial(p=>{let f=p.root??p;f.uuid===s&&f.onVariableUpdate(c,l,u)});let d=this.materials[s];d&&d.onVariableUpdate(c,l,u)}else{let s=o.find(a[0]);if(s===void 0){this.variables[t].locations.splice(i,1);continue}if(a[1]!=="geometry"&&a[1]!=="particles"){for(let l=1;l<a.length-1;l++)s=s[a[l]];a[1]==="rotation"?s[a[a.length-1]]=r*Xb.DEG2RAD:s[a[a.length-1]]=r}if(s=o.find(a[0]),s.type==="ParticleEmitter"&&s.updateVariableState(r,a),Re.is(s)){if(a[1]==="position"||a[1]==="rotation"||a[1]==="scale")s.onVariableUpdate();else if(a[1]==="geometry"){let l=s;s.component&&(l=s.component);let u=l.dataPatched;l.chooseGeoemtryCache(this).forceDelete(u.geometry),l.createGeometryDelayed(this.entityOpContext),l.onVariableUpdate(!0),l.instances.forEach(c=>{let d=c.dataPatched;c.chooseGeoemtryCache(this).forceDelete(d.geometry),c.createGeometryDelayed(this.entityOpContext),c.onVariableUpdate(!0)})}}}}return this.requestRender(),!0}deleteVariable(t){this.variables[t]&&delete this.variables[t]}getVariable(t,e){if(Array.isArray(t)){if(t[0]==="mouse")return this.mouseProperty?.[t[1]]??0;if(t[0]==="raycast")return this.raycastProperty?.[t[1]]??0;let r=this.entityOpContext.scene.find(t[0]);if(t[1]==="width"||t[1]==="height"||t[1]==="depth")return r.geometry.userData.parameters[t[1]];for(let o=1;o<t.length;o++)r=r[t[o]];return t[1]==="rotation"&&(r*=Xb.RAD2DEG),r}for(let r in this.variables){if(e===void 0)break;let o=this.variables[r],i=o.locations?.findIndex(a=>lt.equal(a,e));i!==void 0&&i!==-1&&o.locations.splice(i,1)}if(typeof t=="string"){let r=t,o=t;do{if(o=r,this.variables[r]===void 0)break;r=this.variables[r].value}while(typeof r=="string");return e&&this.variables[o]!==void 0&&this.variables[o].locations.push(e),r}else return t}getVariables(){return this.variables}getDynamicVariablePlayState(t){return this.variables[t]?.dynamicVariablePlayState}setDynamicVariablePlayState(t,e){this.variables[t]!==void 0&&(this.variables[t].dynamicVariablePlayState=e)}getDynamicVariableToggleIsForward(t){return this.variables[t]?.dynamicVariableToggleIsForward}setDynamicVariableToggleIsForward(t,e){this.variables[t]!==void 0&&(this.variables[t].dynamicVariableToggleIsForward=e)}resetLib(t){for(let[e,r]of Object.entries(t.images))this.addImage(e,r.asset);for(let[e,r]of Object.entries(t.audios))this.addAudio(e,r.asset);for(let[e,r]of Object.entries(t.particles))this.addParticle(e,r.asset);for(let[e,r]of Object.entries(t.colors))this.addColor(e,r.asset);for(let[e,r]of Object.entries(t.fonts))this.addFont(e,r.asset);for(let[e,r]of Object.entries(t.materials))this.addMaterial(e,r.asset);for(let[e,r]of Object.entries(t.videos))this.addVideo(e,r.asset);for(let[e,r]of Object.entries(t.variables))this.addVariableHolder(e,r.asset)}updateLibByOp(t,e){t.path[0]==="images"?t.path.length===1&&t.type===1?this.addImage(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteImage(t.id):t.path[0]==="videos"?t.path.length===1&&t.type===1?this.addVideo(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteVideo(t.id):t.path[0]==="audios"?t.path.length===1&&t.type===1?this.addAudio(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteAudio(t.id):t.path[0]==="particles"?t.path.length===1&&t.type===1?this.addParticle(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteParticle(t.id):t.path[0]==="colors"?t.path.length===1&&t.type===1?this.addColor(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteColor(t.id):t.path[0]==="materials"?t.path.length===1&&t.type===1?this.addMaterial(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteMaterial(t.id):t.path[0]==="fonts"?t.path.length===1&&t.type===1?this.addFont(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteFont(t.id):t.path[0]==="variables"?t.path.length===1&&t.type===1?this.addVariableHolder(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteVariable(t.id):t.path[0]==="components"&&e.updateByLibOp(t,this)}updateByOp(t,e,r){this.data=e,t.path[0]==="images"?t.path.length===2&&t.type===0?t.props.data&&this.getImage(t.path[1]).updateSrc(t.props.data):t.path.length===1&&t.type===1?this.addImage(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteImage(t.id):t.path[0]==="videos"?t.path.length===2&&t.type===0?t.props.data&&this.getVideo(t.path[1]).updateSrc(t.props.data):t.path.length===1&&t.type===1?this.addVideo(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteVideo(t.id):t.path[0]==="audios"?t.path.length===2&&t.type===0?t.props.data&&this.addAudio(t.path[1],e.audios[t.path[1]]):t.path.length===1&&t.type===1?this.addAudio(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteAudio(t.id):t.path[0]==="particles"?t.path.length===2&&t.type===0?t.props.data&&this.addParticle(t.path[1],e.particles[t.path[1]]):t.path.length===1&&t.type===1?this.addParticle(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteParticle(t.id):t.path[0]==="colors"?t.path.length===2&&t.type===0?this.updateColor(t.path[1],t.props):t.path.length===1&&t.type===1?this.addColor(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteColor(t.id):t.path[0]==="materials"?t.path.length===1&&t.type===1?this.addMaterial(t.id,t.data):t.path.length===1&&t.type===2?this.deleteMaterial(t.id):t.path.length>1&&this.getMaterial(t.path[1]).updateByOp(ct.drop(t,2),e.materials[t.path[1]],{shared:this,scene:r}):t.path[0]==="fonts"?t.path.length===2&&t.type===0?this.updateFont(t.path[1],t,r):t.path.length===1&&t.type===1?this.addFont(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteFont(t.id):t.path[0]==="variables"?t.path.length===2&&t.type===0&&"value"in t.props?this.updateVariable(t.path[1],t.props.value):t.path.length===1&&t.type===4?this.addVariableHolder(t.id,t.data):t.path.length===1&&t.type===5&&this.deleteVariable(t.id):t.path[0]==="lib"&&this.updateLibByOp(ct.drop(t,1),r)}updateFont(t,e,r){if(e.props.url){let o=this.getFont(t),i={...this.data.fonts[t],url:e.props.url};o.update(i),o.loadingPromise.then(()=>this.requestRender()),r.updateFont(t,this)}}},Qb=new xi(Nr.emptyData());var mr=class extends Dt{updateByPatchedOp(e,r,o){if(super.updateByPatchedOp(e,r,o),Eg(e.path,["materials"])!==null&&e.type===0&&Array.isArray(this.material))for(let[i,a]of Object.entries(e.props)){let s=o.shared.material(a);this.material[Number(i)]=s}else if(Le(e.path,["material"])&&this.material instanceof hr)"material"in r&&typeof r.material!="string"&&this.material.updateByOp(ct.drop(e,1),r.material,o);else if(Le(e.path,["materials","*"])&&Array.isArray(this.material)){let i=e.path[1];if("materials"in r&&i<this.material.length){let a=r.materials[i];typeof a!="string"&&this.material[i].updateByOp(ct.drop(e,2),a,o)}}}get needsAO(){return this.material!==void 0?(Array.isArray(this.material)?this.material[0]:this.material).hasAO:!1}updateState(e,r){super.updateState(e,r),e.castShadow!==void 0&&(this.castShadow=e.castShadow),e.receiveShadow!==void 0&&(this.receiveShadow=e.receiveShadow);let o=this.dataPatched;if(e.geometry?.type!=="NonParametricGeometry"&&"material"in e&&e.material!==void 0&&(this.disposeMaterial(),this.material=r.shared.material(e.material).getFlavor(o.flatShading,o.side,o.wireframe),r.scene.markNeedsUpdateRendererDirty()),(e.geometry?.type==="NonParametricGeometry"||"materials"in e)&&("materials"in e&&e.materials!==void 0?(this.disposeMaterial(),this.material=e.materials.map(i=>r.shared.material(i).getFlavor(o.flatShading,o.side,o.wireframe)),r.scene.markNeedsUpdateRendererDirty()):"material"in e&&e.material!==void 0&&(this.disposeMaterial(),this.material=[r.shared.material(e.material).getFlavor(o.flatShading,o.side,o.wireframe)],r.scene.markNeedsUpdateRendererDirty())),e.flatShading!==void 0||e.wireframe!==void 0||e.side!==void 0)if(Array.isArray(this.material))for(let i=0;i<this.material.length;i++)this.material[i]=this.material[i].getFlavor(o.flatShading,o.side,o.wireframe);else this.material=this.material.getFlavor(o.flatShading,o.side,o.wireframe)}disposeMaterial(){this.material&&Xl(this.material).forEach(e=>{e instanceof hr&&(e instanceof mi||e.nodeMaterialDispose())})}dispose(){this.disposeMaterial(),super.dispose()}};import{BufferGeometry as X3,Matrix4 as ah,Vector3 as tv,Vector4 as sh}from"three";var Kb=new tv,Zb=new sh,Jb=new sh,Q3=new tv,ev=new ah,ft=class extends mr{constructor(e,r,o){super(e,r);this.data=r;this.isSkinnedMesh=!1;this.localGeometry=void 0,r.bindMode&&r.bindMatrix&&(this.bindMode=r.bindMode,this.bindMatrix=new ah().fromArray(r.bindMatrix),this.bindMatrixInverse=new ah)}chooseGeoemtryCache(e){return e.geometryCache}markGeometryAsReachable(e){this.geometryCreateDeleyed instanceof X3&&this.chooseGeoemtryCache(e).markAsReachable(this.dataPatched.geometry,this.geometryCreateDeleyed)}get geometry(){if(this.localGeometry!==void 0)return this.localGeometry;if(this.geometryCreateDeleyed instanceof xi){let e=this.geometryCreateDeleyed,r=this.chooseGeoemtryCache(e);this.geometryCreateDeleyed=r.get(this.dataPatched.geometry,e,this)}return this.geometryCreateDeleyed}set geometry(e){this.localGeometry=e}get is2DAndNoDepth(){let e=this.dataPatched.geometry;return $s.is2DParametricMesh(e.type)&&e.depth===0}get is2DType(){return $s.is2DParametricMesh(this.geometry.userData.type)}get isNonParametric(){return this.geometry.userData.type==="NonParametricGeometry"}updateByPatchedOp(e,r,o){super.updateByPatchedOp(e,r,o),Le(e.path,["geometry"])&&this.updateByPatchedOpGeometry(ct.drop(e,1),r.geometry,o)}removeInteractionGeometry(e){this.localGeometry?.dispose(),this.localGeometry=void 0}updateGeometryInteractions(e,r){this.invalidateDownstreamBooleanData();let o=this.data.geometry.type;if(o==="NonParametricGeometry"||o==="SubdivGeometry"){let i=e;if(this.localGeometry===void 0){let c={...this.data.geometry,...i};this.localGeometry=Qo(c,r,this.data.flatShading,this)}let a,s,l;i.scaleBaked?[a,s,l]=i.scaleBaked:{width:a,height:s,depth:l}=i;let u=this.localGeometry.userData;u.sxPrev!==void 0&&fl(this.localGeometry.attributes,a/u.sxPrev,s/u.syPrev,l/u.szPrev),u.sxPrev=a,u.syPrev=s,u.szPrev=l}else{let i={...this.data.geometry,...e};this.localGeometry?.dispose(),this.localGeometry=Qo(i,r,this.data.flatShading,this)}}refreshAttachedCloners(e){for(let r of this.attachedSurfaceCloners)e.scene.addPendingUpdateCloner(r.object)}refreshAttachedPaths(e){for(let r of this.attachedPaths)e.scene.addPendingCommand(()=>r.updateShape())}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.refreshAttachedCloners(e),this.refreshAttachedPaths(e)}updateByPatchedOpGeometry(e,r,o){let i=!1;e.type===0&&e.path.length===0&&Object.keys(e.props).includes("scaleBaked")&&this.geometryCreateDeleyed instanceof wt&&this.chooseGeoemtryCache(o.shared).mutateIfUnique(this.geometryCreateDeleyed.data,r)===this.geometryCreateDeleyed&&(i=!0,this.geometryCreateDeleyed.mutateDirectlyScaleBaked(r,e.props.scaleBaked),this.refreshAttachedCloners(o),this.refreshAttachedPaths(o)),i||(o.scene?.markGeometryCacheDirty(),this.createGeometryDelayed(o)),this.resetBBoxNeedsUpdate(),this.invalidateDownstreamBooleanData()}updateGeometryOnStateUpdate(e,r){this.createGeometryDelayed(r)}updateState(e,r){e.geometry!==void 0&&this.updateGeometryOnStateUpdate(e.geometry,r),super.updateState(e,r)}updateGeometryGroupsIfNeeded(){Array.isArray(this.material)&&this.geometry.groups.length===0&&this.geometry.addGroup(0,Math.max(this.geometry.getIndex()?.count??0,this.geometry.getAttribute("position").count),0)}updateEntityBoxSize(e,r){let o=this.geometry.userData.parameters;this.is2DType?e.set(0,0,o.depth*.5):this.isNonParametric?(e.setScalar(0),this.geometry.boundingSphere&&e.copy(this.geometry.boundingSphere.center),r.set(o.width,o.height,o.depth??0).multiplyScalar(.5)):e.setScalar(0),r.set(o.width,o.height,o.depth??0).multiplyScalar(.5)}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode==="attached"?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode==="detached"&&this.bindMatrixInverse.copy(this.bindMatrix).invert()}bind(e,r){this.skeleton=e,this.isSkinnedMesh=!0,r===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),r=this.matrixWorld),this.bindMatrix.copy(r),this.bindMatrixInverse.copy(r).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(e){let r=new sh,o=this.geometry.attributes.skinWeight;for(let i=0,a=o.count;i<a;i++){r.fromBufferAttribute(o,i);let s=1/r.manhattanLength();s!==1/0?r.multiplyScalar(s):r.set(1,0,0,0),o.setXYZW(i,r.x,r.y,r.z,r.w)}}boneTransform(e,r){let o=this.skeleton;if(o===void 0)return;let i=this.geometry;Zb.fromBufferAttribute(i.attributes.skinIndex,e),Jb.fromBufferAttribute(i.attributes.skinWeight,e),Kb.copy(r).applyMatrix4(this.bindMatrix),r.set(0,0,0);for(let a=0;a<4;a++){let s=Jb.getComponent(a);if(s!==0){let l=Zb.getComponent(a);ev.multiplyMatrices(o.bones[l].matrixWorld,o.boneInverses[l]),r.addScaledVector(Q3.copy(Kb).applyMatrix4(ev),s)}}return r.applyMatrix4(this.bindMatrixInverse)}};function Z3(n){if(n.geometry.attributes.extrudeNormal||!n.geometry.attributes.position||!n.geometry.attributes.normal)return;let t=new Map,e=n.geometry.attributes,r=e.position.array,o=e.normal.array,i=new Float32Array(r.length);for(let a=0;a<r.length;a+=3){let s=`${r[a]}_${r[a+1]}_${r[a+2]}`,l=new ch(o[a],o[a+1],o[a+2]);t.has(s)?t.get(s)?.normals.push(l):t.set(s,{normals:[l],result:new ch})}t.forEach((a,s)=>{for(let l of a.normals)a.result.add(l);a.result.divideScalar(a.normals.length)});for(let a=0;a<r.length;a+=3){let s=`${r[a]}_${r[a+1]}_${r[a+2]}`,l=t.get(s)?.result;l&&(i[a]=l.x,i[a+1]=l.y,i[a+2]=l.z)}n.geometry.setAttribute("extrudeNormal",new rv(i,3))}function J3(n){if(n.geometry.attributes.extrudeNormals||!n.geometry.attributes.position)return;let e=n.geometry.attributes.position.array,r=new Float32Array(e.length),o=new ch;for(let i=0;i<e.length;i+=3)o.set(e[i],e[i+1],e[i+2]).normalize(),r[i]=o.x,r[i+1]=o.y,r[i+2]=o.z;n.geometry.setAttribute("extrudeNormal",new rv(r,3))}function ms(n){if(Array.isArray(n.material)){for(let t of n.material)if(t.getLayersOfType("outline").length===0)return}else if(!(n.material instanceof hr)||n.material.getLayersOfType("outline").length===0)return;n instanceof ft&&n.is2DAndNoDepth?J3(n):Z3(n)}function ys(n){if(!n.geometry.attributes.position)return;let e=n.geometry.attributes.position.array,r=new Float32Array(e.length),o=parseInt(n.uuid.replace(/\D/g,"")),i=[lh.seededRandom(o),lh.seededRandom(o+1e4),lh.seededRandom(o+2e4)];for(let a=0;a<e.length;a++)r[a]=i[a%3];n.geometry.setAttribute("randomColor",new K3(r,3))}var Oo=new eN,Cl=new rN;function nv(n){let t=!1;return n.scene.objects.traverse((e,r)=>{r.type==="Mesh"&&r.geometry.type==="SubdivGeometry"&&(t=!0)}),t}var bi=class extends ft{constructor(e,r,o){super(e,r,o);this.data=r;this.hiddenMatrixOld=new tN;this.smoothShading=!0;this.skipReactionUpdate=!1}chooseGeoemtryCache(e){return this.dataPatched.flatShading?e.geometryCache:e.geometryCache2}get subdivPointerNew(){return this.localGeometry!==void 0?this.subdivPointer:this.geometry.ensureSubdivPointer()}get originalGeometryNew(){return this.localGeometry!==void 0?this.originalGeometry:this.geometry.originalGeometry}get phongAngle(){return this.data.geometry.phongAngle??45}updateEntityBoxSize(e,r){let o=this.geometry.userData.parameters;e.copy(this.originalGeometryNew.boundingSphere.center),r.set(o.width,o.height,o.depth??0).multiplyScalar(.5)}createGeometryByControls(e){if(this.skipReactionUpdate===!0)return;let r=this.localGeometry?.uuid,{originalGeometry:o,subdividedGeometry:i,subdivPointer:a}=wt.build(e,this.subdivPointer,this.smoothShading,this.hasNonUniformScale?this.shearScale:void 0);this.subdivPointer=a,o!==void 0&&(this.originalGeometry?.dispose(),this.originalGeometry=o),i!==void 0&&(this.subdividedGeometry?.dispose(),this.subdividedGeometry=i??void 0),this.localGeometry=this.subdividedGeometry??this.originalGeometry,ms(this),ys(this),this.calcBoundingBox(),r&&(this.localGeometry.uuid=r)}updateState(e,r){if(super.updateState(e,r),e.flatShading!==void 0){let o=this.material;this.material=Array.isArray(o)?o.map(i=>i.getFlavor(!1,i.side,i.wireframe)):o.getFlavor(!1,o.side,o.wireframe),this.smoothShading=!e.flatShading,this.createGeometryDelayed(r)}}updateMesh(e=!1){wt.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1,this.originalGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0),this.subdividedGeometry&&wt.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1,this.subdividedGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0)}updateTopology(){this.originalGeometry.dispose(),this.originalGeometry=wt.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=wt.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1)),this.localGeometry=this.subdividedGeometry??this.originalGeometry}raycast(e,r){let o=this.localGeometry;this.localGeometry=this.originalGeometryNew,Dt.prototype.raycast.call(this,e,r),this.localGeometry=o}activateSVDCompensation(){!this.hasNonUniformScale||(this.matrix.copy(this.matrixWorldRigid),this.hiddenMatrixOld.copy(this.hiddenMatrix),this.hiddenMatrix.copy(this.parent.matrixWorld).invert())}deactivateSVDCompensation(){!this.hasNonUniformScale||(this.updateMatrix(),this.hasNonUniformScale=void 0,this.hiddenMatrix.copy(this.hiddenMatrixOld))}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new ov,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,o=e.boundingSphere.center;Oo.setFromBufferAttribute(r),Oo.getCenter(o),e.boundingSphere.radius=o.distanceTo(Oo.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Oo.getSize(Cl),this.hasNonUniformScale&&Cl.divide(this.scale);let i={width:Cl.x,height:Cl.y,depth:Cl.z};return this.geometry.userData.parameters=i,i}updateBoundingSphere(e){let r=this.originalGeometry;Oo.min.set(e[0],e[2],e[4]),Oo.max.set(e[1],e[3],e[5]),this.hasNonUniformScale&&(Oo.min.applyMatrix4(this.shearScaleInv),Oo.max.applyMatrix4(this.shearScaleInv)),r.boundingSphere===null&&(r.boundingSphere=new ov);let o=r.boundingSphere.center;Oo.getCenter(o),r.boundingSphere.radius=o.distanceTo(Oo.max)}freeSubdivPointer(){this.subdivPointer&&(wt.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0),this.localGeometry=void 0,this.originalGeometry?.dispose(),this.subdividedGeometry?.dispose()}dispose(){super.dispose(),this.freeSubdivPointer()}updateByPatchedOpGeometry(e,r,o){super.updateByPatchedOpGeometry(e,r,o),this.localGeometry&&this.createGeometryByControls(r)}};import{Triangle as oN,Vector3 as Si}from"three";var iv=-1,nN=1,av={x:[1,0,0],"-x":[-1,0,0],y:[0,1,0],"-y":[0,-1,0],z:[0,0,1],"-z":[0,0,-1]},sv={polygon_center:0,edge:1,vertex:2},Tl=(n,t)=>(e,r)=>!t||e===0||n===0?0:n*r/100,Ce=(n,t)=>{let e=Math.abs(t),r=e*-1;return(n-iv)*(e-r)/(nN-iv)+r};function lv(n){let t=[],e={};for(var r=0,o=n.length;r<o;r++){var i=JSON.stringify(n[r].pos.map(a=>Math.round(a*1e4)/1e4));e[i]||(t.push(n[r]),e[i]=!0)}return t}var iN=new Si,Zu=new Si,aN=new Si,sN=new Si;function gs(n,t){let e=aN.fromArray(n),r=sN.fromArray(t);Zu.copy(r).sub(e);let o=Zu.length();return Zu.normalize().multiplyScalar(o*.5),iN.copy(e).add(Zu).toArray()}var Br=new oN,Ju=new Si,ed=new Si,vi=new Si;function cv(n){let t=[];for(let e=0;e<=n.index.count;e++)if(Ju.fromArray(n.index.array,e*3),Br.setFromAttributeAndIndices(n.attributes.position,Ju.x,Ju.y,Ju.z),Br.getNormal(ed),Br.getMidpoint(vi),!(isNaN(vi.x)||isNaN(vi.y)||isNaN(vi.z))){let{a:r,b:o,c:i}=Br,a=r.toArray(),s=o.toArray(),l=i.toArray(),u=r.distanceTo(o),c=o.distanceTo(i),d=i.distanceTo(r),p=gs(a,s),f=gs(s,l),h=gs(l,a),m=[u,c,d],y=Math.max(...m),g=m.filter(A=>Math.round(A)===Math.round(y)).length>1,b=[],w=Br.getMidpoint(vi).toArray();y===u&&!g&&(b=[f,h,h],w=p),y===c&&!g&&(b=[p,h,h],w=f),y===d&&!g&&(b=[p,f,f],w=h),g&&(b=[p,f,h]),t.push({vertices:[a,s,l],faceCenters:b,midpoint:w,norm:Br.getNormal(ed).toArray()})}return t}function uv(n){let t=[],{position:e}=n.attributes;for(let r=0;r<e.count;r++){Br.setFromAttributeAndIndices(e,r*3,r*3+1,r*3+2),Br.getNormal(ed),Br.getMidpoint(vi);let o=Br.a.toArray(),i=Br.b.toArray(),a=Br.c.toArray();t.push({vertices:[o,i,a],faceCenters:[gs(o,i),gs(i,a),gs(a,o)],midpoint:vi.toArray(),norm:ed.toArray()})}return t}var lN=4,cN=.5,uh=n=>.5*(1-Math.cos(n*Math.PI)),dh=class{constructor(){this.perlin=new Array(4095+1)}noise(t,e=0,r=0){if(this.perlin==null){this.perlin=new Array(4095+1);for(let g=0;g<4095+1;g++)this.perlin[g]=Math.random()}t<0&&(t=-t),e<0&&(e=-e),r<0&&(r=-r);let o=Math.floor(t),i=Math.floor(e),a=Math.floor(r),s=t-o,l=e-i,u=r-a,c,d,p=0,f=.5,h,m,y;for(let g=0;g<lN;g++){let b=o+(i<<4)+(a<<8);c=uh(s),d=uh(l),h=this.perlin[b&4095],h+=c*(this.perlin[b+1&4095]-h),m=this.perlin[b+16&4095],m+=c*(this.perlin[b+16+1&4095]-m),h+=d*(m-h),b+=256,m=this.perlin[b&4095],m+=c*(this.perlin[b+1&4095]-m),y=this.perlin[b+16&4095],y+=c*(this.perlin[b+16+1&4095]-y),m+=d*(y-m),h+=uh(u)*(m-h),p+=h*f,f*=cN,o<<=1,s*=2,i<<=1,l*=2,a<<=1,u*=2,s>=1&&(o++,s--),l>=1&&(i++,l--),u>=1&&(a++,u--)}return p}noiseSeed(t){let e=(()=>{let a,s;return{setSeed(l){s=a=(l??Math.random()*4294967296)>>>0},getSeed(){return a},rand(){return s=(1664525*s+1013904223)%4294967296,s/4294967296}}})();e.setSeed(t),this.perlin=new Array(4095+1);for(let r=0;r<4095+1;r++)this.perlin[r]=e.rand()}},dv=dh;import{Vector3 as uN,Matrix4 as dN,Ray as pN}from"three";var pv=new uN,fv=new dN,hv=new pN;function mv(n){let t=!1;return n.scene.objects.traverse((e,r)=>{r.type==="Mesh"&&r.geometry.type==="TextGeometry"&&(t=!0)}),t}var xs=class extends ft{constructor(e,r,o){super(e,r,o);this.data=r}get textGeometry(){return this.geometry}get charWidths(){return this.textGeometry.charWidths}get charCoords(){return this.textGeometry.charCoords}get wrappedText(){return this.textGeometry.wrappedText}get font(){return this.textGeometry.font}get initialOffsetY(){let e=this.dataPatched;return this.font?.getLineInitialOffsetY(this.lineHeight,this.wrappedText.length,e.geometry.height,this.fontScale,e.geometry.verticalAlign)??0}get fontScale(){let e=this.dataPatched;return this.font?e.geometry.fontSize/this.font.unitsPerEm:1}get AD(){return Math.abs(this.ascender-this.descender)}get ascender(){return(this.font?.ascender??1)*this.fontScale}get descender(){return(this.font?.descender??1)*this.fontScale}get lineHeight(){let e=this.dataPatched;return e.geometry.fontSize*e.geometry.lineHeight}raycast(e,r){let{matrixWorld:o}=this;if(!(isNaN(e.ray.origin.x)||this.scale.x===0||this.scale.y===0||this.scale.z===0)&&(fv.copy(o).invert(),hv.copy(e.ray).applyMatrix4(fv),hv.intersectBox(this.singleBBox,pv))){let i=pv.applyMatrix4(o),a=e.ray.origin.distanceTo(i);r.push({distance:a,point:i.clone(),object:this})}}};var sr=1e-4,Co,bv,vv,Sv,gv=new Pr,xv=new Pr;Bu.then(n=>{Co=n,bv=[Co.get_face_center,Co.get_edge_midpoint,Co.get_vertex_position],vv=[Co.get_face_normal,Co.get_edge_normal,Co.get_vertex_normal],Sv=[Co.face_count,Co.edge_count,Co.vertex_count]});var hN=new wi,mN=new wi,Bn=new Pr,td=new Pr,Ml=new Pr,fh=new Pr,yN=new Pr,gN=new Pr;var en=new dv,vs=class extends Pa(fN){constructor(e,r){super();this.parameters=r;this.objectForSample=void 0;this._pendingMediaLoad=!1;this.object=e}resetOnMove(){this.removeFromParent(),this.parent=null}expandClones(e){if(this.parent===null)this.updateState(this.parameters,e);else for(let r of this.children)r instanceof Wo&&r.expand()}invalidateTransform(e){this.matrixWorldNeedsUpdate=!0,this.traverse(r=>{r instanceof Wo&&r.object===e&&(r.matrixWorldNeedsUpdate=!0)})}onObjUpdateMatrix(){this.parameters.type!=="toObject"&&(this.matrixWorldNeedsUpdate=!0)}update(){switch(this._updateCount(),this.parameters.type){case"radial":this._updateRadial(this.parameters);break;case"linear":this._updateLinear(this.parameters);break;case"grid":this._updateGrid(this.parameters);break;case"toObject":this._updateToObject(this.parameters)}for(let e of this.children)e.updateMatrix(),e.hasNonUniformScale&&(e.updateMatrixWorld(),e.updateMatrixWorldSVD())}_updateCount(e){let r;if(e!==void 0?r=e:r=this.parameters.type==="grid"?Math.round(this.parameters.grid.count[0])*Math.round(this.parameters.grid.count[1])*Math.round(this.parameters.grid.count[2]):this.parameters.count,this.parameters.type==="toObject"&&!this.parameters.toObject.object&&(r=0),this.parameters.type==="toObject"&&this.objectForSample){for(let i=0,a=this.children.length;i<a;++i)this.remove(this.children[0]);let o=this.children;if(o.length===r)return;if(o.length<r)for(let i=0,a=r-o.length;i<a;++i){let s=new Wo(this.object);s.expand(),this.add(s)}else for(let i=0,a=o.length-r;i<a;++i)this.remove(o[i])}else{if(this.children.length===r)return;if(this.children.length<r)for(let o=0,i=r-this.children.length;o<i;++o){let a=new Wo(this.object);a.expand(),this.add(a)}else for(let o=0,i=this.children.length-r;o<i;++o)this.remove(this.children[0])}}_updateRadial(e){let r=e.radial,o=r.start*yv.DEG2RAD,i=r.end*yv.DEG2RAD,a=o-i,s=new ph(r.rotation[0],r.rotation[1],r.rotation[2]),l;switch(r.axis){case"z":l=new Pr(0,0,1);break;case"y":l=new Pr(0,1,0);break;default:case"x":l=new Pr(1,0,0);break}let u=e.randomnessObject??fo.defaultData([1,1,1]).randomnessObject,c=u.noiseType==="perlin";en.noiseSeed(u.seed);let d=lu((0,bs.default)(u.seed)),p=Tl(u.strength,this.parameters.randomness);for(let[f,h]of this.children.entries()){let m=f*(u.freqScale/10)+u.movement,y=c?en.noise(m):d(m,m),g=f+1;h.scale.x=r.scale[0]+p(g,Ce(y,u.scale[0]))||sr,h.scale.y=r.scale[1]+p(g,Ce(y,u.scale[1]))||sr,h.scale.z=r.scale[2]+p(g,Ce(y,u.scale[2]))||sr,h.position.setScalar(0);let b=a/e.count*f-o;switch(r.axis){case"x":h.rotation.set(0,b,0);break;case"y":h.rotation.set(0,0,b);break;case"z":h.rotation.set(b,0,0);break}h.translateOnAxis(l,r.radius),h.position.x+=r.position[0]+p(g,Ce(y,u.position[0])),h.position.y+=r.position[1]+p(g,Ce(y,u.position[1])),h.position.z+=r.position[2]+p(g,Ce(y,u.position[2]));let w=p(g,Ce(y,u.rotation[0])),A=p(g,Ce(y,u.rotation[1])),S=p(g,Ce(y,u.rotation[2]));r.alignment===!0?(h.rotation.x+=s.x+w,h.rotation.y+=s.y+A,h.rotation.z+=s.z+S):h.rotation.set(s.x+w,s.y+A,s.z+S)}}_updateLinear(e){if(e.type!=="linear")throw new Error;let r=e.linear,o=new ph(r.rotation[0],r.rotation[1],r.rotation[2]),i=e.randomnessObject??fo.defaultData([1,1,1]).randomnessObject,a=i.noiseType==="perlin";en.noiseSeed(i.seed);let s=lu((0,bs.default)(i.seed)),l=Tl(i.strength,this.parameters.randomness);for(let[u,c]of this.children.entries()){let d=u*(i.freqScale/10)+i.movement,p=a?en.noise(d):s(d,d),f=u+1,h=l(f,Ce(p,i.rotation[0])),m=l(f,Ce(p,i.rotation[1])),y=l(f,Ce(p,i.rotation[2]));c.scale.x=1+(r.scale[0]-1)*u+l(f,Ce(p,i.scale[0]))||sr,c.scale.y=1+(r.scale[1]-1)*u+l(f,Ce(p,i.scale[1]))||sr,c.scale.z=1+(r.scale[2]-1)*u+l(f,Ce(p,i.scale[2]))||sr,c.rotation.x=o.x*u+h,c.rotation.y=o.y*u+m,c.rotation.z=o.z*u+y,c.position.x=r.position[0]*u+l(f,Ce(p,i.position[0])),c.position.y=r.position[1]*u+l(f,Ce(p,i.position[1])),c.position.z=r.position[2]*u+l(f,Ce(p,i.position[2]))}}_updateGrid(e){let r=0,o=e.grid,i=e.randomnessObject??fo.defaultData([1,1,1]).randomnessObject,a=Tl(i.strength,this.parameters.randomness),s=i.noiseType==="perlin";en.noiseSeed(i.seed);let l=z0((0,bs.default)(i.seed));if(o.useCenter===!0){let u={x:o.count[0]%2===0?2:1,y:o.count[1]%2===0?2:1,z:o.count[2]%2===0?2:1},c=new Pr(o.size[0]*(o.count[0]-u.x)*.5,o.size[1]*(o.count[1]-u.y)*.5,o.size[2]*(o.count[2]-u.z)*.5);for(let d=0;d<o.count[0];d++)for(let p=0;p<o.count[1];p++)for(let f=0;f<o.count[2];f++){let h=[(d+1)*(i.freqScale/10)+i.movement,(p+1)*(i.freqScale/10)+i.movement,(f+1)*(i.freqScale/10)+i.movement],m=s?en.noise(...h):l(...h),y=this.children[r++];y.scale.x=1+a(r,Ce(m,i.scale[0]))||sr,y.scale.y=1+a(r,Ce(m,i.scale[1]))||sr,y.scale.z=1+a(r,Ce(m,i.scale[2]))||sr;let g=a(r,Ce(m,i.rotation[0])),b=a(r,Ce(m,i.rotation[1])),w=a(r,Ce(m,i.rotation[2]));y.rotation.set(g,b,w),y.position.x=o.size[0]*d-c.x+a(r,Ce(m,i.position[0])),y.position.y=o.size[1]*p-c.y+a(r,Ce(m,i.position[1])),y.position.z=o.size[2]*f-c.z+a(r,Ce(m,i.position[2]))}}else for(let u=0;u<o.count[0];u++)for(let c=0;c<o.count[1];c++)for(let d=0;d<o.count[2];d++){let p=[(u+1)*(i.freqScale/10)+i.movement,(c+1)*(i.freqScale/10)+i.movement,(d+1)*(i.freqScale/10)+i.movement],f=s?en.noise(...p):l(...p),h=this.children[r++];h.scale.x=1+a(r,Ce(f,i.scale[0]))||sr,h.scale.y=1+a(r,Ce(f,i.scale[1]))||sr,h.scale.z=1+a(r,Ce(f,i.scale[2]))||sr;let m=a(r,Ce(f,i.rotation[0])),y=a(r,Ce(f,i.rotation[1])),g=a(r,Ce(f,i.rotation[2]));h.rotation.set(m,y,g),h.position.x=o.size[0]*u+a(r,Ce(f,i.position[0])),h.position.y=-o.size[1]*c+a(r,Ce(f,i.position[1])),h.position.z=-o.size[2]*d+a(r,Ce(f,i.position[2]))}}_updateToObject(e){if(e.type!=="toObject")throw new Error;let{toObject:r}=e,o=new ph(r.rotation[0],r.rotation[1],r.rotation[2]),i=e.randomnessObject??fo.defaultData([1,1,1]).randomnessObject,a=i.noiseType==="perlin";en.noiseSeed(i.seed);let s=lu((0,bs.default)(i.seed)),l=Tl(i.strength,this.parameters.randomness);if(!r.object){for(let[,g]of this.children.entries())g.position.set(0,0,0),g.scale.setScalar(1),g.rotation.set(0,0,0);this.objectForSample=void 0;return}if(!this.objectForSample)return;if(this.objectForSample instanceof xs)if(!this.objectForSample.font?.isLoaded||this.objectForSample.geometry.attributes.position===void 0){this._pendingMediaLoad=!0;return}else this._pendingMediaLoad=!1;if(this.objectForSample.geometry===void 0&&this.objectForSample.isAncestorOf(this.object.uuid)){console.warn(`Oh no! The object "${this.object.name}" (${this.object.uuid}) seem to be a child/descendant of the object it's being cloned to. Please re-parent it so that they are siblings instead.`);return}let u=this.getSubdivData(),c=[],d=g=>{let b=g.length,w=g.map(P=>P[0]).reduce((P,O)=>P+O,0),A=g.map(P=>P[1]).reduce((P,O)=>P+O,0),S=g.map(P=>P[2]).reduce((P,O)=>P+O,0);return[w/b,A/b,S/b]},p=g=>Math.round(g*1e6)/1e6;u.forEach(g=>{let b=u.filter(w=>p(g.pos[0])===p(w.pos[0])&&p(g.pos[1])===p(w.pos[1])&&p(g.pos[2])===p(w.pos[2]));b.length>1?c.push({pos:g.pos,norm:d(b.map(w=>w.norm))}):c.push(g)});let f=lv(c);if(f.length>0){let g=Math.round(f.length*r.count/100);this._updateCount(g)}else{let g=this.objectForSample.geometry.getAttribute("position");if(!g||isNaN(g.count)||g.count===0){console.warn(`Oh no! The object "${this.object.name}" (${this.object.uuid}) cannot be cloned on the surface of "${this.objectForSample.name}" (${this.objectForSample.uuid}) because the latter does not have a valid geometry.`);return}}this.objectForSample.updateMatrixWorld();let h=new cu(this.objectForSample).build(),m=av[r.axis],y=this.children;h.setRandomGenerator((0,bs.default)(this.object.uuid+r.seed));for(let[g,b]of y.entries()){let w=g*(i.freqScale/10)+i.movement,A=a?en.noise(w):s(w,w),S=g+1,P=l(S,Ce(A,i.rotation[0])),O=l(S,Ce(A,i.rotation[1])),x=l(S,Ce(A,i.rotation[2]));r.spreadType==="random"?h.sample(Ml,fh):(f.length&&(Ml.fromArray(f[g].pos),fh.fromArray(f[g].norm)),this.objectForSample instanceof bi&&Ml.applyMatrix4(hN.copy(this.objectForSample.matrixWorld).invert())),Ml.applyMatrix4(this.object.hiddenMatrix.clone().invert()),b.position.copy(Ml),Bn.fromArray(m);let D=r.align==="normal"?fh:this.object.getWorldDirection(gN),N=td.fromArray(r.position);td.x+=l(S,Ce(A,i.position[0])),td.y+=l(S,Ce(A,i.position[1])),td.z+=l(S,Ce(A,i.position[2]));let T=Math.acos(D.dot(Bn)),I=yN.crossVectors(Bn,D).normalize(),E=mN.makeRotationAxis(I,T),B=D.clone().cross(this.object.up).normalize(),R=B.clone().cross(D).normalize(),F=new wi().makeBasis(B,D,R),V=new Pr(Bn.y,Bn.z,Bn.x).normalize(),q=V.clone().cross(Bn).normalize(),k=new wi().makeBasis(V,Bn,q).invert(),U=new wi().multiplyMatrices(F,k);b.rotation.setFromRotationMatrix(U),N.applyMatrix4(E),b.position.add(N),b.rotation.x=b.rotation.x+o.x+P,b.rotation.y=b.rotation.y+o.y+O,b.rotation.z=b.rotation.z+o.z+x,b.scale.setScalar(1),b.scale.x=b.scale.x+r.scale[0]+l(S,Ce(A,i.scale[0]))||sr,b.scale.y=b.scale.y+r.scale[1]+l(S,Ce(A,i.scale[1]))||sr,b.scale.z=b.scale.z+r.scale[2]+l(S,Ce(A,i.scale[2]))||sr,b.scale.multiply(this.object.scale),b.hiddenMatrix=this.object.hiddenMatrix}}getSubdivData(){if(!this.objectForSample)return[];let e=this.parameters.toObject.spreadType;if(e==="random")return[];if(this.objectForSample instanceof bi){let r=this.objectForSample,o=sv[e],i=Sv[o],a=bv[o],s=vv[o],l=[],u=i(r.subdivPointerNew);for(let c=0;c<=u-1;c++){let d=a(r.subdivPointerNew,c),p=s(r.subdivPointerNew,c);gv.fromArray(d).applyMatrix4(r.matrixWorld),xv.fromArray(p),l.push({pos:gv.toArray(),norm:xv.toArray()})}return l}else return(this.objectForSample.geometry.index?cv(this.objectForSample.geometry):uv(this.objectForSample.geometry)).map((o,i)=>e==="polygon_center"?{pos:o.midpoint,norm:o.norm}:e==="vertex"?[{pos:o.vertices[0],norm:o.norm},{pos:o.vertices[1],norm:o.norm},{pos:o.vertices[2],norm:o.norm}]:e==="edge"?[{pos:o.faceCenters[0],norm:o.norm},{pos:o.faceCenters[1],norm:o.norm},{pos:o.faceCenters[2],norm:o.norm}]:[]).flat()}updateState(e,r){if(this.parameters=Vo(e),this.parameters.type!=="toObject")(this.parent===null||this.parent!==this.object)&&(this.removeFromParent(),this.object.parent?.add(this),this.matrix=this.object.matrix,this.hiddenMatrix=this.object.hiddenMatrix,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1);else if(this.parent===null||this.parent.uuid!==this.parameters.toObject.object){this.removeFromParent();let o=r.find(this.parameters.toObject.object);o instanceof Dt?this.objectForSample=o:this.objectForSample=void 0,this.matrix=new wi,this.hiddenMatrix=new wi,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1,o&&o.add(this)}this.update()}get pendingMediaLoad(){return this._pendingMediaLoad}};import{Scene as WE,Vector3 as $E,Matrix4 as YE,Box3 as XE,MeshBasicMaterial as QE,Skeleton as KE}from"three";import{Camera as MN,OrthographicCamera as IN,PerspectiveCamera as NN,Vector3 as oo,Object3D as Pv,Quaternion as DN,Matrix4 as EN}from"three";import{Camera as AN,LineSegments as _N,BufferGeometry as PN,LineBasicMaterial as ON,Color as mh,Vector3 as CN,Float32BufferAttribute as Av}from"three";import{BoxGeometry as xN}from"three";var To=n=>{var t;return t=class extends n{},t.geometryHelper=new xN(30,30,30),t};import{Ray as bN,Sphere as vN,Matrix4 as SN,Vector3 as tn}from"three";var rd=new bN,hh=new vN,wv=new SN,Mo=(n,t,e,r,o=!1)=>{let i=t,a=n.matrixWorld;if(i.boundingSphere===null&&i.computeBoundingSphere(),hh.copy(i.boundingSphere),hh.applyMatrix4(a),e.ray.intersectsSphere(hh)===!1||(wv.copy(a).invert(),rd.copy(e.ray).applyMatrix4(wv),i.boundingBox!==null&&rd.intersectsBox(i.boundingBox)===!1))return;let s,l,u,c,d=i.index,p=i.attributes.position,f=i.drawRange,h,m;if(o===!1){let g=Math.max(0,f.start),b=Math.min(d.count,f.start+f.count);for(h=g,m=b;h<m;h+=3)if(l=d.getX(h),u=d.getX(h+1),c=d.getX(h+2),s=y(n,e,rd,p,l,u,c),s){s.faceIndex=Math.floor(h/3),r.push(s);return}}else{let b=i.attributes.position,w=new tn,A=new tn,S=new tn,P=new tn,O=2,D=1/((n.scale.x+n.scale.y+n.scale.z)/3),N=D*D,T=Math.max(0,f.start),I=Math.min(b.count,f.start+f.count);for(let E=T,B=I-1;E<B;E+=O){if(w.fromBufferAttribute(b,E),A.fromBufferAttribute(b,E+1),rd.distanceSqToSegment(w,A,P,S)>N)continue;P.applyMatrix4(n.matrixWorld);let F=e.ray.origin.distanceTo(P);F<e.near||F>e.far||r.push({distance:F,point:S.clone().applyMatrix4(n.matrixWorld),object:n})}}function y(g,b,w,A,S,P,O){let x=new tn,D=new tn,N=new tn,T=new tn,I=new tn;if(x.fromBufferAttribute(A,S),D.fromBufferAttribute(A,P),N.fromBufferAttribute(A,O),w.intersectTriangle(x,D,N,!1,T)===null)return null;I.copy(T),I.applyMatrix4(g.matrixWorld);let B=b.ray.origin.distanceTo(I);return B<b.near||B>b.far?null:{faceIndex:1,distance:B,point:I.clone(),object:g}}};var od=new CN,Lr=new AN,yh=class extends _N{constructor(e){let r=new PN,o=new ON({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],a=[],s={},l=new mh(15711266),u=new mh(15711266),c=new mh(2857471);d("n1","n2",l),d("n2","n4",l),d("n4","n3",l),d("n3","n1",l),d("f1","f2",l),d("f2","f4",l),d("f4","f3",l),d("f3","f1",l),d("n1","f1",l),d("n2","f2",l),d("n3","f3",l),d("n4","f4",l),d("p","n1",u),d("p","n2",u),d("p","n3",u),d("p","n4",u),d("u1","u2",c),d("u2","u3",c),d("u3","u1",c);function d(f,h,m){p(f,m),p(h,m)}function p(f,h){i.push(0,0,0),a.push(h.r,h.g,h.b),s[f]===void 0&&(s[f]=[]),s[f].push(i.length/3-1)}r.setAttribute("position",new Av(i,3)),r.setAttribute("color",new Av(a,3));super(r,o);this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=s,this.update()}update(){let e=this.geometry,r=this.pointMap,o=!0;Lr.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let i=1,a=1,s=o?.8:1e-4;ro("n1",r,e,Lr,-i,-a,s),ro("n2",r,e,Lr,i,-a,s),ro("n3",r,e,Lr,-i,a,s),ro("n4",r,e,Lr,i,a,s);let l=s;ro("f1",r,e,Lr,-i,-a,l),ro("f2",r,e,Lr,i,-a,l),ro("f3",r,e,Lr,-i,a,l),ro("f4",r,e,Lr,i,a,l);let u=l,c=.5;ro("u1",r,e,Lr,i*.7*c,a*1.1,u),ro("u2",r,e,Lr,-i*.7*c,a*1.1,u),ro("u3",r,e,Lr,0,a*(1.1+.9*c),u),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function ro(n,t,e,r,o,i,a){od.set(o,i,a).unproject(r);let s=t[n];if(s!==void 0){let l=e.getAttribute("position");for(let u=0,c=s.length;u<c;u++)l.setXYZ(s[u],od.x,od.y,od.z)}}var nd=class extends To(yh){constructor(e){super(e);this.object=e;this.object=e,this.name=`CombinedCameraHelper: ${e.uuid}`}updateMatrixWorld(e){super.updateMatrixWorld(e),this.updateTarget()}updateTarget(){let e=this.object.getTarget();this.updateWorldMatrix(!0,!1),this.worldToLocal(e)}raycast(e,r){Mo(this.object,this.geometry,e,r,!0)}};import{Box3Helper as _v,BoxGeometry as TN}from"three";var id;(t=>t.is=e=>"objectHelper"in e)(id||(id={}));var Rr=(n,t)=>class extends Ta(n){constructor(){super(...arguments);this.objectHelper=new t(this);this.gizmos={}}get geometryHelper(){return t.geometryHelper}raycast(o,i){this.objectHelper.raycast(o,i)}showGizmos(){for(let o in this.gizmos){let i=this.gizmos[o];i instanceof _v&&(i.visible=!0)}}updateEntityBoxSize(o,i){this.objectHelper.visible&&this.geometryHelper instanceof TN?(o.setScalar(0),i.set(this.geometryHelper.parameters.width,this.geometryHelper.parameters.height,this.geometryHelper.parameters.height).multiplyScalar(.5)):super.updateEntityBoxSize(o,i)}hideGizmos(){for(let o in this.gizmos){let i=this.gizmos[o];i instanceof _v&&(i.visible=!1)}}};var ad=790,Ss=new oo,gh=new oo,xh=new DN,bh=new oo,Il=new oo,vh=new oo,rn=class extends Rr(MN,nd){constructor(e="",r={...oi.defaultData,name:""}){super();this._cameraType="OrthographicCamera";this.targetOffset=Sn.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.wasMovedByUser=!1;this.wasMovedBySwitchCameraAction=!1;this.super_Entity(e,r),this.previousProjectionMatrix=new EN,this.matrixAutoUpdate=!0,this.width=window.innerWidth,this.height=window.innerHeight;let o=this.width,i=this.height;this.orthoCamera=new IN(o*-.5,o*.5,i*.5,i*-.5,-5e4,1e4),this.perspCamera=new NN(45,o/i,50,1e4),this.left=this.orthoCamera.left,this.right=this.orthoCamera.right,this.top=this.orthoCamera.top,this.bottom=this.orthoCamera.bottom,this.far=this.orthoCamera.far,this.view=this.orthoCamera.view,this.aspect=this.perspCamera.aspect,this.focus=this.perspCamera.focus,this.filmGauge=this.perspCamera.filmGauge,this.filmOffset=this.perspCamera.filmOffset,this.objectHelper.update()}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}set fov(e){this.perspCamera.fov=e}get fov(){return this.perspCamera.fov}setNear(e,r){e==="PerspectiveCamera"?this.perspCamera.near=r:this.orthoCamera.near=r}setZoom(e,r){r>=0&&(e==="PerspectiveCamera"?this.perspCamera.zoom=r:this.orthoCamera.zoom=r)}set cameraType(e){e==="PerspectiveCamera"?this.toPerspective():e==="OrthographicCamera"&&this.toOrthographic()}get near(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.near:this.orthoCamera.near}set near(e){this._cameraType==="PerspectiveCamera"?this.perspCamera.near=e:this.orthoCamera.near=e}get zoom(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(e){e>=0&&(this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom=e:this.orthoCamera.zoom=e)}lookAt(e,r,o){typeof e=="number"&&(e=new oo(e,r,o)),super.lookAt(e),this.getWorldPosition(Ss),this.targetOffset=Ss.distanceTo(e)}getTarget(e=new oo){return this.getWorldDirection(gh),this.getWorldPosition(Ss),gh.multiplyScalar(this.targetOffset),e.copy(Ss).add(gh),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(Ss),Ss.distanceTo(e)}updateUp(){this.getWorldQuaternion(xh),bh.set(0,0,1).applyQuaternion(xh),Il.copy(Pv.DEFAULT_UP),this.isUpVectorFlipped&&Il.negate(),Il.applyQuaternion(xh),vh.copy(Pv.DEFAULT_UP).projectOnPlane(bh),this.angleOffsetFromUp=vh.angleTo(Il),this.angleOffsetFromUp*=vh.cross(Il).dot(bh)>=0?1:-1}updateTransformState(e,r){let o=super.updateTransformState(e,r);return e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateUp(),o}getViewFrontToObject(e){let r=e.getWorldPosition(new oo),i=e.getWorldDirection(new oo).multiplyScalar(this.targetOffset);return{position:r.clone().add(i),target:r}}getViewToTarget(e){let o=this.getWorldDirection(new oo).multiplyScalar(this.targetOffset);return{position:e.clone().sub(o),target:e}}getViewToObject(e){let r=new oo,o=e.getWorldPosition(r);return this.getViewToTarget(r)}setViewplaneSize(e,r,o=!1){if(this.aspect=e/r,o){let i=e>r?this.aspect:1,a=e>r?1:this.aspect;this.left=-ad*.5*i,this.right=ad*.5*i,this.top=ad*.5*(1/a),this.bottom=-ad*.5*(1/a)}else this.left=-e*.5,this.right=e*.5,this.top=r*.5,this.bottom=-r*.5;this.updateProjectionMatrix()}copyViewPlaneSize(e){this.aspect=e.aspect,this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.updateProjectionMatrix()}toOrthographic(){this.orthoCamera.left=this.left,this.orthoCamera.right=this.right,this.orthoCamera.top=this.top,this.orthoCamera.bottom=this.bottom,this.orthoCamera.view=this.view,this.orthoCamera.far=this.far,this.orthoCamera.updateProjectionMatrix(),this.projectionMatrix=this.orthoCamera.projectionMatrix,this.projectionMatrixInverse=this.orthoCamera.projectionMatrixInverse,this._cameraType="OrthographicCamera",this.objectHelper&&this.objectHelper.update()}toPerspective(){this.perspCamera.aspect=this.aspect,this.perspCamera.fov=this.fov,this.perspCamera.view=this.view,this.perspCamera.far=this.far,this.perspCamera.updateProjectionMatrix(),this.projectionMatrix=this.perspCamera.projectionMatrix,this.projectionMatrixInverse=this.perspCamera.projectionMatrixInverse,this._cameraType="PerspectiveCamera",this.objectHelper&&this.objectHelper.update()}setFocalLength(e){this.perspCamera.setFocalLength(e),this.toPerspective()}getFocalLength(){return this.perspCamera.getFocalLength()}getEffectiveFOV(){return this.perspCamera.getEffectiveFOV()}getFilmWidth(){return this.perspCamera.getFilmWidth()}getFilmHeight(){return this.perspCamera.getFilmHeight()}setViewOffset(e,r,o,i,a,s){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(e,r,o,i,a,s):this.orthoCamera.setViewOffset(e,r,o,i,a,s)}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}copyHistory(){this.previousProjectionMatrix&&this.previousProjectionMatrix.copy(this.projectionMatrix)}updateProjectionMatrix(){this._cameraType==="PerspectiveCamera"?this.toPerspective():this._cameraType==="OrthographicCamera"&&this.toOrthographic()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,r){super.updateWorldMatrix(e,r),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(e,r){return super.copy(e,r),this.parent=e.parent,this.orthoCamera.copy(e.orthoCamera),this.perspCamera.copy(e.perspCamera),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.far=e.far,this.view=e.view===null?null:Object.assign({},e.view),this._cameraType=e._cameraType,this.aspect=e.aspect,this.fov=e.fov,this.focus=e.focus,this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this.targetOffset=e.targetOffset,this.updateProjectionMatrix(),this}toCameraState(e=[]){let r={type:this.cameraType,far:this.far,orthographic:{near:this.orthoCamera.near,zoom:this.orthoCamera.zoom},perspective:{near:this.perspCamera.near,fov:this.perspCamera.fov,zoom:this.perspCamera.zoom},up:this.up.toArray(),targetOffset:this.targetOffset,isUpVectorFlipped:this.isUpVectorFlipped};return ta(r,e)}updateCameraSubtype(e,r){let o=e==="perspective"?"PerspectiveCamera":"OrthographicCamera";r.zoom!==void 0&&this.setZoom(o,r.zoom),r.near!==void 0&&this.setNear(o,r.near),r.fov!==void 0&&o==="PerspectiveCamera"&&(this.fov=r.fov)}updateState(e,r){this.updateCameraState(e,r)}updateCameraState(e,r){this.updateState_Entity(e,r),e.far!==void 0&&(this.far=e.far),e.orthographic!==void 0&&this.updateCameraSubtype("orthographic",e.orthographic),e.perspective!==void 0&&this.updateCameraSubtype("perspective",e.perspective),e.type!==void 0&&(this.cameraType=e.type),e.up!==void 0&&this.up.fromArray(e.up),e.targetOffset!==void 0&&(this.targetOffset=e.targetOffset),e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateProjectionMatrix()}updateByPatchedOp(e,r,o){super.updateByPatchedOp(e,r,o),e.path.length===1&&e.type===0&&this.updateCameraSubtype(e.path[0],e.props)}toState(e){return{...super.toState(e),...this.toCameraState(e),type:this.cameraType}}};import{MathUtils as Qoe}from"three";import{BufferGeometry as Ov,Matrix4 as Cv,Float32BufferAttribute as BN}from"three";var ws=new Cv,LN=new Cv;var yr=class extends mr{constructor(e,r,o){super(e,r);this.data=r;this.meshSetAddresses=[];this.needsTransformForDownstream=!1;this.geometry=new Ov;this.onAfterRender=(e,r,o,i,a,s)=>{super.onAfterRender(e,r,o,i,a,s),this.recomputeBoolean()};this.geometry.userData.parameters={width:0,height:0,depth:0}}get booleanOp(){return this.data.geometry.operation}get phongAngle(){return this.data.geometry.phongAngle??45}get isLOD(){return this.recomputeBoolean(),!1}updateByPatchedOp(e,r,o){super.updateByPatchedOp(e,r,o),e.path.length===1&&e.path[0]==="geometry"&&e.type===0&&e.props.operation!==void 0&&(this.freeBooleanPointer(),this.resetBBoxNeedsUpdate())}freeBooleanPointer(){super.freeBooleanPointer(),this.geometry.dispose()}recomputeBoolean(e,r=!0){if(this.booleanMeshSetAddress!==-1&&!e)return;for(let i=0;i<this.children.length;i++){let a=this.children[i];a instanceof yr&&a.dataPatched.visible===!0&&a.recomputeBoolean(e===!0,r)}this.meshSetAddresses=[];for(let i=0;i<this.children.length;i++){let a=this.children[i];if(a instanceof Dt&&a.dataPatched.visible===!0&&a.geometry.attributes.position?.count>0&&a.geometry.drawRange.count>0&&a.booleanMeshSetAddress!==0){ws.multiplyMatrices(a.hiddenMatrix,a.matrix);try{if(a.booleanMeshSetAddress===-1){if((a.geometry.index??a.geometry.getAttribute("position")).count/3<15e5&&(a.booleanMeshSetAddress=Dr.getMeshSet(a.geometry,e===!0,r)),a.booleanMeshSetAddress===-1)return;Dr.transformMeshSet(a.booleanMeshSetAddress,ws),a.booleanMatrixInvOld.copy(ws).invert(),a.booleanWasTransformed=!1}else a instanceof yr&&a.needsTransformForDownstream===!0?(Dr.transformMeshSet(a.booleanMeshSetAddress,ws),a.needsTransformForDownstream=!1):a.booleanWasTransformed===!0&&(Dr.transformMeshSet(a.booleanMeshSetAddress,LN.multiplyMatrices(ws,a.booleanMatrixInvOld)),a.booleanMatrixInvOld.copy(ws).invert(),a.booleanWasTransformed=!1)}catch(s){console.error(s),a.booleanMeshSetAddress=0,a.geometry.userData.booleanOperationDidFail=!0;continue}Dr.hasOpenEdges(a.booleanMeshSetAddress)===!1||i===this.children.length-1&&this.booleanOp===2?(this.meshSetAddresses.push(a.booleanMeshSetAddress),a.geometry.userData.booleanOperationDidFail=!1):a.geometry.userData.booleanOperationDidFail="openEdges"}}if(this.meshSetAddresses.length===0){this.geometry.setAttribute("position",new BN([],0)),this.geometry.setDrawRange(0,0);return}if(e===!0)return Dr.calcBooleanTopological(this.meshSetAddresses,this.booleanOp);let o=this.geometry;o.dispose(),this.geometry=new Ov,this.geometry.userData=o.userData,this.geometry.boundingSphere=o.boundingSphere;try{this.booleanMeshSetAddress=Dr.calcBoolean(this.meshSetAddresses,this.booleanOp,this.geometry,this.phongAngle)}catch(i){this.booleanMeshSetAddress=0,this.geometry.userData.booleanOperationDidFail=!0,console.error(i)}this.booleanMatrixInvOld.copy(this.matrix).invert(),this.needsTransformForDownstream=!0,ms(this),ys(this)}dispose(){super.dispose(),this.geometry.dispose()}};import{Light as RN}from"three";var Tv;(t=>{function n(e){return Re.is(e)&&e instanceof RN}t.is=n})(Tv||(Tv={}));var As=(n,t)=>class extends Rr(n,t){updateState_Light(r,o){this.updateState_Entity(r,o),r.color!==void 0&&(this.color=o.shared.color(r.color)),r.intensity!==void 0&&(this.intensity=r.intensity),r.depth!==void 0&&(this.shadow.camera.far=r.depth,this.shadow.needsUpdate=!0),r.shadows!==void 0&&(this.castShadow=r.shadows)}};var Ln=n=>n instanceof Dt,Nl=n=>n!==null&&n instanceof yr;var Dl=n=>id.is(n);import{Group as zN}from"three";import{AxesHelper as VN}from"three";var Vr=class extends To(VN){constructor(e,r=15){super(r);this.object=e;this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${e.uuid}`,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.object.isBone&&(this.visible=!1)}raycast(e,r){Mo(this.object,Vr.geometryHelper,e,r)}update(){}};var Rn=class extends Rr(zN,Vr){constructor(t,e){super(),this.super_Entity(t,e),this.objectHelper.update()}updateState(t,e){this.updateState_Entity(t,e),"buffer"in t&&Object.keys(t).length===1&&e.scene.reloadSplats()}};import{Group as GN}from"three";var sd=class extends Rr(GN,Vr){constructor(e,r,o){super();this.super_Entity(e,r),this.context=o,this.objectHelper.update()}updateState(e,r){this.updateState_Entity(e,r)}};import{Color as pD,Fog as fD,HemisphereLight as hD}from"three";import{ShaderChunk as El}from"three";var FN=n=>`
2242
2242
 
2243
2243
  // PCSS implementation based on:
2244
2244
  // https://www.gamedev.net/articles/programming/graphics/contact-hardening-soft-shadows-made-fast-r4906/
@@ -2612,7 +2612,7 @@ float vogelShadow(int index, sampler2D shadowMap, vec2 uv, float texelSize, floa
2612
2612
  }
2613
2613
 
2614
2614
  #endif
2615
- `,VN=El.lights_fragment_begin,zN=El.shadowmask_pars_fragment,Tv=null,GN=n=>{switch(n){case"low":return 8;case"medium":return 16;case"high":return 32;default:return 16}},Mv=(n="medium")=>{if(Tv===n)return!1;Tv=n;let t=GN(n);El.shadowmap_pars_fragment=RN(t);let e=VN.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 ]"),El.lights_fragment_begin=e;let r=zN.slice();return r=r.replaceAll("getShadow(","getShadow( UNROLLED_LOOP_INDEX, "),El.shadowmask_pars_fragment=r,!0};import{DirectionalLight as HN,CameraHelper as Iv}from"three";import{DirectionalLightHelper as FN}from"three";var As=class extends To(FN){constructor(e,r=15,o=10066329){super(e,r,o);this.object=e;this.added=!1;this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,r){Mo(this.object,As.geometryHelper,e,r)}};import{PointLightHelper as kN}from"three";var _s=class extends To(kN){constructor(e,r=15,o=6710886){super(e,r,o);this.object=e;this.name=`PointLightHelper: ${e.uuid}`}raycast(e,r){Mo(this.object,_s.geometryHelper,e,r)}};import{SpotLightHelper as jN,Vector3 as UN}from"three";var ld=class extends To(jN){constructor(e,r=6710886){super(e,r);this.object=e;this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,r){Mo(this.object,ld.geometryHelper,e,r)}update(){if(this.object!==void 0){let e=ld._vector,r=this.object.distance?this.object.distance:1e3,o=r*Math.tan(this.object.angle);this.cone.scale.set(o,o,r),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 a=0,s=this.cone.material.length;a<s;a++)this.cone.material[a].color.set(i);else this.cone.material.color.set(i)}}},Bl=ld;Bl._vector=new UN;function qN(n,t){n.shadow.camera.right=t/2,n.shadow.camera.left=-t/2,n.shadow.camera.top=t/2,n.shadow.camera.bottom=-t/2,n.shadow.needsUpdate=!0}var Ps=class extends ws(HN,As){constructor(t,e,r){super(),this.super_Entity(t,e),this.castShadow=!0,this.shadow.mapSize.width=2048,this.shadow.mapSize.height=2048,this.shadow.normalBias=1,this.layers.enable(3);let i=this.shadow.camera;i.top=1250,i.bottom=-1250,i.right=1250,i.left=-1250,i.near=-1e4,i.far=2500;let a=new Iv(this.shadow.camera);a.visible=!1,this.gizmos.shadowmap=a}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this.gizmos){let e=this.gizmos[t];e instanceof Iv&&e.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.objectHelper&&this.objectHelper.update()}updateState(t,e){this.updateState_Light(t,e);let r=t.depth!==void 0&&t.depth!==this.shadow.camera.far||t.size!==void 0&&t.size/2!==this.shadow.camera.right;t.size!==void 0&&qN(this,t.size),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),t.penumbraSize!==void 0&&e.scene.markPenumbraSizeDirty(),r&&this.update()}};import{Scene as uD}from"three";import{SpotLight as WN,CameraHelper as Nv,MathUtils as $N,Vector3 as Lv,Quaternion as YN}from"three";var Dv=new Lv,Ev=new Lv,Bv=new YN,Os=class extends ws(WN,Bl){constructor(t,e,r){super(),this.super_Entity(t,e),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let i=this.shadow.camera;i.fov=$N.RAD2DEG*2*this.angle,i.aspect=1,i.near=100,i.far=2500;let a=new Nv(this.shadow.camera);a.visible=!1,this.gizmos.shadowmap=a,this.update()}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this.gizmos){let e=this.gizmos[t];e instanceof Nv&&e.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),Ev.setFromMatrixPosition(this.matrixWorld),Bv.setFromRotationMatrix(this.matrixWorld),Dv.copy(this.up).applyQuaternion(Bv).negate().multiplyScalar(this.distance),this.target.position.copy(Ev).add(Dv),this.target.updateMatrixWorld(),this.objectHelper&&this.objectHelper.update()}updateState(t,e){this.updateState_Light(t,e),t.distance!==void 0&&(this.distance=t.distance),t.decay!==void 0&&(this.decay=t.decay),t.angle!==void 0&&(this.angle=t.angle),t.penumbra!==void 0&&(this.penumbra=t.penumbra),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.penumbraSize!==void 0&&e.scene.markPenumbraSizeDirty(),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};var ke;(S=>{function n(){return[1,0,0,0,1,0,0,0,1]}S.identity=n;function t(P,O=S.identity()){for(let x=0,D=P.length;x<D;x++)O[x]=P[x];return O}S.copy=t;function e(P,O,x,D,N,T){return S.setAbcdef(S.identity(),P,O,x,D,N,T)}S.create=e;function r(P,O,x,D,N,T,I){return P[0]=O,P[1]=D,P[2]=T,P[3]=x,P[4]=N,P[5]=I,P}S.setAbcdef=r;function o(P,O){let[x,D,N,T,I,E]=a(P),[B,R,F,V,q,k]=a(O),U=B*x+R*N,H=B*D+R*T,$=F*x+V*N,J=F*D+V*T,K=q*x+k*N+I,X=q*D+k*T+E;return S.create(U,H,$,J,K,X)}S.append=o;function i(P,O){let[x,D,N,T,I,E]=a(P),[B,R,F,V,q,k]=a(O),U=x,H=D,$=N,J=T;(B!==1||R!==0||F!==0||V!==1)&&(U=x*B+D*F,H=x*R+D*V,$=N*B+T*F,J=N*R+T*V);let K=I*B+E*F+q,X=I*R+E*V+k;return S.create(U,H,$,J,K,X)}S.prepend=i;function a(P){return[P[0],P[3],P[1],P[4],P[2],P[5]]}S.getAbcdef=a;function s(P){let[O,x,D,N,T,I]=S.getAbcdef(P),E=O*N-x*D,B=N/E,R=-x/E,F=-D/E,V=O/E,q=(D*I-N*T)/E,k=-(O*I-x*T)/E;return S.create(B,R,F,V,q,k)}S.invert=s;function l([P,O],x){let[D,N,T,I,E,B]=S.getAbcdef(x);return[D*P+T*O+E,N*P+I*O+B]}S.apply=l;function u(P,O){let[x,D,N,T,I,E]=S.getAbcdef(O),B=1/(x*T+N*-D),[R,F]=P;return[T*B*R+-N*B*F+(E*N-I*T)*B,x*B*F+-D*B*R+(-E*x+I*D)*B]}S.applyInverse=u;function c(P,O,x=O){let[D,N,T,I,E,B]=S.getAbcdef(P);return S.setAbcdef(P,D*O,N*x,T*O,I*x,E*O,B*x),P}S.scale=c;function d(P,O){let x=Math.cos(O),D=Math.sin(O),[N,T,I,E,B,R]=S.getAbcdef(P);return S.setAbcdef(P,N*x-T*D,N*D+T*x,I*x-E*D,I*D+E*x,B*x-R*D,B*D+R*x),P}S.rotate=d;function p(P,O,x){let[D,N]=x,T=S.translate(P,-D,-N);return T=S.rotate(T,O),T=S.translate(T,D,N),T}S.rotateAround=p;function f(P,O,x){let[D,N,T,I,E,B]=S.getAbcdef(P);return S.setAbcdef(P,D,N,T,I,E+O,B+x),P}S.translate=f;function h(P,O,x){let[D,N,T,I]=S.getAbcdef(P);return S.setAbcdef(P,D,N,T,I,O,x),P}S.setTranslate=h;function m(P,O,x){let[D,N,T,I]=S.getAbcdef(P);return S.setAbcdef(P,D,N,T,I,O,x),P}S.setPosition=m;function y(P){let[O,x,D,N]=S.getAbcdef(P),T=Math.sqrt(O*O+x*x),I=Math.sqrt(D*D+N*N);return[T,I]}S.getScale=y;function g(P){let[,,,,O,x]=S.getAbcdef(P);return[O,x]}S.getPosition=g;function b(P,O){return S.decompose(P,O).rotation}S.getRotation=b;function w(P,O){let[x,D,N,T,I,E]=S.getAbcdef(P),B=-Math.atan2(-N,T),R=Math.atan2(D,x),F=Math.abs(B+R),V=0,q=[0,0];F<1e-5||Math.abs(Math.PI*2-F)<1e-5?(V=R,q[0]=q[1]=0):(V=0,q[0]=B,q[1]=R);let k=[Math.sqrt(x*x+D*D),Math.sqrt(N*N+T*T)];return{position:[I+(O[0]*x+O[1]*N)-O[0],E+(O[0]*D+O[1]*T)-O[1]],scale:k,rotation:V,skew:q,pivot:O}}S.decompose=w;function _(P,O,x,D,N=[0,0]){let[T,I]=P,[E,B]=O,[R,F]=D,[V,q]=N,k=Math.cos(x+q)*E,U=Math.sin(x+q)*E,H=-Math.sin(x-V)*B,$=Math.cos(x-V)*B,J=T-(R*k+F*H)+R,K=I-(R*U+F*$)+F;return S.create(k,U,H,$,J,K)}S.compose=_})(ke||(ke={}));var XN=Math.PI/180,eie=180/Math.PI;function Rv(n,t,e,r,o,i){let a=n-e,s=t-r;return a*a/(o*o)+s*s/(i*i)<=1}function Vv(n){return n*XN}function Sh(n){return{all:n=n||new Map,on:function(t,e){var r=n.get(t);r?r.push(e):n.set(t,[e])},off:function(t,e){var r=n.get(t);r&&(e?r.splice(r.indexOf(e)>>>0,1):n.set(t,[]))},emit:function(t,e){var r=n.get(t);r&&r.slice().map(function(o){o(e)}),(r=n.get("*"))&&r.slice().map(function(o){o(t,e)})}}}var on=class{constructor(t,e,r){this.uuid=t;this.data=e;this.localMatrix=ke.identity();this.worldMatrix=ke.identity();this.ignoreCameraZoom=!1;this.visible=!0;this._singleBBox=new Vn;this._recursiveBBox=new Vn;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this.stateSelection=null;this.prevState=null;this.currentState=null;this.reversibleToState=null;this.currentTransitionEvent=null;this.previousAction=null;this.name="";this.position=[0,0];this.scale=[1,1];this.rotation=0;this.emitter=Sh();this.dpr=r.dpr??1,this.dataPatched=e}project(t,e){let r=this.worldMatrix;return e&&(r=ke.append(e.worldMatrix,r)),ke.applyInverse(t,r)}intersects(t,e,r,o=!1){return this.visible&&!this.data.raycastLock&&this.intersectsInLocalSpace(...this.project([t,e],r),o)}intersectsInLocalSpace(t,e,r=!1){let{min:o,max:i}=r?this.recursiveBBox:this.singleBBox;return t>=o[0]&&t<=i[0]&&e>=o[1]&&e<=i[1]}applyTransforms(t){t.setTransform(this.worldMatrix,this.ignoreCameraZoom)}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges()),this._recursiveBBox}updateLocalMatrix(){this.localMatrix=ke.compose(this.position,this.scale,Vv(this.rotation),qo.getPivot(this.dataPatched))}updateWorldMatrix(t,e,r){let o=this.parent;e&&o!==null&&o!==void 0&&o.updateWorldMatrix(t,!0,!1),t&&this.updateLocalMatrix(),this.parent?this.worldMatrix=ke.append(this.parent.worldMatrix,this.localMatrix):this.worldMatrix=ke.copy(this.localMatrix),this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}get pivot(){return qo.getPivot(this.data)}getCenter(){return[0,0]}getHalfSize(){return[0,0]}get id(){return this.uuid}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(t=>{t.resetBBoxNeedsUpdateSelf()})}updateTransformState(t){let e=!1;t.position!==void 0&&(e=!0,this.position=t.position),t.rotation!==void 0&&(e=!0,this.rotation=t.rotation),t.scale!==void 0&&(e=!0,this.scale=t.scale),e&&(this.updateWorldMatrix(!0,!1,!0),this.resetBBoxNeedsUpdate())}updateByOp(t,e,r){t.type===0&&t.props.visible!==void 0&&(this.visible=t.props.visible),this.data=e,this.data=e;let o=t,i=Le(t.path,["states","*"]);if(i!==null){if(t.type===0){let[a]=i;if(this?.stateSelection===a){let s={...t.props};if(delete s.name,Object.values(t.props).some(l=>l===void 0)){let l=this.data;if(l!==void 0){let u=lt.zoom(l,t.path.slice(2));if(u)for(let c in t.props)t.props[c]===void 0&&c in u&&(s[c]=u[c])}}o={...t,props:s,path:t.path.slice(2)}}}}else if(t.type===0){let a=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(a!==void 0){if(t.props.name!==void 0&&a.name){let{name:l,...u}=a;a=u}let s=lt.removeOverridden(t.path,t.props,a);o={...t,props:s}}}this.updateByPatchedOpBase(o,ii.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),r)}changeSelectedState(t,e,r=!1){if(!(this.data.states.length===0&&!r)){for(let o of this.data.states)ii.toOps(this.data,o.data).forEach(a=>{let s=aa.replaceProps(a,this.data);this.dataPatched=this.data,this.updateByPatchedOp(s,this.data,e)});if(t!==null){let o=this.data.states.data(t);o&&(this.dataPatched=ii.patch(this.data,o),ii.toOps(this.data,o).forEach(a=>{this.updateByPatchedOp(a,this.dataPatched,e)}))}r&&this.updateTransformState(this.dataPatched),this.stateSelection=t}}updateState(t,e){t.name!==void 0&&(this.name=t.name),t.visible!==void 0&&(this.visible=t.visible),this.updateTransformState(t)}updateByPatchedOpBase(t,e,r){this.dataPatched=e,this.updateByPatchedOp(t,e,r)}updateByPatchedOp(t,e,r){t.path.length===0&&t.type===0&&this.updateState(t.props,r),this.requestRender()}traverseFrameAncestors(t){this.traverseAncestors(e=>{e.data.type==="frame2d"&&t(e)})}traverseAncestors(t){let e=this.parent;for(;e;)t(e),e=e.parent}requestRender(){this.traverseFrameAncestors(t=>{t.requestRender()})}clone(t){let e=new on(this.uuid,this.data,t);return e.parent=void 0,e}addEventListener(t,e){this.emitter.on(t,e)}removeEventListener(t,e){this.emitter.off(t,e)}dispatchEvent(t){this.emitter.emit(t.type,{...t,target:t.target??this})}traverseSortNextHelper(){let t=this.parent;if(t){let e=t.children;if(e){let r=e.indexOf(this)+1;return e[r]?e[r]:t.traverseSortNextHelper()}}}sortNext(){let t=this.children;return t&&t.length>0&&t[0]?t[0]:this.traverseSortNextHelper()}isDescendantOf(t){t instanceof on&&(t=t.uuid);let e=this;for(;e.parent;){if(e.parent.uuid===t)return!0;e=e.parent}return!1}};var er=class extends on{constructor(e,r,o){super(e,r,o);this.uuid=e;this.data=r;this.context=o;this.children=[]}add(e){e.parent&&e.parent instanceof er&&e.parent.remove(e),this.children.push(e),e.parent=this}remove(e){let r=this.children.indexOf(e);r>=0&&(this.children.splice(r,1),e.parent=void 0)}traverse(e){let r=e(this);if(r!==!0)for(let o of this.children)o instanceof er?o.traverse(e):r=e(o)}intersectsChildren(e,r,o,i=!1,a=[],s=!1){for(let l of this.children){let u=l instanceof lr;if(l instanceof er&&!u&&s&&l.intersectsChildren(e,r,o,i,a,!1),l.intersects(e,r,o,u)&&(a.push(l),i))break}return a}updateWorldMatrix(e,r,o){if(super.updateWorldMatrix(e,r,o),o&&this.children)for(let i of this.children)i.updateWorldMatrix(e,!1,!0)}find(e){let r;return this.traverse(o=>{o.uuid===e&&(r=o)}),r}innerDrawChildren(e){for(let r=this.children.length-1;r>=0;r--)this.children[r].draw(e)}resetBBoxNeedsUpdate(){super.resetBBoxNeedsUpdate(),this.traverse(e=>{e.resetBBoxNeedsUpdateSelf()})}clone(e){let r=new er(this.uuid,this.data,e);r.parent=void 0;for(let o of this.children)r.add(o.clone(e));return r}},lr=class extends er{constructor(e,r,o){super(e,r,o);this.uuid=e;this.data=r;this.updateState(r,o)}draw(e){!this.visible||(e.save(),this.applyTransforms(e),this.innerDrawChildren(e),e.restore())}clone(e){let r=new lr(this.uuid,this.data,e);r.parent=void 0;for(let o of this.children)r.add(o.clone(e));return r}};function QN(n,t){let[[e,r],[o,i]]=n,[[a,s],[l,u]]=t,c=(e-o)*(s-u)-(r-i)*(a-l);if(c===0)return!1;let d=((e-a)*(s-u)-(r-s)*(a-l))/c,p=-((e-o)*(r-s)-(r-i)*(e-a))/c;return d>=0&&d<=1&&p>=0&&p<=1}var Gv=[[-1,1],[-1,-1],[1,-1],[1,1]],zv=(n,t,e)=>{let r=n.getCenter(),o=n.getHalfSize(),i=ke.append(t,n.worldMatrix);o[0]===0&&o[1]===0?e.push(ke.apply(r,i)):Gv.forEach(a=>{let s=[a[0]*o[0]+r[0],a[1]*o[1]+r[1]];e.push(ke.apply(s,i))})},Vn=class{constructor(){this.matrix=ke.identity();this.min=[1/0,1/0];this.max=[-1/0,-1/0];this.vertices=[];this.edges=[]}setFromObjectSize(t,e=!1){t.updateWorldMatrix(),this.makeEmpty(),ke.copy(t.worldMatrix,this.matrix);let r=ke.invert(t.worldMatrix);this.expandByObjectSize(t,r,e)}expandByObjectSize(t,e,r=!1){let o=[];r===!0&&t instanceof er?t.traverse(i=>{i.visible&&zv(i,e,o)}):zv(t,e,o),this.setFromPoints(o)}getCenter(){let[t,e]=this.min,[r,o]=this.getHalfSize();return ke.apply([t+r,e+o],this.matrix)}getSize(){return[this.max[0]-this.min[0],this.max[1]-this.min[1]]}getHalfSize(){return[(this.max[0]-this.min[0])*.5,(this.max[1]-this.min[1])*.5]}makeEmpty(){this.min=[1/0,1/0],this.max=[-1/0,-1/0]}setFromPoints(t){this.makeEmpty();for(let e of t)this.expandByPoint(e)}expandByPoint(t){this.min=[Math.min(this.min[0],t[0]),Math.min(this.min[1],t[1])],this.max=[Math.max(this.max[0],t[0]),Math.max(this.max[1],t[1])]}computeVertices(){let[t,e]=this.getHalfSize(),r=this.getCenter(),[o,i,a,s]=ke.getAbcdef(this.matrix),l=ke.create(o,i,a,s,r[0],r[1]);this.vertices=Gv.map(([u,c])=>ke.apply([u*t,c*e],l))}computeEdges(){this.edges=[];for(let t=0,e=this.vertices.length;t<e;++t)this.edges.push([this.vertices[t],this.vertices[(t+1)%e]])}project(t,e){let r=this.matrix;return e&&(r=ke.append(e.worldMatrix,r)),ke.applyInverse(t,r)}intersects(t,e,r){return this.intersectsInLocalSpace(...this.project([t,e],r))}intersectsInLocalSpace(t,e){let{min:r,max:o}=this;return t>=r[0]&&t<=o[0]&&e>=r[1]&&e<=o[1]}containsPoint(t){let[e,r]=t,[o,i]=this.min,[a,s]=this.max;return e>=o&&e<=a&&r>=i&&r<=s}intersectsBBox2D(t){for(let e=0,r=this.edges.length;e<r;e++){let o=this.edges[e];for(let i=0,a=t.edges.length;i<a;i++){let s=t.edges[i];if(QN(o,s))return!0}}for(let e=0,r=t.vertices.length;e<r;e++){let o=t.vertices[e];if(this.containsPoint(o))return!0}return!1}ensureMinMax(){let t=this.min,e=this.max;this.min=[Math.min(t[0],e[0]),Math.min(t[1],e[1])],this.max=[Math.max(t[0],e[0]),Math.max(t[1],e[1])]}copy(t){this.min=[...t.min],this.max=[...t.max],ke.copy(t.matrix,this.matrix),this.computeVertices(),this.computeEdges()}clone(){let t=new Vn;return t.copy(this),t}};var kv,jv=new Promise(n=>{kv=n}),Fv=!1;var cd;function Uv(){if(Fv)return;if(cd)return cd;async function n(){let e=await import("./ui.js");kv(e.default??e),Fv=!0}return cd=n(),cd}function Wv(n){let t=!1;return n.scene.objects.traverse((e,r)=>{(r.type==="Mesh"&&r.geometry.type==="UIGeometry"||r.type==="Page"&&r.uiFrame!==void 0)&&(t=!0)}),t}var Oe,wh;async function KN(n){let t=await jv;Oe||(wh||(wh=t({locateFile:()=>n})),Oe=await wh)}var Hv=ke.identity(),Rl=class{constructor(t,e=1){this.canvas=t;this.dpr=e;this._width=0;this._height=0;this._strokeMode="inside";this._layerBlur=0;this._backgroundBlur=0;this._dropShadowBlur=0;this._dropShadowOffsetX=0;this._dropShadowOffsetY=0;this._dropShadowColor=Ie.transparent;this._innerShadowBlur=0;this._innerShadowOffsetX=0;this._innerShadowOffsetY=0;this._innerShadowSpread=0;this._innerShadowColor=Ie.transparent;this._fonts=new Map;try{let r=t.getBoundingClientRect();t.width=r.width*e,t.height=r.height*e}catch{console.log(t.width,e)}this._currentM3Transform=Hv,this._currentTransform=new Float32Array(Hv)}async init(){if(!this.wasmURL)throw Error("Your must set the wasm binary url with renderer.wasmURL = ... before you can call renderer.init");await KN(this.wasmURL),this._surface=Oe.MakeWebGLCanvasSurface(this.canvas),this.ctx=this._surface?.getCanvas(),this._paint=new Oe.Paint,this._paint.setAntiAlias(!0),this._paintFill=this._paint.copy(),this._paintFill.setStyle(Oe.PaintStyle.Fill),this._paintStroke=this._paint.copy(),this._paintStroke.setStyle(Oe.PaintStyle.Stroke),this.ctx?.scale(this.dpr,this.dpr)}get currentTransform(){return this._currentM3Transform}get currentTransformBuffer(){return this._currentTransform}set currentTransform(t){this._currentM3Transform=t,this._currentTransform.set(t)}async loadFont(t,e){let r=await(await fetch(t)).arrayBuffer();this.registerFont(r,e)}registerFont(t,e){if(this._fonts.has(e))return;let r=Oe.FontMgr.FromData(t);if(r)this._fonts.set(e,r);else throw new Error("Invalid font data for "+e)}get width(){return this._width}get height(){return this._height}set strokeColor(t){this._paintStroke&&this._paintStroke.setColor(ud(t),Oe.ColorSpace.DISPLAY_P3)}set fillColor(t){this._paintFill&&this._paintFill.setColor(ud(t),Oe.ColorSpace.DISPLAY_P3)}set lineWidth(t){this._paintStroke&&this._paintStroke.setStrokeWidth(this._strokeMode==="center"?t:t*2)}set strokeMode(t){this._strokeMode=t}set dropShadowBlur(t){this._dropShadowBlur=t}set dropShadowColor(t){this._dropShadowColor=t}set dropShadowOffsetX(t){this._dropShadowOffsetX=t}set dropShadowOffsetY(t){this._dropShadowOffsetY=t}set innerShadowBlur(t){this._innerShadowBlur=t}set innerShadowColor(t){this._innerShadowColor=t}set innerShadowOffsetX(t){this._innerShadowOffsetX=t}set innerShadowOffsetY(t){this._innerShadowOffsetY=t}set innerShadowSpread(t){this._innerShadowSpread=t}set layerBlur(t){this._layerBlur=t}set backgroundBlur(t){this._backgroundBlur=t}clear(){this.ctx?.clear(Oe.TRANSPARENT)}save(){this.ctx?.save()}restore(){this.ctx?.restore()}beginPath(){this._currentPath?.delete(),this._currentPath=new Oe.Path}closePath(){let t=this._currentPath;if(t){if(t.isEmpty())return;let e=t.getBounds();(e[3]-e[1]||e[2]-e[0])&&t.close()}}fill(){this._paintInner(this._paintFill,!0)}stroke(){this._paintInner(this._paintStroke,!1)}clipRect(t,e,r,o,i=0,a=0,s=0,l=0){let u=Oe.XYWHRect(t,e,r,o);if(i===0&&a===0&&l===0&&s===0)this.ctx?.clipRect(u,Oe.ClipOp.Intersect,!0);else{let c=Oe.RRectXY(u,i,i);c[4]=c[5]=i,c[6]=c[7]=a,c[8]=c[9]=s,c[10]=c[11]=l,this.ctx?.clipRRect(c,Oe.ClipOp.Intersect,!0)}}_applyShadowOffsetMatrix(){if(this.ctx){let t=ke.invert(this.currentTransform);this.ctx.concat(t);let e=ke.translate(ke.identity(),this._dropShadowOffsetX,this._dropShadowOffsetY);this.ctx.concat(e),this.ctx.concat(this._currentTransform)}}_applyEffectsToPaint(t,e,r=!0){if(this.ctx&&this._currentPath){let o,i=!1;if(r&&this._hasDropShadow()){let a=t.copy();a.setColor(ud(this._dropShadowColor));let s;this._dropShadowBlur>0&&(s=Oe.MaskFilter.MakeBlur(Oe.BlurStyle.Normal,this._dropShadowBlur*this.dpr*(this.camera?.scale??1),!1),a.setMaskFilter(s)),this.ctx.save(),this.ctx.clipPath(this._currentPath,Oe.ClipOp.Difference,!0),this._applyShadowOffsetMatrix(),e(a),this.ctx.restore(),a.delete(),s?.delete()}if(this._backgroundBlur>0&&r){this.ctx.save(),this.ctx.clipPath(this._currentPath,Oe.ClipOp.Intersect,!0);let a=Oe.ImageFilter.MakeBlur(this._backgroundBlur,this._backgroundBlur,Oe.TileMode.Clamp,null),s=t.copy();s.setImageFilter(a),s.setAlphaf(1);let l=this._currentPath.computeTightBounds();this.ctx.saveLayer(s,l,null,Oe.SaveLayerInitWithPrevious),this.ctx.drawColor(t.getColor()),this.ctx.restore(),this.ctx.restore(),s.delete(),a.delete(),i=!0}if(this._layerBlur>0){let a=t.copy();o=Oe.MaskFilter.MakeBlur(Oe.BlurStyle.Normal,this._layerBlur*this.dpr*(this.camera?.scale??1),!1),a.setMaskFilter(o),e(a),a.delete(),o.delete(),i=!0}if(i||e(t),r&&this._hasInnerShadow()){let a=new Oe.Paint;a.setAntiAlias(!0),a.setStyle(Oe.PaintStyle.Fill),a.setColor(ud(this._innerShadowColor));let s;this._innerShadowBlur>0&&(s=Oe.MaskFilter.MakeBlur(Oe.BlurStyle.Normal,this._innerShadowBlur*this.dpr*(this.camera?.scale??1),!1),a.setMaskFilter(s));let l=this._currentPath.computeTightBounds(),[u,c,d,p]=l,f=d-u,h=p-c;this.ctx.save(),this.ctx.clipPath(this._currentPath,Oe.ClipOp.Intersect,!0),this.ctx.saveLayer(a,l,null,Oe.SaveLayerInitWithPrevious),this.ctx?.translate(this._innerShadowOffsetX,this._innerShadowOffsetY),this.ctx.drawRect(Oe.XYWHRect(-1e3-this._innerShadowOffsetX,-1e3-this._innerShadowOffsetY,2e3+f+Math.abs(this._innerShadowOffsetX*2),2e3+h+Math.abs(this._innerShadowOffsetY*2)),a),a.setBlendMode(Oe.BlendMode.Clear),this.ctx.drawPath(this._currentPath,a),this.ctx.restore(),this.ctx.restore(),a.delete(),s?.delete()}}}_paintInner(t,e=!0){if(this.ctx&&this._currentPath&&t){let r=this.ctx,o=this._currentPath;this._applyEffectsToPaint(t,i=>{let a=!1;!e&&this._strokeMode!=="center"&&(r.save(),r.clipPath(o,this._strokeMode==="outside"?Oe.ClipOp.Difference:Oe.ClipOp.Intersect,!0),a=!0),r.drawPath(o,i),a&&r.restore()},e)}}_hasDropShadow(){return this._dropShadowColor?.a>0}_hasInnerShadow(){return this._innerShadowColor?.a>0}path(t){this._currentPath?.addPath(Oe.Path.MakeFromSVGString(t))}ellipse(t,e,r,o,i,a,s,l){if(!qv([t,e,r,o])||!this._currentPath)return;if(r<0||o<0)throw Error("radii cannot be negative");let u=Oe.XYWHRect(t-r,e-o,r*2,o*2);this._currentPath?.addOval(u)}rect(t,e,r,o,i=0,a=0,s=0,l=0){let u=Oe.XYWHRect(t,e,r,o);if(!!qv(u))if(i===0&&a===0&&l===0&&s===0)this._currentPath?.addRect(u);else{let c=Oe.RRectXY(u,i,i);c[4]=c[5]=i,c[6]=c[7]=a,c[8]=c[9]=s,c[10]=c[11]=l,this._currentPath?.addRRect(c)}}getHorizontalAlign(t){switch(t){case 2:return Oe.TextAlign.Right;case 3:return Oe.TextAlign.Center;case 4:return Oe.TextAlign.Justify;case 1:default:return Oe.TextAlign.Left}}drawTextInner(t,e,r,[o,i,a,s],l,u,c=!0){let d=0,{ctx:p}=this;if(!p)return d;let f=u.copy(),h=u.copy();return h.setAlphaf(0),this._applyEffectsToPaint(f,m=>{e.pushPaintStyle(r,m,h),e.addText(t);let y=e.build();y.layout(a);let g=i;l===2?g+=(s-y.getHeight())/2:l===3&&(g+=s-y.getHeight()),p.drawParagraph(y,o,g),d=y.getHeight(),e.reset(),y.delete()},c),f.delete(),h.delete(),d}drawText(t,e){let r=0,o=this._fonts.get(e.font),{ctx:i,_paintFill:a,_paintStroke:s}=this;if(o&&i){let l=new Oe.TextStyle({fontFamilies:[e.font],fontSize:e.fontSize,heightMultiplier:e.lineHeight,letterSpacing:e.letterSpacing}),u=new Oe.ParagraphStyle({textStyle:l,textAlign:this.getHorizontalAlign(e.horizontalAlign)}),c=Oe.XYWHRect(e.x,e.y,e.width,e.height),d=Oe.ParagraphBuilder.Make(u,o);a&&(r=this.drawTextInner(t,d,l,c,e.verticalAlign,a,!0)),s&&(r=this.drawTextInner(t,d,l,c,e.verticalAlign,s,!1)),d.delete()}return{height:r}}render(){this._surface?.flush()}moveTo(t,e){this._currentPath?.moveTo(t,e)}lineTo(t,e){this._currentPath?.lineTo(t,e)}bezierCurveTo(t,e,r,o,i,a){this._currentPath?.cubicTo(t,e,r,o,i,a)}quadraticCurveTo(t,e,r,o){this._currentPath?.quadTo(t,e,r,o)}setTransform(t,e=!1){if(!this.ctx)return;let r=this.ctx.getTotalMatrix(),o=ke.invert(r);if(o&&this.ctx.concat(o),this.ctx?.scale(this.dpr,this.dpr),this.camera?.enabled&&(this.ctx?.concat(this.camera.worldMatrix),e)){let i=ke.getScale(this.camera.worldMatrix);this.ctx?.scale(1/i[0],1/i[1])}this.ctx?.concat(t),this.currentTransform=t}transform(t){this.ctx?.concat(t)}setSize(t,e){t===this._width&&e===this._height||(this._width=t,this._height=e,this.canvas.style.width=t+"px",this.canvas.style.height=e+"px",this.canvas.width=t*this.dpr,this.canvas.height=e*this.dpr,this._surface&&(this._surface=Oe.MakeWebGLCanvasSurface(this.canvas),this.ctx=this._surface?.getCanvas()))}};function qv(n){for(let t=0;t<n.length;t++)if(n[t]!==void 0&&!Number.isFinite(n[t]))return!1;return!0}function ud({r:n,g:t,b:e,a:r}){return Oe.Color4f(n,t,e,r)}var Vl=class{constructor(t,e,r){this.uuid=t;this.data=e;this.enabled=!1;this.color=Ie.transparent;this.blurRadius=0;this.offset=[0,0];this.spread=0;this.update(e)}update(t){t.color!==void 0&&(this.color=t.color),t.enabled!==void 0&&(this.enabled=t.enabled),t.blurRadius!==void 0&&(this.blurRadius=t.blurRadius),t.offset!==void 0&&(this.offset=t.offset),t.spread!==void 0&&(this.spread=t.spread)}};var zl=class{constructor(t,e,r){this.uuid=t;this.data=e;this.enabled=!1;this.radius=0;this.update(e)}update(t){t.enabled!==void 0&&(this.enabled=t.enabled),t.radius!==void 0&&(this.radius=t.radius)}};var dd=class{constructor(t,e,r){this.uuid=t;this.data=e;this.enabled=!1;this.color=Ie.transparent;this.update(e)}update(t){t.enabled!==void 0&&(this.enabled=t.enabled),t.color!==void 0&&(this.color=t.color)}};var pd=class{constructor(t,e,r){this.uuid=t;this.data=e;this.enabled=!1;this.color=Ie.transparent;this.thickness=0;this.mode="inside";this.update(e)}update(t){t.enabled!==void 0&&(this.enabled=t.enabled),t.color!==void 0&&(this.color=t.color),t.thickness!==void 0&&(this.thickness=t.thickness),t.mode!==void 0&&(this.mode=t.mode)}};var gr=class extends on{constructor(e,r,o){super(e,r,o);this.uuid=e;this.data=r;this.autoClose=!0;this.fill=new dd(e+"-fill",r.fill,o),this.stroke=new pd(e+"-stroke",r.stroke,o),this.dropShadow=new Vl(e+"-dropShadow",r.dropShadow,o),this.innerShadow=new Vl(e+"-innerShadow",r.innerShadow,o),this.backgroundBlur=new zl(e+"-backgroundBlur",r.backgroundBlur,o),this.layerBlur=new zl(e+"-layerBlur",r.layerBlur,o)}applyFillStroke(e){e.fillColor=this.fill.enabled?this.fill.color:Ie.transparent,e.strokeColor=this.stroke.enabled&&this.stroke.thickness>0?this.stroke.color:Ie.transparent,e.strokeMode=this.stroke.mode,e.lineWidth=this.stroke.thickness}applyFilters(e){this.layerBlur.enabled?e.layerBlur=this.layerBlur.radius*5:e.layerBlur=0,this.backgroundBlur.enabled?e.backgroundBlur=this.backgroundBlur.radius*5:e.backgroundBlur=0,this.dropShadow.enabled?(e.dropShadowBlur=this.dropShadow.blurRadius*5,e.dropShadowColor=this.dropShadow.color,e.dropShadowOffsetX=this.dropShadow.offset[0],e.dropShadowOffsetY=this.dropShadow.offset[1]):e.dropShadowColor=Ie.transparent,this.innerShadow.enabled?(e.innerShadowSpread=this.innerShadow.spread,e.innerShadowBlur=this.innerShadow.blurRadius*5,e.innerShadowColor=this.innerShadow.color,e.innerShadowOffsetX=this.innerShadow.offset[0],e.innerShadowOffsetY=this.innerShadow.offset[1]):e.innerShadowColor=Ie.transparent}innerDraw(e){}draw(e){!this.visible||(e.save(),this.applyTransforms(e),this.applyFilters(e),this.applyFillStroke(e),e.beginPath(),this.innerDraw(e),this.autoClose&&e.closePath(),this.fill.enabled&&e.fill(),this.stroke.enabled&&e.stroke(),e.restore())}updateByPatchedOp(e,r,o){super.updateByPatchedOp(e,r,o),e.type===0&&(Le(e.path,["fill"])?this.fill.update(e.props):Le(e.path,["stroke"])?this.stroke.update(e.props):Le(e.path,["dropShadow"])?this.dropShadow.update(e.props):Le(e.path,["innerShadow"])?this.innerShadow.update(e.props):Le(e.path,["layerBlur"])?this.layerBlur.update(e.props):Le(e.path,["backgroundBlur"])?this.backgroundBlur.update(e.props):this.resetBBoxNeedsUpdate())}updateState(e,r){super.updateState(e,r),e.fill!==void 0&&this.fill.update(e.fill),e.stroke!==void 0&&this.stroke.update(e.stroke),e.dropShadow!==void 0&&this.dropShadow.update(e.dropShadow),e.innerShadow!==void 0&&this.innerShadow.update(e.innerShadow),e.layerBlur!==void 0&&this.layerBlur.update(e.layerBlur),e.backgroundBlur!==void 0&&this.backgroundBlur.update(e.backgroundBlur)}clone(e){let r=new gr(this.uuid,this.data,e);return r.parent=void 0,r}};var zn=class extends gr{constructor(e,r,o){super(e,r,o);this.uuid=e;this.data=r;this.width=0;this.height=0;this.updateState(r,o)}innerDraw(e){e.ellipse(this.width*.5,this.height*.5,this.width*.5,this.height*.5,0,0,Math.PI*2)}intersectsInLocalSpace(e,r){return Rv(e,r,this.width*.5,this.height*.5,this.width*.5,this.height*.5)}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateSizeState(e){let r=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,r=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,r=!0),r&&this.updateWorldMatrix(!0,!1,!0)}updateState(e,r){super.updateState(e,r),this.updateSizeState(e)}clone(e){let r=new zn(this.uuid,this.data,e);return r.parent=void 0,r}};var Io=class extends gr{constructor(e,r,o){super(e,r,o);this.uuid=e;this.data=r;this.width=0;this.height=0;this.cornerRadius=[0,0,0,0];this.updateState(r,o)}innerDraw(e){e.rect(0,0,this.width,this.height,...this.cornerRadius)}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateCornerState(e){e.cornerRadius!==void 0&&(this.cornerRadius=e.cornerRadius)}updateSizeState(e){let r=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,r=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,r=!0),r&&this.updateWorldMatrix(!0,!1,!0)}updateState(e,r){super.updateState(e,r),this.updateSizeState(e),this.updateCornerState(e)}clone(e){let r=new Io(this.uuid,this.data,e);return r.parent=void 0,r}};var Gn=class extends gr{constructor(e,r,o){super(e,r,o);this.uuid=e;this.data=r;this._textHeight=0;this._textHeightDirty=!0;this.width=0;this.height=0;this.updateState(r,o)}get textHeight(){return this._textHeight}applyFillStroke(e){e.fillColor=this.fill.enabled?this.fill.color:Ie.transparent,e.strokeColor=this.stroke.enabled&&this.stroke.thickness>0?this.stroke.color:Ie.transparent,e.strokeMode="center",e.lineWidth=this.stroke.thickness}innerDraw(e){this._fontHolder?.arrayBuffer&&this._fontHolder.arrayBuffer.byteLength>1&&this.data.font&&e.registerFont(this._fontHolder.arrayBuffer,this.data.font);let r=this.data.textTransform,o=this.data.text.textValue.toString(),i=r===2?o.toUpperCase():r===3?o.toLowerCase():o,{height:a}=e.drawText(i,{x:0,y:0,width:this.width,height:this.height,fontSize:this.data.fontSize,lineHeight:this.data.lineHeight??1,letterSpacing:this.data.letterSpacing??0,horizontalAlign:this.data.horizontalAlign,verticalAlign:this.data.verticalAlign,font:this.data.font});this._textHeight=a}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateSizeState(e){let r=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,r=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,r=!0),r&&this.updateWorldMatrix(!0,!1,!0)}updateFontState(e,{shared:r}){e.font!==void 0&&(this._fontHolder=r.getFont(e.font),this._fontHolder&&!this._fontHolder.isLoaded&&this._fontHolder.loadingPromise.then(()=>{this.requestRender()}))}updateState(e,r){super.updateState(e,r),this.updateSizeState(e),this.updateFontState(e,r)}clone(e){let r=new Gn(this.uuid,this.data,e);return r.parent=void 0,r}};var Cs=class extends gr{constructor(e,r,o){super(e,r,o);this.uuid=e;this.data=r;this.curves=[];this.extremasBBox={min:[0,0],max:[0,0]};this.updateState(r,o)}computeExtremas(){this.curves.length===0&&this.computeCurves();let e=this.curves.map(i=>fd.extremas(i)),r=[1/0,1/0],o=[-1/0,-1/0];for(let i=0,a=e.length;i<a;i++){let s=e[i];s[0][0]<r[0]&&(r[0]=s[0][0]),s[0][1]<r[1]&&(r[1]=s[0][1]),s[1][0]>o[0]&&(o[0]=s[1][0]),s[1][1]>o[1]&&(o[1]=s[1][1])}return this.extremasBBox.min=[r[0],r[1]],this.extremasBBox.max=[o[0],o[1]],this.extremasBBox}computeCurves(){this.curves=[];for(let o=1,i=this.data.points.length;o<i;o++){let a=this.data.points[o].data,s=this.data.points[o-1].data,l={start:s.position,cp1:s.controlNext.position,cp2:a.controlPrevious.position,end:a.position};this.curves.push(l)}let e=this.data.points[0].data,r=this.data.points[this.data.points.length-1].data;if(this.data.isClosed){let o={start:r.position,cp1:r.controlNext.position,cp2:e.controlPrevious.position,end:e.position};this.curves.push(o)}}getCenter(){let[e,r]=this.extremasBBox.min,[o,i]=this.getHalfSize();return[e+o,r+i]}getHalfSize(){let{min:e,max:r}=this.extremasBBox;return[(r[0]-e[0])*.5,(r[1]-e[1])*.5]}innerDraw(e){for(let i=0,a=this.data.points.length;i<a;i++){let s=this.data.points[i].data;if(i===0){let[l,u]=s.position;e.moveTo(l,u)}else{let l=this.data.points[i-1].data,[u,c]=l.controlNext.position,[d,p]=s.controlPrevious.position,[f,h]=s.position,m={start:l.position,cp1:l.controlNext.position,cp2:s.controlPrevious.position,end:s.position};fd.derive(m),e.bezierCurveTo(u,c,d,p,f,h)}}let r=this.data.points[0].data,o=this.data.points[this.data.points.length-1].data;if(this.data.isClosed){let[i,a]=o.controlNext.position,[s,l]=r.controlPrevious.position,[u,c]=r.position;e.bezierCurveTo(i,a,s,l,u,c)}}updateState(e,r){super.updateState(e,r),this.computeExtremas()}clone(e){let r=new Cs(this.uuid,this.data,e);return r.parent=void 0,r}},fd;(i=>{function n(a){let s=a.start,l=a.cp1,u=a.cp2,c=a.end,d=[3*(l[0]-s[0]),3*(l[1]-s[1])],p=[3*(u[0]-l[0]),3*(u[1]-l[1])],f=[3*(c[0]-u[0]),3*(c[1]-u[1])],h={start:d,cp:p,end:f};return a.derivative=h,h.derivative=Ah.derive(h),h}i.derive=n;function t(a,s,l,u=!1){let c=a-2*s+l;if(c!==0){let d=-Math.sqrt(Math.abs(s*s-a*l)),p=-a+s,f=-(d+p)/c,h=-(-d+p)/c;return[f,h]}else if(s!==l&&c===0)return[(2*s-l)/(2*(s-l))];return[]}function e(a){let s=a.derivative??i.derive(a),l=s.start,u=s.cp,c=s.end;return[t(l[0],u[0],c[0]),t(l[1],u[1],c[1])]}i.droot=e;function r(a){let[s,l]=i.droot(a),u=[a.start[0],a.end[0]],c=[a.start[1],a.end[1]];for(let d of s)u.push(i.compute(a,Math.min(1,Math.max(0,d)))[0]);for(let d of l)c.push(i.compute(a,Math.min(1,Math.max(0,d)))[1]);return u.sort((d,p)=>d-p),c.sort((d,p)=>d-p),[[u[0],c[0]],[u[u.length-1],c[c.length-1]]]}i.extremas=r;function o(a,s){if(s===0)return[...a.start];if(s===1)return[...a.end];let l=1-s,u=l*l,c=s*s,d=u*l,p=u*s*3,f=l*c*3,h=s*c;return[d*a.start[0]+p*a.cp1[0]+f*a.cp2[0]+h*a.end[0],d*a.start[1]+p*a.cp1[1]+f*a.cp2[1]+h*a.end[1]]}i.compute=o})(fd||(fd={}));var Ah;(r=>{function n(o){let i=o.start,a=o.cp,s=o.end,l=[2*(a[0]-i[0]),2*(a[1]-i[1])],u=[2*(s[0]-a[0]),2*(s[1]-a[1])],c={start:l,end:u};return c.derivative=_h.derive(c),o.derivative=c,c}r.derive=n;function t(o){let i=o.derivative??r.derive(o),a=i.start,s=i.end;return[a[0]!==s[0]?a[0]/(a[0]-s[0]):0,a[1]!==s[1]?a[1]/(a[1]-s[1]):0]}r.droot=t;function e(o,i){if(i===0)return[...o.start];if(i===1)return[...o.end];let a=1-i,s=a*a,l=i*i,u=s,c=a*i*2,d=l;return[u*o.start[0]+c*o.cp[0]+d*o.end[0],u*o.start[1]+c*o.cp[1]+d*o.end[1]]}r.compute=e})(Ah||(Ah={}));var _h;(e=>{function n(r){let o=r.start,i=r.end,a=[i[0]-o[0],i[1]-o[1]];return r.derivative=a,r.derivative}e.derive=n;function t(r,o){if(o===0)return[...r.start];if(o===1)return[...r.end];let i=r.start,a=r.end;return[i[0]+(a[0]-i[0])*o,i[1]+(a[1]-i[1])*o]}e.compute=t})(_h||(_h={}));var Or=class extends er{constructor(e,r,o){super(e,r,o);this.uuid=e;this.width=0;this.height=0;this.clipped=!0;this.background=new Io(e+"-background",wa.defaultData,o),this.background.parent=this,this.updateState(r,o)}get fill(){return this.background.fill}get stroke(){return this.background.stroke}get backgroundBlur(){return this.background.backgroundBlur}get layerBlur(){return this.background.layerBlur}get dropShadow(){return this.background.dropShadow}get innerShadow(){return this.background.innerShadow}get cornerRadius(){return this.background.cornerRadius}set cornerRadius(e){this.background.cornerRadius=e}updateLocalMatrix(){super.updateLocalMatrix(),this.background?.updateLocalMatrix()}updateWorldMatrix(e,r,o){super.updateWorldMatrix(e,r,o),this.background?.updateWorldMatrix(e,r,o)}draw(e){if(!this.visible)return;e.save();let r=this.width,o=this.height;this.applyTransforms(e),this.background.width=r,this.background.height=o,this.background.draw(e),this.clipped&&e.clipRect(0,0,r,o,...this.cornerRadius),this.innerDrawChildren(e),e.restore()}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateCornerState(e){e.cornerRadius!==void 0&&(this.cornerRadius=e.cornerRadius)}updateSizeState(e){let r=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,r=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,r=!0),r&&this.updateWorldMatrix(!0,!1,!0)}updateState(e,r){super.updateState(e,r),this.updateSizeState(e),this.updateCornerState(e),e.fill!==void 0&&this.fill.update(e.fill),e.stroke!==void 0&&this.stroke.update(e.stroke),e.dropShadow!==void 0&&this.dropShadow.update(e.dropShadow),e.innerShadow!==void 0&&this.innerShadow.update(e.innerShadow),e.layerBlur!==void 0&&this.layerBlur.update(e.layerBlur),e.backgroundBlur!==void 0&&this.backgroundBlur.update(e.backgroundBlur),e.clipped!==void 0&&(this.clipped=e.clipped)}requestRender(){super.requestRender(),this.dispatchEvent({type:"render"})}dispose(){this.removeEventListener("render")}updateByPatchedOp(e,r,o){super.updateByPatchedOp(e,r,o),e.type===0&&(Le(e.path,["fill"])?this.fill.update(e.props):Le(e.path,["stroke"])?this.stroke.update(e.props):Le(e.path,["dropShadow"])?this.dropShadow.update(e.props):Le(e.path,["innerShadow"])?this.innerShadow.update(e.props):Le(e.path,["layerBlur"])?this.layerBlur.update(e.props):Le(e.path,["backgroundBlur"])?this.backgroundBlur.update(e.props):this.resetBBoxNeedsUpdate())}clone(e){let r=new Or(this.uuid,this.data,e);r.parent=void 0;for(let o of this.children)r.add(o.clone(e));return r}};var Qv=Ht(Ph(),1),nn=class extends gr{constructor(e,r,o){super(e,r,o);this.uuid=e;this.data=r;this._pathBBox=new DOMRect;this.path="";this.updateState(r,o),this.autoClose=!1,this.computeSVGBBox()}computeSVGBBox(){let e=document.createElementNS("http://www.w3.org/2000/svg","svg"),r=document.createElementNS("http://www.w3.org/2000/svg","path");document.body.appendChild(e),r.setAttribute("d",this.path),e.appendChild(r),this._pathBBox=r.getBBox(),e.remove()}innerDraw(e){e.path(this.path)}intersectsInLocalSpace(e,r){return e>=this._pathBBox.x&&e<=this._pathBBox.x+this._pathBBox.width&&r>=this._pathBBox.y&&r<=this._pathBBox.y+this._pathBBox.height}getCenter(){return[(this._pathBBox.x+this._pathBBox.width)/2,(this._pathBBox.y+this._pathBBox.height)/2]}getHalfSize(){return[(this._pathBBox.x+this._pathBBox.width)/2,(this._pathBBox.y+this._pathBBox.height)/2]}updateState(e,r){super.updateState(e,r),e.path!==void 0&&(this.path=e.path,this.computeSVGBBox())}clone(e){let r=new nn(this.uuid,this.data,e);return r.parent=void 0,r}};function Kv(n,t=1,e=1){if(t<=0||e<=0)return n;let o=(0,Qv.parseSVG)(n).map(i=>{let a={...i};return"x"in a&&(a.x=a.x*t),"y"in a&&(a.y=a.y*e),"x1"in a&&(a.x1=a.x1*t),"x2"in a&&(a.x2=a.x2*t),"y1"in a&&(a.y1=a.y1*e),"y2"in a&&(a.y2=a.y2*e),"rx"in a&&(a.rx=a.rx*t),"ry"in a&&(a.ry=a.ry*e),a});return Zv(o)}function Zv(n){let t=["rx","ry","xAxisRotation","largeArc","sweep","x1","y1","x2","y2","x","y"],e;return n.map(r=>{let o=[];t.forEach(a=>{if(a in r){let s=r[a]*1;o.length&&s>=0&&o.push(","),o.push(s)}});let i=(e===r.code?o[0]<0?"":",":r.code)+o.join("");return e=r.code,i}).join("")}function Jv(n,t,e){switch(t.type){case"ellipse2d":return new zn(n,t,e);case"rectangle2d":return new Io(n,t,e);case"text2d":return new Gn(n,t,e);case"vector2d":return new Cs(n,t,e);case"path2d":return new nn(n,t,e);case"frame2d":return new Or(n,t,e);case"group2d":default:return new lr(n,t,e)}}var Oh=class{constructor(t,e,r){this.uuid=t;this.data=e;this.group=new lr(Oh.GROUP_ID,{...Qs.defaultData},r),this.createChildrenObjects(e.objects,this.group,r)}createObject(t,e,r,o,i,a){let s=Jv(t,e,a);s&&(o.add(s),o.children.splice(i,0,o.children.pop()),s.updateWorldMatrix(),r.length>0&&(s instanceof lr||s instanceof Or)&&this.createChildrenObjects(r,s,a))}createChildrenObjects(t,e,r){let o=0;for(let i of t)this.createObject(i.id,i.data,i.children,e,o,r),o+=1}draw(t){this.group.draw(t)}updateEntityByOp(t,e,r,o){let i=this.find(t);if(i)try{i.updateByOp(e,r,{shared:o})}catch(a){console.error(a)}}updateTreeByOp(t,e){if(t.path.length===0&&t.type===7){let r=t.parent===null?this.group:this.find(t.parent);r!==void 0&&r instanceof er&&(this.createObject(t.id,t.data,t.children,r,t.localIndex,e),r.requestRender())}else if(t.path.length===0&&t.type===8){let r=this.find(t.id);if(r!==void 0&&r.parent!==void 0&&r.parent instanceof er){let o=r.parent;r.resetBBoxNeedsUpdate(),o?.remove(r),o?.requestRender()}}else if(t.path.length===0&&t.type===9){let r=this.find(t.id);if(r!==void 0){let o=r.parent,i=t.parent===null?this:this.find(t.parent);if(i===void 0&&!1&&console.error("unexpected",i,t),i instanceof er||i===this){i.add(r);let a=t.localIndex;i.children.splice(a,0,i.children.pop()),r.updateWorldMatrix(!0,!1,!0),o?.requestRender(),r.requestRender()}r.resetBBoxNeedsUpdate()}}}add(t){this.group.add(t)}remove(t){this.group.remove(t)}traverse(t){this.group.traverse(e=>{e!==this.group&&t(e)})}intersectsChildren(t,e,r,o=!1,i=[]){return this.group.intersectsChildren(t,e,r,o,i,!0)}find(t){return this.group.find(t)}get children(){return this.group.children}project(t,e){return this.group.project(t,e)}getWithSortKey(t){let e=this.find(t);if(e===void 0)return;let r=[],o=e;for(;o!==this.group;){let i=o;o=o.parent;let a=o.children.indexOf(i);r.splice(0,0,a)}return{entity:e,sortKey:r}}getAllSorted(t){let e=[];for(let r of t){let o=this.getWithSortKey(r.id);o!==void 0&&e.push(o)}return e.sort((r,o)=>Ql(r.sortKey,o.sortKey)),e.map(r=>r.entity)}},_i=Oh;_i.GROUP_ID="scene2d";function Ch({constraints:n,newParentWidth:t,newParentHeight:e,initialParentWidth:r,initialParentHeight:o,objectInitialWidth:i,objectInitialHeight:a,objectInitialPosition:s}){let{horizontalConstraint:l,verticalConstraint:u}=n,c=t-r,d=e-o,p=i,f=a,h=s[0],m=s[1];if(l!==0){if(l===1)h+=c;else if(l===3)h+=c/2;else if(l===2)p=Math.max(1,p+c);else if(l===4){let y=t/r;p*=y,h*=y}}if(u!==0){if(u===1)m+=d;else if(u===3)m+=d/2;else if(u===2)f=Math.max(1,f+d);else if(u===4){let y=e/o;f*=y,m*=y}}return{width:p,height:f,position:[h,m]}}var tD=Ht(Ph(),1);var Ise={mm:{mm:1,cm:.1,in:1/25.4,pt:72/25.4,pc:6/25.4,px:-1},cm:{mm:10,cm:1,in:1/2.54,pt:72/2.54,pc:6/2.54,px:-1},in:{mm:25.4,cm:2.54,in:1,pt:72,pc:6,px:-1},pt:{mm:25.4/72,cm:2.54/72,in:1/72,pt:1,pc:6/72,px:-1},pc:{mm:25.4/6,cm:2.54/6,in:1/6,pt:72/6,pc:1,px:-1},px:{mm:1,px:1,cm:1,in:1,pt:1,pc:1}};import{MathUtils as rD}from"three";var oD=ke.identity(),Ts=class{constructor(t,e,r,o){this.uuid=t;this.width=e;this.height=r;this.context=o;this.enabled=!0;this.isScreenSpace=!1;this.isFrameDirty=!1;this.onRenderRequestedDownstream=()=>{this.isFrameDirty=!0,this.context.shared.requestRender()};this.onFrameOverrideObjectEvent=t=>{if(t.target?.uuid!==void 0){let e=this.frameRoot?.find(t.target.uuid);e&&e.dispatchEvent({...t,target:e})}};this.scene2d=new _i(rD.generateUUID(),su.defaultData,{dpr:window.devicePixelRatio,shared:o.shared}),this.canvas=document.createElement("canvas"),this.renderer=new Rl(this.canvas),o.shared.addCanvas(this.uuid,this.canvas),this.textureHolder=o.shared.canvas(this.uuid),this.promise=this.init()}async init(){this.renderer instanceof Rl&&(this.renderer.wasmURL=Db.skiaWasmUrl),await this.renderer.init()}render(){this.isFrameDirty&&(this.renderer.clear(),this.frameOverride?.draw(this.renderer),this.renderer.render(),this.textureHolder?.setNeedsUpdate(!0),this.isFrameDirty=!1)}updateEntity2DByOp(t,e,r,o){this.scene2d.updateEntityByOp(t,e,r,o),this.applySize()}updateTreeByOp(t,e){this.scene2d.updateTreeByOp(t,e),this.applySize()}applyOverrides(t){if(this.frameOverride&&this.frameRoot){this.frameOverride.position=[0,0],this.frameOverride.rotation=0;let e=t?.width??this.width,r=t?.height??this.height;this.frameOverride.width=e,this.frameOverride.height=r,this.frameOverride.localMatrix=oD,this.isScreenSpace&&(this.frameOverride.fill.color=Ie.from0to1([0,0,0,0])),this.frameOverride.data={...this.frameOverride.data,width:e,height:r},eS({objectOverride:this.frameOverride,objectRoot:this.frameRoot,newParentWidth:this.frameOverride.width,newParentHeight:this.frameOverride.height,initialParentWidth:this.frameRoot.width,initialParentHeight:this.frameRoot.height}),this.frameOverride.updateWorldMatrix(!0,!1,!0)}}applySize(t){let e=t?.width??this.width,r=t?.height??this.height;this.width=e,this.height=r,this.renderer.dpr=this.isScreenSpace?window.devicePixelRatio:Math.floor(2048/Math.max(e,r)),this.renderer.setSize(e,r),this.textureHolder?.dispose(),this.applyOverrides(t),this.frameOverride?.requestRender()}applyFrame(t){let e=this.context.scene.find2D(t);if(!(!e||!(e instanceof Or)))return this.disposeFrameOverride(),this.frameRoot=e,this.frameOverride=e.clone({dpr:this.renderer.dpr,shared:this.context.shared}),this.scene2d.add(this.frameOverride),this.applySize(),this.textureHolder?.dispose(),this.frame?.addEventListener("render",this.onRenderRequestedDownstream),this.frameOverride.traverse(r=>{r.addEventListener("beginState",this.onFrameOverrideObjectEvent)}),this.frameOverride.traverse(r=>{r.addEventListener("completeState",this.onFrameOverrideObjectEvent)}),this.frame?.requestRender(),e}get frame(){return this.frameOverride}get frameId(){return this.frame?.uuid}find(t){return this.scene2d.find(t)}get texture(){return this.textureHolder?.getTexture(1001)}disposeFrameOverride(){this.frameOverride?.removeEventListener("render",this.onRenderRequestedDownstream),this.frameOverride?.traverse(t=>{t.removeEventListener("beginStateChange",this.onFrameOverrideObjectEvent)}),this.frameOverride?.traverse(t=>{t.removeEventListener("completeState",this.onFrameOverrideObjectEvent)}),this.frameOverride&&this.scene2d.remove(this.frameOverride)}};function eS({objectOverride:n,objectRoot:t,newParentWidth:e,newParentHeight:r,initialParentWidth:o,initialParentHeight:i}){if(n instanceof Or&&t instanceof Or||n instanceof lr&&t instanceof lr)for(let a=0,s=n.children.length;a<s;a++){let l=n.children[a],u=t.children[a];l&&u&&l.uuid===u.uuid&&iD({objectOverride:l,objectRoot:u,newParentWidth:e,newParentHeight:r,initialParentWidth:o,initialParentHeight:i})}}function nD(n){if(Th(n))return[n.width,n.height];if(n instanceof nn){let[t,e]=n.getHalfSize();return[t*2,e*2]}else if(n instanceof lr){let[t,e]=n.recursiveBBox.getHalfSize();return[t*2,e*2]}return[0,0]}function iD({objectOverride:n,objectRoot:t,newParentWidth:e,newParentHeight:r,initialParentWidth:o,initialParentHeight:i}){let[a,s]=nD(t),{width:l,height:u,position:c}=Ch({constraints:n.data,newParentWidth:e,newParentHeight:r,initialParentWidth:o,initialParentHeight:i,objectInitialWidth:a,objectInitialHeight:s,objectInitialPosition:t.position});if(n.position=c,n.data={...n.data,position:c},n.states)for(let d in n.states)aD({stateId:d,objectOverride:n,objectRoot:t,newParentWidth:e,newParentHeight:r,initialParentWidth:o,initialParentHeight:i});if(Th(n)||n instanceof lr)Th(n)&&(n.width=l,n.height=u,n.data={...n.data,width:l,height:u}),eS({objectOverride:n,objectRoot:t,newParentWidth:l,newParentHeight:u,initialParentWidth:a,initialParentHeight:s});else if(n instanceof nn){let d=t,p=a!==0?l/a:1,f=s!==0?u/s:1;n.path=Kv(d.path,p,f),n.data={...n.data,path:n.path}}}function aD({stateId:n,objectOverride:t,objectRoot:e,newParentWidth:r,newParentHeight:o,initialParentWidth:i,initialParentHeight:a}){let s=t.states?.[n],l=e.states?.[n];if(s&&l){let{width:u,height:c,position:d}=Ch({constraints:t.data,newParentWidth:r,newParentHeight:o,initialParentWidth:i,initialParentHeight:a,objectInitialWidth:qo.isResizeable(l)?l.width:0,objectInitialHeight:qo.isResizeable(l)?l.height:0,objectInitialPosition:l.position});Object.assign(t.states[n],{position:d}),qo.isResizeable(s)&&Object.assign(t.states[n],{width:u,height:c})}}function Th(n){return n instanceof Io||n instanceof Or||n instanceof zn||n instanceof Gn}var zr=class extends Ca(uD){constructor(e,r,o){super();this.data=r;this.bgColor=new Bt(1,1,1,1);this.fog=null;this.backupFog=new lD(16777215,.1,2e3);this.fogUseBGColor=!1;this.isActive=!1;this.aoColor=new sD;this.penumbraSizeArrayCache=null;this.super_Entity(e,r),this.personalCamera=new rn(bn,{...oi.defaultData,...r.camera,name:"Personal Camera"}),this.personalCamera.objectHelper.visible=!1,this.add(this.personalCamera),this.activeCamera=this.personalCamera,this.ambientLight=new cD(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.ambientLight.removeFromParent(),this.add(this.ambientLight),r.uiScene?this.uiScene=new _i((Array.isArray(e)?e[0]:e)+"-ui",r.uiScene,{dpr:window.devicePixelRatio,shared:o.shared}):r.uiFrame&&this.createUICanvas(r.uiFrame,o)}get scene(){return this.parent}get postprocessing(){return this.data.postprocessing}get frameId(){return this.data.uiFrame}get frame(){return this.uiCanvas?.frame}createUICanvas(e,r){this.uiCanvas=new Ts(this.uuid+"-uiscreen",window.innerWidth,window.innerHeight,r),this.uiCanvas.isScreenSpace=!0,this.uiCanvas.promise.then(()=>{this.uiCanvas?.applyFrame(e),this.uiCanvas?.applySize()})}updateVisible(){}setBackgroundColor(e){this.bgColor=e,this.fogUseBGColor===!0&&(this.backupFog.color=e)}entityChildrenCount(){return this.uiScene?this.uiScene.children.length:super.entityChildrenCount()}updateAmbientLight(e,r){e.color!==void 0&&(this.ambientLight.color=Qt(e.color,r)),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.traverseEntity(r=>{r instanceof yr&&r.recomputeBoolean()}),this.updateShadow(this.data.shadow)}forceMaterialsUpdate(){this.traverseEntity(e=>{if(e instanceof mr)if(Array.isArray(e.material))for(let r of e.material)r.needsUpdate=!0;else e.material.needsUpdate=!0,e.material.dispose()})}updateShadow(e){e.softShadowQuality!==void 0&&this.isActive&&Mv(e.softShadowQuality)&&this.forceMaterialsUpdate()}updateFog(e,r){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=Qt(e.color,r),this.backupFog.near=e.near,this.backupFog.far=e.far}updateAo(e,r){e.aoColor!==void 0&&(this.aoColor=Qt(e.aoColor,r))}updateByOp(e,r,o,i){let a=this.data.uiFrame;super.updateByOp(e,r,o,i);let s=r;Le(e.path,["fog"])?this.updateFog(s.fog,o.shared):Le(e.path,["ao"])?this.updateAo(s.ao,o.shared):Le(e.path,["ambient"])?this.updateAmbientLight(s.ambient,o.shared):Le(e.path,["shadow"])?this.updateShadow(s.shadow):e.type===0&&e.path.length===0&&(e.props.uiFrame!==void 0||a!==s.uiFrame)&&this.updateUIFrame(e.props.uiFrame,o)}updateUIFrame(e,r){e?(this.uiCanvas||this.createUICanvas(e,r),this.uiCanvas.enabled=!0,this.uiCanvas.applyFrame(e)):this.uiCanvas&&(this.uiCanvas.enabled=!1)}updateState(e,r){this.updateState_Entity(e,r),e.backgroundColor!==void 0&&this.setBackgroundColor(Qt(e.backgroundColor,r.shared)),e.fog!==void 0&&this.updateFog(e.fog,r.shared),e.ambient!==void 0&&this.updateAmbientLight(e.ambient,r.shared),e.ao!==void 0&&this.updateAo(e.ao,r.shared),e.shadow!==void 0&&this.updateShadow(e.shadow)}createFrame(e,r){}raycast(e,r){super.raycast(e,r)}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,r=0;this.traverseEntity(o=>{if(!o.visible)return!0;o instanceof Ps&&o.visible&&e<3&&(this.penumbraSizeArrayCache[e]=o.data.penumbraSize,e+=1),o instanceof Os&&o.visible&&e<5-3&&(this.penumbraSizeArrayCache[3+r]=o.data.penumbraSize,r+=1)})}raycastWithClones(e){let r=[],o=i=>{for(let a of i.children){let s=a.cloner;Re.is(a)&&(a.visible||s?.object.data.visible)&&((Ln(a)||Dl(a)&&this.scene.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,r),Gl(a,e,r,!0)),o(a))}};return o(this),r}updateEntity2DByOp(e,r,o,i){this.uiCanvas?.updateEntity2DByOp(e,r,o,i)}};import{PointLight as dD,Vector3 as md,Box3 as pD,Box3Helper as tS,Color as fD}from"three";var yd=class extends ws(dD,_s){constructor(t,e,r){super(),this.super_Entity(t,e),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let i=this.shadow.camera;i.fov=90,i.aspect=1,i.near=100,i.far=2500;let a=new md(-i.far+this.position.x,-i.far+this.position.y,-i.far+this.position.z),s=new md(i.far+this.position.x,i.far+this.position.y,i.far+this.position.z),l=new pD(a,s),u=new tS(l,new fD(16755200));u.visible=!1,this.gizmos.shadowmap=u,this.update()}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this.gizmos))for(let t in this.gizmos){let e=this.gizmos[t];if(e instanceof tS){let r=this.shadow.camera,o=new md(-r.far+this.position.x,-r.far+this.position.y,-r.far+this.position.z),i=new md(r.far+this.position.x,r.far+this.position.y,r.far+this.position.z);e.box.set(o,i),e.updateMatrixWorld(!0)}}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.objectHelper&&this.objectHelper.update()}updateState(t,e){this.updateState_Light(t,e),t.distance!==void 0&&(this.distance=t.distance),t.decay!==void 0&&(this.decay=t.decay),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};var gd=class extends ft{get forceComputeSize(){return!0}get shape(){return this.geometry.userData.shape}updateEntityBoxSize(t,e){let r=this.geometry.getAttribute("position");r!==void 0?ml(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};var Ms=class extends ft{constructor(e,r,o){super(e,r,o);this._shapeId=null;this._context=o}updateState(e,r){super.updateState(e,r),this.updateShape()}updateShape(){let e={...this.data.geometry.extrusion.shape};for(let i in e)typeof e[i]=="string"&&(e[i]=this._context.shared.getVariable(e[i],[this.uuid,"geometry","extrusion","shape",i]));let r;if(e.type==="Custom"){let i=e.shapeId;if(i!==this._shapeId&&this.detachShape(),i){this._shapeId=i;let a=this._context.scene.find(i);a?.data&&(a.attachedPaths.add(this),r=a.geometry.userData?.shape),r||this._context.scene.addPendingCommand(()=>this.updateShape())}}else{let i;switch(e.type){case"Rectangle":i=Ga;break;case"Ellipse":i=La;break;case"Polygon":i=Iu;break;case"Star":i=Nu;break;default:throw new Error(`Unknown shape type: ${e.type}`)}r=i.create({parameters:e}).userData.shape}let o=this.geometry;r&&o.inputs&&(o.inputs.shapeData=r,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,r){return super.updateTransformState(e,r)}updateGeometryInteractions(e,r){super.updateGeometryInteractions(e,r),this.updateShape()}updateEntityBoxSize(e,r){let o=this.geometry.getAttribute("position");o!==void 0?ml(o,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:o.count,e,r):super.updateEntityBoxSize(e,r)}};import{Group as hD,Matrix4 as mD,Skeleton as yD}from"three";var an=class extends Rr(hD,Vr){constructor(e,r,o){super();r.type==="Instance"&&typeof e=="string"&&(r=this.transformAssignData(r,o)),this.super_Entity(e,r),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,r){let o=ga.getComponentData({scene:r.scene.data,shared:r.shared.data},e.component);if(o){let i,a;for(let s of ho.rootOverrideProps)e[s]===void 0?(i===void 0&&(i={...e}),i[s]=o.data[s]):(a===void 0&&(a={}),a[s]=e[s],i===void 0&&(i={...e}),i[s]=so.apply(o.data[s],e[s]));return this.overrideData=a,i}else return{...It.defaultData,...e,...jr(It.defaultData,ho.rootOverrideProps)}}updateByOp(e,r,o,i){let a;if(this.isInstanceRoot&&!i){if(r=this.transformAssignData(r,o),e.type===0&&e.path.length===0&&this.component)for(let s of ho.rootOverrideProps)s in e.props&&e.props[s]===void 0&&(a===void 0&&(a={...e,props:{...e.props}}),a.props[s]=this.component.data[s]);else if(e.type===0&&e.path.length>0&&ho.rootOverrideProps.includes(e.path[0])){let s=e.path[0];a===void 0&&(a={...e,path:[],props:{[s]:r[s]}})}}super.updateByOp(a??e,r,o,i)}updateState(e,r){this.updateState_Entity(e,r)}expandInstanceChildren(e){let r=this.data;if(this.component===void 0){let o=e.scene.find(r.component)??null,i=!1;if(o!==this.oldComponent){if(this.oldComponent){let a=0;for(let s of this.children)if(Re.is(s))e.scene.disposeAndUnregisterEntityRecursivelyIfNotReregistered(s),xd(s),a+=1;else break;this.children.splice(0,a)}i=!0}if(o){let a={};oS(e,[this.uuid],r.overrides,this,o,o,0,i,a);for(let s of this.children)if(Re.is(s)){let l=s.data;l.type==="Empty"&&l.animations&&s.traverseEntity(u=>{if(u instanceof ft&&u.isSkinnedMesh){let c=u.dataPatched;if(c.bones&&c.boneInverses){let d=c.bones.map(h=>e.scene.find(a[h])),p=c.boneInverses.map(h=>new mD().fromArray(h)),f=new yD(d,p);u.bind(f,u.bindMatrix)}}else u.matrixAutoUpdate=!0})}}this.oldComponent=this.component}}};function xd(n){if(n.component){let t=n.component.instances.indexOf(n);t>=0&&n.component.instances.splice(t,1);for(let e of n.children)Re.is(e)&&xd(e)}}function rS(n,t,e,r){return n.component===t&&$d(n.identity,r)?n.overrideData===e?2:1:0}function oS(n,t,e,r,o,i,a,s,l){if(a>50)return!1;if(r.component!==o){if(r.component){let c=r.component.instances.indexOf(r);c>=0&&r.component.instances.splice(c,1)}o.instances.find(c=>c===r)||o.instances.push(r),r.component=o}o instanceof an&&o.isInstanceRoot&&o.expandInstanceChildren(n);let u=0;for(let c of o.children)if(Re.is(c)){let d=[...t,...typeof c.identity=="string"?[c.identity]:c.identity],p=ma.resolve(e,d,1);if(p!=null&&!(p instanceof et)){if(!1)debugger;Object.setPrototypeOf(p,et.prototype),console.error("wrong prototype")}let f=null,h;if(!s){let m=r.children[u];if(f=Re.is(m)?m:null,f!==null){let y=rS(f,c,p,d);h=y>=1?f.stateSelection:void 0,y!==2&&(f=null)}if(f===null&&(f=n.scene.findInstance(d)??null,f!==null)){let y=rS(f,c,p,d);if(h=y>=1?f.stateSelection:void 0,y!==2)f=null;else{let g=f.parent.children.indexOf(f);f.parent.children.splice(g,1),r.children.splice(u,0,f),f.parent===r?(g<=u&&console.error("not possible"),void 0):(f.parent=r,f.matrixWorldNeedsUpdate=!0,f.resetBBoxNeedsUpdate(),f.updateVisible(),n.pendingDeletes.delete(f),void 0)}}}if(f===null){let m=p?so.apply(c.data,p):c.data;Ur.is(m.type)&&(m={...m,type:"Empty"}),f=Wr.createEntity(d,m,n),f.overrideData=p,r.add(f),r.children.splice(r.children.length-1,1),r.children.splice(u,0,f),f.updateState(f.data,n),h&&f.changeSelectedState(h,n),n.scene.registerInstanceAndSetUuid(f)}if(f.isBone){let m=f.identity[f.identity.length-1];l[m]=f.uuid}u+=1,oS(n,t,e,f,c,i,a+1,s,l)}if(!s){let c=u;for(;;){let d=r.children[u];if(Re.is(d))n.pendingDeletes.add(d);else break;u+=1}r.children.splice(c,u-c)}return!0}import{Bone as gD}from"three";var bd=class extends Rr(gD,Vr){constructor(t,e){super(),this.super_Entity(t,e),this.objectHelper.update(),this.matrixAutoUpdate=!0}updateState(t,e){this.updateState_Entity(t,e)}};var Pi=class extends ft{constructor(e,r,o){super(e,r,o);this.onBeforeRender=()=>{this.uiCanvas.render()};this.uiCanvas=new Ts(e+"-canvas",r.geometry.width,r.geometry.height,o),this.uiCanvas.promise.then(()=>{this.applyFrame(this.dataPatched.geometry.frame,o.shared)})}updateByPatchedOpGeometry(e,r,o){super.updateByPatchedOpGeometry(e,r,o),e.type===0&&(e.props.frame!==void 0&&this.applyFrame(e.props.frame,o.shared),(e.props.width!==void 0||e.props.height!==void 0)&&this.applySize(e.props,o.shared))}applySize(e,r){let o=e?.width??this.dataPatched.geometry.width,i=e?.height??this.dataPatched.geometry.height;this.uiCanvas.applySize({width:o,height:i}),this.applyGeometryParametersFromFrame(r)}applyFrame(e,r){this.uiCanvas.applyFrame(e),this.applyGeometryParametersFromFrame(r),this.applyMaterialParametersFromFrame({shared:r})}applyGeometryParametersFromFrame(e){let r=this.frame;r&&(Object.assign(this.data,{geometry:Object.assign(this.data.geometry,{cornerRadius:r.cornerRadius,cornerType:0})}),Object.assign(this.dataPatched,{geometry:Object.assign(this.dataPatched.geometry,{cornerRadius:r.cornerRadius,cornerType:0})}),this.localGeometry?.dispose(),this.localGeometry=Qo(this.dataPatched.geometry,e,this.data.flatShading,this))}applyMaterialParametersFromFrame(e){let r=this.frame;if(r){let o=r.data.backgroundBlur;Object.assign(this.data.material.layers[0].data.texture,{image:this.uiCanvas.uuid}),Object.assign(this.data.material.layers[1].data,{roughness:o.radius,alpha:o.enabled?1:0}),Object.assign(this.dataPatched.material.layers[0].data.texture,{image:this.uiCanvas.uuid}),Object.assign(this.dataPatched.material.layers[1].data,{roughness:o.radius,alpha:o.enabled?1:0}),this.material.reset(this.dataPatched.material,e,!0)}}updateEntity2DByOp(e,r,o,i){this.uiCanvas.updateEntity2DByOp(e,r,o,i),e===this.frameId&&r.type===0&&(r.props.cornerRadius!==void 0?this.applyGeometryParametersFromFrame(i):Le(r.path,["backgroundBlur"])&&this.applyMaterialParametersFromFrame({shared:i}))}get frame(){return this.uiCanvas.frame}get frameId(){return this.frame?.uuid}removeInteractionGeometry(e){super.removeInteractionGeometry(e),this.applySize({},e)}updateGeometryInteractions(e,r){super.updateGeometryInteractions(e,r),this.applySize({width:e.width,height:e.height},r)}};import{Object3D as TD,Vector3 as Gr,InstancedMesh as MD,InstancedBufferAttribute as ID,PlaneGeometry as ND,Vector4 as Fl,Quaternion as _S,TextureLoader as DD,Texture as PS,Euler as ED,MathUtils as Lh}from"three";import{GPUComputationRenderer as BD}from"three/examples/jsm/misc/GPUComputationRenderer.js";import{Vector3 as nS,FloatType as Mh,DataTexture as Ih,RGBAFormat as Nh,Mesh as xD,Euler as xce,Matrix4 as bce}from"three";import{MeshSurfaceSampler as bD}from"three/examples/jsm/math/MeshSurfaceSampler.js";function iS(n){let t=new Float32Array(n*n*2);for(let e=0;e<n;e++)for(let r=0;r<n;r++){let o=e*n+r;t[o*2+0]=e/(n-1),t[o*2+1]=r/(n-1)}return t}function aS(n){let t=Math.ceil(Math.sqrt(n));return Math.max(t,1)}function sS(n,t){let e=new xD(n.geometry,n.material),r=[],o=[],i=new nS,a=new nS;e.geometry.index!==null&&(e.geometry=e.geometry.toNonIndexed());let s=new bD(e).build();for(let c=0;c<t;c++)s.sample(i,a),r.push(i.x,i.y,i.z),o.push(a.x,a.y,a.z);let l=new Float32Array(r),u=new Float32Array(o);return{positions:l,normals:u}}function Dh(n,t){let e=n,r=new Float32Array(4*t*t);for(let i=0;i<t*t;i++)r[4*i]=e[3*i],r[4*i+1]=e[3*i+1],r[4*i+2]=e[3*i+2],r[4*i+3]=0;let o=new Ih(r,t,t,Nh,Mh);return o.needsUpdate=!0,o}function lS({size:n}){let t=new Float32Array(4*n*n);for(let r=0;r<n*n;r++)t[4*r]=r,t[4*r+1]=0,t[4*r+2]=0,t[4*r+3]=0;let e=new Ih(t,n,n,Nh,Mh);return e.needsUpdate=!0,e}function cS(n){let t=new Float32Array(4*n*n);for(let r=0;r<n*n;r++)t[4*r]=0,t[4*r+1]=0,t[4*r+2]=0,t[4*r+3]=0;let e=new Ih(t,n,n,Nh,Mh);return e.needsUpdate=!0,e}var uS=`
2615
+ `,kN=El.lights_fragment_begin,jN=El.shadowmask_pars_fragment,Mv=null,UN=n=>{switch(n){case"low":return 8;case"medium":return 16;case"high":return 32;default:return 16}},Iv=(n="medium")=>{if(Mv===n)return!1;Mv=n;let t=UN(n);El.shadowmap_pars_fragment=FN(t);let e=kN.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 ]"),El.lights_fragment_begin=e;let r=jN.slice();return r=r.replaceAll("getShadow(","getShadow( UNROLLED_LOOP_INDEX, "),El.shadowmask_pars_fragment=r,!0};import{DirectionalLight as YN,CameraHelper as Nv}from"three";import{DirectionalLightHelper as HN}from"three";var _s=class extends To(HN){constructor(e,r=15,o=10066329){super(e,r,o);this.object=e;this.added=!1;this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,r){Mo(this.object,_s.geometryHelper,e,r)}};import{PointLightHelper as qN}from"three";var Ps=class extends To(qN){constructor(e,r=15,o=6710886){super(e,r,o);this.object=e;this.name=`PointLightHelper: ${e.uuid}`}raycast(e,r){Mo(this.object,Ps.geometryHelper,e,r)}};import{SpotLightHelper as WN,Vector3 as $N}from"three";var ld=class extends To(WN){constructor(e,r=6710886){super(e,r);this.object=e;this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,r){Mo(this.object,ld.geometryHelper,e,r)}update(){if(this.object!==void 0){let e=ld._vector,r=this.object.distance?this.object.distance:1e3,o=r*Math.tan(this.object.angle);this.cone.scale.set(o,o,r),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 a=0,s=this.cone.material.length;a<s;a++)this.cone.material[a].color.set(i);else this.cone.material.color.set(i)}}},Bl=ld;Bl._vector=new $N;function XN(n,t){n.shadow.camera.right=t/2,n.shadow.camera.left=-t/2,n.shadow.camera.top=t/2,n.shadow.camera.bottom=-t/2,n.shadow.needsUpdate=!0}var Os=class extends As(YN,_s){constructor(t,e,r){super(),this.super_Entity(t,e),this.castShadow=!0,this.shadow.mapSize.width=2048,this.shadow.mapSize.height=2048,this.shadow.normalBias=1,this.layers.enable(3);let i=this.shadow.camera;i.top=1250,i.bottom=-1250,i.right=1250,i.left=-1250,i.near=-1e4,i.far=2500;let a=new Nv(this.shadow.camera);a.visible=!1,this.gizmos.shadowmap=a}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this.gizmos){let e=this.gizmos[t];e instanceof Nv&&e.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.objectHelper&&this.objectHelper.update()}updateState(t,e){this.updateState_Light(t,e);let r=t.depth!==void 0&&t.depth!==this.shadow.camera.far||t.size!==void 0&&t.size/2!==this.shadow.camera.right;t.size!==void 0&&XN(this,t.size),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),t.penumbraSize!==void 0&&e.scene.markPenumbraSizeDirty(),r&&this.update()}};import{Scene as mD}from"three";import{SpotLight as QN,CameraHelper as Dv,MathUtils as KN,Vector3 as Rv,Quaternion as ZN}from"three";var Ev=new Rv,Bv=new Rv,Lv=new ZN,Cs=class extends As(QN,Bl){constructor(t,e,r){super(),this.super_Entity(t,e),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let i=this.shadow.camera;i.fov=KN.RAD2DEG*2*this.angle,i.aspect=1,i.near=100,i.far=2500;let a=new Dv(this.shadow.camera);a.visible=!1,this.gizmos.shadowmap=a,this.update()}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this.gizmos){let e=this.gizmos[t];e instanceof Dv&&e.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),Bv.setFromMatrixPosition(this.matrixWorld),Lv.setFromRotationMatrix(this.matrixWorld),Ev.copy(this.up).applyQuaternion(Lv).negate().multiplyScalar(this.distance),this.target.position.copy(Bv).add(Ev),this.target.updateMatrixWorld(),this.objectHelper&&this.objectHelper.update()}updateState(t,e){this.updateState_Light(t,e),t.distance!==void 0&&(this.distance=t.distance),t.decay!==void 0&&(this.decay=t.decay),t.angle!==void 0&&(this.angle=t.angle),t.penumbra!==void 0&&(this.penumbra=t.penumbra),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.penumbraSize!==void 0&&e.scene.markPenumbraSizeDirty(),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};function JN(n){let t=(n[0][0]+n[1][1])/2,e=(n[0][0]-n[1][1])/2,r=(n[1][0]+n[0][1])/2,o=(n[1][0]-n[0][1])/2,i=Math.sqrt(t*t+o*o),a=Math.sqrt(e*e+r*r),s=i+a,l=i-a,u=Math.atan2(r,e),c=Math.atan2(o,t),d=(c-u)/2,p=(c+u)/2,f=[[Math.cos(p),Math.sin(p)],[-Math.sin(p),Math.cos(p)]],h=[[s,0],[0,l]],m=[[Math.cos(d),Math.sin(d)],[-Math.sin(d),Math.cos(d)]];return f[0][0]*=-1,f[0][1]*=-1,m[0][0]*=-1,m[1][0]*=-1,[f,h,m]}function cd(n,t){return[[n[0][0]*t[0][0]+n[0][1]*t[1][0],n[0][0]*t[0][1]+n[0][1]*t[1][1]],[n[1][0]*t[0][0]+n[1][1]*t[1][0],n[1][0]*t[0][1]+n[1][1]*t[1][1]]]}function Vv(n){return[[n[0][0],n[1][0]],[n[0][1],n[1][1]]]}function zv(n){let[t,e,r]=JN(n),o=cd(t,Vv(r)),i=cd(cd(r,e),Vv(r)),a=Math.atan2(o[1][0],o[0][0]),s=[i[0][0],i[1][1]],l=[i[0][1]/i[1][1],i[1][0]/i[0][0]];return{rotation:a,scale:s,shear:l}}function Gv({rotation:n,scale:t,shear:e}){let r=Math.cos(n),o=Math.sin(n),i=[[r,-o],[o,r]],a=[[t[0],e[0]*t[1]],[e[1]*t[0],t[1]]],s=cd(i,a);return[s[0][0],s[1][0],s[0][1],s[1][1]]}var ke;(S=>{function n(){return[1,0,0,0,1,0,0,0,1]}S.identity=n;function t(P,O=S.identity()){for(let x=0,D=P.length;x<D;x++)O[x]=P[x];return O}S.copy=t;function e(P,O,x,D,N,T){return S.setAbcdef(S.identity(),P,O,x,D,N,T)}S.create=e;function r(P,O,x,D,N,T,I){return P[0]=O,P[1]=D,P[2]=T,P[3]=x,P[4]=N,P[5]=I,P}S.setAbcdef=r;function o(P,O){let[x,D,N,T,I,E]=a(P),[B,R,F,V,q,k]=a(O),U=B*x+R*N,H=B*D+R*T,Y=F*x+V*N,J=F*D+V*T,Z=q*x+k*N+I,X=q*D+k*T+E;return S.create(U,H,Y,J,Z,X)}S.append=o;function i(P,O){let[x,D,N,T,I,E]=a(P),[B,R,F,V,q,k]=a(O),U=x,H=D,Y=N,J=T;(B!==1||R!==0||F!==0||V!==1)&&(U=x*B+D*F,H=x*R+D*V,Y=N*B+T*F,J=N*R+T*V);let Z=I*B+E*F+q,X=I*R+E*V+k;return S.create(U,H,Y,J,Z,X)}S.prepend=i;function a(P){return[P[0],P[3],P[1],P[4],P[2],P[5]]}S.getAbcdef=a;function s(P){let[O,x,D,N,T,I]=S.getAbcdef(P),E=O*N-x*D,B=N/E,R=-x/E,F=-D/E,V=O/E,q=(D*I-N*T)/E,k=-(O*I-x*T)/E;return S.create(B,R,F,V,q,k)}S.invert=s;function l([P,O],x){let[D,N,T,I,E,B]=S.getAbcdef(x);return[D*P+T*O+E,N*P+I*O+B]}S.apply=l;function u(P,O){let[x,D,N,T,I,E]=S.getAbcdef(O),B=1/(x*T+N*-D),[R,F]=P;return[T*B*R+-N*B*F+(E*N-I*T)*B,x*B*F+-D*B*R+(-E*x+I*D)*B]}S.applyInverse=u;function c(P,O,x=O){let[D,N,T,I,E,B]=S.getAbcdef(P);return S.setAbcdef(P,D*O,N*x,T*O,I*x,E*O,B*x),P}S.scale=c;function d(P,O){let x=Math.cos(O),D=Math.sin(O),[N,T,I,E,B,R]=S.getAbcdef(P);return S.setAbcdef(P,N*x-T*D,N*D+T*x,I*x-E*D,I*D+E*x,B*x-R*D,B*D+R*x),P}S.rotate=d;function p(P,O,x){let[D,N]=x,T=S.translate(P,-D,-N);return T=S.rotate(T,O),T=S.translate(T,D,N),T}S.rotateAround=p;function f(P,O,x){let[D,N,T,I,E,B]=S.getAbcdef(P);return S.setAbcdef(P,D,N,T,I,E+O,B+x),P}S.translate=f;function h(P,O,x){let[D,N,T,I]=S.getAbcdef(P);return S.setAbcdef(P,D,N,T,I,O,x),P}S.setTranslate=h;function m(P,O,x){let[D,N,T,I]=S.getAbcdef(P);return S.setAbcdef(P,D,N,T,I,O,x),P}S.setPosition=m;function y(P){let[O,x,D,N]=S.getAbcdef(P),T=Math.sqrt(O*O+x*x),I=Math.sqrt(D*D+N*N);return[T,I]}S.getScale=y;function g(P){let[,,,,O,x]=S.getAbcdef(P);return[O,x]}S.getPosition=g;function b(P,O){return S.decompose(P,O).rotation}S.getRotation=b;function w(P,O){let[x,D,N,T,I,E]=S.getAbcdef(P),{rotation:B,scale:R,shear:F}=zv([[x,N],[D,T]]);return{position:[I+(O[0]*x+O[1]*N)-O[0],E+(O[0]*D+O[1]*T)-O[1]],scale:R,rotation:B,shear:F,pivot:O}}S.decompose=w;function A(P,O,x,D,N=[0,0]){let[T,I]=P,[E,B]=D,[R,F,V,q]=Gv({rotation:x,scale:O,shear:N}),k=T-(E*R+B*V)+E,U=I-(E*F+B*q)+B;return S.create(R,F,V,q,k,U)}S.compose=A})(ke||(ke={}));var eD=Math.PI/180,sie=180/Math.PI;function Fv(n,t,e,r,o,i){let a=n-e,s=t-r;return a*a/(o*o)+s*s/(i*i)<=1}function kv(n){return n*eD}function wh(n){return{all:n=n||new Map,on:function(t,e){var r=n.get(t);r?r.push(e):n.set(t,[e])},off:function(t,e){var r=n.get(t);r&&(e?r.splice(r.indexOf(e)>>>0,1):n.set(t,[]))},emit:function(t,e){var r=n.get(t);r&&r.slice().map(function(o){o(e)}),(r=n.get("*"))&&r.slice().map(function(o){o(t,e)})}}}var on=class{constructor(t,e,r){this.uuid=t;this.data=e;this.localMatrix=ke.identity();this.worldMatrix=ke.identity();this.ignoreCameraZoom=!1;this.visible=!0;this._singleBBox=new Vn;this._recursiveBBox=new Vn;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this.stateSelection=null;this.prevState=null;this.currentState=null;this.reversibleToState=null;this.currentTransitionEvent=null;this.previousAction=null;this.name="";this.position=[0,0];this.scale=[1,1];this.rotation=0;this.shear=[0,0];this.emitter=wh();this.dpr=r.dpr??1,this.dataPatched=e}project(t,e){let r=this.worldMatrix;return e&&(r=ke.append(e.worldMatrix,r)),ke.applyInverse(t,r)}intersects(t,e,r,o=!1){return this.visible&&!this.data.raycastLock&&this.intersectsInLocalSpace(...this.project([t,e],r),o)}intersectsInLocalSpace(t,e,r=!1){let{min:o,max:i}=r?this.recursiveBBox:this.singleBBox;return t>=o[0]&&t<=i[0]&&e>=o[1]&&e<=i[1]}applyTransforms(t){t.setTransform(this.worldMatrix,this.ignoreCameraZoom)}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges()),this._recursiveBBox}updateLocalMatrix(){this.localMatrix=ke.compose(this.position,this.scale,kv(this.rotation),qo.getPivot(this.dataPatched),this.shear)}updateWorldMatrix(t,e,r){let o=this.parent;e&&o!==null&&o!==void 0&&o.updateWorldMatrix(t,!0,!1),t&&this.updateLocalMatrix(),this.parent?this.worldMatrix=ke.append(this.parent.worldMatrix,this.localMatrix):this.worldMatrix=ke.copy(this.localMatrix),this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}get pivot(){return qo.getPivot(this.data)}getCenter(){return[0,0]}getHalfSize(){return[0,0]}get id(){return this.uuid}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(t=>{t.resetBBoxNeedsUpdateSelf()})}updateTransformState(t){let e=!1;t.position!==void 0&&(e=!0,this.position=t.position),t.rotation!==void 0&&(e=!0,this.rotation=t.rotation),t.scale!==void 0&&(e=!0,this.scale=t.scale),t.shear!==void 0&&(e=!0,this.shear=t.shear),e&&(this.updateWorldMatrix(!0,!1,!0),this.resetBBoxNeedsUpdate())}updateByOp(t,e,r){t.type===0&&t.props.visible!==void 0&&(this.visible=t.props.visible),this.data=e,this.data=e;let o=t,i=Le(t.path,["states","*"]);if(i!==null){if(t.type===0){let[a]=i;if(this?.stateSelection===a){let s={...t.props};if(delete s.name,Object.values(t.props).some(l=>l===void 0)){let l=this.data;if(l!==void 0){let u=lt.zoom(l,t.path.slice(2));if(u)for(let c in t.props)t.props[c]===void 0&&c in u&&(s[c]=u[c])}}o={...t,props:s,path:t.path.slice(2)}}}}else if(t.type===0){let a=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(a!==void 0){if(t.props.name!==void 0&&a.name){let{name:l,...u}=a;a=u}let s=lt.removeOverridden(t.path,t.props,a);o={...t,props:s}}}this.updateByPatchedOpBase(o,ii.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),r)}changeSelectedState(t,e,r=!1){if(!(this.data.states.length===0&&!r)){for(let o of this.data.states)ii.toOps(this.data,o.data).forEach(a=>{let s=aa.replaceProps(a,this.data);this.dataPatched=this.data,this.updateByPatchedOp(s,this.data,e)});if(t!==null){let o=this.data.states.data(t);o&&(this.dataPatched=ii.patch(this.data,o),ii.toOps(this.data,o).forEach(a=>{this.updateByPatchedOp(a,this.dataPatched,e)}))}r&&this.updateTransformState(this.dataPatched),this.stateSelection=t}}updateState(t,e){t.name!==void 0&&(this.name=t.name),t.visible!==void 0&&(this.visible=t.visible),this.updateTransformState(t)}updateByPatchedOpBase(t,e,r){this.dataPatched=e,this.updateByPatchedOp(t,e,r)}updateByPatchedOp(t,e,r){t.path.length===0&&t.type===0&&this.updateState(t.props,r),this.requestRender()}traverseFrameAncestors(t){this.traverseAncestors(e=>{e.data.type==="frame2d"&&t(e)})}traverseAncestors(t){let e=this.parent;for(;e;)t(e),e=e.parent}requestRender(){this.traverseFrameAncestors(t=>{t.requestRender()})}clone(t){let e=new on(this.uuid,this.data,t);return e.parent=void 0,e}addEventListener(t,e){this.emitter.on(t,e)}removeEventListener(t,e){this.emitter.off(t,e)}dispatchEvent(t){this.emitter.emit(t.type,{...t,target:t.target??this})}traverseSortNextHelper(){let t=this.parent;if(t){let e=t.children;if(e){let r=e.indexOf(this)+1;return e[r]?e[r]:t.traverseSortNextHelper()}}}sortNext(){let t=this.children;return t&&t.length>0&&t[0]?t[0]:this.traverseSortNextHelper()}isDescendantOf(t){t instanceof on&&(t=t.uuid);let e=this;for(;e.parent;){if(e.parent.uuid===t)return!0;e=e.parent}return!1}};var er=class extends on{constructor(e,r,o){super(e,r,o);this.uuid=e;this.data=r;this.context=o;this.children=[]}add(e){e.parent&&e.parent instanceof er&&e.parent.remove(e),this.children.push(e),e.parent=this}remove(e){let r=this.children.indexOf(e);r>=0&&(this.children.splice(r,1),e.parent=void 0)}traverse(e){let r=e(this);if(r!==!0)for(let o of this.children)o instanceof er?o.traverse(e):r=e(o)}intersectsChildren(e,r,o,i=!1,a=[],s=!1){for(let l of this.children){let u=l instanceof lr;if(l instanceof er&&!u&&s&&l.intersectsChildren(e,r,o,i,a,!1),l.intersects(e,r,o,u)&&(a.push(l),i))break}return a}updateWorldMatrix(e,r,o){if(super.updateWorldMatrix(e,r,o),o&&this.children)for(let i of this.children)i.updateWorldMatrix(e,!1,!0)}find(e){let r;return this.traverse(o=>{o.uuid===e&&(r=o)}),r}innerDrawChildren(e){for(let r=this.children.length-1;r>=0;r--)this.children[r].draw(e)}resetBBoxNeedsUpdate(){super.resetBBoxNeedsUpdate(),this.traverse(e=>{e.resetBBoxNeedsUpdateSelf()})}clone(e){let r=new er(this.uuid,this.data,e);r.parent=void 0;for(let o of this.children)r.add(o.clone(e));return r}},lr=class extends er{constructor(e,r,o){super(e,r,o);this.uuid=e;this.data=r;this.updateState(r,o)}draw(e){!this.visible||(e.save(),this.applyTransforms(e),this.innerDrawChildren(e),e.restore())}clone(e){let r=new lr(this.uuid,this.data,e);r.parent=void 0;for(let o of this.children)r.add(o.clone(e));return r}};function tD(n,t){let[[e,r],[o,i]]=n,[[a,s],[l,u]]=t,c=(e-o)*(s-u)-(r-i)*(a-l);if(c===0)return!1;let d=((e-a)*(s-u)-(r-s)*(a-l))/c,p=-((e-o)*(r-s)-(r-i)*(e-a))/c;return d>=0&&d<=1&&p>=0&&p<=1}var Uv=[[-1,1],[-1,-1],[1,-1],[1,1]],jv=(n,t,e)=>{let r=n.getCenter(),o=n.getHalfSize(),i=ke.append(t,n.worldMatrix);o[0]===0&&o[1]===0?e.push(ke.apply(r,i)):Uv.forEach(a=>{let s=[a[0]*o[0]+r[0],a[1]*o[1]+r[1]];e.push(ke.apply(s,i))})},Vn=class{constructor(){this.matrix=ke.identity();this.min=[1/0,1/0];this.max=[-1/0,-1/0];this.vertices=[];this.edges=[]}setFromObjectSize(t,e=!1){t.updateWorldMatrix(),this.makeEmpty(),ke.copy(t.worldMatrix,this.matrix);let r=ke.invert(t.worldMatrix);this.expandByObjectSize(t,r,e)}expandByObjectSize(t,e,r=!1){let o=[];r===!0&&t instanceof er?t.traverse(i=>{i.visible&&jv(i,e,o)}):jv(t,e,o),this.setFromPoints(o)}getCenter(){let[t,e]=this.min,[r,o]=this.getHalfSize();return ke.apply([t+r,e+o],this.matrix)}getSize(){return[this.max[0]-this.min[0],this.max[1]-this.min[1]]}getHalfSize(){return[(this.max[0]-this.min[0])*.5,(this.max[1]-this.min[1])*.5]}makeEmpty(){this.min=[1/0,1/0],this.max=[-1/0,-1/0]}setFromPoints(t){this.makeEmpty();for(let e of t)this.expandByPoint(e)}expandByPoint(t){this.min=[Math.min(this.min[0],t[0]),Math.min(this.min[1],t[1])],this.max=[Math.max(this.max[0],t[0]),Math.max(this.max[1],t[1])]}computeVertices(){let[t,e]=this.getHalfSize(),r=this.getCenter(),[o,i,a,s]=ke.getAbcdef(this.matrix),l=ke.create(o,i,a,s,r[0],r[1]);this.vertices=Uv.map(([u,c])=>ke.apply([u*t,c*e],l))}computeEdges(){this.edges=[];for(let t=0,e=this.vertices.length;t<e;++t)this.edges.push([this.vertices[t],this.vertices[(t+1)%e]])}project(t,e){let r=this.matrix;return e&&(r=ke.append(e.worldMatrix,r)),ke.applyInverse(t,r)}intersects(t,e,r){return this.intersectsInLocalSpace(...this.project([t,e],r))}intersectsInLocalSpace(t,e){let{min:r,max:o}=this;return t>=r[0]&&t<=o[0]&&e>=r[1]&&e<=o[1]}containsPoint(t){let[e,r]=t,[o,i]=this.min,[a,s]=this.max;return e>=o&&e<=a&&r>=i&&r<=s}intersectsBBox2D(t){for(let e=0,r=this.edges.length;e<r;e++){let o=this.edges[e];for(let i=0,a=t.edges.length;i<a;i++){let s=t.edges[i];if(tD(o,s))return!0}}for(let e=0,r=t.vertices.length;e<r;e++){let o=t.vertices[e];if(this.containsPoint(o))return!0}return!1}ensureMinMax(){let t=this.min,e=this.max;this.min=[Math.min(t[0],e[0]),Math.min(t[1],e[1])],this.max=[Math.max(t[0],e[0]),Math.max(t[1],e[1])]}copy(t){this.min=[...t.min],this.max=[...t.max],ke.copy(t.matrix,this.matrix),this.computeVertices(),this.computeEdges()}clone(){let t=new Vn;return t.copy(this),t}};var qv,Wv=new Promise(n=>{qv=n}),Hv=!1;var ud;function $v(){if(Hv)return;if(ud)return ud;async function n(){let e=await import("./ui.js");qv(e.default??e),Hv=!0}return ud=n(),ud}function Qv(n){let t=!1;return n.scene.objects.traverse((e,r)=>{(r.type==="Mesh"&&r.geometry.type==="UIGeometry"||r.type==="Page"&&r.uiFrame!==void 0)&&(t=!0)}),t}var Oe,Ah;async function rD(n){let t=await Wv;Oe||(Ah||(Ah=t({locateFile:()=>n})),Oe=await Ah)}var Yv=ke.identity(),Rl=class{constructor(t,e=1){this.canvas=t;this.dpr=e;this._width=0;this._height=0;this._strokeMode="inside";this._layerBlur=0;this._backgroundBlur=0;this._dropShadowBlur=0;this._dropShadowOffsetX=0;this._dropShadowOffsetY=0;this._dropShadowColor=Ie.transparent;this._innerShadowBlur=0;this._innerShadowOffsetX=0;this._innerShadowOffsetY=0;this._innerShadowSpread=0;this._innerShadowColor=Ie.transparent;this._fonts=new Map;try{let r=t.getBoundingClientRect();t.width=r.width*e,t.height=r.height*e}catch{console.log(t.width,e)}this._currentM3Transform=Yv,this._currentTransform=new Float32Array(Yv)}async init(){if(!this.wasmURL)throw Error("Your must set the wasm binary url with renderer.wasmURL = ... before you can call renderer.init");await rD(this.wasmURL),this._surface=Oe.MakeWebGLCanvasSurface(this.canvas),this.ctx=this._surface?.getCanvas(),this._paint=new Oe.Paint,this._paint.setAntiAlias(!0),this._paintFill=this._paint.copy(),this._paintFill.setStyle(Oe.PaintStyle.Fill),this._paintStroke=this._paint.copy(),this._paintStroke.setStyle(Oe.PaintStyle.Stroke),this.ctx?.scale(this.dpr,this.dpr)}get currentTransform(){return this._currentM3Transform}get currentTransformBuffer(){return this._currentTransform}set currentTransform(t){this._currentM3Transform=t,this._currentTransform.set(t)}async loadFont(t,e){let r=await(await fetch(t)).arrayBuffer();this.registerFont(r,e)}registerFont(t,e){if(this._fonts.has(e))return;let r=Oe.FontMgr.FromData(t);if(r)this._fonts.set(e,r);else throw new Error("Invalid font data for "+e)}get width(){return this._width}get height(){return this._height}set strokeColor(t){this._paintStroke&&this._paintStroke.setColor(dd(t),Oe.ColorSpace.DISPLAY_P3)}set fillColor(t){this._paintFill&&this._paintFill.setColor(dd(t),Oe.ColorSpace.DISPLAY_P3)}set lineWidth(t){this._paintStroke&&this._paintStroke.setStrokeWidth(this._strokeMode==="center"?t:t*2)}set strokeMode(t){this._strokeMode=t}set dropShadowBlur(t){this._dropShadowBlur=t}set dropShadowColor(t){this._dropShadowColor=t}set dropShadowOffsetX(t){this._dropShadowOffsetX=t}set dropShadowOffsetY(t){this._dropShadowOffsetY=t}set innerShadowBlur(t){this._innerShadowBlur=t}set innerShadowColor(t){this._innerShadowColor=t}set innerShadowOffsetX(t){this._innerShadowOffsetX=t}set innerShadowOffsetY(t){this._innerShadowOffsetY=t}set innerShadowSpread(t){this._innerShadowSpread=t}set layerBlur(t){this._layerBlur=t}set backgroundBlur(t){this._backgroundBlur=t}clear(){this.ctx?.clear(Oe.TRANSPARENT)}save(){this.ctx?.save()}restore(){this.ctx?.restore()}beginPath(){this._currentPath?.delete(),this._currentPath=new Oe.Path}closePath(){let t=this._currentPath;if(t){if(t.isEmpty())return;let e=t.getBounds();(e[3]-e[1]||e[2]-e[0])&&t.close()}}fill(){this._paintInner(this._paintFill,!0)}stroke(){this._paintInner(this._paintStroke,!1)}clipRect(t,e,r,o,i=0,a=0,s=0,l=0){let u=Oe.XYWHRect(t,e,r,o);if(i===0&&a===0&&l===0&&s===0)this.ctx?.clipRect(u,Oe.ClipOp.Intersect,!0);else{let c=Oe.RRectXY(u,i,i);c[4]=c[5]=i,c[6]=c[7]=a,c[8]=c[9]=s,c[10]=c[11]=l,this.ctx?.clipRRect(c,Oe.ClipOp.Intersect,!0)}}_applyShadowOffsetMatrix(){if(this.ctx){let t=ke.invert(this.currentTransform);this.ctx.concat(t);let e=ke.translate(ke.identity(),this._dropShadowOffsetX,this._dropShadowOffsetY);this.ctx.concat(e),this.ctx.concat(this._currentTransform)}}_applyEffectsToPaint(t,e,r=!0){if(this.ctx&&this._currentPath){let o,i=!1;if(r&&this._hasDropShadow()){let a=t.copy();a.setColor(dd(this._dropShadowColor));let s;this._dropShadowBlur>0&&(s=Oe.MaskFilter.MakeBlur(Oe.BlurStyle.Normal,this._dropShadowBlur*this.dpr*(this.camera?.scale??1),!1),a.setMaskFilter(s)),this.ctx.save(),this.ctx.clipPath(this._currentPath,Oe.ClipOp.Difference,!0),this._applyShadowOffsetMatrix(),e(a),this.ctx.restore(),a.delete(),s?.delete()}if(this._backgroundBlur>0&&r){this.ctx.save(),this.ctx.clipPath(this._currentPath,Oe.ClipOp.Intersect,!0);let a=Oe.ImageFilter.MakeBlur(this._backgroundBlur,this._backgroundBlur,Oe.TileMode.Clamp,null),s=t.copy();s.setImageFilter(a),s.setAlphaf(1);let l=this._currentPath.computeTightBounds();this.ctx.saveLayer(s,l,null,Oe.SaveLayerInitWithPrevious),this.ctx.drawColor(t.getColor()),this.ctx.restore(),this.ctx.restore(),s.delete(),a.delete(),i=!0}if(this._layerBlur>0){let a=t.copy();o=Oe.MaskFilter.MakeBlur(Oe.BlurStyle.Normal,this._layerBlur*this.dpr*(this.camera?.scale??1),!1),a.setMaskFilter(o),e(a),a.delete(),o.delete(),i=!0}if(i||e(t),r&&this._hasInnerShadow()){let a=new Oe.Paint;a.setAntiAlias(!0),a.setStyle(Oe.PaintStyle.Fill),a.setColor(dd(this._innerShadowColor));let s;this._innerShadowBlur>0&&(s=Oe.MaskFilter.MakeBlur(Oe.BlurStyle.Normal,this._innerShadowBlur*this.dpr*(this.camera?.scale??1),!1),a.setMaskFilter(s));let l=this._currentPath.computeTightBounds(),[u,c,d,p]=l,f=d-u,h=p-c;this.ctx.save(),this.ctx.clipPath(this._currentPath,Oe.ClipOp.Intersect,!0),this.ctx.saveLayer(a,l,null,Oe.SaveLayerInitWithPrevious),this.ctx?.translate(this._innerShadowOffsetX,this._innerShadowOffsetY),this.ctx.drawRect(Oe.XYWHRect(-1e3-this._innerShadowOffsetX,-1e3-this._innerShadowOffsetY,2e3+f+Math.abs(this._innerShadowOffsetX*2),2e3+h+Math.abs(this._innerShadowOffsetY*2)),a),a.setBlendMode(Oe.BlendMode.Clear),this.ctx.drawPath(this._currentPath,a),this.ctx.restore(),this.ctx.restore(),a.delete(),s?.delete()}}}_paintInner(t,e=!0){if(this.ctx&&this._currentPath&&t){let r=this.ctx,o=this._currentPath;this._applyEffectsToPaint(t,i=>{let a=!1;!e&&this._strokeMode!=="center"&&(r.save(),r.clipPath(o,this._strokeMode==="outside"?Oe.ClipOp.Difference:Oe.ClipOp.Intersect,!0),a=!0),r.drawPath(o,i),a&&r.restore()},e)}}_hasDropShadow(){return this._dropShadowColor?.a>0}_hasInnerShadow(){return this._innerShadowColor?.a>0}path(t){this._currentPath?.addPath(Oe.Path.MakeFromSVGString(t))}ellipse(t,e,r,o,i,a,s,l){if(!Xv([t,e,r,o])||!this._currentPath)return;if(r<0||o<0)throw Error("radii cannot be negative");let u=Oe.XYWHRect(t-r,e-o,r*2,o*2);this._currentPath?.addOval(u)}rect(t,e,r,o,i=0,a=0,s=0,l=0){let u=Oe.XYWHRect(t,e,r,o);if(!!Xv(u))if(i===0&&a===0&&l===0&&s===0)this._currentPath?.addRect(u);else{let c=Oe.RRectXY(u,i,i);c[4]=c[5]=i,c[6]=c[7]=a,c[8]=c[9]=s,c[10]=c[11]=l,this._currentPath?.addRRect(c)}}getHorizontalAlign(t){switch(t){case 2:return Oe.TextAlign.Right;case 3:return Oe.TextAlign.Center;case 4:return Oe.TextAlign.Justify;case 1:default:return Oe.TextAlign.Left}}drawTextInner(t,e,r,[o,i,a,s],l,u,c=!0){let d=0,{ctx:p}=this;if(!p)return d;let f=u.copy(),h=u.copy();return h.setAlphaf(0),this._applyEffectsToPaint(f,m=>{e.pushPaintStyle(r,m,h),e.addText(t);let y=e.build();y.layout(a);let g=i;l===2?g+=(s-y.getHeight())/2:l===3&&(g+=s-y.getHeight()),p.drawParagraph(y,o,g),d=y.getHeight(),e.reset(),y.delete()},c),f.delete(),h.delete(),d}drawText(t,e){let r=0,o=this._fonts.get(e.font),{ctx:i,_paintFill:a,_paintStroke:s}=this;if(o&&i){let l=new Oe.TextStyle({fontFamilies:[e.font],fontSize:e.fontSize,heightMultiplier:e.lineHeight,letterSpacing:e.letterSpacing}),u=new Oe.ParagraphStyle({textStyle:l,textAlign:this.getHorizontalAlign(e.horizontalAlign)}),c=Oe.XYWHRect(e.x,e.y,e.width,e.height),d=Oe.ParagraphBuilder.Make(u,o);a&&(r=this.drawTextInner(t,d,l,c,e.verticalAlign,a,!0)),s&&(r=this.drawTextInner(t,d,l,c,e.verticalAlign,s,!1)),d.delete()}return{height:r}}render(){this._surface?.flush()}moveTo(t,e){this._currentPath?.moveTo(t,e)}lineTo(t,e){this._currentPath?.lineTo(t,e)}bezierCurveTo(t,e,r,o,i,a){this._currentPath?.cubicTo(t,e,r,o,i,a)}quadraticCurveTo(t,e,r,o){this._currentPath?.quadTo(t,e,r,o)}setTransform(t,e=!1){if(!this.ctx)return;let r=this.ctx.getTotalMatrix(),o=ke.invert(r);if(o&&this.ctx.concat(o),this.ctx?.scale(this.dpr,this.dpr),this.camera?.enabled&&(this.ctx?.concat(this.camera.worldMatrix),e)){let i=ke.getScale(this.camera.worldMatrix);this.ctx?.scale(1/i[0],1/i[1])}this.ctx?.concat(t),this.currentTransform=t}transform(t){this.ctx?.concat(t)}setSize(t,e){t===this._width&&e===this._height||(this._width=t,this._height=e,this.canvas.style.width=t+"px",this.canvas.style.height=e+"px",this.canvas.width=t*this.dpr,this.canvas.height=e*this.dpr,this._surface&&(this._surface=Oe.MakeWebGLCanvasSurface(this.canvas),this.ctx=this._surface?.getCanvas()))}};function Xv(n){for(let t=0;t<n.length;t++)if(n[t]!==void 0&&!Number.isFinite(n[t]))return!1;return!0}function dd({r:n,g:t,b:e,a:r}){return Oe.Color4f(n,t,e,r)}var Vl=class{constructor(t,e,r){this.uuid=t;this.data=e;this.enabled=!1;this.color=Ie.transparent;this.blurRadius=0;this.offset=[0,0];this.spread=0;this.update(e)}update(t){t.color!==void 0&&(this.color=t.color),t.enabled!==void 0&&(this.enabled=t.enabled),t.blurRadius!==void 0&&(this.blurRadius=t.blurRadius),t.offset!==void 0&&(this.offset=t.offset),t.spread!==void 0&&(this.spread=t.spread)}};var zl=class{constructor(t,e,r){this.uuid=t;this.data=e;this.enabled=!1;this.radius=0;this.update(e)}update(t){t.enabled!==void 0&&(this.enabled=t.enabled),t.radius!==void 0&&(this.radius=t.radius)}};var pd=class{constructor(t,e,r){this.uuid=t;this.data=e;this.enabled=!1;this.color=Ie.transparent;this.update(e)}update(t){t.enabled!==void 0&&(this.enabled=t.enabled),t.color!==void 0&&(this.color=t.color)}};var fd=class{constructor(t,e,r){this.uuid=t;this.data=e;this.enabled=!1;this.color=Ie.transparent;this.thickness=0;this.mode="inside";this.update(e)}update(t){t.enabled!==void 0&&(this.enabled=t.enabled),t.color!==void 0&&(this.color=t.color),t.thickness!==void 0&&(this.thickness=t.thickness),t.mode!==void 0&&(this.mode=t.mode)}};var gr=class extends on{constructor(e,r,o){super(e,r,o);this.uuid=e;this.data=r;this.autoClose=!0;this.fill=new pd(e+"-fill",r.fill,o),this.stroke=new fd(e+"-stroke",r.stroke,o),this.dropShadow=new Vl(e+"-dropShadow",r.dropShadow,o),this.innerShadow=new Vl(e+"-innerShadow",r.innerShadow,o),this.backgroundBlur=new zl(e+"-backgroundBlur",r.backgroundBlur,o),this.layerBlur=new zl(e+"-layerBlur",r.layerBlur,o)}applyFillStroke(e){e.fillColor=this.fill.enabled?this.fill.color:Ie.transparent,e.strokeColor=this.stroke.enabled&&this.stroke.thickness>0?this.stroke.color:Ie.transparent,e.strokeMode=this.stroke.mode,e.lineWidth=this.stroke.thickness}applyFilters(e){this.layerBlur.enabled?e.layerBlur=this.layerBlur.radius*5:e.layerBlur=0,this.backgroundBlur.enabled?e.backgroundBlur=this.backgroundBlur.radius*5:e.backgroundBlur=0,this.dropShadow.enabled?(e.dropShadowBlur=this.dropShadow.blurRadius*5,e.dropShadowColor=this.dropShadow.color,e.dropShadowOffsetX=this.dropShadow.offset[0],e.dropShadowOffsetY=this.dropShadow.offset[1]):e.dropShadowColor=Ie.transparent,this.innerShadow.enabled?(e.innerShadowSpread=this.innerShadow.spread,e.innerShadowBlur=this.innerShadow.blurRadius*5,e.innerShadowColor=this.innerShadow.color,e.innerShadowOffsetX=this.innerShadow.offset[0],e.innerShadowOffsetY=this.innerShadow.offset[1]):e.innerShadowColor=Ie.transparent}innerDraw(e){}draw(e){!this.visible||(e.save(),this.applyTransforms(e),this.applyFilters(e),this.applyFillStroke(e),e.beginPath(),this.innerDraw(e),this.autoClose&&e.closePath(),this.fill.enabled&&e.fill(),this.stroke.enabled&&e.stroke(),e.restore())}updateByPatchedOp(e,r,o){super.updateByPatchedOp(e,r,o),e.type===0&&(Le(e.path,["fill"])?this.fill.update(e.props):Le(e.path,["stroke"])?this.stroke.update(e.props):Le(e.path,["dropShadow"])?this.dropShadow.update(e.props):Le(e.path,["innerShadow"])?this.innerShadow.update(e.props):Le(e.path,["layerBlur"])?this.layerBlur.update(e.props):Le(e.path,["backgroundBlur"])?this.backgroundBlur.update(e.props):this.resetBBoxNeedsUpdate())}updateState(e,r){super.updateState(e,r),e.fill!==void 0&&this.fill.update(e.fill),e.stroke!==void 0&&this.stroke.update(e.stroke),e.dropShadow!==void 0&&this.dropShadow.update(e.dropShadow),e.innerShadow!==void 0&&this.innerShadow.update(e.innerShadow),e.layerBlur!==void 0&&this.layerBlur.update(e.layerBlur),e.backgroundBlur!==void 0&&this.backgroundBlur.update(e.backgroundBlur)}clone(e){let r=new gr(this.uuid,this.data,e);return r.parent=void 0,r}};var zn=class extends gr{constructor(e,r,o){super(e,r,o);this.uuid=e;this.data=r;this.width=0;this.height=0;this.updateState(r,o)}innerDraw(e){e.ellipse(this.width*.5,this.height*.5,this.width*.5,this.height*.5,0,0,Math.PI*2)}intersectsInLocalSpace(e,r){return Fv(e,r,this.width*.5,this.height*.5,this.width*.5,this.height*.5)}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateSizeState(e){let r=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,r=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,r=!0),r&&this.updateWorldMatrix(!0,!1,!0)}updateState(e,r){super.updateState(e,r),this.updateSizeState(e)}clone(e){let r=new zn(this.uuid,this.data,e);return r.parent=void 0,r}};var Io=class extends gr{constructor(e,r,o){super(e,r,o);this.uuid=e;this.data=r;this.width=0;this.height=0;this.cornerRadius=[0,0,0,0];this.updateState(r,o)}innerDraw(e){e.rect(0,0,this.width,this.height,...this.cornerRadius)}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateCornerState(e){e.cornerRadius!==void 0&&(this.cornerRadius=e.cornerRadius)}updateSizeState(e){let r=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,r=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,r=!0),r&&this.updateWorldMatrix(!0,!1,!0)}updateState(e,r){super.updateState(e,r),this.updateSizeState(e),this.updateCornerState(e)}clone(e){let r=new Io(this.uuid,this.data,e);return r.parent=void 0,r}};var Gn=class extends gr{constructor(e,r,o){super(e,r,o);this.uuid=e;this.data=r;this._textHeight=0;this._textHeightDirty=!0;this.width=0;this.height=0;this.updateState(r,o)}get textHeight(){return this._textHeight}applyFillStroke(e){e.fillColor=this.fill.enabled?this.fill.color:Ie.transparent,e.strokeColor=this.stroke.enabled&&this.stroke.thickness>0?this.stroke.color:Ie.transparent,e.strokeMode="center",e.lineWidth=this.stroke.thickness}innerDraw(e){this._fontHolder?.arrayBuffer&&this._fontHolder.arrayBuffer.byteLength>1&&this.data.font&&e.registerFont(this._fontHolder.arrayBuffer,this.data.font);let r=this.data.textTransform,o=this.data.text.textValue.toString(),i=r===2?o.toUpperCase():r===3?o.toLowerCase():o,{height:a}=e.drawText(i,{x:0,y:0,width:this.width,height:this.height,fontSize:this.data.fontSize,lineHeight:this.data.lineHeight??1,letterSpacing:this.data.letterSpacing??0,horizontalAlign:this.data.horizontalAlign,verticalAlign:this.data.verticalAlign,font:this.data.font});this._textHeight=a}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateSizeState(e){let r=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,r=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,r=!0),r&&this.updateWorldMatrix(!0,!1,!0)}updateFontState(e,{shared:r}){e.font!==void 0&&(this._fontHolder=r.getFont(e.font),this._fontHolder&&!this._fontHolder.isLoaded&&this._fontHolder.loadingPromise.then(()=>{this.requestRender()}))}updateState(e,r){super.updateState(e,r),this.updateSizeState(e),this.updateFontState(e,r)}clone(e){let r=new Gn(this.uuid,this.data,e);return r.parent=void 0,r}};var Ts=class extends gr{constructor(e,r,o){super(e,r,o);this.uuid=e;this.data=r;this.curves=[];this.extremasBBox={min:[0,0],max:[0,0]};this.updateState(r,o)}computeExtremas(){this.curves.length===0&&this.computeCurves();let e=this.curves.map(i=>hd.extremas(i)),r=[1/0,1/0],o=[-1/0,-1/0];for(let i=0,a=e.length;i<a;i++){let s=e[i];s[0][0]<r[0]&&(r[0]=s[0][0]),s[0][1]<r[1]&&(r[1]=s[0][1]),s[1][0]>o[0]&&(o[0]=s[1][0]),s[1][1]>o[1]&&(o[1]=s[1][1])}return this.extremasBBox.min=[r[0],r[1]],this.extremasBBox.max=[o[0],o[1]],this.extremasBBox}computeCurves(){this.curves=[];for(let o=1,i=this.data.points.length;o<i;o++){let a=this.data.points[o].data,s=this.data.points[o-1].data,l={start:s.position,cp1:s.controlNext.position,cp2:a.controlPrevious.position,end:a.position};this.curves.push(l)}let e=this.data.points[0].data,r=this.data.points[this.data.points.length-1].data;if(this.data.isClosed){let o={start:r.position,cp1:r.controlNext.position,cp2:e.controlPrevious.position,end:e.position};this.curves.push(o)}}getCenter(){let[e,r]=this.extremasBBox.min,[o,i]=this.getHalfSize();return[e+o,r+i]}getHalfSize(){let{min:e,max:r}=this.extremasBBox;return[(r[0]-e[0])*.5,(r[1]-e[1])*.5]}innerDraw(e){for(let i=0,a=this.data.points.length;i<a;i++){let s=this.data.points[i].data;if(i===0){let[l,u]=s.position;e.moveTo(l,u)}else{let l=this.data.points[i-1].data,[u,c]=l.controlNext.position,[d,p]=s.controlPrevious.position,[f,h]=s.position,m={start:l.position,cp1:l.controlNext.position,cp2:s.controlPrevious.position,end:s.position};hd.derive(m),e.bezierCurveTo(u,c,d,p,f,h)}}let r=this.data.points[0].data,o=this.data.points[this.data.points.length-1].data;if(this.data.isClosed){let[i,a]=o.controlNext.position,[s,l]=r.controlPrevious.position,[u,c]=r.position;e.bezierCurveTo(i,a,s,l,u,c)}}updateState(e,r){super.updateState(e,r),this.computeExtremas()}clone(e){let r=new Ts(this.uuid,this.data,e);return r.parent=void 0,r}},hd;(i=>{function n(a){let s=a.start,l=a.cp1,u=a.cp2,c=a.end,d=[3*(l[0]-s[0]),3*(l[1]-s[1])],p=[3*(u[0]-l[0]),3*(u[1]-l[1])],f=[3*(c[0]-u[0]),3*(c[1]-u[1])],h={start:d,cp:p,end:f};return a.derivative=h,h.derivative=_h.derive(h),h}i.derive=n;function t(a,s,l,u=!1){let c=a-2*s+l;if(c!==0){let d=-Math.sqrt(Math.abs(s*s-a*l)),p=-a+s,f=-(d+p)/c,h=-(-d+p)/c;return[f,h]}else if(s!==l&&c===0)return[(2*s-l)/(2*(s-l))];return[]}function e(a){let s=a.derivative??i.derive(a),l=s.start,u=s.cp,c=s.end;return[t(l[0],u[0],c[0]),t(l[1],u[1],c[1])]}i.droot=e;function r(a){let[s,l]=i.droot(a),u=[a.start[0],a.end[0]],c=[a.start[1],a.end[1]];for(let d of s)u.push(i.compute(a,Math.min(1,Math.max(0,d)))[0]);for(let d of l)c.push(i.compute(a,Math.min(1,Math.max(0,d)))[1]);return u.sort((d,p)=>d-p),c.sort((d,p)=>d-p),[[u[0],c[0]],[u[u.length-1],c[c.length-1]]]}i.extremas=r;function o(a,s){if(s===0)return[...a.start];if(s===1)return[...a.end];let l=1-s,u=l*l,c=s*s,d=u*l,p=u*s*3,f=l*c*3,h=s*c;return[d*a.start[0]+p*a.cp1[0]+f*a.cp2[0]+h*a.end[0],d*a.start[1]+p*a.cp1[1]+f*a.cp2[1]+h*a.end[1]]}i.compute=o})(hd||(hd={}));var _h;(r=>{function n(o){let i=o.start,a=o.cp,s=o.end,l=[2*(a[0]-i[0]),2*(a[1]-i[1])],u=[2*(s[0]-a[0]),2*(s[1]-a[1])],c={start:l,end:u};return c.derivative=Ph.derive(c),o.derivative=c,c}r.derive=n;function t(o){let i=o.derivative??r.derive(o),a=i.start,s=i.end;return[a[0]!==s[0]?a[0]/(a[0]-s[0]):0,a[1]!==s[1]?a[1]/(a[1]-s[1]):0]}r.droot=t;function e(o,i){if(i===0)return[...o.start];if(i===1)return[...o.end];let a=1-i,s=a*a,l=i*i,u=s,c=a*i*2,d=l;return[u*o.start[0]+c*o.cp[0]+d*o.end[0],u*o.start[1]+c*o.cp[1]+d*o.end[1]]}r.compute=e})(_h||(_h={}));var Ph;(e=>{function n(r){let o=r.start,i=r.end,a=[i[0]-o[0],i[1]-o[1]];return r.derivative=a,r.derivative}e.derive=n;function t(r,o){if(o===0)return[...r.start];if(o===1)return[...r.end];let i=r.start,a=r.end;return[i[0]+(a[0]-i[0])*o,i[1]+(a[1]-i[1])*o]}e.compute=t})(Ph||(Ph={}));var Or=class extends er{constructor(e,r,o){super(e,r,o);this.uuid=e;this.width=0;this.height=0;this.clipped=!0;this.background=new Io(e+"-background",Aa.defaultData,o),this.background.parent=this,this.updateState(r,o)}get fill(){return this.background.fill}get stroke(){return this.background.stroke}get backgroundBlur(){return this.background.backgroundBlur}get layerBlur(){return this.background.layerBlur}get dropShadow(){return this.background.dropShadow}get innerShadow(){return this.background.innerShadow}get cornerRadius(){return this.background.cornerRadius}set cornerRadius(e){this.background.cornerRadius=e}updateLocalMatrix(){super.updateLocalMatrix(),this.background?.updateLocalMatrix()}updateWorldMatrix(e,r,o){super.updateWorldMatrix(e,r,o),this.background?.updateWorldMatrix(e,r,o)}draw(e){if(!this.visible)return;e.save();let r=this.width,o=this.height;this.applyTransforms(e),this.background.width=r,this.background.height=o,this.background.draw(e),this.clipped&&e.clipRect(0,0,r,o,...this.cornerRadius),this.innerDrawChildren(e),e.restore()}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateCornerState(e){e.cornerRadius!==void 0&&(this.cornerRadius=e.cornerRadius)}updateSizeState(e){let r=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,r=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,r=!0),r&&this.updateWorldMatrix(!0,!1,!0)}updateState(e,r){super.updateState(e,r),this.updateSizeState(e),this.updateCornerState(e),e.fill!==void 0&&this.fill.update(e.fill),e.stroke!==void 0&&this.stroke.update(e.stroke),e.dropShadow!==void 0&&this.dropShadow.update(e.dropShadow),e.innerShadow!==void 0&&this.innerShadow.update(e.innerShadow),e.layerBlur!==void 0&&this.layerBlur.update(e.layerBlur),e.backgroundBlur!==void 0&&this.backgroundBlur.update(e.backgroundBlur),e.clipped!==void 0&&(this.clipped=e.clipped)}requestRender(){super.requestRender(),this.dispatchEvent({type:"render"})}dispose(){this.removeEventListener("render")}updateByPatchedOp(e,r,o){super.updateByPatchedOp(e,r,o),e.type===0&&(Le(e.path,["fill"])?this.fill.update(e.props):Le(e.path,["stroke"])?this.stroke.update(e.props):Le(e.path,["dropShadow"])?this.dropShadow.update(e.props):Le(e.path,["innerShadow"])?this.innerShadow.update(e.props):Le(e.path,["layerBlur"])?this.layerBlur.update(e.props):Le(e.path,["backgroundBlur"])?this.backgroundBlur.update(e.props):this.resetBBoxNeedsUpdate())}clone(e){let r=new Or(this.uuid,this.data,e);r.parent=void 0;for(let o of this.children)r.add(o.clone(e));return r}};var eS=Ht(Oh(),1),nn=class extends gr{constructor(e,r,o){super(e,r,o);this.uuid=e;this.data=r;this._pathBBox=new DOMRect;this.path="";this.updateState(r,o),this.autoClose=!1,this.computeSVGBBox()}computeSVGBBox(){let e=document.createElementNS("http://www.w3.org/2000/svg","svg"),r=document.createElementNS("http://www.w3.org/2000/svg","path");document.body.appendChild(e),r.setAttribute("d",this.path),e.appendChild(r),this._pathBBox=r.getBBox(),e.remove()}innerDraw(e){e.path(this.path)}intersectsInLocalSpace(e,r){return e>=this._pathBBox.x&&e<=this._pathBBox.x+this._pathBBox.width&&r>=this._pathBBox.y&&r<=this._pathBBox.y+this._pathBBox.height}getCenter(){return[(this._pathBBox.x+this._pathBBox.width)/2,(this._pathBBox.y+this._pathBBox.height)/2]}getHalfSize(){return[(this._pathBBox.x+this._pathBBox.width)/2,(this._pathBBox.y+this._pathBBox.height)/2]}updateState(e,r){super.updateState(e,r),e.path!==void 0&&(this.path=e.path,this.computeSVGBBox())}clone(e){let r=new nn(this.uuid,this.data,e);return r.parent=void 0,r}};function tS(n,t=1,e=1){if(t<=0||e<=0)return n;let o=(0,eS.parseSVG)(n).map(i=>{let a={...i};return"x"in a&&(a.x=a.x*t),"y"in a&&(a.y=a.y*e),"x1"in a&&(a.x1=a.x1*t),"x2"in a&&(a.x2=a.x2*t),"y1"in a&&(a.y1=a.y1*e),"y2"in a&&(a.y2=a.y2*e),"rx"in a&&(a.rx=a.rx*t),"ry"in a&&(a.ry=a.ry*e),a});return rS(o)}function rS(n){let t=["rx","ry","xAxisRotation","largeArc","sweep","x1","y1","x2","y2","x","y"],e;return n.map(r=>{let o=[];t.forEach(a=>{if(a in r){let s=r[a]*1;o.length&&s>=0&&o.push(","),o.push(s)}});let i=(e===r.code?o[0]<0?"":",":r.code)+o.join("");return e=r.code,i}).join("")}function oS(n,t,e){switch(t.type){case"ellipse2d":return new zn(n,t,e);case"rectangle2d":return new Io(n,t,e);case"text2d":return new Gn(n,t,e);case"vector2d":return new Ts(n,t,e);case"path2d":return new nn(n,t,e);case"frame2d":return new Or(n,t,e);case"group2d":default:return new lr(n,t,e)}}var Ch=class{constructor(t,e,r){this.uuid=t;this.data=e;this.group=new lr(Ch.GROUP_ID,{...Qs.defaultData},r),this.createChildrenObjects(e.objects,this.group,r)}createObject(t,e,r,o,i,a){let s=oS(t,e,a);s&&(o.add(s),o.children.splice(i,0,o.children.pop()),s.updateWorldMatrix(),r.length>0&&(s instanceof lr||s instanceof Or)&&this.createChildrenObjects(r,s,a))}createChildrenObjects(t,e,r){let o=0;for(let i of t)this.createObject(i.id,i.data,i.children,e,o,r),o+=1}draw(t){this.group.draw(t)}updateEntityByOp(t,e,r,o){let i=this.find(t);if(i)try{i.updateByOp(e,r,{shared:o})}catch(a){console.error(a)}}updateTreeByOp(t,e){if(t.path.length===0&&t.type===7){let r=t.parent===null?this.group:this.find(t.parent);r!==void 0&&r instanceof er&&(this.createObject(t.id,t.data,t.children,r,t.localIndex,e),r.requestRender())}else if(t.path.length===0&&t.type===8){let r=this.find(t.id);if(r!==void 0&&r.parent!==void 0&&r.parent instanceof er){let o=r.parent;r.resetBBoxNeedsUpdate(),o?.remove(r),o?.requestRender()}}else if(t.path.length===0&&t.type===9){let r=this.find(t.id);if(r!==void 0){let o=r.parent,i=t.parent===null?this:this.find(t.parent);if(i===void 0&&!1&&console.error("unexpected",i,t),i instanceof er||i===this){i.add(r);let a=t.localIndex;i.children.splice(a,0,i.children.pop()),r.updateWorldMatrix(!0,!1,!0),o?.requestRender(),r.requestRender()}r.resetBBoxNeedsUpdate()}}}add(t){this.group.add(t)}remove(t){this.group.remove(t)}traverse(t){this.group.traverse(e=>{e!==this.group&&t(e)})}intersectsChildren(t,e,r,o=!1,i=[]){return this.group.intersectsChildren(t,e,r,o,i,!0)}find(t){return this.group.find(t)}get children(){return this.group.children}project(t,e){return this.group.project(t,e)}getWithSortKey(t){let e=this.find(t);if(e===void 0)return;let r=[],o=e;for(;o!==this.group;){let i=o;o=o.parent;let a=o.children.indexOf(i);r.splice(0,0,a)}return{entity:e,sortKey:r}}getAllSorted(t){let e=[];for(let r of t){let o=this.getWithSortKey(r.id);o!==void 0&&e.push(o)}return e.sort((r,o)=>Ql(r.sortKey,o.sortKey)),e.map(r=>r.entity)}},_i=Ch;_i.GROUP_ID="scene2d";function Th({constraints:n,newParentWidth:t,newParentHeight:e,initialParentWidth:r,initialParentHeight:o,objectInitialWidth:i,objectInitialHeight:a,objectInitialPosition:s}){let{horizontalConstraint:l,verticalConstraint:u}=n,c=t-r,d=e-o,p=i,f=a,h=s[0],m=s[1];if(l!==0){if(l===1)h+=c;else if(l===3)h+=c/2;else if(l===2)p=Math.max(1,p+c);else if(l===4){let y=t/r;p*=y,h*=y}}if(u!==0){if(u===1)m+=d;else if(u===3)m+=d/2;else if(u===2)f=Math.max(1,f+d);else if(u===4){let y=e/o;f*=y,m*=y}}return{width:p,height:f,position:[h,m]}}var aD=Ht(Oh(),1);var Vse={mm:{mm:1,cm:.1,in:1/25.4,pt:72/25.4,pc:6/25.4,px:-1},cm:{mm:10,cm:1,in:1/2.54,pt:72/2.54,pc:6/2.54,px:-1},in:{mm:25.4,cm:2.54,in:1,pt:72,pc:6,px:-1},pt:{mm:25.4/72,cm:2.54/72,in:1/72,pt:1,pc:6/72,px:-1},pc:{mm:25.4/6,cm:2.54/6,in:1/6,pt:72/6,pc:1,px:-1},px:{mm:1,px:1,cm:1,in:1,pt:1,pc:1}};import{MathUtils as sD}from"three";var lD=ke.identity(),Ms=class{constructor(t,e,r,o){this.uuid=t;this.width=e;this.height=r;this.context=o;this.enabled=!0;this.isScreenSpace=!1;this.isFrameDirty=!1;this.onRenderRequestedDownstream=()=>{this.isFrameDirty=!0,this.context.shared.requestRender()};this.onFrameOverrideObjectEvent=t=>{if(t.target?.uuid!==void 0){let e=this.frameRoot?.find(t.target.uuid);e&&e.dispatchEvent({...t,target:e})}};this.scene2d=new _i(sD.generateUUID(),su.defaultData,{dpr:window.devicePixelRatio,shared:o.shared}),this.canvas=document.createElement("canvas"),this.renderer=new Rl(this.canvas),o.shared.addCanvas(this.uuid,this.canvas),this.textureHolder=o.shared.canvas(this.uuid),this.promise=this.init()}async init(){this.renderer instanceof Rl&&(this.renderer.wasmURL=Eb.skiaWasmUrl),await this.renderer.init()}render(){this.isFrameDirty&&(this.renderer.clear(),this.frameOverride?.draw(this.renderer),this.renderer.render(),this.textureHolder?.setNeedsUpdate(!0),this.isFrameDirty=!1)}updateEntity2DByOp(t,e,r,o){this.scene2d.updateEntityByOp(t,e,r,o),this.applySize()}updateTreeByOp(t,e){this.scene2d.updateTreeByOp(t,e),this.applySize()}applyOverrides(t){if(this.frameOverride&&this.frameRoot){this.frameOverride.position=[0,0],this.frameOverride.rotation=0;let e=t?.width??this.width,r=t?.height??this.height;this.frameOverride.width=e,this.frameOverride.height=r,this.frameOverride.localMatrix=lD,this.isScreenSpace&&(this.frameOverride.fill.color=Ie.from0to1([0,0,0,0])),this.frameOverride.data={...this.frameOverride.data,width:e,height:r},nS({objectOverride:this.frameOverride,objectRoot:this.frameRoot,newParentWidth:this.frameOverride.width,newParentHeight:this.frameOverride.height,initialParentWidth:this.frameRoot.width,initialParentHeight:this.frameRoot.height}),this.frameOverride.updateWorldMatrix(!0,!1,!0)}}applySize(t){let e=t?.width??this.width,r=t?.height??this.height;this.width=e,this.height=r,this.renderer.dpr=this.isScreenSpace?window.devicePixelRatio:Math.floor(2048/Math.max(e,r)),this.renderer.setSize(e,r),this.textureHolder?.dispose(),this.applyOverrides(t),this.frameOverride?.requestRender()}applyFrame(t){let e=this.context.scene.find2D(t);if(!(!e||!(e instanceof Or)))return this.disposeFrameOverride(),this.frameRoot=e,this.frameOverride=e.clone({dpr:this.renderer.dpr,shared:this.context.shared}),this.scene2d.add(this.frameOverride),this.applySize(),this.textureHolder?.dispose(),this.frame?.addEventListener("render",this.onRenderRequestedDownstream),this.frameOverride.traverse(r=>{r.addEventListener("beginState",this.onFrameOverrideObjectEvent)}),this.frameOverride.traverse(r=>{r.addEventListener("completeState",this.onFrameOverrideObjectEvent)}),this.frame?.requestRender(),e}get frame(){return this.frameOverride}get frameId(){return this.frame?.uuid}find(t){return this.scene2d.find(t)}get texture(){return this.textureHolder?.getTexture(1001)}disposeFrameOverride(){this.frameOverride?.removeEventListener("render",this.onRenderRequestedDownstream),this.frameOverride?.traverse(t=>{t.removeEventListener("beginStateChange",this.onFrameOverrideObjectEvent)}),this.frameOverride?.traverse(t=>{t.removeEventListener("completeState",this.onFrameOverrideObjectEvent)}),this.frameOverride&&this.scene2d.remove(this.frameOverride)}};function nS({objectOverride:n,objectRoot:t,newParentWidth:e,newParentHeight:r,initialParentWidth:o,initialParentHeight:i}){if(n instanceof Or&&t instanceof Or||n instanceof lr&&t instanceof lr)for(let a=0,s=n.children.length;a<s;a++){let l=n.children[a],u=t.children[a];l&&u&&l.uuid===u.uuid&&uD({objectOverride:l,objectRoot:u,newParentWidth:e,newParentHeight:r,initialParentWidth:o,initialParentHeight:i})}}function cD(n){if(Mh(n))return[n.width,n.height];if(n instanceof nn){let[t,e]=n.getHalfSize();return[t*2,e*2]}else if(n instanceof lr){let[t,e]=n.recursiveBBox.getHalfSize();return[t*2,e*2]}return[0,0]}function uD({objectOverride:n,objectRoot:t,newParentWidth:e,newParentHeight:r,initialParentWidth:o,initialParentHeight:i}){let[a,s]=cD(t),{width:l,height:u,position:c}=Th({constraints:n.data,newParentWidth:e,newParentHeight:r,initialParentWidth:o,initialParentHeight:i,objectInitialWidth:a,objectInitialHeight:s,objectInitialPosition:t.position});if(n.position=c,n.data={...n.data,position:c},n.states)for(let d in n.states)dD({stateId:d,objectOverride:n,objectRoot:t,newParentWidth:e,newParentHeight:r,initialParentWidth:o,initialParentHeight:i});if(Mh(n)||n instanceof lr)Mh(n)&&(n.width=l,n.height=u,n.data={...n.data,width:l,height:u}),nS({objectOverride:n,objectRoot:t,newParentWidth:l,newParentHeight:u,initialParentWidth:a,initialParentHeight:s});else if(n instanceof nn){let d=t,p=a!==0?l/a:1,f=s!==0?u/s:1;n.path=tS(d.path,p,f),n.data={...n.data,path:n.path}}}function dD({stateId:n,objectOverride:t,objectRoot:e,newParentWidth:r,newParentHeight:o,initialParentWidth:i,initialParentHeight:a}){let s=t.states?.[n],l=e.states?.[n];if(s&&l){let{width:u,height:c,position:d}=Th({constraints:t.data,newParentWidth:r,newParentHeight:o,initialParentWidth:i,initialParentHeight:a,objectInitialWidth:qo.isResizeable(l)?l.width:0,objectInitialHeight:qo.isResizeable(l)?l.height:0,objectInitialPosition:l.position});Object.assign(t.states[n],{position:d}),qo.isResizeable(s)&&Object.assign(t.states[n],{width:u,height:c})}}function Mh(n){return n instanceof Io||n instanceof Or||n instanceof zn||n instanceof Gn}var zr=class extends Ta(mD){constructor(e,r,o){super();this.data=r;this.bgColor=new Bt(1,1,1,1);this.fog=null;this.backupFog=new fD(16777215,.1,2e3);this.fogUseBGColor=!1;this.isActive=!1;this.aoColor=new pD;this.penumbraSizeArrayCache=null;this.super_Entity(e,r),this.personalCamera=new rn(bn,{...oi.defaultData,...r.camera,name:"Personal Camera"}),this.personalCamera.objectHelper.visible=!1,this.add(this.personalCamera),this.activeCamera=this.personalCamera,this.ambientLight=new hD(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.ambientLight.removeFromParent(),this.add(this.ambientLight),r.uiScene?this.uiScene=new _i((Array.isArray(e)?e[0]:e)+"-ui",r.uiScene,{dpr:window.devicePixelRatio,shared:o.shared}):r.uiFrame&&this.createUICanvas(r.uiFrame,o)}get scene(){return this.parent}get postprocessing(){return this.data.postprocessing}get frameId(){return this.data.uiFrame}get frame(){return this.uiCanvas?.frame}createUICanvas(e,r){this.uiCanvas=new Ms(this.uuid+"-uiscreen",window.innerWidth,window.innerHeight,r),this.uiCanvas.isScreenSpace=!0,this.uiCanvas.promise.then(()=>{this.uiCanvas?.applyFrame(e),this.uiCanvas?.applySize()})}updateVisible(){}setBackgroundColor(e){this.bgColor=e,this.fogUseBGColor===!0&&(this.backupFog.color=e)}entityChildrenCount(){return this.uiScene?this.uiScene.children.length:super.entityChildrenCount()}updateAmbientLight(e,r){e.color!==void 0&&(this.ambientLight.color=Qt(e.color,r)),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.traverseEntity(r=>{r instanceof yr&&r.recomputeBoolean()}),this.updateShadow(this.data.shadow)}forceMaterialsUpdate(){this.traverseEntity(e=>{if(e instanceof mr)if(Array.isArray(e.material))for(let r of e.material)r.needsUpdate=!0;else e.material.needsUpdate=!0,e.material.dispose()})}updateShadow(e){e.softShadowQuality!==void 0&&this.isActive&&Iv(e.softShadowQuality)&&this.forceMaterialsUpdate()}updateFog(e,r){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=Qt(e.color,r),this.backupFog.near=e.near,this.backupFog.far=e.far}updateAo(e,r){e.aoColor!==void 0&&(this.aoColor=Qt(e.aoColor,r))}updateByOp(e,r,o,i){let a=this.data.uiFrame;super.updateByOp(e,r,o,i);let s=r;Le(e.path,["fog"])?this.updateFog(s.fog,o.shared):Le(e.path,["ao"])?this.updateAo(s.ao,o.shared):Le(e.path,["ambient"])?this.updateAmbientLight(s.ambient,o.shared):Le(e.path,["shadow"])?this.updateShadow(s.shadow):e.type===0&&e.path.length===0&&(e.props.uiFrame!==void 0||a!==s.uiFrame)&&this.updateUIFrame(e.props.uiFrame,o)}updateUIFrame(e,r){e?(this.uiCanvas||this.createUICanvas(e,r),this.uiCanvas.enabled=!0,this.uiCanvas.applyFrame(e)):this.uiCanvas&&(this.uiCanvas.enabled=!1)}updateState(e,r){this.updateState_Entity(e,r),e.backgroundColor!==void 0&&this.setBackgroundColor(Qt(e.backgroundColor,r.shared)),e.fog!==void 0&&this.updateFog(e.fog,r.shared),e.ambient!==void 0&&this.updateAmbientLight(e.ambient,r.shared),e.ao!==void 0&&this.updateAo(e.ao,r.shared),e.shadow!==void 0&&this.updateShadow(e.shadow)}createFrame(e,r){}raycast(e,r){super.raycast(e,r)}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,r=0;this.traverseEntity(o=>{if(!o.visible)return!0;o instanceof Os&&o.visible&&e<3&&(this.penumbraSizeArrayCache[e]=o.data.penumbraSize,e+=1),o instanceof Cs&&o.visible&&e<5-3&&(this.penumbraSizeArrayCache[3+r]=o.data.penumbraSize,r+=1)})}raycastWithClones(e){let r=[],o=i=>{for(let a of i.children){let s=a.cloner;Re.is(a)&&(a.visible||s?.object.data.visible)&&((Ln(a)||Dl(a)&&this.scene.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,r),Gl(a,e,r,!0)),o(a))}};return o(this),r}updateEntity2DByOp(e,r,o,i){this.uiCanvas?.updateEntity2DByOp(e,r,o,i)}};import{PointLight as yD,Vector3 as yd,Box3 as gD,Box3Helper as iS,Color as xD}from"three";var gd=class extends As(yD,Ps){constructor(t,e,r){super(),this.super_Entity(t,e),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let i=this.shadow.camera;i.fov=90,i.aspect=1,i.near=100,i.far=2500;let a=new yd(-i.far+this.position.x,-i.far+this.position.y,-i.far+this.position.z),s=new yd(i.far+this.position.x,i.far+this.position.y,i.far+this.position.z),l=new gD(a,s),u=new iS(l,new xD(16755200));u.visible=!1,this.gizmos.shadowmap=u,this.update()}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this.gizmos))for(let t in this.gizmos){let e=this.gizmos[t];if(e instanceof iS){let r=this.shadow.camera,o=new yd(-r.far+this.position.x,-r.far+this.position.y,-r.far+this.position.z),i=new yd(r.far+this.position.x,r.far+this.position.y,r.far+this.position.z);e.box.set(o,i),e.updateMatrixWorld(!0)}}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.objectHelper&&this.objectHelper.update()}updateState(t,e){this.updateState_Light(t,e),t.distance!==void 0&&(this.distance=t.distance),t.decay!==void 0&&(this.decay=t.decay),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};var xd=class extends ft{get forceComputeSize(){return!0}get shape(){return this.geometry.userData.shape}updateEntityBoxSize(t,e){let r=this.geometry.getAttribute("position");r!==void 0?ml(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};var Is=class extends ft{constructor(e,r,o){super(e,r,o);this._shapeId=null;this._context=o}updateState(e,r){super.updateState(e,r),this.updateShape()}updateShape(){let e={...this.data.geometry.extrusion.shape};for(let i in e)typeof e[i]=="string"&&(e[i]=this._context.shared.getVariable(e[i],[this.uuid,"geometry","extrusion","shape",i]));let r;if(e.type==="Custom"){let i=e.shapeId;if(i!==this._shapeId&&this.detachShape(),i){this._shapeId=i;let a=this._context.scene.find(i);a?.data&&(a.attachedPaths.add(this),r=a.geometry.userData?.shape),r||this._context.scene.addPendingCommand(()=>this.updateShape())}}else{let i;switch(e.type){case"Rectangle":i=Fa;break;case"Ellipse":i=Ra;break;case"Polygon":i=Iu;break;case"Star":i=Nu;break;default:throw new Error(`Unknown shape type: ${e.type}`)}r=i.create({parameters:e}).userData.shape}let o=this.geometry;r&&o.inputs&&(o.inputs.shapeData=r,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,r){return super.updateTransformState(e,r)}updateGeometryInteractions(e,r){super.updateGeometryInteractions(e,r),this.updateShape()}updateEntityBoxSize(e,r){let o=this.geometry.getAttribute("position");o!==void 0?ml(o,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:o.count,e,r):super.updateEntityBoxSize(e,r)}};import{Group as bD,Matrix4 as vD,Skeleton as SD}from"three";var an=class extends Rr(bD,Vr){constructor(e,r,o){super();r.type==="Instance"&&typeof e=="string"&&(r=this.transformAssignData(r,o)),this.super_Entity(e,r),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,r){let o=xa.getComponentData({scene:r.scene.data,shared:r.shared.data},e.component);if(o){let i,a;for(let s of ho.rootOverrideProps)e[s]===void 0?(i===void 0&&(i={...e}),i[s]=o.data[s]):(a===void 0&&(a={}),a[s]=e[s],i===void 0&&(i={...e}),i[s]=so.apply(o.data[s],e[s]));return this.overrideData=a,i}else return{...It.defaultData,...e,...jr(It.defaultData,ho.rootOverrideProps)}}updateByOp(e,r,o,i){let a;if(this.isInstanceRoot&&!i){if(r=this.transformAssignData(r,o),e.type===0&&e.path.length===0&&this.component)for(let s of ho.rootOverrideProps)s in e.props&&e.props[s]===void 0&&(a===void 0&&(a={...e,props:{...e.props}}),a.props[s]=this.component.data[s]);else if(e.type===0&&e.path.length>0&&ho.rootOverrideProps.includes(e.path[0])){let s=e.path[0];a===void 0&&(a={...e,path:[],props:{[s]:r[s]}})}}super.updateByOp(a??e,r,o,i)}updateState(e,r){this.updateState_Entity(e,r)}expandInstanceChildren(e){let r=this.data;if(this.component===void 0){let o=e.scene.find(r.component)??null,i=!1;if(o!==this.oldComponent){if(this.oldComponent){let a=0;for(let s of this.children)if(Re.is(s))e.scene.disposeAndUnregisterEntityRecursivelyIfNotReregistered(s),bd(s),a+=1;else break;this.children.splice(0,a)}i=!0}if(o){let a={};sS(e,[this.uuid],r.overrides,this,o,o,0,i,a);for(let s of this.children)if(Re.is(s)){let l=s.data;l.type==="Empty"&&l.animations&&s.traverseEntity(u=>{if(u instanceof ft&&u.isSkinnedMesh){let c=u.dataPatched;if(c.bones&&c.boneInverses){let d=c.bones.map(h=>e.scene.find(a[h])),p=c.boneInverses.map(h=>new vD().fromArray(h)),f=new SD(d,p);u.bind(f,u.bindMatrix)}}else u.matrixAutoUpdate=!0})}}this.oldComponent=this.component}}};function bd(n){if(n.component){let t=n.component.instances.indexOf(n);t>=0&&n.component.instances.splice(t,1);for(let e of n.children)Re.is(e)&&bd(e)}}function aS(n,t,e,r){return n.component===t&&Yd(n.identity,r)?n.overrideData===e?2:1:0}function sS(n,t,e,r,o,i,a,s,l){if(a>50)return!1;if(r.component!==o){if(r.component){let c=r.component.instances.indexOf(r);c>=0&&r.component.instances.splice(c,1)}o.instances.find(c=>c===r)||o.instances.push(r),r.component=o}o instanceof an&&o.isInstanceRoot&&o.expandInstanceChildren(n);let u=0;for(let c of o.children)if(Re.is(c)){let d=[...t,...typeof c.identity=="string"?[c.identity]:c.identity],p=ya.resolve(e,d,1);if(p!=null&&!(p instanceof et)){if(!1)debugger;Object.setPrototypeOf(p,et.prototype),console.error("wrong prototype")}let f=null,h;if(!s){let m=r.children[u];if(f=Re.is(m)?m:null,f!==null){let y=aS(f,c,p,d);h=y>=1?f.stateSelection:void 0,y!==2&&(f=null)}if(f===null&&(f=n.scene.findInstance(d)??null,f!==null)){let y=aS(f,c,p,d);if(h=y>=1?f.stateSelection:void 0,y!==2)f=null;else{let g=f.parent.children.indexOf(f);f.parent.children.splice(g,1),r.children.splice(u,0,f),f.parent===r?(g<=u&&console.error("not possible"),void 0):(f.parent=r,f.matrixWorldNeedsUpdate=!0,f.resetBBoxNeedsUpdate(),f.updateVisible(),n.pendingDeletes.delete(f),void 0)}}}if(f===null){let m=p?so.apply(c.data,p):c.data;Ur.is(m.type)&&(m={...m,type:"Empty"}),f=Wr.createEntity(d,m,n),f.overrideData=p,r.add(f),r.children.splice(r.children.length-1,1),r.children.splice(u,0,f),f.updateState(f.data,n),h&&f.changeSelectedState(h,n),n.scene.registerInstanceAndSetUuid(f)}if(f.isBone){let m=f.identity[f.identity.length-1];l[m]=f.uuid}u+=1,sS(n,t,e,f,c,i,a+1,s,l)}if(!s){let c=u;for(;;){let d=r.children[u];if(Re.is(d))n.pendingDeletes.add(d);else break;u+=1}r.children.splice(c,u-c)}return!0}import{Bone as wD}from"three";var vd=class extends Rr(wD,Vr){constructor(t,e){super(),this.super_Entity(t,e),this.objectHelper.update(),this.matrixAutoUpdate=!0}updateState(t,e){this.updateState_Entity(t,e)}};var Pi=class extends ft{constructor(e,r,o){super(e,r,o);this.onBeforeRender=()=>{this.uiCanvas.render()};this.uiCanvas=new Ms(e+"-canvas",r.geometry.width,r.geometry.height,o),this.uiCanvas.promise.then(()=>{this.applyFrame(this.dataPatched.geometry.frame,o.shared)})}updateByPatchedOpGeometry(e,r,o){super.updateByPatchedOpGeometry(e,r,o),e.type===0&&(e.props.frame!==void 0&&this.applyFrame(e.props.frame,o.shared),(e.props.width!==void 0||e.props.height!==void 0)&&this.applySize(e.props,o.shared))}applySize(e,r){let o=e?.width??this.dataPatched.geometry.width,i=e?.height??this.dataPatched.geometry.height;this.uiCanvas.applySize({width:o,height:i}),this.applyGeometryParametersFromFrame(r)}applyFrame(e,r){this.uiCanvas.applyFrame(e),this.applyGeometryParametersFromFrame(r),this.applyMaterialParametersFromFrame({shared:r})}applyGeometryParametersFromFrame(e){let r=this.frame;r&&(Object.assign(this.data,{geometry:Object.assign(this.data.geometry,{cornerRadius:r.cornerRadius,cornerType:0})}),Object.assign(this.dataPatched,{geometry:Object.assign(this.dataPatched.geometry,{cornerRadius:r.cornerRadius,cornerType:0})}),this.localGeometry?.dispose(),this.localGeometry=Qo(this.dataPatched.geometry,e,this.data.flatShading,this))}applyMaterialParametersFromFrame(e){let r=this.frame;if(r){let o=r.data.backgroundBlur;Object.assign(this.data.material.layers[0].data.texture,{image:this.uiCanvas.uuid}),Object.assign(this.data.material.layers[1].data,{roughness:o.radius,alpha:o.enabled?1:0}),Object.assign(this.dataPatched.material.layers[0].data.texture,{image:this.uiCanvas.uuid}),Object.assign(this.dataPatched.material.layers[1].data,{roughness:o.radius,alpha:o.enabled?1:0}),this.material.reset(this.dataPatched.material,e,!0)}}updateEntity2DByOp(e,r,o,i){this.uiCanvas.updateEntity2DByOp(e,r,o,i),e===this.frameId&&r.type===0&&(r.props.cornerRadius!==void 0?this.applyGeometryParametersFromFrame(i):Le(r.path,["backgroundBlur"])&&this.applyMaterialParametersFromFrame({shared:i}))}get frame(){return this.uiCanvas.frame}get frameId(){return this.frame?.uuid}removeInteractionGeometry(e){super.removeInteractionGeometry(e),this.applySize({},e)}updateGeometryInteractions(e,r){super.updateGeometryInteractions(e,r),this.applySize({width:e.width,height:e.height},r)}};import{Object3D as ED,Vector3 as Gr,InstancedMesh as BD,InstancedBufferAttribute as LD,PlaneGeometry as RD,Vector4 as Fl,Quaternion as TS,TextureLoader as VD,Texture as MS,Euler as zD,MathUtils as Rh}from"three";import{GPUComputationRenderer as GD}from"three/examples/jsm/misc/GPUComputationRenderer.js";import{Vector3 as lS,FloatType as Ih,DataTexture as Nh,RGBAFormat as Dh,Mesh as AD,Euler as Pce,Matrix4 as Oce}from"three";import{MeshSurfaceSampler as _D}from"three/examples/jsm/math/MeshSurfaceSampler.js";function cS(n){let t=new Float32Array(n*n*2);for(let e=0;e<n;e++)for(let r=0;r<n;r++){let o=e*n+r;t[o*2+0]=e/(n-1),t[o*2+1]=r/(n-1)}return t}function uS(n){let t=Math.ceil(Math.sqrt(n));return Math.max(t,1)}function dS(n,t){let e=new AD(n.geometry,n.material),r=[],o=[],i=new lS,a=new lS;e.geometry.index!==null&&(e.geometry=e.geometry.toNonIndexed());let s=new _D(e).build();for(let c=0;c<t;c++)s.sample(i,a),r.push(i.x,i.y,i.z),o.push(a.x,a.y,a.z);let l=new Float32Array(r),u=new Float32Array(o);return{positions:l,normals:u}}function Eh(n,t){let e=n,r=new Float32Array(4*t*t);for(let i=0;i<t*t;i++)r[4*i]=e[3*i],r[4*i+1]=e[3*i+1],r[4*i+2]=e[3*i+2],r[4*i+3]=0;let o=new Nh(r,t,t,Dh,Ih);return o.needsUpdate=!0,o}function pS({size:n}){let t=new Float32Array(4*n*n);for(let r=0;r<n*n;r++)t[4*r]=r,t[4*r+1]=0,t[4*r+2]=0,t[4*r+3]=0;let e=new Nh(t,n,n,Dh,Ih);return e.needsUpdate=!0,e}function fS(n){let t=new Float32Array(4*n*n);for(let r=0;r<n*n;r++)t[4*r]=0,t[4*r+1]=0,t[4*r+2]=0,t[4*r+3]=0;let e=new Nh(t,n,n,Dh,Ih);return e.needsUpdate=!0,e}var hS=`
2616
2616
  // uniform sampler2D uCurrentPosition; // Pass in the variable from GPGPU
2617
2617
  // uniform sampler2D uCurrentVelocity; // Pass in the variable from GPGPU
2618
2618
  // uniform sampler2D uCurrentEmissionRate; // Pass in the variable from GPGPU
@@ -2681,7 +2681,7 @@ void main() {
2681
2681
  gl_FragColor = mix(vec4(0.0), activeColor, isActive);
2682
2682
 
2683
2683
  }
2684
- `;var dS=`
2684
+ `;var mS=`
2685
2685
 
2686
2686
  vec3 mod289(vec3 x) {
2687
2687
  return x - floor(x * (1.0 / 289.0)) * 289.0;
@@ -2883,7 +2883,7 @@ vec3 fbm_vec3(vec3 p, float frequency, float offset)
2883
2883
  );
2884
2884
  }
2885
2885
 
2886
- `;var pS=`
2886
+ `;var yS=`
2887
2887
  #ifdef USE_COLLIDER
2888
2888
  float restitution = max(uBounce * 2., .01); // Energy Loss
2889
2889
  // SPHERE COLLIDER
@@ -2951,7 +2951,7 @@ vec3 fbm_vec3(vec3 p, float frequency, float offset)
2951
2951
  #endif
2952
2952
  #endif
2953
2953
  // END COLLIDER
2954
- `;var fS=`
2954
+ `;var gS=`
2955
2955
  #ifdef USE_ATTRACTOR
2956
2956
 
2957
2957
  #ifdef USE_SPHERE_COLLIDER
@@ -3025,7 +3025,7 @@ vec3 fbm_vec3(vec3 p, float frequency, float offset)
3025
3025
  velocity *= uForceDamping;
3026
3026
  #endif
3027
3027
  #endif
3028
- `;var hS=`
3028
+ `;var xS=`
3029
3029
  #ifdef USE_VORTEX
3030
3030
  // Box dimensions
3031
3031
  vec3 boxHalfSize = uColliderSize / 2.0;
@@ -3064,7 +3064,7 @@ vec3 fbm_vec3(vec3 p, float frequency, float offset)
3064
3064
  velocity += applyForce( originDirection * uSpeed * (1. - uForceDamping) , mass * .5);
3065
3065
  }
3066
3066
  #endif
3067
- `;var mS=`
3067
+ `;var bS=`
3068
3068
  // uniform sampler2D uCurrentPosition; // Pass in the variable from GPGPU
3069
3069
  // uniform sampler2D uCurrentVelocity; // Pass in the variable from GPGPU
3070
3070
  // uniform sampler2D uCurrentEmissionRate; // Pass in the variable from GPGPU
@@ -3090,7 +3090,7 @@ uniform float uForceDamping;
3090
3090
  uniform float uForceIntensity;
3091
3091
 
3092
3092
 
3093
- `+dS+`
3093
+ `+mS+`
3094
3094
  float rand(vec2 co){
3095
3095
  return fract(sin(dot(co, vec2(12.9898, 78.233))) * 43758.5453);
3096
3096
  }
@@ -3168,11 +3168,11 @@ void main() {
3168
3168
  #endif
3169
3169
 
3170
3170
  // COLLIDER
3171
- ${pS}
3171
+ ${yS}
3172
3172
  // ATTRACTION
3173
- ${fS}
3173
+ ${gS}
3174
3174
  // VORTEX
3175
- ${hS}
3175
+ ${xS}
3176
3176
  }
3177
3177
  // End isActive
3178
3178
 
@@ -3190,7 +3190,7 @@ void main() {
3190
3190
 
3191
3191
  gl_FragColor = vec4(velocity, collisionFlag);
3192
3192
  }
3193
- `;import{ShaderMaterial as vD}from"three";var Eh=`
3193
+ `;import{ShaderMaterial as PD}from"three";var Bh=`
3194
3194
 
3195
3195
  // Linear Fade In
3196
3196
  float linearFadeIn(float t) {
@@ -3223,7 +3223,7 @@ void main() {
3223
3223
  float constant(float t) {
3224
3224
  return 1.0;
3225
3225
  }
3226
- `;var yS=`
3226
+ `;var vS=`
3227
3227
 
3228
3228
  float rand(vec3 co){
3229
3229
  return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
@@ -3238,7 +3238,7 @@ vec3 applyForce(vec3 force, float mass) {
3238
3238
 
3239
3239
  return acceleration;
3240
3240
  }
3241
- `;var gS=`
3241
+ `;var SS=`
3242
3242
  vec3 rgb2xyz (in vec3 rgb) {
3243
3243
  float r = rgb.r;
3244
3244
  float g = rgb.g;
@@ -3329,7 +3329,7 @@ vec3 lab2rgb (in vec3 lab) {
3329
3329
  return(rgb);
3330
3330
  }
3331
3331
 
3332
- `;var xS=`
3332
+ `;var wS=`
3333
3333
  uniform sampler2D uPosition;
3334
3334
  uniform float uSize;
3335
3335
  uniform float uSizeEnd;
@@ -3350,9 +3350,9 @@ vec3 lab2rgb (in vec3 lab) {
3350
3350
  varying vec2 vUv;
3351
3351
  varying vec2 vRef;
3352
3352
 
3353
- ${yS}
3354
- ${Eh}
3355
- `,bS=({easeSize:n="linearFadeOut"})=>`
3353
+ ${vS}
3354
+ ${Bh}
3355
+ `,AS=({easeSize:n="linearFadeOut"})=>`
3356
3356
  vUv = uv;
3357
3357
  vRef = ref;
3358
3358
  // Normalized LifeTime 1 to 0
@@ -3404,7 +3404,7 @@ vec3 lab2rgb (in vec3 lab) {
3404
3404
  mvPosition = modelViewMatrix * instanceMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
3405
3405
  mvPosition.xy += rotatedPosition;
3406
3406
  gl_Position = projectionMatrix * mvPosition;
3407
- `,vS=`
3407
+ `,_S=`
3408
3408
  uniform vec4 uColor; // start color
3409
3409
  uniform vec4 uColor2; // end color
3410
3410
  uniform sampler2D uTexture; // texture
@@ -3415,10 +3415,10 @@ vec3 lab2rgb (in vec3 lab) {
3415
3415
  float random(vec2 co) {
3416
3416
  return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);
3417
3417
  }
3418
- `+Eh+`
3419
- ${gS}
3418
+ `+Bh+`
3419
+ ${SS}
3420
3420
 
3421
- `,SS=({easeOpacity:n="linearFadeOut"})=>`
3421
+ `,PS=({easeOpacity:n="linearFadeOut"})=>`
3422
3422
  // if Particle is dead, hide it
3423
3423
  if (v_LifeLeft <= 0.005 ) {
3424
3424
  discard;
@@ -3439,7 +3439,7 @@ vec3 lab2rgb (in vec3 lab) {
3439
3439
 
3440
3440
  gl_FragColor = vec4(finalColor, finalAlpha);
3441
3441
 
3442
- `;var vd=class extends vD{constructor(e,r){super();this.needsJitter=!0;this.type="ParticleMaterial";this.easeOpacity="linearFadeIn";this.easeSize="linearFadeIn";this.useSizeEnd=!1;this.isColoringRandom=!1;this.init(e,r),this.context=r}reset(){}init(e,r){this.transparent=!0,this.depthTest=!0,this.depthWrite=!1,this.easeOpacity=e.ease,this.easeSize=e.easeSize,this.layers=[],this.lightLayer=new ar(0,"",{...Pt.defaultData("light","phong"),visible:!1},new Ko,{},r.shared),this.build()}updateState(e){e.coloring!==void 0&&(this.isColoringRandom=e.coloring==="random"),e.color!==void 0&&(e.color instanceof Array?this.uniforms.uColor.value=e.color:this.uniforms.uColor.value=this.context.shared.color(e.color)),e.color2!==void 0&&(e.color2 instanceof Array?this.uniforms.uColor2.value=e.color2:this.uniforms.uColor2.value=this.context.shared.color(e.color2)),e.size!==void 0&&(this.uniforms.uSize.value=e.size[0],this.uniforms.uSizeEnd.value=e.size[1],e.size[0]!==e.size[1]?this.useSizeEnd=!0:this.useSizeEnd=!1),e.ease!==void 0&&(this.easeOpacity=e.ease,this.build()),e.easeSize!==void 0&&(this.easeSize=e.easeSize,this.build()),this.needsUpdate=!0}onBeforeCompile(e){this.build(),e.defines=this.defines,e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader}build(){let e=new Qa;return e.needsJitter=this.needsJitter,e.addFragmentParsCode(Ab),e.buildShader("vertex",this.fragment),e.buildShader("fragment",this.fragment),e.addFragmentFinalCode(_b),this.isColoringRandom&&e.define("USE_RANDOM_COLORING"),this.useSizeEnd&&e.define("USE_SIZE_END"),e.addVertexParsCode(xS),e.addFragmentParsCode(vS),e.addVertexFinalCode(bS({easeSize:this.easeSize})),e.addFragmentFinalCode(SS({easeOpacity:this.easeOpacity})),this.vertexShader=e.getCode("vertex"),this.fragmentShader=e.getCode("fragment"),this.defines=e.defines,this.uniforms={...e.uniforms,...this.uniforms},this.extensions=e.extensions,this}get nodeMaterial(){return this}get fragment(){return this.lightLayer.node}getDefines(){return this.defines}nodeMaterialDispose(){this.layers.forEach(e=>e.dispose()),super.dispose()}};import{BoxGeometry as SD,ConeGeometry as wD,MeshBasicMaterial as AD,SphereGeometry as Bh,Vector3 as _D}from"three";import{Mesh as PD}from"three";import{TorusGeometry as OD}from"three";import{PlaneGeometry as CD}from"three";var Is=class{constructor(t,e,r,o){this.type="SphereEmitterShape";this.targetMesh=void 0;this.size=t,this.type=r,this.textureSize=aS(e);let i=1;this.targetMesh=o?.type==="Mesh"&&o?o:this.getMesh(r,i);let{positions:a,dataTexture:s,dataTextureNormals:l}=this.createPositions(this.textureSize,this.targetMesh??this.getMesh(r,i));this.positionsTexture=s,this.positionsAttribute=a,this.directionsTexture=l}createPositions(t,e){let{positions:r,normals:o}=sS(e,t*t),i=Dh(r,t),a=Dh(o,t);return{dataTexture:i,positions:r,dataTextureNormals:a}}getMesh(t,e){let r=null;switch(t){case"SphereEmitterShape":{r=new Bh(e*.5,32,32);break}case"TorusEmitterShape":{r=new OD(e*.5,.3,15,40);break}case"ConeEmitterShape":{r=new wD(e,e,15);break}case"BoxEmitterShape":{r=new SD(e,e,e);break}case"PlaneEmitterShape":{r=new CD(e,e),r.rotateX(-Math.PI/2);break}case"MeshEmitterShape":{r=new Bh(e,32,32);break}default:{r=new Bh(e,32,32);break}}return new PD(r,new AD({color:16711680}))}applyToShader(t,e){this.size=new _D().fromArray(e.size),t.uEmitterSize.value=this.size}dispose(){this.positionsTexture.dispose(),this.directionsTexture.dispose(),this.positionsAttribute=new Float32Array}};function Oi(n){let t={...n},e=ua.defaultData;t.forceFieldObjectId&&(t.colliderEntityId=t.forceFieldObjectId);let r={...e.shape,...t.shape},o={...e.renderMaterial,...t.renderMaterial};return{...e,...t,shape:r,renderMaterial:o}}var wS=`
3442
+ `;var Sd=class extends PD{constructor(e,r){super();this.needsJitter=!0;this.type="ParticleMaterial";this.easeOpacity="linearFadeIn";this.easeSize="linearFadeIn";this.useSizeEnd=!1;this.isColoringRandom=!1;this.init(e,r),this.context=r}reset(){}init(e,r){this.transparent=!0,this.depthTest=!0,this.depthWrite=!1,this.easeOpacity=e.ease,this.easeSize=e.easeSize,this.layers=[],this.lightLayer=new ar(0,"",{...Pt.defaultData("light","phong"),visible:!1},new Ko,{},r.shared),this.build()}updateState(e){e.coloring!==void 0&&(this.isColoringRandom=e.coloring==="random"),e.color!==void 0&&(e.color instanceof Array?this.uniforms.uColor.value=e.color:this.uniforms.uColor.value=this.context.shared.color(e.color)),e.color2!==void 0&&(e.color2 instanceof Array?this.uniforms.uColor2.value=e.color2:this.uniforms.uColor2.value=this.context.shared.color(e.color2)),e.size!==void 0&&(this.uniforms.uSize.value=e.size[0],this.uniforms.uSizeEnd.value=e.size[1],e.size[0]!==e.size[1]?this.useSizeEnd=!0:this.useSizeEnd=!1),e.ease!==void 0&&(this.easeOpacity=e.ease,this.build()),e.easeSize!==void 0&&(this.easeSize=e.easeSize,this.build()),this.needsUpdate=!0}onBeforeCompile(e){this.build(),e.defines=this.defines,e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader}build(){let e=new Ka;return e.needsJitter=this.needsJitter,e.addFragmentParsCode(_b),e.buildShader("vertex",this.fragment),e.buildShader("fragment",this.fragment),e.addFragmentFinalCode(Pb),this.isColoringRandom&&e.define("USE_RANDOM_COLORING"),this.useSizeEnd&&e.define("USE_SIZE_END"),e.addVertexParsCode(wS),e.addFragmentParsCode(_S),e.addVertexFinalCode(AS({easeSize:this.easeSize})),e.addFragmentFinalCode(PS({easeOpacity:this.easeOpacity})),this.vertexShader=e.getCode("vertex"),this.fragmentShader=e.getCode("fragment"),this.defines=e.defines,this.uniforms={...e.uniforms,...this.uniforms},this.extensions=e.extensions,this}get nodeMaterial(){return this}get fragment(){return this.lightLayer.node}getDefines(){return this.defines}nodeMaterialDispose(){this.layers.forEach(e=>e.dispose()),super.dispose()}};import{BoxGeometry as OD,ConeGeometry as CD,MeshBasicMaterial as TD,SphereGeometry as Lh,Vector3 as MD}from"three";import{Mesh as ID}from"three";import{TorusGeometry as ND}from"three";import{PlaneGeometry as DD}from"three";var Ns=class{constructor(t,e,r,o){this.type="SphereEmitterShape";this.targetMesh=void 0;this.size=t,this.type=r,this.textureSize=uS(e);let i=1;this.targetMesh=o?.type==="Mesh"&&o?o:this.getMesh(r,i);let{positions:a,dataTexture:s,dataTextureNormals:l}=this.createPositions(this.textureSize,this.targetMesh??this.getMesh(r,i));this.positionsTexture=s,this.positionsAttribute=a,this.directionsTexture=l}createPositions(t,e){let{positions:r,normals:o}=dS(e,t*t),i=Eh(r,t),a=Eh(o,t);return{dataTexture:i,positions:r,dataTextureNormals:a}}getMesh(t,e){let r=null;switch(t){case"SphereEmitterShape":{r=new Lh(e*.5,32,32);break}case"TorusEmitterShape":{r=new ND(e*.5,.3,15,40);break}case"ConeEmitterShape":{r=new CD(e,e,15);break}case"BoxEmitterShape":{r=new OD(e,e,e);break}case"PlaneEmitterShape":{r=new DD(e,e),r.rotateX(-Math.PI/2);break}case"MeshEmitterShape":{r=new Lh(e,32,32);break}default:{r=new Lh(e,32,32);break}}return new ID(r,new TD({color:16711680}))}applyToShader(t,e){this.size=new MD().fromArray(e.size),t.uEmitterSize.value=this.size}dispose(){this.positionsTexture.dispose(),this.directionsTexture.dispose(),this.positionsAttribute=new Float32Array}};function Oi(n){let t={...n},e=da.defaultData;t.forceFieldObjectId&&(t.colliderEntityId=t.forceFieldObjectId);let r={...e.shape,...t.shape},o={...e.renderMaterial,...t.renderMaterial};return{...e,...t,shape:r,renderMaterial:o}}var OS=`
3443
3443
  // uniform sampler2D uCurrentPosition; // Pass in the variable from GPGPU
3444
3444
  // uniform sampler2D uCurrentVelocity; // Pass in the variable from GPGPU
3445
3445
  // uniform sampler2D uCurrentEmissionRate; // Pass in the variable from GPGPU
@@ -3486,14 +3486,14 @@ void main() {
3486
3486
 
3487
3487
 
3488
3488
  }
3489
- `;var Rh=10,Sd=class extends TD{constructor(e,r){super();this.type="ParticleEmitter";this.debugMode=!1;this.worldSpace=!0;this.rootObject=null;this.gpuCompute=null;this.positionSimRT=null;this.velocitySimRT=null;this.emissionRateSimRT=null;this.emitterShape=void 0;this.isEmitting=!1;this.hasBeenReset=!1;this.emittedParticlesAmount=0;this.lastEmitTime=0;this.globalTime=0;this.targetFPS=60;this.previousRatio=1;this.lerpFactor=.4;this.particlesAmount=0;this.noiseStrength=0;this.noiseScale=0;this.isBillboardBased=!0;this.simFeaturesDefinition={USE_COLLIDER:!1,USE_ATTRACTOR:!1,USE_VORTEX:!1,USE_SPHERE_COLLIDER:!1,USE_BOX_COLLIDER:!1,USE_FORCE_LOCAL_SPACE:!1,USE_NORMALS:!1,USE_CURL_NOISE:!0,USE_SIMPLEX_NOISE:!1,USE_FBM_NOISE:!1};this.textureLoader=new DD;this.currentWorldPosition=new Gr;this.systemQuaternion=new _S;this.worldGravity=new Gr(0,0,0);this.directionAxis=new Gr(0,0,0);this.colliderV3=new Gr(0,0,0);this.colliderQuaternion=new _S(0,0,0,1);this.matrixAutoUpdate=!0,this.renderer=e,this.system=r,this.shared=r.context.shared;let o=r.data;this.material=new vd(o.renderMaterial,r.context),this.material.uniforms={uSize:{value:0},uSizeEnd:{value:0},uColor:{value:o.renderMaterial.color},uColor2:{value:o.renderMaterial.color2},uPosition:{value:new Gr(0,0,0)},uEmissionData:{value:new Gr(0,0,0)},uTexture:{value:this.defaultTexture},uWorldOffset:{value:new Gr(0,0,0)},uWorldQuaternion:{value:new Fl(0,0,0,1)},uRandScaleFactor:{value:o.randomScale??0},uRandRotationFactor:{value:o.randomRotation??0},uRotation:{value:o.renderMaterial.spriteRotation[0]??0},uRotationEnd:{value:o.renderMaterial.spriteRotation[1]??0}},this.setTexture(this.material.uniforms,o.renderMaterial.texture),this.init(o)}setTexture(e,r){let o=r.data;if(typeof r=="string"){let i=this.shared.image(r),a=new PS(i.img);a.needsUpdate=!0,e.uTexture.value=a;return}if(typeof o!="string"){let i=new Image;i.onload=()=>{let l=new PS(i);l.needsUpdate=!0,e.uTexture.value=l};let a=new Blob([o],{type:"image/*"}),s=URL.createObjectURL(a);i.src=s}}updateGeometryAttributes(e,r){let o=iS(r);!this.emitterShape?.positionsAttribute||e.geometry.setAttribute("ref",new ID(o,2))}applyWorldSpace(){if(!this.system.started||!this.worldSpace||!this.positionSimRT||!this.velocitySimRT)return;let e=this.system;e.getWorldQuaternion(this.systemQuaternion),this.systemQuaternion.invert(),e.getWorldPosition(this.currentWorldPosition),this.material.uniforms.uWorldOffset.value=this.currentWorldPosition,this.material.uniforms.uWorldQuaternion.value.copy(this.systemQuaternion.normalize()),this.positionSimRT.material.uniforms.uWorldOffset.value=this.currentWorldPosition,this.systemQuaternion.invert(),this.positionSimRT.material.uniforms.uWorldQuaternion.value.copy(this.systemQuaternion.normalize()),this.velocitySimRT.material.uniforms.uWorldQuaternion.value.copy(this.systemQuaternion.normalize())}update(e,r){if(!this.gpuCompute||!this.positionSimRT||!this.velocitySimRT||!this.emissionRateSimRT||this.hasBeenReset)return;if(this.checkIfAllParticlesAreDead()&&!this.hasBeenReset){this.reset();return}this.applyWorldSpace(),this.globalTime=e,this.positionSimRT.material.uniforms.uTime.value=e,this.emissionRateSimRT.material.uniforms.uTime.value=e;let o=1e3/r,i=this.targetFPS/o,a=this.previousRatio+(i-this.previousRatio)*this.lerpFactor;this.positionSimRT.material.uniforms.uFPSRatio.value=a,this.previousRatio=a;let s=this.isEmitting?this.GoEmitSomeParticles(e,this.system.data.birthRatePerSec):0;this.emissionRateSimRT.material.uniforms.uLastIndexEmitted.value=this.emittedParticlesAmount,this.emissionRateSimRT.material.uniforms.uParticlesToEmit.value=s,this.material.uniforms.uPosition.value=this.gpuCompute.getCurrentRenderTarget(this.positionSimRT)?.texture,this.system.colliderEntities.length>0&&this.renderColliders(),this.gpuCompute.compute()}renderColliders(){if(!this.velocitySimRT)return;let e=this.system.colliderEntities[0];if(!e)return;e.getWorldPosition(this.colliderV3),this.colliderV3.y===0&&(this.colliderV3.y=1e-4),this.velocitySimRT.material.uniforms.uColliderPos.value.copy(this.colliderV3);let r=e.data.size;this.colliderV3.fromArray(r),this.velocitySimRT.material.uniforms.uColliderSize.value.copy(this.simFeaturesDefinition.USE_SPHERE_COLLIDER?this.colliderV3.multiplyScalar(.5):this.colliderV3),e.getWorldQuaternion(this.colliderQuaternion),this.velocitySimRT.material.uniforms.uColliderQuaternion.value.copy(this.colliderQuaternion.normalize()),this.velocitySimRT.material.uniforms.uColliderQuaternionInvert.value.copy(this.colliderQuaternion.normalize().invert())}updateState(e){!this.velocitySimRT||!this.positionSimRT||(e.renderMaterial&&this.updateMaterialState(e.renderMaterial),this.updateParticleState(e))}updateVariableState(e,r){if(!this.velocitySimRT||!this.positionSimRT)return;r[2]==="size"&&this.material.updateState({size:[e,this.material.uniforms.uSizeEnd.value]}),r[2]==="sizeEnd"&&this.material.updateState({size:[this.material.uniforms.uSize.value,e]});let o=(i,a)=>{let s=[...this.system.data.shape.size];s[i]=a,this.updateParticleState({shape:{...this.system.data.shape,size:s}})};r[2]==="shape_size_0"&&o(0,e),r[2]==="shape_size_1"&&o(1,e),r[2]==="shape_size_2"&&o(2,e),r[2]==="speed"&&(this.velocitySimRT.material.uniforms.uSpeed.value=e/Rh),r[2]==="gravity"&&this.worldGravity.set(0,e/100,0),r[2]==="noiseStrength"&&(this.noiseStrength=e,this.velocitySimRT.material.uniforms.uNoiseStrength.value=this.noiseStrength),r[2]==="noiseScale"&&(this.noiseScale=e,this.velocitySimRT.material.uniforms.uNoiseScale.value=this.noiseScale),r[2]==="direction_x"&&(this.directionAxis=this.getDirectionAxis([Number(e),this.system.data.direction[1],this.system.data.direction[2]])),r[2]==="direction_y"&&(this.directionAxis=this.getDirectionAxis([this.system.data.direction[0],Number(e),this.system.data.direction[2]])),r[2]==="direction_z"&&(this.directionAxis=this.getDirectionAxis([this.system.data.direction[0],this.system.data.direction[1],Number(e)]))}updateMaterialState(e){this.material.updateState({...e,size:e.size?[Number(this.shared.getVariable(e.size[0],[this.uuid,"particles","size"])),Number(this.shared.getVariable(e.size[1],[this.uuid,"particles","sizeEnd"]))]:[0,0]}),e.texture&&(this.setTexture(this.material.uniforms,e.texture),this.material.needsUpdate=!0)}updateParticleState(e){if(!(!this.positionSimRT||!this.velocitySimRT)){if(this.shouldReInitGPUCompute(e)&&this.init(Oi(this.system.data)),e.life!==void 0&&(this.positionSimRT.material.uniforms.uMaxLifeTime.value=e.life),e.speed!==void 0&&(this.velocitySimRT.material.uniforms.uSpeed.value=Number(this.shared.getVariable(e.speed,[this.uuid,"particles","speed"]))/Rh),e.collisionBounce!==void 0&&(this.velocitySimRT.material.uniforms.uBounce.value=e.collisionBounce),e.noiseStrength!==void 0&&(this.noiseStrength=Number(this.shared.getVariable(e.noiseStrength,[this.uuid,"particles","noiseStrength"])),this.velocitySimRT.material.uniforms.uNoiseStrength.value=this.noiseStrength),e.noiseScale!==void 0&&(this.noiseScale=Number(this.shared.getVariable(e.noiseScale,[this.uuid,"particles","noiseScale"])),this.velocitySimRT.material.uniforms.uNoiseScale.value=this.noiseScale),e.noiseSeed!==void 0&&(this.velocitySimRT.material.uniforms.uNoiseSeed.value=e.noiseSeed),e.randomMass!==void 0&&(this.velocitySimRT.material.uniforms.uRandomMassFactor.value=e.randomMass),e.renderMaterial?.size!==void 0){let r=this.shared.getVariable(e.renderMaterial.size[0],[this.uuid,"particles","size"]);this.velocitySimRT.material.uniforms.particleSize.value=Number(r)}if(e.renderMaterial?.spriteRotation!==void 0&&(this.material.uniforms.uRotation.value=e.renderMaterial.spriteRotation[0],this.material.uniforms.uRotationEnd.value=e.renderMaterial.spriteRotation[1]),e.shape!==void 0){let r=e.shape.size??this.system.data.shape.size,o=[Number(this.shared.getVariable(r[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(r[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(r[2],[this.uuid,"particles","shape_size_2"]))],i={...Oi(this.system.data).shape,size:o};this.emitterShape?.applyToShader(this.positionSimRT.material.uniforms,i)}if(e.gravity!==void 0&&(this.worldGravity.set(0,Number(this.shared.getVariable(this.system.data.gravity,[this.uuid,"particles","gravity"]))/100,0),this.velocitySimRT.material.uniforms.uGravity={value:this.worldGravity}),e.direction!==void 0){let r=this.getDirectionFromVariable(e.direction);this.directionAxis=this.getDirectionAxis(r),this.velocitySimRT.material.uniforms.uDirectionsAxis.value=this.directionAxis}e.randomRotation!==void 0&&(this.material.uniforms.uRandRotationFactor.value=e.randomRotation),e.randomScale!==void 0&&(this.material.uniforms.uRandScaleFactor.value=e.randomScale)}}updateForceFieldParameters(e){!this.velocitySimRT||(e.forceIntensity!==void 0&&(this.velocitySimRT.material.uniforms.uForceIntensity.value=e.forceIntensity),e.forceDambing!==void 0&&(this.velocitySimRT.material.uniforms.uForceDamping.value=e.forceDambing))}getDirectionAxis(e){let r=[Number(e[0])*Lh.DEG2RAD,Number(e[1])*Lh.DEG2RAD,Number(e[2])*Lh.DEG2RAD],o=new ED(r[0],r[1],r[2],"XYZ");return this.directionAxis.set(0,1,0).applyEuler(o).normalize(),this.velocitySimRT&&(this.velocitySimRT.material.uniforms.uDirectionsAxis.value=this.directionAxis),this.directionAxis}shouldReInitGPUCompute(e){let{birthRatePerSec:r,rootObjectType:o,colliderEntityId:i,shape:a,emitTimeDuration:s,emitTimeCycle:l,life:u,directionMode:c,noiseType:d}=e;return r!==void 0||o!==void 0||(i||i===null)||l!==void 0||a!==void 0||u!==void 0||s!==void 0||c!==void 0||d!==void 0}init(e){this.dispose(),this.particlesAmount=this.getMaxParticlesAmount({birthRatePerSecond:e.birthRatePerSec,particleMaxLifeTime:e.life,loopDuration:e.emitTimeCycle==="infinity"?0:e.emitTimeDuration}),this.particlesAmount>1e5&&(console.warn(`The maximum number of particles is limited to ${1e5}.`),this.particlesAmount=1e5),this.emitterShape=this.createShape(e.shape,this.particlesAmount);let r=setInterval(()=>{if(!!this.emitterShape)if(isNaN(this.emitterShape.positionsTexture.source.data.data[0])){this.init(e);return}else clearInterval(r)},100);if(!this.emitterShape)return;let o=new BD(this.emitterShape.textureSize,this.emitterShape.textureSize,this.renderer),i=this.updateSimulationDefinition(e),a=o.addVariable("uCurrentPosition",i+uS,this.emitterShape.positionsTexture),s=o.addVariable("uCurrentVelocity",i+mS,this.emitterShape.directionsTexture),l=o.addVariable("uCurrentEmissionRate",wS,cS(this.emitterShape.textureSize));o.setVariableDependencies(a,[a,s,l]),o.setVariableDependencies(s,[a,s,l]),o.setVariableDependencies(l,[a,s,l]);let u=lS({size:this.emitterShape.textureSize}),c={uOriginalPosition:{value:this.emitterShape.positionsTexture},uWorldOffset:{value:new Gr(0,0,0)},uWorldQuaternion:{value:new Fl(0,0,0,1)},uTime:{value:0},uFPSRatio:{value:1},uMaxLifeTime:{value:e.life},uEmitterSize:{value:new Gr(Number(this.shared.getVariable(e.shape.size[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(e.shape.size[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(e.shape.size[2],[this.uuid,"particles","shape_size_2"])))},particleSize:{value:0}};a.material.uniforms=c;let d=this.getDirectionFromVariable(e.direction);this.directionAxis=this.getDirectionAxis(d),this.worldGravity.set(0,Number(this.shared.getVariable(this.system.data.gravity,[this.uuid,"particles","gravity"]))/100,0),this.noiseStrength=Number(this.shared.getVariable(e.noiseStrength,[this.uuid,"particles","noiseStrength"])),this.noiseScale=Number(this.shared.getVariable(e.noiseScale,[this.uuid,"particles","noiseScale"]));let p=e.colliderEntityId&&this.system.getColliderData(e.colliderEntityId),f={uOriginalPosition:{value:this.emitterShape.positionsTexture},uDirections:{value:this.emitterShape.directionsTexture},uDirectionsAxis:{value:this.directionAxis},uWorldQuaternion:{value:new Fl(0,0,0,1)},uColliderPos:{value:new Gr(0,0,0)},uColliderSize:{value:new Gr(0,0,0)},uForceIntensity:{value:p?p.forceIntensity:0},uForceDamping:{value:p?p.forceDambing:0},uColliderQuaternion:{value:new Fl(0,0,0,1)},uColliderQuaternionInvert:{value:new Fl(0,0,0,1)},particleSize:{value:0},uGravity:{value:this.worldGravity},uNoiseStrength:{value:this.noiseStrength},uNoiseScale:{value:this.noiseScale},uNoiseSeed:{value:e.noiseSeed},uRandomMassFactor:{value:e.randomMass},uBounce:{value:e.collisionBounce},uSpeed:{value:Number(this.shared.getVariable(e.speed,[this.uuid,"particles","speed"]))/Rh}};s.material.uniforms=f;let h={uIndex:{value:u},uTime:{value:0},uLastIndexEmitted:{value:0},uParticlesToEmit:{value:0}};l.material.uniforms=h;let m=[Number(this.shared.getVariable(e.shape.size[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(e.shape.size[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(e.shape.size[2],[this.uuid,"particles","shape_size_2"]))],y={...Oi(this.system.data).shape,size:m};this.emitterShape.applyToShader(a.material.uniforms,y),o.init(),this.gpuCompute=o,this.positionSimRT=a,this.velocitySimRT=s,this.emissionRateSimRT=l,this.rootObject=this.createPrimaryEmitter(this.emitterShape.textureSize),this.add(this.rootObject),this.material.needsUpdate=!0}getDirectionFromVariable(e){let r=Number(this.shared.getVariable(e[0],[this.uuid,"particles","direction_x"])),o=Number(this.shared.getVariable(e[1],[this.uuid,"particles","direction_y"])),i=Number(this.shared.getVariable(e[2],[this.uuid,"particles","direction_z"]));return[r,o,i]}updateSimulationDefinition(e){if(this.simFeaturesDefinition.USE_COLLIDER=!1,this.simFeaturesDefinition.USE_ATTRACTOR=!1,this.simFeaturesDefinition.USE_VORTEX=!1,this.simFeaturesDefinition.USE_SPHERE_COLLIDER=!1,this.simFeaturesDefinition.USE_BOX_COLLIDER=!1,this.simFeaturesDefinition.USE_FORCE_LOCAL_SPACE=!1,this.simFeaturesDefinition.USE_NORMALS=!1,this.simFeaturesDefinition.USE_CURL_NOISE=!1,this.simFeaturesDefinition.USE_SIMPLEX_NOISE=!1,this.simFeaturesDefinition.USE_FBM_NOISE=!1,e.colliderEntityId&&this.system.colliderEntities.length>0){let o=this.system.getColliderData(e.colliderEntityId);switch(o?.forceType){case"attractor":this.simFeaturesDefinition.USE_ATTRACTOR=!0;break;case"collider":this.simFeaturesDefinition.USE_COLLIDER=!0;break;case"vortex":this.simFeaturesDefinition.USE_VORTEX=!0;break}let i=o?.colliderType;i==="sphere"&&(this.simFeaturesDefinition.USE_SPHERE_COLLIDER=!0),i==="box"&&(this.simFeaturesDefinition.USE_BOX_COLLIDER=!0),o?.forceRange==="helper"&&(this.simFeaturesDefinition.USE_FORCE_LOCAL_SPACE=!0)}e.directionMode==="normals"&&(this.simFeaturesDefinition.USE_NORMALS=!0),e.noiseType==="curl"&&(this.simFeaturesDefinition.USE_CURL_NOISE=!0),e.noiseType==="simplex"&&(this.simFeaturesDefinition.USE_SIMPLEX_NOISE=!0),e.noiseType==="fbm"&&(this.simFeaturesDefinition.USE_FBM_NOISE=!0);let r="";for(let[o,i]of Object.entries(this.simFeaturesDefinition))i&&(r+=`#define ${o}
3490
- `);return r}createShape(e,r){this.emitterShape&&this.emitterShape.dispose();let o=new Gr(Number(this.shared.getVariable(e.size[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(e.size[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(e.size[2],[this.uuid,"particles","shape_size_2"])));if(e.type==="MeshEmitterShape"){let i=null;return this.system.context.scene.traverseEntity(a=>{a.uuid===e.fromMeshId&&(i=a)}),i?new Is(o,r,e.type,i):new Is(o,r,"SphereEmitterShape")}else return new Is(o,r,e.type)}createPrimaryEmitter(e){let r,o=e*e;return r=new MD(new ND(1,1,1),this.material,o),this.updateGeometryAttributes(r,e),this.material.needsUpdate=!0,r.onBeforeRender=()=>{this.applyWorldSpace()},r}getMaxParticlesAmount({birthRatePerSecond:e,particleMaxLifeTime:r,loopDuration:o=0}){return Math.ceil(e*(r+o))}dispose(){!this.gpuCompute||(this.rootObject?.parent?.remove(this.rootObject),this.gpuCompute.dispose(),this.material.nodeMaterialDispose(),this.emitterShape?.dispose())}GoEmitSomeParticles(e,r){let o=e-this.lastEmitTime,i=1/r;if(o>=i){let a=Math.max(1,Math.floor(o/i));return this.lastEmitTime=e,this.emittedParticlesAmount+a>this.particlesAmount&&(this.emittedParticlesAmount=0),this.emittedParticlesAmount+=a,a}return 0}checkIfAllParticlesAreDead(){return this.lastEmitTime+this.system.data.life+1<this.globalTime}reset(){this.hasBeenReset=!0,this.lastEmitTime=0,this.emittedParticlesAmount=0,this.gpuCompute&&this.init(Oi(this.system.data))}startEmitting(e){this.isEmitting=!0,this.hasBeenReset=!1,this.lastEmitTime=e}stopEmitting(){this.isEmitting=!1}};import{BufferGeometry as LD,Float32BufferAttribute as RD,MeshBasicMaterial as VD}from"three";var wd=class extends Dt{constructor(e,r,o){super(e,r);this.type="ParticleSystem";this.geometry=new LD;this.actualTime=0;this.currentLoopTime=0;this.started=!1;this.stopped=!1;this.isFrozen=!1;this.isIdle=!0;this.emitter=null;this.colliderEntities=[];this.renderer=null;this.isPreWarm=!1;this._hasOnAfterRenderBeenCalled=!1;this.onAfterRender=e=>{this._hasOnAfterRenderBeenCalled||(this._hasOnAfterRenderBeenCalled=!0,this.init(e))};this.context=o,this.data={...r,...Oi(r)},this.geometry.setAttribute("position",new RD([],3)),this.material=new VD({colorWrite:!1}),this.frustumCulled=!1}init(e){this.renderer=e,this.emitter=new Sd(e,this),this.add(this.emitter),this.updateParticleState(this.data)}update(e){if(!this.isReady||!this.started||this.isFrozen||this.isIdle)return;this.actualTime+=e,this.stopped||(this.currentLoopTime+=e);let r=this.data.emitTimeCycle==="one_time";if((this.data.emitTimeCycle==="loop"||r)&&this.currentLoopTime>this.data.emitTimeDuration*1e3&&(this.stopped||(this.stop(),r||this.start(this.data.emitTimeLoopDelayStart==="start"?0:this.data.emitTimeDelay*1e3))),this.emitter&&this.started){let i=this.actualTime/1e3;this.emitter.update(i,e)}this.scale.set(1,1,1),this.updateMatrix()}isReady(){return!!this.emitter}hasCollider(e){return this.colliderEntities.some(r=>r.identity===e)}getColliderData(e){let r=this.colliderEntities.find(o=>o.identity===e);return r?r.data:null}updateByPatchedOp(e,r,o){super.updateByPatchedOp(e,r,o),Le(e.path,["renderMaterial"])&&this.updateParticleState({renderMaterial:{...this.data.renderMaterial,...ct.drop(e,1).props}}),Le(e.path,["shape"])&&this.updateParticleState({shape:{...this.data.shape,...ct.drop(e,1).props}})}updateState(e,r){super.updateState(e,r),this.updateParticleState(e)}updateParticleState(e){if(!!this.emitter){if(e.colliderEntityId!==void 0&&e.colliderEntityId!==null){let r=this.context.scene.find(e.colliderEntityId);this.colliderEntities=r?[r]:[]}e.colliderEntityId===null&&(this.colliderEntities=[]),this.emitter.updateState(e),e.emitTimeCycle&&this.started&&this.start()}}updateFromColliderEntity(e){!this.emitter||(this.emitter.updateForceFieldParameters(e),this.stop(),this.start())}start(e=0){if(this.currentLoopTime=0,e){setTimeout(()=>{this.start(0)},e);return}this.started=!0,this.stopped=!1,this.isFrozen=!1,this.emitter?.startEmitting(this.actualTime/1e3)}froze(){this.isFrozen=!0}unFroze(){this.isFrozen=!1}stop(){this.stopped=!0,this.currentLoopTime=0,this.emitter?.stopEmitting()}reset(){this.started=!1,this.stopped=!1,this.emitter?.reset()}wakeUp(){this.isIdle=!1}sleep(){this.isIdle=!0,this.reset()}};function zD(n,t,e){let r;return t.geometry.type==="TextGeometry"?new gs(n,t,e):(t.geometry.type==="SubdivGeometry"?r=new bi(n,t,e):t.geometry.type==="PathGeometry"?r=new Ms(n,t,e):t.geometry.type==="VectorGeometry"?r=new gd(n,t,e):t.geometry.type==="BooleanGeometry"?r=new yr(n,t,e):t.geometry.type==="UIGeometry"?r=new Pi(n,t,e):r=new ft(n,t,e),r)}function Ad(n,t,e){return console.assert(t.type!==void 0),t.type==="Mesh"?zD(n,t,e):t.type==="Empty"?new Rn(n,t):t.type==="Particle"?new wd(n,t,e):t.type==="ParticleCollider"?new sd(n,t,e):t.type==="Splat"?new Rn(n,t):t.type==="Bone"?new bd(n,t):t.type==="Page"?new zr(n,t,e):t.type==="PointLight"?new yd(n,t,e):t.type==="SpotLight"?new Os(n,t,e):t.type==="DirectionalLight"?new Ps(n,t,e):t.type==="Component"||t.type==="Instance"?new an(n,t,e):Ur.is(t.type)?new rn(n,t):(console.error(t),new Rn(n,t))}Wr.createEntity=Ad;function GD(n,t,e){let r=Ad(n.identity,t,e),o=n.children,i=n.attachedPaths,a=n.parent,s=n.component,l=n.instances,u=n.overrideData,c=n.uuid,d=n.stateSelection;n.dispose();for(let p of Object.keys(n))delete n[p];Object.setPrototypeOf(n,Object.getPrototypeOf(r));for(let p of Object.keys(r))n[p]=r[p];n.children=[...n.children,...o],n.attachedPaths=i,n.parent=a,n.component=s,n.instances=l,n.uuid=c,n.overrideData=u,n.updateState(n.data,e),d&&n.changeSelectedState(d,e),n.resetBBoxNeedsUpdate()}Wr.changeEntityProptotype=GD;Wr.Cloner=bs;function OS(n,t,e,r){n.updateByOp(t,e,r,!1)}import{Matrix4 as jD,Ray as UD,Raycaster as HD}from"three";function CS(n,t){let e=!1,r=t.getLayersOfType("transmission"),o=t.getLayersOfType("outline");return o.length>0&&(n.layers.set(8),r.length>0&&n.layers.enable(3),e=!0,ms(n),hs(n)),r.length===0&&o.length===0&&n.layers.set(0),n instanceof mr&&n.needsAO&&n.layers.enable(5),e}function TS(n,t){if(!t.layers)return!1;let e=!1,r=t.getLayersOfType("transmission").filter(i=>i.data.visible),o=t.getLayersOfType("outline").filter(i=>i.data.visible);return r.length>0&&(n.layers.set(3),o.length>0&&n.layers.enable(8),e=!0),r.length===0&&o.length===0&&n.layers.set(0),n.needsAO&&n.layers.enable(5),e}function MS(n){let t=!1;return n.traverseEntity(e=>{if(e instanceof mr)if(Array.isArray(e.material))for(let r=0;r<e.material.length;r++)CS(e,e.material[r])&&(t=!0);else CS(e,e.material)&&(t=!0)}),t}function IS(n){let t=!1;return n.traverseEntity(e=>{if(e instanceof mr)if(Array.isArray(e.material))for(let r=0;r<e.material.length;r++)TS(e,e.material[r])&&(t=!0);else TS(e,e.material)&&(t=!0)}),t}var qD=new HD,WD=new jD,$D=new UD;function Gl(n,t,e,r=!1){let o=n.cloner;if(o)for(let i of o.children){let a=WD.copy(i.matrixWorld).invert(),s=$D.copy(t.ray).applyMatrix4(a),l=n.matrixWorld;s.applyMatrix4(l);let u=qD;u.set(s.origin,s.direction),u.near=t.near,u.far=t.far;let c=u.intersectObject(n,!1);c.length>0&&e.push({...c[0],object:r?i:n})}}var _d=class{constructor(){this._constraints=new Map}setConstraint(t,e){e===null?this._constraints.delete(t):this._constraints.set(t,e)}removeDependencies(t){this._constraints.delete(t)}applyConstraints(t){let e=new Set;this._constraints.forEach((r,o)=>{let i=[o,r],a=r;for(;this._constraints.has(a);)a=this._constraints.get(a),e.has(a)||i.push(a);for(let s=i.length-2;s>=0;s--)if(!e.has(i[s])){let l=t.find(i[s]);l?l.applyPathSnapping(t):console.warn(`missing entity ${i[s]}`),e.add(i[s])}})}findDependency(t,e){let r=t;for(;this._constraints.has(r);)if(r=this._constraints.get(r),r===e)return!0;return!1}};var no=Ht(Ns()),No=Ht(Ds());var bt=Ht(Ns()),be=Ht(Ds()),Fn=class{constructor(t,e,r){this._dataNormalized=t,this._minD=e,this._maxD=r}static createFromUnnormalized(t){let e=be.sup(t),r=be.inf(t),o=(0,bt.default)(new Float32Array(t.size),t.shape),i=e-r;return i<1e-4?be.assigns(o,0):(be.subs(o,t,r),be.divs(o,o,i)),new Fn(o,r,e)}get data(){return this._dataNormalized}get minD(){return this._minD}get maxD(){return this._maxD}denormalize(){let t=(0,bt.default)(new Float32Array(this._dataNormalized.size),this._dataNormalized.shape);return be.muls(t,this._dataNormalized,this._maxD-this._minD),be.adds(t,t,this._minD),t}},tt=class{constructor(t,e){this._quantized=t,this._method=e}get quantized(){return this._quantized}static maxIntBits(t){return 2**t-1}static fromNormalized(t,e){let r=t.data,o;if(e==="norm8x"){let i=tt.maxIntBits(8),a=(0,bt.default)(new Float32Array(r.size),r.shape);be.muls(a,r,i),be.roundeq(a),o=(0,bt.default)(new Uint8Array(a.data),r.shape)}else if(e==="norm565"){let i=(0,bt.default)(new Float32Array(r.size),r.shape);be.assign(i,r),be.mulseq(i.pick(null,0),tt.maxIntBits(5)),be.mulseq(i.pick(null,1),tt.maxIntBits(6)),be.mulseq(i.pick(null,2),tt.maxIntBits(5)),be.roundeq(i);let a=(0,bt.default)(new Uint16Array(i.data),r.shape),s=(0,bt.default)(new Uint16Array(r.shape[0]),[r.shape[0]]),l=(0,bt.default)(new Uint16Array(r.shape[0]),[r.shape[0]]);be.lshifts(s,a.pick(null,0),11),be.lshifts(l,a.pick(null,1),5),be.boreq(s,l),be.boreq(s,a.pick(null,2)),o=s}else{let i=(0,bt.default)(new Float32Array(r.size),r.shape);be.assign(i,r),be.mulseq(i.pick(null,0),tt.maxIntBits(11)),be.mulseq(i.pick(null,1),tt.maxIntBits(10)),be.mulseq(i.pick(null,2),tt.maxIntBits(11)),be.roundeq(i);let a=(0,bt.default)(new Uint32Array(i.data),r.shape),s=(0,bt.default)(new Uint32Array(r.shape[0]),[r.shape[0]]),l=(0,bt.default)(new Uint32Array(r.shape[0]),[r.shape[0]]);be.lshifts(s,a.pick(null,0),21),be.lshifts(l,a.pick(null,1),11),be.boreq(s,l),be.boreq(s,a.pick(null,2)),o=s}return new tt(o,e)}dequantize(t,e){let r=this._method,o,i=this._quantized;if(r==="norm8x"){let a=tt.maxIntBits(8);o=(0,bt.default)(new Float32Array(i.size),i.shape),be.muls(o,i,1/a)}else if(r==="norm565"){let a=(0,bt.default)(new Uint8Array(i.shape[0]),[i.shape[0]]),s=(0,bt.default)(new Uint8Array(i.shape[0]),[i.shape[0]]),l=(0,bt.default)(new Uint8Array(i.shape[0]),[i.shape[0]]);be.rrshifts(a,i,11),be.rrshifts(s,i,5),be.bandseq(s,tt.maxIntBits(6)),be.bands(l,i,tt.maxIntBits(5)),o=(0,bt.default)(new Float32Array(i.shape[0]*3),[i.shape[0],3]),be.muls(o.pick(null,0),a,1/tt.maxIntBits(5)),be.muls(o.pick(null,1),s,1/tt.maxIntBits(6)),be.muls(o.pick(null,2),l,1/tt.maxIntBits(5))}else{let a=(0,bt.default)(new Uint16Array(i.shape[0]),[i.shape[0]]),s=(0,bt.default)(new Uint16Array(i.shape[0]),[i.shape[0]]),l=(0,bt.default)(new Uint16Array(i.shape[0]),[i.shape[0]]);be.rrshifts(a,i,21),be.rrshifts(s,i,11),be.bandseq(s,tt.maxIntBits(10)),be.bands(l,i,tt.maxIntBits(11)),o=(0,bt.default)(new Float32Array(i.shape[0]*3),[i.shape[0],3]),be.muls(o.pick(null,0),a,1/tt.maxIntBits(11)),be.muls(o.pick(null,1),s,1/tt.maxIntBits(10)),be.muls(o.pick(null,2),l,1/tt.maxIntBits(11))}return new Fn(o,t,e)}};var rt=class{constructor(t,e,r,o,i,a=!1){this._quantized=t,this._minMaxMatrix=e,this._chunkSize=r,this._quantizationMethod=o,this._variableChunkSize=i,this._isDynamicChunks=a}get length(){return this._quantized.shape[0]}get nchunks(){return this._minMaxMatrix.shape[0]}get quantized(){return this._quantized}get method(){return this._quantizationMethod}get minmaxMatrix(){return this._minMaxMatrix}_createPrunedMinMax(t){let e=t.length,r=this.minmaxMatrix.shape[0]-e,o=(0,no.default)(new Float32Array(r*2),[r,2]),i=0,a=r,s=0,l=this.minmaxMatrix.shape[0];for(let u=0;u<t.length;u++)l=t[u],a=l-s+i,a>i&&No.assign(o.hi(a,2).lo(i,0),this.minmaxMatrix.hi(l,2).lo(s,0)),i=a,s=l+1;return i<r&&No.assign(o.lo(i,0),this.minmaxMatrix.lo(s,0)),o}_createPrunedQuantized(t){let e=t.length,r=this.quantized.shape[0]-e,o=this._quantizationMethod,i,a;if(o==="norm8x"){a=this._quantized.shape[1];let d=a?r*a:r;i=(0,no.default)(new Uint8Array(d),a?[r,a]:[r,1])}else o==="norm565"?i=(0,no.default)(new Uint16Array(r),[r]):i=(0,no.default)(new Uint32Array(r),[r]);let s=0,l=r,u=0,c=i.shape[0];for(let d=0;d<t.length;d++)c=t[d],l=c-u+s,l>s&&(a?No.assign(i.hi(l,a).lo(s,0),this._quantized.hi(c,a).lo(u,0)):No.assign(i.hi(l).lo(s),this._quantized.hi(c).lo(u))),s=l,u=c+1;return s<r&&(a?No.assign(i.lo(s,0),this._quantized.lo(u,0)):No.assign(i.lo(s),this._quantized.lo(u))),i}pruneFeature(t,e,r){let o=this._createPrunedQuantized(t),i=this._createPrunedMinMax(e);return new rt(o,i,this._chunkSize,this._quantizationMethod,r,!0)}static getRequiredNChunks(t,e){return Math.floor(t/e)}static fromArray(t,e,r){let o=t.shape[0],i=Math.floor(o/r),a=(0,no.default)(new Float32Array(i*2),[i,2],[2,1]),s;e==="norm8x"?s=(0,no.default)(new Uint8Array(t.size),t.shape):e==="norm565"?s=(0,no.default)(new Uint16Array(t.shape[0]),[t.shape[0]]):s=(0,no.default)(new Uint32Array(t.shape[0]),[t.shape[0]]);for(let l=0;l<i;l++){let u=l*r,c=l+1<i?(l+1)*r:o,d;t.shape.length>1?d=Fn.createFromUnnormalized(t.hi(c,t.shape[1]).lo(u,0)):d=Fn.createFromUnnormalized(t.hi(c).lo(u)),a.set(l,0,d.minD),a.set(l,1,d.maxD),s.shape.length>1?No.assign(s.hi(c,s.shape[1]).lo(u,0),tt.fromNormalized(d,e).quantized):No.assign(s.hi(c).lo(u),tt.fromNormalized(d,e).quantized)}return new rt(s,a,r,e)}denormDequant(){let t=this._minMaxMatrix.shape[0],e=this._quantized,r=e.shape[0],o=this._quantizationMethod,i=this._chunkSize,a;if(this._isDynamicChunks){if(!this._variableChunkSize)throw new Error("variable chunk must exists if chunkSize isDynamic");a=this._variableChunkSize}let s;o==="norm8x"?s=(0,no.default)(new Float32Array(e.size),e.shape):s=(0,no.default)(new Float32Array(r*3),[r,3]);let l=0,u=i;for(let c=0;c<t;c++){let[d,p]=[this._minMaxMatrix.get(c,0),this._minMaxMatrix.get(c,1)];this._isDynamicChunks&&(u=a[c]);let f=c+1<t?l+u:r,h;e.shape.length>1?h=new tt(e.hi(f,e.shape[1]).lo(l,0),o):h=new tt(e.hi(f).lo(l),o),No.assign(s.hi(f,s.shape[1]).lo(l,0),h.dequantize(d,p).denormalize()),l=f}return s}static async fetchArrayBuffer(t){return await(await fetch(t,{mode:"cors"})).arrayBuffer()}};var sn=Ht(Ns()),ze=Ht(Ds());var ZS="http://127.0.0.1:8000";var Ci=Ht(Ns()),Ze=Ht(Ds());var JS=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9];function e1(n){return n<1e5?n<100?n<10?0:1:n<1e4?n<1e3?2:3:4:n<1e7?n<1e6?5:6:n<1e9?n<1e8?7:8:9}function t1(n,t){if(n===t)return 0;if(~~n===n&&~~t===t){if(n===0||t===0)return n<t?-1:1;if(n<0||t<0){if(t>=0)return-1;if(n>=0)return 1;n=-n,t=-t}let o=e1(n),i=e1(t),a=0;return o<i?(n*=JS[i-o-1],t/=10,a=-1):o>i&&(t*=JS[o-i-1],n/=10,a=1),n===t?a:n<t?-1:1}let e=String(n),r=String(t);return e===r?0:e<r?-1:1}function xE(n){let t=0;for(;n>=32;)t|=n&1,n>>=1;return n+t}function r1(n,t,e,r){let o=t+1;if(o===e)return 1;if(r(n[o++],n[t])<0){for(;o<e&&r(n[o],n[o-1])<0;)o++;bE(n,t,o)}else for(;o<e&&r(n[o],n[o-1])>=0;)o++;return o-t}function bE(n,t,e){for(e--;t<e;){let r=n[t];n[t++]=n[e],n[e--]=r}}function o1(n,t,e,r,o){for(r===t&&r++;r<e;r++){let i=n[r],a=t,s=r;for(;a<s;){let u=a+s>>>1;o(i,n[u])<0?s=u:a=u+1}let l=r-a;switch(l){case 3:n[a+3]=n[a+2];case 2:n[a+2]=n[a+1];case 1:n[a+1]=n[a];break;default:for(;l>0;)n[a+l]=n[a+l-1],l--}n[a]=i}}function Gh(n,t,e,r,o,i){let a=0,s=0,l=1;if(i(n,t[e+o])>0){for(s=r-o;l<s&&i(n,t[e+o+l])>0;)a=l,l=(l<<1)+1,l<=0&&(l=s);l>s&&(l=s),a+=o,l+=o}else{for(s=o+1;l<s&&i(n,t[e+o-l])<=0;)a=l,l=(l<<1)+1,l<=0&&(l=s);l>s&&(l=s);let u=a;a=o-l,l=o-u}for(a++;a<l;){let u=a+(l-a>>>1);i(n,t[e+u])>0?a=u+1:l=u}return l}function Fh(n,t,e,r,o,i){let a=0,s=0,l=1;if(i(n,t[e+o])<0){for(s=o+1;l<s&&i(n,t[e+o-l])<0;)a=l,l=(l<<1)+1,l<=0&&(l=s);l>s&&(l=s);let u=a;a=o-l,l=o-u}else{for(s=r-o;l<s&&i(n,t[e+o+l])>=0;)a=l,l=(l<<1)+1,l<=0&&(l=s);l>s&&(l=s),a+=o,l+=o}for(a++;a<l;){let u=a+(l-a>>>1);i(n,t[e+u])<0?l=u:a=u+1}return l}var kh=class{constructor(t,e){Lt(this,"array",null);Lt(this,"compare",null);Lt(this,"minGallop",7);Lt(this,"length",0);Lt(this,"tmpStorageLength",256);Lt(this,"stackLength",0);Lt(this,"runStart",null);Lt(this,"runLength",null);Lt(this,"stackSize",0);this.array=t,this.compare=e,this.length=t.length,this.length<2*256&&(this.tmpStorageLength=this.length>>>1),this.tmp=new Array(this.tmpStorageLength),this.stackLength=this.length<120?5:this.length<1542?10:this.length<119151?19:40,this.runStart=new Array(this.stackLength),this.runLength=new Array(this.stackLength)}pushRun(t,e){this.runStart[this.stackSize]=t,this.runLength[this.stackSize]=e,this.stackSize+=1}mergeRuns(){for(;this.stackSize>1;){let t=this.stackSize-2;if(t>=1&&this.runLength[t-1]<=this.runLength[t]+this.runLength[t+1]||t>=2&&this.runLength[t-2]<=this.runLength[t]+this.runLength[t-1])this.runLength[t-1]<this.runLength[t+1]&&t--;else if(this.runLength[t]>this.runLength[t+1])break;this.mergeAt(t)}}forceMergeRuns(){for(;this.stackSize>1;){let t=this.stackSize-2;t>0&&this.runLength[t-1]<this.runLength[t+1]&&t--,this.mergeAt(t)}}mergeAt(t){let e=this.compare,r=this.array,o=this.runStart[t],i=this.runLength[t],a=this.runStart[t+1],s=this.runLength[t+1];this.runLength[t]=i+s,t===this.stackSize-3&&(this.runStart[t+1]=this.runStart[t+2],this.runLength[t+1]=this.runLength[t+2]),this.stackSize--;let l=Fh(r[a],r,o,i,0,e);o+=l,i-=l,i!==0&&(s=Gh(r[o+i-1],r,a,s,s-1,e),s!==0&&(i<=s?this.mergeLow(o,i,a,s):this.mergeHigh(o,i,a,s)))}mergeLow(t,e,r,o){let i=this.compare,a=this.array,s=this.tmp,l=0;for(l=0;l<e;l++)s[l]=a[t+l];let u=0,c=r,d=t;if(a[d++]=a[c++],--o===0){for(l=0;l<e;l++)a[d+l]=s[u+l];return}if(e===1){for(l=0;l<o;l++)a[d+l]=a[c+l];a[d+o]=s[u];return}let p=this.minGallop;for(;;){let f=0,h=0,m=!1;do if(i(a[c],s[u])<0){if(a[d++]=a[c++],h++,f=0,--o===0){m=!0;break}}else if(a[d++]=s[u++],f++,h=0,--e===1){m=!0;break}while((f|h)<p);if(m)break;do{if(f=Fh(a[c],s,u,e,0,i),f!==0){for(l=0;l<f;l++)a[d+l]=s[u+l];if(d+=f,u+=f,e-=f,e<=1){m=!0;break}}if(a[d++]=a[c++],--o===0){m=!0;break}if(h=Gh(s[u],a,c,o,0,i),h!==0){for(l=0;l<h;l++)a[d+l]=a[c+l];if(d+=h,c+=h,o-=h,o===0){m=!0;break}}if(a[d++]=s[u++],--e===1){m=!0;break}p--}while(f>=7||h>=7);if(m)break;p<0&&(p=0),p+=2}if(this.minGallop=p,p<1&&(this.minGallop=1),e===1){for(l=0;l<o;l++)a[d+l]=a[c+l];a[d+o]=s[u]}else{if(e===0)throw new Error("mergeLow preconditions were not respected");for(l=0;l<e;l++)a[d+l]=s[u+l]}}mergeHigh(t,e,r,o){let i=this.compare,a=this.array,s=this.tmp,l=0;for(l=0;l<o;l++)s[l]=a[r+l];let u=t+e-1,c=o-1,d=r+o-1,p=0,f=0;if(a[d--]=a[u--],--e===0){for(p=d-(o-1),l=0;l<o;l++)a[p+l]=s[l];return}if(o===1){for(d-=e,u-=e,f=d+1,p=u+1,l=e-1;l>=0;l--)a[f+l]=a[p+l];a[d]=s[c];return}let h=this.minGallop;for(;;){let m=0,y=0,g=!1;do if(i(s[c],a[u])<0){if(a[d--]=a[u--],m++,y=0,--e===0){g=!0;break}}else if(a[d--]=s[c--],y++,m=0,--o===1){g=!0;break}while((m|y)<h);if(g)break;do{if(m=e-Fh(s[c],a,t,e,e-1,i),m!==0){for(d-=m,u-=m,e-=m,f=d+1,p=u+1,l=m-1;l>=0;l--)a[f+l]=a[p+l];if(e===0){g=!0;break}}if(a[d--]=s[c--],--o===1){g=!0;break}if(y=o-Gh(a[u],s,0,o,o-1,i),y!==0){for(d-=y,c-=y,o-=y,f=d+1,p=c+1,l=0;l<y;l++)a[f+l]=s[p+l];if(o<=1){g=!0;break}}if(a[d--]=a[u--],--e===0){g=!0;break}h--}while(m>=7||y>=7);if(g)break;h<0&&(h=0),h+=2}if(this.minGallop=h,h<1&&(this.minGallop=1),o===1){for(d-=e,u-=e,f=d+1,p=u+1,l=e-1;l>=0;l--)a[f+l]=a[p+l];a[d]=s[c]}else{if(o===0)throw new Error("mergeHigh preconditions were not respected");for(p=d-(o-1),l=0;l<o;l++)a[p+l]=s[l]}}};function n1(n,t,e,r){if(!Array.isArray(n))throw new TypeError("Can only sort arrays");t?typeof t!="function"&&(r=e,e=t,t=t1):t=t1,e||(e=0),r||(r=n.length);let o=r-e;if(o<2)return;let i=0;if(o<32){i=r1(n,e,r,t),o1(n,e,r,e+i,t);return}let a=new kh(n,t),s=xE(o);do{if(i=r1(n,e,r,t),i<s){let l=o;l>s&&(l=s),o1(n,e,e+l,e+i,t),i=l}a.pushRun(e,i),a.mergeRuns(),o-=i,e+=i}while(o!==0);a.forceMergeRuns()}function jh(n){let t=(0,Ci.default)(new Int32Array(n.shape[0]),[n.shape[0]]),e=(0,Ci.default)(new Int32Array(n.shape[0]),[n.shape[0]]);return Ze.bands(t,n,1023),Ze.lshifts(e,t,16),Ze.bxoreq(t,e),Ze.bandseq(t,4278190335),Ze.lshifts(e,t,8),Ze.bxoreq(t,e),Ze.bandseq(t,50393103),Ze.lshifts(e,t,4),Ze.bxoreq(t,e),Ze.bandseq(t,51130563),Ze.lshifts(e,t,2),Ze.bxoreq(t,e),Ze.bandseq(t,153391689),t}function vE(n){let t=jh(n.pick(null,0)),e=jh(n.pick(null,1));Ze.lshiftseq(e,1);let r=jh(n.pick(null,2));return Ze.lshiftseq(r,2),Ze.boreq(t,e),Ze.boreq(t,r),t}function kn(n,t){if(n.shape[0]!==t.shape[0])throw new Error("wrong length");let e=(0,Ci.default)(new Float32Array(n.size),n.shape,n.stride,n.offset);for(let r=0;r<t.shape[0];r++){let o=t.get(r);if(n.shape.length>1)for(let i=0;i<n.shape[1];i++)e.set(r,i,n.get(o,i));else e.set(r,n.get(o))}return e}function Uh(n){let t=Ze.sup(n),e=Ze.inf(n),r=1e3/Math.min(1e3,t-e),o=(0,Ci.default)(new Float32Array(n.data),n.shape);Ze.mulseq(o,r);let i=(0,Ci.default)(new Int32Array(o.data),n.shape),a=vE(i),l=Array.from(a.data).map((d,p)=>[d,p]);n1(l,(d,p)=>d[0]-p[0]);let u=l.map(([d,p])=>p);return(0,Ci.default)(Uint32Array.from(u))}var Fr=class{constructor(t,e,r,o,i,a,s,l,u,c){this.propertyDescs=t,this.format=e,this.nsplats=r,this.xyz=o,this.colors=i,this.harmonics=a,this.opacity=s,this.scaling=l,this.rotation=u,this.maxSHDegree=c}getPlyBinary(){let t=Fr._generateHeaderString(this.propertyDescs,this.format,this.nsplats),e=new TextEncoder().encode(t),r=Object.keys(this.propertyDescs).length,o=(0,sn.default)(new Float32Array(this.nsplats*r),[this.nsplats,r]);if(ze.assign(o.pick(null,this.propertyDescs.x.index),this.xyz.pick(null,0)),ze.assign(o.pick(null,this.propertyDescs.y.index),this.xyz.pick(null,1)),ze.assign(o.pick(null,this.propertyDescs.z.index),this.xyz.pick(null,2)),ze.assign(o.pick(null,this.propertyDescs.f_dc_0.index),this.colors.pick(null,0)),ze.assign(o.pick(null,this.propertyDescs.f_dc_1.index),this.colors.pick(null,1)),ze.assign(o.pick(null,this.propertyDescs.f_dc_2.index),this.colors.pick(null,2)),ze.assign(o.pick(null,this.propertyDescs.opacity.index),this.opacity.pick(null,0)),ze.assign(o.pick(null,this.propertyDescs.scale_0.index),this.scaling.pick(null,0)),ze.assign(o.pick(null,this.propertyDescs.scale_1.index),this.scaling.pick(null,1)),ze.assign(o.pick(null,this.propertyDescs.scale_2.index),this.scaling.pick(null,2)),ze.assign(o.pick(null,this.propertyDescs.rot_0.index),this.rotation.pick(null,0)),ze.assign(o.pick(null,this.propertyDescs.rot_1.index),this.rotation.pick(null,1)),ze.assign(o.pick(null,this.propertyDescs.rot_2.index),this.rotation.pick(null,2)),ze.assign(o.pick(null,this.propertyDescs.rot_3.index),this.rotation.pick(null,3)),this.harmonics&&this.harmonics.length>0)for(let s=0;s<this.harmonics.length;s++){let l=s*3;ze.assign(o.pick(null,this.propertyDescs[`f_rest_${l}`].index),this.harmonics[s].pick(null,0)),ze.assign(o.pick(null,this.propertyDescs[`f_rest_${l+1}`].index),this.harmonics[s].pick(null,1)),ze.assign(o.pick(null,this.propertyDescs[`f_rest_${l+2}`].index),this.harmonics[s].pick(null,2))}let i=new Uint8Array(o.data.buffer),a=new Uint8Array(i.length+e.length);return a.set(e),a.set(i,e.length),a.buffer}save(t,e){let r=this.getPlyBinary(),o=new Blob([r],{type:"application/octet-stream"}),i=new File([o],t),a=new FormData;a.append("file",i),a.append("filename",t),a.append("basedir",e),fetch(`${ZS}/push_file`,{method:"POST",body:a})}static async loadFile(t){return await(await fetch(t)).arrayBuffer()}mortonPositionSplatsSort(){let t=Uh(this.xyz),e=kn(this.xyz,t),r=kn(this.colors,t),o=kn(this.opacity,t),i=kn(this.scaling,t),a=kn(this.rotation,t),s=[];for(let l=0;l<this.harmonics.length;l++)s.push(kn(this.harmonics[l],t));return new Fr(this.propertyDescs,this.format,this.nsplats,e,r,s,o,i,a,this.maxSHDegree)}static _generateHeaderString(t,e,r){let o=`ply
3489
+ `;var Vh=10,wd=class extends ED{constructor(e,r){super();this.type="ParticleEmitter";this.debugMode=!1;this.worldSpace=!0;this.rootObject=null;this.gpuCompute=null;this.positionSimRT=null;this.velocitySimRT=null;this.emissionRateSimRT=null;this.emitterShape=void 0;this.isEmitting=!1;this.hasBeenReset=!1;this.emittedParticlesAmount=0;this.lastEmitTime=0;this.globalTime=0;this.targetFPS=60;this.previousRatio=1;this.lerpFactor=.4;this.particlesAmount=0;this.noiseStrength=0;this.noiseScale=0;this.isBillboardBased=!0;this.simFeaturesDefinition={USE_COLLIDER:!1,USE_ATTRACTOR:!1,USE_VORTEX:!1,USE_SPHERE_COLLIDER:!1,USE_BOX_COLLIDER:!1,USE_FORCE_LOCAL_SPACE:!1,USE_NORMALS:!1,USE_CURL_NOISE:!0,USE_SIMPLEX_NOISE:!1,USE_FBM_NOISE:!1};this.textureLoader=new VD;this.currentWorldPosition=new Gr;this.systemQuaternion=new TS;this.worldGravity=new Gr(0,0,0);this.directionAxis=new Gr(0,0,0);this.colliderV3=new Gr(0,0,0);this.colliderQuaternion=new TS(0,0,0,1);this.matrixAutoUpdate=!0,this.renderer=e,this.system=r,this.shared=r.context.shared;let o=r.data;this.material=new Sd(o.renderMaterial,r.context),this.material.uniforms={uSize:{value:0},uSizeEnd:{value:0},uColor:{value:o.renderMaterial.color},uColor2:{value:o.renderMaterial.color2},uPosition:{value:new Gr(0,0,0)},uEmissionData:{value:new Gr(0,0,0)},uTexture:{value:this.defaultTexture},uWorldOffset:{value:new Gr(0,0,0)},uWorldQuaternion:{value:new Fl(0,0,0,1)},uRandScaleFactor:{value:o.randomScale??0},uRandRotationFactor:{value:o.randomRotation??0},uRotation:{value:o.renderMaterial.spriteRotation[0]??0},uRotationEnd:{value:o.renderMaterial.spriteRotation[1]??0}},this.setTexture(this.material.uniforms,o.renderMaterial.texture),this.init(o)}setTexture(e,r){let o=r.data;if(typeof r=="string"){let i=this.shared.image(r),a=new MS(i.img);a.needsUpdate=!0,e.uTexture.value=a;return}if(typeof o!="string"){let i=new Image;i.onload=()=>{let l=new MS(i);l.needsUpdate=!0,e.uTexture.value=l};let a=new Blob([o],{type:"image/*"}),s=URL.createObjectURL(a);i.src=s}}updateGeometryAttributes(e,r){let o=cS(r);!this.emitterShape?.positionsAttribute||e.geometry.setAttribute("ref",new LD(o,2))}applyWorldSpace(){if(!this.system.started||!this.worldSpace||!this.positionSimRT||!this.velocitySimRT)return;let e=this.system;e.getWorldQuaternion(this.systemQuaternion),this.systemQuaternion.invert(),e.getWorldPosition(this.currentWorldPosition),this.material.uniforms.uWorldOffset.value=this.currentWorldPosition,this.material.uniforms.uWorldQuaternion.value.copy(this.systemQuaternion.normalize()),this.positionSimRT.material.uniforms.uWorldOffset.value=this.currentWorldPosition,this.systemQuaternion.invert(),this.positionSimRT.material.uniforms.uWorldQuaternion.value.copy(this.systemQuaternion.normalize()),this.velocitySimRT.material.uniforms.uWorldQuaternion.value.copy(this.systemQuaternion.normalize())}update(e,r){if(!this.gpuCompute||!this.positionSimRT||!this.velocitySimRT||!this.emissionRateSimRT||this.hasBeenReset)return;if(this.checkIfAllParticlesAreDead()&&!this.hasBeenReset){this.reset();return}this.applyWorldSpace(),this.globalTime=e,this.positionSimRT.material.uniforms.uTime.value=e,this.emissionRateSimRT.material.uniforms.uTime.value=e;let o=1e3/r,i=this.targetFPS/o,a=this.previousRatio+(i-this.previousRatio)*this.lerpFactor;this.positionSimRT.material.uniforms.uFPSRatio.value=a,this.previousRatio=a;let s=this.isEmitting?this.GoEmitSomeParticles(e,this.system.data.birthRatePerSec):0;this.emissionRateSimRT.material.uniforms.uLastIndexEmitted.value=this.emittedParticlesAmount,this.emissionRateSimRT.material.uniforms.uParticlesToEmit.value=s,this.material.uniforms.uPosition.value=this.gpuCompute.getCurrentRenderTarget(this.positionSimRT)?.texture,this.system.colliderEntities.length>0&&this.renderColliders(),this.gpuCompute.compute()}renderColliders(){if(!this.velocitySimRT)return;let e=this.system.colliderEntities[0];if(!e)return;e.getWorldPosition(this.colliderV3),this.colliderV3.y===0&&(this.colliderV3.y=1e-4),this.velocitySimRT.material.uniforms.uColliderPos.value.copy(this.colliderV3);let r=e.data.size;this.colliderV3.fromArray(r),this.velocitySimRT.material.uniforms.uColliderSize.value.copy(this.simFeaturesDefinition.USE_SPHERE_COLLIDER?this.colliderV3.multiplyScalar(.5):this.colliderV3),e.getWorldQuaternion(this.colliderQuaternion),this.velocitySimRT.material.uniforms.uColliderQuaternion.value.copy(this.colliderQuaternion.normalize()),this.velocitySimRT.material.uniforms.uColliderQuaternionInvert.value.copy(this.colliderQuaternion.normalize().invert())}updateState(e){!this.velocitySimRT||!this.positionSimRT||(e.renderMaterial&&this.updateMaterialState(e.renderMaterial),this.updateParticleState(e))}updateVariableState(e,r){if(!this.velocitySimRT||!this.positionSimRT)return;r[2]==="size"&&this.material.updateState({size:[e,this.material.uniforms.uSizeEnd.value]}),r[2]==="sizeEnd"&&this.material.updateState({size:[this.material.uniforms.uSize.value,e]});let o=(i,a)=>{let s=[...this.system.data.shape.size];s[i]=a,this.updateParticleState({shape:{...this.system.data.shape,size:s}})};r[2]==="shape_size_0"&&o(0,e),r[2]==="shape_size_1"&&o(1,e),r[2]==="shape_size_2"&&o(2,e),r[2]==="speed"&&(this.velocitySimRT.material.uniforms.uSpeed.value=e/Vh),r[2]==="gravity"&&this.worldGravity.set(0,e/100,0),r[2]==="noiseStrength"&&(this.noiseStrength=e,this.velocitySimRT.material.uniforms.uNoiseStrength.value=this.noiseStrength),r[2]==="noiseScale"&&(this.noiseScale=e,this.velocitySimRT.material.uniforms.uNoiseScale.value=this.noiseScale),r[2]==="direction_x"&&(this.directionAxis=this.getDirectionAxis([Number(e),this.system.data.direction[1],this.system.data.direction[2]])),r[2]==="direction_y"&&(this.directionAxis=this.getDirectionAxis([this.system.data.direction[0],Number(e),this.system.data.direction[2]])),r[2]==="direction_z"&&(this.directionAxis=this.getDirectionAxis([this.system.data.direction[0],this.system.data.direction[1],Number(e)]))}updateMaterialState(e){this.material.updateState({...e,size:e.size?[Number(this.shared.getVariable(e.size[0],[this.uuid,"particles","size"])),Number(this.shared.getVariable(e.size[1],[this.uuid,"particles","sizeEnd"]))]:[0,0]}),e.texture&&(this.setTexture(this.material.uniforms,e.texture),this.material.needsUpdate=!0)}updateParticleState(e){if(!(!this.positionSimRT||!this.velocitySimRT)){if(this.shouldReInitGPUCompute(e)&&this.init(Oi(this.system.data)),e.life!==void 0&&(this.positionSimRT.material.uniforms.uMaxLifeTime.value=e.life),e.speed!==void 0&&(this.velocitySimRT.material.uniforms.uSpeed.value=Number(this.shared.getVariable(e.speed,[this.uuid,"particles","speed"]))/Vh),e.collisionBounce!==void 0&&(this.velocitySimRT.material.uniforms.uBounce.value=e.collisionBounce),e.noiseStrength!==void 0&&(this.noiseStrength=Number(this.shared.getVariable(e.noiseStrength,[this.uuid,"particles","noiseStrength"])),this.velocitySimRT.material.uniforms.uNoiseStrength.value=this.noiseStrength),e.noiseScale!==void 0&&(this.noiseScale=Number(this.shared.getVariable(e.noiseScale,[this.uuid,"particles","noiseScale"])),this.velocitySimRT.material.uniforms.uNoiseScale.value=this.noiseScale),e.noiseSeed!==void 0&&(this.velocitySimRT.material.uniforms.uNoiseSeed.value=e.noiseSeed),e.randomMass!==void 0&&(this.velocitySimRT.material.uniforms.uRandomMassFactor.value=e.randomMass),e.renderMaterial?.size!==void 0){let r=this.shared.getVariable(e.renderMaterial.size[0],[this.uuid,"particles","size"]);this.velocitySimRT.material.uniforms.particleSize.value=Number(r)}if(e.renderMaterial?.spriteRotation!==void 0&&(this.material.uniforms.uRotation.value=e.renderMaterial.spriteRotation[0],this.material.uniforms.uRotationEnd.value=e.renderMaterial.spriteRotation[1]),e.shape!==void 0){let r=e.shape.size??this.system.data.shape.size,o=[Number(this.shared.getVariable(r[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(r[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(r[2],[this.uuid,"particles","shape_size_2"]))],i={...Oi(this.system.data).shape,size:o};this.emitterShape?.applyToShader(this.positionSimRT.material.uniforms,i)}if(e.gravity!==void 0&&(this.worldGravity.set(0,Number(this.shared.getVariable(this.system.data.gravity,[this.uuid,"particles","gravity"]))/100,0),this.velocitySimRT.material.uniforms.uGravity={value:this.worldGravity}),e.direction!==void 0){let r=this.getDirectionFromVariable(e.direction);this.directionAxis=this.getDirectionAxis(r),this.velocitySimRT.material.uniforms.uDirectionsAxis.value=this.directionAxis}e.randomRotation!==void 0&&(this.material.uniforms.uRandRotationFactor.value=e.randomRotation),e.randomScale!==void 0&&(this.material.uniforms.uRandScaleFactor.value=e.randomScale)}}updateForceFieldParameters(e){!this.velocitySimRT||(e.forceIntensity!==void 0&&(this.velocitySimRT.material.uniforms.uForceIntensity.value=e.forceIntensity),e.forceDambing!==void 0&&(this.velocitySimRT.material.uniforms.uForceDamping.value=e.forceDambing))}getDirectionAxis(e){let r=[Number(e[0])*Rh.DEG2RAD,Number(e[1])*Rh.DEG2RAD,Number(e[2])*Rh.DEG2RAD],o=new zD(r[0],r[1],r[2],"XYZ");return this.directionAxis.set(0,1,0).applyEuler(o).normalize(),this.velocitySimRT&&(this.velocitySimRT.material.uniforms.uDirectionsAxis.value=this.directionAxis),this.directionAxis}shouldReInitGPUCompute(e){let{birthRatePerSec:r,rootObjectType:o,colliderEntityId:i,shape:a,emitTimeDuration:s,emitTimeCycle:l,life:u,directionMode:c,noiseType:d}=e;return r!==void 0||o!==void 0||(i||i===null)||l!==void 0||a!==void 0||u!==void 0||s!==void 0||c!==void 0||d!==void 0}init(e){this.dispose(),this.particlesAmount=this.getMaxParticlesAmount({birthRatePerSecond:e.birthRatePerSec,particleMaxLifeTime:e.life,loopDuration:e.emitTimeCycle==="infinity"?0:e.emitTimeDuration}),this.particlesAmount>1e5&&(console.warn(`The maximum number of particles is limited to ${1e5}.`),this.particlesAmount=1e5),this.emitterShape=this.createShape(e.shape,this.particlesAmount);let r=setInterval(()=>{if(!!this.emitterShape)if(isNaN(this.emitterShape.positionsTexture.source.data.data[0])){this.init(e);return}else clearInterval(r)},100);if(!this.emitterShape)return;let o=new GD(this.emitterShape.textureSize,this.emitterShape.textureSize,this.renderer),i=this.updateSimulationDefinition(e),a=o.addVariable("uCurrentPosition",i+hS,this.emitterShape.positionsTexture),s=o.addVariable("uCurrentVelocity",i+bS,this.emitterShape.directionsTexture),l=o.addVariable("uCurrentEmissionRate",OS,fS(this.emitterShape.textureSize));o.setVariableDependencies(a,[a,s,l]),o.setVariableDependencies(s,[a,s,l]),o.setVariableDependencies(l,[a,s,l]);let u=pS({size:this.emitterShape.textureSize}),c={uOriginalPosition:{value:this.emitterShape.positionsTexture},uWorldOffset:{value:new Gr(0,0,0)},uWorldQuaternion:{value:new Fl(0,0,0,1)},uTime:{value:0},uFPSRatio:{value:1},uMaxLifeTime:{value:e.life},uEmitterSize:{value:new Gr(Number(this.shared.getVariable(e.shape.size[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(e.shape.size[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(e.shape.size[2],[this.uuid,"particles","shape_size_2"])))},particleSize:{value:0}};a.material.uniforms=c;let d=this.getDirectionFromVariable(e.direction);this.directionAxis=this.getDirectionAxis(d),this.worldGravity.set(0,Number(this.shared.getVariable(this.system.data.gravity,[this.uuid,"particles","gravity"]))/100,0),this.noiseStrength=Number(this.shared.getVariable(e.noiseStrength,[this.uuid,"particles","noiseStrength"])),this.noiseScale=Number(this.shared.getVariable(e.noiseScale,[this.uuid,"particles","noiseScale"]));let p=e.colliderEntityId&&this.system.getColliderData(e.colliderEntityId),f={uOriginalPosition:{value:this.emitterShape.positionsTexture},uDirections:{value:this.emitterShape.directionsTexture},uDirectionsAxis:{value:this.directionAxis},uWorldQuaternion:{value:new Fl(0,0,0,1)},uColliderPos:{value:new Gr(0,0,0)},uColliderSize:{value:new Gr(0,0,0)},uForceIntensity:{value:p?p.forceIntensity:0},uForceDamping:{value:p?p.forceDambing:0},uColliderQuaternion:{value:new Fl(0,0,0,1)},uColliderQuaternionInvert:{value:new Fl(0,0,0,1)},particleSize:{value:0},uGravity:{value:this.worldGravity},uNoiseStrength:{value:this.noiseStrength},uNoiseScale:{value:this.noiseScale},uNoiseSeed:{value:e.noiseSeed},uRandomMassFactor:{value:e.randomMass},uBounce:{value:e.collisionBounce},uSpeed:{value:Number(this.shared.getVariable(e.speed,[this.uuid,"particles","speed"]))/Vh}};s.material.uniforms=f;let h={uIndex:{value:u},uTime:{value:0},uLastIndexEmitted:{value:0},uParticlesToEmit:{value:0}};l.material.uniforms=h;let m=[Number(this.shared.getVariable(e.shape.size[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(e.shape.size[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(e.shape.size[2],[this.uuid,"particles","shape_size_2"]))],y={...Oi(this.system.data).shape,size:m};this.emitterShape.applyToShader(a.material.uniforms,y),o.init(),this.gpuCompute=o,this.positionSimRT=a,this.velocitySimRT=s,this.emissionRateSimRT=l,this.rootObject=this.createPrimaryEmitter(this.emitterShape.textureSize),this.add(this.rootObject),this.material.needsUpdate=!0}getDirectionFromVariable(e){let r=Number(this.shared.getVariable(e[0],[this.uuid,"particles","direction_x"])),o=Number(this.shared.getVariable(e[1],[this.uuid,"particles","direction_y"])),i=Number(this.shared.getVariable(e[2],[this.uuid,"particles","direction_z"]));return[r,o,i]}updateSimulationDefinition(e){if(this.simFeaturesDefinition.USE_COLLIDER=!1,this.simFeaturesDefinition.USE_ATTRACTOR=!1,this.simFeaturesDefinition.USE_VORTEX=!1,this.simFeaturesDefinition.USE_SPHERE_COLLIDER=!1,this.simFeaturesDefinition.USE_BOX_COLLIDER=!1,this.simFeaturesDefinition.USE_FORCE_LOCAL_SPACE=!1,this.simFeaturesDefinition.USE_NORMALS=!1,this.simFeaturesDefinition.USE_CURL_NOISE=!1,this.simFeaturesDefinition.USE_SIMPLEX_NOISE=!1,this.simFeaturesDefinition.USE_FBM_NOISE=!1,e.colliderEntityId&&this.system.colliderEntities.length>0){let o=this.system.getColliderData(e.colliderEntityId);switch(o?.forceType){case"attractor":this.simFeaturesDefinition.USE_ATTRACTOR=!0;break;case"collider":this.simFeaturesDefinition.USE_COLLIDER=!0;break;case"vortex":this.simFeaturesDefinition.USE_VORTEX=!0;break}let i=o?.colliderType;i==="sphere"&&(this.simFeaturesDefinition.USE_SPHERE_COLLIDER=!0),i==="box"&&(this.simFeaturesDefinition.USE_BOX_COLLIDER=!0),o?.forceRange==="helper"&&(this.simFeaturesDefinition.USE_FORCE_LOCAL_SPACE=!0)}e.directionMode==="normals"&&(this.simFeaturesDefinition.USE_NORMALS=!0),e.noiseType==="curl"&&(this.simFeaturesDefinition.USE_CURL_NOISE=!0),e.noiseType==="simplex"&&(this.simFeaturesDefinition.USE_SIMPLEX_NOISE=!0),e.noiseType==="fbm"&&(this.simFeaturesDefinition.USE_FBM_NOISE=!0);let r="";for(let[o,i]of Object.entries(this.simFeaturesDefinition))i&&(r+=`#define ${o}
3490
+ `);return r}createShape(e,r){this.emitterShape&&this.emitterShape.dispose();let o=new Gr(Number(this.shared.getVariable(e.size[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(e.size[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(e.size[2],[this.uuid,"particles","shape_size_2"])));if(e.type==="MeshEmitterShape"){let i=null;return this.system.context.scene.traverseEntity(a=>{a.uuid===e.fromMeshId&&(i=a)}),i?new Ns(o,r,e.type,i):new Ns(o,r,"SphereEmitterShape")}else return new Ns(o,r,e.type)}createPrimaryEmitter(e){let r,o=e*e;return r=new BD(new RD(1,1,1),this.material,o),this.updateGeometryAttributes(r,e),this.material.needsUpdate=!0,r.onBeforeRender=()=>{this.applyWorldSpace()},r}getMaxParticlesAmount({birthRatePerSecond:e,particleMaxLifeTime:r,loopDuration:o=0}){return Math.ceil(e*(r+o))}dispose(){!this.gpuCompute||(this.rootObject?.parent?.remove(this.rootObject),this.gpuCompute.dispose(),this.material.nodeMaterialDispose(),this.emitterShape?.dispose())}GoEmitSomeParticles(e,r){let o=e-this.lastEmitTime,i=1/r;if(o>=i){let a=Math.max(1,Math.floor(o/i));return this.lastEmitTime=e,this.emittedParticlesAmount+a>this.particlesAmount&&(this.emittedParticlesAmount=0),this.emittedParticlesAmount+=a,a}return 0}checkIfAllParticlesAreDead(){return this.lastEmitTime+this.system.data.life+1<this.globalTime}reset(){this.hasBeenReset=!0,this.lastEmitTime=0,this.emittedParticlesAmount=0,this.gpuCompute&&this.init(Oi(this.system.data))}startEmitting(e){this.isEmitting=!0,this.hasBeenReset=!1,this.lastEmitTime=e}stopEmitting(){this.isEmitting=!1}};import{BufferGeometry as FD,Float32BufferAttribute as kD,MeshBasicMaterial as jD}from"three";var Ad=class extends Dt{constructor(e,r,o){super(e,r);this.type="ParticleSystem";this.geometry=new FD;this.actualTime=0;this.currentLoopTime=0;this.started=!1;this.stopped=!1;this.isFrozen=!1;this.isIdle=!0;this.emitter=null;this.colliderEntities=[];this.renderer=null;this.isPreWarm=!1;this._hasOnAfterRenderBeenCalled=!1;this.onAfterRender=e=>{this._hasOnAfterRenderBeenCalled||(this._hasOnAfterRenderBeenCalled=!0,this.init(e))};this.context=o,this.data={...r,...Oi(r)},this.geometry.setAttribute("position",new kD([],3)),this.material=new jD({colorWrite:!1}),this.frustumCulled=!1}init(e){this.renderer=e,this.emitter=new wd(e,this),this.add(this.emitter),this.updateParticleState(this.data)}update(e){if(!this.isReady||!this.started||this.isFrozen||this.isIdle)return;this.actualTime+=e,this.stopped||(this.currentLoopTime+=e);let r=this.data.emitTimeCycle==="one_time";if((this.data.emitTimeCycle==="loop"||r)&&this.currentLoopTime>this.data.emitTimeDuration*1e3&&(this.stopped||(this.stop(),r||this.start(this.data.emitTimeLoopDelayStart==="start"?0:this.data.emitTimeDelay*1e3))),this.emitter&&this.started){let i=this.actualTime/1e3;this.emitter.update(i,e)}this.scale.set(1,1,1),this.updateMatrix()}isReady(){return!!this.emitter}hasCollider(e){return this.colliderEntities.some(r=>r.identity===e)}getColliderData(e){let r=this.colliderEntities.find(o=>o.identity===e);return r?r.data:null}updateByPatchedOp(e,r,o){super.updateByPatchedOp(e,r,o),Le(e.path,["renderMaterial"])&&this.updateParticleState({renderMaterial:{...this.data.renderMaterial,...ct.drop(e,1).props}}),Le(e.path,["shape"])&&this.updateParticleState({shape:{...this.data.shape,...ct.drop(e,1).props}})}updateState(e,r){super.updateState(e,r),this.updateParticleState(e)}updateParticleState(e){if(!!this.emitter){if(e.colliderEntityId!==void 0&&e.colliderEntityId!==null){let r=this.context.scene.find(e.colliderEntityId);this.colliderEntities=r?[r]:[]}e.colliderEntityId===null&&(this.colliderEntities=[]),this.emitter.updateState(e),e.emitTimeCycle&&this.started&&this.start()}}updateFromColliderEntity(e){!this.emitter||(this.emitter.updateForceFieldParameters(e),this.stop(),this.start())}start(e=0){if(this.currentLoopTime=0,e){setTimeout(()=>{this.start(0)},e);return}this.started=!0,this.stopped=!1,this.isFrozen=!1,this.emitter?.startEmitting(this.actualTime/1e3)}froze(){this.isFrozen=!0}unFroze(){this.isFrozen=!1}stop(){this.stopped=!0,this.currentLoopTime=0,this.emitter?.stopEmitting()}reset(){this.started=!1,this.stopped=!1,this.emitter?.reset()}wakeUp(){this.isIdle=!1}sleep(){this.isIdle=!0,this.reset()}};function UD(n,t,e){let r;return t.geometry.type==="TextGeometry"?new xs(n,t,e):(t.geometry.type==="SubdivGeometry"?r=new bi(n,t,e):t.geometry.type==="PathGeometry"?r=new Is(n,t,e):t.geometry.type==="VectorGeometry"?r=new xd(n,t,e):t.geometry.type==="BooleanGeometry"?r=new yr(n,t,e):t.geometry.type==="UIGeometry"?r=new Pi(n,t,e):r=new ft(n,t,e),r)}function _d(n,t,e){return console.assert(t.type!==void 0),t.type==="Mesh"?UD(n,t,e):t.type==="Empty"?new Rn(n,t):t.type==="Particle"?new Ad(n,t,e):t.type==="ParticleCollider"?new sd(n,t,e):t.type==="Splat"?new Rn(n,t):t.type==="Bone"?new vd(n,t):t.type==="Page"?new zr(n,t,e):t.type==="PointLight"?new gd(n,t,e):t.type==="SpotLight"?new Cs(n,t,e):t.type==="DirectionalLight"?new Os(n,t,e):t.type==="Component"||t.type==="Instance"?new an(n,t,e):Ur.is(t.type)?new rn(n,t):(console.error(t),new Rn(n,t))}Wr.createEntity=_d;function HD(n,t,e){let r=_d(n.identity,t,e),o=n.children,i=n.attachedPaths,a=n.parent,s=n.component,l=n.instances,u=n.overrideData,c=n.uuid,d=n.stateSelection;n.dispose();for(let p of Object.keys(n))delete n[p];Object.setPrototypeOf(n,Object.getPrototypeOf(r));for(let p of Object.keys(r))n[p]=r[p];n.children=[...n.children,...o],n.attachedPaths=i,n.parent=a,n.component=s,n.instances=l,n.uuid=c,n.overrideData=u,n.updateState(n.data,e),d&&n.changeSelectedState(d,e),n.resetBBoxNeedsUpdate()}Wr.changeEntityProptotype=HD;Wr.Cloner=vs;function IS(n,t,e,r){n.updateByOp(t,e,r,!1)}import{Matrix4 as $D,Ray as YD,Raycaster as XD}from"three";function NS(n,t){let e=!1,r=t.getLayersOfType("transmission"),o=t.getLayersOfType("outline");return o.length>0&&(n.layers.set(8),r.length>0&&n.layers.enable(3),e=!0,ys(n),ms(n)),r.length===0&&o.length===0&&n.layers.set(0),n instanceof mr&&n.needsAO&&n.layers.enable(5),e}function DS(n,t){if(!t.layers)return!1;let e=!1,r=t.getLayersOfType("transmission").filter(i=>i.data.visible),o=t.getLayersOfType("outline").filter(i=>i.data.visible);return r.length>0&&(n.layers.set(3),o.length>0&&n.layers.enable(8),e=!0),r.length===0&&o.length===0&&n.layers.set(0),n.needsAO&&n.layers.enable(5),e}function ES(n){let t=!1;return n.traverseEntity(e=>{if(e instanceof mr)if(Array.isArray(e.material))for(let r=0;r<e.material.length;r++)NS(e,e.material[r])&&(t=!0);else NS(e,e.material)&&(t=!0)}),t}function BS(n){let t=!1;return n.traverseEntity(e=>{if(e instanceof mr)if(Array.isArray(e.material))for(let r=0;r<e.material.length;r++)DS(e,e.material[r])&&(t=!0);else DS(e,e.material)&&(t=!0)}),t}var QD=new XD,KD=new $D,ZD=new YD;function Gl(n,t,e,r=!1){let o=n.cloner;if(o)for(let i of o.children){let a=KD.copy(i.matrixWorld).invert(),s=ZD.copy(t.ray).applyMatrix4(a),l=n.matrixWorld;s.applyMatrix4(l);let u=QD;u.set(s.origin,s.direction),u.near=t.near,u.far=t.far;let c=u.intersectObject(n,!1);c.length>0&&e.push({...c[0],object:r?i:n})}}var Pd=class{constructor(){this._constraints=new Map}setConstraint(t,e){e===null?this._constraints.delete(t):this._constraints.set(t,e)}removeDependencies(t){this._constraints.delete(t)}applyConstraints(t){let e=new Set;this._constraints.forEach((r,o)=>{let i=[o,r],a=r;for(;this._constraints.has(a);)a=this._constraints.get(a),e.has(a)||i.push(a);for(let s=i.length-2;s>=0;s--)if(!e.has(i[s])){let l=t.find(i[s]);l?l.applyPathSnapping(t):console.warn(`missing entity ${i[s]}`),e.add(i[s])}})}findDependency(t,e){let r=t;for(;this._constraints.has(r);)if(r=this._constraints.get(r),r===e)return!0;return!1}};var no=Ht(Ds()),No=Ht(Es());var bt=Ht(Ds()),be=Ht(Es()),Fn=class{constructor(t,e,r){this._dataNormalized=t,this._minD=e,this._maxD=r}static createFromUnnormalized(t){let e=be.sup(t),r=be.inf(t),o=(0,bt.default)(new Float32Array(t.size),t.shape),i=e-r;return i<1e-4?be.assigns(o,0):(be.subs(o,t,r),be.divs(o,o,i)),new Fn(o,r,e)}get data(){return this._dataNormalized}get minD(){return this._minD}get maxD(){return this._maxD}denormalize(){let t=(0,bt.default)(new Float32Array(this._dataNormalized.size),this._dataNormalized.shape);return be.muls(t,this._dataNormalized,this._maxD-this._minD),be.adds(t,t,this._minD),t}},tt=class{constructor(t,e){this._quantized=t,this._method=e}get quantized(){return this._quantized}static maxIntBits(t){return 2**t-1}static fromNormalized(t,e){let r=t.data,o;if(e==="norm8x"){let i=tt.maxIntBits(8),a=(0,bt.default)(new Float32Array(r.size),r.shape);be.muls(a,r,i),be.roundeq(a),o=(0,bt.default)(new Uint8Array(a.data),r.shape)}else if(e==="norm565"){let i=(0,bt.default)(new Float32Array(r.size),r.shape);be.assign(i,r),be.mulseq(i.pick(null,0),tt.maxIntBits(5)),be.mulseq(i.pick(null,1),tt.maxIntBits(6)),be.mulseq(i.pick(null,2),tt.maxIntBits(5)),be.roundeq(i);let a=(0,bt.default)(new Uint16Array(i.data),r.shape),s=(0,bt.default)(new Uint16Array(r.shape[0]),[r.shape[0]]),l=(0,bt.default)(new Uint16Array(r.shape[0]),[r.shape[0]]);be.lshifts(s,a.pick(null,0),11),be.lshifts(l,a.pick(null,1),5),be.boreq(s,l),be.boreq(s,a.pick(null,2)),o=s}else{let i=(0,bt.default)(new Float32Array(r.size),r.shape);be.assign(i,r),be.mulseq(i.pick(null,0),tt.maxIntBits(11)),be.mulseq(i.pick(null,1),tt.maxIntBits(10)),be.mulseq(i.pick(null,2),tt.maxIntBits(11)),be.roundeq(i);let a=(0,bt.default)(new Uint32Array(i.data),r.shape),s=(0,bt.default)(new Uint32Array(r.shape[0]),[r.shape[0]]),l=(0,bt.default)(new Uint32Array(r.shape[0]),[r.shape[0]]);be.lshifts(s,a.pick(null,0),21),be.lshifts(l,a.pick(null,1),11),be.boreq(s,l),be.boreq(s,a.pick(null,2)),o=s}return new tt(o,e)}dequantize(t,e){let r=this._method,o,i=this._quantized;if(r==="norm8x"){let a=tt.maxIntBits(8);o=(0,bt.default)(new Float32Array(i.size),i.shape),be.muls(o,i,1/a)}else if(r==="norm565"){let a=(0,bt.default)(new Uint8Array(i.shape[0]),[i.shape[0]]),s=(0,bt.default)(new Uint8Array(i.shape[0]),[i.shape[0]]),l=(0,bt.default)(new Uint8Array(i.shape[0]),[i.shape[0]]);be.rrshifts(a,i,11),be.rrshifts(s,i,5),be.bandseq(s,tt.maxIntBits(6)),be.bands(l,i,tt.maxIntBits(5)),o=(0,bt.default)(new Float32Array(i.shape[0]*3),[i.shape[0],3]),be.muls(o.pick(null,0),a,1/tt.maxIntBits(5)),be.muls(o.pick(null,1),s,1/tt.maxIntBits(6)),be.muls(o.pick(null,2),l,1/tt.maxIntBits(5))}else{let a=(0,bt.default)(new Uint16Array(i.shape[0]),[i.shape[0]]),s=(0,bt.default)(new Uint16Array(i.shape[0]),[i.shape[0]]),l=(0,bt.default)(new Uint16Array(i.shape[0]),[i.shape[0]]);be.rrshifts(a,i,21),be.rrshifts(s,i,11),be.bandseq(s,tt.maxIntBits(10)),be.bands(l,i,tt.maxIntBits(11)),o=(0,bt.default)(new Float32Array(i.shape[0]*3),[i.shape[0],3]),be.muls(o.pick(null,0),a,1/tt.maxIntBits(11)),be.muls(o.pick(null,1),s,1/tt.maxIntBits(10)),be.muls(o.pick(null,2),l,1/tt.maxIntBits(11))}return new Fn(o,t,e)}};var rt=class{constructor(t,e,r,o,i,a=!1){this._quantized=t,this._minMaxMatrix=e,this._chunkSize=r,this._quantizationMethod=o,this._variableChunkSize=i,this._isDynamicChunks=a}get length(){return this._quantized.shape[0]}get nchunks(){return this._minMaxMatrix.shape[0]}get quantized(){return this._quantized}get method(){return this._quantizationMethod}get minmaxMatrix(){return this._minMaxMatrix}_createPrunedMinMax(t){let e=t.length,r=this.minmaxMatrix.shape[0]-e,o=(0,no.default)(new Float32Array(r*2),[r,2]),i=0,a=r,s=0,l=this.minmaxMatrix.shape[0];for(let u=0;u<t.length;u++)l=t[u],a=l-s+i,a>i&&No.assign(o.hi(a,2).lo(i,0),this.minmaxMatrix.hi(l,2).lo(s,0)),i=a,s=l+1;return i<r&&No.assign(o.lo(i,0),this.minmaxMatrix.lo(s,0)),o}_createPrunedQuantized(t){let e=t.length,r=this.quantized.shape[0]-e,o=this._quantizationMethod,i,a;if(o==="norm8x"){a=this._quantized.shape[1];let d=a?r*a:r;i=(0,no.default)(new Uint8Array(d),a?[r,a]:[r,1])}else o==="norm565"?i=(0,no.default)(new Uint16Array(r),[r]):i=(0,no.default)(new Uint32Array(r),[r]);let s=0,l=r,u=0,c=i.shape[0];for(let d=0;d<t.length;d++)c=t[d],l=c-u+s,l>s&&(a?No.assign(i.hi(l,a).lo(s,0),this._quantized.hi(c,a).lo(u,0)):No.assign(i.hi(l).lo(s),this._quantized.hi(c).lo(u))),s=l,u=c+1;return s<r&&(a?No.assign(i.lo(s,0),this._quantized.lo(u,0)):No.assign(i.lo(s),this._quantized.lo(u))),i}pruneFeature(t,e,r){let o=this._createPrunedQuantized(t),i=this._createPrunedMinMax(e);return new rt(o,i,this._chunkSize,this._quantizationMethod,r,!0)}static getRequiredNChunks(t,e){return Math.floor(t/e)}static fromArray(t,e,r){let o=t.shape[0],i=Math.floor(o/r),a=(0,no.default)(new Float32Array(i*2),[i,2],[2,1]),s;e==="norm8x"?s=(0,no.default)(new Uint8Array(t.size),t.shape):e==="norm565"?s=(0,no.default)(new Uint16Array(t.shape[0]),[t.shape[0]]):s=(0,no.default)(new Uint32Array(t.shape[0]),[t.shape[0]]);for(let l=0;l<i;l++){let u=l*r,c=l+1<i?(l+1)*r:o,d;t.shape.length>1?d=Fn.createFromUnnormalized(t.hi(c,t.shape[1]).lo(u,0)):d=Fn.createFromUnnormalized(t.hi(c).lo(u)),a.set(l,0,d.minD),a.set(l,1,d.maxD),s.shape.length>1?No.assign(s.hi(c,s.shape[1]).lo(u,0),tt.fromNormalized(d,e).quantized):No.assign(s.hi(c).lo(u),tt.fromNormalized(d,e).quantized)}return new rt(s,a,r,e)}denormDequant(){let t=this._minMaxMatrix.shape[0],e=this._quantized,r=e.shape[0],o=this._quantizationMethod,i=this._chunkSize,a;if(this._isDynamicChunks){if(!this._variableChunkSize)throw new Error("variable chunk must exists if chunkSize isDynamic");a=this._variableChunkSize}let s;o==="norm8x"?s=(0,no.default)(new Float32Array(e.size),e.shape):s=(0,no.default)(new Float32Array(r*3),[r,3]);let l=0,u=i;for(let c=0;c<t;c++){let[d,p]=[this._minMaxMatrix.get(c,0),this._minMaxMatrix.get(c,1)];this._isDynamicChunks&&(u=a[c]);let f=c+1<t?l+u:r,h;e.shape.length>1?h=new tt(e.hi(f,e.shape[1]).lo(l,0),o):h=new tt(e.hi(f).lo(l),o),No.assign(s.hi(f,s.shape[1]).lo(l,0),h.dequantize(d,p).denormalize()),l=f}return s}static async fetchArrayBuffer(t){return await(await fetch(t,{mode:"cors"})).arrayBuffer()}};var sn=Ht(Ds()),ze=Ht(Es());var r1="http://127.0.0.1:8000";var Ci=Ht(Ds()),Ze=Ht(Es());var o1=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9];function n1(n){return n<1e5?n<100?n<10?0:1:n<1e4?n<1e3?2:3:4:n<1e7?n<1e6?5:6:n<1e9?n<1e8?7:8:9}function i1(n,t){if(n===t)return 0;if(~~n===n&&~~t===t){if(n===0||t===0)return n<t?-1:1;if(n<0||t<0){if(t>=0)return-1;if(n>=0)return 1;n=-n,t=-t}let o=n1(n),i=n1(t),a=0;return o<i?(n*=o1[i-o-1],t/=10,a=-1):o>i&&(t*=o1[o-i-1],n/=10,a=1),n===t?a:n<t?-1:1}let e=String(n),r=String(t);return e===r?0:e<r?-1:1}function AE(n){let t=0;for(;n>=32;)t|=n&1,n>>=1;return n+t}function a1(n,t,e,r){let o=t+1;if(o===e)return 1;if(r(n[o++],n[t])<0){for(;o<e&&r(n[o],n[o-1])<0;)o++;_E(n,t,o)}else for(;o<e&&r(n[o],n[o-1])>=0;)o++;return o-t}function _E(n,t,e){for(e--;t<e;){let r=n[t];n[t++]=n[e],n[e--]=r}}function s1(n,t,e,r,o){for(r===t&&r++;r<e;r++){let i=n[r],a=t,s=r;for(;a<s;){let u=a+s>>>1;o(i,n[u])<0?s=u:a=u+1}let l=r-a;switch(l){case 3:n[a+3]=n[a+2];case 2:n[a+2]=n[a+1];case 1:n[a+1]=n[a];break;default:for(;l>0;)n[a+l]=n[a+l-1],l--}n[a]=i}}function Fh(n,t,e,r,o,i){let a=0,s=0,l=1;if(i(n,t[e+o])>0){for(s=r-o;l<s&&i(n,t[e+o+l])>0;)a=l,l=(l<<1)+1,l<=0&&(l=s);l>s&&(l=s),a+=o,l+=o}else{for(s=o+1;l<s&&i(n,t[e+o-l])<=0;)a=l,l=(l<<1)+1,l<=0&&(l=s);l>s&&(l=s);let u=a;a=o-l,l=o-u}for(a++;a<l;){let u=a+(l-a>>>1);i(n,t[e+u])>0?a=u+1:l=u}return l}function kh(n,t,e,r,o,i){let a=0,s=0,l=1;if(i(n,t[e+o])<0){for(s=o+1;l<s&&i(n,t[e+o-l])<0;)a=l,l=(l<<1)+1,l<=0&&(l=s);l>s&&(l=s);let u=a;a=o-l,l=o-u}else{for(s=r-o;l<s&&i(n,t[e+o+l])>=0;)a=l,l=(l<<1)+1,l<=0&&(l=s);l>s&&(l=s),a+=o,l+=o}for(a++;a<l;){let u=a+(l-a>>>1);i(n,t[e+u])<0?l=u:a=u+1}return l}var jh=class{constructor(t,e){Lt(this,"array",null);Lt(this,"compare",null);Lt(this,"minGallop",7);Lt(this,"length",0);Lt(this,"tmpStorageLength",256);Lt(this,"stackLength",0);Lt(this,"runStart",null);Lt(this,"runLength",null);Lt(this,"stackSize",0);this.array=t,this.compare=e,this.length=t.length,this.length<2*256&&(this.tmpStorageLength=this.length>>>1),this.tmp=new Array(this.tmpStorageLength),this.stackLength=this.length<120?5:this.length<1542?10:this.length<119151?19:40,this.runStart=new Array(this.stackLength),this.runLength=new Array(this.stackLength)}pushRun(t,e){this.runStart[this.stackSize]=t,this.runLength[this.stackSize]=e,this.stackSize+=1}mergeRuns(){for(;this.stackSize>1;){let t=this.stackSize-2;if(t>=1&&this.runLength[t-1]<=this.runLength[t]+this.runLength[t+1]||t>=2&&this.runLength[t-2]<=this.runLength[t]+this.runLength[t-1])this.runLength[t-1]<this.runLength[t+1]&&t--;else if(this.runLength[t]>this.runLength[t+1])break;this.mergeAt(t)}}forceMergeRuns(){for(;this.stackSize>1;){let t=this.stackSize-2;t>0&&this.runLength[t-1]<this.runLength[t+1]&&t--,this.mergeAt(t)}}mergeAt(t){let e=this.compare,r=this.array,o=this.runStart[t],i=this.runLength[t],a=this.runStart[t+1],s=this.runLength[t+1];this.runLength[t]=i+s,t===this.stackSize-3&&(this.runStart[t+1]=this.runStart[t+2],this.runLength[t+1]=this.runLength[t+2]),this.stackSize--;let l=kh(r[a],r,o,i,0,e);o+=l,i-=l,i!==0&&(s=Fh(r[o+i-1],r,a,s,s-1,e),s!==0&&(i<=s?this.mergeLow(o,i,a,s):this.mergeHigh(o,i,a,s)))}mergeLow(t,e,r,o){let i=this.compare,a=this.array,s=this.tmp,l=0;for(l=0;l<e;l++)s[l]=a[t+l];let u=0,c=r,d=t;if(a[d++]=a[c++],--o===0){for(l=0;l<e;l++)a[d+l]=s[u+l];return}if(e===1){for(l=0;l<o;l++)a[d+l]=a[c+l];a[d+o]=s[u];return}let p=this.minGallop;for(;;){let f=0,h=0,m=!1;do if(i(a[c],s[u])<0){if(a[d++]=a[c++],h++,f=0,--o===0){m=!0;break}}else if(a[d++]=s[u++],f++,h=0,--e===1){m=!0;break}while((f|h)<p);if(m)break;do{if(f=kh(a[c],s,u,e,0,i),f!==0){for(l=0;l<f;l++)a[d+l]=s[u+l];if(d+=f,u+=f,e-=f,e<=1){m=!0;break}}if(a[d++]=a[c++],--o===0){m=!0;break}if(h=Fh(s[u],a,c,o,0,i),h!==0){for(l=0;l<h;l++)a[d+l]=a[c+l];if(d+=h,c+=h,o-=h,o===0){m=!0;break}}if(a[d++]=s[u++],--e===1){m=!0;break}p--}while(f>=7||h>=7);if(m)break;p<0&&(p=0),p+=2}if(this.minGallop=p,p<1&&(this.minGallop=1),e===1){for(l=0;l<o;l++)a[d+l]=a[c+l];a[d+o]=s[u]}else{if(e===0)throw new Error("mergeLow preconditions were not respected");for(l=0;l<e;l++)a[d+l]=s[u+l]}}mergeHigh(t,e,r,o){let i=this.compare,a=this.array,s=this.tmp,l=0;for(l=0;l<o;l++)s[l]=a[r+l];let u=t+e-1,c=o-1,d=r+o-1,p=0,f=0;if(a[d--]=a[u--],--e===0){for(p=d-(o-1),l=0;l<o;l++)a[p+l]=s[l];return}if(o===1){for(d-=e,u-=e,f=d+1,p=u+1,l=e-1;l>=0;l--)a[f+l]=a[p+l];a[d]=s[c];return}let h=this.minGallop;for(;;){let m=0,y=0,g=!1;do if(i(s[c],a[u])<0){if(a[d--]=a[u--],m++,y=0,--e===0){g=!0;break}}else if(a[d--]=s[c--],y++,m=0,--o===1){g=!0;break}while((m|y)<h);if(g)break;do{if(m=e-kh(s[c],a,t,e,e-1,i),m!==0){for(d-=m,u-=m,e-=m,f=d+1,p=u+1,l=m-1;l>=0;l--)a[f+l]=a[p+l];if(e===0){g=!0;break}}if(a[d--]=s[c--],--o===1){g=!0;break}if(y=o-Fh(a[u],s,0,o,o-1,i),y!==0){for(d-=y,c-=y,o-=y,f=d+1,p=c+1,l=0;l<y;l++)a[f+l]=s[p+l];if(o<=1){g=!0;break}}if(a[d--]=a[u--],--e===0){g=!0;break}h--}while(m>=7||y>=7);if(g)break;h<0&&(h=0),h+=2}if(this.minGallop=h,h<1&&(this.minGallop=1),o===1){for(d-=e,u-=e,f=d+1,p=u+1,l=e-1;l>=0;l--)a[f+l]=a[p+l];a[d]=s[c]}else{if(o===0)throw new Error("mergeHigh preconditions were not respected");for(p=d-(o-1),l=0;l<o;l++)a[p+l]=s[l]}}};function l1(n,t,e,r){if(!Array.isArray(n))throw new TypeError("Can only sort arrays");t?typeof t!="function"&&(r=e,e=t,t=i1):t=i1,e||(e=0),r||(r=n.length);let o=r-e;if(o<2)return;let i=0;if(o<32){i=a1(n,e,r,t),s1(n,e,r,e+i,t);return}let a=new jh(n,t),s=AE(o);do{if(i=a1(n,e,r,t),i<s){let l=o;l>s&&(l=s),s1(n,e,e+l,e+i,t),i=l}a.pushRun(e,i),a.mergeRuns(),o-=i,e+=i}while(o!==0);a.forceMergeRuns()}function Uh(n){let t=(0,Ci.default)(new Int32Array(n.shape[0]),[n.shape[0]]),e=(0,Ci.default)(new Int32Array(n.shape[0]),[n.shape[0]]);return Ze.bands(t,n,1023),Ze.lshifts(e,t,16),Ze.bxoreq(t,e),Ze.bandseq(t,4278190335),Ze.lshifts(e,t,8),Ze.bxoreq(t,e),Ze.bandseq(t,50393103),Ze.lshifts(e,t,4),Ze.bxoreq(t,e),Ze.bandseq(t,51130563),Ze.lshifts(e,t,2),Ze.bxoreq(t,e),Ze.bandseq(t,153391689),t}function PE(n){let t=Uh(n.pick(null,0)),e=Uh(n.pick(null,1));Ze.lshiftseq(e,1);let r=Uh(n.pick(null,2));return Ze.lshiftseq(r,2),Ze.boreq(t,e),Ze.boreq(t,r),t}function kn(n,t){if(n.shape[0]!==t.shape[0])throw new Error("wrong length");let e=(0,Ci.default)(new Float32Array(n.size),n.shape,n.stride,n.offset);for(let r=0;r<t.shape[0];r++){let o=t.get(r);if(n.shape.length>1)for(let i=0;i<n.shape[1];i++)e.set(r,i,n.get(o,i));else e.set(r,n.get(o))}return e}function Hh(n){let t=Ze.sup(n),e=Ze.inf(n),r=1e3/Math.min(1e3,t-e),o=(0,Ci.default)(new Float32Array(n.data),n.shape);Ze.mulseq(o,r);let i=(0,Ci.default)(new Int32Array(o.data),n.shape),a=PE(i),l=Array.from(a.data).map((d,p)=>[d,p]);l1(l,(d,p)=>d[0]-p[0]);let u=l.map(([d,p])=>p);return(0,Ci.default)(Uint32Array.from(u))}var Fr=class{constructor(t,e,r,o,i,a,s,l,u,c){this.propertyDescs=t,this.format=e,this.nsplats=r,this.xyz=o,this.colors=i,this.harmonics=a,this.opacity=s,this.scaling=l,this.rotation=u,this.maxSHDegree=c}getPlyBinary(){let t=Fr._generateHeaderString(this.propertyDescs,this.format,this.nsplats),e=new TextEncoder().encode(t),r=Object.keys(this.propertyDescs).length,o=(0,sn.default)(new Float32Array(this.nsplats*r),[this.nsplats,r]);if(ze.assign(o.pick(null,this.propertyDescs.x.index),this.xyz.pick(null,0)),ze.assign(o.pick(null,this.propertyDescs.y.index),this.xyz.pick(null,1)),ze.assign(o.pick(null,this.propertyDescs.z.index),this.xyz.pick(null,2)),ze.assign(o.pick(null,this.propertyDescs.f_dc_0.index),this.colors.pick(null,0)),ze.assign(o.pick(null,this.propertyDescs.f_dc_1.index),this.colors.pick(null,1)),ze.assign(o.pick(null,this.propertyDescs.f_dc_2.index),this.colors.pick(null,2)),ze.assign(o.pick(null,this.propertyDescs.opacity.index),this.opacity.pick(null,0)),ze.assign(o.pick(null,this.propertyDescs.scale_0.index),this.scaling.pick(null,0)),ze.assign(o.pick(null,this.propertyDescs.scale_1.index),this.scaling.pick(null,1)),ze.assign(o.pick(null,this.propertyDescs.scale_2.index),this.scaling.pick(null,2)),ze.assign(o.pick(null,this.propertyDescs.rot_0.index),this.rotation.pick(null,0)),ze.assign(o.pick(null,this.propertyDescs.rot_1.index),this.rotation.pick(null,1)),ze.assign(o.pick(null,this.propertyDescs.rot_2.index),this.rotation.pick(null,2)),ze.assign(o.pick(null,this.propertyDescs.rot_3.index),this.rotation.pick(null,3)),this.harmonics&&this.harmonics.length>0)for(let s=0;s<this.harmonics.length;s++){let l=s*3;ze.assign(o.pick(null,this.propertyDescs[`f_rest_${l}`].index),this.harmonics[s].pick(null,0)),ze.assign(o.pick(null,this.propertyDescs[`f_rest_${l+1}`].index),this.harmonics[s].pick(null,1)),ze.assign(o.pick(null,this.propertyDescs[`f_rest_${l+2}`].index),this.harmonics[s].pick(null,2))}let i=new Uint8Array(o.data.buffer),a=new Uint8Array(i.length+e.length);return a.set(e),a.set(i,e.length),a.buffer}save(t,e){let r=this.getPlyBinary(),o=new Blob([r],{type:"application/octet-stream"}),i=new File([o],t),a=new FormData;a.append("file",i),a.append("filename",t),a.append("basedir",e),fetch(`${r1}/push_file`,{method:"POST",body:a})}static async loadFile(t){return await(await fetch(t)).arrayBuffer()}mortonPositionSplatsSort(){let t=Hh(this.xyz),e=kn(this.xyz,t),r=kn(this.colors,t),o=kn(this.opacity,t),i=kn(this.scaling,t),a=kn(this.rotation,t),s=[];for(let l=0;l<this.harmonics.length;l++)s.push(kn(this.harmonics[l],t));return new Fr(this.propertyDescs,this.format,this.nsplats,e,r,s,o,i,a,this.maxSHDegree)}static _generateHeaderString(t,e,r){let o=`ply
3491
3491
  format ${e.format} ${e.version}
3492
3492
  element vertex ${r}`,i=Object.keys(t).length,a=Array(i);for(let s in t){let l=t[s];a[l.index]={name:s,dtype:l.dtype}}for(let s=0;s<a.length;s++)o=`${o}
3493
3493
  property ${a[s].dtype} ${a[s].name}`;return`${o}
3494
3494
  end_header
3495
- `}static fromArrayBuffer(t,e=3){let{splatCount:r,vertexData:o,propertiesDesc:i,format:a}=Fr.decodeHeader(t),s=o.buffer.slice(o.byteOffset),l=Object.keys(i).length,u=(0,sn.default)(new Float32Array(s),[r,l]),c=0,d={},p={double:8,int:4,uint:4,float:4,short:2,ushort:2,uchar:1};for(let S in i)if(i.hasOwnProperty(S)){let P=i[S].dtype;d[S]=c,c+=p[P]}let f=(0,sn.default)(new Float32Array(r*3),[r,3]);ze.assign(f.pick(null,0),u.pick(null,d.x/4)),ze.assign(f.pick(null,1),u.pick(null,d.y/4)),ze.assign(f.pick(null,2),u.pick(null,d.z/4));let h=(0,sn.default)(new Float32Array(r*3),[r,3]);ze.assign(h.pick(null,0),u.pick(null,d.scale_0/4)),ze.assign(h.pick(null,1),u.pick(null,d.scale_1/4)),ze.assign(h.pick(null,2),u.pick(null,d.scale_2/4));let m=(0,sn.default)(new Float32Array(r*3),[r,3]);ze.assign(m.pick(null,0),u.pick(null,d.f_dc_0/4)),ze.assign(m.pick(null,1),u.pick(null,d.f_dc_1/4)),ze.assign(m.pick(null,2),u.pick(null,d.f_dc_2/4));let y=(0,sn.default)(new Float32Array(r*4),[r,4]);ze.assign(y.pick(null,0),u.pick(null,d.rot_1/4)),ze.assign(y.pick(null,1),u.pick(null,d.rot_2/4)),ze.assign(y.pick(null,2),u.pick(null,d.rot_3/4)),ze.assign(y.pick(null,3),u.pick(null,d.rot_0/4));for(let S=0;S<r;S++){let P=y.pick(S,null),O=Math.sqrt(P.get(0)**2+P.get(1)**2+P.get(2)**2+P.get(3)**2);ze.divseq(P,O)}let g=(0,sn.default)(new Float32Array(r*1),[r,1]);ze.assign(g.pick(null,0),u.pick(null,d.opacity/4));let w=(Math.min(Math.max(e,0),3)+1)**2-1,_=[];for(let S=0;S<w;S++){let P=(0,sn.default)(new Float32Array(r*3),[r,3]),O=S*3;ze.assign(P.pick(null,0),u.pick(null,d[`f_rest_${O}`]/4)),ze.assign(P.pick(null,1),u.pick(null,d[`f_rest_${O+1}`]/4)),ze.assign(P.pick(null,2),u.pick(null,d[`f_rest_${O+2}`]/4)),_.push(P)}return new Fr(i,a,r,f,m,_,g,h,y,e)}static async fromPLYFile(t,e=3){let r=await Fr.loadFile(t);return Fr.fromArrayBuffer(r,e)}static decodeHeader(t){let e=new TextDecoder,r=0,o="",i=100;for(;;){if(r+i>=t.byteLength)throw new Error("End of file reached while searching for end of header");let h=new Uint8Array(t,r,i);o+=e.decode(h),r+=i;let m=r-i*2,y=new Uint8Array(t,Math.max(0,m),m>0?i*2:i);if(e.decode(y).includes("end_header"))break}let a=o.split(`
3496
- `),s=0,l={},u={},c=0,d;for(let h=0;h<a.length;h++){let m=a[h].trim();if(m.startsWith("element vertex")){let y=m.match(/\d+/);y&&(s=parseInt(y[0]))}else if(m.startsWith("property")){let y=m.match(/(\w+)\s+(\w+)\s+(\w+)/);if(y){let g=y[2],b=y[3];l[b]=c,u[b]={dtype:g,index:c},c++}}else if(m.startsWith("format")){let y=m.match(/(\w+)\s+(\w+)\s+(\d+\.?\d*)/);y&&(d={format:y[2],version:y[3]})}else if(m==="end_header")break}let p=o.indexOf("end_header")+10+1,f=new DataView(t,p);return{splatCount:s,vertexData:f,headerOffset:r,propertiesDesc:u,format:d}}};var Ti=class{constructor(t,e,r,o,i,a,s,l){this.config=t,this.xyz=e,this.scaling=r,this.color=o,this.opacity=i,this.harmonics=s,this.quaternion=a,this.variableChunkSize=l}get isDynamicChunks(){return this.variableChunkSize&&this.variableChunkSize.length>0}get nchunks(){return this.xyz.nchunks}get nsplats(){return this.xyz.length}get chunkSize(){return this.config.chunkSize}static compressFromGaussianData(t,e){let r=rt.fromArray(t.xyz,e.xyz,e.chunkSize),o=rt.fromArray(t.scaling,e.scaling,e.chunkSize),i=rt.fromArray(t.colors,e.color,e.chunkSize),a=rt.fromArray(t.opacity,e.opacity,e.chunkSize),s=rt.fromArray(t.rotation,e.quaternion,e.chunkSize),l=t.harmonics,u=[];if(e.harmonics)for(let c=0;c<l.length;c++){let d=rt.fromArray(l[c],e.harmonics,e.chunkSize);u.push(d)}return new Ti(e,r,o,i,a,s,u)}_countIndexesInChunks(t){let e=[],r=this.nchunks,o=this.chunkSize,i=this.nsplats,a=rt.getRequiredNChunks(i,o);if(r===a)for(let s=0;s<t.length;s++){let l=t[s],u=Math.floor(l/this.chunkSize);u in e?e[u].push(l):e[u]=[l]}else{let s=this.variableChunkSize,l={},u=0;for(let c=0;c<r;c++)l[c]=u,u+=s[c];for(let c=0;c<t.length;c++){let d=t[c],p=Math.min(Math.floor(d/o),r-1);for(;d>=l[p]+s[p];)p++;p in e?e[p].push(d):e[p]=[d]}}return e}pruneSplats(t){let e=this._countIndexesInChunks(t),r,o=[];return e.length>0&&(r=this.variableChunkSize?[...this.variableChunkSize]:Array(this.nchunks).fill(this.chunkSize),e.forEach((i,a)=>{r[a]-=i.length,r[a]<=0&&o.push(a)}),r=r.filter(i=>i>0)),new Ti(this.config,this.xyz.pruneFeature(t,o,r),this.scaling.pruneFeature(t,o,r),this.color.pruneFeature(t,o,r),this.opacity.pruneFeature(t,o,r),this.quaternion.pruneFeature(t,o,r),this.harmonics?this.harmonics.map(i=>i.pruneFeature(t,o,this.variableChunkSize)):void 0,r)}static async loadConfig(t){return await(await fetch(t,{method:"GET",mode:"cors",headers:{Accept:"application/json"}})).json()}toGaussians(){let t={format:"binary_little_endian",version:"1.0"},e={},r=0;if(e.x={dtype:"float",index:r},r++,e.y={dtype:"float",index:r},r++,e.z={dtype:"float",index:r},r++,e.f_dc_0={dtype:"float",index:r},r++,e.f_dc_1={dtype:"float",index:r},r++,e.f_dc_2={dtype:"float",index:r},r++,this.harmonics&&this.harmonics.length>0)for(let a=0;a<this.harmonics.length;a++)e[`f_rest_${a}`]={dtype:"float",index:r},r++,e[`f_rest_${a+1}`]={dtype:"float",index:r},r++,e[`f_rest_${a+2}`]={dtype:"float",index:r},r++;e.opacity={dtype:"float",index:r},r++,e.scale_0={dtype:"float",index:r},r++,e.scale_1={dtype:"float",index:r},r++,e.scale_2={dtype:"float",index:r},r++,e.rot_0={dtype:"float",index:r},r++,e.rot_1={dtype:"float",index:r},r++,e.rot_2={dtype:"float",index:r},r++,e.rot_3={dtype:"float",index:r},r++;let o=this.harmonics?.map(a=>a.denormDequant());return new Fr(e,t,this.xyz.length,this.xyz.denormDequant(),this.color.denormDequant(),o||[],this.opacity.denormDequant(),this.scaling.denormDequant(),this.quaternion.denormDequant(),3)}};var Mi=Ht(Ns()),Ot=Ht(Ds());import{Matrix3 as Hh,Matrix4 as SE,Quaternion as wE}from"three";var i1={xyz:3,color:3,opacity:1,scaling:3,quaternion:4,harmonics:3},jn=class{constructor(t){this._buffer=t}get buffer(){return this._buffer}get decoded(){return this._decoded||(this._decoded=this.decodeBuffer()),this._decoded}get colorsA(){let t=.28209479177387814,e=this.decoded.color.denormDequant(),r=this.decoded.opacity.denormDequant(),o=(0,Mi.default)(new Float32Array(e.shape[0]*4),[e.shape[0],4]);return Ot.mulseq(e,t),Ot.addseq(e,.5),Ot.mulseq(e,255),Ot.maxseq(e,0),Ot.minseq(e,255),Ot.negeq(r),Ot.expeq(r),Ot.addseq(r,1),Ot.recipeq(r),Ot.mulseq(r,255),Ot.assign(o.hi(e.shape[0],3).lo(0,0),e),Ot.assign(o.hi(e.shape[0],4).lo(0,3),r),(0,Mi.default)(new Uint8Array(o.data),[e.shape[0],4]).data}get nsplats(){return this.decoded.nsplats}getSplatCount(){return this.decoded.nsplats}get precomputedCovarianceBufferData(){return this._precomputedCovarianceBufferData}decodeBuffer(){let{splatCount:t,chunkCount:e,chunkSize:r,typeChunks:o,vertexData:i,propertiesDesc:a}=this.decodeHeader(),s={xyz:a.xyz.compressionMethod,color:a.color.compressionMethod,opacity:a.opacity.compressionMethod,scaling:a.scaling.compressionMethod,quaternion:a.quaternion.compressionMethod,chunkSize:r};a.harmonics_0&&(s.harmonics=a.harmonics_0.compressionMethod);let l=i.byteOffset,u=Array(Object.keys(a).length);for(let g in a)u[a[g].index]={name:g,method:a[g].compressionMethod};let c=e*2*4,d=l,p=o==="dynamic"?e*2:0,f,h=!1;if(p>0){let g=new Uint16Array(i.buffer.slice(d,d+p));d+=p,f=Array.from(g),h=!0}let m={};for(let g of u){let b=0,w=!0;if(g.method==="norm8x")b=t*1*i1[g.name];else if(g.method==="norm11")b=t*4;else if(g.method==="norm565")b=t*2;else throw w=!1,new Error(`Not Implemented format: ${g.method}`);let _;if(w){let O=i.buffer.slice(d,d+c);_=(0,Mi.default)(new Float32Array(O),[e,2]),d+=c}else throw new Error("loading chunk byt hasnot minmax!");let S=i.buffer.slice(d,d+b);d+=b;let P;if(g.method==="norm8x")P=(0,Mi.default)(new Uint8Array(S),[t,i1[g.name]]);else if(g.method==="norm11")P=(0,Mi.default)(new Uint32Array(S));else if(g.method==="norm565")P=(0,Mi.default)(new Uint16Array(S));else throw new Error(`Not Implemented format: ${g.method}`);m[g.name]=new rt(P,_,r,g.method,f,h)}let y=[];for(let g=0;g<15;g++){let b=m[`harmonics_${g}`];b&&(y.push(b),delete m[`harmonics_${g}`])}return y.length>0&&(m.harmonics=y),new Ti(s,m.xyz,m.scaling,m.color,m.opacity,m.quaternion,m.harmonics,f)}buildPreComputedBuffers(){let r=this.decoded,o=r.nsplats,i=new ArrayBuffer(24*o),a=new Float32Array(i),s=r.scaling.denormDequant(),l=r.quaternion.denormDequant(),u=new wE,c=new Hh,d=new Hh,p=new Hh,f=new SE;for(let h=0;h<o;h++){f.makeScale(Math.exp(s.get(h,0)),Math.exp(s.get(h,1)),Math.exp(s.get(h,2))),d.setFromMatrix4(f),u.set(l.get(h,0),l.get(h,1),l.get(h,2),l.get(h,3)),f.makeRotationFromQuaternion(u),c.setFromMatrix4(f),p.copy(c).multiply(d);let m=p.elements;a[6*h]=m[0]*m[0]+m[3]*m[3]+m[6]*m[6],a[6*h+1]=m[0]*m[1]+m[3]*m[4]+m[6]*m[7],a[6*h+2]=m[0]*m[2]+m[3]*m[5]+m[6]*m[8],a[6*h+3]=m[1]*m[1]+m[4]*m[4]+m[7]*m[7],a[6*h+4]=m[1]*m[2]+m[4]*m[5]+m[7]*m[8],a[6*h+5]=m[2]*m[2]+m[5]*m[5]+m[8]*m[8]}this._precomputedCovarianceBufferData=i}decodeHeader(){let t=this._buffer,e=new TextDecoder,r=0,o="",i=100;for(;;){if(r+i>=t.byteLength)throw new Error("End of file reached while searching for end of header");let m=new Uint8Array(t,r,i);o+=e.decode(m),r+=i;let y=r-i*2,g=new Uint8Array(t,Math.max(0,y),y>=0?i*2:i);if(e.decode(g).includes("end_header"))break}let a=o.split(`
3495
+ `}static fromArrayBuffer(t,e=3){let{splatCount:r,vertexData:o,propertiesDesc:i,format:a}=Fr.decodeHeader(t),s=o.buffer.slice(o.byteOffset),l=Object.keys(i).length,u=(0,sn.default)(new Float32Array(s),[r,l]),c=0,d={},p={double:8,int:4,uint:4,float:4,short:2,ushort:2,uchar:1};for(let S in i)if(i.hasOwnProperty(S)){let P=i[S].dtype;d[S]=c,c+=p[P]}let f=(0,sn.default)(new Float32Array(r*3),[r,3]);ze.assign(f.pick(null,0),u.pick(null,d.x/4)),ze.assign(f.pick(null,1),u.pick(null,d.y/4)),ze.assign(f.pick(null,2),u.pick(null,d.z/4));let h=(0,sn.default)(new Float32Array(r*3),[r,3]);ze.assign(h.pick(null,0),u.pick(null,d.scale_0/4)),ze.assign(h.pick(null,1),u.pick(null,d.scale_1/4)),ze.assign(h.pick(null,2),u.pick(null,d.scale_2/4));let m=(0,sn.default)(new Float32Array(r*3),[r,3]);ze.assign(m.pick(null,0),u.pick(null,d.f_dc_0/4)),ze.assign(m.pick(null,1),u.pick(null,d.f_dc_1/4)),ze.assign(m.pick(null,2),u.pick(null,d.f_dc_2/4));let y=(0,sn.default)(new Float32Array(r*4),[r,4]);ze.assign(y.pick(null,0),u.pick(null,d.rot_1/4)),ze.assign(y.pick(null,1),u.pick(null,d.rot_2/4)),ze.assign(y.pick(null,2),u.pick(null,d.rot_3/4)),ze.assign(y.pick(null,3),u.pick(null,d.rot_0/4));for(let S=0;S<r;S++){let P=y.pick(S,null),O=Math.sqrt(P.get(0)**2+P.get(1)**2+P.get(2)**2+P.get(3)**2);ze.divseq(P,O)}let g=(0,sn.default)(new Float32Array(r*1),[r,1]);ze.assign(g.pick(null,0),u.pick(null,d.opacity/4));let w=(Math.min(Math.max(e,0),3)+1)**2-1,A=[];for(let S=0;S<w;S++){let P=(0,sn.default)(new Float32Array(r*3),[r,3]),O=S*3;ze.assign(P.pick(null,0),u.pick(null,d[`f_rest_${O}`]/4)),ze.assign(P.pick(null,1),u.pick(null,d[`f_rest_${O+1}`]/4)),ze.assign(P.pick(null,2),u.pick(null,d[`f_rest_${O+2}`]/4)),A.push(P)}return new Fr(i,a,r,f,m,A,g,h,y,e)}static async fromPLYFile(t,e=3){let r=await Fr.loadFile(t);return Fr.fromArrayBuffer(r,e)}static decodeHeader(t){let e=new TextDecoder,r=0,o="",i=100;for(;;){if(r+i>=t.byteLength)throw new Error("End of file reached while searching for end of header");let h=new Uint8Array(t,r,i);o+=e.decode(h),r+=i;let m=r-i*2,y=new Uint8Array(t,Math.max(0,m),m>0?i*2:i);if(e.decode(y).includes("end_header"))break}let a=o.split(`
3496
+ `),s=0,l={},u={},c=0,d;for(let h=0;h<a.length;h++){let m=a[h].trim();if(m.startsWith("element vertex")){let y=m.match(/\d+/);y&&(s=parseInt(y[0]))}else if(m.startsWith("property")){let y=m.match(/(\w+)\s+(\w+)\s+(\w+)/);if(y){let g=y[2],b=y[3];l[b]=c,u[b]={dtype:g,index:c},c++}}else if(m.startsWith("format")){let y=m.match(/(\w+)\s+(\w+)\s+(\d+\.?\d*)/);y&&(d={format:y[2],version:y[3]})}else if(m==="end_header")break}let p=o.indexOf("end_header")+10+1,f=new DataView(t,p);return{splatCount:s,vertexData:f,headerOffset:r,propertiesDesc:u,format:d}}};var Ti=class{constructor(t,e,r,o,i,a,s,l){this.config=t,this.xyz=e,this.scaling=r,this.color=o,this.opacity=i,this.harmonics=s,this.quaternion=a,this.variableChunkSize=l}get isDynamicChunks(){return this.variableChunkSize&&this.variableChunkSize.length>0}get nchunks(){return this.xyz.nchunks}get nsplats(){return this.xyz.length}get chunkSize(){return this.config.chunkSize}static compressFromGaussianData(t,e){let r=rt.fromArray(t.xyz,e.xyz,e.chunkSize),o=rt.fromArray(t.scaling,e.scaling,e.chunkSize),i=rt.fromArray(t.colors,e.color,e.chunkSize),a=rt.fromArray(t.opacity,e.opacity,e.chunkSize),s=rt.fromArray(t.rotation,e.quaternion,e.chunkSize),l=t.harmonics,u=[];if(e.harmonics)for(let c=0;c<l.length;c++){let d=rt.fromArray(l[c],e.harmonics,e.chunkSize);u.push(d)}return new Ti(e,r,o,i,a,s,u)}_countIndexesInChunks(t){let e=[],r=this.nchunks,o=this.chunkSize,i=this.nsplats,a=rt.getRequiredNChunks(i,o);if(r===a)for(let s=0;s<t.length;s++){let l=t[s],u=Math.floor(l/this.chunkSize);u in e?e[u].push(l):e[u]=[l]}else{let s=this.variableChunkSize,l={},u=0;for(let c=0;c<r;c++)l[c]=u,u+=s[c];for(let c=0;c<t.length;c++){let d=t[c],p=Math.min(Math.floor(d/o),r-1);for(;d>=l[p]+s[p];)p++;p in e?e[p].push(d):e[p]=[d]}}return e}pruneSplats(t){let e=this._countIndexesInChunks(t),r,o=[];return e.length>0&&(r=this.variableChunkSize?[...this.variableChunkSize]:Array(this.nchunks).fill(this.chunkSize),e.forEach((i,a)=>{r[a]-=i.length,r[a]<=0&&o.push(a)}),r=r.filter(i=>i>0)),new Ti(this.config,this.xyz.pruneFeature(t,o,r),this.scaling.pruneFeature(t,o,r),this.color.pruneFeature(t,o,r),this.opacity.pruneFeature(t,o,r),this.quaternion.pruneFeature(t,o,r),this.harmonics?this.harmonics.map(i=>i.pruneFeature(t,o,this.variableChunkSize)):void 0,r)}static async loadConfig(t){return await(await fetch(t,{method:"GET",mode:"cors",headers:{Accept:"application/json"}})).json()}toGaussians(){let t={format:"binary_little_endian",version:"1.0"},e={},r=0;if(e.x={dtype:"float",index:r},r++,e.y={dtype:"float",index:r},r++,e.z={dtype:"float",index:r},r++,e.f_dc_0={dtype:"float",index:r},r++,e.f_dc_1={dtype:"float",index:r},r++,e.f_dc_2={dtype:"float",index:r},r++,this.harmonics&&this.harmonics.length>0)for(let a=0;a<this.harmonics.length;a++)e[`f_rest_${a}`]={dtype:"float",index:r},r++,e[`f_rest_${a+1}`]={dtype:"float",index:r},r++,e[`f_rest_${a+2}`]={dtype:"float",index:r},r++;e.opacity={dtype:"float",index:r},r++,e.scale_0={dtype:"float",index:r},r++,e.scale_1={dtype:"float",index:r},r++,e.scale_2={dtype:"float",index:r},r++,e.rot_0={dtype:"float",index:r},r++,e.rot_1={dtype:"float",index:r},r++,e.rot_2={dtype:"float",index:r},r++,e.rot_3={dtype:"float",index:r},r++;let o=this.harmonics?.map(a=>a.denormDequant());return new Fr(e,t,this.xyz.length,this.xyz.denormDequant(),this.color.denormDequant(),o||[],this.opacity.denormDequant(),this.scaling.denormDequant(),this.quaternion.denormDequant(),3)}};var Mi=Ht(Ds()),Ot=Ht(Es());import{Matrix3 as qh,Matrix4 as OE,Quaternion as CE}from"three";var c1={xyz:3,color:3,opacity:1,scaling:3,quaternion:4,harmonics:3},jn=class{constructor(t){this._buffer=t}get buffer(){return this._buffer}get decoded(){return this._decoded||(this._decoded=this.decodeBuffer()),this._decoded}get colorsA(){let t=.28209479177387814,e=this.decoded.color.denormDequant(),r=this.decoded.opacity.denormDequant(),o=(0,Mi.default)(new Float32Array(e.shape[0]*4),[e.shape[0],4]);return Ot.mulseq(e,t),Ot.addseq(e,.5),Ot.mulseq(e,255),Ot.maxseq(e,0),Ot.minseq(e,255),Ot.negeq(r),Ot.expeq(r),Ot.addseq(r,1),Ot.recipeq(r),Ot.mulseq(r,255),Ot.assign(o.hi(e.shape[0],3).lo(0,0),e),Ot.assign(o.hi(e.shape[0],4).lo(0,3),r),(0,Mi.default)(new Uint8Array(o.data),[e.shape[0],4]).data}get nsplats(){return this.decoded.nsplats}getSplatCount(){return this.decoded.nsplats}get precomputedCovarianceBufferData(){return this._precomputedCovarianceBufferData}decodeBuffer(){let{splatCount:t,chunkCount:e,chunkSize:r,typeChunks:o,vertexData:i,propertiesDesc:a}=this.decodeHeader(),s={xyz:a.xyz.compressionMethod,color:a.color.compressionMethod,opacity:a.opacity.compressionMethod,scaling:a.scaling.compressionMethod,quaternion:a.quaternion.compressionMethod,chunkSize:r};a.harmonics_0&&(s.harmonics=a.harmonics_0.compressionMethod);let l=i.byteOffset,u=Array(Object.keys(a).length);for(let g in a)u[a[g].index]={name:g,method:a[g].compressionMethod};let c=e*2*4,d=l,p=o==="dynamic"?e*2:0,f,h=!1;if(p>0){let g=new Uint16Array(i.buffer.slice(d,d+p));d+=p,f=Array.from(g),h=!0}let m={};for(let g of u){let b=0,w=!0;if(g.method==="norm8x")b=t*1*c1[g.name];else if(g.method==="norm11")b=t*4;else if(g.method==="norm565")b=t*2;else throw w=!1,new Error(`Not Implemented format: ${g.method}`);let A;if(w){let O=i.buffer.slice(d,d+c);A=(0,Mi.default)(new Float32Array(O),[e,2]),d+=c}else throw new Error("loading chunk byt hasnot minmax!");let S=i.buffer.slice(d,d+b);d+=b;let P;if(g.method==="norm8x")P=(0,Mi.default)(new Uint8Array(S),[t,c1[g.name]]);else if(g.method==="norm11")P=(0,Mi.default)(new Uint32Array(S));else if(g.method==="norm565")P=(0,Mi.default)(new Uint16Array(S));else throw new Error(`Not Implemented format: ${g.method}`);m[g.name]=new rt(P,A,r,g.method,f,h)}let y=[];for(let g=0;g<15;g++){let b=m[`harmonics_${g}`];b&&(y.push(b),delete m[`harmonics_${g}`])}return y.length>0&&(m.harmonics=y),new Ti(s,m.xyz,m.scaling,m.color,m.opacity,m.quaternion,m.harmonics,f)}buildPreComputedBuffers(){let r=this.decoded,o=r.nsplats,i=new ArrayBuffer(24*o),a=new Float32Array(i),s=r.scaling.denormDequant(),l=r.quaternion.denormDequant(),u=new CE,c=new qh,d=new qh,p=new qh,f=new OE;for(let h=0;h<o;h++){f.makeScale(Math.exp(s.get(h,0)),Math.exp(s.get(h,1)),Math.exp(s.get(h,2))),d.setFromMatrix4(f),u.set(l.get(h,0),l.get(h,1),l.get(h,2),l.get(h,3)),f.makeRotationFromQuaternion(u),c.setFromMatrix4(f),p.copy(c).multiply(d);let m=p.elements;a[6*h]=m[0]*m[0]+m[3]*m[3]+m[6]*m[6],a[6*h+1]=m[0]*m[1]+m[3]*m[4]+m[6]*m[7],a[6*h+2]=m[0]*m[2]+m[3]*m[5]+m[6]*m[8],a[6*h+3]=m[1]*m[1]+m[4]*m[4]+m[7]*m[7],a[6*h+4]=m[1]*m[2]+m[4]*m[5]+m[7]*m[8],a[6*h+5]=m[2]*m[2]+m[5]*m[5]+m[8]*m[8]}this._precomputedCovarianceBufferData=i}decodeHeader(){let t=this._buffer,e=new TextDecoder,r=0,o="",i=100;for(;;){if(r+i>=t.byteLength)throw new Error("End of file reached while searching for end of header");let m=new Uint8Array(t,r,i);o+=e.decode(m),r+=i;let y=r-i*2,g=new Uint8Array(t,Math.max(0,y),y>=0?i*2:i);if(e.decode(g).includes("end_header"))break}let a=o.split(`
3497
3497
  `),s=0,l=0,u=0,c=0,d="",p={};for(let m=0;m<a.length;m++){let y=a[m].trim();if(y.startsWith("element vertex")){let g=y.match(/\d+/);g&&(s=parseInt(g[0]))}else if(y.startsWith("property")){let g=y.match(/(\w+)\s+(\w+)\s+(\w+)/);if(g){let b=g[2],w=g[3];p[b]={compressionMethod:w,index:c},c++}}else if(y.startsWith("element chunks")){let g=y.match(/\d+/);g&&(l=parseInt(g[0]))}else if(y.startsWith("element chunkSize")){let g=y.match(/\d+/);g&&(u=parseInt(g[0]))}else if(y.startsWith("element typeChunks")){let g=y.match(/(\w+)\s+(\w+)\s+(\w+)/);g&&(d=g[3])}else if(y==="end_header")break}let f=o.indexOf("end_header")+10+1,h=new DataView(t,f);return{splatCount:s,chunkCount:l,chunkSize:u,typeChunks:d,vertexData:h,propertiesDesc:p}}pruneSplats(t){let r=this.decodeBuffer().pruneSplats(t);return jn.fromCompressedGaussianSplats(r)}static fromCompressedGaussianSplats(t){let e=t.xyz.length,r=t.xyz.nchunks,o=`gspline
3498
3498
  element vertex ${e}
3499
3499
  element chunks ${r}
@@ -3506,7 +3506,7 @@ property scaling ${t.scaling.method}
3506
3506
  property quaternion ${t.quaternion.method}`;if(t.harmonics&&t.harmonics.length>0)for(let D=0;D<t.harmonics.length;D++)o=`${o}
3507
3507
  property harmonics_${D} ${t.harmonics[D].method}`;o=`${o}
3508
3508
  end_header
3509
- `;let a=new TextEncoder().encode(o),s=r*2*4,l=t.xyz.quantized.data.buffer.byteLength,u=t.xyz instanceof rt?s:0,c=t.color.quantized.data.buffer.byteLength,d=t.color instanceof rt?s:0,p=t.opacity.quantized.data.buffer.byteLength,f=t.opacity instanceof rt?s:0,h=t.scaling.quantized.data.buffer.byteLength,m=t.scaling instanceof rt?s:0,y=t.quaternion.quantized.data.buffer.byteLength,g=t.quaternion instanceof rt?s:0,b=t.variableChunkSize?Uint16Array.from(t.variableChunkSize):void 0,w=b?b.byteLength:0,_=a.byteLength+w+l+u+c+d+p+f+h+m+y+g,S=0,P=0;if(t.harmonics&&t.harmonics.length>0)for(let D=0;D<t.harmonics.length;D++)S+=t.harmonics[D].quantized.data.buffer.byteLength,P+=t.harmonics[D]instanceof rt?s:0;S=0,P=0,_+=S+P;let O=new Uint8Array(_),x=0;if(O.set(a,x),x+=a.byteLength,w>0&&(O.set(new Uint8Array(b.buffer),x),x+=w),t.xyz instanceof rt&&(O.set(new Uint8Array(t.xyz.minmaxMatrix.data.buffer),x),x+=s),O.set(new Uint8Array(t.xyz.quantized.data.buffer),x),x+=l,t.color instanceof rt&&(O.set(new Uint8Array(t.color.minmaxMatrix.data.buffer),x),x+=s),O.set(new Uint8Array(t.color.quantized.data.buffer),x),x+=c,t.opacity instanceof rt&&(O.set(new Uint8Array(t.opacity.minmaxMatrix.data.buffer),x),x+=s),O.set(new Uint8Array(t.opacity.quantized.data.buffer),x),x+=p,t.scaling instanceof rt&&(O.set(new Uint8Array(t.scaling.minmaxMatrix.data.buffer),x),x+=s),O.set(new Uint8Array(t.scaling.quantized.data.buffer),x),x+=h,t.quaternion instanceof rt&&(O.set(new Uint8Array(t.quaternion.minmaxMatrix.data.buffer),x),x+=s),O.set(new Uint8Array(t.quaternion.quantized.data.buffer),x),x+=y,S>0&&t.harmonics&&t.harmonics.length>0)for(let D=0;D<t.harmonics.length;D++){let N=t.harmonics[D];N instanceof rt&&(O.set(new Uint8Array(N.minmaxMatrix.data.buffer),x),x+=s),O.set(new Uint8Array(N.quantized.data.buffer),x),x+=N.quantized.data.byteLength}return new jn(O.buffer)}};var a1="AGFzbQEAAAAADwhkeWxpbmsuMAEEAAAAAAETA2AAAGAIf39/f39/f38AYAABfwISAQNlbnYGbWVtb3J5AgMAgIAEAwQDAAECBzkDEV9fd2FzbV9jYWxsX2N0b3JzAAALc29ydEluZGV4ZXMAARNlbXNjcmlwdGVuX3Rsc19pbml0AAIK3gMDAwABC9IDAwF/BnwBfgJAIAdFDQAgAysDUCEMIAMrAzAhDSADKwMQIQ5BACEDRP///////+9/IQtEAAAAAAAAEAAhCgNAIAIgA0ECdGoCfyAOIAEgA0EMbGoiCCoCALuiIA0gCCoCBLuioCAMIAgqAgi7oqBEAAAAAAAAsECiIgmZRAAAAAAAAOBBYwRAIAmqDAELQYCAgIB4CzYCACAJIAsgCSALYxshCyAJIAogCSAKZBshCiADQQFqIgMgB0cNAAsgB0UNACAGuCAKIAuhoyEJQQAhAwNAAn8gCSACIANBAnRqIgEoAgC3IAuhoiIKmUQAAAAAAADgQWMEQCAKqgwBC0GAgICAeAshCCABIAg2AgAgBCAIQQJ0aiIBIAEoAgBBAWo2AgAgA0EBaiIDIAdHDQALCyAGQQJPBEAgBCgCACEIQQEhAwNAIAQgA0ECdGoiASABKAIAIAhqIgg2AgAgA0EBaiIDIAZHDQALCyAHQQFrIgGtIQ8DQCAEIAIgD6dBAnQiA2ooAgBBAnRqIgcgBygCAEEBayIHNgIAIAUgASAHa0ECdGogACADaigCADYCACAPUCEDIA9CAX0hDyADRQ0ACyAGBEAgBEEAIAZBAnT8CwALCwQAQQAL";var Do=class{};Lt(Do,"DepthMapRange",1<<16),Lt(Do,"MemoryPageSize",65536),Lt(Do,"BytesPerFloat",4),Lt(Do,"BytesPerInt",4);function AE(n){let t,e,r,o,i,a,s,l,u,c,d,p,f,h,m,y;function g(T){let I=new Float64Array(c,a,16);for(let B=0;B<16;B++)I[B]=T[B];let E;if(r>1){t.exports.sortIndexes(o,i,u,a,s,l,p.DepthMapRange,r);let B=new Uint32Array(r);E=B.buffer,B.set(new Uint32Array(c,l,r))}else if(r===1){let B=new Uint32Array(r);B[0]=new Uint32Array(c,o,e)[0],E=B.buffer}else E=new ArrayBuffer(0);n.postMessage({sortDone:!0,indexesBuffer:E},[E])}function b(T,I,E){let B=new Float32Array(c,i,e*3);r=0;let R=new Uint32Array(c,o,e);for(let F=0;F<E.length-1;F++){let V=I[F],q=T[F].elements,k=V.filter(H=>H.enabled&&H.mode==="Include").map(H=>H.type==="Box"?P(H):D(H)),U=V.filter(H=>H.enabled&&H.mode==="Exclude").map(H=>H.type==="Box"?P(H):D(H));for(let H=E[F];H<E[F+1];H++){let $=f[H*3],J=f[H*3+1],K=f[H*3+2];if((k.length===0||_($,J,K,k))&&(U.length===0||!_($,J,K,U))){let X=1/(q[3]*$+q[7]*J+q[11]*K+q[15]);B[r*3]=(q[0]*$+q[4]*J+q[8]*K+q[12])*X,B[r*3+1]=(q[1]*$+q[5]*J+q[9]*K+q[13])*X,B[r*3+2]=(q[2]*$+q[6]*J+q[10]*K+q[14])*X,R[r]=H,r++}}}}function w(T,I){let E=[],B=I.filter(V=>V.enabled&&V.mode==="Include").map(V=>V.type==="Box"?P(V):D(V)),R=I.filter(V=>V.enabled&&V.mode==="Exclude").map(V=>V.type==="Box"?P(V):D(V)),F=T.length;for(let V=0;V<F;V+=3){let q=T[V],k=T[V+1],U=T[V+2];(B.length===0||_(q,k,U,B))&&(R.length===0||!_(q,k,U,R))||E.push(V/3)}return console.log(E),E}function _(T,I,E,B,R){return B[R==="Intersect"?"every":"some"](F=>{let V=S(T,I,E,F.invRotationMatrix,F.cropCenter);return Array.isArray(F)?x(V.x,V.y,V.z,F):N(V.x,V.y,V.z,F)})}function S(T,I,E,B,R){let F=T-R[0],V=I-R[1],q=E-R[2],k=1/(B[3]*F+B[7]*V+B[11]*q+B[15]);return{x:(B[0]*F+B[4]*V+B[8]*q+B[12])*k+R[0],y:(B[1]*F+B[5]*V+B[9]*q+B[13])*k+R[1],z:(B[2]*F+B[6]*V+B[10]*q+B[14])*k+R[2]}}function P(T){let I=T.cropSize[0]/2,E=T.cropSize[1]/2,B=T.cropSize[2]/2,R=[T.cropCenter[0]-I,T.cropCenter[1]-E,T.cropCenter[2]-B,T.cropCenter[0]+I,T.cropCenter[1]+E,T.cropCenter[2]+B],F=O(T.cropRotation);return Object.assign(R,{invRotationMatrix:F,cropCenter:T.cropCenter})}function O(T){let I=[],E=T[0]*Math.PI/180,B=T[1]*Math.PI/180,R=T[2]*Math.PI/180,F=Math.cos(E),V=Math.sin(E),q=Math.cos(B),k=Math.sin(B),U=Math.cos(R),H=Math.sin(R),$=F*U,J=F*H,K=V*U,X=V*H;return I[0]=q*U,I[1]=-q*H,I[2]=k,I[4]=J+K*k,I[5]=$-X*k,I[6]=-V*q,I[8]=X-$*k,I[9]=K+J*k,I[10]=F*q,I[12]=0,I[13]=0,I[14]=0,I[3]=0,I[7]=0,I[11]=0,I[15]=1,I}function x(T,I,E,B){return T>=B[0]&&T<=B[3]&&I>=B[1]&&I<=B[4]&&E>=B[2]&&E<=B[5]}function D(T){let I=2/T.cropSize[0],E=2/T.cropSize[1],B=2/T.cropSize[2],R=O(T.cropRotation);return{invRadiusX:I,invRadiusY:E,invRadiusZ:B,cropCenter:T.cropCenter,invRotationMatrix:R}}function N(T,I,E,B){let R=(T-B.cropCenter[0])*B.invRadiusX,F=(I-B.cropCenter[1])*B.invRadiusY,V=(E-B.cropCenter[2])*B.invRadiusZ;return R*R+F*F+V*V<=1}n.onmessage=T=>{if(T.data.getCroppedIndexes){let I=new Uint32Array(w(new Float32Array(T.data.positions),T.data.crops)).buffer;n.postMessage({outOfBoundsIndexes:I},[I])}else if(T.data.positions)d=T.data.positions,f=new Float32Array(d),m=T.data.meshMatrixWorlds,y=T.data.cropsArray,h=T.data.meshIndexIntervals,b(m,y,h),n.postMessage({sortSetupComplete:!0});else if(T.data.sort||T.data.newMatrixWorlds||T.data.newCropsArray)(T.data.newMatrixWorlds||T.data.newCropsArray)&&(y=T.data.newCropsArray||y,m=T.data.newMatrixWorlds||m,b(m,y,h)),g(T.data.sort.view,T.data.sort.cameraPosition);else if(T.data.init){p=T.data.init.Constants,e=T.data.init.splatCount;let I=p.BytesPerInt,E=p.BytesPerFloat*3,B=new Uint8Array(T.data.init.sorterWasmBytes),R=I+E,F=e*R,V=e*p.BytesPerInt*2+p.DepthMapRange*p.BytesPerInt*2,q=p.MemoryPageSize*32,k=F+V+q,U=Math.floor(k/p.MemoryPageSize)+1,H={module:{},env:{memory:new WebAssembly.Memory({initial:U*2,maximum:U*3,shared:!0})}};WebAssembly.compile(B).then($=>WebAssembly.instantiate($,H)).then($=>{t=$,o=0,i=e*I,a=i+e*E,u=a+16*p.BytesPerFloat*2,s=u+e*p.BytesPerInt,l=s+p.DepthMapRange*p.BytesPerInt,c=H.env.memory.buffer,n.postMessage({sortSetupPhase1Complete:!0})})}}}function s1(n){let t=new Worker(URL.createObjectURL(new Blob(["(",AE.toString(),")(self)"],{type:"application/javascript"}))),e=atob(a1),r=new Uint8Array(e.length);for(let o=0;o<e.length;o++)r[o]=e.charCodeAt(o);return t.postMessage({init:{sorterWasmBytes:r.buffer,splatCount:n,Constants:{BytesPerFloat:Do.BytesPerFloat,BytesPerInt:Do.BytesPerInt,DepthMapRange:Do.DepthMapRange,MemoryPageSize:Do.MemoryPageSize}}}),t}import{Matrix4 as GE,Quaternion as d1,Vector2 as FE,Vector3 as Es}from"three";import{BufferAttribute as _E,BufferGeometry as PE,Color as OE,DataTexture as Td,DataUtils as CE,DoubleSide as TE,DynamicDrawUsage as ME,FloatType as c1,HalfFloatType as IE,InstancedBufferAttribute as NE,InstancedBufferGeometry as DE,Mesh as EE,NormalBlending as BE,RGBAFormat as LE,RGBAIntegerFormat as RE,RGFormat as u1,ShaderMaterial as VE,UnsignedIntType as zE,Vector2 as Un}from"three";var Cd=function(){let n=new Float32Array(1),t=new Int32Array(n.buffer);return function(e){return n[0]=e,t[0]}}(),l1=function(n,t,e,r){return n+(t<<8)+(e<<16)+(r<<24)};var Md=new Un,Hn=class extends EE{constructor(e,r,o,i,a=!1,s=1,l,u){super(o,i);this.splatCount=r,this.meshIndexIntervals=l,this.meshMatrixWorlds=u,this.splatBuffers=e,this.geometry=o,this.material=i,this.splatDataTextures=null,this.halfPrecisionCovariancesOnGPU=a,this.devicePixelRatio=s,this.resetLocalSplatDataAndTexturesFromSplatBuffer()}static buildMesh(e,r,o=!1,i=1,a,s){let l=Hn.buildGeomtery(r),u=Hn.buildMaterial(a);return new Hn(e,r,l,u,o,i,a,s)}static buildMaterial(e){let r=`
3509
+ `;let a=new TextEncoder().encode(o),s=r*2*4,l=t.xyz.quantized.data.buffer.byteLength,u=t.xyz instanceof rt?s:0,c=t.color.quantized.data.buffer.byteLength,d=t.color instanceof rt?s:0,p=t.opacity.quantized.data.buffer.byteLength,f=t.opacity instanceof rt?s:0,h=t.scaling.quantized.data.buffer.byteLength,m=t.scaling instanceof rt?s:0,y=t.quaternion.quantized.data.buffer.byteLength,g=t.quaternion instanceof rt?s:0,b=t.variableChunkSize?Uint16Array.from(t.variableChunkSize):void 0,w=b?b.byteLength:0,A=a.byteLength+w+l+u+c+d+p+f+h+m+y+g,S=0,P=0;if(t.harmonics&&t.harmonics.length>0)for(let D=0;D<t.harmonics.length;D++)S+=t.harmonics[D].quantized.data.buffer.byteLength,P+=t.harmonics[D]instanceof rt?s:0;S=0,P=0,A+=S+P;let O=new Uint8Array(A),x=0;if(O.set(a,x),x+=a.byteLength,w>0&&(O.set(new Uint8Array(b.buffer),x),x+=w),t.xyz instanceof rt&&(O.set(new Uint8Array(t.xyz.minmaxMatrix.data.buffer),x),x+=s),O.set(new Uint8Array(t.xyz.quantized.data.buffer),x),x+=l,t.color instanceof rt&&(O.set(new Uint8Array(t.color.minmaxMatrix.data.buffer),x),x+=s),O.set(new Uint8Array(t.color.quantized.data.buffer),x),x+=c,t.opacity instanceof rt&&(O.set(new Uint8Array(t.opacity.minmaxMatrix.data.buffer),x),x+=s),O.set(new Uint8Array(t.opacity.quantized.data.buffer),x),x+=p,t.scaling instanceof rt&&(O.set(new Uint8Array(t.scaling.minmaxMatrix.data.buffer),x),x+=s),O.set(new Uint8Array(t.scaling.quantized.data.buffer),x),x+=h,t.quaternion instanceof rt&&(O.set(new Uint8Array(t.quaternion.minmaxMatrix.data.buffer),x),x+=s),O.set(new Uint8Array(t.quaternion.quantized.data.buffer),x),x+=y,S>0&&t.harmonics&&t.harmonics.length>0)for(let D=0;D<t.harmonics.length;D++){let N=t.harmonics[D];N instanceof rt&&(O.set(new Uint8Array(N.minmaxMatrix.data.buffer),x),x+=s),O.set(new Uint8Array(N.quantized.data.buffer),x),x+=N.quantized.data.byteLength}return new jn(O.buffer)}};var u1="AGFzbQEAAAAADwhkeWxpbmsuMAEEAAAAAAETA2AAAGAIf39/f39/f38AYAABfwISAQNlbnYGbWVtb3J5AgMAgIAEAwQDAAECBzkDEV9fd2FzbV9jYWxsX2N0b3JzAAALc29ydEluZGV4ZXMAARNlbXNjcmlwdGVuX3Rsc19pbml0AAIK3gMDAwABC9IDAwF/BnwBfgJAIAdFDQAgAysDUCEMIAMrAzAhDSADKwMQIQ5BACEDRP///////+9/IQtEAAAAAAAAEAAhCgNAIAIgA0ECdGoCfyAOIAEgA0EMbGoiCCoCALuiIA0gCCoCBLuioCAMIAgqAgi7oqBEAAAAAAAAsECiIgmZRAAAAAAAAOBBYwRAIAmqDAELQYCAgIB4CzYCACAJIAsgCSALYxshCyAJIAogCSAKZBshCiADQQFqIgMgB0cNAAsgB0UNACAGuCAKIAuhoyEJQQAhAwNAAn8gCSACIANBAnRqIgEoAgC3IAuhoiIKmUQAAAAAAADgQWMEQCAKqgwBC0GAgICAeAshCCABIAg2AgAgBCAIQQJ0aiIBIAEoAgBBAWo2AgAgA0EBaiIDIAdHDQALCyAGQQJPBEAgBCgCACEIQQEhAwNAIAQgA0ECdGoiASABKAIAIAhqIgg2AgAgA0EBaiIDIAZHDQALCyAHQQFrIgGtIQ8DQCAEIAIgD6dBAnQiA2ooAgBBAnRqIgcgBygCAEEBayIHNgIAIAUgASAHa0ECdGogACADaigCADYCACAPUCEDIA9CAX0hDyADRQ0ACyAGBEAgBEEAIAZBAnT8CwALCwQAQQAL";var Do=class{};Lt(Do,"DepthMapRange",1<<16),Lt(Do,"MemoryPageSize",65536),Lt(Do,"BytesPerFloat",4),Lt(Do,"BytesPerInt",4);function TE(n){let t,e,r,o,i,a,s,l,u,c,d,p,f,h,m,y;function g(T){let I=new Float64Array(c,a,16);for(let B=0;B<16;B++)I[B]=T[B];let E;if(r>1){t.exports.sortIndexes(o,i,u,a,s,l,p.DepthMapRange,r);let B=new Uint32Array(r);E=B.buffer,B.set(new Uint32Array(c,l,r))}else if(r===1){let B=new Uint32Array(r);B[0]=new Uint32Array(c,o,e)[0],E=B.buffer}else E=new ArrayBuffer(0);n.postMessage({sortDone:!0,indexesBuffer:E},[E])}function b(T,I,E){let B=new Float32Array(c,i,e*3);r=0;let R=new Uint32Array(c,o,e);for(let F=0;F<E.length-1;F++){let V=I[F],q=T[F].elements,k=V.filter(H=>H.enabled&&H.mode==="Include").map(H=>H.type==="Box"?P(H):D(H)),U=V.filter(H=>H.enabled&&H.mode==="Exclude").map(H=>H.type==="Box"?P(H):D(H));for(let H=E[F];H<E[F+1];H++){let Y=f[H*3],J=f[H*3+1],Z=f[H*3+2];if((k.length===0||A(Y,J,Z,k))&&(U.length===0||!A(Y,J,Z,U))){let X=1/(q[3]*Y+q[7]*J+q[11]*Z+q[15]);B[r*3]=(q[0]*Y+q[4]*J+q[8]*Z+q[12])*X,B[r*3+1]=(q[1]*Y+q[5]*J+q[9]*Z+q[13])*X,B[r*3+2]=(q[2]*Y+q[6]*J+q[10]*Z+q[14])*X,R[r]=H,r++}}}}function w(T,I){let E=[],B=I.filter(V=>V.enabled&&V.mode==="Include").map(V=>V.type==="Box"?P(V):D(V)),R=I.filter(V=>V.enabled&&V.mode==="Exclude").map(V=>V.type==="Box"?P(V):D(V)),F=T.length;for(let V=0;V<F;V+=3){let q=T[V],k=T[V+1],U=T[V+2];(B.length===0||A(q,k,U,B))&&(R.length===0||!A(q,k,U,R))||E.push(V/3)}return console.log(E),E}function A(T,I,E,B,R){return B[R==="Intersect"?"every":"some"](F=>{let V=S(T,I,E,F.invRotationMatrix,F.cropCenter);return Array.isArray(F)?x(V.x,V.y,V.z,F):N(V.x,V.y,V.z,F)})}function S(T,I,E,B,R){let F=T-R[0],V=I-R[1],q=E-R[2],k=1/(B[3]*F+B[7]*V+B[11]*q+B[15]);return{x:(B[0]*F+B[4]*V+B[8]*q+B[12])*k+R[0],y:(B[1]*F+B[5]*V+B[9]*q+B[13])*k+R[1],z:(B[2]*F+B[6]*V+B[10]*q+B[14])*k+R[2]}}function P(T){let I=T.cropSize[0]/2,E=T.cropSize[1]/2,B=T.cropSize[2]/2,R=[T.cropCenter[0]-I,T.cropCenter[1]-E,T.cropCenter[2]-B,T.cropCenter[0]+I,T.cropCenter[1]+E,T.cropCenter[2]+B],F=O(T.cropRotation);return Object.assign(R,{invRotationMatrix:F,cropCenter:T.cropCenter})}function O(T){let I=[],E=T[0]*Math.PI/180,B=T[1]*Math.PI/180,R=T[2]*Math.PI/180,F=Math.cos(E),V=Math.sin(E),q=Math.cos(B),k=Math.sin(B),U=Math.cos(R),H=Math.sin(R),Y=F*U,J=F*H,Z=V*U,X=V*H;return I[0]=q*U,I[1]=-q*H,I[2]=k,I[4]=J+Z*k,I[5]=Y-X*k,I[6]=-V*q,I[8]=X-Y*k,I[9]=Z+J*k,I[10]=F*q,I[12]=0,I[13]=0,I[14]=0,I[3]=0,I[7]=0,I[11]=0,I[15]=1,I}function x(T,I,E,B){return T>=B[0]&&T<=B[3]&&I>=B[1]&&I<=B[4]&&E>=B[2]&&E<=B[5]}function D(T){let I=2/T.cropSize[0],E=2/T.cropSize[1],B=2/T.cropSize[2],R=O(T.cropRotation);return{invRadiusX:I,invRadiusY:E,invRadiusZ:B,cropCenter:T.cropCenter,invRotationMatrix:R}}function N(T,I,E,B){let R=(T-B.cropCenter[0])*B.invRadiusX,F=(I-B.cropCenter[1])*B.invRadiusY,V=(E-B.cropCenter[2])*B.invRadiusZ;return R*R+F*F+V*V<=1}n.onmessage=T=>{if(T.data.getCroppedIndexes){let I=new Uint32Array(w(new Float32Array(T.data.positions),T.data.crops)).buffer;n.postMessage({outOfBoundsIndexes:I},[I])}else if(T.data.positions)d=T.data.positions,f=new Float32Array(d),m=T.data.meshMatrixWorlds,y=T.data.cropsArray,h=T.data.meshIndexIntervals,b(m,y,h),n.postMessage({sortSetupComplete:!0});else if(T.data.sort||T.data.newMatrixWorlds||T.data.newCropsArray)(T.data.newMatrixWorlds||T.data.newCropsArray)&&(y=T.data.newCropsArray||y,m=T.data.newMatrixWorlds||m,b(m,y,h)),g(T.data.sort.view,T.data.sort.cameraPosition);else if(T.data.init){p=T.data.init.Constants,e=T.data.init.splatCount;let I=p.BytesPerInt,E=p.BytesPerFloat*3,B=new Uint8Array(T.data.init.sorterWasmBytes),R=I+E,F=e*R,V=e*p.BytesPerInt*2+p.DepthMapRange*p.BytesPerInt*2,q=p.MemoryPageSize*32,k=F+V+q,U=Math.floor(k/p.MemoryPageSize)+1,H={module:{},env:{memory:new WebAssembly.Memory({initial:U*2,maximum:U*3,shared:!0})}};WebAssembly.compile(B).then(Y=>WebAssembly.instantiate(Y,H)).then(Y=>{t=Y,o=0,i=e*I,a=i+e*E,u=a+16*p.BytesPerFloat*2,s=u+e*p.BytesPerInt,l=s+p.DepthMapRange*p.BytesPerInt,c=H.env.memory.buffer,n.postMessage({sortSetupPhase1Complete:!0})})}}}function d1(n){let t=new Worker(URL.createObjectURL(new Blob(["(",TE.toString(),")(self)"],{type:"application/javascript"}))),e=atob(u1),r=new Uint8Array(e.length);for(let o=0;o<e.length;o++)r[o]=e.charCodeAt(o);return t.postMessage({init:{sorterWasmBytes:r.buffer,splatCount:n,Constants:{BytesPerFloat:Do.BytesPerFloat,BytesPerInt:Do.BytesPerInt,DepthMapRange:Do.DepthMapRange,MemoryPageSize:Do.MemoryPageSize}}}),t}import{Matrix4 as HE,Quaternion as m1,Vector2 as qE,Vector3 as Bs}from"three";import{BufferAttribute as ME,BufferGeometry as IE,Color as NE,DataTexture as Md,DataUtils as DE,DoubleSide as EE,DynamicDrawUsage as BE,FloatType as f1,HalfFloatType as LE,InstancedBufferAttribute as RE,InstancedBufferGeometry as VE,Mesh as zE,NormalBlending as GE,RGBAFormat as FE,RGBAIntegerFormat as kE,RGFormat as h1,ShaderMaterial as jE,UnsignedIntType as UE,Vector2 as Un}from"three";var Td=function(){let n=new Float32Array(1),t=new Int32Array(n.buffer);return function(e){return n[0]=e,t[0]}}(),p1=function(n,t,e,r){return n+(t<<8)+(e<<16)+(r<<24)};var Id=new Un,Hn=class extends zE{constructor(e,r,o,i,a=!1,s=1,l,u){super(o,i);this.splatCount=r,this.meshIndexIntervals=l,this.meshMatrixWorlds=u,this.splatBuffers=e,this.geometry=o,this.material=i,this.splatDataTextures=null,this.halfPrecisionCovariancesOnGPU=a,this.devicePixelRatio=s,this.resetLocalSplatDataAndTexturesFromSplatBuffer()}static buildMesh(e,r,o=!1,i=1,a,s){let l=Hn.buildGeomtery(r),u=Hn.buildMaterial(a);return new Hn(e,r,l,u,o,i,a,s)}static buildMaterial(e){let r=`
3510
3510
  precision highp float;
3511
3511
  #include <common>
3512
3512
 
@@ -3660,4 +3660,4 @@ end_header
3660
3660
  A = exp(A) * vColor.a;
3661
3661
  gl_FragColor = vec4(color.rgb, A);
3662
3662
  gVelocity = vec4(0.0); // so it is ignored by TAA
3663
- }`,i={covariancesTexture:{type:"t",value:null},centersColorsTexture:{type:"t",value:null},meshIndexIntervals:{value:e},meshMatrixWorldsTexture:{type:"t",value:null},focal:{type:"v2",value:new Un},viewport:{type:"v2",value:new Un},basisViewport:{type:"v2",value:new Un},debugColor:{type:"v3",value:new OE},covariancesTextureSize:{type:"v2",value:new Un(1024,1024)},centersColorsTextureSize:{type:"v2",value:new Un(1024,1024)},orthoZoom:{type:"f",value:-1}};return new VE({uniforms:i,vertexShader:r,fragmentShader:o,transparent:!0,alphaTest:1,blending:BE,depthTest:!0,depthWrite:!1,side:TE})}static buildGeomtery(e){let r=new PE;r.setIndex([0,1,2,0,2,3]);let o=new Float32Array(4*3),i=new _E(o,3);r.setAttribute("position",i),i.setXYZ(0,-1,-1,0),i.setXYZ(1,-1,1,0),i.setXYZ(2,1,1,0),i.setXYZ(3,1,-1,0),i.needsUpdate=!0;let a=new DE().copy(r),s=new Uint32Array(e),l=new NE(s,1,!1);return l.setUsage(ME),a.setAttribute("splatIndex",l),a.instanceCount=e,a}resetLocalSplatDataAndTexturesFromSplatBuffer(){this.updateLocalSplatDataFromSplatBuffer(),this.allocateAndStoreLocalSplatDataInTextures()}updateLocalSplatDataFromSplatBuffer(){this.splatBuffers.forEach(i=>i.buildPreComputedBuffers()),this.covariances=new Float32Array(this.splatCount*6),this.colors=new Uint8Array(this.splatCount*4),this.centers=new Float32Array(this.splatCount*3);let e=0,r=0,o=0;for(let i of this.splatBuffers){let a=i.nsplats;this.colors.subarray(e,e+a*4).set(i.colorsA),e+=a*4,this.centers.subarray(r,r+a*3).set(i.decoded.xyz.denormDequant().data),r+=a*3,this.covariances.subarray(o,o+a*6).set(new Float32Array(i.precomputedCovarianceBufferData)),o+=a*6}}allocateAndStoreLocalSplatDataInTextures(){let o=this.splatCount,i=new Un(4096,1024);for(;i.x*i.y*2<o*6;)i.y*=2;let a=new Un(4096,1024);for(;a.x*a.y*4<o*4;)a.y*=2;let s,l;if(this.halfPrecisionCovariancesOnGPU){l=new Uint16Array(i.x*i.y*2);for(let h=0;h<this.covariances.length;h++)l[h]=CE.toHalfFloat(this.covariances[h]);s=new Td(l,i.x,i.y,u1,IE)}else l=new Float32Array(i.x*i.y*2),l.set(this.covariances),s=new Td(l,i.x,i.y,u1,c1);s.needsUpdate=!0,this.material.uniforms.covariancesTexture.value=s,this.material.uniforms.covariancesTextureSize.value.copy(i);let u=new Uint32Array(a.x*a.y*4);for(let h=0;h<o;h++){let m=h*4,y=h*3,g=h*4;u[g]=l1(this.colors[m],this.colors[m+1],this.colors[m+2],this.colors[m+3]),u[g+1]=Cd(this.centers[y]),u[g+2]=Cd(this.centers[y+1]),u[g+3]=Cd(this.centers[y+2])}let c=new Td(u,a.x,a.y,RE,zE);c.internalFormat="RGBA32UI",c.needsUpdate=!0,this.material.uniforms.centersColorsTexture.value=c,this.material.uniforms.centersColorsTextureSize.value.copy(a);let d=256*4,p=new Float32Array(256*16);for(let h=0;h<this.meshMatrixWorlds.length;h++)p.set(this.meshMatrixWorlds[h].elements,h*16);let f=new Td(p,d,1,LE,c1);f.needsUpdate=!0,this.material.uniforms.meshMatrixWorldsTexture.value=f,this.material.uniformsNeedUpdate=!0,this.splatDataTextures={covariances:{data:l,texture:s,size:i},centerColors:{data:u,texture:c,size:a},meshMatrixWorlds:{data:p,texture:f}}}updateIndexes(e){let r=this.geometry;r.attributes.splatIndex.set(e),r.attributes.splatIndex.needsUpdate=!0,r.instanceCount=e.length}updateUniforms(e,r,o,i){this.splatCount>0&&(Md.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(Md),this.material.uniforms.basisViewport.value.set(2/Md.x,2/Md.y),this.material.uniforms.focal.value.set(r,o),this.material.uniforms.orthoZoom.value=i,this.material.uniformsNeedUpdate=!0)}getSplatDataTextures(){return this.splatDataTextures}getSplatCount(){return this.splatCount}getCenters(){return this.centers}getColors(){return this.colors}getCovariances(){return this.covariances}dispose(){this.geometry.dispose(),this.material.dispose(),this.splatDataTextures&&(this.splatDataTextures.covariances.texture.dispose(),this.splatDataTextures.centerColors.texture.dispose(),this.splatDataTextures.meshMatrixWorlds.texture.dispose())}};var kl=class{constructor(t={}){Lt(this,"updateSplatMeshUniforms",function(){let t=new FE;return function(){if(this.splatMesh===null)return;this.splatMesh.getSplatCount()>0&&(this.renderer.getSize(t),this.cameraFocalLengthX=this.camera.projectionMatrix.elements[0]*this.devicePixelRatio*t.x*.45,this.cameraFocalLengthY=this.camera.projectionMatrix.elements[5]*this.devicePixelRatio*t.y*.45,this.splatMesh.updateUniforms(t,this.cameraFocalLengthX,this.cameraFocalLengthY,this.camera.isPerspectiveCamera?-1:this.camera.zoom*this.devicePixelRatio))}}());Lt(this,"updateView",function(){let t=new GE,e=[],r=new Es(0,0,-1),o=new Es(0,0,-1),i=new Es,a=new Es;return function(s=!1){let l=this.updateMatrixWorldsInWorkerIfNeeded(),u=this.cropsChanged();if(!s){o.set(0,0,-1).applyQuaternion(this.camera.quaternion);let d=!1,p=!1;if(o.dot(r)<=.95&&(d=!0),a.copy(this.camera.position).sub(i).length()>=1&&(p=!0),!d&&!p&&!l&&!u)return}i.copy(this.camera.position),r.copy(o),t.copy(this.camera.matrixWorld).invert(),t.premultiply(this.camera.perspCamera.projectionMatrix),e[0]=this.camera.position.x,e[1]=this.camera.position.y,e[2]=this.camera.position.z;let c={sort:{view:t.elements,cameraPosition:e,splatRenderCount:this.splatRenderCount,splatSortCount:this.splatRenderCount},...l?{newMatrixWorlds:this.meshMatrixWorlds}:{},...u?{newCropsArray:this.cropsArray}:{}};this.sortRunning?this.queuedMessage=c:(this.queuedMessage=null,this.sortRunning=!0,this.sortWorker.postMessage(c))}}());this.scene=t.scene,this.currentPage=null,this.renderer=t.renderer,this.devicePixelRatio=window.devicePixelRatio,this.sortWorker=null,this.splatRenderCount=0,this.splatSortCount=0,this.splatMesh=null,this.sortRunning=!1,this.splatRenderingInitialized=!1,this.meshMatrixWorlds=null,this.meshMatrixWorldsOld=null,this.cropsArray=null,this.splatEntries=null,this.queuedMessage=null}get camera(){return this.scene.activeCamera}reloadSplats(){this.splatRenderingInitialized=!1;let t=this.loadSplat();this.renderer.pipeline.opaquePass.splatViewer=t?this:null}loadSplat(t={}){this.activePage=this.scene.activePage,t.position&&(t.position=new Es().fromArray(t.position)),t.orientation&&(t.orientation=new d1().fromArray(t.orientation)),t.halfPrecisionCovariances=!!t.halfPrecisionCovariances;let e=[];if(this.splatEntries=e,this.activePage.traverseEntity(a=>{if(a.data.type==="Splat"){let s=a.visible;a.traverseAncestors(l=>{s&&(s=l.visible)}),s&&e.push(a)}}),this.splatMesh&&this.splatMesh.dispose(),e.length===0)return this.splatMesh=null,!1;this.meshMatrixWorlds=e.map(a=>a.matrixWorld),this.meshMatrixWorldsOld=e.map(a=>a.matrixWorld.clone()),this.cropsArray=e.map(a=>a.data.crops.map(s=>s.data));let r=e.map(a=>new jn(new Uint8Array(a.data.buffer).buffer)),o=0,i=[0];for(let a of r)o+=a.getSplatCount(),i.push(o);return this.setupSplatMesh(r,o,t.position,t.orientation,t.halfPrecisionCovariances,this.devicePixelRatio,i,this.meshMatrixWorlds),this.setupSortWorker(o),!0}updateMatrixWorldsInWorkerIfNeeded(){let t=this.splatDataTextures.meshMatrixWorlds.data;for(let e=0;e<this.meshMatrixWorlds.length;e++)t.set(this.meshMatrixWorlds[e].elements,e*16);return this.splatDataTextures.meshMatrixWorlds.texture.needsUpdate=!0,this.meshMatrixWorlds.every((e,r)=>e.equals(this.meshMatrixWorldsOld[r]))?!1:(this.meshMatrixWorldsOld=this.meshMatrixWorlds.map(e=>e.clone()),!0)}cropsChanged(){let t=!1;return this.splatEntries.forEach((e,r)=>{e.data.crops.forEach((o,i)=>{this.cropsArray[r][i]===void 0?(t=!0,this.cropsArray[r][i]=o.data):Object.entries(o.data).forEach(([a,s])=>{Array.isArray(s)&&s.some((l,u)=>l!==this.cropsArray[r][i][a][u])?(t=!0,this.cropsArray[r][i][a]=s):s!==this.cropsArray[r][i]?.[a]&&(t=!0,this.cropsArray[r][i][a]=s)})}),e.data.crops.length!==this.cropsArray[r]?.length&&(this.cropsArray[r].length=e.data.crops.length,t=!0)}),t}setupSplatMesh(t,e,r=new Es,o=new d1,i=!1,a=1,s,l){this.splatMesh=Hn.buildMesh(t,e,i,a,s,l),this.splatMesh.position.copy(r),this.splatMesh.quaternion.copy(o),this.splatMesh.frustumCulled=!1,this.splatMesh.renderOrder=10,this.updateSplatMeshUniforms(),this.splatRenderCount=e}setupSortWorker(t){this.sortWorker=s1(t),this.sortWorker.onmessage=e=>{e.data.sortDone?(this.sortRunning=!1,this.splatMesh?.updateIndexes(new Uint32Array(e.data.indexesBuffer)),this.lastSortTime=e.data.sortTime,this.queuedMessage&&(this.sortWorker.postMessage(this.queuedMessage),this.queuedMessage=null)):e.data.sortCanceled?this.sortRunning=!1:e.data.sortSetupPhase1Complete?this.sortWorker.postMessage({positions:this.splatMesh.getCenters().buffer,meshMatrixWorlds:this.splatMesh.meshMatrixWorlds,meshIndexIntervals:this.splatMesh.meshIndexIntervals,cropsArray:this.cropsArray}):e.data.sortSetupComplete&&(this.splatDataTextures=this.splatMesh.getSplatDataTextures(),this.updateView(!0,!0),this.splatRenderingInitialized=!0)}}update(){this.splatRenderingInitialized!==!1&&(this.updateSplatMeshUniforms(),this.updateView())}getSplatMesh(){return this.splatMesh}};var $E=new qE;$E.wireframe=!0;var p1=new jE,Id=class extends kE{constructor(e,r){super();this.data=e;this.sharedAssets=r;this.enableHelpers=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this.needsNormalDirty=!0;this._needsTransmission=!1;this._needsNormal=!1;this.geometryCacheChanged=!1;this.splatViewer=null;this.entityByUuid={};this.entityIdentityToEntity={};this.toExpandCloner=new Set;this.toUpdateCloner=new Set;this.pendingCommands=[];this.pathConstraints=new _d;this.invisibleObjects=new Rn("jflkdsafjasdifjaslk",{...Qc.defaultData,visible:!1,name:"buildin invisible"});this.needsRecomputeInstances=!1;this.init(e,r),this.matrixAutoUpdate=!1,this.errorPage=new zr("fdasfa",{...Go.defaultData,name:""},{shared:r,scene:this})}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=IS(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=MS(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let r=e.identity.join("-"),o=this.entityIdentityToEntity[r];o&&(e.uuid=o.uuid),this.entityIdentityToEntity[r]=e,this.entityByUuid[e.uuid]=e}markPenumbraSizeDirty(){for(let e of this.children)e instanceof zr&&(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 r=this.find(e);if(r===void 0)return;let o=[],i=r;for(;i!==this;){let a=i;i=i.parent;let s=i.children.indexOf(a);o.splice(0,0,s)}return{entity:r,sortKey:o}}getAllSorted(e){let r=[];for(let o of e){let i=this.getWithSortKey(o.id);i!==void 0&&r.push(i)}return r.sort((o,i)=>Ql(o.sortKey,i.sortKey)),r.map(o=>o.entity)}nonExistOrDescendantOf(e,r){let o=this.find(e);if(o===void 0)return!0;for(;o;){if(o.uuid===r)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===bn)return this.activePage.personalCamera}if(e===""||e===void 0)return;let r=this.entityByUuid[e];return r===void 0?this.getObjectByProperty("uuid",e):r}find2D(e){for(let r of this.children)if(r instanceof zr&&r.uiScene){let o=r.uiScene.find(e);if(o)return o}}findScene2DfromObject2D(e){for(let r of this.children)if(r instanceof zr&&r.uiScene&&r.uiScene.find(e))return r.uiScene}find2DInUIObjects(e){let r;return this.traverseEntity(o=>{r===void 0&&o instanceof Pi&&(r=o.uiCanvas.find(e))}),r}traverse2D(e){for(let r of this.children)r instanceof zr&&r.uiScene&&r.uiScene.traverse(e)}debugEnsureEntity(e){let r=this.find(e);if(r){if(Array.isArray(r.identity)&&this.findInstance(r.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(r=>{this.toExpandCloner.add(r)})}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}updateByLibOp(e,r){e.path.length===1&&e.path[0]==="components"&&e.type===1&&this.createChildrenObjects([{...e.data.asset,id:e.id}],this.invisibleObjects,r)}updateTreeByOp(e,r){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,r);i.updateVisible(this),i.resetBBoxNeedsUpdate(),Ln(i)&&Nl(i.parent)&&(i.invalidateUpstreamBooleanData(),i.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(o),this.markNeedsRecomputeInstancesForChildren(i),this.markToExpandCloner(i),this.markPenumbraSizeDirty(),i.updatePathSnapping()}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),Nl(o.parent)&&(o.parent.invalidateUpstreamBooleanData(),o.parent.invalidateDownstreamBooleanData().recomputeBoolean()),Ln(o)&&(o.freeBooleanPointer(),i instanceof yr&&i.invalidateDownstreamBooleanData().recomputeBoolean()),o instanceof Ms&&o.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(o),this.pathConstraints.removeDependencies(o.uuid),o.updatePathSnapping()}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 a=e.parent===null?this:this.find(e.parent);if(a===void 0)throw new Error("unexpected");a.add(o),this.markNeedsRecomputeInstancesForAncessors(a),this.markToExpandCloner(o),o.invalidateClonerTransform(o),o.updateVisible(this),o.resetBBoxNeedsUpdate(),this.markPenumbraSizeDirty();let s=e.localIndex;a.children.splice(s,0,a.children.pop()),Ln(o)&&(o.invalidateUpstreamBooleanData(),Nl(o.parent)?o.parent.invalidateDownstreamBooleanData().recomputeBoolean():i instanceof yr&&i.invalidateDownstreamBooleanData().recomputeBoolean()),o.updatePathSnapping()}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 r of this.children)r instanceof zr&&(r.visible=r.uuid===e,r.visible&&(this.activePage=r,this.activePage.onActive(this)));this.activePage!==this.splatViewer?.activePage&&this.reloadSplats()}updateEntityByOp(e,r,o,i){if(r.type===0){if(("overrides"in r.props||"component"in r.props)&&this.markNeedsRecomputeInstances(),"visible"in r.props&&this.markPenumbraSizeDirty(),r.path.includes("overrides")&&"states"in r.props){let{rest:s}=r.props;r={...r,props:s},this.markNeedsRecomputeInstances()}r.path[0]==="pathSnapping"&&r.props.pathId!==void 0&&this.pathConstraints.setConstraint(e,r.props.pathId)}let a=this.find(e);if(a)try{OS(a,r,o,{scene:this,shared:i}),a instanceof ft&&a.updateGeometryGroupsIfNeeded()}catch(s){console.error(s)}}updateEntity2DByOp(e,r,o,i,a,s=[]){e.updateEntityByOp(r,o,i,a),this.traverseEntity(l=>{(l instanceof Pi||l instanceof zr)&&(s.includes(l.frameId??"")||l.frameId===r)&&l.updateEntity2DByOp(r,o,i,a)})}get activeCamera(){return this.activePage.activeCamera}switchActiveCamera(e){this.activePage.switchActiveCamera(e)}isInvisibleObjects(e){return e===this.invisibleObjects||e.hasAnccestor(this.invisibleObjects)}init(e,r){let o=Object.entries(r.data.lib.components).map((i,a)=>({data:i[1].asset.data,children:i[1].asset.children,id:i[0],fi:a}));this.invisibleObjects.updateState(this.invisibleObjects.data,{scene:this,shared:r}),this.add(this.invisibleObjects),this.createChildrenObjects(o,this.invisibleObjects,r),this.createChildrenObjects(e.objects,this,r),this.updatePage(e.publish.playPage),this.activePage.switchToPlayCamera(),this.expandInstances(r,!0),this.traverseEntity(i=>{i instanceof rn&&i.updateUp()}),this.doPendingExpandCloner(),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(r=>{(r.data.type==="Component"||r.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){Re.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(r=>{Re.is(r)&&r.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,r,o,i,a,s,l){if(e){let u=i.find(e);u&&u!==i&&a.forInstancesRec(c=>{c.data=fn(c.data,d=>{let p=d.events.data(l.id),f=c.goUp(s);if(f){let h=[...Xl(f.identity),e].join("-"),m=this.entityIdentityToEntity[h];if(m){let y=m.uuid,g=lt.zoom(p,r);g[o]=y}else{if(!1)debugger;console.warn("cannot find instance")}}}).data})}}rewriteActions(e,r,o,i,a,s){e.forEach(l=>{l.data.type==="Transition"?this.relativeizeInner(l.data.object,[...r,l.id],"object",o,i,a,s):l.data.type==="Animation"&&this.relativeizeInner(l.data.object,[...r,l.id],"object",o,i,a,s)})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof an&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((r,o)=>{r.data.events.forEach(i=>{if(i.data.type==="GameControl"){let a=!1;if(r.forInstancesRec(s=>{s.data=fn(s.data,l=>{s.isInstanceRoot||(l.events.delete(i.id),a=!0)}).data}),a===!1)for(let s of eu.list)this.rewriteActions(i.data.gameActions[s],["gameActions",s],e,r,o,i)}else i.data.type==="Conditional"?(i.data.condition.type==="Distance"?(this.relativeizeInner(i.data.condition.fromObject,["condition"],"fromObject",e,r,o,i),this.relativeizeInner(i.data.condition.toObject,["condition"],"toObject",e,r,o,i)):i.data.condition.type==="State"?this.relativeizeInner(i.data.condition.object,["condition"],"object",e,r,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,r,o,i),i.data.condition.rOperand.type==="Property"&&this.relativeizeInner(i.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,r,o,i)),this.rewriteActions(i.data.inActions,["inActions"],e,r,o,i),this.rewriteActions(i.data.outActions,["outActions"],e,r,o,i)):"actions"in i.data&&this.rewriteActions(i.data.actions,["actions"],e,r,o,i)})}),!0})}expandInstances(e,r,o){let i=new Set;this.traverseEntity(a=>{if(a instanceof an&&a.isInstanceRoot)return a.expandInstanceChildren({scene:this,shared:e,pendingDeletes:i}),r||a.resetBBoxNeedsUpdate(),o&&a.traverseEntity(s=>{o.addClip(s)}),!0});for(let a of i)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(a),xd(a)}recomputeInstances(e,r){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(o=>{o instanceof an&&o.isInstanceRoot&&(o.component=void 0)}),this.expandInstances(e,!1,r))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(r=>{let o=typeof r.identity=="string"?r.identity:r.identity.join("-");this.entityIdentityToEntity[o]===r&&(delete this.entityByUuid[r.uuid],delete this.entityIdentityToEntity[o]),r.dispose()})}clearScene(){for(let e of this.children)Re.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,r){this.init(e,r)}raycast(e){return this.raycast1(e,!1)}raycast1(e,r){let o=[],i=a=>{for(let s of a.children){let l=s.cloner;if(Re.is(s)&&!s.raycastLock&&(s.visible||l?.object.data.visible))if(r===!0&&s.isInstanceRoot){let u=[];if(e.intersectObject(s,!0,u),u.length){let c=u[0];c.object=s,c.point.applyMatrix4(c.object.matrixWorld);let d=s.matrixWorld.clone().invert();c.point.applyMatrix4(d),o.push(c)}}else(Ln(s)||Dl(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,o),Gl(s,e,o)),i(s)}};return i(this.activePage),o}raycastWithClones(e){let r=[],o=i=>{for(let a of i.children){let s=a.cloner;Re.is(a)&&(a.visible||s?.object.data.visible)&&((Ln(a)||Dl(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,r),Gl(a,e,r,!0)),o(a))}};return o(this),r}forEachEntity(e){for(let r of this.children)Re.is(r)&&e(r)}traverseConcreteEntity(e){for(let r of this.children)Re.is(r)&&r.isConcreteEntity&&r.traverseEntity(e)}traverseEntity(e){for(let r of this.children)Re.is(r)&&r.traverseEntity(e)}updateFont(e,r){this.traverseEntity(o=>{if(o instanceof ft&&o.data.type==="Mesh"&&o.data.geometry.type==="TextGeometry"&&o.data.geometry.font===e){let i=o.geometry,a=o.data.geometry;i.updateFont(e,r).then(()=>{i.update(a);let s=o.invalidateDownstreamBooleanData();Nl(s)&&s.recomputeBoolean()})}})}traverseObject(e){for(let r of this.children)Aa.is(r)&&r.traverseObject(e)}traverseVisibleEntity(e){for(let r of this.children)Re.is(r)&&r.visible&&r.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,r,o){let i=0;for(let a of e)this.createObject(a.id,a.data,a.children,r,i,o),i+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let r of e.children)this.unregisterObject(r)}createObject(e,r,o,i,a,s){let l={scene:this,shared:s},u=Ad(e,r,l);return u&&(this.entityByUuid[e]=u,i.add(u),i.children.splice(a,0,i.children.pop()),o.length>0&&(u.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(o,u,s)),u.updateState(r,l),u instanceof ft&&u.updateGeometryGroupsIfNeeded(),u.updateVisible(this),u.cloner&&this.toExpandCloner.add(u),r.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,r.pathSnapping.pathId)),r.type==="Empty"&&r.animations&&u.traverseEntity(c=>{let d=c.dataPatched;if(c instanceof ft&&d.bones&&d.boneInverses){let p=d.bones.map(m=>this.find(m)),f=d.boneInverses.map(m=>new UE().fromArray(m)),h=new WE(p,f);c.bind(h,c.bindMatrix)}else c.matrixAutoUpdate=!0}),u}getCenter(e){let r=[];for(let i=0,a=e.length;i<a;++i){let{id:s,recursive:l}=e[i],u=this.find(s),c=l?u.recursiveBBox:u.singleBBox;r.push(...c.vertices)}let o=new HE;return o.setFromPoints(r),o.getCenter(p1),p1}copyMatrixWorld(e,r){if(e===null){r.identity();return}let o=this.find(e);o?r.copy(o.matrixWorld):r.identity()}copyParentMatrixWorld(e,r){if(e===null){r.identity();return}let o=this.find(e)?.parent;o?r.copy(o.matrixWorld):r.identity()}traverseMaterial(e){this.traverseEntity(r=>{if(r instanceof Dt)if(Array.isArray(r.material))for(let o=0;o<r.material.length;o++)r.material[o]instanceof hr&&e(r.material[o]);else r.material instanceof hr&&e(r.material)})}updateViewPlaneSize(e,r,o=!1){this.traverseConcreteEntity(i=>{i instanceof rn&&i.setViewplaneSize(e,r,o)})}initializeSplatViewer(e){this.splatViewer=new kl({scene:this,renderer:e}),this.reloadSplats()}reloadSplats(){this.splatViewer?.reloadSplats()}};import{DRACOLoader as YE}from"three/examples/jsm/loaders/DRACOLoader.js";var qn;function XE(){return qn||(qn=new YE,qn.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),qn.decoderPending}async function QE(n){if(qn){let t={attributeIDs:qn.defaultAttributeIDs,attributeTypes:qn.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await qn.decodeGeometry(new Int8Array(n).buffer,t)}catch(r){console.error(r)}if(e)return{index:e.index?{array:e.index.array}:void 0,attributes:Object.entries(e.attributes).map(([r,o])=>({name:r,itemSize:o.itemSize,array:o.array}))}}return null}async function f1(n,t){let[e,r]=Jd(Vc.deserialize(new Uint8Array(n)));ou(e);let o=[];e.scene.objects.traverse((i,a)=>{a.type==="Mesh"&&a.geometry.type==="NonParametricGeometry"&&a.geometry.data.draco!==void 0&&o.push(a)}),o.length&&await XE();for(let i of o){let a=await QE(ut(i.geometry.data.draco));if(a){a.index&&(i.geometry.data.index={array:a.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let s={};a.attributes.forEach(({name:l,array:u,itemSize:c})=>{s[l]={array:u,itemSize:c,type:"Float32Array",normalized:!1}}),i.geometry.data.attributes=s,i.geometry.data.draco=void 0}}return t&&t(e),r.result().data}import{Mesh as ufe}from"three";import{mergeBufferGeometries as ffe}from"three/examples/jsm/utils/BufferGeometryUtils.js";function h1(n){let t;if(!!n.index)for(let e=0;e<n.index.array.length;e+=3)t=n.index.array[e],n.index.array[e]=n.index.array[e+2],n.index.array[e+2]=t}import{Color as m1,ShaderLib as KE}from"three";function y1(n){let t=new Set;return n.traverse(e=>{if(e instanceof mr)if(yt(e.material))e.material.forEach(r=>{let o=r;t.has(o)||t.add(o)});else{let r=e.material;t.has(r)||t.add(r)}}),t.forEach(e=>{if(e instanceof Array)return;let r=e.onBeforeCompile.bind(e);if(ZE(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new m1,specularColor:new m1});let o=0;e.onBeforeCompile=(i,a)=>{r&&r(i,a),i.uniforms=Object.assign({},KE.physical.uniforms,i.uniforms),e.getLayersOfType("transmission").forEach(s=>{if(i.uniforms.transmissionSamplerMap.value){let l=s.color;l&&(l.transmissionSamplerMap.value=i.uniforms.transmissionSamplerMap.value,l.transmissionSamplerSize.value=i.uniforms.transmissionSamplerSize.value,l.aspectRatio.value=Nb(window.innerWidth,window.innerHeight),e.defines.IS_THREEJS_EXPORT=!0)}else o++,o<2&&(e.needsUpdate=!0)})}}else JE(e)||(e.onBeforeCompile=(o,i)=>{r&&r(o,i),e.transparent=!1})}),n}function ZE(n){return n.getLayersOfType("transmission").length>0}function JE(n){let t=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&&(t+=(1-t)*o.value)}}return t<1}function g1(n){return n.traverse(t=>{if(t.type==="Camera"){let e=t;e.type=e.cameraType}}),n}function x1(n){let t=[],e=(r,o=0)=>{let i=o>0?r+o:r;return t.includes(i)?e(r,o+1):i};return n.traverse(r=>{if(t.includes(r.name)){let o=r.name,i=e(r.name);if(r.name=i,r.isMesh){let a=r;a.material instanceof Array?a.material.forEach(s=>{s.name=s.name.replace(o,i)}):a.material.isAsset||(a.material.name=a.material.name.replace(o,i))}}t.push(r.name)}),n}import{mergeBufferGeometries as eB}from"three/examples/jsm/utils/BufferGeometryUtils.js";function b1(n){let t=[];return n.traverse(e=>{e instanceof bs&&t.push(e)}),t.forEach(e=>{let r=e.object,a=[...e.children.map(s=>{s.updateMatrix();let l;if(s.geometry!==void 0)try{l=s.geometry.clone().applyMatrix4(s.matrix)}catch(u){console.error(u)}return l!==void 0&&s.matrix.determinant()<0&&h1(l),l}).filter(s=>s!==void 0)];if(!e.parameters.hideBase&&r instanceof Dt&&a.unshift(r.geometry),a.length){let s=eB(a);r instanceof Dt&&(r.geometry=s)}e.removeFromParent(),r.setFromClonerState(null,{scene:n,shared:Xb})}),n}function v1(n){return n.traverse(t=>{t.matrixAutoUpdate=!0}),n}function S1(n){Object.values(n.shared.materials).forEach(t=>{qh(t)}),n.scene.objects.traverse((t,e)=>{"material"in e?qh(e.material):"materials"in e&&e.materials.forEach(r=>{qh(r)})})}function qh(n){if(typeof n=="string")return;let t=[];n.layers.forEach((e,r)=>{e.type==="outline"&&t.push(r)}),t.reverse().forEach(e=>{n.layers.delete(e)}),t.length&&console.warn("The Spline Loader currently does not support the outline layer.")}var O1=Ht(A1(),1);function _1(n){return n.traverseMaterial(t=>{t.needsJitter=!1}),n}var P1="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",Wh=class extends rB{load(t,e,r,o=console.error){let i=new tB(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),t.endsWith(".spline")?console.warn(P1+" The .spline files are only meant to be used by the Editor."):t.endsWith(".splinecode")||console.warn(P1),i.load(t,async a=>{try{if(typeof a=="string")throw new Error("The .spline file is not binary!");let s=await this.parse(a);e(s)}catch(s){o(s)}},r,o)}async parse(t){let e=await f1(t,S1);e.version&&(0,O1.default)(e.version,"1.0.40")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/loader to the latest version."),await Promise.allSettled([ov(e)&&ab(),hv(e)&&Wb(),Wv(e)&&Uv()].filter(Boolean));let r=new xi(e.shared);Object.values(r.getMaterials()).forEach(a=>Object.assign(a,{isAsset:!0}));let o=new Id(e.scene,r),i=o.activeCamera;return i&&Object.assign(i,{makeDefault:!0}),o=b1(o),o=y1(o),o=g1(o),o=x1(o),o=v1(o),o=_1(o),o}};export{Wh as default};
3663
+ }`,i={covariancesTexture:{type:"t",value:null},centersColorsTexture:{type:"t",value:null},meshIndexIntervals:{value:e},meshMatrixWorldsTexture:{type:"t",value:null},focal:{type:"v2",value:new Un},viewport:{type:"v2",value:new Un},basisViewport:{type:"v2",value:new Un},debugColor:{type:"v3",value:new NE},covariancesTextureSize:{type:"v2",value:new Un(1024,1024)},centersColorsTextureSize:{type:"v2",value:new Un(1024,1024)},orthoZoom:{type:"f",value:-1}};return new jE({uniforms:i,vertexShader:r,fragmentShader:o,transparent:!0,alphaTest:1,blending:GE,depthTest:!0,depthWrite:!1,side:EE})}static buildGeomtery(e){let r=new IE;r.setIndex([0,1,2,0,2,3]);let o=new Float32Array(4*3),i=new ME(o,3);r.setAttribute("position",i),i.setXYZ(0,-1,-1,0),i.setXYZ(1,-1,1,0),i.setXYZ(2,1,1,0),i.setXYZ(3,1,-1,0),i.needsUpdate=!0;let a=new VE().copy(r),s=new Uint32Array(e),l=new RE(s,1,!1);return l.setUsage(BE),a.setAttribute("splatIndex",l),a.instanceCount=e,a}resetLocalSplatDataAndTexturesFromSplatBuffer(){this.updateLocalSplatDataFromSplatBuffer(),this.allocateAndStoreLocalSplatDataInTextures()}updateLocalSplatDataFromSplatBuffer(){this.splatBuffers.forEach(i=>i.buildPreComputedBuffers()),this.covariances=new Float32Array(this.splatCount*6),this.colors=new Uint8Array(this.splatCount*4),this.centers=new Float32Array(this.splatCount*3);let e=0,r=0,o=0;for(let i of this.splatBuffers){let a=i.nsplats;this.colors.subarray(e,e+a*4).set(i.colorsA),e+=a*4,this.centers.subarray(r,r+a*3).set(i.decoded.xyz.denormDequant().data),r+=a*3,this.covariances.subarray(o,o+a*6).set(new Float32Array(i.precomputedCovarianceBufferData)),o+=a*6}}allocateAndStoreLocalSplatDataInTextures(){let o=this.splatCount,i=new Un(4096,1024);for(;i.x*i.y*2<o*6;)i.y*=2;let a=new Un(4096,1024);for(;a.x*a.y*4<o*4;)a.y*=2;let s,l;if(this.halfPrecisionCovariancesOnGPU){l=new Uint16Array(i.x*i.y*2);for(let h=0;h<this.covariances.length;h++)l[h]=DE.toHalfFloat(this.covariances[h]);s=new Md(l,i.x,i.y,h1,LE)}else l=new Float32Array(i.x*i.y*2),l.set(this.covariances),s=new Md(l,i.x,i.y,h1,f1);s.needsUpdate=!0,this.material.uniforms.covariancesTexture.value=s,this.material.uniforms.covariancesTextureSize.value.copy(i);let u=new Uint32Array(a.x*a.y*4);for(let h=0;h<o;h++){let m=h*4,y=h*3,g=h*4;u[g]=p1(this.colors[m],this.colors[m+1],this.colors[m+2],this.colors[m+3]),u[g+1]=Td(this.centers[y]),u[g+2]=Td(this.centers[y+1]),u[g+3]=Td(this.centers[y+2])}let c=new Md(u,a.x,a.y,kE,UE);c.internalFormat="RGBA32UI",c.needsUpdate=!0,this.material.uniforms.centersColorsTexture.value=c,this.material.uniforms.centersColorsTextureSize.value.copy(a);let d=256*4,p=new Float32Array(256*16);for(let h=0;h<this.meshMatrixWorlds.length;h++)p.set(this.meshMatrixWorlds[h].elements,h*16);let f=new Md(p,d,1,FE,f1);f.needsUpdate=!0,this.material.uniforms.meshMatrixWorldsTexture.value=f,this.material.uniformsNeedUpdate=!0,this.splatDataTextures={covariances:{data:l,texture:s,size:i},centerColors:{data:u,texture:c,size:a},meshMatrixWorlds:{data:p,texture:f}}}updateIndexes(e){let r=this.geometry;r.attributes.splatIndex.set(e),r.attributes.splatIndex.needsUpdate=!0,r.instanceCount=e.length}updateUniforms(e,r,o,i){this.splatCount>0&&(Id.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(Id),this.material.uniforms.basisViewport.value.set(2/Id.x,2/Id.y),this.material.uniforms.focal.value.set(r,o),this.material.uniforms.orthoZoom.value=i,this.material.uniformsNeedUpdate=!0)}getSplatDataTextures(){return this.splatDataTextures}getSplatCount(){return this.splatCount}getCenters(){return this.centers}getColors(){return this.colors}getCovariances(){return this.covariances}dispose(){this.geometry.dispose(),this.material.dispose(),this.splatDataTextures&&(this.splatDataTextures.covariances.texture.dispose(),this.splatDataTextures.centerColors.texture.dispose(),this.splatDataTextures.meshMatrixWorlds.texture.dispose())}};var kl=class{constructor(t={}){Lt(this,"updateSplatMeshUniforms",function(){let t=new qE;return function(){if(this.splatMesh===null)return;this.splatMesh.getSplatCount()>0&&(this.renderer.getSize(t),this.cameraFocalLengthX=this.camera.projectionMatrix.elements[0]*this.devicePixelRatio*t.x*.45,this.cameraFocalLengthY=this.camera.projectionMatrix.elements[5]*this.devicePixelRatio*t.y*.45,this.splatMesh.updateUniforms(t,this.cameraFocalLengthX,this.cameraFocalLengthY,this.camera.isPerspectiveCamera?-1:this.camera.zoom*this.devicePixelRatio))}}());Lt(this,"updateView",function(){let t=new HE,e=[],r=new Bs(0,0,-1),o=new Bs(0,0,-1),i=new Bs,a=new Bs;return function(s=!1){let l=this.updateMatrixWorldsInWorkerIfNeeded(),u=this.cropsChanged();if(!s){o.set(0,0,-1).applyQuaternion(this.camera.quaternion);let d=!1,p=!1;if(o.dot(r)<=.95&&(d=!0),a.copy(this.camera.position).sub(i).length()>=1&&(p=!0),!d&&!p&&!l&&!u)return}i.copy(this.camera.position),r.copy(o),t.copy(this.camera.matrixWorld).invert(),t.premultiply(this.camera.perspCamera.projectionMatrix),e[0]=this.camera.position.x,e[1]=this.camera.position.y,e[2]=this.camera.position.z;let c={sort:{view:t.elements,cameraPosition:e,splatRenderCount:this.splatRenderCount,splatSortCount:this.splatRenderCount},...l?{newMatrixWorlds:this.meshMatrixWorlds}:{},...u?{newCropsArray:this.cropsArray}:{}};this.sortRunning?this.queuedMessage=c:(this.queuedMessage=null,this.sortRunning=!0,this.sortWorker.postMessage(c))}}());this.scene=t.scene,this.currentPage=null,this.renderer=t.renderer,this.devicePixelRatio=window.devicePixelRatio,this.sortWorker=null,this.splatRenderCount=0,this.splatSortCount=0,this.splatMesh=null,this.sortRunning=!1,this.splatRenderingInitialized=!1,this.meshMatrixWorlds=null,this.meshMatrixWorldsOld=null,this.cropsArray=null,this.splatEntries=null,this.queuedMessage=null}get camera(){return this.scene.activeCamera}reloadSplats(){this.splatRenderingInitialized=!1;let t=this.loadSplat();this.renderer.pipeline.opaquePass.splatViewer=t?this:null}loadSplat(t={}){this.activePage=this.scene.activePage,t.position&&(t.position=new Bs().fromArray(t.position)),t.orientation&&(t.orientation=new m1().fromArray(t.orientation)),t.halfPrecisionCovariances=!!t.halfPrecisionCovariances;let e=[];if(this.splatEntries=e,this.activePage.traverseEntity(a=>{if(a.data.type==="Splat"){let s=a.visible;a.traverseAncestors(l=>{s&&(s=l.visible)}),s&&e.push(a)}}),this.splatMesh&&this.splatMesh.dispose(),e.length===0)return this.splatMesh=null,!1;this.meshMatrixWorlds=e.map(a=>a.matrixWorld),this.meshMatrixWorldsOld=e.map(a=>a.matrixWorld.clone()),this.cropsArray=e.map(a=>a.data.crops.map(s=>s.data));let r=e.map(a=>new jn(new Uint8Array(a.data.buffer).buffer)),o=0,i=[0];for(let a of r)o+=a.getSplatCount(),i.push(o);return this.setupSplatMesh(r,o,t.position,t.orientation,t.halfPrecisionCovariances,this.devicePixelRatio,i,this.meshMatrixWorlds),this.setupSortWorker(o),!0}updateMatrixWorldsInWorkerIfNeeded(){let t=this.splatDataTextures.meshMatrixWorlds.data;for(let e=0;e<this.meshMatrixWorlds.length;e++)t.set(this.meshMatrixWorlds[e].elements,e*16);return this.splatDataTextures.meshMatrixWorlds.texture.needsUpdate=!0,this.meshMatrixWorlds.every((e,r)=>e.equals(this.meshMatrixWorldsOld[r]))?!1:(this.meshMatrixWorldsOld=this.meshMatrixWorlds.map(e=>e.clone()),!0)}cropsChanged(){let t=!1;return this.splatEntries.forEach((e,r)=>{e.data.crops.forEach((o,i)=>{this.cropsArray[r][i]===void 0?(t=!0,this.cropsArray[r][i]=o.data):Object.entries(o.data).forEach(([a,s])=>{Array.isArray(s)&&s.some((l,u)=>l!==this.cropsArray[r][i][a][u])?(t=!0,this.cropsArray[r][i][a]=s):s!==this.cropsArray[r][i]?.[a]&&(t=!0,this.cropsArray[r][i][a]=s)})}),e.data.crops.length!==this.cropsArray[r]?.length&&(this.cropsArray[r].length=e.data.crops.length,t=!0)}),t}setupSplatMesh(t,e,r=new Bs,o=new m1,i=!1,a=1,s,l){this.splatMesh=Hn.buildMesh(t,e,i,a,s,l),this.splatMesh.position.copy(r),this.splatMesh.quaternion.copy(o),this.splatMesh.frustumCulled=!1,this.splatMesh.renderOrder=10,this.updateSplatMeshUniforms(),this.splatRenderCount=e}setupSortWorker(t){this.sortWorker=d1(t),this.sortWorker.onmessage=e=>{e.data.sortDone?(this.sortRunning=!1,this.splatMesh?.updateIndexes(new Uint32Array(e.data.indexesBuffer)),this.lastSortTime=e.data.sortTime,this.queuedMessage&&(this.sortWorker.postMessage(this.queuedMessage),this.queuedMessage=null)):e.data.sortCanceled?this.sortRunning=!1:e.data.sortSetupPhase1Complete?this.sortWorker.postMessage({positions:this.splatMesh.getCenters().buffer,meshMatrixWorlds:this.splatMesh.meshMatrixWorlds,meshIndexIntervals:this.splatMesh.meshIndexIntervals,cropsArray:this.cropsArray}):e.data.sortSetupComplete&&(this.splatDataTextures=this.splatMesh.getSplatDataTextures(),this.updateView(!0,!0),this.splatRenderingInitialized=!0)}}update(){this.splatRenderingInitialized!==!1&&(this.updateSplatMeshUniforms(),this.updateView())}getSplatMesh(){return this.splatMesh}};var ZE=new QE;ZE.wireframe=!0;var y1=new $E,Nd=class extends WE{constructor(e,r){super();this.data=e;this.sharedAssets=r;this.enableHelpers=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this.needsNormalDirty=!0;this._needsTransmission=!1;this._needsNormal=!1;this.geometryCacheChanged=!1;this.splatViewer=null;this.entityByUuid={};this.entityIdentityToEntity={};this.toExpandCloner=new Set;this.toUpdateCloner=new Set;this.pendingCommands=[];this.pathConstraints=new Pd;this.invisibleObjects=new Rn("jflkdsafjasdifjaslk",{...Qc.defaultData,visible:!1,name:"buildin invisible"});this.needsRecomputeInstances=!1;this.init(e,r),this.matrixAutoUpdate=!1,this.errorPage=new zr("fdasfa",{...Go.defaultData,name:""},{shared:r,scene:this})}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=BS(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=ES(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let r=e.identity.join("-"),o=this.entityIdentityToEntity[r];o&&(e.uuid=o.uuid),this.entityIdentityToEntity[r]=e,this.entityByUuid[e.uuid]=e}markPenumbraSizeDirty(){for(let e of this.children)e instanceof zr&&(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 r=this.find(e);if(r===void 0)return;let o=[],i=r;for(;i!==this;){let a=i;i=i.parent;let s=i.children.indexOf(a);o.splice(0,0,s)}return{entity:r,sortKey:o}}getAllSorted(e){let r=[];for(let o of e){let i=this.getWithSortKey(o.id);i!==void 0&&r.push(i)}return r.sort((o,i)=>Ql(o.sortKey,i.sortKey)),r.map(o=>o.entity)}nonExistOrDescendantOf(e,r){let o=this.find(e);if(o===void 0)return!0;for(;o;){if(o.uuid===r)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===bn)return this.activePage.personalCamera}if(e===""||e===void 0)return;let r=this.entityByUuid[e];return r===void 0?this.getObjectByProperty("uuid",e):r}find2D(e){for(let r of this.children)if(r instanceof zr&&r.uiScene){let o=r.uiScene.find(e);if(o)return o}}findScene2DfromObject2D(e){for(let r of this.children)if(r instanceof zr&&r.uiScene&&r.uiScene.find(e))return r.uiScene}find2DInUIObjects(e){let r;return this.traverseEntity(o=>{r===void 0&&o instanceof Pi&&(r=o.uiCanvas.find(e))}),r}traverse2D(e){for(let r of this.children)r instanceof zr&&r.uiScene&&r.uiScene.traverse(e)}debugEnsureEntity(e){let r=this.find(e);if(r){if(Array.isArray(r.identity)&&this.findInstance(r.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(r=>{this.toExpandCloner.add(r)})}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}updateByLibOp(e,r){e.path.length===1&&e.path[0]==="components"&&e.type===1&&this.createChildrenObjects([{...e.data.asset,id:e.id}],this.invisibleObjects,r)}updateTreeByOp(e,r){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,r);i.updateVisible(this),i.resetBBoxNeedsUpdate(),Ln(i)&&Nl(i.parent)&&(i.invalidateUpstreamBooleanData(),i.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(o),this.markNeedsRecomputeInstancesForChildren(i),this.markToExpandCloner(i),this.markPenumbraSizeDirty(),i.updatePathSnapping()}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),Nl(o.parent)&&(o.parent.invalidateUpstreamBooleanData(),o.parent.invalidateDownstreamBooleanData().recomputeBoolean()),Ln(o)&&(o.freeBooleanPointer(),i instanceof yr&&i.invalidateDownstreamBooleanData().recomputeBoolean()),o instanceof Is&&o.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(o),this.pathConstraints.removeDependencies(o.uuid),o.updatePathSnapping()}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 a=e.parent===null?this:this.find(e.parent);if(a===void 0)throw new Error("unexpected");a.add(o),this.markNeedsRecomputeInstancesForAncessors(a),this.markToExpandCloner(o),o.invalidateClonerTransform(o),o.updateVisible(this),o.resetBBoxNeedsUpdate(),this.markPenumbraSizeDirty();let s=e.localIndex;a.children.splice(s,0,a.children.pop()),Ln(o)&&(o.invalidateUpstreamBooleanData(),Nl(o.parent)?o.parent.invalidateDownstreamBooleanData().recomputeBoolean():i instanceof yr&&i.invalidateDownstreamBooleanData().recomputeBoolean()),o.updatePathSnapping()}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 r of this.children)r instanceof zr&&(r.visible=r.uuid===e,r.visible&&(this.activePage=r,this.activePage.onActive(this)));this.activePage!==this.splatViewer?.activePage&&this.reloadSplats()}updateEntityByOp(e,r,o,i){if(r.type===0){if(("overrides"in r.props||"component"in r.props)&&this.markNeedsRecomputeInstances(),"visible"in r.props&&this.markPenumbraSizeDirty(),r.path.includes("overrides")&&"states"in r.props){let{rest:s}=r.props;r={...r,props:s},this.markNeedsRecomputeInstances()}r.path[0]==="pathSnapping"&&r.props.pathId!==void 0&&this.pathConstraints.setConstraint(e,r.props.pathId)}let a=this.find(e);if(a)try{IS(a,r,o,{scene:this,shared:i}),a instanceof ft&&a.updateGeometryGroupsIfNeeded()}catch(s){console.error(s)}}updateEntity2DByOp(e,r,o,i,a,s=[]){e.updateEntityByOp(r,o,i,a),this.traverseEntity(l=>{(l instanceof Pi||l instanceof zr)&&(s.includes(l.frameId??"")||l.frameId===r)&&l.updateEntity2DByOp(r,o,i,a)})}get activeCamera(){return this.activePage.activeCamera}switchActiveCamera(e){this.activePage.switchActiveCamera(e)}isInvisibleObjects(e){return e===this.invisibleObjects||e.hasAnccestor(this.invisibleObjects)}init(e,r){let o=Object.entries(r.data.lib.components).map((i,a)=>({data:i[1].asset.data,children:i[1].asset.children,id:i[0],fi:a}));this.invisibleObjects.updateState(this.invisibleObjects.data,{scene:this,shared:r}),this.add(this.invisibleObjects),this.createChildrenObjects(o,this.invisibleObjects,r),this.createChildrenObjects(e.objects,this,r),this.updatePage(e.publish.playPage),this.activePage.switchToPlayCamera(),this.expandInstances(r,!0),this.traverseEntity(i=>{i instanceof rn&&i.updateUp()}),this.doPendingExpandCloner(),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(r=>{(r.data.type==="Component"||r.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){Re.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(r=>{Re.is(r)&&r.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,r,o,i,a,s,l){if(e){let u=i.find(e);u&&u!==i&&a.forInstancesRec(c=>{c.data=fn(c.data,d=>{let p=d.events.data(l.id),f=c.goUp(s);if(f){let h=[...Xl(f.identity),e].join("-"),m=this.entityIdentityToEntity[h];if(m){let y=m.uuid,g=lt.zoom(p,r);g[o]=y}else{if(!1)debugger;console.warn("cannot find instance")}}}).data})}}rewriteActions(e,r,o,i,a,s){e.forEach(l=>{l.data.type==="Transition"?this.relativeizeInner(l.data.object,[...r,l.id],"object",o,i,a,s):l.data.type==="Animation"&&this.relativeizeInner(l.data.object,[...r,l.id],"object",o,i,a,s)})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof an&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((r,o)=>{r.data.events.forEach(i=>{if(i.data.type==="GameControl"){let a=!1;if(r.forInstancesRec(s=>{s.data=fn(s.data,l=>{s.isInstanceRoot||(l.events.delete(i.id),a=!0)}).data}),a===!1)for(let s of eu.list)this.rewriteActions(i.data.gameActions[s],["gameActions",s],e,r,o,i)}else i.data.type==="Conditional"?(i.data.condition.type==="Distance"?(this.relativeizeInner(i.data.condition.fromObject,["condition"],"fromObject",e,r,o,i),this.relativeizeInner(i.data.condition.toObject,["condition"],"toObject",e,r,o,i)):i.data.condition.type==="State"?this.relativeizeInner(i.data.condition.object,["condition"],"object",e,r,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,r,o,i),i.data.condition.rOperand.type==="Property"&&this.relativeizeInner(i.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,r,o,i)),this.rewriteActions(i.data.inActions,["inActions"],e,r,o,i),this.rewriteActions(i.data.outActions,["outActions"],e,r,o,i)):"actions"in i.data&&this.rewriteActions(i.data.actions,["actions"],e,r,o,i)})}),!0})}expandInstances(e,r,o){let i=new Set;this.traverseEntity(a=>{if(a instanceof an&&a.isInstanceRoot)return a.expandInstanceChildren({scene:this,shared:e,pendingDeletes:i}),r||a.resetBBoxNeedsUpdate(),o&&a.traverseEntity(s=>{o.addClip(s)}),!0});for(let a of i)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(a),bd(a)}recomputeInstances(e,r){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(o=>{o instanceof an&&o.isInstanceRoot&&(o.component=void 0)}),this.expandInstances(e,!1,r))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(r=>{let o=typeof r.identity=="string"?r.identity:r.identity.join("-");this.entityIdentityToEntity[o]===r&&(delete this.entityByUuid[r.uuid],delete this.entityIdentityToEntity[o]),r.dispose()})}clearScene(){for(let e of this.children)Re.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,r){this.init(e,r)}raycast(e){return this.raycast1(e,!1)}raycast1(e,r){let o=[],i=a=>{for(let s of a.children){let l=s.cloner;if(Re.is(s)&&!s.raycastLock&&(s.visible||l?.object.data.visible))if(r===!0&&s.isInstanceRoot){let u=[];if(e.intersectObject(s,!0,u),u.length){let c=u[0];c.object=s,c.point.applyMatrix4(c.object.matrixWorld);let d=s.matrixWorld.clone().invert();c.point.applyMatrix4(d),o.push(c)}}else(Ln(s)||Dl(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,o),Gl(s,e,o)),i(s)}};return i(this.activePage),o}raycastWithClones(e){let r=[],o=i=>{for(let a of i.children){let s=a.cloner;Re.is(a)&&(a.visible||s?.object.data.visible)&&((Ln(a)||Dl(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,r),Gl(a,e,r,!0)),o(a))}};return o(this),r}forEachEntity(e){for(let r of this.children)Re.is(r)&&e(r)}traverseConcreteEntity(e){for(let r of this.children)Re.is(r)&&r.isConcreteEntity&&r.traverseEntity(e)}traverseEntity(e){for(let r of this.children)Re.is(r)&&r.traverseEntity(e)}updateFont(e,r){this.traverseEntity(o=>{if(o instanceof ft&&o.data.type==="Mesh"&&o.data.geometry.type==="TextGeometry"&&o.data.geometry.font===e){let i=o.geometry,a=o.data.geometry;i.updateFont(e,r).then(()=>{i.update(a);let s=o.invalidateDownstreamBooleanData();Nl(s)&&s.recomputeBoolean()})}})}traverseObject(e){for(let r of this.children)_a.is(r)&&r.traverseObject(e)}traverseVisibleEntity(e){for(let r of this.children)Re.is(r)&&r.visible&&r.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,r,o){let i=0;for(let a of e)this.createObject(a.id,a.data,a.children,r,i,o),i+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let r of e.children)this.unregisterObject(r)}createObject(e,r,o,i,a,s){let l={scene:this,shared:s},u=_d(e,r,l);return u&&(this.entityByUuid[e]=u,i.add(u),i.children.splice(a,0,i.children.pop()),o.length>0&&(u.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(o,u,s)),u.updateState(r,l),u instanceof ft&&u.updateGeometryGroupsIfNeeded(),u.updateVisible(this),u.cloner&&this.toExpandCloner.add(u),r.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,r.pathSnapping.pathId)),r.type==="Empty"&&r.animations&&u.traverseEntity(c=>{let d=c.dataPatched;if(c instanceof ft&&d.bones&&d.boneInverses){let p=d.bones.map(m=>this.find(m)),f=d.boneInverses.map(m=>new YE().fromArray(m)),h=new KE(p,f);c.bind(h,c.bindMatrix)}else c.matrixAutoUpdate=!0}),u}getCenter(e){let r=[];for(let i=0,a=e.length;i<a;++i){let{id:s,recursive:l}=e[i],u=this.find(s),c=l?u.recursiveBBox:u.singleBBox;r.push(...c.vertices)}let o=new XE;return o.setFromPoints(r),o.getCenter(y1),y1}copyMatrixWorld(e,r){if(e===null){r.identity();return}let o=this.find(e);o?r.copy(o.matrixWorld):r.identity()}copyParentMatrixWorld(e,r){if(e===null){r.identity();return}let o=this.find(e)?.parent;o?r.copy(o.matrixWorld):r.identity()}traverseMaterial(e){this.traverseEntity(r=>{if(r instanceof Dt)if(Array.isArray(r.material))for(let o=0;o<r.material.length;o++)r.material[o]instanceof hr&&e(r.material[o]);else r.material instanceof hr&&e(r.material)})}updateViewPlaneSize(e,r,o=!1){this.traverseConcreteEntity(i=>{i instanceof rn&&i.setViewplaneSize(e,r,o)})}initializeSplatViewer(e){this.splatViewer=new kl({scene:this,renderer:e}),this.reloadSplats()}reloadSplats(){this.splatViewer?.reloadSplats()}};import{DRACOLoader as JE}from"three/examples/jsm/loaders/DRACOLoader.js";var qn;function eB(){return qn||(qn=new JE,qn.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),qn.decoderPending}async function tB(n){if(qn){let t={attributeIDs:qn.defaultAttributeIDs,attributeTypes:qn.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await qn.decodeGeometry(new Int8Array(n).buffer,t)}catch(r){console.error(r)}if(e)return{index:e.index?{array:e.index.array}:void 0,attributes:Object.entries(e.attributes).map(([r,o])=>({name:r,itemSize:o.itemSize,array:o.array}))}}return null}async function g1(n,t){let[e,r]=ep(Vc.deserialize(new Uint8Array(n)));ou(e);let o=[];e.scene.objects.traverse((i,a)=>{a.type==="Mesh"&&a.geometry.type==="NonParametricGeometry"&&a.geometry.data.draco!==void 0&&o.push(a)}),o.length&&await eB();for(let i of o){let a=await tB(ut(i.geometry.data.draco));if(a){a.index&&(i.geometry.data.index={array:a.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let s={};a.attributes.forEach(({name:l,array:u,itemSize:c})=>{s[l]={array:u,itemSize:c,type:"Float32Array",normalized:!1}}),i.geometry.data.attributes=s,i.geometry.data.draco=void 0}}return t&&t(e),r.result().data}import{Mesh as gfe}from"three";import{mergeBufferGeometries as vfe}from"three/examples/jsm/utils/BufferGeometryUtils.js";function x1(n){let t;if(!!n.index)for(let e=0;e<n.index.array.length;e+=3)t=n.index.array[e],n.index.array[e]=n.index.array[e+2],n.index.array[e+2]=t}import{Color as b1,ShaderLib as rB}from"three";function v1(n){let t=new Set;return n.traverse(e=>{if(e instanceof mr)if(yt(e.material))e.material.forEach(r=>{let o=r;t.has(o)||t.add(o)});else{let r=e.material;t.has(r)||t.add(r)}}),t.forEach(e=>{if(e instanceof Array)return;let r=e.onBeforeCompile.bind(e);if(oB(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new b1,specularColor:new b1});let o=0;e.onBeforeCompile=(i,a)=>{r&&r(i,a),i.uniforms=Object.assign({},rB.physical.uniforms,i.uniforms),e.getLayersOfType("transmission").forEach(s=>{if(i.uniforms.transmissionSamplerMap.value){let l=s.color;l&&(l.transmissionSamplerMap.value=i.uniforms.transmissionSamplerMap.value,l.transmissionSamplerSize.value=i.uniforms.transmissionSamplerSize.value,l.aspectRatio.value=Db(window.innerWidth,window.innerHeight),e.defines.IS_THREEJS_EXPORT=!0)}else o++,o<2&&(e.needsUpdate=!0)})}}else nB(e)||(e.onBeforeCompile=(o,i)=>{r&&r(o,i),e.transparent=!1})}),n}function oB(n){return n.getLayersOfType("transmission").length>0}function nB(n){let t=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&&(t+=(1-t)*o.value)}}return t<1}function S1(n){return n.traverse(t=>{if(t.type==="Camera"){let e=t;e.type=e.cameraType}}),n}function w1(n){let t=[],e=(r,o=0)=>{let i=o>0?r+o:r;return t.includes(i)?e(r,o+1):i};return n.traverse(r=>{if(t.includes(r.name)){let o=r.name,i=e(r.name);if(r.name=i,r.isMesh){let a=r;a.material instanceof Array?a.material.forEach(s=>{s.name=s.name.replace(o,i)}):a.material.isAsset||(a.material.name=a.material.name.replace(o,i))}}t.push(r.name)}),n}import{mergeBufferGeometries as iB}from"three/examples/jsm/utils/BufferGeometryUtils.js";function A1(n){let t=[];return n.traverse(e=>{e instanceof vs&&t.push(e)}),t.forEach(e=>{let r=e.object,a=[...e.children.map(s=>{s.updateMatrix();let l;if(s.geometry!==void 0)try{l=s.geometry.clone().applyMatrix4(s.matrix)}catch(u){console.error(u)}return l!==void 0&&s.matrix.determinant()<0&&x1(l),l}).filter(s=>s!==void 0)];if(!e.parameters.hideBase&&r instanceof Dt&&a.unshift(r.geometry),a.length){let s=iB(a);r instanceof Dt&&(r.geometry=s)}e.removeFromParent(),r.setFromClonerState(null,{scene:n,shared:Qb})}),n}function _1(n){return n.traverse(t=>{t.matrixAutoUpdate=!0}),n}function P1(n){Object.values(n.shared.materials).forEach(t=>{Wh(t)}),n.scene.objects.traverse((t,e)=>{"material"in e?Wh(e.material):"materials"in e&&e.materials.forEach(r=>{Wh(r)})})}function Wh(n){if(typeof n=="string")return;let t=[];n.layers.forEach((e,r)=>{e.type==="outline"&&t.push(r)}),t.reverse().forEach(e=>{n.layers.delete(e)}),t.length&&console.warn("The Spline Loader currently does not support the outline layer.")}var I1=Ht(C1(),1);function T1(n){return n.traverseMaterial(t=>{t.needsJitter=!1}),n}var M1="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",$h=class extends sB{load(t,e,r,o=console.error){let i=new aB(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),t.endsWith(".spline")?console.warn(M1+" The .spline files are only meant to be used by the Editor."):t.endsWith(".splinecode")||console.warn(M1),i.load(t,async a=>{try{if(typeof a=="string")throw new Error("The .spline file is not binary!");let s=await this.parse(a);e(s)}catch(s){o(s)}},r,o)}async parse(t){let e=await g1(t,P1);e.version&&(0,I1.default)(e.version,"1.0.41")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/loader to the latest version."),await Promise.allSettled([nv(e)&&sb(),mv(e)&&$b(),Qv(e)&&$v()].filter(Boolean));let r=new xi(e.shared);Object.values(r.getMaterials()).forEach(a=>Object.assign(a,{isAsset:!0}));let o=new Nd(e.scene,r),i=o.activeCamera;return i&&Object.assign(i,{makeDefault:!0}),o=A1(o),o=v1(o),o=S1(o),o=w1(o),o=_1(o),o=T1(o),o}};export{$h as default};