@splinetool/loader 0.9.24 → 0.9.25
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.js +15 -15
- package/package.json +1 -1
package/build/SplineLoader.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var zm=Object.create;var Ti=Object.defineProperty,Em=Object.defineProperties,Fm=Object.getOwnPropertyDescriptor,Rm=Object.getOwnPropertyDescriptors,Vm=Object.getOwnPropertyNames,gc=Object.getOwnPropertySymbols,Um=Object.getPrototypeOf,xc=Object.prototype.hasOwnProperty,km=Object.prototype.propertyIsEnumerable;var bc=(i,e,t)=>e in i?Ti(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,O=(i,e)=>{for(var t in e||(e={}))xc.call(e,t)&&bc(i,t,e[t]);if(gc)for(var t of gc(e))km.call(e,t)&&bc(i,t,e[t]);return i},$=(i,e)=>Em(i,Rm(e)),vc=i=>Ti(i,"__esModule",{value:!0});var Sc=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports),Hm=(i,e)=>{vc(i);for(var t in e)Ti(i,t,{get:e[t],enumerable:!0})},qm=(i,e,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Vm(e))!xc.call(i,r)&&r!=="default"&&Ti(i,r,{get:()=>e[r],enumerable:!(t=Fm(e,r))||t.enumerable});return i},wc=i=>qm(vc(Ti(i!=null?zm(Um(i)):{},"default",i&&i.__esModule&&"default"in i?{get:()=>i.default,enumerable:!0}:{value:i,enumerable:!0})),i);var Oh=Sc(Qs=>{"use strict";Qs.byteLength=aS;Qs.toByteArray=cS;Qs.fromByteArray=uS;var Sr=[],Yt=[],sS=typeof Uint8Array!="undefined"?Uint8Array:Array,Al="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Co=0,Mh=Al.length;Co<Mh;++Co)Sr[Co]=Al[Co],Yt[Al.charCodeAt(Co)]=Co;var Co,Mh;Yt["-".charCodeAt(0)]=62;Yt["_".charCodeAt(0)]=63;function Ph(i){var e=i.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=i.indexOf("=");t===-1&&(t=e);var r=t===e?0:4-t%4;return[t,r]}function aS(i){var e=Ph(i),t=e[0],r=e[1];return(t+r)*3/4-r}function lS(i,e,t){return(e+t)*3/4-t}function cS(i){var e,t=Ph(i),r=t[0],o=t[1],n=new sS(lS(i,r,o)),s=0,a=o>0?r-4:r,l;for(l=0;l<a;l+=4)e=Yt[i.charCodeAt(l)]<<18|Yt[i.charCodeAt(l+1)]<<12|Yt[i.charCodeAt(l+2)]<<6|Yt[i.charCodeAt(l+3)],n[s++]=e>>16&255,n[s++]=e>>8&255,n[s++]=e&255;return o===2&&(e=Yt[i.charCodeAt(l)]<<2|Yt[i.charCodeAt(l+1)]>>4,n[s++]=e&255),o===1&&(e=Yt[i.charCodeAt(l)]<<10|Yt[i.charCodeAt(l+1)]<<4|Yt[i.charCodeAt(l+2)]>>2,n[s++]=e>>8&255,n[s++]=e&255),n}function dS(i){return Sr[i>>18&63]+Sr[i>>12&63]+Sr[i>>6&63]+Sr[i&63]}function pS(i,e,t){for(var r,o=[],n=e;n<t;n+=3)r=(i[n]<<16&16711680)+(i[n+1]<<8&65280)+(i[n+2]&255),o.push(dS(r));return o.join("")}function uS(i){for(var e,t=i.length,r=t%3,o=[],n=16383,s=0,a=t-r;s<a;s+=n)o.push(pS(i,s,s+n>a?a:s+n));return r===1?(e=i[t-1],o.push(Sr[e>>2]+Sr[e<<4&63]+"==")):r===2&&(e=(i[t-2]<<8)+i[t-1],o.push(Sr[e>>10]+Sr[e>>4&63]+Sr[e<<2&63]+"=")),o.join("")}});var Sm=Sc((Ia,vm)=>{(function(i,e){typeof Ia=="object"&&typeof vm!="undefined"?e(Ia):typeof define=="function"&&define.amd?define(["exports"],e):e((i=typeof globalThis!="undefined"?globalThis:i||self).SVDJS={})})(Ia,function(i){"use strict";i.SVD=function(e,t,r,o,n){if(t=t===void 0||t,r=r===void 0||r,n=1e-64/(o=o||Math.pow(2,-52)),!e)throw new TypeError("Matrix a is not defined");var s,a,l,c,d,p,u,f,m,x,y,N,L=e[0].length,w=e.length;if(w<L)throw new TypeError("Invalid matrix: m < n");for(var B=[],S=[],_=[],T=t==="f"?w:L,h=x=u=0;h<w;h++)S[h]=new Array(T).fill(0);for(h=0;h<L;h++)_[h]=new Array(L).fill(0);var I,b=new Array(L).fill(0);for(h=0;h<w;h++)for(s=0;s<L;s++)S[h][s]=e[h][s];for(h=0;h<L;h++){for(B[h]=u,m=0,l=h+1,s=h;s<w;s++)m+=Math.pow(S[s][h],2);if(m<n)u=0;else for(f=(p=S[h][h])*(u=p<0?Math.sqrt(m):-Math.sqrt(m))-m,S[h][h]=p-u,s=l;s<L;s++){for(m=0,a=h;a<w;a++)m+=S[a][h]*S[a][s];for(p=m/f,a=h;a<w;a++)S[a][s]=S[a][s]+p*S[a][h]}for(b[h]=u,m=0,s=l;s<L;s++)m+=Math.pow(S[h][s],2);if(m<n)u=0;else{for(f=(p=S[h][h+1])*(u=p<0?Math.sqrt(m):-Math.sqrt(m))-m,S[h][h+1]=p-u,s=l;s<L;s++)B[s]=S[h][s]/f;for(s=l;s<w;s++){for(m=0,a=l;a<L;a++)m+=S[s][a]*S[h][a];for(a=l;a<L;a++)S[s][a]=S[s][a]+m*B[a]}}x<(y=Math.abs(b[h])+Math.abs(B[h]))&&(x=y)}if(r)for(h=L-1;0<=h;h--){if(u!==0){for(f=S[h][h+1]*u,s=l;s<L;s++)_[s][h]=S[h][s]/f;for(s=l;s<L;s++){for(m=0,a=l;a<L;a++)m+=S[h][a]*_[a][s];for(a=l;a<L;a++)_[a][s]=_[a][s]+m*_[a][h]}}for(s=l;s<L;s++)_[h][s]=0,_[s][h]=0;_[h][h]=1,u=B[h],l=h}if(t){if(t==="f")for(h=L;h<w;h++){for(s=L;s<w;s++)S[h][s]=0;S[h][h]=1}for(h=L-1;0<=h;h--){for(l=h+1,u=b[h],s=l;s<T;s++)S[h][s]=0;if(u!==0){for(f=S[h][h]*u,s=l;s<T;s++){for(m=0,a=l;a<w;a++)m+=S[a][h]*S[a][s];for(p=m/f,a=h;a<w;a++)S[a][s]=S[a][s]+p*S[a][h]}for(s=h;s<w;s++)S[s][h]=S[s][h]/u}else for(s=h;s<w;s++)S[s][h]=0;S[h][h]=S[h][h]+1}}for(o*=x,a=L-1;0<=a;a--)for(var P=0;P<50;P++){for(I=!1,l=a;0<=l;l--){if(Math.abs(B[l])<=o){I=!0;break}if(Math.abs(b[l-1])<=o)break}if(!I){for(d=0,c=l-(m=1),h=l;h<a+1&&(p=m*B[h],B[h]=d*B[h],!(Math.abs(p)<=o));h++)if(u=b[h],b[h]=Math.sqrt(p*p+u*u),d=u/(f=b[h]),m=-p/f,t)for(s=0;s<w;s++)y=S[s][c],N=S[s][h],S[s][c]=y*d+N*m,S[s][h]=-y*m+N*d}if(N=b[a],l===a){if(N<0&&(b[a]=-N,r))for(s=0;s<L;s++)_[s][a]=-_[s][a];break}for(x=b[l],p=(((y=b[a-1])-N)*(y+N)+((u=B[a-1])-(f=B[a]))*(u+f))/(2*f*y),u=Math.sqrt(p*p+1),p=((x-N)*(x+N)+f*(y/(p<0?p-u:p+u)-f))/x,h=l+(m=d=1);h<a+1;h++){if(u=B[h],y=b[h],f=m*u,u*=d,N=Math.sqrt(p*p+f*f),p=x*(d=p/(B[h-1]=N))+u*(m=f/N),u=-x*m+u*d,f=y*m,y*=d,r)for(s=0;s<L;s++)x=_[s][h-1],N=_[s][h],_[s][h-1]=x*d+N*m,_[s][h]=-x*m+N*d;if(N=Math.sqrt(p*p+f*f),p=(d=p/(b[h-1]=N))*u+(m=f/N)*y,x=-m*u+d*y,t)for(s=0;s<w;s++)y=S[s][h-1],N=S[s][h],S[s][h-1]=y*d+N*m,S[s][h]=-y*m+N*d}B[l]=0,B[a]=p,b[a]=x}for(h=0;h<L;h++)b[h]<o&&(b[h]=0);return{u:S,q:b,v:_}},i.VERSION="1.1.1",Object.defineProperty(i,"__esModule",{value:!0})})});import{FileLoader as h1,Loader as m1}from"three";function Nc(i){return Array.isArray(i)?i:[i]}var Wm=typeof global=="object"&&global&&global.Object===Object&&global,Tn=Wm;var $m=typeof self=="object"&&self&&self.Object===Object&&self,Jm=Tn||$m||Function("return this")(),et=Jm;var Km=et.Symbol,Ct=Km;var Cc=Object.prototype,Xm=Cc.hasOwnProperty,Zm=Cc.toString,Ii=Ct?Ct.toStringTag:void 0;function Qm(i){var e=Xm.call(i,Ii),t=i[Ii];try{i[Ii]=void 0;var r=!0}catch(n){}var o=Zm.call(i);return r&&(e?i[Ii]=t:delete i[Ii]),o}var Lc=Qm;var Ym=Object.prototype,ef=Ym.toString;function tf(i){return ef.call(i)}var Tc=tf;var rf="[object Null]",of="[object Undefined]",Ic=Ct?Ct.toStringTag:void 0;function nf(i){return i==null?i===void 0?of:rf:Ic&&Ic in Object(i)?Lc(i):Tc(i)}var Ft=nf;function sf(i){return i!=null&&typeof i=="object"}var vt=sf;var af="[object Symbol]";function lf(i){return typeof i=="symbol"||vt(i)&&Ft(i)==af}var _o=lf;function cf(i,e){for(var t=-1,r=i==null?0:i.length,o=Array(r);++t<r;)o[t]=e(i[t],t,i);return o}var In=cf;var df=Array.isArray,ht=df;var pf=1/0,Mc=Ct?Ct.prototype:void 0,Pc=Mc?Mc.toString:void 0;function Oc(i){if(typeof i=="string")return i;if(ht(i))return In(i,Oc)+"";if(_o(i))return Pc?Pc.call(i):"";var e=i+"";return e=="0"&&1/i==-pf?"-0":e}var Ac=Oc;function uf(i){var e=typeof i;return i!=null&&(e=="object"||e=="function")}var St=uf;function hf(i){return i}var Mn=hf;var mf="[object AsyncFunction]",ff="[object Function]",yf="[object GeneratorFunction]",gf="[object Proxy]";function xf(i){if(!St(i))return!1;var e=Ft(i);return e==ff||e==yf||e==mf||e==gf}var Do=xf;var bf=et["__core-js_shared__"],Pn=bf;var jc=function(){var i=/[^.]+$/.exec(Pn&&Pn.keys&&Pn.keys.IE_PROTO||"");return i?"Symbol(src)_1."+i:""}();function vf(i){return!!jc&&jc in i}var _c=vf;var Sf=Function.prototype,wf=Sf.toString;function Nf(i){if(i!=null){try{return wf.call(i)}catch(e){}try{return i+""}catch(e){}}return""}var Pr=Nf;var Cf=/[\\^$.*+?()[\]{}|]/g,Lf=/^\[object .+?Constructor\]$/,Tf=Function.prototype,If=Object.prototype,Mf=Tf.toString,Pf=If.hasOwnProperty,Of=RegExp("^"+Mf.call(Pf).replace(Cf,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Af(i){if(!St(i)||_c(i))return!1;var e=Do(i)?Of:Lf;return e.test(Pr(i))}var Dc=Af;function jf(i,e){return i==null?void 0:i[e]}var Bc=jf;function _f(i,e){var t=Bc(i,e);return Dc(t)?t:void 0}var Ot=_f;var Df=Ot(et,"WeakMap"),On=Df;var Gc=Object.create,Bf=function(){function i(){}return function(e){if(!St(e))return{};if(Gc)return Gc(e);i.prototype=e;var t=new i;return i.prototype=void 0,t}}(),zc=Bf;function Gf(i,e,t){switch(t.length){case 0:return i.call(e);case 1:return i.call(e,t[0]);case 2:return i.call(e,t[0],t[1]);case 3:return i.call(e,t[0],t[1],t[2])}return i.apply(e,t)}var Ec=Gf;function zf(i,e){var t=-1,r=i.length;for(e||(e=Array(r));++t<r;)e[t]=i[t];return e}var An=zf;var Ef=800,Ff=16,Rf=Date.now;function Vf(i){var e=0,t=0;return function(){var r=Rf(),o=Ff-(r-t);if(t=r,o>0){if(++e>=Ef)return arguments[0]}else e=0;return i.apply(void 0,arguments)}}var Fc=Vf;function Uf(i){return function(){return i}}var Rc=Uf;var kf=function(){try{var i=Ot(Object,"defineProperty");return i({},"",{}),i}catch(e){}}(),Bo=kf;var Hf=Bo?function(i,e){return Bo(i,"toString",{configurable:!0,enumerable:!1,value:Rc(e),writable:!0})}:Mn,Vc=Hf;var qf=Fc(Vc),jn=qf;function Wf(i,e){for(var t=-1,r=i==null?0:i.length;++t<r&&e(i[t],t,i)!==!1;);return i}var Uc=Wf;var $f=9007199254740991,Jf=/^(?:0|[1-9]\d*)$/;function Kf(i,e){var t=typeof i;return e=e==null?$f:e,!!e&&(t=="number"||t!="symbol"&&Jf.test(i))&&i>-1&&i%1==0&&i<e}var _n=Kf;function Xf(i,e,t){e=="__proto__"&&Bo?Bo(i,e,{configurable:!0,enumerable:!0,value:t,writable:!0}):i[e]=t}var Go=Xf;function Zf(i,e){return i===e||i!==i&&e!==e}var qr=Zf;var Qf=Object.prototype,Yf=Qf.hasOwnProperty;function ey(i,e,t){var r=i[e];(!(Yf.call(i,e)&&qr(r,t))||t===void 0&&!(e in i))&&Go(i,e,t)}var Dn=ey;function ty(i,e,t,r){var o=!t;t||(t={});for(var n=-1,s=e.length;++n<s;){var a=e[n],l=r?r(t[a],i[a],a,t,i):void 0;l===void 0&&(l=i[a]),o?Go(t,a,l):Dn(t,a,l)}return t}var Kt=ty;var kc=Math.max;function ry(i,e,t){return e=kc(e===void 0?i.length-1:e,0),function(){for(var r=arguments,o=-1,n=kc(r.length-e,0),s=Array(n);++o<n;)s[o]=r[e+o];o=-1;for(var a=Array(e+1);++o<e;)a[o]=r[o];return a[e]=t(s),Ec(i,this,a)}}var Bn=ry;function oy(i,e){return jn(Bn(i,e,Mn),i+"")}var Hc=oy;var iy=9007199254740991;function ny(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=iy}var Gn=ny;function sy(i){return i!=null&&Gn(i.length)&&!Do(i)}var Wr=sy;function ay(i,e,t){if(!St(t))return!1;var r=typeof e;return(r=="number"?Wr(t)&&_n(e,t.length):r=="string"&&e in t)?qr(t[e],i):!1}var qc=ay;function ly(i){return Hc(function(e,t){var r=-1,o=t.length,n=o>1?t[o-1]:void 0,s=o>2?t[2]:void 0;for(n=i.length>3&&typeof n=="function"?(o--,n):void 0,s&&qc(t[0],t[1],s)&&(n=o<3?void 0:n,o=1),e=Object(e);++r<o;){var a=t[r];a&&i(e,a,r,n)}return e})}var Wc=ly;var cy=Object.prototype;function dy(i){var e=i&&i.constructor,t=typeof e=="function"&&e.prototype||cy;return i===t}var zo=dy;function py(i,e){for(var t=-1,r=Array(i);++t<i;)r[t]=e(t);return r}var $c=py;var uy="[object Arguments]";function hy(i){return vt(i)&&Ft(i)==uy}var Pa=hy;var Jc=Object.prototype,my=Jc.hasOwnProperty,fy=Jc.propertyIsEnumerable,yy=Pa(function(){return arguments}())?Pa:function(i){return vt(i)&&my.call(i,"callee")&&!fy.call(i,"callee")},mo=yy;function gy(){return!1}var Kc=gy;var Xc=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Zc=Xc&&typeof module=="object"&&module&&!module.nodeType&&module,xy=Zc&&Zc.exports===Xc,Qc=xy?et.Buffer:void 0,by=Qc?Qc.isBuffer:void 0,vy=by||Kc,Eo=vy;var Sy="[object Arguments]",wy="[object Array]",Ny="[object Boolean]",Cy="[object Date]",Ly="[object Error]",Ty="[object Function]",Iy="[object Map]",My="[object Number]",Py="[object Object]",Oy="[object RegExp]",Ay="[object Set]",jy="[object String]",_y="[object WeakMap]",Dy="[object ArrayBuffer]",By="[object DataView]",Gy="[object Float32Array]",zy="[object Float64Array]",Ey="[object Int8Array]",Fy="[object Int16Array]",Ry="[object Int32Array]",Vy="[object Uint8Array]",Uy="[object Uint8ClampedArray]",ky="[object Uint16Array]",Hy="[object Uint32Array]",Ve={};Ve[Gy]=Ve[zy]=Ve[Ey]=Ve[Fy]=Ve[Ry]=Ve[Vy]=Ve[Uy]=Ve[ky]=Ve[Hy]=!0;Ve[Sy]=Ve[wy]=Ve[Dy]=Ve[Ny]=Ve[By]=Ve[Cy]=Ve[Ly]=Ve[Ty]=Ve[Iy]=Ve[My]=Ve[Py]=Ve[Oy]=Ve[Ay]=Ve[jy]=Ve[_y]=!1;function qy(i){return vt(i)&&Gn(i.length)&&!!Ve[Ft(i)]}var Yc=qy;function Wy(i){return function(e){return i(e)}}var Fo=Wy;var ed=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Mi=ed&&typeof module=="object"&&module&&!module.nodeType&&module,$y=Mi&&Mi.exports===ed,Oa=$y&&Tn.process,Jy=function(){try{var i=Mi&&Mi.require&&Mi.require("util").types;return i||Oa&&Oa.binding&&Oa.binding("util")}catch(e){}}(),Or=Jy;var td=Or&&Or.isTypedArray,Ky=td?Fo(td):Yc,zn=Ky;var Xy=Object.prototype,Zy=Xy.hasOwnProperty;function Qy(i,e){var t=ht(i),r=!t&&mo(i),o=!t&&!r&&Eo(i),n=!t&&!r&&!o&&zn(i),s=t||r||o||n,a=s?$c(i.length,String):[],l=a.length;for(var c in i)(e||Zy.call(i,c))&&!(s&&(c=="length"||o&&(c=="offset"||c=="parent")||n&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||_n(c,l)))&&a.push(c);return a}var En=Qy;function Yy(i,e){return function(t){return i(e(t))}}var Fn=Yy;var eg=Fn(Object.keys,Object),rd=eg;var tg=Object.prototype,rg=tg.hasOwnProperty;function og(i){if(!zo(i))return rd(i);var e=[];for(var t in Object(i))rg.call(i,t)&&t!="constructor"&&e.push(t);return e}var od=og;function ig(i){return Wr(i)?En(i):od(i)}var Ro=ig;function ng(i){var e=[];if(i!=null)for(var t in Object(i))e.push(t);return e}var id=ng;var sg=Object.prototype,ag=sg.hasOwnProperty;function lg(i){if(!St(i))return id(i);var e=zo(i),t=[];for(var r in i)r=="constructor"&&(e||!ag.call(i,r))||t.push(r);return t}var nd=lg;function cg(i){return Wr(i)?En(i,!0):nd(i)}var hr=cg;var dg=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,pg=/^\w*$/;function ug(i,e){if(ht(i))return!1;var t=typeof i;return t=="number"||t=="symbol"||t=="boolean"||i==null||_o(i)?!0:pg.test(i)||!dg.test(i)||e!=null&&i in Object(e)}var sd=ug;var hg=Ot(Object,"create"),Ar=hg;function mg(){this.__data__=Ar?Ar(null):{},this.size=0}var ad=mg;function fg(i){var e=this.has(i)&&delete this.__data__[i];return this.size-=e?1:0,e}var ld=fg;var yg="__lodash_hash_undefined__",gg=Object.prototype,xg=gg.hasOwnProperty;function bg(i){var e=this.__data__;if(Ar){var t=e[i];return t===yg?void 0:t}return xg.call(e,i)?e[i]:void 0}var cd=bg;var vg=Object.prototype,Sg=vg.hasOwnProperty;function wg(i){var e=this.__data__;return Ar?e[i]!==void 0:Sg.call(e,i)}var dd=wg;var Ng="__lodash_hash_undefined__";function Cg(i,e){var t=this.__data__;return this.size+=this.has(i)?0:1,t[i]=Ar&&e===void 0?Ng:e,this}var pd=Cg;function Vo(i){var e=-1,t=i==null?0:i.length;for(this.clear();++e<t;){var r=i[e];this.set(r[0],r[1])}}Vo.prototype.clear=ad;Vo.prototype.delete=ld;Vo.prototype.get=cd;Vo.prototype.has=dd;Vo.prototype.set=pd;var Aa=Vo;function Lg(){this.__data__=[],this.size=0}var ud=Lg;function Tg(i,e){for(var t=i.length;t--;)if(qr(i[t][0],e))return t;return-1}var $r=Tg;var Ig=Array.prototype,Mg=Ig.splice;function Pg(i){var e=this.__data__,t=$r(e,i);if(t<0)return!1;var r=e.length-1;return t==r?e.pop():Mg.call(e,t,1),--this.size,!0}var hd=Pg;function Og(i){var e=this.__data__,t=$r(e,i);return t<0?void 0:e[t][1]}var md=Og;function Ag(i){return $r(this.__data__,i)>-1}var fd=Ag;function jg(i,e){var t=this.__data__,r=$r(t,i);return r<0?(++this.size,t.push([i,e])):t[r][1]=e,this}var yd=jg;function Uo(i){var e=-1,t=i==null?0:i.length;for(this.clear();++e<t;){var r=i[e];this.set(r[0],r[1])}}Uo.prototype.clear=ud;Uo.prototype.delete=hd;Uo.prototype.get=md;Uo.prototype.has=fd;Uo.prototype.set=yd;var Jr=Uo;var _g=Ot(et,"Map"),Kr=_g;function Dg(){this.size=0,this.__data__={hash:new Aa,map:new(Kr||Jr),string:new Aa}}var gd=Dg;function Bg(i){var e=typeof i;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?i!=="__proto__":i===null}var xd=Bg;function Gg(i,e){var t=i.__data__;return xd(e)?t[typeof e=="string"?"string":"hash"]:t.map}var Xr=Gg;function zg(i){var e=Xr(this,i).delete(i);return this.size-=e?1:0,e}var bd=zg;function Eg(i){return Xr(this,i).get(i)}var vd=Eg;function Fg(i){return Xr(this,i).has(i)}var Sd=Fg;function Rg(i,e){var t=Xr(this,i),r=t.size;return t.set(i,e),this.size+=t.size==r?0:1,this}var wd=Rg;function ko(i){var e=-1,t=i==null?0:i.length;for(this.clear();++e<t;){var r=i[e];this.set(r[0],r[1])}}ko.prototype.clear=gd;ko.prototype.delete=bd;ko.prototype.get=vd;ko.prototype.has=Sd;ko.prototype.set=wd;var Pi=ko;var Vg="Expected a function";function ja(i,e){if(typeof i!="function"||e!=null&&typeof e!="function")throw new TypeError(Vg);var t=function(){var r=arguments,o=e?e.apply(this,r):r[0],n=t.cache;if(n.has(o))return n.get(o);var s=i.apply(this,r);return t.cache=n.set(o,s)||n,s};return t.cache=new(ja.Cache||Pi),t}ja.Cache=Pi;var Nd=ja;var Ug=500;function kg(i){var e=Nd(i,function(r){return t.size===Ug&&t.clear(),r}),t=e.cache;return e}var Cd=kg;var Hg=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,qg=/\\(\\)?/g,Wg=Cd(function(i){var e=[];return i.charCodeAt(0)===46&&e.push(""),i.replace(Hg,function(t,r,o,n){e.push(o?n.replace(qg,"$1"):r||t)}),e}),Ld=Wg;function $g(i){return i==null?"":Ac(i)}var Td=$g;function Jg(i,e){return ht(i)?i:sd(i,e)?[i]:Ld(Td(i))}var Ho=Jg;var Kg=1/0;function Xg(i){if(typeof i=="string"||_o(i))return i;var e=i+"";return e=="0"&&1/i==-Kg?"-0":e}var Rn=Xg;function Zg(i,e){e=Ho(e,i);for(var t=0,r=e.length;i!=null&&t<r;)i=i[Rn(e[t++])];return t&&t==r?i:void 0}var Id=Zg;function Qg(i,e){for(var t=-1,r=e.length,o=i.length;++t<r;)i[o+t]=e[t];return i}var qo=Qg;var Md=Ct?Ct.isConcatSpreadable:void 0;function Yg(i){return ht(i)||mo(i)||!!(Md&&i&&i[Md])}var Pd=Yg;function Od(i,e,t,r,o){var n=-1,s=i.length;for(t||(t=Pd),o||(o=[]);++n<s;){var a=i[n];e>0&&t(a)?e>1?Od(a,e-1,t,r,o):qo(o,a):r||(o[o.length]=a)}return o}var Ad=Od;function ex(i){var e=i==null?0:i.length;return e?Ad(i,1):[]}var jd=ex;function tx(i){return jn(Bn(i,void 0,jd),i+"")}var _d=tx;var rx=Fn(Object.getPrototypeOf,Object),Wo=rx;var ox="[object Object]",ix=Function.prototype,nx=Object.prototype,Dd=ix.toString,sx=nx.hasOwnProperty,ax=Dd.call(Object);function lx(i){if(!vt(i)||Ft(i)!=ox)return!1;var e=Wo(i);if(e===null)return!0;var t=sx.call(e,"constructor")&&e.constructor;return typeof t=="function"&&t instanceof t&&Dd.call(t)==ax}var Vn=lx;function cx(i,e,t){var r=-1,o=i.length;e<0&&(e=-e>o?0:o+e),t=t>o?o:t,t<0&&(t+=o),o=e>t?0:t-e>>>0,e>>>=0;for(var n=Array(o);++r<o;)n[r]=i[r+e];return n}var Bd=cx;function dx(){this.__data__=new Jr,this.size=0}var Gd=dx;function px(i){var e=this.__data__,t=e.delete(i);return this.size=e.size,t}var zd=px;function ux(i){return this.__data__.get(i)}var Ed=ux;function hx(i){return this.__data__.has(i)}var Fd=hx;var mx=200;function fx(i,e){var t=this.__data__;if(t instanceof Jr){var r=t.__data__;if(!Kr||r.length<mx-1)return r.push([i,e]),this.size=++t.size,this;t=this.__data__=new Pi(r)}return t.set(i,e),this.size=t.size,this}var Rd=fx;function $o(i){var e=this.__data__=new Jr(i);this.size=e.size}$o.prototype.clear=Gd;$o.prototype.delete=zd;$o.prototype.get=Ed;$o.prototype.has=Fd;$o.prototype.set=Rd;var Un=$o;function yx(i,e){return i&&Kt(e,Ro(e),i)}var Vd=yx;function gx(i,e){return i&&Kt(e,hr(e),i)}var Ud=gx;var kd=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Hd=kd&&typeof module=="object"&&module&&!module.nodeType&&module,xx=Hd&&Hd.exports===kd,qd=xx?et.Buffer:void 0,Wd=qd?qd.allocUnsafe:void 0;function bx(i,e){if(e)return i.slice();var t=i.length,r=Wd?Wd(t):new i.constructor(t);return i.copy(r),r}var kn=bx;function vx(i,e){for(var t=-1,r=i==null?0:i.length,o=0,n=[];++t<r;){var s=i[t];e(s,t,i)&&(n[o++]=s)}return n}var $d=vx;function Sx(){return[]}var Hn=Sx;var wx=Object.prototype,Nx=wx.propertyIsEnumerable,Jd=Object.getOwnPropertySymbols,Cx=Jd?function(i){return i==null?[]:(i=Object(i),$d(Jd(i),function(e){return Nx.call(i,e)}))}:Hn,Jo=Cx;function Lx(i,e){return Kt(i,Jo(i),e)}var Kd=Lx;var Tx=Object.getOwnPropertySymbols,Ix=Tx?function(i){for(var e=[];i;)qo(e,Jo(i)),i=Wo(i);return e}:Hn,qn=Ix;function Mx(i,e){return Kt(i,qn(i),e)}var Xd=Mx;function Px(i,e,t){var r=e(i);return ht(i)?r:qo(r,t(i))}var Wn=Px;function Ox(i){return Wn(i,Ro,Jo)}var Zd=Ox;function Ax(i){return Wn(i,hr,qn)}var $n=Ax;var jx=Ot(et,"DataView"),Jn=jx;var _x=Ot(et,"Promise"),Kn=_x;var Dx=Ot(et,"Set"),Xn=Dx;var Qd="[object Map]",Bx="[object Object]",Yd="[object Promise]",ep="[object Set]",tp="[object WeakMap]",rp="[object DataView]",Gx=Pr(Jn),zx=Pr(Kr),Ex=Pr(Kn),Fx=Pr(Xn),Rx=Pr(On),fo=Ft;(Jn&&fo(new Jn(new ArrayBuffer(1)))!=rp||Kr&&fo(new Kr)!=Qd||Kn&&fo(Kn.resolve())!=Yd||Xn&&fo(new Xn)!=ep||On&&fo(new On)!=tp)&&(fo=function(i){var e=Ft(i),t=e==Bx?i.constructor:void 0,r=t?Pr(t):"";if(r)switch(r){case Gx:return rp;case zx:return Qd;case Ex:return Yd;case Fx:return ep;case Rx:return tp}return e});var Ko=fo;var Vx=Object.prototype,Ux=Vx.hasOwnProperty;function kx(i){var e=i.length,t=new i.constructor(e);return e&&typeof i[0]=="string"&&Ux.call(i,"index")&&(t.index=i.index,t.input=i.input),t}var op=kx;var Hx=et.Uint8Array,_a=Hx;function qx(i){var e=new i.constructor(i.byteLength);return new _a(e).set(new _a(i)),e}var Xo=qx;function Wx(i,e){var t=e?Xo(i.buffer):i.buffer;return new i.constructor(t,i.byteOffset,i.byteLength)}var ip=Wx;var $x=/\w*$/;function Jx(i){var e=new i.constructor(i.source,$x.exec(i));return e.lastIndex=i.lastIndex,e}var np=Jx;var sp=Ct?Ct.prototype:void 0,ap=sp?sp.valueOf:void 0;function Kx(i){return ap?Object(ap.call(i)):{}}var lp=Kx;function Xx(i,e){var t=e?Xo(i.buffer):i.buffer;return new i.constructor(t,i.byteOffset,i.length)}var Zn=Xx;var Zx="[object Boolean]",Qx="[object Date]",Yx="[object Map]",e0="[object Number]",t0="[object RegExp]",r0="[object Set]",o0="[object String]",i0="[object Symbol]",n0="[object ArrayBuffer]",s0="[object DataView]",a0="[object Float32Array]",l0="[object Float64Array]",c0="[object Int8Array]",d0="[object Int16Array]",p0="[object Int32Array]",u0="[object Uint8Array]",h0="[object Uint8ClampedArray]",m0="[object Uint16Array]",f0="[object Uint32Array]";function y0(i,e,t){var r=i.constructor;switch(e){case n0:return Xo(i);case Zx:case Qx:return new r(+i);case s0:return ip(i,t);case a0:case l0:case c0:case d0:case p0:case u0:case h0:case m0:case f0:return Zn(i,t);case Yx:return new r;case e0:case o0:return new r(i);case t0:return np(i);case r0:return new r;case i0:return lp(i)}}var cp=y0;function g0(i){return typeof i.constructor=="function"&&!zo(i)?zc(Wo(i)):{}}var Qn=g0;var x0="[object Map]";function b0(i){return vt(i)&&Ko(i)==x0}var dp=b0;var pp=Or&&Or.isMap,v0=pp?Fo(pp):dp,up=v0;var S0="[object Set]";function w0(i){return vt(i)&&Ko(i)==S0}var hp=w0;var mp=Or&&Or.isSet,N0=mp?Fo(mp):hp,fp=N0;var C0=1,L0=2,T0=4,yp="[object Arguments]",I0="[object Array]",M0="[object Boolean]",P0="[object Date]",O0="[object Error]",gp="[object Function]",A0="[object GeneratorFunction]",j0="[object Map]",_0="[object Number]",xp="[object Object]",D0="[object RegExp]",B0="[object Set]",G0="[object String]",z0="[object Symbol]",E0="[object WeakMap]",F0="[object ArrayBuffer]",R0="[object DataView]",V0="[object Float32Array]",U0="[object Float64Array]",k0="[object Int8Array]",H0="[object Int16Array]",q0="[object Int32Array]",W0="[object Uint8Array]",$0="[object Uint8ClampedArray]",J0="[object Uint16Array]",K0="[object Uint32Array]",Fe={};Fe[yp]=Fe[I0]=Fe[F0]=Fe[R0]=Fe[M0]=Fe[P0]=Fe[V0]=Fe[U0]=Fe[k0]=Fe[H0]=Fe[q0]=Fe[j0]=Fe[_0]=Fe[xp]=Fe[D0]=Fe[B0]=Fe[G0]=Fe[z0]=Fe[W0]=Fe[$0]=Fe[J0]=Fe[K0]=!0;Fe[O0]=Fe[gp]=Fe[E0]=!1;function Yn(i,e,t,r,o,n){var s,a=e&C0,l=e&L0,c=e&T0;if(t&&(s=o?t(i,r,o,n):t(i)),s!==void 0)return s;if(!St(i))return i;var d=ht(i);if(d){if(s=op(i),!a)return An(i,s)}else{var p=Ko(i),u=p==gp||p==A0;if(Eo(i))return kn(i,a);if(p==xp||p==yp||u&&!o){if(s=l||u?{}:Qn(i),!a)return l?Xd(i,Ud(s,i)):Kd(i,Vd(s,i))}else{if(!Fe[p])return o?i:{};s=cp(i,p,a)}}n||(n=new Un);var f=n.get(i);if(f)return f;n.set(i,s),fp(i)?i.forEach(function(y){s.add(Yn(y,e,t,y,i,n))}):up(i)&&i.forEach(function(y,N){s.set(N,Yn(y,e,t,N,i,n))});var m=c?l?$n:Zd:l?hr:Ro,x=d?void 0:m(i);return Uc(x||i,function(y,N){x&&(N=y,y=i[N]),Dn(s,N,Yn(y,e,t,N,i,n))}),s}var es=Yn;var X0=1,Z0=4;function Q0(i){return es(i,X0|Z0)}var yo=Q0;function Y0(i){return function(e,t,r){for(var o=-1,n=Object(e),s=r(e),a=s.length;a--;){var l=s[i?a:++o];if(t(n[l],l,n)===!1)break}return e}}var bp=Y0;var eb=bp(),vp=eb;function tb(i,e,t){(t!==void 0&&!qr(i[e],t)||t===void 0&&!(e in i))&&Go(i,e,t)}var Oi=tb;function rb(i){return vt(i)&&Wr(i)}var Sp=rb;function ob(i,e){if(!(e==="constructor"&&typeof i[e]=="function")&&e!="__proto__")return i[e]}var Ai=ob;function ib(i){return Kt(i,hr(i))}var wp=ib;function nb(i,e,t,r,o,n,s){var a=Ai(i,t),l=Ai(e,t),c=s.get(l);if(c){Oi(i,t,c);return}var d=n?n(a,l,t+"",i,e,s):void 0,p=d===void 0;if(p){var u=ht(l),f=!u&&Eo(l),m=!u&&!f&&zn(l);d=l,u||f||m?ht(a)?d=a:Sp(a)?d=An(a):f?(p=!1,d=kn(l,!0)):m?(p=!1,d=Zn(l,!0)):d=[]:Vn(l)||mo(l)?(d=a,mo(a)?d=wp(a):(!St(a)||Do(a))&&(d=Qn(l))):p=!1}p&&(s.set(l,d),o(d,l,r,n,s),s.delete(l)),Oi(i,t,d)}var Np=nb;function Cp(i,e,t,r,o){i!==e&&vp(e,function(n,s){if(o||(o=new Un),St(n))Np(i,e,s,t,Cp,r,o);else{var a=r?r(Ai(i,s),n,s+"",i,e,o):void 0;a===void 0&&(a=n),Oi(i,s,a)}},hr)}var Lp=Cp;function sb(i){var e=i==null?0:i.length;return e?i[e-1]:void 0}var Tp=sb;function ab(i,e){return e.length<2?i:Id(i,Bd(e,0,-1))}var Ip=ab;var lb=Wc(function(i,e,t){Lp(i,e,t)}),go=lb;function cb(i,e){return e=Ho(e,i),i=Ip(i,e),i==null||delete i[Rn(Tp(e))]}var Mp=cb;function db(i){return Vn(i)?void 0:i}var Pp=db;var pb=1,ub=2,hb=4,mb=_d(function(i,e){var t={};if(i==null)return t;var r=!1;e=In(e,function(n){return n=Ho(n,i),r||(r=n.length>1),n}),Kt(i,$n(i),t),r&&(t=es(t,pb|ub|hb,Pp));for(var o=e.length;o--;)Mp(t,e[o]);return t}),Zo=mb;var Qo;(function(t){t.all=["PerspectiveCamera","OrthographicCamera"];function e(r){return t.all.includes(r)}t.is=e})(Qo||(Qo={}));var xo;(function(o){o.DefaultUp=[0,1,0],o.DefaultTargetOffset=1e3,o.defaultData={far:5e5,type:"OrthographicCamera",perspective:{near:5,fov:45,zoom:1},orthographic:{near:-5e5,zoom:1},up:o.DefaultUp,isUpVectorFlipped:!1,targetOffset:o.DefaultTargetOffset};function r(n){return n.type==="PerspectiveCamera"?n.perspective.zoom:n.orthographic.zoom}o.getZoom=r})(xo||(xo={}));var Yo;(function(r){r.x="x",r.y="y",r.z="z"})(Yo||(Yo={}));var Op;(function(n){n.Top="top",n.Right="right",n.Bottom="bottom",n.Left="left",n.Center="center"})(Op||(Op={}));var Ap;(function(t){function i(r,o){return r[0]===o[0]&&r[1]===o[1]}t.isEqual=i;function e(r,o,n){return[r[0]+(o[0]-r[0])*n,r[1]+(o[1]-r[1])*n]}t.lerp=e})(Ap||(Ap={}));var ei;(function(o){function i(n,s){return n[0]===s[0]&&n[1]===s[1]&&n[2]===s[2]}o.isEqual=i;function e(n,s){return[n[0]+s[0],n[1]+s[1],n[2]+s[2]]}o.add=e;function t(n,s){return[n[0]-s[0],n[1]-s[1],n[2]-s[2]]}o.sub=t;function r(n,s,a){return[n[0]+(s[0]-n[0])*a,n[1]+(s[1]-n[1])*a,n[2]+(s[2]-n[2])*a]}o.lerp=r})(ei||(ei={}));var jp;(function(t){function i(r,o){return r[0]===o[0]&&r[1]===o[1]&&r[2]===o[2]&&r[3]===o[3]}t.isEqual=i;function e(r,o,n){return[r[0]+(o[0]-r[0])*n,r[1]+(o[1]-r[1])*n,r[2]+(o[2]-r[2])*n,r[3]+(o[3]-r[3])*n]}t.lerp=e})(jp||(jp={}));var Zr;(function(n){n.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function e(s,a){for(let l=0;l<16;l++)if(s[l]!==a[l])return!1;return!0}n.isEqual=e;function t(s){return s!=null?s:n.identity}n.simplify=t;function r(s,a){let l=a.slice(0);for(var c=0,d=a.length;c<d;c+=3){let p=1/(s[3]*a[c]+s[7]*a[c+1]+s[11]*a[c+2]+s[15]);l[c]=(s[0]*a[c]+s[4]*a[c+1]+s[8]*a[c+2]+s[12])*p,l[c+1]=(s[1]*a[c]+s[5]*a[c+1]+s[9]*a[c+2]+s[13])*p,l[c+2]=(s[2]*a[c]+s[6]*a[c+1]+s[10]*a[c+2]+s[14])*p}return l}n.applyMatrix4=r;function o(s,a){let l=a.slice(0);for(var c=0,d=a.length;c<d;c+=3)l[c]=s[0]*a[c]+s[4]*a[c+1]+s[8]*a[c+2],l[c+1]=s[1]*a[c]+s[5]*a[c+1]+s[9]*a[c+2],l[c+2]=s[2]*a[c]+s[6]*a[c+1]+s[10]*a[c+2];return l}n.applyMatrix3Components=o})(Zr||(Zr={}));var Rt;(function(l){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 r(c){return{r:Math.round(c.r*255),g:Math.round(c.g*255),b:Math.round(c.b*255),a:1}}l.toRgb255a1=r;function o(c){return{r:c.r,g:c.g,b:c.b}}l.clone=o;function n(c){return c=Math.floor(c),{r:(c>>16&255)/255,g:(c>>8&255)/255,b:(c&255)/255}}l.fromHex=n;function s(c,d){return c.r===d.r&&c.g===d.g&&c.b===d.b}l.equals=s;function a(c,d,p){return{r:c.r+(d.r-c.r)*p,g:c.g+(d.g-c.g)*p,b:c.b+(d.b-c.b)*p}}l.lerp=a})(Rt||(Rt={}));var mr;(function(n){n.white=$(O({},Rt.white),{a:1});function e(s){return{r:s[0],g:s[1],b:s[2],a:s[3]}}n.from0to1=e;function t(s,a){return $(O({},Rt.fromHex(s)),{a})}n.fromHexAndA=t;function r(s){return{r:Math.round(s.r*255),g:Math.round(s.g*255),b:Math.round(s.b*255),a:s.a}}n.toRgb255a1=r;function o(s,a){return Rt.equals(s,a)&&s.a===a.a}n.equals=o})(mr||(mr={}));var ts;(function(e){e.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]}})(ts||(ts={}));var _p;(function(w){w[w.SKIP=0]="SKIP",w[w.ADD=1]="ADD",w[w.ALPHA=2]="ALPHA",w[w.AVERAGE=3]="AVERAGE",w[w.COLOR_BURN=4]="COLOR_BURN",w[w.COLOR_DODGE=5]="COLOR_DODGE",w[w.DARKEN=6]="DARKEN",w[w.DIFFERENCE=7]="DIFFERENCE",w[w.EXCLUSION=8]="EXCLUSION",w[w.LIGHTEN=9]="LIGHTEN",w[w.MULTIPLY=10]="MULTIPLY",w[w.DIVIDE=11]="DIVIDE",w[w.NEGATION=12]="NEGATION",w[w.NORMAL=13]="NORMAL",w[w.OVERLAY=14]="OVERLAY",w[w.REFLECT=15]="REFLECT",w[w.SCREEN=16]="SCREEN",w[w.SOFT_LIGHT=17]="SOFT_LIGHT",w[w.SUBTRACT=18]="SUBTRACT"})(_p||(_p={}));var Dp;(function(a){a[a.LINEAR=0]="LINEAR",a[a.EASE=1]="EASE",a[a.EASE_IN=2]="EASE_IN",a[a.EASE_OUT=3]="EASE_OUT",a[a.EASE_IN_OUT=4]="EASE_IN_OUT",a[a.CUBIC=5]="CUBIC",a[a.SPRING=6]="SPRING"})(Dp||(Dp={}));var Bp;(function(e){e.defaultData={mass:1,stiffness:80,damping:10,velocity:0}})(Bp||(Bp={}));var Gp;(function(e){e.defaultData={control1:[.5,.05],control2:[.1,.3]}})(Gp||(Gp={}));var rs;(function(e){function i(t,r=.1){return{type:"radial",hideBase:!1,count:3,radial:{radius:Math.max(t[0],t[1])*2,start:0,end:360,alignment:!1,axis:Yo.y,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0]},linear:{scale:[0,0,0],rotation:[0,0,0],position:[t[0]+t[0]*r,0,0]},grid:{count:[2,2,2],size:t.map(o=>o*(1+r)),useCenter:!0}}}e.defaultData=i})(rs||(rs={}));var jr;(function(e){e[e.Update=0]="Update"})(jr||(jr={}));var Xt;(function(r){r[r.Add=1]="Add",r[r.Delete=2]="Delete",r[r.Unlink=3]="Unlink"})(Xt||(Xt={}));var Vt;(function(r){r[r.Add=4]="Add",r[r.Delete=5]="Delete",r[r.Move=6]="Move"})(Vt||(Vt={}));var At;(function(r){r[r.Add=7]="Add",r[r.Delete=8]="Delete",r[r.Move=9]="Move"})(At||(At={}));var nr=class{modifyById(e,t){let r=this;if(r[e]===void 0)throw new Error("not expected");{let n=$(O({},r),{[e]:t});return Object.setPrototypeOf(n,nr.prototype),n}}add(e,t){var o;let r=this.runOp({type:Xt.Add,id:e,data:t});return(o=r==null?void 0:r.data)!=null?o:this}runOp(e){let t=this;if(e.type===Xt.Add){let r=t[e.id],o;r===void 0?o={type:Xt.Delete,id:e.id}:o={type:Xt.Add,id:e.id,data:r};let{id:n,data:s}=e,a=$(O({},t),{[n]:s});return Object.setPrototypeOf(a,nr.prototype),{data:a,actual:e,reverse:o}}else if(e.type===Xt.Delete){let{id:r}=e,o=t[r];if(o===void 0)return null;{let n=O({},t);return Object.setPrototypeOf(n,nr.prototype),delete n[r],{data:n,actual:e,reverse:{type:Xt.Add,id:r,data:o}}}}throw new Error("illegal arg")}};function ji(i){if(i.deepFreeze!==void 0){i.deepFreeze(i);return}let e=Object.getOwnPropertyNames(i);for(let t of e){let r=i[t];r&&typeof r=="object"&&ji(r)}return Object.freeze(i)}function zp(i,e){let t=0;for(;t<i.length&&t<e.length;){if(i[t]<e[t])return-1;if(i[t]>e[t])return 1;t+=1}return t!==e.length?-1:t!==i.length?1:0}var Da=class extends Error{};function fr(i,e,t){if(i===void 0?e===void 0?(i=0,e=10):i=e-10:e===void 0&&(e=i+10),i>e){let n=i;i=e,e=n}let r=[],o=1/(t+1);for(let n=0;n<t;n++){let s=i+(e-i)*(n+.75+Math.random()*.5)*o;r.push(s)}return r}function Ep(i){return i instanceof Uint8Array||i instanceof Uint16Array||i instanceof Uint32Array||i instanceof Int8Array||i instanceof Int16Array||i instanceof Int32Array||i instanceof Float32Array||i instanceof Float64Array}function Fp(){return typeof process!="undefined"}function Rp(i,e){for(let t of i)e(t.id,t.data),Rp(t.children,e)}function Vp(i,e){e(i.id,i.data);for(let t of i.children)Vp(t,e)}var sr=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,sr.prototype)}deepFreeze(){let e=0;for(;e<this.length;)ji(this[e]),e++}fillCaches0(e,t){var r;if((r=this.objCaches)==null?void 0:r.has(e.id))throw new Error("duplicated item");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)]}isDescendantOf(e,t){for(;e;){let r=this.parent(e);if(r===t)return!0;e=r}return!1}data(e){var t;return(t=this.get(e))==null?void 0:t.data}has(e){return this.childrenOf(e)!==void 0}get(e){return this.fillCaches(),this.objCaches.get(e)}childrenOf(e){var t;return e===null?this:(t=this.get(e))==null?void 0:t.children}traverseFrom(e,t){if(e===null)this.traverse(t);else{let r=this.get(e);r&&Vp(r,t)}}traverse(e){Rp(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 o=this.parent(e),n=this.childrenArray(o),s=n.findIndex(c=>c.id===e);if(s<0)throw new Error("not expected");let a=n[s];return n=[...n],n[s]=$(O({},a),{data:t}),this.modifyArrayBy(o,n)}}modifyArrayBy(e,t){let r=e,o=t;for(;r!==null;){let s=o,a=r;if(r=this.parent(r),r===void 0)throw new Error;o=this.childrenArray(r);let l=o.findIndex(c=>c.id===a);if(l<0)throw new Error;o=[...o],o[l]=$(O({},o[l]),{children:s})}Object.setPrototypeOf(o,sr.prototype);let n=o;return n.fillCaches(),n}runOp(e){switch(e.type){case At.Add:return this.addOp(e);case At.Delete:return this.deleteOp(e);case At.Move:return this.moveOp(e)}}addOp(e){let{parent:t,fi:r,id:o,data:n,children:s}=e;if(t!==null&&this.get(t)===void 0)return null;if(this.get(o)!==void 0)return null;{let a=t,l=this.childrenArray(a),c={fi:r,id:o,data:n,children:s};return l=[...l,c],l.sort((p,u)=>p.fi-u.fi),e.localIndex=l.indexOf(c),{data:this.modifyArrayBy(a,l),actual:e,reverse:{type:At.Delete,id:o}}}}deleteOp(e){let{id:t}=e;if(this.get(t)===null)return null;{let r=this.parent(t);if(r===void 0)return null;let o=this.childrenArray(r),n=o.findIndex(l=>l.id===t);e.localIndex=n,o=[...o];let s=o.splice(n,1)[0];return{data:this.modifyArrayBy(r,o),actual:e,reverse:$(O({type:At.Add},s),{parent:r})}}}moveOp(e){let{parent:t,fi:r,id:o}=e;if(t!==null&&this.get(t)===void 0)return this.deleteOp({type:At.Delete,id:o});if(t!==null){let u=t;for(;u!==null;){if(u===void 0)throw new Error;if(u===o)throw new Da("cyclic tree");u=this.parent(u)}}let n=this.parent(o);if(n===void 0)return null;let s=n,a=this.childrenArray(n),l=a.findIndex(u=>u.id===o);a=[...a];let c=a.splice(l,1)[0],d=this.modifyArrayBy(n,a);n=t,a=d.childrenArray(n);let p=c.fi;return c=$(O({},c),{fi:r}),a=[...a,c],a.sort((u,f)=>u.fi-f.fi),e.localIndex=a.indexOf(c),d=d.modifyArrayBy(n,a),{data:d,actual:e,reverse:{type:At.Move,parent:s,fi:p,id:o}}}previous(e,t){if(t===null){let o=this.childrenArray(e);return o.length===0?null:o[o.length-1].id}let r=null;for(let o of this.childrenArray(e)){if(o.id===t)return r;r=o.id}return null}traverseSortNext(e){let t=this.parent(e);if(t!==void 0){let r=this.childrenArray(t),o=r.findIndex(n=>n.id===e)+1;if(o<r.length)return r[o].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 r=this.childrenArray(t),o=r.findIndex(n=>n.id===e)-1;return o>=0?this.traverseSortPrevious(r[o].id):t}}getAllSorted(e){let t=[];for(let r of e){let o=this.getWithSortKey(r.id);o!==void 0&&t.push(O(O({},r),o))}t.sort((r,o)=>zp(r.sortKey,o.sortKey));for(let r of t)delete r.sortKey;return t}getWithSortKey(e){var t=e;let r=[],o=this.get(t),n=o;if(o!==void 0){for(;t;)r.splice(0,0,o.fi),t=this.parent(t),t!==null&&(o=this.get(t));return $(O({},n),{sortKey:r})}}insertBeforeHelper(e,t,r){return this.insertAfterHelper(e,this.previous(e,t),r)}insertAfterHelper(e,t,r){let o=this.childrenArray(e);if(t===null){if(o.length===0)return fr(0,r,r);{let n=o[0].fi;return fr(n-r,n,r)}}else{let n=this.get(t);if(n===void 0||this.parent(t)!==e)throw new Error("illegal args");let s=o.find(a=>a.fi>n.fi);if(s===void 0){let a=o[o.length-1].fi;return fr(a,a+r,r)}else return fr(n.fi,s.fi,r)}}};var os;(function(e){function i(t,r){if(Array.isArray(t)){let o=r.props,n={},s=[...t],a=!1;if(o)for(let l of Object.keys(o)){let c=parseInt(l);if(isNaN(c))throw new Error("wrong index");n[l]=s[c],s[c]=o[l],a=!0}return a?{data:s,actual:r,reverse:{type:jr.Update,props:n}}:null}else{let o=r.props,n={},s=O({},t),a=!1;if(o)for(let l of Object.keys(o))n[l]=s[l],s[l]=o[l],a=!0;return a?{data:s,actual:r,reverse:{type:jr.Update,props:n}}:null}}e.runOp=i})(os||(os={}));var Ke=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,Ke.prototype)}deepFreeze(){let e=0;for(;e<this.length;)ji(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){var t;return(t=this.get(e))==null?void 0:t.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 o=this,n=o.findIndex(l=>l.id===e);if(n<0)throw new Error("not expected");let s=o[n];return o=[...o],o[n]=$(O({},s),{data:t}),this.modifyArrayBy(o)}}modifyArrayBy(e){Object.setPrototypeOf(e,Ke.prototype);let t=e;return Fp()||t.fillCaches(),t}runOp(e){switch(e.type){case Vt.Add:return this.addOp(e);case Vt.Delete:return this.deleteOp(e);case Vt.Move:return this.moveOp(e)}}addOp(e){let{fi:t,id:r,data:o}=e,n=this,s={fi:t,id:r,data:o};return n=[...n,s],n.sort((l,c)=>l.fi-c.fi),e.localIndex=n.indexOf(s),{data:this.modifyArrayBy(n),actual:e,reverse:{type:Vt.Delete,id:r}}}deleteOp(e){let{id:t}=e,r=this,o=r.findIndex(a=>a.id===t);if(o===-1)return null;e.localIndex=o,r=[...r];let n=r.splice(o,1)[0];return{data:this.modifyArrayBy(r),actual:e,reverse:O({type:Vt.Add},n)}}moveOp(e){let{fi:t,id:r}=e,o=this;o=[...o];let n=o.findIndex(c=>c.id===r);if(n===-1)return null;let s=o[n].fi,a=$(O({},o[n]),{fi:t});return o[n]=a,o.sort((c,d)=>c.fi-d.fi),e.localIndex=o.indexOf(a),{data:this.modifyArrayBy(o),actual:e,reverse:{type:Vt.Move,fi:s,id:r}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let t=null;for(let r of this){if(r.id===e)return t;t=r.id}return null}insertBeforeHelper(e,t){return this.insertAfterHelper(this.previous(e),t)}insertAfterHelper(e,t){let r=this;if(e===null){if(r.length===0)return fr(0,t,t);{let o=r[0].fi;return fr(o-t,o,t)}}else{let o=this.get(e);if(o===void 0)throw new Error("illegal args");let n=r.find(s=>s.fi>o.fi);if(n===void 0){let s=r[r.length-1].fi;return fr(s,s+t,t)}else return fr(o.fi,n.fi,t)}}};var Up=Symbol(),is=Symbol(),_i=class{reportOp(e,t){let r=this;if(t===null)return;r._current=t.data;let o=[];for(;!(r instanceof Ga);){let n=r._path,s=r._current;if(n!==""&&o.splice(0,0,n),r=r._parent,r===null)return;r.update(n,s)}r.push(o,e,t.actual,t.reverse)}deleteChildren(e){if(this._children){let t=this._children[e];if(t){let r=t[is];r&&r(),delete this._children[e]}}}},kp=class extends _i{constructor(e,t,r){super();this._parent=e,this._path=t,this._current=r}update(e,t){if(Array.isArray(this._current)){if(typeof e=="string"&&(e=parseInt(e),isNaN(e)))throw new Error("Invalid path");this._current=[...this._current],this._current[e]=t}else this._current=$(O({},this._current),{[e]:t})}runOp(e){this.reportOp(e,os.runOp(this._current,e))}},Hp=class extends _i{constructor(e,t,r){super();this._parent=e,this._path=t,this._current=r}update(e,t){this._current=$(O({},this._current),{[e]:t}),Object.setPrototypeOf(this._current,nr.prototype)}runOp(e){this.reportOp(e,this._current.runOp(e))}},qp={get(i,e){if(e===is)return()=>{i._parent=null};if(e===Up)return i._current;let{_current:t,_children:r}=i;if(e==="push"&&Array.isArray(t))throw new Error("not supported to expand array");let o=r===void 0?void 0:r[e];if(o!==void 0)return o;let n=t[e],s=ns(i,e,n);return s!==n?(r===void 0&&(r={},i._children=r),r[e]=s,s):n},has(i,e){return e in i._current},ownKeys(i){return Reflect.ownKeys(i._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(i){return Object.getPrototypeOf(i._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(i,e){let t=i._current,r=Reflect.getOwnPropertyDescriptor(t,e);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:t[e]}}},fb=$(O({},qp),{set(i,e,t){var o;let r;if(t===void 0)throw new Error("set to undefined is not supported!");return r={type:jr.Update,props:{[e]:(o=xb(t))!=null?o:t}},i.deleteChildren(e),i.runOp(r),!0},deleteProperty(i,e){throw new Error("set to undefined is not supported!")}}),yb=$(O({},qp),{set(i,e,t){return t===void 0?this.deleteProperty(i,e):(i.deleteChildren(e),i.runOp({type:Xt.Add,id:e,data:t})),!0},deleteProperty(i,e){return i.runOp({type:Xt.Delete,id:e}),!0}}),Di=class extends _i{constructor(e,t,r){super();this._children={},this._parent=e,this._path=t,this._current=r,this[is]=()=>{this._parent=null}}unproxy(){return this._current}update(e,t){this._current=this._current.modifyById(e,t)}runOp(e){this.reportOp(e,this._current.runOp(e))}randomId(){return this._current.randomId()}isDescendantOf(e,t){return this._current.isDescendantOf(e,t)}childrenOf(e){return this._current.childrenOf(e)}traverse(e){return this._current.traverse(e)}get(e){return this._current.get(e)}parent(e){return this._current.parent(e)}data(e){var a;let{_current:t,_children:r}=this,o=r===void 0?void 0:r[e];if(o!==void 0)return o;let n=(a=t.get(e))==null?void 0:a.data,s=ns(this,e,n);return s!==n?(r===void 0&&(r={},this._children=r),r[e]=s,s):n}add(e,t,r,o,n){this.runOp({type:At.Add,parent:e,fi:t,id:r,data:o,children:n})}move(e,t,r){this.runOp({type:At.Move,parent:e,fi:t,id:r})}insertAfter(e,t,r){let o=this._current.insertAfterHelper(e,t,r.length);for(let n=0;n<r.length;n++){let s=r[n];this.add(e,o[n],s.id,s.data,s.children)}}insertBefore(e,t,r){let o=this._current.insertBeforeHelper(e,t,r.length);for(let n=0;n<r.length;n++){let s=r[n];this.add(e,o[n],s.id,s.data,s.children)}}moveAfter(e,t,r){let o=this._current.insertAfterHelper(e,t,r.length);for(let n=0;n<r.length;n++){let s=r[n];this.move(e,o[n],s)}}moveBefore(e,t,r){let o=this._current.insertBeforeHelper(e,t,r.length);for(let n=0;n<r.length;n++){let s=r[n];this.move(e,o[n],s)}}delete(e){this.deleteChildren(e),this.runOp({type:At.Delete,id:e})}sortNext(e){return this._current.sortNext(e)}sortPrevious(e){return this._current.sortPrevious(e)}getAllSorted(e){return this._current.getAllSorted(e)}},Bi=class extends _i{constructor(e,t,r){super();this._children={},this._parent=e,this._path=t,this._current=r,this[is]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(e){let t=this.length;for(let r=0;r<t;r++){let o=this._current[r].id;e(this.data(this._current[r].id),o)}}update(e,t){this._current=this._current.modifyById(e,t)}randomId(){return this._current.randomId()}get(e){return $(O({},this._current.get(e)),{data:this.data(e)})}data(e){var a;let{_current:t,_children:r}=this,o=r===void 0?void 0:r[e];if(o!==void 0)return o;let n=(a=t.get(e))==null?void 0:a.data,s=ns(this,e,n);return s!==n?(r===void 0&&(r={},this._children=r),r[e]=s,s):n}runOp(e){this.reportOp(e,this._current.runOp(e))}add(e,t,r){this.runOp({type:Vt.Add,fi:e,id:t,data:r})}move(e,t){this.runOp({type:Vt.Move,fi:e,id:t})}insertAfter(e,t){let r=this._current.insertAfterHelper(e,t.length);for(let o=0;o<t.length;o++){let n=t[o];this.add(r[o],n.id,n.data)}}insertBefore(e,t){let r=this._current.insertBeforeHelper(e,t.length);for(let o=0;o<t.length;o++){let n=t[o];this.add(r[o],n.id,n.data)}}moveAfter(e,t){let r=this._current.insertAfterHelper(e,t.length);for(let o=0;o<t.length;o++){let n=t[o];this.move(r[o],n)}}moveBefore(e,t){let r=this._current.insertBeforeHelper(e,t.length);for(let o=0;o<t.length;o++){let n=t[o];this.move(r[o],n)}}delete(e){this.deleteChildren(e),this.runOp({type:Vt.Delete,id:e})}};function Ba(i,e,t){if(i.length>0){let r=i[i.length-1];if(r.type===jr.Update&&e.type===jr.Update&&ss.equal(r.path,t)){Object.assign(r.props,e.props);return}}i.push($(O({},e),{path:t}))}var Ga=class{constructor(e){this.ts=[],this.actual=[],this.reverse=[],this._current=e}update(e,t){if(e!=="")throw new Error("");this._current=t}push(e,t,r,o){Ba(this.ts,t,e),Ba(this.actual,r,e),Ba(this.reverse,o,e)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function ns(i,e,t){return t instanceof sr?new Di(i,e,t):t instanceof Ke?new Bi(i,e,t):t instanceof nr?new Proxy(new Hp(i,e,t),yb):t!==null&&typeof t=="object"?Ep(t)?t:new Proxy(new kp(i,e,t),fb):t}function gb(i){let e=new Ga(i);return[ns(e,"",i),e]}function za(i,e){let[t,r]=gb(i);return e(t),r.result()}function xb(i){return i instanceof Di||i instanceof Bi?i._current:i!==null&&typeof i=="object"?i[Up]:i}var ss;(function(r){function i(o,n){if(n.length===o.length)for(var s=0;s<o.length;){if(o[s]!==n[s])return!1;s+=1}else return!1;return!0}r.equal=i;function e(o,n,s){let a=t(s,o);if(a!==void 0&&typeof a=="object"&&a!==null){let l=O({},n);return Object.keys(a).forEach(c=>{delete l[c]}),l}else return n}r.removeOverridden=e;function t(o,n,s=0){if(n.length<=s)return o;if((o instanceof sr||o instanceof Di)&&typeof n[s]=="string")return t(o.data(n[s]),n,s+1);if((o instanceof Ke||o instanceof Bi)&&typeof n[s]=="string")return t(o.data(n[s]),n,s+1);if(typeof n[s]=="number"&&Array.isArray(o))return t(o[n[s]],n,s+1);if(typeof n[s]=="string"&&typeof o=="object")return t(o[n[s]],n,s+1)}r.zoom=t})(ss||(ss={}));var Ea=class{},as=class extends Ea{constructor(e){super();this.id=e}},ls=class extends Ea{constructor(e){super();this.data=e}};"use strict";var Fa;try{Fa=new TextDecoder}catch(i){}var Q,Qr,C=0;var Wp=[],Ra=Wp,Va=0,jt={},Me,Yr,Zt=0,yr=0,Ut,_r,Lt=[],Ae,$p={useRecords:!1,mapsAsObjects:!0},cs=class{},Ua=new cs;Ua.name="MessagePack 0xC1";var ti=!1,Dr=class{constructor(e){e&&(e.useRecords===!1&&e.mapsAsObjects===void 0&&(e.mapsAsObjects=!0),e.structures?e.structures.sharedLength=e.structures.length:e.getStructures&&((e.structures=[]).uninitialized=!0,e.structures.sharedLength=0)),Object.assign(this,e)}unpack(e,t){if(Q)return iu(()=>(us(),this?this.unpack(e,t):Dr.prototype.unpack.call($p,e,t)));Qr=t>-1?t:e.length,C=0,Va=0,yr=0,Yr=null,Ra=Wp,Ut=null,Q=e;try{Ae=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(r){throw Q=null,e instanceof Uint8Array?r:new Error("Source must be a Uint8Array or Buffer but was a "+(e&&typeof e=="object"?e.constructor.name:typeof e))}if(this instanceof Dr){if(jt=this,this.structures)return Me=this.structures,ds();(!Me||Me.length>0)&&(Me=[])}else jt=$p,(!Me||Me.length>0)&&(Me=[]);return ds()}unpackMultiple(e,t){let r,o=0;try{ti=!0;let n=e.length,s=this?this.unpack(e,n):ms.unpack(e,n);if(t){for(t(s);C<n;)if(o=C,t(ds())===!1)return}else{for(r=[s];C<n;)o=C,r.push(ds());return r}}catch(n){throw n.lastPosition=o,n.values=r,n}finally{ti=!1,us()}}_mergeStructures(e,t){e=e||[];for(let r=0,o=e.length;r<o;r++){let n=e[r];n&&(n.isShared=!0,r>=32&&(n.highByte=r-32>>5))}e.sharedLength=e.length;for(let r in t||[])if(r>=0){let o=e[r],n=t[r];n&&(o&&((e.restoreStructures||(e.restoreStructures=[]))[r]=o),e[r]=n)}return this.structures=e}decode(e,t){return this.unpack(e,t)}};function ds(){try{if(!jt.trusted&&!ti){let e=Me.sharedLength||0;e<Me.length&&(Me.length=e)}let i=Xe();if(C==Qr)Me.restoreStructures&&Jp(),Me=null,Q=null,_r&&(_r=null);else if(C>Qr){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}else if(!ti)throw new Error("Data read, but end of buffer not reached");return i}catch(i){throw Me.restoreStructures&&Jp(),us(),(i instanceof RangeError||i.message.startsWith("Unexpected end of buffer"))&&(i.incomplete=!0),i}}function Jp(){for(let i in Me.restoreStructures)Me[i]=Me.restoreStructures[i];Me.restoreStructures=null}function Xe(){let i=Q[C++];if(i<160)if(i<128){if(i<64)return i;{let e=Me[i&63]||jt.getStructures&&Xp()[i&63];return e?(e.read||(e.read=ka(e,i&63)),e.read()):i}}else if(i<144)if(i-=128,jt.mapsAsObjects){let e={};for(let t=0;t<i;t++)e[tu()]=Xe();return e}else{let e=new Map;for(let t=0;t<i;t++)e.set(Xe(),Xe());return e}else{i-=144;let e=new Array(i);for(let t=0;t<i;t++)e[t]=Xe();return e}else if(i<192){let e=i-160;if(yr>=C)return Yr.slice(C-Zt,(C+=e)-Zt);if(yr==0&&Qr<140){let t=e<16?qa(e):Yp(e);if(t!=null)return t}return Ha(e)}else{let e;switch(i){case 192:return null;case 193:return Ut?(e=Xe(),e>0?Ut[1].slice(Ut.position1,Ut.position1+=e):Ut[0].slice(Ut.position0,Ut.position0-=e)):Ua;case 194:return!1;case 195:return!0;case 196:return Wa(Q[C++]);case 197:return e=Ae.getUint16(C),C+=2,Wa(e);case 198:return e=Ae.getUint32(C),C+=4,Wa(e);case 199:return bo(Q[C++]);case 200:return e=Ae.getUint16(C),C+=2,bo(e);case 201:return e=Ae.getUint32(C),C+=4,bo(e);case 202:if(e=Ae.getFloat32(C),jt.useFloat32>2){let t=hs[(Q[C]&127)<<1|Q[C+1]>>7];return C+=4,(t*e+(e>0?.5:-.5)>>0)/t}return C+=4,e;case 203:return e=Ae.getFloat64(C),C+=8,e;case 204:return Q[C++];case 205:return e=Ae.getUint16(C),C+=2,e;case 206:return e=Ae.getUint32(C),C+=4,e;case 207:return jt.int64AsNumber?(e=Ae.getUint32(C)*4294967296,e+=Ae.getUint32(C+4)):e=Ae.getBigUint64(C),C+=8,e;case 208:return Ae.getInt8(C++);case 209:return e=Ae.getInt16(C),C+=2,e;case 210:return e=Ae.getInt32(C),C+=4,e;case 211:return jt.int64AsNumber?(e=Ae.getInt32(C)*4294967296,e+=Ae.getUint32(C+4)):e=Ae.getBigInt64(C),C+=8,e;case 212:if(e=Q[C++],e==114)return ru(Q[C++]&63);{let t=Lt[e];if(t)return t.read?(C++,t.read(Xe())):t.noBuffer?(C++,t()):t(Q.subarray(C,++C));throw new Error("Unknown extension "+e)}case 213:return e=Q[C],e==114?(C++,ru(Q[C++]&63,Q[C++])):bo(2);case 214:return bo(4);case 215:return bo(8);case 216:return bo(16);case 217:return e=Q[C++],yr>=C?Yr.slice(C-Zt,(C+=e)-Zt):vb(e);case 218:return e=Ae.getUint16(C),C+=2,yr>=C?Yr.slice(C-Zt,(C+=e)-Zt):Sb(e);case 219:return e=Ae.getUint32(C),C+=4,yr>=C?Yr.slice(C-Zt,(C+=e)-Zt):wb(e);case 220:return e=Ae.getUint16(C),C+=2,Zp(e);case 221:return e=Ae.getUint32(C),C+=4,Zp(e);case 222:return e=Ae.getUint16(C),C+=2,Qp(e);case 223:return e=Ae.getUint32(C),C+=4,Qp(e);default:if(i>=224)return i-256;if(i===void 0){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}throw new Error("Unknown MessagePack token "+i)}}}var bb=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function ka(i,e){function t(){if(t.count++>2){let o=i.read=new Function("r","return function(){return {"+i.map(n=>bb.test(n)?n+":r()":"["+JSON.stringify(n)+"]:r()").join(",")+"}}")(Xe);return i.highByte===0&&(i.read=Kp(e,i.read)),o()}let r={};for(let o=0,n=i.length;o<n;o++){let s=i[o];r[s]=Xe()}return r}return t.count=0,i.highByte===0?Kp(e,t):t}var Kp=(i,e)=>function(){let t=Q[C++];if(t===0)return e();let r=i<32?-(i+(t<<5)):i+(t<<5),o=Me[r]||Xp()[r];if(!o)throw new Error("Record id is not defined for "+r);return o.read||(o.read=ka(o,i)),o.read()};function Xp(){let i=iu(()=>(Q=null,jt.getStructures()));return Me=jt._mergeStructures(i,Me)}var Ha=ps,vb=ps,Sb=ps,wb=ps;function ps(i){let e;if(i<16&&(e=qa(i)))return e;if(i>64&&Fa)return Fa.decode(Q.subarray(C,C+=i));let t=C+i,r=[];for(e="";C<t;){let o=Q[C++];if((o&128)==0)r.push(o);else if((o&224)==192){let n=Q[C++]&63;r.push((o&31)<<6|n)}else if((o&240)==224){let n=Q[C++]&63,s=Q[C++]&63;r.push((o&31)<<12|n<<6|s)}else if((o&248)==240){let n=Q[C++]&63,s=Q[C++]&63,a=Q[C++]&63,l=(o&7)<<18|n<<12|s<<6|a;l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|l&1023),r.push(l)}else r.push(o);r.length>=4096&&(e+=ct.apply(String,r),r.length=0)}return r.length>0&&(e+=ct.apply(String,r)),e}function Zp(i){let e=new Array(i);for(let t=0;t<i;t++)e[t]=Xe();return e}function Qp(i){if(jt.mapsAsObjects){let e={};for(let t=0;t<i;t++)e[tu()]=Xe();return e}else{let e=new Map;for(let t=0;t<i;t++)e.set(Xe(),Xe());return e}}var ct=String.fromCharCode;function Yp(i){let e=C,t=new Array(i);for(let r=0;r<i;r++){let o=Q[C++];if((o&128)>0){C=e;return}t[r]=o}return ct.apply(String,t)}function qa(i){if(i<4)if(i<2){if(i===0)return"";{let e=Q[C++];if((e&128)>1){C-=1;return}return ct(e)}}else{let e=Q[C++],t=Q[C++];if((e&128)>0||(t&128)>0){C-=2;return}if(i<3)return ct(e,t);let r=Q[C++];if((r&128)>0){C-=3;return}return ct(e,t,r)}else{let e=Q[C++],t=Q[C++],r=Q[C++],o=Q[C++];if((e&128)>0||(t&128)>0||(r&128)>0||(o&128)>0){C-=4;return}if(i<6){if(i===4)return ct(e,t,r,o);{let n=Q[C++];if((n&128)>0){C-=5;return}return ct(e,t,r,o,n)}}else if(i<8){let n=Q[C++],s=Q[C++];if((n&128)>0||(s&128)>0){C-=6;return}if(i<7)return ct(e,t,r,o,n,s);let a=Q[C++];if((a&128)>0){C-=7;return}return ct(e,t,r,o,n,s,a)}else{let n=Q[C++],s=Q[C++],a=Q[C++],l=Q[C++];if((n&128)>0||(s&128)>0||(a&128)>0||(l&128)>0){C-=8;return}if(i<10){if(i===8)return ct(e,t,r,o,n,s,a,l);{let c=Q[C++];if((c&128)>0){C-=9;return}return ct(e,t,r,o,n,s,a,l,c)}}else if(i<12){let c=Q[C++],d=Q[C++];if((c&128)>0||(d&128)>0){C-=10;return}if(i<11)return ct(e,t,r,o,n,s,a,l,c,d);let p=Q[C++];if((p&128)>0){C-=11;return}return ct(e,t,r,o,n,s,a,l,c,d,p)}else{let c=Q[C++],d=Q[C++],p=Q[C++],u=Q[C++];if((c&128)>0||(d&128)>0||(p&128)>0||(u&128)>0){C-=12;return}if(i<14){if(i===12)return ct(e,t,r,o,n,s,a,l,c,d,p,u);{let f=Q[C++];if((f&128)>0){C-=13;return}return ct(e,t,r,o,n,s,a,l,c,d,p,u,f)}}else{let f=Q[C++],m=Q[C++];if((f&128)>0||(m&128)>0){C-=14;return}if(i<15)return ct(e,t,r,o,n,s,a,l,c,d,p,u,f,m);let x=Q[C++];if((x&128)>0){C-=15;return}return ct(e,t,r,o,n,s,a,l,c,d,p,u,f,m,x)}}}}}function Wa(i){return jt.copyBuffers?Uint8Array.prototype.slice.call(Q,C,C+=i):Q.subarray(C,C+=i)}function bo(i){let e=Q[C++];if(Lt[e])return Lt[e](Q.subarray(C,C+=i));throw new Error("Unknown extension type "+e)}var eu=new Array(4096);function tu(){let i=Q[C++];if(i>=160&&i<192){if(i=i-160,yr>=C)return Yr.slice(C-Zt,(C+=i)-Zt);if(!(yr==0&&Qr<180))return Ha(i)}else return C--,Xe();let e=(i<<5^(i>1?Ae.getUint16(C):i>0?Q[C]:0))&4095,t=eu[e],r=C,o=C+i-3,n,s=0;if(t&&t.bytes==i){for(;r<o;){if(n=Ae.getUint32(r),n!=t[s++]){r=1879048192;break}r+=4}for(o+=3;r<o;)if(n=Q[r++],n!=t[s++]){r=1879048192;break}if(r===o)return C=r,t.string;o-=3,r=C}for(t=[],eu[e]=t,t.bytes=i;r<o;)n=Ae.getUint32(r),t.push(n),r+=4;for(o+=3;r<o;)n=Q[r++],t.push(n);let a=i<16?qa(i):Yp(i);return a!=null?t.string=a:t.string=Ha(i)}var ru=(i,e)=>{var t=Xe();let r=i;e!==void 0&&(i=i<32?-((e<<5)+i):(e<<5)+i,t.highByte=e);let o=Me[i];return o&&o.isShared&&((Me.restoreStructures||(Me.restoreStructures=[]))[i]=o),Me[i]=t,t.read=ka(t,r),t.read()},ou=typeof self=="object"?self:global;Lt[0]=()=>{};Lt[0].noBuffer=!0;Lt[101]=()=>{let i=Xe();return(ou[i[0]]||Error)(i[1])};Lt[105]=i=>{let e=Ae.getUint32(C-4);_r||(_r=new Map);let t=Q[C],r;t>=144&&t<160||t==220||t==221?r=[]:r={};let o={target:r};_r.set(e,o);let n=Xe();return o.used?Object.assign(r,n):(o.target=n,n)};Lt[112]=i=>{let e=Ae.getUint32(C-4),t=_r.get(e);return t.used=!0,t.target};Lt[115]=()=>new Set(Xe());var $a=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(i=>i+"Array");Lt[116]=i=>{let e=i[0],t=$a[e];if(!t)throw new Error("Could not find typed array for code "+e);return new ou[t](Uint8Array.prototype.slice.call(i,1).buffer)};Lt[120]=()=>{let i=Xe();return new RegExp(i[0],i[1])};Lt[98]=i=>{let e=(i[0]<<24)+(i[1]<<16)+(i[2]<<8)+i[3],t=C;C+=e-4,Ut=[Xe(),Xe()],Ut.position0=0,Ut.position1=0;let r=C;C=t;try{return Xe()}finally{C=r}};Lt[255]=i=>i.length==4?new Date((i[0]*16777216+(i[1]<<16)+(i[2]<<8)+i[3])*1e3):i.length==8?new Date(((i[0]<<22)+(i[1]<<14)+(i[2]<<6)+(i[3]>>2))/1e6+((i[3]&3)*4294967296+i[4]*16777216+(i[5]<<16)+(i[6]<<8)+i[7])*1e3):i.length==12?new Date(((i[0]<<24)+(i[1]<<16)+(i[2]<<8)+i[3])/1e6+((i[4]&128?-281474976710656:0)+i[6]*1099511627776+i[7]*4294967296+i[8]*16777216+(i[9]<<16)+(i[10]<<8)+i[11])*1e3):new Date("invalid");function iu(i){let e=Qr,t=C,r=Va,o=Zt,n=yr,s=Yr,a=Ra,l=_r,c=Ut,d=new Uint8Array(Q.slice(0,Qr)),p=Me,u=Me.slice(0,Me.length),f=jt,m=ti,x=i();return Qr=e,C=t,Va=r,Zt=o,yr=n,Yr=s,Ra=a,_r=l,Ut=c,Q=d,ti=m,Me=p,Me.splice(0,Me.length,...u),jt=f,Ae=new DataView(Q.buffer,Q.byteOffset,Q.byteLength),x}function us(){Q=null,_r=null,Me=null}function nu(i){i.unpack?Lt[i.type]=i.unpack:Lt[i.type]=i}var hs=new Array(147);for(let i=0;i<256;i++)hs[i]=+("1e"+Math.floor(45.15-i*.30103));var ms=new Dr({useRecords:!1}),Nb=ms.unpack,Cb=ms.unpackMultiple,Lb=ms.unpack;var Tb=new Float32Array(1),ZO=new Uint8Array(Tb.buffer,0,4);"use strict";var fs;try{fs=new TextEncoder}catch(i){}var ys,Ja,gs=typeof Buffer!="undefined",Ka=gs?Buffer.allocUnsafeSlow:Uint8Array,au=gs?Buffer:Uint8Array,lu=gs?4294967296:2144337920,G,Ze,M=0,gr,xr=null,Ib=/[\u0080-\uFFFF]/,Gi=Symbol("record-id"),ri=class extends Dr{constructor(e){super(e);this.offset=0;let t,r,o,n,s,a,l=0,c=au.prototype.utf8Write?function(h,I,b){return G.utf8Write(h,I,b)}:fs&&fs.encodeInto?function(h,I){return fs.encodeInto(h,G.subarray(I)).written}:!1,d=this;e||(e={});let p=e&&e.sequential,u=e.structures||e.saveStructures,f=e.maxSharedStructures;if(f==null&&(f=u?32:0),f>8160)throw new Error("Maximum maxSharedStructure is 8160");let m=e.maxOwnStructures;m==null&&(m=u?32:64),p&&!e.saveStructures&&(this.structures=[]);let x=f>32||m+f>64,y=f+64,N=f+m+64;if(N>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let L=[],w=0,B=0;this.pack=this.encode=function(h,I){if(G||(G=new Ka(8192),Ze=new DataView(G.buffer,0,8192),M=0),gr=G.length-10,gr-M<2048?(G=new Ka(G.length),Ze=new DataView(G.buffer,0,G.length),gr=G.length-10,M=0):M=M+7&2147483640,r=M,a=d.structuredClone?new Map:null,d.bundleStrings?(xr=["",""],G[M++]=214,G[M++]=98,xr.position=M-r,M+=4):xr=null,o=d.structures,o){o.uninitialized&&(o=d._mergeStructures(d.getStructures()));let b=o.sharedLength||0;if(b>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 P=0;P<b;P++){let v=o[P];if(!v)continue;let D,Z=o.transitions;for(let V=0,ie=v.length;V<ie;V++){let oe=v[V];D=Z[oe],D||(D=Z[oe]=Object.create(null)),Z=D}Z[Gi]=P+64}l=b}p||(o.nextId=b+64)}n&&(n=!1),s=o||[];try{if(S(h),xr){Ze.setUint32(xr.position+r,M-xr.position-r);let b=xr;xr=null,S(b[0]),S(b[1])}if(d.offset=M,a&&a.idsToInsert){M+=a.idsToInsert.length*6,M>gr&&T(M),d.offset=M;let b=Pb(G.subarray(r,M),a.idsToInsert);return a=null,b}return I&uu?(G.start=r,G.end=M,G):G.subarray(r,M)}finally{if(o){if(B<10&&B++,w>1e4)o.transitions=null,B=0,w=0,L.length>0&&(L=[]);else if(L.length>0&&!p){for(let b=0,P=L.length;b<P;b++)L[b][Gi]=0;L=[]}if(n&&d.saveStructures){let b=o.sharedLength||f;o.length>b&&(o=o.slice(0,b));let P=G.subarray(r,M);return d.saveStructures(o,l)===!1?(d._mergeStructures(d.getStructures()),d.pack(h)):(l=b,P)}}I&jb&&(M=r)}};let S=h=>{M>gr&&(G=T(M));var I=typeof h,b;if(I==="string"){let P=h.length;if(xr&&P>=8&&P<4096){let Z=Ib.test(h);xr[Z?0:1]+=h,G[M++]=193,S(Z?-P:P);return}let v;P<32?v=1:P<256?v=2:P<65536?v=3:v=5;let D=P*3;if(M+D>gr&&(G=T(M+D)),P<64||!c){let Z,V,ie,oe=M+v;for(Z=0;Z<P;Z++)V=h.charCodeAt(Z),V<128?G[oe++]=V:V<2048?(G[oe++]=V>>6|192,G[oe++]=V&63|128):(V&64512)==55296&&((ie=h.charCodeAt(Z+1))&64512)==56320?(V=65536+((V&1023)<<10)+(ie&1023),Z++,G[oe++]=V>>18|240,G[oe++]=V>>12&63|128,G[oe++]=V>>6&63|128,G[oe++]=V&63|128):(G[oe++]=V>>12|224,G[oe++]=V>>6&63|128,G[oe++]=V&63|128);b=oe-M-v}else b=c(h,M+v,D);b<32?G[M++]=160|b:b<256?(v<2&&G.copyWithin(M+2,M+1,M+1+b),G[M++]=217,G[M++]=b):b<65536?(v<3&&G.copyWithin(M+3,M+2,M+2+b),G[M++]=218,G[M++]=b>>8,G[M++]=b&255):(v<5&&G.copyWithin(M+5,M+3,M+3+b),G[M++]=219,Ze.setUint32(M,b),M+=4),M+=b}else if(I==="number")if(h>>>0===h)h<64?G[M++]=h:h<256?(G[M++]=204,G[M++]=h):h<65536?(G[M++]=205,G[M++]=h>>8,G[M++]=h&255):(G[M++]=206,Ze.setUint32(M,h),M+=4);else if(h>>0===h)h>=-32?G[M++]=256+h:h>=-128?(G[M++]=208,G[M++]=h+256):h>=-32768?(G[M++]=209,Ze.setInt16(M,h),M+=2):(G[M++]=210,Ze.setInt32(M,h),M+=4);else{let P;if((P=this.useFloat32)>0&&h<4294967296&&h>=-2147483648){G[M++]=202,Ze.setFloat32(M,h);let v;if(P<4||(v=h*hs[(G[M]&127)<<1|G[M+1]>>7])>>0===v){M+=4;return}else M--}G[M++]=203,Ze.setFloat64(M,h),M+=8}else if(I==="object")if(!h)G[M++]=192;else{if(a){let v=a.get(h);if(v){if(!v.id){let D=a.idsToInsert||(a.idsToInsert=[]);v.id=D.push(v)}G[M++]=214,G[M++]=112,Ze.setUint32(M,v.id),M+=4;return}else a.set(h,{offset:M-r})}let P=h.constructor;if(P===Object)_(h,!0);else if(P===Array){b=h.length,b<16?G[M++]=144|b:b<65536?(G[M++]=220,G[M++]=b>>8,G[M++]=b&255):(G[M++]=221,Ze.setUint32(M,b),M+=4);for(let v=0;v<b;v++)S(h[v])}else if(P===Map){b=h.size,b<16?G[M++]=128|b:b<65536?(G[M++]=222,G[M++]=b>>8,G[M++]=b&255):(G[M++]=223,Ze.setUint32(M,b),M+=4);for(let[v,D]of h)S(v),S(D)}else{for(let v=0,D=ys.length;v<D;v++){let Z=Ja[v];if(h instanceof Z){let V=ys[v];if(V.write){V.type&&(G[M++]=212,G[M++]=V.type,G[M++]=0),S(V.write.call(this,h));return}let ie=G,oe=Ze,ge=M;G=null;let xe;try{xe=V.pack.call(this,h,A=>(G=ie,ie=null,M+=A,M>gr&&T(M),{target:G,targetView:Ze,position:M-A}),S)}finally{ie&&(G=ie,Ze=oe,M=ge,gr=G.length-10)}xe&&(xe.length+M>gr&&T(xe.length+M),M=Mb(xe,G,M,V.type));return}}_(h,!h.hasOwnProperty)}}else if(I==="boolean")G[M++]=h?195:194;else if(I==="bigint"){if(h<BigInt(1)<<BigInt(63)&&h>=-(BigInt(1)<<BigInt(63)))G[M++]=211,Ze.setBigInt64(M,h);else if(h<BigInt(1)<<BigInt(64)&&h>0)G[M++]=207,Ze.setBigUint64(M,h);else if(this.largeBigIntToFloat)G[M++]=203,Ze.setFloat64(M,Number(h));else throw new RangeError(h+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");M+=8}else if(I==="undefined")this.encodeUndefinedAsNil?G[M++]=192:(G[M++]=212,G[M++]=0,G[M++]=0);else if(I==="function")S(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+I)},_=this.useRecords===!1?this.variableMapSize?h=>{let I=Object.keys(h),b=I.length;b<16?G[M++]=128|b:b<65536?(G[M++]=222,G[M++]=b>>8,G[M++]=b&255):(G[M++]=223,Ze.setUint32(M,b),M+=4);let P;for(let v=0;v<b;v++)S(P=I[v]),S(h[P])}:(h,I)=>{G[M++]=222;let b=M-r;M+=2;let P=0;for(let v in h)(I||h.hasOwnProperty(v))&&(S(v),S(h[v]),P++);G[b+++r]=P>>8,G[b+r]=P&255}:h=>{let I=Object.keys(h),b,P=s.transitions||(s.transitions=Object.create(null)),v=0;for(let Z=0,V=I.length;Z<V;Z++){let ie=I[Z];b=P[ie],b||(b=P[ie]=Object.create(null),v++),P=b}let D=P[Gi];if(D)D>=96&&x?(G[M++]=((D-=96)&31)+96,G[M++]=D>>5):G[M++]=D;else{D=s.nextId,D||(D=64),D<y&&this.shouldShareStructure&&!this.shouldShareStructure(I)?(D=s.nextOwnId,D<N||(D=y),s.nextOwnId=D+1):(D>=N&&(D=y),s.nextId=D+1);let Z=I.highByte=D>=96&&x?D-96>>5:-1;P[Gi]=D,s[D-64]=I,D<y?(I.isShared=!0,s.sharedLength=D-63,n=!0,Z>=0?(G[M++]=(D&31)+96,G[M++]=Z):G[M++]=D):(Z>=0?(G[M++]=213,G[M++]=114,G[M++]=(D&31)+96,G[M++]=Z):(G[M++]=212,G[M++]=114,G[M++]=D),v&&(w+=B*v),L.length>=m&&(L.shift()[Gi]=0),L.push(P),S(I))}for(let Z=0,V=I.length;Z<V;Z++)S(h[I[Z]])},T=h=>{let I;if(h>16777216){if(h-r>lu)throw new Error("Packed buffer would be larger than maximum buffer size");I=Math.min(lu,Math.round(Math.max((h-r)*(h>67108864?1.25:2),4194304)/4096)*4096)}else I=(Math.max(h-r<<2,G.length-1)>>12)+1<<12;let b=new Ka(I);return Ze=new DataView(b.buffer,0,I),G.copy?G.copy(b,0,r,h):b.set(G.slice(r,h)),M-=r,r=0,gr=b.length-10,G=b}}useBuffer(e){G=e,Ze=new DataView(G.buffer,G.byteOffset,G.byteLength),M=0}};Ja=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,cs];ys=[{pack(i,e,t){let r=i.getTime()/1e3;if((this.useTimestamp32||i.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:o,targetView:n,position:s}=e(6);o[s++]=214,o[s++]=255,n.setUint32(s,r)}else if(r>0&&r<17179869184){let{target:o,targetView:n,position:s}=e(10);o[s++]=215,o[s++]=255,n.setUint32(s,i.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),n.setUint32(s+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return e(0),t(this.onInvalidDate());let{target:o,targetView:n,position:s}=e(3);o[s++]=212,o[s++]=255,o[s++]=255}else{let{target:o,targetView:n,position:s}=e(15);o[s++]=199,o[s++]=12,o[s++]=255,n.setUint32(s,i.getMilliseconds()*1e6),n.setBigInt64(s+4,BigInt(Math.floor(r)))}}},{pack(i,e,t){let r=Array.from(i),{target:o,position:n}=e(this.structuredClone?3:0);this.structuredClone&&(o[n++]=212,o[n++]=115,o[n++]=0),t(r)}},{pack(i,e,t){let{target:r,position:o}=e(this.structuredClone?3:0);this.structuredClone&&(r[o++]=212,r[o++]=101,r[o++]=0),t([i.name,i.message])}},{pack(i,e,t){let{target:r,position:o}=e(this.structuredClone?3:0);this.structuredClone&&(r[o++]=212,r[o++]=120,r[o++]=0),t([i.source,i.flags])}},{pack(i,e){this.structuredClone?cu(i,16,e):du(gs?Buffer.from(i):new Uint8Array(i),e)}},{pack(i,e){let t=i.constructor;t!==au&&this.structuredClone?cu(i,$a.indexOf(t.name),e):du(i,e)}},{pack(i,e){let{target:t,position:r}=e(1);t[r]=193}}];function cu(i,e,t,r){let o=i.byteLength;if(o+1<256){var{target:n,position:s}=t(4+o);n[s++]=199,n[s++]=o+1}else if(o+1<65536){var{target:n,position:s}=t(5+o);n[s++]=200,n[s++]=o+1>>8,n[s++]=o+1&255}else{var{target:n,position:s,targetView:a}=t(7+o);n[s++]=201,a.setUint32(s,o+1),s+=4}n[s++]=116,n[s++]=e,n.set(new Uint8Array(i.buffer,i.byteOffset,i.byteLength),s)}function du(i,e){let t=i.byteLength;var r,o;if(t<256){var{target:r,position:o}=e(t+2);r[o++]=196,r[o++]=t}else if(t<65536){var{target:r,position:o}=e(t+3);r[o++]=197,r[o++]=t>>8,r[o++]=t&255}else{var{target:r,position:o,targetView:n}=e(t+5);r[o++]=198,n.setUint32(o,t),o+=4}r.set(i,o)}function Mb(i,e,t,r){let o=i.length;switch(o){case 1:e[t++]=212;break;case 2:e[t++]=213;break;case 4:e[t++]=214;break;case 8:e[t++]=215;break;case 16:e[t++]=216;break;default:o<256?(e[t++]=199,e[t++]=o):o<65536?(e[t++]=200,e[t++]=o>>8,e[t++]=o&255):(e[t++]=201,e[t++]=o>>24,e[t++]=o>>16&255,e[t++]=o>>8&255,e[t++]=o&255)}return e[t++]=r,e.set(i,t),t+=o,t}function Pb(i,e){let t,r=e.length*6,o=i.length-r;for(e.sort((n,s)=>n.offset>s.offset?1:-1);t=e.pop();){let n=t.offset,s=t.id;i.copyWithin(n+r,n,o),r-=6;let a=n+r;i[a++]=214,i[a++]=105,i[a++]=s>>24,i[a++]=s>>16&255,i[a++]=s>>8&255,i[a++]=s&255,o=n}return i}function vo(i){if(i.Class){if(!i.pack&&!i.write)throw new Error("Extension has no pack or write function");if(i.pack&&!i.type)throw new Error("Extension has no type (numeric code to identify the extension)");Ja.unshift(i.Class),ys.unshift(i)}nu(i)}var pu=new ri({useRecords:!1}),Ob=pu.pack,Ab=pu.pack;var uu=512,jb=1024;var hu=new ri({structuredClone:!0});vo({Class:nr.prototype.constructor,type:1,write(i){return O({},i)},read(i){return Object.setPrototypeOf(i,nr.prototype),i}});vo({Class:Ke.prototype.constructor,type:2,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,Ke.prototype),i}});vo({Class:sr.prototype.constructor,type:3,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,sr.prototype),i}});vo({Class:as.prototype.constructor,type:4,write(i){return i.id},read(i){return new as(i)}});vo({Class:ls.prototype.constructor,type:5,write(i){return i.data},read(i){return new ls(i)}});function _b(i){var e=0;if(i.length===0)return e;for(let t=0;t<i.length;t++){let r=i[t];e=(e<<5)-e+r,e=e&e}return e}var xs;(function(r){function i(o){return hu.pack(o)}r.serialize=i;function e(o){return hu.unpack(o)}r.deserialize=e;function t(o){return _b(i(o)).toString()}r.checksum=t})(xs||(xs={}));var bs;(function(t){t.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function e(r){return t.all.includes(r)}t.is=e})(bs||(bs={}));var vs;(function(t){function i(r){return e(r)}t.defaultData=i;function e(r){if(r==="PointLight")return{type:r,color:mr.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,depth:2500,helper:!0};if(r==="SpotLight")return{type:r,color:mr.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:2500,helper:!0};if(r==="DirectionalLight")return{type:r,color:mr.white,intensity:1,shadows:!0,size:2500,depth:2500,helper:!0};throw new Error("not implemented")}})(vs||(vs={}));var oi;(function(r){r[r.Front=0]="Front",r[r.Back=1]="Back",r[r.Double=2]="Double"})(oi||(oi={}));var Xa;(function(t){t.defaultData={castShadow:!0,receiveShadow:!0};function e(r,o){return r.castShadow===o.castShadow&&r.receiveShadow===o.receiveShadow}t.equals=e})(Xa||(Xa={}));var Za;(function(t){t.defaultData={flatShading:!1,wireframe:!1,side:0};function e(r,o){return r.flatShading===o.flatShading&&r.side===o.side&&r.wireframe===o.wireframe}t.equals=e})(Za||(Za={}));var Ss;(function(e){e.defaultData=$(O(O({},Za.defaultData),Xa.defaultData),{cloner:null})})(Ss||(Ss={}));var Tt;(function(o){o[o.Left=1]="Left",o[o.Right=2]="Right",o[o.Center=3]="Center",o[o.Justify=4]="Justify"})(Tt||(Tt={}));var Br;(function(r){r[r.Top=1]="Top",r[r.Center=2]="Center",r[r.Bottom=3]="Bottom"})(Br||(Br={}));var eo;(function(r){r[r.None=1]="None",r[r.Upper=2]="Upper",r[r.Lower=3]="Lower"})(eo||(eo={}));var ws;(function(e){e.defaultData={width:100,height:100,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.5,letterSpacing:1,text:"",textTransform:1,color:mr.fromHexAndA(6974058,1),alpha:1,font:"roboto_regular"}})(ws||(ws={}));var it;(function(o){o[o.Normal=0]="Normal",o[o.Multiply=1]="Multiply",o[o.Screen=2]="Screen",o[o.Overlay=3]="Overlay"})(it||(it={}));var ii;(function(r){r[r.Linear=0]="Linear",r[r.Radial=1]="Radial",r[r.Polar=2]="Polar"})(ii||(ii={}));var Ns;(function(r){r[r.RepeatWrapping=1e3]="RepeatWrapping",r[r.ClampToEdgeWrapping=1001]="ClampToEdgeWrapping",r[r.MirroredRepeatWrapping=1002]="MirroredRepeatWrapping"})(Ns||(Ns={}));var Cs;(function(o){o[o.UV=0]="UV",o[o.Planar=1]="Planar",o[o.Spherical=2]="Spherical",o[o.Cylindrical=3]="Cylindrical"})(Cs||(Cs={}));var Ls;(function(n){n[n.Simplex=0]="Simplex",n[n.SimplexFractal=1]="SimplexFractal",n[n.Ashima=2]="Ashima",n[n.Fbm=3]="Fbm",n[n.Perlin=4]="Perlin"})(Ls||(Ls={}));var ni;(function(r){function i(o,n){return o==="light"&&n?e(n):t(o)}r.defaultData=i;function e(o){switch(o){case"basic":return{type:"light",category:"basic",alpha:1,visible:!0,mode:0};case"phong":return{category:"phong",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1,visible:!0,mode:0};case"toon":return{category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1,visible:!0,mode:0};case"lambert":return{category:"lambert",emissive:{r:.2,g:.2,b:.2,a:1},type:"light",alpha:1,visible:!0,mode:0};case"physical":return{category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0}}}function t(o){switch(o){case"texture":return{alpha:1,visible:!0,size:[128,128],mode:0,axis:Yo.x,type:"texture",projection:0,texture:{image:"image_0",wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!0};case"color":return{type:"color",alpha:1,visible:!0,mode:0,color:Rt.fromHex(4737101)};case"depth":return{type:"depth",alpha:1,visible:!0,mode:0,gradientType:1,smooth:!1,isVector:!0,isWorldSpace:!1,origin:[0,0,0],direction:[1,0,0],colors:[[1,1,1,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]],steps:[0,1,1,1,1,1,1,1,1,1],num:2,near:50,far:200};case"normal":return{type:"normal",alpha:1,visible:!0,mode:0,cnormal:[1,1,1]};case"gradient":return{type:"gradient",alpha:1,visible:!0,mode:0,gradientType:0,smooth:!1,colors:[[0,0,0,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,1,1,1,1,1,1,1,1,1],num:2,angle:0,offset:[0,0],morph:[0,0]};case"noise":return{type:"noise",alpha:1,visible:!0,mode:0,size:[100,100,100],noiseType:0,scale:1,move:1,colorA:$(O({},Rt.fromHex(6710886)),{a:1}),colorB:$(O({},Rt.fromHex(6710886)),{a:1}),colorC:$(O({},Rt.fromHex(16777215)),{a:1}),colorD:$(O({},Rt.fromHex(16777215)),{a:1}),distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8]};case"fresnel":return{type:"fresnel",alpha:1,visible:!0,mode:0,color:mr.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{type:"rainbow",alpha:1,visible:!0,mode:0,filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"matcap":return{type:"matcap",alpha:1,visible:!0,mode:0,texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0]}};case"transmission":return{type:"transmission",alpha:1,visible:!0,mode:0,thickness:10,ior:1.5,roughness:1};case"displace":return{type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,visible:!0}}}})(ni||(ni={}));var si;(function(a){function i(l){return!l.layers.some(d=>{if(d.data.type==="texture"&&d.data.projection!==0||d.data.type==="depth"&&!d.data.isWorldSpace||d.data.type==="noise"||d.data.type==="displace")return!0})&&!t(l)}a.isMergable=i;function e(l){let c="";return l.layers.forEach(d=>{Object.entries(d.data).forEach(([p,u])=>{c+=`${p}${u}`,Array.isArray(u)?u.forEach(f=>c+=`${f}`):typeof u=="object"?Object.values(u).forEach(f=>{typeof f=="number"?c+=`${f.toFixed(4)}`:c+=`${f}`}):c+=`${u}`})}),c}a.getHash=e;function t(l){let c=0;for(let d of l.layers)"alpha"in d.data&&d.data.type!=="light"&&d.data.type!=="fresnel"&&(c+=(1-c)*d.data.alpha);return c<1}a.isTransparent=t;function r(){return{layers:new Ke}}a.defaultEmptyData=r;function o(l="layer1",c="layer2"){return n("phong",l,c)}a.defaultData=o;function n(l,c="layer1",d="layer2"){let p=new Ke;return p.push({fi:0,data:ni.defaultData("light",l),id:c}),p.push({fi:1,data:ni.defaultData("color"),id:d}),{layers:p}}a.defaultTwoLayerData=n;function s(l,c="basic",d="layer1",p="layer2"){let u=ni.defaultData("texture");Object.assign(u.texture,{image:l});let f=new Ke;return f.push({fi:0,data:u,id:d}),f.push({fi:1,data:ni.defaultData("light",c),id:p}),{layers:f}}a.defaultTwoLayerTextureData=s})(si||(si={}));var ai;(function(r){function i(){return{points:new Ke,roundness:0,shapeHoles:[],isClosed:!1}}r.defaultData=i;function e(o,n){let{points:s}=n;if(s){for(let a of s)if(a.data.position[0]===o[0]&&a.data.position[1]===o[1])return!0}return!1}r.isOverlappingExistingPoint=e;function t(o,n){let s=o.controlNext,a=n.controlPrevious;return o.position[0]===s.position[0]&&o.position[1]===s.position[1]&&n.position[0]===a.position[0]&&n.position[1]===a.position[1]}r.isStraightLine=t})(ai||(ai={}));var Ts;(function(e){function i(t){return t==="PolygonGeometry"||t==="RectangleGeometry"||t==="StarGeometry"||t==="TriangleGeometry"||t==="EllipseGeometry"}e.is2DParametricMesh=i})(Ts||(Ts={}));var Is;(function(e){function i(t){if(t==="RectangleGeometry")return{width:320,height:320,type:t,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1,surfaceMaxCount:1};if(t==="VectorGeometry")return{width:100,height:100,type:t,subdivisions:12,shape:ai.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1,surfaceMaxCount:1};throw new Error("not implemented")}e.defaultData=i})(Is||(Is={}));var zi;(function(o){o.identity=$(O({},ts.identity),{hiddenMatrix:Zr.identity});function e(n){return{position:n.position,rotation:n.rotation,scale:n.scale,hiddenMatrix:n.hiddenMatrix}}o.fromObject=e;function t(n,s){return{position:(s==null?void 0:s.position)||n.position,rotation:(s==null?void 0:s.rotation)||n.rotation,scale:(s==null?void 0:s.scale)||n.scale,hiddenMatrix:(s==null?void 0:s.hiddenMatrix)||n.hiddenMatrix}}o.merge=t;function r(n,s){return{position:ei.isEqual(n.position,s.position)?null:s.position,rotation:ei.isEqual(n.rotation,s.rotation)?null:s.rotation,scale:ei.isEqual(n.scale,s.scale)?null:s.scale,hiddenMatrix:Zr.isEqual(n.hiddenMatrix,s.hiddenMatrix)?null:s.hiddenMatrix}}o.diff=r})(zi||(zi={}));var to;(function(e){e.defaultData=O({states:new Ke,events:new Ke,visible:!0,raycastLock:!1},zi.identity)})(to||(to={}));var mu;(function(e){e.defaultData=O({type:"Empty"},to.defaultData)})(mu||(mu={}));var Qa;(function(e){e.defaultData=O(O({type:"Mesh"},to.defaultData),Ss.defaultData)})(Qa||(Qa={}));var fu;(function(e){e.defaultData=O(O({type:"TextFrame"},to.defaultData),ws.defaultData)})(fu||(fu={}));var Ms;(function(e){e.defaultData=O(O(O({},to.defaultData),zi.identity),xo.defaultData)})(Ms||(Ms={}));var yu;(function(e){function i(t){return O(O({},to.defaultData),vs.defaultData(t))}e.defaultData=i})(yu||(yu={}));var gu;(function(t){t.defaultCamera=O({position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:Zr.identity,name:"Play Camera",visible:!0,raycastLock:!1,states:new Ke,events:new Ke},xo.defaultData),t.defaultMeshObject=$(O(O({name:"Rectangle"},to.defaultData),Qa.defaultData),{geometry:Is.defaultData("RectangleGeometry"),material:si.defaultTwoLayerData("basic","layer1","layer2")})})(gu||(gu={}));var xu;(function(t){function i(r,o){if(o===void 0)return r;let n=O({},r);return"material"in n&&"material"in o&&o.material&&(n.material=za(n.material,s=>{if(typeof s!="string")for(let[a,l]of Object.entries(o.material.layers)){let c=s.layers.data(a);c&&go(c,l)}}).data),n.materials&&o.materials&&(n.materials=za(n.materials,s=>{var a,l;for(let c=0;c<n.materials.length;c++){let d=o.materials[c];if(typeof d!="string")for(let[p,u]of Object.entries(d.layers)){let f=(l=(a=s[c])==null?void 0:a.layers)==null?void 0:l.data(p);f&&go(f,u)}}}).data),n}t.patchMaterialState=i;function e(r,o){var s,a;if(o===void 0)return r;let n=O({},r);if(Object.assign(n,zi.merge(n,o)),Qo.is(r.type)){n.orthographic=O({},n.orthographic),n.perspective=O({},n.perspective);let l=o;((s=l.orthographic)==null?void 0:s.zoom)!==void 0&&(n.orthographic.zoom=l.orthographic.zoom),((a=l.perspective)==null?void 0:a.zoom)!==void 0&&(n.perspective.zoom=l.perspective.zoom)}else if(r.type==="Mesh")n.geometry=O({},n.geometry),Object.assign(n.geometry,o.geometry),n=i(n,o);else if(bs.is(r.type)){let l=o;n.intensity!==void 0&&(n.intensity=l.intensity),l.color!==void 0&&(n.color=Rt.clone(l.color))}return n}t.patch=e})(xu||(xu={}));var nt=5855577;var bu=2857471;var Ya=15711266;import{DoubleSide as Db,Mesh as Bb,MeshBasicMaterial as Gb,ShapeBufferGeometry as zb,Vector2 as Eb,Vector3 as Fb}from"three";import{FontLoader as Rb}from"three/examples/jsm/loaders/FontLoader.js";var Qe=class extends Bb{constructor({char:e,originalChar:t,fontFamily:r,letterSpacing:o,fontSize:n,LOD:s=16},a=new Gb({color:0,opacity:1,visible:!0,transparent:!0,side:Db})){let l=Qe.loadChar(e,r,s);super(l.geometry,a);this.char=e,this.originalChar=t!=null?t:e,this.fontFamily=r,this.letterSpacing=o,this.fontSize=n,this.LOD=s,this.resolution=l.resolution,this.glyphsHa=l.glyphsHa,this.localPosition=new Eb,this.charSize=0,this.geometry.userData={type:"CharacterGeometry",parameters:{char:this.char,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,lod:this.LOD,resolution:this.resolution,charSize:this.charSize,localPosition:this.localPosition}},this.updateFontSize(this.fontSize)}static get FONTS_PATH(){return Qe._fontPath}static set FONTS_PATH(e){Qe._fontPath=e}updatePosition(e,t){this.localPosition.copy(e);let r=new Fb(this.localPosition.x,-this.localPosition.y,0);this.position.copy(r).add(t)}updateFontSize(e){let t=e/this.resolution;this.fontSize=e,this.scale.set(this.fontSize,this.fontSize,1),this.charSize=this.glyphsHa*t*this.letterSpacing}updateFontFamily(e){if(this.fontFamily===e)return;this.fontFamily=e;let t=Qe.loadChar(this.char,e,this.LOD);this.geometry=t.geometry,this.resolution=t.resolution,this.glyphsHa=t.glyphsHa,this.geometry.userData={type:"CharacterGeometry",parameters:{char:this.char,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,lod:this.LOD,resolution:this.resolution,charSize:this.charSize,localPosition:this.localPosition}},this.updateFontSize(this.fontSize)}updateChar(e){if(this.char===e)return;this.char=e;let t=Qe.loadChar(e,this.fontFamily,this.LOD);this.geometry=t.geometry,this.resolution=t.resolution,this.glyphsHa=t.glyphsHa,this.geometry.userData={type:"CharacterGeometry",parameters:{char:this.char,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,lod:this.LOD,resolution:this.resolution,charSize:this.charSize,localPosition:this.localPosition}},this.updateFontSize(this.fontSize)}updateLetterSpacing(e){this.letterSpacing!==e&&(this.letterSpacing=e,this.updateFontSize(this.fontSize))}updateLOD(e){if(this.LOD===e)return;this.LOD=e;let t=Qe.loadChar(this.char,this.fontFamily,this.LOD);this.geometry=t.geometry,this.resolution=t.resolution,this.glyphsHa=t.glyphsHa,this.geometry.userData={type:"CharacterGeometry",parameters:{char:this.char,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,lod:this.LOD,resolution:this.resolution,charSize:this.charSize,localPosition:this.localPosition}},this.updateFontSize(this.fontSize)}clone(){let e={char:this.char,originalChar:this.originalChar,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,LOD:this.LOD};return new Qe(e).copy(this)}static loadFont(e){return new Promise(function(t,r){Qe.fontCache[e]?t(Qe.fontCache[e]):new Rb().load(Qe.FONTS_PATH+e+".json",n=>{Qe.fontCache[e]=n,t(n)},void 0,r)})}static loadChar(e,t,r){if(Qe.charCache[e]){if(Qe.charCache[e][r]&&Qe.charCache[e][r].fontFamily===t)return Qe.charCache[e][r]}else Qe.charCache[e]={};let o=Qe.fontCache[t],n=o.generateShapes(e,1);return Qe.charCache[e][r]={geometry:new zb(n,r),fontFamily:t,resolution:o.data.resolution,glyphsHa:o.data.glyphs[e].ha},Qe.charCache[e][r]}},_t=Qe;_t.charCache={},_t.fontCache={},_t._fontPath="/_assets/_fonts/";import{DoubleSide as Ta,MeshBasicMaterial as gm,Vector3 as xm,Object3D as kw}from"three";import{Mesh as vS}from"three";import{BufferGeometry as xj,ConeBufferGeometry as kb,Float32BufferAttribute as bj,Vector2 as vj,Vector3 as Sj}from"three";import{BufferGeometry as Vb,CylinderBufferGeometry as Ub,Float32BufferAttribute as el,Vector2 as ar,Vector3 as Ps}from"three";var vu=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var s,a,l,c,d;let t=Object.assign({},(s=e==null?void 0:e.parameters)!=null?s:{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:0,cornerSegments:8,hollow:0},i.parameters),r=t.width/2,o=(a=t.radiusTop)!=null?a:r,n=(l=t.radiusBottom)!=null?l:r;return o===n?(o=r,n=r):o>n?(o=r,n=n*r/o):(o=o*r/n,n=r),{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((c=t.height)!=null?c:t.width),depth:Math.abs((d=t.depth)!=null?d:t.width),radiusTop:o,radiusBottom:n})}}static build(i){let{width:e,depth:t,height:r,radialSegments:o,heightSegments:n,openEnded:s,thetaStart:a,thetaLength:l,radiusTop:c,radiusBottom:d,cornerRadius:p,cornerSegments:u,hollow:f}=i.parameters,m;return p||f?m=new Os(c,d,r,o,n,s,a,l*Math.PI/180,p,p,u,f):m=new Ub(c,d,r,o,n,s,a,l*Math.PI/180),m.scale(1,1,t/e),Object.assign(m,{userData:$(O({},i),{type:"CylinderGeometry"})})}};function ro(i,e,t){t.x=i.x*e.x,t.y=i.y,t.z=i.x*e.y}function Su(i){return new ar(i.y,-i.x)}var Os=class extends Vb{constructor(e,t,r,o,n,s,a,l,c,d,p,u,f=!1){super();this.type="RoundedCylinderBufferGeometry",e=e!==void 0?e:1,t=t!==void 0?t:1,r=r||1,o=Math.floor(o)||8,n=Math.floor(n)||1,s=s!==void 0?s:!1,a=a!==void 0?a:0,l=l!==void 0?l:Math.PI*2,s&&(c=0,d=0);let m=[],x=[],y=[],N=[],L=0,w=r/2,B=new Ps,S=new Ps;f&&e==0&&(e=c),f&&t==0&&(t=d);let _=new ar(e,w),T=new ar(t,-w),h=null,I=null,b=null,P=null,v=_.clone().sub(T),D=0,Z=0,V=0;u>0&&(D=Math.min(e,t)*(1-u),Z=e-D,V=t-D);let ie=_.clone();ie.x-=D;let oe=Math.PI-v.angle(),ge=v.angle(),xe=Math.tan(ge/2),A=Math.tan(oe/2),j=xe+A,g=u?j:A,z=u?j:xe;if(c=Math.min(c,(e-Z)/g,v.length()/j),d=Math.min(d,(t-V)/z,v.length()/j),c>0){let E=c/xe;h=_.clone().sub(new ar(E,c)),u&&(b=h.clone(),b.x-=D-j*c),_.sub(v.clone().setLength(E))}if(d>0){let E=d/A;I=T.clone().sub(new ar(E,-d)),T.add(v.clone().setLength(E)),u&&(P=I.clone(),P.x-=D-j*d,ie.sub(v.clone().setLength(E)))}v=_.clone().sub(T);let R=v.length()<.5,U=[];for(let E=0;E<=o;E++){let H=[],k=E/o,se=k*l+a,F=new ar(Math.sin(se),Math.cos(se));P&&I?(q(H,k,F,oe,d,P,-1,!0),q(H,k,F,ge,d,I,-1,!1)):I?(W(H,F,I.x,0,-1),q(H,k,F,ge,d,I,-1,!1)):s||W(H,F,t,V,-1);let K=Su(v).normalize();if(ro(K,F,B),!R)for(let X=0;X<=n;X++){let te=X/n,he=v.clone().multiplyScalar(te).add(T);ro(he,F,S),x.push(S.x,S.y,S.z),y.push(B.x,B.y,B.z),N.push(k,.5+S.y/r),H.push(L++)}if(b&&h?(q(H,k,F,oe,c,h,1,!1),q(H,k,F,ge,c,b,1,!0)):h?(q(H,k,F,oe,c,h,1,!1),W(H,F,h.x,0,1)):s||W(H,F,e,Z,1),u&&!R){let X=Su(v).multiplyScalar(-1).normalize();ro(X,F,B);for(let te=0;te<=n;te++){let he=te/n,Y=v.clone().multiplyScalar(-he).add(ie);ro(Y,F,S),x.push(S.x,S.y,S.z),y.push(B.x,B.y,B.z),N.push(k,.5+S.y/r),H.push(L++)}}u&&!s&&H.push(H[0]),U.push(H)}for(let E=0;E<U.length-1;E++)for(let H=0;H<U[0].length-1;H++){if(s&&u&&H==n)continue;let k=U[E][H],se=U[E+1][H],F=U[E+1][H+1],K=U[E][H+1],X=x[F*3+0],te=x[F*3+2];m.push(k,se,K),(X!=0||te!=0)&&m.push(se,F,K)}l<Math.PI*2&&(J(-1,U[0],a),J(1,U[U.length-1],a+l)),this.setIndex(m),this.setAttribute("position",new el(x,3)),this.setAttribute("normal",new el(y,3)),this.setAttribute("uv",new el(N,2));function q(E,H,k,se,F,K,X,te){for(let he=0;he<p+1;he++){let Y=he/p,ne=X<0?Y:1-Y;te&&(ne-=1),ne*=se;let Se=new ar(Math.sin(ne),Math.cos(ne)*X),me=Se.clone().multiplyScalar(F).add(K);ro(me,k,S),x.push(S.x,S.y,S.z),ro(Se,k,B),y.push(B.x,B.y,B.z),N.push(H,.5+S.y/r),E.push(L++)}}function W(E,H,k,se,F){let K=new Ps,X=new ar,te=[k,se];F<0&&te.reverse();for(let he of te)X.set(he,w*F),ro(X,H,K),x.push(K.x,K.y,K.z),y.push(0,F,0),N.push(.5,.5),E.push(L++)}function J(E,H,k){let se=new ar(Math.sin(k),Math.cos(k)),F=new ar(-Math.cos(k),Math.sin(k)),K=new Ps,X=E<0?(Y,ne,Se)=>m.push(Y,ne,Se):(Y,ne,Se)=>m.push(Y,Se,ne),te=new ar((e+t+Z+V)/4,0);ro(te,se,K),x.push(K.x,K.y,K.z),y.push(F.x,0,F.y),N.push(.5,.5);let he=L++;for(let Y of H){let ne=x.slice(Y*3,Y*3+3);x.push(...ne),y.push(F.x,0,F.y);let Se=N.slice(Y*2,Y*2+2);N.push(...Se),L++}for(let Y=he+1;Y<L-1;Y++)X(he,Y,Y+1);X(he,L-1,he+1)}}};var wu=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,o,n;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:0,cornerRadiusBottom:0,cornerSegments:8},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((o=t.height)!=null?o:t.width),depth:Math.abs((n=t.depth)!=null?n:t.width)})}}static build(i){let{width:e,depth:t,height:r,radialSegments:o,heightSegments:n,openEnded:s,thetaStart:a,thetaLength:l,cornerRadiusTop:c,cornerRadiusBottom:d,cornerSegments:p}=i.parameters,u;return c>0||d>0||l<360?u=new Os(0,e/2,r,o,n,s,a,l*Math.PI/180,c,d,p,0,!0):u=new kb(e/2,r,o,n,s),u.scale(1,1,t/e),Object.assign(u,{userData:$(O({},i),{type:"ConeGeometry"})})}};import{BoxBufferGeometry as Hb,BufferGeometry as qb,Float32BufferAttribute as tl,Vector3 as Ei}from"three";var Nu=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,o,n;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:0,cornerSegments:8},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((o=t.height)!=null?o:t.width),depth:Math.abs((n=t.depth)!=null?n:t.width)})}}static build(i){let{width:e,height:t,depth:r,widthSegments:o,heightSegments:n,depthSegments:s,cornerRadius:a,cornerSegments:l}=i.parameters,c;return a==0?c=new Hb(e,t,r,o,n,s):c=new Cu(e,t,r,o,n,s,a,l),Object.assign(c,{userData:$(O({},i),{type:"CubeGeometry"})})}},rl=Math.PI/2,Cu=class extends qb{constructor(e=1,t=1,r=1,o=1,n=1,s=1,a=0,l=4){super();this.type="BoxBufferGeometry";let c=this;o=Math.floor(o),n=Math.floor(n),s=Math.floor(s),l=Math.floor(l),a=Math.min(a,e/2,t/2,r/2);let d=[],p=[],u=[],f=[],m=0,x=0;y("z","y","x",-1,-1,r,t,e,s,n,0),y("z","y","x",1,-1,r,t,-e,s,n,1),y("x","z","y",1,1,e,r,t,o,s,2),y("x","z","y",1,-1,e,r,-t,o,s,3),y("x","y","z",1,-1,e,t,r,o,n,4),y("x","y","z",-1,-1,e,t,-r,o,n,5),a>0&&(N("z","y","x",-1,-1,1,r,t,e,s,0),N("z","y","x",1,-1,-1,r,t,e,s,1),N("z","y","x",-1,1,-1,r,t,e,s,1),N("z","y","x",1,1,1,r,t,e,s,0),N("x","y","z",-1,-1,-1,e,t,r,o,0),N("x","y","z",1,-1,1,e,t,r,o,1),N("x","y","z",-1,1,1,e,t,r,o,0),N("x","y","z",1,1,-1,e,t,r,o,1),N("y","x","z",-1,-1,1,t,e,r,n,0),N("y","x","z",1,-1,-1,t,e,r,n,1),N("y","x","z",1,1,1,t,e,r,n,1),N("y","x","z",-1,1,-1,t,e,r,n,0),L(1,1,1),L(-1,1,1),L(1,-1,1),L(-1,-1,1),L(1,1,-1),L(-1,1,-1),L(1,-1,-1),L(-1,-1,-1)),this.setIndex(d),this.setAttribute("position",new tl(p,3)),this.setAttribute("normal",new tl(u,3)),this.setAttribute("uv",new tl(f,2));function y(w,B,S,_,T,h,I,b,P,v,D){let Z=(h-2*a)/P,V=(I-2*a)/v,ie=h/2-a,oe=I/2-a,ge=b/2,xe=P+1,A=v+1,j=0,g=0,z=new Ei;for(let R=0;R<A;R++){let U=R*V-oe;for(let q=0;q<xe;q++){let W=q*Z-ie;z[w]=W*_,z[B]=U*T,z[S]=ge,p.push(z.x,z.y,z.z),z[w]=0,z[B]=0,z[S]=b>0?1:-1,u.push(z.x,z.y,z.z),f.push(q/P),f.push(1-R/v),j+=1}}for(let R=0;R<v;R++)for(let U=0;U<P;U++){let q=m+U+xe*R,W=m+U+xe*(R+1),J=m+(U+1)+xe*(R+1),E=m+(U+1)+xe*R;d.push(q,W,E),d.push(W,J,E),g+=6}c.addGroup(x,g,D),x+=g,m+=j}function N(w,B,S,_,T,h,I,b,P,v,D){let Z=(I-2*a)/v,V=I/2-a,ie=b/2-a,oe=P/2,ge=v+1,xe=0,A=0,j=new Ei,g=new Ei;for(let z=0;z<l+1;z++){let R=z/l*rl,U=Math.sin(R)*a,q=(1-Math.cos(R))*a,W=Math.sin(R),J=Math.cos(R);j[B]=(ie+U)*T,j[S]=(oe-q)*h,g[w]=0,g[B]=W*Math.sign(j[B]),g[S]=J*Math.sign(j[S]);for(let E=0;E<ge;E++){let H=E*Z-V;j[w]=H*_,p.push(j.x,j.y,j.z),u.push(g.x,g.y,g.z),f.push(E/v),f.push(0),xe+=1}}for(let z=0;z<l;z++)for(let R=0;R<v;R++){let U=m+R+ge*z,q=m+R+ge*(z+1),W=m+(R+1)+ge*(z+1),J=m+(R+1)+ge*z;d.push(U,q,J),d.push(q,W,J),A+=6}c.addGroup(x,A,D),x+=A,m+=xe}function L(w,B,S){let _=new Ei,T=new Ei(e/2,t/2,r/2);T.subScalar(a);let h=[],I=w*B*S>0?(P,v,D)=>d.push(P,v,D):(P,v,D)=>d.push(P,D,v);for(let P=0;P<=l;P++){let v=[],D=rl*(1-P/l),Z=Math.cos(D),V=Math.sin(D),ie=0;for(let oe=0;oe<=P;oe++){let ge=Math.cos(ie),xe=Math.sin(ie);_.x=Z*ge,_.y=V,_.z=Z*xe;let A=T.clone().addScaledVector(_,a);p.push(w*A.x,B*A.y,S*A.z),u.push(w*_.x,B*_.y,S*_.z),f.push(0,0),v.push(m++),ie+=rl/P}h.push(v)}let b=h.length-1;for(let P=0;P<b;P++){let v=h[P],D=h[P+1],Z=v.length-1;I(v[0],D[1],D[0]);for(let V=1;V<=Z;V++)I(v[V-1],v[V],D[V]),I(v[V],D[V+1],D[V])}}}};import{BufferGeometry as Wb,Float32BufferAttribute as ol,Triangle as $b,Vector3 as Gr,Vector2 as il}from"three";var So=class extends Wb{constructor(e=[],t=[],r="",o=1,n=.2,s=4){super();this.type="PolyhedronGeometryRound";let a=[],l=[],c=[];d(),p(),this.setAttribute("position",new ol(a,3)),this.setAttribute("normal",new ol(c,3)),this.setAttribute("uv",new ol(l,2));return;function d(){var xe;n=Math.min(1-1e-5,n),n==0&&(s=0);let f={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[r],m=new Gr,x=m.clone(),y=new $b,N=n*o,L=o-N,w=s+1,B=new Gr,S=(A,j)=>B.subVectors(A,j).normalize(),_=(A,j)=>Array(A).fill(void 0).map(j),T=_(e.length/3,(A,j)=>new Gr().fromArray(e,j*3).setLength(o)),h=[],I=1e6;for(let A=0;A<T.length;A++){let j=T[A],g=[],z,R,U,q=1e10,W=-1;for(;(W=t.indexOf(A,W+1))!=-1;){let k=W-W%3;z=t[k+(W+1)%3],R=t[k+(W+2)%3],U=j.distanceToSquared(T[z]),q=Math.min(q,U),g.push([z,R,U])}q+=1e-6;let J=[],E=0,H=g.length;for(let k=0;k<H;k++){[z,R,U]=g[E];let se=((xe=h[z])==null?void 0:xe.includes(A))==!0;U<=q&&J.push(z+ +se*I),E=g.findIndex(F=>F[0]==R)}h.push(J)}let b=[];{let A=0,j=0,g,z,R=f==3;for(let U=0;U<=s;U++){g=U*(U+1)/2,z=(U+1)*(U+2)/2;for(let q=0;q<s-U;q++)[A,j]=[g+q+U+2,z+q+U+3],b.push(g,z,...R?[j,g]:[A,z],j,A),[g,z]=[A,j];b.push(g,z,g+s+2)}}let P=m.clone(),v=m.clone(),D=m.clone(),Z=m.clone(),V=m.clone(),ie=[],oe=_(T.length,()=>_(f,()=>m.clone()));for(let A=0;A<T.length;A++){m.copy(T[A]).normalize(),P.copy(m).multiplyScalar(L);let j=h[A];for(let J=0;J<j.length;J++){let E=j[J],H=j[(J+1)%f];y.setFromPointsAndIndices(T,A,E%I,H%I),y.b.sub(y.a).setLength(1e10).add(y.a),y.c.sub(y.a).setLength(1e10).add(y.a),y.closestPointToPoint(P,oe[A][J])}let g=[],z=[],R=[],U=new Gr;s==0&&[...oe[A]].reduce((J,E)=>J.add(E),U).multiplyScalar(1/f);for(let J=0;J<f;J++){let E=[],H=(J-1+f)%f,k=oe[A][H],se=oe[A][J];m.copy(k).sub(P),x.copy(se).sub(P);let F=P.angleTo(m),K=m.angleTo(x),X=Math.cos(F)*N;s==0?v.copy(U):v.copy(P).setLength(L+X),z.push(X);let te=[v,k,se];for(let he=0;he<2;he++){let Y=te[he],ne=te[he+1];Z.subVectors(Y,P),V.subVectors(ne,P),D.crossVectors(Z,V).normalize();for(let Se=0;Se<w;Se++){let me=[F,K][he]*Se/w;m.copy(Z).applyAxisAngle(D,me).add(P),g.push(m.clone()),he&&(S(m,P),E.push([Se==0?Y:m.clone(),B.clone()]))}he&&(S(ne,P),E.push([ne,B.clone()]))}R.push(E)}ie.push(R);let q=2*w,W=2;for(let J=0;J<f;J++){let E=q*J,H=q*((J+1)%f),k=[g[E]];for(let F=1;F<w;F++){Z=g[E+F],V=g[H+F],k.push(Z);for(let K=1,X=F-W+1;K<=X;K++)m.lerpVectors(Z,V,K/(X+1)),m.sub(P).setLength(z[J]).add(P),k.push(m.clone());k.push(V)}for(let F=0;F<w;F++)k.push(g[F+w+E]);k.push(g[H+w]);let se=b.map(F=>k[F]);a.push(...se.map(F=>[F.x,F.y,F.z]).flat()),c.push(...se.map(F=>(S(F,P),[B.x,B.y,B.z])).flat())}}let ge=[];for(let A=0;A<h.length;A++)for(let j=0;j<f;j++){let g=h[A][j];if(g<I){let z=h[g].findIndex(q=>q%I==A),R=ie[A][j],U=ie[g][z];for(let q=0;q<w;q++){let W=R[q],J=U[w-q],E=R[q+1],H=U[w-(q+1)];[W,J,E,E,J,H].forEach(k=>{a.push(k[0].x,k[0].y,k[0].z),c.push(k[1].x,k[1].y,k[1].z)})}ge.push(R[0][0],U[w][0],R[w][0],U[0][0])}}for(;ge.length;){let A,j,g,z;[A,j]=ge.splice(0,2);let R=[A];for(;A!=j;)R.push(j),g=ge.indexOf(j),z=g%2,j=ge.splice(g-z,2)[1-z];B.subVectors(R[0],R[1]).cross(m.subVectors(R[0],R[2])).normalize();let U=B.dot(R[0])<0;U&&B.negate();for(let q=1;q<=R.length-2;q++)[R[q+ +U],R[q+1-+U],R[0]].forEach(W=>{a.push(W.x,W.y,W.z),c.push(B.x,B.y,B.z)})}}function p(){let u=new Gr;for(let T=0;T<a.length;T+=3){u.x=a[T+0],u.y=a[T+1],u.z=a[T+2];let h=S(u)/2/Math.PI+.5,I=_(u)/Math.PI+.5;l.push(h,1-I)}let f=new Gr,m=new Gr,x=new Gr,y=new Gr,N=new il,L=new il,w=new il,B=(T,h,I,b)=>{b<0&&T.x===1&&(l[h]=T.x-1),I.x===0&&I.z===0&&(l[h]=b/2/Math.PI+.5)};for(let T=0,h=0;T<a.length;T+=9,h+=6){f.set(a[T+0],a[T+1],a[T+2]),m.set(a[T+3],a[T+4],a[T+5]),x.set(a[T+6],a[T+7],a[T+8]),N.set(l[h+0],l[h+1]),L.set(l[h+2],l[h+3]),w.set(l[h+4],l[h+5]),y.copy(f).add(m).add(x).divideScalar(3);let I=S(y);B(N,h+0,f,I),B(L,h+2,m,I),B(w,h+4,x,I)}for(let T=0;T<l.length;T+=6){let h=l[T+0],I=l[T+2],b=l[T+4],P=Math.max(h,I,b),v=Math.min(h,I,b);P>.9&&v<.1&&(h<.2&&(l[T+0]+=1),I<.2&&(l[T+2]+=1),b<.2&&(l[T+4]+=1))}function S(T){return Math.atan2(T.z,-T.x)}function _(T){return Math.atan2(-T.y,Math.sqrt(T.x*T.x+T.z*T.z))}}}static fromJSON(e){return new So(e.vertices,e.indices,e.radius,e.corner,e.cornerSides)}};import{DodecahedronBufferGeometry as Jb}from"three";var Lu=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,o,n;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,detail:0,corner:0,cornerSides:4},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((o=t.height)!=null?o:t.width),depth:Math.abs((n=t.depth)!=null?n:t.width)})}}static build(i){let{width:e,height:t,depth:r,detail:o,corner:n,cornerSides:s}=i.parameters,a=o===0&&n!==0?new As(e*.5,n,s):new Jb(e*.5,o);return a.scale(1,t/e,r/e),Object.assign(a,{userData:$(O({},i),{type:"DodecahedronGeometry"})})}},As=class extends So{constructor(e=1,t=.2,r=4){let o=(1+Math.sqrt(5))/2,n=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,-n,-o,0,-n,o,0,n,-o,0,n,o,-n,-o,0,-n,o,0,n,-o,0,n,o,0,-o,0,-n,o,0,-n,-o,0,n,o,0,n],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],l="DodecahedronGeometry";super(s,a,l,e,t,r);this.type=l}static fromJSON(e){return new As(e.radius,e.corner,e.cornerSides)}};import{EventDispatcher as nv,Plane as sv,Shape as zu,Vector2 as zr,Vector3 as av,MathUtils as pl,LineCurve as ul,QuadraticBezierCurve as Eu,CubicBezierCurve as Ds}from"three";import{CubicBezierCurve as js,EllipseCurve as Kb,LineCurve as _s,LineCurve3 as Xb,MathUtils as Zb,QuadraticBezierCurve as nl,SplineCurve as Qb,Vector2 as lr,Vector3 as Tu}from"three";var Fi=1e-12,Ri=class{constructor(e){this.position=new lr;this.startPosition=new lr;this.uuid=Zb.generateUUID();this.position=e.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(e){this.position.copy(this.startPosition).add(e)}copy(e){return this.position.copy(e.position),this.startPosition.copy(e.startPosition),this}clone(){return new Ri(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},Vi=class extends Ri{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new Vi(this.parent).copy(this)}},br=class extends Ri{constructor(e,t){super(t);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new Vi(this),new Vi(this))}static create(e,t){let r=new br(e,new lr(...t.position));return r.controls[0].position.set(...t.controlPrevious.position),r.controls[1].position.set(...t.controlNext.position),r.roundness=t.roundness,r.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored,r}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 r=0,o=this.controls.length;r<o;r++){let n=this.controls[r];this.position.distanceTo(n.position)<=t?n.position.copy(this.position):n.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 br(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}},sl=i=>i,Ui=new lr,al=new lr,Yb=new lr,ev=new lr,tv=new lr,rv=new lr,Iu=new Tu,Mu=new Tu;function Pu(i){let e=new lr;e.addVectors(i.v0,Ui.subVectors(i.v1,i.v0).multiplyScalar(2/3));let t=new lr;return t.addVectors(i.v2,al.subVectors(i.v1,i.v2).multiplyScalar(2/3)),new js(i.v0,e,t,i.v2)}function ki(i,e,t=Number.EPSILON){return Math.abs(i-e)<t}function ov(i,e,t=Number.EPSILON){return i.distanceTo(e)<t}function iv(i,e,t=Number.EPSILON){return i.distanceTo(e)<t}function ll(i,e,t){let r=Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2)),o=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),n=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2));return Math.acos((o*o+r*r-n*n)/(2*o*r))}function Ou(i,e,t,r,o){let n=Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2)),s=(i.y+e.y)/2,a=(i.x+e.x)/2,l=Math.sqrt(Math.pow(t,2)-Math.pow(n/2,2))*(i.y-e.y)/n,c=Math.sqrt(Math.pow(t,2)-Math.pow(n/2,2))*(e.x-i.x)/n;return r.set(a+l,s+c),o.set(a-l,s-c),[r,o]}function Au(i,e,t){let r=i.distanceTo(t),o=e.distanceTo(t);return r<o?e:i}function ju(i,e,t,r,o,n){let s=e.x-i.x,a=e.y-i.y,l=t.x-i.x,c=t.y-i.y,d=Math.sqrt((s+l)*(s+l)+(a+c)*(a+c)),p;return ll(e,i,t)>Math.PI&&(d*=-1),ki(c,a)?p=(a+c)*(r/d-.5)*8/3/(s-l):p=(s+l)*(r/d-.5)*8/3/(c-a),o.set(e.x-p*a,e.y+p*s),n.set(t.x+p*c,t.y-p*l),[o,n]}function cl(i,e){return i.position.equals(i.controls[1].position)&&e.position.equals(e.controls[0].position)}function _u(i,e,t,r,o=.5){let n=Ui.subVectors(e,i).multiplyScalar(o).add(i),s=al.subVectors(t,e).multiplyScalar(o).add(e),a=Yb.subVectors(r,t).multiplyScalar(o).add(t),l=n,c=ev.subVectors(s,n).multiplyScalar(o).add(n),d=tv.subVectors(a,s).multiplyScalar(o).add(s),p=a,u=rv.subVectors(d,c).multiplyScalar(o).add(c);return[i.x,i.y,l.x,l.y,c.x,c.y,u.x,u.y,d.x,d.y,p.x,p.y,r.x,r.y]}function Du(i,e,t=12,r=!0){let o=Mu.set(0,0,0),n,s=0,a=[];for(let l=0;l<e.length;l++){let c=sl(e[l]),d=Ui,p=oo(c,t);a.push(p);for(let u=0;u<=p;u++)if(c instanceof js||c instanceof nl||c instanceof _s){if(c.getPoint(u/p,d),o.set(d.x,d.y,0),n!==void 0&&iv(n,o))continue;n===void 0&&(n=Iu),n.copy(o),i.setXYZ(s,o.x,o.y,o.z),s++}}return r&&s>1&&!(i.getX(s-1)===i.getX(0)&&i.getY(s-1)===i.getY(0)&&i.getZ(s-1)===i.getZ(0))&&(i.setXYZ(s,i.getX(0),i.getY(0),i.getZ(0)),s++),i}function Bu(i,e,t,r=12,o=!0){let n=Mu.set(0,0,0),s=0,a=[];for(let l=0;l<e.length;l++){if(t[l]===!1)continue;let c,d=sl(e[l]),p=Ui,u=oo(d,r);a.push(u);for(let f=0;f<=u;f++)if(d instanceof js||d instanceof nl||d instanceof _s){if(d.getPoint(f/u,p),n.set(p.x,p.y,0),c==null?void 0:c.equals(n))continue;c===void 0?c=Iu:(i.setXYZ(s,c.x,c.y,c.z),s++,i.setXYZ(s,n.x,n.y,n.z),s++),c.copy(n)}}return o&&s>1&&!(i.getX(s-1)===i.getX(0)&&i.getY(s-1)===i.getY(0)&&i.getZ(s-1)===i.getZ(0))&&(i.setXYZ(s,i.getX(0),i.getY(0),i.getZ(0)),s++),a}function dl(i,e=12,t=!1){let r=[];for(let o=0,n=i.length;o<n;o++){let s=i[o],a=0;if(t&&s.roundedCurveCorner!==void 0){let l=oo(s.roundedCurveCorner,e)*.5;o>0&&(r[o-1]+=l),a+=l}s.curveAfter!==void 0&&(a+=oo(s.curveAfter,e)),r.push(a)}return i.length>0&&t&&i[0].roundedCurveCorner!==void 0&&(r[i.length-1]+=oo(i[0].roundedCurveCorner,e)*.5),r}function oo(i,e=12){return i&&i instanceof Kb?e*2:i&&(i instanceof _s||i instanceof Xb)?1:i&&i instanceof Qb?e*i.points.length:e}function Gu(i,e,t=12,r=!0){let o,n=0;for(let s=0;s<e.length;s++){let a=sl(e[s]),l=oo(a,t),c=Ui;for(let d=0;d<=l;d++)if(a instanceof js||a instanceof nl||a instanceof _s){if(a.getPoint(d/l,c),o!==void 0&&ov(o,c,Fi))continue;o===void 0&&(o=al),o.copy(c),i.push(c.x,c.y),n++}}return ki(i[0],i[i.length-2],Fi)&&ki(i[1],i[i.length-1],Fi)&&(i.pop(),i.pop()),r&&n>1&&!(ki(i[n-1],i[1],Fi)&&ki(i[n-2],i[0],Fi))&&(i.push(i[0],i[1]),n++),i}var hl=new zr,lv=new zr,cv=new zr,dv=new zr,pv=new zr,uv=new zr,Pe=class extends zu{constructor(e=100,t=100){super();this.points=[];this.shapeHoles=[];this.eventDispatcher=new nv;this.plane=new sv(new av(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=pl.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=t}static createFromState(e,t,r){let o=new Pe;return o.isClosed=e.isClosed,o.points=e.points.map(n=>br.create(n.id,n.data)),typeof e.roundness=="number"&&(o.roundness=e.roundness),o.shapeHoles=e.shapeHoles.map(n=>Pe.createFromState(n)),t!==void 0&&r!==void 0&&o.applySize(t,r),o.update(),o}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,r=this.points.length;t<r;t++)this.points[t].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(t=>this.getPointIndexById(t)).filter(t=>t>=0)}getPointIndexById(e){return this.points.findIndex(t=>t.uuid===e)}getLineIndexById(e){return this.getPointIndexById(e)}getBezierPoint(e){if(e<=this.points.length-1)return this.points[e];if(this.shapeHoles.length>0)for(let t=0,r=this.shapeHoles.length;t<r;t++){let o=this.shapeHoles[t],n=e-this.points.length;if(n<=o.points.length-1)return o.points[n]}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 r=0,o=this.shapeHoles.length;r<o;r++){let n=this.shapeHoles[r],s=n.points.indexOf(e);if(s>=0)return t+s;t+=n.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 r=hl.set(e,t);for(let o=0,n=this.points.length;o<n;o++){let s=this.points[o];s.position.multiply(r),s.controls[0].position.multiply(r),s.controls[1].position.multiply(r)}for(let o=0,n=this.shapeHoles.length;o<n;o++)this.shapeHoles[o].applyScale(e,t);this._update(!1)}createPoint(e,t=0,r=pl.generateUUID()){let o;e instanceof zr?o=e:o=new zr(e,t);let n=new br(r,o);return n.roundness=this.roundness,n}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,r=this.points.length;t<r;t++){let o=this.points[t];if(o.uuid===e)return o}}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(r=>r.uuid===e);t&&this.removePoint(t)}update(e=!0){for(let t=0,r=this.shapeHoles.length;t<r;t++)this.shapeHoles[t].update(!1);this._update(e)}extractShapePointsToBuffer(e,t=12,r=!1){this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t);let o=r?this.roundedCurveDivisions:this.curveDivisions;return Du(e,r?this.roundedCurves:this.curves,t,this.autoClose),o.reduce((n,s)=>n+s,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=dl(this.points,e,!1),this.roundedCurveDivisions=dl(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,t,r=12){return Bu(e,this.curves,t,r,this.autoClose).reduce((n,s)=>n+s,0)*2}extractShapePointsToFlatArray(e,t=12){return this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t),Gu(e,this.roundedCurves,t,this.autoClose)}getCurveIndexFromVertexId(e,t=!1){let r=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let o=t?this.roundedCurveDivisions:this.curveDivisions,n=0;t&&this.points[0].roundedCurveCorner!==void 0&&(n=oo(this.points[0].roundedCurveCorner,this.subdivision)*.5);let s=e-n;s<0&&(s+=o.reduce((a,l)=>a+l,0));for(let a=0,l=o.length;a<l;a++){let c=o[a];if(s<r+c)return[a,(s-r+1)/c];r+=c}return[0,1]}getCurveT(e,t,r){let o=this.points[e],n=this.points[e>=this.points.length-1?0:e+1],s=this.curveDivisions,a=s[e];if(cl(o,n)){let d=o.position.distanceTo(n.position);return o.position.distanceTo(hl.set(r.x,r.y))/d}let l=0;for(let d=0;d<e;d++)l+=s[d];return(t-l)/a}dispose(){this.eventDispatcher=null}_applyCurveForPoint(e,t){cl(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 r=this.curves[this.curves.length-1];e.curveBefore=r,t.curveAfter=r;let o=r.clone();e.roundedCurveBefore=o,t.roundedCurveAfter=o,e.roundedCurveCorner=void 0,this.roundedCurves.push(o)}_update(e=!0){var r;if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let o=0,n=this.points.length;o<n;o++){let s=this.points[o];if(o===0)this.moveTo(s.position.x,s.position.y);else{let a=this.points[o-1];this._applyCurveForPoint(s,a)}}let t=this.getLastPoint();if((t==null?void 0:t.curveAfter)&&(t.curveAfter=void 0),this.isClosed){let o=this.points[0],n=this.points[this.points.length-1];this._applyCurveForPoint(o,n)}if(this.points.length>2){let o=0;for(let n=0,s=this.points.length;n<s;n++){let a=this.points[n],l=a.roundness;if(!a.controlsMoved()&&l>0){let c=a.curveBefore,d=a.curveAfter;if(c===void 0||d===void 0)continue;let p=a.roundedCurveBefore,u=a.roundedCurveAfter,f=c.getLength(),m=d.getLength(),x=Math.min(l,f*.499),y=Math.min(l,m*.499),N=Math.min(x,y),L=1-N/f,w=N/m,B=c.getPointAt(L,hl),S=d.getPointAt(w,lv);this._subSplitCurve(c,p,L,B,void 0),this._subSplitCurve(d,u,w,void 0,S);let _;if(this.useCubicForRoundedCorners){let T=ll(B,a.position,S)/2,h=Math.tan(T)*B.distanceTo(a.position),[I,b]=Ou(B,S,h,cv,dv),P=Au(I,b,a.position),[v,D]=ju(P,B,S,h,pv,uv);_=new Ds(B.clone(),v.clone(),D.clone(),S.clone())}else _=new Eu(B.clone(),a.position.clone(),S.clone());a.roundedCurveCorner=_,this.roundedCurves.splice(n+o,0,_),o++}}}e&&((r=this.eventDispatcher)==null||r.dispatchEvent({type:"update"}))}_subSplitCurve(e,t,r,o,n){if(e instanceof ul)o!==void 0&&t.v2.copy(o),n!==void 0&&t.v1.copy(n);else{let s=e,a=t,l=s.getUtoTmapping(r,0),c=_u(s.v0,s.v1,s.v2,s.v3,l);return o!==void 0&&(a.v0.set(c[0],c[1]),a.v1.set(c[2],c[3]),a.v2.set(c[4],c[5]),a.v3.set(c[6],c[7])),n!==void 0&&(a.v0.set(c[6],c[7]),a.v1.set(c[8],c[9]),a.v2.set(c[10],c[11]),a.v3.set(c[12],c[13])),a}return t}clone(){let e=new Pe(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){var r;this.points=[],this.pointIDs=0;let t=e.points.length/7;for(let o=0;o<t;o++){let n=o*7,s=e.points[n+0],a=e.points[n+1],l=e.points[n+2],c=e.points[n+3],d=e.points[n+4],p=e.points[n+5],u=e.points[n+6],f=new br(pl.generateUUID(),new zr(s,a));f.controls[0].position.set(l,c),f.controls[1].position.set(d,p),f.roundness=u,this.points.push(f)}return this.shapeHoles=((r=e.shapeHoles)==null?void 0:r.length)?e.shapeHoles.map(o=>{let n=new Pe;return n.fromJSON(o),n}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e){let t=(o,n)=>{n instanceof Ds&&n.v3.equals(o.position)&&o.controls[0].position.copy(n.v2)},r=o=>{let n=[],s,a;for(s=0,a=o.length;s<a;s++)o[s]instanceof Eu&&(o[s]=Pu(o[s]));for(s=0,a=o.length;s<a;s++){let d=o[s],p=s>0?o[s-1]:null,u;d instanceof Ds?(u=this.createPoint(d.v0),u.controls[1].position.copy(d.v1)):d instanceof ul&&(u=this.createPoint(d.v1)),u!==void 0&&(p!==null&&t(u,p),n.push(u))}let l=o[o.length-1],c=!1;return l instanceof Ds?l.v3.equals(n[0].position)&&(n[0].controls[0].position.copy(l.v2),c=!0):l instanceof ul&&l.v2.equals(n[0].position)&&(c=!0),this.isClosed=c,n};return this.points=r(e.curves),e instanceof zu&&(this.shapeHoles=e.holes.map(o=>{let n=new Pe;return n.fromShape(o),n})),this.update(),this}};var ml=Math.PI*2;function fl({x:i,y:e},t,r,o,n){return{x:i*t+o,y:e*r+n}}function hv(i,e){let t=e===1.5707963267948966?.551915024494:e===-1.5707963267948966?-.551915024494:4/3*Math.tan(e/4),r=Math.cos(i),o=Math.sin(i),n=Math.cos(i+e),s=Math.sin(i+e);return[{x:r-o*t,y:o+r*t},{x:n+s*t,y:s-n*t},{x:n,y:s}]}function Fu(i,e,t,r){let o=i*r-e*t<0?-1:1,n=Math.min(1,Math.max(-1,i*t+e*r));return o*Math.acos(n)}function mv(i,e,t,r,o,n,s,a,l,c){let d=Math.pow(o,2),p=Math.pow(n,2),u=Math.pow(s,2),f=Math.pow(a,2),m=d*p-d*f-p*u;m<0&&(m=0),m/=d*f+p*u,m=Math.sqrt(m)*(l===c?-1:1);let x=m*o/n*a,y=m*-n/o*s,N=x+(i+t)/2,L=y+(e+r)/2,w=(s-x)/o,B=(a-y)/n,S=(-s-x)/o,_=(-a-y)/n,T=Fu(1,0,w,B),h=Fu(w,B,S,_);return!c&&h>0&&(h-=ml),c&&h<0&&(h+=ml),{centerx:N,centery:L,ang1:T,ang2:h}}function Ru({px:i,py:e,cx:t,cy:r,rx:o,ry:n,largeArcFlag:s,sweepFlag:a}){let l=[];if(o===0||n===0)return[];let c=(i-t)/2,d=(e-r)/2;if(c===0&&d===0)return[];o=Math.abs(o),n=Math.abs(n);let p=Math.pow(c,2)/Math.pow(o,2)+Math.pow(d,2)/Math.pow(n,2);p>1&&(o*=Math.sqrt(p),n*=Math.sqrt(p));let u=mv(i,e,t,r,o,n,c,d,s,a),{ang1:f,ang2:m}=u,{centerx:x,centery:y}=u,N=Math.abs(m)/(ml/4);Math.abs(1-N)<1e-7&&(N=1);let L=Math.max(Math.ceil(N),1);m/=L;for(let w=0;w<L;w++)l.push(hv(f,m)),f+=m;return l.map(w=>{let{x:B,y:S}=fl(w[0],o,n,x,y),{x:_,y:T}=fl(w[1],o,n,x,y),{x:h,y:I}=fl(w[2],o,n,x,y);return{x1:B,y1:S,x2:_,y2:T,x:h,y:I}})}import{BufferAttribute as Gs,BufferGeometry as bv}from"three";var $e;(function(i){i[i.ODD=0]="ODD",i[i.NONZERO=1]="NONZERO",i[i.POSITIVE=2]="POSITIVE",i[i.NEGATIVE=3]="NEGATIVE",i[i.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})($e||($e={}));var st;(function(i){i[i.POLYGONS=0]="POLYGONS",i[i.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",i[i.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(st||(st={}));function ce(i,e){if(!i)throw e||"Assertion Failed!"}var ae=function(){function i(){}return i.vertEq=function(e,t){return e.s===t.s&&e.t===t.t},i.vertLeq=function(e,t){return e.s<t.s||e.s===t.s&&e.t<=t.t},i.transLeq=function(e,t){return e.t<t.t||e.t===t.t&&e.s<=t.s},i.edgeGoesLeft=function(e){return i.vertLeq(e.Dst,e.Org)},i.edgeGoesRight=function(e){return i.vertLeq(e.Org,e.Dst)},i.vertL1dist=function(e,t){return Math.abs(e.s-t.s)+Math.abs(e.t-t.t)},i.edgeEval=function(e,t,r){ce(i.vertLeq(e,t)&&i.vertLeq(t,r));var o=t.s-e.s,n=r.s-t.s;return o+n>0?o<n?t.t-e.t+(e.t-r.t)*(o/(o+n)):t.t-r.t+(r.t-e.t)*(n/(o+n)):0},i.edgeSign=function(e,t,r){ce(i.vertLeq(e,t)&&i.vertLeq(t,r));var o=t.s-e.s,n=r.s-t.s;return o+n>0?(t.t-r.t)*o+(t.t-e.t)*n:0},i.transEval=function(e,t,r){ce(i.transLeq(e,t)&&i.transLeq(t,r));var o=t.t-e.t,n=r.t-t.t;return o+n>0?o<n?t.s-e.s+(e.s-r.s)*(o/(o+n)):t.s-r.s+(r.s-e.s)*(n/(o+n)):0},i.transSign=function(e,t,r){ce(i.transLeq(e,t)&&i.transLeq(t,r));var o=t.t-e.t,n=r.t-t.t;return o+n>0?(t.s-r.s)*o+(t.s-e.s)*n:0},i.vertCCW=function(e,t,r){return e.s*(t.t-r.t)+t.s*(r.t-e.t)+r.s*(e.t-t.t)>=0},i.interpolate=function(e,t,r,o){return e=e<0?0:e,r=r<0?0:r,e<=r?r===0?(t+o)/2:t+(o-t)*(e/(e+r)):o+(t-o)*(r/(e+r))},i.intersect=function(e,t,r,o,n){var s,a,l;i.vertLeq(e,t)||(l=e,e=t,t=l),i.vertLeq(r,o)||(l=r,r=o,o=l),i.vertLeq(e,r)||(l=e,e=r,r=l,l=t,t=o,o=l),i.vertLeq(r,t)?i.vertLeq(t,o)?(s=i.edgeEval(e,r,t),a=i.edgeEval(r,t,o),s+a<0&&(s=-s,a=-a),n.s=i.interpolate(s,r.s,a,t.s)):(s=i.edgeSign(e,r,t),a=-i.edgeSign(e,o,t),s+a<0&&(s=-s,a=-a),n.s=i.interpolate(s,r.s,a,o.s)):n.s=(r.s+t.s)/2,i.transLeq(e,t)||(l=e,e=t,t=l),i.transLeq(r,o)||(l=r,r=o,o=l),i.transLeq(e,r)||(l=e,e=r,r=l,l=t,t=o,o=l),i.transLeq(r,t)?i.transLeq(t,o)?(s=i.transEval(e,r,t),a=i.transEval(r,t,o),s+a<0&&(s=-s,a=-a),n.t=i.interpolate(s,r.t,a,t.t)):(s=i.transSign(e,r,t),a=-i.transSign(e,o,t),s+a<0&&(s=-s,a=-a),n.t=i.interpolate(s,r.t,a,o.t)):n.t=(r.t+t.t)/2},i}(),Hi=function(){function i(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return i}(),Bs=function(){function i(e){this.side=e,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(i.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(e){this.Sym.Lface=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(e){this.Sym.Org=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(e){this.Sym.Lnext=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(e){this.Onext.Sym=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(e){this.Lnext.Sym=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(e){this.Sym.Onext=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(e){this.Sym.Onext.Sym=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(e){this.Sym.Lnext.Sym=e},enumerable:!0,configurable:!0}),i}(),li=function(){function i(){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 i}(),Vu=function(){function i(){var e=new li,t=new Hi,r=new Bs(0),o=new Bs(1);e.next=e.prev=e,e.anEdge=null,t.next=t.prev=t,r.next=r,r.Sym=o,o.next=o,o.Sym=r,this.vHead=e,this.fHead=t,this.eHead=r,this.eHeadSym=o}return i.prototype.makeEdge_=function(e){var t=new Bs(0),r=new Bs(1);e.Sym.side<e.side&&(e=e.Sym);var o=e.Sym.next;return r.next=o,o.Sym.next=t,t.next=e,e.Sym.next=r,t.Sym=r,t.Onext=t,t.Lnext=r,t.Org=null,t.Lface=null,t.winding=0,t.activeRegion=null,r.Sym=t,r.Onext=r,r.Lnext=t,r.Org=null,r.Lface=null,r.winding=0,r.activeRegion=null,t},i.prototype.splice_=function(e,t){var r=e.Onext,o=t.Onext;r.Sym.Lnext=t,o.Sym.Lnext=e,e.Onext=o,t.Onext=r},i.prototype.makeVertex_=function(e,t,r){var o=e;ce(o,"Vertex can't be null!");var n=r.prev;o.prev=n,n.next=o,o.next=r,r.prev=o,o.anEdge=t;var s=t;do s.Org=o,s=s.Onext;while(s!==t)},i.prototype.makeFace_=function(e,t,r){var o=e;ce(o,"Face can't be null");var n=r.prev;o.prev=n,n.next=o,o.next=r,r.prev=o,o.anEdge=t,o.trail=null,o.marked=!1,o.inside=r.inside;var s=t;do s.Lface=o,s=s.Lnext;while(s!==t)},i.prototype.killEdge_=function(e){e.Sym.side<e.side&&(e=e.Sym);var t=e.next,r=e.Sym.next;t.Sym.next=r,r.Sym.next=t},i.prototype.killVertex_=function(e,t){var r=e.anEdge,o=r;do o.Org=t,o=o.Onext;while(o!==r);var n=e.prev,s=e.next;s.prev=n,n.next=s},i.prototype.killFace_=function(e,t){var r=e.anEdge,o=r;do o.Lface=t,o=o.Lnext;while(o!==r);var n=e.prev,s=e.next;s.prev=n,n.next=s},i.prototype.makeEdge=function(){var e=new li,t=new li,r=new Hi,o=this.makeEdge_(this.eHead);return this.makeVertex_(e,o,this.vHead),this.makeVertex_(t,o.Sym,this.vHead),this.makeFace_(r,o,this.fHead),o},i.prototype.splice=function(e,t){var r=!1,o=!1;if(e!==t){if(t.Org!==e.Org&&(o=!0,this.killVertex_(t.Org,e.Org)),t.Lface!==e.Lface&&(r=!0,this.killFace_(t.Lface,e.Lface)),this.splice_(t,e),!o){var n=new li;this.makeVertex_(n,t,e.Org),e.Org.anEdge=e}if(!r){var s=new Hi;this.makeFace_(s,t,e.Lface),e.Lface.anEdge=e}}},i.prototype.delete=function(e){var t=e.Sym,r=!1;if(e.Lface!==e.Rface&&(r=!0,this.killFace_(e.Lface,e.Rface)),e.Onext===e)this.killVertex_(e.Org,null);else if(e.Rface.anEdge=e.Oprev,e.Org.anEdge=e.Onext,this.splice_(e,e.Oprev),!r){var o=new Hi;this.makeFace_(o,e,e.Lface)}t.Onext===t?(this.killVertex_(t.Org,null),this.killFace_(t.Lface,null)):(e.Lface.anEdge=t.Oprev,t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev)),this.killEdge_(e)},i.prototype.addEdgeVertex=function(e){var t=this.makeEdge_(e),r=t.Sym;this.splice_(t,e.Lnext),t.Org=e.Dst;var o=new li;return this.makeVertex_(o,r,t.Org),t.Lface=r.Lface=e.Lface,t},i.prototype.splitEdge=function(e){var t=this.addEdgeVertex(e),r=t.Sym;return this.splice_(e.Sym,e.Sym.Oprev),this.splice_(e.Sym,r),e.Dst=r.Org,r.Dst.anEdge=r.Sym,r.Rface=e.Rface,r.winding=e.winding,r.Sym.winding=e.Sym.winding,r.idx=e.idx,r.Sym.idx=e.Sym.idx,r},i.prototype.connect=function(e,t){var r=!1,o=this.makeEdge_(e),n=o.Sym;if(t.Lface!==e.Lface&&(r=!0,this.killFace_(t.Lface,e.Lface)),this.splice_(o,e.Lnext),this.splice_(n,t),o.Org=e.Dst,n.Org=t.Org,o.Lface=n.Lface=e.Lface,e.Lface.anEdge=n,!r){var s=new Hi;this.makeFace_(s,o,e.Lface)}return o},i.prototype.zapFace=function(e){var t=e.anEdge,r,o,n,s,a;o=t.Lnext;do r=o,o=r.Lnext,r.Lface=null,r.Rface===null&&(r.Onext===r?this.killVertex_(r.Org,null):(r.Org.anEdge=r.Onext,this.splice_(r,r.Oprev)),n=r.Sym,n.Onext===n?this.killVertex_(n.Org,null):(n.Org.anEdge=n.Onext,this.splice_(n,n.Oprev)),this.killEdge_(r));while(r!=t);s=e.prev,a=e.next,a.prev=s,s.next=a},i.prototype.countFaceVerts_=function(e){var t=e.anEdge,r=0;do r++,t=t.Lnext;while(t!==e.anEdge);return r},i.prototype.mergeConvexFaces=function(e){var t,r,o,n,s,a,l;for(t=this.fHead.next;t!==this.fHead;t=t.next)if(!!t.inside)for(r=t.anEdge,s=r.Org;o=r.Lnext,n=r.Sym,n&&n.Lface&&n.Lface.inside&&(a=this.countFaceVerts_(t),l=this.countFaceVerts_(n.Lface),a+l-2<=e&&ae.vertCCW(r.Lprev.Org,r.Org,n.Lnext.Lnext.Org)&&ae.vertCCW(n.Lprev.Org,n.Org,r.Lnext.Lnext.Org)&&(o=n.Lnext,this.delete(n),r=null,n=null)),!(r&&r.Lnext.Org===s);)r=o;return!0},i.prototype.check=function(){var e=this.fHead,t=this.vHead,r=this.eHead,o,n,s,a,l,c;for(n=e,n=e;(o=n.next)!==e;n=o){ce(o.prev===n),l=o.anEdge;do ce(l.Sym!==l),ce(l.Sym.Sym===l),ce(l.Lnext.Onext.Sym===l),ce(l.Onext.Sym.Lnext===l),ce(l.Lface===o),l=l.Lnext;while(l!==o.anEdge)}for(ce(o.prev===n&&o.anEdge===null),a=t,a=t;(s=a.next)!==t;a=s){ce(s.prev===a),l=s.anEdge;do ce(l.Sym!==l),ce(l.Sym.Sym===l),ce(l.Lnext.Onext.Sym===l),ce(l.Onext.Sym.Lnext===l),ce(l.Org===s),l=l.Onext;while(l!==s.anEdge)}for(ce(s.prev===a&&s.anEdge===null),c=r,c=r;(l=c.next)!==r;c=l)ce(l.Sym.next===c.Sym),ce(l.Sym!==l),ce(l.Sym.Sym===l),ce(l.Org!==null),ce(l.Dst!==null),ce(l.Lnext.Onext.Sym===l),ce(l.Onext.Sym.Lnext===l);ce(l.Sym.next===c.Sym&&l.Sym===this.eHeadSym&&l.Sym.Sym===l&&l.Org===null&&l.Dst===null&&l.Lface===null&&l.Rface===null)},i}(),Uu=function(){function i(){this.handle=null}return i}(),ku=function(){function i(){this.key=null,this.node=0}return i}(),fv=function(){function i(e,t){this.leq=t,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=e,this.nodes=[],this.handles=[];for(var r=0;r<e+1;r++)this.nodes[r]=new Uu,this.handles[r]=new ku;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return i.prototype.floatDown_=function(e){var t=this.nodes,r=this.handles,o,n,s;for(o=t[e].handle;;){if(s=e<<1,s<this.size&&this.leq(r[t[s+1].handle].key,r[t[s].handle].key)&&++s,ce(s<=this.max),n=t[s].handle,s>this.size||this.leq(r[o].key,r[n].key)){t[e].handle=o,r[o].node=e;break}t[e].handle=n,r[n].node=e,e=s}},i.prototype.floatUp_=function(e){var t=this.nodes,r=this.handles,o,n,s;for(o=t[e].handle;;){if(s=e>>1,n=t[s].handle,s===0||this.leq(r[n].key,r[o].key)){t[e].handle=o,r[o].node=e;break}t[e].handle=n,r[n].node=e,e=s}},i.prototype.init=function(){for(var e=this.size;e>=1;--e)this.floatDown_(e);this.initialized=!0},i.prototype.min=function(){return this.handles[this.nodes[1].handle].key},i.prototype.insert=function(e){var t,r;if(t=++this.size,t*2>this.max){this.max*=2;var o,n;for(n=this.nodes.length,this.nodes.length=this.max+1,o=n;o<this.nodes.length;o++)this.nodes[o]=new Uu;for(n=this.handles.length,this.handles.length=this.max+1,o=n;o<this.handles.length;o++)this.handles[o]=new ku}return this.freeList===0?r=t:(r=this.freeList,this.freeList=this.handles[r].node),this.nodes[t].handle=r,this.handles[r].node=t,this.handles[r].key=e,this.initialized&&this.floatUp_(t),r},i.prototype.extractMin=function(){var e=this.nodes,t=this.handles,r=e[1].handle,o=t[r].key;return this.size>0&&(e[1].handle=e[this.size].handle,t[e[1].handle].node=1,t[r].key=null,t[r].node=this.freeList,this.freeList=r,--this.size,this.size>0&&this.floatDown_(1)),o},i.prototype.delete=function(e){var t=this.nodes,r=this.handles,o;ce(e>=1&&e<=this.max&&r[e].key!==null),o=r[e].node,t[o].handle=t[this.size].handle,r[t[o].handle].node=o,--this.size,o<=this.size&&(o<=1||this.leq(r[t[o>>1].handle].key,r[t[o].handle].key)?this.floatDown_(o):this.floatUp_(o)),r[e].key=null,r[e].node=this.freeList,this.freeList=e},i}(),yl=function(){function i(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return i}(),Hu=function(){function i(){this.key=null,this.next=null,this.prev=null}return i}(),yv=function(){function i(e,t){this.frame=e,this.leq=t,this.head=new Hu,this.head.next=this.head,this.head.prev=this.head}return i.prototype.min=function(){return this.head.next},i.prototype.max=function(){return this.head.prev},i.prototype.insert=function(e){return this.insertBefore(this.head,e)},i.prototype.search=function(e){var t=this.head;do t=t.next;while(t.key!==null&&!this.leq(this.frame,e,t.key));return t},i.prototype.insertBefore=function(e,t){do e=e.prev;while(e.key!==null&&!this.leq(this.frame,e.key,t));var r=new Hu;return r.key=t,r.next=e.next,e.next.prev=r,r.prev=e,e.next=r,r},i.prototype.delete=function(e){e.next.prev=e.prev,e.prev.next=e.next},i}(),gv=function(){function i(){}return i.regionBelow=function(e){return e.nodeUp.prev.key},i.regionAbove=function(e){return e.nodeUp.next.key},i.debugEvent=function(e){},i.addWinding=function(e,t){e.winding+=t.winding,e.Sym.winding+=t.Sym.winding},i.edgeLeq=function(e,t,r){var o=e.event,n=t.eUp,s=r.eUp;if(n.Dst===o)return s.Dst===o?ae.vertLeq(n.Org,s.Org)?ae.edgeSign(s.Dst,n.Org,s.Org)<=0:ae.edgeSign(n.Dst,s.Org,n.Org)>=0:ae.edgeSign(s.Dst,o,s.Org)<=0;if(s.Dst===o)return ae.edgeSign(n.Dst,o,n.Org)>=0;var a=ae.edgeEval(n.Dst,o,n.Org),l=ae.edgeEval(s.Dst,o,s.Org);return a>=l},i.deleteRegion=function(e,t){t.fixUpperEdge&&ce(t.eUp.winding===0),t.eUp.activeRegion=null,e.dict.delete(t.nodeUp)},i.fixUpperEdge=function(e,t,r){ce(t.fixUpperEdge),e.mesh.delete(t.eUp),t.fixUpperEdge=!1,t.eUp=r,r.activeRegion=t},i.topLeftRegion=function(e,t){var r=t.eUp.Org,o;do t=i.regionAbove(t);while(t.eUp.Org===r);if(t.fixUpperEdge){if(o=e.mesh.connect(i.regionBelow(t).eUp.Sym,t.eUp.Lnext),o===null)return null;i.fixUpperEdge(e,t,o),t=i.regionAbove(t)}return t},i.topRightRegion=function(e){var t=e.eUp.Dst;do e=i.regionAbove(e);while(e.eUp.Dst===t);return e},i.addRegionBelow=function(e,t,r){var o=new yl;return o.eUp=r,o.nodeUp=e.dict.insertBefore(t.nodeUp,o),o.fixUpperEdge=!1,o.sentinel=!1,o.dirty=!1,r.activeRegion=o,o},i.isWindingInside=function(e,t){switch(e.windingRule){case $e.ODD:return(t&1)!=0;case $e.NONZERO:return t!==0;case $e.POSITIVE:return t>0;case $e.NEGATIVE:return t<0;case $e.ABS_GEQ_TWO:return t>=2||t<=-2}throw new Error("Invalid winding rulle")},i.computeWinding=function(e,t){t.windingNumber=i.regionAbove(t).windingNumber+t.eUp.winding,t.inside=i.isWindingInside(e,t.windingNumber)},i.finishRegion=function(e,t){var r=t.eUp,o=r.Lface;o.inside=t.inside,o.anEdge=r,i.deleteRegion(e,t)},i.finishLeftRegions=function(e,t,r){for(var o,n=null,s=t,a=t.eUp;s!==r;){if(s.fixUpperEdge=!1,n=i.regionBelow(s),o=n.eUp,o.Org!=a.Org){if(!n.fixUpperEdge){i.finishRegion(e,s);break}o=e.mesh.connect(a.Lprev,o.Sym),i.fixUpperEdge(e,n,o)}a.Onext!==o&&(e.mesh.splice(o.Oprev,o),e.mesh.splice(a,o)),i.finishRegion(e,s),a=n.eUp,s=n}return a},i.addRightEdges=function(e,t,r,o,n,s){var a,l,c,d,p=!0;c=r;do ce(ae.vertLeq(c.Org,c.Dst)),i.addRegionBelow(e,t,c.Sym),c=c.Onext;while(c!==o);for(n===null&&(n=i.regionBelow(t).eUp.Rprev),l=t,d=n;a=i.regionBelow(l),c=a.eUp.Sym,c.Org===d.Org;)c.Onext!==d&&(e.mesh.splice(c.Oprev,c),e.mesh.splice(d.Oprev,c)),a.windingNumber=l.windingNumber-c.winding,a.inside=i.isWindingInside(e,a.windingNumber),l.dirty=!0,!p&&i.checkForRightSplice(e,l)&&(i.addWinding(c,d),i.deleteRegion(e,l),e.mesh.delete(d)),p=!1,l=a,d=c;l.dirty=!0,ce(l.windingNumber-c.winding===a.windingNumber),s&&i.walkDirtyRegions(e,l)},i.spliceMergeVertices=function(e,t,r){e.mesh.splice(t,r)},i.vertexWeights=function(e,t,r){var o=ae.vertL1dist(t,e),n=ae.vertL1dist(r,e),s=.5*n/(o+n),a=.5*o/(o+n);e.coords[0]+=s*t.coords[0]+a*r.coords[0],e.coords[1]+=s*t.coords[1]+a*r.coords[1],e.coords[2]+=s*t.coords[2]+a*r.coords[2]},i.getIntersectData=function(e,t,r,o,n,s){t.coords[0]=t.coords[1]=t.coords[2]=0,t.idx=-1,i.vertexWeights(t,r,o),i.vertexWeights(t,n,s)},i.checkForRightSplice=function(e,t){var r=i.regionBelow(t),o=t.eUp,n=r.eUp;if(ae.vertLeq(o.Org,n.Org)){if(ae.edgeSign(n.Dst,o.Org,n.Org)>0)return!1;ae.vertEq(o.Org,n.Org)?o.Org!==n.Org&&(e.pq.delete(o.Org.pqHandle),i.spliceMergeVertices(e,n.Oprev,o)):(e.mesh.splitEdge(n.Sym),e.mesh.splice(o,n.Oprev),t.dirty=r.dirty=!0)}else{if(ae.edgeSign(o.Dst,n.Org,o.Org)<0)return!1;i.regionAbove(t).dirty=t.dirty=!0,e.mesh.splitEdge(o.Sym),e.mesh.splice(n.Oprev,o)}return!0},i.checkForLeftSplice=function(e,t){var r=i.regionBelow(t),o=t.eUp,n=r.eUp,s;if(ce(!ae.vertEq(o.Dst,n.Dst)),ae.vertLeq(o.Dst,n.Dst)){if(ae.edgeSign(o.Dst,n.Dst,o.Org)<0)return!1;i.regionAbove(t).dirty=t.dirty=!0,s=e.mesh.splitEdge(o),e.mesh.splice(n.Sym,s),s.Lface.inside=t.inside}else{if(ae.edgeSign(n.Dst,o.Dst,n.Org)>0)return!1;t.dirty=r.dirty=!0,s=e.mesh.splitEdge(n),e.mesh.splice(o.Lnext,n.Sym),s.Rface.inside=t.inside}return!0},i.checkForIntersect=function(e,t){var r=i.regionBelow(t),o=t.eUp,n=r.eUp,s=o.Org,a=n.Org,l=o.Dst,c=n.Dst,d,p,u=new li,f,m;if(ce(!ae.vertEq(c,l)),ce(ae.edgeSign(l,e.event,s)<=0),ce(ae.edgeSign(c,e.event,a)>=0),ce(s!==e.event&&a!==e.event),ce(!t.fixUpperEdge&&!r.fixUpperEdge),s===a||(d=Math.min(s.t,l.t),p=Math.max(a.t,c.t),d>p))return!1;if(ae.vertLeq(s,a)){if(ae.edgeSign(c,s,a)>0)return!1}else if(ae.edgeSign(l,a,s)<0)return!1;return i.debugEvent(e),ae.intersect(l,s,c,a,u),ce(Math.min(s.t,l.t)<=u.t),ce(u.t<=Math.max(a.t,c.t)),ce(Math.min(c.s,l.s)<=u.s),ce(u.s<=Math.max(a.s,s.s)),ae.vertLeq(u,e.event)&&(u.s=e.event.s,u.t=e.event.t),f=ae.vertLeq(s,a)?s:a,ae.vertLeq(f,u)&&(u.s=f.s,u.t=f.t),ae.vertEq(u,s)||ae.vertEq(u,a)?(i.checkForRightSplice(e,t),!1):!ae.vertEq(l,e.event)&&ae.edgeSign(l,e.event,u)>=0||!ae.vertEq(c,e.event)&&ae.edgeSign(c,e.event,u)<=0?c===e.event?(e.mesh.splitEdge(o.Sym),e.mesh.splice(n.Sym,o),t=i.topLeftRegion(e,t),o=i.regionBelow(t).eUp,i.finishLeftRegions(e,i.regionBelow(t),r),i.addRightEdges(e,t,o.Oprev,o,o,!0),!0):l===e.event?(e.mesh.splitEdge(n.Sym),e.mesh.splice(o.Lnext,n.Oprev),r=t,t=i.topRightRegion(t),m=i.regionBelow(t).eUp.Rprev,r.eUp=n.Oprev,n=i.finishLeftRegions(e,r,null),i.addRightEdges(e,t,n.Onext,o.Rprev,m,!0),!0):(ae.edgeSign(l,e.event,u)>=0&&(i.regionAbove(t).dirty=t.dirty=!0,e.mesh.splitEdge(o.Sym),o.Org.s=e.event.s,o.Org.t=e.event.t),ae.edgeSign(c,e.event,u)<=0&&(t.dirty=r.dirty=!0,e.mesh.splitEdge(n.Sym),n.Org.s=e.event.s,n.Org.t=e.event.t),!1):(e.mesh.splitEdge(o.Sym),e.mesh.splitEdge(n.Sym),e.mesh.splice(n.Oprev,o),o.Org.s=u.s,o.Org.t=u.t,o.Org.pqHandle=e.pq.insert(o.Org),i.getIntersectData(e,o.Org,s,l,a,c),i.regionAbove(t).dirty=t.dirty=r.dirty=!0,!1)},i.walkDirtyRegions=function(e,t){for(var r=i.regionBelow(t),o,n;;){for(;r.dirty;)t=r,r=i.regionBelow(r);if(!t.dirty&&(r=t,t=i.regionAbove(t),t===null||!t.dirty))return;if(t.dirty=!1,o=t.eUp,n=r.eUp,o.Dst!==n.Dst&&i.checkForLeftSplice(e,t)&&(r.fixUpperEdge?(i.deleteRegion(e,r),e.mesh.delete(n),r=i.regionBelow(t),n=r.eUp):t.fixUpperEdge&&(i.deleteRegion(e,t),e.mesh.delete(o),t=i.regionAbove(r),o=t.eUp)),o.Org!==n.Org)if(o.Dst!==n.Dst&&!t.fixUpperEdge&&!r.fixUpperEdge&&(o.Dst===e.event||n.Dst===e.event)){if(i.checkForIntersect(e,t))return}else i.checkForRightSplice(e,t);o.Org===n.Org&&o.Dst===n.Dst&&(i.addWinding(n,o),i.deleteRegion(e,t),e.mesh.delete(o),t=i.regionAbove(r))}},i.connectRightVertex=function(e,t,r){var o,n=r.Onext,s=i.regionBelow(t),a=t.eUp,l=s.eUp,c=!1;if(a.Dst!==l.Dst&&i.checkForIntersect(e,t),ae.vertEq(a.Org,e.event)&&(e.mesh.splice(n.Oprev,a),t=i.topLeftRegion(e,t),n=i.regionBelow(t).eUp,i.finishLeftRegions(e,i.regionBelow(t),s),c=!0),ae.vertEq(l.Org,e.event)&&(e.mesh.splice(r,l.Oprev),r=i.finishLeftRegions(e,s,null),c=!0),c){i.addRightEdges(e,t,r.Onext,n,n,!0);return}ae.vertLeq(l.Org,a.Org)?o=l.Oprev:o=a,o=e.mesh.connect(r.Lprev,o),i.addRightEdges(e,t,o,o.Onext,o.Onext,!1),o.Sym.activeRegion.fixUpperEdge=!0,i.walkDirtyRegions(e,t)},i.connectLeftDegenerate=function(e,t,r){var o,n,s,a,l;if(o=t.eUp,ae.vertEq(o.Org,r)){ce(!1),i.spliceMergeVertices(e,o,r.anEdge);return}if(!ae.vertEq(o.Dst,r)){e.mesh.splitEdge(o.Sym),t.fixUpperEdge&&(e.mesh.delete(o.Onext),t.fixUpperEdge=!1),e.mesh.splice(r.anEdge,o),i.sweepEvent(e,r);return}ce(!1),t=i.topRightRegion(t),l=i.regionBelow(t),s=l.eUp.Sym,n=a=s.Onext,l.fixUpperEdge&&(ce(n!==s),i.deleteRegion(e,l),e.mesh.delete(s),s=n.Oprev),e.mesh.splice(r.anEdge,s),ae.edgeGoesLeft(n)||(n=null),i.addRightEdges(e,t,s.Onext,a,n,!0)},i.connectLeftVertex=function(e,t){var r,o,n,s,a,l,c=new yl;if(c.eUp=t.anEdge.Sym,r=e.dict.search(c).key,o=i.regionBelow(r),!!o){if(s=r.eUp,a=o.eUp,ae.edgeSign(s.Dst,t,s.Org)===0){i.connectLeftDegenerate(e,r,t);return}if(n=ae.vertLeq(a.Dst,s.Dst)?r:o,r.inside||n.fixUpperEdge){if(n===r)l=e.mesh.connect(t.anEdge.Sym,s.Lnext);else{var d=e.mesh.connect(a.Dnext,t.anEdge);l=d.Sym}n.fixUpperEdge?i.fixUpperEdge(e,n,l):i.computeWinding(e,i.addRegionBelow(e,r,l)),i.sweepEvent(e,t)}else i.addRightEdges(e,r,t.anEdge,t.anEdge,null,!0)}},i.sweepEvent=function(e,t){e.event=t,i.debugEvent(e);for(var r=t.anEdge;r.activeRegion===null;)if(r=r.Onext,r===t.anEdge){i.connectLeftVertex(e,t);return}var o=i.topLeftRegion(e,r.activeRegion);ce(o!==null);var n=i.regionBelow(o),s=n.eUp,a=i.finishLeftRegions(e,n,null);a.Onext===s?i.connectRightVertex(e,o,a):i.addRightEdges(e,o,a.Onext,s,s,!0)},i.addSentinel=function(e,t,r,o){var n=new yl,s=e.mesh.makeEdge();s.Org.s=r,s.Org.t=o,s.Dst.s=t,s.Dst.t=o,e.event=s.Dst,n.eUp=s,n.windingNumber=0,n.inside=!1,n.fixUpperEdge=!1,n.sentinel=!0,n.dirty=!1,n.nodeUp=e.dict.insert(n)},i.initEdgeDict=function(e){e.dict=new yv(e,i.edgeLeq);var t=e.bmax[0]-e.bmin[0],r=e.bmax[1]-e.bmin[1],o=e.bmin[0]-t,n=e.bmax[0]+t,s=e.bmin[1]-r,a=e.bmax[1]+r;i.addSentinel(e,o,n,s),i.addSentinel(e,o,n,a)},i.doneEdgeDict=function(e){for(var t,r=0;(t=e.dict.min().key)!==null;)t.sentinel||(ce(t.fixUpperEdge),ce(++r==1)),ce(t.windingNumber===0),i.deleteRegion(e,t)},i.removeDegenerateEdges=function(e){var t,r,o,n=e.mesh.eHead;for(t=n.next;t!==n;t=r)r=t.next,o=t.Lnext,ae.vertEq(t.Org,t.Dst)&&t.Lnext.Lnext!==t&&(i.spliceMergeVertices(e,o,t),e.mesh.delete(t),t=o,o=t.Lnext),o.Lnext===t&&(o!==t&&((o===r||o===r.Sym)&&(r=r.next),e.mesh.delete(o)),(t===r||t===r.Sym)&&(r=r.next),e.mesh.delete(t))},i.initPriorityQ=function(e){var t,r,o,n=0;for(o=e.mesh.vHead,r=o.next;r!==o;r=r.next)n++;for(n+=8,t=e.pq=new fv(n,ae.vertLeq),o=e.mesh.vHead,r=o.next;r!==o;r=r.next)r.pqHandle=t.insert(r);return r!==o?!1:(t.init(),!0)},i.donePriorityQ=function(e){e.pq=null},i.removeDegenerateFaces=function(e,t){var r,o,n;for(r=t.fHead.next;r!==t.fHead;r=o)o=r.next,n=r.anEdge,ce(n.Lnext!==n),n.Lnext.Lnext===n&&(i.addWinding(n.Onext,n),e.mesh.delete(n));return!0},i.computeInterior=function(e,t){t===void 0&&(t=!0);var r,o;if(i.removeDegenerateEdges(e),!i.initPriorityQ(e))return!1;for(i.initEdgeDict(e);(r=e.pq.extractMin())!==null;){for(;o=e.pq.min(),!(o===null||!ae.vertEq(o,r));)o=e.pq.extractMin(),i.spliceMergeVertices(e,r.anEdge,o.anEdge);i.sweepEvent(e,r)}return e.event=e.dict.min().key.eUp.Org,i.debugEvent(e),i.doneEdgeDict(e),i.donePriorityQ(e),i.removeDegenerateFaces(e,e.mesh)?(t&&e.mesh.check(),!0):!1},i}(),xv=function(){function i(){this.mesh=new Vu,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=$e.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 i.prototype.dot_=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]},i.prototype.normalize_=function(e){var t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2];if(!t)throw"Zero-size vector!";t=Math.sqrt(t),e[0]/=t,e[1]/=t,e[2]/=t},i.prototype.longAxis_=function(e){var t=0;return Math.abs(e[1])>Math.abs(e[0])&&(t=1),Math.abs(e[2])>Math.abs(e[t])&&(t=2),t},i.prototype.computeNormal_=function(e){var t,r,o,n,s,a,l=[0,0,0],c=[0,0,0],d=[0,0,0],p=[0,0,0],u=[0,0,0],f=[null,null,null],m=[null,null,null],x=this.mesh.vHead;t=x.next;for(var y=0;y<3;++y)n=t.coords[y],c[y]=n,m[y]=t,l[y]=n,f[y]=t;for(t=x.next;t!==x;t=t.next)for(var N=0;N<3;++N)n=t.coords[N],n<c[N]&&(c[N]=n,m[N]=t),n>l[N]&&(l[N]=n,f[N]=t);var L=0;if(l[1]-c[1]>l[0]-c[0]&&(L=1),l[2]-c[2]>l[L]-c[L]&&(L=2),c[L]>=l[L]){e[0]=0,e[1]=0,e[2]=1;return}for(a=0,r=m[L],o=f[L],d[0]=r.coords[0]-o.coords[0],d[1]=r.coords[1]-o.coords[1],d[2]=r.coords[2]-o.coords[2],t=x.next;t!==x;t=t.next)p[0]=t.coords[0]-o.coords[0],p[1]=t.coords[1]-o.coords[1],p[2]=t.coords[2]-o.coords[2],u[0]=d[1]*p[2]-d[2]*p[1],u[1]=d[2]*p[0]-d[0]*p[2],u[2]=d[0]*p[1]-d[1]*p[0],s=u[0]*u[0]+u[1]*u[1]+u[2]*u[2],s>a&&(a=s,e[0]=u[0],e[1]=u[1],e[2]=u[2]);a<=0&&(e[0]=e[1]=e[2]=0,e[this.longAxis_(d)]=1)},i.prototype.checkOrientation_=function(){for(var e=this.mesh.fHead,t,r=this.mesh.vHead,o,n=0,s=e.next;s!==e;s=s.next)if(o=s.anEdge,!(o.winding<=0))do n+=(o.Org.s-o.Dst.s)*(o.Org.t+o.Dst.t),o=o.Lnext;while(o!==s.anEdge);if(n<0){for(t=r.next;t!==r;t=t.next)t.t=-t.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},i.prototype.projectPolygon_=function(){var e=this.mesh.vHead,t=[0,0,0],r,o,n=!1;t[0]=this.normal[0],t[1]=this.normal[1],t[2]=this.normal[2],!t[0]&&!t[1]&&!t[2]&&(this.computeNormal_(t),n=!0),r=this.sUnit,o=this.tUnit;var s=this.longAxis_(t);r[s]=0,r[(s+1)%3]=1,r[(s+2)%3]=0,o[s]=0,o[(s+1)%3]=0,o[(s+2)%3]=t[s]>0?1:-1;for(var a=e.next;a!==e;a=a.next)a.s=this.dot_(a.coords,r),a.t=this.dot_(a.coords,o);n&&this.checkOrientation_();for(var l=!0,c=e.next;c!==e;c=c.next)l?(this.bmin[0]=this.bmax[0]=c.s,this.bmin[1]=this.bmax[1]=c.t,l=!1):(c.s<this.bmin[0]&&(this.bmin[0]=c.s),c.s>this.bmax[0]&&(this.bmax[0]=c.s),c.t<this.bmin[1]&&(this.bmin[1]=c.t),c.t>this.bmax[1]&&(this.bmax[1]=c.t))},i.prototype.addWinding_=function(e,t){e.winding+=t.winding,e.Sym.winding+=t.Sym.winding},i.prototype.tessellateMonoRegion_=function(e,t){var r,o;if(r=t.anEdge,!(r.Lnext!==r&&r.Lnext.Lnext!==r))throw"Mono region invalid";for(;ae.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;ae.vertLeq(r.Org,r.Dst);r=r.Lnext);o=r.Lprev;for(var n=void 0;r.Lnext!==o;)if(ae.vertLeq(r.Dst,o.Org)){for(;o.Lnext!==r&&(ae.edgeGoesLeft(o.Lnext)||ae.edgeSign(o.Org,o.Dst,o.Lnext.Dst)<=0);)n=e.connect(o.Lnext,o),o=n.Sym;o=o.Lprev}else{for(;o.Lnext!==r&&(ae.edgeGoesRight(r.Lprev)||ae.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)n=e.connect(r,r.Lprev),r=n.Sym;r=r.Lnext}if(o.Lnext===r)throw"Mono region invalid";for(;o.Lnext.Lnext!==r;)n=e.connect(o.Lnext,o),o=n.Sym;return!0},i.prototype.tessellateInterior_=function(e){for(var t,r=e.fHead.next;r!==e.fHead;r=t)if(t=r.next,r.inside&&!this.tessellateMonoRegion_(e,r))return!1;return!0},i.prototype.discardExterior_=function(e){for(var t,r=e.fHead.next;r!==e.fHead;r=t)t=r.next,r.inside||e.zapFace(r)},i.prototype.setWindingNumber_=function(e,t,r){for(var o,n=e.eHead.next;n!==e.eHead;n=o)o=n.next,n.Rface.inside!==n.Lface.inside?n.winding=n.Lface.inside?t:-t:r?e.delete(n):n.winding=0},i.prototype.getNeighbourFace_=function(e){return!e.Rface||!e.Rface.inside?-1:e.Rface.n},i.prototype.outputPolymesh_=function(e,t,r,o){var n,s=0,a=0,l;r>3&&e.mergeConvexFaces(r);for(var c=e.vHead.next;c!==e.vHead;c=c.next)c.n=-1;for(var d=e.fHead.next;d!==e.fHead;d=d.next)if(d.n=-1,!!d.inside){n=d.anEdge,l=0;do{var c=n.Org;c.n===-1&&(c.n=a,a++),l++,n=n.Lnext}while(n!==d.anEdge);if(l>r)throw"Face vertex greater that support polygon";d.n=s,++s}this.elementCount=s,t===st.CONNECTED_POLYGONS&&(s*=2),this.elements=[],this.elements.length=s*r,this.vertexCount=a,this.vertices=[],this.vertices.length=a*o,this.vertexIndices=[],this.vertexIndices.length=a;for(var c=e.vHead.next;c!==e.vHead;c=c.next)if(c.n!==-1){var p=c.n*o;this.vertices[p+0]=c.coords[0],this.vertices[p+1]=c.coords[1],o>2&&(this.vertices[p+2]=c.coords[2]),this.vertexIndices[c.n]=c.idx}for(var u=0,d=e.fHead.next;d!==e.fHead;d=d.next)if(!!d.inside){n=d.anEdge,l=0;do{var c=n.Org;this.elements[u++]=c.n,l++,n=n.Lnext}while(n!==d.anEdge);for(var f=l;f<r;++f)this.elements[u++]=-1;if(t===st.CONNECTED_POLYGONS){n=d.anEdge;do this.elements[u++]=this.getNeighbourFace_(n),n=n.Lnext;while(n!==d.anEdge);for(var m=l;m<r;++m)this.elements[u++]=-1}}},i.prototype.outputContours_=function(e,t){var r,o,n=0,s=0;this.vertexCount=0,this.elementCount=0;for(var a=e.fHead.next;a!==e.fHead;a=a.next)if(!!a.inside){o=r=a.anEdge;do this.vertexCount++,r=r.Lnext;while(r!==o);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*t,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var l=0,c=0,d=0;n=0;for(var a=e.fHead.next;a!==e.fHead;a=a.next)if(!!a.inside){s=0,o=r=a.anEdge;do this.vertices[l++]=r.Org.coords[0],this.vertices[l++]=r.Org.coords[1],t>2&&(this.vertices[l++]=r.Org.coords[2]),this.vertexIndices[c++]=this.vertexIdCallback?this.vertexIdCallback(r):r.Org.idx,s++,r=r.Lnext;while(r!==o);this.elements[d++]=n,this.elements[d++]=s,n+=s}},i.prototype.addContour=function(e,t){this.mesh===null&&(this.mesh=new Vu),e<2&&(e=2),e>3&&(e=3);for(var r=null,o=0;o<t.length;o+=e)r===null?(r=this.mesh.makeEdge(),this.mesh.splice(r,r.Sym)):(this.mesh.splitEdge(r),r=r.Lnext),r.Org.coords[0]=t[o+0],r.Org.coords[1]=t[o+1],e>2?r.Org.coords[2]=t[o+2]:r.Org.coords[2]=0,r.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(r),r.winding=1,r.Sym.winding=-1},i.prototype.tesselate=function(e,t,r,o,n,s){if(e===void 0&&(e=$e.ODD),t===void 0&&(t=st.POLYGONS),s===void 0&&(s=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,n&&(this.normal[0]=n[0],this.normal[1]=n[1],this.normal[2]=n[2]),this.windingRule=e,o<2&&(o=2),o>3&&(o=3),!this.mesh)return!1;this.projectPolygon_(),gv.computeInterior(this,s);var a=this.mesh;return t===st.BOUNDARY_CONTOURS?this.setWindingNumber_(a,1,!0):this.tessellateInterior_(a),s&&a.check(),t===st.BOUNDARY_CONTOURS?this.outputContours_(a,o):this.outputPolymesh_(a,t,r,o),!0},i}();function wo(i){var e=i.windingRule,t=e===void 0?$e.ODD:e,r=i.elementType,o=r===void 0?st.POLYGONS:r,n=i.polySize,s=n===void 0?3:n,a=i.vertexSize,l=a===void 0?2:a,c=i.normal,d=c===void 0?[0,0,1]:c,p=i.contours,u=p===void 0?[]:p,f=i.strict,m=f===void 0?!0:f,x=i.debug,y=x===void 0?!1:x;if(!u&&m)throw new Error("Contours can't be empty");if(!!u){var N=new xv;i.edgeCreateCallback&&(N.edgeCreateCallback=i.edgeCreateCallback),i.vertexIdCallback&&(N.vertexIdCallback=i.vertexIdCallback);for(var L=0;L<u.length;L++)N.addContour(l||2,u[L]);return N.tesselate(t,o,s,l,d,m),{vertices:N.vertices,vertexIndices:N.vertexIndices,vertexCount:N.vertexCount,elements:N.elements,elementCount:N.elementCount,mesh:y?N.mesh:void 0}}}var Uj=$e.ODD,kj=$e.NONZERO,Hj=$e.POSITIVE,qj=$e.NEGATIVE,Wj=$e.ABS_GEQ_TWO,$j=st.POLYGONS,Jj=st.CONNECTED_POLYGONS,Kj=st.BOUNDARY_CONTOURS;var No=class extends bv{constructor(e,t=12,r=100,o={}){super();this.type="ShapeGeometry";this.windingRule=$e.ODD;this.elementType=st.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._drawCount=0,this._shape=e,this._curveSegments=t,this._maxCount=r,this._maxDrawCount=r*3,this._triangulationOptions=Object.assign({windingRule:$e.ODD,elementType:st.POLYGONS,polySize:3,vertexSize:2,strict:!0},o),this._positionAttribute=new Gs(new Float32Array(r*3),3),this._normalAttribute=new Gs(new Float32Array(r*3),3),this._uvAttribute=new Gs(new Float32Array(r*2),2),this._indexAttribute=new Gs(new Uint32Array(r*3),1),this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.updateFromShape()}copy(e){return this._drawCount=e.drawCount,this._maxDrawCount=e._maxDrawCount,this._maxCount=e.maxCount,super.copy(e)}get curveSegments(){return this._curveSegments}set curveSegments(e){this._curveSegments=e,this.updateFromShape()}get drawCount(){return this._drawCount}get maxDrawCount(){return this._maxDrawCount}get maxCount(){return this._maxCount}updateFromShape(){let e=this._shape.extractShapePointsToFlatArray([],this._curveSegments),t=this._shape.shapeHoles.map(l=>l.extractShapePointsToFlatArray([],this._curveSegments)),r,o=!0,n=!0,s,a;for(let l=0,c=e.length/2;l<c;l++){let d=l*2,p=e[d+0],u=e[d+1];if(s!==void 0&&p!==s&&(o=!1),a!==void 0&&u!==a&&(n=!1),s=p,a=u,!o&&!n)break}if(!o&&!n&&(r=wo({contours:[e,...t],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})),this._positionAttribute.array.fill(0),this._normalAttribute.array.fill(0),this._uvAttribute.array.fill(0),this._indexAttribute.array.fill(0),this._drawCount=0,r){let l=1/0,c=-1/0,d=1/0,p=-1/0;for(let m=0,x=r.vertexCount;m<x;m++){let y=m*2,N=r.vertices[y+0],L=r.vertices[y+1];N<l&&(l=N),N>c&&(c=N),L<d&&(d=L),L>p&&(p=L)}let u=c-l,f=p-d;for(let m=0,x=r.vertexCount;m<x;m++){let y=m*2,N=r.vertices[y+0],L=r.vertices[y+1],w=(N-l)/u,B=(L-d)/f;this._positionAttribute.setXYZ(m,N,L,0),this._normalAttribute.setXYZ(m,0,0,1),this._uvAttribute.setXY(m,w,B)}for(let m=0,x=r.elementCount;m<x;m++){let y=m*3,N=r.elements[y+0],L=r.elements[y+1],w=r.elements[y+2];this._indexAttribute.setX(y+0,N),this._indexAttribute.setX(y+1,L),this._indexAttribute.setX(y+2,w),this._drawCount+=3}}return this._positionAttribute.needsUpdate=!0,this._normalAttribute.needsUpdate=!0,this._uvAttribute.needsUpdate=!0,this._indexAttribute.needsUpdate=!0,this.setDrawRange(0,this._drawCount),this._drawCount>this._maxDrawCount}clone(){let e=new No(this._shape,this._curveSegments,this._maxCount);return e.userData=yo(this.userData),e}};import{BufferAttribute as Fs,BufferGeometry as vv}from"three";var Es=class{constructor(e=256,t=!1){this.capacity=e,this.size=0,this.debug=t,this.debug&&console.log(`allocating with cap ${e}`);let r=e*Es.eSize;this.buffer=new ArrayBuffer(r);let o=Float32Array.BYTES_PER_ELEMENT,n=0;this.positions=new Float32Array(this.buffer,n*o,3*e),n+=3*e,this.normals=new Float32Array(this.buffer,n*o,3*e),n+=3*e,this.uvs=new Float32Array(this.buffer,n*o,2*e)}realloc(e,t=!1){if(e<this.size)throw Error("cannot shrink buffer");if(e<=this.capacity&&!t)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${e}`);let r=e*Es.eSize,o=new ArrayBuffer(r),n=Float32Array.BYTES_PER_ELEMENT,s=0,a=new Float32Array(o,s*n,3*e);s+=3*e;let l=new Float32Array(o,s*n,3*e);s+=3*e;let c=new Float32Array(o,s*n,2*e);a.set(this.positions.slice(0,this.size*3)),l.set(this.normals.slice(0,this.size*3)),c.set(this.uvs.slice(0,this.size*2)),this.buffer=o,this.positions=a,this.normals=l,this.uvs=c,this.capacity=e}get(e=1){let t=this.size+e;if(t>this.capacity){let o=this.capacity;for(;t>o;)o*=2;this.realloc(o)}let r=this.size;return this.size=t,r}reserve(e){let t=this.size+e;t>this.capacity&&this.realloc(t)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},zs=Es;zs.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var gl=(i,e)=>([t,r])=>(r<t&&(r+=e),(i>=t?i:i+e)<=r),qi=class extends vv{constructor(e,t,r=0,o=12,n=3){super();this.type="ShapeGeometry";this.vertexCache={};this._shape=e,this._depth=t,this._bevel=r,this._curveSegments=o,this._bevelSegmentsInput=n,r<=0?(this._bevelSize=0,this._bevelSegments=0):(this._bevelSize=Math.min(r,t/2-1e-12),this._bevelSegments=Math.floor(n));let s=this._shape.extractShapePointsToFlatArray([],o),a=this._shape.shapeHoles.map(_=>{let T=_.extractShapePointsToFlatArray([],o),h=[];for(let I=T.length-1;I>=1;I-=2){let b=T[I-1],P=T[I-0];h.push(b,P)}return h}),l=wo({windingRule:$e.ODD,elementType:st.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[s]}),c=wo({windingRule:$e.ODD,elementType:st.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...a]});if(!l)throw new Error("error generating geometry");let d=l.elementCount;if(c){l.elementCount+=c.elementCount;for(let _=0;_<c.elements.length;_++){let T=c.elements[_],h=_%2==0?l.vertexCount:0;l.elements.push(T+h)}for(let _=0;_<c.vertexIndices.length;_++){let T=c.vertexIndices[_],h=l.vertexCount;l.vertexIndices.push(T+h)}for(let _=0;_<c.vertices.length;_++){let T=c.vertices[_];l.vertices.push(T)}}let p=1/0,u=-1/0,f=1/0,m=-1/0;for(let _=0,T=l.vertexCount;_<T;_++){let h=_*2,I=l.vertices[h+0],b=l.vertices[h+1];I<p&&(p=I),I>u&&(u=I),b<f&&(f=b),b>m&&(m=b)}this._minX=p,this._minY=f,this._width=u-p,this._height=m-f;let x=l.vertexCount*2*(2+this._bevelSegments);this._buffer=new zs(x);let y=[],N=[];for(let _=l.elementCount-1;_>=0;_--){let T=_>=d,h=_*2,I=l.elements[h+0],b=l.elements[h+1],P=I+b,v={start:I,count:b,normals:[],continuous:[],concave:[]},D=I,Z=P-1,V=I+1,ie=this._shape.roundedCurves.length;do{let A=D-I,j=l.vertices[Z*2+0],g=l.vertices[Z*2+1],z=l.vertices[D*2+0],R=l.vertices[D*2+1],U=l.vertices[V*2+0],q=l.vertices[V*2+1],W=z-j,J=R-g,E=Math.sqrt(W*W+J*J);W/=E,J/=E;let H=z-U,k=R-q,se=Math.sqrt(H*H+k*k);H/=se,k/=se,v.normals[A*2+0]=-k,v.normals[A*2+1]=H,v.concave[A]=W*k-J*H>0;let F=l.vertexIndices[D];if(Array.isArray(F))v.continuous[A]=!1;else{let[K,X]=this._shape.getCurveIndexFromVertexId(F-1,!0);if(X>0&&X<1)v.continuous[A]=!0;else{let te=X===1?K+1:K-1;te=(te+ie)%ie;let he=X===1?0:1,Y=this._shape.roundedCurves[K].getTangent(X),ne=this._shape.roundedCurves[te].getTangent(he);v.continuous[A]=Y.dot(ne)>.95}}T&&(v.normals[A*2+0]*=-1,v.normals[A*2+1]*=-1),[Z,D,V]=[D,V,V+1],V>=P&&(V-=b)}while(V!==I+1);let oe=[];oe.push({bevelI:0,angle:0,size:0,boundary:{vertices:l.vertices.slice(I*2,P*2),vertexCount:b,vertexIndices:new Array(b).fill(!0).map((A,j)=>[j,j]),elements:[0,b],elementCount:1,mesh:null},reverseMap:[],insetPoints:l.vertices.slice(I*2,P*2)});for(let A=1;A<=this._bevelSegments;A++){let j=A/this._bevelSegments*Math.PI/2,g=(1-Math.cos(j))*this._bevelSize,z=[],R=[],U=[],q=[],W=0;for(let E=0;E<b;E++){let H=E*2,k=(E-1+b)%b*2,se=l.vertices[v.start*2+H+0],F=l.vertices[v.start*2+H+1],K=-v.normals[k+0]*g,X=-v.normals[k+1]*g,te=-v.normals[H+0]*g,he=-v.normals[H+1]*g;if(v.concave[E]||!v.concave[E]&&T){let Y=Math.atan2(X,K),ne=Math.atan2(he,te);ne>Y&&(ne-=Math.PI*2);let Se=ne-Y;if(v.continuous[E]||T){let me=Y+Se/2,Oe=Math.cos(me)*g,He=Math.sin(me)*g;z[2*W+0]=se+Oe*(T?-1:1),z[2*W+1]=F+He*(T?-1:1),q[W]=E,W++}else{let me=Math.max(1,Math.floor(o/4*Math.abs(Se)/Math.PI));for(let Oe=0;Oe<=me;Oe++){let He=Y+Se*(Oe/me),rt=Math.cos(He)*g,pt=Math.sin(He)*g;z[2*W+0]=se+rt,z[2*W+1]=F+pt,q[W]=E,W++}}}else z[2*W+0]=se+K,z[2*W+1]=F+X,q[W]=E,R[E]=W,W++,z[2*W+0]=se,z[2*W+1]=F,q[W]=E,W++,z[2*W+0]=se+te,z[2*W+1]=F+he,q[W]=E,U[E]=W,W++}let J=wo({windingRule:$e.POSITIVE,elementType:st.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[z],edgeCreateCallback:E=>{let k=E.Org.idx,se=q[k],F=q[(k+1)%q.length];E.idx=[se,F],E.Sym.idx=[F,se]},vertexIdCallback:E=>{let H=E.Lprev.idx;return[H?H[1]:0,E.idx[0]]}});if(!J)throw console.log("Error"),new Error(`error generating bevel geometry for ${A}'th loop`);if(!J.vertexCount)break;for(let E=0;E<J.vertexIndices.length;E++){let[H,k]=J.vertexIndices[E];if(H===k)continue;let se=k;k<H&&(se+=b);for(let F=H;F<se;F++){let K=F%b,X=(F+1)%b;if(!v.continuous[K]||!v.continuous[X]){J.vertexIndices[E]=[H,K],J.vertexIndices.splice(E+1,0,[X,k]),J.vertices.splice((E+1)*2,0,J.vertices[E*2],J.vertices[E*2+1]);break}}}oe.push({bevelI:A,angle:j,size:g,boundary:J,reverseMap:q,insetPoints:z})}let ge=(A,j,g)=>{let z=0,R=A.boundary.vertexIndices.length;for(;z<R&&g(A.boundary.vertexIndices[j]);)j=(j+1)%R,z++;return z},xe=y.length;for(let A=1;A<oe.length;A++){let j=oe[A-1],g=oe[A],z=j.boundary.vertexIndices.length,R=g.boundary.vertexIndices.length;if(!z||!R)break;let U=v.concave.length,q=0,W=gl(q,b);for(;!j.boundary.vertexIndices.filter(W).length||!g.boundary.vertexIndices.filter(W).length;)q++,W=gl(q,b);let J=j.boundary.vertexIndices.findIndex(W),E=g.boundary.vertexIndices.findIndex(W);do J=(J+1)%z;while(W(j.boundary.vertexIndices[J]));do E=(E+1)%R;while(W(g.boundary.vertexIndices[E]));q=(q+1)%b;let H=q,k=this.buildBevelVert(v,j,(J-1+z)%z),se=this.buildBevelVert(v,g,(E-1+R)%R),F=k,K=se,X,te,he=!1;do{W=gl(q,b);let Y=ge(j,J,W),ne=ge(g,E,W),Se=he;if(he=!1,Y&&!ne){for(let me=0;me<Y;me++)X=this.buildBevelVert(v,j,(J+me)%z,me/(Y-1)),y.push(F.topN,X.topP,K.topN),y.push(X.bottomP,F.bottomN,K.bottomN),F=X;he=!0}else if(!Y&&ne)for(let me=0;me<ne;me++)te=this.buildBevelVert(v,g,(E+me)%R,me/(ne-1)),y.push(K.topN,F.topP,te.topP),y.push(F.bottomP,K.bottomN,te.bottomP),K=te;else if(Y&&ne)if(X=this.buildBevelVert(v,j,J,0),te=this.buildBevelVert(v,g,E,0),Se?(y.push(F.topN,te.topP,K.topN),y.push(F.topN,X.topP,te.topP),y.push(te.bottomP,F.bottomN,K.bottomN),y.push(X.bottomP,F.bottomN,te.bottomP)):(y.push(F.topN,X.topP,K.topN),y.push(K.topN,X.topP,te.topP),y.push(X.bottomP,F.bottomN,K.bottomN),y.push(X.bottomP,K.bottomN,te.bottomP)),F=X,K=te,Y===ne)for(let me=1;me<Y;me++)X=this.buildBevelVert(v,j,(J+me)%z,me/(Y-1)),te=this.buildBevelVert(v,g,(E+me)%R,me/(ne-1)),y.push(F.topN,X.topP,K.topN),y.push(K.topN,X.topP,te.topP),y.push(X.bottomP,F.bottomN,K.bottomN),y.push(X.bottomP,K.bottomN,te.bottomP),F=X,K=te;else if(Y>ne){let me=Y/ne,Oe=0;for(let He=1;He<Y;He++)X=this.buildBevelVert(v,j,(J+He)%z,He/(Y-1)),y.push(F.topN,X.topP,K.topN),y.push(X.bottomP,F.bottomN,K.bottomN),F=X,He>(Oe+1)*me&&(Oe++,te=this.buildBevelVert(v,g,(E+Oe)%R,Oe/(ne-1)),y.push(K.topN,X.topP,te.topP),y.push(X.bottomP,K.bottomN,te.bottomP),K=te)}else{let me=ne/Y,Oe=0;for(let He=1;He<ne;He++)te=this.buildBevelVert(v,g,(E+He)%R,He/(ne-1)),y.push(K.topN,X.topP,te.topP),y.push(X.bottomP,K.bottomN,te.bottomP),K=te,He>(Oe+1)*me&&(Oe++,X=this.buildBevelVert(v,j,(J+Oe)%z,Oe/(Y-1)),y.push(F.topN,X.topP,K.topN),y.push(X.bottomP,F.bottomN,K.bottomN),F=X)}J=(J+Y)%z,E=(E+ne)%R,q=(q+1)%U}while(q!==H)}{let A=oe[0];for(let j=0,g=A.boundary.vertexCount;j<g;j++){let z=this.buildBevelVert(v,A,j),R=this.buildBevelVert(v,A,(j+1)%g);y.push(R.topP,z.topN,z.bottomN),y.push(R.topP,z.bottomN,R.bottomP)}}if(T){let A=[];for(let j=y.length-1;j>=xe+2;j-=3){let g=y[j-2],z=y[j-1],R=y[j-0];A.push(R,z,g)}y.splice(xe,y.length-xe,...A)}if(T){let A=[];for(let j=oe[oe.length-1].boundary.vertices.length-1;j>=1;j-=2){let g=oe[oe.length-1].boundary.vertices[j-1],z=oe[oe.length-1].boundary.vertices[j-0];A.push(g,z)}N.push(A)}if(!T){let A=oe[oe.length-1],j=wo({windingRule:oe.length>1?$e.POSITIVE:$e.ODD,elementType:st.POLYGONS,vertexSize:2,strict:!0,contours:[A.insetPoints,...N]});if(!j)throw new Error("Error generating geometry for surface");for(let g=0;g<j.elementCount*3;g+=3){let z=this.buildSurfaceVert(j,j.elements[g+0]),R=this.buildSurfaceVert(j,j.elements[g+1]),U=this.buildSurfaceVert(j,j.elements[g+2]);y.push(z.top,R.top,U.top),y.push(U.bottom,R.bottom,z.bottom)}}this.vertexCache={}}this._buffer.shrink();let L=new Fs(Uint32Array.from(y),1),w=new Fs(this._buffer.positions,3),B=new Fs(this._buffer.normals,3),S=new Fs(this._buffer.uvs,2);w.needsUpdate=!0,B.needsUpdate=!0,S.needsUpdate=!0,L.needsUpdate=!0,this.setAttribute("position",w),this.setAttribute("normal",B),this.setAttribute("uv",S),this.setIndex(L)}buildSurfaceVert(e,t){let r=t.toString();if(r in this.vertexCache)return this.vertexCache[r];let o=e.vertices[t*2+0],n=e.vertices[t*2+1],s=(o-this._minX)/this._width,a=(n-this._minY)/this._height,l=this._buffer.get(2),c=l*3,d=l*2,p={top:l+0,bottom:l+1};return this._buffer.positions[c+0]=o,this._buffer.positions[c+1]=n,this._buffer.positions[c+2]=this._depth,this._buffer.normals[c+0]=0,this._buffer.normals[c+1]=0,this._buffer.normals[c+2]=1,this._buffer.uvs[d+0]=s,this._buffer.uvs[d+1]=a,this._buffer.positions[c+3]=o,this._buffer.positions[c+4]=n,this._buffer.positions[c+5]=0,this._buffer.normals[c+3]=0,this._buffer.normals[c+4]=0,this._buffer.normals[c+5]=-1,this._buffer.uvs[d+2]=s,this._buffer.uvs[d+3]=a,this.vertexCache[r]=p,p}buildBevelVert(e,t,r,o=1){let n=`${t.bevelI}:${r}`;if(n in this.vertexCache)return this.vertexCache[n];let[s,a]=t.boundary.vertexIndices[r],l,c,d,p;s!==a?(c=s,l=a,p=!1,d=e.continuous[c]&&e.continuous[l]):(l=s,c=(l-1+e.count)%e.count,p=e.concave[l]&&t.bevelI>0,d=e.continuous[l]||p);let u=Math.cos(t.angle),f=Math.sin(t.angle),m=r*2,x=l*2,y=c*2,N=t.boundary.vertices[m+0],L=t.boundary.vertices[m+1],w=(1-f)*this._bevelSize,B=(N-this._minX)/this._width,S=(L-this._minY)/this._height,_=e.normals[x+0],T=e.normals[x+1],h=e.normals[y+0],I=e.normals[y+1];if(p){let Z=h-_,V=I-T;_=_+Z*(1-o),T=T+V*(1-o);let ie=Math.sqrt(_*_+T*T);_/=ie,T/=ie}let b=this._buffer.get(d?2:4),P=b*3,v=b*2,D={i:r,fi:l,topP:b+0,topN:b+0,bottomP:b+1,bottomN:b+1};return this._buffer.positions[P+0]=N,this._buffer.positions[P+1]=L,this._buffer.positions[P+2]=this._depth-w,this._buffer.normals[P+0]=_*u,this._buffer.normals[P+1]=T*u,this._buffer.normals[P+2]=f,this._buffer.uvs[v+0]=B,this._buffer.uvs[v+1]=S,this._buffer.positions[P+3]=N,this._buffer.positions[P+4]=L,this._buffer.positions[P+5]=w,this._buffer.normals[P+3]=_*u,this._buffer.normals[P+4]=T*u,this._buffer.normals[P+5]=-f,this._buffer.uvs[v+2]=S,this._buffer.uvs[v+3]=B,d||(b+=2,P+=6,v+=4,D.topP=b+0,D.bottomP=b+1,this._buffer.positions[P+0]=N,this._buffer.positions[P+1]=L,this._buffer.positions[P+2]=this._depth-w,this._buffer.normals[P+0]=h*u,this._buffer.normals[P+1]=I*u,this._buffer.normals[P+2]=f,this._buffer.uvs[v+0]=B,this._buffer.uvs[v+1]=S,this._buffer.positions[P+3]=N,this._buffer.positions[P+4]=L,this._buffer.positions[P+5]=w,this._buffer.normals[P+3]=h*u,this._buffer.normals[P+4]=I*u,this._buffer.normals[P+5]=-f,this._buffer.uvs[v+2]=S,this._buffer.uvs[v+3]=B),this.vertexCache[n]=D,D}clone(){let e=new qi(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=yo(this.userData),e}};var mt=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var c,d,p,u,f,m,x;let t=Object.assign({},(c=e==null?void 0:e.parameters)!=null?c:{width:100,subdivisions:40,roundness:0,extrudeDepth:0,surfaceMaxCount:100,extrudeBevelSize:0,extrudeBevelSegments:3},i.parameters),r=Math.abs(t.width),o=Math.abs((d=t.height)!=null?d:t.width),n=Math.abs(t.depth!==void 0&&t.depth===0&&t.extrudeDepth>0?t.extrudeDepth:(p=t.depth)!=null?p:0),s=(u=i.shape)!=null?u:e==null?void 0:e.shape,a=(f=s==null?void 0:s.roundness)!=null?f:t.roundness;s!==void 0&&(s instanceof Pe?(s.width!==r||s.height!==o)&&s.applySize(r,o):s=new Pe(r,o).fromJSON(s),((m=i.parameters)==null?void 0:m.roundness)!==void 0&&((x=i.parameters)==null?void 0:x.roundness)>0&&s.update(!1));let l=s!=null?s:new Pe(r,o);return{parameters:Object.assign(t,{width:r,height:o,depth:n,extrudeDepth:n,roundness:a}),shape:l}}static build(i){let{extrudeDepth:e,extrudeBevelSize:t,extrudeBevelSegments:r,subdivisions:o,roundness:n,surfaceMaxCount:s}=i.parameters;i.shape.roundness=n;let a;return e<=0?a=new No(i.shape,o,s):a=new qi(i.shape,e,t,o,r),Object.assign(a,{userData:$(O({},i),{type:"VectorGeometry"})})}};import{MathUtils as qu,Vector2 as Wu}from"three";var $u=Math.PI*2,Ju=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var o,n,s;let t=Object.assign({},(o=e==null?void 0:e.parameters)!=null?o:{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:1,surfaceMaxCount:1e3},i.parameters);return{shape:i.shape&&i.shape instanceof Pe?i.shape:new Pe,parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((n=t.height)!=null?n:t.width),depth:Math.abs(t.depth!==void 0&&t.depth===0&&t.extrudeDepth>0?t.extrudeDepth:(s=t.depth)!=null?s:0)})}}static build(i){let{width:e,height:t,spikes:r,angle:o,innerRadius:n,depth:s,extrudeBevelSize:a,extrudeBevelSegments:l,surfaceMaxCount:c}=i.parameters,d=i.shape,p=e*.5,u=t*.5,f=Sv(d,p,u,o*Math.PI/180,r,n);d.isClosed=!0,d.update();let m=mt.create({shape:d,parameters:{subdivisions:f,surfaceMaxCount:c,depth:s,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(m,{userData:$(O({},i),{type:"EllipseGeometry"})})}};function Sv(i,e,t,r,o,n){if(r>=$u)return o>30||o%4==0?(Nv(i,e,t,n),Math.round(o/4)):Ku(i,r,o,e,t,n);let s={x:0,y:t},a=r+Math.PI*.5,l={x:Math.cos(a)*e,y:Math.sin(a)*t},c=Ru({px:s.x,py:s.y,cx:l.x,cy:l.y,rx:e,ry:t,largeArcFlag:r>Math.PI,sweepFlag:!0});return o>30||o%c.length==0?wv(i,s.x,s.y,c,o,e,t,n):Ku(i,r,o,e,t,n)}function wv(i,e,t,r,o,n,s,a){let l=Math.round(o/r.length);i.addPoint(ci(e,t));for(let c=0,d=r.length;c<d;c++){let p=r[c],u=i.points[c],f=ci(p.x,p.y);u.controls[1].position.set(p.x1,p.y1),f.controls[0].position.set(p.x2,p.y2),i.addPoint(f)}return a>0?Xu(i,n,s,a):i.addPoint(ci(0,0)),l}function Ku(i,e,t,r,o,n){let s=-e/t;for(let a=0;a<=t;a++){let l=s*a,c=Math.sin(l)*r,d=Math.cos(l)*o;i.addPoint(ci(c,d))}return e<$u?n>0?Xu(i,r,o,n):i.addPoint(ci(0,0)):(i.removePoint(i.points[i.points.length-1]),n>0&&Zu(i,r,o,n)),1}function Nv(i,e,t,r=0,o=0,n=0){let s=.5522847498,a=e*s,l=t*s;i.addPoint(Rs(o-e,n,o-e,n-l,o-e,n+l)),i.addPoint(Rs(o,n+t,o-a,n+t,o+a,n+t)),i.addPoint(Rs(o+e,n,o+e,n+l,o+e,n-l)),i.addPoint(Rs(o,n-t,o+a,n-t,o-a,n-t)),r>0&&Zu(i,e,t,r)}function ci(i,e){return new br(qu.generateUUID(),new Wu(i,e))}function Rs(i,e,t,r,o,n){let s=ci(i,e);return s.controls[0].position.set(t,r),s.controls[1].position.set(o,n),s}function Xu(i,e,t,r){Qu(i,e,t,r).forEach(n=>i.addPoint(n))}function Zu(i,e,t,r){let o=Qu(i,e,t,r),n=new Pe;o.forEach(s=>n.addPoint(s)),n.isClosed=!0,i.shapeHoles.push(n)}function Qu(i,e,t,r){let o=r*e/100,n=o*(Math.abs(t)/Math.abs(e)),s=new Wu(o/e,n/t),a=i.points.map(l=>{let c=l.clone();return c.uuid=qu.generateUUID(),c}).reverse();return a.forEach(l=>{l.position.multiply(s);let c=l.controls[0].position.clone().multiply(s),d=l.controls[1].position.clone().multiply(s);l.controls[0].position.copy(d),l.controls[1].position.copy(c)}),a}import{BufferGeometry as Cv,Float32BufferAttribute as xl,Vector3 as Yu}from"three";var eh=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var a,l,c;let t=Object.assign({},(a=e==null?void 0:e.parameters)!=null?a:{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},i.parameters),r=Math.abs(t.width),o=Math.abs((l=t.height)!=null?l:r),n=Math.abs((c=t.depth)!=null?c:r),s=Math.abs(Math.min(r,n))/2;return{parameters:Object.assign(t,{width:r,height:o,depth:n,radius:s,segments:Math.round(t.segments),pathSegments:Math.round(t.pathSegments),cornerSegments:Math.round(t.cornerSegments)})}}static build(i){let{width:e,height:t,depth:r,radius:o,revolutions:n,segments:s,pathRadius:a,pathType:l,pathSegments:c,cornerRadius:d,cornerSegments:p}=i.parameters,u=new Vs(!1,e,t,r,o,n,s,a,l,c,d,p);return Object.assign(u,{userData:$(O({},i),{type:"HelixGeometry"})})}},Vs=class extends Cv{constructor(e=!0,t=1,r=1,o=1,n=1,s=1,a=1,l=1,c=1,d=1,p=1,u=1){super();let f=e&&s===1;f&&(u=0),p>100&&(p=100);let m=()=>new Yu,x=new Yu,y=m(),N=m(),L=m(),w,B,S,_,T,h,I,b,P=m(),v=m(),D=m(),Z=m(),V=m(),ie=m(),oe=m(),ge=m(),xe=r-2*l+.001,A=xe/s,j=Math.ceil(a*s),g=j+1,z=xe/j,R=-xe/2,U=d+1,q=2*Math.PI/d,W=Math.PI/2/u,J=.01,E=Math.min((1-p/100)*l,l-J),H=l-E,k=0,se=2,F=u*se+se,K=U*F/se,X=K+U*g,te=U*(g+F),[he,Y,ne]=[3,3,2].map(qe=>Array(te*qe).fill(0)),Se=[],me=n-l;function Oe(qe,bt){let Et=Math.PI/2;h=bt*z,b=2*Math.PI*(h%A)/A+Et,h+=R,I=Math.sin(b)*me,T=Math.cos(b)*me,e?qe.set(T,I,h):qe.set(T,h,I)}Oe(x,-1e-10),Oe(y,0),P.copy(x),Oe(x,1);let He=x.distanceTo(y),rt=H+E,pt=He*j+2*rt,zt=E,Tr=pt-rt;for(let qe=0;qe<=j;qe++){Oe(N,qe),ge.subVectors(N,P).normalize(),P.copy(N),ie.copy(N).setComponent(+e+1,0).normalize(),oe.crossVectors(ge,ie).normalize();let bt=qe===0,Et=qe===j,bn=bt?3*Math.PI/2:W,vn=bt?zt:Tr,Sn=bt?U:X,wn=bt?0:te-U,Nn=ge.clone().multiplyScalar(bt?-H:H).add(N),Cn=ge.clone().multiplyScalar(bt?-1:1).normalize();for(let $t=0;$t<U;$t++){let Li=$t*q;if(v.addVectors(x.copy(ie).multiplyScalar(l*Math.cos(Li)),y.copy(oe).multiplyScalar(l*Math.sin(Li))),D.copy(v).normalize(),bt||Et){f||(k=wn+$t,[0,1,2].forEach(ut=>{he[k*3+ut]=Nn.getComponent(ut),Y[k*3+ut]=Cn.getComponent(ut)}),ne[k*2]=+Et,ne[k*2+1]=$t/d),y.copy(D).multiplyScalar(E),L.addVectors(N,y);for(let ut=0;ut<u;ut++){let jo=ut*W+bn;Z.addVectors(x.copy(ge).multiplyScalar(H*Math.sin(jo)),y.copy(D).multiplyScalar(H*Math.cos(jo))),V.copy(Z).normalize(),y.addVectors(L,Z),Z.normalize(),k=Sn+ut*U+$t,[0,1,2].forEach(ye=>{he[k*3+ye]=y.getComponent(ye),Y[k*3+ye]=V.getComponent(ye)});let Ln=+bt+Math.sin(jo);ne[k*2]=(vn+H*Ln)/pt,ne[k*2+1]=$t/d}}y.addVectors(N,v),k=K+qe*U+$t,[0,1,2].forEach(ut=>{he[k*3+ut]=y.getComponent(ut),Y[k*3+ut]=D.getComponent(ut)}),ne[k*2]=(rt+qe*He)/pt,ne[k*2+1]=$t/d}}let xt=g+2*u+se,Ir=1,[uo,ho]=f?[Ir,Ir+g-1]:[0,xt-1];for(let qe=uo;qe<=ho-1;qe++){let bt=f&&qe===ho-1;for(let Et=0;Et<U-1;Et++)w=qe*U+Et,B=w+1,S=(bt?Et:w)+U,_=(bt?Et+1:B)+U,qe===0?Se.push(B,_,S):qe===xt-2?Se.push(w,B,S):Se.push(w,B,S,B,_,S)}this.setIndex(Se),this.setAttribute("position",new xl(he,3)),this.setAttribute("normal",new xl(Y,3)),this.setAttribute("uv",new xl(ne,2))}};import{IcosahedronBufferGeometry as Lv}from"three";var th=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,o,n;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,detail:0,corner:0,cornerSides:4},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((o=t.height)!=null?o:t.width),depth:Math.abs((n=t.depth)!=null?n:t.width)})}}static build(i){let{width:e,height:t,depth:r,detail:o,corner:n,cornerSides:s}=i.parameters,a=o===0&&n!==0?new Us(e*.5,n,s):new Lv(e*.5,o);return a.scale(1,t/e,r/e),Object.assign(a,{userData:$(O({},i),{type:"IcosahedronGeometry"})})}},Us=class extends So{constructor(e=1,t=.2,r=4){let o=(1+Math.sqrt(5))/2,n=[-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(n,s,a,e,t,r);this.type=a}static fromJSON(e){return new Us(e.radius,e.corner,e.cornerSides)}};import{LatheBufferGeometry as Tv,Shape as Iv}from"three";var rh=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,o,n,s,a;((o=(r=i.parameters)==null?void 0:r.points)!=null?o:[]).forEach(l=>{Array.isArray(l)&&(l.x=l[0],l.y=l[1])});let t=Object.assign({},(n=e==null?void 0:e.parameters)!=null?n:{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}]},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((s=t.height)!=null?s:t.width),depth:Math.abs((a=t.depth)!=null?a:t.width)})}}static build(i){let{points:e,segments:t,verticalSegments:r}=i.parameters,o=new Iv;o.moveTo(e[0].x,e[0].y),o.bezierCurveTo(e[1].x,e[1].y,e[2].x,e[2].y,e[3].x,e[3].y);let n=new Tv(o.extractPoints(r).shape,t);return n.rotateZ(Math.PI),Object.assign(n,{userData:$(O({},i),{type:"LatheGeometry"})})}};import{BufferGeometry as ih,BufferGeometryLoader as Dv,Vector3 as Bv,BoxBufferGeometry as nh}from"three";import{BufferGeometry as Mv,Vector2 as bl,Vector3 as oh}from"three";import{Geometry as Pv,Face3 as Ov}from"three/examples/jsm/deprecated/Geometry.js";var Av=["a","b","c"];function jv(i,e){switch(e){case"c":return i.c;case"b":return i.b;case"a":default:return i.a}}function vl(i,e,t){let r=Math.min(i,e),o=Math.max(i,e),n=r+"_"+o;return t.get(n)}function Sl(i,e,t,r,o,n){let s=Math.min(i,e),a=Math.max(i,e),l=s+"_"+a,c;if(r.has(l))c=r.get(l);else{let d=t[s],p=t[a];c={a:d,b:p,newEdge:null,faces:[]},r.set(l,c)}c.faces.push(o),n[i].edges.push(c),n[e].edges.push(c)}function _v(i,e,t,r){let o,n,s;for(o=0,n=i.length;o<n;o++)t[o]={edges:[]};for(o=0,n=e.length;o<n;o++)s=e[o],Sl(s.a,s.b,i,r,s,t),Sl(s.b,s.c,i,r,s,t),Sl(s.c,s.a,i,r,s,t)}function ks(i,e,t,r,o){i.push(new Ov(e,t,r,void 0,void 0,o))}function di(i,e){return Math.abs(e-i)/2+Math.min(i,e)}function Hs(i,e,t,r){i.push([e.clone(),t.clone(),r.clone()])}var wl=class{constructor(e=1){this.subdivisions=e}modify(e){e instanceof Mv?e=new Pv().fromBufferGeometry(e):e=e.clone(),e.mergeVertices();let t=this.subdivisions;for(;t-- >0;)this._smooth(e);return e.computeFaceNormals(),e.computeVertexNormals(),e}_smooth(e){let t=new oh,r,o,n,s,a,l=e.vertices,c=e.faces,d=e.faceVertexUvs[0],p=d!==void 0&&d.length>0,u=[],f=new Map;_v(l,c,u,f);let m=[],x,y,N,L,w,B,S;for(let J of Array.from(f.keys())){for(y=f.get(J),N=new oh,w=3/8,B=1/8,S=y.faces.length,S!=2&&(w=.5,B=0,S!=1),N.addVectors(y.a,y.b).multiplyScalar(w),t.set(0,0,0),s=0;s<S;s++){for(L=y.faces[s],a=0;a<3&&(x=l[jv(L,Av[a])],!(x!==y.a&&x!==y.b));a++);x&&t.add(x)}t.multiplyScalar(B),N.add(t),y.newEdge=m.length,m.push(N)}let _,T,h,I,b,P,v,D=[];for(o=0,n=l.length;o<n;o++){for(P=l[o],b=u[o].edges,r=b.length,r==3?_=3/16:r>3&&(_=3/(8*r)),T=1-r*Number(_),h=_,r<=2&&(r==2?(T=3/4,h=1/8):r==1||r==0),v=P.clone().multiplyScalar(T),t.set(0,0,0),s=0;s<r;s++)I=b[s],x=I.a!==P?I.a:I.b,t.add(x);t.multiplyScalar(Number(h)),v.add(t),D.push(v)}let Z=D.concat(m),V=D.length,ie,oe,ge,xe=[],A=[],j,g,z,R,U=new bl,q=new bl,W=new bl;for(o=0,n=c.length;o<n;o++)L=c[o],ie=Number(vl(L.a,L.b,f).newEdge)+V,oe=Number(vl(L.b,L.c,f).newEdge)+V,ge=Number(vl(L.c,L.a,f).newEdge)+V,ks(xe,ie,oe,ge,L.materialIndex),ks(xe,L.a,ie,ge,L.materialIndex),ks(xe,L.b,oe,ie,L.materialIndex),ks(xe,L.c,ge,oe,L.materialIndex),p&&(j=d[o],g=j[0],z=j[1],R=j[2],U.set(di(g.x,z.x),di(g.y,z.y)),q.set(di(z.x,R.x),di(z.y,R.y)),W.set(di(g.x,R.x),di(g.y,R.y)),Hs(A,U,q,W),Hs(A,g,U,W),Hs(A,z,q,U),Hs(A,R,W,q));e.vertices=Z,e.faces=xe,p&&(e.faceVertexUvs[0]=A)}};var at=new Bv,qs=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var n,s;let t=(s=(n=i.geometry)!=null?n:e==null?void 0:e.geometry)!=null?s:new ih().copy(new nh(100,100,100)),r;e===void 0?(t.computeBoundingBox(),t.boundingBox.getSize(at),r={width:at.x,height:at.y,depth:at.z,subdivisions:0}):r=e.parameters;let o=O(O({},r),i.parameters);return{parameters:{width:Math.abs(o.width),height:Math.abs(o.height),depth:Math.abs(o.depth),subdivisions:Math.abs(o.subdivisions)},geometry:t}}static build(i){var l;let{width:e,height:t,depth:r,subdivisions:o}=i.parameters,n=(l=i.geometry)!=null?l:new ih().copy(new nh(100,100,100)),s=n.userData.parameters;s===void 0?(n.computeBoundingBox(),n.boundingBox.getSize(at)):at.set(s.width,s.height,s.depth),(e!==at.x||t!==at.y||r!==at.z)&&n.scale(at.x===0?1:e/at.x,at.y===0?1:t/at.y,at.z===0?1:r/at.z);let a=n.originalGeometry;return o>0?(a===void 0||(s==null?void 0:s.subdivisions)!==o)&&(a===void 0&&(a=n),n=new wl(o).modify(a).toBufferGeometry()):(a!==void 0&&(n=a),a=void 0,n.getAttribute("normal")===void 0&&n.computeVertexNormals()),a!==void 0&&Object.assign(n,{originalGeometry:a}),delete i.geometry,Object.assign(n,{userData:$(O({},i),{type:"NonParametricGeometry"})})}static loadFromUrl(i,e,t){new Dv(t).load(i,o=>{let n=this.normalizeInputs({geometry:o});o.boundingBox.getSize(at);let s=100/at.x;Object.assign(n.parameters,{width:100,height:at.y*s,depth:at.z*s}),e(this.build(n))})}};var sh=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var o,n,s,a;let t=Object.assign({},(o=e==null?void 0:e.parameters)!=null?o:{width:100,depth:0,spikes:5,cornerRadius:0,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:3},i.parameters);return{shape:i.shape&&i.shape instanceof Pe?i.shape:new Pe,parameters:Object.assign(t,{surfaceMaxCount:((n=t.surfaceMaxCount)!=null?n:t.cornerRadius>0)?1e3:100,width:Math.abs(t.width),height:Math.abs((s=t.height)!=null?s:t.width),depth:Math.abs(t.depth!==void 0&&t.depth===0&&t.extrudeDepth>0?t.extrudeDepth:(a=t.depth)!=null?a:0)})}}static build(i){let{width:e,height:t,spikes:r,cornerRadius:o,depth:n,extrudeBevelSize:s,extrudeBevelSegments:a,surfaceMaxCount:l}=i.parameters,c=i.shape,d=e*.5,p=t*.5,u=0,f=0,m=2*Math.PI/r;for(let y=0;y<r;y++){let N=m*y,L=u+Math.sin(N)*d,w=f+Math.cos(N)*p;c.addPoint(c.createPoint(L,w))}c.isClosed=!0;for(let y=0,N=c.points.length;y<N;y++)c.points[y].roundness=o;c.roundness=o,c.update();let x=mt.create({shape:c,parameters:{surfaceMaxCount:l,roundness:o,depth:n,extrudeBevelSize:s,extrudeBevelSegments:a}});return Object.assign(x,{userData:$(O({},i),{type:"PolygonGeometry"})})}};import{BufferGeometry as Gv,Float32BufferAttribute as Nl,Vector2 as vr,Vector3 as dt}from"three";var ah=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,o,n;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((o=t.height)!=null?o:t.width),depth:Math.abs((n=t.depth)!=null?n:t.width)})}}static build(i){let{width:e,height:t,depth:r,radialSegments:o,heightSegments:n,openEnded:s,cornerRadius:a,cornerSegments:l}=i.parameters,c=new lh(e*.5,t,o,n,s,a,l);return c.scale(1,1,r/e),Object.assign(c,{userData:$(O({},i),{type:"PyramidGeometry"})})}};function Wi(i,e,t){t.x=i.x*e.x,t.y=i.y,t.z=i.x*e.y}function Cl(i,e,t,r,o,n){let s=e.clone().sub(i),a=t.clone().sub(i),l=s.angleTo(a);if(s.normalize(),a.normalize(),r===o){let c=s.add(a).normalize();n.copy(i).addScaledVector(c,r/Math.sin(l/2))}else{let c=s.angleTo(a);n.copy(i),n.addScaledVector(s,o/Math.sin(c)),n.addScaledVector(a,r/Math.sin(c))}}function zv(i,e,t){let r=i.clone().sub(e),o=t.clone().sub(e);return r.projectOnVector(o),r.add(e)}var lh=class extends Gv{constructor(e=.5,t=1,r=4,o=1,n=!1,s=0,a=4){super();r=Math.floor(Math.max(3,r)),o=Math.floor(o),a=Math.floor(a);let l=[],c=[],d=[],p=[],u=0,f=t/2,m=Math.PI/r,x=e*Math.cos(Math.PI/r),y=2*Math.PI/r,N=(r-2)*Math.PI/r,L=Math.PI-N,w=new dt(0,-f,0),B=new dt(0,f,0),S=new vr(e,-f),_=new vr(x,-f),T=new vr(0,B.y).sub(_),h=new vr(0,B.y).sub(S),I=new vr(T.y,-T.x).normalize(),b=new vr(h.y,-h.x).normalize(),v=e*Math.cos(Math.PI/r)*Math.tan((Math.PI-T.angle())/2)-1e-8;s=Math.min(s,v);let D;{let A=new dt(I.x,I.y,0),j=new dt(Math.cos(y)*A.x,A.y,Math.sin(y)*A.x);D=A.angleTo(j)}let Z=s/Math.tan((Math.PI-T.angle())/2),V=s/Math.tan((Math.PI-D)/2),ie=new dt;if(!n){c.push(w.x,w.y,w.z),d.push(0,-1,0),p.push(0,0);let A=u++,j=[],g=S.clone(),z=Z/Math.cos(Math.PI/r);g.x-=z;for(let R=0;R<r;R++){let U=R/r*Math.PI*2+m,q=new vr(Math.sin(U),Math.cos(U));Wi(g,q,ie),c.push(ie.x,ie.y,ie.z),d.push(0,-1,0),p.push(0,0),j.push(u++)}for(let R=0;R<j.length;R++)l.push(j[R],A,j[(R+1)%j.length])}let oe=[];{let A=new dt,j=new dt,g=new dt,z=new dt,R=new dt,U=new dt;for(let q=0;q<r;q++){let W=q/r*Math.PI*2+m,J=(q+.5)/r*Math.PI*2+m,E=(q+1)/r*Math.PI*2+m,H=new vr(Math.sin(W),Math.cos(W)),k=new vr(Math.sin(J),Math.cos(J)),se=new vr(Math.sin(E),Math.cos(E));Wi(S,H,j),Wi(S,se,g),Wi(I,k,A),Cl(B,j,g,V,V,z),c.push(z.x,z.y,z.z),Cl(j,B,g,V,Z,R),c.push(R.x,R.y,R.z),Cl(g,j,B,Z,V,U),c.push(U.x,U.y,U.z),d.push(A.x,A.y,A.z),d.push(A.x,A.y,A.z),d.push(A.x,A.y,A.z),p.push(0,0),p.push(0,0),p.push(0,0);let F=u++,K=u++,X=u++;if(l.push(F,K,X),s>0){{let Y=j.clone().add(g).multiplyScalar(.5),ne=B.clone().sub(Y).normalize(),me=w.clone().sub(Y).normalize().add(ne).normalize().multiplyScalar(-1),Oe=U.clone().sub(R);ge(Y,Oe,me,T.angle())}let te,he;{let Y=new dt;Wi(b,se,Y);let ne=U.clone().add(z).multiplyScalar(.5);ne=zv(ne,g,B);let Se=U.clone().sub(z);[te,he]=ge(ne,Se,Y,D,z.y)}{let Y=te,ne=Y.clone().setY(0).normalize(),Se=new dt(0,-1,0),me=ne.clone().cross(Se);xe(Y,ne,Se,me)}oe.concat(he);{let Y=T.angle(),ne=Math.PI-Y,Se=B.clone();Se.y-=s/Math.sin(Y-Math.PI/2);let me=new dt,Oe=[];for(let rt=0;rt<a;rt++){let pt=[],zt=Math.PI/2-ne*rt/a,Tr=Math.cos(zt),xt=Math.sin(zt),Ir=J;for(let uo=0;uo<=rt;uo++){let ho=Math.cos(Ir),qe=Math.sin(Ir);A.x=Tr*qe,A.y=xt,A.z=Tr*ho,me.copy(Se).addScaledVector(A,s),c.push(me.x,me.y,me.z),d.push(A.x,A.y,A.z),p.push(0,0),pt.push(u++),Ir+=Math.PI*2/rt/r}Oe.push(pt)}he.reverse(),Oe.push(he);let He=Oe.length-1;for(let rt=0;rt<He;rt++){let pt=Oe[rt],zt=Oe[rt+1],Tr=pt.length-1;l.push(zt[1],pt[0],zt[0]);for(let xt=1;xt<=Tr;xt++)l.push(pt[xt],pt[xt-1],zt[xt]),l.push(zt[xt+1],pt[xt],zt[xt])}}}}}this.setIndex(l),this.setAttribute("position",new Nl(c,3)),this.setAttribute("normal",new Nl(d,3)),this.setAttribute("uv",new Nl(p,2));function ge(A,j,g,z,R){let U=-z/2,q=(Math.PI-z)/2,W=j.clone().normalize().cross(g);A.addScaledVector(g,-s/Math.sin(q));let J=new dt,E=new dt,H=1,k=u,se=[];for(let F=0;F<=a;F++){let K=U+F/a*z;E.set(0,0,0),E.addScaledVector(W,Math.sin(K)),E.addScaledVector(g,Math.cos(K));for(let X=0;X<=H;X++){let te=X/H-.5;if(J.copy(A),J.addScaledVector(j,te),J.addScaledVector(E,s),R!=null){let he=Math.max(0,J.y-R);J.addScaledVector(j,-he/j.y)}c.push(J.x,J.y,J.z),d.push(E.x,E.y,E.z),p.push(0,0),X===0&&se.push(u),u++}}for(let F=0;F<a;F++)for(let K=0;K<H;K++){let X=k+K+(H+1)*F,te=X+(H+1),he=te+1,Y=X+1;l.push(X,te,Y),l.push(te,he,Y)}return[A.clone().addScaledVector(j,.5),se]}function xe(A,j,g,z){let R=Math.PI/2,U=h.angle()-R,q=[],W=new dt,J=new dt;for(let H=0;H<=a;H++){let k=[],se=H/a;for(let F=0;F<=H;F++){let X=((H?F/H:0)-.5)*L,te=Math.cos(X),he=Math.sin(X),Y=Math.atan(Math.tan(U)*te),ne=(R+Y)*se,Se=Math.cos(ne),me=Math.sin(ne);W.set(0,0,0),W.addScaledVector(j,me*te),W.addScaledVector(g,Se),W.addScaledVector(z,me*he),J.copy(A).addScaledVector(W,s),c.push(J.x,J.y,J.z),d.push(W.x,W.y,W.z),p.push(0,0),k.push(u++)}q.push(k)}let E=q.length-1;for(let H=0;H<E;H++){let k=q[H],se=q[H+1],F=k.length-1;l.push(k[0],se[1],se[0]);for(let K=1;K<=F;K++)l.push(k[K-1],k[K],se[K]),l.push(k[K],se[K+1],se[K])}}}};var Ws=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var s,a,l,c,d;let t=Object.assign({},(s=e==null?void 0:e.parameters)!=null?s:{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters),r=Object.assign((a=e==null?void 0:e.ui)!=null?a:{enabledIndieCorners:!1},i.ui),o=t.cornerRadius.reduce((p,u)=>p+u,0);return{shape:i.shape&&i.shape instanceof Pe?i.shape:new Pe,parameters:Object.assign(t,{surfaceMaxCount:((l=t.surfaceMaxCount)!=null?l:o>0)?1e3:100,width:Math.abs(t.width),height:Math.abs((c=t.height)!=null?c:t.width),depth:Math.abs(t.depth!==void 0&&t.depth===0&&t.extrudeDepth>0?t.extrudeDepth:(d=t.depth)!=null?d:0)}),ui:r}}static build(i){let e=i.shape,{width:t,height:r,cornerRadius:o,cornerType:n,depth:s,extrudeBevelSize:a,extrudeBevelSegments:l,surfaceMaxCount:c}=i.parameters,d={x:t*.5,y:r*.5},p={x:-d.x,y:-d.y},u={x:d.x,y:d.y};function f(S,_,T){return _>t&&T>r?Math.min(S*t/_,S*r/T):_>t?S*t/_:T>r?S*r/T:S}let m=[];m[0]=o[0]===0?0:f(o[0],o[0]+o[3],o[0]+o[1]),m[1]=o[1]===0?0:f(o[1],o[1]+o[2],o[1]+o[0]),m[2]=o[2]===0?0:f(o[2],o[2]+o[1],o[2]+o[3]),m[3]=o[3]===0?0:f(o[3],o[3]+o[0],o[3]+o[2]);let x=p.x,y=u.x,N=u.y,L=p.y;e.addPoint(e.createPoint(x,N)),e.addPoint(e.createPoint(y,N)),e.addPoint(e.createPoint(y,L)),e.addPoint(e.createPoint(x,L)),e.isClosed=!0;let w=!0;for(let S=0,_=e.points.length;S<_;S++)e.points[S].roundness=m[S],S>0&&m[S]!==m[S-1]&&(w=!1);w&&(e.roundness=m[0]),e.useCubicForRoundedCorners=n!==1,e.update();let B=mt.create({shape:e,parameters:{surfaceMaxCount:c,depth:s,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(B,{userData:$(O({},i),{type:"RectangleGeometry"})})}};import{SphereBufferGeometry as Ev}from"three";var ch=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,o,n;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((o=t.height)!=null?o:t.width),depth:Math.abs((n=t.depth)!=null?n:t.width)})}}static build(i){let{width:e=100,height:t=e,depth:r=e,widthSegments:o=64,heightSegments:n=64,phiStart:s,phiLength:a,thetaStart:l,thetaLength:c}=i.parameters,d=new Ev(.5*e,o,n,s,a,l,c);return d.scale(1,t/e,r/e),Object.assign(d,{userData:$(O({},i),{type:"SphereGeometry"})})}};import{PlaneBufferGeometry as Fv}from"three";var dh=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,o;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,depth:0,widthSegments:8,heightSegments:8},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((o=t.height)!=null?o:t.width),depth:0})}}static build(i){let{width:e=100,height:t=e,widthSegments:r=8,heightSegments:o=8}=i.parameters,n=new Fv(e,t,r,o);return n.scale(1,1,1),Object.assign(n,{userData:$(O({},i),{type:"PlaneGeometry"})})}};var ph=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var o,n,s,a;let t=Object.assign({},(o=e==null?void 0:e.parameters)!=null?o:{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters);return{shape:i.shape&&i.shape instanceof Pe?i.shape:new Pe,parameters:Object.assign(t,{surfaceMaxCount:((n=t.surfaceMaxCount)!=null?n:t.cornerRadius>0)?1e3:100,width:Math.abs(t.width),height:Math.abs((s=t.height)!=null?s:t.width),depth:Math.abs(t.depth!==void 0&&t.depth===0&&t.extrudeDepth>0?t.extrudeDepth:(a=t.depth)!=null?a:0)})}}static build(i){let{width:e,height:t,innerRadiusPercent:r,spikes:o,cornerRadius:n,angle:s,depth:a,extrudeBevelSize:l,extrudeBevelSegments:c,surfaceMaxCount:d}=i.parameters,p=i.shape,u=e*.5,f=t*.5,m=0,x=0,y=s*Math.PI/360/o,N=Math.PI/2*3*-1,L=u*r/100,w=f*r/100;if(o==3&&r==50){y=2*Math.PI/o;for(let S=0;S<o;S++){let _=y*S,T=m+Math.sin(_)*u,h=x+Math.cos(_)*f;p.addPoint(p.createPoint(T,h))}}else for(let S=0;S<o;S++){let _=m+Math.cos(N)*u,T=x+Math.sin(N)*f;p.addPoint(p.createPoint(_,T)),N+=y,_=m+Math.cos(N)*L,T=x+Math.sin(N)*w,S<=o,p.addPoint(p.createPoint(_,T)),N+=y}p.isClosed=!0;for(let S=0,_=p.points.length;S<_;S++)p.points[S].roundness=n;p.roundness=n,p.update();let B=mt.create({shape:p,parameters:{surfaceMaxCount:d,roundness:n,depth:a,extrudeBevelSize:l,extrudeBevelSegments:c}});return Object.assign(B,{userData:$(O({},i),{type:"StarGeometry"})})}};import{PlaneBufferGeometry as Rv}from"three";var $s=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,o,n;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,depth:0},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((o=t.height)!=null?o:t.width),depth:Math.abs((n=t.depth)!=null?n:0)})}}static build(i){let{width:e,height:t}=i.parameters,r=new Rv(e,t);return Object.assign(r,{userData:$(O({},i),{type:"TextFrameGeometry"})})}};var uh=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var s,a,l;let t=Object.assign({},(s=e==null?void 0:e.parameters)!=null?s:{width:100,radialSegments:32,tubularSegments:64,arc:Math.PI*2,cornerRadius:30,cornerSegments:8},i.parameters),r=Math.abs(t.width),o=Math.abs((a=t.height)!=null?a:t.width),n=Math.abs((l=t.depth)!=null?l:t.width*.25);return{parameters:Object.assign(t,{width:r,height:o,depth:n})}}static build(i){let{width:e,height:t,depth:r,radialSegments:o,tubularSegments:n,arc:s,cornerRadius:a,cornerSegments:l}=i.parameters,c=Vv(e,t,r,e*.5,s,n,0,0,o,a,l);return c.scale(1,t/e,1),Object.assign(c,{userData:$(O({},i),{type:"TorusGeometry"})})}};function Vv(i,e,t,r,o,n,s,a,l,c,d){return[e,t]=[t,e],s=e/2,o/=2*Math.PI,o==1&&(c=0),new Vs(!0,i,e,t,r,o,n,s,a,l,c,d)}import{TorusKnotBufferGeometry as Uv}from"three";var hh=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,o,n,s;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((o=t.height)!=null?o:t.width),depth:Math.abs((n=t.depth)!=null?n:t.width),tube:(s=t.tube)!=null?s:t.width*.125})}}static build(i){let{width:e,tube:t,tubularSegments:r,radialSegments:o,p:n,q:s}=i.parameters,a=e*.5;a!==t&&(a-=t);let l=new Uv(a,t,r,o,n,s);return Object.assign(l,{userData:$(O({},i),{type:"TorusKnotGeometry"})})}};var mh=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var o,n,s,a;let t=Object.assign({},(o=e==null?void 0:e.parameters)!=null?o:{width:100,depth:0,spikes:5,cornerRadius:0,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},i.parameters);return{shape:i.shape&&i.shape instanceof Pe?i.shape:new Pe,parameters:Object.assign(t,{surfaceMaxCount:((n=t.surfaceMaxCount)!=null?n:t.cornerRadius>0)?1e3:100,width:Math.abs(t.width),height:Math.abs((s=t.height)!=null?s:t.width*(t.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(t.depth!==void 0&&t.depth===0&&t.extrudeDepth>0?t.extrudeDepth:(a=t.depth)!=null?a:0)})}}static build(i){let{width:e=100,height:t,cornerRadius:r,depth:o,extrudeBevelSize:n,extrudeBevelSegments:s,isRect:a,surfaceMaxCount:l}=i.parameters,c=i.shape,d=e*.5,p=t*.5;a?(c.addPoint(c.createPoint(-d,p)),c.addPoint(c.createPoint(d,-p)),c.addPoint(c.createPoint(-d,-p))):(c.addPoint(c.createPoint(0,p)),c.addPoint(c.createPoint(d,-p)),c.addPoint(c.createPoint(-d,-p))),c.isClosed=!0;for(let f=0,m=c.points.length;f<m;f++)c.points[f].roundness=r;c.roundness=r,c.update();let u=mt.create({shape:c,parameters:{surfaceMaxCount:l,roundness:r,depth:o,extrudeBevelSize:n,extrudeBevelSegments:s}});return Object.assign(u,{userData:$(O({},i),{type:"TriangleGeometry"})})}};var $i={};Hm($i,{addBarycentricAttribute:()=>$v,fixUvs:()=>Kv,loadFromUrl:()=>Jv,resizeGeometry:()=>Wv,roundShapePolygon:()=>qv});import{BufferGeometryLoader as kv,Float32BufferAttribute as Hv,Vector3 as Ll}from"three";var fh=function(i,e){let t=e.x-i.x,r=e.y-i.y,o=Math.sqrt(t*t+r*r),n=t/o,s=r/o,a=Math.atan2(s,n);return{x:t,y:r,len:o,nx:n,ny:s,ang:a}},qv=(i,e,t)=>{let r,o,n,s,a,l,c,d,p,u,f,m,x,y,N=e.length;for(s=e[N-2],i.curves=[],r=1;r<N-1;r++){a=e[r%N],l=e[(r+1)%N];let L=fh(a,s),w=fh(a,l);c=L.nx*w.ny-L.ny*w.nx,d=L.nx*w.nx-L.ny*-w.ny,f=Math.asin(c),p=1,u=!1,d<0?f<0?f=Math.PI+f:(f=Math.PI-f,p=-1,u=!0):f>0&&(p=-1,u=!0),m=f/2,y=Math.abs(Math.cos(m)*t/Math.sin(m)),y>Math.min(L.len/2,w.len/2)?(y=Math.min(L.len/2,w.len/2),x=Math.abs(y*Math.sin(m)/Math.cos(m))):x=t,o=a.x+w.nx*y,n=a.y+w.ny*y,o+=-w.ny*x*p,n+=w.nx*x*p,i.absarc(o,n,x,L.ang+Math.PI/2*p,w.ang-Math.PI/2*p,u),s=a,a=l}i.closePath()},Wv=(i,{width:e,height:t,depth:r})=>{e=Math.abs(e),t=Math.abs(t),r=Math.abs(r);let o=i.userData.parameters,n,s,a;e===0?(e=o.width,n=1):n=e/o.width,t===0?(t=o.height,s=1):s=t/o.height,r===0?(r=o.depth,a=1):a=r/o.depth,i.scale(n,s,a),o.width=e,o.height=t,o.depth=r},$v=(i,e)=>{let t=[new Ll(1,0,0),new Ll(0,1,0),new Ll(0,0,1)],r=i.attributes.position,o=new Float32Array(r.count*3);for(let n=0,s=r.count;n<s;n++)t[n%3].toArray(o,n*3);i.setAttribute(e,new Hv(o,3))},Jv=i=>new Promise(e=>{new kv().load(i,r=>e(r))}),Kv=(i,e,t)=>{let r=i.getAttribute("uv");if(r)for(let o=0;o<r.count;o++){let n=r.getX(o),s=r.getY(o);r.setXY(o,(n+e/2)/e,1-(s-t/2)/t*-1)}};import{BufferGeometry as yh,BufferAttribute as gh,Uint32BufferAttribute as Tl,Float32BufferAttribute as Il,Matrix4 as Zv}from"three";import{mergeVertices as Qv}from"three/examples/jsm/utils/BufferGeometryUtils.js";var Xv,Js=new Promise(i=>{Xv=i});var de;Js.then(i=>{de=i});var xh=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),bh=new Uint32Array([0,1,2,3]),vh=new Uint8Array([4]),kt=class{static build(i,e,t,r,o){let n,s,a;if(i===void 0)n=kt.allocate(o,t),de.set_destination_refinement_level(n,0),s=kt.buildLevel(n,!0,r);else if(i.positionWASM!==void 0){e&&e!==0&&(de.free_bvh(e),de.free_subdivision_surface(e));try{n=kt.allocate(o,void 0,i)}catch(l){console.error(l,i),n=kt.allocate(o,void 0,{positionWASM:xh,indexWASM:bh,verticesPerFaceWASM:vh})}de.set_destination_refinement_level(n,0),s=kt.buildLevel(n,!0,r)}else n=e;if(i!==void 0&&i.subdivisions!==void 0){let l=Yv(i.subdivisions,i.positionWASM.length);de.set_destination_refinement_level(n,l),l>0?a=kt.buildLevel(n,!1,r):a=null}return{subdivPointer:n,originalGeometry:s,subdividedGeometry:a}}static allocate(i,e,t){var S;let r,o,n,s=[],a=[];if(t)t.positionWASM&&t.positionWASM.length>0?(r=t.positionWASM,o=t.indexWASM,n=t.verticesPerFaceWASM):(r=xh,o=bh,n=vh);else{e.deleteAttribute("normal"),e.deleteAttribute("uv");let _=Qv(e);r=_.attributes.position.array;let T=_.getIndex().array,h=T.length;switch(e.userData.type==="TorusGeometry"&&(e==null?void 0:e.userData.parameters.arc)===Math.PI*2&&(e.userData.type="ClosedTorusGeometry"),e.userData.type){case"ClosedTorusGeometry":case"PlaneGeometry":case"TorusKnotGeometry":case"CubeGeometry":o=new Uint32Array(h/3*2),n=new Uint8Array(h/6).fill(4);for(let V=0,ie=0;V<h;V+=6)o[ie++]=T[V],o[ie++]=T[V+1],o[ie++]=T[V+4],o[ie++]=T[V+5];break;case"TorusGeometry":case"SphereGeometry":case"HelixGeometry":case"CylinderGeometry":case"ConeGeometry":let I,b,P;if(e.userData.type==="SphereGeometry")b=e.parameters.heightSegments,I=e.parameters.widthSegments,e.parameters.thetaLength!==Math.PI&&(P=!0);else if(e.userData.type==="CylinderGeometry")b=e.parameters.heightSegments+2,I=e.parameters.radialSegments;else if(e.userData.type==="ConeGeometry")b=e.parameters.heightSegments+1,I=e.parameters.radialSegments;else if(e.userData.type==="TorusGeometry"){let V=e.userData.parameters;b=Math.ceil(V.tubularSegments*V.arc/(2*Math.PI))+2,I=V.radialSegments}else{let{pathSegments:V,segments:ie,revolutions:oe}=e.userData.parameters;b=Math.ceil(ie*oe)+2,I=V}P?(o=new Uint32Array(1*I*3+(b-1)*I*4),n=new Uint8Array(1*I+(b-1)*I)):(o=new Uint32Array(2*I*3+(b-2)*I*4),n=new Uint8Array(2*I+(b-2)*I));let v=0,D=0,Z=0;if(e.userData.type==="SphereGeometry"||e.userData.type==="HelixGeometry"||e.userData.type==="TorusGeometry"){for(;D<3*I;)o[D++]=T[v++],o[D++]=T[v++],o[D++]=T[v++],n[Z++]=3;let V=P?o.length:3*I+4*(b-2)*I;for(;D<V;v+=6)o[D++]=T[v],o[D++]=T[v+1],o[D++]=T[v+4],o[D++]=T[v+5],n[Z++]=4}else for(;D<4*(b-2)*I;v+=6)o[D++]=T[v],o[D++]=T[v+1],o[D++]=T[v+4],o[D++]=T[v+5],n[Z++]=4;for(;D<o.length;)o[D++]=T[v++],o[D++]=T[v++],o[D++]=T[v++],n[Z++]=3;break;default:o=T,n=new Uint8Array(h/3).fill(3);break}}let l=r.length,c=o.length,d=n.length,p=r.length+s.length+a.length,u=o.length+n.length,f=p*Float32Array.BYTES_PER_ELEMENT+u*Uint32Array.BYTES_PER_ELEMENT,m=p*Float32Array.BYTES_PER_ELEMENT,x=u*Uint32Array.BYTES_PER_ELEMENT,y=de._malloc(f),N=new Float32Array(de.HEAPF32.buffer,y,p),L=new Uint32Array(de.HEAPU32.buffer,y+m,u);N.set(r,0),N.set(s,r.length),N.set(a,r.length+s.length),L.set(o,0),L.set(n,o.length);let w;((S=t==null?void 0:t.scaleBaked)==null?void 0:S.some(_=>_!==1))&&(w=new Zv().makeScale(...t.scaleBaked)),i&&(w?w.premultiply(i):w=i);let B=w?de.alloc_subdivision_surface2(y,l,y+m,c,y+m+o.length*Uint32Array.BYTES_PER_ELEMENT,d,w.elements):de.alloc_subdivision_surface(y,l,y+m,c,y+m+o.length*Uint32Array.BYTES_PER_ELEMENT,d);return de._free(y),B}static buildLevel(i,e,t,r,o){let n=o?de.get_mesh_data2(i,e?de.Level.CONTROL:de.Level.REFINED,t!=null?t:!e,o.elements):de.get_mesh_data(i,e?de.Level.CONTROL:de.Level.REFINED,t!=null?t:!e),s=8,a=de.HEAPU32.subarray(n>>2,(n>>2)+s),l=a.subarray(4,4+4),c=0,d=de.HEAPU32[a[c]>>2],p=de.HEAPF32.subarray(d>>2,(d>>2)+l[c]);c++;let u=de.HEAPU32[a[c]>>2],f=de.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let m=de.HEAPU32[a[c]>>2],x=de.HEAPU32.subarray(m>>2,(m>>2)+l[c]);c++;let y=de.HEAPU32[a[c]>>2],N=de.HEAPU32.subarray(y>>2,(y>>2)+l[c]);if(c++,r===void 0){let L=new yh;if(L.setIndex(new Tl(N,1)),L.setAttribute("position",new Il(p,3)),L.setAttribute("normal",new Il(f,3)),e){L.setAttribute("faceMap",new Tl(x,1));let w=new Float32Array(f.length/3*4).fill(0);L.setAttribute("color",new gh(w,4))}return de.free_mesh_data(n),L.userData.type="SubdivGeometry",L}r.getAttribute("position").copyArray(p),r.getAttribute("normal").copyArray(f),r.attributes.position.needsUpdate=!0,r.attributes.normal.needsUpdate=!0,de.free_mesh_data(n)}static buildControlCageWireframe(i,e,t){let r=de.get_wireframe_data_for_base_level(i),o=4,n=de.HEAPU32.subarray(r>>2,(r>>2)+o),s=n.subarray(2,2+2),a=0,l=de.HEAPU32[n[a]>>2],c=de.HEAPF32.subarray(l>>2,(l>>2)+s[a]);a++;let d=de.HEAPU32[n[a]>>2],p=de.HEAPU32.subarray(d>>2,(d>>2)+s[a]);if(e===void 0){let u=new yh;u.setAttribute("position",new Il(c,3));let f=new Float32Array(c.length);for(let m=0,x=c.length;m<x;)f[m++]=t.r,f[m++]=t.g,f[m++]=t.b;return u.setAttribute("color",new gh(f,3)),u.setIndex(new Tl(p,1)),de.free_wireframe_data_for_base_level(r),u}e.getAttribute("position").copyArray(c),e.attributes.position.needsUpdate=!0,de.free_wireframe_data_for_base_level(r)}static updateCollabMesh(i,e,t){e||de.set_destination_refinement_level(i,1);let r=t?de.get_topological_data2(i,e?de.Level.CONTROL:de.Level.REFINED,t.elements):de.get_topological_data(i,e?de.Level.CONTROL:de.Level.REFINED),o=6,n=de.HEAPU32.subarray(r>>2,(r>>2)+o),s=n.subarray(3,3+3),a=0,l=de.HEAPU32[n[a]>>2],c=new Float32Array(de.HEAPF32.subarray(l>>2,(l>>2)+s[a]));a++;let d=de.HEAPU32[n[a]>>2],p=new Uint32Array(de.HEAPU32.subarray(d>>2,(d>>2)+s[a]));a++;let u=de.HEAPU32[n[a]>>2],f=new Uint8Array(de.HEAPU32.subarray(u>>2,(u>>2)+s[a]));return de.free_topological_data(r),{positions:c,indices:p,verticesPerFace:f}}};function Yv(i,e){let t=i;return t=Math.min(t,3-Math.ceil(Math.log(e/172e3)/Math.log(4))),Math.max(t,0)}var Ml={ConeGeometry:wu,CubeGeometry:Nu,CylinderGeometry:vu,DodecahedronGeometry:Lu,EllipseGeometry:Ju,HelixGeometry:eh,IcosahedronGeometry:th,LatheGeometry:rh,NonParametricGeometry:qs,PolygonGeometry:sh,PyramidGeometry:ah,RectangleGeometry:Ws,SphereGeometry:ch,PlaneGeometry:dh,StarGeometry:ph,TextFrameGeometry:$s,TorusGeometry:uh,TorusKnotGeometry:hh,TriangleGeometry:mh,VectorGeometry:mt},Ji=i=>Ml[i.type].create(i);import{Matrix4 as _l}from"three";import{Box3 as Ch,Line3 as Qt,Matrix4 as Pl,Vector3 as Re}from"three";import{HemisphereLight as Sh}from"three";import{Color as eS}from"three";var Ht=class extends eS{constructor(e,t,r,o){super(e,t,r);this.a=o}setRGBA(e,t,r,o){super.setRGB(e,t,r),this.a=o}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}};function Ye(i,e){let t;if(typeof i=="string"){let r=e==null?void 0:e.getColor(i);r?t=r:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),t=new Ht(0,0,0,0))}else return"a"in i?new Ht(i.r,i.g,i.b,i.a):new Ht(i.r,i.g,i.b,1);return t}var Ks=i=>"isEntity"in i,Xs=i=>"isAbstractMesh"in i;var Er=i=>"objectHelper"in i;function tS(i,e){var r;let t=!1;e.position&&(i.position.fromArray(e.position),t=!0),e.rotation&&(i.rotation.fromArray(e.rotation),t=!0),e.scale&&(t=!0,i.scale.fromArray(e.scale)),e.hiddenMatrix!==void 0&&"hiddenMatrix"in i&&(t=!0,i.hiddenMatrix.fromArray((r=e.hiddenMatrix)!=null?r:Zr.identity)),t&&i.updateMatrix(),e.position&&e.rotation&&e.scale&&e.hiddenMatrix!==void 0&&i.updateWorldMatrix(!1,!0),i.objectType==="CombinedCamera"&&(e.isUpVectorFlipped!==void 0&&(i.isUpVectorFlipped=e.isUpVectorFlipped),i.updateUp())}function rS(i,e){tS(i,e),e.name!==void 0&&(i.name=e.name),e.visible!==void 0&&(i.isEntity?i.visibility=e.visible:i.visible=e.visible)}function wh(i,e,t){rS(i,e),e.color!==void 0&&(i.color=Ye(e.color,t)),e.intensity!==void 0&&(i.intensity=e.intensity),e.shadows!==void 0&&!(i instanceof Sh)&&(i.castShadow=e.shadows),i.shadow&&!(i instanceof Sh)&&e.depth!==void 0&&(i.shadow.camera.far=e.depth,i.shadow.needsUpdate=!0),e.helper!==void 0&&Er(i)&&(i.enableHelper=e.helper,i.gizmos.shadowmap.visible=e.helper)}function Nh(i,e){i.shadow.camera.right=e/2,i.shadow.camera.left=-e/2,i.shadow.camera.top=e/2,i.shadow.camera.bottom=-e/2,i.shadow.needsUpdate=!0}var pi=new Ch,ft=new Re,le=new Re,tt=new Pl;function oS(i,e,t=0,r=e.count){let o=1/0,n=1/0,s=1/0,a=-1/0,l=-1/0,c=-1/0;for(let d=t;d<r;d++){let p=e.getX(d),u=e.getY(d),f=e.getZ(d);p<o&&(o=p),u<n&&(n=u),f<s&&(s=f),p>a&&(a=p),u>l&&(l=u),f>c&&(c=f)}return i.min.set(o,n,s),i.max.set(a,l,c),i}var Lh=(i,e,t,r)=>{var o;if(Xs(i)){let n=i.geometry.userData.parameters,s=i.geometry.getAttribute("position");i.geometry.userData.type==="SubdivGeometry"?ft.copy(i.originalGeometry.boundingSphere.center):(oS(pi,s,i.geometry.drawRange.start,i.geometry.drawRange.count<1/0?i.geometry.drawRange.count:s.count),pi.getCenter(ft)),i.forceComputeSize?pi.getSize(le).multiplyScalar(.5):le.set(n.width,n.height,(o=n.depth)!=null?o:0).multiplyScalar(.5)}else if(Er(i)&&r===!0){let n=i.geometryHelper.getAttribute("position");pi.setFromArray(n.array),pi.getCenter(ft),pi.getSize(le).multiplyScalar(.5)}else ft.setScalar(0),le.setScalar(0);tt.copy(e).multiply(i.matrixWorld),le.x===0&&le.y===0&&le.z===0?t.push(new Re(ft.x,ft.y,ft.z).applyMatrix4(tt)):t.push(new Re(-le.x,le.y,le.z).add(ft).applyMatrix4(tt),new Re(-le.x,-le.y,le.z).add(ft).applyMatrix4(tt),new Re(le.x,-le.y,le.z).add(ft).applyMatrix4(tt),new Re(le.x,le.y,le.z).add(ft).applyMatrix4(tt),new Re(-le.x,le.y,-le.z).add(ft).applyMatrix4(tt),new Re(-le.x,-le.y,-le.z).add(ft).applyMatrix4(tt),new Re(le.x,-le.y,-le.z).add(ft).applyMatrix4(tt),new Re(le.x,le.y,-le.z).add(ft).applyMatrix4(tt))},Zs=class extends Ch{constructor(){super(...arguments);this.matrix=new Pl;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 r=new Pl().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,r,t)}expandByObjectSize(e,t,r=!1){let o=[];return r===!0?e.traverseEntity(n=>Lh(n,t,o,e.enableHelper===!0)):Lh(e,t,o,e.enableHelper===!0),this.setFromPoints(o)}getCenter(e){return e=super.getCenter(e),e.applyMatrix4(this.matrix),e}getPositionToCenter(e){return e=super.getCenter(e),e.applyMatrix4(tt.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(le).multiplyScalar(.5),this.getCenter(ft),tt.copy(this.matrix).setPosition(ft),this.vertices=[new Re(-le.x,le.y,le.z).applyMatrix4(tt),new Re(-le.x,-le.y,le.z).applyMatrix4(tt),new Re(le.x,-le.y,le.z).applyMatrix4(tt),new Re(le.x,le.y,le.z).applyMatrix4(tt),new Re(-le.x,le.y,-le.z).applyMatrix4(tt),new Re(-le.x,-le.y,-le.z).applyMatrix4(tt),new Re(le.x,-le.y,-le.z).applyMatrix4(tt),new Re(le.x,le.y,-le.z).applyMatrix4(tt)]}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=[new Qt(this.vertices[0],this.vertices[3]),new Qt(this.vertices[1],this.vertices[2]),new Qt(this.vertices[5],this.vertices[6]),new Qt(this.vertices[4],this.vertices[7]),new Qt(this.vertices[0],this.vertices[1]),new Qt(this.vertices[3],this.vertices[2]),new Qt(this.vertices[7],this.vertices[6]),new Qt(this.vertices[4],this.vertices[5]),new Qt(this.vertices[0],this.vertices[4]),new Qt(this.vertices[1],this.vertices[5]),new Qt(this.vertices[2],this.vertices[6]),new Qt(this.vertices[3],this.vertices[7])],this.centerEdges=this.edges.map(e=>e.getCenter(new Re))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=[new Re().copy(this.vertices[0]).sub(this.vertices[2]).multiplyScalar(.5).add(this.vertices[2]),new Re().copy(this.vertices[7]).sub(this.vertices[5]).multiplyScalar(.5).add(this.vertices[5]),new Re().copy(this.vertices[4]).sub(this.vertices[1]).multiplyScalar(.5).add(this.vertices[1]),new Re().copy(this.vertices[3]).sub(this.vertices[6]).multiplyScalar(.5).add(this.vertices[6]),new Re().copy(this.vertices[4]).sub(this.vertices[3]).multiplyScalar(.5).add(this.vertices[3]),new Re().copy(this.vertices[1]).sub(this.vertices[6]).multiplyScalar(.5).add(this.vertices[6])]}};import{Object3D as yS,Matrix4 as gS,Light as xS}from"three";import{Group as hS,Mesh as Ah,MeshStandardMaterial as jh}from"three";import{BufferGeometry as iS,Float32BufferAttribute as Ol}from"three";function Th(i){var s;let e=[],t=i.groups,r=i.getAttribute("position").array,o=i.getAttribute("normal").array,n=(s=i.getAttribute("uv"))==null?void 0:s.array;return t.forEach(a=>{let l=a.count,c=new iS,d=new Float32Array(l*3),p=new Float32Array(l*3),u=new Float32Array(l*2);for(let f=0;f<l;f++){let m=3*(a.start+f),x=3*f;if(d[x]=r[m],d[x+1]=r[m+1],d[x+2]=r[m+2],p[x]=o[m],p[x+1]=o[m+1],p[x+2]=o[m+2],n){let y=2*(a.start+f),N=2*f;u[N]=n[y],u[N+1]=n[y+1]}}c.setAttribute("position",new Ol(d,3)),c.setAttribute("normal",new Ol(p,3)),n&&c.setAttribute("uv",new Ol(u,2)),e.push(c)}),e}import{GLTFExporter as mS}from"three/examples/jsm/exporters/GLTFExporter.js";var nS,Ih=new Promise(i=>{nS=i});var _h=wc(Oh());var Ys={isPublish:!1,gltfQueue:[]};function jl(i,e,t){return i[e.uuid]===void 0&&(i[e.uuid]=e.toJSON(t)),e.uuid}var fS=new mS;function Dh(i,e,t){if(i[e.uuid]===void 0)if(e.userData.type==="NonParametricGeometry"||e.userData.type==="SubdivGeometry"){if(e.userData.type==="SubdivGeometry")if(Ys.isPublish)e=qs.create({geometry:e.clone()}),e.userData.parameters.subdivisions===0&&(delete e.attributes.color,delete e.attributes.faceMap,delete e.attributes.positionWASM,delete e.attributes.indexWASM,delete e.attributes.verticesPerFaceWASM);else{let o=e.originalGeometry;if(o){let n=e.userData;e=o.clone(),e.userData=n}else e=e.clone();delete e.attributes.color,delete e.attributes.faceMap,delete e.attributes.position,delete e.attributes.normal,e.index=null}let r=e.originalGeometry;if(r!==void 0){let o=e.userData;e=r,e.userData=o}if(!Ys.isPublish)i[e.uuid]=e.toJSON();else{let o={type:"NonParametricGeometry",uuid:e.uuid,userData:{}};e.name!==""&&(o.name=e.name),Object.keys(e.userData).length>0&&(o.userData=O({},e.userData));let n=e.index===null,s=new hS;if(Array.isArray(t))Th(e).forEach((l,c)=>{let d=new Ah(l,new jh);s.add(d),l.userData.groupIndex=c,l.userData.materialIndex=e.groups[c].materialIndex,l.index===null&&(n=!0)});else{let a=new Ah(e,new jh);s.add(a)}Ys.gltfQueue.push(new Promise(async a=>{await Promise.all(Ys.gltfQueue),fS.parse(s,async l=>{let{gltfTransform:c,DracoMeshCompressionExtension:d,addIndex:p}=await Ih,u=c.readJSON({json:yo(l),resources:{}});u.createExtension(d).setRequired(!0).setEncoderOptions({quantizationVolume:"scene"}),n&&await u.transform(p);try{let{json:f,resources:m}=c.writeJSON(u),x=_h.default.fromByteArray(new Uint8Array(m[".bin"]));f.buffers[0].uri=`data:application/octet-stream;base64,${x}`,a()}catch(f){a()}},{})})),i[e.uuid]=o}}else{let r=e.userData;if(r.type==="VectorGeometry"){let o=e.userData.shape;r=Object.assign({},r,{shape:o.toJSON()})}i[e.uuid]={uuid:e.uuid,userData:r}}return e.uuid}function ui(i){let e=[];for(let t in i){let r=i[t];delete r.metadata,e.push(r)}return e}function Bh(i){let e=[];for(let t in i)e.push(i[t]);return e}var ea=i=>class extends i{hasEntityChild(){return this.children.some(t=>Ks(t))}isDescendantOf(t){t instanceof yS&&(t=t.uuid);let r=this;for(;r.parent;){if(r.parent.uuid===t)return!0;r=r.parent}return!1}attach(t,r){this.updateWorldMatrix(!0,!1);let o=new gS().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),o.multiply(t.parent.matrixWorld)),Ks(t)?t.hiddenMatrix.premultiply(o):t.applyMatrix4(o),t.updateWorldMatrix(!1,!1),this.add(t),r!==void 0&&(this.children.pop(),this.children.splice(r,0,t)),this}copy(t,r=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),r===!0)for(let o=0;o<t.children.length;o++){let n=t.children[o];this.add(n.clone())}return this}toJSON(t){let r=t===void 0,o={object:{uuid:"",objectType:""}};t===void 0&&(t={geometries:{},materials:{},textures:{},images:{},interactionStates:{},nodes:{}},o.metadata={version:1.5,type:"Object",generator:"Object3D.toJSON"});let n={uuid:this.uuid,objectType:this.type};if(this.name!==""&&(n.name=this.name),n.matrix=this.matrix.toArray(),this.castShadow===!0&&(n.castShadow=!0),this.receiveShadow===!0&&(n.receiveShadow=!0),this.visible===!1&&(n.visible=!1),this.frustumCulled===!1&&(n.frustumCulled=!1),this.renderOrder!==0&&(n.renderOrder=this.renderOrder),n.layers=this.layers.mask,JSON.stringify(this.userData)!=="{}"&&(n.userData=this.userData),this.children.length>0){n.children=[];for(let s of this.children)(Ks(s)||s instanceof xS)&&n.children.push(s.toJSON(t).object)}if(r){let s=ui(t.geometries),a=ui(t.materials),l=ui(t.textures),c=ui(t.images),d=ui(t.interactionStates),p=Bh(t.nodes);s.length>0&&(o.geometries=s),a.length>0&&(o.materials=a),l.length>0&&(o.textures=l),c.length>0&&(o.images=c),d.length>0&&(o.interactionStates=d),p.length>0&&(o.nodes=p)}return o.object=n,o}fromJSON(t){return this.uuid=t.uuid,t.name!==void 0&&(this.name=t.name),t.matrix!==void 0?(this.matrix.fromArray(t.matrix),t.matrixAutoUpdate!==void 0&&(this.matrixAutoUpdate=t.matrixAutoUpdate),this.matrixAutoUpdate&&this.matrix.decompose(this.position,this.quaternion,this.scale)):(t.position!==void 0&&this.position.fromArray(t.position),t.rotation!==void 0&&this.rotation.fromArray(t.rotation),t.quaternion!==void 0&&this.quaternion.fromArray(t.quaternion),t.scale!==void 0&&this.scale.fromArray(t.scale)),this.castShadow=t.castShadow!==void 0,this.receiveShadow=t.receiveShadow!==void 0,t.visible!==void 0&&(this.visible=t.visible),t.frustumCulled!==void 0&&(this.frustumCulled=t.frustumCulled),t.renderOrder!==void 0&&(this.renderOrder=t.renderOrder),t.layers!==void 0&&(this.layers.mask=t.layers),t.userData!==void 0&&(this.userData=t.userData),this}};var er=i=>"isEntity"in i;var tr=i=>class extends ea(i){constructor(){super(...arguments);this.objectType="";this.isEntity=!0;this.raycastLock=!1;this.scaleLock=!1;this.hiddenMatrix=new _l;this._singleBBox=new Zs;this._recursiveBBox=new Zs;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this.forceComputeSize=!1}set visibility(t){this.visible=t;for(let r of this.children)er(r)&&r.traverseEntity(o=>{Er(o)&&o.visible&&(o.objectHelper.visible=t)})}get visibility(){return this.visible}get interactionCache(){var t,r,o;return((t=this.interaction)==null?void 0:t.cache)===void 0&&((r=this.interaction)==null||r.computeCache()),(o=this.interaction)==null?void 0:o.cache}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}resetBBoxNeedsUpdate(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0,this.traverseAncestors(t=>{er(t)&&(t.singleBBoxNeedsUpdate=!0,t.recursiveBBoxNeedsUpdate=!0)}),this.traverseEntity(t=>{t.singleBBoxNeedsUpdate=!0,t.recursiveBBoxNeedsUpdate=!0})}traverseEntity(t){t(this);for(let r of this.children)er(r)&&r.traverseEntity(t)}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 r of this.children)r.updateMatrixWorld(t)}updateWorldMatrix(t,r){let o=this.parent;if(t&&o!==null&&o.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)),r)for(let n of this.children)n.updateWorldMatrix(!1,!0)}shallowClone(t){return new this.constructor().shallowCopy(this,t)}shallowCopy(t,r=!0){if(super.copy(t,!1),this.raycastLock=t.raycastLock,this.scaleLock=t.scaleLock,this.hiddenMatrix.copy(t.hiddenMatrix),r===!0)for(let o of t.children)er(o)&&this.add(o.shallowClone());return this}clone(t){return new this.constructor().copy(this,t)}copy(t,r=!0){if(super.copy(t,!1),this.raycastLock=t.raycastLock,this.scaleLock=t.scaleLock,this.hiddenMatrix.copy(t.hiddenMatrix),r===!0)for(let o of t.children)er(o)&&this.add(o.clone());return this}keepChildrenMatrixWorld(){let t=new _l,r=this.matrixWorld.clone();this.updateWorldMatrix(!1,!1),t.copy(this.matrixWorld).invert(),t.multiply(r);for(let o of this.children)er(o)&&o.hiddenMatrix.premultiply(t)}toJSON(t){let r=super.toJSON(t),o=r.object;return this.raycastLock===!0&&(o.raycastLock=!0),this.scaleLock===!0&&(o.scaleLock=!0),o.hiddenMatrix=this.hiddenMatrix.toArray(),r}fromJSON(t){return super.fromJSON(t),t.raycastLock!==void 0&&(this.raycastLock=t.raycastLock),t.scaleLock!==void 0&&(this.scaleLock=t.scaleLock),this.hiddenMatrix.fromArray(t.hiddenMatrix),this}fromObject3D(t){let r=t.children;return t.children=[],Object.assign(t,{raycastLock:!1,scaleLock:!1,hiddenMatrix:new _l}),this.copy(t),t.children=r,this}toObjectTransformState(t=[]){this.updateWorldMatrix(!0,!1);let r={position:this.position.toArray(),rotation:[this.rotation.x,this.rotation.y,this.rotation.z],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return Zo(r,t)}fromObjectTransformState(t){return t.position&&this.position.fromArray(t.position),t.rotation&&this.rotation.fromArray(t.rotation),t.scale&&this.scale.fromArray(t.scale),t.hiddenMatrix&&this.hiddenMatrix.fromArray(t.hiddenMatrix),this.updateMatrix(),this}toState(t=[]){let r=O({name:this.name,visible:this.visible,raycastLock:this.raycastLock},this.toObjectTransformState(t));return Zo(r,t)}fromState(t,r){return t.name&&(this.name=t.name),t.raycastLock!==void 0&&(this.raycastLock=t.raycastLock),t.type!=="OrthographicCamera"&&t.type!=="PerspectiveCamera"&&(this.matrixAutoUpdate=!1),t.visible!==void 0&&(this.visibility=t.visible),this.fromObjectTransformState(t),this}};import{Object3D as bS,Vector3 as Ki,Euler as Gh,MathUtils as io}from"three";var ta=class extends bS{constructor(e,t={}){super();this.object=e;let r=e.recursiveBBox.getSize(new Ki),o=.1;this.parameters=rs.defaultData(r.toArray(),o),go(this.parameters,t),this.update(),this.setHideBase(this.parameters.hideBase)}refreshMaterial(){if("material"in this.object)for(let e of this.children)e.material=this.object.material}setHideBase(e){if("material"in this.object){if(Array.isArray(this.object.material)){if(this.children.length>0){for(let t of this.object.material)t.visible=!0;if(e){let t=this.object.material.map(r=>r.clone());for(let r of this.children)r.material=t}else for(let t of this.children)t.material=this.object.material}for(let t of this.object.material)t.visible=!e}else{if(this.children.length>0)if(this.object.material.visible=!0,e){let t=this.object.material.clone();for(let r of this.children)r.material=t}else for(let t of this.children)t.material=this.object.material;this.object.material.visible=!e}this.parameters.hideBase=e}}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)}this.children.forEach(e=>e.updateMatrix())}_updateCount(){let e=this.parameters.type==="grid"?this.parameters.grid.count[0]*this.parameters.grid.count[1]*this.parameters.grid.count[2]:this.parameters.count;if(this.children.length!==e)if(this.children.length<e)for(let t=0,r=e-this.children.length;t<r;++t){let o=this.object.shallowClone(!1);o.visible=!0,this.add(o),this.parameters.hideBase&&this.setHideBase(!0)}else for(let t=0,r=this.children.length-e;t<r;++t)this.remove(this.children[0])}_updateRadial(e){let t=e.radial,r=t.start*io.DEG2RAD,o=t.end*io.DEG2RAD,n=r-o,s=new Gh(t.rotation[0]*io.DEG2RAD,t.rotation[1]*io.DEG2RAD,t.rotation[2]*io.DEG2RAD),a;switch(t.axis){case"z":a=new Ki(0,0,1);break;case"y":a=new Ki(0,1,0);break;default:case"x":a=new Ki(1,0,0);break}for(let[l,c]of this.children.entries()){c.hiddenMatrix.identity(),c.scale.x=t.scale[0]+1,c.scale.y=t.scale[1]+1,c.scale.z=t.scale[2]+1,c.position.setScalar(0);let d=n/e.count*l-r;switch(t.axis){case"x":c.rotation.set(0,d,0);break;case"y":c.rotation.set(0,0,d);break;case"z":c.rotation.set(d,0,0);break}c.translateOnAxis(a,t.radius),c.position.x+=t.position[0],c.position.y+=t.position[1],c.position.z+=t.position[2],t.alignment===!0?(c.rotation.x+=s.x,c.rotation.y+=s.y,c.rotation.z+=s.z):c.rotation.copy(s)}}_updateLinear(e){if(e.type!=="linear")throw new Error;let t=e.linear,r=new Gh(t.rotation[0]*io.DEG2RAD,t.rotation[1]*io.DEG2RAD,t.rotation[2]*io.DEG2RAD);for(let[o,n]of this.children.entries())n.hiddenMatrix.identity(),n.scale.x=t.scale[0]*o+1,n.scale.y=t.scale[1]*o+1,n.scale.z=t.scale[2]*o+1,n.rotation.x=r.x*o,n.rotation.y=r.y*o,n.rotation.z=r.z*o,n.position.x=t.position[0]*o,n.position.y=t.position[1]*o,n.position.z=t.position[2]*o}_updateGrid(e){let t=0,r=e.grid;if(r.useCenter===!0){let o={x:r.count[0]%2==0?2:1,y:r.count[1]%2==0?2:1,z:r.count[2]%2==0?2:1},n=new Ki(r.size[0]*(r.count[0]-o.x)*.5,r.size[1]*(r.count[1]-o.y)*.5,r.size[2]*(r.count[2]-o.z)*.5);for(let s=0;s<r.count[0];s++)for(let a=0;a<r.count[1];a++)for(let l=0;l<r.count[2];l++){let c=this.children[t++];c.hiddenMatrix.identity(),c.scale.setScalar(1),c.rotation.set(0,0,0),c.position.x=r.size[0]*s-n.x,c.position.y=r.size[1]*a-n.y,c.position.z=r.size[2]*l-n.z}}else for(let o=0;o<r.count[0];o++)for(let n=0;n<r.count[1];n++)for(let s=0;s<r.count[2];s++){let a=this.children[t++];a.hiddenMatrix.identity(),a.scale.setScalar(1),a.rotation.set(0,0,0),a.position.x=r.size[0]*o,a.position.y=-r.size[1]*n,a.position.z=-r.size[2]*s}}fromJSON(e){return this}toJSON(){return{}}fromClonerState(e){return e.hideBase!==void 0&&this.setHideBase(e.hideBase),go(this.parameters,e),this.update(),this}};var yt=class extends tr(vS){constructor(e,t){super(e,t);this.isAbstractMesh=!0;Array.isArray(t)&&(this.selectedMaterial=0,e.groups.length===0&&e.addGroup(0,e.getAttribute("position").count,0))}get cloner(){return this._cloner}set cloner(e){this._cloner&&this.remove(this._cloner),e&&this.add(e),this._cloner=e}getSelectedMaterial(e){return Array.isArray(this.material)?(this.selectedMaterial===void 0&&(this.selectedMaterial=e!=null?e:0),this.material[e!=null?e:this.selectedMaterial]):this.material}setSelectedMaterial(e,t){Array.isArray(this.material)?(this.selectedMaterial===void 0&&(this.selectedMaterial=t!=null?t:0),t=t!=null?t:this.selectedMaterial,this.material[t].dispose(),this.material[t]=e):(this.material.dispose(),this.material=e)}updateGeometry(e){let t=this.geometry,r=Ml[t.userData.type],o=this.objectType==="NonParametric"?Object.assign({},t.userData,{geometry:t}):t.userData,n=r.build(r.normalizeInputs(e,o)),s=t.uuid;if(this.geometry.dispose(),this.geometry=n,this.geometry.uuid=s,this.geometry.computeBoundingSphere(),this.cloner)for(let a of this.cloner.children)a.geometry=this.geometry}resizeGeometry(e,t,r){$i.resizeGeometry(this.geometry,{width:e,height:t,depth:r})}shallowClone(e){return new this.constructor(this.geometry,this.material).shallowCopy(this,e)}clone(e){let t=this.objectType==="NonParametric"?Object.assign({},this.geometry.userData,{geometry:this.geometry.clone()}):this.geometry.userData,r=Ji(t),o=Array.isArray(this.material)?this.material.map(n=>n.clone()):this.material.clone();return new this.constructor(r,o).copy(this,e)}copy(e,t=!0){return super.copy(e,t),e.cloner&&(this.cloner=new ta(e,e.cloner.parameters),this.add(this.cloner)),this}toJSON(e){let t=super.toJSON(e),r=t.object;if(r.geometry=Dh(e.geometries,this.geometry,this.material),Array.isArray(this.material)){let o=[];for(let n=0,s=this.material.length;n<s;n++)o.push(jl(e.materials,this.material[n],e));r.material=o}else r.material=jl(e.materials,this.material,e);return t}fromJSON(e){return super.fromJSON(e),e.selectedMaterial!==void 0&&(this.selectedMaterial=e.selectedMaterial),this}setFromClonerState(e){e===null?this.cloner=void 0:(this.cloner===void 0&&(this.cloner=new ta(this)),this.cloner.fromClonerState(e))}fromState(e,t){var r,o;return super.fromState(e),e.type==="Mesh"&&(this.setFromClonerState(e.cloner),this.castShadow=(r=e.castShadow)!=null?r:!0,this.receiveShadow=(o=e.receiveShadow)!=null?o:!0),this}};import{NormalBlending as US,ShaderMaterial as kS,FrontSide as HS}from"three";import{CubeReflectionMapping as jS,CubeRefractionMapping as _S,CubeUVReflectionMapping as DS,CubeUVRefractionMapping as BS,LinearEncoding as Uh,sRGBEncoding as GS}from"three";var ra=class{constructor(e){e=e!=null?e:{},this.name=e.name,this.type=e.type,this.node=e.node,this.size=e.size,this.needsUpdate=e.needsUpdate}get value(){return this.node.value}set value(e){this.node.value=e}};import{MathUtils as SS}from"three";var pe=class{constructor(e){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=SS.generateUUID(),this.type=e,this.name="",this.userData={}}analyze(e,t){t=t!=null?t:{},e.analyzing=!0,this.build(e.addFlow(t.slot,t.cache,t.context),"v4"),e.clearVertexNodeCode(),e.clearFragmentNodeCode(),e.removeFlow(),e.analyzing=!1}analyzeAndFlow(e,t,r){return r=r!=null?r:{},this.analyze(e,r),this.flow(e,t,r)}flow(e,t,r){r=r!=null?r:{},e.addFlow(r.slot,r.cache,r.context);let o={result:this.build(e,t),code:e.clearNodeCode(),extra:e.context.extra};return e.removeFlow(),o}build(e,t,r){t=t!=null?t:this.getType(e,t);let o=e.getNodeData(r!=null?r:this);return e.analyzing&&this.appendDepsNode(e,o,t),e.nodes.indexOf(this)===-1&&e.nodes.push(this),this.updateFrame!==void 0&&e.updaters.indexOf(this)===-1&&e.updaters.push(this),this.generate(e,t,r)}updateFrame(e){}generateReadonly(e,t,r,o,n,s){return""}generate(e,t,r,o,n){return""}parse(e,t,r,o){}appendDepsNode(e,t,r){t.deps=(t.deps||0)+1;let o=e.getTypeLength(r);(o>(t.outputMax||0)||this.getType(e,r))&&(t.outputMax=o,t.output=r)}setName(e){this.name=e}getName(){return this.name}getType(e,t){return t==="sampler2D"||t==="samplerCube"?t:this.type}getJSONNode(e){if((e==null?void 0:e.materials)&&(e==null?void 0:e.materials[this.uuid])!==void 0)return e.materials[this.uuid]}getHash(){let e="{",t,r;for(t in this)r=this[t],r instanceof pe&&(e+='"'+t+'":'+r.getHash()+",");if(this.hashProperties)for(let o=0;o<this.hashProperties.length;o++)t=this.hashProperties[o],r=this[t],e+='"'+t+'":"'+String(r)+'",';return e+='"id":"'+this.uuid+'"}',e}copy(e){return this.name=e.name,e.type&&(this.type=e.type),e.frameId&&(this.frameId=e.frameId),e.hashProperties&&(this.hashProperties=e.hashProperties.map(t=>t)),this.userData=JSON.parse(JSON.stringify(e.userData)),this.shortcuts=JSON.parse(JSON.stringify(e.shortcuts)),this}clone(){return new this.constructor().copy(this)}createJSONNode(e){let t=e===void 0||typeof e=="string";if(typeof this.type!="string")throw new Error("Node does not allow serialization.");let r={};return r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),JSON.stringify(this.userData)!=="{}"&&(r.userData=this.userData),!t&&e&&(e.nodes[this.uuid]=r),r}toJSON(e){var t;return(t=this.getJSONNode(e))!=null?t:this.createJSONNode(e)}fromJSON(e,t){return this.uuid=e.uuid,this.type=e.type,e.name&&(this.name=e.name),e.userData&&(this.userData=e.userData),this}};var zh=class{constructor(){this.nodes={};this.keywords={}}add(e){this.nodes[e.name]=e}addKeyword(e,t,r){r=r!==void 0?r:!0,this.keywords[e]={callback:t,cache:r}}remove(e){delete this.nodes[e.name]}removeKeyword(e){delete this.keywords[e]}get(e){return this.nodes[e]}getKeyword(e,t){return this.keywords[e].callback(t)}getKeywordData(e){return this.keywords[e]}contains(e){return this.nodes[e]!==void 0}containsKeyword(e){return this.keywords[e]!==void 0}},lt=new zh;import{Vector2 as Eh}from"three";import{MathUtils as wS}from"three";var ue=class extends pe{constructor(e,t){super(e);this.scope="";t=t!=null?t:{},this.shared=t.shared!==void 0?t.shared:!0,this.unique=t.unique!==void 0?t.unique:!1}build(e,t,r,o){if(t=t!=null?t:this.getType(e),this.getShared(e,t)){let n=this.getUnique(e,t);n&&this.uuid===void 0&&(this.uuid=wS.generateUUID()),r=e.getUUID(r!=null?r:this.getUUID(),!n);let s=e.getNodeData(r),a=s.output||this.getType(e);if(e.analyzing)return(s.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,s,t),this.generate(e,t,r)):super.build(e,t,r);if(n)return s.name=s.name||super.build(e,t,r),s.name;if(!this.getLabel()&&(!this.getShared(e,a)||e.context.ignoreCache||s.deps===1))return super.build(e,t,r);r=this.getUUID(!1);let l=this.getTemp(e,r);if(l)return e.format(l,a,t);{l=super.generate(e,t,r,s.output,o);let c=this.generate(e,a,r);return e.addNodeCode(l+" = "+c+";"),e.format(l,a,t)}}return super.build(e,t,r)}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 r=e.getVars()[t];return r?r.name:void 0}generate(e,t,r,o,n){return this.getShared(e,t)||console.error("TempNode is not shared"),r=r!=null?r:this.uuid,e.getTempVar(r,o!=null?o:this.getType(e),n,this.getLabel()).name}};var Ue=class extends ue{constructor(e,t){t=t!=null?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}createJSONNode(e){let t=super.createJSONNode(e);return this.readonly===!0&&(t.readonly=this.readonly),t}fromJSON(e,t){return super.fromJSON(e,t),e.readonly!==void 0&&this.setReadonly(e.readonly),this}generate(e,t,r,o,n,s){r=e.getUUID(r!=null?r:this.getUUID()),o=o!=null?o:this.getType(e);let a=e.getNodeData(r);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,t,r,o,n,s):e.isShader("vertex")?(a.vertex||(a.vertex=e.createVertexUniform(o,this,n,s,this.getLabel())),e.format(a.vertex.name,o,t)):(a.fragment||(a.fragment=e.createFragmentUniform(o,this,n,s,this.getLabel())),e.format(a.fragment.name,o,t))}copy(e){return super.copy(e),this.readonly=e.readonly,this}};var It=class extends Ue{constructor(e=0,t){super("v2");this.nodeType="Vector2";this.value=e instanceof Eh?e:new Eh(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,r,o,n,s){return e.format("vec2("+this.value.x+", "+this.value.y+")",o,t)}copy(e){return super.copy(e),this.value.copy(e.value),this}};import{Vector3 as Fh}from"three";var Mt=class extends Ue{constructor(e=0,t,r){super("v3");this.nodeType="Vector3";this.value=e instanceof Fh?e:new Fh(e,t,r)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,t,r,o,n,s){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",o,t)}copy(e){return super.copy(e),this.value.copy(e.value),this}};var no=class extends Ue{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof Ht?e:new Ht(e.r,e.g,e.b,e.a)}generateReadonly(e,t,r,o,n,s){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",o,t)}copy(e){return super.copy(e),this.value.copy(e.value),this}};var NS=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,Rh=/[a-z_0-9]+/gi,re=class extends ue{constructor(e,t,r,o,n){super(n);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=n===void 0,this.isInterface=!1,this.parse(e,t,r,o)}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,r,o,n){let s,a=0,l=this.src;if(this.includes)for(let d=0;d<this.includes.length;d++)e.include(this.includes[d],this);for(let d in this.extensions)e.extensions[d]=!0;let c=[];for(;s=Rh.exec(this.src);)c.push(s);for(let d=0;d<c.length;d++){let p=c[d],u=p[0],f=this.isMethod?!this.getInputByName(u):!0,m=u;if(this.keywords[u]||this.useKeywords&&f&<.containsKeyword(u)){let x=this.keywords[u];if(!x){let y=lt.getKeywordData(u);y.cache&&(x=e.keywords[u]),x=x||lt.getKeyword(u,e),y.cache&&(e.keywords[u]=x)}m=x.build(e)}u!==m&&(l=l.substring(0,p.index+a)+m+l.substring(p.index+u.length+a),a+=m.length-u.length),this.getIncludeByName(m)===void 0&<.contains(m)&&e.include(lt.get(m))}return t==="source"?l:this.isMethod?(this.isInterface||e.include(this,void 0,l),this.name):e.format("( "+l+" )",this.getType(e),t)}parse(e,t,r,o){if(this.src=e||"",this.includes=t!=null?t:[],this.extensions=r!=null?r:{},this.keywords=o!=null?o:{},this.isMethod){let n=NS.exec(this.src);if(this.inputs=[],n&&n.length==4){this.type=n[1],this.name=n[2];let s=n[3].match(Rh);if(s){let a=0;for(;a<s.length;){let l=s[a++],c;l==="in"||l==="out"||l==="inout"?c=s[a++]:(c=l,l="");let d=s[a++];this.inputs.push({name:d,type:c,qualifier:l})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}copy(e){return super.copy(e),this.isMethod=e.isMethod,this.useKeywords=e.useKeywords,e.type!==void 0&&(this.type=e.type),this.parse(e.src,e.includes,e.extensions,e.keywords),this}toJSON(e){var r;let t=this.getJSONNode(e);if(!t){t=this.createJSONNode(e),t.src=this.src,t.isMethod=this.isMethod,t.useKeywords=this.useKeywords,this.isMethod||(t.type=this.type),t.extensions=JSON.parse(JSON.stringify(this.extensions));let o={};for(let n in this.keywords)o[n]=this.keywords[n].toJSON(e).uuid;if(t.keywords=o,(r=this.includes)==null?void 0:r.length){let n=[];for(let s=0;s<this.includes.length;s++)n.push(this.includes[s].toJSON(e).uuid);t.includes=n}t.isMethod=this.isMethod,t.inputs=this.inputs}return t.nodeType=this.nodeType,t}fromJSON(e,t){if(super.fromJSON(e,t),e.inputs!==void 0&&(this.inputs=e.inputs),e.isMethod!==void 0&&(this.isMethod=e.isMethod),e.src&&(this.src=e.src),e.isMethod&&(this.isMethod=e.isMethod),e.useKeywords&&(this.useKeywords=e.useKeywords),e.type&&(this.type=e.type),e.extensions&&(this.extensions=e.extensions),e.keywords&&t){this.keywords={};for(let r in e.keywords)this.keywords[r]=t.getNode(e.keywords[r])}return e.includes&&t&&(this.includes=e.includes.map(r=>t.getNode(r))),this}};var CS=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,Dl=class extends ue{constructor(e="",t){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||Dl.PI,void 0,void 0,void 0,t)}getType(e){return e.getTypeByFormat(this.type)}parse(e,t,r,o,n){this.src=e||"";let s,a,l="",c=CS.exec(e);this.useDefine=n!=null?n:this.src.charAt(0)==="#",c&&c.length>1?(a=c[1],s=c[2],l=c[3]):(s=this.src,a="f"),this.name=s,this.type=a,this.value=l}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,r,o,n){return e.format(this.name,this.getType(e),t)}copy(e){return super.copy(e),this.parse(e.src,void 0,void 0,void 0,e.useDefine),this}},Ie=Dl;Ie.PI="PI",Ie.PI2="PI2",Ie.RECIPROCAL_PI="RECIPROCAL_PI",Ie.RECIPROCAL_PI2="RECIPROCAL_PI2",Ie.LOG2="LOG2",Ie.EPSILON="EPSILON";var LS=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
|
|
1
|
+
var zm=Object.create;var Ti=Object.defineProperty,Em=Object.defineProperties,Fm=Object.getOwnPropertyDescriptor,Rm=Object.getOwnPropertyDescriptors,Vm=Object.getOwnPropertyNames,gc=Object.getOwnPropertySymbols,Um=Object.getPrototypeOf,xc=Object.prototype.hasOwnProperty,km=Object.prototype.propertyIsEnumerable;var bc=(i,e,t)=>e in i?Ti(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,O=(i,e)=>{for(var t in e||(e={}))xc.call(e,t)&&bc(i,t,e[t]);if(gc)for(var t of gc(e))km.call(e,t)&&bc(i,t,e[t]);return i},$=(i,e)=>Em(i,Rm(e)),vc=i=>Ti(i,"__esModule",{value:!0});var Sc=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports),Hm=(i,e)=>{vc(i);for(var t in e)Ti(i,t,{get:e[t],enumerable:!0})},qm=(i,e,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Vm(e))!xc.call(i,r)&&r!=="default"&&Ti(i,r,{get:()=>e[r],enumerable:!(t=Fm(e,r))||t.enumerable});return i},wc=i=>qm(vc(Ti(i!=null?zm(Um(i)):{},"default",i&&i.__esModule&&"default"in i?{get:()=>i.default,enumerable:!0}:{value:i,enumerable:!0})),i);var Oh=Sc(Qs=>{"use strict";Qs.byteLength=aS;Qs.toByteArray=cS;Qs.fromByteArray=uS;var Sr=[],Yt=[],sS=typeof Uint8Array!="undefined"?Uint8Array:Array,Al="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Co=0,Mh=Al.length;Co<Mh;++Co)Sr[Co]=Al[Co],Yt[Al.charCodeAt(Co)]=Co;var Co,Mh;Yt["-".charCodeAt(0)]=62;Yt["_".charCodeAt(0)]=63;function Ph(i){var e=i.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=i.indexOf("=");t===-1&&(t=e);var r=t===e?0:4-t%4;return[t,r]}function aS(i){var e=Ph(i),t=e[0],r=e[1];return(t+r)*3/4-r}function lS(i,e,t){return(e+t)*3/4-t}function cS(i){var e,t=Ph(i),r=t[0],o=t[1],n=new sS(lS(i,r,o)),s=0,a=o>0?r-4:r,l;for(l=0;l<a;l+=4)e=Yt[i.charCodeAt(l)]<<18|Yt[i.charCodeAt(l+1)]<<12|Yt[i.charCodeAt(l+2)]<<6|Yt[i.charCodeAt(l+3)],n[s++]=e>>16&255,n[s++]=e>>8&255,n[s++]=e&255;return o===2&&(e=Yt[i.charCodeAt(l)]<<2|Yt[i.charCodeAt(l+1)]>>4,n[s++]=e&255),o===1&&(e=Yt[i.charCodeAt(l)]<<10|Yt[i.charCodeAt(l+1)]<<4|Yt[i.charCodeAt(l+2)]>>2,n[s++]=e>>8&255,n[s++]=e&255),n}function dS(i){return Sr[i>>18&63]+Sr[i>>12&63]+Sr[i>>6&63]+Sr[i&63]}function pS(i,e,t){for(var r,o=[],n=e;n<t;n+=3)r=(i[n]<<16&16711680)+(i[n+1]<<8&65280)+(i[n+2]&255),o.push(dS(r));return o.join("")}function uS(i){for(var e,t=i.length,r=t%3,o=[],n=16383,s=0,a=t-r;s<a;s+=n)o.push(pS(i,s,s+n>a?a:s+n));return r===1?(e=i[t-1],o.push(Sr[e>>2]+Sr[e<<4&63]+"==")):r===2&&(e=(i[t-2]<<8)+i[t-1],o.push(Sr[e>>10]+Sr[e>>4&63]+Sr[e<<2&63]+"=")),o.join("")}});var Sm=Sc((Ia,vm)=>{(function(i,e){typeof Ia=="object"&&typeof vm!="undefined"?e(Ia):typeof define=="function"&&define.amd?define(["exports"],e):e((i=typeof globalThis!="undefined"?globalThis:i||self).SVDJS={})})(Ia,function(i){"use strict";i.SVD=function(e,t,r,o,n){if(t=t===void 0||t,r=r===void 0||r,n=1e-64/(o=o||Math.pow(2,-52)),!e)throw new TypeError("Matrix a is not defined");var s,a,l,c,d,u,p,f,m,x,y,N,L=e[0].length,w=e.length;if(w<L)throw new TypeError("Invalid matrix: m < n");for(var B=[],S=[],_=[],T=t==="f"?w:L,h=x=p=0;h<w;h++)S[h]=new Array(T).fill(0);for(h=0;h<L;h++)_[h]=new Array(L).fill(0);var I,b=new Array(L).fill(0);for(h=0;h<w;h++)for(s=0;s<L;s++)S[h][s]=e[h][s];for(h=0;h<L;h++){for(B[h]=p,m=0,l=h+1,s=h;s<w;s++)m+=Math.pow(S[s][h],2);if(m<n)p=0;else for(f=(u=S[h][h])*(p=u<0?Math.sqrt(m):-Math.sqrt(m))-m,S[h][h]=u-p,s=l;s<L;s++){for(m=0,a=h;a<w;a++)m+=S[a][h]*S[a][s];for(u=m/f,a=h;a<w;a++)S[a][s]=S[a][s]+u*S[a][h]}for(b[h]=p,m=0,s=l;s<L;s++)m+=Math.pow(S[h][s],2);if(m<n)p=0;else{for(f=(u=S[h][h+1])*(p=u<0?Math.sqrt(m):-Math.sqrt(m))-m,S[h][h+1]=u-p,s=l;s<L;s++)B[s]=S[h][s]/f;for(s=l;s<w;s++){for(m=0,a=l;a<L;a++)m+=S[s][a]*S[h][a];for(a=l;a<L;a++)S[s][a]=S[s][a]+m*B[a]}}x<(y=Math.abs(b[h])+Math.abs(B[h]))&&(x=y)}if(r)for(h=L-1;0<=h;h--){if(p!==0){for(f=S[h][h+1]*p,s=l;s<L;s++)_[s][h]=S[h][s]/f;for(s=l;s<L;s++){for(m=0,a=l;a<L;a++)m+=S[h][a]*_[a][s];for(a=l;a<L;a++)_[a][s]=_[a][s]+m*_[a][h]}}for(s=l;s<L;s++)_[h][s]=0,_[s][h]=0;_[h][h]=1,p=B[h],l=h}if(t){if(t==="f")for(h=L;h<w;h++){for(s=L;s<w;s++)S[h][s]=0;S[h][h]=1}for(h=L-1;0<=h;h--){for(l=h+1,p=b[h],s=l;s<T;s++)S[h][s]=0;if(p!==0){for(f=S[h][h]*p,s=l;s<T;s++){for(m=0,a=l;a<w;a++)m+=S[a][h]*S[a][s];for(u=m/f,a=h;a<w;a++)S[a][s]=S[a][s]+u*S[a][h]}for(s=h;s<w;s++)S[s][h]=S[s][h]/p}else for(s=h;s<w;s++)S[s][h]=0;S[h][h]=S[h][h]+1}}for(o*=x,a=L-1;0<=a;a--)for(var P=0;P<50;P++){for(I=!1,l=a;0<=l;l--){if(Math.abs(B[l])<=o){I=!0;break}if(Math.abs(b[l-1])<=o)break}if(!I){for(d=0,c=l-(m=1),h=l;h<a+1&&(u=m*B[h],B[h]=d*B[h],!(Math.abs(u)<=o));h++)if(p=b[h],b[h]=Math.sqrt(u*u+p*p),d=p/(f=b[h]),m=-u/f,t)for(s=0;s<w;s++)y=S[s][c],N=S[s][h],S[s][c]=y*d+N*m,S[s][h]=-y*m+N*d}if(N=b[a],l===a){if(N<0&&(b[a]=-N,r))for(s=0;s<L;s++)_[s][a]=-_[s][a];break}for(x=b[l],u=(((y=b[a-1])-N)*(y+N)+((p=B[a-1])-(f=B[a]))*(p+f))/(2*f*y),p=Math.sqrt(u*u+1),u=((x-N)*(x+N)+f*(y/(u<0?u-p:u+p)-f))/x,h=l+(m=d=1);h<a+1;h++){if(p=B[h],y=b[h],f=m*p,p*=d,N=Math.sqrt(u*u+f*f),u=x*(d=u/(B[h-1]=N))+p*(m=f/N),p=-x*m+p*d,f=y*m,y*=d,r)for(s=0;s<L;s++)x=_[s][h-1],N=_[s][h],_[s][h-1]=x*d+N*m,_[s][h]=-x*m+N*d;if(N=Math.sqrt(u*u+f*f),u=(d=u/(b[h-1]=N))*p+(m=f/N)*y,x=-m*p+d*y,t)for(s=0;s<w;s++)y=S[s][h-1],N=S[s][h],S[s][h-1]=y*d+N*m,S[s][h]=-y*m+N*d}B[l]=0,B[a]=u,b[a]=x}for(h=0;h<L;h++)b[h]<o&&(b[h]=0);return{u:S,q:b,v:_}},i.VERSION="1.1.1",Object.defineProperty(i,"__esModule",{value:!0})})});import{FileLoader as h1,Loader as m1}from"three";function Nc(i){return Array.isArray(i)?i:[i]}var Wm=typeof global=="object"&&global&&global.Object===Object&&global,Tn=Wm;var $m=typeof self=="object"&&self&&self.Object===Object&&self,Jm=Tn||$m||Function("return this")(),et=Jm;var Km=et.Symbol,Ct=Km;var Cc=Object.prototype,Xm=Cc.hasOwnProperty,Zm=Cc.toString,Ii=Ct?Ct.toStringTag:void 0;function Qm(i){var e=Xm.call(i,Ii),t=i[Ii];try{i[Ii]=void 0;var r=!0}catch(n){}var o=Zm.call(i);return r&&(e?i[Ii]=t:delete i[Ii]),o}var Lc=Qm;var Ym=Object.prototype,ef=Ym.toString;function tf(i){return ef.call(i)}var Tc=tf;var rf="[object Null]",of="[object Undefined]",Ic=Ct?Ct.toStringTag:void 0;function nf(i){return i==null?i===void 0?of:rf:Ic&&Ic in Object(i)?Lc(i):Tc(i)}var Ft=nf;function sf(i){return i!=null&&typeof i=="object"}var vt=sf;var af="[object Symbol]";function lf(i){return typeof i=="symbol"||vt(i)&&Ft(i)==af}var _o=lf;function cf(i,e){for(var t=-1,r=i==null?0:i.length,o=Array(r);++t<r;)o[t]=e(i[t],t,i);return o}var In=cf;var df=Array.isArray,ht=df;var pf=1/0,Mc=Ct?Ct.prototype:void 0,Pc=Mc?Mc.toString:void 0;function Oc(i){if(typeof i=="string")return i;if(ht(i))return In(i,Oc)+"";if(_o(i))return Pc?Pc.call(i):"";var e=i+"";return e=="0"&&1/i==-pf?"-0":e}var Ac=Oc;function uf(i){var e=typeof i;return i!=null&&(e=="object"||e=="function")}var St=uf;function hf(i){return i}var Mn=hf;var mf="[object AsyncFunction]",ff="[object Function]",yf="[object GeneratorFunction]",gf="[object Proxy]";function xf(i){if(!St(i))return!1;var e=Ft(i);return e==ff||e==yf||e==mf||e==gf}var Do=xf;var bf=et["__core-js_shared__"],Pn=bf;var jc=function(){var i=/[^.]+$/.exec(Pn&&Pn.keys&&Pn.keys.IE_PROTO||"");return i?"Symbol(src)_1."+i:""}();function vf(i){return!!jc&&jc in i}var _c=vf;var Sf=Function.prototype,wf=Sf.toString;function Nf(i){if(i!=null){try{return wf.call(i)}catch(e){}try{return i+""}catch(e){}}return""}var Pr=Nf;var Cf=/[\\^$.*+?()[\]{}|]/g,Lf=/^\[object .+?Constructor\]$/,Tf=Function.prototype,If=Object.prototype,Mf=Tf.toString,Pf=If.hasOwnProperty,Of=RegExp("^"+Mf.call(Pf).replace(Cf,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Af(i){if(!St(i)||_c(i))return!1;var e=Do(i)?Of:Lf;return e.test(Pr(i))}var Dc=Af;function jf(i,e){return i==null?void 0:i[e]}var Bc=jf;function _f(i,e){var t=Bc(i,e);return Dc(t)?t:void 0}var Ot=_f;var Df=Ot(et,"WeakMap"),On=Df;var Gc=Object.create,Bf=function(){function i(){}return function(e){if(!St(e))return{};if(Gc)return Gc(e);i.prototype=e;var t=new i;return i.prototype=void 0,t}}(),zc=Bf;function Gf(i,e,t){switch(t.length){case 0:return i.call(e);case 1:return i.call(e,t[0]);case 2:return i.call(e,t[0],t[1]);case 3:return i.call(e,t[0],t[1],t[2])}return i.apply(e,t)}var Ec=Gf;function zf(i,e){var t=-1,r=i.length;for(e||(e=Array(r));++t<r;)e[t]=i[t];return e}var An=zf;var Ef=800,Ff=16,Rf=Date.now;function Vf(i){var e=0,t=0;return function(){var r=Rf(),o=Ff-(r-t);if(t=r,o>0){if(++e>=Ef)return arguments[0]}else e=0;return i.apply(void 0,arguments)}}var Fc=Vf;function Uf(i){return function(){return i}}var Rc=Uf;var kf=function(){try{var i=Ot(Object,"defineProperty");return i({},"",{}),i}catch(e){}}(),Bo=kf;var Hf=Bo?function(i,e){return Bo(i,"toString",{configurable:!0,enumerable:!1,value:Rc(e),writable:!0})}:Mn,Vc=Hf;var qf=Fc(Vc),jn=qf;function Wf(i,e){for(var t=-1,r=i==null?0:i.length;++t<r&&e(i[t],t,i)!==!1;);return i}var Uc=Wf;var $f=9007199254740991,Jf=/^(?:0|[1-9]\d*)$/;function Kf(i,e){var t=typeof i;return e=e==null?$f:e,!!e&&(t=="number"||t!="symbol"&&Jf.test(i))&&i>-1&&i%1==0&&i<e}var _n=Kf;function Xf(i,e,t){e=="__proto__"&&Bo?Bo(i,e,{configurable:!0,enumerable:!0,value:t,writable:!0}):i[e]=t}var Go=Xf;function Zf(i,e){return i===e||i!==i&&e!==e}var qr=Zf;var Qf=Object.prototype,Yf=Qf.hasOwnProperty;function ey(i,e,t){var r=i[e];(!(Yf.call(i,e)&&qr(r,t))||t===void 0&&!(e in i))&&Go(i,e,t)}var Dn=ey;function ty(i,e,t,r){var o=!t;t||(t={});for(var n=-1,s=e.length;++n<s;){var a=e[n],l=r?r(t[a],i[a],a,t,i):void 0;l===void 0&&(l=i[a]),o?Go(t,a,l):Dn(t,a,l)}return t}var Kt=ty;var kc=Math.max;function ry(i,e,t){return e=kc(e===void 0?i.length-1:e,0),function(){for(var r=arguments,o=-1,n=kc(r.length-e,0),s=Array(n);++o<n;)s[o]=r[e+o];o=-1;for(var a=Array(e+1);++o<e;)a[o]=r[o];return a[e]=t(s),Ec(i,this,a)}}var Bn=ry;function oy(i,e){return jn(Bn(i,e,Mn),i+"")}var Hc=oy;var iy=9007199254740991;function ny(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=iy}var Gn=ny;function sy(i){return i!=null&&Gn(i.length)&&!Do(i)}var Wr=sy;function ay(i,e,t){if(!St(t))return!1;var r=typeof e;return(r=="number"?Wr(t)&&_n(e,t.length):r=="string"&&e in t)?qr(t[e],i):!1}var qc=ay;function ly(i){return Hc(function(e,t){var r=-1,o=t.length,n=o>1?t[o-1]:void 0,s=o>2?t[2]:void 0;for(n=i.length>3&&typeof n=="function"?(o--,n):void 0,s&&qc(t[0],t[1],s)&&(n=o<3?void 0:n,o=1),e=Object(e);++r<o;){var a=t[r];a&&i(e,a,r,n)}return e})}var Wc=ly;var cy=Object.prototype;function dy(i){var e=i&&i.constructor,t=typeof e=="function"&&e.prototype||cy;return i===t}var zo=dy;function py(i,e){for(var t=-1,r=Array(i);++t<i;)r[t]=e(t);return r}var $c=py;var uy="[object Arguments]";function hy(i){return vt(i)&&Ft(i)==uy}var Pa=hy;var Jc=Object.prototype,my=Jc.hasOwnProperty,fy=Jc.propertyIsEnumerable,yy=Pa(function(){return arguments}())?Pa:function(i){return vt(i)&&my.call(i,"callee")&&!fy.call(i,"callee")},mo=yy;function gy(){return!1}var Kc=gy;var Xc=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Zc=Xc&&typeof module=="object"&&module&&!module.nodeType&&module,xy=Zc&&Zc.exports===Xc,Qc=xy?et.Buffer:void 0,by=Qc?Qc.isBuffer:void 0,vy=by||Kc,Eo=vy;var Sy="[object Arguments]",wy="[object Array]",Ny="[object Boolean]",Cy="[object Date]",Ly="[object Error]",Ty="[object Function]",Iy="[object Map]",My="[object Number]",Py="[object Object]",Oy="[object RegExp]",Ay="[object Set]",jy="[object String]",_y="[object WeakMap]",Dy="[object ArrayBuffer]",By="[object DataView]",Gy="[object Float32Array]",zy="[object Float64Array]",Ey="[object Int8Array]",Fy="[object Int16Array]",Ry="[object Int32Array]",Vy="[object Uint8Array]",Uy="[object Uint8ClampedArray]",ky="[object Uint16Array]",Hy="[object Uint32Array]",Ve={};Ve[Gy]=Ve[zy]=Ve[Ey]=Ve[Fy]=Ve[Ry]=Ve[Vy]=Ve[Uy]=Ve[ky]=Ve[Hy]=!0;Ve[Sy]=Ve[wy]=Ve[Dy]=Ve[Ny]=Ve[By]=Ve[Cy]=Ve[Ly]=Ve[Ty]=Ve[Iy]=Ve[My]=Ve[Py]=Ve[Oy]=Ve[Ay]=Ve[jy]=Ve[_y]=!1;function qy(i){return vt(i)&&Gn(i.length)&&!!Ve[Ft(i)]}var Yc=qy;function Wy(i){return function(e){return i(e)}}var Fo=Wy;var ed=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Mi=ed&&typeof module=="object"&&module&&!module.nodeType&&module,$y=Mi&&Mi.exports===ed,Oa=$y&&Tn.process,Jy=function(){try{var i=Mi&&Mi.require&&Mi.require("util").types;return i||Oa&&Oa.binding&&Oa.binding("util")}catch(e){}}(),Or=Jy;var td=Or&&Or.isTypedArray,Ky=td?Fo(td):Yc,zn=Ky;var Xy=Object.prototype,Zy=Xy.hasOwnProperty;function Qy(i,e){var t=ht(i),r=!t&&mo(i),o=!t&&!r&&Eo(i),n=!t&&!r&&!o&&zn(i),s=t||r||o||n,a=s?$c(i.length,String):[],l=a.length;for(var c in i)(e||Zy.call(i,c))&&!(s&&(c=="length"||o&&(c=="offset"||c=="parent")||n&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||_n(c,l)))&&a.push(c);return a}var En=Qy;function Yy(i,e){return function(t){return i(e(t))}}var Fn=Yy;var eg=Fn(Object.keys,Object),rd=eg;var tg=Object.prototype,rg=tg.hasOwnProperty;function og(i){if(!zo(i))return rd(i);var e=[];for(var t in Object(i))rg.call(i,t)&&t!="constructor"&&e.push(t);return e}var od=og;function ig(i){return Wr(i)?En(i):od(i)}var Ro=ig;function ng(i){var e=[];if(i!=null)for(var t in Object(i))e.push(t);return e}var id=ng;var sg=Object.prototype,ag=sg.hasOwnProperty;function lg(i){if(!St(i))return id(i);var e=zo(i),t=[];for(var r in i)r=="constructor"&&(e||!ag.call(i,r))||t.push(r);return t}var nd=lg;function cg(i){return Wr(i)?En(i,!0):nd(i)}var hr=cg;var dg=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,pg=/^\w*$/;function ug(i,e){if(ht(i))return!1;var t=typeof i;return t=="number"||t=="symbol"||t=="boolean"||i==null||_o(i)?!0:pg.test(i)||!dg.test(i)||e!=null&&i in Object(e)}var sd=ug;var hg=Ot(Object,"create"),Ar=hg;function mg(){this.__data__=Ar?Ar(null):{},this.size=0}var ad=mg;function fg(i){var e=this.has(i)&&delete this.__data__[i];return this.size-=e?1:0,e}var ld=fg;var yg="__lodash_hash_undefined__",gg=Object.prototype,xg=gg.hasOwnProperty;function bg(i){var e=this.__data__;if(Ar){var t=e[i];return t===yg?void 0:t}return xg.call(e,i)?e[i]:void 0}var cd=bg;var vg=Object.prototype,Sg=vg.hasOwnProperty;function wg(i){var e=this.__data__;return Ar?e[i]!==void 0:Sg.call(e,i)}var dd=wg;var Ng="__lodash_hash_undefined__";function Cg(i,e){var t=this.__data__;return this.size+=this.has(i)?0:1,t[i]=Ar&&e===void 0?Ng:e,this}var pd=Cg;function Vo(i){var e=-1,t=i==null?0:i.length;for(this.clear();++e<t;){var r=i[e];this.set(r[0],r[1])}}Vo.prototype.clear=ad;Vo.prototype.delete=ld;Vo.prototype.get=cd;Vo.prototype.has=dd;Vo.prototype.set=pd;var Aa=Vo;function Lg(){this.__data__=[],this.size=0}var ud=Lg;function Tg(i,e){for(var t=i.length;t--;)if(qr(i[t][0],e))return t;return-1}var $r=Tg;var Ig=Array.prototype,Mg=Ig.splice;function Pg(i){var e=this.__data__,t=$r(e,i);if(t<0)return!1;var r=e.length-1;return t==r?e.pop():Mg.call(e,t,1),--this.size,!0}var hd=Pg;function Og(i){var e=this.__data__,t=$r(e,i);return t<0?void 0:e[t][1]}var md=Og;function Ag(i){return $r(this.__data__,i)>-1}var fd=Ag;function jg(i,e){var t=this.__data__,r=$r(t,i);return r<0?(++this.size,t.push([i,e])):t[r][1]=e,this}var yd=jg;function Uo(i){var e=-1,t=i==null?0:i.length;for(this.clear();++e<t;){var r=i[e];this.set(r[0],r[1])}}Uo.prototype.clear=ud;Uo.prototype.delete=hd;Uo.prototype.get=md;Uo.prototype.has=fd;Uo.prototype.set=yd;var Jr=Uo;var _g=Ot(et,"Map"),Kr=_g;function Dg(){this.size=0,this.__data__={hash:new Aa,map:new(Kr||Jr),string:new Aa}}var gd=Dg;function Bg(i){var e=typeof i;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?i!=="__proto__":i===null}var xd=Bg;function Gg(i,e){var t=i.__data__;return xd(e)?t[typeof e=="string"?"string":"hash"]:t.map}var Xr=Gg;function zg(i){var e=Xr(this,i).delete(i);return this.size-=e?1:0,e}var bd=zg;function Eg(i){return Xr(this,i).get(i)}var vd=Eg;function Fg(i){return Xr(this,i).has(i)}var Sd=Fg;function Rg(i,e){var t=Xr(this,i),r=t.size;return t.set(i,e),this.size+=t.size==r?0:1,this}var wd=Rg;function ko(i){var e=-1,t=i==null?0:i.length;for(this.clear();++e<t;){var r=i[e];this.set(r[0],r[1])}}ko.prototype.clear=gd;ko.prototype.delete=bd;ko.prototype.get=vd;ko.prototype.has=Sd;ko.prototype.set=wd;var Pi=ko;var Vg="Expected a function";function ja(i,e){if(typeof i!="function"||e!=null&&typeof e!="function")throw new TypeError(Vg);var t=function(){var r=arguments,o=e?e.apply(this,r):r[0],n=t.cache;if(n.has(o))return n.get(o);var s=i.apply(this,r);return t.cache=n.set(o,s)||n,s};return t.cache=new(ja.Cache||Pi),t}ja.Cache=Pi;var Nd=ja;var Ug=500;function kg(i){var e=Nd(i,function(r){return t.size===Ug&&t.clear(),r}),t=e.cache;return e}var Cd=kg;var Hg=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,qg=/\\(\\)?/g,Wg=Cd(function(i){var e=[];return i.charCodeAt(0)===46&&e.push(""),i.replace(Hg,function(t,r,o,n){e.push(o?n.replace(qg,"$1"):r||t)}),e}),Ld=Wg;function $g(i){return i==null?"":Ac(i)}var Td=$g;function Jg(i,e){return ht(i)?i:sd(i,e)?[i]:Ld(Td(i))}var Ho=Jg;var Kg=1/0;function Xg(i){if(typeof i=="string"||_o(i))return i;var e=i+"";return e=="0"&&1/i==-Kg?"-0":e}var Rn=Xg;function Zg(i,e){e=Ho(e,i);for(var t=0,r=e.length;i!=null&&t<r;)i=i[Rn(e[t++])];return t&&t==r?i:void 0}var Id=Zg;function Qg(i,e){for(var t=-1,r=e.length,o=i.length;++t<r;)i[o+t]=e[t];return i}var qo=Qg;var Md=Ct?Ct.isConcatSpreadable:void 0;function Yg(i){return ht(i)||mo(i)||!!(Md&&i&&i[Md])}var Pd=Yg;function Od(i,e,t,r,o){var n=-1,s=i.length;for(t||(t=Pd),o||(o=[]);++n<s;){var a=i[n];e>0&&t(a)?e>1?Od(a,e-1,t,r,o):qo(o,a):r||(o[o.length]=a)}return o}var Ad=Od;function ex(i){var e=i==null?0:i.length;return e?Ad(i,1):[]}var jd=ex;function tx(i){return jn(Bn(i,void 0,jd),i+"")}var _d=tx;var rx=Fn(Object.getPrototypeOf,Object),Wo=rx;var ox="[object Object]",ix=Function.prototype,nx=Object.prototype,Dd=ix.toString,sx=nx.hasOwnProperty,ax=Dd.call(Object);function lx(i){if(!vt(i)||Ft(i)!=ox)return!1;var e=Wo(i);if(e===null)return!0;var t=sx.call(e,"constructor")&&e.constructor;return typeof t=="function"&&t instanceof t&&Dd.call(t)==ax}var Vn=lx;function cx(i,e,t){var r=-1,o=i.length;e<0&&(e=-e>o?0:o+e),t=t>o?o:t,t<0&&(t+=o),o=e>t?0:t-e>>>0,e>>>=0;for(var n=Array(o);++r<o;)n[r]=i[r+e];return n}var Bd=cx;function dx(){this.__data__=new Jr,this.size=0}var Gd=dx;function px(i){var e=this.__data__,t=e.delete(i);return this.size=e.size,t}var zd=px;function ux(i){return this.__data__.get(i)}var Ed=ux;function hx(i){return this.__data__.has(i)}var Fd=hx;var mx=200;function fx(i,e){var t=this.__data__;if(t instanceof Jr){var r=t.__data__;if(!Kr||r.length<mx-1)return r.push([i,e]),this.size=++t.size,this;t=this.__data__=new Pi(r)}return t.set(i,e),this.size=t.size,this}var Rd=fx;function $o(i){var e=this.__data__=new Jr(i);this.size=e.size}$o.prototype.clear=Gd;$o.prototype.delete=zd;$o.prototype.get=Ed;$o.prototype.has=Fd;$o.prototype.set=Rd;var Un=$o;function yx(i,e){return i&&Kt(e,Ro(e),i)}var Vd=yx;function gx(i,e){return i&&Kt(e,hr(e),i)}var Ud=gx;var kd=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Hd=kd&&typeof module=="object"&&module&&!module.nodeType&&module,xx=Hd&&Hd.exports===kd,qd=xx?et.Buffer:void 0,Wd=qd?qd.allocUnsafe:void 0;function bx(i,e){if(e)return i.slice();var t=i.length,r=Wd?Wd(t):new i.constructor(t);return i.copy(r),r}var kn=bx;function vx(i,e){for(var t=-1,r=i==null?0:i.length,o=0,n=[];++t<r;){var s=i[t];e(s,t,i)&&(n[o++]=s)}return n}var $d=vx;function Sx(){return[]}var Hn=Sx;var wx=Object.prototype,Nx=wx.propertyIsEnumerable,Jd=Object.getOwnPropertySymbols,Cx=Jd?function(i){return i==null?[]:(i=Object(i),$d(Jd(i),function(e){return Nx.call(i,e)}))}:Hn,Jo=Cx;function Lx(i,e){return Kt(i,Jo(i),e)}var Kd=Lx;var Tx=Object.getOwnPropertySymbols,Ix=Tx?function(i){for(var e=[];i;)qo(e,Jo(i)),i=Wo(i);return e}:Hn,qn=Ix;function Mx(i,e){return Kt(i,qn(i),e)}var Xd=Mx;function Px(i,e,t){var r=e(i);return ht(i)?r:qo(r,t(i))}var Wn=Px;function Ox(i){return Wn(i,Ro,Jo)}var Zd=Ox;function Ax(i){return Wn(i,hr,qn)}var $n=Ax;var jx=Ot(et,"DataView"),Jn=jx;var _x=Ot(et,"Promise"),Kn=_x;var Dx=Ot(et,"Set"),Xn=Dx;var Qd="[object Map]",Bx="[object Object]",Yd="[object Promise]",ep="[object Set]",tp="[object WeakMap]",rp="[object DataView]",Gx=Pr(Jn),zx=Pr(Kr),Ex=Pr(Kn),Fx=Pr(Xn),Rx=Pr(On),fo=Ft;(Jn&&fo(new Jn(new ArrayBuffer(1)))!=rp||Kr&&fo(new Kr)!=Qd||Kn&&fo(Kn.resolve())!=Yd||Xn&&fo(new Xn)!=ep||On&&fo(new On)!=tp)&&(fo=function(i){var e=Ft(i),t=e==Bx?i.constructor:void 0,r=t?Pr(t):"";if(r)switch(r){case Gx:return rp;case zx:return Qd;case Ex:return Yd;case Fx:return ep;case Rx:return tp}return e});var Ko=fo;var Vx=Object.prototype,Ux=Vx.hasOwnProperty;function kx(i){var e=i.length,t=new i.constructor(e);return e&&typeof i[0]=="string"&&Ux.call(i,"index")&&(t.index=i.index,t.input=i.input),t}var op=kx;var Hx=et.Uint8Array,_a=Hx;function qx(i){var e=new i.constructor(i.byteLength);return new _a(e).set(new _a(i)),e}var Xo=qx;function Wx(i,e){var t=e?Xo(i.buffer):i.buffer;return new i.constructor(t,i.byteOffset,i.byteLength)}var ip=Wx;var $x=/\w*$/;function Jx(i){var e=new i.constructor(i.source,$x.exec(i));return e.lastIndex=i.lastIndex,e}var np=Jx;var sp=Ct?Ct.prototype:void 0,ap=sp?sp.valueOf:void 0;function Kx(i){return ap?Object(ap.call(i)):{}}var lp=Kx;function Xx(i,e){var t=e?Xo(i.buffer):i.buffer;return new i.constructor(t,i.byteOffset,i.length)}var Zn=Xx;var Zx="[object Boolean]",Qx="[object Date]",Yx="[object Map]",e0="[object Number]",t0="[object RegExp]",r0="[object Set]",o0="[object String]",i0="[object Symbol]",n0="[object ArrayBuffer]",s0="[object DataView]",a0="[object Float32Array]",l0="[object Float64Array]",c0="[object Int8Array]",d0="[object Int16Array]",p0="[object Int32Array]",u0="[object Uint8Array]",h0="[object Uint8ClampedArray]",m0="[object Uint16Array]",f0="[object Uint32Array]";function y0(i,e,t){var r=i.constructor;switch(e){case n0:return Xo(i);case Zx:case Qx:return new r(+i);case s0:return ip(i,t);case a0:case l0:case c0:case d0:case p0:case u0:case h0:case m0:case f0:return Zn(i,t);case Yx:return new r;case e0:case o0:return new r(i);case t0:return np(i);case r0:return new r;case i0:return lp(i)}}var cp=y0;function g0(i){return typeof i.constructor=="function"&&!zo(i)?zc(Wo(i)):{}}var Qn=g0;var x0="[object Map]";function b0(i){return vt(i)&&Ko(i)==x0}var dp=b0;var pp=Or&&Or.isMap,v0=pp?Fo(pp):dp,up=v0;var S0="[object Set]";function w0(i){return vt(i)&&Ko(i)==S0}var hp=w0;var mp=Or&&Or.isSet,N0=mp?Fo(mp):hp,fp=N0;var C0=1,L0=2,T0=4,yp="[object Arguments]",I0="[object Array]",M0="[object Boolean]",P0="[object Date]",O0="[object Error]",gp="[object Function]",A0="[object GeneratorFunction]",j0="[object Map]",_0="[object Number]",xp="[object Object]",D0="[object RegExp]",B0="[object Set]",G0="[object String]",z0="[object Symbol]",E0="[object WeakMap]",F0="[object ArrayBuffer]",R0="[object DataView]",V0="[object Float32Array]",U0="[object Float64Array]",k0="[object Int8Array]",H0="[object Int16Array]",q0="[object Int32Array]",W0="[object Uint8Array]",$0="[object Uint8ClampedArray]",J0="[object Uint16Array]",K0="[object Uint32Array]",Fe={};Fe[yp]=Fe[I0]=Fe[F0]=Fe[R0]=Fe[M0]=Fe[P0]=Fe[V0]=Fe[U0]=Fe[k0]=Fe[H0]=Fe[q0]=Fe[j0]=Fe[_0]=Fe[xp]=Fe[D0]=Fe[B0]=Fe[G0]=Fe[z0]=Fe[W0]=Fe[$0]=Fe[J0]=Fe[K0]=!0;Fe[O0]=Fe[gp]=Fe[E0]=!1;function Yn(i,e,t,r,o,n){var s,a=e&C0,l=e&L0,c=e&T0;if(t&&(s=o?t(i,r,o,n):t(i)),s!==void 0)return s;if(!St(i))return i;var d=ht(i);if(d){if(s=op(i),!a)return An(i,s)}else{var u=Ko(i),p=u==gp||u==A0;if(Eo(i))return kn(i,a);if(u==xp||u==yp||p&&!o){if(s=l||p?{}:Qn(i),!a)return l?Xd(i,Ud(s,i)):Kd(i,Vd(s,i))}else{if(!Fe[u])return o?i:{};s=cp(i,u,a)}}n||(n=new Un);var f=n.get(i);if(f)return f;n.set(i,s),fp(i)?i.forEach(function(y){s.add(Yn(y,e,t,y,i,n))}):up(i)&&i.forEach(function(y,N){s.set(N,Yn(y,e,t,N,i,n))});var m=c?l?$n:Zd:l?hr:Ro,x=d?void 0:m(i);return Uc(x||i,function(y,N){x&&(N=y,y=i[N]),Dn(s,N,Yn(y,e,t,N,i,n))}),s}var es=Yn;var X0=1,Z0=4;function Q0(i){return es(i,X0|Z0)}var yo=Q0;function Y0(i){return function(e,t,r){for(var o=-1,n=Object(e),s=r(e),a=s.length;a--;){var l=s[i?a:++o];if(t(n[l],l,n)===!1)break}return e}}var bp=Y0;var eb=bp(),vp=eb;function tb(i,e,t){(t!==void 0&&!qr(i[e],t)||t===void 0&&!(e in i))&&Go(i,e,t)}var Oi=tb;function rb(i){return vt(i)&&Wr(i)}var Sp=rb;function ob(i,e){if(!(e==="constructor"&&typeof i[e]=="function")&&e!="__proto__")return i[e]}var Ai=ob;function ib(i){return Kt(i,hr(i))}var wp=ib;function nb(i,e,t,r,o,n,s){var a=Ai(i,t),l=Ai(e,t),c=s.get(l);if(c){Oi(i,t,c);return}var d=n?n(a,l,t+"",i,e,s):void 0,u=d===void 0;if(u){var p=ht(l),f=!p&&Eo(l),m=!p&&!f&&zn(l);d=l,p||f||m?ht(a)?d=a:Sp(a)?d=An(a):f?(u=!1,d=kn(l,!0)):m?(u=!1,d=Zn(l,!0)):d=[]:Vn(l)||mo(l)?(d=a,mo(a)?d=wp(a):(!St(a)||Do(a))&&(d=Qn(l))):u=!1}u&&(s.set(l,d),o(d,l,r,n,s),s.delete(l)),Oi(i,t,d)}var Np=nb;function Cp(i,e,t,r,o){i!==e&&vp(e,function(n,s){if(o||(o=new Un),St(n))Np(i,e,s,t,Cp,r,o);else{var a=r?r(Ai(i,s),n,s+"",i,e,o):void 0;a===void 0&&(a=n),Oi(i,s,a)}},hr)}var Lp=Cp;function sb(i){var e=i==null?0:i.length;return e?i[e-1]:void 0}var Tp=sb;function ab(i,e){return e.length<2?i:Id(i,Bd(e,0,-1))}var Ip=ab;var lb=Wc(function(i,e,t){Lp(i,e,t)}),go=lb;function cb(i,e){return e=Ho(e,i),i=Ip(i,e),i==null||delete i[Rn(Tp(e))]}var Mp=cb;function db(i){return Vn(i)?void 0:i}var Pp=db;var pb=1,ub=2,hb=4,mb=_d(function(i,e){var t={};if(i==null)return t;var r=!1;e=In(e,function(n){return n=Ho(n,i),r||(r=n.length>1),n}),Kt(i,$n(i),t),r&&(t=es(t,pb|ub|hb,Pp));for(var o=e.length;o--;)Mp(t,e[o]);return t}),Zo=mb;var Qo;(function(t){t.all=["PerspectiveCamera","OrthographicCamera"];function e(r){return t.all.includes(r)}t.is=e})(Qo||(Qo={}));var xo;(function(o){o.DefaultUp=[0,1,0],o.DefaultTargetOffset=1e3,o.defaultData={far:5e5,type:"OrthographicCamera",perspective:{near:5,fov:45,zoom:1},orthographic:{near:-5e5,zoom:1},up:o.DefaultUp,isUpVectorFlipped:!1,targetOffset:o.DefaultTargetOffset};function r(n){return n.type==="PerspectiveCamera"?n.perspective.zoom:n.orthographic.zoom}o.getZoom=r})(xo||(xo={}));var Yo;(function(r){r.x="x",r.y="y",r.z="z"})(Yo||(Yo={}));var Op;(function(n){n.Top="top",n.Right="right",n.Bottom="bottom",n.Left="left",n.Center="center"})(Op||(Op={}));var Ap;(function(t){function i(r,o){return r[0]===o[0]&&r[1]===o[1]}t.isEqual=i;function e(r,o,n){return[r[0]+(o[0]-r[0])*n,r[1]+(o[1]-r[1])*n]}t.lerp=e})(Ap||(Ap={}));var ei;(function(o){function i(n,s){return n[0]===s[0]&&n[1]===s[1]&&n[2]===s[2]}o.isEqual=i;function e(n,s){return[n[0]+s[0],n[1]+s[1],n[2]+s[2]]}o.add=e;function t(n,s){return[n[0]-s[0],n[1]-s[1],n[2]-s[2]]}o.sub=t;function r(n,s,a){return[n[0]+(s[0]-n[0])*a,n[1]+(s[1]-n[1])*a,n[2]+(s[2]-n[2])*a]}o.lerp=r})(ei||(ei={}));var jp;(function(t){function i(r,o){return r[0]===o[0]&&r[1]===o[1]&&r[2]===o[2]&&r[3]===o[3]}t.isEqual=i;function e(r,o,n){return[r[0]+(o[0]-r[0])*n,r[1]+(o[1]-r[1])*n,r[2]+(o[2]-r[2])*n,r[3]+(o[3]-r[3])*n]}t.lerp=e})(jp||(jp={}));var Zr;(function(n){n.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function e(s,a){for(let l=0;l<16;l++)if(s[l]!==a[l])return!1;return!0}n.isEqual=e;function t(s){return s!=null?s:n.identity}n.simplify=t;function r(s,a){let l=a.slice(0);for(var c=0,d=a.length;c<d;c+=3){let u=1/(s[3]*a[c]+s[7]*a[c+1]+s[11]*a[c+2]+s[15]);l[c]=(s[0]*a[c]+s[4]*a[c+1]+s[8]*a[c+2]+s[12])*u,l[c+1]=(s[1]*a[c]+s[5]*a[c+1]+s[9]*a[c+2]+s[13])*u,l[c+2]=(s[2]*a[c]+s[6]*a[c+1]+s[10]*a[c+2]+s[14])*u}return l}n.applyMatrix4=r;function o(s,a){let l=a.slice(0);for(var c=0,d=a.length;c<d;c+=3)l[c]=s[0]*a[c]+s[4]*a[c+1]+s[8]*a[c+2],l[c+1]=s[1]*a[c]+s[5]*a[c+1]+s[9]*a[c+2],l[c+2]=s[2]*a[c]+s[6]*a[c+1]+s[10]*a[c+2];return l}n.applyMatrix3Components=o})(Zr||(Zr={}));var Rt;(function(l){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 r(c){return{r:Math.round(c.r*255),g:Math.round(c.g*255),b:Math.round(c.b*255),a:1}}l.toRgb255a1=r;function o(c){return{r:c.r,g:c.g,b:c.b}}l.clone=o;function n(c){return c=Math.floor(c),{r:(c>>16&255)/255,g:(c>>8&255)/255,b:(c&255)/255}}l.fromHex=n;function s(c,d){return c.r===d.r&&c.g===d.g&&c.b===d.b}l.equals=s;function a(c,d,u){return{r:c.r+(d.r-c.r)*u,g:c.g+(d.g-c.g)*u,b:c.b+(d.b-c.b)*u}}l.lerp=a})(Rt||(Rt={}));var mr;(function(n){n.white=$(O({},Rt.white),{a:1});function e(s){return{r:s[0],g:s[1],b:s[2],a:s[3]}}n.from0to1=e;function t(s,a){return $(O({},Rt.fromHex(s)),{a})}n.fromHexAndA=t;function r(s){return{r:Math.round(s.r*255),g:Math.round(s.g*255),b:Math.round(s.b*255),a:s.a}}n.toRgb255a1=r;function o(s,a){return Rt.equals(s,a)&&s.a===a.a}n.equals=o})(mr||(mr={}));var ts;(function(e){e.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]}})(ts||(ts={}));var _p;(function(w){w[w.SKIP=0]="SKIP",w[w.ADD=1]="ADD",w[w.ALPHA=2]="ALPHA",w[w.AVERAGE=3]="AVERAGE",w[w.COLOR_BURN=4]="COLOR_BURN",w[w.COLOR_DODGE=5]="COLOR_DODGE",w[w.DARKEN=6]="DARKEN",w[w.DIFFERENCE=7]="DIFFERENCE",w[w.EXCLUSION=8]="EXCLUSION",w[w.LIGHTEN=9]="LIGHTEN",w[w.MULTIPLY=10]="MULTIPLY",w[w.DIVIDE=11]="DIVIDE",w[w.NEGATION=12]="NEGATION",w[w.NORMAL=13]="NORMAL",w[w.OVERLAY=14]="OVERLAY",w[w.REFLECT=15]="REFLECT",w[w.SCREEN=16]="SCREEN",w[w.SOFT_LIGHT=17]="SOFT_LIGHT",w[w.SUBTRACT=18]="SUBTRACT"})(_p||(_p={}));var Dp;(function(a){a[a.LINEAR=0]="LINEAR",a[a.EASE=1]="EASE",a[a.EASE_IN=2]="EASE_IN",a[a.EASE_OUT=3]="EASE_OUT",a[a.EASE_IN_OUT=4]="EASE_IN_OUT",a[a.CUBIC=5]="CUBIC",a[a.SPRING=6]="SPRING"})(Dp||(Dp={}));var Bp;(function(e){e.defaultData={mass:1,stiffness:80,damping:10,velocity:0}})(Bp||(Bp={}));var Gp;(function(e){e.defaultData={control1:[.5,.05],control2:[.1,.3]}})(Gp||(Gp={}));var rs;(function(e){function i(t,r=.1){return{type:"radial",hideBase:!1,count:3,radial:{radius:Math.max(t[0],t[1])*2,start:0,end:360,alignment:!1,axis:Yo.y,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0]},linear:{scale:[0,0,0],rotation:[0,0,0],position:[t[0]+t[0]*r,0,0]},grid:{count:[2,2,2],size:t.map(o=>o*(1+r)),useCenter:!0}}}e.defaultData=i})(rs||(rs={}));var jr;(function(e){e[e.Update=0]="Update"})(jr||(jr={}));var Xt;(function(r){r[r.Add=1]="Add",r[r.Delete=2]="Delete",r[r.Unlink=3]="Unlink"})(Xt||(Xt={}));var Vt;(function(r){r[r.Add=4]="Add",r[r.Delete=5]="Delete",r[r.Move=6]="Move"})(Vt||(Vt={}));var At;(function(r){r[r.Add=7]="Add",r[r.Delete=8]="Delete",r[r.Move=9]="Move"})(At||(At={}));var nr=class{modifyById(e,t){let r=this;if(r[e]===void 0)throw new Error("not expected");{let n=$(O({},r),{[e]:t});return Object.setPrototypeOf(n,nr.prototype),n}}add(e,t){var o;let r=this.runOp({type:Xt.Add,id:e,data:t});return(o=r==null?void 0:r.data)!=null?o:this}runOp(e){let t=this;if(e.type===Xt.Add){let r=t[e.id],o;r===void 0?o={type:Xt.Delete,id:e.id}:o={type:Xt.Add,id:e.id,data:r};let{id:n,data:s}=e,a=$(O({},t),{[n]:s});return Object.setPrototypeOf(a,nr.prototype),{data:a,actual:e,reverse:o}}else if(e.type===Xt.Delete){let{id:r}=e,o=t[r];if(o===void 0)return null;{let n=O({},t);return Object.setPrototypeOf(n,nr.prototype),delete n[r],{data:n,actual:e,reverse:{type:Xt.Add,id:r,data:o}}}}throw new Error("illegal arg")}};function ji(i){if(i.deepFreeze!==void 0){i.deepFreeze(i);return}let e=Object.getOwnPropertyNames(i);for(let t of e){let r=i[t];r&&typeof r=="object"&&ji(r)}return Object.freeze(i)}function zp(i,e){let t=0;for(;t<i.length&&t<e.length;){if(i[t]<e[t])return-1;if(i[t]>e[t])return 1;t+=1}return t!==e.length?-1:t!==i.length?1:0}var Da=class extends Error{};function fr(i,e,t){if(i===void 0?e===void 0?(i=0,e=10):i=e-10:e===void 0&&(e=i+10),i>e){let n=i;i=e,e=n}let r=[],o=1/(t+1);for(let n=0;n<t;n++){let s=i+(e-i)*(n+.75+Math.random()*.5)*o;r.push(s)}return r}function Ep(i){return i instanceof Uint8Array||i instanceof Uint16Array||i instanceof Uint32Array||i instanceof Int8Array||i instanceof Int16Array||i instanceof Int32Array||i instanceof Float32Array||i instanceof Float64Array}function Fp(){return typeof process!="undefined"}function Rp(i,e){for(let t of i)e(t.id,t.data),Rp(t.children,e)}function Vp(i,e){e(i.id,i.data);for(let t of i.children)Vp(t,e)}var sr=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,sr.prototype)}deepFreeze(){let e=0;for(;e<this.length;)ji(this[e]),e++}fillCaches0(e,t){var r;if((r=this.objCaches)==null?void 0:r.has(e.id))throw new Error("duplicated item");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)]}isDescendantOf(e,t){for(;e;){let r=this.parent(e);if(r===t)return!0;e=r}return!1}data(e){var t;return(t=this.get(e))==null?void 0:t.data}has(e){return this.childrenOf(e)!==void 0}get(e){return this.fillCaches(),this.objCaches.get(e)}childrenOf(e){var t;return e===null?this:(t=this.get(e))==null?void 0:t.children}traverseFrom(e,t){if(e===null)this.traverse(t);else{let r=this.get(e);r&&Vp(r,t)}}traverse(e){Rp(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 o=this.parent(e),n=this.childrenArray(o),s=n.findIndex(c=>c.id===e);if(s<0)throw new Error("not expected");let a=n[s];return n=[...n],n[s]=$(O({},a),{data:t}),this.modifyArrayBy(o,n)}}modifyArrayBy(e,t){let r=e,o=t;for(;r!==null;){let s=o,a=r;if(r=this.parent(r),r===void 0)throw new Error;o=this.childrenArray(r);let l=o.findIndex(c=>c.id===a);if(l<0)throw new Error;o=[...o],o[l]=$(O({},o[l]),{children:s})}Object.setPrototypeOf(o,sr.prototype);let n=o;return n.fillCaches(),n}runOp(e){switch(e.type){case At.Add:return this.addOp(e);case At.Delete:return this.deleteOp(e);case At.Move:return this.moveOp(e)}}addOp(e){let{parent:t,fi:r,id:o,data:n,children:s}=e;if(t!==null&&this.get(t)===void 0)return null;if(this.get(o)!==void 0)return null;{let a=t,l=this.childrenArray(a),c={fi:r,id:o,data:n,children:s};return l=[...l,c],l.sort((u,p)=>u.fi-p.fi),e.localIndex=l.indexOf(c),{data:this.modifyArrayBy(a,l),actual:e,reverse:{type:At.Delete,id:o}}}}deleteOp(e){let{id:t}=e;if(this.get(t)===null)return null;{let r=this.parent(t);if(r===void 0)return null;let o=this.childrenArray(r),n=o.findIndex(l=>l.id===t);e.localIndex=n,o=[...o];let s=o.splice(n,1)[0];return{data:this.modifyArrayBy(r,o),actual:e,reverse:$(O({type:At.Add},s),{parent:r})}}}moveOp(e){let{parent:t,fi:r,id:o}=e;if(t!==null&&this.get(t)===void 0)return this.deleteOp({type:At.Delete,id:o});if(t!==null){let p=t;for(;p!==null;){if(p===void 0)throw new Error;if(p===o)throw new Da("cyclic tree");p=this.parent(p)}}let n=this.parent(o);if(n===void 0)return null;let s=n,a=this.childrenArray(n),l=a.findIndex(p=>p.id===o);a=[...a];let c=a.splice(l,1)[0],d=this.modifyArrayBy(n,a);n=t,a=d.childrenArray(n);let u=c.fi;return c=$(O({},c),{fi:r}),a=[...a,c],a.sort((p,f)=>p.fi-f.fi),e.localIndex=a.indexOf(c),d=d.modifyArrayBy(n,a),{data:d,actual:e,reverse:{type:At.Move,parent:s,fi:u,id:o}}}previous(e,t){if(t===null){let o=this.childrenArray(e);return o.length===0?null:o[o.length-1].id}let r=null;for(let o of this.childrenArray(e)){if(o.id===t)return r;r=o.id}return null}traverseSortNext(e){let t=this.parent(e);if(t!==void 0){let r=this.childrenArray(t),o=r.findIndex(n=>n.id===e)+1;if(o<r.length)return r[o].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 r=this.childrenArray(t),o=r.findIndex(n=>n.id===e)-1;return o>=0?this.traverseSortPrevious(r[o].id):t}}getAllSorted(e){let t=[];for(let r of e){let o=this.getWithSortKey(r.id);o!==void 0&&t.push(O(O({},r),o))}t.sort((r,o)=>zp(r.sortKey,o.sortKey));for(let r of t)delete r.sortKey;return t}getWithSortKey(e){var t=e;let r=[],o=this.get(t),n=o;if(o!==void 0){for(;t;)r.splice(0,0,o.fi),t=this.parent(t),t!==null&&(o=this.get(t));return $(O({},n),{sortKey:r})}}insertBeforeHelper(e,t,r){return this.insertAfterHelper(e,this.previous(e,t),r)}insertAfterHelper(e,t,r){let o=this.childrenArray(e);if(t===null){if(o.length===0)return fr(0,r,r);{let n=o[0].fi;return fr(n-r,n,r)}}else{let n=this.get(t);if(n===void 0||this.parent(t)!==e)throw new Error("illegal args");let s=o.find(a=>a.fi>n.fi);if(s===void 0){let a=o[o.length-1].fi;return fr(a,a+r,r)}else return fr(n.fi,s.fi,r)}}};var os;(function(e){function i(t,r){if(Array.isArray(t)){let o=r.props,n={},s=[...t],a=!1;if(o)for(let l of Object.keys(o)){let c=parseInt(l);if(isNaN(c))throw new Error("wrong index");n[l]=s[c],s[c]=o[l],a=!0}return a?{data:s,actual:r,reverse:{type:jr.Update,props:n}}:null}else{let o=r.props,n={},s=O({},t),a=!1;if(o)for(let l of Object.keys(o))n[l]=s[l],s[l]=o[l],a=!0;return a?{data:s,actual:r,reverse:{type:jr.Update,props:n}}:null}}e.runOp=i})(os||(os={}));var Ke=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,Ke.prototype)}deepFreeze(){let e=0;for(;e<this.length;)ji(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){var t;return(t=this.get(e))==null?void 0:t.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 o=this,n=o.findIndex(l=>l.id===e);if(n<0)throw new Error("not expected");let s=o[n];return o=[...o],o[n]=$(O({},s),{data:t}),this.modifyArrayBy(o)}}modifyArrayBy(e){Object.setPrototypeOf(e,Ke.prototype);let t=e;return Fp()||t.fillCaches(),t}runOp(e){switch(e.type){case Vt.Add:return this.addOp(e);case Vt.Delete:return this.deleteOp(e);case Vt.Move:return this.moveOp(e)}}addOp(e){let{fi:t,id:r,data:o}=e,n=this,s={fi:t,id:r,data:o};return n=[...n,s],n.sort((l,c)=>l.fi-c.fi),e.localIndex=n.indexOf(s),{data:this.modifyArrayBy(n),actual:e,reverse:{type:Vt.Delete,id:r}}}deleteOp(e){let{id:t}=e,r=this,o=r.findIndex(a=>a.id===t);if(o===-1)return null;e.localIndex=o,r=[...r];let n=r.splice(o,1)[0];return{data:this.modifyArrayBy(r),actual:e,reverse:O({type:Vt.Add},n)}}moveOp(e){let{fi:t,id:r}=e,o=this;o=[...o];let n=o.findIndex(c=>c.id===r);if(n===-1)return null;let s=o[n].fi,a=$(O({},o[n]),{fi:t});return o[n]=a,o.sort((c,d)=>c.fi-d.fi),e.localIndex=o.indexOf(a),{data:this.modifyArrayBy(o),actual:e,reverse:{type:Vt.Move,fi:s,id:r}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let t=null;for(let r of this){if(r.id===e)return t;t=r.id}return null}insertBeforeHelper(e,t){return this.insertAfterHelper(this.previous(e),t)}insertAfterHelper(e,t){let r=this;if(e===null){if(r.length===0)return fr(0,t,t);{let o=r[0].fi;return fr(o-t,o,t)}}else{let o=this.get(e);if(o===void 0)throw new Error("illegal args");let n=r.find(s=>s.fi>o.fi);if(n===void 0){let s=r[r.length-1].fi;return fr(s,s+t,t)}else return fr(o.fi,n.fi,t)}}};var Up=Symbol(),is=Symbol(),_i=class{reportOp(e,t){let r=this;if(t===null)return;r._current=t.data;let o=[];for(;!(r instanceof Ga);){let n=r._path,s=r._current;if(n!==""&&o.splice(0,0,n),r=r._parent,r===null)return;r.update(n,s)}r.push(o,e,t.actual,t.reverse)}deleteChildren(e){if(this._children){let t=this._children[e];if(t){let r=t[is];r&&r(),delete this._children[e]}}}},kp=class extends _i{constructor(e,t,r){super();this._parent=e,this._path=t,this._current=r}update(e,t){if(Array.isArray(this._current)){if(typeof e=="string"&&(e=parseInt(e),isNaN(e)))throw new Error("Invalid path");this._current=[...this._current],this._current[e]=t}else this._current=$(O({},this._current),{[e]:t})}runOp(e){this.reportOp(e,os.runOp(this._current,e))}},Hp=class extends _i{constructor(e,t,r){super();this._parent=e,this._path=t,this._current=r}update(e,t){this._current=$(O({},this._current),{[e]:t}),Object.setPrototypeOf(this._current,nr.prototype)}runOp(e){this.reportOp(e,this._current.runOp(e))}},qp={get(i,e){if(e===is)return()=>{i._parent=null};if(e===Up)return i._current;let{_current:t,_children:r}=i;if(e==="push"&&Array.isArray(t))throw new Error("not supported to expand array");let o=r===void 0?void 0:r[e];if(o!==void 0)return o;let n=t[e],s=ns(i,e,n);return s!==n?(r===void 0&&(r={},i._children=r),r[e]=s,s):n},has(i,e){return e in i._current},ownKeys(i){return Reflect.ownKeys(i._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(i){return Object.getPrototypeOf(i._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(i,e){let t=i._current,r=Reflect.getOwnPropertyDescriptor(t,e);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:t[e]}}},fb=$(O({},qp),{set(i,e,t){var o;let r;if(t===void 0)throw new Error("set to undefined is not supported!");return r={type:jr.Update,props:{[e]:(o=xb(t))!=null?o:t}},i.deleteChildren(e),i.runOp(r),!0},deleteProperty(i,e){throw new Error("set to undefined is not supported!")}}),yb=$(O({},qp),{set(i,e,t){return t===void 0?this.deleteProperty(i,e):(i.deleteChildren(e),i.runOp({type:Xt.Add,id:e,data:t})),!0},deleteProperty(i,e){return i.runOp({type:Xt.Delete,id:e}),!0}}),Di=class extends _i{constructor(e,t,r){super();this._children={},this._parent=e,this._path=t,this._current=r,this[is]=()=>{this._parent=null}}unproxy(){return this._current}update(e,t){this._current=this._current.modifyById(e,t)}runOp(e){this.reportOp(e,this._current.runOp(e))}randomId(){return this._current.randomId()}isDescendantOf(e,t){return this._current.isDescendantOf(e,t)}childrenOf(e){return this._current.childrenOf(e)}traverse(e){return this._current.traverse(e)}get(e){return this._current.get(e)}parent(e){return this._current.parent(e)}traverse(e){this._current.traverse((t,r)=>{e(t,this.data(t))})}data(e){var a;let{_current:t,_children:r}=this,o=r===void 0?void 0:r[e];if(o!==void 0)return o;let n=(a=t.get(e))==null?void 0:a.data,s=ns(this,e,n);return s!==n?(r===void 0&&(r={},this._children=r),r[e]=s,s):n}add(e,t,r,o,n){this.runOp({type:At.Add,parent:e,fi:t,id:r,data:o,children:n})}move(e,t,r){this.runOp({type:At.Move,parent:e,fi:t,id:r})}insertAfter(e,t,r){let o=this._current.insertAfterHelper(e,t,r.length);for(let n=0;n<r.length;n++){let s=r[n];this.add(e,o[n],s.id,s.data,s.children)}}insertBefore(e,t,r){let o=this._current.insertBeforeHelper(e,t,r.length);for(let n=0;n<r.length;n++){let s=r[n];this.add(e,o[n],s.id,s.data,s.children)}}moveAfter(e,t,r){let o=this._current.insertAfterHelper(e,t,r.length);for(let n=0;n<r.length;n++){let s=r[n];this.move(e,o[n],s)}}moveBefore(e,t,r){let o=this._current.insertBeforeHelper(e,t,r.length);for(let n=0;n<r.length;n++){let s=r[n];this.move(e,o[n],s)}}delete(e){this.deleteChildren(e),this.runOp({type:At.Delete,id:e})}sortNext(e){return this._current.sortNext(e)}sortPrevious(e){return this._current.sortPrevious(e)}getAllSorted(e){return this._current.getAllSorted(e)}},Bi=class extends _i{constructor(e,t,r){super();this._children={},this._parent=e,this._path=t,this._current=r,this[is]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(e){let t=this.length;for(let r=0;r<t;r++){let o=this._current[r].id;e(this.data(this._current[r].id),o)}}update(e,t){this._current=this._current.modifyById(e,t)}randomId(){return this._current.randomId()}get(e){return $(O({},this._current.get(e)),{data:this.data(e)})}data(e){var a;let{_current:t,_children:r}=this,o=r===void 0?void 0:r[e];if(o!==void 0)return o;let n=(a=t.get(e))==null?void 0:a.data,s=ns(this,e,n);return s!==n?(r===void 0&&(r={},this._children=r),r[e]=s,s):n}runOp(e){this.reportOp(e,this._current.runOp(e))}add(e,t,r){this.runOp({type:Vt.Add,fi:e,id:t,data:r})}move(e,t){this.runOp({type:Vt.Move,fi:e,id:t})}insertAfter(e,t){let r=this._current.insertAfterHelper(e,t.length);for(let o=0;o<t.length;o++){let n=t[o];this.add(r[o],n.id,n.data)}}insertBefore(e,t){let r=this._current.insertBeforeHelper(e,t.length);for(let o=0;o<t.length;o++){let n=t[o];this.add(r[o],n.id,n.data)}}moveAfter(e,t){let r=this._current.insertAfterHelper(e,t.length);for(let o=0;o<t.length;o++){let n=t[o];this.move(r[o],n)}}moveBefore(e,t){let r=this._current.insertBeforeHelper(e,t.length);for(let o=0;o<t.length;o++){let n=t[o];this.move(r[o],n)}}delete(e){this.deleteChildren(e),this.runOp({type:Vt.Delete,id:e})}};function Ba(i,e,t){if(i.length>0){let r=i[i.length-1];if(r.type===jr.Update&&e.type===jr.Update&&ss.equal(r.path,t)){Object.assign(r.props,e.props);return}}i.push($(O({},e),{path:t}))}var Ga=class{constructor(e){this.ts=[],this.actual=[],this.reverse=[],this._current=e}update(e,t){if(e!=="")throw new Error("");this._current=t}push(e,t,r,o){Ba(this.ts,t,e),Ba(this.actual,r,e),Ba(this.reverse,o,e)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function ns(i,e,t){return t instanceof sr?new Di(i,e,t):t instanceof Ke?new Bi(i,e,t):t instanceof nr?new Proxy(new Hp(i,e,t),yb):t!==null&&typeof t=="object"?Ep(t)?t:new Proxy(new kp(i,e,t),fb):t}function gb(i){let e=new Ga(i);return[ns(e,"",i),e]}function za(i,e){let[t,r]=gb(i);return e(t),r.result()}function xb(i){return i instanceof Di||i instanceof Bi?i._current:i!==null&&typeof i=="object"?i[Up]:i}var ss;(function(r){function i(o,n){if(n.length===o.length)for(var s=0;s<o.length;){if(o[s]!==n[s])return!1;s+=1}else return!1;return!0}r.equal=i;function e(o,n,s){let a=t(s,o);if(a!==void 0&&typeof a=="object"&&a!==null){let l=O({},n);return Object.keys(a).forEach(c=>{delete l[c]}),l}else return n}r.removeOverridden=e;function t(o,n,s=0){if(n.length<=s)return o;if((o instanceof sr||o instanceof Di)&&typeof n[s]=="string")return t(o.data(n[s]),n,s+1);if((o instanceof Ke||o instanceof Bi)&&typeof n[s]=="string")return t(o.data(n[s]),n,s+1);if(typeof n[s]=="number"&&Array.isArray(o))return t(o[n[s]],n,s+1);if(typeof n[s]=="string"&&typeof o=="object")return t(o[n[s]],n,s+1)}r.zoom=t})(ss||(ss={}));var Ea=class{},as=class extends Ea{constructor(e){super();this.id=e}},ls=class extends Ea{constructor(e){super();this.data=e}};"use strict";var Fa;try{Fa=new TextDecoder}catch(i){}var Q,Qr,C=0;var Wp=[],Ra=Wp,Va=0,jt={},Me,Yr,Zt=0,yr=0,Ut,_r,Lt=[],Ae,$p={useRecords:!1,mapsAsObjects:!0},cs=class{},Ua=new cs;Ua.name="MessagePack 0xC1";var ti=!1,Dr=class{constructor(e){e&&(e.useRecords===!1&&e.mapsAsObjects===void 0&&(e.mapsAsObjects=!0),e.structures?e.structures.sharedLength=e.structures.length:e.getStructures&&((e.structures=[]).uninitialized=!0,e.structures.sharedLength=0)),Object.assign(this,e)}unpack(e,t){if(Q)return iu(()=>(us(),this?this.unpack(e,t):Dr.prototype.unpack.call($p,e,t)));Qr=t>-1?t:e.length,C=0,Va=0,yr=0,Yr=null,Ra=Wp,Ut=null,Q=e;try{Ae=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(r){throw Q=null,e instanceof Uint8Array?r:new Error("Source must be a Uint8Array or Buffer but was a "+(e&&typeof e=="object"?e.constructor.name:typeof e))}if(this instanceof Dr){if(jt=this,this.structures)return Me=this.structures,ds();(!Me||Me.length>0)&&(Me=[])}else jt=$p,(!Me||Me.length>0)&&(Me=[]);return ds()}unpackMultiple(e,t){let r,o=0;try{ti=!0;let n=e.length,s=this?this.unpack(e,n):ms.unpack(e,n);if(t){for(t(s);C<n;)if(o=C,t(ds())===!1)return}else{for(r=[s];C<n;)o=C,r.push(ds());return r}}catch(n){throw n.lastPosition=o,n.values=r,n}finally{ti=!1,us()}}_mergeStructures(e,t){e=e||[];for(let r=0,o=e.length;r<o;r++){let n=e[r];n&&(n.isShared=!0,r>=32&&(n.highByte=r-32>>5))}e.sharedLength=e.length;for(let r in t||[])if(r>=0){let o=e[r],n=t[r];n&&(o&&((e.restoreStructures||(e.restoreStructures=[]))[r]=o),e[r]=n)}return this.structures=e}decode(e,t){return this.unpack(e,t)}};function ds(){try{if(!jt.trusted&&!ti){let e=Me.sharedLength||0;e<Me.length&&(Me.length=e)}let i=Xe();if(C==Qr)Me.restoreStructures&&Jp(),Me=null,Q=null,_r&&(_r=null);else if(C>Qr){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}else if(!ti)throw new Error("Data read, but end of buffer not reached");return i}catch(i){throw Me.restoreStructures&&Jp(),us(),(i instanceof RangeError||i.message.startsWith("Unexpected end of buffer"))&&(i.incomplete=!0),i}}function Jp(){for(let i in Me.restoreStructures)Me[i]=Me.restoreStructures[i];Me.restoreStructures=null}function Xe(){let i=Q[C++];if(i<160)if(i<128){if(i<64)return i;{let e=Me[i&63]||jt.getStructures&&Xp()[i&63];return e?(e.read||(e.read=ka(e,i&63)),e.read()):i}}else if(i<144)if(i-=128,jt.mapsAsObjects){let e={};for(let t=0;t<i;t++)e[tu()]=Xe();return e}else{let e=new Map;for(let t=0;t<i;t++)e.set(Xe(),Xe());return e}else{i-=144;let e=new Array(i);for(let t=0;t<i;t++)e[t]=Xe();return e}else if(i<192){let e=i-160;if(yr>=C)return Yr.slice(C-Zt,(C+=e)-Zt);if(yr==0&&Qr<140){let t=e<16?qa(e):Yp(e);if(t!=null)return t}return Ha(e)}else{let e;switch(i){case 192:return null;case 193:return Ut?(e=Xe(),e>0?Ut[1].slice(Ut.position1,Ut.position1+=e):Ut[0].slice(Ut.position0,Ut.position0-=e)):Ua;case 194:return!1;case 195:return!0;case 196:return Wa(Q[C++]);case 197:return e=Ae.getUint16(C),C+=2,Wa(e);case 198:return e=Ae.getUint32(C),C+=4,Wa(e);case 199:return bo(Q[C++]);case 200:return e=Ae.getUint16(C),C+=2,bo(e);case 201:return e=Ae.getUint32(C),C+=4,bo(e);case 202:if(e=Ae.getFloat32(C),jt.useFloat32>2){let t=hs[(Q[C]&127)<<1|Q[C+1]>>7];return C+=4,(t*e+(e>0?.5:-.5)>>0)/t}return C+=4,e;case 203:return e=Ae.getFloat64(C),C+=8,e;case 204:return Q[C++];case 205:return e=Ae.getUint16(C),C+=2,e;case 206:return e=Ae.getUint32(C),C+=4,e;case 207:return jt.int64AsNumber?(e=Ae.getUint32(C)*4294967296,e+=Ae.getUint32(C+4)):e=Ae.getBigUint64(C),C+=8,e;case 208:return Ae.getInt8(C++);case 209:return e=Ae.getInt16(C),C+=2,e;case 210:return e=Ae.getInt32(C),C+=4,e;case 211:return jt.int64AsNumber?(e=Ae.getInt32(C)*4294967296,e+=Ae.getUint32(C+4)):e=Ae.getBigInt64(C),C+=8,e;case 212:if(e=Q[C++],e==114)return ru(Q[C++]&63);{let t=Lt[e];if(t)return t.read?(C++,t.read(Xe())):t.noBuffer?(C++,t()):t(Q.subarray(C,++C));throw new Error("Unknown extension "+e)}case 213:return e=Q[C],e==114?(C++,ru(Q[C++]&63,Q[C++])):bo(2);case 214:return bo(4);case 215:return bo(8);case 216:return bo(16);case 217:return e=Q[C++],yr>=C?Yr.slice(C-Zt,(C+=e)-Zt):vb(e);case 218:return e=Ae.getUint16(C),C+=2,yr>=C?Yr.slice(C-Zt,(C+=e)-Zt):Sb(e);case 219:return e=Ae.getUint32(C),C+=4,yr>=C?Yr.slice(C-Zt,(C+=e)-Zt):wb(e);case 220:return e=Ae.getUint16(C),C+=2,Zp(e);case 221:return e=Ae.getUint32(C),C+=4,Zp(e);case 222:return e=Ae.getUint16(C),C+=2,Qp(e);case 223:return e=Ae.getUint32(C),C+=4,Qp(e);default:if(i>=224)return i-256;if(i===void 0){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}throw new Error("Unknown MessagePack token "+i)}}}var bb=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function ka(i,e){function t(){if(t.count++>2){let o=i.read=new Function("r","return function(){return {"+i.map(n=>bb.test(n)?n+":r()":"["+JSON.stringify(n)+"]:r()").join(",")+"}}")(Xe);return i.highByte===0&&(i.read=Kp(e,i.read)),o()}let r={};for(let o=0,n=i.length;o<n;o++){let s=i[o];r[s]=Xe()}return r}return t.count=0,i.highByte===0?Kp(e,t):t}var Kp=(i,e)=>function(){let t=Q[C++];if(t===0)return e();let r=i<32?-(i+(t<<5)):i+(t<<5),o=Me[r]||Xp()[r];if(!o)throw new Error("Record id is not defined for "+r);return o.read||(o.read=ka(o,i)),o.read()};function Xp(){let i=iu(()=>(Q=null,jt.getStructures()));return Me=jt._mergeStructures(i,Me)}var Ha=ps,vb=ps,Sb=ps,wb=ps;function ps(i){let e;if(i<16&&(e=qa(i)))return e;if(i>64&&Fa)return Fa.decode(Q.subarray(C,C+=i));let t=C+i,r=[];for(e="";C<t;){let o=Q[C++];if((o&128)==0)r.push(o);else if((o&224)==192){let n=Q[C++]&63;r.push((o&31)<<6|n)}else if((o&240)==224){let n=Q[C++]&63,s=Q[C++]&63;r.push((o&31)<<12|n<<6|s)}else if((o&248)==240){let n=Q[C++]&63,s=Q[C++]&63,a=Q[C++]&63,l=(o&7)<<18|n<<12|s<<6|a;l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|l&1023),r.push(l)}else r.push(o);r.length>=4096&&(e+=ct.apply(String,r),r.length=0)}return r.length>0&&(e+=ct.apply(String,r)),e}function Zp(i){let e=new Array(i);for(let t=0;t<i;t++)e[t]=Xe();return e}function Qp(i){if(jt.mapsAsObjects){let e={};for(let t=0;t<i;t++)e[tu()]=Xe();return e}else{let e=new Map;for(let t=0;t<i;t++)e.set(Xe(),Xe());return e}}var ct=String.fromCharCode;function Yp(i){let e=C,t=new Array(i);for(let r=0;r<i;r++){let o=Q[C++];if((o&128)>0){C=e;return}t[r]=o}return ct.apply(String,t)}function qa(i){if(i<4)if(i<2){if(i===0)return"";{let e=Q[C++];if((e&128)>1){C-=1;return}return ct(e)}}else{let e=Q[C++],t=Q[C++];if((e&128)>0||(t&128)>0){C-=2;return}if(i<3)return ct(e,t);let r=Q[C++];if((r&128)>0){C-=3;return}return ct(e,t,r)}else{let e=Q[C++],t=Q[C++],r=Q[C++],o=Q[C++];if((e&128)>0||(t&128)>0||(r&128)>0||(o&128)>0){C-=4;return}if(i<6){if(i===4)return ct(e,t,r,o);{let n=Q[C++];if((n&128)>0){C-=5;return}return ct(e,t,r,o,n)}}else if(i<8){let n=Q[C++],s=Q[C++];if((n&128)>0||(s&128)>0){C-=6;return}if(i<7)return ct(e,t,r,o,n,s);let a=Q[C++];if((a&128)>0){C-=7;return}return ct(e,t,r,o,n,s,a)}else{let n=Q[C++],s=Q[C++],a=Q[C++],l=Q[C++];if((n&128)>0||(s&128)>0||(a&128)>0||(l&128)>0){C-=8;return}if(i<10){if(i===8)return ct(e,t,r,o,n,s,a,l);{let c=Q[C++];if((c&128)>0){C-=9;return}return ct(e,t,r,o,n,s,a,l,c)}}else if(i<12){let c=Q[C++],d=Q[C++];if((c&128)>0||(d&128)>0){C-=10;return}if(i<11)return ct(e,t,r,o,n,s,a,l,c,d);let u=Q[C++];if((u&128)>0){C-=11;return}return ct(e,t,r,o,n,s,a,l,c,d,u)}else{let c=Q[C++],d=Q[C++],u=Q[C++],p=Q[C++];if((c&128)>0||(d&128)>0||(u&128)>0||(p&128)>0){C-=12;return}if(i<14){if(i===12)return ct(e,t,r,o,n,s,a,l,c,d,u,p);{let f=Q[C++];if((f&128)>0){C-=13;return}return ct(e,t,r,o,n,s,a,l,c,d,u,p,f)}}else{let f=Q[C++],m=Q[C++];if((f&128)>0||(m&128)>0){C-=14;return}if(i<15)return ct(e,t,r,o,n,s,a,l,c,d,u,p,f,m);let x=Q[C++];if((x&128)>0){C-=15;return}return ct(e,t,r,o,n,s,a,l,c,d,u,p,f,m,x)}}}}}function Wa(i){return jt.copyBuffers?Uint8Array.prototype.slice.call(Q,C,C+=i):Q.subarray(C,C+=i)}function bo(i){let e=Q[C++];if(Lt[e])return Lt[e](Q.subarray(C,C+=i));throw new Error("Unknown extension type "+e)}var eu=new Array(4096);function tu(){let i=Q[C++];if(i>=160&&i<192){if(i=i-160,yr>=C)return Yr.slice(C-Zt,(C+=i)-Zt);if(!(yr==0&&Qr<180))return Ha(i)}else return C--,Xe();let e=(i<<5^(i>1?Ae.getUint16(C):i>0?Q[C]:0))&4095,t=eu[e],r=C,o=C+i-3,n,s=0;if(t&&t.bytes==i){for(;r<o;){if(n=Ae.getUint32(r),n!=t[s++]){r=1879048192;break}r+=4}for(o+=3;r<o;)if(n=Q[r++],n!=t[s++]){r=1879048192;break}if(r===o)return C=r,t.string;o-=3,r=C}for(t=[],eu[e]=t,t.bytes=i;r<o;)n=Ae.getUint32(r),t.push(n),r+=4;for(o+=3;r<o;)n=Q[r++],t.push(n);let a=i<16?qa(i):Yp(i);return a!=null?t.string=a:t.string=Ha(i)}var ru=(i,e)=>{var t=Xe();let r=i;e!==void 0&&(i=i<32?-((e<<5)+i):(e<<5)+i,t.highByte=e);let o=Me[i];return o&&o.isShared&&((Me.restoreStructures||(Me.restoreStructures=[]))[i]=o),Me[i]=t,t.read=ka(t,r),t.read()},ou=typeof self=="object"?self:global;Lt[0]=()=>{};Lt[0].noBuffer=!0;Lt[101]=()=>{let i=Xe();return(ou[i[0]]||Error)(i[1])};Lt[105]=i=>{let e=Ae.getUint32(C-4);_r||(_r=new Map);let t=Q[C],r;t>=144&&t<160||t==220||t==221?r=[]:r={};let o={target:r};_r.set(e,o);let n=Xe();return o.used?Object.assign(r,n):(o.target=n,n)};Lt[112]=i=>{let e=Ae.getUint32(C-4),t=_r.get(e);return t.used=!0,t.target};Lt[115]=()=>new Set(Xe());var $a=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(i=>i+"Array");Lt[116]=i=>{let e=i[0],t=$a[e];if(!t)throw new Error("Could not find typed array for code "+e);return new ou[t](Uint8Array.prototype.slice.call(i,1).buffer)};Lt[120]=()=>{let i=Xe();return new RegExp(i[0],i[1])};Lt[98]=i=>{let e=(i[0]<<24)+(i[1]<<16)+(i[2]<<8)+i[3],t=C;C+=e-4,Ut=[Xe(),Xe()],Ut.position0=0,Ut.position1=0;let r=C;C=t;try{return Xe()}finally{C=r}};Lt[255]=i=>i.length==4?new Date((i[0]*16777216+(i[1]<<16)+(i[2]<<8)+i[3])*1e3):i.length==8?new Date(((i[0]<<22)+(i[1]<<14)+(i[2]<<6)+(i[3]>>2))/1e6+((i[3]&3)*4294967296+i[4]*16777216+(i[5]<<16)+(i[6]<<8)+i[7])*1e3):i.length==12?new Date(((i[0]<<24)+(i[1]<<16)+(i[2]<<8)+i[3])/1e6+((i[4]&128?-281474976710656:0)+i[6]*1099511627776+i[7]*4294967296+i[8]*16777216+(i[9]<<16)+(i[10]<<8)+i[11])*1e3):new Date("invalid");function iu(i){let e=Qr,t=C,r=Va,o=Zt,n=yr,s=Yr,a=Ra,l=_r,c=Ut,d=new Uint8Array(Q.slice(0,Qr)),u=Me,p=Me.slice(0,Me.length),f=jt,m=ti,x=i();return Qr=e,C=t,Va=r,Zt=o,yr=n,Yr=s,Ra=a,_r=l,Ut=c,Q=d,ti=m,Me=u,Me.splice(0,Me.length,...p),jt=f,Ae=new DataView(Q.buffer,Q.byteOffset,Q.byteLength),x}function us(){Q=null,_r=null,Me=null}function nu(i){i.unpack?Lt[i.type]=i.unpack:Lt[i.type]=i}var hs=new Array(147);for(let i=0;i<256;i++)hs[i]=+("1e"+Math.floor(45.15-i*.30103));var ms=new Dr({useRecords:!1}),Nb=ms.unpack,Cb=ms.unpackMultiple,Lb=ms.unpack;var Tb=new Float32Array(1),ZO=new Uint8Array(Tb.buffer,0,4);"use strict";var fs;try{fs=new TextEncoder}catch(i){}var ys,Ja,gs=typeof Buffer!="undefined",Ka=gs?Buffer.allocUnsafeSlow:Uint8Array,au=gs?Buffer:Uint8Array,lu=gs?4294967296:2144337920,G,Ze,M=0,gr,xr=null,Ib=/[\u0080-\uFFFF]/,Gi=Symbol("record-id"),ri=class extends Dr{constructor(e){super(e);this.offset=0;let t,r,o,n,s,a,l=0,c=au.prototype.utf8Write?function(h,I,b){return G.utf8Write(h,I,b)}:fs&&fs.encodeInto?function(h,I){return fs.encodeInto(h,G.subarray(I)).written}:!1,d=this;e||(e={});let u=e&&e.sequential,p=e.structures||e.saveStructures,f=e.maxSharedStructures;if(f==null&&(f=p?32:0),f>8160)throw new Error("Maximum maxSharedStructure is 8160");let m=e.maxOwnStructures;m==null&&(m=p?32:64),u&&!e.saveStructures&&(this.structures=[]);let x=f>32||m+f>64,y=f+64,N=f+m+64;if(N>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let L=[],w=0,B=0;this.pack=this.encode=function(h,I){if(G||(G=new Ka(8192),Ze=new DataView(G.buffer,0,8192),M=0),gr=G.length-10,gr-M<2048?(G=new Ka(G.length),Ze=new DataView(G.buffer,0,G.length),gr=G.length-10,M=0):M=M+7&2147483640,r=M,a=d.structuredClone?new Map:null,d.bundleStrings?(xr=["",""],G[M++]=214,G[M++]=98,xr.position=M-r,M+=4):xr=null,o=d.structures,o){o.uninitialized&&(o=d._mergeStructures(d.getStructures()));let b=o.sharedLength||0;if(b>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 P=0;P<b;P++){let v=o[P];if(!v)continue;let D,Z=o.transitions;for(let V=0,ie=v.length;V<ie;V++){let oe=v[V];D=Z[oe],D||(D=Z[oe]=Object.create(null)),Z=D}Z[Gi]=P+64}l=b}u||(o.nextId=b+64)}n&&(n=!1),s=o||[];try{if(S(h),xr){Ze.setUint32(xr.position+r,M-xr.position-r);let b=xr;xr=null,S(b[0]),S(b[1])}if(d.offset=M,a&&a.idsToInsert){M+=a.idsToInsert.length*6,M>gr&&T(M),d.offset=M;let b=Pb(G.subarray(r,M),a.idsToInsert);return a=null,b}return I&uu?(G.start=r,G.end=M,G):G.subarray(r,M)}finally{if(o){if(B<10&&B++,w>1e4)o.transitions=null,B=0,w=0,L.length>0&&(L=[]);else if(L.length>0&&!u){for(let b=0,P=L.length;b<P;b++)L[b][Gi]=0;L=[]}if(n&&d.saveStructures){let b=o.sharedLength||f;o.length>b&&(o=o.slice(0,b));let P=G.subarray(r,M);return d.saveStructures(o,l)===!1?(d._mergeStructures(d.getStructures()),d.pack(h)):(l=b,P)}}I&jb&&(M=r)}};let S=h=>{M>gr&&(G=T(M));var I=typeof h,b;if(I==="string"){let P=h.length;if(xr&&P>=8&&P<4096){let Z=Ib.test(h);xr[Z?0:1]+=h,G[M++]=193,S(Z?-P:P);return}let v;P<32?v=1:P<256?v=2:P<65536?v=3:v=5;let D=P*3;if(M+D>gr&&(G=T(M+D)),P<64||!c){let Z,V,ie,oe=M+v;for(Z=0;Z<P;Z++)V=h.charCodeAt(Z),V<128?G[oe++]=V:V<2048?(G[oe++]=V>>6|192,G[oe++]=V&63|128):(V&64512)==55296&&((ie=h.charCodeAt(Z+1))&64512)==56320?(V=65536+((V&1023)<<10)+(ie&1023),Z++,G[oe++]=V>>18|240,G[oe++]=V>>12&63|128,G[oe++]=V>>6&63|128,G[oe++]=V&63|128):(G[oe++]=V>>12|224,G[oe++]=V>>6&63|128,G[oe++]=V&63|128);b=oe-M-v}else b=c(h,M+v,D);b<32?G[M++]=160|b:b<256?(v<2&&G.copyWithin(M+2,M+1,M+1+b),G[M++]=217,G[M++]=b):b<65536?(v<3&&G.copyWithin(M+3,M+2,M+2+b),G[M++]=218,G[M++]=b>>8,G[M++]=b&255):(v<5&&G.copyWithin(M+5,M+3,M+3+b),G[M++]=219,Ze.setUint32(M,b),M+=4),M+=b}else if(I==="number")if(h>>>0===h)h<64?G[M++]=h:h<256?(G[M++]=204,G[M++]=h):h<65536?(G[M++]=205,G[M++]=h>>8,G[M++]=h&255):(G[M++]=206,Ze.setUint32(M,h),M+=4);else if(h>>0===h)h>=-32?G[M++]=256+h:h>=-128?(G[M++]=208,G[M++]=h+256):h>=-32768?(G[M++]=209,Ze.setInt16(M,h),M+=2):(G[M++]=210,Ze.setInt32(M,h),M+=4);else{let P;if((P=this.useFloat32)>0&&h<4294967296&&h>=-2147483648){G[M++]=202,Ze.setFloat32(M,h);let v;if(P<4||(v=h*hs[(G[M]&127)<<1|G[M+1]>>7])>>0===v){M+=4;return}else M--}G[M++]=203,Ze.setFloat64(M,h),M+=8}else if(I==="object")if(!h)G[M++]=192;else{if(a){let v=a.get(h);if(v){if(!v.id){let D=a.idsToInsert||(a.idsToInsert=[]);v.id=D.push(v)}G[M++]=214,G[M++]=112,Ze.setUint32(M,v.id),M+=4;return}else a.set(h,{offset:M-r})}let P=h.constructor;if(P===Object)_(h,!0);else if(P===Array){b=h.length,b<16?G[M++]=144|b:b<65536?(G[M++]=220,G[M++]=b>>8,G[M++]=b&255):(G[M++]=221,Ze.setUint32(M,b),M+=4);for(let v=0;v<b;v++)S(h[v])}else if(P===Map){b=h.size,b<16?G[M++]=128|b:b<65536?(G[M++]=222,G[M++]=b>>8,G[M++]=b&255):(G[M++]=223,Ze.setUint32(M,b),M+=4);for(let[v,D]of h)S(v),S(D)}else{for(let v=0,D=ys.length;v<D;v++){let Z=Ja[v];if(h instanceof Z){let V=ys[v];if(V.write){V.type&&(G[M++]=212,G[M++]=V.type,G[M++]=0),S(V.write.call(this,h));return}let ie=G,oe=Ze,ge=M;G=null;let xe;try{xe=V.pack.call(this,h,A=>(G=ie,ie=null,M+=A,M>gr&&T(M),{target:G,targetView:Ze,position:M-A}),S)}finally{ie&&(G=ie,Ze=oe,M=ge,gr=G.length-10)}xe&&(xe.length+M>gr&&T(xe.length+M),M=Mb(xe,G,M,V.type));return}}_(h,!h.hasOwnProperty)}}else if(I==="boolean")G[M++]=h?195:194;else if(I==="bigint"){if(h<BigInt(1)<<BigInt(63)&&h>=-(BigInt(1)<<BigInt(63)))G[M++]=211,Ze.setBigInt64(M,h);else if(h<BigInt(1)<<BigInt(64)&&h>0)G[M++]=207,Ze.setBigUint64(M,h);else if(this.largeBigIntToFloat)G[M++]=203,Ze.setFloat64(M,Number(h));else throw new RangeError(h+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");M+=8}else if(I==="undefined")this.encodeUndefinedAsNil?G[M++]=192:(G[M++]=212,G[M++]=0,G[M++]=0);else if(I==="function")S(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+I)},_=this.useRecords===!1?this.variableMapSize?h=>{let I=Object.keys(h),b=I.length;b<16?G[M++]=128|b:b<65536?(G[M++]=222,G[M++]=b>>8,G[M++]=b&255):(G[M++]=223,Ze.setUint32(M,b),M+=4);let P;for(let v=0;v<b;v++)S(P=I[v]),S(h[P])}:(h,I)=>{G[M++]=222;let b=M-r;M+=2;let P=0;for(let v in h)(I||h.hasOwnProperty(v))&&(S(v),S(h[v]),P++);G[b+++r]=P>>8,G[b+r]=P&255}:h=>{let I=Object.keys(h),b,P=s.transitions||(s.transitions=Object.create(null)),v=0;for(let Z=0,V=I.length;Z<V;Z++){let ie=I[Z];b=P[ie],b||(b=P[ie]=Object.create(null),v++),P=b}let D=P[Gi];if(D)D>=96&&x?(G[M++]=((D-=96)&31)+96,G[M++]=D>>5):G[M++]=D;else{D=s.nextId,D||(D=64),D<y&&this.shouldShareStructure&&!this.shouldShareStructure(I)?(D=s.nextOwnId,D<N||(D=y),s.nextOwnId=D+1):(D>=N&&(D=y),s.nextId=D+1);let Z=I.highByte=D>=96&&x?D-96>>5:-1;P[Gi]=D,s[D-64]=I,D<y?(I.isShared=!0,s.sharedLength=D-63,n=!0,Z>=0?(G[M++]=(D&31)+96,G[M++]=Z):G[M++]=D):(Z>=0?(G[M++]=213,G[M++]=114,G[M++]=(D&31)+96,G[M++]=Z):(G[M++]=212,G[M++]=114,G[M++]=D),v&&(w+=B*v),L.length>=m&&(L.shift()[Gi]=0),L.push(P),S(I))}for(let Z=0,V=I.length;Z<V;Z++)S(h[I[Z]])},T=h=>{let I;if(h>16777216){if(h-r>lu)throw new Error("Packed buffer would be larger than maximum buffer size");I=Math.min(lu,Math.round(Math.max((h-r)*(h>67108864?1.25:2),4194304)/4096)*4096)}else I=(Math.max(h-r<<2,G.length-1)>>12)+1<<12;let b=new Ka(I);return Ze=new DataView(b.buffer,0,I),G.copy?G.copy(b,0,r,h):b.set(G.slice(r,h)),M-=r,r=0,gr=b.length-10,G=b}}useBuffer(e){G=e,Ze=new DataView(G.buffer,G.byteOffset,G.byteLength),M=0}};Ja=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,cs];ys=[{pack(i,e,t){let r=i.getTime()/1e3;if((this.useTimestamp32||i.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:o,targetView:n,position:s}=e(6);o[s++]=214,o[s++]=255,n.setUint32(s,r)}else if(r>0&&r<17179869184){let{target:o,targetView:n,position:s}=e(10);o[s++]=215,o[s++]=255,n.setUint32(s,i.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),n.setUint32(s+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return e(0),t(this.onInvalidDate());let{target:o,targetView:n,position:s}=e(3);o[s++]=212,o[s++]=255,o[s++]=255}else{let{target:o,targetView:n,position:s}=e(15);o[s++]=199,o[s++]=12,o[s++]=255,n.setUint32(s,i.getMilliseconds()*1e6),n.setBigInt64(s+4,BigInt(Math.floor(r)))}}},{pack(i,e,t){let r=Array.from(i),{target:o,position:n}=e(this.structuredClone?3:0);this.structuredClone&&(o[n++]=212,o[n++]=115,o[n++]=0),t(r)}},{pack(i,e,t){let{target:r,position:o}=e(this.structuredClone?3:0);this.structuredClone&&(r[o++]=212,r[o++]=101,r[o++]=0),t([i.name,i.message])}},{pack(i,e,t){let{target:r,position:o}=e(this.structuredClone?3:0);this.structuredClone&&(r[o++]=212,r[o++]=120,r[o++]=0),t([i.source,i.flags])}},{pack(i,e){this.structuredClone?cu(i,16,e):du(gs?Buffer.from(i):new Uint8Array(i),e)}},{pack(i,e){let t=i.constructor;t!==au&&this.structuredClone?cu(i,$a.indexOf(t.name),e):du(i,e)}},{pack(i,e){let{target:t,position:r}=e(1);t[r]=193}}];function cu(i,e,t,r){let o=i.byteLength;if(o+1<256){var{target:n,position:s}=t(4+o);n[s++]=199,n[s++]=o+1}else if(o+1<65536){var{target:n,position:s}=t(5+o);n[s++]=200,n[s++]=o+1>>8,n[s++]=o+1&255}else{var{target:n,position:s,targetView:a}=t(7+o);n[s++]=201,a.setUint32(s,o+1),s+=4}n[s++]=116,n[s++]=e,n.set(new Uint8Array(i.buffer,i.byteOffset,i.byteLength),s)}function du(i,e){let t=i.byteLength;var r,o;if(t<256){var{target:r,position:o}=e(t+2);r[o++]=196,r[o++]=t}else if(t<65536){var{target:r,position:o}=e(t+3);r[o++]=197,r[o++]=t>>8,r[o++]=t&255}else{var{target:r,position:o,targetView:n}=e(t+5);r[o++]=198,n.setUint32(o,t),o+=4}r.set(i,o)}function Mb(i,e,t,r){let o=i.length;switch(o){case 1:e[t++]=212;break;case 2:e[t++]=213;break;case 4:e[t++]=214;break;case 8:e[t++]=215;break;case 16:e[t++]=216;break;default:o<256?(e[t++]=199,e[t++]=o):o<65536?(e[t++]=200,e[t++]=o>>8,e[t++]=o&255):(e[t++]=201,e[t++]=o>>24,e[t++]=o>>16&255,e[t++]=o>>8&255,e[t++]=o&255)}return e[t++]=r,e.set(i,t),t+=o,t}function Pb(i,e){let t,r=e.length*6,o=i.length-r;for(e.sort((n,s)=>n.offset>s.offset?1:-1);t=e.pop();){let n=t.offset,s=t.id;i.copyWithin(n+r,n,o),r-=6;let a=n+r;i[a++]=214,i[a++]=105,i[a++]=s>>24,i[a++]=s>>16&255,i[a++]=s>>8&255,i[a++]=s&255,o=n}return i}function vo(i){if(i.Class){if(!i.pack&&!i.write)throw new Error("Extension has no pack or write function");if(i.pack&&!i.type)throw new Error("Extension has no type (numeric code to identify the extension)");Ja.unshift(i.Class),ys.unshift(i)}nu(i)}var pu=new ri({useRecords:!1}),Ob=pu.pack,Ab=pu.pack;var uu=512,jb=1024;var hu=new ri({structuredClone:!0});vo({Class:nr.prototype.constructor,type:1,write(i){return O({},i)},read(i){return Object.setPrototypeOf(i,nr.prototype),i}});vo({Class:Ke.prototype.constructor,type:2,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,Ke.prototype),i}});vo({Class:sr.prototype.constructor,type:3,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,sr.prototype),i}});vo({Class:as.prototype.constructor,type:4,write(i){return i.id},read(i){return new as(i)}});vo({Class:ls.prototype.constructor,type:5,write(i){return i.data},read(i){return new ls(i)}});function _b(i){var e=0;if(i.length===0)return e;for(let t=0;t<i.length;t++){let r=i[t];e=(e<<5)-e+r,e=e&e}return e}var xs;(function(r){function i(o){return hu.pack(o)}r.serialize=i;function e(o){return hu.unpack(o)}r.deserialize=e;function t(o){return _b(i(o)).toString()}r.checksum=t})(xs||(xs={}));var bs;(function(t){t.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function e(r){return t.all.includes(r)}t.is=e})(bs||(bs={}));var vs;(function(t){function i(r){return e(r)}t.defaultData=i;function e(r){if(r==="PointLight")return{type:r,color:mr.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,depth:2500,helper:!0};if(r==="SpotLight")return{type:r,color:mr.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:2500,helper:!0};if(r==="DirectionalLight")return{type:r,color:mr.white,intensity:1,shadows:!0,size:2500,depth:2500,helper:!0};throw new Error("not implemented")}})(vs||(vs={}));var oi;(function(r){r[r.Front=0]="Front",r[r.Back=1]="Back",r[r.Double=2]="Double"})(oi||(oi={}));var Xa;(function(t){t.defaultData={castShadow:!0,receiveShadow:!0};function e(r,o){return r.castShadow===o.castShadow&&r.receiveShadow===o.receiveShadow}t.equals=e})(Xa||(Xa={}));var Za;(function(t){t.defaultData={flatShading:!1,wireframe:!1,side:0};function e(r,o){return r.flatShading===o.flatShading&&r.side===o.side&&r.wireframe===o.wireframe}t.equals=e})(Za||(Za={}));var Ss;(function(e){e.defaultData=$(O(O({},Za.defaultData),Xa.defaultData),{cloner:null})})(Ss||(Ss={}));var Tt;(function(o){o[o.Left=1]="Left",o[o.Right=2]="Right",o[o.Center=3]="Center",o[o.Justify=4]="Justify"})(Tt||(Tt={}));var Br;(function(r){r[r.Top=1]="Top",r[r.Center=2]="Center",r[r.Bottom=3]="Bottom"})(Br||(Br={}));var eo;(function(r){r[r.None=1]="None",r[r.Upper=2]="Upper",r[r.Lower=3]="Lower"})(eo||(eo={}));var ws;(function(e){e.defaultData={width:100,height:100,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.5,letterSpacing:1,text:"",textTransform:1,color:mr.fromHexAndA(6974058,1),alpha:1,font:"roboto_regular"}})(ws||(ws={}));var it;(function(o){o[o.Normal=0]="Normal",o[o.Multiply=1]="Multiply",o[o.Screen=2]="Screen",o[o.Overlay=3]="Overlay"})(it||(it={}));var ii;(function(r){r[r.Linear=0]="Linear",r[r.Radial=1]="Radial",r[r.Polar=2]="Polar"})(ii||(ii={}));var Ns;(function(r){r[r.RepeatWrapping=1e3]="RepeatWrapping",r[r.ClampToEdgeWrapping=1001]="ClampToEdgeWrapping",r[r.MirroredRepeatWrapping=1002]="MirroredRepeatWrapping"})(Ns||(Ns={}));var Cs;(function(o){o[o.UV=0]="UV",o[o.Planar=1]="Planar",o[o.Spherical=2]="Spherical",o[o.Cylindrical=3]="Cylindrical"})(Cs||(Cs={}));var Ls;(function(n){n[n.Simplex=0]="Simplex",n[n.SimplexFractal=1]="SimplexFractal",n[n.Ashima=2]="Ashima",n[n.Fbm=3]="Fbm",n[n.Perlin=4]="Perlin"})(Ls||(Ls={}));var ni;(function(r){function i(o,n){return o==="light"&&n?e(n):t(o)}r.defaultData=i;function e(o){switch(o){case"basic":return{type:"light",category:"basic",alpha:1,visible:!0,mode:0};case"phong":return{category:"phong",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1,visible:!0,mode:0};case"toon":return{category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1,visible:!0,mode:0};case"lambert":return{category:"lambert",emissive:{r:.2,g:.2,b:.2,a:1},type:"light",alpha:1,visible:!0,mode:0};case"physical":return{category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0}}}function t(o){switch(o){case"texture":return{alpha:1,visible:!0,size:[128,128],mode:0,axis:Yo.x,type:"texture",projection:0,texture:{image:"image_0",wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!0};case"color":return{type:"color",alpha:1,visible:!0,mode:0,color:Rt.fromHex(4737101)};case"depth":return{type:"depth",alpha:1,visible:!0,mode:0,gradientType:1,smooth:!1,isVector:!0,isWorldSpace:!1,origin:[0,0,0],direction:[1,0,0],colors:[[1,1,1,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]],steps:[0,1,1,1,1,1,1,1,1,1],num:2,near:50,far:200};case"normal":return{type:"normal",alpha:1,visible:!0,mode:0,cnormal:[1,1,1]};case"gradient":return{type:"gradient",alpha:1,visible:!0,mode:0,gradientType:0,smooth:!1,colors:[[0,0,0,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,1,1,1,1,1,1,1,1,1],num:2,angle:0,offset:[0,0],morph:[0,0]};case"noise":return{type:"noise",alpha:1,visible:!0,mode:0,size:[100,100,100],noiseType:0,scale:1,move:1,colorA:$(O({},Rt.fromHex(6710886)),{a:1}),colorB:$(O({},Rt.fromHex(6710886)),{a:1}),colorC:$(O({},Rt.fromHex(16777215)),{a:1}),colorD:$(O({},Rt.fromHex(16777215)),{a:1}),distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8]};case"fresnel":return{type:"fresnel",alpha:1,visible:!0,mode:0,color:mr.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{type:"rainbow",alpha:1,visible:!0,mode:0,filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"matcap":return{type:"matcap",alpha:1,visible:!0,mode:0,texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0]}};case"transmission":return{type:"transmission",alpha:1,visible:!0,mode:0,thickness:10,ior:1.5,roughness:1};case"displace":return{type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,visible:!0}}}})(ni||(ni={}));var si;(function(a){function i(l){return!l.layers.some(d=>{if(d.data.type==="texture"&&d.data.projection!==0||d.data.type==="depth"&&!d.data.isWorldSpace||d.data.type==="noise"||d.data.type==="displace")return!0})&&!t(l)}a.isMergable=i;function e(l){let c="";return l.layers.forEach(d=>{Object.entries(d.data).forEach(([u,p])=>{c+=`${u}${p}`,Array.isArray(p)?p.forEach(f=>c+=`${f}`):typeof p=="object"?Object.values(p).forEach(f=>{typeof f=="number"?c+=`${f.toFixed(4)}`:c+=`${f}`}):c+=`${p}`})}),c}a.getHash=e;function t(l){let c=0;for(let d of l.layers)"alpha"in d.data&&d.data.type!=="light"&&d.data.type!=="fresnel"&&(c+=(1-c)*d.data.alpha);return c<1}a.isTransparent=t;function r(){return{layers:new Ke}}a.defaultEmptyData=r;function o(l="layer1",c="layer2"){return n("phong",l,c)}a.defaultData=o;function n(l,c="layer1",d="layer2"){let u=new Ke;return u.push({fi:0,data:ni.defaultData("light",l),id:c}),u.push({fi:1,data:ni.defaultData("color"),id:d}),{layers:u}}a.defaultTwoLayerData=n;function s(l,c="basic",d="layer1",u="layer2"){let p=ni.defaultData("texture");Object.assign(p.texture,{image:l});let f=new Ke;return f.push({fi:0,data:p,id:d}),f.push({fi:1,data:ni.defaultData("light",c),id:u}),{layers:f}}a.defaultTwoLayerTextureData=s})(si||(si={}));var ai;(function(r){function i(){return{points:new Ke,roundness:0,shapeHoles:[],isClosed:!1}}r.defaultData=i;function e(o,n){let{points:s}=n;if(s){for(let a of s)if(a.data.position[0]===o[0]&&a.data.position[1]===o[1])return!0}return!1}r.isOverlappingExistingPoint=e;function t(o,n){let s=o.controlNext,a=n.controlPrevious;return o.position[0]===s.position[0]&&o.position[1]===s.position[1]&&n.position[0]===a.position[0]&&n.position[1]===a.position[1]}r.isStraightLine=t})(ai||(ai={}));var Ts;(function(e){function i(t){return t==="PolygonGeometry"||t==="RectangleGeometry"||t==="StarGeometry"||t==="TriangleGeometry"||t==="EllipseGeometry"}e.is2DParametricMesh=i})(Ts||(Ts={}));var Is;(function(e){function i(t){if(t==="RectangleGeometry")return{width:320,height:320,type:t,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1,surfaceMaxCount:1};if(t==="VectorGeometry")return{width:100,height:100,type:t,subdivisions:12,shape:ai.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1,surfaceMaxCount:1};throw new Error("not implemented")}e.defaultData=i})(Is||(Is={}));var zi;(function(o){o.identity=$(O({},ts.identity),{hiddenMatrix:Zr.identity});function e(n){return{position:n.position,rotation:n.rotation,scale:n.scale,hiddenMatrix:n.hiddenMatrix}}o.fromObject=e;function t(n,s){return{position:(s==null?void 0:s.position)||n.position,rotation:(s==null?void 0:s.rotation)||n.rotation,scale:(s==null?void 0:s.scale)||n.scale,hiddenMatrix:(s==null?void 0:s.hiddenMatrix)||n.hiddenMatrix}}o.merge=t;function r(n,s){return{position:ei.isEqual(n.position,s.position)?null:s.position,rotation:ei.isEqual(n.rotation,s.rotation)?null:s.rotation,scale:ei.isEqual(n.scale,s.scale)?null:s.scale,hiddenMatrix:Zr.isEqual(n.hiddenMatrix,s.hiddenMatrix)?null:s.hiddenMatrix}}o.diff=r})(zi||(zi={}));var to;(function(e){e.defaultData=O({states:new Ke,events:new Ke,visible:!0,raycastLock:!1},zi.identity)})(to||(to={}));var mu;(function(e){e.defaultData=O({type:"Empty"},to.defaultData)})(mu||(mu={}));var Qa;(function(e){e.defaultData=O(O({type:"Mesh"},to.defaultData),Ss.defaultData)})(Qa||(Qa={}));var fu;(function(e){e.defaultData=O(O({type:"TextFrame"},to.defaultData),ws.defaultData)})(fu||(fu={}));var Ms;(function(e){e.defaultData=O(O(O({},to.defaultData),zi.identity),xo.defaultData)})(Ms||(Ms={}));var yu;(function(e){function i(t){return O(O({},to.defaultData),vs.defaultData(t))}e.defaultData=i})(yu||(yu={}));var gu;(function(t){t.defaultCamera=O({position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:Zr.identity,name:"Play Camera",visible:!0,raycastLock:!1,states:new Ke,events:new Ke},xo.defaultData),t.defaultMeshObject=$(O(O({name:"Rectangle"},to.defaultData),Qa.defaultData),{geometry:Is.defaultData("RectangleGeometry"),material:si.defaultTwoLayerData("basic","layer1","layer2")})})(gu||(gu={}));var xu;(function(t){function i(r,o){if(o===void 0)return r;let n=O({},r);return"material"in n&&"material"in o&&o.material&&(n.material=za(n.material,s=>{if(typeof s!="string")for(let[a,l]of Object.entries(o.material.layers)){let c=s.layers.data(a);c&&go(c,l)}}).data),n.materials&&o.materials&&(n.materials=za(n.materials,s=>{var a,l;for(let c=0;c<n.materials.length;c++){let d=o.materials[c];if(typeof d!="string")for(let[u,p]of Object.entries(d.layers)){let f=(l=(a=s[c])==null?void 0:a.layers)==null?void 0:l.data(u);f&&go(f,p)}}}).data),n}t.patchMaterialState=i;function e(r,o){var s,a;if(o===void 0)return r;let n=O({},r);if(Object.assign(n,zi.merge(n,o)),Qo.is(r.type)){n.orthographic=O({},n.orthographic),n.perspective=O({},n.perspective);let l=o;((s=l.orthographic)==null?void 0:s.zoom)!==void 0&&(n.orthographic.zoom=l.orthographic.zoom),((a=l.perspective)==null?void 0:a.zoom)!==void 0&&(n.perspective.zoom=l.perspective.zoom)}else if(r.type==="Mesh")n.geometry=O({},n.geometry),Object.assign(n.geometry,o.geometry),n=i(n,o);else if(bs.is(r.type)){let l=o;n.intensity!==void 0&&(n.intensity=l.intensity),l.color!==void 0&&(n.color=Rt.clone(l.color))}return n}t.patch=e})(xu||(xu={}));var nt=5855577;var bu=2857471;var Ya=15711266;import{DoubleSide as Db,Mesh as Bb,MeshBasicMaterial as Gb,ShapeBufferGeometry as zb,Vector2 as Eb,Vector3 as Fb}from"three";import{FontLoader as Rb}from"three/examples/jsm/loaders/FontLoader.js";var Qe=class extends Bb{constructor({char:e,originalChar:t,fontFamily:r,letterSpacing:o,fontSize:n,LOD:s=16},a=new Gb({color:0,opacity:1,visible:!0,transparent:!0,side:Db})){let l=Qe.loadChar(e,r,s);super(l.geometry,a);this.char=e,this.originalChar=t!=null?t:e,this.fontFamily=r,this.letterSpacing=o,this.fontSize=n,this.LOD=s,this.resolution=l.resolution,this.glyphsHa=l.glyphsHa,this.localPosition=new Eb,this.charSize=0,this.geometry.userData={type:"CharacterGeometry",parameters:{char:this.char,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,lod:this.LOD,resolution:this.resolution,charSize:this.charSize,localPosition:this.localPosition}},this.updateFontSize(this.fontSize)}static get FONTS_PATH(){return Qe._fontPath}static set FONTS_PATH(e){Qe._fontPath=e}updatePosition(e,t){this.localPosition.copy(e);let r=new Fb(this.localPosition.x,-this.localPosition.y,0);this.position.copy(r).add(t)}updateFontSize(e){let t=e/this.resolution;this.fontSize=e,this.scale.set(this.fontSize,this.fontSize,1),this.charSize=this.glyphsHa*t*this.letterSpacing}updateFontFamily(e){if(this.fontFamily===e)return;this.fontFamily=e;let t=Qe.loadChar(this.char,e,this.LOD);this.geometry=t.geometry,this.resolution=t.resolution,this.glyphsHa=t.glyphsHa,this.geometry.userData={type:"CharacterGeometry",parameters:{char:this.char,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,lod:this.LOD,resolution:this.resolution,charSize:this.charSize,localPosition:this.localPosition}},this.updateFontSize(this.fontSize)}updateChar(e){if(this.char===e)return;this.char=e;let t=Qe.loadChar(e,this.fontFamily,this.LOD);this.geometry=t.geometry,this.resolution=t.resolution,this.glyphsHa=t.glyphsHa,this.geometry.userData={type:"CharacterGeometry",parameters:{char:this.char,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,lod:this.LOD,resolution:this.resolution,charSize:this.charSize,localPosition:this.localPosition}},this.updateFontSize(this.fontSize)}updateLetterSpacing(e){this.letterSpacing!==e&&(this.letterSpacing=e,this.updateFontSize(this.fontSize))}updateLOD(e){if(this.LOD===e)return;this.LOD=e;let t=Qe.loadChar(this.char,this.fontFamily,this.LOD);this.geometry=t.geometry,this.resolution=t.resolution,this.glyphsHa=t.glyphsHa,this.geometry.userData={type:"CharacterGeometry",parameters:{char:this.char,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,lod:this.LOD,resolution:this.resolution,charSize:this.charSize,localPosition:this.localPosition}},this.updateFontSize(this.fontSize)}clone(){let e={char:this.char,originalChar:this.originalChar,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,LOD:this.LOD};return new Qe(e).copy(this)}static loadFont(e){return new Promise(function(t,r){Qe.fontCache[e]?t(Qe.fontCache[e]):new Rb().load(Qe.FONTS_PATH+e+".json",n=>{Qe.fontCache[e]=n,t(n)},void 0,r)})}static loadChar(e,t,r){if(Qe.charCache[e]){if(Qe.charCache[e][r]&&Qe.charCache[e][r].fontFamily===t)return Qe.charCache[e][r]}else Qe.charCache[e]={};let o=Qe.fontCache[t],n=o.generateShapes(e,1);return Qe.charCache[e][r]={geometry:new zb(n,r),fontFamily:t,resolution:o.data.resolution,glyphsHa:o.data.glyphs[e].ha},Qe.charCache[e][r]}},_t=Qe;_t.charCache={},_t.fontCache={},_t._fontPath="/_assets/_fonts/";import{DoubleSide as Ta,MeshBasicMaterial as gm,Vector3 as xm,Object3D as kw}from"three";import{Mesh as vS}from"three";import{BufferGeometry as xj,ConeBufferGeometry as kb,Float32BufferAttribute as bj,Vector2 as vj,Vector3 as Sj}from"three";import{BufferGeometry as Vb,CylinderBufferGeometry as Ub,Float32BufferAttribute as el,Vector2 as ar,Vector3 as Ps}from"three";var vu=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var s,a,l,c,d;let t=Object.assign({},(s=e==null?void 0:e.parameters)!=null?s:{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:0,cornerSegments:8,hollow:0},i.parameters),r=t.width/2,o=(a=t.radiusTop)!=null?a:r,n=(l=t.radiusBottom)!=null?l:r;return o===n?(o=r,n=r):o>n?(o=r,n=n*r/o):(o=o*r/n,n=r),{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((c=t.height)!=null?c:t.width),depth:Math.abs((d=t.depth)!=null?d:t.width),radiusTop:o,radiusBottom:n})}}static build(i){let{width:e,depth:t,height:r,radialSegments:o,heightSegments:n,openEnded:s,thetaStart:a,thetaLength:l,radiusTop:c,radiusBottom:d,cornerRadius:u,cornerSegments:p,hollow:f}=i.parameters,m;return u||f?m=new Os(c,d,r,o,n,s,a,l*Math.PI/180,u,u,p,f):m=new Ub(c,d,r,o,n,s,a,l*Math.PI/180),m.scale(1,1,t/e),Object.assign(m,{userData:$(O({},i),{type:"CylinderGeometry"})})}};function ro(i,e,t){t.x=i.x*e.x,t.y=i.y,t.z=i.x*e.y}function Su(i){return new ar(i.y,-i.x)}var Os=class extends Vb{constructor(e,t,r,o,n,s,a,l,c,d,u,p,f=!1){super();this.type="RoundedCylinderBufferGeometry",e=e!==void 0?e:1,t=t!==void 0?t:1,r=r||1,o=Math.floor(o)||8,n=Math.floor(n)||1,s=s!==void 0?s:!1,a=a!==void 0?a:0,l=l!==void 0?l:Math.PI*2,s&&(c=0,d=0);let m=[],x=[],y=[],N=[],L=0,w=r/2,B=new Ps,S=new Ps;f&&e==0&&(e=c),f&&t==0&&(t=d);let _=new ar(e,w),T=new ar(t,-w),h=null,I=null,b=null,P=null,v=_.clone().sub(T),D=0,Z=0,V=0;p>0&&(D=Math.min(e,t)*(1-p),Z=e-D,V=t-D);let ie=_.clone();ie.x-=D;let oe=Math.PI-v.angle(),ge=v.angle(),xe=Math.tan(ge/2),A=Math.tan(oe/2),j=xe+A,g=p?j:A,z=p?j:xe;if(c=Math.min(c,(e-Z)/g,v.length()/j),d=Math.min(d,(t-V)/z,v.length()/j),c>0){let E=c/xe;h=_.clone().sub(new ar(E,c)),p&&(b=h.clone(),b.x-=D-j*c),_.sub(v.clone().setLength(E))}if(d>0){let E=d/A;I=T.clone().sub(new ar(E,-d)),T.add(v.clone().setLength(E)),p&&(P=I.clone(),P.x-=D-j*d,ie.sub(v.clone().setLength(E)))}v=_.clone().sub(T);let R=v.length()<.5,U=[];for(let E=0;E<=o;E++){let H=[],k=E/o,se=k*l+a,F=new ar(Math.sin(se),Math.cos(se));P&&I?(q(H,k,F,oe,d,P,-1,!0),q(H,k,F,ge,d,I,-1,!1)):I?(W(H,F,I.x,0,-1),q(H,k,F,ge,d,I,-1,!1)):s||W(H,F,t,V,-1);let K=Su(v).normalize();if(ro(K,F,B),!R)for(let X=0;X<=n;X++){let te=X/n,he=v.clone().multiplyScalar(te).add(T);ro(he,F,S),x.push(S.x,S.y,S.z),y.push(B.x,B.y,B.z),N.push(k,.5+S.y/r),H.push(L++)}if(b&&h?(q(H,k,F,oe,c,h,1,!1),q(H,k,F,ge,c,b,1,!0)):h?(q(H,k,F,oe,c,h,1,!1),W(H,F,h.x,0,1)):s||W(H,F,e,Z,1),p&&!R){let X=Su(v).multiplyScalar(-1).normalize();ro(X,F,B);for(let te=0;te<=n;te++){let he=te/n,Y=v.clone().multiplyScalar(-he).add(ie);ro(Y,F,S),x.push(S.x,S.y,S.z),y.push(B.x,B.y,B.z),N.push(k,.5+S.y/r),H.push(L++)}}p&&!s&&H.push(H[0]),U.push(H)}for(let E=0;E<U.length-1;E++)for(let H=0;H<U[0].length-1;H++){if(s&&p&&H==n)continue;let k=U[E][H],se=U[E+1][H],F=U[E+1][H+1],K=U[E][H+1],X=x[F*3+0],te=x[F*3+2];m.push(k,se,K),(X!=0||te!=0)&&m.push(se,F,K)}l<Math.PI*2&&(J(-1,U[0],a),J(1,U[U.length-1],a+l)),this.setIndex(m),this.setAttribute("position",new el(x,3)),this.setAttribute("normal",new el(y,3)),this.setAttribute("uv",new el(N,2));function q(E,H,k,se,F,K,X,te){for(let he=0;he<u+1;he++){let Y=he/u,ne=X<0?Y:1-Y;te&&(ne-=1),ne*=se;let Se=new ar(Math.sin(ne),Math.cos(ne)*X),me=Se.clone().multiplyScalar(F).add(K);ro(me,k,S),x.push(S.x,S.y,S.z),ro(Se,k,B),y.push(B.x,B.y,B.z),N.push(H,.5+S.y/r),E.push(L++)}}function W(E,H,k,se,F){let K=new Ps,X=new ar,te=[k,se];F<0&&te.reverse();for(let he of te)X.set(he,w*F),ro(X,H,K),x.push(K.x,K.y,K.z),y.push(0,F,0),N.push(.5,.5),E.push(L++)}function J(E,H,k){let se=new ar(Math.sin(k),Math.cos(k)),F=new ar(-Math.cos(k),Math.sin(k)),K=new Ps,X=E<0?(Y,ne,Se)=>m.push(Y,ne,Se):(Y,ne,Se)=>m.push(Y,Se,ne),te=new ar((e+t+Z+V)/4,0);ro(te,se,K),x.push(K.x,K.y,K.z),y.push(F.x,0,F.y),N.push(.5,.5);let he=L++;for(let Y of H){let ne=x.slice(Y*3,Y*3+3);x.push(...ne),y.push(F.x,0,F.y);let Se=N.slice(Y*2,Y*2+2);N.push(...Se),L++}for(let Y=he+1;Y<L-1;Y++)X(he,Y,Y+1);X(he,L-1,he+1)}}};var wu=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,o,n;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:0,cornerRadiusBottom:0,cornerSegments:8},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((o=t.height)!=null?o:t.width),depth:Math.abs((n=t.depth)!=null?n:t.width)})}}static build(i){let{width:e,depth:t,height:r,radialSegments:o,heightSegments:n,openEnded:s,thetaStart:a,thetaLength:l,cornerRadiusTop:c,cornerRadiusBottom:d,cornerSegments:u}=i.parameters,p;return c>0||d>0||l<360?p=new Os(0,e/2,r,o,n,s,a,l*Math.PI/180,c,d,u,0,!0):p=new kb(e/2,r,o,n,s),p.scale(1,1,t/e),Object.assign(p,{userData:$(O({},i),{type:"ConeGeometry"})})}};import{BoxBufferGeometry as Hb,BufferGeometry as qb,Float32BufferAttribute as tl,Vector3 as Ei}from"three";var Nu=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,o,n;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:0,cornerSegments:8},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((o=t.height)!=null?o:t.width),depth:Math.abs((n=t.depth)!=null?n:t.width)})}}static build(i){let{width:e,height:t,depth:r,widthSegments:o,heightSegments:n,depthSegments:s,cornerRadius:a,cornerSegments:l}=i.parameters,c;return a==0?c=new Hb(e,t,r,o,n,s):c=new Cu(e,t,r,o,n,s,a,l),Object.assign(c,{userData:$(O({},i),{type:"CubeGeometry"})})}},rl=Math.PI/2,Cu=class extends qb{constructor(e=1,t=1,r=1,o=1,n=1,s=1,a=0,l=4){super();this.type="BoxBufferGeometry";let c=this;o=Math.floor(o),n=Math.floor(n),s=Math.floor(s),l=Math.floor(l),a=Math.min(a,e/2,t/2,r/2);let d=[],u=[],p=[],f=[],m=0,x=0;y("z","y","x",-1,-1,r,t,e,s,n,0),y("z","y","x",1,-1,r,t,-e,s,n,1),y("x","z","y",1,1,e,r,t,o,s,2),y("x","z","y",1,-1,e,r,-t,o,s,3),y("x","y","z",1,-1,e,t,r,o,n,4),y("x","y","z",-1,-1,e,t,-r,o,n,5),a>0&&(N("z","y","x",-1,-1,1,r,t,e,s,0),N("z","y","x",1,-1,-1,r,t,e,s,1),N("z","y","x",-1,1,-1,r,t,e,s,1),N("z","y","x",1,1,1,r,t,e,s,0),N("x","y","z",-1,-1,-1,e,t,r,o,0),N("x","y","z",1,-1,1,e,t,r,o,1),N("x","y","z",-1,1,1,e,t,r,o,0),N("x","y","z",1,1,-1,e,t,r,o,1),N("y","x","z",-1,-1,1,t,e,r,n,0),N("y","x","z",1,-1,-1,t,e,r,n,1),N("y","x","z",1,1,1,t,e,r,n,1),N("y","x","z",-1,1,-1,t,e,r,n,0),L(1,1,1),L(-1,1,1),L(1,-1,1),L(-1,-1,1),L(1,1,-1),L(-1,1,-1),L(1,-1,-1),L(-1,-1,-1)),this.setIndex(d),this.setAttribute("position",new tl(u,3)),this.setAttribute("normal",new tl(p,3)),this.setAttribute("uv",new tl(f,2));function y(w,B,S,_,T,h,I,b,P,v,D){let Z=(h-2*a)/P,V=(I-2*a)/v,ie=h/2-a,oe=I/2-a,ge=b/2,xe=P+1,A=v+1,j=0,g=0,z=new Ei;for(let R=0;R<A;R++){let U=R*V-oe;for(let q=0;q<xe;q++){let W=q*Z-ie;z[w]=W*_,z[B]=U*T,z[S]=ge,u.push(z.x,z.y,z.z),z[w]=0,z[B]=0,z[S]=b>0?1:-1,p.push(z.x,z.y,z.z),f.push(q/P),f.push(1-R/v),j+=1}}for(let R=0;R<v;R++)for(let U=0;U<P;U++){let q=m+U+xe*R,W=m+U+xe*(R+1),J=m+(U+1)+xe*(R+1),E=m+(U+1)+xe*R;d.push(q,W,E),d.push(W,J,E),g+=6}c.addGroup(x,g,D),x+=g,m+=j}function N(w,B,S,_,T,h,I,b,P,v,D){let Z=(I-2*a)/v,V=I/2-a,ie=b/2-a,oe=P/2,ge=v+1,xe=0,A=0,j=new Ei,g=new Ei;for(let z=0;z<l+1;z++){let R=z/l*rl,U=Math.sin(R)*a,q=(1-Math.cos(R))*a,W=Math.sin(R),J=Math.cos(R);j[B]=(ie+U)*T,j[S]=(oe-q)*h,g[w]=0,g[B]=W*Math.sign(j[B]),g[S]=J*Math.sign(j[S]);for(let E=0;E<ge;E++){let H=E*Z-V;j[w]=H*_,u.push(j.x,j.y,j.z),p.push(g.x,g.y,g.z),f.push(E/v),f.push(0),xe+=1}}for(let z=0;z<l;z++)for(let R=0;R<v;R++){let U=m+R+ge*z,q=m+R+ge*(z+1),W=m+(R+1)+ge*(z+1),J=m+(R+1)+ge*z;d.push(U,q,J),d.push(q,W,J),A+=6}c.addGroup(x,A,D),x+=A,m+=xe}function L(w,B,S){let _=new Ei,T=new Ei(e/2,t/2,r/2);T.subScalar(a);let h=[],I=w*B*S>0?(P,v,D)=>d.push(P,v,D):(P,v,D)=>d.push(P,D,v);for(let P=0;P<=l;P++){let v=[],D=rl*(1-P/l),Z=Math.cos(D),V=Math.sin(D),ie=0;for(let oe=0;oe<=P;oe++){let ge=Math.cos(ie),xe=Math.sin(ie);_.x=Z*ge,_.y=V,_.z=Z*xe;let A=T.clone().addScaledVector(_,a);u.push(w*A.x,B*A.y,S*A.z),p.push(w*_.x,B*_.y,S*_.z),f.push(0,0),v.push(m++),ie+=rl/P}h.push(v)}let b=h.length-1;for(let P=0;P<b;P++){let v=h[P],D=h[P+1],Z=v.length-1;I(v[0],D[1],D[0]);for(let V=1;V<=Z;V++)I(v[V-1],v[V],D[V]),I(v[V],D[V+1],D[V])}}}};import{BufferGeometry as Wb,Float32BufferAttribute as ol,Triangle as $b,Vector3 as Gr,Vector2 as il}from"three";var So=class extends Wb{constructor(e=[],t=[],r="",o=1,n=.2,s=4){super();this.type="PolyhedronGeometryRound";let a=[],l=[],c=[];d(),u(),this.setAttribute("position",new ol(a,3)),this.setAttribute("normal",new ol(c,3)),this.setAttribute("uv",new ol(l,2));return;function d(){var xe;n=Math.min(1-1e-5,n),n==0&&(s=0);let f={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[r],m=new Gr,x=m.clone(),y=new $b,N=n*o,L=o-N,w=s+1,B=new Gr,S=(A,j)=>B.subVectors(A,j).normalize(),_=(A,j)=>Array(A).fill(void 0).map(j),T=_(e.length/3,(A,j)=>new Gr().fromArray(e,j*3).setLength(o)),h=[],I=1e6;for(let A=0;A<T.length;A++){let j=T[A],g=[],z,R,U,q=1e10,W=-1;for(;(W=t.indexOf(A,W+1))!=-1;){let k=W-W%3;z=t[k+(W+1)%3],R=t[k+(W+2)%3],U=j.distanceToSquared(T[z]),q=Math.min(q,U),g.push([z,R,U])}q+=1e-6;let J=[],E=0,H=g.length;for(let k=0;k<H;k++){[z,R,U]=g[E];let se=((xe=h[z])==null?void 0:xe.includes(A))==!0;U<=q&&J.push(z+ +se*I),E=g.findIndex(F=>F[0]==R)}h.push(J)}let b=[];{let A=0,j=0,g,z,R=f==3;for(let U=0;U<=s;U++){g=U*(U+1)/2,z=(U+1)*(U+2)/2;for(let q=0;q<s-U;q++)[A,j]=[g+q+U+2,z+q+U+3],b.push(g,z,...R?[j,g]:[A,z],j,A),[g,z]=[A,j];b.push(g,z,g+s+2)}}let P=m.clone(),v=m.clone(),D=m.clone(),Z=m.clone(),V=m.clone(),ie=[],oe=_(T.length,()=>_(f,()=>m.clone()));for(let A=0;A<T.length;A++){m.copy(T[A]).normalize(),P.copy(m).multiplyScalar(L);let j=h[A];for(let J=0;J<j.length;J++){let E=j[J],H=j[(J+1)%f];y.setFromPointsAndIndices(T,A,E%I,H%I),y.b.sub(y.a).setLength(1e10).add(y.a),y.c.sub(y.a).setLength(1e10).add(y.a),y.closestPointToPoint(P,oe[A][J])}let g=[],z=[],R=[],U=new Gr;s==0&&[...oe[A]].reduce((J,E)=>J.add(E),U).multiplyScalar(1/f);for(let J=0;J<f;J++){let E=[],H=(J-1+f)%f,k=oe[A][H],se=oe[A][J];m.copy(k).sub(P),x.copy(se).sub(P);let F=P.angleTo(m),K=m.angleTo(x),X=Math.cos(F)*N;s==0?v.copy(U):v.copy(P).setLength(L+X),z.push(X);let te=[v,k,se];for(let he=0;he<2;he++){let Y=te[he],ne=te[he+1];Z.subVectors(Y,P),V.subVectors(ne,P),D.crossVectors(Z,V).normalize();for(let Se=0;Se<w;Se++){let me=[F,K][he]*Se/w;m.copy(Z).applyAxisAngle(D,me).add(P),g.push(m.clone()),he&&(S(m,P),E.push([Se==0?Y:m.clone(),B.clone()]))}he&&(S(ne,P),E.push([ne,B.clone()]))}R.push(E)}ie.push(R);let q=2*w,W=2;for(let J=0;J<f;J++){let E=q*J,H=q*((J+1)%f),k=[g[E]];for(let F=1;F<w;F++){Z=g[E+F],V=g[H+F],k.push(Z);for(let K=1,X=F-W+1;K<=X;K++)m.lerpVectors(Z,V,K/(X+1)),m.sub(P).setLength(z[J]).add(P),k.push(m.clone());k.push(V)}for(let F=0;F<w;F++)k.push(g[F+w+E]);k.push(g[H+w]);let se=b.map(F=>k[F]);a.push(...se.map(F=>[F.x,F.y,F.z]).flat()),c.push(...se.map(F=>(S(F,P),[B.x,B.y,B.z])).flat())}}let ge=[];for(let A=0;A<h.length;A++)for(let j=0;j<f;j++){let g=h[A][j];if(g<I){let z=h[g].findIndex(q=>q%I==A),R=ie[A][j],U=ie[g][z];for(let q=0;q<w;q++){let W=R[q],J=U[w-q],E=R[q+1],H=U[w-(q+1)];[W,J,E,E,J,H].forEach(k=>{a.push(k[0].x,k[0].y,k[0].z),c.push(k[1].x,k[1].y,k[1].z)})}ge.push(R[0][0],U[w][0],R[w][0],U[0][0])}}for(;ge.length;){let A,j,g,z;[A,j]=ge.splice(0,2);let R=[A];for(;A!=j;)R.push(j),g=ge.indexOf(j),z=g%2,j=ge.splice(g-z,2)[1-z];B.subVectors(R[0],R[1]).cross(m.subVectors(R[0],R[2])).normalize();let U=B.dot(R[0])<0;U&&B.negate();for(let q=1;q<=R.length-2;q++)[R[q+ +U],R[q+1-+U],R[0]].forEach(W=>{a.push(W.x,W.y,W.z),c.push(B.x,B.y,B.z)})}}function u(){let p=new Gr;for(let T=0;T<a.length;T+=3){p.x=a[T+0],p.y=a[T+1],p.z=a[T+2];let h=S(p)/2/Math.PI+.5,I=_(p)/Math.PI+.5;l.push(h,1-I)}let f=new Gr,m=new Gr,x=new Gr,y=new Gr,N=new il,L=new il,w=new il,B=(T,h,I,b)=>{b<0&&T.x===1&&(l[h]=T.x-1),I.x===0&&I.z===0&&(l[h]=b/2/Math.PI+.5)};for(let T=0,h=0;T<a.length;T+=9,h+=6){f.set(a[T+0],a[T+1],a[T+2]),m.set(a[T+3],a[T+4],a[T+5]),x.set(a[T+6],a[T+7],a[T+8]),N.set(l[h+0],l[h+1]),L.set(l[h+2],l[h+3]),w.set(l[h+4],l[h+5]),y.copy(f).add(m).add(x).divideScalar(3);let I=S(y);B(N,h+0,f,I),B(L,h+2,m,I),B(w,h+4,x,I)}for(let T=0;T<l.length;T+=6){let h=l[T+0],I=l[T+2],b=l[T+4],P=Math.max(h,I,b),v=Math.min(h,I,b);P>.9&&v<.1&&(h<.2&&(l[T+0]+=1),I<.2&&(l[T+2]+=1),b<.2&&(l[T+4]+=1))}function S(T){return Math.atan2(T.z,-T.x)}function _(T){return Math.atan2(-T.y,Math.sqrt(T.x*T.x+T.z*T.z))}}}static fromJSON(e){return new So(e.vertices,e.indices,e.radius,e.corner,e.cornerSides)}};import{DodecahedronBufferGeometry as Jb}from"three";var Lu=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,o,n;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,detail:0,corner:0,cornerSides:4},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((o=t.height)!=null?o:t.width),depth:Math.abs((n=t.depth)!=null?n:t.width)})}}static build(i){let{width:e,height:t,depth:r,detail:o,corner:n,cornerSides:s}=i.parameters,a=o===0&&n!==0?new As(e*.5,n,s):new Jb(e*.5,o);return a.scale(1,t/e,r/e),Object.assign(a,{userData:$(O({},i),{type:"DodecahedronGeometry"})})}},As=class extends So{constructor(e=1,t=.2,r=4){let o=(1+Math.sqrt(5))/2,n=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,-n,-o,0,-n,o,0,n,-o,0,n,o,-n,-o,0,-n,o,0,n,-o,0,n,o,0,-o,0,-n,o,0,-n,-o,0,n,o,0,n],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],l="DodecahedronGeometry";super(s,a,l,e,t,r);this.type=l}static fromJSON(e){return new As(e.radius,e.corner,e.cornerSides)}};import{EventDispatcher as nv,Plane as sv,Shape as zu,Vector2 as zr,Vector3 as av,MathUtils as pl,LineCurve as ul,QuadraticBezierCurve as Eu,CubicBezierCurve as Ds}from"three";import{CubicBezierCurve as js,EllipseCurve as Kb,LineCurve as _s,LineCurve3 as Xb,MathUtils as Zb,QuadraticBezierCurve as nl,SplineCurve as Qb,Vector2 as lr,Vector3 as Tu}from"three";var Fi=1e-12,Ri=class{constructor(e){this.position=new lr;this.startPosition=new lr;this.uuid=Zb.generateUUID();this.position=e.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(e){this.position.copy(this.startPosition).add(e)}copy(e){return this.position.copy(e.position),this.startPosition.copy(e.startPosition),this}clone(){return new Ri(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},Vi=class extends Ri{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new Vi(this.parent).copy(this)}},br=class extends Ri{constructor(e,t){super(t);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new Vi(this),new Vi(this))}static create(e,t){let r=new br(e,new lr(...t.position));return r.controls[0].position.set(...t.controlPrevious.position),r.controls[1].position.set(...t.controlNext.position),r.roundness=t.roundness,r.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored,r}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 r=0,o=this.controls.length;r<o;r++){let n=this.controls[r];this.position.distanceTo(n.position)<=t?n.position.copy(this.position):n.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 br(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}},sl=i=>i,Ui=new lr,al=new lr,Yb=new lr,ev=new lr,tv=new lr,rv=new lr,Iu=new Tu,Mu=new Tu;function Pu(i){let e=new lr;e.addVectors(i.v0,Ui.subVectors(i.v1,i.v0).multiplyScalar(2/3));let t=new lr;return t.addVectors(i.v2,al.subVectors(i.v1,i.v2).multiplyScalar(2/3)),new js(i.v0,e,t,i.v2)}function ki(i,e,t=Number.EPSILON){return Math.abs(i-e)<t}function ov(i,e,t=Number.EPSILON){return i.distanceTo(e)<t}function iv(i,e,t=Number.EPSILON){return i.distanceTo(e)<t}function ll(i,e,t){let r=Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2)),o=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),n=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2));return Math.acos((o*o+r*r-n*n)/(2*o*r))}function Ou(i,e,t,r,o){let n=Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2)),s=(i.y+e.y)/2,a=(i.x+e.x)/2,l=Math.sqrt(Math.pow(t,2)-Math.pow(n/2,2))*(i.y-e.y)/n,c=Math.sqrt(Math.pow(t,2)-Math.pow(n/2,2))*(e.x-i.x)/n;return r.set(a+l,s+c),o.set(a-l,s-c),[r,o]}function Au(i,e,t){let r=i.distanceTo(t),o=e.distanceTo(t);return r<o?e:i}function ju(i,e,t,r,o,n){let s=e.x-i.x,a=e.y-i.y,l=t.x-i.x,c=t.y-i.y,d=Math.sqrt((s+l)*(s+l)+(a+c)*(a+c)),u;return ll(e,i,t)>Math.PI&&(d*=-1),ki(c,a)?u=(a+c)*(r/d-.5)*8/3/(s-l):u=(s+l)*(r/d-.5)*8/3/(c-a),o.set(e.x-u*a,e.y+u*s),n.set(t.x+u*c,t.y-u*l),[o,n]}function cl(i,e){return i.position.equals(i.controls[1].position)&&e.position.equals(e.controls[0].position)}function _u(i,e,t,r,o=.5){let n=Ui.subVectors(e,i).multiplyScalar(o).add(i),s=al.subVectors(t,e).multiplyScalar(o).add(e),a=Yb.subVectors(r,t).multiplyScalar(o).add(t),l=n,c=ev.subVectors(s,n).multiplyScalar(o).add(n),d=tv.subVectors(a,s).multiplyScalar(o).add(s),u=a,p=rv.subVectors(d,c).multiplyScalar(o).add(c);return[i.x,i.y,l.x,l.y,c.x,c.y,p.x,p.y,d.x,d.y,u.x,u.y,r.x,r.y]}function Du(i,e,t=12,r=!0){let o=Mu.set(0,0,0),n,s=0,a=[];for(let l=0;l<e.length;l++){let c=sl(e[l]),d=Ui,u=oo(c,t);a.push(u);for(let p=0;p<=u;p++)if(c instanceof js||c instanceof nl||c instanceof _s){if(c.getPoint(p/u,d),o.set(d.x,d.y,0),n!==void 0&&iv(n,o))continue;n===void 0&&(n=Iu),n.copy(o),i.setXYZ(s,o.x,o.y,o.z),s++}}return r&&s>1&&!(i.getX(s-1)===i.getX(0)&&i.getY(s-1)===i.getY(0)&&i.getZ(s-1)===i.getZ(0))&&(i.setXYZ(s,i.getX(0),i.getY(0),i.getZ(0)),s++),i}function Bu(i,e,t,r=12,o=!0){let n=Mu.set(0,0,0),s=0,a=[];for(let l=0;l<e.length;l++){if(t[l]===!1)continue;let c,d=sl(e[l]),u=Ui,p=oo(d,r);a.push(p);for(let f=0;f<=p;f++)if(d instanceof js||d instanceof nl||d instanceof _s){if(d.getPoint(f/p,u),n.set(u.x,u.y,0),c==null?void 0:c.equals(n))continue;c===void 0?c=Iu:(i.setXYZ(s,c.x,c.y,c.z),s++,i.setXYZ(s,n.x,n.y,n.z),s++),c.copy(n)}}return o&&s>1&&!(i.getX(s-1)===i.getX(0)&&i.getY(s-1)===i.getY(0)&&i.getZ(s-1)===i.getZ(0))&&(i.setXYZ(s,i.getX(0),i.getY(0),i.getZ(0)),s++),a}function dl(i,e=12,t=!1){let r=[];for(let o=0,n=i.length;o<n;o++){let s=i[o],a=0;if(t&&s.roundedCurveCorner!==void 0){let l=oo(s.roundedCurveCorner,e)*.5;o>0&&(r[o-1]+=l),a+=l}s.curveAfter!==void 0&&(a+=oo(s.curveAfter,e)),r.push(a)}return i.length>0&&t&&i[0].roundedCurveCorner!==void 0&&(r[i.length-1]+=oo(i[0].roundedCurveCorner,e)*.5),r}function oo(i,e=12){return i&&i instanceof Kb?e*2:i&&(i instanceof _s||i instanceof Xb)?1:i&&i instanceof Qb?e*i.points.length:e}function Gu(i,e,t=12,r=!0){let o,n=0;for(let s=0;s<e.length;s++){let a=sl(e[s]),l=oo(a,t),c=Ui;for(let d=0;d<=l;d++)if(a instanceof js||a instanceof nl||a instanceof _s){if(a.getPoint(d/l,c),o!==void 0&&ov(o,c,Fi))continue;o===void 0&&(o=al),o.copy(c),i.push(c.x,c.y),n++}}return ki(i[0],i[i.length-2],Fi)&&ki(i[1],i[i.length-1],Fi)&&(i.pop(),i.pop()),r&&n>1&&!(ki(i[n-1],i[1],Fi)&&ki(i[n-2],i[0],Fi))&&(i.push(i[0],i[1]),n++),i}var hl=new zr,lv=new zr,cv=new zr,dv=new zr,pv=new zr,uv=new zr,Pe=class extends zu{constructor(e=100,t=100){super();this.points=[];this.shapeHoles=[];this.eventDispatcher=new nv;this.plane=new sv(new av(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=pl.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=t}static createFromState(e,t,r){let o=new Pe;return o.isClosed=e.isClosed,o.points=e.points.map(n=>br.create(n.id,n.data)),typeof e.roundness=="number"&&(o.roundness=e.roundness),o.shapeHoles=e.shapeHoles.map(n=>Pe.createFromState(n)),t!==void 0&&r!==void 0&&o.applySize(t,r),o.update(),o}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,r=this.points.length;t<r;t++)this.points[t].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(t=>this.getPointIndexById(t)).filter(t=>t>=0)}getPointIndexById(e){return this.points.findIndex(t=>t.uuid===e)}getLineIndexById(e){return this.getPointIndexById(e)}getBezierPoint(e){if(e<=this.points.length-1)return this.points[e];if(this.shapeHoles.length>0)for(let t=0,r=this.shapeHoles.length;t<r;t++){let o=this.shapeHoles[t],n=e-this.points.length;if(n<=o.points.length-1)return o.points[n]}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 r=0,o=this.shapeHoles.length;r<o;r++){let n=this.shapeHoles[r],s=n.points.indexOf(e);if(s>=0)return t+s;t+=n.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 r=hl.set(e,t);for(let o=0,n=this.points.length;o<n;o++){let s=this.points[o];s.position.multiply(r),s.controls[0].position.multiply(r),s.controls[1].position.multiply(r)}for(let o=0,n=this.shapeHoles.length;o<n;o++)this.shapeHoles[o].applyScale(e,t);this._update(!1)}createPoint(e,t=0,r=pl.generateUUID()){let o;e instanceof zr?o=e:o=new zr(e,t);let n=new br(r,o);return n.roundness=this.roundness,n}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,r=this.points.length;t<r;t++){let o=this.points[t];if(o.uuid===e)return o}}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(r=>r.uuid===e);t&&this.removePoint(t)}update(e=!0){for(let t=0,r=this.shapeHoles.length;t<r;t++)this.shapeHoles[t].update(!1);this._update(e)}extractShapePointsToBuffer(e,t=12,r=!1){this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t);let o=r?this.roundedCurveDivisions:this.curveDivisions;return Du(e,r?this.roundedCurves:this.curves,t,this.autoClose),o.reduce((n,s)=>n+s,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=dl(this.points,e,!1),this.roundedCurveDivisions=dl(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,t,r=12){return Bu(e,this.curves,t,r,this.autoClose).reduce((n,s)=>n+s,0)*2}extractShapePointsToFlatArray(e,t=12){return this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t),Gu(e,this.roundedCurves,t,this.autoClose)}getCurveIndexFromVertexId(e,t=!1){let r=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let o=t?this.roundedCurveDivisions:this.curveDivisions,n=0;t&&this.points[0].roundedCurveCorner!==void 0&&(n=oo(this.points[0].roundedCurveCorner,this.subdivision)*.5);let s=e-n;s<0&&(s+=o.reduce((a,l)=>a+l,0));for(let a=0,l=o.length;a<l;a++){let c=o[a];if(s<r+c)return[a,(s-r+1)/c];r+=c}return[0,1]}getCurveT(e,t,r){let o=this.points[e],n=this.points[e>=this.points.length-1?0:e+1],s=this.curveDivisions,a=s[e];if(cl(o,n)){let d=o.position.distanceTo(n.position);return o.position.distanceTo(hl.set(r.x,r.y))/d}let l=0;for(let d=0;d<e;d++)l+=s[d];return(t-l)/a}dispose(){this.eventDispatcher=null}_applyCurveForPoint(e,t){cl(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 r=this.curves[this.curves.length-1];e.curveBefore=r,t.curveAfter=r;let o=r.clone();e.roundedCurveBefore=o,t.roundedCurveAfter=o,e.roundedCurveCorner=void 0,this.roundedCurves.push(o)}_update(e=!0){var r;if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let o=0,n=this.points.length;o<n;o++){let s=this.points[o];if(o===0)this.moveTo(s.position.x,s.position.y);else{let a=this.points[o-1];this._applyCurveForPoint(s,a)}}let t=this.getLastPoint();if((t==null?void 0:t.curveAfter)&&(t.curveAfter=void 0),this.isClosed){let o=this.points[0],n=this.points[this.points.length-1];this._applyCurveForPoint(o,n)}if(this.points.length>2){let o=0;for(let n=0,s=this.points.length;n<s;n++){let a=this.points[n],l=a.roundness;if(!a.controlsMoved()&&l>0){let c=a.curveBefore,d=a.curveAfter;if(c===void 0||d===void 0)continue;let u=a.roundedCurveBefore,p=a.roundedCurveAfter,f=c.getLength(),m=d.getLength(),x=Math.min(l,f*.499),y=Math.min(l,m*.499),N=Math.min(x,y),L=1-N/f,w=N/m,B=c.getPointAt(L,hl),S=d.getPointAt(w,lv);this._subSplitCurve(c,u,L,B,void 0),this._subSplitCurve(d,p,w,void 0,S);let _;if(this.useCubicForRoundedCorners){let T=ll(B,a.position,S)/2,h=Math.tan(T)*B.distanceTo(a.position),[I,b]=Ou(B,S,h,cv,dv),P=Au(I,b,a.position),[v,D]=ju(P,B,S,h,pv,uv);_=new Ds(B.clone(),v.clone(),D.clone(),S.clone())}else _=new Eu(B.clone(),a.position.clone(),S.clone());a.roundedCurveCorner=_,this.roundedCurves.splice(n+o,0,_),o++}}}e&&((r=this.eventDispatcher)==null||r.dispatchEvent({type:"update"}))}_subSplitCurve(e,t,r,o,n){if(e instanceof ul)o!==void 0&&t.v2.copy(o),n!==void 0&&t.v1.copy(n);else{let s=e,a=t,l=s.getUtoTmapping(r,0),c=_u(s.v0,s.v1,s.v2,s.v3,l);return o!==void 0&&(a.v0.set(c[0],c[1]),a.v1.set(c[2],c[3]),a.v2.set(c[4],c[5]),a.v3.set(c[6],c[7])),n!==void 0&&(a.v0.set(c[6],c[7]),a.v1.set(c[8],c[9]),a.v2.set(c[10],c[11]),a.v3.set(c[12],c[13])),a}return t}clone(){let e=new Pe(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){var r;this.points=[],this.pointIDs=0;let t=e.points.length/7;for(let o=0;o<t;o++){let n=o*7,s=e.points[n+0],a=e.points[n+1],l=e.points[n+2],c=e.points[n+3],d=e.points[n+4],u=e.points[n+5],p=e.points[n+6],f=new br(pl.generateUUID(),new zr(s,a));f.controls[0].position.set(l,c),f.controls[1].position.set(d,u),f.roundness=p,this.points.push(f)}return this.shapeHoles=((r=e.shapeHoles)==null?void 0:r.length)?e.shapeHoles.map(o=>{let n=new Pe;return n.fromJSON(o),n}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e){let t=(o,n)=>{n instanceof Ds&&n.v3.equals(o.position)&&o.controls[0].position.copy(n.v2)},r=o=>{let n=[],s,a;for(s=0,a=o.length;s<a;s++)o[s]instanceof Eu&&(o[s]=Pu(o[s]));for(s=0,a=o.length;s<a;s++){let d=o[s],u=s>0?o[s-1]:null,p;d instanceof Ds?(p=this.createPoint(d.v0),p.controls[1].position.copy(d.v1)):d instanceof ul&&(p=this.createPoint(d.v1)),p!==void 0&&(u!==null&&t(p,u),n.push(p))}let l=o[o.length-1],c=!1;return l instanceof Ds?l.v3.equals(n[0].position)&&(n[0].controls[0].position.copy(l.v2),c=!0):l instanceof ul&&l.v2.equals(n[0].position)&&(c=!0),this.isClosed=c,n};return this.points=r(e.curves),e instanceof zu&&(this.shapeHoles=e.holes.map(o=>{let n=new Pe;return n.fromShape(o),n})),this.update(),this}};var ml=Math.PI*2;function fl({x:i,y:e},t,r,o,n){return{x:i*t+o,y:e*r+n}}function hv(i,e){let t=e===1.5707963267948966?.551915024494:e===-1.5707963267948966?-.551915024494:4/3*Math.tan(e/4),r=Math.cos(i),o=Math.sin(i),n=Math.cos(i+e),s=Math.sin(i+e);return[{x:r-o*t,y:o+r*t},{x:n+s*t,y:s-n*t},{x:n,y:s}]}function Fu(i,e,t,r){let o=i*r-e*t<0?-1:1,n=Math.min(1,Math.max(-1,i*t+e*r));return o*Math.acos(n)}function mv(i,e,t,r,o,n,s,a,l,c){let d=Math.pow(o,2),u=Math.pow(n,2),p=Math.pow(s,2),f=Math.pow(a,2),m=d*u-d*f-u*p;m<0&&(m=0),m/=d*f+u*p,m=Math.sqrt(m)*(l===c?-1:1);let x=m*o/n*a,y=m*-n/o*s,N=x+(i+t)/2,L=y+(e+r)/2,w=(s-x)/o,B=(a-y)/n,S=(-s-x)/o,_=(-a-y)/n,T=Fu(1,0,w,B),h=Fu(w,B,S,_);return!c&&h>0&&(h-=ml),c&&h<0&&(h+=ml),{centerx:N,centery:L,ang1:T,ang2:h}}function Ru({px:i,py:e,cx:t,cy:r,rx:o,ry:n,largeArcFlag:s,sweepFlag:a}){let l=[];if(o===0||n===0)return[];let c=(i-t)/2,d=(e-r)/2;if(c===0&&d===0)return[];o=Math.abs(o),n=Math.abs(n);let u=Math.pow(c,2)/Math.pow(o,2)+Math.pow(d,2)/Math.pow(n,2);u>1&&(o*=Math.sqrt(u),n*=Math.sqrt(u));let p=mv(i,e,t,r,o,n,c,d,s,a),{ang1:f,ang2:m}=p,{centerx:x,centery:y}=p,N=Math.abs(m)/(ml/4);Math.abs(1-N)<1e-7&&(N=1);let L=Math.max(Math.ceil(N),1);m/=L;for(let w=0;w<L;w++)l.push(hv(f,m)),f+=m;return l.map(w=>{let{x:B,y:S}=fl(w[0],o,n,x,y),{x:_,y:T}=fl(w[1],o,n,x,y),{x:h,y:I}=fl(w[2],o,n,x,y);return{x1:B,y1:S,x2:_,y2:T,x:h,y:I}})}import{BufferAttribute as Gs,BufferGeometry as bv}from"three";var $e;(function(i){i[i.ODD=0]="ODD",i[i.NONZERO=1]="NONZERO",i[i.POSITIVE=2]="POSITIVE",i[i.NEGATIVE=3]="NEGATIVE",i[i.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})($e||($e={}));var st;(function(i){i[i.POLYGONS=0]="POLYGONS",i[i.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",i[i.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(st||(st={}));function ce(i,e){if(!i)throw e||"Assertion Failed!"}var ae=function(){function i(){}return i.vertEq=function(e,t){return e.s===t.s&&e.t===t.t},i.vertLeq=function(e,t){return e.s<t.s||e.s===t.s&&e.t<=t.t},i.transLeq=function(e,t){return e.t<t.t||e.t===t.t&&e.s<=t.s},i.edgeGoesLeft=function(e){return i.vertLeq(e.Dst,e.Org)},i.edgeGoesRight=function(e){return i.vertLeq(e.Org,e.Dst)},i.vertL1dist=function(e,t){return Math.abs(e.s-t.s)+Math.abs(e.t-t.t)},i.edgeEval=function(e,t,r){ce(i.vertLeq(e,t)&&i.vertLeq(t,r));var o=t.s-e.s,n=r.s-t.s;return o+n>0?o<n?t.t-e.t+(e.t-r.t)*(o/(o+n)):t.t-r.t+(r.t-e.t)*(n/(o+n)):0},i.edgeSign=function(e,t,r){ce(i.vertLeq(e,t)&&i.vertLeq(t,r));var o=t.s-e.s,n=r.s-t.s;return o+n>0?(t.t-r.t)*o+(t.t-e.t)*n:0},i.transEval=function(e,t,r){ce(i.transLeq(e,t)&&i.transLeq(t,r));var o=t.t-e.t,n=r.t-t.t;return o+n>0?o<n?t.s-e.s+(e.s-r.s)*(o/(o+n)):t.s-r.s+(r.s-e.s)*(n/(o+n)):0},i.transSign=function(e,t,r){ce(i.transLeq(e,t)&&i.transLeq(t,r));var o=t.t-e.t,n=r.t-t.t;return o+n>0?(t.s-r.s)*o+(t.s-e.s)*n:0},i.vertCCW=function(e,t,r){return e.s*(t.t-r.t)+t.s*(r.t-e.t)+r.s*(e.t-t.t)>=0},i.interpolate=function(e,t,r,o){return e=e<0?0:e,r=r<0?0:r,e<=r?r===0?(t+o)/2:t+(o-t)*(e/(e+r)):o+(t-o)*(r/(e+r))},i.intersect=function(e,t,r,o,n){var s,a,l;i.vertLeq(e,t)||(l=e,e=t,t=l),i.vertLeq(r,o)||(l=r,r=o,o=l),i.vertLeq(e,r)||(l=e,e=r,r=l,l=t,t=o,o=l),i.vertLeq(r,t)?i.vertLeq(t,o)?(s=i.edgeEval(e,r,t),a=i.edgeEval(r,t,o),s+a<0&&(s=-s,a=-a),n.s=i.interpolate(s,r.s,a,t.s)):(s=i.edgeSign(e,r,t),a=-i.edgeSign(e,o,t),s+a<0&&(s=-s,a=-a),n.s=i.interpolate(s,r.s,a,o.s)):n.s=(r.s+t.s)/2,i.transLeq(e,t)||(l=e,e=t,t=l),i.transLeq(r,o)||(l=r,r=o,o=l),i.transLeq(e,r)||(l=e,e=r,r=l,l=t,t=o,o=l),i.transLeq(r,t)?i.transLeq(t,o)?(s=i.transEval(e,r,t),a=i.transEval(r,t,o),s+a<0&&(s=-s,a=-a),n.t=i.interpolate(s,r.t,a,t.t)):(s=i.transSign(e,r,t),a=-i.transSign(e,o,t),s+a<0&&(s=-s,a=-a),n.t=i.interpolate(s,r.t,a,o.t)):n.t=(r.t+t.t)/2},i}(),Hi=function(){function i(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return i}(),Bs=function(){function i(e){this.side=e,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(i.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(e){this.Sym.Lface=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(e){this.Sym.Org=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(e){this.Sym.Lnext=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(e){this.Onext.Sym=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(e){this.Lnext.Sym=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(e){this.Sym.Onext=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(e){this.Sym.Onext.Sym=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(e){this.Sym.Lnext.Sym=e},enumerable:!0,configurable:!0}),i}(),li=function(){function i(){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 i}(),Vu=function(){function i(){var e=new li,t=new Hi,r=new Bs(0),o=new Bs(1);e.next=e.prev=e,e.anEdge=null,t.next=t.prev=t,r.next=r,r.Sym=o,o.next=o,o.Sym=r,this.vHead=e,this.fHead=t,this.eHead=r,this.eHeadSym=o}return i.prototype.makeEdge_=function(e){var t=new Bs(0),r=new Bs(1);e.Sym.side<e.side&&(e=e.Sym);var o=e.Sym.next;return r.next=o,o.Sym.next=t,t.next=e,e.Sym.next=r,t.Sym=r,t.Onext=t,t.Lnext=r,t.Org=null,t.Lface=null,t.winding=0,t.activeRegion=null,r.Sym=t,r.Onext=r,r.Lnext=t,r.Org=null,r.Lface=null,r.winding=0,r.activeRegion=null,t},i.prototype.splice_=function(e,t){var r=e.Onext,o=t.Onext;r.Sym.Lnext=t,o.Sym.Lnext=e,e.Onext=o,t.Onext=r},i.prototype.makeVertex_=function(e,t,r){var o=e;ce(o,"Vertex can't be null!");var n=r.prev;o.prev=n,n.next=o,o.next=r,r.prev=o,o.anEdge=t;var s=t;do s.Org=o,s=s.Onext;while(s!==t)},i.prototype.makeFace_=function(e,t,r){var o=e;ce(o,"Face can't be null");var n=r.prev;o.prev=n,n.next=o,o.next=r,r.prev=o,o.anEdge=t,o.trail=null,o.marked=!1,o.inside=r.inside;var s=t;do s.Lface=o,s=s.Lnext;while(s!==t)},i.prototype.killEdge_=function(e){e.Sym.side<e.side&&(e=e.Sym);var t=e.next,r=e.Sym.next;t.Sym.next=r,r.Sym.next=t},i.prototype.killVertex_=function(e,t){var r=e.anEdge,o=r;do o.Org=t,o=o.Onext;while(o!==r);var n=e.prev,s=e.next;s.prev=n,n.next=s},i.prototype.killFace_=function(e,t){var r=e.anEdge,o=r;do o.Lface=t,o=o.Lnext;while(o!==r);var n=e.prev,s=e.next;s.prev=n,n.next=s},i.prototype.makeEdge=function(){var e=new li,t=new li,r=new Hi,o=this.makeEdge_(this.eHead);return this.makeVertex_(e,o,this.vHead),this.makeVertex_(t,o.Sym,this.vHead),this.makeFace_(r,o,this.fHead),o},i.prototype.splice=function(e,t){var r=!1,o=!1;if(e!==t){if(t.Org!==e.Org&&(o=!0,this.killVertex_(t.Org,e.Org)),t.Lface!==e.Lface&&(r=!0,this.killFace_(t.Lface,e.Lface)),this.splice_(t,e),!o){var n=new li;this.makeVertex_(n,t,e.Org),e.Org.anEdge=e}if(!r){var s=new Hi;this.makeFace_(s,t,e.Lface),e.Lface.anEdge=e}}},i.prototype.delete=function(e){var t=e.Sym,r=!1;if(e.Lface!==e.Rface&&(r=!0,this.killFace_(e.Lface,e.Rface)),e.Onext===e)this.killVertex_(e.Org,null);else if(e.Rface.anEdge=e.Oprev,e.Org.anEdge=e.Onext,this.splice_(e,e.Oprev),!r){var o=new Hi;this.makeFace_(o,e,e.Lface)}t.Onext===t?(this.killVertex_(t.Org,null),this.killFace_(t.Lface,null)):(e.Lface.anEdge=t.Oprev,t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev)),this.killEdge_(e)},i.prototype.addEdgeVertex=function(e){var t=this.makeEdge_(e),r=t.Sym;this.splice_(t,e.Lnext),t.Org=e.Dst;var o=new li;return this.makeVertex_(o,r,t.Org),t.Lface=r.Lface=e.Lface,t},i.prototype.splitEdge=function(e){var t=this.addEdgeVertex(e),r=t.Sym;return this.splice_(e.Sym,e.Sym.Oprev),this.splice_(e.Sym,r),e.Dst=r.Org,r.Dst.anEdge=r.Sym,r.Rface=e.Rface,r.winding=e.winding,r.Sym.winding=e.Sym.winding,r.idx=e.idx,r.Sym.idx=e.Sym.idx,r},i.prototype.connect=function(e,t){var r=!1,o=this.makeEdge_(e),n=o.Sym;if(t.Lface!==e.Lface&&(r=!0,this.killFace_(t.Lface,e.Lface)),this.splice_(o,e.Lnext),this.splice_(n,t),o.Org=e.Dst,n.Org=t.Org,o.Lface=n.Lface=e.Lface,e.Lface.anEdge=n,!r){var s=new Hi;this.makeFace_(s,o,e.Lface)}return o},i.prototype.zapFace=function(e){var t=e.anEdge,r,o,n,s,a;o=t.Lnext;do r=o,o=r.Lnext,r.Lface=null,r.Rface===null&&(r.Onext===r?this.killVertex_(r.Org,null):(r.Org.anEdge=r.Onext,this.splice_(r,r.Oprev)),n=r.Sym,n.Onext===n?this.killVertex_(n.Org,null):(n.Org.anEdge=n.Onext,this.splice_(n,n.Oprev)),this.killEdge_(r));while(r!=t);s=e.prev,a=e.next,a.prev=s,s.next=a},i.prototype.countFaceVerts_=function(e){var t=e.anEdge,r=0;do r++,t=t.Lnext;while(t!==e.anEdge);return r},i.prototype.mergeConvexFaces=function(e){var t,r,o,n,s,a,l;for(t=this.fHead.next;t!==this.fHead;t=t.next)if(!!t.inside)for(r=t.anEdge,s=r.Org;o=r.Lnext,n=r.Sym,n&&n.Lface&&n.Lface.inside&&(a=this.countFaceVerts_(t),l=this.countFaceVerts_(n.Lface),a+l-2<=e&&ae.vertCCW(r.Lprev.Org,r.Org,n.Lnext.Lnext.Org)&&ae.vertCCW(n.Lprev.Org,n.Org,r.Lnext.Lnext.Org)&&(o=n.Lnext,this.delete(n),r=null,n=null)),!(r&&r.Lnext.Org===s);)r=o;return!0},i.prototype.check=function(){var e=this.fHead,t=this.vHead,r=this.eHead,o,n,s,a,l,c;for(n=e,n=e;(o=n.next)!==e;n=o){ce(o.prev===n),l=o.anEdge;do ce(l.Sym!==l),ce(l.Sym.Sym===l),ce(l.Lnext.Onext.Sym===l),ce(l.Onext.Sym.Lnext===l),ce(l.Lface===o),l=l.Lnext;while(l!==o.anEdge)}for(ce(o.prev===n&&o.anEdge===null),a=t,a=t;(s=a.next)!==t;a=s){ce(s.prev===a),l=s.anEdge;do ce(l.Sym!==l),ce(l.Sym.Sym===l),ce(l.Lnext.Onext.Sym===l),ce(l.Onext.Sym.Lnext===l),ce(l.Org===s),l=l.Onext;while(l!==s.anEdge)}for(ce(s.prev===a&&s.anEdge===null),c=r,c=r;(l=c.next)!==r;c=l)ce(l.Sym.next===c.Sym),ce(l.Sym!==l),ce(l.Sym.Sym===l),ce(l.Org!==null),ce(l.Dst!==null),ce(l.Lnext.Onext.Sym===l),ce(l.Onext.Sym.Lnext===l);ce(l.Sym.next===c.Sym&&l.Sym===this.eHeadSym&&l.Sym.Sym===l&&l.Org===null&&l.Dst===null&&l.Lface===null&&l.Rface===null)},i}(),Uu=function(){function i(){this.handle=null}return i}(),ku=function(){function i(){this.key=null,this.node=0}return i}(),fv=function(){function i(e,t){this.leq=t,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=e,this.nodes=[],this.handles=[];for(var r=0;r<e+1;r++)this.nodes[r]=new Uu,this.handles[r]=new ku;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return i.prototype.floatDown_=function(e){var t=this.nodes,r=this.handles,o,n,s;for(o=t[e].handle;;){if(s=e<<1,s<this.size&&this.leq(r[t[s+1].handle].key,r[t[s].handle].key)&&++s,ce(s<=this.max),n=t[s].handle,s>this.size||this.leq(r[o].key,r[n].key)){t[e].handle=o,r[o].node=e;break}t[e].handle=n,r[n].node=e,e=s}},i.prototype.floatUp_=function(e){var t=this.nodes,r=this.handles,o,n,s;for(o=t[e].handle;;){if(s=e>>1,n=t[s].handle,s===0||this.leq(r[n].key,r[o].key)){t[e].handle=o,r[o].node=e;break}t[e].handle=n,r[n].node=e,e=s}},i.prototype.init=function(){for(var e=this.size;e>=1;--e)this.floatDown_(e);this.initialized=!0},i.prototype.min=function(){return this.handles[this.nodes[1].handle].key},i.prototype.insert=function(e){var t,r;if(t=++this.size,t*2>this.max){this.max*=2;var o,n;for(n=this.nodes.length,this.nodes.length=this.max+1,o=n;o<this.nodes.length;o++)this.nodes[o]=new Uu;for(n=this.handles.length,this.handles.length=this.max+1,o=n;o<this.handles.length;o++)this.handles[o]=new ku}return this.freeList===0?r=t:(r=this.freeList,this.freeList=this.handles[r].node),this.nodes[t].handle=r,this.handles[r].node=t,this.handles[r].key=e,this.initialized&&this.floatUp_(t),r},i.prototype.extractMin=function(){var e=this.nodes,t=this.handles,r=e[1].handle,o=t[r].key;return this.size>0&&(e[1].handle=e[this.size].handle,t[e[1].handle].node=1,t[r].key=null,t[r].node=this.freeList,this.freeList=r,--this.size,this.size>0&&this.floatDown_(1)),o},i.prototype.delete=function(e){var t=this.nodes,r=this.handles,o;ce(e>=1&&e<=this.max&&r[e].key!==null),o=r[e].node,t[o].handle=t[this.size].handle,r[t[o].handle].node=o,--this.size,o<=this.size&&(o<=1||this.leq(r[t[o>>1].handle].key,r[t[o].handle].key)?this.floatDown_(o):this.floatUp_(o)),r[e].key=null,r[e].node=this.freeList,this.freeList=e},i}(),yl=function(){function i(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return i}(),Hu=function(){function i(){this.key=null,this.next=null,this.prev=null}return i}(),yv=function(){function i(e,t){this.frame=e,this.leq=t,this.head=new Hu,this.head.next=this.head,this.head.prev=this.head}return i.prototype.min=function(){return this.head.next},i.prototype.max=function(){return this.head.prev},i.prototype.insert=function(e){return this.insertBefore(this.head,e)},i.prototype.search=function(e){var t=this.head;do t=t.next;while(t.key!==null&&!this.leq(this.frame,e,t.key));return t},i.prototype.insertBefore=function(e,t){do e=e.prev;while(e.key!==null&&!this.leq(this.frame,e.key,t));var r=new Hu;return r.key=t,r.next=e.next,e.next.prev=r,r.prev=e,e.next=r,r},i.prototype.delete=function(e){e.next.prev=e.prev,e.prev.next=e.next},i}(),gv=function(){function i(){}return i.regionBelow=function(e){return e.nodeUp.prev.key},i.regionAbove=function(e){return e.nodeUp.next.key},i.debugEvent=function(e){},i.addWinding=function(e,t){e.winding+=t.winding,e.Sym.winding+=t.Sym.winding},i.edgeLeq=function(e,t,r){var o=e.event,n=t.eUp,s=r.eUp;if(n.Dst===o)return s.Dst===o?ae.vertLeq(n.Org,s.Org)?ae.edgeSign(s.Dst,n.Org,s.Org)<=0:ae.edgeSign(n.Dst,s.Org,n.Org)>=0:ae.edgeSign(s.Dst,o,s.Org)<=0;if(s.Dst===o)return ae.edgeSign(n.Dst,o,n.Org)>=0;var a=ae.edgeEval(n.Dst,o,n.Org),l=ae.edgeEval(s.Dst,o,s.Org);return a>=l},i.deleteRegion=function(e,t){t.fixUpperEdge&&ce(t.eUp.winding===0),t.eUp.activeRegion=null,e.dict.delete(t.nodeUp)},i.fixUpperEdge=function(e,t,r){ce(t.fixUpperEdge),e.mesh.delete(t.eUp),t.fixUpperEdge=!1,t.eUp=r,r.activeRegion=t},i.topLeftRegion=function(e,t){var r=t.eUp.Org,o;do t=i.regionAbove(t);while(t.eUp.Org===r);if(t.fixUpperEdge){if(o=e.mesh.connect(i.regionBelow(t).eUp.Sym,t.eUp.Lnext),o===null)return null;i.fixUpperEdge(e,t,o),t=i.regionAbove(t)}return t},i.topRightRegion=function(e){var t=e.eUp.Dst;do e=i.regionAbove(e);while(e.eUp.Dst===t);return e},i.addRegionBelow=function(e,t,r){var o=new yl;return o.eUp=r,o.nodeUp=e.dict.insertBefore(t.nodeUp,o),o.fixUpperEdge=!1,o.sentinel=!1,o.dirty=!1,r.activeRegion=o,o},i.isWindingInside=function(e,t){switch(e.windingRule){case $e.ODD:return(t&1)!=0;case $e.NONZERO:return t!==0;case $e.POSITIVE:return t>0;case $e.NEGATIVE:return t<0;case $e.ABS_GEQ_TWO:return t>=2||t<=-2}throw new Error("Invalid winding rulle")},i.computeWinding=function(e,t){t.windingNumber=i.regionAbove(t).windingNumber+t.eUp.winding,t.inside=i.isWindingInside(e,t.windingNumber)},i.finishRegion=function(e,t){var r=t.eUp,o=r.Lface;o.inside=t.inside,o.anEdge=r,i.deleteRegion(e,t)},i.finishLeftRegions=function(e,t,r){for(var o,n=null,s=t,a=t.eUp;s!==r;){if(s.fixUpperEdge=!1,n=i.regionBelow(s),o=n.eUp,o.Org!=a.Org){if(!n.fixUpperEdge){i.finishRegion(e,s);break}o=e.mesh.connect(a.Lprev,o.Sym),i.fixUpperEdge(e,n,o)}a.Onext!==o&&(e.mesh.splice(o.Oprev,o),e.mesh.splice(a,o)),i.finishRegion(e,s),a=n.eUp,s=n}return a},i.addRightEdges=function(e,t,r,o,n,s){var a,l,c,d,u=!0;c=r;do ce(ae.vertLeq(c.Org,c.Dst)),i.addRegionBelow(e,t,c.Sym),c=c.Onext;while(c!==o);for(n===null&&(n=i.regionBelow(t).eUp.Rprev),l=t,d=n;a=i.regionBelow(l),c=a.eUp.Sym,c.Org===d.Org;)c.Onext!==d&&(e.mesh.splice(c.Oprev,c),e.mesh.splice(d.Oprev,c)),a.windingNumber=l.windingNumber-c.winding,a.inside=i.isWindingInside(e,a.windingNumber),l.dirty=!0,!u&&i.checkForRightSplice(e,l)&&(i.addWinding(c,d),i.deleteRegion(e,l),e.mesh.delete(d)),u=!1,l=a,d=c;l.dirty=!0,ce(l.windingNumber-c.winding===a.windingNumber),s&&i.walkDirtyRegions(e,l)},i.spliceMergeVertices=function(e,t,r){e.mesh.splice(t,r)},i.vertexWeights=function(e,t,r){var o=ae.vertL1dist(t,e),n=ae.vertL1dist(r,e),s=.5*n/(o+n),a=.5*o/(o+n);e.coords[0]+=s*t.coords[0]+a*r.coords[0],e.coords[1]+=s*t.coords[1]+a*r.coords[1],e.coords[2]+=s*t.coords[2]+a*r.coords[2]},i.getIntersectData=function(e,t,r,o,n,s){t.coords[0]=t.coords[1]=t.coords[2]=0,t.idx=-1,i.vertexWeights(t,r,o),i.vertexWeights(t,n,s)},i.checkForRightSplice=function(e,t){var r=i.regionBelow(t),o=t.eUp,n=r.eUp;if(ae.vertLeq(o.Org,n.Org)){if(ae.edgeSign(n.Dst,o.Org,n.Org)>0)return!1;ae.vertEq(o.Org,n.Org)?o.Org!==n.Org&&(e.pq.delete(o.Org.pqHandle),i.spliceMergeVertices(e,n.Oprev,o)):(e.mesh.splitEdge(n.Sym),e.mesh.splice(o,n.Oprev),t.dirty=r.dirty=!0)}else{if(ae.edgeSign(o.Dst,n.Org,o.Org)<0)return!1;i.regionAbove(t).dirty=t.dirty=!0,e.mesh.splitEdge(o.Sym),e.mesh.splice(n.Oprev,o)}return!0},i.checkForLeftSplice=function(e,t){var r=i.regionBelow(t),o=t.eUp,n=r.eUp,s;if(ce(!ae.vertEq(o.Dst,n.Dst)),ae.vertLeq(o.Dst,n.Dst)){if(ae.edgeSign(o.Dst,n.Dst,o.Org)<0)return!1;i.regionAbove(t).dirty=t.dirty=!0,s=e.mesh.splitEdge(o),e.mesh.splice(n.Sym,s),s.Lface.inside=t.inside}else{if(ae.edgeSign(n.Dst,o.Dst,n.Org)>0)return!1;t.dirty=r.dirty=!0,s=e.mesh.splitEdge(n),e.mesh.splice(o.Lnext,n.Sym),s.Rface.inside=t.inside}return!0},i.checkForIntersect=function(e,t){var r=i.regionBelow(t),o=t.eUp,n=r.eUp,s=o.Org,a=n.Org,l=o.Dst,c=n.Dst,d,u,p=new li,f,m;if(ce(!ae.vertEq(c,l)),ce(ae.edgeSign(l,e.event,s)<=0),ce(ae.edgeSign(c,e.event,a)>=0),ce(s!==e.event&&a!==e.event),ce(!t.fixUpperEdge&&!r.fixUpperEdge),s===a||(d=Math.min(s.t,l.t),u=Math.max(a.t,c.t),d>u))return!1;if(ae.vertLeq(s,a)){if(ae.edgeSign(c,s,a)>0)return!1}else if(ae.edgeSign(l,a,s)<0)return!1;return i.debugEvent(e),ae.intersect(l,s,c,a,p),ce(Math.min(s.t,l.t)<=p.t),ce(p.t<=Math.max(a.t,c.t)),ce(Math.min(c.s,l.s)<=p.s),ce(p.s<=Math.max(a.s,s.s)),ae.vertLeq(p,e.event)&&(p.s=e.event.s,p.t=e.event.t),f=ae.vertLeq(s,a)?s:a,ae.vertLeq(f,p)&&(p.s=f.s,p.t=f.t),ae.vertEq(p,s)||ae.vertEq(p,a)?(i.checkForRightSplice(e,t),!1):!ae.vertEq(l,e.event)&&ae.edgeSign(l,e.event,p)>=0||!ae.vertEq(c,e.event)&&ae.edgeSign(c,e.event,p)<=0?c===e.event?(e.mesh.splitEdge(o.Sym),e.mesh.splice(n.Sym,o),t=i.topLeftRegion(e,t),o=i.regionBelow(t).eUp,i.finishLeftRegions(e,i.regionBelow(t),r),i.addRightEdges(e,t,o.Oprev,o,o,!0),!0):l===e.event?(e.mesh.splitEdge(n.Sym),e.mesh.splice(o.Lnext,n.Oprev),r=t,t=i.topRightRegion(t),m=i.regionBelow(t).eUp.Rprev,r.eUp=n.Oprev,n=i.finishLeftRegions(e,r,null),i.addRightEdges(e,t,n.Onext,o.Rprev,m,!0),!0):(ae.edgeSign(l,e.event,p)>=0&&(i.regionAbove(t).dirty=t.dirty=!0,e.mesh.splitEdge(o.Sym),o.Org.s=e.event.s,o.Org.t=e.event.t),ae.edgeSign(c,e.event,p)<=0&&(t.dirty=r.dirty=!0,e.mesh.splitEdge(n.Sym),n.Org.s=e.event.s,n.Org.t=e.event.t),!1):(e.mesh.splitEdge(o.Sym),e.mesh.splitEdge(n.Sym),e.mesh.splice(n.Oprev,o),o.Org.s=p.s,o.Org.t=p.t,o.Org.pqHandle=e.pq.insert(o.Org),i.getIntersectData(e,o.Org,s,l,a,c),i.regionAbove(t).dirty=t.dirty=r.dirty=!0,!1)},i.walkDirtyRegions=function(e,t){for(var r=i.regionBelow(t),o,n;;){for(;r.dirty;)t=r,r=i.regionBelow(r);if(!t.dirty&&(r=t,t=i.regionAbove(t),t===null||!t.dirty))return;if(t.dirty=!1,o=t.eUp,n=r.eUp,o.Dst!==n.Dst&&i.checkForLeftSplice(e,t)&&(r.fixUpperEdge?(i.deleteRegion(e,r),e.mesh.delete(n),r=i.regionBelow(t),n=r.eUp):t.fixUpperEdge&&(i.deleteRegion(e,t),e.mesh.delete(o),t=i.regionAbove(r),o=t.eUp)),o.Org!==n.Org)if(o.Dst!==n.Dst&&!t.fixUpperEdge&&!r.fixUpperEdge&&(o.Dst===e.event||n.Dst===e.event)){if(i.checkForIntersect(e,t))return}else i.checkForRightSplice(e,t);o.Org===n.Org&&o.Dst===n.Dst&&(i.addWinding(n,o),i.deleteRegion(e,t),e.mesh.delete(o),t=i.regionAbove(r))}},i.connectRightVertex=function(e,t,r){var o,n=r.Onext,s=i.regionBelow(t),a=t.eUp,l=s.eUp,c=!1;if(a.Dst!==l.Dst&&i.checkForIntersect(e,t),ae.vertEq(a.Org,e.event)&&(e.mesh.splice(n.Oprev,a),t=i.topLeftRegion(e,t),n=i.regionBelow(t).eUp,i.finishLeftRegions(e,i.regionBelow(t),s),c=!0),ae.vertEq(l.Org,e.event)&&(e.mesh.splice(r,l.Oprev),r=i.finishLeftRegions(e,s,null),c=!0),c){i.addRightEdges(e,t,r.Onext,n,n,!0);return}ae.vertLeq(l.Org,a.Org)?o=l.Oprev:o=a,o=e.mesh.connect(r.Lprev,o),i.addRightEdges(e,t,o,o.Onext,o.Onext,!1),o.Sym.activeRegion.fixUpperEdge=!0,i.walkDirtyRegions(e,t)},i.connectLeftDegenerate=function(e,t,r){var o,n,s,a,l;if(o=t.eUp,ae.vertEq(o.Org,r)){ce(!1),i.spliceMergeVertices(e,o,r.anEdge);return}if(!ae.vertEq(o.Dst,r)){e.mesh.splitEdge(o.Sym),t.fixUpperEdge&&(e.mesh.delete(o.Onext),t.fixUpperEdge=!1),e.mesh.splice(r.anEdge,o),i.sweepEvent(e,r);return}ce(!1),t=i.topRightRegion(t),l=i.regionBelow(t),s=l.eUp.Sym,n=a=s.Onext,l.fixUpperEdge&&(ce(n!==s),i.deleteRegion(e,l),e.mesh.delete(s),s=n.Oprev),e.mesh.splice(r.anEdge,s),ae.edgeGoesLeft(n)||(n=null),i.addRightEdges(e,t,s.Onext,a,n,!0)},i.connectLeftVertex=function(e,t){var r,o,n,s,a,l,c=new yl;if(c.eUp=t.anEdge.Sym,r=e.dict.search(c).key,o=i.regionBelow(r),!!o){if(s=r.eUp,a=o.eUp,ae.edgeSign(s.Dst,t,s.Org)===0){i.connectLeftDegenerate(e,r,t);return}if(n=ae.vertLeq(a.Dst,s.Dst)?r:o,r.inside||n.fixUpperEdge){if(n===r)l=e.mesh.connect(t.anEdge.Sym,s.Lnext);else{var d=e.mesh.connect(a.Dnext,t.anEdge);l=d.Sym}n.fixUpperEdge?i.fixUpperEdge(e,n,l):i.computeWinding(e,i.addRegionBelow(e,r,l)),i.sweepEvent(e,t)}else i.addRightEdges(e,r,t.anEdge,t.anEdge,null,!0)}},i.sweepEvent=function(e,t){e.event=t,i.debugEvent(e);for(var r=t.anEdge;r.activeRegion===null;)if(r=r.Onext,r===t.anEdge){i.connectLeftVertex(e,t);return}var o=i.topLeftRegion(e,r.activeRegion);ce(o!==null);var n=i.regionBelow(o),s=n.eUp,a=i.finishLeftRegions(e,n,null);a.Onext===s?i.connectRightVertex(e,o,a):i.addRightEdges(e,o,a.Onext,s,s,!0)},i.addSentinel=function(e,t,r,o){var n=new yl,s=e.mesh.makeEdge();s.Org.s=r,s.Org.t=o,s.Dst.s=t,s.Dst.t=o,e.event=s.Dst,n.eUp=s,n.windingNumber=0,n.inside=!1,n.fixUpperEdge=!1,n.sentinel=!0,n.dirty=!1,n.nodeUp=e.dict.insert(n)},i.initEdgeDict=function(e){e.dict=new yv(e,i.edgeLeq);var t=e.bmax[0]-e.bmin[0],r=e.bmax[1]-e.bmin[1],o=e.bmin[0]-t,n=e.bmax[0]+t,s=e.bmin[1]-r,a=e.bmax[1]+r;i.addSentinel(e,o,n,s),i.addSentinel(e,o,n,a)},i.doneEdgeDict=function(e){for(var t,r=0;(t=e.dict.min().key)!==null;)t.sentinel||(ce(t.fixUpperEdge),ce(++r==1)),ce(t.windingNumber===0),i.deleteRegion(e,t)},i.removeDegenerateEdges=function(e){var t,r,o,n=e.mesh.eHead;for(t=n.next;t!==n;t=r)r=t.next,o=t.Lnext,ae.vertEq(t.Org,t.Dst)&&t.Lnext.Lnext!==t&&(i.spliceMergeVertices(e,o,t),e.mesh.delete(t),t=o,o=t.Lnext),o.Lnext===t&&(o!==t&&((o===r||o===r.Sym)&&(r=r.next),e.mesh.delete(o)),(t===r||t===r.Sym)&&(r=r.next),e.mesh.delete(t))},i.initPriorityQ=function(e){var t,r,o,n=0;for(o=e.mesh.vHead,r=o.next;r!==o;r=r.next)n++;for(n+=8,t=e.pq=new fv(n,ae.vertLeq),o=e.mesh.vHead,r=o.next;r!==o;r=r.next)r.pqHandle=t.insert(r);return r!==o?!1:(t.init(),!0)},i.donePriorityQ=function(e){e.pq=null},i.removeDegenerateFaces=function(e,t){var r,o,n;for(r=t.fHead.next;r!==t.fHead;r=o)o=r.next,n=r.anEdge,ce(n.Lnext!==n),n.Lnext.Lnext===n&&(i.addWinding(n.Onext,n),e.mesh.delete(n));return!0},i.computeInterior=function(e,t){t===void 0&&(t=!0);var r,o;if(i.removeDegenerateEdges(e),!i.initPriorityQ(e))return!1;for(i.initEdgeDict(e);(r=e.pq.extractMin())!==null;){for(;o=e.pq.min(),!(o===null||!ae.vertEq(o,r));)o=e.pq.extractMin(),i.spliceMergeVertices(e,r.anEdge,o.anEdge);i.sweepEvent(e,r)}return e.event=e.dict.min().key.eUp.Org,i.debugEvent(e),i.doneEdgeDict(e),i.donePriorityQ(e),i.removeDegenerateFaces(e,e.mesh)?(t&&e.mesh.check(),!0):!1},i}(),xv=function(){function i(){this.mesh=new Vu,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=$e.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 i.prototype.dot_=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]},i.prototype.normalize_=function(e){var t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2];if(!t)throw"Zero-size vector!";t=Math.sqrt(t),e[0]/=t,e[1]/=t,e[2]/=t},i.prototype.longAxis_=function(e){var t=0;return Math.abs(e[1])>Math.abs(e[0])&&(t=1),Math.abs(e[2])>Math.abs(e[t])&&(t=2),t},i.prototype.computeNormal_=function(e){var t,r,o,n,s,a,l=[0,0,0],c=[0,0,0],d=[0,0,0],u=[0,0,0],p=[0,0,0],f=[null,null,null],m=[null,null,null],x=this.mesh.vHead;t=x.next;for(var y=0;y<3;++y)n=t.coords[y],c[y]=n,m[y]=t,l[y]=n,f[y]=t;for(t=x.next;t!==x;t=t.next)for(var N=0;N<3;++N)n=t.coords[N],n<c[N]&&(c[N]=n,m[N]=t),n>l[N]&&(l[N]=n,f[N]=t);var L=0;if(l[1]-c[1]>l[0]-c[0]&&(L=1),l[2]-c[2]>l[L]-c[L]&&(L=2),c[L]>=l[L]){e[0]=0,e[1]=0,e[2]=1;return}for(a=0,r=m[L],o=f[L],d[0]=r.coords[0]-o.coords[0],d[1]=r.coords[1]-o.coords[1],d[2]=r.coords[2]-o.coords[2],t=x.next;t!==x;t=t.next)u[0]=t.coords[0]-o.coords[0],u[1]=t.coords[1]-o.coords[1],u[2]=t.coords[2]-o.coords[2],p[0]=d[1]*u[2]-d[2]*u[1],p[1]=d[2]*u[0]-d[0]*u[2],p[2]=d[0]*u[1]-d[1]*u[0],s=p[0]*p[0]+p[1]*p[1]+p[2]*p[2],s>a&&(a=s,e[0]=p[0],e[1]=p[1],e[2]=p[2]);a<=0&&(e[0]=e[1]=e[2]=0,e[this.longAxis_(d)]=1)},i.prototype.checkOrientation_=function(){for(var e=this.mesh.fHead,t,r=this.mesh.vHead,o,n=0,s=e.next;s!==e;s=s.next)if(o=s.anEdge,!(o.winding<=0))do n+=(o.Org.s-o.Dst.s)*(o.Org.t+o.Dst.t),o=o.Lnext;while(o!==s.anEdge);if(n<0){for(t=r.next;t!==r;t=t.next)t.t=-t.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},i.prototype.projectPolygon_=function(){var e=this.mesh.vHead,t=[0,0,0],r,o,n=!1;t[0]=this.normal[0],t[1]=this.normal[1],t[2]=this.normal[2],!t[0]&&!t[1]&&!t[2]&&(this.computeNormal_(t),n=!0),r=this.sUnit,o=this.tUnit;var s=this.longAxis_(t);r[s]=0,r[(s+1)%3]=1,r[(s+2)%3]=0,o[s]=0,o[(s+1)%3]=0,o[(s+2)%3]=t[s]>0?1:-1;for(var a=e.next;a!==e;a=a.next)a.s=this.dot_(a.coords,r),a.t=this.dot_(a.coords,o);n&&this.checkOrientation_();for(var l=!0,c=e.next;c!==e;c=c.next)l?(this.bmin[0]=this.bmax[0]=c.s,this.bmin[1]=this.bmax[1]=c.t,l=!1):(c.s<this.bmin[0]&&(this.bmin[0]=c.s),c.s>this.bmax[0]&&(this.bmax[0]=c.s),c.t<this.bmin[1]&&(this.bmin[1]=c.t),c.t>this.bmax[1]&&(this.bmax[1]=c.t))},i.prototype.addWinding_=function(e,t){e.winding+=t.winding,e.Sym.winding+=t.Sym.winding},i.prototype.tessellateMonoRegion_=function(e,t){var r,o;if(r=t.anEdge,!(r.Lnext!==r&&r.Lnext.Lnext!==r))throw"Mono region invalid";for(;ae.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;ae.vertLeq(r.Org,r.Dst);r=r.Lnext);o=r.Lprev;for(var n=void 0;r.Lnext!==o;)if(ae.vertLeq(r.Dst,o.Org)){for(;o.Lnext!==r&&(ae.edgeGoesLeft(o.Lnext)||ae.edgeSign(o.Org,o.Dst,o.Lnext.Dst)<=0);)n=e.connect(o.Lnext,o),o=n.Sym;o=o.Lprev}else{for(;o.Lnext!==r&&(ae.edgeGoesRight(r.Lprev)||ae.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)n=e.connect(r,r.Lprev),r=n.Sym;r=r.Lnext}if(o.Lnext===r)throw"Mono region invalid";for(;o.Lnext.Lnext!==r;)n=e.connect(o.Lnext,o),o=n.Sym;return!0},i.prototype.tessellateInterior_=function(e){for(var t,r=e.fHead.next;r!==e.fHead;r=t)if(t=r.next,r.inside&&!this.tessellateMonoRegion_(e,r))return!1;return!0},i.prototype.discardExterior_=function(e){for(var t,r=e.fHead.next;r!==e.fHead;r=t)t=r.next,r.inside||e.zapFace(r)},i.prototype.setWindingNumber_=function(e,t,r){for(var o,n=e.eHead.next;n!==e.eHead;n=o)o=n.next,n.Rface.inside!==n.Lface.inside?n.winding=n.Lface.inside?t:-t:r?e.delete(n):n.winding=0},i.prototype.getNeighbourFace_=function(e){return!e.Rface||!e.Rface.inside?-1:e.Rface.n},i.prototype.outputPolymesh_=function(e,t,r,o){var n,s=0,a=0,l;r>3&&e.mergeConvexFaces(r);for(var c=e.vHead.next;c!==e.vHead;c=c.next)c.n=-1;for(var d=e.fHead.next;d!==e.fHead;d=d.next)if(d.n=-1,!!d.inside){n=d.anEdge,l=0;do{var c=n.Org;c.n===-1&&(c.n=a,a++),l++,n=n.Lnext}while(n!==d.anEdge);if(l>r)throw"Face vertex greater that support polygon";d.n=s,++s}this.elementCount=s,t===st.CONNECTED_POLYGONS&&(s*=2),this.elements=[],this.elements.length=s*r,this.vertexCount=a,this.vertices=[],this.vertices.length=a*o,this.vertexIndices=[],this.vertexIndices.length=a;for(var c=e.vHead.next;c!==e.vHead;c=c.next)if(c.n!==-1){var u=c.n*o;this.vertices[u+0]=c.coords[0],this.vertices[u+1]=c.coords[1],o>2&&(this.vertices[u+2]=c.coords[2]),this.vertexIndices[c.n]=c.idx}for(var p=0,d=e.fHead.next;d!==e.fHead;d=d.next)if(!!d.inside){n=d.anEdge,l=0;do{var c=n.Org;this.elements[p++]=c.n,l++,n=n.Lnext}while(n!==d.anEdge);for(var f=l;f<r;++f)this.elements[p++]=-1;if(t===st.CONNECTED_POLYGONS){n=d.anEdge;do this.elements[p++]=this.getNeighbourFace_(n),n=n.Lnext;while(n!==d.anEdge);for(var m=l;m<r;++m)this.elements[p++]=-1}}},i.prototype.outputContours_=function(e,t){var r,o,n=0,s=0;this.vertexCount=0,this.elementCount=0;for(var a=e.fHead.next;a!==e.fHead;a=a.next)if(!!a.inside){o=r=a.anEdge;do this.vertexCount++,r=r.Lnext;while(r!==o);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*t,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var l=0,c=0,d=0;n=0;for(var a=e.fHead.next;a!==e.fHead;a=a.next)if(!!a.inside){s=0,o=r=a.anEdge;do this.vertices[l++]=r.Org.coords[0],this.vertices[l++]=r.Org.coords[1],t>2&&(this.vertices[l++]=r.Org.coords[2]),this.vertexIndices[c++]=this.vertexIdCallback?this.vertexIdCallback(r):r.Org.idx,s++,r=r.Lnext;while(r!==o);this.elements[d++]=n,this.elements[d++]=s,n+=s}},i.prototype.addContour=function(e,t){this.mesh===null&&(this.mesh=new Vu),e<2&&(e=2),e>3&&(e=3);for(var r=null,o=0;o<t.length;o+=e)r===null?(r=this.mesh.makeEdge(),this.mesh.splice(r,r.Sym)):(this.mesh.splitEdge(r),r=r.Lnext),r.Org.coords[0]=t[o+0],r.Org.coords[1]=t[o+1],e>2?r.Org.coords[2]=t[o+2]:r.Org.coords[2]=0,r.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(r),r.winding=1,r.Sym.winding=-1},i.prototype.tesselate=function(e,t,r,o,n,s){if(e===void 0&&(e=$e.ODD),t===void 0&&(t=st.POLYGONS),s===void 0&&(s=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,n&&(this.normal[0]=n[0],this.normal[1]=n[1],this.normal[2]=n[2]),this.windingRule=e,o<2&&(o=2),o>3&&(o=3),!this.mesh)return!1;this.projectPolygon_(),gv.computeInterior(this,s);var a=this.mesh;return t===st.BOUNDARY_CONTOURS?this.setWindingNumber_(a,1,!0):this.tessellateInterior_(a),s&&a.check(),t===st.BOUNDARY_CONTOURS?this.outputContours_(a,o):this.outputPolymesh_(a,t,r,o),!0},i}();function wo(i){var e=i.windingRule,t=e===void 0?$e.ODD:e,r=i.elementType,o=r===void 0?st.POLYGONS:r,n=i.polySize,s=n===void 0?3:n,a=i.vertexSize,l=a===void 0?2:a,c=i.normal,d=c===void 0?[0,0,1]:c,u=i.contours,p=u===void 0?[]:u,f=i.strict,m=f===void 0?!0:f,x=i.debug,y=x===void 0?!1:x;if(!p&&m)throw new Error("Contours can't be empty");if(!!p){var N=new xv;i.edgeCreateCallback&&(N.edgeCreateCallback=i.edgeCreateCallback),i.vertexIdCallback&&(N.vertexIdCallback=i.vertexIdCallback);for(var L=0;L<p.length;L++)N.addContour(l||2,p[L]);return N.tesselate(t,o,s,l,d,m),{vertices:N.vertices,vertexIndices:N.vertexIndices,vertexCount:N.vertexCount,elements:N.elements,elementCount:N.elementCount,mesh:y?N.mesh:void 0}}}var Uj=$e.ODD,kj=$e.NONZERO,Hj=$e.POSITIVE,qj=$e.NEGATIVE,Wj=$e.ABS_GEQ_TWO,$j=st.POLYGONS,Jj=st.CONNECTED_POLYGONS,Kj=st.BOUNDARY_CONTOURS;var No=class extends bv{constructor(e,t=12,r=100,o={}){super();this.type="ShapeGeometry";this.windingRule=$e.ODD;this.elementType=st.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._drawCount=0,this._shape=e,this._curveSegments=t,this._maxCount=r,this._maxDrawCount=r*3,this._triangulationOptions=Object.assign({windingRule:$e.ODD,elementType:st.POLYGONS,polySize:3,vertexSize:2,strict:!0},o),this._positionAttribute=new Gs(new Float32Array(r*3),3),this._normalAttribute=new Gs(new Float32Array(r*3),3),this._uvAttribute=new Gs(new Float32Array(r*2),2),this._indexAttribute=new Gs(new Uint32Array(r*3),1),this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.updateFromShape()}copy(e){return this._drawCount=e.drawCount,this._maxDrawCount=e._maxDrawCount,this._maxCount=e.maxCount,super.copy(e)}get curveSegments(){return this._curveSegments}set curveSegments(e){this._curveSegments=e,this.updateFromShape()}get drawCount(){return this._drawCount}get maxDrawCount(){return this._maxDrawCount}get maxCount(){return this._maxCount}updateFromShape(){let e=this._shape.extractShapePointsToFlatArray([],this._curveSegments),t=this._shape.shapeHoles.map(l=>l.extractShapePointsToFlatArray([],this._curveSegments)),r,o=!0,n=!0,s,a;for(let l=0,c=e.length/2;l<c;l++){let d=l*2,u=e[d+0],p=e[d+1];if(s!==void 0&&u!==s&&(o=!1),a!==void 0&&p!==a&&(n=!1),s=u,a=p,!o&&!n)break}if(!o&&!n&&(r=wo({contours:[e,...t],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})),this._positionAttribute.array.fill(0),this._normalAttribute.array.fill(0),this._uvAttribute.array.fill(0),this._indexAttribute.array.fill(0),this._drawCount=0,r){let l=1/0,c=-1/0,d=1/0,u=-1/0;for(let m=0,x=r.vertexCount;m<x;m++){let y=m*2,N=r.vertices[y+0],L=r.vertices[y+1];N<l&&(l=N),N>c&&(c=N),L<d&&(d=L),L>u&&(u=L)}let p=c-l,f=u-d;for(let m=0,x=r.vertexCount;m<x;m++){let y=m*2,N=r.vertices[y+0],L=r.vertices[y+1],w=(N-l)/p,B=(L-d)/f;this._positionAttribute.setXYZ(m,N,L,0),this._normalAttribute.setXYZ(m,0,0,1),this._uvAttribute.setXY(m,w,B)}for(let m=0,x=r.elementCount;m<x;m++){let y=m*3,N=r.elements[y+0],L=r.elements[y+1],w=r.elements[y+2];this._indexAttribute.setX(y+0,N),this._indexAttribute.setX(y+1,L),this._indexAttribute.setX(y+2,w),this._drawCount+=3}}return this._positionAttribute.needsUpdate=!0,this._normalAttribute.needsUpdate=!0,this._uvAttribute.needsUpdate=!0,this._indexAttribute.needsUpdate=!0,this.setDrawRange(0,this._drawCount),this._drawCount>this._maxDrawCount}clone(){let e=new No(this._shape,this._curveSegments,this._maxCount);return e.userData=yo(this.userData),e}};import{BufferAttribute as Fs,BufferGeometry as vv}from"three";var Es=class{constructor(e=256,t=!1){this.capacity=e,this.size=0,this.debug=t,this.debug&&console.log(`allocating with cap ${e}`);let r=e*Es.eSize;this.buffer=new ArrayBuffer(r);let o=Float32Array.BYTES_PER_ELEMENT,n=0;this.positions=new Float32Array(this.buffer,n*o,3*e),n+=3*e,this.normals=new Float32Array(this.buffer,n*o,3*e),n+=3*e,this.uvs=new Float32Array(this.buffer,n*o,2*e)}realloc(e,t=!1){if(e<this.size)throw Error("cannot shrink buffer");if(e<=this.capacity&&!t)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${e}`);let r=e*Es.eSize,o=new ArrayBuffer(r),n=Float32Array.BYTES_PER_ELEMENT,s=0,a=new Float32Array(o,s*n,3*e);s+=3*e;let l=new Float32Array(o,s*n,3*e);s+=3*e;let c=new Float32Array(o,s*n,2*e);a.set(this.positions.slice(0,this.size*3)),l.set(this.normals.slice(0,this.size*3)),c.set(this.uvs.slice(0,this.size*2)),this.buffer=o,this.positions=a,this.normals=l,this.uvs=c,this.capacity=e}get(e=1){let t=this.size+e;if(t>this.capacity){let o=this.capacity;for(;t>o;)o*=2;this.realloc(o)}let r=this.size;return this.size=t,r}reserve(e){let t=this.size+e;t>this.capacity&&this.realloc(t)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},zs=Es;zs.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var gl=(i,e)=>([t,r])=>(r<t&&(r+=e),(i>=t?i:i+e)<=r),qi=class extends vv{constructor(e,t,r=0,o=12,n=3){super();this.type="ShapeGeometry";this.vertexCache={};this._shape=e,this._depth=t,this._bevel=r,this._curveSegments=o,this._bevelSegmentsInput=n,r<=0?(this._bevelSize=0,this._bevelSegments=0):(this._bevelSize=Math.min(r,t/2-1e-12),this._bevelSegments=Math.floor(n));let s=this._shape.extractShapePointsToFlatArray([],o),a=this._shape.shapeHoles.map(_=>{let T=_.extractShapePointsToFlatArray([],o),h=[];for(let I=T.length-1;I>=1;I-=2){let b=T[I-1],P=T[I-0];h.push(b,P)}return h}),l=wo({windingRule:$e.ODD,elementType:st.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[s]}),c=wo({windingRule:$e.ODD,elementType:st.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...a]});if(!l)throw new Error("error generating geometry");let d=l.elementCount;if(c){l.elementCount+=c.elementCount;for(let _=0;_<c.elements.length;_++){let T=c.elements[_],h=_%2==0?l.vertexCount:0;l.elements.push(T+h)}for(let _=0;_<c.vertexIndices.length;_++){let T=c.vertexIndices[_],h=l.vertexCount;l.vertexIndices.push(T+h)}for(let _=0;_<c.vertices.length;_++){let T=c.vertices[_];l.vertices.push(T)}}let u=1/0,p=-1/0,f=1/0,m=-1/0;for(let _=0,T=l.vertexCount;_<T;_++){let h=_*2,I=l.vertices[h+0],b=l.vertices[h+1];I<u&&(u=I),I>p&&(p=I),b<f&&(f=b),b>m&&(m=b)}this._minX=u,this._minY=f,this._width=p-u,this._height=m-f;let x=l.vertexCount*2*(2+this._bevelSegments);this._buffer=new zs(x);let y=[],N=[];for(let _=l.elementCount-1;_>=0;_--){let T=_>=d,h=_*2,I=l.elements[h+0],b=l.elements[h+1],P=I+b,v={start:I,count:b,normals:[],continuous:[],concave:[]},D=I,Z=P-1,V=I+1,ie=this._shape.roundedCurves.length;do{let A=D-I,j=l.vertices[Z*2+0],g=l.vertices[Z*2+1],z=l.vertices[D*2+0],R=l.vertices[D*2+1],U=l.vertices[V*2+0],q=l.vertices[V*2+1],W=z-j,J=R-g,E=Math.sqrt(W*W+J*J);W/=E,J/=E;let H=z-U,k=R-q,se=Math.sqrt(H*H+k*k);H/=se,k/=se,v.normals[A*2+0]=-k,v.normals[A*2+1]=H,v.concave[A]=W*k-J*H>0;let F=l.vertexIndices[D];if(Array.isArray(F))v.continuous[A]=!1;else{let[K,X]=this._shape.getCurveIndexFromVertexId(F-1,!0);if(X>0&&X<1)v.continuous[A]=!0;else{let te=X===1?K+1:K-1;te=(te+ie)%ie;let he=X===1?0:1,Y=this._shape.roundedCurves[K].getTangent(X),ne=this._shape.roundedCurves[te].getTangent(he);v.continuous[A]=Y.dot(ne)>.95}}T&&(v.normals[A*2+0]*=-1,v.normals[A*2+1]*=-1),[Z,D,V]=[D,V,V+1],V>=P&&(V-=b)}while(V!==I+1);let oe=[];oe.push({bevelI:0,angle:0,size:0,boundary:{vertices:l.vertices.slice(I*2,P*2),vertexCount:b,vertexIndices:new Array(b).fill(!0).map((A,j)=>[j,j]),elements:[0,b],elementCount:1,mesh:null},reverseMap:[],insetPoints:l.vertices.slice(I*2,P*2)});for(let A=1;A<=this._bevelSegments;A++){let j=A/this._bevelSegments*Math.PI/2,g=(1-Math.cos(j))*this._bevelSize,z=[],R=[],U=[],q=[],W=0;for(let E=0;E<b;E++){let H=E*2,k=(E-1+b)%b*2,se=l.vertices[v.start*2+H+0],F=l.vertices[v.start*2+H+1],K=-v.normals[k+0]*g,X=-v.normals[k+1]*g,te=-v.normals[H+0]*g,he=-v.normals[H+1]*g;if(v.concave[E]||!v.concave[E]&&T){let Y=Math.atan2(X,K),ne=Math.atan2(he,te);ne>Y&&(ne-=Math.PI*2);let Se=ne-Y;if(v.continuous[E]||T){let me=Y+Se/2,Oe=Math.cos(me)*g,He=Math.sin(me)*g;z[2*W+0]=se+Oe*(T?-1:1),z[2*W+1]=F+He*(T?-1:1),q[W]=E,W++}else{let me=Math.max(1,Math.floor(o/4*Math.abs(Se)/Math.PI));for(let Oe=0;Oe<=me;Oe++){let He=Y+Se*(Oe/me),rt=Math.cos(He)*g,pt=Math.sin(He)*g;z[2*W+0]=se+rt,z[2*W+1]=F+pt,q[W]=E,W++}}}else z[2*W+0]=se+K,z[2*W+1]=F+X,q[W]=E,R[E]=W,W++,z[2*W+0]=se,z[2*W+1]=F,q[W]=E,W++,z[2*W+0]=se+te,z[2*W+1]=F+he,q[W]=E,U[E]=W,W++}let J=wo({windingRule:$e.POSITIVE,elementType:st.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[z],edgeCreateCallback:E=>{let k=E.Org.idx,se=q[k],F=q[(k+1)%q.length];E.idx=[se,F],E.Sym.idx=[F,se]},vertexIdCallback:E=>{let H=E.Lprev.idx;return[H?H[1]:0,E.idx[0]]}});if(!J)throw console.log("Error"),new Error(`error generating bevel geometry for ${A}'th loop`);if(!J.vertexCount)break;for(let E=0;E<J.vertexIndices.length;E++){let[H,k]=J.vertexIndices[E];if(H===k)continue;let se=k;k<H&&(se+=b);for(let F=H;F<se;F++){let K=F%b,X=(F+1)%b;if(!v.continuous[K]||!v.continuous[X]){J.vertexIndices[E]=[H,K],J.vertexIndices.splice(E+1,0,[X,k]),J.vertices.splice((E+1)*2,0,J.vertices[E*2],J.vertices[E*2+1]);break}}}oe.push({bevelI:A,angle:j,size:g,boundary:J,reverseMap:q,insetPoints:z})}let ge=(A,j,g)=>{let z=0,R=A.boundary.vertexIndices.length;for(;z<R&&g(A.boundary.vertexIndices[j]);)j=(j+1)%R,z++;return z},xe=y.length;for(let A=1;A<oe.length;A++){let j=oe[A-1],g=oe[A],z=j.boundary.vertexIndices.length,R=g.boundary.vertexIndices.length;if(!z||!R)break;let U=v.concave.length,q=0,W=gl(q,b);for(;!j.boundary.vertexIndices.filter(W).length||!g.boundary.vertexIndices.filter(W).length;)q++,W=gl(q,b);let J=j.boundary.vertexIndices.findIndex(W),E=g.boundary.vertexIndices.findIndex(W);do J=(J+1)%z;while(W(j.boundary.vertexIndices[J]));do E=(E+1)%R;while(W(g.boundary.vertexIndices[E]));q=(q+1)%b;let H=q,k=this.buildBevelVert(v,j,(J-1+z)%z),se=this.buildBevelVert(v,g,(E-1+R)%R),F=k,K=se,X,te,he=!1;do{W=gl(q,b);let Y=ge(j,J,W),ne=ge(g,E,W),Se=he;if(he=!1,Y&&!ne){for(let me=0;me<Y;me++)X=this.buildBevelVert(v,j,(J+me)%z,me/(Y-1)),y.push(F.topN,X.topP,K.topN),y.push(X.bottomP,F.bottomN,K.bottomN),F=X;he=!0}else if(!Y&&ne)for(let me=0;me<ne;me++)te=this.buildBevelVert(v,g,(E+me)%R,me/(ne-1)),y.push(K.topN,F.topP,te.topP),y.push(F.bottomP,K.bottomN,te.bottomP),K=te;else if(Y&&ne)if(X=this.buildBevelVert(v,j,J,0),te=this.buildBevelVert(v,g,E,0),Se?(y.push(F.topN,te.topP,K.topN),y.push(F.topN,X.topP,te.topP),y.push(te.bottomP,F.bottomN,K.bottomN),y.push(X.bottomP,F.bottomN,te.bottomP)):(y.push(F.topN,X.topP,K.topN),y.push(K.topN,X.topP,te.topP),y.push(X.bottomP,F.bottomN,K.bottomN),y.push(X.bottomP,K.bottomN,te.bottomP)),F=X,K=te,Y===ne)for(let me=1;me<Y;me++)X=this.buildBevelVert(v,j,(J+me)%z,me/(Y-1)),te=this.buildBevelVert(v,g,(E+me)%R,me/(ne-1)),y.push(F.topN,X.topP,K.topN),y.push(K.topN,X.topP,te.topP),y.push(X.bottomP,F.bottomN,K.bottomN),y.push(X.bottomP,K.bottomN,te.bottomP),F=X,K=te;else if(Y>ne){let me=Y/ne,Oe=0;for(let He=1;He<Y;He++)X=this.buildBevelVert(v,j,(J+He)%z,He/(Y-1)),y.push(F.topN,X.topP,K.topN),y.push(X.bottomP,F.bottomN,K.bottomN),F=X,He>(Oe+1)*me&&(Oe++,te=this.buildBevelVert(v,g,(E+Oe)%R,Oe/(ne-1)),y.push(K.topN,X.topP,te.topP),y.push(X.bottomP,K.bottomN,te.bottomP),K=te)}else{let me=ne/Y,Oe=0;for(let He=1;He<ne;He++)te=this.buildBevelVert(v,g,(E+He)%R,He/(ne-1)),y.push(K.topN,X.topP,te.topP),y.push(X.bottomP,K.bottomN,te.bottomP),K=te,He>(Oe+1)*me&&(Oe++,X=this.buildBevelVert(v,j,(J+Oe)%z,Oe/(Y-1)),y.push(F.topN,X.topP,K.topN),y.push(X.bottomP,F.bottomN,K.bottomN),F=X)}J=(J+Y)%z,E=(E+ne)%R,q=(q+1)%U}while(q!==H)}{let A=oe[0];for(let j=0,g=A.boundary.vertexCount;j<g;j++){let z=this.buildBevelVert(v,A,j),R=this.buildBevelVert(v,A,(j+1)%g);y.push(R.topP,z.topN,z.bottomN),y.push(R.topP,z.bottomN,R.bottomP)}}if(T){let A=[];for(let j=y.length-1;j>=xe+2;j-=3){let g=y[j-2],z=y[j-1],R=y[j-0];A.push(R,z,g)}y.splice(xe,y.length-xe,...A)}if(T){let A=[];for(let j=oe[oe.length-1].boundary.vertices.length-1;j>=1;j-=2){let g=oe[oe.length-1].boundary.vertices[j-1],z=oe[oe.length-1].boundary.vertices[j-0];A.push(g,z)}N.push(A)}if(!T){let A=oe[oe.length-1],j=wo({windingRule:oe.length>1?$e.POSITIVE:$e.ODD,elementType:st.POLYGONS,vertexSize:2,strict:!0,contours:[A.insetPoints,...N]});if(!j)throw new Error("Error generating geometry for surface");for(let g=0;g<j.elementCount*3;g+=3){let z=this.buildSurfaceVert(j,j.elements[g+0]),R=this.buildSurfaceVert(j,j.elements[g+1]),U=this.buildSurfaceVert(j,j.elements[g+2]);y.push(z.top,R.top,U.top),y.push(U.bottom,R.bottom,z.bottom)}}this.vertexCache={}}this._buffer.shrink();let L=new Fs(Uint32Array.from(y),1),w=new Fs(this._buffer.positions,3),B=new Fs(this._buffer.normals,3),S=new Fs(this._buffer.uvs,2);w.needsUpdate=!0,B.needsUpdate=!0,S.needsUpdate=!0,L.needsUpdate=!0,this.setAttribute("position",w),this.setAttribute("normal",B),this.setAttribute("uv",S),this.setIndex(L)}buildSurfaceVert(e,t){let r=t.toString();if(r in this.vertexCache)return this.vertexCache[r];let o=e.vertices[t*2+0],n=e.vertices[t*2+1],s=(o-this._minX)/this._width,a=(n-this._minY)/this._height,l=this._buffer.get(2),c=l*3,d=l*2,u={top:l+0,bottom:l+1};return this._buffer.positions[c+0]=o,this._buffer.positions[c+1]=n,this._buffer.positions[c+2]=this._depth,this._buffer.normals[c+0]=0,this._buffer.normals[c+1]=0,this._buffer.normals[c+2]=1,this._buffer.uvs[d+0]=s,this._buffer.uvs[d+1]=a,this._buffer.positions[c+3]=o,this._buffer.positions[c+4]=n,this._buffer.positions[c+5]=0,this._buffer.normals[c+3]=0,this._buffer.normals[c+4]=0,this._buffer.normals[c+5]=-1,this._buffer.uvs[d+2]=s,this._buffer.uvs[d+3]=a,this.vertexCache[r]=u,u}buildBevelVert(e,t,r,o=1){let n=`${t.bevelI}:${r}`;if(n in this.vertexCache)return this.vertexCache[n];let[s,a]=t.boundary.vertexIndices[r],l,c,d,u;s!==a?(c=s,l=a,u=!1,d=e.continuous[c]&&e.continuous[l]):(l=s,c=(l-1+e.count)%e.count,u=e.concave[l]&&t.bevelI>0,d=e.continuous[l]||u);let p=Math.cos(t.angle),f=Math.sin(t.angle),m=r*2,x=l*2,y=c*2,N=t.boundary.vertices[m+0],L=t.boundary.vertices[m+1],w=(1-f)*this._bevelSize,B=(N-this._minX)/this._width,S=(L-this._minY)/this._height,_=e.normals[x+0],T=e.normals[x+1],h=e.normals[y+0],I=e.normals[y+1];if(u){let Z=h-_,V=I-T;_=_+Z*(1-o),T=T+V*(1-o);let ie=Math.sqrt(_*_+T*T);_/=ie,T/=ie}let b=this._buffer.get(d?2:4),P=b*3,v=b*2,D={i:r,fi:l,topP:b+0,topN:b+0,bottomP:b+1,bottomN:b+1};return this._buffer.positions[P+0]=N,this._buffer.positions[P+1]=L,this._buffer.positions[P+2]=this._depth-w,this._buffer.normals[P+0]=_*p,this._buffer.normals[P+1]=T*p,this._buffer.normals[P+2]=f,this._buffer.uvs[v+0]=B,this._buffer.uvs[v+1]=S,this._buffer.positions[P+3]=N,this._buffer.positions[P+4]=L,this._buffer.positions[P+5]=w,this._buffer.normals[P+3]=_*p,this._buffer.normals[P+4]=T*p,this._buffer.normals[P+5]=-f,this._buffer.uvs[v+2]=S,this._buffer.uvs[v+3]=B,d||(b+=2,P+=6,v+=4,D.topP=b+0,D.bottomP=b+1,this._buffer.positions[P+0]=N,this._buffer.positions[P+1]=L,this._buffer.positions[P+2]=this._depth-w,this._buffer.normals[P+0]=h*p,this._buffer.normals[P+1]=I*p,this._buffer.normals[P+2]=f,this._buffer.uvs[v+0]=B,this._buffer.uvs[v+1]=S,this._buffer.positions[P+3]=N,this._buffer.positions[P+4]=L,this._buffer.positions[P+5]=w,this._buffer.normals[P+3]=h*p,this._buffer.normals[P+4]=I*p,this._buffer.normals[P+5]=-f,this._buffer.uvs[v+2]=S,this._buffer.uvs[v+3]=B),this.vertexCache[n]=D,D}clone(){let e=new qi(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=yo(this.userData),e}};var mt=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var c,d,u,p,f,m,x;let t=Object.assign({},(c=e==null?void 0:e.parameters)!=null?c:{width:100,subdivisions:40,roundness:0,extrudeDepth:0,surfaceMaxCount:100,extrudeBevelSize:0,extrudeBevelSegments:3},i.parameters),r=Math.abs(t.width),o=Math.abs((d=t.height)!=null?d:t.width),n=Math.abs(t.depth!==void 0&&t.depth===0&&t.extrudeDepth>0?t.extrudeDepth:(u=t.depth)!=null?u:0),s=(p=i.shape)!=null?p:e==null?void 0:e.shape,a=(f=s==null?void 0:s.roundness)!=null?f:t.roundness;s!==void 0&&(s instanceof Pe?(s.width!==r||s.height!==o)&&s.applySize(r,o):s=new Pe(r,o).fromJSON(s),((m=i.parameters)==null?void 0:m.roundness)!==void 0&&((x=i.parameters)==null?void 0:x.roundness)>0&&s.update(!1));let l=s!=null?s:new Pe(r,o);return{parameters:Object.assign(t,{width:r,height:o,depth:n,extrudeDepth:n,roundness:a}),shape:l}}static build(i){let{extrudeDepth:e,extrudeBevelSize:t,extrudeBevelSegments:r,subdivisions:o,roundness:n,surfaceMaxCount:s}=i.parameters;i.shape.roundness=n;let a;return e<=0?a=new No(i.shape,o,s):a=new qi(i.shape,e,t,o,r),Object.assign(a,{userData:$(O({},i),{type:"VectorGeometry"})})}};import{MathUtils as qu,Vector2 as Wu}from"three";var $u=Math.PI*2,Ju=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var o,n,s;let t=Object.assign({},(o=e==null?void 0:e.parameters)!=null?o:{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:1,surfaceMaxCount:1e3},i.parameters);return{shape:i.shape&&i.shape instanceof Pe?i.shape:new Pe,parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((n=t.height)!=null?n:t.width),depth:Math.abs(t.depth!==void 0&&t.depth===0&&t.extrudeDepth>0?t.extrudeDepth:(s=t.depth)!=null?s:0)})}}static build(i){let{width:e,height:t,spikes:r,angle:o,innerRadius:n,depth:s,extrudeBevelSize:a,extrudeBevelSegments:l,surfaceMaxCount:c}=i.parameters,d=i.shape,u=e*.5,p=t*.5,f=Sv(d,u,p,o*Math.PI/180,r,n);d.isClosed=!0,d.update();let m=mt.create({shape:d,parameters:{subdivisions:f,surfaceMaxCount:c,depth:s,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(m,{userData:$(O({},i),{type:"EllipseGeometry"})})}};function Sv(i,e,t,r,o,n){if(r>=$u)return o>30||o%4==0?(Nv(i,e,t,n),Math.round(o/4)):Ku(i,r,o,e,t,n);let s={x:0,y:t},a=r+Math.PI*.5,l={x:Math.cos(a)*e,y:Math.sin(a)*t},c=Ru({px:s.x,py:s.y,cx:l.x,cy:l.y,rx:e,ry:t,largeArcFlag:r>Math.PI,sweepFlag:!0});return o>30||o%c.length==0?wv(i,s.x,s.y,c,o,e,t,n):Ku(i,r,o,e,t,n)}function wv(i,e,t,r,o,n,s,a){let l=Math.round(o/r.length);i.addPoint(ci(e,t));for(let c=0,d=r.length;c<d;c++){let u=r[c],p=i.points[c],f=ci(u.x,u.y);p.controls[1].position.set(u.x1,u.y1),f.controls[0].position.set(u.x2,u.y2),i.addPoint(f)}return a>0?Xu(i,n,s,a):i.addPoint(ci(0,0)),l}function Ku(i,e,t,r,o,n){let s=-e/t;for(let a=0;a<=t;a++){let l=s*a,c=Math.sin(l)*r,d=Math.cos(l)*o;i.addPoint(ci(c,d))}return e<$u?n>0?Xu(i,r,o,n):i.addPoint(ci(0,0)):(i.removePoint(i.points[i.points.length-1]),n>0&&Zu(i,r,o,n)),1}function Nv(i,e,t,r=0,o=0,n=0){let s=.5522847498,a=e*s,l=t*s;i.addPoint(Rs(o-e,n,o-e,n-l,o-e,n+l)),i.addPoint(Rs(o,n+t,o-a,n+t,o+a,n+t)),i.addPoint(Rs(o+e,n,o+e,n+l,o+e,n-l)),i.addPoint(Rs(o,n-t,o+a,n-t,o-a,n-t)),r>0&&Zu(i,e,t,r)}function ci(i,e){return new br(qu.generateUUID(),new Wu(i,e))}function Rs(i,e,t,r,o,n){let s=ci(i,e);return s.controls[0].position.set(t,r),s.controls[1].position.set(o,n),s}function Xu(i,e,t,r){Qu(i,e,t,r).forEach(n=>i.addPoint(n))}function Zu(i,e,t,r){let o=Qu(i,e,t,r),n=new Pe;o.forEach(s=>n.addPoint(s)),n.isClosed=!0,i.shapeHoles.push(n)}function Qu(i,e,t,r){let o=r*e/100,n=o*(Math.abs(t)/Math.abs(e)),s=new Wu(o/e,n/t),a=i.points.map(l=>{let c=l.clone();return c.uuid=qu.generateUUID(),c}).reverse();return a.forEach(l=>{l.position.multiply(s);let c=l.controls[0].position.clone().multiply(s),d=l.controls[1].position.clone().multiply(s);l.controls[0].position.copy(d),l.controls[1].position.copy(c)}),a}import{BufferGeometry as Cv,Float32BufferAttribute as xl,Vector3 as Yu}from"three";var eh=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var a,l,c;let t=Object.assign({},(a=e==null?void 0:e.parameters)!=null?a:{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},i.parameters),r=Math.abs(t.width),o=Math.abs((l=t.height)!=null?l:r),n=Math.abs((c=t.depth)!=null?c:r),s=Math.abs(Math.min(r,n))/2;return{parameters:Object.assign(t,{width:r,height:o,depth:n,radius:s,segments:Math.round(t.segments),pathSegments:Math.round(t.pathSegments),cornerSegments:Math.round(t.cornerSegments)})}}static build(i){let{width:e,height:t,depth:r,radius:o,revolutions:n,segments:s,pathRadius:a,pathType:l,pathSegments:c,cornerRadius:d,cornerSegments:u}=i.parameters,p=new Vs(!1,e,t,r,o,n,s,a,l,c,d,u);return Object.assign(p,{userData:$(O({},i),{type:"HelixGeometry"})})}},Vs=class extends Cv{constructor(e=!0,t=1,r=1,o=1,n=1,s=1,a=1,l=1,c=1,d=1,u=1,p=1){super();let f=e&&s===1;f&&(p=0),u>100&&(u=100);let m=()=>new Yu,x=new Yu,y=m(),N=m(),L=m(),w,B,S,_,T,h,I,b,P=m(),v=m(),D=m(),Z=m(),V=m(),ie=m(),oe=m(),ge=m(),xe=r-2*l+.001,A=xe/s,j=Math.ceil(a*s),g=j+1,z=xe/j,R=-xe/2,U=d+1,q=2*Math.PI/d,W=Math.PI/2/p,J=.01,E=Math.min((1-u/100)*l,l-J),H=l-E,k=0,se=2,F=p*se+se,K=U*F/se,X=K+U*g,te=U*(g+F),[he,Y,ne]=[3,3,2].map(qe=>Array(te*qe).fill(0)),Se=[],me=n-l;function Oe(qe,bt){let Et=Math.PI/2;h=bt*z,b=2*Math.PI*(h%A)/A+Et,h+=R,I=Math.sin(b)*me,T=Math.cos(b)*me,e?qe.set(T,I,h):qe.set(T,h,I)}Oe(x,-1e-10),Oe(y,0),P.copy(x),Oe(x,1);let He=x.distanceTo(y),rt=H+E,pt=He*j+2*rt,zt=E,Tr=pt-rt;for(let qe=0;qe<=j;qe++){Oe(N,qe),ge.subVectors(N,P).normalize(),P.copy(N),ie.copy(N).setComponent(+e+1,0).normalize(),oe.crossVectors(ge,ie).normalize();let bt=qe===0,Et=qe===j,bn=bt?3*Math.PI/2:W,vn=bt?zt:Tr,Sn=bt?U:X,wn=bt?0:te-U,Nn=ge.clone().multiplyScalar(bt?-H:H).add(N),Cn=ge.clone().multiplyScalar(bt?-1:1).normalize();for(let $t=0;$t<U;$t++){let Li=$t*q;if(v.addVectors(x.copy(ie).multiplyScalar(l*Math.cos(Li)),y.copy(oe).multiplyScalar(l*Math.sin(Li))),D.copy(v).normalize(),bt||Et){f||(k=wn+$t,[0,1,2].forEach(ut=>{he[k*3+ut]=Nn.getComponent(ut),Y[k*3+ut]=Cn.getComponent(ut)}),ne[k*2]=+Et,ne[k*2+1]=$t/d),y.copy(D).multiplyScalar(E),L.addVectors(N,y);for(let ut=0;ut<p;ut++){let jo=ut*W+bn;Z.addVectors(x.copy(ge).multiplyScalar(H*Math.sin(jo)),y.copy(D).multiplyScalar(H*Math.cos(jo))),V.copy(Z).normalize(),y.addVectors(L,Z),Z.normalize(),k=Sn+ut*U+$t,[0,1,2].forEach(ye=>{he[k*3+ye]=y.getComponent(ye),Y[k*3+ye]=V.getComponent(ye)});let Ln=+bt+Math.sin(jo);ne[k*2]=(vn+H*Ln)/pt,ne[k*2+1]=$t/d}}y.addVectors(N,v),k=K+qe*U+$t,[0,1,2].forEach(ut=>{he[k*3+ut]=y.getComponent(ut),Y[k*3+ut]=D.getComponent(ut)}),ne[k*2]=(rt+qe*He)/pt,ne[k*2+1]=$t/d}}let xt=g+2*p+se,Ir=1,[uo,ho]=f?[Ir,Ir+g-1]:[0,xt-1];for(let qe=uo;qe<=ho-1;qe++){let bt=f&&qe===ho-1;for(let Et=0;Et<U-1;Et++)w=qe*U+Et,B=w+1,S=(bt?Et:w)+U,_=(bt?Et+1:B)+U,qe===0?Se.push(B,_,S):qe===xt-2?Se.push(w,B,S):Se.push(w,B,S,B,_,S)}this.setIndex(Se),this.setAttribute("position",new xl(he,3)),this.setAttribute("normal",new xl(Y,3)),this.setAttribute("uv",new xl(ne,2))}};import{IcosahedronBufferGeometry as Lv}from"three";var th=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,o,n;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,detail:0,corner:0,cornerSides:4},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((o=t.height)!=null?o:t.width),depth:Math.abs((n=t.depth)!=null?n:t.width)})}}static build(i){let{width:e,height:t,depth:r,detail:o,corner:n,cornerSides:s}=i.parameters,a=o===0&&n!==0?new Us(e*.5,n,s):new Lv(e*.5,o);return a.scale(1,t/e,r/e),Object.assign(a,{userData:$(O({},i),{type:"IcosahedronGeometry"})})}},Us=class extends So{constructor(e=1,t=.2,r=4){let o=(1+Math.sqrt(5))/2,n=[-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(n,s,a,e,t,r);this.type=a}static fromJSON(e){return new Us(e.radius,e.corner,e.cornerSides)}};import{LatheBufferGeometry as Tv,Shape as Iv}from"three";var rh=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,o,n,s,a;((o=(r=i.parameters)==null?void 0:r.points)!=null?o:[]).forEach(l=>{Array.isArray(l)&&(l.x=l[0],l.y=l[1])});let t=Object.assign({},(n=e==null?void 0:e.parameters)!=null?n:{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}]},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((s=t.height)!=null?s:t.width),depth:Math.abs((a=t.depth)!=null?a:t.width)})}}static build(i){let{points:e,segments:t,verticalSegments:r}=i.parameters,o=new Iv;o.moveTo(e[0].x,e[0].y),o.bezierCurveTo(e[1].x,e[1].y,e[2].x,e[2].y,e[3].x,e[3].y);let n=new Tv(o.extractPoints(r).shape,t);return n.rotateZ(Math.PI),Object.assign(n,{userData:$(O({},i),{type:"LatheGeometry"})})}};import{BufferGeometry as ih,BufferGeometryLoader as Dv,Vector3 as Bv,BoxBufferGeometry as nh}from"three";import{BufferGeometry as Mv,Vector2 as bl,Vector3 as oh}from"three";import{Geometry as Pv,Face3 as Ov}from"three/examples/jsm/deprecated/Geometry.js";var Av=["a","b","c"];function jv(i,e){switch(e){case"c":return i.c;case"b":return i.b;case"a":default:return i.a}}function vl(i,e,t){let r=Math.min(i,e),o=Math.max(i,e),n=r+"_"+o;return t.get(n)}function Sl(i,e,t,r,o,n){let s=Math.min(i,e),a=Math.max(i,e),l=s+"_"+a,c;if(r.has(l))c=r.get(l);else{let d=t[s],u=t[a];c={a:d,b:u,newEdge:null,faces:[]},r.set(l,c)}c.faces.push(o),n[i].edges.push(c),n[e].edges.push(c)}function _v(i,e,t,r){let o,n,s;for(o=0,n=i.length;o<n;o++)t[o]={edges:[]};for(o=0,n=e.length;o<n;o++)s=e[o],Sl(s.a,s.b,i,r,s,t),Sl(s.b,s.c,i,r,s,t),Sl(s.c,s.a,i,r,s,t)}function ks(i,e,t,r,o){i.push(new Ov(e,t,r,void 0,void 0,o))}function di(i,e){return Math.abs(e-i)/2+Math.min(i,e)}function Hs(i,e,t,r){i.push([e.clone(),t.clone(),r.clone()])}var wl=class{constructor(e=1){this.subdivisions=e}modify(e){e instanceof Mv?e=new Pv().fromBufferGeometry(e):e=e.clone(),e.mergeVertices();let t=this.subdivisions;for(;t-- >0;)this._smooth(e);return e.computeFaceNormals(),e.computeVertexNormals(),e}_smooth(e){let t=new oh,r,o,n,s,a,l=e.vertices,c=e.faces,d=e.faceVertexUvs[0],u=d!==void 0&&d.length>0,p=[],f=new Map;_v(l,c,p,f);let m=[],x,y,N,L,w,B,S;for(let J of Array.from(f.keys())){for(y=f.get(J),N=new oh,w=3/8,B=1/8,S=y.faces.length,S!=2&&(w=.5,B=0,S!=1),N.addVectors(y.a,y.b).multiplyScalar(w),t.set(0,0,0),s=0;s<S;s++){for(L=y.faces[s],a=0;a<3&&(x=l[jv(L,Av[a])],!(x!==y.a&&x!==y.b));a++);x&&t.add(x)}t.multiplyScalar(B),N.add(t),y.newEdge=m.length,m.push(N)}let _,T,h,I,b,P,v,D=[];for(o=0,n=l.length;o<n;o++){for(P=l[o],b=p[o].edges,r=b.length,r==3?_=3/16:r>3&&(_=3/(8*r)),T=1-r*Number(_),h=_,r<=2&&(r==2?(T=3/4,h=1/8):r==1||r==0),v=P.clone().multiplyScalar(T),t.set(0,0,0),s=0;s<r;s++)I=b[s],x=I.a!==P?I.a:I.b,t.add(x);t.multiplyScalar(Number(h)),v.add(t),D.push(v)}let Z=D.concat(m),V=D.length,ie,oe,ge,xe=[],A=[],j,g,z,R,U=new bl,q=new bl,W=new bl;for(o=0,n=c.length;o<n;o++)L=c[o],ie=Number(vl(L.a,L.b,f).newEdge)+V,oe=Number(vl(L.b,L.c,f).newEdge)+V,ge=Number(vl(L.c,L.a,f).newEdge)+V,ks(xe,ie,oe,ge,L.materialIndex),ks(xe,L.a,ie,ge,L.materialIndex),ks(xe,L.b,oe,ie,L.materialIndex),ks(xe,L.c,ge,oe,L.materialIndex),u&&(j=d[o],g=j[0],z=j[1],R=j[2],U.set(di(g.x,z.x),di(g.y,z.y)),q.set(di(z.x,R.x),di(z.y,R.y)),W.set(di(g.x,R.x),di(g.y,R.y)),Hs(A,U,q,W),Hs(A,g,U,W),Hs(A,z,q,U),Hs(A,R,W,q));e.vertices=Z,e.faces=xe,u&&(e.faceVertexUvs[0]=A)}};var at=new Bv,qs=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var n,s;let t=(s=(n=i.geometry)!=null?n:e==null?void 0:e.geometry)!=null?s:new ih().copy(new nh(100,100,100)),r;e===void 0?(t.computeBoundingBox(),t.boundingBox.getSize(at),r={width:at.x,height:at.y,depth:at.z,subdivisions:0}):r=e.parameters;let o=O(O({},r),i.parameters);return{parameters:{width:Math.abs(o.width),height:Math.abs(o.height),depth:Math.abs(o.depth),subdivisions:Math.abs(o.subdivisions)},geometry:t}}static build(i){var l;let{width:e,height:t,depth:r,subdivisions:o}=i.parameters,n=(l=i.geometry)!=null?l:new ih().copy(new nh(100,100,100)),s=n.userData.parameters;s===void 0?(n.computeBoundingBox(),n.boundingBox.getSize(at)):at.set(s.width,s.height,s.depth),(e!==at.x||t!==at.y||r!==at.z)&&n.scale(at.x===0?1:e/at.x,at.y===0?1:t/at.y,at.z===0?1:r/at.z);let a=n.originalGeometry;return o>0?(a===void 0||(s==null?void 0:s.subdivisions)!==o)&&(a===void 0&&(a=n),n=new wl(o).modify(a).toBufferGeometry()):(a!==void 0&&(n=a),a=void 0,n.getAttribute("normal")===void 0&&n.computeVertexNormals()),a!==void 0&&Object.assign(n,{originalGeometry:a}),delete i.geometry,Object.assign(n,{userData:$(O({},i),{type:"NonParametricGeometry"})})}static loadFromUrl(i,e,t){new Dv(t).load(i,o=>{let n=this.normalizeInputs({geometry:o});o.boundingBox.getSize(at);let s=100/at.x;Object.assign(n.parameters,{width:100,height:at.y*s,depth:at.z*s}),e(this.build(n))})}};var sh=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var o,n,s,a;let t=Object.assign({},(o=e==null?void 0:e.parameters)!=null?o:{width:100,depth:0,spikes:5,cornerRadius:0,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:3},i.parameters);return{shape:i.shape&&i.shape instanceof Pe?i.shape:new Pe,parameters:Object.assign(t,{surfaceMaxCount:((n=t.surfaceMaxCount)!=null?n:t.cornerRadius>0)?1e3:100,width:Math.abs(t.width),height:Math.abs((s=t.height)!=null?s:t.width),depth:Math.abs(t.depth!==void 0&&t.depth===0&&t.extrudeDepth>0?t.extrudeDepth:(a=t.depth)!=null?a:0)})}}static build(i){let{width:e,height:t,spikes:r,cornerRadius:o,depth:n,extrudeBevelSize:s,extrudeBevelSegments:a,surfaceMaxCount:l}=i.parameters,c=i.shape,d=e*.5,u=t*.5,p=0,f=0,m=2*Math.PI/r;for(let y=0;y<r;y++){let N=m*y,L=p+Math.sin(N)*d,w=f+Math.cos(N)*u;c.addPoint(c.createPoint(L,w))}c.isClosed=!0;for(let y=0,N=c.points.length;y<N;y++)c.points[y].roundness=o;c.roundness=o,c.update();let x=mt.create({shape:c,parameters:{surfaceMaxCount:l,roundness:o,depth:n,extrudeBevelSize:s,extrudeBevelSegments:a}});return Object.assign(x,{userData:$(O({},i),{type:"PolygonGeometry"})})}};import{BufferGeometry as Gv,Float32BufferAttribute as Nl,Vector2 as vr,Vector3 as dt}from"three";var ah=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,o,n;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((o=t.height)!=null?o:t.width),depth:Math.abs((n=t.depth)!=null?n:t.width)})}}static build(i){let{width:e,height:t,depth:r,radialSegments:o,heightSegments:n,openEnded:s,cornerRadius:a,cornerSegments:l}=i.parameters,c=new lh(e*.5,t,o,n,s,a,l);return c.scale(1,1,r/e),Object.assign(c,{userData:$(O({},i),{type:"PyramidGeometry"})})}};function Wi(i,e,t){t.x=i.x*e.x,t.y=i.y,t.z=i.x*e.y}function Cl(i,e,t,r,o,n){let s=e.clone().sub(i),a=t.clone().sub(i),l=s.angleTo(a);if(s.normalize(),a.normalize(),r===o){let c=s.add(a).normalize();n.copy(i).addScaledVector(c,r/Math.sin(l/2))}else{let c=s.angleTo(a);n.copy(i),n.addScaledVector(s,o/Math.sin(c)),n.addScaledVector(a,r/Math.sin(c))}}function zv(i,e,t){let r=i.clone().sub(e),o=t.clone().sub(e);return r.projectOnVector(o),r.add(e)}var lh=class extends Gv{constructor(e=.5,t=1,r=4,o=1,n=!1,s=0,a=4){super();r=Math.floor(Math.max(3,r)),o=Math.floor(o),a=Math.floor(a);let l=[],c=[],d=[],u=[],p=0,f=t/2,m=Math.PI/r,x=e*Math.cos(Math.PI/r),y=2*Math.PI/r,N=(r-2)*Math.PI/r,L=Math.PI-N,w=new dt(0,-f,0),B=new dt(0,f,0),S=new vr(e,-f),_=new vr(x,-f),T=new vr(0,B.y).sub(_),h=new vr(0,B.y).sub(S),I=new vr(T.y,-T.x).normalize(),b=new vr(h.y,-h.x).normalize(),v=e*Math.cos(Math.PI/r)*Math.tan((Math.PI-T.angle())/2)-1e-8;s=Math.min(s,v);let D;{let A=new dt(I.x,I.y,0),j=new dt(Math.cos(y)*A.x,A.y,Math.sin(y)*A.x);D=A.angleTo(j)}let Z=s/Math.tan((Math.PI-T.angle())/2),V=s/Math.tan((Math.PI-D)/2),ie=new dt;if(!n){c.push(w.x,w.y,w.z),d.push(0,-1,0),u.push(0,0);let A=p++,j=[],g=S.clone(),z=Z/Math.cos(Math.PI/r);g.x-=z;for(let R=0;R<r;R++){let U=R/r*Math.PI*2+m,q=new vr(Math.sin(U),Math.cos(U));Wi(g,q,ie),c.push(ie.x,ie.y,ie.z),d.push(0,-1,0),u.push(0,0),j.push(p++)}for(let R=0;R<j.length;R++)l.push(j[R],A,j[(R+1)%j.length])}let oe=[];{let A=new dt,j=new dt,g=new dt,z=new dt,R=new dt,U=new dt;for(let q=0;q<r;q++){let W=q/r*Math.PI*2+m,J=(q+.5)/r*Math.PI*2+m,E=(q+1)/r*Math.PI*2+m,H=new vr(Math.sin(W),Math.cos(W)),k=new vr(Math.sin(J),Math.cos(J)),se=new vr(Math.sin(E),Math.cos(E));Wi(S,H,j),Wi(S,se,g),Wi(I,k,A),Cl(B,j,g,V,V,z),c.push(z.x,z.y,z.z),Cl(j,B,g,V,Z,R),c.push(R.x,R.y,R.z),Cl(g,j,B,Z,V,U),c.push(U.x,U.y,U.z),d.push(A.x,A.y,A.z),d.push(A.x,A.y,A.z),d.push(A.x,A.y,A.z),u.push(0,0),u.push(0,0),u.push(0,0);let F=p++,K=p++,X=p++;if(l.push(F,K,X),s>0){{let Y=j.clone().add(g).multiplyScalar(.5),ne=B.clone().sub(Y).normalize(),me=w.clone().sub(Y).normalize().add(ne).normalize().multiplyScalar(-1),Oe=U.clone().sub(R);ge(Y,Oe,me,T.angle())}let te,he;{let Y=new dt;Wi(b,se,Y);let ne=U.clone().add(z).multiplyScalar(.5);ne=zv(ne,g,B);let Se=U.clone().sub(z);[te,he]=ge(ne,Se,Y,D,z.y)}{let Y=te,ne=Y.clone().setY(0).normalize(),Se=new dt(0,-1,0),me=ne.clone().cross(Se);xe(Y,ne,Se,me)}oe.concat(he);{let Y=T.angle(),ne=Math.PI-Y,Se=B.clone();Se.y-=s/Math.sin(Y-Math.PI/2);let me=new dt,Oe=[];for(let rt=0;rt<a;rt++){let pt=[],zt=Math.PI/2-ne*rt/a,Tr=Math.cos(zt),xt=Math.sin(zt),Ir=J;for(let uo=0;uo<=rt;uo++){let ho=Math.cos(Ir),qe=Math.sin(Ir);A.x=Tr*qe,A.y=xt,A.z=Tr*ho,me.copy(Se).addScaledVector(A,s),c.push(me.x,me.y,me.z),d.push(A.x,A.y,A.z),u.push(0,0),pt.push(p++),Ir+=Math.PI*2/rt/r}Oe.push(pt)}he.reverse(),Oe.push(he);let He=Oe.length-1;for(let rt=0;rt<He;rt++){let pt=Oe[rt],zt=Oe[rt+1],Tr=pt.length-1;l.push(zt[1],pt[0],zt[0]);for(let xt=1;xt<=Tr;xt++)l.push(pt[xt],pt[xt-1],zt[xt]),l.push(zt[xt+1],pt[xt],zt[xt])}}}}}this.setIndex(l),this.setAttribute("position",new Nl(c,3)),this.setAttribute("normal",new Nl(d,3)),this.setAttribute("uv",new Nl(u,2));function ge(A,j,g,z,R){let U=-z/2,q=(Math.PI-z)/2,W=j.clone().normalize().cross(g);A.addScaledVector(g,-s/Math.sin(q));let J=new dt,E=new dt,H=1,k=p,se=[];for(let F=0;F<=a;F++){let K=U+F/a*z;E.set(0,0,0),E.addScaledVector(W,Math.sin(K)),E.addScaledVector(g,Math.cos(K));for(let X=0;X<=H;X++){let te=X/H-.5;if(J.copy(A),J.addScaledVector(j,te),J.addScaledVector(E,s),R!=null){let he=Math.max(0,J.y-R);J.addScaledVector(j,-he/j.y)}c.push(J.x,J.y,J.z),d.push(E.x,E.y,E.z),u.push(0,0),X===0&&se.push(p),p++}}for(let F=0;F<a;F++)for(let K=0;K<H;K++){let X=k+K+(H+1)*F,te=X+(H+1),he=te+1,Y=X+1;l.push(X,te,Y),l.push(te,he,Y)}return[A.clone().addScaledVector(j,.5),se]}function xe(A,j,g,z){let R=Math.PI/2,U=h.angle()-R,q=[],W=new dt,J=new dt;for(let H=0;H<=a;H++){let k=[],se=H/a;for(let F=0;F<=H;F++){let X=((H?F/H:0)-.5)*L,te=Math.cos(X),he=Math.sin(X),Y=Math.atan(Math.tan(U)*te),ne=(R+Y)*se,Se=Math.cos(ne),me=Math.sin(ne);W.set(0,0,0),W.addScaledVector(j,me*te),W.addScaledVector(g,Se),W.addScaledVector(z,me*he),J.copy(A).addScaledVector(W,s),c.push(J.x,J.y,J.z),d.push(W.x,W.y,W.z),u.push(0,0),k.push(p++)}q.push(k)}let E=q.length-1;for(let H=0;H<E;H++){let k=q[H],se=q[H+1],F=k.length-1;l.push(k[0],se[1],se[0]);for(let K=1;K<=F;K++)l.push(k[K-1],k[K],se[K]),l.push(k[K],se[K+1],se[K])}}}};var Ws=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var s,a,l,c,d;let t=Object.assign({},(s=e==null?void 0:e.parameters)!=null?s:{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters),r=Object.assign((a=e==null?void 0:e.ui)!=null?a:{enabledIndieCorners:!1},i.ui),o=t.cornerRadius.reduce((u,p)=>u+p,0);return{shape:i.shape&&i.shape instanceof Pe?i.shape:new Pe,parameters:Object.assign(t,{surfaceMaxCount:((l=t.surfaceMaxCount)!=null?l:o>0)?1e3:100,width:Math.abs(t.width),height:Math.abs((c=t.height)!=null?c:t.width),depth:Math.abs(t.depth!==void 0&&t.depth===0&&t.extrudeDepth>0?t.extrudeDepth:(d=t.depth)!=null?d:0)}),ui:r}}static build(i){let e=i.shape,{width:t,height:r,cornerRadius:o,cornerType:n,depth:s,extrudeBevelSize:a,extrudeBevelSegments:l,surfaceMaxCount:c}=i.parameters,d={x:t*.5,y:r*.5},u={x:-d.x,y:-d.y},p={x:d.x,y:d.y};function f(S,_,T){return _>t&&T>r?Math.min(S*t/_,S*r/T):_>t?S*t/_:T>r?S*r/T:S}let m=[];m[0]=o[0]===0?0:f(o[0],o[0]+o[3],o[0]+o[1]),m[1]=o[1]===0?0:f(o[1],o[1]+o[2],o[1]+o[0]),m[2]=o[2]===0?0:f(o[2],o[2]+o[1],o[2]+o[3]),m[3]=o[3]===0?0:f(o[3],o[3]+o[0],o[3]+o[2]);let x=u.x,y=p.x,N=p.y,L=u.y;e.addPoint(e.createPoint(x,N)),e.addPoint(e.createPoint(y,N)),e.addPoint(e.createPoint(y,L)),e.addPoint(e.createPoint(x,L)),e.isClosed=!0;let w=!0;for(let S=0,_=e.points.length;S<_;S++)e.points[S].roundness=m[S],S>0&&m[S]!==m[S-1]&&(w=!1);w&&(e.roundness=m[0]),e.useCubicForRoundedCorners=n!==1,e.update();let B=mt.create({shape:e,parameters:{surfaceMaxCount:c,depth:s,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(B,{userData:$(O({},i),{type:"RectangleGeometry"})})}};import{SphereBufferGeometry as Ev}from"three";var ch=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,o,n;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((o=t.height)!=null?o:t.width),depth:Math.abs((n=t.depth)!=null?n:t.width)})}}static build(i){let{width:e=100,height:t=e,depth:r=e,widthSegments:o=64,heightSegments:n=64,phiStart:s,phiLength:a,thetaStart:l,thetaLength:c}=i.parameters,d=new Ev(.5*e,o,n,s,a,l,c);return d.scale(1,t/e,r/e),Object.assign(d,{userData:$(O({},i),{type:"SphereGeometry"})})}};import{PlaneBufferGeometry as Fv}from"three";var dh=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,o;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,depth:0,widthSegments:8,heightSegments:8},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((o=t.height)!=null?o:t.width),depth:0})}}static build(i){let{width:e=100,height:t=e,widthSegments:r=8,heightSegments:o=8}=i.parameters,n=new Fv(e,t,r,o);return n.scale(1,1,1),Object.assign(n,{userData:$(O({},i),{type:"PlaneGeometry"})})}};var ph=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var o,n,s,a;let t=Object.assign({},(o=e==null?void 0:e.parameters)!=null?o:{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters);return{shape:i.shape&&i.shape instanceof Pe?i.shape:new Pe,parameters:Object.assign(t,{surfaceMaxCount:((n=t.surfaceMaxCount)!=null?n:t.cornerRadius>0)?1e3:100,width:Math.abs(t.width),height:Math.abs((s=t.height)!=null?s:t.width),depth:Math.abs(t.depth!==void 0&&t.depth===0&&t.extrudeDepth>0?t.extrudeDepth:(a=t.depth)!=null?a:0)})}}static build(i){let{width:e,height:t,innerRadiusPercent:r,spikes:o,cornerRadius:n,angle:s,depth:a,extrudeBevelSize:l,extrudeBevelSegments:c,surfaceMaxCount:d}=i.parameters,u=i.shape,p=e*.5,f=t*.5,m=0,x=0,y=s*Math.PI/360/o,N=Math.PI/2*3*-1,L=p*r/100,w=f*r/100;if(o==3&&r==50){y=2*Math.PI/o;for(let S=0;S<o;S++){let _=y*S,T=m+Math.sin(_)*p,h=x+Math.cos(_)*f;u.addPoint(u.createPoint(T,h))}}else for(let S=0;S<o;S++){let _=m+Math.cos(N)*p,T=x+Math.sin(N)*f;u.addPoint(u.createPoint(_,T)),N+=y,_=m+Math.cos(N)*L,T=x+Math.sin(N)*w,S<=o,u.addPoint(u.createPoint(_,T)),N+=y}u.isClosed=!0;for(let S=0,_=u.points.length;S<_;S++)u.points[S].roundness=n;u.roundness=n,u.update();let B=mt.create({shape:u,parameters:{surfaceMaxCount:d,roundness:n,depth:a,extrudeBevelSize:l,extrudeBevelSegments:c}});return Object.assign(B,{userData:$(O({},i),{type:"StarGeometry"})})}};import{PlaneBufferGeometry as Rv}from"three";var $s=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,o,n;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,depth:0},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((o=t.height)!=null?o:t.width),depth:Math.abs((n=t.depth)!=null?n:0)})}}static build(i){let{width:e,height:t}=i.parameters,r=new Rv(e,t);return Object.assign(r,{userData:$(O({},i),{type:"TextFrameGeometry"})})}};var uh=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var s,a,l;let t=Object.assign({},(s=e==null?void 0:e.parameters)!=null?s:{width:100,radialSegments:32,tubularSegments:64,arc:Math.PI*2,cornerRadius:30,cornerSegments:8},i.parameters),r=Math.abs(t.width),o=Math.abs((a=t.height)!=null?a:t.width),n=Math.abs((l=t.depth)!=null?l:t.width*.25);return{parameters:Object.assign(t,{width:r,height:o,depth:n})}}static build(i){let{width:e,height:t,depth:r,radialSegments:o,tubularSegments:n,arc:s,cornerRadius:a,cornerSegments:l}=i.parameters,c=Vv(e,t,r,e*.5,s,n,0,0,o,a,l);return c.scale(1,t/e,1),Object.assign(c,{userData:$(O({},i),{type:"TorusGeometry"})})}};function Vv(i,e,t,r,o,n,s,a,l,c,d){return[e,t]=[t,e],s=e/2,o/=2*Math.PI,o==1&&(c=0),new Vs(!0,i,e,t,r,o,n,s,a,l,c,d)}import{TorusKnotBufferGeometry as Uv}from"three";var hh=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,o,n,s;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((o=t.height)!=null?o:t.width),depth:Math.abs((n=t.depth)!=null?n:t.width),tube:(s=t.tube)!=null?s:t.width*.125})}}static build(i){let{width:e,tube:t,tubularSegments:r,radialSegments:o,p:n,q:s}=i.parameters,a=e*.5;a!==t&&(a-=t);let l=new Uv(a,t,r,o,n,s);return Object.assign(l,{userData:$(O({},i),{type:"TorusKnotGeometry"})})}};var mh=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var o,n,s,a;let t=Object.assign({},(o=e==null?void 0:e.parameters)!=null?o:{width:100,depth:0,spikes:5,cornerRadius:0,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},i.parameters);return{shape:i.shape&&i.shape instanceof Pe?i.shape:new Pe,parameters:Object.assign(t,{surfaceMaxCount:((n=t.surfaceMaxCount)!=null?n:t.cornerRadius>0)?1e3:100,width:Math.abs(t.width),height:Math.abs((s=t.height)!=null?s:t.width*(t.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(t.depth!==void 0&&t.depth===0&&t.extrudeDepth>0?t.extrudeDepth:(a=t.depth)!=null?a:0)})}}static build(i){let{width:e=100,height:t,cornerRadius:r,depth:o,extrudeBevelSize:n,extrudeBevelSegments:s,isRect:a,surfaceMaxCount:l}=i.parameters,c=i.shape,d=e*.5,u=t*.5;a?(c.addPoint(c.createPoint(-d,u)),c.addPoint(c.createPoint(d,-u)),c.addPoint(c.createPoint(-d,-u))):(c.addPoint(c.createPoint(0,u)),c.addPoint(c.createPoint(d,-u)),c.addPoint(c.createPoint(-d,-u))),c.isClosed=!0;for(let f=0,m=c.points.length;f<m;f++)c.points[f].roundness=r;c.roundness=r,c.update();let p=mt.create({shape:c,parameters:{surfaceMaxCount:l,roundness:r,depth:o,extrudeBevelSize:n,extrudeBevelSegments:s}});return Object.assign(p,{userData:$(O({},i),{type:"TriangleGeometry"})})}};var $i={};Hm($i,{addBarycentricAttribute:()=>$v,fixUvs:()=>Kv,loadFromUrl:()=>Jv,resizeGeometry:()=>Wv,roundShapePolygon:()=>qv});import{BufferGeometryLoader as kv,Float32BufferAttribute as Hv,Vector3 as Ll}from"three";var fh=function(i,e){let t=e.x-i.x,r=e.y-i.y,o=Math.sqrt(t*t+r*r),n=t/o,s=r/o,a=Math.atan2(s,n);return{x:t,y:r,len:o,nx:n,ny:s,ang:a}},qv=(i,e,t)=>{let r,o,n,s,a,l,c,d,u,p,f,m,x,y,N=e.length;for(s=e[N-2],i.curves=[],r=1;r<N-1;r++){a=e[r%N],l=e[(r+1)%N];let L=fh(a,s),w=fh(a,l);c=L.nx*w.ny-L.ny*w.nx,d=L.nx*w.nx-L.ny*-w.ny,f=Math.asin(c),u=1,p=!1,d<0?f<0?f=Math.PI+f:(f=Math.PI-f,u=-1,p=!0):f>0&&(u=-1,p=!0),m=f/2,y=Math.abs(Math.cos(m)*t/Math.sin(m)),y>Math.min(L.len/2,w.len/2)?(y=Math.min(L.len/2,w.len/2),x=Math.abs(y*Math.sin(m)/Math.cos(m))):x=t,o=a.x+w.nx*y,n=a.y+w.ny*y,o+=-w.ny*x*u,n+=w.nx*x*u,i.absarc(o,n,x,L.ang+Math.PI/2*u,w.ang-Math.PI/2*u,p),s=a,a=l}i.closePath()},Wv=(i,{width:e,height:t,depth:r})=>{e=Math.abs(e),t=Math.abs(t),r=Math.abs(r);let o=i.userData.parameters,n,s,a;e===0?(e=o.width,n=1):n=e/o.width,t===0?(t=o.height,s=1):s=t/o.height,r===0?(r=o.depth,a=1):a=r/o.depth,i.scale(n,s,a),o.width=e,o.height=t,o.depth=r},$v=(i,e)=>{let t=[new Ll(1,0,0),new Ll(0,1,0),new Ll(0,0,1)],r=i.attributes.position,o=new Float32Array(r.count*3);for(let n=0,s=r.count;n<s;n++)t[n%3].toArray(o,n*3);i.setAttribute(e,new Hv(o,3))},Jv=i=>new Promise(e=>{new kv().load(i,r=>e(r))}),Kv=(i,e,t)=>{let r=i.getAttribute("uv");if(r)for(let o=0;o<r.count;o++){let n=r.getX(o),s=r.getY(o);r.setXY(o,(n+e/2)/e,1-(s-t/2)/t*-1)}};import{BufferGeometry as yh,BufferAttribute as gh,Uint32BufferAttribute as Tl,Float32BufferAttribute as Il,Matrix4 as Zv}from"three";import{mergeVertices as Qv}from"three/examples/jsm/utils/BufferGeometryUtils.js";var Xv,Js=new Promise(i=>{Xv=i});var de;Js.then(i=>{de=i});var xh=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),bh=new Uint32Array([0,1,2,3]),vh=new Uint8Array([4]),kt=class{static build(i,e,t,r,o){let n,s,a;if(i===void 0)n=kt.allocate(o,t),de.set_destination_refinement_level(n,0),s=kt.buildLevel(n,!0,r);else if(i.positionWASM!==void 0){e&&e!==0&&(de.free_bvh(e),de.free_subdivision_surface(e));try{n=kt.allocate(o,void 0,i)}catch(l){console.error(l,i),n=kt.allocate(o,void 0,{positionWASM:xh,indexWASM:bh,verticesPerFaceWASM:vh})}de.set_destination_refinement_level(n,0),s=kt.buildLevel(n,!0,r)}else n=e;if(i!==void 0&&i.subdivisions!==void 0){let l=Yv(i.subdivisions,i.positionWASM.length);de.set_destination_refinement_level(n,l),l>0?a=kt.buildLevel(n,!1,r):a=null}return{subdivPointer:n,originalGeometry:s,subdividedGeometry:a}}static allocate(i,e,t){var S;let r,o,n,s=[],a=[];if(t)t.positionWASM&&t.positionWASM.length>0?(r=t.positionWASM,o=t.indexWASM,n=t.verticesPerFaceWASM):(r=xh,o=bh,n=vh);else{e.deleteAttribute("normal"),e.deleteAttribute("uv");let _=Qv(e);r=_.attributes.position.array;let T=_.getIndex().array,h=T.length;switch(e.userData.type==="TorusGeometry"&&(e==null?void 0:e.userData.parameters.arc)===Math.PI*2&&(e.userData.type="ClosedTorusGeometry"),e.userData.type){case"ClosedTorusGeometry":case"PlaneGeometry":case"TorusKnotGeometry":case"CubeGeometry":o=new Uint32Array(h/3*2),n=new Uint8Array(h/6).fill(4);for(let V=0,ie=0;V<h;V+=6)o[ie++]=T[V],o[ie++]=T[V+1],o[ie++]=T[V+4],o[ie++]=T[V+5];break;case"TorusGeometry":case"SphereGeometry":case"HelixGeometry":case"CylinderGeometry":case"ConeGeometry":let I,b,P;if(e.userData.type==="SphereGeometry")b=e.parameters.heightSegments,I=e.parameters.widthSegments,e.parameters.thetaLength!==Math.PI&&(P=!0);else if(e.userData.type==="CylinderGeometry")b=e.parameters.heightSegments+2,I=e.parameters.radialSegments;else if(e.userData.type==="ConeGeometry")b=e.parameters.heightSegments+1,I=e.parameters.radialSegments;else if(e.userData.type==="TorusGeometry"){let V=e.userData.parameters;b=Math.ceil(V.tubularSegments*V.arc/(2*Math.PI))+2,I=V.radialSegments}else{let{pathSegments:V,segments:ie,revolutions:oe}=e.userData.parameters;b=Math.ceil(ie*oe)+2,I=V}P?(o=new Uint32Array(1*I*3+(b-1)*I*4),n=new Uint8Array(1*I+(b-1)*I)):(o=new Uint32Array(2*I*3+(b-2)*I*4),n=new Uint8Array(2*I+(b-2)*I));let v=0,D=0,Z=0;if(e.userData.type==="SphereGeometry"||e.userData.type==="HelixGeometry"||e.userData.type==="TorusGeometry"){for(;D<3*I;)o[D++]=T[v++],o[D++]=T[v++],o[D++]=T[v++],n[Z++]=3;let V=P?o.length:3*I+4*(b-2)*I;for(;D<V;v+=6)o[D++]=T[v],o[D++]=T[v+1],o[D++]=T[v+4],o[D++]=T[v+5],n[Z++]=4}else for(;D<4*(b-2)*I;v+=6)o[D++]=T[v],o[D++]=T[v+1],o[D++]=T[v+4],o[D++]=T[v+5],n[Z++]=4;for(;D<o.length;)o[D++]=T[v++],o[D++]=T[v++],o[D++]=T[v++],n[Z++]=3;break;default:o=T,n=new Uint8Array(h/3).fill(3);break}}let l=r.length,c=o.length,d=n.length,u=r.length+s.length+a.length,p=o.length+n.length,f=u*Float32Array.BYTES_PER_ELEMENT+p*Uint32Array.BYTES_PER_ELEMENT,m=u*Float32Array.BYTES_PER_ELEMENT,x=p*Uint32Array.BYTES_PER_ELEMENT,y=de._malloc(f),N=new Float32Array(de.HEAPF32.buffer,y,u),L=new Uint32Array(de.HEAPU32.buffer,y+m,p);N.set(r,0),N.set(s,r.length),N.set(a,r.length+s.length),L.set(o,0),L.set(n,o.length);let w;((S=t==null?void 0:t.scaleBaked)==null?void 0:S.some(_=>_!==1))&&(w=new Zv().makeScale(...t.scaleBaked)),i&&(w?w.premultiply(i):w=i);let B=w?de.alloc_subdivision_surface2(y,l,y+m,c,y+m+o.length*Uint32Array.BYTES_PER_ELEMENT,d,w.elements):de.alloc_subdivision_surface(y,l,y+m,c,y+m+o.length*Uint32Array.BYTES_PER_ELEMENT,d);return de._free(y),B}static buildLevel(i,e,t,r,o){let n=o?de.get_mesh_data2(i,e?de.Level.CONTROL:de.Level.REFINED,t!=null?t:!e,o.elements):de.get_mesh_data(i,e?de.Level.CONTROL:de.Level.REFINED,t!=null?t:!e),s=8,a=de.HEAPU32.subarray(n>>2,(n>>2)+s),l=a.subarray(4,4+4),c=0,d=de.HEAPU32[a[c]>>2],u=de.HEAPF32.subarray(d>>2,(d>>2)+l[c]);c++;let p=de.HEAPU32[a[c]>>2],f=de.HEAPF32.subarray(p>>2,(p>>2)+l[c]);c++;let m=de.HEAPU32[a[c]>>2],x=de.HEAPU32.subarray(m>>2,(m>>2)+l[c]);c++;let y=de.HEAPU32[a[c]>>2],N=de.HEAPU32.subarray(y>>2,(y>>2)+l[c]);if(c++,r===void 0){let L=new yh;if(L.setIndex(new Tl(N,1)),L.setAttribute("position",new Il(u,3)),L.setAttribute("normal",new Il(f,3)),e){L.setAttribute("faceMap",new Tl(x,1));let w=new Float32Array(f.length/3*4).fill(0);L.setAttribute("color",new gh(w,4))}return de.free_mesh_data(n),L.userData.type="SubdivGeometry",L}r.getAttribute("position").copyArray(u),r.getAttribute("normal").copyArray(f),r.attributes.position.needsUpdate=!0,r.attributes.normal.needsUpdate=!0,de.free_mesh_data(n)}static buildControlCageWireframe(i,e,t){let r=de.get_wireframe_data_for_base_level(i),o=4,n=de.HEAPU32.subarray(r>>2,(r>>2)+o),s=n.subarray(2,2+2),a=0,l=de.HEAPU32[n[a]>>2],c=de.HEAPF32.subarray(l>>2,(l>>2)+s[a]);a++;let d=de.HEAPU32[n[a]>>2],u=de.HEAPU32.subarray(d>>2,(d>>2)+s[a]);if(e===void 0){let p=new yh;p.setAttribute("position",new Il(c,3));let f=new Float32Array(c.length);for(let m=0,x=c.length;m<x;)f[m++]=t.r,f[m++]=t.g,f[m++]=t.b;return p.setAttribute("color",new gh(f,3)),p.setIndex(new Tl(u,1)),de.free_wireframe_data_for_base_level(r),p}e.getAttribute("position").copyArray(c),e.attributes.position.needsUpdate=!0,de.free_wireframe_data_for_base_level(r)}static updateCollabMesh(i,e,t){e||de.set_destination_refinement_level(i,1);let r=t?de.get_topological_data2(i,e?de.Level.CONTROL:de.Level.REFINED,t.elements):de.get_topological_data(i,e?de.Level.CONTROL:de.Level.REFINED),o=6,n=de.HEAPU32.subarray(r>>2,(r>>2)+o),s=n.subarray(3,3+3),a=0,l=de.HEAPU32[n[a]>>2],c=new Float32Array(de.HEAPF32.subarray(l>>2,(l>>2)+s[a]));a++;let d=de.HEAPU32[n[a]>>2],u=new Uint32Array(de.HEAPU32.subarray(d>>2,(d>>2)+s[a]));a++;let p=de.HEAPU32[n[a]>>2],f=new Uint8Array(de.HEAPU32.subarray(p>>2,(p>>2)+s[a]));return de.free_topological_data(r),{positions:c,indices:u,verticesPerFace:f}}};function Yv(i,e){let t=i;return t=Math.min(t,3-Math.ceil(Math.log(e/172e3)/Math.log(4))),Math.max(t,0)}var Ml={ConeGeometry:wu,CubeGeometry:Nu,CylinderGeometry:vu,DodecahedronGeometry:Lu,EllipseGeometry:Ju,HelixGeometry:eh,IcosahedronGeometry:th,LatheGeometry:rh,NonParametricGeometry:qs,PolygonGeometry:sh,PyramidGeometry:ah,RectangleGeometry:Ws,SphereGeometry:ch,PlaneGeometry:dh,StarGeometry:ph,TextFrameGeometry:$s,TorusGeometry:uh,TorusKnotGeometry:hh,TriangleGeometry:mh,VectorGeometry:mt},Ji=i=>Ml[i.type].create(i);import{Matrix4 as _l}from"three";import{Box3 as Ch,Line3 as Qt,Matrix4 as Pl,Vector3 as Re}from"three";import{HemisphereLight as Sh}from"three";import{Color as eS}from"three";var Ht=class extends eS{constructor(e,t,r,o){super(e,t,r);this.a=o}setRGBA(e,t,r,o){super.setRGB(e,t,r),this.a=o}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}};function Ye(i,e){let t;if(typeof i=="string"){let r=e==null?void 0:e.getColor(i);r?t=r:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),t=new Ht(0,0,0,0))}else return"a"in i?new Ht(i.r,i.g,i.b,i.a):new Ht(i.r,i.g,i.b,1);return t}var Ks=i=>"isEntity"in i,Xs=i=>"isAbstractMesh"in i;var Er=i=>"objectHelper"in i;function tS(i,e){var r;let t=!1;e.position&&(i.position.fromArray(e.position),t=!0),e.rotation&&(i.rotation.fromArray(e.rotation),t=!0),e.scale&&(t=!0,i.scale.fromArray(e.scale)),e.hiddenMatrix!==void 0&&"hiddenMatrix"in i&&(t=!0,i.hiddenMatrix.fromArray((r=e.hiddenMatrix)!=null?r:Zr.identity)),t&&i.updateMatrix(),e.position&&e.rotation&&e.scale&&e.hiddenMatrix!==void 0&&i.updateWorldMatrix(!1,!0),i.objectType==="CombinedCamera"&&(e.isUpVectorFlipped!==void 0&&(i.isUpVectorFlipped=e.isUpVectorFlipped),i.updateUp())}function rS(i,e){tS(i,e),e.name!==void 0&&(i.name=e.name),e.visible!==void 0&&(i.isEntity?i.visibility=e.visible:i.visible=e.visible)}function wh(i,e,t){rS(i,e),e.color!==void 0&&(i.color=Ye(e.color,t)),e.intensity!==void 0&&(i.intensity=e.intensity),e.shadows!==void 0&&!(i instanceof Sh)&&(i.castShadow=e.shadows),i.shadow&&!(i instanceof Sh)&&e.depth!==void 0&&(i.shadow.camera.far=e.depth,i.shadow.needsUpdate=!0),e.helper!==void 0&&Er(i)&&(i.enableHelper=e.helper,i.gizmos.shadowmap.visible=e.helper)}function Nh(i,e){i.shadow.camera.right=e/2,i.shadow.camera.left=-e/2,i.shadow.camera.top=e/2,i.shadow.camera.bottom=-e/2,i.shadow.needsUpdate=!0}var pi=new Ch,ft=new Re,le=new Re,tt=new Pl;function oS(i,e,t=0,r=e.count){let o=1/0,n=1/0,s=1/0,a=-1/0,l=-1/0,c=-1/0;for(let d=t;d<r;d++){let u=e.getX(d),p=e.getY(d),f=e.getZ(d);u<o&&(o=u),p<n&&(n=p),f<s&&(s=f),u>a&&(a=u),p>l&&(l=p),f>c&&(c=f)}return i.min.set(o,n,s),i.max.set(a,l,c),i}var Lh=(i,e,t,r)=>{var o;if(Xs(i)){let n=i.geometry.userData.parameters,s=i.geometry.getAttribute("position");i.geometry.userData.type==="SubdivGeometry"?ft.copy(i.originalGeometry.boundingSphere.center):(oS(pi,s,i.geometry.drawRange.start,i.geometry.drawRange.count<1/0?i.geometry.drawRange.count:s.count),pi.getCenter(ft)),i.forceComputeSize?pi.getSize(le).multiplyScalar(.5):le.set(n.width,n.height,(o=n.depth)!=null?o:0).multiplyScalar(.5)}else if(Er(i)&&r===!0){let n=i.geometryHelper.getAttribute("position");pi.setFromArray(n.array),pi.getCenter(ft),pi.getSize(le).multiplyScalar(.5)}else ft.setScalar(0),le.setScalar(0);tt.copy(e).multiply(i.matrixWorld),le.x===0&&le.y===0&&le.z===0?t.push(new Re(ft.x,ft.y,ft.z).applyMatrix4(tt)):t.push(new Re(-le.x,le.y,le.z).add(ft).applyMatrix4(tt),new Re(-le.x,-le.y,le.z).add(ft).applyMatrix4(tt),new Re(le.x,-le.y,le.z).add(ft).applyMatrix4(tt),new Re(le.x,le.y,le.z).add(ft).applyMatrix4(tt),new Re(-le.x,le.y,-le.z).add(ft).applyMatrix4(tt),new Re(-le.x,-le.y,-le.z).add(ft).applyMatrix4(tt),new Re(le.x,-le.y,-le.z).add(ft).applyMatrix4(tt),new Re(le.x,le.y,-le.z).add(ft).applyMatrix4(tt))},Zs=class extends Ch{constructor(){super(...arguments);this.matrix=new Pl;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 r=new Pl().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,r,t)}expandByObjectSize(e,t,r=!1){let o=[];return r===!0?e.traverseEntity(n=>Lh(n,t,o,e.enableHelper===!0)):Lh(e,t,o,e.enableHelper===!0),this.setFromPoints(o)}getCenter(e){return e=super.getCenter(e),e.applyMatrix4(this.matrix),e}getPositionToCenter(e){return e=super.getCenter(e),e.applyMatrix4(tt.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(le).multiplyScalar(.5),this.getCenter(ft),tt.copy(this.matrix).setPosition(ft),this.vertices=[new Re(-le.x,le.y,le.z).applyMatrix4(tt),new Re(-le.x,-le.y,le.z).applyMatrix4(tt),new Re(le.x,-le.y,le.z).applyMatrix4(tt),new Re(le.x,le.y,le.z).applyMatrix4(tt),new Re(-le.x,le.y,-le.z).applyMatrix4(tt),new Re(-le.x,-le.y,-le.z).applyMatrix4(tt),new Re(le.x,-le.y,-le.z).applyMatrix4(tt),new Re(le.x,le.y,-le.z).applyMatrix4(tt)]}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=[new Qt(this.vertices[0],this.vertices[3]),new Qt(this.vertices[1],this.vertices[2]),new Qt(this.vertices[5],this.vertices[6]),new Qt(this.vertices[4],this.vertices[7]),new Qt(this.vertices[0],this.vertices[1]),new Qt(this.vertices[3],this.vertices[2]),new Qt(this.vertices[7],this.vertices[6]),new Qt(this.vertices[4],this.vertices[5]),new Qt(this.vertices[0],this.vertices[4]),new Qt(this.vertices[1],this.vertices[5]),new Qt(this.vertices[2],this.vertices[6]),new Qt(this.vertices[3],this.vertices[7])],this.centerEdges=this.edges.map(e=>e.getCenter(new Re))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=[new Re().copy(this.vertices[0]).sub(this.vertices[2]).multiplyScalar(.5).add(this.vertices[2]),new Re().copy(this.vertices[7]).sub(this.vertices[5]).multiplyScalar(.5).add(this.vertices[5]),new Re().copy(this.vertices[4]).sub(this.vertices[1]).multiplyScalar(.5).add(this.vertices[1]),new Re().copy(this.vertices[3]).sub(this.vertices[6]).multiplyScalar(.5).add(this.vertices[6]),new Re().copy(this.vertices[4]).sub(this.vertices[3]).multiplyScalar(.5).add(this.vertices[3]),new Re().copy(this.vertices[1]).sub(this.vertices[6]).multiplyScalar(.5).add(this.vertices[6])]}};import{Object3D as yS,Matrix4 as gS,Light as xS}from"three";import{Group as hS,Mesh as Ah,MeshStandardMaterial as jh}from"three";import{BufferGeometry as iS,Float32BufferAttribute as Ol}from"three";function Th(i){var s;let e=[],t=i.groups,r=i.getAttribute("position").array,o=i.getAttribute("normal").array,n=(s=i.getAttribute("uv"))==null?void 0:s.array;return t.forEach(a=>{let l=a.count,c=new iS,d=new Float32Array(l*3),u=new Float32Array(l*3),p=new Float32Array(l*2);for(let f=0;f<l;f++){let m=3*(a.start+f),x=3*f;if(d[x]=r[m],d[x+1]=r[m+1],d[x+2]=r[m+2],u[x]=o[m],u[x+1]=o[m+1],u[x+2]=o[m+2],n){let y=2*(a.start+f),N=2*f;p[N]=n[y],p[N+1]=n[y+1]}}c.setAttribute("position",new Ol(d,3)),c.setAttribute("normal",new Ol(u,3)),n&&c.setAttribute("uv",new Ol(p,2)),e.push(c)}),e}import{GLTFExporter as mS}from"three/examples/jsm/exporters/GLTFExporter.js";var nS,Ih=new Promise(i=>{nS=i});var _h=wc(Oh());var Ys={isPublish:!1,gltfQueue:[]};function jl(i,e,t){return i[e.uuid]===void 0&&(i[e.uuid]=e.toJSON(t)),e.uuid}var fS=new mS;function Dh(i,e,t){if(i[e.uuid]===void 0)if(e.userData.type==="NonParametricGeometry"||e.userData.type==="SubdivGeometry"){if(e.userData.type==="SubdivGeometry")if(Ys.isPublish)e=qs.create({geometry:e.clone()}),e.userData.parameters.subdivisions===0&&(delete e.attributes.color,delete e.attributes.faceMap,delete e.attributes.positionWASM,delete e.attributes.indexWASM,delete e.attributes.verticesPerFaceWASM);else{let o=e.originalGeometry;if(o){let n=e.userData;e=o.clone(),e.userData=n}else e=e.clone();delete e.attributes.color,delete e.attributes.faceMap,delete e.attributes.position,delete e.attributes.normal,e.index=null}let r=e.originalGeometry;if(r!==void 0){let o=e.userData;e=r,e.userData=o}if(!Ys.isPublish)i[e.uuid]=e.toJSON();else{let o={type:"NonParametricGeometry",uuid:e.uuid,userData:{}};e.name!==""&&(o.name=e.name),Object.keys(e.userData).length>0&&(o.userData=O({},e.userData));let n=e.index===null,s=new hS;if(Array.isArray(t))Th(e).forEach((l,c)=>{let d=new Ah(l,new jh);s.add(d),l.userData.groupIndex=c,l.userData.materialIndex=e.groups[c].materialIndex,l.index===null&&(n=!0)});else{let a=new Ah(e,new jh);s.add(a)}Ys.gltfQueue.push(new Promise(async a=>{await Promise.all(Ys.gltfQueue),fS.parse(s,async l=>{let{gltfTransform:c,DracoMeshCompressionExtension:d,addIndex:u}=await Ih,p=c.readJSON({json:yo(l),resources:{}});p.createExtension(d).setRequired(!0).setEncoderOptions({quantizationVolume:"scene"}),n&&await p.transform(u);try{let{json:f,resources:m}=c.writeJSON(p),x=_h.default.fromByteArray(new Uint8Array(m[".bin"]));f.buffers[0].uri=`data:application/octet-stream;base64,${x}`,a()}catch(f){a()}},{})})),i[e.uuid]=o}}else{let r=e.userData;if(r.type==="VectorGeometry"){let o=e.userData.shape;r=Object.assign({},r,{shape:o.toJSON()})}i[e.uuid]={uuid:e.uuid,userData:r}}return e.uuid}function ui(i){let e=[];for(let t in i){let r=i[t];delete r.metadata,e.push(r)}return e}function Bh(i){let e=[];for(let t in i)e.push(i[t]);return e}var ea=i=>class extends i{hasEntityChild(){return this.children.some(t=>Ks(t))}isDescendantOf(t){t instanceof yS&&(t=t.uuid);let r=this;for(;r.parent;){if(r.parent.uuid===t)return!0;r=r.parent}return!1}attach(t,r){this.updateWorldMatrix(!0,!1);let o=new gS().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),o.multiply(t.parent.matrixWorld)),Ks(t)?t.hiddenMatrix.premultiply(o):t.applyMatrix4(o),t.updateWorldMatrix(!1,!1),this.add(t),r!==void 0&&(this.children.pop(),this.children.splice(r,0,t)),this}copy(t,r=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),r===!0)for(let o=0;o<t.children.length;o++){let n=t.children[o];this.add(n.clone())}return this}toJSON(t){let r=t===void 0,o={object:{uuid:"",objectType:""}};t===void 0&&(t={geometries:{},materials:{},textures:{},images:{},interactionStates:{},nodes:{}},o.metadata={version:1.5,type:"Object",generator:"Object3D.toJSON"});let n={uuid:this.uuid,objectType:this.type};if(this.name!==""&&(n.name=this.name),n.matrix=this.matrix.toArray(),this.castShadow===!0&&(n.castShadow=!0),this.receiveShadow===!0&&(n.receiveShadow=!0),this.visible===!1&&(n.visible=!1),this.frustumCulled===!1&&(n.frustumCulled=!1),this.renderOrder!==0&&(n.renderOrder=this.renderOrder),n.layers=this.layers.mask,JSON.stringify(this.userData)!=="{}"&&(n.userData=this.userData),this.children.length>0){n.children=[];for(let s of this.children)(Ks(s)||s instanceof xS)&&n.children.push(s.toJSON(t).object)}if(r){let s=ui(t.geometries),a=ui(t.materials),l=ui(t.textures),c=ui(t.images),d=ui(t.interactionStates),u=Bh(t.nodes);s.length>0&&(o.geometries=s),a.length>0&&(o.materials=a),l.length>0&&(o.textures=l),c.length>0&&(o.images=c),d.length>0&&(o.interactionStates=d),u.length>0&&(o.nodes=u)}return o.object=n,o}fromJSON(t){return this.uuid=t.uuid,t.name!==void 0&&(this.name=t.name),t.matrix!==void 0?(this.matrix.fromArray(t.matrix),t.matrixAutoUpdate!==void 0&&(this.matrixAutoUpdate=t.matrixAutoUpdate),this.matrixAutoUpdate&&this.matrix.decompose(this.position,this.quaternion,this.scale)):(t.position!==void 0&&this.position.fromArray(t.position),t.rotation!==void 0&&this.rotation.fromArray(t.rotation),t.quaternion!==void 0&&this.quaternion.fromArray(t.quaternion),t.scale!==void 0&&this.scale.fromArray(t.scale)),this.castShadow=t.castShadow!==void 0,this.receiveShadow=t.receiveShadow!==void 0,t.visible!==void 0&&(this.visible=t.visible),t.frustumCulled!==void 0&&(this.frustumCulled=t.frustumCulled),t.renderOrder!==void 0&&(this.renderOrder=t.renderOrder),t.layers!==void 0&&(this.layers.mask=t.layers),t.userData!==void 0&&(this.userData=t.userData),this}};var er=i=>"isEntity"in i;var tr=i=>class extends ea(i){constructor(){super(...arguments);this.objectType="";this.isEntity=!0;this.raycastLock=!1;this.scaleLock=!1;this.hiddenMatrix=new _l;this._singleBBox=new Zs;this._recursiveBBox=new Zs;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this.forceComputeSize=!1}set visibility(t){this.visible=t;for(let r of this.children)er(r)&&r.traverseEntity(o=>{Er(o)&&o.visible&&(o.objectHelper.visible=t)})}get visibility(){return this.visible}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}resetBBoxNeedsUpdate(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0,this.traverseAncestors(t=>{er(t)&&(t.singleBBoxNeedsUpdate=!0,t.recursiveBBoxNeedsUpdate=!0)}),this.traverseEntity(t=>{t.singleBBoxNeedsUpdate=!0,t.recursiveBBoxNeedsUpdate=!0})}traverseEntity(t){t(this);for(let r of this.children)er(r)&&r.traverseEntity(t)}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 r of this.children)r.updateMatrixWorld(t)}updateWorldMatrix(t,r){let o=this.parent;if(t&&o!==null&&o.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)),r)for(let n of this.children)n.updateWorldMatrix(!1,!0)}shallowClone(t){return new this.constructor().shallowCopy(this,t)}shallowCopy(t,r=!0){if(super.copy(t,!1),this.raycastLock=t.raycastLock,this.scaleLock=t.scaleLock,this.hiddenMatrix.copy(t.hiddenMatrix),r===!0)for(let o of t.children)er(o)&&this.add(o.shallowClone());return this}clone(t){return new this.constructor().copy(this,t)}copy(t,r=!0){if(super.copy(t,!1),this.raycastLock=t.raycastLock,this.scaleLock=t.scaleLock,this.hiddenMatrix.copy(t.hiddenMatrix),r===!0)for(let o of t.children)er(o)&&this.add(o.clone());return this}keepChildrenMatrixWorld(){let t=new _l,r=this.matrixWorld.clone();this.updateWorldMatrix(!1,!1),t.copy(this.matrixWorld).invert(),t.multiply(r);for(let o of this.children)er(o)&&o.hiddenMatrix.premultiply(t)}toJSON(t){let r=super.toJSON(t),o=r.object;return this.raycastLock===!0&&(o.raycastLock=!0),this.scaleLock===!0&&(o.scaleLock=!0),o.hiddenMatrix=this.hiddenMatrix.toArray(),r}fromJSON(t){return super.fromJSON(t),t.raycastLock!==void 0&&(this.raycastLock=t.raycastLock),t.scaleLock!==void 0&&(this.scaleLock=t.scaleLock),this.hiddenMatrix.fromArray(t.hiddenMatrix),this}fromObject3D(t){let r=t.children;return t.children=[],Object.assign(t,{raycastLock:!1,scaleLock:!1,hiddenMatrix:new _l}),this.copy(t),t.children=r,this}toObjectTransformState(t=[]){this.updateWorldMatrix(!0,!1);let r={position:this.position.toArray(),rotation:[this.rotation.x,this.rotation.y,this.rotation.z],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return Zo(r,t)}fromObjectTransformState(t){return t.position&&this.position.fromArray(t.position),t.rotation&&this.rotation.fromArray(t.rotation),t.scale&&this.scale.fromArray(t.scale),t.hiddenMatrix&&this.hiddenMatrix.fromArray(t.hiddenMatrix),this.updateMatrix(),this}toState(t=[]){let r=O({name:this.name,visible:this.visible,raycastLock:this.raycastLock},this.toObjectTransformState(t));return Zo(r,t)}fromState(t,r){return t.name&&(this.name=t.name),t.raycastLock!==void 0&&(this.raycastLock=t.raycastLock),t.type!=="OrthographicCamera"&&t.type!=="PerspectiveCamera"&&(this.matrixAutoUpdate=!1),t.visible!==void 0&&(this.visibility=t.visible),this.fromObjectTransformState(t),this}};import{Object3D as bS,Vector3 as Ki,Euler as Gh,MathUtils as io}from"three";var ta=class extends bS{constructor(e,t={}){super();this.object=e;let r=e.recursiveBBox.getSize(new Ki),o=.1;this.parameters=rs.defaultData(r.toArray(),o),go(this.parameters,t),this.update(),this.setHideBase(this.parameters.hideBase)}refreshMaterial(){if("material"in this.object)for(let e of this.children)e.material=this.object.material}setHideBase(e){if("material"in this.object){if(Array.isArray(this.object.material)){if(this.children.length>0){for(let t of this.object.material)t.visible=!0;if(e){let t=this.object.material.map(r=>r.clone());for(let r of this.children)r.material=t}else for(let t of this.children)t.material=this.object.material}for(let t of this.object.material)t.visible=!e}else{if(this.children.length>0)if(this.object.material.visible=!0,e){let t=this.object.material.clone();for(let r of this.children)r.material=t}else for(let t of this.children)t.material=this.object.material;this.object.material.visible=!e}this.parameters.hideBase=e}}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)}this.children.forEach(e=>e.updateMatrix())}_updateCount(){let e=this.parameters.type==="grid"?this.parameters.grid.count[0]*this.parameters.grid.count[1]*this.parameters.grid.count[2]:this.parameters.count;if(this.children.length!==e)if(this.children.length<e)for(let t=0,r=e-this.children.length;t<r;++t){let o=this.object.shallowClone(!1);o.visible=!0,this.add(o),this.parameters.hideBase&&this.setHideBase(!0)}else for(let t=0,r=this.children.length-e;t<r;++t)this.remove(this.children[0])}_updateRadial(e){let t=e.radial,r=t.start*io.DEG2RAD,o=t.end*io.DEG2RAD,n=r-o,s=new Gh(t.rotation[0]*io.DEG2RAD,t.rotation[1]*io.DEG2RAD,t.rotation[2]*io.DEG2RAD),a;switch(t.axis){case"z":a=new Ki(0,0,1);break;case"y":a=new Ki(0,1,0);break;default:case"x":a=new Ki(1,0,0);break}for(let[l,c]of this.children.entries()){c.hiddenMatrix.identity(),c.scale.x=t.scale[0]+1,c.scale.y=t.scale[1]+1,c.scale.z=t.scale[2]+1,c.position.setScalar(0);let d=n/e.count*l-r;switch(t.axis){case"x":c.rotation.set(0,d,0);break;case"y":c.rotation.set(0,0,d);break;case"z":c.rotation.set(d,0,0);break}c.translateOnAxis(a,t.radius),c.position.x+=t.position[0],c.position.y+=t.position[1],c.position.z+=t.position[2],t.alignment===!0?(c.rotation.x+=s.x,c.rotation.y+=s.y,c.rotation.z+=s.z):c.rotation.copy(s)}}_updateLinear(e){if(e.type!=="linear")throw new Error;let t=e.linear,r=new Gh(t.rotation[0]*io.DEG2RAD,t.rotation[1]*io.DEG2RAD,t.rotation[2]*io.DEG2RAD);for(let[o,n]of this.children.entries())n.hiddenMatrix.identity(),n.scale.x=t.scale[0]*o+1,n.scale.y=t.scale[1]*o+1,n.scale.z=t.scale[2]*o+1,n.rotation.x=r.x*o,n.rotation.y=r.y*o,n.rotation.z=r.z*o,n.position.x=t.position[0]*o,n.position.y=t.position[1]*o,n.position.z=t.position[2]*o}_updateGrid(e){let t=0,r=e.grid;if(r.useCenter===!0){let o={x:r.count[0]%2==0?2:1,y:r.count[1]%2==0?2:1,z:r.count[2]%2==0?2:1},n=new Ki(r.size[0]*(r.count[0]-o.x)*.5,r.size[1]*(r.count[1]-o.y)*.5,r.size[2]*(r.count[2]-o.z)*.5);for(let s=0;s<r.count[0];s++)for(let a=0;a<r.count[1];a++)for(let l=0;l<r.count[2];l++){let c=this.children[t++];c.hiddenMatrix.identity(),c.scale.setScalar(1),c.rotation.set(0,0,0),c.position.x=r.size[0]*s-n.x,c.position.y=r.size[1]*a-n.y,c.position.z=r.size[2]*l-n.z}}else for(let o=0;o<r.count[0];o++)for(let n=0;n<r.count[1];n++)for(let s=0;s<r.count[2];s++){let a=this.children[t++];a.hiddenMatrix.identity(),a.scale.setScalar(1),a.rotation.set(0,0,0),a.position.x=r.size[0]*o,a.position.y=-r.size[1]*n,a.position.z=-r.size[2]*s}}fromJSON(e){return this}toJSON(){return{}}fromClonerState(e){return e.hideBase!==void 0&&this.setHideBase(e.hideBase),go(this.parameters,e),this.update(),this}};var yt=class extends tr(vS){constructor(e,t){super(e,t);this.isAbstractMesh=!0;Array.isArray(t)&&(this.selectedMaterial=0,e.groups.length===0&&e.addGroup(0,e.getAttribute("position").count,0))}get cloner(){return this._cloner}set cloner(e){this._cloner&&this.remove(this._cloner),e&&this.add(e),this._cloner=e}getSelectedMaterial(e){return Array.isArray(this.material)?(this.selectedMaterial===void 0&&(this.selectedMaterial=e!=null?e:0),this.material[e!=null?e:this.selectedMaterial]):this.material}setSelectedMaterial(e,t){Array.isArray(this.material)?(this.selectedMaterial===void 0&&(this.selectedMaterial=t!=null?t:0),t=t!=null?t:this.selectedMaterial,this.material[t].dispose(),this.material[t]=e):(this.material.dispose(),this.material=e)}updateGeometry(e){let t=this.geometry,r=Ml[t.userData.type],o=this.objectType==="NonParametric"?Object.assign({},t.userData,{geometry:t}):t.userData,n=r.build(r.normalizeInputs(e,o)),s=t.uuid;if(this.geometry.dispose(),this.geometry=n,this.geometry.uuid=s,this.geometry.computeBoundingSphere(),this.cloner)for(let a of this.cloner.children)a.geometry=this.geometry}resizeGeometry(e,t,r){$i.resizeGeometry(this.geometry,{width:e,height:t,depth:r})}shallowClone(e){return new this.constructor(this.geometry,this.material).shallowCopy(this,e)}clone(e){let t=this.objectType==="NonParametric"?Object.assign({},this.geometry.userData,{geometry:this.geometry.clone()}):this.geometry.userData,r=Ji(t),o=Array.isArray(this.material)?this.material.map(n=>n.clone()):this.material.clone();return new this.constructor(r,o).copy(this,e)}copy(e,t=!0){return super.copy(e,t),e.cloner&&(this.cloner=new ta(e,e.cloner.parameters),this.add(this.cloner)),this}toJSON(e){let t=super.toJSON(e),r=t.object;if(r.geometry=Dh(e.geometries,this.geometry,this.material),Array.isArray(this.material)){let o=[];for(let n=0,s=this.material.length;n<s;n++)o.push(jl(e.materials,this.material[n],e));r.material=o}else r.material=jl(e.materials,this.material,e);return t}fromJSON(e){return super.fromJSON(e),e.selectedMaterial!==void 0&&(this.selectedMaterial=e.selectedMaterial),this}setFromClonerState(e){e===null?this.cloner=void 0:(this.cloner===void 0&&(this.cloner=new ta(this)),this.cloner.fromClonerState(e))}fromState(e,t){var r,o;return super.fromState(e),e.type==="Mesh"&&(this.setFromClonerState(e.cloner),this.castShadow=(r=e.castShadow)!=null?r:!0,this.receiveShadow=(o=e.receiveShadow)!=null?o:!0),this}};import{NormalBlending as US,ShaderMaterial as kS,FrontSide as HS}from"three";import{CubeReflectionMapping as jS,CubeRefractionMapping as _S,CubeUVReflectionMapping as DS,CubeUVRefractionMapping as BS,LinearEncoding as Uh,sRGBEncoding as GS}from"three";var ra=class{constructor(e){e=e!=null?e:{},this.name=e.name,this.type=e.type,this.node=e.node,this.size=e.size,this.needsUpdate=e.needsUpdate}get value(){return this.node.value}set value(e){this.node.value=e}};import{MathUtils as SS}from"three";var pe=class{constructor(e){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=SS.generateUUID(),this.type=e,this.name="",this.userData={}}analyze(e,t){t=t!=null?t:{},e.analyzing=!0,this.build(e.addFlow(t.slot,t.cache,t.context),"v4"),e.clearVertexNodeCode(),e.clearFragmentNodeCode(),e.removeFlow(),e.analyzing=!1}analyzeAndFlow(e,t,r){return r=r!=null?r:{},this.analyze(e,r),this.flow(e,t,r)}flow(e,t,r){r=r!=null?r:{},e.addFlow(r.slot,r.cache,r.context);let o={result:this.build(e,t),code:e.clearNodeCode(),extra:e.context.extra};return e.removeFlow(),o}build(e,t,r){t=t!=null?t:this.getType(e,t);let o=e.getNodeData(r!=null?r:this);return e.analyzing&&this.appendDepsNode(e,o,t),e.nodes.indexOf(this)===-1&&e.nodes.push(this),this.updateFrame!==void 0&&e.updaters.indexOf(this)===-1&&e.updaters.push(this),this.generate(e,t,r)}updateFrame(e){}generateReadonly(e,t,r,o,n,s){return""}generate(e,t,r,o,n){return""}parse(e,t,r,o){}appendDepsNode(e,t,r){t.deps=(t.deps||0)+1;let o=e.getTypeLength(r);(o>(t.outputMax||0)||this.getType(e,r))&&(t.outputMax=o,t.output=r)}setName(e){this.name=e}getName(){return this.name}getType(e,t){return t==="sampler2D"||t==="samplerCube"?t:this.type}getJSONNode(e){if((e==null?void 0:e.materials)&&(e==null?void 0:e.materials[this.uuid])!==void 0)return e.materials[this.uuid]}getHash(){let e="{",t,r;for(t in this)r=this[t],r instanceof pe&&(e+='"'+t+'":'+r.getHash()+",");if(this.hashProperties)for(let o=0;o<this.hashProperties.length;o++)t=this.hashProperties[o],r=this[t],e+='"'+t+'":"'+String(r)+'",';return e+='"id":"'+this.uuid+'"}',e}copy(e){return this.name=e.name,e.type&&(this.type=e.type),e.frameId&&(this.frameId=e.frameId),e.hashProperties&&(this.hashProperties=e.hashProperties.map(t=>t)),this.userData=JSON.parse(JSON.stringify(e.userData)),this.shortcuts=JSON.parse(JSON.stringify(e.shortcuts)),this}clone(){return new this.constructor().copy(this)}createJSONNode(e){let t=e===void 0||typeof e=="string";if(typeof this.type!="string")throw new Error("Node does not allow serialization.");let r={};return r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),JSON.stringify(this.userData)!=="{}"&&(r.userData=this.userData),!t&&e&&(e.nodes[this.uuid]=r),r}toJSON(e){var t;return(t=this.getJSONNode(e))!=null?t:this.createJSONNode(e)}fromJSON(e,t){return this.uuid=e.uuid,this.type=e.type,e.name&&(this.name=e.name),e.userData&&(this.userData=e.userData),this}};var zh=class{constructor(){this.nodes={};this.keywords={}}add(e){this.nodes[e.name]=e}addKeyword(e,t,r){r=r!==void 0?r:!0,this.keywords[e]={callback:t,cache:r}}remove(e){delete this.nodes[e.name]}removeKeyword(e){delete this.keywords[e]}get(e){return this.nodes[e]}getKeyword(e,t){return this.keywords[e].callback(t)}getKeywordData(e){return this.keywords[e]}contains(e){return this.nodes[e]!==void 0}containsKeyword(e){return this.keywords[e]!==void 0}},lt=new zh;import{Vector2 as Eh}from"three";import{MathUtils as wS}from"three";var ue=class extends pe{constructor(e,t){super(e);this.scope="";t=t!=null?t:{},this.shared=t.shared!==void 0?t.shared:!0,this.unique=t.unique!==void 0?t.unique:!1}build(e,t,r,o){if(t=t!=null?t:this.getType(e),this.getShared(e,t)){let n=this.getUnique(e,t);n&&this.uuid===void 0&&(this.uuid=wS.generateUUID()),r=e.getUUID(r!=null?r:this.getUUID(),!n);let s=e.getNodeData(r),a=s.output||this.getType(e);if(e.analyzing)return(s.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,s,t),this.generate(e,t,r)):super.build(e,t,r);if(n)return s.name=s.name||super.build(e,t,r),s.name;if(!this.getLabel()&&(!this.getShared(e,a)||e.context.ignoreCache||s.deps===1))return super.build(e,t,r);r=this.getUUID(!1);let l=this.getTemp(e,r);if(l)return e.format(l,a,t);{l=super.generate(e,t,r,s.output,o);let c=this.generate(e,a,r);return e.addNodeCode(l+" = "+c+";"),e.format(l,a,t)}}return super.build(e,t,r)}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 r=e.getVars()[t];return r?r.name:void 0}generate(e,t,r,o,n){return this.getShared(e,t)||console.error("TempNode is not shared"),r=r!=null?r:this.uuid,e.getTempVar(r,o!=null?o:this.getType(e),n,this.getLabel()).name}};var Ue=class extends ue{constructor(e,t){t=t!=null?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}createJSONNode(e){let t=super.createJSONNode(e);return this.readonly===!0&&(t.readonly=this.readonly),t}fromJSON(e,t){return super.fromJSON(e,t),e.readonly!==void 0&&this.setReadonly(e.readonly),this}generate(e,t,r,o,n,s){r=e.getUUID(r!=null?r:this.getUUID()),o=o!=null?o:this.getType(e);let a=e.getNodeData(r);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,t,r,o,n,s):e.isShader("vertex")?(a.vertex||(a.vertex=e.createVertexUniform(o,this,n,s,this.getLabel())),e.format(a.vertex.name,o,t)):(a.fragment||(a.fragment=e.createFragmentUniform(o,this,n,s,this.getLabel())),e.format(a.fragment.name,o,t))}copy(e){return super.copy(e),this.readonly=e.readonly,this}};var It=class extends Ue{constructor(e=0,t){super("v2");this.nodeType="Vector2";this.value=e instanceof Eh?e:new Eh(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,r,o,n,s){return e.format("vec2("+this.value.x+", "+this.value.y+")",o,t)}copy(e){return super.copy(e),this.value.copy(e.value),this}};import{Vector3 as Fh}from"three";var Mt=class extends Ue{constructor(e=0,t,r){super("v3");this.nodeType="Vector3";this.value=e instanceof Fh?e:new Fh(e,t,r)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,t,r,o,n,s){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",o,t)}copy(e){return super.copy(e),this.value.copy(e.value),this}};var no=class extends Ue{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof Ht?e:new Ht(e.r,e.g,e.b,e.a)}generateReadonly(e,t,r,o,n,s){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",o,t)}copy(e){return super.copy(e),this.value.copy(e.value),this}};var NS=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,Rh=/[a-z_0-9]+/gi,re=class extends ue{constructor(e,t,r,o,n){super(n);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=n===void 0,this.isInterface=!1,this.parse(e,t,r,o)}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,r,o,n){let s,a=0,l=this.src;if(this.includes)for(let d=0;d<this.includes.length;d++)e.include(this.includes[d],this);for(let d in this.extensions)e.extensions[d]=!0;let c=[];for(;s=Rh.exec(this.src);)c.push(s);for(let d=0;d<c.length;d++){let u=c[d],p=u[0],f=this.isMethod?!this.getInputByName(p):!0,m=p;if(this.keywords[p]||this.useKeywords&&f&<.containsKeyword(p)){let x=this.keywords[p];if(!x){let y=lt.getKeywordData(p);y.cache&&(x=e.keywords[p]),x=x||lt.getKeyword(p,e),y.cache&&(e.keywords[p]=x)}m=x.build(e)}p!==m&&(l=l.substring(0,u.index+a)+m+l.substring(u.index+p.length+a),a+=m.length-p.length),this.getIncludeByName(m)===void 0&<.contains(m)&&e.include(lt.get(m))}return t==="source"?l:this.isMethod?(this.isInterface||e.include(this,void 0,l),this.name):e.format("( "+l+" )",this.getType(e),t)}parse(e,t,r,o){if(this.src=e||"",this.includes=t!=null?t:[],this.extensions=r!=null?r:{},this.keywords=o!=null?o:{},this.isMethod){let n=NS.exec(this.src);if(this.inputs=[],n&&n.length==4){this.type=n[1],this.name=n[2];let s=n[3].match(Rh);if(s){let a=0;for(;a<s.length;){let l=s[a++],c;l==="in"||l==="out"||l==="inout"?c=s[a++]:(c=l,l="");let d=s[a++];this.inputs.push({name:d,type:c,qualifier:l})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}copy(e){return super.copy(e),this.isMethod=e.isMethod,this.useKeywords=e.useKeywords,e.type!==void 0&&(this.type=e.type),this.parse(e.src,e.includes,e.extensions,e.keywords),this}toJSON(e){var r;let t=this.getJSONNode(e);if(!t){t=this.createJSONNode(e),t.src=this.src,t.isMethod=this.isMethod,t.useKeywords=this.useKeywords,this.isMethod||(t.type=this.type),t.extensions=JSON.parse(JSON.stringify(this.extensions));let o={};for(let n in this.keywords)o[n]=this.keywords[n].toJSON(e).uuid;if(t.keywords=o,(r=this.includes)==null?void 0:r.length){let n=[];for(let s=0;s<this.includes.length;s++)n.push(this.includes[s].toJSON(e).uuid);t.includes=n}t.isMethod=this.isMethod,t.inputs=this.inputs}return t.nodeType=this.nodeType,t}fromJSON(e,t){if(super.fromJSON(e,t),e.inputs!==void 0&&(this.inputs=e.inputs),e.isMethod!==void 0&&(this.isMethod=e.isMethod),e.src&&(this.src=e.src),e.isMethod&&(this.isMethod=e.isMethod),e.useKeywords&&(this.useKeywords=e.useKeywords),e.type&&(this.type=e.type),e.extensions&&(this.extensions=e.extensions),e.keywords&&t){this.keywords={};for(let r in e.keywords)this.keywords[r]=t.getNode(e.keywords[r])}return e.includes&&t&&(this.includes=e.includes.map(r=>t.getNode(r))),this}};var CS=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,Dl=class extends ue{constructor(e="",t){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||Dl.PI,void 0,void 0,void 0,t)}getType(e){return e.getTypeByFormat(this.type)}parse(e,t,r,o,n){this.src=e||"";let s,a,l="",c=CS.exec(e);this.useDefine=n!=null?n:this.src.charAt(0)==="#",c&&c.length>1?(a=c[1],s=c[2],l=c[3]):(s=this.src,a="f"),this.name=s,this.type=a,this.value=l}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,r,o,n){return e.format(this.name,this.getType(e),t)}copy(e){return super.copy(e),this.parse(e.src,void 0,void 0,void 0,e.useDefine),this}},Ie=Dl;Ie.PI="PI",Ie.PI2="PI2",Ie.RECIPROCAL_PI="RECIPROCAL_PI",Ie.RECIPROCAL_PI2="RECIPROCAL_PI2",Ie.LOG2="LOG2",Ie.EPSILON="EPSILON";var LS=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
|
|
2
2
|
)*?)}`,"gim"),TS=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),Xi=class extends ue{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,r,o,n){return t==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),t)}parse(e=""){this.src=e,this.inputs=[];let t=LS.exec(e);if(t){let r=t[2],o;for(;o=TS.exec(r);)this.inputs.push({type:o[1],name:o[2]});this.name=t[1]}else this.name="";this.type=this.name}};var Zi=class extends ue{constructor(e){super("v2",{shared:!1});this.nodeType="UV";this.index=e!=null?e:0}generate(e,t){e.requires.uv[this.index]=!0;let r=this.index>0?this.index+1:"",o=e.isShader("vertex")?"uv"+r:"vUv"+r;return e.format(o,this.getType(e),t)}copy(e){return super.copy(e),this.index=e.index,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.index=this.index),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.index&&(this.index=e.index),this}};lt.addKeyword("uv",function(){return new Zi});lt.addKeyword("uv2",function(){return new Zi(1)});import{LinearEncoding as IS,sRGBEncoding as MS}from"three";var Lo=class extends ue{constructor(e=new pe,t){super("v4");this.nodeType="ColorSpace";this.factor=new pe;this.input=e,this.method=t!=null?t:Lo.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case IS:return["Linear"];case MS:return["sRGB"];default:return[]}}generate(e,t){var a;let r=this.input.build(e,"v4"),o=this.getType(e),n=Lo.Nodes[this.method],s=e.include(n);if(s===Lo.LINEAR_TO_LINEAR)return e.format(r,o,t);if(((a=n.inputs)==null?void 0:a.length)===2){let l=this.factor.build(e,"f");return e.format(s+"( "+r+", "+l+" )",o,t)}else return e.format(s+"( "+r+" )",o,t)}fromEncoding(e){let t=Lo.getEncodingComponents(e);this.method="LinearTo"+t[0],this.factor=t[1]}fromDecoding(e){let t=Lo.getEncodingComponents(e);this.method=t[0]+"ToLinear",this.factor=t[1]}copy(e){return super.copy(e),this.input.copy(e.input),this.method=e.method,this.factor.copy(e.factor),this}},Dt=Lo;Dt.Nodes={LinearToLinear:new re(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
|
|
3
3
|
`)),sRGBToLinear:new re(["vec4 sRGBToLinear( in vec4 value ) {"," return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );","}"].join(`
|
|
4
4
|
`)),LinearTosRGB:new re(["vec4 LinearTosRGB( in vec4 value ) {"," return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );","}"].join(`
|
|
5
|
-
`))},Dt.LINEAR_TO_LINEAR="LinearToLinear",Dt.SRGB_TO_LINEAR="sRGBToLinear",Dt.LINEAR_TO_SRGB="LinearTosRGB";var Be=class extends re{constructor(e="",t,r,o,n){super(e,n,o,r,t);this.nodeType="Expression"}};import{Texture as PS}from"three";var Fr=class extends PS{toJSON(e){let t=super.toJSON(e),r=e===void 0||typeof e=="string";if(this.image!==void 0&&!r){let o=this.image;if(Array.isArray(o)){e.images[o.uuid].url=[];for(let n=0;n<o.length;n++)e.images[o.uuid].url[n]=Vh(o[n])}else e.images[o.uuid].url=Vh(o)}return t}};function Vh(i){return typeof HTMLImageElement!="undefined"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&i instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&i instanceof ImageBitmap?OS(i):(console.warn("THREE.Texture: Unable to serialize Texture."),"")}var hi;function OS(i){if(/^data:/i.test(i.src))return i.src;let e;if(i instanceof HTMLCanvasElement)e=i;else{hi===void 0&&(hi=document.createElement("canvas")),hi.width=i.width,hi.height=i.height;let r=hi.getContext("2d");i instanceof ImageData?r.putImageData(i,0,0):r.drawImage(i,0,0,i.width,i.height),e=hi}let t=i.src.startsWith("blob:")?i.fileName:i.src;return/\.jpe?g$/i.test(t)?e.toDataURL("image/jpeg",.6):e.toDataURL("image/png")}var Bt=class extends Ue{constructor(e=new Fr,t,r,o){super("v4",{shared:!0});this.nodeType="Texture";this.value=e,this.uv=t!=null?t:new Zi,this.bias=r,this.project=o!==void 0?o:!1}getTexture(e,t){return super.generate(e,t,this.value.uuid,"t")}generate(e,t){var d;if(t==="sampler2D")return this.getTexture(e,t);let r=this.getTexture(e,t),o=this.uv.build(e,this.project?"v4":"v2"),n=this.bias?this.bias.build(e,"f"):void 0;n===void 0&&e.context.bias&&(n=e.context.bias.setTexture(this).build(e,"f"));let s,a;this.project?s="texture2DProj":s=n?"tex2DBias":"tex2D",n?a=s+"( "+r+", "+o+", "+n+" )":a=s+"( "+r+", "+o+" )";let l={include:e.isShader("vertex"),ignoreCache:!0},c=this.getType(e);return e.addContext(l),this.colorSpace=(d=this.colorSpace)!=null?d:new Dt(new Be("",c)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(a),a=this.colorSpace.build(e,c),e.removeContext(),e.format(a,c,t)}copy(e){return super.copy(e),e.value.isRenderTargetTexture?this.value=e.value:this.value.copy(e.value),this.uv.copy(e.uv),e.bias?this.bias?this.bias.copy(e.bias):this.bias=e.bias.clone():this.bias=void 0,e.colorSpace?this.colorSpace?this.colorSpace.copy(e.colorSpace):this.colorSpace=e.colorSpace.clone():this.colorSpace=void 0,this.project=e.project,e.value.isRenderTargetTexture||(this.value.updateMatrix(),this.value.needsUpdate=!0),this}};var ee=class extends Ue{constructor(e){super("f");this.nodeType="Float";this.value=e!=null?e:0}generateReadonly(e,t,r,o,n,s){return e.format(this.value+(this.value%1?"":".0"),o,t)}copy(e){return super.copy(e),this.value=e.value,this}};var oa=class extends ue{constructor(e,t){super();this.inputs=[];this.nodeType="FunctionCall";this.value=e,this.inputs=t!=null?t:[]}getFunction(){return this.value}getType(e){return this.value.getType(e)}generate(e,t,r,o,n){o=this.getType(e);let s=this.value,a=s.build(e,t)+"( ",l=[];if(s.inputs){for(let c=0;c<s.inputs.length;c++){let d=s.inputs[c],p=this.inputs[c]||this.inputs[d.name];l.push(p.build(e,e.getTypeByFormat(d.type)))}a+=l.join(", ")+" )"}return e.format(a,o,t)}copy(e){return super.copy(e),this.value.copy(e.value),this.inputs=e.inputs.map(t=>t.clone()),this}toJSON(e){var r;let t=this.getJSONNode(e);if(!t){let o=this.value;if(t=this.createJSONNode(e),t.value=this.value.toJSON(e).uuid,(r=o.inputs)==null?void 0:r.length){t.inputs={};for(let n=0;n<o.inputs.length;n++){let s=o.inputs[n],a=this.inputs[n];t.inputs[s.name]=a.toJSON(e).uuid}}}return t}};var mi;(function(o){o.ADD="+",o.SUB="-",o.MUL="*",o.DIV="/"})(mi||(mi={}));var Bl=class extends ue{constructor(e=new pe,t=new pe,r=Bl.ADD){super();this.nodeType="Operator";this.type=e.type,this.a=e,this.b=t,this.op=r}getType(e){let t=this.a.getType(e),r=this.b.getType(e);return e.isTypeMatrix(t)?"v4":e.getTypeLength(r)>e.getTypeLength(t)?r:t}generate(e,t){let r=this.getType(e);this.type=r;let o=this.a.build(e,r),n=this.b.build(e,r);return e.format("( "+o+" "+this.op+" "+n+" )",r,t)}copy(e){return super.copy(e),this.a.copy(e.a),this.b.copy(e.b),this.op=e.op,this}},qt=Bl;qt.ADD=mi.ADD,qt.SUB=mi.SUB,qt.MUL=mi.MUL,qt.DIV=mi.DIV;var be;(function(g){g.RAD="radians",g.DEG="degrees",g.EXP="exp",g.EXP2="exp2",g.LOG="log",g.LOG2="log2",g.SQRT="sqrt",g.INV_SQRT="inversesqrt",g.FLOOR="floor",g.CEIL="ceil",g.NORMALIZE="normalize",g.FRACT="fract",g.SATURATE="saturate",g.SIN="sin",g.COS="cos",g.TAN="tan",g.ASIN="asin",g.ACOS="acos",g.ARCTAN="atan",g.ABS="abs",g.SIGN="sign",g.LENGTH="length",g.NEGATE="negate",g.INVERT="invert",g.MIN="min",g.MAX="max",g.MOD="mod",g.STEP="step",g.REFLECT="reflect",g.DISTANCE="distance",g.DOT="dot",g.CROSS="cross",g.POW="pow",g.MIX="mix",g.CLAMP="clamp",g.REFRACT="refract",g.SMOOTHSTEP="smoothstep",g.FACEFORWARD="faceforward"})(be||(be={}));var je=class extends ue{constructor(e=new pe,t=je.ABS,r,o){super();this.nodeType="Math";this.a=e,typeof t!="string"?this.b=t:o=t,typeof r!="string"?this.c=r:o=r,this.method=o,this.hashProperties=["method"]}getNumInputs(e){switch(this.method){case je.MIX:case je.CLAMP:case je.REFRACT:case je.SMOOTHSTEP:case je.FACEFORWARD:return 3;case je.MIN:case je.MAX:case je.MOD:case je.STEP:case je.REFLECT:case je.DISTANCE:case je.DOT:case je.CROSS:case je.POW:return 2;default:return 1}}getInputType(e){let t=e.getTypeLength(this.a.getType(e)),r=this.b?e.getTypeLength(this.b.getType(e)):0,o=this.c?e.getTypeLength(this.c.getType(e)):0;return t>r&&t>o?this.a.getType(e):r>o?this.b.getType(e):this.c.getType(e)}getType(e){switch(this.method){case je.LENGTH:case je.DISTANCE:case je.DOT:return"f";case je.CROSS:return"v3"}return this.getInputType(e)}generate(e,t){let r,o,n,s=this.a?e.getTypeLength(this.a.getType(e)):0,a=this.b?e.getTypeLength(this.b.getType(e)):0,l=this.c?e.getTypeLength(this.c.getType(e)):0,c=this.getInputType(e),d=this.getType(e);switch(this.type=d,this.method){case je.NEGATE:return e.format("( -"+this.a.build(e,c)+" )",c,t);case je.INVERT:return e.format("( 1.0 - "+this.a.build(e,c)+" )",c,t);case je.CROSS:r=this.a.build(e,"v3"),o=this.b.build(e,"v3");break;case je.STEP:r=this.a.build(e,s===1?"f":c),o=this.b.build(e,c);break;case je.MIN:case je.MAX:case je.MOD:r=this.a.build(e,c),o=this.b.build(e,a===1?"f":c);break;case je.REFRACT:r=this.a.build(e,c),o=this.b.build(e,c),n=this.c.build(e,"f");break;case je.MIX:r=this.a.build(e,c),o=this.b.build(e,c),n=this.c.build(e,l===1?"f":c);break;default:r=this.a.build(e,c),this.b&&(o=this.b.build(e,c)),this.c&&(n=this.c.build(e,c));break}let p=[];p.push(r),o&&p.push(o),n&&p.push(n);let u=this.getNumInputs(e);if(p.length!==u)throw Error(`Arguments not match used in "${this.method}". Require ${u}, currently ${p.length}.`);return e.format(this.method+"( "+p.join(", ")+" )",d,t)}copy(e){return super.copy(e),this.a.copy(e.a),this.b=e.b instanceof pe?e.b.clone():e.b,this.c=e.c instanceof pe?e.c.clone():e.c,this.method=e.method,this}},fe=je;fe.RAD=be.RAD,fe.DEG=be.DEG,fe.EXP=be.EXP,fe.EXP2=be.EXP2,fe.LOG=be.LOG,fe.LOG2=be.LOG2,fe.SQRT=be.SQRT,fe.INV_SQRT=be.INV_SQRT,fe.FLOOR=be.FLOOR,fe.CEIL=be.CEIL,fe.NORMALIZE=be.NORMALIZE,fe.FRACT=be.FRACT,fe.SATURATE=be.SATURATE,fe.SIN=be.SIN,fe.COS=be.COS,fe.TAN=be.TAN,fe.ASIN=be.ASIN,fe.ACOS=be.ACOS,fe.ARCTAN=be.ARCTAN,fe.ABS=be.ABS,fe.SIGN=be.SIGN,fe.LENGTH=be.LENGTH,fe.NEGATE=be.NEGATE,fe.INVERT=be.INVERT,fe.MIN=be.MIN,fe.MAX=be.MAX,fe.MOD=be.MOD,fe.STEP=be.STEP,fe.REFLECT=be.REFLECT,fe.DISTANCE=be.DISTANCE,fe.DOT=be.DOT,fe.CROSS=be.CROSS,fe.POW=be.POW,fe.MIX=be.MIX,fe.CLAMP=be.CLAMP,fe.REFRACT=be.REFRACT,fe.SMOOTHSTEP=be.SMOOTHSTEP,fe.FACEFORWARD=be.FACEFORWARD;var fi=class extends ue{constructor(e=new pe,t=new pe,r=new pe){super("v4");this.nodeType="TextureCubeUV";this.value=e,this.uv=t,this.bias=r}bilinearCubeUV(e,t,r,o){var l,c,d,p;let n=new oa(fi.Nodes.bilinearCubeUV,[t,r,o]);this.colorSpaceTL=(l=this.colorSpaceTL)!=null?l:new Dt(new Be("","v4")),this.colorSpaceTL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTL.input.parse(n.build(e)+".tl"),this.colorSpaceTR=(c=this.colorSpaceTR)!=null?c:new Dt(new Be("","v4")),this.colorSpaceTR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTR.input.parse(n.build(e)+".tr"),this.colorSpaceBL=(d=this.colorSpaceBL)!=null?d:new Dt(new Be("","v4")),this.colorSpaceBL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBL.input.parse(n.build(e)+".bl"),this.colorSpaceBR=(p=this.colorSpaceBR)!=null?p:new Dt(new Be("","v4")),this.colorSpaceBR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBR.input.parse(n.build(e)+".br");let s={include:e.isShader("vertex"),ignoreCache:!0};e.addContext(s),this.colorSpaceTLExp=new Be(this.colorSpaceTL.build(e,"v4"),"v4"),this.colorSpaceTRExp=new Be(this.colorSpaceTR.build(e,"v4"),"v4"),this.colorSpaceBLExp=new Be(this.colorSpaceBL.build(e,"v4"),"v4"),this.colorSpaceBRExp=new Be(this.colorSpaceBR.build(e,"v4"),"v4"),e.removeContext();let a=new Be("mix( mix( cubeUV_TL, cubeUV_TR, cubeUV.f.x ), mix( cubeUV_BL, cubeUV_BR, cubeUV.f.x ), cubeUV.f.y )","v4");return a.keywords.cubeUV_TL=this.colorSpaceTLExp,a.keywords.cubeUV_TR=this.colorSpaceTRExp,a.keywords.cubeUV_BL=this.colorSpaceBLExp,a.keywords.cubeUV_BR=this.colorSpaceBRExp,a.keywords.cubeUV=n,a}generate(e,t){if(e.isShader("fragment")){let r=this.uv,o=this.bias||e.context.roughness,n=new oa(fi.Nodes.roughnessToMip,[o]),s=new fe(n,fi.Nodes.m0,fi.Nodes.cubeUV_maxMipLevel,fe.CLAMP),a=new fe(s,fe.FLOOR),l=new fe(s,fe.FRACT),c=this.bilinearCubeUV(e,this.value,r,a),d=this.bilinearCubeUV(e,this.value,r,new qt(a,new ee(1).setReadonly(!0),qt.ADD)),p=new fe(c,d,l,fe.MIX);return e.format(p.build(e),"v4",t)}else return console.warn("TextureCubeUVNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),t)}copy(e){return super.copy(e),this.uv.copy(e.uv),this.bias.copy(e.bias),this.value.copy(e.value),e.colorSpaceTL?this.colorSpaceTL?this.colorSpaceTL.copy(e.colorSpaceTL):this.colorSpaceTL=e.colorSpaceTL.clone():this.colorSpaceTL=void 0,e.colorSpaceTR?this.colorSpaceTR?this.colorSpaceTR.copy(e.colorSpaceTR):this.colorSpaceTR=e.colorSpaceTR.clone():this.colorSpaceTR=void 0,e.colorSpaceBL?this.colorSpaceBL?this.colorSpaceBL.copy(e.colorSpaceBL):this.colorSpaceBL=e.colorSpaceBL.clone():this.colorSpaceBL=void 0,e.colorSpaceBR?this.colorSpaceBR?this.colorSpaceBR.copy(e.colorSpaceBR):this.colorSpaceBR=e.colorSpaceBR.clone():this.colorSpaceBR=void 0,e.colorSpaceTLExp?this.colorSpaceTLExp?this.colorSpaceTLExp.copy(e.colorSpaceTLExp):this.colorSpaceTLExp=e.colorSpaceTLExp.clone():this.colorSpaceTLExp=void 0,e.colorSpaceTRExp?this.colorSpaceTRExp?this.colorSpaceTRExp.copy(e.colorSpaceTRExp):this.colorSpaceTRExp=e.colorSpaceTRExp.clone():this.colorSpaceTRExp=void 0,e.colorSpaceBLExp?this.colorSpaceBLExp?this.colorSpaceBLExp.copy(e.colorSpaceBLExp):this.colorSpaceBLExp=e.colorSpaceBLExp.clone():this.colorSpaceBLExp=void 0,e.colorSpaceBRExp?this.colorSpaceBRExp?this.colorSpaceBRExp.copy(e.colorSpaceBRExp):this.colorSpaceBRExp=e.colorSpaceBRExp.clone():this.colorSpaceBRExp=void 0,this}},Qi=fi;Qi.Nodes=function(){let e=new Xi(`struct TextureCubeUVData {
|
|
5
|
+
`))},Dt.LINEAR_TO_LINEAR="LinearToLinear",Dt.SRGB_TO_LINEAR="sRGBToLinear",Dt.LINEAR_TO_SRGB="LinearTosRGB";var Be=class extends re{constructor(e="",t,r,o,n){super(e,n,o,r,t);this.nodeType="Expression"}};import{Texture as PS}from"three";var Fr=class extends PS{toJSON(e){let t=super.toJSON(e),r=e===void 0||typeof e=="string";if(this.image!==void 0&&!r){let o=this.image;if(Array.isArray(o)){e.images[o.uuid].url=[];for(let n=0;n<o.length;n++)e.images[o.uuid].url[n]=Vh(o[n])}else e.images[o.uuid].url=Vh(o)}return t}};function Vh(i){return typeof HTMLImageElement!="undefined"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&i instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&i instanceof ImageBitmap?OS(i):(console.warn("THREE.Texture: Unable to serialize Texture."),"")}var hi;function OS(i){if(/^data:/i.test(i.src))return i.src;let e;if(i instanceof HTMLCanvasElement)e=i;else{hi===void 0&&(hi=document.createElement("canvas")),hi.width=i.width,hi.height=i.height;let r=hi.getContext("2d");i instanceof ImageData?r.putImageData(i,0,0):r.drawImage(i,0,0,i.width,i.height),e=hi}let t=i.src.startsWith("blob:")?i.fileName:i.src;return/\.jpe?g$/i.test(t)?e.toDataURL("image/jpeg",.6):e.toDataURL("image/png")}var Bt=class extends Ue{constructor(e=new Fr,t,r,o){super("v4",{shared:!0});this.nodeType="Texture";this.value=e,this.uv=t!=null?t:new Zi,this.bias=r,this.project=o!==void 0?o:!1}getTexture(e,t){return super.generate(e,t,this.value.uuid,"t")}generate(e,t){var d;if(t==="sampler2D")return this.getTexture(e,t);let r=this.getTexture(e,t),o=this.uv.build(e,this.project?"v4":"v2"),n=this.bias?this.bias.build(e,"f"):void 0;n===void 0&&e.context.bias&&(n=e.context.bias.setTexture(this).build(e,"f"));let s,a;this.project?s="texture2DProj":s=n?"tex2DBias":"tex2D",n?a=s+"( "+r+", "+o+", "+n+" )":a=s+"( "+r+", "+o+" )";let l={include:e.isShader("vertex"),ignoreCache:!0},c=this.getType(e);return e.addContext(l),this.colorSpace=(d=this.colorSpace)!=null?d:new Dt(new Be("",c)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(a),a=this.colorSpace.build(e,c),e.removeContext(),e.format(a,c,t)}copy(e){return super.copy(e),e.value.isRenderTargetTexture?this.value=e.value:this.value.copy(e.value),this.uv.copy(e.uv),e.bias?this.bias?this.bias.copy(e.bias):this.bias=e.bias.clone():this.bias=void 0,e.colorSpace?this.colorSpace?this.colorSpace.copy(e.colorSpace):this.colorSpace=e.colorSpace.clone():this.colorSpace=void 0,this.project=e.project,e.value.isRenderTargetTexture||(this.value.updateMatrix(),this.value.needsUpdate=!0),this}};var ee=class extends Ue{constructor(e){super("f");this.nodeType="Float";this.value=e!=null?e:0}generateReadonly(e,t,r,o,n,s){return e.format(this.value+(this.value%1?"":".0"),o,t)}copy(e){return super.copy(e),this.value=e.value,this}};var oa=class extends ue{constructor(e,t){super();this.inputs=[];this.nodeType="FunctionCall";this.value=e,this.inputs=t!=null?t:[]}getFunction(){return this.value}getType(e){return this.value.getType(e)}generate(e,t,r,o,n){o=this.getType(e);let s=this.value,a=s.build(e,t)+"( ",l=[];if(s.inputs){for(let c=0;c<s.inputs.length;c++){let d=s.inputs[c],u=this.inputs[c]||this.inputs[d.name];l.push(u.build(e,e.getTypeByFormat(d.type)))}a+=l.join(", ")+" )"}return e.format(a,o,t)}copy(e){return super.copy(e),this.value.copy(e.value),this.inputs=e.inputs.map(t=>t.clone()),this}toJSON(e){var r;let t=this.getJSONNode(e);if(!t){let o=this.value;if(t=this.createJSONNode(e),t.value=this.value.toJSON(e).uuid,(r=o.inputs)==null?void 0:r.length){t.inputs={};for(let n=0;n<o.inputs.length;n++){let s=o.inputs[n],a=this.inputs[n];t.inputs[s.name]=a.toJSON(e).uuid}}}return t}};var mi;(function(o){o.ADD="+",o.SUB="-",o.MUL="*",o.DIV="/"})(mi||(mi={}));var Bl=class extends ue{constructor(e=new pe,t=new pe,r=Bl.ADD){super();this.nodeType="Operator";this.type=e.type,this.a=e,this.b=t,this.op=r}getType(e){let t=this.a.getType(e),r=this.b.getType(e);return e.isTypeMatrix(t)?"v4":e.getTypeLength(r)>e.getTypeLength(t)?r:t}generate(e,t){let r=this.getType(e);this.type=r;let o=this.a.build(e,r),n=this.b.build(e,r);return e.format("( "+o+" "+this.op+" "+n+" )",r,t)}copy(e){return super.copy(e),this.a.copy(e.a),this.b.copy(e.b),this.op=e.op,this}},qt=Bl;qt.ADD=mi.ADD,qt.SUB=mi.SUB,qt.MUL=mi.MUL,qt.DIV=mi.DIV;var be;(function(g){g.RAD="radians",g.DEG="degrees",g.EXP="exp",g.EXP2="exp2",g.LOG="log",g.LOG2="log2",g.SQRT="sqrt",g.INV_SQRT="inversesqrt",g.FLOOR="floor",g.CEIL="ceil",g.NORMALIZE="normalize",g.FRACT="fract",g.SATURATE="saturate",g.SIN="sin",g.COS="cos",g.TAN="tan",g.ASIN="asin",g.ACOS="acos",g.ARCTAN="atan",g.ABS="abs",g.SIGN="sign",g.LENGTH="length",g.NEGATE="negate",g.INVERT="invert",g.MIN="min",g.MAX="max",g.MOD="mod",g.STEP="step",g.REFLECT="reflect",g.DISTANCE="distance",g.DOT="dot",g.CROSS="cross",g.POW="pow",g.MIX="mix",g.CLAMP="clamp",g.REFRACT="refract",g.SMOOTHSTEP="smoothstep",g.FACEFORWARD="faceforward"})(be||(be={}));var je=class extends ue{constructor(e=new pe,t=je.ABS,r,o){super();this.nodeType="Math";this.a=e,typeof t!="string"?this.b=t:o=t,typeof r!="string"?this.c=r:o=r,this.method=o,this.hashProperties=["method"]}getNumInputs(e){switch(this.method){case je.MIX:case je.CLAMP:case je.REFRACT:case je.SMOOTHSTEP:case je.FACEFORWARD:return 3;case je.MIN:case je.MAX:case je.MOD:case je.STEP:case je.REFLECT:case je.DISTANCE:case je.DOT:case je.CROSS:case je.POW:return 2;default:return 1}}getInputType(e){let t=e.getTypeLength(this.a.getType(e)),r=this.b?e.getTypeLength(this.b.getType(e)):0,o=this.c?e.getTypeLength(this.c.getType(e)):0;return t>r&&t>o?this.a.getType(e):r>o?this.b.getType(e):this.c.getType(e)}getType(e){switch(this.method){case je.LENGTH:case je.DISTANCE:case je.DOT:return"f";case je.CROSS:return"v3"}return this.getInputType(e)}generate(e,t){let r,o,n,s=this.a?e.getTypeLength(this.a.getType(e)):0,a=this.b?e.getTypeLength(this.b.getType(e)):0,l=this.c?e.getTypeLength(this.c.getType(e)):0,c=this.getInputType(e),d=this.getType(e);switch(this.type=d,this.method){case je.NEGATE:return e.format("( -"+this.a.build(e,c)+" )",c,t);case je.INVERT:return e.format("( 1.0 - "+this.a.build(e,c)+" )",c,t);case je.CROSS:r=this.a.build(e,"v3"),o=this.b.build(e,"v3");break;case je.STEP:r=this.a.build(e,s===1?"f":c),o=this.b.build(e,c);break;case je.MIN:case je.MAX:case je.MOD:r=this.a.build(e,c),o=this.b.build(e,a===1?"f":c);break;case je.REFRACT:r=this.a.build(e,c),o=this.b.build(e,c),n=this.c.build(e,"f");break;case je.MIX:r=this.a.build(e,c),o=this.b.build(e,c),n=this.c.build(e,l===1?"f":c);break;default:r=this.a.build(e,c),this.b&&(o=this.b.build(e,c)),this.c&&(n=this.c.build(e,c));break}let u=[];u.push(r),o&&u.push(o),n&&u.push(n);let p=this.getNumInputs(e);if(u.length!==p)throw Error(`Arguments not match used in "${this.method}". Require ${p}, currently ${u.length}.`);return e.format(this.method+"( "+u.join(", ")+" )",d,t)}copy(e){return super.copy(e),this.a.copy(e.a),this.b=e.b instanceof pe?e.b.clone():e.b,this.c=e.c instanceof pe?e.c.clone():e.c,this.method=e.method,this}},fe=je;fe.RAD=be.RAD,fe.DEG=be.DEG,fe.EXP=be.EXP,fe.EXP2=be.EXP2,fe.LOG=be.LOG,fe.LOG2=be.LOG2,fe.SQRT=be.SQRT,fe.INV_SQRT=be.INV_SQRT,fe.FLOOR=be.FLOOR,fe.CEIL=be.CEIL,fe.NORMALIZE=be.NORMALIZE,fe.FRACT=be.FRACT,fe.SATURATE=be.SATURATE,fe.SIN=be.SIN,fe.COS=be.COS,fe.TAN=be.TAN,fe.ASIN=be.ASIN,fe.ACOS=be.ACOS,fe.ARCTAN=be.ARCTAN,fe.ABS=be.ABS,fe.SIGN=be.SIGN,fe.LENGTH=be.LENGTH,fe.NEGATE=be.NEGATE,fe.INVERT=be.INVERT,fe.MIN=be.MIN,fe.MAX=be.MAX,fe.MOD=be.MOD,fe.STEP=be.STEP,fe.REFLECT=be.REFLECT,fe.DISTANCE=be.DISTANCE,fe.DOT=be.DOT,fe.CROSS=be.CROSS,fe.POW=be.POW,fe.MIX=be.MIX,fe.CLAMP=be.CLAMP,fe.REFRACT=be.REFRACT,fe.SMOOTHSTEP=be.SMOOTHSTEP,fe.FACEFORWARD=be.FACEFORWARD;var fi=class extends ue{constructor(e=new pe,t=new pe,r=new pe){super("v4");this.nodeType="TextureCubeUV";this.value=e,this.uv=t,this.bias=r}bilinearCubeUV(e,t,r,o){var l,c,d,u;let n=new oa(fi.Nodes.bilinearCubeUV,[t,r,o]);this.colorSpaceTL=(l=this.colorSpaceTL)!=null?l:new Dt(new Be("","v4")),this.colorSpaceTL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTL.input.parse(n.build(e)+".tl"),this.colorSpaceTR=(c=this.colorSpaceTR)!=null?c:new Dt(new Be("","v4")),this.colorSpaceTR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTR.input.parse(n.build(e)+".tr"),this.colorSpaceBL=(d=this.colorSpaceBL)!=null?d:new Dt(new Be("","v4")),this.colorSpaceBL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBL.input.parse(n.build(e)+".bl"),this.colorSpaceBR=(u=this.colorSpaceBR)!=null?u:new Dt(new Be("","v4")),this.colorSpaceBR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBR.input.parse(n.build(e)+".br");let s={include:e.isShader("vertex"),ignoreCache:!0};e.addContext(s),this.colorSpaceTLExp=new Be(this.colorSpaceTL.build(e,"v4"),"v4"),this.colorSpaceTRExp=new Be(this.colorSpaceTR.build(e,"v4"),"v4"),this.colorSpaceBLExp=new Be(this.colorSpaceBL.build(e,"v4"),"v4"),this.colorSpaceBRExp=new Be(this.colorSpaceBR.build(e,"v4"),"v4"),e.removeContext();let a=new Be("mix( mix( cubeUV_TL, cubeUV_TR, cubeUV.f.x ), mix( cubeUV_BL, cubeUV_BR, cubeUV.f.x ), cubeUV.f.y )","v4");return a.keywords.cubeUV_TL=this.colorSpaceTLExp,a.keywords.cubeUV_TR=this.colorSpaceTRExp,a.keywords.cubeUV_BL=this.colorSpaceBLExp,a.keywords.cubeUV_BR=this.colorSpaceBRExp,a.keywords.cubeUV=n,a}generate(e,t){if(e.isShader("fragment")){let r=this.uv,o=this.bias||e.context.roughness,n=new oa(fi.Nodes.roughnessToMip,[o]),s=new fe(n,fi.Nodes.m0,fi.Nodes.cubeUV_maxMipLevel,fe.CLAMP),a=new fe(s,fe.FLOOR),l=new fe(s,fe.FRACT),c=this.bilinearCubeUV(e,this.value,r,a),d=this.bilinearCubeUV(e,this.value,r,new qt(a,new ee(1).setReadonly(!0),qt.ADD)),u=new fe(c,d,l,fe.MIX);return e.format(u.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)}copy(e){return super.copy(e),this.uv.copy(e.uv),this.bias.copy(e.bias),this.value.copy(e.value),e.colorSpaceTL?this.colorSpaceTL?this.colorSpaceTL.copy(e.colorSpaceTL):this.colorSpaceTL=e.colorSpaceTL.clone():this.colorSpaceTL=void 0,e.colorSpaceTR?this.colorSpaceTR?this.colorSpaceTR.copy(e.colorSpaceTR):this.colorSpaceTR=e.colorSpaceTR.clone():this.colorSpaceTR=void 0,e.colorSpaceBL?this.colorSpaceBL?this.colorSpaceBL.copy(e.colorSpaceBL):this.colorSpaceBL=e.colorSpaceBL.clone():this.colorSpaceBL=void 0,e.colorSpaceBR?this.colorSpaceBR?this.colorSpaceBR.copy(e.colorSpaceBR):this.colorSpaceBR=e.colorSpaceBR.clone():this.colorSpaceBR=void 0,e.colorSpaceTLExp?this.colorSpaceTLExp?this.colorSpaceTLExp.copy(e.colorSpaceTLExp):this.colorSpaceTLExp=e.colorSpaceTLExp.clone():this.colorSpaceTLExp=void 0,e.colorSpaceTRExp?this.colorSpaceTRExp?this.colorSpaceTRExp.copy(e.colorSpaceTRExp):this.colorSpaceTRExp=e.colorSpaceTRExp.clone():this.colorSpaceTRExp=void 0,e.colorSpaceBLExp?this.colorSpaceBLExp?this.colorSpaceBLExp.copy(e.colorSpaceBLExp):this.colorSpaceBLExp=e.colorSpaceBLExp.clone():this.colorSpaceBLExp=void 0,e.colorSpaceBRExp?this.colorSpaceBRExp?this.colorSpaceBRExp.copy(e.colorSpaceBRExp):this.colorSpaceBRExp=e.colorSpaceBRExp.clone():this.colorSpaceBRExp=void 0,this}},Qi=fi;Qi.Nodes=function(){let e=new Xi(`struct TextureCubeUVData {
|
|
6
6
|
vec4 tl;
|
|
7
7
|
vec4 tr;
|
|
8
8
|
vec4 br;
|
|
@@ -67,7 +67,7 @@ var zm=Object.create;var Ti=Object.defineProperty,Em=Object.defineProperties,Fm=
|
|
|
67
67
|
uv.x -= texelSize;
|
|
68
68
|
vec4 bl = texture2D(envMap, uv);
|
|
69
69
|
return TextureCubeUVData( tl, tr, br, bl, f );
|
|
70
|
-
}`,[e,s,a,t,r,o,n]);l.useKeywords=!1;let c=new Ie("float r0 1.0",!0),d=new Ie("float v0 0.339",!0),
|
|
70
|
+
}`,[e,s,a,t,r,o,n]);l.useKeywords=!1;let c=new Ie("float r0 1.0",!0),d=new Ie("float v0 0.339",!0),u=new Ie("float m0 -2.0",!0),p=new Ie("float r1 0.8",!0),f=new Ie("float v1 0.276",!0),m=new Ie("float m1 -1.0",!0),x=new Ie("float r4 0.4",!0),y=new Ie("float v4 0.046",!0),N=new Ie("float m4 2.0",!0),L=new Ie("float r5 0.305",!0),w=new Ie("float v5 0.016",!0),B=new Ie("float m5 3.0",!0),S=new Ie("float r6 0.21",!0),_=new Ie("float v6 0.0038",!0),T=new Ie("float m6 4.0",!0),h=[c,d,u,p,f,m,x,y,N,L,w,B,S,_,T],I=new re(`float roughnessToMip(float roughness) {
|
|
71
71
|
float mip = 0.0;
|
|
72
72
|
if (roughness >= r1) {
|
|
73
73
|
mip = (r0 - roughness) * (m1 - m0) / (r0 - r1) + m0;
|
|
@@ -81,7 +81,7 @@ var zm=Object.create;var Ti=Object.defineProperty,Em=Object.defineProperties,Fm=
|
|
|
81
81
|
mip = -2.0 * log2(1.16 * roughness);// 1.16 = 1.79^0.25
|
|
82
82
|
}
|
|
83
83
|
return mip;
|
|
84
|
-
}`,h);return{bilinearCubeUV:l,roughnessToMip:I,m0:
|
|
84
|
+
}`,h);return{bilinearCubeUV:l,roughnessToMip:I,m0:u,cubeUV_maxMipLevel:t}}();var To=class extends ue{constructor(e){super("v3");this.nodeType="Normal";this.scope=e!=null?e:To.VIEW}getShared(){return this.scope===To.WORLD}build(e,t,r,o){let n=e.context[this.scope+"Normal"];return n?n.build(e,t,r,o):super.build(e,t,r)}generate(e,t,r,o,n){let s;switch(this.scope){case To.VIEW:e.isShader("vertex")?s="transformedNormal":s="geometryNormal";break;case To.LOCAL:e.isShader("vertex")?s="objectNormal":(e.requires.normal=!0,s="vObjectNormal");break;case To.WORLD:e.isShader("vertex")?s="inverseTransformDirection( transformedNormal, viewMatrix ).xyz":(e.requires.worldNormal=!0,s="vWNormal");break}return e.format(s,this.getType(e),t)}copy(e){return super.copy(e),this.scope=e.scope,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.scope=this.scope),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.scope&&(this.scope=e.scope),this}},gt=To;gt.LOCAL="local",gt.WORLD="world",gt.VIEW="view",gt.NORMAL="normal";lt.addKeyword("viewNormal",function(){return new gt(gt.VIEW)});lt.addKeyword("localNormal",function(){return new gt(gt.NORMAL)});lt.addKeyword("worldNormal",function(){return new gt(gt.WORLD)});var wr=class extends ue{constructor(e){super("v3");this.nodeType="Position";this.scope=e!=null?e:wr.LOCAL}getType(){switch(this.scope){case wr.PROJECTION:return"v4"}return this.type}getShader(){switch(this.scope){case wr.LOCAL:case wr.WORLD:return!1}return!0}generate(e,t,r,o,n){let s;switch(this.scope){case wr.LOCAL:e.isShader("vertex")?s="transformed":(e.requires.position=!0,s="vPosition");break;case wr.WORLD:if(e.isShader("vertex"))return"( modelMatrix * vec4( transformed, 1.0 ) ).xyz";e.requires.worldPosition=!0,s="vWPosition";break;case wr.VIEW:s=e.isShader("vertex")?"-mvPosition.xyz":"vViewPosition";break;case wr.PROJECTION:s=e.isShader("vertex")?"( projectionMatrix * modelViewMatrix * vec4( position, 1.0 ) )":"vec4( 0.0 )";break}return e.format(s,this.getType(),t)}copy(e){return super.copy(e),this.scope=e.scope,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.scope=this.scope),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.scope&&(this.scope=e.scope),this}},wt=wr;wt.LOCAL="local",wt.WORLD="world",wt.VIEW="view",wt.PROJECTION="projection";lt.addKeyword("position",function(){return new wt});lt.addKeyword("worldPosition",function(){return new wt(wt.WORLD)});lt.addKeyword("viewPosition",function(){return new wt(wt.VIEW)});var cr=class extends ue{constructor(e){super("v3");this.nodeType="Reflect";this.scope=e!=null?e:cr.CUBE}getUnique(e){return!e.context.viewNormal}getType(){switch(this.scope){case cr.SPHERE:return"v2"}return this.type}generate(e,t){let r=this.getUnique(e);if(e.isShader("fragment")){let o;switch(this.scope){case cr.VECTOR:{let n=new gt(gt.VIEW),s=e.context.roughness,a=n.build(e,"v3"),l=new wt(wt.VIEW).build(e,"v3"),c=s?s.build(e,"f"):void 0,d=`reflect( -normalize( ${l} ), ${a} )`;c&&(d=`normalize( mix( ${d}, ${a}, ${c} * ${c} ) )`);let u=`inverseTransformDirection( ${d}, viewMatrix )`;r?(e.addNodeCode(`vec3 reflectVec = ${u};`),o="reflectVec"):o=u;break}case cr.CUBE:{let n=new cr(cr.VECTOR).build(e,"v3"),s="vec3( -"+n+".x, "+n+".yz )";r?(e.addNodeCode(`vec3 reflectCubeVec = ${s};`),o="reflectCubeVec"):o=s;break}case cr.SPHERE:{let n=new cr(cr.VECTOR).build(e,"v3"),s="normalize( ( viewMatrix * vec4( "+n+", 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) ).xy * 0.5 + 0.5";r?(e.addNodeCode(`vec2 reflectSphereVec = ${s};`),o="reflectSphereVec"):o=s;break}}return e.format(o,this.getType(),t)}else return console.warn("ReflectNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.type,t)}copy(e){return super.copy(e),this.scope=e.scope,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.scope=this.scope),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.scope&&(this.scope=e.scope),this}},Rr=cr;Rr.CUBE="cube",Rr.SPHERE="sphere",Rr.VECTOR="vector";var Gl=class extends ue{constructor(e=new Bt,t,r){super("v4");this.nodeType="TextureCube";this.value=e,this.radianceNode=new Qi(this.value,t!=null?t:new Rr(Rr.VECTOR),r),this.irradianceNode=new Qi(this.value,new gt(gt.WORLD),new ee(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))}copy(e){return super.copy(e),this.value.copy(e.value),this.radianceNode.copy(e.radianceNode),this.irradianceNode.copy(e.irradianceNode),this}};import{CubeTexture as AS}from"three";var zl=class extends Ue{constructor(e=new AS,t,r){super("v4",{shared:!0});this.nodeType="CubeTexture";this.value=e,this.uv=t!=null?t:new Rr,this.bias=r}getTexture(e,t){return super.generate(e,t,this.value.uuid,"tc")}generate(e,t){var c,d;if(t==="samplerCube")return this.getTexture(e,t);let r=this.getTexture(e,t),o=(c=this.uv)==null?void 0:c.build(e,"v3"),n=this.bias?this.bias.build(e,"f"):void 0;n===void 0&&e.context.bias&&(n=e.context.bias.setTexture(this).build(e,"f"));let s;n?s="texCubeBias( "+r+", "+o+", "+n+" )":s="texCube( "+r+", "+o+" )";let a={include:e.isShader("vertex"),ignoreCache:!0},l=this.getType(e);return e.addContext(a),this.colorSpace=(d=this.colorSpace)!=null?d:new Dt(new Be("",l)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(s),s=this.colorSpace.build(e,l),e.removeContext(),e.format(s,l,t)}copy(e){return super.copy(e),this.value.copy(e.value),e.uv?this.uv?this.uv.copy(e.uv):this.uv=e.uv.clone():this.uv=void 0,e.bias?this.bias?this.bias.copy(e.bias):this.bias=e.bias.clone():this.bias=void 0,this}};var kh=["x","y","z","w"],zS=["float","vec2","vec3","vec4"],ES={float:"f",vec2:"v2",vec3:"v3",vec4:"v4",mat4:"v4",int:"i",bool:"b","float[]":"f[]","vec4[]":"v4[]"},FS={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[]"},El=class{constructor(){this.includes={consts:{},functions:{},structs:{}};this.cache="";this.slot="";this.shader="";this.context={};this.getIncludesCode=function(){function e(t,r){return t.deps.length-r.deps.length}return function(r,o){let n=this.getIncludes(r,o);if(!n)return"";let s="";n=n.sort(e);for(let a=0;a<n.length;a++)n[a].src&&(s+=n[a].src+`
|
|
85
85
|
`);return s}}();this.slots=[],this.caches=[],this.contexts=[],this.keywords={},this.nodeData={},this.fragmentVariables={},this.requires={uv:[],color:[],lights:!1,fog:!1,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",`
|
|
86
86
|
// NOTE: Include Spline's blending modes. This could be part of BlendNode
|
|
87
87
|
#define SPE_BLENDING_NORMAL 0
|
|
@@ -361,7 +361,7 @@ vec3 sphericalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec
|
|
|
361
361
|
a *= 0.5;
|
|
362
362
|
}
|
|
363
363
|
return v;
|
|
364
|
-
}`,[c]);d.keywords.NUM_OCTAVES=new Ie(`int NUM_OCTAVES ${i}`);let
|
|
364
|
+
}`,[c]);d.keywords.NUM_OCTAVES=new Ie(`int NUM_OCTAVES ${i}`);let u=new re("vec3 fade(vec3 t) {return t*t*t*(t*(t*6.0-15.0)+10.0);}"),p=new re(`float perlin(vec3 P){
|
|
365
365
|
vec3 Pi0 = floor(P);
|
|
366
366
|
vec3 Pi1 = Pi0 + vec3(1.0);
|
|
367
367
|
Pi0 = mod(Pi0, 289.0);
|
|
@@ -420,7 +420,7 @@ vec3 sphericalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec
|
|
|
420
420
|
vec2 n_yz = mix(n_z.xy, n_z.zw, fade_xyz.y);
|
|
421
421
|
float n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x);
|
|
422
422
|
return 2.2 * n_xyz;
|
|
423
|
-
}`,[o,n,
|
|
423
|
+
}`,[o,n,u]);return{simplex:t,simplexFractal:r,simplexAshima:s,fbm:d,perlin:p}}();var Rl=class extends ue{constructor(e,t,r,o,n,s,a){super("v3");this.nodeType="Rainbow";this.filmThickness=e,this.movement=t,this.wavelengths=r,this.noiseStrength=o,this.noiseScale=n,this.offset=s,this.alpha=a,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 r=e.include(Rl.Nodes.rainbow),o=[];return o.push(this.filmThickness.build(e,"f")),o.push(this.movement.build(e,"f")),o.push(this.wavelengths.build(e,"v3")),o.push(this.noiseStrength.build(e,"f")),o.push(this.noiseScale.build(e,"f")),o.push(this.offset.build(e,"v3")),o.push(this.alpha.build(e,"f")),o.push(this.calpha),e.format(r+"("+o.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)}copy(e){return super.copy(e),this.filmThickness=e.filmThickness.clone(),this.movement=e.movement.clone(),this.wavelengths=e.wavelengths.clone(),this.noiseStrength=e.noiseStrength.clone(),this.noiseScale=e.noiseScale.clone(),this.offset=e.offset.clone(),this.alpha=e.alpha.clone(),this.calpha=e.calpha,this}},la=Rl;la.Nodes=function(){let e=new re(`vec3 attenuation(vec3 wavelengths, float filmThickness, float movement, float noiseStrength, float noiseScale, vec3 offset) {
|
|
424
424
|
vec3 st = position / noiseScale;
|
|
425
425
|
vec3 q = vec3(simplex3d(st),
|
|
426
426
|
simplex3d(st + vec3(1.0)),
|
|
@@ -620,7 +620,7 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
|
|
|
620
620
|
vec3 distorted2 = nearby2 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity;
|
|
621
621
|
displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));
|
|
622
622
|
return displaced_position;
|
|
623
|
-
}`,[e,t])}}();var ua=class extends ue{constructor(e=new pe,t=new pe,r=new pe,o=new pe,n=new pe,s=new pe,a=new pe,l=new pe,c=new pe,d=new pe,
|
|
623
|
+
}`,[e,t])}}();var ua=class extends ue{constructor(e=new pe,t=new pe,r=new pe,o=new pe,n=new pe,s=new pe,a=new pe,l=new pe,c=new pe,d=new pe,u=new pe,p=new pe){super("v3");this.nodeType="Noise";this.scale=e,this.size=t,this.move=r,this.fA=o,this.fB=n,this.distortion=s,this.colorA=a,this.colorB=l,this.colorC=c,this.colorD=d,this.alpha=u,this.noiseType=p,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t,r,o,n){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let s=Object.values(bi)[this.noiseType.value],a=new re(`vec3 ${s}customNoise(float scale, vec3 size, float move, vec2 fA, vec2 fB, vec2 distortion, vec4 colorA, vec4 colorB, vec4 colorC, vec4 colorD, float alpha, out float calpha) {
|
|
624
624
|
vec3 st = position / size;
|
|
625
625
|
st /= scale;
|
|
626
626
|
vec3 q = vec3(${s}(st),
|
|
@@ -640,7 +640,7 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
|
|
|
640
640
|
|
|
641
641
|
accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
|
|
642
642
|
return clamp(color, 0.0, 1.0).rgb;
|
|
643
|
-
}`,[Gt.simplex,Gt.simplexFractal,Gt.simplexAshima,Gt.fbm,Gt.perlin]),l=e.include(a),c=[];return c.push(this.scale.build(e,"f")),c.push(this.size.build(e,"v3")),c.push(this.move.build(e,"f")),c.push(this.fA.build(e,"v2")),c.push(this.fB.build(e,"v2")),c.push(this.distortion.build(e,"v2")),c.push(this.colorA.build(e,"v4")),c.push(this.colorB.build(e,"v4")),c.push(this.colorC.build(e,"v4")),c.push(this.colorD.build(e,"v4")),c.push(this.alpha.build(e,"f")),c.push(this.calpha),e.format(l+"("+c.join(",")+")",this.getType(e),t)}copy(e){return super.copy(e),this.scale.copy(e.scale),this.size.copy(e.size),this.move.copy(e.move),this.fA.copy(e.fA),this.fB.copy(e.fB),this.distortion.copy(e.distortion),this.colorA.copy(e.colorA),this.colorB.copy(e.colorB),this.colorC.copy(e.colorC),this.colorD.copy(e.colorD),this.alpha.copy(e.alpha),this.calpha=e.calpha,this.noiseType.copy(e.noiseType),this}};ua.numOctaves=5;var ha=class extends ue{constructor(e=new pe,t=new pe,r=new pe,o=new pe){super("v3");this.nodeType="Blend";this.a=e,this.b=t,this.alpha=r,this.mode=o}generate(e,t){if(e.isShader("fragment")){let r=[];return r.push(this.a.build(e,"c")),r.push(this.b.build(e,"c")),r.push(this.alpha.build(e,"f")),r.push(this.mode.build(e,"i")),e.format("spe_blend("+r.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)}copy(e){return super.copy(e),this.a.copy(e.a),this.b.copy(e.b),this.alpha.copy(e.alpha),this.mode.copy(e.mode),this}};var vi=class extends ue{constructor(e,t,r,o,n,s,a,l,c,d,p
|
|
643
|
+
}`,[Gt.simplex,Gt.simplexFractal,Gt.simplexAshima,Gt.fbm,Gt.perlin]),l=e.include(a),c=[];return c.push(this.scale.build(e,"f")),c.push(this.size.build(e,"v3")),c.push(this.move.build(e,"f")),c.push(this.fA.build(e,"v2")),c.push(this.fB.build(e,"v2")),c.push(this.distortion.build(e,"v2")),c.push(this.colorA.build(e,"v4")),c.push(this.colorB.build(e,"v4")),c.push(this.colorC.build(e,"v4")),c.push(this.colorD.build(e,"v4")),c.push(this.alpha.build(e,"f")),c.push(this.calpha),e.format(l+"("+c.join(",")+")",this.getType(e),t)}copy(e){return super.copy(e),this.scale.copy(e.scale),this.size.copy(e.size),this.move.copy(e.move),this.fA.copy(e.fA),this.fB.copy(e.fB),this.distortion.copy(e.distortion),this.colorA.copy(e.colorA),this.colorB.copy(e.colorB),this.colorC.copy(e.colorC),this.colorD.copy(e.colorD),this.alpha.copy(e.alpha),this.calpha=e.calpha,this.noiseType.copy(e.noiseType),this}};ua.numOctaves=5;var ha=class extends ue{constructor(e=new pe,t=new pe,r=new pe,o=new pe){super("v3");this.nodeType="Blend";this.a=e,this.b=t,this.alpha=r,this.mode=o}generate(e,t){if(e.isShader("fragment")){let r=[];return r.push(this.a.build(e,"c")),r.push(this.b.build(e,"c")),r.push(this.alpha.build(e,"f")),r.push(this.mode.build(e,"i")),e.format("spe_blend("+r.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)}copy(e){return super.copy(e),this.a.copy(e.a),this.b.copy(e.b),this.alpha.copy(e.alpha),this.mode.copy(e.mode),this}};var vi=class extends ue{constructor(e,t,r,o,n,s,a,l,c,d,u,p){super("v3");this.nodeType="Depth";this.gradientType=e,this.smooth=t,this.near=r,this.far=o,this.isVector=n,this.isWorldSpace=s,this.origin=a,this.direction=l,this.colors=c,this.steps=d,this.num=u,this.alpha=p,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){let r=`g${this.uuid.toString().replace(/-/g,"")}`,o=new re(`vec3 ${r}_sdepth(float near, float far, vec3 origin, vec3 direction, vec4 colors[${r}_MAX_COLORS], float steps[10], float alpha, out float calpha) {
|
|
644
644
|
vec4 color = colors[0];
|
|
645
645
|
#ifdef ${r}_IS_VECTOR
|
|
646
646
|
#ifdef ${r}_LINEAR
|
|
@@ -706,7 +706,7 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
|
|
|
706
706
|
|
|
707
707
|
return matcapColor.rgb;
|
|
708
708
|
}
|
|
709
|
-
`)}}();var Pt=class{constructor(e){this.id=2,this.layerCount=2,this.uuid=Vr.generateUUID(),this.needsUpdate=!1,this._material=e,this._layerNodes=[];let t=this._createLayer({id:0,type:Le.COLOR});this._material.color=t.color,this._material.alpha===void 0&&(this._material.alpha=new ee(1));let r=new ee(1),o=new ve(0);"shadingAlpha"in this._material&&"shadingBlend"in this._material&&(this._material.shadingAlpha=r,this._material.shadingBlend=o),this._layerNodes.push({id:0,type:ke.COLOR,color:t.color,alpha:t.alpha,mode:t.mode}),this._layerNodes.push({id:1,type:ke.LIGHTING,alpha:r,mode:o}),this.head=t.layer,this.head.next=new Je(1,void 0,{type:Le.LIGHTING,alpha:r,mode:o}),this.attachLightNodes(this.getLightLayer())}get material(){return this._material}set material(e){var n;this._material=e;let t,r,o=this.head;for(;o!==void 0;){if(o.type===Le.LIGHTING){t=o.uniforms[`f${o.id}_alpha`],r=o.uniforms[`f${o.id}_mode`];break}o=o.next}"shadingAlpha"in this._material&&"shadingBlend"in this._material&&(this._material.shadingAlpha=t,this._material.shadingBlend=r),this.attachLightNodes((n=e.userData.layers)==null?void 0:n.getLightLayer()),this.blendColors(),this.blendAfterColors(),this.blendPositions()}getLayersOfType(e){let t=[],r=this.head;for(;r;)r.type===e&&t.push(r),r=r.next;return t}addLayer(e){var o;if(e.id=(o=e.id)!=null?o:++this.id,this.layerCount++,e.type===Le.LIGHTING){let n=this.createLightLayer(e);return this.uuid=Vr.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),n}let t=this._createLayer(e),r=t.layer;if(this.head===void 0)this.head=r;else{let n=this.head;for(;n.next!=null;)n=n.next;n.next=r}return t.color&&this._layerNodes.push({id:r.id,type:ke.COLOR,color:t.color,alpha:t.alpha,mode:t.mode}),t.position&&this._layerNodes.push({id:r.id,type:ke.POSITION,position:t.position}),this.uuid=Vr.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),r}addLayerBeforeAt(e,t){var a;let r=this.head;e.id=(a=e.id)!=null?a:++this.id,this.layerCount++;let o=this._createLayer(e),n=o.layer;n.next=t;let s=0;if(r===t)this.head=n,o.color&&this._layerNodes.splice(0,0,{id:n.id,type:ke.COLOR,color:o.color,alpha:o.alpha,mode:o.mode}),o.position&&this._layerNodes.splice(0,0,{id:n.id,type:ke.POSITION,position:o.position});else{for(s=1;(r==null?void 0:r.next)!==t;)r=r==null?void 0:r.next,s++;r.next=n,o.color&&this._layerNodes.splice(s,0,{id:n.id,type:ke.COLOR,color:o.color,alpha:o.alpha,mode:o.mode}),o.position&&this._layerNodes.splice(s,0,{id:n.id,type:ke.POSITION,position:o.position})}return this.uuid=Vr.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),n}addLayerAt(e,t){var n;t.id=(n=t.id)!=null?n:++this.id,this.layerCount++;let r=this._createLayer(t),o=r.layer;if(r.color&&this._layerNodes.splice(e,0,{id:o.id,type:ke.COLOR,color:r.color,alpha:r.alpha,mode:r.mode}),r.position&&this._layerNodes.splice(e,0,{id:o.id,type:ke.POSITION,position:r.position}),e==0)o.next=this.head,this.head=o;else{let s=this.head,a=this.head.next;for(let l=0;l<e-1;l++)s=a,a=a.next;o.next=a,s.next=o}return this.uuid=Vr.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),o}removeLayer(e){let t=this.head,r,o=0;if((t==null?void 0:t.id)==e)this.head=t.next;else for(o=1,r=t,t=t==null?void 0:t.next;t!=null;){if(t.id==e){r.next=t.next;break}o++,r=t,t=t.next}return this.cleanupChangedLayer(t),this.blendColors(),this.blendAfterColors(),this.blendPositions(),this.uuid=Vr.generateUUID(),this.layerCount--,o}changeLayer(e,t){let r,o=this.head,n;if((o==null?void 0:o.id)==e){let s=this._createLayer(O({id:e,uuid:o.uuid},t));n=s.layer,n.next=o.next,this.head=n,s.color&&(this._layerNodes[0]={id:n.id,type:ke.COLOR,color:s.color,alpha:s.alpha,mode:s.mode}),s.position&&(this._layerNodes[0]={id:n.id,type:ke.POSITION,position:s.position}),n.uniforms[`f${e}_mode`].value=o.uniforms[`f${e}_mode`].value,n.uniforms[`f${e}_alpha`].value=o.uniforms[`f${e}_alpha`].value}else{r=o,o=o.next;let s=1;for(;o!=null;){if(o.id==e){let a=this._createLayer(O({id:e,uuid:o.uuid},t));n=a.layer,r.next=n,n.next=o.next,a.color&&(this._layerNodes[s]={id:e,type:ke.COLOR,color:a.color,alpha:a.alpha,mode:a.mode}),a.position&&(this._layerNodes[s]={id:e,type:ke.POSITION,position:a.position}),n.uniforms[`f${e}_mode`].value=o.uniforms[`f${e}_mode`].value,n.uniforms[`f${e}_alpha`].value=o.uniforms[`f${e}_alpha`].value;break}r=o,o=o.next,s++}}return this.uuid=Vr.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),n}getLayer(e){let t=this.head;for(;t!=null&&t.id!=e;)t=t.next;return t}getLayerByUuid(e){let t=this.head;for(;t!==void 0;){if(t.uuid===e)return t;t=t.next}}getLayers(){let e=[],t=this.head;for(;t!=null;)e.push(t),t=t.next;return e}getLayerPosition(e){let t=this.head,r=0;for(;t!==void 0&&t.id!=e;)r++,t=t.next;return r}getDefines(){}getBeforeProgram(){}getLightingProgram(){}getAfterProgram(){}getVarPrograms(){}getUniforms(){}moveLayer(e,t){let r,o=this.head,n;if(e==0)r=this.head,this.head=r.next;else{for(let a=0;a<e;a++)n=o,o=o.next;n.next=o.next,r=o}if(o=this.head,n=void 0,t==0)r.next=this.head,this.head=r;else{for(let a=0;a<t-1;a++)o=o.next;r.next=o==null?void 0:o.next,o.next=r}let s=this._layerNodes.splice(e,1)[0];this._layerNodes.splice(t,0,s),this.uuid=Vr.generateUUID(),this.blendColors(),this.blendAfterColors()}updateLayerUniform(){this.uuid=Vr.generateUUID(),this.blendColors(),this.blendAfterColors()}copy(e){this.needsUpdate=!1,this.layerCount=e.layerCount,this._layerNodes=[],this.layerCount=0,this.head=void 0,this.rebuildLayerNodes(this.head,e.head);let t=e.head,r=this.head;for(;t.next!=null;)this.rebuildLayerNodes(r,t.next),r=r.next,t=t.next;return this.id=e.id,this.uuid=e.uuid,this.blendColors(),this.blendAfterColors(),this.blendPositions(),this}createLightLayer(e){let t=new ee(e.alpha),r=new ve(e.mode);this._material.shadingAlpha=t,this._material.shadingBlend=r,this._layerNodes.push({id:e.id,type:ke.LIGHTING,alpha:t,mode:r});let o=new Je(e.id,void 0,{type:Le.LIGHTING,alpha:t,mode:r});if(this.head===void 0)this.head=o;else{let n=this.head;for(;n.next!=null;)n=n.next;n.next=o}return this.attachLightNodes(this.getLightLayer()),o}rebuildLayerNodes(e,t,r=!1){if(t.type===Le.LIGHTING){let o=r?t.uniforms[`f${t.id}_alpha`]:new ee(t.uniforms[`f${t.id}_alpha`].value),n=r?t.uniforms[`f${t.id}_mode`]:new ve(t.uniforms[`f${t.id}_mode`].value);this._material.shadingAlpha=o,this._material.shadingBlend=n,this._layerNodes.push({id:t.id,type:ke.LIGHTING,alpha:o,mode:n}),this.head===void 0?this.head=new Je(t.id,t.uuid,{type:Le.LIGHTING,alpha:o,mode:n}):e&&(e.next=new Je(t.id,t.uuid,{type:Le.LIGHTING,alpha:o,mode:n})),this.attachLightNodes(t)}else{let o={type:t.type,id:t.id};for(let n in t.uniforms){let s=t.getName(n);if(!s)continue;let a=`f${t.id}_${s}`;if(Array.isArray(t.uniforms[a].value))o[s]=t.uniforms[a].value.map(l=>l.clone&&!r?l.clone():l);else{let l=t.uniforms[a].value;if(s==="transmissionDepthMap"){o[s]=l;continue}l!=null&&(o[s]=l.clone&&!r&&!l.isRenderTargetTexture?l.clone():l)}}this.addLayer(o)}}attachLightNodes(e){var o,n,s,a,l,c,d,p,u,f,m;let t={},r=this.getLightLayer();switch(this._material.userData.category){case"Lambert":t.emissive=new Ge((n=(o=e==null?void 0:e.getValue("emissive"))==null?void 0:o.clone())!=null?n:0);break;case"Phong":t.shininess=new ee((s=e==null?void 0:e.getValue("shininess"))!=null?s:30),t.specular=new Ge((l=(a=e==null?void 0:e.getValue("specular"))==null?void 0:a.clone())!=null?l:1118481);break;case"Toon":t.shininess=new ee((c=e==null?void 0:e.getValue("shininess"))!=null?c:30),t.specular=new Ge((p=(d=e==null?void 0:e.getValue("specular"))==null?void 0:d.clone())!=null?p:1118481);break;case"Physical":t.roughness=new ee((u=e==null?void 0:e.getValue("roughness"))!=null?u:.3),t.metalness=new ee((f=e==null?void 0:e.getValue("metalness"))!=null?f:0),t.reflectivity=new ee((m=e==null?void 0:e.getValue("reflectivity"))!=null?m:.5);break;default:break}Object.keys(t).forEach(x=>{this._material[x]=t[x],r.uniforms[`f${r.id}_${x}`]=t[x]})}clone(e){return new Pt(e).copy(this)}toJSON(e){return{id:this.id,uuid:this.uuid,head:this.head.toJSON(e)}}fromJSON(e,t,r){let o=new Je(e.head.id,void 0,{type:e.head.type}).fromJSON(e.head,t),n=e.head.next,s=o;for(;n!=null;)s.next=new Je(n.id,void 0,{type:n.type}).fromJSON(n,t),n=n.next,s=s.next;this._layerNodes=[],this.head=void 0,this.rebuildLayerNodes(this.head,o,!0);let a=o;for(s=this.head;a.next!=null;)this.rebuildLayerNodes(s,a.next,!0),s=s.next,a=a.next;return this._material=r,this.id=e.id,this.uuid=e.uuid,this.blendColors(),this.blendAfterColors(),this.blendPositions(),this}getLightLayer(){var t;let e=this.head;for(;e!==void 0&&e.type!=="light";)e=(t=e.next)!=null?t:e;return e}dispose(){let e=this.head;for(this._layerNodes=[],this.layerCount=0;e!==void 0;)e.hasOwnProperty("dispose")===!0&&e.dispose(),e=e.next;this.head=void 0}_createLayer(e){var r,o,n,s,a,l,c,d,p,u,f,m,x,y,N,L,w,B,S,_,T,h,I,b,P,v,D,Z,V,ie,oe,ge,xe,A,j,g,z,R,U,q,W,J,E,H,k,se,F,K,X,te,he,Y,ne,Se,me,Oe,He,rt,pt,zt,Tr,xt,Ir,uo,ho,qe,bt,Et,bn,vn,Sn,wn,Nn,Cn,$t,Li,ut,jo,Ln;let t=e.type;switch(t){case Le.COLOR:{let ye=new Ge((r=e.color)!=null?r:nt),Ce=new ee((o=e.alpha)!=null?o:1),we=new Be("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");we.keywords.alpha=Ce;let Ne=new ve((n=e.mode)!=null?n:0);return ye.alpha=Ce,{layer:new Je(e.id,e.uuid,{type:t,color:ye,alpha:Ce,calpha:we,mode:Ne}),color:ye,alpha:we,mode:Ne}}case Le.TEXTURE:{let ye=(s=e.texture)!=null?s:new Fr,Ce=ye.matrix;e.mat&&Ce.copy(e.mat),ye.needsUpdate=!0;let we=new ee((a=e.crop)!=null?a:0),Ne=new ve((l=e.projection)!=null?l:0),Te=new ve((c=e.axis)!=null?c:0),_e=new It(e.size?new so(e.size[0],e.size[1]):new so(100,100)),ze=new ee((d=e.alpha)!=null?d:1),Ee=new ve((p=e.mode)!=null?p:0),De=new Bt(ye),We=new Mt((u=e.textureSize)!=null?u:new ao(ye.image?ye.image.width:0,ye.image?ye.image.height:0)),ot=new sa(De,We,we,Ne,Te,_e,ze,Ee),Jt=new Be(ot.calpha,"f");return{layer:new Je(e.id,e.uuid,{type:t,texture:De,textureSize:We,crop:we,projection:Ne,axis:Te,size:_e,mat:ot.mat,alpha:ze,calpha:Jt,mode:Ee}),color:ot,alpha:Jt,mode:Ee}}case Le.MATCAP:{let ye=(f=e.texture)!=null?f:new Fr;ye.needsUpdate=!0;let Ce=new ee((m=e.alpha)!=null?m:1),we=new Bt(ye),Ne=new ve((x=e.mode)!=null?x:0),Te=new fa(we,Ce,Ne),_e=new Be(Te.calpha,"f");return{layer:new Je(e.id,e.uuid,{type:t,texture:we,alpha:Ce,calpha:_e,mode:Ne}),color:Te,alpha:_e,mode:Ne}}case Le.FRESNEL:{let ye=new Ge((y=e.color)!=null?y:16777215),Ce=new ee((N=e.bias)!=null?N:.1),we=new ee((L=e.scale)!=null?L:1),Ne=new ee((w=e.intensity)!=null?w:2),Te=new ee((B=e.factor)!=null?B:1),_e=new ee((S=e.alpha)!=null?S:1),ze=new ve((_=e.mode)!=null?_:0),Ee=new aa(ye,Ce,we,Ne,Te,_e,ze),De=new Be(Ee.calpha,"f");return{layer:new Je(e.id,e.uuid,{type:t,color:ye,bias:Ce,scale:we,intensity:Ne,factor:Te,alpha:_e,calpha:De,mode:ze}),color:Ee,alpha:De,mode:ze}}case Le.RAINBOW:{let ye=new ee((T=e.filmThickness)!=null?T:30),Ce=new ee((h=e.movement)!=null?h:0),we=new Mt((I=e.wavelengths)!=null?I:new ao(0,0,0)),Ne=new ee((b=e.noiseStrength)!=null?b:0),Te=new ee((P=e.noiseScale)!=null?P:1),_e=new Mt((v=e.offset)!=null?v:new ao(0,0,0)),ze=new ee((D=e.alpha)!=null?D:1),Ee=new la(ye,Ce,we,Ne,Te,_e,ze),De=new Be(Ee.calpha,"f"),We=new ve((Z=e.mode)!=null?Z:0);return{layer:new Je(e.id,e.uuid,{type:t,filmThickness:ye,movement:Ce,wavelengths:we,noiseStrength:Ne,noiseScale:Te,offset:_e,alpha:ze,calpha:De,mode:We}),color:Ee,alpha:De,mode:We}}case Le.TRANSMISSION:{let ye=new ee((V=e.thickness)!=null?V:10),Ce=new ee((ie=e.ior)!=null?ie:1.5),we=new ee((oe=e.roughness)!=null?oe:.5),Ne=new It((ge=e.transmissionSamplerSize)!=null?ge:new so(2048,2048)),Te=(xe=e.transmissionSamplerMap)!=null?xe:new Fr,_e=(A=e.transmissionDepthMap)!=null?A:new Fr,ze=new Bt(Te),Ee=new Bt(_e),De=window.innerWidth,We=window.innerHeight,ot=De>=We?new It(We/De,1):new It(1,De/We),Jt=new ee((j=e.alpha)!=null?j:1),Mr=new ca(ye,Ce,we,Ne,ze,Ee,ot,Jt),kr=new Be(Mr.calpha,"f"),Hr=new ve((g=e.mode)!=null?g:0);return{layer:new Je(e.id,e.uuid,{type:t,thickness:ye,ior:Ce,roughness:we,transmissionSamplerSize:Ne,transmissionSamplerMap:ze,transmissionDepthMap:Ee,aspectRatio:ot,alpha:Jt,calpha:kr,mode:Hr}),color:Mr,alpha:kr,mode:Hr}}case Le.DEPTH:{let ye=new ve((z=e.gradientType)!=null?z:0),Ce=new na((R=e.smooth)!=null?R:!1),we=new ee((U=e.near)!=null?U:50),Ne=new ee((q=e.far)!=null?q:200),Te=new ee((W=e.isVector)!=null?W:1),_e=new ee((J=e.isWorldSpace)!=null?J:0),ze=new Mt((E=e.origin)!=null?E:new ao),Ee=new Mt((H=e.direction)!=null?H:new ao),De=new ve((k=e.num)!=null?k:0),We;e.colors?We=new yi(De.value+1,e.colors):(We=new yi(De.value+1,new ya(0,0,0,1)),We.value[1]=new ya(1,1,1,1));let ot;e.steps?ot=new gi(e.steps.length,e.steps):(ot=new gi(10,1),ot.value[0]=0);let Jt=new ee((se=e.alpha)!=null?se:1),Mr=new ve((F=e.mode)!=null?F:0),kr=new ma(ye,Ce,we,Ne,Te,_e,ze,Ee,We,ot,De,Jt),Hr=new Be(kr.calpha,"f");return{layer:new Je(e.id,e.uuid,{type:t,gradientType:ye,smooth:Ce,near:we,far:Ne,isVector:Te,isWorldSpace:_e,origin:ze,direction:Ee,colors:We,steps:ot,num:De,alpha:Jt,calpha:Hr,mode:Mr}),color:kr,alpha:Hr,mode:Mr}}case Le.NOISE:{let ye=new ee((K=e.scale)!=null?K:1),Ce=new Mt((X=e.size)!=null?X:new ao(100,100,100)),we=new ee((te=e.move)!=null?te:1),Ne=new It((he=e.fA)!=null?he:new so(1.7,9.2)),Te=new It((Y=e.fB)!=null?Y:new so(8.3,2.8)),_e=new It((ne=e.distortion)!=null?ne:new so(1,1)),ze=new no(e.colorA),Ee=new no(e.colorB),De=new no(e.colorC),We=new no(e.colorD),ot=new ee((Se=e.alpha)!=null?Se:1),Jt=new ve((me=e.mode)!=null?me:0),Mr=new ve((Oe=e.noiseType)!=null?Oe:0),kr=new ua(ye,Ce,we,Ne,Te,_e,ze,Ee,De,We,ot,Mr),Hr=new Be(kr.calpha,"f");return{layer:new Je(e.id,e.uuid,{type:t,scale:ye,size:Ce,move:we,fA:Ne,fB:Te,distortion:_e,colorA:ze,colorB:Ee,colorC:De,colorD:We,alpha:ot,calpha:Hr,mode:Jt,noiseType:Mr}),color:kr,alpha:Hr,mode:Jt}}case Le.NORMAL:{let ye=new Mt((He=e.cnormal)!=null?He:new ao(1,1,1)),Ce=new ee((rt=e.alpha)!=null?rt:1),we=new ve((pt=e.mode)!=null?pt:0),Ne=new da(ye,Ce),Te=new Be("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");return Te.keywords.alpha=Ce,{layer:new Je(e.id,e.uuid,{type:t,cnormal:ye,alpha:Ce,calpha:Te,mode:we}),color:Ne,alpha:Te,mode:we}}case Le.GRADIENT:{let ye=new ve((zt=e.gradientType)!=null?zt:0),Ce=new na((Tr=e.smooth)!=null?Tr:!1),we;e.colors?we=new yi(e.colors.length,e.colors):(we=new yi(10,new ya(0,0,0,1)),we.value[1]=new ya(1,1,1,1));let Ne;e.steps?Ne=new gi(e.steps.length,e.steps):(Ne=new gi(10,1),Ne.value[0]=0);let Te=new It((xt=e.offset)!=null?xt:new so(0,0)),_e=new It((Ir=e.morph)!=null?Ir:new so(0,0)),ze=new ee((uo=e.angle)!=null?uo:0),Ee=new ee((ho=e.alpha)!=null?ho:1),De=new ve((qe=e.mode)!=null?qe:0),We=new pa(ye,Ce,we,Ne,Te,_e,ze,Ee),ot=new Be(We.calpha,"f");return{layer:new Je(e.id,e.uuid,{type:t,gradientType:ye,smooth:Ce,colors:we,steps:Ne,offset:Te,morph:_e,angle:ze,alpha:Ee,calpha:ot,mode:De}),color:We,alpha:ot,mode:De}}case Le.DISPLACE:{let ye=new ve((bt=e.displacementType)!=null?bt:0);if(ye.value===0){let Ce=new Mt((Et=e.offset)!=null?Et:new ao(0,0,0)),we=new ee((bn=e.scale)!=null?bn:10),Ne=new ee((vn=e.intensity)!=null?vn:8),Te=new ee((Sn=e.movement)!=null?Sn:1),_e=new ee((wn=e.alpha)!=null?wn:1),ze=new ve((Nn=e.mode)!=null?Nn:0),Ee=new ve((Cn=e.noiseType)!=null?Cn:0),De=new tn(ye,Ne,Te,Ce,we,Ee);return{layer:new Je(e.id,e.uuid,{displacementType:ye,type:t,offset:Ce,scale:we,intensity:Ne,movement:Te,alpha:_e,mode:ze,noiseType:Ee}),position:De}}else if(ye.value===1){let Ce=($t=e.texture)!=null?$t:new Fr,we=Ce.matrix;e.mat&&we.copy(e.mat),Ce.needsUpdate=!0;let Ne=new ee((Li=e.intensity)!=null?Li:8),Te=new Bt(Ce),_e=new ee((ut=e.crop)!=null?ut:0),ze=new ee((jo=e.alpha)!=null?jo:1),Ee=new ve((Ln=e.mode)!=null?Ln:0),De=new tn(ye,Ne,Te,_e);return{layer:new Je(e.id,e.uuid,{displacementType:ye,type:t,intensity:Ne,texture:Te,crop:_e,mat:De.mat,alpha:ze,mode:Ee}),position:De}}return{}}}return{}}blendColors(){let e=this._layerNodes.findIndex(r=>r.type===ke.COLOR),t=this._layerNodes.findIndex(r=>r.type===ke.LIGHTING);if(e!==-1&&e<t){let r=this._layerNodes[e].color;for(let o=e+1;o<t;++o){let n=this._layerNodes[o];n.type===ke.COLOR&&(r=new ha(r,n.color,n.alpha,n.mode))}this._material.color=r}else this._material.color=void 0}blendAfterColors(){let e=new Be("outgoingLight","f"),t=this._layerNodes.findIndex(r=>r.type===ke.LIGHTING);if(this._layerNodes.length>t+1){for(let r=t+1;r<this._layerNodes.length;++r){let o=this._layerNodes[r];o.type===ke.COLOR&&(e=new ha(e,o.color,o.alpha,o.mode))}"afterColor"in this._material&&(this._material.afterColor=e)}else"afterColor"in this._material&&(this._material.afterColor=void 0)}blendPositions(){let e=this._layerNodes.filter(t=>t.type===ke.POSITION);if(e.length>0){let t=e[0].position;for(let r=1;r<e.length;++r)e[r]&&(t=new qt(t,e[r].position,qt.ADD),t=new qt(t,new ee(.5).setReadonly(!0),qt.MUL));this._material.position=t}else this._material.position=void 0}cleanupChangedLayer(e){switch(this._layerNodes=this._layerNodes.filter(t=>t.id!==e.id),e.type){case Le.DISPLACE:{this.blendPositions();break}default:{this.blendColors(),this.blendAfterColors();break}}}};var rr=class extends kS{constructor(e,t,r){super(r);this.isNodeMaterial=!0;this.type="NodeMaterial";this.wireframeLinecap="";this.wireframeLinejoin="";this.uniformsBackup={};this.userData={type:"",category:"",nodeType:""};this.fog=!0,this.vertex=e!=null?e:new ia(new wt(wt.PROJECTION)),this.fragment=t!=null?t:new ia(new Ge(nt)),this.updaters=[],this.isDetached=!0,this.dithering=!0,this.onBeforeCompile=this._onBeforeCompile}getDefines(){return this.defines}getUniforms(){return this.uniforms}getVertexShader(){return this.vertexShader}getFragmentShader(){return this.fragmentShader}_onBeforeCompile(e,t){this.build({renderer:t}),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}_getLayerStack(e){let t=new Pt(this);return e&&(async()=>{for(;e.image===void 0;)await new Promise(r=>requestAnimationFrame(r));t.addLayerAt(1,{type:Le.TEXTURE,texture:e}),this.dispose()})(),t}clampUniformsForPreview(e,t){let r=(o,n,s)=>Math.min(Math.max(o,n),s);if(this.userData.layers){for(let o of this.userData.layers.getLayers())if(o.type==Le.DISPLACE){this.uniformsBackup[`f${o.id}_intensity`]=o.uniforms[`f${o.id}_intensity`].value;let n=r(o.uniforms[`f${o.id}_intensity`].value,e,t);o.uniforms[`f${o.id}_intensity`].value=n}}}restoreClampedUniforms(){if(this.userData.layers)for(let e of this.userData.layers.getLayers())e.type==Le.DISPLACE&&(e.uniforms[`f${e.id}_intensity`].value=this.uniformsBackup[`f${e.id}_intensity`])}customProgramCacheKey(){return this.getHash()}updateFrame(e){for(let t=0;t<this.updaters.length;++t)e.updateNode(this.updaters[t])}build(e){var r;e=e!=null?e:{};let t=(r=e.builder)!=null?r:new El;return t.setMaterial(this,e.renderer),t.build(this.vertex,this.fragment),this.vertexShader=t.getCode("vertex"),this.fragmentShader=t.getCode("fragment"),this.defines=t.defines,this.uniforms=t.uniforms,this.extensions=t.extensions,this.updaters=t.updaters,this.fog=t.requires.fog,this.lights=t.requires.lights,this.transparent=t.requires.transparent||this.blending>US,this}getHash(){let e="{";return e+='"vertex":'+this.vertex.getHash()+",",e+='"fragment":'+this.fragment.getHash(),e+="}",e}copy(e){let t=this.uuid;for(let r in e)this[r]=e[r];return this.uuid=t,e.userData!==void 0&&(this.userData=JSON.parse(JSON.stringify(e.userData))),this}toJSON(e){let t=this.userData.layers;this.userData.layers=void 0;let r=super.toJSON(e);return r.type="ShaderMaterial",r.userData={type:this.userData.type,category:this.userData.category,nodeType:this.type,layers:t.toJSON(e)},r.vertex=this.vertex.toJSON(e).uuid,r.fragment=this.fragment.toJSON(e).uuid,delete r.vertexShader,delete r.fragmentShader,delete r.color,delete r.shininess,delete r.specular,delete r.roughness,delete r.metalness,delete r.uniforms,e&&!e.materials[this.uuid]&&(e.materials[this.uuid]=r),this.userData.layers=t,r}fromJSON(e,t){var r;this.defines=(r=e.defines)!=null?r:{},this.depthFunc=e.depthFunc,this.depthWrite=e.depthWrite,this.side=e.side!==void 0?e.side:HS,this.transparent=e.transparent,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.wireframe=e.wireframe,this.userData.layers.fromJSON(e.userData.layers,t,this)}};Object.defineProperties(rr.prototype,{properties:{get:function(){return this.fragment.properties}},needsUpdate:{set:function(i){i===!0&&this.version++,this.needsCompile=i},get:function(){return this.needsCompile}}});import{UniformsLib as qS,UniformsUtils as WS}from"three";var Wl=class extends pe{constructor(){super("basic");this.nodeType="Basic";this.color=new Ge(nt)}generate(e){let t;if(e.isShader("vertex")){let r=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(WS.merge([qS.fog])),e.addParsCode(["varying vec3 vViewPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>"].join(`
|
|
709
|
+
`)}}();var Pt=class{constructor(e){this.id=2,this.layerCount=2,this.uuid=Vr.generateUUID(),this.needsUpdate=!1,this._material=e,this._layerNodes=[];let t=this._createLayer({id:0,type:Le.COLOR});this._material.color=t.color,this._material.alpha===void 0&&(this._material.alpha=new ee(1));let r=new ee(1),o=new ve(0);"shadingAlpha"in this._material&&"shadingBlend"in this._material&&(this._material.shadingAlpha=r,this._material.shadingBlend=o),this._layerNodes.push({id:0,type:ke.COLOR,color:t.color,alpha:t.alpha,mode:t.mode}),this._layerNodes.push({id:1,type:ke.LIGHTING,alpha:r,mode:o}),this.head=t.layer,this.head.next=new Je(1,void 0,{type:Le.LIGHTING,alpha:r,mode:o}),this.attachLightNodes(this.getLightLayer())}get material(){return this._material}set material(e){var n;this._material=e;let t,r,o=this.head;for(;o!==void 0;){if(o.type===Le.LIGHTING){t=o.uniforms[`f${o.id}_alpha`],r=o.uniforms[`f${o.id}_mode`];break}o=o.next}"shadingAlpha"in this._material&&"shadingBlend"in this._material&&(this._material.shadingAlpha=t,this._material.shadingBlend=r),this.attachLightNodes((n=e.userData.layers)==null?void 0:n.getLightLayer()),this.blendColors(),this.blendAfterColors(),this.blendPositions()}getLayersOfType(e){let t=[],r=this.head;for(;r;)r.type===e&&t.push(r),r=r.next;return t}addLayer(e){var o;if(e.id=(o=e.id)!=null?o:++this.id,this.layerCount++,e.type===Le.LIGHTING){let n=this.createLightLayer(e);return this.uuid=Vr.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),n}let t=this._createLayer(e),r=t.layer;if(this.head===void 0)this.head=r;else{let n=this.head;for(;n.next!=null;)n=n.next;n.next=r}return t.color&&this._layerNodes.push({id:r.id,type:ke.COLOR,color:t.color,alpha:t.alpha,mode:t.mode}),t.position&&this._layerNodes.push({id:r.id,type:ke.POSITION,position:t.position}),this.uuid=Vr.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),r}addLayerBeforeAt(e,t){var a;let r=this.head;e.id=(a=e.id)!=null?a:++this.id,this.layerCount++;let o=this._createLayer(e),n=o.layer;n.next=t;let s=0;if(r===t)this.head=n,o.color&&this._layerNodes.splice(0,0,{id:n.id,type:ke.COLOR,color:o.color,alpha:o.alpha,mode:o.mode}),o.position&&this._layerNodes.splice(0,0,{id:n.id,type:ke.POSITION,position:o.position});else{for(s=1;(r==null?void 0:r.next)!==t;)r=r==null?void 0:r.next,s++;r.next=n,o.color&&this._layerNodes.splice(s,0,{id:n.id,type:ke.COLOR,color:o.color,alpha:o.alpha,mode:o.mode}),o.position&&this._layerNodes.splice(s,0,{id:n.id,type:ke.POSITION,position:o.position})}return this.uuid=Vr.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),n}addLayerAt(e,t){var n;t.id=(n=t.id)!=null?n:++this.id,this.layerCount++;let r=this._createLayer(t),o=r.layer;if(r.color&&this._layerNodes.splice(e,0,{id:o.id,type:ke.COLOR,color:r.color,alpha:r.alpha,mode:r.mode}),r.position&&this._layerNodes.splice(e,0,{id:o.id,type:ke.POSITION,position:r.position}),e==0)o.next=this.head,this.head=o;else{let s=this.head,a=this.head.next;for(let l=0;l<e-1;l++)s=a,a=a.next;o.next=a,s.next=o}return this.uuid=Vr.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),o}removeLayer(e){let t=this.head,r,o=0;if((t==null?void 0:t.id)==e)this.head=t.next;else for(o=1,r=t,t=t==null?void 0:t.next;t!=null;){if(t.id==e){r.next=t.next;break}o++,r=t,t=t.next}return this.cleanupChangedLayer(t),this.blendColors(),this.blendAfterColors(),this.blendPositions(),this.uuid=Vr.generateUUID(),this.layerCount--,o}changeLayer(e,t){let r,o=this.head,n;if((o==null?void 0:o.id)==e){let s=this._createLayer(O({id:e,uuid:o.uuid},t));n=s.layer,n.next=o.next,this.head=n,s.color&&(this._layerNodes[0]={id:n.id,type:ke.COLOR,color:s.color,alpha:s.alpha,mode:s.mode}),s.position&&(this._layerNodes[0]={id:n.id,type:ke.POSITION,position:s.position}),n.uniforms[`f${e}_mode`].value=o.uniforms[`f${e}_mode`].value,n.uniforms[`f${e}_alpha`].value=o.uniforms[`f${e}_alpha`].value}else{r=o,o=o.next;let s=1;for(;o!=null;){if(o.id==e){let a=this._createLayer(O({id:e,uuid:o.uuid},t));n=a.layer,r.next=n,n.next=o.next,a.color&&(this._layerNodes[s]={id:e,type:ke.COLOR,color:a.color,alpha:a.alpha,mode:a.mode}),a.position&&(this._layerNodes[s]={id:e,type:ke.POSITION,position:a.position}),n.uniforms[`f${e}_mode`].value=o.uniforms[`f${e}_mode`].value,n.uniforms[`f${e}_alpha`].value=o.uniforms[`f${e}_alpha`].value;break}r=o,o=o.next,s++}}return this.uuid=Vr.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),n}getLayer(e){let t=this.head;for(;t!=null&&t.id!=e;)t=t.next;return t}getLayerByUuid(e){let t=this.head;for(;t!==void 0;){if(t.uuid===e)return t;t=t.next}}getLayers(){let e=[],t=this.head;for(;t!=null;)e.push(t),t=t.next;return e}getLayerPosition(e){let t=this.head,r=0;for(;t!==void 0&&t.id!=e;)r++,t=t.next;return r}getDefines(){}getBeforeProgram(){}getLightingProgram(){}getAfterProgram(){}getVarPrograms(){}getUniforms(){}moveLayer(e,t){let r,o=this.head,n;if(e==0)r=this.head,this.head=r.next;else{for(let a=0;a<e;a++)n=o,o=o.next;n.next=o.next,r=o}if(o=this.head,n=void 0,t==0)r.next=this.head,this.head=r;else{for(let a=0;a<t-1;a++)o=o.next;r.next=o==null?void 0:o.next,o.next=r}let s=this._layerNodes.splice(e,1)[0];this._layerNodes.splice(t,0,s),this.uuid=Vr.generateUUID(),this.blendColors(),this.blendAfterColors()}updateLayerUniform(){this.uuid=Vr.generateUUID(),this.blendColors(),this.blendAfterColors()}copy(e){this.needsUpdate=!1,this.layerCount=e.layerCount,this._layerNodes=[],this.layerCount=0,this.head=void 0,this.rebuildLayerNodes(this.head,e.head);let t=e.head,r=this.head;for(;t.next!=null;)this.rebuildLayerNodes(r,t.next),r=r.next,t=t.next;return this.id=e.id,this.uuid=e.uuid,this.blendColors(),this.blendAfterColors(),this.blendPositions(),this}createLightLayer(e){let t=new ee(e.alpha),r=new ve(e.mode);this._material.shadingAlpha=t,this._material.shadingBlend=r,this._layerNodes.push({id:e.id,type:ke.LIGHTING,alpha:t,mode:r});let o=new Je(e.id,void 0,{type:Le.LIGHTING,alpha:t,mode:r});if(this.head===void 0)this.head=o;else{let n=this.head;for(;n.next!=null;)n=n.next;n.next=o}return this.attachLightNodes(this.getLightLayer()),o}rebuildLayerNodes(e,t,r=!1){if(t.type===Le.LIGHTING){let o=r?t.uniforms[`f${t.id}_alpha`]:new ee(t.uniforms[`f${t.id}_alpha`].value),n=r?t.uniforms[`f${t.id}_mode`]:new ve(t.uniforms[`f${t.id}_mode`].value);this._material.shadingAlpha=o,this._material.shadingBlend=n,this._layerNodes.push({id:t.id,type:ke.LIGHTING,alpha:o,mode:n}),this.head===void 0?this.head=new Je(t.id,t.uuid,{type:Le.LIGHTING,alpha:o,mode:n}):e&&(e.next=new Je(t.id,t.uuid,{type:Le.LIGHTING,alpha:o,mode:n})),this.attachLightNodes(t)}else{let o={type:t.type,id:t.id};for(let n in t.uniforms){let s=t.getName(n);if(!s)continue;let a=`f${t.id}_${s}`;if(Array.isArray(t.uniforms[a].value))o[s]=t.uniforms[a].value.map(l=>l.clone&&!r?l.clone():l);else{let l=t.uniforms[a].value;if(s==="transmissionDepthMap"){o[s]=l;continue}l!=null&&(o[s]=l.clone&&!r&&!l.isRenderTargetTexture?l.clone():l)}}this.addLayer(o)}}attachLightNodes(e){var o,n,s,a,l,c,d,u,p,f,m;let t={},r=this.getLightLayer();switch(this._material.userData.category){case"Lambert":t.emissive=new Ge((n=(o=e==null?void 0:e.getValue("emissive"))==null?void 0:o.clone())!=null?n:0);break;case"Phong":t.shininess=new ee((s=e==null?void 0:e.getValue("shininess"))!=null?s:30),t.specular=new Ge((l=(a=e==null?void 0:e.getValue("specular"))==null?void 0:a.clone())!=null?l:1118481);break;case"Toon":t.shininess=new ee((c=e==null?void 0:e.getValue("shininess"))!=null?c:30),t.specular=new Ge((u=(d=e==null?void 0:e.getValue("specular"))==null?void 0:d.clone())!=null?u:1118481);break;case"Physical":t.roughness=new ee((p=e==null?void 0:e.getValue("roughness"))!=null?p:.3),t.metalness=new ee((f=e==null?void 0:e.getValue("metalness"))!=null?f:0),t.reflectivity=new ee((m=e==null?void 0:e.getValue("reflectivity"))!=null?m:.5);break;default:break}Object.keys(t).forEach(x=>{this._material[x]=t[x],r.uniforms[`f${r.id}_${x}`]=t[x]})}clone(e){return new Pt(e).copy(this)}toJSON(e){return{id:this.id,uuid:this.uuid,head:this.head.toJSON(e)}}fromJSON(e,t,r){let o=new Je(e.head.id,void 0,{type:e.head.type}).fromJSON(e.head,t),n=e.head.next,s=o;for(;n!=null;)s.next=new Je(n.id,void 0,{type:n.type}).fromJSON(n,t),n=n.next,s=s.next;this._layerNodes=[],this.head=void 0,this.rebuildLayerNodes(this.head,o,!0);let a=o;for(s=this.head;a.next!=null;)this.rebuildLayerNodes(s,a.next,!0),s=s.next,a=a.next;return this._material=r,this.id=e.id,this.uuid=e.uuid,this.blendColors(),this.blendAfterColors(),this.blendPositions(),this}getLightLayer(){var t;let e=this.head;for(;e!==void 0&&e.type!=="light";)e=(t=e.next)!=null?t:e;return e}dispose(){let e=this.head;for(this._layerNodes=[],this.layerCount=0;e!==void 0;)e.hasOwnProperty("dispose")===!0&&e.dispose(),e=e.next;this.head=void 0}_createLayer(e){var r,o,n,s,a,l,c,d,u,p,f,m,x,y,N,L,w,B,S,_,T,h,I,b,P,v,D,Z,V,ie,oe,ge,xe,A,j,g,z,R,U,q,W,J,E,H,k,se,F,K,X,te,he,Y,ne,Se,me,Oe,He,rt,pt,zt,Tr,xt,Ir,uo,ho,qe,bt,Et,bn,vn,Sn,wn,Nn,Cn,$t,Li,ut,jo,Ln;let t=e.type;switch(t){case Le.COLOR:{let ye=new Ge((r=e.color)!=null?r:nt),Ce=new ee((o=e.alpha)!=null?o:1),we=new Be("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");we.keywords.alpha=Ce;let Ne=new ve((n=e.mode)!=null?n:0);return ye.alpha=Ce,{layer:new Je(e.id,e.uuid,{type:t,color:ye,alpha:Ce,calpha:we,mode:Ne}),color:ye,alpha:we,mode:Ne}}case Le.TEXTURE:{let ye=(s=e.texture)!=null?s:new Fr,Ce=ye.matrix;e.mat&&Ce.copy(e.mat),ye.needsUpdate=!0;let we=new ee((a=e.crop)!=null?a:0),Ne=new ve((l=e.projection)!=null?l:0),Te=new ve((c=e.axis)!=null?c:0),_e=new It(e.size?new so(e.size[0],e.size[1]):new so(100,100)),ze=new ee((d=e.alpha)!=null?d:1),Ee=new ve((u=e.mode)!=null?u:0),De=new Bt(ye),We=new Mt((p=e.textureSize)!=null?p:new ao(ye.image?ye.image.width:0,ye.image?ye.image.height:0)),ot=new sa(De,We,we,Ne,Te,_e,ze,Ee),Jt=new Be(ot.calpha,"f");return{layer:new Je(e.id,e.uuid,{type:t,texture:De,textureSize:We,crop:we,projection:Ne,axis:Te,size:_e,mat:ot.mat,alpha:ze,calpha:Jt,mode:Ee}),color:ot,alpha:Jt,mode:Ee}}case Le.MATCAP:{let ye=(f=e.texture)!=null?f:new Fr;ye.needsUpdate=!0;let Ce=new ee((m=e.alpha)!=null?m:1),we=new Bt(ye),Ne=new ve((x=e.mode)!=null?x:0),Te=new fa(we,Ce,Ne),_e=new Be(Te.calpha,"f");return{layer:new Je(e.id,e.uuid,{type:t,texture:we,alpha:Ce,calpha:_e,mode:Ne}),color:Te,alpha:_e,mode:Ne}}case Le.FRESNEL:{let ye=new Ge((y=e.color)!=null?y:16777215),Ce=new ee((N=e.bias)!=null?N:.1),we=new ee((L=e.scale)!=null?L:1),Ne=new ee((w=e.intensity)!=null?w:2),Te=new ee((B=e.factor)!=null?B:1),_e=new ee((S=e.alpha)!=null?S:1),ze=new ve((_=e.mode)!=null?_:0),Ee=new aa(ye,Ce,we,Ne,Te,_e,ze),De=new Be(Ee.calpha,"f");return{layer:new Je(e.id,e.uuid,{type:t,color:ye,bias:Ce,scale:we,intensity:Ne,factor:Te,alpha:_e,calpha:De,mode:ze}),color:Ee,alpha:De,mode:ze}}case Le.RAINBOW:{let ye=new ee((T=e.filmThickness)!=null?T:30),Ce=new ee((h=e.movement)!=null?h:0),we=new Mt((I=e.wavelengths)!=null?I:new ao(0,0,0)),Ne=new ee((b=e.noiseStrength)!=null?b:0),Te=new ee((P=e.noiseScale)!=null?P:1),_e=new Mt((v=e.offset)!=null?v:new ao(0,0,0)),ze=new ee((D=e.alpha)!=null?D:1),Ee=new la(ye,Ce,we,Ne,Te,_e,ze),De=new Be(Ee.calpha,"f"),We=new ve((Z=e.mode)!=null?Z:0);return{layer:new Je(e.id,e.uuid,{type:t,filmThickness:ye,movement:Ce,wavelengths:we,noiseStrength:Ne,noiseScale:Te,offset:_e,alpha:ze,calpha:De,mode:We}),color:Ee,alpha:De,mode:We}}case Le.TRANSMISSION:{let ye=new ee((V=e.thickness)!=null?V:10),Ce=new ee((ie=e.ior)!=null?ie:1.5),we=new ee((oe=e.roughness)!=null?oe:.5),Ne=new It((ge=e.transmissionSamplerSize)!=null?ge:new so(2048,2048)),Te=(xe=e.transmissionSamplerMap)!=null?xe:new Fr,_e=(A=e.transmissionDepthMap)!=null?A:new Fr,ze=new Bt(Te),Ee=new Bt(_e),De=window.innerWidth,We=window.innerHeight,ot=De>=We?new It(We/De,1):new It(1,De/We),Jt=new ee((j=e.alpha)!=null?j:1),Mr=new ca(ye,Ce,we,Ne,ze,Ee,ot,Jt),kr=new Be(Mr.calpha,"f"),Hr=new ve((g=e.mode)!=null?g:0);return{layer:new Je(e.id,e.uuid,{type:t,thickness:ye,ior:Ce,roughness:we,transmissionSamplerSize:Ne,transmissionSamplerMap:ze,transmissionDepthMap:Ee,aspectRatio:ot,alpha:Jt,calpha:kr,mode:Hr}),color:Mr,alpha:kr,mode:Hr}}case Le.DEPTH:{let ye=new ve((z=e.gradientType)!=null?z:0),Ce=new na((R=e.smooth)!=null?R:!1),we=new ee((U=e.near)!=null?U:50),Ne=new ee((q=e.far)!=null?q:200),Te=new ee((W=e.isVector)!=null?W:1),_e=new ee((J=e.isWorldSpace)!=null?J:0),ze=new Mt((E=e.origin)!=null?E:new ao),Ee=new Mt((H=e.direction)!=null?H:new ao),De=new ve((k=e.num)!=null?k:0),We;e.colors?We=new yi(De.value+1,e.colors):(We=new yi(De.value+1,new ya(0,0,0,1)),We.value[1]=new ya(1,1,1,1));let ot;e.steps?ot=new gi(e.steps.length,e.steps):(ot=new gi(10,1),ot.value[0]=0);let Jt=new ee((se=e.alpha)!=null?se:1),Mr=new ve((F=e.mode)!=null?F:0),kr=new ma(ye,Ce,we,Ne,Te,_e,ze,Ee,We,ot,De,Jt),Hr=new Be(kr.calpha,"f");return{layer:new Je(e.id,e.uuid,{type:t,gradientType:ye,smooth:Ce,near:we,far:Ne,isVector:Te,isWorldSpace:_e,origin:ze,direction:Ee,colors:We,steps:ot,num:De,alpha:Jt,calpha:Hr,mode:Mr}),color:kr,alpha:Hr,mode:Mr}}case Le.NOISE:{let ye=new ee((K=e.scale)!=null?K:1),Ce=new Mt((X=e.size)!=null?X:new ao(100,100,100)),we=new ee((te=e.move)!=null?te:1),Ne=new It((he=e.fA)!=null?he:new so(1.7,9.2)),Te=new It((Y=e.fB)!=null?Y:new so(8.3,2.8)),_e=new It((ne=e.distortion)!=null?ne:new so(1,1)),ze=new no(e.colorA),Ee=new no(e.colorB),De=new no(e.colorC),We=new no(e.colorD),ot=new ee((Se=e.alpha)!=null?Se:1),Jt=new ve((me=e.mode)!=null?me:0),Mr=new ve((Oe=e.noiseType)!=null?Oe:0),kr=new ua(ye,Ce,we,Ne,Te,_e,ze,Ee,De,We,ot,Mr),Hr=new Be(kr.calpha,"f");return{layer:new Je(e.id,e.uuid,{type:t,scale:ye,size:Ce,move:we,fA:Ne,fB:Te,distortion:_e,colorA:ze,colorB:Ee,colorC:De,colorD:We,alpha:ot,calpha:Hr,mode:Jt,noiseType:Mr}),color:kr,alpha:Hr,mode:Jt}}case Le.NORMAL:{let ye=new Mt((He=e.cnormal)!=null?He:new ao(1,1,1)),Ce=new ee((rt=e.alpha)!=null?rt:1),we=new ve((pt=e.mode)!=null?pt:0),Ne=new da(ye,Ce),Te=new Be("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");return Te.keywords.alpha=Ce,{layer:new Je(e.id,e.uuid,{type:t,cnormal:ye,alpha:Ce,calpha:Te,mode:we}),color:Ne,alpha:Te,mode:we}}case Le.GRADIENT:{let ye=new ve((zt=e.gradientType)!=null?zt:0),Ce=new na((Tr=e.smooth)!=null?Tr:!1),we;e.colors?we=new yi(e.colors.length,e.colors):(we=new yi(10,new ya(0,0,0,1)),we.value[1]=new ya(1,1,1,1));let Ne;e.steps?Ne=new gi(e.steps.length,e.steps):(Ne=new gi(10,1),Ne.value[0]=0);let Te=new It((xt=e.offset)!=null?xt:new so(0,0)),_e=new It((Ir=e.morph)!=null?Ir:new so(0,0)),ze=new ee((uo=e.angle)!=null?uo:0),Ee=new ee((ho=e.alpha)!=null?ho:1),De=new ve((qe=e.mode)!=null?qe:0),We=new pa(ye,Ce,we,Ne,Te,_e,ze,Ee),ot=new Be(We.calpha,"f");return{layer:new Je(e.id,e.uuid,{type:t,gradientType:ye,smooth:Ce,colors:we,steps:Ne,offset:Te,morph:_e,angle:ze,alpha:Ee,calpha:ot,mode:De}),color:We,alpha:ot,mode:De}}case Le.DISPLACE:{let ye=new ve((bt=e.displacementType)!=null?bt:0);if(ye.value===0){let Ce=new Mt((Et=e.offset)!=null?Et:new ao(0,0,0)),we=new ee((bn=e.scale)!=null?bn:10),Ne=new ee((vn=e.intensity)!=null?vn:8),Te=new ee((Sn=e.movement)!=null?Sn:1),_e=new ee((wn=e.alpha)!=null?wn:1),ze=new ve((Nn=e.mode)!=null?Nn:0),Ee=new ve((Cn=e.noiseType)!=null?Cn:0),De=new tn(ye,Ne,Te,Ce,we,Ee);return{layer:new Je(e.id,e.uuid,{displacementType:ye,type:t,offset:Ce,scale:we,intensity:Ne,movement:Te,alpha:_e,mode:ze,noiseType:Ee}),position:De}}else if(ye.value===1){let Ce=($t=e.texture)!=null?$t:new Fr,we=Ce.matrix;e.mat&&we.copy(e.mat),Ce.needsUpdate=!0;let Ne=new ee((Li=e.intensity)!=null?Li:8),Te=new Bt(Ce),_e=new ee((ut=e.crop)!=null?ut:0),ze=new ee((jo=e.alpha)!=null?jo:1),Ee=new ve((Ln=e.mode)!=null?Ln:0),De=new tn(ye,Ne,Te,_e);return{layer:new Je(e.id,e.uuid,{displacementType:ye,type:t,intensity:Ne,texture:Te,crop:_e,mat:De.mat,alpha:ze,mode:Ee}),position:De}}return{}}}return{}}blendColors(){let e=this._layerNodes.findIndex(r=>r.type===ke.COLOR),t=this._layerNodes.findIndex(r=>r.type===ke.LIGHTING);if(e!==-1&&e<t){let r=this._layerNodes[e].color;for(let o=e+1;o<t;++o){let n=this._layerNodes[o];n.type===ke.COLOR&&(r=new ha(r,n.color,n.alpha,n.mode))}this._material.color=r}else this._material.color=void 0}blendAfterColors(){let e=new Be("outgoingLight","f"),t=this._layerNodes.findIndex(r=>r.type===ke.LIGHTING);if(this._layerNodes.length>t+1){for(let r=t+1;r<this._layerNodes.length;++r){let o=this._layerNodes[r];o.type===ke.COLOR&&(e=new ha(e,o.color,o.alpha,o.mode))}"afterColor"in this._material&&(this._material.afterColor=e)}else"afterColor"in this._material&&(this._material.afterColor=void 0)}blendPositions(){let e=this._layerNodes.filter(t=>t.type===ke.POSITION);if(e.length>0){let t=e[0].position;for(let r=1;r<e.length;++r)e[r]&&(t=new qt(t,e[r].position,qt.ADD),t=new qt(t,new ee(.5).setReadonly(!0),qt.MUL));this._material.position=t}else this._material.position=void 0}cleanupChangedLayer(e){switch(this._layerNodes=this._layerNodes.filter(t=>t.id!==e.id),e.type){case Le.DISPLACE:{this.blendPositions();break}default:{this.blendColors(),this.blendAfterColors();break}}}};var rr=class extends kS{constructor(e,t,r){super(r);this.isNodeMaterial=!0;this.type="NodeMaterial";this.wireframeLinecap="";this.wireframeLinejoin="";this.uniformsBackup={};this.userData={type:"",category:"",nodeType:""};this.fog=!0,this.vertex=e!=null?e:new ia(new wt(wt.PROJECTION)),this.fragment=t!=null?t:new ia(new Ge(nt)),this.updaters=[],this.isDetached=!0,this.dithering=!0,this.onBeforeCompile=this._onBeforeCompile}getDefines(){return this.defines}getUniforms(){return this.uniforms}getVertexShader(){return this.vertexShader}getFragmentShader(){return this.fragmentShader}_onBeforeCompile(e,t){this.build({renderer:t}),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}_getLayerStack(e){let t=new Pt(this);return e&&(async()=>{for(;e.image===void 0;)await new Promise(r=>requestAnimationFrame(r));t.addLayerAt(1,{type:Le.TEXTURE,texture:e}),this.dispose()})(),t}clampUniformsForPreview(e,t){let r=(o,n,s)=>Math.min(Math.max(o,n),s);if(this.userData.layers){for(let o of this.userData.layers.getLayers())if(o.type==Le.DISPLACE){this.uniformsBackup[`f${o.id}_intensity`]=o.uniforms[`f${o.id}_intensity`].value;let n=r(o.uniforms[`f${o.id}_intensity`].value,e,t);o.uniforms[`f${o.id}_intensity`].value=n}}}restoreClampedUniforms(){if(this.userData.layers)for(let e of this.userData.layers.getLayers())e.type==Le.DISPLACE&&(e.uniforms[`f${e.id}_intensity`].value=this.uniformsBackup[`f${e.id}_intensity`])}customProgramCacheKey(){return this.getHash()}updateFrame(e){for(let t=0;t<this.updaters.length;++t)e.updateNode(this.updaters[t])}build(e){var r;e=e!=null?e:{};let t=(r=e.builder)!=null?r:new El;return t.setMaterial(this,e.renderer),t.build(this.vertex,this.fragment),this.vertexShader=t.getCode("vertex"),this.fragmentShader=t.getCode("fragment"),this.defines=t.defines,this.uniforms=t.uniforms,this.extensions=t.extensions,this.updaters=t.updaters,this.fog=t.requires.fog,this.lights=t.requires.lights,this.transparent=t.requires.transparent||this.blending>US,this}getHash(){let e="{";return e+='"vertex":'+this.vertex.getHash()+",",e+='"fragment":'+this.fragment.getHash(),e+="}",e}copy(e){let t=this.uuid;for(let r in e)this[r]=e[r];return this.uuid=t,e.userData!==void 0&&(this.userData=JSON.parse(JSON.stringify(e.userData))),this}toJSON(e){let t=this.userData.layers;this.userData.layers=void 0;let r=super.toJSON(e);return r.type="ShaderMaterial",r.userData={type:this.userData.type,category:this.userData.category,nodeType:this.type,layers:t.toJSON(e)},r.vertex=this.vertex.toJSON(e).uuid,r.fragment=this.fragment.toJSON(e).uuid,delete r.vertexShader,delete r.fragmentShader,delete r.color,delete r.shininess,delete r.specular,delete r.roughness,delete r.metalness,delete r.uniforms,e&&!e.materials[this.uuid]&&(e.materials[this.uuid]=r),this.userData.layers=t,r}fromJSON(e,t){var r;this.defines=(r=e.defines)!=null?r:{},this.depthFunc=e.depthFunc,this.depthWrite=e.depthWrite,this.side=e.side!==void 0?e.side:HS,this.transparent=e.transparent,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.wireframe=e.wireframe,this.userData.layers.fromJSON(e.userData.layers,t,this)}};Object.defineProperties(rr.prototype,{properties:{get:function(){return this.fragment.properties}},needsUpdate:{set:function(i){i===!0&&this.version++,this.needsCompile=i},get:function(){return this.needsCompile}}});import{UniformsLib as qS,UniformsUtils as WS}from"three";var Wl=class extends pe{constructor(){super("basic");this.nodeType="Basic";this.color=new Ge(nt)}generate(e){let t;if(e.isShader("vertex")){let r=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(WS.merge([qS.fog])),e.addParsCode(["varying vec3 vViewPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>"].join(`
|
|
710
710
|
`));let o=["#include <beginnormal_vertex>",`
|
|
711
711
|
#if !defined( USE_LAYER_DISPLACE )
|
|
712
712
|
#include <defaultnormal_vertex>
|
|
@@ -938,8 +938,8 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
|
|
|
938
938
|
#include <begin_vertex>
|
|
939
939
|
#endif /* !USE_LAYER_DISPLACE */
|
|
940
940
|
`];r&&o.push(r.code,r.result?"displaced_position = "+r.result+";":""),o.push("transformed = displaced_position;","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),o.push("#include <project_vertex>","#include <fog_vertex>","#include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;","#include <worldpos_vertex>","#include <shadowmap_vertex>"),t=o.join(`
|
|
941
|
-
`)}else{let r={gamma:!0};this.color===void 0&&(this.color=new Ge(nt)),this.color.analyze(e,{slot:"color",context:r}),this.roughness.analyze(e),this.metalness.analyze(e),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e),this.reflectivity&&this.reflectivity.analyze(e);let o=this.color.flow(e,"c",{slot:"color",context:r}),n=this.roughness.flow(e,"f"),s=this.metalness.flow(e,"f"),a=this.shadingAlpha.flow(e,"f"),l=this.shadingBlend.flow(e,"i"),c=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,d=this.alpha?this.alpha.flow(e,"f"):void 0,
|
|
942
|
-
`));let
|
|
941
|
+
`)}else{let r={gamma:!0};this.color===void 0&&(this.color=new Ge(nt)),this.color.analyze(e,{slot:"color",context:r}),this.roughness.analyze(e),this.metalness.analyze(e),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e),this.reflectivity&&this.reflectivity.analyze(e);let o=this.color.flow(e,"c",{slot:"color",context:r}),n=this.roughness.flow(e,"f"),s=this.metalness.flow(e,"f"),a=this.shadingAlpha.flow(e,"f"),l=this.shadingBlend.flow(e,"i"),c=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,d=this.alpha?this.alpha.flow(e,"f"):void 0,u=this.reflectivity?this.reflectivity.flow(e,"f"):void 0;e.requires.transparent=d!==void 0,e.addParsCode(["varying vec3 vViewPosition;","#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(`
|
|
942
|
+
`));let p=["#include <clipping_planes_fragment>"," #include <normal_fragment_begin>",`
|
|
943
943
|
// NOTE: gl_FrontFacing alternative using face normal estimation.
|
|
944
944
|
vec3 viewdx = dFdx(vViewPosition);
|
|
945
945
|
vec3 viewdy = dFdy(vViewPosition);
|
|
@@ -947,12 +947,12 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
|
|
|
947
947
|
if (dot(normal, faceNormal) < 0.0) {
|
|
948
948
|
normal *= -1.0;
|
|
949
949
|
}
|
|
950
|
-
`," PhysicalMaterial material;"," material.diffuseColor = vec3( 1.0 );"];
|
|
950
|
+
`," PhysicalMaterial material;"," material.diffuseColor = vec3( 1.0 );"];p.push(o.code," vec3 diffuseColor = "+o.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );",n.code," float roughnessFactor = "+n.result+";",s.code," float metalnessFactor = "+s.result+";"),d&&p.push(d.code,"#ifdef ALPHATEST"," if ( "+d.result+" <= ALPHATEST ) discard;","#endif"),p.push("vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );","float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );"),p.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 );"),u?p.push(u.code,"material.specularColor = mix( vec3( 0.16 * pow2( "+u.result+" ) ), diffuseColor, metalnessFactor );"):p.push("material.specularColor = mix( vec3( 0.04 ), diffuseColor, metalnessFactor );"),p.push("#include <lights_fragment_begin>"),p.push("#include <lights_fragment_end>"),p.push("vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular;"),p.push(`
|
|
951
951
|
if (outgoingLight != diffuseColor) {
|
|
952
952
|
float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );
|
|
953
953
|
accumAlpha += ( 1.0 - accumAlpha ) * ${a.result} * lightAccu;
|
|
954
954
|
outgoingLight = spe_blend( diffuseColor, outgoingLight, ${a.result}, ${l.result} );
|
|
955
955
|
}
|
|
956
|
-
`),c&&
|
|
957
|
-
`)}return t}copy(e){return super.copy(e),e.color&&(this.color=e.color.clone()),this.roughness=e.roughness.clone(),this.metalness=e.metalness.clone(),e.position&&(this.position=e.position.clone()),e.afterColor&&(this.afterColor=e.afterColor.clone()),e.alpha&&(this.alpha=e.alpha.clone()),e.reflectivity&&(this.reflectivity=e.reflectivity.clone()),e.shadingAlpha&&(this.shadingAlpha=e.shadingAlpha.clone()),e.shadingBlend&&(this.shadingBlend=e.shadingBlend.clone()),this}};var rc=class extends rr{get color(){return this.fragment.color}set color(e){this.fragment.color=e}get afterColor(){return this.fragment.afterColor}set afterColor(e){this.fragment.afterColor=e}get alpha(){return this.fragment.alpha}set alpha(e){this.fragment.alpha=e}get shadingAlpha(){return this.fragment.shadingAlpha}set shadingAlpha(e){this.fragment.shadingAlpha=e}get shadingBlend(){return this.fragment.shadingBlend}set shadingBlend(e){this.fragment.shadingBlend=e}get position(){return this.fragment.position}set position(e){this.fragment.position=e}get roughness(){return this.fragment.roughness}set roughness(e){this.fragment.roughness=e}get metalness(){return this.fragment.metalness}set metalness(e){this.fragment.metalness=e}get reflectivity(){return this.fragment.reflectivity}set reflectivity(e){this.fragment.reflectivity=e}constructor(e=new tc,t){super(e,e,t);this.type="StandardNodeMaterial",this.fragment=e}};var nn=class extends rc{constructor(e,t,r){super(t,e);this.userData.type="PhysicalMaterial",this.userData.category="Physical",this.userData.layers=r!=null?r:this._getLayerStack(e==null?void 0:e.map)}get layersList(){return this.userData.layers}set layersList(e){this.userData.layers=e}equals(e){return this.userData.type===e.userData.type&&this.userData.layers.uuid==e.userData.layers.uuid}copy(e){if(e.userData.layers!==void 0&&e.userData.layers instanceof Pt){let t=e.userData.layers,r=e.fragment;super.copy(e);let o=r.clone();this.fragment=o,this.vertex=o;let n=t.clone(this);this.userData.layers=n,o.shadingAlpha.value=r.shadingAlpha.value,o.shadingBlend.value=r.shadingBlend.value}else super.copy(e);return this}static fromJSON(e,t,r){let o=r.getNode(t.vertex),n=new nn(void 0,o);return n.fromJSON(t,r),n}dispose(){super.dispose()}};import{Color as ic}from"three";import{Matrix3 as Kh,Texture as oc,Vector2 as sn,Vector3 as Mo,Vector4 as Xh}from"three";function Zh(i,e){switch(i.data.type){case"light":return dr(i);case"fresnel":return QS(i,e);case"gradient":return YS(i);case"depth":return ew(i);case"normal":return tw(i);case"noise":return rw(i,e);case"texture":return ow(i,e);case"rainbow":return iw(i);case"transmission":return nw(i,e);case"matcap":return sw(i,e);case"displace":return aw(i);case"color":default:return ZS(i,e)}}function Qh(i){return{type:i.data.type}}function dr(i){let{alpha:e,mode:t}=i.data;return $(O({},Qh(i)),{alpha:e,mode:t})}function ZS(i,e){return $(O({},dr(i)),{color:Ye(i.data.color,e)})}function QS(i,e){let{bias:t,scale:r,intensity:o,factor:n,color:s}=i.data;return $(O({},dr(i)),{color:Ye(s,e),bias:t,scale:r,intensity:o,factor:n})}function YS(i){let{gradientType:e,smooth:t,colors:r,steps:o,angle:n,offset:s,morph:a}=i.data;return $(O({},dr(i)),{gradientType:e,smooth:t,colors:r.map(l=>new Xh(l[0],l[1],l[2],l[3])),num:r.length,steps:o,offset:new sn(...s),morph:new sn(...a),angle:n})}function ew(i){let{gradientType:e,near:t,far:r,isVector:o,isWorldSpace:n,origin:s,direction:a,colors:l,steps:c,smooth:d,num:p}=i.data;return $(O({},dr(i)),{gradientType:e,near:t,far:r,isVector:o,isWorldSpace:n,origin:new Mo(...s),direction:a?new Mo(...a):new Mo(1,0,0),num:p,colors:l.map(u=>new Xh(u[0],u[1],u[2],u[3])),steps:c,smooth:d})}function tw(i){let{cnormal:e}=i.data;return $(O({},dr(i)),{cnormal:new Mo(e[0],e[1],e[2])})}function rw(i,e){let{data:t}=i;return $(O({},dr(i)),{scale:t.scale,move:t.move,fA:new sn(...t.fA),fB:new sn(...t.fB),distortion:new sn(...t.distortion),colorA:Ye(t.colorA,e),colorB:Ye(t.colorB,e),colorC:Ye(t.colorC,e),colorD:Ye(t.colorD,e),noiseType:t.noiseType})}function ow(i,e){let{projection:t,axis:r,crop:o,size:n}=i.data,{image:s,wrapping:a,repeat:l,offset:c}=i.data.texture,d=new oc,p;if(typeof s=="string")p=e==null?void 0:e.getImage(s);else{let u=new Image;u.src=s.data,u.onload=()=>{(e==null?void 0:e.onImageLoad)&&(e==null||e.onImageLoad(s.data))},p=u}return d.image=p,d.wrapS=d.wrapT=a,$(O({},dr(i)),{texture:d,mat:new Kh().setUvTransform(c[0],c[1],l[0],l[1],0,0,0),crop:o,projection:t,axis:["x","y","z"].indexOf(r),size:n})}function iw(i){let{data:e}=i;return $(O({},dr(i)),{filmThickness:e.filmThickness,movement:e.movement,wavelengths:new Mo(...e.wavelengths),noiseStrength:e.noiseStrength,noiseScale:e.noiseScale,offset:new Mo(...e.offset)})}function nw(i,e){let{data:t}=i;return $(O({},dr(i)),{thickness:t.thickness,ior:t.ior,roughness:t.roughness,transmissionSamplerMap:e.transmissionSamplerMap,transmissionDepthMap:e.transmissionDepthMap})}function sw(i,e){let t=new oc,{image:r}=i.data.texture,o;if(typeof r=="string")o=e==null?void 0:e.getImage(r);else{let s=new Image;s.src=r.data,s.onload=()=>{(e==null?void 0:e.onImageLoad)&&(e==null||e.onImageLoad(r.data))},o=s}t.image=o;let n=16777215;return $(O({},dr(i)),{color:n,texture:t})}function aw(i){let{data:e}=i,t=$(O({},Qh(i)),{intensity:e.intensity});if(e.displacementType==="noise")return $(O({},t),{offset:new Mo(...e.offset),scale:e.scale,movement:e.movement,noiseType:e.noiseType});{let r=new oc,o=new Kh().setUvTransform(0,0,1,1,0,0,0);return $(O({},t),{texture:r,mat:o,crop:e.crop})}}function Yh(i,e,t){if(t.type==="displace"&&(i==="intensity"||i==="visible")){let r=e.uniforms[`f${e.id}_intensity`];return r?(r.value=t.intensity*(t.visible?1:0),r):void 0}if(t.type!=="displace"&&(i==="alpha"||i==="visible")){let r=e.uniforms[`f${e.id}_alpha`];return r?(r.value=t.alpha*(t.visible?1:0),r):void 0}}import{Color as em,Vector4 as lw}from"three";var Si;(function(e){function i(t){return new em(t.x,t.y,t.z).getHex()}e.getHex=i})(Si||(Si={}));var tm;(function(e){function i(t){return new lw(t.r,t.g,t.b,t.a)}e.getThreeVector4=i})(tm||(tm={}));var rm;(function(t){function i(r,o){r.setRGB(o.r,o.g,o.b)}t.setThreeColor=i;function e(r){return new em(r.r,r.g,r.b).getHex()}t.getHex=e})(rm||(rm={}));function an(i,e){return typeof i=="string"?e.getMaterialOrDeletedPlaceholder(i):nc(i,e)}function om(i,e){return i.map(t=>an(t,e))}function nc(i,e){var s;let t=(s=i.layers)!=null?s:si.defaultTwoLayerData("phong").layers,r=cw(t),o;switch(r.category){case"basic":o=new Nt;break;case"lambert":{o=new rn;break}case"toon":{o=new on;break}case"physical":o=new nn;break;case"phong":default:{o=new or;break}}let n=o.userData.layers;dw(n);for(let a=t.length-1;a>=0;a--)pw(n,t[a],e);switch(r.category){case"basic":break;case"lambert":{let c=o,p=Ye(r.emissive,e);p instanceof ic?c.emissive.value=p:c.emissive.value.setHex(Si.getHex(p));break}case"toon":{let c=o,d=r;c.shininess.value=d.shininess;let p=Ye(d.specular,e);p instanceof ic?c.specular.value=p:c.specular.value.setHex(Si.getHex(p));break}case"physical":let a=o,l=r;a.metalness.value=l.metalness,a.roughness.value=l.roughness,a.reflectivity.value=l.reflectivity;break;case"phong":default:{let c=o,d=r;c.shininess.value=d.shininess;let p=Ye(d.specular,e);p instanceof ic?c.specular.value=p:c.specular.value.setHex(Si.getHex(p));break}}return n.blendColors(),n.blendAfterColors(),n.blendPositions(),o}function cw(i){for(let e of i)if(e.data.type==="light")return e.data;return{type:"light",category:"basic",visible:!0,alpha:1,mode:it.Normal}}function dw(i){for(let e of i.getLayers())i.removeLayer(e.id)}function pw(i,e,t){let r=Zh(e,t);r.type==="transmission"&&(r.transmissionSamplerMap=t==null?void 0:t.transmissionSamplerMap,r.transmissionDepthMap=t==null?void 0:t.transmissionDepthMap);let o=i.addLayer(r);o.uuid=e.id;for(let n in e.data)Yh(n,o,e.data)}import{Vector2 as im}from"three";var ga=new im,Po=class{constructor(e,t,r){this.message=[];this.endLine=!0;this.yLinePos=e,this.lineHeight=t,this.maxCharSize=r,this.nextChar3DPos=new im(0,this.yLinePos+this.maxCharSize*this.lineHeight),this.align=Tt.Left}addChar3D(e,t,r=this.message.length){this.message.splice(r,0,e),e.fontSize>this.maxCharSize?(this.maxCharSize=e.fontSize,this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight,this.fullUpdate(t)):(e.updatePosition(this.nextChar3DPos,t),this.nextChar3DPos.x+=e.charSize)}deleteChar3D(e=this.message.length-1){let t=this.message[e];if(t)return this.message.splice(e,1),this.nextChar3DPos.x-=t.charSize,t}isEndLine(e){this.endLine=e}fullUpdate(e,t=0){this.nextChar3DPos.x=0;for(let r=t,o=this.message.length;r<o;r+=1)this.message[r].updatePosition(this.nextChar3DPos,e),this.nextChar3DPos.x+=this.message[r].charSize}checkOverFlow(e){let t,r=this.message.length-1;if(r<=0)return!1;for(;r>=0;){if(this.message[r].char!==" "){t=this.message[r];break}r-=1}return!!(r>=0&&t&&t.localPosition.x+t.charSize>e)}containSpaceOverFlow(e=this.message.length-1){for(let t=e;t>=0;t-=1)if(this.message[t].char===" ")return!0;return!1}containSpace(e=this.message.length-1){if(this.endLine)return!0;for(let t=e;t>=0;t-=1)if(this.message[t].char===" ")return!0;return!1}popWord(e=this.message.length-1){let t=[],r=!0,o;for(o=e;o>=0;o-=1)if(this.message[o].char===" "){r=!1,t.length===0&&(o-=1,t.splice(0,0,this.message[o]));break}else t.splice(0,0,this.message[o]);return r?t=[]:this.message.splice(o+1,t.length),t}getWord(e=0,t=1){let r=[],o=e;for(o=e;;o+=t){if(!this.message[o]||this.message[o].char===" "){r.length===0&&this.message[o]&&(r.push(this.message[o]),this.message.splice(o,1));break}t>0?(r.push(this.message[o]),this.message.splice(o,1),o-=t):(r.splice(0,0,this.message[o]),this.message.splice(o,1))}return r}getWordAtIndex(e){let t=[];for(let r=e;r<this.message.length&&this.message[r].char!==" ";r++)t.push(this.message[r]);for(let r=e-1;r>=0&&this.message[r].char!==" ";r--)t.splice(0,0,this.message[r]);return t}wordSize(e=0,t=-1){let r=0,o=e;for(;o>=0&&o<this.message.length;){if(this.message[o].char===" "){r===0&&(r=this.message[o].charSize);break}r+=this.message[o].charSize,o+=t}return(o<0||o>=this.message.length)&&!this.endLine?this.message[e]?this.message[e].charSize:999999999:r===0?999999999:r}spaceLeft(e){return e-this.nextChar3DPos.x}popChar(e=this.message.length-1){return this.nextChar3DPos.x-=this.message[e].charSize,this.message.splice(e,1)}isEmpty(){return!this.message.length}updateNextCharPosY(){this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight}updateYLinePos(e){this.yLinePos=e,this.updateNextCharPosY()}updatelineHeight(e){this.lineHeight=e,this.updateNextCharPosY()}updateFontSize(e,t=0,r=this.message.length-1){for(let o=t;o<=r;o+=1)this.message[o].updateFontSize(e);this.maxCharSize=e,this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight}countSpaces(){let e=0;for(let t=0;t<this.message.length;t++)this.message[t].char===" "&&(e+=1);return e}alignText(e,t,r,o,n){switch(r){case Tt.Left:this.leftAlign(e,n);break;case Tt.Center:this.centerAlign(this.spaceLeft(t),e,n);break;case Tt.Right:this.rightAlign(this.spaceLeft(t),e,n);break;case Tt.Justify:this.justifyAlign(this.spaceLeft(t),e,n);break}}offsetCharacters(e,t,r){ga.set(t,r);let o=this.message.length;for(let n=0;n<o;n++)this.message[n].updatePosition(this.message[n].localPosition.add(ga),e)}leftAlign(e,t){this.align=Tt.Left,this.offsetCharacters(e,0,t)}centerAlign(e,t,r){this.align=Tt.Center,this.offsetCharacters(t,e/2,r)}rightAlign(e,t,r){this.align=Tt.Right,this.offsetCharacters(t,e,r)}justifyAlign(e,t,r){if(this.align=Tt.Justify,this.endLine){this.offsetCharacters(t,0,r);return}let o=this.countSpaces();if(o===0){this.offsetCharacters(t,0,r);return}let n=e/o,s=0;for(let a=0;a<this.message.length;a++)this.message[a].char===" "&&(s+=n),ga.set(s,r),this.message[a].updatePosition(this.message[a].localPosition.add(ga),t)}clone(){let e=new Po(this.yLinePos,this.lineHeight,this.maxCharSize);e.nextChar3DPos=this.nextChar3DPos.clone(),e.align=this.align,e.endLine=this.endLine;for(let t=0;t<this.message.length;t++)e.message.push(this.message[t].clone());return e}};import{DoubleSide as uw,EventDispatcher as hw,Matrix3 as mw,Vector3 as sc}from"three";var fw=new sc(0,0,1),nm=new sc,sm=new sc,am=new mw,Oo=class extends yt{constructor(e=mt.create({}),t=new Nt({side:uw})){super(e,t);this.recursiveSelection=!1;this.objectType="VectorObject";this.eventDispatcher=new hw;this._onShapeUpdate=()=>{if(this.geometry instanceof No){if(this.geometry.updateFromShape()){let e=this.geometry.drawCount,t=this.geometry.userData;this.updateGeometry(Object.assign(this.geometry.userData,{parameters:Object.assign(t.parameters,{surfaceMaxCount:e+1e3})}))}}else this.updateGeometry({});this.geometry.computeBoundingSphere(),this.geometry.computeBoundingBox()};var r;this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!0,this.shape=e.userData.shape,(r=this.shape.eventDispatcher)==null||r.addEventListener("update",this._onShapeUpdate)}toJSON(e){let t=super.toJSON(e);return t.object.objectType="VectorObject",t}fromState(e){return super.fromState(e),this.shape.update(),this}setHelperVisibility(){}updateGeometry(e){if(super.updateGeometry(e),"userData"in this.geometry){let t=this.geometry.userData.parameters;this.eventDispatcher.dispatchEvent({type:"geometryUpdate",parameters:t})}}setShape(e){var t,r;this.shape&&((t=this.shape.eventDispatcher)==null||t.removeEventListener("update",this._onShapeUpdate)),this.shape=e,(r=this.shape.eventDispatcher)==null||r.addEventListener("update",this._onShapeUpdate)}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),am.getNormalMatrix(this.matrixWorld),nm.copy(fw).applyMatrix3(am).normalize(),sm.setFromMatrixPosition(this.matrixWorld),this.shape.plane.setFromNormalAndCoplanarPoint(nm,sm)}clone(e){let t=this.shape.clone(),r=this.material.clone(),o=this.geometry.userData,n=mt.create(Object.assign({},o,{shape:t})),s=new Oo(n,r).copy(this,e);return s.shape=t,t.update(),s}raycast(e,t){yt.prototype.raycast.call(this,e,t)}};import{Camera as Ow,OrthographicCamera as Aw,PerspectiveCamera as jw,Vector3 as Wt,Object3D as pm,Quaternion as _w}from"three";import{BoxBufferGeometry as yw}from"three";var Nr=i=>{var e;return e=class extends i{constructor(){super(...arguments);this.isObjectHelper=!0}},e.geometryHelper=new yw(30,30,30),e};import{Camera as vw,LineSegments as Sw,BufferGeometry as ww,LineBasicMaterial as Nw,Color as lc,Vector3 as Cw,Float32BufferAttribute as cm}from"three";import{Ray as gw,Sphere as xw,Matrix4 as bw,Vector3 as Ur}from"three";var xa=new gw,ac=new xw,lm=new bw,Cr=(i,e,t,r,o=!1)=>{let n=e,s=i.matrixWorld;if(n.boundingSphere===null&&n.computeBoundingSphere(),ac.copy(n.boundingSphere),ac.applyMatrix4(s),t.ray.intersectsSphere(ac)===!1||(lm.copy(s).invert(),xa.copy(t.ray).applyMatrix4(lm),n.boundingBox!==null&&xa.intersectsBox(n.boundingBox)===!1))return;let a,l,c,d,p=n.index,u=n.attributes.position,f=n.drawRange,m,x;if(o===!1){let N=Math.max(0,f.start),L=Math.min(p.count,f.start+f.count);for(m=N,x=L;m<x;m+=3)if(l=p.getX(m),c=p.getX(m+1),d=p.getX(m+2),a=y(i,t,xa,u,l,c,d),a){a.faceIndex=Math.floor(m/3),r.push(a);return}}else{let L=n.attributes.position,w=new Ur,B=new Ur,S=new Ur,_=new Ur,T=2,I=1/((i.scale.x+i.scale.y+i.scale.z)/3),b=I*I,P=Math.max(0,f.start),v=Math.min(L.count,f.start+f.count);for(let D=P,Z=v-1;D<Z;D+=T){if(w.fromBufferAttribute(L,D),B.fromBufferAttribute(L,D+1),xa.distanceSqToSegment(w,B,_,S)>b)continue;_.applyMatrix4(i.matrixWorld);let ie=t.ray.origin.distanceTo(_);ie<t.near||ie>t.far||r.push({distance:ie,point:S.clone().applyMatrix4(i.matrixWorld),object:i})}}function y(N,L,w,B,S,_,T){let h=new Ur,I=new Ur,b=new Ur,P=new Ur,v=new Ur;if(h.fromBufferAttribute(B,S),I.fromBufferAttribute(B,_),b.fromBufferAttribute(B,T),w.intersectTriangle(h,I,b,!1,P)===null)return null;v.copy(P),v.applyMatrix4(N.matrixWorld);let Z=L.ray.origin.distanceTo(v);return Z<L.near||Z>L.far?null:{faceIndex:1,distance:Z,point:v.clone(),object:N}}};var ba=new Cw,ir=new vw,dm=class extends Sw{constructor(e){let t=new ww,r=new Nw({color:16777215,vertexColors:!0,toneMapped:!1}),o=[],n=[],s={},a=new lc(Ya),l=new lc(Ya),c=new lc(bu);d("n1","n2",a),d("n2","n4",a),d("n4","n3",a),d("n3","n1",a),d("f1","f2",a),d("f2","f4",a),d("f4","f3",a),d("f3","f1",a),d("n1","f1",a),d("n2","f2",a),d("n3","f3",a),d("n4","f4",a),d("p","n1",l),d("p","n2",l),d("p","n3",l),d("p","n4",l),d("u1","u2",c),d("u2","u3",c),d("u3","u1",c);function d(u,f,m){p(u,m),p(f,m)}function p(u,f){o.push(0,0,0),n.push(f.r,f.g,f.b),s[u]===void 0&&(s[u]=[]),s[u].push(o.length/3-1)}t.setAttribute("position",new cm(o,3)),t.setAttribute("color",new cm(n,3));super(t,r);this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=s,this.update()}update(){let e=this.geometry,t=this.pointMap,r=!0;ir.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let o=1,n=1,s=r?.8:1e-4;pr("n1",t,e,ir,-o,-n,s),pr("n2",t,e,ir,o,-n,s),pr("n3",t,e,ir,-o,n,s),pr("n4",t,e,ir,o,n,s);let a=s;pr("f1",t,e,ir,-o,-n,a),pr("f2",t,e,ir,o,-n,a),pr("f3",t,e,ir,-o,n,a),pr("f4",t,e,ir,o,n,a);let l=a,c=.5;pr("u1",t,e,ir,o*.7*c,n*1.1,l),pr("u2",t,e,ir,-o*.7*c,n*1.1,l),pr("u3",t,e,ir,0,n*(1.1+.9*c),l),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function pr(i,e,t,r,o,n,s){ba.set(o,n,s).unproject(r);let a=e[i];if(a!==void 0){let l=t.getAttribute("position");for(let c=0,d=a.length;c<d;c++)l.setXYZ(a[c],ba.x,ba.y,ba.z)}}var cc=class extends Nr(dm){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){Cr(this.object,this.geometry,e,t,!0)}};import{DirectionalLightHelper as Lw}from"three";var ln=class extends Nr(Lw){constructor(e,t=15,r=10066329){super(e,t,r);this.object=e;this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,t){Cr(this.object,ln.geometryHelper,e,t)}};import{AxesHelper as Tw}from"three";var cn=class extends Nr(Tw){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){Cr(this.object,cn.geometryHelper,e,t)}update(){}};import{PointLightHelper as Iw}from"three";var dn=class extends Nr(Iw){constructor(e,t=15,r=6710886){super(e,t,r);this.object=e;this.name=`PointLightHelper: ${e.uuid}`}raycast(e,t){Cr(this.object,dn.geometryHelper,e,t)}};import{SpotLightHelper as Mw,Vector3 as Pw}from"three";var Sa=class extends Nr(Mw){constructor(e,t=6710886){super(e,t);this.object=e;this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,t){Cr(this.object,Sa.geometryHelper,e,t)}update(){if(this.object!==void 0){let e=Sa._vector,t=this.object.distance?this.object.distance:1e3,r=t*Math.tan(this.object.angle);this.cone.scale.set(r,r,t),e.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(e);let o=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let n=0,s=this.cone.material.length;n<s;n++)this.cone.material[n].color.set(o);else this.cone.material.color.set(o)}}},va=Sa;va._vector=new Pw;var Lr=(i,e)=>class extends i{constructor(){super(...arguments);this.objectHelper=new e(this);this.enableHelper=!1}set visibility(r){this.visible=r,this.setHelperVisibility(r),this.setHelperChildrenVisibility(r)}get visibility(){return this.visible}get geometryHelper(){return e.geometryHelper}setHelperVisibility(r){this.objectHelper.visible=r}setHelperChildrenVisibility(r){for(let o of this.children)er(o)&&o.traverseEntity(n=>{Er(n)&&n.visible&&(n.objectHelper.visible=r)})}raycast(r,o){this.objectHelper.raycast(r,o)}copy(r,o=!0){return super.copy(r,o),r.enableHelper!==void 0&&(this.enableHelper=r.enableHelper),r.objectHelper!==void 0&&(this.objectHelper.visible=r.objectHelper.visible),this}toJSON(r){let o=super.toJSON(r),n=o.object;return n.enableHelper=this.enableHelper,o}fromJSON(r){return super.fromJSON(r),r.enableHelper!==void 0&&(this.enableHelper=!0),this}fromLightState(r,o){if(this.objectType==="LightDirectional"||this.objectType==="LightPoint"||this.objectType==="LightSpot"){let n=this;r.color!==void 0&&(n.color=Ye(r.color,o)),r.intensity!==void 0&&(n.intensity=r.intensity),r.depth!==void 0&&(n.shadow.camera.far=r.depth,n.shadow.needsUpdate=!0),r.shadows!==void 0&&(this.castShadow=r.shadows),r.helper!==void 0&&(this.enableHelper=r.helper,n.gizmos.shadowmap.visible=r.helper)}return this}};var wi=new Wt,dc=new Wt,lo=class extends Lr(tr(Ow),cc){constructor(e=window.innerWidth,t=window.innerHeight,r=45,o,n=1e5){super();this.objectType="CombinedCamera";this._cameraType="OrthographicCamera";this.targetOffset=xo.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.width=e,this.height=t,this.orthoCamera=new Aw(e*-.5,e*.5,t*.5,t*-.5,o!=null?o:-5e4,n),this.perspCamera=new jw(r,e/t,o!=null?o:50,n),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.fov=this.perspCamera.fov,this.focus=this.perspCamera.focus,this.filmGauge=this.perspCamera.filmGauge,this.filmOffset=this.perspCamera.filmOffset,this.toOrthographic(!0)}static createFromState(e,t){let r=new lo().fromState(t);return r.enableHelper=!0,r.objectHelper.update(),r.uuid=e,r}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}setNear(e,t){e==="PerspectiveCamera"?this.perspCamera.near=t:this.orthoCamera.near=t}setZoom(e,t){t>=0&&(e==="PerspectiveCamera"?this.perspCamera.zoom=t:this.orthoCamera.zoom=t)}set cameraType(e){e==="PerspectiveCamera"?this.toPerspective():e==="OrthographicCamera"&&this.toOrthographic()}get near(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.near:this.orthoCamera.near}set near(e){this._cameraType==="PerspectiveCamera"?this.perspCamera.near=e:this.orthoCamera.near=e}get zoom(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(e){e>=0&&(this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom=e:this.orthoCamera.zoom=e)}lookAt(e){super.lookAt(e),this.getWorldPosition(wi),this.targetOffset=wi.distanceTo(e)}getTarget(e=new Wt){return this.getWorldDirection(dc),this.getWorldPosition(wi),dc.multiplyScalar(this.targetOffset),e.copy(wi).add(dc),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(wi),wi.distanceTo(e)}updateUp(){let e=this.getWorldQuaternion(new _w),t=new Wt(0,0,1).applyQuaternion(e),r=new Wt().copy(pm.DefaultUp);this.isUpVectorFlipped&&r.negate(),r.applyQuaternion(e);let o=new Wt().copy(pm.DefaultUp).projectOnPlane(t),n=new Wt().crossVectors(o,r).dot(t)>=0?1:-1;this.angleOffsetFromUp=o.angleTo(r)*n}getViewFrontToObject(e){let t=e.getWorldPosition(new Wt),o=e.getWorldDirection(new Wt).multiplyScalar(this.targetOffset);return{position:t.clone().add(o),target:t}}getViewToObject(e){let t=e.getWorldPosition(new Wt),o=this.getWorldDirection(new Wt).multiplyScalar(this.targetOffset);return{position:t.clone().sub(o),target:t}}setViewplaneSize(e,t){this.left=-e*.5,this.right=e*.5,this.top=t*.5,this.bottom=-t*.5,this.aspect=e/t,this.updateProjectionMatrix()}toOrthographic(e){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.enableHelper===!0||e===!0)&&this.objectHelper.update()}toPerspective(e){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.enableHelper===!0||e===!0)&&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,r,o,n,s){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(e,t,r,o,n,s):this.orthoCamera.setViewOffset(e,t,r,o,n,s)}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}updateProjectionMatrix(e){this._cameraType==="PerspectiveCamera"?this.toPerspective(e):this._cameraType==="OrthographicCamera"&&this.toOrthographic(e)}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(e,t){return super.copy(e,t),this.orthoCamera.copy(e.orthoCamera),this.perspCamera.copy(e.perspCamera),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.far=e.far,this.view=e.view===null?null:Object.assign({},e.view),this._cameraType=e._cameraType,this.aspect=e.aspect,this.fov=e.fov,this.focus=e.focus,this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this.targetOffset=e.targetOffset,this.updateProjectionMatrix(),this}fromCameraRender(e){let t={near:this.orthoCamera.near,far:this.orthoCamera.far},r={near:this.perspCamera.near,far:this.perspCamera.far};return this.copy(e),this.name="",this.enableHelper=!0,this.objectHelper.visible=!0,this.orthoCamera.near=t.near,this.orthoCamera.far=t.far,this.perspCamera.near=r.near,this.perspCamera.far=r.far,this.updateProjectionMatrix(),this}toJSON(e){let t=super.toJSON(e),r=t.object;return r.objectType="CombinedCamera",r.cameraType=this.cameraType,r.targetOffset=this.targetOffset,r.isUpVectorFlipped=this.isUpVectorFlipped,r.angleOffsetFromUp=this.angleOffsetFromUp,r.left=this.left,r.right=this.right,r.top=this.top,r.bottom=this.bottom,this.view!==null&&(r.view=Object.assign({},this.view)),r.zoomOrtho=this.orthoCamera.zoom,r.nearOrtho=this.orthoCamera.near,r.far=this.far,r.aspect=this.aspect,r.fov=this.fov,r.focus=this.focus,r.filmGauge=this.filmGauge,r.filmOffset=this.filmOffset,r.zoomPersp=this.perspCamera.zoom,r.nearPersp=this.perspCamera.near,t}fromJSON(e){var t;if(super.fromJSON(e),this.cameraType=e.cameraType,e.targetOffset!==void 0&&(this.targetOffset=e.targetOffset),e.orbitControlsTarget!==void 0){let r=this.getWorldPosition(new Wt),o=new Wt().fromArray(e.orbitControlsTarget);this.targetOffset=o.distanceTo(r)}else e.targetOffset!==void 0&&(this.targetOffset=e.targetOffset);return this.isUpVectorFlipped=!1,this.angleOffsetFromUp=(t=e.angleOffsetFromUp)!=null?t:0,e.left!==void 0&&(this.left=e.left),e.right!==void 0&&(this.right=e.right),e.top!==void 0&&(this.top=e.top),e.bottom!==void 0&&(this.bottom=e.bottom),e.view!==void 0&&(this.view=Object.assign({},e.view)),e.zoomOrtho!==void 0&&(this.orthoCamera.zoom=e.zoomOrtho),e.nearOrtho!==void 0&&(this.orthoCamera.near=e.nearOrtho),e.far!==void 0&&(this.far=e.far),e.aspect!==void 0&&(this.aspect=e.aspect),e.fov!==void 0&&(this.fov=e.fov),e.focus!==void 0&&(this.focus=e.focus),e.filmGauge!==void 0&&(this.filmGauge=e.filmGauge),e.filmOffset!==void 0&&(this.filmOffset=e.filmOffset),e.zoomPersp!==void 0&&(this.perspCamera.zoom=e.zoomPersp),e.nearPersp!==void 0&&(this.perspCamera.near=e.nearPersp),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 Zo(t,e)}fromCameraState(e){let{orthographic:t,perspective:r}=e;return e.type!==void 0&&(this.cameraType=e.type),e.far!==void 0&&(this.far=e.far),t!==void 0&&(t.near!==void 0&&(this.orthoCamera.near=t.near),t.zoom!==void 0&&(this.orthoCamera.zoom=t.zoom)),r!==void 0&&(r.near!==void 0&&(this.perspCamera.near=r.near),r.fov!==void 0&&(this.perspCamera.fov=r.fov),r.zoom!==void 0&&(this.perspCamera.zoom=r.zoom)),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(),this}toState(e){return $(O(O({},super.toState(e)),this.toCameraState(e)),{type:this.cameraType})}fromState(e){return super.fromState(e),this.fromCameraState(e),this}};import{Group as Dw}from"three";var co=class extends Lr(tr(Dw),cn){constructor(){super(...arguments);this.objectType="EmptyObject"}static createFromState(e,t){let r=new co().fromState(t);return r.uuid=e,r.enableHelper=!0,r.objectHelper.update(),r}toJSON(e){let t=super.toJSON(e);return t.object.objectType="EmptyObject",t}};import{DirectionalLight as Bw,CameraHelper as wa}from"three";var pn=class extends Lr(tr(Bw),ln){constructor(...e){super(...e);this.objectType="LightDirectional";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024;let r=this.shadow.camera;r.top=1250,r.bottom=-1250,r.right=1250,r.left=-1250,r.near=1,r.far=2500;let o=new wa(this.shadow.camera);o.visible=!1,this._gizmos.shadowmap=o,this.update()}static createFromState(e,t,r){let o=new pn().fromState(t,r);return o.uuid=e,o}get gizmos(){return this._gizmos}showGizmos(){for(let e in this._gizmos){let t=this._gizmos[e];t instanceof wa&&(t.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let t=this._gizmos[e];t instanceof wa&&(t.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this._gizmos){let t=this._gizmos[e];t instanceof wa&&t.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}copy(e,t=!0){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e),r=t.object;return r.objectType="LightDirectional",r.color=this.color.getHex(),r.intensity=this.intensity,r.shadow=this.shadow.toJSON(),t}fromJSON(e){var o;super.fromJSON(e),this.color.set(e.color),this.intensity=e.intensity,this.shadow.normalBias=(o=e.shadow.normalBias)!=null?o:0,this.shadow.radius=e.shadow.radius,this.shadow.mapSize.fromArray(e.shadow.mapSize);let t=this.shadow.camera,r=e.shadow.camera;return t.near=r.near,t.far=r.far,t.zoom=r.zoom,t.left=r.left,t.right=r.right,t.top=r.top,t.bottom=r.bottom,r.view!==void 0&&(t.view=Object.assign({},r.view)),this}fromDirectionalLightState(e,t){let r=e.depth!==void 0&&e.depth!==this.shadow.camera.far||e.size!==void 0&&e.size/2!==this.shadow.camera.right;return super.fromLightState(e,t),e.size!==void 0&&Nh(this,e.size),r&&this.update(),this}fromState(e,t){return super.fromState(e),this.fromDirectionalLightState(e,t),this}};import{PointLight as Gw,Vector3 as Na,Box3 as zw,Box3Helper as Ca,Color as Ew}from"three";var un=class extends Lr(tr(Gw),dn){constructor(...e){super(...e);this.objectType="LightPoint";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024;let r=this.shadow.camera;r.fov=90,r.aspect=1,r.near=100,r.far=2500;let o=new Na(-r.far+this.position.x,-r.far+this.position.y,-r.far+this.position.z),n=new Na(r.far+this.position.x,r.far+this.position.y,r.far+this.position.z),s=new zw(o,n),a=new Ca(s,new Ew(16755200));a.visible=!1,this._gizmos.shadowmap=a,this.update()}static createFromState(e,t,r){let o=new un().fromState(t,r);return o.uuid=e,o}get gizmos(){return this._gizmos}showGizmos(){for(let e in this._gizmos){let t=this._gizmos[e];t instanceof Ca&&(t.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let t=this._gizmos[e];t instanceof Ca&&(t.visible=!1)}}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this._gizmos))for(let e in this._gizmos){let t=this._gizmos[e];if(t instanceof Ca){let r=this.shadow.camera,o=new Na(-r.far+this.position.x,-r.far+this.position.y,-r.far+this.position.z),n=new Na(r.far+this.position.x,r.far+this.position.y,r.far+this.position.z);t.box.set(o,n),t.updateMatrixWorld(!0)}}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}copy(e,t=!0){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e),r=t.object;return r.objectType="LightPoint",r.color=this.color.getHex(),r.intensity=this.intensity,r.distance=this.distance,r.decay=this.decay,r.shadow=this.shadow.toJSON(),t}fromJSON(e){var o,n;super.fromJSON(e),this.color.set(e.color),this.intensity=e.intensity,this.distance=e.distance,this.decay=e.decay,this.shadow.normalBias=(o=e.shadow.normalBias)!=null?o:0,this.shadow.radius=e.shadow.radius,this.shadow.mapSize.fromArray((n=e.shadow.mapSize)!=null?n:[512,512]),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null);let t=this.shadow.camera,r=e.shadow.camera;return t.near=r.near,t.far=r.far,t.zoom=r.zoom,t.fov=r.fov,t.focus=r.focus,t.aspect=r.aspect,t.filmGauge=r.filmGauge,t.filmOffset=r.filmOffset,r.view!==void 0&&(t.view=Object.assign({},r.view)),this}fromPointLightState(e,t){return super.fromLightState(e,t),e.distance!==void 0&&(this.distance=e.distance),e.decay!==void 0&&(this.decay=e.decay),e.shadowRadius!==void 0&&(this.shadow.radius=e.shadowRadius),e.shadowResolution!==void 0&&(this.shadow.mapSize.set(e.shadowResolution,e.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),this}fromState(e,t){return super.fromState(e),this.fromPointLightState(e,t),this}};import{SpotLight as Fw,CameraHelper as La,MathUtils as Rw,Vector3 as um,Quaternion as Vw}from"three";var hm=new um,mm=new um,fm=new Vw,hn=class extends Lr(tr(Fw),va){constructor(...e){super(...e);this.objectType="LightSpot";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024;let r=this.shadow.camera;r.fov=Rw.RAD2DEG*2*this.angle,r.aspect=1,r.near=100,r.far=2500;let o=new La(this.shadow.camera);o.visible=!1,this._gizmos.shadowmap=o,this.update()}static createFromState(e,t,r){let o=new hn().fromState(t,r);return o.uuid=e,o}get gizmos(){return this._gizmos}showGizmos(){for(let e in this._gizmos){let t=this._gizmos[e];t instanceof La&&(t.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let t=this._gizmos[e];t instanceof La&&(t.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this._gizmos){let t=this._gizmos[e];t instanceof La&&t.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),mm.setFromMatrixPosition(this.matrixWorld),fm.setFromRotationMatrix(this.matrixWorld),hm.copy(this.up).applyQuaternion(fm).negate().multiplyScalar(this.distance),this.target.position.copy(mm).add(hm),this.target.updateMatrixWorld(),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}copy(e,t=!0){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e),r=t.object;return r.objectType="LightSpot",r.color=this.color.getHex(),r.intensity=this.intensity,r.distance=this.distance,r.angle=this.angle,r.decay=this.decay,r.penumbra=this.penumbra,r.shadow=this.shadow.toJSON(),t}fromJSON(e){var o;super.fromJSON(e),this.color.set(e.color),this.intensity=e.intensity,this.distance=e.distance,this.angle=e.angle,this.decay=e.decay,this.penumbra=e.penumbra,this.shadow.normalBias=(o=e.shadow.normalBias)!=null?o:0,this.shadow.radius=e.shadow.radius,this.shadow.mapSize.fromArray(e.shadow.mapSize);let t=this.shadow.camera,r=e.shadow.camera;return t.near=r.near,t.far=r.far,t.zoom=r.zoom,t.fov=r.fov,t.focus=r.focus,t.aspect=r.aspect,t.filmGauge=r.filmGauge,t.filmOffset=r.filmOffset,r.view!==void 0&&(t.view=Object.assign({},r.view)),this}fromSpotLightState(e,t){return super.fromLightState(e,t),e.distance!==void 0&&(this.distance=e.distance),e.decay!==void 0&&(this.decay=e.decay),e.angle!==void 0&&(this.angle=e.angle),e.penumbra!==void 0&&(this.penumbra=e.penumbra),this}fromState(e,t){return super.fromState(e),this.fromSpotLightState(e,t),this}};import{VideoTexture as Uw}from"three";var ym=i=>i.tagName==="VIDEO",Ni=class{static resize(e,t,r){let o=e/t,n;if(!r.image)return;let s=r.image;ym(s)?n=s.videoWidth/s.videoHeight:n=s.width/s.height,o>n&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1*n/o):r.repeat.set(1,1*n/o)),o<n&&(r.imageType=="WEBCAM"?r.repeat.set(1*o/n*-1,1):r.repeat.set(1*o/n,1)),o==n&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1):r.repeat.set(1,1))}static resizeTextureLayer(e,t,r){let o=e/t,n=r.image!==void 0?r.image.width/r.image.height:1,s;o>n?s={x:1,y:n/o}:o<n?s={x:o/n,y:1}:s={x:1,y:1},r.repeat.set(s.x,s.y),r.updateMatrix()}static resizeTextureLayers(e,t,r){let o=r.userData.layers,n=o.getLayers();for(let s=0;s<n.length;s++){let a=n[s];Hh(a)&&(Ni.resizeTextureLayer(e,t,a.uniforms[`f${a.id}_texture`].value),o.updateLayerUniform())}}static resizeComplex(e,t,r,o){let n=e/t,s,a=r.image;ym(a)?s=a.videoWidth/a.videoHeight:s=a.width/a.height,o.geometry.type.includes("Shape")?(n>s&&(r.imageType=="WEBCAM"?r.repeat.set(1/e*-1,1/t*s/n):r.repeat.set(1/e,1/t*s/n)),n<s&&(r.imageType=="WEBCAM"?r.repeat.set(1/e*n/s*-1,1/t):r.repeat.set(1/e*n/s,1/t)),n==s&&(r.imageType=="WEBCAM"?r.repeat.set(1/e*-1,1/t):r.repeat.set(1/e,1/t))):(n>s&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1*s/n):r.repeat.set(1,1*s/n)),n<s&&(r.imageType=="WEBCAM"?r.repeat.set(1*n/s*-1,1):r.repeat.set(1*n/s,1)),n==s&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1):r.repeat.set(1,1)))}};var mn=class extends yt{constructor(e,t=new Nt){super(e,t);this.objectType="Mesh2D";this.castShadow=!0,this.receiveShadow=!0}updateGeometry(e){super.updateGeometry(e),this.material.userData.layers&&Ni.resizeTextureLayers(this.geometry.userData.parameters.width,this.geometry.userData.parameters.height,this.material)}resizeGeometry(e,t){super.resizeGeometry(e,t,0),this.material.userData.layers&&Ni.resizeTextureLayers(this.geometry.userData.parameters.width,this.geometry.userData.parameters.height,this.material)}toJSON(e){let t=super.toJSON(e);return t.object.objectType="Mesh2D",t}clone(){let e=super.clone();return e.updateGeometry({}),e}static fromTexture(e){let t,r;if(e instanceof Uw){let s=e.image;t=s.videoWidth*.5,r=s.videoHeight*.5}else{let s=e.image;t=s.width*.5,r=s.height*.5}let o=Ws.create({parameters:{width:t,height:r}}),n=new Nt;return n.layersList.changeLayer(0,{type:Le.TEXTURE,texture:e}),n.layersList.moveLayer(0,1),n.dispose(),new mn(o,n)}};var fn=class extends yt{constructor(e,t=new or){super(e,t);this.objectType="Mesh3D";this.castShadow=!0,this.receiveShadow=!0}toJSON(e){let t=super.toJSON(e);return t.object.objectType="Mesh3D",t}};var yn=class extends fn{constructor(e,t=new or){super(e,t);this.objectType="NonParametric"}toJSON(e){let t=super.toJSON(e);return t.object.objectType="NonParametric",t}};var gn;(function(t){t[t.TO_RIGHT=1]="TO_RIGHT",t[t.TO_LEFT=-1]="TO_LEFT"})(gn||(gn={}));var pc=class extends yt{constructor(e,t=new Nt({transparent:!0,opacity:1,visible:!1,side:Ta})){super(e,t);this.objectType="TextFrame";this.charContainer=new kw,this.add(this.charContainer),this.material.visible=!1,this._geometryUserData=e.userData,this.userData.textFrame={hexColor:null,opacity:1,visible:!0,text:"",fontSize:16,lineHeight:1.5,letterSpacing:1,fontFamily:"roboto_regular",textTransform:eo.None,horizontalAlignment:1,verticalAlignment:Br.Top,LOD:16,maxLineSize:this._geometryUserData.parameters.width,textOrigin:new xm(this._geometryUserData.parameters.width*-.5,this._geometryUserData.parameters.height*.5,0),textLines:[]},this.createTextLine()}static createFromState(e,t,r){let o=$s.create({parameters:{width:t.width,height:t.height}}),n=new pc(o).fromState(t,r);return n.uuid=e,n}async updateText(e){this.clearText();let t=this.userData.textFrame,r=t.fontFamily;await _t.loadFont(r),t.text=e;let o=t.textOrigin,n=new gm({visible:t.visible,transparent:!0,side:Ta}),s=e.split(`
|
|
958
|
-
`),a=0;this.userData.textFrame.textLines=s.map((l,c)=>{let d=new Po(a,t.lineHeight,t.fontSize);return d.message=l.split("").map(p=>{let u={char:p,fontFamily:r,letterSpacing:t.letterSpacing,fontSize:t.fontSize,LOD:16},f=n.clone();f.color=t.hexColor,f.opacity=t.opacity;let m=new _t(u,f);return d.addChar3D(m,o),this.charContainer.add(m),m}),a+=d.maxCharSize*d.lineHeight,d}),this.textFullUpdate(),this.checkOverFlow()}clearText(){let e=this.userData.textFrame.textLines;for(;this.charContainer.children.length;){let t=this.charContainer.children[0];this.charContainer.remove(t)}for(;e.length;)e.pop()}raycast(e,t){let r=[];if(super.raycast(e,r),r.length>0){t.push(r[0]);return}let o=[];for(let n=0,s=this.charContainer.children.length;n<s;++n)if(this.charContainer.children[n]instanceof _t&&(e.intersectObject(this.charContainer.children[n],!1,o),o.length>0)){o[0].object=this,t.push(o[0]);return}}updateGeometry(e){var c,d,p,u;let t=this.userData,r=this.geometry.userData,o=r.parameters.width,n=r.parameters.height,s=(d=(c=e.parameters)==null?void 0:c.width)!=null?d:o,a=(u=(p=e.parameters)==null?void 0:p.height)!=null?u:n,l=t.textFrame;super.updateGeometry(e),l.maxLineSize=s,l.textOrigin.set(-.5*s,.5*a,0),a!==n?(this.checkOverFlow(),this.checkCapacity()):s!==o&&(o<s?this.checkCapacity():o>s&&this.checkOverFlow())}checkOverFlow(e=0){let t=this.userData,r=t.textFrame.textOrigin,o=t.textFrame.textLines;for(let n=e;n<o.length;n++){o[n].updateYLinePos(this.getNewLinePosition(n)),o[n].fullUpdate(r);let s=[];for(;o[n].checkOverFlow(t.textFrame.maxLineSize);)o[n].containSpaceOverFlow()?s.unshift(o[n].getWord(o[n].message.length-1,-1)):s.unshift(o[n].popChar());if(s.length>0){o[n+1]===void 0?(o[n].isEndLine(!1),this.createTextLine()):o[n].endLine&&(this.createTextLine(n+1),o[n].isEndLine(!1),o[n+1].isEndLine(!0));let a=0;for(let l=0;l<s.length;l+=1)for(let c=0;c<s[l].length;c+=1)o[n+1].addChar3D(s[l][c],r,a),a+=1;o[n+1].fullUpdate(r)}o[n].fullUpdate(r)}this.textFullUpdate(e)}checkCapacity(e=0){let t=this.userData,r=t.textFrame.textOrigin,o=t.textFrame.maxLineSize,n=t.textFrame.textLines;for(let s=e;s<n.length;s+=1)if(n[s].updateYLinePos(this.getNewLinePosition(s)),n[s].fullUpdate(r),!!n[s-1])for(;!n[s-1].endLine;){let a,l=n[s-1].spaceLeft(o);if(n[s].wordSize(0,1)<=l){n[s].containSpace()?a=n[s].getWord(0,1):a=n[s].popChar(0);for(let c=0;c<a.length;c+=1)a[c]&&n[s-1].addChar3D(a[c],r)}else{n[s].isEmpty()?(n[s].endLine&&n[s-1].isEndLine(!0),n.splice(s,1),s-=1):(n[s].updateYLinePos(this.getNewLinePosition(s)),n[s].fullUpdate(r));break}}this.textFullUpdate(e)}createTextLine(e=this.userData.textFrame.textLines.length){let r=this.userData.textFrame;r.textLines.splice(e,0,new Po(this.getNewLinePosition(e),r.lineHeight,r.fontSize))}textFullUpdate(e=0){let r=this.userData.textFrame,o=r.textLines,n=this.getVerticalAlignmentOffSet();for(let s=e;s<o.length;s++)o[s].updateYLinePos(this.getNewLinePosition(s)),o[s].fullUpdate(r.textOrigin),o[s].alignText(r.textOrigin,r.maxLineSize,r.horizontalAlignment,r.verticalAlignment,n)}getVerticalAlignmentOffSet(){switch(this.userData.textFrame.verticalAlignment){case Br.Top:return 0;case Br.Center:return this.getRemainingVerticalSpace()/2;case Br.Bottom:return this.getRemainingVerticalSpace();default:return 0}}getRemainingVerticalSpace(){let t=this.userData.textFrame.textLines;return this.geometry.userData.parameters.height-this.getNewLinePosition(t.length)}getNewLinePosition(e){let r=this.userData.textFrame.textLines,o=0;for(let n=0;n<e;n+=1)o+=r[n].maxCharSize*r[n].lineHeight;return o}updateColor(e){var o;let t=this.userData;t.textFrame.hexColor=e;let r=t.textFrame.textLines;for(let n=0;n<r.length;n++){let s=r[n].message;for(let a=0;a<s.length;a++){let l=s[a].material;((o=l.color)==null?void 0:o.isColor)&&(l.color=e)}}}updateOpacity(e){let t=this.userData;t.textFrame.opacity=e;let r=t.textFrame.textLines;for(let o=0;o<r.length;o++){let n=r[o].message;for(let s=0;s<n.length;s++){let a=n[s].material;a.opacity=e}}}updateVisible(e){let t=this.userData;t.textFrame.visible=e;let r=t.textFrame.textLines;for(let o=0;o<r.length;o++){let n=r[o].message;for(let s=0;s<n.length;s++){let a=n[s].material;a.visible=e}}}async updateFontFamily(e){await _t.loadFont(e);let r=this.userData.textFrame,o=r.textLines;r.fontFamily=e;for(let n=0;n<o.length;n++){let s=o[n].message;for(let a=0;a<s.length;a++)s[a].updateFontFamily(e)}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateFontSize(e){let r=this.userData.textFrame,o=r.textLines,n=r.fontSize;r.fontSize=e;for(let s=0;s<o.length;s++)o[s].updateFontSize(e);this.textFullUpdate(),e>n?this.checkOverFlow():e<n&&this.checkCapacity()}async updateTextTransform(e){let r=this.userData.textFrame;await _t.loadFont(r.fontFamily);let o=r.textLines;switch(r.textTransform=e,e){case eo.Upper:for(let n=0;n<o.length;n++){let s=o[n].message;for(let a=0;a<s.length;a++)o[n].message[a].updateChar(s[a].char.toUpperCase())}break;case eo.Lower:for(let n=0;n<o.length;n++){let s=o[n].message;for(let a=0;a<s.length;a++)o[n].message[a].updateChar(s[a].char.toLowerCase())}break;default:for(let n=0;n<o.length;n++){let s=o[n].message;for(let a=0;a<s.length;a++)o[n].message[a].updateChar(s[a].originalChar)}}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLetterSpacing(e){let t=this.userData,r=t.textFrame.textLines;t.textFrame.letterSpacing=e;for(let o=0;o<r.length;o++){let n=r[o].message;for(let s=0;s<n.length;s++)n[s].updateLetterSpacing(e)}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLOD(e){let t=this.userData;t.textFrame.LOD=e;let r=t.textFrame.textLines;for(let o=0;o<r.length;o++);this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLineHeight(e){let t=this.userData,r=t.textFrame.textLines;t.textFrame.lineHeight=e;for(let o=0;o<r.length;o++)r[o].updatelineHeight(e);this.textFullUpdate()}updateVerticalAlignment(e){let t=this.userData;t.textFrame.verticalAlignment=e,this.textFullUpdate()}updateHorizontalAlignment(e){let t=this.userData;t.textFrame.horizontalAlignment=e,this.textFullUpdate()}toJSON(e){let t=super.toJSON(e),r=t.object;r.objectType="TextFrame";let n=this.userData.textFrame.textLines.map(s=>{let a=s.message.map(l=>({char:l.char,originalChar:l.originalChar,fontFamily:l.fontFamily,letterSpacing:l.letterSpacing,fontSize:l.fontSize,LOD:l.LOD}));return{align:s.align,endLine:s.endLine,lineHeight:s.lineHeight,maxCharSize:s.maxCharSize,yLinePos:s.yLinePos,message:a}});return r.userData.textFrame.textLinesData=n,t}async fromJSONasync(e){if(super.fromJSON(e),e.userData!==void 0){let t=e.userData.textFrame;await _t.loadFont(t.fontFamily),t.textOrigin=new xm(t.textOrigin.x,t.textOrigin.y,t.textOrigin.z);let r=new gm({color:t.hexColor,opacity:t.opacity,visible:t.visible,transparent:!0,side:Ta});t.textLinesData&&(t.textLines=t.textLinesData.map((o,n)=>{let s=new Po(Number(o.yLinePos),Number(o.lineHeight),Number(o.maxCharSize)),a=o.message.map((l,c)=>{if(l.char===void 0){let u=t.textLines[n].message[c];if("geometries"in u){let f=u.geometries[0].userData.parameters;Object.assign(l,{LOD:f.lod,char:f.char,fontFamily:f.fontFamily,fontSize:f.fontSize,letterSpacing:f.letterSpacing,originalChar:f.char})}}let d={char:l.char,fontFamily:l.fontFamily,letterSpacing:Number(l.letterSpacing),fontSize:Number(l.fontSize),LOD:l.LOD},p=new _t(d,r.clone());return s.addChar3D(p,t.textOrigin),this.charContainer.add(p),p});return s.message=a,s}),this.userData.textFrame=t),this.textFullUpdate()}return this}fromTextFrameData(e,t){if(e.color!==void 0){let r=Ye(e.color,t);this.updateColor(r),this.updateOpacity(r.a)}e.alpha!==void 0&&this.updateOpacity(e.alpha),e.font!==void 0&&this.updateFontFamily(e.font),e.horizontalAlign!==void 0&&this.updateHorizontalAlignment(e.horizontalAlign),e.verticalAlign!==void 0&&this.updateVerticalAlignment(e.verticalAlign),e.textTransform!==void 0&&this.updateTextTransform(e.textTransform),e.fontSize!==void 0&&this.updateFontSize(e.fontSize),e.lineHeight!==void 0&&this.updateLineHeight(e.lineHeight),e.letterSpacing!==void 0&&this.updateLetterSpacing(e.letterSpacing),e.text!==void 0&&e.text!==""&&this.updateText(e.text),(e.width!==void 0||e.height!==void 0)&&this.updateGeometry({parameters:{width:e.width,height:e.height}})}fromState(e,t){return super.fromState(e),this.fromTextFrameData(e,t),this}convertToVector(){let{fontFamily:e,hexColor:t}=this.userData.textFrame,r=new co;r.name="Text Shape";let o=_t.fontCache[e];for(let n of this.charContainer.children)n instanceof _t&&o.generateShapes(n.char,1).forEach(s=>{let a=new Pe().fromShape(s);a.applyScale(n.scale.x,n.scale.y);let l=mt.create({shape:a}),c=new Nt({side:Ta});c.color=t;let d=new Oo(l,c);d.name=n.char,d.position.copy(n.position),d.rotation.copy(n.rotation),r.attach(d)});return r}},Ci=pc;Ci.VerticalAlign=Br,Ci.HorizontalAlign=Tt,Ci.TextTransform=eo;import{HemisphereLight as i1,Scene as n1,Vector3 as s1,Color as jm,Fog as a1,Box3 as l1}from"three";import{BufferGeometryLoader as Hw}from"three";function bm(i,e){return qw(i)}function qw(i){let e={parameters:i,type:i.type};if(i.type==="VectorGeometry"){let r=Pe.createFromState(i.shape,i.width,i.height);e.shape=r}else i.type==="NonParametricGeometry"&&(i.data.groups&&i.data.groups.forEach(r=>{var o;return r.materialIndex=Math.max((o=r.materialIndex)!=null?o:0,0)}),e.geometry=new Hw().parse(i));let t;try{t=Ji(e)}catch(r){console.error(r)}if(!t){let r=Pe.createFromState(ai.defaultData(),100,100);e.shape=r,t=Ji(e)}return t}import{Box3 as Ww,Matrix4 as Ao,Sphere as wm,Vector3 as $w}from"three";var Nm=wc(Sm());var uc;Js.then(i=>{uc=i});var Cm=new Ao,Jw=new Ao,Kw=new Ao,ur=new Ww,po=new $w,Xw=new Ao,Zw=new Ao,xn=class extends yt{constructor(e,t,r,o=new or){super(r!=null?r:t,o);this.subdivPointer=e;this.originalGeometry=t;this.subdividedGeometry=r;this.objectType="SubdivObject";this.hiddenMatrixOld=new Ao;this.smoothShading=!0;this.matrixWorldRigid=new Ao;this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!1}static createFromState(e,t,r){let{subdivPointer:o,originalGeometry:n,subdividedGeometry:s}=kt.build(t.geometry,void 0,void 0,!t.flatShading),a=an(t.material,r),l=new xn(o,n,s||void 0,a);return l.calcBoundingBox(),l.freeSubdivPointer(),l.uuid=e,l.fromState(t),l}shallowClone(e){return new yn(this.geometry,this.material).shallowCopy(this,e)}toJSON(e){let t=super.toJSON(e);return t.object.objectType="SubdivObject",t}buildFromStore(e){var n,s,a;let{originalGeometry:t,subdividedGeometry:r,subdivPointer:o}=kt.build(e,this.subdivPointer,void 0,this.smoothShading,this.shearScale);if(this.subdivPointer=o,t!==void 0&&((n=this.originalGeometry)==null||n.dispose(),this.originalGeometry=t),r!==void 0&&((s=this.subdividedGeometry)==null||s.dispose(),this.subdividedGeometry=r!=null?r:void 0),this.geometry=(a=this.subdividedGeometry)!=null?a:this.originalGeometry,this.cloner)for(let l of this.cloner.children)l.geometry=this.geometry;e.width&&(this.geometry.userData.parameters={width:e.width,height:e.height,depth:e.depth})}updateMesh(e=!1){kt.buildLevel(this.subdivPointer,!0,this.smoothShading,this.originalGeometry,e?this.shearScaleInv:void 0),this.subdividedGeometry&&kt.buildLevel(this.subdivPointer,!1,this.smoothShading,this.subdividedGeometry,e?this.shearScaleInv:void 0)}updateTopology(){var e;this.originalGeometry.dispose(),this.originalGeometry=kt.buildLevel(this.subdivPointer,!0,this.smoothShading),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=kt.buildLevel(this.subdivPointer,!1,this.smoothShading)),this.geometry=(e=this.subdividedGeometry)!=null?e:this.originalGeometry}raycast(e,t){var r;this.geometry=this.originalGeometry,yt.prototype.raycast.call(this,e,t),this.geometry=(r=this.subdividedGeometry)!=null?r:this.originalGeometry}updateMatrixWorldSVD(){let e=this.matrixWorld.elements,t=[[e[0],e[4],e[8]],[e[1],e[5],e[9]],[e[2],e[6],e[10]]],{u:r,v:o,q:n}=(0,Nm.SVD)(t),s=Cm.set(r[0][0],r[0][1],r[0][2],0,r[1][0],r[1][1],r[1][2],0,r[2][0],r[2][1],r[2][2],0,0,0,0,1),a=Jw.set(o[0][0],o[0][1],o[0][2],0,o[1][0],o[1][1],o[1][2],0,o[2][0],o[2][1],o[2][2],0,0,0,0,1),l=Kw.copy(a).transpose();this.shearScale=Xw.makeScale(n[0],n[1],n[2]).multiply(l).premultiply(a),this.shearScaleInv=Zw.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(s,l),n.every(c=>Math.abs(n[0]-c)<.01)&&(this.shearScale=void 0,this.shearScaleInv=void 0)}activateSVDCompensation(){this.shearScale!==void 0&&(this.matrixAutoUpdate=!1,this.matrix.copy(this.matrixWorldRigid).copyPosition(this.matrixWorld),this.hiddenMatrixOld.copy(this.hiddenMatrix),this.hiddenMatrix.copy(this.parent.matrixWorld).invert())}deactivateSVDCompensation(){this.shearScale!==void 0&&(this.shearScale=void 0,this.shearScaleInv=void 0,this.matrixAutoUpdate=!0,this.hiddenMatrix.copy(this.hiddenMatrixOld))}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new wm);let t=e.attributes.position,r=e.boundingSphere.center;ur.setFromBufferAttribute(t),ur.getCenter(r),e.boundingSphere.radius=r.distanceTo(ur.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),ur.getSize(po);let o={width:po.x,height:po.y,depth:po.z};return this.geometry.userData.parameters=o,o}updateBoundingBox(e){let t=this.originalGeometry;ur.min.set(e[0],e[2],e[4]),ur.max.set(e[1],e[3],e[5]),this.shearScaleInv&&(ur.min.applyMatrix4(this.shearScaleInv),ur.max.applyMatrix4(this.shearScaleInv)),t.boundingSphere===null&&(t.boundingSphere=new wm);let r=t.boundingSphere.center;ur.getCenter(r),t.boundingSphere.radius=r.distanceTo(ur.max),isNaN(t.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),ur.getSize(po);let o={width:po.x,height:po.y,depth:po.z};return this.geometry.userData.parameters=o,o}freeSubdivPointer(){this.subdivPointer&&(uc.free_bvh(this.subdivPointer),uc.free_subdivision_surface(this.subdivPointer),this.subdivPointer=0)}updateGeometry(e){this.geometry.userData.scale||(this.geometry.userData.scale=Array(3)),this.geometry.userData.scale[0]=this.geometry.userData.parameters.width===0?1:e.parameters.width/this.geometry.userData.parameters.width,this.geometry.userData.scale[1]=this.geometry.userData.parameters.height===0?1:e.parameters.height/this.geometry.userData.parameters.height,this.geometry.userData.scale[2]=this.geometry.userData.parameters.depth===0?1:e.parameters.depth/this.geometry.userData.parameters.depth,Lm(this.originalGeometry.attributes,...this.geometry.userData.scale),this.originalGeometry.attributes.position.needsUpdate=!0,this.originalGeometry.attributes.normal.needsUpdate=!0,this.subdividedGeometry&&(Lm(this.subdividedGeometry.attributes,...this.subdividedGeometry.userData.scale),this.subdividedGeometry.attributes.position.needsUpdate=!0,this.subdividedGeometry.attributes.normal.needsUpdate=!0),this.geometry.userData.parameters=O({},e.parameters)}};function Lm(i,e,t,r){let o=i.position.array,n=i.normal.array,s=Cm.makeScale(e,t,r).invert().elements,a,l,c;for(var d=0,p=o.length;d<p;d+=3)o[d]*=e,o[d+1]*=t,o[d+2]*=r,a=n[d],l=n[d+1],c=n[d+2],n[d]=s[0]*a+s[4]*l+s[8]*c,n[d+1]=s[1]*a+s[5]*l+s[9]*c,n[d+2]=s[2]*a+s[6]*l+s[10]*c}import{BackSide as Qw,DoubleSide as Yw,FrontSide as e1}from"three";function Tm(i,e){e.flatShading!==void 0&&(i.flatShading=e.flatShading,i.needsUpdate=!0),e.wireframe!==void 0&&(i.wireframe=e.wireframe),e.side!==void 0&&(e.side===oi.Front?i.side=e1:e.side===oi.Back?i.side=Qw:i.side=Yw)}function t1(i,e){if(Array.isArray(i.material))for(let t of i.material)Tm(t,e);else{let t=i.material;Tm(t,e)}i.objectType==="SubdivObject"&&e.flatShading!==void 0&&(i.material.flatShading=!1,i.smoothShading=!e.flatShading,i.updateMesh())}function Im(i,e,t){let r;if(e.geometry.type==="SubdivGeometry")r=xn.createFromState(i,e,t);else{let o=bm(e.geometry,t),n="materials"in e?om(e.materials,t):an(e.material,t);Ts.is2DParametricMesh(o.userData.type)?r=new mn(o,n):(o==null?void 0:o.userData.type)==="VectorGeometry"?r=new Oo(o,n):e.geometry.type==="NonParametricGeometry"?r=new yn(o,n):r=new fn(o,n),r.uuid=i,r.fromState(e)}return t1(r,e),r}function Mm(i,e,t){return e.type==="Mesh"?Im(i,e,t):e.type==="TextFrame"?Ci.createFromState(i,e,t):e.type==="Empty"?co.createFromState(i,e):e.type==="PointLight"?un.createFromState(i,e,t):e.type==="SpotLight"?hn.createFromState(i,e,t):e.type==="DirectionalLight"?pn.createFromState(i,e,t):Qo.is(e.type)?lo.createFromState(i,e):(console.error(e),new co)}function r1(i,e){e.uniforms[`f${e.id}_transmissionSamplerMap`].value=i.texture,e.uniforms[`f${e.id}_transmissionDepthMap`].value=i.depthTexture}function Pm(i,e,t){if(!t.userData.layers)return!1;let r=!1,o=t.userData.layers.getLayersOfType(Le.TRANSMISSION);return o.length>0?(e.layers.set(3),r=!0,i!==void 0&&o.forEach(n=>r1(i,n))):e.layers.set(0),r}function Om(i,e){let t=!1;return e.traverseEntity(r=>{if(r instanceof yt)if(Array.isArray(r.material))for(let o=0;o<r.material.length;o++)Pm(i,r,r.material[o])&&(t=!0);else Pm(i,r,r.material)&&(t=!0)}),t}function Am(i,e){"material"in i&&o1(i.material,e),"geometry"in i&&i.geometry.dispose()}function o1(i,e){Nc(i).forEach(t=>{e.isSharedMaterial(t)||t.dispose()})}var _m=new s1,hc=class extends ea(n1){constructor(e,t){super();this.objectType="Scene";this.alpha=1;this.backupFog=new a1(16777215,.1,2e3);this.fogUseBGColor=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this._needsTransmission=!1;this._color=new jm(1,0,0);this.bgColor=new jm(1,1,1);this.entityByUuid={};this.ambientLight=new i1(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.personalCamera=this.createPersonalCamera(),this.activeCamera=this.personalCamera,this.sharedAssetManager=t,this.init(e,t)}needsTransmission(e){return this.needsTransmissionDirty&&(this._needsTransmission=Om(e,this),e!==void 0&&(this.needsTransmissionDirty=!1)),this._needsTransmission}find(e){if(e===""||e===void 0)return;let t=this.entityByUuid[e];return t===void 0?this.getObjectByProperty("uuid",e):t}get color(){return this._color}set color(e){this.fogUseBGColor===!0&&this.backupFog.color.copy(e),this._color.copy(e)}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(Ye(e.backgroundColor,t)),this.updateFog(e.fog,t),this.updateAmbientLight(e.environment.ambientLight,t),this.activeCamera=this.personalCamera,e.publish.playCamera!==null){let r=this.find(e.publish.playCamera);r instanceof lo&&this.switchActiveCamera(r)}}clearScene(e){this.traverseEntity(t=>{Am(t,e)});for(let t of this.children)er(t)&&t.removeFromParent()}resetAfterClear(e,t){this.init(e,t)}createPersonalCamera(){let e=lo.createFromState(hc.PERSONAL_CAMERA_ID,$(O({},Ms.defaultData),{name:"Personal Camera"}));return e.enableHelper=!1,e.objectHelper.visible=!1,delete e.isEntity,this.registerObjectCreatedInLegacy(e),e}raycast(e){let t=[],r=o=>{for(let n of o.children)er(n)&&!n.raycastLock&&n.visible&&((Xs(n)||Er(n)&&n.enableHelper&&n.objectHelper.parent)&&e.intersectObject(n,!1,t),r(n))};return r(this),t}traverseEntity(e){for(let t of this.children)er(t)&&t.traverseEntity(e)}updateFog(e,t){this.enableFog=e.enabled,this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=Ye(e.color,t),this.backupFog.near=e.near,this.backupFog.far=e.far}toJSON(e){return{}}fromJSON(e){return this}dispose(){this.clearScene(this.sharedAssetManager),this.sharedAssetManager.dispose()}updateAmbientLight(e,t){wh(this.ambientLight,e,t),e.groundColor!==void 0&&(this.ambientLight.groundColor=Ye(e.groundColor,t)),e.enabled!==void 0&&(this.ambientLight.visible=e.enabled)}switchActiveCamera(e){this.activeCamera!==this.personalCamera&&(this.activeCamera.enableHelper=!0),this.activeCamera=e,e.enableHelper=!1}setBackgroundColor(e){this.bgColor=e,this.alpha=e.a}createChildrenObjects(e,t,r){for(let o of e)this.createChildObject(o.id,o.data,o.children,t,r)}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let t of e.children)this.unregisterObject(t)}createChildObject(e,t,r,o,n){let s=Mm(e,t,n);return s&&(this.entityByUuid[e]=s,o.add(s),this.createChildrenObjects(r,s,n)),s}getCenter(e){let t=[];for(let o=0,n=e.length;o<n;++o){let{id:s,recursive:a}=e[o],l=this.find(s),c=a?l.recursiveBBox:l.singleBBox;t.push(...c.vertices)}let r=new l1;return r.setFromPoints(t),r.getCenter(_m),_m}copyMatrixWorld(e,t){if(e===null){t.identity();return}let r=this.find(e);r?t.copy(r.matrixWorld):t.identity()}copyParentMatrixWorld(e,t){var o;if(e===null){t.identity();return}let r=(o=this.find(e))==null?void 0:o.parent;r?t.copy(r.matrixWorld):t.identity()}traverseMaterial(e){this.traverseEntity(t=>{if(t instanceof yt)if(Array.isArray(t.material))for(let r=0;r<t.material.length;r++)e(t.material[r]);else e(t.material)})}updateCanvasSize(e,t){this.activeCamera.setViewplaneSize(e,t);let r,o;e>=t?(r=t/e,o=1):(r=1,o=e/t),this.traverseMaterial(n=>{n.layersList.getLayersOfType(Le.TRANSMISSION).forEach(a=>{a.uniforms[`f${a.id}_aspectRatio`].value.x=r,a.uniforms[`f${a.id}_aspectRatio`].value.y=o})})}},Ma=hc;Ma.PERSONAL_CAMERA_ID="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera";import{WebGLRenderTarget as c1,LinearMipmapLinearFilter as d1,LinearFilter as p1,ClampToEdgeWrapping as Dm,DepthTexture as u1}from"three";var Bm=new Nt,mc=class extends Ht{},fc=class{constructor(e){this.materials={};this.images={};this.colors={};this.transmissionRenderTarget=new c1(2048,2048,{generateMipmaps:!0,minFilter:d1,magFilter:p1,wrapS:Dm,wrapT:Dm}),this.transmissionRenderTarget.depthTexture=new u1(2048,2048),this.reset(e)}reset(e){for(let[t,r]of Object.entries(e.images))this.addImage(t,r.data);for(let[t,r]of Object.entries(e.colors))this.addColor(t,r);for(let[t,r]of Object.entries(e.materials))this.addMaterial(t,nc(r,this))}get transmissionSamplerMap(){return this.transmissionRenderTarget.texture}get transmissionDepthMap(){return this.transmissionRenderTarget.depthTexture}addMaterial(e,t){t.uuid=e,this.materials[e]=t}deleteMaterial(e){this.materials[e]&&(this.materials[e].dispose(),delete this.materials[e])}isSharedMaterial(e){return e.uuid in this.materials||e===Bm}getMaterial(e){let t=this.materials[e];return t}getMaterialOrDeletedPlaceholder(e){var t;return(t=this.materials[e])!=null?t:Bm}getMaterials(){return this.materials}addImage(e,t){if(this.images[e])return this.images[e].onload=()=>{this.onImageLoad&&this.onImageLoad(e)},this.images[e].src=t,!0;{let r=new Image;return r.src=t,r.onload=()=>{this.onImageLoad&&this.onImageLoad(e)},this.images[e]=r,!1}}deleteImage(e){this.images[e]&&delete this.images[e]}getDefaultImage(){return this.images.image_0}getImage(e){return this.images[e]}getImages(){return this.images}addColor(e,t){return this.colors[e]?("a"in t?this.colors[e].setRGBA(t.r,t.g,t.b,t.a):this.colors[e].setRGBA(t.r,t.g,t.b,1),!0):("a"in t?this.colors[e]=new mc(t.r,t.g,t.b,t.a):this.colors[e]=new mc(t.r,t.g,t.b,1),!1)}updateColor(e,t){var r,o,n,s;if(this.colors[e]){let a=this.colors[e];return this.colors[e].r=(r=t.r)!=null?r:a.r,this.colors[e].g=(o=t.g)!=null?o:a.g,this.colors[e].b=(n=t.b)!=null?n:a.b,this.colors[e].a=(s=t.a)!=null?s:a.a,!0}return!1}deleteColor(e){this.colors[e]&&delete this.colors[e]}getColor(e){return this.colors[e]}dispose(){Object.keys(this.materials).forEach(t=>this.deleteMaterial(t)),this.transmissionRenderTarget.depthTexture.dispose(),this.transmissionRenderTarget.dispose(),this.onImageLoad=void 0}};var Gm=class extends m1{load(e,t,r,o=console.error){let n=new h1(this.manager);n.setPath(this.path),n.setResponseType("arraybuffer"),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),n.load(e,s=>{try{if(typeof s=="string")throw new Error("The .spline file is not binary!");t(this.parse(s))}catch(a){o(a)}},r,o)}parse(e){let t=xs.deserialize(new Uint8Array(e)),r=new fc(t.shared);return new Ma(t.scene,r)}};export{Gm as default};
|
|
956
|
+
`),c&&p.push(c.code,`outgoingLight = spe_blend(outgoingLight, ${c.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(`
|
|
957
|
+
`)}return t}copy(e){return super.copy(e),e.color&&(this.color=e.color.clone()),this.roughness=e.roughness.clone(),this.metalness=e.metalness.clone(),e.position&&(this.position=e.position.clone()),e.afterColor&&(this.afterColor=e.afterColor.clone()),e.alpha&&(this.alpha=e.alpha.clone()),e.reflectivity&&(this.reflectivity=e.reflectivity.clone()),e.shadingAlpha&&(this.shadingAlpha=e.shadingAlpha.clone()),e.shadingBlend&&(this.shadingBlend=e.shadingBlend.clone()),this}};var rc=class extends rr{get color(){return this.fragment.color}set color(e){this.fragment.color=e}get afterColor(){return this.fragment.afterColor}set afterColor(e){this.fragment.afterColor=e}get alpha(){return this.fragment.alpha}set alpha(e){this.fragment.alpha=e}get shadingAlpha(){return this.fragment.shadingAlpha}set shadingAlpha(e){this.fragment.shadingAlpha=e}get shadingBlend(){return this.fragment.shadingBlend}set shadingBlend(e){this.fragment.shadingBlend=e}get position(){return this.fragment.position}set position(e){this.fragment.position=e}get roughness(){return this.fragment.roughness}set roughness(e){this.fragment.roughness=e}get metalness(){return this.fragment.metalness}set metalness(e){this.fragment.metalness=e}get reflectivity(){return this.fragment.reflectivity}set reflectivity(e){this.fragment.reflectivity=e}constructor(e=new tc,t){super(e,e,t);this.type="StandardNodeMaterial",this.fragment=e}};var nn=class extends rc{constructor(e,t,r){super(t,e);this.userData.type="PhysicalMaterial",this.userData.category="Physical",this.userData.layers=r!=null?r:this._getLayerStack(e==null?void 0:e.map)}get layersList(){return this.userData.layers}set layersList(e){this.userData.layers=e}equals(e){return this.userData.type===e.userData.type&&this.userData.layers.uuid==e.userData.layers.uuid}copy(e){if(e.userData.layers!==void 0&&e.userData.layers instanceof Pt){let t=e.userData.layers,r=e.fragment;super.copy(e);let o=r.clone();this.fragment=o,this.vertex=o;let n=t.clone(this);this.userData.layers=n,o.shadingAlpha.value=r.shadingAlpha.value,o.shadingBlend.value=r.shadingBlend.value}else super.copy(e);return this}static fromJSON(e,t,r){let o=r.getNode(t.vertex),n=new nn(void 0,o);return n.fromJSON(t,r),n}dispose(){super.dispose()}};import{Color as ic}from"three";import{Matrix3 as Kh,Texture as oc,Vector2 as sn,Vector3 as Mo,Vector4 as Xh}from"three";function Zh(i,e){switch(i.data.type){case"light":return dr(i);case"fresnel":return QS(i,e);case"gradient":return YS(i);case"depth":return ew(i);case"normal":return tw(i);case"noise":return rw(i,e);case"texture":return ow(i,e);case"rainbow":return iw(i);case"transmission":return nw(i,e);case"matcap":return sw(i,e);case"displace":return aw(i);case"color":default:return ZS(i,e)}}function Qh(i){return{type:i.data.type}}function dr(i){let{alpha:e,mode:t}=i.data;return $(O({},Qh(i)),{alpha:e,mode:t})}function ZS(i,e){return $(O({},dr(i)),{color:Ye(i.data.color,e)})}function QS(i,e){let{bias:t,scale:r,intensity:o,factor:n,color:s}=i.data;return $(O({},dr(i)),{color:Ye(s,e),bias:t,scale:r,intensity:o,factor:n})}function YS(i){let{gradientType:e,smooth:t,colors:r,steps:o,angle:n,offset:s,morph:a}=i.data;return $(O({},dr(i)),{gradientType:e,smooth:t,colors:r.map(l=>new Xh(l[0],l[1],l[2],l[3])),num:r.length,steps:o,offset:new sn(...s),morph:new sn(...a),angle:n})}function ew(i){let{gradientType:e,near:t,far:r,isVector:o,isWorldSpace:n,origin:s,direction:a,colors:l,steps:c,smooth:d,num:u}=i.data;return $(O({},dr(i)),{gradientType:e,near:t,far:r,isVector:o,isWorldSpace:n,origin:new Mo(...s),direction:a?new Mo(...a):new Mo(1,0,0),num:u,colors:l.map(p=>new Xh(p[0],p[1],p[2],p[3])),steps:c,smooth:d})}function tw(i){let{cnormal:e}=i.data;return $(O({},dr(i)),{cnormal:new Mo(e[0],e[1],e[2])})}function rw(i,e){let{data:t}=i;return $(O({},dr(i)),{scale:t.scale,move:t.move,fA:new sn(...t.fA),fB:new sn(...t.fB),distortion:new sn(...t.distortion),colorA:Ye(t.colorA,e),colorB:Ye(t.colorB,e),colorC:Ye(t.colorC,e),colorD:Ye(t.colorD,e),noiseType:t.noiseType})}function ow(i,e){let{projection:t,axis:r,crop:o,size:n}=i.data,{image:s,wrapping:a,repeat:l,offset:c}=i.data.texture,d=new oc,u;if(typeof s=="string")u=e==null?void 0:e.getImage(s);else{let p=new Image;p.src=s.data,p.onload=()=>{(e==null?void 0:e.onImageLoad)&&(e==null||e.onImageLoad(s.data))},u=p}return d.image=u,d.wrapS=d.wrapT=a,$(O({},dr(i)),{texture:d,mat:new Kh().setUvTransform(c[0],c[1],l[0],l[1],0,0,0),crop:o,projection:t,axis:["x","y","z"].indexOf(r),size:n})}function iw(i){let{data:e}=i;return $(O({},dr(i)),{filmThickness:e.filmThickness,movement:e.movement,wavelengths:new Mo(...e.wavelengths),noiseStrength:e.noiseStrength,noiseScale:e.noiseScale,offset:new Mo(...e.offset)})}function nw(i,e){let{data:t}=i;return $(O({},dr(i)),{thickness:t.thickness,ior:t.ior,roughness:t.roughness,transmissionSamplerMap:e.transmissionSamplerMap,transmissionDepthMap:e.transmissionDepthMap})}function sw(i,e){let t=new oc,{image:r}=i.data.texture,o;if(typeof r=="string")o=e==null?void 0:e.getImage(r);else{let s=new Image;s.src=r.data,s.onload=()=>{(e==null?void 0:e.onImageLoad)&&(e==null||e.onImageLoad(r.data))},o=s}t.image=o;let n=16777215;return $(O({},dr(i)),{color:n,texture:t})}function aw(i){let{data:e}=i,t=$(O({},Qh(i)),{intensity:e.intensity});if(e.displacementType==="noise")return $(O({},t),{offset:new Mo(...e.offset),scale:e.scale,movement:e.movement,noiseType:e.noiseType});{let r=new oc,o=new Kh().setUvTransform(0,0,1,1,0,0,0);return $(O({},t),{texture:r,mat:o,crop:e.crop})}}function Yh(i,e,t){if(t.type==="displace"&&(i==="intensity"||i==="visible")){let r=e.uniforms[`f${e.id}_intensity`];return r?(r.value=t.intensity*(t.visible?1:0),r):void 0}if(t.type!=="displace"&&(i==="alpha"||i==="visible")){let r=e.uniforms[`f${e.id}_alpha`];return r?(r.value=t.alpha*(t.visible?1:0),r):void 0}}import{Color as em,Vector4 as lw}from"three";var Si;(function(e){function i(t){return new em(t.x,t.y,t.z).getHex()}e.getHex=i})(Si||(Si={}));var tm;(function(e){function i(t){return new lw(t.r,t.g,t.b,t.a)}e.getThreeVector4=i})(tm||(tm={}));var rm;(function(t){function i(r,o){r.setRGB(o.r,o.g,o.b)}t.setThreeColor=i;function e(r){return new em(r.r,r.g,r.b).getHex()}t.getHex=e})(rm||(rm={}));function an(i,e){return typeof i=="string"?e.getMaterialOrDeletedPlaceholder(i):nc(i,e)}function om(i,e){return i.map(t=>an(t,e))}function nc(i,e){var s,a;let t=(s=i.layers)!=null?s:si.defaultTwoLayerData("phong").layers,r=cw(t),o;switch(r.category){case"basic":o=new Nt;break;case"lambert":{o=new rn;break}case"toon":{o=new on;break}case"physical":o=new nn;break;case"phong":default:{o=new or;break}}o.name=(a=i.name)!=null?a:"Untitled Material";let n=o.userData.layers;dw(n);for(let l=t.length-1;l>=0;l--)pw(n,t[l],e);switch(r.category){case"basic":break;case"lambert":{let d=o,p=Ye(r.emissive,e);p instanceof ic?d.emissive.value=p:d.emissive.value.setHex(Si.getHex(p));break}case"toon":{let d=o,u=r;d.shininess.value=u.shininess;let p=Ye(u.specular,e);p instanceof ic?d.specular.value=p:d.specular.value.setHex(Si.getHex(p));break}case"physical":let l=o,c=r;l.metalness.value=c.metalness,l.roughness.value=c.roughness,l.reflectivity.value=c.reflectivity;break;case"phong":default:{let d=o,u=r;d.shininess.value=u.shininess;let p=Ye(u.specular,e);p instanceof ic?d.specular.value=p:d.specular.value.setHex(Si.getHex(p));break}}return n.blendColors(),n.blendAfterColors(),n.blendPositions(),o}function cw(i){for(let e of i)if(e.data.type==="light")return e.data;return{type:"light",category:"basic",visible:!0,alpha:1,mode:it.Normal}}function dw(i){for(let e of i.getLayers())i.removeLayer(e.id)}function pw(i,e,t){let r=Zh(e,t);r.type==="transmission"&&(r.transmissionSamplerMap=t==null?void 0:t.transmissionSamplerMap,r.transmissionDepthMap=t==null?void 0:t.transmissionDepthMap);let o=i.addLayer(r);o.uuid=e.id;for(let n in e.data)Yh(n,o,e.data)}import{Vector2 as im}from"three";var ga=new im,Po=class{constructor(e,t,r){this.message=[];this.endLine=!0;this.yLinePos=e,this.lineHeight=t,this.maxCharSize=r,this.nextChar3DPos=new im(0,this.yLinePos+this.maxCharSize*this.lineHeight),this.align=Tt.Left}addChar3D(e,t,r=this.message.length){this.message.splice(r,0,e),e.fontSize>this.maxCharSize?(this.maxCharSize=e.fontSize,this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight,this.fullUpdate(t)):(e.updatePosition(this.nextChar3DPos,t),this.nextChar3DPos.x+=e.charSize)}deleteChar3D(e=this.message.length-1){let t=this.message[e];if(t)return this.message.splice(e,1),this.nextChar3DPos.x-=t.charSize,t}isEndLine(e){this.endLine=e}fullUpdate(e,t=0){this.nextChar3DPos.x=0;for(let r=t,o=this.message.length;r<o;r+=1)this.message[r].updatePosition(this.nextChar3DPos,e),this.nextChar3DPos.x+=this.message[r].charSize}checkOverFlow(e){let t,r=this.message.length-1;if(r<=0)return!1;for(;r>=0;){if(this.message[r].char!==" "){t=this.message[r];break}r-=1}return!!(r>=0&&t&&t.localPosition.x+t.charSize>e)}containSpaceOverFlow(e=this.message.length-1){for(let t=e;t>=0;t-=1)if(this.message[t].char===" ")return!0;return!1}containSpace(e=this.message.length-1){if(this.endLine)return!0;for(let t=e;t>=0;t-=1)if(this.message[t].char===" ")return!0;return!1}popWord(e=this.message.length-1){let t=[],r=!0,o;for(o=e;o>=0;o-=1)if(this.message[o].char===" "){r=!1,t.length===0&&(o-=1,t.splice(0,0,this.message[o]));break}else t.splice(0,0,this.message[o]);return r?t=[]:this.message.splice(o+1,t.length),t}getWord(e=0,t=1){let r=[],o=e;for(o=e;;o+=t){if(!this.message[o]||this.message[o].char===" "){r.length===0&&this.message[o]&&(r.push(this.message[o]),this.message.splice(o,1));break}t>0?(r.push(this.message[o]),this.message.splice(o,1),o-=t):(r.splice(0,0,this.message[o]),this.message.splice(o,1))}return r}getWordAtIndex(e){let t=[];for(let r=e;r<this.message.length&&this.message[r].char!==" ";r++)t.push(this.message[r]);for(let r=e-1;r>=0&&this.message[r].char!==" ";r--)t.splice(0,0,this.message[r]);return t}wordSize(e=0,t=-1){let r=0,o=e;for(;o>=0&&o<this.message.length;){if(this.message[o].char===" "){r===0&&(r=this.message[o].charSize);break}r+=this.message[o].charSize,o+=t}return(o<0||o>=this.message.length)&&!this.endLine?this.message[e]?this.message[e].charSize:999999999:r===0?999999999:r}spaceLeft(e){return e-this.nextChar3DPos.x}popChar(e=this.message.length-1){return this.nextChar3DPos.x-=this.message[e].charSize,this.message.splice(e,1)}isEmpty(){return!this.message.length}updateNextCharPosY(){this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight}updateYLinePos(e){this.yLinePos=e,this.updateNextCharPosY()}updatelineHeight(e){this.lineHeight=e,this.updateNextCharPosY()}updateFontSize(e,t=0,r=this.message.length-1){for(let o=t;o<=r;o+=1)this.message[o].updateFontSize(e);this.maxCharSize=e,this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight}countSpaces(){let e=0;for(let t=0;t<this.message.length;t++)this.message[t].char===" "&&(e+=1);return e}alignText(e,t,r,o,n){switch(r){case Tt.Left:this.leftAlign(e,n);break;case Tt.Center:this.centerAlign(this.spaceLeft(t),e,n);break;case Tt.Right:this.rightAlign(this.spaceLeft(t),e,n);break;case Tt.Justify:this.justifyAlign(this.spaceLeft(t),e,n);break}}offsetCharacters(e,t,r){ga.set(t,r);let o=this.message.length;for(let n=0;n<o;n++)this.message[n].updatePosition(this.message[n].localPosition.add(ga),e)}leftAlign(e,t){this.align=Tt.Left,this.offsetCharacters(e,0,t)}centerAlign(e,t,r){this.align=Tt.Center,this.offsetCharacters(t,e/2,r)}rightAlign(e,t,r){this.align=Tt.Right,this.offsetCharacters(t,e,r)}justifyAlign(e,t,r){if(this.align=Tt.Justify,this.endLine){this.offsetCharacters(t,0,r);return}let o=this.countSpaces();if(o===0){this.offsetCharacters(t,0,r);return}let n=e/o,s=0;for(let a=0;a<this.message.length;a++)this.message[a].char===" "&&(s+=n),ga.set(s,r),this.message[a].updatePosition(this.message[a].localPosition.add(ga),t)}clone(){let e=new Po(this.yLinePos,this.lineHeight,this.maxCharSize);e.nextChar3DPos=this.nextChar3DPos.clone(),e.align=this.align,e.endLine=this.endLine;for(let t=0;t<this.message.length;t++)e.message.push(this.message[t].clone());return e}};import{DoubleSide as uw,EventDispatcher as hw,Matrix3 as mw,Vector3 as sc}from"three";var fw=new sc(0,0,1),nm=new sc,sm=new sc,am=new mw,Oo=class extends yt{constructor(e=mt.create({}),t=new Nt({side:uw})){super(e,t);this.recursiveSelection=!1;this.objectType="VectorObject";this.eventDispatcher=new hw;this._onShapeUpdate=()=>{if(this.geometry instanceof No){if(this.geometry.updateFromShape()){let e=this.geometry.drawCount,t=this.geometry.userData;this.updateGeometry(Object.assign(this.geometry.userData,{parameters:Object.assign(t.parameters,{surfaceMaxCount:e+1e3})}))}}else this.updateGeometry({});this.geometry.computeBoundingSphere(),this.geometry.computeBoundingBox()};var r;this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!0,this.shape=e.userData.shape,(r=this.shape.eventDispatcher)==null||r.addEventListener("update",this._onShapeUpdate)}toJSON(e){let t=super.toJSON(e);return t.object.objectType="VectorObject",t}fromState(e){return super.fromState(e),this.shape.update(),this}setHelperVisibility(){}updateGeometry(e){if(super.updateGeometry(e),"userData"in this.geometry){let t=this.geometry.userData.parameters;this.eventDispatcher.dispatchEvent({type:"geometryUpdate",parameters:t})}}setShape(e){var t,r;this.shape&&((t=this.shape.eventDispatcher)==null||t.removeEventListener("update",this._onShapeUpdate)),this.shape=e,(r=this.shape.eventDispatcher)==null||r.addEventListener("update",this._onShapeUpdate)}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),am.getNormalMatrix(this.matrixWorld),nm.copy(fw).applyMatrix3(am).normalize(),sm.setFromMatrixPosition(this.matrixWorld),this.shape.plane.setFromNormalAndCoplanarPoint(nm,sm)}clone(e){let t=this.shape.clone(),r=this.material.clone(),o=this.geometry.userData,n=mt.create(Object.assign({},o,{shape:t})),s=new Oo(n,r).copy(this,e);return s.shape=t,t.update(),s}raycast(e,t){yt.prototype.raycast.call(this,e,t)}};import{Camera as Ow,OrthographicCamera as Aw,PerspectiveCamera as jw,Vector3 as Wt,Object3D as pm,Quaternion as _w}from"three";import{BoxBufferGeometry as yw}from"three";var Nr=i=>{var e;return e=class extends i{constructor(){super(...arguments);this.isObjectHelper=!0}},e.geometryHelper=new yw(30,30,30),e};import{Camera as vw,LineSegments as Sw,BufferGeometry as ww,LineBasicMaterial as Nw,Color as lc,Vector3 as Cw,Float32BufferAttribute as cm}from"three";import{Ray as gw,Sphere as xw,Matrix4 as bw,Vector3 as Ur}from"three";var xa=new gw,ac=new xw,lm=new bw,Cr=(i,e,t,r,o=!1)=>{let n=e,s=i.matrixWorld;if(n.boundingSphere===null&&n.computeBoundingSphere(),ac.copy(n.boundingSphere),ac.applyMatrix4(s),t.ray.intersectsSphere(ac)===!1||(lm.copy(s).invert(),xa.copy(t.ray).applyMatrix4(lm),n.boundingBox!==null&&xa.intersectsBox(n.boundingBox)===!1))return;let a,l,c,d,u=n.index,p=n.attributes.position,f=n.drawRange,m,x;if(o===!1){let N=Math.max(0,f.start),L=Math.min(u.count,f.start+f.count);for(m=N,x=L;m<x;m+=3)if(l=u.getX(m),c=u.getX(m+1),d=u.getX(m+2),a=y(i,t,xa,p,l,c,d),a){a.faceIndex=Math.floor(m/3),r.push(a);return}}else{let L=n.attributes.position,w=new Ur,B=new Ur,S=new Ur,_=new Ur,T=2,I=1/((i.scale.x+i.scale.y+i.scale.z)/3),b=I*I,P=Math.max(0,f.start),v=Math.min(L.count,f.start+f.count);for(let D=P,Z=v-1;D<Z;D+=T){if(w.fromBufferAttribute(L,D),B.fromBufferAttribute(L,D+1),xa.distanceSqToSegment(w,B,_,S)>b)continue;_.applyMatrix4(i.matrixWorld);let ie=t.ray.origin.distanceTo(_);ie<t.near||ie>t.far||r.push({distance:ie,point:S.clone().applyMatrix4(i.matrixWorld),object:i})}}function y(N,L,w,B,S,_,T){let h=new Ur,I=new Ur,b=new Ur,P=new Ur,v=new Ur;if(h.fromBufferAttribute(B,S),I.fromBufferAttribute(B,_),b.fromBufferAttribute(B,T),w.intersectTriangle(h,I,b,!1,P)===null)return null;v.copy(P),v.applyMatrix4(N.matrixWorld);let Z=L.ray.origin.distanceTo(v);return Z<L.near||Z>L.far?null:{faceIndex:1,distance:Z,point:v.clone(),object:N}}};var ba=new Cw,ir=new vw,dm=class extends Sw{constructor(e){let t=new ww,r=new Nw({color:16777215,vertexColors:!0,toneMapped:!1}),o=[],n=[],s={},a=new lc(Ya),l=new lc(Ya),c=new lc(bu);d("n1","n2",a),d("n2","n4",a),d("n4","n3",a),d("n3","n1",a),d("f1","f2",a),d("f2","f4",a),d("f4","f3",a),d("f3","f1",a),d("n1","f1",a),d("n2","f2",a),d("n3","f3",a),d("n4","f4",a),d("p","n1",l),d("p","n2",l),d("p","n3",l),d("p","n4",l),d("u1","u2",c),d("u2","u3",c),d("u3","u1",c);function d(p,f,m){u(p,m),u(f,m)}function u(p,f){o.push(0,0,0),n.push(f.r,f.g,f.b),s[p]===void 0&&(s[p]=[]),s[p].push(o.length/3-1)}t.setAttribute("position",new cm(o,3)),t.setAttribute("color",new cm(n,3));super(t,r);this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=s,this.update()}update(){let e=this.geometry,t=this.pointMap,r=!0;ir.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let o=1,n=1,s=r?.8:1e-4;pr("n1",t,e,ir,-o,-n,s),pr("n2",t,e,ir,o,-n,s),pr("n3",t,e,ir,-o,n,s),pr("n4",t,e,ir,o,n,s);let a=s;pr("f1",t,e,ir,-o,-n,a),pr("f2",t,e,ir,o,-n,a),pr("f3",t,e,ir,-o,n,a),pr("f4",t,e,ir,o,n,a);let l=a,c=.5;pr("u1",t,e,ir,o*.7*c,n*1.1,l),pr("u2",t,e,ir,-o*.7*c,n*1.1,l),pr("u3",t,e,ir,0,n*(1.1+.9*c),l),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function pr(i,e,t,r,o,n,s){ba.set(o,n,s).unproject(r);let a=e[i];if(a!==void 0){let l=t.getAttribute("position");for(let c=0,d=a.length;c<d;c++)l.setXYZ(a[c],ba.x,ba.y,ba.z)}}var cc=class extends Nr(dm){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){Cr(this.object,this.geometry,e,t,!0)}};import{DirectionalLightHelper as Lw}from"three";var ln=class extends Nr(Lw){constructor(e,t=15,r=10066329){super(e,t,r);this.object=e;this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,t){Cr(this.object,ln.geometryHelper,e,t)}};import{AxesHelper as Tw}from"three";var cn=class extends Nr(Tw){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){Cr(this.object,cn.geometryHelper,e,t)}update(){}};import{PointLightHelper as Iw}from"three";var dn=class extends Nr(Iw){constructor(e,t=15,r=6710886){super(e,t,r);this.object=e;this.name=`PointLightHelper: ${e.uuid}`}raycast(e,t){Cr(this.object,dn.geometryHelper,e,t)}};import{SpotLightHelper as Mw,Vector3 as Pw}from"three";var Sa=class extends Nr(Mw){constructor(e,t=6710886){super(e,t);this.object=e;this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,t){Cr(this.object,Sa.geometryHelper,e,t)}update(){if(this.object!==void 0){let e=Sa._vector,t=this.object.distance?this.object.distance:1e3,r=t*Math.tan(this.object.angle);this.cone.scale.set(r,r,t),e.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(e);let o=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let n=0,s=this.cone.material.length;n<s;n++)this.cone.material[n].color.set(o);else this.cone.material.color.set(o)}}},va=Sa;va._vector=new Pw;var Lr=(i,e)=>class extends i{constructor(){super(...arguments);this.objectHelper=new e(this);this.enableHelper=!1}set visibility(r){this.visible=r,this.setHelperVisibility(r),this.setHelperChildrenVisibility(r)}get visibility(){return this.visible}get geometryHelper(){return e.geometryHelper}setHelperVisibility(r){this.objectHelper.visible=r}setHelperChildrenVisibility(r){for(let o of this.children)er(o)&&o.traverseEntity(n=>{Er(n)&&n.visible&&(n.objectHelper.visible=r)})}raycast(r,o){this.objectHelper.raycast(r,o)}copy(r,o=!0){return super.copy(r,o),r.enableHelper!==void 0&&(this.enableHelper=r.enableHelper),r.objectHelper!==void 0&&(this.objectHelper.visible=r.objectHelper.visible),this}toJSON(r){let o=super.toJSON(r),n=o.object;return n.enableHelper=this.enableHelper,o}fromJSON(r){return super.fromJSON(r),r.enableHelper!==void 0&&(this.enableHelper=!0),this}fromLightState(r,o){if(this.objectType==="LightDirectional"||this.objectType==="LightPoint"||this.objectType==="LightSpot"){let n=this;r.color!==void 0&&(n.color=Ye(r.color,o)),r.intensity!==void 0&&(n.intensity=r.intensity),r.depth!==void 0&&(n.shadow.camera.far=r.depth,n.shadow.needsUpdate=!0),r.shadows!==void 0&&(this.castShadow=r.shadows),r.helper!==void 0&&(this.enableHelper=r.helper,n.gizmos.shadowmap.visible=r.helper)}return this}};var wi=new Wt,dc=new Wt,lo=class extends Lr(tr(Ow),cc){constructor(e=window.innerWidth,t=window.innerHeight,r=45,o,n=1e5){super();this.objectType="CombinedCamera";this._cameraType="OrthographicCamera";this.targetOffset=xo.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.width=e,this.height=t,this.orthoCamera=new Aw(e*-.5,e*.5,t*.5,t*-.5,o!=null?o:-5e4,n),this.perspCamera=new jw(r,e/t,o!=null?o:50,n),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.fov=this.perspCamera.fov,this.focus=this.perspCamera.focus,this.filmGauge=this.perspCamera.filmGauge,this.filmOffset=this.perspCamera.filmOffset,this.toOrthographic(!0)}static createFromState(e,t){let r=new lo().fromState(t);return r.enableHelper=!0,r.objectHelper.update(),r.uuid=e,r}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}setNear(e,t){e==="PerspectiveCamera"?this.perspCamera.near=t:this.orthoCamera.near=t}setZoom(e,t){t>=0&&(e==="PerspectiveCamera"?this.perspCamera.zoom=t:this.orthoCamera.zoom=t)}set cameraType(e){e==="PerspectiveCamera"?this.toPerspective():e==="OrthographicCamera"&&this.toOrthographic()}get near(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.near:this.orthoCamera.near}set near(e){this._cameraType==="PerspectiveCamera"?this.perspCamera.near=e:this.orthoCamera.near=e}get zoom(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(e){e>=0&&(this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom=e:this.orthoCamera.zoom=e)}lookAt(e){super.lookAt(e),this.getWorldPosition(wi),this.targetOffset=wi.distanceTo(e)}getTarget(e=new Wt){return this.getWorldDirection(dc),this.getWorldPosition(wi),dc.multiplyScalar(this.targetOffset),e.copy(wi).add(dc),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(wi),wi.distanceTo(e)}updateUp(){let e=this.getWorldQuaternion(new _w),t=new Wt(0,0,1).applyQuaternion(e),r=new Wt().copy(pm.DefaultUp);this.isUpVectorFlipped&&r.negate(),r.applyQuaternion(e);let o=new Wt().copy(pm.DefaultUp).projectOnPlane(t),n=new Wt().crossVectors(o,r).dot(t)>=0?1:-1;this.angleOffsetFromUp=o.angleTo(r)*n}getViewFrontToObject(e){let t=e.getWorldPosition(new Wt),o=e.getWorldDirection(new Wt).multiplyScalar(this.targetOffset);return{position:t.clone().add(o),target:t}}getViewToObject(e){let t=e.getWorldPosition(new Wt),o=this.getWorldDirection(new Wt).multiplyScalar(this.targetOffset);return{position:t.clone().sub(o),target:t}}setViewplaneSize(e,t){this.left=-e*.5,this.right=e*.5,this.top=t*.5,this.bottom=-t*.5,this.aspect=e/t,this.updateProjectionMatrix()}toOrthographic(e){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.enableHelper===!0||e===!0)&&this.objectHelper.update()}toPerspective(e){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.enableHelper===!0||e===!0)&&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,r,o,n,s){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(e,t,r,o,n,s):this.orthoCamera.setViewOffset(e,t,r,o,n,s)}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}updateProjectionMatrix(e){this._cameraType==="PerspectiveCamera"?this.toPerspective(e):this._cameraType==="OrthographicCamera"&&this.toOrthographic(e)}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(e,t){return super.copy(e,t),this.orthoCamera.copy(e.orthoCamera),this.perspCamera.copy(e.perspCamera),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.far=e.far,this.view=e.view===null?null:Object.assign({},e.view),this._cameraType=e._cameraType,this.aspect=e.aspect,this.fov=e.fov,this.focus=e.focus,this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this.targetOffset=e.targetOffset,this.updateProjectionMatrix(),this}fromCameraRender(e){let t={near:this.orthoCamera.near,far:this.orthoCamera.far},r={near:this.perspCamera.near,far:this.perspCamera.far};return this.copy(e),this.name="",this.enableHelper=!0,this.objectHelper.visible=!0,this.orthoCamera.near=t.near,this.orthoCamera.far=t.far,this.perspCamera.near=r.near,this.perspCamera.far=r.far,this.updateProjectionMatrix(),this}toJSON(e){let t=super.toJSON(e),r=t.object;return r.objectType="CombinedCamera",r.cameraType=this.cameraType,r.targetOffset=this.targetOffset,r.isUpVectorFlipped=this.isUpVectorFlipped,r.angleOffsetFromUp=this.angleOffsetFromUp,r.left=this.left,r.right=this.right,r.top=this.top,r.bottom=this.bottom,this.view!==null&&(r.view=Object.assign({},this.view)),r.zoomOrtho=this.orthoCamera.zoom,r.nearOrtho=this.orthoCamera.near,r.far=this.far,r.aspect=this.aspect,r.fov=this.fov,r.focus=this.focus,r.filmGauge=this.filmGauge,r.filmOffset=this.filmOffset,r.zoomPersp=this.perspCamera.zoom,r.nearPersp=this.perspCamera.near,t}fromJSON(e){var t;if(super.fromJSON(e),this.cameraType=e.cameraType,e.targetOffset!==void 0&&(this.targetOffset=e.targetOffset),e.orbitControlsTarget!==void 0){let r=this.getWorldPosition(new Wt),o=new Wt().fromArray(e.orbitControlsTarget);this.targetOffset=o.distanceTo(r)}else e.targetOffset!==void 0&&(this.targetOffset=e.targetOffset);return this.isUpVectorFlipped=!1,this.angleOffsetFromUp=(t=e.angleOffsetFromUp)!=null?t:0,e.left!==void 0&&(this.left=e.left),e.right!==void 0&&(this.right=e.right),e.top!==void 0&&(this.top=e.top),e.bottom!==void 0&&(this.bottom=e.bottom),e.view!==void 0&&(this.view=Object.assign({},e.view)),e.zoomOrtho!==void 0&&(this.orthoCamera.zoom=e.zoomOrtho),e.nearOrtho!==void 0&&(this.orthoCamera.near=e.nearOrtho),e.far!==void 0&&(this.far=e.far),e.aspect!==void 0&&(this.aspect=e.aspect),e.fov!==void 0&&(this.fov=e.fov),e.focus!==void 0&&(this.focus=e.focus),e.filmGauge!==void 0&&(this.filmGauge=e.filmGauge),e.filmOffset!==void 0&&(this.filmOffset=e.filmOffset),e.zoomPersp!==void 0&&(this.perspCamera.zoom=e.zoomPersp),e.nearPersp!==void 0&&(this.perspCamera.near=e.nearPersp),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 Zo(t,e)}fromCameraState(e){let{orthographic:t,perspective:r}=e;return e.type!==void 0&&(this.cameraType=e.type),e.far!==void 0&&(this.far=e.far),t!==void 0&&(t.near!==void 0&&(this.orthoCamera.near=t.near),t.zoom!==void 0&&(this.orthoCamera.zoom=t.zoom)),r!==void 0&&(r.near!==void 0&&(this.perspCamera.near=r.near),r.fov!==void 0&&(this.perspCamera.fov=r.fov),r.zoom!==void 0&&(this.perspCamera.zoom=r.zoom)),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(),this}toState(e){return $(O(O({},super.toState(e)),this.toCameraState(e)),{type:this.cameraType})}fromState(e){return super.fromState(e),this.fromCameraState(e),this}};import{Group as Dw}from"three";var co=class extends Lr(tr(Dw),cn){constructor(){super(...arguments);this.objectType="EmptyObject"}static createFromState(e,t){let r=new co().fromState(t);return r.uuid=e,r.enableHelper=!0,r.objectHelper.update(),r}toJSON(e){let t=super.toJSON(e);return t.object.objectType="EmptyObject",t}};import{DirectionalLight as Bw,CameraHelper as wa}from"three";var pn=class extends Lr(tr(Bw),ln){constructor(...e){super(...e);this.objectType="LightDirectional";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024;let r=this.shadow.camera;r.top=1250,r.bottom=-1250,r.right=1250,r.left=-1250,r.near=1,r.far=2500;let o=new wa(this.shadow.camera);o.visible=!1,this._gizmos.shadowmap=o,this.update()}static createFromState(e,t,r){let o=new pn().fromState(t,r);return o.uuid=e,o}get gizmos(){return this._gizmos}showGizmos(){for(let e in this._gizmos){let t=this._gizmos[e];t instanceof wa&&(t.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let t=this._gizmos[e];t instanceof wa&&(t.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this._gizmos){let t=this._gizmos[e];t instanceof wa&&t.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}copy(e,t=!0){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e),r=t.object;return r.objectType="LightDirectional",r.color=this.color.getHex(),r.intensity=this.intensity,r.shadow=this.shadow.toJSON(),t}fromJSON(e){var o;super.fromJSON(e),this.color.set(e.color),this.intensity=e.intensity,this.shadow.normalBias=(o=e.shadow.normalBias)!=null?o:0,this.shadow.radius=e.shadow.radius,this.shadow.mapSize.fromArray(e.shadow.mapSize);let t=this.shadow.camera,r=e.shadow.camera;return t.near=r.near,t.far=r.far,t.zoom=r.zoom,t.left=r.left,t.right=r.right,t.top=r.top,t.bottom=r.bottom,r.view!==void 0&&(t.view=Object.assign({},r.view)),this}fromDirectionalLightState(e,t){let r=e.depth!==void 0&&e.depth!==this.shadow.camera.far||e.size!==void 0&&e.size/2!==this.shadow.camera.right;return super.fromLightState(e,t),e.size!==void 0&&Nh(this,e.size),r&&this.update(),this}fromState(e,t){return super.fromState(e),this.fromDirectionalLightState(e,t),this}};import{PointLight as Gw,Vector3 as Na,Box3 as zw,Box3Helper as Ca,Color as Ew}from"three";var un=class extends Lr(tr(Gw),dn){constructor(...e){super(...e);this.objectType="LightPoint";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024;let r=this.shadow.camera;r.fov=90,r.aspect=1,r.near=100,r.far=2500;let o=new Na(-r.far+this.position.x,-r.far+this.position.y,-r.far+this.position.z),n=new Na(r.far+this.position.x,r.far+this.position.y,r.far+this.position.z),s=new zw(o,n),a=new Ca(s,new Ew(16755200));a.visible=!1,this._gizmos.shadowmap=a,this.update()}static createFromState(e,t,r){let o=new un().fromState(t,r);return o.uuid=e,o}get gizmos(){return this._gizmos}showGizmos(){for(let e in this._gizmos){let t=this._gizmos[e];t instanceof Ca&&(t.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let t=this._gizmos[e];t instanceof Ca&&(t.visible=!1)}}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this._gizmos))for(let e in this._gizmos){let t=this._gizmos[e];if(t instanceof Ca){let r=this.shadow.camera,o=new Na(-r.far+this.position.x,-r.far+this.position.y,-r.far+this.position.z),n=new Na(r.far+this.position.x,r.far+this.position.y,r.far+this.position.z);t.box.set(o,n),t.updateMatrixWorld(!0)}}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}copy(e,t=!0){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e),r=t.object;return r.objectType="LightPoint",r.color=this.color.getHex(),r.intensity=this.intensity,r.distance=this.distance,r.decay=this.decay,r.shadow=this.shadow.toJSON(),t}fromJSON(e){var o,n;super.fromJSON(e),this.color.set(e.color),this.intensity=e.intensity,this.distance=e.distance,this.decay=e.decay,this.shadow.normalBias=(o=e.shadow.normalBias)!=null?o:0,this.shadow.radius=e.shadow.radius,this.shadow.mapSize.fromArray((n=e.shadow.mapSize)!=null?n:[512,512]),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null);let t=this.shadow.camera,r=e.shadow.camera;return t.near=r.near,t.far=r.far,t.zoom=r.zoom,t.fov=r.fov,t.focus=r.focus,t.aspect=r.aspect,t.filmGauge=r.filmGauge,t.filmOffset=r.filmOffset,r.view!==void 0&&(t.view=Object.assign({},r.view)),this}fromPointLightState(e,t){return super.fromLightState(e,t),e.distance!==void 0&&(this.distance=e.distance),e.decay!==void 0&&(this.decay=e.decay),e.shadowRadius!==void 0&&(this.shadow.radius=e.shadowRadius),e.shadowResolution!==void 0&&(this.shadow.mapSize.set(e.shadowResolution,e.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),this}fromState(e,t){return super.fromState(e),this.fromPointLightState(e,t),this}};import{SpotLight as Fw,CameraHelper as La,MathUtils as Rw,Vector3 as um,Quaternion as Vw}from"three";var hm=new um,mm=new um,fm=new Vw,hn=class extends Lr(tr(Fw),va){constructor(...e){super(...e);this.objectType="LightSpot";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024;let r=this.shadow.camera;r.fov=Rw.RAD2DEG*2*this.angle,r.aspect=1,r.near=100,r.far=2500;let o=new La(this.shadow.camera);o.visible=!1,this._gizmos.shadowmap=o,this.update()}static createFromState(e,t,r){let o=new hn().fromState(t,r);return o.uuid=e,o}get gizmos(){return this._gizmos}showGizmos(){for(let e in this._gizmos){let t=this._gizmos[e];t instanceof La&&(t.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let t=this._gizmos[e];t instanceof La&&(t.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this._gizmos){let t=this._gizmos[e];t instanceof La&&t.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),mm.setFromMatrixPosition(this.matrixWorld),fm.setFromRotationMatrix(this.matrixWorld),hm.copy(this.up).applyQuaternion(fm).negate().multiplyScalar(this.distance),this.target.position.copy(mm).add(hm),this.target.updateMatrixWorld(),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}copy(e,t=!0){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e),r=t.object;return r.objectType="LightSpot",r.color=this.color.getHex(),r.intensity=this.intensity,r.distance=this.distance,r.angle=this.angle,r.decay=this.decay,r.penumbra=this.penumbra,r.shadow=this.shadow.toJSON(),t}fromJSON(e){var o;super.fromJSON(e),this.color.set(e.color),this.intensity=e.intensity,this.distance=e.distance,this.angle=e.angle,this.decay=e.decay,this.penumbra=e.penumbra,this.shadow.normalBias=(o=e.shadow.normalBias)!=null?o:0,this.shadow.radius=e.shadow.radius,this.shadow.mapSize.fromArray(e.shadow.mapSize);let t=this.shadow.camera,r=e.shadow.camera;return t.near=r.near,t.far=r.far,t.zoom=r.zoom,t.fov=r.fov,t.focus=r.focus,t.aspect=r.aspect,t.filmGauge=r.filmGauge,t.filmOffset=r.filmOffset,r.view!==void 0&&(t.view=Object.assign({},r.view)),this}fromSpotLightState(e,t){return super.fromLightState(e,t),e.distance!==void 0&&(this.distance=e.distance),e.decay!==void 0&&(this.decay=e.decay),e.angle!==void 0&&(this.angle=e.angle),e.penumbra!==void 0&&(this.penumbra=e.penumbra),this}fromState(e,t){return super.fromState(e),this.fromSpotLightState(e,t),this}};import{VideoTexture as Uw}from"three";var ym=i=>i.tagName==="VIDEO",Ni=class{static resize(e,t,r){let o=e/t,n;if(!r.image)return;let s=r.image;ym(s)?n=s.videoWidth/s.videoHeight:n=s.width/s.height,o>n&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1*n/o):r.repeat.set(1,1*n/o)),o<n&&(r.imageType=="WEBCAM"?r.repeat.set(1*o/n*-1,1):r.repeat.set(1*o/n,1)),o==n&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1):r.repeat.set(1,1))}static resizeTextureLayer(e,t,r){let o=e/t,n=r.image!==void 0?r.image.width/r.image.height:1,s;o>n?s={x:1,y:n/o}:o<n?s={x:o/n,y:1}:s={x:1,y:1},r.repeat.set(s.x,s.y),r.updateMatrix()}static resizeTextureLayers(e,t,r){let o=r.userData.layers,n=o.getLayers();for(let s=0;s<n.length;s++){let a=n[s];Hh(a)&&(Ni.resizeTextureLayer(e,t,a.uniforms[`f${a.id}_texture`].value),o.updateLayerUniform())}}static resizeComplex(e,t,r,o){let n=e/t,s,a=r.image;ym(a)?s=a.videoWidth/a.videoHeight:s=a.width/a.height,o.geometry.type.includes("Shape")?(n>s&&(r.imageType=="WEBCAM"?r.repeat.set(1/e*-1,1/t*s/n):r.repeat.set(1/e,1/t*s/n)),n<s&&(r.imageType=="WEBCAM"?r.repeat.set(1/e*n/s*-1,1/t):r.repeat.set(1/e*n/s,1/t)),n==s&&(r.imageType=="WEBCAM"?r.repeat.set(1/e*-1,1/t):r.repeat.set(1/e,1/t))):(n>s&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1*s/n):r.repeat.set(1,1*s/n)),n<s&&(r.imageType=="WEBCAM"?r.repeat.set(1*n/s*-1,1):r.repeat.set(1*n/s,1)),n==s&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1):r.repeat.set(1,1)))}};var mn=class extends yt{constructor(e,t=new Nt){super(e,t);this.objectType="Mesh2D";this.castShadow=!0,this.receiveShadow=!0}updateGeometry(e){super.updateGeometry(e),this.material.userData.layers&&Ni.resizeTextureLayers(this.geometry.userData.parameters.width,this.geometry.userData.parameters.height,this.material)}resizeGeometry(e,t){super.resizeGeometry(e,t,0),this.material.userData.layers&&Ni.resizeTextureLayers(this.geometry.userData.parameters.width,this.geometry.userData.parameters.height,this.material)}toJSON(e){let t=super.toJSON(e);return t.object.objectType="Mesh2D",t}clone(){let e=super.clone();return e.updateGeometry({}),e}static fromTexture(e){let t,r;if(e instanceof Uw){let s=e.image;t=s.videoWidth*.5,r=s.videoHeight*.5}else{let s=e.image;t=s.width*.5,r=s.height*.5}let o=Ws.create({parameters:{width:t,height:r}}),n=new Nt;return n.layersList.changeLayer(0,{type:Le.TEXTURE,texture:e}),n.layersList.moveLayer(0,1),n.dispose(),new mn(o,n)}};var fn=class extends yt{constructor(e,t=new or){super(e,t);this.objectType="Mesh3D";this.castShadow=!0,this.receiveShadow=!0}toJSON(e){let t=super.toJSON(e);return t.object.objectType="Mesh3D",t}};var yn=class extends fn{constructor(e,t=new or){super(e,t);this.objectType="NonParametric"}toJSON(e){let t=super.toJSON(e);return t.object.objectType="NonParametric",t}};var gn;(function(t){t[t.TO_RIGHT=1]="TO_RIGHT",t[t.TO_LEFT=-1]="TO_LEFT"})(gn||(gn={}));var pc=class extends yt{constructor(e,t=new Nt({transparent:!0,opacity:1,visible:!1,side:Ta})){super(e,t);this.objectType="TextFrame";this.charContainer=new kw,this.add(this.charContainer),this.material.visible=!1,this._geometryUserData=e.userData,this.userData.textFrame={hexColor:null,opacity:1,visible:!0,text:"",fontSize:16,lineHeight:1.5,letterSpacing:1,fontFamily:"roboto_regular",textTransform:eo.None,horizontalAlignment:1,verticalAlignment:Br.Top,LOD:16,maxLineSize:this._geometryUserData.parameters.width,textOrigin:new xm(this._geometryUserData.parameters.width*-.5,this._geometryUserData.parameters.height*.5,0),textLines:[]},this.createTextLine()}static createFromState(e,t,r){let o=$s.create({parameters:{width:t.width,height:t.height}}),n=new pc(o).fromState(t,r);return n.uuid=e,n}async updateText(e){this.clearText();let t=this.userData.textFrame,r=t.fontFamily;await _t.loadFont(r),t.text=e;let o=t.textOrigin,n=new gm({visible:t.visible,transparent:!0,side:Ta}),s=e.split(`
|
|
958
|
+
`),a=0;this.userData.textFrame.textLines=s.map((l,c)=>{let d=new Po(a,t.lineHeight,t.fontSize);return d.message=l.split("").map(u=>{let p={char:u,fontFamily:r,letterSpacing:t.letterSpacing,fontSize:t.fontSize,LOD:16},f=n.clone();f.color=t.hexColor,f.opacity=t.opacity;let m=new _t(p,f);return d.addChar3D(m,o),this.charContainer.add(m),m}),a+=d.maxCharSize*d.lineHeight,d}),this.textFullUpdate(),this.checkOverFlow()}clearText(){let e=this.userData.textFrame.textLines;for(;this.charContainer.children.length;){let t=this.charContainer.children[0];this.charContainer.remove(t)}for(;e.length;)e.pop()}raycast(e,t){let r=[];if(super.raycast(e,r),r.length>0){t.push(r[0]);return}let o=[];for(let n=0,s=this.charContainer.children.length;n<s;++n)if(this.charContainer.children[n]instanceof _t&&(e.intersectObject(this.charContainer.children[n],!1,o),o.length>0)){o[0].object=this,t.push(o[0]);return}}updateGeometry(e){var c,d,u,p;let t=this.userData,r=this.geometry.userData,o=r.parameters.width,n=r.parameters.height,s=(d=(c=e.parameters)==null?void 0:c.width)!=null?d:o,a=(p=(u=e.parameters)==null?void 0:u.height)!=null?p:n,l=t.textFrame;super.updateGeometry(e),l.maxLineSize=s,l.textOrigin.set(-.5*s,.5*a,0),a!==n?(this.checkOverFlow(),this.checkCapacity()):s!==o&&(o<s?this.checkCapacity():o>s&&this.checkOverFlow())}checkOverFlow(e=0){let t=this.userData,r=t.textFrame.textOrigin,o=t.textFrame.textLines;for(let n=e;n<o.length;n++){o[n].updateYLinePos(this.getNewLinePosition(n)),o[n].fullUpdate(r);let s=[];for(;o[n].checkOverFlow(t.textFrame.maxLineSize);)o[n].containSpaceOverFlow()?s.unshift(o[n].getWord(o[n].message.length-1,-1)):s.unshift(o[n].popChar());if(s.length>0){o[n+1]===void 0?(o[n].isEndLine(!1),this.createTextLine()):o[n].endLine&&(this.createTextLine(n+1),o[n].isEndLine(!1),o[n+1].isEndLine(!0));let a=0;for(let l=0;l<s.length;l+=1)for(let c=0;c<s[l].length;c+=1)o[n+1].addChar3D(s[l][c],r,a),a+=1;o[n+1].fullUpdate(r)}o[n].fullUpdate(r)}this.textFullUpdate(e)}checkCapacity(e=0){let t=this.userData,r=t.textFrame.textOrigin,o=t.textFrame.maxLineSize,n=t.textFrame.textLines;for(let s=e;s<n.length;s+=1)if(n[s].updateYLinePos(this.getNewLinePosition(s)),n[s].fullUpdate(r),!!n[s-1])for(;!n[s-1].endLine;){let a,l=n[s-1].spaceLeft(o);if(n[s].wordSize(0,1)<=l){n[s].containSpace()?a=n[s].getWord(0,1):a=n[s].popChar(0);for(let c=0;c<a.length;c+=1)a[c]&&n[s-1].addChar3D(a[c],r)}else{n[s].isEmpty()?(n[s].endLine&&n[s-1].isEndLine(!0),n.splice(s,1),s-=1):(n[s].updateYLinePos(this.getNewLinePosition(s)),n[s].fullUpdate(r));break}}this.textFullUpdate(e)}createTextLine(e=this.userData.textFrame.textLines.length){let r=this.userData.textFrame;r.textLines.splice(e,0,new Po(this.getNewLinePosition(e),r.lineHeight,r.fontSize))}textFullUpdate(e=0){let r=this.userData.textFrame,o=r.textLines,n=this.getVerticalAlignmentOffSet();for(let s=e;s<o.length;s++)o[s].updateYLinePos(this.getNewLinePosition(s)),o[s].fullUpdate(r.textOrigin),o[s].alignText(r.textOrigin,r.maxLineSize,r.horizontalAlignment,r.verticalAlignment,n)}getVerticalAlignmentOffSet(){switch(this.userData.textFrame.verticalAlignment){case Br.Top:return 0;case Br.Center:return this.getRemainingVerticalSpace()/2;case Br.Bottom:return this.getRemainingVerticalSpace();default:return 0}}getRemainingVerticalSpace(){let t=this.userData.textFrame.textLines;return this.geometry.userData.parameters.height-this.getNewLinePosition(t.length)}getNewLinePosition(e){let r=this.userData.textFrame.textLines,o=0;for(let n=0;n<e;n+=1)o+=r[n].maxCharSize*r[n].lineHeight;return o}updateColor(e){var o;let t=this.userData;t.textFrame.hexColor=e;let r=t.textFrame.textLines;for(let n=0;n<r.length;n++){let s=r[n].message;for(let a=0;a<s.length;a++){let l=s[a].material;((o=l.color)==null?void 0:o.isColor)&&(l.color=e)}}}updateOpacity(e){let t=this.userData;t.textFrame.opacity=e;let r=t.textFrame.textLines;for(let o=0;o<r.length;o++){let n=r[o].message;for(let s=0;s<n.length;s++){let a=n[s].material;a.opacity=e}}}updateVisible(e){let t=this.userData;t.textFrame.visible=e;let r=t.textFrame.textLines;for(let o=0;o<r.length;o++){let n=r[o].message;for(let s=0;s<n.length;s++){let a=n[s].material;a.visible=e}}}async updateFontFamily(e){await _t.loadFont(e);let r=this.userData.textFrame,o=r.textLines;r.fontFamily=e;for(let n=0;n<o.length;n++){let s=o[n].message;for(let a=0;a<s.length;a++)s[a].updateFontFamily(e)}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateFontSize(e){let r=this.userData.textFrame,o=r.textLines,n=r.fontSize;r.fontSize=e;for(let s=0;s<o.length;s++)o[s].updateFontSize(e);this.textFullUpdate(),e>n?this.checkOverFlow():e<n&&this.checkCapacity()}async updateTextTransform(e){let r=this.userData.textFrame;await _t.loadFont(r.fontFamily);let o=r.textLines;switch(r.textTransform=e,e){case eo.Upper:for(let n=0;n<o.length;n++){let s=o[n].message;for(let a=0;a<s.length;a++)o[n].message[a].updateChar(s[a].char.toUpperCase())}break;case eo.Lower:for(let n=0;n<o.length;n++){let s=o[n].message;for(let a=0;a<s.length;a++)o[n].message[a].updateChar(s[a].char.toLowerCase())}break;default:for(let n=0;n<o.length;n++){let s=o[n].message;for(let a=0;a<s.length;a++)o[n].message[a].updateChar(s[a].originalChar)}}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLetterSpacing(e){let t=this.userData,r=t.textFrame.textLines;t.textFrame.letterSpacing=e;for(let o=0;o<r.length;o++){let n=r[o].message;for(let s=0;s<n.length;s++)n[s].updateLetterSpacing(e)}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLOD(e){let t=this.userData;t.textFrame.LOD=e;let r=t.textFrame.textLines;for(let o=0;o<r.length;o++);this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLineHeight(e){let t=this.userData,r=t.textFrame.textLines;t.textFrame.lineHeight=e;for(let o=0;o<r.length;o++)r[o].updatelineHeight(e);this.textFullUpdate()}updateVerticalAlignment(e){let t=this.userData;t.textFrame.verticalAlignment=e,this.textFullUpdate()}updateHorizontalAlignment(e){let t=this.userData;t.textFrame.horizontalAlignment=e,this.textFullUpdate()}toJSON(e){let t=super.toJSON(e),r=t.object;r.objectType="TextFrame";let n=this.userData.textFrame.textLines.map(s=>{let a=s.message.map(l=>({char:l.char,originalChar:l.originalChar,fontFamily:l.fontFamily,letterSpacing:l.letterSpacing,fontSize:l.fontSize,LOD:l.LOD}));return{align:s.align,endLine:s.endLine,lineHeight:s.lineHeight,maxCharSize:s.maxCharSize,yLinePos:s.yLinePos,message:a}});return r.userData.textFrame.textLinesData=n,t}async fromJSONasync(e){if(super.fromJSON(e),e.userData!==void 0){let t=e.userData.textFrame;await _t.loadFont(t.fontFamily),t.textOrigin=new xm(t.textOrigin.x,t.textOrigin.y,t.textOrigin.z);let r=new gm({color:t.hexColor,opacity:t.opacity,visible:t.visible,transparent:!0,side:Ta});t.textLinesData&&(t.textLines=t.textLinesData.map((o,n)=>{let s=new Po(Number(o.yLinePos),Number(o.lineHeight),Number(o.maxCharSize)),a=o.message.map((l,c)=>{if(l.char===void 0){let p=t.textLines[n].message[c];if("geometries"in p){let f=p.geometries[0].userData.parameters;Object.assign(l,{LOD:f.lod,char:f.char,fontFamily:f.fontFamily,fontSize:f.fontSize,letterSpacing:f.letterSpacing,originalChar:f.char})}}let d={char:l.char,fontFamily:l.fontFamily,letterSpacing:Number(l.letterSpacing),fontSize:Number(l.fontSize),LOD:l.LOD},u=new _t(d,r.clone());return s.addChar3D(u,t.textOrigin),this.charContainer.add(u),u});return s.message=a,s}),this.userData.textFrame=t),this.textFullUpdate()}return this}fromTextFrameData(e,t){if(e.color!==void 0){let r=Ye(e.color,t);this.updateColor(r),this.updateOpacity(r.a)}e.alpha!==void 0&&this.updateOpacity(e.alpha),e.font!==void 0&&this.updateFontFamily(e.font),e.horizontalAlign!==void 0&&this.updateHorizontalAlignment(e.horizontalAlign),e.verticalAlign!==void 0&&this.updateVerticalAlignment(e.verticalAlign),e.textTransform!==void 0&&this.updateTextTransform(e.textTransform),e.fontSize!==void 0&&this.updateFontSize(e.fontSize),e.lineHeight!==void 0&&this.updateLineHeight(e.lineHeight),e.letterSpacing!==void 0&&this.updateLetterSpacing(e.letterSpacing),e.text!==void 0&&e.text!==""&&this.updateText(e.text),(e.width!==void 0||e.height!==void 0)&&this.updateGeometry({parameters:{width:e.width,height:e.height}})}fromState(e,t){return super.fromState(e),this.fromTextFrameData(e,t),this}convertToVector(){let{fontFamily:e,hexColor:t}=this.userData.textFrame,r=new co;r.name="Text Shape";let o=_t.fontCache[e];for(let n of this.charContainer.children)n instanceof _t&&o.generateShapes(n.char,1).forEach(s=>{let a=new Pe().fromShape(s);a.applyScale(n.scale.x,n.scale.y);let l=mt.create({shape:a}),c=new Nt({side:Ta});c.color=t;let d=new Oo(l,c);d.name=n.char,d.position.copy(n.position),d.rotation.copy(n.rotation),r.attach(d)});return r}},Ci=pc;Ci.VerticalAlign=Br,Ci.HorizontalAlign=Tt,Ci.TextTransform=eo;import{HemisphereLight as i1,Scene as n1,Vector3 as s1,Color as jm,Fog as a1,Box3 as l1}from"three";import{BufferGeometryLoader as Hw}from"three";function bm(i,e){return qw(i)}function qw(i){let e={parameters:i,type:i.type};if(i.type==="VectorGeometry"){let r=Pe.createFromState(i.shape,i.width,i.height);e.shape=r}else i.type==="NonParametricGeometry"&&(i.data.groups&&i.data.groups.forEach(r=>{var o;return r.materialIndex=Math.max((o=r.materialIndex)!=null?o:0,0)}),e.geometry=new Hw().parse(i));let t;try{t=Ji(e)}catch(r){console.error(r)}if(!t){let r=Pe.createFromState(ai.defaultData(),100,100);e.shape=r,t=Ji(e)}return t}import{Box3 as Ww,Matrix4 as Ao,Sphere as wm,Vector3 as $w}from"three";var Nm=wc(Sm());var uc;Js.then(i=>{uc=i});var Cm=new Ao,Jw=new Ao,Kw=new Ao,ur=new Ww,po=new $w,Xw=new Ao,Zw=new Ao,xn=class extends yt{constructor(e,t,r,o=new or){super(r!=null?r:t,o);this.subdivPointer=e;this.originalGeometry=t;this.subdividedGeometry=r;this.objectType="SubdivObject";this.hiddenMatrixOld=new Ao;this.smoothShading=!0;this.matrixWorldRigid=new Ao;this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!1}static createFromState(e,t,r){let{subdivPointer:o,originalGeometry:n,subdividedGeometry:s}=kt.build(t.geometry,void 0,void 0,!t.flatShading),a=an(t.material,r),l=new xn(o,n,s||void 0,a);return l.calcBoundingBox(),l.freeSubdivPointer(),l.uuid=e,l.fromState(t),l}shallowClone(e){return new yn(this.geometry,this.material).shallowCopy(this,e)}toJSON(e){let t=super.toJSON(e);return t.object.objectType="SubdivObject",t}buildFromStore(e){var n,s,a;let{originalGeometry:t,subdividedGeometry:r,subdivPointer:o}=kt.build(e,this.subdivPointer,void 0,this.smoothShading,this.shearScale);if(this.subdivPointer=o,t!==void 0&&((n=this.originalGeometry)==null||n.dispose(),this.originalGeometry=t),r!==void 0&&((s=this.subdividedGeometry)==null||s.dispose(),this.subdividedGeometry=r!=null?r:void 0),this.geometry=(a=this.subdividedGeometry)!=null?a:this.originalGeometry,this.cloner)for(let l of this.cloner.children)l.geometry=this.geometry;e.width&&(this.geometry.userData.parameters={width:e.width,height:e.height,depth:e.depth})}updateMesh(e=!1){kt.buildLevel(this.subdivPointer,!0,this.smoothShading,this.originalGeometry,e?this.shearScaleInv:void 0),this.subdividedGeometry&&kt.buildLevel(this.subdivPointer,!1,this.smoothShading,this.subdividedGeometry,e?this.shearScaleInv:void 0)}updateTopology(){var e;this.originalGeometry.dispose(),this.originalGeometry=kt.buildLevel(this.subdivPointer,!0,this.smoothShading),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=kt.buildLevel(this.subdivPointer,!1,this.smoothShading)),this.geometry=(e=this.subdividedGeometry)!=null?e:this.originalGeometry}raycast(e,t){var r;this.geometry=this.originalGeometry,yt.prototype.raycast.call(this,e,t),this.geometry=(r=this.subdividedGeometry)!=null?r:this.originalGeometry}updateMatrixWorldSVD(){let e=this.matrixWorld.elements,t=[[e[0],e[4],e[8]],[e[1],e[5],e[9]],[e[2],e[6],e[10]]],{u:r,v:o,q:n}=(0,Nm.SVD)(t),s=Cm.set(r[0][0],r[0][1],r[0][2],0,r[1][0],r[1][1],r[1][2],0,r[2][0],r[2][1],r[2][2],0,0,0,0,1),a=Jw.set(o[0][0],o[0][1],o[0][2],0,o[1][0],o[1][1],o[1][2],0,o[2][0],o[2][1],o[2][2],0,0,0,0,1),l=Kw.copy(a).transpose();this.shearScale=Xw.makeScale(n[0],n[1],n[2]).multiply(l).premultiply(a),this.shearScaleInv=Zw.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(s,l),n.every(c=>Math.abs(n[0]-c)<.01)&&(this.shearScale=void 0,this.shearScaleInv=void 0)}activateSVDCompensation(){this.shearScale!==void 0&&(this.matrixAutoUpdate=!1,this.matrix.copy(this.matrixWorldRigid).copyPosition(this.matrixWorld),this.hiddenMatrixOld.copy(this.hiddenMatrix),this.hiddenMatrix.copy(this.parent.matrixWorld).invert())}deactivateSVDCompensation(){this.shearScale!==void 0&&(this.shearScale=void 0,this.shearScaleInv=void 0,this.matrixAutoUpdate=!0,this.hiddenMatrix.copy(this.hiddenMatrixOld))}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new wm);let t=e.attributes.position,r=e.boundingSphere.center;ur.setFromBufferAttribute(t),ur.getCenter(r),e.boundingSphere.radius=r.distanceTo(ur.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),ur.getSize(po);let o={width:po.x,height:po.y,depth:po.z};return this.geometry.userData.parameters=o,o}updateBoundingBox(e){let t=this.originalGeometry;ur.min.set(e[0],e[2],e[4]),ur.max.set(e[1],e[3],e[5]),this.shearScaleInv&&(ur.min.applyMatrix4(this.shearScaleInv),ur.max.applyMatrix4(this.shearScaleInv)),t.boundingSphere===null&&(t.boundingSphere=new wm);let r=t.boundingSphere.center;ur.getCenter(r),t.boundingSphere.radius=r.distanceTo(ur.max),isNaN(t.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),ur.getSize(po);let o={width:po.x,height:po.y,depth:po.z};return this.geometry.userData.parameters=o,o}freeSubdivPointer(){this.subdivPointer&&(uc.free_bvh(this.subdivPointer),uc.free_subdivision_surface(this.subdivPointer),this.subdivPointer=0)}updateGeometry(e){this.geometry.userData.scale||(this.geometry.userData.scale=Array(3)),this.geometry.userData.scale[0]=this.geometry.userData.parameters.width===0?1:e.parameters.width/this.geometry.userData.parameters.width,this.geometry.userData.scale[1]=this.geometry.userData.parameters.height===0?1:e.parameters.height/this.geometry.userData.parameters.height,this.geometry.userData.scale[2]=this.geometry.userData.parameters.depth===0?1:e.parameters.depth/this.geometry.userData.parameters.depth,Lm(this.originalGeometry.attributes,...this.geometry.userData.scale),this.originalGeometry.attributes.position.needsUpdate=!0,this.originalGeometry.attributes.normal.needsUpdate=!0,this.subdividedGeometry&&(Lm(this.subdividedGeometry.attributes,...this.subdividedGeometry.userData.scale),this.subdividedGeometry.attributes.position.needsUpdate=!0,this.subdividedGeometry.attributes.normal.needsUpdate=!0),this.geometry.userData.parameters=O({},e.parameters)}};function Lm(i,e,t,r){let o=i.position.array,n=i.normal.array,s=Cm.makeScale(e,t,r).invert().elements,a,l,c;for(var d=0,u=o.length;d<u;d+=3)o[d]*=e,o[d+1]*=t,o[d+2]*=r,a=n[d],l=n[d+1],c=n[d+2],n[d]=s[0]*a+s[4]*l+s[8]*c,n[d+1]=s[1]*a+s[5]*l+s[9]*c,n[d+2]=s[2]*a+s[6]*l+s[10]*c}import{BackSide as Qw,DoubleSide as Yw,FrontSide as e1}from"three";function Tm(i,e){e.flatShading!==void 0&&(i.flatShading=e.flatShading,i.needsUpdate=!0),e.wireframe!==void 0&&(i.wireframe=e.wireframe),e.side!==void 0&&(e.side===oi.Front?i.side=e1:e.side===oi.Back?i.side=Qw:i.side=Yw)}function t1(i,e){if(Array.isArray(i.material))for(let t of i.material)Tm(t,e);else{let t=i.material;Tm(t,e)}i.objectType==="SubdivObject"&&e.flatShading!==void 0&&(i.material.flatShading=!1,i.smoothShading=!e.flatShading,i.updateMesh())}function Im(i,e,t){let r;if(e.geometry.type==="SubdivGeometry")r=xn.createFromState(i,e,t);else{let o=bm(e.geometry,t),n="materials"in e?om(e.materials,t):an(e.material,t);Ts.is2DParametricMesh(o.userData.type)?r=new mn(o,n):(o==null?void 0:o.userData.type)==="VectorGeometry"?r=new Oo(o,n):e.geometry.type==="NonParametricGeometry"?r=new yn(o,n):r=new fn(o,n),r.uuid=i,r.fromState(e)}return t1(r,e),r}function Mm(i,e,t){return e.type==="Mesh"?Im(i,e,t):e.type==="TextFrame"?Ci.createFromState(i,e,t):e.type==="Empty"?co.createFromState(i,e):e.type==="PointLight"?un.createFromState(i,e,t):e.type==="SpotLight"?hn.createFromState(i,e,t):e.type==="DirectionalLight"?pn.createFromState(i,e,t):Qo.is(e.type)?lo.createFromState(i,e):(console.error(e),new co)}function r1(i,e){e.uniforms[`f${e.id}_transmissionSamplerMap`].value=i.texture,e.uniforms[`f${e.id}_transmissionDepthMap`].value=i.depthTexture}function Pm(i,e,t){if(!t.userData.layers)return!1;let r=!1,o=t.userData.layers.getLayersOfType(Le.TRANSMISSION);return o.length>0?(e.layers.set(3),r=!0,i!==void 0&&o.forEach(n=>r1(i,n))):e.layers.set(0),r}function Om(i,e){let t=!1;return e.traverseEntity(r=>{if(r instanceof yt)if(Array.isArray(r.material))for(let o=0;o<r.material.length;o++)Pm(i,r,r.material[o])&&(t=!0);else Pm(i,r,r.material)&&(t=!0)}),t}function Am(i,e){"material"in i&&o1(i.material,e),"geometry"in i&&i.geometry.dispose()}function o1(i,e){Nc(i).forEach(t=>{e.isSharedMaterial(t)||t.dispose()})}var _m=new s1,hc=class extends ea(n1){constructor(e,t){super();this.objectType="Scene";this.alpha=1;this.backupFog=new a1(16777215,.1,2e3);this.fogUseBGColor=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this._needsTransmission=!1;this._color=new jm(1,0,0);this.bgColor=new jm(1,1,1);this.entityByUuid={};this.ambientLight=new i1(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.personalCamera=this.createPersonalCamera(),this.activeCamera=this.personalCamera,this.sharedAssetManager=t,this.init(e,t)}needsTransmission(e){return this.needsTransmissionDirty&&(this._needsTransmission=Om(e,this),e!==void 0&&(this.needsTransmissionDirty=!1)),this._needsTransmission}find(e){if(e===""||e===void 0)return;let t=this.entityByUuid[e];return t===void 0?this.getObjectByProperty("uuid",e):t}get color(){return this._color}set color(e){this.fogUseBGColor===!0&&this.backupFog.color.copy(e),this._color.copy(e)}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(Ye(e.backgroundColor,t)),this.updateFog(e.fog,t),this.updateAmbientLight(e.environment.ambientLight,t),this.activeCamera=this.personalCamera,e.publish.playCamera!==null){let r=this.find(e.publish.playCamera);r instanceof lo&&this.switchActiveCamera(r)}}clearScene(e){this.traverseEntity(t=>{Am(t,e)});for(let t of this.children)er(t)&&t.removeFromParent()}resetAfterClear(e,t){this.init(e,t)}createPersonalCamera(){let e=lo.createFromState(hc.PERSONAL_CAMERA_ID,$(O({},Ms.defaultData),{name:"Personal Camera"}));return e.enableHelper=!1,e.objectHelper.visible=!1,delete e.isEntity,this.registerObjectCreatedInLegacy(e),e}raycast(e){let t=[],r=o=>{for(let n of o.children)er(n)&&!n.raycastLock&&n.visible&&((Xs(n)||Er(n)&&n.enableHelper&&n.objectHelper.parent)&&e.intersectObject(n,!1,t),r(n))};return r(this),t}traverseEntity(e){for(let t of this.children)er(t)&&t.traverseEntity(e)}updateFog(e,t){this.enableFog=e.enabled,this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=Ye(e.color,t),this.backupFog.near=e.near,this.backupFog.far=e.far}toJSON(e){return{}}fromJSON(e){return this}dispose(){this.clearScene(this.sharedAssetManager),this.sharedAssetManager.dispose()}updateAmbientLight(e,t){wh(this.ambientLight,e,t),e.groundColor!==void 0&&(this.ambientLight.groundColor=Ye(e.groundColor,t)),e.enabled!==void 0&&(this.ambientLight.visible=e.enabled)}switchActiveCamera(e){this.activeCamera!==this.personalCamera&&(this.activeCamera.enableHelper=!0),this.activeCamera=e,e.enableHelper=!1}setBackgroundColor(e){this.bgColor=e,this.alpha=e.a}createChildrenObjects(e,t,r){for(let o of e)this.createChildObject(o.id,o.data,o.children,t,r)}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let t of e.children)this.unregisterObject(t)}createChildObject(e,t,r,o,n){let s=Mm(e,t,n);return s&&(this.entityByUuid[e]=s,o.add(s),this.createChildrenObjects(r,s,n)),s}getCenter(e){let t=[];for(let o=0,n=e.length;o<n;++o){let{id:s,recursive:a}=e[o],l=this.find(s),c=a?l.recursiveBBox:l.singleBBox;t.push(...c.vertices)}let r=new l1;return r.setFromPoints(t),r.getCenter(_m),_m}copyMatrixWorld(e,t){if(e===null){t.identity();return}let r=this.find(e);r?t.copy(r.matrixWorld):t.identity()}copyParentMatrixWorld(e,t){var o;if(e===null){t.identity();return}let r=(o=this.find(e))==null?void 0:o.parent;r?t.copy(r.matrixWorld):t.identity()}traverseMaterial(e){this.traverseEntity(t=>{if(t instanceof yt)if(Array.isArray(t.material))for(let r=0;r<t.material.length;r++)e(t.material[r]);else e(t.material)})}updateCanvasSize(e,t){this.activeCamera.setViewplaneSize(e,t);let r,o;e>=t?(r=t/e,o=1):(r=1,o=e/t),this.traverseMaterial(n=>{n.layersList.getLayersOfType(Le.TRANSMISSION).forEach(a=>{a.uniforms[`f${a.id}_aspectRatio`].value.x=r,a.uniforms[`f${a.id}_aspectRatio`].value.y=o})})}},Ma=hc;Ma.PERSONAL_CAMERA_ID="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera";import{WebGLRenderTarget as c1,LinearMipmapLinearFilter as d1,LinearFilter as p1,ClampToEdgeWrapping as Dm,DepthTexture as u1}from"three";var Bm=new Nt,mc=class extends Ht{},fc=class{constructor(e){this.materials={};this.images={};this.colors={};this.transmissionRenderTarget=new c1(2048,2048,{generateMipmaps:!0,minFilter:d1,magFilter:p1,wrapS:Dm,wrapT:Dm}),this.transmissionRenderTarget.depthTexture=new u1(2048,2048),this.reset(e)}reset(e){for(let[t,r]of Object.entries(e.images))this.addImage(t,r.data);for(let[t,r]of Object.entries(e.colors))this.addColor(t,r);for(let[t,r]of Object.entries(e.materials))this.addMaterial(t,nc(r,this))}get transmissionSamplerMap(){return this.transmissionRenderTarget.texture}get transmissionDepthMap(){return this.transmissionRenderTarget.depthTexture}addMaterial(e,t){t.uuid=e,this.materials[e]=t}deleteMaterial(e){this.materials[e]&&(this.materials[e].dispose(),delete this.materials[e])}isSharedMaterial(e){return e.uuid in this.materials||e===Bm}getMaterial(e){let t=this.materials[e];return t}getMaterialOrDeletedPlaceholder(e){var t;return(t=this.materials[e])!=null?t:Bm}getMaterials(){return this.materials}addImage(e,t){if(this.images[e])return this.images[e].onload=()=>{this.onImageLoad&&this.onImageLoad(e)},this.images[e].src=t,!0;{let r=new Image;return r.src=t,r.onload=()=>{this.onImageLoad&&this.onImageLoad(e)},this.images[e]=r,!1}}deleteImage(e){this.images[e]&&delete this.images[e]}getDefaultImage(){return this.images.image_0}getImage(e){return this.images[e]}getImages(){return this.images}addColor(e,t){return this.colors[e]?("a"in t?this.colors[e].setRGBA(t.r,t.g,t.b,t.a):this.colors[e].setRGBA(t.r,t.g,t.b,1),!0):("a"in t?this.colors[e]=new mc(t.r,t.g,t.b,t.a):this.colors[e]=new mc(t.r,t.g,t.b,1),!1)}updateColor(e,t){var r,o,n,s;if(this.colors[e]){let a=this.colors[e];return this.colors[e].r=(r=t.r)!=null?r:a.r,this.colors[e].g=(o=t.g)!=null?o:a.g,this.colors[e].b=(n=t.b)!=null?n:a.b,this.colors[e].a=(s=t.a)!=null?s:a.a,!0}return!1}deleteColor(e){this.colors[e]&&delete this.colors[e]}getColor(e){return this.colors[e]}dispose(){Object.keys(this.materials).forEach(t=>this.deleteMaterial(t)),this.transmissionRenderTarget.depthTexture.dispose(),this.transmissionRenderTarget.dispose(),this.onImageLoad=void 0}};var Gm=class extends m1{load(e,t,r,o=console.error){let n=new h1(this.manager);n.setPath(this.path),n.setResponseType("arraybuffer"),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),n.load(e,s=>{try{if(typeof s=="string")throw new Error("The .spline file is not binary!");t(this.parse(s))}catch(a){o(a)}},r,o)}parse(e){let t=xs.deserialize(new Uint8Array(e)),r=new fc(t.shared);return new Ma(t.scene,r)}};export{Gm as default};
|