@splinetool/loader 0.9.384 → 0.9.387
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.
- package/build/SplineLoader.cjs +659 -134
- package/build/SplineLoader.js +659 -134
- package/package.json +2 -2
- package/build/SplineLoader.d.ts +0 -5
- package/build/applyCloners.d.ts +0 -2
- package/build/convertCameras.d.ts +0 -2
- package/build/convertTransmission.d.ts +0 -2
- package/build/deduplicateNames.d.ts +0 -5
- package/build/removeJitter.d.ts +0 -2
- package/build/removeOutlineLayers.d.ts +0 -3
- package/build/restoreMatrixAutoUpdate.d.ts +0 -2
package/build/SplineLoader.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
var u0=Object.create;var Jl=Object.defineProperty;var p0=Object.getOwnPropertyDescriptor;var f0=Object.getOwnPropertyNames;var m0=Object.getPrototypeOf,h0=Object.prototype.hasOwnProperty;var Ws=(n,r)=>()=>(r||n((r={exports:{}}).exports,r),r.exports),y0=(n,r)=>{for(var e in r)Jl(n,e,{get:r[e],enumerable:!0})},g0=(n,r,e,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of f0(r))!h0.call(n,o)&&o!==e&&Jl(n,o,{get:()=>r[o],enumerable:!(t=p0(r,o))||t.enumerable});return n};var $s=(n,r,e)=>(e=n!=null?u0(m0(n)):{},g0(r||!n||!n.__esModule?Jl(e,"default",{value:n,enumerable:!0}):e,n));var Zm=Ws((Ic,Km)=>{(function(n,r){typeof Ic=="object"?Km.exports=r():typeof define=="function"&&define.amd?define(r):n.Alea=r()})(Ic,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 rh=Ws((Qa,th)=>{(function(n,r){typeof Qa=="object"&&typeof th<"u"?r(Qa):typeof define=="function"&&define.amd?define(["exports"],r):r((n=typeof globalThis<"u"?globalThis:n||self).SVDJS={})})(Qa,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,b=r.length;if(b<v)throw new TypeError("Invalid matrix: m < n");for(var w=[],S=[],P=[],_=e==="f"?b:v,x=h=p=0;x<b;x++)S[x]=new Array(_).fill(0);for(x=0;x<v;x++)P[x]=new Array(v).fill(0);var C,T=new Array(v).fill(0);for(x=0;x<b;x++)for(s=0;s<v;s++)S[x][s]=r[x][s];for(x=0;x<v;x++){for(w[x]=p,m=0,c=x+1,s=x;s<b;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<b;l++)m+=S[l][x]*S[l][s];for(d=m/f,l=x;l<b;l++)S[l][s]=S[l][s]+d*S[l][x]}for(T[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++)w[s]=S[x][s]/f;for(s=c;s<b;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*w[l]}}h<(y=Math.abs(T[x])+Math.abs(w[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++)P[s][x]=S[x][s]/f;for(s=c;s<v;s++){for(m=0,l=c;l<v;l++)m+=S[x][l]*P[l][s];for(l=c;l<v;l++)P[l][s]=P[l][s]+m*P[l][x]}}for(s=c;s<v;s++)P[x][s]=0,P[s][x]=0;P[x][x]=1,p=w[x],c=x}if(e){if(e==="f")for(x=v;x<b;x++){for(s=v;s<b;s++)S[x][s]=0;S[x][x]=1}for(x=v-1;0<=x;x--){for(c=x+1,p=T[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<b;l++)m+=S[l][x]*S[l][s];for(d=m/f,l=x;l<b;l++)S[l][s]=S[l][s]+d*S[l][x]}for(s=x;s<b;s++)S[s][x]=S[s][x]/p}else for(s=x;s<b;s++)S[s][x]=0;S[x][x]=S[x][x]+1}}for(o*=h,l=v-1;0<=l;l--)for(var N=0;N<50;N++){for(C=!1,c=l;0<=c;c--){if(Math.abs(w[c])<=o){C=!0;break}if(Math.abs(T[c-1])<=o)break}if(!C){for(a=0,u=c-(m=1),x=c;x<l+1&&(d=m*w[x],w[x]=a*w[x],!(Math.abs(d)<=o));x++)if(p=T[x],T[x]=Math.sqrt(d*d+p*p),a=p/(f=T[x]),m=-d/f,e)for(s=0;s<b;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=T[l],c===l){if(g<0&&(T[l]=-g,t))for(s=0;s<v;s++)P[s][l]=-P[s][l];break}for(h=T[c],d=(((y=T[l-1])-g)*(y+g)+((p=w[l-1])-(f=w[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=w[x],y=T[x],f=m*p,p*=a,g=Math.sqrt(d*d+f*f),d=h*(a=d/(w[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=P[s][x-1],g=P[s][x],P[s][x-1]=h*a+g*m,P[s][x]=-h*m+g*a;if(g=Math.sqrt(d*d+f*f),d=(a=d/(T[x-1]=g))*p+(m=f/g)*y,h=-m*p+a*y,e)for(s=0;s<b;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}w[c]=0,w[l]=d,T[l]=h}for(x=0;x<v;x++)T[x]<o&&(T[x]=0);return{u:S,q:T,v:P}},n.VERSION="1.1.1",Object.defineProperty(n,"__esModule",{value:!0})})});var qy=Ws(Ll=>{(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 b=0;b<a._howls.length;b++)a._howls[b]._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),b=Math.max(0,(p._sprite[a][0]+p._sprite[a][1])/1e3-v),w=b*1e3/Math.abs(y._rate),S=p._sprite[a][0]/1e3,P=(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=P,y._loop=!!(y._loop||p._sprite[a][2])};if(v>=P){p._ended(y);return}var x=y._node;if(p._webAudio){var C=function(){p._playLock=!1,_(),p._refreshBuffer(y);var A=y._muted||p._muted?0:y._volume;x.gain.setValueAtTime(A,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,b):y._loop?x.bufferSource.start(0,v,86400):x.bufferSource.start(0,v,b),w!==1/0&&(p._endTimers[y._id]=setTimeout(p._ended.bind(p,y),w)),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 T=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 A=x.play();if(A&&typeof Promise<"u"&&(A instanceof Promise||typeof A.then=="function")?(p._playLock=!0,_(),A.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),w):(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(G){p._emit("playerror",y._id,G)}};x.src==="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA"&&(x.src=p._src,x.load());var N=window&&window.ejecta||!x.readyState&&r._navigator.isCocoonJS;if(x.readyState>=3||N)T();else{p._playLock=!0,p._state="loading";var O=function(){p._state="loaded",T(),x.removeEventListener(r._canPlayEvent,O,!1)};x.addEventListener(r._canPlayEvent,O,!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,b=v+p/1e3;g._volume=a,g._node.gain.setValueAtTime(a,v),g._node.gain.linearRampToValueAtTime(d,b)}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,b=Math.abs(v/.01),w=Math.max(4,b>0?f/b:f),S=Date.now();a._fadeTo=p,a._interval=setInterval(function(){var P=(Date.now()-S)/f;S=Date.now(),g+=v*P,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))},w)},_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]),b=(a._sprite[y._sprite][0]+a._sprite[y._sprite][1])/1e3-v,w=b*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),w)),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 b=function(){a._playLock?setTimeout(b,0):v()};setTimeout(b,0)}else v()}else if(a._webAudio){var w=a.playing(f)?r.ctx.currentTime-y._playStart:0,S=y._rateSeek?y._rateSeek-y._seek:0;return y._seek+(S+w*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 Ll<"u"&&(Ll.Howler=r,Ll.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 e0=Ws((ZK,Jg)=>{Jg.exports=function(r,e){for(var t=r.split("."),o=e.split("."),i=0;i<3;i++){var s=Number(t[i]),l=Number(o[i]);if(s>l)return 1;if(l>s)return-1;if(!isNaN(s)&&isNaN(l))return 1;if(isNaN(s)&&!isNaN(l))return-1}return 0}});import{FileLoader as oN,Loader as nN}from"three";function wu(n){for(let r of Object.keys(n))n[r]===void 0&&delete n[r];return n}function Vr(n,r){return Object.setPrototypeOf(n,r),n}function Ys(n){return Array.isArray(n)?n:[n]}function _u(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 x0=typeof global=="object"&&global&&global.Object===Object&&global,Xs=x0;var v0=typeof self=="object"&&self&&self.Object===Object&&self,b0=Xs||v0||Function("return this")(),We=b0;var S0=We.Symbol,Ze=S0;var Pu=Object.prototype,w0=Pu.hasOwnProperty,_0=Pu.toString,Fi=Ze?Ze.toStringTag:void 0;function P0(n){var r=w0.call(n,Fi),e=n[Fi];try{n[Fi]=void 0;var t=!0}catch{}var o=_0.call(n);return t&&(r?n[Fi]=e:delete n[Fi]),o}var Tu=P0;var T0=Object.prototype,O0=T0.toString;function A0(n){return O0.call(n)}var Ou=A0;var N0="[object Null]",C0="[object Undefined]",Au=Ze?Ze.toStringTag:void 0;function I0(n){return n==null?n===void 0?C0:N0:Au&&Au in Object(n)?Tu(n):Ou(n)}var Lt=I0;function M0(n){return n!=null&&typeof n=="object"}var at=M0;var E0="[object Symbol]";function L0(n){return typeof n=="symbol"||at(n)&&Lt(n)==E0}var Zo=L0;function B0(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 Ks=B0;var D0=Array.isArray,Ve=D0;var G0=1/0,Nu=Ze?Ze.prototype:void 0,Cu=Nu?Nu.toString:void 0;function Iu(n){if(typeof n=="string")return n;if(Ve(n))return Ks(n,Iu)+"";if(Zo(n))return Cu?Cu.call(n):"";var r=n+"";return r=="0"&&1/n==-G0?"-0":r}var Mu=Iu;function R0(n){var r=typeof n;return n!=null&&(r=="object"||r=="function")}var Bt=R0;function V0(n){return n}var Eu=V0;var z0="[object AsyncFunction]",j0="[object Function]",F0="[object GeneratorFunction]",k0="[object Proxy]";function U0(n){if(!Bt(n))return!1;var r=Lt(n);return r==j0||r==F0||r==z0||r==k0}var Zs=U0;var H0=We["__core-js_shared__"],Qs=H0;var Lu=function(){var n=/[^.]+$/.exec(Qs&&Qs.keys&&Qs.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}();function q0(n){return!!Lu&&Lu in n}var Bu=q0;var W0=Function.prototype,$0=W0.toString;function Y0(n){if(n!=null){try{return $0.call(n)}catch{}try{return n+""}catch{}}return""}var zr=Y0;var X0=/[\\^$.*+?()[\]{}|]/g,K0=/^\[object .+?Constructor\]$/,Z0=Function.prototype,Q0=Object.prototype,J0=Z0.toString,ex=Q0.hasOwnProperty,tx=RegExp("^"+J0.call(ex).replace(X0,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function rx(n){if(!Bt(n)||Bu(n))return!1;var r=Zs(n)?tx:K0;return r.test(zr(n))}var Du=rx;function ox(n,r){return n?.[r]}var Gu=ox;function nx(n,r){var e=Gu(n,r);return Du(e)?e:void 0}var Pt=nx;var ix=Pt(We,"WeakMap"),Js=ix;var Ru=Object.create,sx=function(){function n(){}return function(r){if(!Bt(r))return{};if(Ru)return Ru(r);n.prototype=r;var e=new n;return n.prototype=void 0,e}}(),Vu=sx;function ax(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 zu=ax;function lx(n,r){var e=-1,t=n.length;for(r||(r=Array(t));++e<t;)r[e]=n[e];return r}var ju=lx;var cx=800,dx=16,ux=Date.now;function px(n){var r=0,e=0;return function(){var t=ux(),o=dx-(t-e);if(e=t,o>0){if(++r>=cx)return arguments[0]}else r=0;return n.apply(void 0,arguments)}}var Fu=px;function fx(n){return function(){return n}}var ku=fx;var mx=function(){try{var n=Pt(Object,"defineProperty");return n({},"",{}),n}catch{}}(),Qo=mx;var hx=Qo?function(n,r){return Qo(n,"toString",{configurable:!0,enumerable:!1,value:ku(r),writable:!0})}:Eu,Uu=hx;var yx=Fu(Uu),Hu=yx;function gx(n,r){for(var e=-1,t=n==null?0:n.length;++e<t&&r(n[e],e,n)!==!1;);return n}var qu=gx;var xx=9007199254740991,vx=/^(?:0|[1-9]\d*)$/;function bx(n,r){var e=typeof n;return r=r??xx,!!r&&(e=="number"||e!="symbol"&&vx.test(n))&&n>-1&&n%1==0&&n<r}var Jo=bx;function Sx(n,r,e){r=="__proto__"&&Qo?Qo(n,r,{configurable:!0,enumerable:!0,value:e,writable:!0}):n[r]=e}var ea=Sx;function wx(n,r){return n===r||n!==n&&r!==r}var en=wx;var _x=Object.prototype,Px=_x.hasOwnProperty;function Tx(n,r,e){var t=n[r];(!(Px.call(n,r)&&en(t,e))||e===void 0&&!(r in n))&&ea(n,r,e)}var tn=Tx;function Ox(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?ea(e,l,c):tn(e,l,c)}return e}var hr=Ox;var Wu=Math.max;function Ax(n,r,e){return r=Wu(r===void 0?n.length-1:r,0),function(){for(var t=arguments,o=-1,i=Wu(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),zu(n,this,l)}}var $u=Ax;var Nx=9007199254740991;function Cx(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=Nx}var rn=Cx;function Ix(n){return n!=null&&rn(n.length)&&!Zs(n)}var ta=Ix;var Mx=Object.prototype;function Ex(n){var r=n&&n.constructor,e=typeof r=="function"&&r.prototype||Mx;return n===e}var on=Ex;function Lx(n,r){for(var e=-1,t=Array(n);++e<n;)t[e]=r(e);return t}var Yu=Lx;var Bx="[object Arguments]";function Dx(n){return at(n)&&Lt(n)==Bx}var ec=Dx;var Xu=Object.prototype,Gx=Xu.hasOwnProperty,Rx=Xu.propertyIsEnumerable,Vx=ec(function(){return arguments}())?ec:function(n){return at(n)&&Gx.call(n,"callee")&&!Rx.call(n,"callee")},nn=Vx;function zx(){return!1}var Ku=zx;var Ju=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Zu=Ju&&typeof module=="object"&&module&&!module.nodeType&&module,jx=Zu&&Zu.exports===Ju,Qu=jx?We.Buffer:void 0,Fx=Qu?Qu.isBuffer:void 0,kx=Fx||Ku,_o=kx;var Ux="[object Arguments]",Hx="[object Array]",qx="[object Boolean]",Wx="[object Date]",$x="[object Error]",Yx="[object Function]",Xx="[object Map]",Kx="[object Number]",Zx="[object Object]",Qx="[object RegExp]",Jx="[object Set]",ev="[object String]",tv="[object WeakMap]",rv="[object ArrayBuffer]",ov="[object DataView]",nv="[object Float32Array]",iv="[object Float64Array]",sv="[object Int8Array]",av="[object Int16Array]",lv="[object Int32Array]",cv="[object Uint8Array]",dv="[object Uint8ClampedArray]",uv="[object Uint16Array]",pv="[object Uint32Array]",Le={};Le[nv]=Le[iv]=Le[sv]=Le[av]=Le[lv]=Le[cv]=Le[dv]=Le[uv]=Le[pv]=!0;Le[Ux]=Le[Hx]=Le[rv]=Le[qx]=Le[ov]=Le[Wx]=Le[$x]=Le[Yx]=Le[Xx]=Le[Kx]=Le[Zx]=Le[Qx]=Le[Jx]=Le[ev]=Le[tv]=!1;function fv(n){return at(n)&&rn(n.length)&&!!Le[Lt(n)]}var ep=fv;function mv(n){return function(r){return n(r)}}var sn=mv;var tp=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ki=tp&&typeof module=="object"&&module&&!module.nodeType&&module,hv=ki&&ki.exports===tp,tc=hv&&Xs.process,yv=function(){try{var n=ki&&ki.require&&ki.require("util").types;return n||tc&&tc.binding&&tc.binding("util")}catch{}}(),jr=yv;var rp=jr&&jr.isTypedArray,gv=rp?sn(rp):ep,ra=gv;var xv=Object.prototype,vv=xv.hasOwnProperty;function bv(n,r){var e=Ve(n),t=!e&&nn(n),o=!e&&!t&&_o(n),i=!e&&!t&&!o&&ra(n),s=e||t||o||i,l=s?Yu(n.length,String):[],c=l.length;for(var u in n)(r||vv.call(n,u))&&!(s&&(u=="length"||o&&(u=="offset"||u=="parent")||i&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||Jo(u,c)))&&l.push(u);return l}var oa=bv;function Sv(n,r){return function(e){return n(r(e))}}var na=Sv;var wv=na(Object.keys,Object),op=wv;var _v=Object.prototype,Pv=_v.hasOwnProperty;function Tv(n){if(!on(n))return op(n);var r=[];for(var e in Object(n))Pv.call(n,e)&&e!="constructor"&&r.push(e);return r}var np=Tv;function Ov(n){return ta(n)?oa(n):np(n)}var an=Ov;function Av(n){var r=[];if(n!=null)for(var e in Object(n))r.push(e);return r}var ip=Av;var Nv=Object.prototype,Cv=Nv.hasOwnProperty;function Iv(n){if(!Bt(n))return ip(n);var r=on(n),e=[];for(var t in n)t=="constructor"&&(r||!Cv.call(n,t))||e.push(t);return e}var sp=Iv;function Mv(n){return ta(n)?oa(n,!0):sp(n)}var ln=Mv;var Ev=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Lv=/^\w*$/;function Bv(n,r){if(Ve(n))return!1;var e=typeof n;return e=="number"||e=="symbol"||e=="boolean"||n==null||Zo(n)?!0:Lv.test(n)||!Ev.test(n)||r!=null&&n in Object(r)}var ap=Bv;var Dv=Pt(Object,"create"),Fr=Dv;function Gv(){this.__data__=Fr?Fr(null):{},this.size=0}var lp=Gv;function Rv(n){var r=this.has(n)&&delete this.__data__[n];return this.size-=r?1:0,r}var cp=Rv;var Vv="__lodash_hash_undefined__",zv=Object.prototype,jv=zv.hasOwnProperty;function Fv(n){var r=this.__data__;if(Fr){var e=r[n];return e===Vv?void 0:e}return jv.call(r,n)?r[n]:void 0}var dp=Fv;var kv=Object.prototype,Uv=kv.hasOwnProperty;function Hv(n){var r=this.__data__;return Fr?r[n]!==void 0:Uv.call(r,n)}var up=Hv;var qv="__lodash_hash_undefined__";function Wv(n,r){var e=this.__data__;return this.size+=this.has(n)?0:1,e[n]=Fr&&r===void 0?qv:r,this}var pp=Wv;function cn(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])}}cn.prototype.clear=lp;cn.prototype.delete=cp;cn.prototype.get=dp;cn.prototype.has=up;cn.prototype.set=pp;var rc=cn;function $v(){this.__data__=[],this.size=0}var fp=$v;function Yv(n,r){for(var e=n.length;e--;)if(en(n[e][0],r))return e;return-1}var eo=Yv;var Xv=Array.prototype,Kv=Xv.splice;function Zv(n){var r=this.__data__,e=eo(r,n);if(e<0)return!1;var t=r.length-1;return e==t?r.pop():Kv.call(r,e,1),--this.size,!0}var mp=Zv;function Qv(n){var r=this.__data__,e=eo(r,n);return e<0?void 0:r[e][1]}var hp=Qv;function Jv(n){return eo(this.__data__,n)>-1}var yp=Jv;function eb(n,r){var e=this.__data__,t=eo(e,n);return t<0?(++this.size,e.push([n,r])):e[t][1]=r,this}var gp=eb;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=fp;dn.prototype.delete=mp;dn.prototype.get=hp;dn.prototype.has=yp;dn.prototype.set=gp;var to=dn;var tb=Pt(We,"Map"),ro=tb;function rb(){this.size=0,this.__data__={hash:new rc,map:new(ro||to),string:new rc}}var xp=rb;function ob(n){var r=typeof n;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?n!=="__proto__":n===null}var vp=ob;function nb(n,r){var e=n.__data__;return vp(r)?e[typeof r=="string"?"string":"hash"]:e.map}var oo=nb;function ib(n){var r=oo(this,n).delete(n);return this.size-=r?1:0,r}var bp=ib;function sb(n){return oo(this,n).get(n)}var Sp=sb;function ab(n){return oo(this,n).has(n)}var wp=ab;function lb(n,r){var e=oo(this,n),t=e.size;return e.set(n,r),this.size+=e.size==t?0:1,this}var _p=lb;function un(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])}}un.prototype.clear=xp;un.prototype.delete=bp;un.prototype.get=Sp;un.prototype.has=wp;un.prototype.set=_p;var Po=un;var cb="Expected a function";function oc(n,r){if(typeof n!="function"||r!=null&&typeof r!="function")throw new TypeError(cb);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(oc.Cache||Po),e}oc.Cache=Po;var Pp=oc;var db=500;function ub(n){var r=Pp(n,function(t){return e.size===db&&e.clear(),t}),e=r.cache;return r}var Tp=ub;var pb=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,fb=/\\(\\)?/g,mb=Tp(function(n){var r=[];return n.charCodeAt(0)===46&&r.push(""),n.replace(pb,function(e,t,o,i){r.push(o?i.replace(fb,"$1"):t||e)}),r}),Op=mb;function hb(n){return n==null?"":Mu(n)}var Ap=hb;function yb(n,r){return Ve(n)?n:ap(n,r)?[n]:Op(Ap(n))}var kt=yb;var gb=1/0;function xb(n){if(typeof n=="string"||Zo(n))return n;var r=n+"";return r=="0"&&1/n==-gb?"-0":r}var no=xb;function vb(n,r){r=kt(r,n);for(var e=0,t=r.length;n!=null&&e<t;)n=n[no(r[e++])];return e&&e==t?n:void 0}var ia=vb;function bb(n,r){for(var e=-1,t=r.length,o=n.length;++e<t;)n[o+e]=r[e];return n}var pn=bb;var Np=Ze?Ze.isConcatSpreadable:void 0;function Sb(n){return Ve(n)||nn(n)||!!(Np&&n&&n[Np])}var Cp=Sb;function Ip(n,r,e,t,o){var i=-1,s=n.length;for(e||(e=Cp),o||(o=[]);++i<s;){var l=n[i];r>0&&e(l)?r>1?Ip(l,r-1,e,t,o):pn(o,l):t||(o[o.length]=l)}return o}var Mp=Ip;function wb(n){var r=n==null?0:n.length;return r?Mp(n,1):[]}var Ep=wb;function _b(n){return Hu($u(n,void 0,Ep),n+"")}var sa=_b;var Pb=na(Object.getPrototypeOf,Object),fn=Pb;var Tb="[object Object]",Ob=Function.prototype,Ab=Object.prototype,Lp=Ob.toString,Nb=Ab.hasOwnProperty,Cb=Lp.call(Object);function Ib(n){if(!at(n)||Lt(n)!=Tb)return!1;var r=fn(n);if(r===null)return!0;var e=Nb.call(r,"constructor")&&r.constructor;return typeof e=="function"&&e instanceof e&&Lp.call(e)==Cb}var Bp=Ib;function Mb(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 Dp=Mb;function Eb(){this.__data__=new to,this.size=0}var Gp=Eb;function Lb(n){var r=this.__data__,e=r.delete(n);return this.size=r.size,e}var Rp=Lb;function Bb(n){return this.__data__.get(n)}var Vp=Bb;function Db(n){return this.__data__.has(n)}var zp=Db;var Gb=200;function Rb(n,r){var e=this.__data__;if(e instanceof to){var t=e.__data__;if(!ro||t.length<Gb-1)return t.push([n,r]),this.size=++e.size,this;e=this.__data__=new Po(t)}return e.set(n,r),this.size=e.size,this}var jp=Rb;function mn(n){var r=this.__data__=new to(n);this.size=r.size}mn.prototype.clear=Gp;mn.prototype.delete=Rp;mn.prototype.get=Vp;mn.prototype.has=zp;mn.prototype.set=jp;var hn=mn;function Vb(n,r){return n&&hr(r,an(r),n)}var Fp=Vb;function zb(n,r){return n&&hr(r,ln(r),n)}var kp=zb;var Wp=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Up=Wp&&typeof module=="object"&&module&&!module.nodeType&&module,jb=Up&&Up.exports===Wp,Hp=jb?We.Buffer:void 0,qp=Hp?Hp.allocUnsafe:void 0;function Fb(n,r){if(r)return n.slice();var e=n.length,t=qp?qp(e):new n.constructor(e);return n.copy(t),t}var $p=Fb;function kb(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 Yp=kb;function Ub(){return[]}var aa=Ub;var Hb=Object.prototype,qb=Hb.propertyIsEnumerable,Xp=Object.getOwnPropertySymbols,Wb=Xp?function(n){return n==null?[]:(n=Object(n),Yp(Xp(n),function(r){return qb.call(n,r)}))}:aa,yn=Wb;function $b(n,r){return hr(n,yn(n),r)}var Kp=$b;var Yb=Object.getOwnPropertySymbols,Xb=Yb?function(n){for(var r=[];n;)pn(r,yn(n)),n=fn(n);return r}:aa,la=Xb;function Kb(n,r){return hr(n,la(n),r)}var Zp=Kb;function Zb(n,r,e){var t=r(n);return Ve(n)?t:pn(t,e(n))}var ca=Zb;function Qb(n){return ca(n,an,yn)}var Ui=Qb;function Jb(n){return ca(n,ln,la)}var da=Jb;var e1=Pt(We,"DataView"),ua=e1;var t1=Pt(We,"Promise"),pa=t1;var r1=Pt(We,"Set"),fa=r1;var Qp="[object Map]",o1="[object Object]",Jp="[object Promise]",ef="[object Set]",tf="[object WeakMap]",rf="[object DataView]",n1=zr(ua),i1=zr(ro),s1=zr(pa),a1=zr(fa),l1=zr(Js),To=Lt;(ua&&To(new ua(new ArrayBuffer(1)))!=rf||ro&&To(new ro)!=Qp||pa&&To(pa.resolve())!=Jp||fa&&To(new fa)!=ef||Js&&To(new Js)!=tf)&&(To=function(n){var r=Lt(n),e=r==o1?n.constructor:void 0,t=e?zr(e):"";if(t)switch(t){case n1:return rf;case i1:return Qp;case s1:return Jp;case a1:return ef;case l1:return tf}return r});var kr=To;var c1=Object.prototype,d1=c1.hasOwnProperty;function u1(n){var r=n.length,e=new n.constructor(r);return r&&typeof n[0]=="string"&&d1.call(n,"index")&&(e.index=n.index,e.input=n.input),e}var of=u1;var p1=We.Uint8Array,gn=p1;function f1(n){var r=new n.constructor(n.byteLength);return new gn(r).set(new gn(n)),r}var xn=f1;function m1(n,r){var e=r?xn(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.byteLength)}var nf=m1;var h1=/\w*$/;function y1(n){var r=new n.constructor(n.source,h1.exec(n));return r.lastIndex=n.lastIndex,r}var sf=y1;var af=Ze?Ze.prototype:void 0,lf=af?af.valueOf:void 0;function g1(n){return lf?Object(lf.call(n)):{}}var cf=g1;function x1(n,r){var e=r?xn(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.length)}var df=x1;var v1="[object Boolean]",b1="[object Date]",S1="[object Map]",w1="[object Number]",_1="[object RegExp]",P1="[object Set]",T1="[object String]",O1="[object Symbol]",A1="[object ArrayBuffer]",N1="[object DataView]",C1="[object Float32Array]",I1="[object Float64Array]",M1="[object Int8Array]",E1="[object Int16Array]",L1="[object Int32Array]",B1="[object Uint8Array]",D1="[object Uint8ClampedArray]",G1="[object Uint16Array]",R1="[object Uint32Array]";function V1(n,r,e){var t=n.constructor;switch(r){case A1:return xn(n);case v1:case b1:return new t(+n);case N1:return nf(n,e);case C1:case I1:case M1:case E1:case L1:case B1:case D1:case G1:case R1:return df(n,e);case S1:return new t;case w1:case T1:return new t(n);case _1:return sf(n);case P1:return new t;case O1:return cf(n)}}var uf=V1;function z1(n){return typeof n.constructor=="function"&&!on(n)?Vu(fn(n)):{}}var pf=z1;var j1="[object Map]";function F1(n){return at(n)&&kr(n)==j1}var ff=F1;var mf=jr&&jr.isMap,k1=mf?sn(mf):ff,hf=k1;var U1="[object Set]";function H1(n){return at(n)&&kr(n)==U1}var yf=H1;var gf=jr&&jr.isSet,q1=gf?sn(gf):yf,xf=q1;var W1=1,$1=2,Y1=4,vf="[object Arguments]",X1="[object Array]",K1="[object Boolean]",Z1="[object Date]",Q1="[object Error]",bf="[object Function]",J1="[object GeneratorFunction]",eS="[object Map]",tS="[object Number]",Sf="[object Object]",rS="[object RegExp]",oS="[object Set]",nS="[object String]",iS="[object Symbol]",sS="[object WeakMap]",aS="[object ArrayBuffer]",lS="[object DataView]",cS="[object Float32Array]",dS="[object Float64Array]",uS="[object Int8Array]",pS="[object Int16Array]",fS="[object Int32Array]",mS="[object Uint8Array]",hS="[object Uint8ClampedArray]",yS="[object Uint16Array]",gS="[object Uint32Array]",Ee={};Ee[vf]=Ee[X1]=Ee[aS]=Ee[lS]=Ee[K1]=Ee[Z1]=Ee[cS]=Ee[dS]=Ee[uS]=Ee[pS]=Ee[fS]=Ee[eS]=Ee[tS]=Ee[Sf]=Ee[rS]=Ee[oS]=Ee[nS]=Ee[iS]=Ee[mS]=Ee[hS]=Ee[yS]=Ee[gS]=!0;Ee[Q1]=Ee[bf]=Ee[sS]=!1;function ma(n,r,e,t,o,i){var s,l=r&W1,c=r&$1,u=r&Y1;if(e&&(s=o?e(n,t,o,i):e(n)),s!==void 0)return s;if(!Bt(n))return n;var a=Ve(n);if(a){if(s=of(n),!l)return ju(n,s)}else{var d=kr(n),p=d==bf||d==J1;if(_o(n))return $p(n,l);if(d==Sf||d==vf||p&&!o){if(s=c||p?{}:pf(n),!l)return c?Zp(n,kp(s,n)):Kp(n,Fp(s,n))}else{if(!Ee[d])return o?n:{};s=uf(n,d,l)}}i||(i=new hn);var f=i.get(n);if(f)return f;i.set(n,s),xf(n)?n.forEach(function(y){s.add(ma(y,r,e,y,n,i))}):hf(n)&&n.forEach(function(y,g){s.set(g,ma(y,r,e,g,n,i))});var m=u?c?da:Ui:c?ln:an,h=a?void 0:m(n);return qu(h||n,function(y,g){h&&(g=y,y=n[g]),tn(s,g,ma(y,r,e,g,n,i))}),s}var ha=ma;var xS=1,vS=4;function bS(n){return ha(n,xS|vS)}var Ur=bS;var SS="__lodash_hash_undefined__";function wS(n){return this.__data__.set(n,SS),this}var wf=wS;function _S(n){return this.__data__.has(n)}var _f=_S;function ya(n){var r=-1,e=n==null?0:n.length;for(this.__data__=new Po;++r<e;)this.add(n[r])}ya.prototype.add=ya.prototype.push=wf;ya.prototype.has=_f;var Pf=ya;function PS(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 Tf=PS;function TS(n,r){return n.has(r)}var Of=TS;var OS=1,AS=2;function NS(n,r,e,t,o,i){var s=e&OS,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&AS?new Pf: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(!Tf(r,function(g,v){if(!Of(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 ga=NS;function CS(n){var r=-1,e=Array(n.size);return n.forEach(function(t,o){e[++r]=[o,t]}),e}var Af=CS;function IS(n){var r=-1,e=Array(n.size);return n.forEach(function(t){e[++r]=t}),e}var Nf=IS;var MS=1,ES=2,LS="[object Boolean]",BS="[object Date]",DS="[object Error]",GS="[object Map]",RS="[object Number]",VS="[object RegExp]",zS="[object Set]",jS="[object String]",FS="[object Symbol]",kS="[object ArrayBuffer]",US="[object DataView]",Cf=Ze?Ze.prototype:void 0,nc=Cf?Cf.valueOf:void 0;function HS(n,r,e,t,o,i,s){switch(e){case US:if(n.byteLength!=r.byteLength||n.byteOffset!=r.byteOffset)return!1;n=n.buffer,r=r.buffer;case kS:return!(n.byteLength!=r.byteLength||!i(new gn(n),new gn(r)));case LS:case BS:case RS:return en(+n,+r);case DS:return n.name==r.name&&n.message==r.message;case VS:case jS:return n==r+"";case GS:var l=Af;case zS:var c=t&MS;if(l||(l=Nf),n.size!=r.size&&!c)return!1;var u=s.get(n);if(u)return u==r;t|=ES,s.set(n,r);var a=ga(l(n),l(r),t,o,i,s);return s.delete(n),a;case FS:if(nc)return nc.call(n)==nc.call(r)}return!1}var If=HS;var qS=1,WS=Object.prototype,$S=WS.hasOwnProperty;function YS(n,r,e,t,o,i){var s=e&qS,l=Ui(n),c=l.length,u=Ui(r),a=u.length;if(c!=a&&!s)return!1;for(var d=c;d--;){var p=l[d];if(!(s?p in r:$S.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 b=s?t(v,g,p,r,n,i):t(g,v,p,n,r,i);if(!(b===void 0?g===v||o(g,v,e,t,i):b)){h=!1;break}y||(y=p=="constructor")}if(h&&!y){var w=n.constructor,S=r.constructor;w!=S&&"constructor"in n&&"constructor"in r&&!(typeof w=="function"&&w instanceof w&&typeof S=="function"&&S instanceof S)&&(h=!1)}return i.delete(n),i.delete(r),h}var Mf=YS;var XS=1,Ef="[object Arguments]",Lf="[object Array]",xa="[object Object]",KS=Object.prototype,Bf=KS.hasOwnProperty;function ZS(n,r,e,t,o,i){var s=Ve(n),l=Ve(r),c=s?Lf:kr(n),u=l?Lf:kr(r);c=c==Ef?xa:c,u=u==Ef?xa:u;var a=c==xa,d=u==xa,p=c==u;if(p&&_o(n)){if(!_o(r))return!1;s=!0,a=!1}if(p&&!a)return i||(i=new hn),s||ra(n)?ga(n,r,e,t,o,i):If(n,r,c,e,t,o,i);if(!(e&XS)){var f=a&&Bf.call(n,"__wrapped__"),m=d&&Bf.call(r,"__wrapped__");if(f||m){var h=f?n.value():n,y=m?r.value():r;return i||(i=new hn),o(h,y,e,t,i)}}return p?(i||(i=new hn),Mf(n,r,e,t,o,i)):!1}var Df=ZS;function Gf(n,r,e,t,o){return n===r?!0:n==null||r==null||!at(n)&&!at(r)?n!==n&&r!==r:Df(n,r,e,t,Gf,o)}var Rf=Gf;function QS(n,r){return n!=null&&r in Object(n)}var Vf=QS;function JS(n,r,e){r=kt(r,n);for(var t=-1,o=r.length,i=!1;++t<o;){var s=no(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&&rn(o)&&Jo(s,o)&&(Ve(n)||nn(n)))}var zf=JS;function ew(n,r){return n!=null&&zf(n,r,Vf)}var jf=ew;function tw(n){var r=n==null?0:n.length;return r?n[r-1]:void 0}var Ff=tw;function rw(n,r){return r.length<2?n:ia(n,Dp(r,0,-1))}var kf=rw;function ow(n,r){return Rf(n,r)}var Hi=ow;function nw(n,r){return r=kt(r,n),n=kf(n,r),n==null||delete n[no(Ff(r))]}var Uf=nw;function iw(n){return Bp(n)?void 0:n}var Hf=iw;var sw=1,aw=2,lw=4,cw=sa(function(n,r){var e={};if(n==null)return e;var t=!1;r=Ks(r,function(i){return i=kt(i,n),t||(t=i.length>1),i}),hr(n,da(n),e),t&&(e=ha(e,sw|aw|lw,Hf));for(var o=r.length;o--;)Uf(e,r[o]);return e}),vn=cw;function dw(n,r,e,t){if(!Bt(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=no(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=Bt(a)?a:Jo(r[o+1])?[]:{})}tn(l,c,u),l=l[c]}return n}var qf=dw;function uw(n,r,e){for(var t=-1,o=r.length,i={};++t<o;){var s=r[t],l=ia(n,s);e(l,s)&&qf(i,kt(s,n),l)}return i}var Wf=uw;function pw(n,r){return Wf(n,r,function(e,t){return jf(n,t)})}var $f=pw;var fw=sa(function(n,r){return n==null?{}:$f(n,r)}),bn=fw;function Sn(n){let r;return()=>r||(r=n(),r)}var Me=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,Me.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,Me.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,Me.prototype),delete i[t],{data:i,actual:r,reverse:{type:1,id:t,data:o}}}}return null}};function qi(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"&&qi(t)}return Object.freeze(n)}function Yf(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 wn=class extends Error{};function va(n){let r={...n};return Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r}function yr(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 _n(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 Xf(){return typeof process<"u"}function Kf(n,r){for(let e of n)r(e.id,e.data)!==!0&&Kf(e.children,r)}function Zf(n,r){if(r(n.id,n.data)!==!0)for(let e of n.children)Zf(e,r)}var $e=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,$e.prototype)}deepFreeze(){let e=0;for(;e<this.length;)qi(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&&Zf(o,t)}}traverse(e){Kf(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,$e.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 wn("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)=>Yf(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 yr(0,o,o);{let s=i[0].fi;return yr(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 yr(c,c+o,o)}else return yr(s.fi,l.fi,o)}}};var Pn;(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})(Pn||(Pn={}));var he=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,he.prototype)}deepFreeze(){let e=0;for(;e<this.length;)qi(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,he.prototype);let t=e;return Xf()||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 yr(0,t,t);{let i=o[0].fi;return yr(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 yr(l,l+t,t)}else return yr(i.fi,s.fi,t)}}};function Tn(n){return n&&typeof n=="object"&&n instanceof Be}var Be=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&&!Tn(t))return null;o+=1}t=t?va(t):new Be;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=va(c),delete t[r.path[o-1]])}else{let c=e[o-1];if(c){let u=va(c);u[r.path[o-1]]=t,t=u}else{let u=new Be;u[r.path[o-1]]=t,t=u}}o-=1}let s=Object.setPrototypeOf(t,Be.prototype),l={...r,props:i};return{data:s,actual:r,reverse:l}}},Hr;(t=>{function n(o,i){return Wi(o,i)??o}t.apply=n;function r(o,i){return sc(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=yt.zoomOnce(c,l[s]),c===void 0)return i;if(!Tn(c))return;s+=1}if(c===void 0)return i;if(!!Tn(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=ic([i],c);return u?(console.log(u),u):i}else return i}t.filterOp=e})(Hr||(Hr={}));function ic(n,r){if(r===void 0)return;let e=!1,t=n.map(o=>{let i=o.id,s=Wi(o.data,r[i]);if(e=e||s!==void 0,s===void 0&&(s=o.data),o.children){let l=ic(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 mw(n,r){if(r===void 0)return;let e=!1,t=n.map(o=>{let i=o.id,s=Wi(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 Wi(n,r){if(!Tn(r))return r;if(n instanceof $e){let e=ic(n,r);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e}else{if(n instanceof he)return mw(n,r);if(Array.isArray(n)){let e=!1,t=n.map((o,i)=>{let s=Wi(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 Be)return sc(n,r);if(n&&typeof n=="object"){let e={},t=!1;for(let[o,i]of Object.entries(n)){let s=Wi(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 sc(n,r){if(n===void 0)return r;if(r===void 0)return n;if(!Tn(r))return r;if(!Tn(n))return Hr.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 Be;for(let o of e){let i=sc(n===void 0?void 0:n[o],r===void 0?void 0:r[o]);t[o]=i}return t}function Qf(n,r){let e={cur:[],result:[],len:0};return n=$i(n,r,e)??n,[n,e.result]}function ba(n,r){return n===null?null:(n.cur[n.len]=r,n.len+=1,n)}function Sa(n){n&&(n.len-=1)}function hw(n){if(n===null)return null;n.result.push(n.cur.slice(0,n.len))}function Jf(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=$i(i.data,r,ba(e,s));Sa(e),t=t||c!==void 0,c===void 0&&(c=i.data);let u=Jf(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 yw(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=$i(i.data,r,ba(e,s));return Sa(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 $i(n,r,e){if(n instanceof $e){let t=Jf(n,r,e);return t!==void 0&&Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t}else{if(n instanceof he)return yw(n,r,e);if(Array.isArray(n)){let t=!1,o=n.map((i,s)=>{let l=$i(i,r,ba(e,s));return Sa(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"&&!_n(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=$i(s,r,ba(e,i));Sa(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");hw(e)}return t}else return}}var wa;(r=>{function n(e,t){let o=yt.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})(wa||(wa={}));var lt;(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 Be&&u.type===0&&(p=c.runOp({...u,path:a.slice(d.length)}),p===null&&(p=void 0)),p===void 0&&d.length===a.length&&(c instanceof $e||c instanceof he||c instanceof Me?p=c.runOp(u):p=Pn.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 $e){if(typeof g=="number")throw new Error("illegal arg");h=v.modifyById(g,h)}else if(v instanceof he){if(typeof g=="number")throw new Error("illegal arg");h=v.modifyById(g,h)}else if(v instanceof Me){if(typeof g=="number")throw new Error("illegal arg");h=v.modifyById(g,h)}else if(v instanceof Be){let b={...v,[g]:h};h=Object.setPrototypeOf(b,Be.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 b=h;h=[...v],h[g]=b}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 $e){if(typeof f=="number")throw new Error("");m=c.get(f)?.data}else if(c instanceof he){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})(lt||(lt={}));var ac;(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=>lt.subsumed(p,f))),...a]}c.compress=o;function i(u,a){return u.every(d=>a.every(p=>lt.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=yt.zoom(d,[...m.path,m.id]),y=lt.apply(d,{...m,type:2});if(y!==null){d=y.data;let[g,v]=Qf(d,{[m.id]:h});d=g;for(let b of v){let w=b[b.length-1];b.splice(b.length-1,1),p.push({type:0,path:b,props:{[w]:h}}),f.push({type:0,path:b,props:{[w]:m.id}})}f.push(y.reverse),p.push(y.actual)}}else{let h=lt.apply(d,m);h!==null&&(p.push(h.actual),d=h.data,f.push(h.reverse))}}catch(h){if(h instanceof wn)return null;throw h}return{data:d,actual:p,reverse:f.reverse()}}c.apply=l})(ac||(ac={}));var em=Symbol(),gw=Symbol(),Pa=Symbol(),Oo=class{reportOp(r,e,t=[]){let o=this;if(e===null)return;o._current=e.data;let i=t;for(;!(o instanceof _a);){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[Pa];t&&t(),delete this._children[r]}}}},cc=class extends Oo{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,Pn.runOp(this._current,r),r.path)}},dc=class extends Oo{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,Me.prototype)}runOp(r){this.reportOp(r,this._current.runOp(r))}},tm={get(n,r){if(r===Pa)return()=>{n._parent=null};if(r===em)return n._current;if(r===gw)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=Ta(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]}}},xw={...tm,set(n,r,e){let t={type:0,props:{[r]:Qe(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}},vw={...tm,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}},On=class extends Oo{constructor(r,e,t){super(),this._children={},this._parent=r,this._path=e,this._current=t,this[Pa]=()=>{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=Ta(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)}},An=class extends Oo{constructor(r,e,t){super(),this._children={},this._parent=r,this._path=e,this._current=t,this[Pa]=()=>{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=Ta(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 lc(n,r,e){if(n.length>0){let t=n[n.length-1];if(t.type===0&&r.type===0&&yt.equal(t.path,e)){Object.assign(t.props,r.props);return}}n.push({...r,path:e})}var _a=class extends Oo{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){lc(this.ts,e,r),lc(this.actual,t,r),lc(this.reverse,o,r)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function Ta(n,r,e){return e instanceof $e?new On(n,r,e):e instanceof he?new An(n,r,e):e instanceof Me?new Proxy(new dc(n,r,e),vw):e!==null&&typeof e=="object"?_n(e)?e:new Proxy(new cc(n,r,e),xw):e}function uc(n){let r=new _a(n);return[Ta(r,"",n),r]}function Nn(n,r){let[e,t]=uc(n);return r(e),t.result()}function Qe(n){return n instanceof On||n instanceof An?n._current:n!==null&&typeof n=="object"?n[em]:n}var yt;(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 $e||i instanceof On)&&typeof s=="string")return i.data(s);if((i instanceof he||i instanceof An)&&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})(yt||(yt={}));function rm(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 Zt(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 Oa=class{},Yi=class extends Oa{constructor(e){super();this.id=e}},Xi=class extends Oa{constructor(e){super();this.data=e}};var fc;try{fc=new TextDecoder}catch{}var ne,so,I=0;var dm=[],mc=dm,hc=0,Tt={},Pe,io,Ut=0,gr=0,Dt,qr,gt=[],Ae,om={useRecords:!1,mapsAsObjects:!0},Ki=class{},gc=new Ki;gc.name="MessagePack 0xC1";var Cn=!1,xr=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 hm(()=>(Na(),this?this.unpack(r,e):xr.prototype.unpack.call(om,r,e)));so=e>-1?e:r.length,I=0,hc=0,gr=0,io=null,mc=dm,Dt=null,ne=r;try{Ae=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 xr){if(Tt=this,this.structures)return Pe=this.structures,Aa();(!Pe||Pe.length>0)&&(Pe=[])}else Tt=om,(!Pe||Pe.length>0)&&(Pe=[]);return Aa()}unpackMultiple(r,e){let t,o=0;try{Cn=!0;let i=r.length,s=this?this.unpack(r,i):Ma.unpack(r,i);if(e){for(e(s);I<i;)if(o=I,e(Aa())===!1)return}else{for(t=[s];I<i;)o=I,t.push(Aa());return t}}catch(i){throw i.lastPosition=o,i.values=t,i}finally{Cn=!1,Na()}}_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 Aa(){try{if(!Tt.trusted&&!Cn){let r=Pe.sharedLength||0;r<Pe.length&&(Pe.length=r)}let n=ze();if(I==so)Pe.restoreStructures&&nm(),Pe=null,ne=null,qr&&(qr=null);else if(I>so){let r=new Error("Unexpected end of MessagePack data");throw r.incomplete=!0,r}else if(!Cn)throw new Error("Data read, but end of buffer not reached");return n}catch(n){throw Pe.restoreStructures&&nm(),Na(),(n instanceof RangeError||n.message.startsWith("Unexpected end of buffer"))&&(n.incomplete=!0),n}}function nm(){for(let n in Pe.restoreStructures)Pe[n]=Pe.restoreStructures[n];Pe.restoreStructures=null}function ze(){let n=ne[I++];if(n<160)if(n<128){if(n<64)return n;{let r=Pe[n&63]||Tt.getStructures&&um()[n&63];return r?(r.read||(r.read=xc(r,n&63)),r.read()):n}}else if(n<144)if(n-=128,Tt.mapsAsObjects){let r={};for(let e=0;e<n;e++)r[fm()]=ze();return r}else{let r=new Map;for(let e=0;e<n;e++)r.set(ze(),ze());return r}else{n-=144;let r=new Array(n);for(let e=0;e<n;e++)r[e]=ze();return r}else if(n<192){let r=n-160;if(gr>=I)return io.slice(I-Ut,(I+=r)-Ut);if(gr==0&&so<140){let e=r<16?vc(r):pm(r);if(e!=null)return e}return yc(r)}else{let r;switch(n){case 192:return null;case 193:return Dt?(r=ze(),r>0?Dt[1].slice(Dt.position1,Dt.position1+=r):Dt[0].slice(Dt.position0,Dt.position0-=r)):gc;case 194:return!1;case 195:return!0;case 196:return pc(ne[I++]);case 197:return r=Ae.getUint16(I),I+=2,pc(r);case 198:return r=Ae.getUint32(I),I+=4,pc(r);case 199:return Ao(ne[I++]);case 200:return r=Ae.getUint16(I),I+=2,Ao(r);case 201:return r=Ae.getUint32(I),I+=4,Ao(r);case 202:if(r=Ae.getFloat32(I),Tt.useFloat32>2){let e=Ia[(ne[I]&127)<<1|ne[I+1]>>7];return I+=4,(e*r+(r>0?.5:-.5)>>0)/e}return I+=4,r;case 203:return r=Ae.getFloat64(I),I+=8,r;case 204:return ne[I++];case 205:return r=Ae.getUint16(I),I+=2,r;case 206:return r=Ae.getUint32(I),I+=4,r;case 207:return Tt.int64AsNumber?(r=Ae.getUint32(I)*4294967296,r+=Ae.getUint32(I+4)):r=Ae.getBigUint64(I),I+=8,r;case 208:return Ae.getInt8(I++);case 209:return r=Ae.getInt16(I),I+=2,r;case 210:return r=Ae.getInt32(I),I+=4,r;case 211:return Tt.int64AsNumber?(r=Ae.getInt32(I)*4294967296,r+=Ae.getUint32(I+4)):r=Ae.getBigInt64(I),I+=8,r;case 212:if(r=ne[I++],r==114)return cm(ne[I++]&63);{let e=gt[r];if(e)return e.read?(I++,e.read(ze())):e.noBuffer?(I++,e()):e(ne.subarray(I,++I));throw new Error("Unknown extension "+r)}case 213:return r=ne[I],r==114?(I++,cm(ne[I++]&63,ne[I++])):Ao(2);case 214:return Ao(4);case 215:return Ao(8);case 216:return Ao(16);case 217:return r=ne[I++],gr>=I?io.slice(I-Ut,(I+=r)-Ut):Sw(r);case 218:return r=Ae.getUint16(I),I+=2,gr>=I?io.slice(I-Ut,(I+=r)-Ut):ww(r);case 219:return r=Ae.getUint32(I),I+=4,gr>=I?io.slice(I-Ut,(I+=r)-Ut):_w(r);case 220:return r=Ae.getUint16(I),I+=2,sm(r);case 221:return r=Ae.getUint32(I),I+=4,sm(r);case 222:return r=Ae.getUint16(I),I+=2,am(r);case 223:return r=Ae.getUint32(I),I+=4,am(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 bw=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function xc(n,r){function e(){if(e.count++>2){let o=n.read=new Function("r","return function(){return {"+n.map(i=>bw.test(i)?i+":r()":"["+JSON.stringify(i)+"]:r()").join(",")+"}}")(ze);return n.highByte===0&&(n.read=im(r,n.read)),o()}let t={};for(let o=0,i=n.length;o<i;o++){let s=n[o];t[s]=ze()}return t}return e.count=0,n.highByte===0?im(r,e):e}var im=(n,r)=>function(){let e=ne[I++];if(e===0)return r();let t=n<32?-(n+(e<<5)):n+(e<<5),o=Pe[t]||um()[t];if(!o)throw new Error("Record id is not defined for "+t);return o.read||(o.read=xc(o,n)),o.read()};function um(){let n=hm(()=>(ne=null,Tt.getStructures()));return Pe=Tt._mergeStructures(n,Pe)}var yc=Ca,Sw=Ca,ww=Ca,_w=Ca;function Ca(n){let r;if(n<16&&(r=vc(n)))return r;if(n>64&&fc)return fc.decode(ne.subarray(I,I+=n));let e=I+n,t=[];for(r="";I<e;){let o=ne[I++];if((o&128)===0)t.push(o);else if((o&224)===192){let i=ne[I++]&63;t.push((o&31)<<6|i)}else if((o&240)===224){let i=ne[I++]&63,s=ne[I++]&63;t.push((o&31)<<12|i<<6|s)}else if((o&248)===240){let i=ne[I++]&63,s=ne[I++]&63,l=ne[I++]&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+=Je.apply(String,t),t.length=0)}return t.length>0&&(r+=Je.apply(String,t)),r}function sm(n){let r=new Array(n);for(let e=0;e<n;e++)r[e]=ze();return r}function am(n){if(Tt.mapsAsObjects){let r={};for(let e=0;e<n;e++)r[fm()]=ze();return r}else{let r=new Map;for(let e=0;e<n;e++)r.set(ze(),ze());return r}}var Je=String.fromCharCode;function pm(n){let r=I,e=new Array(n);for(let t=0;t<n;t++){let o=ne[I++];if((o&128)>0){I=r;return}e[t]=o}return Je.apply(String,e)}function vc(n){if(n<4)if(n<2){if(n===0)return"";{let r=ne[I++];if((r&128)>1){I-=1;return}return Je(r)}}else{let r=ne[I++],e=ne[I++];if((r&128)>0||(e&128)>0){I-=2;return}if(n<3)return Je(r,e);let t=ne[I++];if((t&128)>0){I-=3;return}return Je(r,e,t)}else{let r=ne[I++],e=ne[I++],t=ne[I++],o=ne[I++];if((r&128)>0||(e&128)>0||(t&128)>0||(o&128)>0){I-=4;return}if(n<6){if(n===4)return Je(r,e,t,o);{let i=ne[I++];if((i&128)>0){I-=5;return}return Je(r,e,t,o,i)}}else if(n<8){let i=ne[I++],s=ne[I++];if((i&128)>0||(s&128)>0){I-=6;return}if(n<7)return Je(r,e,t,o,i,s);let l=ne[I++];if((l&128)>0){I-=7;return}return Je(r,e,t,o,i,s,l)}else{let i=ne[I++],s=ne[I++],l=ne[I++],c=ne[I++];if((i&128)>0||(s&128)>0||(l&128)>0||(c&128)>0){I-=8;return}if(n<10){if(n===8)return Je(r,e,t,o,i,s,l,c);{let u=ne[I++];if((u&128)>0){I-=9;return}return Je(r,e,t,o,i,s,l,c,u)}}else if(n<12){let u=ne[I++],a=ne[I++];if((u&128)>0||(a&128)>0){I-=10;return}if(n<11)return Je(r,e,t,o,i,s,l,c,u,a);let d=ne[I++];if((d&128)>0){I-=11;return}return Je(r,e,t,o,i,s,l,c,u,a,d)}else{let u=ne[I++],a=ne[I++],d=ne[I++],p=ne[I++];if((u&128)>0||(a&128)>0||(d&128)>0||(p&128)>0){I-=12;return}if(n<14){if(n===12)return Je(r,e,t,o,i,s,l,c,u,a,d,p);{let f=ne[I++];if((f&128)>0){I-=13;return}return Je(r,e,t,o,i,s,l,c,u,a,d,p,f)}}else{let f=ne[I++],m=ne[I++];if((f&128)>0||(m&128)>0){I-=14;return}if(n<15)return Je(r,e,t,o,i,s,l,c,u,a,d,p,f,m);let h=ne[I++];if((h&128)>0){I-=15;return}return Je(r,e,t,o,i,s,l,c,u,a,d,p,f,m,h)}}}}}function pc(n){return Tt.copyBuffers?Uint8Array.prototype.slice.call(ne,I,I+=n):ne.subarray(I,I+=n)}function Ao(n){let r=ne[I++];if(gt[r])return gt[r](ne.subarray(I,I+=n));throw new Error("Unknown extension type "+r)}var lm=new Array(4096);function fm(){let n=ne[I++];if(n>=160&&n<192){if(n=n-160,gr>=I)return io.slice(I-Ut,(I+=n)-Ut);if(!(gr==0&&so<180))return yc(n)}else return I--,ze();let r=(n<<5^(n>1?Ae.getUint16(I):n>0?ne[I]:0))&4095,e=lm[r],t=I,o=I+n-3,i,s=0;if(e&&e.bytes==n){for(;t<o;){if(i=Ae.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 I=t,e.string;o-=3,t=I}for(e=[],lm[r]=e,e.bytes=n;t<o;)i=Ae.getUint32(t),e.push(i),t+=4;for(o+=3;t<o;)i=ne[t++],e.push(i);let l=n<16?vc(n):pm(n);return l!=null?e.string=l:e.string=yc(n)}var cm=(n,r)=>{var e=ze();let t=n;r!==void 0&&(n=n<32?-((r<<5)+n):(r<<5)+n,e.highByte=r);let o=Pe[n];return o&&o.isShared&&((Pe.restoreStructures||(Pe.restoreStructures=[]))[n]=o),Pe[n]=e,e.read=xc(e,t),e.read()},mm=typeof self=="object"?self:global;gt[0]=()=>{};gt[0].noBuffer=!0;gt[101]=()=>{let n=ze();return(mm[n[0]]||Error)(n[1])};gt[105]=n=>{let r=Ae.getUint32(I-4);qr||(qr=new Map);let e=ne[I],t;e>=144&&e<160||e==220||e==221?t=[]:t={};let o={target:t};qr.set(r,o);let i=ze();return o.used?Object.assign(t,i):(o.target=i,i)};gt[112]=n=>{let r=Ae.getUint32(I-4),e=qr.get(r);return e.used=!0,e.target};gt[115]=()=>new Set(ze());var bc=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(n=>n+"Array");gt[116]=n=>{let r=n[0],e=bc[r];if(!e)throw new Error("Could not find typed array for code "+r);return new mm[e](Uint8Array.prototype.slice.call(n,1).buffer)};gt[120]=()=>{let n=ze();return new RegExp(n[0],n[1])};gt[98]=n=>{let r=(n[0]<<24)+(n[1]<<16)+(n[2]<<8)+n[3],e=I;I+=r-4,Dt=[ze(),ze()],Dt.position0=0,Dt.position1=0;let t=I;I=e;try{return ze()}finally{I=t}};gt[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 hm(n){let r=so,e=I,t=hc,o=Ut,i=gr,s=io,l=mc,c=qr,u=Dt,a=new Uint8Array(ne.slice(0,so)),d=Pe,p=Pe.slice(0,Pe.length),f=Tt,m=Cn,h=n();return so=r,I=e,hc=t,Ut=o,gr=i,io=s,mc=l,qr=c,Dt=u,ne=a,Cn=m,Pe=d,Pe.splice(0,Pe.length,...p),Tt=f,Ae=new DataView(ne.buffer,ne.byteOffset,ne.byteLength),h}function Na(){ne=null,qr=null,Pe=null}function ym(n){n.unpack?gt[n.type]=n.unpack:gt[n.type]=n}var Ia=new Array(147);for(let n=0;n<256;n++)Ia[n]=+("1e"+Math.floor(45.15-n*.30103));var Ma=new xr({useRecords:!1}),Pw=Ma.unpack,Tw=Ma.unpackMultiple,Ow=Ma.unpack,Ea={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},Aw=new Float32Array(1),PD=new Uint8Array(Aw.buffer,0,4);var La;try{La=new TextEncoder}catch{}var Ba,wc,Da=typeof Buffer<"u",Sc=Da?Buffer.allocUnsafeSlow:Uint8Array,bm=Da?Buffer:Uint8Array,gm=Da?4294967296:2144337920,z,Ue,E=0,vr,br=null,Nw=/[\u0080-\uFFFF]/,Zi=Symbol("record-id"),No=class extends xr{constructor(r){super(r),this.offset=0;let e,t,o,i,s,l,c=0,u=bm.prototype.utf8Write?function(x,C,T){return z.utf8Write(x,C,T)}:La&&La.encodeInto?function(x,C){return La.encodeInto(x,z.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=[],b=0,w=0;this.pack=this.encode=function(x,C){if(z||(z=new Sc(8192),Ue=new DataView(z.buffer,0,8192),E=0),vr=z.length-10,vr-E<2048?(z=new Sc(z.length),Ue=new DataView(z.buffer,0,z.length),vr=z.length-10,E=0):E=E+7&2147483640,t=E,l=a.structuredClone?new Map:null,a.bundleStrings?(br=["",""],z[E++]=214,z[E++]=98,br.position=E-t,E+=4):br=null,o=a.structures,o){o.uninitialized&&(o=a._mergeStructures(a.getStructures()));let T=o.sharedLength||0;if(T>f)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+o.sharedLength);if(!o.transitions){o.transitions=Object.create(null);for(let N=0;N<T;N++){let O=o[N];if(!O)continue;let A,G=o.transitions;for(let k=0,$=O.length;k<$;k++){let ee=O[k];A=G[ee],A||(A=G[ee]=Object.create(null)),G=A}G[Zi]=N+64}c=T}d||(o.nextId=T+64)}i&&(i=!1),s=o||[];try{if(S(x),br){Ue.setUint32(br.position+t,E-br.position-t);let T=br;br=null,S(T[0]),S(T[1])}if(a.offset=E,l&&l.idsToInsert){E+=l.idsToInsert.length*6,E>vr&&_(E),a.offset=E;let T=Iw(z.subarray(t,E),l.idsToInsert);return l=null,T}return C&wm?(z.start=t,z.end=E,z):z.subarray(t,E)}finally{if(o){if(w<10&&w++,b>1e4)o.transitions=null,w=0,b=0,v.length>0&&(v=[]);else if(v.length>0&&!d){for(let T=0,N=v.length;T<N;T++)v[T][Zi]=0;v=[]}if(i&&a.saveStructures){let T=o.sharedLength||f;o.length>T&&(o=o.slice(0,T));let N=z.subarray(t,E);return a.saveStructures(o,c)===!1?(a._mergeStructures(a.getStructures()),a.pack(x)):(c=T,N)}}C&Rw&&(E=t)}};let S=x=>{E>vr&&(z=_(E));var C=typeof x,T;if(C==="string"){let N=x.length;if(br&&N>=8&&N<4096){let G=Nw.test(x);br[G?0:1]+=x,z[E++]=193,S(G?-N:N);return}let O;N<32?O=1:N<256?O=2:N<65536?O=3:O=5;let A=N*3;if(E+A>vr&&(z=_(E+A)),N<64||!u){let G,k,$,ee=E+O;for(G=0;G<N;G++)k=x.charCodeAt(G),k<128?z[ee++]=k:k<2048?(z[ee++]=k>>6|192,z[ee++]=k&63|128):(k&64512)===55296&&(($=x.charCodeAt(G+1))&64512)===56320?(k=65536+((k&1023)<<10)+($&1023),G++,z[ee++]=k>>18|240,z[ee++]=k>>12&63|128,z[ee++]=k>>6&63|128,z[ee++]=k&63|128):(z[ee++]=k>>12|224,z[ee++]=k>>6&63|128,z[ee++]=k&63|128);T=ee-E-O}else T=u(x,E+O,A);T<32?z[E++]=160|T:T<256?(O<2&&z.copyWithin(E+2,E+1,E+1+T),z[E++]=217,z[E++]=T):T<65536?(O<3&&z.copyWithin(E+3,E+2,E+2+T),z[E++]=218,z[E++]=T>>8,z[E++]=T&255):(O<5&&z.copyWithin(E+5,E+3,E+3+T),z[E++]=219,Ue.setUint32(E,T),E+=4),E+=T}else if(C==="number")if(x>>>0===x)x<64?z[E++]=x:x<256?(z[E++]=204,z[E++]=x):x<65536?(z[E++]=205,z[E++]=x>>8,z[E++]=x&255):(z[E++]=206,Ue.setUint32(E,x),E+=4);else if(x>>0===x)x>=-32?z[E++]=256+x:x>=-128?(z[E++]=208,z[E++]=x+256):x>=-32768?(z[E++]=209,Ue.setInt16(E,x),E+=2):(z[E++]=210,Ue.setInt32(E,x),E+=4);else{let N;if((N=this.useFloat32)>0&&x<4294967296&&x>=-2147483648){z[E++]=202,Ue.setFloat32(E,x);let O;if(N<4||(O=x*Ia[(z[E]&127)<<1|z[E+1]>>7])>>0===O){E+=4;return}else E--}z[E++]=203,Ue.setFloat64(E,x),E+=8}else if(C==="object")if(!x)z[E++]=192;else{if(l){let O=l.get(x);if(O){if(!O.id){let A=l.idsToInsert||(l.idsToInsert=[]);O.id=A.push(O)}z[E++]=214,z[E++]=112,Ue.setUint32(E,O.id),E+=4;return}else l.set(x,{offset:E-t})}let N=x.constructor;if(N===Object)P(x,!0);else if(N===Array){T=x.length,T<16?z[E++]=144|T:T<65536?(z[E++]=220,z[E++]=T>>8,z[E++]=T&255):(z[E++]=221,Ue.setUint32(E,T),E+=4);for(let O=0;O<T;O++)S(x[O])}else if(N===Map){T=x.size,T<16?z[E++]=128|T:T<65536?(z[E++]=222,z[E++]=T>>8,z[E++]=T&255):(z[E++]=223,Ue.setUint32(E,T),E+=4);for(let[O,A]of x)S(O),S(A)}else{for(let O=0,A=Ba.length;O<A;O++){let G=wc[O];if(x instanceof G){let k=Ba[O];if(k.write){k.type&&(z[E++]=212,z[E++]=k.type,z[E++]=0),S(k.write.call(this,x));return}let $=z,ee=Ue,Y=E;z=null;let W;try{W=k.pack.call(this,x,H=>(z=$,$=null,E+=H,E>vr&&_(E),{target:z,targetView:Ue,position:E-H}),S)}finally{$&&(z=$,Ue=ee,E=Y,vr=z.length-10)}W&&(W.length+E>vr&&_(W.length+E),E=Cw(W,z,E,k.type));return}}P(x,!x.hasOwnProperty)}}else if(C==="boolean")z[E++]=x?195:194;else if(C==="bigint"){if(x<BigInt(1)<<BigInt(63)&&x>=-(BigInt(1)<<BigInt(63)))z[E++]=211,Ue.setBigInt64(E,x);else if(x<BigInt(1)<<BigInt(64)&&x>0)z[E++]=207,Ue.setBigUint64(E,x);else if(this.largeBigIntToFloat)z[E++]=203,Ue.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?z[E++]=192:(z[E++]=212,z[E++]=0,z[E++]=0);else if(C==="function")S(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+C)},P=this.useRecords===!1?this.variableMapSize?x=>{let C=Object.keys(x),T=C.length;T<16?z[E++]=128|T:T<65536?(z[E++]=222,z[E++]=T>>8,z[E++]=T&255):(z[E++]=223,Ue.setUint32(E,T),E+=4);let N;for(let O=0;O<T;O++)S(N=C[O]),S(x[N])}:(x,C)=>{z[E++]=222;let T=E-t;E+=2;let N=0;for(let O in x)(C||x.hasOwnProperty(O))&&(S(O),S(x[O]),N++);z[T+++t]=N>>8,z[T+t]=N&255}:x=>{let C=Object.keys(x),T,N=s.transitions||(s.transitions=Object.create(null)),O=0;for(let G=0,k=C.length;G<k;G++){let $=C[G];T=N[$],T||(T=N[$]=Object.create(null),O++),N=T}let A=N[Zi];if(A)A>=96&&h?(z[E++]=((A-=96)&31)+96,z[E++]=A>>5):z[E++]=A;else{A=s.nextId,A||(A=64),A<y&&this.shouldShareStructure&&!this.shouldShareStructure(C)?(A=s.nextOwnId,A<g||(A=y),s.nextOwnId=A+1):(A>=g&&(A=y),s.nextId=A+1);let G=C.highByte=A>=96&&h?A-96>>5:-1;N[Zi]=A,s[A-64]=C,A<y?(C.isShared=!0,s.sharedLength=A-63,i=!0,G>=0?(z[E++]=(A&31)+96,z[E++]=G):z[E++]=A):(G>=0?(z[E++]=213,z[E++]=114,z[E++]=(A&31)+96,z[E++]=G):(z[E++]=212,z[E++]=114,z[E++]=A),O&&(b+=w*O),v.length>=m&&(v.shift()[Zi]=0),v.push(N),S(C))}for(let G=0,k=C.length;G<k;G++)S(x[C[G]])},_=x=>{let C;if(x>16777216){if(x-t>gm)throw new Error("Packed buffer would be larger than maximum buffer size");C=Math.min(gm,Math.round(Math.max((x-t)*(x>67108864?1.25:2),4194304)/4096)*4096)}else C=(Math.max(x-t<<2,z.length-1)>>12)+1<<12;let T=new Sc(C);return Ue=new DataView(T.buffer,0,C),z.copy?z.copy(T,0,t,x):T.set(z.slice(t,x)),E-=t,t=0,vr=T.length-10,z=T}}useBuffer(r){z=r,Ue=new DataView(z.buffer,z.byteOffset,z.byteLength),E=0}};wc=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,Ki];Ba=[{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?xm(n,16,r):vm(Da?Buffer.from(n):new Uint8Array(n),r)}},{pack(n,r){let e=n.constructor;e!==bm&&this.structuredClone?xm(n,bc.indexOf(e.name),r):vm(n,r)}},{pack(n,r){let{target:e,position:t}=r(1);e[t]=193}}];function xm(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 vm(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 Cw(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 Iw(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 ao(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)");wc.unshift(n.Class),Ba.unshift(n)}ym(n)}var Sm=new No({useRecords:!1}),Mw=Sm.pack,Ew=Sm.pack;var{NEVER:Lw,ALWAYS:Bw,DECIMAL_ROUND:Dw,DECIMAL_FIT:Gw}=Ea,wm=512,Rw=1024;var _m=new No({structuredClone:!0});ao({Class:Me.prototype.constructor,type:1,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,Me.prototype),n}});ao({Class:he.prototype.constructor,type:2,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,he.prototype),n}});ao({Class:$e.prototype.constructor,type:3,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,$e.prototype),n}});ao({Class:Yi.prototype.constructor,type:4,write(n){return n.id},read(n){return new Yi(n)}});ao({Class:Xi.prototype.constructor,type:5,write(n){return n.data},read(n){return new Xi(n)}});ao({Class:Be.prototype.constructor,type:6,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,Be.prototype),n}});function Vw(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 _c(n){if(_n(n))return n;if(Array.isArray(n))return n.map(_c);if(typeof n=="object"&&n!==null){let r={};for(let e of Object.keys(n).sort())r[e]=_c(n[e]);return Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r}else return n}var Ga;(t=>{function n(o){return _m.pack(o)}t.serialize=n;function r(o){return _m.unpack(o)}t.deserialize=r;function e(o){return Vw(n(_c(o))).toString()}t.checksum=e})(Ga||(Ga={}));var Pm;(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})(Pm||(Pm={}));var lo;(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})(lo||(lo={}));var Tm;(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})(Tm||(Tm={}));var co;(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})(co||(co={}));var mt;(a=>{function n(d){return typeof d=="object"&&typeof d.r=="number"&&typeof d.g=="number"&&typeof d.b=="number"}a.isRGB=n,a.white={r:1,g:1,b:1},a.red={r:1,g:0,b:0},a.black={r:0,g:0,b:0};function o(d){return{r:Math.round(d.r*255),g:Math.round(d.g*255),b:Math.round(d.b*255),a:1}}a.toRgb255a1=o;function i(d){return{r:d.r,g:d.g,b:d.b}}a.clone=i;function s(d){return d=Math.floor(d),{r:(d>>16&255)/255,g:(d>>8&255)/255,b:(d&255)/255}}a.fromHex=s;function l(d){return Math.round(d.r*255)*65536+Math.round(d.g*255)*256+Math.round(d.b*255)}a.toHex=l;function c(d,p){return d.r===p.r&&d.g===p.g&&d.b===p.b}a.equals=c;function u(d,p,f){return{r:d.r+(p.r-d.r)*f,g:d.g+(p.g-d.g)*f,b:d.b+(p.b-d.b)*f}}a.lerp=u})(mt||(mt={}));var Gt;(l=>{l.white={...mt.white,a:1},l.transparent={...mt.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{...mt.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 mt.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})(Gt||(Gt={}));var Ra;(r=>r.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(Ra||(Ra={}));var Om;(r=>r.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(Om||(Om={}));var Am;(r=>r.defaultData={control1:[.5,0],control2:[.5,1]})(Am||(Am={}));var Nm;(i=>(i.linear=[0,0,1,1],i.ease=[.25,.1,.25,1],i.easeIn=[.42,0,1,1],i.easeOut=[0,0,.58,1],i.easeInOut=[.42,0,.58,1]))(Nm||(Nm={}));var Qt;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function r(t){return e.all.includes(t)}e.is=r})(Qt||(Qt={}));var Co;(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})(Co||(Co={}));var Sr;(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(zw.forEach(s=>{Object.assign(i,{[s]:o[s]??t[s]})}),i.radial={...t.radial},o.radial){let s=t.radial,l=o.radial;jw.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;Fw.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;kw.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;Uw.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;Hw.forEach(c=>{Object.assign(i.randomnessObject,{[c]:l[c]??s[c]})})}return i}e.merge=r})(Sr||(Sr={}));var Va;(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})(Va||(Va={}));var zw=["count"],jw=["radius","start","end","position","scale","rotation"],Fw=["position","scale","rotation"],kw=["count","size"],Uw=["count","position","scale","rotation"],Hw=["strength","scale","rotation","position","movement","seed","freqScale"];var za;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function r(t){return e.all.includes(t)}e.is=r})(za||(za={}));var ja;(e=>{function n(t){return r(t)}e.defaultData=n;function r(t){if(t==="PointLight")return{type:t,color:Gt.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,depth:1e5};if(t==="SpotLight")return{type:t,color:Gt.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:Gt.white,intensity:1,shadows:!0,size:2e3,depth:1e5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(ja||(ja={}));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 Tc;(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})(Tc||(Tc={}));var Fa;(r=>r.defaultData={...Tc.defaultData,...Pc.defaultData})(Fa||(Fa={}));var In;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(In||(In={}));var Cm;(r=>{function n(e){return e==="texture"||e==="video"||e==="color"||e==="depth"||e==="normal"||e==="gradient"||e==="noise"||e==="fresnel"||e==="rainbow"||e==="toon"||e==="outline"||e==="transmission"||e==="matcap"||e==="displace"||e==="pattern"||e==="light"}r.is=n})(Cm||(Cm={}));function Mm(n){return n.type!=="displace"}var Im;(r=>{function n(e){return e==="phong"||e==="toon"||e==="lambert"||e==="physical"}r.is=n})(Im||(Im={}));var Em=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],Lm=["wrapping","image","video"],xt;(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){let s={mode:0,isMask:!1,visible:!0};switch(i){case"phong":return{...s,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...s,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...s,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...s,category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0,occlusion:!0}}}function t(i){let s={alpha:1,mode:0,isMask:!1,visible:!0};switch(i){case"texture":return{...s,type:"texture",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{image:"image_0",wrapping:1e3,repeat:[1,1],offset:[0,0]},crop:!1};case"video":return{...s,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:In.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!1};case"color":return{...s,type:"color",color:mt.fromHex(5526619)};case"depth":return{...s,type:"depth",gradientType:1,smooth:!1,isVector:!0,isWorldSpace:!1,origin:[0,0,0],direction:[1,0,0],colors:[[1,1,1,1],[0,0,0,1]],steps:[0,1],near:50,far:200};case"normal":return{...s,type:"normal",cnormal:[1,1,1]};case"gradient":return{...s,type:"gradient",gradientType:0,smooth:!1,colors:[[0,0,0,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,1,1,1,1,1,1,1,1,1],num:2,angle:0,offset:[0,0],morph:[0,0]};case"noise":return{...s,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...mt.fromHex(6710886),a:1},colorB:{...mt.fromHex(6710886),a:1},colorC:{...mt.fromHex(16777215),a:1},colorD:{...mt.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8],voronoiStyle:0,highCut:1,lowCut:0,smoothness:.3,seed:0,quality:1};case"fresnel":return{...s,type:"fresnel",color:Gt.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{...s,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...s,type:"toon",positioning:2,colors:[[0,0,0,1],[.5,.5,.5,1],[.5,.5,.5,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,.475,.525,1,1,1,1,1,1,1],num:4,source:[0,1e3,0],isWorldSpace:!0,noiseStrength:0,noiseScale:1,shadowColor:Gt.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...s,type:"outline",outlineColor:Gt.fromHexAndA(0,1),contourColor:Gt.fromHexAndA(0,1),outlineWidth:2,contourWidth:5,outlineThreshold:.4,contourThreshold:0,outlineSmoothing:0,contourFrequency:10,contourDirection:[0,1,0],positionalLines:!1,compensation:!0};case"matcap":return{...s,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0]}};case"transmission":return{...s,type:"transmission",thickness:10,ior:1.5,roughness:1};case"displace":return{visible:!0,type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,voronoiStyle:0,smoothness:.3,seed:0,highCut:1,lowCut:0,quality:1};case"pattern":return{...s,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...mt.fromHex(0),a:1},colorB:{...mt.fromHex(16777215),a:1},frequency:[10,10],size:.5,variation:0,smoothness:.5,zigzag:0,rotation:0,vertical:[0,1],horizontal:[0,1],sides:6}}}})(xt||(xt={}));var Ot;(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 he}}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 he;return p.push({fi:0,data:xt.defaultData("light",u),id:a}),p.push({fi:1,data:xt.defaultData("color"),id:d}),{layers:p}}c.defaultTwoLayerData=i;function s(u,a="phong",d="layer1",p="layer2"){let f=xt.defaultData("texture");Object.assign(f.texture,{image:u});let m=new he;return m.push({fi:0,data:f,id:d}),m.push({fi:1,data:xt.defaultData("light",a),id:p}),{layers:m}}c.defaultTwoLayerTextureData=s;function l(u,a="phong",d="layer1",p="layer2"){let f=xt.defaultData("video");Object.assign(f.texture,{video:u});let m=new he;return m.push({fi:0,data:f,id:d}),m.push({fi:1,data:xt.defaultData("light",a),id:p}),{layers:m}}c.defaultTwoLayerVideoTextureData=l})(Ot||(Ot={}));var Mn;(r=>{function n(){return{points:new he,roundness:0,shapeHoles:[],isClosed:!1}}r.defaultData=n})(Mn||(Mn={}));var En;(r=>{function n(){return{points:new he,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}r.defaultData=n})(En||(En={}));var Oc={type:"Ellipse",width:100,height:100,spikes:64,angle:360,innerRadius:0};var ka;(r=>{function n(e,t){let o={...e};return qw.forEach(i=>{Object.assign(o,{[i]:t[i]??e[i]})}),o}r.merge=n})(ka||(ka={}));var Ua={shape:Oc,depth:1,offset:0,bevel:0,bevelSides:1,angle:0,twist:0,startScale:1,endScale:1},qw=["depth","offset","angle","twist","startScale","endScale"];var Qi;(e=>{function n(t){return t==="PolygonGeometry"||t==="RectangleGeometry"||t==="StarGeometry"||t==="TriangleGeometry"||t==="EllipseGeometry"}e.is2DParametricMesh=n;function r(t){return t==="PolygonGeometry"||t==="PolygonGeometry"||t==="RectangleGeometry"||t==="StarGeometry"||t==="TriangleGeometry"||t==="EllipseGeometry"||t==="PathGeometry"||t==="VectorGeometry"||t==="ConeGeometry"||t==="CubeGeometry"||t==="CylinderGeometry"||t==="DodecahedronGeometry"||t==="HelixGeometry"||t==="IcosahedronGeometry"||t==="LatheGeometry"||t==="PyramidGeometry"||t==="SphereGeometry"||t==="PlaneGeometry"||t==="BackdropGeometry"||t==="TorusGeometry"||t==="TorusKnotGeometry"||t==="BooleanGeometry"||t==="TextGeometry"}e.isParametricMesh=r})(Qi||(Qi={}));var Ha;(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,ka.merge(o.extrusion,t.extrusion))),o}r.merge=n})(Ha||(Ha={}));var uo;(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:En.defaultData(),extrusion:Ua};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};if(e==="SphereGeometry")return{type:"SphereGeometry",width:100,height:100,depth:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI};throw new Error("not implemented")}r.defaultData=n})(uo||(uo={}));var Bm;(e=>{function n(t){return t==="Component"||t==="Instance"}e.isComponentRelated=n;function r(t){return t==="Empty"||t==="Instance"}e.isEmptyOrComponent=r})(Bm||(Bm={}));var Ln;(o=>{o.identity={...Ra.identity,hiddenMatrix:co.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 wu({position:lo.isEqual(i.position,s.position)?void 0:s.position,rotation:lo.isEqual(i.rotation,s.rotation)?void 0:s.rotation,scale:lo.isEqual(i.scale,s.scale)?null:s.scale,hiddenMatrix:co.isEqual(i.hiddenMatrix,s.hiddenMatrix)?void 0:s.hiddenMatrix})}o.diff=t})(Ln||(Ln={}));var Dm;(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]})(Dm||(Dm={}));var Rt;(r=>r.defaultData={states:new he,events:new he,visible:!0,raycastLock:!1,collision:"visibility",physics:null,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...Ln.identity,cloner:null})(Rt||(Rt={}));var Gm;(r=>r.defaultData={type:"Empty",...Rt.defaultData})(Gm||(Gm={}));var Rm;(r=>r.defaultData={type:"Component",...Rt.defaultData})(Rm||(Rm={}));var Io;(r=>r.defaultData={type:"Mesh",...Rt.defaultData,...Fa.defaultData})(Io||(Io={}));var Bn;(r=>r.defaultData={...Rt.defaultData,...Ln.identity,...Co.defaultData})(Bn||(Bn={}));var Vm;(r=>{function n(e){return{...Rt.defaultData,...ja.defaultData(e)}}r.defaultData=n})(Vm||(Vm={}));var Dn;(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})(Dn||(Dn={}));var po;(i=>{i.rootOverrideProps=["physics"],i.compositeNonOptionalOverrideProps=["geometry"],i.compositeEntireOverrideOverrideProps=["material"];function t(s,l){return{...Rt.defaultData,...l,component:s,overrides:new Be,physics:void 0,type:"Instance"}}i.ofComponent=t;function o(s){let l=Ln.fromObject(s.data);return t(s.id,l)}i.fromComponentData=o})(po||(po={}));var zm;(i=>(i.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:co.identity,name:"Play Camera",visible:!0,raycastLock:!1,collision:"visibility",physics:null,states:new he,events:new he,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...Co.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",...Rt.defaultData,...Io.defaultData,geometry:uo.defaultData("RectangleGeometry"),material:Ot.defaultTwoLayerData("phong","layer1","layer2")},i.defaultBooleanObject={name:"Boolean",...Rt.defaultData,...Io.defaultData,geometry:uo.defaultData("BooleanGeometry"),material:Ot.defaultTwoLayerData("phong","layer1","layer2")},i.defaultTextObject={name:"Text",...Rt.defaultData,...Io.defaultData,geometry:uo.defaultData("TextGeometry"),material:Ot.defaultTwoLayerData("phong","layer1","layer2")}))(zm||(zm={}));var Mo;(o=>{function n(i,s){let l={name:s};return i.type==="Mesh"?(l.geometry={},"material"in i&&(l.material={layers:new Be}),"materials"in i&&(l.materials=i.materials.map(c=>({layers:new Be})))):Qt.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=Nn(l.material,c=>{if(typeof c!="string")for(let[u,a]of Object.entries(s.material.layers)){let d=c.layers.data(u);d&&xt.patch(d,a)}}).data),l.materials&&s.materials&&(l.materials=Nn(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&&xt.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(...Va.toOps(p,["cloner"]));else if(d==="pathSnapping")c.push({path:[d],props:{slide:p.slide,offset:p.offset},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,Ln.merge(l,s)),Object.assign(l,{pathSnapping:Object.assign({},l.pathSnapping,{slide:s.pathSnapping?.slide??l.pathSnapping?.slide??0,offset:s.pathSnapping?.offset??l.pathSnapping?.offset??0})}),Qt.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:Ha.merge(l.geometry,s.geometry)}),(s.material||s.materials)&&(l=r(l,s)),l.cloner&&"cloner"in s&&Object.assign(l,{cloner:Sr.merge(l.cloner,s.cloner)});else if(i.type==="Empty")l.cloner&&"cloner"in s&&Object.assign(l,{cloner:Sr.merge(l.cloner,s.cloner)});else if(za.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=mt.clone(c.color))}return l}o.patch=t})(Mo||(Mo={}));var Gn;(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})(Gn||(Gn={}));var qa;(r=>r.defaultData={orbitControls:Gn.defaultData,playCamera:null,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",settings:{image:{format:"jpg",ratio:1},video:{format:"mp4",imageFormat:"jpg",fps:30,mbps:80,ratio:Math.max(1,typeof window<"u"?Math.floor(window.devicePixelRatio):1),stopMode:"manual",duration:5e3},web:{logo:!0,compress:!0,preset:1,preload:!0,hint:!1}},stopRaycast:!0,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,hdTransmission:!1})(qa||(qa={}));var Ac;(r=>r.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(Ac||(Ac={}));var Nc;(r=>r.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(Nc||(Nc={}));var Wa;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...Ac.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:Nc.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(Wa||(Wa={}));var Rn;(r=>r.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII="})(Rn||(Rn={}));var $a;(t=>{function n(){let o={};return o["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},Vr(o,Me.prototype)}t.defaultColors=n;function r(o){let i={};return o?.withAITexture&&(i["a1b10010-844c-a8a3-11ec-0242ac2011ec"]={...Rn.emptyImage,name:"AI generated image"}),Vr(i,Me.prototype)}t.defaultImages=r;function e(){return{materials:new Me,images:new Me,videos:new Me,colors:new Me,audios:new Me,fonts:new Me,penumbraSize:[2,2,2]}}t.emptyData=e})($a||($a={}));import{MathUtils as Xa}from"three";var Ya;(e=>(e.defaultColliderData={type:"capsule",height:200,radius:50,position:[0,0,0],rotation:[0,0,0]},e.defaultDataThirdPerson={moveMode:"walk",speedTranslate:1e3,speedRotate:100,rotationMode:"normal",rotBy:"keys",rotByTouch:"drag",delayPos:[.3,.3],delayRot:[.3,.3],keyAssignments:[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","\u25B2"],["rotPosY","\u25C0"],["rotNegX","\u25BC"],["rotNegY","\u25B6"],["jump","Space"]],touchControl:!0,joystickPosLoc:5,joystickRotLoc:11,jumpTouchButtonLoc:9,collider:e.defaultColliderData,colliderHelperVisible:!0,collisionEnabled:!0,jumpPower:100,resetYPosition:3e3,alignToGround:!1,autoOrientMove:!0,orientWith:"camera",orientMode:"radial",delayPosCamera:.3,delayRotCamera:.3,camera:"",cameraXAxis:"Limit",cameraYAxis:"Free",cameraRotXLimits:[0,Math.PI/2],cameraRotYLimits:[-Math.PI/2,Math.PI/2],gameActions:{idle:new he,move:new he,jump:new he},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:Gt.fromHexAndA(3728051,1)}}))(Ya||(Ya={}));function jm(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={...bn(Qe(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={...Qe(r),near:Math.max(r.near,0),far:Math.max(r.far,0)};Object.assign(r,e)}})}function Vn(n,r){Object.values(n.shared.materials).forEach(e=>r(e))}function zn(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 Ww(n){Object.assign(n.scene.publish,{orbitControls:{...Gn.defaultData,...Qe(n.scene.publish.orbitControls)}})}function $w(n){Object.assign(n.scene.publish.settings,{video:{...qa.defaultData.settings.video,...Qe(n.scene.publish.settings.video)}})}function Yw(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((Em.includes(o)||typeof i=="boolean")&&delete t[o],o==="texture")for(let[s,l]of Object.entries(i))(Lm.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 Xw(n){n.scene.publish.withBackground=!0}function Kw(n){n.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function Zw(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 Qw(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 Jw(n){n.scene.objects.traverse((r,e)=>{let t=n.scene.objects.unproxy().parent(r);if(t){let o=Qe(n.scene.objects.data(t));o&&o.type==="Mesh"&&o.geometry.type==="BooleanGeometry"&&e.type==="Mesh"&&(e.visible=Qe(e).booleanExclude!==!0)}})}function e_(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 t_(n){function r(t){Object.setPrototypeOf(t,Be.prototype),t.texture&&Object.setPrototypeOf(t.texture,Be.prototype)}function e(t){Object.setPrototypeOf(t,Be.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=Qe(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=Qe(c).layers;e(u),c.layers=u}})})}function Fm(n){n.layers===void 0&&Object.assign(n,Ot.defaultTwoLayerData("lambert"))}function Cc(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={...Qe(r),colors:e,steps:t};Object.assign(r,o)}})}function r_(n){n.scene.objects.traverse((r,e)=>{e.type==="Mesh"&&(e.geometry.type==="BooleanGeometry"||e.geometry.type==="SubdivGeometry")&&(e.geometry.phongAngle=35)})}function km(n){n.scene.objects.traverse((r,e)=>{"materials"in e?e.materials.forEach(t=>{typeof t!="string"&&Cc(t)}):"material"in e&&typeof e.material!="string"&&Cc(e.material)}),Object.values(n.shared.materials).forEach(r=>Cc(r))}function o_(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 n_(n){n.shared.audios=Vr({},Me.prototype)}function i_(n){n.shared.videos=Vr({},Me.prototype)}function s_(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 a_(n){Object.entries(Qe(n.shared.images)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete n.shared.images[t]}),Object.entries(Qe(n.shared.audios)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete n.shared.audios[t]})}function l_(n){n.scene.publish.settings.web.preload=!1}function Um(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 Hm(n){n.layers&&n.layers.forEach(r=>{Mm(r)&&r.isMask===void 0&&(r.isMask=!1),(r.type==="texture"||r.type==="video")&&r.blending===void 0&&(r.blending=0),(r.type==="noise"||r.type==="displace"&&r.displacementType==="noise")&&(r.voronoiStyle===void 0&&(r.voronoiStyle=0),r.highCut===void 0&&(r.highCut=1),r.lowCut===void 0&&(r.lowCut=0),r.smoothness===void 0&&(r.smoothness=.3),r.seed===void 0&&(r.seed=0),r.quality===void 0&&(r.quality=1))})}function c_(n){n.shared.fonts=Vr({},Me.prototype)}function d_(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 u_(n){let r=[];n.scene.objects.traverse((e,t)=>{let o=t;if(o.type==="TextFrame"){let i=Ot.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=d_(o.font);n.shared.fonts[l]===void 0&&(n.shared.fonts[l]={name:l});let c={name:o.name,...Rt.defaultData,...Io.defaultData,flatShading:!1,wireframe:!1,geometry:{...uo.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:Qe(o.states),events:Qe(o.events),visible:o.visible,raycastLock:o.raycastLock,position:o.position,rotation:o.rotation,scale:o.scale,hiddenMatrix:o.hiddenMatrix},u=Qe(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 p_(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 he,move:new he,jump:new he}});else{let i=new he;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:Xa.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,bn(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 he({fi:0,id:Xa.generateUUID(),data:u},{fi:1,id:Xa.generateUUID(),data:p})};i.push({fi:c,id:l,data:f})}),delete o.targets)}})})}function f_(n){n.scene.objects.traverse((r,e)=>{function t(o,i){let s=new he,l=[];if(e.events.forEach((c,u,a)=>{if(c.type==="Audio"&&c.trigger===i){let d;l.push(u),c.interaction==="play"?d={...bn(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={...bn(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:Xa.generateUUID(),data:{type:o,actions:s}}])}}t("Start","start"),t("MouseDown","mouseDown"),t("MouseUp","mouseUp"),t("KeyDown","keyDown"),t("KeyUp","keyUp")})}function qm(n){let r=n.layers.find(e=>e.type==="light")?.data;if(r?.category==="basic"){let e=xt.defaultData("light","phong"),t=r;Object.assign(t,e),t.visible=!1}}function Wm(n){Vn(n,qm),zn(n,qm)}function m_(n){n.scene.objects.traverse((r,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(e.geometry.scaleBaked||(e.geometry.scaleBaked=[1,1,1]))})}function h_(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 y_(n){n.scene.objects.traverse((r,e)=>{e.type==="Mesh"&&e.geometry.type==="NonParametricGeometry"&&!("material"in e)&&!("materials"in e)&&(e.material=Ot.defaultTwoLayerData("phong"))})}function g_(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 x_(n){n.scene.objects.traverse((r,e)=>{e.pathSnapping===void 0&&(e.pathSnapping={pathId:null,slide:0,offset:0,orientation:"tangential"}),e.pathSnapping.offset===void 0&&(e.pathSnapping.offset=0)})}function v_(n){n.scene.publish.mouseEventTarget===void 0&&(n.scene.publish.mouseEventTarget="canvas"),n.scene.publish.settings.web.hint===void 0&&(n.scene.publish.settings.web.hint=!1)}function b_(n){let{video:r}=n.scene.publish.settings;r.format==="gif"&&r.fps>48&&(r.fps=15)}function S_(n){n.scene.objects.traverse((r,e)=>{e.events.forEach(t=>{t.type==="GameControl"&&(t.resetYPosition=Math.abs(t.resetYPosition-e.position[1]))})})}function w_(n){let r=n.scene.environment.usePhysics;n.scene.objects.traverse((e,t)=>{r&&t.physics===null?t.collision=!1:t.collision="visibility"})}function __(n){n.scene.objects.traverse((r,e)=>{e.events.forEach(t=>{t.type==="GameControl"&&(t.navmesh=Ya.defaultDataThirdPerson.navmesh)})})}function P_(n){n.scene.styles||(n.scene.styles=Wa.defaultData())}function $m(n){n.layers.forEach(r=>{r.type==="light"&&r.category!=="toon"&&r.occlusion===void 0&&(r.occlusion=!0)})}function T_(n){n.scene.environment.ambientLight.occlusion===void 0&&(n.scene.environment.ambientLight.occlusion=!1),n.scene.environment.ambientLight.aoFullRes===void 0&&(n.scene.environment.ambientLight.aoFullRes=!1),n.scene.environment.ambientLight.radius===void 0&&(n.scene.environment.ambientLight.radius=256),n.scene.environment.ambientLight.bias===void 0&&(n.scene.environment.ambientLight.bias=.5),n.scene.environment.ambientLight.aoColor===void 0&&(n.scene.environment.ambientLight.aoColor={r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}),zn(n,$m),Vn(n,$m)}var Ym=41;function Xm(n){let r=n.schema??0;r!==Ym&&(console.warn("updating from ",r,"to ",Ym),r<1&&(zn(n,jm),Vn(n,jm),n.schema=1),r<2&&(Ww(n),n.schema=2),r<3&&(Yw(n),n.schema=3),r<4&&(Xw(n),n.schema=4),r<5&&(Kw(n),n.schema=5),r<6&&(Zw(n),n.schema=6),r<7&&(Qw(n),n.schema=7),r<8&&(n.schema=8),r<9&&(km(n),n.schema=9),r<10&&(r_(n),n.schema=10),r<11&&(o_(n),n.schema=11),r<12&&(km(n),n.schema=12),r<13&&(n_(n),n.schema=13),r<14&&(s_(n),n.schema=14),r<15&&(a_(n),n.schema=15),r<16&&(l_(n),n.schema=16),r<17&&(zn(n,Um),Vn(n,Um),n.schema=17),r<18&&(zn(n,Fm),Vn(n,Fm),n.schema=18),r<19&&($w(n),n.schema=19),r<20&&(c_(n),u_(n),n.schema=20),r<21&&(p_(n),f_(n),n.schema=21),r<22&&(Wm(n),n.schema=22),r<23&&(m_(n),n.schema=23),r<24&&(h_(n),n.schema=24),(r<25||n.shared.videos===void 0)&&(i_(n),r<25&&(n.schema=25)),r<26&&(Jw(n),n.schema=26),r<27&&(e_(n),n.schema=27),r<28&&(Wm(n),n.schema=28),r<29&&(t_(n),n.schema=29),r<30&&(y_(n),n.schema=30),r<31&&(g_(n),n.schema=31),r<33&&(x_(n),n.schema=33),r<34&&(v_(n),n.schema=34),r<35&&(b_(n),n.schema=35),r<36&&(S_(n),n.schema=36),r<37&&(w_(n),n.schema=37),r<38&&(zn(n,Hm),Vn(n,Hm),n.schema=38),r<39&&(__(n),n.schema=39),r<40&&(P_(n),n.schema=40),r<41&&(T_(n),n.schema=41))}var Mi=$s(Zm());import{Object3D as XO,Vector3 as jt,Euler as su,MathUtils as mg,Matrix4 as Xo}from"three";var O_=.5*(Math.sqrt(3)-1),ts=(3-Math.sqrt(3))/6,A_=1/3,wr=1/6,$R=(Math.sqrt(5)-1)/4,YR=(5-Math.sqrt(5))/20,rs=n=>Math.floor(n)|0,Qm=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]),Mc=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 Ka(n=Math.random){let r=eh(n),e=new Float64Array(r).map(o=>Qm[o%12*2]),t=new Float64Array(r).map(o=>Qm[o%12*2+1]);return function(i,s){let l=0,c=0,u=0,a=(i+s)*O_,d=rs(i+a),p=rs(s+a),f=(d+p)*ts,m=d-f,h=p-f,y=i-m,g=s-h,v,b;y>g?(v=1,b=0):(v=0,b=1);let w=y-v+ts,S=g-b+ts,P=y-1+2*ts,_=g-1+2*ts,x=d&255,C=p&255,T=.5-y*y-g*g;if(T>=0){let A=x+r[C],G=e[A],k=t[A];T*=T,l=T*T*(G*y+k*g)}let N=.5-w*w-S*S;if(N>=0){let A=x+v+r[C+b],G=e[A],k=t[A];N*=N,c=N*N*(G*w+k*S)}let O=.5-P*P-_*_;if(O>=0){let A=x+1+r[C+1],G=e[A],k=t[A];O*=O,u=O*O*(G*P+k*_)}return 70*(l+c+u)}}function Jm(n=Math.random){let r=eh(n),e=new Float64Array(r).map(i=>Mc[i%12*3]),t=new Float64Array(r).map(i=>Mc[i%12*3+1]),o=new Float64Array(r).map(i=>Mc[i%12*3+2]);return function(s,l,c){let u,a,d,p,f=(s+l+c)*A_,m=rs(s+f),h=rs(l+f),y=rs(c+f),g=(m+h+y)*wr,v=m-g,b=h-g,w=y-g,S=s-v,P=l-b,_=c-w,x,C,T,N,O,A;S>=P?P>=_?(x=1,C=0,T=0,N=1,O=1,A=0):S>=_?(x=1,C=0,T=0,N=1,O=0,A=1):(x=0,C=0,T=1,N=1,O=0,A=1):P<_?(x=0,C=0,T=1,N=0,O=1,A=1):S<_?(x=0,C=1,T=0,N=0,O=1,A=1):(x=0,C=1,T=0,N=1,O=1,A=0);let G=S-x+wr,k=P-C+wr,$=_-T+wr,ee=S-N+2*wr,Y=P-O+2*wr,W=_-A+2*wr,H=S-1+3*wr,V=P-1+3*wr,R=_-1+3*wr,B=m&255,L=h&255,D=y&255,X=.6-S*S-P*P-_*_;if(X<0)u=0;else{let M=B+r[L+r[D]];X*=X,u=X*X*(e[M]*S+t[M]*P+o[M]*_)}let q=.6-G*G-k*k-$*$;if(q<0)a=0;else{let M=B+x+r[L+C+r[D+T]];q*=q,a=q*q*(e[M]*G+t[M]*k+o[M]*$)}let j=.6-ee*ee-Y*Y-W*W;if(j<0)d=0;else{let M=B+N+r[L+O+r[D+A]];j*=j,d=j*j*(e[M]*ee+t[M]*Y+o[M]*W)}let F=.6-H*H-V*V-R*R;if(F<0)p=0;else{let M=B+1+r[L+1+r[D+1]];F*=F,p=F*F*(e[M]*H+t[M]*V+o[M]*R)}return 32*(u+a+d+p)}}function eh(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}import{Triangle as N_}from"three";var er=new N_,Za=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;er.a.fromBufferAttribute(r,o),er.b.fromBufferAttribute(r,o+1),er.c.fromBufferAttribute(r,o+2),i*=er.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),er.a.fromBufferAttribute(this.positionAttribute,r*3),er.b.fromBufferAttribute(this.positionAttribute,r*3+1),er.c.fromBufferAttribute(this.positionAttribute,r*3+2),e.set(0,0,0).addScaledVector(er.a,o).addScaledVector(er.b,i).addScaledVector(er.c,1-(o+i)),er.getNormal(t),this}};import{Object3D as L_}from"three";var oh=$s(rh());import{Object3D as C_,Matrix4 as _r}from"three";var I_=new _r,M_=new _r,E_=new _r,os;(r=>{function n(e){return e&&e.__isSPEObject}r.is=n})(os||(os={}));var jn=n=>class extends n{constructor(){super(...arguments);this.previousModelViewMatrix=new _r;this.copyPreviousMatrix=!0;this.hiddenMatrix=new _r;this.matrixWorldRigid=new _r;this.shearScale=new _r;this.shearScaleInv=new _r}get __isSPEObject(){return!0}isDescendantOf(t){t instanceof C_&&(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)os.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,oh.SVD)(o),c=I_.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=M_.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=E_.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 _r().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),i.multiply(t.parent.matrixWorld)),"hiddenMatrix"in t&&t.hiddenMatrix instanceof _r?t.hiddenMatrix.premultiply(i):t.applyMatrix4(i),t.updateWorldMatrix(!1,!1),this.add(t),o!==void 0&&(this.children.pop(),this.children.splice(o,0,t)),this}copy(t,o=!1){return super.copy(t,o),this.hasNonUniformScale=t.hasNonUniformScale,this}onAfterRender(t,o,i,s,l,c){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}};var Ec=class extends jn(L_){},B_=n=>n.type==="Mesh",Wr=class extends Ec{constructor(e){super();this.object=e;this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,t){}expand(){let e=0,t=this.object.entityChildren(e);for(;t;){let o=this.children[e];o?.object!==t&&(o&&this.remove(o),o=new Wr(t),this.add(o),this.children.splice(e,0,this.children.pop()),o.matrixWorldNeedsUpdate=!0,o.matrixAutoUpdate=!1,o.matrix=t.matrix,o.hiddenMatrix=t.hiddenMatrix),o.expand(),e+=1,t=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e])}get visible(){return this.playModeVisible!==void 0?this.playModeVisible:this.object.visible||this.object.dataPatched.visible&&this.object.dataPatched.cloner?.hideBase===!0}set visible(e){}get castShadow(){return this.object.castShadow}set castShadow(e){}get receiveShadow(){return this.object.receiveShadow}set receiveShadow(e){}get isMesh(){return B_(this.object)}get isLight(){return this.object.isLight}get layers(){return this.object.layers}set layers(e){}get isCamera(){return!1}get geometry(){if(this.object.geometry)return this.object.geometry}get material(){if(this.object.material)return this.object.material}};import{Box3 as ST,BufferGeometry as wT,MeshBasicMaterial as _T}from"three";import{Matrix4 as vT,Mesh as bT}from"three";import{Matrix4 as el,Vector3 as j_,Euler as F_}from"three";import{Box3 as D_,Line3 as G_,Matrix4 as Lc,Vector3 as Vt}from"three";var Eo=new Vt,Lo=new Vt,Fn=new Lc,ih=[new Vt(-1,1,1),new Vt(-1,-1,1),new Vt(1,-1,1),new Vt(1,1,1),new Vt(-1,1,-1),new Vt(-1,-1,-1),new Vt(1,-1,-1),new Vt(1,1,-1)],R_=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],V_=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],nh=(n,r,e)=>{n.updateEntityBoxSize(Eo,Lo),Fn.copy(r).multiply(n.matrixWorld),Lo.x===0&&Lo.y===0&&Lo.z===0?e.push(new Vt(Eo.x,Eo.y,Eo.z).applyMatrix4(Fn)):ih.forEach(t=>{e.push(t.clone().multiply(Lo).add(Eo).applyMatrix4(Fn))})},ns=class extends D_{constructor(){super(...arguments);this.matrix=new Lc;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 Lc().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,o,t)}expandByObjectSize(e,t,o=!1){let i=[];return o===!0?e.traverseEntity(s=>{if(s.visible||s.cloner&&s.data.visible){if(!("geometry"in s)){i.push(new Vt);return}nh(s,t,i)}}):nh(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(Fn.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(Lo).multiplyScalar(.5),this.getCenter(Eo),Fn.copy(this.matrix).setPosition(Eo),this.vertices=ih.map(e=>e.clone().multiply(Lo).applyMatrix4(Fn))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=R_.map(([e,t])=>new G_(this.vertices[e],this.vertices[t])),this.centerEdges=this.edges.map(e=>e.getCenter(new Vt))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=V_.map(([e,t])=>this.vertices[e].clone().add(this.vertices[t]).multiplyScalar(.5))}};var tr={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}};import{CurvePath as z_,CubicBezierCurve3 as Bc,Vector3 as rr}from"three";var Gc=class extends z_{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 Rc=.001;function Vc(n,r,e){return r.clone().sub(n).cross(r.clone().sub(e)).length()<=Rc}function Dc(n,r){let e=new rr(...n.position),t=new rr(...n.controlNext.position),o=new rr(...r.controlPrevious.position),i=new rr(...r.position);return Vc(e,t,i)&&Vc(e,o,i)}function Ja(n){let r=n.points.map(a=>new rr(...a.data.position)),e=[n.points[0]],t=new rr(...e[0].data.position);for(let a=0;a<n.points.length-1;a++)Vc(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 rr(...d.position),f=new rr(...d.controlPrevious.position),m=new rr(...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,b=e[g].data,w=new rr(...v.position),S=new rr(...b.position),P=w.clone().sub(p).normalize(),_=S.clone().sub(p).normalize();Object.assign(h,{prevDir:P,nextDir:_});let x=Dc(v,d),C=Dc(d,b);if(!x||!C)l[a]={...h,removedLength:0};else{let T=P.clone().add(_).normalize(),N=T.clone().cross(P).length()/P.dot(T);l[a]={...h,tan:N,removedLength:d.roundness/N}}}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(!Dc(e[d].data,e[p].data))f.position.distanceTo(m.position)>Rc&&(h=new Bc(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)>Rc&&(h=new Bc(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,b=y.clone().multiplyScalar(Math.sqrt(Math.pow(h,2)-Math.pow(v,2))).add(g),w=y.clone().multiplyScalar(-h).add(b),S=p.distanceTo(w)/p.distanceTo(g),P=d.prevDir.clone().multiplyScalar(S*p.distanceTo(f)).add(p),_=P.clone().lerp(w,2),x=f.clone().lerp(P,4/3),C=m.clone().lerp(_,4/3);c[2*a]=new Bc(f,x,C,m)}let u=new Gc;return c.forEach(a=>{a&&u.add(a)}),u}var Ie;(r=>{function n(e){return e&&e.__isEntity}r.is=n})(Ie||(Ie={}));var is=n=>Ie.is(n),k_={type:"completeState",isfromEntity:!0},tl=n=>class extends jn(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 ns;this._recursiveBBox=new ns;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this._needApplyPathSnapping=!0;this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(t){let o=this.children[t];if(Ie.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(Ie.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=wa.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=Mo.patch(this.data,s),Mo.toOps(this.data,s).forEach(c=>{this.updateByPatchedOp(c,this.dataPatched,o)}))}i&&this.updateTransformState(this.dataPatched),this.stateSelection=t,this.updatePathSnapping(this.dataPatched.pathSnapping)}}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges(),this._singleBBox.computeFaces()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges(),this._recursiveBBox.computeFaces()),this._recursiveBBox}updateEntityBoxSize(t,o){t.setScalar(0),o.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(t=>{is(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(Ie.is(o[i]))return o[i];if(Ie.is(t))return t.traverseSortNextHelper()}}sortNext(){let t=this.children;return this.children.length>0&&Ie.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)is(o)&&t(o)}traverseEntityAncestors(t){this.traverseAncestors(o=>{Ie.is(o)&&t(o)})}traverseEntity(t,o=0){if(t(this,o)!==!0)for(let s of this.children)is(s)&&s.traverseEntity(t,o+1)}traverseVisibleEntity(t){t(this);for(let o of this.children)is(o)&&o.visible&&o.traverseVisibleEntity(t)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}copy(t,o=!1){return super.copy(t,o),this.dataPatched=t.dataPatched,this.raycastLock=t.raycastLock,this.scaleLock=t.scaleLock,this.hiddenMatrix.copy(t.hiddenMatrix),this}hasEntityChild(){return this.children.some(t=>is(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 vn(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??co.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)Ie.is(t)&&t.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(t=>{Ie.is(t)&&t.disposeRecursively()})}toState(t=[]){let o={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(t)};return vn(o,t)}updateByOp(t,o,i,s){let l=this.data;this.data=o;let c=t,u=Zt(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=yt.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=yt.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),Zt(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(Hr.apply(f.component.data,f.overrideData),i))}}else{let p=i.scene.findInstance([this.uuid,...a]);if(p){let f=yt.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=Dn.resolve(o.overrides,a),p.updateByOp(t,lt.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 po.rootOverrideProps)p in t.props&&(d===void 0&&(d={}),d[p]=t.props[p]);d&&(a={...t,props:d})}else for(let d of po.rootOverrideProps)if(Zt(t.path,[d])){a=t;break}a!==void 0&&this.instances.forEach(d=>{if(d.isInstanceRoot){let p=Hr.filterOp(d.overrideData,a);p&&d.updateByOp(p,lt.applySimple(d.data,p),i,!0)}}),this.instances.forEach(d=>{if(!d.isInstanceRoot){let p=Hr.filterOp(d.overrideData,t);if(p){let f;l===d.data&&t===p?f=o:f=lt.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&&!Qt.is(t.props.type)&&tr.changeEntityProptotype(this,o,i);else if(t.path.length===1&&t.path[0]==="geometry"&&t.type===0&&"type"in t.props){tr.changeEntityProptotype(this,o,i);for(let s of this.children)Ie.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),Zt(t.path,["pathSnapping"])!==null&&this.updatePathSnapping(o.pathSnapping),Zt(t.path,["cloner"])!==null){let s=lt.drop(t,1);s.path.length===0&&s.type===0&&s.props.disabled===!0?this.setFromClonerState(null,i):this.cloner?this.cloner.updateState(o.cloner,i.scene):(this.setFromClonerState(o.cloner,i),this.expandCloner(i.scene)),this.updateVisible()}}updatePathSnapping(t){this._updatedPathSnapping=t,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(t){let o=this._updatedPathSnapping?.pathId??this.dataPatched.pathSnapping.pathId,i=this._updatedPathSnapping?.slide??this.dataPatched.pathSnapping.slide??0,s=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset,l=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(o===null)return;let c=t.find(o);if(!c||this._needApplyPathSnapping===!1)return;this._needApplyPathSnapping=!1;let u=c.data,a=Ja(u.geometry.path),d=(i+s)%1;i+s===1&&d===0&&(d=1);let p=a.getPointAt(d),f=this.parent?this.parent?.matrixWorld:new el;c.updateMatrixWorld();let m=new el().multiplyMatrices(f.clone().invert(),c.matrixWorld);p.applyMatrix4(m);let h={position:p.toArray(),rotation:u.rotation};if(l==="tangential"){let y=new el().extractRotation(c.matrixWorld),g=a.getTangentAt(d).applyMatrix4(y).add(p),v=new el().lookAt(p,g,new j_(0,1,0)),b=new F_().setFromRotationMatrix(v);h={...h,rotation:[b.x,b.y,b.z]}}this.updateTransformState(h),this.traverseEntity(y=>{y._cameraType&&y.dispatchEvent(k_)})}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 tr.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 tr.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)}};import{ConeGeometry as q_}from"three";import{BufferGeometry as U_,CylinderGeometry as H_,Float32BufferAttribute as zc,Vector2 as or,Vector3 as rl}from"three";var ah=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},n.parameters),t=e.width/2,o=e.radiusTop??t,i=e.radiusBottom??t;return o===i?(o=t,i=t):o>i?(o=t,i=i*t/o):(o=o*t/i,i=t),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),radiusTop:o,radiusBottom:i})}}static build(n){let{width:r,depth:e,height:t,radialSegments:o,heightSegments:i,openEnded:s,thetaStart:l,thetaLength:c,radiusTop:u,radiusBottom:a,cornerRadius:d,cornerSegments:p,hollow:f}=n.parameters,m;return d||f?m=new ss(u,a,t,o,i,s,l,c*Math.PI/180,d,d,p,f):m=new H_(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 fo(n,r,e){e.x=n.x*r.x,e.y=n.y,e.z=n.x*r.y}function sh(n){return new or(n.y,-n.x)}var ss=class extends U_{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,b=t/2,w=new rl,S=new rl;f&&r==0&&(r=u),f&&e==0&&(e=a);let P=new or(r,b),_=new or(e,-b),x=null,C=null,T=null,N=null,O=P.clone().sub(_),A=0,G=0,k=0;p>0&&(A=Math.min(r,e)*(1-p),G=r-A,k=e-A);let $=P.clone();$.x-=A;let ee=Math.PI-O.angle(),Y=O.angle(),W=Math.tan(Y/2),H=Math.tan(ee/2),V=W+H,R=p?V:H,B=p?V:W;if(u=Math.min(u,(r-G)/R,O.length()/V),a=Math.min(a,(e-k)/B,O.length()/V),u>0){let F=u/W;x=P.clone().sub(new or(F,u)),p&&(T=x.clone(),T.x-=A-V*u),P.sub(O.clone().setLength(F))}if(a>0){let F=a/H;C=_.clone().sub(new or(F,-a)),_.add(O.clone().setLength(F)),p&&(N=C.clone(),N.x-=A-V*a,$.sub(O.clone().setLength(F)))}O=P.clone().sub(_);let L=O.length()<.5,D=[];for(let F=0;F<=o;F++){let M=[],Q=F/o,re=Q*c+l,oe=new or(Math.sin(re),Math.cos(re));N&&C?(X(M,Q,oe,ee,a,N,-1,!0),X(M,Q,oe,Y,a,C,-1,!1)):C?(q(M,oe,C.x,0,-1),X(M,Q,oe,Y,a,C,-1,!1)):s||q(M,oe,e,k,-1);let K=sh(O).normalize();if(fo(K,oe,w),!L)for(let te=0;te<=i;te++){let J=te/i,ie=O.clone().multiplyScalar(J).add(_);fo(ie,oe,S),h.push(S.x,S.y,S.z),y.push(w.x,w.y,w.z),g.push(Q,.5+S.y/t),M.push(v++)}if(T&&x?(X(M,Q,oe,ee,u,x,1,!1),X(M,Q,oe,Y,u,T,1,!0)):x?(X(M,Q,oe,ee,u,x,1,!1),q(M,oe,x.x,0,1)):s||q(M,oe,r,G,1),p&&!L){let te=sh(O).multiplyScalar(-1).normalize();fo(te,oe,w);for(let J=0;J<=i;J++){let ie=J/i,ce=O.clone().multiplyScalar(-ie).add($);fo(ce,oe,S),h.push(S.x,S.y,S.z),y.push(w.x,w.y,w.z),g.push(Q,.5+S.y/t),M.push(v++)}}p&&!s&&M.push(M[0]),D.push(M)}for(let F=0;F<D.length-1;F++)for(let M=0;M<D[0].length-1;M++){if(s&&p&&M==i)continue;let Q=D[F][M],re=D[F+1][M],oe=D[F+1][M+1],K=D[F][M+1],te=h[oe*3+0],J=h[oe*3+2];m.push(Q,re,K),(te!=0||J!=0)&&m.push(re,oe,K)}c<Math.PI*2&&(j(-1,D[0],l),j(1,D[D.length-1],l+c)),this.setIndex(m),this.setAttribute("position",new zc(h,3)),this.setAttribute("normal",new zc(y,3)),this.setAttribute("uv",new zc(g,2));function X(F,M,Q,re,oe,K,te,J){for(let ie=0;ie<d+1;ie++){let ce=ie/d,se=te<0?ce:1-ce;J&&(se-=1),se*=re;let fe=new or(Math.sin(se),Math.cos(se)*te),Re=fe.clone().multiplyScalar(oe).add(K);fo(Re,Q,S),h.push(S.x,S.y,S.z),fo(fe,Q,w),y.push(w.x,w.y,w.z),g.push(M,.5+S.y/t),F.push(v++)}}function q(F,M,Q,re,oe){let K=new rl,te=new or,J=[Q,re];oe<0&&J.reverse();for(let ie of J)te.set(ie,b*oe),fo(te,M,K),h.push(K.x,K.y,K.z),y.push(0,oe,0),g.push(.5,.5),F.push(v++)}function j(F,M,Q){let re=new or(Math.sin(Q),Math.cos(Q)),oe=new or(-Math.cos(Q),Math.sin(Q)),K=new rl,te=F<0?(ce,se,fe)=>m.push(ce,se,fe):(ce,se,fe)=>m.push(ce,fe,se),J=new or((r+e+G+k)/4,0);fo(J,re,K),h.push(K.x,K.y,K.z),y.push(oe.x,0,oe.y),g.push(.5,.5);let ie=v++;for(let ce of M){let se=h.slice(ce*3,ce*3+3);h.push(...se),y.push(oe.x,0,oe.y);let fe=g.slice(ce*2,ce*2+2);g.push(...fe),v++}for(let ce=ie+1;ce<v-1;ce++)te(ie,ce,ce+1);te(ie,v-1,ie+1)}}};var lh=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:8,cornerRadiusBottom:8,cornerSegments:8},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:r,depth:e,height:t,radialSegments:o,heightSegments:i,openEnded:s,thetaStart:l,thetaLength:c,cornerRadiusTop:u,cornerRadiusBottom:a,cornerSegments:d}=n.parameters,p;return u>0||a>0||c<360?p=new ss(0,r/2,t,o,i,s,l,c*Math.PI/180,u,a,d,0,!0):p=new q_(r/2,t,o,i,s),p.scale(1,1,e/r),Object.assign(p,{userData:{...n,type:"ConeGeometry"}})}};import{BoxGeometry as W_,BufferGeometry as $_,Float32BufferAttribute as jc,Vector3 as as}from"three";var ch=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:r,height:e,depth:t,widthSegments:o,heightSegments:i,depthSegments:s,cornerRadius:l,cornerSegments:c}=n.parameters,u;return l==0?u=new W_(r,e,t,o,i,s):u=new kc(r,e,t,o,i,s,l,c),Object.assign(u,{userData:{...n,type:"CubeGeometry"}})}},Fc=Math.PI/2,kc=class extends $_{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 jc(d,3)),this.setAttribute("normal",new jc(p,3)),this.setAttribute("uv",new jc(f,2));function y(b,w,S,P,_,x,C,T,N,O,A){let G=(x-2*l)/N,k=(C-2*l)/O,$=x/2-l,ee=C/2-l,Y=T/2,W=N+1,H=O+1,V=0,R=0,B=new as;for(let L=0;L<H;L++){let D=L*k-ee;for(let X=0;X<W;X++){let q=X*G-$;B[b]=q*P,B[w]=D*_,B[S]=Y,d.push(B.x,B.y,B.z),B[b]=0,B[w]=0,B[S]=T>0?1:-1,p.push(B.x,B.y,B.z),f.push(X/N),f.push(1-L/O),V+=1}}for(let L=0;L<O;L++)for(let D=0;D<N;D++){let X=m+D+W*L,q=m+D+W*(L+1),j=m+(D+1)+W*(L+1),F=m+(D+1)+W*L;a.push(X,q,F),a.push(q,j,F),R+=6}u.addGroup(h,R,A),h+=R,m+=V}function g(b,w,S,P,_,x,C,T,N,O,A){let G=(C-2*l)/O,k=C/2-l,$=T/2-l,ee=N/2,Y=O+1,W=0,H=0,V=new as,R=new as;for(let B=0;B<c+1;B++){let L=B/c*Fc,D=Math.sin(L)*l,X=(1-Math.cos(L))*l,q=Math.sin(L),j=Math.cos(L);V[w]=($+D)*_,V[S]=(ee-X)*x,R[b]=0,R[w]=q*Math.sign(V[w]),R[S]=j*Math.sign(V[S]);for(let F=0;F<Y;F++){let M=F*G-k;V[b]=M*P,d.push(V.x,V.y,V.z),p.push(R.x,R.y,R.z),f.push(F/O),f.push(0),W+=1}}for(let B=0;B<c;B++)for(let L=0;L<O;L++){let D=m+L+Y*B,X=m+L+Y*(B+1),q=m+(L+1)+Y*(B+1),j=m+(L+1)+Y*B;a.push(D,X,j),a.push(X,q,j),H+=6}u.addGroup(h,H,A),h+=H,m+=W}function v(b,w,S){let P=new as,_=new as(r/2,e/2,t/2);_.subScalar(l);let x=[],C=b*w*S>0?(N,O,A)=>a.push(N,O,A):(N,O,A)=>a.push(N,A,O);for(let N=0;N<=c;N++){let O=[],A=Fc*(1-N/c),G=Math.cos(A),k=Math.sin(A),$=0;for(let ee=0;ee<=N;ee++){let Y=Math.cos($),W=Math.sin($);P.x=G*Y,P.y=k,P.z=G*W;let H=_.clone().addScaledVector(P,l);d.push(b*H.x,w*H.y,S*H.z),p.push(b*P.x,w*P.y,S*P.z),f.push(0,0),O.push(m++),$+=Fc/N}x.push(O)}let T=x.length-1;for(let N=0;N<T;N++){let O=x[N],A=x[N+1],G=O.length-1;C(O[0],A[1],A[0]);for(let k=1;k<=G;k++)C(O[k-1],O[k],A[k]),C(O[k],A[k+1],A[k])}}}};import{BufferGeometry as Y_,Float32BufferAttribute as Uc,Triangle as X_,Vector3 as $r,Vector2 as Hc}from"three";var mo=class extends Y_{constructor(r=[],e=[],t="",o=1,i=.2,s=4){super(),this.type="PolyhedronGeometryRound";let l=[],c=[],u=[];a(),d(),this.setAttribute("position",new Uc(l,3)),this.setAttribute("normal",new Uc(u,3)),this.setAttribute("uv",new Uc(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 $r,h=m.clone(),y=new X_,g=i*o,v=o-g,b=s+1,w=new $r,S=(W,H)=>w.subVectors(W,H).normalize(),P=(W,H)=>Array(W).fill(void 0).map(H),_=P(r.length/3,(W,H)=>new $r().fromArray(r,H*3).setLength(o)),x=[],C=1e6;for(let W=0;W<_.length;W++){let H=_[W],V=[],R,B,L,D=1e10,X=-1;for(;(X=e.indexOf(W,X+1))!=-1;){let M=X-X%3;R=e[M+(X+1)%3],B=e[M+(X+2)%3],L=H.distanceToSquared(_[R]),D=Math.min(D,L),V.push([R,B,L])}D+=1e-6;let q=[],j=0,F=V.length;for(let M=0;M<F;M++){[R,B,L]=V[j];let Q=x[R]?.includes(W)==!0;L<=D&&q.push(R+ +Q*C),j=V.findIndex(re=>re[0]==B)}x.push(q)}let T=[];{let W=0,H=0,V,R,B=f==3;for(let L=0;L<=s;L++){V=L*(L+1)/2,R=(L+1)*(L+2)/2;for(let D=0;D<s-L;D++)[W,H]=[V+D+L+2,R+D+L+3],T.push(V,R,...B?[H,V]:[W,R],H,W),[V,R]=[W,H];T.push(V,R,V+s+2)}}let N=m.clone(),O=m.clone(),A=m.clone(),G=m.clone(),k=m.clone(),$=[],ee=P(_.length,()=>P(f,()=>m.clone()));for(let W=0;W<_.length;W++){m.copy(_[W]).normalize(),N.copy(m).multiplyScalar(v);let H=x[W];for(let q=0;q<H.length;q++){let j=H[q],F=H[(q+1)%f];y.setFromPointsAndIndices(_,W,j%C,F%C),y.b.sub(y.a).setLength(1e10).add(y.a),y.c.sub(y.a).setLength(1e10).add(y.a),y.closestPointToPoint(N,ee[W][q])}let V=[],R=[],B=[],L=new $r;s==0&&[...ee[W]].reduce((q,j)=>q.add(j),L).multiplyScalar(1/f);for(let q=0;q<f;q++){let j=[],F=(q-1+f)%f,M=ee[W][F],Q=ee[W][q];m.copy(M).sub(N),h.copy(Q).sub(N);let re=N.angleTo(m),oe=m.angleTo(h),K=Math.cos(re)*g;s==0?O.copy(L):O.copy(N).setLength(v+K),R.push(K);let te=[O,M,Q];for(let J=0;J<2;J++){let ie=te[J],ce=te[J+1];G.subVectors(ie,N),k.subVectors(ce,N),A.crossVectors(G,k).normalize();for(let se=0;se<b;se++){let fe=[re,oe][J]*se/b;m.copy(G).applyAxisAngle(A,fe).add(N),V.push(m.clone()),J&&(S(m,N),j.push([se==0?ie:m.clone(),w.clone()]))}J&&(S(ce,N),j.push([ce,w.clone()]))}B.push(j)}$.push(B);let D=2*b,X=2;for(let q=0;q<f;q++){let j=D*q,F=D*((q+1)%f),M=[V[j]];for(let re=1;re<b;re++){G=V[j+re],k=V[F+re],M.push(G);for(let oe=1,K=re-X+1;oe<=K;oe++)m.lerpVectors(G,k,oe/(K+1)),m.sub(N).setLength(R[q]).add(N),M.push(m.clone());M.push(k)}for(let re=0;re<b;re++)M.push(V[re+b+j]);M.push(V[F+b]);let Q=T.map(re=>M[re]);l.push(...Q.map(re=>[re.x,re.y,re.z]).flat()),u.push(...Q.map(re=>(S(re,N),[w.x,w.y,w.z])).flat())}}let Y=[];for(let W=0;W<x.length;W++)for(let H=0;H<f;H++){let V=x[W][H];if(V<C){let R=x[V].findIndex(D=>D%C==W),B=$[W][H],L=$[V][R];for(let D=0;D<b;D++){let X=B[D],q=L[b-D],j=B[D+1],F=L[b-(D+1)];[X,q,j,j,q,F].forEach(M=>{l.push(M[0].x,M[0].y,M[0].z),u.push(M[1].x,M[1].y,M[1].z)})}Y.push(B[0][0],L[b][0],B[b][0],L[0][0])}}for(;Y.length;){let W,H,V,R;[W,H]=Y.splice(0,2);let B=[W];for(;W!=H;)B.push(H),V=Y.indexOf(H),R=V%2,H=Y.splice(V-R,2)[1-R];w.subVectors(B[0],B[1]).cross(m.subVectors(B[0],B[2])).normalize();let L=w.dot(B[0])<0;L&&w.negate();for(let D=1;D<=B.length-2;D++)[B[D+ +L],B[D+1-+L],B[0]].forEach(X=>{l.push(X.x,X.y,X.z),u.push(w.x,w.y,w.z)})}}function d(){let p=new $r;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,C=P(p)/Math.PI+.5;c.push(x,1-C)}let f=new $r,m=new $r,h=new $r,y=new $r,g=new Hc,v=new Hc,b=new Hc,w=(_,x,C,T)=>{T<0&&_.x===1&&(c[x]=_.x-1),C.x===0&&C.z===0&&(c[x]=T/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]),b.set(c[x+4],c[x+5]),y.copy(f).add(m).add(h).divideScalar(3);let C=S(y);w(g,x+0,f,C),w(v,x+2,m,C),w(b,x+4,h,C)}for(let _=0;_<c.length;_+=6){let x=c[_+0],C=c[_+2],T=c[_+4],N=Math.max(x,C,T),O=Math.min(x,C,T);N>.9&&O<.1&&(x<.2&&(c[_+0]+=1),C<.2&&(c[_+2]+=1),T<.2&&(c[_+4]+=1))}function S(_){return Math.atan2(_.z,-_.x)}function P(_){return Math.atan2(-_.y,Math.sqrt(_.x*_.x+_.z*_.z))}}}static fromJSON(r){return new mo(r.vertices,r.indices,r.radius,r.corner,r.cornerSides)}};import{DodecahedronGeometry as K_}from"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 ls(r*.5,i,s):new K_(r*.5,o);return l.scale(1,e/r,t/r),Object.assign(l,{userData:{...n,type:"DodecahedronGeometry"}})}},ls=class extends mo{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 ls(r.radius,r.corner,r.cornerSides)}};import{Plane as aP,Shape as Th,Vector2 as Yr,Vector3 as lP,MathUtils as Zc,LineCurve as Qc,QuadraticBezierCurve as Oh,CubicBezierCurve as sl}from"three";import{CubicBezierCurve as ol,EllipseCurve as Z_,LineCurve as nl,LineCurve3 as Q_,MathUtils as J_,QuadraticBezierCurve as Wc,SplineCurve as eP,Vector2 as ht,Vector3 as fh}from"three";var cs=1e-12,kn=class{constructor(r){this.position=new ht;this.startPosition=new ht;this.uuid=J_.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 kn(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},Un=class extends kn{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new Un(this.parent).copy(this)}},nr=class extends kn{constructor(e,t){super(t);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new Un(this),new Un(this))}static create(e,t){let o=new nr(e,new ht(...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 nr(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 ht,t=new ht){let[o,i]=this.computeTangents();return o&&i&&(uh(o,e),uh(i,t)),[e,t]}computeTangent(e=new ht){let[t,o]=this.computeTangents();return t&&o&&e.copy(t).add(o).normalize(),e}computeNormal(e=new ht){let[t,o]=this.computeNormals();return e.copy(t).add(o).normalize(),e}};function uh(n,r=new ht){let e=n.length();return r.set(-n.y/e,n.x/e)}var $c=n=>n,Hn=new ht,il=new ht,tP=new ht,rP=new ht,oP=new ht,nP=new ht,mh=new fh,hh=new fh;function yh(n){let r=new ht;r.addVectors(n.v0,Hn.subVectors(n.v1,n.v0).multiplyScalar(2/3));let e=new ht;return e.addVectors(n.v2,il.subVectors(n.v1,n.v2).multiplyScalar(2/3)),new ol(n.v0,r,e,n.v2)}function ds(n,r,e=Number.EPSILON){return Math.abs(n-r)<e}function iP(n,r,e=Number.EPSILON){return n.distanceTo(r)<e}function sP(n,r,e=Number.EPSILON){return n.distanceTo(r)<e}function Yc(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 gh(n,r,e){return ph(n,r)&&ph(r,e)&&qc(n.position,r.position,e.position)}function qc(n,r,e){return Hn.copy(r).sub(n).cross(il.copy(e).sub(n))===0}function xh(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 vh(n,r,e){let t=n.distanceTo(e),o=r.distanceTo(e);return t<o?r:n}function bh(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 Yc(r,n,e)>Math.PI&&(a*=-1),ds(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 Xc(n,r){return n.position.equals(n.controls[1].position)&&r.position.equals(r.controls[0].position)}function ph(n,r){return qc(n.position,n.controls[1].position,r.position)&&qc(n.position,r.controls[0].position,r.position)}function Sh(n,r,e,t,o=.5){let i=Hn.subVectors(r,n).multiplyScalar(o).add(n),s=il.subVectors(e,r).multiplyScalar(o).add(r),l=tP.subVectors(t,e).multiplyScalar(o).add(e),c=i,u=rP.subVectors(s,i).multiplyScalar(o).add(i),a=oP.subVectors(l,s).multiplyScalar(o).add(s),d=l,p=nP.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 wh(n,r,e=12,t=!0){let o=hh.set(0,0,0),i,s=0,l=[];for(let c=0;c<r.length;c++){let u=$c(r[c]),a=Hn,d=ho(u,e);l.push(d);for(let p=0;p<=d;p++)if(u instanceof ol||u instanceof Wc||u instanceof nl){if(u.getPoint(p/d,a),o.set(a.x,a.y,0),i!==void 0&&sP(i,o))continue;i===void 0&&(i=mh),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 _h(n,r,e,t=12,o=!0){let i=hh.set(0,0,0),s=0,l=[];for(let c=0;c<r.length;c++){if(e[c]===!1)continue;let u,a=$c(r[c]),d=Hn,p=ho(a,t);l.push(p);for(let f=0;f<=p;f++)if(a instanceof ol||a instanceof Wc||a instanceof nl){if(a.getPoint(f/p,d),i.set(d.x,d.y,0),u?.equals(i))continue;u===void 0?u=mh:(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 Kc(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=ho(s.roundedCurveCorner,r)*.5;o>0&&(t[o-1]+=c),l+=c}s.curveAfter!==void 0&&(l+=ho(s.curveAfter,r)),t.push(l)}return n.length>0&&e&&n[0].roundedCurveCorner!==void 0&&(t[n.length-1]+=ho(n[0].roundedCurveCorner,r)*.5),t}function ho(n,r=12){return n&&n instanceof Z_?r*2:n&&(n instanceof nl||n instanceof Q_)?1:n&&n instanceof eP?r*n.points.length:r}function Ph(n,r,e=12,t=!0){let o,i=0;for(let s=0;s<r.length;s++){let l=$c(r[s]),c=ho(l,e),u=Hn;for(let a=0;a<=c;a++)if(l instanceof ol||l instanceof Wc||l instanceof nl){if(l.getPoint(a/c,u),o!==void 0&&iP(o,u,cs))continue;o===void 0&&(o=il),o.copy(u),n.push(u.x,u.y),i++}}return ds(n[0],n[n.length-2],cs)&&ds(n[1],n[n.length-1],cs)&&(n.pop(),n.pop()),t&&i>1&&!(ds(n[i-1],n[1],cs)&&ds(n[i-2],n[0],cs))&&(n.push(n[0],n[1]),i++),n}var Jc=new Yr,cP=new Yr,dP=new Yr,uP=new Yr,pP=new Yr,fP=new Yr,we=class extends Th{constructor(e=100,t=100){super();this.points=[];this.shapeHoles=[];this.plane=new aP(new lP(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=Zc.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=t}static createFromState(e,t,o){let i=new we;return i.isClosed=e.isClosed,i.points=e.points.map(s=>nr.create(s.id,s.data)),typeof e.roundness=="number"&&(i.roundness=e.roundness),i.shapeHoles=e.shapeHoles.map(s=>we.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=Jc.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=Zc.generateUUID()){let i;e instanceof Yr?i=e:i=new Yr(e,t);let s=new nr(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 wh(e,o?this.roundedCurves:this.curves,t,this.autoClose),i.reduce((s,l)=>s+l,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=Kc(this.points,e,!1),this.roundedCurveDivisions=Kc(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,t,o=12){return _h(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),Ph(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=ho(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(Xc(i,s)){let d=i.position.distanceTo(s.position);return i.position.distanceTo(Jc.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){Xc(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&&gh(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),b=Math.min(g,v),w=1-b/h,S=b/y,P=d.getPointAt(w,Jc),_=p.getPointAt(S,cP);this._subSplitCurve(d,f,w,P,void 0),this._subSplitCurve(p,m,S,void 0,_);let x;if(this.useCubicForRoundedCorners){let C=Yc(P,s.position,_)/2,T=Math.tan(C)*P.distanceTo(s.position),[N,O]=xh(P,_,T,dP,uP),A=vh(N,O,s.position),[G,k]=bh(A,P,_,T,pP,fP);x=new sl(P.clone(),G.clone(),k.clone(),_.clone())}else x=new Oh(P.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 Qc)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=Sh(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 we(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 nr(Zc.generateUUID(),new Yr(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 we;return i.fromJSON(o),i}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e){let t=(i,s)=>{s instanceof sl&&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 Oh&&(i[l]=yh(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 sl?(f=this.createPoint(d.v0),f.controls[1].position.copy(d.v1)):d instanceof Qc&&(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 sl?u.v3.equals(s[0].position)&&(s[0].controls[0].position.copy(u.v2),a=!0):u instanceof Qc&&u.v2.equals(s[0].position)&&(a=!0),this.isClosed=a,s};return this.points=o(e.curves),e instanceof Th&&(this.shapeHoles=e.holes.map(i=>{let s=new we;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 td=Math.PI*2;function ed({x:n,y:r},e,t,o,i){return{x:n*e+o,y:r*t+i}}function mP(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 Ah(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 hP(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,b=(s-h)/o,w=(l-y)/i,S=(-s-h)/o,P=(-l-y)/i,_=Ah(1,0,b,w),x=Ah(b,w,S,P);return!u&&x>0&&(x-=td),u&&x<0&&(x+=td),{centerx:g,centery:v,ang1:_,ang2:x}}function Nh({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=hP(n,r,e,t,o,i,u,a,s,l),{ang1:f,ang2:m}=p,{centerx:h,centery:y}=p,g=Math.abs(m)/(td/4);Math.abs(1-g)<1e-7&&(g=1);let v=Math.max(Math.ceil(g),1);m/=v;for(let b=0;b<v;b++)c.push(mP(f,m)),f+=m;return c.map(b=>{let{x:w,y:S}=ed(b[0],o,i,h,y),{x:P,y:_}=ed(b[1],o,i,h,y),{x,y:C}=ed(b[2],o,i,h,y);return{x1:w,y1:S,x2:P,y2:_,x,y:C}})}import{BufferAttribute as dl,BufferGeometry as SP}from"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 Ge;(function(n){n[n.POLYGONS=0]="POLYGONS",n[n.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",n[n.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(Ge||(Ge={}));function ue(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){ue(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){ue(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){ue(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){ue(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}(),us=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}(),al=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}(),qn=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}(),Ch=function(){function n(){var r=new qn,e=new us,t=new al(0),o=new al(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 al(0),t=new al(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;ue(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;ue(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 qn,e=new qn,t=new us,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 qn;this.makeVertex_(i,e,r.Org),r.Org.anEdge=r}if(!t){var s=new us;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 us;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 qn;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 us;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){ue(o.prev===i),c=o.anEdge;do ue(c.Sym!==c),ue(c.Sym.Sym===c),ue(c.Lnext.Onext.Sym===c),ue(c.Onext.Sym.Lnext===c),ue(c.Lface===o),c=c.Lnext;while(c!==o.anEdge)}for(ue(o.prev===i&&o.anEdge===null),l=e,l=e;(s=l.next)!==e;l=s){ue(s.prev===l),c=s.anEdge;do ue(c.Sym!==c),ue(c.Sym.Sym===c),ue(c.Lnext.Onext.Sym===c),ue(c.Onext.Sym.Lnext===c),ue(c.Org===s),c=c.Onext;while(c!==s.anEdge)}for(ue(s.prev===l&&s.anEdge===null),u=t,u=t;(c=u.next)!==t;u=c)ue(c.Sym.next===u.Sym),ue(c.Sym!==c),ue(c.Sym.Sym===c),ue(c.Org!==null),ue(c.Dst!==null),ue(c.Lnext.Onext.Sym===c),ue(c.Onext.Sym.Lnext===c);ue(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}(),Ih=function(){function n(){this.handle=null}return n}(),Mh=function(){function n(){this.key=null,this.node=0}return n}(),yP=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 Ih,this.handles[t]=new Mh;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,ue(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 Ih;for(i=this.handles.length,this.handles.length=this.max+1,o=i;o<this.handles.length;o++)this.handles[o]=new Mh}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;ue(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}(),rd=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}(),Eh=function(){function n(){this.key=null,this.next=null,this.prev=null}return n}(),gP=function(){function n(r,e){this.frame=r,this.leq=e,this.head=new Eh,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 Eh;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}(),xP=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&&ue(e.eUp.winding===0),e.eUp.activeRegion=null,r.dict.delete(e.nodeUp)},n.fixUpperEdge=function(r,e,t){ue(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 rd;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 ue(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,ue(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(ue(!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 qn,f,m;if(ue(!le.vertEq(u,c)),ue(le.edgeSign(c,r.event,s)<=0),ue(le.edgeSign(u,r.event,l)>=0),ue(s!==r.event&&l!==r.event),ue(!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),ue(Math.min(s.t,c.t)<=p.t),ue(p.t<=Math.max(l.t,u.t)),ue(Math.min(u.s,c.s)<=p.s),ue(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)){ue(!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}ue(!1),e=n.topRightRegion(e),c=n.regionBelow(e),s=c.eUp.Sym,i=l=s.Onext,c.fixUpperEdge&&(ue(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 rd;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);ue(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 rd,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 gP(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||(ue(e.fixUpperEdge),ue(++t===1)),ue(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 yP(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,ue(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}(),vP=function(){function n(){this.mesh=new Ch,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===Ge.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===Ge.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 Ch),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=Ge.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_(),xP.computeInterior(this,s);var l=this.mesh;return e===Ge.BOUNDARY_CONTOURS?this.setWindingNumber_(l,1,!0):this.tessellateInterior_(l),s&&l.check(),e===Ge.BOUNDARY_CONTOURS?this.outputContours_(l,o):this.outputPolymesh_(l,e,t,o),!0},n}();function ir(n){var r=n.windingRule,e=r===void 0?be.ODD:r,t=n.elementType,o=t===void 0?Ge.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 vP;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 Sz=be.ODD,wz=be.NONZERO,_z=be.POSITIVE,Pz=be.NEGATIVE,Tz=be.ABS_GEQ_TWO,Oz=Ge.POLYGONS,Az=Ge.CONNECTED_POLYGONS,Nz=Ge.BOUNDARY_CONTOURS;import{BufferAttribute as cl,BufferGeometry as bP}from"three";var ll=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*ll.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*ll.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)}},ps=ll;ps.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var fs={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},nd={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},id={vertices:[-160,160,160,-160,160,160,-160,-160],vertexIndices:[1,3,0,2],vertexCount:4,elements:[0,1,2,1,0,3],elementCount:2,mesh:void 0},od=(n,r)=>([e,t])=>(t<e&&(t+=r),(n>=e?n:n+r)<=t),Wn=class extends bP{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(_=>{let x=_.extractShapePointsToFlatArray([],i),C=[];for(let T=x.length-1;T>=1;T-=2){let N=x[T-1],O=x[T-0];C.push(N,O)}return C}),a;try{a=ir({windingRule:l,elementType:Ge.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[c]})}catch{a=fs}let d;try{d=ir({windingRule:be.ODD,elementType:Ge.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...u]})}catch{d=nd}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,T=a.vertices[C+0],N=a.vertices[C+1];T<f&&(f=T),T>m&&(m=T),N<h&&(h=N),N>y&&(y=N)}this._minX=f,this._minY=h,this._width=m-f,this._height=y-h,this._buffer=new ps(this._computeBufferEstimatedSize(a));let g=[],v=[];for(let _=a.elementCount-1;_>=0;_--){let x=_>=p,C=_*2,T=a.elements[C+0],N=a.elements[C+1],O=T+N,A={start:T,count:N,normals:[],continuous:[],concave:[]},G=T,k=O-1,$=T+1,ee=this._shape.roundedCurves.length;do{let V=G-T,R=a.vertices[k*2+0],B=a.vertices[k*2+1],L=a.vertices[G*2+0],D=a.vertices[G*2+1],X=a.vertices[$*2+0],q=a.vertices[$*2+1],j=L-R,F=D-B,M=Math.sqrt(j*j+F*F);j/=M,F/=M;let Q=L-X,re=D-q,oe=Math.sqrt(Q*Q+re*re);Q/=oe,re/=oe,A.normals[V*2+0]=-re,A.normals[V*2+1]=Q,A.concave[V]=j*re-F*Q>0;let K=a.vertexIndices[G];if(Array.isArray(K))A.continuous[V]=!1;else{let[te,J]=this._shape.getCurveIndexFromVertexId(K-1,!0);if(J>0&&J<1)A.continuous[V]=!0;else{let ie=J===1?te+1:te-1;ie=(ie+ee)%ee;let ce=J===1?0:1,se=this._shape.roundedCurves[te].getTangent(J),fe=this._shape.roundedCurves[ie].getTangent(ce);A.continuous[V]=se.dot(fe)>.95}}x&&(A.normals[V*2+0]*=-1,A.normals[V*2+1]*=-1),[k,G,$]=[G,$,$+1],$>=O&&($-=N)}while($!==T+1);let Y=[];Y.push({bevelI:0,angle:0,size:0,boundary:{vertices:a.vertices.slice(T*2,O*2),vertexCount:N,vertexIndices:new Array(N).fill(!0).map((V,R)=>[R,R]),elements:[0,N],elementCount:1,mesh:null},reverseMap:[],insetPoints:a.vertices.slice(T*2,O*2)});for(let V=1;V<=this._bevelSegments;V++){let R=V/this._bevelSegments*Math.PI/2,B=(1-Math.cos(R))*this._bevelSize,L=[],D=[],X=[],q=[],j=0;for(let M=0;M<N;M++){let Q=M*2,re=(M-1+N)%N*2,oe=a.vertices[A.start*2+Q+0],K=a.vertices[A.start*2+Q+1],te=-A.normals[re+0]*B,J=-A.normals[re+1]*B,ie=-A.normals[Q+0]*B,ce=-A.normals[Q+1]*B;if(A.concave[M]||!A.concave[M]&&x){let se=Math.atan2(J,te),fe=Math.atan2(ce,ie);fe>se&&(fe-=Math.PI*2);let Re=fe-se;if(A.continuous[M]||x){let ge=se+Re/2,qe=Math.cos(ge)*B,Te=Math.sin(ge)*B;L[2*j+0]=oe+qe*(x?-1:1),L[2*j+1]=K+Te*(x?-1:1),q[j]=M,j++}else{let ge=Math.max(1,Math.floor(i/4*Math.abs(Re)/Math.PI));for(let qe=0;qe<=ge;qe++){let Te=se+Re*(qe/ge),wt=Math.cos(Te)*B,Ft=Math.sin(Te)*B;L[2*j+0]=oe+wt,L[2*j+1]=K+Ft,q[j]=M,j++}}}else L[2*j+0]=oe+te,L[2*j+1]=K+J,q[j]=M,D[M]=j,j++,L[2*j+0]=oe,L[2*j+1]=K,q[j]=M,j++,L[2*j+0]=oe+ie,L[2*j+1]=K+ce,q[j]=M,X[M]=j,j++}let F=ir({windingRule:be.POSITIVE,elementType:Ge.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[L],edgeCreateCallback:M=>{let re=M.Org.idx,oe=q[re],K=q[(re+1)%q.length];M.idx=[oe,K],M.Sym.idx=[K,oe]},vertexIdCallback:M=>{let Q=M.Lprev.idx;return[Q?Q[1]:0,M.idx?M.idx[0]:0]}});if(!F)throw console.log("Error"),new Error(`error generating bevel geometry for ${V}'th loop`);if(!F.vertexCount)break;for(let M=0;M<F.vertexIndices.length;M++){let[Q,re]=F.vertexIndices[M];if(Q===re)continue;let oe=re;re<Q&&(oe+=N);for(let K=Q;K<oe;K++){let te=K%N,J=(K+1)%N;if(!A.continuous[te]||!A.continuous[J]){F.vertexIndices[M]=[Q,te],F.vertexIndices.splice(M+1,0,[J,re]),F.vertices.splice((M+1)*2,0,F.vertices[M*2],F.vertices[M*2+1]);break}}}Y.push({bevelI:V,angle:R,size:B,boundary:F,reverseMap:q,insetPoints:L})}let W=(V,R,B)=>{let L=0,D=V.boundary.vertexIndices.length;for(;L<D&&B(V.boundary.vertexIndices[R]);)R=(R+1)%D,L++;return L},H=g.length;for(let V=1;V<Y.length;V++){let R=Y[V-1],B=Y[V],L=R.boundary.vertexIndices.length,D=B.boundary.vertexIndices.length;if(!L||!D)break;let X=A.concave.length,q=0,j=od(q,N);for(;!R.boundary.vertexIndices.filter(j).length||!B.boundary.vertexIndices.filter(j).length;)q++,j=od(q,N);let F=R.boundary.vertexIndices.findIndex(j),M=B.boundary.vertexIndices.findIndex(j);do F=(F+1)%L;while(j(R.boundary.vertexIndices[F]));do M=(M+1)%D;while(j(B.boundary.vertexIndices[M]));q=(q+1)%N;let Q=q,re=this._buildBevelVert(A,R,(F-1+L)%L),oe=this._buildBevelVert(A,B,(M-1+D)%D),K=re,te=oe,J,ie,ce=!1;do{j=od(q,N);let se=W(R,F,j),fe=W(B,M,j),Re=ce;if(ce=!1,se&&!fe){for(let ge=0;ge<se;ge++)J=this._buildBevelVert(A,R,(F+ge)%L,ge/(se-1)),g.push(K.topN,J.topP,te.topN),g.push(J.bottomP,K.bottomN,te.bottomN),K=J;ce=!0}else if(!se&&fe)for(let ge=0;ge<fe;ge++)ie=this._buildBevelVert(A,B,(M+ge)%D,ge/(fe-1)),g.push(te.topN,K.topP,ie.topP),g.push(K.bottomP,te.bottomN,ie.bottomP),te=ie;else if(se&&fe)if(J=this._buildBevelVert(A,R,F,0),ie=this._buildBevelVert(A,B,M,0),Re?(g.push(K.topN,ie.topP,te.topN),g.push(K.topN,J.topP,ie.topP),g.push(ie.bottomP,K.bottomN,te.bottomN),g.push(ie.bottomP,J.bottomP,K.bottomN)):(g.push(te.topN,K.topN,J.topP),g.push(te.topN,J.topP,ie.topP),g.push(J.bottomP,K.bottomN,te.bottomN),g.push(J.bottomP,te.bottomN,ie.bottomP)),K=J,te=ie,se===fe)for(let ge=1;ge<se;ge++)J=this._buildBevelVert(A,R,(F+ge)%L,ge/(se-1)),ie=this._buildBevelVert(A,B,(M+ge)%D,ge/(fe-1)),g.push(K.topN,J.topP,te.topN),g.push(te.topN,J.topP,ie.topP),g.push(J.bottomP,K.bottomN,te.bottomN),g.push(J.bottomP,te.bottomN,ie.bottomP),K=J,te=ie;else if(se>fe){let ge=se/fe,qe=0;for(let Te=1;Te<se;Te++)J=this._buildBevelVert(A,R,(F+Te)%L,Te/(se-1)),g.push(K.topN,J.topP,te.topN),g.push(J.bottomP,K.bottomN,te.bottomN),K=J,Te>(qe+1)*ge&&(qe++,ie=this._buildBevelVert(A,B,(M+qe)%D,qe/(fe-1)),g.push(te.topN,J.topP,ie.topP),g.push(J.bottomP,te.bottomN,ie.bottomP),te=ie)}else{let ge=fe/se,qe=0;for(let Te=1;Te<fe;Te++)ie=this._buildBevelVert(A,B,(M+Te)%D,Te/(fe-1)),g.push(te.topN,J.topP,ie.topP),g.push(J.bottomP,te.bottomN,ie.bottomP),te=ie,Te>(qe+1)*ge&&(qe++,J=this._buildBevelVert(A,R,(F+qe)%L,qe/(se-1)),g.push(K.topN,J.topP,te.topN),g.push(J.bottomP,K.bottomN,te.bottomN),K=J)}F=(F+se)%L,M=(M+fe)%D,q=(q+1)%X}while(q!==Q)}if(this._depth>this._bevel*2&&this._buildWall(Y,A,g),x){let V=[];for(let R=g.length-1;R>=H+2;R-=3){let B=g[R-2],L=g[R-1],D=g[R-0];V.push(D,L,B)}g.splice(H,g.length-H,...V)}if(x){let V=[];for(let R=Y[Y.length-1].boundary.vertices.length-1;R>=1;R-=2){let B=Y[Y.length-1].boundary.vertices[R-1],L=Y[Y.length-1].boundary.vertices[R-0];V.push(B,L)}v.push(V)}if(!x){let V=Y[Y.length-1],R;try{R=ir({windingRule:Y.length>1?be.POSITIVE:be.ODD,elementType:Ge.POLYGONS,vertexSize:2,strict:!0,contours:[V.insetPoints,...v]})}catch{R=id}if(!R)throw new Error("Error generating geometry for surface");u.length===0&&Object.assign(this,{capStartIndex:g.length});for(let B=0;B<R.elementCount*3;B+=3){let L=this._buildSurfaceVert(R,R.elements[B+0]),D=this._buildSurfaceVert(R,R.elements[B+1]),X=this._buildSurfaceVert(R,R.elements[B+2]);g.push(L.top,D.top,X.top),g.push(X.bottom,D.bottom,L.bottom)}}this.vertexCache={}}this._buffer.shrink();let b=new cl(Uint32Array.from(g),1),w=new cl(this._buffer.positions,3),S=new cl(this._buffer.normals,3),P=new cl(this._buffer.uvs,2);w.needsUpdate=!0,S.needsUpdate=!0,P.needsUpdate=!0,b.needsUpdate=!0,this.setAttribute("position",w),this.setAttribute("normal",S),this.setAttribute("uv",P),this.setIndex(b)}_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],b=t.boundary.vertices[h+1],w=(1-m)*this._bevelSize,S=(v-this._minX)/this._width,P=(b-this._minY)/this._height,_=e.normals[y+0],x=e.normals[y+1],C=e.normals[g+0],T=e.normals[g+1];if(p){let k=C-_,$=T-x;_=_+k*(1-i),x=x+$*(1-i);let ee=Math.sqrt(_*_+x*x);_/=ee,x/=ee}let N=this._buffer.get(d?2:4),O=N*3,A=N*2,G={i:o,fi:u,topP:N+0,topN:N+0,bottomP:N+1,bottomN:N+1};return this._buffer.positions[O+0]=v,this._buffer.positions[O+1]=b,this._buffer.positions[O+2]=this._depth-w,this._buffer.normals[O+0]=_*f,this._buffer.normals[O+1]=x*f,this._buffer.normals[O+2]=m,this._buffer.uvs[A+0]=S,this._buffer.uvs[A+1]=P,this._buffer.positions[O+3]=v,this._buffer.positions[O+4]=b,this._buffer.positions[O+5]=w,this._buffer.normals[O+3]=_*f,this._buffer.normals[O+4]=x*f,this._buffer.normals[O+5]=-m,this._buffer.uvs[A+2]=P,this._buffer.uvs[A+3]=S,d||(N+=2,O+=6,A+=4,G.topP=N+0,G.bottomP=N+1,this._buffer.positions[O+0]=v,this._buffer.positions[O+1]=b,this._buffer.positions[O+2]=this._depth-w,this._buffer.normals[O+0]=C*f,this._buffer.normals[O+1]=T*f,this._buffer.normals[O+2]=m,this._buffer.uvs[A+0]=S,this._buffer.uvs[A+1]=P,this._buffer.positions[O+3]=v,this._buffer.positions[O+4]=b,this._buffer.positions[O+5]=w,this._buffer.normals[O+3]=C*f,this._buffer.normals[O+4]=T*f,this._buffer.normals[O+5]=-m,this._buffer.uvs[A+2]=P,this._buffer.uvs[A+3]=S),this.vertexCache[s]=G,G}clone(){let e=new Wn(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Ur(this.userData),e}};var $n=class extends SP{constructor(e,t=12,o={}){super();this.type="ShapeGeometry";this.windingRule=be.ODD;this.elementType=Ge.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=e,this._curveSegments=t,this._triangulationOptions=Object.assign({windingRule:be.ODD,elementType:Ge.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}if(!c&&!u)try{l=ir({contours:[i,...s],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})}catch{l=fs}let p=l?.vertexCount??1,f=l?.elementCount??1;if(this._positionAttribute=new dl(new Float32Array(p*3),3),this._normalAttribute=new dl(new Float32Array(p*3),3),this._uvAttribute=new dl(new Float32Array(p*2),2),this._indexAttribute=new dl(new Uint32Array(f*3),1),l){let m=1/0,h=-1/0,y=1/0,g=-1/0;for(let w=0,S=p;w<S;w++){let P=w*2,_=l.vertices[P+0],x=l.vertices[P+1];_<m&&(m=_),_>h&&(h=_),x<y&&(y=x),x>g&&(g=x)}let v=h-m,b=g-y;for(let w=0,S=p;w<S;w++){let P=w*2,_=l.vertices[P+0],x=l.vertices[P+1],C=(_-m)/v,T=(x-y)/b;this._positionAttribute.setXYZ(w,_,x,0),this._normalAttribute.setXYZ(w,0,0,1),this._uvAttribute.setXY(w,C,T)}for(let w=0,S=f;w<S;w++){let P=w*3,_=l.elements[P+0],x=l.elements[P+1],C=l.elements[P+2];this._indexAttribute.setX(P+0,_),this._indexAttribute.setX(P+1,x),this._indexAttribute.setX(P+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 $n(this._shape,this._curveSegments);return e.userData=Ur(this.userData),e}};var Yn=class extends Wn{constructor(e,t,o=0,i=12,s=3,l=be.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 Yn(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Ur(this.userData),e}};var At=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 we?(s.width!==t||s.height!==o)&&s.applySize(t,o):s=new we(t,o).fromJSON(s),n.parameters?.roundness!==void 0&&n.parameters?.roundness>0&&s.update());let c=s??new we(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 $n(n.shape,o,{windingRule:s}):l=new Yn(n.shape,r,e,o,t,s),Object.assign(l,{userData:{...n,type:"VectorGeometry"}})}};import{MathUtils as Bh,Vector2 as Dh}from"three";var Gh=Math.PI*2,Kn=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 we?n.shape:new we,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=wP(u,a,d,o*Math.PI/180,t,i);u.isClosed=!0,u.update();let f=At.create({shape:u,parameters:{subdivisions:p,depth:s,extrudeBevelSize:l,extrudeBevelSegments:c}});return Object.assign(f,{userData:{...n,type:"EllipseGeometry"}})}};function wP(n,r,e,t,o,i){if(t>=Gh)return o>30||o%4===0?(PP(n,r,e,i),Math.round(o/4)):Lh(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=Nh({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?_P(n,s.x,s.y,u,o,r,e,i):Lh(n,t,o,r,e,i)}function _P(n,r,e,t,o,i,s,l){let c=Math.round(o/t.length);n.addPoint(Xn(r,e));for(let u=0,a=t.length;u<a;u++){let d=t[u],p=n.points[u],f=Xn(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?Rh(n,i,s,l):n.addPoint(Xn(0,0)),c}function Lh(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(Xn(u,a))}return r<Gh?i>0?Rh(n,t,o,i):n.addPoint(Xn(0,0)):(n.removePoint(n.points[n.points.length-1]),i>0&&Vh(n,t,o,i)),1}function PP(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&&Vh(n,r,e,t)}function Xn(n,r){return new nr(Bh.generateUUID(),new Dh(n,r))}function ul(n,r,e,t,o,i){let s=Xn(n,r);return s.controls[0].position.set(e,t),s.controls[1].position.set(o,i),s}function Rh(n,r,e,t){zh(n,r,e,t).forEach(i=>n.addPoint(i))}function Vh(n,r,e,t){let o=zh(n,r,e,t),i=new we;o.forEach(s=>i.addPoint(s)),i.isClosed=!0,n.shapeHoles.push(i)}function zh(n,r,e,t){let o=t*r/100,i=o*(Math.abs(e)/Math.abs(r)),s=new Dh(o/r,i/e),l=n.points.map(c=>{let u=c.clone();return u.uuid=Bh.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}import{BufferGeometry as TP,Float32BufferAttribute as sd,Uint32BufferAttribute as OP,Vector3 as jh}from"three";var Fh=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 ms(!1,r,e,t,o,i,s,l,c,u,a,d);return Object.assign(p,{userData:{...n,type:"HelixGeometry"}})}},ad=new OP([0,0,0],1),ms=class extends TP{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){if(super(),s===0)return;let f=r&&s===1;f&&(p=0),d>100&&(d=100),d===0&&(p=0);let m=()=>new jh,h=new jh,y=m(),g=m(),v=m(),b,w,S,P,_,x,C,T,N=m(),O=m(),A=m(),G=m(),k=m(),$=m(),ee=m(),Y=m(),W=t-2*c+.001,H=W/s,V=Math.ceil(l*s),R=V+1,B=W/V,L=-W/2,D=a+1,X=2*Math.PI/a,q=Math.PI/2/p,j=.01,F=Math.min((1-d/100)*c,c-j),M=c-F,Q=0,re=2,oe=p*re+re,K=D*oe/re,te=K+D*R,J=D*(R+oe),[ie,ce,se]=[3,3,2].map(ke=>Array(J*ke).fill(0)),fe=[],Re=i-c;function ge(ke,Et){let mr=Math.PI/2;x=Et*B,T=2*Math.PI*(x%H)/H+mr,x+=L,C=Math.sin(T)*Re,_=Math.cos(T)*Re,r?ke.set(_,C,x):ke.set(_,x,C)}ge(h,-1e-10),ge(y,0),N.copy(h),ge(h,1);let qe=h.distanceTo(y),Te=f?0:M+F,wt=qe*V+2*Te,Ft=F,Ko=wt-Te;for(let ke=0;ke<=V;ke++){ge(g,ke),Y.subVectors(g,N).normalize(),N.copy(g),$.copy(g).setComponent(+r+1,0).normalize(),ee.crossVectors(Y,$).normalize();let Et=ke===0,mr=ke===V,n0=Et?3*Math.PI/2:q,i0=Et?Ft:Ko,s0=Et?D:te,a0=Et?0:J-D,l0=Y.clone().multiplyScalar(Et?-M:M).add(g),c0=Y.clone().multiplyScalar(Et?-1:1).normalize();for(let Rr=0;Rr<D;Rr++){let Su=Rr*X;if(O.addVectors(h.copy($).multiplyScalar(c*Math.cos(Su)),y.copy(ee).multiplyScalar(c*Math.sin(Su))),A.copy(O).normalize(),Et||mr){f||(Q=a0+Rr,[0,1,2].forEach(_t=>{ie[Q*3+_t]=l0.getComponent(_t),ce[Q*3+_t]=c0.getComponent(_t)}),se[Q*2]=+mr,se[Q*2+1]=Rr/a),y.copy(A).multiplyScalar(F),v.addVectors(g,y);for(let _t=0;_t<p;_t++){let Ql=_t*q+n0;G.addVectors(h.copy(Y).multiplyScalar(M*Math.sin(Ql)),y.copy(A).multiplyScalar(M*Math.cos(Ql))),k.copy(G).normalize(),y.addVectors(v,G),G.normalize(),Q=s0+_t*D+Rr,[0,1,2].forEach(qs=>{ie[Q*3+qs]=y.getComponent(qs),ce[Q*3+qs]=k.getComponent(qs)});let d0=+Et+Math.sin(Ql);se[Q*2]=(i0+M*d0)/wt,se[Q*2+1]=Rr/a}}y.addVectors(g,O),Q=K+ke*D+Rr,[0,1,2].forEach(_t=>{ie[Q*3+_t]=y.getComponent(_t),ce[Q*3+_t]=A.getComponent(_t)}),se[Q*2]=(Te+ke*qe)/wt,se[Q*2+1]=Rr/a}}let Mt=R+2*p+re,ks=1,[Us,Hs]=[+f,Mt-1];for(let ke=Us;ke<=Hs-1;ke++){let Et=f&&ke===Hs-1;for(let mr=0;mr<D-1;mr++)b=ke*D+mr,w=b+1,S=(Et?mr:b)+D,P=(Et?mr+1:w)+D,ke===0?fe.push(w,P,S):ke===Mt-2?fe.push(b,w,S):fe.push(b,w,S,w,P,S)}this.setIndex(fe),this.setAttribute("position",new sd(ie,3)),this.setAttribute("normal",new sd(ce,3)),this.setAttribute("uv",new sd(se,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let r=this.userData.parameters,e=Math.ceil(r.tubularSegments),t=r.radialSegments+1,o=Array.from(this.getIndex().array),i,s,l,c,u=6*(e-1)*r.radialSegments,a=e,d=a===e;for(let p=0;p<r.radialSegments;p++)i=a*t+p,s=i+1,l=(d?p:i)+t,c=(d?p+1:s)+t,o[u++]=i,o[u++]=s,o[u++]=l,o[u++]=s,o[u++]=c,o[u++]=l;return o.length=u,ad.array=o,ad.count=o.length,ad}};import{IcosahedronGeometry as AP}from"three";var kh=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 hs(r*.5,i,s):new AP(r*.5,o);return l.scale(1,e/r,t/r),Object.assign(l,{userData:{...n,type:"IcosahedronGeometry"}})}},hs=class extends mo{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 hs(r.radius,r.corner,r.cornerSides)}};import{LatheGeometry as NP,Shape as CP}from"three";var 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 CP;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 NP(o.extractPoints(t).shape,e);return i.rotateZ(Math.PI),Object.assign(i,{userData:{...n,type:"LatheGeometry"}})}};import{BufferGeometry as Zh,BufferGeometryLoader as FP,Vector3 as kP,BoxGeometry as Qh}from"three";import{BufferGeometry as RP,Vector2 as ud,Vector3 as Kh}from"three";import{Box3 as IP,BufferAttribute as ys,BufferGeometry as Hh,Color as dd,EventDispatcher as MP,Float32BufferAttribute as Zn,Matrix3 as qh,Matrix4 as Xh,MathUtils as EP,Object3D as LP,Sphere as BP,Vector2 as zt,Vector3 as ct,Vector4 as DP}from"three";var Pr=new Xh,ld=new LP,pl=new ct,yo=class extends MP{constructor(){super(),this.uuid=EP.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 qh().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 Pr.makeRotationX(r),this.applyMatrix4(Pr),this}rotateY(r){return Pr.makeRotationY(r),this.applyMatrix4(Pr),this}rotateZ(r){return Pr.makeRotationZ(r),this.applyMatrix4(Pr),this}translate(r,e,t){return Pr.makeTranslation(r,e,t),this.applyMatrix4(Pr),this}scale(r,e,t){return Pr.makeScale(r,e,t),this.applyMatrix4(Pr),this}lookAt(r){return ld.lookAt(r),ld.updateMatrix(),this.applyMatrix4(ld.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 ct().fromBufferAttribute(i,p)),l!==void 0&&e.colors.push(new dd().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 ct().fromBufferAttribute(s,p),new ct().fromBufferAttribute(s,f),new ct().fromBufferAttribute(s,m)],v=new Qn(p,f,m,g,y,h);e.faces.push(v),c!==void 0&&e.faceVertexUvs[0].push([new zt().fromBufferAttribute(c,p),new zt().fromBufferAttribute(c,f),new zt().fromBufferAttribute(c,m)]),u!==void 0&&e.faceVertexUvs[1].push([new zt().fromBufferAttribute(u,p),new zt().fromBufferAttribute(u,f),new zt().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(pl).negate(),this.translate(pl.x,pl.y,pl.z),this}normalize(){this.computeBoundingSphere();let r=this.boundingSphere.center,e=this.boundingSphere.radius,t=e===0?1:1/e,o=new Xh;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 ct,e=new ct;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 ct;if(r){let t=new ct,o=new ct;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 yo;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 ct,a={a:new ct,b:new ct,c:new ct};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 IP),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new BP),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 qh().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,b=new Qn(m.a+i,m.b+i,m.c+i);b.normal.copy(m.normal),o!==void 0&&b.normal.applyMatrix3(o).normalize();for(let w=0,S=g.length;w<S;w++)h=g[w].clone(),o!==void 0&&h.applyMatrix3(o).normalize(),b.vertexNormals.push(h);b.color.copy(m.color);for(let w=0,S=v.length;w<S;w++)y=v[w],b.vertexColors.push(y.clone());b.materialIndex=m.materialIndex+t,c.push(b)}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 b=0,w=g.length;b<w;b++)v.push(g[b].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 ct(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,b=h.normal.length()>0,w=h.vertexNormals.length>0,S=h.color.r!==1||h.color.g!==1||h.color.b!==1,P=h.vertexColors.length>0,_=0;if(_=a(_,0,0),_=a(_,1,y),_=a(_,2,g),_=a(_,3,v),_=a(_,4,b),_=a(_,5,w),_=a(_,6,S),_=a(_,7,P),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(b&&t.push(d(h.normal)),w){let x=h.vertexNormals;t.push(d(x[0]),d(x[1]),d(x[2]))}if(S&&t.push(p(h.color)),P){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 yo().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 b=0,w=g.length;b<w;b++){let S=g[b];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 cd().fromGeometry(this),e=new Hh,t=new Float32Array(r.vertices.length*3);if(e.setAttribute("position",fl.call(new ys(t,3),r.vertices)),r.normals.length>0){let o=new Float32Array(r.normals.length*3);e.setAttribute("normal",fl.call(new ys(o,3),r.normals))}if(r.colors.length>0){let o=new Float32Array(r.colors.length*3);e.setAttribute("color",Wh.call(new ys(o,3),r.colors))}if(r.uvs.length>0){let o=new Float32Array(r.uvs.length*2);e.setAttribute("uv",$h.call(new ys(o,2),r.uvs))}if(r.uvs2.length>0){let o=new Float32Array(r.uvs2.length*2);e.setAttribute("uv2",$h.call(new ys(o,2),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 Zn(u.data.length*3,3);a.name=u.name,i.push(fl.call(a,u.data))}e.morphAttributes[o]=i}if(r.skinIndices.length>0){let o=new Zn(r.skinIndices.length*4,4);e.setAttribute("skinIndex",Yh.call(o,r.skinIndices))}if(r.skinWeights.length>0){let o=new Zn(r.skinWeights.length*4,4);e.setAttribute("skinWeight",Yh.call(o,r.skinWeights))}return r.boundingSphere!==null&&(e.boundingSphere=r.boundingSphere.clone()),r.boundingBox!==null&&(e.boundingBox=r.boundingBox.clone()),e}computeTangents(){console.error("THREE.Geometry: .computeTangents() has been removed.")}computeLineDistances(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")}applyMatrix(r){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(r)}dispose(){this.dispatchEvent({type:"dispose"})}static createBufferGeometryFromObject(r){let e=new Hh,t=r.geometry;if(r.isPoints||r.isLine){let o=new Zn(t.vertices.length*3,3),i=new Zn(t.colors.length*3,3);if(e.setAttribute("position",fl.call(o,t.vertices)),e.setAttribute("color",Wh.call(i,t.colors)),t.lineDistances&&t.lineDistances.length===t.vertices.length){let s=new Zn(t.lineDistances.length,1);e.setAttribute("lineDistance",GP.call(s,t.lineDistances))}t.boundingSphere!==null&&(e.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(e.boundingBox=t.boundingBox.clone())}else r.isMesh&&(e=t.toBufferGeometry());return e}};yo.prototype.isGeometry=!0;var cd=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 b=v.vertexNormals;if(b.length===3)this.normals.push(b[0],b[1],b[2]);else{let S=v.normal;this.normals.push(S,S,S)}let w=v.vertexColors;if(w.length===3)this.colors.push(w[0],w[1],w[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 zt,new zt,new zt))}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 zt,new zt,new zt))}for(let S=0;S<c;S++){let P=l[S].vertices;u[S].data.push(P[v.a],P[v.b],P[v.c])}for(let S=0;S<d;S++){let P=a[S].vertexNormals[g];p[S].data.push(P.a,P.b,P.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 ct,this.vertexNormals=Array.isArray(o)?o:[],this.color=i&&i.isColor?i:new dd,this.vertexColors=Array.isArray(i)?i:[],this.materialIndex=s}clone(){return new this.constructor().copy(this)}copy(r){this.a=r.a,this.b=r.b,this.c=r.c,this.normal.copy(r.normal),this.color.copy(r.color),this.materialIndex=r.materialIndex;for(let e=0,t=r.vertexNormals.length;e<t;e++)this.vertexNormals[e]=r.vertexNormals[e].clone();for(let e=0,t=r.vertexColors.length;e<t;e++)this.vertexColors[e]=r.vertexColors[e].clone();return this}};function GP(n){return this.array.set(n),this}function Wh(n){let r=this.array,e=0;for(let t=0,o=n.length;t<o;t++){let i=n[t];i===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",t),i=new dd),r[e++]=i.r,r[e++]=i.g,r[e++]=i.b}return this}function $h(n){let r=this.array,e=0;for(let t=0,o=n.length;t<o;t++){let i=n[t];i===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",t),i=new zt),r[e++]=i.x,r[e++]=i.y}return this}function fl(n){let r=this.array,e=0;for(let t=0,o=n.length;t<o;t++){let i=n[t];i===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",t),i=new ct),r[e++]=i.x,r[e++]=i.y,r[e++]=i.z}return this}function Yh(n){let r=this.array,e=0;for(let t=0,o=n.length;t<o;t++){let i=n[t];i===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",t),i=new DP),r[e++]=i.x,r[e++]=i.y,r[e++]=i.z,r[e++]=i.w}return this}var VP=["a","b","c"];function zP(n,r){switch(r){case"c":return n.c;case"b":return n.b;case"a":default:return n.a}}function pd(n,r,e){let t=Math.min(n,r),o=Math.max(n,r),i=t+"_"+o;return e.get(i)}function fd(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 jP(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],fd(s.a,s.b,n,t,s,e),fd(s.b,s.c,n,t,s,e),fd(s.c,s.a,n,t,s,e)}function ml(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 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 RP?r=new yo().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 Kh,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;jP(c,u,p,f);let m=[],h,y,g,v,b,w,S;for(let j of Array.from(f.keys())){for(y=f.get(j),g=new Kh,b=3/8,w=1/8,S=y.faces.length,S!=2&&(b=.5,w=0,S!=1),g.addVectors(y.a,y.b).multiplyScalar(b),e.set(0,0,0),s=0;s<S;s++){for(v=y.faces[s],l=0;l<3&&(h=c[zP(v,VP[l])],!(h!==y.a&&h!==y.b));l++);h&&e.add(h)}e.multiplyScalar(w),g.add(e),y.newEdge=m.length,m.push(g)}let P,_,x,C,T,N,O,A=[];for(o=0,i=c.length;o<i;o++){for(N=c[o],T=p[o].edges,t=T.length,t==3?P=3/16:t>3&&(P=3/(8*t)),_=1-t*Number(P),x=P,t<=2&&(t==2?(_=3/4,x=1/8):t==1||t==0),O=N.clone().multiplyScalar(_),e.set(0,0,0),s=0;s<t;s++)C=T[s],h=C.a!==N?C.a:C.b,e.add(h);e.multiplyScalar(Number(x)),O.add(e),A.push(O)}let G=A.concat(m),k=A.length,$,ee,Y,W=[],H=[],V,R,B,L,D=new ud,X=new ud,q=new ud;for(o=0,i=u.length;o<i;o++)v=u[o],$=Number(pd(v.a,v.b,f).newEdge)+k,ee=Number(pd(v.b,v.c,f).newEdge)+k,Y=Number(pd(v.c,v.a,f).newEdge)+k,ml(W,$,ee,Y,v.materialIndex),ml(W,v.a,$,Y,v.materialIndex),ml(W,v.b,ee,$,v.materialIndex),ml(W,v.c,Y,ee,v.materialIndex),d&&(V=a[o],R=V[0],B=V[1],L=V[2],D.set(Jn(R.x,B.x),Jn(R.y,B.y)),X.set(Jn(B.x,L.x),Jn(B.y,L.y)),q.set(Jn(R.x,L.x),Jn(R.y,L.y)),hl(H,D,X,q),hl(H,R,D,q),hl(H,B,X,D),hl(H,L,q,X));r.vertices=G,r.faces=W,d&&(r.faceVertexUvs[0]=H)}};var Ye=new kP,Jh=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=n.geometry??r?.geometry??new Zh().copy(new Qh(100,100,100)),t;r===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(Ye),t={width:Ye.x,height:Ye.y,depth:Ye.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 Zh().copy(new Qh(100,100,100)),s=i.userData.parameters;s===void 0?(i.computeBoundingBox(),i.boundingBox.getSize(Ye)):Ye.set(s.width,s.height,s.depth),(r!==Ye.x||e!==Ye.y||t!==Ye.z)&&i.scale(Ye.x===0?1:r/Ye.x,Ye.y===0?1:e/Ye.y,Ye.z===0?1:t/Ye.z);let l=i.originalGeometry;try{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())}catch{l!==void 0&&(i=l),l=void 0,i.getAttribute("normal")===void 0&&i.computeVertexNormals()}return l!==void 0&&Object.assign(i,{originalGeometry:l}),delete n.geometry,Object.assign(i,{userData:{...n,type:"NonParametricGeometry"}})}static loadFromUrl(n,r,e){new FP(e).load(n,o=>{let i=this.normalizeInputs({geometry:o});o.boundingBox.getSize(Ye);let s=100/Ye.x;Object.assign(i.parameters,{width:100,height:Ye.y*s,depth:Ye.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 we?n.shape:new we,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=At.create({shape:c,parameters:{roundness:o,depth:i,extrudeBevelSize:s,extrudeBevelSegments:l}});return Object.assign(m,{userData:{...n,type:"PolygonGeometry"}})}};import{BufferGeometry as UP,Float32BufferAttribute as md,Vector2 as Tr,Vector3 as et}from"three";var ey=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 yd(r*.5,e,o,i,s,l,c);return u.scale(1,1,t/r),Object.assign(u,{userData:{...n,type:"PyramidGeometry"}})}};function gs(n,r,e){e.x=n.x*r.x,e.y=n.y,e.z=n.x*r.y}function hd(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 HP(n,r,e){let t=n.clone().sub(r),o=e.clone().sub(r);return t.projectOnVector(o),t.add(r)}var yd=class extends UP{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,b=new et(0,-f,0),w=new et(0,f,0),S=new Tr(r,-f),P=new Tr(h,-f),_=new Tr(0,w.y).sub(P),x=new Tr(0,w.y).sub(S),C=new Tr(_.y,-_.x).normalize(),T=new Tr(x.y,-x.x).normalize(),O=r*Math.cos(Math.PI/t)*Math.tan((Math.PI-_.angle())/2)-1e-8;s=Math.min(s,O);let A;{let H=new et(C.x,C.y,0),V=new et(Math.cos(y)*H.x,H.y,Math.sin(y)*H.x);A=H.angleTo(V)}let G=s/Math.tan((Math.PI-_.angle())/2),k=s/Math.tan((Math.PI-A)/2),$=new et;if(!i){u.push(b.x,b.y,b.z),a.push(0,-1,0),d.push(0,0);let H=p++,V=[],R=S.clone(),B=G/Math.cos(Math.PI/t);R.x-=B;for(let L=0;L<t;L++){let D=L/t*Math.PI*2+m,X=new Tr(Math.sin(D),Math.cos(D));gs(R,X,$),u.push($.x,$.y,$.z),a.push(0,-1,0),d.push(0,0),V.push(p++)}for(let L=0;L<V.length;L++)c.push(V[L],H,V[(L+1)%V.length])}let ee=[];{let H=new et,V=new et,R=new et,B=new et,L=new et,D=new et;for(let X=0;X<t;X++){let q=X/t*Math.PI*2+m,j=(X+.5)/t*Math.PI*2+m,F=(X+1)/t*Math.PI*2+m,M=new Tr(Math.sin(q),Math.cos(q)),Q=new Tr(Math.sin(j),Math.cos(j)),re=new Tr(Math.sin(F),Math.cos(F));gs(S,M,V),gs(S,re,R),gs(C,Q,H),hd(w,V,R,k,k,B),u.push(B.x,B.y,B.z),hd(V,w,R,k,G,L),u.push(L.x,L.y,L.z),hd(R,V,w,G,k,D),u.push(D.x,D.y,D.z),a.push(H.x,H.y,H.z),a.push(H.x,H.y,H.z),a.push(H.x,H.y,H.z),d.push(0,0),d.push(0,0),d.push(0,0);let oe=p++,K=p++,te=p++;if(c.push(oe,K,te),s>0){{let ce=V.clone().add(R).multiplyScalar(.5),se=w.clone().sub(ce).normalize(),Re=b.clone().sub(ce).normalize().add(se).normalize().multiplyScalar(-1),ge=D.clone().sub(L);Y(ce,ge,Re,_.angle())}let J,ie;{let ce=new et;gs(T,re,ce);let se=D.clone().add(B).multiplyScalar(.5);se=HP(se,R,w);let fe=D.clone().sub(B);[J,ie]=Y(se,fe,ce,A,B.y)}{let ce=J,se=ce.clone().setY(0).normalize(),fe=new et(0,-1,0),Re=se.clone().cross(fe);W(ce,se,fe,Re)}ee.concat(ie);{let ce=_.angle(),se=Math.PI-ce,fe=w.clone();fe.y-=s/Math.sin(ce-Math.PI/2);let Re=new et,ge=[];for(let Te=0;Te<l;Te++){let wt=[],Ft=Math.PI/2-se*Te/l,Ko=Math.cos(Ft),Mt=Math.sin(Ft),ks=j;for(let Us=0;Us<=Te;Us++){let Hs=Math.cos(ks),ke=Math.sin(ks);H.x=Ko*ke,H.y=Mt,H.z=Ko*Hs,Re.copy(fe).addScaledVector(H,s),u.push(Re.x,Re.y,Re.z),a.push(H.x,H.y,H.z),d.push(0,0),wt.push(p++),ks+=Math.PI*2/Te/t}ge.push(wt)}ie.reverse(),ge.push(ie);let qe=ge.length-1;for(let Te=0;Te<qe;Te++){let wt=ge[Te],Ft=ge[Te+1],Ko=wt.length-1;c.push(Ft[1],wt[0],Ft[0]);for(let Mt=1;Mt<=Ko;Mt++)c.push(wt[Mt],wt[Mt-1],Ft[Mt]),c.push(Ft[Mt+1],wt[Mt],Ft[Mt])}}}}}this.setIndex(c),this.setAttribute("position",new md(u,3)),this.setAttribute("normal",new md(a,3)),this.setAttribute("uv",new md(d,2));function Y(H,V,R,B,L){let D=-B/2,X=(Math.PI-B)/2,q=V.clone().normalize().cross(R);H.addScaledVector(R,-s/Math.sin(X));let j=new et,F=new et,M=1,Q=p,re=[];for(let oe=0;oe<=l;oe++){let K=D+oe/l*B;F.set(0,0,0),F.addScaledVector(q,Math.sin(K)),F.addScaledVector(R,Math.cos(K));for(let te=0;te<=M;te++){let J=te/M-.5;if(j.copy(H),j.addScaledVector(V,J),j.addScaledVector(F,s),L!=null){let ie=Math.max(0,j.y-L);j.addScaledVector(V,-ie/V.y)}u.push(j.x,j.y,j.z),a.push(F.x,F.y,F.z),d.push(0,0),te===0&&re.push(p),p++}}for(let oe=0;oe<l;oe++)for(let K=0;K<M;K++){let te=Q+K+(M+1)*oe,J=te+(M+1),ie=J+1,ce=te+1;c.push(te,J,ce),c.push(J,ie,ce)}return[H.clone().addScaledVector(V,.5),re]}function W(H,V,R,B){let L=Math.PI/2,D=x.angle()-L,X=[],q=new et,j=new et;for(let M=0;M<=l;M++){let Q=[],re=M/l;for(let oe=0;oe<=M;oe++){let te=((M?oe/M:0)-.5)*v,J=Math.cos(te),ie=Math.sin(te),ce=Math.atan(Math.tan(D)*J),se=(L+ce)*re,fe=Math.cos(se),Re=Math.sin(se);q.set(0,0,0),q.addScaledVector(V,Re*J),q.addScaledVector(R,fe),q.addScaledVector(B,Re*ie),j.copy(H).addScaledVector(q,s),u.push(j.x,j.y,j.z),a.push(q.x,q.y,q.z),d.push(0,0),Q.push(p++)}X.push(Q)}let F=X.length-1;for(let M=0;M<F;M++){let Q=X[M],re=X[M+1],oe=Q.length-1;c.push(Q[0],re[1],re[0]);for(let K=1;K<=oe;K++)c.push(Q[K-1],Q[K],re[K]),c.push(Q[K],re[K+1],re[K])}}}};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 we?n.shape:new we,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(w,S,P){return S>e&&P>t?Math.min(w*e/S,w*t/P):S>e?w*e/S:P>t?w*t/P:w}let f=[];f[0]=o[0]===0?0:p(o[0],o[0]+o[3],o[0]+o[1]),f[1]=o[1]===0?0:p(o[1],o[1]+o[2],o[1]+o[0]),f[2]=o[2]===0?0:p(o[2],o[2]+o[1],o[2]+o[3]),f[3]=o[3]===0?0:p(o[3],o[3]+o[0],o[3]+o[2]);let m=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 w=0,S=r.points.length;w<S;w++)r.points[w].roundness=f[w],w>0&&f[w]!==f[w-1]&&(v=!1);v&&(r.roundness=f[0]),r.useCubicForRoundedCorners=i!==1,r.update();let b=At.create({shape:r,parameters:{depth:s,extrudeBevelSize:l,extrudeBevelSegments:c}});return Object.assign(b,{userData:{...n,type:"RectangleGeometry"}})}};import{SphereGeometry as qP}from"three";var ty=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 qP(.5*r,o,i,s,l,c,u);return a.scale(1,e/r,t/r),Object.assign(a,{userData:{...n,type:"SphereGeometry"}})}};import{PlaneGeometry as WP}from"three";var ry=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 WP(r,e,t,o);return i.scale(1,1,1),Object.assign(i,{userData:{...n,type:"PlaneGeometry"}})}};import{BufferGeometry as $P,Float32BufferAttribute as gd,Vector3 as YP}from"three";var oy=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 xd(r,e,t,o,i,s);return Object.assign(l,{userData:{...n,type:"BackdropGeometry"}})}},xd=class extends $P{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,F=0,M=0)=>new YP(j,F,M),m=f(),h=f(),[y,g,v]=[e/2,r/2,t/2],b=-g,w=+g,[S,P,_]=[f(b,-y,+v),f(b,-y,-v),f(b,+y,-v)],x=(j,F=!1)=>Math.sin(j-Math.PI/(1+ +F)),C=(j,F=!1)=>Math.cos(j-Math.PI/(1+ +F));_.y=Math.sin(o)*e-y;let T=Math.cos(o)*e-v,N=S.z-a;o<=p?(_.z=Math.min(T,N),_.z==N&&(_.y-=(T-N)/Math.tan(p-o))):P.z=Math.min(P.z-T-v,S.z-a),m.subVectors(S,P),h.subVectors(_,P);let O=Math.min(m.length(),h.length())*i/100,A=O*Math.tan(o/2),G=O/Math.cos(o/2),k=m.clone().normalize().add(h.normalize()).setLength(G).add(P);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 F=p+o+j*$;m.set(0,Math.sin(F)*A,Math.cos(F)*A),m.add(k),h.set(0,x(F),C(F)),d.push([m.clone(),h.clone()])}d.push([S,f(0,1,0)]);let ee=Math.sin($/2)*A*2,Y=d.length-1,W=d[0][0].distanceTo(d[1][0]),H=d[Y-1][0].distanceTo(d[Y][0]),V=W+ee*s+H;d[0].push(1);for(let j=0;j<=s;j++)d[j+1].push(1-(W+j*ee)/V);d[Y].push(0);let[R,B,L]=d[0],D,X,q;for(let j=1;j<d.length;j++)[D,X,q]=d[j],l.push(b,R.y,R.z,b,D.y,D.z,w,R.y,R.z,w,R.y,R.z,b,D.y,D.z,w,D.y,D.z),c.push(0,B.y,B.z,0,X.y,X.z,0,B.y,B.z,0,B.y,B.z,0,X.y,X.z,0,X.y,X.z),u.push(0,L,0,q,1,L,1,L,0,q,1,q),[R,B,L]=[D,X,q];this.setAttribute("position",new gd(l,3)),this.setAttribute("normal",new gd(c,3)),this.setAttribute("uv",new gd(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 we?n.shape:new we,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 w=0;w<o;w++){let S=h*w,P=f+Math.sin(S)*d,_=m+Math.cos(S)*p;a.addPoint(a.createPoint(P,_))}}else for(let w=0;w<o;w++){let S=f+Math.cos(y)*d,P=m+Math.sin(y)*p;a.addPoint(a.createPoint(S,P)),y+=h,S=f+Math.cos(y)*g,P=m+Math.sin(y)*v,w<=o,a.addPoint(a.createPoint(S,P)),y+=h}a.isClosed=!0;for(let w=0,S=a.points.length;w<S;w++)a.points[w].roundness=i;a.roundness=i,a.update();let b=At.create({shape:a,parameters:{roundness:i,depth:l,extrudeBevelSize:c,extrudeBevelSegments:u}});return Object.assign(b,{userData:{...n,type:"StarGeometry"}})}};import{PlaneGeometry as XP}from"three";var ny=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 XP(r,e);return Object.assign(t,{userData:{...n,type:"TextFrameGeometry"}})}};var iy=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=KP(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 KP(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 ms(!0,n,r,e,t,o,i,s,l,c,u,a)}import{TorusKnotGeometry as ZP}from"three";var sy=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,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 ZP(l,e,t,o,i,s);return Object.assign(c,{userData:{...n,type:"TorusKnotGeometry"}})}};var ay=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 we?n.shape:new we,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=At.create({shape:c,parameters:{roundness:t,depth:o,extrudeBevelSize:i,extrudeBevelSegments:s}});return Object.assign(d,{userData:{...n,type:"TriangleGeometry"}})}};import{Vector2 as cy,Vector3 as tt,Matrix4 as xs,BufferGeometry as dy,BufferAttribute as vd,MathUtils as bd}from"three";function ly(n,r){let e=2*Math.PI;return(n%e+e)%e===(r%e+e)%e}function QP(n,r,e){let t=[new tt,new tt,new tt],o=[new tt,new tt,new tt];return n.extractBasis(t[0],t[1],t[2]),r.extractBasis(o[0],o[1],o[2]),t.forEach((i,s)=>{let l=o[s],c=bd.lerp(i.length(),l.length(),e);i.lerp(l,e).setLength(c)}),new xs().makeBasis(t[0],t[1],t[2])}var uy=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??Kn.create({parameters:Oc}).userData.shape;return{path:n.path??En.defaultData(),parameters:Object.assign(e,{width:t,height:o,depth:i,extrusion:{...Ua,...e.extrusion}}),shapeData:s}}static build(n){if(n.path.points.length>=2){let e=new Sd(n);return Object.assign(e,{userData:{...n,type:"PathGeometry"}})}else return Object.assign(new dy,{userData:{...n,type:"PathGeometry"}})}},Sd=class extends dy{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)||!ly(e.twist,0)||e.startScale!==e.endScale}build(){let e=this._extractPathPoints();if(e.length<2)return;let t=this._computeBasisMatrices(e),{depth:o,offset:i}=this.inputs.parameters.extrusion,s=this.inputs.path.isClosed?e.length:e.length-1,l=Math.floor(i*s),c=this.inputs.path.isClosed?Math.ceil((o+i)*s):Math.ceil(Math.min(1,o+i)*s),u=Math.min(Math.max(2,c-l+1),s+2),a=[],d=[];for(let O=0;O<u;O++){let A=this.inputs.path.isClosed?(O+l)%e.length:Math.min(O+l,e.length-1);a.push(e[A].clone()),d.push(t[A].clone())}let p=(O,A,G)=>{a[O]=a[O].clone().lerp(a[A],G),d[O]=QP(d[O],d[A],G)},f=0,m=i*s%1;(!this.inputs.path.isClosed||o<=1)&&(m||i===0)&&(f=m,p(0,1,f));let h=0,y=(i+o)*s%1;if((this.inputs.path.isClosed&&o<=1||!this.inputs.path.isClosed&&i+o<1)&&y&&(h=y,p(a.length-1,a.length-2,1-h)),o===0){let O=a.length-1;a[O].copy(a[0]),d[O].copy(d[0])}this._applyPathModifiers(d,f,h);let{regions:g,infos:v,vertices:b}=this._computeShapePoints(5),w=0,S=0;v.sort((O,A)=>O.start-A.start),v.forEach(O=>{O.verticesStart=w,O.verticesCount=O.continuous.reduce((A,G,k)=>A+(k===0||!G?2:1),0),S+=O.verticesCount,w=S});let P=S*u,_,x=0;if(this._isOpenEnded()){try{_=ir({windingRule:be.ODD,elementType:Ge.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:g})}catch{_=id}x=_.vertexCount}let C=P+2*x,T={positions:new Float32Array(C*3),normals:new Float32Array(C*3),uvs:new Float32Array(C*2)},N=[];v.forEach(O=>{this._extrudeRegion(O,b,d,a,T,N,this._isGeometryClosed()&&!this._isOpenEnded())}),_&&(this._closeEnd(_,P,N,T,d[0],a[0],!1),this._closeEnd(_,P+x,N,T,d[d.length-1],a[a.length-1],!0)),this.setAttribute("position",new vd(T.positions,3)),this.setAttribute("normal",new vd(T.normals,3)),this.setAttribute("uv",new vd(T.uvs,2)),this.setIndex(N)}_extractPathPoints(){let t=Ja(this.inputs.path).getPoints(this.inputs.path.subdivisions);if(t.length<2)return[];let o=[t[0]];return t.forEach(s=>{o[o.length-1].distanceToSquared(s)>.001&&o.push(s)}),this.inputs.path.isClosed&&o[o.length-1].distanceTo(o[0])<.001&&o.pop(),o}_computeBasisMatrices(e){let t=[],o=e.length,i=this.inputs.path.isClosed,s=new tt,l=new tt,c=new tt,u=new tt,a=new tt(0,1,0);for(let y=0;y<o;y++){let g=e[y],v;y===0?v=i?e[e.length-2]:g.clone().multiplyScalar(2).sub(e[1]):v=e[y-1];let b;y===o-1?b=i?e[1]:g.clone().multiplyScalar(2).sub(e[y-1]):b=e[y+1];let w=g.clone().sub(v).normalize(),S=b.clone().sub(g).normalize(),P=w.clone().add(S).normalize();c.copy(P),y===0&&(P.equals(a)||P.clone().negate().equals(a))&&a.set(0,0,1);let _=a.clone().cross(P).normalize(),x=P.clone().cross(_).normalize();a.copy(x),u.copy(_),y===0&&(s.copy(x),l.copy(P));let C=new xs().makeBasis(_,x,P);t.push(C)}let d=i?l:c,p=i?s:new tt(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 xs().makeRotationZ(m*y/t.length);t[y].multiply(g)}return t}_applyPathModifiers(e,t,o){let i=e.length,{angle:s,twist:l,startScale:c,endScale:u}=this.inputs.parameters.extrusion,a=new xs,d=new xs;return e.forEach((p,f)=>{let m=f===0?0:f===i-1?1:(f-t)/(i-(o===0?0:1)-(t+(1-o)));a.makeRotationZ(bd.lerp(s,s+l,m));let h=bd.lerp(c,u,m);d.makeScale(h,h,h),p.multiply(a).multiply(d)}),e}_computeShapePoints(e=12,t=be.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 b=y[v-1],w=y[v-0];g.push(b,w)}return g}),l;try{l=ir({windingRule:t,elementType:Ge.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[i]})}catch{l=fs}let c;try{c=ir({windingRule:be.ODD,elementType:Ge.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...s]})}catch{c=nd}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],b=l.vertices[g+1];v<a&&(a=v),v>d&&(d=v),b<p&&(p=b),b>f&&(f=b)}let m=[];for(let h=l.elementCount-1;h>=0;h--){let y=h>=u,g=h*2,v=l.elements[g+0],b=l.elements[g+1],w=v+b,S={start:v,count:b,normals:[],isHole:y,continuous:[],verticesStart:0,verticesCount:0};m.push(S);let P=v,_=w-1,x=v+1,C=o.roundedCurves.length;do{let T=P-v,N=l.vertices[_*2+0],O=l.vertices[_*2+1],A=l.vertices[P*2+0],G=l.vertices[P*2+1],k=l.vertices[x*2+0],$=l.vertices[x*2+1],ee=A-N,Y=G-O,W=Math.sqrt(ee*ee+Y*Y);ee/=W,Y/=W;let H=A-k,V=G-$,R=Math.sqrt(H*H+V*V);H/=R,V/=R,S.normals[T*2+0]=-V,S.normals[T*2+1]=H;let B=l.vertexIndices[P];if(Array.isArray(B))S.continuous[T]=!1;else{let[L,D]=o.getCurveIndexFromVertexId(B-1,!0);if(D>0&&D<1)S.continuous[T]=!0;else{let X=D===1?L+1:L-1;X=(X+C)%C;let q=D===1?0:1,j=o.roundedCurves[L].getTangent(D),F=o.roundedCurves[X].getTangent(q);S.continuous[T]=j.dot(F)>.95}}y&&(S.normals[T*2+0]*=-1,S.normals[T*2+1]*=-1),[_,P,x]=[P,x,x+1],x>=w&&(x-=b)}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 tt,a=new tt,d=new tt,p=new tt,f=new cy;o.forEach((h,y)=>{let g=i[y],v=e.verticesStart*o.length+e.verticesCount*y;for(let b=0;b<e.count;b++){let w=(e.start+b)*2;if(u.set(t[w+0],t[w+1],0),d.copy(u).applyMatrix4(h).add(g),e.continuous[b])p.set(e.normals[b*2+0],e.normals[b*2+1],0);else{let S=b==0?(e.start+e.count-1)*2:w-2;a.set(t[S+0],t[S+1],0),p.copy(u).sub(a),p.set(-p.y,p.x,0),e.isHole||p.negate()}if(p.applyMatrix4(h).normalize(),f.set(b===0?1:b/e.count,y/(o.length-1)),this._insertVertex(s,v,d,p,f),v++,!e.continuous[b]||b===0){if(b===0)p.set(e.normals[b*2+0],e.normals[b*2+1],0),f.set(0,y/(o.length-1));else{let S=b===e.count-1?e.start*2:w+2;a.set(t[S+0],t[S+1],0),p.copy(a).sub(u),p.set(-p.y,p.x,0),e.isHole||p.negate()}p.applyMatrix4(h).normalize(),this._insertVertex(s,v,d,p,f),v++}}});let m=o.length-1;for(let h=0;h<m;h++){let y=e.verticesStart*o.length+e.verticesCount*h,g=e.verticesStart*o.length+e.verticesCount*(h+1),v=0;for(let b=0;b<e.count;b++){(!e.continuous[b]||b===0)&&v++;let w=b===e.count-1?0:v+1,S=y+v,P=y+w,_=g+w,x=g+v;e.isHole?l.push(S,_,P,S,x,_):l.push(S,P,_,S,_,x),v++}}}_closeEnd(e,t,o,i,s,l,c){let u=e.vertexCount,a=new tt(0,0,c?-1:1).applyMatrix4(s),d=new tt,p=new cy;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)}}};import{BufferAttribute as py,BufferGeometry as wd}from"three";import{mergeBufferGeometries as JP}from"three/examples/jsm/utils/BufferGeometryUtils.js";function fy(){let n=new wd;return n.setAttribute("position",new py(new Float32Array([]),3)),n.setIndex(new py(new Uint16Array([]),1)),n}var eT=fy().attributes,tT=12,rT=1,ei=class extends wd{constructor(e,t){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];Object.assign(this.attributes,eT),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=oT(e,t,d),{shapes:f,charWidths:m,charCoords:h}=t.generateShapes(p,e),y=o*.5,g=i*.5,v=f.map(S=>new we().fromShape(S));this.vectorShapes=v;let b=v.map(S=>At.create({shape:S,parameters:{depth:s,extrudeBevelSegments:c,extrudeBevelSize:l,windingRule:s<=0?be.NONZERO:be.ODD,subdivisions:this.isLowResolution&&s>0?rT:tT}})),w=b.length?JP(b):fy();w.translate(-y,g,0),this.dispose(),this.wrappedText=p,this.charCoords=h,this.charWidths=m,this.deleteAttribute("extrudeNormal"),Object.entries(w.attributes).forEach(([S,P])=>{this.setAttribute(S,P)}),this.setIndex(w.index),this.computeBoundingSphere()}clone(){let e=Vr(new wd,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 oT(n,r,e){e=e??n.text;let t=[""],o="";for(let i of e)o+=i,i===" "||i===`
|
|
1
|
+
var k0=Object.create;var xc=Object.defineProperty;var U0=Object.getOwnPropertyDescriptor;var H0=Object.getOwnPropertyNames;var W0=Object.getPrototypeOf,q0=Object.prototype.hasOwnProperty;var sa=(n,r)=>()=>(r||n((r={exports:{}}).exports,r),r.exports),$0=(n,r)=>{for(var e in r)xc(n,e,{get:r[e],enumerable:!0})},Y0=(n,r,e,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of H0(r))!q0.call(n,o)&&o!==e&&xc(n,o,{get:()=>r[o],enumerable:!(t=U0(r,o))||t.enumerable});return n};var aa=(n,r,e)=>(e=n!=null?k0(W0(n)):{},Y0(r||!n||!n.__esModule?xc(e,"default",{value:n,enumerable:!0}):e,n));var bh=sa((Jc,vh)=>{(function(n,r){typeof Jc=="object"?vh.exports=r():typeof define=="function"&&define.amd?define(r):n.Alea=r()})(Jc,function(){"use strict";return n.importState=function(e){var t=new n;return t.importState(e),t},n;function n(){return function(e){var t=0,o=0,i=0,s=1;e.length==0&&(e=[+new Date]);var a=r();t=a(" "),o=a(" "),i=a(" ");for(var c=0;c<e.length;c++)t-=a(e[c]),t<0&&(t+=1),o-=a(e[c]),o<0&&(o+=1),i-=a(e[c]),i<0&&(i+=1);a=null;var u=function(){var l=2091639*t+s*23283064365386963e-26;return t=o,o=i,i=l-(s=l|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(l){t=+l[0]||0,o=+l[1]||0,i=+l[2]||0,s=+l[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 Th=sa((gl,Ph)=>{(function(n,r){typeof gl=="object"&&typeof Ph<"u"?r(gl):typeof define=="function"&&define.amd?define(["exports"],r):r((n=typeof globalThis<"u"?globalThis:n||self).SVDJS={})})(gl,function(n){"use strict";n.SVD=function(r,e,t,o,i){if(e=e===void 0||e,t=t===void 0||t,i=1e-64/(o=o||Math.pow(2,-52)),!r)throw new TypeError("Matrix a is not defined");var s,a,c,u,l,d,p,f,m,h,y,g,x=r[0].length,b=r.length;if(b<x)throw new TypeError("Invalid matrix: m < n");for(var w=[],S=[],P=[],_=e==="f"?b:x,v=h=p=0;v<b;v++)S[v]=new Array(_).fill(0);for(v=0;v<x;v++)P[v]=new Array(x).fill(0);var N,T=new Array(x).fill(0);for(v=0;v<b;v++)for(s=0;s<x;s++)S[v][s]=r[v][s];for(v=0;v<x;v++){for(w[v]=p,m=0,c=v+1,s=v;s<b;s++)m+=Math.pow(S[s][v],2);if(m<i)p=0;else for(f=(d=S[v][v])*(p=d<0?Math.sqrt(m):-Math.sqrt(m))-m,S[v][v]=d-p,s=c;s<x;s++){for(m=0,a=v;a<b;a++)m+=S[a][v]*S[a][s];for(d=m/f,a=v;a<b;a++)S[a][s]=S[a][s]+d*S[a][v]}for(T[v]=p,m=0,s=c;s<x;s++)m+=Math.pow(S[v][s],2);if(m<i)p=0;else{for(f=(d=S[v][v+1])*(p=d<0?Math.sqrt(m):-Math.sqrt(m))-m,S[v][v+1]=d-p,s=c;s<x;s++)w[s]=S[v][s]/f;for(s=c;s<b;s++){for(m=0,a=c;a<x;a++)m+=S[s][a]*S[v][a];for(a=c;a<x;a++)S[s][a]=S[s][a]+m*w[a]}}h<(y=Math.abs(T[v])+Math.abs(w[v]))&&(h=y)}if(t)for(v=x-1;0<=v;v--){if(p!==0){for(f=S[v][v+1]*p,s=c;s<x;s++)P[s][v]=S[v][s]/f;for(s=c;s<x;s++){for(m=0,a=c;a<x;a++)m+=S[v][a]*P[a][s];for(a=c;a<x;a++)P[a][s]=P[a][s]+m*P[a][v]}}for(s=c;s<x;s++)P[v][s]=0,P[s][v]=0;P[v][v]=1,p=w[v],c=v}if(e){if(e==="f")for(v=x;v<b;v++){for(s=x;s<b;s++)S[v][s]=0;S[v][v]=1}for(v=x-1;0<=v;v--){for(c=v+1,p=T[v],s=c;s<_;s++)S[v][s]=0;if(p!==0){for(f=S[v][v]*p,s=c;s<_;s++){for(m=0,a=c;a<b;a++)m+=S[a][v]*S[a][s];for(d=m/f,a=v;a<b;a++)S[a][s]=S[a][s]+d*S[a][v]}for(s=v;s<b;s++)S[s][v]=S[s][v]/p}else for(s=v;s<b;s++)S[s][v]=0;S[v][v]=S[v][v]+1}}for(o*=h,a=x-1;0<=a;a--)for(var C=0;C<50;C++){for(N=!1,c=a;0<=c;c--){if(Math.abs(w[c])<=o){N=!0;break}if(Math.abs(T[c-1])<=o)break}if(!N){for(l=0,u=c-(m=1),v=c;v<a+1&&(d=m*w[v],w[v]=l*w[v],!(Math.abs(d)<=o));v++)if(p=T[v],T[v]=Math.sqrt(d*d+p*p),l=p/(f=T[v]),m=-d/f,e)for(s=0;s<b;s++)y=S[s][u],g=S[s][v],S[s][u]=y*l+g*m,S[s][v]=-y*m+g*l}if(g=T[a],c===a){if(g<0&&(T[a]=-g,t))for(s=0;s<x;s++)P[s][a]=-P[s][a];break}for(h=T[c],d=(((y=T[a-1])-g)*(y+g)+((p=w[a-1])-(f=w[a]))*(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,v=c+(m=l=1);v<a+1;v++){if(p=w[v],y=T[v],f=m*p,p*=l,g=Math.sqrt(d*d+f*f),d=h*(l=d/(w[v-1]=g))+p*(m=f/g),p=-h*m+p*l,f=y*m,y*=l,t)for(s=0;s<x;s++)h=P[s][v-1],g=P[s][v],P[s][v-1]=h*l+g*m,P[s][v]=-h*m+g*l;if(g=Math.sqrt(d*d+f*f),d=(l=d/(T[v-1]=g))*p+(m=f/g)*y,h=-m*p+l*y,e)for(s=0;s<b;s++)y=S[s][v-1],g=S[s][v],S[s][v-1]=y*l+g*m,S[s][v]=-y*m+g*l}w[c]=0,w[a]=d,T[a]=h}for(v=0;v<x;v++)T[v]<o&&(T[v]=0);return{u:S,q:T,v:P}},n.VERSION="1.1.1",Object.defineProperty(n,"__esModule",{value:!0})})});var yg=sa(Zl=>{(function(){"use strict";var n=function(){this.init()};n.prototype={init:function(){var l=this||r;return l._counter=1e3,l._html5AudioPool=[],l.html5PoolSize=10,l._codecs={},l._howls=[],l._muted=!1,l._volume=1,l._canPlayEvent="canplaythrough",l._navigator=typeof window<"u"&&window.navigator?window.navigator:null,l.masterGain=null,l.noAudio=!1,l.usingWebAudio=!0,l.autoSuspend=!0,l.ctx=null,l.autoUnlock=!0,l._setup(),l},volume:function(l){var d=this||r;if(l=parseFloat(l),d.ctx||u(),typeof l<"u"&&l>=0&&l<=1){if(d._volume=l,d._muted)return d;d.usingWebAudio&&d.masterGain.gain.setValueAtTime(l,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*l)}return d}return d._volume},mute:function(l){var d=this||r;d.ctx||u(),d._muted=l,d.usingWebAudio&&d.masterGain.gain.setValueAtTime(l?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=l?!0:h._muted)}return d},stop:function(){for(var l=this||r,d=0;d<l._howls.length;d++)l._howls[d].stop();return l},unload:function(){for(var l=this||r,d=l._howls.length-1;d>=0;d--)l._howls[d].unload();return l.usingWebAudio&&l.ctx&&typeof l.ctx.close<"u"&&(l.ctx.close(),l.ctx=null,u()),l},codecs:function(l){return(this||r)._codecs[l.replace(/^x-/,"")]},_setup:function(){var l=this||r;if(l.state=l.ctx&&l.ctx.state||"suspended",l._autoSuspend(),!l.usingWebAudio)if(typeof Audio<"u")try{var d=new Audio;typeof d.oncanplaythrough>"u"&&(l._canPlayEvent="canplay")}catch{l.noAudio=!0}else l.noAudio=!0;try{var d=new Audio;d.muted&&(l.noAudio=!0)}catch{}return l.noAudio||l._setupCodecs(),l},_setupCodecs:function(){var l=this||r,d=null;try{d=typeof Audio<"u"?new Audio:null}catch{return l}if(!d||typeof d.canPlayType!="function")return l;var p=d.canPlayType("audio/mpeg;").replace(/^no$/,""),f=l._navigator?l._navigator.userAgent:"",m=f.match(/OPR\/([0-6].)/g),h=m&&parseInt(m[0].split("/")[1],10)<33,y=f.indexOf("Safari")!==-1&&f.indexOf("Chrome")===-1,g=f.match(/Version\/(.*?) /),x=y&&g&&parseInt(g[1],10)<15;return l._codecs={mp3:!!(!h&&(p||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:!!(!x&&d.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),webm:!!(!x&&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$/,"")},l},_unlockAudio:function(){var l=this||r;if(!(l._audioUnlocked||!l.ctx)){l._audioUnlocked=!1,l.autoUnlock=!1,!l._mobileUnloaded&&l.ctx.sampleRate!==44100&&(l._mobileUnloaded=!0,l.unload()),l._scratchBuffer=l.ctx.createBuffer(1,1,22050);var d=function(p){for(;l._html5AudioPool.length<l.html5PoolSize;)try{var f=new Audio;f._unlocked=!0,l._releaseHtml5Audio(f)}catch{l.noAudio=!0;break}for(var m=0;m<l._howls.length;m++)if(!l._howls[m]._webAudio)for(var h=l._howls[m]._getSoundIds(),y=0;y<h.length;y++){var g=l._howls[m]._soundById(h[y]);g&&g._node&&!g._node._unlocked&&(g._node._unlocked=!0,g._node.load())}l._autoResume();var x=l.ctx.createBufferSource();x.buffer=l._scratchBuffer,x.connect(l.ctx.destination),typeof x.start>"u"?x.noteOn(0):x.start(0),typeof l.ctx.resume=="function"&&l.ctx.resume(),x.onended=function(){x.disconnect(0),l._audioUnlocked=!0,document.removeEventListener("touchstart",d,!0),document.removeEventListener("touchend",d,!0),document.removeEventListener("click",d,!0),document.removeEventListener("keydown",d,!0);for(var b=0;b<l._howls.length;b++)l._howls[b]._emit("unlock")}};return document.addEventListener("touchstart",d,!0),document.addEventListener("touchend",d,!0),document.addEventListener("click",d,!0),document.addEventListener("keydown",d,!0),l}},_obtainHtml5Audio:function(){var l=this||r;if(l._html5AudioPool.length)return l._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(l){var d=this||r;return l._unlocked&&d._html5AudioPool.push(l),d},_autoSuspend:function(){var l=this;if(!(!l.autoSuspend||!l.ctx||typeof l.ctx.suspend>"u"||!r.usingWebAudio)){for(var d=0;d<l._howls.length;d++)if(l._howls[d]._webAudio){for(var p=0;p<l._howls[d]._sounds.length;p++)if(!l._howls[d]._sounds[p]._paused)return l}return l._suspendTimer&&clearTimeout(l._suspendTimer),l._suspendTimer=setTimeout(function(){if(!!l.autoSuspend){l._suspendTimer=null,l.state="suspending";var f=function(){l.state="suspended",l._resumeAfterSuspend&&(delete l._resumeAfterSuspend,l._autoResume())};l.ctx.suspend().then(f,f)}},3e4),l}},_autoResume:function(){var l=this;if(!(!l.ctx||typeof l.ctx.resume>"u"||!r.usingWebAudio))return l.state==="running"&&l.ctx.state!=="interrupted"&&l._suspendTimer?(clearTimeout(l._suspendTimer),l._suspendTimer=null):l.state==="suspended"||l.state==="running"&&l.ctx.state==="interrupted"?(l.ctx.resume().then(function(){l.state="running";for(var d=0;d<l._howls.length;d++)l._howls[d]._emit("resume")}),l._suspendTimer&&(clearTimeout(l._suspendTimer),l._suspendTimer=null)):l.state==="suspending"&&(l._resumeAfterSuspend=!0),l}};var r=new n,e=function(l){var d=this;if(!l.src||l.src.length===0){console.error("An array of source files must be passed with any new Howl.");return}d.init(l)};e.prototype={init:function(l){var d=this;return r.ctx||u(),d._autoplay=l.autoplay||!1,d._format=typeof l.format!="string"?l.format:[l.format],d._html5=l.html5||!1,d._muted=l.mute||!1,d._loop=l.loop||!1,d._pool=l.pool||5,d._preload=typeof l.preload=="boolean"||l.preload==="metadata"?l.preload:!0,d._rate=l.rate||1,d._sprite=l.sprite||{},d._src=typeof l.src!="string"?l.src:[l.src],d._volume=l.volume!==void 0?l.volume:1,d._xhr={method:l.xhr&&l.xhr.method?l.xhr.method:"GET",headers:l.xhr&&l.xhr.headers?l.xhr.headers:null,withCredentials:l.xhr&&l.xhr.withCredentials?l.xhr.withCredentials:!1},d._duration=0,d._state="unloaded",d._sounds=[],d._endTimers={},d._queue=[],d._playLock=!1,d._onend=l.onend?[{fn:l.onend}]:[],d._onfade=l.onfade?[{fn:l.onfade}]:[],d._onload=l.onload?[{fn:l.onload}]:[],d._onloaderror=l.onloaderror?[{fn:l.onloaderror}]:[],d._onplayerror=l.onplayerror?[{fn:l.onplayerror}]:[],d._onpause=l.onpause?[{fn:l.onpause}]:[],d._onplay=l.onplay?[{fn:l.onplay}]:[],d._onstop=l.onstop?[{fn:l.onstop}]:[],d._onmute=l.onmute?[{fn:l.onmute}]:[],d._onvolume=l.onvolume?[{fn:l.onvolume}]:[],d._onrate=l.onrate?[{fn:l.onrate}]:[],d._onseek=l.onseek?[{fn:l.onseek}]:[],d._onunlock=l.onunlock?[{fn:l.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 l=this,d=null;if(r.noAudio){l._emit("loaderror",null,"No audio support.");return}typeof l._src=="string"&&(l._src=[l._src]);for(var p=0;p<l._src.length;p++){var f,m;if(l._format&&l._format[p])f=l._format[p];else{if(m=l._src[p],typeof m!="string"){l._emit("loaderror",null,"Non-string found in selected audio sources - ignoring.");continue}f=/^data:audio\/([^;,]+);/i.exec(m),f||(f=/\.([^.]+)$/.exec(m.split("?",1)[0])),f&&(f=f[1].toLowerCase())}if(f||console.warn('No file extension was found. Consider using the "format" property or specify an extension.'),f&&r.codecs(f)){d=l._src[p];break}}if(!d){l._emit("loaderror",null,"No codec support for selected audio sources.");return}return l._src=d,l._state="loading",window.location.protocol==="https:"&&d.slice(0,5)==="http:"&&(l._html5=!0,l._webAudio=!1),new t(l),l._webAudio&&i(l),l},play:function(l,d){var p=this,f=null;if(typeof l=="number")f=l,l=null;else{if(typeof l=="string"&&p._state==="loaded"&&!p._sprite[l])return null;if(typeof l>"u"&&(l="__default",!p._playLock)){for(var m=0,h=0;h<p._sounds.length;h++)p._sounds[h]._paused&&!p._sounds[h]._ended&&(m++,f=p._sounds[h]._id);m===1?l=null:f=null}}var y=f?p._soundById(f):p._inactiveSound();if(!y)return null;if(f&&!l&&(l=y._sprite||"__default"),p._state!=="loaded"){y._sprite=l,y._ended=!1;var g=y._id;return p._queue.push({event:"play",action:function(){p.play(g)}}),g}if(f&&!y._paused)return d||p._loadQueue("play"),y._id;p._webAudio&&r._autoResume();var x=Math.max(0,y._seek>0?y._seek:p._sprite[l][0]/1e3),b=Math.max(0,(p._sprite[l][0]+p._sprite[l][1])/1e3-x),w=b*1e3/Math.abs(y._rate),S=p._sprite[l][0]/1e3,P=(p._sprite[l][0]+p._sprite[l][1])/1e3;y._sprite=l,y._ended=!1;var _=function(){y._paused=!1,y._seek=x,y._start=S,y._stop=P,y._loop=!!(y._loop||p._sprite[l][2])};if(x>=P){p._ended(y);return}var v=y._node;if(p._webAudio){var N=function(){p._playLock=!1,_(),p._refreshBuffer(y);var A=y._muted||p._muted?0:y._volume;v.gain.setValueAtTime(A,r.ctx.currentTime),y._playStart=r.ctx.currentTime,typeof v.bufferSource.start>"u"?y._loop?v.bufferSource.noteGrainOn(0,x,86400):v.bufferSource.noteGrainOn(0,x,b):y._loop?v.bufferSource.start(0,x,86400):v.bufferSource.start(0,x,b),w!==1/0&&(p._endTimers[y._id]=setTimeout(p._ended.bind(p,y),w)),d||setTimeout(function(){p._emit("play",y._id),p._loadQueue()},0)};r.state==="running"&&r.ctx.state!=="interrupted"?N():(p._playLock=!0,p.once("resume",N),p._clearTimer(y._id))}else{var T=function(){v.currentTime=x,v.muted=y._muted||p._muted||r._muted||v.muted,v.volume=y._volume*r.volume(),v.playbackRate=y._rate;try{var A=v.play();if(A&&typeof Promise<"u"&&(A instanceof Promise||typeof A.then=="function")?(p._playLock=!0,_(),A.then(function(){p._playLock=!1,v._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)),v.playbackRate=y._rate,v.paused){p._emit("playerror",y._id,"Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction.");return}l!=="__default"||y._loop?p._endTimers[y._id]=setTimeout(p._ended.bind(p,y),w):(p._endTimers[y._id]=function(){p._ended(y),v.removeEventListener("ended",p._endTimers[y._id],!1)},v.addEventListener("ended",p._endTimers[y._id],!1))}catch(R){p._emit("playerror",y._id,R)}};v.src==="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA"&&(v.src=p._src,v.load());var C=window&&window.ejecta||!v.readyState&&r._navigator.isCocoonJS;if(v.readyState>=3||C)T();else{p._playLock=!0,p._state="loading";var O=function(){p._state="loaded",T(),v.removeEventListener(r._canPlayEvent,O,!1)};v.addEventListener(r._canPlayEvent,O,!1),p._clearTimer(y._id)}}return y._id},pause:function(l){var d=this;if(d._state!=="loaded"||d._playLock)return d._queue.push({event:"pause",action:function(){d.pause(l)}}),d;for(var p=d._getSoundIds(l),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(l,d){var p=this;if(p._state!=="loaded"||p._playLock)return p._queue.push({event:"stop",action:function(){p.stop(l)}}),p;for(var f=p._getSoundIds(l),m=0;m<f.length;m++){p._clearTimer(f[m]);var h=p._soundById(f[m]);h&&(h._seek=h._start||0,h._rateSeek=0,h._paused=!0,h._ended=!0,p._stopFade(f[m]),h._node&&(p._webAudio?h._node.bufferSource&&(typeof h._node.bufferSource.stop>"u"?h._node.bufferSource.noteOff(0):h._node.bufferSource.stop(0),p._cleanBuffer(h._node)):(!isNaN(h._node.duration)||h._node.duration===1/0)&&(h._node.currentTime=h._start||0,h._node.pause(),h._node.duration===1/0&&p._clearSound(h._node))),d||p._emit("stop",h._id))}return p},mute:function(l,d){var p=this;if(p._state!=="loaded"||p._playLock)return p._queue.push({event:"mute",action:function(){p.mute(l,d)}}),p;if(typeof d>"u")if(typeof l=="boolean")p._muted=l;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=l,h._interval&&p._stopFade(h._id),p._webAudio&&h._node?h._node.gain.setValueAtTime(l?0:h._volume,r.ctx.currentTime):h._node&&(h._node.muted=r._muted?!0:l),p._emit("mute",h._id))}return p},volume:function(){var l=this,d=arguments,p,f;if(d.length===0)return l._volume;if(d.length===1||d.length===2&&typeof d[1]>"u"){var m=l._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(l._state!=="loaded"||l._playLock)return l._queue.push({event:"volume",action:function(){l.volume.apply(l,d)}}),l;typeof f>"u"&&(l._volume=p),f=l._getSoundIds(f);for(var g=0;g<f.length;g++)y=l._soundById(f[g]),y&&(y._volume=p,d[2]||l._stopFade(f[g]),l._webAudio&&y._node&&!y._muted?y._node.gain.setValueAtTime(p,r.ctx.currentTime):y._node&&!y._muted&&(y._node.volume=p*r.volume()),l._emit("volume",y._id))}else return y=f?l._soundById(f):l._sounds[0],y?y._volume:0;return l},fade:function(l,d,p,f){var m=this;if(m._state!=="loaded"||m._playLock)return m._queue.push({event:"fade",action:function(){m.fade(l,d,p,f)}}),m;l=Math.min(Math.max(0,parseFloat(l)),1),d=Math.min(Math.max(0,parseFloat(d)),1),p=parseFloat(p),m.volume(l,f);for(var h=m._getSoundIds(f),y=0;y<h.length;y++){var g=m._soundById(h[y]);if(g){if(f||m._stopFade(h[y]),m._webAudio&&!g._muted){var x=r.ctx.currentTime,b=x+p/1e3;g._volume=l,g._node.gain.setValueAtTime(l,x),g._node.gain.linearRampToValueAtTime(d,b)}m._startFadeInterval(g,l,d,p,h[y],typeof f>"u")}}return m},_startFadeInterval:function(l,d,p,f,m,h){var y=this,g=d,x=p-d,b=Math.abs(x/.01),w=Math.max(4,b>0?f/b:f),S=Date.now();l._fadeTo=p,l._interval=setInterval(function(){var P=(Date.now()-S)/f;S=Date.now(),g+=x*P,g=Math.round(g*100)/100,x<0?g=Math.max(p,g):g=Math.min(p,g),y._webAudio?l._volume=g:y.volume(g,l._id,!0),h&&(y._volume=g),(p<d&&g<=p||p>d&&g>=p)&&(clearInterval(l._interval),l._interval=null,l._fadeTo=null,y.volume(p,l._id),y._emit("fade",l._id))},w)},_stopFade:function(l){var d=this,p=d._soundById(l);return p&&p._interval&&(d._webAudio&&p._node.gain.cancelScheduledValues(r.ctx.currentTime),clearInterval(p._interval),p._interval=null,d.volume(p._fadeTo,l),p._fadeTo=null,d._emit("fade",l)),d},loop:function(){var l=this,d=arguments,p,f,m;if(d.length===0)return l._loop;if(d.length===1)if(typeof d[0]=="boolean")p=d[0],l._loop=p;else return m=l._soundById(parseInt(d[0],10)),m?m._loop:!1;else d.length===2&&(p=d[0],f=parseInt(d[1],10));for(var h=l._getSoundIds(f),y=0;y<h.length;y++)m=l._soundById(h[y]),m&&(m._loop=p,l._webAudio&&m._node&&m._node.bufferSource&&(m._node.bufferSource.loop=p,p&&(m._node.bufferSource.loopStart=m._start||0,m._node.bufferSource.loopEnd=m._stop,l.playing(h[y])&&(l.pause(h[y],!0),l.play(h[y],!0)))));return l},rate:function(){var l=this,d=arguments,p,f;if(d.length===0)f=l._sounds[0]._id;else if(d.length===1){var m=l._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(l._state!=="loaded"||l._playLock)return l._queue.push({event:"rate",action:function(){l.rate.apply(l,d)}}),l;typeof f>"u"&&(l._rate=p),f=l._getSoundIds(f);for(var g=0;g<f.length;g++)if(y=l._soundById(f[g]),y){l.playing(f[g])&&(y._rateSeek=l.seek(f[g]),y._playStart=l._webAudio?r.ctx.currentTime:y._playStart),y._rate=p,l._webAudio&&y._node&&y._node.bufferSource?y._node.bufferSource.playbackRate.setValueAtTime(p,r.ctx.currentTime):y._node&&(y._node.playbackRate=p);var x=l.seek(f[g]),b=(l._sprite[y._sprite][0]+l._sprite[y._sprite][1])/1e3-x,w=b*1e3/Math.abs(y._rate);(l._endTimers[f[g]]||!y._paused)&&(l._clearTimer(f[g]),l._endTimers[f[g]]=setTimeout(l._ended.bind(l,y),w)),l._emit("rate",y._id)}}else return y=l._soundById(f),y?y._rate:l._rate;return l},seek:function(){var l=this,d=arguments,p,f;if(d.length===0)l._sounds.length&&(f=l._sounds[0]._id);else if(d.length===1){var m=l._getSoundIds(),h=m.indexOf(d[0]);h>=0?f=parseInt(d[0],10):l._sounds.length&&(f=l._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"&&(l._state!=="loaded"||l._playLock))return l._queue.push({event:"seek",action:function(){l.seek.apply(l,d)}}),l;var y=l._soundById(f);if(y)if(typeof p=="number"&&p>=0){var g=l.playing(f);g&&l.pause(f,!0),y._seek=p,y._ended=!1,l._clearTimer(f),!l._webAudio&&y._node&&!isNaN(y._node.duration)&&(y._node.currentTime=p);var x=function(){g&&l.play(f,!0),l._emit("seek",f)};if(g&&!l._webAudio){var b=function(){l._playLock?setTimeout(b,0):x()};setTimeout(b,0)}else x()}else if(l._webAudio){var w=l.playing(f)?r.ctx.currentTime-y._playStart:0,S=y._rateSeek?y._rateSeek-y._seek:0;return y._seek+(S+w*Math.abs(y._rate))}else return y._node.currentTime;return l},playing:function(l){var d=this;if(typeof l=="number"){var p=d._soundById(l);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(l){var d=this,p=d._duration,f=d._soundById(l);return f&&(p=d._sprite[f._sprite][1]/1e3),p},state:function(){return this._state},unload:function(){for(var l=this,d=l._sounds,p=0;p<d.length;p++)d[p]._paused||l.stop(d[p]._id),l._webAudio||(l._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,l._clearTimer(d[p]._id);var f=r._howls.indexOf(l);f>=0&&r._howls.splice(f,1);var m=!0;for(p=0;p<r._howls.length;p++)if(r._howls[p]._src===l._src||l._src.indexOf(r._howls[p]._src)>=0){m=!1;break}return o&&m&&delete o[l._src],r.noAudio=!1,l._state="unloaded",l._sounds=[],l=null,null},on:function(l,d,p,f){var m=this,h=m["_on"+l];return typeof d=="function"&&h.push(f?{id:p,fn:d,once:f}:{id:p,fn:d}),m},off:function(l,d,p){var f=this,m=f["_on"+l],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(l)f["_on"+l]=[];else{var g=Object.keys(f);for(h=0;h<g.length;h++)g[h].indexOf("_on")===0&&Array.isArray(f[g[h]])&&(f[g[h]]=[])}return f},once:function(l,d,p){var f=this;return f.on(l,d,p,1),f},_emit:function(l,d,p){for(var f=this,m=f["_on"+l],h=m.length-1;h>=0;h--)(!m[h].id||m[h].id===d||l==="load")&&(setTimeout(function(y){y.call(this,d,p)}.bind(f,m[h].fn),0),m[h].once&&f.off(l,m[h].fn,m[h].id));return f._loadQueue(l),f},_loadQueue:function(l){var d=this;if(d._queue.length>0){var p=d._queue[0];p.event===l&&(d._queue.shift(),d._loadQueue()),l||p.action()}return d},_ended:function(l){var d=this,p=l._sprite;if(!d._webAudio&&l._node&&!l._node.paused&&!l._node.ended&&l._node.currentTime<l._stop)return setTimeout(d._ended.bind(d,l),100),d;var f=!!(l._loop||d._sprite[p][2]);if(d._emit("end",l._id),!d._webAudio&&f&&d.stop(l._id,!0).play(l._id),d._webAudio&&f){d._emit("play",l._id),l._seek=l._start||0,l._rateSeek=0,l._playStart=r.ctx.currentTime;var m=(l._stop-l._start)*1e3/Math.abs(l._rate);d._endTimers[l._id]=setTimeout(d._ended.bind(d,l),m)}return d._webAudio&&!f&&(l._paused=!0,l._ended=!0,l._seek=l._start||0,l._rateSeek=0,d._clearTimer(l._id),d._cleanBuffer(l._node),r._autoSuspend()),!d._webAudio&&!f&&d.stop(l._id,!0),d},_clearTimer:function(l){var d=this;if(d._endTimers[l]){if(typeof d._endTimers[l]!="function")clearTimeout(d._endTimers[l]);else{var p=d._soundById(l);p&&p._node&&p._node.removeEventListener("ended",d._endTimers[l],!1)}delete d._endTimers[l]}return d},_soundById:function(l){for(var d=this,p=0;p<d._sounds.length;p++)if(l===d._sounds[p]._id)return d._sounds[p];return null},_inactiveSound:function(){var l=this;l._drain();for(var d=0;d<l._sounds.length;d++)if(l._sounds[d]._ended)return l._sounds[d].reset();return new t(l)},_drain:function(){var l=this,d=l._pool,p=0,f=0;if(!(l._sounds.length<d)){for(f=0;f<l._sounds.length;f++)l._sounds[f]._ended&&p++;for(f=l._sounds.length-1;f>=0;f--){if(p<=d)return;l._sounds[f]._ended&&(l._webAudio&&l._sounds[f]._node&&l._sounds[f]._node.disconnect(0),l._sounds.splice(f,1),p--)}}},_getSoundIds:function(l){var d=this;if(typeof l>"u"){for(var p=[],f=0;f<d._sounds.length;f++)p.push(d._sounds[f]._id);return p}else return[l]},_refreshBuffer:function(l){var d=this;return l._node.bufferSource=r.ctx.createBufferSource(),l._node.bufferSource.buffer=o[d._src],l._panner?l._node.bufferSource.connect(l._panner):l._node.bufferSource.connect(l._node),l._node.bufferSource.loop=l._loop,l._loop&&(l._node.bufferSource.loopStart=l._start||0,l._node.bufferSource.loopEnd=l._stop||0),l._node.bufferSource.playbackRate.setValueAtTime(l._rate,r.ctx.currentTime),d},_cleanBuffer:function(l){var d=this,p=r._navigator&&r._navigator.vendor.indexOf("Apple")>=0;if(r._scratchBuffer&&l.bufferSource&&(l.bufferSource.onended=null,l.bufferSource.disconnect(0),p))try{l.bufferSource.buffer=r._scratchBuffer}catch{}return l.bufferSource=null,d},_clearSound:function(l){var d=/MSIE |Trident\//.test(r._navigator&&r._navigator.userAgent);d||(l.src="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA")}};var t=function(l){this._parent=l,this.init()};t.prototype={init:function(){var l=this,d=l._parent;return l._muted=d._muted,l._loop=d._loop,l._volume=d._volume,l._rate=d._rate,l._seek=0,l._paused=!0,l._ended=!0,l._sprite="__default",l._id=++r._counter,d._sounds.push(l),l.create(),l},create:function(){var l=this,d=l._parent,p=r._muted||l._muted||l._parent._muted?0:l._volume;return d._webAudio?(l._node=typeof r.ctx.createGain>"u"?r.ctx.createGainNode():r.ctx.createGain(),l._node.gain.setValueAtTime(p,r.ctx.currentTime),l._node.paused=!0,l._node.connect(r.masterGain)):r.noAudio||(l._node=r._obtainHtml5Audio(),l._errorFn=l._errorListener.bind(l),l._node.addEventListener("error",l._errorFn,!1),l._loadFn=l._loadListener.bind(l),l._node.addEventListener(r._canPlayEvent,l._loadFn,!1),l._endFn=l._endListener.bind(l),l._node.addEventListener("ended",l._endFn,!1),l._node.src=d._src,l._node.preload=d._preload===!0?"auto":d._preload,l._node.volume=p*r.volume(),l._node.load()),l},reset:function(){var l=this,d=l._parent;return l._muted=d._muted,l._loop=d._loop,l._volume=d._volume,l._rate=d._rate,l._seek=0,l._rateSeek=0,l._paused=!0,l._ended=!0,l._sprite="__default",l._id=++r._counter,l},_errorListener:function(){var l=this;l._parent._emit("loaderror",l._id,l._node.error?l._node.error.code:0),l._node.removeEventListener("error",l._errorFn,!1)},_loadListener:function(){var l=this,d=l._parent;d._duration=Math.ceil(l._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()),l._node.removeEventListener(r._canPlayEvent,l._loadFn,!1)},_endListener:function(){var l=this,d=l._parent;d._duration===1/0&&(d._duration=Math.ceil(l._node.duration*10)/10,d._sprite.__default[1]===1/0&&(d._sprite.__default[1]=d._duration*1e3),d._ended(l)),l._node.removeEventListener("ended",l._endFn,!1)}};var o={},i=function(l){var d=l._src;if(o[d]){l._duration=o[d].duration,c(l);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);a(f.buffer,l)}else{var h=new XMLHttpRequest;h.open(l._xhr.method,d,!0),h.withCredentials=l._xhr.withCredentials,h.responseType="arraybuffer",l._xhr.headers&&Object.keys(l._xhr.headers).forEach(function(y){h.setRequestHeader(y,l._xhr.headers[y])}),h.onload=function(){var y=(h.status+"")[0];if(y!=="0"&&y!=="2"&&y!=="3"){l._emit("loaderror",null,"Failed loading audio file with status: "+h.status+".");return}a(h.response,l)},h.onerror=function(){l._webAudio&&(l._html5=!0,l._webAudio=!1,l._sounds=[],delete o[d],l.load())},s(h)}},s=function(l){try{l.send()}catch{l.onerror()}},a=function(l,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(l).then(f).catch(p):r.ctx.decodeAudioData(l,f,p)},c=function(l,d){d&&!l._duration&&(l._duration=d.duration),Object.keys(l._sprite).length===0&&(l._sprite={__default:[0,l._duration*1e3]}),l._state!=="loaded"&&(l._state="loaded",l._emit("load"),l._loadQueue())},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 l=/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(l&&p&&p<9){var f=/safari/.test(r._navigator&&r._navigator.userAgent.toLowerCase());r._navigator&&!f&&(r.usingWebAudio=!1)}r.usingWebAudio&&(r.masterGain=typeof r.ctx.createGain>"u"?r.ctx.createGainNode():r.ctx.createGain(),r.masterGain.gain.setValueAtTime(r._muted?0:r._volume,r.ctx.currentTime),r.masterGain.connect(r.ctx.destination)),r._setup()}};typeof define=="function"&&define.amd&&define([],function(){return{Howler:r,Howl:e}}),typeof Zl<"u"&&(Zl.Howler=r,Zl.Howl=e),typeof global<"u"?(global.HowlerGlobal=n,global.Howler=r,global.Howl=e,global.Sound=t):typeof window<"u"&&(window.HowlerGlobal=n,window.Howler=r,window.Howl=e,window.Sound=t)})();(function(){"use strict";HowlerGlobal.prototype._pos=[0,0,0],HowlerGlobal.prototype._orientation=[0,0,-1,0,1,0],HowlerGlobal.prototype.stereo=function(r){var e=this;if(!e.ctx||!e.ctx.listener)return e;for(var t=e._howls.length-1;t>=0;t--)e._howls[t].stereo(r);return e},HowlerGlobal.prototype.pos=function(r,e,t){var o=this;if(!o.ctx||!o.ctx.listener)return o;if(e=typeof e!="number"?o._pos[1]:e,t=typeof t!="number"?o._pos[2]:t,typeof r=="number")o._pos=[r,e,t],typeof o.ctx.listener.positionX<"u"?(o.ctx.listener.positionX.setTargetAtTime(o._pos[0],Howler.ctx.currentTime,.1),o.ctx.listener.positionY.setTargetAtTime(o._pos[1],Howler.ctx.currentTime,.1),o.ctx.listener.positionZ.setTargetAtTime(o._pos[2],Howler.ctx.currentTime,.1)):o.ctx.listener.setPosition(o._pos[0],o._pos[1],o._pos[2]);else return o._pos;return o},HowlerGlobal.prototype.orientation=function(r,e,t,o,i,s){var a=this;if(!a.ctx||!a.ctx.listener)return a;var c=a._orientation;if(e=typeof e!="number"?c[1]:e,t=typeof t!="number"?c[2]:t,o=typeof o!="number"?c[3]:o,i=typeof i!="number"?c[4]:i,s=typeof s!="number"?c[5]:s,typeof r=="number")a._orientation=[r,e,t,o,i,s],typeof a.ctx.listener.forwardX<"u"?(a.ctx.listener.forwardX.setTargetAtTime(r,Howler.ctx.currentTime,.1),a.ctx.listener.forwardY.setTargetAtTime(e,Howler.ctx.currentTime,.1),a.ctx.listener.forwardZ.setTargetAtTime(t,Howler.ctx.currentTime,.1),a.ctx.listener.upX.setTargetAtTime(o,Howler.ctx.currentTime,.1),a.ctx.listener.upY.setTargetAtTime(i,Howler.ctx.currentTime,.1),a.ctx.listener.upZ.setTargetAtTime(s,Howler.ctx.currentTime,.1)):a.ctx.listener.setOrientation(r,e,t,o,i,s);else return c;return a},Howl.prototype.init=function(r){return function(e){var t=this;return t._orientation=e.orientation||[1,0,0],t._stereo=e.stereo||null,t._pos=e.pos||null,t._pannerAttr={coneInnerAngle:typeof e.coneInnerAngle<"u"?e.coneInnerAngle:360,coneOuterAngle:typeof e.coneOuterAngle<"u"?e.coneOuterAngle:360,coneOuterGain:typeof e.coneOuterGain<"u"?e.coneOuterGain:0,distanceModel:typeof e.distanceModel<"u"?e.distanceModel:"inverse",maxDistance:typeof e.maxDistance<"u"?e.maxDistance:1e4,panningModel:typeof e.panningModel<"u"?e.panningModel:"HRTF",refDistance:typeof e.refDistance<"u"?e.refDistance:1,rolloffFactor:typeof e.rolloffFactor<"u"?e.rolloffFactor:1},t._onstereo=e.onstereo?[{fn:e.onstereo}]:[],t._onpos=e.onpos?[{fn:e.onpos}]:[],t._onorientation=e.onorientation?[{fn:e.onorientation}]:[],r.call(this,e)}}(Howl.prototype.init),Howl.prototype.stereo=function(r,e){var t=this;if(!t._webAudio)return t;if(t._state!=="loaded")return t._queue.push({event:"stereo",action:function(){t.stereo(r,e)}}),t;var o=typeof Howler.ctx.createStereoPanner>"u"?"spatial":"stereo";if(typeof e>"u")if(typeof r=="number")t._stereo=r,t._pos=[r,0,0];else return t._stereo;for(var i=t._getSoundIds(e),s=0;s<i.length;s++){var a=t._soundById(i[s]);if(a)if(typeof r=="number")a._stereo=r,a._pos=[r,0,0],a._node&&(a._pannerAttr.panningModel="equalpower",(!a._panner||!a._panner.pan)&&n(a,o),o==="spatial"?typeof a._panner.positionX<"u"?(a._panner.positionX.setValueAtTime(r,Howler.ctx.currentTime),a._panner.positionY.setValueAtTime(0,Howler.ctx.currentTime),a._panner.positionZ.setValueAtTime(0,Howler.ctx.currentTime)):a._panner.setPosition(r,0,0):a._panner.pan.setValueAtTime(r,Howler.ctx.currentTime)),t._emit("stereo",a._id);else return a._stereo}return t},Howl.prototype.pos=function(r,e,t,o){var i=this;if(!i._webAudio)return i;if(i._state!=="loaded")return i._queue.push({event:"pos",action:function(){i.pos(r,e,t,o)}}),i;if(e=typeof e!="number"?0:e,t=typeof t!="number"?-.5:t,typeof o>"u")if(typeof r=="number")i._pos=[r,e,t];else return i._pos;for(var s=i._getSoundIds(o),a=0;a<s.length;a++){var c=i._soundById(s[a]);if(c)if(typeof r=="number")c._pos=[r,e,t],c._node&&((!c._panner||c._panner.pan)&&n(c,"spatial"),typeof c._panner.positionX<"u"?(c._panner.positionX.setValueAtTime(r,Howler.ctx.currentTime),c._panner.positionY.setValueAtTime(e,Howler.ctx.currentTime),c._panner.positionZ.setValueAtTime(t,Howler.ctx.currentTime)):c._panner.setPosition(r,e,t)),i._emit("pos",c._id);else return c._pos}return i},Howl.prototype.orientation=function(r,e,t,o){var i=this;if(!i._webAudio)return i;if(i._state!=="loaded")return i._queue.push({event:"orientation",action:function(){i.orientation(r,e,t,o)}}),i;if(e=typeof e!="number"?i._orientation[1]:e,t=typeof t!="number"?i._orientation[2]:t,typeof o>"u")if(typeof r=="number")i._orientation=[r,e,t];else return i._orientation;for(var s=i._getSoundIds(o),a=0;a<s.length;a++){var c=i._soundById(s[a]);if(c)if(typeof r=="number")c._orientation=[r,e,t],c._node&&(c._panner||(c._pos||(c._pos=i._pos||[0,0,-.5]),n(c,"spatial")),typeof c._panner.orientationX<"u"?(c._panner.orientationX.setValueAtTime(r,Howler.ctx.currentTime),c._panner.orientationY.setValueAtTime(e,Howler.ctx.currentTime),c._panner.orientationZ.setValueAtTime(t,Howler.ctx.currentTime)):c._panner.setOrientation(r,e,t)),i._emit("orientation",c._id);else return c._orientation}return i},Howl.prototype.pannerAttr=function(){var r=this,e=arguments,t,o,i;if(!r._webAudio)return r;if(e.length===0)return r._pannerAttr;if(e.length===1)if(typeof e[0]=="object")t=e[0],typeof o>"u"&&(t.pannerAttr||(t.pannerAttr={coneInnerAngle:t.coneInnerAngle,coneOuterAngle:t.coneOuterAngle,coneOuterGain:t.coneOuterGain,distanceModel:t.distanceModel,maxDistance:t.maxDistance,refDistance:t.refDistance,rolloffFactor:t.rolloffFactor,panningModel:t.panningModel}),r._pannerAttr={coneInnerAngle:typeof t.pannerAttr.coneInnerAngle<"u"?t.pannerAttr.coneInnerAngle:r._coneInnerAngle,coneOuterAngle:typeof t.pannerAttr.coneOuterAngle<"u"?t.pannerAttr.coneOuterAngle:r._coneOuterAngle,coneOuterGain:typeof t.pannerAttr.coneOuterGain<"u"?t.pannerAttr.coneOuterGain:r._coneOuterGain,distanceModel:typeof t.pannerAttr.distanceModel<"u"?t.pannerAttr.distanceModel:r._distanceModel,maxDistance:typeof t.pannerAttr.maxDistance<"u"?t.pannerAttr.maxDistance:r._maxDistance,refDistance:typeof t.pannerAttr.refDistance<"u"?t.pannerAttr.refDistance:r._refDistance,rolloffFactor:typeof t.pannerAttr.rolloffFactor<"u"?t.pannerAttr.rolloffFactor:r._rolloffFactor,panningModel:typeof t.pannerAttr.panningModel<"u"?t.pannerAttr.panningModel:r._panningModel});else return i=r._soundById(parseInt(e[0],10)),i?i._pannerAttr:r._pannerAttr;else e.length===2&&(t=e[0],o=parseInt(e[1],10));for(var s=r._getSoundIds(o),a=0;a<s.length;a++)if(i=r._soundById(s[a]),i){var c=i._pannerAttr;c={coneInnerAngle:typeof t.coneInnerAngle<"u"?t.coneInnerAngle:c.coneInnerAngle,coneOuterAngle:typeof t.coneOuterAngle<"u"?t.coneOuterAngle:c.coneOuterAngle,coneOuterGain:typeof t.coneOuterGain<"u"?t.coneOuterGain:c.coneOuterGain,distanceModel:typeof t.distanceModel<"u"?t.distanceModel:c.distanceModel,maxDistance:typeof t.maxDistance<"u"?t.maxDistance:c.maxDistance,refDistance:typeof t.refDistance<"u"?t.refDistance:c.refDistance,rolloffFactor:typeof t.rolloffFactor<"u"?t.rolloffFactor:c.rolloffFactor,panningModel:typeof t.panningModel<"u"?t.panningModel:c.panningModel};var 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 M0=sa((XJ,I0)=>{I0.exports=function(r,e){for(var t=r.split("."),o=e.split("."),i=0;i<3;i++){var s=Number(t[i]),a=Number(o[i]);if(s>a)return 1;if(a>s)return-1;if(!isNaN(s)&&isNaN(a))return 1;if(isNaN(s)&&!isNaN(a))return-1}return 0}});import{FileLoader as XC,Loader as KC}from"three";function Hu(n){for(let r of Object.keys(n))n[r]===void 0&&delete n[r];return n}function Jt(n,r){return Object.setPrototypeOf(n,r),n}function la(n){return Array.isArray(n)?n:[n]}function Wu(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 X0=typeof global=="object"&&global&&global.Object===Object&&global,ca=X0;var K0=typeof self=="object"&&self&&self.Object===Object&&self,Z0=ca||K0||Function("return this")(),$e=Z0;var Q0=$e.Symbol,et=Q0;var qu=Object.prototype,J0=qu.hasOwnProperty,ex=qu.toString,es=et?et.toStringTag:void 0;function tx(n){var r=J0.call(n,es),e=n[es];try{n[es]=void 0;var t=!0}catch{}var o=ex.call(n);return t&&(r?n[es]=e:delete n[es]),o}var $u=tx;var rx=Object.prototype,ox=rx.toString;function nx(n){return ox.call(n)}var Yu=nx;var ix="[object Null]",sx="[object Undefined]",Xu=et?et.toStringTag:void 0;function ax(n){return n==null?n===void 0?sx:ix:Xu&&Xu in Object(n)?$u(n):Yu(n)}var Vt=ax;function lx(n){return n!=null&&typeof n=="object"}var ct=lx;var cx="[object Symbol]";function dx(n){return typeof n=="symbol"||ct(n)&&Vt(n)==cx}var fn=dx;function ux(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 da=ux;var px=Array.isArray,je=px;var fx=1/0,Ku=et?et.prototype:void 0,Zu=Ku?Ku.toString:void 0;function Qu(n){if(typeof n=="string")return n;if(je(n))return da(n,Qu)+"";if(fn(n))return Zu?Zu.call(n):"";var r=n+"";return r=="0"&&1/n==-fx?"-0":r}var Ju=Qu;function mx(n){var r=typeof n;return n!=null&&(r=="object"||r=="function")}var zt=mx;function hx(n){return n}var ep=hx;var yx="[object AsyncFunction]",gx="[object Function]",xx="[object GeneratorFunction]",vx="[object Proxy]";function bx(n){if(!zt(n))return!1;var r=Vt(n);return r==gx||r==xx||r==yx||r==vx}var ua=bx;var Sx=$e["__core-js_shared__"],pa=Sx;var tp=function(){var n=/[^.]+$/.exec(pa&&pa.keys&&pa.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}();function wx(n){return!!tp&&tp in n}var rp=wx;var _x=Function.prototype,Px=_x.toString;function Tx(n){if(n!=null){try{return Px.call(n)}catch{}try{return n+""}catch{}}return""}var Ur=Tx;var Ox=/[\\^$.*+?()[\]{}|]/g,Ax=/^\[object .+?Constructor\]$/,Cx=Function.prototype,Nx=Object.prototype,Ix=Cx.toString,Mx=Nx.hasOwnProperty,Ex=RegExp("^"+Ix.call(Mx).replace(Ox,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Lx(n){if(!zt(n)||rp(n))return!1;var r=ua(n)?Ex:Ax;return r.test(Ur(n))}var op=Lx;function Dx(n,r){return n?.[r]}var np=Dx;function Bx(n,r){var e=np(n,r);return op(e)?e:void 0}var Ct=Bx;var Rx=Ct($e,"WeakMap"),fa=Rx;var ip=Object.create,Gx=function(){function n(){}return function(r){if(!zt(r))return{};if(ip)return ip(r);n.prototype=r;var e=new n;return n.prototype=void 0,e}}(),sp=Gx;function Vx(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 ap=Vx;function zx(n,r){var e=-1,t=n.length;for(r||(r=Array(t));++e<t;)r[e]=n[e];return r}var lp=zx;var jx=800,Fx=16,kx=Date.now;function Ux(n){var r=0,e=0;return function(){var t=kx(),o=Fx-(t-e);if(e=t,o>0){if(++r>=jx)return arguments[0]}else r=0;return n.apply(void 0,arguments)}}var cp=Ux;function Hx(n){return function(){return n}}var dp=Hx;var Wx=function(){try{var n=Ct(Object,"defineProperty");return n({},"",{}),n}catch{}}(),mn=Wx;var qx=mn?function(n,r){return mn(n,"toString",{configurable:!0,enumerable:!1,value:dp(r),writable:!0})}:ep,up=qx;var $x=cp(up),pp=$x;function Yx(n,r){for(var e=-1,t=n==null?0:n.length;++e<t&&r(n[e],e,n)!==!1;);return n}var fp=Yx;var Xx=9007199254740991,Kx=/^(?:0|[1-9]\d*)$/;function Zx(n,r){var e=typeof n;return r=r??Xx,!!r&&(e=="number"||e!="symbol"&&Kx.test(n))&&n>-1&&n%1==0&&n<r}var hn=Zx;function Qx(n,r,e){r=="__proto__"&&mn?mn(n,r,{configurable:!0,enumerable:!0,value:e,writable:!0}):n[r]=e}var ma=Qx;function Jx(n,r){return n===r||n!==n&&r!==r}var yn=Jx;var ev=Object.prototype,tv=ev.hasOwnProperty;function rv(n,r,e){var t=n[r];(!(tv.call(n,r)&&yn(t,e))||e===void 0&&!(r in n))&&ma(n,r,e)}var gn=rv;function ov(n,r,e,t){var o=!e;e||(e={});for(var i=-1,s=r.length;++i<s;){var a=r[i],c=t?t(e[a],n[a],a,e,n):void 0;c===void 0&&(c=n[a]),o?ma(e,a,c):gn(e,a,c)}return e}var yr=ov;var mp=Math.max;function nv(n,r,e){return r=mp(r===void 0?n.length-1:r,0),function(){for(var t=arguments,o=-1,i=mp(t.length-r,0),s=Array(i);++o<i;)s[o]=t[r+o];o=-1;for(var a=Array(r+1);++o<r;)a[o]=t[o];return a[r]=e(s),ap(n,this,a)}}var hp=nv;var iv=9007199254740991;function sv(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=iv}var xn=sv;function av(n){return n!=null&&xn(n.length)&&!ua(n)}var ha=av;var lv=Object.prototype;function cv(n){var r=n&&n.constructor,e=typeof r=="function"&&r.prototype||lv;return n===e}var vn=cv;function dv(n,r){for(var e=-1,t=Array(n);++e<n;)t[e]=r(e);return t}var yp=dv;var uv="[object Arguments]";function pv(n){return ct(n)&&Vt(n)==uv}var vc=pv;var gp=Object.prototype,fv=gp.hasOwnProperty,mv=gp.propertyIsEnumerable,hv=vc(function(){return arguments}())?vc:function(n){return ct(n)&&fv.call(n,"callee")&&!mv.call(n,"callee")},bn=hv;function yv(){return!1}var xp=yv;var Sp=typeof exports=="object"&&exports&&!exports.nodeType&&exports,vp=Sp&&typeof module=="object"&&module&&!module.nodeType&&module,gv=vp&&vp.exports===Sp,bp=gv?$e.Buffer:void 0,xv=bp?bp.isBuffer:void 0,vv=xv||xp,Bo=vv;var bv="[object Arguments]",Sv="[object Array]",wv="[object Boolean]",_v="[object Date]",Pv="[object Error]",Tv="[object Function]",Ov="[object Map]",Av="[object Number]",Cv="[object Object]",Nv="[object RegExp]",Iv="[object Set]",Mv="[object String]",Ev="[object WeakMap]",Lv="[object ArrayBuffer]",Dv="[object DataView]",Bv="[object Float32Array]",Rv="[object Float64Array]",Gv="[object Int8Array]",Vv="[object Int16Array]",zv="[object Int32Array]",jv="[object Uint8Array]",Fv="[object Uint8ClampedArray]",kv="[object Uint16Array]",Uv="[object Uint32Array]",Le={};Le[Bv]=Le[Rv]=Le[Gv]=Le[Vv]=Le[zv]=Le[jv]=Le[Fv]=Le[kv]=Le[Uv]=!0;Le[bv]=Le[Sv]=Le[Lv]=Le[wv]=Le[Dv]=Le[_v]=Le[Pv]=Le[Tv]=Le[Ov]=Le[Av]=Le[Cv]=Le[Nv]=Le[Iv]=Le[Mv]=Le[Ev]=!1;function Hv(n){return ct(n)&&xn(n.length)&&!!Le[Vt(n)]}var wp=Hv;function Wv(n){return function(r){return n(r)}}var Sn=Wv;var _p=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ts=_p&&typeof module=="object"&&module&&!module.nodeType&&module,qv=ts&&ts.exports===_p,bc=qv&&ca.process,$v=function(){try{var n=ts&&ts.require&&ts.require("util").types;return n||bc&&bc.binding&&bc.binding("util")}catch{}}(),Hr=$v;var Pp=Hr&&Hr.isTypedArray,Yv=Pp?Sn(Pp):wp,ya=Yv;var Xv=Object.prototype,Kv=Xv.hasOwnProperty;function Zv(n,r){var e=je(n),t=!e&&bn(n),o=!e&&!t&&Bo(n),i=!e&&!t&&!o&&ya(n),s=e||t||o||i,a=s?yp(n.length,String):[],c=a.length;for(var u in n)(r||Kv.call(n,u))&&!(s&&(u=="length"||o&&(u=="offset"||u=="parent")||i&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||hn(u,c)))&&a.push(u);return a}var ga=Zv;function Qv(n,r){return function(e){return n(r(e))}}var xa=Qv;var Jv=xa(Object.keys,Object),Tp=Jv;var eb=Object.prototype,tb=eb.hasOwnProperty;function rb(n){if(!vn(n))return Tp(n);var r=[];for(var e in Object(n))tb.call(n,e)&&e!="constructor"&&r.push(e);return r}var Op=rb;function ob(n){return ha(n)?ga(n):Op(n)}var wn=ob;function nb(n){var r=[];if(n!=null)for(var e in Object(n))r.push(e);return r}var Ap=nb;var ib=Object.prototype,sb=ib.hasOwnProperty;function ab(n){if(!zt(n))return Ap(n);var r=vn(n),e=[];for(var t in n)t=="constructor"&&(r||!sb.call(n,t))||e.push(t);return e}var Cp=ab;function lb(n){return ha(n)?ga(n,!0):Cp(n)}var _n=lb;var cb=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,db=/^\w*$/;function ub(n,r){if(je(n))return!1;var e=typeof n;return e=="number"||e=="symbol"||e=="boolean"||n==null||fn(n)?!0:db.test(n)||!cb.test(n)||r!=null&&n in Object(r)}var Np=ub;var pb=Ct(Object,"create"),Wr=pb;function fb(){this.__data__=Wr?Wr(null):{},this.size=0}var Ip=fb;function mb(n){var r=this.has(n)&&delete this.__data__[n];return this.size-=r?1:0,r}var Mp=mb;var hb="__lodash_hash_undefined__",yb=Object.prototype,gb=yb.hasOwnProperty;function xb(n){var r=this.__data__;if(Wr){var e=r[n];return e===hb?void 0:e}return gb.call(r,n)?r[n]:void 0}var Ep=xb;var vb=Object.prototype,bb=vb.hasOwnProperty;function Sb(n){var r=this.__data__;return Wr?r[n]!==void 0:bb.call(r,n)}var Lp=Sb;var wb="__lodash_hash_undefined__";function _b(n,r){var e=this.__data__;return this.size+=this.has(n)?0:1,e[n]=Wr&&r===void 0?wb:r,this}var Dp=_b;function Pn(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])}}Pn.prototype.clear=Ip;Pn.prototype.delete=Mp;Pn.prototype.get=Ep;Pn.prototype.has=Lp;Pn.prototype.set=Dp;var Sc=Pn;function Pb(){this.__data__=[],this.size=0}var Bp=Pb;function Tb(n,r){for(var e=n.length;e--;)if(yn(n[e][0],r))return e;return-1}var ao=Tb;var Ob=Array.prototype,Ab=Ob.splice;function Cb(n){var r=this.__data__,e=ao(r,n);if(e<0)return!1;var t=r.length-1;return e==t?r.pop():Ab.call(r,e,1),--this.size,!0}var Rp=Cb;function Nb(n){var r=this.__data__,e=ao(r,n);return e<0?void 0:r[e][1]}var Gp=Nb;function Ib(n){return ao(this.__data__,n)>-1}var Vp=Ib;function Mb(n,r){var e=this.__data__,t=ao(e,n);return t<0?(++this.size,e.push([n,r])):e[t][1]=r,this}var zp=Mb;function Tn(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])}}Tn.prototype.clear=Bp;Tn.prototype.delete=Rp;Tn.prototype.get=Gp;Tn.prototype.has=Vp;Tn.prototype.set=zp;var lo=Tn;var Eb=Ct($e,"Map"),co=Eb;function Lb(){this.size=0,this.__data__={hash:new Sc,map:new(co||lo),string:new Sc}}var jp=Lb;function Db(n){var r=typeof n;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?n!=="__proto__":n===null}var Fp=Db;function Bb(n,r){var e=n.__data__;return Fp(r)?e[typeof r=="string"?"string":"hash"]:e.map}var uo=Bb;function Rb(n){var r=uo(this,n).delete(n);return this.size-=r?1:0,r}var kp=Rb;function Gb(n){return uo(this,n).get(n)}var Up=Gb;function Vb(n){return uo(this,n).has(n)}var Hp=Vb;function zb(n,r){var e=uo(this,n),t=e.size;return e.set(n,r),this.size+=e.size==t?0:1,this}var Wp=zb;function On(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])}}On.prototype.clear=jp;On.prototype.delete=kp;On.prototype.get=Up;On.prototype.has=Hp;On.prototype.set=Wp;var Ro=On;var jb="Expected a function";function wc(n,r){if(typeof n!="function"||r!=null&&typeof r!="function")throw new TypeError(jb);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(wc.Cache||Ro),e}wc.Cache=Ro;var qp=wc;var Fb=500;function kb(n){var r=qp(n,function(t){return e.size===Fb&&e.clear(),t}),e=r.cache;return r}var $p=kb;var Ub=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Hb=/\\(\\)?/g,Wb=$p(function(n){var r=[];return n.charCodeAt(0)===46&&r.push(""),n.replace(Ub,function(e,t,o,i){r.push(o?i.replace(Hb,"$1"):t||e)}),r}),Yp=Wb;function qb(n){return n==null?"":Ju(n)}var Xp=qb;function $b(n,r){return je(n)?n:Np(n,r)?[n]:Yp(Xp(n))}var qt=$b;var Yb=1/0;function Xb(n){if(typeof n=="string"||fn(n))return n;var r=n+"";return r=="0"&&1/n==-Yb?"-0":r}var po=Xb;function Kb(n,r){r=qt(r,n);for(var e=0,t=r.length;n!=null&&e<t;)n=n[po(r[e++])];return e&&e==t?n:void 0}var va=Kb;function Zb(n,r){for(var e=-1,t=r.length,o=n.length;++e<t;)n[o+e]=r[e];return n}var An=Zb;var Kp=et?et.isConcatSpreadable:void 0;function Qb(n){return je(n)||bn(n)||!!(Kp&&n&&n[Kp])}var Zp=Qb;function Qp(n,r,e,t,o){var i=-1,s=n.length;for(e||(e=Zp),o||(o=[]);++i<s;){var a=n[i];r>0&&e(a)?r>1?Qp(a,r-1,e,t,o):An(o,a):t||(o[o.length]=a)}return o}var Jp=Qp;function Jb(n){var r=n==null?0:n.length;return r?Jp(n,1):[]}var ef=Jb;function eS(n){return pp(hp(n,void 0,ef),n+"")}var ba=eS;var tS=xa(Object.getPrototypeOf,Object),Cn=tS;var rS="[object Object]",oS=Function.prototype,nS=Object.prototype,tf=oS.toString,iS=nS.hasOwnProperty,sS=tf.call(Object);function aS(n){if(!ct(n)||Vt(n)!=rS)return!1;var r=Cn(n);if(r===null)return!0;var e=iS.call(r,"constructor")&&r.constructor;return typeof e=="function"&&e instanceof e&&tf.call(e)==sS}var rf=aS;function lS(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 of=lS;function cS(){this.__data__=new lo,this.size=0}var nf=cS;function dS(n){var r=this.__data__,e=r.delete(n);return this.size=r.size,e}var sf=dS;function uS(n){return this.__data__.get(n)}var af=uS;function pS(n){return this.__data__.has(n)}var lf=pS;var fS=200;function mS(n,r){var e=this.__data__;if(e instanceof lo){var t=e.__data__;if(!co||t.length<fS-1)return t.push([n,r]),this.size=++e.size,this;e=this.__data__=new Ro(t)}return e.set(n,r),this.size=e.size,this}var cf=mS;function Nn(n){var r=this.__data__=new lo(n);this.size=r.size}Nn.prototype.clear=nf;Nn.prototype.delete=sf;Nn.prototype.get=af;Nn.prototype.has=lf;Nn.prototype.set=cf;var In=Nn;function hS(n,r){return n&&yr(r,wn(r),n)}var df=hS;function yS(n,r){return n&&yr(r,_n(r),n)}var uf=yS;var hf=typeof exports=="object"&&exports&&!exports.nodeType&&exports,pf=hf&&typeof module=="object"&&module&&!module.nodeType&&module,gS=pf&&pf.exports===hf,ff=gS?$e.Buffer:void 0,mf=ff?ff.allocUnsafe:void 0;function xS(n,r){if(r)return n.slice();var e=n.length,t=mf?mf(e):new n.constructor(e);return n.copy(t),t}var yf=xS;function vS(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 gf=vS;function bS(){return[]}var Sa=bS;var SS=Object.prototype,wS=SS.propertyIsEnumerable,xf=Object.getOwnPropertySymbols,_S=xf?function(n){return n==null?[]:(n=Object(n),gf(xf(n),function(r){return wS.call(n,r)}))}:Sa,Mn=_S;function PS(n,r){return yr(n,Mn(n),r)}var vf=PS;var TS=Object.getOwnPropertySymbols,OS=TS?function(n){for(var r=[];n;)An(r,Mn(n)),n=Cn(n);return r}:Sa,wa=OS;function AS(n,r){return yr(n,wa(n),r)}var bf=AS;function CS(n,r,e){var t=r(n);return je(n)?t:An(t,e(n))}var _a=CS;function NS(n){return _a(n,wn,Mn)}var rs=NS;function IS(n){return _a(n,_n,wa)}var Pa=IS;var MS=Ct($e,"DataView"),Ta=MS;var ES=Ct($e,"Promise"),Oa=ES;var LS=Ct($e,"Set"),Aa=LS;var Sf="[object Map]",DS="[object Object]",wf="[object Promise]",_f="[object Set]",Pf="[object WeakMap]",Tf="[object DataView]",BS=Ur(Ta),RS=Ur(co),GS=Ur(Oa),VS=Ur(Aa),zS=Ur(fa),Go=Vt;(Ta&&Go(new Ta(new ArrayBuffer(1)))!=Tf||co&&Go(new co)!=Sf||Oa&&Go(Oa.resolve())!=wf||Aa&&Go(new Aa)!=_f||fa&&Go(new fa)!=Pf)&&(Go=function(n){var r=Vt(n),e=r==DS?n.constructor:void 0,t=e?Ur(e):"";if(t)switch(t){case BS:return Tf;case RS:return Sf;case GS:return wf;case VS:return _f;case zS:return Pf}return r});var qr=Go;var jS=Object.prototype,FS=jS.hasOwnProperty;function kS(n){var r=n.length,e=new n.constructor(r);return r&&typeof n[0]=="string"&&FS.call(n,"index")&&(e.index=n.index,e.input=n.input),e}var Of=kS;var US=$e.Uint8Array,En=US;function HS(n){var r=new n.constructor(n.byteLength);return new En(r).set(new En(n)),r}var Ln=HS;function WS(n,r){var e=r?Ln(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.byteLength)}var Af=WS;var qS=/\w*$/;function $S(n){var r=new n.constructor(n.source,qS.exec(n));return r.lastIndex=n.lastIndex,r}var Cf=$S;var Nf=et?et.prototype:void 0,If=Nf?Nf.valueOf:void 0;function YS(n){return If?Object(If.call(n)):{}}var Mf=YS;function XS(n,r){var e=r?Ln(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.length)}var Ef=XS;var KS="[object Boolean]",ZS="[object Date]",QS="[object Map]",JS="[object Number]",ew="[object RegExp]",tw="[object Set]",rw="[object String]",ow="[object Symbol]",nw="[object ArrayBuffer]",iw="[object DataView]",sw="[object Float32Array]",aw="[object Float64Array]",lw="[object Int8Array]",cw="[object Int16Array]",dw="[object Int32Array]",uw="[object Uint8Array]",pw="[object Uint8ClampedArray]",fw="[object Uint16Array]",mw="[object Uint32Array]";function hw(n,r,e){var t=n.constructor;switch(r){case nw:return Ln(n);case KS:case ZS:return new t(+n);case iw:return Af(n,e);case sw:case aw:case lw:case cw:case dw:case uw:case pw:case fw:case mw:return Ef(n,e);case QS:return new t;case JS:case rw:return new t(n);case ew:return Cf(n);case tw:return new t;case ow:return Mf(n)}}var Lf=hw;function yw(n){return typeof n.constructor=="function"&&!vn(n)?sp(Cn(n)):{}}var Df=yw;var gw="[object Map]";function xw(n){return ct(n)&&qr(n)==gw}var Bf=xw;var Rf=Hr&&Hr.isMap,vw=Rf?Sn(Rf):Bf,Gf=vw;var bw="[object Set]";function Sw(n){return ct(n)&&qr(n)==bw}var Vf=Sw;var zf=Hr&&Hr.isSet,ww=zf?Sn(zf):Vf,jf=ww;var _w=1,Pw=2,Tw=4,Ff="[object Arguments]",Ow="[object Array]",Aw="[object Boolean]",Cw="[object Date]",Nw="[object Error]",kf="[object Function]",Iw="[object GeneratorFunction]",Mw="[object Map]",Ew="[object Number]",Uf="[object Object]",Lw="[object RegExp]",Dw="[object Set]",Bw="[object String]",Rw="[object Symbol]",Gw="[object WeakMap]",Vw="[object ArrayBuffer]",zw="[object DataView]",jw="[object Float32Array]",Fw="[object Float64Array]",kw="[object Int8Array]",Uw="[object Int16Array]",Hw="[object Int32Array]",Ww="[object Uint8Array]",qw="[object Uint8ClampedArray]",$w="[object Uint16Array]",Yw="[object Uint32Array]",Ee={};Ee[Ff]=Ee[Ow]=Ee[Vw]=Ee[zw]=Ee[Aw]=Ee[Cw]=Ee[jw]=Ee[Fw]=Ee[kw]=Ee[Uw]=Ee[Hw]=Ee[Mw]=Ee[Ew]=Ee[Uf]=Ee[Lw]=Ee[Dw]=Ee[Bw]=Ee[Rw]=Ee[Ww]=Ee[qw]=Ee[$w]=Ee[Yw]=!0;Ee[Nw]=Ee[kf]=Ee[Gw]=!1;function Ca(n,r,e,t,o,i){var s,a=r&_w,c=r&Pw,u=r&Tw;if(e&&(s=o?e(n,t,o,i):e(n)),s!==void 0)return s;if(!zt(n))return n;var l=je(n);if(l){if(s=Of(n),!a)return lp(n,s)}else{var d=qr(n),p=d==kf||d==Iw;if(Bo(n))return yf(n,a);if(d==Uf||d==Ff||p&&!o){if(s=c||p?{}:Df(n),!a)return c?bf(n,uf(s,n)):vf(n,df(s,n))}else{if(!Ee[d])return o?n:{};s=Lf(n,d,a)}}i||(i=new In);var f=i.get(n);if(f)return f;i.set(n,s),jf(n)?n.forEach(function(y){s.add(Ca(y,r,e,y,n,i))}):Gf(n)&&n.forEach(function(y,g){s.set(g,Ca(y,r,e,g,n,i))});var m=u?c?Pa:rs:c?_n:wn,h=l?void 0:m(n);return fp(h||n,function(y,g){h&&(g=y,y=n[g]),gn(s,g,Ca(y,r,e,g,n,i))}),s}var Na=Ca;var Xw=1,Kw=4;function Zw(n){return Na(n,Xw|Kw)}var $r=Zw;var Qw="__lodash_hash_undefined__";function Jw(n){return this.__data__.set(n,Qw),this}var Hf=Jw;function e1(n){return this.__data__.has(n)}var Wf=e1;function Ia(n){var r=-1,e=n==null?0:n.length;for(this.__data__=new Ro;++r<e;)this.add(n[r])}Ia.prototype.add=Ia.prototype.push=Hf;Ia.prototype.has=Wf;var qf=Ia;function t1(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 $f=t1;function r1(n,r){return n.has(r)}var Yf=r1;var o1=1,n1=2;function i1(n,r,e,t,o,i){var s=e&o1,a=n.length,c=r.length;if(a!=c&&!(s&&c>a))return!1;var u=i.get(n),l=i.get(r);if(u&&l)return u==r&&l==n;var d=-1,p=!0,f=e&n1?new qf:void 0;for(i.set(n,r),i.set(r,n);++d<a;){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(!$f(r,function(g,x){if(!Yf(f,x)&&(m===g||o(m,g,e,t,i)))return f.push(x)})){p=!1;break}}else if(!(m===h||o(m,h,e,t,i))){p=!1;break}}return i.delete(n),i.delete(r),p}var Ma=i1;function s1(n){var r=-1,e=Array(n.size);return n.forEach(function(t,o){e[++r]=[o,t]}),e}var Xf=s1;function a1(n){var r=-1,e=Array(n.size);return n.forEach(function(t){e[++r]=t}),e}var Kf=a1;var l1=1,c1=2,d1="[object Boolean]",u1="[object Date]",p1="[object Error]",f1="[object Map]",m1="[object Number]",h1="[object RegExp]",y1="[object Set]",g1="[object String]",x1="[object Symbol]",v1="[object ArrayBuffer]",b1="[object DataView]",Zf=et?et.prototype:void 0,_c=Zf?Zf.valueOf:void 0;function S1(n,r,e,t,o,i,s){switch(e){case b1:if(n.byteLength!=r.byteLength||n.byteOffset!=r.byteOffset)return!1;n=n.buffer,r=r.buffer;case v1:return!(n.byteLength!=r.byteLength||!i(new En(n),new En(r)));case d1:case u1:case m1:return yn(+n,+r);case p1:return n.name==r.name&&n.message==r.message;case h1:case g1:return n==r+"";case f1:var a=Xf;case y1:var c=t&l1;if(a||(a=Kf),n.size!=r.size&&!c)return!1;var u=s.get(n);if(u)return u==r;t|=c1,s.set(n,r);var l=Ma(a(n),a(r),t,o,i,s);return s.delete(n),l;case x1:if(_c)return _c.call(n)==_c.call(r)}return!1}var Qf=S1;var w1=1,_1=Object.prototype,P1=_1.hasOwnProperty;function T1(n,r,e,t,o,i){var s=e&w1,a=rs(n),c=a.length,u=rs(r),l=u.length;if(c!=l&&!s)return!1;for(var d=c;d--;){var p=a[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=a[d];var g=n[p],x=r[p];if(t)var b=s?t(x,g,p,r,n,i):t(g,x,p,n,r,i);if(!(b===void 0?g===x||o(g,x,e,t,i):b)){h=!1;break}y||(y=p=="constructor")}if(h&&!y){var w=n.constructor,S=r.constructor;w!=S&&"constructor"in n&&"constructor"in r&&!(typeof w=="function"&&w instanceof w&&typeof S=="function"&&S instanceof S)&&(h=!1)}return i.delete(n),i.delete(r),h}var Jf=T1;var O1=1,em="[object Arguments]",tm="[object Array]",Ea="[object Object]",A1=Object.prototype,rm=A1.hasOwnProperty;function C1(n,r,e,t,o,i){var s=je(n),a=je(r),c=s?tm:qr(n),u=a?tm:qr(r);c=c==em?Ea:c,u=u==em?Ea:u;var l=c==Ea,d=u==Ea,p=c==u;if(p&&Bo(n)){if(!Bo(r))return!1;s=!0,l=!1}if(p&&!l)return i||(i=new In),s||ya(n)?Ma(n,r,e,t,o,i):Qf(n,r,c,e,t,o,i);if(!(e&O1)){var f=l&&rm.call(n,"__wrapped__"),m=d&&rm.call(r,"__wrapped__");if(f||m){var h=f?n.value():n,y=m?r.value():r;return i||(i=new In),o(h,y,e,t,i)}}return p?(i||(i=new In),Jf(n,r,e,t,o,i)):!1}var om=C1;function nm(n,r,e,t,o){return n===r?!0:n==null||r==null||!ct(n)&&!ct(r)?n!==n&&r!==r:om(n,r,e,t,nm,o)}var im=nm;function N1(n,r){return n!=null&&r in Object(n)}var sm=N1;function I1(n,r,e){r=qt(r,n);for(var t=-1,o=r.length,i=!1;++t<o;){var s=po(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&&xn(o)&&hn(s,o)&&(je(n)||bn(n)))}var am=I1;function M1(n,r){return n!=null&&am(n,r,sm)}var lm=M1;function E1(n){var r=n==null?0:n.length;return r?n[r-1]:void 0}var cm=E1;function L1(n,r){return r.length<2?n:va(n,of(r,0,-1))}var dm=L1;function D1(n,r){return im(n,r)}var os=D1;function B1(n,r){return r=qt(r,n),n=dm(n,r),n==null||delete n[po(cm(r))]}var um=B1;function R1(n){return rf(n)?void 0:n}var pm=R1;var G1=1,V1=2,z1=4,j1=ba(function(n,r){var e={};if(n==null)return e;var t=!1;r=da(r,function(i){return i=qt(i,n),t||(t=i.length>1),i}),yr(n,Pa(n),e),t&&(e=Na(e,G1|V1|z1,pm));for(var o=r.length;o--;)um(e,r[o]);return e}),Dn=j1;function F1(n,r,e,t){if(!zt(n))return n;r=qt(r,n);for(var o=-1,i=r.length,s=i-1,a=n;a!=null&&++o<i;){var c=po(r[o]),u=e;if(c==="__proto__"||c==="constructor"||c==="prototype")return n;if(o!=s){var l=a[c];u=t?t(l,c,a):void 0,u===void 0&&(u=zt(l)?l:hn(r[o+1])?[]:{})}gn(a,c,u),a=a[c]}return n}var fm=F1;function k1(n,r,e){for(var t=-1,o=r.length,i={};++t<o;){var s=r[t],a=va(n,s);e(a,s)&&fm(i,qt(s,n),a)}return i}var mm=k1;function U1(n,r){return mm(n,r,function(e,t){return lm(n,t)})}var hm=U1;var H1=ba(function(n,r){return n==null?{}:hm(n,r)}),Yr=H1;function Bn(n){let r;return()=>r||(r=n(),r)}var Me=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,Me.prototype),i}}add(r,e){return this.runOp({type:1,id:r,data:e})?.data??this}runOp(r){let e=this;if(r.type===1){let t=e[r.id],o;t===void 0?o={type:2,id:r.id}:o={type:1,id:r.id,data:t};let{id:i,data:s}=r,a={...e,[i]:s};return Object.setPrototypeOf(a,Me.prototype),{data:a,actual:r,reverse:o}}else if(r.type===2){let{id:t}=r,o=e[t];if(o===void 0)return null;{let i={...e};return Object.setPrototypeOf(i,Me.prototype),delete i[t],{data:i,actual:r,reverse:{type:1,id:t,data:o}}}}return null}};function ns(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"&&ns(t)}return Object.freeze(n)}function ym(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 Rn=class extends Error{};function La(n){let r={...n};return Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r}function gr(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 Gn(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 gm(){return typeof process<"u"}function xm(n,r){for(let e of n)r(e.id,e.data)!==!0&&xm(e.children,r)}function vm(n,r){if(r(n.id,n.data)!==!0)for(let e of n.children)vm(e,r)}var Be=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,Be.prototype)}deepFreeze(){let e=0;for(;e<this.length;)ns(this[e]),e++}fillCaches0(e,t){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,t);for(let o of e.children)this.fillCaches0(o,e.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let e of this)this.fillCaches0(e,null)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}nonExistOrDescendantOf(e,t){if(!this.has(e))return!0;for(;e;){let o=this.parent(e);if(o===t)return!0;e=o}return!1}rootAcestor(e){for(;e;){let t=this.parent(e);if(t)e=t;else return e}return e}isDescendantOf(e,t){for(;e;){let o=this.parent(e);if(o===t)return!0;e=o}return!1}data(e){return this.get(e)?.data}has(e){return this.childrenOf(e)!==void 0}get(e){return this.fillCaches(),this.objCaches.get(e)}childrenOf(e){return e===null?this:this.get(e)?.children}traverseFrom(e,t){if(e===null)this.traverse(t);else{let o=this.get(e);o&&vm(o,t)}}traverse(e){xm(this,e)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(e){return this.fillCaches(),this.parentCaches.get(e)}childrenArray(e){return e===null?this:this.get(e).children}modifyById(e,t){if(this.get(e)===void 0)throw new Error("not expected");{let i=this.parent(e),s=this.childrenArray(i),a=s.findIndex(l=>l.id===e);if(a<0)throw new Error("not expected");let c=s[a];return s=[...s],s[a]={...c,data:t},this.modifyArrayBy(i,s)}}modifyArrayBy(e,t){let o=e,i=t;for(;o!==null;){let a=i,c=o;if(o=this.parent(o),o===void 0)throw new Error;i=this.childrenArray(o);let u=i.findIndex(l=>l.id===c);if(u<0)throw new Error;i=[...i],i[u]={...i[u],children:a}}Object.setPrototypeOf(i,Be.prototype);let s=i;return s.fillCaches(),s}runOp(e){switch(e.type){case 7:return this.addOp(e);case 8:return this.deleteOp(e);case 9:return this.moveOp(e)}return null}checkDuplicatedIdRec({id:e,children:t}){if(this.get(e)!==void 0)return!0;for(let o of t)if(this.checkDuplicatedIdRec(o))return!0;return!1}addOp(e){let{parent:t,fi:o,id:i,data:s,children:a}=e;if(t!==null&&this.get(t)===void 0)return null;if(this.checkDuplicatedIdRec(e))return null;{let c=t,u=this.childrenArray(c),l={fi:o,id:i,data:s,children:a};return u=[...u,l],u.sort((p,f)=>p.fi-f.fi),e.localIndex=u.indexOf(l),{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 a=i.splice(s,1)[0];return{data:this.modifyArrayBy(o,i),actual:e,reverse:{type:7,...a,parent:o}}}}moveOp(e){let{parent:t,fi:o,id:i}=e;if(t!==null&&this.get(t)===void 0)return this.deleteOp({type:8,id:i});if(t!==null){let f=t;for(;f!==null;){if(f===void 0)throw new Error;if(f===i)throw new Rn("cyclic tree");f=this.parent(f)}}let s=this.parent(i);if(s===void 0)return null;let a=s,c=this.childrenArray(s),u=c.findIndex(f=>f.id===i);c=[...c];let l=c.splice(u,1)[0],d=this.modifyArrayBy(s,c);s=t,c=d.childrenArray(s);let p=l.fi;return l={...l,fi:o},c=[...c,l],c.sort((f,m)=>f.fi-m.fi),e.localIndex=c.indexOf(l),d=d.modifyArrayBy(s,c),{data:d,actual:e,reverse:{type:9,parent:a,fi:p,id:i}}}previous(e,t){if(t===null){let i=this.childrenArray(e);return i.length===0?null:i[i.length-1].id}let o=null;for(let i of this.childrenArray(e)){if(i.id===t)return o;o=i.id}return null}traverseSortNext(e){let t=this.parent(e);if(t!==void 0){let o=this.childrenArray(t),i=o.findIndex(s=>s.id===e)+1;if(i<o.length)return o[i].id;if(t)return this.traverseSortNext(t)}}sortNext(e){let t=this.childrenArray(e);return t.length>0?t[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let t=this.childrenArray(e);return t.length>0?this.traverseSortPrevious(t[t.length-1].id):e}sortPrevious(e){let t=this.parent(e);if(t!==void 0){let o=this.childrenArray(t),i=o.findIndex(s=>s.id===e)-1;return i>=0?this.traverseSortPrevious(o[i].id):t}}getAllSorted(e){let t=[];for(let o of e){let i=this.getWithSortKey(o.id);i!==void 0&&t.push({...o,...i})}t.sort((o,i)=>ym(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 gr(0,o,o);{let s=i[0].fi;return gr(s-o,s,o)}}else{let s=this.get(t);if(s===void 0||this.parent(t)!==e)throw new Error("illegal args");let a=i.find(c=>c.fi>s.fi);if(a===void 0){let c=i[i.length-1].fi;return gr(c,c+o,o)}else return gr(s.fi,a.fi,o)}}};var Vn;(r=>{function n(e,t){if(t.type!==0)return null;if(Array.isArray(e)){let o=t.props,i={},s=[...e],a=!1;if(o)for(let c of Object.keys(o)){let u=parseInt(c);if(isNaN(u))throw new Error("wrong index");i[c]=s[u],s[u]=o[c],a=!0}return a?{data:s,actual:t,reverse:{type:0,props:i}}:null}else{let o=t.props,i={},s={...e},a=!1;if(o)for(let c of Object.keys(o)){i[c]=s[c];let u=o[c];u===void 0?delete s[c]:s[c]=u,a=!0}return a?{data:s,actual:t,reverse:{type:0,props:i}}:null}}r.runOp=n})(Vn||(Vn={}));var me=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,me.prototype)}deepFreeze(){let e=0;for(;e<this.length;)ns(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 a=i[s];return i=[...i],i[s]={...a,data:t},this.modifyArrayBy(i)}}modifyArrayBy(e){Object.setPrototypeOf(e,me.prototype);let t=e;return gm()||t.fillCaches(),t}runOp(e){switch(e.type){case 4:return this.addOp(e);case 5:return this.deleteOp(e);case 6:return this.moveOp(e)}return null}addOp(e){let{fi:t,id:o,data:i}=e,s=this,a={fi:t,id:o,data:i};return s=[...s,a],s.sort((u,l)=>u.fi-l.fi),e.localIndex=s.indexOf(a),{data:this.modifyArrayBy(s),actual:e,reverse:{type:5,id:o}}}deleteOp(e){let{id:t}=e,o=this,i=o.findIndex(c=>c.id===t);if(i===-1)return null;e.localIndex=i,o=[...o];let s=o.splice(i,1)[0];return{data:this.modifyArrayBy(o),actual:e,reverse:{type:4,...s}}}moveOp(e){let{fi:t,id:o}=e,i=this;i=[...i];let s=i.findIndex(l=>l.id===o);if(s===-1)return null;let a=i[s].fi,c={...i[s],fi:t};return i[s]=c,i.sort((l,d)=>l.fi-d.fi),e.localIndex=i.indexOf(c),{data:this.modifyArrayBy(i),actual:e,reverse:{type:6,fi:a,id:o}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let t=null;for(let o of this){if(o.id===e)return t;t=o.id}return null}insertBeforeHelper(e,t){return this.insertAfterHelper(this.previous(e),t)}insertAfterHelper(e,t){let o=this;if(e===null){if(o.length===0)return gr(0,t,t);{let i=o[0].fi;return gr(i-t,i,t)}}else{let i=this.get(e);if(i===void 0)throw new Error("illegal args");let s=o.find(a=>a.fi>i.fi);if(s===void 0){let a=o[o.length-1].fi;return gr(a,a+t,t)}else return gr(i.fi,s.fi,t)}}};function zn(n){return n&&typeof n=="object"&&n instanceof Re}var Re=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&&!zn(t))return null;o+=1}t=t?La(t):new Re;for(let[c,u]of Object.entries(r.props)){let l=t[c];i[c]=l,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=La(c),delete t[r.path[o-1]])}else{let c=e[o-1];if(c){let u=La(c);u[r.path[o-1]]=t,t=u}else{let u=new Re;u[r.path[o-1]]=t,t=u}}o-=1}let s=Object.setPrototypeOf(t,Re.prototype),a={...r,props:i};return{data:s,actual:r,reverse:a}}},xr;(t=>{function n(o,i){return is(o,i)??o}t.apply=n;function r(o,i){return Tc(o,i)}t.merge=r;function e(o,i){let s=0,a=i.path,c=o;for(;s<a.length&&c!==void 0;){if(c=vt.zoomOnce(c,a[s]),c===void 0)return i;if(!zn(c))return;s+=1}if(c===void 0)return i;if(!!zn(c))if(i.type===0){let u={...i.props};for(let l of Object.keys(c))delete u[l];return{...i,props:u}}else if(i.type===1||i.type===4||i.type===7){let u=Pc([i],c);return u?(console.log(u),u):i}else return i}t.filterOp=e})(xr||(xr={}));function Pc(n,r){if(r===void 0)return;let e=!1,t=n.map(o=>{let i=o.id,s=is(o.data,r[i]);if(e=e||s!==void 0,s===void 0&&(s=o.data),o.children){let a=Pc(o.children,r);return a!==void 0?e=!0:a=o.children,{...o,id:i,data:s,children:a}}else return{...o,id:i,data:s}});if(e)return t}function W1(n,r){if(r===void 0)return;let e=!1,t=n.map(o=>{let i=o.id,s=is(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 is(n,r){if(!zn(r))return r;if(n instanceof Be){let e=Pc(n,r);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e}else{if(n instanceof me)return W1(n,r);if(Array.isArray(n)){let e=!1,t=n.map((o,i)=>{let s=is(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 Re)return Tc(n,r);if(n&&typeof n=="object"){let e={},t=!1;for(let[o,i]of Object.entries(n)){let s=is(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 Tc(n,r){if(n===void 0)return r;if(r===void 0)return n;if(!zn(r))return r;if(!zn(n))return xr.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 Re;for(let o of e){let i=Tc(n===void 0?void 0:n[o],r===void 0?void 0:r[o]);t[o]=i}return t}function bm(n,r){let e={cur:[],result:[],len:0};return n=ss(n,r,e)??n,[n,e.result]}function Da(n,r){return n===null?null:(n.cur[n.len]=r,n.len+=1,n)}function Ba(n){n&&(n.len-=1)}function q1(n){if(n===null)return null;n.result.push(n.cur.slice(0,n.len))}function Sm(n,r,e){let t=!1,o=n.map(i=>{let s=i.id,a=r[s];if(a!==void 0&&typeof a=="string"&&(t=!0,s=a,e!==null))throw new Error("not supported");let c=ss(i.data,r,Da(e,s));Ba(e),t=t||c!==void 0,c===void 0&&(c=i.data);let u=Sm(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 $1(n,r,e){let t=!1,o=n.map(i=>{let s=i.id,a=r[s];if(a!==void 0&&typeof a=="string"&&(t=!0,s=a,e!==null))throw new Error("not supported");let c=ss(i.data,r,Da(e,s));return Ba(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 ss(n,r,e){if(n instanceof Be){let t=Sm(n,r,e);return t!==void 0&&Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t}else{if(n instanceof me)return $1(n,r,e);if(Array.isArray(n)){let t=!1,o=n.map((i,s)=>{let a=ss(i,r,Da(e,s));return Ba(e),t=t||a!==void 0,a===void 0&&(a=i),a});return t?(Object.setPrototypeOf(o,Object.getPrototypeOf(n)),o):void 0}else if(n&&typeof n=="object"&&!Gn(n)){let t={},o=!1;for(let[i,s]of Object.entries(n))if(i!=="name"&&i!=="text"){let a=r[i];if(typeof a=="string"){if(e!==null)throw new Error("not supported");o=!0,i=a}let c=ss(s,r,Da(e,i));Ba(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");q1(e)}return t}else return}}var Ra;(r=>{function n(e,t){let o=vt.zoom(t,e.path);if(typeof o=="object"){let i={};for(let s of Object.keys(e.props))i[s]=o[s];return{...e,props:i}}else return{...e,props:{}}}r.replaceProps=n})(Ra||(Ra={}));var dt;(a=>{function n(c,u){return{...c,path:c.path.slice(u)}}a.drop=n;function r(c,u){return e(c,u)?.data??c}a.applySimple=r;function e(c,u){let l=u.path;for(var d=[];;){let p;if(c instanceof Re&&u.type===0&&(p=c.runOp({...u,path:l.slice(d.length)}),p===null&&(p=void 0)),p===void 0&&d.length===l.length&&(c instanceof Be||c instanceof me||c instanceof Me?p=c.runOp(u):p=Vn.runOp(c,u)),p!==void 0)if(p!==null){let h=p.data;for(let y=d.length-1;y>=0;y--){let g=l[y],x=d[y];if(x instanceof Be){if(typeof g=="number")throw new Error("illegal arg");h=x.modifyById(g,h)}else if(x instanceof me){if(typeof g=="number")throw new Error("illegal arg");h=x.modifyById(g,h)}else if(x instanceof Me){if(typeof g=="number")throw new Error("illegal arg");h=x.modifyById(g,h)}else if(x instanceof Re){let b={...x,[g]:h};h=Object.setPrototypeOf(b,Re.prototype)}else if(typeof x=="object")if(Array.isArray(x)){if(typeof g=="string"&&(g=parseInt(g),isNaN(g)))throw new Error("Invalid path");let b=h;h=[...x],h[g]=b}else h={...x,[g]:h};else return null}return{data:h,actual:{...p.actual,path:l},reverse:{...p.reverse,path:l}}}else return null;let f=l[d.length],m;if(c instanceof Be){if(typeof f=="number")throw new Error("");m=c.get(f)?.data}else if(c instanceof me){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}}a.apply=e;function t(c,u){for(let l=0;l<c.length&&l<u.length;l++)if(c[l]!==u[l])return!0;return!1}a.pathDisjoint=t;function o(c,u){if(c.length!==u.length)return!1;for(let l=0;l<c.length;l++)if(c[l]!==u[l])return!1;return!0}a.pathEq=o;function i(c,u){return t(c.path,u.path)}a.commutative=i;function s(c,u){return c.type===0&&u.type===0&&o(c.path,u.path)?Object.keys(c.props).every(l=>u.props[l]!==void 0):!1}a.subsumed=s})(dt||(dt={}));var Oc;(c=>{function n(){return[]}c.empty=n;function r(u,l){let d=[];for(let p of u){let[f,...m]=p.path;f===l&&d.push({...p,path:m})}return d}c.removePrefix=r;function e(u,l){return u.map(d=>({...d,path:[l,...d.path]}))}c.addPrefix=e;function t(u,l){return[...u,...l]}c.concat=t;function o(u,l){return[...u.filter(p=>!l.some(f=>dt.subsumed(p,f))),...l]}c.compress=o;function i(u,l){return u.every(d=>l.every(p=>dt.commutative(d,p)))}c.commutative=i;function s(u,l){for(let d of l){let p=a(u,d);p!==null&&(u=p.data)}return u}c.applyAll=s;function a(u,l){var d=u;let p=[],f=[];for(let m of l)try{if(m.type===3){let h=vt.zoom(d,[...m.path,m.id]),y=dt.apply(d,{...m,type:2});if(y!==null){d=y.data;let[g,x]=bm(d,{[m.id]:h});d=g;for(let b of x){let w=b[b.length-1];b.splice(b.length-1,1),p.push({type:0,path:b,props:{[w]:h}}),f.push({type:0,path:b,props:{[w]:m.id}})}f.push(y.reverse),p.push(y.actual)}}else{let h=dt.apply(d,m);h!==null&&(p.push(h.actual),d=h.data,f.push(h.reverse))}}catch(h){if(h instanceof Rn)return null;throw h}return{data:d,actual:p,reverse:f.reverse()}}c.apply=a})(Oc||(Oc={}));var wm=Symbol(),Y1=Symbol(),Va=Symbol(),Vo=class{reportOp(r,e,t=[]){let o=this;if(e===null)return;o._current=e.data;let i=t;for(;!(o instanceof Ga);){let s=o._path,a=o._current;if(s!==""&&i.splice(0,0,s),o=o._parent,o===null)return;o.update(s,a)}o.push(i,r,e.actual,e.reverse)}deleteChildren(r){if(this._children){let e=this._children[r];if(e){let t=e[Va];t&&t(),delete this._children[r]}}}},Cc=class extends Vo{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,Vn.runOp(this._current,r),r.path)}},Nc=class extends Vo{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,Me.prototype)}runOp(r){this.reportOp(r,this._current.runOp(r))}},_m={get(n,r){if(r===Va)return()=>{n._parent=null};if(r===wm)return n._current;if(r===Y1)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=za(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]}}},X1={..._m,set(n,r,e){let t={type:0,props:{[r]:Ye(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}},K1={..._m,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}},jn=class extends Vo{constructor(r,e,t){super(),this._children={},this._parent=r,this._path=e,this._current=t,this[Va]=()=>{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=za(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 Vo{constructor(r,e,t){super(),this._children={},this._parent=r,this._path=e,this._current=t,this[Va]=()=>{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=za(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 Ac(n,r,e){if(n.length>0){let t=n[n.length-1];if(t.type===0&&r.type===0&&vt.equal(t.path,e)){Object.assign(t.props,r.props);return}}n.push({...r,path:e})}var Ga=class extends Vo{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){Ac(this.ts,e,r),Ac(this.actual,t,r),Ac(this.reverse,o,r)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function za(n,r,e){return e instanceof Be?new jn(n,r,e):e instanceof me?new Fn(n,r,e):e instanceof Me?new Proxy(new Nc(n,r,e),K1):e!==null&&typeof e=="object"?Gn(e)?e:new Proxy(new Cc(n,r,e),X1):e}function Ic(n){let r=new Ga(n);return[za(r,"",n),r]}function kn(n,r){let[e,t]=Ic(n);return r(e),t.result()}function Ye(n){return n instanceof jn||n instanceof Fn?n._current:n!==null&&typeof n=="object"?n[wm]:n}var vt;(o=>{function n(i,s){if(s.length===i.length)for(var a=0;a<i.length;){if(i[a]!==s[a])return!1;a+=1}else return!1;return!0}o.equal=n;function r(i,s,a){let c=t(a,i);if(c!==void 0&&typeof c=="object"&&c!==null){let u={...s};return Object.keys(c).forEach(l=>{delete u[l]}),u}else return s}o.removeOverridden=r;function e(i,s){if((i instanceof Be||i instanceof jn)&&typeof s=="string")return i.data(s);if((i instanceof me||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,a=0){for(;a<s.length&&i!==void 0;)i=e(i,s[a]),a+=1;return i}o.zoom=t})(vt||(vt={}));function Pm(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 yt(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 ja=class{},as=class extends ja{constructor(e){super();this.id=e}},ls=class extends ja{constructor(e){super();this.data=e}};var Ec;try{Ec=new TextDecoder}catch{}var ne,mo,I=0;var Em=[],Lc=Em,Dc=0,Nt={},Te,fo,$t=0,vr=0,jt,Xr,bt=[],Ce,Tm={useRecords:!1,mapsAsObjects:!0},cs=class{},Rc=new cs;Rc.name="MessagePack 0xC1";var Un=!1,br=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 Gm(()=>(ka(),this?this.unpack(r,e):br.prototype.unpack.call(Tm,r,e)));mo=e>-1?e:r.length,I=0,Dc=0,vr=0,fo=null,Lc=Em,jt=null,ne=r;try{Ce=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 br){if(Nt=this,this.structures)return Te=this.structures,Fa();(!Te||Te.length>0)&&(Te=[])}else Nt=Tm,(!Te||Te.length>0)&&(Te=[]);return Fa()}unpackMultiple(r,e){let t,o=0;try{Un=!0;let i=r.length,s=this?this.unpack(r,i):Wa.unpack(r,i);if(e){for(e(s);I<i;)if(o=I,e(Fa())===!1)return}else{for(t=[s];I<i;)o=I,t.push(Fa());return t}}catch(i){throw i.lastPosition=o,i.values=t,i}finally{Un=!1,ka()}}_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 Fa(){try{if(!Nt.trusted&&!Un){let r=Te.sharedLength||0;r<Te.length&&(Te.length=r)}let n=Fe();if(I==mo)Te.restoreStructures&&Om(),Te=null,ne=null,Xr&&(Xr=null);else if(I>mo){let r=new Error("Unexpected end of MessagePack data");throw r.incomplete=!0,r}else if(!Un)throw new Error("Data read, but end of buffer not reached");return n}catch(n){throw Te.restoreStructures&&Om(),ka(),(n instanceof RangeError||n.message.startsWith("Unexpected end of buffer"))&&(n.incomplete=!0),n}}function Om(){for(let n in Te.restoreStructures)Te[n]=Te.restoreStructures[n];Te.restoreStructures=null}function Fe(){let n=ne[I++];if(n<160)if(n<128){if(n<64)return n;{let r=Te[n&63]||Nt.getStructures&&Lm()[n&63];return r?(r.read||(r.read=Gc(r,n&63)),r.read()):n}}else if(n<144)if(n-=128,Nt.mapsAsObjects){let r={};for(let e=0;e<n;e++)r[Bm()]=Fe();return r}else{let r=new Map;for(let e=0;e<n;e++)r.set(Fe(),Fe());return r}else{n-=144;let r=new Array(n);for(let e=0;e<n;e++)r[e]=Fe();return r}else if(n<192){let r=n-160;if(vr>=I)return fo.slice(I-$t,(I+=r)-$t);if(vr==0&&mo<140){let e=r<16?Vc(r):Dm(r);if(e!=null)return e}return Bc(r)}else{let r;switch(n){case 192:return null;case 193:return jt?(r=Fe(),r>0?jt[1].slice(jt.position1,jt.position1+=r):jt[0].slice(jt.position0,jt.position0-=r)):Rc;case 194:return!1;case 195:return!0;case 196:return Mc(ne[I++]);case 197:return r=Ce.getUint16(I),I+=2,Mc(r);case 198:return r=Ce.getUint32(I),I+=4,Mc(r);case 199:return zo(ne[I++]);case 200:return r=Ce.getUint16(I),I+=2,zo(r);case 201:return r=Ce.getUint32(I),I+=4,zo(r);case 202:if(r=Ce.getFloat32(I),Nt.useFloat32>2){let e=Ha[(ne[I]&127)<<1|ne[I+1]>>7];return I+=4,(e*r+(r>0?.5:-.5)>>0)/e}return I+=4,r;case 203:return r=Ce.getFloat64(I),I+=8,r;case 204:return ne[I++];case 205:return r=Ce.getUint16(I),I+=2,r;case 206:return r=Ce.getUint32(I),I+=4,r;case 207:return Nt.int64AsNumber?(r=Ce.getUint32(I)*4294967296,r+=Ce.getUint32(I+4)):r=Ce.getBigUint64(I),I+=8,r;case 208:return Ce.getInt8(I++);case 209:return r=Ce.getInt16(I),I+=2,r;case 210:return r=Ce.getInt32(I),I+=4,r;case 211:return Nt.int64AsNumber?(r=Ce.getInt32(I)*4294967296,r+=Ce.getUint32(I+4)):r=Ce.getBigInt64(I),I+=8,r;case 212:if(r=ne[I++],r==114)return Mm(ne[I++]&63);{let e=bt[r];if(e)return e.read?(I++,e.read(Fe())):e.noBuffer?(I++,e()):e(ne.subarray(I,++I));throw new Error("Unknown extension "+r)}case 213:return r=ne[I],r==114?(I++,Mm(ne[I++]&63,ne[I++])):zo(2);case 214:return zo(4);case 215:return zo(8);case 216:return zo(16);case 217:return r=ne[I++],vr>=I?fo.slice(I-$t,(I+=r)-$t):Q1(r);case 218:return r=Ce.getUint16(I),I+=2,vr>=I?fo.slice(I-$t,(I+=r)-$t):J1(r);case 219:return r=Ce.getUint32(I),I+=4,vr>=I?fo.slice(I-$t,(I+=r)-$t):e_(r);case 220:return r=Ce.getUint16(I),I+=2,Cm(r);case 221:return r=Ce.getUint32(I),I+=4,Cm(r);case 222:return r=Ce.getUint16(I),I+=2,Nm(r);case 223:return r=Ce.getUint32(I),I+=4,Nm(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 Z1=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function Gc(n,r){function e(){if(e.count++>2){let o=n.read=new Function("r","return function(){return {"+n.map(i=>Z1.test(i)?i+":r()":"["+JSON.stringify(i)+"]:r()").join(",")+"}}")(Fe);return n.highByte===0&&(n.read=Am(r,n.read)),o()}let t={};for(let o=0,i=n.length;o<i;o++){let s=n[o];t[s]=Fe()}return t}return e.count=0,n.highByte===0?Am(r,e):e}var Am=(n,r)=>function(){let e=ne[I++];if(e===0)return r();let t=n<32?-(n+(e<<5)):n+(e<<5),o=Te[t]||Lm()[t];if(!o)throw new Error("Record id is not defined for "+t);return o.read||(o.read=Gc(o,n)),o.read()};function Lm(){let n=Gm(()=>(ne=null,Nt.getStructures()));return Te=Nt._mergeStructures(n,Te)}var Bc=Ua,Q1=Ua,J1=Ua,e_=Ua;function Ua(n){let r;if(n<16&&(r=Vc(n)))return r;if(n>64&&Ec)return Ec.decode(ne.subarray(I,I+=n));let e=I+n,t=[];for(r="";I<e;){let o=ne[I++];if((o&128)===0)t.push(o);else if((o&224)===192){let i=ne[I++]&63;t.push((o&31)<<6|i)}else if((o&240)===224){let i=ne[I++]&63,s=ne[I++]&63;t.push((o&31)<<12|i<<6|s)}else if((o&248)===240){let i=ne[I++]&63,s=ne[I++]&63,a=ne[I++]&63,c=(o&7)<<18|i<<12|s<<6|a;c>65535&&(c-=65536,t.push(c>>>10&1023|55296),c=56320|c&1023),t.push(c)}else t.push(o);t.length>=4096&&(r+=tt.apply(String,t),t.length=0)}return t.length>0&&(r+=tt.apply(String,t)),r}function Cm(n){let r=new Array(n);for(let e=0;e<n;e++)r[e]=Fe();return r}function Nm(n){if(Nt.mapsAsObjects){let r={};for(let e=0;e<n;e++)r[Bm()]=Fe();return r}else{let r=new Map;for(let e=0;e<n;e++)r.set(Fe(),Fe());return r}}var tt=String.fromCharCode;function Dm(n){let r=I,e=new Array(n);for(let t=0;t<n;t++){let o=ne[I++];if((o&128)>0){I=r;return}e[t]=o}return tt.apply(String,e)}function Vc(n){if(n<4)if(n<2){if(n===0)return"";{let r=ne[I++];if((r&128)>1){I-=1;return}return tt(r)}}else{let r=ne[I++],e=ne[I++];if((r&128)>0||(e&128)>0){I-=2;return}if(n<3)return tt(r,e);let t=ne[I++];if((t&128)>0){I-=3;return}return tt(r,e,t)}else{let r=ne[I++],e=ne[I++],t=ne[I++],o=ne[I++];if((r&128)>0||(e&128)>0||(t&128)>0||(o&128)>0){I-=4;return}if(n<6){if(n===4)return tt(r,e,t,o);{let i=ne[I++];if((i&128)>0){I-=5;return}return tt(r,e,t,o,i)}}else if(n<8){let i=ne[I++],s=ne[I++];if((i&128)>0||(s&128)>0){I-=6;return}if(n<7)return tt(r,e,t,o,i,s);let a=ne[I++];if((a&128)>0){I-=7;return}return tt(r,e,t,o,i,s,a)}else{let i=ne[I++],s=ne[I++],a=ne[I++],c=ne[I++];if((i&128)>0||(s&128)>0||(a&128)>0||(c&128)>0){I-=8;return}if(n<10){if(n===8)return tt(r,e,t,o,i,s,a,c);{let u=ne[I++];if((u&128)>0){I-=9;return}return tt(r,e,t,o,i,s,a,c,u)}}else if(n<12){let u=ne[I++],l=ne[I++];if((u&128)>0||(l&128)>0){I-=10;return}if(n<11)return tt(r,e,t,o,i,s,a,c,u,l);let d=ne[I++];if((d&128)>0){I-=11;return}return tt(r,e,t,o,i,s,a,c,u,l,d)}else{let u=ne[I++],l=ne[I++],d=ne[I++],p=ne[I++];if((u&128)>0||(l&128)>0||(d&128)>0||(p&128)>0){I-=12;return}if(n<14){if(n===12)return tt(r,e,t,o,i,s,a,c,u,l,d,p);{let f=ne[I++];if((f&128)>0){I-=13;return}return tt(r,e,t,o,i,s,a,c,u,l,d,p,f)}}else{let f=ne[I++],m=ne[I++];if((f&128)>0||(m&128)>0){I-=14;return}if(n<15)return tt(r,e,t,o,i,s,a,c,u,l,d,p,f,m);let h=ne[I++];if((h&128)>0){I-=15;return}return tt(r,e,t,o,i,s,a,c,u,l,d,p,f,m,h)}}}}}function Mc(n){return Nt.copyBuffers?Uint8Array.prototype.slice.call(ne,I,I+=n):ne.subarray(I,I+=n)}function zo(n){let r=ne[I++];if(bt[r])return bt[r](ne.subarray(I,I+=n));throw new Error("Unknown extension type "+r)}var Im=new Array(4096);function Bm(){let n=ne[I++];if(n>=160&&n<192){if(n=n-160,vr>=I)return fo.slice(I-$t,(I+=n)-$t);if(!(vr==0&&mo<180))return Bc(n)}else return I--,Fe();let r=(n<<5^(n>1?Ce.getUint16(I):n>0?ne[I]:0))&4095,e=Im[r],t=I,o=I+n-3,i,s=0;if(e&&e.bytes==n){for(;t<o;){if(i=Ce.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 I=t,e.string;o-=3,t=I}for(e=[],Im[r]=e,e.bytes=n;t<o;)i=Ce.getUint32(t),e.push(i),t+=4;for(o+=3;t<o;)i=ne[t++],e.push(i);let a=n<16?Vc(n):Dm(n);return a!=null?e.string=a:e.string=Bc(n)}var Mm=(n,r)=>{var e=Fe();let t=n;r!==void 0&&(n=n<32?-((r<<5)+n):(r<<5)+n,e.highByte=r);let o=Te[n];return o&&o.isShared&&((Te.restoreStructures||(Te.restoreStructures=[]))[n]=o),Te[n]=e,e.read=Gc(e,t),e.read()},Rm=typeof self=="object"?self:global;bt[0]=()=>{};bt[0].noBuffer=!0;bt[101]=()=>{let n=Fe();return(Rm[n[0]]||Error)(n[1])};bt[105]=n=>{let r=Ce.getUint32(I-4);Xr||(Xr=new Map);let e=ne[I],t;e>=144&&e<160||e==220||e==221?t=[]:t={};let o={target:t};Xr.set(r,o);let i=Fe();return o.used?Object.assign(t,i):(o.target=i,i)};bt[112]=n=>{let r=Ce.getUint32(I-4),e=Xr.get(r);return e.used=!0,e.target};bt[115]=()=>new Set(Fe());var zc=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(n=>n+"Array");bt[116]=n=>{let r=n[0],e=zc[r];if(!e)throw new Error("Could not find typed array for code "+r);return new Rm[e](Uint8Array.prototype.slice.call(n,1).buffer)};bt[120]=()=>{let n=Fe();return new RegExp(n[0],n[1])};bt[98]=n=>{let r=(n[0]<<24)+(n[1]<<16)+(n[2]<<8)+n[3],e=I;I+=r-4,jt=[Fe(),Fe()],jt.position0=0,jt.position1=0;let t=I;I=e;try{return Fe()}finally{I=t}};bt[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 Gm(n){let r=mo,e=I,t=Dc,o=$t,i=vr,s=fo,a=Lc,c=Xr,u=jt,l=new Uint8Array(ne.slice(0,mo)),d=Te,p=Te.slice(0,Te.length),f=Nt,m=Un,h=n();return mo=r,I=e,Dc=t,$t=o,vr=i,fo=s,Lc=a,Xr=c,jt=u,ne=l,Un=m,Te=d,Te.splice(0,Te.length,...p),Nt=f,Ce=new DataView(ne.buffer,ne.byteOffset,ne.byteLength),h}function ka(){ne=null,Xr=null,Te=null}function Vm(n){n.unpack?bt[n.type]=n.unpack:bt[n.type]=n}var Ha=new Array(147);for(let n=0;n<256;n++)Ha[n]=+("1e"+Math.floor(45.15-n*.30103));var Wa=new br({useRecords:!1}),t_=Wa.unpack,r_=Wa.unpackMultiple,o_=Wa.unpack,qa={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},n_=new Float32Array(1),yR=new Uint8Array(n_.buffer,0,4);var $a;try{$a=new TextEncoder}catch{}var Ya,Fc,Xa=typeof Buffer<"u",jc=Xa?Buffer.allocUnsafeSlow:Uint8Array,km=Xa?Buffer:Uint8Array,zm=Xa?4294967296:2144337920,z,He,E=0,Sr,wr=null,i_=/[\u0080-\uFFFF]/,ds=Symbol("record-id"),jo=class extends br{constructor(r){super(r),this.offset=0;let e,t,o,i,s,a,c=0,u=km.prototype.utf8Write?function(v,N,T){return z.utf8Write(v,N,T)}:$a&&$a.encodeInto?function(v,N){return $a.encodeInto(v,z.subarray(N)).written}:!1,l=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 x=[],b=0,w=0;this.pack=this.encode=function(v,N){if(z||(z=new jc(8192),He=new DataView(z.buffer,0,8192),E=0),Sr=z.length-10,Sr-E<2048?(z=new jc(z.length),He=new DataView(z.buffer,0,z.length),Sr=z.length-10,E=0):E=E+7&2147483640,t=E,a=l.structuredClone?new Map:null,l.bundleStrings?(wr=["",""],z[E++]=214,z[E++]=98,wr.position=E-t,E+=4):wr=null,o=l.structures,o){o.uninitialized&&(o=l._mergeStructures(l.getStructures()));let T=o.sharedLength||0;if(T>f)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+o.sharedLength);if(!o.transitions){o.transitions=Object.create(null);for(let C=0;C<T;C++){let O=o[C];if(!O)continue;let A,R=o.transitions;for(let U=0,$=O.length;U<$;U++){let ee=O[U];A=R[ee],A||(A=R[ee]=Object.create(null)),R=A}R[ds]=C+64}c=T}d||(o.nextId=T+64)}i&&(i=!1),s=o||[];try{if(S(v),wr){He.setUint32(wr.position+t,E-wr.position-t);let T=wr;wr=null,S(T[0]),S(T[1])}if(l.offset=E,a&&a.idsToInsert){E+=a.idsToInsert.length*6,E>Sr&&_(E),l.offset=E;let T=a_(z.subarray(t,E),a.idsToInsert);return a=null,T}return N&Hm?(z.start=t,z.end=E,z):z.subarray(t,E)}finally{if(o){if(w<10&&w++,b>1e4)o.transitions=null,w=0,b=0,x.length>0&&(x=[]);else if(x.length>0&&!d){for(let T=0,C=x.length;T<C;T++)x[T][ds]=0;x=[]}if(i&&l.saveStructures){let T=o.sharedLength||f;o.length>T&&(o=o.slice(0,T));let C=z.subarray(t,E);return l.saveStructures(o,c)===!1?(l._mergeStructures(l.getStructures()),l.pack(v)):(c=T,C)}}N&m_&&(E=t)}};let S=v=>{E>Sr&&(z=_(E));var N=typeof v,T;if(N==="string"){let C=v.length;if(wr&&C>=8&&C<4096){let R=i_.test(v);wr[R?0:1]+=v,z[E++]=193,S(R?-C:C);return}let O;C<32?O=1:C<256?O=2:C<65536?O=3:O=5;let A=C*3;if(E+A>Sr&&(z=_(E+A)),C<64||!u){let R,U,$,ee=E+O;for(R=0;R<C;R++)U=v.charCodeAt(R),U<128?z[ee++]=U:U<2048?(z[ee++]=U>>6|192,z[ee++]=U&63|128):(U&64512)===55296&&(($=v.charCodeAt(R+1))&64512)===56320?(U=65536+((U&1023)<<10)+($&1023),R++,z[ee++]=U>>18|240,z[ee++]=U>>12&63|128,z[ee++]=U>>6&63|128,z[ee++]=U&63|128):(z[ee++]=U>>12|224,z[ee++]=U>>6&63|128,z[ee++]=U&63|128);T=ee-E-O}else T=u(v,E+O,A);T<32?z[E++]=160|T:T<256?(O<2&&z.copyWithin(E+2,E+1,E+1+T),z[E++]=217,z[E++]=T):T<65536?(O<3&&z.copyWithin(E+3,E+2,E+2+T),z[E++]=218,z[E++]=T>>8,z[E++]=T&255):(O<5&&z.copyWithin(E+5,E+3,E+3+T),z[E++]=219,He.setUint32(E,T),E+=4),E+=T}else if(N==="number")if(v>>>0===v)v<64?z[E++]=v:v<256?(z[E++]=204,z[E++]=v):v<65536?(z[E++]=205,z[E++]=v>>8,z[E++]=v&255):(z[E++]=206,He.setUint32(E,v),E+=4);else if(v>>0===v)v>=-32?z[E++]=256+v:v>=-128?(z[E++]=208,z[E++]=v+256):v>=-32768?(z[E++]=209,He.setInt16(E,v),E+=2):(z[E++]=210,He.setInt32(E,v),E+=4);else{let C;if((C=this.useFloat32)>0&&v<4294967296&&v>=-2147483648){z[E++]=202,He.setFloat32(E,v);let O;if(C<4||(O=v*Ha[(z[E]&127)<<1|z[E+1]>>7])>>0===O){E+=4;return}else E--}z[E++]=203,He.setFloat64(E,v),E+=8}else if(N==="object")if(!v)z[E++]=192;else{if(a){let O=a.get(v);if(O){if(!O.id){let A=a.idsToInsert||(a.idsToInsert=[]);O.id=A.push(O)}z[E++]=214,z[E++]=112,He.setUint32(E,O.id),E+=4;return}else a.set(v,{offset:E-t})}let C=v.constructor;if(C===Object)P(v,!0);else if(C===Array){T=v.length,T<16?z[E++]=144|T:T<65536?(z[E++]=220,z[E++]=T>>8,z[E++]=T&255):(z[E++]=221,He.setUint32(E,T),E+=4);for(let O=0;O<T;O++)S(v[O])}else if(C===Map){T=v.size,T<16?z[E++]=128|T:T<65536?(z[E++]=222,z[E++]=T>>8,z[E++]=T&255):(z[E++]=223,He.setUint32(E,T),E+=4);for(let[O,A]of v)S(O),S(A)}else{for(let O=0,A=Ya.length;O<A;O++){let R=Fc[O];if(v instanceof R){let U=Ya[O];if(U.write){U.type&&(z[E++]=212,z[E++]=U.type,z[E++]=0),S(U.write.call(this,v));return}let $=z,ee=He,Y=E;z=null;let q;try{q=U.pack.call(this,v,H=>(z=$,$=null,E+=H,E>Sr&&_(E),{target:z,targetView:He,position:E-H}),S)}finally{$&&(z=$,He=ee,E=Y,Sr=z.length-10)}q&&(q.length+E>Sr&&_(q.length+E),E=s_(q,z,E,U.type));return}}P(v,!v.hasOwnProperty)}}else if(N==="boolean")z[E++]=v?195:194;else if(N==="bigint"){if(v<BigInt(1)<<BigInt(63)&&v>=-(BigInt(1)<<BigInt(63)))z[E++]=211,He.setBigInt64(E,v);else if(v<BigInt(1)<<BigInt(64)&&v>0)z[E++]=207,He.setBigUint64(E,v);else if(this.largeBigIntToFloat)z[E++]=203,He.setFloat64(E,Number(v));else throw new RangeError(v+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");E+=8}else if(N==="undefined")this.encodeUndefinedAsNil?z[E++]=192:(z[E++]=212,z[E++]=0,z[E++]=0);else if(N==="function")S(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+N)},P=this.useRecords===!1?this.variableMapSize?v=>{let N=Object.keys(v),T=N.length;T<16?z[E++]=128|T:T<65536?(z[E++]=222,z[E++]=T>>8,z[E++]=T&255):(z[E++]=223,He.setUint32(E,T),E+=4);let C;for(let O=0;O<T;O++)S(C=N[O]),S(v[C])}:(v,N)=>{z[E++]=222;let T=E-t;E+=2;let C=0;for(let O in v)(N||v.hasOwnProperty(O))&&(S(O),S(v[O]),C++);z[T+++t]=C>>8,z[T+t]=C&255}:v=>{let N=Object.keys(v),T,C=s.transitions||(s.transitions=Object.create(null)),O=0;for(let R=0,U=N.length;R<U;R++){let $=N[R];T=C[$],T||(T=C[$]=Object.create(null),O++),C=T}let A=C[ds];if(A)A>=96&&h?(z[E++]=((A-=96)&31)+96,z[E++]=A>>5):z[E++]=A;else{A=s.nextId,A||(A=64),A<y&&this.shouldShareStructure&&!this.shouldShareStructure(N)?(A=s.nextOwnId,A<g||(A=y),s.nextOwnId=A+1):(A>=g&&(A=y),s.nextId=A+1);let R=N.highByte=A>=96&&h?A-96>>5:-1;C[ds]=A,s[A-64]=N,A<y?(N.isShared=!0,s.sharedLength=A-63,i=!0,R>=0?(z[E++]=(A&31)+96,z[E++]=R):z[E++]=A):(R>=0?(z[E++]=213,z[E++]=114,z[E++]=(A&31)+96,z[E++]=R):(z[E++]=212,z[E++]=114,z[E++]=A),O&&(b+=w*O),x.length>=m&&(x.shift()[ds]=0),x.push(C),S(N))}for(let R=0,U=N.length;R<U;R++)S(v[N[R]])},_=v=>{let N;if(v>16777216){if(v-t>zm)throw new Error("Packed buffer would be larger than maximum buffer size");N=Math.min(zm,Math.round(Math.max((v-t)*(v>67108864?1.25:2),4194304)/4096)*4096)}else N=(Math.max(v-t<<2,z.length-1)>>12)+1<<12;let T=new jc(N);return He=new DataView(T.buffer,0,N),z.copy?z.copy(T,0,t,v):T.set(z.slice(t,v)),E-=t,t=0,Sr=T.length-10,z=T}}useBuffer(r){z=r,He=new DataView(z.buffer,z.byteOffset,z.byteLength),E=0}};Fc=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,cs];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?jm(n,16,r):Fm(Xa?Buffer.from(n):new Uint8Array(n),r)}},{pack(n,r){let e=n.constructor;e!==km&&this.structuredClone?jm(n,zc.indexOf(e.name),r):Fm(n,r)}},{pack(n,r){let{target:e,position:t}=r(1);e[t]=193}}];function jm(n,r,e,t){let o=n.byteLength;if(o+1<256){var{target:i,position:s}=e(4+o);i[s++]=199,i[s++]=o+1}else if(o+1<65536){var{target:i,position:s}=e(5+o);i[s++]=200,i[s++]=o+1>>8,i[s++]=o+1&255}else{var{target:i,position:s,targetView:a}=e(7+o);i[s++]=201,a.setUint32(s,o+1),s+=4}i[s++]=116,i[s++]=r,i.set(new Uint8Array(n.buffer,n.byteOffset,n.byteLength),s)}function Fm(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 s_(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 a_(n,r){let e,t=r.length*6,o=n.length-t;for(r.sort((i,s)=>i.offset>s.offset?1:-1);e=r.pop();){let i=e.offset,s=e.id;n.copyWithin(i+t,i,o),t-=6;let a=i+t;n[a++]=214,n[a++]=105,n[a++]=s>>24,n[a++]=s>>16&255,n[a++]=s>>8&255,n[a++]=s&255,o=i}return n}function ho(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)");Fc.unshift(n.Class),Ya.unshift(n)}Vm(n)}var Um=new jo({useRecords:!1}),l_=Um.pack,c_=Um.pack;var{NEVER:d_,ALWAYS:u_,DECIMAL_ROUND:p_,DECIMAL_FIT:f_}=qa,Hm=512,m_=1024;var Wm=new jo({structuredClone:!0});ho({Class:Me.prototype.constructor,type:1,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,Me.prototype),n}});ho({Class:me.prototype.constructor,type:2,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,me.prototype),n}});ho({Class:Be.prototype.constructor,type:3,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,Be.prototype),n}});ho({Class:as.prototype.constructor,type:4,write(n){return n.id},read(n){return new as(n)}});ho({Class:ls.prototype.constructor,type:5,write(n){return n.data},read(n){return new ls(n)}});ho({Class:Re.prototype.constructor,type:6,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,Re.prototype),n}});function h_(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 kc(n){if(Gn(n))return n;if(Array.isArray(n))return n.map(kc);if(typeof n=="object"&&n!==null){let r={};for(let e of Object.keys(n).sort())r[e]=kc(n[e]);return Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r}else return n}var Ka;(t=>{function n(o){return Wm.pack(o)}t.serialize=n;function r(o){return Wm.unpack(o)}t.deserialize=r;function e(o){return h_(n(kc(o))).toString()}t.checksum=e})(Ka||(Ka={}));var xo="personal camera",vo="a218fcc3-276b-49b9-b485-49037fd14f5f",Zm=2960946,Ke=5526619;var qm;(e=>{function n(t,o){return t[0]===o[0]&&t[1]===o[1]}e.isEqual=n;function r(t,o,i){return[t[0]+(o[0]-t[0])*i,t[1]+(o[1]-t[1])*i]}e.lerp=r})(qm||(qm={}));var yo;(a=>{function n(c,u){return c[0]===u[0]&&c[1]===u[1]&&c[2]===u[2]}a.isEqual=n;function r(c,u){return[c[0]+u[0],c[1]+u[1],c[2]+u[2]]}a.add=r;function e(c,u){return[c[0]-u[0],c[1]-u[1],c[2]-u[2]]}a.sub=e;function t(c,u){return[c[0]/u[0],c[1]/u[1],c[2]/u[2]]}a.div=t;function o(c,u){return[c[0]*u[0],c[1]*u[1],c[2]*u[2]]}a.mul=o;function i(c,u){return Math.hypot(c[0]-u[0],c[1]-u[1],c[2]-u[2])}a.dist=i;function s(c,u,l){return[c[0]+(u[0]-c[0])*l,c[1]+(u[1]-c[1])*l,c[2]+(u[2]-c[2])*l]}a.lerp=s})(yo||(yo={}));var $m;(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})($m||($m={}));var go;(o=>{o.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function r(i,s){for(let a=0;a<16;a++)if(i[a]!==s[a])return!1;return!0}o.isEqual=r;function e(i){return i??o.identity}o.simplify=e;function t(i,s){let a=s.slice(0);for(var c=0,u=s.length;c<u;c+=3){let l=i[3]*s[c]+i[7]*s[c+1]+i[11]*s[c+2]+i[15];a[c]=(i[0]*s[c]+i[4]*s[c+1]+i[8]*s[c+2]+i[12])/l,a[c+1]=(i[1]*s[c]+i[5]*s[c+1]+i[9]*s[c+2]+i[13])/l,a[c+2]=(i[2]*s[c]+i[6]*s[c+1]+i[10]*s[c+2]+i[14])/l}return a}o.applyMatrix4=t})(go||(go={}));var rt;(l=>{function n(d){return typeof d=="object"&&typeof d.r=="number"&&typeof d.g=="number"&&typeof d.b=="number"}l.isRGB=n,l.white={r:1,g:1,b:1},l.red={r:1,g:0,b:0},l.black={r:0,g:0,b:0};function o(d){return{r:Math.round(d.r*255),g:Math.round(d.g*255),b:Math.round(d.b*255),a:1}}l.toRgb255a1=o;function i(d){return{r:d.r,g:d.g,b:d.b}}l.clone=i;function s(d){return d=Math.floor(d),{r:(d>>16&255)/255,g:(d>>8&255)/255,b:(d&255)/255}}l.fromHex=s;function a(d){return Math.round(d.r*255)*65536+Math.round(d.g*255)*256+Math.round(d.b*255)}l.toHex=a;function c(d,p){return d.r===p.r&&d.g===p.g&&d.b===p.b}l.equals=c;function u(d,p,f){return{r:d.r+(p.r-d.r)*f,g:d.g+(p.g-d.g)*f,b:d.b+(p.b-d.b)*f}}l.lerp=u})(rt||(rt={}));var St;(a=>{a.white={...rt.white,a:1},a.transparent={...rt.white,a:0};function e(c){return{r:c[0],g:c[1],b:c[2],a:c[3]}}a.from0to1=e;function t(c,u){return{...rt.fromHex(c),a:u}}a.fromHexAndA=t;function o(c){return{r:Math.round(c.r*255),g:Math.round(c.g*255),b:Math.round(c.b*255),a:c.a}}a.toRgb255a1=o;function i(c,u){return rt.equals(c,u)&&c.a===u.a}a.equals=i;function s(c,u,l){return{r:c.r+(u.r-c.r)*l,g:c.g+(u.g-c.g)*l,b:c.b+(u.b-c.b)*l,a:c.a+(u.a-c.a)*l}}a.lerp=s})(St||(St={}));var Za;(r=>r.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(Za||(Za={}));var Ym;(r=>r.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(Ym||(Ym={}));var Xm;(r=>r.defaultData={control1:[.5,0],control2:[.5,1]})(Xm||(Xm={}));var Km;(i=>(i.linear=[0,0,1,1],i.ease=[.25,.1,.25,1],i.easeIn=[.42,0,1,1],i.easeOut=[0,0,.58,1],i.easeInOut=[.42,0,.58,1]))(Km||(Km={}));var er;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function r(t){return e.all.includes(t)}e.is=r})(er||(er={}));var bo;(o=>{o.DefaultUp=[0,1,0],o.DefaultTargetOffset=1e3,o.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:o.DefaultUp,isUpVectorFlipped:!1,targetOffset:o.DefaultTargetOffset};function t(i){return i.type==="PerspectiveCamera"?i.perspective.zoom:i.orthographic.zoom}o.getZoom=t})(bo||(bo={}));var _r;(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(y_.forEach(s=>{Object.assign(i,{[s]:o[s]??t[s]})}),i.radial={...t.radial},o.radial){let s=t.radial,a=o.radial;g_.forEach(c=>{Object.assign(i.radial,{[c]:a[c]??s[c]})})}if(i.linear={...t.linear},o.linear){let s=t.linear,a=o.linear;x_.forEach(c=>{Object.assign(i.linear,{[c]:a[c]??s[c]})})}if(i.grid={...t.grid},o.grid){let s=t.grid,a=o.grid;v_.forEach(c=>{Object.assign(i.grid,{[c]:a[c]??s[c]})})}if(i.toObject={...t.toObject},o.toObject){let s=t.toObject,a=o.toObject;b_.forEach(c=>{Object.assign(i.toObject,{[c]:a[c]??s[c]})})}if(i.randomnessObject={...t.randomnessObject},o.randomnessObject){let s=t.randomnessObject,a=o.randomnessObject;S_.forEach(c=>{Object.assign(i.randomnessObject,{[c]:a[c]??s[c]})})}return i}e.merge=r})(_r||(_r={}));var Qa;(t=>{t.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let r=["radial","linear","grid","toObject","randomnessObject"];function e(o,i){let s=[];o.count!==void 0&&s.push({type:0,path:i,props:{count:o.count}});for(let a of r){let c=o[a];c&&Object.keys(c).length>0&&s.push({type:0,path:[...i,a],props:c})}return s}t.toOps=e})(Qa||(Qa={}));var y_=["count"],g_=["radius","start","end","position","scale","rotation"],x_=["position","scale","rotation"],v_=["count","size"],b_=["count","position","scale","rotation"],S_=["strength","scale","rotation","position","movement","seed","freqScale"];var Ja;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function r(t){return e.all.includes(t)}e.is=r})(Ja||(Ja={}));var el;(e=>{function n(t){return r(t)}e.defaultData=n;function r(t){if(t==="PointLight")return{type:t,color:St.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(t==="SpotLight")return{type:t,color:St.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};if(t==="DirectionalLight")return{type:t,color:St.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(el||(el={}));var So;(r=>r.defaultData={enabled:"visibility",fusedBody:!0,rigidBody:"positioned",density:1,pointMass:0,gravityScale:1,friction:.5,damping:0,restitution:.2,colliderType:"convex",enabledRotation:[!0,!0,!0],enabledTranslation:[!0,!0,!0]})(So||(So={}));var Uc;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function r(t,o){return t.castShadow===o.castShadow&&t.receiveShadow===o.receiveShadow}e.equals=r})(Uc||(Uc={}));var Hc;(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})(Hc||(Hc={}));var tl;(r=>r.defaultData={...Hc.defaultData,...Uc.defaultData})(tl||(tl={}));var Hn;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(Hn||(Hn={}));var Qm;(r=>{function n(e){return e==="texture"||e==="video"||e==="color"||e==="depth"||e==="normal"||e==="gradient"||e==="noise"||e==="fresnel"||e==="rainbow"||e==="toon"||e==="outline"||e==="transmission"||e==="matcap"||e==="displace"||e==="pattern"||e==="light"}r.is=n})(Qm||(Qm={}));function eh(n){return n.type!=="displace"}var Jm;(r=>{function n(e){return e==="phong"||e==="toon"||e==="lambert"||e==="physical"}r.is=n})(Jm||(Jm={}));var th=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],rh=["wrapping","image","video","name"],wt;(o=>{function n(i,s){let{texture:a,...c}=s;if(Object.assign(i,c),a){let u=i.texture;u&&Object.assign(u,a)}}o.patch=n;function r(i,s){return i==="light"&&s?e(s):t(i)}o.defaultData=r;function e(i){let s={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0};switch(i){case"phong":return{...s,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...s,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...s,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...s,category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0,occlusion:!0}}}function t(i){let s={alpha:1,mode:0,isMask:!1,visible:!0};switch(i){case"texture":return{...s,type:"texture",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{image:"image_0",wrapping:1e3,repeat:[1,1],offset:[0,0]},crop:!1};case"video":return{...s,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:Hn.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!1};case"color":return{...s,type:"color",color:rt.fromHex(Ke)};case"depth":return{...s,type:"depth",gradientType:1,smooth:!1,isVector:!0,isWorldSpace:!1,origin:[0,0,0],direction:[1,0,0],colors:[[1,1,1,1],[0,0,0,1]],steps:[0,1],near:50,far:200};case"normal":return{...s,type:"normal",cnormal:[1,1,1]};case"gradient":return{...s,type:"gradient",gradientType:0,smooth:!1,colors:[[0,0,0,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,1,1,1,1,1,1,1,1,1],num:2,angle:0,offset:[0,0],morph:[0,0]};case"noise":return{...s,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...rt.fromHex(6710886),a:1},colorB:{...rt.fromHex(6710886),a:1},colorC:{...rt.fromHex(16777215),a:1},colorD:{...rt.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8],voronoiStyle:0,highCut:1,lowCut:0,smoothness:.3,seed:0,quality:1};case"fresnel":return{...s,type:"fresnel",color:St.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{...s,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...s,type:"toon",positioning:2,colors:[[0,0,0,1],[.5,.5,.5,1],[.5,.5,.5,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,.475,.525,1,1,1,1,1,1,1],num:4,source:[0,1e3,0],isWorldSpace:!0,noiseStrength:0,noiseScale:1,shadowColor:St.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...s,type:"outline",outlineColor:St.fromHexAndA(0,1),contourColor:St.fromHexAndA(0,1),outlineWidth:2,contourWidth:5,outlineThreshold:.4,contourThreshold:0,outlineSmoothing:0,contourFrequency:10,contourDirection:[0,1,0],positionalLines:!1,compensation:!0};case"matcap":return{...s,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0]}};case"transmission":return{...s,type:"transmission",thickness:10,ior:1.5,roughness:1};case"displace":return{visible:!0,type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,voronoiStyle:0,smoothness:.3,seed:0,highCut:1,lowCut:0,quality:1};case"pattern":return{...s,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...rt.fromHex(0),a:1},colorB:{...rt.fromHex(16777215),a:1},frequency:[10,10],size:.5,variation:0,smoothness:.5,zigzag:0,rotation:0,vertical:[0,1],horizontal:[0,1],sides:6}}}})(wt||(wt={}));var It;(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 l="";return u.layers.forEach(d=>{Object.entries(d.data).forEach(([p,f])=>{l+=`${p}${f}`,Array.isArray(f)?f.forEach(m=>l+=`${m}`):typeof f=="object"?Object.values(f).forEach(m=>{typeof m=="number"?l+=`${m.toFixed(4)}`:l+=`${m}`}):l+=`${f}`})}),l}c.getHash=r;function e(){return{layers:new me}}c.defaultEmptyData=e;function t(u="layer1",l="layer2"){return i("phong",u,l)}c.defaultData=t;function o(u,l){return{...u,name:l}}c.withName=o;function i(u,l="layer1",d="layer2"){let p=new me;return p.push({fi:0,data:wt.defaultData("light",u),id:l}),p.push({fi:1,data:wt.defaultData("color"),id:d}),{layers:p}}c.defaultTwoLayerData=i;function s(u,l="phong",d="layer1",p="layer2"){let f=wt.defaultData("texture");Object.assign(f.texture,{image:u});let m=new me;return m.push({fi:0,data:f,id:d}),m.push({fi:1,data:wt.defaultData("light",l),id:p}),{layers:m}}c.defaultTwoLayerTextureData=s;function a(u,l="phong",d="layer1",p="layer2"){let f=wt.defaultData("video");Object.assign(f.texture,{video:u});let m=new me;return m.push({fi:0,data:f,id:d}),m.push({fi:1,data:wt.defaultData("light",l),id:p}),{layers:m}}c.defaultTwoLayerVideoTextureData=a})(It||(It={}));var Wn;(r=>{function n(){return{points:new me,roundness:0,shapeHoles:[],isClosed:!1}}r.defaultData=n})(Wn||(Wn={}));var qn;(r=>{function n(){return{points:new me,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}r.defaultData=n})(qn||(qn={}));var Wc={type:"Ellipse",width:100,height:100,spikes:64,angle:360,innerRadius:0};var rl;(r=>{function n(e,t){let o={...e};return w_.forEach(i=>{Object.assign(o,{[i]:t[i]??e[i]})}),o}r.merge=n})(rl||(rl={}));var ol={shape:Wc,depth:1,offset:0,bevel:0,bevelSides:1,angle:0,twist:0,startScale:1,endScale:1},w_=["depth","offset","angle","twist","startScale","endScale"];var us;(e=>{function n(t){return t==="PolygonGeometry"||t==="RectangleGeometry"||t==="StarGeometry"||t==="TriangleGeometry"||t==="EllipseGeometry"}e.is2DParametricMesh=n;function r(t){return t==="PolygonGeometry"||t==="PolygonGeometry"||t==="RectangleGeometry"||t==="StarGeometry"||t==="TriangleGeometry"||t==="EllipseGeometry"||t==="PathGeometry"||t==="VectorGeometry"||t==="ConeGeometry"||t==="CubeGeometry"||t==="CylinderGeometry"||t==="DodecahedronGeometry"||t==="HelixGeometry"||t==="IcosahedronGeometry"||t==="LatheGeometry"||t==="PyramidGeometry"||t==="SphereGeometry"||t==="PlaneGeometry"||t==="BackdropGeometry"||t==="TorusGeometry"||t==="TorusKnotGeometry"||t==="BooleanGeometry"||t==="TextGeometry"}e.isParametricMesh=r})(us||(us={}));var nl;(r=>{function n(e,t){let o={...e};return Object.assign(o,t),o.type==="PathGeometry"&&"extrusion"in t&&t.extrusion&&(o.extrusion={...e.extrusion},Object.assign(o.extrusion,rl.merge(o.extrusion,t.extrusion))),o}r.merge=n})(nl||(nl={}));var wo;(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:qn.defaultData(),extrusion:ol};if(e==="VectorGeometry")return{width:1,height:1,type:e,subdivisions:12,shape:Wn.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="BooleanGeometry")return{type:e,operation:2,width:0,height:0,depth:0,phongAngle:35};if(e==="TextGeometry")return{type:e,width:100,height:100,depth:0,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.2,letterSpacing:0,text:"",textTransform:1,font:"Roboto_regular",extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="SphereGeometry")return{type:"SphereGeometry",width:100,height:100,depth:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI};throw new Error("not implemented")}r.defaultData=n})(wo||(wo={}));var il;(r=>r.defaultData={enabled:!1,useBackgroundColor:!1,color:rt.white,near:.1,far:2e3})(il||(il={}));var sl;(e=>{let n={opacity:1,blendFunction:13,enabled:!1};e.defaultData={enabled:!1,pixelation:{...n,blendFunction:16,granularity:15},bloom:{...n,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...n,offset:[2,2]},vignette:{...n,darkness:1,offset:0},hueSaturation:{...n,hue:3,saturation:0},brightnessContrast:{...n,brightness:.25,contrast:0},depthOfField:{...n,focalLength:2,focusDistance:2,bokehScale:2},noise:{...n,blendFunction:16}}})(sl||(sl={}));var qc;(r=>r.defaultData={softShadowQuality:"low"})(qc||(qc={}));var $c;(r=>r.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})($c||($c={}));var Yc;(r=>r.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(Yc||(Yc={}));var ps;(r=>r.defaultData={usePhysics:!1,gravity:-10})(ps||(ps={}));var Xc;(r=>r.defaultData={playCamera:xo,gameControlObject:null})(Xc||(Xc={}));var al;(r=>r.defaultData={backgroundColor:St.fromHexAndA(Zm,1),postprocessing:sl.defaultData,fog:il.defaultData,globalPhysics:ps.defaultData,ambient:$c.defaultData,ao:Yc.defaultData,shadow:qc.defaultData,publish:Xc.defaultData})(al||(al={}));var oh;(e=>{function n(t){return t==="Component"||t==="Instance"}e.isComponentRelated=n;function r(t){return t==="Empty"||t==="Instance"}e.isEmptyOrComponent=r})(oh||(oh={}));var $n;(o=>{o.identity={...Za.identity,hiddenMatrix:go.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 Hu({position:yo.isEqual(i.position,s.position)?void 0:s.position,rotation:yo.isEqual(i.rotation,s.rotation)?void 0:s.rotation,scale:yo.isEqual(i.scale,s.scale)?null:s.scale,hiddenMatrix:go.isEqual(i.hiddenMatrix,s.hiddenMatrix)?void 0:s.hiddenMatrix})}o.diff=t})($n||($n={}));var gt;(r=>r.defaultData={states:new me,events:new me,visible:!0,raycastLock:!1,physics:So.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...$n.identity,cloner:null})(gt||(gt={}));var nh;(r=>r.defaultData={type:"Empty",...gt.defaultData})(nh||(nh={}));var ih;(r=>r.defaultData={type:"Component",...gt.defaultData})(ih||(ih={}));var Fo;(r=>r.defaultData={type:"Mesh",...gt.defaultData,...tl.defaultData})(Fo||(Fo={}));var ko;(r=>r.defaultData={...gt.defaultData,...$n.identity,position:[0,0,bo.DefaultTargetOffset],...bo.defaultData})(ko||(ko={}));var ll;(e=>{function n(t){return{...gt.defaultData,...el.defaultData(t)}}e.defaultData=n,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(ll||(ll={}));var Yn;(e=>{function n(t,o,i=0){for(;i<o.length;){let s=t?t[o[i]]:void 0;if(o.length===i+1)return s;if(s)t=s.descendants,i+=1;else return}}e.resolveWithDes=n;function r(t,o,i=0){let s=n(t,o,i);if(s){let a=Object.keys(s);if(a.length===1&&a[0]==="descendants")return}return s}e.resolve=r})(Yn||(Yn={}));var Kr;(i=>{i.rootOverrideProps=["physics","events"],i.compositeNonOptionalOverrideProps=["geometry"],i.compositeEntireOverrideOverrideProps=["material"];function t(s,a){return{...gt.defaultData,...a,component:s,overrides:new Re,physics:void 0,events:void 0,type:"Instance"}}i.ofComponent=t;function o(s){let a=$n.fromObject(s.data);return t(s.id,a)}i.fromComponentData=o})(Kr||(Kr={}));var Zr;(r=>r.defaultData={type:"Page",...gt.defaultData,physics:{...So.defaultData,fusedBody:!1},...al.defaultData,camera:ko.defaultData})(Zr||(Zr={}));var cl;(i=>(i.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:go.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:So.defaultData,states:new me,events:new me,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...bo.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",...gt.defaultData,...Fo.defaultData,geometry:wo.defaultData("RectangleGeometry"),material:It.defaultTwoLayerData("phong","layer1","layer2")},i.defaultBooleanObject={name:"Boolean",...gt.defaultData,...Fo.defaultData,geometry:wo.defaultData("BooleanGeometry"),material:It.defaultTwoLayerData("phong","layer1","layer2")},i.defaultTextObject={name:"Text",...gt.defaultData,...Fo.defaultData,geometry:wo.defaultData("TextGeometry"),material:It.defaultTwoLayerData("phong","layer1","layer2")}))(cl||(cl={}));var Uo;(o=>{function n(i,s){let a={name:s};return i.type==="Mesh"?(a.geometry={},"material"in i&&(a.material={layers:new Re}),"materials"in i&&(a.materials=i.materials.map(c=>({layers:new Re})))):er.is(i.type)&&(a.perspective={},a.orthographic={}),a}o.newEmpty=n;function r(i,s){if(s===void 0)return i;let a={...i};return"material"in a&&"material"in s&&s.material&&(a.material=kn(a.material,c=>{if(typeof c!="string")for(let[u,l]of Object.entries(s.material.layers)){let d=c.layers.data(u);d&&wt.patch(d,l)}}).data),a.materials&&s.materials&&(a.materials=kn(a.materials,c=>{for(let u=0;u<a.materials.length;u++){let l=s.materials[u];if(typeof l!="string")for(let[d,p]of Object.entries(l.layers)){let f=c[u]?.layers?.data(d);f&&wt.patch(f,p)}}}).data),a}function e(i,s){let a,c=[],u={orthographic:0,perspective:0,geometry:0};function l(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(...Qa.toOps(p,["cloner"]));else if(d==="pathSnapping")c.push({path:[d],props:{slide:p.slide,offset:p.offset},type:0});else if(d==="material")l(["material"],p);else if(d==="materials")for(let[f,m]of Object.entries(p))l(["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 a===void 0&&(a={path:[],props:{},type:0},c.push(a)),a.props[d]=p;return c}o.toOps=e;function t(i,s){if(s===void 0)return i;let a={...i};if(Object.assign(a,$n.merge(a,s)),Object.assign(a,{pathSnapping:Object.assign({},a.pathSnapping,{slide:s.pathSnapping?.slide??a.pathSnapping?.slide??0,offset:s.pathSnapping?.offset??a.pathSnapping?.offset??0})}),er.is(i.type)){a.orthographic={...a.orthographic},a.perspective={...a.perspective};let c=s;c.orthographic?.zoom!==void 0&&(a.orthographic.zoom=c.orthographic.zoom),c.perspective?.zoom!==void 0&&(a.perspective.zoom=c.perspective.zoom),c.isUpVectorFlipped!==void 0&&(a.isUpVectorFlipped=c.isUpVectorFlipped),c.targetOffset!==void 0&&(a.targetOffset=c.targetOffset)}else if(i.type==="Mesh")"geometry"in s&&Object.assign(a,{geometry:nl.merge(a.geometry,s.geometry)}),(s.material||s.materials)&&(a=r(a,s)),a.cloner&&"cloner"in s&&Object.assign(a,{cloner:_r.merge(a.cloner,s.cloner)});else if(i.type==="Empty")a.cloner&&"cloner"in s&&Object.assign(a,{cloner:_r.merge(a.cloner,s.cloner)});else if(Ja.is(i.type)){let c=s;c.intensity!==void 0&&(a.intensity=c.intensity),c.color!==void 0&&(typeof c.color=="string"?a.color=c.color:a.color=rt.clone(c.color))}return a}o.patch=t})(Uo||(Uo={}));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})(Xn||(Xn={}));var Pr;(r=>r.defaultData={orbitControls:Xn.defaultData,playPage:vo,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((e,t)=>{let o=0,i=0;return t<5?i=-30:t<10&&(i=30),t===0||t===10||t===5?o=30:(t===4||t===11||t===9)&&(o=-30),[120,[o,i],"show"]}),settings:{image:{format:"jpg",ratio:1},video:{format:"mp4",imageFormat:"jpg",fps:30,mbps:80,ratio:Math.max(1,typeof window<"u"?Math.floor(window.devicePixelRatio):1),stopMode:"manual",duration:5e3},web:{logo:!0,compress:!0,preset:1,preload:!0,hint:!1}},stopRaycast:!0,hdTransmission:!1})(Pr||(Pr={}));var Kc;(r=>r.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(Kc||(Kc={}));var Zc;(r=>r.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(Zc||(Zc={}));var _o;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...Kc.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:Zc.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(_o||(_o={}));var sh;(e=>{function n(t){return t.find(o=>o.data.type==="Page"&&o.data.globalPhysics.usePhysics)!==void 0}e.physicsEnabled=n;function r(t,o,i){t.traverseFrom(o,(s,a)=>{if(a.type==="Instance"){let c=t.data(a.component);c&&i(a,c.events)}else i(a,a.events)})}e.traverseModuleInstances=r})(sh||(sh={}));var dl;(a=>{a.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222";function r(c={withLight:!0,withSquare:!0}){let u=[],l=cl.defaultMeshObject;c.withLight===!0&&u.push({fi:-1,data:ll.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]}),c.withSquare===!0&&u.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:l,children:[]});let d=new Be;return d.push({fi:1,id:vo,data:{...Zr.defaultData,name:"Scene 1"},children:u}),d}a.defaultData={objects:r(),publish:Pr.defaultData,styles:_o.defaultData()},a.emptyDataWithoutPage=function(){return{objects:new Be,publish:Pr.defaultData,styles:_o.defaultData()}},a.emptyDataWithPage=function(c){return{objects:r(c),publish:Pr.defaultData,styles:_o.defaultData()}};function i(c){return{...a.defaultData,objects:Jt(c,Be.prototype)}}a.withObjs=i;function s(c,u){return i([{id:c,data:u,children:[],fi:0}])}a.withObj=s})(dl||(dl={}));var Kn;(r=>r.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(Kn||(Kn={}));var ul;(t=>{function n(){let o={};return o["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},Jt(o,Me.prototype)}t.defaultColors=n;function r(o){let i={};return o?.withAITexture&&(i["a1b10010-844c-a8a3-11ec-0242ac2011ec"]={...Kn.emptyImage,name:"AI generated image"}),Jt(i,Me.prototype)}t.defaultImages=r;function e(){return{materials:new Me,images:new Me,videos:new Me,colors:new Me,audios:new Me,fonts:new Me}}t.emptyData=e})(ul||(ul={}));import{MathUtils as ml}from"three";var pl;(r=>r.list=["idle","move","jump","run"])(pl||(pl={}));var fl;(e=>(e.defaultColliderData={type:"capsule",height:200,radius:50,position:[0,0,0],rotation:[0,0,0]},e.defaultDataThirdPerson={moveMode:"walk",forwardDirection:"+z",speedTranslate:1e3,speedRotate:100,runMultiplier:2,rotationMode:"normal",rotBy:"keys",rotByTouch:"drag",delayPos:[.3,.3],delayRot:[.3,.3],keyAssignments:[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","\u25B2"],["rotPosY","\u25C0"],["rotNegX","\u25BC"],["rotNegY","\u25B6"],["jump","Space"],["run","\u21E7"],["none","Ctrl"]],touchControl:!0,joystickPosLoc:5,joystickRotLoc:11,jumpTouchButtonLoc:9,collider:e.defaultColliderData,colliderHelperVisible:!0,collisionEnabled:!0,jumpPower:100,resetYPosition:3e3,alignToGround:!1,autoOrientMove:!0,orientWith:"camera",orientMode:"radial",delayPosCamera:.3,delayRotCamera:.3,camera:"",cameraXAxis:"Limit",cameraYAxis:"Free",cameraRotXLimits:[0,Math.PI/2],cameraRotYLimits:[-Math.PI/2,Math.PI/2],gameActions:{idle:new me,move:new me,jump:new me,run:new me},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:St.fromHexAndA(3728051,1)}}))(fl||(fl={}));function ah(n){n.layers.forEach(r=>{if(r.type==="depth"&&r.colorA!==void 0){let e=r.colorA,t=r.colorB,o=[[e.r,e.g,e.b,e.a],[t.r,t.g,t.b,t.a]],i=[0,1];for(let a=2;a<10;a++)o.push(o[1]),i.push(1);let s={...Yr(Ye(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={...Ye(r),near:Math.max(r.near,0),far:Math.max(r.far,0)};Object.assign(r,e)}})}function Ho(n,r){Object.values(n.shared.materials).forEach(e=>r(e))}function Wo(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 __(n){Object.assign(n.scene.publish,{orbitControls:{...Xn.defaultData,...Ye(n.scene.publish.orbitControls)}})}function P_(n){Object.assign(n.scene.publish.settings,{video:{...Pr.defaultData.settings.video,...Ye(n.scene.publish.settings.video)}})}function T_(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((th.includes(o)||typeof i=="boolean")&&delete t[o],o==="texture")for(let[s,a]of Object.entries(i))(rh.includes(s)||typeof a=="boolean")&&delete i[s]}}}n.scene.objects.traverse((e,t)=>{t.states.forEach(o=>{let i=o;i.material?r(i.material):i.materials&&i.materials.forEach(s=>{r(s)})})})}function O_(n){n.scene.publish.withBackground=!0}function A_(n){n.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function C_(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 N_(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 I_(n){n.scene.objects.traverse((r,e)=>{let t=n.scene.objects.unproxy().parent(r);if(t){let o=Ye(n.scene.objects.data(t));o&&o.type==="Mesh"&&o.geometry.type==="BooleanGeometry"&&e.type==="Mesh"&&(e.visible=Ye(e).booleanExclude!==!0)}})}function M_(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 E_(n){function r(t){Object.setPrototypeOf(t,Re.prototype),t.texture&&Object.setPrototypeOf(t.texture,Re.prototype)}function e(t){Object.setPrototypeOf(t,Re.prototype);for(let o in t)r(t[o])}n.scene.objects.traverse((t,o)=>{o.states.forEach(i=>{let s=i;if(s.material){let a=Ye(s.material).layers;e(a),s.material.layers=a}if(s.materials)for(let a=0;a<s.materials.length;a++){let c=s.materials[a],u=Ye(c).layers;e(u),c.layers=u}})})}function lh(n){n.layers===void 0&&Object.assign(n,It.defaultTwoLayerData("lambert"))}function Qc(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={...Ye(r),colors:e,steps:t};Object.assign(r,o)}})}function L_(n){n.scene.objects.traverse((r,e)=>{e.type==="Mesh"&&(e.geometry.type==="BooleanGeometry"||e.geometry.type==="SubdivGeometry")&&(e.geometry.phongAngle=35)})}function ch(n){n.scene.objects.traverse((r,e)=>{"materials"in e?e.materials.forEach(t=>{typeof t!="string"&&Qc(t)}):"material"in e&&typeof e.material!="string"&&Qc(e.material)}),Object.values(n.shared.materials).forEach(r=>Qc(r))}function D_(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 B_(n){n.shared.audios=Jt({},Me.prototype)}function R_(n){n.shared.videos=Jt({},Me.prototype)}function G_(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 V_(n){Object.entries(Ye(n.shared.images)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete n.shared.images[t]}),Object.entries(Ye(n.shared.audios)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete n.shared.audios[t]})}function z_(n){n.scene.publish.settings.web.preload=!1}function dh(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 uh(n){n.layers&&n.layers.forEach(r=>{eh(r)&&r.isMask===void 0&&(r.isMask=!1),(r.type==="texture"||r.type==="video")&&r.blending===void 0&&(r.blending=0),(r.type==="noise"||r.type==="displace"&&r.displacementType==="noise")&&(r.voronoiStyle===void 0&&(r.voronoiStyle=0),r.highCut===void 0&&(r.highCut=1),r.lowCut===void 0&&(r.lowCut=0),r.smoothness===void 0&&(r.smoothness=.3),r.seed===void 0&&(r.seed=0),r.quality===void 0&&(r.quality=1))})}function j_(n){n.shared.fonts=Jt({},Me.prototype)}function F_(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 k_(n){let r=[];n.scene.objects.traverse((e,t)=>{let o=t;if(o.type==="TextFrame"){let i=It.defaultTwoLayerData("phong"),s=typeof o.color=="string"?n.shared.colors[o.color]:o.color;i.layers[1].data.color={r:s.r,g:s.g,b:s.b},i.layers[1].data.alpha=o.alpha;let a=F_(o.font);n.shared.fonts[a]===void 0&&(n.shared.fonts[a]={name:a});let c={name:o.name,...gt.defaultData,...Fo.defaultData,flatShading:!1,wireframe:!1,geometry:{...wo.defaultData("TextGeometry"),width:o.width,height:o.height,font:a,depth:0,horizontalAlign:o.horizontalAlign,verticalAlign:o.verticalAlign,fontSize:o.fontSize*1.40625,lineHeight:o.lineHeight/1.40625,letterSpacing:o.letterSpacing-1,text:o.text,textTransform:o.textTransform,extrudeBevelSize:0,extrudeBevelSegments:1},material:i,states:Ye(o.states),events:Ye(o.events),visible:o.visible,raycastLock:o.raycastLock,position:o.position,rotation:o.rotation,scale:o.scale,hiddenMatrix:o.hiddenMatrix},u=Ye(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 U_(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 me,move:new me,jump:new me}});else{let i=new me;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:ml.generateUUID(),data:{type:"Link",url:o.url,delay:0}}),"targets"in o&&(o.targets.forEach((s,a,c)=>{let u={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},l={easing:s.easing,duration:s.duration};s.easing===6?Object.assign(l,Yr(s,"mass","stiffness","damping","velocity")):s.easing===5&&Object.assign(l,{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,...l},f={allowSlerp:!0,type:"Transition",object:s.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new me({fi:0,id:ml.generateUUID(),data:u},{fi:1,id:ml.generateUUID(),data:p})};i.push({fi:c,id:a,data:f})}),delete o.targets)}})})}function H_(n){n.scene.objects.traverse((r,e)=>{function t(o,i){let s=new me,a=[];if(e.events.forEach((c,u,l)=>{if(c.type==="Audio"&&c.trigger===i){let d;a.push(u),c.interaction==="play"?d={...Yr(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={...Yr(c,"interaction","delay","object","playAudio"),type:"Audio"}),d&&s.push({fi:l,id:u,data:d})}}),a.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:ml.generateUUID(),data:{type:o,actions:s}}])}}t("Start","start"),t("MouseDown","mouseDown"),t("MouseUp","mouseUp"),t("KeyDown","keyDown"),t("KeyUp","keyUp")})}function ph(n){let r=n.layers.find(e=>e.type==="light")?.data;if(r?.category==="basic"){let e=wt.defaultData("light","phong"),t=r;Object.assign(t,e),t.visible=!1}}function fh(n){Ho(n,ph),Wo(n,ph)}function W_(n){n.scene.objects.traverse((r,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(e.geometry.scaleBaked||(e.geometry.scaleBaked=[1,1,1]))})}function q_(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 $_(n){n.scene.objects.traverse((r,e)=>{e.type==="Mesh"&&e.geometry.type==="NonParametricGeometry"&&!("material"in e)&&!("materials"in e)&&(e.material=It.defaultTwoLayerData("phong"))})}function Y_(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 X_(n){n.scene.objects.traverse((r,e)=>{e.pathSnapping===void 0&&(e.pathSnapping={pathId:null,slide:0,offset:0,orientation:"tangential"}),e.pathSnapping.offset===void 0&&(e.pathSnapping.offset=0)})}function K_(n){n.scene.publish.mouseEventTarget===void 0&&(n.scene.publish.mouseEventTarget="canvas"),n.scene.publish.settings.web.hint===void 0&&(n.scene.publish.settings.web.hint=!1)}function Z_(n){let{video:r}=n.scene.publish.settings;r.format==="gif"&&r.fps>48&&(r.fps=15)}function Q_(n){n.scene.objects.traverse((r,e)=>{e.events.forEach(t=>{t.type==="GameControl"&&(t.resetYPosition=Math.abs(t.resetYPosition-e.position[1]))})})}function J_(n){let r=n.scene.environment.usePhysics;n.scene.objects.traverse((e,t)=>{r&&t.physics===null?t.collision=!1:t.collision="visibility"})}function eP(n){n.scene.objects.traverse((r,e)=>{e.events.forEach(t=>{t.type==="GameControl"&&(t.navmesh=fl.defaultDataThirdPerson.navmesh)})})}function tP(n){n.scene.styles||(n.scene.styles=_o.defaultData())}function mh(n){n.layers.forEach(r=>{r.type==="light"&&r.category!=="toon"&&r.occlusion===void 0&&(r.occlusion=!0)})}function rP(n){n.scene.environment.ambientLight.occlusion===void 0&&(n.scene.environment.ambientLight.occlusion=!1),n.scene.environment.ambientLight.aoFullRes===void 0&&(n.scene.environment.ambientLight.aoFullRes=!1),n.scene.environment.ambientLight.radius===void 0&&(n.scene.environment.ambientLight.radius=256),n.scene.environment.ambientLight.bias===void 0&&(n.scene.environment.ambientLight.bias=.5),n.scene.environment.ambientLight.aoColor===void 0&&(n.scene.environment.ambientLight.aoColor={r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}),Wo(n,mh),Ho(n,mh)}function oP(n){n.scene.objects.traverse((r,e)=>{e.events.forEach(t=>{t.type==="GameControl"&&Object.assign(t.gameActions,{run:new me})})})}function nP(n){n.scene.objects.traverse((r,e)=>{e.events.forEach(t=>{t.type==="GameControl"&&(t.keyAssignments=[...t.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function hh(n){n.layers&&n.layers.forEach(r=>{r.type==="light"&&r.bumpMapIntensity===void 0&&(r.bumpMapIntensity=5)})}function yh(n,r){if(r<1&&(Wo(n,ah),Ho(n,ah),n.schema=1),r<2&&(__(n),n.schema=2),r<3&&(T_(n),n.schema=3),r<4&&(O_(n),n.schema=4),r<5&&(A_(n),n.schema=5),r<6&&(C_(n),n.schema=6),r<7&&(N_(n),n.schema=7),r<8&&(n.schema=8),r<9&&(ch(n),n.schema=9),r<10&&(L_(n),n.schema=10),r<11&&(D_(n),n.schema=11),r<12&&(ch(n),n.schema=12),r<13&&(B_(n),n.schema=13),r<14&&(G_(n),n.schema=14),r<15&&(V_(n),n.schema=15),r<16&&(z_(n),n.schema=16),r<17&&(Wo(n,dh),Ho(n,dh),n.schema=17),r<18&&(Wo(n,lh),Ho(n,lh),n.schema=18),r<19&&(P_(n),n.schema=19),r<20&&(j_(n),k_(n),n.schema=20),r<21&&(U_(n),H_(n),n.schema=21),r<22&&(fh(n),n.schema=22),r<23&&(W_(n),n.schema=23),r<24&&(q_(n),n.schema=24),(r<25||n.shared.videos===void 0)&&(R_(n),r<25&&(n.schema=25)),r<26&&(I_(n),n.schema=26),r<27&&(M_(n),n.schema=27),r<28&&(fh(n),n.schema=28),r<29&&(E_(n),n.schema=29),r<30&&($_(n),n.schema=30),r<31&&(Y_(n),n.schema=31),r<33&&(X_(n),n.schema=33),r<34&&(K_(n),n.schema=34),r<35&&(Z_(n),n.schema=35),r<36&&(Q_(n),n.schema=36),r<37&&(J_(n),n.schema=37),r<38&&(Wo(n,uh),Ho(n,uh),n.schema=38),r<39&&(eP(n),n.schema=39),r<40&&(tP(n),n.schema=40),r<41&&(rP(n),n.schema=41),r<42&&(oP(n),n.schema=42),r<43&&(nP(n),n.schema=43),r<99){Wo(n,hh),Ho(n,hh),n.scene.publish.playCamera===null&&(n.scene.publish.playCamera=xo);let e=Ye(n.scene.objects),t=n.scene.objects;n.scene.publish.playPage=vo,t.insertBefore(null,null,[{id:vo,data:{...Zr.defaultData,backgroundColor:n.scene.backgroundColor,fog:n.scene.fog,postprocessing:n.scene.postprocessing,ao:Yr(n.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:n.scene.publish.playCamera,gameControlObject:n.scene.publish.gameControlObject},shadow:Yr(n.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...ps.defaultData,...Yr(n.scene.environment,"usePhysics","gravity")},camera:Ye(n.scene.ownerCamera)??Zr.defaultData.camera,name:"Scene"},children:[]}]);for(let s of e)s.id!==dl.TRASH_CAN_ID&&t.move(vo,s.fi,s.id);let o=0,i=0;n.shared.penumbraSize&&n.scene.objects.traverse((s,a)=>{a.type==="DirectionalLight"?(a.penumbraSize=n.shared.penumbraSize[Math.min(o,2)],o+=1):a.type==="SpotLight"&&(a.penumbraSize=n.shared.penumbraSize[3+Math.min(i,1)],i+=1),(a.physics===void 0||a.physics===null)&&a.type!=="Instance"&&(a.physics={},Object.assign(a.physics,So.defaultData)),a.physics!==void 0&&(a.physics.enabled=a.collision??"visibility",delete a.collision)}),n.schema=99}}var gh=100;function xh(n){let r=n.schema??0;r!==gh&&(console.warn("updating from ",r,"to ",gh),yh(n,r),r<100&&(n.scene.publish.joystickSizeAndXYOffset===void 0&&(n.scene.publish.joystickSizeAndXYOffset=Pr.defaultData.joystickSizeAndXYOffset),n.schema=100))}var Hi=aa(bh());import{Object3D as NA,Vector3 as Ht,Euler as Mu,MathUtils as Hg,Matrix4 as un}from"three";var iP=.5*(Math.sqrt(3)-1),ms=(3-Math.sqrt(3))/6,sP=1/3,Tr=1/6,Mz=(Math.sqrt(5)-1)/4,Ez=(5-Math.sqrt(5))/20,hs=n=>Math.floor(n)|0,Sh=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]),ed=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 hl(n=Math.random){let r=_h(n),e=new Float64Array(r).map(o=>Sh[o%12*2]),t=new Float64Array(r).map(o=>Sh[o%12*2+1]);return function(i,s){let a=0,c=0,u=0,l=(i+s)*iP,d=hs(i+l),p=hs(s+l),f=(d+p)*ms,m=d-f,h=p-f,y=i-m,g=s-h,x,b;y>g?(x=1,b=0):(x=0,b=1);let w=y-x+ms,S=g-b+ms,P=y-1+2*ms,_=g-1+2*ms,v=d&255,N=p&255,T=.5-y*y-g*g;if(T>=0){let A=v+r[N],R=e[A],U=t[A];T*=T,a=T*T*(R*y+U*g)}let C=.5-w*w-S*S;if(C>=0){let A=v+x+r[N+b],R=e[A],U=t[A];C*=C,c=C*C*(R*w+U*S)}let O=.5-P*P-_*_;if(O>=0){let A=v+1+r[N+1],R=e[A],U=t[A];O*=O,u=O*O*(R*P+U*_)}return 70*(a+c+u)}}function wh(n=Math.random){let r=_h(n),e=new Float64Array(r).map(i=>ed[i%12*3]),t=new Float64Array(r).map(i=>ed[i%12*3+1]),o=new Float64Array(r).map(i=>ed[i%12*3+2]);return function(s,a,c){let u,l,d,p,f=(s+a+c)*sP,m=hs(s+f),h=hs(a+f),y=hs(c+f),g=(m+h+y)*Tr,x=m-g,b=h-g,w=y-g,S=s-x,P=a-b,_=c-w,v,N,T,C,O,A;S>=P?P>=_?(v=1,N=0,T=0,C=1,O=1,A=0):S>=_?(v=1,N=0,T=0,C=1,O=0,A=1):(v=0,N=0,T=1,C=1,O=0,A=1):P<_?(v=0,N=0,T=1,C=0,O=1,A=1):S<_?(v=0,N=1,T=0,C=0,O=1,A=1):(v=0,N=1,T=0,C=1,O=1,A=0);let R=S-v+Tr,U=P-N+Tr,$=_-T+Tr,ee=S-C+2*Tr,Y=P-O+2*Tr,q=_-A+2*Tr,H=S-1+3*Tr,V=P-1+3*Tr,G=_-1+3*Tr,D=m&255,L=h&255,B=y&255,X=.6-S*S-P*P-_*_;if(X<0)u=0;else{let M=D+r[L+r[B]];X*=X,u=X*X*(e[M]*S+t[M]*P+o[M]*_)}let W=.6-R*R-U*U-$*$;if(W<0)l=0;else{let M=D+v+r[L+N+r[B+T]];W*=W,l=W*W*(e[M]*R+t[M]*U+o[M]*$)}let j=.6-ee*ee-Y*Y-q*q;if(j<0)d=0;else{let M=D+C+r[L+O+r[B+A]];j*=j,d=j*j*(e[M]*ee+t[M]*Y+o[M]*q)}let F=.6-H*H-V*V-G*G;if(F<0)p=0;else{let M=D+1+r[L+1+r[B+1]];F*=F,p=F*F*(e[M]*H+t[M]*V+o[M]*G)}return 32*(u+l+d+p)}}function _h(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}import{Triangle as aP}from"three";var tr=new aP,yl=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;tr.a.fromBufferAttribute(r,o),tr.b.fromBufferAttribute(r,o+1),tr.c.fromBufferAttribute(r,o+2),i*=tr.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),tr.a.fromBufferAttribute(this.positionAttribute,r*3),tr.b.fromBufferAttribute(this.positionAttribute,r*3+1),tr.c.fromBufferAttribute(this.positionAttribute,r*3+2),e.set(0,0,0).addScaledVector(tr.a,o).addScaledVector(tr.b,i).addScaledVector(tr.c,1-(o+i)),tr.getNormal(t),this}};import{Object3D as pP}from"three";var Oh=aa(Th());import{Object3D as lP,Matrix4 as Or}from"three";var cP=new Or,dP=new Or,uP=new Or,Zn;(r=>{function n(e){return e&&e.__isSPEObject}r.is=n})(Zn||(Zn={}));var Qn=n=>class extends n{constructor(){super(...arguments);this.previousModelViewMatrix=new Or;this.copyPreviousMatrix=!0;this.hiddenMatrix=new Or;this.matrixWorldRigid=new Or;this.shearScale=new Or;this.shearScaleInv=new Or}get __isSPEObject(){return!0}isDescendantOf(t){t instanceof lP&&(t=t.uuid);let o=this;for(;o.parent;){if(o.parent.uuid===t)return!0;o=o.parent}return!1}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);for(let o of this.children)o.updateMatrixWorld(t)}updateWorldMatrix(t,o){let i=this.parent;if(t&&i!==null&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),o)for(let s of this.children)s.updateWorldMatrix(!1,!0)}traverseChildren(t,o=0){for(let i of this.children)Zn.is(i)&&i.traverseObject(t,o+1)}traverseObject(t,o=0){if(t(this,o)!==!0)for(let s of this.children)Zn.is(s)&&s.traverseObject(t,o+1)}updateMatrixWorldSVD(){let t=this.matrixWorld.elements,o=[[t[0],t[4],t[8]],[t[1],t[5],t[9]],[t[2],t[6],t[10]]],{u:i,v:s,q:a}=(0,Oh.SVD)(o),c=cP.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=dP.set(s[0][0],s[0][1],s[0][2],0,s[1][0],s[1][1],s[1][2],0,s[2][0],s[2][1],s[2][2],0,0,0,0,1),l=uP.copy(u).transpose();this.shearScale.makeScale(a[0],a[1],a[2]).multiply(l).premultiply(u),this.shearScaleInv.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(c,l).copyPosition(this.matrixWorld),a.every(d=>Math.abs(a[0]-d)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(t,o){this.updateWorldMatrix(!0,!1);let i=new Or().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),i.multiply(t.parent.matrixWorld)),"hiddenMatrix"in t&&t.hiddenMatrix instanceof Or?t.hiddenMatrix.premultiply(i):t.applyMatrix4(i),t.updateWorldMatrix(!1,!1),this.add(t),o!==void 0&&(this.children.pop(),this.children.splice(o,0,t)),this}copy(t,o=!1){return super.copy(t,o),this.hasNonUniformScale=t.hasNonUniformScale,this}onAfterRender(t,o,i,s,a,c){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}};var td=class extends Qn(pP){},fP=n=>n.type==="Mesh",Qr=class extends td{constructor(e){super();this.object=e;this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,t){}expand(){let e=0,t=this.object.entityChildren(e);for(;t;){let o=this.children[e];o?.object!==t&&(o&&this.remove(o),o=new Qr(t),this.add(o),this.children.splice(e,0,this.children.pop()),o.matrixWorldNeedsUpdate=!0,o.matrixAutoUpdate=!1,o.matrix=t.matrix,o.hiddenMatrix=t.hiddenMatrix),o.expand(),e+=1,t=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e])}get visible(){return this.playModeVisible!==void 0?this.playModeVisible:this.object.visible||this.object.dataPatched.visible&&this.object.dataPatched.cloner?.hideBase===!0}set visible(e){}get castShadow(){return this.object.castShadow}set castShadow(e){}get receiveShadow(){return this.object.receiveShadow}set receiveShadow(e){}get isMesh(){return fP(this.object)}get isLight(){return this.object.isLight}get layers(){return this.object.layers}set layers(e){}get isCamera(){return!1}get geometry(){if(this.object.geometry)return this.object.geometry}get material(){if(this.object.material)return this.object.material}};import{Box3 as eO,BufferGeometry as tO,MeshBasicMaterial as rO}from"three";import{Matrix4 as QT,Mesh as JT}from"three";import{Matrix4 as vl,Vector3 as vP,Euler as bP}from"three";import{Box3 as mP,Line3 as hP,Matrix4 as rd,Vector3 as Ft}from"three";var qo=new Ft,$o=new Ft,Jn=new rd,Ch=[new Ft(-1,1,1),new Ft(-1,-1,1),new Ft(1,-1,1),new Ft(1,1,1),new Ft(-1,1,-1),new Ft(-1,-1,-1),new Ft(1,-1,-1),new Ft(1,1,-1)],yP=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],gP=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],Ah=(n,r,e)=>{n.updateEntityBoxSize(qo,$o),Jn.copy(r).multiply(n.matrixWorld),$o.x===0&&$o.y===0&&$o.z===0?e.push(new Ft(qo.x,qo.y,qo.z).applyMatrix4(Jn)):Ch.forEach(t=>{e.push(t.clone().multiply($o).add(qo).applyMatrix4(Jn))})},ys=class extends mP{constructor(){super(...arguments);this.matrix=new rd;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 rd().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,o,t)}expandByObjectSize(e,t,o=!1){let i=[];return o===!0?e.traverseEntity(s=>{if(s.visible||s.cloner&&s.data.visible){if(!("geometry"in s)){i.push(new Ft);return}Ah(s,t,i)}}):Ah(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(Jn.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize($o).multiplyScalar(.5),this.getCenter(qo),Jn.copy(this.matrix).setPosition(qo),this.vertices=Ch.map(e=>e.clone().multiply($o).applyMatrix4(Jn))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=yP.map(([e,t])=>new hP(this.vertices[e],this.vertices[t])),this.centerEdges=this.edges.map(e=>e.getCenter(new Ft))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=gP.map(([e,t])=>this.vertices[e].clone().add(this.vertices[t]).multiplyScalar(.5))}};var rr={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}};import{CurvePath as xP,CubicBezierCurve3 as od,Vector3 as or}from"three";var id=class extends xP{constructor(){super()}getPoints(r=12){let e=[],t,o=this.getCurveLengths(),s=o[o.length-1]/o.length;for(let a=0,c=this.curves;a<c.length;a++){let u=c[a],l=a===0?o[a]:o[a]-o[a-1],d=Math.ceil(r*l/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 sd=.001;function ad(n,r,e){return r.clone().sub(n).cross(r.clone().sub(e)).length()<=sd}function nd(n,r){let e=new or(...n.position),t=new or(...n.controlNext.position),o=new or(...r.controlPrevious.position),i=new or(...r.position);return ad(e,t,i)&&ad(e,o,i)}function xl(n){let r=n.points.map(l=>new or(...l.data.position)),e=[n.points[0]],t=new or(...e[0].data.position);for(let l=0;l<n.points.length-1;l++)ad(t,r[l],r[l+1])||(e.push(n.points[l]),t=r[l]);e.push(n.points[n.points.length-1]);let o=n.isClosed,i=e.length-(o?0:1),s=e.length,a=[];for(let l=0;l<s;l++){let d=e[l].data,p=new or(...d.position),f=new or(...d.controlPrevious.position),m=new or(...d.controlNext.position),h={position:p,baseRoundness:d.roundness,controlPrevious:f,controlNext:m};if(d.roundness===0||!n.isClosed&&(l===0||l===s-1)){a[l]={...h,removedLength:0};continue}let y=o&&l==0?s-1:l-1,g=o&&l==s-1?0:l+1,x=e[y].data,b=e[g].data,w=new or(...x.position),S=new or(...b.position),P=w.clone().sub(p).normalize(),_=S.clone().sub(p).normalize();Object.assign(h,{prevDir:P,nextDir:_});let v=nd(x,d),N=nd(d,b);if(!v||!N)a[l]={...h,removedLength:0};else{let T=P.clone().add(_).normalize(),C=T.clone().cross(P).length()/P.dot(T);a[l]={...h,tan:C,removedLength:d.roundness/C}}}for(let l=0;l<i;l++){let d=l,p=o&&l===s-1?0:l+1,f=a[d],m=a[p];if(f.removedLength!==0||m.removedLength!==0){let h=f.position.distanceTo(m.position);f.removedLength=Math.min(f.removedLength,h/2),m.removedLength=Math.min(m.removedLength,h/2)}}let c=[];for(let l=0;l<i;l++){let d=l,p=o&&l===s-1?0:l+1,f=a[d],m=a[p],h=null;if(!nd(e[d].data,e[p].data))f.position.distanceTo(m.position)>sd&&(h=new od(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)>sd&&(h=new od(y,y.clone().lerp(g,.3),g.clone().lerp(y,.3),g))}c[2*l+1]=h}for(let l=0;l<s;l++){let d=a[l];if(d.removedLength===0){c[2*l]=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),x=f.distanceTo(m)/2,b=y.clone().multiplyScalar(Math.sqrt(Math.pow(h,2)-Math.pow(x,2))).add(g),w=y.clone().multiplyScalar(-h).add(b),S=p.distanceTo(w)/p.distanceTo(g),P=d.prevDir.clone().multiplyScalar(S*p.distanceTo(f)).add(p),_=P.clone().lerp(w,2),v=f.clone().lerp(P,4/3),N=m.clone().lerp(_,4/3);c[2*l]=new od(f,v,N,m)}let u=new id;return c.forEach(l=>{l&&u.add(l)}),u}var Se;(r=>{function n(e){return e&&e.__isEntity}r.is=n})(Se||(Se={}));var ei=n=>Se.is(n),SP={type:"completeState",isfromEntity:!0},ti=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 ys;this._recursiveBBox=new ys;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this._needApplyPathSnapping=!0;this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(t){let o=this.children[t];if(Se.is(o))return o}entityChildrenCount(){let t=this.children.length;for(;t--;)if(Se.is(this.children[t]))return t+1;return 0}get isConcreteEntity(){return typeof this.identity=="string"}get isVirtualEntity(){return typeof this.identity!="string"}get isInstanceRoot(){return this.isConcreteEntity&&this.data.type==="Instance"}nearestInstanceSelfOrParent(){let t=this;for(;t.data.type!=="Instance";){let o=t.parent;if(Se.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)Uo.toOps(this.data,s.data).forEach(c=>{let u=Ra.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=Uo.patch(this.data,s),Uo.toOps(this.data,s).forEach(c=>{this.updateByPatchedOp(c,this.dataPatched,o)}))}i&&this.updateTransformState(this.dataPatched),this.stateSelection=t,this.updatePathSnapping(this.dataPatched.pathSnapping)}}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges(),this._singleBBox.computeFaces()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges(),this._recursiveBBox.computeFaces()),this._recursiveBBox}updateEntityBoxSize(t,o){t.setScalar(0),o.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(t=>{ei(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(Se.is(o[i]))return o[i];if(Se.is(t))return t.traverseSortNextHelper()}}sortNext(){let t=this.children;return this.children.length>0&&Se.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)ei(o)&&t(o)}traverseEntityAncestors(t){this.traverseAncestors(o=>{Se.is(o)&&t(o)})}traverseConcreteEntity(t,o=0){if(t(this,o)!==!0)for(let s of this.children)ei(s)&&s.isConcreteEntity&&s.traverseEntity(t,o+1)}traverseEntity(t,o=0){if(t(this,o)!==!0)for(let s of this.children)ei(s)&&s.traverseEntity(t,o+1)}traverseVisibleEntity(t){t(this);for(let o of this.children)ei(o)&&o.visible&&o.traverseVisibleEntity(t)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}copy(t,o=!1){return super.copy(t,o),this.dataPatched=t.dataPatched,this.raycastLock=t.raycastLock,this.scaleLock=t.scaleLock,this.hiddenMatrix.copy(t.hiddenMatrix),this}hasEntityChild(){return this.children.some(t=>ei(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 Dn(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??go.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)Se.is(t)&&t.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(t=>{Se.is(t)&&t.disposeRecursively()})}toState(t=[]){let o={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(t)};return Dn(o,t)}updateByObjUpdateOp(t,o){this.updateByOp({type:0,props:t,path:[]},{...this.data,...t},o,!1)}updateByOp(t,o,i,s){let a=this.data;this.data=o;let c=t,u=yt(t.path,["states","*"]);if(u!==null){if(t.type===0){let[l]=u;if(this?.stateSelection===l){let d={...t.props};if(Object.values(t.props).some(p=>p===void 0)){let p=this.data;if(p!==void 0){let f=vt.zoom(p,t.path.slice(2));if(f)for(let m in t.props)t.props[m]===void 0&&m in f&&(d[m]=f[m])}}c={...t,props:d,path:t.path.slice(2)}}}}else if(t.type===0){let l=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(l!==void 0){if(t.props.name!==void 0&&l.name){let{name:p,...f}=l;l=f}if(t.props.material!==void 0&&"material"in l){let{material:p,...f}=l;l=f}let d=vt.removeOverridden(t.path,t.props,l);c={...t,props:d}}}if(this.updateByPatchedOpBase(c,Uo.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),i),yt(t.path,["overrides"])){let l=[],d=[...t.path];for(l.push(d[1]),d.splice(0,2);d.length>0&&d[0]==="descendants";)l.push(d[1]),d.splice(0,2);if(l[l.length-1]===void 0){if(t.type===0)for(let p of Object.keys(t.props)){l[l.length-1]=p;let f=i.scene.findInstance([this.uuid,...l]);f&&(f.overrideData=t.props[p],f.updateState(xr.apply(f.component.data,f.overrideData),i))}}else{let p=i.scene.findInstance([this.uuid,...l]);if(p){let f=vt.zoom(p.component.data,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=Yn.resolve(o.overrides,l),p.updateByOp(t,dt.applySimple(p.data,t),i,!1)}}}else if(this.instances.length>0){let l;if(t.path.length===0&&t.type===0){let d;for(let p of Kr.rootOverrideProps)p in t.props&&(d===void 0&&(d={}),d[p]=t.props[p]);d&&(l={...t,props:d})}else for(let d of Kr.rootOverrideProps)if(yt(t.path,[d])){l=t;break}l!==void 0&&this.instances.forEach(d=>{if(d.isInstanceRoot){let p=xr.filterOp(d.overrideData,l);p&&d.updateByOp(p,dt.applySimple(d.data,p),i,!0)}}),this.instances.forEach(d=>{if(!d.isInstanceRoot){let p=xr.filterOp(d.overrideData,t);if(p){let f;a===d.data&&t===p?f=o:f=dt.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&&!er.is(t.props.type)&&rr.changeEntityProptotype(this,o,i);else if(t.path.length===1&&t.path[0]==="geometry"&&t.type===0&&"type"in t.props){rr.changeEntityProptotype(this,o,i);for(let s of this.children)Se.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),yt(t.path,["pathSnapping"])!==null&&this.updatePathSnapping(o.pathSnapping),yt(t.path,["cloner"])!==null){let s=dt.drop(t,1);s.path.length===0&&s.type===0&&s.props.disabled===!0?this.setFromClonerState(null,i):this.cloner?this.cloner.updateState(o.cloner,i.scene):(this.setFromClonerState(o.cloner,i),this.expandCloner(i.scene)),this.updateVisible()}}updatePathSnapping(t){this._updatedPathSnapping=t,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(t){let o=this._updatedPathSnapping?.pathId??this.dataPatched.pathSnapping.pathId,i=this._updatedPathSnapping?.slide??this.dataPatched.pathSnapping.slide??0,s=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset,a=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(o===null)return;let c=t.find(o);if(!c||this._needApplyPathSnapping===!1)return;this._needApplyPathSnapping=!1;let u=c.data,l=xl(u.geometry.path),d=(i+s)%1;i+s===1&&d===0&&(d=1);let p=l.getPointAt(d),f=this.parent?this.parent?.matrixWorld:new vl;c.updateMatrixWorld();let m=new vl().multiplyMatrices(f.clone().invert(),c.matrixWorld);p.applyMatrix4(m);let h={position:p.toArray(),rotation:u.rotation};if(a==="tangential"){let y=new vl().extractRotation(c.matrixWorld),g=l.getTangentAt(d).applyMatrix4(y).add(p),x=new vl().lookAt(p,g,new vP(0,1,0)),b=new bP().setFromRotationMatrix(x);h={...h,rotation:[b.x,b.y,b.z]}}this.updateTransformState(h),this.traverseEntity(y=>{y._cameraType&&y.dispatchEvent(SP)})}updateVisible(){this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0)}updateState_Entity(t,o){t.name!==void 0&&(this.name=t.name),t.raycastLock!==void 0&&(this.raycastLock=t.raycastLock),t.visible!==void 0&&(this.updateVisible(),this.resetBBoxNeedsUpdate()),o&&"cloner"in t&&t.cloner!==void 0&&(this.setFromClonerState(t.cloner,o),this.updateVisible()),this.updateTransformState(t)}get attachedSurfaceCloners(){return this.children.filter(t=>t instanceof rr.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 rr.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)}};import{ConeGeometry as PP}from"three";import{BufferGeometry as wP,CylinderGeometry as _P,Float32BufferAttribute as ld,Vector2 as nr,Vector3 as bl}from"three";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:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},n.parameters),t=e.width/2,o=e.radiusTop??t,i=e.radiusBottom??t;return o===i?(o=t,i=t):o>i?(o=t,i=i*t/o):(o=o*t/i,i=t),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),radiusTop:o,radiusBottom:i})}}static build(n){let{width:r,depth:e,height:t,radialSegments:o,heightSegments:i,openEnded:s,thetaStart:a,thetaLength:c,radiusTop:u,radiusBottom:l,cornerRadius:d,cornerSegments:p,hollow:f}=n.parameters,m;return d||f?m=new gs(u,l,t,o,i,s,a,c*Math.PI/180,d,d,p,f):m=new _P(u,l,t,o,i,s,a,c*Math.PI/180),m.scale(1,1,e/r),Object.assign(m,{userData:{...n,type:"CylinderGeometry"}})}};function Po(n,r,e){e.x=n.x*r.x,e.y=n.y,e.z=n.x*r.y}function Nh(n){return new nr(n.y,-n.x)}var gs=class extends wP{constructor(r,e,t,o,i,s,a,c,u,l,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,a=a!==void 0?a:0,c=c!==void 0?c:Math.PI*2,s&&(u=0,l=0);let m=[],h=[],y=[],g=[],x=0,b=t/2,w=new bl,S=new bl;f&&r==0&&(r=u),f&&e==0&&(e=l);let P=new nr(r,b),_=new nr(e,-b),v=null,N=null,T=null,C=null,O=P.clone().sub(_),A=0,R=0,U=0;p>0&&(A=Math.min(r,e)*(1-p),R=r-A,U=e-A);let $=P.clone();$.x-=A;let ee=Math.PI-O.angle(),Y=O.angle(),q=Math.tan(Y/2),H=Math.tan(ee/2),V=q+H,G=p?V:H,D=p?V:q;if(u=Math.min(u,(r-R)/G,O.length()/V),l=Math.min(l,(e-U)/D,O.length()/V),u>0){let F=u/q;v=P.clone().sub(new nr(F,u)),p&&(T=v.clone(),T.x-=A-V*u),P.sub(O.clone().setLength(F))}if(l>0){let F=l/H;N=_.clone().sub(new nr(F,-l)),_.add(O.clone().setLength(F)),p&&(C=N.clone(),C.x-=A-V*l,$.sub(O.clone().setLength(F)))}O=P.clone().sub(_);let L=O.length()<.5,B=[];for(let F=0;F<=o;F++){let M=[],Q=F/o,re=Q*c+a,oe=new nr(Math.sin(re),Math.cos(re));C&&N?(X(M,Q,oe,ee,l,C,-1,!0),X(M,Q,oe,Y,l,N,-1,!1)):N?(W(M,oe,N.x,0,-1),X(M,Q,oe,Y,l,N,-1,!1)):s||W(M,oe,e,U,-1);let K=Nh(O).normalize();if(Po(K,oe,w),!L)for(let te=0;te<=i;te++){let J=te/i,ie=O.clone().multiplyScalar(J).add(_);Po(ie,oe,S),h.push(S.x,S.y,S.z),y.push(w.x,w.y,w.z),g.push(Q,.5+S.y/t),M.push(x++)}if(T&&v?(X(M,Q,oe,ee,u,v,1,!1),X(M,Q,oe,Y,u,T,1,!0)):v?(X(M,Q,oe,ee,u,v,1,!1),W(M,oe,v.x,0,1)):s||W(M,oe,r,R,1),p&&!L){let te=Nh(O).multiplyScalar(-1).normalize();Po(te,oe,w);for(let J=0;J<=i;J++){let ie=J/i,ce=O.clone().multiplyScalar(-ie).add($);Po(ce,oe,S),h.push(S.x,S.y,S.z),y.push(w.x,w.y,w.z),g.push(Q,.5+S.y/t),M.push(x++)}}p&&!s&&M.push(M[0]),B.push(M)}for(let F=0;F<B.length-1;F++)for(let M=0;M<B[0].length-1;M++){if(s&&p&&M==i)continue;let Q=B[F][M],re=B[F+1][M],oe=B[F+1][M+1],K=B[F][M+1],te=h[oe*3+0],J=h[oe*3+2];m.push(Q,re,K),(te!=0||J!=0)&&m.push(re,oe,K)}c<Math.PI*2&&(j(-1,B[0],a),j(1,B[B.length-1],a+c)),this.setIndex(m),this.setAttribute("position",new ld(h,3)),this.setAttribute("normal",new ld(y,3)),this.setAttribute("uv",new ld(g,2));function X(F,M,Q,re,oe,K,te,J){for(let ie=0;ie<d+1;ie++){let ce=ie/d,se=te<0?ce:1-ce;J&&(se-=1),se*=re;let fe=new nr(Math.sin(se),Math.cos(se)*te),ze=fe.clone().multiplyScalar(oe).add(K);Po(ze,Q,S),h.push(S.x,S.y,S.z),Po(fe,Q,w),y.push(w.x,w.y,w.z),g.push(M,.5+S.y/t),F.push(x++)}}function W(F,M,Q,re,oe){let K=new bl,te=new nr,J=[Q,re];oe<0&&J.reverse();for(let ie of J)te.set(ie,b*oe),Po(te,M,K),h.push(K.x,K.y,K.z),y.push(0,oe,0),g.push(.5,.5),F.push(x++)}function j(F,M,Q){let re=new nr(Math.sin(Q),Math.cos(Q)),oe=new nr(-Math.cos(Q),Math.sin(Q)),K=new bl,te=F<0?(ce,se,fe)=>m.push(ce,se,fe):(ce,se,fe)=>m.push(ce,fe,se),J=new nr((r+e+R+U)/4,0);Po(J,re,K),h.push(K.x,K.y,K.z),y.push(oe.x,0,oe.y),g.push(.5,.5);let ie=x++;for(let ce of M){let se=h.slice(ce*3,ce*3+3);h.push(...se),y.push(oe.x,0,oe.y);let fe=g.slice(ce*2,ce*2+2);g.push(...fe),x++}for(let ce=ie+1;ce<x-1;ce++)te(ie,ce,ce+1);te(ie,x-1,ie+1)}}};var Mh=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:8,cornerRadiusBottom:8,cornerSegments:8},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:r,depth:e,height:t,radialSegments:o,heightSegments:i,openEnded:s,thetaStart:a,thetaLength:c,cornerRadiusTop:u,cornerRadiusBottom:l,cornerSegments:d}=n.parameters,p;return u>0||l>0||c<360?p=new gs(0,r/2,t,o,i,s,a,c*Math.PI/180,u,l,d,0,!0):p=new PP(r/2,t,o,i,s),p.scale(1,1,e/r),Object.assign(p,{userData:{...n,type:"ConeGeometry"}})}};import{BoxGeometry as TP,BufferGeometry as OP,Float32BufferAttribute as cd,Vector3 as xs}from"three";var Eh=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:r,height:e,depth:t,widthSegments:o,heightSegments:i,depthSegments:s,cornerRadius:a,cornerSegments:c}=n.parameters,u;return a==0?u=new TP(r,e,t,o,i,s):u=new ud(r,e,t,o,i,s,a,c),Object.assign(u,{userData:{...n,type:"CubeGeometry"}})}},dd=Math.PI/2,ud=class extends OP{constructor(r=1,e=1,t=1,o=1,i=1,s=1,a=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),a=Math.min(a,r/2,e/2,t/2);let l=[],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),a>0&&(g("z","y","x",-1,-1,1,t,e,r,s,0),g("z","y","x",1,-1,-1,t,e,r,s,1),g("z","y","x",-1,1,-1,t,e,r,s,1),g("z","y","x",1,1,1,t,e,r,s,0),g("x","y","z",-1,-1,-1,r,e,t,o,0),g("x","y","z",1,-1,1,r,e,t,o,1),g("x","y","z",-1,1,1,r,e,t,o,0),g("x","y","z",1,1,-1,r,e,t,o,1),g("y","x","z",-1,-1,1,e,r,t,i,0),g("y","x","z",1,-1,-1,e,r,t,i,1),g("y","x","z",1,1,1,e,r,t,i,1),g("y","x","z",-1,1,-1,e,r,t,i,0),x(1,1,1),x(-1,1,1),x(1,-1,1),x(-1,-1,1),x(1,1,-1),x(-1,1,-1),x(1,-1,-1),x(-1,-1,-1)),this.setIndex(l),this.setAttribute("position",new cd(d,3)),this.setAttribute("normal",new cd(p,3)),this.setAttribute("uv",new cd(f,2));function y(b,w,S,P,_,v,N,T,C,O,A){let R=(v-2*a)/C,U=(N-2*a)/O,$=v/2-a,ee=N/2-a,Y=T/2,q=C+1,H=O+1,V=0,G=0,D=new xs;for(let L=0;L<H;L++){let B=L*U-ee;for(let X=0;X<q;X++){let W=X*R-$;D[b]=W*P,D[w]=B*_,D[S]=Y,d.push(D.x,D.y,D.z),D[b]=0,D[w]=0,D[S]=T>0?1:-1,p.push(D.x,D.y,D.z),f.push(X/C),f.push(1-L/O),V+=1}}for(let L=0;L<O;L++)for(let B=0;B<C;B++){let X=m+B+q*L,W=m+B+q*(L+1),j=m+(B+1)+q*(L+1),F=m+(B+1)+q*L;l.push(X,W,F),l.push(W,j,F),G+=6}u.addGroup(h,G,A),h+=G,m+=V}function g(b,w,S,P,_,v,N,T,C,O,A){let R=(N-2*a)/O,U=N/2-a,$=T/2-a,ee=C/2,Y=O+1,q=0,H=0,V=new xs,G=new xs;for(let D=0;D<c+1;D++){let L=D/c*dd,B=Math.sin(L)*a,X=(1-Math.cos(L))*a,W=Math.sin(L),j=Math.cos(L);V[w]=($+B)*_,V[S]=(ee-X)*v,G[b]=0,G[w]=W*Math.sign(V[w]),G[S]=j*Math.sign(V[S]);for(let F=0;F<Y;F++){let M=F*R-U;V[b]=M*P,d.push(V.x,V.y,V.z),p.push(G.x,G.y,G.z),f.push(F/O),f.push(0),q+=1}}for(let D=0;D<c;D++)for(let L=0;L<O;L++){let B=m+L+Y*D,X=m+L+Y*(D+1),W=m+(L+1)+Y*(D+1),j=m+(L+1)+Y*D;l.push(B,X,j),l.push(X,W,j),H+=6}u.addGroup(h,H,A),h+=H,m+=q}function x(b,w,S){let P=new xs,_=new xs(r/2,e/2,t/2);_.subScalar(a);let v=[],N=b*w*S>0?(C,O,A)=>l.push(C,O,A):(C,O,A)=>l.push(C,A,O);for(let C=0;C<=c;C++){let O=[],A=dd*(1-C/c),R=Math.cos(A),U=Math.sin(A),$=0;for(let ee=0;ee<=C;ee++){let Y=Math.cos($),q=Math.sin($);P.x=R*Y,P.y=U,P.z=R*q;let H=_.clone().addScaledVector(P,a);d.push(b*H.x,w*H.y,S*H.z),p.push(b*P.x,w*P.y,S*P.z),f.push(0,0),O.push(m++),$+=dd/C}v.push(O)}let T=v.length-1;for(let C=0;C<T;C++){let O=v[C],A=v[C+1],R=O.length-1;N(O[0],A[1],A[0]);for(let U=1;U<=R;U++)N(O[U-1],O[U],A[U]),N(O[U],A[U+1],A[U])}}}};import{BufferGeometry as AP,Float32BufferAttribute as pd,Triangle as CP,Vector3 as Jr,Vector2 as fd}from"three";var To=class extends AP{constructor(r=[],e=[],t="",o=1,i=.2,s=4){super(),this.type="PolyhedronGeometryRound";let a=[],c=[],u=[];l(),d(),this.setAttribute("position",new pd(a,3)),this.setAttribute("normal",new pd(u,3)),this.setAttribute("uv",new pd(c,2));return;function l(){i=Math.min(1-1e-5,i),i==0&&(s=0);let f={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[t],m=new Jr,h=m.clone(),y=new CP,g=i*o,x=o-g,b=s+1,w=new Jr,S=(q,H)=>w.subVectors(q,H).normalize(),P=(q,H)=>Array(q).fill(void 0).map(H),_=P(r.length/3,(q,H)=>new Jr().fromArray(r,H*3).setLength(o)),v=[],N=1e6;for(let q=0;q<_.length;q++){let H=_[q],V=[],G,D,L,B=1e10,X=-1;for(;(X=e.indexOf(q,X+1))!=-1;){let M=X-X%3;G=e[M+(X+1)%3],D=e[M+(X+2)%3],L=H.distanceToSquared(_[G]),B=Math.min(B,L),V.push([G,D,L])}B+=1e-6;let W=[],j=0,F=V.length;for(let M=0;M<F;M++){[G,D,L]=V[j];let Q=v[G]?.includes(q)==!0;L<=B&&W.push(G+ +Q*N),j=V.findIndex(re=>re[0]==D)}v.push(W)}let T=[];{let q=0,H=0,V,G,D=f==3;for(let L=0;L<=s;L++){V=L*(L+1)/2,G=(L+1)*(L+2)/2;for(let B=0;B<s-L;B++)[q,H]=[V+B+L+2,G+B+L+3],T.push(V,G,...D?[H,V]:[q,G],H,q),[V,G]=[q,H];T.push(V,G,V+s+2)}}let C=m.clone(),O=m.clone(),A=m.clone(),R=m.clone(),U=m.clone(),$=[],ee=P(_.length,()=>P(f,()=>m.clone()));for(let q=0;q<_.length;q++){m.copy(_[q]).normalize(),C.copy(m).multiplyScalar(x);let H=v[q];for(let W=0;W<H.length;W++){let j=H[W],F=H[(W+1)%f];y.setFromPointsAndIndices(_,q,j%N,F%N),y.b.sub(y.a).setLength(1e10).add(y.a),y.c.sub(y.a).setLength(1e10).add(y.a),y.closestPointToPoint(C,ee[q][W])}let V=[],G=[],D=[],L=new Jr;s==0&&[...ee[q]].reduce((W,j)=>W.add(j),L).multiplyScalar(1/f);for(let W=0;W<f;W++){let j=[],F=(W-1+f)%f,M=ee[q][F],Q=ee[q][W];m.copy(M).sub(C),h.copy(Q).sub(C);let re=C.angleTo(m),oe=m.angleTo(h),K=Math.cos(re)*g;s==0?O.copy(L):O.copy(C).setLength(x+K),G.push(K);let te=[O,M,Q];for(let J=0;J<2;J++){let ie=te[J],ce=te[J+1];R.subVectors(ie,C),U.subVectors(ce,C),A.crossVectors(R,U).normalize();for(let se=0;se<b;se++){let fe=[re,oe][J]*se/b;m.copy(R).applyAxisAngle(A,fe).add(C),V.push(m.clone()),J&&(S(m,C),j.push([se==0?ie:m.clone(),w.clone()]))}J&&(S(ce,C),j.push([ce,w.clone()]))}D.push(j)}$.push(D);let B=2*b,X=2;for(let W=0;W<f;W++){let j=B*W,F=B*((W+1)%f),M=[V[j]];for(let re=1;re<b;re++){R=V[j+re],U=V[F+re],M.push(R);for(let oe=1,K=re-X+1;oe<=K;oe++)m.lerpVectors(R,U,oe/(K+1)),m.sub(C).setLength(G[W]).add(C),M.push(m.clone());M.push(U)}for(let re=0;re<b;re++)M.push(V[re+b+j]);M.push(V[F+b]);let Q=T.map(re=>M[re]);a.push(...Q.map(re=>[re.x,re.y,re.z]).flat()),u.push(...Q.map(re=>(S(re,C),[w.x,w.y,w.z])).flat())}}let Y=[];for(let q=0;q<v.length;q++)for(let H=0;H<f;H++){let V=v[q][H];if(V<N){let G=v[V].findIndex(B=>B%N==q),D=$[q][H],L=$[V][G];for(let B=0;B<b;B++){let X=D[B],W=L[b-B],j=D[B+1],F=L[b-(B+1)];[X,W,j,j,W,F].forEach(M=>{a.push(M[0].x,M[0].y,M[0].z),u.push(M[1].x,M[1].y,M[1].z)})}Y.push(D[0][0],L[b][0],D[b][0],L[0][0])}}for(;Y.length;){let q,H,V,G;[q,H]=Y.splice(0,2);let D=[q];for(;q!=H;)D.push(H),V=Y.indexOf(H),G=V%2,H=Y.splice(V-G,2)[1-G];w.subVectors(D[0],D[1]).cross(m.subVectors(D[0],D[2])).normalize();let L=w.dot(D[0])<0;L&&w.negate();for(let B=1;B<=D.length-2;B++)[D[B+ +L],D[B+1-+L],D[0]].forEach(X=>{a.push(X.x,X.y,X.z),u.push(w.x,w.y,w.z)})}}function d(){let p=new Jr;for(let _=0;_<a.length;_+=3){p.x=a[_+0],p.y=a[_+1],p.z=a[_+2];let v=S(p)/2/Math.PI+.5,N=P(p)/Math.PI+.5;c.push(v,1-N)}let f=new Jr,m=new Jr,h=new Jr,y=new Jr,g=new fd,x=new fd,b=new fd,w=(_,v,N,T)=>{T<0&&_.x===1&&(c[v]=_.x-1),N.x===0&&N.z===0&&(c[v]=T/2/Math.PI+.5)};for(let _=0,v=0;_<a.length;_+=9,v+=6){f.set(a[_+0],a[_+1],a[_+2]),m.set(a[_+3],a[_+4],a[_+5]),h.set(a[_+6],a[_+7],a[_+8]),g.set(c[v+0],c[v+1]),x.set(c[v+2],c[v+3]),b.set(c[v+4],c[v+5]),y.copy(f).add(m).add(h).divideScalar(3);let N=S(y);w(g,v+0,f,N),w(x,v+2,m,N),w(b,v+4,h,N)}for(let _=0;_<c.length;_+=6){let v=c[_+0],N=c[_+2],T=c[_+4],C=Math.max(v,N,T),O=Math.min(v,N,T);C>.9&&O<.1&&(v<.2&&(c[_+0]+=1),N<.2&&(c[_+2]+=1),T<.2&&(c[_+4]+=1))}function S(_){return Math.atan2(_.z,-_.x)}function P(_){return Math.atan2(-_.y,Math.sqrt(_.x*_.x+_.z*_.z))}}}static fromJSON(r){return new To(r.vertices,r.indices,r.radius,r.corner,r.cornerSides)}};import{DodecahedronGeometry as NP}from"three";var Lh=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,detail:0,corner:0,cornerSides:4},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:r,height:e,depth:t,detail:o,corner:i,cornerSides:s}=n.parameters,a=o===0&&i!==0?new vs(r*.5,i,s):new NP(r*.5,o);return a.scale(1,e/r,t/r),Object.assign(a,{userData:{...n,type:"DodecahedronGeometry"}})}},vs=class extends To{constructor(r=1,e=.2,t=4){let o=(1+Math.sqrt(5))/2,i=1/o,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-i,-o,0,-i,o,0,i,-o,0,i,o,-i,-o,0,-i,o,0,i,-o,0,i,o,0,-o,0,-i,o,0,-i,-o,0,i,o,0,i],a=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],c="DodecahedronGeometry";super(s,a,c,r,e,t),this.type=c}static fromJSON(r){return new vs(r.radius,r.corner,r.cornerSides)}};import{Plane as jP,Shape as Yh,Vector2 as eo,Vector3 as FP,MathUtils as bd,LineCurve as Sd,QuadraticBezierCurve as Xh,CubicBezierCurve as Pl}from"three";import{CubicBezierCurve as Sl,EllipseCurve as IP,LineCurve as wl,LineCurve3 as MP,MathUtils as EP,QuadraticBezierCurve as hd,SplineCurve as LP,Vector2 as xt,Vector3 as Rh}from"three";var bs=1e-12,ri=class{constructor(r){this.position=new xt;this.startPosition=new xt;this.uuid=EP.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 ri(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},oi=class extends ri{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new oi(this.parent).copy(this)}},ir=class extends ri{constructor(e,t){super(t);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new oi(this),new oi(this))}static create(e,t){let o=new ir(e,new xt(...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 ir(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 xt,t=new xt){let[o,i]=this.computeTangents();return o&&i&&(Dh(o,e),Dh(i,t)),[e,t]}computeTangent(e=new xt){let[t,o]=this.computeTangents();return t&&o&&e.copy(t).add(o).normalize(),e}computeNormal(e=new xt){let[t,o]=this.computeNormals();return e.copy(t).add(o).normalize(),e}};function Dh(n,r=new xt){let e=n.length();return r.set(-n.y/e,n.x/e)}var yd=n=>n,ni=new xt,_l=new xt,DP=new xt,BP=new xt,RP=new xt,GP=new xt,Gh=new Rh,Vh=new Rh;function zh(n){let r=new xt;r.addVectors(n.v0,ni.subVectors(n.v1,n.v0).multiplyScalar(2/3));let e=new xt;return e.addVectors(n.v2,_l.subVectors(n.v1,n.v2).multiplyScalar(2/3)),new Sl(n.v0,r,e,n.v2)}function Ss(n,r,e=Number.EPSILON){return Math.abs(n-r)<e}function VP(n,r,e=Number.EPSILON){return n.distanceTo(r)<e}function zP(n,r,e=Number.EPSILON){return n.distanceTo(r)<e}function gd(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 jh(n,r,e){return Bh(n,r)&&Bh(r,e)&&md(n.position,r.position,e.position)}function md(n,r,e){return ni.copy(r).sub(n).cross(_l.copy(e).sub(n))===0}function Fh(n,r,e,t,o){let i=Math.sqrt(Math.pow(r.x-n.x,2)+Math.pow(r.y-n.y,2)),s=(n.y+r.y)/2,a=(n.x+r.x)/2,c=Math.sqrt(Math.pow(e,2)-Math.pow(i/2,2))*(n.y-r.y)/i,u=Math.sqrt(Math.pow(e,2)-Math.pow(i/2,2))*(r.x-n.x)/i;return t.set(a+c,s+u),o.set(a-c,s-u),[t,o]}function kh(n,r,e){let t=n.distanceTo(e),o=r.distanceTo(e);return t<o?r:n}function Uh(n,r,e,t,o,i){let s=r.x-n.x,a=r.y-n.y,c=e.x-n.x,u=e.y-n.y,l=Math.sqrt((s+c)*(s+c)+(a+u)*(a+u)),d;return gd(r,n,e)>Math.PI&&(l*=-1),Ss(u,a)?d=(a+u)*(t/l-.5)*8/3/(s-c):d=(s+c)*(t/l-.5)*8/3/(u-a),o.set(r.x-d*a,r.y+d*s),i.set(e.x+d*u,e.y-d*c),[o,i]}function xd(n,r){return n.position.equals(n.controls[1].position)&&r.position.equals(r.controls[0].position)}function Bh(n,r){return md(n.position,n.controls[1].position,r.position)&&md(n.position,r.controls[0].position,r.position)}function Hh(n,r,e,t,o=.5){let i=ni.subVectors(r,n).multiplyScalar(o).add(n),s=_l.subVectors(e,r).multiplyScalar(o).add(r),a=DP.subVectors(t,e).multiplyScalar(o).add(e),c=i,u=BP.subVectors(s,i).multiplyScalar(o).add(i),l=RP.subVectors(a,s).multiplyScalar(o).add(s),d=a,p=GP.subVectors(l,u).multiplyScalar(o).add(u);return[n.x,n.y,c.x,c.y,u.x,u.y,p.x,p.y,l.x,l.y,d.x,d.y,t.x,t.y]}function Wh(n,r,e=12,t=!0){let o=Vh.set(0,0,0),i,s=0,a=[];for(let c=0;c<r.length;c++){let u=yd(r[c]),l=ni,d=Oo(u,e);a.push(d);for(let p=0;p<=d;p++)if(u instanceof Sl||u instanceof hd||u instanceof wl){if(u.getPoint(p/d,l),o.set(l.x,l.y,0),i!==void 0&&zP(i,o))continue;i===void 0&&(i=Gh),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 qh(n,r,e,t=12,o=!0){let i=Vh.set(0,0,0),s=0,a=[];for(let c=0;c<r.length;c++){if(e[c]===!1)continue;let u,l=yd(r[c]),d=ni,p=Oo(l,t);a.push(p);for(let f=0;f<=p;f++)if(l instanceof Sl||l instanceof hd||l instanceof wl){if(l.getPoint(f/p,d),i.set(d.x,d.y,0),u?.equals(i))continue;u===void 0?u=Gh:(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++),a}function vd(n,r=12,e=!1){let t=[];for(let o=0,i=n.length;o<i;o++){let s=n[o],a=0;if(e&&s.roundedCurveCorner!==void 0){let c=Oo(s.roundedCurveCorner,r)*.5;o>0&&(t[o-1]+=c),a+=c}s.curveAfter!==void 0&&(a+=Oo(s.curveAfter,r)),t.push(a)}return n.length>0&&e&&n[0].roundedCurveCorner!==void 0&&(t[n.length-1]+=Oo(n[0].roundedCurveCorner,r)*.5),t}function Oo(n,r=12){return n&&n instanceof IP?r*2:n&&(n instanceof wl||n instanceof MP)?1:n&&n instanceof LP?r*n.points.length:r}function $h(n,r,e=12,t=!0){let o,i=0;for(let s=0;s<r.length;s++){let a=yd(r[s]),c=Oo(a,e),u=ni;for(let l=0;l<=c;l++)if(a instanceof Sl||a instanceof hd||a instanceof wl){if(a.getPoint(l/c,u),o!==void 0&&VP(o,u,bs))continue;o===void 0&&(o=_l),o.copy(u),n.push(u.x,u.y),i++}}return Ss(n[0],n[n.length-2],bs)&&Ss(n[1],n[n.length-1],bs)&&(n.pop(),n.pop()),t&&i>1&&!(Ss(n[i-1],n[1],bs)&&Ss(n[i-2],n[0],bs))&&(n.push(n[0],n[1]),i++),n}var wd=new eo,kP=new eo,UP=new eo,HP=new eo,WP=new eo,qP=new eo,_e=class extends Yh{constructor(e=100,t=100){super();this.points=[];this.shapeHoles=[];this.plane=new jP(new FP(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=bd.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=t}static createFromState(e,t,o){let i=new _e;return i.isClosed=e.isClosed,i.points=e.points.map(s=>ir.create(s.id,s.data)),typeof e.roundness=="number"&&(i.roundness=e.roundness),i.shapeHoles=e.shapeHoles.map(s=>_e.createFromState(s)),t!==void 0&&o!==void 0&&i.applySize(t,o),i.update(),i}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(e){if(this._roundness!==e){this._roundness=e;for(let t=0,o=this.points.length;t<o;t++)this.points[t].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(t=>this.getPointIndexById(t)).filter(t=>t>=0)}getPointIndexById(e){let t=this.points.length,o=this.points.findIndex(i=>i.uuid===e);if(o<0){let i=t;for(let s=0,a=this.shapeHoles.length;s<a;s++){let c=this.shapeHoles[s],u=c.points.length,l=c.getPointIndexById(e);if(l<0)i+=u;else return l+i}}return o}getLineIndexById(e){return this.getPointIndexById(e)}getBezierPoint(e){if(e<=this.points.length-1)return this.points[e];if(this.shapeHoles.length>0){let t=this.points.length;for(let o=0,i=this.shapeHoles.length;o<i;o++){let s=this.shapeHoles[o],a=e-t;if(a<=s.points.length-1)return s.points[a];t+=s.points.length}}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let t=this.points.indexOf(e);if(t>=0)return t;if(t=this.points.length,this.shapeHoles.length>0)for(let o=0,i=this.shapeHoles.length;o<i;o++){let s=this.shapeHoles[o],a=s.points.indexOf(e);if(a>=0)return t+a;t+=s.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(t=>t.points));return[...this.points,...e]}applySize(e,t){e===0&&(e=.001),t===0&&(t=.001),this._width=e,this._height=t}applyScale(e,t){let o=wd.set(e,t);for(let i=0,s=this.points.length;i<s;i++){let a=this.points[i];a.position.multiply(o),a.controls[0].position.multiply(o),a.controls[1].position.multiply(o)}for(let i=0,s=this.shapeHoles.length;i<s;i++)this.shapeHoles[i].applyScale(e,t);this._update()}createPoint(e,t=0,o=bd.generateUUID()){let i;e instanceof eo?i=e:i=new eo(e,t);let s=new ir(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 Wh(e,o?this.roundedCurves:this.curves,t,this.autoClose),i.reduce((s,a)=>s+a,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=vd(this.points,e,!1),this.roundedCurveDivisions=vd(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,t,o=12){return qh(e,this.curves,t,o,this.autoClose).reduce((s,a)=>s+a,0)*2}extractShapePointsToFlatArray(e,t=12){return this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t),$h(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=Oo(this.points[0].roundedCurveCorner,this.subdivision)*.5);let a=e-s;a<0&&(a+=i.reduce((c,u)=>c+u,0));for(let c=0,u=i.length;c<u;c++){let l=i[c];if(a<o+l)return[c,(a-o+1)/l];o+=l}return[0,1]}getCurveT(e,t,o){let i=this.points[e],s=this.points[e>=this.points.length-1?0:e+1],a=this.curveDivisions,c=a[e];if(xd(i,s)){let d=i.position.distanceTo(s.position);return i.position.distanceTo(wd.set(o.x,o.y))/d}let u=0;for(let d=0;d<e;d++)u+=a[d];return(t-u)/c}dispose(){}_applyCurveForPoint(e,t){xd(t,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(t.controls[1].position.x,t.controls[1].position.y,e.controls[0].position.x,e.controls[0].position.y,e.position.x,e.position.y);let o=this.curves[this.curves.length-1];e.curveBefore=o,t.curveAfter=o;let i=o.clone();e.roundedCurveBefore=i,t.roundedCurveAfter=i,e.roundedCurveCorner=void 0,this.roundedCurves.push(i)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let t=0,o=this.points.length;t<o;t++){let i=this.points[t];if(t===0)this.moveTo(i.position.x,i.position.y);else{let s=this.points[t-1];this._applyCurveForPoint(i,s)}}let e=this.getLastPoint();if(e?.curveAfter&&(e.curveAfter=void 0),this.isClosed){let t=this.points[0],o=this.points[this.points.length-1];this._applyCurveForPoint(t,o)}if(this.points.length>2){let t=0;for(let o=0,i=this.points.length;o<i;o++){let s=this.points[o],a=this.points[o-1]??this.points[this.points.length-1],c=this.points[o+1]??this.points[0],u=s.roundness,l=a&&c&&jh(a,s,c);if(!s.controlsMoved()&&u>0&&!l){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),x=Math.min(u,y*.499),b=Math.min(g,x),w=1-b/h,S=b/y,P=d.getPointAt(w,wd),_=p.getPointAt(S,kP);this._subSplitCurve(d,f,w,P,void 0),this._subSplitCurve(p,m,S,void 0,_);let v;if(this.useCubicForRoundedCorners){let N=gd(P,s.position,_)/2,T=Math.tan(N)*P.distanceTo(s.position),[C,O]=Fh(P,_,T,UP,HP),A=kh(C,O,s.position),[R,U]=Uh(A,P,_,T,WP,qP);v=new Pl(P.clone(),R.clone(),U.clone(),_.clone())}else v=new Xh(P.clone(),s.position.clone(),_.clone());s.roundedCurveCorner=v,this.roundedCurves.splice(o+t,0,v),t++}}}}_subSplitCurve(e,t,o,i,s){if(e instanceof Sd)i!==void 0&&t.v2.copy(i),s!==void 0&&t.v1.copy(s);else{let a=e,c=t,u=a.getUtoTmapping(o,0),l=Hh(a.v0,a.v1,a.v2,a.v3,u);return i!==void 0&&(c.v0.set(l[0],l[1]),c.v1.set(l[2],l[3]),c.v2.set(l[4],l[5]),c.v3.set(l[6],l[7])),s!==void 0&&(c.v0.set(l[6],l[7]),c.v1.set(l[8],l[9]),c.v2.set(l[10],l[11]),c.v3.set(l[12],l[13])),c}return t}clone(){let e=new _e(this._width,this._height);return e.points=this.points.map(t=>t.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(t=>t.clone()),e}toJSON(){return{points:this.points.reduce((e,t)=>e.concat(t.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){this.points=[],this.pointIDs=0;let t=e.points.length/7;for(let o=0;o<t;o++){let i=o*7,s=e.points[i+0],a=e.points[i+1],c=e.points[i+2],u=e.points[i+3],l=e.points[i+4],d=e.points[i+5],p=e.points[i+6],f=new ir(bd.generateUUID(),new eo(s,a));f.controls[0].position.set(c,u),f.controls[1].position.set(l,d),f.roundness=p,this.points.push(f)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(o=>{let i=new _e;return i.fromJSON(o),i}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e){let t=(i,s)=>{s instanceof Pl&&s.v3.equals(i.position)&&i.controls[0].position.copy(s.v2)},o=i=>{let s=[],a,c;for(a=0,c=i.length;a<c;a++)i[a]instanceof Xh&&(i[a]=zh(i[a]));for(a=0,c=i.length;a<c;a++){let d=i[a],p=a>0?i[a-1]:null,f;d instanceof Pl?(f=this.createPoint(d.v0),f.controls[1].position.copy(d.v1)):d instanceof Sd&&(f=this.createPoint(d.v1)),f!==void 0&&(p!==null&&t(f,p),s.push(f))}let u=i[i.length-1],l=!1;return u instanceof Pl?u.v3.equals(s[0].position)&&(s[0].controls[0].position.copy(u.v2),l=!0):u instanceof Sd&&u.v2.equals(s[0].position)&&(l=!0),this.isClosed=l,s};return this.points=o(e.curves),e instanceof Yh&&(this.shapeHoles=e.holes.map(i=>{let s=new _e;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 Pd=Math.PI*2;function _d({x:n,y:r},e,t,o,i){return{x:n*e+o,y:r*t+i}}function $P(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 Kh(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 YP(n,r,e,t,o,i,s,a,c,u){let l=Math.pow(o,2),d=Math.pow(i,2),p=Math.pow(s,2),f=Math.pow(a,2),m=l*d-l*f-d*p;m<0&&(m=0),m/=l*f+d*p,m=Math.sqrt(m)*(c===u?-1:1);let h=m*o/i*a,y=m*-i/o*s,g=h+(n+e)/2,x=y+(r+t)/2,b=(s-h)/o,w=(a-y)/i,S=(-s-h)/o,P=(-a-y)/i,_=Kh(1,0,b,w),v=Kh(b,w,S,P);return!u&&v>0&&(v-=Pd),u&&v<0&&(v+=Pd),{centerx:g,centery:x,ang1:_,ang2:v}}function Zh({px:n,py:r,cx:e,cy:t,rx:o,ry:i,largeArcFlag:s,sweepFlag:a}){let c=[];if(o===0||i===0)return[];let u=(n-e)/2,l=(r-t)/2;if(u===0&&l===0)return[];o=Math.abs(o),i=Math.abs(i);let d=Math.pow(u,2)/Math.pow(o,2)+Math.pow(l,2)/Math.pow(i,2);d>1&&(o*=Math.sqrt(d),i*=Math.sqrt(d));let p=YP(n,r,e,t,o,i,u,l,s,a),{ang1:f,ang2:m}=p,{centerx:h,centery:y}=p,g=Math.abs(m)/(Pd/4);Math.abs(1-g)<1e-7&&(g=1);let x=Math.max(Math.ceil(g),1);m/=x;for(let b=0;b<x;b++)c.push($P(f,m)),f+=m;return c.map(b=>{let{x:w,y:S}=_d(b[0],o,i,h,y),{x:P,y:_}=_d(b[1],o,i,h,y),{x:v,y:N}=_d(b[2],o,i,h,y);return{x1:w,y1:S,x2:P,y2:_,x:v,y:N}})}import{BufferAttribute as Cl,BufferGeometry as eT}from"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 Ge;(function(n){n[n.POLYGONS=0]="POLYGONS",n[n.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",n[n.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(Ge||(Ge={}));function ue(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){ue(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){ue(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){ue(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){ue(n.transLeq(r,e)&&n.transLeq(e,t));var o=e.t-r.t,i=t.t-e.t;return o+i>0?(e.s-t.s)*o+(e.s-r.s)*i:0},n.vertCCW=function(r,e,t){return r.s*(e.t-t.t)+e.s*(t.t-r.t)+t.s*(r.t-e.t)>=0},n.interpolate=function(r,e,t,o){return r=r<0?0:r,t=t<0?0:t,r<=t?t===0?(e+o)/2:e+(o-e)*(r/(r+t)):o+(e-o)*(t/(r+t))},n.intersect=function(r,e,t,o,i){var s,a,c;n.vertLeq(r,e)||(c=r,r=e,e=c),n.vertLeq(t,o)||(c=t,t=o,o=c),n.vertLeq(r,t)||(c=r,r=t,t=c,c=e,e=o,o=c),n.vertLeq(t,e)?n.vertLeq(e,o)?(s=n.edgeEval(r,t,e),a=n.edgeEval(t,e,o),s+a<0&&(s=-s,a=-a),i.s=n.interpolate(s,t.s,a,e.s)):(s=n.edgeSign(r,t,e),a=-n.edgeSign(r,o,e),s+a<0&&(s=-s,a=-a),i.s=n.interpolate(s,t.s,a,o.s)):i.s=(t.s+e.s)/2,n.transLeq(r,e)||(c=r,r=e,e=c),n.transLeq(t,o)||(c=t,t=o,o=c),n.transLeq(r,t)||(c=r,r=t,t=c,c=e,e=o,o=c),n.transLeq(t,e)?n.transLeq(e,o)?(s=n.transEval(r,t,e),a=n.transEval(t,e,o),s+a<0&&(s=-s,a=-a),i.t=n.interpolate(s,t.t,a,e.t)):(s=n.transSign(r,t,e),a=-n.transSign(r,o,e),s+a<0&&(s=-s,a=-a),i.t=n.interpolate(s,t.t,a,o.t)):i.t=(t.t+e.t)/2},n}(),ws=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}(),Tl=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}(),ii=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}(),Qh=function(){function n(){var r=new ii,e=new ws,t=new Tl(0),o=new Tl(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 Tl(0),t=new Tl(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;ue(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;ue(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 ii,e=new ii,t=new ws,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 ii;this.makeVertex_(i,e,r.Org),r.Org.anEdge=r}if(!t){var s=new ws;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 ws;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 ii;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 ws;this.makeFace_(s,o,r.Lface)}return o},n.prototype.zapFace=function(r){var e=r.anEdge,t,o,i,s,a;o=e.Lnext;do t=o,o=t.Lnext,t.Lface=null,t.Rface===null&&(t.Onext===t?this.killVertex_(t.Org,null):(t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev)),i=t.Sym,i.Onext===i?this.killVertex_(i.Org,null):(i.Org.anEdge=i.Onext,this.splice_(i,i.Oprev)),this.killEdge_(t));while(t!=e);s=r.prev,a=r.next,a.prev=s,s.next=a},n.prototype.countFaceVerts_=function(r){var e=r.anEdge,t=0;do t++,e=e.Lnext;while(e!==r.anEdge);return t},n.prototype.mergeConvexFaces=function(r){var e,t,o,i,s,a,c;for(e=this.fHead.next;e!==this.fHead;e=e.next)if(!!e.inside)for(t=e.anEdge,s=t.Org;o=t.Lnext,i=t.Sym,i&&i.Lface&&i.Lface.inside&&(a=this.countFaceVerts_(e),c=this.countFaceVerts_(i.Lface),a+c-2<=r&&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,a,c,u;for(i=r,i=r;(o=i.next)!==r;i=o){ue(o.prev===i),c=o.anEdge;do ue(c.Sym!==c),ue(c.Sym.Sym===c),ue(c.Lnext.Onext.Sym===c),ue(c.Onext.Sym.Lnext===c),ue(c.Lface===o),c=c.Lnext;while(c!==o.anEdge)}for(ue(o.prev===i&&o.anEdge===null),a=e,a=e;(s=a.next)!==e;a=s){ue(s.prev===a),c=s.anEdge;do ue(c.Sym!==c),ue(c.Sym.Sym===c),ue(c.Lnext.Onext.Sym===c),ue(c.Onext.Sym.Lnext===c),ue(c.Org===s),c=c.Onext;while(c!==s.anEdge)}for(ue(s.prev===a&&s.anEdge===null),u=t,u=t;(c=u.next)!==t;u=c)ue(c.Sym.next===u.Sym),ue(c.Sym!==c),ue(c.Sym.Sym===c),ue(c.Org!==null),ue(c.Dst!==null),ue(c.Lnext.Onext.Sym===c),ue(c.Onext.Sym.Lnext===c);ue(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}(),Jh=function(){function n(){this.handle=null}return n}(),ey=function(){function n(){this.key=null,this.node=0}return n}(),XP=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 Jh,this.handles[t]=new ey;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,ue(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 Jh;for(i=this.handles.length,this.handles.length=this.max+1,o=i;o<this.handles.length;o++)this.handles[o]=new ey}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;ue(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}(),Td=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}(),ty=function(){function n(){this.key=null,this.next=null,this.prev=null}return n}(),KP=function(){function n(r,e){this.frame=r,this.leq=e,this.head=new ty,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 ty;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}(),ZP=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 a=le.edgeEval(i.Dst,o,i.Org),c=le.edgeEval(s.Dst,o,s.Org);return a>=c},n.deleteRegion=function(r,e){e.fixUpperEdge&&ue(e.eUp.winding===0),e.eUp.activeRegion=null,r.dict.delete(e.nodeUp)},n.fixUpperEdge=function(r,e,t){ue(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 Td;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,a=e.eUp;s!==t;){if(s.fixUpperEdge=!1,i=n.regionBelow(s),o=i.eUp,o.Org!=a.Org){if(!i.fixUpperEdge){n.finishRegion(r,s);break}o=r.mesh.connect(a.Lprev,o.Sym),n.fixUpperEdge(r,i,o)}a.Onext!==o&&(r.mesh.splice(o.Oprev,o),r.mesh.splice(a,o)),n.finishRegion(r,s),a=i.eUp,s=i}return a},n.addRightEdges=function(r,e,t,o,i,s){var a,c,u,l,d=!0;u=t;do ue(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,l=i;a=n.regionBelow(c),u=a.eUp.Sym,u.Org===l.Org;)u.Onext!==l&&(r.mesh.splice(u.Oprev,u),r.mesh.splice(l.Oprev,u)),a.windingNumber=c.windingNumber-u.winding,a.inside=n.isWindingInside(r,a.windingNumber),c.dirty=!0,!d&&n.checkForRightSplice(r,c)&&(n.addWinding(u,l),n.deleteRegion(r,c),r.mesh.delete(l)),d=!1,c=a,l=u;c.dirty=!0,ue(c.windingNumber-u.winding===a.windingNumber),s&&n.walkDirtyRegions(r,c)},n.spliceMergeVertices=function(r,e,t){r.mesh.splice(e,t)},n.vertexWeights=function(r,e,t){var o=le.vertL1dist(e,r),i=le.vertL1dist(t,r),s=.5*i/(o+i),a=.5*o/(o+i);r.coords[0]+=s*e.coords[0]+a*t.coords[0],r.coords[1]+=s*e.coords[1]+a*t.coords[1],r.coords[2]+=s*e.coords[2]+a*t.coords[2]},n.getIntersectData=function(r,e,t,o,i,s){e.coords[0]=e.coords[1]=e.coords[2]=0,e.idx=-1,n.vertexWeights(e,t,o),n.vertexWeights(e,i,s)},n.checkForRightSplice=function(r,e){var t=n.regionBelow(e),o=e.eUp,i=t.eUp;if(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(ue(!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,a=i.Org,c=o.Dst,u=i.Dst,l,d,p=new ii,f,m;if(ue(!le.vertEq(u,c)),ue(le.edgeSign(c,r.event,s)<=0),ue(le.edgeSign(u,r.event,a)>=0),ue(s!==r.event&&a!==r.event),ue(!e.fixUpperEdge&&!t.fixUpperEdge),s===a||(l=Math.min(s.t,c.t),d=Math.max(a.t,u.t),l>d))return!1;if(le.vertLeq(s,a)){if(le.edgeSign(u,s,a)>0)return!1}else if(le.edgeSign(c,a,s)<0)return!1;return n.debugEvent(r),le.intersect(c,s,u,a,p),ue(Math.min(s.t,c.t)<=p.t),ue(p.t<=Math.max(a.t,u.t)),ue(Math.min(u.s,c.s)<=p.s),ue(p.s<=Math.max(a.s,s.s)),le.vertLeq(p,r.event)&&(p.s=r.event.s,p.t=r.event.t),f=le.vertLeq(s,a)?s:a,le.vertLeq(f,p)&&(p.s=f.s,p.t=f.t),le.vertEq(p,s)||le.vertEq(p,a)?(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,a,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),a=e.eUp,c=s.eUp,u=!1;if(a.Dst!==c.Dst&&n.checkForIntersect(r,e),le.vertEq(a.Org,r.event)&&(r.mesh.splice(i.Oprev,a),e=n.topLeftRegion(r,e),i=n.regionBelow(e).eUp,n.finishLeftRegions(r,n.regionBelow(e),s),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,a.Org)?o=c.Oprev:o=a,o=r.mesh.connect(t.Lprev,o),n.addRightEdges(r,e,o,o.Onext,o.Onext,!1),o.Sym.activeRegion.fixUpperEdge=!0,n.walkDirtyRegions(r,e)},n.connectLeftDegenerate=function(r,e,t){var o,i,s,a,c;if(o=e.eUp,le.vertEq(o.Org,t)){ue(!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}ue(!1),e=n.topRightRegion(e),c=n.regionBelow(e),s=c.eUp.Sym,i=a=s.Onext,c.fixUpperEdge&&(ue(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,a,i,!0)},n.connectLeftVertex=function(r,e){var t,o,i,s,a,c,u=new Td;if(u.eUp=e.anEdge.Sym,t=r.dict.search(u).key,o=n.regionBelow(t),!!o){if(s=t.eUp,a=o.eUp,le.edgeSign(s.Dst,e,s.Org)===0){n.connectLeftDegenerate(r,t,e);return}if(i=le.vertLeq(a.Dst,s.Dst)?t:o,t.inside||i.fixUpperEdge){if(i===t)c=r.mesh.connect(e.anEdge.Sym,s.Lnext);else{var l=r.mesh.connect(a.Dnext,e.anEdge);c=l.Sym}i.fixUpperEdge?n.fixUpperEdge(r,i,c):n.computeWinding(r,n.addRegionBelow(r,t,c)),n.sweepEvent(r,e)}else n.addRightEdges(r,t,e.anEdge,e.anEdge,null,!0)}},n.sweepEvent=function(r,e){r.event=e,n.debugEvent(r);for(var t=e.anEdge;t.activeRegion===null;)if(t=t.Onext,t===e.anEdge){n.connectLeftVertex(r,e);return}var o=n.topLeftRegion(r,t.activeRegion);ue(o!==null);var i=n.regionBelow(o),s=i.eUp,a=n.finishLeftRegions(r,i,null);a.Onext===s?n.connectRightVertex(r,o,a):n.addRightEdges(r,o,a.Onext,s,s,!0)},n.addSentinel=function(r,e,t,o){var i=new Td,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 KP(r,n.edgeLeq);var e=r.bmax[0]-r.bmin[0],t=r.bmax[1]-r.bmin[1],o=r.bmin[0]-e,i=r.bmax[0]+e,s=r.bmin[1]-t,a=r.bmax[1]+t;n.addSentinel(r,o,i,s),n.addSentinel(r,o,i,a)},n.doneEdgeDict=function(r){for(var e,t=0;(e=r.dict.min().key)!==null;)e.sentinel||(ue(e.fixUpperEdge),ue(++t===1)),ue(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 XP(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,ue(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}(),QP=function(){function n(){this.mesh=new Qh,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,a,c=[0,0,0],u=[0,0,0],l=[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 x=0;if(c[1]-u[1]>c[0]-u[0]&&(x=1),c[2]-u[2]>c[x]-u[x]&&(x=2),u[x]>=c[x]){r[0]=0,r[1]=0,r[2]=1;return}for(a=0,t=m[x],o=f[x],l[0]=t.coords[0]-o.coords[0],l[1]=t.coords[1]-o.coords[1],l[2]=t.coords[2]-o.coords[2],e=h.next;e!==h;e=e.next)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]=l[1]*d[2]-l[2]*d[1],p[1]=l[2]*d[0]-l[0]*d[2],p[2]=l[0]*d[1]-l[1]*d[0],s=p[0]*p[0]+p[1]*p[1]+p[2]*p[2],s>a&&(a=s,r[0]=p[0],r[1]=p[1],r[2]=p[2]);a<=0&&(r[0]=r[1]=r[2]=0,r[this.longAxis_(l)]=1)},n.prototype.checkOrientation_=function(){for(var r=this.mesh.fHead,e,t=this.mesh.vHead,o,i=0,s=r.next;s!==r;s=s.next)if(o=s.anEdge,!(o.winding<=0))do i+=(o.Org.s-o.Dst.s)*(o.Org.t+o.Dst.t),o=o.Lnext;while(o!==s.anEdge);if(i<0){for(e=t.next;e!==t;e=e.next)e.t=-e.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},n.prototype.projectPolygon_=function(){var r=this.mesh.vHead,e=[0,0,0],t,o,i=!1;e[0]=this.normal[0],e[1]=this.normal[1],e[2]=this.normal[2],!e[0]&&!e[1]&&!e[2]&&(this.computeNormal_(e),i=!0),t=this.sUnit,o=this.tUnit;var s=this.longAxis_(e);t[s]=0,t[(s+1)%3]=1,t[(s+2)%3]=0,o[s]=0,o[(s+1)%3]=0,o[(s+2)%3]=e[s]>0?1:-1;for(var a=r.next;a!==r;a=a.next)a.s=this.dot_(a.coords,t),a.t=this.dot_(a.coords,o);i&&this.checkOrientation_();for(var c=!0,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,a=0,c;t>3&&r.mergeConvexFaces(t);for(var u=r.vHead.next;u!==r.vHead;u=u.next)u.n=-1;for(var l=r.fHead.next;l!==r.fHead;l=l.next)if(l.n=-1,!!l.inside){i=l.anEdge,c=0;do{var u=i.Org;u.n===-1&&(u.n=a,a++),c++,i=i.Lnext}while(i!==l.anEdge);if(c>t)throw"Face vertex greater that support polygon";l.n=s,++s}this.elementCount=s,e===Ge.CONNECTED_POLYGONS&&(s*=2),this.elements=[],this.elements.length=s*t,this.vertexCount=a,this.vertices=[],this.vertices.length=a*o,this.vertexIndices=[],this.vertexIndices.length=a;for(var 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,l=r.fHead.next;l!==r.fHead;l=l.next)if(!!l.inside){i=l.anEdge,c=0;do{var u=i.Org;this.elements[p++]=u.n,c++,i=i.Lnext}while(i!==l.anEdge);for(var f=c;f<t;++f)this.elements[p++]=-1;if(e===Ge.CONNECTED_POLYGONS){i=l.anEdge;do this.elements[p++]=this.getNeighbourFace_(i),i=i.Lnext;while(i!==l.anEdge);for(var m=c;m<t;++m)this.elements[p++]=-1}}},n.prototype.outputContours_=function(r,e){var t,o,i=0,s=0;this.vertexCount=0,this.elementCount=0;for(var a=r.fHead.next;a!==r.fHead;a=a.next)if(!!a.inside){o=t=a.anEdge;do this.vertexCount++,t=t.Lnext;while(t!==o);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*e,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var c=0,u=0,l=0;i=0;for(var a=r.fHead.next;a!==r.fHead;a=a.next)if(!!a.inside){s=0,o=t=a.anEdge;do this.vertices[c++]=t.Org.coords[0],this.vertices[c++]=t.Org.coords[1],e>2&&(this.vertices[c++]=t.Org.coords[2]),this.vertexIndices[u++]=this.vertexIdCallback?this.vertexIdCallback(t):t.Org.idx,s++,t=t.Lnext;while(t!==o);this.elements[l++]=i,this.elements[l++]=s,i+=s}},n.prototype.addContour=function(r,e){this.mesh===null&&(this.mesh=new Qh),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=Ge.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_(),ZP.computeInterior(this,s);var a=this.mesh;return e===Ge.BOUNDARY_CONTOURS?this.setWindingNumber_(a,1,!0):this.tessellateInterior_(a),s&&a.check(),e===Ge.BOUNDARY_CONTOURS?this.outputContours_(a,o):this.outputPolymesh_(a,e,t,o),!0},n}();function sr(n){var r=n.windingRule,e=r===void 0?be.ODD:r,t=n.elementType,o=t===void 0?Ge.POLYGONS:t,i=n.polySize,s=i===void 0?3:i,a=n.vertexSize,c=a===void 0?2:a,u=n.normal,l=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 QP;n.edgeCreateCallback&&(g.edgeCreateCallback=n.edgeCreateCallback),n.vertexIdCallback&&(g.vertexIdCallback=n.vertexIdCallback);for(var x=0;x<p.length;x++)g.addContour(c||2,p[x]);return g.tesselate(e,o,s,c,l,m),{vertices:g.vertices,vertexIndices:g.vertexIndices,vertexCount:g.vertexCount,elements:g.elements,elementCount:g.elementCount,mesh:y?g.mesh:void 0}}}var sF=be.ODD,aF=be.NONZERO,lF=be.POSITIVE,cF=be.NEGATIVE,dF=be.ABS_GEQ_TWO,uF=Ge.POLYGONS,pF=Ge.CONNECTED_POLYGONS,fF=Ge.BOUNDARY_CONTOURS;import{BufferAttribute as Al,BufferGeometry as JP}from"three";var Ol=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*Ol.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*Ol.eSize,o=new ArrayBuffer(t),i=Float32Array.BYTES_PER_ELEMENT,s=0,a=new Float32Array(o,s*i,3*r);s+=3*r;let c=new Float32Array(o,s*i,3*r);s+=3*r;let u=new Float32Array(o,s*i,2*r);a.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=a,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)}},_s=Ol;_s.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var Ps={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},Ad={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},Cd={vertices:[-160,160,160,-160,160,160,-160,-160],vertexIndices:[1,3,0,2],vertexCount:4,elements:[0,1,2,1,0,3],elementCount:2,mesh:void 0},Od=(n,r)=>([e,t])=>(t<e&&(t+=r),(n>=e?n:n+r)<=t),si=class extends JP{constructor(e,t,o=0,i=12,s=3,a=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(_=>{let v=_.extractShapePointsToFlatArray([],i),N=[];for(let T=v.length-1;T>=1;T-=2){let C=v[T-1],O=v[T-0];N.push(C,O)}return N}),l;try{l=sr({windingRule:a,elementType:Ge.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[c]})}catch{l=Ps}let d;try{d=sr({windingRule:be.ODD,elementType:Ge.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...u]})}catch{d=Ad}if(!l)throw new Error("error generating geometry");let p=l.elementCount;if(d){l.elementCount+=d.elementCount;for(let _=0;_<d.elements.length;_++){let v=d.elements[_],N=_%2===0?l.vertexCount:0;l.elements.push(v+N)}for(let _=0;_<d.vertexIndices.length;_++){let v=d.vertexIndices[_],N=l.vertexCount;l.vertexIndices.push(v+N)}for(let _=0;_<d.vertices.length;_++){let v=d.vertices[_];l.vertices.push(v)}}let f=1/0,m=-1/0,h=1/0,y=-1/0;for(let _=0,v=l.vertexCount;_<v;_++){let N=_*2,T=l.vertices[N+0],C=l.vertices[N+1];T<f&&(f=T),T>m&&(m=T),C<h&&(h=C),C>y&&(y=C)}this._minX=f,this._minY=h,this._width=m-f,this._height=y-h,this._buffer=new _s(this._computeBufferEstimatedSize(l));let g=[],x=[];for(let _=l.elementCount-1;_>=0;_--){let v=_>=p,N=_*2,T=l.elements[N+0],C=l.elements[N+1],O=T+C,A={start:T,count:C,normals:[],continuous:[],concave:[]},R=T,U=O-1,$=T+1,ee=this._shape.roundedCurves.length;do{let V=R-T,G=l.vertices[U*2+0],D=l.vertices[U*2+1],L=l.vertices[R*2+0],B=l.vertices[R*2+1],X=l.vertices[$*2+0],W=l.vertices[$*2+1],j=L-G,F=B-D,M=Math.sqrt(j*j+F*F);j/=M,F/=M;let Q=L-X,re=B-W,oe=Math.sqrt(Q*Q+re*re);Q/=oe,re/=oe,A.normals[V*2+0]=-re,A.normals[V*2+1]=Q,A.concave[V]=j*re-F*Q>0;let K=l.vertexIndices[R];if(Array.isArray(K))A.continuous[V]=!1;else{let[te,J]=this._shape.getCurveIndexFromVertexId(K-1,!0);if(J>0&&J<1)A.continuous[V]=!0;else{let ie=J===1?te+1:te-1;ie=(ie+ee)%ee;let ce=J===1?0:1,se=this._shape.roundedCurves[te].getTangent(J),fe=this._shape.roundedCurves[ie].getTangent(ce);A.continuous[V]=se.dot(fe)>.95}}v&&(A.normals[V*2+0]*=-1,A.normals[V*2+1]*=-1),[U,R,$]=[R,$,$+1],$>=O&&($-=C)}while($!==T+1);let Y=[];Y.push({bevelI:0,angle:0,size:0,boundary:{vertices:l.vertices.slice(T*2,O*2),vertexCount:C,vertexIndices:new Array(C).fill(!0).map((V,G)=>[G,G]),elements:[0,C],elementCount:1,mesh:null},reverseMap:[],insetPoints:l.vertices.slice(T*2,O*2)});for(let V=1;V<=this._bevelSegments;V++){let G=V/this._bevelSegments*Math.PI/2,D=(1-Math.cos(G))*this._bevelSize,L=[],B=[],X=[],W=[],j=0;for(let M=0;M<C;M++){let Q=M*2,re=(M-1+C)%C*2,oe=l.vertices[A.start*2+Q+0],K=l.vertices[A.start*2+Q+1],te=-A.normals[re+0]*D,J=-A.normals[re+1]*D,ie=-A.normals[Q+0]*D,ce=-A.normals[Q+1]*D;if(A.concave[M]||!A.concave[M]&&v){let se=Math.atan2(J,te),fe=Math.atan2(ce,ie);fe>se&&(fe-=Math.PI*2);let ze=fe-se;if(A.continuous[M]||v){let ge=se+ze/2,qe=Math.cos(ge)*D,Oe=Math.sin(ge)*D;L[2*j+0]=oe+qe*(v?-1:1),L[2*j+1]=K+Oe*(v?-1:1),W[j]=M,j++}else{let ge=Math.max(1,Math.floor(i/4*Math.abs(ze)/Math.PI));for(let qe=0;qe<=ge;qe++){let Oe=se+ze*(qe/ge),Ot=Math.cos(Oe)*D,Wt=Math.sin(Oe)*D;L[2*j+0]=oe+Ot,L[2*j+1]=K+Wt,W[j]=M,j++}}}else L[2*j+0]=oe+te,L[2*j+1]=K+J,W[j]=M,B[M]=j,j++,L[2*j+0]=oe,L[2*j+1]=K,W[j]=M,j++,L[2*j+0]=oe+ie,L[2*j+1]=K+ce,W[j]=M,X[M]=j,j++}let F=sr({windingRule:be.POSITIVE,elementType:Ge.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[L],edgeCreateCallback:M=>{let re=M.Org.idx,oe=W[re],K=W[(re+1)%W.length];M.idx=[oe,K],M.Sym.idx=[K,oe]},vertexIdCallback:M=>{let Q=M.Lprev.idx;return[Q?Q[1]:0,M.idx?M.idx[0]:0]}});if(!F)throw console.log("Error"),new Error(`error generating bevel geometry for ${V}'th loop`);if(!F.vertexCount)break;for(let M=0;M<F.vertexIndices.length;M++){let[Q,re]=F.vertexIndices[M];if(Q===re)continue;let oe=re;re<Q&&(oe+=C);for(let K=Q;K<oe;K++){let te=K%C,J=(K+1)%C;if(!A.continuous[te]||!A.continuous[J]){F.vertexIndices[M]=[Q,te],F.vertexIndices.splice(M+1,0,[J,re]),F.vertices.splice((M+1)*2,0,F.vertices[M*2],F.vertices[M*2+1]);break}}}Y.push({bevelI:V,angle:G,size:D,boundary:F,reverseMap:W,insetPoints:L})}let q=(V,G,D)=>{let L=0,B=V.boundary.vertexIndices.length;for(;L<B&&D(V.boundary.vertexIndices[G]);)G=(G+1)%B,L++;return L},H=g.length;for(let V=1;V<Y.length;V++){let G=Y[V-1],D=Y[V],L=G.boundary.vertexIndices.length,B=D.boundary.vertexIndices.length;if(!L||!B)break;let X=A.concave.length,W=0,j=Od(W,C);for(;!G.boundary.vertexIndices.filter(j).length||!D.boundary.vertexIndices.filter(j).length;)W++,j=Od(W,C);let F=G.boundary.vertexIndices.findIndex(j),M=D.boundary.vertexIndices.findIndex(j);do F=(F+1)%L;while(j(G.boundary.vertexIndices[F]));do M=(M+1)%B;while(j(D.boundary.vertexIndices[M]));W=(W+1)%C;let Q=W,re=this._buildBevelVert(A,G,(F-1+L)%L),oe=this._buildBevelVert(A,D,(M-1+B)%B),K=re,te=oe,J,ie,ce=!1;do{j=Od(W,C);let se=q(G,F,j),fe=q(D,M,j),ze=ce;if(ce=!1,se&&!fe){for(let ge=0;ge<se;ge++)J=this._buildBevelVert(A,G,(F+ge)%L,ge/(se-1)),g.push(K.topN,J.topP,te.topN),g.push(J.bottomP,K.bottomN,te.bottomN),K=J;ce=!0}else if(!se&&fe)for(let ge=0;ge<fe;ge++)ie=this._buildBevelVert(A,D,(M+ge)%B,ge/(fe-1)),g.push(te.topN,K.topP,ie.topP),g.push(K.bottomP,te.bottomN,ie.bottomP),te=ie;else if(se&&fe)if(J=this._buildBevelVert(A,G,F,0),ie=this._buildBevelVert(A,D,M,0),ze?(g.push(K.topN,ie.topP,te.topN),g.push(K.topN,J.topP,ie.topP),g.push(ie.bottomP,K.bottomN,te.bottomN),g.push(ie.bottomP,J.bottomP,K.bottomN)):(g.push(te.topN,K.topN,J.topP),g.push(te.topN,J.topP,ie.topP),g.push(J.bottomP,K.bottomN,te.bottomN),g.push(J.bottomP,te.bottomN,ie.bottomP)),K=J,te=ie,se===fe)for(let ge=1;ge<se;ge++)J=this._buildBevelVert(A,G,(F+ge)%L,ge/(se-1)),ie=this._buildBevelVert(A,D,(M+ge)%B,ge/(fe-1)),g.push(K.topN,J.topP,te.topN),g.push(te.topN,J.topP,ie.topP),g.push(J.bottomP,K.bottomN,te.bottomN),g.push(J.bottomP,te.bottomN,ie.bottomP),K=J,te=ie;else if(se>fe){let ge=se/fe,qe=0;for(let Oe=1;Oe<se;Oe++)J=this._buildBevelVert(A,G,(F+Oe)%L,Oe/(se-1)),g.push(K.topN,J.topP,te.topN),g.push(J.bottomP,K.bottomN,te.bottomN),K=J,Oe>(qe+1)*ge&&(qe++,ie=this._buildBevelVert(A,D,(M+qe)%B,qe/(fe-1)),g.push(te.topN,J.topP,ie.topP),g.push(J.bottomP,te.bottomN,ie.bottomP),te=ie)}else{let ge=fe/se,qe=0;for(let Oe=1;Oe<fe;Oe++)ie=this._buildBevelVert(A,D,(M+Oe)%B,Oe/(fe-1)),g.push(te.topN,J.topP,ie.topP),g.push(J.bottomP,te.bottomN,ie.bottomP),te=ie,Oe>(qe+1)*ge&&(qe++,J=this._buildBevelVert(A,G,(F+qe)%L,qe/(se-1)),g.push(K.topN,J.topP,te.topN),g.push(J.bottomP,K.bottomN,te.bottomN),K=J)}F=(F+se)%L,M=(M+fe)%B,W=(W+1)%X}while(W!==Q)}if(this._depth>this._bevel*2&&this._buildWall(Y,A,g),v){let V=[];for(let G=g.length-1;G>=H+2;G-=3){let D=g[G-2],L=g[G-1],B=g[G-0];V.push(B,L,D)}g.splice(H,g.length-H,...V)}if(v){let V=[];for(let G=Y[Y.length-1].boundary.vertices.length-1;G>=1;G-=2){let D=Y[Y.length-1].boundary.vertices[G-1],L=Y[Y.length-1].boundary.vertices[G-0];V.push(D,L)}x.push(V)}if(!v){let V=Y[Y.length-1],G;try{G=sr({windingRule:Y.length>1?be.POSITIVE:be.ODD,elementType:Ge.POLYGONS,vertexSize:2,strict:!0,contours:[V.insetPoints,...x]})}catch{G=Cd}if(!G)throw new Error("Error generating geometry for surface");u.length===0&&Object.assign(this,{capStartIndex:g.length});for(let D=0;D<G.elementCount*3;D+=3){let L=this._buildSurfaceVert(G,G.elements[D+0]),B=this._buildSurfaceVert(G,G.elements[D+1]),X=this._buildSurfaceVert(G,G.elements[D+2]);g.push(L.top,B.top,X.top),g.push(X.bottom,B.bottom,L.bottom)}}this.vertexCache={}}this._buffer.shrink();let b=new Al(Uint32Array.from(g),1),w=new Al(this._buffer.positions,3),S=new Al(this._buffer.normals,3),P=new Al(this._buffer.uvs,2);w.needsUpdate=!0,S.needsUpdate=!0,P.needsUpdate=!0,b.needsUpdate=!0,this.setAttribute("position",w),this.setAttribute("normal",S),this.setAttribute("uv",P),this.setIndex(b)}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,t,o){let i=e[0];for(let s=0,a=i.boundary.vertexCount;s<a;s++){let c=this._buildBevelVert(t,i,s),u=this._buildBevelVert(t,i,(s+1)%a);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],a=(i-this._minX)/this._width,c=(s-this._minY)/this._height,u=this._buffer.get(2),l=u*3,d=u*2,p={top:u+0,bottom:u+1};return this._buffer.positions[l+0]=i,this._buffer.positions[l+1]=s,this._buffer.positions[l+2]=this._depth,this._buffer.normals[l+0]=0,this._buffer.normals[l+1]=0,this._buffer.normals[l+2]=1,this._buffer.uvs[d+0]=a,this._buffer.uvs[d+1]=c,this._buffer.positions[l+3]=i,this._buffer.positions[l+4]=s,this._buffer.positions[l+5]=0,this._buffer.normals[l+3]=0,this._buffer.normals[l+4]=0,this._buffer.normals[l+5]=-1,this._buffer.uvs[d+2]=a,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[a,c]=t.boundary.vertexIndices[o],u,l,d,p;a!==c?(l=a,u=c,p=!1,d=e.continuous[l]&&e.continuous[u]):(u=a,l=(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=l*2,x=t.boundary.vertices[h+0],b=t.boundary.vertices[h+1],w=(1-m)*this._bevelSize,S=(x-this._minX)/this._width,P=(b-this._minY)/this._height,_=e.normals[y+0],v=e.normals[y+1],N=e.normals[g+0],T=e.normals[g+1];if(p){let U=N-_,$=T-v;_=_+U*(1-i),v=v+$*(1-i);let ee=Math.sqrt(_*_+v*v);_/=ee,v/=ee}let C=this._buffer.get(d?2:4),O=C*3,A=C*2,R={i:o,fi:u,topP:C+0,topN:C+0,bottomP:C+1,bottomN:C+1};return this._buffer.positions[O+0]=x,this._buffer.positions[O+1]=b,this._buffer.positions[O+2]=this._depth-w,this._buffer.normals[O+0]=_*f,this._buffer.normals[O+1]=v*f,this._buffer.normals[O+2]=m,this._buffer.uvs[A+0]=S,this._buffer.uvs[A+1]=P,this._buffer.positions[O+3]=x,this._buffer.positions[O+4]=b,this._buffer.positions[O+5]=w,this._buffer.normals[O+3]=_*f,this._buffer.normals[O+4]=v*f,this._buffer.normals[O+5]=-m,this._buffer.uvs[A+2]=P,this._buffer.uvs[A+3]=S,d||(C+=2,O+=6,A+=4,R.topP=C+0,R.bottomP=C+1,this._buffer.positions[O+0]=x,this._buffer.positions[O+1]=b,this._buffer.positions[O+2]=this._depth-w,this._buffer.normals[O+0]=N*f,this._buffer.normals[O+1]=T*f,this._buffer.normals[O+2]=m,this._buffer.uvs[A+0]=S,this._buffer.uvs[A+1]=P,this._buffer.positions[O+3]=x,this._buffer.positions[O+4]=b,this._buffer.positions[O+5]=w,this._buffer.normals[O+3]=N*f,this._buffer.normals[O+4]=T*f,this._buffer.normals[O+5]=-m,this._buffer.uvs[A+2]=P,this._buffer.uvs[A+3]=S),this.vertexCache[s]=R,R}clone(){let e=new si(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=$r(this.userData),e}};var ai=class extends eT{constructor(e,t=12,o={}){super();this.type="ShapeGeometry";this.windingRule=be.ODD;this.elementType=Ge.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=e,this._curveSegments=t,this._triangulationOptions=Object.assign({windingRule:be.ODD,elementType:Ge.POLYGONS,polySize:3,vertexSize:2,strict:!0},o);let i=this._shape.extractShapePointsToFlatArray([],this._curveSegments),s=this._shape.shapeHoles.map(m=>m.extractShapePointsToFlatArray([],this._curveSegments)),a,c=!0,u=!0,l,d;for(let m=0,h=i.length/2;m<h;m++){let y=m*2,g=i[y+0],x=i[y+1];if(l!==void 0&&g!==l&&(c=!1),d!==void 0&&x!==d&&(u=!1),l=g,d=x,!c&&!u)break}if(!c&&!u)try{a=sr({contours:[i,...s],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})}catch{a=Ps}let p=a?.vertexCount??1,f=a?.elementCount??1;if(this._positionAttribute=new Cl(new Float32Array(p*3),3),this._normalAttribute=new Cl(new Float32Array(p*3),3),this._uvAttribute=new Cl(new Float32Array(p*2),2),this._indexAttribute=new Cl(new Uint32Array(f*3),1),a){let m=1/0,h=-1/0,y=1/0,g=-1/0;for(let w=0,S=p;w<S;w++){let P=w*2,_=a.vertices[P+0],v=a.vertices[P+1];_<m&&(m=_),_>h&&(h=_),v<y&&(y=v),v>g&&(g=v)}let x=h-m,b=g-y;for(let w=0,S=p;w<S;w++){let P=w*2,_=a.vertices[P+0],v=a.vertices[P+1],N=(_-m)/x,T=(v-y)/b;this._positionAttribute.setXYZ(w,_,v,0),this._normalAttribute.setXYZ(w,0,0,1),this._uvAttribute.setXY(w,N,T)}for(let w=0,S=f;w<S;w++){let P=w*3,_=a.elements[P+0],v=a.elements[P+1],N=a.elements[P+2];this._indexAttribute.setX(P+0,_),this._indexAttribute.setX(P+1,v),this._indexAttribute.setX(P+2,N)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,(a?.elementCount??1)*3)}clone(){let e=new ai(this._shape,this._curveSegments);return e.userData=$r(this.userData),e}};var li=class extends si{constructor(e,t,o=0,i=12,s=3,a=be.ODD){super(e,t,o,i,s,a);this.type="ShapeGeometry"}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,t,o){let i=e[0];for(let s=0,a=i.boundary.vertexCount;s<a;s++){let c=this._buildBevelVert(t,i,s),u=this._buildBevelVert(t,i,(s+1)%a);o.push(u.topP,c.topN,c.bottomN),o.push(u.topP,c.bottomN,u.bottomP)}}clone(){let e=new li(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=$r(this.userData),e}};var Mt=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,a=s?.roundness??e.roundness;s!==void 0&&(s instanceof _e?(s.width!==t||s.height!==o)&&s.applySize(t,o):s=new _e(t,o).fromJSON(s),n.parameters?.roundness!==void 0&&n.parameters?.roundness>0&&s.update());let c=s??new _e(t,o);return{parameters:Object.assign(e,{width:t,height:o,depth:i,roundness:a}),shape:c}}static build(n){let{depth:r,extrudeBevelSize:e,extrudeBevelSegments:t,subdivisions:o,roundness:i,windingRule:s}=n.parameters;n.shape.roundness=i;let a;return r<=0?a=new ai(n.shape,o,{windingRule:s}):a=new li(n.shape,r,e,o,t,s),Object.assign(a,{userData:{...n,type:"VectorGeometry"}})}};import{MathUtils as oy,Vector2 as ny}from"three";var iy=Math.PI*2,di=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 _e?n.shape:new _e,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(n){let{width:r,height:e,spikes:t,angle:o,innerRadius:i,depth:s,extrudeBevelSize:a,extrudeBevelSegments:c}=n.parameters,u=n.shape,l=r*.5,d=e*.5,p=tT(u,l,d,o*Math.PI/180,t,i);u.isClosed=!0,u.update();let f=Mt.create({shape:u,parameters:{subdivisions:p,depth:s,extrudeBevelSize:a,extrudeBevelSegments:c}});return Object.assign(f,{userData:{...n,type:"EllipseGeometry"}})}};function tT(n,r,e,t,o,i){if(t>=iy)return o>30||o%4===0?(oT(n,r,e,i),Math.round(o/4)):ry(n,t,o,r,e,i);t=Math.max(t,.001);let s={x:0,y:e},a=t+Math.PI*.5,c={x:Math.cos(a)*r,y:Math.sin(a)*e},u=Zh({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?rT(n,s.x,s.y,u,o,r,e,i):ry(n,t,o,r,e,i)}function rT(n,r,e,t,o,i,s,a){let c=Math.round(o/t.length);n.addPoint(ci(r,e));for(let u=0,l=t.length;u<l;u++){let d=t[u],p=n.points[u],f=ci(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 a>0?sy(n,i,s,a):n.addPoint(ci(0,0)),c}function ry(n,r,e,t,o,i){let s=-r/e;for(let a=0;a<=e;a++){let c=s*a,u=Math.sin(c)*t,l=Math.cos(c)*o;n.addPoint(ci(u,l))}return r<iy?i>0?sy(n,t,o,i):n.addPoint(ci(0,0)):(n.removePoint(n.points[n.points.length-1]),i>0&&ay(n,t,o,i)),1}function oT(n,r,e,t=0,o=0,i=0){let s=.5522847498,a=r*s,c=e*s;n.addPoint(Nl(o-r,i,o-r,i-c,o-r,i+c)),n.addPoint(Nl(o,i+e,o-a,i+e,o+a,i+e)),n.addPoint(Nl(o+r,i,o+r,i+c,o+r,i-c)),n.addPoint(Nl(o,i-e,o+a,i-e,o-a,i-e)),t>0&&ay(n,r,e,t)}function ci(n,r){return new ir(oy.generateUUID(),new ny(n,r))}function Nl(n,r,e,t,o,i){let s=ci(n,r);return s.controls[0].position.set(e,t),s.controls[1].position.set(o,i),s}function sy(n,r,e,t){ly(n,r,e,t).forEach(i=>n.addPoint(i))}function ay(n,r,e,t){let o=ly(n,r,e,t),i=new _e;o.forEach(s=>i.addPoint(s)),i.isClosed=!0,n.shapeHoles.push(i)}function ly(n,r,e,t){let o=t*r/100,i=o*(Math.abs(e)/Math.abs(r)),s=new ny(o/r,i/e),a=n.points.map(c=>{let u=c.clone();return u.uuid=oy.generateUUID(),u}).reverse();return a.forEach(c=>{c.position.multiply(s);let u=c.controls[0].position.clone().multiply(s),l=c.controls[1].position.clone().multiply(s);c.controls[0].position.copy(l),c.controls[1].position.copy(u)}),a}import{BufferGeometry as nT,Float32BufferAttribute as Nd,Uint32BufferAttribute as iT,Vector3 as cy}from"three";var dy=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},n.parameters),t=Math.abs(e.width),o=Math.abs(e.height??t),i=Math.abs(e.depth??t),s=Math.abs(Math.min(t,i))/2;return{parameters:Object.assign(e,{width:t,height:o,depth:i,radius:s,segments:Math.round(e.segments),pathSegments:Math.round(e.pathSegments),cornerSegments:Math.round(e.cornerSegments)})}}static build(n){let{width:r,height:e,depth:t,radius:o,revolutions:i,segments:s,pathRadius:a,pathType:c,pathSegments:u,cornerRadius:l,cornerSegments:d}=n.parameters,p=new Ts(!1,r,e,t,o,i,s,a,c,u,l,d);return Object.assign(p,{userData:{...n,type:"HelixGeometry"}})}},Id=new iT([0,0,0],1),Ts=class extends nT{constructor(r=!0,e=1,t=1,o=1,i=1,s=1,a=1,c=1,u=1,l=1,d=1,p=1){if(super(),s===0)return;let f=r&&s===1;f&&(p=0),d>100&&(d=100),d===0&&(p=0);let m=()=>new cy,h=new cy,y=m(),g=m(),x=m(),b,w,S,P,_,v,N,T,C=m(),O=m(),A=m(),R=m(),U=m(),$=m(),ee=m(),Y=m(),q=t-2*c+.001,H=q/s,V=Math.ceil(a*s),G=V+1,D=q/V,L=-q/2,B=l+1,X=2*Math.PI/l,W=Math.PI/2/p,j=.01,F=Math.min((1-d/100)*c,c-j),M=c-F,Q=0,re=2,oe=p*re+re,K=B*oe/re,te=K+B*G,J=B*(G+oe),[ie,ce,se]=[3,3,2].map(Ue=>Array(J*Ue).fill(0)),fe=[],ze=i-c;function ge(Ue,Gt){let hr=Math.PI/2;v=Gt*D,T=2*Math.PI*(v%H)/H+hr,v+=L,N=Math.sin(T)*ze,_=Math.cos(T)*ze,r?Ue.set(_,N,v):Ue.set(_,v,N)}ge(h,-1e-10),ge(y,0),C.copy(h),ge(h,1);let qe=h.distanceTo(y),Oe=f?0:M+F,Ot=qe*V+2*Oe,Wt=F,pn=Ot-Oe;for(let Ue=0;Ue<=V;Ue++){ge(g,Ue),Y.subVectors(g,C).normalize(),C.copy(g),$.copy(g).setComponent(+r+1,0).normalize(),ee.crossVectors(Y,$).normalize();let Gt=Ue===0,hr=Ue===V,B0=Gt?3*Math.PI/2:W,R0=Gt?Wt:pn,G0=Gt?B:te,V0=Gt?0:J-B,z0=Y.clone().multiplyScalar(Gt?-M:M).add(g),j0=Y.clone().multiplyScalar(Gt?-1:1).normalize();for(let kr=0;kr<B;kr++){let Uu=kr*X;if(O.addVectors(h.copy($).multiplyScalar(c*Math.cos(Uu)),y.copy(ee).multiplyScalar(c*Math.sin(Uu))),A.copy(O).normalize(),Gt||hr){f||(Q=V0+kr,[0,1,2].forEach(At=>{ie[Q*3+At]=z0.getComponent(At),ce[Q*3+At]=j0.getComponent(At)}),se[Q*2]=+hr,se[Q*2+1]=kr/l),y.copy(A).multiplyScalar(F),x.addVectors(g,y);for(let At=0;At<p;At++){let gc=At*W+B0;R.addVectors(h.copy(Y).multiplyScalar(M*Math.sin(gc)),y.copy(A).multiplyScalar(M*Math.cos(gc))),U.copy(R).normalize(),y.addVectors(x,R),R.normalize(),Q=G0+At*B+kr,[0,1,2].forEach(ia=>{ie[Q*3+ia]=y.getComponent(ia),ce[Q*3+ia]=U.getComponent(ia)});let F0=+Gt+Math.sin(gc);se[Q*2]=(R0+M*F0)/Ot,se[Q*2+1]=kr/l}}y.addVectors(g,O),Q=K+Ue*B+kr,[0,1,2].forEach(At=>{ie[Q*3+At]=y.getComponent(At),ce[Q*3+At]=A.getComponent(At)}),se[Q*2]=(Oe+Ue*qe)/Ot,se[Q*2+1]=kr/l}}let Rt=G+2*p+re,ra=1,[oa,na]=[+f,Rt-1];for(let Ue=oa;Ue<=na-1;Ue++){let Gt=f&&Ue===na-1;for(let hr=0;hr<B-1;hr++)b=Ue*B+hr,w=b+1,S=(Gt?hr:b)+B,P=(Gt?hr+1:w)+B,Ue===0?fe.push(w,P,S):Ue===Rt-2?fe.push(b,w,S):fe.push(b,w,S,w,P,S)}this.setIndex(fe),this.setAttribute("position",new Nd(ie,3)),this.setAttribute("normal",new Nd(ce,3)),this.setAttribute("uv",new Nd(se,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let r=this.userData.parameters,e=Math.ceil(r.tubularSegments),t=r.radialSegments+1,o=Array.from(this.getIndex().array),i,s,a,c,u=6*(e-1)*r.radialSegments,l=e,d=l===e;for(let p=0;p<r.radialSegments;p++)i=l*t+p,s=i+1,a=(d?p:i)+t,c=(d?p+1:s)+t,o[u++]=i,o[u++]=s,o[u++]=a,o[u++]=s,o[u++]=c,o[u++]=a;return o.length=u,Id.array=o,Id.count=o.length,Id}};import{IcosahedronGeometry as sT}from"three";var uy=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,detail:0,corner:0,cornerSides:4},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:r,height:e,depth:t,detail:o,corner:i,cornerSides:s}=n.parameters,a=o===0&&i!==0?new Os(r*.5,i,s):new sT(r*.5,o);return a.scale(1,e/r,t/r),Object.assign(a,{userData:{...n,type:"IcosahedronGeometry"}})}},Os=class extends To{constructor(r=1,e=.2,t=4){let o=(1+Math.sqrt(5))/2,i=[-1,o,0,1,o,0,-1,-o,0,1,-o,0,0,-1,o,0,1,o,0,-1,-o,0,1,-o,o,0,-1,o,0,1,-o,0,-1,-o,0,1],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],a="IcosahedronGeometry";super(i,s,a,r,e,t),this.type=a}static fromJSON(r){return new Os(r.radius,r.corner,r.cornerSides)}};import{LatheGeometry as aT,Shape as lT}from"three";var py=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 lT;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 aT(o.extractPoints(t).shape,e);return i.rotateZ(Math.PI),Object.assign(i,{userData:{...n,type:"LatheGeometry"}})}};import{BufferGeometry as by,BufferGeometryLoader as bT,Vector3 as ST,BoxGeometry as Sy}from"three";import{BufferGeometry as yT,Vector2 as Dd,Vector3 as vy}from"three";import{Box3 as cT,BufferAttribute as As,BufferGeometry as fy,Color as Ld,EventDispatcher as dT,Float32BufferAttribute as ui,Matrix3 as my,Matrix4 as xy,MathUtils as uT,Object3D as pT,Sphere as fT,Vector2 as kt,Vector3 as ut,Vector4 as mT}from"three";var Ar=new xy,Md=new pT,Il=new ut,Ao=class extends dT{constructor(){super(),this.uuid=uT.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 my().getNormalMatrix(r);for(let t=0,o=this.vertices.length;t<o;t++)this.vertices[t].applyMatrix4(r);for(let t=0,o=this.faces.length;t<o;t++){let i=this.faces[t];i.normal.applyMatrix3(e).normalize();for(let s=0,a=i.vertexNormals.length;s<a;s++)i.vertexNormals[s].applyMatrix3(e).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this}rotateX(r){return Ar.makeRotationX(r),this.applyMatrix4(Ar),this}rotateY(r){return Ar.makeRotationY(r),this.applyMatrix4(Ar),this}rotateZ(r){return Ar.makeRotationZ(r),this.applyMatrix4(Ar),this}translate(r,e,t){return Ar.makeTranslation(r,e,t),this.applyMatrix4(Ar),this}scale(r,e,t){return Ar.makeScale(r,e,t),this.applyMatrix4(Ar),this}lookAt(r){return Md.lookAt(r),Md.updateMatrix(),this.applyMatrix4(Md.matrix),this}fromBufferGeometry(r){let e=this,t=r.index!==null?r.index:void 0,o=r.attributes;if(o.position===void 0)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;let i=o.position,s=o.normal,a=o.color,c=o.uv,u=o.uv2;u!==void 0&&(this.faceVertexUvs[1]=[]);for(let p=0;p<i.count;p++)e.vertices.push(new ut().fromBufferAttribute(i,p)),a!==void 0&&e.colors.push(new Ld().fromBufferAttribute(a,p));function l(p,f,m,h){let y=a===void 0?[]:[e.colors[p].clone(),e.colors[f].clone(),e.colors[m].clone()],g=s===void 0?[]:[new ut().fromBufferAttribute(s,p),new ut().fromBufferAttribute(s,f),new ut().fromBufferAttribute(s,m)],x=new pi(p,f,m,g,y,h);e.faces.push(x),c!==void 0&&e.faceVertexUvs[0].push([new kt().fromBufferAttribute(c,p),new kt().fromBufferAttribute(c,f),new kt().fromBufferAttribute(c,m)]),u!==void 0&&e.faceVertexUvs[1].push([new kt().fromBufferAttribute(u,p),new kt().fromBufferAttribute(u,f),new kt().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?l(t.getX(y),t.getX(y+1),t.getX(y+2),f.materialIndex):l(y,y+1,y+2,f.materialIndex)}else if(t!==void 0)for(let p=0;p<t.count;p+=3)l(t.getX(p),t.getX(p+1),t.getX(p+2));else for(let p=0;p<i.count;p+=3)l(p,p+1,p+2);return this.computeFaceNormals(),r.boundingBox!==null&&(this.boundingBox=r.boundingBox.clone()),r.boundingSphere!==null&&(this.boundingSphere=r.boundingSphere.clone()),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Il).negate(),this.translate(Il.x,Il.y,Il.z),this}normalize(){this.computeBoundingSphere();let r=this.boundingSphere.center,e=this.boundingSphere.radius,t=e===0?1:1/e,o=new xy;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 ut,e=new ut;for(let t=0,o=this.faces.length;t<o;t++){let i=this.faces[t],s=this.vertices[i.a],a=this.vertices[i.b],c=this.vertices[i.c];r.subVectors(c,a),e.subVectors(s,a),r.cross(e),r.normalize(),i.normal.copy(r)}}computeVertexNormals(r=!0){let e=new Array(this.vertices.length);for(let t=0,o=this.vertices.length;t<o;t++)e[t]=new ut;if(r){let t=new ut,o=new ut;for(let i=0,s=this.faces.length;i<s;i++){let a=this.faces[i],c=this.vertices[a.a],u=this.vertices[a.b],l=this.vertices[a.c];t.subVectors(l,u),o.subVectors(c,u),t.cross(o),e[a.a].add(t),e[a.b].add(t),e[a.c].add(t)}}else{this.computeFaceNormals();for(let t=0,o=this.faces.length;t<o;t++){let i=this.faces[t];e[i.a].add(i.normal),e[i.b].add(i.normal),e[i.c].add(i.normal)}}for(let t=0,o=this.vertices.length;t<o;t++)e[t].normalize();for(let t=0,o=this.faces.length;t<o;t++){let i=this.faces[t],s=i.vertexNormals;s.length===3?(s[0].copy(e[i.a]),s[1].copy(e[i.b]),s[2].copy(e[i.c])):(s[0]=e[i.a].clone(),s[1]=e[i.b].clone(),s[2]=e[i.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeFlatVertexNormals(){this.computeFaceNormals();for(let r=0,e=this.faces.length;r<e;r++){let t=this.faces[r],o=t.vertexNormals;o.length===3?(o[0].copy(t.normal),o[1].copy(t.normal),o[2].copy(t.normal)):(o[0]=t.normal.clone(),o[1]=t.normal.clone(),o[2]=t.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let e=0,t=this.faces.length;e<t;e++){let o=this.faces[e];o.__originalFaceNormal?o.__originalFaceNormal.copy(o.normal):o.__originalFaceNormal=o.normal.clone(),o.__originalVertexNormals||(o.__originalVertexNormals=[]);for(let i=0,s=o.vertexNormals.length;i<s;i++)o.__originalVertexNormals[i]?o.__originalVertexNormals[i].copy(o.vertexNormals[i]):o.__originalVertexNormals[i]=o.vertexNormals[i].clone()}let r=new Ao;r.faces=this.faces;for(let e=0,t=this.morphTargets.length;e<t;e++){if(!this.morphNormals[e]){this.morphNormals[e]={},this.morphNormals[e].faceNormals=[],this.morphNormals[e].vertexNormals=[];let i=this.morphNormals[e].faceNormals,s=this.morphNormals[e].vertexNormals;for(let a=0,c=this.faces.length;a<c;a++){let u=new ut,l={a:new ut,b:new ut,c:new ut};i.push(u),s.push(l)}}let o=this.morphNormals[e];r.vertices=this.morphTargets[e].vertices,r.computeFaceNormals(),r.computeVertexNormals();for(let i=0,s=this.faces.length;i<s;i++){let a=this.faces[i],c=o.faceNormals[i],u=o.vertexNormals[i];c.copy(a.normal),u.a.copy(a.vertexNormals[0]),u.b.copy(a.vertexNormals[1]),u.c.copy(a.vertexNormals[2])}}for(let e=0,t=this.faces.length;e<t;e++){let o=this.faces[e];o.normal=o.__originalFaceNormal,o.vertexNormals=o.__originalVertexNormals}}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new cT),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new fT),this.boundingSphere.setFromPoints(this.vertices)}merge(r,e,t=0){if(!(r&&r.isGeometry)){console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",r);return}let o,i=this.vertices.length,s=this.vertices,a=r.vertices,c=this.faces,u=r.faces,l=this.colors,d=r.colors;e!==void 0&&(o=new my().getNormalMatrix(e));for(let p=0,f=a.length;p<f;p++){let h=a[p].clone();e!==void 0&&h.applyMatrix4(e),s.push(h)}for(let p=0,f=d.length;p<f;p++)l.push(d[p].clone());for(let p=0,f=u.length;p<f;p++){let m=u[p],h,y,g=m.vertexNormals,x=m.vertexColors,b=new pi(m.a+i,m.b+i,m.c+i);b.normal.copy(m.normal),o!==void 0&&b.normal.applyMatrix3(o).normalize();for(let w=0,S=g.length;w<S;w++)h=g[w].clone(),o!==void 0&&h.applyMatrix3(o).normalize(),b.vertexNormals.push(h);b.color.copy(m.color);for(let w=0,S=x.length;w<S;w++)y=x[w],b.vertexColors.push(y.clone());b.materialIndex=m.materialIndex+t,c.push(b)}for(let p=0,f=r.faceVertexUvs.length;p<f;p++){let m=r.faceVertexUvs[p];this.faceVertexUvs[p]===void 0&&(this.faceVertexUvs[p]=[]);for(let h=0,y=m.length;h<y;h++){let g=m[h],x=[];for(let b=0,w=g.length;b<w;b++)x.push(g[b].clone());this.faceVertexUvs[p].push(x)}}}mergeMesh(r){if(!(r&&r.isMesh)){console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",r);return}r.matrixAutoUpdate&&r.updateMatrix(),this.merge(r.geometry,r.matrix)}mergeVertices(r=4){let e={},t=[],o=[],i=Math.pow(10,r);for(let c=0,u=this.vertices.length;c<u;c++){let l=this.vertices[c],d=Math.round(l.x*i)+"_"+Math.round(l.y*i)+"_"+Math.round(l.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 l=this.faces[c];l.a=o[l.a],l.b=o[l.b],l.c=o[l.c];let d=[l.a,l.b,l.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 l=0,d=this.faceVertexUvs.length;l<d;l++)this.faceVertexUvs[l].splice(u,1)}let a=this.vertices.length-t.length;return this.vertices=t,a}setFromPoints(r){this.vertices=[];for(let e=0,t=r.length;e<t;e++){let o=r[e];this.vertices.push(new ut(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,a;o&&o.length===e&&(s=[]),i&&i.length===e&&(a=[]);for(let c=0;c<e;c++){let u=r[c]._id;s&&s.push(o[u]),a&&a.push(i[u])}s&&(this.faceVertexUvs[0]=s),a&&(this.faceVertexUvs[1]=a)}toJSON(){let r={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.parameters!==void 0){let m=this.parameters;for(let h in m)m[h]!==void 0&&(r[h]=m[h]);return r}let e=[];for(let m=0;m<this.vertices.length;m++){let h=this.vertices[m];e.push(h.x,h.y,h.z)}let t=[],o=[],i={},s=[],a={},c=[],u={};for(let m=0;m<this.faces.length;m++){let h=this.faces[m],y=!0,g=!1,x=this.faceVertexUvs[0][m]!==void 0,b=h.normal.length()>0,w=h.vertexNormals.length>0,S=h.color.r!==1||h.color.g!==1||h.color.b!==1,P=h.vertexColors.length>0,_=0;if(_=l(_,0,0),_=l(_,1,y),_=l(_,2,g),_=l(_,3,x),_=l(_,4,b),_=l(_,5,w),_=l(_,6,S),_=l(_,7,P),t.push(_),t.push(h.a,h.b,h.c),t.push(h.materialIndex),x){let v=this.faceVertexUvs[0][m];t.push(f(v[0]),f(v[1]),f(v[2]))}if(b&&t.push(d(h.normal)),w){let v=h.vertexNormals;t.push(d(v[0]),d(v[1]),d(v[2]))}if(S&&t.push(p(h.color)),P){let v=h.vertexColors;t.push(p(v[0]),p(v[1]),p(v[2]))}}function l(m,h,y){return y?m|1<<h:m&~(1<<h)}function 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 a[h]!==void 0||(a[h]=s.length,s.push(m.getHex())),a[h]}function f(m){let h=m.x.toString()+m.y.toString();return 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 Ao().copy(this)}copy(r){this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=r.name;let e=r.vertices;for(let p=0,f=e.length;p<f;p++)this.vertices.push(e[p].clone());let t=r.colors;for(let p=0,f=t.length;p<f;p++)this.colors.push(t[p].clone());let o=r.faces;for(let p=0,f=o.length;p<f;p++)this.faces.push(o[p].clone());for(let p=0,f=r.faceVertexUvs.length;p<f;p++){let m=r.faceVertexUvs[p];this.faceVertexUvs[p]===void 0&&(this.faceVertexUvs[p]=[]);for(let h=0,y=m.length;h<y;h++){let g=m[h],x=[];for(let b=0,w=g.length;b<w;b++){let S=g[b];x.push(S.clone())}this.faceVertexUvs[p].push(x)}}let i=r.morphTargets;for(let p=0,f=i.length;p<f;p++){let m={};if(m.name=i[p].name,i[p].vertices!==void 0){m.vertices=[];for(let h=0,y=i[p].vertices.length;h<y;h++)m.vertices.push(i[p].vertices[h].clone())}if(i[p].normals!==void 0){m.normals=[];for(let h=0,y=i[p].normals.length;h<y;h++)m.normals.push(i[p].normals[h].clone())}this.morphTargets.push(m)}let s=r.morphNormals;for(let p=0,f=s.length;p<f;p++){let m={};if(s[p].vertexNormals!==void 0){m.vertexNormals=[];for(let h=0,y=s[p].vertexNormals.length;h<y;h++){let g=s[p].vertexNormals[h],x={};x.a=g.a.clone(),x.b=g.b.clone(),x.c=g.c.clone(),m.vertexNormals.push(x)}}if(s[p].faceNormals!==void 0){m.faceNormals=[];for(let h=0,y=s[p].faceNormals.length;h<y;h++)m.faceNormals.push(s[p].faceNormals[h].clone())}this.morphNormals.push(m)}let a=r.skinWeights;for(let p=0,f=a.length;p<f;p++)this.skinWeights.push(a[p].clone());let c=r.skinIndices;for(let p=0,f=c.length;p<f;p++)this.skinIndices.push(c[p].clone());let u=r.lineDistances;for(let p=0,f=u.length;p<f;p++)this.lineDistances.push(u[p]);let l=r.boundingBox;l!==null&&(this.boundingBox=l.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 Ed().fromGeometry(this),e=new fy,t=new Float32Array(r.vertices.length*3);if(e.setAttribute("position",Ml.call(new As(t,3),r.vertices)),r.normals.length>0){let o=new Float32Array(r.normals.length*3);e.setAttribute("normal",Ml.call(new As(o,3),r.normals))}if(r.colors.length>0){let o=new Float32Array(r.colors.length*3);e.setAttribute("color",hy.call(new As(o,3),r.colors))}if(r.uvs.length>0){let o=new Float32Array(r.uvs.length*2);e.setAttribute("uv",yy.call(new As(o,2),r.uvs))}if(r.uvs2.length>0){let o=new Float32Array(r.uvs2.length*2);e.setAttribute("uv2",yy.call(new As(o,2),r.uvs2))}e.groups=r.groups;for(let o in r.morphTargets){let i=[],s=r.morphTargets[o];for(let a=0,c=s.length;a<c;a++){let u=s[a],l=new ui(u.data.length*3,3);l.name=u.name,i.push(Ml.call(l,u.data))}e.morphAttributes[o]=i}if(r.skinIndices.length>0){let o=new ui(r.skinIndices.length*4,4);e.setAttribute("skinIndex",gy.call(o,r.skinIndices))}if(r.skinWeights.length>0){let o=new ui(r.skinWeights.length*4,4);e.setAttribute("skinWeight",gy.call(o,r.skinWeights))}return r.boundingSphere!==null&&(e.boundingSphere=r.boundingSphere.clone()),r.boundingBox!==null&&(e.boundingBox=r.boundingBox.clone()),e}computeTangents(){console.error("THREE.Geometry: .computeTangents() has been removed.")}computeLineDistances(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")}applyMatrix(r){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(r)}dispose(){this.dispatchEvent({type:"dispose"})}static createBufferGeometryFromObject(r){let e=new fy,t=r.geometry;if(r.isPoints||r.isLine){let o=new ui(t.vertices.length*3,3),i=new ui(t.colors.length*3,3);if(e.setAttribute("position",Ml.call(o,t.vertices)),e.setAttribute("color",hy.call(i,t.colors)),t.lineDistances&&t.lineDistances.length===t.vertices.length){let s=new ui(t.lineDistances.length,1);e.setAttribute("lineDistance",hT.call(s,t.lineDistances))}t.boundingSphere!==null&&(e.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(e.boundingBox=t.boundingBox.clone())}else r.isMesh&&(e=t.toBufferGeometry());return e}};Ao.prototype.isGeometry=!0;var Ed=class{constructor(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}computeGroups(r){let e=[],t,o,i,s=r.faces;for(o=0;o<s.length;o++){let a=s[o];a.materialIndex!==i&&(i=a.materialIndex,t!==void 0&&(t.count=o*3-t.start,e.push(t)),t={start:o*3,materialIndex:i})}t!==void 0&&(t.count=o*3-t.start,e.push(t)),this.groups=e}fromGeometry(r){let e=r.faces,t=r.vertices,o=r.faceVertexUvs,i=o[0]&&o[0].length>0,s=o[1]&&o[1].length>0,a=r.morphTargets,c=a.length,u;if(c>0){u=[];for(let g=0;g<c;g++)u[g]={name:a[g].name,data:[]};this.morphTargets.position=u}let l=r.morphNormals,d=l.length,p;if(d>0){p=[];for(let g=0;g<d;g++)p[g]={name:l[g].name,data:[]};this.morphTargets.normal=p}let f=r.skinIndices,m=r.skinWeights,h=f.length===t.length,y=m.length===t.length;t.length>0&&e.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let g=0;g<e.length;g++){let x=e[g];this.vertices.push(t[x.a],t[x.b],t[x.c]);let b=x.vertexNormals;if(b.length===3)this.normals.push(b[0],b[1],b[2]);else{let S=x.normal;this.normals.push(S,S,S)}let w=x.vertexColors;if(w.length===3)this.colors.push(w[0],w[1],w[2]);else{let S=x.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 kt,new kt,new kt))}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 kt,new kt,new kt))}for(let S=0;S<c;S++){let P=a[S].vertices;u[S].data.push(P[x.a],P[x.b],P[x.c])}for(let S=0;S<d;S++){let P=l[S].vertexNormals[g];p[S].data.push(P.a,P.b,P.c)}h&&this.skinIndices.push(f[x.a],f[x.b],f[x.c]),y&&this.skinWeights.push(m[x.a],m[x.b],m[x.c])}return this.computeGroups(r),this.verticesNeedUpdate=r.verticesNeedUpdate,this.normalsNeedUpdate=r.normalsNeedUpdate,this.colorsNeedUpdate=r.colorsNeedUpdate,this.uvsNeedUpdate=r.uvsNeedUpdate,this.groupsNeedUpdate=r.groupsNeedUpdate,r.boundingSphere!==null&&(this.boundingSphere=r.boundingSphere.clone()),r.boundingBox!==null&&(this.boundingBox=r.boundingBox.clone()),this}},pi=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 ut,this.vertexNormals=Array.isArray(o)?o:[],this.color=i&&i.isColor?i:new Ld,this.vertexColors=Array.isArray(i)?i:[],this.materialIndex=s}clone(){return new this.constructor().copy(this)}copy(r){this.a=r.a,this.b=r.b,this.c=r.c,this.normal.copy(r.normal),this.color.copy(r.color),this.materialIndex=r.materialIndex;for(let e=0,t=r.vertexNormals.length;e<t;e++)this.vertexNormals[e]=r.vertexNormals[e].clone();for(let e=0,t=r.vertexColors.length;e<t;e++)this.vertexColors[e]=r.vertexColors[e].clone();return this}};function hT(n){return this.array.set(n),this}function hy(n){let r=this.array,e=0;for(let t=0,o=n.length;t<o;t++){let i=n[t];i===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",t),i=new Ld),r[e++]=i.r,r[e++]=i.g,r[e++]=i.b}return this}function yy(n){let r=this.array,e=0;for(let t=0,o=n.length;t<o;t++){let i=n[t];i===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",t),i=new kt),r[e++]=i.x,r[e++]=i.y}return this}function Ml(n){let r=this.array,e=0;for(let t=0,o=n.length;t<o;t++){let i=n[t];i===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",t),i=new ut),r[e++]=i.x,r[e++]=i.y,r[e++]=i.z}return this}function gy(n){let r=this.array,e=0;for(let t=0,o=n.length;t<o;t++){let i=n[t];i===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",t),i=new mT),r[e++]=i.x,r[e++]=i.y,r[e++]=i.z,r[e++]=i.w}return this}var gT=["a","b","c"];function xT(n,r){switch(r){case"c":return n.c;case"b":return n.b;case"a":default:return n.a}}function Bd(n,r,e){let t=Math.min(n,r),o=Math.max(n,r),i=t+"_"+o;return e.get(i)}function Rd(n,r,e,t,o,i){let s=Math.min(n,r),a=Math.max(n,r),c=s+"_"+a,u;if(t.has(c))u=t.get(c);else{let l=e[s],d=e[a];u={a:l,b:d,newEdge:null,faces:[]},t.set(c,u)}u.faces.push(o),i[n].edges.push(u),i[r].edges.push(u)}function vT(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],Rd(s.a,s.b,n,t,s,e),Rd(s.b,s.c,n,t,s,e),Rd(s.c,s.a,n,t,s,e)}function El(n,r,e,t,o){n.push(new pi(r,e,t,void 0,void 0,o))}function fi(n,r){return Math.abs(r-n)/2+Math.min(n,r)}function Ll(n,r,e,t){n.push([r.clone(),e.clone(),t.clone()])}var Dl=class{constructor(r=1){this.subdivisions=r}modify(r){r instanceof yT?r=new Ao().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 vy,t,o,i,s,a,c=r.vertices,u=r.faces,l=r.faceVertexUvs[0],d=l!==void 0&&l.length>0,p=[],f=new Map;vT(c,u,p,f);let m=[],h,y,g,x,b,w,S;for(let j of Array.from(f.keys())){for(y=f.get(j),g=new vy,b=3/8,w=1/8,S=y.faces.length,S!=2&&(b=.5,w=0,S!=1),g.addVectors(y.a,y.b).multiplyScalar(b),e.set(0,0,0),s=0;s<S;s++){for(x=y.faces[s],a=0;a<3&&(h=c[xT(x,gT[a])],!(h!==y.a&&h!==y.b));a++);h&&e.add(h)}e.multiplyScalar(w),g.add(e),y.newEdge=m.length,m.push(g)}let P,_,v,N,T,C,O,A=[];for(o=0,i=c.length;o<i;o++){for(C=c[o],T=p[o].edges,t=T.length,t==3?P=3/16:t>3&&(P=3/(8*t)),_=1-t*Number(P),v=P,t<=2&&(t==2?(_=3/4,v=1/8):t==1||t==0),O=C.clone().multiplyScalar(_),e.set(0,0,0),s=0;s<t;s++)N=T[s],h=N.a!==C?N.a:N.b,e.add(h);e.multiplyScalar(Number(v)),O.add(e),A.push(O)}let R=A.concat(m),U=A.length,$,ee,Y,q=[],H=[],V,G,D,L,B=new Dd,X=new Dd,W=new Dd;for(o=0,i=u.length;o<i;o++)x=u[o],$=Number(Bd(x.a,x.b,f).newEdge)+U,ee=Number(Bd(x.b,x.c,f).newEdge)+U,Y=Number(Bd(x.c,x.a,f).newEdge)+U,El(q,$,ee,Y,x.materialIndex),El(q,x.a,$,Y,x.materialIndex),El(q,x.b,ee,$,x.materialIndex),El(q,x.c,Y,ee,x.materialIndex),d&&(V=l[o],G=V[0],D=V[1],L=V[2],B.set(fi(G.x,D.x),fi(G.y,D.y)),X.set(fi(D.x,L.x),fi(D.y,L.y)),W.set(fi(G.x,L.x),fi(G.y,L.y)),Ll(H,B,X,W),Ll(H,G,B,W),Ll(H,D,X,B),Ll(H,L,W,X));r.vertices=R,r.faces=q,d&&(r.faceVertexUvs[0]=H)}};var Ze=new ST,wy=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=n.geometry??r?.geometry??new by().copy(new Sy(100,100,100)),t;r===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(Ze),t={width:Ze.x,height:Ze.y,depth:Ze.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 by().copy(new Sy(100,100,100)),s=i.userData.parameters;s===void 0?(i.computeBoundingBox(),i.boundingBox.getSize(Ze)):Ze.set(s.width,s.height,s.depth),(r!==Ze.x||e!==Ze.y||t!==Ze.z)&&i.scale(Ze.x===0?1:r/Ze.x,Ze.y===0?1:e/Ze.y,Ze.z===0?1:t/Ze.z);let a=i.originalGeometry;try{o>0?(a===void 0||s?.subdivisions!==o)&&(a===void 0&&(a=i),i=new Dl(o).modify(a).toBufferGeometry()):(a!==void 0&&(i=a),a=void 0,i.getAttribute("normal")===void 0&&i.computeVertexNormals())}catch{a!==void 0&&(i=a),a=void 0,i.getAttribute("normal")===void 0&&i.computeVertexNormals()}return a!==void 0&&Object.assign(i,{originalGeometry:a}),delete n.geometry,Object.assign(i,{userData:{...n,type:"NonParametricGeometry"}})}static loadFromUrl(n,r,e){new bT(e).load(n,o=>{let i=this.normalizeInputs({geometry:o});o.boundingBox.getSize(Ze);let s=100/Ze.x;Object.assign(i.parameters,{width:100,height:Ze.y*s,depth:Ze.z*s}),r(this.build(i))})}};var Bl=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 _e?n.shape:new _e,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(n){let{width:r,height:e,spikes:t,cornerRadius:o,depth:i,extrudeBevelSize:s,extrudeBevelSegments:a}=n.parameters,c=n.shape,u=r*.5,l=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,x=p+Math.cos(y)*l;c.addPoint(c.createPoint(g,x))}c.isClosed=!0;for(let h=0,y=c.points.length;h<y;h++)c.points[h].roundness=o;c.roundness=o,c.update();let m=Mt.create({shape:c,parameters:{roundness:o,depth:i,extrudeBevelSize:s,extrudeBevelSegments:a}});return Object.assign(m,{userData:{...n,type:"PolygonGeometry"}})}};import{BufferGeometry as wT,Float32BufferAttribute as Gd,Vector2 as Cr,Vector3 as ot}from"three";var _y=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:r,height:e,depth:t,radialSegments:o,heightSegments:i,openEnded:s,cornerRadius:a,cornerSegments:c}=n.parameters,u=new zd(r*.5,e,o,i,s,a,c);return u.scale(1,1,t/r),Object.assign(u,{userData:{...n,type:"PyramidGeometry"}})}};function Cs(n,r,e){e.x=n.x*r.x,e.y=n.y,e.z=n.x*r.y}function Vd(n,r,e,t,o,i){let s=r.clone().sub(n),a=e.clone().sub(n),c=s.angleTo(a);if(s.normalize(),a.normalize(),t===o){let u=s.add(a).normalize();i.copy(n).addScaledVector(u,t/Math.sin(c/2))}else{let u=s.angleTo(a);i.copy(n),i.addScaledVector(s,o/Math.sin(u)),i.addScaledVector(a,t/Math.sin(u))}}function _T(n,r,e){let t=n.clone().sub(r),o=e.clone().sub(r);return t.projectOnVector(o),t.add(r)}var zd=class extends wT{constructor(r=.5,e=1,t=4,o=1,i=!1,s=0,a=4){super(),t=Math.floor(Math.max(3,t)),o=Math.floor(o),a=Math.floor(a);let c=[],u=[],l=[],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,x=Math.PI-g,b=new ot(0,-f,0),w=new ot(0,f,0),S=new Cr(r,-f),P=new Cr(h,-f),_=new Cr(0,w.y).sub(P),v=new Cr(0,w.y).sub(S),N=new Cr(_.y,-_.x).normalize(),T=new Cr(v.y,-v.x).normalize(),O=r*Math.cos(Math.PI/t)*Math.tan((Math.PI-_.angle())/2)-1e-8;s=Math.min(s,O);let A;{let H=new ot(N.x,N.y,0),V=new ot(Math.cos(y)*H.x,H.y,Math.sin(y)*H.x);A=H.angleTo(V)}let R=s/Math.tan((Math.PI-_.angle())/2),U=s/Math.tan((Math.PI-A)/2),$=new ot;if(!i){u.push(b.x,b.y,b.z),l.push(0,-1,0),d.push(0,0);let H=p++,V=[],G=S.clone(),D=R/Math.cos(Math.PI/t);G.x-=D;for(let L=0;L<t;L++){let B=L/t*Math.PI*2+m,X=new Cr(Math.sin(B),Math.cos(B));Cs(G,X,$),u.push($.x,$.y,$.z),l.push(0,-1,0),d.push(0,0),V.push(p++)}for(let L=0;L<V.length;L++)c.push(V[L],H,V[(L+1)%V.length])}let ee=[];{let H=new ot,V=new ot,G=new ot,D=new ot,L=new ot,B=new ot;for(let X=0;X<t;X++){let W=X/t*Math.PI*2+m,j=(X+.5)/t*Math.PI*2+m,F=(X+1)/t*Math.PI*2+m,M=new Cr(Math.sin(W),Math.cos(W)),Q=new Cr(Math.sin(j),Math.cos(j)),re=new Cr(Math.sin(F),Math.cos(F));Cs(S,M,V),Cs(S,re,G),Cs(N,Q,H),Vd(w,V,G,U,U,D),u.push(D.x,D.y,D.z),Vd(V,w,G,U,R,L),u.push(L.x,L.y,L.z),Vd(G,V,w,R,U,B),u.push(B.x,B.y,B.z),l.push(H.x,H.y,H.z),l.push(H.x,H.y,H.z),l.push(H.x,H.y,H.z),d.push(0,0),d.push(0,0),d.push(0,0);let oe=p++,K=p++,te=p++;if(c.push(oe,K,te),s>0){{let ce=V.clone().add(G).multiplyScalar(.5),se=w.clone().sub(ce).normalize(),ze=b.clone().sub(ce).normalize().add(se).normalize().multiplyScalar(-1),ge=B.clone().sub(L);Y(ce,ge,ze,_.angle())}let J,ie;{let ce=new ot;Cs(T,re,ce);let se=B.clone().add(D).multiplyScalar(.5);se=_T(se,G,w);let fe=B.clone().sub(D);[J,ie]=Y(se,fe,ce,A,D.y)}{let ce=J,se=ce.clone().setY(0).normalize(),fe=new ot(0,-1,0),ze=se.clone().cross(fe);q(ce,se,fe,ze)}ee.concat(ie);{let ce=_.angle(),se=Math.PI-ce,fe=w.clone();fe.y-=s/Math.sin(ce-Math.PI/2);let ze=new ot,ge=[];for(let Oe=0;Oe<a;Oe++){let Ot=[],Wt=Math.PI/2-se*Oe/a,pn=Math.cos(Wt),Rt=Math.sin(Wt),ra=j;for(let oa=0;oa<=Oe;oa++){let na=Math.cos(ra),Ue=Math.sin(ra);H.x=pn*Ue,H.y=Rt,H.z=pn*na,ze.copy(fe).addScaledVector(H,s),u.push(ze.x,ze.y,ze.z),l.push(H.x,H.y,H.z),d.push(0,0),Ot.push(p++),ra+=Math.PI*2/Oe/t}ge.push(Ot)}ie.reverse(),ge.push(ie);let qe=ge.length-1;for(let Oe=0;Oe<qe;Oe++){let Ot=ge[Oe],Wt=ge[Oe+1],pn=Ot.length-1;c.push(Wt[1],Ot[0],Wt[0]);for(let Rt=1;Rt<=pn;Rt++)c.push(Ot[Rt],Ot[Rt-1],Wt[Rt]),c.push(Wt[Rt+1],Ot[Rt],Wt[Rt])}}}}}this.setIndex(c),this.setAttribute("position",new Gd(u,3)),this.setAttribute("normal",new Gd(l,3)),this.setAttribute("uv",new Gd(d,2));function Y(H,V,G,D,L){let B=-D/2,X=(Math.PI-D)/2,W=V.clone().normalize().cross(G);H.addScaledVector(G,-s/Math.sin(X));let j=new ot,F=new ot,M=1,Q=p,re=[];for(let oe=0;oe<=a;oe++){let K=B+oe/a*D;F.set(0,0,0),F.addScaledVector(W,Math.sin(K)),F.addScaledVector(G,Math.cos(K));for(let te=0;te<=M;te++){let J=te/M-.5;if(j.copy(H),j.addScaledVector(V,J),j.addScaledVector(F,s),L!=null){let ie=Math.max(0,j.y-L);j.addScaledVector(V,-ie/V.y)}u.push(j.x,j.y,j.z),l.push(F.x,F.y,F.z),d.push(0,0),te===0&&re.push(p),p++}}for(let oe=0;oe<a;oe++)for(let K=0;K<M;K++){let te=Q+K+(M+1)*oe,J=te+(M+1),ie=J+1,ce=te+1;c.push(te,J,ce),c.push(J,ie,ce)}return[H.clone().addScaledVector(V,.5),re]}function q(H,V,G,D){let L=Math.PI/2,B=v.angle()-L,X=[],W=new ot,j=new ot;for(let M=0;M<=a;M++){let Q=[],re=M/a;for(let oe=0;oe<=M;oe++){let te=((M?oe/M:0)-.5)*x,J=Math.cos(te),ie=Math.sin(te),ce=Math.atan(Math.tan(B)*J),se=(L+ce)*re,fe=Math.cos(se),ze=Math.sin(se);W.set(0,0,0),W.addScaledVector(V,ze*J),W.addScaledVector(G,fe),W.addScaledVector(D,ze*ie),j.copy(H).addScaledVector(W,s),u.push(j.x,j.y,j.z),l.push(W.x,W.y,W.z),d.push(0,0),Q.push(p++)}X.push(Q)}let F=X.length-1;for(let M=0;M<F;M++){let Q=X[M],re=X[M+1],oe=Q.length-1;c.push(Q[0],re[1],re[0]);for(let K=1;K<=oe;K++)c.push(Q[K-1],Q[K],re[K]),c.push(Q[K],re[K+1],re[K])}}}};var Rl=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 _e?n.shape:new _e,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)}),ui:t}}static build(n){let r=n.shape,{width:e,height:t,cornerRadius:o,cornerType:i,depth:s,extrudeBevelSize:a,extrudeBevelSegments:c}=n.parameters,u={x:e*.5,y:t*.5},l={x:-u.x,y:-u.y},d={x:u.x,y:u.y};function p(w,S,P){return S>e&&P>t?Math.min(w*e/S,w*t/P):S>e?w*e/S:P>t?w*t/P:w}let f=[];f[0]=o[0]===0?0:p(o[0],o[0]+o[3],o[0]+o[1]),f[1]=o[1]===0?0:p(o[1],o[1]+o[2],o[1]+o[0]),f[2]=o[2]===0?0:p(o[2],o[2]+o[1],o[2]+o[3]),f[3]=o[3]===0?0:p(o[3],o[3]+o[0],o[3]+o[2]);let m=l.x,h=d.x,y=d.y,g=l.y;r.addPoint(r.createPoint(m,y)),r.addPoint(r.createPoint(h,y)),r.addPoint(r.createPoint(h,g)),r.addPoint(r.createPoint(m,g)),r.isClosed=!0;let x=!0;for(let w=0,S=r.points.length;w<S;w++)r.points[w].roundness=f[w],w>0&&f[w]!==f[w-1]&&(x=!1);x&&(r.roundness=f[0]),r.useCubicForRoundedCorners=i!==1,r.update();let b=Mt.create({shape:r,parameters:{depth:s,extrudeBevelSize:a,extrudeBevelSegments:c}});return Object.assign(b,{userData:{...n,type:"RectangleGeometry"}})}};import{SphereGeometry as PT}from"three";var Py=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:r=100,height:e=r,depth:t=r,widthSegments:o=64,heightSegments:i=64,phiStart:s,phiLength:a,thetaStart:c,thetaLength:u}=n.parameters,l=new PT(.5*r,o,i,s,a,c,u);return l.scale(1,e/r,t/r),Object.assign(l,{userData:{...n,type:"SphereGeometry"}})}};import{PlaneGeometry as TT}from"three";var Ty=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 TT(r,e,t,o);return i.scale(1,1,1),Object.assign(i,{userData:{...n,type:"PlaneGeometry"}})}};import{BufferGeometry as OT,Float32BufferAttribute as jd,Vector3 as AT}from"three";var Oy=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:r,height:e,depth:t,angle:o,cornerRadius:i,cornerSegments:s}=n.parameters,a=new Fd(r,e,t,o,i,s);return Object.assign(a,{userData:{...n,type:"BackdropGeometry"}})}},Fd=class extends OT{constructor(r=1,e=1,t=1,o=90,i=10,s=24){super(),this.type="BackdropGeometry";let a=[],c=[],u=[],l=.001;i==0&&(s=1),s=Math.max(1,Math.floor(s)),i=Math.min(i,100),o=Math.min(180-l,o),o*=Math.PI/180;let d=[],p=Math.PI/2,f=(j=0,F=0,M=0)=>new AT(j,F,M),m=f(),h=f(),[y,g,x]=[e/2,r/2,t/2],b=-g,w=+g,[S,P,_]=[f(b,-y,+x),f(b,-y,-x),f(b,+y,-x)],v=(j,F=!1)=>Math.sin(j-Math.PI/(1+ +F)),N=(j,F=!1)=>Math.cos(j-Math.PI/(1+ +F));_.y=Math.sin(o)*e-y;let T=Math.cos(o)*e-x,C=S.z-l;o<=p?(_.z=Math.min(T,C),_.z==C&&(_.y-=(T-C)/Math.tan(p-o))):P.z=Math.min(P.z-T-x,S.z-l),m.subVectors(S,P),h.subVectors(_,P);let O=Math.min(m.length(),h.length())*i/100,A=O*Math.tan(o/2),R=O/Math.cos(o/2),U=m.clone().normalize().add(h.normalize()).setLength(R).add(P);m.set(0,v(o,!0),N(o,!0)),d.push([_,m.clone()]);let $=(Math.PI-o)/s;for(let j=0;j<=s;j++){let F=p+o+j*$;m.set(0,Math.sin(F)*A,Math.cos(F)*A),m.add(U),h.set(0,v(F),N(F)),d.push([m.clone(),h.clone()])}d.push([S,f(0,1,0)]);let ee=Math.sin($/2)*A*2,Y=d.length-1,q=d[0][0].distanceTo(d[1][0]),H=d[Y-1][0].distanceTo(d[Y][0]),V=q+ee*s+H;d[0].push(1);for(let j=0;j<=s;j++)d[j+1].push(1-(q+j*ee)/V);d[Y].push(0);let[G,D,L]=d[0],B,X,W;for(let j=1;j<d.length;j++)[B,X,W]=d[j],a.push(b,G.y,G.z,b,B.y,B.z,w,G.y,G.z,w,G.y,G.z,b,B.y,B.z,w,B.y,B.z),c.push(0,D.y,D.z,0,X.y,X.z,0,D.y,D.z,0,D.y,D.z,0,X.y,X.z,0,X.y,X.z),u.push(0,L,0,W,1,L,1,L,0,W,1,W),[G,D,L]=[B,X,W];this.setAttribute("position",new jd(a,3)),this.setAttribute("normal",new jd(c,3)),this.setAttribute("uv",new jd(u,2))}};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,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters);return{shape:n.shape&&n.shape instanceof _e?n.shape:new _e,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(n){let{width:r,height:e,innerRadiusPercent:t,spikes:o,cornerRadius:i,angle:s,depth:a,extrudeBevelSize:c,extrudeBevelSegments:u}=n.parameters,l=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,x=p*t/100;if(o===3&&t===50){h=2*Math.PI/o;for(let w=0;w<o;w++){let S=h*w,P=f+Math.sin(S)*d,_=m+Math.cos(S)*p;l.addPoint(l.createPoint(P,_))}}else for(let w=0;w<o;w++){let S=f+Math.cos(y)*d,P=m+Math.sin(y)*p;l.addPoint(l.createPoint(S,P)),y+=h,S=f+Math.cos(y)*g,P=m+Math.sin(y)*x,w<=o,l.addPoint(l.createPoint(S,P)),y+=h}l.isClosed=!0;for(let w=0,S=l.points.length;w<S;w++)l.points[w].roundness=i;l.roundness=i,l.update();let b=Mt.create({shape:l,parameters:{roundness:i,depth:a,extrudeBevelSize:c,extrudeBevelSegments:u}});return Object.assign(b,{userData:{...n,type:"StarGeometry"}})}};import{PlaneGeometry as CT}from"three";var Ay=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 CT(r,e);return Object.assign(t,{userData:{...n,type:"TextFrameGeometry"}})}};var Cy=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:Math.PI*2,cornerRadius:30,cornerSegments:8},n.parameters),t=Math.abs(e.width),o=Math.abs(e.height??e.width),i=Math.round(Math.abs(e.depth??e.width*.25));return{parameters:Object.assign(e,{width:t,height:o,depth:i})}}static build(n){let{width:r,height:e,depth:t,radialSegments:o,tubularSegments:i,arc:s,cornerRadius:a,cornerSegments:c}=n.parameters,u=NT(r,e,t,r*.5,s,i,0,0,o,a,c);return u.scale(1,e/r,1),Object.assign(u,{userData:{...n,type:"TorusGeometry"}})}};function NT(n,r,e,t,o,i,s,a,c,u,l){return[r,e]=[e,r],s=r/2,o/=2*Math.PI,o==1&&(u=0),new Ts(!0,n,r,e,t,o,i,s,a,c,u,l)}import{TorusKnotGeometry as IT}from"three";var Ny=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),tube:e.tube??e.width*.125})}}static build(n){let{width:r,tube:e,tubularSegments:t,radialSegments:o,p:i,q:s}=n.parameters,a=r*.5;a!==e&&(a-=e);let c=new IT(a,e,t,o,i,s);return Object.assign(c,{userData:{...n,type:"TorusKnotGeometry"}})}};var Iy=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 _e?n.shape:new _e,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width*(e.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(e.depth??0)})}}static build(n){let{width:r=100,height:e,cornerRadius:t,depth:o,extrudeBevelSize:i,extrudeBevelSegments:s,isRect:a}=n.parameters,c=n.shape,u=r*.5,l=e*.5;a?(c.addPoint(c.createPoint(-u,l)),c.addPoint(c.createPoint(u,-l)),c.addPoint(c.createPoint(-u,-l))):(c.addPoint(c.createPoint(0,l)),c.addPoint(c.createPoint(u,-l)),c.addPoint(c.createPoint(-u,-l))),c.isClosed=!0;for(let p=0,f=c.points.length;p<f;p++)c.points[p].roundness=t;c.roundness=t,c.update();let d=Mt.create({shape:c,parameters:{roundness:t,depth:o,extrudeBevelSize:i,extrudeBevelSegments:s}});return Object.assign(d,{userData:{...n,type:"TriangleGeometry"}})}};import{Vector2 as Ey,Vector3 as nt,Matrix4 as Ns,BufferGeometry as Ly,BufferAttribute as kd,MathUtils as Ud}from"three";function My(n,r){let e=2*Math.PI;return(n%e+e)%e===(r%e+e)%e}function MT(n,r,e){let t=[new nt,new nt,new nt],o=[new nt,new nt,new nt];return n.extractBasis(t[0],t[1],t[2]),r.extractBasis(o[0],o[1],o[2]),t.forEach((i,s)=>{let a=o[s],c=Ud.lerp(i.length(),a.length(),e);i.lerp(a,e).setLength(c)}),new Ns().makeBasis(t[0],t[1],t[2])}var Dy=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??di.create({parameters:Wc}).userData.shape;return{path:n.path??qn.defaultData(),parameters:Object.assign(e,{width:t,height:o,depth:i,extrusion:{...ol,...e.extrusion}}),shapeData:s}}static build(n){if(n.path.points.length>=2){let e=new Hd(n);return Object.assign(e,{userData:{...n,type:"PathGeometry"}})}else return Object.assign(new Ly,{userData:{...n,type:"PathGeometry"}})}},Hd=class extends Ly{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)||!My(e.twist,0)||e.startScale!==e.endScale}build(){let e=this._extractPathPoints();if(e.length<2)return;let t=this._computeBasisMatrices(e),{depth:o,offset:i}=this.inputs.parameters.extrusion,s=this.inputs.path.isClosed?e.length:e.length-1,a=Math.floor(i*s),c=this.inputs.path.isClosed?Math.ceil((o+i)*s):Math.ceil(Math.min(1,o+i)*s),u=Math.min(Math.max(2,c-a+1),s+2),l=[],d=[];for(let O=0;O<u;O++){let A=this.inputs.path.isClosed?(O+a)%e.length:Math.min(O+a,e.length-1);l.push(e[A].clone()),d.push(t[A].clone())}let p=(O,A,R)=>{l[O]=l[O].clone().lerp(l[A],R),d[O]=MT(d[O],d[A],R)},f=0,m=i*s%1;(!this.inputs.path.isClosed||o<=1)&&(m||i===0)&&(f=m,p(0,1,f));let h=0,y=(i+o)*s%1;if((this.inputs.path.isClosed&&o<=1||!this.inputs.path.isClosed&&i+o<1)&&y&&(h=y,p(l.length-1,l.length-2,1-h)),o===0){let O=l.length-1;l[O].copy(l[0]),d[O].copy(d[0])}this._applyPathModifiers(d,f,h);let{regions:g,infos:x,vertices:b}=this._computeShapePoints(5),w=0,S=0;x.sort((O,A)=>O.start-A.start),x.forEach(O=>{O.verticesStart=w,O.verticesCount=O.continuous.reduce((A,R,U)=>A+(U===0||!R?2:1),0),S+=O.verticesCount,w=S});let P=S*u,_,v=0;if(this._isOpenEnded()){try{_=sr({windingRule:be.ODD,elementType:Ge.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:g})}catch{_=Cd}v=_.vertexCount}let N=P+2*v,T={positions:new Float32Array(N*3),normals:new Float32Array(N*3),uvs:new Float32Array(N*2)},C=[];x.forEach(O=>{this._extrudeRegion(O,b,d,l,T,C,this._isGeometryClosed()&&!this._isOpenEnded())}),_&&(this._closeEnd(_,P,C,T,d[0],l[0],!1),this._closeEnd(_,P+v,C,T,d[d.length-1],l[l.length-1],!0)),this.setAttribute("position",new kd(T.positions,3)),this.setAttribute("normal",new kd(T.normals,3)),this.setAttribute("uv",new kd(T.uvs,2)),this.setIndex(C)}_extractPathPoints(){let t=xl(this.inputs.path).getPoints(this.inputs.path.subdivisions);if(t.length<2)return[];let o=[t[0]];return t.forEach(s=>{o[o.length-1].distanceToSquared(s)>.001&&o.push(s)}),this.inputs.path.isClosed&&o[o.length-1].distanceTo(o[0])<.001&&o.pop(),o}_computeBasisMatrices(e){let t=[],o=e.length,i=this.inputs.path.isClosed,s=new nt,a=new nt,c=new nt,u=new nt,l=new nt(0,1,0);for(let y=0;y<o;y++){let g=e[y],x;y===0?x=i?e[e.length-2]:g.clone().multiplyScalar(2).sub(e[1]):x=e[y-1];let b;y===o-1?b=i?e[1]:g.clone().multiplyScalar(2).sub(e[y-1]):b=e[y+1];let w=g.clone().sub(x).normalize(),S=b.clone().sub(g).normalize(),P=w.clone().add(S).normalize();c.copy(P),y===0&&(P.equals(l)||P.clone().negate().equals(l))&&l.set(0,0,1);let _=l.clone().cross(P).normalize(),v=P.clone().cross(_).normalize();l.copy(v),u.copy(_),y===0&&(s.copy(v),a.copy(P));let N=new Ns().makeBasis(_,v,P);t.push(N)}let d=i?a:c,p=i?s:new nt(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 Ns().makeRotationZ(m*y/t.length);t[y].multiply(g)}return t}_applyPathModifiers(e,t,o){let i=e.length,{angle:s,twist:a,startScale:c,endScale:u}=this.inputs.parameters.extrusion,l=new Ns,d=new Ns;return e.forEach((p,f)=>{let m=f===0?0:f===i-1?1:(f-t)/(i-(o===0?0:1)-(t+(1-o)));l.makeRotationZ(Ud.lerp(s,s+a,m));let h=Ud.lerp(c,u,m);d.makeScale(h,h,h),p.multiply(l).multiply(d)}),e}_computeShapePoints(e=12,t=be.ODD){let o=this.inputs.shapeData,i=o.extractShapePointsToFlatArray([],e),s=o.shapeHoles.map(h=>{let y=h.extractShapePointsToFlatArray([],e),g=[];for(let x=y.length-1;x>=1;x-=2){let b=y[x-1],w=y[x-0];g.push(b,w)}return g}),a;try{a=sr({windingRule:t,elementType:Ge.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[i]})}catch{a=Ps}let c;try{c=sr({windingRule:be.ODD,elementType:Ge.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...s]})}catch{c=Ad}if(!a)throw new Error("error generating geometry");let u=a.elementCount;if(c){a.elementCount+=c.elementCount;for(let h=0;h<c.elements.length;h++){let y=c.elements[h],g=h%2===0?a.vertexCount:0;a.elements.push(y+g)}for(let h=0;h<c.vertexIndices.length;h++){let y=c.vertexIndices[h],g=a.vertexCount;a.vertexIndices.push(y+g)}for(let h=0;h<c.vertices.length;h++){let y=c.vertices[h];a.vertices.push(y)}}let l=1/0,d=-1/0,p=1/0,f=-1/0;for(let h=0,y=a.vertexCount;h<y;h++){let g=h*2,x=a.vertices[g+0],b=a.vertices[g+1];x<l&&(l=x),x>d&&(d=x),b<p&&(p=b),b>f&&(f=b)}let m=[];for(let h=a.elementCount-1;h>=0;h--){let y=h>=u,g=h*2,x=a.elements[g+0],b=a.elements[g+1],w=x+b,S={start:x,count:b,normals:[],isHole:y,continuous:[],verticesStart:0,verticesCount:0};m.push(S);let P=x,_=w-1,v=x+1,N=o.roundedCurves.length;do{let T=P-x,C=a.vertices[_*2+0],O=a.vertices[_*2+1],A=a.vertices[P*2+0],R=a.vertices[P*2+1],U=a.vertices[v*2+0],$=a.vertices[v*2+1],ee=A-C,Y=R-O,q=Math.sqrt(ee*ee+Y*Y);ee/=q,Y/=q;let H=A-U,V=R-$,G=Math.sqrt(H*H+V*V);H/=G,V/=G,S.normals[T*2+0]=-V,S.normals[T*2+1]=H;let D=a.vertexIndices[P];if(Array.isArray(D))S.continuous[T]=!1;else{let[L,B]=o.getCurveIndexFromVertexId(D-1,!0);if(B>0&&B<1)S.continuous[T]=!0;else{let X=B===1?L+1:L-1;X=(X+N)%N;let W=B===1?0:1,j=o.roundedCurves[L].getTangent(B),F=o.roundedCurves[X].getTangent(W);S.continuous[T]=j.dot(F)>.95}}y&&(S.normals[T*2+0]*=-1,S.normals[T*2+1]*=-1),[_,P,v]=[P,v,v+1],v>=w&&(v-=b)}while(v!==x+1)}return{regions:[i,...s],infos:m,vertices:a.vertices}}_insertVertex(e,t,o,i,s){let a=t*2,c=t*3;e.positions[c+0]=o.x,e.positions[c+1]=o.y,e.positions[c+2]=o.z,e.normals[c+0]=i.x,e.normals[c+1]=i.y,e.normals[c+2]=i.z,e.uvs[a+0]=s.x,e.uvs[a+1]=s.y}_extrudeRegion(e,t,o,i,s,a,c){let u=new nt,l=new nt,d=new nt,p=new nt,f=new Ey;o.forEach((h,y)=>{let g=i[y],x=e.verticesStart*o.length+e.verticesCount*y;for(let b=0;b<e.count;b++){let w=(e.start+b)*2;if(u.set(t[w+0],t[w+1],0),d.copy(u).applyMatrix4(h).add(g),e.continuous[b])p.set(e.normals[b*2+0],e.normals[b*2+1],0);else{let S=b==0?(e.start+e.count-1)*2:w-2;l.set(t[S+0],t[S+1],0),p.copy(u).sub(l),p.set(-p.y,p.x,0),e.isHole||p.negate()}if(p.applyMatrix4(h).normalize(),f.set(b===0?1:b/e.count,y/(o.length-1)),this._insertVertex(s,x,d,p,f),x++,!e.continuous[b]||b===0){if(b===0)p.set(e.normals[b*2+0],e.normals[b*2+1],0),f.set(0,y/(o.length-1));else{let S=b===e.count-1?e.start*2:w+2;l.set(t[S+0],t[S+1],0),p.copy(l).sub(u),p.set(-p.y,p.x,0),e.isHole||p.negate()}p.applyMatrix4(h).normalize(),this._insertVertex(s,x,d,p,f),x++}}});let m=o.length-1;for(let h=0;h<m;h++){let y=e.verticesStart*o.length+e.verticesCount*h,g=e.verticesStart*o.length+e.verticesCount*(h+1),x=0;for(let b=0;b<e.count;b++){(!e.continuous[b]||b===0)&&x++;let w=b===e.count-1?0:x+1,S=y+x,P=y+w,_=g+w,v=g+x;e.isHole?a.push(S,_,P,S,v,_):a.push(S,P,_,S,_,v),x++}}}_closeEnd(e,t,o,i,s,a,c){let u=e.vertexCount,l=new nt(0,0,c?-1:1).applyMatrix4(s),d=new nt,p=new Ey;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(a),this._insertVertex(i,t+m,d,l,p)}let f=e.elements;for(let m=0;m<e.elementCount;m++){let h=3*m,y=f[h+0]+t,g=f[h+(c?1:2)]+t,x=f[h+(c?2:1)]+t;o.push(y,g,x)}}};import{BufferAttribute as By,BufferGeometry as Wd}from"three";import{mergeBufferGeometries as ET}from"three/examples/jsm/utils/BufferGeometryUtils.js";function Ry(){let n=new Wd;return n.setAttribute("position",new By(new Float32Array([]),3)),n.setIndex(new By(new Uint16Array([]),1)),n}var LT=Ry().attributes,DT=12,BT=1,mi=class extends Wd{constructor(e,t){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];Object.assign(this.attributes,LT),this.userData={parameters:e,type:"TextGeometry"};let o=t.getFont(e.font);o?.isLoaded?(this.font=o,this.update(e)):this.updateFont(e.font,t).then(()=>{this.update(e),t?.requestRender()})}async updateFont(e,t){let o=t.getFont(e);o&&(this.font=o,await o.loadingPromise)}update(e){let t=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!t?.isLoaded){console.warn("Cannot update text because its font is not loaded");return}let{width:o,height:i,depth:s,extrudeBevelSize:a,extrudeBevelSegments:c,text:u,textTransform:l}=e,d=l===2?u.toUpperCase():l===3?u.toLowerCase():u,p=RT(e,t,d),{shapes:f,charWidths:m,charCoords:h}=t.generateShapes(p,e),y=o*.5,g=i*.5,x=f.map(S=>new _e().fromShape(S));this.vectorShapes=x;let b=x.map(S=>Mt.create({shape:S,parameters:{depth:s,extrudeBevelSegments:c,extrudeBevelSize:a,windingRule:s<=0?be.NONZERO:be.ODD,subdivisions:this.isLowResolution&&s>0?BT:DT}})),w=b.length?ET(b):Ry();w.translate(-y,g,0),this.dispose(),this.wrappedText=p,this.charCoords=h,this.charWidths=m,this.deleteAttribute("extrudeNormal"),Object.entries(w.attributes).forEach(([S,P])=>{this.setAttribute(S,P)}),this.setIndex(w.index),this.computeBoundingSphere()}clone(){let e=Jt(new Wd,mi.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 RT(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}import{BufferGeometry as Pd,BufferAttribute as yy,Uint32BufferAttribute as Td,Float32BufferAttribute as Od,Matrix4 as aT,Vector3 as bs,Sphere as lT,Box3 as cT,BoxGeometry as dT}from"three";var my,ti=new Promise(n=>{my=n});var hy=Sn(async()=>{let r=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@0.9.384/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});my(i)});import{BufferGeometryLoader as nT}from"three";function Bo(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=we.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 nT().parse(n);else{if(n.type==="SubdivGeometry")return new He(n,e);if(n.type==="TextGeometry")return new ei(n,r)}let o;try{o=_d(t)}catch(i){console.error(i)}if(!o){let i=we.createFromState(Mn.defaultData(),100,100);t.shape=i,o=_d(t)}return o}import{Matrix4 as iT}from"three";var sT=new iT;function vs(n,r,e,t){let o=n.position.array,i=n.normal.array,s=sT.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 cT,ri=new bs,de;ti.then(n=>{de=n});var gy=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),xy=new Uint32Array([0,1,2,3]),vy=new Uint8Array([4]),He=class extends Pd{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=lo.div(t,o);this.subdividedGeometry&&vs(this.subdividedGeometry.attributes,...i),this.originalGeometry&&vs(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(ri.fromArray(i));let l=ri.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}=He.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new dT(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&&(He.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new lT,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(ri);let i={width:ri.x,height:ri.y,depth:ri.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=He.allocate(e,i)}catch(a){console.error(a,e),s=He.allocate({positionWASM:gy,indexWASM:xy,verticesPerFaceWASM:vy},i)}if(de.set_destination_refinement_level(s,0),l=He.buildLevel(s,!0,u),e.subdivisions>0)try{de.set_destination_refinement_level(s,e.subdivisions),c=He.buildLevel(s,!1,u)}catch{try{de.set_destination_refinement_level(s,e.subdivisions-1),c=He.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=e.shape!==void 0?t.geometry:Bo(e,o,!1),s;e.type==="TorusGeometry"&&e.arc===Math.PI*2?s=i.getClosedTorusIndicesForBooleanOrSubdiv():s=i.getIndex();let l,c,u,a;({positions:l,triIndices:a}=Id(i.getAttribute("position"),s));let d;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let p=e.radialSegments*e.heightSegments*3*2,f=p+e.radialSegments*3;d=[p,f]}return{indices:c,verticesPerFace:u}=Md(l,a,i,d),{positions:l,indices:c,verticesPerFace:u}}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=gy,i=xy,s=vy);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),b=new Uint32Array(de.HEAPU32.buffer,g+h,f);v.set(o,0),v.set(l,o.length),v.set(c,o.length+l.length),b.set(i,0),b.set(s,i.length);let w;e?.scaleBaked?.some(P=>P!==1)&&(w=new aT().makeScale(...e.scaleBaked)),t&&(w?w.premultiply(t):w=t);let S=w?de.alloc_subdivision_surface2(g,u,g+h,a,g+h+i.length*Uint32Array.BYTES_PER_ELEMENT,d,w.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],b=de.HEAPU32.subarray(v>>2,(v>>2)+a[d]);if(d++,i===void 0){let w=new Pd;if(w.setIndex(new Td(b,1)),w.setAttribute("position",new Od(f,3)),w.setAttribute("normal",new Od(h,3)),t){w.setAttribute("faceMap",new Td(g,1));let S=new Float32Array(h.length/3*4).fill(0);w.setAttribute("color",new yy(S,4))}return de.free_mesh_data(l),w.userData.type="SubdivGeometry",w}i.getAttribute("position").copyArray(f),i.getAttribute("normal").copyArray(h),i.attributes.position.needsUpdate=!0,i.attributes.normal.needsUpdate=!0,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 Pd;m.setAttribute("position",new Od(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 yy(h,3)),m.setIndex(new Td(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 by=["getX","getY","getZ"];function Id(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[by[p]](a)*l)},`;if(d in e)i.push(e[d]);else{for(let p=0;p<3;p++)s.push(n[by[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 bs,Ad=new bs,Nd=new bs,Cd=new bs;function Md(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]),Ad.set(n[r[s+1]*3],n[r[s+1]*3+1],n[r[s+1]*3+2]),Nd.set(n[r[s+4]*3],n[r[s+4]*3+1],n[r[s+4]*3+2]),Cd.set(n[r[s+5]*3],n[r[s+5]*3+1],n[r[s+5]*3+2]),Ad.sub(Sl).normalize(),Nd.sub(Sl).normalize(),Cd.sub(Sl).normalize();let c=Ad.cross(Nd).dot(Cd);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 sr={};y0(sr,{calcBoolean:()=>mT,calcBooleanTopological:()=>fT,freeMeshSet:()=>gT,getMeshSet:()=>hT,transformMeshSet:()=>yT});var Sy,wy=new Promise(n=>{Sy=n});var nk=Sn(async()=>{let r=!1?".":"https://unpkg.com/@splinetool/boolean-wasm@0.9.384/build",[e,t]=await Promise.all([import("./boolean.js"),fetch(`${r}/boolean.wasm`).then(s=>s.arrayBuffer())]),o=e.default,i=await o({wasmBinary:t});Sy(i)});import{Float32BufferAttribute as _y,Sphere as uT}from"three";var xe,oi;wy.then(n=>xe=n);function pT(n,r,e){let t,o;n.userData.parameters.type==="TorusGeometry"&&n.userData.parameters.arc===Math.PI*2?o=n.getClosedTorusIndicesForBooleanOrSubdiv():o=n.getIndex();let{positions:i,triIndices:s}=Id(n.getAttribute("position"),o),l;if(r&&e){let{indices:c,verticesPerFace:u}=Md(i,s,n);l=u.length,t=[];for(let a=0,d=0;a<l;a++){t.push(u[a]);for(let p=0;p<u[a];p++)t.push(c[d++])}}else{let c=s.length;t=Array(c+c/3),l=0;for(let u=0,a=0;a<t.length;)t[a++]=3,l++,t[a++]=s[u++],t[a++]=s[u++],t[a++]=s[u++]}return{positions:i,faceIndices:t,nFaces:l}}function Py(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 Ty(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 fT(n,r){oi===void 0&&(oi=xe.init_csg());let e=Py(n),t=xe.csg_calc_topological(oi,e,n.length,Ty(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 mT(n,r,e,t){oi===void 0&&(oi=xe.init_csg());let o=Py(n),i=xe.csg_calc(oi,o,n.length,t,Ty(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 _y(d,3)),e.setAttribute("normal",new _y(f,3));let h=xe.HEAPF32.subarray((i>>2)+5,(i>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new uT),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 hT(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,b=0;g<y.verticesPerFace.length;g++){o[b++]=y.verticesPerFace[g];for(let w=0;w<y.verticesPerFace[g];w++)o[b++]=y.indices[v++]}}else({positions:t,faceIndices:o,nFaces:i}=pT(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 yT(n,r){xe.transform_csg_mesh(n,r.elements)}function gT(n){xe.free_csg_mesh(n)}var xT={ConeGeometry:lh,CubeGeometry:ch,CylinderGeometry:ah,DodecahedronGeometry:dh,EllipseGeometry:Kn,HelixGeometry:Fh,IcosahedronGeometry:kh,LatheGeometry:Uh,NonParametricGeometry:Jh,PolygonGeometry:gl,PyramidGeometry:ey,RectangleGeometry:xl,SphereGeometry:ty,PlaneGeometry:ry,BackdropGeometry:oy,StarGeometry:vl,TextFrameGeometry:ny,TorusGeometry:iy,TorusKnotGeometry:sy,TriangleGeometry:ay,PathGeometry:uy,VectorGeometry:At},_d=n=>xT[n.type].create(n);function Ss(n){return n!==null&&"booleanOp"in n}var ni=class extends tl(bT){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new vT}updateVisible(){super.updateVisible(),this.visible=!Ss(this.parent)&&this.visible,Ss(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(sr.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 ni&&(e.freeBooleanPointer(),Ss(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e){let t=super.updateTransformState(e);return t&&Ss(this.parent)&&this.invalidateDownstreamBooleanData(!0),t}};var wl=new ST;function ws(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)}wl.min.set(i,s,l),wl.max.set(c,u,a),wl.getCenter(t),wl.getSize(o).multiplyScalar(.5)}var PT=new wT,TT=new _T,dt=class extends ni{constructor(r,e){super(PT,TT),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?ws(t,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:t.count,r,e):super.updateEntityBoxSize(r,e)}};import{Box3 as DO,Matrix4 as GO,Sphere as tg,Vector3 as RO}from"three";import{BufferAttribute as EO,Float32BufferAttribute as eg,MathUtils as ru,Vector3 as ou}from"three";import{ShaderMaterial as vO}from"three";import{CubeReflectionMapping as RT,CubeRefractionMapping as VT,CubeUVReflectionMapping as zT,LinearEncoding as Ly,sRGBEncoding as jT}from"three";var _s=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}};import{MathUtils as OT}from"three";var rt=class{constructor(r){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=OT.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 rt&&(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 Ed=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}},Xe=new Ed;import{Vector2 as Oy}from"three";import{MathUtils as AT}from"three";var ae=class extends rt{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=AT.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 Ne=class extends ae{constructor(e,t){t=t??{},t.shared=t.shared!==void 0?t.shared:!1;super(e,t);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,t,o,i,s,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 je=class extends Ne{constructor(e=0,t){super("v2");this.nodeType="Vector2";this.value=e instanceof Oy?e:new Oy(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)}};import{Vector3 as Ay}from"three";var ut=class extends Ne{constructor(e=0,t,o){super("v3");this.nodeType="Vector3";this.value=e instanceof Ay?e:new Ay(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)}};import{Color as NT}from"three";var Ke=class extends NT{constructor(e,t,o,i){super(e,t,o);this.isColorA=!0;this.a=i}setRGBA(e,t,o,i){super.setRGB(e,t,o),this.a=i}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}setStyle(e,t="srgb"){let o;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(o=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let i,s=o[1],l=o[2];switch(s){case"rgb":case"rgba":if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return this.a=s==="rgba"?parseFloat(i[4]):1,super.setStyle(e,t);break;case"hsl":case"hsla":if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return this.a=s==="hsla"?parseFloat(i[4]):1,super.setStyle(e,t);break}}return super.setStyle(e,t)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(e){this.r=e}set y(e){this.g=e}set z(e){this.b=e}set w(e){this.a=e}};var Nt=class extends Ne{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof Ke?e:new Ke(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 CT=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,Ny=/[a-z_0-9]+/gi,U=class extends ae{constructor(e,t,o,i,s){super(s);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=s===void 0,this.isInterface=!1,this.parse(e,t,o,i)}getShared(e,t){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}}getIncludeByName(e){if(this.includes){let t=this.includes.length;for(;t--;)if(this.includes[t].name===e)return this.includes[t]}}generate(e,t,o,i,s){let 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=Ny.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&&Xe.containsKeyword(f)){let y=this.keywords[f];if(!y){let g=Xe.getKeywordData(f);g.cache&&(y=e.keywords[f]),y=y||Xe.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&&Xe.contains(h)&&e.include(Xe.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=CT.exec(this.src);if(this.inputs=[],s&&s.length==4){this.type=s[1],this.name=s[2];let l=s[3].match(Ny);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 IT=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,Ld=class extends ae{constructor(e="",t){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||Ld.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=IT.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)}},Se=Ld;Se.PI="PI",Se.PI2="PI2",Se.RECIPROCAL_PI="RECIPROCAL_PI",Se.RECIPROCAL_PI2="RECIPROCAL_PI2",Se.LOG2="LOG2",Se.EPSILON="EPSILON";var MT=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
|
|
4
|
-
)*?)}`,"gim"),
|
|
5
|
-
`)),sRGBToLinear:new
|
|
6
|
-
`)),LinearTosRGB:new
|
|
7
|
-
`))},
|
|
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}import{BufferGeometry as $d,BufferAttribute as zy,Uint32BufferAttribute as Yd,Float32BufferAttribute as Xd,Matrix4 as jT,Vector3 as Ms,Sphere as FT,Box3 as kT,BoxGeometry as UT}from"three";var Gy,hi=new Promise(n=>{Gy=n});var Vy=Bn(async()=>{let r=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@0.9.387/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});Gy(i)});import{BufferGeometryLoader as GT}from"three";function Yo(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=_e.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 GT().parse(n);else{if(n.type==="SubdivGeometry")return new We(n,e);if(n.type==="TextGeometry")return new mi(n,r)}let o;try{o=qd(t)}catch(i){console.error(i)}if(!o){let i=_e.createFromState(Wn.defaultData(),100,100);t.shape=i,o=qd(t)}return o}import{Matrix4 as VT}from"three";var zT=new VT;function Is(n,r,e,t){let o=n.position.array,i=n.normal.array,s=zT.makeScale(r,e,t).invert().elements,a,c,u;for(var l=0,d=o.length;l<d;l+=3)o[l]*=r,o[l+1]*=e,o[l+2]*=t,a=i[l],c=i[l+1],u=i[l+2],i[l]=s[0]*a+s[4]*c+s[8]*u,i[l+1]=s[1]*a+s[5]*c+s[9]*u,i[l+2]=s[2]*a+s[6]*c+s[10]*u;n.position.needsUpdate=!0,n.normal.needsUpdate=!0}var Vl=new kT,yi=new Ms,de;hi.then(n=>{de=n});var jy=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),Fy=new Uint32Array([0,1,2,3]),ky=new Uint8Array([4]),We=class extends $d{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=yo.div(t,o);this.subdividedGeometry&&Is(this.subdividedGeometry.attributes,...i),this.originalGeometry&&Is(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(yi.fromArray(i));let a=yi.set(s.width,s.height,s.depth).length();this.originalGeometry.boundingSphere.radius=a/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,t,o;try{({originalGeometry:e,subdividedGeometry:t,subdivPointer:o}=We.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new UT(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&&(We.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new FT,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,o=e.boundingSphere.center;Vl.setFromBufferAttribute(t),Vl.getCenter(o),e.boundingSphere.radius=o.distanceTo(Vl.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Vl.getSize(yi);let i={width:yi.x,height:yi.y,depth:yi.z};return this.userData.parameters=i,i}static build(e,t,o,i){let s,a,c,u=e?.phongAngle??35;o===!1&&(u=-1),t&&(de.free_bvh(t),de.free_subdivision_surface(t));try{s=We.allocate(e,i)}catch(l){console.error(l,e),s=We.allocate({positionWASM:jy,indexWASM:Fy,verticesPerFaceWASM:ky},i)}if(de.set_destination_refinement_level(s,0),a=We.buildLevel(s,!0,u),e.subdivisions>0)try{de.set_destination_refinement_level(s,e.subdivisions),c=We.buildLevel(s,!1,u)}catch{try{de.set_destination_refinement_level(s,e.subdivisions-1),c=We.buildLevel(s,!1,u)}catch{c=null}}else c=null;return{subdivPointer:s,originalGeometry:a,subdividedGeometry:c}}static primitiveToQuads(e,t,o){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let i=e.shape!==void 0?t.geometry:Yo(e,o,!1),s;e.type==="TorusGeometry"&&e.arc===Math.PI*2?s=i.getClosedTorusIndicesForBooleanOrSubdiv():s=i.getIndex();let a,c,u,l;({positions:a,triIndices:l}=Jd(i.getAttribute("position"),s));let d;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let p=e.radialSegments*e.heightSegments*3*2,f=p+e.radialSegments*3;d=[p,f]}return{indices:c,verticesPerFace:u}=eu(a,l,i,d),{positions:a,indices:c,verticesPerFace:u}}static allocate(e,t){let o,i,s,a=[],c=[];e.positionWASM&&e.positionWASM.length>0?(o=e.positionWASM,i=e.indexWASM,s=e.verticesPerFaceWASM):(o=jy,i=Fy,s=ky);let u=o.length,l=i.length,d=s.length,p=o.length+a.length+c.length,f=i.length+s.length,m=p*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,h=p*Float32Array.BYTES_PER_ELEMENT,y=f*Uint32Array.BYTES_PER_ELEMENT,g=de._malloc(m),x=new Float32Array(de.HEAPF32.buffer,g,p),b=new Uint32Array(de.HEAPU32.buffer,g+h,f);x.set(o,0),x.set(a,o.length),x.set(c,o.length+a.length),b.set(i,0),b.set(s,i.length);let w;e?.scaleBaked?.some(P=>P!==1)&&(w=new jT().makeScale(...e.scaleBaked)),t&&(w?w.premultiply(t):w=t);let S=w?de.alloc_subdivision_surface2(g,u,g+h,l,g+h+i.length*Uint32Array.BYTES_PER_ELEMENT,d,w.elements):de.alloc_subdivision_surface(g,u,g+h,l,g+h+i.length*Uint32Array.BYTES_PER_ELEMENT,d);return de._free(g),S}static buildLevel(e,t,o,i,s){let a=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(a>>2,(a>>2)+c),l=u.subarray(4,4+4),d=0,p=de.HEAPU32[u[d]>>2],f=de.HEAPF32.subarray(p>>2,(p>>2)+l[d]);d++;let m=de.HEAPU32[u[d]>>2],h=de.HEAPF32.subarray(m>>2,(m>>2)+l[d]);d++;let y=de.HEAPU32[u[d]>>2],g=de.HEAPU32.subarray(y>>2,(y>>2)+l[d]);d++;let x=de.HEAPU32[u[d]>>2],b=de.HEAPU32.subarray(x>>2,(x>>2)+l[d]);if(d++,i===void 0){let w=new $d;if(w.setIndex(new Yd(b,1)),w.setAttribute("position",new Xd(f,3)),w.setAttribute("normal",new Xd(h,3)),t){w.setAttribute("faceMap",new Yd(g,1));let S=new Float32Array(h.length/3*4).fill(0);w.setAttribute("color",new zy(S,4))}return de.free_mesh_data(a),w.userData.type="SubdivGeometry",w}i.getAttribute("position").copyArray(f),i.getAttribute("normal").copyArray(h),i.attributes.position.needsUpdate=!0,i.attributes.normal.needsUpdate=!0,de.free_mesh_data(a)}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,a=de.HEAPU32.subarray(i>>2,(i>>2)+s),c=a.subarray(2,2+2),u=0,l=de.HEAPU32[a[u]>>2],d=de.HEAPF32.subarray(l>>2,(l>>2)+c[u]);u++;let p=de.HEAPU32[a[u]>>2],f=de.HEAPU32.subarray(p>>2,(p>>2)+c[u]);if(t===void 0){let m=new $d;m.setAttribute("position",new Xd(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 zy(h,3)),m.setIndex(new Yd(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),a=6,c=de.HEAPU32.subarray(s>>2,(s>>2)+a),u=c.subarray(3,3+3),l=0,d=de.HEAPU32[c[l]>>2],p=new Float32Array(de.HEAPF32.subarray(d>>2,(d>>2)+u[l]));l++;let f=de.HEAPU32[c[l]>>2],m=new Uint32Array(de.HEAPU32.subarray(f>>2,(f>>2)+u[l]));l++;let h=de.HEAPU32[c[l]>>2],y=new Uint8Array(de.HEAPU32.subarray(h>>2,(h>>2)+u[l]));return de.free_topological_data(s),{positions:p,indices:m,verticesPerFace:y}}};var Uy=["getX","getY","getZ"];function Jd(n,r){let e={},t=r?r.count:n.count,o=0,i=[],s=[],a=1e4;for(let u=0;u<t;u++){let l=r?r.getX(u):u,d="";for(let p=0;p<3;p++)d+=`${~~(n[Uy[p]](l)*a)},`;if(d in e)i.push(e[d]);else{for(let p=0;p<3;p++)s.push(n[Uy[p]](l));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 zl=new Ms,Kd=new Ms,Zd=new Ms,Qd=new Ms;function eu(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([]),a=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&a<=24&&a%4===0&&e.userData.parameters.angle>=360){let l=s.length/2/a;s=s.filter((d,p)=>Math.floor(p/2)%l===0)}let c=0;for(let l=0;l<s.length;l+=2)c+=(s[l]-s[(l===0?s.length:l)-2])*(s[l+1]+s[(l===0?s.length:l)-1]);n.length=0;let u=0;if(c<0)for(let l=0;l<s.length;l+=2)n.push(s[l],s[l+1],0),o.push(u++);else for(let l=s.length-2;l>=0;l-=2)n.push(s[l],s[l+1],0),o.push(u++);return i.push(u),{indices:o,verticesPerFace:i}}for(let s=0,a=e.capStartIndex??r.length;s<a;)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]){zl.set(n[r[s]*3],n[r[s]*3+1],n[r[s]*3+2]),Kd.set(n[r[s+1]*3],n[r[s+1]*3+1],n[r[s+1]*3+2]),Zd.set(n[r[s+4]*3],n[r[s+4]*3+1],n[r[s+4]*3+2]),Qd.set(n[r[s+5]*3],n[r[s+5]*3+1],n[r[s+5]*3+2]),Kd.sub(zl).normalize(),Zd.sub(zl).normalize(),Qd.sub(zl).normalize();let c=Kd.cross(Zd).dot(Qd);Math.abs(c)>.005||t&&t.some((u,l)=>l%2===1?!1:s>=t[l]&&s<t[l+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=[],a=[],c=0,u=new Float32Array([e.userData.parameters.depth])[0];for(let l=0,d=0;l<n.length;l+=3,d++)n[l+2]===0&&(s.push(d),c++),n[l+2]===u&&a.push(d);if(e.userData.parameters.extrudeBevelSize===0){let l=a[0];a[0]=a[1],a[1]=l}s.reverse(),o.push(...s,...a),i.push(c,c)}return{indices:o,verticesPerFace:i}}var ar={};$0(ar,{calcBoolean:()=>$T,calcBooleanTopological:()=>qT,freeMeshSet:()=>KT,getMeshSet:()=>YT,transformMeshSet:()=>XT});var Hy,Wy=new Promise(n=>{Hy=n});var UU=Bn(async()=>{let r=!1?".":"https://unpkg.com/@splinetool/boolean-wasm@0.9.387/build",[e,t]=await Promise.all([import("./boolean.js"),fetch(`${r}/boolean.wasm`).then(s=>s.arrayBuffer())]),o=e.default,i=await o({wasmBinary:t});Hy(i)});import{Float32BufferAttribute as qy,Sphere as HT}from"three";var xe,gi;Wy.then(n=>xe=n);function WT(n,r,e){let t,o;n.userData.parameters.type==="TorusGeometry"&&n.userData.parameters.arc===Math.PI*2?o=n.getClosedTorusIndicesForBooleanOrSubdiv():o=n.getIndex();let{positions:i,triIndices:s}=Jd(n.getAttribute("position"),o),a;if(r&&e){let{indices:c,verticesPerFace:u}=eu(i,s,n);a=u.length,t=[];for(let l=0,d=0;l<a;l++){t.push(u[l]);for(let p=0;p<u[l];p++)t.push(c[d++])}}else{let c=s.length;t=Array(c+c/3),a=0;for(let u=0,l=0;l<t.length;)t[l++]=3,a++,t[l++]=s[u++],t[l++]=s[u++],t[l++]=s[u++]}return{positions:i,faceIndices:t,nFaces:a}}function $y(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 Yy(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 qT(n,r){gi===void 0&&(gi=xe.init_csg());let e=$y(n),t=xe.csg_calc_topological(gi,e,n.length,Yy(r));xe._free(e);let o=6,i=xe.HEAPU32.subarray(t>>2,(t>>2)+o),s=i.subarray(3,3+3),a=0,c=xe.HEAPU32[i[a]>>2],u=new Float32Array(xe.HEAPF32.subarray(c>>2,(c>>2)+s[a]));a++;let l=xe.HEAPU32[i[a]>>2],d=new Uint32Array(xe.HEAPU32.subarray(l>>2,(l>>2)+s[a]));a++;let p=xe.HEAPU32[i[a]>>2],f=new Uint8Array(xe.HEAPU32.subarray(p>>2,(p>>2)+s[a]));return xe.free_mesh_data(t),{positions:u,indices:d,verticesPerFace:f}}function $T(n,r,e,t){gi===void 0&&(gi=xe.init_csg());let o=$y(n),i=xe.csg_calc(gi,o,n.length,t,Yy(r));xe._free(o);let s=5,a=xe.HEAPU32.subarray(i>>2,(i>>2)+s),c=a.subarray(2,2+3),u=0,l=xe.HEAPU32[a[u]>>2],d=xe.HEAPF32.subarray(l>>2,(l>>2)+c[u]);u++;let p=xe.HEAPU32[a[u]>>2],f=xe.HEAPF32.subarray(p>>2,(p>>2)+c[u]);u++;let m=c[u];e.setAttribute("position",new qy(d,3)),e.setAttribute("normal",new qy(f,3));let h=xe.HEAPF32.subarray((i>>2)+5,(i>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new HT),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 YT(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,x)=>g+x,0)+i);for(let g=0,x=0,b=0;g<y.verticesPerFace.length;g++){o[b++]=y.verticesPerFace[g];for(let w=0;w<y.verticesPerFace[g];w++)o[b++]=y.indices[x++]}}else({positions:t,faceIndices:o,nFaces:i}=WT(n,r,e));let s=t.length,a=o.length,c=t.length,u=o.length,l=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(l),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,a,i)}function XT(n,r){xe.transform_csg_mesh(n,r.elements)}function KT(n){xe.free_csg_mesh(n)}var ZT={ConeGeometry:Mh,CubeGeometry:Eh,CylinderGeometry:Ih,DodecahedronGeometry:Lh,EllipseGeometry:di,HelixGeometry:dy,IcosahedronGeometry:uy,LatheGeometry:py,NonParametricGeometry:wy,PolygonGeometry:Bl,PyramidGeometry:_y,RectangleGeometry:Rl,SphereGeometry:Py,PlaneGeometry:Ty,BackdropGeometry:Oy,StarGeometry:Gl,TextFrameGeometry:Ay,TorusGeometry:Cy,TorusKnotGeometry:Ny,TriangleGeometry:Iy,PathGeometry:Dy,VectorGeometry:Mt},qd=n=>ZT[n.type].create(n);function Es(n){return n!==null&&"booleanOp"in n}var xi=class extends ti(JT){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new QT}updateVisible(){super.updateVisible(),this.visible=!Es(this.parent)&&this.visible,Es(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(ar.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),Es(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof xi&&(e.freeBooleanPointer(),Es(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e){let t=super.updateTransformState(e);return t&&Es(this.parent)&&this.invalidateDownstreamBooleanData(!0),t}};var jl=new eO;function Ls(n,r=0,e=n.count,t,o){let i=1/0,s=1/0,a=1/0,c=-1/0,u=-1/0,l=-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<a&&(a=m),p>c&&(c=p),f>u&&(u=f),m>l&&(l=m)}jl.min.set(i,s,a),jl.max.set(c,u,l),jl.getCenter(t),jl.getSize(o).multiplyScalar(.5)}var oO=new tO,nO=new rO,pt=class extends xi{constructor(r,e){super(oO,nO),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?Ls(t,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:t.count,r,e):super.updateEntityBoxSize(r,e)}};import{Box3 as hA,Matrix4 as yA,Sphere as Mg,Vector3 as gA}from"three";import{BufferAttribute as pA,Float32BufferAttribute as Ig,MathUtils as Au,Vector3 as Cu}from"three";import{ShaderMaterial as QO}from"three";import{CubeReflectionMapping as yO,CubeRefractionMapping as gO,CubeUVReflectionMapping as xO,LinearEncoding as rg,sRGBEncoding as vO}from"three";var Ds=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}};import{MathUtils as iO}from"three";var it=class{constructor(r){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=iO.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 it&&(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 tu=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}},Qe=new tu;import{Vector2 as Xy}from"three";import{MathUtils as sO}from"three";var ae=class extends it{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=sO.generateUUID()),o=e.getUUID(o??this.getUUID(),!s);let a=e.getNodeData(o),c=a.output||this.getType(e);if(e.analyzing)return(a.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,a,t),this.generate(e,t,o)):super.build(e,t,o);if(s)return a.name=a.name||super.build(e,t,o),a.name;if(!this.getLabel()&&(!this.getShared(e,c)||e.context.ignoreCache||a.deps===1))return super.build(e,t,o);o=this.getUUID(!1);let u=this.getTemp(e,o);if(u)return e.format(u,c,t);{u=super.generate(e,t,o,a.output,i);let l=this.generate(e,c,o);return e.addNodeCode(u+" = "+l+";"),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 Ne=class extends ae{constructor(e,t){t=t??{},t.shared=t.shared!==void 0?t.shared:!1;super(e,t);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,t,o,i,s,a){o=e.getUUID(o??this.getUUID()),i=i??this.getType(e);let c=e.getNodeData(o);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,t,o,i,s,a):e.isShader("vertex")?(c.vertex||(c.vertex=e.createVertexUniform(i,this,s,a,this.getLabel())),e.format(c.vertex.name,i,t)):(c.fragment||(c.fragment=e.createFragmentUniform(i,this,s,a,this.getLabel())),e.format(c.fragment.name,i,t))}};var Ve=class extends Ne{constructor(e=0,t){super("v2");this.nodeType="Vector2";this.value=e instanceof Xy?e:new Xy(e,t)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,t,o,i,s,a){return e.format("vec2("+this.value.x+", "+this.value.y+")",i,t)}};import{Vector3 as Ky}from"three";var ft=class extends Ne{constructor(e=0,t,o){super("v3");this.nodeType="Vector3";this.value=e instanceof Ky?e:new Ky(e,t,o)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,t,o,i,s,a){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",i,t)}};import{Color as aO}from"three";var Je=class extends aO{constructor(e,t,o,i){super(e,t,o);this.isColorA=!0;this.a=i}setRGBA(e,t,o,i){super.setRGB(e,t,o),this.a=i}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}setStyle(e,t="srgb"){let o;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(o=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let i,s=o[1],a=o[2];switch(s){case"rgb":case"rgba":if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.a=s==="rgba"?parseFloat(i[4]):1,super.setStyle(e,t);break;case"hsl":case"hsla":if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.a=s==="hsla"?parseFloat(i[4]):1,super.setStyle(e,t);break}}return super.setStyle(e,t)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(e){this.r=e}set y(e){this.g=e}set z(e){this.b=e}set w(e){this.a=e}};var Et=class extends Ne{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof Je?e:new Je(e.r,e.g,e.b,e.a)}generateReadonly(e,t,o,i,s,a){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",i,t)}};var lO=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,Zy=/[a-z_0-9]+/gi,k=class extends ae{constructor(e,t,o,i,s){super(s);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=s===void 0,this.isInterface=!1,this.parse(e,t,o,i)}getShared(e,t){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}}getIncludeByName(e){if(this.includes){let t=this.includes.length;for(;t--;)if(this.includes[t].name===e)return this.includes[t]}}generate(e,t,o,i,s){let a,c=0,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 l=[];for(;a=Zy.exec(this.src);)l.push(a);for(let d=0;d<l.length;d++){let p=l[d],f=p[0],m=this.isMethod?!this.getInputByName(f):!0,h=f;if(this.keywords[f]||this.useKeywords&&m&&Qe.containsKeyword(f)){let y=this.keywords[f];if(!y){let g=Qe.getKeywordData(f);g.cache&&(y=e.keywords[f]),y=y||Qe.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&&Qe.contains(h)&&e.include(Qe.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=lO.exec(this.src);if(this.inputs=[],s&&s.length==4){this.type=s[1],this.name=s[2];let a=s[3].match(Zy);if(a){let c=0;for(;c<a.length;){let u=a[c++],l;u==="in"||u==="out"||u==="inout"?l=a[c++]:(l=u,u="");let d=a[c++];this.inputs.push({name:d,type:l,qualifier:u})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var cO=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,ru=class extends ae{constructor(e="",t){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||ru.PI,void 0,void 0,void 0,t)}getType(e){return e.getTypeByFormat(this.type)}parse(e,t,o,i,s){this.src=e||"";let a,c,u="",l=cO.exec(e);this.useDefine=s??this.src.charAt(0)==="#",l&&l.length>1?(c=l[1],a=l[2],u=l[3]):(a=this.src,c="f"),this.name=a,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=ru;we.PI="PI",we.PI2="PI2",we.RECIPROCAL_PI="RECIPROCAL_PI",we.RECIPROCAL_PI2="RECIPROCAL_PI2",we.LOG2="LOG2",we.EPSILON="EPSILON";var dO=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
|
|
4
|
+
)*?)}`,"gim"),uO=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),vi=class extends ae{constructor(e=""){super();this.inputs=[];this.src="";this.nodeType="Struct";this.parse(e)}getType(e){return e.getTypeByFormat(this.name)}getInputByName(e){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}generate(e,t,o,i,s){return t==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),t)}parse(e=""){this.src=e,this.inputs=[];let t=dO.exec(e);if(t){let o=t[2],i;for(;i=uO.exec(o);)this.inputs.push({type:i[1],name:i[2]});this.name=t[1]}else this.name="";this.type=this.name}};var bi=class extends ae{constructor(e){super("v2",{shared:!1});this.nodeType="UV";this.index=e??0}generate(e,t){e.requires.uv[this.index]=!0;let o=this.index>0?this.index+1:"",i=e.isShader("vertex")?"uv"+o:"vUv"+o;return e.format(i,this.getType(e),t)}};Qe.addKeyword("uv",function(){return new bi});Qe.addKeyword("uv2",function(){return new bi(1)});import{LinearEncoding as pO,sRGBEncoding as fO}from"three";var Xo=class extends ae{constructor(e,t){super("v4");this.nodeType="ColorSpace";this.input=e,this.method=t??Xo.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case pO:return["Linear"];case fO:return["sRGB"];default:return[]}}generate(e,t){let o=this.input.build(e,"v4"),i=this.getType(e),s=Xo.Nodes[this.method],a=e.include(s);if(a===Xo.LINEAR_TO_LINEAR)return e.format(o,i,t);if(s.inputs?.length===2){let c=this.factor.build(e,"f");return e.format(a+"( "+o+", "+c+" )",i,t)}else return e.format(a+"( "+o+" )",i,t)}fromEncoding(e){let t=Xo.getEncodingComponents(e);this.method="LinearTo"+t[0],this.factor=t[1]}fromDecoding(e){let t=Xo.getEncodingComponents(e);this.method=t[0]+"ToLinear",this.factor=t[1]}},_t=Xo;_t.Nodes={LinearToLinear:new k(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
|
|
5
|
+
`)),sRGBToLinear:new k(["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 k(["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
|
+
`))},_t.LINEAR_TO_LINEAR="LinearToLinear",_t.SRGB_TO_LINEAR="sRGBToLinear",_t.LINEAR_TO_SRGB="LinearTosRGB";var Pe=class extends k{constructor(e="",t,o,i,s){super(e,s,i,o,t);this.nodeType="Expression"}};import{Texture as mO}from"three";var Pt=class extends Ne{constructor(e=new mO,t,o,i){super("v4",{shared:!0});this.nodeType="Texture";this.value=e,this.uv=t??new bi,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 a,c;this.project?a="texture2DProj":a=s?"tex2DBias":"tex2D",s?c=a+"( "+o+", "+i+", "+s+" )":c=a+"( "+o+", "+i+" )";let u={include:e.isShader("vertex"),ignoreCache:!0},l=this.getType(e);return e.addContext(u),this.colorSpace=this.colorSpace??new _t(new Pe("",l)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(c),c=this.colorSpace.build(e,l),e.removeContext(),e.format(c,l,t)}};var Z=class extends Ne{constructor(e){super("f");this.nodeType="Float";this.value=e??0}generateReadonly(e,t,o,i,s,a){return e.format(this.value+(this.value%1?"":".0"),i,t)}};var Bs=class extends ae{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 a=this.value,c=a.build(e,t)+"( ",u=[];if(a.inputs){for(let l=0;l<a.inputs.length;l++){let d=a.inputs[l],p=this.inputs[l]||this.inputs[d.name];u.push(p.build(e,e.getTypeByFormat(d.type)))}c+=u.join(", ")+" )"}return e.format(c,i,t)}};var ou=class extends ae{constructor(e,t,o=ou.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)}},st=ou;st.ADD="+",st.SUB="-",st.MUL="*",st.DIV="/";var Ie=class extends ae{constructor(e,t=Ie.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 Ie.MIX:case Ie.CLAMP:case Ie.REFRACT:case Ie.SMOOTHSTEP:case Ie.FACEFORWARD:return 3;case Ie.MIN:case Ie.MAX:case Ie.MOD:case Ie.STEP:case Ie.REFLECT:case Ie.DISTANCE:case Ie.DOT:case Ie.CROSS:case Ie.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 Ie.LENGTH:case Ie.DISTANCE:case Ie.DOT:return"f";case Ie.CROSS:return"v3"}return this.getInputType(e)}generate(e,t){let o,i,s,a=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,l=this.getInputType(e),d=this.getType(e);switch(this.type=d,this.method){case Ie.NEGATE:return e.format("( -"+this.a.build(e,l)+" )",l,t);case Ie.INVERT:return e.format("( 1.0 - "+this.a.build(e,l)+" )",l,t);case Ie.CROSS:o=this.a.build(e,"v3"),i=this.b.build(e,"v3");break;case Ie.STEP:o=this.a.build(e,a===1?"f":l),i=this.b.build(e,l);break;case Ie.MIN:case Ie.MAX:case Ie.MOD:o=this.a.build(e,l),i=this.b.build(e,c===1?"f":l);break;case Ie.REFRACT:o=this.a.build(e,l),i=this.b.build(e,l),s=this.c.build(e,"f");break;case Ie.MIX:o=this.a.build(e,l),i=this.b.build(e,l),s=this.c.build(e,u===1?"f":l);break;default:o=this.a.build(e,l),this.b&&(i=this.b.build(e,l)),this.c&&(s=this.c.build(e,l));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)}},pe=Ie;pe.RAD="radians",pe.DEG="degrees",pe.EXP="exp",pe.EXP2="exp2",pe.LOG="log",pe.LOG2="log2",pe.SQRT="sqrt",pe.INV_SQRT="inversesqrt",pe.FLOOR="floor",pe.CEIL="ceil",pe.NORMALIZE="normalize",pe.FRACT="fract",pe.SATURATE="saturate",pe.SIN="sin",pe.COS="cos",pe.TAN="tan",pe.ASIN="asin",pe.ACOS="acos",pe.ARCTAN="atan",pe.ABS="abs",pe.SIGN="sign",pe.LENGTH="length",pe.NEGATE="negate",pe.INVERT="invert",pe.MIN="min",pe.MAX="max",pe.MOD="mod",pe.STEP="step",pe.REFLECT="reflect",pe.DISTANCE="distance",pe.DOT="dot",pe.CROSS="cross",pe.POW="pow",pe.MIX="mix",pe.CLAMP="clamp",pe.REFRACT="refract",pe.SMOOTHSTEP="smoothstep",pe.FACEFORWARD="faceforward";var Si=class extends ae{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 Bs(Si.Nodes.bilinearCubeUV,[t,o,i]);this.colorSpaceTL=this.colorSpaceTL??new _t(new Pe("","v4")),this.colorSpaceTL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTL.input.parse(s.build(e)+".tl"),this.colorSpaceTR=this.colorSpaceTR??new _t(new Pe("","v4")),this.colorSpaceTR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTR.input.parse(s.build(e)+".tr"),this.colorSpaceBL=this.colorSpaceBL??new _t(new Pe("","v4")),this.colorSpaceBL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBL.input.parse(s.build(e)+".bl"),this.colorSpaceBR=this.colorSpaceBR??new _t(new Pe("","v4")),this.colorSpaceBR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBR.input.parse(s.build(e)+".br");let a={include:e.isShader("vertex"),ignoreCache:!0};e.addContext(a),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 Bs(Si.Nodes.roughnessToMip,[i]),a=new pe(s,Si.Nodes.m0,Si.Nodes.cubeUV_maxMipLevel,pe.CLAMP),c=new pe(a,pe.FLOOR),u=new pe(a,pe.FRACT),l=this.bilinearCubeUV(e,this.value,o,c),d=this.bilinearCubeUV(e,this.value,o,new st(c,new Z(1).setReadonly(!0),st.ADD)),p=new pe(l,d,u,pe.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)}},wi=Si;wi.Nodes=function(){let e=new vi(`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
|
|
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),a=new k(`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 @@ var u0=Object.create;var Jl=Object.defineProperty;var p0=Object.getOwnPropertyDe
|
|
|
25
25
|
face = direction.y > 0.0 ? 1.0 : 4.0;
|
|
26
26
|
}
|
|
27
27
|
return face;
|
|
28
|
-
}`);
|
|
28
|
+
}`);a.useKeywords=!1;let c=new k(`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 @@ var u0=Object.create;var Jl=Object.defineProperty;var p0=Object.getOwnPropertyDe
|
|
|
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
|
|
44
|
+
}`);c.useKeywords=!1;let u=new k(`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 @@ var u0=Object.create;var Jl=Object.defineProperty;var p0=Object.getOwnPropertyDe
|
|
|
69
69
|
uv.x -= texelSize;
|
|
70
70
|
vec4 bl = texture2D(envMap, uv);
|
|
71
71
|
return TextureCubeUVData( tl, tr, br, bl, f );
|
|
72
|
-
}`,[e,
|
|
72
|
+
}`,[e,a,c,t,o,i,s]);u.useKeywords=!1;let l=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),x=new we("float m4 2.0",!0),b=new we("float r5 0.305",!0),w=new we("float v5 0.016",!0),S=new we("float m5 3.0",!0),P=new we("float r6 0.21",!0),_=new we("float v6 0.0038",!0),v=new we("float m6 4.0",!0),N=[l,d,p,f,m,h,y,g,x,b,w,S,P,_,v],T=new k(`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 @@ var u0=Object.create;var Jl=Object.defineProperty;var p0=Object.getOwnPropertyDe
|
|
|
83
83
|
mip = -2.0 * log2(1.16 * roughness);// 1.16 = 1.79^0.25
|
|
84
84
|
}
|
|
85
85
|
return mip;
|
|
86
|
-
}`,
|
|
86
|
+
}`,N);return{bilinearCubeUV:u,roughnessToMip:T,m0:p,cubeUV_maxMipLevel:t}}();var Ko=class extends ae{constructor(e){super("v3");this.nodeType="Normal";this.scope=e??Ko.VIEW}getShared(){return this.scope===Ko.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 a;switch(this.scope){case Ko.VIEW:e.isShader("vertex")?a="transformedNormal":a="geometryNormal";break;case Ko.LOCAL:e.isShader("vertex")?a="objectNormal":(e.requires.normal=!0,a="vObjectNormal");break;case Ko.WORLD:e.isShader("vertex")?a="inverseTransformDirection( transformedNormal, viewMatrix ).xyz":(e.requires.worldNormal=!0,a="vWNormal");break}return e.format(a,this.getType(e),t)}},at=Ko;at.LOCAL="local",at.WORLD="world",at.VIEW="view",at.NORMAL="normal";Qe.addKeyword("viewNormal",function(){return new at(at.VIEW)});Qe.addKeyword("localNormal",function(){return new at(at.NORMAL)});Qe.addKeyword("worldNormal",function(){return new at(at.WORLD)});var Nr=class extends ae{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 a;switch(this.scope){case Nr.LOCAL:e.isShader("vertex")?a="transformed":(e.requires.position=!0,a="vPosition");break;case Nr.WORLD:if(e.isShader("vertex"))return"( modelMatrix * vec4( transformed, 1.0 ) ).xyz";e.requires.worldPosition=!0,a="vWPosition";break;case Nr.VIEW:a=e.isShader("vertex")?"-mvPosition.xyz":"vViewPosition";break;case Nr.PROJECTION:a=e.isShader("vertex")?"( projectionMatrix * modelViewMatrix * vec4( position, 1.0 ) )":"vec4( 0.0 )";break}return e.format(a,this.getType(),t)}},Lt=Nr;Lt.LOCAL="local",Lt.WORLD="world",Lt.VIEW="view",Lt.PROJECTION="projection";Qe.addKeyword("position",function(){return new Lt});Qe.addKeyword("worldPosition",function(){return new Lt(Lt.WORLD)});Qe.addKeyword("viewPosition",function(){return new Lt(Lt.VIEW)});var lr=class extends ae{constructor(e){super("v3");this.nodeType="Reflect";this.scope=e??lr.CUBE}getUnique(e){return!e.context.viewNormal}getType(){switch(this.scope){case lr.SPHERE:return"v2"}return this.type}generate(e,t){let o=this.getUnique(e);if(e.isShader("fragment")){let i;switch(this.scope){case lr.VECTOR:{let s=new at(at.VIEW),a=e.context.roughness,c=s.build(e,"v3"),u=new Lt(Lt.VIEW).build(e,"v3"),l=a?a.build(e,"f"):void 0,d=`reflect( -normalize( ${u} ), ${c} )`;l&&(d=`normalize( mix( ${d}, ${c}, ${l} * ${l} ) )`);let p=`inverseTransformDirection( ${d}, viewMatrix )`;o?(e.addNodeCode(`vec3 reflectVec = ${p};`),i="reflectVec"):i=p;break}case lr.CUBE:{let s=new lr(lr.VECTOR).build(e,"v3"),a="vec3( -"+s+".x, "+s+".yz )";o?(e.addNodeCode(`vec3 reflectCubeVec = ${a};`),i="reflectCubeVec"):i=a;break}case lr.SPHERE:{let a="normalize( ( viewMatrix * vec4( "+new lr(lr.VECTOR).build(e,"v3")+", 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) ).xy * 0.5 + 0.5";o?(e.addNodeCode(`vec2 reflectSphereVec = ${a};`),i="reflectSphereVec"):i=a;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)}},Ir=lr;Ir.CUBE="cube",Ir.SPHERE="sphere",Ir.VECTOR="vector";var Fl=class extends ae{constructor(e=new Pt,t,o){super("v4");this.nodeType="TextureCube";this.value=e,this.radianceNode=new wi(this.value,t??new Ir(Ir.VECTOR),o),this.irradianceNode=new wi(this.value,new at(at.WORLD),new Z(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))}};import{CubeTexture as hO}from"three";var kl=class extends Ne{constructor(e=new hO,t,o){super("v4",{shared:!0});this.nodeType="CubeTexture";this.value=e,this.uv=t??new Ir,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 a;s?a="texCubeBias( "+o+", "+i+", "+s+" )":a="texCube( "+o+", "+i+" )";let c={include:e.isShader("vertex"),ignoreCache:!0},u=this.getType(e);return e.addContext(c),this.colorSpace=this.colorSpace??new _t(new Pe("",u)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(a),a=this.colorSpace.build(e,u),e.removeContext(),e.format(a,u,t)}};var Qy=`
|
|
87
87
|
uniform int frameIndex;
|
|
88
88
|
uniform vec2 resolution;
|
|
89
89
|
uniform mat4 previousModelViewMatrix;
|
|
@@ -91,7 +91,7 @@ uniform mat4 previousProjectionMatrix;
|
|
|
91
91
|
|
|
92
92
|
varying vec4 vCurrentPosition;
|
|
93
93
|
varying vec4 vPreviousPosition;
|
|
94
|
-
`,
|
|
94
|
+
`,Jy=`
|
|
95
95
|
layout(location = 1) out vec4 gVelocity;
|
|
96
96
|
|
|
97
97
|
uniform int frameIndex;
|
|
@@ -133,7 +133,7 @@ float getNoiseInterleavedGradient(vec2 screenPos) {
|
|
|
133
133
|
return fract(magic.z * fract(dot(screenPos, magic.xy)));
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
-
`,
|
|
136
|
+
`,eg=`
|
|
137
137
|
// TODO: This could be generated CPU side and passed to the shader every frame
|
|
138
138
|
const vec2 haltonSequence[16] = vec2[16](
|
|
139
139
|
vec2( 0.000000,-0.333334),
|
|
@@ -170,7 +170,7 @@ vPreviousPosition.xy += OUTLINE_COMPENSATION;
|
|
|
170
170
|
#endif
|
|
171
171
|
gl_Position = currentPositionJittered;
|
|
172
172
|
|
|
173
|
-
`,
|
|
173
|
+
`,tg=`
|
|
174
174
|
vec2 oldPos = vPreviousPosition.xy;
|
|
175
175
|
oldPos /= vPreviousPosition.w;
|
|
176
176
|
oldPos.xy = (oldPos.xy+1.)/2.0;
|
|
@@ -184,7 +184,7 @@ vec2 velocity = (newPos - oldPos);
|
|
|
184
184
|
// NOTE: We use the blue channel to avoid temporal reprojection
|
|
185
185
|
// with incorrect velocity if the fragment is transparent.
|
|
186
186
|
gVelocity = vec4(velocity, gl_FragColor.a < 1.0 ? 0.0 : 1.0, 1.);
|
|
187
|
-
`;var
|
|
187
|
+
`;var og=["x","y","z","w"],bO=["float","vec2","vec3","vec4"],SO={float:"f",vec2:"v2",vec3:"v3",vec4:"v4",mat4:"v4",int:"i",bool:"b","float[]":"f[]","vec4[]":"v4[]"},wO={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[]"},Ul=class{constructor(){this.includes={consts:{},functions:{},structs:{}};this.cache="";this.slot="";this.shader="";this.context={};this.needsJitter=!0;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 a=0;a<i.length;a++)i[a].src&&(s+=i[a].src+`
|
|
188
188
|
`);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",`
|
|
189
189
|
// NOTE: Include Spline's blending modes. This could be part of BlendNode
|
|
190
190
|
#define SPE_BLENDING_NORMAL 0
|
|
@@ -222,20 +222,20 @@ gVelocity = vec4(velocity, gl_FragColor.a < 1.0 ? 0.0 : 1.0, 1.);
|
|
|
222
222
|
`),fragment:["float accumAlpha = 0.0;",`void accumulateAlpha(float alpha) {
|
|
223
223
|
accumAlpha += (1.0 - accumAlpha) * alpha;
|
|
224
224
|
}`,""].join(`
|
|
225
|
-
`)},this.code={vertex:"",fragment:""},this.nodeCode={vertex:"",fragment:""},this.resultCode={vertex:"",fragment:""},this.finalCode={vertex:"",fragment:""},this.inputs={uniforms:{list:[],vertex:[],fragment:[]},arrayUniforms:{list:[],vertex:[],fragment:[]},vars:{varying:[],vertex:[],fragment:[]}},this.defines={},this.uniforms={},this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.updaters=[],this.nodes=[],this.analyzing=!1}build(r,e){this.addVertexParsCode(
|
|
225
|
+
`)},this.code={vertex:"",fragment:""},this.nodeCode={vertex:"",fragment:""},this.resultCode={vertex:"",fragment:""},this.finalCode={vertex:"",fragment:""},this.inputs={uniforms:{list:[],vertex:[],fragment:[]},arrayUniforms:{list:[],vertex:[],fragment:[]},vars:{varying:[],vertex:[],fragment:[]}},this.defines={},this.uniforms={},this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.updaters=[],this.nodes=[],this.analyzing=!1}build(r,e){this.addVertexParsCode(Qy),this.addFragmentParsCode(Jy),this.buildShader("vertex",r),this.buildShader("fragment",e);for(let t=0;t<this.requires.uv.length;t++)if(this.requires.uv[t]){let o=t>0?t+1:"";this.addVaryCode("varying vec2 vUv"+o+";"),t>0&&this.addVertexParsCode("attribute vec2 uv"+o+";"),this.addVertexFinalCode("vUv"+o+" = uv"+o+";")}return this.requires.color[0]&&(this.addVaryCode("varying vec4 vColor;"),this.addVertexParsCode("attribute vec4 color;"),this.addVertexFinalCode("vColor = color;")),this.requires.color[1]&&(this.addVaryCode("varying vec4 vColor2;"),this.addVertexParsCode("attribute vec4 color2;"),this.addVertexFinalCode("vColor2 = color2;")),this.requires.position&&(this.addVaryCode("varying vec3 vPosition;"),this.addVertexFinalCode("vPosition = transformed;")),this.requires.worldPosition,this.requires.normal&&(this.addVaryCode("varying vec3 vObjectNormal;"),this.addVertexFinalCode("vObjectNormal = normal;")),this.requires.modelMatrix&&this.addFragmentParsCode("uniform mat4 modelMatrix;"),this.requires.viewMatrix&&this.addFragmentParsCode("uniform mat4 viewMatrix;"),this.requires.projectionMatrix&&this.addFragmentParsCode("uniform mat4 projectionMatrix;"),this.requires.worldNormal&&(this.addVaryCode("varying vec3 vWNormal;"),this.addVertexFinalCode("vWNormal = inverseTransformDirection( transformedNormal, viewMatrix ).xyz;")),this.requires.vWorldViewDir&&(this.addVaryCode("varying vec3 vWorldViewDir;"),this.addVertexFinalCode("vWorldViewDir = isPerspectiveMatrix( projectionMatrix ) ? ( (modelMatrix * vec4(position, 1.0)).xyz - cameraPosition ) : vec3( -viewMatrix[0][2], -viewMatrix[1][2], -viewMatrix[2][2] );")),this.needsJitter&&(this.addVertexFinalCode(eg),this.addFragmentFinalCode(tg)),this}buildShader(r,e){this.resultCode[r]=e.build(this.setShader(r),"v4")}setMaterial(r,e){return this.defines={},this}addFlow(r,e,t){return this.addSlot(r).addCache(e).addContext(t)}removeFlow(){return this.removeSlot().removeCache().removeContext()}addCache(r){return this.cache=r??"",this.caches.push(this.cache),this}removeCache(){return this.caches.pop(),this.cache=this.caches[this.caches.length-1]||"",this}addContext(r){return this.context=Object.assign({},this.context,r),this.context.extra=this.context.extra||{},this.contexts.push(this.context),this}removeContext(){return this.contexts.pop(),this.context=this.contexts[this.contexts.length-1]||{},this}addSlot(r){return this.slot=r||"",this.slots.push(this.slot),this}removeSlot(){return this.slots.pop(),this.slot=this.slots[this.slots.length-1]||"",this}addFragmentVariable(r,e){this.fragmentVariables[r]===void 0&&(this.addFragmentCode(`${e} ${r};`),this.fragmentVariables[r]="")}addFragmentParsVariable(r,e){this.fragmentParsVariables[r]===void 0&&(this.addFragmentParsCode(`${e} ${r};`),this.fragmentParsVariables[r]="")}addVertexParsVariable(r,e){this.vertexParsVariables[r]===void 0&&(this.addVertexParsCode(`${e} ${r};`),this.vertexParsVariables[r]="")}addVertexCode(r){this.addCode(r,"vertex")}addFragmentCode(r){this.addCode(r,"fragment")}addCode(r,e){this.code[e??this.shader]+=r+`
|
|
226
226
|
`}addVertexNodeCode(r){this.addNodeCode(r,"vertex")}addFragmentNodeCode(r){this.addNodeCode(r,"fragment")}addNodeCode(r,e){this.nodeCode[e??this.shader]+=r+`
|
|
227
227
|
`}clearNodeCode(r){r=r??this.shader;let e=this.nodeCode[r];return this.nodeCode[r]="",e}clearVertexNodeCode(){return this.clearNodeCode("vertex")}clearFragmentNodeCode(){return this.clearNodeCode("fragment")}addVertexFinalCode(r){this.addFinalCode(r,"vertex")}addFragmentFinalCode(r){this.addFinalCode(r,"fragment")}addFinalCode(r,e){this.finalCode[e??this.shader]+=r+`
|
|
228
228
|
`}addVertexParsCode(r){this.addParsCode(r,"vertex")}addFragmentParsCode(r){this.addParsCode(r,"fragment")}addParsCode(r,e){this.parsCode[e??this.shader]+=r+`
|
|
229
|
-
`}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
|
|
230
|
-
`)}getVarListCode(r,e){e=e??"";let t="";for(let o=0,i=r.length;o<i;++o){let s=r[o],
|
|
231
|
-
`:t+=e+" "+
|
|
232
|
-
`}return t}getVars(r){return this.inputs.vars[r??this.shader]}getNodeData(r){let e=r instanceof
|
|
229
|
+
`}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 a=this.getVars(o),c=a[r];if(!c){let u=a.length;c={name:t||"node"+i+u+(s?"_"+s:""),type:e},a.push(c),a[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(`
|
|
230
|
+
`)}getVarListCode(r,e){e=e??"";let t="";for(let o=0,i=r.length;o<i;++o){let s=r[o],a=s.type,c=s.name,u=s.size,l=this.getFormatByType(a);if(l===void 0)throw new Error("Node pars "+l+" not found.");l.includes("[]")?t+=e+" "+l.substring(0,l.length-2)+" "+c+`[${u}];
|
|
231
|
+
`:t+=e+" "+l+" "+c+`;
|
|
232
|
+
`}return t}getVars(r){return this.inputs.vars[r??this.shader]}getNodeData(r){let e=r instanceof it?r.uuid:r;return this.nodeData[e]=this.nodeData[e]||{}}createUniform(r,e,t,o,i,s){if(e.includes("[]")){let a=this.inputs.arrayUniforms,c=a.list.length,u=new Ds({type:e,size:t.size,name:o||"nodeUA"+c+(s?"_"+s:""),node:t,needsUpdate:i});return a.list.push(u),a[r].push(u),a[r][u.name]=u,this.uniforms[u.name]=u,u}else{let a=this.inputs.uniforms,c=a.list.length,u=new Ds({type:e,name:o||"nodeU"+c+(s?"_"+s:""),node:t,needsUpdate:i});return a.list.push(u),a[r].push(u),a[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"?Qe.get(r):r,this.context.include===!1)return r.name;r instanceof k?o=this.includes.functions:r instanceof we?o=this.includes.consts:r instanceof vi&&(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 k&&e&&i[e.name]&&i[e.name].deps.indexOf(r)===-1&&(i[e.name].deps.push(r),r.includes?.length)){let a=0;do this.include(r.includes[a++],e);while(a<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 bO[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 yO:case gO:return new kl(t);case xO:return new Fl(new Pt(t));default:return new Pt(t)}else{if(t.isVector2)return new Ve(t);if(t.isVector3)return new ft(t);if(t.isVector4)return new Et(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 SO[r]||r}getFormatByType(r){return wO[r]||r}getUUID(r,e){return e=e!==void 0?e:!0,e&&this.cache&&(r=this.cache+"-"+r),r}getElementByIndex(r){return og[r]}getIndexByElement(r){return og.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=rg,e===rg&&this.context.gamma&&(e=vO),e}};import{Vector2 as pr,Vector3 as Lr,Vector4 as zi}from"three";var Ae=class extends Ne{constructor(e=0,t,o,i){super("c");this.nodeType="Color";this.value=e instanceof Je?e:new Je(e||0,t,o,i)}setRGBA(e){this.value.setRGBA(e.r,e.g,e.b,e.a)}generate(e,t,o,i,s,a){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 l=this.alpha.build(e,"f");e.addFragmentNodeCode(`accumAlpha += ( 1.0 - accumAlpha ) * ${l};`)}return u?this.generateReadonly(e,t,o,i,s,a):e.isShader("vertex")?(c.vertex||(c.vertex=e.createVertexUniform(i,this,s,a,this.getLabel())),e.format(c.vertex.name,i,t)):(c.fragment||(c.fragment=e.createFragmentUniform(i,this,s,a,this.getLabel())),e.format(c.fragment.name,i,t))}generateReadonly(e,t,o,i,s,a){return e.format("vec3("+this.value.r+", "+this.value.g+", "+this.value.b+")",i,t)}};var ve=class extends Ne{constructor(e){super("i");this.nodeType="Int";this.value=Math.floor(e??0)}generateReadonly(e,t,o,i,s,a){return e.format(this.value.toString(),i,t)}};import{UniformsLib as AO,UniformsUtils as CO}from"three";var ke=class extends Ne{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 cr=class extends Ne{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)}};import{Vector3 as _O}from"three";var Co=class extends Ne{};var Hl=class extends Co{constructor(e){super("v3");this.image=e;this._value=new _O}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 Zo=class extends Co{constructor(e,t){super("t");this.image=e;this.wrap=t}get value(){return this.image.getTexture(this.wrap)}};import{Matrix3 as PO}from"three";var _i=class extends Ne{constructor(e){super("m3");this.nodeType="Matrix3";this.value=e??new PO}generateReadonly(e,t,o,i,s,a){return e.format("mat3("+this.value.elements.join(", ")+")",i,t)}get elements(){return this.value.elements}set elements(e){this.value.fromArray(e)}};import{Matrix4 as TO}from"three";var mt=class extends Ne{constructor(e){super("m4");this.nodeType="Matrix4";this.value=e??new TO}generateReadonly(e,t,o,i,s,a){return e.format("mat4("+this.value.elements.join(", ")+")",i,t)}get elements(){return this.value.elements}set elements(e){this.value.fromArray(e)}};import{Matrix3 as OO}from"three";function ng(n,r,e){n.setUvTransform(e[0],e[1],r[0],r[1],0,0,0)}var Wl=class extends _i{constructor(e,t){super(new OO);this.repeat=e;this.offset=t;ng(this.value,e,t)}updateMatrix(){ng(this.value,this.repeat,this.offset)}};import{Vector4 as ig}from"three";var dr=class extends Ne{constructor(e=1,t){super("v4[]");this.nodeType="Vector4Array";this.size=e,this.value=Array.isArray(t)?t:t instanceof ig?new Array(e).fill(t):new Array(e).fill(new ig(0))}};var Pi=class extends ae{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 nu=class extends ae{constructor(e,t){super("v3");this.nodeType="CustomColor";this.color=e,this.alpha=t,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.isShader("fragment")){let o=e.include(nu.Nodes.customColor);e.addFragmentVariable(this.calpha,"float");let i=[];return i.push(this.color.build(e,"v3")),i.push(this.mask?`luminance(${this.mask.build(e,"v3")})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(o+"("+i.join(",")+")",this.getType(e),t)}else return console.warn("CustomColorNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},Qo=nu;Qo.Nodes=function(){return{customColor:new k(`vec3 customColor(vec3 color, float mask, float alpha, out float calpha) {
|
|
233
233
|
float lalpha = alpha * mask;
|
|
234
234
|
calpha = lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0);
|
|
235
235
|
accumAlpha += (1.0 - accumAlpha) * lalpha;
|
|
236
236
|
|
|
237
237
|
return color;
|
|
238
|
-
}`)}}();var
|
|
238
|
+
}`)}}();var iu=class extends ae{constructor(e,t){super("v3");this.nodeType="CustomNormal";this.cnormal=e,this.alpha=t,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.isShader("fragment")){let o=e.include(iu.Nodes.customNormal);e.addFragmentVariable(this.calpha,"float");let i=[];return i.push(this.cnormal.build(e,"v3")),i.push("normal"),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(o+"("+i.join(",")+")",this.getType(e),t)}else return console.warn("CustomNormalNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},Ti=iu;Ti.Nodes=function(){return{customNormal:new k(`vec3 customNormal(vec3 cnormal, vec3 norm, float mask, float alpha, out float calpha) {
|
|
239
239
|
vec3 normal = packNormalToRGB( norm ).rgb;
|
|
240
240
|
normal *= step( vec3(0.5), cnormal );
|
|
241
241
|
|
|
@@ -244,16 +244,17 @@ gVelocity = vec4(velocity, gl_FragColor.a < 1.0 ? 0.0 : 1.0, 1.);
|
|
|
244
244
|
accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
|
|
245
245
|
|
|
246
246
|
return normal;
|
|
247
|
-
}`)}}();var
|
|
248
|
-
vec3 ${o}_planarTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha) {
|
|
249
|
-
|
|
250
|
-
vec2 uvs = ( mat * vec3( (
|
|
247
|
+
}`)}}();var Oi=class extends ae{constructor(e,t,o,i,s,a,c,u,l,d,p,f){super("v3");this.nodeType="CustomTexture";this.texture=e,this.textureSize=t,this.crop=o,this.projection=i,this.axis=s,this.side=a,this.size=c,this.blending=u,this.mat=l,this.isMask=f,this.alpha=d,this.mode=p,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(Oi.Nodes.cylindrical);break;case 2:i=e.include(Oi.Nodes.spherical);break;case 1:let a=["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=["zy","xz","xy"][this.axis.value],u=new k(`
|
|
248
|
+
vec3 ${o}_planarTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUv) {
|
|
249
|
+
vec2 projected = (1. + (position.${c})) / 2.;
|
|
250
|
+
vec2 uvs = ( mat * vec3( (projected * 2. - 1.) / (size * .5), 1. ) / 2. + 0.5 ).xy;
|
|
251
|
+
writeUv = uvs;
|
|
251
252
|
|
|
252
253
|
vec4 tmp = texture2D( tex, uvs );
|
|
253
254
|
|
|
254
255
|
vec3 col = tmp.rgb;
|
|
255
256
|
float lalpha = alpha * tmp.a;
|
|
256
|
-
${this.side.value===2?"":`lalpha *= step(0.0, ${this.side.value===1?"-1.0 * ":""}dot(vObjectNormal, mat * ${
|
|
257
|
+
${this.side.value===2?"":`lalpha *= step(0.0, ${this.side.value===1?"-1.0 * ":""}dot(vObjectNormal, mat * ${a}));`}
|
|
257
258
|
|
|
258
259
|
if ( crop > 0.5 ) {
|
|
259
260
|
if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {
|
|
@@ -267,8 +268,8 @@ gVelocity = vec4(velocity, gl_FragColor.a < 1.0 ? 0.0 : 1.0, 1.);
|
|
|
267
268
|
accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
|
|
268
269
|
|
|
269
270
|
return col;
|
|
270
|
-
}`);i=e.include(
|
|
271
|
-
vec3 cylindricalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha) {
|
|
271
|
+
}`);i=e.include(u);break;case 4:i=e.include(Oi.Nodes.triplanar);break;default:i=e.include(Oi.Nodes.uv);break}e.addFragmentVariable(this.calpha,"float");let s=[];if(s.push("normal"),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.blending.build(e,"f")),s.push(this.isMask.build(e,"b")),s.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),s.push(this.alpha.build(e,"f")),s.push(this.mode.build(e,"i")),s.push(this.calpha),this.projection.value===4){let a=`${o}_writeUvs`,c=a+"0",u=a+"1",l=a+"2",d=`${o}_triplanarWeights`;e.addFragmentVariable(c,"vec2"),e.addFragmentVariable(u,"vec2"),e.addFragmentVariable(l,"vec2"),e.addFragmentVariable(d,"vec3"),s.push(c),s.push(u),s.push(l),s.push(d)}else{let a=`${o}_writeUvs`;e.addFragmentVariable(a,"vec2"),s.push(a)}return e.format(i+"("+s.join(",")+")",this.getType(e),t)}},No=Oi;No.Nodes=function(){let e=new k(`
|
|
272
|
+
vec3 cylindricalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUv) {
|
|
272
273
|
vec3 posN = normalize(position);
|
|
273
274
|
float u = 0.5 + atan(posN.z, posN.x) / (2.*3.1415);
|
|
274
275
|
float scaledHeight = position.y / (size.y * 0.5);
|
|
@@ -276,6 +277,7 @@ vec3 cylindricalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop
|
|
|
276
277
|
|
|
277
278
|
vec2 calculatedUv = vec2(u,v);
|
|
278
279
|
vec2 uvs = ( mat * vec3( calculatedUv * 2. - 1., 1. ) / 2. + 0.5 ).xy;
|
|
280
|
+
writeUv = uvs;
|
|
279
281
|
|
|
280
282
|
vec2 df = fwidth(uvs);
|
|
281
283
|
if(df.x > 0.5) df.x = 0.;
|
|
@@ -301,14 +303,15 @@ vec3 cylindricalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop
|
|
|
301
303
|
|
|
302
304
|
return col;
|
|
303
305
|
}
|
|
304
|
-
`),t=new
|
|
305
|
-
vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha) {
|
|
306
|
+
`),t=new k(`
|
|
307
|
+
vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUv) {
|
|
306
308
|
vec3 posN = normalize(vPosition);
|
|
307
309
|
float u = 0.5 + atan(posN.z, posN.x) / (2.*3.1415);
|
|
308
310
|
float v = 0.5 + asin(posN.y) / 3.1415;
|
|
309
311
|
|
|
310
312
|
vec2 calculatedUv = vec2(u,v);
|
|
311
313
|
vec2 uvs = ( mat * vec3( calculatedUv * 2. - 1., 1. ) / 2. + 0.5 ).xy;
|
|
314
|
+
writeUv = uvs;
|
|
312
315
|
|
|
313
316
|
vec2 df = fwidth(uvs);
|
|
314
317
|
if(df.x > 0.5) df.x = 0.;
|
|
@@ -333,9 +336,10 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
|
|
|
333
336
|
|
|
334
337
|
return col;
|
|
335
338
|
}
|
|
336
|
-
`),o=new
|
|
337
|
-
|
|
339
|
+
`),o=new k(`vec3 uvTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUv) {
|
|
338
340
|
vec2 uvs = ( mat * vec3( vUv * 2. - 1., 1. ) / 2. + 0.5 ).xy;
|
|
341
|
+
writeUv = uvs;
|
|
342
|
+
|
|
339
343
|
vec4 tmp = texture2D( tex, uvs );
|
|
340
344
|
|
|
341
345
|
vec3 col = tmp.rgb;
|
|
@@ -353,7 +357,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
|
|
|
353
357
|
accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
|
|
354
358
|
|
|
355
359
|
return col;
|
|
356
|
-
}`),i=new
|
|
360
|
+
}`),i=new k(`vec3 triplanarTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUvs0, out vec2 writeUvs1, out vec2 writeUvs2, out vec3 writeWeights) {
|
|
357
361
|
vec3 p = position;
|
|
358
362
|
vec2 uv0 = (1.0 + p.xy) / 2.0;
|
|
359
363
|
vec2 uv1 = (1.0 + p.zy) / 2.0;
|
|
@@ -371,6 +375,12 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
|
|
|
371
375
|
weights = pow(weights, vec3(exponent));
|
|
372
376
|
weights /= dot(weights, vec3(1.0));
|
|
373
377
|
|
|
378
|
+
// Write out all sets of UVs that we generated
|
|
379
|
+
writeUvs0 = uv0;
|
|
380
|
+
writeUvs1 = uv1;
|
|
381
|
+
writeUvs2 = uv2;
|
|
382
|
+
writeWeights = weights;
|
|
383
|
+
|
|
374
384
|
// Derivatives for LOD
|
|
375
385
|
vec2 df0 = fwidth(uv0);
|
|
376
386
|
vec2 df1 = fwidth(uv1);
|
|
@@ -413,7 +423,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
|
|
|
413
423
|
|
|
414
424
|
return col;//n * 0.5 + 0.5;
|
|
415
425
|
}
|
|
416
|
-
`);return{cylindrical:e,spherical:t,uv:o,triplanar:i}}();var
|
|
426
|
+
`);return{cylindrical:e,spherical:t,uv:o,triplanar:i}}();var Ai=class extends ae{constructor(e,t,o,i,s,a,c,u,l,d,p,f){super("v3");this.nodeType="Depth";this.gradientType=e,this.smooth=t,this.near=o,this.far=i,this.isVector=s,this.isWorldSpace=a,this.origin=c,this.direction=u,this.colors=l,this.steps=d,this.isMask=f,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 k(`vec3 ${o}_sdepth(float near, float far, vec3 origin, vec3 direction, vec4 colors[${o}_MAX_COLORS], float steps[${o}_MAX_COLORS], bool isMask, float mask, float alpha, out float calpha) {
|
|
417
427
|
vec4 color = colors[0];
|
|
418
428
|
#ifdef ${o}_IS_VECTOR
|
|
419
429
|
#ifdef ${o}_LINEAR
|
|
@@ -453,21 +463,21 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
|
|
|
453
463
|
accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
|
|
454
464
|
|
|
455
465
|
return color.rgb;
|
|
456
|
-
}`,[
|
|
466
|
+
}`,[Ai.Nodes.vectorLinearWorldSpaceDepth,Ai.Nodes.vectorLinearObjectSpaceDepth,Ai.Nodes.vectorSphericalObjectSpaceDepth,Ai.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),a=[];return a.push(this.near.build(e,"f")),a.push(this.far.build(e,"f")),a.push(this.origin.build(e,"v3")),a.push(this.direction.build(e,"v3")),a.push(this.colors.build(e,"v4[]")),a.push(this.steps.build(e,"f[]")),a.push(this.isMask.build(e,"b")),a.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),a.push(this.alpha.build(e,"f")),a.push(this.calpha),e.format(s+"("+a.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)}},Ci=Ai;Ci.Nodes=function(){let e=new k(`float vectorLinearWorldSpaceDepth(vec3 direction, vec3 origin, float near, float far) {
|
|
457
467
|
vec3 n = normalize(direction);
|
|
458
468
|
float dist = (n.x*(vWPosition.x - origin.x) + n.y*(vWPosition.y - origin.y) + n.z*(vWPosition.z - origin.z));
|
|
459
469
|
return ( dist - near ) / ( far - near );
|
|
460
|
-
}`),t=new
|
|
470
|
+
}`),t=new k(`float vectorLinearObjectSpaceDepth(vec3 direction, vec3 origin, float near, float far) {
|
|
461
471
|
vec3 n = normalize(direction);
|
|
462
472
|
float dist = (n.x*(position.x - origin.x) + n.y*(position.y - origin.y) + n.z*(position.z - origin.z));
|
|
463
473
|
return ( dist - near ) / ( far - near );
|
|
464
|
-
}`),o=new
|
|
474
|
+
}`),o=new k(`float vectorSphericalWorldSpaceDepth(vec3 origin, float near, float far) {
|
|
465
475
|
float dist = length(vWPosition - origin);
|
|
466
476
|
return ( dist - near ) / ( far - near );
|
|
467
|
-
}`),i=new
|
|
477
|
+
}`),i=new k(`float vectorSphericalObjectSpaceDepth(vec3 origin, float near, float far) {
|
|
468
478
|
float dist = length(position - origin);
|
|
469
479
|
return ( dist - near ) / ( far - near );
|
|
470
|
-
}`);return{vectorLinearWorldSpaceDepth:e,vectorLinearObjectSpaceDepth:t,vectorSphericalWorldSpaceDepth:o,vectorSphericalObjectSpaceDepth:i}}();var
|
|
480
|
+
}`);return{vectorLinearWorldSpaceDepth:e,vectorLinearObjectSpaceDepth:t,vectorSphericalWorldSpaceDepth:o,vectorSphericalObjectSpaceDepth:i}}();var Rs=class extends ae{constructor(e,t,o,i,s,a,c,u){super("v3");this.nodeType="Fresnel";this.color=e,this.bias=t,this.scale=o,this.intensity=i,this.factor=s,this.isMask=u,this.alpha=a,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=new k(`vec3 fresnel(vec3 color, float bias, float scale, float intensity, float factor, bool isMask, float mask, float alpha, int mode, out float calpha) {
|
|
471
481
|
float fresnel = bias + scale * pow( abs( factor + dot( normalize( vWorldViewDir ), normalize( vWNormal ) ) ), intensity );
|
|
472
482
|
|
|
473
483
|
float lalpha = clamp(fresnel, 0.0, 1.0) * alpha * mask;
|
|
@@ -475,7 +485,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
|
|
|
475
485
|
accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
|
|
476
486
|
|
|
477
487
|
return color;
|
|
478
|
-
}`),i=e.include(o),s=[];return s.push(this.color.build(e,"c")),s.push(this.bias.build(e,"f")),s.push(this.scale.build(e,"f")),s.push(this.intensity.build(e,"f")),s.push(this.factor.build(e,"f")),s.push(this.isMask.build(e,"b")),s.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),s.push(this.alpha.build(e,"f")),s.push(this.mode.build(e,"i")),s.push(this.calpha),e.format(i+"("+s.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)}};var
|
|
488
|
+
}`),i=e.include(o),s=[];return s.push(this.color.build(e,"c")),s.push(this.bias.build(e,"f")),s.push(this.scale.build(e,"f")),s.push(this.intensity.build(e,"f")),s.push(this.factor.build(e,"f")),s.push(this.isMask.build(e,"b")),s.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),s.push(this.alpha.build(e,"f")),s.push(this.mode.build(e,"i")),s.push(this.calpha),e.format(i+"("+s.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)}};var su=class extends ae{constructor(e,t,o,i,s,a,c,u,l){super("v3");this.nodeType="Gradient";this.gradientType=e,this.smooth=t,this.colors=o,this.steps=i,this.offset=s,this.morph=a,this.angle=c,this.isMask=l,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(su.Nodes.gradient),i=[];return i.push(this.gradientType.build(e,"i")),i.push(this.smooth.build(e,"b")),i.push(this.colors.build(e,"v4[]")),i.push(this.steps.build(e,"f[]")),i.push(this.offset.build(e,"v2")),i.push(this.morph.build(e,"v2")),i.push(this.angle.build(e,"f")),i.push(this.isMask.build(e,"b")),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(o+"("+i.join(",")+")",this.getType(e),t)}else return console.warn("GradientNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},Ni=su;Ni.Nodes=function(){return{gradient:new k(`vec3 gradient(int gradientType, bool smoothed, vec4 colors[GRAD_MAX], float steps[GRAD_MAX], vec2 offset, vec2 morph, float angle, bool isMask, float mask, float alpha, out float calpha) {
|
|
479
489
|
vec4 color = colors[0];
|
|
480
490
|
vec2 m = morph / vUv.xy;
|
|
481
491
|
vec2 rot = vec2( 0.5 + m.x, m.y );
|
|
@@ -517,7 +527,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
|
|
|
517
527
|
accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
|
|
518
528
|
|
|
519
529
|
return color.xyz;
|
|
520
|
-
}`)}}();var
|
|
530
|
+
}`)}}();var au=class extends ae{constructor(e,t,o,i){super("v3");this.nodeType="Matcap";this.texture=e,this.isMask=i,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(au.Nodes.matcap);e.require("normal"),e.requires.normal=!0;let i=[];return i.push(this.texture.generate(e,"t")),i.push("normal"),i.push(this.isMask.build(e,"b")),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.mode.build(e,"i")),i.push(this.calpha),e.format(o+"("+i.join(",")+")",this.getType(e),t)}else return console.warn("MatcapNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},Ii=au;Ii.Nodes=function(){return{matcap:new k(`vec3 matcap(sampler2D matcapTex, vec3 normal, bool isMask, float mask, float alpha, int mode, out float calpha) {
|
|
521
531
|
vec3 viewDir = normalize( vViewPosition );
|
|
522
532
|
vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
|
|
523
533
|
vec3 y = cross( viewDir, x );
|
|
@@ -529,7 +539,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
|
|
|
529
539
|
accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
|
|
530
540
|
|
|
531
541
|
return matcapColor.rgb;
|
|
532
|
-
}`)}}();var
|
|
542
|
+
}`)}}();var Gs=(s=>(s.SIMPLEX="simplex3d",s.SIMPLEX_FRACTAL="simplex3dFractal",s.ASHIMA="simplexAshima",s.FBM="fbm",s.PERLIN="perlin",s.VORONOI="voronoi",s))(Gs||{}),lt=function(){let r=new k(`vec3 random3(vec3 c) {
|
|
533
543
|
float j = 4096.0*sin(dot(c,vec3(17.0, 59.4, 15.0)));
|
|
534
544
|
vec3 r;
|
|
535
545
|
r.z = fract(512.0*j);
|
|
@@ -538,7 +548,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
|
|
|
538
548
|
j *= .125;
|
|
539
549
|
r.y = fract(512.0*j);
|
|
540
550
|
return r-0.5;
|
|
541
|
-
}`),e=new
|
|
551
|
+
}`),e=new k(`float simplex3d(vec3 p) {
|
|
542
552
|
vec3 s = floor(p + dot(p, vec3(F3)));
|
|
543
553
|
vec3 x = p - s + dot(s, vec3(G3));
|
|
544
554
|
|
|
@@ -569,7 +579,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
|
|
|
569
579
|
d *= w;
|
|
570
580
|
|
|
571
581
|
return dot(d, vec4(52.0));
|
|
572
|
-
}`,[r]);e.keywords.F3=new
|
|
582
|
+
}`,[r]);e.keywords.F3=new we("float F3 0.3333333"),e.keywords.G3=new we("float G3 0.1666667");let t=new k(`float simplex3dFractal(vec3 m) {
|
|
573
583
|
mat3 rot1 = mat3(-0.37, 0.36, 0.85,-0.14,-0.93, 0.34,0.92, 0.01,0.4);
|
|
574
584
|
mat3 rot2 = mat3(-0.55,-0.39, 0.74, 0.33,-0.91,-0.24,0.77, 0.12,0.63);
|
|
575
585
|
mat3 rot3 = mat3(-0.71, 0.52,-0.47,-0.08,-0.72,-0.68,-0.7,-0.45,0.56);
|
|
@@ -577,7 +587,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
|
|
|
577
587
|
+ 0.2666667 * simplex3d(2.0 * m * rot2)
|
|
578
588
|
+ 0.1333333 * simplex3d(4.0 * m * rot3)
|
|
579
589
|
+ 0.0666667 * simplex3d(8.0 * m);
|
|
580
|
-
}`,[e]),o=new
|
|
590
|
+
}`,[e]),o=new k("vec4 permute(vec4 x){return mod(((x*34.0)+1.0)*x, 289.0);}"),i=new k("vec4 taylorInvSqrt(vec4 r){return 1.79284291400159 - 0.85373472095314 * r;}"),s=new k(`float simplexAshima(vec3 v) {
|
|
581
591
|
const vec2 C = vec2(1.0/6.0, 1.0/3.0) ;
|
|
582
592
|
const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);
|
|
583
593
|
vec3 i = floor(v + dot(v, C.yyy) );
|
|
@@ -622,7 +632,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
|
|
|
622
632
|
m = m * m;
|
|
623
633
|
return 42.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1),
|
|
624
634
|
dot(p2,x2), dot(p3,x3) ) );
|
|
625
|
-
}`,[o,i]),
|
|
635
|
+
}`,[o,i]),a=new k("vec4 mod289(vec4 x){return x - floor(x * (1.0 / 289.0)) * 289.0;}"),c=new k("vec4 perm(vec4 x){return mod289(((x * 34.0) + 1.0) * x);}",[a]),u=new k(`float noise(vec3 p){
|
|
626
636
|
vec3 a = floor(p);
|
|
627
637
|
vec3 d = p - a;
|
|
628
638
|
d = d * d * (3.0 - 2.0 * d);
|
|
@@ -637,7 +647,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
|
|
|
637
647
|
vec4 o3 = o2 * d.z + o1 * (1.0 - d.z);
|
|
638
648
|
vec2 o4 = o3.yw * d.x + o3.xz * (1.0 - d.x);
|
|
639
649
|
return o4.y * d.y + o4.x * (1.0 - d.y);
|
|
640
|
-
}`,[c]),
|
|
650
|
+
}`,[c]),l=new k(`float fbm(vec3 x) {
|
|
641
651
|
float v = 0.0;
|
|
642
652
|
float a = 0.5;
|
|
643
653
|
vec3 shift = vec3(100);
|
|
@@ -647,7 +657,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
|
|
|
647
657
|
a *= 0.5;
|
|
648
658
|
}
|
|
649
659
|
return v;
|
|
650
|
-
}`,[u]);
|
|
660
|
+
}`,[u]);l.keywords.NUM_OCTAVES=new we(`int NUM_OCTAVES ${5}`);let d=new k("vec3 fade(vec3 t) {return t*t*t*(t*(t*6.0-15.0)+10.0);}"),p=new k(`float perlin(vec3 P){
|
|
651
661
|
vec3 Pi0 = floor(P);
|
|
652
662
|
vec3 Pi1 = Pi0 + vec3(1.0);
|
|
653
663
|
Pi0 = mod(Pi0, 289.0);
|
|
@@ -706,17 +716,17 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
|
|
|
706
716
|
vec2 n_yz = mix(n_z.xy, n_z.zw, fade_xyz.y);
|
|
707
717
|
float n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x);
|
|
708
718
|
return 2.2 * n_xyz;
|
|
709
|
-
}`,[o,i,d]),f=new
|
|
719
|
+
}`,[o,i,d]),f=new k(`float hashwithoutsine13(vec3 p3)
|
|
710
720
|
{
|
|
711
721
|
p3 = fract(p3 * .1031);
|
|
712
722
|
p3 += dot(p3, p3.yzx + 33.33);
|
|
713
723
|
return fract((p3.x + p3.y) * p3.z);
|
|
714
|
-
}`),m=new
|
|
724
|
+
}`),m=new k(`vec3 hashwithoutsine33(vec3 p3)
|
|
715
725
|
{
|
|
716
726
|
p3 = fract(p3 * vec3(.1031, .1030, .0973));
|
|
717
727
|
p3 += dot(p3, p3.yxz+33.33);
|
|
718
728
|
return fract((p3.xxy + p3.yxx)*p3.zyx);
|
|
719
|
-
}`),h=new
|
|
729
|
+
}`),h=new k(`float metric(in vec3 p)
|
|
720
730
|
{
|
|
721
731
|
// L2
|
|
722
732
|
return length(p);
|
|
@@ -724,17 +734,17 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
|
|
|
724
734
|
// Chebyshev
|
|
725
735
|
// vec3 a = abs(p);
|
|
726
736
|
// return max(a.x, max(a.y, a.z));
|
|
727
|
-
}`),y=new
|
|
737
|
+
}`),y=new k(`float smin( float a, float b, float k )
|
|
728
738
|
{
|
|
729
739
|
float h = smoothstep(0.0, 1.0, 0.5 + 0.5 * (b - a) / k);
|
|
730
740
|
float correction = k * h * (1.0 - h);
|
|
731
741
|
return mix(b, a, h) - correction;
|
|
732
|
-
}`),g=new
|
|
742
|
+
}`),g=new k(`float smax( float a, float b, float k )
|
|
733
743
|
{
|
|
734
744
|
float h = smoothstep(1.0, 0.0, 0.5 + 0.5 * (a - b) / k);
|
|
735
745
|
float correction = k * h * (1.0 - h);
|
|
736
746
|
return mix(a, b, h) + correction;
|
|
737
|
-
}`),
|
|
747
|
+
}`),x=new k(`float remap(float value, float input_min, float input_max, float output_min, float output_max) {
|
|
738
748
|
// Compute width of each interval
|
|
739
749
|
float input_width = input_max - input_min;
|
|
740
750
|
float output_width = output_max - output_min;
|
|
@@ -744,7 +754,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
|
|
|
744
754
|
|
|
745
755
|
// Convert the 0-1 range into a value in output range
|
|
746
756
|
return output_min + (scaled * output_width);
|
|
747
|
-
}`),b=new
|
|
757
|
+
}`),b=new k(`float voronoi(in vec3 x, in int style, in float smoothness, in float seed, in int quality)
|
|
748
758
|
{
|
|
749
759
|
// Integer and fractional parts of this point's coordinates
|
|
750
760
|
ivec3 p = ivec3(floor(x));
|
|
@@ -882,8 +892,8 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
|
|
|
882
892
|
return hashwithoutsine13(vec3(p + mb) + seed);
|
|
883
893
|
}
|
|
884
894
|
}
|
|
885
|
-
`,[f,m,h,y,g,
|
|
886
|
-
float v = ${
|
|
895
|
+
`,[f,m,h,y,g,x]);return{simplex:e,simplexFractal:t,simplexAshima:s,fbm:l,perlin:p,voronoi:b}}();var Mi=class extends ae{constructor(e,t,o,i,s,a,c,u,l,d,p,f,m,h,y,g,x,b,w){super("v3");this.nodeType="Noise";this.scale=e,this.size=t,this.move=o,this.fA=i,this.fB=s,this.distortion=a,this.colorA=c,this.colorB=u,this.colorC=l,this.colorD=d,this.noiseType=f,this.voronoiStyle=h,this.highCut=y,this.lowCut=g,this.smoothness=x,this.seed=b,this.quality=w,this.isMask=m,this.alpha=p,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 a=Object.values(Gs)[this.noiseType.value],c=a=="voronoi"?`
|
|
896
|
+
float v = ${a}(st + move, voronoiStyle, smoothness, seed, quality);
|
|
887
897
|
|
|
888
898
|
// Apply clipping to colors
|
|
889
899
|
v = remap(v, lowCut, highCut, 0.0, 1.0);
|
|
@@ -893,18 +903,18 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
|
|
|
893
903
|
// Note that the voronoi mode only uses colors "A" and "C" from the UI
|
|
894
904
|
vec4 color = mix(colorA, colorC, v);
|
|
895
905
|
`:`
|
|
896
|
-
vec3 q = vec3(${
|
|
897
|
-
${
|
|
898
|
-
${
|
|
899
|
-
vec3 r = vec3(${
|
|
900
|
-
${
|
|
901
|
-
${
|
|
902
|
-
float f = ${
|
|
906
|
+
vec3 q = vec3(${a}(st),
|
|
907
|
+
${a}(st + vec3(1.0)),
|
|
908
|
+
${a}(st + vec3(1.0)));
|
|
909
|
+
vec3 r = vec3(${a}(st + vec3(distortion, 1.0) * q + vec3(fA, 1.0) + move),
|
|
910
|
+
${a}(st + vec3(distortion, 1.0) * q + vec3(fB, 1.0) + move),
|
|
911
|
+
${a}(st * q));
|
|
912
|
+
float f = ${a}(st + r);
|
|
903
913
|
vec4 color;
|
|
904
914
|
color = mix(colorA, colorB, clamp((f * f) * 4.0, 0.0, 1.0));
|
|
905
915
|
color = mix(color, colorC, clamp(length(q), 0.0, 1.0));
|
|
906
916
|
color = mix(color, colorD, clamp(length(r.x), 0.0, 1.0));
|
|
907
|
-
`,u=new
|
|
917
|
+
`,u=new k(`vec3 ${a}customNoise(float scale, vec3 size, float move, vec2 fA, vec2 fB, vec2 distortion, vec4 colorA, vec4 colorB, vec4 colorC, vec4 colorD, int voronoiStyle, float highCut, float lowCut, float smoothness, float seed, int quality, bool isMask, float mask, float alpha, out float calpha)
|
|
908
918
|
{
|
|
909
919
|
// Prevent scale of zero
|
|
910
920
|
scale = max(abs(scale), 0.001);
|
|
@@ -919,10 +929,10 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
|
|
|
919
929
|
accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
|
|
920
930
|
|
|
921
931
|
return clamp(color, 0.0, 1.0).rgb;
|
|
922
|
-
}`,[
|
|
932
|
+
}`,[lt.simplex,lt.simplexFractal,lt.simplexAshima,lt.fbm,lt.perlin,lt.voronoi]),l=e.include(u),d=[];return d.push(this.scale.build(e,"f")),d.push(this.size.build(e,"v3")),d.push(this.move.build(e,"f")),d.push(this.fA.build(e,"v2")),d.push(this.fB.build(e,"v2")),d.push(this.distortion.build(e,"v2")),d.push(this.colorA.build(e,"v4")),d.push(this.colorB.build(e,"v4")),d.push(this.colorC.build(e,"v4")),d.push(this.colorD.build(e,"v4")),d.push(this.voronoiStyle.build(e,"i")),d.push(this.highCut.build(e,"f")),d.push(this.lowCut.build(e,"f")),d.push(this.smoothness.build(e,"f")),d.push(this.seed.build(e,"f")),d.push(this.quality.build(e,"i")),d.push(this.isMask.build(e,"b")),d.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),d.push(this.alpha.build(e,"f")),d.push(this.calpha),e.format(l+"("+d.join(",")+")",this.getType(e),t)}};Mi.numOctaves=5;var lu=class extends ae{constructor(e,t,o,i,s,a,c,u,l,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=a,this.contourFrequency=c,this.outlineSmoothing=u,this.contourDirection=l,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){let o=`g${this.uuid.toString().replace(/-/g,"")}`;if(e.require("vWorldViewDir"),e.require("worldNormal"),e.extensions.derivatives=!0,this.compensation.value&&e.define("OUTLINE_COMPENSATION",`${o}_offset`),this.firstTime){let i=this.outlineWidth.build(e,"f"),s=this.resolution.build(e,"v2"),a=this.compensation.build(e,"b"),c=this.pixelRatio.build(e,"f");e.addVertexParsVariable("randomColor","attribute vec3"),e.addVertexParsVariable("extrudeNormal","attribute vec3"),e.addVertexParsVariable(i,"uniform float"),e.addVertexParsVariable(s,"uniform vec2"),e.addVertexParsVariable(a,"uniform bool"),e.addVertexParsVariable(c,"uniform float"),e.addVertexParsVariable("vID","flat out float"),e.addFragmentParsVariable("vID","flat in float"),e.addVertexFinalCode(`
|
|
923
933
|
vID = randomColor.r;
|
|
924
934
|
vec2 ${o}_offset = vec2(0.0);
|
|
925
|
-
if (${
|
|
935
|
+
if (${a}) {
|
|
926
936
|
vec4 ${o}_clipPosition = projectionMatrix * (modelViewMatrix * vec4(position, 1.0));
|
|
927
937
|
// NOTE: For certain shapes, like spheres, we get incorrect extrusion when the
|
|
928
938
|
// normals face the camera directly. So we hackily fix this by offsetting the normal
|
|
@@ -934,7 +944,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
|
|
|
934
944
|
// if this offset is the biggest of all the potential offsets
|
|
935
945
|
gl_Position = ${o}_clipPosition;
|
|
936
946
|
}
|
|
937
|
-
`)}if(e.isShader("fragment")){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let i=e.include(
|
|
947
|
+
`)}if(e.isShader("fragment")){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let i=e.include(lu.Nodes.outline),s=[];return s.push(this.outlineColor.build(e,"c")),s.push(this.contourColor.build(e,"c")),s.push(this.outlineWidth.build(e,"f")),s.push(this.contourWidth.build(e,"f")),s.push(this.contourThreshold.build(e,"f")),s.push(this.outlineThreshold.build(e,"f")),s.push(this.contourFrequency.build(e,"f")),s.push(this.outlineSmoothing.build(e,"f")),s.push(this.contourDirection.build(e,"v3")),s.push(this.positionalLines.build(e,"b")),s.push(this.resolution.build(e,"v2")),s.push(this.normalMap.getTexture(e,"t")),s.push(this.depthMap.getTexture(e,"t")),s.push(this.pixelRatio.build(e,"f")),s.push(this.compensation.build(e,"b")),s.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),s.push(this.alpha.build(e,"f")),s.push(this.calpha),this.firstTime=!this.firstTime,e.format(i+"("+s.join(",")+")",this.getType(e),t)}else return console.warn("OutlineNode is not compatible with "+e.shader+" shader."),""}},Ei=lu;Ei.Nodes=function(){let e=new k(`
|
|
938
948
|
float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outlineWidth, float pixelRatio)
|
|
939
949
|
{
|
|
940
950
|
vec2 halton = haltonSequence[frameIndex];
|
|
@@ -1040,7 +1050,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1040
1050
|
float edgeNormal = sqrt(dot(sobel_edge_h, sobel_edge_h) + dot(sobel_edge_v, sobel_edge_v));
|
|
1041
1051
|
return edgeNormal;
|
|
1042
1052
|
}
|
|
1043
|
-
`);return{outline:new
|
|
1053
|
+
`);return{outline:new k(`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 mask, float alpha, out float calpha) {
|
|
1044
1054
|
vec3 result = outlineColor;
|
|
1045
1055
|
float resultAlpha = 0.0;
|
|
1046
1056
|
|
|
@@ -1083,12 +1093,12 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1083
1093
|
accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
|
|
1084
1094
|
|
|
1085
1095
|
return result;
|
|
1086
|
-
}`,[e])}}();var
|
|
1096
|
+
}`,[e])}}();var Mr=class extends ae{constructor(e,t,o,i,s,a,c,u,l,d,p,f,m,h,y,g,x,b){super("v3");this.nodeType="Pattern";this.style=e,this.projection=t,this.axis=o,this.blending=i,this.offset=s,this.colorA=a,this.colorB=c,this.frequency=u,this.size=l,this.variation=d,this.smoothness=p,this.zigzag=f,this.rotation=m,this.vertical=h,this.horizontal=y,this.sides=g,this.isMask=b,this.alpha=x,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.isShader("fragment")){e.require("position"),e.require("uv"),e.requires.uv=[!0],e.require("normal"),e.requires.normal=!0,e.addFragmentVariable(this.calpha,"float");let o;switch(this.style.value){case 0:o="circle";break;case 1:o="ring";break;case 2:o="polygon";break;case 3:o="xcross";break;case 4:o="diamond";break;case 5:o="checkerboard";break;case 6:o="line";break;case 7:o="wave";break;default:o="circle";break}let i=`g${this.uuid.toString().replace(/-/g,"")}`,s=new k(`float hashwithoutsine12(vec2 p)
|
|
1087
1097
|
{
|
|
1088
1098
|
vec3 p3 = fract(vec3(p.xyx) * .1031);
|
|
1089
1099
|
p3 += dot(p3, p3.yzx + 33.33);
|
|
1090
1100
|
return fract((p3.x + p3.y) * p3.z);
|
|
1091
|
-
}`),
|
|
1101
|
+
}`),a=new k(`vec2 rotate_uv(in vec2 uv, float a, bool repeat)
|
|
1092
1102
|
{
|
|
1093
1103
|
const float mid = 0.5;
|
|
1094
1104
|
float radians = a * (PI / 180.0);
|
|
@@ -1145,7 +1155,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1145
1155
|
custom_uv = rotate_uv(custom_uv, rotation, true);
|
|
1146
1156
|
|
|
1147
1157
|
float draw = ${p};
|
|
1148
|
-
`}let u=new
|
|
1158
|
+
`}let u=new k(`vec3 ${i}_pattern(vec3 normal, float blending, int style, vec2 offset, vec4 colorA, vec4 colorB, vec2 frequency, float size, float variation, float smoothness, float zigzag, float rotation, vec2 vertical, vec2 horizontal, int sides, bool isMask, float mask, float alpha, out float calpha) {
|
|
1149
1159
|
const float TWO_PI = PI * 2.0;
|
|
1150
1160
|
float smoothness_remapped = pow(smoothness, 5.0);
|
|
1151
1161
|
|
|
@@ -1169,11 +1179,11 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1169
1179
|
accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
|
|
1170
1180
|
|
|
1171
1181
|
return clamp(color, 0.0, 1.0).rgb;
|
|
1172
|
-
}`,[
|
|
1182
|
+
}`,[a,s,Mr.DrawFunctions.circle,Mr.DrawFunctions.ring,Mr.DrawFunctions.polygon,Mr.DrawFunctions.cross,Mr.DrawFunctions.diamond,Mr.DrawFunctions.checkerboard,Mr.DrawFunctions.line,Mr.DrawFunctions.wave]),l=e.include(u),d=[];return d.push("normal"),d.push(this.blending.build(e,"f")),d.push(this.style.build(e,"i")),d.push(this.offset.build(e,"v2")),d.push(this.colorA.build(e,"v4")),d.push(this.colorB.build(e,"v4")),d.push(this.frequency.build(e,"v2")),d.push(this.size.build(e,"f")),d.push(this.variation.build(e,"f")),d.push(this.smoothness.build(e,"f")),d.push(this.zigzag.build(e,"f")),d.push(this.rotation.build(e,"f")),d.push(this.vertical.build(e,"v2")),d.push(this.horizontal.build(e,"v2")),d.push(this.sides.build(e,"i")),d.push(this.isMask.build(e,"b")),d.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),d.push(this.alpha.build(e,"f")),d.push(this.calpha),e.format(l+"("+d.join(",")+")",this.getType(e),t)}else return console.warn("PatterNode is not compatible with "+e.shader+" shader."),e.format("vec3(0.0)",this.getType(e),t)}},Li=Mr;Li.DrawFunctions=function(){let e=new k(`float hashwithoutsine12(vec2 p) {
|
|
1173
1183
|
vec3 p3 = fract(vec3(p.xyx) * 0.1031);
|
|
1174
1184
|
p3 += dot(p3, p3.yzx + 33.33);
|
|
1175
1185
|
return fract((p3.x + p3.y) * p3.z);
|
|
1176
|
-
}`),t=new
|
|
1186
|
+
}`),t=new k(`vec2 tile_and_center(in vec2 uv, in vec2 frequency, in float variation, in float zigzag, in float rotation) {
|
|
1177
1187
|
// Create tiles in UV-space
|
|
1178
1188
|
uv *= frequency;
|
|
1179
1189
|
|
|
@@ -1202,14 +1212,14 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1202
1212
|
f *= jitter;
|
|
1203
1213
|
|
|
1204
1214
|
return f;
|
|
1205
|
-
}`,[e]),o=new
|
|
1215
|
+
}`,[e]),o=new k(`float circle(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {
|
|
1206
1216
|
vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation);
|
|
1207
1217
|
return smoothstep(
|
|
1208
1218
|
-smoothness,
|
|
1209
1219
|
smoothness,
|
|
1210
1220
|
length(f) - size
|
|
1211
1221
|
);
|
|
1212
|
-
}`,[t]),i=new
|
|
1222
|
+
}`,[t]),i=new k(`float ring(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {
|
|
1213
1223
|
vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation);
|
|
1214
1224
|
|
|
1215
1225
|
float d = length(f);
|
|
@@ -1218,7 +1228,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1218
1228
|
float outer = smoothstep(-smoothness, smoothness, d - size);
|
|
1219
1229
|
float inner = smoothstep(-smoothness, smoothness, d - size * inner_width);
|
|
1220
1230
|
return outer + (1.0 - inner);
|
|
1221
|
-
}`,[t]),s=new
|
|
1231
|
+
}`,[t]),s=new k(`float sdf_ngon(in vec2 p, in float r, in int n) {
|
|
1222
1232
|
float an = (PI * 2.0) / float(n);
|
|
1223
1233
|
float he = r * tan(0.5 * an);
|
|
1224
1234
|
|
|
@@ -1235,7 +1245,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1235
1245
|
float polygon(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation, in int sides) {
|
|
1236
1246
|
vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation);
|
|
1237
1247
|
return smoothstep(-smoothness, smoothness, sdf_ngon(f, size, sides));
|
|
1238
|
-
}`,[t]),
|
|
1248
|
+
}`,[t]),a=new k(`float sdf_cross(in vec2 p, in vec2 b, float r ) {
|
|
1239
1249
|
p = abs(p);
|
|
1240
1250
|
p = (p.y > p.x) ? p.yx : p.xy;
|
|
1241
1251
|
vec2 q = p - b;
|
|
@@ -1248,7 +1258,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1248
1258
|
float xcross(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {
|
|
1249
1259
|
vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation);
|
|
1250
1260
|
return smoothstep(-smoothness, smoothness, sdf_cross(f, vec2(size, size * 0.25), smoothness));
|
|
1251
|
-
}`,[t]),c=new
|
|
1261
|
+
}`,[t]),c=new k(`float ndot(vec2 a, vec2 b) {
|
|
1252
1262
|
return a.x*b.x - a.y*b.y;
|
|
1253
1263
|
}
|
|
1254
1264
|
|
|
@@ -1262,7 +1272,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1262
1272
|
float diamond(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {
|
|
1263
1273
|
vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation);
|
|
1264
1274
|
return smoothstep(-smoothness, smoothness, sdf_diamond(f, vec2(size)));
|
|
1265
|
-
}`,[t]),u=new
|
|
1275
|
+
}`,[t]),u=new k(`float checkerboard(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {
|
|
1266
1276
|
uv *= frequency;
|
|
1267
1277
|
vec2 i = floor(uv);
|
|
1268
1278
|
|
|
@@ -1272,7 +1282,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1272
1282
|
float x = floor(uv.x);
|
|
1273
1283
|
|
|
1274
1284
|
return mod(x, 2.0);
|
|
1275
|
-
}`),
|
|
1285
|
+
}`),l=new k(`float line(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {
|
|
1276
1286
|
vec2 f = tile_and_center(uv, frequency, 0.0, zigzag, rotation);
|
|
1277
1287
|
|
|
1278
1288
|
// Different approach for variation param here
|
|
@@ -1285,7 +1295,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1285
1295
|
s + smoothness,
|
|
1286
1296
|
abs(f.y)
|
|
1287
1297
|
);
|
|
1288
|
-
}`,[t]),d=new
|
|
1298
|
+
}`,[t]),d=new k(`// Uses bisection
|
|
1289
1299
|
float udf_cos(in vec2 p, in float a, in float b, in float c, in float d) {
|
|
1290
1300
|
// Convert all data to a primitive cosine wave
|
|
1291
1301
|
p = c * (p - vec2(d, a));
|
|
@@ -1334,7 +1344,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1334
1344
|
float s = mix(size, size * rand, variation);
|
|
1335
1345
|
|
|
1336
1346
|
return smoothstep(-smoothness, smoothness, distance_estimate - s * 0.5);
|
|
1337
|
-
}`);return{tileAndCenter:t,circle:o,ring:i,polygon:s,cross:
|
|
1347
|
+
}`);return{tileAndCenter:t,circle:o,ring:i,polygon:s,cross:a,diamond:c,checkerboard:u,line:l,wave:d}}();var cu=class extends ae{constructor(e,t,o,i,s,a,c,u){super("v3");this.nodeType="Rainbow";this.filmThickness=e,this.movement=t,this.wavelengths=o,this.noiseStrength=i,this.noiseScale=s,this.offset=a,this.isMask=u,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(cu.Nodes.rainbow),i=[];return i.push(this.filmThickness.build(e,"f")),i.push(this.movement.build(e,"f")),i.push(this.wavelengths.build(e,"v3")),i.push(this.noiseStrength.build(e,"f")),i.push(this.noiseScale.build(e,"f")),i.push(this.offset.build(e,"v3")),i.push(this.isMask.build(e,"b")),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(o+"("+i.join(",")+")",this.getType(e),t)}else return console.warn("RainbowNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},Di=cu;Di.Nodes=function(){let e=new k(`vec3 attenuation(vec3 wavelengths, float filmThickness, float movement, float noiseStrength, float noiseScale, vec3 offset) {
|
|
1338
1348
|
vec3 st = position / noiseScale;
|
|
1339
1349
|
vec3 q = vec3(simplex3d(st),
|
|
1340
1350
|
simplex3d(st + vec3(1.0)),
|
|
@@ -1347,7 +1357,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1347
1357
|
float noise = simplex3d(st + r);
|
|
1348
1358
|
|
|
1349
1359
|
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);
|
|
1350
|
-
}`,[
|
|
1360
|
+
}`,[lt.simplex]);return{rainbow:new k(`vec3 rainbow(float filmThickness, float movement, vec3 wavelengths, float noiseStrength, float noiseScale, vec3 offset, bool isMask, float mask, float alpha, out float calpha) {
|
|
1351
1361
|
vec3 res = clamp(attenuation(wavelengths, filmThickness, movement, noiseStrength, noiseScale, offset), 0.0, 2.0);
|
|
1352
1362
|
|
|
1353
1363
|
float rainbowContribution = clamp(res.r + res.g + res.b, 0.0, 1.0);
|
|
@@ -1357,14 +1367,14 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1357
1367
|
accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
|
|
1358
1368
|
|
|
1359
1369
|
return res;
|
|
1360
|
-
}`,[e])}}();var
|
|
1370
|
+
}`,[e])}}();var du=class extends ae{constructor(e,t,o,i,s,a,c,u,l,d){super("v3");this.nodeType="Toon";this.positioning=e,this.colors=t,this.steps=o,this.source=i,this.isWorldSpace=s,this.noiseStrength=a,this.noiseScale=c,this.shadowColor=u,this.offset=l,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(du.Nodes.toon),i=[];return i.push(this.positioning.build(e,"i")),i.push(this.colors.build(e,"v4[]")),i.push(this.steps.build(e,"f[]")),i.push(this.source.build(e,"v3")),i.push(this.isWorldSpace.build(e,"b")),i.push(this.noiseStrength.build(e,"f")),i.push(this.noiseScale.build(e,"f")),i.push(this.shadowColor.build(e,"v4")),i.push(this.offset.build(e,"v3")),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(o+"("+i.join(",")+")",this.getType(e),t)}else return console.warn("ToonNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},Bi=du;Bi.Nodes=function(){let e=new k(`float rand(float n) {
|
|
1361
1371
|
return fract(sin(n) * 43758.5453123);
|
|
1362
|
-
}`),t=new
|
|
1372
|
+
}`),t=new k(`float hash1(float p) {
|
|
1363
1373
|
p = fract(p * 0.011);
|
|
1364
1374
|
p *= p + 7.5;
|
|
1365
1375
|
p *= p + p;
|
|
1366
1376
|
return fract(p);
|
|
1367
|
-
}`),o=new
|
|
1377
|
+
}`),o=new k(`float valueNoise(vec3 x) {
|
|
1368
1378
|
const vec3 step = vec3(110, 241, 171);
|
|
1369
1379
|
|
|
1370
1380
|
vec3 i = floor(x);
|
|
@@ -1379,13 +1389,13 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1379
1389
|
mix( hash1(n + dot(step, vec3(0, 1, 0))), hash1(n + dot(step, vec3(1, 1, 0))), u.x), u.y),
|
|
1380
1390
|
mix(mix( hash1(n + dot(step, vec3(0, 0, 1))), hash1(n + dot(step, vec3(1, 0, 1))), u.x),
|
|
1381
1391
|
mix( hash1(n + dot(step, vec3(0, 1, 1))), hash1(n + dot(step, vec3(1, 1, 1))), u.x), u.y), u.z);
|
|
1382
|
-
}`,[t]),i=new
|
|
1392
|
+
}`,[t]),i=new k(`vec3 hash3(vec3 x) {
|
|
1383
1393
|
x = vec3(dot(x,vec3(127.1, 311.7, 74.7)),
|
|
1384
1394
|
dot(x,vec3(269.5, 183.3, 246.1)),
|
|
1385
1395
|
dot(x,vec3(113.5, 271.9, 124.6)));
|
|
1386
1396
|
|
|
1387
1397
|
return fract(sin(x)*43758.5453123);
|
|
1388
|
-
}`),s=new
|
|
1398
|
+
}`),s=new k(`vec3 voronoiNoise(in vec3 x)
|
|
1389
1399
|
{
|
|
1390
1400
|
vec3 p = floor(x);
|
|
1391
1401
|
vec3 f = fract(x);
|
|
@@ -1416,7 +1426,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1416
1426
|
|
|
1417
1427
|
return vec3(sqrt(res), abs(id));
|
|
1418
1428
|
}
|
|
1419
|
-
`,[i]);return{toon:new
|
|
1429
|
+
`,[i]);return{toon:new k(`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 mask, float alpha, out float calpha) {
|
|
1420
1430
|
float t = 0.0;
|
|
1421
1431
|
float shadow = 1.0;
|
|
1422
1432
|
|
|
@@ -1593,7 +1603,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1593
1603
|
|
|
1594
1604
|
return color.xyz;
|
|
1595
1605
|
|
|
1596
|
-
}`,[
|
|
1606
|
+
}`,[lt.simplex,e,o,s])}}();import{Vector2 as ag}from"three";var sg=function(){return{textureBicubic:new k(`float w0( float a ) {
|
|
1597
1607
|
return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
|
|
1598
1608
|
}
|
|
1599
1609
|
|
|
@@ -1657,7 +1667,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1657
1667
|
vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
|
|
1658
1668
|
vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
|
|
1659
1669
|
return mix( fSample, cSample, fract( lod ) );
|
|
1660
|
-
}`)}}();var
|
|
1670
|
+
}`)}}();function lg(n,r){return n>=r?new ag(r/n,1):new ag(1,n/r)}var uu=class extends ae{constructor(e,t,o,i,s,a,c,u){super("v3");this.nodeType="Transmission";this.thickness=e,this.ior=t,this.roughness=o,this.transmissionSamplerSize=i,this.transmissionSamplerMap=s,this.transmissionDepthMap=a,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",6),e.define("BLUR_SLOD",Math.pow(2,ye.transmissionLod.value)),e.require("worldPosition"),e.requires.worldNormal=!0,e.requires.modelMatrix=!0,e.requires.projectionMatrix=!0,e.addFragmentVariable(this.calpha,"float");let o=e.include(uu.Nodes.transmission),i=[];return i.push(this.thickness.build(e,"f")),i.push(this.ior.build(e,"f")),i.push(this.roughness.build(e,"f")),i.push(this.transmissionSamplerSize.build(e,"v2")),i.push(this.transmissionSamplerMap.getTexture(e,"t")),i.push(this.transmissionDepthMap.getTexture(e,"t")),i.push(this.aspectRatio.build(e,"v2")),i.push("normal"),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(o+"("+i.join(",")+")",this.getType(e),t)}else return console.warn("TransmissionNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},Ri=uu;Ri.Nodes=function(){let e=new k(`vec3 blur(sampler2D sp, vec2 U, vec2 scale, float lod, sampler2D dm, vec2 unrefractedU, vec2 aspectRatio) {
|
|
1661
1671
|
// Slightly modified version of this:
|
|
1662
1672
|
// https://www.shadertoy.com/view/ltScRG
|
|
1663
1673
|
|
|
@@ -1690,7 +1700,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1690
1700
|
res += textureLod(sp, uv, lod).rgb;
|
|
1691
1701
|
}
|
|
1692
1702
|
return res / float(NUM_SAMPLES);
|
|
1693
|
-
}`),t=new
|
|
1703
|
+
}`),t=new k(`vec3 getVolumeTransmissionRay( vec3 n, vec3 v, float thickness, float ior, mat4 modelMatrix ) {
|
|
1694
1704
|
// Direction of refracted light.
|
|
1695
1705
|
vec3 refractionVector = refract( -v, n, 1.0 / ior );
|
|
1696
1706
|
|
|
@@ -1702,11 +1712,11 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1702
1712
|
|
|
1703
1713
|
// The thickness is specified in local space
|
|
1704
1714
|
return normalize( refractionVector ) * thickness * modelScale;
|
|
1705
|
-
}`),o=new
|
|
1715
|
+
}`),o=new k(`float applyIorToRoughness( float roughness, float ior ) {
|
|
1706
1716
|
// Scale roughness with IOR so that an IOR of 1.0 results in no microfacet refraction and
|
|
1707
1717
|
// an IOR of 1.5 results in the default amount of microfacet refraction.
|
|
1708
1718
|
return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
|
|
1709
|
-
}`),i=new
|
|
1719
|
+
}`),i=new k(`vec3 getTransmissionSample( vec2 fragCoord, float roughness, float ior, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 unrefractedCoords, vec2 aspectRatio) {
|
|
1710
1720
|
// Threejs exports do not pass a depth map to this shader, so we have to fallback to the "Threejs method of blurring" - see
|
|
1711
1721
|
// also the code in convertTransmission.ts, which runs during export
|
|
1712
1722
|
#ifdef IS_THREEJS_EXPORT
|
|
@@ -1717,7 +1727,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1717
1727
|
float lod = applyIorToRoughness(roughness, ior);
|
|
1718
1728
|
return blur(transmissionSamplerMap, fragCoord, vec2(lod), min(framebufferLod / 5.5, 8.5), transmissionDepthMap, unrefractedCoords, aspectRatio);
|
|
1719
1729
|
#endif
|
|
1720
|
-
}`,[
|
|
1730
|
+
}`,[sg.textureBicubic,o,e]),s=new k(`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 ) {
|
|
1721
1731
|
vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
|
|
1722
1732
|
vec3 refractedRayExit = position + transmissionRay;
|
|
1723
1733
|
|
|
@@ -1734,7 +1744,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1734
1744
|
|
|
1735
1745
|
// Sample framebuffer to get pixel the refracted ray hits.
|
|
1736
1746
|
return getTransmissionSample( refractionCoords, roughness, ior, transmissionSamplerSize, transmissionSamplerMap, transmissionDepthMap, unrefractedCoords, aspectRatio );
|
|
1737
|
-
}`,[i,t]);return{transmission:new
|
|
1747
|
+
}`,[i,t]);return{transmission:new k(`vec3 transmission(float thickness, float ior, float roughness, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 aspectRatio, vec3 normal, float mask, float alpha, out float calpha) {
|
|
1738
1748
|
vec3 v = vec3(0.);
|
|
1739
1749
|
if (isOrthographic) {
|
|
1740
1750
|
v = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
|
|
@@ -1748,20 +1758,20 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1748
1758
|
accumAlpha += ( 1.0 - accumAlpha ) * alpha;
|
|
1749
1759
|
|
|
1750
1760
|
return transmission;
|
|
1751
|
-
}`,[s])}}();var
|
|
1761
|
+
}`,[s])}}();var pu=(e=>(e.NOISE="noise",e.MAP="map",e))(pu||{}),fu=class extends ae{constructor(e,t,o,i,s,a,c,u,l,d,p){super("v3");this.displacementTypeIndex=new ve(0);this.nodeType="VertexDisplacement";this.intensity=e,this.movementOrTexture=t,Object.values(pu)[this.displacementTypeIndex.value]==="map"&&(this.mat=new _i(this.movementOrTexture.value.matrix)),this.cropOrOffset=o,this.scale=d,this.noiseFunctionIndex=p,this.voronoiStyle=i,this.smoothness=s,this.seed=a,this.highCut=c,this.lowCut=u,this.quality=l}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(pu)[this.displacementTypeIndex.value]){case"map":{o=e.include(fu.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 a=Object.values(Gs)[this.noiseFunctionIndex.value],c=new k(`vec3 orthogonal(vec3 v) {
|
|
1752
1762
|
return normalize(abs(v.x) > abs(v.z) ? vec3(-v.y, v.x, 0.0) : vec3(0.0, -v.z, v.y));
|
|
1753
|
-
}`),u=
|
|
1754
|
-
float v = ${
|
|
1763
|
+
}`),u=a=="voronoi"?`
|
|
1764
|
+
float v = ${a}((p + offset) * scale * 0.001 + neighbour_offset + (movement * 0.1), voronoiStyle, smoothness, seed, quality);
|
|
1755
1765
|
v = remap(v, lowCut, highCut, 0.0, 1.0);
|
|
1756
1766
|
v = smax(v, 0.0, smoothness * 0.25);
|
|
1757
1767
|
v = smin(v, 1.0, smoothness * 0.25);
|
|
1758
1768
|
|
|
1759
1769
|
return p + n * v * intensity;
|
|
1760
1770
|
`:`
|
|
1761
|
-
return p + n * ${
|
|
1762
|
-
`,
|
|
1771
|
+
return p + n * ${a}((p + offset) * scale * 0.001 + neighbour_offset + (movement * 0.1)) * intensity;
|
|
1772
|
+
`,l=new k(`vec3 distorted(vec3 p, vec3 n, float scale, float intensity, vec3 offset, float neighbour_offset, float movement, int voronoiStyle, float smoothness, float seed, float highCut, float lowCut, int quality) {
|
|
1763
1773
|
${u}
|
|
1764
|
-
}`,[
|
|
1774
|
+
}`,[lt.simplex,lt.simplexFractal,lt.simplexAshima,lt.fbm,lt.perlin,lt.voronoi]),d=new k(`vec3 vertexDisplacementNoise(vec3 position, vec3 normal, float scale, vec3 offset, float movement, int voronoiStyle, float smoothness, float seed, float highCut, float lowCut, int quality, float intensity, out vec3 displaced_normal) {
|
|
1765
1775
|
vec3 displaced_position = distorted(position, normal, scale, intensity, offset, neighbor_offset, movement, voronoiStyle, smoothness, seed, highCut, lowCut, quality);
|
|
1766
1776
|
vec3 tangent1 = orthogonal(normal);
|
|
1767
1777
|
vec3 tangent2 = normalize(cross(normal, tangent1));
|
|
@@ -1777,9 +1787,9 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1777
1787
|
vec3 distorted2 = distorted(nearby2, normal, scale, intensity, offset, neighbor_offset, movement, voronoiStyle, smoothness, seed, highCut, lowCut, quality);
|
|
1778
1788
|
displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));
|
|
1779
1789
|
return displaced_position;
|
|
1780
|
-
}`,[
|
|
1790
|
+
}`,[l,c]);o=e.include(d),i.push(this.scale.build(e,"f")),i.push(this.cropOrOffset.build(e,"v3")),i.push(this.movementOrTexture.build(e,"f")),i.push(this.voronoiStyle.build(e,"i")),i.push(this.smoothness.build(e,"f")),i.push(this.seed.build(e,"f")),i.push(this.highCut.build(e,"f")),i.push(this.lowCut.build(e,"f")),i.push(this.quality.build(e,"i"));break}}return i.push(this.intensity.build(e,"f")),i.push("displaced_normal"),e.format(o+"("+i.join(",")+")",this.getType(e),t)}else return console.warn("VertexDisplacementNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},Gi=fu;Gi.Nodes=function(){let e=new k(`vec3 orthogonal(vec3 v) {
|
|
1781
1791
|
return normalize(abs(v.x) > abs(v.z) ? vec3(-v.y, v.x, 0.0) : vec3(0.0, -v.z, v.y));
|
|
1782
|
-
}`),t=new
|
|
1792
|
+
}`),t=new k(`float displacementMapTexture(sampler2D tex, float crop, vec2 uv, mat3 mat, vec2 offset) {
|
|
1783
1793
|
vec2 uvs = (mat * vec3(uv * 2.0 - 1.0, 1.0) / 2.0 + 0.5).xy + offset;
|
|
1784
1794
|
vec4 tmp = texture2D(tex, uvs);
|
|
1785
1795
|
vec3 col = tmp.rgb;
|
|
@@ -1789,7 +1799,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1789
1799
|
}
|
|
1790
1800
|
}
|
|
1791
1801
|
return col.r;
|
|
1792
|
-
}`);return{map:new
|
|
1802
|
+
}`);return{map:new k(`vec3 vertexDisplacementMap(vec3 position, vec3 normal, sampler2D tex, vec2 uv, float crop, mat3 mat, float intensity, out vec3 displaced_normal) {
|
|
1793
1803
|
vec3 displaced_position = position + normal * displacementMapTexture(tex, crop, uv, mat, vec2(0.0)) * intensity;
|
|
1794
1804
|
vec3 tangent1 = normalize(orthogonal(normal));
|
|
1795
1805
|
vec3 tangent2 = normalize(cross(normal, tangent1));
|
|
@@ -1799,7 +1809,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1799
1809
|
vec3 distorted2 = nearby2 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity;
|
|
1800
1810
|
displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));
|
|
1801
1811
|
return displaced_position;
|
|
1802
|
-
}`,[e,t])}}();var ye={normalRenderTarget:new
|
|
1812
|
+
}`,[e,t])}}();var ye={normalRenderTarget:new Pt,normalRenderTargetDepth:new Pt,transmissionRenderTarget:new Pt,aspectRatio:new Ve,transmissionSize:new Ve(2048,2048),transmissionRenderTargetDepth:new Pt,aoRenderTarget:new Pt,aoEnabled:new ke,pixelRatioNode:new Z(1),resolution:new Ve,penumbraSize:new cr(5,.5),frameIndex:new ve(0),transmissionLod:new ve(2)};for(let n of Object.values(ye))n.isRenderGlobal=!0;var en=class extends it{constructor(){super("basic");this.nodeType="Basic";this.color=new Ae(Ke),this.shadingAlpha=new Z(1),this.shadingBlend=new ve(0),this.previousModelViewMatrix=new mt,this.previouseProjectionMatrix=new mt}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({frameIndex:ye.frameIndex}),e.mergeUniform({resolution:ye.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(CO.merge([AO.fog])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>"].join(`
|
|
1803
1813
|
`));let i=["#include <beginnormal_vertex>",`
|
|
1804
1814
|
#if !defined( USE_LAYER_DISPLACE )
|
|
1805
1815
|
#include <defaultnormal_vertex>
|
|
@@ -1817,9 +1827,9 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1817
1827
|
#include <begin_vertex>
|
|
1818
1828
|
#endif /* !USE_LAYER_DISPLACE */
|
|
1819
1829
|
`];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(`
|
|
1820
|
-
`)}else{this.color===void 0&&(this.color=new
|
|
1821
|
-
`));let
|
|
1822
|
-
`)}return t}};import{UniformsLib as
|
|
1830
|
+
`)}else{this.color===void 0&&(this.color=new Ae(Ke)),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(`
|
|
1831
|
+
`));let a=["#include <normal_fragment_begin>",o.code];i&&a.push(i.code,"#ifdef ALPHATEST"," if ( "+i.result+" <= ALPHATEST ) discard;","#endif"),s?a.push(s.code,`vec3 outgoingLight = ${o.result};`,`vec3 finalColor = spe_blend(outgoingLight, ${s.result}, 1.0, SPE_BLENDING_NORMAL);`):a.push(`vec3 finalColor = ${o.result};`);let c="1.0";this.mask&&(this.mask.analyze(e),c=`luminance(${this.mask.flow(e,"v3").result})`),i?a.push(`gl_FragColor = vec4( finalColor, accumAlpha * ${i.result} * ${c} );`):a.push("gl_FragColor = vec4("+o.result+", 1.0 );"),a.push("#include <fog_fragment>","#include <dithering_fragment>"),t=a.join(`
|
|
1832
|
+
`)}return t}};import{UniformsLib as cg,UniformsUtils as NO}from"three";var Vs=class extends it{constructor(){super("lambert");this.nodeType="Lambert";this.color=new Ae(Ke),this.emissive=new Ae(0),this.emissiveIntensity=new Z(1),this.previousModelViewMatrix=new mt,this.previouseProjectionMatrix=new mt,this.shadingAlpha=new Z(1),this.shadingBlend=new ve(0),this.occlusion=new ke(!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({frameIndex:ye.frameIndex}),e.mergeUniform({resolution:ye.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(NO.merge([cg.fog,cg.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(`
|
|
1823
1833
|
`));let i=["#include <beginnormal_vertex>",`
|
|
1824
1834
|
#ifndef USE_LAYER_DISPLACE
|
|
1825
1835
|
#include <defaultnormal_vertex>
|
|
@@ -1842,6 +1852,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1842
1852
|
geometry.position = mvPosition.xyz;
|
|
1843
1853
|
geometry.normal = normalize( transformedNormal );
|
|
1844
1854
|
geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );
|
|
1855
|
+
`),i.push(`
|
|
1845
1856
|
GeometricContext backGeometry;
|
|
1846
1857
|
backGeometry.position = geometry.position;
|
|
1847
1858
|
backGeometry.normal = -geometry.normal;
|
|
@@ -1911,14 +1922,14 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1911
1922
|
#pragma unroll_loop_end
|
|
1912
1923
|
#endif
|
|
1913
1924
|
`," #include <shadowmap_vertex>"," #include <fog_vertex>"),i.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),t=i.join(`
|
|
1914
|
-
`)}else{e.mergeUniform({penumbraSize:ye.penumbraSize}),e.mergeUniform({frameIndex:ye.frameIndex}),e.mergeUniform({aoMap:ye.aoRenderTarget}),e.mergeUniform({aoEnabled:ye.aoEnabled}),this.color===void 0&&(this.color=new
|
|
1925
|
+
`)}else{e.mergeUniform({penumbraSize:ye.penumbraSize}),e.mergeUniform({frameIndex:ye.frameIndex}),e.mergeUniform({aoMap:ye.aoRenderTarget}),e.mergeUniform({aoEnabled:ye.aoEnabled}),this.color===void 0&&(this.color=new Ae(Ke)),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"}),a=this.occlusion.flow(e,"b",{slot:"occlusion"}),c=this.shadingAlpha.flow(e,"f"),u=this.shadingBlend.flow(e,"i"),l=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,d=this.alpha?this.alpha.flow(e,"f"):void 0;e.requires.transparent=d!==void 0,e.addParsCode([`uniform float penumbraSize[${5}];`,"uniform sampler2D aoMap;","uniform bool aoEnabled;","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(`
|
|
1915
1926
|
`));let p=["#include <normal_fragment_begin>",`
|
|
1916
1927
|
// NOTE: gl_FrontFacing alternative using face normal estimation.
|
|
1917
1928
|
vec3 viewdx = dFdx(vViewPosition);
|
|
1918
1929
|
vec3 viewdy = dFdy(vViewPosition);
|
|
1919
1930
|
vec3 faceNormal = normalize(cross(viewdx, viewdy));
|
|
1920
1931
|
bool isFrontFacing = (dot(normal, faceNormal) >= 0.0);
|
|
1921
|
-
`,"#include <clipping_planes_fragment>"];p.push(o.code,"vec3 diffuseColor = "+o.result+";","ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );"),d&&p.push(d.code,"#ifdef ALPHATEST","if ( "+d.result+" <= ALPHATEST ) discard;","#endif"),p.push("#ifdef DOUBLE_SIDED"," reflectedLight.indirectDiffuse += ( isFrontFacing ) ? vIndirectFront : vIndirectBack;","#else"," reflectedLight.indirectDiffuse += vIndirectFront;","#endif","#include <lightmap_fragment>","reflectedLight.indirectDiffuse *= BRDF_Lambert( diffuseColor.rgb );","#ifdef DOUBLE_SIDED"," reflectedLight.directDiffuse = ( isFrontFacing ) ? vLightFront : vLightBack;","#else"," reflectedLight.directDiffuse = vLightFront;","#endif","reflectedLight.directDiffuse *= BRDF_Lambert( diffuseColor.rgb ) * getShadowMask();"),i&&p.push(i.code,"reflectedLight.directDiffuse += "+i.result+" * "+s.result+";"),p.push("vec3 ao = aoEnabled && "+
|
|
1932
|
+
`,"#include <clipping_planes_fragment>"];p.push(o.code,"vec3 diffuseColor = "+o.result+";","ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );"),d&&p.push(d.code,"#ifdef ALPHATEST","if ( "+d.result+" <= ALPHATEST ) discard;","#endif"),p.push("#ifdef DOUBLE_SIDED"," reflectedLight.indirectDiffuse += ( isFrontFacing ) ? vIndirectFront : vIndirectBack;","#else"," reflectedLight.indirectDiffuse += vIndirectFront;","#endif","#include <lightmap_fragment>","reflectedLight.indirectDiffuse *= BRDF_Lambert( diffuseColor.rgb );","#ifdef DOUBLE_SIDED"," reflectedLight.directDiffuse = ( isFrontFacing ) ? vLightFront : vLightBack;","#else"," reflectedLight.directDiffuse = vLightFront;","#endif","reflectedLight.directDiffuse *= BRDF_Lambert( diffuseColor.rgb ) * getShadowMask();"),i&&p.push(i.code,"reflectedLight.directDiffuse += "+i.result+" * "+s.result+";"),p.push("vec3 ao = aoEnabled && "+a.result+" ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);","vec3 outgoingLight = (reflectedLight.directDiffuse + reflectedLight.indirectDiffuse) ;");let f="1.0";this.mask&&(this.mask.analyze(e),f=`luminance(${this.mask.flow(e,"v3").result})`),p.push(`
|
|
1922
1933
|
if (outgoingLight != diffuseColor) {
|
|
1923
1934
|
float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );
|
|
1924
1935
|
accumAlpha += ( 1.0 - accumAlpha ) * ${c.result} * ${f} * lightAccu;
|
|
@@ -1926,16 +1937,43 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1926
1937
|
|
|
1927
1938
|
outgoingLight *= ao;
|
|
1928
1939
|
}
|
|
1929
|
-
`),
|
|
1930
|
-
`)}return t}};import{UniformsLib as
|
|
1940
|
+
`),l&&p.push(l.code,`outgoingLight = spe_blend(outgoingLight, ${l.result}, 1.0, SPE_BLENDING_NORMAL);`),d?p.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${d.result} );`):p.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),p.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),t=p.join(`
|
|
1941
|
+
`)}return t}};import{UniformsLib as dg,UniformsUtils as IO}from"three";var ro=function(){let n=new k(`vec2 dHdxy(sampler2D bumpMap, vec2 bumpMapUv, float bumpScale) {
|
|
1942
|
+
|
|
1943
|
+
vec2 dSTdx = dFdx( bumpMapUv );
|
|
1944
|
+
vec2 dSTdy = dFdy( bumpMapUv );
|
|
1945
|
+
|
|
1946
|
+
float Hll = bumpScale * texture2D( bumpMap, bumpMapUv ).x;
|
|
1947
|
+
float dBx = bumpScale * texture2D( bumpMap, bumpMapUv + dSTdx ).x - Hll;
|
|
1948
|
+
float dBy = bumpScale * texture2D( bumpMap, bumpMapUv + dSTdy ).x - Hll;
|
|
1949
|
+
|
|
1950
|
+
return vec2( dBx, dBy );
|
|
1951
|
+
|
|
1952
|
+
}`),r=new k(`vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
|
|
1953
|
+
|
|
1954
|
+
vec3 vSigmaX = dFdx( surf_pos.xyz );
|
|
1955
|
+
vec3 vSigmaY = dFdy( surf_pos.xyz );
|
|
1956
|
+
vec3 vN = surf_norm; // normalized
|
|
1957
|
+
|
|
1958
|
+
vec3 R1 = cross( vSigmaY, vN );
|
|
1959
|
+
vec3 R2 = cross( vN, vSigmaX );
|
|
1960
|
+
|
|
1961
|
+
float fDet = dot( vSigmaX, R1 ) * faceDirection;
|
|
1962
|
+
|
|
1963
|
+
vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
|
|
1964
|
+
return normalize( abs( fDet ) * surf_norm - vGrad );
|
|
1965
|
+
|
|
1966
|
+
}`);return{dHdxy:n,perturbNormalArb:r}}();var zs=class extends it{constructor(){super("phong");this.nodeType="Phong";this.color=new Ae(Ke),this.specular=new Ae(1118481),this.shininess=new Z(30),this.previousModelViewMatrix=new mt,this.previouseProjectionMatrix=new mt,this.shadingAlpha=new Z(1),this.shadingBlend=new ve(0),this.occlusion=new ke(!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({frameIndex:ye.frameIndex}),e.mergeUniform({resolution:ye.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(IO.merge([dg.fog,dg.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
|
|
1931
1967
|
`));let i=["#include <beginnormal_vertex>",`
|
|
1968
|
+
#include <skinbase_vertex>
|
|
1969
|
+
#include <skinnormal_vertex>
|
|
1932
1970
|
#ifndef USE_LAYER_DISPLACE
|
|
1933
1971
|
#include <defaultnormal_vertex>
|
|
1934
1972
|
#endif
|
|
1935
1973
|
|
|
1936
1974
|
|
|
1937
1975
|
vec3 displaced_position = position;
|
|
1938
|
-
vec3 displaced_normal =
|
|
1976
|
+
vec3 displaced_normal = objectNormal;
|
|
1939
1977
|
|
|
1940
1978
|
#ifdef USE_LAYER_DISPLACE
|
|
1941
1979
|
vec3 transformed;
|
|
@@ -1945,8 +1983,8 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1945
1983
|
#ifndef USE_LAYER_DISPLACE
|
|
1946
1984
|
#include <begin_vertex>
|
|
1947
1985
|
#endif
|
|
1948
|
-
`];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(`
|
|
1949
|
-
`)}else{e.mergeUniform({penumbraSize:ye.penumbraSize}),e.mergeUniform({frameIndex:ye.frameIndex}),e.mergeUniform({aoMap:ye.aoRenderTarget}),e.mergeUniform({aoEnabled:ye.aoEnabled}),this.color===void 0&&(this.color=new
|
|
1986
|
+
`];o&&i.push(o.code,o.result?"displaced_position = "+o.result+";":""),i.push("transformed = displaced_position;","#include <skinning_vertex>","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(`
|
|
1987
|
+
`)}else{e.mergeUniform({penumbraSize:ye.penumbraSize}),e.mergeUniform({frameIndex:ye.frameIndex}),e.mergeUniform({aoMap:ye.aoRenderTarget}),e.mergeUniform({aoEnabled:ye.aoEnabled}),this.color===void 0&&(this.color=new Ae(Ke)),this.color.analyze(e,{slot:"color"}),this.specular.analyze(e),this.shininess.analyze(e);let o=this.occlusion.flow(e,"b",{slot:"occlusion"});this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e);let i=this.color.flow(e,"c",{slot:"color"}),s=this.specular.flow(e,"c"),a=this.shininess.flow(e,"f"),c=this.shadingAlpha.flow(e,"f"),u=this.shadingBlend.flow(e,"i"),l=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,d=this.alpha?this.alpha.flow(e,"f"):void 0;e.requires.transparent=d!==void 0,e.addParsCode(["varying vec3 vWPosition;","uniform vec3 emissive;",`uniform float penumbraSize[${5}];`,"uniform sampler2D aoMap;","uniform bool aoEnabled;","#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(`
|
|
1950
1988
|
`));let p=["#include <normal_fragment_begin>",`
|
|
1951
1989
|
// NOTE: gl_FrontFacing alternative using face normal estimation.
|
|
1952
1990
|
vec3 viewdx = dFdx(vViewPosition);
|
|
@@ -1955,7 +1993,36 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1955
1993
|
if (dot(normal, faceNormal) < 0.0) {
|
|
1956
1994
|
normal *= -1.0;
|
|
1957
1995
|
}
|
|
1958
|
-
`," BlinnPhongMaterial material;"];
|
|
1996
|
+
`," BlinnPhongMaterial material;"];if(this.bumpMap){e.include(ro.dHdxy),e.include(ro.perturbNormalArb);let m=this.bumpMap.texture.flow(e,"t"),h=this.bumpMap.flow(e,"v3"),y=this.bumpMapIntensity?this.bumpMapIntensity.flow(e,"f").result:"1.0",g="";this.bumpMap.projection.value===4?g=`
|
|
1997
|
+
vec3 bumpNormal = vec3(0.0);
|
|
1998
|
+
{
|
|
1999
|
+
vec2 uv0 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs0;
|
|
2000
|
+
vec2 uv1 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs1;
|
|
2001
|
+
vec2 uv2 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs2;
|
|
2002
|
+
vec3 weights = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_triplanarWeights;
|
|
2003
|
+
|
|
2004
|
+
vec2 grad0 = dHdxy(${m.result}, uv0, ${y});
|
|
2005
|
+
vec3 n0 = perturbNormalArb(-vViewPosition, normal, grad0, faceDirection);
|
|
2006
|
+
|
|
2007
|
+
vec2 grad1 = dHdxy(${m.result}, uv1, ${y});
|
|
2008
|
+
vec3 n1 = perturbNormalArb(-vViewPosition, normal, grad1, faceDirection);
|
|
2009
|
+
|
|
2010
|
+
vec2 grad2 = dHdxy(${m.result}, uv2, ${y});
|
|
2011
|
+
vec3 n2 = perturbNormalArb(-vViewPosition, normal, grad2, faceDirection);
|
|
2012
|
+
|
|
2013
|
+
bumpNormal = n0 * weights.z + n1 * weights.x + n2 * weights.y;
|
|
2014
|
+
bumpNormal = normalize(bumpNormal);
|
|
2015
|
+
}
|
|
2016
|
+
|
|
2017
|
+
normal = bumpNormal;
|
|
2018
|
+
`:g=`
|
|
2019
|
+
vec2 bumpMapCachedUv = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs;
|
|
2020
|
+
vec2 grad = dHdxy(${m.result}, bumpMapCachedUv, ${y});
|
|
2021
|
+
normal = perturbNormalArb( - vViewPosition, normal, grad, faceDirection );
|
|
2022
|
+
`,p.push(`// Call the Texture Layer's function once here so that it writes out its procedural UV coordinates
|
|
2023
|
+
${h.result};
|
|
2024
|
+
${g}
|
|
2025
|
+
`)}p.push(i.code," vec3 diffuseColor = "+i.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );"," vec3 totalEmissiveRadiance = emissive;",s.code," vec3 specular = "+s.result+";",a.code," float shininess = max( 0.0001, "+a.result+" );"," float specularStrength = 1.0;"),d&&p.push(d.code,"#ifdef ALPHATEST","if ( "+d.result+" <= ALPHATEST ) discard;","#endif"),p.push("material.diffuseColor = diffuseColor;"),p.push("material.specularColor = specular;","material.specularShininess = shininess;","material.specularStrength = specularStrength;","#include <lights_fragment_begin>","#include <lights_fragment_end>"),p.push("vec3 ao = aoEnabled && "+o.result+" ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);","vec3 outgoingLight = ((reflectedLight.directDiffuse + reflectedLight.indirectDiffuse)) + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;");let f="1.0";this.mask&&(this.mask.analyze(e),f=`luminance(${this.mask.flow(e,"v3").result})`),p.push(`
|
|
1959
2026
|
if (outgoingLight != diffuseColor) {
|
|
1960
2027
|
float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );
|
|
1961
2028
|
accumAlpha += ( 1.0 - accumAlpha ) * ${c.result} * ${f} * lightAccu;
|
|
@@ -1963,8 +2030,8 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1963
2030
|
|
|
1964
2031
|
outgoingLight *= ao;
|
|
1965
2032
|
}
|
|
1966
|
-
`),
|
|
1967
|
-
`)}return t}};import{UniformsLib as
|
|
2033
|
+
`),l&&p.push(l.code,`outgoingLight = spe_blend(outgoingLight, ${l.result}, 1.0, SPE_BLENDING_NORMAL);`),d?p.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${d.result} );`):p.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),p.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),t=p.join(`
|
|
2034
|
+
`)}return t}};import{UniformsLib as mu,UniformsUtils as MO}from"three";var js=class extends it{constructor(){super("standard");this.nodeType="Standard";this.color=new Ae(Ke),this.roughness=new Z(.3),this.metalness=new Z(0),this.reflectivity=new Z(.5),this.previousModelViewMatrix=new mt,this.previouseProjectionMatrix=new mt,this.shadingAlpha=new Z(1),this.shadingBlend=new ve(0),this.occlusion=new ke(!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({frameIndex:ye.frameIndex}),e.mergeUniform({resolution:ye.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(MO.merge([mu.fog,mu.lights])),mu.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(`
|
|
1968
2035
|
`));let i=["#include <beginnormal_vertex>",`
|
|
1969
2036
|
#if !defined( USE_LAYER_DISPLACE )
|
|
1970
2037
|
#include <defaultnormal_vertex>
|
|
@@ -1982,7 +2049,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1982
2049
|
#include <begin_vertex>
|
|
1983
2050
|
#endif /* !USE_LAYER_DISPLACE */
|
|
1984
2051
|
`];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(`
|
|
1985
|
-
`)}else{e.mergeUniform({penumbraSize:ye.penumbraSize}),e.mergeUniform({frameIndex:ye.frameIndex}),e.mergeUniform({aoMap:ye.aoRenderTarget}),e.mergeUniform({aoEnabled:ye.aoEnabled});let o={gamma:!0};this.color===void 0&&(this.color=new
|
|
2052
|
+
`)}else{e.mergeUniform({penumbraSize:ye.penumbraSize}),e.mergeUniform({frameIndex:ye.frameIndex}),e.mergeUniform({aoMap:ye.aoRenderTarget}),e.mergeUniform({aoEnabled:ye.aoEnabled});let o={gamma:!0};this.color===void 0&&(this.color=new Ae(Ke)),this.color.analyze(e,{slot:"color",context:o}),this.roughness.analyze(e),this.metalness.analyze(e);let i=this.occlusion.flow(e,"b",{slot:"occlusion"});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 s=this.color.flow(e,"c",{slot:"color",context:o}),a=this.roughness.flow(e,"f"),c=this.metalness.flow(e,"f"),u=this.shadingAlpha.flow(e,"f"),l=this.shadingBlend.flow(e,"i"),d=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,p=this.alpha?this.alpha.flow(e,"f"):void 0,f=this.reflectivity?this.reflectivity.flow(e,"f"):void 0;e.requires.transparent=p!==void 0,e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;",`uniform float penumbraSize[${5}];`,"uniform sampler2D aoMap;","uniform bool aoEnabled;","#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(`
|
|
1986
2053
|
`));let m=["#include <clipping_planes_fragment>"," #include <normal_fragment_begin>",`
|
|
1987
2054
|
// NOTE: gl_FrontFacing alternative using face normal estimation.
|
|
1988
2055
|
vec3 viewdx = dFdx(vViewPosition);
|
|
@@ -1991,16 +2058,71 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
1991
2058
|
if (dot(normal, faceNormal) < 0.0) {
|
|
1992
2059
|
normal *= -1.0;
|
|
1993
2060
|
}
|
|
1994
|
-
`," PhysicalMaterial material;"," material.diffuseColor = vec3( 1.0 );"];
|
|
2061
|
+
`," PhysicalMaterial material;"," material.diffuseColor = vec3( 1.0 );"];if(this.bumpMap){e.include(ro.dHdxy),e.include(ro.perturbNormalArb);let y=this.bumpMap.texture.flow(e,"t"),g=this.bumpMap.flow(e,"v3"),x=this.bumpMapIntensity?this.bumpMapIntensity.flow(e,"f").result:"1.0",b="";this.bumpMap.projection.value===4?b=`
|
|
2062
|
+
vec3 bumpNormal = vec3(0.0);
|
|
2063
|
+
{
|
|
2064
|
+
vec2 uv0 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs0;
|
|
2065
|
+
vec2 uv1 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs1;
|
|
2066
|
+
vec2 uv2 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs2;
|
|
2067
|
+
vec3 weights = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_triplanarWeights;
|
|
2068
|
+
|
|
2069
|
+
vec2 grad0 = dHdxy(${y.result}, uv0, ${x});
|
|
2070
|
+
vec3 n0 = perturbNormalArb(-vViewPosition, normal, grad0, faceDirection);
|
|
2071
|
+
|
|
2072
|
+
vec2 grad1 = dHdxy(${y.result}, uv1, ${x});
|
|
2073
|
+
vec3 n1 = perturbNormalArb(-vViewPosition, normal, grad1, faceDirection);
|
|
2074
|
+
|
|
2075
|
+
vec2 grad2 = dHdxy(${y.result}, uv2, ${x});
|
|
2076
|
+
vec3 n2 = perturbNormalArb(-vViewPosition, normal, grad2, faceDirection);
|
|
2077
|
+
|
|
2078
|
+
bumpNormal = n0 * weights.z + n1 * weights.x + n2 * weights.y;
|
|
2079
|
+
bumpNormal = normalize(bumpNormal);
|
|
2080
|
+
}
|
|
2081
|
+
|
|
2082
|
+
normal = bumpNormal;
|
|
2083
|
+
`:b=`
|
|
2084
|
+
vec2 bumpMapCachedUv = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs;
|
|
2085
|
+
vec2 grad = dHdxy(${y.result}, bumpMapCachedUv, ${x});
|
|
2086
|
+
normal = perturbNormalArb( - vViewPosition, normal, grad, faceDirection );
|
|
2087
|
+
`,m.push(`// Call the Texture Layer's function once here so that it writes out its procedural UV coordinates
|
|
2088
|
+
${g.result};
|
|
2089
|
+
${b}
|
|
2090
|
+
`)}if(m.push(s.code," vec3 diffuseColor = "+s.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );",c.code," float metalnessFactor = "+c.result+";"),this.roughnessMap){let y=this.roughnessMap.texture.flow(e,"t"),g=this.roughnessMap.flow(e,"v3"),x="";this.roughnessMap.projection.value===4?x=`
|
|
2091
|
+
float roughnessChange = 1.0;
|
|
2092
|
+
{
|
|
2093
|
+
vec2 uv0 = g${this.roughnessMap.uuid.toString().replace(/-/g,"")}_writeUvs0;
|
|
2094
|
+
vec2 uv1 = g${this.roughnessMap.uuid.toString().replace(/-/g,"")}_writeUvs1;
|
|
2095
|
+
vec2 uv2 = g${this.roughnessMap.uuid.toString().replace(/-/g,"")}_writeUvs2;
|
|
2096
|
+
vec3 weights = g${this.roughnessMap.uuid.toString().replace(/-/g,"")}_triplanarWeights;
|
|
2097
|
+
|
|
2098
|
+
float r0 = luminance(texture(${y.result}, uv0).rgb) * roughnessScale;
|
|
2099
|
+
float r1 = luminance(texture(${y.result}, uv1).rgb) * roughnessScale;
|
|
2100
|
+
float r2 = luminance(texture(${y.result}, uv2).rgb) * roughnessScale;
|
|
2101
|
+
|
|
2102
|
+
roughnessChange = (r0 * weights.z + r1 * weights.x + r2 * weights.y);
|
|
2103
|
+
}
|
|
2104
|
+
float roughnessFactor = roughnessChange * ${a.result};
|
|
2105
|
+
`:x=`
|
|
2106
|
+
vec2 roughnessMapCachedUv = g${this.roughnessMap.uuid.toString().replace(/-/g,"")}_writeUvs;
|
|
2107
|
+
|
|
2108
|
+
vec4 vals = texture(${y.result}, roughnessMapCachedUv);
|
|
2109
|
+
float roughnessFactor = luminance(vals.rgb) * ${a.result};
|
|
2110
|
+
`,m.push(`// Call the Texture Layer's function once here so that it writes out its procedural UV coordinates
|
|
2111
|
+
${g.result};
|
|
2112
|
+
|
|
2113
|
+
const float roughnessScale = 1.0;
|
|
2114
|
+
|
|
2115
|
+
${x}
|
|
2116
|
+
`)}else m.push(a.code," float roughnessFactor = "+a.result+";");p&&m.push(p.code,"#ifdef ALPHATEST"," if ( "+p.result+" <= ALPHATEST ) discard;","#endif"),m.push("vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );","float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );"),m.push("material.diffuseColor = diffuseColor * ( 1.0 - metalnessFactor );","material.roughness = max( roughnessFactor, 0.0525 );","material.roughness += geometryRoughness;","material.roughness = min( material.roughness, 1.0 );","material.roughness = clamp( roughnessFactor, 0.04, 1.0 );"),f?m.push(f.code,"material.specularColor = mix( vec3( 0.16 * pow2( "+f.result+" ) ), diffuseColor, metalnessFactor );"):m.push("material.specularColor = mix( vec3( 0.04 ), diffuseColor, metalnessFactor );"),m.push("#include <lights_fragment_begin>"),m.push("#include <lights_fragment_end>"),m.push("vec3 ao = aoEnabled && "+i.result+" ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);","vec3 outgoingLight = ((reflectedLight.directDiffuse + reflectedLight.indirectDiffuse)) + reflectedLight.directSpecular + reflectedLight.indirectSpecular;");let h="1.0";this.mask&&(this.mask.analyze(e),h=`luminance(${this.mask.flow(e,"v3").result})`),m.push(`
|
|
1995
2117
|
if (outgoingLight != diffuseColor) {
|
|
1996
2118
|
float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );
|
|
1997
2119
|
accumAlpha += ( 1.0 - accumAlpha ) * ${u.result} * ${h} * lightAccu;
|
|
1998
|
-
outgoingLight = spe_blend( diffuseColor, outgoingLight, ${u.result} * ${h}, ${
|
|
2120
|
+
outgoingLight = spe_blend( diffuseColor, outgoingLight, ${u.result} * ${h}, ${l.result} );
|
|
1999
2121
|
|
|
2000
2122
|
outgoingLight *= ao;
|
|
2001
2123
|
}
|
|
2002
2124
|
`),d&&m.push(d.code,`outgoingLight = spe_blend(outgoingLight, ${d.result}, 1.0, SPE_BLENDING_NORMAL);`),p?m.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${p.result} );`):m.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),m.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),t=m.join(`
|
|
2003
|
-
`)}return t}};import{UniformsLib as
|
|
2125
|
+
`)}return t}};import{UniformsLib as ug,UniformsUtils as EO}from"three";var Fs=class extends it{constructor(){super("toon");this.nodeType="Toon";this.color=new Ae(Ke),this.specular=new Ae(1118481),this.shininess=new Z(30),this.previousModelViewMatrix=new mt,this.previouseProjectionMatrix=new mt,this.shadingAlpha=new Z(1),this.shadingBlend=new ve(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({frameIndex:ye.frameIndex}),e.mergeUniform({resolution:ye.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(EO.merge([ug.fog,ug.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(`
|
|
2004
2126
|
`));let i=["#include <beginnormal_vertex>",`
|
|
2005
2127
|
#ifndef USE_LAYER_DISPLACE
|
|
2006
2128
|
#include <defaultnormal_vertex>
|
|
@@ -2018,7 +2140,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
2018
2140
|
#include <begin_vertex>
|
|
2019
2141
|
#endif
|
|
2020
2142
|
`];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(`
|
|
2021
|
-
`)}else{e.mergeUniform({penumbraSize:ye.penumbraSize}),e.mergeUniform({frameIndex:ye.frameIndex}),e.mergeUniform({aoMap:ye.aoRenderTarget}),e.mergeUniform({aoEnabled:ye.aoEnabled}),this.color===void 0&&(this.color=new
|
|
2143
|
+
`)}else{e.mergeUniform({penumbraSize:ye.penumbraSize}),e.mergeUniform({frameIndex:ye.frameIndex}),e.mergeUniform({aoMap:ye.aoRenderTarget}),e.mergeUniform({aoEnabled:ye.aoEnabled}),this.color===void 0&&(this.color=new Ae(Ke)),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"),a=this.shadingAlpha.flow(e,"f"),c=this.shadingBlend.flow(e,"i"),u=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,l=this.alpha?this.alpha.flow(e,"f"):void 0;e.requires.transparent=l!==void 0,e.addParsCode([`uniform float penumbraSize[${5}];`,"uniform sampler2D aoMap;","uniform bool aoEnabled;","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>",`
|
|
2022
2144
|
varying vec3 vViewPosition;
|
|
2023
2145
|
struct ToonMaterial {
|
|
2024
2146
|
vec3 diffuseColor;
|
|
@@ -2047,15 +2169,418 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
2047
2169
|
if (dot(normal, faceNormal) < 0.0) {
|
|
2048
2170
|
normal *= -1.0;
|
|
2049
2171
|
}
|
|
2050
|
-
`," ToonMaterial material;"];
|
|
2172
|
+
`," ToonMaterial material;"];if(this.bumpMap){e.include(ro.dHdxy),e.include(ro.perturbNormalArb);let f=this.bumpMap.texture.flow(e,"t"),m=this.bumpMap.flow(e,"v3"),h=this.bumpMapIntensity?this.bumpMapIntensity.flow(e,"f").result:"1.0",y="";this.bumpMap.projection.value===4?y=`
|
|
2173
|
+
vec3 bumpNormal = vec3(0.0);
|
|
2174
|
+
{
|
|
2175
|
+
vec2 uv0 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs0;
|
|
2176
|
+
vec2 uv1 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs1;
|
|
2177
|
+
vec2 uv2 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs2;
|
|
2178
|
+
vec3 weights = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_triplanarWeights;
|
|
2179
|
+
|
|
2180
|
+
vec2 grad0 = dHdxy(${f.result}, uv0, ${h});
|
|
2181
|
+
vec3 n0 = perturbNormalArb(-vViewPosition, normal, grad0, faceDirection);
|
|
2182
|
+
|
|
2183
|
+
vec2 grad1 = dHdxy(${f.result}, uv1, ${h});
|
|
2184
|
+
vec3 n1 = perturbNormalArb(-vViewPosition, normal, grad1, faceDirection);
|
|
2185
|
+
|
|
2186
|
+
vec2 grad2 = dHdxy(${f.result}, uv2, ${h});
|
|
2187
|
+
vec3 n2 = perturbNormalArb(-vViewPosition, normal, grad2, faceDirection);
|
|
2188
|
+
|
|
2189
|
+
bumpNormal = n0 * weights.z + n1 * weights.x + n2 * weights.y;
|
|
2190
|
+
bumpNormal = normalize(bumpNormal);
|
|
2191
|
+
}
|
|
2192
|
+
|
|
2193
|
+
normal = bumpNormal;
|
|
2194
|
+
`:y=`
|
|
2195
|
+
vec2 bumpMapCachedUv = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs;
|
|
2196
|
+
vec2 grad = dHdxy(${f.result}, bumpMapCachedUv, ${h});
|
|
2197
|
+
normal = perturbNormalArb( - vViewPosition, normal, grad, faceDirection );
|
|
2198
|
+
`,d.push(`// Call the Texture Layer's function once here so that it writes out its procedural UV coordinates
|
|
2199
|
+
${m.result};
|
|
2200
|
+
${y}
|
|
2201
|
+
`)}d.push(o.code," vec3 diffuseColor = "+o.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );",i.code," vec3 specular = "+i.result+";",s.code," float shininess = max( 0.0001, "+s.result+" );"," float specularStrength = 1.0;"),l&&d.push(l.code,"#ifdef ALPHATEST","if ( "+l.result+" <= ALPHATEST ) discard;","#endif"),d.push("material.diffuseColor = diffuseColor;"),d.push("material.specularColor = specular;","material.specularShininess = shininess;","material.specularStrength = specularStrength;","#include <lights_fragment_begin>","#include <lights_fragment_end>"),d.push("vec3 ao = aoEnabled ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);","vec3 outgoingLight = ((reflectedLight.directDiffuse + reflectedLight.indirectDiffuse) * ao) + reflectedLight.directSpecular;");let p="1.0";this.mask&&(this.mask.analyze(e),p=`luminance(${this.mask.flow(e,"v3").result})`),d.push(`
|
|
2051
2202
|
if (outgoingLight != diffuseColor) {
|
|
2052
2203
|
float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );
|
|
2053
|
-
accumAlpha += ( 1.0 - accumAlpha ) * ${
|
|
2054
|
-
outgoingLight = spe_blend( diffuseColor, outgoingLight, ${
|
|
2204
|
+
accumAlpha += ( 1.0 - accumAlpha ) * ${a.result} * ${p} * lightAccu;
|
|
2205
|
+
outgoingLight = spe_blend( diffuseColor, outgoingLight, ${a.result} * ${p}, ${c.result} );
|
|
2055
2206
|
}
|
|
2056
|
-
`),u&&d.push(u.code,`outgoingLight = spe_blend(outgoingLight, ${u.result}, 1.0, SPE_BLENDING_NORMAL);`),
|
|
2057
|
-
`)}return t}};import{VideoTexture as eO,Texture as tO}from"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 $d=class extends Nl{create(r){return URL.createObjectURL(new Blob([r]))}dispose(r,e){URL.revokeObjectURL(e)}},Wd;function Fy(n){return typeof n=="string"?n:(Wd||(Wd=new $d),Wd.load(n))}var Cl=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")}},Il=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 Ti=class extends Cl{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=Fy(e),this.img.onload=t}getTexture(e){let t=this[e];if(t)return t;{let o;return this.isVideo?o=new eO(this.img,void 0,e,e):o=new tO(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 Ht=class extends Ti{};import{Vector2 as Kr,Vector3 as Cr,Vector4 as Ml}from"three";function st(n,r){return r.color(n)}function ky(n,r){switch(n.type){case"fresnel":return nO(n,r);case"gradient":return iO(n);case"depth":return sO(n);case"normal":return aO(n);case"noise":return lO(n,r);case"rainbow":return cO(n);case"toon":return dO(n,r);case"outline":return uO(n,r);case"transmission":return pO(n,r);case"color":return oO(n,r);case"pattern":return fO(n,r)}}function rO(n){return{type:n.type}}function dr(n){let{alpha:r,mode:e,isMask:t}=n;return{...rO(n),alpha:r,mode:e,isMask:t}}function oO(n,r){return{...dr(n),color:st(n.color,r)}}function nO(n,r){let{bias:e,scale:t,intensity:o,factor:i,color:s,isMask:l}=n;return{...dr(n),color:st(s,r),bias:e,scale:t,intensity:o,factor:i}}function iO(n){let{gradientType:r,smooth:e,colors:t,steps:o,angle:i,offset:s,morph:l}=n;return{...dr(n),gradientType:r,smooth:e,colors:t.map(c=>new Ml(c[0],c[1],c[2],c[3])),num:t.length,steps:o,offset:new Kr(...s),morph:new Kr(...l),angle:i}}function sO(n){let{gradientType:r,near:e,far:t,isVector:o,isWorldSpace:i,origin:s,direction:l,colors:c,steps:u,smooth:a}=n;return{...dr(n),gradientType:r,near:e,far:t,isVector:o,isWorldSpace:i,origin:new Cr(...s),direction:l?new Cr(...l):new Cr(1,0,0),colors:c.map(d=>d!==void 0?new Ml(d[0],d[1],d[2],d[3]):new Ml(0,0,0,0)),steps:u.slice(0,c.length),smooth:a}}function aO(n){let{cnormal:r}=n;return{...dr(n),cnormal:new Cr(r[0],r[1],r[2])}}function lO(n,r){return{...dr(n),scale:n.scale,move:n.move,fA:new Kr(...n.fA),fB:new Kr(...n.fB),size:new Cr(...n.size),distortion:new Kr(...n.distortion),colorA:st(n.colorA,r),colorB:st(n.colorB,r),colorC:st(n.colorC,r),colorD:st(n.colorD,r),noiseType:n.noiseType,voronoiStyle:n.voronoiStyle,highCut:n.highCut,lowCut:n.lowCut,smoothness:n.smoothness,seed:n.seed,quality:n.quality}}function cO(n){return{...dr(n),filmThickness:n.filmThickness,movement:n.movement,wavelengths:new Cr(...n.wavelengths),noiseStrength:n.noiseStrength,noiseScale:n.noiseScale,offset:new Cr(...n.offset)}}function dO(n,r){return{...dr(n),positioning:n.positioning,colors:n.colors.map(e=>new Ml(e[0],e[1],e[2],e[3])),num:n.colors.length,steps:n.steps,source:new Cr(...n.source),isWorldSpace:n.isWorldSpace,noiseStrength:n.noiseStrength,noiseScale:n.noiseScale,shadowColor:st(n.shadowColor,r),offset:new Cr(...n.offset)}}function uO(n,r){return{...dr(n),outlineColor:st(n.outlineColor,r),contourColor:st(n.contourColor,r),outlineWidth:n.outlineWidth,contourWidth:n.contourWidth,outlineThreshold:n.outlineThreshold,contourThreshold:n.contourThreshold,outlineSmoothing:n.outlineSmoothing,contourFrequency:n.contourFrequency,contourDirection:new Cr(...n.contourDirection),positionalLines:n.positionalLines,compensation:n.compensation}}function pO(n,r){return{...dr(n),thickness:n.thickness,ior:n.ior,roughness:n.roughness}}function fO(n,r){return{...dr(n),style:n.style,projection:n.projection,axis:n.axis,blending:n.blending,offset:new Kr(...n.offset),colorA:st(n.colorA,r),colorB:st(n.colorB,r),frequency:new Kr(...n.frequency),size:n.size,variation:n.variation,smoothness:n.smoothness,zigzag:n.zigzag,rotation:n.rotation,vertical:new Kr(...n.vertical),horizontal:new Kr(...n.horizontal),sides:n.sides}}var xo=class extends Ke{};import{Vector4 as mO}from"three";var Yd={noise:["noiseType"],texture:["projection","axis","side"],video:["projection","axis","side"],displace:["noiseType"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"]},Xd={depth:["colors"]};function hO(n,r,e){if(r==="isMask")return!0;let t=Yd[n.type],o=Xd[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 Kd(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 Ht||c.image.deref(),c.image=l}if("video"in i){let s=i.video,l=r.video(s),c=t;c.image instanceof Ht||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 Uy(n,r,e,t){let o=!1;for(let[i,s]of Object.entries(n)){if(!i||s===void 0)continue;if(Zd(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 go))switch(o=o||hO(e,i,s),l.constructor){case Oe:if(typeof s=="string"){let c=r.getColor(s);c&&(l.value=c);break}else{let c=s;l.value instanceof xo?l.value=new Ke(c.r,c.g,c.b,c.a):l.setRGBA(c);break}case Nt:if(typeof s=="string"){let c=r.getColor(s);c&&(l.value=c);break}else{let c=s;l.value instanceof xo?l.value=new Ke(c.r,c.g,c.b,c.a):l.value.setRGBA(c.r,c.g,c.b,c.a);break}case je:{let c=s;l.value.setX(c[0]),l.value.setY(c[1]);break}case ut:{let c=s;l.value.setX(c[0]),l.value.setY(c[1]),l.value.setZ(c[2]);break}case bt:{Kd(s,r,e);break}case cr:{l.value=s.map(c=>new mO(...c));break}default:{l.value=s;break}}}return o}var Mr=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)Zd(i,this,t)}get type(){return this.data.type}static create(r,e,t,o){if(t.type==="light")return Wt.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 Ro(i,t.texture.wrapping),l=new Ol(i),c=new Al(t.texture.repeat,t.texture.offset),u=new Z(t.crop?1:0),a=new ve(t.projection??0),d=new ve(["x","y","z"].indexOf(t.axis)??0),p=new ve(t.side??0),f=new je(t.size?new ur(t.size[0],t.size[1]):new ur(100,100)),m=new Z(t.blending??0),h=new Z(t.alpha??1),y=new ve(t.mode??0),g=new Fe(t.isMask??!1),v=new fi(s,l,u,a,d,p,f,m,c,h,y,g),b=new _e(v.calpha,"f");return new De(r,e,t,{texture:s,textureSize:l,crop:u,projection:a,axis:d,side:p,size:f,blending:m,mat:c,alpha:h,mode:y,isMask:g},v,y,b,g)}else if(t.type==="matcap"){let i=o.image(t.texture.image),s=new Ro(i,t.texture.wrapping),l=new Z(t.alpha??1),c=new ve(t.mode??0),u=new Fe(t.isMask??!1),a=new gi(s,l,c,u),d=new _e(a.calpha,"f");return new De(r,e,t,{texture:s,alpha:l,mode:c,isMask:u},a,c,d,u)}else if(t.type==="displace")if(t.displacementType==="noise"){let i=new ut(new Ir(...t.offset)),s=new Z(t.scale??10),l=new Z(t.intensity??8),c=new Z(t.movement??1),u=new ve(t.noiseType??0),a=new ve(t.voronoiStyle??0),d=new Z(t.smoothness??.5),p=new Z(t.seed??0),f=new Z(t.highCut??1),m=new Z(t.lowCut??0),h=new ve(t.quality??1),y=new Pi(l,c,i,a,d,p,f,m,h,s,u);return new Ms(r,e,t,{offset:i,scale:s,intensity:l,movement:c,noiseType:u,voronoiStyle:a,smoothness:d,seed:p,highCut:f,lowCut:m,quality:h},y)}else throw new Error;else return xO(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||"visible"in o.props?(t.scene?.markNeedsUpdateRendererDirty(),!0):Uy(o.props,t.shared,this,e)}else if(o.path[0]==="texture")return"texture"in e||"video"in e?Kd(o.props,t.shared,this):!0;return!1}dispose(){if(yO(this)){let r=this.uniforms[`f${this.id}_texture`];if(!r)return!1;let e=r;e.image instanceof Ht||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}},De=class extends Mr{constructor(e,t,o,i,s,l,c,u){super(e,t,o,i);this.params=i;this.color=s;this.mode=l;this.alpha=c;this.isMask=u}},Ms=class extends Mr{constructor(e,t,o,i,s){super(e,t,o,i);this.position=s}},Wt=class extends Mr{constructor(e,t,o,i,s){super(e,t,o,s);this.node=i}static createLigherLayer(e,t,o,i){let s,l=new Z(o.alpha),c=new ve(o.mode),u;if(!o.visible)s=new zo,u={};else if(o.category==="lambert"){s=new As;let a=new Oe(i.color(o.emissive)??0),d=new Fe(o.occlusion??!0);u={emissive:a,occlusion:d},s.emissive=a,s.occlusion=d}else if(o.category==="toon"){s=new Is;let a=new Z(o.shininess??30),d=new Oe(i.color(o.specular)??1118481);u={shininess:a,specular:d},s.shininess=a,s.specular=d}else if(o.category==="physical"){s=new Cs;let a=new Z(o.roughness??.3),d=new Z(o.metalness??0),p=new Z(o.reflectivity??.5),f=new Fe(o.occlusion??!0);u={roughness:a,metalness:d,reflectivity:p,occlusion:f},s.roughness=a,s.metalness=d,s.reflectivity=p,s.occlusion=f}else{s=new Ns;let a=new Z(o.shininess??30),d=new Oe(o.specular!==void 0?i.color(o.specular)??1118481:1118481),p=new Fe(o.occlusion??!0);u={shininess:a,specular:d,occlusion:p},s.shininess=a,s.specular=d,s.occlusion=p}return s.alpha=new Z(1),s.shadingAlpha=l,s.shadingBlend=c,u.alpha=s.shadingAlpha,u.mode=s.shadingBlend,new Wt(e,t,o,s,u)}get category(){return this.node.category}};function yO(n){let r=n instanceof Mr?n.type:n;return r==="texture"||r==="video"||r==="displace_map"||r==="matcap"}function qt(n){return{alpha:new Z(n.alpha??1),mode:new ve(n.mode??0),isMask:new Fe(n.isMask??!1)}}function gO(n,r,e,t){switch(n.type){case"color":{let o=new Oe(t.color??5526619),i=qt(t),s=new Vo(o,i.alpha),l=new _e(s.calpha,"f");return new De(r,e,n,{color:o,...i},s,i.mode,l,i.isMask)}case"fresnel":{let o=new Oe(t.color??16777215),i=new Z(t.bias??.1),s=new Z(t.scale??1),l=new Z(t.intensity??2),c=new Z(t.factor??1),u=qt(t),a=new Ts(o,i,s,l,c,u.alpha,u.mode,u.isMask),d=new _e(a.calpha,"f");return new De(r,e,n,{color:o,bias:i,scale:s,intensity:l,factor:c,...u},a,u.mode,d,u.isMask)}case"rainbow":{let o=new Z(t.filmThickness??30),i=new Z(t.movement??0),s=new ut(t.wavelengths??new Ir(0,0,0)),l=new Z(t.noiseStrength??0),c=new Z(t.noiseScale??1),u=new ut(t.offset??new Ir(0,0,0)),a=qt(t),d=new Si(o,i,s,l,c,u,a.alpha,a.isMask),p=new _e(d.calpha,"f");return new De(r,e,n,{filmThickness:o,movement:i,wavelengths:s,noiseStrength:l,noiseScale:c,offset:u,...a},d,a.mode,p,a.isMask)}case"transmission":{let o=new Z(t.thickness??10),i=new Z(t.ior??1.5),s=new Z(t.roughness??.5),l=ye.transmissionSize,c=ye.transmissionRenderTarget,u=ye.transmissionRenderTargetDepth,a=window.innerWidth,d=window.innerHeight,p=a>=d?new je(d/a,1):new je(1,a/d),f=qt(t),m=new _i(o,i,s,l,c,u,p,f.alpha),h=new _e(m.calpha,"f");return new De(r,e,n,{thickness:o,ior:i,roughness:s,aspectRatio:p,...f},m,f.mode,h,f.isMask)}case"toon":{let o=new ve(t.positioning??0),i;t.colors?i=new cr(t.colors.length,t.colors):(i=new cr(10,new Oi(0,0,0,1)),i.value[1]=new Oi(1,1,1,1));let s;t.steps?s=new lr(t.steps.length,t.steps):(s=new lr(10,1),s.value[0]=0);let l=new ut(t.source??new Ir(0,0,0)),c=new Fe(t.isWorldSpace??!0),u=new Z(t.noiseStrength??0),a=new Z(t.noiseScale??1),d=new Nt(t.shadowColor),p=new ut(t.offset??new Ir(0,0,0)),f=qt(t),m=new wi(o,i,s,l,c,u,a,d,p,f.alpha),h=new _e(m.calpha,"f");return new De(r,e,n,{positioning:o,colors:i,steps:s,source:l,isWorldSpace:c,noiseStrength:u,noiseScale:a,shadowColor:d,offset:p,...f},m,f.mode,h,f.isMask)}case"outline":{let o=new Oe(t.outlineColor??16777215),i=new Oe(t.contourColor??16777215),s=new Z(t.outlineWidth??.1),l=new Z(t.contourWidth??.1),c=new Z(t.outlineThreshold??.1),u=new Z(t.contourThreshold??.1),a=new Z(t.outlineSmoothing??.1),d=new Z(t.contourFrequency??.1),p=new ut(t.contourDirection??new Ir(0,1,0)),f=new Fe(t.positionalLines??!1),m=new Fe(t.compensation??!0),h=ye.normalRenderTarget,y=ye.normalRenderTargetDepth,g=ye.pixelRatioNode,v=ye.resolution,b=qt(t),w=new vi(o,i,s,l,c,u,a,d,p,f,m,v,h,y,g,b.alpha),S=new _e(w.calpha,"f");return new De(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,...b},w,b.mode,S,b.isMask)}case"depth":{let o=new ve(t.gradientType??0),i=new Fe(t.smooth??!1),s=new Z(t.near??50),l=new Z(t.far??200),c=new Z(t.isVector??1),u=new Z(t.isWorldSpace??0),a=new ut(t.origin??new Ir),d=new ut(t.direction??new Ir),p;t.colors?p=new cr(t.colors.length,t.colors):(p=new cr(2,new Oi(0,0,0,1)),p.value[1]=new Oi(1,1,1,1));let f;t.steps?f=new lr(t.steps.length,t.steps):(f=new lr(2,1),f.value[0]=0);let m=qt(t),h=new hi(o,i,s,l,c,u,a,d,p,f,m.alpha,m.isMask),y=new _e(h.calpha,"f");return new De(r,e,n,{gradientType:o,smooth:i,near:s,far:l,isVector:c,isWorldSpace:u,origin:a,direction:d,colors:p,steps:f,...m},h,m.mode,y,m.isMask)}case"noise":{let o=new Z(t.scale??1),i=new ut(t.size??new Ir(100,100,100)),s=new Z(t.move??1),l=new je(t.fA??new ur(1.7,9.2)),c=new je(t.fB??new ur(8.3,2.8)),u=new je(t.distortion??new ur(1,1)),a=new Nt(t.colorA),d=new Nt(t.colorB),p=new Nt(t.colorC),f=new Nt(t.colorD),m=new ve(t.noiseType??0),h=new ve(t.voronoiStyle??0),y=new Z(t.highCut??1),g=new Z(t.lowCut??0),v=new Z(t.smoothness??.5),b=new Z(t.seed??.5),w=new ve(t.quality??1),S=qt(t),P=new xi(o,i,s,l,c,u,a,d,p,f,S.alpha,m,S.isMask,h,y,g,v,b,w),_=new _e(P.calpha,"f");return new De(r,e,n,{scale:o,size:i,move:s,fA:l,fB:c,distortion:u,colorA:a,colorB:d,colorC:p,colorD:f,noiseType:m,...S,voronoiStyle:h,highCut:y,lowCut:g,smoothness:v,seed:b,quality:w},P,S.mode,_,S.isMask)}case"normal":{let o=new ut(t.cnormal??new Ir(1,1,1)),i=qt(t),s=new ui(o,i.alpha),l=new _e(s.calpha,"f");return new De(r,e,n,{cnormal:o,...i},s,i.mode,l,i.isMask)}case"gradient":{let o=new ve(t.gradientType??0),i=new Fe(t.smooth??!1),s;t.colors?s=new cr(t.colors.length,t.colors):(s=new cr(10,new Oi(0,0,0,1)),s.value[1]=new Oi(1,1,1,1));let l;t.steps?l=new lr(t.steps.length,t.steps):(l=new lr(10,1),l.value[0]=0);let c=new je(t.offset??new ur(0,0)),u=new je(t.morph??new ur(0,0)),a=new Z(t.angle??0),d=qt(t),p=new yi(o,i,s,l,c,u,a,d.alpha,d.isMask),f=new _e(p.calpha,"f");return new De(r,e,n,{gradientType:o,smooth:i,colors:s,steps:l,offset:c,morph:u,angle:a,...d},p,d.mode,f,d.isMask)}case"pattern":{let o=new ve(t.style??0),i=new ve(t.projection??0),s=new ve(["x","y","z"].indexOf(t.axis)??0),l=new Z(t.blending??0),c=new je(t.offset??new ur(0,0)),u=new Nt(t.colorA),a=new Nt(t.colorB),d=new je(t.frequency??new ur(10,10)),p=new Z(t.size??.5),f=new Z(t.variation??0),m=new Z(t.smoothness??.5),h=new Z(t.zigzag??0),y=new Z(t.rotation??0),g=new je(t.vertical??new ur(0,1)),v=new je(t.horizontal??new ur(0,1)),b=new ve(t.sides??6),w=qt(t),S=new bi(o,i,s,l,c,u,a,d,p,f,m,h,y,g,v,b,w.alpha,w.isMask),P=new _e(S.calpha,"f");return new De(r,e,n,{style:o,projection:i,axis:s,blending:l,offset:c,colorA:u,colorB:a,frequency:d,size:p,variation:f,smoothness:m,zigzag:h,rotation:y,vertical:g,horizontal:v,sides:b,...w},S,w.mode,P,w.isMask)}default:{let o=new Oe(1,0,0,1),i=qt(t),s=new Vo(o,i.alpha),l=new _e(s.calpha,"f");return new De(r,e,n,{color:o,...i},s,i.mode,l,i.isMask)}}}function xO(n,r,e,t){let o=ky(e,t);return gO(e,n,r,o)}function Zd(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 Hy(n,r){let e=0;for(let t of n.layers){if(t.data.type!=="displace"&&t.data.isMask)return!0;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"&&t.data.type!=="pattern"){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 It=class extends vO{constructor(){super(void 0);this.flatShading=!1;this.needsJitter=!0;this.cacheKey="";this.fog=!0,this.dithering=!0,this.vertexColors=!0,this.transparent=!0}customProgramCacheKey(){return this.cacheKey}},El=class extends It{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}get hasAO(){return this.root.hasAO}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()}},jo=class extends It{constructor(e,t){super();this.data=e;this.layerIdGen=0;this.flavors=[];this.masks={};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 El(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}get hasAO(){return this.lightLayer.getNode("occlusion")?.value??!1}reset(e,t){this.data!==e&&this.reset0(e,t)}reset0(e,t){this.data=e;let o=e.layers??Ot.defaultTwoLayerData("phong").layers;this.layers=o.map(i=>Mr.create(this.layerIdGen++,i.id,i.data,t.shared)),this.layers.reverse(),this.name=e.name??"Untitled Material",this.onUpdate(),this.transparent=Hy(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 Wt),this.lightLayer===void 0&&(this.lightLayer=new Wt(0,"",{...xt.defaultData("light","phong"),visible:!1},new zo,{})),this.dispose();for(let e of this.flavors)e&&e.dispose();this.applyMasks(),this.blendColors(),this.blendAfterColors(),this.blendPositions()}updateByOp(e,t,o){if(t!==void 0?this.data=t:t=this.data,this.transparent=Hy(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=Mr.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{e.type===0&&e.props.occlusion!==void 0&&o.scene?.markNeedsUpdateRendererDirty();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=Mr.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)}applyMasks(){for(let e=0;e<this.layers.length;++e){let t=this.layers[e];t instanceof De?t.color.mask=void 0:t instanceof Wt&&(t.node.mask=void 0)}for(let e=0;e<this.layers.length;++e){let t=this.layers[e];if(t instanceof De&&t.isMask.value&&t.data.visible&&e>0){let o=e-1,i=this.layers[o];i instanceof Wt?i.node.mask=new ot(t.color,t.alpha,ot.MUL):i instanceof De&&(i.isMask.value||(i.color.mask=new ot(t.color,t.alpha,ot.MUL)))}}}blendColors(){let e=this.layers.findIndex(o=>o instanceof De),t=this.layers.findIndex(o=>o instanceof Wt);if(e!==-1&&e<t){let o=this.layers[e].color;for(let i=e+1;i<t;++i){let s=this.layers[i];if(s instanceof De){if(s.isMask.value)continue;o=new di(o,s.color,s.alpha,s.mode)}}this.fragment.color=o}else this.fragment.color=void 0}blendAfterColors(){let e=new _e("outgoingLight","f"),t=this.layers.findIndex(o=>o instanceof Wt);if(this.layers.length>t+1){for(let o=t+1;o<this.layers.length;++o){let i=this.layers[o];if(i instanceof De){if(i.isMask.value)continue;e=new di(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 Ms);if(e.length>0){let t=e[0].position;for(let o=1;o<e.length;++o)e[o]&&(t=new ot(t,e[o].position,ot.ADD),t=new ot(t,new Z(.5).setReadonly(!0),ot.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=(Yd[t.type]??[]).map(u=>t[u]),i=(Xd[t.type]??[]).map(u=>t[u]?.length??0),s=[...o,...i],l="isMask"in t&&t.isMask,c=`"${t.type}-${t.visible}-${l}"`;s.length?e+=`[${c}, "${s.join('","')}"],`:e+=c}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 Tl;e.needsJitter=this.needsJitter,this.lights=this.lightLayer.data.visible,e.build(this.fragment,this.fragment),this.vertexShader=e.getCode("vertex"),this.fragmentShader=e.getCode("fragment"),this.defines=e.defines,this.uniforms=e.uniforms,this.extensions=e.extensions,this.updaters=e.updaters;for(let 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 De){let t=e.params.texture;if(t instanceof Ro&&!t.image.loaded)return!1}return!0}getHash(){let e="{";return e+='"fragment":'+this.fragment.getHash(),e+="}",e}};Object.defineProperties(It.prototype,{properties:{get:function(){return this.fragment.properties}}});var Fo=class extends jo{};var Yy=$s(qy());var Wy=new Map;function $y(n){if(typeof n=="string")return n;let r=Wy.get(n);return r||(r={url:URL.createObjectURL(new Blob([n]))},Wy.set(n,r)),r.url}var ko=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:$y(r),format:"wav"},this.sound=new Yy.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()}};import{Box2 as bO,Vector2 as Uo,Path as Xy,Shape as SO,ShapeUtils as wO,Color as _O}from"three";var Bl=class{constructor(){this.type="ShapePath";this.color=new _O;this.subPaths=[];this.currentPath=null}moveTo(r,e){return this.currentPath=new Xy,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 b=h.x,w=y.x,S=g.x,P=v.x,_=h.y,x=y.y,C=g.y,T=v.y,N=(P-S)*(_-C)-(T-C)*(b-S),O=(w-b)*(_-C)-(x-_)*(b-S),A=(T-C)*(w-b)-(P-S)*(x-_),G=N/A,k=O/A;if(A===0&&N!==0||G<=0||G>=1||k<0||k>1)return null;if(N===0&&A===0){for(let $=0;$<2;$++)if(i($===0?g:v,h,y),t.loc===e.ORIGIN){let ee=$===0?g:v;return{x:ee.x,y:ee.y,t:t.t}}else if(t.loc===e.BETWEEN){let ee=+(b+t.t*(w-b)).toPrecision(10),Y=+(_+t.t*(x-_)).toPrecision(10);return{x:ee,y:Y,t:t.t}}return null}else{for(let Y=0;Y<2;Y++)if(i(Y===0?g:v,h,y),t.loc===e.ORIGIN){let W=Y===0?g:v;return{x:W.x,y:W.y,t:t.t}}let $=+(b+G*(w-b)).toPrecision(10),ee=+(_+G*(x-_)).toPrecision(10);return{x:$,y:ee,t:G}}}function i(h,y,g){let v=g.x-y.x,b=g.y-y.y,w=h.x-y.x,S=h.y-y.y,P=v*S-w*b;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(P<-Number.EPSILON){t.loc=e.LEFT;return}if(P>Number.EPSILON){t.loc=e.RIGHT;return}if(v*w<0||b*S<0){t.loc=e.BEHIND;return}if(Math.sqrt(v*v+b*b)<Math.sqrt(w*w+S*S)){t.loc=e.BEYOND;return}let _;v!==0?_=w/v:_=S/b,t.loc=e.BETWEEN,t.t=_}function s(h,y){let g=[],v=[];for(let b=1;b<h.length;b++){let w=h[b-1],S=h[b];for(let P=1;P<y.length;P++){let _=y[P-1],x=y[P],C=o(w,S,_,x);C!==null&&g.find(T=>T.t<=C.t+Number.EPSILON&&T.t>=C.t-Number.EPSILON)===void 0&&(g.push(C),v.push(new Uo(C.x,C.y)))}}return v}function l(h,y,g){let v=new Uo;y.getCenter(v);let b=[];return g.forEach(w=>{w.boundingBox.containsPoint(v)&&s(h,w.points).forEach(P=>{b.push({identifier:w.identifier,isCW:w.isCW,point:P})})}),b.sort((w,S)=>w.point.x-S.point.x),b}function c(h,y,g,v,b){(b==null||b==="")&&(b="nonzero");let w=new Uo;h.boundingBox.getCenter(w);let S=[new Uo(g,w.y),new Uo(v,w.y)],P=l(S,h.boundingBox,y);P.sort((O,A)=>O.point.x-A.point.x);let _=[],x=[];P.forEach(O=>{O.identifier===h.identifier?_.push(O):x.push(O)});let C=_[0].point.x,T=[],N=0;for(;N<x.length&&x[N].point.x<C;)T.length>0&&T[T.length-1]===x[N].identifier?T.pop():T.push(x[N].identifier),N++;if(T.push(h.identifier),b==="evenodd"){let O=T.length%2===0,A=T[T.length-2];return{identifier:h.identifier,isHole:O,for:A}}else if(b==="nonzero"){let O=!0,A=null,G=null;for(let k=0;k<T.length;k++){let $=T[k];y[$]&&(O?(G=y[$].isCW,O=!1,A=$):G!==y[$].isCW&&(G=y[$].isCW,O=!0))}return{identifier:h.identifier,isHole:O,for:A}}else console.warn('fill-rule: "'+b+'" is currently not implemented.')}let u=0,a=999999999,d=-999999999,p=[];this.subPaths.forEach(h=>{let y=h.getPoints(),g=-999999999,v=999999999,b=-999999999,w=999999999;for(let S=0;S<y.length;S++){let P=y[S];P.y>g&&(g=P.y),P.y<v&&(v=P.y),P.x>b&&(b=P.x),P.x<w&&(w=P.x)}d<=b&&(d=b+1),a>=w&&(a=w-1),y.length&&p.push({curves:h.curves,points:y,isCW:wO.isClockWise(y),identifier:u++,boundingBox:new bO(new Uo(w,v),new Uo(b,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 SO;g.curves=h.curves,f.filter(b=>b?.isHole&&b.for===h.identifier).forEach(b=>{if(b){let w=p[b.identifier],S=new Xy;S.curves=w.curves,g.holes.push(S)}}),m.push(g)}}),m}};var Ky,Qd=new Promise(n=>{Ky=n});var Zy=Sn(async()=>{let n=await import("./opentype.js");Ky(n)});var Es=class{async load(r,e,t=()=>{}){let{load:o}=await Qd;o(r,(i,s)=>{i||!s?t(i??"Something went wrong"):e(s)})}async parse(r){let{parse:e,Bidi:t}=await Qd;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 PO(n){return await(await fetch(n)).arrayBuffer()}var TO=new Es;async function Jd(n){let r,e,t=!1;if(n.url?(r=await PO(n.url),e=n.url,t=n.url.startsWith("/")):n.data&&(r=n.data.buffer),r){let o=await TO.parse(r);if(o)return{font:o.font,url:e,intercepted:t,arr:r,bidi:o.bidi}}}import{CubicBezierCurve as OO,LineCurve as AO,QuadraticBezierCurve as NO}from"three";function CO(n,r){return r.state.glyphIndex===n||r.state.fina===n||r.state.medi===n||r.state.init===n}var Dl=class{constructor(r){this._arrayBuffer=new ArrayBuffer(1);this._isLoaded=!1;this._intercepted=!1;this._isUserFont=r.isUserFont??!1,this._loadingPromise=Jd(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=Jd(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(CO(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(`
|
|
2058
|
-
`,e),u=e.horizontalAlign===1?c:0,
|
|
2059
|
-
`:
|
|
2060
|
-
`)A=u;else if(
|
|
2061
|
-
`)>=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 Bl,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=IO(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 IO(n){if(n.length){let r=n[0];if(r instanceof AO)return r.v1;if(r instanceof OO||r instanceof NO)return r.v0}}var eu=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 eu{constructor(e){super();this.flatShading=e}disposeObject(e){e.dispose()}createObject(e,t){let o=Bo(e,t,this.flatShading);return o.computeBoundingSphere(),o}};var Qy={find(n){},markNeedsUpdateRendererDirty:function(){},markGeometryCacheDirty:function(){},addPendingExpandCloner:function(n){},addPendingUpdateCloner(n){},addPendingCommand(n){}};var tu=class extends Il{constructor(e){super();this.shared=e}create(e){return new Ti(e,this.shared)}},Ho=class{constructor(r,e={}){this.geometryCache=new Ls(!0);this.geometryCache2=new Ls(!1);this.imageHolderCache=new tu(this);this.thisContext={scene:Qy,shared:this};this.deletedMaterial=new Fo(Ot.defaultTwoLayerData("phong"),this.thisContext);this.deletedImage=new Ht(Rn.emptyImage,this);this.deletedVideo=new Ht(In.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 Fo(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]?(this.materials[r].reset(e.data,this.thisContext),e.dispose()):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 jo(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 Ht(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 Ht(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 xo(e.r,e.g,e.b,e.a):this.colors[r]=new xo(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 Ke(0,0,0,0))}else return"a"in r?new Ke(r.r,r.g,r.b,r.a):new Ke(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 ko)return e;{let t=new ko({src:e});return this.audios[r]=t,t}}deleteAudio(r){let e=this.audios[r];e&&(e instanceof ko&&e.dispose(),delete this.audios[r])}addFont(r,e){this.fonts[r]=new Dl(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 ko&&e.dispose()}),this.audios={},this.geometryCache.dispose(),this.geometryCache2.dispose()}},Jy=new Ho($a.emptyData());var $t=class extends dt{updateByPatchedOp(e,t,o){if(super.updateByPatchedOp(e,t,o),rm(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(Zt(e.path,["material"])&&this.material instanceof It)"material"in t&&typeof t.material!="string"&&this.material.updateByOp(lt.drop(e,1),t.material,o);else if(Zt(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(lt.drop(e,2),s,o)}}}get needsAO(){return this.material!==void 0?(Array.isArray(this.material)?this.material[0]:this.material).hasAO:!1}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&&Ys(this.material).forEach(e=>{e instanceof It&&(e instanceof Fo||e.nodeMaterialDispose())})}dispose(){this.disposeMaterial(),super.dispose()}};import{BufferGeometry as MO}from"three";var ft=class extends $t{constructor(e,t,o){super(e,t);this.data=t;this.localGeometry=void 0}chooseGeoemtryCache(e){return e.geometryCache}markGeometryAsReachable(e){this.geometryCreateDeleyed instanceof MO&&this.chooseGeoemtryCache(e).markAsReachable(this.dataPatched.geometry,this.geometryCreateDeleyed)}get geometry(){if(this.localGeometry!==void 0)return this.localGeometry;if(this.geometryCreateDeleyed instanceof Ho){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 Qi.is2DParametricMesh(e.type)&&e.depth===0}get is2DType(){return Qi.is2DParametricMesh(this.geometry.userData.type)}get isNonParametric(){return this.geometry.userData.type==="NonParametricGeometry"}updateByPatchedOp(e,t,o){super.updateByPatchedOp(e,t,o),Zt(e.path,["geometry"])&&this.updateByPatchedOpGeometry(lt.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=Bo(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&&vs(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=Bo(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&&Hi(["scaleBaked"],Object.keys(e.props))&&this.geometryCreateDeleyed instanceof He&&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):this.isNonParametric?(e.setScalar(0),this.geometry.boundingSphere&&e.copy(this.geometry.boundingSphere.center),t.set(o.width,o.height,o.depth??0).multiplyScalar(.5)):e.setScalar(0),t.set(o.width,o.height,o.depth??0).multiplyScalar(.5)}};function LO(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 ou(o[s],o[s+1],o[s+2]);r.has(l)?r.get(l)?.normals.push(c):r.set(l,{normals:[c],result:new ou})}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 eg(i,3))}function BO(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 ou;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 eg(t,3))}function Ai(n){if(Array.isArray(n.material)){for(let r of n.material)if(r.getLayersOfType("outline").length===0)return}else if(!(n.material instanceof It)||n.material.getLayersOfType("outline").length===0)return;n instanceof ft&&n.is2DAndNoDepth?BO(n):LO(n)}function Ni(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=[ru.seededRandom(o),ru.seededRandom(o+1e4),ru.seededRandom(o+2e4)];for(let s=0;s<e.length;s++)t[s]=i[s%3];n.geometry.setAttribute("randomColor",new EO(t,3))}var VO;ti.then(n=>{VO=n});var Er=new DO,Bs=new RO;function rg(n){let r=!1;return n.scene.objects.traverse((e,t)=>{t.type==="Mesh"&&t.geometry.type==="SubdivGeometry"&&(r=!0)}),r}var qo=class extends ft{constructor(e,t,o){super(e,t,o);this.data=t;this.hiddenMatrixOld=new GO;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}=He.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,Ai(this),Ni(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){He.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1,this.originalGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0),this.subdividedGeometry&&He.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1,this.subdividedGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0)}updateTopology(){this.originalGeometry.dispose(),this.originalGeometry=He.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=He.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,dt.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 tg,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,o=e.boundingSphere.center;Er.setFromBufferAttribute(t),Er.getCenter(o),e.boundingSphere.radius=o.distanceTo(Er.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Er.getSize(Bs),this.hasNonUniformScale&&Bs.divide(this.scale);let i={width:Bs.x,height:Bs.y,depth:Bs.z};return this.geometry.userData.parameters=i,i}updateBoundingSphere(e){let t=this.originalGeometry;Er.min.set(e[0],e[2],e[4]),Er.max.set(e[1],e[3],e[5]),this.hasNonUniformScale&&(Er.min.applyMatrix4(this.shearScaleInv),Er.max.applyMatrix4(this.shearScaleInv)),t.boundingSphere===null&&(t.boundingSphere=new tg);let o=t.boundingSphere.center;Er.getCenter(o),t.boundingSphere.radius=o.distanceTo(Er.max)}freeSubdivPointer(){this.subdivPointer&&(He.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)}};import{Triangle as zO,Vector3 as $o}from"three";var og=-1,jO=1,ng={x:[1,0,0],"-x":[-1,0,0],y:[0,1,0],"-y":[0,-1,0],z:[0,0,1],"-z":[0,0,-1]},ig={polygon_center:0,edge:1,vertex:2},Ds=(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-og)*(e-t)/(jO-og)+t};function sg(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 FO=new $o,Gl=new $o,kO=new $o,UO=new $o;function Ci(n,r){let e=kO.fromArray(n),t=UO.fromArray(r);Gl.copy(t).sub(e);let o=Gl.length();return Gl.normalize().multiplyScalar(o*.5),FO.copy(e).add(Gl).toArray()}var Yt=new zO,Rl=new $o,Vl=new $o,Wo=new $o;function ag(n){let r=[];for(let e=0;e<=n.index.count;e++)if(Rl.fromArray(n.index.array,e*3),Yt.setFromAttributeAndIndices(n.attributes.position,Rl.x,Rl.y,Rl.z),Yt.getNormal(Vl),Yt.getMidpoint(Wo),!(isNaN(Wo.x)||isNaN(Wo.y)||isNaN(Wo.z))){let{a:t,b:o,c:i}=Yt,s=t.toArray(),l=o.toArray(),c=i.toArray(),u=t.distanceTo(o),a=o.distanceTo(i),d=i.distanceTo(t),p=Ci(s,l),f=Ci(l,c),m=Ci(c,s),h=[u,a,d],y=Math.max(...h),g=h.filter(w=>Math.round(w)===Math.round(y)).length>1,v=[],b=Yt.getMidpoint(Wo).toArray();y===u&&!g&&(v=[f,m,m],b=p),y===a&&!g&&(v=[p,m,m],b=f),y===d&&!g&&(v=[p,f,f],b=m),g&&(v=[p,f,m]),r.push({vertices:[s,l,c],faceCenters:v,midpoint:b,norm:Yt.getNormal(Vl).toArray()})}return r}function lg(n){let r=[],{position:e}=n.attributes;for(let t=0;t<e.count;t++){Yt.setFromAttributeAndIndices(e,t*3,t*3+1,t*3+2),Yt.getNormal(Vl),Yt.getMidpoint(Wo);let o=Yt.a.toArray(),i=Yt.b.toArray(),s=Yt.c.toArray();r.push({vertices:[o,i,s],faceCenters:[Ci(o,i),Ci(i,s),Ci(s,o)],midpoint:Wo.toArray(),norm:Vl.toArray()})}return r}var HO=4,qO=.5,nu=n=>.5*(1-Math.cos(n*Math.PI)),iu=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<HO;g++){let v=o+(i<<4)+(s<<8);a=nu(l),d=nu(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+=nu(u)*(h-m),p+=m*f,f*=qO,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()}},cg=iu;import{Vector3 as WO,Matrix4 as $O,Ray as YO}from"three";var dg=new WO,ug=new $O,pg=new YO;function fg(n){let r=!1;return n.scene.objects.traverse((e,t)=>{t.type==="Mesh"&&t.geometry.type==="TextGeometry"&&(r=!0)}),r}var Ii=class extends ft{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)&&(ug.copy(o).invert(),pg.copy(e.ray).applyMatrix4(ug),pg.intersectBox(this.singleBBox,dg))){let i=dg.applyMatrix4(o),s=e.ray.origin.distanceTo(i);t.push({distance:s,point:i.clone(),object:this})}}};var St=1e-4,Lr,gg,xg,vg,hg=new jt,yg=new jt;ti.then(n=>{Lr=n,gg=[Lr.get_face_center,Lr.get_edge_midpoint,Lr.get_vertex_position],xg=[Lr.get_face_normal,Lr.get_edge_normal,Lr.get_vertex_normal],vg=[Lr.face_count,Lr.edge_count,Lr.vertex_count]});var KO=new Xo,ZO=new Xo,vo=new jt,Yo=new jt,Gs=new jt,au=new jt,QO=new jt,JO=new jt;var Zr=new cg,Ei=class extends jn(XO){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 Wr&&t.expand()}invalidateTransform(e){this.matrixWorldNeedsUpdate=!0,this.traverse(t=>{t instanceof Wr&&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"?Math.round(this.parameters.grid.count[0])*Math.round(this.parameters.grid.count[1])*Math.round(this.parameters.grid.count[2]):this.parameters.count,this.parameters.type==="toObject"&&!this.parameters.toObject.object&&(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 Wr(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 Wr(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*mg.DEG2RAD,i=t.end*mg.DEG2RAD,s=o-i,l=new su(t.rotation[0],t.rotation[1],t.rotation[2]),c;switch(t.axis){case"z":c=new jt(0,0,1);break;case"y":c=new jt(0,1,0);break;default:case"x":c=new jt(1,0,0);break}let u=e.randomnessObject??Sr.defaultData([1,1,1]).randomnessObject,a=u.noiseType==="perlin";Zr.noiseSeed(u.seed);let d=Ka((0,Mi.default)(u.seed)),p=Ds(u.strength,this.parameters.randomness);for(let[f,m]of this.children.entries()){let h=f*(u.freqScale/10)+u.movement,y=a?Zr.noise(h):d(h,h),g=f+1;m.scale.x=t.scale[0]+p(g,me(y,u.scale[0]))||St,m.scale.y=t.scale[1]+p(g,me(y,u.scale[1]))||St,m.scale.z=t.scale[2]+p(g,me(y,u.scale[2]))||St,m.position.setScalar(0);let v=s/e.count*f-o;switch(t.axis){case"x":m.rotation.set(0,v,0);break;case"y":m.rotation.set(0,0,v);break;case"z":m.rotation.set(v,0,0);break}m.translateOnAxis(c,t.radius),m.position.x+=t.position[0]+p(g,me(y,u.position[0])),m.position.y+=t.position[1]+p(g,me(y,u.position[1])),m.position.z+=t.position[2]+p(g,me(y,u.position[2]));let b=p(g,me(y,u.rotation[0])),w=p(g,me(y,u.rotation[1])),S=p(g,me(y,u.rotation[2]));t.alignment===!0?(m.rotation.x+=l.x+b,m.rotation.y+=l.y+w,m.rotation.z+=l.z+S):m.rotation.set(l.x+b,l.y+w,l.z+S)}}_updateLinear(e){if(e.type!=="linear")throw new Error;let t=e.linear,o=new su(t.rotation[0],t.rotation[1],t.rotation[2]),i=e.randomnessObject??Sr.defaultData([1,1,1]).randomnessObject,s=i.noiseType==="perlin";Zr.noiseSeed(i.seed);let l=Ka((0,Mi.default)(i.seed)),c=Ds(i.strength,this.parameters.randomness);for(let[u,a]of this.children.entries()){let d=u*(i.freqScale/10)+i.movement,p=s?Zr.noise(d):l(d,d),f=u+1,m=c(f,me(p,i.rotation[0])),h=c(f,me(p,i.rotation[1])),y=c(f,me(p,i.rotation[2]));a.scale.x=1+(t.scale[0]-1)*u+c(f,me(p,i.scale[0]))||St,a.scale.y=1+(t.scale[1]-1)*u+c(f,me(p,i.scale[1]))||St,a.scale.z=1+(t.scale[2]-1)*u+c(f,me(p,i.scale[2]))||St,a.rotation.x=o.x*u+m,a.rotation.y=o.y*u+h,a.rotation.z=o.z*u+y,a.position.x=t.position[0]*u+c(f,me(p,i.position[0])),a.position.y=t.position[1]*u+c(f,me(p,i.position[1])),a.position.z=t.position[2]*u+c(f,me(p,i.position[2]))}}_updateGrid(e){let t=0,o=e.grid,i=e.randomnessObject??Sr.defaultData([1,1,1]).randomnessObject,s=Ds(i.strength,this.parameters.randomness),l=i.noiseType==="perlin";Zr.noiseSeed(i.seed);let c=Jm((0,Mi.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 jt(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?Zr.noise(...m):c(...m),y=this.children[t++];y.scale.x=1+s(t,me(h,i.scale[0]))||St,y.scale.y=1+s(t,me(h,i.scale[1]))||St,y.scale.z=1+s(t,me(h,i.scale[2]))||St;let g=s(t,me(h,i.rotation[0])),v=s(t,me(h,i.rotation[1])),b=s(t,me(h,i.rotation[2]));y.rotation.set(g,v,b),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?Zr.noise(...p):c(...p),m=this.children[t++];m.scale.x=1+s(t,me(f,i.scale[0]))||St,m.scale.y=1+s(t,me(f,i.scale[1]))||St,m.scale.z=1+s(t,me(f,i.scale[2]))||St;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 su(t.rotation[0],t.rotation[1],t.rotation[2]),i=e.randomnessObject??Sr.defaultData([1,1,1]).randomnessObject,s=i.noiseType==="perlin";Zr.noiseSeed(i.seed);let l=Ka((0,Mi.default)(i.seed)),c=Ds(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 Ii)if(!this.objectForSample.font?.isLoaded||this.objectForSample.geometry.attributes.position===void 0){this._pendingMediaLoad=!0;return}else this._pendingMediaLoad=!1;if(this.objectForSample.geometry===void 0&&this.objectForSample.isAncestorOf(this.object.uuid)){console.warn(`Oh no! The object "${this.object.name}" (${this.object.uuid}) seem to be a child/descendant of the object it's being cloned to. Please re-parent it so that they are siblings instead.`);return}let u=this.getSubdivData(),a=[],d=g=>{let v=g.length,b=g.map(P=>P[0]).reduce((P,_)=>P+_,0),w=g.map(P=>P[1]).reduce((P,_)=>P+_,0),S=g.map(P=>P[2]).reduce((P,_)=>P+_,0);return[b/v,w/v,S/v]},p=g=>Math.round(g*1e6)/1e6;u.forEach(g=>{let v=u.filter(b=>p(g.pos[0])===p(b.pos[0])&&p(g.pos[1])===p(b.pos[1])&&p(g.pos[2])===p(b.pos[2]));v.length>1?a.push({pos:g.pos,norm:d(v.map(b=>b.norm))}):a.push(g)});let f=sg(a);if(u.length>0){let g=Math.round(f.length*t.count/100);this._updateCount(g)}this.objectForSample.updateMatrixWorld();let m=new Za(this.objectForSample).build(),h=ng[t.axis],y=this.children;m.setRandomGenerator((0,Mi.default)(this.object.uuid+t.seed));for(let[g,v]of y.entries()){let b=g*(i.freqScale/10)+i.movement,w=s?Zr.noise(b):l(b,b),S=g+1,P=c(S,me(w,i.rotation[0])),_=c(S,me(w,i.rotation[1])),x=c(S,me(w,i.rotation[2]));t.spreadType==="random"?m.sample(Gs,au):(f.length&&(Gs.fromArray(f[g].pos),au.fromArray(f[g].norm)),this.objectForSample instanceof qo&&Gs.applyMatrix4(KO.copy(this.objectForSample.matrixWorld).invert())),Gs.applyMatrix4(this.object.hiddenMatrix.clone().invert()),v.position.copy(Gs),vo.fromArray(h);let C=t.align==="normal"?au:this.object.getWorldDirection(JO),T=Yo.fromArray(t.position);Yo.x+=Yo.x+c(S,me(w,i.position[0])),Yo.y+=Yo.y+c(S,me(w,i.position[1])),Yo.z+=Yo.z+c(S,me(w,i.position[2]));let N=Math.acos(C.dot(vo)),O=QO.crossVectors(vo,C).normalize(),A=ZO.makeRotationAxis(O,N),G=C.clone().cross(this.object.up).normalize(),k=G.clone().cross(C).normalize(),$=new Xo().makeBasis(G,C,k),ee=new jt(vo.y,vo.z,vo.x).normalize(),Y=ee.clone().cross(vo).normalize(),W=new Xo().makeBasis(ee,vo,Y).invert(),H=new Xo().multiplyMatrices($,W);v.rotation.setFromRotationMatrix(H),T.applyMatrix4(A),v.position.add(T),v.rotation.x=v.rotation.x+o.x+P,v.rotation.y=v.rotation.y+o.y+_,v.rotation.z=v.rotation.z+o.z+x,v.scale.setScalar(1),v.scale.x=v.scale.x+t.scale[0]+c(S,me(w,i.scale[0]))||St,v.scale.y=v.scale.y+t.scale[1]+c(S,me(w,i.scale[1]))||St,v.scale.z=v.scale.z+t.scale[2]+c(S,me(w,i.scale[2]))||St,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 qo){let t=this.objectForSample,o=ig[e],i=vg[o],s=gg[o],l=xg[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);hg.fromArray(d).applyMatrix4(t.matrixWorld),yg.fromArray(p),c.push({pos:hg.toArray(),norm:yg.toArray()})}return c}else return(this.objectForSample.geometry.index?ag(this.objectForSample.geometry):lg(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=Ur(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 dt?this.objectForSample=o:this.objectForSample=void 0,this.matrix=new Xo,this.hiddenMatrix=new Xo,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1,o&&o.add(this)}this.update()}get pendingMediaLoad(){return this._pendingMediaLoad}};import{HemisphereLight as UA,Scene as HA,Vector3 as qA,Fog as WA,Box3 as $A,MeshBasicMaterial as YA}from"three";import{Camera as uA,OrthographicCamera as _g,PerspectiveCamera as pA,Vector3 as fr,Object3D as Pg,Quaternion as fA,Matrix4 as mA}from"three";import{Camera as iA,LineSegments as sA,BufferGeometry as aA,LineBasicMaterial as lA,Color as cu,Vector3 as cA,Float32BufferAttribute as Sg}from"three";import{BoxGeometry as eA}from"three";var Br=n=>{var r;return r=class extends n{},r.geometryHelper=new eA(30,30,30),r};import{Ray as tA,Sphere as rA,Matrix4 as oA,Vector3 as Qr}from"three";var zl=new tA,lu=new rA,bg=new oA,Dr=(n,r,e,t,o=!1)=>{let i=r,s=n.matrixWorld;if(i.boundingSphere===null&&i.computeBoundingSphere(),lu.copy(i.boundingSphere),lu.applyMatrix4(s),e.ray.intersectsSphere(lu)===!1||(bg.copy(s).invert(),zl.copy(e.ray).applyMatrix4(bg),i.boundingBox!==null&&zl.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,zl,p,c,u,a),l){l.faceIndex=Math.floor(m/3),t.push(l);return}}else{let v=i.attributes.position,b=new Qr,w=new Qr,S=new Qr,P=new Qr,_=2,C=1/((n.scale.x+n.scale.y+n.scale.z)/3),T=C*C,N=Math.max(0,f.start),O=Math.min(v.count,f.start+f.count);for(let A=N,G=O-1;A<G;A+=_){if(b.fromBufferAttribute(v,A),w.fromBufferAttribute(v,A+1),zl.distanceSqToSegment(b,w,P,S)>T)continue;P.applyMatrix4(n.matrixWorld);let $=e.ray.origin.distanceTo(P);$<e.near||$>e.far||t.push({distance:$,point:S.clone().applyMatrix4(n.matrixWorld),object:n})}}function y(g,v,b,w,S,P,_){let x=new Qr,C=new Qr,T=new Qr,N=new Qr,O=new Qr;if(x.fromBufferAttribute(w,S),C.fromBufferAttribute(w,P),T.fromBufferAttribute(w,_),b.intersectTriangle(x,C,T,!1,N)===null)return null;O.copy(N),O.applyMatrix4(g.matrixWorld);let G=v.ray.origin.distanceTo(O);return G<v.near||G>v.far?null:{faceIndex:1,distance:G,point:O.clone(),object:g}}};var jl=new cA,Xt=new iA,du=class extends sA{constructor(e){let t=new aA,o=new lA({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],s=[],l={},c=new cu(15711266),u=new cu(15711266),a=new cu(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 Sg(i,3)),t.setAttribute("color",new Sg(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;Xt.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;pr("n1",t,e,Xt,-i,-s,l),pr("n2",t,e,Xt,i,-s,l),pr("n3",t,e,Xt,-i,s,l),pr("n4",t,e,Xt,i,s,l);let c=l;pr("f1",t,e,Xt,-i,-s,c),pr("f2",t,e,Xt,i,-s,c),pr("f3",t,e,Xt,-i,s,c),pr("f4",t,e,Xt,i,s,c);let u=c,a=.5;pr("u1",t,e,Xt,i*.7*a,s*1.1,u),pr("u2",t,e,Xt,-i*.7*a,s*1.1,u),pr("u3",t,e,Xt,0,s*(1.1+.9*a),u),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function pr(n,r,e,t,o,i,s){jl.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],jl.x,jl.y,jl.z)}}var Fl=class extends Br(du){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){Dr(this.object,this.geometry,e,t,!0)}};import{Box3Helper as wg,BoxGeometry as dA}from"three";var kl;(r=>r.is=e=>"objectHelper"in e)(kl||(kl={}));var bo=(n,r)=>class extends tl(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 wg&&(i.visible=!0)}}updateEntityBoxSize(o,i){this.objectHelper.visible&&this.geometryHelper instanceof dA?(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 wg&&(i.visible=!1)}}};var uu=790,Li=new fr,pu=new fr,fu=new fA,mu=new fr,Rs=new fr,hu=new fr,Gr=class extends bo(uA,Fl){constructor(e="",t={...Bn.defaultData,name:""}){super();this._cameraType="OrthographicCamera";this.targetOffset=Co.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.wasMovedByUser=!1;this.wasMovedBySwitchCameraAction=!1;this.super_Entity(e,t),this.previousProjectionMatrix=new mA,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??uu,l=o/i,c=o>i?l:1,u=o>i?1:l;this.orthoCamera=new _g(-s*.5*c,s*.5*c,s*.5*(1/u),-s*.5*(1/u),-5e4,1e4)}else this.orthoCamera=new _g(o*-.5,o*.5,i*.5,i*-.5,-5e4,1e4);this.perspCamera=new pA(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 fr(e,t,o)),super.lookAt(e),this.getWorldPosition(Li),this.targetOffset=Li.distanceTo(e)}getTarget(e=new fr){return this.getWorldDirection(pu),this.getWorldPosition(Li),pu.multiplyScalar(this.targetOffset),e.copy(Li).add(pu),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(Li),Li.distanceTo(e)}updateUp(){this.getWorldQuaternion(fu),mu.set(0,0,1).applyQuaternion(fu),Rs.copy(Pg.DEFAULT_UP),this.isUpVectorFlipped&&Rs.negate(),Rs.applyQuaternion(fu),hu.copy(Pg.DEFAULT_UP).projectOnPlane(mu),this.angleOffsetFromUp=hu.angleTo(Rs),this.angleOffsetFromUp*=hu.cross(Rs).dot(mu)>=0?1:-1}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 fr),i=e.getWorldDirection(new fr).multiplyScalar(this.targetOffset);return{position:t.clone().add(i),target:t}}getViewToObject(e){let t=e.getWorldPosition(new fr),i=this.getWorldDirection(new fr).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??uu,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())}copyHistory(){this.previousProjectionMatrix&&this.previousProjectionMatrix.copy(this.projectionMatrix)}updateProjectionMatrix(){this._cameraType==="PerspectiveCamera"?this.toPerspective():this._cameraType==="OrthographicCamera"&&this.toOrthographic()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(e,t){return super.copy(e,t),this.parent=e.parent,this.orthoCamera.copy(e.orthoCamera),this.perspCamera.copy(e.perspCamera),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.far=e.far,this.view=e.view===null?null:Object.assign({},e.view),this._cameraType=e._cameraType,this.aspect=e.aspect,this.fov=e.fov,this.focus=e.focus,this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this.targetOffset=e.targetOffset,this.updateProjectionMatrix(),this}toCameraState(e=[]){let t={type:this.cameraType,far:this.far,orthographic:{near:this.orthoCamera.near,zoom:this.orthoCamera.zoom,autoZoom:!0,autoZoomFrustumSize:uu},perspective:{near:this.perspCamera.near,fov:this.perspCamera.fov,zoom:this.perspCamera.zoom},up:this.up.toArray(),targetOffset:this.targetOffset,isUpVectorFlipped:this.isUpVectorFlipped};return vn(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}}};import{BufferGeometry as Tg,Matrix4 as Og,Float32BufferAttribute as hA}from"three";var Bi=new Og,yA=new Og;var Kt=class extends $t{constructor(e,t,o){super(e,t);this.data=t;this.meshSetAddresses=[];this.needsTransformForDownstream=!1;this.geometry=new Tg;this.onAfterRender=(e,t,o,i,s,l)=>{super.onAfterRender(e,t,o,i,s,l),this.recomputeBoolean()};this.geometry.userData.parameters={width:0,height:0,depth:0}}get booleanOp(){return this.data.geometry.operation}get phongAngle(){return this.data.geometry.phongAngle??45}get isLOD(){return this.recomputeBoolean(),!1}updateByPatchedOp(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 Kt&&s.recomputeBoolean(e===!0,t)}this.meshSetAddresses=[];for(let i=0;i<this.children.length;i++){let s=this.children[i];if(s instanceof dt&&s.dataPatched.visible===!0&&s.geometry.attributes.position?.count>0&&s.geometry.drawRange.count>0){if(Bi.multiplyMatrices(s.hiddenMatrix,s.matrix),s.booleanMeshSetAddress===-1){if((s.geometry.index??s.geometry.getAttribute("position")).count/3<15e5&&(s.booleanMeshSetAddress=sr.getMeshSet(s.geometry,e===!0,t)),s.booleanMeshSetAddress===-1)return;sr.transformMeshSet(s.booleanMeshSetAddress,Bi),s.booleanMatrixInvOld.copy(Bi).invert(),s.booleanWasTransformed=!1}else s instanceof Kt&&s.needsTransformForDownstream===!0?(sr.transformMeshSet(s.booleanMeshSetAddress,Bi),s.needsTransformForDownstream=!1):s.booleanWasTransformed===!0&&(sr.transformMeshSet(s.booleanMeshSetAddress,yA.multiplyMatrices(Bi,s.booleanMatrixInvOld)),s.booleanMatrixInvOld.copy(Bi).invert(),s.booleanWasTransformed=!1);this.meshSetAddresses.push(s.booleanMeshSetAddress)}}if(this.meshSetAddresses.length===0){this.geometry.setAttribute("position",new hA([],0)),this.geometry.setDrawRange(0,0);return}if(e===!0)return sr.calcBooleanTopological(this.meshSetAddresses,this.booleanOp);let o=this.geometry;o.dispose(),this.geometry=new Tg,this.geometry.userData=o.userData,this.geometry.boundingSphere=o.boundingSphere;try{this.booleanMeshSetAddress=sr.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,Ai(this),Ni(this)}dispose(){super.dispose(),this.geometry.dispose()}};import{Light as gA}from"three";var Ag;(r=>{function n(e){return Ie.is(e)&&e instanceof gA}r.is=n})(Ag||(Ag={}));var Di=(n,r)=>class extends bo(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 Gi=n=>n instanceof dt,Vs=n=>n!==null&&n instanceof Kt,Ng=n=>n instanceof Gr;var yu=n=>kl.is(n);import{Group as vA}from"three";import{AxesHelper as xA}from"three";var So=class extends Br(xA){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){Dr(this.object,So.geometryHelper,e,t)}update(){}};var zs=class extends bo(vA,So){constructor(r,e){super(),this.super_Entity(r,e),this.objectHelper.update()}updateState(r,e){this.updateState_Entity(r,e)}};import{DirectionalLight as PA,CameraHelper as Cg}from"three";import{DirectionalLightHelper as bA}from"three";var Ri=class extends Br(bA){constructor(e,t=15,o=10066329){super(e,t,o);this.object=e;this.added=!1;this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,t){Dr(this.object,Ri.geometryHelper,e,t)}};import{PointLightHelper as SA}from"three";var Vi=class extends Br(SA){constructor(e,t=15,o=6710886){super(e,t,o);this.object=e;this.name=`PointLightHelper: ${e.uuid}`}raycast(e,t){Dr(this.object,Vi.geometryHelper,e,t)}};import{SpotLightHelper as wA,Vector3 as _A}from"three";var Ul=class extends Br(wA){constructor(e,t=6710886){super(e,t);this.object=e;this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,t){Dr(this.object,Ul.geometryHelper,e,t)}update(){if(this.object!==void 0){let e=Ul._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)}}},js=Ul;js._vector=new _A;function TA(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 Hl=class extends Di(PA,Ri){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 Cg(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 Cg&&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&&TA(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()}};import{PointLight as OA,Vector3 as ql,Box3 as AA,Box3Helper as Ig,Color as NA}from"three";var Wl=class extends Di(OA,Vi){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 ql(-i.far+this.position.x,-i.far+this.position.y,-i.far+this.position.z),l=new ql(i.far+this.position.x,i.far+this.position.y,i.far+this.position.z),c=new AA(s,l),u=new Ig(c,new NA(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 Ig){let t=this.shadow.camera,o=new ql(-t.far+this.position.x,-t.far+this.position.y,-t.far+this.position.z),i=new ql(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))}};import{SpotLight as CA,CameraHelper as Mg,MathUtils as IA,Vector3 as Dg,Quaternion as MA}from"three";var Eg=new Dg,Lg=new Dg,Bg=new MA,$l=class extends Di(CA,js){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=IA.RAD2DEG*2*this.angle,i.aspect=1,i.near=100,i.far=2500;let s=new Mg(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 Mg&&e.update()}}updateMatrixWorld(r){super.updateMatrixWorld(r),Lg.setFromMatrixPosition(this.matrixWorld),Bg.setFromRotationMatrix(this.matrixWorld),Eg.copy(this.up).applyQuaternion(Bg).negate().multiplyScalar(this.distance),this.target.position.copy(Lg).add(Eg),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 Yl=class extends ft{get forceComputeSize(){return!0}get shape(){return this.geometry.userData.shape}updateEntityBoxSize(r,e){let t=this.geometry.getAttribute("position");t!==void 0?ws(t,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:t.count,r,e):super.updateEntityBoxSize(r,e)}};var zi=class extends ft{constructor(e,t,o){super(e,t,o);this._shapeId=null;this._context=o}updateState(e,t){super.updateState(e,t),this.updateShape()}updateShape(){let e=this.data.geometry.extrusion.shape,t;if(e.type==="Custom"){let i=e.shapeId;if(i!==this._shapeId&&this.detachShape(),i){this._shapeId=i;let s=this._context.scene.find(i);s?.data&&(s.attachedPaths.add(this),t=s.geometry.userData?.shape),t||this._context.scene.addPendingCommand(()=>this.updateShape())}}else{let i;switch(e.type){case"Rectangle":i=xl;break;case"Ellipse":i=Kn;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()))}detachShape(){this._shapeId!==null&&this._context.scene.find(this._shapeId)?.attachedPaths.delete(this)}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.updateShape(),this.refreshAttachedPaths(e)}updateTransformState(e){return super.updateTransformState(e)}updateGeometryInteractions(e,t){super.updateGeometryInteractions(e,t),this.updateShape()}updateEntityBoxSize(e,t){let o=this.geometry.getAttribute("position");o!==void 0?ws(o,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:o.count,e,t):super.updateEntityBoxSize(e,t)}};import{Group as EA}from"three";var Jr=class extends bo(EA,So){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 po.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 po.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(Ie.is(s))e.scene.disposeAndUnregisterEntityRecursivelyIfNotReregistered(s),Xl(s),i+=1;else break;this.children.splice(0,i)}o=!0}this.component&&Rg(e,[this.uuid],t.overrides,this,this.component,this.component,0,o),this.oldComponent=this.component}}};function Xl(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)Ie.is(e)&&Xl(e)}}function Gg(n,r,e,t){return n.component===r&&Hi(n.identity,t)?n.overrideData===e?2:1:0}function Rg(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 Jr&&o.isInstanceRoot&&o.expandInstanceChildren(n);let c=0;for(let u of o.children)if(Ie.is(u)){let a=[...r,...typeof u.identity=="string"?[u.identity]:u.identity],d=Dn.resolve(e,a,1),p=null,f;if(!l){let m=t.children[c];if(p=Ie.is(m)?m:null,p!==null){let h=Gg(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=Gg(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?Hr.apply(u.data,d):u.data;Qt.is(m.type)&&(m={...m,type:"Empty"}),p=tr.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,Rg(n,r,e,p,u,i,s+1,l)}if(!l){let u=c;for(;;){let a=t.children[c];if(Ie.is(a))n.pendingDeletes.add(a);else break;c+=1}t.children.splice(u,c-u)}return!0}function LA(n,r,e){let t;return r.geometry.type==="TextGeometry"?new Ii(n,r,e):(r.geometry.type==="SubdivGeometry"?t=new qo(n,r,e):r.geometry.type==="PathGeometry"?t=new zi(n,r,e):r.geometry.type==="VectorGeometry"?t=new Yl(n,r,e):r.geometry.type==="BooleanGeometry"?t=new Kt(n,r,e):t=new ft(n,r,e),t)}function Kl(n,r,e){return r.type==="Mesh"?LA(n,r,e):r.type==="Empty"?new zs(n,r):r.type==="PointLight"?new Wl(n,r,e):r.type==="SpotLight"?new $l(n,r,e):r.type==="DirectionalLight"?new Hl(n,r,e):r.type==="Component"||r.type==="Instance"?new Jr(n,r,e):Qt.is(r.type)?new Gr(n,r):(console.error(r),new zs(n,r))}tr.createEntity=Kl;function BA(n,r,e){let t=Kl(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()}tr.changeEntityProptotype=BA;tr.Cloner=Ei;function Vg(n,r,e,t){n.updateByOp(r,e,t,!1)}import{Matrix4 as RA,Ray as VA,Raycaster as zA}from"three";function zg(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,Ni(n),Ai(n)),t.length===0&&o.length===0&&n.layers.set(0),n instanceof $t&&n.needsAO&&n.layers.enable(5),e}function jg(n,r){if(!r.layers)return!1;let e=!1,t=r.getLayersOfType("transmission").filter(i=>i.data.visible),o=r.getLayersOfType("outline").filter(i=>i.data.visible);return t.length>0&&(n.layers.set(3),o.length>0&&n.layers.enable(8),e=!0),t.length===0&&o.length===0&&n.layers.set(0),n.needsAO&&n.layers.enable(5),e}function Fg(n){let r=!1;return n.traverseEntity(e=>{if(e instanceof $t)if(Array.isArray(e.material))for(let t=0;t<e.material.length;t++)zg(e,e.material[t])&&(r=!0);else zg(e,e.material)&&(r=!0)}),r}function kg(n){let r=!1;return n.traverseEntity(e=>{if(e instanceof $t)if(Array.isArray(e.material))for(let t=0;t<e.material.length;t++)jg(e,e.material[t])&&(r=!0);else jg(e,e.material)&&(r=!0)}),r}var jA=new zA,FA=new RA,kA=new VA;function gu(n,r,e,t=!1){let o=n.cloner;if(o)for(let i of o.children){let s=FA.copy(i.matrixWorld).invert(),l=kA.copy(r.ray).applyMatrix4(s),c=n.matrixWorld;l.applyMatrix4(c);let u=jA;u.set(l.origin,l.direction),u.near=r.near,u.far=r.far;let a=u.intersectObject(n,!1);a.length>0&&e.push({...a[0],object:t?i:n})}}var Zl=class{constructor(){this._constraints=new Map}setConstraint(r,e){e===null?this._constraints.delete(r):this._constraints.set(r,e)}removeDependencies(r){this._constraints.delete(r)}applyConstraints(r){let e=new Set;this._constraints.forEach((t,o)=>{let i=[o,t],s=t;for(;this._constraints.has(s);)s=this._constraints.get(s),e.has(s)||i.push(s);for(let l=i.length-2;l>=0;l--)if(!e.has(i[l])){let c=r.find(i[l]);c?c.applyPathSnapping(r):console.warn(`missing entity ${i[l]}`),e.add(i[l])}})}findDependency(r,e){let t=r;for(;this._constraints.has(t);)if(t=this._constraints.get(t),t===e)return!0;return!1}};var XA=new YA;XA.wireframe=!0;var Ug=new qA,xu=class extends HA{constructor(e,t){super();this.data=e;this.backupFog=new WA(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.occlusion=!1;this.aoFullRes=!1;this.radius=128;this.bias=.5;this.aoColor={r:0,g:0,b:0};this.geometryCacheChanged=!1;this.bgColor=new Ke(1,1,1,1);this.entityByUuid={};this.entityIdentityToEntity={};this.toExpandCloner=new Set;this.toUpdateCloner=new Set;this.pendingCommands=[];this.pathConstraints=new Zl;this.needsRecomputeInstances=!1;this.ambientLight=new UA(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=kg(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=Fg(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)=>_u(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(),Gi(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()),Gi(o)&&(o.freeBooleanPointer(),i instanceof Kt&&i.invalidateDownstreamBooleanData().recomputeBoolean()),o instanceof zi&&o.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(o),this.pathConstraints.removeDependencies(o.uuid)}else if(e.path.length===0&&e.type===9){let o=this.find(e.id);if(o===void 0)throw new Error("unexpected");this.markNeedsRecomputeInstancesForChildren(o);let i=o.parent;this.markNeedsRecomputeInstancesForAncessors(i),o.cloner?.resetOnMove(),this.markToExpandCloner(o);let s=e.parent===null?this:this.find(e.parent);if(s===void 0)throw new Error("unexpected");s.add(o),this.markNeedsRecomputeInstancesForAncessors(s),this.markToExpandCloner(o),o.invalidateClonerTransform(o),o.updateVisible(),o.resetBBoxNeedsUpdate();let l=e.localIndex;s.children.splice(l,0,s.children.pop()),Gi(o)&&(o.invalidateUpstreamBooleanData(),Vs(o.parent)?o.parent.invalidateDownstreamBooleanData().recomputeBoolean():i instanceof Kt&&i.invalidateDownstreamBooleanData().recomputeBoolean())}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}updateEntityByOp(e,t,o,i){if(t.type===0){if(("overrides"in t.props||"component"in t.props)&&this.markNeedsRecomputeInstances(),t.path.includes("overrides")&&"states"in t.props){let{rest:l}=t.props;t={...t,props:l},this.markNeedsRecomputeInstances()}t.path[0]==="pathSnapping"&&t.props.pathId!==void 0&&this.pathConstraints.setConstraint(e,t.props.pathId)}let s=this.find(e);if(s)try{Vg(s,t,o,{scene:this,shared:i}),s instanceof ft&&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(st(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 Gr&&this.switchActiveCamera(o)}this.expandInstances(t,!0),this.traverseEntity(o=>{Vs(o)&&o.recomputeBoolean(),o instanceof Gr&&o.updateUp()}),this.doPendingExpandCloner(),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(t=>{(t.data.type==="Component"||t.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){Ie.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(t=>{Ie.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=Nn(a.data,d=>{let p=d.events.data(c.id),f=a.goUp(l);if(f){let m=[...Ys(f.identity),e].join("-"),h=this.entityIdentityToEntity[m];if(h){let y=h.uuid;yt.zoom(p,t)[o]=y}else{if(!1)debugger;console.warn("cannot find instance")}}}).data)})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof Jr&&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=Nn(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 Jr&&i.isInstanceRoot)return i.expandInstanceChildren({scene:this,shared:e,pendingDeletes:o}),t||i.resetBBoxNeedsUpdate(),!0});for(let i of o)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(i),Xl(i)}recomputeInstances(e){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(t=>{t instanceof Jr&&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)Ie.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,t){this.init(e,t)}createPersonalCamera(){let e=new Gr(xu.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){let l=s.cloner;Ie.is(s)&&!s.raycastLock&&(s.visible||l?.object.data.visible)&&((Gi(s)||yu(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,t),gu(s,e,t)),o(s))}};return o(this),t}raycastWithClones(e){let t=[],o=i=>{for(let s of i.children){let l=s.cloner;Ie.is(s)&&(s.visible||l?.object.data.visible)&&((Gi(s)||yu(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,t),gu(s,e,t,!0)),o(s))}};return o(this),t}forEachEntity(e){for(let t of this.children)Ie.is(t)&&e(t)}traverseEntity(e){for(let t of this.children)Ie.is(t)&&t.traverseEntity(e)}traverseObject(e){for(let t of this.children)os.is(t)&&t.traverseObject(e)}traverseVisibleEntity(e){for(let t of this.children)Ie.is(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=st(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=st(e.color,t)),e.intensity!==void 0&&(this.ambientLight.intensity=e.intensity),e.groundColor!==void 0&&(this.ambientLight.groundColor=st(e.groundColor,t)),e.enabled!==void 0&&(this.ambientLight.visible=e.enabled),e.occlusion!==void 0&&(this.occlusion=e.occlusion),e.aoFullRes!==void 0&&(this.aoFullRes=e.aoFullRes),e.radius!==void 0&&(this.radius=e.radius),e.bias!==void 0&&(this.bias=e.bias),e.aoColor!==void 0&&(this.aoColor=st(e.aoColor,t))}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=Kl(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 ft&&u.updateGeometryGroupsIfNeeded(),u.updateVisible(),u.cloner&&this.toExpandCloner.add(u),t.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,t.pathSnapping.pathId)),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 $A;return o.setFromPoints(t),o.getCenter(Ug),Ug}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 dt)if(Array.isArray(t.material))for(let o=0;o<t.material.length;o++)t.material[o]instanceof It&&e(t.material[o]);else t.material instanceof It&&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})})}},ji=xu;ji.PERSONAL_CAMERA_ID="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera",ji.PERSONAL_CAMERA_EXPORT_ID="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCameraExport";import{DRACOLoader as KA}from"three/examples/jsm/loaders/DRACOLoader.js";var wo;function ZA(){return wo||(wo=new KA,wo.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),wo.decoderPending}async function QA(n){if(wo){let r={attributeIDs:wo.defaultAttributeIDs,attributeTypes:wo.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await wo.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 Hg(n,r){let[e,t]=uc(Ga.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 ZA();for(let i of o){let s=await QA(Qe(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}import{Mesh as IK}from"three";import{mergeBufferGeometries as LK}from"three/examples/jsm/utils/BufferGeometryUtils.js";function qg(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}import{Color as Wg,ShaderLib as JA}from"three";function $g(n){let r=new Set;return n.traverse(e=>{if(e instanceof $t)if(Ve(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(eN(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new Wg,specularColor:new Wg});let o=0;e.onBeforeCompile=(i,s)=>{t&&t(i,s),i.uniforms=Object.assign({},JA.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,e.defines.IS_THREEJS_EXPORT=!0)}else o++,o<2&&(e.needsUpdate=!0)})}}else tN(e)||(e.onBeforeCompile=(o,i)=>{t&&t(o,i),e.transparent=!1})}),n}function eN(n){return n.getLayersOfType("transmission").length>0}function tN(n){let r=0;for(let e of n.layers){if(e.data.type!=="displace"&&e.data.isMask)return!0;if(e.type!=="light"&&e.type!=="fresnel"){let o=e.uniforms["f"+e.id+"_alpha"];o&&(r+=(1-r)*o.value)}}return r<1}function Yg(n){return n.traverse(r=>{if(r.type==="Camera"){let e=r;e.type=e.cameraType}}),n}function Xg(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}import{mergeBufferGeometries as rN}from"three/examples/jsm/utils/BufferGeometryUtils.js";function Kg(n){let r=[];return n.traverse(e=>{e instanceof Ei&&r.push(e)}),r.forEach(e=>{let t=e.object,s=[...e.children.map(l=>{l.updateMatrix();let c;if(l.geometry!==void 0)try{c=l.geometry.clone().applyMatrix4(l.matrix)}catch(u){console.error(u)}return c!==void 0&&l.matrix.determinant()<0&&qg(c),c}).filter(l=>l!==void 0)];if(!e.parameters.hideBase&&t instanceof dt&&s.unshift(t.geometry),s.length){let l=rN(s);t instanceof dt&&(t.geometry=l)}e.removeFromParent(),t.setFromClonerState(null,{scene:n,shared:Jy})}),n}function Zg(n){return n.traverse(r=>{r.matrixAutoUpdate=!0}),n}function Qg(n){Object.values(n.shared.materials).forEach(r=>{vu(r)}),n.scene.objects.traverse((r,e)=>{"material"in e?vu(e.material):"materials"in e&&e.materials.forEach(t=>{vu(t)})})}function vu(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 o0=$s(e0(),1);function t0(n){return n.traverseMaterial(r=>{r.needsJitter=!1}),n}var r0="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",bu=class extends nN{load(r,e,t,o=console.error){let i=new oN(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),r.endsWith(".spline")?console.warn(r0+" The .spline files are only meant to be used by the Editor."):r.endsWith(".splinecode")||console.warn(r0),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 Hg(r,Qg);e.version&&(0,o0.default)(e.version,"0.9.384")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/loader to the latest version."),await Promise.all([rg(e)&&hy(),fg(e)&&Zy()].filter(Boolean));let t=new Ho(e.shared);Object.values(t.getMaterials()).forEach(s=>Object.assign(s,{isAsset:!0}));let o=new ji(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&&Ng(s)&&Object.assign(s,{makeDefault:!0})}return o=Kg(o),o=$g(o),o=Yg(o),o=Xg(o),o=Zg(o),o=t0(o),o}};export{bu as default};
|
|
2207
|
+
`),u&&d.push(u.code,`outgoingLight = spe_blend(outgoingLight, ${u.result}, 1.0, SPE_BLENDING_NORMAL);`),l?d.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${l.result} );`):d.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),d.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),t=d.join(`
|
|
2208
|
+
`)}return t}};import{VideoTexture as LO,Texture as DO}from"three";var ql=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 yu=class extends ql{create(r){return URL.createObjectURL(new Blob([r]))}dispose(r,e){URL.revokeObjectURL(e)}},hu;function pg(n){return typeof n=="string"?n:(hu||(hu=new yu),hu.load(n))}var $l=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")}},Yl=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 Vi=class extends $l{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 a=this[s];a&&(a.image=this.img,a.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=a=>{i=a.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=pg(e),this.img.onload=t}getTexture(e){let t=this[e];if(t)return t;{let o;return this.isVideo?o=new LO(this.img,void 0,e,e):o=new DO(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 Yt=class extends Vi{};import{Vector2 as oo,Vector3 as Er,Vector4 as Xl}from"three";function ht(n,r){return r.color(n)}function fg(n,r){switch(n.type){case"fresnel":return GO(n,r);case"gradient":return VO(n);case"depth":return zO(n);case"normal":return jO(n);case"noise":return FO(n,r);case"rainbow":return kO(n);case"toon":return UO(n,r);case"outline":return HO(n,r);case"transmission":return WO(n,r);case"color":return RO(n,r);case"pattern":return qO(n,r)}}function BO(n){return{type:n.type}}function ur(n){let{alpha:r,mode:e,isMask:t}=n;return{...BO(n),alpha:r,mode:e,isMask:t}}function RO(n,r){return{...ur(n),color:ht(n.color,r)}}function GO(n,r){let{bias:e,scale:t,intensity:o,factor:i,color:s,isMask:a}=n;return{...ur(n),color:ht(s,r),bias:e,scale:t,intensity:o,factor:i}}function VO(n){let{gradientType:r,smooth:e,colors:t,steps:o,angle:i,offset:s,morph:a}=n;return{...ur(n),gradientType:r,smooth:e,colors:t.map(c=>new Xl(c[0],c[1],c[2],c[3])),num:t.length,steps:o,offset:new oo(...s),morph:new oo(...a),angle:i}}function zO(n){let{gradientType:r,near:e,far:t,isVector:o,isWorldSpace:i,origin:s,direction:a,colors:c,steps:u,smooth:l}=n;return{...ur(n),gradientType:r,near:e,far:t,isVector:o,isWorldSpace:i,origin:new Er(...s),direction:a?new Er(...a):new Er(1,0,0),colors:c.map(d=>d!==void 0?new Xl(d[0],d[1],d[2],d[3]):new Xl(0,0,0,0)),steps:u.slice(0,c.length),smooth:l}}function jO(n){let{cnormal:r}=n;return{...ur(n),cnormal:new Er(r[0],r[1],r[2])}}function FO(n,r){return{...ur(n),scale:n.scale,move:n.move,fA:new oo(...n.fA),fB:new oo(...n.fB),size:new Er(...n.size),distortion:new oo(...n.distortion),colorA:ht(n.colorA,r),colorB:ht(n.colorB,r),colorC:ht(n.colorC,r),colorD:ht(n.colorD,r),noiseType:n.noiseType,voronoiStyle:n.voronoiStyle,highCut:n.highCut,lowCut:n.lowCut,smoothness:n.smoothness,seed:n.seed,quality:n.quality}}function kO(n){return{...ur(n),filmThickness:n.filmThickness,movement:n.movement,wavelengths:new Er(...n.wavelengths),noiseStrength:n.noiseStrength,noiseScale:n.noiseScale,offset:new Er(...n.offset)}}function UO(n,r){return{...ur(n),positioning:n.positioning,colors:n.colors.map(e=>new Xl(e[0],e[1],e[2],e[3])),num:n.colors.length,steps:n.steps,source:new Er(...n.source),isWorldSpace:n.isWorldSpace,noiseStrength:n.noiseStrength,noiseScale:n.noiseScale,shadowColor:ht(n.shadowColor,r),offset:new Er(...n.offset)}}function HO(n,r){return{...ur(n),outlineColor:ht(n.outlineColor,r),contourColor:ht(n.contourColor,r),outlineWidth:n.outlineWidth,contourWidth:n.contourWidth,outlineThreshold:n.outlineThreshold,contourThreshold:n.contourThreshold,outlineSmoothing:n.outlineSmoothing,contourFrequency:n.contourFrequency,contourDirection:new Er(...n.contourDirection),positionalLines:n.positionalLines,compensation:n.compensation}}function WO(n,r){return{...ur(n),thickness:n.thickness,ior:n.ior,roughness:n.roughness}}function qO(n,r){return{...ur(n),style:n.style,projection:n.projection,axis:n.axis,blending:n.blending,offset:new oo(...n.offset),colorA:ht(n.colorA,r),colorB:ht(n.colorB,r),frequency:new oo(...n.frequency),size:n.size,variation:n.variation,smoothness:n.smoothness,zigzag:n.zigzag,rotation:n.rotation,vertical:new oo(...n.vertical),horizontal:new oo(...n.horizontal),sides:n.sides}}var Io=class extends Je{};import{Vector4 as $O}from"three";var gu={noise:["noiseType"],texture:["projection","axis","side"],video:["projection","axis","side"],displace:["noiseType"],light:["roughnessMap","bumpMap"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"]},xu={depth:["colors"]};function YO(n,r,e){if(r==="isMask")return!0;let t=gu[n.type],o=xu[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 vu(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,a=r.image(s),c=t;c.image instanceof Yt||c.image.deref(),c.image=a}if("video"in i){let s=i.video,a=r.video(s),c=t;c.image instanceof Yt||c.image.deref(),c.image=a}if("wrapping"in i){let s=t;s.wrap=i.wrapping}if("repeat"in i||"offset"in i){let s="mat",a=e.uniforms[`f${e.id}_${s}`];"repeat"in i&&(a.repeat=i.repeat),"offset"in i&&(a.offset=i.offset),a.updateMatrix()}return o}function mg(n,r,e,t){let o=!1;for(let[i,s]of Object.entries(n)){if(!i||s===void 0)continue;if(bu(i,e,t)){i==="visible"&&e.type==="light"&&(o=!0);continue}e.visible=t.visible;let a=e.uniforms[`f${e.id}_${i}`];if(!!a&&!(a instanceof Co))switch(o=o||YO(e,i,s),a.constructor){case Ae:if(typeof s=="string"){let c=r.getColor(s);c&&(a.value=c);break}else{let c=s;a.value instanceof Io?a.value=new Je(c.r,c.g,c.b,c.a):a.setRGBA(c);break}case Et:if(typeof s=="string"){let c=r.getColor(s);c&&(a.value=c);break}else{let c=s;a.value instanceof Io?a.value=new Je(c.r,c.g,c.b,c.a):a.value.setRGBA(c.r,c.g,c.b,c.a);break}case Ve:{let c=s;a.value.setX(c[0]),a.value.setY(c[1]);break}case ft:{let c=s;a.value.setX(c[0]),a.value.setY(c[1]),a.value.setZ(c[2]);break}case Pt:{vu(s,r,e);break}case dr:{a.value=s.map(c=>new $O(...c));break}default:{a.value=s;break}}}return o}var Dr=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)bu(i,this,t)}get type(){return this.data.type}static create(r,e,t,o){if(t.type==="light")return Ut.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),a=new Hl(i),c=new Wl(t.texture.repeat,t.texture.offset),u=new Z(t.crop?1:0),l=new ve(t.projection??0),d=new ve(["x","y","z"].indexOf(t.axis)??0),p=new ve(t.side??0),f=new Ve(t.size?new pr(t.size[0],t.size[1]):new pr(100,100)),m=new Z(t.blending??0),h=new Z(t.alpha??1),y=new ve(t.mode??0),g=new ke(t.isMask??!1),x=new No(s,a,u,l,d,p,f,m,c,h,y,g),b=new Pe(x.calpha,"f");return new De(r,e,t,{texture:s,textureSize:a,crop:u,projection:l,axis:d,side:p,size:f,blending:m,mat:c,alpha:h,mode:y,isMask:g},x,y,b,g)}else if(t.type==="matcap"){let i=o.image(t.texture.image),s=new Zo(i,t.texture.wrapping),a=new Z(t.alpha??1),c=new ve(t.mode??0),u=new ke(t.isMask??!1),l=new Ii(s,a,c,u),d=new Pe(l.calpha,"f");return new De(r,e,t,{texture:s,alpha:a,mode:c,isMask:u},l,c,d,u)}else if(t.type==="displace")if(t.displacementType==="noise"){let i=new ft(new Lr(...t.offset)),s=new Z(t.scale??10),a=new Z(t.intensity??8),c=new Z(t.movement??1),u=new ve(t.noiseType??0),l=new ve(t.voronoiStyle??0),d=new Z(t.smoothness??.5),p=new Z(t.seed??0),f=new Z(t.highCut??1),m=new Z(t.lowCut??0),h=new ve(t.quality??1),y=new Gi(a,c,i,l,d,p,f,m,h,s,u);return new ks(r,e,t,{offset:i,scale:s,intensity:a,movement:c,noiseType:u,voronoiStyle:l,smoothness:d,seed:p,highCut:f,lowCut:m,quality:h},y)}else throw new Error;else return ZO(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||"visible"in o.props?(t.scene.markNeedsUpdateRendererDirty(),!0):mg(o.props,t.shared,this,e)}else if(o.path[0]==="texture")return"texture"in e||"video"in e?vu(o.props,t.shared,this):!0;return!1}dispose(){if(XO(this)){let r=this.uniforms[`f${this.id}_texture`];if(!r)return!1;let e=r;e.image instanceof Yt||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}},De=class extends Dr{constructor(e,t,o,i,s,a,c,u){super(e,t,o,i);this.params=i;this.color=s;this.mode=a;this.alpha=c;this.isMask=u}},ks=class extends Dr{constructor(e,t,o,i,s){super(e,t,o,i);this.position=s}},Ut=class extends Dr{constructor(e,t,o,i,s){super(e,t,o,s);this.node=i}static createLigherLayer(e,t,o,i){let s,a=new Z(o.alpha),c=new ve(o.mode),u=new Z(o.bumpMapIntensity),l;if(!o.visible)s=new en,l={};else if(o.category==="lambert"){s=new Vs;let d=new Ae(i.color(o.emissive)??0),p=new ke(o.occlusion??!0);l={emissive:d,occlusion:p},s.emissive=d,s.occlusion=p}else if(o.category==="toon"){s=new Fs;let d=new Z(o.shininess??30),p=new Ae(i.color(o.specular)??1118481);l={shininess:d,specular:p},s.shininess=d,s.specular=p}else if(o.category==="physical"){s=new js;let d=new Z(o.roughness??.3),p=new Z(o.metalness??0),f=new Z(o.reflectivity??.5),m=new ke(o.occlusion??!0);l={roughness:d,metalness:p,reflectivity:f,occlusion:m},s.roughness=d,s.metalness=p,s.reflectivity=f,s.occlusion=m}else{s=new zs;let d=new Z(o.shininess??30),p=new Ae(o.specular!==void 0?i.color(o.specular)??1118481:1118481),f=new ke(o.occlusion??!0);l={shininess:d,specular:p,occlusion:f},s.shininess=d,s.specular=p,s.occlusion=f}return s.alpha=new Z(1),s.shadingAlpha=a,s.shadingBlend=c,s.bumpMapIntensity=u,l.alpha=s.shadingAlpha,l.mode=s.shadingBlend,l.bumpMapIntensity=s.bumpMapIntensity,new Ut(e,t,o,s,l)}get category(){return this.node.category}};function XO(n){let r=n instanceof Dr?n.type:n;return r==="texture"||r==="video"||r==="displace_map"||r==="matcap"}function Xt(n){return{alpha:new Z(n.alpha??1),mode:new ve(n.mode??0),isMask:new ke(n.isMask??!1)}}function KO(n,r,e,t){switch(n.type){case"color":{let o=new Ae(t.color??Ke),i=Xt(t),s=new Qo(o,i.alpha),a=new Pe(s.calpha,"f");return new De(r,e,n,{color:o,...i},s,i.mode,a,i.isMask)}case"fresnel":{let o=new Ae(t.color??16777215),i=new Z(t.bias??.1),s=new Z(t.scale??1),a=new Z(t.intensity??2),c=new Z(t.factor??1),u=Xt(t),l=new Rs(o,i,s,a,c,u.alpha,u.mode,u.isMask),d=new Pe(l.calpha,"f");return new De(r,e,n,{color:o,bias:i,scale:s,intensity:a,factor:c,...u},l,u.mode,d,u.isMask)}case"rainbow":{let o=new Z(t.filmThickness??30),i=new Z(t.movement??0),s=new ft(t.wavelengths??new Lr(0,0,0)),a=new Z(t.noiseStrength??0),c=new Z(t.noiseScale??1),u=new ft(t.offset??new Lr(0,0,0)),l=Xt(t),d=new Di(o,i,s,a,c,u,l.alpha,l.isMask),p=new Pe(d.calpha,"f");return new De(r,e,n,{filmThickness:o,movement:i,wavelengths:s,noiseStrength:a,noiseScale:c,offset:u,...l},d,l.mode,p,l.isMask)}case"transmission":{let o=new Z(t.thickness??10),i=new Z(t.ior??1.5),s=new Z(t.roughness??.5),a=ye.transmissionSize,c=ye.transmissionRenderTarget,u=ye.transmissionRenderTargetDepth,l=window.innerWidth,d=window.innerHeight,p=l>=d?new Ve(d/l,1):new Ve(1,l/d),f=Xt(t),m=new Ri(o,i,s,a,c,u,p,f.alpha),h=new Pe(m.calpha,"f");return new De(r,e,n,{thickness:o,ior:i,roughness:s,aspectRatio:p,...f},m,f.mode,h,f.isMask)}case"toon":{let o=new ve(t.positioning??0),i;t.colors?i=new dr(t.colors.length,t.colors):(i=new dr(10,new zi(0,0,0,1)),i.value[1]=new zi(1,1,1,1));let s;t.steps?s=new cr(t.steps.length,t.steps):(s=new cr(10,1),s.value[0]=0);let a=new ft(t.source??new Lr(0,0,0)),c=new ke(t.isWorldSpace??!0),u=new Z(t.noiseStrength??0),l=new Z(t.noiseScale??1),d=new Et(t.shadowColor),p=new ft(t.offset??new Lr(0,0,0)),f=Xt(t),m=new Bi(o,i,s,a,c,u,l,d,p,f.alpha),h=new Pe(m.calpha,"f");return new De(r,e,n,{positioning:o,colors:i,steps:s,source:a,isWorldSpace:c,noiseStrength:u,noiseScale:l,shadowColor:d,offset:p,...f},m,f.mode,h,f.isMask)}case"outline":{let o=new Ae(t.outlineColor??16777215),i=new Ae(t.contourColor??16777215),s=new Z(t.outlineWidth??.1),a=new Z(t.contourWidth??.1),c=new Z(t.outlineThreshold??.1),u=new Z(t.contourThreshold??.1),l=new Z(t.outlineSmoothing??.1),d=new Z(t.contourFrequency??.1),p=new ft(t.contourDirection??new Lr(0,1,0)),f=new ke(t.positionalLines??!1),m=new ke(t.compensation??!0),h=ye.normalRenderTarget,y=ye.normalRenderTargetDepth,g=ye.pixelRatioNode,x=ye.resolution,b=Xt(t),w=new Ei(o,i,s,a,c,u,l,d,p,f,m,x,h,y,g,b.alpha),S=new Pe(w.calpha,"f");return new De(r,e,n,{outlineColor:o,contourColor:i,outlineWidth:s,contourWidth:a,outlineThreshold:c,contourThreshold:u,outlineSmoothing:l,contourFrequency:d,contourDirection:p,positionalLines:f,compensation:m,...b},w,b.mode,S,b.isMask)}case"depth":{let o=new ve(t.gradientType??0),i=new ke(t.smooth??!1),s=new Z(t.near??50),a=new Z(t.far??200),c=new Z(t.isVector??1),u=new Z(t.isWorldSpace??0),l=new ft(t.origin??new Lr),d=new ft(t.direction??new Lr),p;t.colors?p=new dr(t.colors.length,t.colors):(p=new dr(2,new zi(0,0,0,1)),p.value[1]=new zi(1,1,1,1));let f;t.steps?f=new cr(t.steps.length,t.steps):(f=new cr(2,1),f.value[0]=0);let m=Xt(t),h=new Ci(o,i,s,a,c,u,l,d,p,f,m.alpha,m.isMask),y=new Pe(h.calpha,"f");return new De(r,e,n,{gradientType:o,smooth:i,near:s,far:a,isVector:c,isWorldSpace:u,origin:l,direction:d,colors:p,steps:f,...m},h,m.mode,y,m.isMask)}case"noise":{let o=new Z(t.scale??1),i=new ft(t.size??new Lr(100,100,100)),s=new Z(t.move??1),a=new Ve(t.fA??new pr(1.7,9.2)),c=new Ve(t.fB??new pr(8.3,2.8)),u=new Ve(t.distortion??new pr(1,1)),l=new Et(t.colorA),d=new Et(t.colorB),p=new Et(t.colorC),f=new Et(t.colorD),m=new ve(t.noiseType??0),h=new ve(t.voronoiStyle??0),y=new Z(t.highCut??1),g=new Z(t.lowCut??0),x=new Z(t.smoothness??.5),b=new Z(t.seed??.5),w=new ve(t.quality??1),S=Xt(t),P=new Mi(o,i,s,a,c,u,l,d,p,f,S.alpha,m,S.isMask,h,y,g,x,b,w),_=new Pe(P.calpha,"f");return new De(r,e,n,{scale:o,size:i,move:s,fA:a,fB:c,distortion:u,colorA:l,colorB:d,colorC:p,colorD:f,noiseType:m,...S,voronoiStyle:h,highCut:y,lowCut:g,smoothness:x,seed:b,quality:w},P,S.mode,_,S.isMask)}case"normal":{let o=new ft(t.cnormal??new Lr(1,1,1)),i=Xt(t),s=new Ti(o,i.alpha),a=new Pe(s.calpha,"f");return new De(r,e,n,{cnormal:o,...i},s,i.mode,a,i.isMask)}case"gradient":{let o=new ve(t.gradientType??0),i=new ke(t.smooth??!1),s;t.colors?s=new dr(t.colors.length,t.colors):(s=new dr(10,new zi(0,0,0,1)),s.value[1]=new zi(1,1,1,1));let a;t.steps?a=new cr(t.steps.length,t.steps):(a=new cr(10,1),a.value[0]=0);let c=new Ve(t.offset??new pr(0,0)),u=new Ve(t.morph??new pr(0,0)),l=new Z(t.angle??0),d=Xt(t),p=new Ni(o,i,s,a,c,u,l,d.alpha,d.isMask),f=new Pe(p.calpha,"f");return new De(r,e,n,{gradientType:o,smooth:i,colors:s,steps:a,offset:c,morph:u,angle:l,...d},p,d.mode,f,d.isMask)}case"pattern":{let o=new ve(t.style??0),i=new ve(t.projection??0),s=new ve(["x","y","z"].indexOf(t.axis)??0),a=new Z(t.blending??0),c=new Ve(t.offset??new pr(0,0)),u=new Et(t.colorA),l=new Et(t.colorB),d=new Ve(t.frequency??new pr(10,10)),p=new Z(t.size??.5),f=new Z(t.variation??0),m=new Z(t.smoothness??.5),h=new Z(t.zigzag??0),y=new Z(t.rotation??0),g=new Ve(t.vertical??new pr(0,1)),x=new Ve(t.horizontal??new pr(0,1)),b=new ve(t.sides??6),w=Xt(t),S=new Li(o,i,s,a,c,u,l,d,p,f,m,h,y,g,x,b,w.alpha,w.isMask),P=new Pe(S.calpha,"f");return new De(r,e,n,{style:o,projection:i,axis:s,blending:a,offset:c,colorA:u,colorB:l,frequency:d,size:p,variation:f,smoothness:m,zigzag:h,rotation:y,vertical:g,horizontal:x,sides:b,...w},S,w.mode,P,w.isMask)}default:{let o=new Ae(1,0,0,1),i=Xt(t),s=new Qo(o,i.alpha),a=new Pe(s.calpha,"f");return new De(r,e,n,{color:o,...i},s,i.mode,a,i.isMask)}}}function ZO(n,r,e,t){let o=fg(e,t);return KO(e,n,r,o)}function bu(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 hg(n,r){let e=0;for(let t of n.layers){if(t.data.type!=="displace"&&t.data.isMask)return!0;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"&&t.data.type!=="pattern"){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,a=r.color(t.data.colorC).a,c=r.color(t.data.colorD).a,u=Math.min(i,Math.min(s,Math.min(a,c)));u<1&&(o=u)}e+=(1-e)*o}}return e<1}var Dt=class extends QO{constructor(){super(void 0);this.flatShading=!1;this.needsJitter=!0;this.cacheKey="";this.fog=!0,this.dithering=!0,this.vertexColors=!0,this.transparent=!0}customProgramCacheKey(){return this.cacheKey}},Kl=class extends Dt{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}get hasAO(){return this.root.hasAO}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()}},tn=class extends Dt{constructor(e,t){super();this.data=e;this.layerIdGen=0;this.flavors=[];this.masks={};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 Kl(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}get hasAO(){return this.lightLayer.getNode("occlusion")?.value??!1}reset(e,t){this.data!==e&&this.reset0(e,t)}reset0(e,t){this.data=e;let o=e.layers??It.defaultTwoLayerData("phong").layers;try{this.layers=o.map(i=>Dr.create(this.layerIdGen++,i.id,i.data,t.shared))}catch{this.layers=[]}this.layers.reverse(),this.name=e.name??"Untitled Material",this.onUpdate(),this.transparent=hg(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 Ut),this.lightLayer===void 0&&(this.lightLayer=new Ut(0,"",{...wt.defaultData("light","phong"),visible:!1},new en,{})),this.dispose();for(let e of this.flavors)e&&e.dispose();this.applyTextureMaps(),this.applyMasks(),this.blendColors(),this.blendAfterColors(),this.blendPositions()}applyTextureMaps(){let e=this.layers.find(s=>s instanceof Ut);if(!e)return;let t=e.data,o=t.bumpMap,i=t.roughnessMap;e.node.bumpMap=void 0,e.node.roughnessMap=void 0;for(let s=0;s<this.layers.length;++s){let a=this.layers[s];a instanceof De&&a.color instanceof No&&(a.uuid===o&&(e.node.bumpMap=a.color),a.uuid===i&&(e.node.roughnessMap=a.color))}}updateByOp(e,t,o){if(t!==void 0?this.data=t:t=this.data,this.transparent=hg(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 a=Dr.create(this.layerIdGen++,e.id,e.data,o.shared);this.layers.splice(e.localIndex,0,a),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 a=this.layers.findIndex(u=>u.uuid===e.id),c=this.layers[a];this.layers.splice(a,1),this.layers.splice(e.localIndex,0,c),o.scene.markNeedsUpdateRendererDirty()}this.layers.reverse(),this.onUpdate()}else{e.type===0&&e.props.occlusion!==void 0&&o.scene.markNeedsUpdateRendererDirty();let a=this.layers.find(c=>c.uuid===s);if(a){let c=t.layers.data(s);if(a.updateByOp({...e,path:e.path.slice(2)},c,o)){let l=Dr.create(this.layerIdGen++,s,c,i);this.layers.splice(this.layers.findIndex(d=>d.uuid===s),1,l),this.onUpdate()}}}}else this.reset(t,o)}applyMasks(){for(let e=0;e<this.layers.length;++e){let t=this.layers[e];t instanceof De?t.color.mask=void 0:t instanceof Ut&&(t.node.mask=void 0)}for(let e=0;e<this.layers.length;++e){let t=this.layers[e];if(t instanceof De&&t.isMask.value&&t.data.visible&&e>0){let o=e-1,i=this.layers[o];i instanceof Ut?i.node.mask=new st(t.color,t.alpha,st.MUL):i instanceof De&&(i.isMask.value||(i.color.mask=new st(t.color,t.alpha,st.MUL)))}}}blendColors(){let e=this.layers.findIndex(o=>o instanceof De),t=this.layers.findIndex(o=>o instanceof Ut);if(e!==-1&&e<t){let o=this.layers[e].color;for(let i=e+1;i<t;++i){let s=this.layers[i];if(s instanceof De){if(s.isMask.value)continue;o=new Pi(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 Ut);if(this.layers.length>t+1){for(let o=t+1;o<this.layers.length;++o){let i=this.layers[o];if(i instanceof De){if(i.isMask.value)continue;e=new Pi(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 ks);if(e.length>0){let t=e[0].position;for(let o=1;o<e.length;++o)e[o]&&(t=new st(t,e[o].position,st.ADD),t=new st(t,new Z(.5).setReadonly(!0),st.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,a)=>Math.min(Math.max(i,s),a);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=(gu[t.type]??[]).map(u=>t[u]),i=(xu[t.type]??[]).map(u=>t[u]?.length??0),s=[...o,...i],a="isMask"in t&&t.isMask,c=`"${t.type}-${t.visible}-${a}"`;s.length?e+=`[${c}, "${s.join('","')}"],`:e+=c}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 Ul;e.needsJitter=this.needsJitter,this.lights=this.lightLayer.data.visible,e.build(this.fragment,this.fragment),this.vertexShader=e.getCode("vertex"),this.fragmentShader=e.getCode("fragment"),this.defines=e.defines,this.uniforms=e.uniforms,this.extensions=e.extensions,this.updaters=e.updaters;for(let 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 De){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(Dt.prototype,{properties:{get:function(){return this.fragment.properties}}});var rn=class extends tn{};var vg=aa(yg());var gg=new Map;function xg(n){if(typeof n=="string")return n;let r=gg.get(n);return r||(r={url:URL.createObjectURL(new Blob([n]))},gg.set(n,r)),r.url}var on=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:xg(r),format:"wav"},this.sound=new vg.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()}};import{Box2 as JO,Vector2 as nn,Path as bg,Shape as eA,ShapeUtils as tA,Color as rA}from"three";var Ql=class{constructor(){this.type="ShapePath";this.color=new rA;this.subPaths=[];this.currentPath=null}moveTo(r,e){return this.currentPath=new bg,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,x){let b=h.x,w=y.x,S=g.x,P=x.x,_=h.y,v=y.y,N=g.y,T=x.y,C=(P-S)*(_-N)-(T-N)*(b-S),O=(w-b)*(_-N)-(v-_)*(b-S),A=(T-N)*(w-b)-(P-S)*(v-_),R=C/A,U=O/A;if(A===0&&C!==0||R<=0||R>=1||U<0||U>1)return null;if(C===0&&A===0){for(let $=0;$<2;$++)if(i($===0?g:x,h,y),t.loc===e.ORIGIN){let ee=$===0?g:x;return{x:ee.x,y:ee.y,t:t.t}}else if(t.loc===e.BETWEEN){let ee=+(b+t.t*(w-b)).toPrecision(10),Y=+(_+t.t*(v-_)).toPrecision(10);return{x:ee,y:Y,t:t.t}}return null}else{for(let Y=0;Y<2;Y++)if(i(Y===0?g:x,h,y),t.loc===e.ORIGIN){let q=Y===0?g:x;return{x:q.x,y:q.y,t:t.t}}let $=+(b+R*(w-b)).toPrecision(10),ee=+(_+R*(v-_)).toPrecision(10);return{x:$,y:ee,t:R}}}function i(h,y,g){let x=g.x-y.x,b=g.y-y.y,w=h.x-y.x,S=h.y-y.y,P=x*S-w*b;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(P<-Number.EPSILON){t.loc=e.LEFT;return}if(P>Number.EPSILON){t.loc=e.RIGHT;return}if(x*w<0||b*S<0){t.loc=e.BEHIND;return}if(Math.sqrt(x*x+b*b)<Math.sqrt(w*w+S*S)){t.loc=e.BEYOND;return}let _;x!==0?_=w/x:_=S/b,t.loc=e.BETWEEN,t.t=_}function s(h,y){let g=[],x=[];for(let b=1;b<h.length;b++){let w=h[b-1],S=h[b];for(let P=1;P<y.length;P++){let _=y[P-1],v=y[P],N=o(w,S,_,v);N!==null&&g.find(T=>T.t<=N.t+Number.EPSILON&&T.t>=N.t-Number.EPSILON)===void 0&&(g.push(N),x.push(new nn(N.x,N.y)))}}return x}function a(h,y,g){let x=new nn;y.getCenter(x);let b=[];return g.forEach(w=>{w.boundingBox.containsPoint(x)&&s(h,w.points).forEach(P=>{b.push({identifier:w.identifier,isCW:w.isCW,point:P})})}),b.sort((w,S)=>w.point.x-S.point.x),b}function c(h,y,g,x,b){(b==null||b==="")&&(b="nonzero");let w=new nn;h.boundingBox.getCenter(w);let S=[new nn(g,w.y),new nn(x,w.y)],P=a(S,h.boundingBox,y);P.sort((O,A)=>O.point.x-A.point.x);let _=[],v=[];P.forEach(O=>{O.identifier===h.identifier?_.push(O):v.push(O)});let N=_[0].point.x,T=[],C=0;for(;C<v.length&&v[C].point.x<N;)T.length>0&&T[T.length-1]===v[C].identifier?T.pop():T.push(v[C].identifier),C++;if(T.push(h.identifier),b==="evenodd"){let O=T.length%2===0,A=T[T.length-2];return{identifier:h.identifier,isHole:O,for:A}}else if(b==="nonzero"){let O=!0,A=null,R=null;for(let U=0;U<T.length;U++){let $=T[U];y[$]&&(O?(R=y[$].isCW,O=!1,A=$):R!==y[$].isCW&&(R=y[$].isCW,O=!0))}return{identifier:h.identifier,isHole:O,for:A}}else console.warn('fill-rule: "'+b+'" is currently not implemented.')}let u=0,l=999999999,d=-999999999,p=[];this.subPaths.forEach(h=>{let y=h.getPoints(),g=-999999999,x=999999999,b=-999999999,w=999999999;for(let S=0;S<y.length;S++){let P=y[S];P.y>g&&(g=P.y),P.y<x&&(x=P.y),P.x>b&&(b=P.x),P.x<w&&(w=P.x)}d<=b&&(d=b+1),l>=w&&(l=w-1),y.length&&p.push({curves:h.curves,points:y,isCW:tA.isClockWise(y),identifier:u++,boundingBox:new JO(new nn(w,x),new nn(b,g))})});let f=p.map(h=>c(h,p,l,d,this.userData?.style.fillRule)),m=[];return p.forEach(h=>{let y=f[h.identifier];if(y&&!y.isHole){let g=new eA;g.curves=h.curves,f.filter(b=>b?.isHole&&b.for===h.identifier).forEach(b=>{if(b){let w=p[b.identifier],S=new bg;S.curves=w.curves,g.holes.push(S)}}),m.push(g)}}),m}};var Sg,Su=new Promise(n=>{Sg=n});var wg=Bn(async()=>{let n=await import("./opentype.js");Sg(n)});var Us=class{async load(r,e,t=()=>{}){let{load:o}=await Su;o(r,(i,s)=>{i||!s?t(i??"Something went wrong"):e(s)})}async parse(r){let{parse:e,Bidi:t}=await Su;try{let o=e(r),i=new t,s=a=>o.charToGlyphIndex(a.char);return i.registerModifier("glyphIndex",null,s),i.applyFeatures(o,o.defaultRenderOptions.features),{font:o,bidi:i}}catch(o){console.error(o)}}};async function oA(n){return await(await fetch(n)).arrayBuffer()}var nA=new Us;async function wu(n){let r,e,t=!1;if(n.url?(r=await oA(n.url),e=n.url,t=n.url.startsWith("/")):n.data&&(r=n.data.buffer),r){let o=await nA.parse(r);if(o)return{font:o.font,url:e,intercepted:t,arr:r,bidi:o.bidi}}}import{CubicBezierCurve as iA,LineCurve as sA,QuadraticBezierCurve as aA}from"three";function lA(n,r){return r.state.glyphIndex===n||r.state.fina===n||r.state.medi===n||r.state.init===n}var Jl=class{constructor(r){this._arrayBuffer=new ArrayBuffer(1);this._isLoaded=!1;this._intercepted=!1;this._isUserFont=r.isUserFont??!1,this._loadingPromise=wu(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=wu(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=[],a=0,c=t.length===i.length;for(let u=0;u<t.length;u++){let l=t[u].index,d=String.fromCharCode(t[u].unicode),p=i[a];if(lA(l,p)||c)s.push({char:d,index:l,replacements:[p.state.glyphIndex],replacementChars:[p.char]}),a++;else{let f=p.char,m="",h=[p.state.glyphIndex],y=[],g=!1;for(;!g;)a++,m=e.charAt(a),f+=m,h.push(r.charToGlyphIndex(m)),y=r.stringToGlyphs(f),y.length===1&&y[0].index===l&&(g=!0),a>e.length&&(g=!0);s.push({char:d,index:l,replacements:h,replacementChars:Array.from(f)}),a++}}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(x=>this.getTextWidth(x,e)),a=e.width,c=this.getCharWidth(`
|
|
2209
|
+
`,e),u=e.horizontalAlign===1?c:0,l=this.computeSpaceWidthForLine(r,0,e),d=this.getLineInitialOffsetX(s[0],a,e.horizontalAlign,r[0],c),p=this.getLineInitialOffsetY(i,r.length,e.height,o,e.verticalAlign),f=[],m=r.map(x=>[]),h=r.map(x=>[]),y;for(let x=0;x<r.length;x++){let b=r[x],w={features:{liga:!0}},S=[];try{S=t.stringToGlyphs(b,w)}catch(_){console.warn(_)}d=this.getLineInitialOffsetX(s[x],a,e.horizontalAlign,b,c);let P=[];try{P=this.reverseLigaturesTable(t,b,S)}catch(_){console.warn(_)}l=this.computeSpaceWidthForLine(r,x,e);for(let _=0;_<S.length;_++){let v=S[_],N=v.index===0?`
|
|
2210
|
+
`:v.unicode?String.fromCharCode(v.unicode):void 0,T=P[_],C=0,O=0;_===0&&e.horizontalAlign===2&&v.leftSideBearing!==void 0&&(O=-v.leftSideBearing*o),y&&(C=t.getKerningValue(v,y)*o),d+=O+C;let A=0;if(N===`
|
|
2211
|
+
`)A=u;else if(N===" ")A=l;else{let R=this.createPath(v,o,d,p,e);R&&(A=R.offsetX-(C+O),f.push(R.path))}if(T.replacements.length===1)h[x].push([d,p]),m[x].push(A);else{let R=T.replacements.map(Y=>(t.glyphs.get(Y).advanceWidth??0)*o),U=R.reduce((Y,q)=>Y+=q,0),$=R.map(Y=>Y/U),ee=d;for(let Y=0;Y<$.length;Y++){let q=A*$[Y];h[x].push([ee,p]),m[x].push(q),ee+=q}}d+=A,y=v}p-=i}let g=[];for(let x=0,b=f.length;x<b;x++)g.push(...f[x].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(`
|
|
2212
|
+
`)>=0&&(r-=i),t===3?e*.5-r*.5:t===2?e-r:0}getLineInitialOffsetY(r,e,t,o,i){let s=e*r,a=Math.abs(this.ascender-this.descender)*o,c=r-a,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 a=new Ql,c=(r.advanceWidth??1)*e;if(r)for(let u of s.commands){let l=a.currentPath?.currentPoint;if(!(l&&u.type!=="Z"&&l.x===u.x&&-l.y===u.y))switch(u.type){case"M":a.moveTo(u.x,-u.y);break;case"L":a.lineTo(u.x,-u.y);break;case"Q":a.quadraticCurveTo(u.x1,-u.y1,u.x,-u.y);break;case"C":a.bezierCurveTo(u.x1,-u.y1,u.x2,-u.y2,u.x,-u.y);break}}return a.subPaths.forEach(u=>{let l=cA(u.curves);l!==void 0&&u.currentPoint.distanceTo(l)>0&&u.lineTo(l.x,l.y)}),{offsetX:c+i.fontSize*i.letterSpacing,path:a}}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 a=t.width,c=this.getTextWidth(i,t);return(a-(c-s*o))/s}}return o}countSpaces(r){return(r.match(/ /g)||[]).length}};function cA(n){if(n.length){let r=n[0];if(r instanceof sA)return r.v1;if(r instanceof iA||r instanceof aA)return r.v0}}var _u=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()}},Hs=class extends _u{constructor(e){super();this.flatShading=e}disposeObject(e){e.dispose()}createObject(e,t){let o=Yo(e,t,this.flatShading);return o.computeBoundingSphere(),o}};var _g={markNeedsUpdateRendererDirty:()=>{}};var Pu=class extends Yl{constructor(e){super();this.shared=e}create(e){return new Vi(e,this.shared)}},sn=class{constructor(r,e={}){this.geometryCache=new Hs(!0);this.geometryCache2=new Hs(!1);this.imageHolderCache=new Pu(this);this.thisContext={scene:_g,shared:this};this.deletedMaterial=new rn(It.defaultTwoLayerData("phong"),this.thisContext);this.deletedImage=new Yt(Kn.emptyImage,this);this.deletedVideo=new Yt(Hn.defaultVideo,this);this.materials={};this.images={};this.videos={};this.colors={};this.audios={};this.fonts={};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 rn(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)}addMaterial(r,e){e.uuid=r,this.materials[r]?(this.materials[r].reset(e.data,this.thisContext),e.dispose()):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 tn(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 Yt(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 Yt(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 Io(e.r,e.g,e.b,e.a):this.colors[r]=new Io(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 Je(0,0,0,0))}else return"a"in r?new Je(r.r,r.g,r.b,r.a):new Je(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 on)return e;{let t=new on({src:e});return this.audios[r]=t,t}}deleteAudio(r){let e=this.audios[r];e&&(e instanceof on&&e.dispose(),delete this.audios[r])}addFont(r,e){this.fonts[r]=new Jl(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 on&&e.dispose()}),this.audios={},this.geometryCache.dispose(),this.geometryCache2.dispose()}},Pg=new sn(ul.emptyData());var Bt=class extends pt{updateByPatchedOp(e,t,o){if(super.updateByPatchedOp(e,t,o),Pm(e.path,["materials"])!==null&&e.type===0&&Array.isArray(this.material))for(let[i,s]of Object.entries(e.props)){let a=o.shared.material(s);this.material[Number(i)]=a}else if(yt(e.path,["material"])&&this.material instanceof Dt)"material"in t&&typeof t.material!="string"&&this.material.updateByOp(dt.drop(e,1),t.material,o);else if(yt(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(dt.drop(e,2),s,o)}}}get needsAO(){return this.material!==void 0?(Array.isArray(this.material)?this.material[0]:this.material).hasAO:!1}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&&la(this.material).forEach(e=>{e instanceof Dt&&(e instanceof rn||e.nodeMaterialDispose())})}dispose(){this.disposeMaterial(),super.dispose()}};import{BufferGeometry as dA,Matrix4 as Tu,Vector3 as Ng,Vector4 as Ou}from"three";var Tg=new Ng,Og=new Ou,Ag=new Ou,uA=new Ng,Cg=new Tu,Xe=class extends Bt{constructor(e,t,o){super(e,t);this.data=t;this.localGeometry=void 0,t.bindMode&&t.bindMatrix&&(this.isSkinnedMesh=!0,this.bindMode=t.bindMode,this.bindMatrix=new Tu().fromArray(t.bindMatrix),this.bindMatrixInverse=new Tu)}chooseGeoemtryCache(e){return e.geometryCache}markGeometryAsReachable(e){this.geometryCreateDeleyed instanceof dA&&this.chooseGeoemtryCache(e).markAsReachable(this.dataPatched.geometry,this.geometryCreateDeleyed)}get geometry(){if(this.localGeometry!==void 0)return this.localGeometry;if(this.geometryCreateDeleyed instanceof sn){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 us.is2DParametricMesh(e.type)&&e.depth===0}get is2DType(){return us.is2DParametricMesh(this.geometry.userData.type)}get isNonParametric(){return this.geometry.userData.type==="NonParametricGeometry"}updateByPatchedOp(e,t,o){super.updateByPatchedOp(e,t,o),yt(e.path,["geometry"])&&this.updateByPatchedOpGeometry(dt.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 l={...this.data.geometry,...i};this.localGeometry=Yo(l,t,this.data.flatShading)}let s,a,c;i.scaleBaked?[s,a,c]=i.scaleBaked:{width:s,height:a,depth:c}=i;let u=this.localGeometry.userData;u.sxPrev!==void 0&&Is(this.localGeometry.attributes,s/u.sxPrev,a/u.syPrev,c/u.szPrev),u.sxPrev=s,u.syPrev=a,u.szPrev=c}else{let i={...this.data.geometry,...e};this.localGeometry?.dispose(),this.localGeometry=Yo(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&&os(["scaleBaked"],Object.keys(e.props))&&this.geometryCreateDeleyed instanceof We&&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):this.isNonParametric?(e.setScalar(0),this.geometry.boundingSphere&&e.copy(this.geometry.boundingSphere.center),t.set(o.width,o.height,o.depth??0).multiplyScalar(.5)):e.setScalar(0),t.set(o.width,o.height,o.depth??0).multiplyScalar(.5)}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode==="attached"?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode==="detached"&&this.bindMatrixInverse.copy(this.bindMatrix).invert()}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(e){let t=new Ou,o=this.geometry.attributes.skinWeight;for(let i=0,s=o.count;i<s;i++){t.fromBufferAttribute(o,i);let a=1/t.manhattanLength();a!==1/0?t.multiplyScalar(a):t.set(1,0,0,0),o.setXYZW(i,t.x,t.y,t.z,t.w)}}boneTransform(e,t){let o=this.skeleton;if(o===void 0)return;let i=this.geometry;Og.fromBufferAttribute(i.attributes.skinIndex,e),Ag.fromBufferAttribute(i.attributes.skinWeight,e),Tg.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let s=0;s<4;s++){let a=Ag.getComponent(s);if(a!==0){let c=Og.getComponent(s);Cg.multiplyMatrices(o.bones[c].matrixWorld,o.boneInverses[c]),t.addScaledVector(uA.copy(Tg).applyMatrix4(Cg),a)}}return t.applyMatrix4(this.bindMatrixInverse)}};function fA(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 a=`${t[s]}_${t[s+1]}_${t[s+2]}`,c=new Cu(o[s],o[s+1],o[s+2]);r.has(a)?r.get(a)?.normals.push(c):r.set(a,{normals:[c],result:new Cu})}r.forEach((s,a)=>{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 a=`${t[s]}_${t[s+1]}_${t[s+2]}`,c=r.get(a)?.result;c&&(i[s]=c.x,i[s+1]=c.y,i[s+2]=c.z)}n.geometry.setAttribute("extrudeNormal",new Ig(i,3))}function mA(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 Cu;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 Ig(t,3))}function ji(n){if(Array.isArray(n.material)){for(let r of n.material)if(r.getLayersOfType("outline").length===0)return}else if(!(n.material instanceof Dt)||n.material.getLayersOfType("outline").length===0)return;n instanceof Xe&&n.is2DAndNoDepth?mA(n):fA(n)}function Fi(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=[Au.seededRandom(o),Au.seededRandom(o+1e4),Au.seededRandom(o+2e4)];for(let s=0;s<e.length;s++)t[s]=i[s%3];n.geometry.setAttribute("randomColor",new pA(t,3))}var xA;hi.then(n=>{xA=n});var Br=new hA,Ws=new gA;function Eg(n){let r=!1;return n.scene.objects.traverse((e,t)=>{t.type==="Mesh"&&t.geometry.type==="SubdivGeometry"&&(r=!0)}),r}var an=class extends Xe{constructor(e,t,o){super(e,t,o);this.data=t;this.hiddenMatrixOld=new yA;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}=We.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,ji(this),Fi(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){We.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1,this.originalGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0),this.subdividedGeometry&&We.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1,this.subdividedGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0)}updateTopology(){this.originalGeometry.dispose(),this.originalGeometry=We.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=We.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,pt.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 Mg,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,o=e.boundingSphere.center;Br.setFromBufferAttribute(t),Br.getCenter(o),e.boundingSphere.radius=o.distanceTo(Br.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Br.getSize(Ws),this.hasNonUniformScale&&Ws.divide(this.scale);let i={width:Ws.x,height:Ws.y,depth:Ws.z};return this.geometry.userData.parameters=i,i}updateBoundingSphere(e){let t=this.originalGeometry;Br.min.set(e[0],e[2],e[4]),Br.max.set(e[1],e[3],e[5]),this.hasNonUniformScale&&(Br.min.applyMatrix4(this.shearScaleInv),Br.max.applyMatrix4(this.shearScaleInv)),t.boundingSphere===null&&(t.boundingSphere=new Mg);let o=t.boundingSphere.center;Br.getCenter(o),t.boundingSphere.radius=o.distanceTo(Br.max)}freeSubdivPointer(){this.subdivPointer&&(We.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)}};import{Triangle as vA,Vector3 as cn}from"three";var Lg=-1,bA=1,Dg={x:[1,0,0],"-x":[-1,0,0],y:[0,1,0],"-y":[0,-1,0],z:[0,0,1],"-z":[0,0,-1]},Bg={polygon_center:0,edge:1,vertex:2},qs=(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-Lg)*(e-t)/(bA-Lg)+t};function Rg(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 SA=new cn,ec=new cn,wA=new cn,_A=new cn;function ki(n,r){let e=wA.fromArray(n),t=_A.fromArray(r);ec.copy(t).sub(e);let o=ec.length();return ec.normalize().multiplyScalar(o*.5),SA.copy(e).add(ec).toArray()}var Kt=new vA,tc=new cn,rc=new cn,ln=new cn;function Gg(n){let r=[];for(let e=0;e<=n.index.count;e++)if(tc.fromArray(n.index.array,e*3),Kt.setFromAttributeAndIndices(n.attributes.position,tc.x,tc.y,tc.z),Kt.getNormal(rc),Kt.getMidpoint(ln),!(isNaN(ln.x)||isNaN(ln.y)||isNaN(ln.z))){let{a:t,b:o,c:i}=Kt,s=t.toArray(),a=o.toArray(),c=i.toArray(),u=t.distanceTo(o),l=o.distanceTo(i),d=i.distanceTo(t),p=ki(s,a),f=ki(a,c),m=ki(c,s),h=[u,l,d],y=Math.max(...h),g=h.filter(w=>Math.round(w)===Math.round(y)).length>1,x=[],b=Kt.getMidpoint(ln).toArray();y===u&&!g&&(x=[f,m,m],b=p),y===l&&!g&&(x=[p,m,m],b=f),y===d&&!g&&(x=[p,f,f],b=m),g&&(x=[p,f,m]),r.push({vertices:[s,a,c],faceCenters:x,midpoint:b,norm:Kt.getNormal(rc).toArray()})}return r}function Vg(n){let r=[],{position:e}=n.attributes;for(let t=0;t<e.count;t++){Kt.setFromAttributeAndIndices(e,t*3,t*3+1,t*3+2),Kt.getNormal(rc),Kt.getMidpoint(ln);let o=Kt.a.toArray(),i=Kt.b.toArray(),s=Kt.c.toArray();r.push({vertices:[o,i,s],faceCenters:[ki(o,i),ki(i,s),ki(s,o)],midpoint:ln.toArray(),norm:rc.toArray()})}return r}var PA=4,TA=.5,Nu=n=>.5*(1-Math.cos(n*Math.PI)),Iu=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),a=r-o,c=e-i,u=t-s,l,d,p=0,f=.5,m,h,y;for(let g=0;g<PA;g++){let x=o+(i<<4)+(s<<8);l=Nu(a),d=Nu(c),m=this.perlin[x&4095],m+=l*(this.perlin[x+1&4095]-m),h=this.perlin[x+16&4095],h+=l*(this.perlin[x+16+1&4095]-h),m+=d*(h-m),x+=256,h=this.perlin[x&4095],h+=l*(this.perlin[x+1&4095]-h),y=this.perlin[x+16&4095],y+=l*(this.perlin[x+16+1&4095]-y),h+=d*(y-h),m+=Nu(u)*(h-m),p+=m*f,f*=TA,o<<=1,a*=2,i<<=1,c*=2,s<<=1,u*=2,a>=1&&(o++,a--),c>=1&&(i++,c--),u>=1&&(s++,u--)}return p}noiseSeed(r){let e=(()=>{let s,a;return{setSeed(c){a=s=(c??Math.random()*4294967296)>>>0},getSeed(){return s},rand(){return a=(1664525*a+1013904223)%4294967296,a/4294967296}}})();e.setSeed(r),this.perlin=new Array(4095+1);for(let t=0;t<4095+1;t++)this.perlin[t]=e.rand()}},zg=Iu;import{Vector3 as OA,Matrix4 as AA,Ray as CA}from"three";var jg=new OA,Fg=new AA,kg=new CA;function Ug(n){let r=!1;return n.scene.objects.traverse((e,t)=>{t.type==="Mesh"&&t.geometry.type==="TextGeometry"&&(r=!0)}),r}var Ui=class extends Xe{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)&&(Fg.copy(o).invert(),kg.copy(e.ray).applyMatrix4(Fg),kg.intersectBox(this.singleBBox,jg))){let i=jg.applyMatrix4(o),s=e.ray.origin.distanceTo(i);t.push({distance:s,point:i.clone(),object:this})}}};var Tt=1e-4,Rr,$g,Yg,Xg,Wg=new Ht,qg=new Ht;hi.then(n=>{Rr=n,$g=[Rr.get_face_center,Rr.get_edge_midpoint,Rr.get_vertex_position],Yg=[Rr.get_face_normal,Rr.get_edge_normal,Rr.get_vertex_normal],Xg=[Rr.face_count,Rr.edge_count,Rr.vertex_count]});var IA=new un,MA=new un,Mo=new Ht,dn=new Ht,$s=new Ht,Eu=new Ht,EA=new Ht,LA=new Ht;var no=new zg,Wi=class extends Qn(NA){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"?Math.round(this.parameters.grid.count[0])*Math.round(this.parameters.grid.count[1])*Math.round(this.parameters.grid.count[2]):this.parameters.count,this.parameters.type==="toObject"&&!this.parameters.toObject.object&&(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 a=new Qr(this.object);a.expand(),this.add(a)}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*Hg.DEG2RAD,i=t.end*Hg.DEG2RAD,s=o-i,a=new Mu(t.rotation[0],t.rotation[1],t.rotation[2]),c;switch(t.axis){case"z":c=new Ht(0,0,1);break;case"y":c=new Ht(0,1,0);break;default:case"x":c=new Ht(1,0,0);break}let u=e.randomnessObject??_r.defaultData([1,1,1]).randomnessObject,l=u.noiseType==="perlin";no.noiseSeed(u.seed);let d=hl((0,Hi.default)(u.seed)),p=qs(u.strength,this.parameters.randomness);for(let[f,m]of this.children.entries()){let h=f*(u.freqScale/10)+u.movement,y=l?no.noise(h):d(h,h),g=f+1;m.scale.x=t.scale[0]+p(g,he(y,u.scale[0]))||Tt,m.scale.y=t.scale[1]+p(g,he(y,u.scale[1]))||Tt,m.scale.z=t.scale[2]+p(g,he(y,u.scale[2]))||Tt,m.position.setScalar(0);let x=s/e.count*f-o;switch(t.axis){case"x":m.rotation.set(0,x,0);break;case"y":m.rotation.set(0,0,x);break;case"z":m.rotation.set(x,0,0);break}m.translateOnAxis(c,t.radius),m.position.x+=t.position[0]+p(g,he(y,u.position[0])),m.position.y+=t.position[1]+p(g,he(y,u.position[1])),m.position.z+=t.position[2]+p(g,he(y,u.position[2]));let b=p(g,he(y,u.rotation[0])),w=p(g,he(y,u.rotation[1])),S=p(g,he(y,u.rotation[2]));t.alignment===!0?(m.rotation.x+=a.x+b,m.rotation.y+=a.y+w,m.rotation.z+=a.z+S):m.rotation.set(a.x+b,a.y+w,a.z+S)}}_updateLinear(e){if(e.type!=="linear")throw new Error;let t=e.linear,o=new Mu(t.rotation[0],t.rotation[1],t.rotation[2]),i=e.randomnessObject??_r.defaultData([1,1,1]).randomnessObject,s=i.noiseType==="perlin";no.noiseSeed(i.seed);let a=hl((0,Hi.default)(i.seed)),c=qs(i.strength,this.parameters.randomness);for(let[u,l]of this.children.entries()){let d=u*(i.freqScale/10)+i.movement,p=s?no.noise(d):a(d,d),f=u+1,m=c(f,he(p,i.rotation[0])),h=c(f,he(p,i.rotation[1])),y=c(f,he(p,i.rotation[2]));l.scale.x=1+(t.scale[0]-1)*u+c(f,he(p,i.scale[0]))||Tt,l.scale.y=1+(t.scale[1]-1)*u+c(f,he(p,i.scale[1]))||Tt,l.scale.z=1+(t.scale[2]-1)*u+c(f,he(p,i.scale[2]))||Tt,l.rotation.x=o.x*u+m,l.rotation.y=o.y*u+h,l.rotation.z=o.z*u+y,l.position.x=t.position[0]*u+c(f,he(p,i.position[0])),l.position.y=t.position[1]*u+c(f,he(p,i.position[1])),l.position.z=t.position[2]*u+c(f,he(p,i.position[2]))}}_updateGrid(e){let t=0,o=e.grid,i=e.randomnessObject??_r.defaultData([1,1,1]).randomnessObject,s=qs(i.strength,this.parameters.randomness),a=i.noiseType==="perlin";no.noiseSeed(i.seed);let c=wh((0,Hi.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},l=new Ht(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=a?no.noise(...m):c(...m),y=this.children[t++];y.scale.x=1+s(t,he(h,i.scale[0]))||Tt,y.scale.y=1+s(t,he(h,i.scale[1]))||Tt,y.scale.z=1+s(t,he(h,i.scale[2]))||Tt;let g=s(t,he(h,i.rotation[0])),x=s(t,he(h,i.rotation[1])),b=s(t,he(h,i.rotation[2]));y.rotation.set(g,x,b),y.position.x=o.size[0]*d-l.x+s(t,he(h,i.position[0])),y.position.y=o.size[1]*p-l.y+s(t,he(h,i.position[1])),y.position.z=o.size[2]*f-l.z+s(t,he(h,i.position[2]))}}else for(let u=0;u<o.count[0];u++)for(let l=0;l<o.count[1];l++)for(let d=0;d<o.count[2];d++){let p=[(u+1)*(i.freqScale/10)+i.movement,(l+1)*(i.freqScale/10)+i.movement,(d+1)*(i.freqScale/10)+i.movement],f=a?no.noise(...p):c(...p),m=this.children[t++];m.scale.x=1+s(t,he(f,i.scale[0]))||Tt,m.scale.y=1+s(t,he(f,i.scale[1]))||Tt,m.scale.z=1+s(t,he(f,i.scale[2]))||Tt;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]*l+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 Mu(t.rotation[0],t.rotation[1],t.rotation[2]),i=e.randomnessObject??_r.defaultData([1,1,1]).randomnessObject,s=i.noiseType==="perlin";no.noiseSeed(i.seed);let a=hl((0,Hi.default)(i.seed)),c=qs(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 Ui)if(!this.objectForSample.font?.isLoaded||this.objectForSample.geometry.attributes.position===void 0){this._pendingMediaLoad=!0;return}else this._pendingMediaLoad=!1;if(this.objectForSample.geometry===void 0&&this.objectForSample.isAncestorOf(this.object.uuid)){console.warn(`Oh no! The object "${this.object.name}" (${this.object.uuid}) seem to be a child/descendant of the object it's being cloned to. Please re-parent it so that they are siblings instead.`);return}let u=this.getSubdivData(),l=[],d=g=>{let x=g.length,b=g.map(P=>P[0]).reduce((P,_)=>P+_,0),w=g.map(P=>P[1]).reduce((P,_)=>P+_,0),S=g.map(P=>P[2]).reduce((P,_)=>P+_,0);return[b/x,w/x,S/x]},p=g=>Math.round(g*1e6)/1e6;u.forEach(g=>{let x=u.filter(b=>p(g.pos[0])===p(b.pos[0])&&p(g.pos[1])===p(b.pos[1])&&p(g.pos[2])===p(b.pos[2]));x.length>1?l.push({pos:g.pos,norm:d(x.map(b=>b.norm))}):l.push(g)});let f=Rg(l);if(u.length>0){let g=Math.round(f.length*t.count/100);this._updateCount(g)}this.objectForSample.updateMatrixWorld();let m=new yl(this.objectForSample).build(),h=Dg[t.axis],y=this.children;m.setRandomGenerator((0,Hi.default)(this.object.uuid+t.seed));for(let[g,x]of y.entries()){let b=g*(i.freqScale/10)+i.movement,w=s?no.noise(b):a(b,b),S=g+1,P=c(S,he(w,i.rotation[0])),_=c(S,he(w,i.rotation[1])),v=c(S,he(w,i.rotation[2]));t.spreadType==="random"?m.sample($s,Eu):(f.length&&($s.fromArray(f[g].pos),Eu.fromArray(f[g].norm)),this.objectForSample instanceof an&&$s.applyMatrix4(IA.copy(this.objectForSample.matrixWorld).invert())),$s.applyMatrix4(this.object.hiddenMatrix.clone().invert()),x.position.copy($s),Mo.fromArray(h);let N=t.align==="normal"?Eu:this.object.getWorldDirection(LA),T=dn.fromArray(t.position);dn.x+=dn.x+c(S,he(w,i.position[0])),dn.y+=dn.y+c(S,he(w,i.position[1])),dn.z+=dn.z+c(S,he(w,i.position[2]));let C=Math.acos(N.dot(Mo)),O=EA.crossVectors(Mo,N).normalize(),A=MA.makeRotationAxis(O,C),R=N.clone().cross(this.object.up).normalize(),U=R.clone().cross(N).normalize(),$=new un().makeBasis(R,N,U),ee=new Ht(Mo.y,Mo.z,Mo.x).normalize(),Y=ee.clone().cross(Mo).normalize(),q=new un().makeBasis(ee,Mo,Y).invert(),H=new un().multiplyMatrices($,q);x.rotation.setFromRotationMatrix(H),T.applyMatrix4(A),x.position.add(T),x.rotation.x=x.rotation.x+o.x+P,x.rotation.y=x.rotation.y+o.y+_,x.rotation.z=x.rotation.z+o.z+v,x.scale.setScalar(1),x.scale.x=x.scale.x+t.scale[0]+c(S,he(w,i.scale[0]))||Tt,x.scale.y=x.scale.y+t.scale[1]+c(S,he(w,i.scale[1]))||Tt,x.scale.z=x.scale.z+t.scale[2]+c(S,he(w,i.scale[2]))||Tt,x.scale.multiply(this.object.scale),x.hiddenMatrix=this.object.hiddenMatrix}}getSubdivData(){if(!this.objectForSample)return[];let e=this.parameters.toObject.spreadType;if(e==="random")return[];if(this.objectForSample instanceof an){let t=this.objectForSample,o=Bg[e],i=Xg[o],s=$g[o],a=Yg[o],c=[],u=i(t.subdivPointerNew);for(let l=0;l<=u-1;l++){let d=s(t.subdivPointerNew,l),p=a(t.subdivPointerNew,l);Wg.fromArray(d).applyMatrix4(t.matrixWorld),qg.fromArray(p),c.push({pos:Wg.toArray(),norm:qg.toArray()})}return c}else return(this.objectForSample.geometry.index?Gg(this.objectForSample.geometry):Vg(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=$r(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 pt?this.objectForSample=o:this.objectForSample=void 0,this.matrix=new un,this.hiddenMatrix=new un,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1,o&&o.add(this)}this.update()}get pendingMediaLoad(){return this._pendingMediaLoad}};import{Scene as BC,Vector3 as RC,Matrix4 as GC,Box3 as VC,MeshBasicMaterial as zC,Skeleton as jC}from"three";import{Camera as WA,OrthographicCamera as qA,PerspectiveCamera as $A,Vector3 as mr,Object3D as Jg,Quaternion as YA,Matrix4 as XA}from"three";import{Camera as zA,LineSegments as jA,BufferGeometry as FA,LineBasicMaterial as kA,Color as Du,Vector3 as UA,Float32BufferAttribute as Zg}from"three";import{BoxGeometry as DA}from"three";var Gr=n=>{var r;return r=class extends n{},r.geometryHelper=new DA(30,30,30),r};import{Ray as BA,Sphere as RA,Matrix4 as GA,Vector3 as io}from"three";var oc=new BA,Lu=new RA,Kg=new GA,Vr=(n,r,e,t,o=!1)=>{let i=r,s=n.matrixWorld;if(i.boundingSphere===null&&i.computeBoundingSphere(),Lu.copy(i.boundingSphere),Lu.applyMatrix4(s),e.ray.intersectsSphere(Lu)===!1||(Kg.copy(s).invert(),oc.copy(e.ray).applyMatrix4(Kg),i.boundingBox!==null&&oc.intersectsBox(i.boundingBox)===!1))return;let a,c,u,l,d=i.index,p=i.attributes.position,f=i.drawRange,m,h;if(o===!1){let g=Math.max(0,f.start),x=Math.min(d.count,f.start+f.count);for(m=g,h=x;m<h;m+=3)if(c=d.getX(m),u=d.getX(m+1),l=d.getX(m+2),a=y(n,e,oc,p,c,u,l),a){a.faceIndex=Math.floor(m/3),t.push(a);return}}else{let x=i.attributes.position,b=new io,w=new io,S=new io,P=new io,_=2,N=1/((n.scale.x+n.scale.y+n.scale.z)/3),T=N*N,C=Math.max(0,f.start),O=Math.min(x.count,f.start+f.count);for(let A=C,R=O-1;A<R;A+=_){if(b.fromBufferAttribute(x,A),w.fromBufferAttribute(x,A+1),oc.distanceSqToSegment(b,w,P,S)>T)continue;P.applyMatrix4(n.matrixWorld);let $=e.ray.origin.distanceTo(P);$<e.near||$>e.far||t.push({distance:$,point:S.clone().applyMatrix4(n.matrixWorld),object:n})}}function y(g,x,b,w,S,P,_){let v=new io,N=new io,T=new io,C=new io,O=new io;if(v.fromBufferAttribute(w,S),N.fromBufferAttribute(w,P),T.fromBufferAttribute(w,_),b.intersectTriangle(v,N,T,!1,C)===null)return null;O.copy(C),O.applyMatrix4(g.matrixWorld);let R=x.ray.origin.distanceTo(O);return R<x.near||R>x.far?null:{faceIndex:1,distance:R,point:O.clone(),object:g}}};var nc=new UA,Zt=new zA,Bu=class extends jA{constructor(e){let t=new FA,o=new kA({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],s=[],a={},c=new Du(15711266),u=new Du(15711266),l=new Du(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",l),d("u2","u3",l),d("u3","u1",l);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),a[f]===void 0&&(a[f]=[]),a[f].push(i.length/3-1)}t.setAttribute("position",new Zg(i,3)),t.setAttribute("color",new Zg(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=a,this.update()}update(){let e=this.geometry,t=this.pointMap,o=!0;Zt.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let i=1,s=1,a=o?.8:1e-4;fr("n1",t,e,Zt,-i,-s,a),fr("n2",t,e,Zt,i,-s,a),fr("n3",t,e,Zt,-i,s,a),fr("n4",t,e,Zt,i,s,a);let c=a;fr("f1",t,e,Zt,-i,-s,c),fr("f2",t,e,Zt,i,-s,c),fr("f3",t,e,Zt,-i,s,c),fr("f4",t,e,Zt,i,s,c);let u=c,l=.5;fr("u1",t,e,Zt,i*.7*l,s*1.1,u),fr("u2",t,e,Zt,-i*.7*l,s*1.1,u),fr("u3",t,e,Zt,0,s*(1.1+.9*l),u),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function fr(n,r,e,t,o,i,s){nc.set(o,i,s).unproject(t);let a=r[n];if(a!==void 0){let c=e.getAttribute("position");for(let u=0,l=a.length;u<l;u++)c.setXYZ(a[u],nc.x,nc.y,nc.z)}}var ic=class extends Gr(Bu){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){Vr(this.object,this.geometry,e,t,!0)}};import{Box3Helper as Qg,BoxGeometry as HA}from"three";var sc;(r=>r.is=e=>"objectHelper"in e)(sc||(sc={}));var zr=(n,r)=>class extends ti(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 Qg&&(i.visible=!0)}}updateEntityBoxSize(o,i){this.objectHelper.visible&&this.geometryHelper instanceof HA?(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 Qg&&(i.visible=!1)}}};var ac=790,qi=new mr,Ru=new mr,Gu=new YA,Vu=new mr,Ys=new mr,zu=new mr,jr=class extends zr(WA,ic){constructor(e="",t={...ko.defaultData,name:""}){super();this._cameraType="OrthographicCamera";this.targetOffset=bo.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.wasMovedByUser=!1;this.wasMovedBySwitchCameraAction=!1;this.super_Entity(e,t),this.previousProjectionMatrix=new XA,this.matrixAutoUpdate=!0,this.width=window.innerWidth,this.height=window.innerHeight;let o=this.width,i=this.height;this.orthoCamera=new qA(o*-.5,o*.5,i*.5,i*-.5,-5e4,1e4),this.perspCamera=new $A(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 mr(e,t,o)),super.lookAt(e),this.getWorldPosition(qi),this.targetOffset=qi.distanceTo(e)}getTarget(e=new mr){return this.getWorldDirection(Ru),this.getWorldPosition(qi),Ru.multiplyScalar(this.targetOffset),e.copy(qi).add(Ru),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(qi),qi.distanceTo(e)}updateUp(){this.getWorldQuaternion(Gu),Vu.set(0,0,1).applyQuaternion(Gu),Ys.copy(Jg.DEFAULT_UP),this.isUpVectorFlipped&&Ys.negate(),Ys.applyQuaternion(Gu),zu.copy(Jg.DEFAULT_UP).projectOnPlane(Vu),this.angleOffsetFromUp=zu.angleTo(Ys),this.angleOffsetFromUp*=zu.cross(Ys).dot(Vu)>=0?1:-1}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 mr),i=e.getWorldDirection(new mr).multiplyScalar(this.targetOffset);return{position:t.clone().add(i),target:t}}getViewToTarget(e){let o=this.getWorldDirection(new mr).multiplyScalar(this.targetOffset);return{position:e.clone().sub(o),target:e}}getViewToObject(e){let t=new mr,o=e.getWorldPosition(t);return this.getViewToTarget(t)}setViewplaneSize(e,t,o=!1){if(this.aspect=e/t,o){let i=e>t?this.aspect:1,s=e>t?1:this.aspect;this.left=-ac*.5*i,this.right=ac*.5*i,this.top=ac*.5*(1/s),this.bottom=-ac*.5*(1/s)}else this.left=-e*.5,this.right=e*.5,this.top=t*.5,this.bottom=-t*.5;this.updateProjectionMatrix()}copyViewPlaneSize(e){this.aspect=e.aspect,this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.updateProjectionMatrix()}toOrthographic(){this.orthoCamera.left=this.left,this.orthoCamera.right=this.right,this.orthoCamera.top=this.top,this.orthoCamera.bottom=this.bottom,this.orthoCamera.view=this.view,this.orthoCamera.far=this.far,this.orthoCamera.updateProjectionMatrix(),this.projectionMatrix=this.orthoCamera.projectionMatrix,this.projectionMatrixInverse=this.orthoCamera.projectionMatrixInverse,this._cameraType="OrthographicCamera",this.objectHelper&&this.objectHelper.update()}toPerspective(){this.perspCamera.aspect=this.aspect,this.perspCamera.fov=this.fov,this.perspCamera.view=this.view,this.perspCamera.far=this.far,this.perspCamera.updateProjectionMatrix(),this.projectionMatrix=this.perspCamera.projectionMatrix,this.projectionMatrixInverse=this.perspCamera.projectionMatrixInverse,this._cameraType="PerspectiveCamera",this.objectHelper&&this.objectHelper.update()}setFocalLength(e){this.perspCamera.setFocalLength(e),this.toPerspective()}getFocalLength(){return this.perspCamera.getFocalLength()}getEffectiveFOV(){return this.perspCamera.getEffectiveFOV()}getFilmWidth(){return this.perspCamera.getFilmWidth()}getFilmHeight(){return this.perspCamera.getFilmHeight()}setViewOffset(e,t,o,i,s,a){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(e,t,o,i,s,a):this.orthoCamera.setViewOffset(e,t,o,i,s,a)}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}copyHistory(){this.previousProjectionMatrix&&this.previousProjectionMatrix.copy(this.projectionMatrix)}updateProjectionMatrix(){this._cameraType==="PerspectiveCamera"?this.toPerspective():this._cameraType==="OrthographicCamera"&&this.toOrthographic()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(e,t){return super.copy(e,t),this.parent=e.parent,this.orthoCamera.copy(e.orthoCamera),this.perspCamera.copy(e.perspCamera),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.far=e.far,this.view=e.view===null?null:Object.assign({},e.view),this._cameraType=e._cameraType,this.aspect=e.aspect,this.fov=e.fov,this.focus=e.focus,this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this.targetOffset=e.targetOffset,this.updateProjectionMatrix(),this}toCameraState(e=[]){let t={type:this.cameraType,far:this.far,orthographic:{near:this.orthoCamera.near,zoom:this.orthoCamera.zoom},perspective:{near:this.perspCamera.near,fov:this.perspCamera.fov,zoom:this.perspCamera.zoom},up:this.up.toArray(),targetOffset:this.targetOffset,isUpVectorFlipped:this.isUpVectorFlipped};return Dn(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}}};import{BufferGeometry as e0,Matrix4 as t0,Float32BufferAttribute as KA}from"three";var $i=new t0,ZA=new t0;var Qt=class extends Bt{constructor(e,t,o){super(e,t);this.data=t;this.meshSetAddresses=[];this.needsTransformForDownstream=!1;this.geometry=new e0;this.onAfterRender=(e,t,o,i,s,a)=>{super.onAfterRender(e,t,o,i,s,a),this.recomputeBoolean()};this.geometry.userData.parameters={width:0,height:0,depth:0}}get booleanOp(){return this.data.geometry.operation}get phongAngle(){return this.data.geometry.phongAngle??45}get isLOD(){return this.recomputeBoolean(),!1}updateByPatchedOp(e,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 Qt&&s.recomputeBoolean(e===!0,t)}this.meshSetAddresses=[];for(let i=0;i<this.children.length;i++){let s=this.children[i];if(s instanceof pt&&s.dataPatched.visible===!0&&s.geometry.attributes.position?.count>0&&s.geometry.drawRange.count>0){if($i.multiplyMatrices(s.hiddenMatrix,s.matrix),s.booleanMeshSetAddress===-1){if((s.geometry.index??s.geometry.getAttribute("position")).count/3<15e5&&(s.booleanMeshSetAddress=ar.getMeshSet(s.geometry,e===!0,t)),s.booleanMeshSetAddress===-1)return;ar.transformMeshSet(s.booleanMeshSetAddress,$i),s.booleanMatrixInvOld.copy($i).invert(),s.booleanWasTransformed=!1}else s instanceof Qt&&s.needsTransformForDownstream===!0?(ar.transformMeshSet(s.booleanMeshSetAddress,$i),s.needsTransformForDownstream=!1):s.booleanWasTransformed===!0&&(ar.transformMeshSet(s.booleanMeshSetAddress,ZA.multiplyMatrices($i,s.booleanMatrixInvOld)),s.booleanMatrixInvOld.copy($i).invert(),s.booleanWasTransformed=!1);this.meshSetAddresses.push(s.booleanMeshSetAddress)}}if(this.meshSetAddresses.length===0){this.geometry.setAttribute("position",new KA([],0)),this.geometry.setDrawRange(0,0);return}if(e===!0)return ar.calcBooleanTopological(this.meshSetAddresses,this.booleanOp);let o=this.geometry;o.dispose(),this.geometry=new e0,this.geometry.userData=o.userData,this.geometry.boundingSphere=o.boundingSphere;try{this.booleanMeshSetAddress=ar.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,ji(this),Fi(this)}dispose(){super.dispose(),this.geometry.dispose()}};import{Light as QA}from"three";var r0;(r=>{function n(e){return Se.is(e)&&e instanceof QA}r.is=n})(r0||(r0={}));var Yi=(n,r)=>class extends zr(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 Eo=n=>n instanceof pt,Xs=n=>n!==null&&n instanceof Qt,o0=n=>n instanceof jr;var Ks=n=>sc.is(n);import{Group as eC}from"three";import{AxesHelper as JA}from"three";var Fr=class extends Gr(JA){constructor(e,t=15){super(t);this.object=e;this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${e.uuid}`,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.object.isBone&&(this.visible=!1)}raycast(e,t){Vr(this.object,Fr.geometryHelper,e,t)}update(){}};var Zs=class extends zr(eC,Fr){constructor(r,e){super(),this.super_Entity(r,e),this.objectHelper.update()}updateState(r,e){this.updateState_Entity(r,e)}};import{Color as mC,Fog as hC,HemisphereLight as yC}from"three";import{ShaderChunk as Qs}from"three";var tC=n=>`
|
|
2213
|
+
|
|
2214
|
+
// PCSS implementation based on:
|
|
2215
|
+
// https://www.gamedev.net/articles/programming/graphics/contact-hardening-soft-shadows-made-fast-r4906/
|
|
2216
|
+
// NOTE: This number affects how big the shadow blur can
|
|
2217
|
+
// possibly get. Bigger number == bigger blur, but less precise results
|
|
2218
|
+
|
|
2219
|
+
const float gPenumbraFilterSize = 80.0;
|
|
2220
|
+
const int gPenumbraSamples = ${n};
|
|
2221
|
+
const int gShadowSamples = ${n};
|
|
2222
|
+
const float gShadowSamplesRpc = 1.0f / float(gShadowSamples);
|
|
2223
|
+
|
|
2224
|
+
#ifdef USE_SHADOWMAP
|
|
2225
|
+
#if NUM_DIR_LIGHT_SHADOWS > 0
|
|
2226
|
+
|
|
2227
|
+
uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
|
|
2228
|
+
varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
|
|
2229
|
+
|
|
2230
|
+
struct DirectionalLightShadow {
|
|
2231
|
+
float shadowBias;
|
|
2232
|
+
float shadowNormalBias;
|
|
2233
|
+
float shadowRadius;
|
|
2234
|
+
vec2 shadowMapSize;
|
|
2235
|
+
};
|
|
2236
|
+
|
|
2237
|
+
uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
|
|
2238
|
+
|
|
2239
|
+
#endif
|
|
2240
|
+
|
|
2241
|
+
#if NUM_SPOT_LIGHT_SHADOWS > 0
|
|
2242
|
+
|
|
2243
|
+
uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
|
|
2244
|
+
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_SHADOWS ];
|
|
2245
|
+
|
|
2246
|
+
struct SpotLightShadow {
|
|
2247
|
+
float shadowBias;
|
|
2248
|
+
float shadowNormalBias;
|
|
2249
|
+
float shadowRadius;
|
|
2250
|
+
vec2 shadowMapSize;
|
|
2251
|
+
};
|
|
2252
|
+
|
|
2253
|
+
uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
|
|
2254
|
+
|
|
2255
|
+
#endif
|
|
2256
|
+
|
|
2257
|
+
#if NUM_POINT_LIGHT_SHADOWS > 0
|
|
2258
|
+
|
|
2259
|
+
uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
|
|
2260
|
+
varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
|
|
2261
|
+
|
|
2262
|
+
struct PointLightShadow {
|
|
2263
|
+
float shadowBias;
|
|
2264
|
+
float shadowNormalBias;
|
|
2265
|
+
float shadowRadius;
|
|
2266
|
+
vec2 shadowMapSize;
|
|
2267
|
+
float shadowCameraNear;
|
|
2268
|
+
float shadowCameraFar;
|
|
2269
|
+
};
|
|
2270
|
+
|
|
2271
|
+
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
|
|
2272
|
+
|
|
2273
|
+
#endif
|
|
2274
|
+
|
|
2275
|
+
/*
|
|
2276
|
+
#if NUM_RECT_AREA_LIGHTS > 0
|
|
2277
|
+
|
|
2278
|
+
// TODO (abelnation): create uniforms for area light shadows
|
|
2279
|
+
|
|
2280
|
+
#endif
|
|
2281
|
+
*/
|
|
2282
|
+
|
|
2283
|
+
float computePenumbra(int index, sampler2D shadowMap, float temporalAngle, float texelSize, vec2 uv, float compare, float texelScalar, float shadowRadius)
|
|
2284
|
+
{
|
|
2285
|
+
float penumbra = 1.0;
|
|
2286
|
+
float blockerDepthAvg = 0.0;
|
|
2287
|
+
float blockerCount = 0.0;
|
|
2288
|
+
|
|
2289
|
+
#pragma unroll_loop_start
|
|
2290
|
+
for(int i = 0; i < gPenumbraSamples; i ++)
|
|
2291
|
+
{
|
|
2292
|
+
vec2 offset = (vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize) * texelScalar;
|
|
2293
|
+
float depth = unpackRGBAToDepth( texture2D( shadowMap, uv + offset ) );
|
|
2294
|
+
|
|
2295
|
+
if(depth < compare + 0.0001)
|
|
2296
|
+
{
|
|
2297
|
+
blockerDepthAvg += depth;
|
|
2298
|
+
blockerCount++;
|
|
2299
|
+
}
|
|
2300
|
+
}
|
|
2301
|
+
#pragma unroll_loop_end
|
|
2302
|
+
|
|
2303
|
+
if (blockerCount > 0.0)
|
|
2304
|
+
{
|
|
2305
|
+
blockerDepthAvg /= blockerCount;
|
|
2306
|
+
|
|
2307
|
+
// Compute penumbra
|
|
2308
|
+
penumbra = (compare - blockerDepthAvg) / (blockerDepthAvg);
|
|
2309
|
+
penumbra *= penumbra;
|
|
2310
|
+
penumbra *= 200.0 * penumbraSize[min(index, ${5} - 1)]; // Magic number that affects how quickly the penumbra grows
|
|
2311
|
+
|
|
2312
|
+
return clamp(penumbra, 0.00, 1.0);
|
|
2313
|
+
}
|
|
2314
|
+
return 0.0;
|
|
2315
|
+
}
|
|
2316
|
+
|
|
2317
|
+
float vogelShadow(int index, sampler2D shadowMap, vec2 uv, float texelSize, float compare, float shadowRadius)
|
|
2318
|
+
{
|
|
2319
|
+
float shadow = 0.0f;
|
|
2320
|
+
|
|
2321
|
+
// NOTE: When using TAA, we should use screen space interleaved gradient noise
|
|
2322
|
+
vec2 halton = haltonSequence[frameIndex];
|
|
2323
|
+
float temporalOffset = getNoiseInterleavedGradient(gl_FragCoord.xy + halton);
|
|
2324
|
+
float temporalAngle = temporalOffset * PI2;
|
|
2325
|
+
|
|
2326
|
+
float texelScalar = (gPenumbraFilterSize) / (texelSize * 1024.);
|
|
2327
|
+
float penumbra = computePenumbra(index, shadowMap, temporalAngle, texelSize, uv, compare, texelScalar, shadowRadius);
|
|
2328
|
+
if (penumbra == -1.0) {
|
|
2329
|
+
return 1.0;
|
|
2330
|
+
}
|
|
2331
|
+
|
|
2332
|
+
#pragma unroll_loop_start
|
|
2333
|
+
for (int i = 0; i < gShadowSamples; i++)
|
|
2334
|
+
{
|
|
2335
|
+
vec2 vogelSample = vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize;
|
|
2336
|
+
// Overall blurring offset
|
|
2337
|
+
vec2 offset = vogelSample * (shadowRadius * 2.);
|
|
2338
|
+
|
|
2339
|
+
// Penumbra offset
|
|
2340
|
+
offset += vogelSample * (penumbra * texelScalar);
|
|
2341
|
+
|
|
2342
|
+
shadow += step( compare, unpackRGBAToDepth( texture2D( shadowMap, uv + offset ) ) );
|
|
2343
|
+
}
|
|
2344
|
+
#pragma unroll_loop_end
|
|
2345
|
+
|
|
2346
|
+
return shadow * gShadowSamplesRpc;
|
|
2347
|
+
}
|
|
2348
|
+
|
|
2349
|
+
|
|
2350
|
+
float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
|
|
2351
|
+
|
|
2352
|
+
return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
|
|
2353
|
+
|
|
2354
|
+
}
|
|
2355
|
+
|
|
2356
|
+
vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
|
|
2357
|
+
|
|
2358
|
+
return unpackRGBATo2Half( texture2D( shadow, uv ) );
|
|
2359
|
+
|
|
2360
|
+
}
|
|
2361
|
+
|
|
2362
|
+
float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
|
|
2363
|
+
|
|
2364
|
+
float occlusion = 1.0;
|
|
2365
|
+
|
|
2366
|
+
vec2 distribution = texture2DDistribution( shadow, uv );
|
|
2367
|
+
|
|
2368
|
+
float hard_shadow = step( compare , distribution.x ); // Hard Shadow
|
|
2369
|
+
|
|
2370
|
+
if (hard_shadow != 1.0 ) {
|
|
2371
|
+
|
|
2372
|
+
float distance = compare - distribution.x ;
|
|
2373
|
+
float variance = max( 0.00000, distribution.y * distribution.y );
|
|
2374
|
+
float softness_probability = variance / (variance + distance * distance ); // Chebeyshevs inequality
|
|
2375
|
+
softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); // 0.3 reduces light bleed
|
|
2376
|
+
occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
|
|
2377
|
+
|
|
2378
|
+
}
|
|
2379
|
+
return occlusion;
|
|
2380
|
+
|
|
2381
|
+
}
|
|
2382
|
+
|
|
2383
|
+
float getShadow( int i, sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
|
|
2384
|
+
|
|
2385
|
+
float shadow = 1.0;
|
|
2386
|
+
|
|
2387
|
+
shadowCoord.xyz /= shadowCoord.w;
|
|
2388
|
+
shadowCoord.z += shadowBias;
|
|
2389
|
+
|
|
2390
|
+
// if ( something && something ) breaks ATI OpenGL shader compiler
|
|
2391
|
+
// if ( all( something, something ) ) using this instead
|
|
2392
|
+
|
|
2393
|
+
bvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );
|
|
2394
|
+
bool inFrustum = all( inFrustumVec );
|
|
2395
|
+
|
|
2396
|
+
bvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );
|
|
2397
|
+
|
|
2398
|
+
bool frustumTest = all( frustumTestVec );
|
|
2399
|
+
|
|
2400
|
+
if ( frustumTest ) {
|
|
2401
|
+
|
|
2402
|
+
#if defined( SHADOWMAP_TYPE_PCF )
|
|
2403
|
+
|
|
2404
|
+
vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
|
|
2405
|
+
return vogelShadow(i, shadowMap, shadowCoord.xy, texelSize.x, shadowCoord.z, shadowRadius );
|
|
2406
|
+
|
|
2407
|
+
#elif defined( SHADOWMAP_TYPE_PCF_SOFT )
|
|
2408
|
+
|
|
2409
|
+
vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
|
|
2410
|
+
float dx = texelSize.x;
|
|
2411
|
+
float dy = texelSize.y;
|
|
2412
|
+
|
|
2413
|
+
vec2 uv = shadowCoord.xy;
|
|
2414
|
+
vec2 f = fract( uv * shadowMapSize + 0.5 );
|
|
2415
|
+
uv -= f * texelSize;
|
|
2416
|
+
|
|
2417
|
+
shadow = (
|
|
2418
|
+
texture2DCompare( shadowMap, uv, shadowCoord.z ) +
|
|
2419
|
+
texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
|
|
2420
|
+
texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
|
|
2421
|
+
texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
|
|
2422
|
+
mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
|
|
2423
|
+
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
|
|
2424
|
+
f.x ) +
|
|
2425
|
+
mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
|
|
2426
|
+
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
|
|
2427
|
+
f.x ) +
|
|
2428
|
+
mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
|
|
2429
|
+
texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
|
|
2430
|
+
f.y ) +
|
|
2431
|
+
mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
|
|
2432
|
+
texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
|
|
2433
|
+
f.y ) +
|
|
2434
|
+
mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
|
|
2435
|
+
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
|
|
2436
|
+
f.x ),
|
|
2437
|
+
mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
|
|
2438
|
+
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
|
|
2439
|
+
f.x ),
|
|
2440
|
+
f.y )
|
|
2441
|
+
) * ( 1.0 / 9.0 );
|
|
2442
|
+
|
|
2443
|
+
#elif defined( SHADOWMAP_TYPE_VSM )
|
|
2444
|
+
|
|
2445
|
+
shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
|
|
2446
|
+
|
|
2447
|
+
#else // no percentage-closer filtering:
|
|
2448
|
+
|
|
2449
|
+
shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
|
|
2450
|
+
|
|
2451
|
+
#endif
|
|
2452
|
+
|
|
2453
|
+
}
|
|
2454
|
+
|
|
2455
|
+
return shadow;
|
|
2456
|
+
|
|
2457
|
+
}
|
|
2458
|
+
|
|
2459
|
+
// cubeToUV() maps a 3D direction vector suitable for cube texture mapping to a 2D
|
|
2460
|
+
// vector suitable for 2D texture mapping. This code uses the following layout for the
|
|
2461
|
+
// 2D texture:
|
|
2462
|
+
//
|
|
2463
|
+
// xzXZ
|
|
2464
|
+
// y Y
|
|
2465
|
+
//
|
|
2466
|
+
// Y - Positive y direction
|
|
2467
|
+
// y - Negative y direction
|
|
2468
|
+
// X - Positive x direction
|
|
2469
|
+
// x - Negative x direction
|
|
2470
|
+
// Z - Positive z direction
|
|
2471
|
+
// z - Negative z direction
|
|
2472
|
+
//
|
|
2473
|
+
// Source and test bed:
|
|
2474
|
+
// https://gist.github.com/tschw/da10c43c467ce8afd0c4
|
|
2475
|
+
|
|
2476
|
+
vec2 cubeToUV( vec3 v, float texelSizeY ) {
|
|
2477
|
+
|
|
2478
|
+
// Number of texels to avoid at the edge of each square
|
|
2479
|
+
|
|
2480
|
+
vec3 absV = abs( v );
|
|
2481
|
+
|
|
2482
|
+
// Intersect unit cube
|
|
2483
|
+
|
|
2484
|
+
float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
|
|
2485
|
+
absV *= scaleToCube;
|
|
2486
|
+
|
|
2487
|
+
// Apply scale to avoid seams
|
|
2488
|
+
|
|
2489
|
+
// two texels less per square (one texel will do for NEAREST)
|
|
2490
|
+
v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
|
|
2491
|
+
|
|
2492
|
+
// Unwrap
|
|
2493
|
+
|
|
2494
|
+
// space: -1 ... 1 range for each square
|
|
2495
|
+
//
|
|
2496
|
+
// #X## dim := ( 4 , 2 )
|
|
2497
|
+
// # # center := ( 1 , 1 )
|
|
2498
|
+
|
|
2499
|
+
vec2 planar = v.xy;
|
|
2500
|
+
|
|
2501
|
+
float almostATexel = 1.5 * texelSizeY;
|
|
2502
|
+
float almostOne = 1.0 - almostATexel;
|
|
2503
|
+
|
|
2504
|
+
if ( absV.z >= almostOne ) {
|
|
2505
|
+
|
|
2506
|
+
if ( v.z > 0.0 )
|
|
2507
|
+
planar.x = 4.0 - v.x;
|
|
2508
|
+
|
|
2509
|
+
} else if ( absV.x >= almostOne ) {
|
|
2510
|
+
|
|
2511
|
+
float signX = sign( v.x );
|
|
2512
|
+
planar.x = v.z * signX + 2.0 * signX;
|
|
2513
|
+
|
|
2514
|
+
} else if ( absV.y >= almostOne ) {
|
|
2515
|
+
|
|
2516
|
+
float signY = sign( v.y );
|
|
2517
|
+
planar.x = v.x + 2.0 * signY + 2.0;
|
|
2518
|
+
planar.y = v.z * signY - 2.0;
|
|
2519
|
+
|
|
2520
|
+
}
|
|
2521
|
+
|
|
2522
|
+
// Transform to UV space
|
|
2523
|
+
|
|
2524
|
+
// scale := 0.5 / dim
|
|
2525
|
+
// translate := ( center + 0.5 ) / dim
|
|
2526
|
+
return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
|
|
2527
|
+
|
|
2528
|
+
}
|
|
2529
|
+
|
|
2530
|
+
float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
|
|
2531
|
+
|
|
2532
|
+
float shadow = 1.0;
|
|
2533
|
+
vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
|
|
2534
|
+
|
|
2535
|
+
// for point lights, the uniform @vShadowCoord is re-purposed to hold
|
|
2536
|
+
// the vector from the light to the world-space position of the fragment.
|
|
2537
|
+
vec3 lightToPosition = shadowCoord.xyz;
|
|
2538
|
+
|
|
2539
|
+
// dp = normalized distance from light to fragment position
|
|
2540
|
+
float compare = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); // need to clamp?
|
|
2541
|
+
compare += shadowBias;
|
|
2542
|
+
|
|
2543
|
+
// bd3D = base direction 3D
|
|
2544
|
+
vec3 bd3D = normalize( lightToPosition );
|
|
2545
|
+
|
|
2546
|
+
vec2 halton = haltonSequence[frameIndex];
|
|
2547
|
+
float temporalOffset = getNoiseInterleavedGradient(gl_FragCoord.xy + halton);
|
|
2548
|
+
float temporalAngle = temporalOffset * PI2;
|
|
2549
|
+
|
|
2550
|
+
#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_VSM )
|
|
2551
|
+
for (int i = 0; i < gShadowSamples; i++) {
|
|
2552
|
+
vec2 vogelSample = vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize;
|
|
2553
|
+
|
|
2554
|
+
// Overall blurring offset
|
|
2555
|
+
vec3 offset = vec3(vogelSample.x, vogelSample.y, -vogelSample.x) * (shadowRadius + 5.);
|
|
2556
|
+
|
|
2557
|
+
// NOTE: Removed for now
|
|
2558
|
+
// Penumbra offset
|
|
2559
|
+
//offset += vec3(vogelSample.x, vogelSample.y, vogelSample.y) * (penumbra * gPenumbraFilterSize);
|
|
2560
|
+
|
|
2561
|
+
shadow += texture2DCompare( shadowMap, cubeToUV( bd3D + offset, texelSize.y ), compare );
|
|
2562
|
+
|
|
2563
|
+
}
|
|
2564
|
+
return shadow * gShadowSamplesRpc;
|
|
2565
|
+
|
|
2566
|
+
#elif defined( SHADOWMAP_TYPE_PCF_SOFT )
|
|
2567
|
+
for (int i = 0; i < 16; i++) {
|
|
2568
|
+
vec2 vogelSample = vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize;
|
|
2569
|
+
|
|
2570
|
+
// Overall blurring offset
|
|
2571
|
+
vec3 offset = vec3(vogelSample.x, vogelSample.y, -vogelSample.x) * (shadowRadius + 5.);
|
|
2572
|
+
|
|
2573
|
+
shadow += texture2DCompare( shadowMap, cubeToUV( bd3D + offset, texelSize.y ), compare );
|
|
2574
|
+
|
|
2575
|
+
}
|
|
2576
|
+
return shadow * (1.0 / 16.0);
|
|
2577
|
+
#else // no percentage-closer filtering
|
|
2578
|
+
|
|
2579
|
+
return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), compare );
|
|
2580
|
+
|
|
2581
|
+
#endif
|
|
2582
|
+
|
|
2583
|
+
}
|
|
2584
|
+
|
|
2585
|
+
#endif
|
|
2586
|
+
`,rC=Qs.lights_fragment_begin,oC=Qs.shadowmask_pars_fragment,n0=null,nC=n=>{switch(n){case"low":return 8;case"medium":return 16;case"high":return 32;default:return 16}},i0=(n="medium")=>{if(n0===n)return!1;n0=n;let r=nC(n);Qs.shadowmap_pars_fragment=tC(r);let e=rC.slice();e=e.replace("getShadow( spotShadowMap[ i ]",`getShadow( UNROLLED_LOOP_INDEX + ${3}, spotShadowMap[ i ]`),e=e.replace("getShadow( directionalShadowMap[ i ]","getShadow( UNROLLED_LOOP_INDEX, directionalShadowMap[ i ]"),Qs.lights_fragment_begin=e;let t=oC.slice();return t=t.replaceAll("getShadow(","getShadow( UNROLLED_LOOP_INDEX, "),Qs.shadowmask_pars_fragment=t,!0};import{DirectionalLight as cC,CameraHelper as s0}from"three";import{DirectionalLightHelper as iC}from"three";var Xi=class extends Gr(iC){constructor(e,t=15,o=10066329){super(e,t,o);this.object=e;this.added=!1;this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,t){Vr(this.object,Xi.geometryHelper,e,t)}};import{PointLightHelper as sC}from"three";var Ki=class extends Gr(sC){constructor(e,t=15,o=6710886){super(e,t,o);this.object=e;this.name=`PointLightHelper: ${e.uuid}`}raycast(e,t){Vr(this.object,Ki.geometryHelper,e,t)}};import{SpotLightHelper as aC,Vector3 as lC}from"three";var lc=class extends Gr(aC){constructor(e,t=6710886){super(e,t);this.object=e;this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,t){Vr(this.object,lc.geometryHelper,e,t)}update(){if(this.object!==void 0){let e=lc._vector,t=this.object.distance?this.object.distance:1e3,o=t*Math.tan(this.object.angle);this.cone.scale.set(o,o,t),e.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(e);let i=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let s=0,a=this.cone.material.length;s<a;s++)this.cone.material[s].color.set(i);else this.cone.material.color.set(i)}}},Js=lc;Js._vector=new lC;function dC(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 Zi=class extends Yi(cC,Xi){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 s0(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 s0&&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&&dC(this,r.size),r.shadowRadius!==void 0&&(this.shadow.radius=r.shadowRadius),r.shadowResolution!==void 0&&(this.shadow.mapSize.set(r.shadowResolution,r.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),r.penumbraSize!==void 0&&e.scene.markPenumbraSizeDirty(),t&&this.update()}};import{Scene as gC}from"three";import{SpotLight as uC,CameraHelper as a0,MathUtils as pC,Vector3 as u0,Quaternion as fC}from"three";var l0=new u0,c0=new u0,d0=new fC,Qi=class extends Yi(uC,Js){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=pC.RAD2DEG*2*this.angle,i.aspect=1,i.near=100,i.far=2500;let s=new a0(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 a0&&e.update()}}updateMatrixWorld(r){super.updateMatrixWorld(r),c0.setFromMatrixPosition(this.matrixWorld),d0.setFromRotationMatrix(this.matrixWorld),l0.copy(this.up).applyQuaternion(d0).negate().multiplyScalar(this.distance),this.target.position.copy(c0).add(l0),this.target.updateMatrixWorld(),this.objectHelper&&this.objectHelper.update()}updateState(r,e){this.updateState_Light(r,e),r.distance!==void 0&&(this.distance=r.distance),r.decay!==void 0&&(this.decay=r.decay),r.angle!==void 0&&(this.angle=r.angle),r.penumbra!==void 0&&(this.penumbra=r.penumbra),r.shadowRadius!==void 0&&(this.shadow.radius=r.shadowRadius),r.penumbraSize!==void 0&&e.scene.markPenumbraSizeDirty(),r.shadowResolution!==void 0&&(this.shadow.mapSize.set(r.shadowResolution,r.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};var Lo=class extends ti(gC){constructor(e,t){super();this.data=t;this.bgColor=new Je(1,1,1,1);this.fog=null;this.backupFog=new hC(16777215,.1,2e3);this.fogUseBGColor=!1;this.isActive=!1;this.aoColor=new mC;this.penumbraSizeArrayCache=null;this.super_Entity(e,t),this.personalCamera=new jr(xo,{...ko.defaultData,...t.camera,name:"Personal Camera"}),this.personalCamera.objectHelper.visible=!1,this.add(this.personalCamera),this.activeCamera=this.personalCamera,this.ambientLight=new yC(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.ambientLight.removeFromParent(),this.add(this.ambientLight)}get scene(){return this.parent}get postprocessing(){return this.data.postprocessing}updateVisible(){}setBackgroundColor(e){this.bgColor=e,this.fogUseBGColor===!0&&(this.backupFog.color=e)}updateAmbientLight(e,t){e.color!==void 0&&(this.ambientLight.color=ht(e.color,t)),e.intensity!==void 0&&(this.ambientLight.intensity=e.intensity),e.enabled!==void 0&&(e.enabled?this.add(this.ambientLight):this.remove(this.ambientLight))}onDeactive(){this.isActive=!1}onActive(e){this.isActive=!0,e.fog=this.fog,this.updateShadow(this.data.shadow)}forceMaterialsUpdate(){this.traverseEntity(e=>{if(e instanceof Bt)if(Array.isArray(e.material))for(let t of e.material)t.needsUpdate=!0;else e.material.needsUpdate=!0,e.material.dispose()})}updateShadow(e){e.softShadowQuality!==void 0&&this.isActive&&i0(e.softShadowQuality)&&this.forceMaterialsUpdate()}updateFog(e,t){if(e.enabled?this.fog=this.backupFog:this.fog=null,this.isActive){let o=this.scene;o.fog=this.fog}this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=ht(e.color,t),this.backupFog.near=e.near,this.backupFog.far=e.far}updateAo(e,t){e.aoColor!==void 0&&(this.aoColor=ht(e.aoColor,t))}updateByOp(e,t,o,i){super.updateByOp(e,t,o,i);let s=t;yt(e.path,["fog"])?this.updateFog(s.fog,o.shared):yt(e.path,["ao"])?this.updateAo(s.ao,o.shared):yt(e.path,["ambient"])?this.updateAmbientLight(s.ambient,o.shared):yt(e.path,["shadow"])&&this.updateShadow(s.shadow)}updateState(e,t){this.updateState_Entity(e,t),e.backgroundColor!==void 0&&this.setBackgroundColor(ht(e.backgroundColor,t.shared)),e.fog!==void 0&&this.updateFog(e.fog,t.shared),e.ambient!==void 0&&this.updateAmbientLight(e.ambient,t.shared),e.ao!==void 0&&this.updateAo(e.ao,t.shared),e.shadow!==void 0&&this.updateShadow(e.shadow)}raycast(e,t){super.raycast(e,t)}switchActiveCamera(e){e&&e.isDescendantOf(this)&&(this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=e,e.objectHelper.visible=!1)}get playCamera(){return this.scene?.find(this.data.publish.playCamera)??this.personalCamera}switchToPlayCamera(){this.switchActiveCamera(this.playCamera)}get penumbraSizeArray(){return this.penumbraSizeArrayCache===null&&this.updatePenumbraSizeArray(),this.penumbraSizeArrayCache}updatePenumbraSizeArray(){this.penumbraSizeArrayCache=new Array(5).fill(.5);let e=0,t=0;this.traverseEntity(o=>{if(!o.visible)return!0;o instanceof Zi&&o.visible&&e<3&&(this.penumbraSizeArrayCache[e]=o.data.penumbraSize,e+=1),o instanceof Qi&&o.visible&&e<5-3&&(this.penumbraSizeArrayCache[3+t]=o.data.penumbraSize,t+=1)})}raycastWithClones(e){let t=[],o=i=>{for(let s of i.children){let a=s.cloner;Se.is(s)&&(s.visible||a?.object.data.visible)&&((Eo(s)||Ks(s)&&this.scene.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,t),ta(s,e,t,!0)),o(s))}};return o(this),t}};import{PointLight as xC,Vector3 as cc,Box3 as vC,Box3Helper as p0,Color as bC}from"three";var dc=class extends Yi(xC,Ki){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 cc(-i.far+this.position.x,-i.far+this.position.y,-i.far+this.position.z),a=new cc(i.far+this.position.x,i.far+this.position.y,i.far+this.position.z),c=new vC(s,a),u=new p0(c,new bC(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 p0){let t=this.shadow.camera,o=new cc(-t.far+this.position.x,-t.far+this.position.y,-t.far+this.position.z),i=new cc(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 uc=class extends Xe{get forceComputeSize(){return!0}get shape(){return this.geometry.userData.shape}updateEntityBoxSize(r,e){let t=this.geometry.getAttribute("position");t!==void 0?Ls(t,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:t.count,r,e):super.updateEntityBoxSize(r,e)}};var Ji=class extends Xe{constructor(e,t,o){super(e,t,o);this._shapeId=null;this._context=o}updateState(e,t){super.updateState(e,t),this.updateShape()}updateShape(){let e=this.data.geometry.extrusion.shape,t;if(e.type==="Custom"){let i=e.shapeId;if(i!==this._shapeId&&this.detachShape(),i){this._shapeId=i;let s=this._context.scene.find(i);s?.data&&(s.attachedPaths.add(this),t=s.geometry.userData?.shape),t||this._context.scene.addPendingCommand(()=>this.updateShape())}}else{let i;switch(e.type){case"Rectangle":i=Rl;break;case"Ellipse":i=di;break;case"Polygon":i=Bl;break;case"Star":i=Gl;break;default:throw new Error(`Unknown shape type: ${e.type}`)}t=i.create({parameters:e}).userData.shape}let o=this.geometry;t&&o.inputs&&(o.inputs.shapeData=t,o.build(),this.attachedSurfaceCloners.forEach(i=>i.update()))}detachShape(){this._shapeId!==null&&this._context.scene.find(this._shapeId)?.attachedPaths.delete(this)}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.updateShape(),this.refreshAttachedPaths(e)}updateTransformState(e){return super.updateTransformState(e)}updateGeometryInteractions(e,t){super.updateGeometryInteractions(e,t),this.updateShape()}updateEntityBoxSize(e,t){let o=this.geometry.getAttribute("position");o!==void 0?Ls(o,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:o.count,e,t):super.updateEntityBoxSize(e,t)}};import{Group as SC,Matrix4 as wC,Skeleton as _C}from"three";var so=class extends zr(SC,Fr){constructor(e,t,o){super();t.type==="Instance"&&typeof e=="string"&&(t=this.transformAssignData(t,o)),this.super_Entity(e,t),this.objectHelper.update()}get isComponentRoot(){return this.data.type==="Component"&&typeof this.identity=="string"}get isInstanceRoot(){return this.data.type==="Instance"&&typeof this.identity=="string"}transformAssignData(e,t){let o=t.scene.data.objects.get(e.component);if(o){let i,s;for(let a of Kr.rootOverrideProps)e[a]===void 0?(i===void 0&&(i={...e}),i[a]=o.data[a]):(s===void 0&&(s={}),s[a]=e[a],i===void 0&&(i={...e}),i[a]=xr.apply(o.data[a],e[a]));return this.overrideData=s,i}else return{...gt.defaultData,...e}}updateByOp(e,t,o,i){let s;if(this.isInstanceRoot&&!i){if(t=this.transformAssignData(t,o),e.type===0&&e.path.length===0&&this.component)for(let a of Kr.rootOverrideProps)a in e.props&&e.props[a]===void 0&&(s===void 0&&(s={...e,props:{...e.props}}),s.props[a]=this.component.data[a]);else if(e.type===0&&e.path.length>0&&Kr.rootOverrideProps.includes(e.path[0])){let a=e.path[0];s===void 0&&(s={...e,path:[],props:{[a]:t[a]}})}}super.updateByOp(s??e,t,o,i)}updateState(e,t){this.updateState_Entity(e,t)}expandInstanceChildren(e){let t=this.data;if(this.component===void 0){let o=e.scene.find(t.component)??null,i=!1;if(o!==this.oldComponent){if(this.oldComponent){let s=0;for(let a of this.children)if(Se.is(a))e.scene.disposeAndUnregisterEntityRecursivelyIfNotReregistered(a),pc(a),s+=1;else break;this.children.splice(0,s)}i=!0}if(o){let s={};m0(e,[this.uuid],t.overrides,this,o,o,0,i,s);for(let a of this.children)if(Se.is(a)){let c=a.data;c.type==="Empty"&&c.animations&&a.traverseEntity(u=>{if(u instanceof Xe&&u.isSkinnedMesh){let l=u.dataPatched;if(l.bones&&l.boneInverses){let d=l.bones.map(m=>e.scene.find(s[m])),p=l.boneInverses.map(m=>new wC().fromArray(m)),f=new _C(d,p);u.bind(f,u.bindMatrix)}}else u.matrixAutoUpdate=!0})}}this.oldComponent=this.component}}};function pc(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)Se.is(e)&&pc(e)}}function f0(n,r,e,t){return n.component===r&&os(n.identity,t)?n.overrideData===e?2:1:0}function m0(n,r,e,t,o,i,s,a,c){if(s>50)return!1;if(t.component!==o){if(t.component){let l=t.component.instances.indexOf(t);l>=0&&t.component.instances.splice(l,1)}o.instances.push(t),t.component=o}o instanceof so&&o.isInstanceRoot&&o.expandInstanceChildren(n);let u=0;for(let l of o.children)if(Se.is(l)){let d=[...r,...typeof l.identity=="string"?[l.identity]:l.identity],p=Yn.resolve(e,d,1),f=null,m;if(!a){let h=t.children[u];if(f=Se.is(h)?h:null,f!==null){let y=f0(f,l,p,d);m=y>=1?f.stateSelection:void 0,y!==2&&(f=null)}if(f===null&&(f=n.scene.findInstance(d)??null,f!==null)){let y=f0(f,l,p,d);if(m=y>=1?f.stateSelection:void 0,y!==2)f=null;else{let g=f.parent.children.indexOf(f);f.parent.children.splice(g,1),t.children.splice(u,0,f),f.parent===t?(g<=u&&console.error("not possible"),void 0):(f.parent=t,f.matrixWorldNeedsUpdate=!0,f.resetBBoxNeedsUpdate(),f.updateVisible(),n.pendingDeletes.delete(f),void 0)}}}if(f===null){let h=p?xr.apply(l.data,p):l.data;er.is(h.type)&&(h={...h,type:"Empty"}),f=rr.createEntity(d,h,n),f.overrideData=p,t.add(f),t.children.splice(t.children.length-1,1),t.children.splice(u,0,f),f.updateState(f.data,n),m&&f.changeSelectedState(m,n),n.scene.registerInstanceAndSetUuid(f)}if(f.isBone){let h=f.identity[f.identity.length-1];c[h]=f.uuid}u+=1,m0(n,r,e,f,l,i,s+1,a,c)}if(!a){let l=u;for(;;){let d=t.children[u];if(Se.is(d))n.pendingDeletes.add(d);else break;u+=1}t.children.splice(l,u-l)}return!0}import{Bone as PC}from"three";var fc=class extends zr(PC,Fr){constructor(r,e){super(),this.super_Entity(r,e),this.objectHelper.update(),this.matrixAutoUpdate=!0}updateState(r,e){this.updateState_Entity(r,e)}};function TC(n,r,e){let t;return r.geometry.type==="TextGeometry"?new Ui(n,r,e):(r.geometry.type==="SubdivGeometry"?t=new an(n,r,e):r.geometry.type==="PathGeometry"?t=new Ji(n,r,e):r.geometry.type==="VectorGeometry"?t=new uc(n,r,e):r.geometry.type==="BooleanGeometry"?t=new Qt(n,r,e):t=new Xe(n,r,e),t)}function mc(n,r,e){return r.type==="Mesh"?TC(n,r,e):r.type==="Empty"?new Zs(n,r):r.type==="Bone"?new fc(n,r):r.type==="Page"?new Lo(n,r):r.type==="PointLight"?new dc(n,r,e):r.type==="SpotLight"?new Qi(n,r,e):r.type==="DirectionalLight"?new Zi(n,r,e):r.type==="Component"||r.type==="Instance"?new so(n,r,e):er.is(r.type)?new jr(n,r):(console.error(r),new Zs(n,r))}rr.createEntity=mc;function OC(n,r,e){let t=mc(n.identity,r,e),o=n.children,i=n.attachedPaths,s=n.parent,a=n.component,c=n.instances,u=n.overrideData,l=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=a,n.instances=c,n.uuid=l,n.overrideData=u,n.updateState(n.data,e),d&&n.changeSelectedState(d,e),n.resetBBoxNeedsUpdate()}rr.changeEntityProptotype=OC;rr.Cloner=Wi;function h0(n,r,e,t){n.updateByOp(r,e,t,!1)}import{Matrix4 as NC,Ray as IC,Raycaster as MC}from"three";function y0(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,Fi(n),ji(n)),t.length===0&&o.length===0&&n.layers.set(0),n instanceof Bt&&n.needsAO&&n.layers.enable(5),e}function g0(n,r){if(!r.layers)return!1;let e=!1,t=r.getLayersOfType("transmission").filter(i=>i.data.visible),o=r.getLayersOfType("outline").filter(i=>i.data.visible);return t.length>0&&(n.layers.set(3),o.length>0&&n.layers.enable(8),e=!0),t.length===0&&o.length===0&&n.layers.set(0),n.needsAO&&n.layers.enable(5),e}function x0(n){let r=!1;return n.traverseEntity(e=>{if(e instanceof Bt)if(Array.isArray(e.material))for(let t=0;t<e.material.length;t++)y0(e,e.material[t])&&(r=!0);else y0(e,e.material)&&(r=!0)}),r}function v0(n){let r=!1;return n.traverseEntity(e=>{if(e instanceof Bt)if(Array.isArray(e.material))for(let t=0;t<e.material.length;t++)g0(e,e.material[t])&&(r=!0);else g0(e,e.material)&&(r=!0)}),r}var EC=new MC,LC=new NC,DC=new IC;function ta(n,r,e,t=!1){let o=n.cloner;if(o)for(let i of o.children){let s=LC.copy(i.matrixWorld).invert(),a=DC.copy(r.ray).applyMatrix4(s),c=n.matrixWorld;a.applyMatrix4(c);let u=EC;u.set(a.origin,a.direction),u.near=r.near,u.far=r.far;let l=u.intersectObject(n,!1);l.length>0&&e.push({...l[0],object:t?i:n})}}var hc=class{constructor(){this._constraints=new Map}setConstraint(r,e){e===null?this._constraints.delete(r):this._constraints.set(r,e)}removeDependencies(r){this._constraints.delete(r)}applyConstraints(r){let e=new Set;this._constraints.forEach((t,o)=>{let i=[o,t],s=t;for(;this._constraints.has(s);)s=this._constraints.get(s),e.has(s)||i.push(s);for(let a=i.length-2;a>=0;a--)if(!e.has(i[a])){let c=r.find(i[a]);c?c.applyPathSnapping(r):console.warn(`missing entity ${i[a]}`),e.add(i[a])}})}findDependency(r,e){let t=r;for(;this._constraints.has(t);)if(t=this._constraints.get(t),t===e)return!0;return!1}};var FC=new zC;FC.wireframe=!0;var b0=new RC,yc=class extends BC{constructor(e,t){super();this.data=e;this.enableHelpers=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this.needsNormalDirty=!0;this._needsTransmission=!1;this._needsNormal=!1;this.geometryCacheChanged=!1;this.entityByUuid={};this.entityIdentityToEntity={};this.toExpandCloner=new Set;this.toUpdateCloner=new Set;this.pendingCommands=[];this.pathConstraints=new hc;this.errorPage=new Lo("fdasfa",{...Zr.defaultData,name:""});this.needsRecomputeInstances=!1;this.init(e,t),this.matrixAutoUpdate=!1}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=v0(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=x0(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let t=e.identity.join("-"),o=this.entityIdentityToEntity[t];o&&(e.uuid=o.uuid),this.entityIdentityToEntity[t]=e,this.entityByUuid[e.uuid]=e}markPenumbraSizeDirty(){for(let e of this.children)e instanceof Lo&&(e.penumbraSizeArrayCache=null)}findInstance(e){return this.entityIdentityToEntity[e.join("-")]}get bgColor(){return this.activePage.bgColor}get postprocessing(){return this.activePage.data.postprocessing}getWithSortKey(e){let t=this.find(e);if(t===void 0)return;let o=[],i=t;for(;i!==this;){let s=i;i=i.parent;let a=i.children.indexOf(s);o.splice(0,0,a)}return{entity:t,sortKey:o}}getAllSorted(e){let t=[];for(let o of e){let i=this.getWithSortKey(o.id);i!==void 0&&t.push(i)}return t.sort((o,i)=>Wu(o.sortKey,i.sortKey)),t.map(o=>o.entity)}nonExistOrDescendantOf(e,t){let o=this.find(e);if(o===void 0)return!0;for(;o;){if(o.uuid===t)return!0;o=o.parent}return!1}find(e){if(this.activePage&&this.activePage.personalCamera.parent){if(e==="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera")return this.activePage.personalCamera;if(e===xo)return this.activePage.personalCamera}if(e===""||e===void 0)return;let t=this.entityByUuid[e];return t===void 0?this.getObjectByProperty("uuid",e):t}debugEnsureEntity(e){let t=this.find(e);if(t){if(Array.isArray(t.identity)&&this.findInstance(t.identity)===void 0){console.error("not found instance");debugger}}else{console.error("not found");debugger}}addPendingExpandCloner(e){this.toExpandCloner.add(e)}addPendingUpdateCloner(e){this.toUpdateCloner.add(e)}markToExpandCloner(e){this.toExpandCloner.add(e),e.traverseEntityAncestors(t=>{this.toExpandCloner.add(t)})}doPendingExpandCloner(){this.toExpandCloner.forEach(e=>{e.expandCloner(this)}),this.toExpandCloner.clear()}doPendingUpdateCloner(){this.toUpdateCloner.forEach(e=>{e.cloner?.update()}),this.toUpdateCloner.clear()}doPendingUpdates(){this.doPendingExpandCloner(),this.doPendingUpdateCloner(),this.applyPendingCommands()}addPendingCommand(e){this.pendingCommands.push(e)}applyPendingCommands(){this.pendingCommands.forEach(e=>e()),this.pendingCommands.length=0}updateTreeByOp(e,t){if(e.path.length===0&&e.type===7){let o=e.parent===null?this:this.find(e.parent);if(o===void 0)throw new Error("unexpected");let i=this.createObject(e.id,e.data,e.children,o,e.localIndex,t);i.updateVisible(),i.resetBBoxNeedsUpdate(),Eo(i)&&Xs(i.parent)&&(i.invalidateUpstreamBooleanData(),i.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(o),this.markNeedsRecomputeInstancesForChildren(i),this.markToExpandCloner(i),this.markPenumbraSizeDirty()}else if(e.path.length===0&&e.type===8){let o=this.find(e.id);if(o===void 0)throw new Error("unexpected");this.markToExpandCloner(o),o.resetBBoxNeedsUpdate(),this.unregisterObject(o);let i=o.parent;this.markNeedsRecomputeInstancesForAncessors(i),this.markNeedsRecomputeInstancesForChildren(o),this.markPenumbraSizeDirty(),o.parent.remove(o),Xs(o.parent)&&(o.parent.invalidateUpstreamBooleanData(),o.parent.invalidateDownstreamBooleanData().recomputeBoolean()),Eo(o)&&(o.freeBooleanPointer(),i instanceof Qt&&i.invalidateDownstreamBooleanData().recomputeBoolean()),o instanceof Ji&&o.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(o),this.pathConstraints.removeDependencies(o.uuid)}else if(e.path.length===0&&e.type===9){let o=this.find(e.id);if(o===void 0)throw new Error("unexpected");this.markNeedsRecomputeInstancesForChildren(o);let i=o.parent;this.markNeedsRecomputeInstancesForAncessors(i),o.cloner?.resetOnMove(),this.markToExpandCloner(o);let s=e.parent===null?this:this.find(e.parent);if(s===void 0)throw new Error("unexpected");s.add(o),this.markNeedsRecomputeInstancesForAncessors(s),this.markToExpandCloner(o),o.invalidateClonerTransform(o),o.updateVisible(),o.resetBBoxNeedsUpdate(),this.markPenumbraSizeDirty();let a=e.localIndex;s.children.splice(a,0,s.children.pop()),Eo(o)&&(o.invalidateUpstreamBooleanData(),Xs(o.parent)?o.parent.invalidateDownstreamBooleanData().recomputeBoolean():i instanceof Qt&&i.invalidateDownstreamBooleanData().recomputeBoolean())}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}updatePage(e){this.activePage&&this.activePage.onDeactive(),this.activePage=this.errorPage;for(let t of this.children)t instanceof Lo&&(t.visible=t.uuid===e,t.visible&&(this.activePage=t,this.activePage.onActive(this)))}updateEntityByOp(e,t,o,i){if(t.type===0){if(("overrides"in t.props||"component"in t.props)&&this.markNeedsRecomputeInstances(),"visible"in t.props&&this.markPenumbraSizeDirty(),t.path.includes("overrides")&&"states"in t.props){let{rest:a}=t.props;t={...t,props:a},this.markNeedsRecomputeInstances()}t.path[0]==="pathSnapping"&&t.props.pathId!==void 0&&this.pathConstraints.setConstraint(e,t.props.pathId)}let s=this.find(e);if(s)try{h0(s,t,o,{scene:this,shared:i}),s instanceof Xe&&s.updateGeometryGroupsIfNeeded()}catch(a){console.error(a)}}get activeCamera(){return this.activePage.activeCamera}switchActiveCamera(e){this.activePage.switchActiveCamera(e)}init(e,t){this.createChildrenObjects(e.objects,this,t),this.updatePage(e.publish.playPage),this.activePage.switchToPlayCamera(),this.expandInstances(t,!0),this.traverseEntity(o=>{Xs(o)&&o.recomputeBoolean(),o instanceof jr&&o.updateUp()}),this.doPendingExpandCloner(),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(t=>{(t.data.type==="Component"||t.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){Se.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(t=>{Se.is(t)&&t.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,t,o,i,s,a,c){if(e){let u=i.find(e);u&&u!==i&&s.forInstancesRec(l=>{l.data=kn(l.data,d=>{let p=d.events.data(c.id),f=l.goUp(a);if(f){let m=[...la(f.identity),e].join("-"),h=this.entityIdentityToEntity[m];if(h){let y=h.uuid,g=vt.zoom(p,t);g[o]=y}else{if(!1)debugger;console.warn("cannot find instance")}}}).data})}}rewriteActions(e,t,o,i,s,a){e.forEach(c=>{c.data.type==="Transition"?this.relativeizeInner(c.data.object,[...t,c.id],"object",o,i,s,a):c.data.type==="Animation"&&this.relativeizeInner(c.data.object,[...t,c.id],"object",o,i,s,a)})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof so&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((t,o)=>{t.data.events.forEach(i=>{if(i.data.type==="GameControl"){let s=!1;if(t.forInstancesRec(a=>{a.data=kn(a.data,c=>{a.isInstanceRoot||(c.events.delete(i.id),s=!0)}).data}),s===!1)for(let a of pl.list)this.rewriteActions(i.data.gameActions[a],["gameActions",a],e,t,o,i)}else i.data.type==="Conditional"?(i.data.condition.type==="Distance"?(this.relativeizeInner(i.data.condition.fromObject,["condition"],"fromObject",e,t,o,i),this.relativeizeInner(i.data.condition.toObject,["condition"],"toObject",e,t,o,i)):i.data.condition.type==="State"?this.relativeizeInner(i.data.condition.object,["condition"],"object",e,t,o,i):i.data.condition.type==="Comparison"&&(i.data.condition.lOperand.type==="Property"&&this.relativeizeInner(i.data.condition.lOperand.value[0],["condition","lOperand","value"],0,e,t,o,i),i.data.condition.rOperand.type==="Property"&&this.relativeizeInner(i.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,t,o,i)),this.rewriteActions(i.data.inActions,["inActions"],e,t,o,i),this.rewriteActions(i.data.outActions,["outActions"],e,t,o,i)):"actions"in i.data&&this.rewriteActions(i.data.actions,["actions"],e,t,o,i)})}),!0})}expandInstances(e,t,o){let i=new Set;this.traverseEntity(s=>{if(s instanceof so&&s.isInstanceRoot)return s.expandInstanceChildren({scene:this,shared:e,pendingDeletes:i}),t||s.resetBBoxNeedsUpdate(),o&&s.traverseEntity(a=>{o.addClip(a)}),!0});for(let s of i)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(s),pc(s)}recomputeInstances(e,t){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(o=>{o instanceof so&&o.isInstanceRoot&&(o.component=void 0)}),this.expandInstances(e,!1,t))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(t=>{let o=typeof t.identity=="string"?t.identity:t.identity.join("-");this.entityIdentityToEntity[o]===t&&(delete this.entityByUuid[t.uuid],delete this.entityIdentityToEntity[o]),t.dispose()})}clearScene(){for(let e of this.children)Se.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,t){this.init(e,t)}raycast(e){return this.raycast1(e,!1)}raycast1(e,t){let o=[],i=s=>{for(let a of s.children){let c=a.cloner;if(Se.is(a)&&!a.raycastLock&&(a.visible||c?.object.data.visible))if(t===!0&&a.isInstanceRoot){let u=[];if(e.intersectObject(a,!0,u),u.length){let l=u[0];l.object=a,l.point.applyMatrix4(l.object.matrixWorld);let d=a.matrixWorld.clone().invert();l.point.applyMatrix4(d),o.push(l)}}else(Eo(a)||Ks(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,o),ta(a,e,o)),i(a)}};return i(this),o}raycastWithClones(e){let t=[],o=i=>{for(let s of i.children){let a=s.cloner;Se.is(s)&&(s.visible||a?.object.data.visible)&&((Eo(s)||Ks(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,t),ta(s,e,t,!0)),o(s))}};return o(this),t}forEachEntity(e){for(let t of this.children)Se.is(t)&&e(t)}traverseConcreteEntity(e){for(let t of this.children)Se.is(t)&&t.isConcreteEntity&&t.traverseEntity(e)}traverseEntity(e){for(let t of this.children)Se.is(t)&&t.traverseEntity(e)}traverseObject(e){for(let t of this.children)Zn.is(t)&&t.traverseObject(e)}traverseVisibleEntity(e){for(let t of this.children)Se.is(t)&&t.visible&&t.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,t,o){let i=0;for(let s of e)this.createObject(s.id,s.data,s.children,t,i,o),i+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let t of e.children)this.unregisterObject(t)}createObject(e,t,o,i,s,a){let c={scene:this,shared:a},u=mc(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,a)),u.updateState(t,c),u instanceof Xe&&u.updateGeometryGroupsIfNeeded(),u.updateVisible(),u.cloner&&this.toExpandCloner.add(u),t.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,t.pathSnapping.pathId)),t.type==="Empty"&&t.animations&&u.traverseEntity(l=>{if(l instanceof Xe&&l.isSkinnedMesh){let d=l.dataPatched;if(d.bones&&d.boneInverses){let p=d.bones.map(h=>this.find(h)),f=d.boneInverses.map(h=>new GC().fromArray(h)),m=new jC(p,f);l.bind(m,l.bindMatrix)}}else l.matrixAutoUpdate=!0}),u}getCenter(e){let t=[];for(let i=0,s=e.length;i<s;++i){let{id:a,recursive:c}=e[i],u=this.find(a),l=c?u.recursiveBBox:u.singleBBox;t.push(...l.vertices)}let o=new VC;return o.setFromPoints(t),o.getCenter(b0),b0}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 pt)if(Array.isArray(t.material))for(let o=0;o<t.material.length;o++)t.material[o]instanceof Dt&&e(t.material[o]);else t.material instanceof Dt&&e(t.material)})}updateCanvasSize(e,t,o=!1){this.activeCamera.setViewplaneSize(e,t,o)}};import{DRACOLoader as kC}from"three/examples/jsm/loaders/DRACOLoader.js";var Do;function UC(){return Do||(Do=new kC,Do.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),Do.decoderPending}async function HC(n){if(Do){let r={attributeIDs:Do.defaultAttributeIDs,attributeTypes:Do.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await Do.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 S0(n,r){let[e,t]=Ic(Ka.deserialize(new Uint8Array(n)));xh(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 UC();for(let i of o){let s=await HC(Ye(i.geometry.data.draco));if(s){s.index&&(i.geometry.data.index={array:s.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let a={};s.attributes.forEach(({name:c,array:u,itemSize:l})=>{a[c]={array:u,itemSize:l,type:"Float32Array",normalized:!1}}),i.geometry.data.attributes=a,i.geometry.data.draco=void 0}}return r&&r(e),t.result().data}import{Mesh as OJ}from"three";import{mergeBufferGeometries as NJ}from"three/examples/jsm/utils/BufferGeometryUtils.js";function w0(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}import{Color as _0,ShaderLib as WC}from"three";function P0(n){let r=new Set;return n.traverse(e=>{if(e instanceof Bt)if(je(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(qC(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new _0,specularColor:new _0});let o=0;e.onBeforeCompile=(i,s)=>{t&&t(i,s),i.uniforms=Object.assign({},WC.physical.uniforms,i.uniforms),e.getLayersOfType("transmission").forEach(a=>{if(i.uniforms.transmissionSamplerMap.value){let c=a.color;c&&(c.transmissionSamplerMap.value=i.uniforms.transmissionSamplerMap.value,c.transmissionSamplerSize.value=i.uniforms.transmissionSamplerSize.value,c.aspectRatio.value=lg(window.innerWidth,window.innerHeight),e.defines.IS_THREEJS_EXPORT=!0)}else o++,o<2&&(e.needsUpdate=!0)})}}else $C(e)||(e.onBeforeCompile=(o,i)=>{t&&t(o,i),e.transparent=!1})}),n}function qC(n){return n.getLayersOfType("transmission").length>0}function $C(n){let r=0;for(let e of n.layers){if(e.data.type!=="displace"&&e.data.isMask)return!0;if(e.type!=="light"&&e.type!=="fresnel"){let o=e.uniforms["f"+e.id+"_alpha"];o&&(r+=(1-r)*o.value)}}return r<1}function T0(n){return n.traverse(r=>{if(r.type==="Camera"){let e=r;e.type=e.cameraType}}),n}function O0(n){let r=[],e=(t,o=0)=>{let i=o>0?t+o:t;return r.includes(i)?e(t,o+1):i};return n.traverse(t=>{if(r.includes(t.name)){let o=t.name,i=e(t.name);if(t.name=i,t.isMesh){let s=t;s.material instanceof Array?s.material.forEach(a=>{a.name=a.name.replace(o,i)}):s.material.isAsset||(s.material.name=s.material.name.replace(o,i))}}r.push(t.name)}),n}import{mergeBufferGeometries as YC}from"three/examples/jsm/utils/BufferGeometryUtils.js";function A0(n){let r=[];return n.traverse(e=>{e instanceof Wi&&r.push(e)}),r.forEach(e=>{let t=e.object,s=[...e.children.map(a=>{a.updateMatrix();let c;if(a.geometry!==void 0)try{c=a.geometry.clone().applyMatrix4(a.matrix)}catch(u){console.error(u)}return c!==void 0&&a.matrix.determinant()<0&&w0(c),c}).filter(a=>a!==void 0)];if(!e.parameters.hideBase&&t instanceof pt&&s.unshift(t.geometry),s.length){let a=YC(s);t instanceof pt&&(t.geometry=a)}e.removeFromParent(),t.setFromClonerState(null,{scene:n,shared:Pg})}),n}function C0(n){return n.traverse(r=>{r.matrixAutoUpdate=!0}),n}function N0(n){Object.values(n.shared.materials).forEach(r=>{Fu(r)}),n.scene.objects.traverse((r,e)=>{"material"in e?Fu(e.material):"materials"in e&&e.materials.forEach(t=>{Fu(t)})})}function Fu(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 D0=aa(M0(),1);function E0(n){return n.traverseMaterial(r=>{r.needsJitter=!1}),n}var L0="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",ku=class extends KC{load(r,e,t,o=console.error){let i=new XC(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),r.endsWith(".spline")?console.warn(L0+" The .spline files are only meant to be used by the Editor."):r.endsWith(".splinecode")||console.warn(L0),i.load(r,async s=>{try{if(typeof s=="string")throw new Error("The .spline file is not binary!");let a=await this.parse(s);e(a)}catch(a){o(a)}},t,o)}async parse(r){let e=await S0(r,N0);e.version&&(0,D0.default)(e.version,"0.9.387")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/loader to the latest version."),await Promise.all([Eg(e)&&Vy(),Ug(e)&&wg()].filter(Boolean));let t=new sn(e.shared);Object.values(t.getMaterials()).forEach(s=>Object.assign(s,{isAsset:!0}));let o=new yc(e.scene,t),i=e.scene.publish.playCamera;if(i){let s=o.find(i);s&&o0(s)&&Object.assign(s,{makeDefault:!0})}return o=A0(o),o=P0(o),o=T0(o),o=O0(o),o=C0(o),o=E0(o),o}};export{ku as default};
|