@splinetool/loader 0.9.225 → 0.9.227

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,16 +1,16 @@
1
- "use strict";var eg=Object.create;var qs=Object.defineProperty;var tg=Object.getOwnPropertyDescriptor;var rg=Object.getOwnPropertyNames;var og=Object.getPrototypeOf,ng=Object.prototype.hasOwnProperty;var Hl=(n,r)=>()=>(r||n((r={exports:{}}).exports,r),r.exports),Ed=(n,r)=>{for(var e in r)qs(n,e,{get:r[e],enumerable:!0})},Ld=(n,r,e,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of rg(r))!ng.call(n,o)&&o!==e&&qs(n,o,{get:()=>r[o],enumerable:!(t=tg(r,o))||t.enumerable});return n};var Ni=(n,r,e)=>(e=n!=null?eg(og(n)):{},Ld(r||!n||!n.__esModule?qs(e,"default",{value:n,enumerable:!0}):e,n)),ig=n=>Ld(qs({},"__esModule",{value:!0}),n);var em=Hl((vc,Jf)=>{(function(n,r){typeof vc=="object"?Jf.exports=r():typeof define=="function"&&define.amd?define(r):n.Alea=r()})(vc,function(){"use strict";return n.importState=function(e){var t=new n;return t.importState(e),t},n;function n(){return function(e){var t=0,o=0,i=0,s=1;e.length==0&&(e=[+new Date]);var l=r();t=l(" "),o=l(" "),i=l(" ");for(var c=0;c<e.length;c++)t-=l(e[c]),t<0&&(t+=1),o-=l(e[c]),o<0&&(o+=1),i-=l(e[c]),i<0&&(i+=1);l=null;var u=function(){var a=2091639*t+s*23283064365386963e-26;return t=o,o=i,i=a-(s=a|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[t,o,i,s]},u.importState=function(a){t=+a[0]||0,o=+a[1]||0,i=+a[2]||0,s=+a[3]||0},u}(Array.prototype.slice.call(arguments))}function r(){var e=4022871197,t=function(o){o=o.toString();for(var i=0;i<o.length;i++){e+=o.charCodeAt(i);var s=.02519603282416938*e;e=s>>>0,s-=e,s*=e,e=s>>>0,s-=e,e+=s*4294967296}return(e>>>0)*23283064365386963e-26};return t.version="Mash 0.9",t}})});var sm=Hl((Ya,im)=>{(function(n,r){typeof Ya=="object"&&typeof im<"u"?r(Ya):typeof define=="function"&&define.amd?define(["exports"],r):r((n=typeof globalThis<"u"?globalThis:n||self).SVDJS={})})(Ya,function(n){"use strict";n.SVD=function(r,e,t,o,i){if(e=e===void 0||e,t=t===void 0||t,i=1e-64/(o=o||Math.pow(2,-52)),!r)throw new TypeError("Matrix a is not defined");var s,l,c,u,a,d,p,f,m,h,y,g,v=r[0].length,w=r.length;if(w<v)throw new TypeError("Invalid matrix: m < n");for(var b=[],S=[],A=[],_=e==="f"?w:v,x=h=p=0;x<w;x++)S[x]=new Array(_).fill(0);for(x=0;x<v;x++)A[x]=new Array(v).fill(0);var P,O=new Array(v).fill(0);for(x=0;x<w;x++)for(s=0;s<v;s++)S[x][s]=r[x][s];for(x=0;x<v;x++){for(b[x]=p,m=0,c=x+1,s=x;s<w;s++)m+=Math.pow(S[s][x],2);if(m<i)p=0;else for(f=(d=S[x][x])*(p=d<0?Math.sqrt(m):-Math.sqrt(m))-m,S[x][x]=d-p,s=c;s<v;s++){for(m=0,l=x;l<w;l++)m+=S[l][x]*S[l][s];for(d=m/f,l=x;l<w;l++)S[l][s]=S[l][s]+d*S[l][x]}for(O[x]=p,m=0,s=c;s<v;s++)m+=Math.pow(S[x][s],2);if(m<i)p=0;else{for(f=(d=S[x][x+1])*(p=d<0?Math.sqrt(m):-Math.sqrt(m))-m,S[x][x+1]=d-p,s=c;s<v;s++)b[s]=S[x][s]/f;for(s=c;s<w;s++){for(m=0,l=c;l<v;l++)m+=S[s][l]*S[x][l];for(l=c;l<v;l++)S[s][l]=S[s][l]+m*b[l]}}h<(y=Math.abs(O[x])+Math.abs(b[x]))&&(h=y)}if(t)for(x=v-1;0<=x;x--){if(p!==0){for(f=S[x][x+1]*p,s=c;s<v;s++)A[s][x]=S[x][s]/f;for(s=c;s<v;s++){for(m=0,l=c;l<v;l++)m+=S[x][l]*A[l][s];for(l=c;l<v;l++)A[l][s]=A[l][s]+m*A[l][x]}}for(s=c;s<v;s++)A[x][s]=0,A[s][x]=0;A[x][x]=1,p=b[x],c=x}if(e){if(e==="f")for(x=v;x<w;x++){for(s=v;s<w;s++)S[x][s]=0;S[x][x]=1}for(x=v-1;0<=x;x--){for(c=x+1,p=O[x],s=c;s<_;s++)S[x][s]=0;if(p!==0){for(f=S[x][x]*p,s=c;s<_;s++){for(m=0,l=c;l<w;l++)m+=S[l][x]*S[l][s];for(d=m/f,l=x;l<w;l++)S[l][s]=S[l][s]+d*S[l][x]}for(s=x;s<w;s++)S[s][x]=S[s][x]/p}else for(s=x;s<w;s++)S[s][x]=0;S[x][x]=S[x][x]+1}}for(o*=h,l=v-1;0<=l;l--)for(var I=0;I<50;I++){for(P=!1,c=l;0<=c;c--){if(Math.abs(b[c])<=o){P=!0;break}if(Math.abs(O[c-1])<=o)break}if(!P){for(a=0,u=c-(m=1),x=c;x<l+1&&(d=m*b[x],b[x]=a*b[x],!(Math.abs(d)<=o));x++)if(p=O[x],O[x]=Math.sqrt(d*d+p*p),a=p/(f=O[x]),m=-d/f,e)for(s=0;s<w;s++)y=S[s][u],g=S[s][x],S[s][u]=y*a+g*m,S[s][x]=-y*m+g*a}if(g=O[l],c===l){if(g<0&&(O[l]=-g,t))for(s=0;s<v;s++)A[s][l]=-A[s][l];break}for(h=O[c],d=(((y=O[l-1])-g)*(y+g)+((p=b[l-1])-(f=b[l]))*(p+f))/(2*f*y),p=Math.sqrt(d*d+1),d=((h-g)*(h+g)+f*(y/(d<0?d-p:d+p)-f))/h,x=c+(m=a=1);x<l+1;x++){if(p=b[x],y=O[x],f=m*p,p*=a,g=Math.sqrt(d*d+f*f),d=h*(a=d/(b[x-1]=g))+p*(m=f/g),p=-h*m+p*a,f=y*m,y*=a,t)for(s=0;s<v;s++)h=A[s][x-1],g=A[s][x],A[s][x-1]=h*a+g*m,A[s][x]=-h*m+g*a;if(g=Math.sqrt(d*d+f*f),d=(a=d/(O[x-1]=g))*p+(m=f/g)*y,h=-m*p+a*y,e)for(s=0;s<w;s++)y=S[s][x-1],g=S[s][x],S[s][x-1]=y*a+g*m,S[s][x]=-y*m+g*a}b[c]=0,b[l]=d,O[l]=h}for(x=0;x<v;x++)O[x]<o&&(O[x]=0);return{u:S,q:O,v:A}},n.VERSION="1.1.1",Object.defineProperty(n,"__esModule",{value:!0})})});var jh=Hl(Sl=>{(function(){"use strict";var n=function(){this.init()};n.prototype={init:function(){var a=this||r;return a._counter=1e3,a._html5AudioPool=[],a.html5PoolSize=10,a._codecs={},a._howls=[],a._muted=!1,a._volume=1,a._canPlayEvent="canplaythrough",a._navigator=typeof window<"u"&&window.navigator?window.navigator:null,a.masterGain=null,a.noAudio=!1,a.usingWebAudio=!0,a.autoSuspend=!0,a.ctx=null,a.autoUnlock=!0,a._setup(),a},volume:function(a){var d=this||r;if(a=parseFloat(a),d.ctx||u(),typeof a<"u"&&a>=0&&a<=1){if(d._volume=a,d._muted)return d;d.usingWebAudio&&d.masterGain.gain.setValueAtTime(a,r.ctx.currentTime);for(var p=0;p<d._howls.length;p++)if(!d._howls[p]._webAudio)for(var f=d._howls[p]._getSoundIds(),m=0;m<f.length;m++){var h=d._howls[p]._soundById(f[m]);h&&h._node&&(h._node.volume=h._volume*a)}return d}return d._volume},mute:function(a){var d=this||r;d.ctx||u(),d._muted=a,d.usingWebAudio&&d.masterGain.gain.setValueAtTime(a?0:d._volume,r.ctx.currentTime);for(var p=0;p<d._howls.length;p++)if(!d._howls[p]._webAudio)for(var f=d._howls[p]._getSoundIds(),m=0;m<f.length;m++){var h=d._howls[p]._soundById(f[m]);h&&h._node&&(h._node.muted=a?!0:h._muted)}return d},stop:function(){for(var a=this||r,d=0;d<a._howls.length;d++)a._howls[d].stop();return a},unload:function(){for(var a=this||r,d=a._howls.length-1;d>=0;d--)a._howls[d].unload();return a.usingWebAudio&&a.ctx&&typeof a.ctx.close<"u"&&(a.ctx.close(),a.ctx=null,u()),a},codecs:function(a){return(this||r)._codecs[a.replace(/^x-/,"")]},_setup:function(){var a=this||r;if(a.state=a.ctx&&a.ctx.state||"suspended",a._autoSuspend(),!a.usingWebAudio)if(typeof Audio<"u")try{var d=new Audio;typeof d.oncanplaythrough>"u"&&(a._canPlayEvent="canplay")}catch{a.noAudio=!0}else a.noAudio=!0;try{var d=new Audio;d.muted&&(a.noAudio=!0)}catch{}return a.noAudio||a._setupCodecs(),a},_setupCodecs:function(){var a=this||r,d=null;try{d=typeof Audio<"u"?new Audio:null}catch{return a}if(!d||typeof d.canPlayType!="function")return a;var p=d.canPlayType("audio/mpeg;").replace(/^no$/,""),f=a._navigator?a._navigator.userAgent:"",m=f.match(/OPR\/([0-6].)/g),h=m&&parseInt(m[0].split("/")[1],10)<33,y=f.indexOf("Safari")!==-1&&f.indexOf("Chrome")===-1,g=f.match(/Version\/(.*?) /),v=y&&g&&parseInt(g[1],10)<15;return a._codecs={mp3:!!(!h&&(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:!!(!v&&d.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),webm:!!(!v&&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$/,"")},a},_unlockAudio:function(){var a=this||r;if(!(a._audioUnlocked||!a.ctx)){a._audioUnlocked=!1,a.autoUnlock=!1,!a._mobileUnloaded&&a.ctx.sampleRate!==44100&&(a._mobileUnloaded=!0,a.unload()),a._scratchBuffer=a.ctx.createBuffer(1,1,22050);var d=function(p){for(;a._html5AudioPool.length<a.html5PoolSize;)try{var f=new Audio;f._unlocked=!0,a._releaseHtml5Audio(f)}catch{a.noAudio=!0;break}for(var m=0;m<a._howls.length;m++)if(!a._howls[m]._webAudio)for(var h=a._howls[m]._getSoundIds(),y=0;y<h.length;y++){var g=a._howls[m]._soundById(h[y]);g&&g._node&&!g._node._unlocked&&(g._node._unlocked=!0,g._node.load())}a._autoResume();var v=a.ctx.createBufferSource();v.buffer=a._scratchBuffer,v.connect(a.ctx.destination),typeof v.start>"u"?v.noteOn(0):v.start(0),typeof a.ctx.resume=="function"&&a.ctx.resume(),v.onended=function(){v.disconnect(0),a._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<a._howls.length;w++)a._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),a}},_obtainHtml5Audio:function(){var a=this||r;if(a._html5AudioPool.length)return a._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(a){var d=this||r;return a._unlocked&&d._html5AudioPool.push(a),d},_autoSuspend:function(){var a=this;if(!(!a.autoSuspend||!a.ctx||typeof a.ctx.suspend>"u"||!r.usingWebAudio)){for(var d=0;d<a._howls.length;d++)if(a._howls[d]._webAudio){for(var p=0;p<a._howls[d]._sounds.length;p++)if(!a._howls[d]._sounds[p]._paused)return a}return a._suspendTimer&&clearTimeout(a._suspendTimer),a._suspendTimer=setTimeout(function(){if(!!a.autoSuspend){a._suspendTimer=null,a.state="suspending";var f=function(){a.state="suspended",a._resumeAfterSuspend&&(delete a._resumeAfterSuspend,a._autoResume())};a.ctx.suspend().then(f,f)}},3e4),a}},_autoResume:function(){var a=this;if(!(!a.ctx||typeof a.ctx.resume>"u"||!r.usingWebAudio))return a.state==="running"&&a.ctx.state!=="interrupted"&&a._suspendTimer?(clearTimeout(a._suspendTimer),a._suspendTimer=null):a.state==="suspended"||a.state==="running"&&a.ctx.state==="interrupted"?(a.ctx.resume().then(function(){a.state="running";for(var d=0;d<a._howls.length;d++)a._howls[d]._emit("resume")}),a._suspendTimer&&(clearTimeout(a._suspendTimer),a._suspendTimer=null)):a.state==="suspending"&&(a._resumeAfterSuspend=!0),a}};var r=new n,e=function(a){var d=this;if(!a.src||a.src.length===0){console.error("An array of source files must be passed with any new Howl.");return}d.init(a)};e.prototype={init:function(a){var d=this;return r.ctx||u(),d._autoplay=a.autoplay||!1,d._format=typeof a.format!="string"?a.format:[a.format],d._html5=a.html5||!1,d._muted=a.mute||!1,d._loop=a.loop||!1,d._pool=a.pool||5,d._preload=typeof a.preload=="boolean"||a.preload==="metadata"?a.preload:!0,d._rate=a.rate||1,d._sprite=a.sprite||{},d._src=typeof a.src!="string"?a.src:[a.src],d._volume=a.volume!==void 0?a.volume:1,d._xhr={method:a.xhr&&a.xhr.method?a.xhr.method:"GET",headers:a.xhr&&a.xhr.headers?a.xhr.headers:null,withCredentials:a.xhr&&a.xhr.withCredentials?a.xhr.withCredentials:!1},d._duration=0,d._state="unloaded",d._sounds=[],d._endTimers={},d._queue=[],d._playLock=!1,d._onend=a.onend?[{fn:a.onend}]:[],d._onfade=a.onfade?[{fn:a.onfade}]:[],d._onload=a.onload?[{fn:a.onload}]:[],d._onloaderror=a.onloaderror?[{fn:a.onloaderror}]:[],d._onplayerror=a.onplayerror?[{fn:a.onplayerror}]:[],d._onpause=a.onpause?[{fn:a.onpause}]:[],d._onplay=a.onplay?[{fn:a.onplay}]:[],d._onstop=a.onstop?[{fn:a.onstop}]:[],d._onmute=a.onmute?[{fn:a.onmute}]:[],d._onvolume=a.onvolume?[{fn:a.onvolume}]:[],d._onrate=a.onrate?[{fn:a.onrate}]:[],d._onseek=a.onseek?[{fn:a.onseek}]:[],d._onunlock=a.onunlock?[{fn:a.onunlock}]:[],d._onresume=[],d._webAudio=r.usingWebAudio&&!d._html5,typeof r.ctx<"u"&&r.ctx&&r.autoUnlock&&r._unlockAudio(),r._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 a=this,d=null;if(r.noAudio){a._emit("loaderror",null,"No audio support.");return}typeof a._src=="string"&&(a._src=[a._src]);for(var p=0;p<a._src.length;p++){var f,m;if(a._format&&a._format[p])f=a._format[p];else{if(m=a._src[p],typeof m!="string"){a._emit("loaderror",null,"Non-string found in selected audio sources - ignoring.");continue}f=/^data:audio\/([^;,]+);/i.exec(m),f||(f=/\.([^.]+)$/.exec(m.split("?",1)[0])),f&&(f=f[1].toLowerCase())}if(f||console.warn('No file extension was found. Consider using the "format" property or specify an extension.'),f&&r.codecs(f)){d=a._src[p];break}}if(!d){a._emit("loaderror",null,"No codec support for selected audio sources.");return}return a._src=d,a._state="loading",window.location.protocol==="https:"&&d.slice(0,5)==="http:"&&(a._html5=!0,a._webAudio=!1),new t(a),a._webAudio&&i(a),a},play:function(a,d){var p=this,f=null;if(typeof a=="number")f=a,a=null;else{if(typeof a=="string"&&p._state==="loaded"&&!p._sprite[a])return null;if(typeof a>"u"&&(a="__default",!p._playLock)){for(var m=0,h=0;h<p._sounds.length;h++)p._sounds[h]._paused&&!p._sounds[h]._ended&&(m++,f=p._sounds[h]._id);m===1?a=null:f=null}}var y=f?p._soundById(f):p._inactiveSound();if(!y)return null;if(f&&!a&&(a=y._sprite||"__default"),p._state!=="loaded"){y._sprite=a,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&&r._autoResume();var v=Math.max(0,y._seek>0?y._seek:p._sprite[a][0]/1e3),w=Math.max(0,(p._sprite[a][0]+p._sprite[a][1])/1e3-v),b=w*1e3/Math.abs(y._rate),S=p._sprite[a][0]/1e3,A=(p._sprite[a][0]+p._sprite[a][1])/1e3;y._sprite=a,y._ended=!1;var _=function(){y._paused=!1,y._seek=v,y._start=S,y._stop=A,y._loop=!!(y._loop||p._sprite[a][2])};if(v>=A){p._ended(y);return}var x=y._node;if(p._webAudio){var P=function(){p._playLock=!1,_(),p._refreshBuffer(y);var N=y._muted||p._muted?0:y._volume;x.gain.setValueAtTime(N,r.ctx.currentTime),y._playStart=r.ctx.currentTime,typeof x.bufferSource.start>"u"?y._loop?x.bufferSource.noteGrainOn(0,v,86400):x.bufferSource.noteGrainOn(0,v,w):y._loop?x.bufferSource.start(0,v,86400):x.bufferSource.start(0,v,w),b!==1/0&&(p._endTimers[y._id]=setTimeout(p._ended.bind(p,y),b)),d||setTimeout(function(){p._emit("play",y._id),p._loadQueue()},0)};r.state==="running"&&r.ctx.state!=="interrupted"?P():(p._playLock=!0,p.once("resume",P),p._clearTimer(y._id))}else{var O=function(){x.currentTime=v,x.muted=y._muted||p._muted||r._muted||x.muted,x.volume=y._volume*r.volume(),x.playbackRate=y._rate;try{var N=x.play();if(N&&typeof Promise<"u"&&(N instanceof Promise||typeof N.then=="function")?(p._playLock=!0,_(),N.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,_(),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}a!=="__default"||y._loop?p._endTimers[y._id]=setTimeout(p._ended.bind(p,y),b):(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(L){p._emit("playerror",y._id,L)}};x.src==="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA"&&(x.src=p._src,x.load());var I=window&&window.ejecta||!x.readyState&&r._navigator.isCocoonJS;if(x.readyState>=3||I)O();else{p._playLock=!0,p._state="loading";var T=function(){p._state="loaded",O(),x.removeEventListener(r._canPlayEvent,T,!1)};x.addEventListener(r._canPlayEvent,T,!1),p._clearTimer(y._id)}}return y._id},pause:function(a){var d=this;if(d._state!=="loaded"||d._playLock)return d._queue.push({event:"pause",action:function(){d.pause(a)}}),d;for(var p=d._getSoundIds(a),f=0;f<p.length;f++){d._clearTimer(p[f]);var m=d._soundById(p[f]);if(m&&!m._paused&&(m._seek=d.seek(p[f]),m._rateSeek=0,m._paused=!0,d._stopFade(p[f]),m._node))if(d._webAudio){if(!m._node.bufferSource)continue;typeof m._node.bufferSource.stop>"u"?m._node.bufferSource.noteOff(0):m._node.bufferSource.stop(0),d._cleanBuffer(m._node)}else(!isNaN(m._node.duration)||m._node.duration===1/0)&&m._node.pause();arguments[1]||d._emit("pause",m?m._id:null)}return d},stop:function(a,d){var p=this;if(p._state!=="loaded"||p._playLock)return p._queue.push({event:"stop",action:function(){p.stop(a)}}),p;for(var f=p._getSoundIds(a),m=0;m<f.length;m++){p._clearTimer(f[m]);var h=p._soundById(f[m]);h&&(h._seek=h._start||0,h._rateSeek=0,h._paused=!0,h._ended=!0,p._stopFade(f[m]),h._node&&(p._webAudio?h._node.bufferSource&&(typeof h._node.bufferSource.stop>"u"?h._node.bufferSource.noteOff(0):h._node.bufferSource.stop(0),p._cleanBuffer(h._node)):(!isNaN(h._node.duration)||h._node.duration===1/0)&&(h._node.currentTime=h._start||0,h._node.pause(),h._node.duration===1/0&&p._clearSound(h._node))),d||p._emit("stop",h._id))}return p},mute:function(a,d){var p=this;if(p._state!=="loaded"||p._playLock)return p._queue.push({event:"mute",action:function(){p.mute(a,d)}}),p;if(typeof d>"u")if(typeof a=="boolean")p._muted=a;else return p._muted;for(var f=p._getSoundIds(d),m=0;m<f.length;m++){var h=p._soundById(f[m]);h&&(h._muted=a,h._interval&&p._stopFade(h._id),p._webAudio&&h._node?h._node.gain.setValueAtTime(a?0:h._volume,r.ctx.currentTime):h._node&&(h._node.muted=r._muted?!0:a),p._emit("mute",h._id))}return p},volume:function(){var a=this,d=arguments,p,f;if(d.length===0)return a._volume;if(d.length===1||d.length===2&&typeof d[1]>"u"){var m=a._getSoundIds(),h=m.indexOf(d[0]);h>=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(a._state!=="loaded"||a._playLock)return a._queue.push({event:"volume",action:function(){a.volume.apply(a,d)}}),a;typeof f>"u"&&(a._volume=p),f=a._getSoundIds(f);for(var g=0;g<f.length;g++)y=a._soundById(f[g]),y&&(y._volume=p,d[2]||a._stopFade(f[g]),a._webAudio&&y._node&&!y._muted?y._node.gain.setValueAtTime(p,r.ctx.currentTime):y._node&&!y._muted&&(y._node.volume=p*r.volume()),a._emit("volume",y._id))}else return y=f?a._soundById(f):a._sounds[0],y?y._volume:0;return a},fade:function(a,d,p,f){var m=this;if(m._state!=="loaded"||m._playLock)return m._queue.push({event:"fade",action:function(){m.fade(a,d,p,f)}}),m;a=Math.min(Math.max(0,parseFloat(a)),1),d=Math.min(Math.max(0,parseFloat(d)),1),p=parseFloat(p),m.volume(a,f);for(var h=m._getSoundIds(f),y=0;y<h.length;y++){var g=m._soundById(h[y]);if(g){if(f||m._stopFade(h[y]),m._webAudio&&!g._muted){var v=r.ctx.currentTime,w=v+p/1e3;g._volume=a,g._node.gain.setValueAtTime(a,v),g._node.gain.linearRampToValueAtTime(d,w)}m._startFadeInterval(g,a,d,p,h[y],typeof f>"u")}}return m},_startFadeInterval:function(a,d,p,f,m,h){var y=this,g=d,v=p-d,w=Math.abs(v/.01),b=Math.max(4,w>0?f/w:f),S=Date.now();a._fadeTo=p,a._interval=setInterval(function(){var A=(Date.now()-S)/f;S=Date.now(),g+=v*A,g=Math.round(g*100)/100,v<0?g=Math.max(p,g):g=Math.min(p,g),y._webAudio?a._volume=g:y.volume(g,a._id,!0),h&&(y._volume=g),(p<d&&g<=p||p>d&&g>=p)&&(clearInterval(a._interval),a._interval=null,a._fadeTo=null,y.volume(p,a._id),y._emit("fade",a._id))},b)},_stopFade:function(a){var d=this,p=d._soundById(a);return p&&p._interval&&(d._webAudio&&p._node.gain.cancelScheduledValues(r.ctx.currentTime),clearInterval(p._interval),p._interval=null,d.volume(p._fadeTo,a),p._fadeTo=null,d._emit("fade",a)),d},loop:function(){var a=this,d=arguments,p,f,m;if(d.length===0)return a._loop;if(d.length===1)if(typeof d[0]=="boolean")p=d[0],a._loop=p;else return m=a._soundById(parseInt(d[0],10)),m?m._loop:!1;else d.length===2&&(p=d[0],f=parseInt(d[1],10));for(var h=a._getSoundIds(f),y=0;y<h.length;y++)m=a._soundById(h[y]),m&&(m._loop=p,a._webAudio&&m._node&&m._node.bufferSource&&(m._node.bufferSource.loop=p,p&&(m._node.bufferSource.loopStart=m._start||0,m._node.bufferSource.loopEnd=m._stop,a.playing(h[y])&&(a.pause(h[y],!0),a.play(h[y],!0)))));return a},rate:function(){var a=this,d=arguments,p,f;if(d.length===0)f=a._sounds[0]._id;else if(d.length===1){var m=a._getSoundIds(),h=m.indexOf(d[0]);h>=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(a._state!=="loaded"||a._playLock)return a._queue.push({event:"rate",action:function(){a.rate.apply(a,d)}}),a;typeof f>"u"&&(a._rate=p),f=a._getSoundIds(f);for(var g=0;g<f.length;g++)if(y=a._soundById(f[g]),y){a.playing(f[g])&&(y._rateSeek=a.seek(f[g]),y._playStart=a._webAudio?r.ctx.currentTime:y._playStart),y._rate=p,a._webAudio&&y._node&&y._node.bufferSource?y._node.bufferSource.playbackRate.setValueAtTime(p,r.ctx.currentTime):y._node&&(y._node.playbackRate=p);var v=a.seek(f[g]),w=(a._sprite[y._sprite][0]+a._sprite[y._sprite][1])/1e3-v,b=w*1e3/Math.abs(y._rate);(a._endTimers[f[g]]||!y._paused)&&(a._clearTimer(f[g]),a._endTimers[f[g]]=setTimeout(a._ended.bind(a,y),b)),a._emit("rate",y._id)}}else return y=a._soundById(f),y?y._rate:a._rate;return a},seek:function(){var a=this,d=arguments,p,f;if(d.length===0)a._sounds.length&&(f=a._sounds[0]._id);else if(d.length===1){var m=a._getSoundIds(),h=m.indexOf(d[0]);h>=0?f=parseInt(d[0],10):a._sounds.length&&(f=a._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"&&(a._state!=="loaded"||a._playLock))return a._queue.push({event:"seek",action:function(){a.seek.apply(a,d)}}),a;var y=a._soundById(f);if(y)if(typeof p=="number"&&p>=0){var g=a.playing(f);g&&a.pause(f,!0),y._seek=p,y._ended=!1,a._clearTimer(f),!a._webAudio&&y._node&&!isNaN(y._node.duration)&&(y._node.currentTime=p);var v=function(){g&&a.play(f,!0),a._emit("seek",f)};if(g&&!a._webAudio){var w=function(){a._playLock?setTimeout(w,0):v()};setTimeout(w,0)}else v()}else if(a._webAudio){var b=a.playing(f)?r.ctx.currentTime-y._playStart:0,S=y._rateSeek?y._rateSeek-y._seek:0;return y._seek+(S+b*Math.abs(y._rate))}else return y._node.currentTime;return a},playing:function(a){var d=this;if(typeof a=="number"){var p=d._soundById(a);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(a){var d=this,p=d._duration,f=d._soundById(a);return f&&(p=d._sprite[f._sprite][1]/1e3),p},state:function(){return this._state},unload:function(){for(var a=this,d=a._sounds,p=0;p<d.length;p++)d[p]._paused||a.stop(d[p]._id),a._webAudio||(a._clearSound(d[p]._node),d[p]._node.removeEventListener("error",d[p]._errorFn,!1),d[p]._node.removeEventListener(r._canPlayEvent,d[p]._loadFn,!1),d[p]._node.removeEventListener("ended",d[p]._endFn,!1),r._releaseHtml5Audio(d[p]._node)),delete d[p]._node,a._clearTimer(d[p]._id);var f=r._howls.indexOf(a);f>=0&&r._howls.splice(f,1);var m=!0;for(p=0;p<r._howls.length;p++)if(r._howls[p]._src===a._src||a._src.indexOf(r._howls[p]._src)>=0){m=!1;break}return o&&m&&delete o[a._src],r.noAudio=!1,a._state="unloaded",a._sounds=[],a=null,null},on:function(a,d,p,f){var m=this,h=m["_on"+a];return typeof d=="function"&&h.push(f?{id:p,fn:d,once:f}:{id:p,fn:d}),m},off:function(a,d,p){var f=this,m=f["_on"+a],h=0;if(typeof d=="number"&&(p=d,d=null),d||p)for(h=0;h<m.length;h++){var y=p===m[h].id;if(d===m[h].fn&&y||!d&&y){m.splice(h,1);break}}else if(a)f["_on"+a]=[];else{var g=Object.keys(f);for(h=0;h<g.length;h++)g[h].indexOf("_on")===0&&Array.isArray(f[g[h]])&&(f[g[h]]=[])}return f},once:function(a,d,p){var f=this;return f.on(a,d,p,1),f},_emit:function(a,d,p){for(var f=this,m=f["_on"+a],h=m.length-1;h>=0;h--)(!m[h].id||m[h].id===d||a==="load")&&(setTimeout(function(y){y.call(this,d,p)}.bind(f,m[h].fn),0),m[h].once&&f.off(a,m[h].fn,m[h].id));return f._loadQueue(a),f},_loadQueue:function(a){var d=this;if(d._queue.length>0){var p=d._queue[0];p.event===a&&(d._queue.shift(),d._loadQueue()),a||p.action()}return d},_ended:function(a){var d=this,p=a._sprite;if(!d._webAudio&&a._node&&!a._node.paused&&!a._node.ended&&a._node.currentTime<a._stop)return setTimeout(d._ended.bind(d,a),100),d;var f=!!(a._loop||d._sprite[p][2]);if(d._emit("end",a._id),!d._webAudio&&f&&d.stop(a._id,!0).play(a._id),d._webAudio&&f){d._emit("play",a._id),a._seek=a._start||0,a._rateSeek=0,a._playStart=r.ctx.currentTime;var m=(a._stop-a._start)*1e3/Math.abs(a._rate);d._endTimers[a._id]=setTimeout(d._ended.bind(d,a),m)}return d._webAudio&&!f&&(a._paused=!0,a._ended=!0,a._seek=a._start||0,a._rateSeek=0,d._clearTimer(a._id),d._cleanBuffer(a._node),r._autoSuspend()),!d._webAudio&&!f&&d.stop(a._id,!0),d},_clearTimer:function(a){var d=this;if(d._endTimers[a]){if(typeof d._endTimers[a]!="function")clearTimeout(d._endTimers[a]);else{var p=d._soundById(a);p&&p._node&&p._node.removeEventListener("ended",d._endTimers[a],!1)}delete d._endTimers[a]}return d},_soundById:function(a){for(var d=this,p=0;p<d._sounds.length;p++)if(a===d._sounds[p]._id)return d._sounds[p];return null},_inactiveSound:function(){var a=this;a._drain();for(var d=0;d<a._sounds.length;d++)if(a._sounds[d]._ended)return a._sounds[d].reset();return new t(a)},_drain:function(){var a=this,d=a._pool,p=0,f=0;if(!(a._sounds.length<d)){for(f=0;f<a._sounds.length;f++)a._sounds[f]._ended&&p++;for(f=a._sounds.length-1;f>=0;f--){if(p<=d)return;a._sounds[f]._ended&&(a._webAudio&&a._sounds[f]._node&&a._sounds[f]._node.disconnect(0),a._sounds.splice(f,1),p--)}}},_getSoundIds:function(a){var d=this;if(typeof a>"u"){for(var p=[],f=0;f<d._sounds.length;f++)p.push(d._sounds[f]._id);return p}else return[a]},_refreshBuffer:function(a){var d=this;return a._node.bufferSource=r.ctx.createBufferSource(),a._node.bufferSource.buffer=o[d._src],a._panner?a._node.bufferSource.connect(a._panner):a._node.bufferSource.connect(a._node),a._node.bufferSource.loop=a._loop,a._loop&&(a._node.bufferSource.loopStart=a._start||0,a._node.bufferSource.loopEnd=a._stop||0),a._node.bufferSource.playbackRate.setValueAtTime(a._rate,r.ctx.currentTime),d},_cleanBuffer:function(a){var d=this,p=r._navigator&&r._navigator.vendor.indexOf("Apple")>=0;if(r._scratchBuffer&&a.bufferSource&&(a.bufferSource.onended=null,a.bufferSource.disconnect(0),p))try{a.bufferSource.buffer=r._scratchBuffer}catch{}return a.bufferSource=null,d},_clearSound:function(a){var d=/MSIE |Trident\//.test(r._navigator&&r._navigator.userAgent);d||(a.src="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA")}};var t=function(a){this._parent=a,this.init()};t.prototype={init:function(){var a=this,d=a._parent;return a._muted=d._muted,a._loop=d._loop,a._volume=d._volume,a._rate=d._rate,a._seek=0,a._paused=!0,a._ended=!0,a._sprite="__default",a._id=++r._counter,d._sounds.push(a),a.create(),a},create:function(){var a=this,d=a._parent,p=r._muted||a._muted||a._parent._muted?0:a._volume;return d._webAudio?(a._node=typeof r.ctx.createGain>"u"?r.ctx.createGainNode():r.ctx.createGain(),a._node.gain.setValueAtTime(p,r.ctx.currentTime),a._node.paused=!0,a._node.connect(r.masterGain)):r.noAudio||(a._node=r._obtainHtml5Audio(),a._errorFn=a._errorListener.bind(a),a._node.addEventListener("error",a._errorFn,!1),a._loadFn=a._loadListener.bind(a),a._node.addEventListener(r._canPlayEvent,a._loadFn,!1),a._endFn=a._endListener.bind(a),a._node.addEventListener("ended",a._endFn,!1),a._node.src=d._src,a._node.preload=d._preload===!0?"auto":d._preload,a._node.volume=p*r.volume(),a._node.load()),a},reset:function(){var a=this,d=a._parent;return a._muted=d._muted,a._loop=d._loop,a._volume=d._volume,a._rate=d._rate,a._seek=0,a._rateSeek=0,a._paused=!0,a._ended=!0,a._sprite="__default",a._id=++r._counter,a},_errorListener:function(){var a=this;a._parent._emit("loaderror",a._id,a._node.error?a._node.error.code:0),a._node.removeEventListener("error",a._errorFn,!1)},_loadListener:function(){var a=this,d=a._parent;d._duration=Math.ceil(a._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()),a._node.removeEventListener(r._canPlayEvent,a._loadFn,!1)},_endListener:function(){var a=this,d=a._parent;d._duration===1/0&&(d._duration=Math.ceil(a._node.duration*10)/10,d._sprite.__default[1]===1/0&&(d._sprite.__default[1]=d._duration*1e3),d._ended(a)),a._node.removeEventListener("ended",a._endFn,!1)}};var o={},i=function(a){var d=a._src;if(o[d]){a._duration=o[d].duration,c(a);return}if(/^data:[^;]+;base64,/.test(d)){for(var p=atob(d.split(",")[1]),f=new Uint8Array(p.length),m=0;m<p.length;++m)f[m]=p.charCodeAt(m);l(f.buffer,a)}else{var h=new XMLHttpRequest;h.open(a._xhr.method,d,!0),h.withCredentials=a._xhr.withCredentials,h.responseType="arraybuffer",a._xhr.headers&&Object.keys(a._xhr.headers).forEach(function(y){h.setRequestHeader(y,a._xhr.headers[y])}),h.onload=function(){var y=(h.status+"")[0];if(y!=="0"&&y!=="2"&&y!=="3"){a._emit("loaderror",null,"Failed loading audio file with status: "+h.status+".");return}l(h.response,a)},h.onerror=function(){a._webAudio&&(a._html5=!0,a._webAudio=!1,a._sounds=[],delete o[d],a.load())},s(h)}},s=function(a){try{a.send()}catch{a.onerror()}},l=function(a,d){var p=function(){d._emit("loaderror",null,"Decoding audio data failed.")},f=function(m){m&&d._sounds.length>0?(o[d._src]=m,c(d,m)):p()};typeof Promise<"u"&&r.ctx.decodeAudioData.length===1?r.ctx.decodeAudioData(a).then(f).catch(p):r.ctx.decodeAudioData(a,f,p)},c=function(a,d){d&&!a._duration&&(a._duration=d.duration),Object.keys(a._sprite).length===0&&(a._sprite={__default:[0,a._duration*1e3]}),a._state!=="loaded"&&(a._state="loaded",a._emit("load"),a._loadQueue())},u=function(){if(!!r.usingWebAudio){try{typeof AudioContext<"u"?r.ctx=new AudioContext:typeof webkitAudioContext<"u"?r.ctx=new webkitAudioContext:r.usingWebAudio=!1}catch{r.usingWebAudio=!1}r.ctx||(r.usingWebAudio=!1);var a=/iP(hone|od|ad)/.test(r._navigator&&r._navigator.platform),d=r._navigator&&r._navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/),p=d?parseInt(d[1],10):null;if(a&&p&&p<9){var f=/safari/.test(r._navigator&&r._navigator.userAgent.toLowerCase());r._navigator&&!f&&(r.usingWebAudio=!1)}r.usingWebAudio&&(r.masterGain=typeof r.ctx.createGain>"u"?r.ctx.createGainNode():r.ctx.createGain(),r.masterGain.gain.setValueAtTime(r._muted?0:r._volume,r.ctx.currentTime),r.masterGain.connect(r.ctx.destination)),r._setup()}};typeof define=="function"&&define.amd&&define([],function(){return{Howler:r,Howl:e}}),typeof Sl<"u"&&(Sl.Howler=r,Sl.Howl=e),typeof global<"u"?(global.HowlerGlobal=n,global.Howler=r,global.Howl=e,global.Sound=t):typeof window<"u"&&(window.HowlerGlobal=n,window.Howler=r,window.Howl=e,window.Sound=t)})();(function(){"use strict";HowlerGlobal.prototype._pos=[0,0,0],HowlerGlobal.prototype._orientation=[0,0,-1,0,1,0],HowlerGlobal.prototype.stereo=function(r){var e=this;if(!e.ctx||!e.ctx.listener)return e;for(var t=e._howls.length-1;t>=0;t--)e._howls[t].stereo(r);return e},HowlerGlobal.prototype.pos=function(r,e,t){var o=this;if(!o.ctx||!o.ctx.listener)return o;if(e=typeof e!="number"?o._pos[1]:e,t=typeof t!="number"?o._pos[2]:t,typeof r=="number")o._pos=[r,e,t],typeof o.ctx.listener.positionX<"u"?(o.ctx.listener.positionX.setTargetAtTime(o._pos[0],Howler.ctx.currentTime,.1),o.ctx.listener.positionY.setTargetAtTime(o._pos[1],Howler.ctx.currentTime,.1),o.ctx.listener.positionZ.setTargetAtTime(o._pos[2],Howler.ctx.currentTime,.1)):o.ctx.listener.setPosition(o._pos[0],o._pos[1],o._pos[2]);else return o._pos;return o},HowlerGlobal.prototype.orientation=function(r,e,t,o,i,s){var l=this;if(!l.ctx||!l.ctx.listener)return l;var c=l._orientation;if(e=typeof e!="number"?c[1]:e,t=typeof t!="number"?c[2]:t,o=typeof o!="number"?c[3]:o,i=typeof i!="number"?c[4]:i,s=typeof s!="number"?c[5]:s,typeof r=="number")l._orientation=[r,e,t,o,i,s],typeof l.ctx.listener.forwardX<"u"?(l.ctx.listener.forwardX.setTargetAtTime(r,Howler.ctx.currentTime,.1),l.ctx.listener.forwardY.setTargetAtTime(e,Howler.ctx.currentTime,.1),l.ctx.listener.forwardZ.setTargetAtTime(t,Howler.ctx.currentTime,.1),l.ctx.listener.upX.setTargetAtTime(o,Howler.ctx.currentTime,.1),l.ctx.listener.upY.setTargetAtTime(i,Howler.ctx.currentTime,.1),l.ctx.listener.upZ.setTargetAtTime(s,Howler.ctx.currentTime,.1)):l.ctx.listener.setOrientation(r,e,t,o,i,s);else return c;return l},Howl.prototype.init=function(r){return function(e){var t=this;return t._orientation=e.orientation||[1,0,0],t._stereo=e.stereo||null,t._pos=e.pos||null,t._pannerAttr={coneInnerAngle:typeof e.coneInnerAngle<"u"?e.coneInnerAngle:360,coneOuterAngle:typeof e.coneOuterAngle<"u"?e.coneOuterAngle:360,coneOuterGain:typeof e.coneOuterGain<"u"?e.coneOuterGain:0,distanceModel:typeof e.distanceModel<"u"?e.distanceModel:"inverse",maxDistance:typeof e.maxDistance<"u"?e.maxDistance:1e4,panningModel:typeof e.panningModel<"u"?e.panningModel:"HRTF",refDistance:typeof e.refDistance<"u"?e.refDistance:1,rolloffFactor:typeof e.rolloffFactor<"u"?e.rolloffFactor:1},t._onstereo=e.onstereo?[{fn:e.onstereo}]:[],t._onpos=e.onpos?[{fn:e.onpos}]:[],t._onorientation=e.onorientation?[{fn:e.onorientation}]:[],r.call(this,e)}}(Howl.prototype.init),Howl.prototype.stereo=function(r,e){var t=this;if(!t._webAudio)return t;if(t._state!=="loaded")return t._queue.push({event:"stereo",action:function(){t.stereo(r,e)}}),t;var o=typeof Howler.ctx.createStereoPanner>"u"?"spatial":"stereo";if(typeof e>"u")if(typeof r=="number")t._stereo=r,t._pos=[r,0,0];else return t._stereo;for(var i=t._getSoundIds(e),s=0;s<i.length;s++){var l=t._soundById(i[s]);if(l)if(typeof r=="number")l._stereo=r,l._pos=[r,0,0],l._node&&(l._pannerAttr.panningModel="equalpower",(!l._panner||!l._panner.pan)&&n(l,o),o==="spatial"?typeof l._panner.positionX<"u"?(l._panner.positionX.setValueAtTime(r,Howler.ctx.currentTime),l._panner.positionY.setValueAtTime(0,Howler.ctx.currentTime),l._panner.positionZ.setValueAtTime(0,Howler.ctx.currentTime)):l._panner.setPosition(r,0,0):l._panner.pan.setValueAtTime(r,Howler.ctx.currentTime)),t._emit("stereo",l._id);else return l._stereo}return t},Howl.prototype.pos=function(r,e,t,o){var i=this;if(!i._webAudio)return i;if(i._state!=="loaded")return i._queue.push({event:"pos",action:function(){i.pos(r,e,t,o)}}),i;if(e=typeof e!="number"?0:e,t=typeof t!="number"?-.5:t,typeof o>"u")if(typeof r=="number")i._pos=[r,e,t];else return i._pos;for(var s=i._getSoundIds(o),l=0;l<s.length;l++){var c=i._soundById(s[l]);if(c)if(typeof r=="number")c._pos=[r,e,t],c._node&&((!c._panner||c._panner.pan)&&n(c,"spatial"),typeof c._panner.positionX<"u"?(c._panner.positionX.setValueAtTime(r,Howler.ctx.currentTime),c._panner.positionY.setValueAtTime(e,Howler.ctx.currentTime),c._panner.positionZ.setValueAtTime(t,Howler.ctx.currentTime)):c._panner.setPosition(r,e,t)),i._emit("pos",c._id);else return c._pos}return i},Howl.prototype.orientation=function(r,e,t,o){var i=this;if(!i._webAudio)return i;if(i._state!=="loaded")return i._queue.push({event:"orientation",action:function(){i.orientation(r,e,t,o)}}),i;if(e=typeof e!="number"?i._orientation[1]:e,t=typeof t!="number"?i._orientation[2]:t,typeof o>"u")if(typeof r=="number")i._orientation=[r,e,t];else return i._orientation;for(var s=i._getSoundIds(o),l=0;l<s.length;l++){var c=i._soundById(s[l]);if(c)if(typeof r=="number")c._orientation=[r,e,t],c._node&&(c._panner||(c._pos||(c._pos=i._pos||[0,0,-.5]),n(c,"spatial")),typeof c._panner.orientationX<"u"?(c._panner.orientationX.setValueAtTime(r,Howler.ctx.currentTime),c._panner.orientationY.setValueAtTime(e,Howler.ctx.currentTime),c._panner.orientationZ.setValueAtTime(t,Howler.ctx.currentTime)):c._panner.setOrientation(r,e,t)),i._emit("orientation",c._id);else return c._orientation}return i},Howl.prototype.pannerAttr=function(){var r=this,e=arguments,t,o,i;if(!r._webAudio)return r;if(e.length===0)return r._pannerAttr;if(e.length===1)if(typeof e[0]=="object")t=e[0],typeof o>"u"&&(t.pannerAttr||(t.pannerAttr={coneInnerAngle:t.coneInnerAngle,coneOuterAngle:t.coneOuterAngle,coneOuterGain:t.coneOuterGain,distanceModel:t.distanceModel,maxDistance:t.maxDistance,refDistance:t.refDistance,rolloffFactor:t.rolloffFactor,panningModel:t.panningModel}),r._pannerAttr={coneInnerAngle:typeof t.pannerAttr.coneInnerAngle<"u"?t.pannerAttr.coneInnerAngle:r._coneInnerAngle,coneOuterAngle:typeof t.pannerAttr.coneOuterAngle<"u"?t.pannerAttr.coneOuterAngle:r._coneOuterAngle,coneOuterGain:typeof t.pannerAttr.coneOuterGain<"u"?t.pannerAttr.coneOuterGain:r._coneOuterGain,distanceModel:typeof t.pannerAttr.distanceModel<"u"?t.pannerAttr.distanceModel:r._distanceModel,maxDistance:typeof t.pannerAttr.maxDistance<"u"?t.pannerAttr.maxDistance:r._maxDistance,refDistance:typeof t.pannerAttr.refDistance<"u"?t.pannerAttr.refDistance:r._refDistance,rolloffFactor:typeof t.pannerAttr.rolloffFactor<"u"?t.pannerAttr.rolloffFactor:r._rolloffFactor,panningModel:typeof t.pannerAttr.panningModel<"u"?t.pannerAttr.panningModel:r._panningModel});else return i=r._soundById(parseInt(e[0],10)),i?i._pannerAttr:r._pannerAttr;else e.length===2&&(t=e[0],o=parseInt(e[1],10));for(var s=r._getSoundIds(o),l=0;l<s.length;l++)if(i=r._soundById(s[l]),i){var c=i._pannerAttr;c={coneInnerAngle:typeof t.coneInnerAngle<"u"?t.coneInnerAngle:c.coneInnerAngle,coneOuterAngle:typeof t.coneOuterAngle<"u"?t.coneOuterAngle:c.coneOuterAngle,coneOuterGain:typeof t.coneOuterGain<"u"?t.coneOuterGain:c.coneOuterGain,distanceModel:typeof t.distanceModel<"u"?t.distanceModel:c.distanceModel,maxDistance:typeof t.maxDistance<"u"?t.maxDistance:c.maxDistance,refDistance:typeof t.refDistance<"u"?t.refDistance:c.refDistance,rolloffFactor:typeof t.rolloffFactor<"u"?t.rolloffFactor:c.rolloffFactor,panningModel:typeof t.panningModel<"u"?t.panningModel:c.panningModel};var u=i._panner;u?(u.coneInnerAngle=c.coneInnerAngle,u.coneOuterAngle=c.coneOuterAngle,u.coneOuterGain=c.coneOuterGain,u.distanceModel=c.distanceModel,u.maxDistance=c.maxDistance,u.refDistance=c.refDistance,u.rolloffFactor=c.rolloffFactor,u.panningModel=c.panningModel):(i._pos||(i._pos=r._pos||[0,0,-.5]),n(i,"spatial"))}return r},Sound.prototype.init=function(r){return function(){var e=this,t=e._parent;e._orientation=t._orientation,e._stereo=t._stereo,e._pos=t._pos,e._pannerAttr=t._pannerAttr,r.call(this),e._stereo?t.stereo(e._stereo):e._pos&&t.pos(e._pos[0],e._pos[1],e._pos[2],e._id)}}(Sound.prototype.init),Sound.prototype.reset=function(r){return function(){var e=this,t=e._parent;return e._orientation=t._orientation,e._stereo=t._stereo,e._pos=t._pos,e._pannerAttr=t._pannerAttr,e._stereo?t.stereo(e._stereo):e._pos?t.pos(e._pos[0],e._pos[1],e._pos[2],e._id):e._panner&&(e._panner.disconnect(0),e._panner=void 0,t._refreshBuffer(e)),r.call(this)}}(Sound.prototype.reset);var n=function(r,e){e=e||"spatial",e==="spatial"?(r._panner=Howler.ctx.createPanner(),r._panner.coneInnerAngle=r._pannerAttr.coneInnerAngle,r._panner.coneOuterAngle=r._pannerAttr.coneOuterAngle,r._panner.coneOuterGain=r._pannerAttr.coneOuterGain,r._panner.distanceModel=r._pannerAttr.distanceModel,r._panner.maxDistance=r._pannerAttr.maxDistance,r._panner.refDistance=r._pannerAttr.refDistance,r._panner.rolloffFactor=r._pannerAttr.rolloffFactor,r._panner.panningModel=r._pannerAttr.panningModel,typeof r._panner.positionX<"u"?(r._panner.positionX.setValueAtTime(r._pos[0],Howler.ctx.currentTime),r._panner.positionY.setValueAtTime(r._pos[1],Howler.ctx.currentTime),r._panner.positionZ.setValueAtTime(r._pos[2],Howler.ctx.currentTime)):r._panner.setPosition(r._pos[0],r._pos[1],r._pos[2]),typeof r._panner.orientationX<"u"?(r._panner.orientationX.setValueAtTime(r._orientation[0],Howler.ctx.currentTime),r._panner.orientationY.setValueAtTime(r._orientation[1],Howler.ctx.currentTime),r._panner.orientationZ.setValueAtTime(r._orientation[2],Howler.ctx.currentTime)):r._panner.setOrientation(r._orientation[0],r._orientation[1],r._orientation[2])):(r._panner=Howler.ctx.createStereoPanner(),r._panner.pan.setValueAtTime(r._stereo,Howler.ctx.currentTime)),r._panner.connect(r._node),r._paused||r._parent.pause(r._id,!0).play(r._id,!0)}})()});var J_={};Ed(J_,{default:()=>jl});module.exports=ig(J_);var Fl=require("three");var Re=class{modifyById(r,e){let t=this;if(t[r]===void 0)throw new Error("not expected");{let i={...t,[r]:e};return Object.setPrototypeOf(i,Re.prototype),i}}add(r,e){return this.runOp({type:1,id:r,data:e})?.data??this}runOp(r){let e=this;if(r.type===1){let t=e[r.id],o;t===void 0?o={type:2,id:r.id}:o={type:1,id:r.id,data:t};let{id:i,data:s}=r,l={...e,[i]:s};return Object.setPrototypeOf(l,Re.prototype),{data:l,actual:r,reverse:o}}else if(r.type===2){let{id:t}=r,o=e[t];if(o===void 0)return null;{let i={...e};return Object.setPrototypeOf(i,Re.prototype),delete i[t],{data:i,actual:r,reverse:{type:1,id:t,data:o}}}}return null}};function Ei(n){if(n.deepFreeze!==void 0){n.deepFreeze(n);return}let r=Object.getOwnPropertyNames(n);for(let e of r){let t=n[e];t&&typeof t=="object"&&Ei(t)}return Object.freeze(n)}function Md(n,r){let e=0;for(;e<n.length&&e<r.length;){if(n[e]<r[e])return-1;if(n[e]>r[e])return 1;e+=1}return e!==r.length?-1:e!==n.length?1:0}var nn=class extends Error{};function $s(n){let r={...n};return Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r}function vr(n,r,e){if(n===void 0?r===void 0?(n=0,r=10):n=r-10:r===void 0&&(r=n+10),n>r){let i=n;n=r,r=i}let t=[],o=1/(e+1);for(let i=0;i<e;i++){let s=n+(r-n)*(i+.75+Math.random()*.5)*o;t.push(s)}return t}function sn(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 Bd(){return typeof process<"u"}function Dd(n,r){for(let e of n)r(e.id,e.data)!==!0&&Dd(e.children,r)}function Gd(n,r){if(r(n.id,n.data)!==!0)for(let e of n.children)Gd(e,r)}var Qe=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,Qe.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Ei(this[e]),e++}fillCaches0(e,t){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,t);for(let o of e.children)this.fillCaches0(o,e.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let e of this)this.fillCaches0(e,null)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}nonExistOrDescendantOf(e,t){if(!this.has(e))return!0;for(;e;){let o=this.parent(e);if(o===t)return!0;e=o}return!1}isDescendantOf(e,t){for(;e;){let o=this.parent(e);if(o===t)return!0;e=o}return!1}data(e){return this.get(e)?.data}has(e){return this.childrenOf(e)!==void 0}get(e){return this.fillCaches(),this.objCaches.get(e)}childrenOf(e){return e===null?this:this.get(e)?.children}traverseFrom(e,t){if(e===null)this.traverse(t);else{let o=this.get(e);o&&Gd(o,t)}}traverse(e){Dd(this,e)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(e){return this.fillCaches(),this.parentCaches.get(e)}childrenArray(e){return e===null?this:this.get(e).children}modifyById(e,t){if(this.get(e)===void 0)throw new Error("not expected");{let i=this.parent(e),s=this.childrenArray(i),l=s.findIndex(a=>a.id===e);if(l<0)throw new Error("not expected");let c=s[l];return s=[...s],s[l]={...c,data:t},this.modifyArrayBy(i,s)}}modifyArrayBy(e,t){let o=e,i=t;for(;o!==null;){let l=i,c=o;if(o=this.parent(o),o===void 0)throw new Error;i=this.childrenArray(o);let u=i.findIndex(a=>a.id===c);if(u<0)throw new Error;i=[...i],i[u]={...i[u],children:l}}Object.setPrototypeOf(i,Qe.prototype);let s=i;return s.fillCaches(),s}runOp(e){switch(e.type){case 7:return this.addOp(e);case 8:return this.deleteOp(e);case 9:return this.moveOp(e)}return null}checkDuplicatedIdRec({id:e,children:t}){if(this.get(e)!==void 0)return!0;for(let o of t)if(this.checkDuplicatedIdRec(o))return!0;return!1}addOp(e){let{parent:t,fi:o,id:i,data:s,children:l}=e;if(t!==null&&this.get(t)===void 0)return null;if(this.checkDuplicatedIdRec(e))return null;{let c=t,u=this.childrenArray(c),a={fi:o,id:i,data:s,children:l};return u=[...u,a],u.sort((p,f)=>p.fi-f.fi),e.localIndex=u.indexOf(a),{data:this.modifyArrayBy(c,u),actual:e,reverse:{type:8,id:i}}}}deleteOp(e){let{id:t}=e;if(this.get(t)===null)return null;{let o=this.parent(t);if(o===void 0)return null;let i=this.childrenArray(o),s=i.findIndex(u=>u.id===t);e.localIndex=s,i=[...i];let l=i.splice(s,1)[0];return{data:this.modifyArrayBy(o,i),actual:e,reverse:{type:7,...l,parent:o}}}}moveOp(e){let{parent:t,fi:o,id:i}=e;if(t!==null&&this.get(t)===void 0)return this.deleteOp({type:8,id:i});if(t!==null){let f=t;for(;f!==null;){if(f===void 0)throw new Error;if(f===i)throw new nn("cyclic tree");f=this.parent(f)}}let s=this.parent(i);if(s===void 0)return null;let l=s,c=this.childrenArray(s),u=c.findIndex(f=>f.id===i);c=[...c];let a=c.splice(u,1)[0],d=this.modifyArrayBy(s,c);s=t,c=d.childrenArray(s);let p=a.fi;return a={...a,fi:o},c=[...c,a],c.sort((f,m)=>f.fi-m.fi),e.localIndex=c.indexOf(a),d=d.modifyArrayBy(s,c),{data:d,actual:e,reverse:{type:9,parent:l,fi:p,id:i}}}previous(e,t){if(t===null){let i=this.childrenArray(e);return i.length===0?null:i[i.length-1].id}let o=null;for(let i of this.childrenArray(e)){if(i.id===t)return o;o=i.id}return null}traverseSortNext(e){let t=this.parent(e);if(t!==void 0){let o=this.childrenArray(t),i=o.findIndex(s=>s.id===e)+1;if(i<o.length)return o[i].id;if(t)return this.traverseSortNext(t)}}sortNext(e){let t=this.childrenArray(e);return t.length>0?t[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let t=this.childrenArray(e);return t.length>0?this.traverseSortPrevious(t[t.length-1].id):e}sortPrevious(e){let t=this.parent(e);if(t!==void 0){let o=this.childrenArray(t),i=o.findIndex(s=>s.id===e)-1;return i>=0?this.traverseSortPrevious(o[i].id):t}}getAllSorted(e){let t=[];for(let o of e){let i=this.getWithSortKey(o.id);i!==void 0&&t.push({...o,...i})}t.sort((o,i)=>Md(o.sortKey,i.sortKey));for(let o of t)delete o.sortKey;return t}getWithSortKey(e){var t=e;let o=[],i=this.get(t),s=i;if(i!==void 0){for(;t;)o.splice(0,0,i.fi),t=this.parent(t),t!==null&&(i=this.get(t));return{...s,sortKey:o}}}insertBeforeHelper(e,t,o){return this.insertAfterHelper(e,this.previous(e,t),o)}insertAfterHelper(e,t,o){let i=this.childrenArray(e);if(t===null){if(i.length===0)return vr(0,o,o);{let s=i[0].fi;return vr(s-o,s,o)}}else{let s=this.get(t);if(s===void 0||this.parent(t)!==e)throw new Error("illegal args");let l=i.find(c=>c.fi>s.fi);if(l===void 0){let c=i[i.length-1].fi;return vr(c,c+o,o)}else return vr(s.fi,l.fi,o)}}};var an;(r=>{function n(e,t){if(t.type!==0)return null;if(Array.isArray(e)){let o=t.props,i={},s=[...e],l=!1;if(o)for(let c of Object.keys(o)){let u=parseInt(c);if(isNaN(u))throw new Error("wrong index");i[c]=s[u],s[u]=o[c],l=!0}return l?{data:s,actual:t,reverse:{type:0,props:i}}:null}else{let o=t.props,i={},s={...e},l=!1;if(o)for(let c of Object.keys(o)){i[c]=s[c];let u=o[c];u===void 0?delete s[c]:s[c]=u,l=!0}return l?{data:s,actual:t,reverse:{type:0,props:i}}:null}}r.runOp=n})(an||(an={}));var xe=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,xe.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Ei(this[e]),e++}fillCaches0(e){this.objCaches.set(e.id,e)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,Object.getOwnPropertyDescriptor(this,"objCaches").enumerable=!1;for(let e of this)this.fillCaches0(e)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}data(e){return this.get(e)?.data}get(e){return this.fillCaches(),this.objCaches.get(e)}modifyById(e,t){if(this.get(e)===void 0)throw new Error("not expected");{let i=this,s=i.findIndex(u=>u.id===e);if(s<0)throw new Error("not expected");let l=i[s];return i=[...i],i[s]={...l,data:t},this.modifyArrayBy(i)}}modifyArrayBy(e){Object.setPrototypeOf(e,xe.prototype);let t=e;return Bd()||t.fillCaches(),t}runOp(e){switch(e.type){case 4:return this.addOp(e);case 5:return this.deleteOp(e);case 6:return this.moveOp(e)}return null}addOp(e){let{fi:t,id:o,data:i}=e,s=this,l={fi:t,id:o,data:i};return s=[...s,l],s.sort((u,a)=>u.fi-a.fi),e.localIndex=s.indexOf(l),{data:this.modifyArrayBy(s),actual:e,reverse:{type:5,id:o}}}deleteOp(e){let{id:t}=e,o=this,i=o.findIndex(c=>c.id===t);if(i===-1)return null;e.localIndex=i,o=[...o];let s=o.splice(i,1)[0];return{data:this.modifyArrayBy(o),actual:e,reverse:{type:4,...s}}}moveOp(e){let{fi:t,id:o}=e,i=this;i=[...i];let s=i.findIndex(a=>a.id===o);if(s===-1)return null;let l=i[s].fi,c={...i[s],fi:t};return i[s]=c,i.sort((a,d)=>a.fi-d.fi),e.localIndex=i.indexOf(c),{data:this.modifyArrayBy(i),actual:e,reverse:{type:6,fi:l,id:o}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let t=null;for(let o of this){if(o.id===e)return t;t=o.id}return null}insertBeforeHelper(e,t){return this.insertAfterHelper(this.previous(e),t)}insertAfterHelper(e,t){let o=this;if(e===null){if(o.length===0)return vr(0,t,t);{let i=o[0].fi;return vr(i-t,i,t)}}else{let i=this.get(e);if(i===void 0)throw new Error("illegal args");let s=o.find(l=>l.fi>i.fi);if(s===void 0){let l=o[o.length-1].fi;return vr(l,l+t,t)}else return vr(i.fi,s.fi,t)}}};function ln(n){return n&&typeof n=="object"&&n instanceof ze}var ze=class{unusedFunOverridesTable(r){}runOp(r){let e=[],t=this,o=0,i={};for(;o<r.path.length;){if(e.push(t),t=t===void 0?void 0:t[r.path[o]],t!==void 0&&!ln(t))return null;o+=1}t=t?$s(t):new ze;for(let[c,u]of Object.entries(r.props)){let a=t[c];i[c]=a,u===void 0?delete t[c]:t[c]=u}for(;o>0;){if(Object.keys(t).length===0){let c=e[o-1];c&&(t=$s(c),delete t[r.path[o-1]])}else{let c=e[o-1];if(c){let u=$s(c);u[r.path[o-1]]=t,t=u}else{let u=new ze;u[r.path[o-1]]=t,t=u}}o-=1}let s=Object.setPrototypeOf(t,ze.prototype),l={...r,props:i};return{data:s,actual:r,reverse:l}}},zr;(t=>{function n(o,i){return Li(o,i)??o}t.apply=n;function r(o,i){return ql(o,i)}t.merge=r;function e(o,i){let s=0,l=i.path,c=o;for(;s<l.length&&c!==void 0;){if(c=wt.zoomOnce(c,l[s]),c===void 0)return i;if(!ln(c))return;s+=1}if(c===void 0)return i;if(!!ln(c))if(i.type===0){let u={...i.props};for(let a of Object.keys(c))delete u[a];return{...i,props:u}}else if(i.type===1||i.type===4||i.type===7){let u=Wl([i],c);return u?(console.log(u),u):i}else return i}t.filterOp=e})(zr||(zr={}));function Wl(n,r){if(r===void 0)return;let e=!1,t=n.map(o=>{let i=o.id,s=Li(o.data,r[i]);if(e=e||s!==void 0,s===void 0&&(s=o.data),o.children){let l=Wl(o.children,r);return l!==void 0?e=!0:l=o.children,{...o,id:i,data:s,children:l}}else return{...o,id:i,data:s}});if(e)return t}function sg(n,r){if(r===void 0)return;let e=!1,t=n.map(o=>{let i=o.id,s=Li(o.data,r[i]);return e=e||s!==void 0,s===void 0&&(s=o.data),{...o,id:i,data:s}});if(e)return Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t}function Li(n,r){if(!ln(r))return r;if(n instanceof Qe){let e=Wl(n,r);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e}else{if(n instanceof xe)return sg(n,r);if(Array.isArray(n)){let e=!1,t=n.map((o,i)=>{let s=Li(o,r[i]);return e=e||s!==void 0,s===void 0&&(s=o),s});return e?(Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t):void 0}else{if(n instanceof ze)return ql(n,r);if(n&&typeof n=="object"){let e={},t=!1;for(let[o,i]of Object.entries(n)){let s=Li(i,r[o]);t=t||s!==void 0,s===void 0&&(s=i),e[o]=s}return t?(Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e):void 0}}}}function ql(n,r){if(n===void 0)return r;if(r===void 0)return n;if(!ln(r))return r;if(!ln(n))return zr.apply(n,r);let e=new Set;for(let o of Object.keys(n))e.add(o);for(let o of Object.keys(r))e.add(o);let t=new ze;for(let o of e){let i=ql(n===void 0?void 0:n[o],r===void 0?void 0:r[o]);t[o]=i}return t}function Rd(n,r){let e={cur:[],result:[],len:0};return n=Mi(n,r,e)??n,[n,e.result]}function Ys(n,r){return n===null?null:(n.cur[n.len]=r,n.len+=1,n)}function Xs(n){n&&(n.len-=1)}function ag(n){if(n===null)return null;n.result.push(n.cur.slice(0,n.len))}function Vd(n,r,e){let t=!1,o=n.map(i=>{let s=i.id,l=r[s];if(l!==void 0&&typeof l=="string"&&(t=!0,s=l,e!==null))throw new Error("not supported");let c=Mi(i.data,r,Ys(e,s));Xs(e),t=t||c!==void 0,c===void 0&&(c=i.data);let u=Vd(i.children,r,e);return u!==void 0?t=!0:u=i.children,{...i,id:s,data:c,children:u}});if(t)return o}function lg(n,r,e){let t=!1,o=n.map(i=>{let s=i.id,l=r[s];if(l!==void 0&&typeof l=="string"&&(t=!0,s=l,e!==null))throw new Error("not supported");let c=Mi(i.data,r,Ys(e,s));return Xs(e),t=t||c!==void 0,c===void 0&&(c=i.data),{...i,id:s,data:c}});if(t)return Object.setPrototypeOf(o,Object.getPrototypeOf(n)),o}function Mi(n,r,e){if(n instanceof Qe){let t=Vd(n,r,e);return t!==void 0&&Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t}else{if(n instanceof xe)return lg(n,r,e);if(Array.isArray(n)){let t=!1,o=n.map((i,s)=>{let l=Mi(i,r,Ys(e,s));return Xs(e),t=t||l!==void 0,l===void 0&&(l=i),l});return t?(Object.setPrototypeOf(o,Object.getPrototypeOf(n)),o):void 0}else if(n&&typeof n=="object"&&!sn(n)){let t={},o=!1;for(let[i,s]of Object.entries(n))if(i!=="name"&&i!=="text"){let l=r[i];if(typeof l=="string"){if(e!==null)throw new Error("not supported");o=!0,i=l}let c=Mi(s,r,Ys(e,i));Xs(e),o=o||c!==void 0,c===void 0&&(c=s),t[i]=c}else t[i]=s;return o?(Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t):void 0}else if(typeof n=="string"){let t=r[n];if(t!==void 0){if(n.length!==36)throw new Error("for now you should only call this method when the key is a uuid");ag(e)}return t}else return}}var Ks;(r=>{function n(e,t){let o=wt.zoom(t,e.path);if(typeof o=="object"){let i={};for(let s of Object.keys(e.props))i[s]=o[s];return{...e,props:i}}else return{...e,props:{}}}r.replaceProps=n})(Ks||(Ks={}));var ft;(l=>{function n(c,u){return{...c,path:c.path.slice(u)}}l.drop=n;function r(c,u){return e(c,u)?.data??c}l.applySimple=r;function e(c,u){let a=u.path;for(var d=[];;){let p;if(c instanceof ze&&u.type===0&&(p=c.runOp({...u,path:a.slice(d.length)}),p===null&&(p=void 0)),d.length===a.length&&(c instanceof Qe||c instanceof xe||c instanceof Re?p=c.runOp(u):p=an.runOp(c,u)),p!==void 0)if(p!==null){let h=p.data;for(let y=d.length-1;y>=0;y--){let g=a[y],v=d[y];if(v instanceof Qe){if(typeof g=="number")throw new Error("illegal arg");h=v.modifyById(g,h)}else if(v instanceof xe){if(typeof g=="number")throw new Error("illegal arg");h=v.modifyById(g,h)}else if(v instanceof Re){if(typeof g=="number")throw new Error("illegal arg");h=v.modifyById(g,h)}else if(v instanceof ze){let w={...v,[g]:h};h=Object.setPrototypeOf(w,ze.prototype)}else if(typeof v=="object")if(Array.isArray(v)){if(typeof g=="string"&&(g=parseInt(g),isNaN(g)))throw new Error("Invalid path");let w=h;h=[...v],h[g]=w}else h={...v,[g]:h};else return null}return{data:h,actual:{...p.actual,path:a},reverse:{...p.reverse,path:a}}}else return null;let f=a[d.length],m;if(c instanceof Qe){if(typeof f=="number")throw new Error("");m=c.get(f)?.data}else if(c instanceof xe){if(typeof f=="number")throw new Error("");m=c.get(f)?.data}else c!==null&&(m=c[f]);if(m!==void 0)d.push(c),c=m;else return null}}l.apply=e;function t(c,u){for(let a=0;a<c.length&&a<u.length;a++)if(c[a]!==u[a])return!0;return!1}l.pathDisjoint=t;function o(c,u){if(c.length!==u.length)return!1;for(let a=0;a<c.length;a++)if(c[a]!==u[a])return!1;return!0}l.pathEq=o;function i(c,u){return t(c.path,u.path)}l.commutative=i;function s(c,u){return c.type===0&&u.type===0&&o(c.path,u.path)?Object.keys(c.props).every(a=>u.props[a]!==void 0):!1}l.subsumed=s})(ft||(ft={}));var $l;(c=>{function n(){return[]}c.empty=n;function r(u,a){let d=[];for(let p of u){let[f,...m]=p.path;f===a&&d.push({...p,path:m})}return d}c.removePrefix=r;function e(u,a){return u.map(d=>({...d,path:[a,...d.path]}))}c.addPrefix=e;function t(u,a){return[...u,...a]}c.concat=t;function o(u,a){return[...u.filter(p=>!a.some(f=>ft.subsumed(p,f))),...a]}c.compress=o;function i(u,a){return u.every(d=>a.every(p=>ft.commutative(d,p)))}c.commutative=i;function s(u,a){for(let d of a){let p=l(u,d);p!==null&&(u=p.data)}return u}c.applyAll=s;function l(u,a){var d=u;let p=[],f=[];for(let m of a)try{if(m.type===3){let h=wt.zoom(d,[...m.path,m.id]),y=ft.apply(d,{...m,type:2});if(y!==null){d=y.data;let[g,v]=Rd(d,{[m.id]:h});d=g;for(let w of v){let b=w[w.length-1];w.splice(w.length-1,1),p.push({type:0,path:w,props:{[b]:h}}),f.push({type:0,path:w,props:{[b]:m.id}})}f.push(y.reverse),p.push(y.actual)}}else{let h=ft.apply(d,m);h!==null&&(p.push(h.actual),d=h.data,f.push(h.reverse))}}catch(h){if(h instanceof nn)return null;throw h}return{data:d,actual:p,reverse:f.reverse()}}c.apply=l})($l||($l={}));var jd=Symbol(),cg=Symbol(),Qs=Symbol(),Io=class{reportOp(r,e,t=[]){let o=this;if(e===null)return;o._current=e.data;let i=t;for(;!(o instanceof Zs);){let s=o._path,l=o._current;if(s!==""&&i.splice(0,0,s),o=o._parent,o===null)return;o.update(s,l)}o.push(i,r,e.actual,e.reverse)}deleteChildren(r){if(this._children){let e=this._children[r];if(e){let t=e[Qs];t&&t(),delete this._children[r]}}}},Xl=class extends Io{constructor(r,e,t){super(),this._parent=r,this._path=e,this._current=t}update(r,e){if(Array.isArray(this._current)){if(typeof r=="string"&&(r=parseInt(r),isNaN(r)))throw new Error("Invalid path");this._current=[...this._current],this._current[r]=e}else this._current={...this._current,[r]:e}}runOp(r){this.reportOp(r,an.runOp(this._current,r),r.path)}},Kl=class extends Io{constructor(r,e,t){super(),this._parent=r,this._path=e,this._current=t}update(r,e){this._current={...this._current,[r]:e},Object.setPrototypeOf(this._current,Re.prototype)}runOp(r){this.reportOp(r,this._current.runOp(r))}},Fd={get(n,r){if(r===Qs)return()=>{n._parent=null};if(r===jd)return n._current;if(r===cg)return n;let{_current:e,_children:t}=n;if(r==="push"&&Array.isArray(e))throw new Error("not supported to expand array");let o=t===void 0?void 0:t[r];if(o!==void 0)return o;let i=e[r],s=Js(n,r,i);return s!==i?(t===void 0&&(t={},n._children=t),t[r]=s,s):i},has(n,r){return r in n._current},ownKeys(n){return Reflect.ownKeys(n._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(n){return Object.getPrototypeOf(n._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(n,r){let e=n._current,t=Reflect.getOwnPropertyDescriptor(e,r);return t&&{writable:!0,configurable:!0,enumerable:t.enumerable,value:e[r]}}},dg={...Fd,set(n,r,e){let t={type:0,props:{[r]:at(e)??e}};return n.deleteChildren(r),n.runOp(t),!0},deleteProperty(n,r){let e={type:0,props:{[r]:void 0}};return n.deleteChildren(r),n.runOp(e),!0}},ug={...Fd,set(n,r,e){return e===void 0?this.deleteProperty(n,r):(n.deleteChildren(r),n.runOp({type:1,id:r,data:e})),!0},deleteProperty(n,r){return n.runOp({type:2,id:r}),!0}},cn=class extends Io{constructor(r,e,t){super(),this._children={},this._parent=r,this._path=e,this._current=t,this[Qs]=()=>{this._parent=null}}unproxy(){return this._current}update(r,e){this._current=this._current.modifyById(r,e)}runOp(r){this.reportOp(r,this._current.runOp(r))}randomId(){return this._current.randomId()}isDescendantOf(r,e){return this._current.isDescendantOf(r,e)}childrenOf(r){return this._current.childrenOf(r)}traverse(r){return this._current.traverse(r)}get(r){return this._current.get(r)}parent(r){return this._current.parent(r)}traverse(r){this._current.traverse((e,t)=>{r(e,this.data(e))})}data(r){let{_current:e,_children:t}=this,o=t===void 0?void 0:t[r];if(o!==void 0)return o;let i=e.get(r)?.data,s=Js(this,r,i);return s!==i?(t===void 0&&(t={},this._children=t),t[r]=s,s):i}add(r,e,t,o,i){this.runOp({type:7,parent:r,fi:e,id:t,data:o,children:i})}move(r,e,t){this.runOp({type:9,parent:r,fi:e,id:t})}insertAfter(r,e,t){let o=this._current.insertAfterHelper(r,e,t.length);for(let i=0;i<t.length;i++){let s=t[i];this.add(r,o[i],s.id,s.data,s.children)}}insertBefore(r,e,t){let o=this._current.insertBeforeHelper(r,e,t.length);for(let i=0;i<t.length;i++){let s=t[i];this.add(r,o[i],s.id,s.data,s.children)}}moveAfter(r,e,t){let o=this._current.insertAfterHelper(r,e,t.length);for(let i=0;i<t.length;i++){let s=t[i];this.move(r,o[i],s)}}moveBefore(r,e,t){let o=this._current.insertBeforeHelper(r,e,t.length);for(let i=0;i<t.length;i++){let s=t[i];this.move(r,o[i],s)}}delete(r){this.deleteChildren(r),this.runOp({type:8,id:r})}sortNext(r){return this._current.sortNext(r)}sortPrevious(r){return this._current.sortPrevious(r)}getAllSorted(r){return this._current.getAllSorted(r)}},dn=class extends Io{constructor(r,e,t){super(),this._children={},this._parent=r,this._path=e,this._current=t,this[Qs]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(r){let e=this.length;for(let t=0;t<e;t++){let o=this._current[t].id,i=this._current[t].fi;r(this.data(this._current[t].id),o,i)}}find(r){let e=this.length;for(let t=0;t<e;t++){let o=this._current[t].id;if(r(this.data(o),o))return this.get(o)}}update(r,e){this._current=this._current.modifyById(r,e)}randomId(){return this._current.randomId()}get(r){return{...this._current.get(r),data:this.data(r)}}data(r){let{_current:e,_children:t}=this,o=t===void 0?void 0:t[r];if(o!==void 0)return o;let i=e.get(r)?.data,s=Js(this,r,i);return s!==i?(t===void 0&&(t={},this._children=t),t[r]=s,s):i}runOp(r){this.reportOp(r,this._current.runOp(r))}add(r,e,t){this.runOp({type:4,fi:r,id:e,data:t})}move(r,e){this.runOp({type:6,fi:r,id:e})}insertAfter(r,e){let t=this._current.insertAfterHelper(r,e.length);for(let o=0;o<e.length;o++){let i=e[o];this.add(t[o],i.id,i.data)}}insertBefore(r,e){let t=this._current.insertBeforeHelper(r,e.length);for(let o=0;o<e.length;o++){let i=e[o];this.add(t[o],i.id,i.data)}}moveAfter(r,e){let t=this._current.insertAfterHelper(r,e.length);for(let o=0;o<e.length;o++){let i=e[o];this.move(t[o],i)}}moveBefore(r,e){let t=this._current.insertBeforeHelper(r,e.length);for(let o=0;o<e.length;o++){let i=e[o];this.move(t[o],i)}}delete(r){this.deleteChildren(r),this.runOp({type:5,id:r})}};function Yl(n,r,e){if(n.length>0){let t=n[n.length-1];if(t.type===0&&r.type===0&&wt.equal(t.path,e)){Object.assign(t.props,r.props);return}}n.push({...r,path:e})}var Zs=class extends Io{constructor(r){super(),this.ts=[],this.actual=[],this.reverse=[],this._current=r}update(r,e){if(r!=="")throw new Error("");this._current=e}push(r,e,t,o){Yl(this.ts,e,r),Yl(this.actual,t,r),Yl(this.reverse,o,r)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function Js(n,r,e){return e instanceof Qe?new cn(n,r,e):e instanceof xe?new dn(n,r,e):e instanceof Re?new Proxy(new Kl(n,r,e),ug):e!==null&&typeof e=="object"?sn(e)?e:new Proxy(new Xl(n,r,e),dg):e}function Zl(n){let r=new Zs(n);return[Js(r,"",n),r]}function un(n,r){let[e,t]=Zl(n);return r(e),t.result()}function at(n){return n instanceof cn||n instanceof dn?n._current:n!==null&&typeof n=="object"?n[jd]:n}var wt;(o=>{function n(i,s){if(s.length===i.length)for(var l=0;l<i.length;){if(i[l]!==s[l])return!1;l+=1}else return!1;return!0}o.equal=n;function r(i,s,l){let c=t(l,i);if(c!==void 0&&typeof c=="object"&&c!==null){let u={...s};return Object.keys(c).forEach(a=>{delete u[a]}),u}else return s}o.removeOverridden=r;function e(i,s){if((i instanceof Qe||i instanceof cn)&&typeof s=="string")return i.data(s);if((i instanceof xe||i instanceof dn)&&typeof s=="string")return i.data(s);if(typeof s=="number"&&Array.isArray(i))return i[s];if(typeof s=="string"&&typeof i=="object"&&i!==null)return i[s]}o.zoomOnce=e;function t(i,s,l=0){for(;l<s.length&&i!==void 0;)i=e(i,s[l]),l+=1;return i}o.zoom=t})(wt||(wt={}));function Ud(n,r){let e=[];if(r.length===n.length)for(var t=0;t<n.length;){if(r[t]==="*")e.push(n[t]);else if(n[t]!==r[t])return null;t+=1}else return null;return e}function br(n,r){let e=[];if(r.length<=n.length)for(var t=0;t<r.length;){if(r[t]==="*")e.push(n[t]);else if(n[t]!==r[t])return null;t+=1}else return null;return e}var ea=class{},Bi=class extends ea{constructor(e){super();this.id=e}},Di=class extends ea{constructor(e){super();this.data=e}};var Jl;try{Jl=new TextDecoder}catch{}var ne,oo,C=0;var Xd=[],ec=Xd,tc=0,Et={},Ae,ro,Xt=0,Sr=0,kt,kr,_t=[],Ne,zd={useRecords:!1,mapsAsObjects:!0},Gi=class{},oc=new Gi;oc.name="MessagePack 0xC1";var pn=!1,wr=class{constructor(r){r&&(r.useRecords===!1&&r.mapsAsObjects===void 0&&(r.mapsAsObjects=!0),r.structures?r.structures.sharedLength=r.structures.length:r.getStructures&&((r.structures=[]).uninitialized=!0,r.structures.sharedLength=0)),Object.assign(this,r)}unpack(r,e){if(ne)return eu(()=>(ra(),this?this.unpack(r,e):wr.prototype.unpack.call(zd,r,e)));oo=e>-1?e:r.length,C=0,tc=0,Sr=0,ro=null,ec=Xd,kt=null,ne=r;try{Ne=r.dataView||(r.dataView=new DataView(r.buffer,r.byteOffset,r.byteLength))}catch(t){throw ne=null,r instanceof Uint8Array?t:new Error("Source must be a Uint8Array or Buffer but was a "+(r&&typeof r=="object"?r.constructor.name:typeof r))}if(this instanceof wr){if(Et=this,this.structures)return Ae=this.structures,ta();(!Ae||Ae.length>0)&&(Ae=[])}else Et=zd,(!Ae||Ae.length>0)&&(Ae=[]);return ta()}unpackMultiple(r,e){let t,o=0;try{pn=!0;let i=r.length,s=this?this.unpack(r,i):ia.unpack(r,i);if(e){for(e(s);C<i;)if(o=C,e(ta())===!1)return}else{for(t=[s];C<i;)o=C,t.push(ta());return t}}catch(i){throw i.lastPosition=o,i.values=t,i}finally{pn=!1,ra()}}_mergeStructures(r,e){r=r||[];for(let t=0,o=r.length;t<o;t++){let i=r[t];i&&(i.isShared=!0,t>=32&&(i.highByte=t-32>>5))}r.sharedLength=r.length;for(let t in e||[])if(t>=0){let o=r[t],i=e[t];i&&(o&&((r.restoreStructures||(r.restoreStructures=[]))[t]=o),r[t]=i)}return this.structures=r}decode(r,e){return this.unpack(r,e)}};function ta(){try{if(!Et.trusted&&!pn){let r=Ae.sharedLength||0;r<Ae.length&&(Ae.length=r)}let n=We();if(C==oo)Ae.restoreStructures&&kd(),Ae=null,ne=null,kr&&(kr=null);else if(C>oo){let r=new Error("Unexpected end of MessagePack data");throw r.incomplete=!0,r}else if(!pn)throw new Error("Data read, but end of buffer not reached");return n}catch(n){throw Ae.restoreStructures&&kd(),ra(),(n instanceof RangeError||n.message.startsWith("Unexpected end of buffer"))&&(n.incomplete=!0),n}}function kd(){for(let n in Ae.restoreStructures)Ae[n]=Ae.restoreStructures[n];Ae.restoreStructures=null}function We(){let n=ne[C++];if(n<160)if(n<128){if(n<64)return n;{let r=Ae[n&63]||Et.getStructures&&Kd()[n&63];return r?(r.read||(r.read=nc(r,n&63)),r.read()):n}}else if(n<144)if(n-=128,Et.mapsAsObjects){let r={};for(let e=0;e<n;e++)r[Qd()]=We();return r}else{let r=new Map;for(let e=0;e<n;e++)r.set(We(),We());return r}else{n-=144;let r=new Array(n);for(let e=0;e<n;e++)r[e]=We();return r}else if(n<192){let r=n-160;if(Sr>=C)return ro.slice(C-Xt,(C+=r)-Xt);if(Sr==0&&oo<140){let e=r<16?ic(r):Zd(r);if(e!=null)return e}return rc(r)}else{let r;switch(n){case 192:return null;case 193:return kt?(r=We(),r>0?kt[1].slice(kt.position1,kt.position1+=r):kt[0].slice(kt.position0,kt.position0-=r)):oc;case 194:return!1;case 195:return!0;case 196:return Ql(ne[C++]);case 197:return r=Ne.getUint16(C),C+=2,Ql(r);case 198:return r=Ne.getUint32(C),C+=4,Ql(r);case 199:return Co(ne[C++]);case 200:return r=Ne.getUint16(C),C+=2,Co(r);case 201:return r=Ne.getUint32(C),C+=4,Co(r);case 202:if(r=Ne.getFloat32(C),Et.useFloat32>2){let e=na[(ne[C]&127)<<1|ne[C+1]>>7];return C+=4,(e*r+(r>0?.5:-.5)>>0)/e}return C+=4,r;case 203:return r=Ne.getFloat64(C),C+=8,r;case 204:return ne[C++];case 205:return r=Ne.getUint16(C),C+=2,r;case 206:return r=Ne.getUint32(C),C+=4,r;case 207:return Et.int64AsNumber?(r=Ne.getUint32(C)*4294967296,r+=Ne.getUint32(C+4)):r=Ne.getBigUint64(C),C+=8,r;case 208:return Ne.getInt8(C++);case 209:return r=Ne.getInt16(C),C+=2,r;case 210:return r=Ne.getInt32(C),C+=4,r;case 211:return Et.int64AsNumber?(r=Ne.getInt32(C)*4294967296,r+=Ne.getUint32(C+4)):r=Ne.getBigInt64(C),C+=8,r;case 212:if(r=ne[C++],r==114)return Yd(ne[C++]&63);{let e=_t[r];if(e)return e.read?(C++,e.read(We())):e.noBuffer?(C++,e()):e(ne.subarray(C,++C));throw new Error("Unknown extension "+r)}case 213:return r=ne[C],r==114?(C++,Yd(ne[C++]&63,ne[C++])):Co(2);case 214:return Co(4);case 215:return Co(8);case 216:return Co(16);case 217:return r=ne[C++],Sr>=C?ro.slice(C-Xt,(C+=r)-Xt):fg(r);case 218:return r=Ne.getUint16(C),C+=2,Sr>=C?ro.slice(C-Xt,(C+=r)-Xt):mg(r);case 219:return r=Ne.getUint32(C),C+=4,Sr>=C?ro.slice(C-Xt,(C+=r)-Xt):hg(r);case 220:return r=Ne.getUint16(C),C+=2,Wd(r);case 221:return r=Ne.getUint32(C),C+=4,Wd(r);case 222:return r=Ne.getUint16(C),C+=2,qd(r);case 223:return r=Ne.getUint32(C),C+=4,qd(r);default:if(n>=224)return n-256;if(n===void 0){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}throw new Error("Unknown MessagePack token "+n)}}}var pg=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function nc(n,r){function e(){if(e.count++>2){let o=n.read=new Function("r","return function(){return {"+n.map(i=>pg.test(i)?i+":r()":"["+JSON.stringify(i)+"]:r()").join(",")+"}}")(We);return n.highByte===0&&(n.read=Hd(r,n.read)),o()}let t={};for(let o=0,i=n.length;o<i;o++){let s=n[o];t[s]=We()}return t}return e.count=0,n.highByte===0?Hd(r,e):e}var Hd=(n,r)=>function(){let e=ne[C++];if(e===0)return r();let t=n<32?-(n+(e<<5)):n+(e<<5),o=Ae[t]||Kd()[t];if(!o)throw new Error("Record id is not defined for "+t);return o.read||(o.read=nc(o,n)),o.read()};function Kd(){let n=eu(()=>(ne=null,Et.getStructures()));return Ae=Et._mergeStructures(n,Ae)}var rc=oa,fg=oa,mg=oa,hg=oa;function oa(n){let r;if(n<16&&(r=ic(n)))return r;if(n>64&&Jl)return Jl.decode(ne.subarray(C,C+=n));let e=C+n,t=[];for(r="";C<e;){let o=ne[C++];if((o&128)===0)t.push(o);else if((o&224)===192){let i=ne[C++]&63;t.push((o&31)<<6|i)}else if((o&240)===224){let i=ne[C++]&63,s=ne[C++]&63;t.push((o&31)<<12|i<<6|s)}else if((o&248)===240){let i=ne[C++]&63,s=ne[C++]&63,l=ne[C++]&63,c=(o&7)<<18|i<<12|s<<6|l;c>65535&&(c-=65536,t.push(c>>>10&1023|55296),c=56320|c&1023),t.push(c)}else t.push(o);t.length>=4096&&(r+=lt.apply(String,t),t.length=0)}return t.length>0&&(r+=lt.apply(String,t)),r}function Wd(n){let r=new Array(n);for(let e=0;e<n;e++)r[e]=We();return r}function qd(n){if(Et.mapsAsObjects){let r={};for(let e=0;e<n;e++)r[Qd()]=We();return r}else{let r=new Map;for(let e=0;e<n;e++)r.set(We(),We());return r}}var lt=String.fromCharCode;function Zd(n){let r=C,e=new Array(n);for(let t=0;t<n;t++){let o=ne[C++];if((o&128)>0){C=r;return}e[t]=o}return lt.apply(String,e)}function ic(n){if(n<4)if(n<2){if(n===0)return"";{let r=ne[C++];if((r&128)>1){C-=1;return}return lt(r)}}else{let r=ne[C++],e=ne[C++];if((r&128)>0||(e&128)>0){C-=2;return}if(n<3)return lt(r,e);let t=ne[C++];if((t&128)>0){C-=3;return}return lt(r,e,t)}else{let r=ne[C++],e=ne[C++],t=ne[C++],o=ne[C++];if((r&128)>0||(e&128)>0||(t&128)>0||(o&128)>0){C-=4;return}if(n<6){if(n===4)return lt(r,e,t,o);{let i=ne[C++];if((i&128)>0){C-=5;return}return lt(r,e,t,o,i)}}else if(n<8){let i=ne[C++],s=ne[C++];if((i&128)>0||(s&128)>0){C-=6;return}if(n<7)return lt(r,e,t,o,i,s);let l=ne[C++];if((l&128)>0){C-=7;return}return lt(r,e,t,o,i,s,l)}else{let i=ne[C++],s=ne[C++],l=ne[C++],c=ne[C++];if((i&128)>0||(s&128)>0||(l&128)>0||(c&128)>0){C-=8;return}if(n<10){if(n===8)return lt(r,e,t,o,i,s,l,c);{let u=ne[C++];if((u&128)>0){C-=9;return}return lt(r,e,t,o,i,s,l,c,u)}}else if(n<12){let u=ne[C++],a=ne[C++];if((u&128)>0||(a&128)>0){C-=10;return}if(n<11)return lt(r,e,t,o,i,s,l,c,u,a);let d=ne[C++];if((d&128)>0){C-=11;return}return lt(r,e,t,o,i,s,l,c,u,a,d)}else{let u=ne[C++],a=ne[C++],d=ne[C++],p=ne[C++];if((u&128)>0||(a&128)>0||(d&128)>0||(p&128)>0){C-=12;return}if(n<14){if(n===12)return lt(r,e,t,o,i,s,l,c,u,a,d,p);{let f=ne[C++];if((f&128)>0){C-=13;return}return lt(r,e,t,o,i,s,l,c,u,a,d,p,f)}}else{let f=ne[C++],m=ne[C++];if((f&128)>0||(m&128)>0){C-=14;return}if(n<15)return lt(r,e,t,o,i,s,l,c,u,a,d,p,f,m);let h=ne[C++];if((h&128)>0){C-=15;return}return lt(r,e,t,o,i,s,l,c,u,a,d,p,f,m,h)}}}}}function Ql(n){return Et.copyBuffers?Uint8Array.prototype.slice.call(ne,C,C+=n):ne.subarray(C,C+=n)}function Co(n){let r=ne[C++];if(_t[r])return _t[r](ne.subarray(C,C+=n));throw new Error("Unknown extension type "+r)}var $d=new Array(4096);function Qd(){let n=ne[C++];if(n>=160&&n<192){if(n=n-160,Sr>=C)return ro.slice(C-Xt,(C+=n)-Xt);if(!(Sr==0&&oo<180))return rc(n)}else return C--,We();let r=(n<<5^(n>1?Ne.getUint16(C):n>0?ne[C]:0))&4095,e=$d[r],t=C,o=C+n-3,i,s=0;if(e&&e.bytes==n){for(;t<o;){if(i=Ne.getUint32(t),i!=e[s++]){t=1879048192;break}t+=4}for(o+=3;t<o;)if(i=ne[t++],i!=e[s++]){t=1879048192;break}if(t===o)return C=t,e.string;o-=3,t=C}for(e=[],$d[r]=e,e.bytes=n;t<o;)i=Ne.getUint32(t),e.push(i),t+=4;for(o+=3;t<o;)i=ne[t++],e.push(i);let l=n<16?ic(n):Zd(n);return l!=null?e.string=l:e.string=rc(n)}var Yd=(n,r)=>{var e=We();let t=n;r!==void 0&&(n=n<32?-((r<<5)+n):(r<<5)+n,e.highByte=r);let o=Ae[n];return o&&o.isShared&&((Ae.restoreStructures||(Ae.restoreStructures=[]))[n]=o),Ae[n]=e,e.read=nc(e,t),e.read()},Jd=typeof self=="object"?self:global;_t[0]=()=>{};_t[0].noBuffer=!0;_t[101]=()=>{let n=We();return(Jd[n[0]]||Error)(n[1])};_t[105]=n=>{let r=Ne.getUint32(C-4);kr||(kr=new Map);let e=ne[C],t;e>=144&&e<160||e==220||e==221?t=[]:t={};let o={target:t};kr.set(r,o);let i=We();return o.used?Object.assign(t,i):(o.target=i,i)};_t[112]=n=>{let r=Ne.getUint32(C-4),e=kr.get(r);return e.used=!0,e.target};_t[115]=()=>new Set(We());var sc=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(n=>n+"Array");_t[116]=n=>{let r=n[0],e=sc[r];if(!e)throw new Error("Could not find typed array for code "+r);return new Jd[e](Uint8Array.prototype.slice.call(n,1).buffer)};_t[120]=()=>{let n=We();return new RegExp(n[0],n[1])};_t[98]=n=>{let r=(n[0]<<24)+(n[1]<<16)+(n[2]<<8)+n[3],e=C;C+=r-4,kt=[We(),We()],kt.position0=0,kt.position1=0;let t=C;C=e;try{return We()}finally{C=t}};_t[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 eu(n){let r=oo,e=C,t=tc,o=Xt,i=Sr,s=ro,l=ec,c=kr,u=kt,a=new Uint8Array(ne.slice(0,oo)),d=Ae,p=Ae.slice(0,Ae.length),f=Et,m=pn,h=n();return oo=r,C=e,tc=t,Xt=o,Sr=i,ro=s,ec=l,kr=c,kt=u,ne=a,pn=m,Ae=d,Ae.splice(0,Ae.length,...p),Et=f,Ne=new DataView(ne.buffer,ne.byteOffset,ne.byteLength),h}function ra(){ne=null,kr=null,Ae=null}function tu(n){n.unpack?_t[n.type]=n.unpack:_t[n.type]=n}var na=new Array(147);for(let n=0;n<256;n++)na[n]=+("1e"+Math.floor(45.15-n*.30103));var ia=new wr({useRecords:!1}),yg=ia.unpack,gg=ia.unpackMultiple,xg=ia.unpack,sa={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},vg=new Float32Array(1),oO=new Uint8Array(vg.buffer,0,4);var aa;try{aa=new TextEncoder}catch{}var la,lc,ca=typeof Buffer<"u",ac=ca?Buffer.allocUnsafeSlow:Uint8Array,iu=ca?Buffer:Uint8Array,ru=ca?4294967296:2144337920,R,Xe,E=0,_r,Tr=null,bg=/[\u0080-\uFFFF]/,Ri=Symbol("record-id"),No=class extends wr{constructor(r){super(r),this.offset=0;let e,t,o,i,s,l,c=0,u=iu.prototype.utf8Write?function(x,P,O){return R.utf8Write(x,P,O)}:aa&&aa.encodeInto?function(x,P){return aa.encodeInto(x,R.subarray(P)).written}:!1,a=this;r||(r={});let d=r&&r.sequential,p=r.structures||r.saveStructures,f=r.maxSharedStructures;if(f==null&&(f=p?32:0),f>8160)throw new Error("Maximum maxSharedStructure is 8160");let m=r.maxOwnStructures;m==null&&(m=p?32:64),d&&!r.saveStructures&&(this.structures=[]);let h=f>32||m+f>64,y=f+64,g=f+m+64;if(g>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let v=[],w=0,b=0;this.pack=this.encode=function(x,P){if(R||(R=new ac(8192),Xe=new DataView(R.buffer,0,8192),E=0),_r=R.length-10,_r-E<2048?(R=new ac(R.length),Xe=new DataView(R.buffer,0,R.length),_r=R.length-10,E=0):E=E+7&2147483640,t=E,l=a.structuredClone?new Map:null,a.bundleStrings?(Tr=["",""],R[E++]=214,R[E++]=98,Tr.position=E-t,E+=4):Tr=null,o=a.structures,o){o.uninitialized&&(o=a._mergeStructures(a.getStructures()));let O=o.sharedLength||0;if(O>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 I=0;I<O;I++){let T=o[I];if(!T)continue;let N,L=o.transitions;for(let U=0,K=T.length;U<K;U++){let J=T[U];N=L[J],N||(N=L[J]=Object.create(null)),L=N}L[Ri]=I+64}c=O}d||(o.nextId=O+64)}i&&(i=!1),s=o||[];try{if(S(x),Tr){Xe.setUint32(Tr.position+t,E-Tr.position-t);let O=Tr;Tr=null,S(O[0]),S(O[1])}if(a.offset=E,l&&l.idsToInsert){E+=l.idsToInsert.length*6,E>_r&&_(E),a.offset=E;let O=wg(R.subarray(t,E),l.idsToInsert);return l=null,O}return P&au?(R.start=t,R.end=E,R):R.subarray(t,E)}finally{if(o){if(b<10&&b++,w>1e4)o.transitions=null,b=0,w=0,v.length>0&&(v=[]);else if(v.length>0&&!d){for(let O=0,I=v.length;O<I;O++)v[O][Ri]=0;v=[]}if(i&&a.saveStructures){let O=o.sharedLength||f;o.length>O&&(o=o.slice(0,O));let I=R.subarray(t,E);return a.saveStructures(o,c)===!1?(a._mergeStructures(a.getStructures()),a.pack(x)):(c=O,I)}}P&Cg&&(E=t)}};let S=x=>{E>_r&&(R=_(E));var P=typeof x,O;if(P==="string"){let I=x.length;if(Tr&&I>=8&&I<4096){let L=bg.test(x);Tr[L?0:1]+=x,R[E++]=193,S(L?-I:I);return}let T;I<32?T=1:I<256?T=2:I<65536?T=3:T=5;let N=I*3;if(E+N>_r&&(R=_(E+N)),I<64||!u){let L,U,K,J=E+T;for(L=0;L<I;L++)U=x.charCodeAt(L),U<128?R[J++]=U:U<2048?(R[J++]=U>>6|192,R[J++]=U&63|128):(U&64512)===55296&&((K=x.charCodeAt(L+1))&64512)===56320?(U=65536+((U&1023)<<10)+(K&1023),L++,R[J++]=U>>18|240,R[J++]=U>>12&63|128,R[J++]=U>>6&63|128,R[J++]=U&63|128):(R[J++]=U>>12|224,R[J++]=U>>6&63|128,R[J++]=U&63|128);O=J-E-T}else O=u(x,E+T,N);O<32?R[E++]=160|O:O<256?(T<2&&R.copyWithin(E+2,E+1,E+1+O),R[E++]=217,R[E++]=O):O<65536?(T<3&&R.copyWithin(E+3,E+2,E+2+O),R[E++]=218,R[E++]=O>>8,R[E++]=O&255):(T<5&&R.copyWithin(E+5,E+3,E+3+O),R[E++]=219,Xe.setUint32(E,O),E+=4),E+=O}else if(P==="number")if(x>>>0===x)x<64?R[E++]=x:x<256?(R[E++]=204,R[E++]=x):x<65536?(R[E++]=205,R[E++]=x>>8,R[E++]=x&255):(R[E++]=206,Xe.setUint32(E,x),E+=4);else if(x>>0===x)x>=-32?R[E++]=256+x:x>=-128?(R[E++]=208,R[E++]=x+256):x>=-32768?(R[E++]=209,Xe.setInt16(E,x),E+=2):(R[E++]=210,Xe.setInt32(E,x),E+=4);else{let I;if((I=this.useFloat32)>0&&x<4294967296&&x>=-2147483648){R[E++]=202,Xe.setFloat32(E,x);let T;if(I<4||(T=x*na[(R[E]&127)<<1|R[E+1]>>7])>>0===T){E+=4;return}else E--}R[E++]=203,Xe.setFloat64(E,x),E+=8}else if(P==="object")if(!x)R[E++]=192;else{if(l){let T=l.get(x);if(T){if(!T.id){let N=l.idsToInsert||(l.idsToInsert=[]);T.id=N.push(T)}R[E++]=214,R[E++]=112,Xe.setUint32(E,T.id),E+=4;return}else l.set(x,{offset:E-t})}let I=x.constructor;if(I===Object)A(x,!0);else if(I===Array){O=x.length,O<16?R[E++]=144|O:O<65536?(R[E++]=220,R[E++]=O>>8,R[E++]=O&255):(R[E++]=221,Xe.setUint32(E,O),E+=4);for(let T=0;T<O;T++)S(x[T])}else if(I===Map){O=x.size,O<16?R[E++]=128|O:O<65536?(R[E++]=222,R[E++]=O>>8,R[E++]=O&255):(R[E++]=223,Xe.setUint32(E,O),E+=4);for(let[T,N]of x)S(T),S(N)}else{for(let T=0,N=la.length;T<N;T++){let L=lc[T];if(x instanceof L){let U=la[T];if(U.write){U.type&&(R[E++]=212,R[E++]=U.type,R[E++]=0),S(U.write.call(this,x));return}let K=R,J=Xe,se=E;R=null;let z;try{z=U.pack.call(this,x,W=>(R=K,K=null,E+=W,E>_r&&_(E),{target:R,targetView:Xe,position:E-W}),S)}finally{K&&(R=K,Xe=J,E=se,_r=R.length-10)}z&&(z.length+E>_r&&_(z.length+E),E=Sg(z,R,E,U.type));return}}A(x,!x.hasOwnProperty)}}else if(P==="boolean")R[E++]=x?195:194;else if(P==="bigint"){if(x<BigInt(1)<<BigInt(63)&&x>=-(BigInt(1)<<BigInt(63)))R[E++]=211,Xe.setBigInt64(E,x);else if(x<BigInt(1)<<BigInt(64)&&x>0)R[E++]=207,Xe.setBigUint64(E,x);else if(this.largeBigIntToFloat)R[E++]=203,Xe.setFloat64(E,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");E+=8}else if(P==="undefined")this.encodeUndefinedAsNil?R[E++]=192:(R[E++]=212,R[E++]=0,R[E++]=0);else if(P==="function")S(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+P)},A=this.useRecords===!1?this.variableMapSize?x=>{let P=Object.keys(x),O=P.length;O<16?R[E++]=128|O:O<65536?(R[E++]=222,R[E++]=O>>8,R[E++]=O&255):(R[E++]=223,Xe.setUint32(E,O),E+=4);let I;for(let T=0;T<O;T++)S(I=P[T]),S(x[I])}:(x,P)=>{R[E++]=222;let O=E-t;E+=2;let I=0;for(let T in x)(P||x.hasOwnProperty(T))&&(S(T),S(x[T]),I++);R[O+++t]=I>>8,R[O+t]=I&255}:x=>{let P=Object.keys(x),O,I=s.transitions||(s.transitions=Object.create(null)),T=0;for(let L=0,U=P.length;L<U;L++){let K=P[L];O=I[K],O||(O=I[K]=Object.create(null),T++),I=O}let N=I[Ri];if(N)N>=96&&h?(R[E++]=((N-=96)&31)+96,R[E++]=N>>5):R[E++]=N;else{N=s.nextId,N||(N=64),N<y&&this.shouldShareStructure&&!this.shouldShareStructure(P)?(N=s.nextOwnId,N<g||(N=y),s.nextOwnId=N+1):(N>=g&&(N=y),s.nextId=N+1);let L=P.highByte=N>=96&&h?N-96>>5:-1;I[Ri]=N,s[N-64]=P,N<y?(P.isShared=!0,s.sharedLength=N-63,i=!0,L>=0?(R[E++]=(N&31)+96,R[E++]=L):R[E++]=N):(L>=0?(R[E++]=213,R[E++]=114,R[E++]=(N&31)+96,R[E++]=L):(R[E++]=212,R[E++]=114,R[E++]=N),T&&(w+=b*T),v.length>=m&&(v.shift()[Ri]=0),v.push(I),S(P))}for(let L=0,U=P.length;L<U;L++)S(x[P[L]])},_=x=>{let P;if(x>16777216){if(x-t>ru)throw new Error("Packed buffer would be larger than maximum buffer size");P=Math.min(ru,Math.round(Math.max((x-t)*(x>67108864?1.25:2),4194304)/4096)*4096)}else P=(Math.max(x-t<<2,R.length-1)>>12)+1<<12;let O=new ac(P);return Xe=new DataView(O.buffer,0,P),R.copy?R.copy(O,0,t,x):O.set(R.slice(t,x)),E-=t,t=0,_r=O.length-10,R=O}}useBuffer(r){R=r,Xe=new DataView(R.buffer,R.byteOffset,R.byteLength),E=0}};lc=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,Gi];la=[{pack(n,r,e){let t=n.getTime()/1e3;if((this.useTimestamp32||n.getMilliseconds()===0)&&t>=0&&t<4294967296){let{target:o,targetView:i,position:s}=r(6);o[s++]=214,o[s++]=255,i.setUint32(s,t)}else if(t>0&&t<17179869184){let{target:o,targetView:i,position:s}=r(10);o[s++]=215,o[s++]=255,i.setUint32(s,n.getMilliseconds()*4e6+(t/1e3/4294967296>>0)),i.setUint32(s+4,t)}else if(isNaN(t)){if(this.onInvalidDate)return r(0),e(this.onInvalidDate());let{target:o,targetView:i,position:s}=r(3);o[s++]=212,o[s++]=255,o[s++]=255}else{let{target:o,targetView:i,position:s}=r(15);o[s++]=199,o[s++]=12,o[s++]=255,i.setUint32(s,n.getMilliseconds()*1e6),i.setBigInt64(s+4,BigInt(Math.floor(t)))}}},{pack(n,r,e){let t=Array.from(n),{target:o,position:i}=r(this.structuredClone?3:0);this.structuredClone&&(o[i++]=212,o[i++]=115,o[i++]=0),e(t)}},{pack(n,r,e){let{target:t,position:o}=r(this.structuredClone?3:0);this.structuredClone&&(t[o++]=212,t[o++]=101,t[o++]=0),e([n.name,n.message])}},{pack(n,r,e){let{target:t,position:o}=r(this.structuredClone?3:0);this.structuredClone&&(t[o++]=212,t[o++]=120,t[o++]=0),e([n.source,n.flags])}},{pack(n,r){this.structuredClone?ou(n,16,r):nu(ca?Buffer.from(n):new Uint8Array(n),r)}},{pack(n,r){let e=n.constructor;e!==iu&&this.structuredClone?ou(n,sc.indexOf(e.name),r):nu(n,r)}},{pack(n,r){let{target:e,position:t}=r(1);e[t]=193}}];function ou(n,r,e,t){let o=n.byteLength;if(o+1<256){var{target:i,position:s}=e(4+o);i[s++]=199,i[s++]=o+1}else if(o+1<65536){var{target:i,position:s}=e(5+o);i[s++]=200,i[s++]=o+1>>8,i[s++]=o+1&255}else{var{target:i,position:s,targetView:l}=e(7+o);i[s++]=201,l.setUint32(s,o+1),s+=4}i[s++]=116,i[s++]=r,i.set(new Uint8Array(n.buffer,n.byteOffset,n.byteLength),s)}function nu(n,r){let e=n.byteLength;var t,o;if(e<256){var{target:t,position:o}=r(e+2);t[o++]=196,t[o++]=e}else if(e<65536){var{target:t,position:o}=r(e+3);t[o++]=197,t[o++]=e>>8,t[o++]=e&255}else{var{target:t,position:o,targetView:i}=r(e+5);t[o++]=198,i.setUint32(o,e),o+=4}t.set(n,o)}function Sg(n,r,e,t){let o=n.length;switch(o){case 1:r[e++]=212;break;case 2:r[e++]=213;break;case 4:r[e++]=214;break;case 8:r[e++]=215;break;case 16:r[e++]=216;break;default:o<256?(r[e++]=199,r[e++]=o):o<65536?(r[e++]=200,r[e++]=o>>8,r[e++]=o&255):(r[e++]=201,r[e++]=o>>24,r[e++]=o>>16&255,r[e++]=o>>8&255,r[e++]=o&255)}return r[e++]=t,r.set(n,e),e+=o,e}function wg(n,r){let e,t=r.length*6,o=n.length-t;for(r.sort((i,s)=>i.offset>s.offset?1:-1);e=r.pop();){let i=e.offset,s=e.id;n.copyWithin(i+t,i,o),t-=6;let l=i+t;n[l++]=214,n[l++]=105,n[l++]=s>>24,n[l++]=s>>16&255,n[l++]=s>>8&255,n[l++]=s&255,o=i}return n}function no(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)");lc.unshift(n.Class),la.unshift(n)}tu(n)}var su=new No({useRecords:!1}),_g=su.pack,Tg=su.pack;var{NEVER:Og,ALWAYS:Ag,DECIMAL_ROUND:Pg,DECIMAL_FIT:Ig}=sa,au=512,Cg=1024;var lu=new No({structuredClone:!0});no({Class:Re.prototype.constructor,type:1,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,Re.prototype),n}});no({Class:xe.prototype.constructor,type:2,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,xe.prototype),n}});no({Class:Qe.prototype.constructor,type:3,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,Qe.prototype),n}});no({Class:Bi.prototype.constructor,type:4,write(n){return n.id},read(n){return new Bi(n)}});no({Class:Di.prototype.constructor,type:5,write(n){return n.data},read(n){return new Di(n)}});no({Class:ze.prototype.constructor,type:6,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,ze.prototype),n}});function Ng(n){var r=0;if(n.length===0)return r;for(let e=0;e<n.length;e++){let t=n[e];r=(r<<5)-r+t,r=r&r}return r}function cc(n){if(sn(n))return n;if(Array.isArray(n))return n.map(cc);if(typeof n=="object"&&n!==null){let r={};for(let e of Object.keys(n).sort())r[e]=cc(n[e]);return Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r}else return n}var da;(t=>{function n(o){return lu.pack(o)}t.serialize=n;function r(o){return lu.unpack(o)}t.deserialize=r;function e(o){return Ng(n(cc(o))).toString()}t.checksum=e})(da||(da={}));var cu;(e=>{function n(t,o){return t[0]===o[0]&&t[1]===o[1]}e.isEqual=n;function r(t,o,i){return[t[0]+(o[0]-t[0])*i,t[1]+(o[1]-t[1])*i]}e.lerp=r})(cu||(cu={}));var io;(s=>{function n(l,c){return l[0]===c[0]&&l[1]===c[1]&&l[2]===c[2]}s.isEqual=n;function r(l,c){return[l[0]+c[0],l[1]+c[1],l[2]+c[2]]}s.add=r;function e(l,c){return[l[0]-c[0],l[1]-c[1],l[2]-c[2]]}s.sub=e;function t(l,c){return[l[0]/c[0],l[1]/c[1],l[2]/c[2]]}s.div=t;function o(l,c){return[l[0]*c[0],l[1]*c[1],l[2]*c[2]]}s.mul=o;function i(l,c,u){return[l[0]+(c[0]-l[0])*u,l[1]+(c[1]-l[1])*u,l[2]+(c[2]-l[2])*u]}s.lerp=i})(io||(io={}));var du;(e=>{function n(t,o){return t[0]===o[0]&&t[1]===o[1]&&t[2]===o[2]&&t[3]===o[3]}e.isEqual=n;function r(t,o,i){return[t[0]+(o[0]-t[0])*i,t[1]+(o[1]-t[1])*i,t[2]+(o[2]-t[2])*i,t[3]+(o[3]-t[3])*i]}e.lerp=r})(du||(du={}));var so;(o=>{o.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function r(i,s){for(let l=0;l<16;l++)if(i[l]!==s[l])return!1;return!0}o.isEqual=r;function e(i){return i??o.identity}o.simplify=e;function t(i,s){let l=s.slice(0);for(var c=0,u=s.length;c<u;c+=3){let a=i[3]*s[c]+i[7]*s[c+1]+i[11]*s[c+2]+i[15];l[c]=(i[0]*s[c]+i[4]*s[c+1]+i[8]*s[c+2]+i[12])/a,l[c+1]=(i[1]*s[c]+i[5]*s[c+1]+i[9]*s[c+2]+i[13])/a,l[c+2]=(i[2]*s[c]+i[6]*s[c+1]+i[10]*s[c+2]+i[14])/a}return l}o.applyMatrix4=t})(so||(so={}));var Lt;(u=>{function n(a){return typeof a=="object"&&typeof a.r=="number"&&typeof a.g=="number"&&typeof a.b=="number"}u.isRGB=n,u.white={r:1,g:1,b:1},u.red={r:1,g:0,b:0},u.black={r:0,g:0,b:0};function o(a){return{r:Math.round(a.r*255),g:Math.round(a.g*255),b:Math.round(a.b*255),a:1}}u.toRgb255a1=o;function i(a){return{r:a.r,g:a.g,b:a.b}}u.clone=i;function s(a){return a=Math.floor(a),{r:(a>>16&255)/255,g:(a>>8&255)/255,b:(a&255)/255}}u.fromHex=s;function l(a,d){return a.r===d.r&&a.g===d.g&&a.b===d.b}u.equals=l;function c(a,d,p){return{r:a.r+(d.r-a.r)*p,g:a.g+(d.g-a.g)*p,b:a.b+(d.b-a.b)*p}}u.lerp=c})(Lt||(Lt={}));var ir;(l=>{l.white={...Lt.white,a:1},l.transparent={...Lt.white,a:0};function e(c){return{r:c[0],g:c[1],b:c[2],a:c[3]}}l.from0to1=e;function t(c,u){return{...Lt.fromHex(c),a:u}}l.fromHexAndA=t;function o(c){return{r:Math.round(c.r*255),g:Math.round(c.g*255),b:Math.round(c.b*255),a:c.a}}l.toRgb255a1=o;function i(c,u){return Lt.equals(c,u)&&c.a===u.a}l.equals=i;function s(c,u,a){return{r:c.r+(u.r-c.r)*a,g:c.g+(u.g-c.g)*a,b:c.b+(u.b-c.b)*a,a:c.a+(u.a-c.a)*a}}l.lerp=s})(ir||(ir={}));var ua;(r=>r.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(ua||(ua={}));var uu;(r=>r.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(uu||(uu={}));var pu;(r=>r.defaultData={control1:[.5,.05],control2:[.1,.3]})(pu||(pu={}));var sr;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function r(t){return e.all.includes(t)}e.is=r})(sr||(sr={}));var Eo;(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,autoZoom:!1,autoZoomFrustumSize:790},up:o.DefaultUp,isUpVectorFlipped:!1,targetOffset:o.DefaultTargetOffset};function t(i){return i.type==="PerspectiveCamera"?i.perspective.zoom:i.orthographic.zoom}o.getZoom=t})(Eo||(Eo={}));var Or;(e=>{function n(t,o=.1){return{disabled:!1,type:"linear",hideBase:!1,count:3,radial:{radius:Math.max(t[0],t[1])*2,start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0]},toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},linear:{scale:[1,1,1],rotation:[0,0,0],position:[t[0]+t[0]*o,0,0]},grid:{count:[2,2,2],size:t.map(i=>i*(1+o)),useCenter:!0},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}}}e.defaultData=n;function r(t,o){let i={...t};if(Eg.forEach(s=>{Object.assign(i,{[s]:o[s]??t[s]})}),i.radial={...t.radial},o.radial){let s=t.radial,l=o.radial;Lg.forEach(c=>{Object.assign(i.radial,{[c]:l[c]??s[c]})})}if(i.linear={...t.linear},o.linear){let s=t.linear,l=o.linear;Mg.forEach(c=>{Object.assign(i.linear,{[c]:l[c]??s[c]})})}if(i.grid={...t.grid},o.grid){let s=t.grid,l=o.grid;Bg.forEach(c=>{Object.assign(i.grid,{[c]:l[c]??s[c]})})}if(i.toObject={...t.toObject},o.toObject){let s=t.toObject,l=o.toObject;Dg.forEach(c=>{Object.assign(i.toObject,{[c]:l[c]??s[c]})})}if(i.randomnessObject={...t.randomnessObject},o.randomnessObject){let s=t.randomnessObject,l=o.randomnessObject;Gg.forEach(c=>{Object.assign(i.randomnessObject,{[c]:l[c]??s[c]})})}return i}e.merge=r})(Or||(Or={}));var pa;(t=>{t.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let r=["radial","linear","grid","toObject","randomnessObject"];function e(o,i){let s=[];o.count!==void 0&&s.push({type:0,path:i,props:{count:o.count}});for(let l of r){let c=o[l];c&&Object.keys(c).length>0&&s.push({type:0,path:[...i,l],props:c})}return s}t.toOps=e})(pa||(pa={}));var Eg=["count"],Lg=["radius","start","end","position","scale","rotation"],Mg=["position","scale","rotation"],Bg=["count","size"],Dg=["count","position","scale","rotation"],Gg=["strength","scale","rotation","position","movement","seed","freqScale"];var fa;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function r(t){return e.all.includes(t)}e.is=r})(fa||(fa={}));var ma;(e=>{function n(t){return r(t)}e.defaultData=n;function r(t){if(t==="PointLight")return{type:t,color:ir.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,depth:1e5};if(t==="SpotLight")return{type:t,color:ir.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:1e5,shadowResolution:1024,shadowRadius:1};if(t==="DirectionalLight")return{type:t,color:ir.white,intensity:1,shadows:!0,size:1e3,depth:1e5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(ma||(ma={}));var dc;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function r(t,o){return t.castShadow===o.castShadow&&t.receiveShadow===o.receiveShadow}e.equals=r})(dc||(dc={}));var uc;(e=>{e.defaultData={flatShading:!1,wireframe:!1,side:0};function r(t,o){return t.flatShading===o.flatShading&&t.side===o.side&&t.wireframe===o.wireframe}e.equals=r})(uc||(uc={}));var ha;(r=>r.defaultData={...uc.defaultData,...dc.defaultData})(ha||(ha={}));var fn;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(fn||(fn={}));var fu=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],mu=["wrapping","image","video"],Tt;(o=>{function n(i,s){let{texture:l,...c}=s;if(Object.assign(i,c),l){let u=i.texture;u&&Object.assign(u,l)}}o.patch=n;function r(i,s){return i==="light"&&s?e(s):t(i)}o.defaultData=r;function e(i){switch(i){case"phong":return{category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",alpha:.6,visible:!0,mode:0};case"toon":return{category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1,visible:!0,mode:0};case"lambert":return{category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0};case"physical":return{category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0}}}function t(i){switch(i){case"texture":return{alpha:1,visible:!0,size:[128,128],mode:0,axis:"x",side:2,type:"texture",projection:0,texture:{image:"image_0",wrapping:1e3,repeat:[1,1],offset:[0,0]},crop:!1};case"video":return{alpha:1,visible:!0,size:[128,128],mode:0,axis:"x",side:2,type:"video",projection:0,texture:{video:fn.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!0};case"color":return{type:"color",alpha:1,visible:!0,mode:0,color:Lt.fromHex(4737101)};case"depth":return{type:"depth",alpha:1,visible:!0,mode:0,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{type:"normal",alpha:1,visible:!0,mode:0,cnormal:[1,1,1]};case"gradient":return{type:"gradient",alpha:1,visible:!0,mode:0,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{type:"noise",alpha:1,visible:!0,mode:0,size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...Lt.fromHex(6710886),a:1},colorB:{...Lt.fromHex(6710886),a:1},colorC:{...Lt.fromHex(16777215),a:1},colorD:{...Lt.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8]};case"fresnel":return{type:"fresnel",alpha:1,visible:!0,mode:0,color:ir.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{type:"rainbow",alpha:1,visible:!0,mode:0,filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{type:"toon",alpha:1,visible:!0,mode:0,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:ir.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{type:"outline",alpha:1,visible:!0,mode:0,outlineColor:ir.fromHexAndA(0,1),contourColor:ir.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{type:"matcap",alpha:1,visible:!0,mode:0,texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0]}};case"transmission":return{type:"transmission",alpha:1,visible:!0,mode:0,thickness:10,ior:1.5,roughness:1};case"displace":return{type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,visible:!0}}}})(Tt||(Tt={}));var Mt;(c=>{function n(u){return!u.layers.some(d=>d.data.type==="texture"&&d.data.projection!==0||d.data.type==="depth"&&!d.data.isWorldSpace||d.data.type==="noise"||d.data.type==="displace")}c.isMergable=n;function r(u){let a="";return u.layers.forEach(d=>{Object.entries(d.data).forEach(([p,f])=>{a+=`${p}${f}`,Array.isArray(f)?f.forEach(m=>a+=`${m}`):typeof f=="object"?Object.values(f).forEach(m=>{typeof m=="number"?a+=`${m.toFixed(4)}`:a+=`${m}`}):a+=`${f}`})}),a}c.getHash=r;function e(){return{layers:new xe}}c.defaultEmptyData=e;function t(u="layer1",a="layer2"){return i("phong",u,a)}c.defaultData=t;function o(u,a){return{...u,name:a}}c.withName=o;function i(u,a="layer1",d="layer2"){let p=new xe;return p.push({fi:0,data:Tt.defaultData("light",u),id:a}),p.push({fi:1,data:Tt.defaultData("color"),id:d}),{layers:p}}c.defaultTwoLayerData=i;function s(u,a="phong",d="layer1",p="layer2"){let f=Tt.defaultData("texture");Object.assign(f.texture,{image:u});let m=new xe;return m.push({fi:0,data:f,id:d}),m.push({fi:1,data:Tt.defaultData("light",a),id:p}),{layers:m}}c.defaultTwoLayerTextureData=s;function l(u,a="phong",d="layer1",p="layer2"){let f=Tt.defaultData("video");Object.assign(f.texture,{video:u});let m=new xe;return m.push({fi:0,data:f,id:d}),m.push({fi:1,data:Tt.defaultData("light",a),id:p}),{layers:m}}c.defaultTwoLayerVideoTextureData=l})(Mt||(Mt={}));var mn;(r=>{function n(){return{points:new xe,roundness:0,shapeHoles:[],isClosed:!1}}r.defaultData=n})(mn||(mn={}));var Vi;(r=>{function n(e){return e==="PolygonGeometry"||e==="RectangleGeometry"||e==="StarGeometry"||e==="TriangleGeometry"||e==="EllipseGeometry"}r.is2DParametricMesh=n})(Vi||(Vi={}));var ao;(r=>{function n(e){if(e==="RectangleGeometry")return{width:320,height:320,type:e,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="VectorGeometry")return{width:1,height:1,type:e,subdivisions:12,shape:mn.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="BooleanGeometry")return{type:e,operation:2,width:0,height:0,depth:0,phongAngle:35};if(e==="TextGeometry")return{type:e,width:100,height:100,depth:0,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.2,letterSpacing:0,text:"",textTransform:1,font:"Roboto_regular",extrudeBevelSize:0,extrudeBevelSegments:1};throw new Error("not implemented")}r.defaultData=n})(ao||(ao={}));var hu;(e=>{function n(t){return t==="Component"||t==="Instance"}e.isComponentRelated=n;function r(t){return t==="Empty"||t==="Instance"}e.isEmptyOrComponent=r})(hu||(hu={}));var hn;(o=>{o.identity={...ua.identity,hiddenMatrix:so.identity};function r(i){return{position:i.position,rotation:i.rotation,scale:i.scale,hiddenMatrix:i.hiddenMatrix}}o.fromObject=r;function e(i,s){return{position:s?.position||i.position,rotation:s?.rotation||i.rotation,scale:s?.scale||i.scale,hiddenMatrix:s?.hiddenMatrix||i.hiddenMatrix}}o.merge=e;function t(i,s){return{position:io.isEqual(i.position,s.position)?null:s.position,rotation:io.isEqual(i.rotation,s.rotation)?null:s.rotation,scale:io.isEqual(i.scale,s.scale)?null:s.scale,hiddenMatrix:so.isEqual(i.hiddenMatrix,s.hiddenMatrix)?null:s.hiddenMatrix}}o.diff=t})(hn||(hn={}));var pc;(r=>r.defaultData={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]})(pc||(pc={}));var Ht;(r=>r.defaultData={states:new xe,events:new xe,visible:!0,raycastLock:!1,physics:null,...hn.identity,cloner:null})(Ht||(Ht={}));var yu;(r=>r.defaultData={type:"Empty",...Ht.defaultData})(yu||(yu={}));var gu;(r=>r.defaultData={type:"Component",...Ht.defaultData})(gu||(gu={}));var Lo;(r=>r.defaultData={type:"Mesh",...Ht.defaultData,...ha.defaultData})(Lo||(Lo={}));var yn;(r=>r.defaultData={...Ht.defaultData,...hn.identity,...Eo.defaultData})(yn||(yn={}));var xu;(r=>{function n(e){return{...Ht.defaultData,...ma.defaultData(e)}}r.defaultData=n})(xu||(xu={}));var gn;(e=>{function n(t,o,i=0){for(;i<o.length;){let s=t?t[o[i]]:void 0;if(o.length===i+1)return s;if(s)t=s.descendants,i+=1;else return}}e.resolveWithDes=n;function r(t,o,i=0){let s=n(t,o,i);if(s){let l=Object.keys(s);if(l.length===1&&l[0]==="descendants")return}return s}e.resolve=r})(gn||(gn={}));var lo;(i=>{i.rootOverrideProps=["physics"],i.compositeNonOptionalOverrideProps=["geometry"],i.compositeEntireOverrideOverrideProps=["material"];function t(s,l){return{...Ht.defaultData,...l,component:s,overrides:new ze,physics:void 0,type:"Instance"}}i.ofComponent=t;function o(s){let l=hn.fromObject(s.data);return t(s.id,l)}i.fromComponentData=o})(lo||(lo={}));var vu;(i=>(i.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:so.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:pc.defaultData,states:new xe,events:new xe,cloner:null,...Eo.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",...Ht.defaultData,...Lo.defaultData,geometry:ao.defaultData("RectangleGeometry"),material:Mt.defaultTwoLayerData("phong","layer1","layer2")},i.defaultBooleanObject={name:"Boolean",...Ht.defaultData,...Lo.defaultData,geometry:ao.defaultData("BooleanGeometry"),material:Mt.defaultTwoLayerData("phong","layer1","layer2")},i.defaultTextObject={name:"Text",...Ht.defaultData,...Lo.defaultData,geometry:ao.defaultData("TextGeometry"),material:Mt.defaultTwoLayerData("phong","layer1","layer2")}))(vu||(vu={}));var Mo;(o=>{function n(i,s){let l={name:s};return i.type==="Mesh"?(l.geometry={},"material"in i&&(l.material={layers:new ze}),"materials"in i&&(l.materials=i.materials.map(c=>({layers:new ze})))):sr.is(i.type)&&(l.perspective={},l.orthographic={}),l}o.newEmpty=n;function r(i,s){if(s===void 0)return i;let l={...i};return"material"in l&&"material"in s&&s.material&&(l.material=un(l.material,c=>{if(typeof c!="string")for(let[u,a]of Object.entries(s.material.layers)){let d=c.layers.data(u);d&&Tt.patch(d,a)}}).data),l.materials&&s.materials&&(l.materials=un(l.materials,c=>{for(let u=0;u<l.materials.length;u++){let a=s.materials[u];if(typeof a!="string")for(let[d,p]of Object.entries(a.layers)){let f=c[u]?.layers?.data(d);f&&Tt.patch(f,p)}}}).data),l}function e(i,s){let l,c=[],u={orthographic:0,perspective:0,geometry:0};function a(d,p){for(let[f,m]of Object.entries(p.layers)){let{texture:h,...y}=m;if(h!==void 0&&Object.keys(h).length>0){let g={path:[...d,"layers",f,"texture"],props:h,type:0};c.push(g)}if(Object.keys(y).length>0){let g={path:[...d,"layers",f],props:y,type:0};c.push(g)}}}for(let[d,p]of Object.entries(s))if(d!=="name")if(d==="cloner")c.push(...pa.toOps(p,["cloner"]));else if(d==="material")a(["material"],p);else if(d==="materials")for(let[f,m]of Object.entries(p))a(["materials",f],m);else if(u[d]===0){if(Object.keys(p).length>0){let f={path:[d],props:p,type:0};c.push(f)}}else l===void 0&&(l={path:[],props:{},type:0},c.push(l)),l.props[d]=p;return c}o.toOps=e;function t(i,s){if(s===void 0)return i;let l={...i};if(Object.assign(l,hn.merge(l,s)),sr.is(i.type)){l.orthographic={...l.orthographic},l.perspective={...l.perspective};let c=s;c.orthographic?.zoom!==void 0&&(l.orthographic.zoom=c.orthographic.zoom),c.perspective?.zoom!==void 0&&(l.perspective.zoom=c.perspective.zoom),c.isUpVectorFlipped!==void 0&&(l.isUpVectorFlipped=c.isUpVectorFlipped),c.targetOffset!==void 0&&(l.targetOffset=c.targetOffset)}else if(i.type==="Mesh")s.geometry&&(l.geometry={...l.geometry},Object.assign(l.geometry,s.geometry)),(s.material||s.materials)&&(l=r(l,s)),l.cloner&&"cloner"in s&&Object.assign(l,{cloner:Or.merge(l.cloner,s.cloner)});else if(i.type==="Empty")l.cloner&&"cloner"in s&&Object.assign(l,{cloner:Or.merge(l.cloner,s.cloner)});else if(fa.is(i.type)){let c=s;c.intensity!==void 0&&(l.intensity=c.intensity),c.color!==void 0&&(typeof c.color=="string"?l.color=c.color:l.color=Lt.clone(c.color))}return l}o.patch=t})(Mo||(Mo={}));var xn;(r=>r.defaultData={enablePan:!0,enableZoom:!0,enableRotate:!0,enableDamping:!0,rotationLimitsMode:0,rotationVerticalOffset:{min:Math.PI/4,max:Math.PI/4},rotationHorizontalOffset:{min:Math.PI/4,max:Math.PI/4},rotationSoftLimit:2,panLimitsMode:0,panVerticalOffset:{min:250,max:250},panHorizontalOffset:{min:250,max:250},panSoftLimit:2,zoomLimitsEnabled:!1,zoomLimits:{min:.1,max:2},autoRotate:!1,autoRotateSpeed:2,autoRotateClockwise:!0,hoverRotatePanMode:0,hoverRotatePanStrength:20,isTouchZoom:!0,orbitTouches:2,panTouches:3,resetHoverEffectOnPointerLeave:!0,autoZoom:!1})(xn||(xn={}));var ya;(r=>r.defaultData={orbitControls:xn.defaultData,playCamera:null,withBackground:!0,preventScroll:!1,hideCursor:!1,settings:{image:{format:"jpg",ratio:1},video:{format:"mp4",imageFormat:"jpg",fps:30,mbps:80,ratio:typeof window<"u"?Math.floor(window.devicePixelRatio):1,stopMode:"manual",duration:5e3},web:{compress:!0,preset:1,preload:!0}},stopRaycast:!0,joystickSizeAndXYOffset:Array(12).fill(0).map((e,t)=>{let o=0,i=0;return t<5?i=-30:t<10&&(i=30),t===0||t===10||t===5?o=30:(t===4||t===11||t===9)&&(o=-30),[120,[o,i],"show"]}),gameControlObject:null})(ya||(ya={}));function co(n,r){return Object.setPrototypeOf(n,r),n}function ga(n){return Array.isArray(n)?n:[n]}function bu(n,r){let e=0;for(;e<n.length&&e<r.length;){if(n[e]<r[e])return-1;if(n[e]>r[e])return 1;e+=1}return e!==r.length?-1:e!==n.length?1:0}var xa;(e=>{function n(){let t={};return t["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},co(t,Re.prototype)}e.defaultColors=n;function r(){return{materials:new Re,images:new Re,videos:new Re,colors:new Re,audios:new Re,fonts:new Re,penumbraSize:[.5,.5,.5]}}e.emptyData=r})(xa||(xa={}));var Rg=typeof global=="object"&&global&&global.Object===Object&&global,va=Rg;var Vg=typeof self=="object"&&self&&self.Object===Object&&self,jg=va||Vg||Function("return this")(),Je=jg;var Fg=Je.Symbol,ct=Fg;var Su=Object.prototype,Ug=Su.hasOwnProperty,zg=Su.toString,Fi=ct?ct.toStringTag:void 0;function kg(n){var r=Ug.call(n,Fi),e=n[Fi];try{n[Fi]=void 0;var t=!0}catch{}var o=zg.call(n);return t&&(r?n[Fi]=e:delete n[Fi]),o}var wu=kg;var Hg=Object.prototype,Wg=Hg.toString;function qg(n){return Wg.call(n)}var _u=qg;var $g="[object Null]",Yg="[object Undefined]",Tu=ct?ct.toStringTag:void 0;function Xg(n){return n==null?n===void 0?Yg:$g:Tu&&Tu in Object(n)?wu(n):_u(n)}var Wt=Xg;function Kg(n){return n!=null&&typeof n=="object"}var mt=Kg;var Zg="[object Symbol]";function Qg(n){return typeof n=="symbol"||mt(n)&&Wt(n)==Zg}var vn=Qg;function Jg(n,r){for(var e=-1,t=n==null?0:n.length,o=Array(t);++e<t;)o[e]=r(n[e],e,n);return o}var ba=Jg;var e0=Array.isArray,qe=e0;var t0=1/0,Ou=ct?ct.prototype:void 0,Au=Ou?Ou.toString:void 0;function Pu(n){if(typeof n=="string")return n;if(qe(n))return ba(n,Pu)+"";if(vn(n))return Au?Au.call(n):"";var r=n+"";return r=="0"&&1/n==-t0?"-0":r}var Iu=Pu;function r0(n){var r=typeof n;return n!=null&&(r=="object"||r=="function")}var qt=r0;function o0(n){return n}var Cu=o0;var n0="[object AsyncFunction]",i0="[object Function]",s0="[object GeneratorFunction]",a0="[object Proxy]";function l0(n){if(!qt(n))return!1;var r=Wt(n);return r==i0||r==s0||r==n0||r==a0}var Sa=l0;var c0=Je["__core-js_shared__"],wa=c0;var Nu=function(){var n=/[^.]+$/.exec(wa&&wa.keys&&wa.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}();function d0(n){return!!Nu&&Nu in n}var Eu=d0;var u0=Function.prototype,p0=u0.toString;function f0(n){if(n!=null){try{return p0.call(n)}catch{}try{return n+""}catch{}}return""}var Hr=f0;var m0=/[\\^$.*+?()[\]{}|]/g,h0=/^\[object .+?Constructor\]$/,y0=Function.prototype,g0=Object.prototype,x0=y0.toString,v0=g0.hasOwnProperty,b0=RegExp("^"+x0.call(v0).replace(m0,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function S0(n){if(!qt(n)||Eu(n))return!1;var r=Sa(n)?b0:h0;return r.test(Hr(n))}var Lu=S0;function w0(n,r){return n?.[r]}var Mu=w0;function _0(n,r){var e=Mu(n,r);return Lu(e)?e:void 0}var Bt=_0;var T0=Bt(Je,"WeakMap"),_a=T0;var Bu=Object.create,O0=function(){function n(){}return function(r){if(!qt(r))return{};if(Bu)return Bu(r);n.prototype=r;var e=new n;return n.prototype=void 0,e}}(),Du=O0;function A0(n,r,e){switch(e.length){case 0:return n.call(r);case 1:return n.call(r,e[0]);case 2:return n.call(r,e[0],e[1]);case 3:return n.call(r,e[0],e[1],e[2])}return n.apply(r,e)}var Gu=A0;function P0(n,r){var e=-1,t=n.length;for(r||(r=Array(t));++e<t;)r[e]=n[e];return r}var Ru=P0;var I0=800,C0=16,N0=Date.now;function E0(n){var r=0,e=0;return function(){var t=N0(),o=C0-(t-e);if(e=t,o>0){if(++r>=I0)return arguments[0]}else r=0;return n.apply(void 0,arguments)}}var Vu=E0;function L0(n){return function(){return n}}var ju=L0;var M0=function(){try{var n=Bt(Object,"defineProperty");return n({},"",{}),n}catch{}}(),bn=M0;var B0=bn?function(n,r){return bn(n,"toString",{configurable:!0,enumerable:!1,value:ju(r),writable:!0})}:Cu,Fu=B0;var D0=Vu(Fu),Uu=D0;function G0(n,r){for(var e=-1,t=n==null?0:n.length;++e<t&&r(n[e],e,n)!==!1;);return n}var zu=G0;var R0=9007199254740991,V0=/^(?:0|[1-9]\d*)$/;function j0(n,r){var e=typeof n;return r=r??R0,!!r&&(e=="number"||e!="symbol"&&V0.test(n))&&n>-1&&n%1==0&&n<r}var Sn=j0;function F0(n,r,e){r=="__proto__"&&bn?bn(n,r,{configurable:!0,enumerable:!0,value:e,writable:!0}):n[r]=e}var Ta=F0;function U0(n,r){return n===r||n!==n&&r!==r}var wn=U0;var z0=Object.prototype,k0=z0.hasOwnProperty;function H0(n,r,e){var t=n[r];(!(k0.call(n,r)&&wn(t,e))||e===void 0&&!(r in n))&&Ta(n,r,e)}var _n=H0;function W0(n,r,e,t){var o=!e;e||(e={});for(var i=-1,s=r.length;++i<s;){var l=r[i],c=t?t(e[l],n[l],l,e,n):void 0;c===void 0&&(c=n[l]),o?Ta(e,l,c):_n(e,l,c)}return e}var Ar=W0;var ku=Math.max;function q0(n,r,e){return r=ku(r===void 0?n.length-1:r,0),function(){for(var t=arguments,o=-1,i=ku(t.length-r,0),s=Array(i);++o<i;)s[o]=t[r+o];o=-1;for(var l=Array(r+1);++o<r;)l[o]=t[o];return l[r]=e(s),Gu(n,this,l)}}var Hu=q0;var $0=9007199254740991;function Y0(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=$0}var Tn=Y0;function X0(n){return n!=null&&Tn(n.length)&&!Sa(n)}var Oa=X0;var K0=Object.prototype;function Z0(n){var r=n&&n.constructor,e=typeof r=="function"&&r.prototype||K0;return n===e}var On=Z0;function Q0(n,r){for(var e=-1,t=Array(n);++e<n;)t[e]=r(e);return t}var Wu=Q0;var J0="[object Arguments]";function ex(n){return mt(n)&&Wt(n)==J0}var fc=ex;var qu=Object.prototype,tx=qu.hasOwnProperty,rx=qu.propertyIsEnumerable,ox=fc(function(){return arguments}())?fc:function(n){return mt(n)&&tx.call(n,"callee")&&!rx.call(n,"callee")},An=ox;function nx(){return!1}var $u=nx;var Ku=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Yu=Ku&&typeof module=="object"&&module&&!module.nodeType&&module,ix=Yu&&Yu.exports===Ku,Xu=ix?Je.Buffer:void 0,sx=Xu?Xu.isBuffer:void 0,ax=sx||$u,Bo=ax;var lx="[object Arguments]",cx="[object Array]",dx="[object Boolean]",ux="[object Date]",px="[object Error]",fx="[object Function]",mx="[object Map]",hx="[object Number]",yx="[object Object]",gx="[object RegExp]",xx="[object Set]",vx="[object String]",bx="[object WeakMap]",Sx="[object ArrayBuffer]",wx="[object DataView]",_x="[object Float32Array]",Tx="[object Float64Array]",Ox="[object Int8Array]",Ax="[object Int16Array]",Px="[object Int32Array]",Ix="[object Uint8Array]",Cx="[object Uint8ClampedArray]",Nx="[object Uint16Array]",Ex="[object Uint32Array]",Fe={};Fe[_x]=Fe[Tx]=Fe[Ox]=Fe[Ax]=Fe[Px]=Fe[Ix]=Fe[Cx]=Fe[Nx]=Fe[Ex]=!0;Fe[lx]=Fe[cx]=Fe[Sx]=Fe[dx]=Fe[wx]=Fe[ux]=Fe[px]=Fe[fx]=Fe[mx]=Fe[hx]=Fe[yx]=Fe[gx]=Fe[xx]=Fe[vx]=Fe[bx]=!1;function Lx(n){return mt(n)&&Tn(n.length)&&!!Fe[Wt(n)]}var Zu=Lx;function Mx(n){return function(r){return n(r)}}var Pn=Mx;var Qu=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ui=Qu&&typeof module=="object"&&module&&!module.nodeType&&module,Bx=Ui&&Ui.exports===Qu,mc=Bx&&va.process,Dx=function(){try{var n=Ui&&Ui.require&&Ui.require("util").types;return n||mc&&mc.binding&&mc.binding("util")}catch{}}(),Wr=Dx;var Ju=Wr&&Wr.isTypedArray,Gx=Ju?Pn(Ju):Zu,Aa=Gx;var Rx=Object.prototype,Vx=Rx.hasOwnProperty;function jx(n,r){var e=qe(n),t=!e&&An(n),o=!e&&!t&&Bo(n),i=!e&&!t&&!o&&Aa(n),s=e||t||o||i,l=s?Wu(n.length,String):[],c=l.length;for(var u in n)(r||Vx.call(n,u))&&!(s&&(u=="length"||o&&(u=="offset"||u=="parent")||i&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||Sn(u,c)))&&l.push(u);return l}var Pa=jx;function Fx(n,r){return function(e){return n(r(e))}}var Ia=Fx;var Ux=Ia(Object.keys,Object),ep=Ux;var zx=Object.prototype,kx=zx.hasOwnProperty;function Hx(n){if(!On(n))return ep(n);var r=[];for(var e in Object(n))kx.call(n,e)&&e!="constructor"&&r.push(e);return r}var tp=Hx;function Wx(n){return Oa(n)?Pa(n):tp(n)}var In=Wx;function qx(n){var r=[];if(n!=null)for(var e in Object(n))r.push(e);return r}var rp=qx;var $x=Object.prototype,Yx=$x.hasOwnProperty;function Xx(n){if(!qt(n))return rp(n);var r=On(n),e=[];for(var t in n)t=="constructor"&&(r||!Yx.call(n,t))||e.push(t);return e}var op=Xx;function Kx(n){return Oa(n)?Pa(n,!0):op(n)}var Cn=Kx;var Zx=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Qx=/^\w*$/;function Jx(n,r){if(qe(n))return!1;var e=typeof n;return e=="number"||e=="symbol"||e=="boolean"||n==null||vn(n)?!0:Qx.test(n)||!Zx.test(n)||r!=null&&n in Object(r)}var np=Jx;var ev=Bt(Object,"create"),qr=ev;function tv(){this.__data__=qr?qr(null):{},this.size=0}var ip=tv;function rv(n){var r=this.has(n)&&delete this.__data__[n];return this.size-=r?1:0,r}var sp=rv;var ov="__lodash_hash_undefined__",nv=Object.prototype,iv=nv.hasOwnProperty;function sv(n){var r=this.__data__;if(qr){var e=r[n];return e===ov?void 0:e}return iv.call(r,n)?r[n]:void 0}var ap=sv;var av=Object.prototype,lv=av.hasOwnProperty;function cv(n){var r=this.__data__;return qr?r[n]!==void 0:lv.call(r,n)}var lp=cv;var dv="__lodash_hash_undefined__";function uv(n,r){var e=this.__data__;return this.size+=this.has(n)?0:1,e[n]=qr&&r===void 0?dv:r,this}var cp=uv;function Nn(n){var r=-1,e=n==null?0:n.length;for(this.clear();++r<e;){var t=n[r];this.set(t[0],t[1])}}Nn.prototype.clear=ip;Nn.prototype.delete=sp;Nn.prototype.get=ap;Nn.prototype.has=lp;Nn.prototype.set=cp;var hc=Nn;function pv(){this.__data__=[],this.size=0}var dp=pv;function fv(n,r){for(var e=n.length;e--;)if(wn(n[e][0],r))return e;return-1}var uo=fv;var mv=Array.prototype,hv=mv.splice;function yv(n){var r=this.__data__,e=uo(r,n);if(e<0)return!1;var t=r.length-1;return e==t?r.pop():hv.call(r,e,1),--this.size,!0}var up=yv;function gv(n){var r=this.__data__,e=uo(r,n);return e<0?void 0:r[e][1]}var pp=gv;function xv(n){return uo(this.__data__,n)>-1}var fp=xv;function vv(n,r){var e=this.__data__,t=uo(e,n);return t<0?(++this.size,e.push([n,r])):e[t][1]=r,this}var mp=vv;function En(n){var r=-1,e=n==null?0:n.length;for(this.clear();++r<e;){var t=n[r];this.set(t[0],t[1])}}En.prototype.clear=dp;En.prototype.delete=up;En.prototype.get=pp;En.prototype.has=fp;En.prototype.set=mp;var po=En;var bv=Bt(Je,"Map"),fo=bv;function Sv(){this.size=0,this.__data__={hash:new hc,map:new(fo||po),string:new hc}}var hp=Sv;function wv(n){var r=typeof n;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?n!=="__proto__":n===null}var yp=wv;function _v(n,r){var e=n.__data__;return yp(r)?e[typeof r=="string"?"string":"hash"]:e.map}var mo=_v;function Tv(n){var r=mo(this,n).delete(n);return this.size-=r?1:0,r}var gp=Tv;function Ov(n){return mo(this,n).get(n)}var xp=Ov;function Av(n){return mo(this,n).has(n)}var vp=Av;function Pv(n,r){var e=mo(this,n),t=e.size;return e.set(n,r),this.size+=e.size==t?0:1,this}var bp=Pv;function Ln(n){var r=-1,e=n==null?0:n.length;for(this.clear();++r<e;){var t=n[r];this.set(t[0],t[1])}}Ln.prototype.clear=hp;Ln.prototype.delete=gp;Ln.prototype.get=xp;Ln.prototype.has=vp;Ln.prototype.set=bp;var Do=Ln;var Iv="Expected a function";function yc(n,r){if(typeof n!="function"||r!=null&&typeof r!="function")throw new TypeError(Iv);var e=function(){var t=arguments,o=r?r.apply(this,t):t[0],i=e.cache;if(i.has(o))return i.get(o);var s=n.apply(this,t);return e.cache=i.set(o,s)||i,s};return e.cache=new(yc.Cache||Do),e}yc.Cache=Do;var Sp=yc;var Cv=500;function Nv(n){var r=Sp(n,function(t){return e.size===Cv&&e.clear(),t}),e=r.cache;return r}var wp=Nv;var Ev=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Lv=/\\(\\)?/g,Mv=wp(function(n){var r=[];return n.charCodeAt(0)===46&&r.push(""),n.replace(Ev,function(e,t,o,i){r.push(o?i.replace(Lv,"$1"):t||e)}),r}),_p=Mv;function Bv(n){return n==null?"":Iu(n)}var Tp=Bv;function Dv(n,r){return qe(n)?n:np(n,r)?[n]:_p(Tp(n))}var Kt=Dv;var Gv=1/0;function Rv(n){if(typeof n=="string"||vn(n))return n;var r=n+"";return r=="0"&&1/n==-Gv?"-0":r}var ho=Rv;function Vv(n,r){r=Kt(r,n);for(var e=0,t=r.length;n!=null&&e<t;)n=n[ho(r[e++])];return e&&e==t?n:void 0}var Ca=Vv;function jv(n,r){for(var e=-1,t=r.length,o=n.length;++e<t;)n[o+e]=r[e];return n}var Mn=jv;var Op=ct?ct.isConcatSpreadable:void 0;function Fv(n){return qe(n)||An(n)||!!(Op&&n&&n[Op])}var Ap=Fv;function Pp(n,r,e,t,o){var i=-1,s=n.length;for(e||(e=Ap),o||(o=[]);++i<s;){var l=n[i];r>0&&e(l)?r>1?Pp(l,r-1,e,t,o):Mn(o,l):t||(o[o.length]=l)}return o}var Ip=Pp;function Uv(n){var r=n==null?0:n.length;return r?Ip(n,1):[]}var Cp=Uv;function zv(n){return Uu(Hu(n,void 0,Cp),n+"")}var Na=zv;var kv=Ia(Object.getPrototypeOf,Object),Bn=kv;var Hv="[object Object]",Wv=Function.prototype,qv=Object.prototype,Np=Wv.toString,$v=qv.hasOwnProperty,Yv=Np.call(Object);function Xv(n){if(!mt(n)||Wt(n)!=Hv)return!1;var r=Bn(n);if(r===null)return!0;var e=$v.call(r,"constructor")&&r.constructor;return typeof e=="function"&&e instanceof e&&Np.call(e)==Yv}var Ep=Xv;function Kv(n,r,e){var t=-1,o=n.length;r<0&&(r=-r>o?0:o+r),e=e>o?o:e,e<0&&(e+=o),o=r>e?0:e-r>>>0,r>>>=0;for(var i=Array(o);++t<o;)i[t]=n[t+r];return i}var Lp=Kv;function Zv(){this.__data__=new po,this.size=0}var Mp=Zv;function Qv(n){var r=this.__data__,e=r.delete(n);return this.size=r.size,e}var Bp=Qv;function Jv(n){return this.__data__.get(n)}var Dp=Jv;function eb(n){return this.__data__.has(n)}var Gp=eb;var tb=200;function rb(n,r){var e=this.__data__;if(e instanceof po){var t=e.__data__;if(!fo||t.length<tb-1)return t.push([n,r]),this.size=++e.size,this;e=this.__data__=new Do(t)}return e.set(n,r),this.size=e.size,this}var Rp=rb;function Dn(n){var r=this.__data__=new po(n);this.size=r.size}Dn.prototype.clear=Mp;Dn.prototype.delete=Bp;Dn.prototype.get=Dp;Dn.prototype.has=Gp;Dn.prototype.set=Rp;var Gn=Dn;function ob(n,r){return n&&Ar(r,In(r),n)}var Vp=ob;function nb(n,r){return n&&Ar(r,Cn(r),n)}var jp=nb;var kp=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Fp=kp&&typeof module=="object"&&module&&!module.nodeType&&module,ib=Fp&&Fp.exports===kp,Up=ib?Je.Buffer:void 0,zp=Up?Up.allocUnsafe:void 0;function sb(n,r){if(r)return n.slice();var e=n.length,t=zp?zp(e):new n.constructor(e);return n.copy(t),t}var Hp=sb;function ab(n,r){for(var e=-1,t=n==null?0:n.length,o=0,i=[];++e<t;){var s=n[e];r(s,e,n)&&(i[o++]=s)}return i}var Wp=ab;function lb(){return[]}var Ea=lb;var cb=Object.prototype,db=cb.propertyIsEnumerable,qp=Object.getOwnPropertySymbols,ub=qp?function(n){return n==null?[]:(n=Object(n),Wp(qp(n),function(r){return db.call(n,r)}))}:Ea,Rn=ub;function pb(n,r){return Ar(n,Rn(n),r)}var $p=pb;var fb=Object.getOwnPropertySymbols,mb=fb?function(n){for(var r=[];n;)Mn(r,Rn(n)),n=Bn(n);return r}:Ea,La=mb;function hb(n,r){return Ar(n,La(n),r)}var Yp=hb;function yb(n,r,e){var t=r(n);return qe(n)?t:Mn(t,e(n))}var Ma=yb;function gb(n){return Ma(n,In,Rn)}var zi=gb;function xb(n){return Ma(n,Cn,La)}var Ba=xb;var vb=Bt(Je,"DataView"),Da=vb;var bb=Bt(Je,"Promise"),Ga=bb;var Sb=Bt(Je,"Set"),Ra=Sb;var Xp="[object Map]",wb="[object Object]",Kp="[object Promise]",Zp="[object Set]",Qp="[object WeakMap]",Jp="[object DataView]",_b=Hr(Da),Tb=Hr(fo),Ob=Hr(Ga),Ab=Hr(Ra),Pb=Hr(_a),Go=Wt;(Da&&Go(new Da(new ArrayBuffer(1)))!=Jp||fo&&Go(new fo)!=Xp||Ga&&Go(Ga.resolve())!=Kp||Ra&&Go(new Ra)!=Zp||_a&&Go(new _a)!=Qp)&&(Go=function(n){var r=Wt(n),e=r==wb?n.constructor:void 0,t=e?Hr(e):"";if(t)switch(t){case _b:return Jp;case Tb:return Xp;case Ob:return Kp;case Ab:return Zp;case Pb:return Qp}return r});var $r=Go;var Ib=Object.prototype,Cb=Ib.hasOwnProperty;function Nb(n){var r=n.length,e=new n.constructor(r);return r&&typeof n[0]=="string"&&Cb.call(n,"index")&&(e.index=n.index,e.input=n.input),e}var ef=Nb;var Eb=Je.Uint8Array,Vn=Eb;function Lb(n){var r=new n.constructor(n.byteLength);return new Vn(r).set(new Vn(n)),r}var jn=Lb;function Mb(n,r){var e=r?jn(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.byteLength)}var tf=Mb;var Bb=/\w*$/;function Db(n){var r=new n.constructor(n.source,Bb.exec(n));return r.lastIndex=n.lastIndex,r}var rf=Db;var of=ct?ct.prototype:void 0,nf=of?of.valueOf:void 0;function Gb(n){return nf?Object(nf.call(n)):{}}var sf=Gb;function Rb(n,r){var e=r?jn(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.length)}var af=Rb;var Vb="[object Boolean]",jb="[object Date]",Fb="[object Map]",Ub="[object Number]",zb="[object RegExp]",kb="[object Set]",Hb="[object String]",Wb="[object Symbol]",qb="[object ArrayBuffer]",$b="[object DataView]",Yb="[object Float32Array]",Xb="[object Float64Array]",Kb="[object Int8Array]",Zb="[object Int16Array]",Qb="[object Int32Array]",Jb="[object Uint8Array]",eS="[object Uint8ClampedArray]",tS="[object Uint16Array]",rS="[object Uint32Array]";function oS(n,r,e){var t=n.constructor;switch(r){case qb:return jn(n);case Vb:case jb:return new t(+n);case $b:return tf(n,e);case Yb:case Xb:case Kb:case Zb:case Qb:case Jb:case eS:case tS:case rS:return af(n,e);case Fb:return new t;case Ub:case Hb:return new t(n);case zb:return rf(n);case kb:return new t;case Wb:return sf(n)}}var lf=oS;function nS(n){return typeof n.constructor=="function"&&!On(n)?Du(Bn(n)):{}}var cf=nS;var iS="[object Map]";function sS(n){return mt(n)&&$r(n)==iS}var df=sS;var uf=Wr&&Wr.isMap,aS=uf?Pn(uf):df,pf=aS;var lS="[object Set]";function cS(n){return mt(n)&&$r(n)==lS}var ff=cS;var mf=Wr&&Wr.isSet,dS=mf?Pn(mf):ff,hf=dS;var uS=1,pS=2,fS=4,yf="[object Arguments]",mS="[object Array]",hS="[object Boolean]",yS="[object Date]",gS="[object Error]",gf="[object Function]",xS="[object GeneratorFunction]",vS="[object Map]",bS="[object Number]",xf="[object Object]",SS="[object RegExp]",wS="[object Set]",_S="[object String]",TS="[object Symbol]",OS="[object WeakMap]",AS="[object ArrayBuffer]",PS="[object DataView]",IS="[object Float32Array]",CS="[object Float64Array]",NS="[object Int8Array]",ES="[object Int16Array]",LS="[object Int32Array]",MS="[object Uint8Array]",BS="[object Uint8ClampedArray]",DS="[object Uint16Array]",GS="[object Uint32Array]",Ve={};Ve[yf]=Ve[mS]=Ve[AS]=Ve[PS]=Ve[hS]=Ve[yS]=Ve[IS]=Ve[CS]=Ve[NS]=Ve[ES]=Ve[LS]=Ve[vS]=Ve[bS]=Ve[xf]=Ve[SS]=Ve[wS]=Ve[_S]=Ve[TS]=Ve[MS]=Ve[BS]=Ve[DS]=Ve[GS]=!0;Ve[gS]=Ve[gf]=Ve[OS]=!1;function Va(n,r,e,t,o,i){var s,l=r&uS,c=r&pS,u=r&fS;if(e&&(s=o?e(n,t,o,i):e(n)),s!==void 0)return s;if(!qt(n))return n;var a=qe(n);if(a){if(s=ef(n),!l)return Ru(n,s)}else{var d=$r(n),p=d==gf||d==xS;if(Bo(n))return Hp(n,l);if(d==xf||d==yf||p&&!o){if(s=c||p?{}:cf(n),!l)return c?Yp(n,jp(s,n)):$p(n,Vp(s,n))}else{if(!Ve[d])return o?n:{};s=lf(n,d,l)}}i||(i=new Gn);var f=i.get(n);if(f)return f;i.set(n,s),hf(n)?n.forEach(function(y){s.add(Va(y,r,e,y,n,i))}):pf(n)&&n.forEach(function(y,g){s.set(g,Va(y,r,e,g,n,i))});var m=u?c?Ba:zi:c?Cn:In,h=a?void 0:m(n);return zu(h||n,function(y,g){h&&(g=y,y=n[g]),_n(s,g,Va(y,r,e,g,n,i))}),s}var ja=Va;var RS=1,VS=4;function jS(n){return ja(n,RS|VS)}var Ro=jS;var FS="__lodash_hash_undefined__";function US(n){return this.__data__.set(n,FS),this}var vf=US;function zS(n){return this.__data__.has(n)}var bf=zS;function Fa(n){var r=-1,e=n==null?0:n.length;for(this.__data__=new Do;++r<e;)this.add(n[r])}Fa.prototype.add=Fa.prototype.push=vf;Fa.prototype.has=bf;var Sf=Fa;function kS(n,r){for(var e=-1,t=n==null?0:n.length;++e<t;)if(r(n[e],e,n))return!0;return!1}var wf=kS;function HS(n,r){return n.has(r)}var _f=HS;var WS=1,qS=2;function $S(n,r,e,t,o,i){var s=e&WS,l=n.length,c=r.length;if(l!=c&&!(s&&c>l))return!1;var u=i.get(n),a=i.get(r);if(u&&a)return u==r&&a==n;var d=-1,p=!0,f=e&qS?new Sf:void 0;for(i.set(n,r),i.set(r,n);++d<l;){var m=n[d],h=r[d];if(t)var y=s?t(h,m,d,r,n,i):t(m,h,d,n,r,i);if(y!==void 0){if(y)continue;p=!1;break}if(f){if(!wf(r,function(g,v){if(!_f(f,v)&&(m===g||o(m,g,e,t,i)))return f.push(v)})){p=!1;break}}else if(!(m===h||o(m,h,e,t,i))){p=!1;break}}return i.delete(n),i.delete(r),p}var Ua=$S;function YS(n){var r=-1,e=Array(n.size);return n.forEach(function(t,o){e[++r]=[o,t]}),e}var Tf=YS;function XS(n){var r=-1,e=Array(n.size);return n.forEach(function(t){e[++r]=t}),e}var Of=XS;var KS=1,ZS=2,QS="[object Boolean]",JS="[object Date]",e1="[object Error]",t1="[object Map]",r1="[object Number]",o1="[object RegExp]",n1="[object Set]",i1="[object String]",s1="[object Symbol]",a1="[object ArrayBuffer]",l1="[object DataView]",Af=ct?ct.prototype:void 0,gc=Af?Af.valueOf:void 0;function c1(n,r,e,t,o,i,s){switch(e){case l1:if(n.byteLength!=r.byteLength||n.byteOffset!=r.byteOffset)return!1;n=n.buffer,r=r.buffer;case a1:return!(n.byteLength!=r.byteLength||!i(new Vn(n),new Vn(r)));case QS:case JS:case r1:return wn(+n,+r);case e1:return n.name==r.name&&n.message==r.message;case o1:case i1:return n==r+"";case t1:var l=Tf;case n1:var c=t&KS;if(l||(l=Of),n.size!=r.size&&!c)return!1;var u=s.get(n);if(u)return u==r;t|=ZS,s.set(n,r);var a=Ua(l(n),l(r),t,o,i,s);return s.delete(n),a;case s1:if(gc)return gc.call(n)==gc.call(r)}return!1}var Pf=c1;var d1=1,u1=Object.prototype,p1=u1.hasOwnProperty;function f1(n,r,e,t,o,i){var s=e&d1,l=zi(n),c=l.length,u=zi(r),a=u.length;if(c!=a&&!s)return!1;for(var d=c;d--;){var p=l[d];if(!(s?p in r:p1.call(r,p)))return!1}var f=i.get(n),m=i.get(r);if(f&&m)return f==r&&m==n;var h=!0;i.set(n,r),i.set(r,n);for(var y=s;++d<c;){p=l[d];var g=n[p],v=r[p];if(t)var w=s?t(v,g,p,r,n,i):t(g,v,p,n,r,i);if(!(w===void 0?g===v||o(g,v,e,t,i):w)){h=!1;break}y||(y=p=="constructor")}if(h&&!y){var b=n.constructor,S=r.constructor;b!=S&&"constructor"in n&&"constructor"in r&&!(typeof b=="function"&&b instanceof b&&typeof S=="function"&&S instanceof S)&&(h=!1)}return i.delete(n),i.delete(r),h}var If=f1;var m1=1,Cf="[object Arguments]",Nf="[object Array]",za="[object Object]",h1=Object.prototype,Ef=h1.hasOwnProperty;function y1(n,r,e,t,o,i){var s=qe(n),l=qe(r),c=s?Nf:$r(n),u=l?Nf:$r(r);c=c==Cf?za:c,u=u==Cf?za:u;var a=c==za,d=u==za,p=c==u;if(p&&Bo(n)){if(!Bo(r))return!1;s=!0,a=!1}if(p&&!a)return i||(i=new Gn),s||Aa(n)?Ua(n,r,e,t,o,i):Pf(n,r,c,e,t,o,i);if(!(e&m1)){var f=a&&Ef.call(n,"__wrapped__"),m=d&&Ef.call(r,"__wrapped__");if(f||m){var h=f?n.value():n,y=m?r.value():r;return i||(i=new Gn),o(h,y,e,t,i)}}return p?(i||(i=new Gn),If(n,r,e,t,o,i)):!1}var Lf=y1;function Mf(n,r,e,t,o){return n===r?!0:n==null||r==null||!mt(n)&&!mt(r)?n!==n&&r!==r:Lf(n,r,e,t,Mf,o)}var Bf=Mf;function g1(n,r){return n!=null&&r in Object(n)}var Df=g1;function x1(n,r,e){r=Kt(r,n);for(var t=-1,o=r.length,i=!1;++t<o;){var s=ho(r[t]);if(!(i=n!=null&&e(n,s)))break;n=n[s]}return i||++t!=o?i:(o=n==null?0:n.length,!!o&&Tn(o)&&Sn(s,o)&&(qe(n)||An(n)))}var Gf=x1;function v1(n,r){return n!=null&&Gf(n,r,Df)}var Rf=v1;function b1(n){var r=n==null?0:n.length;return r?n[r-1]:void 0}var Vf=b1;function S1(n,r){return r.length<2?n:Ca(n,Lp(r,0,-1))}var jf=S1;function w1(n,r){return Bf(n,r)}var ki=w1;function _1(n,r){return r=Kt(r,n),n=jf(n,r),n==null||delete n[ho(Vf(r))]}var Ff=_1;function T1(n){return Ep(n)?void 0:n}var Uf=T1;var O1=1,A1=2,P1=4,I1=Na(function(n,r){var e={};if(n==null)return e;var t=!1;r=ba(r,function(i){return i=Kt(i,n),t||(t=i.length>1),i}),Ar(n,Ba(n),e),t&&(e=ja(e,O1|A1|P1,Uf));for(var o=r.length;o--;)Ff(e,r[o]);return e}),Fn=I1;function C1(n,r,e,t){if(!qt(n))return n;r=Kt(r,n);for(var o=-1,i=r.length,s=i-1,l=n;l!=null&&++o<i;){var c=ho(r[o]),u=e;if(c==="__proto__"||c==="constructor"||c==="prototype")return n;if(o!=s){var a=l[c];u=t?t(a,c,l):void 0,u===void 0&&(u=qt(a)?a:Sn(r[o+1])?[]:{})}_n(l,c,u),l=l[c]}return n}var zf=C1;function N1(n,r,e){for(var t=-1,o=r.length,i={};++t<o;){var s=r[t],l=Ca(n,s);e(l,s)&&zf(i,Kt(s,n),l)}return i}var kf=N1;function E1(n,r){return kf(n,r,function(e,t){return Rf(n,t)})}var Hf=E1;var L1=Na(function(n,r){return n==null?{}:Hf(n,r)}),Un=L1;var Hi=require("three");function Wf(n){n.layers.forEach(r=>{if(r.type==="depth"&&r.colorA!==void 0){let e=r.colorA,t=r.colorB,o=[[e.r,e.g,e.b,e.a],[t.r,t.g,t.b,t.a]],i=[0,1];for(let l=2;l<10;l++)o.push(o[1]),i.push(1);let s={...Un(at(r),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,r.near),far:Math.max(0,r.far),colors:o,steps:i,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(r,s)}else if(r.type==="depth"&&r.gradientType===1&&(r.near<0||r.far<0)){let e={...at(r),near:Math.max(r.near,0),far:Math.max(r.far,0)};Object.assign(r,e)}})}function ka(n,r){Object.values(n.shared.materials).forEach(e=>r(e))}function Ha(n,r){n.scene.objects.traverse((e,t)=>{"materials"in t?t.materials.forEach(o=>{typeof o!="string"&&r(o)}):"material"in t&&typeof t.material!="string"&&r(t.material)})}function M1(n){Object.assign(n.scene.publish,{orbitControls:{...xn.defaultData,...at(n.scene.publish.orbitControls)}})}function B1(n){Object.assign(n.scene.publish.settings,{video:{...ya.defaultData.settings.video,...at(n.scene.publish.settings.video)}})}function D1(n){function r(e){if(e.layers){for(let t of Object.values(e.layers))if(t){for(let[o,i]of Object.entries(t))if((fu.includes(o)||typeof i=="boolean")&&delete t[o],o==="texture")for(let[s,l]of Object.entries(i))(mu.includes(s)||typeof l=="boolean")&&delete i[s]}}}n.scene.objects.traverse((e,t)=>{t.states.forEach(o=>{let i=o;i.material?r(i.material):i.materials&&i.materials.forEach(s=>{r(s)})})})}function G1(n){n.scene.publish.withBackground=!0}function R1(n){n.scene.publish.settings.web={compress:!0,preload:!0,preset:1}}function V1(n){n.scene.objects.traverse((r,e)=>{let t=e.cloner;t&&(t.radial.scale=t.radial.scale.map(o=>o+1),t.linear.scale=t.linear.scale.map(o=>o+1))})}function j1(n){n.scene.objects.traverse((r,e)=>{let t=e.geometry;t&&(t.type==="DodecahedronGeometry"||t.type==="IcosahedronGeometry")&&(t.detail=Math.round(t.detail))})}function F1(n){n.scene.objects.traverse((r,e)=>{let t=n.scene.objects.unproxy().parent(r);if(t){let o=at(n.scene.objects.data(t));o&&o.type==="Mesh"&&o.geometry.type==="BooleanGeometry"&&e.type==="Mesh"&&(e.visible=at(e).booleanExclude!==!0)}})}function U1(n){n.scene.objects.traverse((r,e)=>{if(e.type==="Mesh"){let t=e;e.geometry.type==="NonParametricGeometry"?t.material!==void 0&&delete t.material:t.materials!==void 0&&delete t.materials}})}function z1(n){function r(t){Object.setPrototypeOf(t,ze.prototype),t.texture&&Object.setPrototypeOf(t.texture,ze.prototype)}function e(t){Object.setPrototypeOf(t,ze.prototype);for(let o in t)r(t[o])}n.scene.objects.traverse((t,o)=>{o.states.forEach(i=>{let s=i;if(s.material){let l=at(s.material).layers;e(l),s.material.layers=l}if(s.materials)for(let l=0;l<s.materials.length;l++){let c=s.materials[l],u=at(c).layers;e(u),c.layers=u}})})}function qf(n){n.layers===void 0&&Object.assign(n,Mt.defaultTwoLayerData("lambert"))}function xc(n){!n.layers||n.layers.forEach(r=>{if(r.type==="depth"&&r.colors.length===10){let e=[...r.colors];e.push(r.colors[9]);let t=[...r.steps];t.push(r.steps[9]);let o={...at(r),colors:e,steps:t};Object.assign(r,o)}})}function k1(n){n.scene.objects.traverse((r,e)=>{e.type==="Mesh"&&(e.geometry.type==="BooleanGeometry"||e.geometry.type==="SubdivGeometry")&&(e.geometry.phongAngle=35)})}function $f(n){n.scene.objects.traverse((r,e)=>{"materials"in e?e.materials.forEach(t=>{typeof t!="string"&&xc(t)}):"material"in e&&typeof e.material!="string"&&xc(e.material)}),Object.values(n.shared.materials).forEach(r=>xc(r))}function H1(n){n.scene.environment.ambientLight.softShadows=!1,n.scene.environment.ambientLight.softShadowQuality="low",n.scene.objects.traverse((r,e)=>{(e.type==="DirectionalLight"||e.type==="SpotLight")&&(e.shadowResolution=1024,e.shadowRadius=1,e.depth=1e5)}),n.shared.penumbraSize=new Array(5).fill(.5)}function W1(n){n.shared.audios=co({},Re.prototype)}function q1(n){n.shared.videos=co({},Re.prototype)}function $1(n){let r=n.shared.materials;Object.entries(r).forEach(([e,t])=>{if(!t.layers){let o={name:"Untitled Material",layers:[{fi:0,data:{type:"light",category:"phong",alpha:.6,visible:!0,mode:0,specular:{r:.2,g:.2,b:.2},shininess:5},id:"layer1"},{fi:1,data:{type:"color",alpha:1,visible:!0,mode:0,color:{r:.2823529411764706,g:.2823529411764706,b:.30196078431372547}},id:"layer2"}]};Object.assign(r,{[e]:o})}})}function Y1(n){Object.entries(at(n.shared.images)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete n.shared.images[t]}),Object.entries(at(n.shared.audios)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete n.shared.audios[t]})}function X1(n){n.scene.publish.settings.web.preload=!1}function Yf(n){n.layers&&n.layers.forEach(r=>{r.type==="depth"&&r.num!==void 0&&(r.colors=r.colors.slice(0,r.num),r.steps=r.steps.slice(0,r.num),delete r.num)})}function K1(n){n.shared.fonts=co({},Re.prototype)}function Z1(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 Q1(n){let r=[];n.scene.objects.traverse((e,t)=>{let o=t;if(o.type==="TextFrame"){let i=Mt.defaultTwoLayerData("phong"),s=typeof o.color=="string"?n.shared.colors[o.color]:o.color;i.layers[1].data.color={r:s.r,g:s.g,b:s.b},i.layers[1].data.alpha=o.alpha;let l=Z1(o.font);n.shared.fonts[l]===void 0&&(n.shared.fonts[l]={name:l});let c={name:o.name,...Ht.defaultData,...Lo.defaultData,flatShading:!1,wireframe:!1,geometry:{...ao.defaultData("TextGeometry"),width:o.width,height:o.height,font:l,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:at(o.states),events:at(o.events),visible:o.visible,raycastLock:o.raycastLock,position:o.position,rotation:o.rotation,scale:o.scale,hiddenMatrix:o.hiddenMatrix},u=at(n.scene.objects).parent(e);n.scene.objects.insertAfter(u??null,e,[{id:e+"new",data:c,children:[]}]),r.push(e)}}),r.forEach(e=>{n.scene.objects.delete(e)})}function J1(n){let r={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};n.scene.objects.traverse((e,t)=>{t.events.forEach(o=>{if(!!r[Number(o.type)])if(Object.assign(o,{type:r[Number(o.type)]}),o.type==="Audio"&&"audioEvent"in o&&(Object.assign(o,{playAudio:o.audioEvent}),delete o.audioEvent),o.type==="GameControl")Object.assign(o,{gameActions:{idle:new xe,move:new xe,jump:new xe}});else{let i=new xe;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:Hi.MathUtils.generateUUID(),data:{type:"Link",url:o.url,delay:0}}),"targets"in o&&(o.targets.forEach((s,l,c)=>{let u={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},a={easing:s.easing,duration:s.duration};s.easing===6?Object.assign(a,Un(s,"mass","stiffness","damping","velocity")):s.easing===5&&Object.assign(a,{control1:{...s.control1},control2:{...s.control2}});let d={repeat:s.repeat?-1:0,delay:s.delay,delayDirection:s.delayDirection,direction:s.cycle&&s.rewind?"pingpong-rewind":s.cycle?"pingpong":"normal"},p={state:s.state,...d,...a},f={allowSlerp:!0,type:"Transition",object:s.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new xe({fi:0,id:Hi.MathUtils.generateUUID(),data:u},{fi:1,id:Hi.MathUtils.generateUUID(),data:p})};i.push({fi:c,id:l,data:f})}),delete o.targets)}})})}function ew(n){n.scene.objects.traverse((r,e)=>{function t(o,i){let s=new xe,l=[];if(e.events.forEach((c,u,a)=>{if(c.type==="Audio"&&c.trigger===i){let d;l.push(u),c.interaction==="play"?d={...Un(c,"interaction","audio","delay","volume","loop"),triggerAfter:"after"in c?c.after:void 0,toggle:"after"in c?c.toggle:void 0,type:"Audio"}:(c.interaction==="pause"||c.interaction==="stop")&&(d={...Un(c,"interaction","delay","object","playAudio"),type:"Audio"}),d&&s.push({fi:a,id:u,data:d})}}),l.forEach(c=>e.events.delete(c)),s.length){let c=e.events.find(u=>u.type===o)?.data;c?"actions"in c&&c.actions.insertBefore(null,s):e.events.insertBefore(null,[{id:Hi.MathUtils.generateUUID(),data:{type:o,actions:s}}])}}t("Start","start"),t("MouseDown","mouseDown"),t("MouseUp","mouseUp"),t("KeyDown","keyDown"),t("KeyUp","keyUp")})}function Xf(n){let r=n.layers.find(e=>e.type==="light")?.data;if(r?.category==="basic"){let e=Tt.defaultData("light","phong"),t=r;Object.assign(t,e),t.visible=!1}}function Kf(n){ka(n,Xf),Ha(n,Xf)}function tw(n){n.scene.objects.traverse((r,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(e.geometry.scaleBaked||(e.geometry.scaleBaked=[1,1,1]))})}function rw(n){n.scene.objects.traverse((r,e)=>{(e.type==="Empty"||e.type==="Mesh")&&e.cloner&&!e.cloner.randomnessObject&&!e.cloner.toObject&&!e.cloner.randomness&&(e.cloner={...e.cloner,toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}})})}function ow(n){n.scene.objects.traverse((r,e)=>{e.type==="Mesh"&&e.geometry.type==="NonParametricGeometry"&&!("material"in e)&&!("materials"in e)&&(e.material=Mt.defaultTwoLayerData("phong"))})}function nw(n){n.scene.publish.orbitControls.autoZoom===void 0&&(n.scene.publish.orbitControls.autoZoom=!1),n.scene.objects.traverse((r,e)=>{(e.type==="OrthographicCamera"||e.type==="PerspectiveCamera")&&(e.orthographic.autoZoom===void 0&&(e.orthographic.autoZoom=!1),e.orthographic.autoZoomFrustumSize===void 0&&(e.orthographic.autoZoomFrustumSize=790))})}var Zf=31;function Qf(n){let r=n.schema??0;r!==Zf&&(console.warn("updating from ",r,"to ",Zf),r<1&&(Ha(n,Wf),ka(n,Wf),n.schema=1),r<2&&(M1(n),n.schema=2),r<3&&(D1(n),n.schema=3),r<4&&(G1(n),n.schema=4),r<5&&(R1(n),n.schema=5),r<6&&(V1(n),n.schema=6),r<7&&(j1(n),n.schema=7),r<8&&(n.schema=8),r<9&&($f(n),n.schema=9),r<10&&(k1(n),n.schema=10),r<11&&(H1(n),n.schema=11),r<12&&($f(n),n.schema=12),r<13&&(W1(n),n.schema=13),r<14&&($1(n),n.schema=14),r<15&&(Y1(n),n.schema=15),r<16&&(X1(n),n.schema=16),r<17&&(Ha(n,Yf),ka(n,Yf),n.schema=17),r<18&&(Ha(n,qf),ka(n,qf),n.schema=18),r<19&&(B1(n),n.schema=19),r<20&&(K1(n),Q1(n),n.schema=20),r<21&&(J1(n),ew(n),n.schema=21),r<22&&(Kf(n),n.schema=22),r<23&&(tw(n),n.schema=23),r<24&&(rw(n),n.schema=24),(r<25||n.shared.videos===void 0)&&(q1(n),r<25&&(n.schema=25)),r<26&&(F1(n),n.schema=26),r<27&&(U1(n),n.schema=27),r<28&&(Kf(n),n.schema=28),r<29&&(z1(n),n.schema=29),r<30&&(ow(n),n.schema=30),r<31&&(nw(n),n.schema=31))}var Wa;(r=>r.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII="})(Wa||(Wa={}));var Ce=require("three"),wi=Ni(em());var iw=.5*(Math.sqrt(3)-1),qi=(3-Math.sqrt(3))/6,sw=1/3,Pr=1/6,O3=(Math.sqrt(5)-1)/4,A3=(5-Math.sqrt(5))/20,$i=n=>Math.floor(n)|0,tm=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]),bc=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 qa(n=Math.random){let r=om(n),e=new Float64Array(r).map(o=>tm[o%12*2]),t=new Float64Array(r).map(o=>tm[o%12*2+1]);return function(i,s){let l=0,c=0,u=0,a=(i+s)*iw,d=$i(i+a),p=$i(s+a),f=(d+p)*qi,m=d-f,h=p-f,y=i-m,g=s-h,v,w;y>g?(v=1,w=0):(v=0,w=1);let b=y-v+qi,S=g-w+qi,A=y-1+2*qi,_=g-1+2*qi,x=d&255,P=p&255,O=.5-y*y-g*g;if(O>=0){let N=x+r[P],L=e[N],U=t[N];O*=O,l=O*O*(L*y+U*g)}let I=.5-b*b-S*S;if(I>=0){let N=x+v+r[P+w],L=e[N],U=t[N];I*=I,c=I*I*(L*b+U*S)}let T=.5-A*A-_*_;if(T>=0){let N=x+1+r[P+1],L=e[N],U=t[N];T*=T,u=T*T*(L*A+U*_)}return 70*(l+c+u)}}function rm(n=Math.random){let r=om(n),e=new Float64Array(r).map(i=>bc[i%12*3]),t=new Float64Array(r).map(i=>bc[i%12*3+1]),o=new Float64Array(r).map(i=>bc[i%12*3+2]);return function(s,l,c){let u,a,d,p,f=(s+l+c)*sw,m=$i(s+f),h=$i(l+f),y=$i(c+f),g=(m+h+y)*Pr,v=m-g,w=h-g,b=y-g,S=s-v,A=l-w,_=c-b,x,P,O,I,T,N;S>=A?A>=_?(x=1,P=0,O=0,I=1,T=1,N=0):S>=_?(x=1,P=0,O=0,I=1,T=0,N=1):(x=0,P=0,O=1,I=1,T=0,N=1):A<_?(x=0,P=0,O=1,I=0,T=1,N=1):S<_?(x=0,P=1,O=0,I=0,T=1,N=1):(x=0,P=1,O=0,I=1,T=1,N=0);let L=S-x+Pr,U=A-P+Pr,K=_-O+Pr,J=S-I+2*Pr,se=A-T+2*Pr,z=_-N+2*Pr,W=S-1+3*Pr,q=A-1+3*Pr,j=_-1+3*Pr,M=m&255,B=h&255,D=y&255,F=.6-S*S-A*A-_*_;if(F<0)u=0;else{let G=M+r[B+r[D]];F*=F,u=F*F*(e[G]*S+t[G]*A+o[G]*_)}let Y=.6-L*L-U*U-K*K;if(Y<0)a=0;else{let G=M+x+r[B+P+r[D+O]];Y*=Y,a=Y*Y*(e[G]*L+t[G]*U+o[G]*K)}let k=.6-J*J-se*se-z*z;if(k<0)d=0;else{let G=M+I+r[B+T+r[D+N]];k*=k,d=k*k*(e[G]*J+t[G]*se+o[G]*z)}let V=.6-W*W-q*q-j*j;if(V<0)p=0;else{let G=M+1+r[B+1+r[D+1]];V*=V,p=V*V*(e[G]*W+t[G]*q+o[G]*j)}return 32*(u+a+d+p)}}function om(n){let e=new Uint8Array(512);for(let t=0;t<512/2;t++)e[t]=t;for(let t=0;t<512/2-1;t++){let o=t+~~(n()*(256-t)),i=e[t];e[t]=e[o],e[o]=i}for(let t=256;t<512;t++)e[t]=e[t-256];return e}var nm=require("three"),ar=new nm.Triangle,$a=class{constructor(r){this.weightAttribute=null;let e=r.geometry;if(!e.isBufferGeometry||e.attributes.position.itemSize!==3)throw new Error("THREE.MeshSurfaceSampler: Requires BufferGeometry triangle mesh.");e.index&&(e=e.toNonIndexed()),this.geometry=e,this.randomFunction=Math.random,this.positionAttribute=this.geometry.getAttribute("position"),this.distribution=null}build(){let r=this.positionAttribute,e=new Float32Array(r.count/3);for(let o=0;o<r.count;o+=3){let i=1;ar.a.fromBufferAttribute(r,o),ar.b.fromBufferAttribute(r,o+1),ar.c.fromBufferAttribute(r,o+2),i*=ar.getArea(),e[o/3]=i}this.distribution=new Float32Array(r.count/3);let t=0;for(let o=0;o<e.length;o++)t+=e[o],this.distribution[o]=t;return this}setRandomGenerator(r){return this.randomFunction=r,this}sample(r,e){if(this.distribution){let t=this.distribution[this.distribution.length-1],o=this.binarySearch(this.randomFunction()*t);return this.sampleFace(o,r,e)}}binarySearch(r){if(!this.distribution)return 0;let e=this.distribution,t=0,o=e.length-1,i=-1;for(;t<=o;){let s=Math.ceil((t+o)/2);if(s===0||e[s-1]<=r&&e[s]>r){i=s;break}else r<e[s]?o=s-1:t=s+1}return i}sampleFace(r,e,t){let o=this.randomFunction(),i=this.randomFunction();return o+i>1&&(o=1-o,i=1-i),ar.a.fromBufferAttribute(this.positionAttribute,r*3),ar.b.fromBufferAttribute(this.positionAttribute,r*3+1),ar.c.fromBufferAttribute(this.positionAttribute,r*3+2),e.set(0,0,0).addScaledVector(ar.a,o).addScaledVector(ar.b,i).addScaledVector(ar.c,1-(o+i)),ar.getNormal(t),this}};var lm=require("three");var Zt=require("three"),am=Ni(sm()),aw=new Zt.Matrix4,lw=new Zt.Matrix4,cw=new Zt.Matrix4,Yi;(r=>{function n(e){return e&&e.__isSPEObject}r.is=n})(Yi||(Yi={}));var zn=n=>class extends n{constructor(){super(...arguments);this.hiddenMatrix=new Zt.Matrix4;this.matrixWorldRigid=new Zt.Matrix4;this.shearScale=new Zt.Matrix4;this.shearScaleInv=new Zt.Matrix4}get __isSPEObject(){return!0}isDescendantOf(t){t instanceof Zt.Object3D&&(t=t.uuid);let o=this;for(;o.parent;){if(o.parent.uuid===t)return!0;o=o.parent}return!1}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);for(let o of this.children)o.updateMatrixWorld(t)}updateWorldMatrix(t,o){let i=this.parent;if(t&&i!==null&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),o)for(let s of this.children)s.updateWorldMatrix(!1,!0)}traverseObject(t,o=0){if(t(this,o)!==!0)for(let s of this.children)Yi.is(s)&&s.traverseObject(t,o+1)}updateMatrixWorldSVD(){let t=this.matrixWorld.elements,o=[[t[0],t[4],t[8]],[t[1],t[5],t[9]],[t[2],t[6],t[10]]],{u:i,v:s,q:l}=(0,am.SVD)(o),c=aw.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=lw.set(s[0][0],s[0][1],s[0][2],0,s[1][0],s[1][1],s[1][2],0,s[2][0],s[2][1],s[2][2],0,0,0,0,1),a=cw.copy(u).transpose();this.shearScale.makeScale(l[0],l[1],l[2]).multiply(a).premultiply(u),this.shearScaleInv.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(c,a).copyPosition(this.matrixWorld),l.every(d=>Math.abs(l[0]-d)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(t,o){this.updateWorldMatrix(!0,!1);let i=new Zt.Matrix4().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),i.multiply(t.parent.matrixWorld)),"hiddenMatrix"in t&&t.hiddenMatrix instanceof Zt.Matrix4?t.hiddenMatrix.premultiply(i):t.applyMatrix4(i),t.updateWorldMatrix(!1,!1),this.add(t),o!==void 0&&(this.children.pop(),this.children.splice(o,0,t)),this}};var Sc=class extends zn(lm.Object3D){},dw=n=>n.type==="Mesh",Yr=class extends Sc{constructor(e){super();this.object=e;this.matrixAutoUpdate=!1}expand(){let e=0,t=this.object.entityChildren(e);for(;t;){let o=this.children[e];o?.object!==t&&(o&&this.remove(o),o=new Yr(t),this.add(o),o.matrixAutoUpdate=!1,o.matrix=t.matrix,o.hiddenMatrix=t.hiddenMatrix),o.expand(),e+=1,t=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e])}get visible(){return this.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 dw(this.object)}get isLight(){return this.object.isLight}get layers(){return this.object.layers}set layers(e){}get isCamera(){return!1}get geometry(){if(this.object.geometry)return this.object.geometry}get material(){if(this.object.material)return this.object.material}};var si=require("three");var al=require("three");var Ke=require("three"),Vo=new Ke.Vector3,jo=new Ke.Vector3,kn=new Ke.Matrix4,dm=[new Ke.Vector3(-1,1,1),new Ke.Vector3(-1,-1,1),new Ke.Vector3(1,-1,1),new Ke.Vector3(1,1,1),new Ke.Vector3(-1,1,-1),new Ke.Vector3(-1,-1,-1),new Ke.Vector3(1,-1,-1),new Ke.Vector3(1,1,-1)],uw=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],pw=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],cm=(n,r,e)=>{n.updateEntityBoxSize(Vo,jo),kn.copy(r).multiply(n.matrixWorld),jo.x===0&&jo.y===0&&jo.z===0?e.push(new Ke.Vector3(Vo.x,Vo.y,Vo.z).applyMatrix4(kn)):dm.forEach(t=>{e.push(t.clone().multiply(jo).add(Vo).applyMatrix4(kn))})},Xi=class extends Ke.Box3{constructor(){super(...arguments);this.matrix=new Ke.Matrix4;this.vertices=[];this.faces=[];this.edges=[];this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(t=>t.clone()),this.faces=e.faces.map(t=>t.clone()),this.edges=e.edges.map(t=>t.clone()),this.centerEdges=e.centerEdges.map(t=>t.clone()),this}setFromObjectSize(e,t=!1){e.updateWorldMatrix(!1,t),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let o=new Ke.Matrix4().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,o,t)}expandByObjectSize(e,t,o=!1){let i=[];return o===!0?e.traverseEntity(s=>{s.visible&&cm(s,t,i)}):cm(e,t,i),this.setFromPoints(i)}getCenter(e){return e=super.getCenter(e),e.applyMatrix4(this.matrix),e}getPositionToCenter(e){return e=super.getCenter(e),e.applyMatrix4(kn.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(jo).multiplyScalar(.5),this.getCenter(Vo),kn.copy(this.matrix).setPosition(Vo),this.vertices=dm.map(e=>e.clone().multiply(jo).applyMatrix4(kn))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=uw.map(([e,t])=>new Ke.Line3(this.vertices[e],this.vertices[t])),this.centerEdges=this.edges.map(e=>e.getCenter(new Ke.Vector3))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=pw.map(([e,t])=>this.vertices[e].clone().add(this.vertices[t]).multiplyScalar(.5))}};var lr={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}};var He;(r=>{function n(e){return e&&e.__isEntity}r.is=n})(He||(He={}));var cr=n=>He.is(n),Xa=n=>class extends zn(n){constructor(){super(...arguments);this.raycastLock=!1;this.scaleLock=!1;this.disposed=!1;this.stateSelection=null;this.instances=[];this.prevState=null;this.currentState=null;this.reversibleToState=null;this.currentTransitionEvent=null;this.previousAction=null;this._singleBBox=new Xi;this._recursiveBBox=new Xi;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0}get __isEntity(){return!0}entityChildren(t){let o=this.children[t];if(He.is(o))return o}get isConcreteEntity(){return typeof this.identity=="string"}get isVirtualEntity(){return typeof this.identity!="string"}get isInstanceRoot(){return this.isConcreteEntity&&this.data.type==="Instance"}nearestInstanceSelfOrParent(){let t=this;for(;t.data.type!=="Instance";){let o=t.parent;if(He.is(o))t=o;else return}return t}forInstancesRec(t){this.instances.forEach(o=>{o.disposed||t(o),o.forInstancesRec(t)})}super_Entity(t,o){typeof t=="string"&&(this.uuid=t),this.identity=t,this.data=o,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(t,o,i=!1){if(!(this.data.states.length===0&&!i)){for(let s of this.data.states)Mo.toOps(this.data,s.data).forEach(c=>{let u=Ks.replaceProps(c,this.data);this.updateByPatchedOp(u,this.data,o)});if(t!==null){let s=this.data.states.data(t);s&&(this.dataPatched=Mo.patch(this.data,s),Mo.toOps(this.data,s).forEach(c=>{this.updateByPatchedOp(c,this.dataPatched,o)}))}else this.dataPatched=this.data;i&&this.updateTransformState(this.dataPatched),this.stateSelection=t}}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges(),this._singleBBox.computeFaces()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges(),this._recursiveBBox.computeFaces()),this._recursiveBBox}updateEntityBoxSize(t,o){t.setScalar(0),o.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(t=>{cr(t)&&t.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(t=>{t.resetBBoxNeedsUpdateSelf()})}find(t){let o;return this.traverseEntity(i=>{i.uuid===t&&(o=i)}),o}traverseSortNextHelper(){let t=this.parent;if(t){let o=t.children,i=o.indexOf(this)+1;if(He.is(o[i]))return o[i];if(He.is(t))return t.traverseSortNextHelper()}}sortNext(){let t=this.children;return this.children.length>0&&He.is(this.children[0])?t[0]:this.traverseSortNextHelper()}goUp(t){let o=this;for(;t>0&&o!==null;)o=o.parent,t-=1;return o}hasAnccestorOrSelf(t){return this===t||this.hasAnccestor(t)}hasAnccestor(t){let o=this.parent;for(;o;){if(t===o)return!0;o=o.parent}return!1}countToAccestor(t){let o=0,i=this;for(;i!==t;){if(i===null)return-1;i=i.parent,o+=1}return o}forEachEntity(t){for(let o of this.children)cr(o)&&t(o)}traverseEntityAncestors(t){this.traverseAncestors(o=>{He.is(o)&&t(o)})}traverseEntity(t,o=0){if(t(this,o)!==!0)for(let s of this.children)cr(s)&&s.traverseEntity(t,o+1)}traverseVisibleEntity(t){t(this);for(let o of this.children)cr(o)&&o.visible&&o.traverseVisibleEntity(t)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}copy(t,o=!0){return super.copy(t,!1),this.raycastLock=t.raycastLock,this.scaleLock=t.scaleLock,this.hiddenMatrix.copy(t.hiddenMatrix),this}hasEntityChild(){return this.children.some(t=>cr(t))}isAncestorOf(t){if(this.uuid===t)return!1;let o=!1;return this.traverseEntity(i=>{i.uuid===t&&(o=!0)}),o}toObjectTransformState(t=[]){this.updateWorldMatrix(!0,!1);let o={position:this.position.toArray(),rotation:[this.rotation.x,this.rotation.y,this.rotation.z],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return Fn(o,t)}updateTransformState(t){let o=!1;return t.position&&(this.position.fromArray(t.position),o=!0),t.rotation&&(this.rotation.fromArray(t.rotation),o=!0),t.scale&&(o=!0,this.scale.fromArray(t.scale)),t.hiddenMatrix!==void 0&&(o=!0,this.hiddenMatrix.fromArray(t.hiddenMatrix??so.identity)),o&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(i=>{i.invalidateClonerTransform(this)})),t.position&&t.rotation&&t.scale&&t.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),o}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let t of this.children)He.is(t)&&t.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(t=>{He.is(t)&&t.disposeRecursively()})}toState(t=[]){let o={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(t)};return Fn(o,t)}updateByOp(t,o,i,s){let l=this.data;this.data=o;let c=t,u=br(t.path,["states","*"]);if(u!==null){if(t.type===0){let[a]=u;if(this?.stateSelection===a){let d={...t.props};if(Object.values(t.props).some(p=>p===void 0)){let p=this.data;if(p!==void 0){let f=wt.zoom(p,t.path.slice(2));if(f)for(let m in t.props)t.props[m]===void 0&&m in f&&(d[m]=f[m])}}c={...t,props:d,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:p,...f}=a;a=f}if(t.props.material!==void 0&&"material"in a){let{material:p,...f}=a;a=f}let d=wt.removeOverridden(t.path,t.props,a);c={...t,props:d}}}if(this.updateByPatchedOpBase(c,Mo.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),i),br(t.path,["overrides"])){let a=[],d=[...t.path];for(a.push(d[1]),d.splice(0,2);d.length>0&&d[0]==="descendants";)a.push(d[1]),d.splice(0,2);if(a[a.length-1]===void 0){if(t.type===0)for(let p of Object.keys(t.props)){a[a.length-1]=p;let f=i.scene.findInstance([this.uuid,...a]);f&&(f.overrideData=t.props[p],f.updateState(zr.apply(f.component.data,f.overrideData),i))}}else{let p=i.scene.findInstance([this.uuid,...a]);if(p){let f=wt.zoom(p.component.data,d);if(t={...t,path:d},t.type===0){let m=t.props;if(f)for(let[h,y]of Object.entries(t.props))y===void 0&&(m===t.props&&(m={...t.props}),m[h]=f[h]);t={...t,props:m}}p.overrideData=gn.resolve(o.overrides,a),p.updateByOp(t,ft.applySimple(p.data,t),i,!1)}}}else if(this.instances.length>0){let a;if(t.path.length===0&&t.type===0){let d;for(let p of lo.rootOverrideProps)p in t.props&&(d===void 0&&(d={}),d[p]=t.props[p]);d&&(a={...t,props:d})}else for(let d of lo.rootOverrideProps)if(br(t.path,[d])){a=t;break}a!==void 0&&this.instances.forEach(d=>{if(d.isInstanceRoot){let p=zr.filterOp(d.overrideData,a);p&&d.updateByOp(p,ft.applySimple(d.data,p),i,!0)}}),this.instances.forEach(d=>{if(!d.isInstanceRoot){let p=zr.filterOp(d.overrideData,t);if(p){let f;l===d.data&&t===p?f=o:f=ft.applySimple(d.data,p),d.updateByOp(p,f,i,!0)}}})}}updateByPatchedOpBase(t,o,i){if(this.dataPatched=o,t.path.length===0&&t.type===0)t.props.type!==void 0&&!sr.is(t.props.type)&&lr.changeEntityProptotype(this,o,i);else if(t.path.length===1&&t.path[0]==="geometry"&&t.type===0&&"type"in t.props){lr.changeEntityProptotype(this,o,i);for(let s of this.children)He.is(s)&&s.updateVisible()}this.updateByPatchedOp(t,o,i)}updateByPatchedOp(t,o,i){if(t.path.length===0&&t.type===0&&this.updateState(t.props,i),br(t.path,["cloner"])!==null){let s=ft.drop(t,1);s.path.length===0&&s.type===0&&s.props.disabled===!0?this.setFromClonerState(null,i):this.cloner?this.cloner.updateState(o.cloner,i.scene):(this.setFromClonerState(o.cloner,i),this.expandCloner(i.scene)),this.updateVisible()}}updateVisible(){this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0)}updateState_Entity(t,o){t.name!==void 0&&(this.name=t.name),t.raycastLock!==void 0&&(this.raycastLock=t.raycastLock),t.visible!==void 0&&(this.updateVisible(),this.resetBBoxNeedsUpdate()),"cloner"in t&&t.cloner!==void 0&&(this.setFromClonerState(t.cloner,o),this.updateVisible()),this.updateTransformState(t)}get attachedSurfaceCloners(){return this.children.filter(t=>t instanceof lr.Cloner&&t.parameters.type==="toObject")}setFromClonerState(t,o){this.disposed||(t===null||t.disabled?(this.cloner&&this.cloner.removeFromParent(),this.cloner=void 0):(this.cloner===void 0&&(this.cloner=new lr.Cloner(this,t),o.scene.addPendingExpandCloner(this)),this.cloner.updateState(t,o.scene)))}expandCloner(t){!this.disposed&&this.cloner&&this.cloner.expandClones(t)}invalidateClonerTransform(t){this.cloner&&this.cloner.invalidateTransform(t)}};var fm=require("three");var Ue=require("three"),pm=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:0,cornerSegments:8,hollow:0},n.parameters),t=e.width/2,o=e.radiusTop??t,i=e.radiusBottom??t;return o===i?(o=t,i=t):o>i?(o=t,i=i*t/o):(o=o*t/i,i=t),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),radiusTop:o,radiusBottom:i})}}static build(n){let{width:r,depth:e,height:t,radialSegments:o,heightSegments:i,openEnded:s,thetaStart:l,thetaLength:c,radiusTop:u,radiusBottom:a,cornerRadius:d,cornerSegments:p,hollow:f}=n.parameters,m;return d||f?m=new Ki(u,a,t,o,i,s,l,c*Math.PI/180,d,d,p,f):m=new Ue.CylinderGeometry(u,a,t,o,i,s,l,c*Math.PI/180),m.scale(1,1,e/r),Object.assign(m,{userData:{...n,type:"CylinderGeometry"}})}};function yo(n,r,e){e.x=n.x*r.x,e.y=n.y,e.z=n.x*r.y}function um(n){return new Ue.Vector2(n.y,-n.x)}var Ki=class extends Ue.BufferGeometry{constructor(r,e,t,o,i,s,l,c,u,a,d,p,f=!1){super(),this.type="RoundedCylinderBufferGeometry",r=r!==void 0?r:1,e=e!==void 0?e:1,t=t||1,o=Math.floor(o)||8,i=Math.floor(i)||1,s=s!==void 0?s:!1,l=l!==void 0?l:0,c=c!==void 0?c:Math.PI*2,s&&(u=0,a=0);let m=[],h=[],y=[],g=[],v=0,w=t/2,b=new Ue.Vector3,S=new Ue.Vector3;f&&r==0&&(r=u),f&&e==0&&(e=a);let A=new Ue.Vector2(r,w),_=new Ue.Vector2(e,-w),x=null,P=null,O=null,I=null,T=A.clone().sub(_),N=0,L=0,U=0;p>0&&(N=Math.min(r,e)*(1-p),L=r-N,U=e-N);let K=A.clone();K.x-=N;let J=Math.PI-T.angle(),se=T.angle(),z=Math.tan(se/2),W=Math.tan(J/2),q=z+W,j=p?q:W,M=p?q:z;if(u=Math.min(u,(r-L)/j,T.length()/q),a=Math.min(a,(e-U)/M,T.length()/q),u>0){let V=u/z;x=A.clone().sub(new Ue.Vector2(V,u)),p&&(O=x.clone(),O.x-=N-q*u),A.sub(T.clone().setLength(V))}if(a>0){let V=a/W;P=_.clone().sub(new Ue.Vector2(V,-a)),_.add(T.clone().setLength(V)),p&&(I=P.clone(),I.x-=N-q*a,K.sub(T.clone().setLength(V)))}T=A.clone().sub(_);let B=T.length()<.5,D=[];for(let V=0;V<=o;V++){let G=[],H=V/o,$=H*c+l,ee=new Ue.Vector2(Math.sin($),Math.cos($));I&&P?(F(G,H,ee,J,a,I,-1,!0),F(G,H,ee,se,a,P,-1,!1)):P?(Y(G,ee,P.x,0,-1),F(G,H,ee,se,a,P,-1,!1)):s||Y(G,ee,e,U,-1);let ae=um(T).normalize();if(yo(ae,ee,b),!B)for(let te=0;te<=i;te++){let re=te/i,oe=T.clone().multiplyScalar(re).add(_);yo(oe,ee,S),h.push(S.x,S.y,S.z),y.push(b.x,b.y,b.z),g.push(H,.5+S.y/t),G.push(v++)}if(O&&x?(F(G,H,ee,J,u,x,1,!1),F(G,H,ee,se,u,O,1,!0)):x?(F(G,H,ee,J,u,x,1,!1),Y(G,ee,x.x,0,1)):s||Y(G,ee,r,L,1),p&&!B){let te=um(T).multiplyScalar(-1).normalize();yo(te,ee,b);for(let re=0;re<=i;re++){let oe=re/i,Z=T.clone().multiplyScalar(-oe).add(K);yo(Z,ee,S),h.push(S.x,S.y,S.z),y.push(b.x,b.y,b.z),g.push(H,.5+S.y/t),G.push(v++)}}p&&!s&&G.push(G[0]),D.push(G)}for(let V=0;V<D.length-1;V++)for(let G=0;G<D[0].length-1;G++){if(s&&p&&G==i)continue;let H=D[V][G],$=D[V+1][G],ee=D[V+1][G+1],ae=D[V][G+1],te=h[ee*3+0],re=h[ee*3+2];m.push(H,$,ae),(te!=0||re!=0)&&m.push($,ee,ae)}c<Math.PI*2&&(k(-1,D[0],l),k(1,D[D.length-1],l+c)),this.setIndex(m),this.setAttribute("position",new Ue.Float32BufferAttribute(h,3)),this.setAttribute("normal",new Ue.Float32BufferAttribute(y,3)),this.setAttribute("uv",new Ue.Float32BufferAttribute(g,2));function F(V,G,H,$,ee,ae,te,re){for(let oe=0;oe<d+1;oe++){let Z=oe/d,he=te<0?Z:1-Z;re&&(he-=1),he*=$;let ue=new Ue.Vector2(Math.sin(he),Math.cos(he)*te),ge=ue.clone().multiplyScalar(ee).add(ae);yo(ge,H,S),h.push(S.x,S.y,S.z),yo(ue,H,b),y.push(b.x,b.y,b.z),g.push(G,.5+S.y/t),V.push(v++)}}function Y(V,G,H,$,ee){let ae=new Ue.Vector3,te=new Ue.Vector2,re=[H,$];ee<0&&re.reverse();for(let oe of re)te.set(oe,w*ee),yo(te,G,ae),h.push(ae.x,ae.y,ae.z),y.push(0,ee,0),g.push(.5,.5),V.push(v++)}function k(V,G,H){let $=new Ue.Vector2(Math.sin(H),Math.cos(H)),ee=new Ue.Vector2(-Math.cos(H),Math.sin(H)),ae=new Ue.Vector3,te=V<0?(Z,he,ue)=>m.push(Z,he,ue):(Z,he,ue)=>m.push(Z,ue,he),re=new Ue.Vector2((r+e+L+U)/4,0);yo(re,$,ae),h.push(ae.x,ae.y,ae.z),y.push(ee.x,0,ee.y),g.push(.5,.5);let oe=v++;for(let Z of G){let he=h.slice(Z*3,Z*3+3);h.push(...he),y.push(ee.x,0,ee.y);let ue=g.slice(Z*2,Z*2+2);g.push(...ue),v++}for(let Z=oe+1;Z<v-1;Z++)te(oe,Z,Z+1);te(oe,v-1,oe+1)}}};var mm=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:0,cornerRadiusBottom:0,cornerSegments:8},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:r,depth:e,height:t,radialSegments:o,heightSegments:i,openEnded:s,thetaStart:l,thetaLength:c,cornerRadiusTop:u,cornerRadiusBottom:a,cornerSegments:d}=n.parameters,p;return u>0||a>0||c<360?p=new Ki(0,r/2,t,o,i,s,l,c*Math.PI/180,u,a,d,0,!0):p=new fm.ConeGeometry(r/2,t,o,i,s),p.scale(1,1,e/r),Object.assign(p,{userData:{...n,type:"ConeGeometry"}})}};var Dt=require("three"),hm=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:0,cornerSegments:8},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:r,height:e,depth:t,widthSegments:o,heightSegments:i,depthSegments:s,cornerRadius:l,cornerSegments:c}=n.parameters,u;return l==0?u=new Dt.BoxGeometry(r,e,t,o,i,s):u=new _c(r,e,t,o,i,s,l,c),Object.assign(u,{userData:{...n,type:"CubeGeometry"}})}},wc=Math.PI/2,_c=class extends Dt.BufferGeometry{constructor(r=1,e=1,t=1,o=1,i=1,s=1,l=0,c=4){super(),this.type="BoxGeometry";let u=this;o=Math.floor(o),i=Math.floor(i),s=Math.floor(s),c=Math.floor(c),l=Math.min(l,r/2,e/2,t/2);let a=[],d=[],p=[],f=[],m=0,h=0;y("z","y","x",-1,-1,t,e,r,s,i,0),y("z","y","x",1,-1,t,e,-r,s,i,1),y("x","z","y",1,1,r,t,e,o,s,2),y("x","z","y",1,-1,r,t,-e,o,s,3),y("x","y","z",1,-1,r,e,t,o,i,4),y("x","y","z",-1,-1,r,e,-t,o,i,5),l>0&&(g("z","y","x",-1,-1,1,t,e,r,s,0),g("z","y","x",1,-1,-1,t,e,r,s,1),g("z","y","x",-1,1,-1,t,e,r,s,1),g("z","y","x",1,1,1,t,e,r,s,0),g("x","y","z",-1,-1,-1,r,e,t,o,0),g("x","y","z",1,-1,1,r,e,t,o,1),g("x","y","z",-1,1,1,r,e,t,o,0),g("x","y","z",1,1,-1,r,e,t,o,1),g("y","x","z",-1,-1,1,e,r,t,i,0),g("y","x","z",1,-1,-1,e,r,t,i,1),g("y","x","z",1,1,1,e,r,t,i,1),g("y","x","z",-1,1,-1,e,r,t,i,0),v(1,1,1),v(-1,1,1),v(1,-1,1),v(-1,-1,1),v(1,1,-1),v(-1,1,-1),v(1,-1,-1),v(-1,-1,-1)),this.setIndex(a),this.setAttribute("position",new Dt.Float32BufferAttribute(d,3)),this.setAttribute("normal",new Dt.Float32BufferAttribute(p,3)),this.setAttribute("uv",new Dt.Float32BufferAttribute(f,2));function y(w,b,S,A,_,x,P,O,I,T,N){let L=(x-2*l)/I,U=(P-2*l)/T,K=x/2-l,J=P/2-l,se=O/2,z=I+1,W=T+1,q=0,j=0,M=new Dt.Vector3;for(let B=0;B<W;B++){let D=B*U-J;for(let F=0;F<z;F++){let Y=F*L-K;M[w]=Y*A,M[b]=D*_,M[S]=se,d.push(M.x,M.y,M.z),M[w]=0,M[b]=0,M[S]=O>0?1:-1,p.push(M.x,M.y,M.z),f.push(F/I),f.push(1-B/T),q+=1}}for(let B=0;B<T;B++)for(let D=0;D<I;D++){let F=m+D+z*B,Y=m+D+z*(B+1),k=m+(D+1)+z*(B+1),V=m+(D+1)+z*B;a.push(F,Y,V),a.push(Y,k,V),j+=6}u.addGroup(h,j,N),h+=j,m+=q}function g(w,b,S,A,_,x,P,O,I,T,N){let L=(P-2*l)/T,U=P/2-l,K=O/2-l,J=I/2,se=T+1,z=0,W=0,q=new Dt.Vector3,j=new Dt.Vector3;for(let M=0;M<c+1;M++){let B=M/c*wc,D=Math.sin(B)*l,F=(1-Math.cos(B))*l,Y=Math.sin(B),k=Math.cos(B);q[b]=(K+D)*_,q[S]=(J-F)*x,j[w]=0,j[b]=Y*Math.sign(q[b]),j[S]=k*Math.sign(q[S]);for(let V=0;V<se;V++){let G=V*L-U;q[w]=G*A,d.push(q.x,q.y,q.z),p.push(j.x,j.y,j.z),f.push(V/T),f.push(0),z+=1}}for(let M=0;M<c;M++)for(let B=0;B<T;B++){let D=m+B+se*M,F=m+B+se*(M+1),Y=m+(B+1)+se*(M+1),k=m+(B+1)+se*M;a.push(D,F,k),a.push(F,Y,k),W+=6}u.addGroup(h,W,N),h+=W,m+=z}function v(w,b,S){let A=new Dt.Vector3,_=new Dt.Vector3(r/2,e/2,t/2);_.subScalar(l);let x=[],P=w*b*S>0?(I,T,N)=>a.push(I,T,N):(I,T,N)=>a.push(I,N,T);for(let I=0;I<=c;I++){let T=[],N=wc*(1-I/c),L=Math.cos(N),U=Math.sin(N),K=0;for(let J=0;J<=I;J++){let se=Math.cos(K),z=Math.sin(K);A.x=L*se,A.y=U,A.z=L*z;let W=_.clone().addScaledVector(A,l);d.push(w*W.x,b*W.y,S*W.z),p.push(w*A.x,b*A.y,S*A.z),f.push(0,0),T.push(m++),K+=wc/I}x.push(T)}let O=x.length-1;for(let I=0;I<O;I++){let T=x[I],N=x[I+1],L=T.length-1;P(T[0],N[1],N[0]);for(let U=1;U<=L;U++)P(T[U-1],T[U],N[U]),P(T[U],N[U+1],N[U])}}}};var $e=require("three"),go=class extends $e.BufferGeometry{constructor(r=[],e=[],t="",o=1,i=.2,s=4){super(),this.type="PolyhedronGeometryRound";let l=[],c=[],u=[];a(),d(),this.setAttribute("position",new $e.Float32BufferAttribute(l,3)),this.setAttribute("normal",new $e.Float32BufferAttribute(u,3)),this.setAttribute("uv",new $e.Float32BufferAttribute(c,2));return;function a(){i=Math.min(1-1e-5,i),i==0&&(s=0);let f={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[t],m=new $e.Vector3,h=m.clone(),y=new $e.Triangle,g=i*o,v=o-g,w=s+1,b=new $e.Vector3,S=(z,W)=>b.subVectors(z,W).normalize(),A=(z,W)=>Array(z).fill(void 0).map(W),_=A(r.length/3,(z,W)=>new $e.Vector3().fromArray(r,W*3).setLength(o)),x=[],P=1e6;for(let z=0;z<_.length;z++){let W=_[z],q=[],j,M,B,D=1e10,F=-1;for(;(F=e.indexOf(z,F+1))!=-1;){let G=F-F%3;j=e[G+(F+1)%3],M=e[G+(F+2)%3],B=W.distanceToSquared(_[j]),D=Math.min(D,B),q.push([j,M,B])}D+=1e-6;let Y=[],k=0,V=q.length;for(let G=0;G<V;G++){[j,M,B]=q[k];let H=x[j]?.includes(z)==!0;B<=D&&Y.push(j+ +H*P),k=q.findIndex($=>$[0]==M)}x.push(Y)}let O=[];{let z=0,W=0,q,j,M=f==3;for(let B=0;B<=s;B++){q=B*(B+1)/2,j=(B+1)*(B+2)/2;for(let D=0;D<s-B;D++)[z,W]=[q+D+B+2,j+D+B+3],O.push(q,j,...M?[W,q]:[z,j],W,z),[q,j]=[z,W];O.push(q,j,q+s+2)}}let I=m.clone(),T=m.clone(),N=m.clone(),L=m.clone(),U=m.clone(),K=[],J=A(_.length,()=>A(f,()=>m.clone()));for(let z=0;z<_.length;z++){m.copy(_[z]).normalize(),I.copy(m).multiplyScalar(v);let W=x[z];for(let Y=0;Y<W.length;Y++){let k=W[Y],V=W[(Y+1)%f];y.setFromPointsAndIndices(_,z,k%P,V%P),y.b.sub(y.a).setLength(1e10).add(y.a),y.c.sub(y.a).setLength(1e10).add(y.a),y.closestPointToPoint(I,J[z][Y])}let q=[],j=[],M=[],B=new $e.Vector3;s==0&&[...J[z]].reduce((Y,k)=>Y.add(k),B).multiplyScalar(1/f);for(let Y=0;Y<f;Y++){let k=[],V=(Y-1+f)%f,G=J[z][V],H=J[z][Y];m.copy(G).sub(I),h.copy(H).sub(I);let $=I.angleTo(m),ee=m.angleTo(h),ae=Math.cos($)*g;s==0?T.copy(B):T.copy(I).setLength(v+ae),j.push(ae);let te=[T,G,H];for(let re=0;re<2;re++){let oe=te[re],Z=te[re+1];L.subVectors(oe,I),U.subVectors(Z,I),N.crossVectors(L,U).normalize();for(let he=0;he<w;he++){let ue=[$,ee][re]*he/w;m.copy(L).applyAxisAngle(N,ue).add(I),q.push(m.clone()),re&&(S(m,I),k.push([he==0?oe:m.clone(),b.clone()]))}re&&(S(Z,I),k.push([Z,b.clone()]))}M.push(k)}K.push(M);let D=2*w,F=2;for(let Y=0;Y<f;Y++){let k=D*Y,V=D*((Y+1)%f),G=[q[k]];for(let $=1;$<w;$++){L=q[k+$],U=q[V+$],G.push(L);for(let ee=1,ae=$-F+1;ee<=ae;ee++)m.lerpVectors(L,U,ee/(ae+1)),m.sub(I).setLength(j[Y]).add(I),G.push(m.clone());G.push(U)}for(let $=0;$<w;$++)G.push(q[$+w+k]);G.push(q[V+w]);let H=O.map($=>G[$]);l.push(...H.map($=>[$.x,$.y,$.z]).flat()),u.push(...H.map($=>(S($,I),[b.x,b.y,b.z])).flat())}}let se=[];for(let z=0;z<x.length;z++)for(let W=0;W<f;W++){let q=x[z][W];if(q<P){let j=x[q].findIndex(D=>D%P==z),M=K[z][W],B=K[q][j];for(let D=0;D<w;D++){let F=M[D],Y=B[w-D],k=M[D+1],V=B[w-(D+1)];[F,Y,k,k,Y,V].forEach(G=>{l.push(G[0].x,G[0].y,G[0].z),u.push(G[1].x,G[1].y,G[1].z)})}se.push(M[0][0],B[w][0],M[w][0],B[0][0])}}for(;se.length;){let z,W,q,j;[z,W]=se.splice(0,2);let M=[z];for(;z!=W;)M.push(W),q=se.indexOf(W),j=q%2,W=se.splice(q-j,2)[1-j];b.subVectors(M[0],M[1]).cross(m.subVectors(M[0],M[2])).normalize();let B=b.dot(M[0])<0;B&&b.negate();for(let D=1;D<=M.length-2;D++)[M[D+ +B],M[D+1-+B],M[0]].forEach(F=>{l.push(F.x,F.y,F.z),u.push(b.x,b.y,b.z)})}}function d(){let p=new $e.Vector3;for(let _=0;_<l.length;_+=3){p.x=l[_+0],p.y=l[_+1],p.z=l[_+2];let x=S(p)/2/Math.PI+.5,P=A(p)/Math.PI+.5;c.push(x,1-P)}let f=new $e.Vector3,m=new $e.Vector3,h=new $e.Vector3,y=new $e.Vector3,g=new $e.Vector2,v=new $e.Vector2,w=new $e.Vector2,b=(_,x,P,O)=>{O<0&&_.x===1&&(c[x]=_.x-1),P.x===0&&P.z===0&&(c[x]=O/2/Math.PI+.5)};for(let _=0,x=0;_<l.length;_+=9,x+=6){f.set(l[_+0],l[_+1],l[_+2]),m.set(l[_+3],l[_+4],l[_+5]),h.set(l[_+6],l[_+7],l[_+8]),g.set(c[x+0],c[x+1]),v.set(c[x+2],c[x+3]),w.set(c[x+4],c[x+5]),y.copy(f).add(m).add(h).divideScalar(3);let P=S(y);b(g,x+0,f,P),b(v,x+2,m,P),b(w,x+4,h,P)}for(let _=0;_<c.length;_+=6){let x=c[_+0],P=c[_+2],O=c[_+4],I=Math.max(x,P,O),T=Math.min(x,P,O);I>.9&&T<.1&&(x<.2&&(c[_+0]+=1),P<.2&&(c[_+2]+=1),O<.2&&(c[_+4]+=1))}function S(_){return Math.atan2(_.z,-_.x)}function A(_){return Math.atan2(-_.y,Math.sqrt(_.x*_.x+_.z*_.z))}}}static fromJSON(r){return new go(r.vertices,r.indices,r.radius,r.corner,r.cornerSides)}};var ym=require("three"),gm=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,detail:0,corner:0,cornerSides:4},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:r,height:e,depth:t,detail:o,corner:i,cornerSides:s}=n.parameters,l=o===0&&i!==0?new Zi(r*.5,i,s):new ym.DodecahedronGeometry(r*.5,o);return l.scale(1,e/r,t/r),Object.assign(l,{userData:{...n,type:"DodecahedronGeometry"}})}},Zi=class extends go{constructor(r=1,e=.2,t=4){let o=(1+Math.sqrt(5))/2,i=1/o,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-i,-o,0,-i,o,0,i,-o,0,i,o,-i,-o,0,-i,o,0,i,-o,0,i,o,0,-o,0,-i,o,0,-i,-o,0,i,o,0,i],l=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],c="DodecahedronGeometry";super(s,l,c,r,e,t),this.type=c}static fromJSON(r){return new Zi(r.radius,r.corner,r.cornerSides)}};var Oe=require("three");var ye=require("three"),Qi=1e-12,Hn=class{constructor(r){this.position=new ye.Vector2;this.startPosition=new ye.Vector2;this.uuid=ye.MathUtils.generateUUID();this.position=r.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(r){this.position.copy(this.startPosition).add(r)}copy(r){return this.position.copy(r.position),this.startPosition.copy(r.startPosition),this}clone(){return new Hn(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},Wn=class extends Hn{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new Wn(this.parent).copy(this)}},dr=class extends Hn{constructor(e,t){super(t);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new Wn(this),new Wn(this))}static create(e,t){let o=new dr(e,new ye.Vector2(...t.position));return o.controls[0].position.set(...t.controlPrevious.position),o.controls[1].position.set(...t.controlNext.position),o.roundness=t.roundness,o.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored,o}getOppositeControl(e){let t=this.controls.indexOf(e);return t===0?this.controls[1]:t===1?this.controls[0]:null}applyOffsetToControls(e,t=1){for(let o=0,i=this.controls.length;o<i;o++){let s=this.controls[o];this.position.distanceTo(s.position)<=t?s.position.copy(this.position):s.applyOffset(e)}}controlsMoved(){return!(this.position.equals(this.controls[0].position)&&this.position.equals(this.controls[1].position))}copy(e){return super.copy(e),this.controls[0].copy(e.controls[0]),this.controls[1].copy(e.controls[1]),this.roundness=e.roundness,this.uuid=e.uuid,this}clone(){return new dr(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}computeTangents(){let e=this.curveBefore?.getTangentAt(1),t=this.curveAfter?.getTangentAt(0);return[e,t]}computeNormals(e=new ye.Vector2,t=new ye.Vector2){let[o,i]=this.computeTangents();return o&&i&&(xm(o,e),xm(i,t)),[e,t]}computeTangent(e=new ye.Vector2){let[t,o]=this.computeTangents();return t&&o&&e.copy(t).add(o).normalize(),e}computeNormal(e=new ye.Vector2){let[t,o]=this.computeNormals();return e.copy(t).add(o).normalize(),e}};function xm(n,r=new ye.Vector2){let e=n.length();return r.set(-n.y/e,n.x/e)}var Oc=n=>n,qn=new ye.Vector2,Ka=new ye.Vector2,fw=new ye.Vector2,mw=new ye.Vector2,hw=new ye.Vector2,yw=new ye.Vector2,bm=new ye.Vector3,Sm=new ye.Vector3;function wm(n){let r=new ye.Vector2;r.addVectors(n.v0,qn.subVectors(n.v1,n.v0).multiplyScalar(2/3));let e=new ye.Vector2;return e.addVectors(n.v2,Ka.subVectors(n.v1,n.v2).multiplyScalar(2/3)),new ye.CubicBezierCurve(n.v0,r,e,n.v2)}function Ji(n,r,e=Number.EPSILON){return Math.abs(n-r)<e}function gw(n,r,e=Number.EPSILON){return n.distanceTo(r)<e}function xw(n,r,e=Number.EPSILON){return n.distanceTo(r)<e}function Ac(n,r,e){let t=Math.sqrt(Math.pow(r.x-n.x,2)+Math.pow(r.y-n.y,2)),o=Math.sqrt(Math.pow(r.x-e.x,2)+Math.pow(r.y-e.y,2)),i=Math.sqrt(Math.pow(e.x-n.x,2)+Math.pow(e.y-n.y,2));return Math.acos((o*o+t*t-i*i)/(2*o*t))}function _m(n,r,e){return vm(n,r)&&vm(r,e)&&Tc(n.position,r.position,e.position)}function Tc(n,r,e){return qn.copy(r).sub(n).cross(Ka.copy(e).sub(n))===0}function Tm(n,r,e,t,o){let i=Math.sqrt(Math.pow(r.x-n.x,2)+Math.pow(r.y-n.y,2)),s=(n.y+r.y)/2,l=(n.x+r.x)/2,c=Math.sqrt(Math.pow(e,2)-Math.pow(i/2,2))*(n.y-r.y)/i,u=Math.sqrt(Math.pow(e,2)-Math.pow(i/2,2))*(r.x-n.x)/i;return t.set(l+c,s+u),o.set(l-c,s-u),[t,o]}function Om(n,r,e){let t=n.distanceTo(e),o=r.distanceTo(e);return t<o?r:n}function Am(n,r,e,t,o,i){let s=r.x-n.x,l=r.y-n.y,c=e.x-n.x,u=e.y-n.y,a=Math.sqrt((s+c)*(s+c)+(l+u)*(l+u)),d;return Ac(r,n,e)>Math.PI&&(a*=-1),Ji(u,l)?d=(l+u)*(t/a-.5)*8/3/(s-c):d=(s+c)*(t/a-.5)*8/3/(u-l),o.set(r.x-d*l,r.y+d*s),i.set(e.x+d*u,e.y-d*c),[o,i]}function Pc(n,r){return n.position.equals(n.controls[1].position)&&r.position.equals(r.controls[0].position)}function vm(n,r){return Tc(n.position,n.controls[1].position,r.position)&&Tc(n.position,r.controls[0].position,r.position)}function Pm(n,r,e,t,o=.5){let i=qn.subVectors(r,n).multiplyScalar(o).add(n),s=Ka.subVectors(e,r).multiplyScalar(o).add(r),l=fw.subVectors(t,e).multiplyScalar(o).add(e),c=i,u=mw.subVectors(s,i).multiplyScalar(o).add(i),a=hw.subVectors(l,s).multiplyScalar(o).add(s),d=l,p=yw.subVectors(a,u).multiplyScalar(o).add(u);return[n.x,n.y,c.x,c.y,u.x,u.y,p.x,p.y,a.x,a.y,d.x,d.y,t.x,t.y]}function Im(n,r,e=12,t=!0){let o=Sm.set(0,0,0),i,s=0,l=[];for(let c=0;c<r.length;c++){let u=Oc(r[c]),a=qn,d=xo(u,e);l.push(d);for(let p=0;p<=d;p++)if(u instanceof ye.CubicBezierCurve||u instanceof ye.QuadraticBezierCurve||u instanceof ye.LineCurve){if(u.getPoint(p/d,a),o.set(a.x,a.y,0),i!==void 0&&xw(i,o))continue;i===void 0&&(i=bm),i.copy(o),n.setXYZ(s,o.x,o.y,o.z),s++}}return t&&s>1&&!(n.getX(s-1)===n.getX(0)&&n.getY(s-1)===n.getY(0)&&n.getZ(s-1)===n.getZ(0))&&(n.setXYZ(s,n.getX(0),n.getY(0),n.getZ(0)),s++),n}function Cm(n,r,e,t=12,o=!0){let i=Sm.set(0,0,0),s=0,l=[];for(let c=0;c<r.length;c++){if(e[c]===!1)continue;let u,a=Oc(r[c]),d=qn,p=xo(a,t);l.push(p);for(let f=0;f<=p;f++)if(a instanceof ye.CubicBezierCurve||a instanceof ye.QuadraticBezierCurve||a instanceof ye.LineCurve){if(a.getPoint(f/p,d),i.set(d.x,d.y,0),u?.equals(i))continue;u===void 0?u=bm:(n.setXYZ(s,u.x,u.y,u.z),s++,n.setXYZ(s,i.x,i.y,i.z),s++),u.copy(i)}}return o&&s>1&&!(n.getX(s-1)===n.getX(0)&&n.getY(s-1)===n.getY(0)&&n.getZ(s-1)===n.getZ(0))&&(n.setXYZ(s,n.getX(0),n.getY(0),n.getZ(0)),s++),l}function Ic(n,r=12,e=!1){let t=[];for(let o=0,i=n.length;o<i;o++){let s=n[o],l=0;if(e&&s.roundedCurveCorner!==void 0){let c=xo(s.roundedCurveCorner,r)*.5;o>0&&(t[o-1]+=c),l+=c}s.curveAfter!==void 0&&(l+=xo(s.curveAfter,r)),t.push(l)}return n.length>0&&e&&n[0].roundedCurveCorner!==void 0&&(t[n.length-1]+=xo(n[0].roundedCurveCorner,r)*.5),t}function xo(n,r=12){return n&&n instanceof ye.EllipseCurve?r*2:n&&(n instanceof ye.LineCurve||n instanceof ye.LineCurve3)?1:n&&n instanceof ye.SplineCurve?r*n.points.length:r}function Nm(n,r,e=12,t=!0){let o,i=0;for(let s=0;s<r.length;s++){let l=Oc(r[s]),c=xo(l,e),u=qn;for(let a=0;a<=c;a++)if(l instanceof ye.CubicBezierCurve||l instanceof ye.QuadraticBezierCurve||l instanceof ye.LineCurve){if(l.getPoint(a/c,u),o!==void 0&&gw(o,u,Qi))continue;o===void 0&&(o=Ka),o.copy(u),n.push(u.x,u.y),i++}}return Ji(n[0],n[n.length-2],Qi)&&Ji(n[1],n[n.length-1],Qi)&&(n.pop(),n.pop()),t&&i>1&&!(Ji(n[i-1],n[1],Qi)&&Ji(n[i-2],n[0],Qi))&&(n.push(n[0],n[1]),i++),n}var Cc=new Oe.Vector2,vw=new Oe.Vector2,bw=new Oe.Vector2,Sw=new Oe.Vector2,ww=new Oe.Vector2,_w=new Oe.Vector2,Te=class extends Oe.Shape{constructor(e=100,t=100){super();this.points=[];this.shapeHoles=[];this.plane=new Oe.Plane(new Oe.Vector3(0,0,-1));this.subdivision=0;this.controlSnapDistance=4;this.pointIDs=0;this.isMesh2D=!1;this._roundness=0;this.isClosed=!1;this.useCubicForRoundedCorners=!0;this.uuid=Oe.MathUtils.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=t}static createFromState(e,t,o){let i=new Te;return i.isClosed=e.isClosed,i.points=e.points.map(s=>dr.create(s.id,s.data)),typeof e.roundness=="number"&&(i.roundness=e.roundness),i.shapeHoles=e.shapeHoles.map(s=>Te.createFromState(s)),t!==void 0&&o!==void 0&&i.applySize(t,o),i.update(),i}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(e){if(this._roundness!==e){this._roundness=e;for(let t=0,o=this.points.length;t<o;t++)this.points[t].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(t=>this.getPointIndexById(t)).filter(t=>t>=0)}getPointIndexById(e){let t=this.points.length,o=this.points.findIndex(i=>i.uuid===e);if(o<0){let i=t;for(let s=0,l=this.shapeHoles.length;s<l;s++){let c=this.shapeHoles[s],u=c.points.length,a=c.getPointIndexById(e);if(a<0)i+=u;else return a+i}}return o}getLineIndexById(e){return this.getPointIndexById(e)}getBezierPoint(e){if(e<=this.points.length-1)return this.points[e];if(this.shapeHoles.length>0){let t=this.points.length;for(let o=0,i=this.shapeHoles.length;o<i;o++){let s=this.shapeHoles[o],l=e-t;if(l<=s.points.length-1)return s.points[l];t+=s.points.length}}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let t=this.points.indexOf(e);if(t>=0)return t;if(t=this.points.length,this.shapeHoles.length>0)for(let o=0,i=this.shapeHoles.length;o<i;o++){let s=this.shapeHoles[o],l=s.points.indexOf(e);if(l>=0)return t+l;t+=s.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(t=>t.points));return[...this.points,...e]}applySize(e,t){e===0&&(e=.001),t===0&&(t=.001),this._width=e,this._height=t}applyScale(e,t){let o=Cc.set(e,t);for(let i=0,s=this.points.length;i<s;i++){let l=this.points[i];l.position.multiply(o),l.controls[0].position.multiply(o),l.controls[1].position.multiply(o)}for(let i=0,s=this.shapeHoles.length;i<s;i++)this.shapeHoles[i].applyScale(e,t);this._update()}createPoint(e,t=0,o=Oe.MathUtils.generateUUID()){let i;e instanceof Oe.Vector2?i=e:i=new Oe.Vector2(e,t);let s=new dr(o,i);return s.roundness=this.roundness,s}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,t){this.points.splice(t,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let t=0,o=this.points.length;t<o;t++){let i=this.points[t];if(i.uuid===e)return i}for(let t=0,o=this.shapeHoles.length;t<o;t++){let s=this.shapeHoles[t].getPointByUuid(e);if(s)return s}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){let t=this.points.indexOf(e);t>=0&&this.points.splice(t,1),this.needsUpdate=!0}removePointById(e){let t=this.points.find(o=>o.uuid===e);t&&this.removePoint(t)}update(){for(let e=0,t=this.shapeHoles.length;e<t;e++)this.shapeHoles[e].update();this._update()}extractShapePointsToBuffer(e,t=12,o=!1){this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t);let i=o?this.roundedCurveDivisions:this.curveDivisions;return Im(e,o?this.roundedCurves:this.curves,t,this.autoClose),i.reduce((s,l)=>s+l,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=Ic(this.points,e,!1),this.roundedCurveDivisions=Ic(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,t,o=12){return Cm(e,this.curves,t,o,this.autoClose).reduce((s,l)=>s+l,0)*2}extractShapePointsToFlatArray(e,t=12){return this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t),Nm(e,this.roundedCurves,t,this.autoClose)}getCurveIndexFromVertexId(e,t=!1){let o=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let i=t?this.roundedCurveDivisions:this.curveDivisions,s=0;t&&this.points[0].roundedCurveCorner!==void 0&&(s=xo(this.points[0].roundedCurveCorner,this.subdivision)*.5);let l=e-s;l<0&&(l+=i.reduce((c,u)=>c+u,0));for(let c=0,u=i.length;c<u;c++){let a=i[c];if(l<o+a)return[c,(l-o+1)/a];o+=a}return[0,1]}getCurveT(e,t,o){let i=this.points[e],s=this.points[e>=this.points.length-1?0:e+1],l=this.curveDivisions,c=l[e];if(Pc(i,s)){let d=i.position.distanceTo(s.position);return i.position.distanceTo(Cc.set(o.x,o.y))/d}let u=0;for(let d=0;d<e;d++)u+=l[d];return(t-u)/c}dispose(){}_applyCurveForPoint(e,t){Pc(t,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(t.controls[1].position.x,t.controls[1].position.y,e.controls[0].position.x,e.controls[0].position.y,e.position.x,e.position.y);let o=this.curves[this.curves.length-1];e.curveBefore=o,t.curveAfter=o;let i=o.clone();e.roundedCurveBefore=i,t.roundedCurveAfter=i,e.roundedCurveCorner=void 0,this.roundedCurves.push(i)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let t=0,o=this.points.length;t<o;t++){let i=this.points[t];if(t===0)this.moveTo(i.position.x,i.position.y);else{let s=this.points[t-1];this._applyCurveForPoint(i,s)}}let e=this.getLastPoint();if(e?.curveAfter&&(e.curveAfter=void 0),this.isClosed){let t=this.points[0],o=this.points[this.points.length-1];this._applyCurveForPoint(t,o)}if(this.points.length>2){let t=0;for(let o=0,i=this.points.length;o<i;o++){let s=this.points[o],l=this.points[o-1]??this.points[this.points.length-1],c=this.points[o+1]??this.points[0],u=s.roundness,a=l&&c&&_m(l,s,c);if(!s.controlsMoved()&&u>0&&!a){let d=s.curveBefore,p=s.curveAfter;if(d===void 0||p===void 0)continue;let f=s.roundedCurveBefore,m=s.roundedCurveAfter,h=d.getLength(),y=p.getLength(),g=Math.min(u,h*.499),v=Math.min(u,y*.499),w=Math.min(g,v),b=1-w/h,S=w/y,A=d.getPointAt(b,Cc),_=p.getPointAt(S,vw);this._subSplitCurve(d,f,b,A,void 0),this._subSplitCurve(p,m,S,void 0,_);let x;if(this.useCubicForRoundedCorners){let P=Ac(A,s.position,_)/2,O=Math.tan(P)*A.distanceTo(s.position),[I,T]=Tm(A,_,O,bw,Sw),N=Om(I,T,s.position),[L,U]=Am(N,A,_,O,ww,_w);x=new Oe.CubicBezierCurve(A.clone(),L.clone(),U.clone(),_.clone())}else x=new Oe.QuadraticBezierCurve(A.clone(),s.position.clone(),_.clone());s.roundedCurveCorner=x,this.roundedCurves.splice(o+t,0,x),t++}}}}_subSplitCurve(e,t,o,i,s){if(e instanceof Oe.LineCurve)i!==void 0&&t.v2.copy(i),s!==void 0&&t.v1.copy(s);else{let l=e,c=t,u=l.getUtoTmapping(o,0),a=Pm(l.v0,l.v1,l.v2,l.v3,u);return i!==void 0&&(c.v0.set(a[0],a[1]),c.v1.set(a[2],a[3]),c.v2.set(a[4],a[5]),c.v3.set(a[6],a[7])),s!==void 0&&(c.v0.set(a[6],a[7]),c.v1.set(a[8],a[9]),c.v2.set(a[10],a[11]),c.v3.set(a[12],a[13])),c}return t}clone(){let e=new Te(this._width,this._height);return e.points=this.points.map(t=>t.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(t=>t.clone()),e}toJSON(){return{points:this.points.reduce((e,t)=>e.concat(t.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){this.points=[],this.pointIDs=0;let t=e.points.length/7;for(let o=0;o<t;o++){let i=o*7,s=e.points[i+0],l=e.points[i+1],c=e.points[i+2],u=e.points[i+3],a=e.points[i+4],d=e.points[i+5],p=e.points[i+6],f=new dr(Oe.MathUtils.generateUUID(),new Oe.Vector2(s,l));f.controls[0].position.set(c,u),f.controls[1].position.set(a,d),f.roundness=p,this.points.push(f)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(o=>{let i=new Te;return i.fromJSON(o),i}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e){let t=(i,s)=>{s instanceof Oe.CubicBezierCurve&&s.v3.equals(i.position)&&i.controls[0].position.copy(s.v2)},o=i=>{let s=[],l,c;for(l=0,c=i.length;l<c;l++)i[l]instanceof Oe.QuadraticBezierCurve&&(i[l]=wm(i[l]));for(l=0,c=i.length;l<c;l++){let d=i[l],p=l>0?i[l-1]:null,f;d instanceof Oe.CubicBezierCurve?(f=this.createPoint(d.v0),f.controls[1].position.copy(d.v1)):d instanceof Oe.LineCurve&&(f=this.createPoint(d.v1)),f!==void 0&&(p!==null&&t(f,p),s.push(f))}let u=i[i.length-1],a=!1;return u instanceof Oe.CubicBezierCurve?u.v3.equals(s[0].position)&&(s[0].controls[0].position.copy(u.v2),a=!0):u instanceof Oe.LineCurve&&u.v2.equals(s[0].position)&&(a=!0),this.isClosed=a,s};return this.points=o(e.curves),e instanceof Oe.Shape&&(this.shapeHoles=e.holes.map(i=>{let s=new Te;return s.fromShape(i),s})),this.update(),this}updatePoint(e,t){let o=this.getPointByUuid(e);o&&(t.position!==void 0&&o.position.fromArray(t.position),t.roundness!==void 0&&(o.roundness=t.roundness),t.areControlsDirectionsMirrored!==void 0&&(o.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(e,t){let i=this.getPointByUuid(e)?.controls[0];i&&(t.position&&i.position.fromArray(t.position),this.needsUpdate=!0)}updateNextControl(e,t){let i=this.getPointByUuid(e)?.controls[1];i&&(t.position&&i.position.fromArray(t.position),this.needsUpdate=!0)}};var Ec=Math.PI*2;function Nc({x:n,y:r},e,t,o,i){return{x:n*e+o,y:r*t+i}}function Tw(n,r){let e=r===1.5707963267948966?.551915024494:r===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(r/4),t=Math.cos(n),o=Math.sin(n),i=Math.cos(n+r),s=Math.sin(n+r);return[{x:t-o*e,y:o+t*e},{x:i+s*e,y:s-i*e},{x:i,y:s}]}function Em(n,r,e,t){let o=n*t-r*e<0?-1:1,i=Math.min(1,Math.max(-1,n*e+r*t));return o*Math.acos(i)}function Ow(n,r,e,t,o,i,s,l,c,u){let a=Math.pow(o,2),d=Math.pow(i,2),p=Math.pow(s,2),f=Math.pow(l,2),m=a*d-a*f-d*p;m<0&&(m=0),m/=a*f+d*p,m=Math.sqrt(m)*(c===u?-1:1);let h=m*o/i*l,y=m*-i/o*s,g=h+(n+e)/2,v=y+(r+t)/2,w=(s-h)/o,b=(l-y)/i,S=(-s-h)/o,A=(-l-y)/i,_=Em(1,0,w,b),x=Em(w,b,S,A);return!u&&x>0&&(x-=Ec),u&&x<0&&(x+=Ec),{centerx:g,centery:v,ang1:_,ang2:x}}function Lm({px:n,py:r,cx:e,cy:t,rx:o,ry:i,largeArcFlag:s,sweepFlag:l}){let c=[];if(o===0||i===0)return[];let u=(n-e)/2,a=(r-t)/2;if(u===0&&a===0)return[];o=Math.abs(o),i=Math.abs(i);let d=Math.pow(u,2)/Math.pow(o,2)+Math.pow(a,2)/Math.pow(i,2);d>1&&(o*=Math.sqrt(d),i*=Math.sqrt(d));let p=Ow(n,r,e,t,o,i,u,a,s,l),{ang1:f,ang2:m}=p,{centerx:h,centery:y}=p,g=Math.abs(m)/(Ec/4);Math.abs(1-g)<1e-7&&(g=1);let v=Math.max(Math.ceil(g),1);m/=v;for(let w=0;w<v;w++)c.push(Tw(f,m)),f+=m;return c.map(w=>{let{x:b,y:S}=Nc(w[0],o,i,h,y),{x:A,y:_}=Nc(w[1],o,i,h,y),{x,y:P}=Nc(w[2],o,i,h,y);return{x1:b,y1:S,x2:A,y2:_,x,y:P}})}var Uo=require("three");var Be;(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"})(Be||(Be={}));var rt;(function(n){n[n.POLYGONS=0]="POLYGONS",n[n.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",n[n.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(rt||(rt={}));function pe(n,r){if(!n)throw r||"Assertion Failed!"}var le=function(){function n(){}return n.vertEq=function(r,e){return r.s===e.s&&r.t===e.t},n.vertLeq=function(r,e){return r.s<e.s||r.s===e.s&&r.t<=e.t},n.transLeq=function(r,e){return r.t<e.t||r.t===e.t&&r.s<=e.s},n.edgeGoesLeft=function(r){return n.vertLeq(r.Dst,r.Org)},n.edgeGoesRight=function(r){return n.vertLeq(r.Org,r.Dst)},n.vertL1dist=function(r,e){return Math.abs(r.s-e.s)+Math.abs(r.t-e.t)},n.edgeEval=function(r,e,t){pe(n.vertLeq(r,e)&&n.vertLeq(e,t));var o=e.s-r.s,i=t.s-e.s;return o+i>0?o<i?e.t-r.t+(r.t-t.t)*(o/(o+i)):e.t-t.t+(t.t-r.t)*(i/(o+i)):0},n.edgeSign=function(r,e,t){pe(n.vertLeq(r,e)&&n.vertLeq(e,t));var o=e.s-r.s,i=t.s-e.s;return o+i>0?(e.t-t.t)*o+(e.t-r.t)*i:0},n.transEval=function(r,e,t){pe(n.transLeq(r,e)&&n.transLeq(e,t));var o=e.t-r.t,i=t.t-e.t;return o+i>0?o<i?e.s-r.s+(r.s-t.s)*(o/(o+i)):e.s-t.s+(t.s-r.s)*(i/(o+i)):0},n.transSign=function(r,e,t){pe(n.transLeq(r,e)&&n.transLeq(e,t));var o=e.t-r.t,i=t.t-e.t;return o+i>0?(e.s-t.s)*o+(e.s-r.s)*i:0},n.vertCCW=function(r,e,t){return r.s*(e.t-t.t)+e.s*(t.t-r.t)+t.s*(r.t-e.t)>=0},n.interpolate=function(r,e,t,o){return r=r<0?0:r,t=t<0?0:t,r<=t?t===0?(e+o)/2:e+(o-e)*(r/(r+t)):o+(e-o)*(t/(r+t))},n.intersect=function(r,e,t,o,i){var s,l,c;n.vertLeq(r,e)||(c=r,r=e,e=c),n.vertLeq(t,o)||(c=t,t=o,o=c),n.vertLeq(r,t)||(c=r,r=t,t=c,c=e,e=o,o=c),n.vertLeq(t,e)?n.vertLeq(e,o)?(s=n.edgeEval(r,t,e),l=n.edgeEval(t,e,o),s+l<0&&(s=-s,l=-l),i.s=n.interpolate(s,t.s,l,e.s)):(s=n.edgeSign(r,t,e),l=-n.edgeSign(r,o,e),s+l<0&&(s=-s,l=-l),i.s=n.interpolate(s,t.s,l,o.s)):i.s=(t.s+e.s)/2,n.transLeq(r,e)||(c=r,r=e,e=c),n.transLeq(t,o)||(c=t,t=o,o=c),n.transLeq(r,t)||(c=r,r=t,t=c,c=e,e=o,o=c),n.transLeq(t,e)?n.transLeq(e,o)?(s=n.transEval(r,t,e),l=n.transEval(t,e,o),s+l<0&&(s=-s,l=-l),i.t=n.interpolate(s,t.t,l,e.t)):(s=n.transSign(r,t,e),l=-n.transSign(r,o,e),s+l<0&&(s=-s,l=-l),i.t=n.interpolate(s,t.t,l,o.t)):i.t=(t.t+e.t)/2},n}(),es=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}(),Za=function(){function n(r){this.side=r,this.next=null,this.Org=null,this.Sym=null,this.Onext=null,this.Lnext=null,this.Lface=null,this.activeRegion=null,this.winding=0}return Object.defineProperty(n.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(r){this.Sym.Lface=r},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(r){this.Sym.Org=r},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(r){this.Sym.Lnext=r},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(r){this.Onext.Sym=r},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(r){this.Lnext.Sym=r},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(r){this.Sym.Onext=r},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(r){this.Sym.Onext.Sym=r},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(r){this.Sym.Lnext.Sym=r},enumerable:!0,configurable:!0}),n}(),$n=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}(),Mm=function(){function n(){var r=new $n,e=new es,t=new Za(0),o=new Za(1);r.next=r.prev=r,r.anEdge=null,e.next=e.prev=e,t.next=t,t.Sym=o,o.next=o,o.Sym=t,this.vHead=r,this.fHead=e,this.eHead=t,this.eHeadSym=o}return n.prototype.makeEdge_=function(r){var e=new Za(0),t=new Za(1);r.Sym.side<r.side&&(r=r.Sym);var o=r.Sym.next;return t.next=o,o.Sym.next=e,e.next=r,r.Sym.next=t,e.Sym=t,e.Onext=e,e.Lnext=t,e.Org=null,e.Lface=null,e.winding=0,e.activeRegion=null,t.Sym=e,t.Onext=t,t.Lnext=e,t.Org=null,t.Lface=null,t.winding=0,t.activeRegion=null,e},n.prototype.splice_=function(r,e){var t=r.Onext,o=e.Onext;t.Sym.Lnext=e,o.Sym.Lnext=r,r.Onext=o,e.Onext=t},n.prototype.makeVertex_=function(r,e,t){var o=r;pe(o,"Vertex can't be null!");var i=t.prev;o.prev=i,i.next=o,o.next=t,t.prev=o,o.anEdge=e;var s=e;do s.Org=o,s=s.Onext;while(s!==e)},n.prototype.makeFace_=function(r,e,t){var o=r;pe(o,"Face can't be null");var i=t.prev;o.prev=i,i.next=o,o.next=t,t.prev=o,o.anEdge=e,o.trail=null,o.marked=!1,o.inside=t.inside;var s=e;do s.Lface=o,s=s.Lnext;while(s!==e)},n.prototype.killEdge_=function(r){r.Sym.side<r.side&&(r=r.Sym);var e=r.next,t=r.Sym.next;e.Sym.next=t,t.Sym.next=e},n.prototype.killVertex_=function(r,e){var t=r.anEdge,o=t;do o.Org=e,o=o.Onext;while(o!==t);var i=r.prev,s=r.next;s.prev=i,i.next=s},n.prototype.killFace_=function(r,e){var t=r.anEdge,o=t;do o.Lface=e,o=o.Lnext;while(o!==t);var i=r.prev,s=r.next;s.prev=i,i.next=s},n.prototype.makeEdge=function(){var r=new $n,e=new $n,t=new es,o=this.makeEdge_(this.eHead);return this.makeVertex_(r,o,this.vHead),this.makeVertex_(e,o.Sym,this.vHead),this.makeFace_(t,o,this.fHead),o},n.prototype.splice=function(r,e){var t=!1,o=!1;if(r!==e){if(e.Org!==r.Org&&(o=!0,this.killVertex_(e.Org,r.Org)),e.Lface!==r.Lface&&(t=!0,this.killFace_(e.Lface,r.Lface)),this.splice_(e,r),!o){var i=new $n;this.makeVertex_(i,e,r.Org),r.Org.anEdge=r}if(!t){var s=new es;this.makeFace_(s,e,r.Lface),r.Lface.anEdge=r}}},n.prototype.delete=function(r){var e=r.Sym,t=!1;if(r.Lface!==r.Rface&&(t=!0,this.killFace_(r.Lface,r.Rface)),r.Onext===r)this.killVertex_(r.Org,null);else if(r.Rface.anEdge=r.Oprev,r.Org.anEdge=r.Onext,this.splice_(r,r.Oprev),!t){var o=new es;this.makeFace_(o,r,r.Lface)}e.Onext===e?(this.killVertex_(e.Org,null),this.killFace_(e.Lface,null)):(r.Lface.anEdge=e.Oprev,e.Org.anEdge=e.Onext,this.splice_(e,e.Oprev)),this.killEdge_(r)},n.prototype.addEdgeVertex=function(r){var e=this.makeEdge_(r),t=e.Sym;this.splice_(e,r.Lnext),e.Org=r.Dst;var o=new $n;return this.makeVertex_(o,t,e.Org),e.Lface=t.Lface=r.Lface,e},n.prototype.splitEdge=function(r){var e=this.addEdgeVertex(r),t=e.Sym;return this.splice_(r.Sym,r.Sym.Oprev),this.splice_(r.Sym,t),r.Dst=t.Org,t.Dst.anEdge=t.Sym,t.Rface=r.Rface,t.winding=r.winding,t.Sym.winding=r.Sym.winding,t.idx=r.idx,t.Sym.idx=r.Sym.idx,t},n.prototype.connect=function(r,e){var t=!1,o=this.makeEdge_(r),i=o.Sym;if(e.Lface!==r.Lface&&(t=!0,this.killFace_(e.Lface,r.Lface)),this.splice_(o,r.Lnext),this.splice_(i,e),o.Org=r.Dst,i.Org=e.Org,o.Lface=i.Lface=r.Lface,r.Lface.anEdge=i,!t){var s=new es;this.makeFace_(s,o,r.Lface)}return o},n.prototype.zapFace=function(r){var e=r.anEdge,t,o,i,s,l;o=e.Lnext;do t=o,o=t.Lnext,t.Lface=null,t.Rface===null&&(t.Onext===t?this.killVertex_(t.Org,null):(t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev)),i=t.Sym,i.Onext===i?this.killVertex_(i.Org,null):(i.Org.anEdge=i.Onext,this.splice_(i,i.Oprev)),this.killEdge_(t));while(t!=e);s=r.prev,l=r.next,l.prev=s,s.next=l},n.prototype.countFaceVerts_=function(r){var e=r.anEdge,t=0;do t++,e=e.Lnext;while(e!==r.anEdge);return t},n.prototype.mergeConvexFaces=function(r){var e,t,o,i,s,l,c;for(e=this.fHead.next;e!==this.fHead;e=e.next)if(!!e.inside)for(t=e.anEdge,s=t.Org;o=t.Lnext,i=t.Sym,i&&i.Lface&&i.Lface.inside&&(l=this.countFaceVerts_(e),c=this.countFaceVerts_(i.Lface),l+c-2<=r&&le.vertCCW(t.Lprev.Org,t.Org,i.Lnext.Lnext.Org)&&le.vertCCW(i.Lprev.Org,i.Org,t.Lnext.Lnext.Org)&&(o=i.Lnext,this.delete(i),t=null,i=null)),!(t&&t.Lnext.Org===s);)t=o;return!0},n.prototype.check=function(){var r=this.fHead,e=this.vHead,t=this.eHead,o,i,s,l,c,u;for(i=r,i=r;(o=i.next)!==r;i=o){pe(o.prev===i),c=o.anEdge;do pe(c.Sym!==c),pe(c.Sym.Sym===c),pe(c.Lnext.Onext.Sym===c),pe(c.Onext.Sym.Lnext===c),pe(c.Lface===o),c=c.Lnext;while(c!==o.anEdge)}for(pe(o.prev===i&&o.anEdge===null),l=e,l=e;(s=l.next)!==e;l=s){pe(s.prev===l),c=s.anEdge;do pe(c.Sym!==c),pe(c.Sym.Sym===c),pe(c.Lnext.Onext.Sym===c),pe(c.Onext.Sym.Lnext===c),pe(c.Org===s),c=c.Onext;while(c!==s.anEdge)}for(pe(s.prev===l&&s.anEdge===null),u=t,u=t;(c=u.next)!==t;u=c)pe(c.Sym.next===u.Sym),pe(c.Sym!==c),pe(c.Sym.Sym===c),pe(c.Org!==null),pe(c.Dst!==null),pe(c.Lnext.Onext.Sym===c),pe(c.Onext.Sym.Lnext===c);pe(c.Sym.next===u.Sym&&c.Sym===this.eHeadSym&&c.Sym.Sym===c&&c.Org===null&&c.Dst===null&&c.Lface===null&&c.Rface===null)},n}(),Bm=function(){function n(){this.handle=null}return n}(),Dm=function(){function n(){this.key=null,this.node=0}return n}(),Aw=function(){function n(r,e){this.leq=e,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=r,this.nodes=[],this.handles=[];for(var t=0;t<r+1;t++)this.nodes[t]=new Bm,this.handles[t]=new Dm;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return n.prototype.floatDown_=function(r){var e=this.nodes,t=this.handles,o,i,s;for(o=e[r].handle;;){if(s=r<<1,s<this.size&&this.leq(t[e[s+1].handle].key,t[e[s].handle].key)&&++s,pe(s<=this.max),i=e[s].handle,s>this.size||this.leq(t[o].key,t[i].key)){e[r].handle=o,t[o].node=r;break}e[r].handle=i,t[i].node=r,r=s}},n.prototype.floatUp_=function(r){var e=this.nodes,t=this.handles,o,i,s;for(o=e[r].handle;;){if(s=r>>1,i=e[s].handle,s===0||this.leq(t[i].key,t[o].key)){e[r].handle=o,t[o].node=r;break}e[r].handle=i,t[i].node=r,r=s}},n.prototype.init=function(){for(var r=this.size;r>=1;--r)this.floatDown_(r);this.initialized=!0},n.prototype.min=function(){return this.handles[this.nodes[1].handle].key},n.prototype.insert=function(r){var e,t;if(e=++this.size,e*2>this.max){this.max*=2;var o,i;for(i=this.nodes.length,this.nodes.length=this.max+1,o=i;o<this.nodes.length;o++)this.nodes[o]=new Bm;for(i=this.handles.length,this.handles.length=this.max+1,o=i;o<this.handles.length;o++)this.handles[o]=new Dm}return this.freeList===0?t=e:(t=this.freeList,this.freeList=this.handles[t].node),this.nodes[e].handle=t,this.handles[t].node=e,this.handles[t].key=r,this.initialized&&this.floatUp_(e),t},n.prototype.extractMin=function(){var r=this.nodes,e=this.handles,t=r[1].handle,o=e[t].key;return this.size>0&&(r[1].handle=r[this.size].handle,e[r[1].handle].node=1,e[t].key=null,e[t].node=this.freeList,this.freeList=t,--this.size,this.size>0&&this.floatDown_(1)),o},n.prototype.delete=function(r){var e=this.nodes,t=this.handles,o;pe(r>=1&&r<=this.max&&t[r].key!==null),o=t[r].node,e[o].handle=e[this.size].handle,t[e[o].handle].node=o,--this.size,o<=this.size&&(o<=1||this.leq(t[e[o>>1].handle].key,t[e[o].handle].key)?this.floatDown_(o):this.floatUp_(o)),t[r].key=null,t[r].node=this.freeList,this.freeList=r},n}(),Lc=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}(),Gm=function(){function n(){this.key=null,this.next=null,this.prev=null}return n}(),Pw=function(){function n(r,e){this.frame=r,this.leq=e,this.head=new Gm,this.head.next=this.head,this.head.prev=this.head}return n.prototype.min=function(){return this.head.next},n.prototype.max=function(){return this.head.prev},n.prototype.insert=function(r){return this.insertBefore(this.head,r)},n.prototype.search=function(r){var e=this.head;do e=e.next;while(e.key!==null&&!this.leq(this.frame,r,e.key));return e},n.prototype.insertBefore=function(r,e){do r=r.prev;while(r.key!==null&&!this.leq(this.frame,r.key,e));var t=new Gm;return t.key=e,t.next=r.next,r.next.prev=t,t.prev=r,r.next=t,t},n.prototype.delete=function(r){r.next.prev=r.prev,r.prev.next=r.next},n}(),Iw=function(){function n(){}return n.regionBelow=function(r){return r.nodeUp.prev.key},n.regionAbove=function(r){return r.nodeUp.next.key},n.debugEvent=function(r){},n.addWinding=function(r,e){r.winding+=e.winding,r.Sym.winding+=e.Sym.winding},n.edgeLeq=function(r,e,t){var o=r.event,i=e.eUp,s=t.eUp;if(i.Dst===o)return s.Dst===o?le.vertLeq(i.Org,s.Org)?le.edgeSign(s.Dst,i.Org,s.Org)<=0:le.edgeSign(i.Dst,s.Org,i.Org)>=0:le.edgeSign(s.Dst,o,s.Org)<=0;if(s.Dst===o)return le.edgeSign(i.Dst,o,i.Org)>=0;var l=le.edgeEval(i.Dst,o,i.Org),c=le.edgeEval(s.Dst,o,s.Org);return l>=c},n.deleteRegion=function(r,e){e.fixUpperEdge&&pe(e.eUp.winding===0),e.eUp.activeRegion=null,r.dict.delete(e.nodeUp)},n.fixUpperEdge=function(r,e,t){pe(e.fixUpperEdge),r.mesh.delete(e.eUp),e.fixUpperEdge=!1,e.eUp=t,t.activeRegion=e},n.topLeftRegion=function(r,e){var t=e.eUp.Org,o;do e=n.regionAbove(e);while(e.eUp.Org===t);if(e.fixUpperEdge){if(o=r.mesh.connect(n.regionBelow(e).eUp.Sym,e.eUp.Lnext),o===null)return null;n.fixUpperEdge(r,e,o),e=n.regionAbove(e)}return e},n.topRightRegion=function(r){var e=r.eUp.Dst;do r=n.regionAbove(r);while(r.eUp.Dst===e);return r},n.addRegionBelow=function(r,e,t){var o=new Lc;return o.eUp=t,o.nodeUp=r.dict.insertBefore(e.nodeUp,o),o.fixUpperEdge=!1,o.sentinel=!1,o.dirty=!1,t.activeRegion=o,o},n.isWindingInside=function(r,e){switch(r.windingRule){case Be.ODD:return(e&1)!==0;case Be.NONZERO:return e!==0;case Be.POSITIVE:return e>0;case Be.NEGATIVE:return e<0;case Be.ABS_GEQ_TWO:return e>=2||e<=-2}throw new Error("Invalid winding rulle")},n.computeWinding=function(r,e){e.windingNumber=n.regionAbove(e).windingNumber+e.eUp.winding,e.inside=n.isWindingInside(r,e.windingNumber)},n.finishRegion=function(r,e){var t=e.eUp,o=t.Lface;o.inside=e.inside,o.anEdge=t,n.deleteRegion(r,e)},n.finishLeftRegions=function(r,e,t){for(var o,i=null,s=e,l=e.eUp;s!==t;){if(s.fixUpperEdge=!1,i=n.regionBelow(s),o=i.eUp,o.Org!=l.Org){if(!i.fixUpperEdge){n.finishRegion(r,s);break}o=r.mesh.connect(l.Lprev,o.Sym),n.fixUpperEdge(r,i,o)}l.Onext!==o&&(r.mesh.splice(o.Oprev,o),r.mesh.splice(l,o)),n.finishRegion(r,s),l=i.eUp,s=i}return l},n.addRightEdges=function(r,e,t,o,i,s){var l,c,u,a,d=!0;u=t;do pe(le.vertLeq(u.Org,u.Dst)),n.addRegionBelow(r,e,u.Sym),u=u.Onext;while(u!==o);for(i===null&&(i=n.regionBelow(e).eUp.Rprev),c=e,a=i;l=n.regionBelow(c),u=l.eUp.Sym,u.Org===a.Org;)u.Onext!==a&&(r.mesh.splice(u.Oprev,u),r.mesh.splice(a.Oprev,u)),l.windingNumber=c.windingNumber-u.winding,l.inside=n.isWindingInside(r,l.windingNumber),c.dirty=!0,!d&&n.checkForRightSplice(r,c)&&(n.addWinding(u,a),n.deleteRegion(r,c),r.mesh.delete(a)),d=!1,c=l,a=u;c.dirty=!0,pe(c.windingNumber-u.winding===l.windingNumber),s&&n.walkDirtyRegions(r,c)},n.spliceMergeVertices=function(r,e,t){r.mesh.splice(e,t)},n.vertexWeights=function(r,e,t){var o=le.vertL1dist(e,r),i=le.vertL1dist(t,r),s=.5*i/(o+i),l=.5*o/(o+i);r.coords[0]+=s*e.coords[0]+l*t.coords[0],r.coords[1]+=s*e.coords[1]+l*t.coords[1],r.coords[2]+=s*e.coords[2]+l*t.coords[2]},n.getIntersectData=function(r,e,t,o,i,s){e.coords[0]=e.coords[1]=e.coords[2]=0,e.idx=-1,n.vertexWeights(e,t,o),n.vertexWeights(e,i,s)},n.checkForRightSplice=function(r,e){var t=n.regionBelow(e),o=e.eUp,i=t.eUp;if(le.vertLeq(o.Org,i.Org)){if(le.edgeSign(i.Dst,o.Org,i.Org)>0)return!1;le.vertEq(o.Org,i.Org)?o.Org!==i.Org&&(r.pq.delete(o.Org.pqHandle),n.spliceMergeVertices(r,i.Oprev,o)):(r.mesh.splitEdge(i.Sym),r.mesh.splice(o,i.Oprev),e.dirty=t.dirty=!0)}else{if(le.edgeSign(o.Dst,i.Org,o.Org)<0)return!1;n.regionAbove(e).dirty=e.dirty=!0,r.mesh.splitEdge(o.Sym),r.mesh.splice(i.Oprev,o)}return!0},n.checkForLeftSplice=function(r,e){var t=n.regionBelow(e),o=e.eUp,i=t.eUp,s;if(pe(!le.vertEq(o.Dst,i.Dst)),le.vertLeq(o.Dst,i.Dst)){if(le.edgeSign(o.Dst,i.Dst,o.Org)<0)return!1;n.regionAbove(e).dirty=e.dirty=!0,s=r.mesh.splitEdge(o),r.mesh.splice(i.Sym,s),s.Lface.inside=e.inside}else{if(le.edgeSign(i.Dst,o.Dst,i.Org)>0)return!1;e.dirty=t.dirty=!0,s=r.mesh.splitEdge(i),r.mesh.splice(o.Lnext,i.Sym),s.Rface.inside=e.inside}return!0},n.checkForIntersect=function(r,e){var t=n.regionBelow(e),o=e.eUp,i=t.eUp,s=o.Org,l=i.Org,c=o.Dst,u=i.Dst,a,d,p=new $n,f,m;if(pe(!le.vertEq(u,c)),pe(le.edgeSign(c,r.event,s)<=0),pe(le.edgeSign(u,r.event,l)>=0),pe(s!==r.event&&l!==r.event),pe(!e.fixUpperEdge&&!t.fixUpperEdge),s===l||(a=Math.min(s.t,c.t),d=Math.max(l.t,u.t),a>d))return!1;if(le.vertLeq(s,l)){if(le.edgeSign(u,s,l)>0)return!1}else if(le.edgeSign(c,l,s)<0)return!1;return n.debugEvent(r),le.intersect(c,s,u,l,p),pe(Math.min(s.t,c.t)<=p.t),pe(p.t<=Math.max(l.t,u.t)),pe(Math.min(u.s,c.s)<=p.s),pe(p.s<=Math.max(l.s,s.s)),le.vertLeq(p,r.event)&&(p.s=r.event.s,p.t=r.event.t),f=le.vertLeq(s,l)?s:l,le.vertLeq(f,p)&&(p.s=f.s,p.t=f.t),le.vertEq(p,s)||le.vertEq(p,l)?(n.checkForRightSplice(r,e),!1):!le.vertEq(c,r.event)&&le.edgeSign(c,r.event,p)>=0||!le.vertEq(u,r.event)&&le.edgeSign(u,r.event,p)<=0?u===r.event?(r.mesh.splitEdge(o.Sym),r.mesh.splice(i.Sym,o),e=n.topLeftRegion(r,e),o=n.regionBelow(e).eUp,n.finishLeftRegions(r,n.regionBelow(e),t),n.addRightEdges(r,e,o.Oprev,o,o,!0),!0):c===r.event?(r.mesh.splitEdge(i.Sym),r.mesh.splice(o.Lnext,i.Oprev),t=e,e=n.topRightRegion(e),m=n.regionBelow(e).eUp.Rprev,t.eUp=i.Oprev,i=n.finishLeftRegions(r,t,null),n.addRightEdges(r,e,i.Onext,o.Rprev,m,!0),!0):(le.edgeSign(c,r.event,p)>=0&&(n.regionAbove(e).dirty=e.dirty=!0,r.mesh.splitEdge(o.Sym),o.Org.s=r.event.s,o.Org.t=r.event.t),le.edgeSign(u,r.event,p)<=0&&(e.dirty=t.dirty=!0,r.mesh.splitEdge(i.Sym),i.Org.s=r.event.s,i.Org.t=r.event.t),!1):(r.mesh.splitEdge(o.Sym),r.mesh.splitEdge(i.Sym),r.mesh.splice(i.Oprev,o),o.Org.s=p.s,o.Org.t=p.t,o.Org.pqHandle=r.pq.insert(o.Org),n.getIntersectData(r,o.Org,s,c,l,u),n.regionAbove(e).dirty=e.dirty=t.dirty=!0,!1)},n.walkDirtyRegions=function(r,e){for(var t=n.regionBelow(e),o,i;;){for(;t.dirty;)e=t,t=n.regionBelow(t);if(!e.dirty&&(t=e,e=n.regionAbove(e),e===null||!e.dirty))return;if(e.dirty=!1,o=e.eUp,i=t.eUp,o.Dst!==i.Dst&&n.checkForLeftSplice(r,e)&&(t.fixUpperEdge?(n.deleteRegion(r,t),r.mesh.delete(i),t=n.regionBelow(e),i=t.eUp):e.fixUpperEdge&&(n.deleteRegion(r,e),r.mesh.delete(o),e=n.regionAbove(t),o=e.eUp)),o.Org!==i.Org)if(o.Dst!==i.Dst&&!e.fixUpperEdge&&!t.fixUpperEdge&&(o.Dst===r.event||i.Dst===r.event)){if(n.checkForIntersect(r,e))return}else n.checkForRightSplice(r,e);o.Org===i.Org&&o.Dst===i.Dst&&(n.addWinding(i,o),n.deleteRegion(r,e),r.mesh.delete(o),e=n.regionAbove(t))}},n.connectRightVertex=function(r,e,t){var o,i=t.Onext,s=n.regionBelow(e),l=e.eUp,c=s.eUp,u=!1;if(l.Dst!==c.Dst&&n.checkForIntersect(r,e),le.vertEq(l.Org,r.event)&&(r.mesh.splice(i.Oprev,l),e=n.topLeftRegion(r,e),i=n.regionBelow(e).eUp,n.finishLeftRegions(r,n.regionBelow(e),s),u=!0),le.vertEq(c.Org,r.event)&&(r.mesh.splice(t,c.Oprev),t=n.finishLeftRegions(r,s,null),u=!0),u){n.addRightEdges(r,e,t.Onext,i,i,!0);return}le.vertLeq(c.Org,l.Org)?o=c.Oprev:o=l,o=r.mesh.connect(t.Lprev,o),n.addRightEdges(r,e,o,o.Onext,o.Onext,!1),o.Sym.activeRegion.fixUpperEdge=!0,n.walkDirtyRegions(r,e)},n.connectLeftDegenerate=function(r,e,t){var o,i,s,l,c;if(o=e.eUp,le.vertEq(o.Org,t)){pe(!1),n.spliceMergeVertices(r,o,t.anEdge);return}if(!le.vertEq(o.Dst,t)){r.mesh.splitEdge(o.Sym),e.fixUpperEdge&&(r.mesh.delete(o.Onext),e.fixUpperEdge=!1),r.mesh.splice(t.anEdge,o),n.sweepEvent(r,t);return}pe(!1),e=n.topRightRegion(e),c=n.regionBelow(e),s=c.eUp.Sym,i=l=s.Onext,c.fixUpperEdge&&(pe(i!==s),n.deleteRegion(r,c),r.mesh.delete(s),s=i.Oprev),r.mesh.splice(t.anEdge,s),le.edgeGoesLeft(i)||(i=null),n.addRightEdges(r,e,s.Onext,l,i,!0)},n.connectLeftVertex=function(r,e){var t,o,i,s,l,c,u=new Lc;if(u.eUp=e.anEdge.Sym,t=r.dict.search(u).key,o=n.regionBelow(t),!!o){if(s=t.eUp,l=o.eUp,le.edgeSign(s.Dst,e,s.Org)===0){n.connectLeftDegenerate(r,t,e);return}if(i=le.vertLeq(l.Dst,s.Dst)?t:o,t.inside||i.fixUpperEdge){if(i===t)c=r.mesh.connect(e.anEdge.Sym,s.Lnext);else{var a=r.mesh.connect(l.Dnext,e.anEdge);c=a.Sym}i.fixUpperEdge?n.fixUpperEdge(r,i,c):n.computeWinding(r,n.addRegionBelow(r,t,c)),n.sweepEvent(r,e)}else n.addRightEdges(r,t,e.anEdge,e.anEdge,null,!0)}},n.sweepEvent=function(r,e){r.event=e,n.debugEvent(r);for(var t=e.anEdge;t.activeRegion===null;)if(t=t.Onext,t===e.anEdge){n.connectLeftVertex(r,e);return}var o=n.topLeftRegion(r,t.activeRegion);pe(o!==null);var i=n.regionBelow(o),s=i.eUp,l=n.finishLeftRegions(r,i,null);l.Onext===s?n.connectRightVertex(r,o,l):n.addRightEdges(r,o,l.Onext,s,s,!0)},n.addSentinel=function(r,e,t,o){var i=new Lc,s=r.mesh.makeEdge();s.Org.s=t,s.Org.t=o,s.Dst.s=e,s.Dst.t=o,r.event=s.Dst,i.eUp=s,i.windingNumber=0,i.inside=!1,i.fixUpperEdge=!1,i.sentinel=!0,i.dirty=!1,i.nodeUp=r.dict.insert(i)},n.initEdgeDict=function(r){r.dict=new Pw(r,n.edgeLeq);var e=r.bmax[0]-r.bmin[0],t=r.bmax[1]-r.bmin[1],o=r.bmin[0]-e,i=r.bmax[0]+e,s=r.bmin[1]-t,l=r.bmax[1]+t;n.addSentinel(r,o,i,s),n.addSentinel(r,o,i,l)},n.doneEdgeDict=function(r){for(var e,t=0;(e=r.dict.min().key)!==null;)e.sentinel||(pe(e.fixUpperEdge),pe(++t===1)),pe(e.windingNumber===0),n.deleteRegion(r,e)},n.removeDegenerateEdges=function(r){var e,t,o,i=r.mesh.eHead;for(e=i.next;e!==i;e=t)t=e.next,o=e.Lnext,le.vertEq(e.Org,e.Dst)&&e.Lnext.Lnext!==e&&(n.spliceMergeVertices(r,o,e),r.mesh.delete(e),e=o,o=e.Lnext),o.Lnext===e&&(o!==e&&((o===t||o===t.Sym)&&(t=t.next),r.mesh.delete(o)),(e===t||e===t.Sym)&&(t=t.next),r.mesh.delete(e))},n.initPriorityQ=function(r){var e,t,o,i=0;for(o=r.mesh.vHead,t=o.next;t!==o;t=t.next)i++;for(i+=8,e=r.pq=new Aw(i,le.vertLeq),o=r.mesh.vHead,t=o.next;t!==o;t=t.next)t.pqHandle=e.insert(t);return t!==o?!1:(e.init(),!0)},n.donePriorityQ=function(r){r.pq=null},n.removeDegenerateFaces=function(r,e){var t,o,i;for(t=e.fHead.next;t!==e.fHead;t=o)o=t.next,i=t.anEdge,pe(i.Lnext!==i),i.Lnext.Lnext===i&&(n.addWinding(i.Onext,i),r.mesh.delete(i));return!0},n.computeInterior=function(r,e){e===void 0&&(e=!0);var t,o;if(n.removeDegenerateEdges(r),!n.initPriorityQ(r))return!1;for(n.initEdgeDict(r);(t=r.pq.extractMin())!==null;){for(;o=r.pq.min(),!(o===null||!le.vertEq(o,t));)o=r.pq.extractMin(),n.spliceMergeVertices(r,t.anEdge,o.anEdge);n.sweepEvent(r,t)}return r.event=r.dict.min().key.eUp.Org,n.debugEvent(r),n.doneEdgeDict(r),n.donePriorityQ(r),n.removeDegenerateFaces(r,r.mesh)?(e&&r.mesh.check(),!0):!1},n}(),Cw=function(){function n(){this.mesh=new Mm,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=Be.ODD,this.dict=null,this.pq=null,this.event=null,this.vertexIndexCounter=0,this.vertices=[],this.vertexIndices=[],this.vertexCount=0,this.elements=[],this.elementCount=0}return n.prototype.dot_=function(r,e){return r[0]*e[0]+r[1]*e[1]+r[2]*e[2]},n.prototype.normalize_=function(r){var e=r[0]*r[0]+r[1]*r[1]+r[2]*r[2];if(!e)throw"Zero-size vector!";e=Math.sqrt(e),r[0]/=e,r[1]/=e,r[2]/=e},n.prototype.longAxis_=function(r){var e=0;return Math.abs(r[1])>Math.abs(r[0])&&(e=1),Math.abs(r[2])>Math.abs(r[e])&&(e=2),e},n.prototype.computeNormal_=function(r){var e,t,o,i,s,l,c=[0,0,0],u=[0,0,0],a=[0,0,0],d=[0,0,0],p=[0,0,0],f=[null,null,null],m=[null,null,null],h=this.mesh.vHead;e=h.next;for(var y=0;y<3;++y)i=e.coords[y],u[y]=i,m[y]=e,c[y]=i,f[y]=e;for(e=h.next;e!==h;e=e.next)for(var g=0;g<3;++g)i=e.coords[g],i<u[g]&&(u[g]=i,m[g]=e),i>c[g]&&(c[g]=i,f[g]=e);var v=0;if(c[1]-u[1]>c[0]-u[0]&&(v=1),c[2]-u[2]>c[v]-u[v]&&(v=2),u[v]>=c[v]){r[0]=0,r[1]=0,r[2]=1;return}for(l=0,t=m[v],o=f[v],a[0]=t.coords[0]-o.coords[0],a[1]=t.coords[1]-o.coords[1],a[2]=t.coords[2]-o.coords[2],e=h.next;e!==h;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]=a[1]*d[2]-a[2]*d[1],p[1]=a[2]*d[0]-a[0]*d[2],p[2]=a[0]*d[1]-a[1]*d[0],s=p[0]*p[0]+p[1]*p[1]+p[2]*p[2],s>l&&(l=s,r[0]=p[0],r[1]=p[1],r[2]=p[2]);l<=0&&(r[0]=r[1]=r[2]=0,r[this.longAxis_(a)]=1)},n.prototype.checkOrientation_=function(){for(var r=this.mesh.fHead,e,t=this.mesh.vHead,o,i=0,s=r.next;s!==r;s=s.next)if(o=s.anEdge,!(o.winding<=0))do i+=(o.Org.s-o.Dst.s)*(o.Org.t+o.Dst.t),o=o.Lnext;while(o!==s.anEdge);if(i<0){for(e=t.next;e!==t;e=e.next)e.t=-e.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},n.prototype.projectPolygon_=function(){var r=this.mesh.vHead,e=[0,0,0],t,o,i=!1;e[0]=this.normal[0],e[1]=this.normal[1],e[2]=this.normal[2],!e[0]&&!e[1]&&!e[2]&&(this.computeNormal_(e),i=!0),t=this.sUnit,o=this.tUnit;var s=this.longAxis_(e);t[s]=0,t[(s+1)%3]=1,t[(s+2)%3]=0,o[s]=0,o[(s+1)%3]=0,o[(s+2)%3]=e[s]>0?1:-1;for(var l=r.next;l!==r;l=l.next)l.s=this.dot_(l.coords,t),l.t=this.dot_(l.coords,o);i&&this.checkOrientation_();for(var c=!0,u=r.next;u!==r;u=u.next)c?(this.bmin[0]=this.bmax[0]=u.s,this.bmin[1]=this.bmax[1]=u.t,c=!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(r,e){r.winding+=e.winding,r.Sym.winding+=e.Sym.winding},n.prototype.tessellateMonoRegion_=function(r,e){var t,o;if(t=e.anEdge,!(t.Lnext!==t&&t.Lnext.Lnext!==t))throw"Mono region invalid";for(;le.vertLeq(t.Dst,t.Org);t=t.Lprev);for(;le.vertLeq(t.Org,t.Dst);t=t.Lnext);o=t.Lprev;for(var i=void 0;t.Lnext!==o;)if(le.vertLeq(t.Dst,o.Org)){for(;o.Lnext!==t&&(le.edgeGoesLeft(o.Lnext)||le.edgeSign(o.Org,o.Dst,o.Lnext.Dst)<=0);)i=r.connect(o.Lnext,o),o=i.Sym;o=o.Lprev}else{for(;o.Lnext!==t&&(le.edgeGoesRight(t.Lprev)||le.edgeSign(t.Dst,t.Org,t.Lprev.Org)>=0);)i=r.connect(t,t.Lprev),t=i.Sym;t=t.Lnext}if(o.Lnext===t)throw"Mono region invalid";for(;o.Lnext.Lnext!==t;)i=r.connect(o.Lnext,o),o=i.Sym;return!0},n.prototype.tessellateInterior_=function(r){for(var e,t=r.fHead.next;t!==r.fHead;t=e)if(e=t.next,t.inside&&!this.tessellateMonoRegion_(r,t))return!1;return!0},n.prototype.discardExterior_=function(r){for(var e,t=r.fHead.next;t!==r.fHead;t=e)e=t.next,t.inside||r.zapFace(t)},n.prototype.setWindingNumber_=function(r,e,t){for(var o,i=r.eHead.next;i!==r.eHead;i=o)o=i.next,i.Rface.inside!==i.Lface.inside?i.winding=i.Lface.inside?e:-e:t?r.delete(i):i.winding=0},n.prototype.getNeighbourFace_=function(r){return!r.Rface||!r.Rface.inside?-1:r.Rface.n},n.prototype.outputPolymesh_=function(r,e,t,o){var i,s=0,l=0,c;t>3&&r.mergeConvexFaces(t);for(var u=r.vHead.next;u!==r.vHead;u=u.next)u.n=-1;for(var a=r.fHead.next;a!==r.fHead;a=a.next)if(a.n=-1,!!a.inside){i=a.anEdge,c=0;do{var u=i.Org;u.n===-1&&(u.n=l,l++),c++,i=i.Lnext}while(i!==a.anEdge);if(c>t)throw"Face vertex greater that support polygon";a.n=s,++s}this.elementCount=s,e===rt.CONNECTED_POLYGONS&&(s*=2),this.elements=[],this.elements.length=s*t,this.vertexCount=l,this.vertices=[],this.vertices.length=l*o,this.vertexIndices=[],this.vertexIndices.length=l;for(var u=r.vHead.next;u!==r.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,a=r.fHead.next;a!==r.fHead;a=a.next)if(!!a.inside){i=a.anEdge,c=0;do{var u=i.Org;this.elements[p++]=u.n,c++,i=i.Lnext}while(i!==a.anEdge);for(var f=c;f<t;++f)this.elements[p++]=-1;if(e===rt.CONNECTED_POLYGONS){i=a.anEdge;do this.elements[p++]=this.getNeighbourFace_(i),i=i.Lnext;while(i!==a.anEdge);for(var m=c;m<t;++m)this.elements[p++]=-1}}},n.prototype.outputContours_=function(r,e){var t,o,i=0,s=0;this.vertexCount=0,this.elementCount=0;for(var l=r.fHead.next;l!==r.fHead;l=l.next)if(!!l.inside){o=t=l.anEdge;do this.vertexCount++,t=t.Lnext;while(t!==o);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*e,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var c=0,u=0,a=0;i=0;for(var l=r.fHead.next;l!==r.fHead;l=l.next)if(!!l.inside){s=0,o=t=l.anEdge;do this.vertices[c++]=t.Org.coords[0],this.vertices[c++]=t.Org.coords[1],e>2&&(this.vertices[c++]=t.Org.coords[2]),this.vertexIndices[u++]=this.vertexIdCallback?this.vertexIdCallback(t):t.Org.idx,s++,t=t.Lnext;while(t!==o);this.elements[a++]=i,this.elements[a++]=s,i+=s}},n.prototype.addContour=function(r,e){this.mesh===null&&(this.mesh=new Mm),r<2&&(r=2),r>3&&(r=3);for(var t=null,o=0;o<e.length;o+=r)t===null?(t=this.mesh.makeEdge(),this.mesh.splice(t,t.Sym)):(this.mesh.splitEdge(t),t=t.Lnext),t.Org.coords[0]=e[o+0],t.Org.coords[1]=e[o+1],r>2?t.Org.coords[2]=e[o+2]:t.Org.coords[2]=0,t.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(t),t.winding=1,t.Sym.winding=-1},n.prototype.tesselate=function(r,e,t,o,i,s){if(r===void 0&&(r=Be.ODD),e===void 0&&(e=rt.POLYGONS),s===void 0&&(s=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,i&&(this.normal[0]=i[0],this.normal[1]=i[1],this.normal[2]=i[2]),this.windingRule=r,o<2&&(o=2),o>3&&(o=3),!this.mesh)return!1;this.projectPolygon_(),Iw.computeInterior(this,s);var l=this.mesh;return e===rt.BOUNDARY_CONTOURS?this.setWindingNumber_(l,1,!0):this.tessellateInterior_(l),s&&l.check(),e===rt.BOUNDARY_CONTOURS?this.outputContours_(l,o):this.outputPolymesh_(l,e,t,o),!0},n}();function Fo(n){var r=n.windingRule,e=r===void 0?Be.ODD:r,t=n.elementType,o=t===void 0?rt.POLYGONS:t,i=n.polySize,s=i===void 0?3:i,l=n.vertexSize,c=l===void 0?2:l,u=n.normal,a=u===void 0?[0,0,1]:u,d=n.contours,p=d===void 0?[]:d,f=n.strict,m=f===void 0?!0:f,h=n.debug,y=h===void 0?!1:h;if(!p&&m)throw new Error("Contours can't be empty");if(!!p){var g=new Cw;n.edgeCreateCallback&&(g.edgeCreateCallback=n.edgeCreateCallback),n.vertexIdCallback&&(g.vertexIdCallback=n.vertexIdCallback);for(var v=0;v<p.length;v++)g.addContour(c||2,p[v]);return g.tesselate(e,o,s,c,a,m),{vertices:g.vertices,vertexIndices:g.vertexIndices,vertexCount:g.vertexCount,elements:g.elements,elementCount:g.elementCount,mesh:y?g.mesh:void 0}}}var OB=Be.ODD,AB=Be.NONZERO,PB=Be.POSITIVE,IB=Be.NEGATIVE,CB=Be.ABS_GEQ_TWO,NB=rt.POLYGONS,EB=rt.CONNECTED_POLYGONS,LB=rt.BOUNDARY_CONTOURS;var Yn=class extends Uo.BufferGeometry{constructor(e,t=12,o={}){super();this.type="ShapeGeometry";this.windingRule=Be.ODD;this.elementType=rt.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=e,this._curveSegments=t,this._triangulationOptions=Object.assign({windingRule:Be.ODD,elementType:rt.POLYGONS,polySize:3,vertexSize:2,strict:!0},o);let i=this._shape.extractShapePointsToFlatArray([],this._curveSegments),s=this._shape.shapeHoles.map(m=>m.extractShapePointsToFlatArray([],this._curveSegments)),l,c=!0,u=!0,a,d;for(let m=0,h=i.length/2;m<h;m++){let y=m*2,g=i[y+0],v=i[y+1];if(a!==void 0&&g!==a&&(c=!1),d!==void 0&&v!==d&&(u=!1),a=g,d=v,!c&&!u)break}!c&&!u&&(l=Fo({contours:[i,...s],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict}));let p=l?.vertexCount??1,f=l?.elementCount??1;if(this._positionAttribute=new Uo.BufferAttribute(new Float32Array(p*3),3),this._normalAttribute=new Uo.BufferAttribute(new Float32Array(p*3),3),this._uvAttribute=new Uo.BufferAttribute(new Float32Array(p*2),2),this._indexAttribute=new Uo.BufferAttribute(new Uint32Array(f*3),1),l){let m=1/0,h=-1/0,y=1/0,g=-1/0;for(let b=0,S=p;b<S;b++){let A=b*2,_=l.vertices[A+0],x=l.vertices[A+1];_<m&&(m=_),_>h&&(h=_),x<y&&(y=x),x>g&&(g=x)}let v=h-m,w=g-y;for(let b=0,S=p;b<S;b++){let A=b*2,_=l.vertices[A+0],x=l.vertices[A+1],P=(_-m)/v,O=(x-y)/w;this._positionAttribute.setXYZ(b,_,x,0),this._normalAttribute.setXYZ(b,0,0,1),this._uvAttribute.setXY(b,P,O)}for(let b=0,S=f;b<S;b++){let A=b*3,_=l.elements[A+0],x=l.elements[A+1],P=l.elements[A+2];this._indexAttribute.setX(A+0,_),this._indexAttribute.setX(A+1,x),this._indexAttribute.setX(A+2,P)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,(l?.elementCount??1)*3)}clone(){let e=new Yn(this._shape,this._curveSegments);return e.userData=Ro(this.userData),e}};var zo=require("three");var Qa=class{constructor(r=256,e=!1){this.capacity=r,this.size=0,this.debug=e,this.debug&&console.log(`allocating with cap ${r}`);let t=r*Qa.eSize;this.buffer=new ArrayBuffer(t);let o=Float32Array.BYTES_PER_ELEMENT,i=0;this.positions=new Float32Array(this.buffer,i*o,3*r),i+=3*r,this.normals=new Float32Array(this.buffer,i*o,3*r),i+=3*r,this.uvs=new Float32Array(this.buffer,i*o,2*r)}realloc(r,e=!1){if(r<this.size)throw Error("cannot shrink buffer");if(r<=this.capacity&&!e)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${r}`);let t=r*Qa.eSize,o=new ArrayBuffer(t),i=Float32Array.BYTES_PER_ELEMENT,s=0,l=new Float32Array(o,s*i,3*r);s+=3*r;let c=new Float32Array(o,s*i,3*r);s+=3*r;let u=new Float32Array(o,s*i,2*r);l.set(this.positions.slice(0,this.size*3)),c.set(this.normals.slice(0,this.size*3)),u.set(this.uvs.slice(0,this.size*2)),this.buffer=o,this.positions=l,this.normals=c,this.uvs=u,this.capacity=r}get(r=1){let e=this.size+r;if(e>this.capacity){let o=this.capacity;for(;e>o;)o*=2;this.realloc(o)}let t=this.size;return this.size=e,t}reserve(r){let e=this.size+r;e>this.capacity&&this.realloc(e)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},ts=Qa;ts.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var Mc=(n,r)=>([e,t])=>(t<e&&(t+=r),(n>=e?n:n+r)<=t),Xn=class extends zo.BufferGeometry{constructor(e,t,o=0,i=12,s=3,l=Be.ODD){super();this.type="ShapeGeometry";this.vertexCache={};this._shape=e,this._depth=t,this._bevel=o,this._curveSegments=i,this._bevelSegmentsInput=s,o<=0?(this._bevelSize=0,this._bevelSegments=0):(this._bevelSize=Math.min(o,t/2-1e-12),this._bevelSegments=Math.floor(s));let c=this._shape.extractShapePointsToFlatArray([],i),u=this._shape.shapeHoles.map(x=>{let P=x.extractShapePointsToFlatArray([],i),O=[];for(let I=P.length-1;I>=1;I-=2){let T=P[I-1],N=P[I-0];O.push(T,N)}return O}),a=Fo({windingRule:l,elementType:rt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[c]}),d=Fo({windingRule:Be.ODD,elementType:rt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...u]});if(!a)throw new Error("error generating geometry");let p=a.elementCount;if(d){a.elementCount+=d.elementCount;for(let x=0;x<d.elements.length;x++){let P=d.elements[x],O=x%2===0?a.vertexCount:0;a.elements.push(P+O)}for(let x=0;x<d.vertexIndices.length;x++){let P=d.vertexIndices[x],O=a.vertexCount;a.vertexIndices.push(P+O)}for(let x=0;x<d.vertices.length;x++){let P=d.vertices[x];a.vertices.push(P)}}let f=1/0,m=-1/0,h=1/0,y=-1/0;for(let x=0,P=a.vertexCount;x<P;x++){let O=x*2,I=a.vertices[O+0],T=a.vertices[O+1];I<f&&(f=I),I>m&&(m=I),T<h&&(h=T),T>y&&(y=T)}this._minX=f,this._minY=h,this._width=m-f,this._height=y-h;let g=a.vertexCount*2*(2+this._bevelSegments);this._buffer=new ts(g);let v=[],w=[];for(let x=a.elementCount-1;x>=0;x--){let P=x>=p,O=x*2,I=a.elements[O+0],T=a.elements[O+1],N=I+T,L={start:I,count:T,normals:[],continuous:[],concave:[]},U=I,K=N-1,J=I+1,se=this._shape.roundedCurves.length;do{let j=U-I,M=a.vertices[K*2+0],B=a.vertices[K*2+1],D=a.vertices[U*2+0],F=a.vertices[U*2+1],Y=a.vertices[J*2+0],k=a.vertices[J*2+1],V=D-M,G=F-B,H=Math.sqrt(V*V+G*G);V/=H,G/=H;let $=D-Y,ee=F-k,ae=Math.sqrt($*$+ee*ee);$/=ae,ee/=ae,L.normals[j*2+0]=-ee,L.normals[j*2+1]=$,L.concave[j]=V*ee-G*$>0;let te=a.vertexIndices[U];if(Array.isArray(te))L.continuous[j]=!1;else{let[re,oe]=this._shape.getCurveIndexFromVertexId(te-1,!0);if(oe>0&&oe<1)L.continuous[j]=!0;else{let Z=oe===1?re+1:re-1;Z=(Z+se)%se;let he=oe===1?0:1,ue=this._shape.roundedCurves[re].getTangent(oe),ge=this._shape.roundedCurves[Z].getTangent(he);L.continuous[j]=ue.dot(ge)>.95}}P&&(L.normals[j*2+0]*=-1,L.normals[j*2+1]*=-1),[K,U,J]=[U,J,J+1],J>=N&&(J-=T)}while(J!==I+1);let z=[];z.push({bevelI:0,angle:0,size:0,boundary:{vertices:a.vertices.slice(I*2,N*2),vertexCount:T,vertexIndices:new Array(T).fill(!0).map((j,M)=>[M,M]),elements:[0,T],elementCount:1,mesh:null},reverseMap:[],insetPoints:a.vertices.slice(I*2,N*2)});for(let j=1;j<=this._bevelSegments;j++){let M=j/this._bevelSegments*Math.PI/2,B=(1-Math.cos(M))*this._bevelSize,D=[],F=[],Y=[],k=[],V=0;for(let H=0;H<T;H++){let $=H*2,ee=(H-1+T)%T*2,ae=a.vertices[L.start*2+$+0],te=a.vertices[L.start*2+$+1],re=-L.normals[ee+0]*B,oe=-L.normals[ee+1]*B,Z=-L.normals[$+0]*B,he=-L.normals[$+1]*B;if(L.concave[H]||!L.concave[H]&&P){let ue=Math.atan2(oe,re),ge=Math.atan2(he,Z);ge>ue&&(ge-=Math.PI*2);let vt=ge-ue;if(L.continuous[H]||P){let _e=ue+vt/2,Le=Math.cos(_e)*B,Me=Math.sin(_e)*B;D[2*V+0]=ae+Le*(P?-1:1),D[2*V+1]=te+Me*(P?-1:1),k[V]=H,V++}else{let _e=Math.max(1,Math.floor(i/4*Math.abs(vt)/Math.PI));for(let Le=0;Le<=_e;Le++){let Me=ue+vt*(Le/_e),Ct=Math.cos(Me)*B,to=Math.sin(Me)*B;D[2*V+0]=ae+Ct,D[2*V+1]=te+to,k[V]=H,V++}}}else D[2*V+0]=ae+re,D[2*V+1]=te+oe,k[V]=H,F[H]=V,V++,D[2*V+0]=ae,D[2*V+1]=te,k[V]=H,V++,D[2*V+0]=ae+Z,D[2*V+1]=te+he,k[V]=H,Y[H]=V,V++}let G=Fo({windingRule:Be.POSITIVE,elementType:rt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[D],edgeCreateCallback:H=>{let ee=H.Org.idx,ae=k[ee],te=k[(ee+1)%k.length];H.idx=[ae,te],H.Sym.idx=[te,ae]},vertexIdCallback:H=>{let $=H.Lprev.idx;return[$?$[1]:0,H.idx[0]]}});if(!G)throw console.log("Error"),new Error(`error generating bevel geometry for ${j}'th loop`);if(!G.vertexCount)break;for(let H=0;H<G.vertexIndices.length;H++){let[$,ee]=G.vertexIndices[H];if($===ee)continue;let ae=ee;ee<$&&(ae+=T);for(let te=$;te<ae;te++){let re=te%T,oe=(te+1)%T;if(!L.continuous[re]||!L.continuous[oe]){G.vertexIndices[H]=[$,re],G.vertexIndices.splice(H+1,0,[oe,ee]),G.vertices.splice((H+1)*2,0,G.vertices[H*2],G.vertices[H*2+1]);break}}}z.push({bevelI:j,angle:M,size:B,boundary:G,reverseMap:k,insetPoints:D})}let W=(j,M,B)=>{let D=0,F=j.boundary.vertexIndices.length;for(;D<F&&B(j.boundary.vertexIndices[M]);)M=(M+1)%F,D++;return D},q=v.length;for(let j=1;j<z.length;j++){let M=z[j-1],B=z[j],D=M.boundary.vertexIndices.length,F=B.boundary.vertexIndices.length;if(!D||!F)break;let Y=L.concave.length,k=0,V=Mc(k,T);for(;!M.boundary.vertexIndices.filter(V).length||!B.boundary.vertexIndices.filter(V).length;)k++,V=Mc(k,T);let G=M.boundary.vertexIndices.findIndex(V),H=B.boundary.vertexIndices.findIndex(V);do G=(G+1)%D;while(V(M.boundary.vertexIndices[G]));do H=(H+1)%F;while(V(B.boundary.vertexIndices[H]));k=(k+1)%T;let $=k,ee=this.buildBevelVert(L,M,(G-1+D)%D),ae=this.buildBevelVert(L,B,(H-1+F)%F),te=ee,re=ae,oe,Z,he=!1;do{V=Mc(k,T);let ue=W(M,G,V),ge=W(B,H,V),vt=he;if(he=!1,ue&&!ge){for(let _e=0;_e<ue;_e++)oe=this.buildBevelVert(L,M,(G+_e)%D,_e/(ue-1)),v.push(te.topN,oe.topP,re.topN),v.push(oe.bottomP,te.bottomN,re.bottomN),te=oe;he=!0}else if(!ue&&ge)for(let _e=0;_e<ge;_e++)Z=this.buildBevelVert(L,B,(H+_e)%F,_e/(ge-1)),v.push(re.topN,te.topP,Z.topP),v.push(te.bottomP,re.bottomN,Z.bottomP),re=Z;else if(ue&&ge)if(oe=this.buildBevelVert(L,M,G,0),Z=this.buildBevelVert(L,B,H,0),vt?(v.push(te.topN,Z.topP,re.topN),v.push(te.topN,oe.topP,Z.topP),v.push(Z.bottomP,te.bottomN,re.bottomN),v.push(Z.bottomP,oe.bottomP,te.bottomN)):(v.push(re.topN,te.topN,oe.topP),v.push(re.topN,oe.topP,Z.topP),v.push(oe.bottomP,te.bottomN,re.bottomN),v.push(oe.bottomP,re.bottomN,Z.bottomP)),te=oe,re=Z,ue===ge)for(let _e=1;_e<ue;_e++)oe=this.buildBevelVert(L,M,(G+_e)%D,_e/(ue-1)),Z=this.buildBevelVert(L,B,(H+_e)%F,_e/(ge-1)),v.push(te.topN,oe.topP,re.topN),v.push(re.topN,oe.topP,Z.topP),v.push(oe.bottomP,te.bottomN,re.bottomN),v.push(oe.bottomP,re.bottomN,Z.bottomP),te=oe,re=Z;else if(ue>ge){let _e=ue/ge,Le=0;for(let Me=1;Me<ue;Me++)oe=this.buildBevelVert(L,M,(G+Me)%D,Me/(ue-1)),v.push(te.topN,oe.topP,re.topN),v.push(oe.bottomP,te.bottomN,re.bottomN),te=oe,Me>(Le+1)*_e&&(Le++,Z=this.buildBevelVert(L,B,(H+Le)%F,Le/(ge-1)),v.push(re.topN,oe.topP,Z.topP),v.push(oe.bottomP,re.bottomN,Z.bottomP),re=Z)}else{let _e=ge/ue,Le=0;for(let Me=1;Me<ge;Me++)Z=this.buildBevelVert(L,B,(H+Me)%F,Me/(ge-1)),v.push(re.topN,oe.topP,Z.topP),v.push(oe.bottomP,re.bottomN,Z.bottomP),re=Z,Me>(Le+1)*_e&&(Le++,oe=this.buildBevelVert(L,M,(G+Le)%D,Le/(ue-1)),v.push(te.topN,oe.topP,re.topN),v.push(oe.bottomP,te.bottomN,re.bottomN),te=oe)}G=(G+ue)%D,H=(H+ge)%F,k=(k+1)%Y}while(k!==$)}{let j=z[0];for(let M=0,B=j.boundary.vertexCount;M<B;M++){let D=this.buildBevelVert(L,j,M),F=this.buildBevelVert(L,j,(M+1)%B);v.push(F.topP,D.topN,D.bottomN),v.push(F.topP,D.bottomN,F.bottomP)}}if(P){let j=[];for(let M=v.length-1;M>=q+2;M-=3){let B=v[M-2],D=v[M-1],F=v[M-0];j.push(F,D,B)}v.splice(q,v.length-q,...j)}if(P){let j=[];for(let M=z[z.length-1].boundary.vertices.length-1;M>=1;M-=2){let B=z[z.length-1].boundary.vertices[M-1],D=z[z.length-1].boundary.vertices[M-0];j.push(B,D)}w.push(j)}if(!P){let j=z[z.length-1],M=Fo({windingRule:z.length>1?Be.POSITIVE:Be.ODD,elementType:rt.POLYGONS,vertexSize:2,strict:!0,contours:[j.insetPoints,...w]});if(!M)throw new Error("Error generating geometry for surface");u.length===0&&Object.assign(this,{capStartIndex:v.length});for(let B=0;B<M.elementCount*3;B+=3){let D=this.buildSurfaceVert(M,M.elements[B+0]),F=this.buildSurfaceVert(M,M.elements[B+1]),Y=this.buildSurfaceVert(M,M.elements[B+2]);v.push(D.top,F.top,Y.top),v.push(Y.bottom,F.bottom,D.bottom)}}this.vertexCache={}}this._buffer.shrink();let b=new zo.BufferAttribute(Uint32Array.from(v),1),S=new zo.BufferAttribute(this._buffer.positions,3),A=new zo.BufferAttribute(this._buffer.normals,3),_=new zo.BufferAttribute(this._buffer.uvs,2);S.needsUpdate=!0,A.needsUpdate=!0,_.needsUpdate=!0,b.needsUpdate=!0,this.setAttribute("position",S),this.setAttribute("normal",A),this.setAttribute("uv",_),this.setIndex(b)}buildSurfaceVert(e,t){let o=t.toString();if(o in this.vertexCache)return this.vertexCache[o];let i=e.vertices[t*2+0],s=e.vertices[t*2+1],l=(i-this._minX)/this._width,c=(s-this._minY)/this._height,u=this._buffer.get(2),a=u*3,d=u*2,p={top:u+0,bottom:u+1};return this._buffer.positions[a+0]=i,this._buffer.positions[a+1]=s,this._buffer.positions[a+2]=this._depth,this._buffer.normals[a+0]=0,this._buffer.normals[a+1]=0,this._buffer.normals[a+2]=1,this._buffer.uvs[d+0]=l,this._buffer.uvs[d+1]=c,this._buffer.positions[a+3]=i,this._buffer.positions[a+4]=s,this._buffer.positions[a+5]=0,this._buffer.normals[a+3]=0,this._buffer.normals[a+4]=0,this._buffer.normals[a+5]=-1,this._buffer.uvs[d+2]=l,this._buffer.uvs[d+3]=c,this.vertexCache[o]=p,p}buildBevelVert(e,t,o,i=1){let s=`${t.bevelI}:${o}`;if(s in this.vertexCache)return this.vertexCache[s];let[l,c]=t.boundary.vertexIndices[o],u,a,d,p;l!==c?(a=l,u=c,p=!1,d=e.continuous[a]&&e.continuous[u]):(u=l,a=(u-1+e.count)%e.count,p=e.concave[u]&&t.bevelI>0,d=e.continuous[u]||p);let f=Math.cos(t.angle),m=Math.sin(t.angle),h=o*2,y=u*2,g=a*2,v=t.boundary.vertices[h+0],w=t.boundary.vertices[h+1],b=(1-m)*this._bevelSize,S=(v-this._minX)/this._width,A=(w-this._minY)/this._height,_=e.normals[y+0],x=e.normals[y+1],P=e.normals[g+0],O=e.normals[g+1];if(p){let U=P-_,K=O-x;_=_+U*(1-i),x=x+K*(1-i);let J=Math.sqrt(_*_+x*x);_/=J,x/=J}let I=this._buffer.get(d?2:4),T=I*3,N=I*2,L={i:o,fi:u,topP:I+0,topN:I+0,bottomP:I+1,bottomN:I+1};return this._buffer.positions[T+0]=v,this._buffer.positions[T+1]=w,this._buffer.positions[T+2]=this._depth-b,this._buffer.normals[T+0]=_*f,this._buffer.normals[T+1]=x*f,this._buffer.normals[T+2]=m,this._buffer.uvs[N+0]=S,this._buffer.uvs[N+1]=A,this._buffer.positions[T+3]=v,this._buffer.positions[T+4]=w,this._buffer.positions[T+5]=b,this._buffer.normals[T+3]=_*f,this._buffer.normals[T+4]=x*f,this._buffer.normals[T+5]=-m,this._buffer.uvs[N+2]=A,this._buffer.uvs[N+3]=S,d||(I+=2,T+=6,N+=4,L.topP=I+0,L.bottomP=I+1,this._buffer.positions[T+0]=v,this._buffer.positions[T+1]=w,this._buffer.positions[T+2]=this._depth-b,this._buffer.normals[T+0]=P*f,this._buffer.normals[T+1]=O*f,this._buffer.normals[T+2]=m,this._buffer.uvs[N+0]=S,this._buffer.uvs[N+1]=A,this._buffer.positions[T+3]=v,this._buffer.positions[T+4]=w,this._buffer.positions[T+5]=b,this._buffer.normals[T+3]=P*f,this._buffer.normals[T+4]=O*f,this._buffer.normals[T+5]=-m,this._buffer.uvs[N+2]=A,this._buffer.uvs[N+3]=S),this.vertexCache[s]=L,L}clone(){let e=new Xn(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Ro(this.userData),e}};var Gt=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:Be.ODD},n.parameters),t=Math.abs(e.width),o=Math.abs(e.height??e.width),i=Math.abs(e.depth??0),s=n.shape??r?.shape,l=s?.roundness??e.roundness;s!==void 0&&(s instanceof Te?(s.width!==t||s.height!==o)&&s.applySize(t,o):s=new Te(t,o).fromJSON(s),n.parameters?.roundness!==void 0&&n.parameters?.roundness>0&&s.update());let c=s??new Te(t,o);return{parameters:Object.assign(e,{width:t,height:o,depth:i,roundness:l}),shape:c}}static build(n){let{depth:r,extrudeBevelSize:e,extrudeBevelSegments:t,subdivisions:o,roundness:i,windingRule:s}=n.parameters;n.shape.roundness=i;let l;return r<=0?l=new Yn(n.shape,o,{windingRule:s}):l=new Xn(n.shape,r,e,o,t,s),Object.assign(l,{userData:{...n,type:"VectorGeometry"}})}};var Zn=require("three"),Vm=Math.PI*2,jm=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters);return{shape:n.shape&&n.shape instanceof Te?n.shape:new Te,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(n){let{width:r,height:e,spikes:t,angle:o,innerRadius:i,depth:s,extrudeBevelSize:l,extrudeBevelSegments:c}=n.parameters,u=n.shape,a=r*.5,d=e*.5,p=Nw(u,a,d,o*Math.PI/180,t,i);u.isClosed=!0,u.update();let f=Gt.create({shape:u,parameters:{subdivisions:p,depth:s,extrudeBevelSize:l,extrudeBevelSegments:c}});return Object.assign(f,{userData:{...n,type:"EllipseGeometry"}})}};function Nw(n,r,e,t,o,i){if(t>=Vm)return o>30||o%4===0?(Lw(n,r,e,i),Math.round(o/4)):Rm(n,t,o,r,e,i);t=Math.max(t,.001);let s={x:0,y:e},l=t+Math.PI*.5,c={x:Math.cos(l)*r,y:Math.sin(l)*e},u=Lm({px:s.x,py:s.y,cx:c.x,cy:c.y,rx:r,ry:e,largeArcFlag:t>Math.PI,sweepFlag:!0});return o>30||o%u.length===0?Ew(n,s.x,s.y,u,o,r,e,i):Rm(n,t,o,r,e,i)}function Ew(n,r,e,t,o,i,s,l){let c=Math.round(o/t.length);n.addPoint(Kn(r,e));for(let u=0,a=t.length;u<a;u++){let d=t[u],p=n.points[u],f=Kn(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 l>0?Fm(n,i,s,l):n.addPoint(Kn(0,0)),c}function Rm(n,r,e,t,o,i){let s=-r/e;for(let l=0;l<=e;l++){let c=s*l,u=Math.sin(c)*t,a=Math.cos(c)*o;n.addPoint(Kn(u,a))}return r<Vm?i>0?Fm(n,t,o,i):n.addPoint(Kn(0,0)):(n.removePoint(n.points[n.points.length-1]),i>0&&Um(n,t,o,i)),1}function Lw(n,r,e,t=0,o=0,i=0){let s=.5522847498,l=r*s,c=e*s;n.addPoint(Ja(o-r,i,o-r,i-c,o-r,i+c)),n.addPoint(Ja(o,i+e,o-l,i+e,o+l,i+e)),n.addPoint(Ja(o+r,i,o+r,i+c,o+r,i-c)),n.addPoint(Ja(o,i-e,o+l,i-e,o-l,i-e)),t>0&&Um(n,r,e,t)}function Kn(n,r){return new dr(Zn.MathUtils.generateUUID(),new Zn.Vector2(n,r))}function Ja(n,r,e,t,o,i){let s=Kn(n,r);return s.controls[0].position.set(e,t),s.controls[1].position.set(o,i),s}function Fm(n,r,e,t){zm(n,r,e,t).forEach(i=>n.addPoint(i))}function Um(n,r,e,t){let o=zm(n,r,e,t),i=new Te;o.forEach(s=>i.addPoint(s)),i.isClosed=!0,n.shapeHoles.push(i)}function zm(n,r,e,t){let o=t*r/100,i=o*(Math.abs(e)/Math.abs(r)),s=new Zn.Vector2(o/r,i/e),l=n.points.map(c=>{let u=c.clone();return u.uuid=Zn.MathUtils.generateUUID(),u}).reverse();return l.forEach(c=>{c.position.multiply(s);let u=c.controls[0].position.clone().multiply(s),a=c.controls[1].position.clone().multiply(s);c.controls[0].position.copy(a),c.controls[1].position.copy(u)}),l}var Xr=require("three"),km=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},n.parameters),t=Math.abs(e.width),o=Math.abs(e.height??t),i=Math.abs(e.depth??t),s=Math.abs(Math.min(t,i))/2;return{parameters:Object.assign(e,{width:t,height:o,depth:i,radius:s,segments:Math.round(e.segments),pathSegments:Math.round(e.pathSegments),cornerSegments:Math.round(e.cornerSegments)})}}static build(n){let{width:r,height:e,depth:t,radius:o,revolutions:i,segments:s,pathRadius:l,pathType:c,pathSegments:u,cornerRadius:a,cornerSegments:d}=n.parameters,p=new ko(!1,r,e,t,o,i,s,l,c,u,a,d);return Object.assign(p,{userData:{...n,type:"HelixGeometry"}})}},ko=class extends Xr.BufferGeometry{constructor(r=!0,e=1,t=1,o=1,i=1,s=1,l=1,c=1,u=1,a=1,d=1,p=1,f=!1){super();let m=r&&s===1;m&&(p=0),d>100&&(d=100);let h=()=>new Xr.Vector3,y=new Xr.Vector3,g=h(),v=h(),w=h(),b,S,A,_,x,P,O,I,T=h(),N=h(),L=h(),U=h(),K=h(),J=h(),se=h(),z=h(),W=t-2*c+.001,q=W/s,j=Math.ceil(l*s),M=j+1,B=W/j,D=-W/2,F=a+1,Y=2*Math.PI/a,k=Math.PI/2/p,V=.01,G=Math.min((1-d/100)*c,c-V),H=c-G,$=0,ee=2,ae=p*ee+ee,te=F*ae/ee,re=te+F*M,oe=F*(M+ae),[Z,he,ue]=[3,3,2].map(tt=>Array(oe*tt).fill(0)),ge=[],vt=i-c;function _e(tt,zt){let xr=Math.PI/2;P=zt*B,I=2*Math.PI*(P%q)/q+xr,P+=D,O=Math.sin(I)*vt,x=Math.cos(I)*vt,r?tt.set(x,O,P):tt.set(x,P,O)}_e(y,-1e-10),_e(g,0),T.copy(y),_e(y,1);let Le=y.distanceTo(g),Me=m?0:H+G,Ct=Le*j+2*Me,to=G,Yt=Ct-Me;for(let tt=0;tt<=j;tt++){_e(v,tt),z.subVectors(v,T).normalize(),T.copy(v),J.copy(v).setComponent(+r+1,0).normalize(),se.crossVectors(z,J).normalize();let zt=tt===0,xr=tt===j,$y=zt?3*Math.PI/2:k,Yy=zt?to:Yt,Xy=zt?F:re,Ky=zt?0:oe-F,Zy=z.clone().multiplyScalar(zt?-H:H).add(v),Qy=z.clone().multiplyScalar(zt?-1:1).normalize();for(let Ur=0;Ur<F;Ur++){let Nd=Ur*Y;if(N.addVectors(y.copy(J).multiplyScalar(c*Math.cos(Nd)),g.copy(se).multiplyScalar(c*Math.sin(Nd))),L.copy(N).normalize(),zt||xr){m||($=Ky+Ur,[0,1,2].forEach(Nt=>{Z[$*3+Nt]=Zy.getComponent(Nt),he[$*3+Nt]=Qy.getComponent(Nt)}),ue[$*2]=+xr,ue[$*2+1]=Ur/a),g.copy(L).multiplyScalar(G),w.addVectors(v,g);for(let Nt=0;Nt<p;Nt++){let kl=Nt*k+$y;U.addVectors(y.copy(z).multiplyScalar(H*Math.sin(kl)),g.copy(L).multiplyScalar(H*Math.cos(kl))),K.copy(U).normalize(),g.addVectors(w,U),U.normalize(),$=Xy+Nt*F+Ur,[0,1,2].forEach(Ws=>{Z[$*3+Ws]=g.getComponent(Ws),he[$*3+Ws]=K.getComponent(Ws)});let Jy=+zt+Math.sin(kl);ue[$*2]=(Yy+H*Jy)/Ct,ue[$*2+1]=Ur/a}}g.addVectors(v,N),$=te+tt*F+Ur,[0,1,2].forEach(Nt=>{Z[$*3+Nt]=g.getComponent(Nt),he[$*3+Nt]=L.getComponent(Nt)}),ue[$*2]=(Me+tt*Le)/Ct,ue[$*2+1]=Ur/a}}let on=M+2*p+ee,Ul=1,[zl,Ci]=[+m,on-1];f&&(Ci-=1);for(let tt=zl;tt<=Ci-1;tt++){let zt=m&&tt===Ci-1;for(let xr=0;xr<F-1;xr++)b=tt*F+xr,S=b+1,A=(zt?xr:b)+F,_=(zt?xr+1:S)+F,tt===0?ge.push(S,_,A):tt===on-2?ge.push(b,S,A):ge.push(b,S,A,S,_,A)}this.setIndex(ge),this.setAttribute("position",new Xr.Float32BufferAttribute(Z,3)),this.setAttribute("normal",new Xr.Float32BufferAttribute(he,3)),this.setAttribute("uv",new Xr.Float32BufferAttribute(ue,2))}};var Hm=require("three");var Wm=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,detail:0,corner:0,cornerSides:4},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:r,height:e,depth:t,detail:o,corner:i,cornerSides:s}=n.parameters,l=o===0&&i!==0?new rs(r*.5,i,s):new Hm.IcosahedronGeometry(r*.5,o);return l.scale(1,e/r,t/r),Object.assign(l,{userData:{...n,type:"IcosahedronGeometry"}})}},rs=class extends go{constructor(r=1,e=.2,t=4){let o=(1+Math.sqrt(5))/2,i=[-1,o,0,1,o,0,-1,-o,0,1,-o,0,0,-1,o,0,1,o,0,-1,-o,0,1,-o,o,0,-1,o,0,1,-o,0,-1,-o,0,1],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],l="IcosahedronGeometry";super(i,s,l,r,e,t),this.type=l}static fromJSON(r){return new rs(r.radius,r.corner,r.cornerSides)}};var el=require("three"),qm=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){(n.parameters?.points??[]).forEach(t=>{Array.isArray(t)&&(t.x=t[0],t.y=t[1])});let e=Object.assign({},r?.parameters??{width:100,segments:64,verticalSegments:64,points:[{x:0,y:-50,id:0},{x:50,y:-50,id:1},{x:50,y:50,id:2},{x:0,y:50,id:3}]},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{points:r,segments:e,verticalSegments:t}=n.parameters,o=new el.Shape;o.moveTo(r[0].x,r[0].y),o.bezierCurveTo(r[1].x,r[1].y,r[2].x,r[2].y,r[3].x,r[3].y);let i=new el.LatheGeometry(o.extractPoints(t).shape,e);return i.rotateZ(Math.PI),Object.assign(i,{userData:{...n,type:"LatheGeometry"}})}};var Cr=require("three");var Kr=require("three");var ie=require("three"),Ir=new ie.Matrix4,Bc=new ie.Object3D,tl=new ie.Vector3,vo=class extends ie.EventDispatcher{constructor(){super(),this.uuid=ie.MathUtils.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}applyMatrix4(r){let e=new ie.Matrix3().getNormalMatrix(r);for(let t=0,o=this.vertices.length;t<o;t++)this.vertices[t].applyMatrix4(r);for(let t=0,o=this.faces.length;t<o;t++){let i=this.faces[t];i.normal.applyMatrix3(e).normalize();for(let s=0,l=i.vertexNormals.length;s<l;s++)i.vertexNormals[s].applyMatrix3(e).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this}rotateX(r){return Ir.makeRotationX(r),this.applyMatrix4(Ir),this}rotateY(r){return Ir.makeRotationY(r),this.applyMatrix4(Ir),this}rotateZ(r){return Ir.makeRotationZ(r),this.applyMatrix4(Ir),this}translate(r,e,t){return Ir.makeTranslation(r,e,t),this.applyMatrix4(Ir),this}scale(r,e,t){return Ir.makeScale(r,e,t),this.applyMatrix4(Ir),this}lookAt(r){return Bc.lookAt(r),Bc.updateMatrix(),this.applyMatrix4(Bc.matrix),this}fromBufferGeometry(r){let e=this,t=r.index!==null?r.index:void 0,o=r.attributes;if(o.position===void 0)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;let i=o.position,s=o.normal,l=o.color,c=o.uv,u=o.uv2;u!==void 0&&(this.faceVertexUvs[1]=[]);for(let p=0;p<i.count;p++)e.vertices.push(new ie.Vector3().fromBufferAttribute(i,p)),l!==void 0&&e.colors.push(new ie.Color().fromBufferAttribute(l,p));function a(p,f,m,h){let y=l===void 0?[]:[e.colors[p].clone(),e.colors[f].clone(),e.colors[m].clone()],g=s===void 0?[]:[new ie.Vector3().fromBufferAttribute(s,p),new ie.Vector3().fromBufferAttribute(s,f),new ie.Vector3().fromBufferAttribute(s,m)],v=new Qn(p,f,m,g,y,h);e.faces.push(v),c!==void 0&&e.faceVertexUvs[0].push([new ie.Vector2().fromBufferAttribute(c,p),new ie.Vector2().fromBufferAttribute(c,f),new ie.Vector2().fromBufferAttribute(c,m)]),u!==void 0&&e.faceVertexUvs[1].push([new ie.Vector2().fromBufferAttribute(u,p),new ie.Vector2().fromBufferAttribute(u,f),new ie.Vector2().fromBufferAttribute(u,m)])}let d=r.groups;if(d.length>0)for(let p=0;p<d.length;p++){let f=d[p],m=f.start,h=f.count;for(let y=m,g=m+h;y<g;y+=3)t!==void 0?a(t.getX(y),t.getX(y+1),t.getX(y+2),f.materialIndex):a(y,y+1,y+2,f.materialIndex)}else if(t!==void 0)for(let p=0;p<t.count;p+=3)a(t.getX(p),t.getX(p+1),t.getX(p+2));else for(let p=0;p<i.count;p+=3)a(p,p+1,p+2);return this.computeFaceNormals(),r.boundingBox!==null&&(this.boundingBox=r.boundingBox.clone()),r.boundingSphere!==null&&(this.boundingSphere=r.boundingSphere.clone()),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(tl).negate(),this.translate(tl.x,tl.y,tl.z),this}normalize(){this.computeBoundingSphere();let r=this.boundingSphere.center,e=this.boundingSphere.radius,t=e===0?1:1/e,o=new ie.Matrix4;return o.set(t,0,0,-t*r.x,0,t,0,-t*r.y,0,0,t,-t*r.z,0,0,0,1),this.applyMatrix4(o),this}computeFaceNormals(){let r=new ie.Vector3,e=new ie.Vector3;for(let t=0,o=this.faces.length;t<o;t++){let i=this.faces[t],s=this.vertices[i.a],l=this.vertices[i.b],c=this.vertices[i.c];r.subVectors(c,l),e.subVectors(s,l),r.cross(e),r.normalize(),i.normal.copy(r)}}computeVertexNormals(r=!0){let e=new Array(this.vertices.length);for(let t=0,o=this.vertices.length;t<o;t++)e[t]=new ie.Vector3;if(r){let t=new ie.Vector3,o=new ie.Vector3;for(let i=0,s=this.faces.length;i<s;i++){let l=this.faces[i],c=this.vertices[l.a],u=this.vertices[l.b],a=this.vertices[l.c];t.subVectors(a,u),o.subVectors(c,u),t.cross(o),e[l.a].add(t),e[l.b].add(t),e[l.c].add(t)}}else{this.computeFaceNormals();for(let t=0,o=this.faces.length;t<o;t++){let i=this.faces[t];e[i.a].add(i.normal),e[i.b].add(i.normal),e[i.c].add(i.normal)}}for(let t=0,o=this.vertices.length;t<o;t++)e[t].normalize();for(let t=0,o=this.faces.length;t<o;t++){let i=this.faces[t],s=i.vertexNormals;s.length===3?(s[0].copy(e[i.a]),s[1].copy(e[i.b]),s[2].copy(e[i.c])):(s[0]=e[i.a].clone(),s[1]=e[i.b].clone(),s[2]=e[i.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeFlatVertexNormals(){this.computeFaceNormals();for(let r=0,e=this.faces.length;r<e;r++){let t=this.faces[r],o=t.vertexNormals;o.length===3?(o[0].copy(t.normal),o[1].copy(t.normal),o[2].copy(t.normal)):(o[0]=t.normal.clone(),o[1]=t.normal.clone(),o[2]=t.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let e=0,t=this.faces.length;e<t;e++){let o=this.faces[e];o.__originalFaceNormal?o.__originalFaceNormal.copy(o.normal):o.__originalFaceNormal=o.normal.clone(),o.__originalVertexNormals||(o.__originalVertexNormals=[]);for(let i=0,s=o.vertexNormals.length;i<s;i++)o.__originalVertexNormals[i]?o.__originalVertexNormals[i].copy(o.vertexNormals[i]):o.__originalVertexNormals[i]=o.vertexNormals[i].clone()}let r=new vo;r.faces=this.faces;for(let e=0,t=this.morphTargets.length;e<t;e++){if(!this.morphNormals[e]){this.morphNormals[e]={},this.morphNormals[e].faceNormals=[],this.morphNormals[e].vertexNormals=[];let i=this.morphNormals[e].faceNormals,s=this.morphNormals[e].vertexNormals;for(let l=0,c=this.faces.length;l<c;l++){let u=new ie.Vector3,a={a:new ie.Vector3,b:new ie.Vector3,c:new ie.Vector3};i.push(u),s.push(a)}}let o=this.morphNormals[e];r.vertices=this.morphTargets[e].vertices,r.computeFaceNormals(),r.computeVertexNormals();for(let i=0,s=this.faces.length;i<s;i++){let l=this.faces[i],c=o.faceNormals[i],u=o.vertexNormals[i];c.copy(l.normal),u.a.copy(l.vertexNormals[0]),u.b.copy(l.vertexNormals[1]),u.c.copy(l.vertexNormals[2])}}for(let e=0,t=this.faces.length;e<t;e++){let o=this.faces[e];o.normal=o.__originalFaceNormal,o.vertexNormals=o.__originalVertexNormals}}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ie.Box3),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new ie.Sphere),this.boundingSphere.setFromPoints(this.vertices)}merge(r,e,t=0){if(!(r&&r.isGeometry)){console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",r);return}let o,i=this.vertices.length,s=this.vertices,l=r.vertices,c=this.faces,u=r.faces,a=this.colors,d=r.colors;e!==void 0&&(o=new ie.Matrix3().getNormalMatrix(e));for(let p=0,f=l.length;p<f;p++){let h=l[p].clone();e!==void 0&&h.applyMatrix4(e),s.push(h)}for(let p=0,f=d.length;p<f;p++)a.push(d[p].clone());for(let p=0,f=u.length;p<f;p++){let m=u[p],h,y,g=m.vertexNormals,v=m.vertexColors,w=new Qn(m.a+i,m.b+i,m.c+i);w.normal.copy(m.normal),o!==void 0&&w.normal.applyMatrix3(o).normalize();for(let b=0,S=g.length;b<S;b++)h=g[b].clone(),o!==void 0&&h.applyMatrix3(o).normalize(),w.vertexNormals.push(h);w.color.copy(m.color);for(let b=0,S=v.length;b<S;b++)y=v[b],w.vertexColors.push(y.clone());w.materialIndex=m.materialIndex+t,c.push(w)}for(let p=0,f=r.faceVertexUvs.length;p<f;p++){let m=r.faceVertexUvs[p];this.faceVertexUvs[p]===void 0&&(this.faceVertexUvs[p]=[]);for(let h=0,y=m.length;h<y;h++){let g=m[h],v=[];for(let w=0,b=g.length;w<b;w++)v.push(g[w].clone());this.faceVertexUvs[p].push(v)}}}mergeMesh(r){if(!(r&&r.isMesh)){console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",r);return}r.matrixAutoUpdate&&r.updateMatrix(),this.merge(r.geometry,r.matrix)}mergeVertices(r=4){let e={},t=[],o=[],i=Math.pow(10,r);for(let c=0,u=this.vertices.length;c<u;c++){let a=this.vertices[c],d=Math.round(a.x*i)+"_"+Math.round(a.y*i)+"_"+Math.round(a.z*i);e[d]===void 0?(e[d]=c,t.push(this.vertices[c]),o[c]=t.length-1):o[c]=o[e[d]]}let s=[];for(let c=0,u=this.faces.length;c<u;c++){let a=this.faces[c];a.a=o[a.a],a.b=o[a.b],a.c=o[a.c];let d=[a.a,a.b,a.c];for(let p=0;p<3;p++)if(d[p]===d[(p+1)%3]){s.push(c);break}}for(let c=s.length-1;c>=0;c--){let u=s[c];this.faces.splice(u,1);for(let a=0,d=this.faceVertexUvs.length;a<d;a++)this.faceVertexUvs[a].splice(u,1)}let l=this.vertices.length-t.length;return this.vertices=t,l}setFromPoints(r){this.vertices=[];for(let e=0,t=r.length;e<t;e++){let o=r[e];this.vertices.push(new ie.Vector3(o.x,o.y,o.z||0))}return this}sortFacesByMaterialIndex(){let r=this.faces,e=r.length;for(let c=0;c<e;c++)r[c]._id=c;function t(c,u){return c.materialIndex-u.materialIndex}r.sort(t);let o=this.faceVertexUvs[0],i=this.faceVertexUvs[1],s,l;o&&o.length===e&&(s=[]),i&&i.length===e&&(l=[]);for(let c=0;c<e;c++){let u=r[c]._id;s&&s.push(o[u]),l&&l.push(i[u])}s&&(this.faceVertexUvs[0]=s),l&&(this.faceVertexUvs[1]=l)}toJSON(){let r={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.parameters!==void 0){let m=this.parameters;for(let h in m)m[h]!==void 0&&(r[h]=m[h]);return r}let e=[];for(let m=0;m<this.vertices.length;m++){let h=this.vertices[m];e.push(h.x,h.y,h.z)}let t=[],o=[],i={},s=[],l={},c=[],u={};for(let m=0;m<this.faces.length;m++){let h=this.faces[m],y=!0,g=!1,v=this.faceVertexUvs[0][m]!==void 0,w=h.normal.length()>0,b=h.vertexNormals.length>0,S=h.color.r!==1||h.color.g!==1||h.color.b!==1,A=h.vertexColors.length>0,_=0;if(_=a(_,0,0),_=a(_,1,y),_=a(_,2,g),_=a(_,3,v),_=a(_,4,w),_=a(_,5,b),_=a(_,6,S),_=a(_,7,A),t.push(_),t.push(h.a,h.b,h.c),t.push(h.materialIndex),v){let x=this.faceVertexUvs[0][m];t.push(f(x[0]),f(x[1]),f(x[2]))}if(w&&t.push(d(h.normal)),b){let x=h.vertexNormals;t.push(d(x[0]),d(x[1]),d(x[2]))}if(S&&t.push(p(h.color)),A){let x=h.vertexColors;t.push(p(x[0]),p(x[1]),p(x[2]))}}function a(m,h,y){return y?m|1<<h:m&~(1<<h)}function d(m){let h=m.x.toString()+m.y.toString()+m.z.toString();return i[h]!==void 0||(i[h]=o.length/3,o.push(m.x,m.y,m.z)),i[h]}function p(m){let h=m.r.toString()+m.g.toString()+m.b.toString();return l[h]!==void 0||(l[h]=s.length,s.push(m.getHex())),l[h]}function f(m){let h=m.x.toString()+m.y.toString();return u[h]!==void 0||(u[h]=c.length/2,c.push(m.x,m.y)),u[h]}return r.data={},r.data.vertices=e,r.data.normals=o,s.length>0&&(r.data.colors=s),c.length>0&&(r.data.uvs=[c]),r.data.faces=t,r}clone(){return new vo().copy(this)}copy(r){this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=r.name;let e=r.vertices;for(let p=0,f=e.length;p<f;p++)this.vertices.push(e[p].clone());let t=r.colors;for(let p=0,f=t.length;p<f;p++)this.colors.push(t[p].clone());let o=r.faces;for(let p=0,f=o.length;p<f;p++)this.faces.push(o[p].clone());for(let p=0,f=r.faceVertexUvs.length;p<f;p++){let m=r.faceVertexUvs[p];this.faceVertexUvs[p]===void 0&&(this.faceVertexUvs[p]=[]);for(let h=0,y=m.length;h<y;h++){let g=m[h],v=[];for(let w=0,b=g.length;w<b;w++){let S=g[w];v.push(S.clone())}this.faceVertexUvs[p].push(v)}}let i=r.morphTargets;for(let p=0,f=i.length;p<f;p++){let m={};if(m.name=i[p].name,i[p].vertices!==void 0){m.vertices=[];for(let h=0,y=i[p].vertices.length;h<y;h++)m.vertices.push(i[p].vertices[h].clone())}if(i[p].normals!==void 0){m.normals=[];for(let h=0,y=i[p].normals.length;h<y;h++)m.normals.push(i[p].normals[h].clone())}this.morphTargets.push(m)}let s=r.morphNormals;for(let p=0,f=s.length;p<f;p++){let m={};if(s[p].vertexNormals!==void 0){m.vertexNormals=[];for(let h=0,y=s[p].vertexNormals.length;h<y;h++){let g=s[p].vertexNormals[h],v={};v.a=g.a.clone(),v.b=g.b.clone(),v.c=g.c.clone(),m.vertexNormals.push(v)}}if(s[p].faceNormals!==void 0){m.faceNormals=[];for(let h=0,y=s[p].faceNormals.length;h<y;h++)m.faceNormals.push(s[p].faceNormals[h].clone())}this.morphNormals.push(m)}let l=r.skinWeights;for(let p=0,f=l.length;p<f;p++)this.skinWeights.push(l[p].clone());let c=r.skinIndices;for(let p=0,f=c.length;p<f;p++)this.skinIndices.push(c[p].clone());let u=r.lineDistances;for(let p=0,f=u.length;p<f;p++)this.lineDistances.push(u[p]);let a=r.boundingBox;a!==null&&(this.boundingBox=a.clone());let d=r.boundingSphere;return d!==null&&(this.boundingSphere=d.clone()),this.elementsNeedUpdate=r.elementsNeedUpdate,this.verticesNeedUpdate=r.verticesNeedUpdate,this.uvsNeedUpdate=r.uvsNeedUpdate,this.normalsNeedUpdate=r.normalsNeedUpdate,this.colorsNeedUpdate=r.colorsNeedUpdate,this.lineDistancesNeedUpdate=r.lineDistancesNeedUpdate,this.groupsNeedUpdate=r.groupsNeedUpdate,this}toBufferGeometry(){let r=new Dc().fromGeometry(this),e=new ie.BufferGeometry,t=new Float32Array(r.vertices.length*3);if(e.setAttribute("position",new ie.BufferAttribute(t,3).copyVector3sArray(r.vertices)),r.normals.length>0){let o=new Float32Array(r.normals.length*3);e.setAttribute("normal",new ie.BufferAttribute(o,3).copyVector3sArray(r.normals))}if(r.colors.length>0){let o=new Float32Array(r.colors.length*3);e.setAttribute("color",new ie.BufferAttribute(o,3).copyColorsArray(r.colors))}if(r.uvs.length>0){let o=new Float32Array(r.uvs.length*2);e.setAttribute("uv",new ie.BufferAttribute(o,2).copyVector2sArray(r.uvs))}if(r.uvs2.length>0){let o=new Float32Array(r.uvs2.length*2);e.setAttribute("uv2",new ie.BufferAttribute(o,2).copyVector2sArray(r.uvs2))}e.groups=r.groups;for(let o in r.morphTargets){let i=[],s=r.morphTargets[o];for(let l=0,c=s.length;l<c;l++){let u=s[l],a=new ie.Float32BufferAttribute(u.data.length*3,3);a.name=u.name,i.push(a.copyVector3sArray(u.data))}e.morphAttributes[o]=i}if(r.skinIndices.length>0){let o=new ie.Float32BufferAttribute(r.skinIndices.length*4,4);e.setAttribute("skinIndex",o.copyVector4sArray(r.skinIndices))}if(r.skinWeights.length>0){let o=new ie.Float32BufferAttribute(r.skinWeights.length*4,4);e.setAttribute("skinWeight",o.copyVector4sArray(r.skinWeights))}return r.boundingSphere!==null&&(e.boundingSphere=r.boundingSphere.clone()),r.boundingBox!==null&&(e.boundingBox=r.boundingBox.clone()),e}computeTangents(){console.error("THREE.Geometry: .computeTangents() has been removed.")}computeLineDistances(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")}applyMatrix(r){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(r)}dispose(){this.dispatchEvent({type:"dispose"})}static createBufferGeometryFromObject(r){let e=new ie.BufferGeometry,t=r.geometry;if(r.isPoints||r.isLine){let o=new ie.Float32BufferAttribute(t.vertices.length*3,3),i=new ie.Float32BufferAttribute(t.colors.length*3,3);if(e.setAttribute("position",o.copyVector3sArray(t.vertices)),e.setAttribute("color",i.copyColorsArray(t.colors)),t.lineDistances&&t.lineDistances.length===t.vertices.length){let s=new ie.Float32BufferAttribute(t.lineDistances.length,1);e.setAttribute("lineDistance",s.copyArray(t.lineDistances))}t.boundingSphere!==null&&(e.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(e.boundingBox=t.boundingBox.clone())}else r.isMesh&&(e=t.toBufferGeometry());return e}};vo.prototype.isGeometry=!0;var Dc=class{constructor(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}computeGroups(r){let e=[],t,o,i,s=r.faces;for(o=0;o<s.length;o++){let l=s[o];l.materialIndex!==i&&(i=l.materialIndex,t!==void 0&&(t.count=o*3-t.start,e.push(t)),t={start:o*3,materialIndex:i})}t!==void 0&&(t.count=o*3-t.start,e.push(t)),this.groups=e}fromGeometry(r){let e=r.faces,t=r.vertices,o=r.faceVertexUvs,i=o[0]&&o[0].length>0,s=o[1]&&o[1].length>0,l=r.morphTargets,c=l.length,u;if(c>0){u=[];for(let g=0;g<c;g++)u[g]={name:l[g].name,data:[]};this.morphTargets.position=u}let a=r.morphNormals,d=a.length,p;if(d>0){p=[];for(let g=0;g<d;g++)p[g]={name:a[g].name,data:[]};this.morphTargets.normal=p}let f=r.skinIndices,m=r.skinWeights,h=f.length===t.length,y=m.length===t.length;t.length>0&&e.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let g=0;g<e.length;g++){let v=e[g];this.vertices.push(t[v.a],t[v.b],t[v.c]);let w=v.vertexNormals;if(w.length===3)this.normals.push(w[0],w[1],w[2]);else{let S=v.normal;this.normals.push(S,S,S)}let b=v.vertexColors;if(b.length===3)this.colors.push(b[0],b[1],b[2]);else{let S=v.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 ie.Vector2,new ie.Vector2,new ie.Vector2))}if(s===!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 ie.Vector2,new ie.Vector2,new ie.Vector2))}for(let S=0;S<c;S++){let A=l[S].vertices;u[S].data.push(A[v.a],A[v.b],A[v.c])}for(let S=0;S<d;S++){let A=a[S].vertexNormals[g];p[S].data.push(A.a,A.b,A.c)}h&&this.skinIndices.push(f[v.a],f[v.b],f[v.c]),y&&this.skinWeights.push(m[v.a],m[v.b],m[v.c])}return this.computeGroups(r),this.verticesNeedUpdate=r.verticesNeedUpdate,this.normalsNeedUpdate=r.normalsNeedUpdate,this.colorsNeedUpdate=r.colorsNeedUpdate,this.uvsNeedUpdate=r.uvsNeedUpdate,this.groupsNeedUpdate=r.groupsNeedUpdate,r.boundingSphere!==null&&(this.boundingSphere=r.boundingSphere.clone()),r.boundingBox!==null&&(this.boundingBox=r.boundingBox.clone()),this}},Qn=class{constructor(r,e,t,o,i,s=0){this.a=r,this.b=e,this.c=t,this.normal=o&&o.isVector3?o:new ie.Vector3,this.vertexNormals=Array.isArray(o)?o:[],this.color=i&&i.isColor?i:new ie.Color,this.vertexColors=Array.isArray(i)?i:[],this.materialIndex=s}clone(){return new this.constructor().copy(this)}copy(r){this.a=r.a,this.b=r.b,this.c=r.c,this.normal.copy(r.normal),this.color.copy(r.color),this.materialIndex=r.materialIndex;for(let e=0,t=r.vertexNormals.length;e<t;e++)this.vertexNormals[e]=r.vertexNormals[e].clone();for(let e=0,t=r.vertexColors.length;e<t;e++)this.vertexColors[e]=r.vertexColors[e].clone();return this}};var Mw=["a","b","c"];function Bw(n,r){switch(r){case"c":return n.c;case"b":return n.b;case"a":default:return n.a}}function Gc(n,r,e){let t=Math.min(n,r),o=Math.max(n,r),i=t+"_"+o;return e.get(i)}function Rc(n,r,e,t,o,i){let s=Math.min(n,r),l=Math.max(n,r),c=s+"_"+l,u;if(t.has(c))u=t.get(c);else{let a=e[s],d=e[l];u={a,b:d,newEdge:null,faces:[]},t.set(c,u)}u.faces.push(o),i[n].edges.push(u),i[r].edges.push(u)}function Dw(n,r,e,t){let o,i,s;for(o=0,i=n.length;o<i;o++)e[o]={edges:[]};for(o=0,i=r.length;o<i;o++)s=r[o],Rc(s.a,s.b,n,t,s,e),Rc(s.b,s.c,n,t,s,e),Rc(s.c,s.a,n,t,s,e)}function rl(n,r,e,t,o){n.push(new Qn(r,e,t,void 0,void 0,o))}function Jn(n,r){return Math.abs(r-n)/2+Math.min(n,r)}function ol(n,r,e,t){n.push([r.clone(),e.clone(),t.clone()])}var nl=class{constructor(r=1){this.subdivisions=r}modify(r){r instanceof Kr.BufferGeometry?r=new vo().fromBufferGeometry(r):r=r.clone(),r.mergeVertices();let e=this.subdivisions;for(;e-- >0;)this._smooth(r);return r.computeFaceNormals(),r.computeVertexNormals(),r}_smooth(r){let e=new Kr.Vector3,t,o,i,s,l,c=r.vertices,u=r.faces,a=r.faceVertexUvs[0],d=a!==void 0&&a.length>0,p=[],f=new Map;Dw(c,u,p,f);let m=[],h,y,g,v,w,b,S;for(let k of Array.from(f.keys())){for(y=f.get(k),g=new Kr.Vector3,w=3/8,b=1/8,S=y.faces.length,S!=2&&(w=.5,b=0,S!=1),g.addVectors(y.a,y.b).multiplyScalar(w),e.set(0,0,0),s=0;s<S;s++){for(v=y.faces[s],l=0;l<3&&(h=c[Bw(v,Mw[l])],!(h!==y.a&&h!==y.b));l++);h&&e.add(h)}e.multiplyScalar(b),g.add(e),y.newEdge=m.length,m.push(g)}let A,_,x,P,O,I,T,N=[];for(o=0,i=c.length;o<i;o++){for(I=c[o],O=p[o].edges,t=O.length,t==3?A=3/16:t>3&&(A=3/(8*t)),_=1-t*Number(A),x=A,t<=2&&(t==2?(_=3/4,x=1/8):t==1||t==0),T=I.clone().multiplyScalar(_),e.set(0,0,0),s=0;s<t;s++)P=O[s],h=P.a!==I?P.a:P.b,e.add(h);e.multiplyScalar(Number(x)),T.add(e),N.push(T)}let L=N.concat(m),U=N.length,K,J,se,z=[],W=[],q,j,M,B,D=new Kr.Vector2,F=new Kr.Vector2,Y=new Kr.Vector2;for(o=0,i=u.length;o<i;o++)v=u[o],K=Number(Gc(v.a,v.b,f).newEdge)+U,J=Number(Gc(v.b,v.c,f).newEdge)+U,se=Number(Gc(v.c,v.a,f).newEdge)+U,rl(z,K,J,se,v.materialIndex),rl(z,v.a,K,se,v.materialIndex),rl(z,v.b,J,K,v.materialIndex),rl(z,v.c,se,J,v.materialIndex),d&&(q=a[o],j=q[0],M=q[1],B=q[2],D.set(Jn(j.x,M.x),Jn(j.y,M.y)),F.set(Jn(M.x,B.x),Jn(M.y,B.y)),Y.set(Jn(j.x,B.x),Jn(j.y,B.y)),ol(W,D,F,Y),ol(W,j,D,Y),ol(W,M,F,D),ol(W,B,Y,F));r.vertices=L,r.faces=z,d&&(r.faceVertexUvs[0]=W)}};var ot=new Cr.Vector3,$m=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=n.geometry??r?.geometry??new Cr.BufferGeometry().copy(new Cr.BoxGeometry(100,100,100)),t;r===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(ot),t={width:ot.x,height:ot.y,depth:ot.z,subdivisions:0}):t=r.parameters;let o={...t,...n.parameters};return{parameters:{width:Math.abs(o.width),height:Math.abs(o.height),depth:Math.abs(o.depth),subdivisions:Math.abs(o.subdivisions)},geometry:e}}static build(n){let{width:r,height:e,depth:t,subdivisions:o}=n.parameters,i=n.geometry??new Cr.BufferGeometry().copy(new Cr.BoxGeometry(100,100,100)),s=i.userData.parameters;s===void 0?(i.computeBoundingBox(),i.boundingBox.getSize(ot)):ot.set(s.width,s.height,s.depth),(r!==ot.x||e!==ot.y||t!==ot.z)&&i.scale(ot.x===0?1:r/ot.x,ot.y===0?1:e/ot.y,ot.z===0?1:t/ot.z);let l=i.originalGeometry;return o>0?(l===void 0||s?.subdivisions!==o)&&(l===void 0&&(l=i),i=new nl(o).modify(l).toBufferGeometry()):(l!==void 0&&(i=l),l=void 0,i.getAttribute("normal")===void 0&&i.computeVertexNormals()),l!==void 0&&Object.assign(i,{originalGeometry:l}),delete n.geometry,Object.assign(i,{userData:{...n,type:"NonParametricGeometry"}})}static loadFromUrl(n,r,e){new Cr.BufferGeometryLoader(e).load(n,o=>{let i=this.normalizeInputs({geometry:o});o.boundingBox.getSize(ot);let s=100/ot.x;Object.assign(i.parameters,{width:100,height:ot.y*s,depth:ot.z*s}),r(this.build(i))})}};var Ym=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},n.parameters);return{shape:n.shape&&n.shape instanceof Te?n.shape:new Te,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(n){let{width:r,height:e,spikes:t,cornerRadius:o,depth:i,extrudeBevelSize:s,extrudeBevelSegments:l}=n.parameters,c=n.shape,u=r*.5,a=e*.5,d=0,p=0,f=2*Math.PI/t;for(let h=0;h<t;h++){let y=f*h,g=d+Math.sin(y)*u,v=p+Math.cos(y)*a;c.addPoint(c.createPoint(g,v))}c.isClosed=!0;for(let h=0,y=c.points.length;h<y;h++)c.points[h].roundness=o;c.roundness=o,c.update();let m=Gt.create({shape:c,parameters:{roundness:o,depth:i,extrudeBevelSize:s,extrudeBevelSegments:l}});return Object.assign(m,{userData:{...n,type:"PolygonGeometry"}})}};var Se=require("three"),Xm=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:r,height:e,depth:t,radialSegments:o,heightSegments:i,openEnded:s,cornerRadius:l,cornerSegments:c}=n.parameters,u=new jc(r*.5,e,o,i,s,l,c);return u.scale(1,1,t/r),Object.assign(u,{userData:{...n,type:"PyramidGeometry"}})}};function os(n,r,e){e.x=n.x*r.x,e.y=n.y,e.z=n.x*r.y}function Vc(n,r,e,t,o,i){let s=r.clone().sub(n),l=e.clone().sub(n),c=s.angleTo(l);if(s.normalize(),l.normalize(),t===o){let u=s.add(l).normalize();i.copy(n).addScaledVector(u,t/Math.sin(c/2))}else{let u=s.angleTo(l);i.copy(n),i.addScaledVector(s,o/Math.sin(u)),i.addScaledVector(l,t/Math.sin(u))}}function Gw(n,r,e){let t=n.clone().sub(r),o=e.clone().sub(r);return t.projectOnVector(o),t.add(r)}var jc=class extends Se.BufferGeometry{constructor(r=.5,e=1,t=4,o=1,i=!1,s=0,l=4){super(),t=Math.floor(Math.max(3,t)),o=Math.floor(o),l=Math.floor(l);let c=[],u=[],a=[],d=[],p=0,f=e/2,m=Math.PI/t,h=r*Math.cos(Math.PI/t),y=2*Math.PI/t,g=(t-2)*Math.PI/t,v=Math.PI-g,w=new Se.Vector3(0,-f,0),b=new Se.Vector3(0,f,0),S=new Se.Vector2(r,-f),A=new Se.Vector2(h,-f),_=new Se.Vector2(0,b.y).sub(A),x=new Se.Vector2(0,b.y).sub(S),P=new Se.Vector2(_.y,-_.x).normalize(),O=new Se.Vector2(x.y,-x.x).normalize(),T=r*Math.cos(Math.PI/t)*Math.tan((Math.PI-_.angle())/2)-1e-8;s=Math.min(s,T);let N;{let W=new Se.Vector3(P.x,P.y,0),q=new Se.Vector3(Math.cos(y)*W.x,W.y,Math.sin(y)*W.x);N=W.angleTo(q)}let L=s/Math.tan((Math.PI-_.angle())/2),U=s/Math.tan((Math.PI-N)/2),K=new Se.Vector3;if(!i){u.push(w.x,w.y,w.z),a.push(0,-1,0),d.push(0,0);let W=p++,q=[],j=S.clone(),M=L/Math.cos(Math.PI/t);j.x-=M;for(let B=0;B<t;B++){let D=B/t*Math.PI*2+m,F=new Se.Vector2(Math.sin(D),Math.cos(D));os(j,F,K),u.push(K.x,K.y,K.z),a.push(0,-1,0),d.push(0,0),q.push(p++)}for(let B=0;B<q.length;B++)c.push(q[B],W,q[(B+1)%q.length])}let J=[];{let W=new Se.Vector3,q=new Se.Vector3,j=new Se.Vector3,M=new Se.Vector3,B=new Se.Vector3,D=new Se.Vector3;for(let F=0;F<t;F++){let Y=F/t*Math.PI*2+m,k=(F+.5)/t*Math.PI*2+m,V=(F+1)/t*Math.PI*2+m,G=new Se.Vector2(Math.sin(Y),Math.cos(Y)),H=new Se.Vector2(Math.sin(k),Math.cos(k)),$=new Se.Vector2(Math.sin(V),Math.cos(V));os(S,G,q),os(S,$,j),os(P,H,W),Vc(b,q,j,U,U,M),u.push(M.x,M.y,M.z),Vc(q,b,j,U,L,B),u.push(B.x,B.y,B.z),Vc(j,q,b,L,U,D),u.push(D.x,D.y,D.z),a.push(W.x,W.y,W.z),a.push(W.x,W.y,W.z),a.push(W.x,W.y,W.z),d.push(0,0),d.push(0,0),d.push(0,0);let ee=p++,ae=p++,te=p++;if(c.push(ee,ae,te),s>0){{let Z=q.clone().add(j).multiplyScalar(.5),he=b.clone().sub(Z).normalize(),ge=w.clone().sub(Z).normalize().add(he).normalize().multiplyScalar(-1),vt=D.clone().sub(B);se(Z,vt,ge,_.angle())}let re,oe;{let Z=new Se.Vector3;os(O,$,Z);let he=D.clone().add(M).multiplyScalar(.5);he=Gw(he,j,b);let ue=D.clone().sub(M);[re,oe]=se(he,ue,Z,N,M.y)}{let Z=re,he=Z.clone().setY(0).normalize(),ue=new Se.Vector3(0,-1,0),ge=he.clone().cross(ue);z(Z,he,ue,ge)}J.concat(oe);{let Z=_.angle(),he=Math.PI-Z,ue=b.clone();ue.y-=s/Math.sin(Z-Math.PI/2);let ge=new Se.Vector3,vt=[];for(let Le=0;Le<l;Le++){let Me=[],Ct=Math.PI/2-he*Le/l,to=Math.cos(Ct),Yt=Math.sin(Ct),on=k;for(let Ul=0;Ul<=Le;Ul++){let zl=Math.cos(on),Ci=Math.sin(on);W.x=to*Ci,W.y=Yt,W.z=to*zl,ge.copy(ue).addScaledVector(W,s),u.push(ge.x,ge.y,ge.z),a.push(W.x,W.y,W.z),d.push(0,0),Me.push(p++),on+=Math.PI*2/Le/t}vt.push(Me)}oe.reverse(),vt.push(oe);let _e=vt.length-1;for(let Le=0;Le<_e;Le++){let Me=vt[Le],Ct=vt[Le+1],to=Me.length-1;c.push(Ct[1],Me[0],Ct[0]);for(let Yt=1;Yt<=to;Yt++)c.push(Me[Yt],Me[Yt-1],Ct[Yt]),c.push(Ct[Yt+1],Me[Yt],Ct[Yt])}}}}}this.setIndex(c),this.setAttribute("position",new Se.Float32BufferAttribute(u,3)),this.setAttribute("normal",new Se.Float32BufferAttribute(a,3)),this.setAttribute("uv",new Se.Float32BufferAttribute(d,2));function se(W,q,j,M,B){let D=-M/2,F=(Math.PI-M)/2,Y=q.clone().normalize().cross(j);W.addScaledVector(j,-s/Math.sin(F));let k=new Se.Vector3,V=new Se.Vector3,G=1,H=p,$=[];for(let ee=0;ee<=l;ee++){let ae=D+ee/l*M;V.set(0,0,0),V.addScaledVector(Y,Math.sin(ae)),V.addScaledVector(j,Math.cos(ae));for(let te=0;te<=G;te++){let re=te/G-.5;if(k.copy(W),k.addScaledVector(q,re),k.addScaledVector(V,s),B!=null){let oe=Math.max(0,k.y-B);k.addScaledVector(q,-oe/q.y)}u.push(k.x,k.y,k.z),a.push(V.x,V.y,V.z),d.push(0,0),te===0&&$.push(p),p++}}for(let ee=0;ee<l;ee++)for(let ae=0;ae<G;ae++){let te=H+ae+(G+1)*ee,re=te+(G+1),oe=re+1,Z=te+1;c.push(te,re,Z),c.push(re,oe,Z)}return[W.clone().addScaledVector(q,.5),$]}function z(W,q,j,M){let B=Math.PI/2,D=x.angle()-B,F=[],Y=new Se.Vector3,k=new Se.Vector3;for(let G=0;G<=l;G++){let H=[],$=G/l;for(let ee=0;ee<=G;ee++){let te=((G?ee/G:0)-.5)*v,re=Math.cos(te),oe=Math.sin(te),Z=Math.atan(Math.tan(D)*re),he=(B+Z)*$,ue=Math.cos(he),ge=Math.sin(he);Y.set(0,0,0),Y.addScaledVector(q,ge*re),Y.addScaledVector(j,ue),Y.addScaledVector(M,ge*oe),k.copy(W).addScaledVector(Y,s),u.push(k.x,k.y,k.z),a.push(Y.x,Y.y,Y.z),d.push(0,0),H.push(p++)}F.push(H)}let V=F.length-1;for(let G=0;G<V;G++){let H=F[G],$=F[G+1],ee=H.length-1;c.push(H[0],$[1],$[0]);for(let ae=1;ae<=ee;ae++)c.push(H[ae-1],H[ae],$[ae]),c.push(H[ae],$[ae+1],$[ae])}}}};var Km=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters),t=Object.assign(r?.ui??{enabledIndieCorners:!1},n.ui);return{shape:n.shape&&n.shape instanceof Te?n.shape:new Te,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)}),ui:t}}static build(n){let r=n.shape,{width:e,height:t,cornerRadius:o,cornerType:i,depth:s,extrudeBevelSize:l,extrudeBevelSegments:c}=n.parameters,u={x:e*.5,y:t*.5},a={x:-u.x,y:-u.y},d={x:u.x,y:u.y};function p(b,S,A){return S>e&&A>t?Math.min(b*e/S,b*t/A):S>e?b*e/S:A>t?b*t/A:b}let f=[];f[0]=o[0]===0?0:p(o[0],o[0]+o[3],o[0]+o[1]),f[1]=o[1]===0?0:p(o[1],o[1]+o[2],o[1]+o[0]),f[2]=o[2]===0?0:p(o[2],o[2]+o[1],o[2]+o[3]),f[3]=o[3]===0?0:p(o[3],o[3]+o[0],o[3]+o[2]);let m=a.x,h=d.x,y=d.y,g=a.y;r.addPoint(r.createPoint(m,y)),r.addPoint(r.createPoint(h,y)),r.addPoint(r.createPoint(h,g)),r.addPoint(r.createPoint(m,g)),r.isClosed=!0;let v=!0;for(let b=0,S=r.points.length;b<S;b++)r.points[b].roundness=f[b],b>0&&f[b]!==f[b-1]&&(v=!1);v&&(r.roundness=f[0]),r.useCubicForRoundedCorners=i!==1,r.update();let w=Gt.create({shape:r,parameters:{depth:s,extrudeBevelSize:l,extrudeBevelSegments:c}});return Object.assign(w,{userData:{...n,type:"RectangleGeometry"}})}};var Zm=require("three"),Qm=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:r=100,height:e=r,depth:t=r,widthSegments:o=64,heightSegments:i=64,phiStart:s,phiLength:l,thetaStart:c,thetaLength:u}=n.parameters,a=new Zm.SphereGeometry(.5*r,o,i,s,l,c,u);return a.scale(1,e/r,t/r),Object.assign(a,{userData:{...n,type:"SphereGeometry"}})}};var Jm=require("three"),eh=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:0})}}static build(n){let{width:r=100,height:e=r,widthSegments:t=8,heightSegments:o=8}=n.parameters,i=new Jm.PlaneGeometry(r,e,t,o);return i.scale(1,1,1),Object.assign(i,{userData:{...n,type:"PlaneGeometry"}})}};var bo=require("three"),th=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:r,height:e,depth:t,angle:o,cornerRadius:i,cornerSegments:s}=n.parameters,l=new Fc(r,e,t,o,i,s);return Object.assign(l,{userData:{...n,type:"BackdropGeometry"}})}},Fc=class extends bo.BufferGeometry{constructor(r=1,e=1,t=1,o=90,i=10,s=24){super(),this.type="BackdropGeometry";let l=[],c=[],u=[],a=.001;i==0&&(s=1),s=Math.max(1,Math.floor(s)),i=Math.min(i,100),o=Math.min(180-a,o),o*=Math.PI/180;let d=[],p=Math.PI/2,f=(k=0,V=0,G=0)=>new bo.Vector3(k,V,G),m=f(),h=f(),[y,g,v]=[e/2,r/2,t/2],w=-g,b=+g,[S,A,_]=[f(w,-y,+v),f(w,-y,-v),f(w,+y,-v)],x=(k,V=!1)=>Math.sin(k-Math.PI/(1+ +V)),P=(k,V=!1)=>Math.cos(k-Math.PI/(1+ +V));_.y=Math.sin(o)*e-y;let O=Math.cos(o)*e-v,I=S.z-a;o<=p?(_.z=Math.min(O,I),_.z==I&&(_.y-=(O-I)/Math.tan(p-o))):A.z=Math.min(A.z-O-v,S.z-a),m.subVectors(S,A),h.subVectors(_,A);let T=Math.min(m.length(),h.length())*i/100,N=T*Math.tan(o/2),L=T/Math.cos(o/2),U=m.clone().normalize().add(h.normalize()).setLength(L).add(A);m.set(0,x(o,!0),P(o,!0)),d.push([_,m.clone()]);let K=(Math.PI-o)/s;for(let k=0;k<=s;k++){let V=p+o+k*K;m.set(0,Math.sin(V)*N,Math.cos(V)*N),m.add(U),h.set(0,x(V),P(V)),d.push([m.clone(),h.clone()])}d.push([S,f(0,1,0)]);let J=Math.sin(K/2)*N*2,se=d.length-1,z=d[0][0].distanceTo(d[1][0]),W=d[se-1][0].distanceTo(d[se][0]),q=z+J*s+W;d[0].push(1);for(let k=0;k<=s;k++)d[k+1].push(1-(z+k*J)/q);d[se].push(0);let[j,M,B]=d[0],D,F,Y;for(let k=1;k<d.length;k++)[D,F,Y]=d[k],l.push(w,j.y,j.z,w,D.y,D.z,b,j.y,j.z,b,j.y,j.z,w,D.y,D.z,b,D.y,D.z),c.push(0,M.y,M.z,0,F.y,F.z,0,M.y,M.z,0,M.y,M.z,0,F.y,F.z,0,F.y,F.z),u.push(0,B,0,Y,1,B,1,B,0,Y,1,Y),[j,M,B]=[D,F,Y];this.setAttribute("position",new bo.Float32BufferAttribute(l,3)),this.setAttribute("normal",new bo.Float32BufferAttribute(c,3)),this.setAttribute("uv",new bo.Float32BufferAttribute(u,2))}};var rh=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters);return{shape:n.shape&&n.shape instanceof Te?n.shape:new Te,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(n){let{width:r,height:e,innerRadiusPercent:t,spikes:o,cornerRadius:i,angle:s,depth:l,extrudeBevelSize:c,extrudeBevelSegments:u}=n.parameters,a=n.shape,d=r*.5,p=e*.5,f=0,m=0,h=s*Math.PI/360/o,y=Math.PI/2*3*-1,g=d*t/100,v=p*t/100;if(o===3&&t===50){h=2*Math.PI/o;for(let b=0;b<o;b++){let S=h*b,A=f+Math.sin(S)*d,_=m+Math.cos(S)*p;a.addPoint(a.createPoint(A,_))}}else for(let b=0;b<o;b++){let S=f+Math.cos(y)*d,A=m+Math.sin(y)*p;a.addPoint(a.createPoint(S,A)),y+=h,S=f+Math.cos(y)*g,A=m+Math.sin(y)*v,b<=o,a.addPoint(a.createPoint(S,A)),y+=h}a.isClosed=!0;for(let b=0,S=a.points.length;b<S;b++)a.points[b].roundness=i;a.roundness=i,a.update();let w=Gt.create({shape:a,parameters:{roundness:i,depth:l,extrudeBevelSize:c,extrudeBevelSegments:u}});return Object.assign(w,{userData:{...n,type:"StarGeometry"}})}};var oh=require("three"),nh=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,depth:0},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(n){let{width:r,height:e}=n.parameters,t=new oh.PlaneGeometry(r,e);return Object.assign(t,{userData:{...n,type:"TextFrameGeometry"}})}};var ih=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:Math.PI*2,cornerRadius:30,cornerSegments:8},n.parameters),t=Math.abs(e.width),o=Math.abs(e.height??e.width),i=Math.round(Math.abs(e.depth??e.width*.25));return{parameters:Object.assign(e,{width:t,height:o,depth:i})}}static build(n){let{width:r,height:e,depth:t,radialSegments:o,tubularSegments:i,arc:s,cornerRadius:l,cornerSegments:c}=n.parameters,u=Rw(r,e,t,r*.5,s,i,0,0,o,l,c);return u.scale(1,e/r,1),Object.assign(u,{userData:{...n,type:"TorusGeometry"}})}};function Rw(n,r,e,t,o,i,s,l,c,u,a){return[r,e]=[e,r],s=r/2,o/=2*Math.PI,o==1&&(u=0),new ko(!0,n,r,e,t,o,i,s,l,c,u,a)}var sh=require("three"),ah=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),tube:e.tube??e.width*.125})}}static build(n){let{width:r,tube:e,tubularSegments:t,radialSegments:o,p:i,q:s}=n.parameters,l=r*.5;l!==e&&(l-=e);let c=new sh.TorusKnotGeometry(l,e,t,o,i,s);return Object.assign(c,{userData:{...n,type:"TorusKnotGeometry"}})}};var lh=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},n.parameters);return{shape:n.shape&&n.shape instanceof Te?n.shape:new Te,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width*(e.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(e.depth??0)})}}static build(n){let{width:r=100,height:e,cornerRadius:t,depth:o,extrudeBevelSize:i,extrudeBevelSegments:s,isRect:l}=n.parameters,c=n.shape,u=r*.5,a=e*.5;l?(c.addPoint(c.createPoint(-u,a)),c.addPoint(c.createPoint(u,-a)),c.addPoint(c.createPoint(-u,-a))):(c.addPoint(c.createPoint(0,a)),c.addPoint(c.createPoint(u,-a)),c.addPoint(c.createPoint(-u,-a))),c.isClosed=!0;for(let p=0,f=c.points.length;p<f;p++)c.points[p].roundness=t;c.roundness=t,c.update();let d=Gt.create({shape:c,parameters:{roundness:t,depth:o,extrudeBevelSize:i,extrudeBevelSegments:s}});return Object.assign(d,{userData:{...n,type:"TriangleGeometry"}})}};var Ho=require("three"),ch=require("three/examples/jsm/utils/BufferGeometryUtils.js");function Vw(){let n=new Ho.BufferGeometry;return n.setAttribute("position",new Ho.BufferAttribute(new Float32Array([]),3)),n.setIndex(new Ho.BufferAttribute(new Uint16Array([]),1)),n}var jw=12,Fw=1,ei=class extends Ho.BufferGeometry{constructor(e,t){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];this.userData={parameters:e,type:"TextGeometry"};let o=t.getFont(e.font);o?.isLoaded?(this.font=o,this.update(e)):this.updateFont(e.font,t).then(()=>{this.update(e),t?.requestRender()})}async updateFont(e,t){let o=t.getFont(e);o&&(this.font=o,await o.loadingPromise)}update(e){let t=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!t?.isLoaded){console.warn("Cannot update text because its font is not loaded");return}let{width:o,height:i,depth:s,extrudeBevelSize:l,extrudeBevelSegments:c,text:u,textTransform:a}=e,d=a===2?u.toUpperCase():a===3?u.toLowerCase():u,p=Uw(e,t,d),{shapes:f,charWidths:m,charCoords:h}=t.generateShapes(p,e),y=o*.5,g=i*.5,v=f.map(S=>new Te().fromShape(S));this.vectorShapes=v;let w=v.map(S=>Gt.create({shape:S,parameters:{depth:s,extrudeBevelSegments:c,extrudeBevelSize:l,windingRule:s<=0?Be.NONZERO:Be.ODD,subdivisions:this.isLowResolution&&s>0?Fw:jw}})),b=w.length?(0,ch.mergeBufferGeometries)(w):Vw();b.translate(-y,g,0),this.dispose(),this.wrappedText=p,this.charCoords=h,this.charWidths=m,this.deleteAttribute("extrudeNormal"),Object.entries(b.attributes).forEach(([S,A])=>{this.setAttribute(S,A)}),this.setIndex(b.index),this.computeBoundingSphere()}clone(){let e=co(new Ho.BufferGeometry,ei.prototype);return e.copy(this),console.log("CloneGeometry",this,e),e}copy(e){return Object.entries(e.attributes).forEach(([t,o])=>{this.setAttribute(t,o)}),this.setIndex(e.index),this.userData={parameters:{...e.userData.parameters},type:"TextGeometry"},this}async setText(e){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:e})}get text(){return this.userData.parameters.text??""}};function Uw(n,r,e){e=e??n.text;let t=[""],o="";for(let i of e)o+=i,i===" "||i===`
1
+ "use strict";var xg=Object.create;var ea=Object.defineProperty;var vg=Object.getOwnPropertyDescriptor;var bg=Object.getOwnPropertyNames;var Sg=Object.getPrototypeOf,wg=Object.prototype.hasOwnProperty;var ic=(n,r)=>()=>(r||n((r={exports:{}}).exports,r),r.exports),Zd=(n,r)=>{for(var e in r)ea(n,e,{get:r[e],enumerable:!0})},Qd=(n,r,e,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of bg(r))!wg.call(n,o)&&o!==e&&ea(n,o,{get:()=>r[o],enumerable:!(t=vg(r,o))||t.enumerable});return n};var Ri=(n,r,e)=>(e=n!=null?xg(Sg(n)):{},Qd(r||!n||!n.__esModule?ea(e,"default",{value:n,enumerable:!0}):e,n)),_g=n=>Qd(ea({},"__esModule",{value:!0}),n);var bm=ic((Dc,vm)=>{(function(n,r){typeof Dc=="object"?vm.exports=r():typeof define=="function"&&define.amd?define(r):n.Alea=r()})(Dc,function(){"use strict";return n.importState=function(e){var t=new n;return t.importState(e),t},n;function n(){return function(e){var t=0,o=0,i=0,s=1;e.length==0&&(e=[+new Date]);var l=r();t=l(" "),o=l(" "),i=l(" ");for(var c=0;c<e.length;c++)t-=l(e[c]),t<0&&(t+=1),o-=l(e[c]),o<0&&(o+=1),i-=l(e[c]),i<0&&(i+=1);l=null;var u=function(){var a=2091639*t+s*23283064365386963e-26;return t=o,o=i,i=a-(s=a|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[t,o,i,s]},u.importState=function(a){t=+a[0]||0,o=+a[1]||0,i=+a[2]||0,s=+a[3]||0},u}(Array.prototype.slice.call(arguments))}function r(){var e=4022871197,t=function(o){o=o.toString();for(var i=0;i<o.length;i++){e+=o.charCodeAt(i);var s=.02519603282416938*e;e=s>>>0,s-=e,s*=e,e=s>>>0,s-=e,e+=s*4294967296}return(e>>>0)*23283064365386963e-26};return t.version="Mash 0.9",t}})});var Om=ic((il,Pm)=>{(function(n,r){typeof il=="object"&&typeof Pm<"u"?r(il):typeof define=="function"&&define.amd?define(["exports"],r):r((n=typeof globalThis<"u"?globalThis:n||self).SVDJS={})})(il,function(n){"use strict";n.SVD=function(r,e,t,o,i){if(e=e===void 0||e,t=t===void 0||t,i=1e-64/(o=o||Math.pow(2,-52)),!r)throw new TypeError("Matrix a is not defined");var s,l,c,u,a,d,p,f,m,h,y,g,v=r[0].length,w=r.length;if(w<v)throw new TypeError("Invalid matrix: m < n");for(var S=[],b=[],T=[],_=e==="f"?w:v,x=h=p=0;x<w;x++)b[x]=new Array(_).fill(0);for(x=0;x<v;x++)T[x]=new Array(v).fill(0);var C,P=new Array(v).fill(0);for(x=0;x<w;x++)for(s=0;s<v;s++)b[x][s]=r[x][s];for(x=0;x<v;x++){for(S[x]=p,m=0,c=x+1,s=x;s<w;s++)m+=Math.pow(b[s][x],2);if(m<i)p=0;else for(f=(d=b[x][x])*(p=d<0?Math.sqrt(m):-Math.sqrt(m))-m,b[x][x]=d-p,s=c;s<v;s++){for(m=0,l=x;l<w;l++)m+=b[l][x]*b[l][s];for(d=m/f,l=x;l<w;l++)b[l][s]=b[l][s]+d*b[l][x]}for(P[x]=p,m=0,s=c;s<v;s++)m+=Math.pow(b[x][s],2);if(m<i)p=0;else{for(f=(d=b[x][x+1])*(p=d<0?Math.sqrt(m):-Math.sqrt(m))-m,b[x][x+1]=d-p,s=c;s<v;s++)S[s]=b[x][s]/f;for(s=c;s<w;s++){for(m=0,l=c;l<v;l++)m+=b[s][l]*b[x][l];for(l=c;l<v;l++)b[s][l]=b[s][l]+m*S[l]}}h<(y=Math.abs(P[x])+Math.abs(S[x]))&&(h=y)}if(t)for(x=v-1;0<=x;x--){if(p!==0){for(f=b[x][x+1]*p,s=c;s<v;s++)T[s][x]=b[x][s]/f;for(s=c;s<v;s++){for(m=0,l=c;l<v;l++)m+=b[x][l]*T[l][s];for(l=c;l<v;l++)T[l][s]=T[l][s]+m*T[l][x]}}for(s=c;s<v;s++)T[x][s]=0,T[s][x]=0;T[x][x]=1,p=S[x],c=x}if(e){if(e==="f")for(x=v;x<w;x++){for(s=v;s<w;s++)b[x][s]=0;b[x][x]=1}for(x=v-1;0<=x;x--){for(c=x+1,p=P[x],s=c;s<_;s++)b[x][s]=0;if(p!==0){for(f=b[x][x]*p,s=c;s<_;s++){for(m=0,l=c;l<w;l++)m+=b[l][x]*b[l][s];for(d=m/f,l=x;l<w;l++)b[l][s]=b[l][s]+d*b[l][x]}for(s=x;s<w;s++)b[s][x]=b[s][x]/p}else for(s=x;s<w;s++)b[s][x]=0;b[x][x]=b[x][x]+1}}for(o*=h,l=v-1;0<=l;l--)for(var I=0;I<50;I++){for(C=!1,c=l;0<=c;c--){if(Math.abs(S[c])<=o){C=!0;break}if(Math.abs(P[c-1])<=o)break}if(!C){for(a=0,u=c-(m=1),x=c;x<l+1&&(d=m*S[x],S[x]=a*S[x],!(Math.abs(d)<=o));x++)if(p=P[x],P[x]=Math.sqrt(d*d+p*p),a=p/(f=P[x]),m=-d/f,e)for(s=0;s<w;s++)y=b[s][u],g=b[s][x],b[s][u]=y*a+g*m,b[s][x]=-y*m+g*a}if(g=P[l],c===l){if(g<0&&(P[l]=-g,t))for(s=0;s<v;s++)T[s][l]=-T[s][l];break}for(h=P[c],d=(((y=P[l-1])-g)*(y+g)+((p=S[l-1])-(f=S[l]))*(p+f))/(2*f*y),p=Math.sqrt(d*d+1),d=((h-g)*(h+g)+f*(y/(d<0?d-p:d+p)-f))/h,x=c+(m=a=1);x<l+1;x++){if(p=S[x],y=P[x],f=m*p,p*=a,g=Math.sqrt(d*d+f*f),d=h*(a=d/(S[x-1]=g))+p*(m=f/g),p=-h*m+p*a,f=y*m,y*=a,t)for(s=0;s<v;s++)h=T[s][x-1],g=T[s][x],T[s][x-1]=h*a+g*m,T[s][x]=-h*m+g*a;if(g=Math.sqrt(d*d+f*f),d=(a=d/(P[x-1]=g))*p+(m=f/g)*y,h=-m*p+a*y,e)for(s=0;s<w;s++)y=b[s][x-1],g=b[s][x],b[s][x-1]=y*a+g*m,b[s][x]=-y*m+g*a}S[c]=0,S[l]=d,P[l]=h}for(x=0;x<v;x++)P[x]<o&&(P[x]=0);return{u:b,q:P,v:T}},n.VERSION="1.1.1",Object.defineProperty(n,"__esModule",{value:!0})})});var oy=ic(Gl=>{(function(){"use strict";var n=function(){this.init()};n.prototype={init:function(){var a=this||r;return a._counter=1e3,a._html5AudioPool=[],a.html5PoolSize=10,a._codecs={},a._howls=[],a._muted=!1,a._volume=1,a._canPlayEvent="canplaythrough",a._navigator=typeof window<"u"&&window.navigator?window.navigator:null,a.masterGain=null,a.noAudio=!1,a.usingWebAudio=!0,a.autoSuspend=!0,a.ctx=null,a.autoUnlock=!0,a._setup(),a},volume:function(a){var d=this||r;if(a=parseFloat(a),d.ctx||u(),typeof a<"u"&&a>=0&&a<=1){if(d._volume=a,d._muted)return d;d.usingWebAudio&&d.masterGain.gain.setValueAtTime(a,r.ctx.currentTime);for(var p=0;p<d._howls.length;p++)if(!d._howls[p]._webAudio)for(var f=d._howls[p]._getSoundIds(),m=0;m<f.length;m++){var h=d._howls[p]._soundById(f[m]);h&&h._node&&(h._node.volume=h._volume*a)}return d}return d._volume},mute:function(a){var d=this||r;d.ctx||u(),d._muted=a,d.usingWebAudio&&d.masterGain.gain.setValueAtTime(a?0:d._volume,r.ctx.currentTime);for(var p=0;p<d._howls.length;p++)if(!d._howls[p]._webAudio)for(var f=d._howls[p]._getSoundIds(),m=0;m<f.length;m++){var h=d._howls[p]._soundById(f[m]);h&&h._node&&(h._node.muted=a?!0:h._muted)}return d},stop:function(){for(var a=this||r,d=0;d<a._howls.length;d++)a._howls[d].stop();return a},unload:function(){for(var a=this||r,d=a._howls.length-1;d>=0;d--)a._howls[d].unload();return a.usingWebAudio&&a.ctx&&typeof a.ctx.close<"u"&&(a.ctx.close(),a.ctx=null,u()),a},codecs:function(a){return(this||r)._codecs[a.replace(/^x-/,"")]},_setup:function(){var a=this||r;if(a.state=a.ctx&&a.ctx.state||"suspended",a._autoSuspend(),!a.usingWebAudio)if(typeof Audio<"u")try{var d=new Audio;typeof d.oncanplaythrough>"u"&&(a._canPlayEvent="canplay")}catch{a.noAudio=!0}else a.noAudio=!0;try{var d=new Audio;d.muted&&(a.noAudio=!0)}catch{}return a.noAudio||a._setupCodecs(),a},_setupCodecs:function(){var a=this||r,d=null;try{d=typeof Audio<"u"?new Audio:null}catch{return a}if(!d||typeof d.canPlayType!="function")return a;var p=d.canPlayType("audio/mpeg;").replace(/^no$/,""),f=a._navigator?a._navigator.userAgent:"",m=f.match(/OPR\/([0-6].)/g),h=m&&parseInt(m[0].split("/")[1],10)<33,y=f.indexOf("Safari")!==-1&&f.indexOf("Chrome")===-1,g=f.match(/Version\/(.*?) /),v=y&&g&&parseInt(g[1],10)<15;return a._codecs={mp3:!!(!h&&(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:!!(!v&&d.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),webm:!!(!v&&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$/,"")},a},_unlockAudio:function(){var a=this||r;if(!(a._audioUnlocked||!a.ctx)){a._audioUnlocked=!1,a.autoUnlock=!1,!a._mobileUnloaded&&a.ctx.sampleRate!==44100&&(a._mobileUnloaded=!0,a.unload()),a._scratchBuffer=a.ctx.createBuffer(1,1,22050);var d=function(p){for(;a._html5AudioPool.length<a.html5PoolSize;)try{var f=new Audio;f._unlocked=!0,a._releaseHtml5Audio(f)}catch{a.noAudio=!0;break}for(var m=0;m<a._howls.length;m++)if(!a._howls[m]._webAudio)for(var h=a._howls[m]._getSoundIds(),y=0;y<h.length;y++){var g=a._howls[m]._soundById(h[y]);g&&g._node&&!g._node._unlocked&&(g._node._unlocked=!0,g._node.load())}a._autoResume();var v=a.ctx.createBufferSource();v.buffer=a._scratchBuffer,v.connect(a.ctx.destination),typeof v.start>"u"?v.noteOn(0):v.start(0),typeof a.ctx.resume=="function"&&a.ctx.resume(),v.onended=function(){v.disconnect(0),a._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<a._howls.length;w++)a._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),a}},_obtainHtml5Audio:function(){var a=this||r;if(a._html5AudioPool.length)return a._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(a){var d=this||r;return a._unlocked&&d._html5AudioPool.push(a),d},_autoSuspend:function(){var a=this;if(!(!a.autoSuspend||!a.ctx||typeof a.ctx.suspend>"u"||!r.usingWebAudio)){for(var d=0;d<a._howls.length;d++)if(a._howls[d]._webAudio){for(var p=0;p<a._howls[d]._sounds.length;p++)if(!a._howls[d]._sounds[p]._paused)return a}return a._suspendTimer&&clearTimeout(a._suspendTimer),a._suspendTimer=setTimeout(function(){if(!!a.autoSuspend){a._suspendTimer=null,a.state="suspending";var f=function(){a.state="suspended",a._resumeAfterSuspend&&(delete a._resumeAfterSuspend,a._autoResume())};a.ctx.suspend().then(f,f)}},3e4),a}},_autoResume:function(){var a=this;if(!(!a.ctx||typeof a.ctx.resume>"u"||!r.usingWebAudio))return a.state==="running"&&a.ctx.state!=="interrupted"&&a._suspendTimer?(clearTimeout(a._suspendTimer),a._suspendTimer=null):a.state==="suspended"||a.state==="running"&&a.ctx.state==="interrupted"?(a.ctx.resume().then(function(){a.state="running";for(var d=0;d<a._howls.length;d++)a._howls[d]._emit("resume")}),a._suspendTimer&&(clearTimeout(a._suspendTimer),a._suspendTimer=null)):a.state==="suspending"&&(a._resumeAfterSuspend=!0),a}};var r=new n,e=function(a){var d=this;if(!a.src||a.src.length===0){console.error("An array of source files must be passed with any new Howl.");return}d.init(a)};e.prototype={init:function(a){var d=this;return r.ctx||u(),d._autoplay=a.autoplay||!1,d._format=typeof a.format!="string"?a.format:[a.format],d._html5=a.html5||!1,d._muted=a.mute||!1,d._loop=a.loop||!1,d._pool=a.pool||5,d._preload=typeof a.preload=="boolean"||a.preload==="metadata"?a.preload:!0,d._rate=a.rate||1,d._sprite=a.sprite||{},d._src=typeof a.src!="string"?a.src:[a.src],d._volume=a.volume!==void 0?a.volume:1,d._xhr={method:a.xhr&&a.xhr.method?a.xhr.method:"GET",headers:a.xhr&&a.xhr.headers?a.xhr.headers:null,withCredentials:a.xhr&&a.xhr.withCredentials?a.xhr.withCredentials:!1},d._duration=0,d._state="unloaded",d._sounds=[],d._endTimers={},d._queue=[],d._playLock=!1,d._onend=a.onend?[{fn:a.onend}]:[],d._onfade=a.onfade?[{fn:a.onfade}]:[],d._onload=a.onload?[{fn:a.onload}]:[],d._onloaderror=a.onloaderror?[{fn:a.onloaderror}]:[],d._onplayerror=a.onplayerror?[{fn:a.onplayerror}]:[],d._onpause=a.onpause?[{fn:a.onpause}]:[],d._onplay=a.onplay?[{fn:a.onplay}]:[],d._onstop=a.onstop?[{fn:a.onstop}]:[],d._onmute=a.onmute?[{fn:a.onmute}]:[],d._onvolume=a.onvolume?[{fn:a.onvolume}]:[],d._onrate=a.onrate?[{fn:a.onrate}]:[],d._onseek=a.onseek?[{fn:a.onseek}]:[],d._onunlock=a.onunlock?[{fn:a.onunlock}]:[],d._onresume=[],d._webAudio=r.usingWebAudio&&!d._html5,typeof r.ctx<"u"&&r.ctx&&r.autoUnlock&&r._unlockAudio(),r._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 a=this,d=null;if(r.noAudio){a._emit("loaderror",null,"No audio support.");return}typeof a._src=="string"&&(a._src=[a._src]);for(var p=0;p<a._src.length;p++){var f,m;if(a._format&&a._format[p])f=a._format[p];else{if(m=a._src[p],typeof m!="string"){a._emit("loaderror",null,"Non-string found in selected audio sources - ignoring.");continue}f=/^data:audio\/([^;,]+);/i.exec(m),f||(f=/\.([^.]+)$/.exec(m.split("?",1)[0])),f&&(f=f[1].toLowerCase())}if(f||console.warn('No file extension was found. Consider using the "format" property or specify an extension.'),f&&r.codecs(f)){d=a._src[p];break}}if(!d){a._emit("loaderror",null,"No codec support for selected audio sources.");return}return a._src=d,a._state="loading",window.location.protocol==="https:"&&d.slice(0,5)==="http:"&&(a._html5=!0,a._webAudio=!1),new t(a),a._webAudio&&i(a),a},play:function(a,d){var p=this,f=null;if(typeof a=="number")f=a,a=null;else{if(typeof a=="string"&&p._state==="loaded"&&!p._sprite[a])return null;if(typeof a>"u"&&(a="__default",!p._playLock)){for(var m=0,h=0;h<p._sounds.length;h++)p._sounds[h]._paused&&!p._sounds[h]._ended&&(m++,f=p._sounds[h]._id);m===1?a=null:f=null}}var y=f?p._soundById(f):p._inactiveSound();if(!y)return null;if(f&&!a&&(a=y._sprite||"__default"),p._state!=="loaded"){y._sprite=a,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&&r._autoResume();var v=Math.max(0,y._seek>0?y._seek:p._sprite[a][0]/1e3),w=Math.max(0,(p._sprite[a][0]+p._sprite[a][1])/1e3-v),S=w*1e3/Math.abs(y._rate),b=p._sprite[a][0]/1e3,T=(p._sprite[a][0]+p._sprite[a][1])/1e3;y._sprite=a,y._ended=!1;var _=function(){y._paused=!1,y._seek=v,y._start=b,y._stop=T,y._loop=!!(y._loop||p._sprite[a][2])};if(v>=T){p._ended(y);return}var x=y._node;if(p._webAudio){var C=function(){p._playLock=!1,_(),p._refreshBuffer(y);var O=y._muted||p._muted?0:y._volume;x.gain.setValueAtTime(O,r.ctx.currentTime),y._playStart=r.ctx.currentTime,typeof x.bufferSource.start>"u"?y._loop?x.bufferSource.noteGrainOn(0,v,86400):x.bufferSource.noteGrainOn(0,v,w):y._loop?x.bufferSource.start(0,v,86400):x.bufferSource.start(0,v,w),S!==1/0&&(p._endTimers[y._id]=setTimeout(p._ended.bind(p,y),S)),d||setTimeout(function(){p._emit("play",y._id),p._loadQueue()},0)};r.state==="running"&&r.ctx.state!=="interrupted"?C():(p._playLock=!0,p.once("resume",C),p._clearTimer(y._id))}else{var P=function(){x.currentTime=v,x.muted=y._muted||p._muted||r._muted||x.muted,x.volume=y._volume*r.volume(),x.playbackRate=y._rate;try{var O=x.play();if(O&&typeof Promise<"u"&&(O instanceof Promise||typeof O.then=="function")?(p._playLock=!0,_(),O.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,_(),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}a!=="__default"||y._loop?p._endTimers[y._id]=setTimeout(p._ended.bind(p,y),S):(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(V){p._emit("playerror",y._id,V)}};x.src==="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA"&&(x.src=p._src,x.load());var I=window&&window.ejecta||!x.readyState&&r._navigator.isCocoonJS;if(x.readyState>=3||I)P();else{p._playLock=!0,p._state="loading";var A=function(){p._state="loaded",P(),x.removeEventListener(r._canPlayEvent,A,!1)};x.addEventListener(r._canPlayEvent,A,!1),p._clearTimer(y._id)}}return y._id},pause:function(a){var d=this;if(d._state!=="loaded"||d._playLock)return d._queue.push({event:"pause",action:function(){d.pause(a)}}),d;for(var p=d._getSoundIds(a),f=0;f<p.length;f++){d._clearTimer(p[f]);var m=d._soundById(p[f]);if(m&&!m._paused&&(m._seek=d.seek(p[f]),m._rateSeek=0,m._paused=!0,d._stopFade(p[f]),m._node))if(d._webAudio){if(!m._node.bufferSource)continue;typeof m._node.bufferSource.stop>"u"?m._node.bufferSource.noteOff(0):m._node.bufferSource.stop(0),d._cleanBuffer(m._node)}else(!isNaN(m._node.duration)||m._node.duration===1/0)&&m._node.pause();arguments[1]||d._emit("pause",m?m._id:null)}return d},stop:function(a,d){var p=this;if(p._state!=="loaded"||p._playLock)return p._queue.push({event:"stop",action:function(){p.stop(a)}}),p;for(var f=p._getSoundIds(a),m=0;m<f.length;m++){p._clearTimer(f[m]);var h=p._soundById(f[m]);h&&(h._seek=h._start||0,h._rateSeek=0,h._paused=!0,h._ended=!0,p._stopFade(f[m]),h._node&&(p._webAudio?h._node.bufferSource&&(typeof h._node.bufferSource.stop>"u"?h._node.bufferSource.noteOff(0):h._node.bufferSource.stop(0),p._cleanBuffer(h._node)):(!isNaN(h._node.duration)||h._node.duration===1/0)&&(h._node.currentTime=h._start||0,h._node.pause(),h._node.duration===1/0&&p._clearSound(h._node))),d||p._emit("stop",h._id))}return p},mute:function(a,d){var p=this;if(p._state!=="loaded"||p._playLock)return p._queue.push({event:"mute",action:function(){p.mute(a,d)}}),p;if(typeof d>"u")if(typeof a=="boolean")p._muted=a;else return p._muted;for(var f=p._getSoundIds(d),m=0;m<f.length;m++){var h=p._soundById(f[m]);h&&(h._muted=a,h._interval&&p._stopFade(h._id),p._webAudio&&h._node?h._node.gain.setValueAtTime(a?0:h._volume,r.ctx.currentTime):h._node&&(h._node.muted=r._muted?!0:a),p._emit("mute",h._id))}return p},volume:function(){var a=this,d=arguments,p,f;if(d.length===0)return a._volume;if(d.length===1||d.length===2&&typeof d[1]>"u"){var m=a._getSoundIds(),h=m.indexOf(d[0]);h>=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(a._state!=="loaded"||a._playLock)return a._queue.push({event:"volume",action:function(){a.volume.apply(a,d)}}),a;typeof f>"u"&&(a._volume=p),f=a._getSoundIds(f);for(var g=0;g<f.length;g++)y=a._soundById(f[g]),y&&(y._volume=p,d[2]||a._stopFade(f[g]),a._webAudio&&y._node&&!y._muted?y._node.gain.setValueAtTime(p,r.ctx.currentTime):y._node&&!y._muted&&(y._node.volume=p*r.volume()),a._emit("volume",y._id))}else return y=f?a._soundById(f):a._sounds[0],y?y._volume:0;return a},fade:function(a,d,p,f){var m=this;if(m._state!=="loaded"||m._playLock)return m._queue.push({event:"fade",action:function(){m.fade(a,d,p,f)}}),m;a=Math.min(Math.max(0,parseFloat(a)),1),d=Math.min(Math.max(0,parseFloat(d)),1),p=parseFloat(p),m.volume(a,f);for(var h=m._getSoundIds(f),y=0;y<h.length;y++){var g=m._soundById(h[y]);if(g){if(f||m._stopFade(h[y]),m._webAudio&&!g._muted){var v=r.ctx.currentTime,w=v+p/1e3;g._volume=a,g._node.gain.setValueAtTime(a,v),g._node.gain.linearRampToValueAtTime(d,w)}m._startFadeInterval(g,a,d,p,h[y],typeof f>"u")}}return m},_startFadeInterval:function(a,d,p,f,m,h){var y=this,g=d,v=p-d,w=Math.abs(v/.01),S=Math.max(4,w>0?f/w:f),b=Date.now();a._fadeTo=p,a._interval=setInterval(function(){var T=(Date.now()-b)/f;b=Date.now(),g+=v*T,g=Math.round(g*100)/100,v<0?g=Math.max(p,g):g=Math.min(p,g),y._webAudio?a._volume=g:y.volume(g,a._id,!0),h&&(y._volume=g),(p<d&&g<=p||p>d&&g>=p)&&(clearInterval(a._interval),a._interval=null,a._fadeTo=null,y.volume(p,a._id),y._emit("fade",a._id))},S)},_stopFade:function(a){var d=this,p=d._soundById(a);return p&&p._interval&&(d._webAudio&&p._node.gain.cancelScheduledValues(r.ctx.currentTime),clearInterval(p._interval),p._interval=null,d.volume(p._fadeTo,a),p._fadeTo=null,d._emit("fade",a)),d},loop:function(){var a=this,d=arguments,p,f,m;if(d.length===0)return a._loop;if(d.length===1)if(typeof d[0]=="boolean")p=d[0],a._loop=p;else return m=a._soundById(parseInt(d[0],10)),m?m._loop:!1;else d.length===2&&(p=d[0],f=parseInt(d[1],10));for(var h=a._getSoundIds(f),y=0;y<h.length;y++)m=a._soundById(h[y]),m&&(m._loop=p,a._webAudio&&m._node&&m._node.bufferSource&&(m._node.bufferSource.loop=p,p&&(m._node.bufferSource.loopStart=m._start||0,m._node.bufferSource.loopEnd=m._stop,a.playing(h[y])&&(a.pause(h[y],!0),a.play(h[y],!0)))));return a},rate:function(){var a=this,d=arguments,p,f;if(d.length===0)f=a._sounds[0]._id;else if(d.length===1){var m=a._getSoundIds(),h=m.indexOf(d[0]);h>=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(a._state!=="loaded"||a._playLock)return a._queue.push({event:"rate",action:function(){a.rate.apply(a,d)}}),a;typeof f>"u"&&(a._rate=p),f=a._getSoundIds(f);for(var g=0;g<f.length;g++)if(y=a._soundById(f[g]),y){a.playing(f[g])&&(y._rateSeek=a.seek(f[g]),y._playStart=a._webAudio?r.ctx.currentTime:y._playStart),y._rate=p,a._webAudio&&y._node&&y._node.bufferSource?y._node.bufferSource.playbackRate.setValueAtTime(p,r.ctx.currentTime):y._node&&(y._node.playbackRate=p);var v=a.seek(f[g]),w=(a._sprite[y._sprite][0]+a._sprite[y._sprite][1])/1e3-v,S=w*1e3/Math.abs(y._rate);(a._endTimers[f[g]]||!y._paused)&&(a._clearTimer(f[g]),a._endTimers[f[g]]=setTimeout(a._ended.bind(a,y),S)),a._emit("rate",y._id)}}else return y=a._soundById(f),y?y._rate:a._rate;return a},seek:function(){var a=this,d=arguments,p,f;if(d.length===0)a._sounds.length&&(f=a._sounds[0]._id);else if(d.length===1){var m=a._getSoundIds(),h=m.indexOf(d[0]);h>=0?f=parseInt(d[0],10):a._sounds.length&&(f=a._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"&&(a._state!=="loaded"||a._playLock))return a._queue.push({event:"seek",action:function(){a.seek.apply(a,d)}}),a;var y=a._soundById(f);if(y)if(typeof p=="number"&&p>=0){var g=a.playing(f);g&&a.pause(f,!0),y._seek=p,y._ended=!1,a._clearTimer(f),!a._webAudio&&y._node&&!isNaN(y._node.duration)&&(y._node.currentTime=p);var v=function(){g&&a.play(f,!0),a._emit("seek",f)};if(g&&!a._webAudio){var w=function(){a._playLock?setTimeout(w,0):v()};setTimeout(w,0)}else v()}else if(a._webAudio){var S=a.playing(f)?r.ctx.currentTime-y._playStart:0,b=y._rateSeek?y._rateSeek-y._seek:0;return y._seek+(b+S*Math.abs(y._rate))}else return y._node.currentTime;return a},playing:function(a){var d=this;if(typeof a=="number"){var p=d._soundById(a);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(a){var d=this,p=d._duration,f=d._soundById(a);return f&&(p=d._sprite[f._sprite][1]/1e3),p},state:function(){return this._state},unload:function(){for(var a=this,d=a._sounds,p=0;p<d.length;p++)d[p]._paused||a.stop(d[p]._id),a._webAudio||(a._clearSound(d[p]._node),d[p]._node.removeEventListener("error",d[p]._errorFn,!1),d[p]._node.removeEventListener(r._canPlayEvent,d[p]._loadFn,!1),d[p]._node.removeEventListener("ended",d[p]._endFn,!1),r._releaseHtml5Audio(d[p]._node)),delete d[p]._node,a._clearTimer(d[p]._id);var f=r._howls.indexOf(a);f>=0&&r._howls.splice(f,1);var m=!0;for(p=0;p<r._howls.length;p++)if(r._howls[p]._src===a._src||a._src.indexOf(r._howls[p]._src)>=0){m=!1;break}return o&&m&&delete o[a._src],r.noAudio=!1,a._state="unloaded",a._sounds=[],a=null,null},on:function(a,d,p,f){var m=this,h=m["_on"+a];return typeof d=="function"&&h.push(f?{id:p,fn:d,once:f}:{id:p,fn:d}),m},off:function(a,d,p){var f=this,m=f["_on"+a],h=0;if(typeof d=="number"&&(p=d,d=null),d||p)for(h=0;h<m.length;h++){var y=p===m[h].id;if(d===m[h].fn&&y||!d&&y){m.splice(h,1);break}}else if(a)f["_on"+a]=[];else{var g=Object.keys(f);for(h=0;h<g.length;h++)g[h].indexOf("_on")===0&&Array.isArray(f[g[h]])&&(f[g[h]]=[])}return f},once:function(a,d,p){var f=this;return f.on(a,d,p,1),f},_emit:function(a,d,p){for(var f=this,m=f["_on"+a],h=m.length-1;h>=0;h--)(!m[h].id||m[h].id===d||a==="load")&&(setTimeout(function(y){y.call(this,d,p)}.bind(f,m[h].fn),0),m[h].once&&f.off(a,m[h].fn,m[h].id));return f._loadQueue(a),f},_loadQueue:function(a){var d=this;if(d._queue.length>0){var p=d._queue[0];p.event===a&&(d._queue.shift(),d._loadQueue()),a||p.action()}return d},_ended:function(a){var d=this,p=a._sprite;if(!d._webAudio&&a._node&&!a._node.paused&&!a._node.ended&&a._node.currentTime<a._stop)return setTimeout(d._ended.bind(d,a),100),d;var f=!!(a._loop||d._sprite[p][2]);if(d._emit("end",a._id),!d._webAudio&&f&&d.stop(a._id,!0).play(a._id),d._webAudio&&f){d._emit("play",a._id),a._seek=a._start||0,a._rateSeek=0,a._playStart=r.ctx.currentTime;var m=(a._stop-a._start)*1e3/Math.abs(a._rate);d._endTimers[a._id]=setTimeout(d._ended.bind(d,a),m)}return d._webAudio&&!f&&(a._paused=!0,a._ended=!0,a._seek=a._start||0,a._rateSeek=0,d._clearTimer(a._id),d._cleanBuffer(a._node),r._autoSuspend()),!d._webAudio&&!f&&d.stop(a._id,!0),d},_clearTimer:function(a){var d=this;if(d._endTimers[a]){if(typeof d._endTimers[a]!="function")clearTimeout(d._endTimers[a]);else{var p=d._soundById(a);p&&p._node&&p._node.removeEventListener("ended",d._endTimers[a],!1)}delete d._endTimers[a]}return d},_soundById:function(a){for(var d=this,p=0;p<d._sounds.length;p++)if(a===d._sounds[p]._id)return d._sounds[p];return null},_inactiveSound:function(){var a=this;a._drain();for(var d=0;d<a._sounds.length;d++)if(a._sounds[d]._ended)return a._sounds[d].reset();return new t(a)},_drain:function(){var a=this,d=a._pool,p=0,f=0;if(!(a._sounds.length<d)){for(f=0;f<a._sounds.length;f++)a._sounds[f]._ended&&p++;for(f=a._sounds.length-1;f>=0;f--){if(p<=d)return;a._sounds[f]._ended&&(a._webAudio&&a._sounds[f]._node&&a._sounds[f]._node.disconnect(0),a._sounds.splice(f,1),p--)}}},_getSoundIds:function(a){var d=this;if(typeof a>"u"){for(var p=[],f=0;f<d._sounds.length;f++)p.push(d._sounds[f]._id);return p}else return[a]},_refreshBuffer:function(a){var d=this;return a._node.bufferSource=r.ctx.createBufferSource(),a._node.bufferSource.buffer=o[d._src],a._panner?a._node.bufferSource.connect(a._panner):a._node.bufferSource.connect(a._node),a._node.bufferSource.loop=a._loop,a._loop&&(a._node.bufferSource.loopStart=a._start||0,a._node.bufferSource.loopEnd=a._stop||0),a._node.bufferSource.playbackRate.setValueAtTime(a._rate,r.ctx.currentTime),d},_cleanBuffer:function(a){var d=this,p=r._navigator&&r._navigator.vendor.indexOf("Apple")>=0;if(r._scratchBuffer&&a.bufferSource&&(a.bufferSource.onended=null,a.bufferSource.disconnect(0),p))try{a.bufferSource.buffer=r._scratchBuffer}catch{}return a.bufferSource=null,d},_clearSound:function(a){var d=/MSIE |Trident\//.test(r._navigator&&r._navigator.userAgent);d||(a.src="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA")}};var t=function(a){this._parent=a,this.init()};t.prototype={init:function(){var a=this,d=a._parent;return a._muted=d._muted,a._loop=d._loop,a._volume=d._volume,a._rate=d._rate,a._seek=0,a._paused=!0,a._ended=!0,a._sprite="__default",a._id=++r._counter,d._sounds.push(a),a.create(),a},create:function(){var a=this,d=a._parent,p=r._muted||a._muted||a._parent._muted?0:a._volume;return d._webAudio?(a._node=typeof r.ctx.createGain>"u"?r.ctx.createGainNode():r.ctx.createGain(),a._node.gain.setValueAtTime(p,r.ctx.currentTime),a._node.paused=!0,a._node.connect(r.masterGain)):r.noAudio||(a._node=r._obtainHtml5Audio(),a._errorFn=a._errorListener.bind(a),a._node.addEventListener("error",a._errorFn,!1),a._loadFn=a._loadListener.bind(a),a._node.addEventListener(r._canPlayEvent,a._loadFn,!1),a._endFn=a._endListener.bind(a),a._node.addEventListener("ended",a._endFn,!1),a._node.src=d._src,a._node.preload=d._preload===!0?"auto":d._preload,a._node.volume=p*r.volume(),a._node.load()),a},reset:function(){var a=this,d=a._parent;return a._muted=d._muted,a._loop=d._loop,a._volume=d._volume,a._rate=d._rate,a._seek=0,a._rateSeek=0,a._paused=!0,a._ended=!0,a._sprite="__default",a._id=++r._counter,a},_errorListener:function(){var a=this;a._parent._emit("loaderror",a._id,a._node.error?a._node.error.code:0),a._node.removeEventListener("error",a._errorFn,!1)},_loadListener:function(){var a=this,d=a._parent;d._duration=Math.ceil(a._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()),a._node.removeEventListener(r._canPlayEvent,a._loadFn,!1)},_endListener:function(){var a=this,d=a._parent;d._duration===1/0&&(d._duration=Math.ceil(a._node.duration*10)/10,d._sprite.__default[1]===1/0&&(d._sprite.__default[1]=d._duration*1e3),d._ended(a)),a._node.removeEventListener("ended",a._endFn,!1)}};var o={},i=function(a){var d=a._src;if(o[d]){a._duration=o[d].duration,c(a);return}if(/^data:[^;]+;base64,/.test(d)){for(var p=atob(d.split(",")[1]),f=new Uint8Array(p.length),m=0;m<p.length;++m)f[m]=p.charCodeAt(m);l(f.buffer,a)}else{var h=new XMLHttpRequest;h.open(a._xhr.method,d,!0),h.withCredentials=a._xhr.withCredentials,h.responseType="arraybuffer",a._xhr.headers&&Object.keys(a._xhr.headers).forEach(function(y){h.setRequestHeader(y,a._xhr.headers[y])}),h.onload=function(){var y=(h.status+"")[0];if(y!=="0"&&y!=="2"&&y!=="3"){a._emit("loaderror",null,"Failed loading audio file with status: "+h.status+".");return}l(h.response,a)},h.onerror=function(){a._webAudio&&(a._html5=!0,a._webAudio=!1,a._sounds=[],delete o[d],a.load())},s(h)}},s=function(a){try{a.send()}catch{a.onerror()}},l=function(a,d){var p=function(){d._emit("loaderror",null,"Decoding audio data failed.")},f=function(m){m&&d._sounds.length>0?(o[d._src]=m,c(d,m)):p()};typeof Promise<"u"&&r.ctx.decodeAudioData.length===1?r.ctx.decodeAudioData(a).then(f).catch(p):r.ctx.decodeAudioData(a,f,p)},c=function(a,d){d&&!a._duration&&(a._duration=d.duration),Object.keys(a._sprite).length===0&&(a._sprite={__default:[0,a._duration*1e3]}),a._state!=="loaded"&&(a._state="loaded",a._emit("load"),a._loadQueue())},u=function(){if(!!r.usingWebAudio){try{typeof AudioContext<"u"?r.ctx=new AudioContext:typeof webkitAudioContext<"u"?r.ctx=new webkitAudioContext:r.usingWebAudio=!1}catch{r.usingWebAudio=!1}r.ctx||(r.usingWebAudio=!1);var a=/iP(hone|od|ad)/.test(r._navigator&&r._navigator.platform),d=r._navigator&&r._navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/),p=d?parseInt(d[1],10):null;if(a&&p&&p<9){var f=/safari/.test(r._navigator&&r._navigator.userAgent.toLowerCase());r._navigator&&!f&&(r.usingWebAudio=!1)}r.usingWebAudio&&(r.masterGain=typeof r.ctx.createGain>"u"?r.ctx.createGainNode():r.ctx.createGain(),r.masterGain.gain.setValueAtTime(r._muted?0:r._volume,r.ctx.currentTime),r.masterGain.connect(r.ctx.destination)),r._setup()}};typeof define=="function"&&define.amd&&define([],function(){return{Howler:r,Howl:e}}),typeof Gl<"u"&&(Gl.Howler=r,Gl.Howl=e),typeof global<"u"?(global.HowlerGlobal=n,global.Howler=r,global.Howl=e,global.Sound=t):typeof window<"u"&&(window.HowlerGlobal=n,window.Howler=r,window.Howl=e,window.Sound=t)})();(function(){"use strict";HowlerGlobal.prototype._pos=[0,0,0],HowlerGlobal.prototype._orientation=[0,0,-1,0,1,0],HowlerGlobal.prototype.stereo=function(r){var e=this;if(!e.ctx||!e.ctx.listener)return e;for(var t=e._howls.length-1;t>=0;t--)e._howls[t].stereo(r);return e},HowlerGlobal.prototype.pos=function(r,e,t){var o=this;if(!o.ctx||!o.ctx.listener)return o;if(e=typeof e!="number"?o._pos[1]:e,t=typeof t!="number"?o._pos[2]:t,typeof r=="number")o._pos=[r,e,t],typeof o.ctx.listener.positionX<"u"?(o.ctx.listener.positionX.setTargetAtTime(o._pos[0],Howler.ctx.currentTime,.1),o.ctx.listener.positionY.setTargetAtTime(o._pos[1],Howler.ctx.currentTime,.1),o.ctx.listener.positionZ.setTargetAtTime(o._pos[2],Howler.ctx.currentTime,.1)):o.ctx.listener.setPosition(o._pos[0],o._pos[1],o._pos[2]);else return o._pos;return o},HowlerGlobal.prototype.orientation=function(r,e,t,o,i,s){var l=this;if(!l.ctx||!l.ctx.listener)return l;var c=l._orientation;if(e=typeof e!="number"?c[1]:e,t=typeof t!="number"?c[2]:t,o=typeof o!="number"?c[3]:o,i=typeof i!="number"?c[4]:i,s=typeof s!="number"?c[5]:s,typeof r=="number")l._orientation=[r,e,t,o,i,s],typeof l.ctx.listener.forwardX<"u"?(l.ctx.listener.forwardX.setTargetAtTime(r,Howler.ctx.currentTime,.1),l.ctx.listener.forwardY.setTargetAtTime(e,Howler.ctx.currentTime,.1),l.ctx.listener.forwardZ.setTargetAtTime(t,Howler.ctx.currentTime,.1),l.ctx.listener.upX.setTargetAtTime(o,Howler.ctx.currentTime,.1),l.ctx.listener.upY.setTargetAtTime(i,Howler.ctx.currentTime,.1),l.ctx.listener.upZ.setTargetAtTime(s,Howler.ctx.currentTime,.1)):l.ctx.listener.setOrientation(r,e,t,o,i,s);else return c;return l},Howl.prototype.init=function(r){return function(e){var t=this;return t._orientation=e.orientation||[1,0,0],t._stereo=e.stereo||null,t._pos=e.pos||null,t._pannerAttr={coneInnerAngle:typeof e.coneInnerAngle<"u"?e.coneInnerAngle:360,coneOuterAngle:typeof e.coneOuterAngle<"u"?e.coneOuterAngle:360,coneOuterGain:typeof e.coneOuterGain<"u"?e.coneOuterGain:0,distanceModel:typeof e.distanceModel<"u"?e.distanceModel:"inverse",maxDistance:typeof e.maxDistance<"u"?e.maxDistance:1e4,panningModel:typeof e.panningModel<"u"?e.panningModel:"HRTF",refDistance:typeof e.refDistance<"u"?e.refDistance:1,rolloffFactor:typeof e.rolloffFactor<"u"?e.rolloffFactor:1},t._onstereo=e.onstereo?[{fn:e.onstereo}]:[],t._onpos=e.onpos?[{fn:e.onpos}]:[],t._onorientation=e.onorientation?[{fn:e.onorientation}]:[],r.call(this,e)}}(Howl.prototype.init),Howl.prototype.stereo=function(r,e){var t=this;if(!t._webAudio)return t;if(t._state!=="loaded")return t._queue.push({event:"stereo",action:function(){t.stereo(r,e)}}),t;var o=typeof Howler.ctx.createStereoPanner>"u"?"spatial":"stereo";if(typeof e>"u")if(typeof r=="number")t._stereo=r,t._pos=[r,0,0];else return t._stereo;for(var i=t._getSoundIds(e),s=0;s<i.length;s++){var l=t._soundById(i[s]);if(l)if(typeof r=="number")l._stereo=r,l._pos=[r,0,0],l._node&&(l._pannerAttr.panningModel="equalpower",(!l._panner||!l._panner.pan)&&n(l,o),o==="spatial"?typeof l._panner.positionX<"u"?(l._panner.positionX.setValueAtTime(r,Howler.ctx.currentTime),l._panner.positionY.setValueAtTime(0,Howler.ctx.currentTime),l._panner.positionZ.setValueAtTime(0,Howler.ctx.currentTime)):l._panner.setPosition(r,0,0):l._panner.pan.setValueAtTime(r,Howler.ctx.currentTime)),t._emit("stereo",l._id);else return l._stereo}return t},Howl.prototype.pos=function(r,e,t,o){var i=this;if(!i._webAudio)return i;if(i._state!=="loaded")return i._queue.push({event:"pos",action:function(){i.pos(r,e,t,o)}}),i;if(e=typeof e!="number"?0:e,t=typeof t!="number"?-.5:t,typeof o>"u")if(typeof r=="number")i._pos=[r,e,t];else return i._pos;for(var s=i._getSoundIds(o),l=0;l<s.length;l++){var c=i._soundById(s[l]);if(c)if(typeof r=="number")c._pos=[r,e,t],c._node&&((!c._panner||c._panner.pan)&&n(c,"spatial"),typeof c._panner.positionX<"u"?(c._panner.positionX.setValueAtTime(r,Howler.ctx.currentTime),c._panner.positionY.setValueAtTime(e,Howler.ctx.currentTime),c._panner.positionZ.setValueAtTime(t,Howler.ctx.currentTime)):c._panner.setPosition(r,e,t)),i._emit("pos",c._id);else return c._pos}return i},Howl.prototype.orientation=function(r,e,t,o){var i=this;if(!i._webAudio)return i;if(i._state!=="loaded")return i._queue.push({event:"orientation",action:function(){i.orientation(r,e,t,o)}}),i;if(e=typeof e!="number"?i._orientation[1]:e,t=typeof t!="number"?i._orientation[2]:t,typeof o>"u")if(typeof r=="number")i._orientation=[r,e,t];else return i._orientation;for(var s=i._getSoundIds(o),l=0;l<s.length;l++){var c=i._soundById(s[l]);if(c)if(typeof r=="number")c._orientation=[r,e,t],c._node&&(c._panner||(c._pos||(c._pos=i._pos||[0,0,-.5]),n(c,"spatial")),typeof c._panner.orientationX<"u"?(c._panner.orientationX.setValueAtTime(r,Howler.ctx.currentTime),c._panner.orientationY.setValueAtTime(e,Howler.ctx.currentTime),c._panner.orientationZ.setValueAtTime(t,Howler.ctx.currentTime)):c._panner.setOrientation(r,e,t)),i._emit("orientation",c._id);else return c._orientation}return i},Howl.prototype.pannerAttr=function(){var r=this,e=arguments,t,o,i;if(!r._webAudio)return r;if(e.length===0)return r._pannerAttr;if(e.length===1)if(typeof e[0]=="object")t=e[0],typeof o>"u"&&(t.pannerAttr||(t.pannerAttr={coneInnerAngle:t.coneInnerAngle,coneOuterAngle:t.coneOuterAngle,coneOuterGain:t.coneOuterGain,distanceModel:t.distanceModel,maxDistance:t.maxDistance,refDistance:t.refDistance,rolloffFactor:t.rolloffFactor,panningModel:t.panningModel}),r._pannerAttr={coneInnerAngle:typeof t.pannerAttr.coneInnerAngle<"u"?t.pannerAttr.coneInnerAngle:r._coneInnerAngle,coneOuterAngle:typeof t.pannerAttr.coneOuterAngle<"u"?t.pannerAttr.coneOuterAngle:r._coneOuterAngle,coneOuterGain:typeof t.pannerAttr.coneOuterGain<"u"?t.pannerAttr.coneOuterGain:r._coneOuterGain,distanceModel:typeof t.pannerAttr.distanceModel<"u"?t.pannerAttr.distanceModel:r._distanceModel,maxDistance:typeof t.pannerAttr.maxDistance<"u"?t.pannerAttr.maxDistance:r._maxDistance,refDistance:typeof t.pannerAttr.refDistance<"u"?t.pannerAttr.refDistance:r._refDistance,rolloffFactor:typeof t.pannerAttr.rolloffFactor<"u"?t.pannerAttr.rolloffFactor:r._rolloffFactor,panningModel:typeof t.pannerAttr.panningModel<"u"?t.pannerAttr.panningModel:r._panningModel});else return i=r._soundById(parseInt(e[0],10)),i?i._pannerAttr:r._pannerAttr;else e.length===2&&(t=e[0],o=parseInt(e[1],10));for(var s=r._getSoundIds(o),l=0;l<s.length;l++)if(i=r._soundById(s[l]),i){var c=i._pannerAttr;c={coneInnerAngle:typeof t.coneInnerAngle<"u"?t.coneInnerAngle:c.coneInnerAngle,coneOuterAngle:typeof t.coneOuterAngle<"u"?t.coneOuterAngle:c.coneOuterAngle,coneOuterGain:typeof t.coneOuterGain<"u"?t.coneOuterGain:c.coneOuterGain,distanceModel:typeof t.distanceModel<"u"?t.distanceModel:c.distanceModel,maxDistance:typeof t.maxDistance<"u"?t.maxDistance:c.maxDistance,refDistance:typeof t.refDistance<"u"?t.refDistance:c.refDistance,rolloffFactor:typeof t.rolloffFactor<"u"?t.rolloffFactor:c.rolloffFactor,panningModel:typeof t.panningModel<"u"?t.panningModel:c.panningModel};var u=i._panner;u?(u.coneInnerAngle=c.coneInnerAngle,u.coneOuterAngle=c.coneOuterAngle,u.coneOuterGain=c.coneOuterGain,u.distanceModel=c.distanceModel,u.maxDistance=c.maxDistance,u.refDistance=c.refDistance,u.rolloffFactor=c.rolloffFactor,u.panningModel=c.panningModel):(i._pos||(i._pos=r._pos||[0,0,-.5]),n(i,"spatial"))}return r},Sound.prototype.init=function(r){return function(){var e=this,t=e._parent;e._orientation=t._orientation,e._stereo=t._stereo,e._pos=t._pos,e._pannerAttr=t._pannerAttr,r.call(this),e._stereo?t.stereo(e._stereo):e._pos&&t.pos(e._pos[0],e._pos[1],e._pos[2],e._id)}}(Sound.prototype.init),Sound.prototype.reset=function(r){return function(){var e=this,t=e._parent;return e._orientation=t._orientation,e._stereo=t._stereo,e._pos=t._pos,e._pannerAttr=t._pannerAttr,e._stereo?t.stereo(e._stereo):e._pos?t.pos(e._pos[0],e._pos[1],e._pos[2],e._id):e._panner&&(e._panner.disconnect(0),e._panner=void 0,t._refreshBuffer(e)),r.call(this)}}(Sound.prototype.reset);var n=function(r,e){e=e||"spatial",e==="spatial"?(r._panner=Howler.ctx.createPanner(),r._panner.coneInnerAngle=r._pannerAttr.coneInnerAngle,r._panner.coneOuterAngle=r._pannerAttr.coneOuterAngle,r._panner.coneOuterGain=r._pannerAttr.coneOuterGain,r._panner.distanceModel=r._pannerAttr.distanceModel,r._panner.maxDistance=r._pannerAttr.maxDistance,r._panner.refDistance=r._pannerAttr.refDistance,r._panner.rolloffFactor=r._pannerAttr.rolloffFactor,r._panner.panningModel=r._pannerAttr.panningModel,typeof r._panner.positionX<"u"?(r._panner.positionX.setValueAtTime(r._pos[0],Howler.ctx.currentTime),r._panner.positionY.setValueAtTime(r._pos[1],Howler.ctx.currentTime),r._panner.positionZ.setValueAtTime(r._pos[2],Howler.ctx.currentTime)):r._panner.setPosition(r._pos[0],r._pos[1],r._pos[2]),typeof r._panner.orientationX<"u"?(r._panner.orientationX.setValueAtTime(r._orientation[0],Howler.ctx.currentTime),r._panner.orientationY.setValueAtTime(r._orientation[1],Howler.ctx.currentTime),r._panner.orientationZ.setValueAtTime(r._orientation[2],Howler.ctx.currentTime)):r._panner.setOrientation(r._orientation[0],r._orientation[1],r._orientation[2])):(r._panner=Howler.ctx.createStereoPanner(),r._panner.pan.setValueAtTime(r._stereo,Howler.ctx.currentTime)),r._panner.connect(r._node),r._paused||r._parent.pause(r._id,!0).play(r._id,!0)}})()});var vT={};Zd(vT,{default:()=>ec});module.exports=_g(vT);var tc=require("three");var Ge=class{modifyById(r,e){let t=this;if(t[r]===void 0)throw new Error("not expected");{let i={...t,[r]:e};return Object.setPrototypeOf(i,Ge.prototype),i}}add(r,e){return this.runOp({type:1,id:r,data:e})?.data??this}runOp(r){let e=this;if(r.type===1){let t=e[r.id],o;t===void 0?o={type:2,id:r.id}:o={type:1,id:r.id,data:t};let{id:i,data:s}=r,l={...e,[i]:s};return Object.setPrototypeOf(l,Ge.prototype),{data:l,actual:r,reverse:o}}else if(r.type===2){let{id:t}=r,o=e[t];if(o===void 0)return null;{let i={...e};return Object.setPrototypeOf(i,Ge.prototype),delete i[t],{data:i,actual:r,reverse:{type:1,id:t,data:o}}}}return null}};function Vi(n){if(n.deepFreeze!==void 0){n.deepFreeze(n);return}let r=Object.getOwnPropertyNames(n);for(let e of r){let t=n[e];t&&typeof t=="object"&&Vi(t)}return Object.freeze(n)}function Jd(n,r){let e=0;for(;e<n.length&&e<r.length;){if(n[e]<r[e])return-1;if(n[e]>r[e])return 1;e+=1}return e!==r.length?-1:e!==n.length?1:0}var ln=class extends Error{};function ta(n){let r={...n};return Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r}function _r(n,r,e){if(n===void 0?r===void 0?(n=0,r=10):n=r-10:r===void 0&&(r=n+10),n>r){let i=n;n=r,r=i}let t=[],o=1/(e+1);for(let i=0;i<e;i++){let s=n+(r-n)*(i+.75+Math.random()*.5)*o;t.push(s)}return t}function cn(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 eu(){return typeof process<"u"}function tu(n,r){for(let e of n)r(e.id,e.data)!==!0&&tu(e.children,r)}function ru(n,r){if(r(n.id,n.data)!==!0)for(let e of n.children)ru(e,r)}var et=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,et.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Vi(this[e]),e++}fillCaches0(e,t){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,t);for(let o of e.children)this.fillCaches0(o,e.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let e of this)this.fillCaches0(e,null)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}nonExistOrDescendantOf(e,t){if(!this.has(e))return!0;for(;e;){let o=this.parent(e);if(o===t)return!0;e=o}return!1}isDescendantOf(e,t){for(;e;){let o=this.parent(e);if(o===t)return!0;e=o}return!1}data(e){return this.get(e)?.data}has(e){return this.childrenOf(e)!==void 0}get(e){return this.fillCaches(),this.objCaches.get(e)}childrenOf(e){return e===null?this:this.get(e)?.children}traverseFrom(e,t){if(e===null)this.traverse(t);else{let o=this.get(e);o&&ru(o,t)}}traverse(e){tu(this,e)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(e){return this.fillCaches(),this.parentCaches.get(e)}childrenArray(e){return e===null?this:this.get(e).children}modifyById(e,t){if(this.get(e)===void 0)throw new Error("not expected");{let i=this.parent(e),s=this.childrenArray(i),l=s.findIndex(a=>a.id===e);if(l<0)throw new Error("not expected");let c=s[l];return s=[...s],s[l]={...c,data:t},this.modifyArrayBy(i,s)}}modifyArrayBy(e,t){let o=e,i=t;for(;o!==null;){let l=i,c=o;if(o=this.parent(o),o===void 0)throw new Error;i=this.childrenArray(o);let u=i.findIndex(a=>a.id===c);if(u<0)throw new Error;i=[...i],i[u]={...i[u],children:l}}Object.setPrototypeOf(i,et.prototype);let s=i;return s.fillCaches(),s}runOp(e){switch(e.type){case 7:return this.addOp(e);case 8:return this.deleteOp(e);case 9:return this.moveOp(e)}return null}checkDuplicatedIdRec({id:e,children:t}){if(this.get(e)!==void 0)return!0;for(let o of t)if(this.checkDuplicatedIdRec(o))return!0;return!1}addOp(e){let{parent:t,fi:o,id:i,data:s,children:l}=e;if(t!==null&&this.get(t)===void 0)return null;if(this.checkDuplicatedIdRec(e))return null;{let c=t,u=this.childrenArray(c),a={fi:o,id:i,data:s,children:l};return u=[...u,a],u.sort((p,f)=>p.fi-f.fi),e.localIndex=u.indexOf(a),{data:this.modifyArrayBy(c,u),actual:e,reverse:{type:8,id:i}}}}deleteOp(e){let{id:t}=e;if(this.get(t)===null)return null;{let o=this.parent(t);if(o===void 0)return null;let i=this.childrenArray(o),s=i.findIndex(u=>u.id===t);e.localIndex=s,i=[...i];let l=i.splice(s,1)[0];return{data:this.modifyArrayBy(o,i),actual:e,reverse:{type:7,...l,parent:o}}}}moveOp(e){let{parent:t,fi:o,id:i}=e;if(t!==null&&this.get(t)===void 0)return this.deleteOp({type:8,id:i});if(t!==null){let f=t;for(;f!==null;){if(f===void 0)throw new Error;if(f===i)throw new ln("cyclic tree");f=this.parent(f)}}let s=this.parent(i);if(s===void 0)return null;let l=s,c=this.childrenArray(s),u=c.findIndex(f=>f.id===i);c=[...c];let a=c.splice(u,1)[0],d=this.modifyArrayBy(s,c);s=t,c=d.childrenArray(s);let p=a.fi;return a={...a,fi:o},c=[...c,a],c.sort((f,m)=>f.fi-m.fi),e.localIndex=c.indexOf(a),d=d.modifyArrayBy(s,c),{data:d,actual:e,reverse:{type:9,parent:l,fi:p,id:i}}}previous(e,t){if(t===null){let i=this.childrenArray(e);return i.length===0?null:i[i.length-1].id}let o=null;for(let i of this.childrenArray(e)){if(i.id===t)return o;o=i.id}return null}traverseSortNext(e){let t=this.parent(e);if(t!==void 0){let o=this.childrenArray(t),i=o.findIndex(s=>s.id===e)+1;if(i<o.length)return o[i].id;if(t)return this.traverseSortNext(t)}}sortNext(e){let t=this.childrenArray(e);return t.length>0?t[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let t=this.childrenArray(e);return t.length>0?this.traverseSortPrevious(t[t.length-1].id):e}sortPrevious(e){let t=this.parent(e);if(t!==void 0){let o=this.childrenArray(t),i=o.findIndex(s=>s.id===e)-1;return i>=0?this.traverseSortPrevious(o[i].id):t}}getAllSorted(e){let t=[];for(let o of e){let i=this.getWithSortKey(o.id);i!==void 0&&t.push({...o,...i})}t.sort((o,i)=>Jd(o.sortKey,i.sortKey));for(let o of t)delete o.sortKey;return t}getWithSortKey(e){var t=e;let o=[],i=this.get(t),s=i;if(i!==void 0){for(;t;)o.splice(0,0,i.fi),t=this.parent(t),t!==null&&(i=this.get(t));return{...s,sortKey:o}}}insertBeforeHelper(e,t,o){return this.insertAfterHelper(e,this.previous(e,t),o)}insertAfterHelper(e,t,o){let i=this.childrenArray(e);if(t===null){if(i.length===0)return _r(0,o,o);{let s=i[0].fi;return _r(s-o,s,o)}}else{let s=this.get(t);if(s===void 0||this.parent(t)!==e)throw new Error("illegal args");let l=i.find(c=>c.fi>s.fi);if(l===void 0){let c=i[i.length-1].fi;return _r(c,c+o,o)}else return _r(s.fi,l.fi,o)}}};var dn;(r=>{function n(e,t){if(t.type!==0)return null;if(Array.isArray(e)){let o=t.props,i={},s=[...e],l=!1;if(o)for(let c of Object.keys(o)){let u=parseInt(c);if(isNaN(u))throw new Error("wrong index");i[c]=s[u],s[u]=o[c],l=!0}return l?{data:s,actual:t,reverse:{type:0,props:i}}:null}else{let o=t.props,i={},s={...e},l=!1;if(o)for(let c of Object.keys(o)){i[c]=s[c];let u=o[c];u===void 0?delete s[c]:s[c]=u,l=!0}return l?{data:s,actual:t,reverse:{type:0,props:i}}:null}}r.runOp=n})(dn||(dn={}));var ge=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,ge.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Vi(this[e]),e++}fillCaches0(e){this.objCaches.set(e.id,e)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,Object.getOwnPropertyDescriptor(this,"objCaches").enumerable=!1;for(let e of this)this.fillCaches0(e)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}data(e){return this.get(e)?.data}get(e){return this.fillCaches(),this.objCaches.get(e)}modifyById(e,t){if(this.get(e)===void 0)throw new Error("not expected");{let i=this,s=i.findIndex(u=>u.id===e);if(s<0)throw new Error("not expected");let l=i[s];return i=[...i],i[s]={...l,data:t},this.modifyArrayBy(i)}}modifyArrayBy(e){Object.setPrototypeOf(e,ge.prototype);let t=e;return eu()||t.fillCaches(),t}runOp(e){switch(e.type){case 4:return this.addOp(e);case 5:return this.deleteOp(e);case 6:return this.moveOp(e)}return null}addOp(e){let{fi:t,id:o,data:i}=e,s=this,l={fi:t,id:o,data:i};return s=[...s,l],s.sort((u,a)=>u.fi-a.fi),e.localIndex=s.indexOf(l),{data:this.modifyArrayBy(s),actual:e,reverse:{type:5,id:o}}}deleteOp(e){let{id:t}=e,o=this,i=o.findIndex(c=>c.id===t);if(i===-1)return null;e.localIndex=i,o=[...o];let s=o.splice(i,1)[0];return{data:this.modifyArrayBy(o),actual:e,reverse:{type:4,...s}}}moveOp(e){let{fi:t,id:o}=e,i=this;i=[...i];let s=i.findIndex(a=>a.id===o);if(s===-1)return null;let l=i[s].fi,c={...i[s],fi:t};return i[s]=c,i.sort((a,d)=>a.fi-d.fi),e.localIndex=i.indexOf(c),{data:this.modifyArrayBy(i),actual:e,reverse:{type:6,fi:l,id:o}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let t=null;for(let o of this){if(o.id===e)return t;t=o.id}return null}insertBeforeHelper(e,t){return this.insertAfterHelper(this.previous(e),t)}insertAfterHelper(e,t){let o=this;if(e===null){if(o.length===0)return _r(0,t,t);{let i=o[0].fi;return _r(i-t,i,t)}}else{let i=this.get(e);if(i===void 0)throw new Error("illegal args");let s=o.find(l=>l.fi>i.fi);if(s===void 0){let l=o[o.length-1].fi;return _r(l,l+t,t)}else return _r(i.fi,s.fi,t)}}};function un(n){return n&&typeof n=="object"&&n instanceof ke}var ke=class{unusedFunOverridesTable(r){}runOp(r){let e=[],t=this,o=0,i={};for(;o<r.path.length;){if(e.push(t),t=t===void 0?void 0:t[r.path[o]],t!==void 0&&!un(t))return null;o+=1}t=t?ta(t):new ke;for(let[c,u]of Object.entries(r.props)){let a=t[c];i[c]=a,u===void 0?delete t[c]:t[c]=u}for(;o>0;){if(Object.keys(t).length===0){let c=e[o-1];c&&(t=ta(c),delete t[r.path[o-1]])}else{let c=e[o-1];if(c){let u=ta(c);u[r.path[o-1]]=t,t=u}else{let u=new ke;u[r.path[o-1]]=t,t=u}}o-=1}let s=Object.setPrototypeOf(t,ke.prototype),l={...r,props:i};return{data:s,actual:r,reverse:l}}},Wr;(t=>{function n(o,i){return ji(o,i)??o}t.apply=n;function r(o,i){return ac(o,i)}t.merge=r;function e(o,i){let s=0,l=i.path,c=o;for(;s<l.length&&c!==void 0;){if(c=Tt.zoomOnce(c,l[s]),c===void 0)return i;if(!un(c))return;s+=1}if(c===void 0)return i;if(!!un(c))if(i.type===0){let u={...i.props};for(let a of Object.keys(c))delete u[a];return{...i,props:u}}else if(i.type===1||i.type===4||i.type===7){let u=sc([i],c);return u?(console.log(u),u):i}else return i}t.filterOp=e})(Wr||(Wr={}));function sc(n,r){if(r===void 0)return;let e=!1,t=n.map(o=>{let i=o.id,s=ji(o.data,r[i]);if(e=e||s!==void 0,s===void 0&&(s=o.data),o.children){let l=sc(o.children,r);return l!==void 0?e=!0:l=o.children,{...o,id:i,data:s,children:l}}else return{...o,id:i,data:s}});if(e)return t}function Tg(n,r){if(r===void 0)return;let e=!1,t=n.map(o=>{let i=o.id,s=ji(o.data,r[i]);return e=e||s!==void 0,s===void 0&&(s=o.data),{...o,id:i,data:s}});if(e)return Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t}function ji(n,r){if(!un(r))return r;if(n instanceof et){let e=sc(n,r);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e}else{if(n instanceof ge)return Tg(n,r);if(Array.isArray(n)){let e=!1,t=n.map((o,i)=>{let s=ji(o,r[i]);return e=e||s!==void 0,s===void 0&&(s=o),s});return e?(Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t):void 0}else{if(n instanceof ke)return ac(n,r);if(n&&typeof n=="object"){let e={},t=!1;for(let[o,i]of Object.entries(n)){let s=ji(i,r[o]);t=t||s!==void 0,s===void 0&&(s=i),e[o]=s}return t?(Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e):void 0}}}}function ac(n,r){if(n===void 0)return r;if(r===void 0)return n;if(!un(r))return r;if(!un(n))return Wr.apply(n,r);let e=new Set;for(let o of Object.keys(n))e.add(o);for(let o of Object.keys(r))e.add(o);let t=new ke;for(let o of e){let i=ac(n===void 0?void 0:n[o],r===void 0?void 0:r[o]);t[o]=i}return t}function ou(n,r){let e={cur:[],result:[],len:0};return n=Fi(n,r,e)??n,[n,e.result]}function ra(n,r){return n===null?null:(n.cur[n.len]=r,n.len+=1,n)}function oa(n){n&&(n.len-=1)}function Pg(n){if(n===null)return null;n.result.push(n.cur.slice(0,n.len))}function nu(n,r,e){let t=!1,o=n.map(i=>{let s=i.id,l=r[s];if(l!==void 0&&typeof l=="string"&&(t=!0,s=l,e!==null))throw new Error("not supported");let c=Fi(i.data,r,ra(e,s));oa(e),t=t||c!==void 0,c===void 0&&(c=i.data);let u=nu(i.children,r,e);return u!==void 0?t=!0:u=i.children,{...i,id:s,data:c,children:u}});if(t)return o}function Og(n,r,e){let t=!1,o=n.map(i=>{let s=i.id,l=r[s];if(l!==void 0&&typeof l=="string"&&(t=!0,s=l,e!==null))throw new Error("not supported");let c=Fi(i.data,r,ra(e,s));return oa(e),t=t||c!==void 0,c===void 0&&(c=i.data),{...i,id:s,data:c}});if(t)return Object.setPrototypeOf(o,Object.getPrototypeOf(n)),o}function Fi(n,r,e){if(n instanceof et){let t=nu(n,r,e);return t!==void 0&&Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t}else{if(n instanceof ge)return Og(n,r,e);if(Array.isArray(n)){let t=!1,o=n.map((i,s)=>{let l=Fi(i,r,ra(e,s));return oa(e),t=t||l!==void 0,l===void 0&&(l=i),l});return t?(Object.setPrototypeOf(o,Object.getPrototypeOf(n)),o):void 0}else if(n&&typeof n=="object"&&!cn(n)){let t={},o=!1;for(let[i,s]of Object.entries(n))if(i!=="name"&&i!=="text"){let l=r[i];if(typeof l=="string"){if(e!==null)throw new Error("not supported");o=!0,i=l}let c=Fi(s,r,ra(e,i));oa(e),o=o||c!==void 0,c===void 0&&(c=s),t[i]=c}else t[i]=s;return o?(Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t):void 0}else if(typeof n=="string"){let t=r[n];if(t!==void 0){if(n.length!==36)throw new Error("for now you should only call this method when the key is a uuid");Pg(e)}return t}else return}}var na;(r=>{function n(e,t){let o=Tt.zoom(t,e.path);if(typeof o=="object"){let i={};for(let s of Object.keys(e.props))i[s]=o[s];return{...e,props:i}}else return{...e,props:{}}}r.replaceProps=n})(na||(na={}));var ht;(l=>{function n(c,u){return{...c,path:c.path.slice(u)}}l.drop=n;function r(c,u){return e(c,u)?.data??c}l.applySimple=r;function e(c,u){let a=u.path;for(var d=[];;){let p;if(c instanceof ke&&u.type===0&&(p=c.runOp({...u,path:a.slice(d.length)}),p===null&&(p=void 0)),d.length===a.length&&(c instanceof et||c instanceof ge||c instanceof Ge?p=c.runOp(u):p=dn.runOp(c,u)),p!==void 0)if(p!==null){let h=p.data;for(let y=d.length-1;y>=0;y--){let g=a[y],v=d[y];if(v instanceof et){if(typeof g=="number")throw new Error("illegal arg");h=v.modifyById(g,h)}else if(v instanceof ge){if(typeof g=="number")throw new Error("illegal arg");h=v.modifyById(g,h)}else if(v instanceof Ge){if(typeof g=="number")throw new Error("illegal arg");h=v.modifyById(g,h)}else if(v instanceof ke){let w={...v,[g]:h};h=Object.setPrototypeOf(w,ke.prototype)}else if(typeof v=="object")if(Array.isArray(v)){if(typeof g=="string"&&(g=parseInt(g),isNaN(g)))throw new Error("Invalid path");let w=h;h=[...v],h[g]=w}else h={...v,[g]:h};else return null}return{data:h,actual:{...p.actual,path:a},reverse:{...p.reverse,path:a}}}else return null;let f=a[d.length],m;if(c instanceof et){if(typeof f=="number")throw new Error("");m=c.get(f)?.data}else if(c instanceof ge){if(typeof f=="number")throw new Error("");m=c.get(f)?.data}else c!==null&&(m=c[f]);if(m!==void 0)d.push(c),c=m;else return null}}l.apply=e;function t(c,u){for(let a=0;a<c.length&&a<u.length;a++)if(c[a]!==u[a])return!0;return!1}l.pathDisjoint=t;function o(c,u){if(c.length!==u.length)return!1;for(let a=0;a<c.length;a++)if(c[a]!==u[a])return!1;return!0}l.pathEq=o;function i(c,u){return t(c.path,u.path)}l.commutative=i;function s(c,u){return c.type===0&&u.type===0&&o(c.path,u.path)?Object.keys(c.props).every(a=>u.props[a]!==void 0):!1}l.subsumed=s})(ht||(ht={}));var lc;(c=>{function n(){return[]}c.empty=n;function r(u,a){let d=[];for(let p of u){let[f,...m]=p.path;f===a&&d.push({...p,path:m})}return d}c.removePrefix=r;function e(u,a){return u.map(d=>({...d,path:[a,...d.path]}))}c.addPrefix=e;function t(u,a){return[...u,...a]}c.concat=t;function o(u,a){return[...u.filter(p=>!a.some(f=>ht.subsumed(p,f))),...a]}c.compress=o;function i(u,a){return u.every(d=>a.every(p=>ht.commutative(d,p)))}c.commutative=i;function s(u,a){for(let d of a){let p=l(u,d);p!==null&&(u=p.data)}return u}c.applyAll=s;function l(u,a){var d=u;let p=[],f=[];for(let m of a)try{if(m.type===3){let h=Tt.zoom(d,[...m.path,m.id]),y=ht.apply(d,{...m,type:2});if(y!==null){d=y.data;let[g,v]=ou(d,{[m.id]:h});d=g;for(let w of v){let S=w[w.length-1];w.splice(w.length-1,1),p.push({type:0,path:w,props:{[S]:h}}),f.push({type:0,path:w,props:{[S]:m.id}})}f.push(y.reverse),p.push(y.actual)}}else{let h=ht.apply(d,m);h!==null&&(p.push(h.actual),d=h.data,f.push(h.reverse))}}catch(h){if(h instanceof ln)return null;throw h}return{data:d,actual:p,reverse:f.reverse()}}c.apply=l})(lc||(lc={}));var iu=Symbol(),Ag=Symbol(),sa=Symbol(),Mo=class{reportOp(r,e,t=[]){let o=this;if(e===null)return;o._current=e.data;let i=t;for(;!(o instanceof ia);){let s=o._path,l=o._current;if(s!==""&&i.splice(0,0,s),o=o._parent,o===null)return;o.update(s,l)}o.push(i,r,e.actual,e.reverse)}deleteChildren(r){if(this._children){let e=this._children[r];if(e){let t=e[sa];t&&t(),delete this._children[r]}}}},dc=class extends Mo{constructor(r,e,t){super(),this._parent=r,this._path=e,this._current=t}update(r,e){if(Array.isArray(this._current)){if(typeof r=="string"&&(r=parseInt(r),isNaN(r)))throw new Error("Invalid path");this._current=[...this._current],this._current[r]=e}else this._current={...this._current,[r]:e}}runOp(r){this.reportOp(r,dn.runOp(this._current,r),r.path)}},uc=class extends Mo{constructor(r,e,t){super(),this._parent=r,this._path=e,this._current=t}update(r,e){this._current={...this._current,[r]:e},Object.setPrototypeOf(this._current,Ge.prototype)}runOp(r){this.reportOp(r,this._current.runOp(r))}},su={get(n,r){if(r===sa)return()=>{n._parent=null};if(r===iu)return n._current;if(r===Ag)return n;let{_current:e,_children:t}=n;if(r==="push"&&Array.isArray(e))throw new Error("not supported to expand array");let o=t===void 0?void 0:t[r];if(o!==void 0)return o;let i=e[r],s=aa(n,r,i);return s!==i?(t===void 0&&(t={},n._children=t),t[r]=s,s):i},has(n,r){return r in n._current},ownKeys(n){return Reflect.ownKeys(n._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(n){return Object.getPrototypeOf(n._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(n,r){let e=n._current,t=Reflect.getOwnPropertyDescriptor(e,r);return t&&{writable:!0,configurable:!0,enumerable:t.enumerable,value:e[r]}}},Ig={...su,set(n,r,e){let t={type:0,props:{[r]:lt(e)??e}};return n.deleteChildren(r),n.runOp(t),!0},deleteProperty(n,r){let e={type:0,props:{[r]:void 0}};return n.deleteChildren(r),n.runOp(e),!0}},Cg={...su,set(n,r,e){return e===void 0?this.deleteProperty(n,r):(n.deleteChildren(r),n.runOp({type:1,id:r,data:e})),!0},deleteProperty(n,r){return n.runOp({type:2,id:r}),!0}},pn=class extends Mo{constructor(r,e,t){super(),this._children={},this._parent=r,this._path=e,this._current=t,this[sa]=()=>{this._parent=null}}unproxy(){return this._current}update(r,e){this._current=this._current.modifyById(r,e)}runOp(r){this.reportOp(r,this._current.runOp(r))}randomId(){return this._current.randomId()}isDescendantOf(r,e){return this._current.isDescendantOf(r,e)}childrenOf(r){return this._current.childrenOf(r)}traverse(r){return this._current.traverse(r)}get(r){return this._current.get(r)}parent(r){return this._current.parent(r)}traverse(r){this._current.traverse((e,t)=>{r(e,this.data(e))})}data(r){let{_current:e,_children:t}=this,o=t===void 0?void 0:t[r];if(o!==void 0)return o;let i=e.get(r)?.data,s=aa(this,r,i);return s!==i?(t===void 0&&(t={},this._children=t),t[r]=s,s):i}add(r,e,t,o,i){this.runOp({type:7,parent:r,fi:e,id:t,data:o,children:i})}move(r,e,t){this.runOp({type:9,parent:r,fi:e,id:t})}insertAfter(r,e,t){let o=this._current.insertAfterHelper(r,e,t.length);for(let i=0;i<t.length;i++){let s=t[i];this.add(r,o[i],s.id,s.data,s.children)}}insertBefore(r,e,t){let o=this._current.insertBeforeHelper(r,e,t.length);for(let i=0;i<t.length;i++){let s=t[i];this.add(r,o[i],s.id,s.data,s.children)}}moveAfter(r,e,t){let o=this._current.insertAfterHelper(r,e,t.length);for(let i=0;i<t.length;i++){let s=t[i];this.move(r,o[i],s)}}moveBefore(r,e,t){let o=this._current.insertBeforeHelper(r,e,t.length);for(let i=0;i<t.length;i++){let s=t[i];this.move(r,o[i],s)}}delete(r){this.deleteChildren(r),this.runOp({type:8,id:r})}sortNext(r){return this._current.sortNext(r)}sortPrevious(r){return this._current.sortPrevious(r)}getAllSorted(r){return this._current.getAllSorted(r)}},fn=class extends Mo{constructor(r,e,t){super(),this._children={},this._parent=r,this._path=e,this._current=t,this[sa]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(r){let e=this.length;for(let t=0;t<e;t++){let o=this._current[t].id,i=this._current[t].fi;r(this.data(this._current[t].id),o,i)}}find(r){let e=this.length;for(let t=0;t<e;t++){let o=this._current[t].id;if(r(this.data(o),o))return this.get(o)}}update(r,e){this._current=this._current.modifyById(r,e)}randomId(){return this._current.randomId()}get(r){return{...this._current.get(r),data:this.data(r)}}data(r){let{_current:e,_children:t}=this,o=t===void 0?void 0:t[r];if(o!==void 0)return o;let i=e.get(r)?.data,s=aa(this,r,i);return s!==i?(t===void 0&&(t={},this._children=t),t[r]=s,s):i}runOp(r){this.reportOp(r,this._current.runOp(r))}add(r,e,t){this.runOp({type:4,fi:r,id:e,data:t})}move(r,e){this.runOp({type:6,fi:r,id:e})}insertAfter(r,e){let t=this._current.insertAfterHelper(r,e.length);for(let o=0;o<e.length;o++){let i=e[o];this.add(t[o],i.id,i.data)}}insertBefore(r,e){let t=this._current.insertBeforeHelper(r,e.length);for(let o=0;o<e.length;o++){let i=e[o];this.add(t[o],i.id,i.data)}}moveAfter(r,e){let t=this._current.insertAfterHelper(r,e.length);for(let o=0;o<e.length;o++){let i=e[o];this.move(t[o],i)}}moveBefore(r,e){let t=this._current.insertBeforeHelper(r,e.length);for(let o=0;o<e.length;o++){let i=e[o];this.move(t[o],i)}}delete(r){this.deleteChildren(r),this.runOp({type:5,id:r})}};function cc(n,r,e){if(n.length>0){let t=n[n.length-1];if(t.type===0&&r.type===0&&Tt.equal(t.path,e)){Object.assign(t.props,r.props);return}}n.push({...r,path:e})}var ia=class extends Mo{constructor(r){super(),this.ts=[],this.actual=[],this.reverse=[],this._current=r}update(r,e){if(r!=="")throw new Error("");this._current=e}push(r,e,t,o){cc(this.ts,e,r),cc(this.actual,t,r),cc(this.reverse,o,r)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function aa(n,r,e){return e instanceof et?new pn(n,r,e):e instanceof ge?new fn(n,r,e):e instanceof Ge?new Proxy(new uc(n,r,e),Cg):e!==null&&typeof e=="object"?cn(e)?e:new Proxy(new dc(n,r,e),Ig):e}function pc(n){let r=new ia(n);return[aa(r,"",n),r]}function mn(n,r){let[e,t]=pc(n);return r(e),t.result()}function lt(n){return n instanceof pn||n instanceof fn?n._current:n!==null&&typeof n=="object"?n[iu]:n}var Tt;(o=>{function n(i,s){if(s.length===i.length)for(var l=0;l<i.length;){if(i[l]!==s[l])return!1;l+=1}else return!1;return!0}o.equal=n;function r(i,s,l){let c=t(l,i);if(c!==void 0&&typeof c=="object"&&c!==null){let u={...s};return Object.keys(c).forEach(a=>{delete u[a]}),u}else return s}o.removeOverridden=r;function e(i,s){if((i instanceof et||i instanceof pn)&&typeof s=="string")return i.data(s);if((i instanceof ge||i instanceof fn)&&typeof s=="string")return i.data(s);if(typeof s=="number"&&Array.isArray(i))return i[s];if(typeof s=="string"&&typeof i=="object"&&i!==null)return i[s]}o.zoomOnce=e;function t(i,s,l=0){for(;l<s.length&&i!==void 0;)i=e(i,s[l]),l+=1;return i}o.zoom=t})(Tt||(Tt={}));function au(n,r){let e=[];if(r.length===n.length)for(var t=0;t<n.length;){if(r[t]==="*")e.push(n[t]);else if(n[t]!==r[t])return null;t+=1}else return null;return e}function ar(n,r){let e=[];if(r.length<=n.length)for(var t=0;t<r.length;){if(r[t]==="*")e.push(n[t]);else if(n[t]!==r[t])return null;t+=1}else return null;return e}var la=class{},zi=class extends la{constructor(e){super();this.id=e}},Ui=class extends la{constructor(e){super();this.data=e}};var mc;try{mc=new TextDecoder}catch{}var ne,ao,N=0;var hu=[],hc=hu,yc=0,Lt={},Oe,so,Zt=0,Tr=0,Wt,qr,Pt=[],Ee,lu={useRecords:!1,mapsAsObjects:!0},ki=class{},xc=new ki;xc.name="MessagePack 0xC1";var hn=!1,Pr=class{constructor(r){r&&(r.useRecords===!1&&r.mapsAsObjects===void 0&&(r.mapsAsObjects=!0),r.structures?r.structures.sharedLength=r.structures.length:r.getStructures&&((r.structures=[]).uninitialized=!0,r.structures.sharedLength=0)),Object.assign(this,r)}unpack(r,e){if(ne)return bu(()=>(da(),this?this.unpack(r,e):Pr.prototype.unpack.call(lu,r,e)));ao=e>-1?e:r.length,N=0,yc=0,Tr=0,so=null,hc=hu,Wt=null,ne=r;try{Ee=r.dataView||(r.dataView=new DataView(r.buffer,r.byteOffset,r.byteLength))}catch(t){throw ne=null,r instanceof Uint8Array?t:new Error("Source must be a Uint8Array or Buffer but was a "+(r&&typeof r=="object"?r.constructor.name:typeof r))}if(this instanceof Pr){if(Lt=this,this.structures)return Oe=this.structures,ca();(!Oe||Oe.length>0)&&(Oe=[])}else Lt=lu,(!Oe||Oe.length>0)&&(Oe=[]);return ca()}unpackMultiple(r,e){let t,o=0;try{hn=!0;let i=r.length,s=this?this.unpack(r,i):fa.unpack(r,i);if(e){for(e(s);N<i;)if(o=N,e(ca())===!1)return}else{for(t=[s];N<i;)o=N,t.push(ca());return t}}catch(i){throw i.lastPosition=o,i.values=t,i}finally{hn=!1,da()}}_mergeStructures(r,e){r=r||[];for(let t=0,o=r.length;t<o;t++){let i=r[t];i&&(i.isShared=!0,t>=32&&(i.highByte=t-32>>5))}r.sharedLength=r.length;for(let t in e||[])if(t>=0){let o=r[t],i=e[t];i&&(o&&((r.restoreStructures||(r.restoreStructures=[]))[t]=o),r[t]=i)}return this.structures=r}decode(r,e){return this.unpack(r,e)}};function ca(){try{if(!Lt.trusted&&!hn){let r=Oe.sharedLength||0;r<Oe.length&&(Oe.length=r)}let n=$e();if(N==ao)Oe.restoreStructures&&cu(),Oe=null,ne=null,qr&&(qr=null);else if(N>ao){let r=new Error("Unexpected end of MessagePack data");throw r.incomplete=!0,r}else if(!hn)throw new Error("Data read, but end of buffer not reached");return n}catch(n){throw Oe.restoreStructures&&cu(),da(),(n instanceof RangeError||n.message.startsWith("Unexpected end of buffer"))&&(n.incomplete=!0),n}}function cu(){for(let n in Oe.restoreStructures)Oe[n]=Oe.restoreStructures[n];Oe.restoreStructures=null}function $e(){let n=ne[N++];if(n<160)if(n<128){if(n<64)return n;{let r=Oe[n&63]||Lt.getStructures&&yu()[n&63];return r?(r.read||(r.read=vc(r,n&63)),r.read()):n}}else if(n<144)if(n-=128,Lt.mapsAsObjects){let r={};for(let e=0;e<n;e++)r[xu()]=$e();return r}else{let r=new Map;for(let e=0;e<n;e++)r.set($e(),$e());return r}else{n-=144;let r=new Array(n);for(let e=0;e<n;e++)r[e]=$e();return r}else if(n<192){let r=n-160;if(Tr>=N)return so.slice(N-Zt,(N+=r)-Zt);if(Tr==0&&ao<140){let e=r<16?bc(r):gu(r);if(e!=null)return e}return gc(r)}else{let r;switch(n){case 192:return null;case 193:return Wt?(r=$e(),r>0?Wt[1].slice(Wt.position1,Wt.position1+=r):Wt[0].slice(Wt.position0,Wt.position0-=r)):xc;case 194:return!1;case 195:return!0;case 196:return fc(ne[N++]);case 197:return r=Ee.getUint16(N),N+=2,fc(r);case 198:return r=Ee.getUint32(N),N+=4,fc(r);case 199:return Lo(ne[N++]);case 200:return r=Ee.getUint16(N),N+=2,Lo(r);case 201:return r=Ee.getUint32(N),N+=4,Lo(r);case 202:if(r=Ee.getFloat32(N),Lt.useFloat32>2){let e=pa[(ne[N]&127)<<1|ne[N+1]>>7];return N+=4,(e*r+(r>0?.5:-.5)>>0)/e}return N+=4,r;case 203:return r=Ee.getFloat64(N),N+=8,r;case 204:return ne[N++];case 205:return r=Ee.getUint16(N),N+=2,r;case 206:return r=Ee.getUint32(N),N+=4,r;case 207:return Lt.int64AsNumber?(r=Ee.getUint32(N)*4294967296,r+=Ee.getUint32(N+4)):r=Ee.getBigUint64(N),N+=8,r;case 208:return Ee.getInt8(N++);case 209:return r=Ee.getInt16(N),N+=2,r;case 210:return r=Ee.getInt32(N),N+=4,r;case 211:return Lt.int64AsNumber?(r=Ee.getInt32(N)*4294967296,r+=Ee.getUint32(N+4)):r=Ee.getBigInt64(N),N+=8,r;case 212:if(r=ne[N++],r==114)return mu(ne[N++]&63);{let e=Pt[r];if(e)return e.read?(N++,e.read($e())):e.noBuffer?(N++,e()):e(ne.subarray(N,++N));throw new Error("Unknown extension "+r)}case 213:return r=ne[N],r==114?(N++,mu(ne[N++]&63,ne[N++])):Lo(2);case 214:return Lo(4);case 215:return Lo(8);case 216:return Lo(16);case 217:return r=ne[N++],Tr>=N?so.slice(N-Zt,(N+=r)-Zt):Eg(r);case 218:return r=Ee.getUint16(N),N+=2,Tr>=N?so.slice(N-Zt,(N+=r)-Zt):Mg(r);case 219:return r=Ee.getUint32(N),N+=4,Tr>=N?so.slice(N-Zt,(N+=r)-Zt):Lg(r);case 220:return r=Ee.getUint16(N),N+=2,uu(r);case 221:return r=Ee.getUint32(N),N+=4,uu(r);case 222:return r=Ee.getUint16(N),N+=2,pu(r);case 223:return r=Ee.getUint32(N),N+=4,pu(r);default:if(n>=224)return n-256;if(n===void 0){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}throw new Error("Unknown MessagePack token "+n)}}}var Ng=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function vc(n,r){function e(){if(e.count++>2){let o=n.read=new Function("r","return function(){return {"+n.map(i=>Ng.test(i)?i+":r()":"["+JSON.stringify(i)+"]:r()").join(",")+"}}")($e);return n.highByte===0&&(n.read=du(r,n.read)),o()}let t={};for(let o=0,i=n.length;o<i;o++){let s=n[o];t[s]=$e()}return t}return e.count=0,n.highByte===0?du(r,e):e}var du=(n,r)=>function(){let e=ne[N++];if(e===0)return r();let t=n<32?-(n+(e<<5)):n+(e<<5),o=Oe[t]||yu()[t];if(!o)throw new Error("Record id is not defined for "+t);return o.read||(o.read=vc(o,n)),o.read()};function yu(){let n=bu(()=>(ne=null,Lt.getStructures()));return Oe=Lt._mergeStructures(n,Oe)}var gc=ua,Eg=ua,Mg=ua,Lg=ua;function ua(n){let r;if(n<16&&(r=bc(n)))return r;if(n>64&&mc)return mc.decode(ne.subarray(N,N+=n));let e=N+n,t=[];for(r="";N<e;){let o=ne[N++];if((o&128)===0)t.push(o);else if((o&224)===192){let i=ne[N++]&63;t.push((o&31)<<6|i)}else if((o&240)===224){let i=ne[N++]&63,s=ne[N++]&63;t.push((o&31)<<12|i<<6|s)}else if((o&248)===240){let i=ne[N++]&63,s=ne[N++]&63,l=ne[N++]&63,c=(o&7)<<18|i<<12|s<<6|l;c>65535&&(c-=65536,t.push(c>>>10&1023|55296),c=56320|c&1023),t.push(c)}else t.push(o);t.length>=4096&&(r+=ct.apply(String,t),t.length=0)}return t.length>0&&(r+=ct.apply(String,t)),r}function uu(n){let r=new Array(n);for(let e=0;e<n;e++)r[e]=$e();return r}function pu(n){if(Lt.mapsAsObjects){let r={};for(let e=0;e<n;e++)r[xu()]=$e();return r}else{let r=new Map;for(let e=0;e<n;e++)r.set($e(),$e());return r}}var ct=String.fromCharCode;function gu(n){let r=N,e=new Array(n);for(let t=0;t<n;t++){let o=ne[N++];if((o&128)>0){N=r;return}e[t]=o}return ct.apply(String,e)}function bc(n){if(n<4)if(n<2){if(n===0)return"";{let r=ne[N++];if((r&128)>1){N-=1;return}return ct(r)}}else{let r=ne[N++],e=ne[N++];if((r&128)>0||(e&128)>0){N-=2;return}if(n<3)return ct(r,e);let t=ne[N++];if((t&128)>0){N-=3;return}return ct(r,e,t)}else{let r=ne[N++],e=ne[N++],t=ne[N++],o=ne[N++];if((r&128)>0||(e&128)>0||(t&128)>0||(o&128)>0){N-=4;return}if(n<6){if(n===4)return ct(r,e,t,o);{let i=ne[N++];if((i&128)>0){N-=5;return}return ct(r,e,t,o,i)}}else if(n<8){let i=ne[N++],s=ne[N++];if((i&128)>0||(s&128)>0){N-=6;return}if(n<7)return ct(r,e,t,o,i,s);let l=ne[N++];if((l&128)>0){N-=7;return}return ct(r,e,t,o,i,s,l)}else{let i=ne[N++],s=ne[N++],l=ne[N++],c=ne[N++];if((i&128)>0||(s&128)>0||(l&128)>0||(c&128)>0){N-=8;return}if(n<10){if(n===8)return ct(r,e,t,o,i,s,l,c);{let u=ne[N++];if((u&128)>0){N-=9;return}return ct(r,e,t,o,i,s,l,c,u)}}else if(n<12){let u=ne[N++],a=ne[N++];if((u&128)>0||(a&128)>0){N-=10;return}if(n<11)return ct(r,e,t,o,i,s,l,c,u,a);let d=ne[N++];if((d&128)>0){N-=11;return}return ct(r,e,t,o,i,s,l,c,u,a,d)}else{let u=ne[N++],a=ne[N++],d=ne[N++],p=ne[N++];if((u&128)>0||(a&128)>0||(d&128)>0||(p&128)>0){N-=12;return}if(n<14){if(n===12)return ct(r,e,t,o,i,s,l,c,u,a,d,p);{let f=ne[N++];if((f&128)>0){N-=13;return}return ct(r,e,t,o,i,s,l,c,u,a,d,p,f)}}else{let f=ne[N++],m=ne[N++];if((f&128)>0||(m&128)>0){N-=14;return}if(n<15)return ct(r,e,t,o,i,s,l,c,u,a,d,p,f,m);let h=ne[N++];if((h&128)>0){N-=15;return}return ct(r,e,t,o,i,s,l,c,u,a,d,p,f,m,h)}}}}}function fc(n){return Lt.copyBuffers?Uint8Array.prototype.slice.call(ne,N,N+=n):ne.subarray(N,N+=n)}function Lo(n){let r=ne[N++];if(Pt[r])return Pt[r](ne.subarray(N,N+=n));throw new Error("Unknown extension type "+r)}var fu=new Array(4096);function xu(){let n=ne[N++];if(n>=160&&n<192){if(n=n-160,Tr>=N)return so.slice(N-Zt,(N+=n)-Zt);if(!(Tr==0&&ao<180))return gc(n)}else return N--,$e();let r=(n<<5^(n>1?Ee.getUint16(N):n>0?ne[N]:0))&4095,e=fu[r],t=N,o=N+n-3,i,s=0;if(e&&e.bytes==n){for(;t<o;){if(i=Ee.getUint32(t),i!=e[s++]){t=1879048192;break}t+=4}for(o+=3;t<o;)if(i=ne[t++],i!=e[s++]){t=1879048192;break}if(t===o)return N=t,e.string;o-=3,t=N}for(e=[],fu[r]=e,e.bytes=n;t<o;)i=Ee.getUint32(t),e.push(i),t+=4;for(o+=3;t<o;)i=ne[t++],e.push(i);let l=n<16?bc(n):gu(n);return l!=null?e.string=l:e.string=gc(n)}var mu=(n,r)=>{var e=$e();let t=n;r!==void 0&&(n=n<32?-((r<<5)+n):(r<<5)+n,e.highByte=r);let o=Oe[n];return o&&o.isShared&&((Oe.restoreStructures||(Oe.restoreStructures=[]))[n]=o),Oe[n]=e,e.read=vc(e,t),e.read()},vu=typeof self=="object"?self:global;Pt[0]=()=>{};Pt[0].noBuffer=!0;Pt[101]=()=>{let n=$e();return(vu[n[0]]||Error)(n[1])};Pt[105]=n=>{let r=Ee.getUint32(N-4);qr||(qr=new Map);let e=ne[N],t;e>=144&&e<160||e==220||e==221?t=[]:t={};let o={target:t};qr.set(r,o);let i=$e();return o.used?Object.assign(t,i):(o.target=i,i)};Pt[112]=n=>{let r=Ee.getUint32(N-4),e=qr.get(r);return e.used=!0,e.target};Pt[115]=()=>new Set($e());var Sc=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(n=>n+"Array");Pt[116]=n=>{let r=n[0],e=Sc[r];if(!e)throw new Error("Could not find typed array for code "+r);return new vu[e](Uint8Array.prototype.slice.call(n,1).buffer)};Pt[120]=()=>{let n=$e();return new RegExp(n[0],n[1])};Pt[98]=n=>{let r=(n[0]<<24)+(n[1]<<16)+(n[2]<<8)+n[3],e=N;N+=r-4,Wt=[$e(),$e()],Wt.position0=0,Wt.position1=0;let t=N;N=e;try{return $e()}finally{N=t}};Pt[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 bu(n){let r=ao,e=N,t=yc,o=Zt,i=Tr,s=so,l=hc,c=qr,u=Wt,a=new Uint8Array(ne.slice(0,ao)),d=Oe,p=Oe.slice(0,Oe.length),f=Lt,m=hn,h=n();return ao=r,N=e,yc=t,Zt=o,Tr=i,so=s,hc=l,qr=c,Wt=u,ne=a,hn=m,Oe=d,Oe.splice(0,Oe.length,...p),Lt=f,Ee=new DataView(ne.buffer,ne.byteOffset,ne.byteLength),h}function da(){ne=null,qr=null,Oe=null}function Su(n){n.unpack?Pt[n.type]=n.unpack:Pt[n.type]=n}var pa=new Array(147);for(let n=0;n<256;n++)pa[n]=+("1e"+Math.floor(45.15-n*.30103));var fa=new Pr({useRecords:!1}),Bg=fa.unpack,Dg=fa.unpackMultiple,Gg=fa.unpack,ma={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},Rg=new Float32Array(1),_P=new Uint8Array(Rg.buffer,0,4);var ha;try{ha=new TextEncoder}catch{}var ya,_c,ga=typeof Buffer<"u",wc=ga?Buffer.allocUnsafeSlow:Uint8Array,Pu=ga?Buffer:Uint8Array,wu=ga?4294967296:2144337920,R,Ze,E=0,Or,Ar=null,Vg=/[\u0080-\uFFFF]/,Hi=Symbol("record-id"),Bo=class extends Pr{constructor(r){super(r),this.offset=0;let e,t,o,i,s,l,c=0,u=Pu.prototype.utf8Write?function(x,C,P){return R.utf8Write(x,C,P)}:ha&&ha.encodeInto?function(x,C){return ha.encodeInto(x,R.subarray(C)).written}:!1,a=this;r||(r={});let d=r&&r.sequential,p=r.structures||r.saveStructures,f=r.maxSharedStructures;if(f==null&&(f=p?32:0),f>8160)throw new Error("Maximum maxSharedStructure is 8160");let m=r.maxOwnStructures;m==null&&(m=p?32:64),d&&!r.saveStructures&&(this.structures=[]);let h=f>32||m+f>64,y=f+64,g=f+m+64;if(g>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let v=[],w=0,S=0;this.pack=this.encode=function(x,C){if(R||(R=new wc(8192),Ze=new DataView(R.buffer,0,8192),E=0),Or=R.length-10,Or-E<2048?(R=new wc(R.length),Ze=new DataView(R.buffer,0,R.length),Or=R.length-10,E=0):E=E+7&2147483640,t=E,l=a.structuredClone?new Map:null,a.bundleStrings?(Ar=["",""],R[E++]=214,R[E++]=98,Ar.position=E-t,E+=4):Ar=null,o=a.structures,o){o.uninitialized&&(o=a._mergeStructures(a.getStructures()));let P=o.sharedLength||0;if(P>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 I=0;I<P;I++){let A=o[I];if(!A)continue;let O,V=o.transitions;for(let z=0,$=A.length;z<$;z++){let te=A[z];O=V[te],O||(O=V[te]=Object.create(null)),V=O}V[Hi]=I+64}c=P}d||(o.nextId=P+64)}i&&(i=!1),s=o||[];try{if(b(x),Ar){Ze.setUint32(Ar.position+t,E-Ar.position-t);let P=Ar;Ar=null,b(P[0]),b(P[1])}if(a.offset=E,l&&l.idsToInsert){E+=l.idsToInsert.length*6,E>Or&&_(E),a.offset=E;let P=Fg(R.subarray(t,E),l.idsToInsert);return l=null,P}return C&Au?(R.start=t,R.end=E,R):R.subarray(t,E)}finally{if(o){if(S<10&&S++,w>1e4)o.transitions=null,S=0,w=0,v.length>0&&(v=[]);else if(v.length>0&&!d){for(let P=0,I=v.length;P<I;P++)v[P][Hi]=0;v=[]}if(i&&a.saveStructures){let P=o.sharedLength||f;o.length>P&&(o=o.slice(0,P));let I=R.subarray(t,E);return a.saveStructures(o,c)===!1?(a._mergeStructures(a.getStructures()),a.pack(x)):(c=P,I)}}C&$g&&(E=t)}};let b=x=>{E>Or&&(R=_(E));var C=typeof x,P;if(C==="string"){let I=x.length;if(Ar&&I>=8&&I<4096){let V=Vg.test(x);Ar[V?0:1]+=x,R[E++]=193,b(V?-I:I);return}let A;I<32?A=1:I<256?A=2:I<65536?A=3:A=5;let O=I*3;if(E+O>Or&&(R=_(E+O)),I<64||!u){let V,z,$,te=E+A;for(V=0;V<I;V++)z=x.charCodeAt(V),z<128?R[te++]=z:z<2048?(R[te++]=z>>6|192,R[te++]=z&63|128):(z&64512)===55296&&(($=x.charCodeAt(V+1))&64512)===56320?(z=65536+((z&1023)<<10)+($&1023),V++,R[te++]=z>>18|240,R[te++]=z>>12&63|128,R[te++]=z>>6&63|128,R[te++]=z&63|128):(R[te++]=z>>12|224,R[te++]=z>>6&63|128,R[te++]=z&63|128);P=te-E-A}else P=u(x,E+A,O);P<32?R[E++]=160|P:P<256?(A<2&&R.copyWithin(E+2,E+1,E+1+P),R[E++]=217,R[E++]=P):P<65536?(A<3&&R.copyWithin(E+3,E+2,E+2+P),R[E++]=218,R[E++]=P>>8,R[E++]=P&255):(A<5&&R.copyWithin(E+5,E+3,E+3+P),R[E++]=219,Ze.setUint32(E,P),E+=4),E+=P}else if(C==="number")if(x>>>0===x)x<64?R[E++]=x:x<256?(R[E++]=204,R[E++]=x):x<65536?(R[E++]=205,R[E++]=x>>8,R[E++]=x&255):(R[E++]=206,Ze.setUint32(E,x),E+=4);else if(x>>0===x)x>=-32?R[E++]=256+x:x>=-128?(R[E++]=208,R[E++]=x+256):x>=-32768?(R[E++]=209,Ze.setInt16(E,x),E+=2):(R[E++]=210,Ze.setInt32(E,x),E+=4);else{let I;if((I=this.useFloat32)>0&&x<4294967296&&x>=-2147483648){R[E++]=202,Ze.setFloat32(E,x);let A;if(I<4||(A=x*pa[(R[E]&127)<<1|R[E+1]>>7])>>0===A){E+=4;return}else E--}R[E++]=203,Ze.setFloat64(E,x),E+=8}else if(C==="object")if(!x)R[E++]=192;else{if(l){let A=l.get(x);if(A){if(!A.id){let O=l.idsToInsert||(l.idsToInsert=[]);A.id=O.push(A)}R[E++]=214,R[E++]=112,Ze.setUint32(E,A.id),E+=4;return}else l.set(x,{offset:E-t})}let I=x.constructor;if(I===Object)T(x,!0);else if(I===Array){P=x.length,P<16?R[E++]=144|P:P<65536?(R[E++]=220,R[E++]=P>>8,R[E++]=P&255):(R[E++]=221,Ze.setUint32(E,P),E+=4);for(let A=0;A<P;A++)b(x[A])}else if(I===Map){P=x.size,P<16?R[E++]=128|P:P<65536?(R[E++]=222,R[E++]=P>>8,R[E++]=P&255):(R[E++]=223,Ze.setUint32(E,P),E+=4);for(let[A,O]of x)b(A),b(O)}else{for(let A=0,O=ya.length;A<O;A++){let V=_c[A];if(x instanceof V){let z=ya[A];if(z.write){z.type&&(R[E++]=212,R[E++]=z.type,R[E++]=0),b(z.write.call(this,x));return}let $=R,te=Ze,K=E;R=null;let q;try{q=z.pack.call(this,x,k=>(R=$,$=null,E+=k,E>Or&&_(E),{target:R,targetView:Ze,position:E-k}),b)}finally{$&&(R=$,Ze=te,E=K,Or=R.length-10)}q&&(q.length+E>Or&&_(q.length+E),E=jg(q,R,E,z.type));return}}T(x,!x.hasOwnProperty)}}else if(C==="boolean")R[E++]=x?195:194;else if(C==="bigint"){if(x<BigInt(1)<<BigInt(63)&&x>=-(BigInt(1)<<BigInt(63)))R[E++]=211,Ze.setBigInt64(E,x);else if(x<BigInt(1)<<BigInt(64)&&x>0)R[E++]=207,Ze.setBigUint64(E,x);else if(this.largeBigIntToFloat)R[E++]=203,Ze.setFloat64(E,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");E+=8}else if(C==="undefined")this.encodeUndefinedAsNil?R[E++]=192:(R[E++]=212,R[E++]=0,R[E++]=0);else if(C==="function")b(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+C)},T=this.useRecords===!1?this.variableMapSize?x=>{let C=Object.keys(x),P=C.length;P<16?R[E++]=128|P:P<65536?(R[E++]=222,R[E++]=P>>8,R[E++]=P&255):(R[E++]=223,Ze.setUint32(E,P),E+=4);let I;for(let A=0;A<P;A++)b(I=C[A]),b(x[I])}:(x,C)=>{R[E++]=222;let P=E-t;E+=2;let I=0;for(let A in x)(C||x.hasOwnProperty(A))&&(b(A),b(x[A]),I++);R[P+++t]=I>>8,R[P+t]=I&255}:x=>{let C=Object.keys(x),P,I=s.transitions||(s.transitions=Object.create(null)),A=0;for(let V=0,z=C.length;V<z;V++){let $=C[V];P=I[$],P||(P=I[$]=Object.create(null),A++),I=P}let O=I[Hi];if(O)O>=96&&h?(R[E++]=((O-=96)&31)+96,R[E++]=O>>5):R[E++]=O;else{O=s.nextId,O||(O=64),O<y&&this.shouldShareStructure&&!this.shouldShareStructure(C)?(O=s.nextOwnId,O<g||(O=y),s.nextOwnId=O+1):(O>=g&&(O=y),s.nextId=O+1);let V=C.highByte=O>=96&&h?O-96>>5:-1;I[Hi]=O,s[O-64]=C,O<y?(C.isShared=!0,s.sharedLength=O-63,i=!0,V>=0?(R[E++]=(O&31)+96,R[E++]=V):R[E++]=O):(V>=0?(R[E++]=213,R[E++]=114,R[E++]=(O&31)+96,R[E++]=V):(R[E++]=212,R[E++]=114,R[E++]=O),A&&(w+=S*A),v.length>=m&&(v.shift()[Hi]=0),v.push(I),b(C))}for(let V=0,z=C.length;V<z;V++)b(x[C[V]])},_=x=>{let C;if(x>16777216){if(x-t>wu)throw new Error("Packed buffer would be larger than maximum buffer size");C=Math.min(wu,Math.round(Math.max((x-t)*(x>67108864?1.25:2),4194304)/4096)*4096)}else C=(Math.max(x-t<<2,R.length-1)>>12)+1<<12;let P=new wc(C);return Ze=new DataView(P.buffer,0,C),R.copy?R.copy(P,0,t,x):P.set(R.slice(t,x)),E-=t,t=0,Or=P.length-10,R=P}}useBuffer(r){R=r,Ze=new DataView(R.buffer,R.byteOffset,R.byteLength),E=0}};_c=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,ki];ya=[{pack(n,r,e){let t=n.getTime()/1e3;if((this.useTimestamp32||n.getMilliseconds()===0)&&t>=0&&t<4294967296){let{target:o,targetView:i,position:s}=r(6);o[s++]=214,o[s++]=255,i.setUint32(s,t)}else if(t>0&&t<17179869184){let{target:o,targetView:i,position:s}=r(10);o[s++]=215,o[s++]=255,i.setUint32(s,n.getMilliseconds()*4e6+(t/1e3/4294967296>>0)),i.setUint32(s+4,t)}else if(isNaN(t)){if(this.onInvalidDate)return r(0),e(this.onInvalidDate());let{target:o,targetView:i,position:s}=r(3);o[s++]=212,o[s++]=255,o[s++]=255}else{let{target:o,targetView:i,position:s}=r(15);o[s++]=199,o[s++]=12,o[s++]=255,i.setUint32(s,n.getMilliseconds()*1e6),i.setBigInt64(s+4,BigInt(Math.floor(t)))}}},{pack(n,r,e){let t=Array.from(n),{target:o,position:i}=r(this.structuredClone?3:0);this.structuredClone&&(o[i++]=212,o[i++]=115,o[i++]=0),e(t)}},{pack(n,r,e){let{target:t,position:o}=r(this.structuredClone?3:0);this.structuredClone&&(t[o++]=212,t[o++]=101,t[o++]=0),e([n.name,n.message])}},{pack(n,r,e){let{target:t,position:o}=r(this.structuredClone?3:0);this.structuredClone&&(t[o++]=212,t[o++]=120,t[o++]=0),e([n.source,n.flags])}},{pack(n,r){this.structuredClone?_u(n,16,r):Tu(ga?Buffer.from(n):new Uint8Array(n),r)}},{pack(n,r){let e=n.constructor;e!==Pu&&this.structuredClone?_u(n,Sc.indexOf(e.name),r):Tu(n,r)}},{pack(n,r){let{target:e,position:t}=r(1);e[t]=193}}];function _u(n,r,e,t){let o=n.byteLength;if(o+1<256){var{target:i,position:s}=e(4+o);i[s++]=199,i[s++]=o+1}else if(o+1<65536){var{target:i,position:s}=e(5+o);i[s++]=200,i[s++]=o+1>>8,i[s++]=o+1&255}else{var{target:i,position:s,targetView:l}=e(7+o);i[s++]=201,l.setUint32(s,o+1),s+=4}i[s++]=116,i[s++]=r,i.set(new Uint8Array(n.buffer,n.byteOffset,n.byteLength),s)}function Tu(n,r){let e=n.byteLength;var t,o;if(e<256){var{target:t,position:o}=r(e+2);t[o++]=196,t[o++]=e}else if(e<65536){var{target:t,position:o}=r(e+3);t[o++]=197,t[o++]=e>>8,t[o++]=e&255}else{var{target:t,position:o,targetView:i}=r(e+5);t[o++]=198,i.setUint32(o,e),o+=4}t.set(n,o)}function jg(n,r,e,t){let o=n.length;switch(o){case 1:r[e++]=212;break;case 2:r[e++]=213;break;case 4:r[e++]=214;break;case 8:r[e++]=215;break;case 16:r[e++]=216;break;default:o<256?(r[e++]=199,r[e++]=o):o<65536?(r[e++]=200,r[e++]=o>>8,r[e++]=o&255):(r[e++]=201,r[e++]=o>>24,r[e++]=o>>16&255,r[e++]=o>>8&255,r[e++]=o&255)}return r[e++]=t,r.set(n,e),e+=o,e}function Fg(n,r){let e,t=r.length*6,o=n.length-t;for(r.sort((i,s)=>i.offset>s.offset?1:-1);e=r.pop();){let i=e.offset,s=e.id;n.copyWithin(i+t,i,o),t-=6;let l=i+t;n[l++]=214,n[l++]=105,n[l++]=s>>24,n[l++]=s>>16&255,n[l++]=s>>8&255,n[l++]=s&255,o=i}return n}function lo(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)");_c.unshift(n.Class),ya.unshift(n)}Su(n)}var Ou=new Bo({useRecords:!1}),zg=Ou.pack,Ug=Ou.pack;var{NEVER:kg,ALWAYS:Hg,DECIMAL_ROUND:Wg,DECIMAL_FIT:qg}=ma,Au=512,$g=1024;var Iu=new Bo({structuredClone:!0});lo({Class:Ge.prototype.constructor,type:1,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,Ge.prototype),n}});lo({Class:ge.prototype.constructor,type:2,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,ge.prototype),n}});lo({Class:et.prototype.constructor,type:3,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,et.prototype),n}});lo({Class:zi.prototype.constructor,type:4,write(n){return n.id},read(n){return new zi(n)}});lo({Class:Ui.prototype.constructor,type:5,write(n){return n.data},read(n){return new Ui(n)}});lo({Class:ke.prototype.constructor,type:6,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,ke.prototype),n}});function Yg(n){var r=0;if(n.length===0)return r;for(let e=0;e<n.length;e++){let t=n[e];r=(r<<5)-r+t,r=r&r}return r}function Tc(n){if(cn(n))return n;if(Array.isArray(n))return n.map(Tc);if(typeof n=="object"&&n!==null){let r={};for(let e of Object.keys(n).sort())r[e]=Tc(n[e]);return Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r}else return n}var xa;(t=>{function n(o){return Iu.pack(o)}t.serialize=n;function r(o){return Iu.unpack(o)}t.deserialize=r;function e(o){return Yg(n(Tc(o))).toString()}t.checksum=e})(xa||(xa={}));var Cu;(e=>{function n(t,o){return t[0]===o[0]&&t[1]===o[1]}e.isEqual=n;function r(t,o,i){return[t[0]+(o[0]-t[0])*i,t[1]+(o[1]-t[1])*i]}e.lerp=r})(Cu||(Cu={}));var co;(l=>{function n(c,u){return c[0]===u[0]&&c[1]===u[1]&&c[2]===u[2]}l.isEqual=n;function r(c,u){return[c[0]+u[0],c[1]+u[1],c[2]+u[2]]}l.add=r;function e(c,u){return[c[0]-u[0],c[1]-u[1],c[2]-u[2]]}l.sub=e;function t(c,u){return[c[0]/u[0],c[1]/u[1],c[2]/u[2]]}l.div=t;function o(c,u){return[c[0]*u[0],c[1]*u[1],c[2]*u[2]]}l.mul=o;function i(c,u){return Math.hypot(c[0]-u[0],c[1]-u[1],c[2]-u[2])}l.dist=i;function s(c,u,a){return[c[0]+(u[0]-c[0])*a,c[1]+(u[1]-c[1])*a,c[2]+(u[2]-c[2])*a]}l.lerp=s})(co||(co={}));var Nu;(e=>{function n(t,o){return t[0]===o[0]&&t[1]===o[1]&&t[2]===o[2]&&t[3]===o[3]}e.isEqual=n;function r(t,o,i){return[t[0]+(o[0]-t[0])*i,t[1]+(o[1]-t[1])*i,t[2]+(o[2]-t[2])*i,t[3]+(o[3]-t[3])*i]}e.lerp=r})(Nu||(Nu={}));var uo;(o=>{o.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function r(i,s){for(let l=0;l<16;l++)if(i[l]!==s[l])return!1;return!0}o.isEqual=r;function e(i){return i??o.identity}o.simplify=e;function t(i,s){let l=s.slice(0);for(var c=0,u=s.length;c<u;c+=3){let a=i[3]*s[c]+i[7]*s[c+1]+i[11]*s[c+2]+i[15];l[c]=(i[0]*s[c]+i[4]*s[c+1]+i[8]*s[c+2]+i[12])/a,l[c+1]=(i[1]*s[c]+i[5]*s[c+1]+i[9]*s[c+2]+i[13])/a,l[c+2]=(i[2]*s[c]+i[6]*s[c+1]+i[10]*s[c+2]+i[14])/a}return l}o.applyMatrix4=t})(uo||(uo={}));var Bt;(u=>{function n(a){return typeof a=="object"&&typeof a.r=="number"&&typeof a.g=="number"&&typeof a.b=="number"}u.isRGB=n,u.white={r:1,g:1,b:1},u.red={r:1,g:0,b:0},u.black={r:0,g:0,b:0};function o(a){return{r:Math.round(a.r*255),g:Math.round(a.g*255),b:Math.round(a.b*255),a:1}}u.toRgb255a1=o;function i(a){return{r:a.r,g:a.g,b:a.b}}u.clone=i;function s(a){return a=Math.floor(a),{r:(a>>16&255)/255,g:(a>>8&255)/255,b:(a&255)/255}}u.fromHex=s;function l(a,d){return a.r===d.r&&a.g===d.g&&a.b===d.b}u.equals=l;function c(a,d,p){return{r:a.r+(d.r-a.r)*p,g:a.g+(d.g-a.g)*p,b:a.b+(d.b-a.b)*p}}u.lerp=c})(Bt||(Bt={}));var lr;(l=>{l.white={...Bt.white,a:1},l.transparent={...Bt.white,a:0};function e(c){return{r:c[0],g:c[1],b:c[2],a:c[3]}}l.from0to1=e;function t(c,u){return{...Bt.fromHex(c),a:u}}l.fromHexAndA=t;function o(c){return{r:Math.round(c.r*255),g:Math.round(c.g*255),b:Math.round(c.b*255),a:c.a}}l.toRgb255a1=o;function i(c,u){return Bt.equals(c,u)&&c.a===u.a}l.equals=i;function s(c,u,a){return{r:c.r+(u.r-c.r)*a,g:c.g+(u.g-c.g)*a,b:c.b+(u.b-c.b)*a,a:c.a+(u.a-c.a)*a}}l.lerp=s})(lr||(lr={}));var va;(r=>r.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(va||(va={}));var Eu;(r=>r.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(Eu||(Eu={}));var Mu;(r=>r.defaultData={control1:[.5,.05],control2:[.1,.3]})(Mu||(Mu={}));var cr;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function r(t){return e.all.includes(t)}e.is=r})(cr||(cr={}));var Do;(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,autoZoom:!1,autoZoomFrustumSize:790},up:o.DefaultUp,isUpVectorFlipped:!1,targetOffset:o.DefaultTargetOffset};function t(i){return i.type==="PerspectiveCamera"?i.perspective.zoom:i.orthographic.zoom}o.getZoom=t})(Do||(Do={}));var Ir;(e=>{function n(t,o=.1){return{disabled:!1,type:"linear",hideBase:!1,count:3,radial:{radius:Math.max(t[0],t[1])*2,start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0]},toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},linear:{scale:[1,1,1],rotation:[0,0,0],position:[t[0]+t[0]*o,0,0]},grid:{count:[2,2,2],size:t.map(i=>i*(1+o)),useCenter:!0},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}}}e.defaultData=n;function r(t,o){let i={...t};if(Xg.forEach(s=>{Object.assign(i,{[s]:o[s]??t[s]})}),i.radial={...t.radial},o.radial){let s=t.radial,l=o.radial;Kg.forEach(c=>{Object.assign(i.radial,{[c]:l[c]??s[c]})})}if(i.linear={...t.linear},o.linear){let s=t.linear,l=o.linear;Zg.forEach(c=>{Object.assign(i.linear,{[c]:l[c]??s[c]})})}if(i.grid={...t.grid},o.grid){let s=t.grid,l=o.grid;Qg.forEach(c=>{Object.assign(i.grid,{[c]:l[c]??s[c]})})}if(i.toObject={...t.toObject},o.toObject){let s=t.toObject,l=o.toObject;Jg.forEach(c=>{Object.assign(i.toObject,{[c]:l[c]??s[c]})})}if(i.randomnessObject={...t.randomnessObject},o.randomnessObject){let s=t.randomnessObject,l=o.randomnessObject;ex.forEach(c=>{Object.assign(i.randomnessObject,{[c]:l[c]??s[c]})})}return i}e.merge=r})(Ir||(Ir={}));var ba;(t=>{t.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let r=["radial","linear","grid","toObject","randomnessObject"];function e(o,i){let s=[];o.count!==void 0&&s.push({type:0,path:i,props:{count:o.count}});for(let l of r){let c=o[l];c&&Object.keys(c).length>0&&s.push({type:0,path:[...i,l],props:c})}return s}t.toOps=e})(ba||(ba={}));var Xg=["count"],Kg=["radius","start","end","position","scale","rotation"],Zg=["position","scale","rotation"],Qg=["count","size"],Jg=["count","position","scale","rotation"],ex=["strength","scale","rotation","position","movement","seed","freqScale"];var Sa;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function r(t){return e.all.includes(t)}e.is=r})(Sa||(Sa={}));var wa;(e=>{function n(t){return r(t)}e.defaultData=n;function r(t){if(t==="PointLight")return{type:t,color:lr.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,depth:1e5};if(t==="SpotLight")return{type:t,color:lr.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:1e5,shadowResolution:1024,shadowRadius:1};if(t==="DirectionalLight")return{type:t,color:lr.white,intensity:1,shadows:!0,size:1e3,depth:1e5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(wa||(wa={}));var Pc;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function r(t,o){return t.castShadow===o.castShadow&&t.receiveShadow===o.receiveShadow}e.equals=r})(Pc||(Pc={}));var Oc;(e=>{e.defaultData={flatShading:!1,wireframe:!1,side:0};function r(t,o){return t.flatShading===o.flatShading&&t.side===o.side&&t.wireframe===o.wireframe}e.equals=r})(Oc||(Oc={}));var _a;(r=>r.defaultData={...Oc.defaultData,...Pc.defaultData})(_a||(_a={}));var yn;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(yn||(yn={}));var Lu=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],Bu=["wrapping","image","video"],Ot;(o=>{function n(i,s){let{texture:l,...c}=s;if(Object.assign(i,c),l){let u=i.texture;u&&Object.assign(u,l)}}o.patch=n;function r(i,s){return i==="light"&&s?e(s):t(i)}o.defaultData=r;function e(i){switch(i){case"phong":return{category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",alpha:.6,visible:!0,mode:0};case"toon":return{category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1,visible:!0,mode:0};case"lambert":return{category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0};case"physical":return{category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0}}}function t(i){switch(i){case"texture":return{alpha:1,visible:!0,size:[128,128],mode:0,axis:"x",side:2,type:"texture",projection:0,texture:{image:"image_0",wrapping:1e3,repeat:[1,1],offset:[0,0]},crop:!1};case"video":return{alpha:1,visible:!0,size:[128,128],mode:0,axis:"x",side:2,type:"video",projection:0,texture:{video:yn.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!0};case"color":return{type:"color",alpha:1,visible:!0,mode:0,color:Bt.fromHex(4737101)};case"depth":return{type:"depth",alpha:1,visible:!0,mode:0,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{type:"normal",alpha:1,visible:!0,mode:0,cnormal:[1,1,1]};case"gradient":return{type:"gradient",alpha:1,visible:!0,mode:0,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{type:"noise",alpha:1,visible:!0,mode:0,size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...Bt.fromHex(6710886),a:1},colorB:{...Bt.fromHex(6710886),a:1},colorC:{...Bt.fromHex(16777215),a:1},colorD:{...Bt.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8]};case"fresnel":return{type:"fresnel",alpha:1,visible:!0,mode:0,color:lr.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{type:"rainbow",alpha:1,visible:!0,mode:0,filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{type:"toon",alpha:1,visible:!0,mode:0,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:lr.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{type:"outline",alpha:1,visible:!0,mode:0,outlineColor:lr.fromHexAndA(0,1),contourColor:lr.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{type:"matcap",alpha:1,visible:!0,mode:0,texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0]}};case"transmission":return{type:"transmission",alpha:1,visible:!0,mode:0,thickness:10,ior:1.5,roughness:1};case"displace":return{type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,visible:!0}}}})(Ot||(Ot={}));var Dt;(c=>{function n(u){return!u.layers.some(d=>d.data.type==="texture"&&d.data.projection!==0||d.data.type==="depth"&&!d.data.isWorldSpace||d.data.type==="noise"||d.data.type==="displace")}c.isMergable=n;function r(u){let a="";return u.layers.forEach(d=>{Object.entries(d.data).forEach(([p,f])=>{a+=`${p}${f}`,Array.isArray(f)?f.forEach(m=>a+=`${m}`):typeof f=="object"?Object.values(f).forEach(m=>{typeof m=="number"?a+=`${m.toFixed(4)}`:a+=`${m}`}):a+=`${f}`})}),a}c.getHash=r;function e(){return{layers:new ge}}c.defaultEmptyData=e;function t(u="layer1",a="layer2"){return i("phong",u,a)}c.defaultData=t;function o(u,a){return{...u,name:a}}c.withName=o;function i(u,a="layer1",d="layer2"){let p=new ge;return p.push({fi:0,data:Ot.defaultData("light",u),id:a}),p.push({fi:1,data:Ot.defaultData("color"),id:d}),{layers:p}}c.defaultTwoLayerData=i;function s(u,a="phong",d="layer1",p="layer2"){let f=Ot.defaultData("texture");Object.assign(f.texture,{image:u});let m=new ge;return m.push({fi:0,data:f,id:d}),m.push({fi:1,data:Ot.defaultData("light",a),id:p}),{layers:m}}c.defaultTwoLayerTextureData=s;function l(u,a="phong",d="layer1",p="layer2"){let f=Ot.defaultData("video");Object.assign(f.texture,{video:u});let m=new ge;return m.push({fi:0,data:f,id:d}),m.push({fi:1,data:Ot.defaultData("light",a),id:p}),{layers:m}}c.defaultTwoLayerVideoTextureData=l})(Dt||(Dt={}));var gn;(r=>{function n(){return{points:new ge,roundness:0,shapeHoles:[],isClosed:!1}}r.defaultData=n})(gn||(gn={}));var xn;(r=>{function n(){return{points:new ge,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}r.defaultData=n})(xn||(xn={}));var Ac={type:"Ellipse",width:100,height:100,spikes:64,angle:360,innerRadius:0};var Ta;(r=>{function n(e,t){let o={...e};return tx.forEach(i=>{Object.assign(o,{[i]:t[i]??e[i]})}),o}r.merge=n})(Ta||(Ta={}));var Pa={shape:Ac,depth:1,offset:0,bevel:0,bevelSides:1,angle:0,twist:0,startScale:1,endScale:1},tx=["depth","offset","angle","twist","startScale","endScale"];var Wi;(r=>{function n(e){return e==="PolygonGeometry"||e==="RectangleGeometry"||e==="StarGeometry"||e==="TriangleGeometry"||e==="EllipseGeometry"}r.is2DParametricMesh=n})(Wi||(Wi={}));var Oa;(r=>{function n(e,t){let o={...e};return Object.assign(o,t),o.type==="PathGeometry"&&"extrusion"in t&&t.extrusion&&(o.extrusion={...e.extrusion},Object.assign(o.extrusion,Ta.merge(o.extrusion,t.extrusion))),o}r.merge=n})(Oa||(Oa={}));var po;(r=>{function n(e){if(e==="RectangleGeometry")return{width:320,height:320,type:e,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="PathGeometry")return{type:e,width:1,height:1,depth:1,path:xn.defaultData(),extrusion:Pa};if(e==="VectorGeometry")return{width:1,height:1,type:e,subdivisions:12,shape:gn.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="BooleanGeometry")return{type:e,operation:2,width:0,height:0,depth:0,phongAngle:35};if(e==="TextGeometry")return{type:e,width:100,height:100,depth:0,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.2,letterSpacing:0,text:"",textTransform:1,font:"Roboto_regular",extrudeBevelSize:0,extrudeBevelSegments:1};throw new Error("not implemented")}r.defaultData=n})(po||(po={}));var Du;(e=>{function n(t){return t==="Component"||t==="Instance"}e.isComponentRelated=n;function r(t){return t==="Empty"||t==="Instance"}e.isEmptyOrComponent=r})(Du||(Du={}));var vn;(o=>{o.identity={...va.identity,hiddenMatrix:uo.identity};function r(i){return{position:i.position,rotation:i.rotation,scale:i.scale,hiddenMatrix:i.hiddenMatrix}}o.fromObject=r;function e(i,s){return{position:s?.position||i.position,rotation:s?.rotation||i.rotation,scale:s?.scale||i.scale,hiddenMatrix:s?.hiddenMatrix||i.hiddenMatrix}}o.merge=e;function t(i,s){return{position:co.isEqual(i.position,s.position)?null:s.position,rotation:co.isEqual(i.rotation,s.rotation)?null:s.rotation,scale:co.isEqual(i.scale,s.scale)?null:s.scale,hiddenMatrix:uo.isEqual(i.hiddenMatrix,s.hiddenMatrix)?null:s.hiddenMatrix}}o.diff=t})(vn||(vn={}));var Ic;(r=>r.defaultData={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]})(Ic||(Ic={}));var qt;(r=>r.defaultData={states:new ge,events:new ge,visible:!0,raycastLock:!1,physics:null,pathSnapping:{pathId:null,slide:0,orientation:"tangential"},...vn.identity,cloner:null})(qt||(qt={}));var Gu;(r=>r.defaultData={type:"Empty",...qt.defaultData})(Gu||(Gu={}));var Ru;(r=>r.defaultData={type:"Component",...qt.defaultData})(Ru||(Ru={}));var Go;(r=>r.defaultData={type:"Mesh",...qt.defaultData,..._a.defaultData})(Go||(Go={}));var bn;(r=>r.defaultData={...qt.defaultData,...vn.identity,...Do.defaultData})(bn||(bn={}));var Vu;(r=>{function n(e){return{...qt.defaultData,...wa.defaultData(e)}}r.defaultData=n})(Vu||(Vu={}));var Sn;(e=>{function n(t,o,i=0){for(;i<o.length;){let s=t?t[o[i]]:void 0;if(o.length===i+1)return s;if(s)t=s.descendants,i+=1;else return}}e.resolveWithDes=n;function r(t,o,i=0){let s=n(t,o,i);if(s){let l=Object.keys(s);if(l.length===1&&l[0]==="descendants")return}return s}e.resolve=r})(Sn||(Sn={}));var fo;(i=>{i.rootOverrideProps=["physics"],i.compositeNonOptionalOverrideProps=["geometry"],i.compositeEntireOverrideOverrideProps=["material"];function t(s,l){return{...qt.defaultData,...l,component:s,overrides:new ke,physics:void 0,type:"Instance"}}i.ofComponent=t;function o(s){let l=vn.fromObject(s.data);return t(s.id,l)}i.fromComponentData=o})(fo||(fo={}));var ju;(i=>(i.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:uo.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:Ic.defaultData,states:new ge,events:new ge,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0},...Do.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",...qt.defaultData,...Go.defaultData,geometry:po.defaultData("RectangleGeometry"),material:Dt.defaultTwoLayerData("phong","layer1","layer2")},i.defaultBooleanObject={name:"Boolean",...qt.defaultData,...Go.defaultData,geometry:po.defaultData("BooleanGeometry"),material:Dt.defaultTwoLayerData("phong","layer1","layer2")},i.defaultTextObject={name:"Text",...qt.defaultData,...Go.defaultData,geometry:po.defaultData("TextGeometry"),material:Dt.defaultTwoLayerData("phong","layer1","layer2")}))(ju||(ju={}));var Ro;(o=>{function n(i,s){let l={name:s};return i.type==="Mesh"?(l.geometry={},"material"in i&&(l.material={layers:new ke}),"materials"in i&&(l.materials=i.materials.map(c=>({layers:new ke})))):cr.is(i.type)&&(l.perspective={},l.orthographic={}),l}o.newEmpty=n;function r(i,s){if(s===void 0)return i;let l={...i};return"material"in l&&"material"in s&&s.material&&(l.material=mn(l.material,c=>{if(typeof c!="string")for(let[u,a]of Object.entries(s.material.layers)){let d=c.layers.data(u);d&&Ot.patch(d,a)}}).data),l.materials&&s.materials&&(l.materials=mn(l.materials,c=>{for(let u=0;u<l.materials.length;u++){let a=s.materials[u];if(typeof a!="string")for(let[d,p]of Object.entries(a.layers)){let f=c[u]?.layers?.data(d);f&&Ot.patch(f,p)}}}).data),l}function e(i,s){let l,c=[],u={orthographic:0,perspective:0,geometry:0};function a(d,p){for(let[f,m]of Object.entries(p.layers)){let{texture:h,...y}=m;if(h!==void 0&&Object.keys(h).length>0){let g={path:[...d,"layers",f,"texture"],props:h,type:0};c.push(g)}if(Object.keys(y).length>0){let g={path:[...d,"layers",f],props:y,type:0};c.push(g)}}}for(let[d,p]of Object.entries(s))if(d!=="name")if(d==="cloner")c.push(...ba.toOps(p,["cloner"]));else if(d==="pathSnapping")c.push({path:[d],props:{slide:p.slide},type:0});else if(d==="material")a(["material"],p);else if(d==="materials")for(let[f,m]of Object.entries(p))a(["materials",f],m);else if(u[d]===0){if(d==="geometry"&&p.extrusion!==void 0){let f={path:[d,"extrusion"],props:p.extrusion,type:0};c.push(f),p={...p},delete p.extrusion}if(Object.keys(p).length>0){let f={path:[d],props:p,type:0};c.push(f)}}else l===void 0&&(l={path:[],props:{},type:0},c.push(l)),l.props[d]=p;return c}o.toOps=e;function t(i,s){if(s===void 0)return i;let l={...i};if(Object.assign(l,vn.merge(l,s)),Object.assign(l,{pathSnapping:Object.assign({},l.pathSnapping,{slide:s.pathSnapping?.slide??l.pathSnapping.slide})}),cr.is(i.type)){l.orthographic={...l.orthographic},l.perspective={...l.perspective};let c=s;c.orthographic?.zoom!==void 0&&(l.orthographic.zoom=c.orthographic.zoom),c.perspective?.zoom!==void 0&&(l.perspective.zoom=c.perspective.zoom),c.isUpVectorFlipped!==void 0&&(l.isUpVectorFlipped=c.isUpVectorFlipped),c.targetOffset!==void 0&&(l.targetOffset=c.targetOffset)}else if(i.type==="Mesh")"geometry"in s&&Object.assign(l,{geometry:Oa.merge(l.geometry,s.geometry)}),(s.material||s.materials)&&(l=r(l,s)),l.cloner&&"cloner"in s&&Object.assign(l,{cloner:Ir.merge(l.cloner,s.cloner)});else if(i.type==="Empty")l.cloner&&"cloner"in s&&Object.assign(l,{cloner:Ir.merge(l.cloner,s.cloner)});else if(Sa.is(i.type)){let c=s;c.intensity!==void 0&&(l.intensity=c.intensity),c.color!==void 0&&(typeof c.color=="string"?l.color=c.color:l.color=Bt.clone(c.color))}return l}o.patch=t})(Ro||(Ro={}));var wn;(r=>r.defaultData={enablePan:!0,enableZoom:!0,enableRotate:!0,enableDamping:!0,rotationLimitsMode:0,rotationVerticalOffset:{min:Math.PI/4,max:Math.PI/4},rotationHorizontalOffset:{min:Math.PI/4,max:Math.PI/4},rotationSoftLimit:2,panLimitsMode:0,panVerticalOffset:{min:250,max:250},panHorizontalOffset:{min:250,max:250},panSoftLimit:2,zoomLimitsEnabled:!1,zoomLimits:{min:.1,max:2},autoRotate:!1,autoRotateSpeed:2,autoRotateClockwise:!0,hoverRotatePanMode:0,hoverRotatePanStrength:20,isTouchZoom:!0,orbitTouches:2,panTouches:3,resetHoverEffectOnPointerLeave:!0,autoZoom:!1})(wn||(wn={}));var Aa;(r=>r.defaultData={orbitControls:wn.defaultData,playCamera:null,withBackground:!0,preventScroll:!1,hideCursor:!1,settings:{image:{format:"jpg",ratio:1},video:{format:"mp4",imageFormat:"jpg",fps:30,mbps:80,ratio:typeof window<"u"?Math.floor(window.devicePixelRatio):1,stopMode:"manual",duration:5e3},web:{compress:!0,preset:1,preload:!0}},stopRaycast:!0,joystickSizeAndXYOffset:Array(12).fill(0).map((e,t)=>{let o=0,i=0;return t<5?i=-30:t<10&&(i=30),t===0||t===10||t===5?o=30:(t===4||t===11||t===9)&&(o=-30),[120,[o,i],"show"]}),gameControlObject:null})(Aa||(Aa={}));function mo(n,r){return Object.setPrototypeOf(n,r),n}function Ia(n){return Array.isArray(n)?n:[n]}function Fu(n,r){let e=0;for(;e<n.length&&e<r.length;){if(n[e]<r[e])return-1;if(n[e]>r[e])return 1;e+=1}return e!==r.length?-1:e!==n.length?1:0}var Ca;(e=>{function n(){let t={};return t["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},mo(t,Ge.prototype)}e.defaultColors=n;function r(){return{materials:new Ge,images:new Ge,videos:new Ge,colors:new Ge,audios:new Ge,fonts:new Ge,penumbraSize:[.5,.5,.5]}}e.emptyData=r})(Ca||(Ca={}));var rx=typeof global=="object"&&global&&global.Object===Object&&global,Na=rx;var ox=typeof self=="object"&&self&&self.Object===Object&&self,nx=Na||ox||Function("return this")(),tt=nx;var ix=tt.Symbol,dt=ix;var zu=Object.prototype,sx=zu.hasOwnProperty,ax=zu.toString,$i=dt?dt.toStringTag:void 0;function lx(n){var r=sx.call(n,$i),e=n[$i];try{n[$i]=void 0;var t=!0}catch{}var o=ax.call(n);return t&&(r?n[$i]=e:delete n[$i]),o}var Uu=lx;var cx=Object.prototype,dx=cx.toString;function ux(n){return dx.call(n)}var ku=ux;var px="[object Null]",fx="[object Undefined]",Hu=dt?dt.toStringTag:void 0;function mx(n){return n==null?n===void 0?fx:px:Hu&&Hu in Object(n)?Uu(n):ku(n)}var $t=mx;function hx(n){return n!=null&&typeof n=="object"}var yt=hx;var yx="[object Symbol]";function gx(n){return typeof n=="symbol"||yt(n)&&$t(n)==yx}var _n=gx;function xx(n,r){for(var e=-1,t=n==null?0:n.length,o=Array(t);++e<t;)o[e]=r(n[e],e,n);return o}var Ea=xx;var vx=Array.isArray,Ye=vx;var bx=1/0,Wu=dt?dt.prototype:void 0,qu=Wu?Wu.toString:void 0;function $u(n){if(typeof n=="string")return n;if(Ye(n))return Ea(n,$u)+"";if(_n(n))return qu?qu.call(n):"";var r=n+"";return r=="0"&&1/n==-bx?"-0":r}var Yu=$u;function Sx(n){var r=typeof n;return n!=null&&(r=="object"||r=="function")}var Yt=Sx;function wx(n){return n}var Xu=wx;var _x="[object AsyncFunction]",Tx="[object Function]",Px="[object GeneratorFunction]",Ox="[object Proxy]";function Ax(n){if(!Yt(n))return!1;var r=$t(n);return r==Tx||r==Px||r==_x||r==Ox}var Ma=Ax;var Ix=tt["__core-js_shared__"],La=Ix;var Ku=function(){var n=/[^.]+$/.exec(La&&La.keys&&La.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}();function Cx(n){return!!Ku&&Ku in n}var Zu=Cx;var Nx=Function.prototype,Ex=Nx.toString;function Mx(n){if(n!=null){try{return Ex.call(n)}catch{}try{return n+""}catch{}}return""}var $r=Mx;var Lx=/[\\^$.*+?()[\]{}|]/g,Bx=/^\[object .+?Constructor\]$/,Dx=Function.prototype,Gx=Object.prototype,Rx=Dx.toString,Vx=Gx.hasOwnProperty,jx=RegExp("^"+Rx.call(Vx).replace(Lx,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Fx(n){if(!Yt(n)||Zu(n))return!1;var r=Ma(n)?jx:Bx;return r.test($r(n))}var Qu=Fx;function zx(n,r){return n?.[r]}var Ju=zx;function Ux(n,r){var e=Ju(n,r);return Qu(e)?e:void 0}var Gt=Ux;var kx=Gt(tt,"WeakMap"),Ba=kx;var ep=Object.create,Hx=function(){function n(){}return function(r){if(!Yt(r))return{};if(ep)return ep(r);n.prototype=r;var e=new n;return n.prototype=void 0,e}}(),tp=Hx;function Wx(n,r,e){switch(e.length){case 0:return n.call(r);case 1:return n.call(r,e[0]);case 2:return n.call(r,e[0],e[1]);case 3:return n.call(r,e[0],e[1],e[2])}return n.apply(r,e)}var rp=Wx;function qx(n,r){var e=-1,t=n.length;for(r||(r=Array(t));++e<t;)r[e]=n[e];return r}var op=qx;var $x=800,Yx=16,Xx=Date.now;function Kx(n){var r=0,e=0;return function(){var t=Xx(),o=Yx-(t-e);if(e=t,o>0){if(++r>=$x)return arguments[0]}else r=0;return n.apply(void 0,arguments)}}var np=Kx;function Zx(n){return function(){return n}}var ip=Zx;var Qx=function(){try{var n=Gt(Object,"defineProperty");return n({},"",{}),n}catch{}}(),Tn=Qx;var Jx=Tn?function(n,r){return Tn(n,"toString",{configurable:!0,enumerable:!1,value:ip(r),writable:!0})}:Xu,sp=Jx;var e0=np(sp),ap=e0;function t0(n,r){for(var e=-1,t=n==null?0:n.length;++e<t&&r(n[e],e,n)!==!1;);return n}var lp=t0;var r0=9007199254740991,o0=/^(?:0|[1-9]\d*)$/;function n0(n,r){var e=typeof n;return r=r??r0,!!r&&(e=="number"||e!="symbol"&&o0.test(n))&&n>-1&&n%1==0&&n<r}var Pn=n0;function i0(n,r,e){r=="__proto__"&&Tn?Tn(n,r,{configurable:!0,enumerable:!0,value:e,writable:!0}):n[r]=e}var Da=i0;function s0(n,r){return n===r||n!==n&&r!==r}var On=s0;var a0=Object.prototype,l0=a0.hasOwnProperty;function c0(n,r,e){var t=n[r];(!(l0.call(n,r)&&On(t,e))||e===void 0&&!(r in n))&&Da(n,r,e)}var An=c0;function d0(n,r,e,t){var o=!e;e||(e={});for(var i=-1,s=r.length;++i<s;){var l=r[i],c=t?t(e[l],n[l],l,e,n):void 0;c===void 0&&(c=n[l]),o?Da(e,l,c):An(e,l,c)}return e}var Cr=d0;var cp=Math.max;function u0(n,r,e){return r=cp(r===void 0?n.length-1:r,0),function(){for(var t=arguments,o=-1,i=cp(t.length-r,0),s=Array(i);++o<i;)s[o]=t[r+o];o=-1;for(var l=Array(r+1);++o<r;)l[o]=t[o];return l[r]=e(s),rp(n,this,l)}}var dp=u0;var p0=9007199254740991;function f0(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=p0}var In=f0;function m0(n){return n!=null&&In(n.length)&&!Ma(n)}var Ga=m0;var h0=Object.prototype;function y0(n){var r=n&&n.constructor,e=typeof r=="function"&&r.prototype||h0;return n===e}var Cn=y0;function g0(n,r){for(var e=-1,t=Array(n);++e<n;)t[e]=r(e);return t}var up=g0;var x0="[object Arguments]";function v0(n){return yt(n)&&$t(n)==x0}var Cc=v0;var pp=Object.prototype,b0=pp.hasOwnProperty,S0=pp.propertyIsEnumerable,w0=Cc(function(){return arguments}())?Cc:function(n){return yt(n)&&b0.call(n,"callee")&&!S0.call(n,"callee")},Nn=w0;function _0(){return!1}var fp=_0;var yp=typeof exports=="object"&&exports&&!exports.nodeType&&exports,mp=yp&&typeof module=="object"&&module&&!module.nodeType&&module,T0=mp&&mp.exports===yp,hp=T0?tt.Buffer:void 0,P0=hp?hp.isBuffer:void 0,O0=P0||fp,Vo=O0;var A0="[object Arguments]",I0="[object Array]",C0="[object Boolean]",N0="[object Date]",E0="[object Error]",M0="[object Function]",L0="[object Map]",B0="[object Number]",D0="[object Object]",G0="[object RegExp]",R0="[object Set]",V0="[object String]",j0="[object WeakMap]",F0="[object ArrayBuffer]",z0="[object DataView]",U0="[object Float32Array]",k0="[object Float64Array]",H0="[object Int8Array]",W0="[object Int16Array]",q0="[object Int32Array]",$0="[object Uint8Array]",Y0="[object Uint8ClampedArray]",X0="[object Uint16Array]",K0="[object Uint32Array]",je={};je[U0]=je[k0]=je[H0]=je[W0]=je[q0]=je[$0]=je[Y0]=je[X0]=je[K0]=!0;je[A0]=je[I0]=je[F0]=je[C0]=je[z0]=je[N0]=je[E0]=je[M0]=je[L0]=je[B0]=je[D0]=je[G0]=je[R0]=je[V0]=je[j0]=!1;function Z0(n){return yt(n)&&In(n.length)&&!!je[$t(n)]}var gp=Z0;function Q0(n){return function(r){return n(r)}}var En=Q0;var xp=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Yi=xp&&typeof module=="object"&&module&&!module.nodeType&&module,J0=Yi&&Yi.exports===xp,Nc=J0&&Na.process,ev=function(){try{var n=Yi&&Yi.require&&Yi.require("util").types;return n||Nc&&Nc.binding&&Nc.binding("util")}catch{}}(),Yr=ev;var vp=Yr&&Yr.isTypedArray,tv=vp?En(vp):gp,Ra=tv;var rv=Object.prototype,ov=rv.hasOwnProperty;function nv(n,r){var e=Ye(n),t=!e&&Nn(n),o=!e&&!t&&Vo(n),i=!e&&!t&&!o&&Ra(n),s=e||t||o||i,l=s?up(n.length,String):[],c=l.length;for(var u in n)(r||ov.call(n,u))&&!(s&&(u=="length"||o&&(u=="offset"||u=="parent")||i&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||Pn(u,c)))&&l.push(u);return l}var Va=nv;function iv(n,r){return function(e){return n(r(e))}}var ja=iv;var sv=ja(Object.keys,Object),bp=sv;var av=Object.prototype,lv=av.hasOwnProperty;function cv(n){if(!Cn(n))return bp(n);var r=[];for(var e in Object(n))lv.call(n,e)&&e!="constructor"&&r.push(e);return r}var Sp=cv;function dv(n){return Ga(n)?Va(n):Sp(n)}var Mn=dv;function uv(n){var r=[];if(n!=null)for(var e in Object(n))r.push(e);return r}var wp=uv;var pv=Object.prototype,fv=pv.hasOwnProperty;function mv(n){if(!Yt(n))return wp(n);var r=Cn(n),e=[];for(var t in n)t=="constructor"&&(r||!fv.call(n,t))||e.push(t);return e}var _p=mv;function hv(n){return Ga(n)?Va(n,!0):_p(n)}var Ln=hv;var yv=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,gv=/^\w*$/;function xv(n,r){if(Ye(n))return!1;var e=typeof n;return e=="number"||e=="symbol"||e=="boolean"||n==null||_n(n)?!0:gv.test(n)||!yv.test(n)||r!=null&&n in Object(r)}var Tp=xv;var vv=Gt(Object,"create"),Xr=vv;function bv(){this.__data__=Xr?Xr(null):{},this.size=0}var Pp=bv;function Sv(n){var r=this.has(n)&&delete this.__data__[n];return this.size-=r?1:0,r}var Op=Sv;var wv="__lodash_hash_undefined__",_v=Object.prototype,Tv=_v.hasOwnProperty;function Pv(n){var r=this.__data__;if(Xr){var e=r[n];return e===wv?void 0:e}return Tv.call(r,n)?r[n]:void 0}var Ap=Pv;var Ov=Object.prototype,Av=Ov.hasOwnProperty;function Iv(n){var r=this.__data__;return Xr?r[n]!==void 0:Av.call(r,n)}var Ip=Iv;var Cv="__lodash_hash_undefined__";function Nv(n,r){var e=this.__data__;return this.size+=this.has(n)?0:1,e[n]=Xr&&r===void 0?Cv:r,this}var Cp=Nv;function Bn(n){var r=-1,e=n==null?0:n.length;for(this.clear();++r<e;){var t=n[r];this.set(t[0],t[1])}}Bn.prototype.clear=Pp;Bn.prototype.delete=Op;Bn.prototype.get=Ap;Bn.prototype.has=Ip;Bn.prototype.set=Cp;var Ec=Bn;function Ev(){this.__data__=[],this.size=0}var Np=Ev;function Mv(n,r){for(var e=n.length;e--;)if(On(n[e][0],r))return e;return-1}var ho=Mv;var Lv=Array.prototype,Bv=Lv.splice;function Dv(n){var r=this.__data__,e=ho(r,n);if(e<0)return!1;var t=r.length-1;return e==t?r.pop():Bv.call(r,e,1),--this.size,!0}var Ep=Dv;function Gv(n){var r=this.__data__,e=ho(r,n);return e<0?void 0:r[e][1]}var Mp=Gv;function Rv(n){return ho(this.__data__,n)>-1}var Lp=Rv;function Vv(n,r){var e=this.__data__,t=ho(e,n);return t<0?(++this.size,e.push([n,r])):e[t][1]=r,this}var Bp=Vv;function Dn(n){var r=-1,e=n==null?0:n.length;for(this.clear();++r<e;){var t=n[r];this.set(t[0],t[1])}}Dn.prototype.clear=Np;Dn.prototype.delete=Ep;Dn.prototype.get=Mp;Dn.prototype.has=Lp;Dn.prototype.set=Bp;var yo=Dn;var jv=Gt(tt,"Map"),go=jv;function Fv(){this.size=0,this.__data__={hash:new Ec,map:new(go||yo),string:new Ec}}var Dp=Fv;function zv(n){var r=typeof n;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?n!=="__proto__":n===null}var Gp=zv;function Uv(n,r){var e=n.__data__;return Gp(r)?e[typeof r=="string"?"string":"hash"]:e.map}var xo=Uv;function kv(n){var r=xo(this,n).delete(n);return this.size-=r?1:0,r}var Rp=kv;function Hv(n){return xo(this,n).get(n)}var Vp=Hv;function Wv(n){return xo(this,n).has(n)}var jp=Wv;function qv(n,r){var e=xo(this,n),t=e.size;return e.set(n,r),this.size+=e.size==t?0:1,this}var Fp=qv;function Gn(n){var r=-1,e=n==null?0:n.length;for(this.clear();++r<e;){var t=n[r];this.set(t[0],t[1])}}Gn.prototype.clear=Dp;Gn.prototype.delete=Rp;Gn.prototype.get=Vp;Gn.prototype.has=jp;Gn.prototype.set=Fp;var jo=Gn;var $v="Expected a function";function Mc(n,r){if(typeof n!="function"||r!=null&&typeof r!="function")throw new TypeError($v);var e=function(){var t=arguments,o=r?r.apply(this,t):t[0],i=e.cache;if(i.has(o))return i.get(o);var s=n.apply(this,t);return e.cache=i.set(o,s)||i,s};return e.cache=new(Mc.Cache||jo),e}Mc.Cache=jo;var zp=Mc;var Yv=500;function Xv(n){var r=zp(n,function(t){return e.size===Yv&&e.clear(),t}),e=r.cache;return r}var Up=Xv;var Kv=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Zv=/\\(\\)?/g,Qv=Up(function(n){var r=[];return n.charCodeAt(0)===46&&r.push(""),n.replace(Kv,function(e,t,o,i){r.push(o?i.replace(Zv,"$1"):t||e)}),r}),kp=Qv;function Jv(n){return n==null?"":Yu(n)}var Hp=Jv;function eb(n,r){return Ye(n)?n:Tp(n,r)?[n]:kp(Hp(n))}var Qt=eb;var tb=1/0;function rb(n){if(typeof n=="string"||_n(n))return n;var r=n+"";return r=="0"&&1/n==-tb?"-0":r}var vo=rb;function ob(n,r){r=Qt(r,n);for(var e=0,t=r.length;n!=null&&e<t;)n=n[vo(r[e++])];return e&&e==t?n:void 0}var Fa=ob;function nb(n,r){for(var e=-1,t=r.length,o=n.length;++e<t;)n[o+e]=r[e];return n}var Rn=nb;var Wp=dt?dt.isConcatSpreadable:void 0;function ib(n){return Ye(n)||Nn(n)||!!(Wp&&n&&n[Wp])}var qp=ib;function $p(n,r,e,t,o){var i=-1,s=n.length;for(e||(e=qp),o||(o=[]);++i<s;){var l=n[i];r>0&&e(l)?r>1?$p(l,r-1,e,t,o):Rn(o,l):t||(o[o.length]=l)}return o}var Yp=$p;function sb(n){var r=n==null?0:n.length;return r?Yp(n,1):[]}var Xp=sb;function ab(n){return ap(dp(n,void 0,Xp),n+"")}var za=ab;var lb=ja(Object.getPrototypeOf,Object),Vn=lb;var cb="[object Object]",db=Function.prototype,ub=Object.prototype,Kp=db.toString,pb=ub.hasOwnProperty,fb=Kp.call(Object);function mb(n){if(!yt(n)||$t(n)!=cb)return!1;var r=Vn(n);if(r===null)return!0;var e=pb.call(r,"constructor")&&r.constructor;return typeof e=="function"&&e instanceof e&&Kp.call(e)==fb}var Zp=mb;function hb(n,r,e){var t=-1,o=n.length;r<0&&(r=-r>o?0:o+r),e=e>o?o:e,e<0&&(e+=o),o=r>e?0:e-r>>>0,r>>>=0;for(var i=Array(o);++t<o;)i[t]=n[t+r];return i}var Qp=hb;function yb(){this.__data__=new yo,this.size=0}var Jp=yb;function gb(n){var r=this.__data__,e=r.delete(n);return this.size=r.size,e}var ef=gb;function xb(n){return this.__data__.get(n)}var tf=xb;function vb(n){return this.__data__.has(n)}var rf=vb;var bb=200;function Sb(n,r){var e=this.__data__;if(e instanceof yo){var t=e.__data__;if(!go||t.length<bb-1)return t.push([n,r]),this.size=++e.size,this;e=this.__data__=new jo(t)}return e.set(n,r),this.size=e.size,this}var of=Sb;function jn(n){var r=this.__data__=new yo(n);this.size=r.size}jn.prototype.clear=Jp;jn.prototype.delete=ef;jn.prototype.get=tf;jn.prototype.has=rf;jn.prototype.set=of;var Fn=jn;function wb(n,r){return n&&Cr(r,Mn(r),n)}var nf=wb;function _b(n,r){return n&&Cr(r,Ln(r),n)}var sf=_b;var df=typeof exports=="object"&&exports&&!exports.nodeType&&exports,af=df&&typeof module=="object"&&module&&!module.nodeType&&module,Tb=af&&af.exports===df,lf=Tb?tt.Buffer:void 0,cf=lf?lf.allocUnsafe:void 0;function Pb(n,r){if(r)return n.slice();var e=n.length,t=cf?cf(e):new n.constructor(e);return n.copy(t),t}var uf=Pb;function Ob(n,r){for(var e=-1,t=n==null?0:n.length,o=0,i=[];++e<t;){var s=n[e];r(s,e,n)&&(i[o++]=s)}return i}var pf=Ob;function Ab(){return[]}var Ua=Ab;var Ib=Object.prototype,Cb=Ib.propertyIsEnumerable,ff=Object.getOwnPropertySymbols,Nb=ff?function(n){return n==null?[]:(n=Object(n),pf(ff(n),function(r){return Cb.call(n,r)}))}:Ua,zn=Nb;function Eb(n,r){return Cr(n,zn(n),r)}var mf=Eb;var Mb=Object.getOwnPropertySymbols,Lb=Mb?function(n){for(var r=[];n;)Rn(r,zn(n)),n=Vn(n);return r}:Ua,ka=Lb;function Bb(n,r){return Cr(n,ka(n),r)}var hf=Bb;function Db(n,r,e){var t=r(n);return Ye(n)?t:Rn(t,e(n))}var Ha=Db;function Gb(n){return Ha(n,Mn,zn)}var Xi=Gb;function Rb(n){return Ha(n,Ln,ka)}var Wa=Rb;var Vb=Gt(tt,"DataView"),qa=Vb;var jb=Gt(tt,"Promise"),$a=jb;var Fb=Gt(tt,"Set"),Ya=Fb;var yf="[object Map]",zb="[object Object]",gf="[object Promise]",xf="[object Set]",vf="[object WeakMap]",bf="[object DataView]",Ub=$r(qa),kb=$r(go),Hb=$r($a),Wb=$r(Ya),qb=$r(Ba),Fo=$t;(qa&&Fo(new qa(new ArrayBuffer(1)))!=bf||go&&Fo(new go)!=yf||$a&&Fo($a.resolve())!=gf||Ya&&Fo(new Ya)!=xf||Ba&&Fo(new Ba)!=vf)&&(Fo=function(n){var r=$t(n),e=r==zb?n.constructor:void 0,t=e?$r(e):"";if(t)switch(t){case Ub:return bf;case kb:return yf;case Hb:return gf;case Wb:return xf;case qb:return vf}return r});var Kr=Fo;var $b=Object.prototype,Yb=$b.hasOwnProperty;function Xb(n){var r=n.length,e=new n.constructor(r);return r&&typeof n[0]=="string"&&Yb.call(n,"index")&&(e.index=n.index,e.input=n.input),e}var Sf=Xb;var Kb=tt.Uint8Array,Un=Kb;function Zb(n){var r=new n.constructor(n.byteLength);return new Un(r).set(new Un(n)),r}var kn=Zb;function Qb(n,r){var e=r?kn(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.byteLength)}var wf=Qb;var Jb=/\w*$/;function eS(n){var r=new n.constructor(n.source,Jb.exec(n));return r.lastIndex=n.lastIndex,r}var _f=eS;var Tf=dt?dt.prototype:void 0,Pf=Tf?Tf.valueOf:void 0;function tS(n){return Pf?Object(Pf.call(n)):{}}var Of=tS;function rS(n,r){var e=r?kn(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.length)}var Af=rS;var oS="[object Boolean]",nS="[object Date]",iS="[object Map]",sS="[object Number]",aS="[object RegExp]",lS="[object Set]",cS="[object String]",dS="[object Symbol]",uS="[object ArrayBuffer]",pS="[object DataView]",fS="[object Float32Array]",mS="[object Float64Array]",hS="[object Int8Array]",yS="[object Int16Array]",gS="[object Int32Array]",xS="[object Uint8Array]",vS="[object Uint8ClampedArray]",bS="[object Uint16Array]",SS="[object Uint32Array]";function wS(n,r,e){var t=n.constructor;switch(r){case uS:return kn(n);case oS:case nS:return new t(+n);case pS:return wf(n,e);case fS:case mS:case hS:case yS:case gS:case xS:case vS:case bS:case SS:return Af(n,e);case iS:return new t;case sS:case cS:return new t(n);case aS:return _f(n);case lS:return new t;case dS:return Of(n)}}var If=wS;function _S(n){return typeof n.constructor=="function"&&!Cn(n)?tp(Vn(n)):{}}var Cf=_S;var TS="[object Map]";function PS(n){return yt(n)&&Kr(n)==TS}var Nf=PS;var Ef=Yr&&Yr.isMap,OS=Ef?En(Ef):Nf,Mf=OS;var AS="[object Set]";function IS(n){return yt(n)&&Kr(n)==AS}var Lf=IS;var Bf=Yr&&Yr.isSet,CS=Bf?En(Bf):Lf,Df=CS;var NS=1,ES=2,MS=4,Gf="[object Arguments]",LS="[object Array]",BS="[object Boolean]",DS="[object Date]",GS="[object Error]",Rf="[object Function]",RS="[object GeneratorFunction]",VS="[object Map]",jS="[object Number]",Vf="[object Object]",FS="[object RegExp]",zS="[object Set]",US="[object String]",kS="[object Symbol]",HS="[object WeakMap]",WS="[object ArrayBuffer]",qS="[object DataView]",$S="[object Float32Array]",YS="[object Float64Array]",XS="[object Int8Array]",KS="[object Int16Array]",ZS="[object Int32Array]",QS="[object Uint8Array]",JS="[object Uint8ClampedArray]",e1="[object Uint16Array]",t1="[object Uint32Array]",Re={};Re[Gf]=Re[LS]=Re[WS]=Re[qS]=Re[BS]=Re[DS]=Re[$S]=Re[YS]=Re[XS]=Re[KS]=Re[ZS]=Re[VS]=Re[jS]=Re[Vf]=Re[FS]=Re[zS]=Re[US]=Re[kS]=Re[QS]=Re[JS]=Re[e1]=Re[t1]=!0;Re[GS]=Re[Rf]=Re[HS]=!1;function Xa(n,r,e,t,o,i){var s,l=r&NS,c=r&ES,u=r&MS;if(e&&(s=o?e(n,t,o,i):e(n)),s!==void 0)return s;if(!Yt(n))return n;var a=Ye(n);if(a){if(s=Sf(n),!l)return op(n,s)}else{var d=Kr(n),p=d==Rf||d==RS;if(Vo(n))return uf(n,l);if(d==Vf||d==Gf||p&&!o){if(s=c||p?{}:Cf(n),!l)return c?hf(n,sf(s,n)):mf(n,nf(s,n))}else{if(!Re[d])return o?n:{};s=If(n,d,l)}}i||(i=new Fn);var f=i.get(n);if(f)return f;i.set(n,s),Df(n)?n.forEach(function(y){s.add(Xa(y,r,e,y,n,i))}):Mf(n)&&n.forEach(function(y,g){s.set(g,Xa(y,r,e,g,n,i))});var m=u?c?Wa:Xi:c?Ln:Mn,h=a?void 0:m(n);return lp(h||n,function(y,g){h&&(g=y,y=n[g]),An(s,g,Xa(y,r,e,g,n,i))}),s}var Ka=Xa;var r1=1,o1=4;function n1(n){return Ka(n,r1|o1)}var Zr=n1;var i1="__lodash_hash_undefined__";function s1(n){return this.__data__.set(n,i1),this}var jf=s1;function a1(n){return this.__data__.has(n)}var Ff=a1;function Za(n){var r=-1,e=n==null?0:n.length;for(this.__data__=new jo;++r<e;)this.add(n[r])}Za.prototype.add=Za.prototype.push=jf;Za.prototype.has=Ff;var zf=Za;function l1(n,r){for(var e=-1,t=n==null?0:n.length;++e<t;)if(r(n[e],e,n))return!0;return!1}var Uf=l1;function c1(n,r){return n.has(r)}var kf=c1;var d1=1,u1=2;function p1(n,r,e,t,o,i){var s=e&d1,l=n.length,c=r.length;if(l!=c&&!(s&&c>l))return!1;var u=i.get(n),a=i.get(r);if(u&&a)return u==r&&a==n;var d=-1,p=!0,f=e&u1?new zf:void 0;for(i.set(n,r),i.set(r,n);++d<l;){var m=n[d],h=r[d];if(t)var y=s?t(h,m,d,r,n,i):t(m,h,d,n,r,i);if(y!==void 0){if(y)continue;p=!1;break}if(f){if(!Uf(r,function(g,v){if(!kf(f,v)&&(m===g||o(m,g,e,t,i)))return f.push(v)})){p=!1;break}}else if(!(m===h||o(m,h,e,t,i))){p=!1;break}}return i.delete(n),i.delete(r),p}var Qa=p1;function f1(n){var r=-1,e=Array(n.size);return n.forEach(function(t,o){e[++r]=[o,t]}),e}var Hf=f1;function m1(n){var r=-1,e=Array(n.size);return n.forEach(function(t){e[++r]=t}),e}var Wf=m1;var h1=1,y1=2,g1="[object Boolean]",x1="[object Date]",v1="[object Error]",b1="[object Map]",S1="[object Number]",w1="[object RegExp]",_1="[object Set]",T1="[object String]",P1="[object Symbol]",O1="[object ArrayBuffer]",A1="[object DataView]",qf=dt?dt.prototype:void 0,Lc=qf?qf.valueOf:void 0;function I1(n,r,e,t,o,i,s){switch(e){case A1:if(n.byteLength!=r.byteLength||n.byteOffset!=r.byteOffset)return!1;n=n.buffer,r=r.buffer;case O1:return!(n.byteLength!=r.byteLength||!i(new Un(n),new Un(r)));case g1:case x1:case S1:return On(+n,+r);case v1:return n.name==r.name&&n.message==r.message;case w1:case T1:return n==r+"";case b1:var l=Hf;case _1:var c=t&h1;if(l||(l=Wf),n.size!=r.size&&!c)return!1;var u=s.get(n);if(u)return u==r;t|=y1,s.set(n,r);var a=Qa(l(n),l(r),t,o,i,s);return s.delete(n),a;case P1:if(Lc)return Lc.call(n)==Lc.call(r)}return!1}var $f=I1;var C1=1,N1=Object.prototype,E1=N1.hasOwnProperty;function M1(n,r,e,t,o,i){var s=e&C1,l=Xi(n),c=l.length,u=Xi(r),a=u.length;if(c!=a&&!s)return!1;for(var d=c;d--;){var p=l[d];if(!(s?p in r:E1.call(r,p)))return!1}var f=i.get(n),m=i.get(r);if(f&&m)return f==r&&m==n;var h=!0;i.set(n,r),i.set(r,n);for(var y=s;++d<c;){p=l[d];var g=n[p],v=r[p];if(t)var w=s?t(v,g,p,r,n,i):t(g,v,p,n,r,i);if(!(w===void 0?g===v||o(g,v,e,t,i):w)){h=!1;break}y||(y=p=="constructor")}if(h&&!y){var S=n.constructor,b=r.constructor;S!=b&&"constructor"in n&&"constructor"in r&&!(typeof S=="function"&&S instanceof S&&typeof b=="function"&&b instanceof b)&&(h=!1)}return i.delete(n),i.delete(r),h}var Yf=M1;var L1=1,Xf="[object Arguments]",Kf="[object Array]",Ja="[object Object]",B1=Object.prototype,Zf=B1.hasOwnProperty;function D1(n,r,e,t,o,i){var s=Ye(n),l=Ye(r),c=s?Kf:Kr(n),u=l?Kf:Kr(r);c=c==Xf?Ja:c,u=u==Xf?Ja:u;var a=c==Ja,d=u==Ja,p=c==u;if(p&&Vo(n)){if(!Vo(r))return!1;s=!0,a=!1}if(p&&!a)return i||(i=new Fn),s||Ra(n)?Qa(n,r,e,t,o,i):$f(n,r,c,e,t,o,i);if(!(e&L1)){var f=a&&Zf.call(n,"__wrapped__"),m=d&&Zf.call(r,"__wrapped__");if(f||m){var h=f?n.value():n,y=m?r.value():r;return i||(i=new Fn),o(h,y,e,t,i)}}return p?(i||(i=new Fn),Yf(n,r,e,t,o,i)):!1}var Qf=D1;function Jf(n,r,e,t,o){return n===r?!0:n==null||r==null||!yt(n)&&!yt(r)?n!==n&&r!==r:Qf(n,r,e,t,Jf,o)}var em=Jf;function G1(n,r){return n!=null&&r in Object(n)}var tm=G1;function R1(n,r,e){r=Qt(r,n);for(var t=-1,o=r.length,i=!1;++t<o;){var s=vo(r[t]);if(!(i=n!=null&&e(n,s)))break;n=n[s]}return i||++t!=o?i:(o=n==null?0:n.length,!!o&&In(o)&&Pn(s,o)&&(Ye(n)||Nn(n)))}var rm=R1;function V1(n,r){return n!=null&&rm(n,r,tm)}var om=V1;function j1(n){var r=n==null?0:n.length;return r?n[r-1]:void 0}var nm=j1;function F1(n,r){return r.length<2?n:Fa(n,Qp(r,0,-1))}var im=F1;function z1(n,r){return em(n,r)}var Ki=z1;function U1(n,r){return r=Qt(r,n),n=im(n,r),n==null||delete n[vo(nm(r))]}var sm=U1;function k1(n){return Zp(n)?void 0:n}var am=k1;var H1=1,W1=2,q1=4,$1=za(function(n,r){var e={};if(n==null)return e;var t=!1;r=Ea(r,function(i){return i=Qt(i,n),t||(t=i.length>1),i}),Cr(n,Wa(n),e),t&&(e=Ka(e,H1|W1|q1,am));for(var o=r.length;o--;)sm(e,r[o]);return e}),Hn=$1;function Y1(n,r,e,t){if(!Yt(n))return n;r=Qt(r,n);for(var o=-1,i=r.length,s=i-1,l=n;l!=null&&++o<i;){var c=vo(r[o]),u=e;if(c==="__proto__"||c==="constructor"||c==="prototype")return n;if(o!=s){var a=l[c];u=t?t(a,c,l):void 0,u===void 0&&(u=Yt(a)?a:Pn(r[o+1])?[]:{})}An(l,c,u),l=l[c]}return n}var lm=Y1;function X1(n,r,e){for(var t=-1,o=r.length,i={};++t<o;){var s=r[t],l=Fa(n,s);e(l,s)&&lm(i,Qt(s,n),l)}return i}var cm=X1;function K1(n,r){return cm(n,r,function(e,t){return om(n,t)})}var dm=K1;var Z1=za(function(n,r){return n==null?{}:dm(n,r)}),Wn=Z1;var Zi=require("three");function um(n){n.layers.forEach(r=>{if(r.type==="depth"&&r.colorA!==void 0){let e=r.colorA,t=r.colorB,o=[[e.r,e.g,e.b,e.a],[t.r,t.g,t.b,t.a]],i=[0,1];for(let l=2;l<10;l++)o.push(o[1]),i.push(1);let s={...Wn(lt(r),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,r.near),far:Math.max(0,r.far),colors:o,steps:i,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(r,s)}else if(r.type==="depth"&&r.gradientType===1&&(r.near<0||r.far<0)){let e={...lt(r),near:Math.max(r.near,0),far:Math.max(r.far,0)};Object.assign(r,e)}})}function el(n,r){Object.values(n.shared.materials).forEach(e=>r(e))}function tl(n,r){n.scene.objects.traverse((e,t)=>{"materials"in t?t.materials.forEach(o=>{typeof o!="string"&&r(o)}):"material"in t&&typeof t.material!="string"&&r(t.material)})}function Q1(n){Object.assign(n.scene.publish,{orbitControls:{...wn.defaultData,...lt(n.scene.publish.orbitControls)}})}function J1(n){Object.assign(n.scene.publish.settings,{video:{...Aa.defaultData.settings.video,...lt(n.scene.publish.settings.video)}})}function ew(n){function r(e){if(e.layers){for(let t of Object.values(e.layers))if(t){for(let[o,i]of Object.entries(t))if((Lu.includes(o)||typeof i=="boolean")&&delete t[o],o==="texture")for(let[s,l]of Object.entries(i))(Bu.includes(s)||typeof l=="boolean")&&delete i[s]}}}n.scene.objects.traverse((e,t)=>{t.states.forEach(o=>{let i=o;i.material?r(i.material):i.materials&&i.materials.forEach(s=>{r(s)})})})}function tw(n){n.scene.publish.withBackground=!0}function rw(n){n.scene.publish.settings.web={compress:!0,preload:!0,preset:1}}function ow(n){n.scene.objects.traverse((r,e)=>{let t=e.cloner;t&&(t.radial.scale=t.radial.scale.map(o=>o+1),t.linear.scale=t.linear.scale.map(o=>o+1))})}function nw(n){n.scene.objects.traverse((r,e)=>{let t=e.geometry;t&&(t.type==="DodecahedronGeometry"||t.type==="IcosahedronGeometry")&&(t.detail=Math.round(t.detail))})}function iw(n){n.scene.objects.traverse((r,e)=>{let t=n.scene.objects.unproxy().parent(r);if(t){let o=lt(n.scene.objects.data(t));o&&o.type==="Mesh"&&o.geometry.type==="BooleanGeometry"&&e.type==="Mesh"&&(e.visible=lt(e).booleanExclude!==!0)}})}function sw(n){n.scene.objects.traverse((r,e)=>{if(e.type==="Mesh"){let t=e;e.geometry.type==="NonParametricGeometry"?t.material!==void 0&&delete t.material:t.materials!==void 0&&delete t.materials}})}function aw(n){function r(t){Object.setPrototypeOf(t,ke.prototype),t.texture&&Object.setPrototypeOf(t.texture,ke.prototype)}function e(t){Object.setPrototypeOf(t,ke.prototype);for(let o in t)r(t[o])}n.scene.objects.traverse((t,o)=>{o.states.forEach(i=>{let s=i;if(s.material){let l=lt(s.material).layers;e(l),s.material.layers=l}if(s.materials)for(let l=0;l<s.materials.length;l++){let c=s.materials[l],u=lt(c).layers;e(u),c.layers=u}})})}function pm(n){n.layers===void 0&&Object.assign(n,Dt.defaultTwoLayerData("lambert"))}function Bc(n){!n.layers||n.layers.forEach(r=>{if(r.type==="depth"&&r.colors.length===10){let e=[...r.colors];e.push(r.colors[9]);let t=[...r.steps];t.push(r.steps[9]);let o={...lt(r),colors:e,steps:t};Object.assign(r,o)}})}function lw(n){n.scene.objects.traverse((r,e)=>{e.type==="Mesh"&&(e.geometry.type==="BooleanGeometry"||e.geometry.type==="SubdivGeometry")&&(e.geometry.phongAngle=35)})}function fm(n){n.scene.objects.traverse((r,e)=>{"materials"in e?e.materials.forEach(t=>{typeof t!="string"&&Bc(t)}):"material"in e&&typeof e.material!="string"&&Bc(e.material)}),Object.values(n.shared.materials).forEach(r=>Bc(r))}function cw(n){n.scene.environment.ambientLight.softShadows=!1,n.scene.environment.ambientLight.softShadowQuality="low",n.scene.objects.traverse((r,e)=>{(e.type==="DirectionalLight"||e.type==="SpotLight")&&(e.shadowResolution=1024,e.shadowRadius=1,e.depth=1e5)}),n.shared.penumbraSize=new Array(5).fill(.5)}function dw(n){n.shared.audios=mo({},Ge.prototype)}function uw(n){n.shared.videos=mo({},Ge.prototype)}function pw(n){let r=n.shared.materials;Object.entries(r).forEach(([e,t])=>{if(!t.layers){let o={name:"Untitled Material",layers:[{fi:0,data:{type:"light",category:"phong",alpha:.6,visible:!0,mode:0,specular:{r:.2,g:.2,b:.2},shininess:5},id:"layer1"},{fi:1,data:{type:"color",alpha:1,visible:!0,mode:0,color:{r:.2823529411764706,g:.2823529411764706,b:.30196078431372547}},id:"layer2"}]};Object.assign(r,{[e]:o})}})}function fw(n){Object.entries(lt(n.shared.images)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete n.shared.images[t]}),Object.entries(lt(n.shared.audios)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete n.shared.audios[t]})}function mw(n){n.scene.publish.settings.web.preload=!1}function mm(n){n.layers&&n.layers.forEach(r=>{r.type==="depth"&&r.num!==void 0&&(r.colors=r.colors.slice(0,r.num),r.steps=r.steps.slice(0,r.num),delete r.num)})}function hw(n){n.shared.fonts=mo({},Ge.prototype)}function yw(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 gw(n){let r=[];n.scene.objects.traverse((e,t)=>{let o=t;if(o.type==="TextFrame"){let i=Dt.defaultTwoLayerData("phong"),s=typeof o.color=="string"?n.shared.colors[o.color]:o.color;i.layers[1].data.color={r:s.r,g:s.g,b:s.b},i.layers[1].data.alpha=o.alpha;let l=yw(o.font);n.shared.fonts[l]===void 0&&(n.shared.fonts[l]={name:l});let c={name:o.name,...qt.defaultData,...Go.defaultData,flatShading:!1,wireframe:!1,geometry:{...po.defaultData("TextGeometry"),width:o.width,height:o.height,font:l,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:lt(o.states),events:lt(o.events),visible:o.visible,raycastLock:o.raycastLock,position:o.position,rotation:o.rotation,scale:o.scale,hiddenMatrix:o.hiddenMatrix},u=lt(n.scene.objects).parent(e);n.scene.objects.insertAfter(u??null,e,[{id:e+"new",data:c,children:[]}]),r.push(e)}}),r.forEach(e=>{n.scene.objects.delete(e)})}function xw(n){let r={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};n.scene.objects.traverse((e,t)=>{t.events.forEach(o=>{if(!!r[Number(o.type)])if(Object.assign(o,{type:r[Number(o.type)]}),o.type==="Audio"&&"audioEvent"in o&&(Object.assign(o,{playAudio:o.audioEvent}),delete o.audioEvent),o.type==="GameControl")Object.assign(o,{gameActions:{idle:new ge,move:new ge,jump:new ge}});else{let i=new ge;Object.assign(o,{actions:i}),(o.type==="MouseDown"||o.type==="MouseUp"||o.type==="KeyDown"||o.type==="KeyUp")&&"url"in o&&i.push({fi:0,id:Zi.MathUtils.generateUUID(),data:{type:"Link",url:o.url,delay:0}}),"targets"in o&&(o.targets.forEach((s,l,c)=>{let u={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},a={easing:s.easing,duration:s.duration};s.easing===6?Object.assign(a,Wn(s,"mass","stiffness","damping","velocity")):s.easing===5&&Object.assign(a,{control1:{...s.control1},control2:{...s.control2}});let d={repeat:s.repeat?-1:0,delay:s.delay,delayDirection:s.delayDirection,direction:s.cycle&&s.rewind?"pingpong-rewind":s.cycle?"pingpong":"normal"},p={state:s.state,...d,...a},f={allowSlerp:!0,type:"Transition",object:s.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new ge({fi:0,id:Zi.MathUtils.generateUUID(),data:u},{fi:1,id:Zi.MathUtils.generateUUID(),data:p})};i.push({fi:c,id:l,data:f})}),delete o.targets)}})})}function vw(n){n.scene.objects.traverse((r,e)=>{function t(o,i){let s=new ge,l=[];if(e.events.forEach((c,u,a)=>{if(c.type==="Audio"&&c.trigger===i){let d;l.push(u),c.interaction==="play"?d={...Wn(c,"interaction","audio","delay","volume","loop"),triggerAfter:"after"in c?c.after:void 0,toggle:"after"in c?c.toggle:void 0,type:"Audio"}:(c.interaction==="pause"||c.interaction==="stop")&&(d={...Wn(c,"interaction","delay","object","playAudio"),type:"Audio"}),d&&s.push({fi:a,id:u,data:d})}}),l.forEach(c=>e.events.delete(c)),s.length){let c=e.events.find(u=>u.type===o)?.data;c?"actions"in c&&c.actions.insertBefore(null,s):e.events.insertBefore(null,[{id:Zi.MathUtils.generateUUID(),data:{type:o,actions:s}}])}}t("Start","start"),t("MouseDown","mouseDown"),t("MouseUp","mouseUp"),t("KeyDown","keyDown"),t("KeyUp","keyUp")})}function hm(n){let r=n.layers.find(e=>e.type==="light")?.data;if(r?.category==="basic"){let e=Ot.defaultData("light","phong"),t=r;Object.assign(t,e),t.visible=!1}}function ym(n){el(n,hm),tl(n,hm)}function bw(n){n.scene.objects.traverse((r,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(e.geometry.scaleBaked||(e.geometry.scaleBaked=[1,1,1]))})}function Sw(n){n.scene.objects.traverse((r,e)=>{(e.type==="Empty"||e.type==="Mesh")&&e.cloner&&!e.cloner.randomnessObject&&!e.cloner.toObject&&!e.cloner.randomness&&(e.cloner={...e.cloner,toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}})})}function ww(n){n.scene.objects.traverse((r,e)=>{e.type==="Mesh"&&e.geometry.type==="NonParametricGeometry"&&!("material"in e)&&!("materials"in e)&&(e.material=Dt.defaultTwoLayerData("phong"))})}function _w(n){n.scene.publish.orbitControls.autoZoom===void 0&&(n.scene.publish.orbitControls.autoZoom=!1),n.scene.objects.traverse((r,e)=>{(e.type==="OrthographicCamera"||e.type==="PerspectiveCamera")&&(e.orthographic.autoZoom===void 0&&(e.orthographic.autoZoom=!1),e.orthographic.autoZoomFrustumSize===void 0&&(e.orthographic.autoZoomFrustumSize=790))})}function Tw(n){n.scene.objects.traverse((r,e)=>{e.pathSnapping===void 0&&(e.pathSnapping={pathId:null,slide:0,orientation:"tangential"})})}var gm=32;function xm(n){let r=n.schema??0;r!==gm&&(console.warn("updating from ",r,"to ",gm),r<1&&(tl(n,um),el(n,um),n.schema=1),r<2&&(Q1(n),n.schema=2),r<3&&(ew(n),n.schema=3),r<4&&(tw(n),n.schema=4),r<5&&(rw(n),n.schema=5),r<6&&(ow(n),n.schema=6),r<7&&(nw(n),n.schema=7),r<8&&(n.schema=8),r<9&&(fm(n),n.schema=9),r<10&&(lw(n),n.schema=10),r<11&&(cw(n),n.schema=11),r<12&&(fm(n),n.schema=12),r<13&&(dw(n),n.schema=13),r<14&&(pw(n),n.schema=14),r<15&&(fw(n),n.schema=15),r<16&&(mw(n),n.schema=16),r<17&&(tl(n,mm),el(n,mm),n.schema=17),r<18&&(tl(n,pm),el(n,pm),n.schema=18),r<19&&(J1(n),n.schema=19),r<20&&(hw(n),gw(n),n.schema=20),r<21&&(xw(n),vw(n),n.schema=21),r<22&&(ym(n),n.schema=22),r<23&&(bw(n),n.schema=23),r<24&&(Sw(n),n.schema=24),(r<25||n.shared.videos===void 0)&&(uw(n),r<25&&(n.schema=25)),r<26&&(iw(n),n.schema=26),r<27&&(sw(n),n.schema=27),r<28&&(ym(n),n.schema=28),r<29&&(aw(n),n.schema=29),r<30&&(ww(n),n.schema=30),r<31&&(_w(n),n.schema=31),r<32&&(Tw(n),n.schema=32))}var rl;(r=>r.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII="})(rl||(rl={}));var Ce=require("three"),Ii=Ri(bm());var Pw=.5*(Math.sqrt(3)-1),Ji=(3-Math.sqrt(3))/6,Ow=1/3,Nr=1/6,$3=(Math.sqrt(5)-1)/4,Y3=(5-Math.sqrt(5))/20,es=n=>Math.floor(n)|0,Sm=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]),Gc=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 ol(n=Math.random){let r=_m(n),e=new Float64Array(r).map(o=>Sm[o%12*2]),t=new Float64Array(r).map(o=>Sm[o%12*2+1]);return function(i,s){let l=0,c=0,u=0,a=(i+s)*Pw,d=es(i+a),p=es(s+a),f=(d+p)*Ji,m=d-f,h=p-f,y=i-m,g=s-h,v,w;y>g?(v=1,w=0):(v=0,w=1);let S=y-v+Ji,b=g-w+Ji,T=y-1+2*Ji,_=g-1+2*Ji,x=d&255,C=p&255,P=.5-y*y-g*g;if(P>=0){let O=x+r[C],V=e[O],z=t[O];P*=P,l=P*P*(V*y+z*g)}let I=.5-S*S-b*b;if(I>=0){let O=x+v+r[C+w],V=e[O],z=t[O];I*=I,c=I*I*(V*S+z*b)}let A=.5-T*T-_*_;if(A>=0){let O=x+1+r[C+1],V=e[O],z=t[O];A*=A,u=A*A*(V*T+z*_)}return 70*(l+c+u)}}function wm(n=Math.random){let r=_m(n),e=new Float64Array(r).map(i=>Gc[i%12*3]),t=new Float64Array(r).map(i=>Gc[i%12*3+1]),o=new Float64Array(r).map(i=>Gc[i%12*3+2]);return function(s,l,c){let u,a,d,p,f=(s+l+c)*Ow,m=es(s+f),h=es(l+f),y=es(c+f),g=(m+h+y)*Nr,v=m-g,w=h-g,S=y-g,b=s-v,T=l-w,_=c-S,x,C,P,I,A,O;b>=T?T>=_?(x=1,C=0,P=0,I=1,A=1,O=0):b>=_?(x=1,C=0,P=0,I=1,A=0,O=1):(x=0,C=0,P=1,I=1,A=0,O=1):T<_?(x=0,C=0,P=1,I=0,A=1,O=1):b<_?(x=0,C=1,P=0,I=0,A=1,O=1):(x=0,C=1,P=0,I=1,A=1,O=0);let V=b-x+Nr,z=T-C+Nr,$=_-P+Nr,te=b-I+2*Nr,K=T-A+2*Nr,q=_-O+2*Nr,k=b-1+3*Nr,G=T-1+3*Nr,D=_-1+3*Nr,B=m&255,L=h&255,F=y&255,W=.6-b*b-T*T-_*_;if(W<0)u=0;else{let M=B+r[L+r[F]];W*=W,u=W*W*(e[M]*b+t[M]*T+o[M]*_)}let H=.6-V*V-z*z-$*$;if(H<0)a=0;else{let M=B+x+r[L+C+r[F+P]];H*=H,a=H*H*(e[M]*V+t[M]*z+o[M]*$)}let j=.6-te*te-K*K-q*q;if(j<0)d=0;else{let M=B+I+r[L+A+r[F+O]];j*=j,d=j*j*(e[M]*te+t[M]*K+o[M]*q)}let U=.6-k*k-G*G-D*D;if(U<0)p=0;else{let M=B+1+r[L+1+r[F+1]];U*=U,p=U*U*(e[M]*k+t[M]*G+o[M]*D)}return 32*(u+a+d+p)}}function _m(n){let e=new Uint8Array(512);for(let t=0;t<512/2;t++)e[t]=t;for(let t=0;t<512/2-1;t++){let o=t+~~(n()*(256-t)),i=e[t];e[t]=e[o],e[o]=i}for(let t=256;t<512;t++)e[t]=e[t-256];return e}var Tm=require("three"),dr=new Tm.Triangle,nl=class{constructor(r){this.weightAttribute=null;let e=r.geometry;if(!e.isBufferGeometry||e.attributes.position.itemSize!==3)throw new Error("THREE.MeshSurfaceSampler: Requires BufferGeometry triangle mesh.");e.index&&(e=e.toNonIndexed()),this.geometry=e,this.randomFunction=Math.random,this.positionAttribute=this.geometry.getAttribute("position"),this.distribution=null}build(){let r=this.positionAttribute,e=new Float32Array(r.count/3);for(let o=0;o<r.count;o+=3){let i=1;dr.a.fromBufferAttribute(r,o),dr.b.fromBufferAttribute(r,o+1),dr.c.fromBufferAttribute(r,o+2),i*=dr.getArea(),e[o/3]=i}this.distribution=new Float32Array(r.count/3);let t=0;for(let o=0;o<e.length;o++)t+=e[o],this.distribution[o]=t;return this}setRandomGenerator(r){return this.randomFunction=r,this}sample(r,e){if(this.distribution){let t=this.distribution[this.distribution.length-1],o=this.binarySearch(this.randomFunction()*t);return this.sampleFace(o,r,e)}}binarySearch(r){if(!this.distribution)return 0;let e=this.distribution,t=0,o=e.length-1,i=-1;for(;t<=o;){let s=Math.ceil((t+o)/2);if(s===0||e[s-1]<=r&&e[s]>r){i=s;break}else r<e[s]?o=s-1:t=s+1}return i}sampleFace(r,e,t){let o=this.randomFunction(),i=this.randomFunction();return o+i>1&&(o=1-o,i=1-i),dr.a.fromBufferAttribute(this.positionAttribute,r*3),dr.b.fromBufferAttribute(this.positionAttribute,r*3+1),dr.c.fromBufferAttribute(this.positionAttribute,r*3+2),e.set(0,0,0).addScaledVector(dr.a,o).addScaledVector(dr.b,i).addScaledVector(dr.c,1-(o+i)),dr.getNormal(t),this}};var Im=require("three");var Jt=require("three"),Am=Ri(Om()),Aw=new Jt.Matrix4,Iw=new Jt.Matrix4,Cw=new Jt.Matrix4,ts;(r=>{function n(e){return e&&e.__isSPEObject}r.is=n})(ts||(ts={}));var qn=n=>class extends n{constructor(){super(...arguments);this.hiddenMatrix=new Jt.Matrix4;this.matrixWorldRigid=new Jt.Matrix4;this.shearScale=new Jt.Matrix4;this.shearScaleInv=new Jt.Matrix4}get __isSPEObject(){return!0}isDescendantOf(t){t instanceof Jt.Object3D&&(t=t.uuid);let o=this;for(;o.parent;){if(o.parent.uuid===t)return!0;o=o.parent}return!1}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);for(let o of this.children)o.updateMatrixWorld(t)}updateWorldMatrix(t,o){let i=this.parent;if(t&&i!==null&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),o)for(let s of this.children)s.updateWorldMatrix(!1,!0)}traverseObject(t,o=0){if(t(this,o)!==!0)for(let s of this.children)ts.is(s)&&s.traverseObject(t,o+1)}updateMatrixWorldSVD(){let t=this.matrixWorld.elements,o=[[t[0],t[4],t[8]],[t[1],t[5],t[9]],[t[2],t[6],t[10]]],{u:i,v:s,q:l}=(0,Am.SVD)(o),c=Aw.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=Iw.set(s[0][0],s[0][1],s[0][2],0,s[1][0],s[1][1],s[1][2],0,s[2][0],s[2][1],s[2][2],0,0,0,0,1),a=Cw.copy(u).transpose();this.shearScale.makeScale(l[0],l[1],l[2]).multiply(a).premultiply(u),this.shearScaleInv.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(c,a).copyPosition(this.matrixWorld),l.every(d=>Math.abs(l[0]-d)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(t,o){this.updateWorldMatrix(!0,!1);let i=new Jt.Matrix4().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),i.multiply(t.parent.matrixWorld)),"hiddenMatrix"in t&&t.hiddenMatrix instanceof Jt.Matrix4?t.hiddenMatrix.premultiply(i):t.applyMatrix4(i),t.updateWorldMatrix(!1,!1),this.add(t),o!==void 0&&(this.children.pop(),this.children.splice(o,0,t)),this}};var Rc=class extends qn(Im.Object3D){},Nw=n=>n.type==="Mesh",Qr=class extends Rc{constructor(e){super();this.object=e;this.matrixAutoUpdate=!1}expand(){let e=0,t=this.object.entityChildren(e);for(;t;){let o=this.children[e];o?.object!==t&&(o&&this.remove(o),o=new Qr(t),this.add(o),o.matrixAutoUpdate=!1,o.matrix=t.matrix,o.hiddenMatrix=t.hiddenMatrix),o.expand(),e+=1,t=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e])}get visible(){return this.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 Nw(this.object)}get isLight(){return this.object.isLight}get layers(){return this.object.layers}set layers(e){}get isCamera(){return!1}get geometry(){if(this.object.geometry)return this.object.geometry}get material(){if(this.object.material)return this.object.material}};var pi=require("three");var wl=require("three");var Jr=require("three");var Qe=require("three"),zo=new Qe.Vector3,Uo=new Qe.Vector3,$n=new Qe.Matrix4,Nm=[new Qe.Vector3(-1,1,1),new Qe.Vector3(-1,-1,1),new Qe.Vector3(1,-1,1),new Qe.Vector3(1,1,1),new Qe.Vector3(-1,1,-1),new Qe.Vector3(-1,-1,-1),new Qe.Vector3(1,-1,-1),new Qe.Vector3(1,1,-1)],Ew=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],Mw=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],Cm=(n,r,e)=>{n.updateEntityBoxSize(zo,Uo),$n.copy(r).multiply(n.matrixWorld),Uo.x===0&&Uo.y===0&&Uo.z===0?e.push(new Qe.Vector3(zo.x,zo.y,zo.z).applyMatrix4($n)):Nm.forEach(t=>{e.push(t.clone().multiply(Uo).add(zo).applyMatrix4($n))})},rs=class extends Qe.Box3{constructor(){super(...arguments);this.matrix=new Qe.Matrix4;this.vertices=[];this.faces=[];this.edges=[];this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(t=>t.clone()),this.faces=e.faces.map(t=>t.clone()),this.edges=e.edges.map(t=>t.clone()),this.centerEdges=e.centerEdges.map(t=>t.clone()),this}setFromObjectSize(e,t=!1){e.updateWorldMatrix(!1,t),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let o=new Qe.Matrix4().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,o,t)}expandByObjectSize(e,t,o=!1){let i=[];return o===!0?e.traverseEntity(s=>{s.visible&&Cm(s,t,i)}):Cm(e,t,i),this.setFromPoints(i)}getCenter(e){return e=super.getCenter(e),e.applyMatrix4(this.matrix),e}getPositionToCenter(e){return e=super.getCenter(e),e.applyMatrix4($n.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(Uo).multiplyScalar(.5),this.getCenter(zo),$n.copy(this.matrix).setPosition(zo),this.vertices=Nm.map(e=>e.clone().multiply(Uo).applyMatrix4($n))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=Ew.map(([e,t])=>new Qe.Line3(this.vertices[e],this.vertices[t])),this.centerEdges=this.edges.map(e=>e.getCenter(new Qe.Vector3))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=Mw.map(([e,t])=>this.vertices[e].clone().add(this.vertices[t]).multiplyScalar(.5))}};var ur={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}};var ut=require("three"),jc=class extends ut.CurvePath{constructor(){super()}getPoints(r=12){let e=[],t,o=this.getCurveLengths(),s=o[o.length-1]/o.length;for(let l=0,c=this.curves;l<c.length;l++){let u=c[l],a=l===0?o[l]:o[l]-o[l-1],d=Math.ceil(r*a/s),p=u.getPoints(d);for(let f=0;f<p.length;f++){let m=p[f];t&&t.equals(m)||(e.push(m),t=m)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}};var Fc=.001;function zc(n,r,e){return r.clone().sub(n).cross(r.clone().sub(e)).length()<=Fc}function Vc(n,r){let e=new ut.Vector3(...n.position),t=new ut.Vector3(...n.controlNext.position),o=new ut.Vector3(...r.controlPrevious.position),i=new ut.Vector3(...r.position);return zc(e,t,i)&&zc(e,o,i)}function sl(n){let r=n.points.map(a=>new ut.Vector3(...a.data.position)),e=[n.points[0]],t=new ut.Vector3(...e[0].data.position);for(let a=0;a<n.points.length-1;a++)zc(t,r[a],r[a+1])||(e.push(n.points[a]),t=r[a]);e.push(n.points[n.points.length-1]);let o=n.isClosed,i=e.length-(o?0:1),s=e.length,l=[];for(let a=0;a<s;a++){let d=e[a].data,p=new ut.Vector3(...d.position),f=new ut.Vector3(...d.controlPrevious.position),m=new ut.Vector3(...d.controlNext.position),h={position:p,baseRoundness:d.roundness,controlPrevious:f,controlNext:m};if(d.roundness===0||!n.isClosed&&(a===0||a===s-1)){l[a]={...h,removedLength:0};continue}let y=o&&a==0?s-1:a-1,g=o&&a==s-1?0:a+1,v=e[y].data,w=e[g].data,S=new ut.Vector3(...v.position),b=new ut.Vector3(...w.position),T=S.clone().sub(p).normalize(),_=b.clone().sub(p).normalize();Object.assign(h,{prevDir:T,nextDir:_});let x=Vc(v,d),C=Vc(d,w);if(!x||!C)l[a]={...h,removedLength:0};else{let P=T.clone().add(_).normalize(),I=P.clone().cross(T).length()/T.dot(P);l[a]={...h,tan:I,removedLength:d.roundness/I}}}for(let a=0;a<i;a++){let d=a,p=o&&a===s-1?0:a+1,f=l[d],m=l[p];if(f.removedLength!==0||m.removedLength!==0){let h=f.position.distanceTo(m.position);f.removedLength=Math.min(f.removedLength,h/2),m.removedLength=Math.min(m.removedLength,h/2)}}let c=[];for(let a=0;a<i;a++){let d=a,p=o&&a===s-1?0:a+1,f=l[d],m=l[p],h=null;if(!Vc(e[d].data,e[p].data))f.position.distanceTo(m.position)>Fc&&(h=new ut.CubicBezierCurve3(f.position,f.controlNext,m.controlPrevious,m.position));else{let y=f.position.clone(),g=m.position.clone();(f.removedLength!==0||m.removedLength!==0)&&(f.nextDir&&y.add(f.nextDir.clone().setLength(f.removedLength)),m.prevDir&&g.add(m.prevDir.clone().setLength(m.removedLength))),y.distanceTo(g)>Fc&&(h=new ut.CubicBezierCurve3(y,y.clone().lerp(g,.3),g.clone().lerp(y,.3),g))}c[2*a+1]=h}for(let a=0;a<s;a++){let d=l[a];if(d.removedLength===0){c[2*a]=null;continue}let p=d.position,f=d.prevDir.clone().multiplyScalar(d.removedLength).add(p),m=d.nextDir.clone().multiplyScalar(d.removedLength).add(p),h=d.tan*d.removedLength,y=d.prevDir.clone().add(d.nextDir).normalize(),g=f.clone().lerp(m,.5),v=f.distanceTo(m)/2,w=y.clone().multiplyScalar(Math.sqrt(Math.pow(h,2)-Math.pow(v,2))).add(g),S=y.clone().multiplyScalar(-h).add(w),b=p.distanceTo(S)/p.distanceTo(g),T=d.prevDir.clone().multiplyScalar(b*p.distanceTo(f)).add(p),_=T.clone().lerp(S,2),x=f.clone().lerp(T,4/3),C=m.clone().lerp(_,4/3);c[2*a]=new ut.CubicBezierCurve3(f,x,C,m)}let u=new jc;return c.forEach(a=>{a&&u.add(a)}),u}var He;(r=>{function n(e){return e&&e.__isEntity}r.is=n})(He||(He={}));var pr=n=>He.is(n),al=n=>class extends qn(n){constructor(){super(...arguments);this.raycastLock=!1;this.scaleLock=!1;this.disposed=!1;this.stateSelection=null;this.instances=[];this.prevState=null;this.currentState=null;this.reversibleToState=null;this.currentTransitionEvent=null;this.previousAction=null;this._singleBBox=new rs;this._recursiveBBox=new rs;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(t){let o=this.children[t];if(He.is(o))return o}get isConcreteEntity(){return typeof this.identity=="string"}get isVirtualEntity(){return typeof this.identity!="string"}get isInstanceRoot(){return this.isConcreteEntity&&this.data.type==="Instance"}nearestInstanceSelfOrParent(){let t=this;for(;t.data.type!=="Instance";){let o=t.parent;if(He.is(o))t=o;else return}return t}forInstancesRec(t){this.instances.forEach(o=>{o.disposed||t(o),o.forInstancesRec(t)})}super_Entity(t,o){typeof t=="string"&&(this.uuid=t),this.identity=t,this.data=o,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(t,o,i=!1){if(!(this.data.states.length===0&&!i)){for(let s of this.data.states)Ro.toOps(this.data,s.data).forEach(c=>{let u=na.replaceProps(c,this.data);this.dataPatched=this.data,this.updateByPatchedOp(u,this.data,o)});if(t!==null){let s=this.data.states.data(t);s&&(this.dataPatched=Ro.patch(this.data,s),Ro.toOps(this.data,s).forEach(c=>{this.updateByPatchedOp(c,this.dataPatched,o)}))}i&&this.updateTransformState(this.dataPatched),this.stateSelection=t,this.updatePathSnapping(o.scene)}}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges(),this._singleBBox.computeFaces()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges(),this._recursiveBBox.computeFaces()),this._recursiveBBox}updateEntityBoxSize(t,o){t.setScalar(0),o.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(t=>{pr(t)&&t.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(t=>{t.resetBBoxNeedsUpdateSelf()})}find(t){let o;return this.traverseEntity(i=>{i.uuid===t&&(o=i)}),o}traverseSortNextHelper(){let t=this.parent;if(t){let o=t.children,i=o.indexOf(this)+1;if(He.is(o[i]))return o[i];if(He.is(t))return t.traverseSortNextHelper()}}sortNext(){let t=this.children;return this.children.length>0&&He.is(this.children[0])?t[0]:this.traverseSortNextHelper()}goUp(t){let o=this;for(;t>0&&o!==null;)o=o.parent,t-=1;return o}hasAnccestorOrSelf(t){return this===t||this.hasAnccestor(t)}hasAnccestor(t){let o=this.parent;for(;o;){if(t===o)return!0;o=o.parent}return!1}countToAccestor(t){let o=0,i=this;for(;i!==t;){if(i===null)return-1;i=i.parent,o+=1}return o}forEachEntity(t){for(let o of this.children)pr(o)&&t(o)}traverseEntityAncestors(t){this.traverseAncestors(o=>{He.is(o)&&t(o)})}traverseEntity(t,o=0){if(t(this,o)!==!0)for(let s of this.children)pr(s)&&s.traverseEntity(t,o+1)}traverseVisibleEntity(t){t(this);for(let o of this.children)pr(o)&&o.visible&&o.traverseVisibleEntity(t)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}copy(t,o=!0){return super.copy(t,!1),this.raycastLock=t.raycastLock,this.scaleLock=t.scaleLock,this.hiddenMatrix.copy(t.hiddenMatrix),this}hasEntityChild(){return this.children.some(t=>pr(t))}isAncestorOf(t){if(this.uuid===t)return!1;let o=!1;return this.traverseEntity(i=>{i.uuid===t&&(o=!0)}),o}toObjectTransformState(t=[]){this.updateWorldMatrix(!0,!1);let o={position:this.position.toArray(),rotation:[this.rotation.x,this.rotation.y,this.rotation.z],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return Hn(o,t)}updateTransformState(t){let o=!1;return t.position&&(this.position.fromArray(t.position),o=!0),t.rotation&&(this.rotation.fromArray(t.rotation),o=!0),t.scale&&(o=!0,this.scale.fromArray(t.scale)),t.hiddenMatrix!==void 0&&(o=!0,this.hiddenMatrix.fromArray(t.hiddenMatrix??uo.identity)),o&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(i=>{i.invalidateClonerTransform(this)})),t.position&&t.rotation&&t.scale&&t.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),o}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let t of this.children)He.is(t)&&t.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(t=>{He.is(t)&&t.disposeRecursively()})}toState(t=[]){let o={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(t)};return Hn(o,t)}updateByOp(t,o,i,s){let l=this.data;this.data=o;let c=t,u=ar(t.path,["states","*"]);if(u!==null){if(t.type===0){let[a]=u;if(this?.stateSelection===a){let d={...t.props};if(Object.values(t.props).some(p=>p===void 0)){let p=this.data;if(p!==void 0){let f=Tt.zoom(p,t.path.slice(2));if(f)for(let m in t.props)t.props[m]===void 0&&m in f&&(d[m]=f[m])}}c={...t,props:d,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:p,...f}=a;a=f}if(t.props.material!==void 0&&"material"in a){let{material:p,...f}=a;a=f}let d=Tt.removeOverridden(t.path,t.props,a);c={...t,props:d}}}if(this.updateByPatchedOpBase(c,Ro.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),i),ar(t.path,["overrides"])){let a=[],d=[...t.path];for(a.push(d[1]),d.splice(0,2);d.length>0&&d[0]==="descendants";)a.push(d[1]),d.splice(0,2);if(a[a.length-1]===void 0){if(t.type===0)for(let p of Object.keys(t.props)){a[a.length-1]=p;let f=i.scene.findInstance([this.uuid,...a]);f&&(f.overrideData=t.props[p],f.updateState(Wr.apply(f.component.data,f.overrideData),i))}}else{let p=i.scene.findInstance([this.uuid,...a]);if(p){let f=Tt.zoom(p.component.data,d);if(t={...t,path:d},t.type===0){let m=t.props;if(f)for(let[h,y]of Object.entries(t.props))y===void 0&&(m===t.props&&(m={...t.props}),m[h]=f[h]);t={...t,props:m}}p.overrideData=Sn.resolve(o.overrides,a),p.updateByOp(t,ht.applySimple(p.data,t),i,!1)}}}else if(this.instances.length>0){let a;if(t.path.length===0&&t.type===0){let d;for(let p of fo.rootOverrideProps)p in t.props&&(d===void 0&&(d={}),d[p]=t.props[p]);d&&(a={...t,props:d})}else for(let d of fo.rootOverrideProps)if(ar(t.path,[d])){a=t;break}a!==void 0&&this.instances.forEach(d=>{if(d.isInstanceRoot){let p=Wr.filterOp(d.overrideData,a);p&&d.updateByOp(p,ht.applySimple(d.data,p),i,!0)}}),this.instances.forEach(d=>{if(!d.isInstanceRoot){let p=Wr.filterOp(d.overrideData,t);if(p){let f;l===d.data&&t===p?f=o:f=ht.applySimple(d.data,p),d.updateByOp(p,f,i,!0)}}})}}updateByPatchedOpBase(t,o,i){if(this.dataPatched=o,t.path.length===0&&t.type===0)t.props.type!==void 0&&!cr.is(t.props.type)&&ur.changeEntityProptotype(this,o,i);else if(t.path.length===1&&t.path[0]==="geometry"&&t.type===0&&"type"in t.props){ur.changeEntityProptotype(this,o,i);for(let s of this.children)He.is(s)&&s.updateVisible()}this.updateByPatchedOp(t,o,i)}updateByPatchedOp(t,o,i){if(t.path.length===0&&t.type===0&&this.updateState(t.props,i),ar(t.path,["pathSnapping"])!==null&&this.updatePathSnapping(i.scene),ar(t.path,["cloner"])!==null){let s=ht.drop(t,1);s.path.length===0&&s.type===0&&s.props.disabled===!0?this.setFromClonerState(null,i):this.cloner?this.cloner.updateState(o.cloner,i.scene):(this.setFromClonerState(o.cloner,i),this.expandCloner(i.scene)),this.updateVisible()}}updatePathSnapping(t,o=this.dataPatched.pathSnapping){if(o?.pathId){let i=t.find(o.pathId);this._pathSnappingObject=i,i?this.updatePathSnappingSlide(o):t.addPendingCommand(()=>{this.updatePathSnapping(t)})}}updatePathSnappingSlide(t=this.dataPatched.pathSnapping){let o=this._pathSnappingObject;if(!o)return;o.snappedEntities.add(this);let i=o.data,s=sl(i.geometry.path),l=s.getPointAt(t.slide),c=this.parent?this.parent?.matrixWorld:new Jr.Matrix4,u=new Jr.Matrix4().multiplyMatrices(c.clone().invert(),o.matrixWorld);l.applyMatrix4(u);let a={position:l.toArray(),rotation:i.rotation};if(t.orientation==="tangential"){let d=s.getTangentAt(t.slide).add(l),p=new Jr.Matrix4().lookAt(l,d,new Jr.Vector3(0,1,0)),f=new Jr.Matrix4().extractRotation(o.matrixWorld),m=new Jr.Euler().setFromRotationMatrix(f.clone().multiply(p));a={...a,rotation:[m.x,m.y,m.z]}}this.updateTransformState(a)}updateVisible(){this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0)}updateState_Entity(t,o){t.name!==void 0&&(this.name=t.name),t.raycastLock!==void 0&&(this.raycastLock=t.raycastLock),t.visible!==void 0&&(this.updateVisible(),this.resetBBoxNeedsUpdate()),"cloner"in t&&t.cloner!==void 0&&(this.setFromClonerState(t.cloner,o),this.updateVisible()),this.updateTransformState(t),o?.scene&&this.updatePathSnapping(o.scene,t.pathSnapping)}get attachedSurfaceCloners(){return this.children.filter(t=>t instanceof ur.Cloner&&t.parameters.type==="toObject")}setFromClonerState(t,o){this.disposed||(t===null||t.disabled?(this.cloner&&this.cloner.removeFromParent(),this.cloner=void 0):(this.cloner===void 0&&(this.cloner=new ur.Cloner(this,t),o.scene.addPendingExpandCloner(this)),this.cloner.updateState(t,o.scene)))}expandCloner(t){!this.disposed&&this.cloner&&this.cloner.expandClones(t)}invalidateClonerTransform(t){this.cloner&&this.cloner.invalidateTransform(t)}};var Lm=require("three");var Fe=require("three"),Mm=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:0,cornerSegments:8,hollow:0},n.parameters),t=e.width/2,o=e.radiusTop??t,i=e.radiusBottom??t;return o===i?(o=t,i=t):o>i?(o=t,i=i*t/o):(o=o*t/i,i=t),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),radiusTop:o,radiusBottom:i})}}static build(n){let{width:r,depth:e,height:t,radialSegments:o,heightSegments:i,openEnded:s,thetaStart:l,thetaLength:c,radiusTop:u,radiusBottom:a,cornerRadius:d,cornerSegments:p,hollow:f}=n.parameters,m;return d||f?m=new os(u,a,t,o,i,s,l,c*Math.PI/180,d,d,p,f):m=new Fe.CylinderGeometry(u,a,t,o,i,s,l,c*Math.PI/180),m.scale(1,1,e/r),Object.assign(m,{userData:{...n,type:"CylinderGeometry"}})}};function bo(n,r,e){e.x=n.x*r.x,e.y=n.y,e.z=n.x*r.y}function Em(n){return new Fe.Vector2(n.y,-n.x)}var os=class extends Fe.BufferGeometry{constructor(r,e,t,o,i,s,l,c,u,a,d,p,f=!1){super(),this.type="RoundedCylinderBufferGeometry",r=r!==void 0?r:1,e=e!==void 0?e:1,t=t||1,o=Math.floor(o)||8,i=Math.floor(i)||1,s=s!==void 0?s:!1,l=l!==void 0?l:0,c=c!==void 0?c:Math.PI*2,s&&(u=0,a=0);let m=[],h=[],y=[],g=[],v=0,w=t/2,S=new Fe.Vector3,b=new Fe.Vector3;f&&r==0&&(r=u),f&&e==0&&(e=a);let T=new Fe.Vector2(r,w),_=new Fe.Vector2(e,-w),x=null,C=null,P=null,I=null,A=T.clone().sub(_),O=0,V=0,z=0;p>0&&(O=Math.min(r,e)*(1-p),V=r-O,z=e-O);let $=T.clone();$.x-=O;let te=Math.PI-A.angle(),K=A.angle(),q=Math.tan(K/2),k=Math.tan(te/2),G=q+k,D=p?G:k,B=p?G:q;if(u=Math.min(u,(r-V)/D,A.length()/G),a=Math.min(a,(e-z)/B,A.length()/G),u>0){let U=u/q;x=T.clone().sub(new Fe.Vector2(U,u)),p&&(P=x.clone(),P.x-=O-G*u),T.sub(A.clone().setLength(U))}if(a>0){let U=a/k;C=_.clone().sub(new Fe.Vector2(U,-a)),_.add(A.clone().setLength(U)),p&&(I=C.clone(),I.x-=O-G*a,$.sub(A.clone().setLength(U)))}A=T.clone().sub(_);let L=A.length()<.5,F=[];for(let U=0;U<=o;U++){let M=[],oe=U/o,Y=oe*c+l,re=new Fe.Vector2(Math.sin(Y),Math.cos(Y));I&&C?(W(M,oe,re,te,a,I,-1,!0),W(M,oe,re,K,a,C,-1,!1)):C?(H(M,re,C.x,0,-1),W(M,oe,re,K,a,C,-1,!1)):s||H(M,re,e,z,-1);let X=Em(A).normalize();if(bo(X,re,S),!L)for(let ee=0;ee<=i;ee++){let Z=ee/i,se=A.clone().multiplyScalar(Z).add(_);bo(se,re,b),h.push(b.x,b.y,b.z),y.push(S.x,S.y,S.z),g.push(oe,.5+b.y/t),M.push(v++)}if(P&&x?(W(M,oe,re,te,u,x,1,!1),W(M,oe,re,K,u,P,1,!0)):x?(W(M,oe,re,te,u,x,1,!1),H(M,re,x.x,0,1)):s||H(M,re,r,V,1),p&&!L){let ee=Em(A).multiplyScalar(-1).normalize();bo(ee,re,S);for(let Z=0;Z<=i;Z++){let se=Z/i,de=A.clone().multiplyScalar(-se).add($);bo(de,re,b),h.push(b.x,b.y,b.z),y.push(S.x,S.y,S.z),g.push(oe,.5+b.y/t),M.push(v++)}}p&&!s&&M.push(M[0]),F.push(M)}for(let U=0;U<F.length-1;U++)for(let M=0;M<F[0].length-1;M++){if(s&&p&&M==i)continue;let oe=F[U][M],Y=F[U+1][M],re=F[U+1][M+1],X=F[U][M+1],ee=h[re*3+0],Z=h[re*3+2];m.push(oe,Y,X),(ee!=0||Z!=0)&&m.push(Y,re,X)}c<Math.PI*2&&(j(-1,F[0],l),j(1,F[F.length-1],l+c)),this.setIndex(m),this.setAttribute("position",new Fe.Float32BufferAttribute(h,3)),this.setAttribute("normal",new Fe.Float32BufferAttribute(y,3)),this.setAttribute("uv",new Fe.Float32BufferAttribute(g,2));function W(U,M,oe,Y,re,X,ee,Z){for(let se=0;se<d+1;se++){let de=se/d,ae=ee<0?de:1-de;Z&&(ae-=1),ae*=Y;let fe=new Fe.Vector2(Math.sin(ae),Math.cos(ae)*ee),Ue=fe.clone().multiplyScalar(re).add(X);bo(Ue,oe,b),h.push(b.x,b.y,b.z),bo(fe,oe,S),y.push(S.x,S.y,S.z),g.push(M,.5+b.y/t),U.push(v++)}}function H(U,M,oe,Y,re){let X=new Fe.Vector3,ee=new Fe.Vector2,Z=[oe,Y];re<0&&Z.reverse();for(let se of Z)ee.set(se,w*re),bo(ee,M,X),h.push(X.x,X.y,X.z),y.push(0,re,0),g.push(.5,.5),U.push(v++)}function j(U,M,oe){let Y=new Fe.Vector2(Math.sin(oe),Math.cos(oe)),re=new Fe.Vector2(-Math.cos(oe),Math.sin(oe)),X=new Fe.Vector3,ee=U<0?(de,ae,fe)=>m.push(de,ae,fe):(de,ae,fe)=>m.push(de,fe,ae),Z=new Fe.Vector2((r+e+V+z)/4,0);bo(Z,Y,X),h.push(X.x,X.y,X.z),y.push(re.x,0,re.y),g.push(.5,.5);let se=v++;for(let de of M){let ae=h.slice(de*3,de*3+3);h.push(...ae),y.push(re.x,0,re.y);let fe=g.slice(de*2,de*2+2);g.push(...fe),v++}for(let de=se+1;de<v-1;de++)ee(se,de,de+1);ee(se,v-1,se+1)}}};var Bm=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:0,cornerRadiusBottom:0,cornerSegments:8},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:r,depth:e,height:t,radialSegments:o,heightSegments:i,openEnded:s,thetaStart:l,thetaLength:c,cornerRadiusTop:u,cornerRadiusBottom:a,cornerSegments:d}=n.parameters,p;return u>0||a>0||c<360?p=new os(0,r/2,t,o,i,s,l,c*Math.PI/180,u,a,d,0,!0):p=new Lm.ConeGeometry(r/2,t,o,i,s),p.scale(1,1,e/r),Object.assign(p,{userData:{...n,type:"ConeGeometry"}})}};var Rt=require("three"),Dm=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:0,cornerSegments:8},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:r,height:e,depth:t,widthSegments:o,heightSegments:i,depthSegments:s,cornerRadius:l,cornerSegments:c}=n.parameters,u;return l==0?u=new Rt.BoxGeometry(r,e,t,o,i,s):u=new kc(r,e,t,o,i,s,l,c),Object.assign(u,{userData:{...n,type:"CubeGeometry"}})}},Uc=Math.PI/2,kc=class extends Rt.BufferGeometry{constructor(r=1,e=1,t=1,o=1,i=1,s=1,l=0,c=4){super(),this.type="BoxGeometry";let u=this;o=Math.floor(o),i=Math.floor(i),s=Math.floor(s),c=Math.floor(c),l=Math.min(l,r/2,e/2,t/2);let a=[],d=[],p=[],f=[],m=0,h=0;y("z","y","x",-1,-1,t,e,r,s,i,0),y("z","y","x",1,-1,t,e,-r,s,i,1),y("x","z","y",1,1,r,t,e,o,s,2),y("x","z","y",1,-1,r,t,-e,o,s,3),y("x","y","z",1,-1,r,e,t,o,i,4),y("x","y","z",-1,-1,r,e,-t,o,i,5),l>0&&(g("z","y","x",-1,-1,1,t,e,r,s,0),g("z","y","x",1,-1,-1,t,e,r,s,1),g("z","y","x",-1,1,-1,t,e,r,s,1),g("z","y","x",1,1,1,t,e,r,s,0),g("x","y","z",-1,-1,-1,r,e,t,o,0),g("x","y","z",1,-1,1,r,e,t,o,1),g("x","y","z",-1,1,1,r,e,t,o,0),g("x","y","z",1,1,-1,r,e,t,o,1),g("y","x","z",-1,-1,1,e,r,t,i,0),g("y","x","z",1,-1,-1,e,r,t,i,1),g("y","x","z",1,1,1,e,r,t,i,1),g("y","x","z",-1,1,-1,e,r,t,i,0),v(1,1,1),v(-1,1,1),v(1,-1,1),v(-1,-1,1),v(1,1,-1),v(-1,1,-1),v(1,-1,-1),v(-1,-1,-1)),this.setIndex(a),this.setAttribute("position",new Rt.Float32BufferAttribute(d,3)),this.setAttribute("normal",new Rt.Float32BufferAttribute(p,3)),this.setAttribute("uv",new Rt.Float32BufferAttribute(f,2));function y(w,S,b,T,_,x,C,P,I,A,O){let V=(x-2*l)/I,z=(C-2*l)/A,$=x/2-l,te=C/2-l,K=P/2,q=I+1,k=A+1,G=0,D=0,B=new Rt.Vector3;for(let L=0;L<k;L++){let F=L*z-te;for(let W=0;W<q;W++){let H=W*V-$;B[w]=H*T,B[S]=F*_,B[b]=K,d.push(B.x,B.y,B.z),B[w]=0,B[S]=0,B[b]=P>0?1:-1,p.push(B.x,B.y,B.z),f.push(W/I),f.push(1-L/A),G+=1}}for(let L=0;L<A;L++)for(let F=0;F<I;F++){let W=m+F+q*L,H=m+F+q*(L+1),j=m+(F+1)+q*(L+1),U=m+(F+1)+q*L;a.push(W,H,U),a.push(H,j,U),D+=6}u.addGroup(h,D,O),h+=D,m+=G}function g(w,S,b,T,_,x,C,P,I,A,O){let V=(C-2*l)/A,z=C/2-l,$=P/2-l,te=I/2,K=A+1,q=0,k=0,G=new Rt.Vector3,D=new Rt.Vector3;for(let B=0;B<c+1;B++){let L=B/c*Uc,F=Math.sin(L)*l,W=(1-Math.cos(L))*l,H=Math.sin(L),j=Math.cos(L);G[S]=($+F)*_,G[b]=(te-W)*x,D[w]=0,D[S]=H*Math.sign(G[S]),D[b]=j*Math.sign(G[b]);for(let U=0;U<K;U++){let M=U*V-z;G[w]=M*T,d.push(G.x,G.y,G.z),p.push(D.x,D.y,D.z),f.push(U/A),f.push(0),q+=1}}for(let B=0;B<c;B++)for(let L=0;L<A;L++){let F=m+L+K*B,W=m+L+K*(B+1),H=m+(L+1)+K*(B+1),j=m+(L+1)+K*B;a.push(F,W,j),a.push(W,H,j),k+=6}u.addGroup(h,k,O),h+=k,m+=q}function v(w,S,b){let T=new Rt.Vector3,_=new Rt.Vector3(r/2,e/2,t/2);_.subScalar(l);let x=[],C=w*S*b>0?(I,A,O)=>a.push(I,A,O):(I,A,O)=>a.push(I,O,A);for(let I=0;I<=c;I++){let A=[],O=Uc*(1-I/c),V=Math.cos(O),z=Math.sin(O),$=0;for(let te=0;te<=I;te++){let K=Math.cos($),q=Math.sin($);T.x=V*K,T.y=z,T.z=V*q;let k=_.clone().addScaledVector(T,l);d.push(w*k.x,S*k.y,b*k.z),p.push(w*T.x,S*T.y,b*T.z),f.push(0,0),A.push(m++),$+=Uc/I}x.push(A)}let P=x.length-1;for(let I=0;I<P;I++){let A=x[I],O=x[I+1],V=A.length-1;C(A[0],O[1],O[0]);for(let z=1;z<=V;z++)C(A[z-1],A[z],O[z]),C(A[z],O[z+1],O[z])}}}};var Xe=require("three"),So=class extends Xe.BufferGeometry{constructor(r=[],e=[],t="",o=1,i=.2,s=4){super(),this.type="PolyhedronGeometryRound";let l=[],c=[],u=[];a(),d(),this.setAttribute("position",new Xe.Float32BufferAttribute(l,3)),this.setAttribute("normal",new Xe.Float32BufferAttribute(u,3)),this.setAttribute("uv",new Xe.Float32BufferAttribute(c,2));return;function a(){i=Math.min(1-1e-5,i),i==0&&(s=0);let f={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[t],m=new Xe.Vector3,h=m.clone(),y=new Xe.Triangle,g=i*o,v=o-g,w=s+1,S=new Xe.Vector3,b=(q,k)=>S.subVectors(q,k).normalize(),T=(q,k)=>Array(q).fill(void 0).map(k),_=T(r.length/3,(q,k)=>new Xe.Vector3().fromArray(r,k*3).setLength(o)),x=[],C=1e6;for(let q=0;q<_.length;q++){let k=_[q],G=[],D,B,L,F=1e10,W=-1;for(;(W=e.indexOf(q,W+1))!=-1;){let M=W-W%3;D=e[M+(W+1)%3],B=e[M+(W+2)%3],L=k.distanceToSquared(_[D]),F=Math.min(F,L),G.push([D,B,L])}F+=1e-6;let H=[],j=0,U=G.length;for(let M=0;M<U;M++){[D,B,L]=G[j];let oe=x[D]?.includes(q)==!0;L<=F&&H.push(D+ +oe*C),j=G.findIndex(Y=>Y[0]==B)}x.push(H)}let P=[];{let q=0,k=0,G,D,B=f==3;for(let L=0;L<=s;L++){G=L*(L+1)/2,D=(L+1)*(L+2)/2;for(let F=0;F<s-L;F++)[q,k]=[G+F+L+2,D+F+L+3],P.push(G,D,...B?[k,G]:[q,D],k,q),[G,D]=[q,k];P.push(G,D,G+s+2)}}let I=m.clone(),A=m.clone(),O=m.clone(),V=m.clone(),z=m.clone(),$=[],te=T(_.length,()=>T(f,()=>m.clone()));for(let q=0;q<_.length;q++){m.copy(_[q]).normalize(),I.copy(m).multiplyScalar(v);let k=x[q];for(let H=0;H<k.length;H++){let j=k[H],U=k[(H+1)%f];y.setFromPointsAndIndices(_,q,j%C,U%C),y.b.sub(y.a).setLength(1e10).add(y.a),y.c.sub(y.a).setLength(1e10).add(y.a),y.closestPointToPoint(I,te[q][H])}let G=[],D=[],B=[],L=new Xe.Vector3;s==0&&[...te[q]].reduce((H,j)=>H.add(j),L).multiplyScalar(1/f);for(let H=0;H<f;H++){let j=[],U=(H-1+f)%f,M=te[q][U],oe=te[q][H];m.copy(M).sub(I),h.copy(oe).sub(I);let Y=I.angleTo(m),re=m.angleTo(h),X=Math.cos(Y)*g;s==0?A.copy(L):A.copy(I).setLength(v+X),D.push(X);let ee=[A,M,oe];for(let Z=0;Z<2;Z++){let se=ee[Z],de=ee[Z+1];V.subVectors(se,I),z.subVectors(de,I),O.crossVectors(V,z).normalize();for(let ae=0;ae<w;ae++){let fe=[Y,re][Z]*ae/w;m.copy(V).applyAxisAngle(O,fe).add(I),G.push(m.clone()),Z&&(b(m,I),j.push([ae==0?se:m.clone(),S.clone()]))}Z&&(b(de,I),j.push([de,S.clone()]))}B.push(j)}$.push(B);let F=2*w,W=2;for(let H=0;H<f;H++){let j=F*H,U=F*((H+1)%f),M=[G[j]];for(let Y=1;Y<w;Y++){V=G[j+Y],z=G[U+Y],M.push(V);for(let re=1,X=Y-W+1;re<=X;re++)m.lerpVectors(V,z,re/(X+1)),m.sub(I).setLength(D[H]).add(I),M.push(m.clone());M.push(z)}for(let Y=0;Y<w;Y++)M.push(G[Y+w+j]);M.push(G[U+w]);let oe=P.map(Y=>M[Y]);l.push(...oe.map(Y=>[Y.x,Y.y,Y.z]).flat()),u.push(...oe.map(Y=>(b(Y,I),[S.x,S.y,S.z])).flat())}}let K=[];for(let q=0;q<x.length;q++)for(let k=0;k<f;k++){let G=x[q][k];if(G<C){let D=x[G].findIndex(F=>F%C==q),B=$[q][k],L=$[G][D];for(let F=0;F<w;F++){let W=B[F],H=L[w-F],j=B[F+1],U=L[w-(F+1)];[W,H,j,j,H,U].forEach(M=>{l.push(M[0].x,M[0].y,M[0].z),u.push(M[1].x,M[1].y,M[1].z)})}K.push(B[0][0],L[w][0],B[w][0],L[0][0])}}for(;K.length;){let q,k,G,D;[q,k]=K.splice(0,2);let B=[q];for(;q!=k;)B.push(k),G=K.indexOf(k),D=G%2,k=K.splice(G-D,2)[1-D];S.subVectors(B[0],B[1]).cross(m.subVectors(B[0],B[2])).normalize();let L=S.dot(B[0])<0;L&&S.negate();for(let F=1;F<=B.length-2;F++)[B[F+ +L],B[F+1-+L],B[0]].forEach(W=>{l.push(W.x,W.y,W.z),u.push(S.x,S.y,S.z)})}}function d(){let p=new Xe.Vector3;for(let _=0;_<l.length;_+=3){p.x=l[_+0],p.y=l[_+1],p.z=l[_+2];let x=b(p)/2/Math.PI+.5,C=T(p)/Math.PI+.5;c.push(x,1-C)}let f=new Xe.Vector3,m=new Xe.Vector3,h=new Xe.Vector3,y=new Xe.Vector3,g=new Xe.Vector2,v=new Xe.Vector2,w=new Xe.Vector2,S=(_,x,C,P)=>{P<0&&_.x===1&&(c[x]=_.x-1),C.x===0&&C.z===0&&(c[x]=P/2/Math.PI+.5)};for(let _=0,x=0;_<l.length;_+=9,x+=6){f.set(l[_+0],l[_+1],l[_+2]),m.set(l[_+3],l[_+4],l[_+5]),h.set(l[_+6],l[_+7],l[_+8]),g.set(c[x+0],c[x+1]),v.set(c[x+2],c[x+3]),w.set(c[x+4],c[x+5]),y.copy(f).add(m).add(h).divideScalar(3);let C=b(y);S(g,x+0,f,C),S(v,x+2,m,C),S(w,x+4,h,C)}for(let _=0;_<c.length;_+=6){let x=c[_+0],C=c[_+2],P=c[_+4],I=Math.max(x,C,P),A=Math.min(x,C,P);I>.9&&A<.1&&(x<.2&&(c[_+0]+=1),C<.2&&(c[_+2]+=1),P<.2&&(c[_+4]+=1))}function b(_){return Math.atan2(_.z,-_.x)}function T(_){return Math.atan2(-_.y,Math.sqrt(_.x*_.x+_.z*_.z))}}}static fromJSON(r){return new So(r.vertices,r.indices,r.radius,r.corner,r.cornerSides)}};var Gm=require("three"),Rm=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,detail:0,corner:0,cornerSides:4},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:r,height:e,depth:t,detail:o,corner:i,cornerSides:s}=n.parameters,l=o===0&&i!==0?new ns(r*.5,i,s):new Gm.DodecahedronGeometry(r*.5,o);return l.scale(1,e/r,t/r),Object.assign(l,{userData:{...n,type:"DodecahedronGeometry"}})}},ns=class extends So{constructor(r=1,e=.2,t=4){let o=(1+Math.sqrt(5))/2,i=1/o,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-i,-o,0,-i,o,0,i,-o,0,i,o,-i,-o,0,-i,o,0,i,-o,0,i,o,0,-o,0,-i,o,0,-i,-o,0,i,o,0,i],l=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],c="DodecahedronGeometry";super(s,l,c,r,e,t),this.type=c}static fromJSON(r){return new ns(r.radius,r.corner,r.cornerSides)}};var Pe=require("three");var ye=require("three"),is=1e-12,Yn=class{constructor(r){this.position=new ye.Vector2;this.startPosition=new ye.Vector2;this.uuid=ye.MathUtils.generateUUID();this.position=r.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(r){this.position.copy(this.startPosition).add(r)}copy(r){return this.position.copy(r.position),this.startPosition.copy(r.startPosition),this}clone(){return new Yn(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},Xn=class extends Yn{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new Xn(this.parent).copy(this)}},fr=class extends Yn{constructor(e,t){super(t);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new Xn(this),new Xn(this))}static create(e,t){let o=new fr(e,new ye.Vector2(...t.position));return o.controls[0].position.set(...t.controlPrevious.position),o.controls[1].position.set(...t.controlNext.position),o.roundness=t.roundness,o.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored,o}getOppositeControl(e){let t=this.controls.indexOf(e);return t===0?this.controls[1]:t===1?this.controls[0]:null}applyOffsetToControls(e,t=1){for(let o=0,i=this.controls.length;o<i;o++){let s=this.controls[o];this.position.distanceTo(s.position)<=t?s.position.copy(this.position):s.applyOffset(e)}}controlsMoved(){return!(this.position.equals(this.controls[0].position)&&this.position.equals(this.controls[1].position))}copy(e){return super.copy(e),this.controls[0].copy(e.controls[0]),this.controls[1].copy(e.controls[1]),this.roundness=e.roundness,this.uuid=e.uuid,this}clone(){return new fr(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}computeTangents(){let e=this.curveBefore?.getTangentAt(1),t=this.curveAfter?.getTangentAt(0);return[e,t]}computeNormals(e=new ye.Vector2,t=new ye.Vector2){let[o,i]=this.computeTangents();return o&&i&&(Vm(o,e),Vm(i,t)),[e,t]}computeTangent(e=new ye.Vector2){let[t,o]=this.computeTangents();return t&&o&&e.copy(t).add(o).normalize(),e}computeNormal(e=new ye.Vector2){let[t,o]=this.computeNormals();return e.copy(t).add(o).normalize(),e}};function Vm(n,r=new ye.Vector2){let e=n.length();return r.set(-n.y/e,n.x/e)}var Wc=n=>n,Kn=new ye.Vector2,ll=new ye.Vector2,Lw=new ye.Vector2,Bw=new ye.Vector2,Dw=new ye.Vector2,Gw=new ye.Vector2,Fm=new ye.Vector3,zm=new ye.Vector3;function Um(n){let r=new ye.Vector2;r.addVectors(n.v0,Kn.subVectors(n.v1,n.v0).multiplyScalar(2/3));let e=new ye.Vector2;return e.addVectors(n.v2,ll.subVectors(n.v1,n.v2).multiplyScalar(2/3)),new ye.CubicBezierCurve(n.v0,r,e,n.v2)}function ss(n,r,e=Number.EPSILON){return Math.abs(n-r)<e}function Rw(n,r,e=Number.EPSILON){return n.distanceTo(r)<e}function Vw(n,r,e=Number.EPSILON){return n.distanceTo(r)<e}function qc(n,r,e){let t=Math.sqrt(Math.pow(r.x-n.x,2)+Math.pow(r.y-n.y,2)),o=Math.sqrt(Math.pow(r.x-e.x,2)+Math.pow(r.y-e.y,2)),i=Math.sqrt(Math.pow(e.x-n.x,2)+Math.pow(e.y-n.y,2));return Math.acos((o*o+t*t-i*i)/(2*o*t))}function km(n,r,e){return jm(n,r)&&jm(r,e)&&Hc(n.position,r.position,e.position)}function Hc(n,r,e){return Kn.copy(r).sub(n).cross(ll.copy(e).sub(n))===0}function Hm(n,r,e,t,o){let i=Math.sqrt(Math.pow(r.x-n.x,2)+Math.pow(r.y-n.y,2)),s=(n.y+r.y)/2,l=(n.x+r.x)/2,c=Math.sqrt(Math.pow(e,2)-Math.pow(i/2,2))*(n.y-r.y)/i,u=Math.sqrt(Math.pow(e,2)-Math.pow(i/2,2))*(r.x-n.x)/i;return t.set(l+c,s+u),o.set(l-c,s-u),[t,o]}function Wm(n,r,e){let t=n.distanceTo(e),o=r.distanceTo(e);return t<o?r:n}function qm(n,r,e,t,o,i){let s=r.x-n.x,l=r.y-n.y,c=e.x-n.x,u=e.y-n.y,a=Math.sqrt((s+c)*(s+c)+(l+u)*(l+u)),d;return qc(r,n,e)>Math.PI&&(a*=-1),ss(u,l)?d=(l+u)*(t/a-.5)*8/3/(s-c):d=(s+c)*(t/a-.5)*8/3/(u-l),o.set(r.x-d*l,r.y+d*s),i.set(e.x+d*u,e.y-d*c),[o,i]}function $c(n,r){return n.position.equals(n.controls[1].position)&&r.position.equals(r.controls[0].position)}function jm(n,r){return Hc(n.position,n.controls[1].position,r.position)&&Hc(n.position,r.controls[0].position,r.position)}function $m(n,r,e,t,o=.5){let i=Kn.subVectors(r,n).multiplyScalar(o).add(n),s=ll.subVectors(e,r).multiplyScalar(o).add(r),l=Lw.subVectors(t,e).multiplyScalar(o).add(e),c=i,u=Bw.subVectors(s,i).multiplyScalar(o).add(i),a=Dw.subVectors(l,s).multiplyScalar(o).add(s),d=l,p=Gw.subVectors(a,u).multiplyScalar(o).add(u);return[n.x,n.y,c.x,c.y,u.x,u.y,p.x,p.y,a.x,a.y,d.x,d.y,t.x,t.y]}function Ym(n,r,e=12,t=!0){let o=zm.set(0,0,0),i,s=0,l=[];for(let c=0;c<r.length;c++){let u=Wc(r[c]),a=Kn,d=wo(u,e);l.push(d);for(let p=0;p<=d;p++)if(u instanceof ye.CubicBezierCurve||u instanceof ye.QuadraticBezierCurve||u instanceof ye.LineCurve){if(u.getPoint(p/d,a),o.set(a.x,a.y,0),i!==void 0&&Vw(i,o))continue;i===void 0&&(i=Fm),i.copy(o),n.setXYZ(s,o.x,o.y,o.z),s++}}return t&&s>1&&!(n.getX(s-1)===n.getX(0)&&n.getY(s-1)===n.getY(0)&&n.getZ(s-1)===n.getZ(0))&&(n.setXYZ(s,n.getX(0),n.getY(0),n.getZ(0)),s++),n}function Xm(n,r,e,t=12,o=!0){let i=zm.set(0,0,0),s=0,l=[];for(let c=0;c<r.length;c++){if(e[c]===!1)continue;let u,a=Wc(r[c]),d=Kn,p=wo(a,t);l.push(p);for(let f=0;f<=p;f++)if(a instanceof ye.CubicBezierCurve||a instanceof ye.QuadraticBezierCurve||a instanceof ye.LineCurve){if(a.getPoint(f/p,d),i.set(d.x,d.y,0),u?.equals(i))continue;u===void 0?u=Fm:(n.setXYZ(s,u.x,u.y,u.z),s++,n.setXYZ(s,i.x,i.y,i.z),s++),u.copy(i)}}return o&&s>1&&!(n.getX(s-1)===n.getX(0)&&n.getY(s-1)===n.getY(0)&&n.getZ(s-1)===n.getZ(0))&&(n.setXYZ(s,n.getX(0),n.getY(0),n.getZ(0)),s++),l}function Yc(n,r=12,e=!1){let t=[];for(let o=0,i=n.length;o<i;o++){let s=n[o],l=0;if(e&&s.roundedCurveCorner!==void 0){let c=wo(s.roundedCurveCorner,r)*.5;o>0&&(t[o-1]+=c),l+=c}s.curveAfter!==void 0&&(l+=wo(s.curveAfter,r)),t.push(l)}return n.length>0&&e&&n[0].roundedCurveCorner!==void 0&&(t[n.length-1]+=wo(n[0].roundedCurveCorner,r)*.5),t}function wo(n,r=12){return n&&n instanceof ye.EllipseCurve?r*2:n&&(n instanceof ye.LineCurve||n instanceof ye.LineCurve3)?1:n&&n instanceof ye.SplineCurve?r*n.points.length:r}function Km(n,r,e=12,t=!0){let o,i=0;for(let s=0;s<r.length;s++){let l=Wc(r[s]),c=wo(l,e),u=Kn;for(let a=0;a<=c;a++)if(l instanceof ye.CubicBezierCurve||l instanceof ye.QuadraticBezierCurve||l instanceof ye.LineCurve){if(l.getPoint(a/c,u),o!==void 0&&Rw(o,u,is))continue;o===void 0&&(o=ll),o.copy(u),n.push(u.x,u.y),i++}}return ss(n[0],n[n.length-2],is)&&ss(n[1],n[n.length-1],is)&&(n.pop(),n.pop()),t&&i>1&&!(ss(n[i-1],n[1],is)&&ss(n[i-2],n[0],is))&&(n.push(n[0],n[1]),i++),n}var Xc=new Pe.Vector2,jw=new Pe.Vector2,Fw=new Pe.Vector2,zw=new Pe.Vector2,Uw=new Pe.Vector2,kw=new Pe.Vector2,Te=class extends Pe.Shape{constructor(e=100,t=100){super();this.points=[];this.shapeHoles=[];this.plane=new Pe.Plane(new Pe.Vector3(0,0,-1));this.subdivision=0;this.controlSnapDistance=4;this.pointIDs=0;this.isMesh2D=!1;this._roundness=0;this.isClosed=!1;this.useCubicForRoundedCorners=!0;this.uuid=Pe.MathUtils.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=t}static createFromState(e,t,o){let i=new Te;return i.isClosed=e.isClosed,i.points=e.points.map(s=>fr.create(s.id,s.data)),typeof e.roundness=="number"&&(i.roundness=e.roundness),i.shapeHoles=e.shapeHoles.map(s=>Te.createFromState(s)),t!==void 0&&o!==void 0&&i.applySize(t,o),i.update(),i}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(e){if(this._roundness!==e){this._roundness=e;for(let t=0,o=this.points.length;t<o;t++)this.points[t].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(t=>this.getPointIndexById(t)).filter(t=>t>=0)}getPointIndexById(e){let t=this.points.length,o=this.points.findIndex(i=>i.uuid===e);if(o<0){let i=t;for(let s=0,l=this.shapeHoles.length;s<l;s++){let c=this.shapeHoles[s],u=c.points.length,a=c.getPointIndexById(e);if(a<0)i+=u;else return a+i}}return o}getLineIndexById(e){return this.getPointIndexById(e)}getBezierPoint(e){if(e<=this.points.length-1)return this.points[e];if(this.shapeHoles.length>0){let t=this.points.length;for(let o=0,i=this.shapeHoles.length;o<i;o++){let s=this.shapeHoles[o],l=e-t;if(l<=s.points.length-1)return s.points[l];t+=s.points.length}}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let t=this.points.indexOf(e);if(t>=0)return t;if(t=this.points.length,this.shapeHoles.length>0)for(let o=0,i=this.shapeHoles.length;o<i;o++){let s=this.shapeHoles[o],l=s.points.indexOf(e);if(l>=0)return t+l;t+=s.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(t=>t.points));return[...this.points,...e]}applySize(e,t){e===0&&(e=.001),t===0&&(t=.001),this._width=e,this._height=t}applyScale(e,t){let o=Xc.set(e,t);for(let i=0,s=this.points.length;i<s;i++){let l=this.points[i];l.position.multiply(o),l.controls[0].position.multiply(o),l.controls[1].position.multiply(o)}for(let i=0,s=this.shapeHoles.length;i<s;i++)this.shapeHoles[i].applyScale(e,t);this._update()}createPoint(e,t=0,o=Pe.MathUtils.generateUUID()){let i;e instanceof Pe.Vector2?i=e:i=new Pe.Vector2(e,t);let s=new fr(o,i);return s.roundness=this.roundness,s}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,t){this.points.splice(t,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let t=0,o=this.points.length;t<o;t++){let i=this.points[t];if(i.uuid===e)return i}for(let t=0,o=this.shapeHoles.length;t<o;t++){let s=this.shapeHoles[t].getPointByUuid(e);if(s)return s}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){let t=this.points.indexOf(e);t>=0&&this.points.splice(t,1),this.needsUpdate=!0}removePointById(e){let t=this.points.find(o=>o.uuid===e);t&&this.removePoint(t)}update(){for(let e=0,t=this.shapeHoles.length;e<t;e++)this.shapeHoles[e].update();this._update()}extractShapePointsToBuffer(e,t=12,o=!1){this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t);let i=o?this.roundedCurveDivisions:this.curveDivisions;return Ym(e,o?this.roundedCurves:this.curves,t,this.autoClose),i.reduce((s,l)=>s+l,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=Yc(this.points,e,!1),this.roundedCurveDivisions=Yc(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,t,o=12){return Xm(e,this.curves,t,o,this.autoClose).reduce((s,l)=>s+l,0)*2}extractShapePointsToFlatArray(e,t=12){return this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t),Km(e,this.roundedCurves,t,this.autoClose)}getCurveIndexFromVertexId(e,t=!1){let o=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let i=t?this.roundedCurveDivisions:this.curveDivisions,s=0;t&&this.points[0].roundedCurveCorner!==void 0&&(s=wo(this.points[0].roundedCurveCorner,this.subdivision)*.5);let l=e-s;l<0&&(l+=i.reduce((c,u)=>c+u,0));for(let c=0,u=i.length;c<u;c++){let a=i[c];if(l<o+a)return[c,(l-o+1)/a];o+=a}return[0,1]}getCurveT(e,t,o){let i=this.points[e],s=this.points[e>=this.points.length-1?0:e+1],l=this.curveDivisions,c=l[e];if($c(i,s)){let d=i.position.distanceTo(s.position);return i.position.distanceTo(Xc.set(o.x,o.y))/d}let u=0;for(let d=0;d<e;d++)u+=l[d];return(t-u)/c}dispose(){}_applyCurveForPoint(e,t){$c(t,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(t.controls[1].position.x,t.controls[1].position.y,e.controls[0].position.x,e.controls[0].position.y,e.position.x,e.position.y);let o=this.curves[this.curves.length-1];e.curveBefore=o,t.curveAfter=o;let i=o.clone();e.roundedCurveBefore=i,t.roundedCurveAfter=i,e.roundedCurveCorner=void 0,this.roundedCurves.push(i)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let t=0,o=this.points.length;t<o;t++){let i=this.points[t];if(t===0)this.moveTo(i.position.x,i.position.y);else{let s=this.points[t-1];this._applyCurveForPoint(i,s)}}let e=this.getLastPoint();if(e?.curveAfter&&(e.curveAfter=void 0),this.isClosed){let t=this.points[0],o=this.points[this.points.length-1];this._applyCurveForPoint(t,o)}if(this.points.length>2){let t=0;for(let o=0,i=this.points.length;o<i;o++){let s=this.points[o],l=this.points[o-1]??this.points[this.points.length-1],c=this.points[o+1]??this.points[0],u=s.roundness,a=l&&c&&km(l,s,c);if(!s.controlsMoved()&&u>0&&!a){let d=s.curveBefore,p=s.curveAfter;if(d===void 0||p===void 0)continue;let f=s.roundedCurveBefore,m=s.roundedCurveAfter,h=d.getLength(),y=p.getLength(),g=Math.min(u,h*.499),v=Math.min(u,y*.499),w=Math.min(g,v),S=1-w/h,b=w/y,T=d.getPointAt(S,Xc),_=p.getPointAt(b,jw);this._subSplitCurve(d,f,S,T,void 0),this._subSplitCurve(p,m,b,void 0,_);let x;if(this.useCubicForRoundedCorners){let C=qc(T,s.position,_)/2,P=Math.tan(C)*T.distanceTo(s.position),[I,A]=Hm(T,_,P,Fw,zw),O=Wm(I,A,s.position),[V,z]=qm(O,T,_,P,Uw,kw);x=new Pe.CubicBezierCurve(T.clone(),V.clone(),z.clone(),_.clone())}else x=new Pe.QuadraticBezierCurve(T.clone(),s.position.clone(),_.clone());s.roundedCurveCorner=x,this.roundedCurves.splice(o+t,0,x),t++}}}}_subSplitCurve(e,t,o,i,s){if(e instanceof Pe.LineCurve)i!==void 0&&t.v2.copy(i),s!==void 0&&t.v1.copy(s);else{let l=e,c=t,u=l.getUtoTmapping(o,0),a=$m(l.v0,l.v1,l.v2,l.v3,u);return i!==void 0&&(c.v0.set(a[0],a[1]),c.v1.set(a[2],a[3]),c.v2.set(a[4],a[5]),c.v3.set(a[6],a[7])),s!==void 0&&(c.v0.set(a[6],a[7]),c.v1.set(a[8],a[9]),c.v2.set(a[10],a[11]),c.v3.set(a[12],a[13])),c}return t}clone(){let e=new Te(this._width,this._height);return e.points=this.points.map(t=>t.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(t=>t.clone()),e}toJSON(){return{points:this.points.reduce((e,t)=>e.concat(t.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){this.points=[],this.pointIDs=0;let t=e.points.length/7;for(let o=0;o<t;o++){let i=o*7,s=e.points[i+0],l=e.points[i+1],c=e.points[i+2],u=e.points[i+3],a=e.points[i+4],d=e.points[i+5],p=e.points[i+6],f=new fr(Pe.MathUtils.generateUUID(),new Pe.Vector2(s,l));f.controls[0].position.set(c,u),f.controls[1].position.set(a,d),f.roundness=p,this.points.push(f)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(o=>{let i=new Te;return i.fromJSON(o),i}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e){let t=(i,s)=>{s instanceof Pe.CubicBezierCurve&&s.v3.equals(i.position)&&i.controls[0].position.copy(s.v2)},o=i=>{let s=[],l,c;for(l=0,c=i.length;l<c;l++)i[l]instanceof Pe.QuadraticBezierCurve&&(i[l]=Um(i[l]));for(l=0,c=i.length;l<c;l++){let d=i[l],p=l>0?i[l-1]:null,f;d instanceof Pe.CubicBezierCurve?(f=this.createPoint(d.v0),f.controls[1].position.copy(d.v1)):d instanceof Pe.LineCurve&&(f=this.createPoint(d.v1)),f!==void 0&&(p!==null&&t(f,p),s.push(f))}let u=i[i.length-1],a=!1;return u instanceof Pe.CubicBezierCurve?u.v3.equals(s[0].position)&&(s[0].controls[0].position.copy(u.v2),a=!0):u instanceof Pe.LineCurve&&u.v2.equals(s[0].position)&&(a=!0),this.isClosed=a,s};return this.points=o(e.curves),e instanceof Pe.Shape&&(this.shapeHoles=e.holes.map(i=>{let s=new Te;return s.fromShape(i),s})),this.update(),this}updatePoint(e,t){let o=this.getPointByUuid(e);o&&(t.position!==void 0&&o.position.fromArray(t.position),t.roundness!==void 0&&(o.roundness=t.roundness),t.areControlsDirectionsMirrored!==void 0&&(o.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(e,t){let i=this.getPointByUuid(e)?.controls[0];i&&(t.position&&i.position.fromArray(t.position),this.needsUpdate=!0)}updateNextControl(e,t){let i=this.getPointByUuid(e)?.controls[1];i&&(t.position&&i.position.fromArray(t.position),this.needsUpdate=!0)}};var Zc=Math.PI*2;function Kc({x:n,y:r},e,t,o,i){return{x:n*e+o,y:r*t+i}}function Hw(n,r){let e=r===1.5707963267948966?.551915024494:r===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(r/4),t=Math.cos(n),o=Math.sin(n),i=Math.cos(n+r),s=Math.sin(n+r);return[{x:t-o*e,y:o+t*e},{x:i+s*e,y:s-i*e},{x:i,y:s}]}function Zm(n,r,e,t){let o=n*t-r*e<0?-1:1,i=Math.min(1,Math.max(-1,n*e+r*t));return o*Math.acos(i)}function Ww(n,r,e,t,o,i,s,l,c,u){let a=Math.pow(o,2),d=Math.pow(i,2),p=Math.pow(s,2),f=Math.pow(l,2),m=a*d-a*f-d*p;m<0&&(m=0),m/=a*f+d*p,m=Math.sqrt(m)*(c===u?-1:1);let h=m*o/i*l,y=m*-i/o*s,g=h+(n+e)/2,v=y+(r+t)/2,w=(s-h)/o,S=(l-y)/i,b=(-s-h)/o,T=(-l-y)/i,_=Zm(1,0,w,S),x=Zm(w,S,b,T);return!u&&x>0&&(x-=Zc),u&&x<0&&(x+=Zc),{centerx:g,centery:v,ang1:_,ang2:x}}function Qm({px:n,py:r,cx:e,cy:t,rx:o,ry:i,largeArcFlag:s,sweepFlag:l}){let c=[];if(o===0||i===0)return[];let u=(n-e)/2,a=(r-t)/2;if(u===0&&a===0)return[];o=Math.abs(o),i=Math.abs(i);let d=Math.pow(u,2)/Math.pow(o,2)+Math.pow(a,2)/Math.pow(i,2);d>1&&(o*=Math.sqrt(d),i*=Math.sqrt(d));let p=Ww(n,r,e,t,o,i,u,a,s,l),{ang1:f,ang2:m}=p,{centerx:h,centery:y}=p,g=Math.abs(m)/(Zc/4);Math.abs(1-g)<1e-7&&(g=1);let v=Math.max(Math.ceil(g),1);m/=v;for(let w=0;w<v;w++)c.push(Hw(f,m)),f+=m;return c.map(w=>{let{x:S,y:b}=Kc(w[0],o,i,h,y),{x:T,y:_}=Kc(w[1],o,i,h,y),{x,y:C}=Kc(w[2],o,i,h,y);return{x1:S,y1:b,x2:T,y2:_,x,y:C}})}var ko=require("three");var we;(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"})(we||(we={}));var We;(function(n){n[n.POLYGONS=0]="POLYGONS",n[n.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",n[n.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(We||(We={}));function pe(n,r){if(!n)throw r||"Assertion Failed!"}var le=function(){function n(){}return n.vertEq=function(r,e){return r.s===e.s&&r.t===e.t},n.vertLeq=function(r,e){return r.s<e.s||r.s===e.s&&r.t<=e.t},n.transLeq=function(r,e){return r.t<e.t||r.t===e.t&&r.s<=e.s},n.edgeGoesLeft=function(r){return n.vertLeq(r.Dst,r.Org)},n.edgeGoesRight=function(r){return n.vertLeq(r.Org,r.Dst)},n.vertL1dist=function(r,e){return Math.abs(r.s-e.s)+Math.abs(r.t-e.t)},n.edgeEval=function(r,e,t){pe(n.vertLeq(r,e)&&n.vertLeq(e,t));var o=e.s-r.s,i=t.s-e.s;return o+i>0?o<i?e.t-r.t+(r.t-t.t)*(o/(o+i)):e.t-t.t+(t.t-r.t)*(i/(o+i)):0},n.edgeSign=function(r,e,t){pe(n.vertLeq(r,e)&&n.vertLeq(e,t));var o=e.s-r.s,i=t.s-e.s;return o+i>0?(e.t-t.t)*o+(e.t-r.t)*i:0},n.transEval=function(r,e,t){pe(n.transLeq(r,e)&&n.transLeq(e,t));var o=e.t-r.t,i=t.t-e.t;return o+i>0?o<i?e.s-r.s+(r.s-t.s)*(o/(o+i)):e.s-t.s+(t.s-r.s)*(i/(o+i)):0},n.transSign=function(r,e,t){pe(n.transLeq(r,e)&&n.transLeq(e,t));var o=e.t-r.t,i=t.t-e.t;return o+i>0?(e.s-t.s)*o+(e.s-r.s)*i:0},n.vertCCW=function(r,e,t){return r.s*(e.t-t.t)+e.s*(t.t-r.t)+t.s*(r.t-e.t)>=0},n.interpolate=function(r,e,t,o){return r=r<0?0:r,t=t<0?0:t,r<=t?t===0?(e+o)/2:e+(o-e)*(r/(r+t)):o+(e-o)*(t/(r+t))},n.intersect=function(r,e,t,o,i){var s,l,c;n.vertLeq(r,e)||(c=r,r=e,e=c),n.vertLeq(t,o)||(c=t,t=o,o=c),n.vertLeq(r,t)||(c=r,r=t,t=c,c=e,e=o,o=c),n.vertLeq(t,e)?n.vertLeq(e,o)?(s=n.edgeEval(r,t,e),l=n.edgeEval(t,e,o),s+l<0&&(s=-s,l=-l),i.s=n.interpolate(s,t.s,l,e.s)):(s=n.edgeSign(r,t,e),l=-n.edgeSign(r,o,e),s+l<0&&(s=-s,l=-l),i.s=n.interpolate(s,t.s,l,o.s)):i.s=(t.s+e.s)/2,n.transLeq(r,e)||(c=r,r=e,e=c),n.transLeq(t,o)||(c=t,t=o,o=c),n.transLeq(r,t)||(c=r,r=t,t=c,c=e,e=o,o=c),n.transLeq(t,e)?n.transLeq(e,o)?(s=n.transEval(r,t,e),l=n.transEval(t,e,o),s+l<0&&(s=-s,l=-l),i.t=n.interpolate(s,t.t,l,e.t)):(s=n.transSign(r,t,e),l=-n.transSign(r,o,e),s+l<0&&(s=-s,l=-l),i.t=n.interpolate(s,t.t,l,o.t)):i.t=(t.t+e.t)/2},n}(),as=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}(),cl=function(){function n(r){this.side=r,this.next=null,this.Org=null,this.Sym=null,this.Onext=null,this.Lnext=null,this.Lface=null,this.activeRegion=null,this.winding=0}return Object.defineProperty(n.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(r){this.Sym.Lface=r},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(r){this.Sym.Org=r},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(r){this.Sym.Lnext=r},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(r){this.Onext.Sym=r},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(r){this.Lnext.Sym=r},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(r){this.Sym.Onext=r},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(r){this.Sym.Onext.Sym=r},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(r){this.Sym.Lnext.Sym=r},enumerable:!0,configurable:!0}),n}(),Zn=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}(),Jm=function(){function n(){var r=new Zn,e=new as,t=new cl(0),o=new cl(1);r.next=r.prev=r,r.anEdge=null,e.next=e.prev=e,t.next=t,t.Sym=o,o.next=o,o.Sym=t,this.vHead=r,this.fHead=e,this.eHead=t,this.eHeadSym=o}return n.prototype.makeEdge_=function(r){var e=new cl(0),t=new cl(1);r.Sym.side<r.side&&(r=r.Sym);var o=r.Sym.next;return t.next=o,o.Sym.next=e,e.next=r,r.Sym.next=t,e.Sym=t,e.Onext=e,e.Lnext=t,e.Org=null,e.Lface=null,e.winding=0,e.activeRegion=null,t.Sym=e,t.Onext=t,t.Lnext=e,t.Org=null,t.Lface=null,t.winding=0,t.activeRegion=null,e},n.prototype.splice_=function(r,e){var t=r.Onext,o=e.Onext;t.Sym.Lnext=e,o.Sym.Lnext=r,r.Onext=o,e.Onext=t},n.prototype.makeVertex_=function(r,e,t){var o=r;pe(o,"Vertex can't be null!");var i=t.prev;o.prev=i,i.next=o,o.next=t,t.prev=o,o.anEdge=e;var s=e;do s.Org=o,s=s.Onext;while(s!==e)},n.prototype.makeFace_=function(r,e,t){var o=r;pe(o,"Face can't be null");var i=t.prev;o.prev=i,i.next=o,o.next=t,t.prev=o,o.anEdge=e,o.trail=null,o.marked=!1,o.inside=t.inside;var s=e;do s.Lface=o,s=s.Lnext;while(s!==e)},n.prototype.killEdge_=function(r){r.Sym.side<r.side&&(r=r.Sym);var e=r.next,t=r.Sym.next;e.Sym.next=t,t.Sym.next=e},n.prototype.killVertex_=function(r,e){var t=r.anEdge,o=t;do o.Org=e,o=o.Onext;while(o!==t);var i=r.prev,s=r.next;s.prev=i,i.next=s},n.prototype.killFace_=function(r,e){var t=r.anEdge,o=t;do o.Lface=e,o=o.Lnext;while(o!==t);var i=r.prev,s=r.next;s.prev=i,i.next=s},n.prototype.makeEdge=function(){var r=new Zn,e=new Zn,t=new as,o=this.makeEdge_(this.eHead);return this.makeVertex_(r,o,this.vHead),this.makeVertex_(e,o.Sym,this.vHead),this.makeFace_(t,o,this.fHead),o},n.prototype.splice=function(r,e){var t=!1,o=!1;if(r!==e){if(e.Org!==r.Org&&(o=!0,this.killVertex_(e.Org,r.Org)),e.Lface!==r.Lface&&(t=!0,this.killFace_(e.Lface,r.Lface)),this.splice_(e,r),!o){var i=new Zn;this.makeVertex_(i,e,r.Org),r.Org.anEdge=r}if(!t){var s=new as;this.makeFace_(s,e,r.Lface),r.Lface.anEdge=r}}},n.prototype.delete=function(r){var e=r.Sym,t=!1;if(r.Lface!==r.Rface&&(t=!0,this.killFace_(r.Lface,r.Rface)),r.Onext===r)this.killVertex_(r.Org,null);else if(r.Rface.anEdge=r.Oprev,r.Org.anEdge=r.Onext,this.splice_(r,r.Oprev),!t){var o=new as;this.makeFace_(o,r,r.Lface)}e.Onext===e?(this.killVertex_(e.Org,null),this.killFace_(e.Lface,null)):(r.Lface.anEdge=e.Oprev,e.Org.anEdge=e.Onext,this.splice_(e,e.Oprev)),this.killEdge_(r)},n.prototype.addEdgeVertex=function(r){var e=this.makeEdge_(r),t=e.Sym;this.splice_(e,r.Lnext),e.Org=r.Dst;var o=new Zn;return this.makeVertex_(o,t,e.Org),e.Lface=t.Lface=r.Lface,e},n.prototype.splitEdge=function(r){var e=this.addEdgeVertex(r),t=e.Sym;return this.splice_(r.Sym,r.Sym.Oprev),this.splice_(r.Sym,t),r.Dst=t.Org,t.Dst.anEdge=t.Sym,t.Rface=r.Rface,t.winding=r.winding,t.Sym.winding=r.Sym.winding,t.idx=r.idx,t.Sym.idx=r.Sym.idx,t},n.prototype.connect=function(r,e){var t=!1,o=this.makeEdge_(r),i=o.Sym;if(e.Lface!==r.Lface&&(t=!0,this.killFace_(e.Lface,r.Lface)),this.splice_(o,r.Lnext),this.splice_(i,e),o.Org=r.Dst,i.Org=e.Org,o.Lface=i.Lface=r.Lface,r.Lface.anEdge=i,!t){var s=new as;this.makeFace_(s,o,r.Lface)}return o},n.prototype.zapFace=function(r){var e=r.anEdge,t,o,i,s,l;o=e.Lnext;do t=o,o=t.Lnext,t.Lface=null,t.Rface===null&&(t.Onext===t?this.killVertex_(t.Org,null):(t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev)),i=t.Sym,i.Onext===i?this.killVertex_(i.Org,null):(i.Org.anEdge=i.Onext,this.splice_(i,i.Oprev)),this.killEdge_(t));while(t!=e);s=r.prev,l=r.next,l.prev=s,s.next=l},n.prototype.countFaceVerts_=function(r){var e=r.anEdge,t=0;do t++,e=e.Lnext;while(e!==r.anEdge);return t},n.prototype.mergeConvexFaces=function(r){var e,t,o,i,s,l,c;for(e=this.fHead.next;e!==this.fHead;e=e.next)if(!!e.inside)for(t=e.anEdge,s=t.Org;o=t.Lnext,i=t.Sym,i&&i.Lface&&i.Lface.inside&&(l=this.countFaceVerts_(e),c=this.countFaceVerts_(i.Lface),l+c-2<=r&&le.vertCCW(t.Lprev.Org,t.Org,i.Lnext.Lnext.Org)&&le.vertCCW(i.Lprev.Org,i.Org,t.Lnext.Lnext.Org)&&(o=i.Lnext,this.delete(i),t=null,i=null)),!(t&&t.Lnext.Org===s);)t=o;return!0},n.prototype.check=function(){var r=this.fHead,e=this.vHead,t=this.eHead,o,i,s,l,c,u;for(i=r,i=r;(o=i.next)!==r;i=o){pe(o.prev===i),c=o.anEdge;do pe(c.Sym!==c),pe(c.Sym.Sym===c),pe(c.Lnext.Onext.Sym===c),pe(c.Onext.Sym.Lnext===c),pe(c.Lface===o),c=c.Lnext;while(c!==o.anEdge)}for(pe(o.prev===i&&o.anEdge===null),l=e,l=e;(s=l.next)!==e;l=s){pe(s.prev===l),c=s.anEdge;do pe(c.Sym!==c),pe(c.Sym.Sym===c),pe(c.Lnext.Onext.Sym===c),pe(c.Onext.Sym.Lnext===c),pe(c.Org===s),c=c.Onext;while(c!==s.anEdge)}for(pe(s.prev===l&&s.anEdge===null),u=t,u=t;(c=u.next)!==t;u=c)pe(c.Sym.next===u.Sym),pe(c.Sym!==c),pe(c.Sym.Sym===c),pe(c.Org!==null),pe(c.Dst!==null),pe(c.Lnext.Onext.Sym===c),pe(c.Onext.Sym.Lnext===c);pe(c.Sym.next===u.Sym&&c.Sym===this.eHeadSym&&c.Sym.Sym===c&&c.Org===null&&c.Dst===null&&c.Lface===null&&c.Rface===null)},n}(),eh=function(){function n(){this.handle=null}return n}(),th=function(){function n(){this.key=null,this.node=0}return n}(),qw=function(){function n(r,e){this.leq=e,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=r,this.nodes=[],this.handles=[];for(var t=0;t<r+1;t++)this.nodes[t]=new eh,this.handles[t]=new th;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return n.prototype.floatDown_=function(r){var e=this.nodes,t=this.handles,o,i,s;for(o=e[r].handle;;){if(s=r<<1,s<this.size&&this.leq(t[e[s+1].handle].key,t[e[s].handle].key)&&++s,pe(s<=this.max),i=e[s].handle,s>this.size||this.leq(t[o].key,t[i].key)){e[r].handle=o,t[o].node=r;break}e[r].handle=i,t[i].node=r,r=s}},n.prototype.floatUp_=function(r){var e=this.nodes,t=this.handles,o,i,s;for(o=e[r].handle;;){if(s=r>>1,i=e[s].handle,s===0||this.leq(t[i].key,t[o].key)){e[r].handle=o,t[o].node=r;break}e[r].handle=i,t[i].node=r,r=s}},n.prototype.init=function(){for(var r=this.size;r>=1;--r)this.floatDown_(r);this.initialized=!0},n.prototype.min=function(){return this.handles[this.nodes[1].handle].key},n.prototype.insert=function(r){var e,t;if(e=++this.size,e*2>this.max){this.max*=2;var o,i;for(i=this.nodes.length,this.nodes.length=this.max+1,o=i;o<this.nodes.length;o++)this.nodes[o]=new eh;for(i=this.handles.length,this.handles.length=this.max+1,o=i;o<this.handles.length;o++)this.handles[o]=new th}return this.freeList===0?t=e:(t=this.freeList,this.freeList=this.handles[t].node),this.nodes[e].handle=t,this.handles[t].node=e,this.handles[t].key=r,this.initialized&&this.floatUp_(e),t},n.prototype.extractMin=function(){var r=this.nodes,e=this.handles,t=r[1].handle,o=e[t].key;return this.size>0&&(r[1].handle=r[this.size].handle,e[r[1].handle].node=1,e[t].key=null,e[t].node=this.freeList,this.freeList=t,--this.size,this.size>0&&this.floatDown_(1)),o},n.prototype.delete=function(r){var e=this.nodes,t=this.handles,o;pe(r>=1&&r<=this.max&&t[r].key!==null),o=t[r].node,e[o].handle=e[this.size].handle,t[e[o].handle].node=o,--this.size,o<=this.size&&(o<=1||this.leq(t[e[o>>1].handle].key,t[e[o].handle].key)?this.floatDown_(o):this.floatUp_(o)),t[r].key=null,t[r].node=this.freeList,this.freeList=r},n}(),Qc=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}(),rh=function(){function n(){this.key=null,this.next=null,this.prev=null}return n}(),$w=function(){function n(r,e){this.frame=r,this.leq=e,this.head=new rh,this.head.next=this.head,this.head.prev=this.head}return n.prototype.min=function(){return this.head.next},n.prototype.max=function(){return this.head.prev},n.prototype.insert=function(r){return this.insertBefore(this.head,r)},n.prototype.search=function(r){var e=this.head;do e=e.next;while(e.key!==null&&!this.leq(this.frame,r,e.key));return e},n.prototype.insertBefore=function(r,e){do r=r.prev;while(r.key!==null&&!this.leq(this.frame,r.key,e));var t=new rh;return t.key=e,t.next=r.next,r.next.prev=t,t.prev=r,r.next=t,t},n.prototype.delete=function(r){r.next.prev=r.prev,r.prev.next=r.next},n}(),Yw=function(){function n(){}return n.regionBelow=function(r){return r.nodeUp.prev.key},n.regionAbove=function(r){return r.nodeUp.next.key},n.debugEvent=function(r){},n.addWinding=function(r,e){r.winding+=e.winding,r.Sym.winding+=e.Sym.winding},n.edgeLeq=function(r,e,t){var o=r.event,i=e.eUp,s=t.eUp;if(i.Dst===o)return s.Dst===o?le.vertLeq(i.Org,s.Org)?le.edgeSign(s.Dst,i.Org,s.Org)<=0:le.edgeSign(i.Dst,s.Org,i.Org)>=0:le.edgeSign(s.Dst,o,s.Org)<=0;if(s.Dst===o)return le.edgeSign(i.Dst,o,i.Org)>=0;var l=le.edgeEval(i.Dst,o,i.Org),c=le.edgeEval(s.Dst,o,s.Org);return l>=c},n.deleteRegion=function(r,e){e.fixUpperEdge&&pe(e.eUp.winding===0),e.eUp.activeRegion=null,r.dict.delete(e.nodeUp)},n.fixUpperEdge=function(r,e,t){pe(e.fixUpperEdge),r.mesh.delete(e.eUp),e.fixUpperEdge=!1,e.eUp=t,t.activeRegion=e},n.topLeftRegion=function(r,e){var t=e.eUp.Org,o;do e=n.regionAbove(e);while(e.eUp.Org===t);if(e.fixUpperEdge){if(o=r.mesh.connect(n.regionBelow(e).eUp.Sym,e.eUp.Lnext),o===null)return null;n.fixUpperEdge(r,e,o),e=n.regionAbove(e)}return e},n.topRightRegion=function(r){var e=r.eUp.Dst;do r=n.regionAbove(r);while(r.eUp.Dst===e);return r},n.addRegionBelow=function(r,e,t){var o=new Qc;return o.eUp=t,o.nodeUp=r.dict.insertBefore(e.nodeUp,o),o.fixUpperEdge=!1,o.sentinel=!1,o.dirty=!1,t.activeRegion=o,o},n.isWindingInside=function(r,e){switch(r.windingRule){case we.ODD:return(e&1)!==0;case we.NONZERO:return e!==0;case we.POSITIVE:return e>0;case we.NEGATIVE:return e<0;case we.ABS_GEQ_TWO:return e>=2||e<=-2}throw new Error("Invalid winding rulle")},n.computeWinding=function(r,e){e.windingNumber=n.regionAbove(e).windingNumber+e.eUp.winding,e.inside=n.isWindingInside(r,e.windingNumber)},n.finishRegion=function(r,e){var t=e.eUp,o=t.Lface;o.inside=e.inside,o.anEdge=t,n.deleteRegion(r,e)},n.finishLeftRegions=function(r,e,t){for(var o,i=null,s=e,l=e.eUp;s!==t;){if(s.fixUpperEdge=!1,i=n.regionBelow(s),o=i.eUp,o.Org!=l.Org){if(!i.fixUpperEdge){n.finishRegion(r,s);break}o=r.mesh.connect(l.Lprev,o.Sym),n.fixUpperEdge(r,i,o)}l.Onext!==o&&(r.mesh.splice(o.Oprev,o),r.mesh.splice(l,o)),n.finishRegion(r,s),l=i.eUp,s=i}return l},n.addRightEdges=function(r,e,t,o,i,s){var l,c,u,a,d=!0;u=t;do pe(le.vertLeq(u.Org,u.Dst)),n.addRegionBelow(r,e,u.Sym),u=u.Onext;while(u!==o);for(i===null&&(i=n.regionBelow(e).eUp.Rprev),c=e,a=i;l=n.regionBelow(c),u=l.eUp.Sym,u.Org===a.Org;)u.Onext!==a&&(r.mesh.splice(u.Oprev,u),r.mesh.splice(a.Oprev,u)),l.windingNumber=c.windingNumber-u.winding,l.inside=n.isWindingInside(r,l.windingNumber),c.dirty=!0,!d&&n.checkForRightSplice(r,c)&&(n.addWinding(u,a),n.deleteRegion(r,c),r.mesh.delete(a)),d=!1,c=l,a=u;c.dirty=!0,pe(c.windingNumber-u.winding===l.windingNumber),s&&n.walkDirtyRegions(r,c)},n.spliceMergeVertices=function(r,e,t){r.mesh.splice(e,t)},n.vertexWeights=function(r,e,t){var o=le.vertL1dist(e,r),i=le.vertL1dist(t,r),s=.5*i/(o+i),l=.5*o/(o+i);r.coords[0]+=s*e.coords[0]+l*t.coords[0],r.coords[1]+=s*e.coords[1]+l*t.coords[1],r.coords[2]+=s*e.coords[2]+l*t.coords[2]},n.getIntersectData=function(r,e,t,o,i,s){e.coords[0]=e.coords[1]=e.coords[2]=0,e.idx=-1,n.vertexWeights(e,t,o),n.vertexWeights(e,i,s)},n.checkForRightSplice=function(r,e){var t=n.regionBelow(e),o=e.eUp,i=t.eUp;if(le.vertLeq(o.Org,i.Org)){if(le.edgeSign(i.Dst,o.Org,i.Org)>0)return!1;le.vertEq(o.Org,i.Org)?o.Org!==i.Org&&(r.pq.delete(o.Org.pqHandle),n.spliceMergeVertices(r,i.Oprev,o)):(r.mesh.splitEdge(i.Sym),r.mesh.splice(o,i.Oprev),e.dirty=t.dirty=!0)}else{if(le.edgeSign(o.Dst,i.Org,o.Org)<0)return!1;n.regionAbove(e).dirty=e.dirty=!0,r.mesh.splitEdge(o.Sym),r.mesh.splice(i.Oprev,o)}return!0},n.checkForLeftSplice=function(r,e){var t=n.regionBelow(e),o=e.eUp,i=t.eUp,s;if(pe(!le.vertEq(o.Dst,i.Dst)),le.vertLeq(o.Dst,i.Dst)){if(le.edgeSign(o.Dst,i.Dst,o.Org)<0)return!1;n.regionAbove(e).dirty=e.dirty=!0,s=r.mesh.splitEdge(o),r.mesh.splice(i.Sym,s),s.Lface.inside=e.inside}else{if(le.edgeSign(i.Dst,o.Dst,i.Org)>0)return!1;e.dirty=t.dirty=!0,s=r.mesh.splitEdge(i),r.mesh.splice(o.Lnext,i.Sym),s.Rface.inside=e.inside}return!0},n.checkForIntersect=function(r,e){var t=n.regionBelow(e),o=e.eUp,i=t.eUp,s=o.Org,l=i.Org,c=o.Dst,u=i.Dst,a,d,p=new Zn,f,m;if(pe(!le.vertEq(u,c)),pe(le.edgeSign(c,r.event,s)<=0),pe(le.edgeSign(u,r.event,l)>=0),pe(s!==r.event&&l!==r.event),pe(!e.fixUpperEdge&&!t.fixUpperEdge),s===l||(a=Math.min(s.t,c.t),d=Math.max(l.t,u.t),a>d))return!1;if(le.vertLeq(s,l)){if(le.edgeSign(u,s,l)>0)return!1}else if(le.edgeSign(c,l,s)<0)return!1;return n.debugEvent(r),le.intersect(c,s,u,l,p),pe(Math.min(s.t,c.t)<=p.t),pe(p.t<=Math.max(l.t,u.t)),pe(Math.min(u.s,c.s)<=p.s),pe(p.s<=Math.max(l.s,s.s)),le.vertLeq(p,r.event)&&(p.s=r.event.s,p.t=r.event.t),f=le.vertLeq(s,l)?s:l,le.vertLeq(f,p)&&(p.s=f.s,p.t=f.t),le.vertEq(p,s)||le.vertEq(p,l)?(n.checkForRightSplice(r,e),!1):!le.vertEq(c,r.event)&&le.edgeSign(c,r.event,p)>=0||!le.vertEq(u,r.event)&&le.edgeSign(u,r.event,p)<=0?u===r.event?(r.mesh.splitEdge(o.Sym),r.mesh.splice(i.Sym,o),e=n.topLeftRegion(r,e),o=n.regionBelow(e).eUp,n.finishLeftRegions(r,n.regionBelow(e),t),n.addRightEdges(r,e,o.Oprev,o,o,!0),!0):c===r.event?(r.mesh.splitEdge(i.Sym),r.mesh.splice(o.Lnext,i.Oprev),t=e,e=n.topRightRegion(e),m=n.regionBelow(e).eUp.Rprev,t.eUp=i.Oprev,i=n.finishLeftRegions(r,t,null),n.addRightEdges(r,e,i.Onext,o.Rprev,m,!0),!0):(le.edgeSign(c,r.event,p)>=0&&(n.regionAbove(e).dirty=e.dirty=!0,r.mesh.splitEdge(o.Sym),o.Org.s=r.event.s,o.Org.t=r.event.t),le.edgeSign(u,r.event,p)<=0&&(e.dirty=t.dirty=!0,r.mesh.splitEdge(i.Sym),i.Org.s=r.event.s,i.Org.t=r.event.t),!1):(r.mesh.splitEdge(o.Sym),r.mesh.splitEdge(i.Sym),r.mesh.splice(i.Oprev,o),o.Org.s=p.s,o.Org.t=p.t,o.Org.pqHandle=r.pq.insert(o.Org),n.getIntersectData(r,o.Org,s,c,l,u),n.regionAbove(e).dirty=e.dirty=t.dirty=!0,!1)},n.walkDirtyRegions=function(r,e){for(var t=n.regionBelow(e),o,i;;){for(;t.dirty;)e=t,t=n.regionBelow(t);if(!e.dirty&&(t=e,e=n.regionAbove(e),e===null||!e.dirty))return;if(e.dirty=!1,o=e.eUp,i=t.eUp,o.Dst!==i.Dst&&n.checkForLeftSplice(r,e)&&(t.fixUpperEdge?(n.deleteRegion(r,t),r.mesh.delete(i),t=n.regionBelow(e),i=t.eUp):e.fixUpperEdge&&(n.deleteRegion(r,e),r.mesh.delete(o),e=n.regionAbove(t),o=e.eUp)),o.Org!==i.Org)if(o.Dst!==i.Dst&&!e.fixUpperEdge&&!t.fixUpperEdge&&(o.Dst===r.event||i.Dst===r.event)){if(n.checkForIntersect(r,e))return}else n.checkForRightSplice(r,e);o.Org===i.Org&&o.Dst===i.Dst&&(n.addWinding(i,o),n.deleteRegion(r,e),r.mesh.delete(o),e=n.regionAbove(t))}},n.connectRightVertex=function(r,e,t){var o,i=t.Onext,s=n.regionBelow(e),l=e.eUp,c=s.eUp,u=!1;if(l.Dst!==c.Dst&&n.checkForIntersect(r,e),le.vertEq(l.Org,r.event)&&(r.mesh.splice(i.Oprev,l),e=n.topLeftRegion(r,e),i=n.regionBelow(e).eUp,n.finishLeftRegions(r,n.regionBelow(e),s),u=!0),le.vertEq(c.Org,r.event)&&(r.mesh.splice(t,c.Oprev),t=n.finishLeftRegions(r,s,null),u=!0),u){n.addRightEdges(r,e,t.Onext,i,i,!0);return}le.vertLeq(c.Org,l.Org)?o=c.Oprev:o=l,o=r.mesh.connect(t.Lprev,o),n.addRightEdges(r,e,o,o.Onext,o.Onext,!1),o.Sym.activeRegion.fixUpperEdge=!0,n.walkDirtyRegions(r,e)},n.connectLeftDegenerate=function(r,e,t){var o,i,s,l,c;if(o=e.eUp,le.vertEq(o.Org,t)){pe(!1),n.spliceMergeVertices(r,o,t.anEdge);return}if(!le.vertEq(o.Dst,t)){r.mesh.splitEdge(o.Sym),e.fixUpperEdge&&(r.mesh.delete(o.Onext),e.fixUpperEdge=!1),r.mesh.splice(t.anEdge,o),n.sweepEvent(r,t);return}pe(!1),e=n.topRightRegion(e),c=n.regionBelow(e),s=c.eUp.Sym,i=l=s.Onext,c.fixUpperEdge&&(pe(i!==s),n.deleteRegion(r,c),r.mesh.delete(s),s=i.Oprev),r.mesh.splice(t.anEdge,s),le.edgeGoesLeft(i)||(i=null),n.addRightEdges(r,e,s.Onext,l,i,!0)},n.connectLeftVertex=function(r,e){var t,o,i,s,l,c,u=new Qc;if(u.eUp=e.anEdge.Sym,t=r.dict.search(u).key,o=n.regionBelow(t),!!o){if(s=t.eUp,l=o.eUp,le.edgeSign(s.Dst,e,s.Org)===0){n.connectLeftDegenerate(r,t,e);return}if(i=le.vertLeq(l.Dst,s.Dst)?t:o,t.inside||i.fixUpperEdge){if(i===t)c=r.mesh.connect(e.anEdge.Sym,s.Lnext);else{var a=r.mesh.connect(l.Dnext,e.anEdge);c=a.Sym}i.fixUpperEdge?n.fixUpperEdge(r,i,c):n.computeWinding(r,n.addRegionBelow(r,t,c)),n.sweepEvent(r,e)}else n.addRightEdges(r,t,e.anEdge,e.anEdge,null,!0)}},n.sweepEvent=function(r,e){r.event=e,n.debugEvent(r);for(var t=e.anEdge;t.activeRegion===null;)if(t=t.Onext,t===e.anEdge){n.connectLeftVertex(r,e);return}var o=n.topLeftRegion(r,t.activeRegion);pe(o!==null);var i=n.regionBelow(o),s=i.eUp,l=n.finishLeftRegions(r,i,null);l.Onext===s?n.connectRightVertex(r,o,l):n.addRightEdges(r,o,l.Onext,s,s,!0)},n.addSentinel=function(r,e,t,o){var i=new Qc,s=r.mesh.makeEdge();s.Org.s=t,s.Org.t=o,s.Dst.s=e,s.Dst.t=o,r.event=s.Dst,i.eUp=s,i.windingNumber=0,i.inside=!1,i.fixUpperEdge=!1,i.sentinel=!0,i.dirty=!1,i.nodeUp=r.dict.insert(i)},n.initEdgeDict=function(r){r.dict=new $w(r,n.edgeLeq);var e=r.bmax[0]-r.bmin[0],t=r.bmax[1]-r.bmin[1],o=r.bmin[0]-e,i=r.bmax[0]+e,s=r.bmin[1]-t,l=r.bmax[1]+t;n.addSentinel(r,o,i,s),n.addSentinel(r,o,i,l)},n.doneEdgeDict=function(r){for(var e,t=0;(e=r.dict.min().key)!==null;)e.sentinel||(pe(e.fixUpperEdge),pe(++t===1)),pe(e.windingNumber===0),n.deleteRegion(r,e)},n.removeDegenerateEdges=function(r){var e,t,o,i=r.mesh.eHead;for(e=i.next;e!==i;e=t)t=e.next,o=e.Lnext,le.vertEq(e.Org,e.Dst)&&e.Lnext.Lnext!==e&&(n.spliceMergeVertices(r,o,e),r.mesh.delete(e),e=o,o=e.Lnext),o.Lnext===e&&(o!==e&&((o===t||o===t.Sym)&&(t=t.next),r.mesh.delete(o)),(e===t||e===t.Sym)&&(t=t.next),r.mesh.delete(e))},n.initPriorityQ=function(r){var e,t,o,i=0;for(o=r.mesh.vHead,t=o.next;t!==o;t=t.next)i++;for(i+=8,e=r.pq=new qw(i,le.vertLeq),o=r.mesh.vHead,t=o.next;t!==o;t=t.next)t.pqHandle=e.insert(t);return t!==o?!1:(e.init(),!0)},n.donePriorityQ=function(r){r.pq=null},n.removeDegenerateFaces=function(r,e){var t,o,i;for(t=e.fHead.next;t!==e.fHead;t=o)o=t.next,i=t.anEdge,pe(i.Lnext!==i),i.Lnext.Lnext===i&&(n.addWinding(i.Onext,i),r.mesh.delete(i));return!0},n.computeInterior=function(r,e){e===void 0&&(e=!0);var t,o;if(n.removeDegenerateEdges(r),!n.initPriorityQ(r))return!1;for(n.initEdgeDict(r);(t=r.pq.extractMin())!==null;){for(;o=r.pq.min(),!(o===null||!le.vertEq(o,t));)o=r.pq.extractMin(),n.spliceMergeVertices(r,t.anEdge,o.anEdge);n.sweepEvent(r,t)}return r.event=r.dict.min().key.eUp.Org,n.debugEvent(r),n.doneEdgeDict(r),n.donePriorityQ(r),n.removeDegenerateFaces(r,r.mesh)?(e&&r.mesh.check(),!0):!1},n}(),Xw=function(){function n(){this.mesh=new Jm,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=we.ODD,this.dict=null,this.pq=null,this.event=null,this.vertexIndexCounter=0,this.vertices=[],this.vertexIndices=[],this.vertexCount=0,this.elements=[],this.elementCount=0}return n.prototype.dot_=function(r,e){return r[0]*e[0]+r[1]*e[1]+r[2]*e[2]},n.prototype.normalize_=function(r){var e=r[0]*r[0]+r[1]*r[1]+r[2]*r[2];if(!e)throw"Zero-size vector!";e=Math.sqrt(e),r[0]/=e,r[1]/=e,r[2]/=e},n.prototype.longAxis_=function(r){var e=0;return Math.abs(r[1])>Math.abs(r[0])&&(e=1),Math.abs(r[2])>Math.abs(r[e])&&(e=2),e},n.prototype.computeNormal_=function(r){var e,t,o,i,s,l,c=[0,0,0],u=[0,0,0],a=[0,0,0],d=[0,0,0],p=[0,0,0],f=[null,null,null],m=[null,null,null],h=this.mesh.vHead;e=h.next;for(var y=0;y<3;++y)i=e.coords[y],u[y]=i,m[y]=e,c[y]=i,f[y]=e;for(e=h.next;e!==h;e=e.next)for(var g=0;g<3;++g)i=e.coords[g],i<u[g]&&(u[g]=i,m[g]=e),i>c[g]&&(c[g]=i,f[g]=e);var v=0;if(c[1]-u[1]>c[0]-u[0]&&(v=1),c[2]-u[2]>c[v]-u[v]&&(v=2),u[v]>=c[v]){r[0]=0,r[1]=0,r[2]=1;return}for(l=0,t=m[v],o=f[v],a[0]=t.coords[0]-o.coords[0],a[1]=t.coords[1]-o.coords[1],a[2]=t.coords[2]-o.coords[2],e=h.next;e!==h;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]=a[1]*d[2]-a[2]*d[1],p[1]=a[2]*d[0]-a[0]*d[2],p[2]=a[0]*d[1]-a[1]*d[0],s=p[0]*p[0]+p[1]*p[1]+p[2]*p[2],s>l&&(l=s,r[0]=p[0],r[1]=p[1],r[2]=p[2]);l<=0&&(r[0]=r[1]=r[2]=0,r[this.longAxis_(a)]=1)},n.prototype.checkOrientation_=function(){for(var r=this.mesh.fHead,e,t=this.mesh.vHead,o,i=0,s=r.next;s!==r;s=s.next)if(o=s.anEdge,!(o.winding<=0))do i+=(o.Org.s-o.Dst.s)*(o.Org.t+o.Dst.t),o=o.Lnext;while(o!==s.anEdge);if(i<0){for(e=t.next;e!==t;e=e.next)e.t=-e.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},n.prototype.projectPolygon_=function(){var r=this.mesh.vHead,e=[0,0,0],t,o,i=!1;e[0]=this.normal[0],e[1]=this.normal[1],e[2]=this.normal[2],!e[0]&&!e[1]&&!e[2]&&(this.computeNormal_(e),i=!0),t=this.sUnit,o=this.tUnit;var s=this.longAxis_(e);t[s]=0,t[(s+1)%3]=1,t[(s+2)%3]=0,o[s]=0,o[(s+1)%3]=0,o[(s+2)%3]=e[s]>0?1:-1;for(var l=r.next;l!==r;l=l.next)l.s=this.dot_(l.coords,t),l.t=this.dot_(l.coords,o);i&&this.checkOrientation_();for(var c=!0,u=r.next;u!==r;u=u.next)c?(this.bmin[0]=this.bmax[0]=u.s,this.bmin[1]=this.bmax[1]=u.t,c=!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(r,e){r.winding+=e.winding,r.Sym.winding+=e.Sym.winding},n.prototype.tessellateMonoRegion_=function(r,e){var t,o;if(t=e.anEdge,!(t.Lnext!==t&&t.Lnext.Lnext!==t))throw"Mono region invalid";for(;le.vertLeq(t.Dst,t.Org);t=t.Lprev);for(;le.vertLeq(t.Org,t.Dst);t=t.Lnext);o=t.Lprev;for(var i=void 0;t.Lnext!==o;)if(le.vertLeq(t.Dst,o.Org)){for(;o.Lnext!==t&&(le.edgeGoesLeft(o.Lnext)||le.edgeSign(o.Org,o.Dst,o.Lnext.Dst)<=0);)i=r.connect(o.Lnext,o),o=i.Sym;o=o.Lprev}else{for(;o.Lnext!==t&&(le.edgeGoesRight(t.Lprev)||le.edgeSign(t.Dst,t.Org,t.Lprev.Org)>=0);)i=r.connect(t,t.Lprev),t=i.Sym;t=t.Lnext}if(o.Lnext===t)throw"Mono region invalid";for(;o.Lnext.Lnext!==t;)i=r.connect(o.Lnext,o),o=i.Sym;return!0},n.prototype.tessellateInterior_=function(r){for(var e,t=r.fHead.next;t!==r.fHead;t=e)if(e=t.next,t.inside&&!this.tessellateMonoRegion_(r,t))return!1;return!0},n.prototype.discardExterior_=function(r){for(var e,t=r.fHead.next;t!==r.fHead;t=e)e=t.next,t.inside||r.zapFace(t)},n.prototype.setWindingNumber_=function(r,e,t){for(var o,i=r.eHead.next;i!==r.eHead;i=o)o=i.next,i.Rface.inside!==i.Lface.inside?i.winding=i.Lface.inside?e:-e:t?r.delete(i):i.winding=0},n.prototype.getNeighbourFace_=function(r){return!r.Rface||!r.Rface.inside?-1:r.Rface.n},n.prototype.outputPolymesh_=function(r,e,t,o){var i,s=0,l=0,c;t>3&&r.mergeConvexFaces(t);for(var u=r.vHead.next;u!==r.vHead;u=u.next)u.n=-1;for(var a=r.fHead.next;a!==r.fHead;a=a.next)if(a.n=-1,!!a.inside){i=a.anEdge,c=0;do{var u=i.Org;u.n===-1&&(u.n=l,l++),c++,i=i.Lnext}while(i!==a.anEdge);if(c>t)throw"Face vertex greater that support polygon";a.n=s,++s}this.elementCount=s,e===We.CONNECTED_POLYGONS&&(s*=2),this.elements=[],this.elements.length=s*t,this.vertexCount=l,this.vertices=[],this.vertices.length=l*o,this.vertexIndices=[],this.vertexIndices.length=l;for(var u=r.vHead.next;u!==r.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,a=r.fHead.next;a!==r.fHead;a=a.next)if(!!a.inside){i=a.anEdge,c=0;do{var u=i.Org;this.elements[p++]=u.n,c++,i=i.Lnext}while(i!==a.anEdge);for(var f=c;f<t;++f)this.elements[p++]=-1;if(e===We.CONNECTED_POLYGONS){i=a.anEdge;do this.elements[p++]=this.getNeighbourFace_(i),i=i.Lnext;while(i!==a.anEdge);for(var m=c;m<t;++m)this.elements[p++]=-1}}},n.prototype.outputContours_=function(r,e){var t,o,i=0,s=0;this.vertexCount=0,this.elementCount=0;for(var l=r.fHead.next;l!==r.fHead;l=l.next)if(!!l.inside){o=t=l.anEdge;do this.vertexCount++,t=t.Lnext;while(t!==o);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*e,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var c=0,u=0,a=0;i=0;for(var l=r.fHead.next;l!==r.fHead;l=l.next)if(!!l.inside){s=0,o=t=l.anEdge;do this.vertices[c++]=t.Org.coords[0],this.vertices[c++]=t.Org.coords[1],e>2&&(this.vertices[c++]=t.Org.coords[2]),this.vertexIndices[u++]=this.vertexIdCallback?this.vertexIdCallback(t):t.Org.idx,s++,t=t.Lnext;while(t!==o);this.elements[a++]=i,this.elements[a++]=s,i+=s}},n.prototype.addContour=function(r,e){this.mesh===null&&(this.mesh=new Jm),r<2&&(r=2),r>3&&(r=3);for(var t=null,o=0;o<e.length;o+=r)t===null?(t=this.mesh.makeEdge(),this.mesh.splice(t,t.Sym)):(this.mesh.splitEdge(t),t=t.Lnext),t.Org.coords[0]=e[o+0],t.Org.coords[1]=e[o+1],r>2?t.Org.coords[2]=e[o+2]:t.Org.coords[2]=0,t.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(t),t.winding=1,t.Sym.winding=-1},n.prototype.tesselate=function(r,e,t,o,i,s){if(r===void 0&&(r=we.ODD),e===void 0&&(e=We.POLYGONS),s===void 0&&(s=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,i&&(this.normal[0]=i[0],this.normal[1]=i[1],this.normal[2]=i[2]),this.windingRule=r,o<2&&(o=2),o>3&&(o=3),!this.mesh)return!1;this.projectPolygon_(),Yw.computeInterior(this,s);var l=this.mesh;return e===We.BOUNDARY_CONTOURS?this.setWindingNumber_(l,1,!0):this.tessellateInterior_(l),s&&l.check(),e===We.BOUNDARY_CONTOURS?this.outputContours_(l,o):this.outputPolymesh_(l,e,t,o),!0},n}();function mr(n){var r=n.windingRule,e=r===void 0?we.ODD:r,t=n.elementType,o=t===void 0?We.POLYGONS:t,i=n.polySize,s=i===void 0?3:i,l=n.vertexSize,c=l===void 0?2:l,u=n.normal,a=u===void 0?[0,0,1]:u,d=n.contours,p=d===void 0?[]:d,f=n.strict,m=f===void 0?!0:f,h=n.debug,y=h===void 0?!1:h;if(!p&&m)throw new Error("Contours can't be empty");if(!!p){var g=new Xw;n.edgeCreateCallback&&(g.edgeCreateCallback=n.edgeCreateCallback),n.vertexIdCallback&&(g.vertexIdCallback=n.vertexIdCallback);for(var v=0;v<p.length;v++)g.addContour(c||2,p[v]);return g.tesselate(e,o,s,c,a,m),{vertices:g.vertices,vertexIndices:g.vertexIndices,vertexCount:g.vertexCount,elements:g.elements,elementCount:g.elementCount,mesh:y?g.mesh:void 0}}}var QB=we.ODD,JB=we.NONZERO,eD=we.POSITIVE,tD=we.NEGATIVE,rD=we.ABS_GEQ_TWO,oD=We.POLYGONS,nD=We.CONNECTED_POLYGONS,iD=We.BOUNDARY_CONTOURS;var Qn=class extends ko.BufferGeometry{constructor(e,t=12,o={}){super();this.type="ShapeGeometry";this.windingRule=we.ODD;this.elementType=We.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=e,this._curveSegments=t,this._triangulationOptions=Object.assign({windingRule:we.ODD,elementType:We.POLYGONS,polySize:3,vertexSize:2,strict:!0},o);let i=this._shape.extractShapePointsToFlatArray([],this._curveSegments),s=this._shape.shapeHoles.map(m=>m.extractShapePointsToFlatArray([],this._curveSegments)),l,c=!0,u=!0,a,d;for(let m=0,h=i.length/2;m<h;m++){let y=m*2,g=i[y+0],v=i[y+1];if(a!==void 0&&g!==a&&(c=!1),d!==void 0&&v!==d&&(u=!1),a=g,d=v,!c&&!u)break}!c&&!u&&(l=mr({contours:[i,...s],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict}));let p=l?.vertexCount??1,f=l?.elementCount??1;if(this._positionAttribute=new ko.BufferAttribute(new Float32Array(p*3),3),this._normalAttribute=new ko.BufferAttribute(new Float32Array(p*3),3),this._uvAttribute=new ko.BufferAttribute(new Float32Array(p*2),2),this._indexAttribute=new ko.BufferAttribute(new Uint32Array(f*3),1),l){let m=1/0,h=-1/0,y=1/0,g=-1/0;for(let S=0,b=p;S<b;S++){let T=S*2,_=l.vertices[T+0],x=l.vertices[T+1];_<m&&(m=_),_>h&&(h=_),x<y&&(y=x),x>g&&(g=x)}let v=h-m,w=g-y;for(let S=0,b=p;S<b;S++){let T=S*2,_=l.vertices[T+0],x=l.vertices[T+1],C=(_-m)/v,P=(x-y)/w;this._positionAttribute.setXYZ(S,_,x,0),this._normalAttribute.setXYZ(S,0,0,1),this._uvAttribute.setXY(S,C,P)}for(let S=0,b=f;S<b;S++){let T=S*3,_=l.elements[T+0],x=l.elements[T+1],C=l.elements[T+2];this._indexAttribute.setX(T+0,_),this._indexAttribute.setX(T+1,x),this._indexAttribute.setX(T+2,C)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,(l?.elementCount??1)*3)}clone(){let e=new Qn(this._shape,this._curveSegments);return e.userData=Zr(this.userData),e}};var Ho=require("three");var dl=class{constructor(r=256,e=!1){this.capacity=r,this.size=0,this.debug=e,this.debug&&console.log(`allocating with cap ${r}`);let t=r*dl.eSize;this.buffer=new ArrayBuffer(t);let o=Float32Array.BYTES_PER_ELEMENT,i=0;this.positions=new Float32Array(this.buffer,i*o,3*r),i+=3*r,this.normals=new Float32Array(this.buffer,i*o,3*r),i+=3*r,this.uvs=new Float32Array(this.buffer,i*o,2*r)}realloc(r,e=!1){if(r<this.size)throw Error("cannot shrink buffer");if(r<=this.capacity&&!e)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${r}`);let t=r*dl.eSize,o=new ArrayBuffer(t),i=Float32Array.BYTES_PER_ELEMENT,s=0,l=new Float32Array(o,s*i,3*r);s+=3*r;let c=new Float32Array(o,s*i,3*r);s+=3*r;let u=new Float32Array(o,s*i,2*r);l.set(this.positions.slice(0,this.size*3)),c.set(this.normals.slice(0,this.size*3)),u.set(this.uvs.slice(0,this.size*2)),this.buffer=o,this.positions=l,this.normals=c,this.uvs=u,this.capacity=r}get(r=1){let e=this.size+r;if(e>this.capacity){let o=this.capacity;for(;e>o;)o*=2;this.realloc(o)}let t=this.size;return this.size=e,t}reserve(r){let e=this.size+r;e>this.capacity&&this.realloc(e)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},ls=dl;ls.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var Jc=(n,r)=>([e,t])=>(t<e&&(t+=r),(n>=e?n:n+r)<=t),Jn=class extends Ho.BufferGeometry{constructor(e,t,o=0,i=12,s=3,l=we.ODD){super();this.type="ShapeGeometry";this.vertexCache={};this._shape=e,this._depth=t,this._bevel=o,this._curveSegments=i,this._bevelSegmentsInput=s,o<=0?(this._bevelSize=0,this._bevelSegments=0):(this._bevelSize=Math.min(o,t/2-1e-12),this._bevelSegments=Math.floor(s));let c=this._shape.extractShapePointsToFlatArray([],i),u=this._shape.shapeHoles.map(_=>{let x=_.extractShapePointsToFlatArray([],i),C=[];for(let P=x.length-1;P>=1;P-=2){let I=x[P-1],A=x[P-0];C.push(I,A)}return C}),a=mr({windingRule:l,elementType:We.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[c]}),d=mr({windingRule:we.ODD,elementType:We.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...u]});if(!a)throw new Error("error generating geometry");let p=a.elementCount;if(d){a.elementCount+=d.elementCount;for(let _=0;_<d.elements.length;_++){let x=d.elements[_],C=_%2===0?a.vertexCount:0;a.elements.push(x+C)}for(let _=0;_<d.vertexIndices.length;_++){let x=d.vertexIndices[_],C=a.vertexCount;a.vertexIndices.push(x+C)}for(let _=0;_<d.vertices.length;_++){let x=d.vertices[_];a.vertices.push(x)}}let f=1/0,m=-1/0,h=1/0,y=-1/0;for(let _=0,x=a.vertexCount;_<x;_++){let C=_*2,P=a.vertices[C+0],I=a.vertices[C+1];P<f&&(f=P),P>m&&(m=P),I<h&&(h=I),I>y&&(y=I)}this._minX=f,this._minY=h,this._width=m-f,this._height=y-h,this._buffer=new ls(this._computeBufferEstimatedSize(a));let g=[],v=[];for(let _=a.elementCount-1;_>=0;_--){let x=_>=p,C=_*2,P=a.elements[C+0],I=a.elements[C+1],A=P+I,O={start:P,count:I,normals:[],continuous:[],concave:[]},V=P,z=A-1,$=P+1,te=this._shape.roundedCurves.length;do{let G=V-P,D=a.vertices[z*2+0],B=a.vertices[z*2+1],L=a.vertices[V*2+0],F=a.vertices[V*2+1],W=a.vertices[$*2+0],H=a.vertices[$*2+1],j=L-D,U=F-B,M=Math.sqrt(j*j+U*U);j/=M,U/=M;let oe=L-W,Y=F-H,re=Math.sqrt(oe*oe+Y*Y);oe/=re,Y/=re,O.normals[G*2+0]=-Y,O.normals[G*2+1]=oe,O.concave[G]=j*Y-U*oe>0;let X=a.vertexIndices[V];if(Array.isArray(X))O.continuous[G]=!1;else{let[ee,Z]=this._shape.getCurveIndexFromVertexId(X-1,!0);if(Z>0&&Z<1)O.continuous[G]=!0;else{let se=Z===1?ee+1:ee-1;se=(se+te)%te;let de=Z===1?0:1,ae=this._shape.roundedCurves[ee].getTangent(Z),fe=this._shape.roundedCurves[se].getTangent(de);O.continuous[G]=ae.dot(fe)>.95}}x&&(O.normals[G*2+0]*=-1,O.normals[G*2+1]*=-1),[z,V,$]=[V,$,$+1],$>=A&&($-=I)}while($!==P+1);let K=[];K.push({bevelI:0,angle:0,size:0,boundary:{vertices:a.vertices.slice(P*2,A*2),vertexCount:I,vertexIndices:new Array(I).fill(!0).map((G,D)=>[D,D]),elements:[0,I],elementCount:1,mesh:null},reverseMap:[],insetPoints:a.vertices.slice(P*2,A*2)});for(let G=1;G<=this._bevelSegments;G++){let D=G/this._bevelSegments*Math.PI/2,B=(1-Math.cos(D))*this._bevelSize,L=[],F=[],W=[],H=[],j=0;for(let M=0;M<I;M++){let oe=M*2,Y=(M-1+I)%I*2,re=a.vertices[O.start*2+oe+0],X=a.vertices[O.start*2+oe+1],ee=-O.normals[Y+0]*B,Z=-O.normals[Y+1]*B,se=-O.normals[oe+0]*B,de=-O.normals[oe+1]*B;if(O.concave[M]||!O.concave[M]&&x){let ae=Math.atan2(Z,ee),fe=Math.atan2(de,se);fe>ae&&(fe-=Math.PI*2);let Ue=fe-ae;if(O.continuous[M]||x){let ve=ae+Ue/2,qe=Math.cos(ve)*B,Ne=Math.sin(ve)*B;L[2*j+0]=re+qe*(x?-1:1),L[2*j+1]=X+Ne*(x?-1:1),H[j]=M,j++}else{let ve=Math.max(1,Math.floor(i/4*Math.abs(Ue)/Math.PI));for(let qe=0;qe<=ve;qe++){let Ne=ae+Ue*(qe/ve),Nt=Math.cos(Ne)*B,Et=Math.sin(Ne)*B;L[2*j+0]=re+Nt,L[2*j+1]=X+Et,H[j]=M,j++}}}else L[2*j+0]=re+ee,L[2*j+1]=X+Z,H[j]=M,F[M]=j,j++,L[2*j+0]=re,L[2*j+1]=X,H[j]=M,j++,L[2*j+0]=re+se,L[2*j+1]=X+de,H[j]=M,W[M]=j,j++}let U=mr({windingRule:we.POSITIVE,elementType:We.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[L],edgeCreateCallback:M=>{let Y=M.Org.idx,re=H[Y],X=H[(Y+1)%H.length];M.idx=[re,X],M.Sym.idx=[X,re]},vertexIdCallback:M=>{let oe=M.Lprev.idx;return[oe?oe[1]:0,M.idx[0]]}});if(!U)throw console.log("Error"),new Error(`error generating bevel geometry for ${G}'th loop`);if(!U.vertexCount)break;for(let M=0;M<U.vertexIndices.length;M++){let[oe,Y]=U.vertexIndices[M];if(oe===Y)continue;let re=Y;Y<oe&&(re+=I);for(let X=oe;X<re;X++){let ee=X%I,Z=(X+1)%I;if(!O.continuous[ee]||!O.continuous[Z]){U.vertexIndices[M]=[oe,ee],U.vertexIndices.splice(M+1,0,[Z,Y]),U.vertices.splice((M+1)*2,0,U.vertices[M*2],U.vertices[M*2+1]);break}}}K.push({bevelI:G,angle:D,size:B,boundary:U,reverseMap:H,insetPoints:L})}let q=(G,D,B)=>{let L=0,F=G.boundary.vertexIndices.length;for(;L<F&&B(G.boundary.vertexIndices[D]);)D=(D+1)%F,L++;return L},k=g.length;for(let G=1;G<K.length;G++){let D=K[G-1],B=K[G],L=D.boundary.vertexIndices.length,F=B.boundary.vertexIndices.length;if(!L||!F)break;let W=O.concave.length,H=0,j=Jc(H,I);for(;!D.boundary.vertexIndices.filter(j).length||!B.boundary.vertexIndices.filter(j).length;)H++,j=Jc(H,I);let U=D.boundary.vertexIndices.findIndex(j),M=B.boundary.vertexIndices.findIndex(j);do U=(U+1)%L;while(j(D.boundary.vertexIndices[U]));do M=(M+1)%F;while(j(B.boundary.vertexIndices[M]));H=(H+1)%I;let oe=H,Y=this._buildBevelVert(O,D,(U-1+L)%L),re=this._buildBevelVert(O,B,(M-1+F)%F),X=Y,ee=re,Z,se,de=!1;do{j=Jc(H,I);let ae=q(D,U,j),fe=q(B,M,j),Ue=de;if(de=!1,ae&&!fe){for(let ve=0;ve<ae;ve++)Z=this._buildBevelVert(O,D,(U+ve)%L,ve/(ae-1)),g.push(X.topN,Z.topP,ee.topN),g.push(Z.bottomP,X.bottomN,ee.bottomN),X=Z;de=!0}else if(!ae&&fe)for(let ve=0;ve<fe;ve++)se=this._buildBevelVert(O,B,(M+ve)%F,ve/(fe-1)),g.push(ee.topN,X.topP,se.topP),g.push(X.bottomP,ee.bottomN,se.bottomP),ee=se;else if(ae&&fe)if(Z=this._buildBevelVert(O,D,U,0),se=this._buildBevelVert(O,B,M,0),Ue?(g.push(X.topN,se.topP,ee.topN),g.push(X.topN,Z.topP,se.topP),g.push(se.bottomP,X.bottomN,ee.bottomN),g.push(se.bottomP,Z.bottomP,X.bottomN)):(g.push(ee.topN,X.topN,Z.topP),g.push(ee.topN,Z.topP,se.topP),g.push(Z.bottomP,X.bottomN,ee.bottomN),g.push(Z.bottomP,ee.bottomN,se.bottomP)),X=Z,ee=se,ae===fe)for(let ve=1;ve<ae;ve++)Z=this._buildBevelVert(O,D,(U+ve)%L,ve/(ae-1)),se=this._buildBevelVert(O,B,(M+ve)%F,ve/(fe-1)),g.push(X.topN,Z.topP,ee.topN),g.push(ee.topN,Z.topP,se.topP),g.push(Z.bottomP,X.bottomN,ee.bottomN),g.push(Z.bottomP,ee.bottomN,se.bottomP),X=Z,ee=se;else if(ae>fe){let ve=ae/fe,qe=0;for(let Ne=1;Ne<ae;Ne++)Z=this._buildBevelVert(O,D,(U+Ne)%L,Ne/(ae-1)),g.push(X.topN,Z.topP,ee.topN),g.push(Z.bottomP,X.bottomN,ee.bottomN),X=Z,Ne>(qe+1)*ve&&(qe++,se=this._buildBevelVert(O,B,(M+qe)%F,qe/(fe-1)),g.push(ee.topN,Z.topP,se.topP),g.push(Z.bottomP,ee.bottomN,se.bottomP),ee=se)}else{let ve=fe/ae,qe=0;for(let Ne=1;Ne<fe;Ne++)se=this._buildBevelVert(O,B,(M+Ne)%F,Ne/(fe-1)),g.push(ee.topN,Z.topP,se.topP),g.push(Z.bottomP,ee.bottomN,se.bottomP),ee=se,Ne>(qe+1)*ve&&(qe++,Z=this._buildBevelVert(O,D,(U+qe)%L,qe/(ae-1)),g.push(X.topN,Z.topP,ee.topN),g.push(Z.bottomP,X.bottomN,ee.bottomN),X=Z)}U=(U+ae)%L,M=(M+fe)%F,H=(H+1)%W}while(H!==oe)}if(this._buildWall(K,O,g),x){let G=[];for(let D=g.length-1;D>=k+2;D-=3){let B=g[D-2],L=g[D-1],F=g[D-0];G.push(F,L,B)}g.splice(k,g.length-k,...G)}if(x){let G=[];for(let D=K[K.length-1].boundary.vertices.length-1;D>=1;D-=2){let B=K[K.length-1].boundary.vertices[D-1],L=K[K.length-1].boundary.vertices[D-0];G.push(B,L)}v.push(G)}if(!x){let G=K[K.length-1],D=mr({windingRule:K.length>1?we.POSITIVE:we.ODD,elementType:We.POLYGONS,vertexSize:2,strict:!0,contours:[G.insetPoints,...v]});if(!D)throw new Error("Error generating geometry for surface");u.length===0&&Object.assign(this,{capStartIndex:g.length});for(let B=0;B<D.elementCount*3;B+=3){let L=this._buildSurfaceVert(D,D.elements[B+0]),F=this._buildSurfaceVert(D,D.elements[B+1]),W=this._buildSurfaceVert(D,D.elements[B+2]);g.push(L.top,F.top,W.top),g.push(W.bottom,F.bottom,L.bottom)}}this.vertexCache={}}this._buffer.shrink();let w=new Ho.BufferAttribute(Uint32Array.from(g),1),S=new Ho.BufferAttribute(this._buffer.positions,3),b=new Ho.BufferAttribute(this._buffer.normals,3),T=new Ho.BufferAttribute(this._buffer.uvs,2);S.needsUpdate=!0,b.needsUpdate=!0,T.needsUpdate=!0,w.needsUpdate=!0,this.setAttribute("position",S),this.setAttribute("normal",b),this.setAttribute("uv",T),this.setIndex(w)}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,t,o){let i=e[0];for(let s=0,l=i.boundary.vertexCount;s<l;s++){let c=this._buildBevelVert(t,i,s),u=this._buildBevelVert(t,i,(s+1)%l);o.push(u.topP,c.topN,c.bottomN),o.push(u.topP,c.bottomN,u.bottomP)}}_buildSurfaceVert(e,t){let o=t.toString();if(o in this.vertexCache)return this.vertexCache[o];let i=e.vertices[t*2+0],s=e.vertices[t*2+1],l=(i-this._minX)/this._width,c=(s-this._minY)/this._height,u=this._buffer.get(2),a=u*3,d=u*2,p={top:u+0,bottom:u+1};return this._buffer.positions[a+0]=i,this._buffer.positions[a+1]=s,this._buffer.positions[a+2]=this._depth,this._buffer.normals[a+0]=0,this._buffer.normals[a+1]=0,this._buffer.normals[a+2]=1,this._buffer.uvs[d+0]=l,this._buffer.uvs[d+1]=c,this._buffer.positions[a+3]=i,this._buffer.positions[a+4]=s,this._buffer.positions[a+5]=0,this._buffer.normals[a+3]=0,this._buffer.normals[a+4]=0,this._buffer.normals[a+5]=-1,this._buffer.uvs[d+2]=l,this._buffer.uvs[d+3]=c,this.vertexCache[o]=p,p}_buildBevelVert(e,t,o,i=1){let s=`${t.bevelI}:${o}`;if(s in this.vertexCache)return this.vertexCache[s];let[l,c]=t.boundary.vertexIndices[o],u,a,d,p;l!==c?(a=l,u=c,p=!1,d=e.continuous[a]&&e.continuous[u]):(u=l,a=(u-1+e.count)%e.count,p=e.concave[u]&&t.bevelI>0,d=e.continuous[u]||p);let f=Math.cos(t.angle),m=Math.sin(t.angle),h=o*2,y=u*2,g=a*2,v=t.boundary.vertices[h+0],w=t.boundary.vertices[h+1],S=(1-m)*this._bevelSize,b=(v-this._minX)/this._width,T=(w-this._minY)/this._height,_=e.normals[y+0],x=e.normals[y+1],C=e.normals[g+0],P=e.normals[g+1];if(p){let z=C-_,$=P-x;_=_+z*(1-i),x=x+$*(1-i);let te=Math.sqrt(_*_+x*x);_/=te,x/=te}let I=this._buffer.get(d?2:4),A=I*3,O=I*2,V={i:o,fi:u,topP:I+0,topN:I+0,bottomP:I+1,bottomN:I+1};return this._buffer.positions[A+0]=v,this._buffer.positions[A+1]=w,this._buffer.positions[A+2]=this._depth-S,this._buffer.normals[A+0]=_*f,this._buffer.normals[A+1]=x*f,this._buffer.normals[A+2]=m,this._buffer.uvs[O+0]=b,this._buffer.uvs[O+1]=T,this._buffer.positions[A+3]=v,this._buffer.positions[A+4]=w,this._buffer.positions[A+5]=S,this._buffer.normals[A+3]=_*f,this._buffer.normals[A+4]=x*f,this._buffer.normals[A+5]=-m,this._buffer.uvs[O+2]=T,this._buffer.uvs[O+3]=b,d||(I+=2,A+=6,O+=4,V.topP=I+0,V.bottomP=I+1,this._buffer.positions[A+0]=v,this._buffer.positions[A+1]=w,this._buffer.positions[A+2]=this._depth-S,this._buffer.normals[A+0]=C*f,this._buffer.normals[A+1]=P*f,this._buffer.normals[A+2]=m,this._buffer.uvs[O+0]=b,this._buffer.uvs[O+1]=T,this._buffer.positions[A+3]=v,this._buffer.positions[A+4]=w,this._buffer.positions[A+5]=S,this._buffer.normals[A+3]=C*f,this._buffer.normals[A+4]=P*f,this._buffer.normals[A+5]=-m,this._buffer.uvs[O+2]=T,this._buffer.uvs[O+3]=b),this.vertexCache[s]=V,V}clone(){let e=new Jn(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Zr(this.userData),e}};var ei=class extends Jn{constructor(e,t,o=0,i=12,s=3,l=we.ODD){super(e,t,o,i,s,l);this.type="ShapeGeometry"}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,t,o){let i=e[0];for(let s=0,l=i.boundary.vertexCount;s<l;s++){let c=this._buildBevelVert(t,i,s),u=this._buildBevelVert(t,i,(s+1)%l);o.push(u.topP,c.topN,c.bottomN),o.push(u.topP,c.bottomN,u.bottomP)}}clone(){let e=new ei(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Zr(this.userData),e}};var Vt=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:we.ODD},n.parameters),t=Math.abs(e.width),o=Math.abs(e.height??e.width),i=Math.abs(e.depth??0),s=n.shape??r?.shape,l=s?.roundness??e.roundness;s!==void 0&&(s instanceof Te?(s.width!==t||s.height!==o)&&s.applySize(t,o):s=new Te(t,o).fromJSON(s),n.parameters?.roundness!==void 0&&n.parameters?.roundness>0&&s.update());let c=s??new Te(t,o);return{parameters:Object.assign(e,{width:t,height:o,depth:i,roundness:l}),shape:c}}static build(n){let{depth:r,extrudeBevelSize:e,extrudeBevelSegments:t,subdivisions:o,roundness:i,windingRule:s}=n.parameters;n.shape.roundness=i;let l;return r<=0?l=new Qn(n.shape,o,{windingRule:s}):l=new ei(n.shape,r,e,o,t,s),Object.assign(l,{userData:{...n,type:"VectorGeometry"}})}};var ri=require("three"),nh=Math.PI*2,oi=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters);return{shape:n.shape&&n.shape instanceof Te?n.shape:new Te,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(n){let{width:r,height:e,spikes:t,angle:o,innerRadius:i,depth:s,extrudeBevelSize:l,extrudeBevelSegments:c}=n.parameters,u=n.shape,a=r*.5,d=e*.5,p=Kw(u,a,d,o*Math.PI/180,t,i);u.isClosed=!0,u.update();let f=Vt.create({shape:u,parameters:{subdivisions:p,depth:s,extrudeBevelSize:l,extrudeBevelSegments:c}});return Object.assign(f,{userData:{...n,type:"EllipseGeometry"}})}};function Kw(n,r,e,t,o,i){if(t>=nh)return o>30||o%4===0?(Qw(n,r,e,i),Math.round(o/4)):oh(n,t,o,r,e,i);t=Math.max(t,.001);let s={x:0,y:e},l=t+Math.PI*.5,c={x:Math.cos(l)*r,y:Math.sin(l)*e},u=Qm({px:s.x,py:s.y,cx:c.x,cy:c.y,rx:r,ry:e,largeArcFlag:t>Math.PI,sweepFlag:!0});return o>30||o%u.length===0?Zw(n,s.x,s.y,u,o,r,e,i):oh(n,t,o,r,e,i)}function Zw(n,r,e,t,o,i,s,l){let c=Math.round(o/t.length);n.addPoint(ti(r,e));for(let u=0,a=t.length;u<a;u++){let d=t[u],p=n.points[u],f=ti(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 l>0?ih(n,i,s,l):n.addPoint(ti(0,0)),c}function oh(n,r,e,t,o,i){let s=-r/e;for(let l=0;l<=e;l++){let c=s*l,u=Math.sin(c)*t,a=Math.cos(c)*o;n.addPoint(ti(u,a))}return r<nh?i>0?ih(n,t,o,i):n.addPoint(ti(0,0)):(n.removePoint(n.points[n.points.length-1]),i>0&&sh(n,t,o,i)),1}function Qw(n,r,e,t=0,o=0,i=0){let s=.5522847498,l=r*s,c=e*s;n.addPoint(ul(o-r,i,o-r,i-c,o-r,i+c)),n.addPoint(ul(o,i+e,o-l,i+e,o+l,i+e)),n.addPoint(ul(o+r,i,o+r,i+c,o+r,i-c)),n.addPoint(ul(o,i-e,o+l,i-e,o-l,i-e)),t>0&&sh(n,r,e,t)}function ti(n,r){return new fr(ri.MathUtils.generateUUID(),new ri.Vector2(n,r))}function ul(n,r,e,t,o,i){let s=ti(n,r);return s.controls[0].position.set(e,t),s.controls[1].position.set(o,i),s}function ih(n,r,e,t){ah(n,r,e,t).forEach(i=>n.addPoint(i))}function sh(n,r,e,t){let o=ah(n,r,e,t),i=new Te;o.forEach(s=>i.addPoint(s)),i.isClosed=!0,n.shapeHoles.push(i)}function ah(n,r,e,t){let o=t*r/100,i=o*(Math.abs(e)/Math.abs(r)),s=new ri.Vector2(o/r,i/e),l=n.points.map(c=>{let u=c.clone();return u.uuid=ri.MathUtils.generateUUID(),u}).reverse();return l.forEach(c=>{c.position.multiply(s);let u=c.controls[0].position.clone().multiply(s),a=c.controls[1].position.clone().multiply(s);c.controls[0].position.copy(a),c.controls[1].position.copy(u)}),l}var eo=require("three"),lh=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},n.parameters),t=Math.abs(e.width),o=Math.abs(e.height??t),i=Math.abs(e.depth??t),s=Math.abs(Math.min(t,i))/2;return{parameters:Object.assign(e,{width:t,height:o,depth:i,radius:s,segments:Math.round(e.segments),pathSegments:Math.round(e.pathSegments),cornerSegments:Math.round(e.cornerSegments)})}}static build(n){let{width:r,height:e,depth:t,radius:o,revolutions:i,segments:s,pathRadius:l,pathType:c,pathSegments:u,cornerRadius:a,cornerSegments:d}=n.parameters,p=new Wo(!1,r,e,t,o,i,s,l,c,u,a,d);return Object.assign(p,{userData:{...n,type:"HelixGeometry"}})}},Wo=class extends eo.BufferGeometry{constructor(r=!0,e=1,t=1,o=1,i=1,s=1,l=1,c=1,u=1,a=1,d=1,p=1,f=!1){super();let m=r&&s===1;m&&(p=0),d>100&&(d=100);let h=()=>new eo.Vector3,y=new eo.Vector3,g=h(),v=h(),w=h(),S,b,T,_,x,C,P,I,A=h(),O=h(),V=h(),z=h(),$=h(),te=h(),K=h(),q=h(),k=t-2*c+.001,G=k/s,D=Math.ceil(l*s),B=D+1,L=k/D,F=-k/2,W=a+1,H=2*Math.PI/a,j=Math.PI/2/p,U=.01,M=Math.min((1-d/100)*c,c-U),oe=c-M,Y=0,re=2,X=p*re+re,ee=W*X/re,Z=ee+W*B,se=W*(B+X),[de,ae,fe]=[3,3,2].map(ot=>Array(se*ot).fill(0)),Ue=[],ve=i-c;function qe(ot,Ht){let wr=Math.PI/2;C=Ht*L,I=2*Math.PI*(C%G)/G+wr,C+=F,P=Math.sin(I)*ve,x=Math.cos(I)*ve,r?ot.set(x,P,C):ot.set(x,C,P)}qe(y,-1e-10),qe(g,0),A.copy(y),qe(y,1);let Ne=y.distanceTo(g),Nt=m?0:oe+M,Et=Ne*D+2*Nt,sn=M,Kt=Et-Nt;for(let ot=0;ot<=D;ot++){qe(v,ot),q.subVectors(v,A).normalize(),A.copy(v),te.copy(v).setComponent(+r+1,0).normalize(),K.crossVectors(q,te).normalize();let Ht=ot===0,wr=ot===D,ug=Ht?3*Math.PI/2:j,pg=Ht?sn:Kt,fg=Ht?W:Z,mg=Ht?0:se-W,hg=q.clone().multiplyScalar(Ht?-oe:oe).add(v),yg=q.clone().multiplyScalar(Ht?-1:1).normalize();for(let Hr=0;Hr<W;Hr++){let Kd=Hr*H;if(O.addVectors(y.copy(te).multiplyScalar(c*Math.cos(Kd)),g.copy(K).multiplyScalar(c*Math.sin(Kd))),V.copy(O).normalize(),Ht||wr){m||(Y=mg+Hr,[0,1,2].forEach(Mt=>{de[Y*3+Mt]=hg.getComponent(Mt),ae[Y*3+Mt]=yg.getComponent(Mt)}),fe[Y*2]=+wr,fe[Y*2+1]=Hr/a),g.copy(V).multiplyScalar(M),w.addVectors(v,g);for(let Mt=0;Mt<p;Mt++){let nc=Mt*j+ug;z.addVectors(y.copy(q).multiplyScalar(oe*Math.sin(nc)),g.copy(V).multiplyScalar(oe*Math.cos(nc))),$.copy(z).normalize(),g.addVectors(w,z),z.normalize(),Y=fg+Mt*W+Hr,[0,1,2].forEach(Js=>{de[Y*3+Js]=g.getComponent(Js),ae[Y*3+Js]=$.getComponent(Js)});let gg=+Ht+Math.sin(nc);fe[Y*2]=(pg+oe*gg)/Et,fe[Y*2+1]=Hr/a}}g.addVectors(v,O),Y=ee+ot*W+Hr,[0,1,2].forEach(Mt=>{de[Y*3+Mt]=g.getComponent(Mt),ae[Y*3+Mt]=V.getComponent(Mt)}),fe[Y*2]=(Nt+ot*Ne)/Et,fe[Y*2+1]=Hr/a}}let an=B+2*p+re,rc=1,[oc,Gi]=[+m,an-1];f&&(Gi-=1);for(let ot=oc;ot<=Gi-1;ot++){let Ht=m&&ot===Gi-1;for(let wr=0;wr<W-1;wr++)S=ot*W+wr,b=S+1,T=(Ht?wr:S)+W,_=(Ht?wr+1:b)+W,ot===0?Ue.push(b,_,T):ot===an-2?Ue.push(S,b,T):Ue.push(S,b,T,b,_,T)}this.setIndex(Ue),this.setAttribute("position",new eo.Float32BufferAttribute(de,3)),this.setAttribute("normal",new eo.Float32BufferAttribute(ae,3)),this.setAttribute("uv",new eo.Float32BufferAttribute(fe,2))}};var ch=require("three");var dh=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,detail:0,corner:0,cornerSides:4},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:r,height:e,depth:t,detail:o,corner:i,cornerSides:s}=n.parameters,l=o===0&&i!==0?new cs(r*.5,i,s):new ch.IcosahedronGeometry(r*.5,o);return l.scale(1,e/r,t/r),Object.assign(l,{userData:{...n,type:"IcosahedronGeometry"}})}},cs=class extends So{constructor(r=1,e=.2,t=4){let o=(1+Math.sqrt(5))/2,i=[-1,o,0,1,o,0,-1,-o,0,1,-o,0,0,-1,o,0,1,o,0,-1,-o,0,1,-o,o,0,-1,o,0,1,-o,0,-1,-o,0,1],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],l="IcosahedronGeometry";super(i,s,l,r,e,t),this.type=l}static fromJSON(r){return new cs(r.radius,r.corner,r.cornerSides)}};var pl=require("three"),uh=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){(n.parameters?.points??[]).forEach(t=>{Array.isArray(t)&&(t.x=t[0],t.y=t[1])});let e=Object.assign({},r?.parameters??{width:100,segments:64,verticalSegments:64,points:[{x:0,y:-50,id:0},{x:50,y:-50,id:1},{x:50,y:50,id:2},{x:0,y:50,id:3}]},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{points:r,segments:e,verticalSegments:t}=n.parameters,o=new pl.Shape;o.moveTo(r[0].x,r[0].y),o.bezierCurveTo(r[1].x,r[1].y,r[2].x,r[2].y,r[3].x,r[3].y);let i=new pl.LatheGeometry(o.extractPoints(t).shape,e);return i.rotateZ(Math.PI),Object.assign(i,{userData:{...n,type:"LatheGeometry"}})}};var Mr=require("three");var to=require("three");var ie=require("three"),Er=new ie.Matrix4,ed=new ie.Object3D,fl=new ie.Vector3,_o=class extends ie.EventDispatcher{constructor(){super(),this.uuid=ie.MathUtils.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}applyMatrix4(r){let e=new ie.Matrix3().getNormalMatrix(r);for(let t=0,o=this.vertices.length;t<o;t++)this.vertices[t].applyMatrix4(r);for(let t=0,o=this.faces.length;t<o;t++){let i=this.faces[t];i.normal.applyMatrix3(e).normalize();for(let s=0,l=i.vertexNormals.length;s<l;s++)i.vertexNormals[s].applyMatrix3(e).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this}rotateX(r){return Er.makeRotationX(r),this.applyMatrix4(Er),this}rotateY(r){return Er.makeRotationY(r),this.applyMatrix4(Er),this}rotateZ(r){return Er.makeRotationZ(r),this.applyMatrix4(Er),this}translate(r,e,t){return Er.makeTranslation(r,e,t),this.applyMatrix4(Er),this}scale(r,e,t){return Er.makeScale(r,e,t),this.applyMatrix4(Er),this}lookAt(r){return ed.lookAt(r),ed.updateMatrix(),this.applyMatrix4(ed.matrix),this}fromBufferGeometry(r){let e=this,t=r.index!==null?r.index:void 0,o=r.attributes;if(o.position===void 0)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;let i=o.position,s=o.normal,l=o.color,c=o.uv,u=o.uv2;u!==void 0&&(this.faceVertexUvs[1]=[]);for(let p=0;p<i.count;p++)e.vertices.push(new ie.Vector3().fromBufferAttribute(i,p)),l!==void 0&&e.colors.push(new ie.Color().fromBufferAttribute(l,p));function a(p,f,m,h){let y=l===void 0?[]:[e.colors[p].clone(),e.colors[f].clone(),e.colors[m].clone()],g=s===void 0?[]:[new ie.Vector3().fromBufferAttribute(s,p),new ie.Vector3().fromBufferAttribute(s,f),new ie.Vector3().fromBufferAttribute(s,m)],v=new ni(p,f,m,g,y,h);e.faces.push(v),c!==void 0&&e.faceVertexUvs[0].push([new ie.Vector2().fromBufferAttribute(c,p),new ie.Vector2().fromBufferAttribute(c,f),new ie.Vector2().fromBufferAttribute(c,m)]),u!==void 0&&e.faceVertexUvs[1].push([new ie.Vector2().fromBufferAttribute(u,p),new ie.Vector2().fromBufferAttribute(u,f),new ie.Vector2().fromBufferAttribute(u,m)])}let d=r.groups;if(d.length>0)for(let p=0;p<d.length;p++){let f=d[p],m=f.start,h=f.count;for(let y=m,g=m+h;y<g;y+=3)t!==void 0?a(t.getX(y),t.getX(y+1),t.getX(y+2),f.materialIndex):a(y,y+1,y+2,f.materialIndex)}else if(t!==void 0)for(let p=0;p<t.count;p+=3)a(t.getX(p),t.getX(p+1),t.getX(p+2));else for(let p=0;p<i.count;p+=3)a(p,p+1,p+2);return this.computeFaceNormals(),r.boundingBox!==null&&(this.boundingBox=r.boundingBox.clone()),r.boundingSphere!==null&&(this.boundingSphere=r.boundingSphere.clone()),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(fl).negate(),this.translate(fl.x,fl.y,fl.z),this}normalize(){this.computeBoundingSphere();let r=this.boundingSphere.center,e=this.boundingSphere.radius,t=e===0?1:1/e,o=new ie.Matrix4;return o.set(t,0,0,-t*r.x,0,t,0,-t*r.y,0,0,t,-t*r.z,0,0,0,1),this.applyMatrix4(o),this}computeFaceNormals(){let r=new ie.Vector3,e=new ie.Vector3;for(let t=0,o=this.faces.length;t<o;t++){let i=this.faces[t],s=this.vertices[i.a],l=this.vertices[i.b],c=this.vertices[i.c];r.subVectors(c,l),e.subVectors(s,l),r.cross(e),r.normalize(),i.normal.copy(r)}}computeVertexNormals(r=!0){let e=new Array(this.vertices.length);for(let t=0,o=this.vertices.length;t<o;t++)e[t]=new ie.Vector3;if(r){let t=new ie.Vector3,o=new ie.Vector3;for(let i=0,s=this.faces.length;i<s;i++){let l=this.faces[i],c=this.vertices[l.a],u=this.vertices[l.b],a=this.vertices[l.c];t.subVectors(a,u),o.subVectors(c,u),t.cross(o),e[l.a].add(t),e[l.b].add(t),e[l.c].add(t)}}else{this.computeFaceNormals();for(let t=0,o=this.faces.length;t<o;t++){let i=this.faces[t];e[i.a].add(i.normal),e[i.b].add(i.normal),e[i.c].add(i.normal)}}for(let t=0,o=this.vertices.length;t<o;t++)e[t].normalize();for(let t=0,o=this.faces.length;t<o;t++){let i=this.faces[t],s=i.vertexNormals;s.length===3?(s[0].copy(e[i.a]),s[1].copy(e[i.b]),s[2].copy(e[i.c])):(s[0]=e[i.a].clone(),s[1]=e[i.b].clone(),s[2]=e[i.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeFlatVertexNormals(){this.computeFaceNormals();for(let r=0,e=this.faces.length;r<e;r++){let t=this.faces[r],o=t.vertexNormals;o.length===3?(o[0].copy(t.normal),o[1].copy(t.normal),o[2].copy(t.normal)):(o[0]=t.normal.clone(),o[1]=t.normal.clone(),o[2]=t.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let e=0,t=this.faces.length;e<t;e++){let o=this.faces[e];o.__originalFaceNormal?o.__originalFaceNormal.copy(o.normal):o.__originalFaceNormal=o.normal.clone(),o.__originalVertexNormals||(o.__originalVertexNormals=[]);for(let i=0,s=o.vertexNormals.length;i<s;i++)o.__originalVertexNormals[i]?o.__originalVertexNormals[i].copy(o.vertexNormals[i]):o.__originalVertexNormals[i]=o.vertexNormals[i].clone()}let r=new _o;r.faces=this.faces;for(let e=0,t=this.morphTargets.length;e<t;e++){if(!this.morphNormals[e]){this.morphNormals[e]={},this.morphNormals[e].faceNormals=[],this.morphNormals[e].vertexNormals=[];let i=this.morphNormals[e].faceNormals,s=this.morphNormals[e].vertexNormals;for(let l=0,c=this.faces.length;l<c;l++){let u=new ie.Vector3,a={a:new ie.Vector3,b:new ie.Vector3,c:new ie.Vector3};i.push(u),s.push(a)}}let o=this.morphNormals[e];r.vertices=this.morphTargets[e].vertices,r.computeFaceNormals(),r.computeVertexNormals();for(let i=0,s=this.faces.length;i<s;i++){let l=this.faces[i],c=o.faceNormals[i],u=o.vertexNormals[i];c.copy(l.normal),u.a.copy(l.vertexNormals[0]),u.b.copy(l.vertexNormals[1]),u.c.copy(l.vertexNormals[2])}}for(let e=0,t=this.faces.length;e<t;e++){let o=this.faces[e];o.normal=o.__originalFaceNormal,o.vertexNormals=o.__originalVertexNormals}}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ie.Box3),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new ie.Sphere),this.boundingSphere.setFromPoints(this.vertices)}merge(r,e,t=0){if(!(r&&r.isGeometry)){console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",r);return}let o,i=this.vertices.length,s=this.vertices,l=r.vertices,c=this.faces,u=r.faces,a=this.colors,d=r.colors;e!==void 0&&(o=new ie.Matrix3().getNormalMatrix(e));for(let p=0,f=l.length;p<f;p++){let h=l[p].clone();e!==void 0&&h.applyMatrix4(e),s.push(h)}for(let p=0,f=d.length;p<f;p++)a.push(d[p].clone());for(let p=0,f=u.length;p<f;p++){let m=u[p],h,y,g=m.vertexNormals,v=m.vertexColors,w=new ni(m.a+i,m.b+i,m.c+i);w.normal.copy(m.normal),o!==void 0&&w.normal.applyMatrix3(o).normalize();for(let S=0,b=g.length;S<b;S++)h=g[S].clone(),o!==void 0&&h.applyMatrix3(o).normalize(),w.vertexNormals.push(h);w.color.copy(m.color);for(let S=0,b=v.length;S<b;S++)y=v[S],w.vertexColors.push(y.clone());w.materialIndex=m.materialIndex+t,c.push(w)}for(let p=0,f=r.faceVertexUvs.length;p<f;p++){let m=r.faceVertexUvs[p];this.faceVertexUvs[p]===void 0&&(this.faceVertexUvs[p]=[]);for(let h=0,y=m.length;h<y;h++){let g=m[h],v=[];for(let w=0,S=g.length;w<S;w++)v.push(g[w].clone());this.faceVertexUvs[p].push(v)}}}mergeMesh(r){if(!(r&&r.isMesh)){console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",r);return}r.matrixAutoUpdate&&r.updateMatrix(),this.merge(r.geometry,r.matrix)}mergeVertices(r=4){let e={},t=[],o=[],i=Math.pow(10,r);for(let c=0,u=this.vertices.length;c<u;c++){let a=this.vertices[c],d=Math.round(a.x*i)+"_"+Math.round(a.y*i)+"_"+Math.round(a.z*i);e[d]===void 0?(e[d]=c,t.push(this.vertices[c]),o[c]=t.length-1):o[c]=o[e[d]]}let s=[];for(let c=0,u=this.faces.length;c<u;c++){let a=this.faces[c];a.a=o[a.a],a.b=o[a.b],a.c=o[a.c];let d=[a.a,a.b,a.c];for(let p=0;p<3;p++)if(d[p]===d[(p+1)%3]){s.push(c);break}}for(let c=s.length-1;c>=0;c--){let u=s[c];this.faces.splice(u,1);for(let a=0,d=this.faceVertexUvs.length;a<d;a++)this.faceVertexUvs[a].splice(u,1)}let l=this.vertices.length-t.length;return this.vertices=t,l}setFromPoints(r){this.vertices=[];for(let e=0,t=r.length;e<t;e++){let o=r[e];this.vertices.push(new ie.Vector3(o.x,o.y,o.z||0))}return this}sortFacesByMaterialIndex(){let r=this.faces,e=r.length;for(let c=0;c<e;c++)r[c]._id=c;function t(c,u){return c.materialIndex-u.materialIndex}r.sort(t);let o=this.faceVertexUvs[0],i=this.faceVertexUvs[1],s,l;o&&o.length===e&&(s=[]),i&&i.length===e&&(l=[]);for(let c=0;c<e;c++){let u=r[c]._id;s&&s.push(o[u]),l&&l.push(i[u])}s&&(this.faceVertexUvs[0]=s),l&&(this.faceVertexUvs[1]=l)}toJSON(){let r={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.parameters!==void 0){let m=this.parameters;for(let h in m)m[h]!==void 0&&(r[h]=m[h]);return r}let e=[];for(let m=0;m<this.vertices.length;m++){let h=this.vertices[m];e.push(h.x,h.y,h.z)}let t=[],o=[],i={},s=[],l={},c=[],u={};for(let m=0;m<this.faces.length;m++){let h=this.faces[m],y=!0,g=!1,v=this.faceVertexUvs[0][m]!==void 0,w=h.normal.length()>0,S=h.vertexNormals.length>0,b=h.color.r!==1||h.color.g!==1||h.color.b!==1,T=h.vertexColors.length>0,_=0;if(_=a(_,0,0),_=a(_,1,y),_=a(_,2,g),_=a(_,3,v),_=a(_,4,w),_=a(_,5,S),_=a(_,6,b),_=a(_,7,T),t.push(_),t.push(h.a,h.b,h.c),t.push(h.materialIndex),v){let x=this.faceVertexUvs[0][m];t.push(f(x[0]),f(x[1]),f(x[2]))}if(w&&t.push(d(h.normal)),S){let x=h.vertexNormals;t.push(d(x[0]),d(x[1]),d(x[2]))}if(b&&t.push(p(h.color)),T){let x=h.vertexColors;t.push(p(x[0]),p(x[1]),p(x[2]))}}function a(m,h,y){return y?m|1<<h:m&~(1<<h)}function d(m){let h=m.x.toString()+m.y.toString()+m.z.toString();return i[h]!==void 0||(i[h]=o.length/3,o.push(m.x,m.y,m.z)),i[h]}function p(m){let h=m.r.toString()+m.g.toString()+m.b.toString();return l[h]!==void 0||(l[h]=s.length,s.push(m.getHex())),l[h]}function f(m){let h=m.x.toString()+m.y.toString();return u[h]!==void 0||(u[h]=c.length/2,c.push(m.x,m.y)),u[h]}return r.data={},r.data.vertices=e,r.data.normals=o,s.length>0&&(r.data.colors=s),c.length>0&&(r.data.uvs=[c]),r.data.faces=t,r}clone(){return new _o().copy(this)}copy(r){this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=r.name;let e=r.vertices;for(let p=0,f=e.length;p<f;p++)this.vertices.push(e[p].clone());let t=r.colors;for(let p=0,f=t.length;p<f;p++)this.colors.push(t[p].clone());let o=r.faces;for(let p=0,f=o.length;p<f;p++)this.faces.push(o[p].clone());for(let p=0,f=r.faceVertexUvs.length;p<f;p++){let m=r.faceVertexUvs[p];this.faceVertexUvs[p]===void 0&&(this.faceVertexUvs[p]=[]);for(let h=0,y=m.length;h<y;h++){let g=m[h],v=[];for(let w=0,S=g.length;w<S;w++){let b=g[w];v.push(b.clone())}this.faceVertexUvs[p].push(v)}}let i=r.morphTargets;for(let p=0,f=i.length;p<f;p++){let m={};if(m.name=i[p].name,i[p].vertices!==void 0){m.vertices=[];for(let h=0,y=i[p].vertices.length;h<y;h++)m.vertices.push(i[p].vertices[h].clone())}if(i[p].normals!==void 0){m.normals=[];for(let h=0,y=i[p].normals.length;h<y;h++)m.normals.push(i[p].normals[h].clone())}this.morphTargets.push(m)}let s=r.morphNormals;for(let p=0,f=s.length;p<f;p++){let m={};if(s[p].vertexNormals!==void 0){m.vertexNormals=[];for(let h=0,y=s[p].vertexNormals.length;h<y;h++){let g=s[p].vertexNormals[h],v={};v.a=g.a.clone(),v.b=g.b.clone(),v.c=g.c.clone(),m.vertexNormals.push(v)}}if(s[p].faceNormals!==void 0){m.faceNormals=[];for(let h=0,y=s[p].faceNormals.length;h<y;h++)m.faceNormals.push(s[p].faceNormals[h].clone())}this.morphNormals.push(m)}let l=r.skinWeights;for(let p=0,f=l.length;p<f;p++)this.skinWeights.push(l[p].clone());let c=r.skinIndices;for(let p=0,f=c.length;p<f;p++)this.skinIndices.push(c[p].clone());let u=r.lineDistances;for(let p=0,f=u.length;p<f;p++)this.lineDistances.push(u[p]);let a=r.boundingBox;a!==null&&(this.boundingBox=a.clone());let d=r.boundingSphere;return d!==null&&(this.boundingSphere=d.clone()),this.elementsNeedUpdate=r.elementsNeedUpdate,this.verticesNeedUpdate=r.verticesNeedUpdate,this.uvsNeedUpdate=r.uvsNeedUpdate,this.normalsNeedUpdate=r.normalsNeedUpdate,this.colorsNeedUpdate=r.colorsNeedUpdate,this.lineDistancesNeedUpdate=r.lineDistancesNeedUpdate,this.groupsNeedUpdate=r.groupsNeedUpdate,this}toBufferGeometry(){let r=new td().fromGeometry(this),e=new ie.BufferGeometry,t=new Float32Array(r.vertices.length*3);if(e.setAttribute("position",new ie.BufferAttribute(t,3).copyVector3sArray(r.vertices)),r.normals.length>0){let o=new Float32Array(r.normals.length*3);e.setAttribute("normal",new ie.BufferAttribute(o,3).copyVector3sArray(r.normals))}if(r.colors.length>0){let o=new Float32Array(r.colors.length*3);e.setAttribute("color",new ie.BufferAttribute(o,3).copyColorsArray(r.colors))}if(r.uvs.length>0){let o=new Float32Array(r.uvs.length*2);e.setAttribute("uv",new ie.BufferAttribute(o,2).copyVector2sArray(r.uvs))}if(r.uvs2.length>0){let o=new Float32Array(r.uvs2.length*2);e.setAttribute("uv2",new ie.BufferAttribute(o,2).copyVector2sArray(r.uvs2))}e.groups=r.groups;for(let o in r.morphTargets){let i=[],s=r.morphTargets[o];for(let l=0,c=s.length;l<c;l++){let u=s[l],a=new ie.Float32BufferAttribute(u.data.length*3,3);a.name=u.name,i.push(a.copyVector3sArray(u.data))}e.morphAttributes[o]=i}if(r.skinIndices.length>0){let o=new ie.Float32BufferAttribute(r.skinIndices.length*4,4);e.setAttribute("skinIndex",o.copyVector4sArray(r.skinIndices))}if(r.skinWeights.length>0){let o=new ie.Float32BufferAttribute(r.skinWeights.length*4,4);e.setAttribute("skinWeight",o.copyVector4sArray(r.skinWeights))}return r.boundingSphere!==null&&(e.boundingSphere=r.boundingSphere.clone()),r.boundingBox!==null&&(e.boundingBox=r.boundingBox.clone()),e}computeTangents(){console.error("THREE.Geometry: .computeTangents() has been removed.")}computeLineDistances(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")}applyMatrix(r){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(r)}dispose(){this.dispatchEvent({type:"dispose"})}static createBufferGeometryFromObject(r){let e=new ie.BufferGeometry,t=r.geometry;if(r.isPoints||r.isLine){let o=new ie.Float32BufferAttribute(t.vertices.length*3,3),i=new ie.Float32BufferAttribute(t.colors.length*3,3);if(e.setAttribute("position",o.copyVector3sArray(t.vertices)),e.setAttribute("color",i.copyColorsArray(t.colors)),t.lineDistances&&t.lineDistances.length===t.vertices.length){let s=new ie.Float32BufferAttribute(t.lineDistances.length,1);e.setAttribute("lineDistance",s.copyArray(t.lineDistances))}t.boundingSphere!==null&&(e.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(e.boundingBox=t.boundingBox.clone())}else r.isMesh&&(e=t.toBufferGeometry());return e}};_o.prototype.isGeometry=!0;var td=class{constructor(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}computeGroups(r){let e=[],t,o,i,s=r.faces;for(o=0;o<s.length;o++){let l=s[o];l.materialIndex!==i&&(i=l.materialIndex,t!==void 0&&(t.count=o*3-t.start,e.push(t)),t={start:o*3,materialIndex:i})}t!==void 0&&(t.count=o*3-t.start,e.push(t)),this.groups=e}fromGeometry(r){let e=r.faces,t=r.vertices,o=r.faceVertexUvs,i=o[0]&&o[0].length>0,s=o[1]&&o[1].length>0,l=r.morphTargets,c=l.length,u;if(c>0){u=[];for(let g=0;g<c;g++)u[g]={name:l[g].name,data:[]};this.morphTargets.position=u}let a=r.morphNormals,d=a.length,p;if(d>0){p=[];for(let g=0;g<d;g++)p[g]={name:a[g].name,data:[]};this.morphTargets.normal=p}let f=r.skinIndices,m=r.skinWeights,h=f.length===t.length,y=m.length===t.length;t.length>0&&e.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let g=0;g<e.length;g++){let v=e[g];this.vertices.push(t[v.a],t[v.b],t[v.c]);let w=v.vertexNormals;if(w.length===3)this.normals.push(w[0],w[1],w[2]);else{let b=v.normal;this.normals.push(b,b,b)}let S=v.vertexColors;if(S.length===3)this.colors.push(S[0],S[1],S[2]);else{let b=v.color;this.colors.push(b,b,b)}if(i===!0){let b=o[0][g];b!==void 0?this.uvs.push(b[0],b[1],b[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",g),this.uvs.push(new ie.Vector2,new ie.Vector2,new ie.Vector2))}if(s===!0){let b=o[1][g];b!==void 0?this.uvs2.push(b[0],b[1],b[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",g),this.uvs2.push(new ie.Vector2,new ie.Vector2,new ie.Vector2))}for(let b=0;b<c;b++){let T=l[b].vertices;u[b].data.push(T[v.a],T[v.b],T[v.c])}for(let b=0;b<d;b++){let T=a[b].vertexNormals[g];p[b].data.push(T.a,T.b,T.c)}h&&this.skinIndices.push(f[v.a],f[v.b],f[v.c]),y&&this.skinWeights.push(m[v.a],m[v.b],m[v.c])}return this.computeGroups(r),this.verticesNeedUpdate=r.verticesNeedUpdate,this.normalsNeedUpdate=r.normalsNeedUpdate,this.colorsNeedUpdate=r.colorsNeedUpdate,this.uvsNeedUpdate=r.uvsNeedUpdate,this.groupsNeedUpdate=r.groupsNeedUpdate,r.boundingSphere!==null&&(this.boundingSphere=r.boundingSphere.clone()),r.boundingBox!==null&&(this.boundingBox=r.boundingBox.clone()),this}},ni=class{constructor(r,e,t,o,i,s=0){this.a=r,this.b=e,this.c=t,this.normal=o&&o.isVector3?o:new ie.Vector3,this.vertexNormals=Array.isArray(o)?o:[],this.color=i&&i.isColor?i:new ie.Color,this.vertexColors=Array.isArray(i)?i:[],this.materialIndex=s}clone(){return new this.constructor().copy(this)}copy(r){this.a=r.a,this.b=r.b,this.c=r.c,this.normal.copy(r.normal),this.color.copy(r.color),this.materialIndex=r.materialIndex;for(let e=0,t=r.vertexNormals.length;e<t;e++)this.vertexNormals[e]=r.vertexNormals[e].clone();for(let e=0,t=r.vertexColors.length;e<t;e++)this.vertexColors[e]=r.vertexColors[e].clone();return this}};var Jw=["a","b","c"];function e_(n,r){switch(r){case"c":return n.c;case"b":return n.b;case"a":default:return n.a}}function rd(n,r,e){let t=Math.min(n,r),o=Math.max(n,r),i=t+"_"+o;return e.get(i)}function od(n,r,e,t,o,i){let s=Math.min(n,r),l=Math.max(n,r),c=s+"_"+l,u;if(t.has(c))u=t.get(c);else{let a=e[s],d=e[l];u={a,b:d,newEdge:null,faces:[]},t.set(c,u)}u.faces.push(o),i[n].edges.push(u),i[r].edges.push(u)}function t_(n,r,e,t){let o,i,s;for(o=0,i=n.length;o<i;o++)e[o]={edges:[]};for(o=0,i=r.length;o<i;o++)s=r[o],od(s.a,s.b,n,t,s,e),od(s.b,s.c,n,t,s,e),od(s.c,s.a,n,t,s,e)}function ml(n,r,e,t,o){n.push(new ni(r,e,t,void 0,void 0,o))}function ii(n,r){return Math.abs(r-n)/2+Math.min(n,r)}function hl(n,r,e,t){n.push([r.clone(),e.clone(),t.clone()])}var yl=class{constructor(r=1){this.subdivisions=r}modify(r){r instanceof to.BufferGeometry?r=new _o().fromBufferGeometry(r):r=r.clone(),r.mergeVertices();let e=this.subdivisions;for(;e-- >0;)this._smooth(r);return r.computeFaceNormals(),r.computeVertexNormals(),r}_smooth(r){let e=new to.Vector3,t,o,i,s,l,c=r.vertices,u=r.faces,a=r.faceVertexUvs[0],d=a!==void 0&&a.length>0,p=[],f=new Map;t_(c,u,p,f);let m=[],h,y,g,v,w,S,b;for(let j of Array.from(f.keys())){for(y=f.get(j),g=new to.Vector3,w=3/8,S=1/8,b=y.faces.length,b!=2&&(w=.5,S=0,b!=1),g.addVectors(y.a,y.b).multiplyScalar(w),e.set(0,0,0),s=0;s<b;s++){for(v=y.faces[s],l=0;l<3&&(h=c[e_(v,Jw[l])],!(h!==y.a&&h!==y.b));l++);h&&e.add(h)}e.multiplyScalar(S),g.add(e),y.newEdge=m.length,m.push(g)}let T,_,x,C,P,I,A,O=[];for(o=0,i=c.length;o<i;o++){for(I=c[o],P=p[o].edges,t=P.length,t==3?T=3/16:t>3&&(T=3/(8*t)),_=1-t*Number(T),x=T,t<=2&&(t==2?(_=3/4,x=1/8):t==1||t==0),A=I.clone().multiplyScalar(_),e.set(0,0,0),s=0;s<t;s++)C=P[s],h=C.a!==I?C.a:C.b,e.add(h);e.multiplyScalar(Number(x)),A.add(e),O.push(A)}let V=O.concat(m),z=O.length,$,te,K,q=[],k=[],G,D,B,L,F=new to.Vector2,W=new to.Vector2,H=new to.Vector2;for(o=0,i=u.length;o<i;o++)v=u[o],$=Number(rd(v.a,v.b,f).newEdge)+z,te=Number(rd(v.b,v.c,f).newEdge)+z,K=Number(rd(v.c,v.a,f).newEdge)+z,ml(q,$,te,K,v.materialIndex),ml(q,v.a,$,K,v.materialIndex),ml(q,v.b,te,$,v.materialIndex),ml(q,v.c,K,te,v.materialIndex),d&&(G=a[o],D=G[0],B=G[1],L=G[2],F.set(ii(D.x,B.x),ii(D.y,B.y)),W.set(ii(B.x,L.x),ii(B.y,L.y)),H.set(ii(D.x,L.x),ii(D.y,L.y)),hl(k,F,W,H),hl(k,D,F,H),hl(k,B,W,F),hl(k,L,H,W));r.vertices=V,r.faces=q,d&&(r.faceVertexUvs[0]=k)}};var nt=new Mr.Vector3,ph=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=n.geometry??r?.geometry??new Mr.BufferGeometry().copy(new Mr.BoxGeometry(100,100,100)),t;r===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(nt),t={width:nt.x,height:nt.y,depth:nt.z,subdivisions:0}):t=r.parameters;let o={...t,...n.parameters};return{parameters:{width:Math.abs(o.width),height:Math.abs(o.height),depth:Math.abs(o.depth),subdivisions:Math.abs(o.subdivisions)},geometry:e}}static build(n){let{width:r,height:e,depth:t,subdivisions:o}=n.parameters,i=n.geometry??new Mr.BufferGeometry().copy(new Mr.BoxGeometry(100,100,100)),s=i.userData.parameters;s===void 0?(i.computeBoundingBox(),i.boundingBox.getSize(nt)):nt.set(s.width,s.height,s.depth),(r!==nt.x||e!==nt.y||t!==nt.z)&&i.scale(nt.x===0?1:r/nt.x,nt.y===0?1:e/nt.y,nt.z===0?1:t/nt.z);let l=i.originalGeometry;return o>0?(l===void 0||s?.subdivisions!==o)&&(l===void 0&&(l=i),i=new yl(o).modify(l).toBufferGeometry()):(l!==void 0&&(i=l),l=void 0,i.getAttribute("normal")===void 0&&i.computeVertexNormals()),l!==void 0&&Object.assign(i,{originalGeometry:l}),delete n.geometry,Object.assign(i,{userData:{...n,type:"NonParametricGeometry"}})}static loadFromUrl(n,r,e){new Mr.BufferGeometryLoader(e).load(n,o=>{let i=this.normalizeInputs({geometry:o});o.boundingBox.getSize(nt);let s=100/nt.x;Object.assign(i.parameters,{width:100,height:nt.y*s,depth:nt.z*s}),r(this.build(i))})}};var gl=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},n.parameters);return{shape:n.shape&&n.shape instanceof Te?n.shape:new Te,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(n){let{width:r,height:e,spikes:t,cornerRadius:o,depth:i,extrudeBevelSize:s,extrudeBevelSegments:l}=n.parameters,c=n.shape,u=r*.5,a=e*.5,d=0,p=0,f=2*Math.PI/t;for(let h=0;h<t;h++){let y=f*h,g=d+Math.sin(y)*u,v=p+Math.cos(y)*a;c.addPoint(c.createPoint(g,v))}c.isClosed=!0;for(let h=0,y=c.points.length;h<y;h++)c.points[h].roundness=o;c.roundness=o,c.update();let m=Vt.create({shape:c,parameters:{roundness:o,depth:i,extrudeBevelSize:s,extrudeBevelSegments:l}});return Object.assign(m,{userData:{...n,type:"PolygonGeometry"}})}};var Se=require("three"),fh=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:r,height:e,depth:t,radialSegments:o,heightSegments:i,openEnded:s,cornerRadius:l,cornerSegments:c}=n.parameters,u=new id(r*.5,e,o,i,s,l,c);return u.scale(1,1,t/r),Object.assign(u,{userData:{...n,type:"PyramidGeometry"}})}};function ds(n,r,e){e.x=n.x*r.x,e.y=n.y,e.z=n.x*r.y}function nd(n,r,e,t,o,i){let s=r.clone().sub(n),l=e.clone().sub(n),c=s.angleTo(l);if(s.normalize(),l.normalize(),t===o){let u=s.add(l).normalize();i.copy(n).addScaledVector(u,t/Math.sin(c/2))}else{let u=s.angleTo(l);i.copy(n),i.addScaledVector(s,o/Math.sin(u)),i.addScaledVector(l,t/Math.sin(u))}}function r_(n,r,e){let t=n.clone().sub(r),o=e.clone().sub(r);return t.projectOnVector(o),t.add(r)}var id=class extends Se.BufferGeometry{constructor(r=.5,e=1,t=4,o=1,i=!1,s=0,l=4){super(),t=Math.floor(Math.max(3,t)),o=Math.floor(o),l=Math.floor(l);let c=[],u=[],a=[],d=[],p=0,f=e/2,m=Math.PI/t,h=r*Math.cos(Math.PI/t),y=2*Math.PI/t,g=(t-2)*Math.PI/t,v=Math.PI-g,w=new Se.Vector3(0,-f,0),S=new Se.Vector3(0,f,0),b=new Se.Vector2(r,-f),T=new Se.Vector2(h,-f),_=new Se.Vector2(0,S.y).sub(T),x=new Se.Vector2(0,S.y).sub(b),C=new Se.Vector2(_.y,-_.x).normalize(),P=new Se.Vector2(x.y,-x.x).normalize(),A=r*Math.cos(Math.PI/t)*Math.tan((Math.PI-_.angle())/2)-1e-8;s=Math.min(s,A);let O;{let k=new Se.Vector3(C.x,C.y,0),G=new Se.Vector3(Math.cos(y)*k.x,k.y,Math.sin(y)*k.x);O=k.angleTo(G)}let V=s/Math.tan((Math.PI-_.angle())/2),z=s/Math.tan((Math.PI-O)/2),$=new Se.Vector3;if(!i){u.push(w.x,w.y,w.z),a.push(0,-1,0),d.push(0,0);let k=p++,G=[],D=b.clone(),B=V/Math.cos(Math.PI/t);D.x-=B;for(let L=0;L<t;L++){let F=L/t*Math.PI*2+m,W=new Se.Vector2(Math.sin(F),Math.cos(F));ds(D,W,$),u.push($.x,$.y,$.z),a.push(0,-1,0),d.push(0,0),G.push(p++)}for(let L=0;L<G.length;L++)c.push(G[L],k,G[(L+1)%G.length])}let te=[];{let k=new Se.Vector3,G=new Se.Vector3,D=new Se.Vector3,B=new Se.Vector3,L=new Se.Vector3,F=new Se.Vector3;for(let W=0;W<t;W++){let H=W/t*Math.PI*2+m,j=(W+.5)/t*Math.PI*2+m,U=(W+1)/t*Math.PI*2+m,M=new Se.Vector2(Math.sin(H),Math.cos(H)),oe=new Se.Vector2(Math.sin(j),Math.cos(j)),Y=new Se.Vector2(Math.sin(U),Math.cos(U));ds(b,M,G),ds(b,Y,D),ds(C,oe,k),nd(S,G,D,z,z,B),u.push(B.x,B.y,B.z),nd(G,S,D,z,V,L),u.push(L.x,L.y,L.z),nd(D,G,S,V,z,F),u.push(F.x,F.y,F.z),a.push(k.x,k.y,k.z),a.push(k.x,k.y,k.z),a.push(k.x,k.y,k.z),d.push(0,0),d.push(0,0),d.push(0,0);let re=p++,X=p++,ee=p++;if(c.push(re,X,ee),s>0){{let de=G.clone().add(D).multiplyScalar(.5),ae=S.clone().sub(de).normalize(),Ue=w.clone().sub(de).normalize().add(ae).normalize().multiplyScalar(-1),ve=F.clone().sub(L);K(de,ve,Ue,_.angle())}let Z,se;{let de=new Se.Vector3;ds(P,Y,de);let ae=F.clone().add(B).multiplyScalar(.5);ae=r_(ae,D,S);let fe=F.clone().sub(B);[Z,se]=K(ae,fe,de,O,B.y)}{let de=Z,ae=de.clone().setY(0).normalize(),fe=new Se.Vector3(0,-1,0),Ue=ae.clone().cross(fe);q(de,ae,fe,Ue)}te.concat(se);{let de=_.angle(),ae=Math.PI-de,fe=S.clone();fe.y-=s/Math.sin(de-Math.PI/2);let Ue=new Se.Vector3,ve=[];for(let Ne=0;Ne<l;Ne++){let Nt=[],Et=Math.PI/2-ae*Ne/l,sn=Math.cos(Et),Kt=Math.sin(Et),an=j;for(let rc=0;rc<=Ne;rc++){let oc=Math.cos(an),Gi=Math.sin(an);k.x=sn*Gi,k.y=Kt,k.z=sn*oc,Ue.copy(fe).addScaledVector(k,s),u.push(Ue.x,Ue.y,Ue.z),a.push(k.x,k.y,k.z),d.push(0,0),Nt.push(p++),an+=Math.PI*2/Ne/t}ve.push(Nt)}se.reverse(),ve.push(se);let qe=ve.length-1;for(let Ne=0;Ne<qe;Ne++){let Nt=ve[Ne],Et=ve[Ne+1],sn=Nt.length-1;c.push(Et[1],Nt[0],Et[0]);for(let Kt=1;Kt<=sn;Kt++)c.push(Nt[Kt],Nt[Kt-1],Et[Kt]),c.push(Et[Kt+1],Nt[Kt],Et[Kt])}}}}}this.setIndex(c),this.setAttribute("position",new Se.Float32BufferAttribute(u,3)),this.setAttribute("normal",new Se.Float32BufferAttribute(a,3)),this.setAttribute("uv",new Se.Float32BufferAttribute(d,2));function K(k,G,D,B,L){let F=-B/2,W=(Math.PI-B)/2,H=G.clone().normalize().cross(D);k.addScaledVector(D,-s/Math.sin(W));let j=new Se.Vector3,U=new Se.Vector3,M=1,oe=p,Y=[];for(let re=0;re<=l;re++){let X=F+re/l*B;U.set(0,0,0),U.addScaledVector(H,Math.sin(X)),U.addScaledVector(D,Math.cos(X));for(let ee=0;ee<=M;ee++){let Z=ee/M-.5;if(j.copy(k),j.addScaledVector(G,Z),j.addScaledVector(U,s),L!=null){let se=Math.max(0,j.y-L);j.addScaledVector(G,-se/G.y)}u.push(j.x,j.y,j.z),a.push(U.x,U.y,U.z),d.push(0,0),ee===0&&Y.push(p),p++}}for(let re=0;re<l;re++)for(let X=0;X<M;X++){let ee=oe+X+(M+1)*re,Z=ee+(M+1),se=Z+1,de=ee+1;c.push(ee,Z,de),c.push(Z,se,de)}return[k.clone().addScaledVector(G,.5),Y]}function q(k,G,D,B){let L=Math.PI/2,F=x.angle()-L,W=[],H=new Se.Vector3,j=new Se.Vector3;for(let M=0;M<=l;M++){let oe=[],Y=M/l;for(let re=0;re<=M;re++){let ee=((M?re/M:0)-.5)*v,Z=Math.cos(ee),se=Math.sin(ee),de=Math.atan(Math.tan(F)*Z),ae=(L+de)*Y,fe=Math.cos(ae),Ue=Math.sin(ae);H.set(0,0,0),H.addScaledVector(G,Ue*Z),H.addScaledVector(D,fe),H.addScaledVector(B,Ue*se),j.copy(k).addScaledVector(H,s),u.push(j.x,j.y,j.z),a.push(H.x,H.y,H.z),d.push(0,0),oe.push(p++)}W.push(oe)}let U=W.length-1;for(let M=0;M<U;M++){let oe=W[M],Y=W[M+1],re=oe.length-1;c.push(oe[0],Y[1],Y[0]);for(let X=1;X<=re;X++)c.push(oe[X-1],oe[X],Y[X]),c.push(oe[X],Y[X+1],Y[X])}}}};var xl=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters),t=Object.assign(r?.ui??{enabledIndieCorners:!1},n.ui);return{shape:n.shape&&n.shape instanceof Te?n.shape:new Te,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)}),ui:t}}static build(n){let r=n.shape,{width:e,height:t,cornerRadius:o,cornerType:i,depth:s,extrudeBevelSize:l,extrudeBevelSegments:c}=n.parameters,u={x:e*.5,y:t*.5},a={x:-u.x,y:-u.y},d={x:u.x,y:u.y};function p(S,b,T){return b>e&&T>t?Math.min(S*e/b,S*t/T):b>e?S*e/b:T>t?S*t/T:S}let f=[];f[0]=o[0]===0?0:p(o[0],o[0]+o[3],o[0]+o[1]),f[1]=o[1]===0?0:p(o[1],o[1]+o[2],o[1]+o[0]),f[2]=o[2]===0?0:p(o[2],o[2]+o[1],o[2]+o[3]),f[3]=o[3]===0?0:p(o[3],o[3]+o[0],o[3]+o[2]);let m=a.x,h=d.x,y=d.y,g=a.y;r.addPoint(r.createPoint(m,y)),r.addPoint(r.createPoint(h,y)),r.addPoint(r.createPoint(h,g)),r.addPoint(r.createPoint(m,g)),r.isClosed=!0;let v=!0;for(let S=0,b=r.points.length;S<b;S++)r.points[S].roundness=f[S],S>0&&f[S]!==f[S-1]&&(v=!1);v&&(r.roundness=f[0]),r.useCubicForRoundedCorners=i!==1,r.update();let w=Vt.create({shape:r,parameters:{depth:s,extrudeBevelSize:l,extrudeBevelSegments:c}});return Object.assign(w,{userData:{...n,type:"RectangleGeometry"}})}};var mh=require("three"),hh=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:r=100,height:e=r,depth:t=r,widthSegments:o=64,heightSegments:i=64,phiStart:s,phiLength:l,thetaStart:c,thetaLength:u}=n.parameters,a=new mh.SphereGeometry(.5*r,o,i,s,l,c,u);return a.scale(1,e/r,t/r),Object.assign(a,{userData:{...n,type:"SphereGeometry"}})}};var yh=require("three"),gh=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:0})}}static build(n){let{width:r=100,height:e=r,widthSegments:t=8,heightSegments:o=8}=n.parameters,i=new yh.PlaneGeometry(r,e,t,o);return i.scale(1,1,1),Object.assign(i,{userData:{...n,type:"PlaneGeometry"}})}};var To=require("three"),xh=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:r,height:e,depth:t,angle:o,cornerRadius:i,cornerSegments:s}=n.parameters,l=new sd(r,e,t,o,i,s);return Object.assign(l,{userData:{...n,type:"BackdropGeometry"}})}},sd=class extends To.BufferGeometry{constructor(r=1,e=1,t=1,o=90,i=10,s=24){super(),this.type="BackdropGeometry";let l=[],c=[],u=[],a=.001;i==0&&(s=1),s=Math.max(1,Math.floor(s)),i=Math.min(i,100),o=Math.min(180-a,o),o*=Math.PI/180;let d=[],p=Math.PI/2,f=(j=0,U=0,M=0)=>new To.Vector3(j,U,M),m=f(),h=f(),[y,g,v]=[e/2,r/2,t/2],w=-g,S=+g,[b,T,_]=[f(w,-y,+v),f(w,-y,-v),f(w,+y,-v)],x=(j,U=!1)=>Math.sin(j-Math.PI/(1+ +U)),C=(j,U=!1)=>Math.cos(j-Math.PI/(1+ +U));_.y=Math.sin(o)*e-y;let P=Math.cos(o)*e-v,I=b.z-a;o<=p?(_.z=Math.min(P,I),_.z==I&&(_.y-=(P-I)/Math.tan(p-o))):T.z=Math.min(T.z-P-v,b.z-a),m.subVectors(b,T),h.subVectors(_,T);let A=Math.min(m.length(),h.length())*i/100,O=A*Math.tan(o/2),V=A/Math.cos(o/2),z=m.clone().normalize().add(h.normalize()).setLength(V).add(T);m.set(0,x(o,!0),C(o,!0)),d.push([_,m.clone()]);let $=(Math.PI-o)/s;for(let j=0;j<=s;j++){let U=p+o+j*$;m.set(0,Math.sin(U)*O,Math.cos(U)*O),m.add(z),h.set(0,x(U),C(U)),d.push([m.clone(),h.clone()])}d.push([b,f(0,1,0)]);let te=Math.sin($/2)*O*2,K=d.length-1,q=d[0][0].distanceTo(d[1][0]),k=d[K-1][0].distanceTo(d[K][0]),G=q+te*s+k;d[0].push(1);for(let j=0;j<=s;j++)d[j+1].push(1-(q+j*te)/G);d[K].push(0);let[D,B,L]=d[0],F,W,H;for(let j=1;j<d.length;j++)[F,W,H]=d[j],l.push(w,D.y,D.z,w,F.y,F.z,S,D.y,D.z,S,D.y,D.z,w,F.y,F.z,S,F.y,F.z),c.push(0,B.y,B.z,0,W.y,W.z,0,B.y,B.z,0,B.y,B.z,0,W.y,W.z,0,W.y,W.z),u.push(0,L,0,H,1,L,1,L,0,H,1,H),[D,B,L]=[F,W,H];this.setAttribute("position",new To.Float32BufferAttribute(l,3)),this.setAttribute("normal",new To.Float32BufferAttribute(c,3)),this.setAttribute("uv",new To.Float32BufferAttribute(u,2))}};var vl=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters);return{shape:n.shape&&n.shape instanceof Te?n.shape:new Te,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(n){let{width:r,height:e,innerRadiusPercent:t,spikes:o,cornerRadius:i,angle:s,depth:l,extrudeBevelSize:c,extrudeBevelSegments:u}=n.parameters,a=n.shape,d=r*.5,p=e*.5,f=0,m=0,h=s*Math.PI/360/o,y=Math.PI/2*3*-1,g=d*t/100,v=p*t/100;if(o===3&&t===50){h=2*Math.PI/o;for(let S=0;S<o;S++){let b=h*S,T=f+Math.sin(b)*d,_=m+Math.cos(b)*p;a.addPoint(a.createPoint(T,_))}}else for(let S=0;S<o;S++){let b=f+Math.cos(y)*d,T=m+Math.sin(y)*p;a.addPoint(a.createPoint(b,T)),y+=h,b=f+Math.cos(y)*g,T=m+Math.sin(y)*v,S<=o,a.addPoint(a.createPoint(b,T)),y+=h}a.isClosed=!0;for(let S=0,b=a.points.length;S<b;S++)a.points[S].roundness=i;a.roundness=i,a.update();let w=Vt.create({shape:a,parameters:{roundness:i,depth:l,extrudeBevelSize:c,extrudeBevelSegments:u}});return Object.assign(w,{userData:{...n,type:"StarGeometry"}})}};var vh=require("three"),bh=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,depth:0},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(n){let{width:r,height:e}=n.parameters,t=new vh.PlaneGeometry(r,e);return Object.assign(t,{userData:{...n,type:"TextFrameGeometry"}})}};var Sh=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:Math.PI*2,cornerRadius:30,cornerSegments:8},n.parameters),t=Math.abs(e.width),o=Math.abs(e.height??e.width),i=Math.round(Math.abs(e.depth??e.width*.25));return{parameters:Object.assign(e,{width:t,height:o,depth:i})}}static build(n){let{width:r,height:e,depth:t,radialSegments:o,tubularSegments:i,arc:s,cornerRadius:l,cornerSegments:c}=n.parameters,u=o_(r,e,t,r*.5,s,i,0,0,o,l,c);return u.scale(1,e/r,1),Object.assign(u,{userData:{...n,type:"TorusGeometry"}})}};function o_(n,r,e,t,o,i,s,l,c,u,a){return[r,e]=[e,r],s=r/2,o/=2*Math.PI,o==1&&(u=0),new Wo(!0,n,r,e,t,o,i,s,l,c,u,a)}var wh=require("three"),_h=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),tube:e.tube??e.width*.125})}}static build(n){let{width:r,tube:e,tubularSegments:t,radialSegments:o,p:i,q:s}=n.parameters,l=r*.5;l!==e&&(l-=e);let c=new wh.TorusKnotGeometry(l,e,t,o,i,s);return Object.assign(c,{userData:{...n,type:"TorusKnotGeometry"}})}};var Th=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},n.parameters);return{shape:n.shape&&n.shape instanceof Te?n.shape:new Te,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width*(e.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(e.depth??0)})}}static build(n){let{width:r=100,height:e,cornerRadius:t,depth:o,extrudeBevelSize:i,extrudeBevelSegments:s,isRect:l}=n.parameters,c=n.shape,u=r*.5,a=e*.5;l?(c.addPoint(c.createPoint(-u,a)),c.addPoint(c.createPoint(u,-a)),c.addPoint(c.createPoint(-u,-a))):(c.addPoint(c.createPoint(0,a)),c.addPoint(c.createPoint(u,-a)),c.addPoint(c.createPoint(-u,-a))),c.isClosed=!0;for(let p=0,f=c.points.length;p<f;p++)c.points[p].roundness=t;c.roundness=t,c.update();let d=Vt.create({shape:c,parameters:{roundness:t,depth:o,extrudeBevelSize:i,extrudeBevelSegments:s}});return Object.assign(d,{userData:{...n,type:"TriangleGeometry"}})}};var Le=require("three");function Ph(n,r){let e=2*Math.PI;return(n%e+e)%e===(r%e+e)%e}var Oh=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},n.parameters),t=Math.abs(e.width),o=Math.abs(e.height??e.width),i=Math.abs(e.depth??0),s=r?.shapeData??oi.create({parameters:Ac}).userData.shape;return{path:n.path??xn.defaultData(),parameters:Object.assign(e,{width:t,height:o,depth:i,extrusion:{...Pa,...e.extrusion}}),shapeData:s}}static build(n){if(n.path.points.length>=2){let e=new ad(n);return Object.assign(e,{userData:{...n,type:"PathGeometry"}})}else return Object.assign(new Le.BufferGeometry,{userData:{...n,type:"PathGeometry"}})}},ad=class extends Le.BufferGeometry{constructor(e){super();this.type="PathExtrusionGeometry",this.inputs=e,this.build()}_isGeometryClosed(){return this.inputs.path.isClosed&&this.inputs.parameters.extrusion.depth===1}_isOpenEnded(){let e=this.inputs.parameters.extrusion;return!(this.inputs.path.isClosed&&e.depth===1)||!Ph(e.twist,0)||e.startScale!==e.endScale}build(){let e=this._extractPathPoints();if(e.length<2)return;let t=this._computeBasisMatrices(e),{depth:o,offset:i}=this.inputs.parameters.extrusion,s=Math.max(2,Math.ceil(this.inputs.path.isClosed?o*e.length:(Math.min(i+o,1)-i)*e.length)),l=[],c=[],u=Math.floor(i*e.length);for(let b=0;b<s;b++){let T=this.inputs.path.isClosed?(b+u)%e.length:Math.min(e.length-1,b+u);l.push(e[T]),c.push(t[T])}this._isOpenEnded()&&this._isGeometryClosed()&&(s++,l.push(l[0].clone()),c.push(c[0].clone())),this._applyPathModifiers(c);let{regions:a,infos:d,vertices:p}=this._computeShapePoints(5),f=0,m=0;d.sort((b,T)=>b.start-T.start),d.forEach(b=>{b.verticesStart=f,b.verticesCount=b.count+b.continuous.reduce((T,_)=>T+(_?0:1),0),m+=b.verticesCount,f=m});let h=m*s,y,g=0;this._isOpenEnded()&&(y=mr({windingRule:we.ODD,elementType:We.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:a}),g=y.vertexCount);let v=h+2*g,w={positions:new Float32Array(v*3),normals:new Float32Array(v*3),uvs:new Float32Array(v*2)},S=[];d.forEach(b=>{this._extrudeRegion(b,p,c,l,w,S,this._isGeometryClosed()&&!this._isOpenEnded())}),y&&(this._closeEnd(y,h,S,w,c[0],l[0],!1),this._closeEnd(y,h+g,S,w,c[c.length-1],l[l.length-1],!0)),this.setAttribute("position",new Le.BufferAttribute(w.positions,3)),this.setAttribute("normal",new Le.BufferAttribute(w.normals,3)),this.setAttribute("uv",new Le.BufferAttribute(w.uvs,2)),this.setIndex(S),this.computeVertexNormals()}_extractPathPoints(){let e=this.inputs.path.isClosed,o=sl(this.inputs.path).getPoints(this.inputs.path.subdivisions);if(o.length<2)return[];let i=[o[0]];return o.forEach(s=>{i[i.length-1].distanceToSquared(s)>.001&&i.push(s)}),e&&i[i.length-1].distanceTo(i[0])<.001&&i.pop(),i}_computeBasisMatrices(e){let t=[],o=e.length,i=this.inputs.path.isClosed,s=new Le.Vector3,l=new Le.Vector3,c=new Le.Vector3,u=new Le.Vector3,a=new Le.Vector3(0,1,0);for(let y=0;y<o;y++){let g=e[y],v;y===0?v=i?e[e.length-1]:g.clone().multiplyScalar(2).sub(e[1]):v=e[y-1];let w;y===o-1?w=i?e[0]:g.clone().multiplyScalar(2).sub(e[y-1]):w=e[y+1];let S=g.clone().sub(v).normalize(),b=w.clone().sub(g).normalize(),T=S.clone().add(b).normalize();c.copy(T),y===0&&(T.equals(a)||T.clone().negate().equals(a))&&a.set(0,0,1);let _=a.clone().cross(T).normalize(),x=T.clone().cross(_).normalize();a.copy(x),u.copy(_),y===0&&(s.copy(x),l.copy(T));let C=new Le.Matrix4().makeBasis(_,x,T);t.push(C)}let d=i?l:c,p=i?s:new Le.Vector3(0,1,0),f=d.clone().cross(u).normalize(),m=Math.acos(p.dot(f));if(isNaN(m))return t;let h=p.clone().cross(f);d.dot(h)>0&&(m*=-1);for(let y=1;y<t.length;y++){let g=new Le.Matrix4().makeRotationZ(m*y/t.length);t[y].multiply(g)}return t}_applyPathModifiers(e){let t=e.length,{angle:o,twist:i,startScale:s,endScale:l}=this.inputs.parameters.extrusion,c=new Le.Matrix4,u=new Le.Matrix4;return e.forEach((a,d)=>{let p=this._isGeometryClosed()?d/t:d/(t-1);c.makeRotationZ(Le.MathUtils.lerp(o,o+i,p));let f=Le.MathUtils.lerp(s,l,p);u.makeScale(f,f,f),a.multiply(c).multiply(u)}),e}_computeShapePoints(e=12,t=we.ODD){let o=this.inputs.shapeData,i=o.extractShapePointsToFlatArray([],e),s=o.shapeHoles.map(h=>{let y=h.extractShapePointsToFlatArray([],e),g=[];for(let v=y.length-1;v>=1;v-=2){let w=y[v-1],S=y[v-0];g.push(w,S)}return g}),l=mr({windingRule:t,elementType:We.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[i]}),c=mr({windingRule:we.ODD,elementType:We.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...s]});if(!l)throw new Error("error generating geometry");let u=l.elementCount;if(c){l.elementCount+=c.elementCount;for(let h=0;h<c.elements.length;h++){let y=c.elements[h],g=h%2===0?l.vertexCount:0;l.elements.push(y+g)}for(let h=0;h<c.vertexIndices.length;h++){let y=c.vertexIndices[h],g=l.vertexCount;l.vertexIndices.push(y+g)}for(let h=0;h<c.vertices.length;h++){let y=c.vertices[h];l.vertices.push(y)}}let a=1/0,d=-1/0,p=1/0,f=-1/0;for(let h=0,y=l.vertexCount;h<y;h++){let g=h*2,v=l.vertices[g+0],w=l.vertices[g+1];v<a&&(a=v),v>d&&(d=v),w<p&&(p=w),w>f&&(f=w)}let m=[];for(let h=l.elementCount-1;h>=0;h--){let y=h>=u,g=h*2,v=l.elements[g+0],w=l.elements[g+1],S=v+w,b={start:v,count:w,normals:[],isHole:y,continuous:[],verticesStart:0,verticesCount:0};m.push(b);let T=v,_=S-1,x=v+1,C=o.roundedCurves.length;do{let P=T-v,I=l.vertices[_*2+0],A=l.vertices[_*2+1],O=l.vertices[T*2+0],V=l.vertices[T*2+1],z=l.vertices[x*2+0],$=l.vertices[x*2+1],te=O-I,K=V-A,q=Math.sqrt(te*te+K*K);te/=q,K/=q;let k=O-z,G=V-$,D=Math.sqrt(k*k+G*G);k/=D,G/=D,b.normals[P*2+0]=-G,b.normals[P*2+1]=k;let B=l.vertexIndices[T];if(Array.isArray(B))b.continuous[P]=!1;else{let[L,F]=o.getCurveIndexFromVertexId(B-1,!0);if(F>0&&F<1)b.continuous[P]=!0;else{let W=F===1?L+1:L-1;W=(W+C)%C;let H=F===1?0:1,j=o.roundedCurves[L].getTangent(F),U=o.roundedCurves[W].getTangent(H);b.continuous[P]=j.dot(U)>.95}}y&&(b.normals[P*2+0]*=-1,b.normals[P*2+1]*=-1),[_,T,x]=[T,x,x+1],x>=S&&(x-=w)}while(x!==v+1)}return{regions:[i,...s],infos:m,vertices:l.vertices}}_insertVertex(e,t,o,i,s){let l=t*2,c=t*3;e.positions[c+0]=o.x,e.positions[c+1]=o.y,e.positions[c+2]=o.z,e.normals[c+0]=i.x,e.normals[c+1]=i.y,e.normals[c+2]=i.z,e.uvs[l+0]=s.x,e.uvs[l+1]=s.y}_extrudeRegion(e,t,o,i,s,l,c){let u=new Le.Vector3,a=new Le.Vector3,d=new Le.Vector2;o.forEach((f,m)=>{let h=i[m],y=e.verticesStart*o.length+e.verticesCount*m;for(let g=0;g<e.count;g++){let v=(e.start+g)*2;u.set(t[v+0],t[v+1],0).applyMatrix4(f).add(h),a.set(e.normals[g*2+0],e.normals[g*2+1],0).applyMatrix4(f).normalize(),d.set(g/(e.count-1),m/(o.length-1)),this._insertVertex(s,y,u,a,d),y++,e.continuous[g]||(this._insertVertex(s,y,u,a,d),y++)}});let p=c?o.length:o.length-1;for(let f=0;f<p;f++){let m=e.verticesStart*o.length+e.verticesCount*f,h=c&&f===p-1?e.verticesStart*o.length:e.verticesStart*o.length+e.verticesCount*(f+1),y=0;for(let g=0;g<e.count;g++){e.continuous[g]||y++;let v=(g+1)%e.count===0?0:y+1,w=m+y,S=m+v,b=h+v,T=h+y;e.isHole?l.push(w,b,S,w,T,b):l.push(w,S,b,w,b,T),y++}}}_closeEnd(e,t,o,i,s,l,c){let u=e.vertexCount,a=new Le.Vector3(0,0,c?-1:1).applyMatrix4(s),d=new Le.Vector3,p=new Le.Vector2;for(let m=0;m<u;m++){let h=2*m;d.set(e.vertices[h+0],e.vertices[h+1],0).applyMatrix4(s).add(l),this._insertVertex(i,t+m,d,a,p)}let f=e.elements;for(let m=0;m<e.elementCount;m++){let h=3*m,y=f[h+0]+t,g=f[h+(c?1:2)]+t,v=f[h+(c?2:1)]+t;o.push(y,g,v)}}};var qo=require("three"),Ah=require("three/examples/jsm/utils/BufferGeometryUtils.js");function n_(){let n=new qo.BufferGeometry;return n.setAttribute("position",new qo.BufferAttribute(new Float32Array([]),3)),n.setIndex(new qo.BufferAttribute(new Uint16Array([]),1)),n}var i_=12,s_=1,si=class extends qo.BufferGeometry{constructor(e,t){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];this.userData={parameters:e,type:"TextGeometry"};let o=t.getFont(e.font);o?.isLoaded?(this.font=o,this.update(e)):this.updateFont(e.font,t).then(()=>{this.update(e),t?.requestRender()})}async updateFont(e,t){let o=t.getFont(e);o&&(this.font=o,await o.loadingPromise)}update(e){let t=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!t?.isLoaded){console.warn("Cannot update text because its font is not loaded");return}let{width:o,height:i,depth:s,extrudeBevelSize:l,extrudeBevelSegments:c,text:u,textTransform:a}=e,d=a===2?u.toUpperCase():a===3?u.toLowerCase():u,p=a_(e,t,d),{shapes:f,charWidths:m,charCoords:h}=t.generateShapes(p,e),y=o*.5,g=i*.5,v=f.map(b=>new Te().fromShape(b));this.vectorShapes=v;let w=v.map(b=>Vt.create({shape:b,parameters:{depth:s,extrudeBevelSegments:c,extrudeBevelSize:l,windingRule:s<=0?we.NONZERO:we.ODD,subdivisions:this.isLowResolution&&s>0?s_:i_}})),S=w.length?(0,Ah.mergeBufferGeometries)(w):n_();S.translate(-y,g,0),this.dispose(),this.wrappedText=p,this.charCoords=h,this.charWidths=m,this.deleteAttribute("extrudeNormal"),Object.entries(S.attributes).forEach(([b,T])=>{this.setAttribute(b,T)}),this.setIndex(S.index),this.computeBoundingSphere()}clone(){let e=mo(new qo.BufferGeometry,si.prototype);return e.copy(this),console.log("CloneGeometry",this,e),e}copy(e){return Object.entries(e.attributes).forEach(([t,o])=>{this.setAttribute(t,o)}),this.setIndex(e.index),this.userData={parameters:{...e.userData.parameters},type:"TextGeometry"},this}async setText(e){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:e})}get text(){return this.userData.parameters.text??""}};function a_(n,r,e){e=e??n.text;let t=[""],o="";for(let i of e)o+=i,i===" "||i===`
2
2
  `?(t[t.length-1]+=o,o="",i===`
3
- `&&t.push("")):r.getTextWidth(t[t.length-1]+o,n)>n.width&&(t[t.length-1].length&&t.push(""),r.getTextWidth(t[t.length-1]+o,n)>n.width&&(o.length===1?(t[t.length-1]+=o,o=""):(t[t.length-1]+=o.slice(0,-1),o=o[o.length-1],t.push(""))));return t[t.length-1]+=o,t}var De=require("three");var uh,ri=new Promise(n=>{uh=n}),dh=!1;async function ph(){if(dh)return;let r=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@0.9.225/build",[e,t]=await Promise.all([import("./process.js"),fetch(`${r}/process.wasm`).then(s=>s.arrayBuffer())]),o=e.default,i=await o({wasmBinary:t});uh(i),dh=!0}var fh=require("three");function Wo(n,r,e){let t={parameters:n,type:n.type};if(n.type==="VectorGeometry"){let i=Te.createFromState(n.shape,n.width,n.height);t.shape=i}else if(n.type==="NonParametricGeometry")n.data.groups&&n.data.groups.forEach(i=>i.materialIndex=Math.max(i.materialIndex??0,0)),t.geometry=new fh.BufferGeometryLoader().parse(n);else{if(n.type==="SubdivGeometry")return new Ze(n,e);if(n.type==="TextGeometry")return new ei(n,r)}let o;try{o=Uc(t)}catch(i){console.error(i)}if(!o){let i=Te.createFromState(mn.defaultData(),100,100);t.shape=i,o=Uc(t)}return o}var mh=require("three"),zw=new mh.Matrix4;function ns(n,r,e,t){let o=n.position.array,i=n.normal.array,s=zw.makeScale(r,e,t).invert().elements,l,c,u;for(var a=0,d=o.length;a<d;a+=3)o[a]*=r,o[a+1]*=e,o[a+2]*=t,l=i[a],c=i[a+1],u=i[a+2],i[a]=s[0]*l+s[4]*c+s[8]*u,i[a+1]=s[1]*l+s[5]*c+s[9]*u,i[a+2]=s[2]*l+s[6]*c+s[10]*u;n.position.needsUpdate=!0,n.normal.needsUpdate=!0}var il=new De.Box3,oi=new De.Vector3,de;ri.then(n=>{de=n});var hh=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),yh=new Uint32Array([0,1,2,3]),gh=new Uint8Array([4]),Ze=class extends De.BufferGeometry{constructor(e,t){super();this.data=e;this.flatShading=t;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,t){this.freeSubdivPointer();let o=this.data.scaleBaked,i=io.div(t,o);this.subdividedGeometry&&ns(this.subdividedGeometry.attributes,...i),this.originalGeometry&&ns(this.originalGeometry.attributes,...i),this.data=e;let s=this.userData.parameters;this.userData.parameters={width:s.width*i[0],height:s.height*i[1],depth:s.depth*i[2]},this.originalGeometry.boundingSphere.center.multiply(oi.fromArray(i));let l=oi.set(s.width,s.height,s.depth).length();this.originalGeometry.boundingSphere.radius=l/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,t,o;try{({originalGeometry:e,subdividedGeometry:t,subdivPointer:o}=Ze.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new De.BoxGeometry(100,100,100),o=0}this.subdivPointer=o,this.originalGeometry=e,this.subdividedGeometry=t??void 0;let i=this.subdividedGeometry??this.originalGeometry;Object.assign(this,i),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(Ze.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new De.Sphere,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,o=e.boundingSphere.center;il.setFromBufferAttribute(t),il.getCenter(o),e.boundingSphere.radius=o.distanceTo(il.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),il.getSize(oi);let i={width:oi.x,height:oi.y,depth:oi.z};return this.userData.parameters=i,i}static build(e,t,o,i){let s,l,c,u=e?.phongAngle??35;o===!1&&(u=-1),t&&(de.free_bvh(t),de.free_subdivision_surface(t));try{s=Ze.allocate(e,i)}catch(a){console.error(a,e),s=Ze.allocate({positionWASM:hh,indexWASM:yh,verticesPerFaceWASM:gh},i)}if(de.set_destination_refinement_level(s,0),l=Ze.buildLevel(s,!0,u),e.subdivisions>0)try{de.set_destination_refinement_level(s,e.subdivisions),c=Ze.buildLevel(s,!1,u)}catch{try{de.set_destination_refinement_level(s,e.subdivisions-1),c=Ze.buildLevel(s,!1,u)}catch{c=null}}else c=null;return{subdivPointer:s,originalGeometry:l,subdividedGeometry:c}}static primitiveToQuads(e,t,o){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let i;if(e.type==="TorusGeometry"&&e.arc===Math.PI*2){let{width:d,height:p,depth:f,arc:m,tubularSegments:h,radialSegments:y}=e;i=new ko(!0,d,f,p,d*.5,m/(2*Math.PI),h,f/2,0,y,0,0,!0)}else i=e.shape!==void 0?t.geometry:Wo(e,o,!1);let s,l,c,u;({positions:s,triIndices:u}=Wc(i.getAttribute("position"),i.getIndex()));let a;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let d=e.radialSegments*e.heightSegments*3*2,p=d+e.radialSegments*3;a=[d,p]}return{indices:l,verticesPerFace:c}=qc(s,u,i,a),{positions:s,indices:l,verticesPerFace:c}}static allocate(e,t){let o,i,s,l=[],c=[];e.positionWASM&&e.positionWASM.length>0?(o=e.positionWASM,i=e.indexWASM,s=e.verticesPerFaceWASM):(o=hh,i=yh,s=gh);let u=o.length,a=i.length,d=s.length,p=o.length+l.length+c.length,f=i.length+s.length,m=p*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,h=p*Float32Array.BYTES_PER_ELEMENT,y=f*Uint32Array.BYTES_PER_ELEMENT,g=de._malloc(m),v=new Float32Array(de.HEAPF32.buffer,g,p),w=new Uint32Array(de.HEAPU32.buffer,g+h,f);v.set(o,0),v.set(l,o.length),v.set(c,o.length+l.length),w.set(i,0),w.set(s,i.length);let b;e?.scaleBaked?.some(A=>A!==1)&&(b=new De.Matrix4().makeScale(...e.scaleBaked)),t&&(b?b.premultiply(t):b=t);let S=b?de.alloc_subdivision_surface2(g,u,g+h,a,g+h+i.length*Uint32Array.BYTES_PER_ELEMENT,d,b.elements):de.alloc_subdivision_surface(g,u,g+h,a,g+h+i.length*Uint32Array.BYTES_PER_ELEMENT,d);return de._free(g),S}static buildLevel(e,t,o,i,s){let l=s?de.get_mesh_data2(e,t?de.Level.CONTROL:de.Level.REFINED,o,s.elements):de.get_mesh_data(e,t?de.Level.CONTROL:de.Level.REFINED,o),c=8,u=de.HEAPU32.subarray(l>>2,(l>>2)+c),a=u.subarray(4,4+4),d=0,p=de.HEAPU32[u[d]>>2],f=de.HEAPF32.subarray(p>>2,(p>>2)+a[d]);d++;let m=de.HEAPU32[u[d]>>2],h=de.HEAPF32.subarray(m>>2,(m>>2)+a[d]);d++;let y=de.HEAPU32[u[d]>>2],g=de.HEAPU32.subarray(y>>2,(y>>2)+a[d]);d++;let v=de.HEAPU32[u[d]>>2],w=de.HEAPU32.subarray(v>>2,(v>>2)+a[d]);if(d++,i===void 0){let b=new De.BufferGeometry;if(b.setIndex(new De.Uint32BufferAttribute(w,1)),b.setAttribute("position",new De.Float32BufferAttribute(f,3)),b.setAttribute("normal",new De.Float32BufferAttribute(h,3)),t){b.setAttribute("faceMap",new De.Uint32BufferAttribute(g,1));let S=new Float32Array(h.length/3*4).fill(0);b.setAttribute("color",new De.BufferAttribute(S,4))}return de.free_mesh_data(l),b.userData.type="SubdivGeometry",b}i.getAttribute("position").copyArray(f),i.getAttribute("normal").copyArray(h),i.attributes.position.needsUpdate=!0,i.attributes.normal.needsUpdate=!0,de.free_mesh_data(l)}static freeSubdivPointer(e){de.free_bvh(e),de.free_subdivision_surface(e)}static buildControlCageWireframe(e,t,o){let i=de.get_wireframe_data_for_base_level(e),s=4,l=de.HEAPU32.subarray(i>>2,(i>>2)+s),c=l.subarray(2,2+2),u=0,a=de.HEAPU32[l[u]>>2],d=de.HEAPF32.subarray(a>>2,(a>>2)+c[u]);u++;let p=de.HEAPU32[l[u]>>2],f=de.HEAPU32.subarray(p>>2,(p>>2)+c[u]);if(t===void 0){let m=new De.BufferGeometry;m.setAttribute("position",new De.Float32BufferAttribute(d,3));let h=new Float32Array(d.length);for(let y=0,g=d.length;y<g;)h[y++]=o.r,h[y++]=o.g,h[y++]=o.b;return m.setAttribute("color",new De.BufferAttribute(h,3)),m.setIndex(new De.Uint32BufferAttribute(f,1)),de.free_wireframe_data_for_base_level(i),m}t.getAttribute("position").copyArray(d),t.attributes.position.needsUpdate=!0,de.free_wireframe_data_for_base_level(i)}static updateCollabMesh(e,t,o){let i=t===0;i||de.set_destination_refinement_level(e,t);let s=o?de.get_topological_data2(e,i?de.Level.CONTROL:de.Level.REFINED,o.elements):de.get_topological_data(e,i?de.Level.CONTROL:de.Level.REFINED),l=6,c=de.HEAPU32.subarray(s>>2,(s>>2)+l),u=c.subarray(3,3+3),a=0,d=de.HEAPU32[c[a]>>2],p=new Float32Array(de.HEAPF32.subarray(d>>2,(d>>2)+u[a]));a++;let f=de.HEAPU32[c[a]>>2],m=new Uint32Array(de.HEAPU32.subarray(f>>2,(f>>2)+u[a]));a++;let h=de.HEAPU32[c[a]>>2],y=new Uint8Array(de.HEAPU32.subarray(h>>2,(h>>2)+u[a]));return de.free_topological_data(s),{positions:p,indices:m,verticesPerFace:y}}};var xh=["getX","getY","getZ"];function Wc(n,r){let e={},t=r?r.count:n.count,o=0,i=[],s=[],l=1e4;for(let u=0;u<t;u++){let a=r?r.getX(u):u,d="";for(let p=0;p<3;p++)d+=`${~~(n[xh[p]](a)*l)},`;if(d in e)i.push(e[d]);else{for(let p=0;p<3;p++)s.push(n[xh[p]](a));e[d]=o,i.push(o),o++}}let c=[];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]||c.push(i[u],i[u+1],i[u+2]);return{positions:s,triIndices:c}}var sl=new De.Vector3,zc=new De.Vector3,kc=new De.Vector3,Hc=new De.Vector3;function qc(n,r,e,t){let o=[],i=[];if(e.userData.shape!==void 0&&e.userData.parameters.depth===0&&e.userData.shape.shapeHoles.length===0){let s=e.userData.shape.extractShapePointsToFlatArray([]),l=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&l<=24&&l%4===0&&e.userData.parameters.angle>=360){let a=s.length/2/l;s=s.filter((d,p)=>Math.floor(p/2)%a===0)}let c=0;for(let a=0;a<s.length;a+=2)c+=(s[a]-s[(a===0?s.length:a)-2])*(s[a+1]+s[(a===0?s.length:a)-1]);n.length=0;let u=0;if(c<0)for(let a=0;a<s.length;a+=2)n.push(s[a],s[a+1],0),o.push(u++);else for(let a=s.length-2;a>=0;a-=2)n.push(s[a],s[a+1],0),o.push(u++);return i.push(u),{indices:o,verticesPerFace:i}}for(let s=0,l=e.capStartIndex??r.length;s<l;)if(r[s+1]===r[s+3]&&r[s+2]===r[s+5]||r[s+0]===r[s+3]&&r[s+2]===r[s+4]){sl.set(n[r[s]*3],n[r[s]*3+1],n[r[s]*3+2]),zc.set(n[r[s+1]*3],n[r[s+1]*3+1],n[r[s+1]*3+2]),kc.set(n[r[s+4]*3],n[r[s+4]*3+1],n[r[s+4]*3+2]),Hc.set(n[r[s+5]*3],n[r[s+5]*3+1],n[r[s+5]*3+2]),zc.sub(sl).normalize(),kc.sub(sl).normalize(),Hc.sub(sl).normalize();let c=zc.cross(kc).dot(Hc);Math.abs(c)>.005||t&&t.some((u,a)=>a%2===1?!1:s>=t[a]&&s<t[a+1])?(o.push(r[s],r[s+1],r[s+2]),i.push(3),s+=3):(o.push(r[s],r[s+1],r[s+4],r[s+5]),i.push(4),s+=6)}else o.push(r[s],r[s+1],r[s+2]),i.push(3),s+=3;if(e.capStartIndex!==void 0){let s=[],l=[],c=0,u=new Float32Array([e.userData.parameters.depth])[0];for(let a=0,d=0;a<n.length;a+=3,d++)n[a+2]===0&&(s.push(d),c++),n[a+2]===u&&l.push(d);if(e.userData.parameters.extrudeBevelSize===0){let a=l[0];l[0]=l[1],l[1]=a}s.reverse(),o.push(...s,...l),i.push(c,c)}return{indices:o,verticesPerFace:i}}var ur={};Ed(ur,{calcBoolean:()=>qw,calcBooleanTopological:()=>Ww,freeMeshSet:()=>Xw,getMeshSet:()=>$w,transformMeshSet:()=>Yw});var kw,vh=new Promise(n=>{kw=n});var is=require("three");var ve,ni;vh.then(n=>ve=n);function Hw(n,r,e){let t,{positions:o,triIndices:i}=Wc(n.getAttribute("position"),n.getIndex()),s;if(r&&e){let{indices:l,verticesPerFace:c}=qc(o,i,n);s=c.length,t=[];for(let u=0,a=0;u<s;u++){t.push(c[u]);for(let d=0;d<c[u];d++)t.push(l[a++])}}else{let l=i.length;t=Array(l+l/3),s=0;for(let c=0,u=0;u<t.length;)t[u++]=3,s++,t[u++]=i[c++],t[u++]=i[c++],t[u++]=i[c++]}return{positions:o,faceIndices:t,nFaces:s}}function bh(n){let r=n.length,e=r*Uint32Array.BYTES_PER_ELEMENT,t=r*Float32Array.BYTES_PER_ELEMENT,o=Number.isInteger(n[0])?e:t,i=ve._malloc(o);return(Number.isInteger(n[0])?new Uint32Array(ve.HEAPU32.buffer,i,r):new Float32Array(ve.HEAPF32.buffer,i,r)).set(n,0),i}function Sh(n){switch(n){case 0:return ve.OP.UNION;case 1:return ve.OP.INTERSECTION;case 2:return ve.OP.A_MINUS_B;case 3:return ve.OP.B_MINUS_A;case 4:return ve.OP.SYMMETRIC_DIFFERENCE;case 5:return ve.OP.ALL;default:throw new Error("Unknown boolean operation "+n)}}function Ww(n,r){ni===void 0&&(ni=ve.init_csg());let e=bh(n),t=ve.csg_calc_topological(ni,e,n.length,Sh(r));ve._free(e);let o=6,i=ve.HEAPU32.subarray(t>>2,(t>>2)+o),s=i.subarray(3,3+3),l=0,c=ve.HEAPU32[i[l]>>2],u=new Float32Array(ve.HEAPF32.subarray(c>>2,(c>>2)+s[l]));l++;let a=ve.HEAPU32[i[l]>>2],d=new Uint32Array(ve.HEAPU32.subarray(a>>2,(a>>2)+s[l]));l++;let p=ve.HEAPU32[i[l]>>2],f=new Uint8Array(ve.HEAPU32.subarray(p>>2,(p>>2)+s[l]));return ve.free_mesh_data(t),{positions:u,indices:d,verticesPerFace:f}}function qw(n,r,e,t){ni===void 0&&(ni=ve.init_csg());let o=bh(n),i=ve.csg_calc(ni,o,n.length,t,Sh(r));ve._free(o);let s=5,l=ve.HEAPU32.subarray(i>>2,(i>>2)+s),c=l.subarray(2,2+3),u=0,a=ve.HEAPU32[l[u]>>2],d=ve.HEAPF32.subarray(a>>2,(a>>2)+c[u]);u++;let p=ve.HEAPU32[l[u]>>2],f=ve.HEAPF32.subarray(p>>2,(p>>2)+c[u]);u++;let m=c[u];e.setAttribute("position",new is.Float32BufferAttribute(d,3)),e.setAttribute("normal",new is.Float32BufferAttribute(f,3));let h=ve.HEAPF32.subarray((i>>2)+5,(i>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new is.Sphere),e.boundingSphere.center.set(h[0],h[1],h[2]),e.boundingSphere.radius=(h[3]**2+h[4]**2+h[5]**2)**.5,e.userData.parameters={width:h[3]*2,height:h[4]*2,depth:h[5]*2},ve.free_mesh_data(i),m}function $w(n,r,e){if(ve===void 0)return-1;let t,o,i;if(r&&n.userData.positions!==void 0){let y=n.userData;i=y.verticesPerFace.length,t=y.positions,o=Array(y.verticesPerFace.reduce((g,v)=>g+v,0)+i);for(let g=0,v=0,w=0;g<y.verticesPerFace.length;g++){o[w++]=y.verticesPerFace[g];for(let b=0;b<y.verticesPerFace[g];b++)o[w++]=y.indices[v++]}}else({positions:t,faceIndices:o,nFaces:i}=Hw(n,r,e));let s=t.length,l=o.length,c=t.length,u=o.length,a=c*Float32Array.BYTES_PER_ELEMENT+u*Uint32Array.BYTES_PER_ELEMENT,d=c*Float32Array.BYTES_PER_ELEMENT,p=u*Uint32Array.BYTES_PER_ELEMENT,f=ve._malloc(a),m=new Float32Array(ve.HEAPF32.buffer,f,c),h=new Uint32Array(ve.HEAPU32.buffer,f+d,u);return m.set(t,0),h.set(o,0),ve.get_csg_mesh(f,s,f+d,l,i)}function Yw(n,r){ve.transform_csg_mesh(n,r.elements)}function Xw(n){ve.free_csg_mesh(n)}var Kw={ConeGeometry:mm,CubeGeometry:hm,CylinderGeometry:pm,DodecahedronGeometry:gm,EllipseGeometry:jm,HelixGeometry:km,IcosahedronGeometry:Wm,LatheGeometry:qm,NonParametricGeometry:$m,PolygonGeometry:Ym,PyramidGeometry:Xm,RectangleGeometry:Km,SphereGeometry:Qm,PlaneGeometry:eh,BackdropGeometry:th,StarGeometry:rh,TextFrameGeometry:nh,TorusGeometry:ih,TorusKnotGeometry:ah,TriangleGeometry:lh,VectorGeometry:Gt},Uc=n=>Kw[n.type].create(n);function ss(n){return n!==null&&"booleanOp"in n}var ii=class extends Xa(al.Mesh){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new al.Matrix4}updateVisible(){super.updateVisible(),this.visible=!ss(this.parent)&&this.visible,ss(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(ur.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),ss(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof ii&&(e.freeBooleanPointer(),ss(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e){let t=super.updateTransformState(e);return t&&ss(this.parent)&&this.invalidateDownstreamBooleanData(!0),t}};var ll=new si.Box3;function $c(n,r=0,e=n.count,t,o){let i=1/0,s=1/0,l=1/0,c=-1/0,u=-1/0,a=-1/0;for(let d=r;d<e;d++){let p=n.getX(d),f=n.getY(d),m=n.getZ(d);p<i&&(i=p),f<s&&(s=f),m<l&&(l=m),p>c&&(c=p),f>u&&(u=f),m>a&&(a=m)}ll.min.set(i,s,l),ll.max.set(c,u,a),ll.getCenter(t),ll.getSize(o).multiplyScalar(.5)}var Zw=new si.BufferGeometry,Qw=new si.MeshBasicMaterial,ht=class extends ii{constructor(r,e){super(Zw,Qw),this.super_Entity(r,e)}updateState(r,e){this.updateState_Entity(r,e)}updateEntityBoxSize(r,e){let t=this.geometry.getAttribute("position");t!==void 0?$c(t,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:t.count,r,e):super.updateEntityBoxSize(r,e)}};var Zr=require("three");var $t=require("three");var Vh=require("three");var fr=require("three");var as=class{constructor(r){r=r??{},this.name=r.name,this.type=r.type,this.node=r.node,this.size=r.size,this.needsUpdate=r.needsUpdate}get value(){return this.node.value}set value(r){this.node.value=r}};var wh=require("three"),dt=class{constructor(r){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=wh.MathUtils.generateUUID(),this.type=r,this.name=""}analyze(r,e){e=e??{},r.analyzing=!0,this.build(r.addFlow(e.slot,e.cache,e.context),"v4"),r.clearVertexNodeCode(),r.clearFragmentNodeCode(),r.removeFlow(),r.analyzing=!1}analyzeAndFlow(r,e,t){return t=t??{},this.analyze(r,t),this.flow(r,e,t)}flow(r,e,t){t=t??{},r.addFlow(t.slot,t.cache,t.context);let o={result:this.build(r,e),code:r.clearNodeCode(),extra:r.context.extra};return r.removeFlow(),o}build(r,e,t){e=e??this.getType(r,e);let o=r.getNodeData(t??this);return r.analyzing&&this.appendDepsNode(r,o,e),r.nodes.indexOf(this)===-1&&r.nodes.push(this),this.updateFrame!==void 0&&r.updaters.indexOf(this)===-1&&r.updaters.push(this),this.generate(r,e,t)}updateFrame(r){}generateReadonly(r,e,t,o,i,s){return""}generate(r,e,t,o,i){return""}parse(r,e,t,o){}appendDepsNode(r,e,t){e.deps=(e.deps||0)+1;let o=r.getTypeLength(t);(o>(e.outputMax||0)||this.getType(r,t))&&(e.outputMax=o,e.output=t)}setName(r){this.name=r}getName(){return this.name}getType(r,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}getHash(){let r="{",e,t;for(e in this)t=this[e],t instanceof dt&&(r+='"'+e+'":'+t.getHash()+",");if(this.hashProperties)for(let o=0;o<this.hashProperties.length;o++)e=this.hashProperties[o],t=this[e],r+='"'+e+'":"'+String(t)+'",';return r+='"id":"'+this.uuid+'"}',r}};var Yc=class{constructor(){this.nodes={};this.keywords={}}add(r){this.nodes[r.name]=r}addKeyword(r,e,t){t=t!==void 0?t:!0,this.keywords[r]={callback:e,cache:t}}remove(r){delete this.nodes[r.name]}removeKeyword(r){delete this.keywords[r]}get(r){return this.nodes[r]}getKeyword(r,e){return this.keywords[r].callback(e)}getKeywordData(r){return this.keywords[r]}contains(r){return this.nodes[r]!==void 0}containsKeyword(r){return this.keywords[r]!==void 0}},nt=new Yc;var Xc=require("three");var _h=require("three"),ce=class extends dt{constructor(e,t){super(e);this.scope="";t=t??{},this.shared=t.shared!==void 0?t.shared:!0,this.unique=t.unique!==void 0?t.unique:!1}build(e,t,o,i){if(t=t??this.getType(e),this.getShared(e,t)){let s=this.getUnique(e,t);s&&this.uuid===void 0&&(this.uuid=_h.MathUtils.generateUUID()),o=e.getUUID(o??this.getUUID(),!s);let l=e.getNodeData(o),c=l.output||this.getType(e);if(e.analyzing)return(l.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,l,t),this.generate(e,t,o)):super.build(e,t,o);if(s)return l.name=l.name||super.build(e,t,o),l.name;if(!this.getLabel()&&(!this.getShared(e,c)||e.context.ignoreCache||l.deps===1))return super.build(e,t,o);o=this.getUUID(!1);let u=this.getTemp(e,o);if(u)return e.format(u,c,t);{u=super.generate(e,t,o,l.output,i);let a=this.generate(e,c,o);return e.addNodeCode(u+" = "+a+";"),e.format(u,c,t)}}return super.build(e,t,o)}getShared(e,t){return t!=="sampler2D"&&t!=="samplerCube"&&this.shared}getUnique(e,t){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let t=this.uuid;return typeof this.scope=="string"&&(t=this.scope+"-"+t),t}getTemp(e,t){t=t||this.uuid;let o=e.getVars()[t];return o?o.name:void 0}generate(e,t,o,i,s){return this.getShared(e,t)||console.error("TempNode is not shared"),o=o??this.uuid,e.getTempVar(o,i??this.getType(e),s,this.getLabel()).name}};var Ge=class extends ce{constructor(e,t){t=t??{},t.shared=t.shared!==void 0?t.shared:!1;super(e,t);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,t,o,i,s,l){o=e.getUUID(o??this.getUUID()),i=i??this.getType(e);let c=e.getNodeData(o);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,t,o,i,s,l):e.isShader("vertex")?(c.vertex||(c.vertex=e.createVertexUniform(i,this,s,l,this.getLabel())),e.format(c.vertex.name,i,t)):(c.fragment||(c.fragment=e.createFragmentUniform(i,this,s,l,this.getLabel())),e.format(c.fragment.name,i,t))}};var ut=class extends Ge{constructor(e=0,t){super("v2");this.nodeType="Vector2";this.value=e instanceof Xc.Vector2?e:new Xc.Vector2(e,t)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,t,o,i,s,l){return e.format("vec2("+this.value.x+", "+this.value.y+")",i,t)}};var Kc=require("three");var yt=class extends Ge{constructor(e=0,t,o){super("v3");this.nodeType="Vector3";this.value=e instanceof Kc.Vector3?e:new Kc.Vector3(e,t,o)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,t,o,i,s,l){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",i,t)}};var Th=require("three"),it=class extends Th.Color{constructor(e,t,o,i){super(e,t,o);this.isColorA=!0;this.a=i}setRGBA(e,t,o,i){super.setRGB(e,t,o),this.a=i}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}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 Qt=class extends Ge{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof it?e:new it(e.r,e.g,e.b,e.a)}generateReadonly(e,t,o,i,s,l){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",i,t)}};var Jw=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,Oh=/[a-z_0-9]+/gi,X=class extends ce{constructor(e,t,o,i,s){super(s);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=s===void 0,this.isInterface=!1,this.parse(e,t,o,i)}getShared(e,t){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}}getIncludeByName(e){if(this.includes){let t=this.includes.length;for(;t--;)if(this.includes[t].name===e)return this.includes[t]}}generate(e,t,o,i,s){let l,c=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 a=[];for(;l=Oh.exec(this.src);)a.push(l);for(let d=0;d<a.length;d++){let p=a[d],f=p[0],m=this.isMethod?!this.getInputByName(f):!0,h=f;if(this.keywords[f]||this.useKeywords&&m&&nt.containsKeyword(f)){let y=this.keywords[f];if(!y){let g=nt.getKeywordData(f);g.cache&&(y=e.keywords[f]),y=y||nt.getKeyword(f,e),g.cache&&(e.keywords[f]=y)}h=y.build(e)}f!==h&&u[p.index+c-1]!=="."&&(u=u.substring(0,p.index+c)+h+u.substring(p.index+f.length+c),c+=h.length-f.length),this.getIncludeByName(h)===void 0&&nt.contains(h)&&e.include(nt.get(h))}return t==="source"?u:this.isMethod?(this.isInterface||e.include(this,void 0,u),this.name):e.format("( "+u+" )",this.getType(e),t)}parse(e,t,o,i){if(this.src=e||"",this.includes=t??[],this.extensions=o??{},this.keywords=i??{},this.isMethod){let s=Jw.exec(this.src);if(this.inputs=[],s&&s.length==4){this.type=s[1],this.name=s[2];let l=s[3].match(Oh);if(l){let c=0;for(;c<l.length;){let u=l[c++],a;u==="in"||u==="out"||u==="inout"?a=l[c++]:(a=u,u="");let d=l[c++];this.inputs.push({name:d,type:a,qualifier:u})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var e_=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,Zc=class extends ce{constructor(e="",t){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||Zc.PI,void 0,void 0,void 0,t)}getType(e){return e.getTypeByFormat(this.type)}parse(e,t,o,i,s){this.src=e||"";let l,c,u="",a=e_.exec(e);this.useDefine=s??this.src.charAt(0)==="#",a&&a.length>1?(c=a[1],l=a[2],u=a[3]):(l=this.src,c="f"),this.name=l,this.type=c,this.value=u}build(e,t){if(t==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),t)}generate(e,t,o,i,s){return e.format(this.name,this.getType(e),t)}},we=Zc;we.PI="PI",we.PI2="PI2",we.RECIPROCAL_PI="RECIPROCAL_PI",we.RECIPROCAL_PI2="RECIPROCAL_PI2",we.LOG2="LOG2",we.EPSILON="EPSILON";var t_=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
4
- )*?)}`,"gim"),r_=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),ai=class extends ce{constructor(e=""){super();this.inputs=[];this.src="";this.nodeType="Struct";this.parse(e)}getType(e){return e.getTypeByFormat(this.name)}getInputByName(e){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}generate(e,t,o,i,s){return t==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),t)}parse(e=""){this.src=e,this.inputs=[];let t=t_.exec(e);if(t){let o=t[2],i;for(;i=r_.exec(o);)this.inputs.push({type:i[1],name:i[2]});this.name=t[1]}else this.name="";this.type=this.name}};var li=class extends ce{constructor(e){super("v2",{shared:!1});this.nodeType="UV";this.index=e??0}generate(e,t){e.requires.uv[this.index]=!0;let o=this.index>0?this.index+1:"",i=e.isShader("vertex")?"uv"+o:"vUv"+o;return e.format(i,this.getType(e),t)}};nt.addKeyword("uv",function(){return new li});nt.addKeyword("uv2",function(){return new li(1)});var cl=require("three");var qo=class extends ce{constructor(e,t){super("v4");this.nodeType="ColorSpace";this.input=e,this.method=t??qo.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case cl.LinearEncoding:return["Linear"];case cl.sRGBEncoding:return["sRGB"];default:return[]}}generate(e,t){let o=this.input.build(e,"v4"),i=this.getType(e),s=qo.Nodes[this.method],l=e.include(s);if(l===qo.LINEAR_TO_LINEAR)return e.format(o,i,t);if(s.inputs?.length===2){let c=this.factor.build(e,"f");return e.format(l+"( "+o+", "+c+" )",i,t)}else return e.format(l+"( "+o+" )",i,t)}fromEncoding(e){let t=qo.getEncodingComponents(e);this.method="LinearTo"+t[0],this.factor=t[1]}fromDecoding(e){let t=qo.getEncodingComponents(e);this.method=t[0]+"ToLinear",this.factor=t[1]}},Ot=qo;Ot.Nodes={LinearToLinear:new X(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
5
- `)),sRGBToLinear:new X(["vec4 sRGBToLinear( in vec4 value ) {"," return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );","}"].join(`
6
- `)),LinearTosRGB:new X(["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(`
7
- `))},Ot.LINEAR_TO_LINEAR="LinearToLinear",Ot.SRGB_TO_LINEAR="sRGBToLinear",Ot.LINEAR_TO_SRGB="LinearTosRGB";var Pe=class extends X{constructor(e="",t,o,i,s){super(e,s,i,o,t);this.nodeType="Expression"}};var Ah=require("three"),Rt=class extends Ge{constructor(e=new Ah.Texture,t,o,i){super("v4",{shared:!0});this.nodeType="Texture";this.value=e,this.uv=t??new li,this.bias=o,this.project=i!==void 0?i:!1}getTexture(e,t){return super.generate(e,t,this.value.uuid,"t")}generate(e,t){if(t==="sampler2D")return this.getTexture(e,t);let o=this.getTexture(e,t),i=this.uv.build(e,this.project?"v4":"v2"),s=this.bias?this.bias.build(e,"f"):void 0;s===void 0&&e.context.bias&&(s=e.context.bias.setTexture(this).build(e,"f"));let l,c;this.project?l="texture2DProj":l=s?"tex2DBias":"tex2D",s?c=l+"( "+o+", "+i+", "+s+" )":c=l+"( "+o+", "+i+" )";let u={include:e.isShader("vertex"),ignoreCache:!0},a=this.getType(e);return e.addContext(u),this.colorSpace=this.colorSpace??new Ot(new Pe("",a)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(c),c=this.colorSpace.build(e,a),e.removeContext(),e.format(c,a,t)}};var Q=class extends Ge{constructor(e){super("f");this.nodeType="Float";this.value=e??0}generateReadonly(e,t,o,i,s,l){return e.format(this.value+(this.value%1?"":".0"),i,t)}};var ls=class extends ce{constructor(e,t){super();this.inputs=[];this.nodeType="FunctionCall";this.value=e,this.inputs=t??[]}getFunction(){return this.value}getType(e){return this.value.getType(e)}generate(e,t,o,i,s){i=this.getType(e);let l=this.value,c=l.build(e,t)+"( ",u=[];if(l.inputs){for(let a=0;a<l.inputs.length;a++){let d=l.inputs[a],p=this.inputs[a]||this.inputs[d.name];u.push(p.build(e,e.getTypeByFormat(d.type)))}c+=u.join(", ")+" )"}return e.format(c,i,t)}};var Qc=class extends ce{constructor(e,t,o=Qc.ADD){super();this.nodeType="Operator";this.type=e.type,this.a=e,this.b=t,this.op=o}getType(e){let t=this.a.getType(e),o=this.b.getType(e);return e.isTypeMatrix(t)?"v4":e.getTypeLength(o)>e.getTypeLength(t)?o:t}generate(e,t){let o=this.getType(e);this.type=o;let i=this.a.build(e,o),s=this.b.build(e,o);return e.format("( "+i+" "+this.op+" "+s+" )",o,t)}},Vt=Qc;Vt.ADD="+",Vt.SUB="-",Vt.MUL="*",Vt.DIV="/";var Ee=class extends ce{constructor(e,t=Ee.ABS,o,i){super();this.nodeType="Math";this.a=e,typeof t!="string"?this.b=t:i=t,typeof o!="string"?this.c=o:i=o,this.method=i,this.hashProperties=["method"]}getNumInputs(e){switch(this.method){case Ee.MIX:case Ee.CLAMP:case Ee.REFRACT:case Ee.SMOOTHSTEP:case Ee.FACEFORWARD:return 3;case Ee.MIN:case Ee.MAX:case Ee.MOD:case Ee.STEP:case Ee.REFLECT:case Ee.DISTANCE:case Ee.DOT:case Ee.CROSS:case Ee.POW:return 2;default:return 1}}getInputType(e){let t=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 t>o&&t>i?this.a.getType(e):o>i?this.b.getType(e):this.c.getType(e)}getType(e){switch(this.method){case Ee.LENGTH:case Ee.DISTANCE:case Ee.DOT:return"f";case Ee.CROSS:return"v3"}return this.getInputType(e)}generate(e,t){let o,i,s,l=this.a?e.getTypeLength(this.a.getType(e)):0,c=this.b?e.getTypeLength(this.b.getType(e)):0,u=this.c?e.getTypeLength(this.c.getType(e)):0,a=this.getInputType(e),d=this.getType(e);switch(this.type=d,this.method){case Ee.NEGATE:return e.format("( -"+this.a.build(e,a)+" )",a,t);case Ee.INVERT:return e.format("( 1.0 - "+this.a.build(e,a)+" )",a,t);case Ee.CROSS:o=this.a.build(e,"v3"),i=this.b.build(e,"v3");break;case Ee.STEP:o=this.a.build(e,l===1?"f":a),i=this.b.build(e,a);break;case Ee.MIN:case Ee.MAX:case Ee.MOD:o=this.a.build(e,a),i=this.b.build(e,c===1?"f":a);break;case Ee.REFRACT:o=this.a.build(e,a),i=this.b.build(e,a),s=this.c.build(e,"f");break;case Ee.MIX:o=this.a.build(e,a),i=this.b.build(e,a),s=this.c.build(e,u===1?"f":a);break;default:o=this.a.build(e,a),this.b&&(i=this.b.build(e,a)),this.c&&(s=this.c.build(e,a));break}let p=[];p.push(o),i&&p.push(i),s&&p.push(s);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,t)}},fe=Ee;fe.RAD="radians",fe.DEG="degrees",fe.EXP="exp",fe.EXP2="exp2",fe.LOG="log",fe.LOG2="log2",fe.SQRT="sqrt",fe.INV_SQRT="inversesqrt",fe.FLOOR="floor",fe.CEIL="ceil",fe.NORMALIZE="normalize",fe.FRACT="fract",fe.SATURATE="saturate",fe.SIN="sin",fe.COS="cos",fe.TAN="tan",fe.ASIN="asin",fe.ACOS="acos",fe.ARCTAN="atan",fe.ABS="abs",fe.SIGN="sign",fe.LENGTH="length",fe.NEGATE="negate",fe.INVERT="invert",fe.MIN="min",fe.MAX="max",fe.MOD="mod",fe.STEP="step",fe.REFLECT="reflect",fe.DISTANCE="distance",fe.DOT="dot",fe.CROSS="cross",fe.POW="pow",fe.MIX="mix",fe.CLAMP="clamp",fe.REFRACT="refract",fe.SMOOTHSTEP="smoothstep",fe.FACEFORWARD="faceforward";var ci=class extends ce{constructor(e,t,o){super("v4");this.nodeType="TextureCubeUV";this.value=e,this.uv=t,this.bias=o}bilinearCubeUV(e,t,o,i){let s=new ls(ci.Nodes.bilinearCubeUV,[t,o,i]);this.colorSpaceTL=this.colorSpaceTL??new Ot(new Pe("","v4")),this.colorSpaceTL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTL.input.parse(s.build(e)+".tl"),this.colorSpaceTR=this.colorSpaceTR??new Ot(new Pe("","v4")),this.colorSpaceTR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTR.input.parse(s.build(e)+".tr"),this.colorSpaceBL=this.colorSpaceBL??new Ot(new Pe("","v4")),this.colorSpaceBL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBL.input.parse(s.build(e)+".bl"),this.colorSpaceBR=this.colorSpaceBR??new Ot(new Pe("","v4")),this.colorSpaceBR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBR.input.parse(s.build(e)+".br");let l={include:e.isShader("vertex"),ignoreCache:!0};e.addContext(l),this.colorSpaceTLExp=new Pe(this.colorSpaceTL.build(e,"v4"),"v4"),this.colorSpaceTRExp=new Pe(this.colorSpaceTR.build(e,"v4"),"v4"),this.colorSpaceBLExp=new Pe(this.colorSpaceBL.build(e,"v4"),"v4"),this.colorSpaceBRExp=new Pe(this.colorSpaceBR.build(e,"v4"),"v4"),e.removeContext();let c=new Pe("mix( mix( cubeUV_TL, cubeUV_TR, cubeUV.f.x ), mix( cubeUV_BL, cubeUV_BR, cubeUV.f.x ), cubeUV.f.y )","v4");return c.keywords.cubeUV_TL=this.colorSpaceTLExp,c.keywords.cubeUV_TR=this.colorSpaceTRExp,c.keywords.cubeUV_BL=this.colorSpaceBLExp,c.keywords.cubeUV_BR=this.colorSpaceBRExp,c.keywords.cubeUV=s,c}generate(e,t){if(e.isShader("fragment")){let o=this.uv,i=this.bias||e.context.roughness,s=new ls(ci.Nodes.roughnessToMip,[i]),l=new fe(s,ci.Nodes.m0,ci.Nodes.cubeUV_maxMipLevel,fe.CLAMP),c=new fe(l,fe.FLOOR),u=new fe(l,fe.FRACT),a=this.bilinearCubeUV(e,this.value,o,c),d=this.bilinearCubeUV(e,this.value,o,new Vt(c,new Q(1).setReadonly(!0),Vt.ADD)),p=new fe(a,d,u,fe.MIX);return e.format(p.build(e),"v4",t)}else return console.warn("TextureCubeUVNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),t)}},di=ci;di.Nodes=function(){let e=new ai(`struct TextureCubeUVData {
3
+ `&&t.push("")):r.getTextWidth(t[t.length-1]+o,n)>n.width&&(t[t.length-1].length&&t.push(""),r.getTextWidth(t[t.length-1]+o,n)>n.width&&(o.length===1?(t[t.length-1]+=o,o=""):(t[t.length-1]+=o.slice(0,-1),o=o[o.length-1],t.push(""))));return t[t.length-1]+=o,t}var Be=require("three");var Ch,li=new Promise(n=>{Ch=n}),Ih=!1;async function Nh(){if(Ih)return;let r=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@0.9.227/build",[e,t]=await Promise.all([import("./process.js"),fetch(`${r}/process.wasm`).then(s=>s.arrayBuffer())]),o=e.default,i=await o({wasmBinary:t});Ch(i),Ih=!0}var Eh=require("three");function $o(n,r,e){let t={parameters:n,type:n.type};if(n.type==="PathGeometry")t.path=n.path;else if(n.type==="VectorGeometry"){let i=Te.createFromState(n.shape,n.width,n.height);t.shape=i}else if(n.type==="NonParametricGeometry")n.data.groups&&n.data.groups.forEach(i=>i.materialIndex=Math.max(i.materialIndex??0,0)),t.geometry=new Eh.BufferGeometryLoader().parse(n);else{if(n.type==="SubdivGeometry")return new Je(n,e);if(n.type==="TextGeometry")return new si(n,r)}let o;try{o=ld(t)}catch(i){console.error(i)}if(!o){let i=Te.createFromState(gn.defaultData(),100,100);t.shape=i,o=ld(t)}return o}var Mh=require("three"),l_=new Mh.Matrix4;function us(n,r,e,t){let o=n.position.array,i=n.normal.array,s=l_.makeScale(r,e,t).invert().elements,l,c,u;for(var a=0,d=o.length;a<d;a+=3)o[a]*=r,o[a+1]*=e,o[a+2]*=t,l=i[a],c=i[a+1],u=i[a+2],i[a]=s[0]*l+s[4]*c+s[8]*u,i[a+1]=s[1]*l+s[5]*c+s[9]*u,i[a+2]=s[2]*l+s[6]*c+s[10]*u;n.position.needsUpdate=!0,n.normal.needsUpdate=!0}var bl=new Be.Box3,ci=new Be.Vector3,ue;li.then(n=>{ue=n});var Lh=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),Bh=new Uint32Array([0,1,2,3]),Dh=new Uint8Array([4]),Je=class extends Be.BufferGeometry{constructor(e,t){super();this.data=e;this.flatShading=t;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,t){this.freeSubdivPointer();let o=this.data.scaleBaked,i=co.div(t,o);this.subdividedGeometry&&us(this.subdividedGeometry.attributes,...i),this.originalGeometry&&us(this.originalGeometry.attributes,...i),this.data=e;let s=this.userData.parameters;this.userData.parameters={width:s.width*i[0],height:s.height*i[1],depth:s.depth*i[2]},this.originalGeometry.boundingSphere.center.multiply(ci.fromArray(i));let l=ci.set(s.width,s.height,s.depth).length();this.originalGeometry.boundingSphere.radius=l/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,t,o;try{({originalGeometry:e,subdividedGeometry:t,subdivPointer:o}=Je.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new Be.BoxGeometry(100,100,100),o=0}this.subdivPointer=o,this.originalGeometry=e,this.subdividedGeometry=t??void 0;let i=this.subdividedGeometry??this.originalGeometry;Object.assign(this,i),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(Je.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new Be.Sphere,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,o=e.boundingSphere.center;bl.setFromBufferAttribute(t),bl.getCenter(o),e.boundingSphere.radius=o.distanceTo(bl.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),bl.getSize(ci);let i={width:ci.x,height:ci.y,depth:ci.z};return this.userData.parameters=i,i}static build(e,t,o,i){let s,l,c,u=e?.phongAngle??35;o===!1&&(u=-1),t&&(ue.free_bvh(t),ue.free_subdivision_surface(t));try{s=Je.allocate(e,i)}catch(a){console.error(a,e),s=Je.allocate({positionWASM:Lh,indexWASM:Bh,verticesPerFaceWASM:Dh},i)}if(ue.set_destination_refinement_level(s,0),l=Je.buildLevel(s,!0,u),e.subdivisions>0)try{ue.set_destination_refinement_level(s,e.subdivisions),c=Je.buildLevel(s,!1,u)}catch{try{ue.set_destination_refinement_level(s,e.subdivisions-1),c=Je.buildLevel(s,!1,u)}catch{c=null}}else c=null;return{subdivPointer:s,originalGeometry:l,subdividedGeometry:c}}static primitiveToQuads(e,t,o){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let i;if(e.type==="TorusGeometry"&&e.arc===Math.PI*2){let{width:d,height:p,depth:f,arc:m,tubularSegments:h,radialSegments:y}=e;i=new Wo(!0,d,f,p,d*.5,m/(2*Math.PI),h,f/2,0,y,0,0,!0)}else i=e.shape!==void 0?t.geometry:$o(e,o,!1);let s,l,c,u;({positions:s,triIndices:u}=pd(i.getAttribute("position"),i.getIndex()));let a;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let d=e.radialSegments*e.heightSegments*3*2,p=d+e.radialSegments*3;a=[d,p]}return{indices:l,verticesPerFace:c}=fd(s,u,i,a),{positions:s,indices:l,verticesPerFace:c}}static allocate(e,t){let o,i,s,l=[],c=[];e.positionWASM&&e.positionWASM.length>0?(o=e.positionWASM,i=e.indexWASM,s=e.verticesPerFaceWASM):(o=Lh,i=Bh,s=Dh);let u=o.length,a=i.length,d=s.length,p=o.length+l.length+c.length,f=i.length+s.length,m=p*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,h=p*Float32Array.BYTES_PER_ELEMENT,y=f*Uint32Array.BYTES_PER_ELEMENT,g=ue._malloc(m),v=new Float32Array(ue.HEAPF32.buffer,g,p),w=new Uint32Array(ue.HEAPU32.buffer,g+h,f);v.set(o,0),v.set(l,o.length),v.set(c,o.length+l.length),w.set(i,0),w.set(s,i.length);let S;e?.scaleBaked?.some(T=>T!==1)&&(S=new Be.Matrix4().makeScale(...e.scaleBaked)),t&&(S?S.premultiply(t):S=t);let b=S?ue.alloc_subdivision_surface2(g,u,g+h,a,g+h+i.length*Uint32Array.BYTES_PER_ELEMENT,d,S.elements):ue.alloc_subdivision_surface(g,u,g+h,a,g+h+i.length*Uint32Array.BYTES_PER_ELEMENT,d);return ue._free(g),b}static buildLevel(e,t,o,i,s){let l=s?ue.get_mesh_data2(e,t?ue.Level.CONTROL:ue.Level.REFINED,o,s.elements):ue.get_mesh_data(e,t?ue.Level.CONTROL:ue.Level.REFINED,o),c=8,u=ue.HEAPU32.subarray(l>>2,(l>>2)+c),a=u.subarray(4,4+4),d=0,p=ue.HEAPU32[u[d]>>2],f=ue.HEAPF32.subarray(p>>2,(p>>2)+a[d]);d++;let m=ue.HEAPU32[u[d]>>2],h=ue.HEAPF32.subarray(m>>2,(m>>2)+a[d]);d++;let y=ue.HEAPU32[u[d]>>2],g=ue.HEAPU32.subarray(y>>2,(y>>2)+a[d]);d++;let v=ue.HEAPU32[u[d]>>2],w=ue.HEAPU32.subarray(v>>2,(v>>2)+a[d]);if(d++,i===void 0){let S=new Be.BufferGeometry;if(S.setIndex(new Be.Uint32BufferAttribute(w,1)),S.setAttribute("position",new Be.Float32BufferAttribute(f,3)),S.setAttribute("normal",new Be.Float32BufferAttribute(h,3)),t){S.setAttribute("faceMap",new Be.Uint32BufferAttribute(g,1));let b=new Float32Array(h.length/3*4).fill(0);S.setAttribute("color",new Be.BufferAttribute(b,4))}return ue.free_mesh_data(l),S.userData.type="SubdivGeometry",S}i.getAttribute("position").copyArray(f),i.getAttribute("normal").copyArray(h),i.attributes.position.needsUpdate=!0,i.attributes.normal.needsUpdate=!0,ue.free_mesh_data(l)}static freeSubdivPointer(e){ue.free_bvh(e),ue.free_subdivision_surface(e)}static buildControlCageWireframe(e,t,o){let i=ue.get_wireframe_data_for_base_level(e),s=4,l=ue.HEAPU32.subarray(i>>2,(i>>2)+s),c=l.subarray(2,2+2),u=0,a=ue.HEAPU32[l[u]>>2],d=ue.HEAPF32.subarray(a>>2,(a>>2)+c[u]);u++;let p=ue.HEAPU32[l[u]>>2],f=ue.HEAPU32.subarray(p>>2,(p>>2)+c[u]);if(t===void 0){let m=new Be.BufferGeometry;m.setAttribute("position",new Be.Float32BufferAttribute(d,3));let h=new Float32Array(d.length);for(let y=0,g=d.length;y<g;)h[y++]=o.r,h[y++]=o.g,h[y++]=o.b;return m.setAttribute("color",new Be.BufferAttribute(h,3)),m.setIndex(new Be.Uint32BufferAttribute(f,1)),ue.free_wireframe_data_for_base_level(i),m}t.getAttribute("position").copyArray(d),t.attributes.position.needsUpdate=!0,ue.free_wireframe_data_for_base_level(i)}static updateCollabMesh(e,t,o){let i=t===0;i||ue.set_destination_refinement_level(e,t);let s=o?ue.get_topological_data2(e,i?ue.Level.CONTROL:ue.Level.REFINED,o.elements):ue.get_topological_data(e,i?ue.Level.CONTROL:ue.Level.REFINED),l=6,c=ue.HEAPU32.subarray(s>>2,(s>>2)+l),u=c.subarray(3,3+3),a=0,d=ue.HEAPU32[c[a]>>2],p=new Float32Array(ue.HEAPF32.subarray(d>>2,(d>>2)+u[a]));a++;let f=ue.HEAPU32[c[a]>>2],m=new Uint32Array(ue.HEAPU32.subarray(f>>2,(f>>2)+u[a]));a++;let h=ue.HEAPU32[c[a]>>2],y=new Uint8Array(ue.HEAPU32.subarray(h>>2,(h>>2)+u[a]));return ue.free_topological_data(s),{positions:p,indices:m,verticesPerFace:y}}};var Gh=["getX","getY","getZ"];function pd(n,r){let e={},t=r?r.count:n.count,o=0,i=[],s=[],l=1e4;for(let u=0;u<t;u++){let a=r?r.getX(u):u,d="";for(let p=0;p<3;p++)d+=`${~~(n[Gh[p]](a)*l)},`;if(d in e)i.push(e[d]);else{for(let p=0;p<3;p++)s.push(n[Gh[p]](a));e[d]=o,i.push(o),o++}}let c=[];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]||c.push(i[u],i[u+1],i[u+2]);return{positions:s,triIndices:c}}var Sl=new Be.Vector3,cd=new Be.Vector3,dd=new Be.Vector3,ud=new Be.Vector3;function fd(n,r,e,t){let o=[],i=[];if(e.userData.shape!==void 0&&e.userData.parameters.depth===0&&e.userData.shape.shapeHoles.length===0){let s=e.userData.shape.extractShapePointsToFlatArray([]),l=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&l<=24&&l%4===0&&e.userData.parameters.angle>=360){let a=s.length/2/l;s=s.filter((d,p)=>Math.floor(p/2)%a===0)}let c=0;for(let a=0;a<s.length;a+=2)c+=(s[a]-s[(a===0?s.length:a)-2])*(s[a+1]+s[(a===0?s.length:a)-1]);n.length=0;let u=0;if(c<0)for(let a=0;a<s.length;a+=2)n.push(s[a],s[a+1],0),o.push(u++);else for(let a=s.length-2;a>=0;a-=2)n.push(s[a],s[a+1],0),o.push(u++);return i.push(u),{indices:o,verticesPerFace:i}}for(let s=0,l=e.capStartIndex??r.length;s<l;)if(r[s+1]===r[s+3]&&r[s+2]===r[s+5]||r[s+0]===r[s+3]&&r[s+2]===r[s+4]){Sl.set(n[r[s]*3],n[r[s]*3+1],n[r[s]*3+2]),cd.set(n[r[s+1]*3],n[r[s+1]*3+1],n[r[s+1]*3+2]),dd.set(n[r[s+4]*3],n[r[s+4]*3+1],n[r[s+4]*3+2]),ud.set(n[r[s+5]*3],n[r[s+5]*3+1],n[r[s+5]*3+2]),cd.sub(Sl).normalize(),dd.sub(Sl).normalize(),ud.sub(Sl).normalize();let c=cd.cross(dd).dot(ud);Math.abs(c)>.005||t&&t.some((u,a)=>a%2===1?!1:s>=t[a]&&s<t[a+1])?(o.push(r[s],r[s+1],r[s+2]),i.push(3),s+=3):(o.push(r[s],r[s+1],r[s+4],r[s+5]),i.push(4),s+=6)}else o.push(r[s],r[s+1],r[s+2]),i.push(3),s+=3;if(e.capStartIndex!==void 0){let s=[],l=[],c=0,u=new Float32Array([e.userData.parameters.depth])[0];for(let a=0,d=0;a<n.length;a+=3,d++)n[a+2]===0&&(s.push(d),c++),n[a+2]===u&&l.push(d);if(e.userData.parameters.extrudeBevelSize===0){let a=l[0];l[0]=l[1],l[1]=a}s.reverse(),o.push(...s,...l),i.push(c,c)}return{indices:o,verticesPerFace:i}}var hr={};Zd(hr,{calcBoolean:()=>p_,calcBooleanTopological:()=>u_,freeMeshSet:()=>h_,getMeshSet:()=>f_,transformMeshSet:()=>m_});var c_,Rh=new Promise(n=>{c_=n});var ps=require("three");var xe,di;Rh.then(n=>xe=n);function d_(n,r,e){let t,{positions:o,triIndices:i}=pd(n.getAttribute("position"),n.getIndex()),s;if(r&&e){let{indices:l,verticesPerFace:c}=fd(o,i,n);s=c.length,t=[];for(let u=0,a=0;u<s;u++){t.push(c[u]);for(let d=0;d<c[u];d++)t.push(l[a++])}}else{let l=i.length;t=Array(l+l/3),s=0;for(let c=0,u=0;u<t.length;)t[u++]=3,s++,t[u++]=i[c++],t[u++]=i[c++],t[u++]=i[c++]}return{positions:o,faceIndices:t,nFaces:s}}function Vh(n){let r=n.length,e=r*Uint32Array.BYTES_PER_ELEMENT,t=r*Float32Array.BYTES_PER_ELEMENT,o=Number.isInteger(n[0])?e:t,i=xe._malloc(o);return(Number.isInteger(n[0])?new Uint32Array(xe.HEAPU32.buffer,i,r):new Float32Array(xe.HEAPF32.buffer,i,r)).set(n,0),i}function jh(n){switch(n){case 0:return xe.OP.UNION;case 1:return xe.OP.INTERSECTION;case 2:return xe.OP.A_MINUS_B;case 3:return xe.OP.B_MINUS_A;case 4:return xe.OP.SYMMETRIC_DIFFERENCE;case 5:return xe.OP.ALL;default:throw new Error("Unknown boolean operation "+n)}}function u_(n,r){di===void 0&&(di=xe.init_csg());let e=Vh(n),t=xe.csg_calc_topological(di,e,n.length,jh(r));xe._free(e);let o=6,i=xe.HEAPU32.subarray(t>>2,(t>>2)+o),s=i.subarray(3,3+3),l=0,c=xe.HEAPU32[i[l]>>2],u=new Float32Array(xe.HEAPF32.subarray(c>>2,(c>>2)+s[l]));l++;let a=xe.HEAPU32[i[l]>>2],d=new Uint32Array(xe.HEAPU32.subarray(a>>2,(a>>2)+s[l]));l++;let p=xe.HEAPU32[i[l]>>2],f=new Uint8Array(xe.HEAPU32.subarray(p>>2,(p>>2)+s[l]));return xe.free_mesh_data(t),{positions:u,indices:d,verticesPerFace:f}}function p_(n,r,e,t){di===void 0&&(di=xe.init_csg());let o=Vh(n),i=xe.csg_calc(di,o,n.length,t,jh(r));xe._free(o);let s=5,l=xe.HEAPU32.subarray(i>>2,(i>>2)+s),c=l.subarray(2,2+3),u=0,a=xe.HEAPU32[l[u]>>2],d=xe.HEAPF32.subarray(a>>2,(a>>2)+c[u]);u++;let p=xe.HEAPU32[l[u]>>2],f=xe.HEAPF32.subarray(p>>2,(p>>2)+c[u]);u++;let m=c[u];e.setAttribute("position",new ps.Float32BufferAttribute(d,3)),e.setAttribute("normal",new ps.Float32BufferAttribute(f,3));let h=xe.HEAPF32.subarray((i>>2)+5,(i>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new ps.Sphere),e.boundingSphere.center.set(h[0],h[1],h[2]),e.boundingSphere.radius=(h[3]**2+h[4]**2+h[5]**2)**.5,e.userData.parameters={width:h[3]*2,height:h[4]*2,depth:h[5]*2},xe.free_mesh_data(i),m}function f_(n,r,e){if(xe===void 0)return-1;let t,o,i;if(r&&n.userData.positions!==void 0){let y=n.userData;i=y.verticesPerFace.length,t=y.positions,o=Array(y.verticesPerFace.reduce((g,v)=>g+v,0)+i);for(let g=0,v=0,w=0;g<y.verticesPerFace.length;g++){o[w++]=y.verticesPerFace[g];for(let S=0;S<y.verticesPerFace[g];S++)o[w++]=y.indices[v++]}}else({positions:t,faceIndices:o,nFaces:i}=d_(n,r,e));let s=t.length,l=o.length,c=t.length,u=o.length,a=c*Float32Array.BYTES_PER_ELEMENT+u*Uint32Array.BYTES_PER_ELEMENT,d=c*Float32Array.BYTES_PER_ELEMENT,p=u*Uint32Array.BYTES_PER_ELEMENT,f=xe._malloc(a),m=new Float32Array(xe.HEAPF32.buffer,f,c),h=new Uint32Array(xe.HEAPU32.buffer,f+d,u);return m.set(t,0),h.set(o,0),xe.get_csg_mesh(f,s,f+d,l,i)}function m_(n,r){xe.transform_csg_mesh(n,r.elements)}function h_(n){xe.free_csg_mesh(n)}var y_={ConeGeometry:Bm,CubeGeometry:Dm,CylinderGeometry:Mm,DodecahedronGeometry:Rm,EllipseGeometry:oi,HelixGeometry:lh,IcosahedronGeometry:dh,LatheGeometry:uh,NonParametricGeometry:ph,PolygonGeometry:gl,PyramidGeometry:fh,RectangleGeometry:xl,SphereGeometry:hh,PlaneGeometry:gh,BackdropGeometry:xh,StarGeometry:vl,TextFrameGeometry:bh,TorusGeometry:Sh,TorusKnotGeometry:_h,TriangleGeometry:Th,PathGeometry:Oh,VectorGeometry:Vt},ld=n=>y_[n.type].create(n);function fs(n){return n!==null&&"booleanOp"in n}var ui=class extends al(wl.Mesh){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new wl.Matrix4}updateVisible(){super.updateVisible(),this.visible=!fs(this.parent)&&this.visible,fs(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(hr.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),fs(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof ui&&(e.freeBooleanPointer(),fs(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e){let t=super.updateTransformState(e);return t&&fs(this.parent)&&this.invalidateDownstreamBooleanData(!0),t}};var _l=new pi.Box3;function ms(n,r=0,e=n.count,t,o){let i=1/0,s=1/0,l=1/0,c=-1/0,u=-1/0,a=-1/0;for(let d=r;d<e;d++){let p=n.getX(d),f=n.getY(d),m=n.getZ(d);p<i&&(i=p),f<s&&(s=f),m<l&&(l=m),p>c&&(c=p),f>u&&(u=f),m>a&&(a=m)}_l.min.set(i,s,l),_l.max.set(c,u,a),_l.getCenter(t),_l.getSize(o).multiplyScalar(.5)}var g_=new pi.BufferGeometry,x_=new pi.MeshBasicMaterial,gt=class extends ui{constructor(r,e){super(g_,x_),this.super_Entity(r,e)}updateState(r,e){this.updateState_Entity(r,e)}updateEntityBoxSize(r,e){let t=this.geometry.getAttribute("position");t!==void 0?ms(t,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:t.count,r,e):super.updateEntityBoxSize(r,e)}};var ro=require("three");var Xt=require("three");var ry=require("three");var gr=require("three");var hs=class{constructor(r){r=r??{},this.name=r.name,this.type=r.type,this.node=r.node,this.size=r.size,this.needsUpdate=r.needsUpdate}get value(){return this.node.value}set value(r){this.node.value=r}};var Fh=require("three"),pt=class{constructor(r){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=Fh.MathUtils.generateUUID(),this.type=r,this.name=""}analyze(r,e){e=e??{},r.analyzing=!0,this.build(r.addFlow(e.slot,e.cache,e.context),"v4"),r.clearVertexNodeCode(),r.clearFragmentNodeCode(),r.removeFlow(),r.analyzing=!1}analyzeAndFlow(r,e,t){return t=t??{},this.analyze(r,t),this.flow(r,e,t)}flow(r,e,t){t=t??{},r.addFlow(t.slot,t.cache,t.context);let o={result:this.build(r,e),code:r.clearNodeCode(),extra:r.context.extra};return r.removeFlow(),o}build(r,e,t){e=e??this.getType(r,e);let o=r.getNodeData(t??this);return r.analyzing&&this.appendDepsNode(r,o,e),r.nodes.indexOf(this)===-1&&r.nodes.push(this),this.updateFrame!==void 0&&r.updaters.indexOf(this)===-1&&r.updaters.push(this),this.generate(r,e,t)}updateFrame(r){}generateReadonly(r,e,t,o,i,s){return""}generate(r,e,t,o,i){return""}parse(r,e,t,o){}appendDepsNode(r,e,t){e.deps=(e.deps||0)+1;let o=r.getTypeLength(t);(o>(e.outputMax||0)||this.getType(r,t))&&(e.outputMax=o,e.output=t)}setName(r){this.name=r}getName(){return this.name}getType(r,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}getHash(){let r="{",e,t;for(e in this)t=this[e],t instanceof pt&&(r+='"'+e+'":'+t.getHash()+",");if(this.hashProperties)for(let o=0;o<this.hashProperties.length;o++)e=this.hashProperties[o],t=this[e],r+='"'+e+'":"'+String(t)+'",';return r+='"id":"'+this.uuid+'"}',r}};var md=class{constructor(){this.nodes={};this.keywords={}}add(r){this.nodes[r.name]=r}addKeyword(r,e,t){t=t!==void 0?t:!0,this.keywords[r]={callback:e,cache:t}}remove(r){delete this.nodes[r.name]}removeKeyword(r){delete this.keywords[r]}get(r){return this.nodes[r]}getKeyword(r,e){return this.keywords[r].callback(e)}getKeywordData(r){return this.keywords[r]}contains(r){return this.nodes[r]!==void 0}containsKeyword(r){return this.keywords[r]!==void 0}},it=new md;var hd=require("three");var zh=require("three"),ce=class extends pt{constructor(e,t){super(e);this.scope="";t=t??{},this.shared=t.shared!==void 0?t.shared:!0,this.unique=t.unique!==void 0?t.unique:!1}build(e,t,o,i){if(t=t??this.getType(e),this.getShared(e,t)){let s=this.getUnique(e,t);s&&this.uuid===void 0&&(this.uuid=zh.MathUtils.generateUUID()),o=e.getUUID(o??this.getUUID(),!s);let l=e.getNodeData(o),c=l.output||this.getType(e);if(e.analyzing)return(l.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,l,t),this.generate(e,t,o)):super.build(e,t,o);if(s)return l.name=l.name||super.build(e,t,o),l.name;if(!this.getLabel()&&(!this.getShared(e,c)||e.context.ignoreCache||l.deps===1))return super.build(e,t,o);o=this.getUUID(!1);let u=this.getTemp(e,o);if(u)return e.format(u,c,t);{u=super.generate(e,t,o,l.output,i);let a=this.generate(e,c,o);return e.addNodeCode(u+" = "+a+";"),e.format(u,c,t)}}return super.build(e,t,o)}getShared(e,t){return t!=="sampler2D"&&t!=="samplerCube"&&this.shared}getUnique(e,t){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let t=this.uuid;return typeof this.scope=="string"&&(t=this.scope+"-"+t),t}getTemp(e,t){t=t||this.uuid;let o=e.getVars()[t];return o?o.name:void 0}generate(e,t,o,i,s){return this.getShared(e,t)||console.error("TempNode is not shared"),o=o??this.uuid,e.getTempVar(o,i??this.getType(e),s,this.getLabel()).name}};var De=class extends ce{constructor(e,t){t=t??{},t.shared=t.shared!==void 0?t.shared:!1;super(e,t);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,t,o,i,s,l){o=e.getUUID(o??this.getUUID()),i=i??this.getType(e);let c=e.getNodeData(o);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,t,o,i,s,l):e.isShader("vertex")?(c.vertex||(c.vertex=e.createVertexUniform(i,this,s,l,this.getLabel())),e.format(c.vertex.name,i,t)):(c.fragment||(c.fragment=e.createFragmentUniform(i,this,s,l,this.getLabel())),e.format(c.fragment.name,i,t))}};var ft=class extends De{constructor(e=0,t){super("v2");this.nodeType="Vector2";this.value=e instanceof hd.Vector2?e:new hd.Vector2(e,t)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,t,o,i,s,l){return e.format("vec2("+this.value.x+", "+this.value.y+")",i,t)}};var yd=require("three");var xt=class extends De{constructor(e=0,t,o){super("v3");this.nodeType="Vector3";this.value=e instanceof yd.Vector3?e:new yd.Vector3(e,t,o)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,t,o,i,s,l){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",i,t)}};var Uh=require("three"),st=class extends Uh.Color{constructor(e,t,o,i){super(e,t,o);this.isColorA=!0;this.a=i}setRGBA(e,t,o,i){super.setRGB(e,t,o),this.a=i}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}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 er=class extends De{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof st?e:new st(e.r,e.g,e.b,e.a)}generateReadonly(e,t,o,i,s,l){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",i,t)}};var v_=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,kh=/[a-z_0-9]+/gi,Q=class extends ce{constructor(e,t,o,i,s){super(s);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=s===void 0,this.isInterface=!1,this.parse(e,t,o,i)}getShared(e,t){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}}getIncludeByName(e){if(this.includes){let t=this.includes.length;for(;t--;)if(this.includes[t].name===e)return this.includes[t]}}generate(e,t,o,i,s){let l,c=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 a=[];for(;l=kh.exec(this.src);)a.push(l);for(let d=0;d<a.length;d++){let p=a[d],f=p[0],m=this.isMethod?!this.getInputByName(f):!0,h=f;if(this.keywords[f]||this.useKeywords&&m&&it.containsKeyword(f)){let y=this.keywords[f];if(!y){let g=it.getKeywordData(f);g.cache&&(y=e.keywords[f]),y=y||it.getKeyword(f,e),g.cache&&(e.keywords[f]=y)}h=y.build(e)}f!==h&&u[p.index+c-1]!=="."&&(u=u.substring(0,p.index+c)+h+u.substring(p.index+f.length+c),c+=h.length-f.length),this.getIncludeByName(h)===void 0&&it.contains(h)&&e.include(it.get(h))}return t==="source"?u:this.isMethod?(this.isInterface||e.include(this,void 0,u),this.name):e.format("( "+u+" )",this.getType(e),t)}parse(e,t,o,i){if(this.src=e||"",this.includes=t??[],this.extensions=o??{},this.keywords=i??{},this.isMethod){let s=v_.exec(this.src);if(this.inputs=[],s&&s.length==4){this.type=s[1],this.name=s[2];let l=s[3].match(kh);if(l){let c=0;for(;c<l.length;){let u=l[c++],a;u==="in"||u==="out"||u==="inout"?a=l[c++]:(a=u,u="");let d=l[c++];this.inputs.push({name:d,type:a,qualifier:u})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var b_=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,gd=class extends ce{constructor(e="",t){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||gd.PI,void 0,void 0,void 0,t)}getType(e){return e.getTypeByFormat(this.type)}parse(e,t,o,i,s){this.src=e||"";let l,c,u="",a=b_.exec(e);this.useDefine=s??this.src.charAt(0)==="#",a&&a.length>1?(c=a[1],l=a[2],u=a[3]):(l=this.src,c="f"),this.name=l,this.type=c,this.value=u}build(e,t){if(t==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),t)}generate(e,t,o,i,s){return e.format(this.name,this.getType(e),t)}},_e=gd;_e.PI="PI",_e.PI2="PI2",_e.RECIPROCAL_PI="RECIPROCAL_PI",_e.RECIPROCAL_PI2="RECIPROCAL_PI2",_e.LOG2="LOG2",_e.EPSILON="EPSILON";var S_=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
4
+ )*?)}`,"gim"),w_=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),fi=class extends ce{constructor(e=""){super();this.inputs=[];this.src="";this.nodeType="Struct";this.parse(e)}getType(e){return e.getTypeByFormat(this.name)}getInputByName(e){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}generate(e,t,o,i,s){return t==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),t)}parse(e=""){this.src=e,this.inputs=[];let t=S_.exec(e);if(t){let o=t[2],i;for(;i=w_.exec(o);)this.inputs.push({type:i[1],name:i[2]});this.name=t[1]}else this.name="";this.type=this.name}};var mi=class extends ce{constructor(e){super("v2",{shared:!1});this.nodeType="UV";this.index=e??0}generate(e,t){e.requires.uv[this.index]=!0;let o=this.index>0?this.index+1:"",i=e.isShader("vertex")?"uv"+o:"vUv"+o;return e.format(i,this.getType(e),t)}};it.addKeyword("uv",function(){return new mi});it.addKeyword("uv2",function(){return new mi(1)});var Tl=require("three");var Yo=class extends ce{constructor(e,t){super("v4");this.nodeType="ColorSpace";this.input=e,this.method=t??Yo.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case Tl.LinearEncoding:return["Linear"];case Tl.sRGBEncoding:return["sRGB"];default:return[]}}generate(e,t){let o=this.input.build(e,"v4"),i=this.getType(e),s=Yo.Nodes[this.method],l=e.include(s);if(l===Yo.LINEAR_TO_LINEAR)return e.format(o,i,t);if(s.inputs?.length===2){let c=this.factor.build(e,"f");return e.format(l+"( "+o+", "+c+" )",i,t)}else return e.format(l+"( "+o+" )",i,t)}fromEncoding(e){let t=Yo.getEncodingComponents(e);this.method="LinearTo"+t[0],this.factor=t[1]}fromDecoding(e){let t=Yo.getEncodingComponents(e);this.method=t[0]+"ToLinear",this.factor=t[1]}},At=Yo;At.Nodes={LinearToLinear:new Q(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
5
+ `)),sRGBToLinear:new Q(["vec4 sRGBToLinear( in vec4 value ) {"," return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );","}"].join(`
6
+ `)),LinearTosRGB:new Q(["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(`
7
+ `))},At.LINEAR_TO_LINEAR="LinearToLinear",At.SRGB_TO_LINEAR="sRGBToLinear",At.LINEAR_TO_SRGB="LinearTosRGB";var Ae=class extends Q{constructor(e="",t,o,i,s){super(e,s,i,o,t);this.nodeType="Expression"}};var Hh=require("three"),jt=class extends De{constructor(e=new Hh.Texture,t,o,i){super("v4",{shared:!0});this.nodeType="Texture";this.value=e,this.uv=t??new mi,this.bias=o,this.project=i!==void 0?i:!1}getTexture(e,t){return super.generate(e,t,this.value.uuid,"t")}generate(e,t){if(t==="sampler2D")return this.getTexture(e,t);let o=this.getTexture(e,t),i=this.uv.build(e,this.project?"v4":"v2"),s=this.bias?this.bias.build(e,"f"):void 0;s===void 0&&e.context.bias&&(s=e.context.bias.setTexture(this).build(e,"f"));let l,c;this.project?l="texture2DProj":l=s?"tex2DBias":"tex2D",s?c=l+"( "+o+", "+i+", "+s+" )":c=l+"( "+o+", "+i+" )";let u={include:e.isShader("vertex"),ignoreCache:!0},a=this.getType(e);return e.addContext(u),this.colorSpace=this.colorSpace??new At(new Ae("",a)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(c),c=this.colorSpace.build(e,a),e.removeContext(),e.format(c,a,t)}};var J=class extends De{constructor(e){super("f");this.nodeType="Float";this.value=e??0}generateReadonly(e,t,o,i,s,l){return e.format(this.value+(this.value%1?"":".0"),i,t)}};var ys=class extends ce{constructor(e,t){super();this.inputs=[];this.nodeType="FunctionCall";this.value=e,this.inputs=t??[]}getFunction(){return this.value}getType(e){return this.value.getType(e)}generate(e,t,o,i,s){i=this.getType(e);let l=this.value,c=l.build(e,t)+"( ",u=[];if(l.inputs){for(let a=0;a<l.inputs.length;a++){let d=l.inputs[a],p=this.inputs[a]||this.inputs[d.name];u.push(p.build(e,e.getTypeByFormat(d.type)))}c+=u.join(", ")+" )"}return e.format(c,i,t)}};var xd=class extends ce{constructor(e,t,o=xd.ADD){super();this.nodeType="Operator";this.type=e.type,this.a=e,this.b=t,this.op=o}getType(e){let t=this.a.getType(e),o=this.b.getType(e);return e.isTypeMatrix(t)?"v4":e.getTypeLength(o)>e.getTypeLength(t)?o:t}generate(e,t){let o=this.getType(e);this.type=o;let i=this.a.build(e,o),s=this.b.build(e,o);return e.format("( "+i+" "+this.op+" "+s+" )",o,t)}},Ft=xd;Ft.ADD="+",Ft.SUB="-",Ft.MUL="*",Ft.DIV="/";var Me=class extends ce{constructor(e,t=Me.ABS,o,i){super();this.nodeType="Math";this.a=e,typeof t!="string"?this.b=t:i=t,typeof o!="string"?this.c=o:i=o,this.method=i,this.hashProperties=["method"]}getNumInputs(e){switch(this.method){case Me.MIX:case Me.CLAMP:case Me.REFRACT:case Me.SMOOTHSTEP:case Me.FACEFORWARD:return 3;case Me.MIN:case Me.MAX:case Me.MOD:case Me.STEP:case Me.REFLECT:case Me.DISTANCE:case Me.DOT:case Me.CROSS:case Me.POW:return 2;default:return 1}}getInputType(e){let t=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 t>o&&t>i?this.a.getType(e):o>i?this.b.getType(e):this.c.getType(e)}getType(e){switch(this.method){case Me.LENGTH:case Me.DISTANCE:case Me.DOT:return"f";case Me.CROSS:return"v3"}return this.getInputType(e)}generate(e,t){let o,i,s,l=this.a?e.getTypeLength(this.a.getType(e)):0,c=this.b?e.getTypeLength(this.b.getType(e)):0,u=this.c?e.getTypeLength(this.c.getType(e)):0,a=this.getInputType(e),d=this.getType(e);switch(this.type=d,this.method){case Me.NEGATE:return e.format("( -"+this.a.build(e,a)+" )",a,t);case Me.INVERT:return e.format("( 1.0 - "+this.a.build(e,a)+" )",a,t);case Me.CROSS:o=this.a.build(e,"v3"),i=this.b.build(e,"v3");break;case Me.STEP:o=this.a.build(e,l===1?"f":a),i=this.b.build(e,a);break;case Me.MIN:case Me.MAX:case Me.MOD:o=this.a.build(e,a),i=this.b.build(e,c===1?"f":a);break;case Me.REFRACT:o=this.a.build(e,a),i=this.b.build(e,a),s=this.c.build(e,"f");break;case Me.MIX:o=this.a.build(e,a),i=this.b.build(e,a),s=this.c.build(e,u===1?"f":a);break;default:o=this.a.build(e,a),this.b&&(i=this.b.build(e,a)),this.c&&(s=this.c.build(e,a));break}let p=[];p.push(o),i&&p.push(i),s&&p.push(s);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,t)}},me=Me;me.RAD="radians",me.DEG="degrees",me.EXP="exp",me.EXP2="exp2",me.LOG="log",me.LOG2="log2",me.SQRT="sqrt",me.INV_SQRT="inversesqrt",me.FLOOR="floor",me.CEIL="ceil",me.NORMALIZE="normalize",me.FRACT="fract",me.SATURATE="saturate",me.SIN="sin",me.COS="cos",me.TAN="tan",me.ASIN="asin",me.ACOS="acos",me.ARCTAN="atan",me.ABS="abs",me.SIGN="sign",me.LENGTH="length",me.NEGATE="negate",me.INVERT="invert",me.MIN="min",me.MAX="max",me.MOD="mod",me.STEP="step",me.REFLECT="reflect",me.DISTANCE="distance",me.DOT="dot",me.CROSS="cross",me.POW="pow",me.MIX="mix",me.CLAMP="clamp",me.REFRACT="refract",me.SMOOTHSTEP="smoothstep",me.FACEFORWARD="faceforward";var hi=class extends ce{constructor(e,t,o){super("v4");this.nodeType="TextureCubeUV";this.value=e,this.uv=t,this.bias=o}bilinearCubeUV(e,t,o,i){let s=new ys(hi.Nodes.bilinearCubeUV,[t,o,i]);this.colorSpaceTL=this.colorSpaceTL??new At(new Ae("","v4")),this.colorSpaceTL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTL.input.parse(s.build(e)+".tl"),this.colorSpaceTR=this.colorSpaceTR??new At(new Ae("","v4")),this.colorSpaceTR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTR.input.parse(s.build(e)+".tr"),this.colorSpaceBL=this.colorSpaceBL??new At(new Ae("","v4")),this.colorSpaceBL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBL.input.parse(s.build(e)+".bl"),this.colorSpaceBR=this.colorSpaceBR??new At(new Ae("","v4")),this.colorSpaceBR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBR.input.parse(s.build(e)+".br");let l={include:e.isShader("vertex"),ignoreCache:!0};e.addContext(l),this.colorSpaceTLExp=new Ae(this.colorSpaceTL.build(e,"v4"),"v4"),this.colorSpaceTRExp=new Ae(this.colorSpaceTR.build(e,"v4"),"v4"),this.colorSpaceBLExp=new Ae(this.colorSpaceBL.build(e,"v4"),"v4"),this.colorSpaceBRExp=new Ae(this.colorSpaceBR.build(e,"v4"),"v4"),e.removeContext();let c=new Ae("mix( mix( cubeUV_TL, cubeUV_TR, cubeUV.f.x ), mix( cubeUV_BL, cubeUV_BR, cubeUV.f.x ), cubeUV.f.y )","v4");return c.keywords.cubeUV_TL=this.colorSpaceTLExp,c.keywords.cubeUV_TR=this.colorSpaceTRExp,c.keywords.cubeUV_BL=this.colorSpaceBLExp,c.keywords.cubeUV_BR=this.colorSpaceBRExp,c.keywords.cubeUV=s,c}generate(e,t){if(e.isShader("fragment")){let o=this.uv,i=this.bias||e.context.roughness,s=new ys(hi.Nodes.roughnessToMip,[i]),l=new me(s,hi.Nodes.m0,hi.Nodes.cubeUV_maxMipLevel,me.CLAMP),c=new me(l,me.FLOOR),u=new me(l,me.FRACT),a=this.bilinearCubeUV(e,this.value,o,c),d=this.bilinearCubeUV(e,this.value,o,new Ft(c,new J(1).setReadonly(!0),Ft.ADD)),p=new me(a,d,u,me.MIX);return e.format(p.build(e),"v4",t)}else return console.warn("TextureCubeUVNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),t)}},yi=hi;yi.Nodes=function(){let e=new fi(`struct TextureCubeUVData {
8
8
  vec4 tl;
9
9
  vec4 tr;
10
10
  vec4 br;
11
11
  vec4 bl;
12
12
  vec2 f;
13
- }`),t=new we("float cubeUV_maxMipLevel 8.0",!0),o=new we("float cubeUV_minMipLevel 4.0",!0),i=new we("float cubeUV_maxTileSize 256.0",!0),s=new we("float cubeUV_minTileSize 16.0",!0),l=new X(`float getFace(vec3 direction) {
13
+ }`),t=new _e("float cubeUV_maxMipLevel 8.0",!0),o=new _e("float cubeUV_minMipLevel 4.0",!0),i=new _e("float cubeUV_maxTileSize 256.0",!0),s=new _e("float cubeUV_minTileSize 16.0",!0),l=new Q(`float getFace(vec3 direction) {
14
14
  vec3 absDirection = abs(direction);
15
15
  float face = -1.0;
16
16
  if (absDirection.x > absDirection.z) {
@@ -25,7 +25,7 @@
25
25
  face = direction.y > 0.0 ? 1.0 : 4.0;
26
26
  }
27
27
  return face;
28
- }`);l.useKeywords=!1;let c=new X(`vec2 getUV(vec3 direction, float face) {
28
+ }`);l.useKeywords=!1;let c=new Q(`vec2 getUV(vec3 direction, float face) {
29
29
  vec2 uv;
30
30
  if (face == 0.0) {
31
31
  uv = vec2(direction.z, direction.y) / abs(direction.x); // pos x
@@ -41,7 +41,7 @@
41
41
  uv = vec2(direction.x, direction.y) / abs(direction.z); // neg z
42
42
  }
43
43
  return 0.5 * (uv + 1.0);
44
- }`);c.useKeywords=!1;let u=new X(`TextureCubeUVData bilinearCubeUV(sampler2D envMap, vec3 direction, float mipInt) {
44
+ }`);c.useKeywords=!1;let u=new Q(`TextureCubeUVData bilinearCubeUV(sampler2D envMap, vec3 direction, float mipInt) {
45
45
  float face = getFace(direction);
46
46
  float filterInt = max(cubeUV_minMipLevel - mipInt, 0.0);
47
47
  mipInt = max(mipInt, cubeUV_minMipLevel);
@@ -69,7 +69,7 @@
69
69
  uv.x -= texelSize;
70
70
  vec4 bl = texture2D(envMap, uv);
71
71
  return TextureCubeUVData( tl, tr, br, bl, f );
72
- }`,[e,l,c,t,o,i,s]);u.useKeywords=!1;let a=new we("float r0 1.0",!0),d=new we("float v0 0.339",!0),p=new we("float m0 -2.0",!0),f=new we("float r1 0.8",!0),m=new we("float v1 0.276",!0),h=new we("float m1 -1.0",!0),y=new we("float r4 0.4",!0),g=new we("float v4 0.046",!0),v=new we("float m4 2.0",!0),w=new we("float r5 0.305",!0),b=new we("float v5 0.016",!0),S=new we("float m5 3.0",!0),A=new we("float r6 0.21",!0),_=new we("float v6 0.0038",!0),x=new we("float m6 4.0",!0),P=[a,d,p,f,m,h,y,g,v,w,b,S,A,_,x],O=new X(`float roughnessToMip(float roughness) {
72
+ }`,[e,l,c,t,o,i,s]);u.useKeywords=!1;let a=new _e("float r0 1.0",!0),d=new _e("float v0 0.339",!0),p=new _e("float m0 -2.0",!0),f=new _e("float r1 0.8",!0),m=new _e("float v1 0.276",!0),h=new _e("float m1 -1.0",!0),y=new _e("float r4 0.4",!0),g=new _e("float v4 0.046",!0),v=new _e("float m4 2.0",!0),w=new _e("float r5 0.305",!0),S=new _e("float v5 0.016",!0),b=new _e("float m5 3.0",!0),T=new _e("float r6 0.21",!0),_=new _e("float v6 0.0038",!0),x=new _e("float m6 4.0",!0),C=[a,d,p,f,m,h,y,g,v,w,S,b,T,_,x],P=new Q(`float roughnessToMip(float roughness) {
73
73
  float mip = 0.0;
74
74
  if (roughness >= r1) {
75
75
  mip = (r0 - roughness) * (m1 - m0) / (r0 - r1) + m0;
@@ -83,7 +83,7 @@
83
83
  mip = -2.0 * log2(1.16 * roughness);// 1.16 = 1.79^0.25
84
84
  }
85
85
  return mip;
86
- }`,P);return{bilinearCubeUV:u,roughnessToMip:O,m0:p,cubeUV_maxMipLevel:t}}();var $o=class extends ce{constructor(e){super("v3");this.nodeType="Normal";this.scope=e??$o.VIEW}getShared(){return this.scope===$o.WORLD}build(e,t,o,i){let s=e.context[this.scope+"Normal"];return s?s.build(e,t,o,i):super.build(e,t,o)}generate(e,t,o,i,s){let l;switch(this.scope){case $o.VIEW:e.isShader("vertex")?l="transformedNormal":l="geometryNormal";break;case $o.LOCAL:e.isShader("vertex")?l="objectNormal":(e.requires.normal=!0,l="vObjectNormal");break;case $o.WORLD:e.isShader("vertex")?l="inverseTransformDirection( transformedNormal, viewMatrix ).xyz":(e.requires.worldNormal=!0,l="vWNormal");break}return e.format(l,this.getType(e),t)}},pt=$o;pt.LOCAL="local",pt.WORLD="world",pt.VIEW="view",pt.NORMAL="normal";nt.addKeyword("viewNormal",function(){return new pt(pt.VIEW)});nt.addKeyword("localNormal",function(){return new pt(pt.NORMAL)});nt.addKeyword("worldNormal",function(){return new pt(pt.WORLD)});var Nr=class extends ce{constructor(e){super("v3");this.nodeType="Position";this.scope=e??Nr.LOCAL}getType(){switch(this.scope){case Nr.PROJECTION:return"v4"}return this.type}getShader(){switch(this.scope){case Nr.LOCAL:case Nr.WORLD:return!1}return!0}generate(e,t,o,i,s){let l;switch(this.scope){case Nr.LOCAL:e.isShader("vertex")?l="transformed":(e.requires.position=!0,l="vPosition");break;case Nr.WORLD:if(e.isShader("vertex"))return"( modelMatrix * vec4( transformed, 1.0 ) ).xyz";e.requires.worldPosition=!0,l="vWPosition";break;case Nr.VIEW:l=e.isShader("vertex")?"-mvPosition.xyz":"vViewPosition";break;case Nr.PROJECTION:l=e.isShader("vertex")?"( projectionMatrix * modelViewMatrix * vec4( position, 1.0 ) )":"vec4( 0.0 )";break}return e.format(l,this.getType(),t)}},jt=Nr;jt.LOCAL="local",jt.WORLD="world",jt.VIEW="view",jt.PROJECTION="projection";nt.addKeyword("position",function(){return new jt});nt.addKeyword("worldPosition",function(){return new jt(jt.WORLD)});nt.addKeyword("viewPosition",function(){return new jt(jt.VIEW)});var pr=class extends ce{constructor(e){super("v3");this.nodeType="Reflect";this.scope=e??pr.CUBE}getUnique(e){return!e.context.viewNormal}getType(){switch(this.scope){case pr.SPHERE:return"v2"}return this.type}generate(e,t){let o=this.getUnique(e);if(e.isShader("fragment")){let i;switch(this.scope){case pr.VECTOR:{let s=new pt(pt.VIEW),l=e.context.roughness,c=s.build(e,"v3"),u=new jt(jt.VIEW).build(e,"v3"),a=l?l.build(e,"f"):void 0,d=`reflect( -normalize( ${u} ), ${c} )`;a&&(d=`normalize( mix( ${d}, ${c}, ${a} * ${a} ) )`);let p=`inverseTransformDirection( ${d}, viewMatrix )`;o?(e.addNodeCode(`vec3 reflectVec = ${p};`),i="reflectVec"):i=p;break}case pr.CUBE:{let s=new pr(pr.VECTOR).build(e,"v3"),l="vec3( -"+s+".x, "+s+".yz )";o?(e.addNodeCode(`vec3 reflectCubeVec = ${l};`),i="reflectCubeVec"):i=l;break}case pr.SPHERE:{let l="normalize( ( viewMatrix * vec4( "+new pr(pr.VECTOR).build(e,"v3")+", 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) ).xy * 0.5 + 0.5";o?(e.addNodeCode(`vec2 reflectSphereVec = ${l};`),i="reflectSphereVec"):i=l;break}}return e.format(i,this.getType(),t)}else return console.warn("ReflectNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.type,t)}},Er=pr;Er.CUBE="cube",Er.SPHERE="sphere",Er.VECTOR="vector";var dl=class extends ce{constructor(e=new Rt,t,o){super("v4");this.nodeType="TextureCube";this.value=e,this.radianceNode=new di(this.value,t??new Er(Er.VECTOR),o),this.irradianceNode=new di(this.value,new pt(pt.WORLD),new Q(1).setReadonly(!0))}generate(e,t){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,t)):(console.warn("TextureCubeNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),t))}};var Ph=require("three");var ul=class extends Ge{constructor(e=new Ph.CubeTexture,t,o){super("v4",{shared:!0});this.nodeType="CubeTexture";this.value=e,this.uv=t??new Er,this.bias=o}getTexture(e,t){return super.generate(e,t,this.value.uuid,"tc")}generate(e,t){if(t==="samplerCube")return this.getTexture(e,t);let o=this.getTexture(e,t),i=this.uv?.build(e,"v3"),s=this.bias?this.bias.build(e,"f"):void 0;s===void 0&&e.context.bias&&(s=e.context.bias.setTexture(this).build(e,"f"));let l;s?l="texCubeBias( "+o+", "+i+", "+s+" )":l="texCube( "+o+", "+i+" )";let c={include:e.isShader("vertex"),ignoreCache:!0},u=this.getType(e);return e.addContext(c),this.colorSpace=this.colorSpace??new Ot(new Pe("",u)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(l),l=this.colorSpace.build(e,u),e.removeContext(),e.format(l,u,t)}};var Ih=["x","y","z","w"],o_=["float","vec2","vec3","vec4"],n_={float:"f",vec2:"v2",vec3:"v3",vec4:"v4",mat4:"v4",int:"i",bool:"b","float[]":"f[]","vec4[]":"v4[]"},i_={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[]"},pl=class{constructor(){this.includes={consts:{},functions:{},structs:{}};this.cache="";this.slot="";this.shader="";this.context={};this.getIncludesCode=function(){function r(e,t){return e.deps.length-t.deps.length}return function(t,o){let i=this.getIncludes(t,o);if(!i)return"";let s="";i=i.sort(r);for(let l=0;l<i.length;l++)i[l].src&&(s+=i[l].src+`
86
+ }`,C);return{bilinearCubeUV:u,roughnessToMip:P,m0:p,cubeUV_maxMipLevel:t}}();var Xo=class extends ce{constructor(e){super("v3");this.nodeType="Normal";this.scope=e??Xo.VIEW}getShared(){return this.scope===Xo.WORLD}build(e,t,o,i){let s=e.context[this.scope+"Normal"];return s?s.build(e,t,o,i):super.build(e,t,o)}generate(e,t,o,i,s){let l;switch(this.scope){case Xo.VIEW:e.isShader("vertex")?l="transformedNormal":l="geometryNormal";break;case Xo.LOCAL:e.isShader("vertex")?l="objectNormal":(e.requires.normal=!0,l="vObjectNormal");break;case Xo.WORLD:e.isShader("vertex")?l="inverseTransformDirection( transformedNormal, viewMatrix ).xyz":(e.requires.worldNormal=!0,l="vWNormal");break}return e.format(l,this.getType(e),t)}},mt=Xo;mt.LOCAL="local",mt.WORLD="world",mt.VIEW="view",mt.NORMAL="normal";it.addKeyword("viewNormal",function(){return new mt(mt.VIEW)});it.addKeyword("localNormal",function(){return new mt(mt.NORMAL)});it.addKeyword("worldNormal",function(){return new mt(mt.WORLD)});var Lr=class extends ce{constructor(e){super("v3");this.nodeType="Position";this.scope=e??Lr.LOCAL}getType(){switch(this.scope){case Lr.PROJECTION:return"v4"}return this.type}getShader(){switch(this.scope){case Lr.LOCAL:case Lr.WORLD:return!1}return!0}generate(e,t,o,i,s){let l;switch(this.scope){case Lr.LOCAL:e.isShader("vertex")?l="transformed":(e.requires.position=!0,l="vPosition");break;case Lr.WORLD:if(e.isShader("vertex"))return"( modelMatrix * vec4( transformed, 1.0 ) ).xyz";e.requires.worldPosition=!0,l="vWPosition";break;case Lr.VIEW:l=e.isShader("vertex")?"-mvPosition.xyz":"vViewPosition";break;case Lr.PROJECTION:l=e.isShader("vertex")?"( projectionMatrix * modelViewMatrix * vec4( position, 1.0 ) )":"vec4( 0.0 )";break}return e.format(l,this.getType(),t)}},zt=Lr;zt.LOCAL="local",zt.WORLD="world",zt.VIEW="view",zt.PROJECTION="projection";it.addKeyword("position",function(){return new zt});it.addKeyword("worldPosition",function(){return new zt(zt.WORLD)});it.addKeyword("viewPosition",function(){return new zt(zt.VIEW)});var yr=class extends ce{constructor(e){super("v3");this.nodeType="Reflect";this.scope=e??yr.CUBE}getUnique(e){return!e.context.viewNormal}getType(){switch(this.scope){case yr.SPHERE:return"v2"}return this.type}generate(e,t){let o=this.getUnique(e);if(e.isShader("fragment")){let i;switch(this.scope){case yr.VECTOR:{let s=new mt(mt.VIEW),l=e.context.roughness,c=s.build(e,"v3"),u=new zt(zt.VIEW).build(e,"v3"),a=l?l.build(e,"f"):void 0,d=`reflect( -normalize( ${u} ), ${c} )`;a&&(d=`normalize( mix( ${d}, ${c}, ${a} * ${a} ) )`);let p=`inverseTransformDirection( ${d}, viewMatrix )`;o?(e.addNodeCode(`vec3 reflectVec = ${p};`),i="reflectVec"):i=p;break}case yr.CUBE:{let s=new yr(yr.VECTOR).build(e,"v3"),l="vec3( -"+s+".x, "+s+".yz )";o?(e.addNodeCode(`vec3 reflectCubeVec = ${l};`),i="reflectCubeVec"):i=l;break}case yr.SPHERE:{let l="normalize( ( viewMatrix * vec4( "+new yr(yr.VECTOR).build(e,"v3")+", 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) ).xy * 0.5 + 0.5";o?(e.addNodeCode(`vec2 reflectSphereVec = ${l};`),i="reflectSphereVec"):i=l;break}}return e.format(i,this.getType(),t)}else return console.warn("ReflectNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.type,t)}},Br=yr;Br.CUBE="cube",Br.SPHERE="sphere",Br.VECTOR="vector";var Pl=class extends ce{constructor(e=new jt,t,o){super("v4");this.nodeType="TextureCube";this.value=e,this.radianceNode=new yi(this.value,t??new Br(Br.VECTOR),o),this.irradianceNode=new yi(this.value,new mt(mt.WORLD),new J(1).setReadonly(!0))}generate(e,t){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,t)):(console.warn("TextureCubeNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),t))}};var Wh=require("three");var Ol=class extends De{constructor(e=new Wh.CubeTexture,t,o){super("v4",{shared:!0});this.nodeType="CubeTexture";this.value=e,this.uv=t??new Br,this.bias=o}getTexture(e,t){return super.generate(e,t,this.value.uuid,"tc")}generate(e,t){if(t==="samplerCube")return this.getTexture(e,t);let o=this.getTexture(e,t),i=this.uv?.build(e,"v3"),s=this.bias?this.bias.build(e,"f"):void 0;s===void 0&&e.context.bias&&(s=e.context.bias.setTexture(this).build(e,"f"));let l;s?l="texCubeBias( "+o+", "+i+", "+s+" )":l="texCube( "+o+", "+i+" )";let c={include:e.isShader("vertex"),ignoreCache:!0},u=this.getType(e);return e.addContext(c),this.colorSpace=this.colorSpace??new At(new Ae("",u)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(l),l=this.colorSpace.build(e,u),e.removeContext(),e.format(l,u,t)}};var qh=["x","y","z","w"],__=["float","vec2","vec3","vec4"],T_={float:"f",vec2:"v2",vec3:"v3",vec4:"v4",mat4:"v4",int:"i",bool:"b","float[]":"f[]","vec4[]":"v4[]"},P_={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[]"},Al=class{constructor(){this.includes={consts:{},functions:{},structs:{}};this.cache="";this.slot="";this.shader="";this.context={};this.getIncludesCode=function(){function r(e,t){return e.deps.length-t.deps.length}return function(t,o){let i=this.getIncludes(t,o);if(!i)return"";let s="";i=i.sort(r);for(let l=0;l<i.length;l++)i[l].src&&(s+=i[l].src+`
87
87
  `);return s}}();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",`
88
88
  // NOTE: Include Spline's blending modes. This could be part of BlendNode
89
89
  #define SPE_BLENDING_NORMAL 0
@@ -128,7 +128,7 @@
128
128
  `}addVaryCode(r){this.addVertexParsCode(r),this.addFragmentParsCode(r)}isCache(r){return this.caches.indexOf(r)!==-1}isSlot(r){return this.slots.indexOf(r)!==-1}define(r,e){this.defines[r]=e===void 0?1:e}require(r){this.requires[r]=!0}isDefined(r){return this.defines[r]!==void 0}getVar(r,e,t,o="varying",i="V",s=""){let l=this.getVars(o),c=l[r];if(!c){let u=l.length;c={name:t||"node"+i+u+(s?"_"+s:""),type:e},l.push(c),l[r]=c}return c}getTempVar(r,e,t,o){return this.getVar(r,e,t,this.shader,"T",o)}getAttribute(r,e){if(!this.attributes[r]){let t=this.getVar(r,e);this.addVertexParsCode("attribute "+e+" "+r+";"),this.addVertexFinalCode(t.name+" = "+r+";"),this.attributes[r]={varying:t,name:r,type:e}}return this.attributes[r]}getCode(r){return[this.prefixCode,this.parsCode[r],this.getVarListCode(this.getVars("varying"),"varying"),this.getVarListCode(this.inputs.uniforms[r],"uniform"),this.getVarListCode(this.inputs.arrayUniforms[r],"uniform"),this.getIncludesCode("consts",r),this.getIncludesCode("structs",r),this.getIncludesCode("functions",r),"void main() {",this.getVarListCode(this.getVars(r)),this.code[r],this.resultCode[r],this.finalCode[r],"}"].join(`
129
129
  `)}getVarListCode(r,e){e=e??"";let t="";for(let o=0,i=r.length;o<i;++o){let s=r[o],l=s.type,c=s.name,u=s.size,a=this.getFormatByType(l);if(a===void 0)throw new Error("Node pars "+a+" not found.");a.includes("[]")?t+=e+" "+a.substring(0,a.length-2)+" "+c+`[${u}];
130
130
  `:t+=e+" "+a+" "+c+`;
131
- `}return t}getVars(r){return this.inputs.vars[r??this.shader]}getNodeData(r){let e=r instanceof dt?r.uuid:r;return this.nodeData[e]=this.nodeData[e]||{}}createUniform(r,e,t,o,i,s){if(e.includes("[]")){let l=this.inputs.arrayUniforms,c=l.list.length,u=new as({type:e,size:t.size,name:o||"nodeUA"+c+(s?"_"+s:""),node:t,needsUpdate:i});return l.list.push(u),l[r].push(u),l[r][u.name]=u,this.uniforms[u.name]=u,u}else{let l=this.inputs.uniforms,c=l.list.length,u=new as({type:e,name:o||"nodeU"+c+(s?"_"+s:""),node:t,needsUpdate:i});return l.list.push(u),l[r].push(u),l[r][u.name]=u,this.uniforms[u.name]=u,u}}createVertexUniform(r,e,t,o,i){return this.createUniform("vertex",r,e,t,o,i)}createFragmentUniform(r,e,t,o,i){return this.createUniform("fragment",r,e,t,o,i)}include(r,e,t){let o;if(r=typeof r=="string"?nt.get(r):r,this.context.include===!1)return r.name;r instanceof X?o=this.includes.functions:r instanceof we?o=this.includes.consts:r instanceof ai&&(o=this.includes.structs);let i=o[this.shader]=o[this.shader]||[];if(r){let s=i[r.name];if(s||(s=i[r.name]={node:r,deps:[]},i.push(s),s.src=r.build(this,"source")),r instanceof X&&e&&i[e.name]&&i[e.name].deps.indexOf(r)===-1&&(i[e.name].deps.push(r),r.includes?.length)){let l=0;do this.include(r.includes[l++],e);while(l<r.includes.length)}return t&&(s.src=t),r.name}else throw new Error("Include not found.")}colorToVectorProperties(r){return r.replace("r","x").replace("g","y").replace("b","z").replace("a","w")}colorToVector(r){return r.replace(/c/g,"v3")}getIncludes(r,e){return this.includes[r][e||this.shader]}getConstructorFromLength(r){return o_[r-1]}isTypeMatrix(r){return/^m/.test(r)}getTypeLength(r){return r==="f"?1:parseInt(this.colorToVector(r).substr(1))}getTypeFromLength(r){return r===1?"f":"v"+r}findNode(...r){for(let e=0;e<arguments.length;e++){let t=r[e];if(t?.isNode)return t}}resolve(...r){for(let e=0;e<arguments.length;e++){let t=r[e];if(t!==void 0){if(t.isNode)return t;if(t.isTexture)switch(t.mapping){case fr.CubeReflectionMapping:case fr.CubeRefractionMapping:return new ul(t);case fr.CubeUVReflectionMapping:return new dl(new Rt(t));default:return new Rt(t)}else{if(t.isVector2)return new ut(t);if(t.isVector3)return new yt(t);if(t.isVector4)return new Qt(t)}}}}format(r,e,t){switch(this.colorToVector(t+" <- "+e)){case"f <- v2":return r+".x";case"f <- v3":return r+".x";case"f <- v4":return r+".x";case"f <- i":case"f <- b":return"float( "+r+" )";case"v2 <- f":return"vec2( "+r+" )";case"v2 <- v3":return r+".xy";case"v2 <- v4":return r+".xy";case"v2 <- i":case"v2 <- b":return"vec2( float( "+r+" ) )";case"v3 <- f":return"vec3( "+r+" )";case"v3 <- v2":return"vec3( "+r+", 0.0 )";case"v3 <- v4":return r+".xyz";case"v3 <- i":case"v3 <- b":return"vec2( float( "+r+" ) )";case"v4 <- f":return"vec4( "+r+" )";case"v4 <- v2":return"vec4( "+r+", 0.0, 1.0 )";case"v4 <- v3":return"vec4( "+r+", 1.0 )";case"v4 <- i":case"v4 <- b":return"vec4( float( "+r+" ) )";case"i <- f":case"i <- b":return"int( "+r+" )";case"i <- v2":return"int( "+r+".x )";case"i <- v3":return"int( "+r+".x )";case"i <- v4":return"int( "+r+".x )";case"b <- f":return"( "+r+" != 0.0 )";case"b <- v2":return"( "+r+" != vec2( 0.0 ) )";case"b <- v3":return"( "+r+" != vec3( 0.0 ) )";case"b <- v4":return"( "+r+" != vec4( 0.0 ) )";case"b <- i":return"( "+r+" != 0 )"}return r}getTypeByFormat(r){return n_[r]||r}getFormatByType(r){return i_[r]||r}getUUID(r,e){return e=e!==void 0?e:!0,e&&this.cache&&(r=this.cache+"-"+r),r}getElementByIndex(r){return Ih[r]}getIndexByElement(r){return Ih.indexOf(r)}isShader(r){return this.shader===r}setShader(r){return this.shader=r,this}mergeDefines(r){for(let e in r)this.defines[e]=r[e];return this.defines}mergeUniform(r){for(let e in r)this.uniforms[e]=r[e];return this.uniforms}getTextureEncodingFromMap(r){let e;return r?r.isTexture&&(e=r.encoding):e=fr.LinearEncoding,e===fr.LinearEncoding&&this.context.gamma&&(e=fr.sRGBEncoding),e}};var je=require("three");var Ie=class extends Ge{constructor(e=0,t,o,i){super("c");this.nodeType="Color";this.value=e instanceof it?e:new it(e||0,t,o,i)}setRGBA(e){this.value.setRGBA(e.r,e.g,e.b,e.a)}generate(e,t,o,i,s,l){o=e.getUUID(o??this.getUUID()),i=i??this.getType(e);let c=e.getNodeData(o),u=this.getReadonly()&&this.generateReadonly!==void 0;if(this.alpha){let a=this.alpha.build(e,"f");e.addFragmentNodeCode(`accumAlpha += ( 1.0 - accumAlpha ) * ${a};`)}return u?this.generateReadonly(e,t,o,i,s,l):e.isShader("vertex")?(c.vertex||(c.vertex=e.createVertexUniform(i,this,s,l,this.getLabel())),e.format(c.vertex.name,i,t)):(c.fragment||(c.fragment=e.createFragmentUniform(i,this,s,l,this.getLabel())),e.format(c.fragment.name,i,t))}generateReadonly(e,t,o,i,s,l){return e.format("vec3("+this.value.r+", "+this.value.g+", "+this.value.b+")",i,t)}};var be=class extends Ge{constructor(e){super("i");this.nodeType="Int";this.value=Math.floor(e??0)}generateReadonly(e,t,o,i,s,l){return e.format(this.value.toString(),i,t)}};var fl=require("three");var Yo=class extends dt{constructor(){super("basic");this.nodeType="Basic";this.color=new Ie(5855577),this.shadingAlpha=new Q(1),this.shadingBlend=new be(0)}get category(){return"phong"}generate(e){let t;if(e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(fl.UniformsUtils.merge([fl.UniformsLib.fog])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>"].join(`
131
+ `}return t}getVars(r){return this.inputs.vars[r??this.shader]}getNodeData(r){let e=r instanceof pt?r.uuid:r;return this.nodeData[e]=this.nodeData[e]||{}}createUniform(r,e,t,o,i,s){if(e.includes("[]")){let l=this.inputs.arrayUniforms,c=l.list.length,u=new hs({type:e,size:t.size,name:o||"nodeUA"+c+(s?"_"+s:""),node:t,needsUpdate:i});return l.list.push(u),l[r].push(u),l[r][u.name]=u,this.uniforms[u.name]=u,u}else{let l=this.inputs.uniforms,c=l.list.length,u=new hs({type:e,name:o||"nodeU"+c+(s?"_"+s:""),node:t,needsUpdate:i});return l.list.push(u),l[r].push(u),l[r][u.name]=u,this.uniforms[u.name]=u,u}}createVertexUniform(r,e,t,o,i){return this.createUniform("vertex",r,e,t,o,i)}createFragmentUniform(r,e,t,o,i){return this.createUniform("fragment",r,e,t,o,i)}include(r,e,t){let o;if(r=typeof r=="string"?it.get(r):r,this.context.include===!1)return r.name;r instanceof Q?o=this.includes.functions:r instanceof _e?o=this.includes.consts:r instanceof fi&&(o=this.includes.structs);let i=o[this.shader]=o[this.shader]||[];if(r){let s=i[r.name];if(s||(s=i[r.name]={node:r,deps:[]},i.push(s),s.src=r.build(this,"source")),r instanceof Q&&e&&i[e.name]&&i[e.name].deps.indexOf(r)===-1&&(i[e.name].deps.push(r),r.includes?.length)){let l=0;do this.include(r.includes[l++],e);while(l<r.includes.length)}return t&&(s.src=t),r.name}else throw new Error("Include not found.")}colorToVectorProperties(r){return r.replace("r","x").replace("g","y").replace("b","z").replace("a","w")}colorToVector(r){return r.replace(/c/g,"v3")}getIncludes(r,e){return this.includes[r][e||this.shader]}getConstructorFromLength(r){return __[r-1]}isTypeMatrix(r){return/^m/.test(r)}getTypeLength(r){return r==="f"?1:parseInt(this.colorToVector(r).substr(1))}getTypeFromLength(r){return r===1?"f":"v"+r}findNode(...r){for(let e=0;e<arguments.length;e++){let t=r[e];if(t?.isNode)return t}}resolve(...r){for(let e=0;e<arguments.length;e++){let t=r[e];if(t!==void 0){if(t.isNode)return t;if(t.isTexture)switch(t.mapping){case gr.CubeReflectionMapping:case gr.CubeRefractionMapping:return new Ol(t);case gr.CubeUVReflectionMapping:return new Pl(new jt(t));default:return new jt(t)}else{if(t.isVector2)return new ft(t);if(t.isVector3)return new xt(t);if(t.isVector4)return new er(t)}}}}format(r,e,t){switch(this.colorToVector(t+" <- "+e)){case"f <- v2":return r+".x";case"f <- v3":return r+".x";case"f <- v4":return r+".x";case"f <- i":case"f <- b":return"float( "+r+" )";case"v2 <- f":return"vec2( "+r+" )";case"v2 <- v3":return r+".xy";case"v2 <- v4":return r+".xy";case"v2 <- i":case"v2 <- b":return"vec2( float( "+r+" ) )";case"v3 <- f":return"vec3( "+r+" )";case"v3 <- v2":return"vec3( "+r+", 0.0 )";case"v3 <- v4":return r+".xyz";case"v3 <- i":case"v3 <- b":return"vec2( float( "+r+" ) )";case"v4 <- f":return"vec4( "+r+" )";case"v4 <- v2":return"vec4( "+r+", 0.0, 1.0 )";case"v4 <- v3":return"vec4( "+r+", 1.0 )";case"v4 <- i":case"v4 <- b":return"vec4( float( "+r+" ) )";case"i <- f":case"i <- b":return"int( "+r+" )";case"i <- v2":return"int( "+r+".x )";case"i <- v3":return"int( "+r+".x )";case"i <- v4":return"int( "+r+".x )";case"b <- f":return"( "+r+" != 0.0 )";case"b <- v2":return"( "+r+" != vec2( 0.0 ) )";case"b <- v3":return"( "+r+" != vec3( 0.0 ) )";case"b <- v4":return"( "+r+" != vec4( 0.0 ) )";case"b <- i":return"( "+r+" != 0 )"}return r}getTypeByFormat(r){return T_[r]||r}getFormatByType(r){return P_[r]||r}getUUID(r,e){return e=e!==void 0?e:!0,e&&this.cache&&(r=this.cache+"-"+r),r}getElementByIndex(r){return qh[r]}getIndexByElement(r){return qh.indexOf(r)}isShader(r){return this.shader===r}setShader(r){return this.shader=r,this}mergeDefines(r){for(let e in r)this.defines[e]=r[e];return this.defines}mergeUniform(r){for(let e in r)this.uniforms[e]=r[e];return this.uniforms}getTextureEncodingFromMap(r){let e;return r?r.isTexture&&(e=r.encoding):e=gr.LinearEncoding,e===gr.LinearEncoding&&this.context.gamma&&(e=gr.sRGBEncoding),e}};var Ve=require("three");var Ie=class extends De{constructor(e=0,t,o,i){super("c");this.nodeType="Color";this.value=e instanceof st?e:new st(e||0,t,o,i)}setRGBA(e){this.value.setRGBA(e.r,e.g,e.b,e.a)}generate(e,t,o,i,s,l){o=e.getUUID(o??this.getUUID()),i=i??this.getType(e);let c=e.getNodeData(o),u=this.getReadonly()&&this.generateReadonly!==void 0;if(this.alpha){let a=this.alpha.build(e,"f");e.addFragmentNodeCode(`accumAlpha += ( 1.0 - accumAlpha ) * ${a};`)}return u?this.generateReadonly(e,t,o,i,s,l):e.isShader("vertex")?(c.vertex||(c.vertex=e.createVertexUniform(i,this,s,l,this.getLabel())),e.format(c.vertex.name,i,t)):(c.fragment||(c.fragment=e.createFragmentUniform(i,this,s,l,this.getLabel())),e.format(c.fragment.name,i,t))}generateReadonly(e,t,o,i,s,l){return e.format("vec3("+this.value.r+", "+this.value.g+", "+this.value.b+")",i,t)}};var be=class extends De{constructor(e){super("i");this.nodeType="Int";this.value=Math.floor(e??0)}generateReadonly(e,t,o,i,s,l){return e.format(this.value.toString(),i,t)}};var Il=require("three");var Ko=class extends pt{constructor(){super("basic");this.nodeType="Basic";this.color=new Ie(5855577),this.shadingAlpha=new J(1),this.shadingBlend=new be(0)}get category(){return"phong"}generate(e){let t;if(e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(Il.UniformsUtils.merge([Il.UniformsLib.fog])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>"].join(`
132
132
  `));let i=["#include <beginnormal_vertex>",`
133
133
  #if !defined( USE_LAYER_DISPLACE )
134
134
  #include <defaultnormal_vertex>
@@ -148,7 +148,7 @@
148
148
  `];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;"),t=i.join(`
149
149
  `)}else{this.color===void 0&&(this.color=new Ie(5855577)),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,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(`
150
150
  `));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};`),i?l.push(`gl_FragColor = vec4( finalColor, accumAlpha * ${i.result} );`):l.push("gl_FragColor = vec4("+o.result+", 1.0 );"),l.push("#include <fog_fragment>","#include <dithering_fragment>"),t=l.join(`
151
- `)}return t}};var cs=require("three");var mr=class extends Ge{constructor(e=1,t){super("f[]");this.nodeType="FloatArray";this.size=e,this.value=Array.isArray(t)?t:typeof t=="number"?new Array(e).fill(t):new Array(e).fill(0)}};var gt={normalRenderTarget:new Rt,normalRenderTargetDepth:new Rt,transmissionRenderTarget:new Rt,transmissionSize:new ut(2048,2048),transmissionRenderTargetDepth:new Rt,pixelRatioNode:new Q(1),resolution:new ut,penumbraSize:new mr(5,.5)};for(let n of Object.values(gt))n.isRenderGlobal=!0;var ds=class extends dt{constructor(){super("lambert");this.nodeType="Lambert";this.color=new Ie(5855577),this.emissive=new Ie(0),this.emissiveIntensity=new Q(1),this.shadingAlpha=new Q(1),this.shadingBlend=new be(0)}get category(){return"lambert"}build(e){let t;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(cs.UniformsUtils.merge([cs.UniformsLib.fog,cs.UniformsLib.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(`
151
+ `)}return t}};var gs=require("three");var xr=class extends De{constructor(e=1,t){super("f[]");this.nodeType="FloatArray";this.size=e,this.value=Array.isArray(t)?t:typeof t=="number"?new Array(e).fill(t):new Array(e).fill(0)}};var vt={normalRenderTarget:new jt,normalRenderTargetDepth:new jt,transmissionRenderTarget:new jt,transmissionSize:new ft(2048,2048),transmissionRenderTargetDepth:new jt,pixelRatioNode:new J(1),resolution:new ft,penumbraSize:new xr(5,.5)};for(let n of Object.values(vt))n.isRenderGlobal=!0;var xs=class extends pt{constructor(){super("lambert");this.nodeType="Lambert";this.color=new Ie(5855577),this.emissive=new Ie(0),this.emissiveIntensity=new J(1),this.shadingAlpha=new J(1),this.shadingBlend=new be(0)}get category(){return"lambert"}build(e){let t;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(gs.UniformsUtils.merge([gs.UniformsLib.fog,gs.UniformsLib.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(`
152
152
  `));let i=["#include <beginnormal_vertex>",`
153
153
  #ifndef USE_LAYER_DISPLACE
154
154
  #include <defaultnormal_vertex>
@@ -240,7 +240,7 @@
240
240
  #pragma unroll_loop_end
241
241
  #endif
242
242
  `," #include <shadowmap_vertex>"," #include <fog_vertex>"),i.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),t=i.join(`
243
- `)}else{e.mergeUniform({penumbraSize:gt.penumbraSize}),this.color===void 0&&(this.color=new Ie(5855577)),this.color.analyze(e,{slot:"color"}),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e);let o=this.color.flow(e,"c",{slot:"color"}),i=this.emissive.flow(e,"c",{slot:"emissive"}),s=this.emissiveIntensity.flow(e,"f",{slot:"emissive"}),l=this.shadingAlpha.flow(e,"f"),c=this.shadingBlend.flow(e,"i"),u=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,a=this.alpha?this.alpha.flow(e,"f"):void 0;e.requires.transparent=a!==void 0,e.addParsCode([`uniform float penumbraSize[${5}];`,"varying vec3 vViewPosition;","varying vec3 vWPosition;","varying vec3 vLightFront;","varying vec3 vIndirectFront;","#ifndef DOUBLE_SIDED"," #define DOUBLE_SIDED","#endif","#include <normal_pars_fragment>","#ifdef DOUBLE_SIDED"," varying vec3 vLightBack;"," varying vec3 vIndirectBack;","#endif","#include <bsdfs>","#include <lights_pars_begin>","#include <fog_pars_fragment>","#include <shadowmap_pars_fragment>","#include <shadowmask_pars_fragment>","#include <clipping_planes_pars_fragment>","#include <dithering_pars_fragment>"].join(`
243
+ `)}else{e.mergeUniform({penumbraSize:vt.penumbraSize}),this.color===void 0&&(this.color=new Ie(5855577)),this.color.analyze(e,{slot:"color"}),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e);let o=this.color.flow(e,"c",{slot:"color"}),i=this.emissive.flow(e,"c",{slot:"emissive"}),s=this.emissiveIntensity.flow(e,"f",{slot:"emissive"}),l=this.shadingAlpha.flow(e,"f"),c=this.shadingBlend.flow(e,"i"),u=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,a=this.alpha?this.alpha.flow(e,"f"):void 0;e.requires.transparent=a!==void 0,e.addParsCode([`uniform float penumbraSize[${5}];`,"varying vec3 vViewPosition;","varying vec3 vWPosition;","varying vec3 vLightFront;","varying vec3 vIndirectFront;","#ifndef DOUBLE_SIDED"," #define DOUBLE_SIDED","#endif","#include <normal_pars_fragment>","#ifdef DOUBLE_SIDED"," varying vec3 vLightBack;"," varying vec3 vIndirectBack;","#endif","#include <bsdfs>","#include <lights_pars_begin>","#include <fog_pars_fragment>","#include <shadowmap_pars_fragment>","#include <shadowmask_pars_fragment>","#include <clipping_planes_pars_fragment>","#include <dithering_pars_fragment>"].join(`
244
244
  `));let d=["#include <normal_fragment_begin>",`
245
245
  // NOTE: gl_FrontFacing alternative using face normal estimation.
246
246
  vec3 viewdx = dFdx(vViewPosition);
@@ -254,7 +254,7 @@
254
254
  outgoingLight = spe_blend( diffuseColor, outgoingLight, ${l.result}, ${c.result} );
255
255
  }
256
256
  `),u&&d.push(u.code,`outgoingLight = spe_blend(outgoingLight, ${u.result}, 1.0, SPE_BLENDING_NORMAL);`),a?d.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${a.result} );`):d.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),d.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),t=d.join(`
257
- `)}return t}};var us=require("three");var ml=class extends dt{constructor(){super("phong");this.nodeType="Phong";this.color=new Ie(5855577),this.specular=new Ie(1118481),this.shininess=new Q(30),this.shadingAlpha=new Q(1),this.shadingBlend=new be(0)}get category(){return"phong"}build(e){let t;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(us.UniformsUtils.merge([us.UniformsLib.fog,us.UniformsLib.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(`
257
+ `)}return t}};var vs=require("three");var Cl=class extends pt{constructor(){super("phong");this.nodeType="Phong";this.color=new Ie(5855577),this.specular=new Ie(1118481),this.shininess=new J(30),this.shadingAlpha=new J(1),this.shadingBlend=new be(0)}get category(){return"phong"}build(e){let t;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(vs.UniformsUtils.merge([vs.UniformsLib.fog,vs.UniformsLib.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(`
258
258
  `));let i=["#include <beginnormal_vertex>",`
259
259
  #ifndef USE_LAYER_DISPLACE
260
260
  #include <defaultnormal_vertex>
@@ -273,7 +273,7 @@
273
273
  #include <begin_vertex>
274
274
  #endif
275
275
  `];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 <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;"," #include <worldpos_vertex>"," #include <shadowmap_vertex>"," #include <fog_vertex>"),i.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),t=i.join(`
276
- `)}else{e.mergeUniform({penumbraSize:gt.penumbraSize}),this.color===void 0&&(this.color=new Ie(5855577)),this.color.analyze(e,{slot:"color"}),this.specular.analyze(e),this.shininess.analyze(e),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e);let o=this.color.flow(e,"c",{slot:"color"}),i=this.specular.flow(e,"c"),s=this.shininess.flow(e,"f"),l=this.shadingAlpha.flow(e,"f"),c=this.shadingBlend.flow(e,"i"),u=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,a=this.alpha?this.alpha.flow(e,"f"):void 0;e.requires.transparent=a!==void 0,e.addParsCode(["varying vec3 vWPosition;","uniform vec3 emissive;",`uniform float penumbraSize[${5}];`,"#include <normal_pars_fragment>","#include <fog_pars_fragment>","#include <bsdfs>","#include <lights_pars_begin>","#include <lights_phong_pars_fragment>","#include <shadowmap_pars_fragment>","#include <dithering_pars_fragment>"].join(`
276
+ `)}else{e.mergeUniform({penumbraSize:vt.penumbraSize}),this.color===void 0&&(this.color=new Ie(5855577)),this.color.analyze(e,{slot:"color"}),this.specular.analyze(e),this.shininess.analyze(e),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e);let o=this.color.flow(e,"c",{slot:"color"}),i=this.specular.flow(e,"c"),s=this.shininess.flow(e,"f"),l=this.shadingAlpha.flow(e,"f"),c=this.shadingBlend.flow(e,"i"),u=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,a=this.alpha?this.alpha.flow(e,"f"):void 0;e.requires.transparent=a!==void 0,e.addParsCode(["varying vec3 vWPosition;","uniform vec3 emissive;",`uniform float penumbraSize[${5}];`,"#include <normal_pars_fragment>","#include <fog_pars_fragment>","#include <bsdfs>","#include <lights_pars_begin>","#include <lights_phong_pars_fragment>","#include <shadowmap_pars_fragment>","#include <dithering_pars_fragment>"].join(`
277
277
  `));let d=["#include <normal_fragment_begin>",`
278
278
  // NOTE: gl_FrontFacing alternative using face normal estimation.
279
279
  vec3 viewdx = dFdx(vViewPosition);
@@ -289,7 +289,7 @@
289
289
  outgoingLight = spe_blend( diffuseColor, outgoingLight, ${l.result}, ${c.result} );
290
290
  }
291
291
  `),u&&d.push(u.code,`outgoingLight = spe_blend(outgoingLight, ${u.result}, 1.0, SPE_BLENDING_NORMAL);`),a?d.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${a.result} );`):d.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),d.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),t=d.join(`
292
- `)}return t}};var ui=require("three");var ps=class extends dt{constructor(){super("standard");this.nodeType="Standard";this.color=new Ie(5855577),this.roughness=new Q(.3),this.metalness=new Q(0),this.reflectivity=new Q(.5),this.shadingAlpha=new Q(1),this.shadingBlend=new be(0)}get category(){return"physical"}build(e){let t;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(ui.UniformsUtils.merge([ui.UniformsLib.fog,ui.UniformsLib.lights])),ui.UniformsLib.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(`
292
+ `)}return t}};var gi=require("three");var bs=class extends pt{constructor(){super("standard");this.nodeType="Standard";this.color=new Ie(5855577),this.roughness=new J(.3),this.metalness=new J(0),this.reflectivity=new J(.5),this.shadingAlpha=new J(1),this.shadingBlend=new be(0)}get category(){return"physical"}build(e){let t;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(gi.UniformsUtils.merge([gi.UniformsLib.fog,gi.UniformsLib.lights])),gi.UniformsLib.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(`
293
293
  `));let i=["#include <beginnormal_vertex>",`
294
294
  #if !defined( USE_LAYER_DISPLACE )
295
295
  #include <defaultnormal_vertex>
@@ -307,7 +307,7 @@
307
307
  #include <begin_vertex>
308
308
  #endif /* !USE_LAYER_DISPLACE */
309
309
  `];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>","#include <shadowmap_vertex>"),i.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),t=i.join(`
310
- `)}else{e.mergeUniform({penumbraSize:gt.penumbraSize});let o={gamma:!0};this.color===void 0&&(this.color=new Ie(5855577)),this.color.analyze(e,{slot:"color",context:o}),this.roughness.analyze(e),this.metalness.analyze(e),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e),this.reflectivity&&this.reflectivity.analyze(e);let i=this.color.flow(e,"c",{slot:"color",context:o}),s=this.roughness.flow(e,"f"),l=this.metalness.flow(e,"f"),c=this.shadingAlpha.flow(e,"f"),u=this.shadingBlend.flow(e,"i"),a=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,d=this.alpha?this.alpha.flow(e,"f"):void 0,p=this.reflectivity?this.reflectivity.flow(e,"f"):void 0;e.requires.transparent=d!==void 0,e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;",`uniform float penumbraSize[${5}];`,"#include <normal_pars_fragment>","#include <dithering_pars_fragment>","#include <fog_pars_fragment>","#include <bsdfs>","#include <lights_pars_begin>","#include <lights_physical_pars_fragment>","#include <shadowmap_pars_fragment>"].join(`
310
+ `)}else{e.mergeUniform({penumbraSize:vt.penumbraSize});let o={gamma:!0};this.color===void 0&&(this.color=new Ie(5855577)),this.color.analyze(e,{slot:"color",context:o}),this.roughness.analyze(e),this.metalness.analyze(e),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e),this.reflectivity&&this.reflectivity.analyze(e);let i=this.color.flow(e,"c",{slot:"color",context:o}),s=this.roughness.flow(e,"f"),l=this.metalness.flow(e,"f"),c=this.shadingAlpha.flow(e,"f"),u=this.shadingBlend.flow(e,"i"),a=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,d=this.alpha?this.alpha.flow(e,"f"):void 0,p=this.reflectivity?this.reflectivity.flow(e,"f"):void 0;e.requires.transparent=d!==void 0,e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;",`uniform float penumbraSize[${5}];`,"#include <normal_pars_fragment>","#include <dithering_pars_fragment>","#include <fog_pars_fragment>","#include <bsdfs>","#include <lights_pars_begin>","#include <lights_physical_pars_fragment>","#include <shadowmap_pars_fragment>"].join(`
311
311
  `));let f=["#include <clipping_planes_fragment>"," #include <normal_fragment_begin>",`
312
312
  // NOTE: gl_FrontFacing alternative using face normal estimation.
313
313
  vec3 viewdx = dFdx(vViewPosition);
@@ -323,7 +323,7 @@
323
323
  outgoingLight = spe_blend( diffuseColor, outgoingLight, ${c.result}, ${u.result} );
324
324
  }
325
325
  `),a&&f.push(a.code,`outgoingLight = spe_blend(outgoingLight, ${a.result}, 1.0, SPE_BLENDING_NORMAL);`),d?f.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${d.result} );`):f.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),f.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),t=f.join(`
326
- `)}return t}};var fs=require("three");var ms=class extends dt{constructor(){super("toon");this.nodeType="Toon";this.color=new Ie(5855577),this.specular=new Ie(1118481),this.shininess=new Q(30),this.shadingAlpha=new Q(1),this.shadingBlend=new be(0)}get category(){return"toon"}build(e){let t;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(fs.UniformsUtils.merge([fs.UniformsLib.fog,fs.UniformsLib.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(`
326
+ `)}return t}};var Ss=require("three");var ws=class extends pt{constructor(){super("toon");this.nodeType="Toon";this.color=new Ie(5855577),this.specular=new Ie(1118481),this.shininess=new J(30),this.shadingAlpha=new J(1),this.shadingBlend=new be(0)}get category(){return"toon"}build(e){let t;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(Ss.UniformsUtils.merge([Ss.UniformsLib.fog,Ss.UniformsLib.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(`
327
327
  `));let i=["#include <beginnormal_vertex>",`
328
328
  #ifndef USE_LAYER_DISPLACE
329
329
  #include <defaultnormal_vertex>
@@ -341,7 +341,7 @@
341
341
  #include <begin_vertex>
342
342
  #endif
343
343
  `];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>"," #include <shadowmap_vertex>"," #include <fog_vertex>"),i.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),t=i.join(`
344
- `)}else{e.mergeUniform({penumbraSize:gt.penumbraSize}),this.color===void 0&&(this.color=new Ie(5855577)),this.color.analyze(e,{slot:"color"}),this.specular.analyze(e),this.shininess.analyze(e),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e);let o=this.color.flow(e,"c",{slot:"color"}),i=this.specular.flow(e,"c"),s=this.shininess.flow(e,"f"),l=this.shadingAlpha.flow(e,"f"),c=this.shadingBlend.flow(e,"i"),u=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,a=this.alpha?this.alpha.flow(e,"f"):void 0;e.requires.transparent=a!==void 0,e.addParsCode([`uniform float penumbraSize[${5}];`,"varying vec3 vWPosition;","#include <normal_pars_fragment>","#include <gradientmap_pars_fragment>","#include <fog_pars_fragment>","#include <bsdfs>","#include <lights_pars_begin>","#include <dithering_pars_fragment>",`
344
+ `)}else{e.mergeUniform({penumbraSize:vt.penumbraSize}),this.color===void 0&&(this.color=new Ie(5855577)),this.color.analyze(e,{slot:"color"}),this.specular.analyze(e),this.shininess.analyze(e),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e);let o=this.color.flow(e,"c",{slot:"color"}),i=this.specular.flow(e,"c"),s=this.shininess.flow(e,"f"),l=this.shadingAlpha.flow(e,"f"),c=this.shadingBlend.flow(e,"i"),u=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,a=this.alpha?this.alpha.flow(e,"f"):void 0;e.requires.transparent=a!==void 0,e.addParsCode([`uniform float penumbraSize[${5}];`,"varying vec3 vWPosition;","#include <normal_pars_fragment>","#include <gradientmap_pars_fragment>","#include <fog_pars_fragment>","#include <bsdfs>","#include <lights_pars_begin>","#include <dithering_pars_fragment>",`
345
345
  varying vec3 vViewPosition;
346
346
  struct ToonMaterial {
347
347
  vec3 diffuseColor;
@@ -377,7 +377,7 @@
377
377
  outgoingLight = spe_blend( diffuseColor, outgoingLight, ${l.result}, ${c.result} );
378
378
  }
379
379
  `),u&&d.push(u.code,`outgoingLight = spe_blend(outgoingLight, ${u.result}, 1.0, SPE_BLENDING_NORMAL);`),a?d.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${a.result} );`):d.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),d.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),t=d.join(`
380
- `)}return t}};var So=class extends Ge{constructor(e){super("b");this.nodeType="Bool";this.value=e??!1}generateReadonly(e,t,o,i){return e.format(this.value?"true":"false",i,t)}};var Ch=require("three");var pi=class extends Ge{constructor(e){super("m3");this.nodeType="Matrix3";this.value=e??new Ch.Matrix3}generateReadonly(e,t,o,i,s,l){return e.format("mat3("+this.value.elements.join(", ")+")",i,t)}get elements(){return this.value.elements}set elements(e){this.value.fromArray(e)}};var Jc=require("three");var hr=class extends Ge{constructor(e=1,t){super("v4[]");this.nodeType="Vector4Array";this.size=e,this.value=Array.isArray(t)?t:t instanceof Jc.Vector4?new Array(e).fill(t):new Array(e).fill(new Jc.Vector4(0))}};var hs=(i=>(i.SIMPLEX="simplex3d",i.SIMPLEX_FRACTAL="simplex3dFractal",i.ASHIMA="simplexAshima",i.FBM="fbm",i.PERLIN="perlin",i))(hs||{}),bt=function(){let r=new X(`vec3 random3(vec3 c) {
380
+ `)}return t}};var Po=class extends De{constructor(e){super("b");this.nodeType="Bool";this.value=e??!1}generateReadonly(e,t,o,i){return e.format(this.value?"true":"false",i,t)}};var $h=require("three");var xi=class extends De{constructor(e){super("m3");this.nodeType="Matrix3";this.value=e??new $h.Matrix3}generateReadonly(e,t,o,i,s,l){return e.format("mat3("+this.value.elements.join(", ")+")",i,t)}get elements(){return this.value.elements}set elements(e){this.value.fromArray(e)}};var vd=require("three");var vr=class extends De{constructor(e=1,t){super("v4[]");this.nodeType="Vector4Array";this.size=e,this.value=Array.isArray(t)?t:t instanceof vd.Vector4?new Array(e).fill(t):new Array(e).fill(new vd.Vector4(0))}};var _s=(i=>(i.SIMPLEX="simplex3d",i.SIMPLEX_FRACTAL="simplex3dFractal",i.ASHIMA="simplexAshima",i.FBM="fbm",i.PERLIN="perlin",i))(_s||{}),wt=function(){let r=new Q(`vec3 random3(vec3 c) {
381
381
  float j = 4096.0*sin(dot(c,vec3(17.0, 59.4, 15.0)));
382
382
  vec3 r;
383
383
  r.z = fract(512.0*j);
@@ -386,7 +386,7 @@
386
386
  j *= .125;
387
387
  r.y = fract(512.0*j);
388
388
  return r-0.5;
389
- }`),e=new X(`float simplex3d(vec3 p) {
389
+ }`),e=new Q(`float simplex3d(vec3 p) {
390
390
  vec3 s = floor(p + dot(p, vec3(F3)));
391
391
  vec3 x = p - s + dot(s, vec3(G3));
392
392
 
@@ -417,7 +417,7 @@
417
417
  d *= w;
418
418
 
419
419
  return dot(d, vec4(52.0));
420
- }`,[r]);e.keywords.F3=new we("float F3 0.3333333"),e.keywords.G3=new we("float G3 0.1666667");let t=new X(`float simplex3dFractal(vec3 m) {
420
+ }`,[r]);e.keywords.F3=new _e("float F3 0.3333333"),e.keywords.G3=new _e("float G3 0.1666667");let t=new Q(`float simplex3dFractal(vec3 m) {
421
421
  mat3 rot1 = mat3(-0.37, 0.36, 0.85,-0.14,-0.93, 0.34,0.92, 0.01,0.4);
422
422
  mat3 rot2 = mat3(-0.55,-0.39, 0.74, 0.33,-0.91,-0.24,0.77, 0.12,0.63);
423
423
  mat3 rot3 = mat3(-0.71, 0.52,-0.47,-0.08,-0.72,-0.68,-0.7,-0.45,0.56);
@@ -425,7 +425,7 @@
425
425
  + 0.2666667 * simplex3d(2.0 * m * rot2)
426
426
  + 0.1333333 * simplex3d(4.0 * m * rot3)
427
427
  + 0.0666667 * simplex3d(8.0 * m);
428
- }`,[e]),o=new X("vec4 permute(vec4 x){return mod(((x*34.0)+1.0)*x, 289.0);}"),i=new X("vec4 taylorInvSqrt(vec4 r){return 1.79284291400159 - 0.85373472095314 * r;}"),s=new X(`float simplexAshima(vec3 v) {
428
+ }`,[e]),o=new Q("vec4 permute(vec4 x){return mod(((x*34.0)+1.0)*x, 289.0);}"),i=new Q("vec4 taylorInvSqrt(vec4 r){return 1.79284291400159 - 0.85373472095314 * r;}"),s=new Q(`float simplexAshima(vec3 v) {
429
429
  const vec2 C = vec2(1.0/6.0, 1.0/3.0) ;
430
430
  const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);
431
431
  vec3 i = floor(v + dot(v, C.yyy) );
@@ -470,7 +470,7 @@
470
470
  m = m * m;
471
471
  return 42.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1),
472
472
  dot(p2,x2), dot(p3,x3) ) );
473
- }`,[o,i]),l=new X("vec4 mod289(vec4 x){return x - floor(x * (1.0 / 289.0)) * 289.0;}"),c=new X("vec4 perm(vec4 x){return mod289(((x * 34.0) + 1.0) * x);}",[l]),u=new X(`float noise(vec3 p){
473
+ }`,[o,i]),l=new Q("vec4 mod289(vec4 x){return x - floor(x * (1.0 / 289.0)) * 289.0;}"),c=new Q("vec4 perm(vec4 x){return mod289(((x * 34.0) + 1.0) * x);}",[l]),u=new Q(`float noise(vec3 p){
474
474
  vec3 a = floor(p);
475
475
  vec3 d = p - a;
476
476
  d = d * d * (3.0 - 2.0 * d);
@@ -485,7 +485,7 @@
485
485
  vec4 o3 = o2 * d.z + o1 * (1.0 - d.z);
486
486
  vec2 o4 = o3.yw * d.x + o3.xz * (1.0 - d.x);
487
487
  return o4.y * d.y + o4.x * (1.0 - d.y);
488
- }`,[c]),a=new X(`float fbm(vec3 x) {
488
+ }`,[c]),a=new Q(`float fbm(vec3 x) {
489
489
  float v = 0.0;
490
490
  float a = 0.5;
491
491
  vec3 shift = vec3(100);
@@ -495,7 +495,7 @@
495
495
  a *= 0.5;
496
496
  }
497
497
  return v;
498
- }`,[u]);a.keywords.NUM_OCTAVES=new we(`int NUM_OCTAVES ${5}`);let d=new X("vec3 fade(vec3 t) {return t*t*t*(t*(t*6.0-15.0)+10.0);}"),p=new X(`float perlin(vec3 P){
498
+ }`,[u]);a.keywords.NUM_OCTAVES=new _e(`int NUM_OCTAVES ${5}`);let d=new Q("vec3 fade(vec3 t) {return t*t*t*(t*(t*6.0-15.0)+10.0);}"),p=new Q(`float perlin(vec3 P){
499
499
  vec3 Pi0 = floor(P);
500
500
  vec3 Pi1 = Pi0 + vec3(1.0);
501
501
  Pi0 = mod(Pi0, 289.0);
@@ -554,7 +554,7 @@
554
554
  vec2 n_yz = mix(n_z.xy, n_z.zw, fade_xyz.y);
555
555
  float n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x);
556
556
  return 2.2 * n_xyz;
557
- }`,[o,i,d]);return{simplex:e,simplexFractal:t,simplexAshima:s,fbm:a,perlin:p}}();var ys=class extends ce{constructor(e,t,o,i,s,l,c,u,a,d,p,f){super("v3");this.nodeType="Noise";this.scale=e,this.size=t,this.move=o,this.fA=i,this.fB=s,this.distortion=l,this.colorA=c,this.colorB=u,this.colorC=a,this.colorD=d,this.alpha=p,this.noiseType=f,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t,o,i,s){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let l=Object.values(hs)[this.noiseType.value],c=new X(`vec3 ${l}customNoise(float scale, vec3 size, float move, vec2 fA, vec2 fB, vec2 distortion, vec4 colorA, vec4 colorB, vec4 colorC, vec4 colorD, float alpha, out float calpha) {
557
+ }`,[o,i,d]);return{simplex:e,simplexFractal:t,simplexAshima:s,fbm:a,perlin:p}}();var Ts=class extends ce{constructor(e,t,o,i,s,l,c,u,a,d,p,f){super("v3");this.nodeType="Noise";this.scale=e,this.size=t,this.move=o,this.fA=i,this.fB=s,this.distortion=l,this.colorA=c,this.colorB=u,this.colorC=a,this.colorD=d,this.alpha=p,this.noiseType=f,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t,o,i,s){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let l=Object.values(_s)[this.noiseType.value],c=new Q(`vec3 ${l}customNoise(float scale, vec3 size, float move, vec2 fA, vec2 fB, vec2 distortion, vec4 colorA, vec4 colorB, vec4 colorC, vec4 colorD, float alpha, out float calpha) {
558
558
  vec3 st = position / size;
559
559
  st /= scale;
560
560
  vec3 q = vec3(${l}(st),
@@ -574,14 +574,14 @@
574
574
 
575
575
  accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
576
576
  return clamp(color, 0.0, 1.0).rgb;
577
- }`,[bt.simplex,bt.simplexFractal,bt.simplexAshima,bt.fbm,bt.perlin]),u=e.include(c),a=[];return a.push(this.scale.build(e,"f")),a.push(this.size.build(e,"v3")),a.push(this.move.build(e,"f")),a.push(this.fA.build(e,"v2")),a.push(this.fB.build(e,"v2")),a.push(this.distortion.build(e,"v2")),a.push(this.colorA.build(e,"v4")),a.push(this.colorB.build(e,"v4")),a.push(this.colorC.build(e,"v4")),a.push(this.colorD.build(e,"v4")),a.push(this.alpha.build(e,"f")),a.push(this.calpha),e.format(u+"("+a.join(",")+")",this.getType(e),t)}};ys.numOctaves=5;var ed=class extends ce{constructor(e,t,o,i,s,l,c){super("v3");this.nodeType="Fresnel";this.color=e,this.bias=t,this.scale=o,this.intensity=i,this.factor=s,this.alpha=l,this.mode=c,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.require("vWorldViewDir"),e.require("worldNormal"),e.isShader("fragment")){e.addFragmentVariable(this.calpha,"float");let o=e.include(ed.Nodes.fresnel),i=[];return i.push(this.color.build(e,"c")),i.push(this.bias.build(e,"f")),i.push(this.scale.build(e,"f")),i.push(this.intensity.build(e,"f")),i.push(this.factor.build(e,"f")),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),t)}else return console.warn("FresnelNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},gs=ed;gs.Nodes=function(){return{fresnel:new X(`vec3 fresnel(vec3 color, float bias, float scale, float intensity, float factor, float alpha, int mode, out float calpha) {
577
+ }`,[wt.simplex,wt.simplexFractal,wt.simplexAshima,wt.fbm,wt.perlin]),u=e.include(c),a=[];return a.push(this.scale.build(e,"f")),a.push(this.size.build(e,"v3")),a.push(this.move.build(e,"f")),a.push(this.fA.build(e,"v2")),a.push(this.fB.build(e,"v2")),a.push(this.distortion.build(e,"v2")),a.push(this.colorA.build(e,"v4")),a.push(this.colorB.build(e,"v4")),a.push(this.colorC.build(e,"v4")),a.push(this.colorD.build(e,"v4")),a.push(this.alpha.build(e,"f")),a.push(this.calpha),e.format(u+"("+a.join(",")+")",this.getType(e),t)}};Ts.numOctaves=5;var bd=class extends ce{constructor(e,t,o,i,s,l,c){super("v3");this.nodeType="Fresnel";this.color=e,this.bias=t,this.scale=o,this.intensity=i,this.factor=s,this.alpha=l,this.mode=c,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.require("vWorldViewDir"),e.require("worldNormal"),e.isShader("fragment")){e.addFragmentVariable(this.calpha,"float");let o=e.include(bd.Nodes.fresnel),i=[];return i.push(this.color.build(e,"c")),i.push(this.bias.build(e,"f")),i.push(this.scale.build(e,"f")),i.push(this.intensity.build(e,"f")),i.push(this.factor.build(e,"f")),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),t)}else return console.warn("FresnelNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},Ps=bd;Ps.Nodes=function(){return{fresnel:new Q(`vec3 fresnel(vec3 color, float bias, float scale, float intensity, float factor, float alpha, int mode, out float calpha) {
578
578
  float fresnel = bias + scale * pow( abs( factor + dot( normalize( vWorldViewDir ), normalize( vWNormal ) ) ), intensity );
579
579
 
580
580
  float lalpha = clamp( fresnel, 0.0, 1.0 ) * alpha;
581
581
  calpha = lalpha / clamp(lalpha + accumAlpha, 0.001, 1.0);
582
582
  accumAlpha += (1.0 - accumAlpha) * lalpha;
583
583
  return color;
584
- }`)}}();var td=class extends ce{constructor(e,t,o,i,s,l,c){super("v3");this.nodeType="Rainbow";this.filmThickness=e,this.movement=t,this.wavelengths=o,this.noiseStrength=i,this.noiseScale=s,this.offset=l,this.alpha=c,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){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(td.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.alpha.build(e,"f")),i.push(this.calpha),e.format(o+"("+i.join(",")+")",this.getType(e),t)}else return console.warn("RainbowNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},xs=td;xs.Nodes=function(){let e=new X(`vec3 attenuation(vec3 wavelengths, float filmThickness, float movement, float noiseStrength, float noiseScale, vec3 offset) {
584
+ }`)}}();var Sd=class extends ce{constructor(e,t,o,i,s,l,c){super("v3");this.nodeType="Rainbow";this.filmThickness=e,this.movement=t,this.wavelengths=o,this.noiseStrength=i,this.noiseScale=s,this.offset=l,this.alpha=c,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){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(Sd.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.alpha.build(e,"f")),i.push(this.calpha),e.format(o+"("+i.join(",")+")",this.getType(e),t)}else return console.warn("RainbowNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},Os=Sd;Os.Nodes=function(){let e=new Q(`vec3 attenuation(vec3 wavelengths, float filmThickness, float movement, float noiseStrength, float noiseScale, vec3 offset) {
585
585
  vec3 st = position / noiseScale;
586
586
  vec3 q = vec3(simplex3d(st),
587
587
  simplex3d(st + vec3(1.0)),
@@ -594,7 +594,7 @@
594
594
  float noise = simplex3d(st + r);
595
595
 
596
596
  return .5 + .5 * cos((((filmThickness + (noise * noiseStrength)) / (vec3(wavelengths.r * 1.0, wavelengths.g * 0.8, wavelengths.b * 0.6) + 1.0)) * dot(normalize(vWorldViewDir + (offset * -0.001)), normalize(vWNormal))) + movement);
597
- }`,[bt.simplex]);return{rainbow:new X(`vec3 rainbow(float filmThickness, float movement, vec3 wavelengths, float noiseStrength, float noiseScale, vec3 offset, float alpha, out float calpha) {
597
+ }`,[wt.simplex]);return{rainbow:new Q(`vec3 rainbow(float filmThickness, float movement, vec3 wavelengths, float noiseStrength, float noiseScale, vec3 offset, float alpha, out float calpha) {
598
598
  vec3 res = clamp(attenuation(wavelengths, filmThickness, movement, noiseStrength, noiseScale, offset), 0.0, 2.0);
599
599
 
600
600
  float rainbowContribution = clamp(res.r + res.g + res.b, 0.0, 1.0);
@@ -603,7 +603,7 @@
603
603
  accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
604
604
 
605
605
  return res;
606
- }`,[e])}}();var rd=class extends ce{constructor(e,t,o,i,s,l,c,u,a,d,p,f,m,h,y,g){super("v3");this.nodeType="Outline";this.firstTime=!0,this.outlineColor=e,this.contourColor=t,this.outlineWidth=o,this.contourWidth=i,this.contourThreshold=s,this.outlineThreshold=l,this.contourFrequency=c,this.outlineSmoothing=u,this.contourDirection=a,this.positionalLines=d,this.compensation=p,this.resolution=f,this.normalMap=m,this.depthMap=h,this.pixelRatio=y,this.alpha=g,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.require("vWorldViewDir"),e.require("worldNormal"),e.extensions.derivatives=!0,this.firstTime){let o=this.outlineWidth.build(e,"f"),i=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(o,"uniform float"),e.addVertexParsVariable(i,"uniform vec2"),e.addVertexParsVariable(s,"uniform bool"),e.addVertexParsVariable(l,"uniform float"),e.addVertexParsVariable("vID","flat out float"),e.addFragmentParsVariable("vID","flat in float");let c=`g${this.uuid.toString().replace(/-/g,"")}`;e.addVertexFinalCode(`
606
+ }`,[e])}}();var wd=class extends ce{constructor(e,t,o,i,s,l,c,u,a,d,p,f,m,h,y,g){super("v3");this.nodeType="Outline";this.firstTime=!0,this.outlineColor=e,this.contourColor=t,this.outlineWidth=o,this.contourWidth=i,this.contourThreshold=s,this.outlineThreshold=l,this.contourFrequency=c,this.outlineSmoothing=u,this.contourDirection=a,this.positionalLines=d,this.compensation=p,this.resolution=f,this.normalMap=m,this.depthMap=h,this.pixelRatio=y,this.alpha=g,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.require("vWorldViewDir"),e.require("worldNormal"),e.extensions.derivatives=!0,this.firstTime){let o=this.outlineWidth.build(e,"f"),i=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(o,"uniform float"),e.addVertexParsVariable(i,"uniform vec2"),e.addVertexParsVariable(s,"uniform bool"),e.addVertexParsVariable(l,"uniform float"),e.addVertexParsVariable("vID","flat out float"),e.addFragmentParsVariable("vID","flat in float");let c=`g${this.uuid.toString().replace(/-/g,"")}`;e.addVertexFinalCode(`
607
607
  vID = randomColor.r;
608
608
  if (${s}) {
609
609
  vec4 ${c}_clipPosition = projectionMatrix * (modelViewMatrix * vec4(position, 1.0));
@@ -617,7 +617,7 @@
617
617
  // if this offset is the biggest of all the potential offsets
618
618
  gl_Position = ${c}_clipPosition;
619
619
  }
620
- `)}if(e.isShader("fragment")){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let o=e.include(rd.Nodes.outline),i=[];return i.push(this.outlineColor.build(e,"c")),i.push(this.contourColor.build(e,"c")),i.push(this.outlineWidth.build(e,"f")),i.push(this.contourWidth.build(e,"f")),i.push(this.contourThreshold.build(e,"f")),i.push(this.outlineThreshold.build(e,"f")),i.push(this.contourFrequency.build(e,"f")),i.push(this.outlineSmoothing.build(e,"f")),i.push(this.contourDirection.build(e,"v3")),i.push(this.positionalLines.build(e,"b")),i.push(this.resolution.build(e,"v2")),i.push(this.normalMap.getTexture(e,"t")),i.push(this.depthMap.getTexture(e,"t")),i.push(this.pixelRatio.build(e,"f")),i.push(this.compensation.build(e,"b")),i.push(this.alpha.build(e,"f")),i.push(this.calpha),this.firstTime=!this.firstTime,e.format(o+"("+i.join(",")+")",this.getType(e),t)}else return console.warn("OutlineNode is not compatible with "+e.shader+" shader."),""}},vs=rd;vs.Nodes=function(){let e=new X(`
620
+ `)}if(e.isShader("fragment")){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let o=e.include(wd.Nodes.outline),i=[];return i.push(this.outlineColor.build(e,"c")),i.push(this.contourColor.build(e,"c")),i.push(this.outlineWidth.build(e,"f")),i.push(this.contourWidth.build(e,"f")),i.push(this.contourThreshold.build(e,"f")),i.push(this.outlineThreshold.build(e,"f")),i.push(this.contourFrequency.build(e,"f")),i.push(this.outlineSmoothing.build(e,"f")),i.push(this.contourDirection.build(e,"v3")),i.push(this.positionalLines.build(e,"b")),i.push(this.resolution.build(e,"v2")),i.push(this.normalMap.getTexture(e,"t")),i.push(this.depthMap.getTexture(e,"t")),i.push(this.pixelRatio.build(e,"f")),i.push(this.compensation.build(e,"b")),i.push(this.alpha.build(e,"f")),i.push(this.calpha),this.firstTime=!this.firstTime,e.format(o+"("+i.join(",")+")",this.getType(e),t)}else return console.warn("OutlineNode is not compatible with "+e.shader+" shader."),""}},As=wd;As.Nodes=function(){let e=new Q(`
621
621
  float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outlineWidth, float pixelRatio)
622
622
  {
623
623
  vec2 texelSize = (vec2(1.0) / resolution) * outlineWidth * pixelRatio;
@@ -718,7 +718,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
718
718
  float edgeNormal = sqrt(dot(sobel_edge_h, sobel_edge_h) + dot(sobel_edge_v, sobel_edge_v));
719
719
  return edgeNormal;
720
720
  }
721
- `);return{outline:new X(`vec3 outline(vec3 outlineColor, vec3 contourColor, float outlineWidth, float contourWidth, float outlineThreshold, float contourThreshold, float outlineSmoothing, float contourFrequency, vec3 contourDirection, bool positionalLines, vec2 resolution, sampler2D normalMap, sampler2D depthMap, float pixelRatio, bool compensation, float alpha, out float calpha) {
721
+ `);return{outline:new Q(`vec3 outline(vec3 outlineColor, vec3 contourColor, float outlineWidth, float contourWidth, float outlineThreshold, float contourThreshold, float outlineSmoothing, float contourFrequency, vec3 contourDirection, bool positionalLines, vec2 resolution, sampler2D normalMap, sampler2D depthMap, float pixelRatio, bool compensation, float alpha, out float calpha) {
722
722
  vec3 result = outlineColor;
723
723
  float resultAlpha = 0.0;
724
724
 
@@ -757,11 +757,11 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
757
757
  calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
758
758
  accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
759
759
  return result;
760
- }`,[e])}}();var od=class extends ce{constructor(e,t,o,i,s,l,c,u){super("v3");this.nodeType="Transmission";this.thickness=e,this.ior=t,this.roughness=o,this.transmissionSamplerSize=i,this.transmissionSamplerMap=s,this.transmissionDepthMap=l,this.aspectRatio=c,this.alpha=u,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.extensions.shaderTextureLOD=!0,e.extensions.derivatives=!0,e.isShader("fragment")){e.define("NUM_SAMPLES",30),e.require("worldPosition"),e.requires.worldNormal=!0,e.requires.modelMatrix=!0,e.requires.projectionMatrix=!0,e.addFragmentVariable(this.calpha,"float");let o=e.include(od.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.alpha.build(e,"f")),i.push(this.calpha),e.format(o+"("+i.join(",")+")",this.getType(e),t)}else return console.warn("TransmissionNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},bs=od;bs.Nodes=function(){let e=new X(`
760
+ }`,[e])}}();var _d=class extends ce{constructor(e,t,o,i,s,l,c,u){super("v3");this.nodeType="Transmission";this.thickness=e,this.ior=t,this.roughness=o,this.transmissionSamplerSize=i,this.transmissionSamplerMap=s,this.transmissionDepthMap=l,this.aspectRatio=c,this.alpha=u,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.extensions.shaderTextureLOD=!0,e.extensions.derivatives=!0,e.isShader("fragment")){e.define("NUM_SAMPLES",30),e.require("worldPosition"),e.requires.worldNormal=!0,e.requires.modelMatrix=!0,e.requires.projectionMatrix=!0,e.addFragmentVariable(this.calpha,"float");let o=e.include(_d.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.alpha.build(e,"f")),i.push(this.calpha),e.format(o+"("+i.join(",")+")",this.getType(e),t)}else return console.warn("TransmissionNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},Is=_d;Is.Nodes=function(){let e=new Q(`
761
761
  float gaussian(vec2 i) {
762
762
  const float sigma = float(NUM_SAMPLES) * .25;
763
763
  return exp( -.5* dot(i/=sigma,i) ) / ( 6.28 * sigma*sigma );
764
- }`),t=new X(`
764
+ }`),t=new Q(`
765
765
  vec3 blur(sampler2D sp, vec2 U, vec2 scale, float lod, sampler2D dm, vec2 unrefractedU, vec2 aspectRatio) {
766
766
  // Slightly modified version of this:
767
767
  // https://www.shadertoy.com/view/ltScRG
@@ -791,7 +791,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
791
791
  a += gaussian;
792
792
  }
793
793
  return O / a;
794
- }`,[e]),o=new X(`
794
+ }`,[e]),o=new Q(`
795
795
  vec3 getVolumeTransmissionRay( vec3 n, vec3 v, float thickness, float ior, mat4 modelMatrix ) {
796
796
  // Direction of refracted light.
797
797
  vec3 refractionVector = refract( -v, n, 1.0 / ior );
@@ -802,18 +802,18 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
802
802
  modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
803
803
  // The thickness is specified in local space.
804
804
  return normalize( refractionVector ) * thickness * modelScale;
805
- }`),i=new X(`
805
+ }`),i=new Q(`
806
806
  float applyIorToRoughness( float roughness, float ior ) {
807
807
  // Scale roughness with IOR so that an IOR of 1.0 results in no microfacet refraction and
808
808
  // an IOR of 1.5 results in the default amount of microfacet refraction.
809
809
  return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
810
- } `),s=new X(`
810
+ } `),s=new Q(`
811
811
  vec3 getTransmissionSample( vec2 fragCoord, float roughness, float ior, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 unrefractedCoords, vec2 aspectRatio) {
812
812
  float framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
813
813
  float lod = applyIorToRoughness(roughness, ior);
814
814
 
815
815
  return blur(transmissionSamplerMap, fragCoord, vec2(lod / (transmissionSamplerSize.x / 2.)), min(framebufferLod / 5.5, 8.5), transmissionDepthMap, unrefractedCoords, aspectRatio);
816
- }`,[i,t]),l=new X(`
816
+ }`,[i,t]),l=new Q(`
817
817
  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 ) {
818
818
  vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
819
819
  vec3 refractedRayExit = position + transmissionRay;
@@ -831,7 +831,7 @@ vec3 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
831
831
 
832
832
  // Sample framebuffer to get pixel the refracted ray hits.
833
833
  return getTransmissionSample( refractionCoords, roughness, ior, transmissionSamplerSize, transmissionSamplerMap, transmissionDepthMap, unrefractedCoords, aspectRatio );
834
- }`,[s,o]);return{transmission:new X(`
834
+ }`,[s,o]);return{transmission:new Q(`
835
835
  vec3 transmission(float thickness, float ior, float roughness, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 aspectRatio, vec3 normal, float alpha, out float calpha) {
836
836
  vec3 v = vec3(0.);
837
837
  if (isOrthographic) {
@@ -845,7 +845,7 @@ vec3 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
845
845
  calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
846
846
  accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
847
847
  return transmission;
848
- }`,[l])}}();var fi=class extends ce{constructor(e,t,o,i,s,l,c,u,a,d,p){super("v3");this.nodeType="Depth";this.gradientType=e,this.smooth=t,this.near=o,this.far=i,this.isVector=s,this.isWorldSpace=l,this.origin=c,this.direction=u,this.colors=a,this.steps=d,this.alpha=p,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){let o=`g${this.uuid.toString().replace(/-/g,"")}`,i=new X(`vec3 ${o}_sdepth(float near, float far, vec3 origin, vec3 direction, vec4 colors[${o}_MAX_COLORS], float steps[${o}_MAX_COLORS], float alpha, out float calpha) {
848
+ }`,[l])}}();var vi=class extends ce{constructor(e,t,o,i,s,l,c,u,a,d,p){super("v3");this.nodeType="Depth";this.gradientType=e,this.smooth=t,this.near=o,this.far=i,this.isVector=s,this.isWorldSpace=l,this.origin=c,this.direction=u,this.colors=a,this.steps=d,this.alpha=p,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){let o=`g${this.uuid.toString().replace(/-/g,"")}`,i=new Q(`vec3 ${o}_sdepth(float near, float far, vec3 origin, vec3 direction, vec4 colors[${o}_MAX_COLORS], float steps[${o}_MAX_COLORS], float alpha, out float calpha) {
849
849
  vec4 color = colors[0];
850
850
  #ifdef ${o}_IS_VECTOR
851
851
  #ifdef ${o}_LINEAR
@@ -885,25 +885,25 @@ vec3 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
885
885
 
886
886
  accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
887
887
  return color.rgb;
888
- }`,[fi.Nodes.vectorLinearWorldSpaceDepth,fi.Nodes.vectorLinearObjectSpaceDepth,fi.Nodes.vectorSphericalObjectSpaceDepth,fi.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 s=e.include(i),l=[];return l.push(this.near.build(e,"f")),l.push(this.far.build(e,"f")),l.push(this.origin.build(e,"v3")),l.push(this.direction.build(e,"v3")),l.push(this.colors.build(e,"v4[]")),l.push(this.steps.build(e,"f[]")),l.push(this.alpha.build(e,"f")),l.push(this.calpha),e.format(s+"("+l.join(",")+")",this.getType(e),t)}else return console.warn("DepthNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},Ss=fi;Ss.Nodes=function(){let e=new X(`float vectorLinearWorldSpaceDepth(vec3 direction, vec3 origin, float near, float far) {
888
+ }`,[vi.Nodes.vectorLinearWorldSpaceDepth,vi.Nodes.vectorLinearObjectSpaceDepth,vi.Nodes.vectorSphericalObjectSpaceDepth,vi.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 s=e.include(i),l=[];return l.push(this.near.build(e,"f")),l.push(this.far.build(e,"f")),l.push(this.origin.build(e,"v3")),l.push(this.direction.build(e,"v3")),l.push(this.colors.build(e,"v4[]")),l.push(this.steps.build(e,"f[]")),l.push(this.alpha.build(e,"f")),l.push(this.calpha),e.format(s+"("+l.join(",")+")",this.getType(e),t)}else return console.warn("DepthNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},Cs=vi;Cs.Nodes=function(){let e=new Q(`float vectorLinearWorldSpaceDepth(vec3 direction, vec3 origin, float near, float far) {
889
889
  vec3 n = normalize(direction);
890
890
  float dist = (n.x*(vWPosition.x - origin.x) + n.y*(vWPosition.y - origin.y) + n.z*(vWPosition.z - origin.z));
891
891
  return ( dist - near ) / ( far - near );
892
- }`),t=new X(`float vectorLinearObjectSpaceDepth(vec3 direction, vec3 origin, float near, float far) {
892
+ }`),t=new Q(`float vectorLinearObjectSpaceDepth(vec3 direction, vec3 origin, float near, float far) {
893
893
  vec3 n = normalize(direction);
894
894
  float dist = (n.x*(position.x - origin.x) + n.y*(position.y - origin.y) + n.z*(position.z - origin.z));
895
895
  return ( dist - near ) / ( far - near );
896
- }`),o=new X(`float vectorSphericalWorldSpaceDepth(vec3 origin, float near, float far) {
896
+ }`),o=new Q(`float vectorSphericalWorldSpaceDepth(vec3 origin, float near, float far) {
897
897
  float dist = length(vWPosition - origin);
898
898
  return ( dist - near ) / ( far - near );
899
- }`),i=new X(`float vectorSphericalObjectSpaceDepth(vec3 origin, float near, float far) {
899
+ }`),i=new Q(`float vectorSphericalObjectSpaceDepth(vec3 origin, float near, float far) {
900
900
  float dist = length(position - origin);
901
901
  return ( dist - near ) / ( far - near );
902
- }`);return{vectorLinearWorldSpaceDepth:e,vectorLinearObjectSpaceDepth:t,vectorSphericalWorldSpaceDepth:o,vectorSphericalObjectSpaceDepth:i}}();var ws=class extends ce{constructor(e,t,o,i){super("v3");this.nodeType="Blend";this.a=e,this.b=t,this.alpha=o,this.mode=i}generate(e,t){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),t)}else return console.warn("BlendNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}};var nd=(e=>(e.NOISE="noise",e.MAP="map",e))(nd||{}),id=class extends ce{constructor(e,t,o,i,s){super("v3");this.displacementTypeIndex=new be(0);this.nodeType="VertexDisplacement";this.intensity=e,this.movementOrTexture=t,Object.values(nd)[this.displacementTypeIndex.value]==="map"&&(this.mat=new pi(this.movementOrTexture.value.matrix)),this.cropOrOffset=o,this.scale=i,this.noiseFunctionIndex=s}generate(e,t){if(e.isShader("vertex")){e.define("USE_LAYER_DISPLACE");let o,i=[];switch(i.push("displaced_position"),i.push("displaced_normal"),Object.values(nd)[this.displacementTypeIndex.value]){case"map":{o=e.include(id.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 l=Object.values(hs)[this.noiseFunctionIndex.value],c=new X(`vec3 orthogonal(vec3 v) {
902
+ }`);return{vectorLinearWorldSpaceDepth:e,vectorLinearObjectSpaceDepth:t,vectorSphericalWorldSpaceDepth:o,vectorSphericalObjectSpaceDepth:i}}();var Ns=class extends ce{constructor(e,t,o,i){super("v3");this.nodeType="Blend";this.a=e,this.b=t,this.alpha=o,this.mode=i}generate(e,t){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),t)}else return console.warn("BlendNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}};var Td=(e=>(e.NOISE="noise",e.MAP="map",e))(Td||{}),Pd=class extends ce{constructor(e,t,o,i,s){super("v3");this.displacementTypeIndex=new be(0);this.nodeType="VertexDisplacement";this.intensity=e,this.movementOrTexture=t,Object.values(Td)[this.displacementTypeIndex.value]==="map"&&(this.mat=new xi(this.movementOrTexture.value.matrix)),this.cropOrOffset=o,this.scale=i,this.noiseFunctionIndex=s}generate(e,t){if(e.isShader("vertex")){e.define("USE_LAYER_DISPLACE");let o,i=[];switch(i.push("displaced_position"),i.push("displaced_normal"),Object.values(Td)[this.displacementTypeIndex.value]){case"map":{o=e.include(Pd.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 l=Object.values(_s)[this.noiseFunctionIndex.value],c=new Q(`vec3 orthogonal(vec3 v) {
903
903
  return normalize(abs(v.x) > abs(v.z) ? vec3(-v.y, v.x, 0.0) : vec3(0.0, -v.z, v.y));
904
- }`),u=new X(`vec3 distorted(vec3 p, vec3 n, float scale, float intensity, vec3 offset, float neighbour_offset, float movement) {
904
+ }`),u=new Q(`vec3 distorted(vec3 p, vec3 n, float scale, float intensity, vec3 offset, float neighbour_offset, float movement) {
905
905
  return p + n * ${l}((p + offset) * scale * 0.001 + neighbour_offset + (movement * 0.1)) * intensity;
906
- }`,[bt.simplex,bt.simplexFractal,bt.simplexAshima,bt.fbm,bt.perlin]),a=new X(`vec3 vertexDisplacementNoise(vec3 position, vec3 normal, float scale, vec3 offset, float movement, float intensity, out vec3 displaced_normal) {
906
+ }`,[wt.simplex,wt.simplexFractal,wt.simplexAshima,wt.fbm,wt.perlin]),a=new Q(`vec3 vertexDisplacementNoise(vec3 position, vec3 normal, float scale, vec3 offset, float movement, float intensity, out vec3 displaced_normal) {
907
907
  vec3 displaced_position = distorted(position, normal, scale, intensity, offset, neighbor_offset, movement);
908
908
  vec3 tangent1 = orthogonal(normal);
909
909
  vec3 tangent2 = normalize(cross(normal, tangent1));
@@ -919,9 +919,9 @@ vec3 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
919
919
  vec3 distorted2 = distorted(nearby2, normal, scale, intensity, offset, neighbor_offset, movement);
920
920
  displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));
921
921
  return displaced_position;
922
- }`,[u,c]);o=e.include(a),i.push(this.scale.build(e,"f")),i.push(this.cropOrOffset.build(e,"v3")),i.push(this.movementOrTexture.build(e,"f"));break}}return i.push(this.intensity.build(e,"f")),i.push("displaced_normal"),e.format(o+"("+i.join(",")+")",this.getType(e),t)}else return console.warn("VertexDisplacementNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},_s=id;_s.Nodes=function(){let e=new X(`vec3 orthogonal(vec3 v) {
922
+ }`,[u,c]);o=e.include(a),i.push(this.scale.build(e,"f")),i.push(this.cropOrOffset.build(e,"v3")),i.push(this.movementOrTexture.build(e,"f"));break}}return i.push(this.intensity.build(e,"f")),i.push("displaced_normal"),e.format(o+"("+i.join(",")+")",this.getType(e),t)}else return console.warn("VertexDisplacementNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},Es=Pd;Es.Nodes=function(){let e=new Q(`vec3 orthogonal(vec3 v) {
923
923
  return normalize(abs(v.x) > abs(v.z) ? vec3(-v.y, v.x, 0.0) : vec3(0.0, -v.z, v.y));
924
- }`),t=new X(`float displacementMapTexture(sampler2D tex, float crop, vec2 uv, mat3 mat, vec2 offset) {
924
+ }`),t=new Q(`float displacementMapTexture(sampler2D tex, float crop, vec2 uv, mat3 mat, vec2 offset) {
925
925
  vec2 uvs = (mat * vec3(uv * 2.0 - 1.0, 1.0) / 2.0 + 0.5).xy + offset;
926
926
  vec4 tmp = texture2D(tex, uvs);
927
927
  vec3 col = tmp.rgb;
@@ -931,7 +931,7 @@ vec3 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
931
931
  }
932
932
  }
933
933
  return col.r;
934
- }`);return{map:new X(`vec3 vertexDisplacementMap(vec3 position, vec3 normal, sampler2D tex, vec2 uv, float crop, mat3 mat, float intensity, out vec3 displaced_normal) {
934
+ }`);return{map:new Q(`vec3 vertexDisplacementMap(vec3 position, vec3 normal, sampler2D tex, vec2 uv, float crop, mat3 mat, float intensity, out vec3 displaced_normal) {
935
935
  vec3 displaced_position = position + normal * displacementMapTexture(tex, crop, uv, mat, vec2(0.0)) * intensity;
936
936
  vec3 tangent1 = normalize(orthogonal(normal));
937
937
  vec3 tangent2 = normalize(cross(normal, tangent1));
@@ -941,7 +941,7 @@ vec3 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
941
941
  vec3 distorted2 = nearby2 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity;
942
942
  displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));
943
943
  return displaced_position;
944
- }`,[e,t])}}();var sd=class extends ce{constructor(e,t,o,i,s,l,c,u){super("v3");this.nodeType="Gradient";this.gradientType=e,this.smooth=t,this.colors=o,this.steps=i,this.offset=s,this.morph=l,this.angle=c,this.alpha=u,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){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(sd.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.alpha.build(e,"f")),i.push(this.calpha),e.format(o+"("+i.join(",")+")",this.getType(e),t)}else return console.warn("GradientNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},Ts=sd;Ts.Nodes=function(){return{gradient:new X(`vec3 gradient(int gradientType, bool smoothed, vec4 colors[GRAD_MAX], float steps[GRAD_MAX], vec2 offset, vec2 morph, float angle, float alpha, out float calpha) {
944
+ }`,[e,t])}}();var Od=class extends ce{constructor(e,t,o,i,s,l,c,u){super("v3");this.nodeType="Gradient";this.gradientType=e,this.smooth=t,this.colors=o,this.steps=i,this.offset=s,this.morph=l,this.angle=c,this.alpha=u,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){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(Od.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.alpha.build(e,"f")),i.push(this.calpha),e.format(o+"("+i.join(",")+")",this.getType(e),t)}else return console.warn("GradientNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},Ms=Od;Ms.Nodes=function(){return{gradient:new Q(`vec3 gradient(int gradientType, bool smoothed, vec4 colors[GRAD_MAX], float steps[GRAD_MAX], vec2 offset, vec2 morph, float angle, float alpha, out float calpha) {
945
945
  vec4 color = colors[0];
946
946
  vec2 m = morph / vUv.xy;
947
947
  vec2 rot = vec2( 0.5 + m.x, m.y );
@@ -983,7 +983,7 @@ vec3 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
983
983
  accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
984
984
 
985
985
  return color.xyz;
986
- }`)}}();var As=class extends ce{constructor(e,t,o,i,s,l,c,u,a,d){super("v3");this.nodeType="CustomTexture";this.firstTime=!0,this.texture=e,this.textureSize=t,this.crop=o,this.projection=i,this.axis=s,this.side=l,this.size=c,this.mat=u,this.alpha=a,this.mode=d,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){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(As.Nodes.cylindrical);break;case 2:i=e.include(As.Nodes.spherical);break;case 1:let l=["vec3(1.0, 0.0, 0.0)","vec3(0.0, 1.0, 0.0)","vec3(0.0, 0.0, 1.0)"][this.axis.value],c=new X(`
986
+ }`)}}();var Bs=class extends ce{constructor(e,t,o,i,s,l,c,u,a,d){super("v3");this.nodeType="CustomTexture";this.firstTime=!0,this.texture=e,this.textureSize=t,this.crop=o,this.projection=i,this.axis=s,this.side=l,this.size=c,this.mat=u,this.alpha=a,this.mode=d,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){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(Bs.Nodes.cylindrical);break;case 2:i=e.include(Bs.Nodes.spherical);break;case 1:let l=["vec3(1.0, 0.0, 0.0)","vec3(0.0, 1.0, 0.0)","vec3(0.0, 0.0, 1.0)"][this.axis.value],c=new Q(`
987
987
  vec3 ${o}_planarTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float alpha, int mode, out float calpha) {
988
988
 
989
989
  vec2 uvs = ( mat * vec3( (${o}_vCustomUv * 2. - 1.) / (size * .5), 1. ) / 2. + 0.5 ).xy;
@@ -1002,7 +1002,7 @@ vec3 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
1002
1002
  calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
1003
1003
  accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
1004
1004
  return col;
1005
- }`);i=e.include(c);break;default:i=e.include(As.Nodes.uv);break}if(this.projection.value===1&&this.firstTime){e.addVertexParsCode(`varying vec2 ${o}_vCustomUv;`),e.addFragmentParsCode(`varying vec2 ${o}_vCustomUv;`);let l=["zy","xz","xy"][this.axis.value];e.addVertexFinalCode(`${o}_vCustomUv = (1. + (transformed.${l})) / 2.;`)}e.addFragmentVariable(this.calpha,"float");let s=[];return s.push(this.texture.generate(e,"t")),s.push(this.textureSize.build(e,"v2")),s.push(this.crop.build(e,"f")),s.push(this.mat.build(e,"mat3")),s.push(this.size.build(e,"v2")),s.push(this.alpha.build(e,"f")),s.push(this.mode.build(e,"i")),s.push(this.calpha),this.firstTime=!this.firstTime,e.format(i+"("+s.join(",")+")",this.getType(e),t)}},Os=As;Os.Nodes=function(){let e=new X(`
1005
+ }`);i=e.include(c);break;default:i=e.include(Bs.Nodes.uv);break}if(this.projection.value===1&&this.firstTime){e.addVertexParsCode(`varying vec2 ${o}_vCustomUv;`),e.addFragmentParsCode(`varying vec2 ${o}_vCustomUv;`);let l=["zy","xz","xy"][this.axis.value];e.addVertexFinalCode(`${o}_vCustomUv = (1. + (transformed.${l})) / 2.;`)}e.addFragmentVariable(this.calpha,"float");let s=[];return s.push(this.texture.generate(e,"t")),s.push(this.textureSize.build(e,"v2")),s.push(this.crop.build(e,"f")),s.push(this.mat.build(e,"mat3")),s.push(this.size.build(e,"v2")),s.push(this.alpha.build(e,"f")),s.push(this.mode.build(e,"i")),s.push(this.calpha),this.firstTime=!this.firstTime,e.format(i+"("+s.join(",")+")",this.getType(e),t)}},Ls=Bs;Ls.Nodes=function(){let e=new Q(`
1006
1006
  vec3 cylindricalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float alpha, int mode, out float calpha) {
1007
1007
  vec3 posN = normalize(position);
1008
1008
  float u = 0.5 + atan(posN.z, posN.x) / (2.*3.1415);
@@ -1032,7 +1032,7 @@ vec3 cylindricalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, v
1032
1032
  accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
1033
1033
  return col;
1034
1034
  }
1035
- `),t=new X(`
1035
+ `),t=new Q(`
1036
1036
  vec3 sphericalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float alpha, int mode, out float calpha) {
1037
1037
  vec3 posN = normalize(vPosition);
1038
1038
  float u = 0.5 + atan(posN.z, posN.x) / (2.*3.1415);
@@ -1060,7 +1060,7 @@ vec3 sphericalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec
1060
1060
  accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
1061
1061
  return col;
1062
1062
  }
1063
- `),o=new X(`vec3 uvTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float alpha, int mode, out float calpha) {
1063
+ `),o=new Q(`vec3 uvTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float alpha, int mode, out float calpha) {
1064
1064
 
1065
1065
  vec2 uvs = ( mat * vec3( vUv * 2. - 1., 1. ) / 2. + 0.5 ).xy;
1066
1066
  vec4 tmp = texture2D( tex, uvs );
@@ -1076,14 +1076,14 @@ vec3 sphericalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec
1076
1076
  calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
1077
1077
  accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
1078
1078
  return col;
1079
- }`);return{cylindrical:e,spherical:t,uv:o}}();var ad=class extends ce{constructor(e,t){super("v3");this.nodeType="CustomNormal";this.cnormal=e,this.alpha=t}generate(e,t){if(e.isShader("fragment")){let o=e.include(ad.Nodes.customNormal),i=[];return i.push(this.cnormal.build(e,"v3")),i.push("normal"),i.push(this.alpha.build(e,"f")),e.format(o+"("+i.join(",")+")",this.getType(e),t)}else return console.warn("CustomNormalNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},Ps=ad;Ps.Nodes=function(){return{customNormal:new X(`vec3 customNormal(vec3 cnormal, vec3 norm, float alpha) {
1079
+ }`);return{cylindrical:e,spherical:t,uv:o}}();var Ad=class extends ce{constructor(e,t){super("v3");this.nodeType="CustomNormal";this.cnormal=e,this.alpha=t}generate(e,t){if(e.isShader("fragment")){let o=e.include(Ad.Nodes.customNormal),i=[];return i.push(this.cnormal.build(e,"v3")),i.push("normal"),i.push(this.alpha.build(e,"f")),e.format(o+"("+i.join(",")+")",this.getType(e),t)}else return console.warn("CustomNormalNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},Ds=Ad;Ds.Nodes=function(){return{customNormal:new Q(`vec3 customNormal(vec3 cnormal, vec3 norm, float alpha) {
1080
1080
  vec3 normal = packNormalToRGB( norm ).rgb;
1081
1081
  normal *= step( vec3(0.5), cnormal );
1082
1082
 
1083
1083
  accumAlpha += ( 1.0 - accumAlpha ) * alpha;
1084
1084
 
1085
1085
  return normal;
1086
- }`)}}();var Ye=require("three");function At(n,r){return r.color(n)}function Nh(n,r){switch(n.type){case"fresnel":return l_(n,r);case"gradient":return c_(n);case"depth":return d_(n);case"normal":return u_(n);case"noise":return p_(n,r);case"rainbow":return f_(n);case"toon":return m_(n,r);case"outline":return h_(n,r);case"transmission":return y_(n,r);case"color":return a_(n,r)}}function s_(n){return{type:n.type}}function Mr(n){let{alpha:r,mode:e}=n;return{...s_(n),alpha:r,mode:e}}function a_(n,r){return{...Mr(n),color:At(n.color,r)}}function l_(n,r){let{bias:e,scale:t,intensity:o,factor:i,color:s}=n;return{...Mr(n),color:At(s,r),bias:e,scale:t,intensity:o,factor:i}}function c_(n){let{gradientType:r,smooth:e,colors:t,steps:o,angle:i,offset:s,morph:l}=n;return{...Mr(n),gradientType:r,smooth:e,colors:t.map(c=>new Ye.Vector4(c[0],c[1],c[2],c[3])),num:t.length,steps:o,offset:new Ye.Vector2(...s),morph:new Ye.Vector2(...l),angle:i}}function d_(n){let{gradientType:r,near:e,far:t,isVector:o,isWorldSpace:i,origin:s,direction:l,colors:c,steps:u,smooth:a}=n;return{...Mr(n),gradientType:r,near:e,far:t,isVector:o,isWorldSpace:i,origin:new Ye.Vector3(...s),direction:l?new Ye.Vector3(...l):new Ye.Vector3(1,0,0),colors:c.map(d=>d!==void 0?new Ye.Vector4(d[0],d[1],d[2],d[3]):new Ye.Vector4(0,0,0,0)),steps:u.slice(0,c.length),smooth:a}}function u_(n){let{cnormal:r}=n;return{...Mr(n),cnormal:new Ye.Vector3(r[0],r[1],r[2])}}function p_(n,r){return{...Mr(n),scale:n.scale,move:n.move,fA:new Ye.Vector2(...n.fA),fB:new Ye.Vector2(...n.fB),size:new Ye.Vector3(...n.size),distortion:new Ye.Vector2(...n.distortion),colorA:At(n.colorA,r),colorB:At(n.colorB,r),colorC:At(n.colorC,r),colorD:At(n.colorD,r),noiseType:n.noiseType}}function f_(n){return{...Mr(n),filmThickness:n.filmThickness,movement:n.movement,wavelengths:new Ye.Vector3(...n.wavelengths),noiseStrength:n.noiseStrength,noiseScale:n.noiseScale,offset:new Ye.Vector3(...n.offset)}}function m_(n,r){return{...Mr(n),positioning:n.positioning,colors:n.colors.map(e=>new Ye.Vector4(e[0],e[1],e[2],e[3])),num:n.colors.length,steps:n.steps,source:new Ye.Vector3(...n.source),isWorldSpace:n.isWorldSpace,noiseStrength:n.noiseStrength,noiseScale:n.noiseScale,shadowColor:At(n.shadowColor,r),offset:new Ye.Vector3(...n.offset)}}function h_(n,r){return{...Mr(n),outlineColor:At(n.outlineColor,r),contourColor:At(n.contourColor,r),outlineWidth:n.outlineWidth,contourWidth:n.contourWidth,outlineThreshold:n.outlineThreshold,contourThreshold:n.contourThreshold,outlineSmoothing:n.outlineSmoothing,contourFrequency:n.contourFrequency,contourDirection:new Ye.Vector3(...n.contourDirection),positionalLines:n.positionalLines,compensation:n.compensation}}function y_(n,r){return{...Mr(n),thickness:n.thickness,ior:n.ior,roughness:n.roughness}}var wo=class extends it{};var Lh=require("three");var xl=require("three");var hl=class{constructor(r=1e3*10){this.timeout=r;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(...r){}remove(r){let e=this.cache.get(r);e&&(this.dispose(r,e.data),this.cache.delete(r),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 r=Date.now(),e=this.head.next;for(;e.time<r-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(r){return this.cache.get(r)?.data}load(r){let e=Date.now(),t=this.cache.get(r);return t===void 0?(t={data:this.create(r),src:r,time:e,next:null,prev:null},this.cache.set(r,t)):(t.time=e,t.prev.next=t.next,t.next.prev=t.prev),t.prev=this.tail.prev,t.next=this.tail,this.tail.prev.next=t,this.tail.prev=t,this.scheduleCleanup(),t.data}};var cd=class extends hl{create(r){return URL.createObjectURL(new Blob([r]))}dispose(r,e){URL.revokeObjectURL(e)}},ld;function Eh(n){return typeof n=="string"?n:(ld||(ld=new cd),ld.load(n))}var yl=class{constructor(r,e){this.data=r;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")}},gl=class{constructor(){this.cache=new Map}remove(r){if(this.cache.delete(r.data)===!1&&!1)throw new Error("ref count remove non-exists")}load(r){let e=this.cache.get(r);return e===void 0&&(e=this.create(r),this.cache.set(r,e)),e.refCount+=1,e}};var mi=class extends yl{constructor(e,t){super(e,t.imageHolderCache);this.data=e;this.shared=t;this.loaded=!1;this.isVideo=!1;this.isVideo=e.type=="video",this.updateSrc(e.data)}async updateSrc(e){if(typeof document>"u")return;this.disposeTextures(),this.loaded=!1;let t=()=>{this.loaded=!0;let i=[1e3,1001,1002];for(let s of i){let l=this[s];l&&(l.image=this.img,l.needsUpdate=!0)}this.shared.requestRender()};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(s=>{o.onloadend=l=>{i=l.target?.result,s(null)}}),this.img.src=i}else this.img.src=e;this.img.onloadeddata=()=>{t()}}else this.img=new Image,this.img.src=Eh(e),this.img.onload=t}getTexture(e){let t=this[e];if(t)return t;{let o;return this.isVideo?o=new xl.VideoTexture(this.img,void 0,e,e):o=new xl.Texture(this.img,void 0,e,e),this.loaded&&(o.needsUpdate=!0),this[e]=o,o}}disposeTextures(){this[1e3]?.dispose(),this[1e3]=void 0,this[1001]?.dispose(),this[1001]=void 0,this[1002]?.dispose(),this[1002]=void 0}dispose(){super.dispose(),this.disposeTextures()}};1e3,1001,1002;var Jt=class extends mi{};var _o=class extends Ge{};var dd={noise:["noiseType"],texture:["projection","axis","side"],video:["projection","axis","side"],displace:["noiseType"],depth:["smooth","isWorldSpace","gradientType","isVector"]},ud={depth:["colors"]};function g_(n,r,e){let t=dd[n.type],o=ud[n.type];if(o!==void 0){let i=n.color;if(o.includes(r)){let s=i[r]?.value?.length;if(s!==void 0&&s!==e.length)return!0}}return t!==void 0?t.includes(r):!1}function pd(n,r,e){let t=e.uniforms[`f${e.id}_texture`];if(!t)return!1;let o=!1,i=n;if("image"in i){let s=i.image,l=r.image(s),c=t;c.image instanceof Jt||c.image.deref(),c.image=l}if("video"in i){let s=i.video,l=r.video(s),c=t;c.image instanceof Jt||c.image.deref(),c.image=l}if("wrapping"in i){let s=t;s.wrap=i.wrapping}if("repeat"in i||"offset"in i){let s="mat",l=e.uniforms[`f${e.id}_${s}`];"repeat"in i&&(l.repeat=i.repeat),"offset"in i&&(l.offset=i.offset),l.updateMatrix()}return o}function Mh(n,r,e,t){let o=!1;for(let[i,s]of Object.entries(n)){if(!i||s===void 0)continue;if(fd(i,e,t)){i==="visible"&&e.type==="light"&&(o=!0);continue}e.visible=t.visible;let l=e.uniforms[`f${e.id}_${i}`];if(!!l&&!(l instanceof _o))switch(o=o||g_(e,i,s),l.constructor){case Ie:if(typeof s=="string"){let c=r.getColor(s);c&&(l.value=c);break}else{let c=s;l.value instanceof wo?l.value=new it(c.r,c.g,c.b,c.a):l.setRGBA(c);break}case Qt:if(typeof s=="string"){let c=r.getColor(s);c&&(l.value=c);break}else{let c=s;l.value instanceof wo?l.value=new it(c.r,c.g,c.b,c.a):l.value.setRGBA(c.r,c.g,c.b,c.a);break}case ut:{let c=s;l.value.setX(c[0]),l.value.setY(c[1]);break}case yt:{let c=s;l.value.setX(c[0]),l.value.setY(c[1]),l.value.setZ(c[2]);break}case Rt:{pd(s,r,e);break}case hr:{l.value=s.map(c=>new Lh.Vector4(...c));break}default:{l.value=s;break}}}return o}var md=class extends ce{constructor(e,t,o){super("v3");this.nodeType="Matcap";this.texture=e,this.alpha=t,this.mode=o,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.isShader("fragment")){e.addFragmentVariable(this.calpha,"float");let o=e.include(md.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.alpha.build(e,"f")),i.push(this.mode.build(e,"i")),i.push(this.calpha),e.format(o+"("+i.join(",")+")",this.getType(e),t)}else return console.warn("MatcapNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},Is=md;Is.Nodes=function(){return{matcap:new X(`vec3 matcap(sampler2D matcapTex, vec3 normal, float alpha, int mode, out float calpha) {
1086
+ }`)}}();var Ke=require("three");function It(n,r){return r.color(n)}function Yh(n,r){switch(n.type){case"fresnel":return I_(n,r);case"gradient":return C_(n);case"depth":return N_(n);case"normal":return E_(n);case"noise":return M_(n,r);case"rainbow":return L_(n);case"toon":return B_(n,r);case"outline":return D_(n,r);case"transmission":return G_(n,r);case"color":return A_(n,r)}}function O_(n){return{type:n.type}}function Gr(n){let{alpha:r,mode:e}=n;return{...O_(n),alpha:r,mode:e}}function A_(n,r){return{...Gr(n),color:It(n.color,r)}}function I_(n,r){let{bias:e,scale:t,intensity:o,factor:i,color:s}=n;return{...Gr(n),color:It(s,r),bias:e,scale:t,intensity:o,factor:i}}function C_(n){let{gradientType:r,smooth:e,colors:t,steps:o,angle:i,offset:s,morph:l}=n;return{...Gr(n),gradientType:r,smooth:e,colors:t.map(c=>new Ke.Vector4(c[0],c[1],c[2],c[3])),num:t.length,steps:o,offset:new Ke.Vector2(...s),morph:new Ke.Vector2(...l),angle:i}}function N_(n){let{gradientType:r,near:e,far:t,isVector:o,isWorldSpace:i,origin:s,direction:l,colors:c,steps:u,smooth:a}=n;return{...Gr(n),gradientType:r,near:e,far:t,isVector:o,isWorldSpace:i,origin:new Ke.Vector3(...s),direction:l?new Ke.Vector3(...l):new Ke.Vector3(1,0,0),colors:c.map(d=>d!==void 0?new Ke.Vector4(d[0],d[1],d[2],d[3]):new Ke.Vector4(0,0,0,0)),steps:u.slice(0,c.length),smooth:a}}function E_(n){let{cnormal:r}=n;return{...Gr(n),cnormal:new Ke.Vector3(r[0],r[1],r[2])}}function M_(n,r){return{...Gr(n),scale:n.scale,move:n.move,fA:new Ke.Vector2(...n.fA),fB:new Ke.Vector2(...n.fB),size:new Ke.Vector3(...n.size),distortion:new Ke.Vector2(...n.distortion),colorA:It(n.colorA,r),colorB:It(n.colorB,r),colorC:It(n.colorC,r),colorD:It(n.colorD,r),noiseType:n.noiseType}}function L_(n){return{...Gr(n),filmThickness:n.filmThickness,movement:n.movement,wavelengths:new Ke.Vector3(...n.wavelengths),noiseStrength:n.noiseStrength,noiseScale:n.noiseScale,offset:new Ke.Vector3(...n.offset)}}function B_(n,r){return{...Gr(n),positioning:n.positioning,colors:n.colors.map(e=>new Ke.Vector4(e[0],e[1],e[2],e[3])),num:n.colors.length,steps:n.steps,source:new Ke.Vector3(...n.source),isWorldSpace:n.isWorldSpace,noiseStrength:n.noiseStrength,noiseScale:n.noiseScale,shadowColor:It(n.shadowColor,r),offset:new Ke.Vector3(...n.offset)}}function D_(n,r){return{...Gr(n),outlineColor:It(n.outlineColor,r),contourColor:It(n.contourColor,r),outlineWidth:n.outlineWidth,contourWidth:n.contourWidth,outlineThreshold:n.outlineThreshold,contourThreshold:n.contourThreshold,outlineSmoothing:n.outlineSmoothing,contourFrequency:n.contourFrequency,contourDirection:new Ke.Vector3(...n.contourDirection),positionalLines:n.positionalLines,compensation:n.compensation}}function G_(n,r){return{...Gr(n),thickness:n.thickness,ior:n.ior,roughness:n.roughness}}var Oo=class extends st{};var Kh=require("three");var Ll=require("three");var Nl=class{constructor(r=1e3*10){this.timeout=r;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(...r){}remove(r){let e=this.cache.get(r);e&&(this.dispose(r,e.data),this.cache.delete(r),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 r=Date.now(),e=this.head.next;for(;e.time<r-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(r){return this.cache.get(r)?.data}load(r){let e=Date.now(),t=this.cache.get(r);return t===void 0?(t={data:this.create(r),src:r,time:e,next:null,prev:null},this.cache.set(r,t)):(t.time=e,t.prev.next=t.next,t.next.prev=t.prev),t.prev=this.tail.prev,t.next=this.tail,this.tail.prev.next=t,this.tail.prev=t,this.scheduleCleanup(),t.data}};var Cd=class extends Nl{create(r){return URL.createObjectURL(new Blob([r]))}dispose(r,e){URL.revokeObjectURL(e)}},Id;function Xh(n){return typeof n=="string"?n:(Id||(Id=new Cd),Id.load(n))}var El=class{constructor(r,e){this.data=r;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")}},Ml=class{constructor(){this.cache=new Map}remove(r){if(this.cache.delete(r.data)===!1&&!1)throw new Error("ref count remove non-exists")}load(r){let e=this.cache.get(r);return e===void 0&&(e=this.create(r),this.cache.set(r,e)),e.refCount+=1,e}};var bi=class extends El{constructor(e,t){super(e,t.imageHolderCache);this.data=e;this.shared=t;this.loaded=!1;this.isVideo=!1;this.isVideo=e.type=="video",this.updateSrc(e.data)}async updateSrc(e){if(typeof document>"u")return;this.disposeTextures(),this.loaded=!1;let t=()=>{this.loaded=!0;let i=[1e3,1001,1002];for(let s of i){let l=this[s];l&&(l.image=this.img,l.needsUpdate=!0)}this.shared.requestRender()};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(s=>{o.onloadend=l=>{i=l.target?.result,s(null)}}),this.img.src=i}else this.img.src=e;this.img.onloadeddata=()=>{t()}}else this.img=new Image,this.img.src=Xh(e),this.img.onload=t}getTexture(e){let t=this[e];if(t)return t;{let o;return this.isVideo?o=new Ll.VideoTexture(this.img,void 0,e,e):o=new Ll.Texture(this.img,void 0,e,e),this.loaded&&(o.needsUpdate=!0),this[e]=o,o}}disposeTextures(){this[1e3]?.dispose(),this[1e3]=void 0,this[1001]?.dispose(),this[1001]=void 0,this[1002]?.dispose(),this[1002]=void 0}dispose(){super.dispose(),this.disposeTextures()}};1e3,1001,1002;var tr=class extends bi{};var Ao=class extends De{};var Nd={noise:["noiseType"],texture:["projection","axis","side"],video:["projection","axis","side"],displace:["noiseType"],depth:["smooth","isWorldSpace","gradientType","isVector"]},Ed={depth:["colors"]};function R_(n,r,e){let t=Nd[n.type],o=Ed[n.type];if(o!==void 0){let i=n.color;if(o.includes(r)){let s=i[r]?.value?.length;if(s!==void 0&&s!==e.length)return!0}}return t!==void 0?t.includes(r):!1}function Md(n,r,e){let t=e.uniforms[`f${e.id}_texture`];if(!t)return!1;let o=!1,i=n;if("image"in i){let s=i.image,l=r.image(s),c=t;c.image instanceof tr||c.image.deref(),c.image=l}if("video"in i){let s=i.video,l=r.video(s),c=t;c.image instanceof tr||c.image.deref(),c.image=l}if("wrapping"in i){let s=t;s.wrap=i.wrapping}if("repeat"in i||"offset"in i){let s="mat",l=e.uniforms[`f${e.id}_${s}`];"repeat"in i&&(l.repeat=i.repeat),"offset"in i&&(l.offset=i.offset),l.updateMatrix()}return o}function Zh(n,r,e,t){let o=!1;for(let[i,s]of Object.entries(n)){if(!i||s===void 0)continue;if(Ld(i,e,t)){i==="visible"&&e.type==="light"&&(o=!0);continue}e.visible=t.visible;let l=e.uniforms[`f${e.id}_${i}`];if(!!l&&!(l instanceof Ao))switch(o=o||R_(e,i,s),l.constructor){case Ie:if(typeof s=="string"){let c=r.getColor(s);c&&(l.value=c);break}else{let c=s;l.value instanceof Oo?l.value=new st(c.r,c.g,c.b,c.a):l.setRGBA(c);break}case er:if(typeof s=="string"){let c=r.getColor(s);c&&(l.value=c);break}else{let c=s;l.value instanceof Oo?l.value=new st(c.r,c.g,c.b,c.a):l.value.setRGBA(c.r,c.g,c.b,c.a);break}case ft:{let c=s;l.value.setX(c[0]),l.value.setY(c[1]);break}case xt:{let c=s;l.value.setX(c[0]),l.value.setY(c[1]),l.value.setZ(c[2]);break}case jt:{Md(s,r,e);break}case vr:{l.value=s.map(c=>new Kh.Vector4(...c));break}default:{l.value=s;break}}}return o}var Bd=class extends ce{constructor(e,t,o){super("v3");this.nodeType="Matcap";this.texture=e,this.alpha=t,this.mode=o,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.isShader("fragment")){e.addFragmentVariable(this.calpha,"float");let o=e.include(Bd.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.alpha.build(e,"f")),i.push(this.mode.build(e,"i")),i.push(this.calpha),e.format(o+"("+i.join(",")+")",this.getType(e),t)}else return console.warn("MatcapNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},Gs=Bd;Gs.Nodes=function(){return{matcap:new Q(`vec3 matcap(sampler2D matcapTex, vec3 normal, float alpha, int mode, out float calpha) {
1087
1087
  vec3 viewDir = normalize( vViewPosition );
1088
1088
  vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
1089
1089
  vec3 y = cross( viewDir, x );
@@ -1095,14 +1095,14 @@ vec3 sphericalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec
1095
1095
 
1096
1096
  return matcapColor.rgb;
1097
1097
  }
1098
- `)}}();var Xo=class extends _o{constructor(e,t){super("t");this.image=e;this.wrap=t}get value(){return this.image.getTexture(this.wrap)}};var Bh=require("three");var vl=class extends _o{constructor(e){super("v3");this.image=e;this._value=new Bh.Vector3}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 hd=class extends ce{constructor(e,t,o,i,s,l,c,u,a,d){super("v3");this.nodeType="Toon";this.positioning=e,this.colors=t,this.steps=o,this.source=i,this.isWorldSpace=s,this.noiseStrength=l,this.noiseScale=c,this.shadowColor=u,this.offset=a,this.alpha=d,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.require("worldNormal"),e.require("worldPosition"),e.isShader("fragment")){e.define("COLORS_MAX",10),e.addFragmentVariable(this.calpha,"float");let o=e.include(hd.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.alpha.build(e,"f")),i.push(this.calpha),e.format(o+"("+i.join(",")+")",this.getType(e),t)}else return console.warn("ToonNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},Cs=hd;Cs.Nodes=function(){let e=new X(`float rand(float n) {
1098
+ `)}}();var Zo=class extends Ao{constructor(e,t){super("t");this.image=e;this.wrap=t}get value(){return this.image.getTexture(this.wrap)}};var Qh=require("three");var Bl=class extends Ao{constructor(e){super("v3");this.image=e;this._value=new Qh.Vector3}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 Dd=class extends ce{constructor(e,t,o,i,s,l,c,u,a,d){super("v3");this.nodeType="Toon";this.positioning=e,this.colors=t,this.steps=o,this.source=i,this.isWorldSpace=s,this.noiseStrength=l,this.noiseScale=c,this.shadowColor=u,this.offset=a,this.alpha=d,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.require("worldNormal"),e.require("worldPosition"),e.isShader("fragment")){e.define("COLORS_MAX",10),e.addFragmentVariable(this.calpha,"float");let o=e.include(Dd.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.alpha.build(e,"f")),i.push(this.calpha),e.format(o+"("+i.join(",")+")",this.getType(e),t)}else return console.warn("ToonNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},Rs=Dd;Rs.Nodes=function(){let e=new Q(`float rand(float n) {
1099
1099
  return fract(sin(n) * 43758.5453123);
1100
- }`),t=new X(`float hash1(float p) {
1100
+ }`),t=new Q(`float hash1(float p) {
1101
1101
  p = fract(p * 0.011);
1102
1102
  p *= p + 7.5;
1103
1103
  p *= p + p;
1104
1104
  return fract(p);
1105
- }`),o=new X(`float valueNoise(vec3 x) {
1105
+ }`),o=new Q(`float valueNoise(vec3 x) {
1106
1106
  const vec3 step = vec3(110, 241, 171);
1107
1107
 
1108
1108
  vec3 i = floor(x);
@@ -1117,13 +1117,13 @@ vec3 sphericalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec
1117
1117
  mix( hash1(n + dot(step, vec3(0, 1, 0))), hash1(n + dot(step, vec3(1, 1, 0))), u.x), u.y),
1118
1118
  mix(mix( hash1(n + dot(step, vec3(0, 0, 1))), hash1(n + dot(step, vec3(1, 0, 1))), u.x),
1119
1119
  mix( hash1(n + dot(step, vec3(0, 1, 1))), hash1(n + dot(step, vec3(1, 1, 1))), u.x), u.y), u.z);
1120
- }`,[t]),i=new X(`vec3 hash3(vec3 x) {
1120
+ }`,[t]),i=new Q(`vec3 hash3(vec3 x) {
1121
1121
  x = vec3(dot(x,vec3(127.1, 311.7, 74.7)),
1122
1122
  dot(x,vec3(269.5, 183.3, 246.1)),
1123
1123
  dot(x,vec3(113.5, 271.9, 124.6)));
1124
1124
 
1125
1125
  return fract(sin(x)*43758.5453123);
1126
- }`),s=new X(`vec3 voronoiNoise(in vec3 x)
1126
+ }`),s=new Q(`vec3 voronoiNoise(in vec3 x)
1127
1127
  {
1128
1128
  vec3 p = floor(x);
1129
1129
  vec3 f = fract(x);
@@ -1154,7 +1154,7 @@ vec3 sphericalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec
1154
1154
 
1155
1155
  return vec3(sqrt(res), abs(id));
1156
1156
  }
1157
- `,[i]);return{toon:new X(`vec3 toon(int positioning, vec4 colors[COLORS_MAX], float steps[COLORS_MAX], vec3 source, bool isWorldSpace, float noiseStrength, float noiseScale, vec4 shadowColor, vec3 offset, float alpha, out float calpha) {
1157
+ `,[i]);return{toon:new Q(`vec3 toon(int positioning, vec4 colors[COLORS_MAX], float steps[COLORS_MAX], vec3 source, bool isWorldSpace, float noiseStrength, float noiseScale, vec4 shadowColor, vec3 offset, float alpha, out float calpha) {
1158
1158
  float t = 0.0;
1159
1159
  float shadow = 1.0;
1160
1160
 
@@ -1331,8 +1331,8 @@ vec3 sphericalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec
1331
1331
 
1332
1332
  return color.xyz;
1333
1333
 
1334
- }`,[bt.simplex,e,o,s])}}();var Gh=require("three");function Dh(n,r,e){n.setUvTransform(e[0],e[1],r[0],r[1],0,0,0)}var bl=class extends pi{constructor(e,t){super(new Gh.Matrix3);this.repeat=e;this.offset=t;Dh(this.value,e,t)}updateMatrix(){Dh(this.value,this.repeat,this.offset)}};var Br=class{constructor(r,e,t,o){this.id=r;this.uuid=e;this.data=t;this.uniforms={};for(let i in o)this.uniforms[`f${this.id}_${i}`]=o[i];for(let i in t)fd(i,this,t)}get type(){return this.data.type}static create(r,e,t,o){if(t.type==="light")return Dr.createLigherLayer(r,e,t,o);if(t.type==="texture"||t.type==="video"){let i=t.type==="texture"?o.image(t.texture.image):o.video(t.texture.video),s=new Xo(i,t.texture.wrapping),l=new vl(i),c=new bl(t.texture.repeat,t.texture.offset),u=new Q(t.crop?1:0),a=new be(t.projection??0),d=new be(["x","y","z"].indexOf(t.axis)??0),p=new be(t.side??0),f=new ut(t.size?new je.Vector2(t.size[0],t.size[1]):new je.Vector2(100,100)),m=new Q(t.alpha??1),h=new be(t.mode??0),y=new Os(s,l,u,a,d,p,f,c,m,h),g=new Pe(y.calpha,"f");return new et(r,e,t,{texture:s,textureSize:l,crop:u,projection:a,axis:d,side:p,size:f,mat:c,alpha:m,mode:h},y,h,g)}else if(t.type==="matcap"){let i=o.image(t.texture.image),s=new Xo(i,t.texture.wrapping),l=new Q(t.alpha??1),c=new be(t.mode??0),u=new Is(s,l,c),a=new Pe(u.calpha,"f");return new et(r,e,t,{texture:s,alpha:l,mode:c},u,c,a)}else if(t.type==="displace")if(t.displacementType==="noise"){let i=new yt(new je.Vector3(...t.offset)),s=new Q(t.scale??10),l=new Q(t.intensity??8),c=new Q(t.movement??1),u=new be(t.noiseType??0),a=new _s(l,c,i,s,u);return new Ns(r,e,t,{offset:i,scale:s,intensity:l,movement:c,noiseType:u},a)}else throw new Error;else return b_(r,e,t,o)}updateByOp(r,e,t){let o=r;if(o.path[0]===void 0){if(o.type===0)return"type"in o.props||"category"in o.props?(t.scene?.markNeedsUpdateRendererDirty(),!0):Mh(o.props,t.shared,this,e)}else if(o.path[0]==="texture")return"texture"in e||"video"in e?pd(o.props,t.shared,this):!0;return!1}dispose(){if(x_(this)){let r=this.uniforms[`f${this.id}_texture`];if(!r)return!1;let e=r;e.image instanceof Jt||e.image.deref()}}hasValueByKey(r){return this.uniforms[r]!==void 0}hasValue(r){return this.hasValueByKey(`f${this.id}_${r}`)}setValue(r,e){let t=`f${this.id}_${r}`;this.hasValueByKey(t)&&e!==void 0&&(this.uniforms[t].value=e)}getNode(r){let e=`f${this.id}_${r}`;if(this.hasValueByKey(e))return this.uniforms[e]}getValue(r){let e=`f${this.id}_${r}`;if(this.hasValueByKey(e))return this.uniforms[e].value}getName(r){let t=/f\d+_(.*)/.exec(r);if(t&&t.length>1)return t[1];console.log(`Layer.getName: error ${r}`)}getNames(){let r=[];for(let e in this.uniforms){let t=this.getName(e);t&&r.push(t)}return r}},et=class extends Br{constructor(e,t,o,i,s,l,c){super(e,t,o,i);this.params=i;this.color=s;this.mode=l;this.alpha=c}},Ns=class extends Br{constructor(e,t,o,i,s){super(e,t,o,i);this.position=s}},Dr=class extends Br{constructor(e,t,o,i,s){super(e,t,o,s);this.node=i}static createLigherLayer(e,t,o,i){let s,l=new Q(o.alpha),c=new be(o.mode),u;if(!o.visible)s=new Yo,u={};else if(o.category==="lambert"){s=new ds;let a=new Ie(i.color(o.emissive)??0);u={emissive:a},s.emissive=a}else if(o.category==="toon"){s=new ms;let a=new Q(o.shininess??30),d=new Ie(i.color(o.specular)??1118481);u={shininess:a,specular:d},s.shininess=a,s.specular=d}else if(o.category==="physical"){s=new ps;let a=new Q(o.roughness??.3),d=new Q(o.metalness??0),p=new Q(o.reflectivity??.5);u={roughness:a,metalness:d,reflectivity:p},s.roughness=a,s.metalness=d,s.reflectivity=p}else{s=new ml;let a=new Q(o.shininess??30),d=new Ie(o.specular!==void 0?i.color(o.specular)??1118481:1118481);u={shininess:a,specular:d},s.shininess=a,s.specular=d}return s.alpha=new Q(1),s.shadingAlpha=l,s.shadingBlend=c,u.alpha=s.shadingAlpha,u.mode=s.shadingBlend,new Dr(e,t,o,s,u)}get category(){return this.node.category}};function x_(n){let r=n instanceof Br?n.type:n;return r==="texture"||r==="video"||r==="displace_map"||r==="matcap"}function v_(n,r,e,t){switch(n.type){case"color":{let o=new Ie(t.color??5855577),i=new Q(t.alpha??1),s=new Pe("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");s.keywords.alpha=i;let l=new be(t.mode??0);return o.alpha=i,new et(r,e,n,{color:o,alpha:i,mode:l},o,l,s)}case"fresnel":{let o=new Ie(t.color??16777215),i=new Q(t.bias??.1),s=new Q(t.scale??1),l=new Q(t.intensity??2),c=new Q(t.factor??1),u=new Q(t.alpha??1),a=new be(t.mode??0),d=new gs(o,i,s,l,c,u,a),p=new Pe(d.calpha,"f");return new et(r,e,n,{color:o,bias:i,scale:s,intensity:l,factor:c,alpha:u,mode:a},d,a,p)}case"rainbow":{let o=new Q(t.filmThickness??30),i=new Q(t.movement??0),s=new yt(t.wavelengths??new je.Vector3(0,0,0)),l=new Q(t.noiseStrength??0),c=new Q(t.noiseScale??1),u=new yt(t.offset??new je.Vector3(0,0,0)),a=new Q(t.alpha??1),d=new xs(o,i,s,l,c,u,a),p=new Pe(d.calpha,"f"),f=new be(t.mode??0);return new et(r,e,n,{filmThickness:o,movement:i,wavelengths:s,noiseStrength:l,noiseScale:c,offset:u,alpha:a,mode:f},d,f,p)}case"transmission":{let o=new Q(t.thickness??10),i=new Q(t.ior??1.5),s=new Q(t.roughness??.5),l=gt.transmissionSize,c=gt.transmissionRenderTarget,u=gt.transmissionRenderTargetDepth,a=window.innerWidth,d=window.innerHeight,p=a>=d?new ut(d/a,1):new ut(1,a/d),f=new Q(t.alpha??1),m=new bs(o,i,s,l,c,u,p,f),h=new Pe(m.calpha,"f"),y=new be(t.mode??0);return new et(r,e,n,{thickness:o,ior:i,roughness:s,aspectRatio:p,alpha:f,mode:y},m,y,h)}case"toon":{let o=new be(t.positioning??0),i;t.colors?i=new hr(t.colors.length,t.colors):(i=new hr(10,new je.Vector4(0,0,0,1)),i.value[1]=new je.Vector4(1,1,1,1));let s;t.steps?s=new mr(t.steps.length,t.steps):(s=new mr(10,1),s.value[0]=0);let l=new yt(t.source??new je.Vector3(0,0,0)),c=new So(t.isWorldSpace??!0),u=new Q(t.noiseStrength??0),a=new Q(t.noiseScale??1),d=new Qt(t.shadowColor),p=new yt(t.offset??new je.Vector3(0,0,0)),f=new Q(t.alpha??1),m=new Cs(o,i,s,l,c,u,a,d,p,f),h=new Pe(m.calpha,"f"),y=new be(t.mode??0);return new et(r,e,n,{positioning:o,colors:i,steps:s,source:l,isWorldSpace:c,noiseStrength:u,noiseScale:a,shadowColor:d,offset:p,alpha:f,mode:y},m,y,h)}case"outline":{let o=new Ie(t.outlineColor??16777215),i=new Ie(t.contourColor??16777215),s=new Q(t.outlineWidth??.1),l=new Q(t.contourWidth??.1),c=new Q(t.outlineThreshold??.1),u=new Q(t.contourThreshold??.1),a=new Q(t.outlineSmoothing??.1),d=new Q(t.contourFrequency??.1),p=new yt(t.contourDirection??new je.Vector3(0,1,0)),f=new So(t.positionalLines??!1),m=new So(t.compensation??!0),h=gt.normalRenderTarget,y=gt.normalRenderTargetDepth,g=gt.pixelRatioNode,v=gt.resolution,w=new Q(t.alpha??1),b=new vs(o,i,s,l,c,u,a,d,p,f,m,v,h,y,g,w),S=new Pe(b.calpha,"f"),A=new be(t.mode??0);return new et(r,e,n,{outlineColor:o,contourColor:i,outlineWidth:s,contourWidth:l,outlineThreshold:c,contourThreshold:u,outlineSmoothing:a,contourFrequency:d,contourDirection:p,positionalLines:f,compensation:m,alpha:w,mode:A},b,A,S)}case"depth":{let o=new be(t.gradientType??0),i=new So(t.smooth??!1),s=new Q(t.near??50),l=new Q(t.far??200),c=new Q(t.isVector??1),u=new Q(t.isWorldSpace??0),a=new yt(t.origin??new je.Vector3),d=new yt(t.direction??new je.Vector3),p;t.colors?p=new hr(t.colors.length,t.colors):(p=new hr(2,new je.Vector4(0,0,0,1)),p.value[1]=new je.Vector4(1,1,1,1));let f;t.steps?f=new mr(t.steps.length,t.steps):(f=new mr(2,1),f.value[0]=0);let m=new Q(t.alpha??1),h=new be(t.mode??0),y=new Ss(o,i,s,l,c,u,a,d,p,f,m),g=new Pe(y.calpha,"f");return new et(r,e,n,{gradientType:o,smooth:i,near:s,far:l,isVector:c,isWorldSpace:u,origin:a,direction:d,colors:p,steps:f,alpha:m,mode:h},y,h,g)}case"noise":{let o=new Q(t.scale??1),i=new yt(t.size??new je.Vector3(100,100,100)),s=new Q(t.move??1),l=new ut(t.fA??new je.Vector2(1.7,9.2)),c=new ut(t.fB??new je.Vector2(8.3,2.8)),u=new ut(t.distortion??new je.Vector2(1,1)),a=new Qt(t.colorA),d=new Qt(t.colorB),p=new Qt(t.colorC),f=new Qt(t.colorD),m=new Q(t.alpha??1),h=new be(t.mode??0),y=new be(t.noiseType??0),g=new ys(o,i,s,l,c,u,a,d,p,f,m,y),v=new Pe(g.calpha,"f");return new et(r,e,n,{scale:o,size:i,move:s,fA:l,fB:c,distortion:u,colorA:a,colorB:d,colorC:p,colorD:f,alpha:m,mode:h,noiseType:y},g,h,v)}case"normal":{let o=new yt(t.cnormal??new je.Vector3(1,1,1)),i=new Q(t.alpha??1),s=new be(t.mode??0),l=new Ps(o,i),c=new Pe("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");return c.keywords.alpha=i,new et(r,e,n,{cnormal:o,alpha:i,mode:s},l,s,c)}case"gradient":{let o=new be(t.gradientType??0),i=new So(t.smooth??!1),s;t.colors?s=new hr(t.colors.length,t.colors):(s=new hr(10,new je.Vector4(0,0,0,1)),s.value[1]=new je.Vector4(1,1,1,1));let l;t.steps?l=new mr(t.steps.length,t.steps):(l=new mr(10,1),l.value[0]=0);let c=new ut(t.offset??new je.Vector2(0,0)),u=new ut(t.morph??new je.Vector2(0,0)),a=new Q(t.angle??0),d=new Q(t.alpha??1),p=new be(t.mode??0),f=new Ts(o,i,s,l,c,u,a,d),m=new Pe(f.calpha,"f");return new et(r,e,n,{gradientType:o,smooth:i,colors:s,steps:l,offset:c,morph:u,angle:a,alpha:d,mode:p},f,p,m)}default:{let o=new Ie(1,0,0,1),i=new Q(1),s=new Pe("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");s.keywords.alpha=i;let l=new be(0);return o.alpha=i,new et(r,e,n,{color:o,alpha:i,mode:l},o,l,s)}}}function b_(n,r,e,t){let o=Nh(e,t);return v_(e,n,r,o)}function fd(n,r,e){if(e.type==="displace"&&(n==="intensity"||n==="visible")){let t=r.uniforms[`f${r.id}_intensity`];return t?(t.value=e.intensity*(e.visible?1:0),t):void 0}if(e.type!=="displace"&&(n==="alpha"||n==="visible")){let t=r.uniforms[`f${r.id}_alpha`];if(!t)return;if(t.value=e.alpha*(e.visible?1:0),e.type==="outline"&&n==="visible"){let o=r.uniforms[`f${r.id}_compensation`];o&&(o.value=e.compensation&&e.visible)}return t}}function Rh(n,r){let e=0;for(let t of n.layers)if(t.data.type!=="displace"&&"alpha"in t.data&&t.data.type!=="light"&&t.data.type!=="fresnel"&&t.data.type!=="texture"&&t.data.type!=="matcap"&&t.data.type!=="rainbow"&&t.data.type!=="outline"){let o=t.data.visible?t.data.alpha:0;if(o==1&&t.data.type=="depth"||t.data.type=="gradient"){for(let i of t.data.colors)if(i[3]<1){o=i[3];break}}else if(o==1&&t.data.type=="noise"){let i=r.color(t.data.colorA).a,s=r.color(t.data.colorB).a,l=r.color(t.data.colorC).a,c=r.color(t.data.colorD).a,u=Math.min(i,Math.min(s,Math.min(l,c)));u<1&&(o=u)}e+=(1-e)*o}return e<1}var Ft=class extends Vh.ShaderMaterial{constructor(){super(void 0);this.flatShading=!1;this.cacheKey="";this.fog=!0,this.dithering=!0,this.vertexColors=!0,this.transparent=!0}customProgramCacheKey(){return this.cacheKey}},yd=class extends Ft{constructor(e,t,o,i){super();this.flatShading=e;this.side=t;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,t){this.root.onBeforeCompile(e)}get data(){return this.root.data}get category(){return this.root.category}getFlavor(e,t,o){return this.root.getFlavor(e,t,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,t,o){this.root.updateByOp(e,t,o)}nodeMaterialDispose(){this.root.nodeMaterialDispose()}},hi=class extends Ft{constructor(e,t){super();this.data=e;this.layerIdGen=0;this.flavors=[];this.type="NodeMaterial";this.updaters=[],this.reset0(e,t)}get nodeMaterial(){return this}getFlavor(e,t,o){let i=o?6:(e?3:0)+t;if(i===0)return this;this.flavors===void 0&&(this.flavors=[]),i-=1;let s=this.flavors[i];return s===void 0&&(s=new yd(e,t,o,this),this.flavors[i]=s,s.flatShading=e,s.side=t,s.updateAfterBuild()),s}get fragment(){return this.lightLayer.node}get category(){return this.lightLayer.category}reset(e,t){this.data!==e&&this.reset0(e,t)}reset0(e,t){this.data=e;let o=e.layers??Mt.defaultTwoLayerData("phong").layers;this.layers=o.map(i=>Br.create(this.layerIdGen++,i.id,i.data,t.shared)),this.layers.reverse(),this.name=e.name??"Untitled Material",this.onUpdate(),this.transparent=Rh(e,t.shared)}getLayersOfType(e){return this.layers.filter(t=>t.type===e)}getLayerByUuid(e){return this.layers.find(t=>t.uuid===e)}onUpdate(){this.cacheKey=this.computeCacheKey(),this.lightLayer=this.layers.find(e=>e instanceof Dr),this.lightLayer===void 0&&(this.lightLayer=new Dr(0,"",{...Tt.defaultData("light","phong"),visible:!1},new Yo,{})),this.dispose(),this.needsUpdate=!0,this.blendColors(),this.blendAfterColors(),this.blendPositions()}updateByOp(e,t,o){if(this.data=t,this.transparent=Rh(t,o.shared),e.path[0]==="layers"){this.data=t;let i=o.shared,s=e.path[1];if(s===void 0){if(this.layers.reverse(),e.type===4){let l=Br.create(this.layerIdGen++,e.id,e.data,o.shared);this.layers.splice(e.localIndex,0,l),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 l=this.layers.findIndex(u=>u.uuid===e.id),c=this.layers[l];this.layers.splice(l,1),this.layers.splice(e.localIndex,0,c),o.scene?.markNeedsUpdateRendererDirty()}this.layers.reverse(),this.onUpdate()}else{let l=this.layers.find(c=>c.uuid===s);if(l){let c=t.layers.data(s);if(l.updateByOp({...e,path:e.path.slice(2)},c,o)){let a=Br.create(this.layerIdGen++,s,c,i);this.layers.splice(this.layers.findIndex(d=>d.uuid===s),1,a),this.onUpdate()}}}}else this.reset(t,o)}blendColors(){let e=this.layers.findIndex(o=>o instanceof et),t=this.layers.findIndex(o=>o instanceof Dr);if(e!==-1&&e<t){let o=this.layers[e].color;for(let i=e+1;i<t;++i){let s=this.layers[i];s instanceof et&&(o=new ws(o,s.color,s.alpha,s.mode))}this.fragment.color=o}else this.fragment.color=void 0}blendAfterColors(){let e=new Pe("outgoingLight","f"),t=this.layers.findIndex(o=>o instanceof Dr);if(this.layers.length>t+1){for(let o=t+1;o<this.layers.length;++o){let i=this.layers[o];i instanceof et&&(e=new ws(e,i.color,i.alpha,i.mode))}this.fragment.afterColor=e}else this.fragment.afterColor=void 0}blendPositions(){let e=this.layers.filter(t=>t instanceof Ns);if(e.length>0){let t=e[0].position;for(let o=1;o<e.length;++o)e[o]&&(t=new Vt(t,e[o].position,Vt.ADD),t=new Vt(t,new Q(.5).setReadonly(!0),Vt.MUL));this.fragment.position=t}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,t){let o=(i,s,l)=>Math.min(Math.max(i,s),l);for(let i of this.layers)if(i.type==="displace"){let s=o(i.uniforms[`f${i.id}_intensity`].value,e,t);i.uniforms[`f${i.id}_intensity`].value=s}}computeCacheKey(){let e="[";for(let{data:t}of this.data.layers)if(t.type==="light")e+=`"${t.visible?t.category.toUpperCase():"Basic"}"`;else{let o=(dd[t.type]??[]).map(l=>t[l]),i=(ud[t.type]??[]).map(l=>t[l]?.length??0),s=[...o,...i];s.length?e+=`["${t.type}", "${s.join('","')}"],`:e+=`"${t.type}",`}return e=e.slice(0,-1)+"]",e}updateFrame(e){for(let t=0;t<this.updaters.length;++t)e.updateNode(this.updaters[t])}build(){let e=new pl;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 t of this.flavors)t&&t.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 et){let t=e.params.texture;if(t instanceof Xo&&!t.image.loaded)return!1}return!0}getHash(){let e="{";return e+='"fragment":'+this.fragment.getHash(),e+="}",e}};Object.defineProperties(Ft.prototype,{properties:{get:function(){return this.fragment.properties}}});var Ko=class extends hi{};var zh=Ni(jh());var Fh=new Map;function Uh(n){if(typeof n=="string")return n;let r=Fh.get(n);return r||(r={url:URL.createObjectURL(new Blob([n]))},Fh.set(n,r)),r.url}var Zo=class{constructor({src:r,volume:e,delay:t,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 r=="string"?i={src:r}:i={src:Uh(r),format:"wav"},this.sound=new zh.Howl(i),this.sound.on("end",this.onEnd),this.src=r,e!==void 0&&(this.volume=e),t!==void 0&&(this.delay=t),o!==void 0&&(this.loop=o)}get status(){return this._status}get volume(){return this._volume}set volume(r){this._volume=r,this.sound.volume(r)}get loop(){return this._loop}set loop(r){this._loop=r,this.loopsRemaining=r}replay(){this.clearDelay(),this.delayTimerId=window.setTimeout(()=>{this.sound.play(),this.clearDelay()},this.delay)}fade(r,e=1e3){r?(this.sound.volume(this._volume),this.clearFade(),this.fadeTimerId=window.setTimeout(()=>{this.sound.fade(this._volume,0,e),this.clearFade()},r)):this.sound.fade(this._volume,0,e)}on(r,e,t){this.sound.on(r,e,t)}off(r,e,t){this.sound.off(r,e,t)}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(r=!1){this.off(),this.stop(),this.clearFade(),this.clearDelay()}};var st=require("three"),wl=class{constructor(){this.type="ShapePath";this.color=new st.Color;this.subPaths=[];this.currentPath=null}moveTo(r,e){return this.currentPath=new st.Path,this.subPaths.push(this.currentPath),this.currentPath.moveTo(r,e),this}lineTo(r,e){return this.currentPath?.lineTo(r,e),this}quadraticCurveTo(r,e,t,o){return this.currentPath?.quadraticCurveTo(r,e,t,o),this}bezierCurveTo(r,e,t,o,i,s){return this.currentPath?.bezierCurveTo(r,e,t,o,i,s),this}splineThru(r){return this.currentPath?.splineThru(r),this}toShapes(){let e={ORIGIN:0,DESTINATION:1,BETWEEN:2,LEFT:3,RIGHT:4,BEHIND:5,BEYOND:6},t={loc:e.ORIGIN,t:0};function o(h,y,g,v){let w=h.x,b=y.x,S=g.x,A=v.x,_=h.y,x=y.y,P=g.y,O=v.y,I=(A-S)*(_-P)-(O-P)*(w-S),T=(b-w)*(_-P)-(x-_)*(w-S),N=(O-P)*(b-w)-(A-S)*(x-_),L=I/N,U=T/N;if(N===0&&I!==0||L<=0||L>=1||U<0||U>1)return null;if(I===0&&N===0){for(let K=0;K<2;K++)if(i(K===0?g:v,h,y),t.loc===e.ORIGIN){let J=K===0?g:v;return{x:J.x,y:J.y,t:t.t}}else if(t.loc===e.BETWEEN){let J=+(w+t.t*(b-w)).toPrecision(10),se=+(_+t.t*(x-_)).toPrecision(10);return{x:J,y:se,t:t.t}}return null}else{for(let se=0;se<2;se++)if(i(se===0?g:v,h,y),t.loc===e.ORIGIN){let z=se===0?g:v;return{x:z.x,y:z.y,t:t.t}}let K=+(w+L*(b-w)).toPrecision(10),J=+(_+L*(x-_)).toPrecision(10);return{x:K,y:J,t:L}}}function i(h,y,g){let v=g.x-y.x,w=g.y-y.y,b=h.x-y.x,S=h.y-y.y,A=v*S-b*w;if(h.x===y.x&&h.y===y.y){t.loc=e.ORIGIN,t.t=0;return}if(h.x===g.x&&h.y===g.y){t.loc=e.DESTINATION,t.t=1;return}if(A<-Number.EPSILON){t.loc=e.LEFT;return}if(A>Number.EPSILON){t.loc=e.RIGHT;return}if(v*b<0||w*S<0){t.loc=e.BEHIND;return}if(Math.sqrt(v*v+w*w)<Math.sqrt(b*b+S*S)){t.loc=e.BEYOND;return}let _;v!==0?_=b/v:_=S/w,t.loc=e.BETWEEN,t.t=_}function s(h,y){let g=[],v=[];for(let w=1;w<h.length;w++){let b=h[w-1],S=h[w];for(let A=1;A<y.length;A++){let _=y[A-1],x=y[A],P=o(b,S,_,x);P!==null&&g.find(O=>O.t<=P.t+Number.EPSILON&&O.t>=P.t-Number.EPSILON)===void 0&&(g.push(P),v.push(new st.Vector2(P.x,P.y)))}}return v}function l(h,y,g){let v=new st.Vector2;y.getCenter(v);let w=[];return g.forEach(b=>{b.boundingBox.containsPoint(v)&&s(h,b.points).forEach(A=>{w.push({identifier:b.identifier,isCW:b.isCW,point:A})})}),w.sort((b,S)=>b.point.x-S.point.x),w}function c(h,y,g,v,w){(w==null||w==="")&&(w="nonzero");let b=new st.Vector2;h.boundingBox.getCenter(b);let S=[new st.Vector2(g,b.y),new st.Vector2(v,b.y)],A=l(S,h.boundingBox,y);A.sort((T,N)=>T.point.x-N.point.x);let _=[],x=[];A.forEach(T=>{T.identifier===h.identifier?_.push(T):x.push(T)});let P=_[0].point.x,O=[],I=0;for(;I<x.length&&x[I].point.x<P;)O.length>0&&O[O.length-1]===x[I].identifier?O.pop():O.push(x[I].identifier),I++;if(O.push(h.identifier),w==="evenodd"){let T=O.length%2===0,N=O[O.length-2];return{identifier:h.identifier,isHole:T,for:N}}else if(w==="nonzero"){let T=!0,N=null,L=null;for(let U=0;U<O.length;U++){let K=O[U];y[K]&&(T?(L=y[K].isCW,T=!1,N=K):L!==y[K].isCW&&(L=y[K].isCW,T=!0))}return{identifier:h.identifier,isHole:T,for:N}}else console.warn('fill-rule: "'+w+'" is currently not implemented.')}let u=0,a=999999999,d=-999999999,p=[];this.subPaths.forEach(h=>{let y=h.getPoints(),g=-999999999,v=999999999,w=-999999999,b=999999999;for(let S=0;S<y.length;S++){let A=y[S];A.y>g&&(g=A.y),A.y<v&&(v=A.y),A.x>w&&(w=A.x),A.x<b&&(b=A.x)}d<=w&&(d=w+1),a>=b&&(a=b-1),y.length&&p.push({curves:h.curves,points:y,isCW:st.ShapeUtils.isClockWise(y),identifier:u++,boundingBox:new st.Box2(new st.Vector2(b,v),new st.Vector2(w,g))})});let f=p.map(h=>c(h,p,a,d,this.userData?.style.fillRule)),m=[];return p.forEach(h=>{let y=f[h.identifier];if(y&&!y.isHole){let g=new st.Shape;g.curves=h.curves,f.filter(w=>w?.isHole&&w.for===h.identifier).forEach(w=>{if(w){let b=p[w.identifier],S=new st.Path;S.curves=b.curves,g.holes.push(S)}}),m.push(g)}}),m}};var Hh,gd=new Promise(n=>{Hh=n}),kh=!1;async function Wh(){if(kh)return;let n=await import("./opentype.js");Hh(n),kh=!0}var Es=class{async load(r,e,t=()=>{}){let{load:o}=await gd;o(r,(i,s)=>{i||!s?t(i??"Something went wrong"):e(s)})}async parse(r){let{parse:e,Bidi:t}=await gd;try{let o=e(r),i=new t,s=l=>o.charToGlyphIndex(l.char);return i.registerModifier("glyphIndex",null,s),i.applyFeatures(o,o.defaultRenderOptions.features),{font:o,bidi:i}}catch(o){console.error(o)}}};async function S_(n){return await(await fetch(n)).arrayBuffer()}var w_=new Es;async function xd(n){let r,e,t=!1;if(n.url?(r=await S_(n.url),e=n.url,t=n.url.startsWith("/")):n.data&&(r=n.data.buffer),r){let o=await w_.parse(r);if(o)return{font:o.font,url:e,intercepted:t,arr:r,bidi:o.bidi}}}var yi=require("three");function __(n,r){return r.state.glyphIndex===n||r.state.fina===n||r.state.medi===n||r.state.init===n}var _l=class{constructor(r){this._arrayBuffer=new ArrayBuffer(1);this._isLoaded=!1;this._intercepted=!1;this._isUserFont=r.isUserFont??!1,this._loadingPromise=xd(r).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(r){this._isLoaded=!1,this._isUserFont=r.isUserFont??!1,this._loadingPromise=xd(r).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(r,e,t){if(!this._bidi)return[];let o=this._bidi;o.getTextGlyphs(e);let i=o.tokenizer.tokens,s=[],l=0,c=t.length===i.length;for(let u=0;u<t.length;u++){let a=t[u].index,d=String.fromCharCode(t[u].unicode),p=i[l];if(__(a,p)||c)s.push({char:d,index:a,replacements:[p.state.glyphIndex],replacementChars:[p.char]}),l++;else{let f=p.char,m="",h=[p.state.glyphIndex],y=[],g=!1;for(;!g;)l++,m=e.charAt(l),f+=m,h.push(r.charToGlyphIndex(m)),y=r.stringToGlyphs(f),y.length===1&&y[0].index===a&&(g=!0),l>e.length&&(g=!0);s.push({char:d,index:a,replacements:h,replacementChars:Array.from(f)}),l++}}return s}generateShapes(r,e){if(!this._isLoaded)return;let t=this.font,o=e.fontSize/this.unitsPerEm,i=e.fontSize*e.lineHeight,s=r.map(v=>this.getTextWidth(v,e)),l=e.width,c=this.getCharWidth(`
1335
- `,e),u=e.horizontalAlign===1?c:0,a=this.computeSpaceWidthForLine(r,0,e),d=this.getLineInitialOffsetX(s[0],l,e.horizontalAlign,r[0],c),p=this.getLineInitialOffsetY(i,r.length,e.height,o,e.verticalAlign),f=[],m=r.map(v=>[]),h=r.map(v=>[]),y;for(let v=0;v<r.length;v++){let w=r[v],b={features:{liga:!0}},S=[];try{S=t.stringToGlyphs(w,b)}catch(_){console.warn(_)}d=this.getLineInitialOffsetX(s[v],l,e.horizontalAlign,w,c);let A=[];try{A=this.reverseLigaturesTable(t,w,S)}catch(_){console.warn(_)}a=this.computeSpaceWidthForLine(r,v,e);for(let _=0;_<S.length;_++){let x=S[_],P=x.index===0?`
1336
- `:x.unicode?String.fromCharCode(x.unicode):void 0,O=A[_],I=0,T=0;_===0&&e.horizontalAlign===2&&x.leftSideBearing!==void 0&&(T=-x.leftSideBearing*o),y&&(I=t.getKerningValue(x,y)*o),d+=T+I;let N=0;if(P===`
1337
- `)N=u;else if(P===" ")N=a;else{let L=this.createPath(x,o,d,p,e);L&&(N=L.offsetX-(I+T),f.push(L.path))}if(O.replacements.length===1)h[v].push([d,p]),m[v].push(N);else{let L=O.replacements.map(se=>(t.glyphs.get(se).advanceWidth??0)*o),U=L.reduce((se,z)=>se+=z,0),K=L.map(se=>se/U),J=d;for(let se=0;se<K.length;se++){let z=N*K[se];h[v].push([J,p]),m[v].push(z),J+=z}}d+=N,y=x}p-=i}let g=[];for(let v=0,w=f.length;v<w;v++)g.push(...f[v].toShapes());return{shapes:g,charWidths:m,lineWidths:s,charCoords:h}}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(r,e,t,o,i){return(t===3||t===2)&&o.indexOf(`
1338
- `)>=0&&(r-=i),t===3?e*.5-r*.5:t===2?e-r:0}getLineInitialOffsetY(r,e,t,o,i){let s=e*r,l=Math.abs(this.ascender-this.descender)*o,c=r-l,u=-this.ascender*o-c/2;return i===3?-(t-s-u):i===2?-(t*.5-s*.5-u):u}createPath(r,e,t,o,i){let s=r.getPath(t,-o,i.fontSize,{kerning:!1,letterSpacing:i.letterSpacing});if(!s){console.error('THREE.Font: character "'+r+'" does not exists in font family '+this.familyName+".");return}let l=new wl,c=(r.advanceWidth??1)*e;if(r)for(let u of s.commands){let a=l.currentPath?.currentPoint;if(!(a&&u.type!=="Z"&&a.x===u.x&&-a.y===u.y))switch(u.type){case"M":l.moveTo(u.x,-u.y);break;case"L":l.lineTo(u.x,-u.y);break;case"Q":l.quadraticCurveTo(u.x1,-u.y1,u.x,-u.y);break;case"C":l.bezierCurveTo(u.x1,-u.y1,u.x2,-u.y2,u.x,-u.y);break}}return l.subPaths.forEach(u=>{let a=T_(u.curves);a!==void 0&&u.currentPoint.distanceTo(a)>0&&u.lineTo(a.x,a.y)}),{offsetX:c+i.fontSize*i.letterSpacing,path:l}}getCharWidth(r,e){return this.font?.getAdvanceWidth(r,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}getTextWidth(r,e){return this.font?.getAdvanceWidth(r,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}computeSpaceWidthForLine(r,e,t){let o=this.getCharWidth(" ",t),i=r[e];if(i){let s=this.countSpaces(i.trimEnd());if(t.horizontalAlign===4&&e<r.length-1&&s){let l=t.width,c=this.getTextWidth(i,t);return(l-(c-s*o))/s}}return o}countSpaces(r){return(r.match(/ /g)||[]).length}};function T_(n){if(n.length){let r=n[0];if(r instanceof yi.LineCurve)return r.v1;if(r instanceof yi.CubicBezierCurve||r instanceof yi.QuadraticBezierCurve)return r.v0}}var vd=class{constructor(){this.objects=new Map;this.unreachable=new Set}getCached(r){return this.objects.get(r)}get size(){return this.objects.size}get(r,e){let t=this.objects.get(r);return t===void 0?(t=this.createObject(r,e),this.objects.set(r,t)):t.isShared=!0,t}mutateIfUnique(r,e){let t=this.objects.get(r);if(t&&t.isShared!==!0)return this.objects.delete(r),this.objects.set(e,t),t}startGc(){this.unreachable=new Set(this.objects.keys())}markAsReachable(r,e){let t=this.objects.get(r);e===t?this.unreachable.delete(r):!1&&console.warn("Reachable but deleted",r)}endGc(){this.unreachable.forEach(r=>{this.disposeObject(this.objects.get(r)),this.objects.delete(r)}),this.unreachable.clear()}dispose(){this.objects.forEach(r=>{this.disposeObject(r)}),this.objects.clear()}},Ls=class extends vd{constructor(e){super();this.flatShading=e}disposeObject(e){e.dispose()}createObject(e,t){let o=Wo(e,t,this.flatShading);return o.computeBoundingSphere(),o}};var qh={find(n){},markNeedsUpdateRendererDirty:function(){},markGeometryCacheDirty:function(){},addPendingExpandCloner:function(n){},addPendingUpdateCloner(n){}};var bd=class extends gl{constructor(e){super();this.shared=e}create(e){return new mi(e,this.shared)}},Qo=class{constructor(r,e={}){this.geometryCache=new Ls(!0);this.geometryCache2=new Ls(!1);this.imageHolderCache=new bd(this);this.thisContext={scene:qh,shared:this};this.deletedMaterial=new Ko(Mt.defaultTwoLayerData("phong"),this.thisContext);this.deletedImage=new Jt(Wa.emptyImage,this);this.deletedVideo=new Jt(fn.defaultVideo,this);this.materials={};this.images={};this.videos={};this.colors={};this.audios={};this.fonts={};this.penumbraSize=[];this.requestRender=()=>{this._requestRender&&this._requestRender()};if(e.images)for(let[t,o]of Object.entries(e.images))this.addImage(t,o);if(e.videos)for(let[t,o]of Object.entries(e.videos))this.addVideo(t,o);if(e.audios)for(let[t,o]of Object.entries(e.audios))this.addAudio(t,o.data);this.reset(r)}setRequestRender(r){this._requestRender=r}reset(r){for(let[e,t]of Object.entries(r.images))this.addImage(e,t);for(let[e,t]of Object.entries(r.videos))this.addVideo(e,t);for(let[e,t]of Object.entries(r.colors))this.addColor(e,t);for(let[e,t]of Object.entries(r.materials))this.addMaterial(e,new Ko(t,this.thisContext));for(let[e,t]of Object.entries(r.audios))this.addAudio(e,t.data);for(let[e,t]of Object.entries(r.fonts))this.addFont(e,t);this.penumbraSize=r.penumbraSize}addMaterial(r,e){e.uuid=r,this.materials[r]=e}deleteMaterial(r){this.materials[r]&&(this.materials[r].nodeMaterialDispose(),delete this.materials[r])}getMaterial(r){let e=this.materials[r];return e}getMaterialOrDeletedPlaceholder(r){return this.materials[r]??this.deletedMaterial}material(r){return typeof r=="string"?this.getMaterialOrDeletedPlaceholder(r):new hi(r,this.thisContext)}getMaterials(){return this.materials}addImage(r,e){return this.images[r]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.images[r].updateSrc(e.data),!0):(this.images[r]=new Jt(e,this),!1)}deleteImage(r){let e=this.images[r];e&&(e.dispose(),delete this.images[r])}getDefaultImage(){return this.images.image_0}getImage(r){return this.images[r]??this.deletedImage}image(r){return typeof r=="string"?this.getImage(r):this.imageHolderCache.load(r)}addVideo(r,e){return this.videos[r]?(this.videos[r].updateSrc(e.data),!0):(this.videos[r]=new Jt(e,this),!1)}deleteVideo(r){let e=this.videos[r];e&&(e.dispose(),delete this.videos[r])}getVideo(r){return this.videos[r]??this.deletedVideo}video(r){return typeof r=="string"?this.getVideo(r):this.imageHolderCache.load(r)}addColor(r,e){return this.colors[r]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),"a"in e?this.colors[r].setRGBA(e.r,e.g,e.b,e.a):this.colors[r].setRGBA(e.r,e.g,e.b,1),!0):("a"in e?this.colors[r]=new wo(e.r,e.g,e.b,e.a):this.colors[r]=new wo(e.r,e.g,e.b,1),!1)}updateColor(r,e){if(this.colors[r]){this.onColorOrImageUpdate&&this.onColorOrImageUpdate();let t=this.colors[r];return this.colors[r].r=e.r??t.r,this.colors[r].g=e.g??t.g,this.colors[r].b=e.b??t.b,this.colors[r].a=e.a??t.a,!0}return!1}deleteColor(r){this.colors[r]&&delete this.colors[r]}getColor(r){return this.colors[r]}color(r){let e;if(typeof r=="string"){let t=this.getColor(r);t?e=t:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),e=new it(0,0,0,0))}else return"a"in r?new it(r.r,r.g,r.b,r.a):new it(r.r,r.g,r.b,1);return e}addAudio(r,e){this.audios[r]=e}getAudio(r){let e=this.audios[r];if(e instanceof Zo)return e;{let t=new Zo({src:e});return this.audios[r]=t,t}}deleteAudio(r){let e=this.audios[r];e&&(e instanceof Zo&&e.dispose(),delete this.audios[r])}addFont(r,e){this.fonts[r]=new _l(e),this.fonts[r].loadingPromise.then(()=>this.requestRender())}getFont(r){return this.fonts[r]}deleteFont(r){this.fonts[r]&&delete this.fonts[r]}dispose(){Object.keys(this.materials).forEach(e=>this.deleteMaterial(e)),this._requestRender=void 0,Object.values(this.audios).forEach(e=>{e instanceof Zo&&e.dispose()}),this.audios={},this.geometryCache.dispose(),this.geometryCache2.dispose()}},$h=new Qo(xa.emptyData());var yr=class extends ht{updateByPatchedOp(e,t,o){if(super.updateByPatchedOp(e,t,o),Ud(e.path,["materials"])!==null&&e.type===0&&Array.isArray(this.material))for(let[i,s]of Object.entries(e.props)){let l=o.shared.material(s);this.material[Number(i)]=l}else if(br(e.path,["material"])&&this.material instanceof Ft)"material"in t&&typeof t.material!="string"&&this.material.updateByOp(ft.drop(e,1),t.material,o);else if(br(e.path,["materials","*"])&&Array.isArray(this.material)){let i=e.path[1];if("materials"in t&&i<this.material.length){let s=t.materials[i];typeof s!="string"&&this.material[i].updateByOp(ft.drop(e,2),s,o)}}}updateState(e,t){super.updateState(e,t),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=t.shared.material(e.material).getFlavor(o.flatShading,o.side,o.wireframe),t.scene?.markNeedsUpdateRendererDirty()),e.geometry?.type==="NonParametricGeometry"&&("materials"in e&&e.materials!==void 0?(this.disposeMaterial(),this.material=e.materials.map(i=>t.shared.material(i).getFlavor(o.flatShading,o.side,o.wireframe)),t.scene?.markNeedsUpdateRendererDirty()):"material"in e&&e.material!==void 0&&(this.disposeMaterial(),this.material=[t.shared.material(e.material).getFlavor(o.flatShading,o.side,o.wireframe)],t.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&&ga(this.material).forEach(e=>{e instanceof Ft&&(e instanceof Ko||e.nodeMaterialDispose())})}dispose(){this.disposeMaterial(),super.dispose()}};var Yh=require("three");var Pt=class extends yr{constructor(e,t,o){super(e,t);this.data=t;this.localGeometry=void 0}chooseGeoemtryCache(e){return e.geometryCache}markGeometryAsReachable(e){this.geometryCreateDeleyed instanceof Yh.BufferGeometry&&this.chooseGeoemtryCache(e).markAsReachable(this.dataPatched.geometry,this.geometryCreateDeleyed)}get geometry(){if(this.localGeometry!==void 0)return this.localGeometry;if(this.geometryCreateDeleyed instanceof Qo){let e=this.geometryCreateDeleyed,t=this.chooseGeoemtryCache(e);this.geometryCreateDeleyed=t.get(this.dataPatched.geometry,e)}return this.geometryCreateDeleyed}set geometry(e){this.localGeometry=e}get is2DAndNoDepth(){let e=this.dataPatched.geometry;return Vi.is2DParametricMesh(e.type)&&e.depth===0}get is2DType(){return Vi.is2DParametricMesh(this.geometry.userData.type)}updateByPatchedOp(e,t,o){super.updateByPatchedOp(e,t,o),br(e.path,["geometry"])&&this.updateByPatchedOpGeometry(ft.drop(e,1),t.geometry,o)}removeInteractionGeometry(){this.localGeometry?.dispose(),this.localGeometry=void 0}updateGeometryInteractions(e,t){this.invalidateDownstreamBooleanData();let o=this.data.geometry.type;if(o==="NonParametricGeometry"||o==="SubdivGeometry"){let i=e;if(this.localGeometry===void 0){let a={...this.data.geometry,...i};this.localGeometry=Wo(a,t,this.data.flatShading)}let s,l,c;i.scaleBaked?[s,l,c]=i.scaleBaked:{width:s,height:l,depth:c}=i;let u=this.localGeometry.userData;u.sxPrev!==void 0&&ns(this.localGeometry.attributes,s/u.sxPrev,l/u.syPrev,c/u.szPrev),u.sxPrev=s,u.syPrev=l,u.szPrev=c}else{let i={...this.data.geometry,...e};this.localGeometry?.dispose(),this.localGeometry=Wo(i,t,this.data.flatShading)}}refreshAttachedCloners(e){for(let t of this.attachedSurfaceCloners)e.scene.addPendingUpdateCloner(t.object)}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.refreshAttachedCloners(e)}updateByPatchedOpGeometry(e,t,o){let i=!1;e.type===0&&e.path.length===0&&ki(["scaleBaked"],Object.keys(e.props))&&this.geometryCreateDeleyed instanceof Ze&&this.chooseGeoemtryCache(o.shared).mutateIfUnique(this.geometryCreateDeleyed.data,t)===this.geometryCreateDeleyed&&(i=!0,this.geometryCreateDeleyed.mutateDirectlyScaleBaked(t,e.props.scaleBaked),this.refreshAttachedCloners(o)),i||(o.scene?.markGeometryCacheDirty(),this.createGeometryDelayed(o)),this.resetBBoxNeedsUpdate(),this.invalidateDownstreamBooleanData()}updateGeometryOnStateUpdate(e,t){this.createGeometryDelayed(t)}updateState(e,t){e.geometry!==void 0&&this.updateGeometryOnStateUpdate(e.geometry,t),super.updateState(e,t)}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,t){let o=this.geometry.userData.parameters;this.is2DType?e.set(0,0,o.depth*.5):e.setScalar(0),t.set(o.width,o.height,o.depth??0).multiplyScalar(.5)}};function O_(n){if(n.geometry.attributes.extrudeNormal||!n.geometry.attributes.position||!n.geometry.attributes.normal)return;let r=new Map,e=n.geometry.attributes.position.array,t=n.geometry.attributes.normal.array,o=new Float32Array(e.length);for(let i=0;i<e.length;i+=3){let s=`${e[i]}_${e[i+1]}_${e[i+2]}`,l=new $t.Vector3(t[i],t[i+1],t[i+2]);r.has(s)?r.get(s)?.normals.push(l):r.set(s,{normals:[l],result:new $t.Vector3})}r.forEach((i,s)=>{for(let l of i.normals)i.result.add(l);i.result.divideScalar(i.normals.length)});for(let i=0;i<e.length;i+=3){let s=`${e[i]}_${e[i+1]}_${e[i+2]}`,l=r.get(s)?.result;l&&(o[i]=l.x,o[i+1]=l.y,o[i+2]=l.z)}n.geometry.setAttribute("extrudeNormal",new $t.Float32BufferAttribute(o,3))}function A_(n){if(n.geometry.attributes.extrudeNormals||!n.geometry.attributes.position)return;let r=n.geometry.attributes.position.array,e=new Float32Array(r.length),t=new $t.Vector3;for(let o=0;o<r.length;o+=3)t.set(r[o],r[o+1],r[o+2]).normalize(),e[o]=t.x,e[o+1]=t.y,e[o+2]=t.z;n.geometry.setAttribute("extrudeNormal",new $t.Float32BufferAttribute(e,3))}function gi(n){if(Array.isArray(n.material)){for(let r of n.material)if(r.getLayersOfType("outline").length===0)return}else if(!(n.material instanceof Ft)||n.material.getLayersOfType("outline").length===0)return;n instanceof Pt&&n.is2DAndNoDepth?A_(n):O_(n)}function xi(n){if(!n.geometry.attributes.position)return;let r=n.geometry.attributes.position.array,e=new Float32Array(r.length),t=parseInt(n.uuid.replace(/\D/g,"")),o=[$t.MathUtils.seededRandom(t),$t.MathUtils.seededRandom(t+1e4),$t.MathUtils.seededRandom(t+2e4)];for(let i=0;i<r.length;i++)e[i]=o[i%3];n.geometry.setAttribute("randomColor",new $t.BufferAttribute(e,3))}var P_;ri.then(n=>{P_=n});var Gr=new Zr.Box3,Ms=new Zr.Vector3;function Xh(n){let r=!1;return n.scene.objects.traverse((e,t)=>{t.type==="Mesh"&&t.geometry.type==="SubdivGeometry"&&(r=!0)}),r}var Jo=class extends Pt{constructor(e,t,o){super(e,t,o);this.data=t;this.hiddenMatrixOld=new Zr.Matrix4;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,t){let o=this.geometry.userData.parameters;e.copy(this.originalGeometryNew.boundingSphere.center),t.set(o.width,o.height,o.depth??0).multiplyScalar(.5)}createGeometryByControls(e){if(this.skipReactionUpdate===!0)return;let t=this.localGeometry?.uuid,{originalGeometry:o,subdividedGeometry:i,subdivPointer:s}=Ze.build(e,this.subdivPointer,this.smoothShading,this.hasNonUniformScale?this.shearScale:void 0);this.subdivPointer=s,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,gi(this),xi(this),this.calcBoundingBox(),t&&(this.localGeometry.uuid=t)}updateState(e,t){if(super.updateState(e,t),e.flatShading!==void 0){let o=this.material;this.material=o.getFlavor(!1,o.side,o.wireframe),this.smoothShading=!e.flatShading,this.createGeometryDelayed(t)}}updateMesh(e=!1){Ze.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1,this.originalGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0),this.subdividedGeometry&&Ze.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1,this.subdividedGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0)}updateTopology(){this.originalGeometry.dispose(),this.originalGeometry=Ze.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=Ze.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1)),this.localGeometry=this.subdividedGeometry??this.originalGeometry}raycast(e,t){let o=this.localGeometry;this.localGeometry=this.originalGeometryNew,ht.prototype.raycast.call(this,e,t),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 Zr.Sphere,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,o=e.boundingSphere.center;Gr.setFromBufferAttribute(t),Gr.getCenter(o),e.boundingSphere.radius=o.distanceTo(Gr.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Gr.getSize(Ms),this.hasNonUniformScale&&Ms.divide(this.scale);let i={width:Ms.x,height:Ms.y,depth:Ms.z};return this.geometry.userData.parameters=i,i}updateBoundingSphere(e){let t=this.originalGeometry;Gr.min.set(e[0],e[2],e[4]),Gr.max.set(e[1],e[3],e[5]),this.hasNonUniformScale&&(Gr.min.applyMatrix4(this.shearScaleInv),Gr.max.applyMatrix4(this.shearScaleInv)),t.boundingSphere===null&&(t.boundingSphere=new Zr.Sphere);let o=t.boundingSphere.center;Gr.getCenter(o),t.boundingSphere.radius=o.distanceTo(Gr.max)}freeSubdivPointer(){this.subdivPointer&&(Ze.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0),this.localGeometry=void 0,this.originalGeometry?.dispose(),this.subdividedGeometry?.dispose()}dispose(){super.dispose(),this.freeSubdivPointer()}updateByPatchedOpGeometry(e,t,o){super.updateByPatchedOpGeometry(e,t,o),this.localGeometry&&this.createGeometryByControls(t)}};var Rr=require("three"),Kh=-1,I_=1,Zh={x:[1,0,0],"-x":[-1,0,0],y:[0,1,0],"-y":[0,-1,0],z:[0,0,1],"-z":[0,0,-1]},Qh={polygon_center:0,edge:1,vertex:2},Bs=(n,r)=>(e,t)=>!r||e===0||n===0?0:n*t/100,me=(n,r)=>{let e=Math.abs(r),t=e*-1;return(n-Kh)*(e-t)/(I_-Kh)+t};function Jh(n){let r=[],e={};for(var t=0,o=n.length;t<o;t++){var i=JSON.stringify(n[t].pos.map(s=>Math.round(s*1e4)/1e4));e[i]||(r.push(n[t]),e[i]=!0)}return r}var C_=new Rr.Vector3,Tl=new Rr.Vector3,N_=new Rr.Vector3,E_=new Rr.Vector3;function vi(n,r){let e=N_.fromArray(n),t=E_.fromArray(r);Tl.copy(t).sub(e);let o=Tl.length();return Tl.normalize().multiplyScalar(o*.5),C_.copy(e).add(Tl).toArray()}var er=new Rr.Triangle,Ol=new Rr.Vector3,Al=new Rr.Vector3,en=new Rr.Vector3;function ey(n){let r=[];for(let e=0;e<=n.index.count;e++)if(Ol.fromArray(n.index.array,e*3),er.setFromAttributeAndIndices(n.attributes.position,Ol.x,Ol.y,Ol.z),er.getNormal(Al),er.getMidpoint(en),!(isNaN(en.x)||isNaN(en.y)||isNaN(en.z))){let{a:t,b:o,c:i}=er,s=t.toArray(),l=o.toArray(),c=i.toArray(),u=t.distanceTo(o),a=o.distanceTo(i),d=i.distanceTo(t),p=vi(s,l),f=vi(l,c),m=vi(c,s),h=[u,a,d],y=Math.max(...h),g=h.filter(b=>Math.round(b)===Math.round(y)).length>1,v=[],w=er.getMidpoint(en).toArray();y===u&&!g&&(v=[f,m,m],w=p),y===a&&!g&&(v=[p,m,m],w=f),y===d&&!g&&(v=[p,f,f],w=m),g&&(v=[p,f,m]),r.push({vertices:[s,l,c],faceCenters:v,midpoint:w,norm:er.getNormal(Al).toArray()})}return r}function ty(n){let r=[],{position:e}=n.attributes;for(let t=0;t<e.count;t++){er.setFromAttributeAndIndices(e,t*3,t*3+1,t*3+2),er.getNormal(Al),er.getMidpoint(en);let o=er.a.toArray(),i=er.b.toArray(),s=er.c.toArray();r.push({vertices:[o,i,s],faceCenters:[vi(o,i),vi(i,s),vi(s,o)],midpoint:en.toArray(),norm:Al.toArray()})}return r}var L_=4,M_=.5,Sd=n=>.5*(1-Math.cos(n*Math.PI)),wd=class{constructor(){this.perlin=new Array(4095+1)}noise(r,e=0,t=0){if(this.perlin==null){this.perlin=new Array(4095+1);for(let g=0;g<4095+1;g++)this.perlin[g]=Math.random()}r<0&&(r=-r),e<0&&(e=-e),t<0&&(t=-t);let o=Math.floor(r),i=Math.floor(e),s=Math.floor(t),l=r-o,c=e-i,u=t-s,a,d,p=0,f=.5,m,h,y;for(let g=0;g<L_;g++){let v=o+(i<<4)+(s<<8);a=Sd(l),d=Sd(c),m=this.perlin[v&4095],m+=a*(this.perlin[v+1&4095]-m),h=this.perlin[v+16&4095],h+=a*(this.perlin[v+16+1&4095]-h),m+=d*(h-m),v+=256,h=this.perlin[v&4095],h+=a*(this.perlin[v+1&4095]-h),y=this.perlin[v+16&4095],y+=a*(this.perlin[v+16+1&4095]-y),h+=d*(y-h),m+=Sd(u)*(h-m),p+=m*f,f*=M_,o<<=1,l*=2,i<<=1,c*=2,s<<=1,u*=2,l>=1&&(o++,l--),c>=1&&(i++,c--),u>=1&&(s++,u--)}return p}noiseSeed(r){let e=(()=>{let s,l;return{setSeed(c){l=s=(c??Math.random()*4294967296)>>>0},getSeed(){return s},rand(){return l=(1664525*l+1013904223)%4294967296,l/4294967296}}})();e.setSeed(r),this.perlin=new Array(4095+1);for(let t=0;t<4095+1;t++)this.perlin[t]=e.rand()}},ry=wd;var Si=require("three");var oy=new Si.Vector3,ny=new Si.Matrix4,iy=new Si.Ray;function sy(n){let r=!1;return n.scene.objects.traverse((e,t)=>{t.type==="Mesh"&&t.geometry.type==="TextGeometry"&&(r=!0)}),r}var bi=class extends Pt{constructor(e,t,o){super(e,t,o);this.data=t}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,t){let{matrixWorld:o}=this;if(!(isNaN(e.ray.origin.x)||this.scale.x===0||this.scale.y===0||this.scale.z===0)&&(ny.copy(o).invert(),iy.copy(e.ray).applyMatrix4(ny),iy.intersectBox(this.singleBBox,oy))){let i=oy.applyMatrix4(o),s=e.ray.origin.distanceTo(i);t.push({distance:s,point:i.clone(),object:this})}}};var It=1e-4,Vr,cy,dy,uy,ay=new Ce.Vector3,ly=new Ce.Vector3;ri.then(n=>{Vr=n,cy=[Vr.get_face_center,Vr.get_edge_midpoint,Vr.get_vertex_position],dy=[Vr.get_face_normal,Vr.get_edge_normal,Vr.get_vertex_normal],uy=[Vr.face_count,Vr.edge_count,Vr.vertex_count]});var B_=new Ce.Matrix4,D_=new Ce.Matrix4,To=new Ce.Vector3,tn=new Ce.Vector3,Ds=new Ce.Vector3,_d=new Ce.Vector3,G_=new Ce.Vector3,R_=new Ce.Vector3;var Qr=new ry,_i=class extends zn(Ce.Object3D){constructor(e,t){super();this.parameters=t;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 t of this.children)t instanceof Yr&&t.expand()}invalidateTransform(e){this.matrixWorldNeedsUpdate=!0,this.traverse(t=>{t instanceof Yr&&t.object===e&&(t.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 t;if(e!==void 0?t=e:t=this.parameters.type==="grid"?this.parameters.grid.count[0]*this.parameters.grid.count[1]*this.parameters.grid.count[2]:this.parameters.count,this.parameters.type==="toObject"&&!this.parameters.toObject.object&&(t=0),this.parameters.type==="toObject"&&this.objectForSample){for(let i=0,s=this.children.length;i<s;++i)this.remove(this.children[0]);let o=this.children;if(o.length===t)return;if(o.length<t)for(let i=0,s=t-o.length;i<s;++i){let l=new Yr(this.object);l.expand(),this.add(l)}else for(let i=0,s=o.length-t;i<s;++i)this.remove(o[i])}else{if(this.children.length===t)return;if(this.children.length<t)for(let o=0,i=t-this.children.length;o<i;++o){let s=new Yr(this.object);s.expand(),this.add(s)}else for(let o=0,i=this.children.length-t;o<i;++o)this.remove(this.children[0])}}_updateRadial(e){let t=e.radial,o=t.start*Ce.MathUtils.DEG2RAD,i=t.end*Ce.MathUtils.DEG2RAD,s=o-i,l=new Ce.Euler(t.rotation[0],t.rotation[1],t.rotation[2]),c;switch(t.axis){case"z":c=new Ce.Vector3(0,0,1);break;case"y":c=new Ce.Vector3(0,1,0);break;default:case"x":c=new Ce.Vector3(1,0,0);break}let u=e.randomnessObject??Or.defaultData([1,1,1]).randomnessObject,a=u.noiseType==="perlin";Qr.noiseSeed(u.seed);let d=qa((0,wi.default)(u.seed)),p=Bs(u.strength,this.parameters.randomness);for(let[f,m]of this.children.entries()){let h=f*(u.freqScale/10)+u.movement,y=a?Qr.noise(h):d(h,h);m.scale.x=t.scale[0]+p(f,me(y,u.scale[0]))||It,m.scale.y=t.scale[1]+p(f,me(y,u.scale[1]))||It,m.scale.z=t.scale[2]+p(f,me(y,u.scale[2]))||It,m.position.setScalar(0);let g=s/e.count*f-o;switch(t.axis){case"x":m.rotation.set(0,g,0);break;case"y":m.rotation.set(0,0,g);break;case"z":m.rotation.set(g,0,0);break}m.translateOnAxis(c,t.radius),m.position.x+=t.position[0]+p(f,me(y,u.position[0])),m.position.y+=t.position[1]+p(f,me(y,u.position[1])),m.position.z+=t.position[2]+p(f,me(y,u.position[2]));let v=p(f,me(y,u.rotation[0])),w=p(f,me(y,u.rotation[1])),b=p(f,me(y,u.rotation[2]));t.alignment===!0?(m.rotation.x+=l.x+v,m.rotation.y+=l.y+w,m.rotation.z+=l.z+b):m.rotation.set(l.x+v,l.y+w,l.z+b)}}_updateLinear(e){if(e.type!=="linear")throw new Error;let t=e.linear,o=new Ce.Euler(t.rotation[0],t.rotation[1],t.rotation[2]),i=e.randomnessObject??Or.defaultData([1,1,1]).randomnessObject,s=i.noiseType==="perlin";Qr.noiseSeed(i.seed);let l=qa((0,wi.default)(i.seed)),c=Bs(i.strength,this.parameters.randomness);for(let[u,a]of this.children.entries()){let d=u*(i.freqScale/10)+i.movement,p=s?Qr.noise(d):l(d,d),f=c(u,me(p,i.rotation[0])),m=c(u,me(p,i.rotation[1])),h=c(u,me(p,i.rotation[2]));a.scale.x=1+(t.scale[0]-1)*u+c(u,me(p,i.scale[0]))||It,a.scale.y=1+(t.scale[1]-1)*u+c(u,me(p,i.scale[1]))||It,a.scale.z=1+(t.scale[2]-1)*u+c(u,me(p,i.scale[2]))||It,a.rotation.x=o.x*u+f,a.rotation.y=o.y*u+m,a.rotation.z=o.z*u+h,a.position.x=t.position[0]*u+c(u,me(p,i.position[0])),a.position.y=t.position[1]*u+c(u,me(p,i.position[1])),a.position.z=t.position[2]*u+c(u,me(p,i.position[2]))}}_updateGrid(e){let t=0,o=e.grid,i=e.randomnessObject??Or.defaultData([1,1,1]).randomnessObject,s=Bs(i.strength,this.parameters.randomness),l=i.noiseType==="perlin";Qr.noiseSeed(i.seed);let c=rm((0,wi.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},a=new Ce.Vector3(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 m=[(d+1)*(i.freqScale/10)+i.movement,(p+1)*(i.freqScale/10)+i.movement,(f+1)*(i.freqScale/10)+i.movement],h=l?Qr.noise(...m):c(...m),y=this.children[t++];y.scale.x=1+s(t,me(h,i.scale[0]))||It,y.scale.y=1+s(t,me(h,i.scale[1]))||It,y.scale.z=1+s(t,me(h,i.scale[2]))||It;let g=s(t,me(h,i.rotation[0])),v=s(t,me(h,i.rotation[1])),w=s(t,me(h,i.rotation[2]));y.rotation.set(g,v,w),y.position.x=o.size[0]*d-a.x+s(t,me(h,i.position[0])),y.position.y=o.size[1]*p-a.y+s(t,me(h,i.position[1])),y.position.z=o.size[2]*f-a.z+s(t,me(h,i.position[2]))}}else for(let u=0;u<o.count[0];u++)for(let a=0;a<o.count[1];a++)for(let d=0;d<o.count[2];d++){let p=[(u+1)*(i.freqScale/10)+i.movement,(a+1)*(i.freqScale/10)+i.movement,(d+1)*(i.freqScale/10)+i.movement],f=l?Qr.noise(...p):c(...p),m=this.children[t++];m.scale.x=1+s(t,me(f,i.scale[0]))||It,m.scale.y=1+s(t,me(f,i.scale[1]))||It,m.scale.z=1+s(t,me(f,i.scale[2]))||It;let h=s(t,me(f,i.rotation[0])),y=s(t,me(f,i.rotation[1])),g=s(t,me(f,i.rotation[2]));m.rotation.set(h,y,g),m.position.x=o.size[0]*u+s(t,me(f,i.position[0])),m.position.y=-o.size[1]*a+s(t,me(f,i.position[1])),m.position.z=-o.size[2]*d+s(t,me(f,i.position[2]))}}_updateToObject(e){if(e.type!=="toObject")throw new Error;let{toObject:t}=e,o=new Ce.Euler(t.rotation[0],t.rotation[1],t.rotation[2]),i=e.randomnessObject??Or.defaultData([1,1,1]).randomnessObject,s=i.noiseType==="perlin";Qr.noiseSeed(i.seed);let l=qa((0,wi.default)(i.seed)),c=Bs(i.strength,this.parameters.randomness);if(!t.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 bi)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.object.parent===this.objectForSample){console.warn(`Oh no! The object "${this.object.name}" (${this.object.uuid}) seem to be a child of the object it's being cloned to. Please re-parent it so that they are siblings instead.`);return}let u=this.getSubdivData(),a=[],d=g=>{let v=g.length,w=g.map(A=>A[0]).reduce((A,_)=>A+_,0),b=g.map(A=>A[1]).reduce((A,_)=>A+_,0),S=g.map(A=>A[2]).reduce((A,_)=>A+_,0);return[w/v,b/v,S/v]},p=g=>Math.round(g*1e6)/1e6;u.forEach(g=>{let v=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]));v.length>1?a.push({pos:g.pos,norm:d(v.map(w=>w.norm))}):a.push(g)});let f=Jh(a);if(u.length>0){let g=Math.round(f.length*t.count/100);this._updateCount(g)}this.objectForSample.updateMatrixWorld();let m=new $a(this.objectForSample).build(),h=Zh[t.axis],y=this.children;m.setRandomGenerator((0,wi.default)(this.object.uuid+t.seed));for(let[g,v]of y.entries()){let w=g*(i.freqScale/10)+i.movement,b=s?Qr.noise(w):l(w,w),S=c(g,me(b,i.rotation[0])),A=c(g,me(b,i.rotation[1])),_=c(g,me(b,i.rotation[2]));t.spreadType==="random"?m.sample(Ds,_d):(f.length&&(Ds.fromArray(f[g].pos),_d.fromArray(f[g].norm)),this.objectForSample instanceof Jo&&Ds.applyMatrix4(B_.copy(this.objectForSample.matrixWorld).invert())),Ds.applyMatrix4(this.object.hiddenMatrix.clone().invert()),v.position.copy(Ds),To.fromArray(h);let x=t.align==="normal"?_d:this.object.getWorldDirection(R_),P=tn.fromArray(t.position);tn.x+=tn.x+c(g,me(b,i.position[0])),tn.y+=tn.y+c(g,me(b,i.position[1])),tn.z+=tn.z+c(g,me(b,i.position[2]));let O=Math.acos(x.dot(To)),I=G_.crossVectors(To,x).normalize(),T=D_.makeRotationAxis(I,O),N=x.clone().cross(this.object.up).normalize(),L=N.clone().cross(x).normalize(),U=new Ce.Matrix4().makeBasis(N,x,L),K=new Ce.Vector3(To.y,To.z,To.x).normalize(),J=K.clone().cross(To).normalize(),se=new Ce.Matrix4().makeBasis(K,To,J).invert(),z=new Ce.Matrix4().multiplyMatrices(U,se);v.rotation.setFromRotationMatrix(z),P.applyMatrix4(T),v.position.add(P),v.rotation.x=v.rotation.x+o.x+S,v.rotation.y=v.rotation.y+o.y+A,v.rotation.z=v.rotation.z+o.z+_,v.scale.setScalar(1),v.scale.x=v.scale.x+t.scale[0]+c(g,me(b,i.scale[0]))||It,v.scale.y=v.scale.y+t.scale[1]+c(g,me(b,i.scale[1]))||It,v.scale.z=v.scale.z+t.scale[2]+c(g,me(b,i.scale[2]))||It,v.scale.multiply(this.object.scale),v.hiddenMatrix=this.object.hiddenMatrix}}getSubdivData(){if(!this.objectForSample)return[];let e=this.parameters.toObject.spreadType;if(e==="random")return[];if(this.objectForSample instanceof Jo){let t=this.objectForSample,o=Qh[e],i=uy[o],s=cy[o],l=dy[o],c=[],u=i(t.subdivPointerNew);for(let a=0;a<=u-1;a++){let d=s(t.subdivPointerNew,a),p=l(t.subdivPointerNew,a);ay.fromArray(d).applyMatrix4(t.matrixWorld),ly.fromArray(p),c.push({pos:ay.toArray(),norm:ly.toArray()})}return c}else return(this.objectForSample.geometry.index?ey(this.objectForSample.geometry):ty(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,t){if(this.parameters=Ro(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=t.find(this.parameters.toObject.object);o instanceof ht?this.objectForSample=o:this.objectForSample=void 0,this.matrix=new Ce.Matrix4,this.hiddenMatrix=new Ce.Matrix4,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1,o&&o.add(this)}this.update()}get pendingMediaLoad(){return this._pendingMediaLoad}};var nr=require("three");var ke=require("three");var xt=require("three");var py=require("three"),jr=n=>{var r;return r=class extends n{},r.geometryHelper=new py.BoxGeometry(30,30,30),r};var St=require("three"),Pl=new St.Ray,Td=new St.Sphere,fy=new St.Matrix4,Fr=(n,r,e,t,o=!1)=>{let i=r,s=n.matrixWorld;if(i.boundingSphere===null&&i.computeBoundingSphere(),Td.copy(i.boundingSphere),Td.applyMatrix4(s),e.ray.intersectsSphere(Td)===!1||(fy.copy(s).invert(),Pl.copy(e.ray).applyMatrix4(fy),i.boundingBox!==null&&Pl.intersectsBox(i.boundingBox)===!1))return;let l,c,u,a,d=i.index,p=i.attributes.position,f=i.drawRange,m,h;if(o===!1){let g=Math.max(0,f.start),v=Math.min(d.count,f.start+f.count);for(m=g,h=v;m<h;m+=3)if(c=d.getX(m),u=d.getX(m+1),a=d.getX(m+2),l=y(n,e,Pl,p,c,u,a),l){l.faceIndex=Math.floor(m/3),t.push(l);return}}else{let v=i.attributes.position,w=new St.Vector3,b=new St.Vector3,S=new St.Vector3,A=new St.Vector3,_=2,P=1/((n.scale.x+n.scale.y+n.scale.z)/3),O=P*P,I=Math.max(0,f.start),T=Math.min(v.count,f.start+f.count);for(let N=I,L=T-1;N<L;N+=_){if(w.fromBufferAttribute(v,N),b.fromBufferAttribute(v,N+1),Pl.distanceSqToSegment(w,b,A,S)>O)continue;A.applyMatrix4(n.matrixWorld);let K=e.ray.origin.distanceTo(A);K<e.near||K>e.far||t.push({distance:K,point:S.clone().applyMatrix4(n.matrixWorld),object:n})}}function y(g,v,w,b,S,A,_){let x=new St.Vector3,P=new St.Vector3,O=new St.Vector3,I=new St.Vector3,T=new St.Vector3;if(x.fromBufferAttribute(b,S),P.fromBufferAttribute(b,A),O.fromBufferAttribute(b,_),w.intersectTriangle(x,P,O,!1,I)===null)return null;T.copy(I),T.applyMatrix4(g.matrixWorld);let L=v.ray.origin.distanceTo(T);return L<v.near||L>v.far?null:{faceIndex:1,distance:L,point:T.clone(),object:g}}};var Il=new xt.Vector3,tr=new xt.Camera,Od=class extends xt.LineSegments{constructor(e){let t=new xt.BufferGeometry,o=new xt.LineBasicMaterial({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],s=[],l={},c=new xt.Color(15711266),u=new xt.Color(15711266),a=new xt.Color(2857471);d("n1","n2",c),d("n2","n4",c),d("n4","n3",c),d("n3","n1",c),d("f1","f2",c),d("f2","f4",c),d("f4","f3",c),d("f3","f1",c),d("n1","f1",c),d("n2","f2",c),d("n3","f3",c),d("n4","f4",c),d("p","n1",u),d("p","n2",u),d("p","n3",u),d("p","n4",u),d("u1","u2",a),d("u2","u3",a),d("u3","u1",a);function d(f,m,h){p(f,h),p(m,h)}function p(f,m){i.push(0,0,0),s.push(m.r,m.g,m.b),l[f]===void 0&&(l[f]=[]),l[f].push(i.length/3-1)}t.setAttribute("position",new xt.Float32BufferAttribute(i,3)),t.setAttribute("color",new xt.Float32BufferAttribute(s,3));super(t,o);this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=l,this.update()}update(){let e=this.geometry,t=this.pointMap,o=!0;tr.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let i=1,s=1,l=o?.8:1e-4;gr("n1",t,e,tr,-i,-s,l),gr("n2",t,e,tr,i,-s,l),gr("n3",t,e,tr,-i,s,l),gr("n4",t,e,tr,i,s,l);let c=l;gr("f1",t,e,tr,-i,-s,c),gr("f2",t,e,tr,i,-s,c),gr("f3",t,e,tr,-i,s,c),gr("f4",t,e,tr,i,s,c);let u=c,a=.5;gr("u1",t,e,tr,i*.7*a,s*1.1,u),gr("u2",t,e,tr,-i*.7*a,s*1.1,u),gr("u3",t,e,tr,0,s*(1.1+.9*a),u),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function gr(n,r,e,t,o,i,s){Il.set(o,i,s).unproject(t);let l=r[n];if(l!==void 0){let c=e.getAttribute("position");for(let u=0,a=l.length;u<a;u++)c.setXYZ(l[u],Il.x,Il.y,Il.z)}}var Cl=class extends jr(Od){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,t){Fr(this.object,this.geometry,e,t,!0)}};var Gs=require("three");var Nl;(r=>r.is=e=>"objectHelper"in e)(Nl||(Nl={}));var Oo=(n,r)=>class extends Xa(n){constructor(){super(...arguments);this.objectHelper=new r(this);this.gizmos={}}get geometryHelper(){return r.geometryHelper}raycast(o,i){this.objectHelper.raycast(o,i)}showGizmos(){for(let o in this.gizmos){let i=this.gizmos[o];i instanceof Gs.Box3Helper&&(i.visible=!0)}}updateEntityBoxSize(o,i){this.objectHelper.visible&&this.geometryHelper instanceof Gs.BoxGeometry?(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 Gs.Box3Helper&&(i.visible=!1)}}};var Ad=790,Ti=new ke.Vector3,Pd=new ke.Vector3,Jr=class extends Oo(ke.Camera,Cl){constructor(e="",t={...yn.defaultData,name:""}){super();this._cameraType="OrthographicCamera";this.targetOffset=Eo.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.super_Entity(e,t),this.matrixAutoUpdate=!0,this.width=window.innerWidth,this.height=window.innerHeight;let o=this.width,i=this.height;if(t.orthographic.autoZoom){let s=t.orthographic.autoZoomFrustumSize??Ad,l=o/i,c=o>i?l:1,u=o>i?1:l;this.orthoCamera=new ke.OrthographicCamera(-s*.5*c,s*.5*c,s*.5*(1/u),-s*.5*(1/u),-5e4,1e4)}else this.orthoCamera=new ke.OrthographicCamera(o*-.5,o*.5,i*.5,i*-.5,-5e4,1e4);this.perspCamera=new ke.PerspectiveCamera(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,t){e==="PerspectiveCamera"?this.perspCamera.near=t:this.orthoCamera.near=t}setZoom(e,t){t>=0&&(e==="PerspectiveCamera"?this.perspCamera.zoom=t:this.orthoCamera.zoom=t)}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){super.lookAt(e),this.getWorldPosition(Ti),this.targetOffset=Ti.distanceTo(e)}getTarget(e=new ke.Vector3){return this.getWorldDirection(Pd),this.getWorldPosition(Ti),Pd.multiplyScalar(this.targetOffset),e.copy(Ti).add(Pd),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(Ti),Ti.distanceTo(e)}updateUp(){let e=this.getWorldQuaternion(new ke.Quaternion),t=new ke.Vector3(0,0,1).applyQuaternion(e),o=new ke.Vector3().copy(ke.Object3D.DefaultUp);this.isUpVectorFlipped&&o.negate(),o.applyQuaternion(e);let i=new ke.Vector3().copy(ke.Object3D.DefaultUp).projectOnPlane(t),s=new ke.Vector3().crossVectors(i,o).dot(t)>=0?1:-1;this.angleOffsetFromUp=i.angleTo(o)*s}updateTransformState(e){let t=super.updateTransformState(e);return e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateUp(),t}getViewFrontToObject(e){let t=e.getWorldPosition(new ke.Vector3),i=e.getWorldDirection(new ke.Vector3).multiplyScalar(this.targetOffset);return{position:t.clone().add(i),target:t}}getViewToObject(e){let t=e.getWorldPosition(new ke.Vector3),i=this.getWorldDirection(new ke.Vector3).multiplyScalar(this.targetOffset);return{position:t.clone().sub(i),target:t}}setViewplaneSize(e,t){if(this.aspect=e/t,this.data.type==="OrthographicCamera"&&this.data.orthographic.autoZoom){let o=this.data.orthographic.autoZoomFrustumSize??Ad,i=e>t?this.aspect:1,s=e>t?1:this.aspect;this.left=-o*.5*i,this.right=o*.5*i,this.top=o*.5*(1/s),this.bottom=-o*.5*(1/s)}else this.left=-e*.5,this.right=e*.5,this.top=t*.5,this.bottom=-t*.5;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,t,o,i,s,l){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(e,t,o,i,s,l):this.orthoCamera.setViewOffset(e,t,o,i,s,l)}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}updateProjectionMatrix(){this._cameraType==="PerspectiveCamera"?this.toPerspective():this._cameraType==="OrthographicCamera"&&this.toOrthographic()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(e,t){return super.copy(e,t),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 t={type:this.cameraType,far:this.far,orthographic:{near:this.orthoCamera.near,zoom:this.orthoCamera.zoom,autoZoom:!0,autoZoomFrustumSize:Ad},perspective:{near:this.perspCamera.near,fov:this.perspCamera.fov,zoom:this.perspCamera.zoom},up:this.up.toArray(),targetOffset:this.targetOffset,isUpVectorFlipped:this.isUpVectorFlipped};return Fn(t,e)}updateCameraSubtype(e,t){let o=e==="perspective"?"PerspectiveCamera":"OrthographicCamera";t.zoom!==void 0&&this.setZoom(o,t.zoom),t.near!==void 0&&this.setNear(o,t.near),t.fov!==void 0&&o==="PerspectiveCamera"&&(this.fov=t.fov)}updateState(e){this.updateCameraState(e)}updateCameraState(e){this.updateState_Entity(e,{}),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,t,o){super.updateByPatchedOp(e,t,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}}};var rn=require("three");var my=new rn.Matrix4;var rr=class extends yr{constructor(e,t,o){super(e,t);this.data=t;this.meshSetAddresses=[];this.needsTransformForDownstream=!1;this.geometry=new rn.BufferGeometry;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,t,o){super.updateByPatchedOp(e,t,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,t=!0){if(this.booleanMeshSetAddress!==-1&&!e)return;for(let i=0;i<this.children.length;i++){let s=this.children[i];s instanceof rr&&s.recomputeBoolean(e===!0,t)}this.meshSetAddresses=[];for(let i=0;i<this.children.length;i++){let s=this.children[i];if(s instanceof ht&&s.dataPatched.visible===!0&&s.geometry.attributes.position?.count>0&&s.geometry.drawRange.count>0){if(s.booleanMeshSetAddress===-1){if((s.geometry.index??s.geometry.getAttribute("position")).count/3<15e5&&(s.booleanMeshSetAddress=ur.getMeshSet(s.geometry,e===!0,t)),s.booleanMeshSetAddress===-1)return;ur.transformMeshSet(s.booleanMeshSetAddress,s.matrix),s.booleanMatrixInvOld.copy(s.matrix).invert(),s.booleanWasTransformed=!1}else s instanceof rr&&s.needsTransformForDownstream===!0?(ur.transformMeshSet(s.booleanMeshSetAddress,s.matrix),s.needsTransformForDownstream=!1):s.booleanWasTransformed===!0&&(my.multiplyMatrices(s.matrix,s.booleanMatrixInvOld),ur.transformMeshSet(s.booleanMeshSetAddress,my),s.booleanMatrixInvOld.copy(s.matrix).invert(),s.booleanWasTransformed=!1);this.meshSetAddresses.push(s.booleanMeshSetAddress)}}if(this.meshSetAddresses.length===0){this.geometry.setAttribute("position",new rn.Float16BufferAttribute([],0)),this.geometry.setDrawRange(0,0);return}if(e===!0)return ur.calcBooleanTopological(this.meshSetAddresses,this.booleanOp);let o=this.geometry;o.dispose(),this.geometry=new rn.BufferGeometry,this.geometry.userData=o.userData,this.geometry.boundingSphere=o.boundingSphere;try{this.booleanMeshSetAddress=ur.calcBoolean(this.meshSetAddresses,this.booleanOp,this.geometry,this.phongAngle)}catch(i){this.booleanMeshSetAddress=0,console.error(i)}this.booleanMatrixInvOld.copy(this.matrix).invert(),this.needsTransformForDownstream=!0,gi(this),xi(this)}dispose(){super.dispose(),this.geometry.dispose()}};var yy=require("three");var hy;(r=>{function n(e){return He.is(e)&&e instanceof yy.Light}r.is=n})(hy||(hy={}));var Oi=(n,r)=>class extends Oo(n,r){updateState_Light(t,o){this.updateState_Entity(t,o),t.color!==void 0&&(this.color=o.shared.color(t.color)),t.intensity!==void 0&&(this.intensity=t.intensity),t.depth!==void 0&&(this.shadow.camera.far=t.depth,this.shadow.needsUpdate=!0),t.shadows!==void 0&&(this.castShadow=t.shadows)}};var Rs=n=>n instanceof ht,Vs=n=>n!==null&&n instanceof rr,gy=n=>n instanceof Jr;var xy=n=>Nl.is(n);var by=require("three");var vy=require("three");var Ao=class extends jr(vy.AxesHelper){constructor(e,t=15){super(t);this.object=e;this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${e.uuid}`,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}raycast(e,t){Fr(this.object,Ao.geometryHelper,e,t)}update(){}};var js=class extends Oo(by.Group,Ao){constructor(r,e){super(),this.super_Entity(r,e),this.objectHelper.update()}updateState(r,e){this.updateState_Entity(r,e)}};var Us=require("three");var Sy=require("three");var Ai=class extends jr(Sy.DirectionalLightHelper){constructor(e,t=15,o=10066329){super(e,t,o);this.object=e;this.added=!1;this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,t){Fr(this.object,Ai.geometryHelper,e,t)}};var wy=require("three");var Pi=class extends jr(wy.PointLightHelper){constructor(e,t=15,o=6710886){super(e,t,o);this.object=e;this.name=`PointLightHelper: ${e.uuid}`}raycast(e,t){Fr(this.object,Pi.geometryHelper,e,t)}};var Ll=require("three");var El=class extends jr(Ll.SpotLightHelper){constructor(e,t=6710886){super(e,t);this.object=e;this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,t){Fr(this.object,El.geometryHelper,e,t)}update(){if(this.object!==void 0){let e=El._vector,t=this.object.distance?this.object.distance:1e3,o=t*Math.tan(this.object.angle);this.cone.scale.set(o,o,t),e.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(e);let i=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let s=0,l=this.cone.material.length;s<l;s++)this.cone.material[s].color.set(i);else this.cone.material.color.set(i)}}},Fs=El;Fs._vector=new Ll.Vector3;function j_(n,r){n.shadow.camera.right=r/2,n.shadow.camera.left=-r/2,n.shadow.camera.top=r/2,n.shadow.camera.bottom=-r/2,n.shadow.needsUpdate=!0}var Ml=class extends Oi(Us.DirectionalLight,Ai){constructor(r,e,t){super(),this.super_Entity(r,e),this.castShadow=!0,this.shadow.mapSize.width=2048,this.shadow.mapSize.height=2048,this.shadow.normalBias=1,this.layers.enable(3);let i=this.shadow.camera;i.top=1250,i.bottom=-1250,i.right=1250,i.left=-1250,i.near=-1e4,i.far=2500;let s=new Us.CameraHelper(this.shadow.camera);s.visible=!1,this.gizmos.shadowmap=s}update(){this.shadow.camera.updateProjectionMatrix();for(let r in this.gizmos){let e=this.gizmos[r];e instanceof Us.CameraHelper&&e.update()}}updateMatrixWorld(r){super.updateMatrixWorld(r),this.objectHelper&&this.objectHelper.update()}updateState(r,e){this.updateState_Light(r,e);let t=r.depth!==void 0&&r.depth!==this.shadow.camera.far||r.size!==void 0&&r.size/2!==this.shadow.camera.right;r.size!==void 0&&j_(this,r.size),r.shadowRadius!==void 0&&(this.shadow.radius=r.shadowRadius),r.shadowResolution!==void 0&&(this.shadow.mapSize.set(r.shadowResolution,r.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),t&&this.update()}};var Ut=require("three");var Bl=class extends Oi(Ut.PointLight,Pi){constructor(r,e,t){super(),this.super_Entity(r,e),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let i=this.shadow.camera;i.fov=90,i.aspect=1,i.near=100,i.far=2500;let s=new Ut.Vector3(-i.far+this.position.x,-i.far+this.position.y,-i.far+this.position.z),l=new Ut.Vector3(i.far+this.position.x,i.far+this.position.y,i.far+this.position.z),c=new Ut.Box3(s,l),u=new Ut.Box3Helper(c,new Ut.Color(16755200));u.visible=!1,this.gizmos.shadowmap=u,this.update()}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this.gizmos))for(let r in this.gizmos){let e=this.gizmos[r];if(e instanceof Ut.Box3Helper){let t=this.shadow.camera,o=new Ut.Vector3(-t.far+this.position.x,-t.far+this.position.y,-t.far+this.position.z),i=new Ut.Vector3(t.far+this.position.x,t.far+this.position.y,t.far+this.position.z);e.box.set(o,i),e.updateMatrixWorld(!0)}}}updateMatrixWorld(r){super.updateMatrixWorld(r),this.objectHelper&&this.objectHelper.update()}updateState(r,e){this.updateState_Light(r,e),r.distance!==void 0&&(this.distance=r.distance),r.decay!==void 0&&(this.decay=r.decay),r.shadowRadius!==void 0&&(this.shadow.radius=r.shadowRadius),r.shadowResolution!==void 0&&(this.shadow.mapSize.set(r.shadowResolution,r.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};var or=require("three");var _y=new or.Vector3,Ty=new or.Vector3,Oy=new or.Quaternion,Dl=class extends Oi(or.SpotLight,Fs){constructor(r,e,t){super(),this.super_Entity(r,e),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let i=this.shadow.camera;i.fov=or.MathUtils.RAD2DEG*2*this.angle,i.aspect=1,i.near=100,i.far=2500;let s=new or.CameraHelper(this.shadow.camera);s.visible=!1,this.gizmos.shadowmap=s,this.update()}update(){this.shadow.camera.updateProjectionMatrix();for(let r in this.gizmos){let e=this.gizmos[r];e instanceof or.CameraHelper&&e.update()}}updateMatrixWorld(r){super.updateMatrixWorld(r),Ty.setFromMatrixPosition(this.matrixWorld),Oy.setFromRotationMatrix(this.matrixWorld),_y.copy(this.up).applyQuaternion(Oy).negate().multiplyScalar(this.distance),this.target.position.copy(Ty).add(_y),this.target.updateMatrixWorld(),this.objectHelper&&this.objectHelper.update()}updateState(r,e){this.updateState_Light(r,e),r.distance!==void 0&&(this.distance=r.distance),r.decay!==void 0&&(this.decay=r.decay),r.angle!==void 0&&(this.angle=r.angle),r.penumbra!==void 0&&(this.penumbra=r.penumbra),r.shadowRadius!==void 0&&(this.shadow.radius=r.shadowRadius),r.shadowResolution!==void 0&&(this.shadow.mapSize.set(r.shadowResolution,r.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};var Gl=class extends Pt{get forceComputeSize(){return!0}get shape(){return this.geometry.userData.shape}constructor(r,e,t){super(r,e,t)}updateEntityBoxSize(r,e){let t=this.geometry.getAttribute("position");t!==void 0?$c(t,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:t.count,r,e):super.updateEntityBoxSize(r,e)}};var Py=require("three");var eo=class extends Oo(Py.Group,Ao){constructor(e,t,o){super();t.type==="Instance"&&typeof e=="string"&&(t=this.transformAssignData(t,o)),this.super_Entity(e,t),this.objectHelper.update()}get isComponentRoot(){return this.data.type==="Component"&&typeof this.identity=="string"}get isInstanceRoot(){return this.data.type==="Instance"&&typeof this.identity=="string"}transformAssignData(e,t){let o=t.scene.data.objects.get(e.component);if(o){let i,s;for(let l of lo.rootOverrideProps)e[l]===void 0?(i===void 0&&(i={...e}),i[l]=o.data[l]):(s===void 0&&(s={}),s[l]=e[l]);return this.overrideData=s,i??e}return e}updateByOp(e,t,o,i){let s;if(this.isInstanceRoot&&!i&&(t=this.transformAssignData(t,o),e.type===0&&e.path.length===0&&this.component))for(let l of lo.rootOverrideProps)l in e.props&&e.props[l]===void 0&&(s===void 0&&(s={...e,props:{...e.props}}),s.props[l]=this.component.data[l]);super.updateByOp(s??e,t,o,i)}updateState(e,t){this.updateState_Entity(e,t)}expandInstanceChildren(e){let t=this.data;if(this.component===void 0){this.component=e.scene.find(t.component)??null;let o=!1;if(this.component!==this.oldComponent){if(this.oldComponent){let i=0;for(let s of this.children)if(He.is(s))e.scene.disposeAndUnregisterEntityRecursivelyIfNotReregistered(s),Rl(s),i+=1;else break;this.children.splice(0,i)}o=!0}this.component&&Iy(e,[this.uuid],t.overrides,this,this.component,this.component,0,o),this.oldComponent=this.component}}};function Rl(n){if(n.component){let r=n.component.instances.indexOf(n);r>=0&&n.component.instances.splice(r,1);for(let e of n.children)He.is(e)&&Rl(e)}}function Ay(n,r,e,t){return n.component===r&&ki(n.identity,t)?n.overrideData===e?2:1:0}function Iy(n,r,e,t,o,i,s,l){if(s>50)return!1;if(t.component!==o){if(t.component){let u=t.component.instances.indexOf(t);u>=0&&t.component.instances.splice(u,1)}o.instances.push(t),t.component=o}o instanceof eo&&o.isInstanceRoot&&o.expandInstanceChildren(n);let c=0;for(let u of o.children)if(He.is(u)){let a=[...r,...typeof u.identity=="string"?[u.identity]:u.identity],d=gn.resolve(e,a,1),p=null,f;if(!l){let m=t.children[c];if(p=He.is(m)?m:null,p!==null){let h=Ay(p,u,d,a);f=h>=1?p.stateSelection:void 0,h!==2&&(p=null)}if(p===null&&(p=n.scene.findInstance(a)??null,p!==null)){let h=Ay(p,u,d,a);if(f=h>=1?p.stateSelection:void 0,h!==2)p=null;else{let y=p.parent.children.indexOf(p);p.parent.children.splice(y,1),t.children.splice(c,0,p),p.parent===t?(y<=c&&console.error("not possible"),void 0):(p.parent=t,p.matrixWorldNeedsUpdate=!0,p.resetBBoxNeedsUpdate(),p.updateVisible(),n.pendingDeletes.delete(p),void 0)}}}if(p===null){let m=d?zr.apply(u.data,d):u.data;sr.is(m.type)&&(m={...m,type:"Empty"}),p=lr.createEntity(a,m,n),p.overrideData=d,t.add(p),t.children.splice(t.children.length-1,1),t.children.splice(c,0,p),p.updateState(p.data,n),f&&p.changeSelectedState(f,n),n.scene.registerInstanceAndSetUuid(p)}c+=1,Iy(n,r,e,p,u,i,s+1,l)}if(!l){let u=c;for(;;){let a=t.children[c];if(He.is(a))n.pendingDeletes.add(a);else break;c+=1}t.children.splice(u,c-u)}return!0}function F_(n,r,e){let t;return r.geometry.type==="TextGeometry"?new bi(n,r,e):(r.geometry.type==="SubdivGeometry"?t=new Jo(n,r,e):r.geometry.type==="VectorGeometry"?t=new Gl(n,r,e):r.geometry.type==="BooleanGeometry"?t=new rr(n,r,e):t=new Pt(n,r,e),t)}function Vl(n,r,e){return r.type==="Mesh"?F_(n,r,e):r.type==="Empty"?new js(n,r):r.type==="PointLight"?new Bl(n,r,e):r.type==="SpotLight"?new Dl(n,r,e):r.type==="DirectionalLight"?new Ml(n,r,e):r.type==="Component"||r.type==="Instance"?new eo(n,r,e):sr.is(r.type)?new Jr(n,r):(console.error(r),new js(n,r))}lr.createEntity=Vl;function U_(n,r,e){let t=Vl(n.identity,r,e),o=n.children,i=n.parent,s=n.component,l=n.instances,c=n.overrideData,u=n.uuid,a=n.stateSelection;n.dispose();for(let d of Object.keys(n))delete n[d];Object.setPrototypeOf(n,Object.getPrototypeOf(t));for(let d of Object.keys(t))n[d]=t[d];n.children=[...n.children,...o],n.parent=i,n.component=s,n.instances=l,n.uuid=u,n.overrideData=c,n.updateState(n.data,e),a&&n.changeSelectedState(a,e),n.resetBBoxNeedsUpdate()}lr.changeEntityProptotype=U_;lr.Cloner=_i;function Cy(n,r,e,t){n.updateByOp(r,e,t,!1)}var Ii=require("three");function Ny(n,r){let e=!1,t=r.getLayersOfType("transmission"),o=r.getLayersOfType("outline");return o.length>0&&(n.layers.set(8),t.length>0&&n.layers.enable(3),e=!0,xi(n),gi(n)),t.length===0&&o.length===0&&n.layers.set(0),e}function Ey(n,r){if(!r.layers)return!1;let e=!1,t=r.getLayersOfType("transmission"),o=r.getLayersOfType("outline");return t.length>0&&(n.layers.set(3),o.length>0&&n.layers.enable(8),e=!0),t.length===0&&o.length===0&&n.layers.set(0),e}function Ly(n){let r=!1;return n.traverseEntity(e=>{if(e instanceof yr)if(Array.isArray(e.material))for(let t=0;t<e.material.length;t++)Ny(e,e.material[t])&&(r=!0);else Ny(e,e.material)&&(r=!0)}),r}function My(n){let r=!1;return n.traverseEntity(e=>{if(e instanceof yr)if(Array.isArray(e.material))for(let t=0;t<e.material.length;t++)Ey(e,e.material[t])&&(r=!0);else Ey(e,e.material)&&(r=!0)}),r}var k_=new Ii.Raycaster,H_=new Ii.Matrix4,W_=new Ii.Ray;function By(n,r,e){let t=n.cloner;if(t)for(let o of t.children){let i=H_.copy(o.matrixWorld).invert(),s=W_.copy(r.ray).applyMatrix4(i),l=n.matrixWorld;s.applyMatrix4(l);let c=k_;c.set(s.origin,s.direction),c.near=r.near,c.far=r.far,c.intersectObject(n,!1).length>0&&e.push({object:n})}}var q_=new nr.MeshBasicMaterial;q_.wireframe=!0;var Dy=new nr.Vector3,Id=class extends nr.Scene{constructor(e,t){super();this.data=e;this.backupFog=new nr.Fog(16777215,.1,2e3);this.fogUseBGColor=!1;this.enableHelpers=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this.needsNormalDirty=!0;this._needsTransmission=!1;this._needsNormal=!1;this.geometryCacheChanged=!1;this.bgColor=new it(1,1,1,1);this.entityByUuid={};this.entityIdentityToEntity={};this.toExpandCloner=new Set;this.toUpdateCloner=new Set;this.needsRecomputeInstances=!1;this.ambientLight=new nr.HemisphereLight(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.personalCamera=this.createPersonalCamera(),this.activeCamera=this.personalCamera,this.postprocessing=e.postprocessing,this.init(e,t),this.matrixAutoUpdate=!1}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=My(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=Ly(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let t=e.identity.join("-"),o=this.entityIdentityToEntity[t];o&&(e.uuid=o.uuid),this.entityIdentityToEntity[t]=e,this.entityByUuid[e.uuid]=e}findInstance(e){return this.entityIdentityToEntity[e.join("-")]}getWithSortKey(e){let t=this.find(e);if(t===void 0)return;let o=[],i=t;for(;i!==this;){let s=i;i=i.parent;let l=i.children.indexOf(s);o.splice(0,0,l)}return{entity:t,sortKey:o}}getAllSorted(e){let t=[];for(let o of e){let i=this.getWithSortKey(o.id);i!==void 0&&t.push(i)}return t.sort((o,i)=>bu(o.sortKey,i.sortKey)),t.map(o=>o.entity)}nonExistOrDescendantOf(e,t){let o=this.find(e);if(o===void 0)return!0;for(;o;){if(o.uuid===t)return!0;o=o.parent}return!1}find(e){if(e===""||e===void 0)return;let t=this.entityByUuid[e];return t===void 0?this.getObjectByProperty("uuid",e):t}debugEnsureEntity(e){let t=this.find(e);if(t){if(Array.isArray(t.identity)&&this.findInstance(t.identity)===void 0){console.error("not found instance");debugger}}else{console.error("not found");debugger}}addPendingExpandCloner(e){this.toExpandCloner.add(e)}addPendingUpdateCloner(e){this.toUpdateCloner.add(e)}markToExpandCloner(e){this.toExpandCloner.add(e),e.traverseEntityAncestors(t=>{this.toExpandCloner.add(t)})}doPendingExpandCloner(){this.toExpandCloner.forEach(e=>{e.expandCloner(this)}),this.toExpandCloner.clear()}doPendingUpdateCloner(){this.toUpdateCloner.forEach(e=>{e.cloner?.update()}),this.toUpdateCloner.clear()}doPendingUpdates(){this.doPendingExpandCloner(),this.doPendingUpdateCloner()}updateTreeByOp(e,t){if(e.path.length===0&&e.type===7){let o=e.parent===null?this:this.find(e.parent);if(o===void 0)throw new Error("unexpected");let i=this.createObject(e.id,e.data,e.children,o,e.localIndex,t);i.updateVisible(),i.resetBBoxNeedsUpdate(),Rs(i)&&Vs(i.parent)&&(i.invalidateUpstreamBooleanData(),i.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(o),this.markNeedsRecomputeInstancesForChildren(i),this.markToExpandCloner(i)}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),o.parent.remove(o),Vs(o.parent)&&(o.parent.invalidateUpstreamBooleanData(),o.parent.invalidateDownstreamBooleanData().recomputeBoolean()),Rs(o)&&(o.freeBooleanPointer(),i instanceof rr&&i.invalidateDownstreamBooleanData().recomputeBoolean()),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(o)}else if(e.path.length===0&&e.type===9){let o=this.find(e.id);if(o===void 0)throw new Error("unexpected");this.markNeedsRecomputeInstancesForChildren(o);let i=o.parent;this.markNeedsRecomputeInstancesForAncessors(i),o.cloner?.resetOnMove(),this.markToExpandCloner(o);let s=e.parent===null?this:this.find(e.parent);if(s===void 0)throw new Error("unexpected");s.add(o),this.markNeedsRecomputeInstancesForAncessors(s),this.markToExpandCloner(o),o.invalidateClonerTransform(o),o.updateVisible(),o.resetBBoxNeedsUpdate();let l=e.localIndex;s.children.splice(l,0,s.children.pop()),Rs(o)&&(o.invalidateUpstreamBooleanData(),Vs(o.parent)?o.parent.invalidateDownstreamBooleanData().recomputeBoolean():i instanceof rr&&i.invalidateDownstreamBooleanData().recomputeBoolean())}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}updateEntityByOp(e,t,o,i){if(t.type===0&&(("overrides"in t.props||"component"in t.props)&&this.markNeedsRecomputeInstances(),t.path.includes("overrides")&&"states"in t.props)){let{states:l,rest:c}=t.props;t={...t,props:c},this.markNeedsRecomputeInstances()}let s=this.find(e);if(s)try{Cy(s,t,o,{scene:this,shared:i}),s instanceof Pt&&s.updateGeometryGroupsIfNeeded()}catch(l){console.error(l)}}get enableFog(){return this.fog!==null}set enableFog(e){this.fog=e===!0?this.backupFog:null}init(e,t){if(this.createChildrenObjects(e.objects,this,t),this.personalCamera.removeFromParent(),this.add(this.personalCamera),this.ambientLight.removeFromParent(),this.add(this.ambientLight),this.setBackgroundColor(At(e.backgroundColor,t)),this.updateFog(e.fog,t),this.updateAmbientLight(e.environment.ambientLight,t),this.activeCamera=this.personalCamera,e.publish.playCamera!==null){let o=this.find(e.publish.playCamera);o instanceof Jr&&this.switchActiveCamera(o)}this.expandInstances(t,!0),this.traverseEntity(o=>{Vs(o)&&o.recomputeBoolean()}),this.doPendingExpandCloner()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(t=>{(t.data.type==="Component"||t.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){He.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(t=>{He.is(t)&&t.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,t,o,i,s,l,c){e&&e!==i.uuid&&i.find(e)&&s.forInstancesRec(a=>{a.isInstanceRoot||(a.data=un(a.data,d=>{let p=d.events.data(c.id),f=a.goUp(l);if(f){let m=[...ga(f.identity),e].join("-"),h=this.entityIdentityToEntity[m];if(h){let y=h.uuid;wt.zoom(p,t)[o]=y}else{if(!1)debugger;console.warn("cannot find instance")}}}).data)})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof eo&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((t,o)=>{t.data.events.forEach(i=>{i.data.type==="GameControl"?t.forInstancesRec(s=>{s.isInstanceRoot||(s.data=un(s.data,l=>{l.events.delete(i.id)}).data)}):i.data.type==="Conditional"?(i.data.condition.type==="Distance"?(this.relativeizeInner(i.data.condition.fromObject,["condition"],"fromObject",e,t,o,i),this.relativeizeInner(i.data.condition.toObject,["condition"],"toObject",e,t,o,i)):i.data.condition.type==="State"?this.relativeizeInner(i.data.condition.object,["condition"],"object",e,t,o,i):i.data.condition.type==="Comparison"&&(i.data.condition.lOperand.type==="Property"&&this.relativeizeInner(i.data.condition.lOperand.value[0],["condition","lOperand","value"],0,e,t,o,i),i.data.condition.rOperand.type==="Property"&&this.relativeizeInner(i.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,t,o,i)),i.data.inActions.forEach(s=>{s.data.type==="Transition"&&this.relativeizeInner(s.data.object,["inActions",s.id],"object",e,t,o,i)}),i.data.outActions.forEach(s=>{s.data.type==="Transition"&&this.relativeizeInner(s.data.object,["outActions",s.id],"object",e,t,o,i)})):"actions"in i.data&&i.data.actions.forEach(s=>{s.data.type==="Transition"&&this.relativeizeInner(s.data.object,["actions",s.id],"object",e,t,o,i)})})}),!0})}expandInstances(e,t){let o=new Set;this.traverseEntity(i=>{if(i instanceof eo&&i.isInstanceRoot)return i.expandInstanceChildren({scene:this,shared:e,pendingDeletes:o}),t||i.resetBBoxNeedsUpdate(),!0});for(let i of o)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(i),Rl(i)}recomputeInstances(e){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(t=>{t instanceof eo&&t.isInstanceRoot&&(t.component=void 0)}),this.expandInstances(e,!1))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(t=>{let o=typeof t.identity=="string"?t.identity:t.identity.join("-");this.entityIdentityToEntity[o]===t&&(delete this.entityByUuid[t.uuid],delete this.entityIdentityToEntity[o]),t.dispose()})}clearScene(){for(let e of this.children)cr(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,t){this.init(e,t)}createPersonalCamera(){let e=new Jr(Id.PERSONAL_CAMERA_ID,{...yn.defaultData,name:"Personal Camera"});return e.objectHelper.visible=!1,this.registerObjectCreatedInLegacy(e),e}raycast(e){let t=[],o=i=>{for(let s of i.children)cr(s)&&!s.raycastLock&&s.visible&&((Rs(s)||xy(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,t),By(s,e,t)),o(s))};return o(this),t}forEachEntity(e){for(let t of this.children)cr(t)&&e(t)}traverseEntity(e){for(let t of this.children)cr(t)&&t.traverseEntity(e)}traverseObject(e){for(let t of this.children)Yi.is(t)&&t.traverseObject(e)}traverseVisibleEntity(e){for(let t of this.children)cr(t)&&t.visible&&t.traverseVisibleEntity(e)}updateFog(e,t){this.enableFog=e.enabled,this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=At(e.color,t),this.backupFog.near=e.near,this.backupFog.far=e.far}dispose(){this.clearScene()}updateAmbientLight(e,t){e.color!==void 0&&(this.ambientLight.color=At(e.color,t)),e.intensity!==void 0&&(this.ambientLight.intensity=e.intensity),e.groundColor!==void 0&&(this.ambientLight.groundColor=At(e.groundColor,t)),e.enabled!==void 0&&(this.ambientLight.visible=e.enabled)}switchActiveCamera(e){this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=e,e.objectHelper.visible=!1}setBackgroundColor(e){this.bgColor=e,this.fogUseBGColor===!0&&(this.backupFog.color=e)}createChildrenObjects(e,t,o){let i=0;for(let s of e)this.createObject(s.id,s.data,s.children,t,i,o),i+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let t of e.children)this.unregisterObject(t)}createObject(e,t,o,i,s,l){let c={scene:this,shared:l},u=Vl(e,t,c);return u&&(this.entityByUuid[e]=u,i.add(u),i.children.splice(s,0,i.children.pop()),o.length>0&&(u.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(o,u,l)),u.updateState(t,c),u instanceof Pt&&u.updateGeometryGroupsIfNeeded(),u.updateVisible(),u.cloner&&this.toExpandCloner.add(u)),u}getCenter(e){let t=[];for(let i=0,s=e.length;i<s;++i){let{id:l,recursive:c}=e[i],u=this.find(l),a=c?u.recursiveBBox:u.singleBBox;t.push(...a.vertices)}let o=new nr.Box3;return o.setFromPoints(t),o.getCenter(Dy),Dy}copyMatrixWorld(e,t){if(e===null){t.identity();return}let o=this.find(e);o?t.copy(o.matrixWorld):t.identity()}copyParentMatrixWorld(e,t){if(e===null){t.identity();return}let o=this.find(e)?.parent;o?t.copy(o.matrixWorld):t.identity()}traverseMaterial(e){this.traverseEntity(t=>{if(t instanceof ht)if(Array.isArray(t.material))for(let o=0;o<t.material.length;o++)t.material[o]instanceof Ft&&e(t.material[o]);else t.material instanceof Ft&&e(t.material)})}updateCanvasSize(e,t){this.activeCamera.setViewplaneSize(e,t);let o,i;e>=t?(o=t/e,i=1):(o=1,i=e/t),this.traverseMaterial(s=>{s.getLayersOfType("transmission").forEach(c=>{c.uniforms[`f${c.id}_aspectRatio`].value.x=o,c.uniforms[`f${c.id}_aspectRatio`].value.y=i})})}},ks=Id;ks.PERSONAL_CAMERA_ID="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera";var Gy=require("three/examples/jsm/loaders/DRACOLoader.js");var Po;function $_(){return Po||(Po=new Gy.DRACOLoader,Po.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),Po.decoderPending}async function Y_(n){if(Po){let r={attributeIDs:Po.defaultAttributeIDs,attributeTypes:Po.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await Po.decodeGeometry(new Int8Array(n).buffer,r)}catch(t){console.error(t)}if(e)return{index:e.index?{array:e.index.array}:void 0,attributes:Object.entries(e.attributes).map(([t,o])=>({name:t,itemSize:o.itemSize,array:o.array}))}}return null}async function Ry(n,r){let[e,t]=Zl(da.deserialize(new Uint8Array(n)));Qf(e);let o=[];e.scene.objects.traverse((i,s)=>{s.type==="Mesh"&&s.geometry.type==="NonParametricGeometry"&&s.geometry.data.draco!==void 0&&o.push(s)}),o.length&&await $_();for(let i of o){let s=await Y_(at(i.geometry.data.draco));if(s){s.index&&(i.geometry.data.index={array:s.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let l={};s.attributes.forEach(({name:c,array:u,itemSize:a})=>{l[c]={array:u,itemSize:a,type:"Float32Array",normalized:!1}}),i.geometry.data.attributes=l,i.geometry.data.draco=void 0}}return r&&r(e),t.result().data}var X_=require("three"),K_=require("three/examples/jsm/utils/BufferGeometryUtils.js");function Vy(n){let r;if(!!n.index)for(let e=0;e<n.index.array.length;e+=3)r=n.index.array[e],n.index.array[e]=n.index.array[e+2],n.index.array[e+2]=r}var Hs=require("three");function jy(n){let r=new Set;return n.traverse(e=>{if(e instanceof yr)if(qe(e.material))e.material.forEach(t=>{let o=t;r.has(o)||r.add(o)});else{let t=e.material;r.has(t)||r.add(t)}}),r.forEach(e=>{if(e instanceof Array)return;let t=e.onBeforeCompile.bind(e);if(Z_(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new Hs.Color,specularColor:new Hs.Color});let o=0;e.onBeforeCompile=(i,s)=>{t&&t(i,s),i.uniforms=Object.assign({},Hs.ShaderLib.physical.uniforms,i.uniforms),e.getLayersOfType("transmission").forEach(l=>{if(i.uniforms.transmissionSamplerMap.value){let c=l.color;c&&(c.transmissionSamplerMap.value=i.uniforms.transmissionSamplerMap.value,c.transmissionSamplerSize.value=i.uniforms.transmissionSamplerSize.value)}else o++,o<2&&(e.needsUpdate=!0)})}}else Q_(e)||(e.onBeforeCompile=(o,i)=>{t&&t(o,i),e.transparent=!1})}),n}function Z_(n){return n.getLayersOfType("transmission").length>0}function Q_(n){let r=0;return n.layers.forEach(e=>{if(e.type!=="light"&&e.type!=="fresnel"){let t=e.uniforms["f"+e.id+"_alpha"];t&&(r+=(1-r)*t.value)}}),r<1}function Fy(n){return n.traverse(r=>{if(r.type==="Camera"){let e=r;e.type=e.cameraType}}),n}function Uy(n){let r=[],e=(t,o=0)=>{let i=o>0?t+o:t;return r.includes(i)?e(t,o+1):i};return n.traverse(t=>{if(r.includes(t.name)){let o=t.name,i=e(t.name);if(t.name=i,t.isMesh){let s=t;s.material instanceof Array?s.material.forEach(l=>{l.name=l.name.replace(o,i)}):s.material.isAsset||(s.material.name=s.material.name.replace(o,i))}}r.push(t.name)}),n}var zy=require("three/examples/jsm/utils/BufferGeometryUtils.js");function ky(n){let r=[];return n.traverse(e=>{e instanceof _i&&r.push(e)}),r.forEach(e=>{let t=e.object,i=e.children.map(l=>{l.updateMatrix();let c=l.geometry.clone().applyMatrix4(l.matrix);return l.matrix.determinant()<0&&Vy(c),c}),s=(0,zy.mergeBufferGeometries)(e.parameters.hideBase?i:[t instanceof ht?t.geometry:[],...i]);t instanceof ht&&(t.geometry=s),e.removeFromParent(),t.setFromClonerState(null,{scene:n,shared:$h})}),n}function Hy(n){return n.traverse(r=>{r.matrixAutoUpdate=!0}),n}function Wy(n){Object.values(n.shared.materials).forEach(r=>{Cd(r)}),n.scene.objects.traverse((r,e)=>{"material"in e?Cd(e.material):"materials"in e&&e.materials.forEach(t=>{Cd(t)})})}function Cd(n){if(typeof n=="string")return;let r=[];n.layers.forEach((e,t)=>{e.type==="outline"&&r.push(t)}),r.reverse().forEach(e=>{n.layers.delete(e)}),r.length&&console.warn("The Spline Loader currently does not support the outline layer.")}var qy="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",jl=class extends Fl.Loader{load(r,e,t,o=console.error){let i=new Fl.FileLoader(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),r.endsWith(".spline")?console.warn(qy+" The .spline files are only meant to be used by the Editor."):r.endsWith(".splinecode")||console.warn(qy),i.load(r,async s=>{try{if(typeof s=="string")throw new Error("The .spline file is not binary!");let l=await this.parse(s);e(l)}catch(l){o(l)}},t,o)}async parse(r){let e=await Ry(r,Wy);await Promise.all([Xh(e)&&ph(),sy(e)&&Wh()].filter(Boolean));let t=new Qo(e.shared);Object.values(t.getMaterials()).forEach(s=>Object.assign(s,{isAsset:!0}));let o=new ks(e.scene,t);o.remove(o.personalCamera),e.scene.environment.ambientLight.enabled||o.remove(o.ambientLight);let i=e.scene.publish.playCamera;if(i){let s=o.find(i);s&&gy(s)&&Object.assign(s,{makeDefault:!0})}return o=ky(o),o=jy(o),o=Fy(o),o=Uy(o),o=Hy(o),o}};
1334
+ }`,[wt.simplex,e,o,s])}}();var ey=require("three");function Jh(n,r,e){n.setUvTransform(e[0],e[1],r[0],r[1],0,0,0)}var Dl=class extends xi{constructor(e,t){super(new ey.Matrix3);this.repeat=e;this.offset=t;Jh(this.value,e,t)}updateMatrix(){Jh(this.value,this.repeat,this.offset)}};var Rr=class{constructor(r,e,t,o){this.id=r;this.uuid=e;this.data=t;this.uniforms={};for(let i in o)this.uniforms[`f${this.id}_${i}`]=o[i];for(let i in t)Ld(i,this,t)}get type(){return this.data.type}static create(r,e,t,o){if(t.type==="light")return Vr.createLigherLayer(r,e,t,o);if(t.type==="texture"||t.type==="video"){let i=t.type==="texture"?o.image(t.texture.image):o.video(t.texture.video),s=new Zo(i,t.texture.wrapping),l=new Bl(i),c=new Dl(t.texture.repeat,t.texture.offset),u=new J(t.crop?1:0),a=new be(t.projection??0),d=new be(["x","y","z"].indexOf(t.axis)??0),p=new be(t.side??0),f=new ft(t.size?new Ve.Vector2(t.size[0],t.size[1]):new Ve.Vector2(100,100)),m=new J(t.alpha??1),h=new be(t.mode??0),y=new Ls(s,l,u,a,d,p,f,c,m,h),g=new Ae(y.calpha,"f");return new rt(r,e,t,{texture:s,textureSize:l,crop:u,projection:a,axis:d,side:p,size:f,mat:c,alpha:m,mode:h},y,h,g)}else if(t.type==="matcap"){let i=o.image(t.texture.image),s=new Zo(i,t.texture.wrapping),l=new J(t.alpha??1),c=new be(t.mode??0),u=new Gs(s,l,c),a=new Ae(u.calpha,"f");return new rt(r,e,t,{texture:s,alpha:l,mode:c},u,c,a)}else if(t.type==="displace")if(t.displacementType==="noise"){let i=new xt(new Ve.Vector3(...t.offset)),s=new J(t.scale??10),l=new J(t.intensity??8),c=new J(t.movement??1),u=new be(t.noiseType??0),a=new Es(l,c,i,s,u);return new Vs(r,e,t,{offset:i,scale:s,intensity:l,movement:c,noiseType:u},a)}else throw new Error;else return F_(r,e,t,o)}updateByOp(r,e,t){let o=r;if(o.path[0]===void 0){if(o.type===0)return"type"in o.props||"category"in o.props?(t.scene?.markNeedsUpdateRendererDirty(),!0):Zh(o.props,t.shared,this,e)}else if(o.path[0]==="texture")return"texture"in e||"video"in e?Md(o.props,t.shared,this):!0;return!1}dispose(){if(V_(this)){let r=this.uniforms[`f${this.id}_texture`];if(!r)return!1;let e=r;e.image instanceof tr||e.image.deref()}}hasValueByKey(r){return this.uniforms[r]!==void 0}hasValue(r){return this.hasValueByKey(`f${this.id}_${r}`)}setValue(r,e){let t=`f${this.id}_${r}`;this.hasValueByKey(t)&&e!==void 0&&(this.uniforms[t].value=e)}getNode(r){let e=`f${this.id}_${r}`;if(this.hasValueByKey(e))return this.uniforms[e]}getValue(r){let e=`f${this.id}_${r}`;if(this.hasValueByKey(e))return this.uniforms[e].value}getName(r){let t=/f\d+_(.*)/.exec(r);if(t&&t.length>1)return t[1];console.log(`Layer.getName: error ${r}`)}getNames(){let r=[];for(let e in this.uniforms){let t=this.getName(e);t&&r.push(t)}return r}},rt=class extends Rr{constructor(e,t,o,i,s,l,c){super(e,t,o,i);this.params=i;this.color=s;this.mode=l;this.alpha=c}},Vs=class extends Rr{constructor(e,t,o,i,s){super(e,t,o,i);this.position=s}},Vr=class extends Rr{constructor(e,t,o,i,s){super(e,t,o,s);this.node=i}static createLigherLayer(e,t,o,i){let s,l=new J(o.alpha),c=new be(o.mode),u;if(!o.visible)s=new Ko,u={};else if(o.category==="lambert"){s=new xs;let a=new Ie(i.color(o.emissive)??0);u={emissive:a},s.emissive=a}else if(o.category==="toon"){s=new ws;let a=new J(o.shininess??30),d=new Ie(i.color(o.specular)??1118481);u={shininess:a,specular:d},s.shininess=a,s.specular=d}else if(o.category==="physical"){s=new bs;let a=new J(o.roughness??.3),d=new J(o.metalness??0),p=new J(o.reflectivity??.5);u={roughness:a,metalness:d,reflectivity:p},s.roughness=a,s.metalness=d,s.reflectivity=p}else{s=new Cl;let a=new J(o.shininess??30),d=new Ie(o.specular!==void 0?i.color(o.specular)??1118481:1118481);u={shininess:a,specular:d},s.shininess=a,s.specular=d}return s.alpha=new J(1),s.shadingAlpha=l,s.shadingBlend=c,u.alpha=s.shadingAlpha,u.mode=s.shadingBlend,new Vr(e,t,o,s,u)}get category(){return this.node.category}};function V_(n){let r=n instanceof Rr?n.type:n;return r==="texture"||r==="video"||r==="displace_map"||r==="matcap"}function j_(n,r,e,t){switch(n.type){case"color":{let o=new Ie(t.color??5855577),i=new J(t.alpha??1),s=new Ae("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");s.keywords.alpha=i;let l=new be(t.mode??0);return o.alpha=i,new rt(r,e,n,{color:o,alpha:i,mode:l},o,l,s)}case"fresnel":{let o=new Ie(t.color??16777215),i=new J(t.bias??.1),s=new J(t.scale??1),l=new J(t.intensity??2),c=new J(t.factor??1),u=new J(t.alpha??1),a=new be(t.mode??0),d=new Ps(o,i,s,l,c,u,a),p=new Ae(d.calpha,"f");return new rt(r,e,n,{color:o,bias:i,scale:s,intensity:l,factor:c,alpha:u,mode:a},d,a,p)}case"rainbow":{let o=new J(t.filmThickness??30),i=new J(t.movement??0),s=new xt(t.wavelengths??new Ve.Vector3(0,0,0)),l=new J(t.noiseStrength??0),c=new J(t.noiseScale??1),u=new xt(t.offset??new Ve.Vector3(0,0,0)),a=new J(t.alpha??1),d=new Os(o,i,s,l,c,u,a),p=new Ae(d.calpha,"f"),f=new be(t.mode??0);return new rt(r,e,n,{filmThickness:o,movement:i,wavelengths:s,noiseStrength:l,noiseScale:c,offset:u,alpha:a,mode:f},d,f,p)}case"transmission":{let o=new J(t.thickness??10),i=new J(t.ior??1.5),s=new J(t.roughness??.5),l=vt.transmissionSize,c=vt.transmissionRenderTarget,u=vt.transmissionRenderTargetDepth,a=window.innerWidth,d=window.innerHeight,p=a>=d?new ft(d/a,1):new ft(1,a/d),f=new J(t.alpha??1),m=new Is(o,i,s,l,c,u,p,f),h=new Ae(m.calpha,"f"),y=new be(t.mode??0);return new rt(r,e,n,{thickness:o,ior:i,roughness:s,aspectRatio:p,alpha:f,mode:y},m,y,h)}case"toon":{let o=new be(t.positioning??0),i;t.colors?i=new vr(t.colors.length,t.colors):(i=new vr(10,new Ve.Vector4(0,0,0,1)),i.value[1]=new Ve.Vector4(1,1,1,1));let s;t.steps?s=new xr(t.steps.length,t.steps):(s=new xr(10,1),s.value[0]=0);let l=new xt(t.source??new Ve.Vector3(0,0,0)),c=new Po(t.isWorldSpace??!0),u=new J(t.noiseStrength??0),a=new J(t.noiseScale??1),d=new er(t.shadowColor),p=new xt(t.offset??new Ve.Vector3(0,0,0)),f=new J(t.alpha??1),m=new Rs(o,i,s,l,c,u,a,d,p,f),h=new Ae(m.calpha,"f"),y=new be(t.mode??0);return new rt(r,e,n,{positioning:o,colors:i,steps:s,source:l,isWorldSpace:c,noiseStrength:u,noiseScale:a,shadowColor:d,offset:p,alpha:f,mode:y},m,y,h)}case"outline":{let o=new Ie(t.outlineColor??16777215),i=new Ie(t.contourColor??16777215),s=new J(t.outlineWidth??.1),l=new J(t.contourWidth??.1),c=new J(t.outlineThreshold??.1),u=new J(t.contourThreshold??.1),a=new J(t.outlineSmoothing??.1),d=new J(t.contourFrequency??.1),p=new xt(t.contourDirection??new Ve.Vector3(0,1,0)),f=new Po(t.positionalLines??!1),m=new Po(t.compensation??!0),h=vt.normalRenderTarget,y=vt.normalRenderTargetDepth,g=vt.pixelRatioNode,v=vt.resolution,w=new J(t.alpha??1),S=new As(o,i,s,l,c,u,a,d,p,f,m,v,h,y,g,w),b=new Ae(S.calpha,"f"),T=new be(t.mode??0);return new rt(r,e,n,{outlineColor:o,contourColor:i,outlineWidth:s,contourWidth:l,outlineThreshold:c,contourThreshold:u,outlineSmoothing:a,contourFrequency:d,contourDirection:p,positionalLines:f,compensation:m,alpha:w,mode:T},S,T,b)}case"depth":{let o=new be(t.gradientType??0),i=new Po(t.smooth??!1),s=new J(t.near??50),l=new J(t.far??200),c=new J(t.isVector??1),u=new J(t.isWorldSpace??0),a=new xt(t.origin??new Ve.Vector3),d=new xt(t.direction??new Ve.Vector3),p;t.colors?p=new vr(t.colors.length,t.colors):(p=new vr(2,new Ve.Vector4(0,0,0,1)),p.value[1]=new Ve.Vector4(1,1,1,1));let f;t.steps?f=new xr(t.steps.length,t.steps):(f=new xr(2,1),f.value[0]=0);let m=new J(t.alpha??1),h=new be(t.mode??0),y=new Cs(o,i,s,l,c,u,a,d,p,f,m),g=new Ae(y.calpha,"f");return new rt(r,e,n,{gradientType:o,smooth:i,near:s,far:l,isVector:c,isWorldSpace:u,origin:a,direction:d,colors:p,steps:f,alpha:m,mode:h},y,h,g)}case"noise":{let o=new J(t.scale??1),i=new xt(t.size??new Ve.Vector3(100,100,100)),s=new J(t.move??1),l=new ft(t.fA??new Ve.Vector2(1.7,9.2)),c=new ft(t.fB??new Ve.Vector2(8.3,2.8)),u=new ft(t.distortion??new Ve.Vector2(1,1)),a=new er(t.colorA),d=new er(t.colorB),p=new er(t.colorC),f=new er(t.colorD),m=new J(t.alpha??1),h=new be(t.mode??0),y=new be(t.noiseType??0),g=new Ts(o,i,s,l,c,u,a,d,p,f,m,y),v=new Ae(g.calpha,"f");return new rt(r,e,n,{scale:o,size:i,move:s,fA:l,fB:c,distortion:u,colorA:a,colorB:d,colorC:p,colorD:f,alpha:m,mode:h,noiseType:y},g,h,v)}case"normal":{let o=new xt(t.cnormal??new Ve.Vector3(1,1,1)),i=new J(t.alpha??1),s=new be(t.mode??0),l=new Ds(o,i),c=new Ae("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");return c.keywords.alpha=i,new rt(r,e,n,{cnormal:o,alpha:i,mode:s},l,s,c)}case"gradient":{let o=new be(t.gradientType??0),i=new Po(t.smooth??!1),s;t.colors?s=new vr(t.colors.length,t.colors):(s=new vr(10,new Ve.Vector4(0,0,0,1)),s.value[1]=new Ve.Vector4(1,1,1,1));let l;t.steps?l=new xr(t.steps.length,t.steps):(l=new xr(10,1),l.value[0]=0);let c=new ft(t.offset??new Ve.Vector2(0,0)),u=new ft(t.morph??new Ve.Vector2(0,0)),a=new J(t.angle??0),d=new J(t.alpha??1),p=new be(t.mode??0),f=new Ms(o,i,s,l,c,u,a,d),m=new Ae(f.calpha,"f");return new rt(r,e,n,{gradientType:o,smooth:i,colors:s,steps:l,offset:c,morph:u,angle:a,alpha:d,mode:p},f,p,m)}default:{let o=new Ie(1,0,0,1),i=new J(1),s=new Ae("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");s.keywords.alpha=i;let l=new be(0);return o.alpha=i,new rt(r,e,n,{color:o,alpha:i,mode:l},o,l,s)}}}function F_(n,r,e,t){let o=Yh(e,t);return j_(e,n,r,o)}function Ld(n,r,e){if(e.type==="displace"&&(n==="intensity"||n==="visible")){let t=r.uniforms[`f${r.id}_intensity`];return t?(t.value=e.intensity*(e.visible?1:0),t):void 0}if(e.type!=="displace"&&(n==="alpha"||n==="visible")){let t=r.uniforms[`f${r.id}_alpha`];if(!t)return;if(t.value=e.alpha*(e.visible?1:0),e.type==="outline"&&n==="visible"){let o=r.uniforms[`f${r.id}_compensation`];o&&(o.value=e.compensation&&e.visible)}return t}}function ty(n,r){let e=0;for(let t of n.layers)if(t.data.type!=="displace"&&"alpha"in t.data&&t.data.type!=="light"&&t.data.type!=="fresnel"&&t.data.type!=="texture"&&t.data.type!=="matcap"&&t.data.type!=="rainbow"&&t.data.type!=="outline"){let o=t.data.visible?t.data.alpha:0;if(o==1&&t.data.type=="depth"||t.data.type=="gradient"){for(let i of t.data.colors)if(i[3]<1){o=i[3];break}}else if(o==1&&t.data.type=="noise"){let i=r.color(t.data.colorA).a,s=r.color(t.data.colorB).a,l=r.color(t.data.colorC).a,c=r.color(t.data.colorD).a,u=Math.min(i,Math.min(s,Math.min(l,c)));u<1&&(o=u)}e+=(1-e)*o}return e<1}var Ut=class extends ry.ShaderMaterial{constructor(){super(void 0);this.flatShading=!1;this.cacheKey="";this.fog=!0,this.dithering=!0,this.vertexColors=!0,this.transparent=!0}customProgramCacheKey(){return this.cacheKey}},Gd=class extends Ut{constructor(e,t,o,i){super();this.flatShading=e;this.side=t;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,t){this.root.onBeforeCompile(e)}get data(){return this.root.data}get category(){return this.root.category}getFlavor(e,t,o){return this.root.getFlavor(e,t,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,t,o){this.root.updateByOp(e,t,o)}nodeMaterialDispose(){this.root.nodeMaterialDispose()}},Si=class extends Ut{constructor(e,t){super();this.data=e;this.layerIdGen=0;this.flavors=[];this.type="NodeMaterial";this.updaters=[],this.reset0(e,t)}get nodeMaterial(){return this}getFlavor(e,t,o){let i=o?6:(e?3:0)+t;if(i===0)return this;this.flavors===void 0&&(this.flavors=[]),i-=1;let s=this.flavors[i];return s===void 0&&(s=new Gd(e,t,o,this),this.flavors[i]=s,s.flatShading=e,s.side=t,s.updateAfterBuild()),s}get fragment(){return this.lightLayer.node}get category(){return this.lightLayer.category}reset(e,t){this.data!==e&&this.reset0(e,t)}reset0(e,t){this.data=e;let o=e.layers??Dt.defaultTwoLayerData("phong").layers;this.layers=o.map(i=>Rr.create(this.layerIdGen++,i.id,i.data,t.shared)),this.layers.reverse(),this.name=e.name??"Untitled Material",this.onUpdate(),this.transparent=ty(e,t.shared)}getLayersOfType(e){return this.layers.filter(t=>t.type===e)}getLayerByUuid(e){return this.layers.find(t=>t.uuid===e)}onUpdate(){this.cacheKey=this.computeCacheKey(),this.lightLayer=this.layers.find(e=>e instanceof Vr),this.lightLayer===void 0&&(this.lightLayer=new Vr(0,"",{...Ot.defaultData("light","phong"),visible:!1},new Ko,{})),this.dispose(),this.needsUpdate=!0,this.blendColors(),this.blendAfterColors(),this.blendPositions()}updateByOp(e,t,o){if(this.data=t,this.transparent=ty(t,o.shared),e.path[0]==="layers"){this.data=t;let i=o.shared,s=e.path[1];if(s===void 0){if(this.layers.reverse(),e.type===4){let l=Rr.create(this.layerIdGen++,e.id,e.data,o.shared);this.layers.splice(e.localIndex,0,l),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 l=this.layers.findIndex(u=>u.uuid===e.id),c=this.layers[l];this.layers.splice(l,1),this.layers.splice(e.localIndex,0,c),o.scene?.markNeedsUpdateRendererDirty()}this.layers.reverse(),this.onUpdate()}else{let l=this.layers.find(c=>c.uuid===s);if(l){let c=t.layers.data(s);if(l.updateByOp({...e,path:e.path.slice(2)},c,o)){let a=Rr.create(this.layerIdGen++,s,c,i);this.layers.splice(this.layers.findIndex(d=>d.uuid===s),1,a),this.onUpdate()}}}}else this.reset(t,o)}blendColors(){let e=this.layers.findIndex(o=>o instanceof rt),t=this.layers.findIndex(o=>o instanceof Vr);if(e!==-1&&e<t){let o=this.layers[e].color;for(let i=e+1;i<t;++i){let s=this.layers[i];s instanceof rt&&(o=new Ns(o,s.color,s.alpha,s.mode))}this.fragment.color=o}else this.fragment.color=void 0}blendAfterColors(){let e=new Ae("outgoingLight","f"),t=this.layers.findIndex(o=>o instanceof Vr);if(this.layers.length>t+1){for(let o=t+1;o<this.layers.length;++o){let i=this.layers[o];i instanceof rt&&(e=new Ns(e,i.color,i.alpha,i.mode))}this.fragment.afterColor=e}else this.fragment.afterColor=void 0}blendPositions(){let e=this.layers.filter(t=>t instanceof Vs);if(e.length>0){let t=e[0].position;for(let o=1;o<e.length;++o)e[o]&&(t=new Ft(t,e[o].position,Ft.ADD),t=new Ft(t,new J(.5).setReadonly(!0),Ft.MUL));this.fragment.position=t}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,t){let o=(i,s,l)=>Math.min(Math.max(i,s),l);for(let i of this.layers)if(i.type==="displace"){let s=o(i.uniforms[`f${i.id}_intensity`].value,e,t);i.uniforms[`f${i.id}_intensity`].value=s}}computeCacheKey(){let e="[";for(let{data:t}of this.data.layers)if(t.type==="light")e+=`"${t.visible?t.category.toUpperCase():"Basic"}"`;else{let o=(Nd[t.type]??[]).map(l=>t[l]),i=(Ed[t.type]??[]).map(l=>t[l]?.length??0),s=[...o,...i];s.length?e+=`["${t.type}", "${s.join('","')}"],`:e+=`"${t.type}",`}return e=e.slice(0,-1)+"]",e}updateFrame(e){for(let t=0;t<this.updaters.length;++t)e.updateNode(this.updaters[t])}build(){let e=new Al;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 t of this.flavors)t&&t.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 rt){let t=e.params.texture;if(t instanceof Zo&&!t.image.loaded)return!1}return!0}getHash(){let e="{";return e+='"fragment":'+this.fragment.getHash(),e+="}",e}};Object.defineProperties(Ut.prototype,{properties:{get:function(){return this.fragment.properties}}});var Qo=class extends Si{};var sy=Ri(oy());var ny=new Map;function iy(n){if(typeof n=="string")return n;let r=ny.get(n);return r||(r={url:URL.createObjectURL(new Blob([n]))},ny.set(n,r)),r.url}var Jo=class{constructor({src:r,volume:e,delay:t,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 r=="string"?i={src:r}:i={src:iy(r),format:"wav"},this.sound=new sy.Howl(i),this.sound.on("end",this.onEnd),this.src=r,e!==void 0&&(this.volume=e),t!==void 0&&(this.delay=t),o!==void 0&&(this.loop=o)}get status(){return this._status}get volume(){return this._volume}set volume(r){this._volume=r,this.sound.volume(r)}get loop(){return this._loop}set loop(r){this._loop=r,this.loopsRemaining=r}replay(){this.clearDelay(),this.delayTimerId=window.setTimeout(()=>{this.sound.play(),this.clearDelay()},this.delay)}fade(r,e=1e3){r?(this.sound.volume(this._volume),this.clearFade(),this.fadeTimerId=window.setTimeout(()=>{this.sound.fade(this._volume,0,e),this.clearFade()},r)):this.sound.fade(this._volume,0,e)}on(r,e,t){this.sound.on(r,e,t)}off(r,e,t){this.sound.off(r,e,t)}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(r=!1){this.off(),this.stop(),this.clearFade(),this.clearDelay()}};var at=require("three"),Rl=class{constructor(){this.type="ShapePath";this.color=new at.Color;this.subPaths=[];this.currentPath=null}moveTo(r,e){return this.currentPath=new at.Path,this.subPaths.push(this.currentPath),this.currentPath.moveTo(r,e),this}lineTo(r,e){return this.currentPath?.lineTo(r,e),this}quadraticCurveTo(r,e,t,o){return this.currentPath?.quadraticCurveTo(r,e,t,o),this}bezierCurveTo(r,e,t,o,i,s){return this.currentPath?.bezierCurveTo(r,e,t,o,i,s),this}splineThru(r){return this.currentPath?.splineThru(r),this}toShapes(){let e={ORIGIN:0,DESTINATION:1,BETWEEN:2,LEFT:3,RIGHT:4,BEHIND:5,BEYOND:6},t={loc:e.ORIGIN,t:0};function o(h,y,g,v){let w=h.x,S=y.x,b=g.x,T=v.x,_=h.y,x=y.y,C=g.y,P=v.y,I=(T-b)*(_-C)-(P-C)*(w-b),A=(S-w)*(_-C)-(x-_)*(w-b),O=(P-C)*(S-w)-(T-b)*(x-_),V=I/O,z=A/O;if(O===0&&I!==0||V<=0||V>=1||z<0||z>1)return null;if(I===0&&O===0){for(let $=0;$<2;$++)if(i($===0?g:v,h,y),t.loc===e.ORIGIN){let te=$===0?g:v;return{x:te.x,y:te.y,t:t.t}}else if(t.loc===e.BETWEEN){let te=+(w+t.t*(S-w)).toPrecision(10),K=+(_+t.t*(x-_)).toPrecision(10);return{x:te,y:K,t:t.t}}return null}else{for(let K=0;K<2;K++)if(i(K===0?g:v,h,y),t.loc===e.ORIGIN){let q=K===0?g:v;return{x:q.x,y:q.y,t:t.t}}let $=+(w+V*(S-w)).toPrecision(10),te=+(_+V*(x-_)).toPrecision(10);return{x:$,y:te,t:V}}}function i(h,y,g){let v=g.x-y.x,w=g.y-y.y,S=h.x-y.x,b=h.y-y.y,T=v*b-S*w;if(h.x===y.x&&h.y===y.y){t.loc=e.ORIGIN,t.t=0;return}if(h.x===g.x&&h.y===g.y){t.loc=e.DESTINATION,t.t=1;return}if(T<-Number.EPSILON){t.loc=e.LEFT;return}if(T>Number.EPSILON){t.loc=e.RIGHT;return}if(v*S<0||w*b<0){t.loc=e.BEHIND;return}if(Math.sqrt(v*v+w*w)<Math.sqrt(S*S+b*b)){t.loc=e.BEYOND;return}let _;v!==0?_=S/v:_=b/w,t.loc=e.BETWEEN,t.t=_}function s(h,y){let g=[],v=[];for(let w=1;w<h.length;w++){let S=h[w-1],b=h[w];for(let T=1;T<y.length;T++){let _=y[T-1],x=y[T],C=o(S,b,_,x);C!==null&&g.find(P=>P.t<=C.t+Number.EPSILON&&P.t>=C.t-Number.EPSILON)===void 0&&(g.push(C),v.push(new at.Vector2(C.x,C.y)))}}return v}function l(h,y,g){let v=new at.Vector2;y.getCenter(v);let w=[];return g.forEach(S=>{S.boundingBox.containsPoint(v)&&s(h,S.points).forEach(T=>{w.push({identifier:S.identifier,isCW:S.isCW,point:T})})}),w.sort((S,b)=>S.point.x-b.point.x),w}function c(h,y,g,v,w){(w==null||w==="")&&(w="nonzero");let S=new at.Vector2;h.boundingBox.getCenter(S);let b=[new at.Vector2(g,S.y),new at.Vector2(v,S.y)],T=l(b,h.boundingBox,y);T.sort((A,O)=>A.point.x-O.point.x);let _=[],x=[];T.forEach(A=>{A.identifier===h.identifier?_.push(A):x.push(A)});let C=_[0].point.x,P=[],I=0;for(;I<x.length&&x[I].point.x<C;)P.length>0&&P[P.length-1]===x[I].identifier?P.pop():P.push(x[I].identifier),I++;if(P.push(h.identifier),w==="evenodd"){let A=P.length%2===0,O=P[P.length-2];return{identifier:h.identifier,isHole:A,for:O}}else if(w==="nonzero"){let A=!0,O=null,V=null;for(let z=0;z<P.length;z++){let $=P[z];y[$]&&(A?(V=y[$].isCW,A=!1,O=$):V!==y[$].isCW&&(V=y[$].isCW,A=!0))}return{identifier:h.identifier,isHole:A,for:O}}else console.warn('fill-rule: "'+w+'" is currently not implemented.')}let u=0,a=999999999,d=-999999999,p=[];this.subPaths.forEach(h=>{let y=h.getPoints(),g=-999999999,v=999999999,w=-999999999,S=999999999;for(let b=0;b<y.length;b++){let T=y[b];T.y>g&&(g=T.y),T.y<v&&(v=T.y),T.x>w&&(w=T.x),T.x<S&&(S=T.x)}d<=w&&(d=w+1),a>=S&&(a=S-1),y.length&&p.push({curves:h.curves,points:y,isCW:at.ShapeUtils.isClockWise(y),identifier:u++,boundingBox:new at.Box2(new at.Vector2(S,v),new at.Vector2(w,g))})});let f=p.map(h=>c(h,p,a,d,this.userData?.style.fillRule)),m=[];return p.forEach(h=>{let y=f[h.identifier];if(y&&!y.isHole){let g=new at.Shape;g.curves=h.curves,f.filter(w=>w?.isHole&&w.for===h.identifier).forEach(w=>{if(w){let S=p[w.identifier],b=new at.Path;b.curves=S.curves,g.holes.push(b)}}),m.push(g)}}),m}};var ly,Rd=new Promise(n=>{ly=n}),ay=!1;async function cy(){if(ay)return;let n=await import("./opentype.js");ly(n),ay=!0}var js=class{async load(r,e,t=()=>{}){let{load:o}=await Rd;o(r,(i,s)=>{i||!s?t(i??"Something went wrong"):e(s)})}async parse(r){let{parse:e,Bidi:t}=await Rd;try{let o=e(r),i=new t,s=l=>o.charToGlyphIndex(l.char);return i.registerModifier("glyphIndex",null,s),i.applyFeatures(o,o.defaultRenderOptions.features),{font:o,bidi:i}}catch(o){console.error(o)}}};async function z_(n){return await(await fetch(n)).arrayBuffer()}var U_=new js;async function Vd(n){let r,e,t=!1;if(n.url?(r=await z_(n.url),e=n.url,t=n.url.startsWith("/")):n.data&&(r=n.data.buffer),r){let o=await U_.parse(r);if(o)return{font:o.font,url:e,intercepted:t,arr:r,bidi:o.bidi}}}var wi=require("three");function k_(n,r){return r.state.glyphIndex===n||r.state.fina===n||r.state.medi===n||r.state.init===n}var Vl=class{constructor(r){this._arrayBuffer=new ArrayBuffer(1);this._isLoaded=!1;this._intercepted=!1;this._isUserFont=r.isUserFont??!1,this._loadingPromise=Vd(r).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(r){this._isLoaded=!1,this._isUserFont=r.isUserFont??!1,this._loadingPromise=Vd(r).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(r,e,t){if(!this._bidi)return[];let o=this._bidi;o.getTextGlyphs(e);let i=o.tokenizer.tokens,s=[],l=0,c=t.length===i.length;for(let u=0;u<t.length;u++){let a=t[u].index,d=String.fromCharCode(t[u].unicode),p=i[l];if(k_(a,p)||c)s.push({char:d,index:a,replacements:[p.state.glyphIndex],replacementChars:[p.char]}),l++;else{let f=p.char,m="",h=[p.state.glyphIndex],y=[],g=!1;for(;!g;)l++,m=e.charAt(l),f+=m,h.push(r.charToGlyphIndex(m)),y=r.stringToGlyphs(f),y.length===1&&y[0].index===a&&(g=!0),l>e.length&&(g=!0);s.push({char:d,index:a,replacements:h,replacementChars:Array.from(f)}),l++}}return s}generateShapes(r,e){if(!this._isLoaded)return;let t=this.font,o=e.fontSize/this.unitsPerEm,i=e.fontSize*e.lineHeight,s=r.map(v=>this.getTextWidth(v,e)),l=e.width,c=this.getCharWidth(`
1335
+ `,e),u=e.horizontalAlign===1?c:0,a=this.computeSpaceWidthForLine(r,0,e),d=this.getLineInitialOffsetX(s[0],l,e.horizontalAlign,r[0],c),p=this.getLineInitialOffsetY(i,r.length,e.height,o,e.verticalAlign),f=[],m=r.map(v=>[]),h=r.map(v=>[]),y;for(let v=0;v<r.length;v++){let w=r[v],S={features:{liga:!0}},b=[];try{b=t.stringToGlyphs(w,S)}catch(_){console.warn(_)}d=this.getLineInitialOffsetX(s[v],l,e.horizontalAlign,w,c);let T=[];try{T=this.reverseLigaturesTable(t,w,b)}catch(_){console.warn(_)}a=this.computeSpaceWidthForLine(r,v,e);for(let _=0;_<b.length;_++){let x=b[_],C=x.index===0?`
1336
+ `:x.unicode?String.fromCharCode(x.unicode):void 0,P=T[_],I=0,A=0;_===0&&e.horizontalAlign===2&&x.leftSideBearing!==void 0&&(A=-x.leftSideBearing*o),y&&(I=t.getKerningValue(x,y)*o),d+=A+I;let O=0;if(C===`
1337
+ `)O=u;else if(C===" ")O=a;else{let V=this.createPath(x,o,d,p,e);V&&(O=V.offsetX-(I+A),f.push(V.path))}if(P.replacements.length===1)h[v].push([d,p]),m[v].push(O);else{let V=P.replacements.map(K=>(t.glyphs.get(K).advanceWidth??0)*o),z=V.reduce((K,q)=>K+=q,0),$=V.map(K=>K/z),te=d;for(let K=0;K<$.length;K++){let q=O*$[K];h[v].push([te,p]),m[v].push(q),te+=q}}d+=O,y=x}p-=i}let g=[];for(let v=0,w=f.length;v<w;v++)g.push(...f[v].toShapes());return{shapes:g,charWidths:m,lineWidths:s,charCoords:h}}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(r,e,t,o,i){return(t===3||t===2)&&o.indexOf(`
1338
+ `)>=0&&(r-=i),t===3?e*.5-r*.5:t===2?e-r:0}getLineInitialOffsetY(r,e,t,o,i){let s=e*r,l=Math.abs(this.ascender-this.descender)*o,c=r-l,u=-this.ascender*o-c/2;return i===3?-(t-s-u):i===2?-(t*.5-s*.5-u):u}createPath(r,e,t,o,i){let s=r.getPath(t,-o,i.fontSize,{kerning:!1,letterSpacing:i.letterSpacing});if(!s){console.error('THREE.Font: character "'+r+'" does not exists in font family '+this.familyName+".");return}let l=new Rl,c=(r.advanceWidth??1)*e;if(r)for(let u of s.commands){let a=l.currentPath?.currentPoint;if(!(a&&u.type!=="Z"&&a.x===u.x&&-a.y===u.y))switch(u.type){case"M":l.moveTo(u.x,-u.y);break;case"L":l.lineTo(u.x,-u.y);break;case"Q":l.quadraticCurveTo(u.x1,-u.y1,u.x,-u.y);break;case"C":l.bezierCurveTo(u.x1,-u.y1,u.x2,-u.y2,u.x,-u.y);break}}return l.subPaths.forEach(u=>{let a=H_(u.curves);a!==void 0&&u.currentPoint.distanceTo(a)>0&&u.lineTo(a.x,a.y)}),{offsetX:c+i.fontSize*i.letterSpacing,path:l}}getCharWidth(r,e){return this.font?.getAdvanceWidth(r,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}getTextWidth(r,e){return this.font?.getAdvanceWidth(r,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}computeSpaceWidthForLine(r,e,t){let o=this.getCharWidth(" ",t),i=r[e];if(i){let s=this.countSpaces(i.trimEnd());if(t.horizontalAlign===4&&e<r.length-1&&s){let l=t.width,c=this.getTextWidth(i,t);return(l-(c-s*o))/s}}return o}countSpaces(r){return(r.match(/ /g)||[]).length}};function H_(n){if(n.length){let r=n[0];if(r instanceof wi.LineCurve)return r.v1;if(r instanceof wi.CubicBezierCurve||r instanceof wi.QuadraticBezierCurve)return r.v0}}var jd=class{constructor(){this.objects=new Map;this.unreachable=new Set}getCached(r){return this.objects.get(r)}get size(){return this.objects.size}get(r,e){let t=this.objects.get(r);return t===void 0?(t=this.createObject(r,e),this.objects.set(r,t)):t.isShared=!0,t}mutateIfUnique(r,e){let t=this.objects.get(r);if(t&&t.isShared!==!0)return this.objects.delete(r),this.objects.set(e,t),t}startGc(){this.unreachable=new Set(this.objects.keys())}markAsReachable(r,e){let t=this.objects.get(r);e===t?this.unreachable.delete(r):!1&&console.warn("Reachable but deleted",r)}endGc(){this.unreachable.forEach(r=>{this.disposeObject(this.objects.get(r)),this.objects.delete(r)}),this.unreachable.clear()}dispose(){this.objects.forEach(r=>{this.disposeObject(r)}),this.objects.clear()}},Fs=class extends jd{constructor(e){super();this.flatShading=e}disposeObject(e){e.dispose()}createObject(e,t){let o=$o(e,t,this.flatShading);return o.computeBoundingSphere(),o}};var dy={find(n){},markNeedsUpdateRendererDirty:function(){},markGeometryCacheDirty:function(){},addPendingExpandCloner:function(n){},addPendingUpdateCloner(n){},addPendingCommand(n){}};var Fd=class extends Ml{constructor(e){super();this.shared=e}create(e){return new bi(e,this.shared)}},en=class{constructor(r,e={}){this.geometryCache=new Fs(!0);this.geometryCache2=new Fs(!1);this.imageHolderCache=new Fd(this);this.thisContext={scene:dy,shared:this};this.deletedMaterial=new Qo(Dt.defaultTwoLayerData("phong"),this.thisContext);this.deletedImage=new tr(rl.emptyImage,this);this.deletedVideo=new tr(yn.defaultVideo,this);this.materials={};this.images={};this.videos={};this.colors={};this.audios={};this.fonts={};this.penumbraSize=[];this.requestRender=()=>{this._requestRender&&this._requestRender()};if(e.images)for(let[t,o]of Object.entries(e.images))this.addImage(t,o);if(e.videos)for(let[t,o]of Object.entries(e.videos))this.addVideo(t,o);if(e.audios)for(let[t,o]of Object.entries(e.audios))this.addAudio(t,o.data);this.reset(r)}setRequestRender(r){this._requestRender=r}reset(r){for(let[e,t]of Object.entries(r.images))this.addImage(e,t);for(let[e,t]of Object.entries(r.videos))this.addVideo(e,t);for(let[e,t]of Object.entries(r.colors))this.addColor(e,t);for(let[e,t]of Object.entries(r.materials))this.addMaterial(e,new Qo(t,this.thisContext));for(let[e,t]of Object.entries(r.audios))this.addAudio(e,t.data);for(let[e,t]of Object.entries(r.fonts))this.addFont(e,t);this.penumbraSize=r.penumbraSize}addMaterial(r,e){e.uuid=r,this.materials[r]=e}deleteMaterial(r){this.materials[r]&&(this.materials[r].nodeMaterialDispose(),delete this.materials[r])}getMaterial(r){let e=this.materials[r];return e}getMaterialOrDeletedPlaceholder(r){return this.materials[r]??this.deletedMaterial}material(r){return typeof r=="string"?this.getMaterialOrDeletedPlaceholder(r):new Si(r,this.thisContext)}getMaterials(){return this.materials}addImage(r,e){return this.images[r]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.images[r].updateSrc(e.data),!0):(this.images[r]=new tr(e,this),!1)}deleteImage(r){let e=this.images[r];e&&(e.dispose(),delete this.images[r])}getDefaultImage(){return this.images.image_0}getImage(r){return this.images[r]??this.deletedImage}image(r){return typeof r=="string"?this.getImage(r):this.imageHolderCache.load(r)}addVideo(r,e){return this.videos[r]?(this.videos[r].updateSrc(e.data),!0):(this.videos[r]=new tr(e,this),!1)}deleteVideo(r){let e=this.videos[r];e&&(e.dispose(),delete this.videos[r])}getVideo(r){return this.videos[r]??this.deletedVideo}video(r){return typeof r=="string"?this.getVideo(r):this.imageHolderCache.load(r)}addColor(r,e){return this.colors[r]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),"a"in e?this.colors[r].setRGBA(e.r,e.g,e.b,e.a):this.colors[r].setRGBA(e.r,e.g,e.b,1),!0):("a"in e?this.colors[r]=new Oo(e.r,e.g,e.b,e.a):this.colors[r]=new Oo(e.r,e.g,e.b,1),!1)}updateColor(r,e){if(this.colors[r]){this.onColorOrImageUpdate&&this.onColorOrImageUpdate();let t=this.colors[r];return this.colors[r].r=e.r??t.r,this.colors[r].g=e.g??t.g,this.colors[r].b=e.b??t.b,this.colors[r].a=e.a??t.a,!0}return!1}deleteColor(r){this.colors[r]&&delete this.colors[r]}getColor(r){return this.colors[r]}color(r){let e;if(typeof r=="string"){let t=this.getColor(r);t?e=t:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),e=new st(0,0,0,0))}else return"a"in r?new st(r.r,r.g,r.b,r.a):new st(r.r,r.g,r.b,1);return e}addAudio(r,e){this.audios[r]=e}getAudio(r){let e=this.audios[r];if(e instanceof Jo)return e;{let t=new Jo({src:e});return this.audios[r]=t,t}}deleteAudio(r){let e=this.audios[r];e&&(e instanceof Jo&&e.dispose(),delete this.audios[r])}addFont(r,e){this.fonts[r]=new Vl(e),this.fonts[r].loadingPromise.then(()=>this.requestRender())}getFont(r){return this.fonts[r]}deleteFont(r){this.fonts[r]&&delete this.fonts[r]}dispose(){Object.keys(this.materials).forEach(e=>this.deleteMaterial(e)),this._requestRender=void 0,Object.values(this.audios).forEach(e=>{e instanceof Jo&&e.dispose()}),this.audios={},this.geometryCache.dispose(),this.geometryCache2.dispose()}},uy=new en(Ca.emptyData());var br=class extends gt{updateByPatchedOp(e,t,o){if(super.updateByPatchedOp(e,t,o),au(e.path,["materials"])!==null&&e.type===0&&Array.isArray(this.material))for(let[i,s]of Object.entries(e.props)){let l=o.shared.material(s);this.material[Number(i)]=l}else if(ar(e.path,["material"])&&this.material instanceof Ut)"material"in t&&typeof t.material!="string"&&this.material.updateByOp(ht.drop(e,1),t.material,o);else if(ar(e.path,["materials","*"])&&Array.isArray(this.material)){let i=e.path[1];if("materials"in t&&i<this.material.length){let s=t.materials[i];typeof s!="string"&&this.material[i].updateByOp(ht.drop(e,2),s,o)}}}updateState(e,t){super.updateState(e,t),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=t.shared.material(e.material).getFlavor(o.flatShading,o.side,o.wireframe),t.scene?.markNeedsUpdateRendererDirty()),e.geometry?.type==="NonParametricGeometry"&&("materials"in e&&e.materials!==void 0?(this.disposeMaterial(),this.material=e.materials.map(i=>t.shared.material(i).getFlavor(o.flatShading,o.side,o.wireframe)),t.scene?.markNeedsUpdateRendererDirty()):"material"in e&&e.material!==void 0&&(this.disposeMaterial(),this.material=[t.shared.material(e.material).getFlavor(o.flatShading,o.side,o.wireframe)],t.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&&Ia(this.material).forEach(e=>{e instanceof Ut&&(e instanceof Qo||e.nodeMaterialDispose())})}dispose(){this.disposeMaterial(),super.dispose()}};var py=require("three");var bt=class extends br{constructor(e,t,o){super(e,t);this.data=t;this.localGeometry=void 0}chooseGeoemtryCache(e){return e.geometryCache}markGeometryAsReachable(e){this.geometryCreateDeleyed instanceof py.BufferGeometry&&this.chooseGeoemtryCache(e).markAsReachable(this.dataPatched.geometry,this.geometryCreateDeleyed)}get geometry(){if(this.localGeometry!==void 0)return this.localGeometry;if(this.geometryCreateDeleyed instanceof en){let e=this.geometryCreateDeleyed,t=this.chooseGeoemtryCache(e);this.geometryCreateDeleyed=t.get(this.dataPatched.geometry,e)}return this.geometryCreateDeleyed}set geometry(e){this.localGeometry=e}get is2DAndNoDepth(){let e=this.dataPatched.geometry;return Wi.is2DParametricMesh(e.type)&&e.depth===0}get is2DType(){return Wi.is2DParametricMesh(this.geometry.userData.type)}updateByPatchedOp(e,t,o){super.updateByPatchedOp(e,t,o),ar(e.path,["geometry"])&&this.updateByPatchedOpGeometry(ht.drop(e,1),t.geometry,o)}removeInteractionGeometry(){this.localGeometry?.dispose(),this.localGeometry=void 0}updateGeometryInteractions(e,t){this.invalidateDownstreamBooleanData();let o=this.data.geometry.type;if(o==="NonParametricGeometry"||o==="SubdivGeometry"){let i=e;if(this.localGeometry===void 0){let a={...this.data.geometry,...i};this.localGeometry=$o(a,t,this.data.flatShading)}let s,l,c;i.scaleBaked?[s,l,c]=i.scaleBaked:{width:s,height:l,depth:c}=i;let u=this.localGeometry.userData;u.sxPrev!==void 0&&us(this.localGeometry.attributes,s/u.sxPrev,l/u.syPrev,c/u.szPrev),u.sxPrev=s,u.syPrev=l,u.szPrev=c}else{let i={...this.data.geometry,...e};this.localGeometry?.dispose(),this.localGeometry=$o(i,t,this.data.flatShading)}}refreshAttachedCloners(e){for(let t of this.attachedSurfaceCloners)e.scene.addPendingUpdateCloner(t.object)}refreshAttachedPaths(e){for(let t of this.attachedPaths)e.scene.addPendingCommand(()=>t.updateShape())}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.refreshAttachedCloners(e),this.refreshAttachedPaths(e)}updateByPatchedOpGeometry(e,t,o){let i=!1;e.type===0&&e.path.length===0&&Ki(["scaleBaked"],Object.keys(e.props))&&this.geometryCreateDeleyed instanceof Je&&this.chooseGeoemtryCache(o.shared).mutateIfUnique(this.geometryCreateDeleyed.data,t)===this.geometryCreateDeleyed&&(i=!0,this.geometryCreateDeleyed.mutateDirectlyScaleBaked(t,e.props.scaleBaked),this.refreshAttachedCloners(o),this.refreshAttachedPaths(o)),i||(o.scene?.markGeometryCacheDirty(),this.createGeometryDelayed(o)),this.resetBBoxNeedsUpdate(),this.invalidateDownstreamBooleanData()}updateGeometryOnStateUpdate(e,t){this.createGeometryDelayed(t)}updateState(e,t){e.geometry!==void 0&&this.updateGeometryOnStateUpdate(e.geometry,t),super.updateState(e,t)}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,t){let o=this.geometry.userData.parameters;this.is2DType?e.set(0,0,o.depth*.5):e.setScalar(0),t.set(o.width,o.height,o.depth??0).multiplyScalar(.5)}};function W_(n){if(n.geometry.attributes.extrudeNormal||!n.geometry.attributes.position||!n.geometry.attributes.normal)return;let r=new Map,e=n.geometry.attributes,t=e.position.array,o=e.normal.array,i=new Float32Array(t.length);for(let s=0;s<t.length;s+=3){let l=`${t[s]}_${t[s+1]}_${t[s+2]}`,c=new Xt.Vector3(o[s],o[s+1],o[s+2]);r.has(l)?r.get(l)?.normals.push(c):r.set(l,{normals:[c],result:new Xt.Vector3})}r.forEach((s,l)=>{for(let c of s.normals)s.result.add(c);s.result.divideScalar(s.normals.length)});for(let s=0;s<t.length;s+=3){let l=`${t[s]}_${t[s+1]}_${t[s+2]}`,c=r.get(l)?.result;c&&(i[s]=c.x,i[s+1]=c.y,i[s+2]=c.z)}n.geometry.setAttribute("extrudeNormal",new Xt.Float32BufferAttribute(i,3))}function q_(n){if(n.geometry.attributes.extrudeNormals||!n.geometry.attributes.position)return;let e=n.geometry.attributes.position.array,t=new Float32Array(e.length),o=new Xt.Vector3;for(let i=0;i<e.length;i+=3)o.set(e[i],e[i+1],e[i+2]).normalize(),t[i]=o.x,t[i+1]=o.y,t[i+2]=o.z;n.geometry.setAttribute("extrudeNormal",new Xt.Float32BufferAttribute(t,3))}function _i(n){if(Array.isArray(n.material)){for(let r of n.material)if(r.getLayersOfType("outline").length===0)return}else if(!(n.material instanceof Ut)||n.material.getLayersOfType("outline").length===0)return;n instanceof bt&&n.is2DAndNoDepth?q_(n):W_(n)}function Ti(n){if(!n.geometry.attributes.position)return;let e=n.geometry.attributes.position.array,t=new Float32Array(e.length),o=parseInt(n.uuid.replace(/\D/g,"")),i=[Xt.MathUtils.seededRandom(o),Xt.MathUtils.seededRandom(o+1e4),Xt.MathUtils.seededRandom(o+2e4)];for(let s=0;s<e.length;s++)t[s]=i[s%3];n.geometry.setAttribute("randomColor",new Xt.BufferAttribute(t,3))}var $_;li.then(n=>{$_=n});var jr=new ro.Box3,zs=new ro.Vector3;function fy(n){let r=!1;return n.scene.objects.traverse((e,t)=>{t.type==="Mesh"&&t.geometry.type==="SubdivGeometry"&&(r=!0)}),r}var tn=class extends bt{constructor(e,t,o){super(e,t,o);this.data=t;this.hiddenMatrixOld=new ro.Matrix4;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,t){let o=this.geometry.userData.parameters;e.copy(this.originalGeometryNew.boundingSphere.center),t.set(o.width,o.height,o.depth??0).multiplyScalar(.5)}createGeometryByControls(e){if(this.skipReactionUpdate===!0)return;let t=this.localGeometry?.uuid,{originalGeometry:o,subdividedGeometry:i,subdivPointer:s}=Je.build(e,this.subdivPointer,this.smoothShading,this.hasNonUniformScale?this.shearScale:void 0);this.subdivPointer=s,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,_i(this),Ti(this),this.calcBoundingBox(),t&&(this.localGeometry.uuid=t)}updateState(e,t){if(super.updateState(e,t),e.flatShading!==void 0){let o=this.material;this.material=o.getFlavor(!1,o.side,o.wireframe),this.smoothShading=!e.flatShading,this.createGeometryDelayed(t)}}updateMesh(e=!1){Je.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1,this.originalGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0),this.subdividedGeometry&&Je.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1,this.subdividedGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0)}updateTopology(){this.originalGeometry.dispose(),this.originalGeometry=Je.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=Je.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1)),this.localGeometry=this.subdividedGeometry??this.originalGeometry}raycast(e,t){let o=this.localGeometry;this.localGeometry=this.originalGeometryNew,gt.prototype.raycast.call(this,e,t),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 ro.Sphere,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,o=e.boundingSphere.center;jr.setFromBufferAttribute(t),jr.getCenter(o),e.boundingSphere.radius=o.distanceTo(jr.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),jr.getSize(zs),this.hasNonUniformScale&&zs.divide(this.scale);let i={width:zs.x,height:zs.y,depth:zs.z};return this.geometry.userData.parameters=i,i}updateBoundingSphere(e){let t=this.originalGeometry;jr.min.set(e[0],e[2],e[4]),jr.max.set(e[1],e[3],e[5]),this.hasNonUniformScale&&(jr.min.applyMatrix4(this.shearScaleInv),jr.max.applyMatrix4(this.shearScaleInv)),t.boundingSphere===null&&(t.boundingSphere=new ro.Sphere);let o=t.boundingSphere.center;jr.getCenter(o),t.boundingSphere.radius=o.distanceTo(jr.max)}freeSubdivPointer(){this.subdivPointer&&(Je.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0),this.localGeometry=void 0,this.originalGeometry?.dispose(),this.subdividedGeometry?.dispose()}dispose(){super.dispose(),this.freeSubdivPointer()}updateByPatchedOpGeometry(e,t,o){super.updateByPatchedOpGeometry(e,t,o),this.localGeometry&&this.createGeometryByControls(t)}};var Fr=require("three"),my=-1,Y_=1,hy={x:[1,0,0],"-x":[-1,0,0],y:[0,1,0],"-y":[0,-1,0],z:[0,0,1],"-z":[0,0,-1]},yy={polygon_center:0,edge:1,vertex:2},Us=(n,r)=>(e,t)=>!r||e===0||n===0?0:n*t/100,he=(n,r)=>{let e=Math.abs(r),t=e*-1;return(n-my)*(e-t)/(Y_-my)+t};function gy(n){let r=[],e={};for(var t=0,o=n.length;t<o;t++){var i=JSON.stringify(n[t].pos.map(s=>Math.round(s*1e4)/1e4));e[i]||(r.push(n[t]),e[i]=!0)}return r}var X_=new Fr.Vector3,jl=new Fr.Vector3,K_=new Fr.Vector3,Z_=new Fr.Vector3;function Pi(n,r){let e=K_.fromArray(n),t=Z_.fromArray(r);jl.copy(t).sub(e);let o=jl.length();return jl.normalize().multiplyScalar(o*.5),X_.copy(e).add(jl).toArray()}var rr=new Fr.Triangle,Fl=new Fr.Vector3,zl=new Fr.Vector3,rn=new Fr.Vector3;function xy(n){let r=[];for(let e=0;e<=n.index.count;e++)if(Fl.fromArray(n.index.array,e*3),rr.setFromAttributeAndIndices(n.attributes.position,Fl.x,Fl.y,Fl.z),rr.getNormal(zl),rr.getMidpoint(rn),!(isNaN(rn.x)||isNaN(rn.y)||isNaN(rn.z))){let{a:t,b:o,c:i}=rr,s=t.toArray(),l=o.toArray(),c=i.toArray(),u=t.distanceTo(o),a=o.distanceTo(i),d=i.distanceTo(t),p=Pi(s,l),f=Pi(l,c),m=Pi(c,s),h=[u,a,d],y=Math.max(...h),g=h.filter(S=>Math.round(S)===Math.round(y)).length>1,v=[],w=rr.getMidpoint(rn).toArray();y===u&&!g&&(v=[f,m,m],w=p),y===a&&!g&&(v=[p,m,m],w=f),y===d&&!g&&(v=[p,f,f],w=m),g&&(v=[p,f,m]),r.push({vertices:[s,l,c],faceCenters:v,midpoint:w,norm:rr.getNormal(zl).toArray()})}return r}function vy(n){let r=[],{position:e}=n.attributes;for(let t=0;t<e.count;t++){rr.setFromAttributeAndIndices(e,t*3,t*3+1,t*3+2),rr.getNormal(zl),rr.getMidpoint(rn);let o=rr.a.toArray(),i=rr.b.toArray(),s=rr.c.toArray();r.push({vertices:[o,i,s],faceCenters:[Pi(o,i),Pi(i,s),Pi(s,o)],midpoint:rn.toArray(),norm:zl.toArray()})}return r}var Q_=4,J_=.5,zd=n=>.5*(1-Math.cos(n*Math.PI)),Ud=class{constructor(){this.perlin=new Array(4095+1)}noise(r,e=0,t=0){if(this.perlin==null){this.perlin=new Array(4095+1);for(let g=0;g<4095+1;g++)this.perlin[g]=Math.random()}r<0&&(r=-r),e<0&&(e=-e),t<0&&(t=-t);let o=Math.floor(r),i=Math.floor(e),s=Math.floor(t),l=r-o,c=e-i,u=t-s,a,d,p=0,f=.5,m,h,y;for(let g=0;g<Q_;g++){let v=o+(i<<4)+(s<<8);a=zd(l),d=zd(c),m=this.perlin[v&4095],m+=a*(this.perlin[v+1&4095]-m),h=this.perlin[v+16&4095],h+=a*(this.perlin[v+16+1&4095]-h),m+=d*(h-m),v+=256,h=this.perlin[v&4095],h+=a*(this.perlin[v+1&4095]-h),y=this.perlin[v+16&4095],y+=a*(this.perlin[v+16+1&4095]-y),h+=d*(y-h),m+=zd(u)*(h-m),p+=m*f,f*=J_,o<<=1,l*=2,i<<=1,c*=2,s<<=1,u*=2,l>=1&&(o++,l--),c>=1&&(i++,c--),u>=1&&(s++,u--)}return p}noiseSeed(r){let e=(()=>{let s,l;return{setSeed(c){l=s=(c??Math.random()*4294967296)>>>0},getSeed(){return s},rand(){return l=(1664525*l+1013904223)%4294967296,l/4294967296}}})();e.setSeed(r),this.perlin=new Array(4095+1);for(let t=0;t<4095+1;t++)this.perlin[t]=e.rand()}},by=Ud;var Ai=require("three");var Sy=new Ai.Vector3,wy=new Ai.Matrix4,_y=new Ai.Ray;function Ty(n){let r=!1;return n.scene.objects.traverse((e,t)=>{t.type==="Mesh"&&t.geometry.type==="TextGeometry"&&(r=!0)}),r}var Oi=class extends bt{constructor(e,t,o){super(e,t,o);this.data=t}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,t){let{matrixWorld:o}=this;if(!(isNaN(e.ray.origin.x)||this.scale.x===0||this.scale.y===0||this.scale.z===0)&&(wy.copy(o).invert(),_y.copy(e.ray).applyMatrix4(wy),_y.intersectBox(this.singleBBox,Sy))){let i=Sy.applyMatrix4(o),s=e.ray.origin.distanceTo(i);t.push({distance:s,point:i.clone(),object:this})}}};var Ct=1e-4,zr,Ay,Iy,Cy,Py=new Ce.Vector3,Oy=new Ce.Vector3;li.then(n=>{zr=n,Ay=[zr.get_face_center,zr.get_edge_midpoint,zr.get_vertex_position],Iy=[zr.get_face_normal,zr.get_edge_normal,zr.get_vertex_normal],Cy=[zr.face_count,zr.edge_count,zr.vertex_count]});var eT=new Ce.Matrix4,tT=new Ce.Matrix4,Io=new Ce.Vector3,on=new Ce.Vector3,ks=new Ce.Vector3,kd=new Ce.Vector3,rT=new Ce.Vector3,oT=new Ce.Vector3;var oo=new by,Ci=class extends qn(Ce.Object3D){constructor(e,t){super();this.parameters=t;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 t of this.children)t instanceof Qr&&t.expand()}invalidateTransform(e){this.matrixWorldNeedsUpdate=!0,this.traverse(t=>{t instanceof Qr&&t.object===e&&(t.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 t;if(e!==void 0?t=e:t=this.parameters.type==="grid"?this.parameters.grid.count[0]*this.parameters.grid.count[1]*this.parameters.grid.count[2]:this.parameters.count,this.parameters.type==="toObject"&&!this.parameters.toObject.object&&(t=0),this.parameters.type==="toObject"&&this.objectForSample){for(let i=0,s=this.children.length;i<s;++i)this.remove(this.children[0]);let o=this.children;if(o.length===t)return;if(o.length<t)for(let i=0,s=t-o.length;i<s;++i){let l=new Qr(this.object);l.expand(),this.add(l)}else for(let i=0,s=o.length-t;i<s;++i)this.remove(o[i])}else{if(this.children.length===t)return;if(this.children.length<t)for(let o=0,i=t-this.children.length;o<i;++o){let s=new Qr(this.object);s.expand(),this.add(s)}else for(let o=0,i=this.children.length-t;o<i;++o)this.remove(this.children[0])}}_updateRadial(e){let t=e.radial,o=t.start*Ce.MathUtils.DEG2RAD,i=t.end*Ce.MathUtils.DEG2RAD,s=o-i,l=new Ce.Euler(t.rotation[0],t.rotation[1],t.rotation[2]),c;switch(t.axis){case"z":c=new Ce.Vector3(0,0,1);break;case"y":c=new Ce.Vector3(0,1,0);break;default:case"x":c=new Ce.Vector3(1,0,0);break}let u=e.randomnessObject??Ir.defaultData([1,1,1]).randomnessObject,a=u.noiseType==="perlin";oo.noiseSeed(u.seed);let d=ol((0,Ii.default)(u.seed)),p=Us(u.strength,this.parameters.randomness);for(let[f,m]of this.children.entries()){let h=f*(u.freqScale/10)+u.movement,y=a?oo.noise(h):d(h,h);m.scale.x=t.scale[0]+p(f,he(y,u.scale[0]))||Ct,m.scale.y=t.scale[1]+p(f,he(y,u.scale[1]))||Ct,m.scale.z=t.scale[2]+p(f,he(y,u.scale[2]))||Ct,m.position.setScalar(0);let g=s/e.count*f-o;switch(t.axis){case"x":m.rotation.set(0,g,0);break;case"y":m.rotation.set(0,0,g);break;case"z":m.rotation.set(g,0,0);break}m.translateOnAxis(c,t.radius),m.position.x+=t.position[0]+p(f,he(y,u.position[0])),m.position.y+=t.position[1]+p(f,he(y,u.position[1])),m.position.z+=t.position[2]+p(f,he(y,u.position[2]));let v=p(f,he(y,u.rotation[0])),w=p(f,he(y,u.rotation[1])),S=p(f,he(y,u.rotation[2]));t.alignment===!0?(m.rotation.x+=l.x+v,m.rotation.y+=l.y+w,m.rotation.z+=l.z+S):m.rotation.set(l.x+v,l.y+w,l.z+S)}}_updateLinear(e){if(e.type!=="linear")throw new Error;let t=e.linear,o=new Ce.Euler(t.rotation[0],t.rotation[1],t.rotation[2]),i=e.randomnessObject??Ir.defaultData([1,1,1]).randomnessObject,s=i.noiseType==="perlin";oo.noiseSeed(i.seed);let l=ol((0,Ii.default)(i.seed)),c=Us(i.strength,this.parameters.randomness);for(let[u,a]of this.children.entries()){let d=u*(i.freqScale/10)+i.movement,p=s?oo.noise(d):l(d,d),f=c(u,he(p,i.rotation[0])),m=c(u,he(p,i.rotation[1])),h=c(u,he(p,i.rotation[2]));a.scale.x=1+(t.scale[0]-1)*u+c(u,he(p,i.scale[0]))||Ct,a.scale.y=1+(t.scale[1]-1)*u+c(u,he(p,i.scale[1]))||Ct,a.scale.z=1+(t.scale[2]-1)*u+c(u,he(p,i.scale[2]))||Ct,a.rotation.x=o.x*u+f,a.rotation.y=o.y*u+m,a.rotation.z=o.z*u+h,a.position.x=t.position[0]*u+c(u,he(p,i.position[0])),a.position.y=t.position[1]*u+c(u,he(p,i.position[1])),a.position.z=t.position[2]*u+c(u,he(p,i.position[2]))}}_updateGrid(e){let t=0,o=e.grid,i=e.randomnessObject??Ir.defaultData([1,1,1]).randomnessObject,s=Us(i.strength,this.parameters.randomness),l=i.noiseType==="perlin";oo.noiseSeed(i.seed);let c=wm((0,Ii.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},a=new Ce.Vector3(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 m=[(d+1)*(i.freqScale/10)+i.movement,(p+1)*(i.freqScale/10)+i.movement,(f+1)*(i.freqScale/10)+i.movement],h=l?oo.noise(...m):c(...m),y=this.children[t++];y.scale.x=1+s(t,he(h,i.scale[0]))||Ct,y.scale.y=1+s(t,he(h,i.scale[1]))||Ct,y.scale.z=1+s(t,he(h,i.scale[2]))||Ct;let g=s(t,he(h,i.rotation[0])),v=s(t,he(h,i.rotation[1])),w=s(t,he(h,i.rotation[2]));y.rotation.set(g,v,w),y.position.x=o.size[0]*d-a.x+s(t,he(h,i.position[0])),y.position.y=o.size[1]*p-a.y+s(t,he(h,i.position[1])),y.position.z=o.size[2]*f-a.z+s(t,he(h,i.position[2]))}}else for(let u=0;u<o.count[0];u++)for(let a=0;a<o.count[1];a++)for(let d=0;d<o.count[2];d++){let p=[(u+1)*(i.freqScale/10)+i.movement,(a+1)*(i.freqScale/10)+i.movement,(d+1)*(i.freqScale/10)+i.movement],f=l?oo.noise(...p):c(...p),m=this.children[t++];m.scale.x=1+s(t,he(f,i.scale[0]))||Ct,m.scale.y=1+s(t,he(f,i.scale[1]))||Ct,m.scale.z=1+s(t,he(f,i.scale[2]))||Ct;let h=s(t,he(f,i.rotation[0])),y=s(t,he(f,i.rotation[1])),g=s(t,he(f,i.rotation[2]));m.rotation.set(h,y,g),m.position.x=o.size[0]*u+s(t,he(f,i.position[0])),m.position.y=-o.size[1]*a+s(t,he(f,i.position[1])),m.position.z=-o.size[2]*d+s(t,he(f,i.position[2]))}}_updateToObject(e){if(e.type!=="toObject")throw new Error;let{toObject:t}=e,o=new Ce.Euler(t.rotation[0],t.rotation[1],t.rotation[2]),i=e.randomnessObject??Ir.defaultData([1,1,1]).randomnessObject,s=i.noiseType==="perlin";oo.noiseSeed(i.seed);let l=ol((0,Ii.default)(i.seed)),c=Us(i.strength,this.parameters.randomness);if(!t.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 Oi)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.object.parent===this.objectForSample){console.warn(`Oh no! The object "${this.object.name}" (${this.object.uuid}) seem to be a child of the object it's being cloned to. Please re-parent it so that they are siblings instead.`);return}let u=this.getSubdivData(),a=[],d=g=>{let v=g.length,w=g.map(T=>T[0]).reduce((T,_)=>T+_,0),S=g.map(T=>T[1]).reduce((T,_)=>T+_,0),b=g.map(T=>T[2]).reduce((T,_)=>T+_,0);return[w/v,S/v,b/v]},p=g=>Math.round(g*1e6)/1e6;u.forEach(g=>{let v=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]));v.length>1?a.push({pos:g.pos,norm:d(v.map(w=>w.norm))}):a.push(g)});let f=gy(a);if(u.length>0){let g=Math.round(f.length*t.count/100);this._updateCount(g)}this.objectForSample.updateMatrixWorld();let m=new nl(this.objectForSample).build(),h=hy[t.axis],y=this.children;m.setRandomGenerator((0,Ii.default)(this.object.uuid+t.seed));for(let[g,v]of y.entries()){let w=g*(i.freqScale/10)+i.movement,S=s?oo.noise(w):l(w,w),b=c(g,he(S,i.rotation[0])),T=c(g,he(S,i.rotation[1])),_=c(g,he(S,i.rotation[2]));t.spreadType==="random"?m.sample(ks,kd):(f.length&&(ks.fromArray(f[g].pos),kd.fromArray(f[g].norm)),this.objectForSample instanceof tn&&ks.applyMatrix4(eT.copy(this.objectForSample.matrixWorld).invert())),ks.applyMatrix4(this.object.hiddenMatrix.clone().invert()),v.position.copy(ks),Io.fromArray(h);let x=t.align==="normal"?kd:this.object.getWorldDirection(oT),C=on.fromArray(t.position);on.x+=on.x+c(g,he(S,i.position[0])),on.y+=on.y+c(g,he(S,i.position[1])),on.z+=on.z+c(g,he(S,i.position[2]));let P=Math.acos(x.dot(Io)),I=rT.crossVectors(Io,x).normalize(),A=tT.makeRotationAxis(I,P),O=x.clone().cross(this.object.up).normalize(),V=O.clone().cross(x).normalize(),z=new Ce.Matrix4().makeBasis(O,x,V),$=new Ce.Vector3(Io.y,Io.z,Io.x).normalize(),te=$.clone().cross(Io).normalize(),K=new Ce.Matrix4().makeBasis($,Io,te).invert(),q=new Ce.Matrix4().multiplyMatrices(z,K);v.rotation.setFromRotationMatrix(q),C.applyMatrix4(A),v.position.add(C),v.rotation.x=v.rotation.x+o.x+b,v.rotation.y=v.rotation.y+o.y+T,v.rotation.z=v.rotation.z+o.z+_,v.scale.setScalar(1),v.scale.x=v.scale.x+t.scale[0]+c(g,he(S,i.scale[0]))||Ct,v.scale.y=v.scale.y+t.scale[1]+c(g,he(S,i.scale[1]))||Ct,v.scale.z=v.scale.z+t.scale[2]+c(g,he(S,i.scale[2]))||Ct,v.scale.multiply(this.object.scale),v.hiddenMatrix=this.object.hiddenMatrix}}getSubdivData(){if(!this.objectForSample)return[];let e=this.parameters.toObject.spreadType;if(e==="random")return[];if(this.objectForSample instanceof tn){let t=this.objectForSample,o=yy[e],i=Cy[o],s=Ay[o],l=Iy[o],c=[],u=i(t.subdivPointerNew);for(let a=0;a<=u-1;a++){let d=s(t.subdivPointerNew,a),p=l(t.subdivPointerNew,a);Py.fromArray(d).applyMatrix4(t.matrixWorld),Oy.fromArray(p),c.push({pos:Py.toArray(),norm:Oy.toArray()})}return c}else return(this.objectForSample.geometry.index?xy(this.objectForSample.geometry):vy(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,t){if(this.parameters=Zr(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=t.find(this.parameters.toObject.object);o instanceof gt?this.objectForSample=o:this.objectForSample=void 0,this.matrix=new Ce.Matrix4,this.hiddenMatrix=new Ce.Matrix4,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1,o&&o.add(this)}this.update()}get pendingMediaLoad(){return this._pendingMediaLoad}};var sr=require("three");var ze=require("three");var St=require("three");var Ny=require("three"),Ur=n=>{var r;return r=class extends n{},r.geometryHelper=new Ny.BoxGeometry(30,30,30),r};var _t=require("three"),Ul=new _t.Ray,Hd=new _t.Sphere,Ey=new _t.Matrix4,kr=(n,r,e,t,o=!1)=>{let i=r,s=n.matrixWorld;if(i.boundingSphere===null&&i.computeBoundingSphere(),Hd.copy(i.boundingSphere),Hd.applyMatrix4(s),e.ray.intersectsSphere(Hd)===!1||(Ey.copy(s).invert(),Ul.copy(e.ray).applyMatrix4(Ey),i.boundingBox!==null&&Ul.intersectsBox(i.boundingBox)===!1))return;let l,c,u,a,d=i.index,p=i.attributes.position,f=i.drawRange,m,h;if(o===!1){let g=Math.max(0,f.start),v=Math.min(d.count,f.start+f.count);for(m=g,h=v;m<h;m+=3)if(c=d.getX(m),u=d.getX(m+1),a=d.getX(m+2),l=y(n,e,Ul,p,c,u,a),l){l.faceIndex=Math.floor(m/3),t.push(l);return}}else{let v=i.attributes.position,w=new _t.Vector3,S=new _t.Vector3,b=new _t.Vector3,T=new _t.Vector3,_=2,C=1/((n.scale.x+n.scale.y+n.scale.z)/3),P=C*C,I=Math.max(0,f.start),A=Math.min(v.count,f.start+f.count);for(let O=I,V=A-1;O<V;O+=_){if(w.fromBufferAttribute(v,O),S.fromBufferAttribute(v,O+1),Ul.distanceSqToSegment(w,S,T,b)>P)continue;T.applyMatrix4(n.matrixWorld);let $=e.ray.origin.distanceTo(T);$<e.near||$>e.far||t.push({distance:$,point:b.clone().applyMatrix4(n.matrixWorld),object:n})}}function y(g,v,w,S,b,T,_){let x=new _t.Vector3,C=new _t.Vector3,P=new _t.Vector3,I=new _t.Vector3,A=new _t.Vector3;if(x.fromBufferAttribute(S,b),C.fromBufferAttribute(S,T),P.fromBufferAttribute(S,_),w.intersectTriangle(x,C,P,!1,I)===null)return null;A.copy(I),A.applyMatrix4(g.matrixWorld);let V=v.ray.origin.distanceTo(A);return V<v.near||V>v.far?null:{faceIndex:1,distance:V,point:A.clone(),object:g}}};var kl=new St.Vector3,or=new St.Camera,Wd=class extends St.LineSegments{constructor(e){let t=new St.BufferGeometry,o=new St.LineBasicMaterial({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],s=[],l={},c=new St.Color(15711266),u=new St.Color(15711266),a=new St.Color(2857471);d("n1","n2",c),d("n2","n4",c),d("n4","n3",c),d("n3","n1",c),d("f1","f2",c),d("f2","f4",c),d("f4","f3",c),d("f3","f1",c),d("n1","f1",c),d("n2","f2",c),d("n3","f3",c),d("n4","f4",c),d("p","n1",u),d("p","n2",u),d("p","n3",u),d("p","n4",u),d("u1","u2",a),d("u2","u3",a),d("u3","u1",a);function d(f,m,h){p(f,h),p(m,h)}function p(f,m){i.push(0,0,0),s.push(m.r,m.g,m.b),l[f]===void 0&&(l[f]=[]),l[f].push(i.length/3-1)}t.setAttribute("position",new St.Float32BufferAttribute(i,3)),t.setAttribute("color",new St.Float32BufferAttribute(s,3));super(t,o);this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=l,this.update()}update(){let e=this.geometry,t=this.pointMap,o=!0;or.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let i=1,s=1,l=o?.8:1e-4;Sr("n1",t,e,or,-i,-s,l),Sr("n2",t,e,or,i,-s,l),Sr("n3",t,e,or,-i,s,l),Sr("n4",t,e,or,i,s,l);let c=l;Sr("f1",t,e,or,-i,-s,c),Sr("f2",t,e,or,i,-s,c),Sr("f3",t,e,or,-i,s,c),Sr("f4",t,e,or,i,s,c);let u=c,a=.5;Sr("u1",t,e,or,i*.7*a,s*1.1,u),Sr("u2",t,e,or,-i*.7*a,s*1.1,u),Sr("u3",t,e,or,0,s*(1.1+.9*a),u),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function Sr(n,r,e,t,o,i,s){kl.set(o,i,s).unproject(t);let l=r[n];if(l!==void 0){let c=e.getAttribute("position");for(let u=0,a=l.length;u<a;u++)c.setXYZ(l[u],kl.x,kl.y,kl.z)}}var Hl=class extends Ur(Wd){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,t){kr(this.object,this.geometry,e,t,!0)}};var Hs=require("three");var Wl;(r=>r.is=e=>"objectHelper"in e)(Wl||(Wl={}));var Co=(n,r)=>class extends al(n){constructor(){super(...arguments);this.objectHelper=new r(this);this.gizmos={}}get geometryHelper(){return r.geometryHelper}raycast(o,i){this.objectHelper.raycast(o,i)}showGizmos(){for(let o in this.gizmos){let i=this.gizmos[o];i instanceof Hs.Box3Helper&&(i.visible=!0)}}updateEntityBoxSize(o,i){this.objectHelper.visible&&this.geometryHelper instanceof Hs.BoxGeometry?(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 Hs.Box3Helper&&(i.visible=!1)}}};var qd=790,Ni=new ze.Vector3,$d=new ze.Vector3,no=class extends Co(ze.Camera,Hl){constructor(e="",t={...bn.defaultData,name:""}){super();this._cameraType="OrthographicCamera";this.targetOffset=Do.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.super_Entity(e,t),this.matrixAutoUpdate=!0,this.width=window.innerWidth,this.height=window.innerHeight;let o=this.width,i=this.height;if(t.orthographic.autoZoom){let s=t.orthographic.autoZoomFrustumSize??qd,l=o/i,c=o>i?l:1,u=o>i?1:l;this.orthoCamera=new ze.OrthographicCamera(-s*.5*c,s*.5*c,s*.5*(1/u),-s*.5*(1/u),-5e4,1e4)}else this.orthoCamera=new ze.OrthographicCamera(o*-.5,o*.5,i*.5,i*-.5,-5e4,1e4);this.perspCamera=new ze.PerspectiveCamera(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,t){e==="PerspectiveCamera"?this.perspCamera.near=t:this.orthoCamera.near=t}setZoom(e,t){t>=0&&(e==="PerspectiveCamera"?this.perspCamera.zoom=t:this.orthoCamera.zoom=t)}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,t,o){typeof e=="number"&&(e=new ze.Vector3(e,t,o)),super.lookAt(e),this.getWorldPosition(Ni),this.targetOffset=Ni.distanceTo(e)}getTarget(e=new ze.Vector3){return this.getWorldDirection($d),this.getWorldPosition(Ni),$d.multiplyScalar(this.targetOffset),e.copy(Ni).add($d),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(Ni),Ni.distanceTo(e)}updateUp(){let e=this.getWorldQuaternion(new ze.Quaternion),t=new ze.Vector3(0,0,1).applyQuaternion(e),o=new ze.Vector3().copy(ze.Object3D.DEFAULT_UP);this.isUpVectorFlipped&&o.negate(),o.applyQuaternion(e);let i=new ze.Vector3().copy(ze.Object3D.DEFAULT_UP).projectOnPlane(t),s=new ze.Vector3().crossVectors(i,o).dot(t)>=0?1:-1;this.angleOffsetFromUp=i.angleTo(o)*s}updateTransformState(e){let t=super.updateTransformState(e);return e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateUp(),t}getViewFrontToObject(e){let t=e.getWorldPosition(new ze.Vector3),i=e.getWorldDirection(new ze.Vector3).multiplyScalar(this.targetOffset);return{position:t.clone().add(i),target:t}}getViewToObject(e){let t=e.getWorldPosition(new ze.Vector3),i=this.getWorldDirection(new ze.Vector3).multiplyScalar(this.targetOffset);return{position:t.clone().sub(i),target:t}}setViewplaneSize(e,t){if(this.aspect=e/t,this.data.type==="OrthographicCamera"&&this.data.orthographic.autoZoom){let o=this.data.orthographic.autoZoomFrustumSize??qd,i=e>t?this.aspect:1,s=e>t?1:this.aspect;this.left=-o*.5*i,this.right=o*.5*i,this.top=o*.5*(1/s),this.bottom=-o*.5*(1/s)}else this.left=-e*.5,this.right=e*.5,this.top=t*.5,this.bottom=-t*.5;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,t,o,i,s,l){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(e,t,o,i,s,l):this.orthoCamera.setViewOffset(e,t,o,i,s,l)}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}updateProjectionMatrix(){this._cameraType==="PerspectiveCamera"?this.toPerspective():this._cameraType==="OrthographicCamera"&&this.toOrthographic()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(e,t){return super.copy(e,t),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 t={type:this.cameraType,far:this.far,orthographic:{near:this.orthoCamera.near,zoom:this.orthoCamera.zoom,autoZoom:!0,autoZoomFrustumSize:qd},perspective:{near:this.perspCamera.near,fov:this.perspCamera.fov,zoom:this.perspCamera.zoom},up:this.up.toArray(),targetOffset:this.targetOffset,isUpVectorFlipped:this.isUpVectorFlipped};return Hn(t,e)}updateCameraSubtype(e,t){let o=e==="perspective"?"PerspectiveCamera":"OrthographicCamera";t.zoom!==void 0&&this.setZoom(o,t.zoom),t.near!==void 0&&this.setNear(o,t.near),t.fov!==void 0&&o==="PerspectiveCamera"&&(this.fov=t.fov)}updateState(e,t){this.updateCameraState(e,t)}updateCameraState(e,t){this.updateState_Entity(e,t),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,t,o){super.updateByPatchedOp(e,t,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}}};var nn=require("three");var My=new nn.Matrix4;var nr=class extends br{constructor(e,t,o){super(e,t);this.data=t;this.meshSetAddresses=[];this.needsTransformForDownstream=!1;this.geometry=new nn.BufferGeometry;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,t,o){super.updateByPatchedOp(e,t,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,t=!0){if(this.booleanMeshSetAddress!==-1&&!e)return;for(let i=0;i<this.children.length;i++){let s=this.children[i];s instanceof nr&&s.recomputeBoolean(e===!0,t)}this.meshSetAddresses=[];for(let i=0;i<this.children.length;i++){let s=this.children[i];if(s instanceof gt&&s.dataPatched.visible===!0&&s.geometry.attributes.position?.count>0&&s.geometry.drawRange.count>0){if(s.booleanMeshSetAddress===-1){if((s.geometry.index??s.geometry.getAttribute("position")).count/3<15e5&&(s.booleanMeshSetAddress=hr.getMeshSet(s.geometry,e===!0,t)),s.booleanMeshSetAddress===-1)return;hr.transformMeshSet(s.booleanMeshSetAddress,s.matrix),s.booleanMatrixInvOld.copy(s.matrix).invert(),s.booleanWasTransformed=!1}else s instanceof nr&&s.needsTransformForDownstream===!0?(hr.transformMeshSet(s.booleanMeshSetAddress,s.matrix),s.needsTransformForDownstream=!1):s.booleanWasTransformed===!0&&(My.multiplyMatrices(s.matrix,s.booleanMatrixInvOld),hr.transformMeshSet(s.booleanMeshSetAddress,My),s.booleanMatrixInvOld.copy(s.matrix).invert(),s.booleanWasTransformed=!1);this.meshSetAddresses.push(s.booleanMeshSetAddress)}}if(this.meshSetAddresses.length===0){this.geometry.setAttribute("position",new nn.Float16BufferAttribute([],0)),this.geometry.setDrawRange(0,0);return}if(e===!0)return hr.calcBooleanTopological(this.meshSetAddresses,this.booleanOp);let o=this.geometry;o.dispose(),this.geometry=new nn.BufferGeometry,this.geometry.userData=o.userData,this.geometry.boundingSphere=o.boundingSphere;try{this.booleanMeshSetAddress=hr.calcBoolean(this.meshSetAddresses,this.booleanOp,this.geometry,this.phongAngle)}catch(i){this.booleanMeshSetAddress=0,console.error(i)}this.booleanMatrixInvOld.copy(this.matrix).invert(),this.needsTransformForDownstream=!0,_i(this),Ti(this)}dispose(){super.dispose(),this.geometry.dispose()}};var By=require("three");var Ly;(r=>{function n(e){return He.is(e)&&e instanceof By.Light}r.is=n})(Ly||(Ly={}));var Ei=(n,r)=>class extends Co(n,r){updateState_Light(t,o){this.updateState_Entity(t,o),t.color!==void 0&&(this.color=o.shared.color(t.color)),t.intensity!==void 0&&(this.intensity=t.intensity),t.depth!==void 0&&(this.shadow.camera.far=t.depth,this.shadow.needsUpdate=!0),t.shadows!==void 0&&(this.castShadow=t.shadows)}};var Ws=n=>n instanceof gt,qs=n=>n!==null&&n instanceof nr,Dy=n=>n instanceof no;var Gy=n=>Wl.is(n);var Vy=require("three");var Ry=require("three");var No=class extends Ur(Ry.AxesHelper){constructor(e,t=15){super(t);this.object=e;this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${e.uuid}`,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}raycast(e,t){kr(this.object,No.geometryHelper,e,t)}update(){}};var $s=class extends Co(Vy.Group,No){constructor(r,e){super(),this.super_Entity(r,e),this.objectHelper.update()}updateState(r,e){this.updateState_Entity(r,e)}};var Xs=require("three");var jy=require("three");var Mi=class extends Ur(jy.DirectionalLightHelper){constructor(e,t=15,o=10066329){super(e,t,o);this.object=e;this.added=!1;this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,t){kr(this.object,Mi.geometryHelper,e,t)}};var Fy=require("three");var Li=class extends Ur(Fy.PointLightHelper){constructor(e,t=15,o=6710886){super(e,t,o);this.object=e;this.name=`PointLightHelper: ${e.uuid}`}raycast(e,t){kr(this.object,Li.geometryHelper,e,t)}};var $l=require("three");var ql=class extends Ur($l.SpotLightHelper){constructor(e,t=6710886){super(e,t);this.object=e;this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,t){kr(this.object,ql.geometryHelper,e,t)}update(){if(this.object!==void 0){let e=ql._vector,t=this.object.distance?this.object.distance:1e3,o=t*Math.tan(this.object.angle);this.cone.scale.set(o,o,t),e.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(e);let i=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let s=0,l=this.cone.material.length;s<l;s++)this.cone.material[s].color.set(i);else this.cone.material.color.set(i)}}},Ys=ql;Ys._vector=new $l.Vector3;function iT(n,r){n.shadow.camera.right=r/2,n.shadow.camera.left=-r/2,n.shadow.camera.top=r/2,n.shadow.camera.bottom=-r/2,n.shadow.needsUpdate=!0}var Yl=class extends Ei(Xs.DirectionalLight,Mi){constructor(r,e,t){super(),this.super_Entity(r,e),this.castShadow=!0,this.shadow.mapSize.width=2048,this.shadow.mapSize.height=2048,this.shadow.normalBias=1,this.layers.enable(3);let i=this.shadow.camera;i.top=1250,i.bottom=-1250,i.right=1250,i.left=-1250,i.near=-1e4,i.far=2500;let s=new Xs.CameraHelper(this.shadow.camera);s.visible=!1,this.gizmos.shadowmap=s}update(){this.shadow.camera.updateProjectionMatrix();for(let r in this.gizmos){let e=this.gizmos[r];e instanceof Xs.CameraHelper&&e.update()}}updateMatrixWorld(r){super.updateMatrixWorld(r),this.objectHelper&&this.objectHelper.update()}updateState(r,e){this.updateState_Light(r,e);let t=r.depth!==void 0&&r.depth!==this.shadow.camera.far||r.size!==void 0&&r.size/2!==this.shadow.camera.right;r.size!==void 0&&iT(this,r.size),r.shadowRadius!==void 0&&(this.shadow.radius=r.shadowRadius),r.shadowResolution!==void 0&&(this.shadow.mapSize.set(r.shadowResolution,r.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),t&&this.update()}};var kt=require("three");var Xl=class extends Ei(kt.PointLight,Li){constructor(r,e,t){super(),this.super_Entity(r,e),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let i=this.shadow.camera;i.fov=90,i.aspect=1,i.near=100,i.far=2500;let s=new kt.Vector3(-i.far+this.position.x,-i.far+this.position.y,-i.far+this.position.z),l=new kt.Vector3(i.far+this.position.x,i.far+this.position.y,i.far+this.position.z),c=new kt.Box3(s,l),u=new kt.Box3Helper(c,new kt.Color(16755200));u.visible=!1,this.gizmos.shadowmap=u,this.update()}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this.gizmos))for(let r in this.gizmos){let e=this.gizmos[r];if(e instanceof kt.Box3Helper){let t=this.shadow.camera,o=new kt.Vector3(-t.far+this.position.x,-t.far+this.position.y,-t.far+this.position.z),i=new kt.Vector3(t.far+this.position.x,t.far+this.position.y,t.far+this.position.z);e.box.set(o,i),e.updateMatrixWorld(!0)}}}updateMatrixWorld(r){super.updateMatrixWorld(r),this.objectHelper&&this.objectHelper.update()}updateState(r,e){this.updateState_Light(r,e),r.distance!==void 0&&(this.distance=r.distance),r.decay!==void 0&&(this.decay=r.decay),r.shadowRadius!==void 0&&(this.shadow.radius=r.shadowRadius),r.shadowResolution!==void 0&&(this.shadow.mapSize.set(r.shadowResolution,r.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};var ir=require("three");var zy=new ir.Vector3,Uy=new ir.Vector3,ky=new ir.Quaternion,Kl=class extends Ei(ir.SpotLight,Ys){constructor(r,e,t){super(),this.super_Entity(r,e),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let i=this.shadow.camera;i.fov=ir.MathUtils.RAD2DEG*2*this.angle,i.aspect=1,i.near=100,i.far=2500;let s=new ir.CameraHelper(this.shadow.camera);s.visible=!1,this.gizmos.shadowmap=s,this.update()}update(){this.shadow.camera.updateProjectionMatrix();for(let r in this.gizmos){let e=this.gizmos[r];e instanceof ir.CameraHelper&&e.update()}}updateMatrixWorld(r){super.updateMatrixWorld(r),Uy.setFromMatrixPosition(this.matrixWorld),ky.setFromRotationMatrix(this.matrixWorld),zy.copy(this.up).applyQuaternion(ky).negate().multiplyScalar(this.distance),this.target.position.copy(Uy).add(zy),this.target.updateMatrixWorld(),this.objectHelper&&this.objectHelper.update()}updateState(r,e){this.updateState_Light(r,e),r.distance!==void 0&&(this.distance=r.distance),r.decay!==void 0&&(this.decay=r.decay),r.angle!==void 0&&(this.angle=r.angle),r.penumbra!==void 0&&(this.penumbra=r.penumbra),r.shadowRadius!==void 0&&(this.shadow.radius=r.shadowRadius),r.shadowResolution!==void 0&&(this.shadow.mapSize.set(r.shadowResolution,r.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};var Zl=class extends bt{get forceComputeSize(){return!0}get shape(){return this.geometry.userData.shape}updateEntityBoxSize(r,e){let t=this.geometry.getAttribute("position");t!==void 0?ms(t,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:t.count,r,e):super.updateEntityBoxSize(r,e)}};var Bi=class extends bt{constructor(e,t,o){super(e,t,o);this._shapeId=null;this.snappedEntities=new Set;this._context=o}updateState(e,t){super.updateState(e,t),this.updateShape(),this.updateSnappedEntities(t)}updateShape(){let e=this.data.geometry.extrusion.shape,t;if(e.type==="Custom"){let i=e.shapeId;if(i!==this._shapeId&&this.detachShape(),i){this._shapeId=i;let s=this._context.scene.find(i);s?.data&&(s.attachedPaths.add(this),t=s.geometry.userData?.shape),t||this._context.scene.addPendingCommand(()=>this.updateShape())}}else{let i;switch(e.type){case"Rectangle":i=xl;break;case"Ellipse":i=oi;break;case"Polygon":i=gl;break;case"Star":i=vl;break;default:throw new Error(`Unknown shape type: ${e.type}`)}t=i.create({parameters:e}).userData.shape}let o=this.geometry;t&&o.inputs&&(o.inputs.shapeData=t,o.build(),this.attachedSurfaceCloners.forEach(i=>i.update()))}updateSnappedEntities(e){this.snappedEntities.forEach(t=>{t.updatePathSnapping(e.scene)})}detachShape(){this._shapeId!==null&&this._context.scene.find(this._shapeId)?.attachedPaths.delete(this)}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.updateShape(),this.refreshAttachedPaths(e),this.updateSnappedEntities(e)}updateGeometryInteractions(e,t){super.updateGeometryInteractions(e,t),this.updateShape()}updateEntityBoxSize(e,t){let o=this.geometry.getAttribute("position");o!==void 0?ms(o,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:o.count,e,t):super.updateEntityBoxSize(e,t)}};var Wy=require("three");var io=class extends Co(Wy.Group,No){constructor(e,t,o){super();t.type==="Instance"&&typeof e=="string"&&(t=this.transformAssignData(t,o)),this.super_Entity(e,t),this.objectHelper.update()}get isComponentRoot(){return this.data.type==="Component"&&typeof this.identity=="string"}get isInstanceRoot(){return this.data.type==="Instance"&&typeof this.identity=="string"}transformAssignData(e,t){let o=t.scene.data.objects.get(e.component);if(o){let i,s;for(let l of fo.rootOverrideProps)e[l]===void 0?(i===void 0&&(i={...e}),i[l]=o.data[l]):(s===void 0&&(s={}),s[l]=e[l]);return this.overrideData=s,i??e}return e}updateByOp(e,t,o,i){let s;if(this.isInstanceRoot&&!i&&(t=this.transformAssignData(t,o),e.type===0&&e.path.length===0&&this.component))for(let l of fo.rootOverrideProps)l in e.props&&e.props[l]===void 0&&(s===void 0&&(s={...e,props:{...e.props}}),s.props[l]=this.component.data[l]);super.updateByOp(s??e,t,o,i)}updateState(e,t){this.updateState_Entity(e,t)}expandInstanceChildren(e){let t=this.data;if(this.component===void 0){this.component=e.scene.find(t.component)??null;let o=!1;if(this.component!==this.oldComponent){if(this.oldComponent){let i=0;for(let s of this.children)if(He.is(s))e.scene.disposeAndUnregisterEntityRecursivelyIfNotReregistered(s),Ql(s),i+=1;else break;this.children.splice(0,i)}o=!0}this.component&&qy(e,[this.uuid],t.overrides,this,this.component,this.component,0,o),this.oldComponent=this.component}}};function Ql(n){if(n.component){let r=n.component.instances.indexOf(n);r>=0&&n.component.instances.splice(r,1);for(let e of n.children)He.is(e)&&Ql(e)}}function Hy(n,r,e,t){return n.component===r&&Ki(n.identity,t)?n.overrideData===e?2:1:0}function qy(n,r,e,t,o,i,s,l){if(s>50)return!1;if(t.component!==o){if(t.component){let u=t.component.instances.indexOf(t);u>=0&&t.component.instances.splice(u,1)}o.instances.push(t),t.component=o}o instanceof io&&o.isInstanceRoot&&o.expandInstanceChildren(n);let c=0;for(let u of o.children)if(He.is(u)){let a=[...r,...typeof u.identity=="string"?[u.identity]:u.identity],d=Sn.resolve(e,a,1),p=null,f;if(!l){let m=t.children[c];if(p=He.is(m)?m:null,p!==null){let h=Hy(p,u,d,a);f=h>=1?p.stateSelection:void 0,h!==2&&(p=null)}if(p===null&&(p=n.scene.findInstance(a)??null,p!==null)){let h=Hy(p,u,d,a);if(f=h>=1?p.stateSelection:void 0,h!==2)p=null;else{let y=p.parent.children.indexOf(p);p.parent.children.splice(y,1),t.children.splice(c,0,p),p.parent===t?(y<=c&&console.error("not possible"),void 0):(p.parent=t,p.matrixWorldNeedsUpdate=!0,p.resetBBoxNeedsUpdate(),p.updateVisible(),n.pendingDeletes.delete(p),void 0)}}}if(p===null){let m=d?Wr.apply(u.data,d):u.data;cr.is(m.type)&&(m={...m,type:"Empty"}),p=ur.createEntity(a,m,n),p.overrideData=d,t.add(p),t.children.splice(t.children.length-1,1),t.children.splice(c,0,p),p.updateState(p.data,n),f&&p.changeSelectedState(f,n),n.scene.registerInstanceAndSetUuid(p)}c+=1,qy(n,r,e,p,u,i,s+1,l)}if(!l){let u=c;for(;;){let a=t.children[c];if(He.is(a))n.pendingDeletes.add(a);else break;c+=1}t.children.splice(u,c-u)}return!0}function sT(n,r,e){let t;return r.geometry.type==="TextGeometry"?new Oi(n,r,e):(r.geometry.type==="SubdivGeometry"?t=new tn(n,r,e):r.geometry.type==="PathGeometry"?t=new Bi(n,r,e):r.geometry.type==="VectorGeometry"?t=new Zl(n,r,e):r.geometry.type==="BooleanGeometry"?t=new nr(n,r,e):t=new bt(n,r,e),t)}function Jl(n,r,e){return r.type==="Mesh"?sT(n,r,e):r.type==="Empty"?new $s(n,r):r.type==="PointLight"?new Xl(n,r,e):r.type==="SpotLight"?new Kl(n,r,e):r.type==="DirectionalLight"?new Yl(n,r,e):r.type==="Component"||r.type==="Instance"?new io(n,r,e):cr.is(r.type)?new no(n,r):(console.error(r),new $s(n,r))}ur.createEntity=Jl;function aT(n,r,e){let t=Jl(n.identity,r,e),o=n.children,i=n.attachedPaths,s=n.parent,l=n.component,c=n.instances,u=n.overrideData,a=n.uuid,d=n.stateSelection;n.dispose();for(let p of Object.keys(n))delete n[p];Object.setPrototypeOf(n,Object.getPrototypeOf(t));for(let p of Object.keys(t))n[p]=t[p];n.children=[...n.children,...o],n.attachedPaths=i,n.parent=s,n.component=l,n.instances=c,n.uuid=a,n.overrideData=u,n.updateState(n.data,e),d&&n.changeSelectedState(d,e),n.resetBBoxNeedsUpdate()}ur.changeEntityProptotype=aT;ur.Cloner=Ci;function $y(n,r,e,t){n.updateByOp(r,e,t,!1)}var Di=require("three");function Yy(n,r){let e=!1,t=r.getLayersOfType("transmission"),o=r.getLayersOfType("outline");return o.length>0&&(n.layers.set(8),t.length>0&&n.layers.enable(3),e=!0,Ti(n),_i(n)),t.length===0&&o.length===0&&n.layers.set(0),e}function Xy(n,r){if(!r.layers)return!1;let e=!1,t=r.getLayersOfType("transmission"),o=r.getLayersOfType("outline");return t.length>0&&(n.layers.set(3),o.length>0&&n.layers.enable(8),e=!0),t.length===0&&o.length===0&&n.layers.set(0),e}function Ky(n){let r=!1;return n.traverseEntity(e=>{if(e instanceof br)if(Array.isArray(e.material))for(let t=0;t<e.material.length;t++)Yy(e,e.material[t])&&(r=!0);else Yy(e,e.material)&&(r=!0)}),r}function Zy(n){let r=!1;return n.traverseEntity(e=>{if(e instanceof br)if(Array.isArray(e.material))for(let t=0;t<e.material.length;t++)Xy(e,e.material[t])&&(r=!0);else Xy(e,e.material)&&(r=!0)}),r}var cT=new Di.Raycaster,dT=new Di.Matrix4,uT=new Di.Ray;function Qy(n,r,e){let t=n.cloner;if(t)for(let o of t.children){let i=dT.copy(o.matrixWorld).invert(),s=uT.copy(r.ray).applyMatrix4(i),l=n.matrixWorld;s.applyMatrix4(l);let c=cT;c.set(s.origin,s.direction),c.near=r.near,c.far=r.far,c.intersectObject(n,!1).length>0&&e.push({object:n})}}var pT=new sr.MeshBasicMaterial;pT.wireframe=!0;var Jy=new sr.Vector3,Yd=class extends sr.Scene{constructor(e,t){super();this.data=e;this.backupFog=new sr.Fog(16777215,.1,2e3);this.fogUseBGColor=!1;this.enableHelpers=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this.needsNormalDirty=!0;this._needsTransmission=!1;this._needsNormal=!1;this.geometryCacheChanged=!1;this.bgColor=new st(1,1,1,1);this.entityByUuid={};this.entityIdentityToEntity={};this.toExpandCloner=new Set;this.toUpdateCloner=new Set;this.pendingCommands=[];this.needsRecomputeInstances=!1;this.ambientLight=new sr.HemisphereLight(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.personalCamera=this.createPersonalCamera(),this.activeCamera=this.personalCamera,this.postprocessing=e.postprocessing,this.init(e,t),this.matrixAutoUpdate=!1}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=Zy(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=Ky(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let t=e.identity.join("-"),o=this.entityIdentityToEntity[t];o&&(e.uuid=o.uuid),this.entityIdentityToEntity[t]=e,this.entityByUuid[e.uuid]=e}findInstance(e){return this.entityIdentityToEntity[e.join("-")]}getWithSortKey(e){let t=this.find(e);if(t===void 0)return;let o=[],i=t;for(;i!==this;){let s=i;i=i.parent;let l=i.children.indexOf(s);o.splice(0,0,l)}return{entity:t,sortKey:o}}getAllSorted(e){let t=[];for(let o of e){let i=this.getWithSortKey(o.id);i!==void 0&&t.push(i)}return t.sort((o,i)=>Fu(o.sortKey,i.sortKey)),t.map(o=>o.entity)}nonExistOrDescendantOf(e,t){let o=this.find(e);if(o===void 0)return!0;for(;o;){if(o.uuid===t)return!0;o=o.parent}return!1}find(e){if(e===""||e===void 0)return;let t=this.entityByUuid[e];return t===void 0?this.getObjectByProperty("uuid",e):t}debugEnsureEntity(e){let t=this.find(e);if(t){if(Array.isArray(t.identity)&&this.findInstance(t.identity)===void 0){console.error("not found instance");debugger}}else{console.error("not found");debugger}}addPendingExpandCloner(e){this.toExpandCloner.add(e)}addPendingUpdateCloner(e){this.toUpdateCloner.add(e)}markToExpandCloner(e){this.toExpandCloner.add(e),e.traverseEntityAncestors(t=>{this.toExpandCloner.add(t)})}doPendingExpandCloner(){this.toExpandCloner.forEach(e=>{e.expandCloner(this)}),this.toExpandCloner.clear()}doPendingUpdateCloner(){this.toUpdateCloner.forEach(e=>{e.cloner?.update()}),this.toUpdateCloner.clear()}doPendingUpdates(){this.doPendingExpandCloner(),this.doPendingUpdateCloner(),this.applyPendingCommands()}addPendingCommand(e){this.pendingCommands.push(e)}applyPendingCommands(){this.pendingCommands.forEach(e=>e()),this.pendingCommands.length=0}updateTreeByOp(e,t){if(e.path.length===0&&e.type===7){let o=e.parent===null?this:this.find(e.parent);if(o===void 0)throw new Error("unexpected");let i=this.createObject(e.id,e.data,e.children,o,e.localIndex,t);i.updateVisible(),i.resetBBoxNeedsUpdate(),Ws(i)&&qs(i.parent)&&(i.invalidateUpstreamBooleanData(),i.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(o),this.markNeedsRecomputeInstancesForChildren(i),this.markToExpandCloner(i)}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),o.parent.remove(o),qs(o.parent)&&(o.parent.invalidateUpstreamBooleanData(),o.parent.invalidateDownstreamBooleanData().recomputeBoolean()),Ws(o)&&(o.freeBooleanPointer(),i instanceof nr&&i.invalidateDownstreamBooleanData().recomputeBoolean()),o instanceof Bi&&o.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(o)}else if(e.path.length===0&&e.type===9){let o=this.find(e.id);if(o===void 0)throw new Error("unexpected");this.markNeedsRecomputeInstancesForChildren(o);let i=o.parent;this.markNeedsRecomputeInstancesForAncessors(i),o.cloner?.resetOnMove(),this.markToExpandCloner(o);let s=e.parent===null?this:this.find(e.parent);if(s===void 0)throw new Error("unexpected");s.add(o),this.markNeedsRecomputeInstancesForAncessors(s),this.markToExpandCloner(o),o.invalidateClonerTransform(o),o.updateVisible(),o.resetBBoxNeedsUpdate();let l=e.localIndex;s.children.splice(l,0,s.children.pop()),Ws(o)&&(o.invalidateUpstreamBooleanData(),qs(o.parent)?o.parent.invalidateDownstreamBooleanData().recomputeBoolean():i instanceof nr&&i.invalidateDownstreamBooleanData().recomputeBoolean())}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}updateEntityByOp(e,t,o,i){if(t.type===0&&(("overrides"in t.props||"component"in t.props)&&this.markNeedsRecomputeInstances(),t.path.includes("overrides")&&"states"in t.props)){let{states:l,rest:c}=t.props;t={...t,props:c},this.markNeedsRecomputeInstances()}let s=this.find(e);if(s)try{$y(s,t,o,{scene:this,shared:i}),s instanceof bt&&s.updateGeometryGroupsIfNeeded()}catch(l){console.error(l)}}get enableFog(){return this.fog!==null}set enableFog(e){this.fog=e===!0?this.backupFog:null}init(e,t){if(this.createChildrenObjects(e.objects,this,t),this.personalCamera.removeFromParent(),this.add(this.personalCamera),this.ambientLight.removeFromParent(),this.add(this.ambientLight),this.setBackgroundColor(It(e.backgroundColor,t)),this.updateFog(e.fog,t),this.updateAmbientLight(e.environment.ambientLight,t),this.activeCamera=this.personalCamera,e.publish.playCamera!==null){let o=this.find(e.publish.playCamera);o instanceof no&&this.switchActiveCamera(o)}this.expandInstances(t,!0),this.traverseEntity(o=>{qs(o)&&o.recomputeBoolean()}),this.doPendingExpandCloner(),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(t=>{(t.data.type==="Component"||t.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){He.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(t=>{He.is(t)&&t.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,t,o,i,s,l,c){e&&e!==i.uuid&&i.find(e)&&s.forInstancesRec(a=>{a.isInstanceRoot||(a.data=mn(a.data,d=>{let p=d.events.data(c.id),f=a.goUp(l);if(f){let m=[...Ia(f.identity),e].join("-"),h=this.entityIdentityToEntity[m];if(h){let y=h.uuid;Tt.zoom(p,t)[o]=y}else{if(!1)debugger;console.warn("cannot find instance")}}}).data)})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof io&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((t,o)=>{t.data.events.forEach(i=>{i.data.type==="GameControl"?t.forInstancesRec(s=>{s.isInstanceRoot||(s.data=mn(s.data,l=>{l.events.delete(i.id)}).data)}):i.data.type==="Conditional"?(i.data.condition.type==="Distance"?(this.relativeizeInner(i.data.condition.fromObject,["condition"],"fromObject",e,t,o,i),this.relativeizeInner(i.data.condition.toObject,["condition"],"toObject",e,t,o,i)):i.data.condition.type==="State"?this.relativeizeInner(i.data.condition.object,["condition"],"object",e,t,o,i):i.data.condition.type==="Comparison"&&(i.data.condition.lOperand.type==="Property"&&this.relativeizeInner(i.data.condition.lOperand.value[0],["condition","lOperand","value"],0,e,t,o,i),i.data.condition.rOperand.type==="Property"&&this.relativeizeInner(i.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,t,o,i)),i.data.inActions.forEach(s=>{s.data.type==="Transition"&&this.relativeizeInner(s.data.object,["inActions",s.id],"object",e,t,o,i)}),i.data.outActions.forEach(s=>{s.data.type==="Transition"&&this.relativeizeInner(s.data.object,["outActions",s.id],"object",e,t,o,i)})):"actions"in i.data&&i.data.actions.forEach(s=>{s.data.type==="Transition"&&this.relativeizeInner(s.data.object,["actions",s.id],"object",e,t,o,i)})})}),!0})}expandInstances(e,t){let o=new Set;this.traverseEntity(i=>{if(i instanceof io&&i.isInstanceRoot)return i.expandInstanceChildren({scene:this,shared:e,pendingDeletes:o}),t||i.resetBBoxNeedsUpdate(),!0});for(let i of o)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(i),Ql(i)}recomputeInstances(e){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(t=>{t instanceof io&&t.isInstanceRoot&&(t.component=void 0)}),this.expandInstances(e,!1))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(t=>{let o=typeof t.identity=="string"?t.identity:t.identity.join("-");this.entityIdentityToEntity[o]===t&&(delete this.entityByUuid[t.uuid],delete this.entityIdentityToEntity[o]),t.dispose()})}clearScene(){for(let e of this.children)pr(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,t){this.init(e,t)}createPersonalCamera(){let e=new no(Yd.PERSONAL_CAMERA_ID,{...bn.defaultData,name:"Personal Camera"});return e.objectHelper.visible=!1,this.registerObjectCreatedInLegacy(e),e}raycast(e){let t=[],o=i=>{for(let s of i.children)pr(s)&&!s.raycastLock&&s.visible&&((Ws(s)||Gy(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,t),Qy(s,e,t)),o(s))};return o(this),t}forEachEntity(e){for(let t of this.children)pr(t)&&e(t)}traverseEntity(e){for(let t of this.children)pr(t)&&t.traverseEntity(e)}traverseObject(e){for(let t of this.children)ts.is(t)&&t.traverseObject(e)}traverseVisibleEntity(e){for(let t of this.children)pr(t)&&t.visible&&t.traverseVisibleEntity(e)}updateFog(e,t){this.enableFog=e.enabled,this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=It(e.color,t),this.backupFog.near=e.near,this.backupFog.far=e.far}dispose(){this.clearScene()}updateAmbientLight(e,t){e.color!==void 0&&(this.ambientLight.color=It(e.color,t)),e.intensity!==void 0&&(this.ambientLight.intensity=e.intensity),e.groundColor!==void 0&&(this.ambientLight.groundColor=It(e.groundColor,t)),e.enabled!==void 0&&(this.ambientLight.visible=e.enabled)}switchActiveCamera(e){this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=e,e.objectHelper.visible=!1}setBackgroundColor(e){this.bgColor=e,this.fogUseBGColor===!0&&(this.backupFog.color=e)}createChildrenObjects(e,t,o){let i=0;for(let s of e)this.createObject(s.id,s.data,s.children,t,i,o),i+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let t of e.children)this.unregisterObject(t)}createObject(e,t,o,i,s,l){let c={scene:this,shared:l},u=Jl(e,t,c);return u&&(this.entityByUuid[e]=u,i.add(u),i.children.splice(s,0,i.children.pop()),o.length>0&&(u.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(o,u,l)),u.updateState(t,c),u instanceof bt&&u.updateGeometryGroupsIfNeeded(),u.updateVisible(),u.cloner&&this.toExpandCloner.add(u)),u}getCenter(e){let t=[];for(let i=0,s=e.length;i<s;++i){let{id:l,recursive:c}=e[i],u=this.find(l),a=c?u.recursiveBBox:u.singleBBox;t.push(...a.vertices)}let o=new sr.Box3;return o.setFromPoints(t),o.getCenter(Jy),Jy}copyMatrixWorld(e,t){if(e===null){t.identity();return}let o=this.find(e);o?t.copy(o.matrixWorld):t.identity()}copyParentMatrixWorld(e,t){if(e===null){t.identity();return}let o=this.find(e)?.parent;o?t.copy(o.matrixWorld):t.identity()}traverseMaterial(e){this.traverseEntity(t=>{if(t instanceof gt)if(Array.isArray(t.material))for(let o=0;o<t.material.length;o++)t.material[o]instanceof Ut&&e(t.material[o]);else t.material instanceof Ut&&e(t.material)})}updateCanvasSize(e,t){this.activeCamera.setViewplaneSize(e,t);let o,i;e>=t?(o=t/e,i=1):(o=1,i=e/t),this.traverseMaterial(s=>{s.getLayersOfType("transmission").forEach(c=>{c.uniforms[`f${c.id}_aspectRatio`].value.x=o,c.uniforms[`f${c.id}_aspectRatio`].value.y=i})})}},Zs=Yd;Zs.PERSONAL_CAMERA_ID="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera";var eg=require("three/examples/jsm/loaders/DRACOLoader.js");var Eo;function fT(){return Eo||(Eo=new eg.DRACOLoader,Eo.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),Eo.decoderPending}async function mT(n){if(Eo){let r={attributeIDs:Eo.defaultAttributeIDs,attributeTypes:Eo.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await Eo.decodeGeometry(new Int8Array(n).buffer,r)}catch(t){console.error(t)}if(e)return{index:e.index?{array:e.index.array}:void 0,attributes:Object.entries(e.attributes).map(([t,o])=>({name:t,itemSize:o.itemSize,array:o.array}))}}return null}async function tg(n,r){let[e,t]=pc(xa.deserialize(new Uint8Array(n)));xm(e);let o=[];e.scene.objects.traverse((i,s)=>{s.type==="Mesh"&&s.geometry.type==="NonParametricGeometry"&&s.geometry.data.draco!==void 0&&o.push(s)}),o.length&&await fT();for(let i of o){let s=await mT(lt(i.geometry.data.draco));if(s){s.index&&(i.geometry.data.index={array:s.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let l={};s.attributes.forEach(({name:c,array:u,itemSize:a})=>{l[c]={array:u,itemSize:a,type:"Float32Array",normalized:!1}}),i.geometry.data.attributes=l,i.geometry.data.draco=void 0}}return r&&r(e),t.result().data}var hT=require("three"),yT=require("three/examples/jsm/utils/BufferGeometryUtils.js");function rg(n){let r;if(!!n.index)for(let e=0;e<n.index.array.length;e+=3)r=n.index.array[e],n.index.array[e]=n.index.array[e+2],n.index.array[e+2]=r}var Qs=require("three");function og(n){let r=new Set;return n.traverse(e=>{if(e instanceof br)if(Ye(e.material))e.material.forEach(t=>{let o=t;r.has(o)||r.add(o)});else{let t=e.material;r.has(t)||r.add(t)}}),r.forEach(e=>{if(e instanceof Array)return;let t=e.onBeforeCompile.bind(e);if(gT(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new Qs.Color,specularColor:new Qs.Color});let o=0;e.onBeforeCompile=(i,s)=>{t&&t(i,s),i.uniforms=Object.assign({},Qs.ShaderLib.physical.uniforms,i.uniforms),e.getLayersOfType("transmission").forEach(l=>{if(i.uniforms.transmissionSamplerMap.value){let c=l.color;c&&(c.transmissionSamplerMap.value=i.uniforms.transmissionSamplerMap.value,c.transmissionSamplerSize.value=i.uniforms.transmissionSamplerSize.value)}else o++,o<2&&(e.needsUpdate=!0)})}}else xT(e)||(e.onBeforeCompile=(o,i)=>{t&&t(o,i),e.transparent=!1})}),n}function gT(n){return n.getLayersOfType("transmission").length>0}function xT(n){let r=0;return n.layers.forEach(e=>{if(e.type!=="light"&&e.type!=="fresnel"){let t=e.uniforms["f"+e.id+"_alpha"];t&&(r+=(1-r)*t.value)}}),r<1}function ng(n){return n.traverse(r=>{if(r.type==="Camera"){let e=r;e.type=e.cameraType}}),n}function ig(n){let r=[],e=(t,o=0)=>{let i=o>0?t+o:t;return r.includes(i)?e(t,o+1):i};return n.traverse(t=>{if(r.includes(t.name)){let o=t.name,i=e(t.name);if(t.name=i,t.isMesh){let s=t;s.material instanceof Array?s.material.forEach(l=>{l.name=l.name.replace(o,i)}):s.material.isAsset||(s.material.name=s.material.name.replace(o,i))}}r.push(t.name)}),n}var sg=require("three/examples/jsm/utils/BufferGeometryUtils.js");function ag(n){let r=[];return n.traverse(e=>{e instanceof Ci&&r.push(e)}),r.forEach(e=>{let t=e.object,i=e.children.map(l=>{l.updateMatrix();let c=l.geometry.clone().applyMatrix4(l.matrix);return l.matrix.determinant()<0&&rg(c),c}),s=(0,sg.mergeBufferGeometries)(e.parameters.hideBase?i:[t instanceof gt?t.geometry:[],...i]);t instanceof gt&&(t.geometry=s),e.removeFromParent(),t.setFromClonerState(null,{scene:n,shared:uy})}),n}function lg(n){return n.traverse(r=>{r.matrixAutoUpdate=!0}),n}function cg(n){Object.values(n.shared.materials).forEach(r=>{Xd(r)}),n.scene.objects.traverse((r,e)=>{"material"in e?Xd(e.material):"materials"in e&&e.materials.forEach(t=>{Xd(t)})})}function Xd(n){if(typeof n=="string")return;let r=[];n.layers.forEach((e,t)=>{e.type==="outline"&&r.push(t)}),r.reverse().forEach(e=>{n.layers.delete(e)}),r.length&&console.warn("The Spline Loader currently does not support the outline layer.")}var dg="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",ec=class extends tc.Loader{load(r,e,t,o=console.error){let i=new tc.FileLoader(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),r.endsWith(".spline")?console.warn(dg+" The .spline files are only meant to be used by the Editor."):r.endsWith(".splinecode")||console.warn(dg),i.load(r,async s=>{try{if(typeof s=="string")throw new Error("The .spline file is not binary!");let l=await this.parse(s);e(l)}catch(l){o(l)}},t,o)}async parse(r){let e=await tg(r,cg);await Promise.all([fy(e)&&Nh(),Ty(e)&&cy()].filter(Boolean));let t=new en(e.shared);Object.values(t.getMaterials()).forEach(s=>Object.assign(s,{isAsset:!0}));let o=new Zs(e.scene,t);o.remove(o.personalCamera),e.scene.environment.ambientLight.enabled||o.remove(o.ambientLight);let i=e.scene.publish.playCamera;if(i){let s=o.find(i);s&&Dy(s)&&Object.assign(s,{makeDefault:!0})}return o=ag(o),o=og(o),o=ng(o),o=ig(o),o=lg(o),o}};